diff --git a/demo-widget b/demo-widget deleted file mode 160000 index 2489060e09630dff334e88b8e51e1efa1bfa1989..0000000000000000000000000000000000000000 --- a/demo-widget +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2489060e09630dff334e88b8e51e1efa1bfa1989 diff --git a/demo/$(pwd)/logs/application.log b/demo/$(pwd)/logs/application.log new file mode 100644 index 0000000000000000000000000000000000000000..a8af82d2235332a4c44c79f84907bc04344ab15d --- /dev/null +++ b/demo/$(pwd)/logs/application.log @@ -0,0 +1,6 @@ +time="2022-11-02T16:37:36+08:00" level=warning msg="Can't load env file. open /home/zhoushimin/workspace/github/1024opensource/demo-widget/$(pwd)/.env: no such file or directory" +time="2022-11-02T16:37:36+08:00" level=warning msg="Can't load env file. open /home/zhoushimin/workspace/github/1024opensource/demo-widget/$(pwd)/.env: no such file or directory" +time="2022-11-02T16:37:36+08:00" level=warning msg="Can't load env file. open /home/zhoushimin/workspace/github/1024opensource/demo-widget/$(pwd)/.env: no such file or directory" +time="2022-11-02T16:38:14+08:00" level=warning msg="Can't load env file. open /home/zhoushimin/workspace/github/1024opensource/demo-widget/$(pwd)/.env: no such file or directory" +time="2022-11-02T16:40:07+08:00" level=warning msg="Can't load env file. open /home/zhoushimin/workspace/github/1024opensource/demo-widget/$(pwd)/.env: no such file or directory" +time="2022-11-02T16:41:13+08:00" level=warning msg="Can't load env file. open /home/zhoushimin/workspace/github/1024opensource/demo-widget/$(pwd)/.env: no such file or directory" diff --git a/demo/.gitignore b/demo/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..dcdd0cb2e47ea8f2a554341c7b4800012f070fc2 --- /dev/null +++ b/demo/.gitignore @@ -0,0 +1,5 @@ +.env +logs/application.log +data/.session.db +db/yao.db +.DS_Store diff --git a/demo/LICENSE b/demo/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/demo/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/demo/README.md b/demo/README.md new file mode 100644 index 0000000000000000000000000000000000000000..15e22e290d53c7ffa5fc6e484c3e7b57d327c45e --- /dev/null +++ b/demo/README.md @@ -0,0 +1,77 @@ +# YAO Widget DEMO + +![Image](docs/images/intro.png) + +[中文介绍](README.zh-CN.md) + +YAO Widget DEMO + +Documentation: [https://yaoapps.com/en-US/doc](https://yaoapps.com/en-US/doc/Introduction/Getting%20Started) + +## USAGE + +### Docker + +```bash +docker run -d -p 5099:5099 --restart unless-stopped \ + -e YAO_INIT=reset \ + -e YAO_PROCESS_RESET=flows.setmenu \ + yaoapp/demo-widget:1.0.0-amd64 +``` + +### Yao + +#### Download source code + +```bash +git clone https://github.com/YaoApp/demo-widget /app/path/widget + +``` + +#### Set the environment variables + +```bash +mkdir /app/path/widget/db +mkdir /app/path/widget/data +mkdir /app/path/widget/logs + +cat << EOF +YAO_ENV=development # development | production +YAO_ROOT="/app/path/widget" +YAO_HOST="0.0.0.0" +YAO_PORT="5099" +YAO_SESSION="memory" +YAO_LOG="/app/path/widget/logs/application.log" +YAO_LOG_MODE="TEXT" # TEXT | JSON +YAO_JWT_SECRET="bLp@bi!oqo-2U+hoTRUG" +YAO_DB_DRIVER=sqlite3 # sqlite3 | mysql +YAO_DB_PRIMARY="/app/path/widget/db/yao.db" +EOF > /app/path/widget/.env +``` + +#### Initialization + +```bash +cd /app/path/widget + +# Create tables & set menu +yao migrate --reset +yao run flows.setmenu + +``` + +#### Start the service + +```bash +cd /app/path/widget +yao start +``` + +## ADMIN + +Open the browser to visit the URL: + +http://127.0.0.1:5099/xiang/login/admin + +User Name: `xiang@iqka.com` +Password: `A123456p+` diff --git a/demo/README.zh-CN.md b/demo/README.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..0a250a479e65ff7b9f6105d2ee6e1ae0cb25fc25 --- /dev/null +++ b/demo/README.zh-CN.md @@ -0,0 +1,79 @@ +# YAO Widget DEMO + +![Image](docs/images/intro.png) + +[English](README.md) + +云表格 DEMO + +参考文档: [https://yaoapps.com/doc](https://yaoapps.com/doc/%E6%95%99%E7%A8%8B/%E4%BD%BF%E7%94%A8%20YAO%20Widget%20%E8%87%AA%E5%BB%BA%E4%BA%91%E8%A1%A8%E6%A0%BC) + +## 下载安装 + +### 使用 Docker 运行 + +```bash +docker run -d -p 5099:5099 --restart unless-stopped \ + -e YAO_INIT=demo \ + -e YAO_PROCESS_RESET=flows.init.menu \ + -e YAO_PROCESS_DEMO=flows.demo.data \ + yaoapp/demo-widget:1.0.3-amd64 +``` + +### 在本地运行 + +#### 下载源码 + +```bash +git clone https://github.com/YaoApp/demo-widget /app/path/widget + +``` + +#### 设置环境变量 + +```bash +mkdir /app/path/widget/db +mkdir /app/path/widget/data +mkdir /app/path/widget/logs + +cat << EOF +YAO_ENV=development # development | production +YAO_ROOT="/app/path/widget" +YAO_HOST="0.0.0.0" +YAO_PORT="5099" +YAO_SESSION="memory" +YAO_LOG="/app/path/widget/logs/application.log" +YAO_LOG_MODE="TEXT" # TEXT | JSON +YAO_JWT_SECRET="bLp@bi!oqo-2U+hoTRUG" +YAO_DB_DRIVER=sqlite3 # sqlite3 | mysql +YAO_DB_PRIMARY="/app/path/widget/db/yao.db" +EOF > /app/path/widget/.env +``` + +#### 项目初始化 + +```bash +cd /app/path/widget + +# 创建数据表 & 设置菜单 +yao migrate --reset +yao run flows.setmenu + + +``` + +#### 启动服务 + +```bash +cd /app/path/widget +yao start +``` + +## 管理后台 + +打开浏览器输入以下网址进入: + +http://127.0.0.1:5099/xiang/login/admin + +用户名: `xiang@iqka.com` +密码: `A123456p+` diff --git a/demo/apis/page.http.json b/demo/apis/page.http.json new file mode 100644 index 0000000000000000000000000000000000000000..bb5b401591dd88e9517c2beace75f078fde20b8a --- /dev/null +++ b/demo/apis/page.http.json @@ -0,0 +1,17 @@ +{ + "name": "选项接口", + "version": "1.0.0", + "description": "选项接口", + "group": "page", + "guard": "-", + "paths": [ + { + "path": "/form/setting/:name", + "method": "GET", + "guard": "-", + "process": "xiang.table.Setting", + "in": ["$param.name", ":query"], + "out": { "status": 200, "type": "application/json" } + } + ] +} diff --git a/demo/app.json b/demo/app.json new file mode 100644 index 0000000000000000000000000000000000000000..5add0f29398a8f5b269e5b271a3cc0abd9427d2a --- /dev/null +++ b/demo/app.json @@ -0,0 +1,12 @@ +{ + "name": "Widget Demo", + "short": "Widget", + "description": "Widget demo app", + "option": { + "nav_user": "xiang.user", + "nav_menu": "xiang.menu", + "hide_user": false, + "hide_menu": false, + "login": { "entry": { "admin": "/table/template" } } + } +} diff --git a/demo/docs/images/intro.png b/demo/docs/images/intro.png new file mode 100644 index 0000000000000000000000000000000000000000..8f4a2ac613dee308c03aa8d623990b079f0c8542 Binary files /dev/null and b/demo/docs/images/intro.png differ diff --git a/demo/dyforms/demo.form.json b/demo/dyforms/demo.form.json new file mode 100644 index 0000000000000000000000000000000000000000..61ca5c20e0935bd5e170dc9e015b7be58c6e95d1 --- /dev/null +++ b/demo/dyforms/demo.form.json @@ -0,0 +1,32 @@ +{ + "name": "TEST", + "decription": "A TEST DYFORM", + "columns": [ + { + "title": "First Name", + "name": "name", + "type": "input", + "search": true, + "props": { + "placeholder": "Please input your first name" + } + }, + { + "title": "Amount", + "name": "amount", + "type": "input", + "search": true, + "props": { + "placeholder": "Please input amount" + } + }, + { + "title": "Description", + "name": "desc", + "type": "textArea", + "props": { + "placeholder": "Please input Description" + } + } + ] +} diff --git a/demo/flows/setmenu.flow.json b/demo/flows/setmenu.flow.json new file mode 100644 index 0000000000000000000000000000000000000000..98b2d806d78a3877a435924c8a4e2ed72c06a207 --- /dev/null +++ b/demo/flows/setmenu.flow.json @@ -0,0 +1,57 @@ +{ + "label": "System Menu", + "version": "1.0.0", + "description": "Initialize system menu", + "nodes": [ + { + "name": "Clean menu data", + "engine": "xiang", + "query": { + "sql": { "stmt": "delete from xiang_menu" } + } + }, + { + "name": "Add new menu", + "process": "models.xiang.menu.Insert", + "args": [ + [ + "id", + "name", + "path", + "icon", + "rank", + "status", + "parent", + "visible_menu", + "blocks" + ], + [ + [ + 1, + "Template", + "/table/template", + "icon-grid", + 1, + "enabled", + null, + 0, + 0 + ], + [ + 2, + "Tables", + "/table/dyform.demo", + "icon-database", + 1, + "enabled", + null, + 1, + 0 + ], + [3, "Demo", "/table/dyform.demo", null, 1, "enabled", 2, 1, 0] + ] + ] + } + ], + "output": "done" +} diff --git a/demo/libs/f.json b/demo/libs/f.json new file mode 100644 index 0000000000000000000000000000000000000000..bdd516da0ae7a46cca83efe971c13e43935eac2b --- /dev/null +++ b/demo/libs/f.json @@ -0,0 +1,14 @@ +{ + "Keywords": { + "__comment": "{ '@': 'f.Keywords', 'in': ['where.name.match']}", + "label": "Keywords", + "bind": "{{$in.0}}", + "input": { + "type": "input", + "props": { + "placeholder": "type Keywords..." + } + } + } + } + \ No newline at end of file diff --git a/demo/models/template.mod.json b/demo/models/template.mod.json new file mode 100644 index 0000000000000000000000000000000000000000..36105d1e6feafa7757f2ce470f0a3848267b8622 --- /dev/null +++ b/demo/models/template.mod.json @@ -0,0 +1,29 @@ +{ + "name": "Template", + "table": { "name": "template", "comment": "For dyform DSL source" }, + "columns": [ + { "label": "ID", "name": "id", "type": "ID", "comment": "ID" }, + { + "label": "INSTANCE", + "name": "instance", + "type": "string", + "unique": true + }, + { + "label": "SN", + "name": "sn", + "type": "string", + "nullable": true, + "unique": true + }, + { "label": "Name", "name": "name", "type": "string", "index": true }, + { + "label": "DSL", + "name": "dsl", + "type": "text", + "comment": "DSL" + } + ], + "values": [], + "option": { "timestamps": true, "soft_deletes": true } +} diff --git a/demo/scripts/template.js b/demo/scripts/template.js new file mode 100644 index 0000000000000000000000000000000000000000..54b7658604c92c43f11c4c7f2e9ec9cc813866ad --- /dev/null +++ b/demo/scripts/template.js @@ -0,0 +1,157 @@ +/** + * AfterSave Hook: upgrade the instance shcema + */ +function AfterSave(id, payload) { + payload = payload || {}; + if (!payload.dsl) { + return id; + } + + var dsl = {}; + try { + dsl = JSON.parse(payload.dsl); + } catch (e) { + log.Error("After Save: %s", e.message); + return id; + } + + // Save schema + const instance = `instance_${id}`; + var res = Process("widgets.dyform.Save", instance, dsl); + if (!res) { + log.Error("After Save: upgrade schema error"); + return id; + } + + // Add Menu items + setMenu(instance, dsl.name ? dsl.name : instance); + + return id; +} + +/** + * AfterDelete Hook: remove the instance shcema + */ +function AfterDelete(params, id) { + // Remove schema + const instance = `instance_${id}`; + Process("widgets.dyform.Delete", instance); + removeMenu(instance); + return id; +} + +/** + * AfterFind Hook: transform the DSL format to the form editor needs + * @param {*} id + * @param {*} template + */ +function AfterFind(template, id) { + let dsl = JSON.parse(template["dsl"]); + let columns = dsl.columns || []; + let types = { input: "Input", select: "Select" }; + + template["dsl"] = []; + columns.forEach((column) => { + // let props = column.props || {}; + // let search = props.showSearch ? true : false; + template["dsl"].push({ + title: column.title, + bind: column.name, + id: types[column.type], + props: column.props || {}, + search: true, + width: 6, + chosen: false, + selected: false, + }); + }); + + return template; +} + +/** + * BeforSave Hook: transform the form editor data to the DSL + * @param {*} payload + */ +function BeforeSave(payload) { + payload = payload || {}; + columns = payload.dsl || []; + payload["dsl"] = { columns: [], name: payload.name || "UNTITLE" }; + columns.forEach((column) => { + let type = column.id || ""; + payload["dsl"].columns.push({ + title: column.title || "UNTITLE", + name: column.bind, + type: type.toLowerCase(), + props: column.props || {}, + }); + }); + payload["dsl"] = JSON.stringify(payload["dsl"]); + return [payload]; +} + +/** + * Remove menu item + * @debug + * yao run scripts.template.removeMenu instance_1 + * + * @param {*} instance + */ +function removeMenu(instance) { + const path = `/table/dyform.${instance}`; + Process("models.xiang.menu.DestroyWhere", { + wheres: [{ column: "path", value: path }], + }); +} + +/** + * Set Menu + * + * @debug + * yao run scripts.template.setMenu instance_1 Foo + * + * @param {*} instance + * @param {*} title + * @returns + */ +function setMenu(instance, title) { + var parentItem = new Query().Get({ + select: ["id"], + from: "xiang_menu", + wheres: [{ ":name": "名称", "=": "Tables" }], + limit: 1, + }); + + var parent_id = parentItem.length > 0 ? parentItem[0].id : null; + if (parent_id == null) { + return; + } + + const path = `/table/dyform.${instance}`; + var menu = { + name: title, + parent: parent_id, + path: path, + rank: 1, + status: "enabled", + visible_menu: 1, + blocks: 0, + }; + + var items = Process("models.xiang.menu.Get", { + select: ["id"], + wheres: [{ column: "path", value: path }], + limit: 1, + }); + + if (items.code && items.message) { + log.Error("After Save: save menu %s", items.message); + return id; + } + + if (items.length > 0) { + menu["id"] = items[0].id; + } + + Process("models.xiang.menu.Save", menu); +} diff --git a/demo/tables/template.tab.json b/demo/tables/template.tab.json new file mode 100644 index 0000000000000000000000000000000000000000..b620aac21b70af4ef4aa40930f9c2f1eb0852445 --- /dev/null +++ b/demo/tables/template.tab.json @@ -0,0 +1,65 @@ +{ + "name": "Template", + "version": "1.0.0", + "decription": "Form Templates", + "bind": { "model": "template" }, + "apis": {}, + "hooks": { + "after:find": "scripts.template.AfterFind", + "before:save": "scripts.template.BeforeSave", + "after:save": "scripts.template.AfterSave", + "after:delete": "scripts.template.AfterDelete" + }, + "columns": { + "ID": { + "label": "ID", + "view": { "type": "label", "props": { "value": ":id" } } + }, + "Form Name": { + "label": "Form Name", + "view": { "type": "label", "props": { "value": ":name" } }, + "edit": { "type": "input", "props": { "value": ":name" } } + }, + "Form Editor": { + "label": "Form Editor", + "edit": { "type": "FormPrinter", "props": { "value": ":dsl" } } + } + }, + "filters": { "Keywords": { "@": "f.Keywords", "in": ["where.name.match"] } }, + "list": { + "primary": "id", + "layout": { + "columns": [ + { "name": "ID", "width": 80 }, + { "name": "Name", "width": 200 } + ], + "filters": [{ "name": "Keywords" }] + }, + "actions": { + "pagination": { "props": { "showTotal": true } }, + "create": { + "props": { "label": "Create" } + } + }, + "option": { "operation": { "unfold": true } } + }, + "edit": { + "primary": "id", + "layout": { + "fieldset": [ + { + "columns": [ + { "name": "Form Name", "width": 24 }, + { "name": "Form Editor", "width": 24 } + ] + } + ] + }, + "actions": { + "cancel": {}, + "save": {}, + "delete": { "type": "button", "props": { "label": "Delete" } } + }, + "option": { "dev": false } + } +} diff --git a/demo/tests/demo.form.json b/demo/tests/demo.form.json new file mode 100644 index 0000000000000000000000000000000000000000..e35df1b77a778db5023b9d30f71b1e67852ac15b --- /dev/null +++ b/demo/tests/demo.form.json @@ -0,0 +1,30 @@ +{ + "columns": [ + { + "title": "First Name", + "name": "name", + "type": "input", + "search": true, + "props": { + "placeholder": "Please input your first name" + } + }, + { + "title": "Amount", + "name": "amount", + "type": "input", + "search": true, + "props": { + "placeholder": "Please input amount" + } + }, + { + "title": "Description", + "name": "desc", + "type": "textArea", + "props": { + "placeholder": "Please input Description" + } + } + ] +} diff --git a/demo/ui/index.html b/demo/ui/index.html new file mode 100644 index 0000000000000000000000000000000000000000..86e3bccc24f447a83f6b03a0ef5ca875ffeb8c76 --- /dev/null +++ b/demo/ui/index.html @@ -0,0 +1 @@ +It works! https://yaoapps.com \ No newline at end of file diff --git a/demo/ui/vue3/assets/index.0a966209.js b/demo/ui/vue3/assets/index.0a966209.js new file mode 100644 index 0000000000000000000000000000000000000000..b9570d08e81d3ffb829430e7052c536645a7bd2b --- /dev/null +++ b/demo/ui/vue3/assets/index.0a966209.js @@ -0,0 +1 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerpolicy&&(i.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?i.credentials="include":r.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function yn(e,t){const n=Object.create(null),s=e.split(",");for(let r=0;r!!n[r.toLowerCase()]:r=>!!n[r]}const wr="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",Er=yn(wr);function xs(e){return!!e||e===""}function wn(e){if(P(e)){const t={};for(let n=0;n{if(n){const s=n.split(Or);s.length>1&&(t[s[0].trim()]=s[1].trim())}}),t}function En(e){let t="";if(z(e))t=e;else if(P(e))for(let n=0;nz(e)?e:e==null?"":P(e)||J(e)&&(e.toString===Cs||!A(e.toString))?JSON.stringify(e,ys,2):String(e),ys=(e,t)=>t&&t.__v_isRef?ys(e,t.value):ke(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[s,r])=>(n[`${s} =>`]=r,n),{})}:ws(t)?{[`Set(${t.size})`]:[...t.values()]}:J(t)&&!P(t)&&!Os(t)?String(t):t,L={},Ye=[],oe=()=>{},vr=()=>!1,Ir=/^on[^a-z]/,jt=e=>Ir.test(e),Cn=e=>e.startsWith("onUpdate:"),Z=Object.assign,On=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},Pr=Object.prototype.hasOwnProperty,M=(e,t)=>Pr.call(e,t),P=Array.isArray,ke=e=>$t(e)==="[object Map]",ws=e=>$t(e)==="[object Set]",A=e=>typeof e=="function",z=e=>typeof e=="string",Tn=e=>typeof e=="symbol",J=e=>e!==null&&typeof e=="object",Es=e=>J(e)&&A(e.then)&&A(e.catch),Cs=Object.prototype.toString,$t=e=>Cs.call(e),Ar=e=>$t(e).slice(8,-1),Os=e=>$t(e)==="[object Object]",vn=e=>z(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,vt=yn(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Ht=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Fr=/-(\w)/g,pe=Ht(e=>e.replace(Fr,(t,n)=>n?n.toUpperCase():"")),Mr=/\B([A-Z])/g,Ve=Ht(e=>e.replace(Mr,"-$1").toLowerCase()),Lt=Ht(e=>e.charAt(0).toUpperCase()+e.slice(1)),Vt=Ht(e=>e?`on${Lt(e)}`:""),at=(e,t)=>!Object.is(e,t),Gt=(e,t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},Nr=e=>{const t=parseFloat(e);return isNaN(t)?e:t};let Jn;const Rr=()=>Jn||(Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let ue;class jr{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&ue&&(this.parent=ue,this.index=(ue.scopes||(ue.scopes=[])).push(this)-1)}run(t){if(this.active){const n=ue;try{return ue=this,t()}finally{ue=n}}}on(){ue=this}off(){ue=this.parent}stop(t){if(this.active){let n,s;for(n=0,s=this.effects.length;n{const t=new Set(e);return t.w=0,t.n=0,t},Ts=e=>(e.w&Ae)>0,vs=e=>(e.n&Ae)>0,Hr=({deps:e})=>{if(e.length)for(let t=0;t{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s{(d==="length"||d>=s)&&c.push(u)});else switch(n!==void 0&&c.push(o.get(n)),t){case"add":P(e)?vn(n)&&c.push(o.get("length")):(c.push(o.get(He)),ke(e)&&c.push(o.get(cn)));break;case"delete":P(e)||(c.push(o.get(He)),ke(e)&&c.push(o.get(cn)));break;case"set":ke(e)&&c.push(o.get(He));break}if(c.length===1)c[0]&&fn(c[0]);else{const u=[];for(const d of c)d&&u.push(...d);fn(In(u))}}function fn(e,t){const n=P(e)?e:[...e];for(const s of n)s.computed&&kn(s);for(const s of n)s.computed||kn(s)}function kn(e,t){(e!==re||e.allowRecurse)&&(e.scheduler?e.scheduler():e.run())}const Sr=yn("__proto__,__v_isRef,__isVue"),As=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(Tn)),Ur=An(),Br=An(!1,!0),Dr=An(!0),Xn=Kr();function Kr(){const e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...n){const s=j(this);for(let i=0,o=this.length;i{e[t]=function(...n){Ge();const s=j(this)[t].apply(this,n);return et(),s}}),e}function An(e=!1,t=!1){return function(s,r,i){if(r==="__v_isReactive")return!e;if(r==="__v_isReadonly")return e;if(r==="__v_isShallow")return t;if(r==="__v_raw"&&i===(e?t?ri:js:t?Rs:Ns).get(s))return s;const o=P(s);if(!e&&o&&M(Xn,r))return Reflect.get(Xn,r,i);const c=Reflect.get(s,r,i);return(Tn(r)?As.has(r):Sr(r))||(e||te(s,"get",r),t)?c:k(c)?o&&vn(r)?c:c.value:J(c)?e?$s(c):Nn(c):c}}const Wr=Fs(),zr=Fs(!0);function Fs(e=!1){return function(n,s,r,i){let o=n[s];if(dt(o)&&k(o)&&!k(r))return!1;if(!e&&!dt(r)&&(un(r)||(r=j(r),o=j(o)),!P(n)&&k(o)&&!k(r)))return o.value=r,!0;const c=P(n)&&vn(s)?Number(s)e,St=e=>Reflect.getPrototypeOf(e);function yt(e,t,n=!1,s=!1){e=e.__v_raw;const r=j(e),i=j(t);n||(t!==i&&te(r,"get",t),te(r,"get",i));const{has:o}=St(r),c=s?Fn:n?jn:ht;if(o.call(r,t))return c(e.get(t));if(o.call(r,i))return c(e.get(i));e!==r&&e.get(t)}function wt(e,t=!1){const n=this.__v_raw,s=j(n),r=j(e);return t||(e!==r&&te(s,"has",e),te(s,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function Et(e,t=!1){return e=e.__v_raw,!t&&te(j(e),"iterate",He),Reflect.get(e,"size",e)}function Zn(e){e=j(e);const t=j(this);return St(t).has.call(t,e)||(t.add(e),ye(t,"add",e,e)),this}function Qn(e,t){t=j(t);const n=j(this),{has:s,get:r}=St(n);let i=s.call(n,e);i||(e=j(e),i=s.call(n,e));const o=r.call(n,e);return n.set(e,t),i?at(t,o)&&ye(n,"set",e,t):ye(n,"add",e,t),this}function Vn(e){const t=j(this),{has:n,get:s}=St(t);let r=n.call(t,e);r||(e=j(e),r=n.call(t,e)),s&&s.call(t,e);const i=t.delete(e);return r&&ye(t,"delete",e,void 0),i}function Gn(){const e=j(this),t=e.size!==0,n=e.clear();return t&&ye(e,"clear",void 0,void 0),n}function Ct(e,t){return function(s,r){const i=this,o=i.__v_raw,c=j(o),u=t?Fn:e?jn:ht;return!e&&te(c,"iterate",He),o.forEach((d,m)=>s.call(r,u(d),u(m),i))}}function Ot(e,t,n){return function(...s){const r=this.__v_raw,i=j(r),o=ke(i),c=e==="entries"||e===Symbol.iterator&&o,u=e==="keys"&&o,d=r[e](...s),m=n?Fn:t?jn:ht;return!t&&te(i,"iterate",u?cn:He),{next(){const{value:x,done:E}=d.next();return E?{value:x,done:E}:{value:c?[m(x[0]),m(x[1])]:m(x),done:E}},[Symbol.iterator](){return this}}}}function Oe(e){return function(...t){return e==="delete"?!1:this}}function Zr(){const e={get(i){return yt(this,i)},get size(){return Et(this)},has:wt,add:Zn,set:Qn,delete:Vn,clear:Gn,forEach:Ct(!1,!1)},t={get(i){return yt(this,i,!1,!0)},get size(){return Et(this)},has:wt,add:Zn,set:Qn,delete:Vn,clear:Gn,forEach:Ct(!1,!0)},n={get(i){return yt(this,i,!0)},get size(){return Et(this,!0)},has(i){return wt.call(this,i,!0)},add:Oe("add"),set:Oe("set"),delete:Oe("delete"),clear:Oe("clear"),forEach:Ct(!0,!1)},s={get(i){return yt(this,i,!0,!0)},get size(){return Et(this,!0)},has(i){return wt.call(this,i,!0)},add:Oe("add"),set:Oe("set"),delete:Oe("delete"),clear:Oe("clear"),forEach:Ct(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(i=>{e[i]=Ot(i,!1,!1),n[i]=Ot(i,!0,!1),t[i]=Ot(i,!1,!0),s[i]=Ot(i,!0,!0)}),[e,n,t,s]}const[Qr,Vr,Gr,ei]=Zr();function Mn(e,t){const n=t?e?ei:Gr:e?Vr:Qr;return(s,r,i)=>r==="__v_isReactive"?!e:r==="__v_isReadonly"?e:r==="__v_raw"?s:Reflect.get(M(n,r)&&r in s?n:s,r,i)}const ti={get:Mn(!1,!1)},ni={get:Mn(!1,!0)},si={get:Mn(!0,!1)},Ns=new WeakMap,Rs=new WeakMap,js=new WeakMap,ri=new WeakMap;function ii(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function oi(e){return e.__v_skip||!Object.isExtensible(e)?0:ii(Ar(e))}function Nn(e){return dt(e)?e:Rn(e,!1,Ms,ti,Ns)}function li(e){return Rn(e,!1,Xr,ni,Rs)}function $s(e){return Rn(e,!0,kr,si,js)}function Rn(e,t,n,s,r){if(!J(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const i=r.get(e);if(i)return i;const o=oi(e);if(o===0)return e;const c=new Proxy(e,o===2?s:n);return r.set(e,c),c}function Xe(e){return dt(e)?Xe(e.__v_raw):!!(e&&e.__v_isReactive)}function dt(e){return!!(e&&e.__v_isReadonly)}function un(e){return!!(e&&e.__v_isShallow)}function Hs(e){return Xe(e)||dt(e)}function j(e){const t=e&&e.__v_raw;return t?j(t):e}function Ls(e){return At(e,"__v_skip",!0),e}const ht=e=>J(e)?Nn(e):e,jn=e=>J(e)?$s(e):e;function Ss(e){Ie&&re&&(e=j(e),Ps(e.dep||(e.dep=In())))}function Us(e,t){e=j(e),e.dep&&fn(e.dep)}function k(e){return!!(e&&e.__v_isRef===!0)}function Tt(e){return ci(e,!1)}function ci(e,t){return k(e)?e:new fi(e,t)}class fi{constructor(t,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?t:j(t),this._value=n?t:ht(t)}get value(){return Ss(this),this._value}set value(t){t=this.__v_isShallow?t:j(t),at(t,this._rawValue)&&(this._rawValue=t,this._value=this.__v_isShallow?t:ht(t),Us(this))}}function ui(e){return k(e)?e.value:e}const ai={get:(e,t,n)=>ui(Reflect.get(e,t,n)),set:(e,t,n,s)=>{const r=e[t];return k(r)&&!k(n)?(r.value=n,!0):Reflect.set(e,t,n,s)}};function Bs(e){return Xe(e)?e:new Proxy(e,ai)}class di{constructor(t,n,s,r){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this._dirty=!0,this.effect=new Pn(t,()=>{this._dirty||(this._dirty=!0,Us(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!r,this.__v_isReadonly=s}get value(){const t=j(this);return Ss(t),(t._dirty||!t._cacheable)&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function hi(e,t,n=!1){let s,r;const i=A(e);return i?(s=e,r=oe):(s=e.get,r=e.set),new di(s,r,i||!r,n)}function Pe(e,t,n,s){let r;try{r=s?e(...s):e()}catch(i){Ut(i,t,n)}return r}function le(e,t,n,s){if(A(e)){const i=Pe(e,t,n,s);return i&&Es(i)&&i.catch(o=>{Ut(o,t,n)}),i}const r=[];for(let i=0;i>>1;pt(ee[s])be&&ee.splice(t,1)}function zs(e,t,n,s){P(e)?n.push(...e):(!t||!t.includes(e,e.allowRecurse?s+1:s))&&n.push(e),Ws()}function bi(e){zs(e,lt,ct,ze)}function xi(e){zs(e,Te,ft,qe)}function Bt(e,t=null){if(ct.length){for(dn=t,lt=[...new Set(ct)],ct.length=0,ze=0;zept(n)-pt(s)),qe=0;qee.id==null?1/0:e.id;function Js(e){an=!1,Ft=!0,Bt(e),ee.sort((n,s)=>pt(n)-pt(s));const t=oe;try{for(be=0;bev.trim())),x&&(r=n.map(Nr))}let c,u=s[c=Vt(t)]||s[c=Vt(pe(t))];!u&&i&&(u=s[c=Vt(Ve(t))]),u&&le(u,e,6,r);const d=s[c+"Once"];if(d){if(!e.emitted)e.emitted={};else if(e.emitted[c])return;e.emitted[c]=!0,le(d,e,6,r)}}function Ys(e,t,n=!1){const s=t.emitsCache,r=s.get(e);if(r!==void 0)return r;const i=e.emits;let o={},c=!1;if(!A(e)){const u=d=>{const m=Ys(d,t,!0);m&&(c=!0,Z(o,m))};!n&&t.mixins.length&&t.mixins.forEach(u),e.extends&&u(e.extends),e.mixins&&e.mixins.forEach(u)}return!i&&!c?(s.set(e,null),null):(P(i)?i.forEach(u=>o[u]=null):Z(o,i),s.set(e,o),o)}function Dt(e,t){return!e||!jt(t)?!1:(t=t.slice(2).replace(/Once$/,""),M(e,t[0].toLowerCase()+t.slice(1))||M(e,Ve(t))||M(e,t))}let he=null,Kt=null;function Mt(e){const t=he;return he=e,Kt=e&&e.type.__scopeId||null,t}function wi(e){Kt=e}function Ei(){Kt=null}function Ci(e,t=he,n){if(!t||e._n)return e;const s=(...r)=>{s._d&&fs(-1);const i=Mt(t),o=e(...r);return Mt(i),s._d&&fs(1),o};return s._n=!0,s._c=!0,s._d=!0,s}function en(e){const{type:t,vnode:n,proxy:s,withProxy:r,props:i,propsOptions:[o],slots:c,attrs:u,emit:d,render:m,renderCache:x,data:E,setupState:v,ctx:S,inheritAttrs:K}=e;let F,R;const ne=Mt(e);try{if(n.shapeFlag&4){const q=r||s;F=de(m.call(q,q,x,i,v,E,S)),R=u}else{const q=t;F=de(q.length>1?q(i,{attrs:u,slots:c,emit:d}):q(i,null)),R=t.props?u:Oi(u)}}catch(q){ut.length=0,Ut(q,e,1),F=xe(Ue)}let U=F;if(R&&K!==!1){const q=Object.keys(R),{shapeFlag:Ee}=U;q.length&&Ee&7&&(o&&q.some(Cn)&&(R=Ti(R,o)),U=Ze(U,R))}return n.dirs&&(U=Ze(U),U.dirs=U.dirs?U.dirs.concat(n.dirs):n.dirs),n.transition&&(U.transition=n.transition),F=U,Mt(ne),F}const Oi=e=>{let t;for(const n in e)(n==="class"||n==="style"||jt(n))&&((t||(t={}))[n]=e[n]);return t},Ti=(e,t)=>{const n={};for(const s in e)(!Cn(s)||!(s.slice(9)in t))&&(n[s]=e[s]);return n};function vi(e,t,n){const{props:s,children:r,component:i}=e,{props:o,children:c,patchFlag:u}=t,d=i.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&u>=0){if(u&1024)return!0;if(u&16)return s?es(s,o,d):!!o;if(u&8){const m=t.dynamicProps;for(let x=0;xe.__isSuspense;function Ai(e,t){t&&t.pendingBranch?P(e)?t.effects.push(...e):t.effects.push(e):xi(e)}function Fi(e,t){if(Y){let n=Y.provides;const s=Y.parent&&Y.parent.provides;s===n&&(n=Y.provides=Object.create(s)),n[e]=t}}function tn(e,t,n=!1){const s=Y||he;if(s){const r=s.parent==null?s.vnode.appContext&&s.vnode.appContext.provides:s.parent.provides;if(r&&e in r)return r[e];if(arguments.length>1)return n&&A(t)?t.call(s.proxy):t}}const ts={};function nn(e,t,n){return ks(e,t,n)}function ks(e,t,{immediate:n,deep:s,flush:r,onTrack:i,onTrigger:o}=L){const c=Y;let u,d=!1,m=!1;if(k(e)?(u=()=>e.value,d=un(e)):Xe(e)?(u=()=>e,s=!0):P(e)?(m=!0,d=e.some(R=>Xe(R)||un(R)),u=()=>e.map(R=>{if(k(R))return R.value;if(Xe(R))return Je(R);if(A(R))return Pe(R,c,2)})):A(e)?t?u=()=>Pe(e,c,2):u=()=>{if(!(c&&c.isUnmounted))return x&&x(),le(e,c,3,[E])}:u=oe,t&&s){const R=u;u=()=>Je(R())}let x,E=R=>{x=F.onStop=()=>{Pe(R,c,4)}};if(mt)return E=oe,t?n&&le(t,c,3,[u(),m?[]:void 0,E]):u(),oe;let v=m?[]:ts;const S=()=>{if(!!F.active)if(t){const R=F.run();(s||d||(m?R.some((ne,U)=>at(ne,v[U])):at(R,v)))&&(x&&x(),le(t,c,3,[R,v===ts?void 0:v,E]),v=R)}else F.run()};S.allowRecurse=!!t;let K;r==="sync"?K=S:r==="post"?K=()=>V(S,c&&c.suspense):K=()=>bi(S);const F=new Pn(u,K);return t?n?S():v=F.run():r==="post"?V(F.run.bind(F),c&&c.suspense):F.run(),()=>{F.stop(),c&&c.scope&&On(c.scope.effects,F)}}function Mi(e,t,n){const s=this.proxy,r=z(e)?e.includes(".")?Xs(s,e):()=>s[e]:e.bind(s,s);let i;A(t)?i=t:(i=t.handler,n=t);const o=Y;Qe(this);const c=ks(r,i.bind(s),n);return o?Qe(o):Se(),c}function Xs(e,t){const n=t.split(".");return()=>{let s=e;for(let r=0;r{Je(n,t)});else if(Os(e))for(const n in e)Je(e[n],t);return e}function Zs(e){return A(e)?{setup:e,name:e.name}:e}const It=e=>!!e.type.__asyncLoader,Qs=e=>e.type.__isKeepAlive;function Ni(e,t){Vs(e,"a",t)}function Ri(e,t){Vs(e,"da",t)}function Vs(e,t,n=Y){const s=e.__wdc||(e.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return e()});if(Wt(t,s,n),n){let r=n.parent;for(;r&&r.parent;)Qs(r.parent.vnode)&&ji(s,t,n,r),r=r.parent}}function ji(e,t,n,s){const r=Wt(t,e,s,!0);Gs(()=>{On(s[t],r)},n)}function Wt(e,t,n=Y,s=!1){if(n){const r=n[e]||(n[e]=[]),i=t.__weh||(t.__weh=(...o)=>{if(n.isUnmounted)return;Ge(),Qe(n);const c=le(t,n,e,o);return Se(),et(),c});return s?r.unshift(i):r.push(i),i}}const we=e=>(t,n=Y)=>(!mt||e==="sp")&&Wt(e,t,n),$i=we("bm"),Hi=we("m"),Li=we("bu"),Si=we("u"),Ui=we("bum"),Gs=we("um"),Bi=we("sp"),Di=we("rtg"),Ki=we("rtc");function Wi(e,t=Y){Wt("ec",e,t)}function Me(e,t,n,s){const r=e.dirs,i=t&&t.dirs;for(let o=0;ot(o,c,void 0,i&&i[c]));else{const o=Object.keys(e);r=new Array(o.length);for(let c=0,u=o.length;ce?pr(e)?Un(e)||e.proxy:hn(e.parent):null,Nt=Z(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>hn(e.parent),$root:e=>hn(e.root),$emit:e=>e.emit,$options:e=>sr(e),$forceUpdate:e=>e.f||(e.f=()=>Ks(e.update)),$nextTick:e=>e.n||(e.n=gi.bind(e.proxy)),$watch:e=>Mi.bind(e)}),Yi={get({_:e},t){const{ctx:n,setupState:s,data:r,props:i,accessCache:o,type:c,appContext:u}=e;let d;if(t[0]!=="$"){const v=o[t];if(v!==void 0)switch(v){case 1:return s[t];case 2:return r[t];case 4:return n[t];case 3:return i[t]}else{if(s!==L&&M(s,t))return o[t]=1,s[t];if(r!==L&&M(r,t))return o[t]=2,r[t];if((d=e.propsOptions[0])&&M(d,t))return o[t]=3,i[t];if(n!==L&&M(n,t))return o[t]=4,n[t];pn&&(o[t]=0)}}const m=Nt[t];let x,E;if(m)return t==="$attrs"&&te(e,"get",t),m(e);if((x=c.__cssModules)&&(x=x[t]))return x;if(n!==L&&M(n,t))return o[t]=4,n[t];if(E=u.config.globalProperties,M(E,t))return E[t]},set({_:e},t,n){const{data:s,setupState:r,ctx:i}=e;return r!==L&&M(r,t)?(r[t]=n,!0):s!==L&&M(s,t)?(s[t]=n,!0):M(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:s,appContext:r,propsOptions:i}},o){let c;return!!n[o]||e!==L&&M(e,o)||t!==L&&M(t,o)||(c=i[0])&&M(c,o)||M(s,o)||M(Nt,o)||M(r.config.globalProperties,o)},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:M(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};let pn=!0;function ki(e){const t=sr(e),n=e.proxy,s=e.ctx;pn=!1,t.beforeCreate&&ss(t.beforeCreate,e,"bc");const{data:r,computed:i,methods:o,watch:c,provide:u,inject:d,created:m,beforeMount:x,mounted:E,beforeUpdate:v,updated:S,activated:K,deactivated:F,beforeDestroy:R,beforeUnmount:ne,destroyed:U,unmounted:q,render:Ee,renderTracked:qt,renderTriggered:Jt,errorCaptured:_t,serverPrefetch:Fe,expose:tt,inheritAttrs:Be,components:nt,directives:bt,filters:Bn}=t;if(d&&Xi(d,s,null,e.appContext.config.unwrapInjectedRef),o)for(const W in o){const B=o[W];A(B)&&(s[W]=B.bind(n))}if(r){const W=r.call(n,n);J(W)&&(e.data=Nn(W))}if(pn=!0,i)for(const W in i){const B=i[W],ge=A(B)?B.bind(n,n):A(B.get)?B.get.bind(n,n):oe,kt=!A(B)&&A(B.set)?B.set.bind(n):oe,st=Io({get:ge,set:kt});Object.defineProperty(s,W,{enumerable:!0,configurable:!0,get:()=>st.value,set:De=>st.value=De})}if(c)for(const W in c)nr(c[W],s,n,W);if(u){const W=A(u)?u.call(n):u;Reflect.ownKeys(W).forEach(B=>{Fi(B,W[B])})}m&&ss(m,e,"c");function Q(W,B){P(B)?B.forEach(ge=>W(ge.bind(n))):B&&W(B.bind(n))}if(Q($i,x),Q(Hi,E),Q(Li,v),Q(Si,S),Q(Ni,K),Q(Ri,F),Q(Wi,_t),Q(Ki,qt),Q(Di,Jt),Q(Ui,ne),Q(Gs,q),Q(Bi,Fe),P(tt))if(tt.length){const W=e.exposed||(e.exposed={});tt.forEach(B=>{Object.defineProperty(W,B,{get:()=>n[B],set:ge=>n[B]=ge})})}else e.exposed||(e.exposed={});Ee&&e.render===oe&&(e.render=Ee),Be!=null&&(e.inheritAttrs=Be),nt&&(e.components=nt),bt&&(e.directives=bt)}function Xi(e,t,n=oe,s=!1){P(e)&&(e=gn(e));for(const r in e){const i=e[r];let o;J(i)?"default"in i?o=tn(i.from||r,i.default,!0):o=tn(i.from||r):o=tn(i),k(o)&&s?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>o.value,set:c=>o.value=c}):t[r]=o}}function ss(e,t,n){le(P(e)?e.map(s=>s.bind(t.proxy)):e.bind(t.proxy),t,n)}function nr(e,t,n,s){const r=s.includes(".")?Xs(n,s):()=>n[s];if(z(e)){const i=t[e];A(i)&&nn(r,i)}else if(A(e))nn(r,e.bind(n));else if(J(e))if(P(e))e.forEach(i=>nr(i,t,n,s));else{const i=A(e.handler)?e.handler.bind(n):t[e.handler];A(i)&&nn(r,i,e)}}function sr(e){const t=e.type,{mixins:n,extends:s}=t,{mixins:r,optionsCache:i,config:{optionMergeStrategies:o}}=e.appContext,c=i.get(t);let u;return c?u=c:!r.length&&!n&&!s?u=t:(u={},r.length&&r.forEach(d=>Rt(u,d,o,!0)),Rt(u,t,o)),i.set(t,u),u}function Rt(e,t,n,s=!1){const{mixins:r,extends:i}=t;i&&Rt(e,i,n,!0),r&&r.forEach(o=>Rt(e,o,n,!0));for(const o in t)if(!(s&&o==="expose")){const c=Zi[o]||n&&n[o];e[o]=c?c(e[o],t[o]):t[o]}return e}const Zi={data:rs,props:Re,emits:Re,methods:Re,computed:Re,beforeCreate:X,created:X,beforeMount:X,mounted:X,beforeUpdate:X,updated:X,beforeDestroy:X,beforeUnmount:X,destroyed:X,unmounted:X,activated:X,deactivated:X,errorCaptured:X,serverPrefetch:X,components:Re,directives:Re,watch:Vi,provide:rs,inject:Qi};function rs(e,t){return t?e?function(){return Z(A(e)?e.call(this,this):e,A(t)?t.call(this,this):t)}:t:e}function Qi(e,t){return Re(gn(e),gn(t))}function gn(e){if(P(e)){const t={};for(let n=0;n0)&&!(o&16)){if(o&8){const m=e.vnode.dynamicProps;for(let x=0;x{u=!0;const[E,v]=ir(x,t,!0);Z(o,E),v&&c.push(...v)};!n&&t.mixins.length&&t.mixins.forEach(m),e.extends&&m(e.extends),e.mixins&&e.mixins.forEach(m)}if(!i&&!u)return s.set(e,Ye),Ye;if(P(i))for(let m=0;m-1,v[1]=K<0||S-1||M(v,"default"))&&c.push(x)}}}const d=[o,c];return s.set(e,d),d}function is(e){return e[0]!=="$"}function os(e){const t=e&&e.toString().match(/^\s*function (\w+)/);return t?t[1]:e===null?"null":""}function ls(e,t){return os(e)===os(t)}function cs(e,t){return P(t)?t.findIndex(n=>ls(n,e)):A(t)&&ls(t,e)?0:-1}const or=e=>e[0]==="_"||e==="$stable",Hn=e=>P(e)?e.map(de):[de(e)],to=(e,t,n)=>{if(t._n)return t;const s=Ci((...r)=>Hn(t(...r)),n);return s._c=!1,s},lr=(e,t,n)=>{const s=e._ctx;for(const r in e){if(or(r))continue;const i=e[r];if(A(i))t[r]=to(r,i,s);else if(i!=null){const o=Hn(i);t[r]=()=>o}}},cr=(e,t)=>{const n=Hn(t);e.slots.default=()=>n},no=(e,t)=>{if(e.vnode.shapeFlag&32){const n=t._;n?(e.slots=j(t),At(t,"_",n)):lr(t,e.slots={})}else e.slots={},t&&cr(e,t);At(e.slots,zt,1)},so=(e,t,n)=>{const{vnode:s,slots:r}=e;let i=!0,o=L;if(s.shapeFlag&32){const c=t._;c?n&&c===1?i=!1:(Z(r,t),!n&&c===1&&delete r._):(i=!t.$stable,lr(t,r)),o=t}else t&&(cr(e,t),o={default:1});if(i)for(const c in r)!or(c)&&!(c in o)&&delete r[c]};function fr(){return{app:null,config:{isNativeTag:vr,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let ro=0;function io(e,t){return function(s,r=null){A(s)||(s=Object.assign({},s)),r!=null&&!J(r)&&(r=null);const i=fr(),o=new Set;let c=!1;const u=i.app={_uid:ro++,_component:s,_props:r,_container:null,_context:i,_instance:null,version:Po,get config(){return i.config},set config(d){},use(d,...m){return o.has(d)||(d&&A(d.install)?(o.add(d),d.install(u,...m)):A(d)&&(o.add(d),d(u,...m))),u},mixin(d){return i.mixins.includes(d)||i.mixins.push(d),u},component(d,m){return m?(i.components[d]=m,u):i.components[d]},directive(d,m){return m?(i.directives[d]=m,u):i.directives[d]},mount(d,m,x){if(!c){const E=xe(s,r);return E.appContext=i,m&&t?t(E,d):e(E,d,x),c=!0,u._container=d,d.__vue_app__=u,Un(E.component)||E.component.proxy}},unmount(){c&&(e(null,u._container),delete u._container.__vue_app__)},provide(d,m){return i.provides[d]=m,u}};return u}}function _n(e,t,n,s,r=!1){if(P(e)){e.forEach((E,v)=>_n(E,t&&(P(t)?t[v]:t),n,s,r));return}if(It(s)&&!r)return;const i=s.shapeFlag&4?Un(s.component)||s.component.proxy:s.el,o=r?null:i,{i:c,r:u}=e,d=t&&t.r,m=c.refs===L?c.refs={}:c.refs,x=c.setupState;if(d!=null&&d!==u&&(z(d)?(m[d]=null,M(x,d)&&(x[d]=null)):k(d)&&(d.value=null)),A(u))Pe(u,c,12,[o,m]);else{const E=z(u),v=k(u);if(E||v){const S=()=>{if(e.f){const K=E?m[u]:u.value;r?P(K)&&On(K,i):P(K)?K.includes(i)||K.push(i):E?(m[u]=[i],M(x,u)&&(x[u]=m[u])):(u.value=[i],e.k&&(m[e.k]=u.value))}else E?(m[u]=o,M(x,u)&&(x[u]=o)):v&&(u.value=o,e.k&&(m[e.k]=o))};o?(S.id=-1,V(S,n)):S()}}}const V=Ai;function oo(e){return lo(e)}function lo(e,t){const n=Rr();n.__VUE__=!0;const{insert:s,remove:r,patchProp:i,createElement:o,createText:c,createComment:u,setText:d,setElementText:m,parentNode:x,nextSibling:E,setScopeId:v=oe,cloneNode:S,insertStaticContent:K}=e,F=(l,f,a,p=null,h=null,b=null,w=!1,_=null,y=!!f.dynamicChildren)=>{if(l===f)return;l&&!it(l,f)&&(p=xt(l),Ce(l,h,b,!0),l=null),f.patchFlag===-2&&(y=!1,f.dynamicChildren=null);const{type:g,ref:O,shapeFlag:C}=f;switch(g){case Ln:R(l,f,a,p);break;case Ue:ne(l,f,a,p);break;case sn:l==null&&U(f,a,p,w);break;case ae:bt(l,f,a,p,h,b,w,_,y);break;default:C&1?qt(l,f,a,p,h,b,w,_,y):C&6?Bn(l,f,a,p,h,b,w,_,y):(C&64||C&128)&&g.process(l,f,a,p,h,b,w,_,y,Ke)}O!=null&&h&&_n(O,l&&l.ref,b,f||l,!f)},R=(l,f,a,p)=>{if(l==null)s(f.el=c(f.children),a,p);else{const h=f.el=l.el;f.children!==l.children&&d(h,f.children)}},ne=(l,f,a,p)=>{l==null?s(f.el=u(f.children||""),a,p):f.el=l.el},U=(l,f,a,p)=>{[l.el,l.anchor]=K(l.children,f,a,p,l.el,l.anchor)},q=({el:l,anchor:f},a,p)=>{let h;for(;l&&l!==f;)h=E(l),s(l,a,p),l=h;s(f,a,p)},Ee=({el:l,anchor:f})=>{let a;for(;l&&l!==f;)a=E(l),r(l),l=a;r(f)},qt=(l,f,a,p,h,b,w,_,y)=>{w=w||f.type==="svg",l==null?Jt(f,a,p,h,b,w,_,y):tt(l,f,h,b,w,_,y)},Jt=(l,f,a,p,h,b,w,_)=>{let y,g;const{type:O,props:C,shapeFlag:T,transition:I,patchFlag:N,dirs:$}=l;if(l.el&&S!==void 0&&N===-1)y=l.el=S(l.el);else{if(y=l.el=o(l.type,b,C&&C.is,C),T&8?m(y,l.children):T&16&&Fe(l.children,y,null,p,h,b&&O!=="foreignObject",w,_),$&&Me(l,null,p,"created"),C){for(const D in C)D!=="value"&&!vt(D)&&i(y,D,null,C[D],b,l.children,p,h,me);"value"in C&&i(y,"value",null,C.value),(g=C.onVnodeBeforeMount)&&fe(g,p,l)}_t(y,l,l.scopeId,w,p)}$&&Me(l,null,p,"beforeMount");const H=(!h||h&&!h.pendingBranch)&&I&&!I.persisted;H&&I.beforeEnter(y),s(y,f,a),((g=C&&C.onVnodeMounted)||H||$)&&V(()=>{g&&fe(g,p,l),H&&I.enter(y),$&&Me(l,null,p,"mounted")},h)},_t=(l,f,a,p,h)=>{if(a&&v(l,a),p)for(let b=0;b{for(let g=y;g{const _=f.el=l.el;let{patchFlag:y,dynamicChildren:g,dirs:O}=f;y|=l.patchFlag&16;const C=l.props||L,T=f.props||L;let I;a&&Ne(a,!1),(I=T.onVnodeBeforeUpdate)&&fe(I,a,f,l),O&&Me(f,l,a,"beforeUpdate"),a&&Ne(a,!0);const N=h&&f.type!=="foreignObject";if(g?Be(l.dynamicChildren,g,_,a,p,N,b):w||ge(l,f,_,null,a,p,N,b,!1),y>0){if(y&16)nt(_,f,C,T,a,p,h);else if(y&2&&C.class!==T.class&&i(_,"class",null,T.class,h),y&4&&i(_,"style",C.style,T.style,h),y&8){const $=f.dynamicProps;for(let H=0;H<$.length;H++){const D=$[H],se=C[D],We=T[D];(We!==se||D==="value")&&i(_,D,se,We,h,l.children,a,p,me)}}y&1&&l.children!==f.children&&m(_,f.children)}else!w&&g==null&&nt(_,f,C,T,a,p,h);((I=T.onVnodeUpdated)||O)&&V(()=>{I&&fe(I,a,f,l),O&&Me(f,l,a,"updated")},p)},Be=(l,f,a,p,h,b,w)=>{for(let _=0;_{if(a!==p){for(const _ in p){if(vt(_))continue;const y=p[_],g=a[_];y!==g&&_!=="value"&&i(l,_,g,y,w,f.children,h,b,me)}if(a!==L)for(const _ in a)!vt(_)&&!(_ in p)&&i(l,_,a[_],null,w,f.children,h,b,me);"value"in p&&i(l,"value",a.value,p.value)}},bt=(l,f,a,p,h,b,w,_,y)=>{const g=f.el=l?l.el:c(""),O=f.anchor=l?l.anchor:c("");let{patchFlag:C,dynamicChildren:T,slotScopeIds:I}=f;I&&(_=_?_.concat(I):I),l==null?(s(g,a,p),s(O,a,p),Fe(f.children,a,O,h,b,w,_,y)):C>0&&C&64&&T&&l.dynamicChildren?(Be(l.dynamicChildren,T,a,h,b,w,_),(f.key!=null||h&&f===h.subTree)&&ur(l,f,!0)):ge(l,f,a,O,h,b,w,_,y)},Bn=(l,f,a,p,h,b,w,_,y)=>{f.slotScopeIds=_,l==null?f.shapeFlag&512?h.ctx.activate(f,a,p,w,y):Yt(f,a,p,h,b,w,y):Q(l,f,y)},Yt=(l,f,a,p,h,b,w)=>{const _=l.component=yo(l,p,h);if(Qs(l)&&(_.ctx.renderer=Ke),wo(_),_.asyncDep){if(h&&h.registerDep(_,W),!l.el){const y=_.subTree=xe(Ue);ne(null,y,f,a)}return}W(_,l,f,a,h,b,w)},Q=(l,f,a)=>{const p=f.component=l.component;if(vi(l,f,a))if(p.asyncDep&&!p.asyncResolved){B(p,f,a);return}else p.next=f,_i(p.update),p.update();else f.el=l.el,p.vnode=f},W=(l,f,a,p,h,b,w)=>{const _=()=>{if(l.isMounted){let{next:O,bu:C,u:T,parent:I,vnode:N}=l,$=O,H;Ne(l,!1),O?(O.el=N.el,B(l,O,w)):O=N,C&&Gt(C),(H=O.props&&O.props.onVnodeBeforeUpdate)&&fe(H,I,O,N),Ne(l,!0);const D=en(l),se=l.subTree;l.subTree=D,F(se,D,x(se.el),xt(se),l,h,b),O.el=D.el,$===null&&Ii(l,D.el),T&&V(T,h),(H=O.props&&O.props.onVnodeUpdated)&&V(()=>fe(H,I,O,N),h)}else{let O;const{el:C,props:T}=f,{bm:I,m:N,parent:$}=l,H=It(f);if(Ne(l,!1),I&&Gt(I),!H&&(O=T&&T.onVnodeBeforeMount)&&fe(O,$,f),Ne(l,!0),C&&Zt){const D=()=>{l.subTree=en(l),Zt(C,l.subTree,l,h,null)};H?f.type.__asyncLoader().then(()=>!l.isUnmounted&&D()):D()}else{const D=l.subTree=en(l);F(null,D,a,p,l,h,b),f.el=D.el}if(N&&V(N,h),!H&&(O=T&&T.onVnodeMounted)){const D=f;V(()=>fe(O,$,D),h)}(f.shapeFlag&256||$&&It($.vnode)&&$.vnode.shapeFlag&256)&&l.a&&V(l.a,h),l.isMounted=!0,f=a=p=null}},y=l.effect=new Pn(_,()=>Ks(g),l.scope),g=l.update=()=>y.run();g.id=l.uid,Ne(l,!0),g()},B=(l,f,a)=>{f.component=l;const p=l.vnode.props;l.vnode=f,l.next=null,eo(l,f.props,p,a),so(l,f.children,a),Ge(),Bt(void 0,l.update),et()},ge=(l,f,a,p,h,b,w,_,y=!1)=>{const g=l&&l.children,O=l?l.shapeFlag:0,C=f.children,{patchFlag:T,shapeFlag:I}=f;if(T>0){if(T&128){st(g,C,a,p,h,b,w,_,y);return}else if(T&256){kt(g,C,a,p,h,b,w,_,y);return}}I&8?(O&16&&me(g,h,b),C!==g&&m(a,C)):O&16?I&16?st(g,C,a,p,h,b,w,_,y):me(g,h,b,!0):(O&8&&m(a,""),I&16&&Fe(C,a,p,h,b,w,_,y))},kt=(l,f,a,p,h,b,w,_,y)=>{l=l||Ye,f=f||Ye;const g=l.length,O=f.length,C=Math.min(g,O);let T;for(T=0;TO?me(l,h,b,!0,!1,C):Fe(f,a,p,h,b,w,_,y,C)},st=(l,f,a,p,h,b,w,_,y)=>{let g=0;const O=f.length;let C=l.length-1,T=O-1;for(;g<=C&&g<=T;){const I=l[g],N=f[g]=y?ve(f[g]):de(f[g]);if(it(I,N))F(I,N,a,null,h,b,w,_,y);else break;g++}for(;g<=C&&g<=T;){const I=l[C],N=f[T]=y?ve(f[T]):de(f[T]);if(it(I,N))F(I,N,a,null,h,b,w,_,y);else break;C--,T--}if(g>C){if(g<=T){const I=T+1,N=IT)for(;g<=C;)Ce(l[g],h,b,!0),g++;else{const I=g,N=g,$=new Map;for(g=N;g<=T;g++){const G=f[g]=y?ve(f[g]):de(f[g]);G.key!=null&&$.set(G.key,g)}let H,D=0;const se=T-N+1;let We=!1,Wn=0;const rt=new Array(se);for(g=0;g=se){Ce(G,h,b,!0);continue}let ce;if(G.key!=null)ce=$.get(G.key);else for(H=N;H<=T;H++)if(rt[H-N]===0&&it(G,f[H])){ce=H;break}ce===void 0?Ce(G,h,b,!0):(rt[ce-N]=g+1,ce>=Wn?Wn=ce:We=!0,F(G,f[ce],a,null,h,b,w,_,y),D++)}const zn=We?co(rt):Ye;for(H=zn.length-1,g=se-1;g>=0;g--){const G=N+g,ce=f[G],qn=G+1{const{el:b,type:w,transition:_,children:y,shapeFlag:g}=l;if(g&6){De(l.component.subTree,f,a,p);return}if(g&128){l.suspense.move(f,a,p);return}if(g&64){w.move(l,f,a,Ke);return}if(w===ae){s(b,f,a);for(let C=0;C_.enter(b),h);else{const{leave:C,delayLeave:T,afterLeave:I}=_,N=()=>s(b,f,a),$=()=>{C(b,()=>{N(),I&&I()})};T?T(b,N,$):$()}else s(b,f,a)},Ce=(l,f,a,p=!1,h=!1)=>{const{type:b,props:w,ref:_,children:y,dynamicChildren:g,shapeFlag:O,patchFlag:C,dirs:T}=l;if(_!=null&&_n(_,null,a,l,!0),O&256){f.ctx.deactivate(l);return}const I=O&1&&T,N=!It(l);let $;if(N&&($=w&&w.onVnodeBeforeUnmount)&&fe($,f,l),O&6)yr(l.component,a,p);else{if(O&128){l.suspense.unmount(a,p);return}I&&Me(l,null,f,"beforeUnmount"),O&64?l.type.remove(l,f,a,h,Ke,p):g&&(b!==ae||C>0&&C&64)?me(g,f,a,!1,!0):(b===ae&&C&384||!h&&O&16)&&me(y,f,a),p&&Dn(l)}(N&&($=w&&w.onVnodeUnmounted)||I)&&V(()=>{$&&fe($,f,l),I&&Me(l,null,f,"unmounted")},a)},Dn=l=>{const{type:f,el:a,anchor:p,transition:h}=l;if(f===ae){xr(a,p);return}if(f===sn){Ee(l);return}const b=()=>{r(a),h&&!h.persisted&&h.afterLeave&&h.afterLeave()};if(l.shapeFlag&1&&h&&!h.persisted){const{leave:w,delayLeave:_}=h,y=()=>w(a,b);_?_(l.el,b,y):y()}else b()},xr=(l,f)=>{let a;for(;l!==f;)a=E(l),r(l),l=a;r(f)},yr=(l,f,a)=>{const{bum:p,scope:h,update:b,subTree:w,um:_}=l;p&&Gt(p),h.stop(),b&&(b.active=!1,Ce(w,l,f,a)),_&&V(_,f),V(()=>{l.isUnmounted=!0},f),f&&f.pendingBranch&&!f.isUnmounted&&l.asyncDep&&!l.asyncResolved&&l.suspenseId===f.pendingId&&(f.deps--,f.deps===0&&f.resolve())},me=(l,f,a,p=!1,h=!1,b=0)=>{for(let w=b;wl.shapeFlag&6?xt(l.component.subTree):l.shapeFlag&128?l.suspense.next():E(l.anchor||l.el),Kn=(l,f,a)=>{l==null?f._vnode&&Ce(f._vnode,null,null,!0):F(f._vnode||null,l,f,null,null,null,a),qs(),f._vnode=l},Ke={p:F,um:Ce,m:De,r:Dn,mt:Yt,mc:Fe,pc:ge,pbc:Be,n:xt,o:e};let Xt,Zt;return t&&([Xt,Zt]=t(Ke)),{render:Kn,hydrate:Xt,createApp:io(Kn,Xt)}}function Ne({effect:e,update:t},n){e.allowRecurse=t.allowRecurse=n}function ur(e,t,n=!1){const s=e.children,r=t.children;if(P(s)&&P(r))for(let i=0;i>1,e[n[c]]0&&(t[s]=n[i-1]),n[i]=s)}}for(i=n.length,o=n[i-1];i-- >0;)n[i]=o,o=t[o];return n}const fo=e=>e.__isTeleport,ae=Symbol(void 0),Ln=Symbol(void 0),Ue=Symbol(void 0),sn=Symbol(void 0),ut=[];let ie=null;function _e(e=!1){ut.push(ie=e?null:[])}function uo(){ut.pop(),ie=ut[ut.length-1]||null}let gt=1;function fs(e){gt+=e}function ar(e){return e.dynamicChildren=gt>0?ie||Ye:null,uo(),gt>0&&ie&&ie.push(e),e}function je(e,t,n,s,r,i){return ar(Le(e,t,n,s,r,i,!0))}function dr(e,t,n,s,r){return ar(xe(e,t,n,s,r,!0))}function ao(e){return e?e.__v_isVNode===!0:!1}function it(e,t){return e.type===t.type&&e.key===t.key}const zt="__vInternal",hr=({key:e})=>e!=null?e:null,Pt=({ref:e,ref_key:t,ref_for:n})=>e!=null?z(e)||k(e)||A(e)?{i:he,r:e,k:t,f:!!n}:e:null;function Le(e,t=null,n=null,s=0,r=null,i=e===ae?0:1,o=!1,c=!1){const u={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&hr(t),ref:t&&Pt(t),scopeId:Kt,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null};return c?(Sn(u,n),i&128&&e.normalize(u)):n&&(u.shapeFlag|=z(n)?8:16),gt>0&&!o&&ie&&(u.patchFlag>0||i&6)&&u.patchFlag!==32&&ie.push(u),u}const xe=ho;function ho(e,t=null,n=null,s=0,r=null,i=!1){if((!e||e===tr)&&(e=Ue),ao(e)){const c=Ze(e,t,!0);return n&&Sn(c,n),gt>0&&!i&&ie&&(c.shapeFlag&6?ie[ie.indexOf(e)]=c:ie.push(c)),c.patchFlag|=-2,c}if(vo(e)&&(e=e.__vccOpts),t){t=po(t);let{class:c,style:u}=t;c&&!z(c)&&(t.class=En(c)),J(u)&&(Hs(u)&&!P(u)&&(u=Z({},u)),t.style=wn(u))}const o=z(e)?1:Pi(e)?128:fo(e)?64:J(e)?4:A(e)?2:0;return Le(e,t,n,s,r,o,i,!0)}function po(e){return e?Hs(e)||zt in e?Z({},e):e:null}function Ze(e,t,n=!1){const{props:s,ref:r,patchFlag:i,children:o}=e,c=t?_o(s||{},t):s;return{__v_isVNode:!0,__v_skip:!0,type:e.type,props:c,key:c&&hr(c),ref:t&&t.ref?n&&r?P(r)?r.concat(Pt(t)):[r,Pt(t)]:Pt(t):r,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:o,target:e.target,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==ae?i===-1?16:i|16:i,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:e.transition,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&Ze(e.ssContent),ssFallback:e.ssFallback&&Ze(e.ssFallback),el:e.el,anchor:e.anchor}}function go(e=" ",t=0){return xe(Ln,null,e,t)}function mo(e="",t=!1){return t?(_e(),dr(Ue,null,e)):xe(Ue,null,e)}function de(e){return e==null||typeof e=="boolean"?xe(Ue):P(e)?xe(ae,null,e.slice()):typeof e=="object"?ve(e):xe(Ln,null,String(e))}function ve(e){return e.el===null||e.memo?e:Ze(e)}function Sn(e,t){let n=0;const{shapeFlag:s}=e;if(t==null)t=null;else if(P(t))n=16;else if(typeof t=="object")if(s&65){const r=t.default;r&&(r._c&&(r._d=!1),Sn(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!(zt in t)?t._ctx=he:r===3&&he&&(he.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else A(t)?(t={default:t,_ctx:he},n=32):(t=String(t),s&64?(n=16,t=[go(t)]):n=8);e.children=t,e.shapeFlag|=n}function _o(...e){const t={};for(let n=0;n{Y=e,e.scope.on()},Se=()=>{Y&&Y.scope.off(),Y=null};function pr(e){return e.vnode.shapeFlag&4}let mt=!1;function wo(e,t=!1){mt=t;const{props:n,children:s}=e.vnode,r=pr(e);Gi(e,n,r,t),no(e,s);const i=r?Eo(e,t):void 0;return mt=!1,i}function Eo(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=Ls(new Proxy(e.ctx,Yi));const{setup:s}=n;if(s){const r=e.setupContext=s.length>1?Oo(e):null;Qe(e),Ge();const i=Pe(s,e,0,[e.props,r]);if(et(),Se(),Es(i)){if(i.then(Se,Se),t)return i.then(o=>{us(e,o,t)}).catch(o=>{Ut(o,e,0)});e.asyncDep=i}else us(e,i,t)}else gr(e,t)}function us(e,t,n){A(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:J(t)&&(e.setupState=Bs(t)),gr(e,n)}let as;function gr(e,t,n){const s=e.type;if(!e.render){if(!t&&as&&!s.render){const r=s.template;if(r){const{isCustomElement:i,compilerOptions:o}=e.appContext.config,{delimiters:c,compilerOptions:u}=s,d=Z(Z({isCustomElement:i,delimiters:c},o),u);s.render=as(r,d)}}e.render=s.render||oe}Qe(e),Ge(),ki(e),et(),Se()}function Co(e){return new Proxy(e.attrs,{get(t,n){return te(e,"get","$attrs"),t[n]}})}function Oo(e){const t=s=>{e.exposed=s||{}};let n;return{get attrs(){return n||(n=Co(e))},slots:e.slots,emit:e.emit,expose:t}}function Un(e){if(e.exposed)return e.exposeProxy||(e.exposeProxy=new Proxy(Bs(Ls(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Nt)return Nt[n](e)}}))}function To(e,t=!0){return A(e)?e.displayName||e.name:e.name||t&&e.__name}function vo(e){return A(e)&&"__vccOpts"in e}const Io=(e,t)=>hi(e,t,mt),Po="3.2.37",Ao="http://www.w3.org/2000/svg",$e=typeof document<"u"?document:null,ds=$e&&$e.createElement("template"),Fo={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t?$e.createElementNS(Ao,e):$e.createElement(e,n?{is:n}:void 0);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>$e.createTextNode(e),createComment:e=>$e.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>$e.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},cloneNode(e){const t=e.cloneNode(!0);return"_value"in e&&(t._value=e._value),t},insertStaticContent(e,t,n,s,r,i){const o=n?n.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===i||!(r=r.nextSibling)););else{ds.innerHTML=s?`${e}`:e;const c=ds.content;if(s){const u=c.firstChild;for(;u.firstChild;)c.appendChild(u.firstChild);c.removeChild(u)}t.insertBefore(c,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}};function Mo(e,t,n){const s=e._vtc;s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}function No(e,t,n){const s=e.style,r=z(n);if(n&&!r){for(const i in n)bn(s,i,n[i]);if(t&&!z(t))for(const i in t)n[i]==null&&bn(s,i,"")}else{const i=s.display;r?t!==n&&(s.cssText=n):t&&e.removeAttribute("style"),"_vod"in e&&(s.display=i)}}const hs=/\s*!important$/;function bn(e,t,n){if(P(n))n.forEach(s=>bn(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=Ro(e,t);hs.test(n)?e.setProperty(Ve(s),n.replace(hs,""),"important"):e[s]=n}}const ps=["Webkit","Moz","ms"],rn={};function Ro(e,t){const n=rn[t];if(n)return n;let s=pe(t);if(s!=="filter"&&s in e)return rn[t]=s;s=Lt(s);for(let r=0;r{let e=Date.now,t=!1;if(typeof window<"u"){Date.now()>document.createEvent("Event").timeStamp&&(e=performance.now.bind(performance));const n=navigator.userAgent.match(/firefox\/(\d+)/i);t=!!(n&&Number(n[1])<=53)}return[e,t]})();let xn=0;const Lo=Promise.resolve(),So=()=>{xn=0},Uo=()=>xn||(Lo.then(So),xn=mr());function Bo(e,t,n,s){e.addEventListener(t,n,s)}function Do(e,t,n,s){e.removeEventListener(t,n,s)}function Ko(e,t,n,s,r=null){const i=e._vei||(e._vei={}),o=i[t];if(s&&o)o.value=s;else{const[c,u]=Wo(t);if(s){const d=i[t]=zo(s,r);Bo(e,c,d,u)}else o&&(Do(e,c,o,u),i[t]=void 0)}}const ms=/(?:Once|Passive|Capture)$/;function Wo(e){let t;if(ms.test(e)){t={};let n;for(;n=e.match(ms);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[Ve(e.slice(2)),t]}function zo(e,t){const n=s=>{const r=s.timeStamp||mr();(Ho||r>=n.attached-1)&&le(qo(s,n.value),t,5,[s])};return n.value=e,n.attached=Uo(),n}function qo(e,t){if(P(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const _s=/^on[a-z]/,Jo=(e,t,n,s,r=!1,i,o,c,u)=>{t==="class"?Mo(e,s,r):t==="style"?No(e,n,s):jt(t)?Cn(t)||Ko(e,t,n,s,o):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Yo(e,t,s,r))?$o(e,t,s,i,o,c,u):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),jo(e,t,s,r))};function Yo(e,t,n,s){return s?!!(t==="innerHTML"||t==="textContent"||t in e&&_s.test(t)&&A(n)):t==="spellcheck"||t==="draggable"||t==="translate"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA"||_s.test(t)&&z(n)?!1:t in e}const ko=Z({patchProp:Jo},Fo);let bs;function Xo(){return bs||(bs=oo(ko))}const Zo=(...e)=>{const t=Xo().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=Qo(s);if(!r)return;const i=t._component;!A(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.innerHTML="";const o=n(r,!1,r instanceof SVGElement);return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t};function Qo(e){return z(e)?document.querySelector(e):e}const Vo=Zs({props:{name:{type:String,required:!0}}});const _r=(e,t)=>{const n=e.__vccOpts||e;for(const[s,r]of t)n[s]=r;return n},Go=["name","placeholder"];function el(e,t,n,s,r,i){return _e(),je("input",{class:"c-input",name:e.name,placeholder:e.name},null,8,Go)}const tl=_r(Vo,[["render",el],["__scopeId","data-v-53e2c381"]]),br=e=>(wi("data-v-8b7cdf89"),e=e(),Ei(),e),nl={key:0},sl={class:"header"},rl={class:"label"},il={key:0,class:"form-item"},ol=br(()=>Le("button",{class:"button",type:"button"},"Submit",-1)),ll=[ol],cl={key:1,class:"failure"},fl={key:2},ul=br(()=>Le("div",null,"Loading...",-1)),al=[ul],dl=Zs({__name:"App",setup(e){const t={input:tl},n=window.location.search.substring(1),r=new URLSearchParams(n).get("form"),i=`${window.location.protocol}//${window.location.host}/api/page/form/setting/${r}`,o=Tt([]),c=Tt(""),u=Tt(!1),d=Tt("");return fetch(i).then(x=>x.json()).then(x=>{var K,F,R;c.value=x.name;const E=((F=(K=x==null?void 0:x.edit)==null?void 0:K.layout)==null?void 0:F.fieldset)||[],v=E.length>0?(R=E[0])==null?void 0:R.columns:[],S=(x==null?void 0:x.columns)||{};v.forEach(ne=>{var q;let U=S[ne.name]||!1;if(U!=null&&U.edit){let Ee=((q=U.edit.props)==null?void 0:q.value)||"";U.edit.label=ne.name,U.edit.field=Ee.replace(":",""),U.edit.type=t[U.edit.type],o.value.push(U.edit)}}),u.value=!0}).catch(x=>{console.log("ERR",x),d.value=x.message}),(x,E)=>u.value?(_e(),je("div",nl,[Le("div",sl,Qt(c.value),1),Le("form",null,[(_e(!0),je(ae,null,Ji(o.value,v=>(_e(),je("div",{class:"form-item",key:v.label},[Le("div",rl,Qt(v.label),1),(_e(),dr(zi(v.type),{name:v.field},null,8,["name"]))]))),128)),o.value?(_e(),je("div",il,ll)):mo("",!0)])])):d.value?(_e(),je("div",cl,Qt(d.value),1)):(_e(),je("div",fl,al))}});const hl=_r(dl,[["__scopeId","data-v-8b7cdf89"]]);Zo(hl).mount("#app"); diff --git a/demo/ui/vue3/assets/index.dbbe974b.css b/demo/ui/vue3/assets/index.dbbe974b.css new file mode 100644 index 0000000000000000000000000000000000000000..f021da8ebde3d45222c997bc146fdf63b2b3c6ea --- /dev/null +++ b/demo/ui/vue3/assets/index.dbbe974b.css @@ -0,0 +1 @@ +.c-input[data-v-53e2c381]{width:300px;height:32px}.header[data-v-8b7cdf89]{font-size:1.1rem;margin-bottom:.5em}.failure[data-v-8b7cdf89]{color:red}.form-item[data-v-8b7cdf89]{display:flex;width:400px;justify-content:space-between;margin-bottom:15px}.form-item .label[data-v-8b7cdf89]{font-weight:400;text-align:right;width:80px;line-height:32px}.form-item .button[data-v-8b7cdf89]{width:100%;height:32px}@media (min-width: 1024px){header[data-v-8b7cdf89]{display:flex;place-items:center;padding-right:calc(var(--section-gap) / 2)}.logo[data-v-8b7cdf89]{margin:0 2rem 0 0}header .wrapper[data-v-8b7cdf89]{display:flex;place-items:flex-start;flex-wrap:wrap}}:root{--vt-c-white: #ffffff;--vt-c-white-soft: #f8f8f8;--vt-c-white-mute: #f2f2f2;--vt-c-black: #181818;--vt-c-black-soft: #222222;--vt-c-black-mute: #282828;--vt-c-indigo: #2c3e50;--vt-c-divider-light-1: rgba(60, 60, 60, .29);--vt-c-divider-light-2: rgba(60, 60, 60, .12);--vt-c-divider-dark-1: rgba(84, 84, 84, .65);--vt-c-divider-dark-2: rgba(84, 84, 84, .48);--vt-c-text-light-1: var(--vt-c-indigo);--vt-c-text-light-2: rgba(60, 60, 60, .66);--vt-c-text-dark-1: var(--vt-c-white);--vt-c-text-dark-2: rgba(235, 235, 235, .64)}:root{--color-background: var(--vt-c-white);--color-background-soft: var(--vt-c-white-soft);--color-background-mute: var(--vt-c-white-mute);--color-border: var(--vt-c-divider-light-2);--color-border-hover: var(--vt-c-divider-light-1);--color-heading: var(--vt-c-text-light-1);--color-text: var(--vt-c-text-light-1);--section-gap: 160px}@media (prefers-color-scheme: dark){:root{--color-background: var(--vt-c-black);--color-background-soft: var(--vt-c-black-soft);--color-background-mute: var(--vt-c-black-mute);--color-border: var(--vt-c-divider-dark-2);--color-border-hover: var(--vt-c-divider-dark-1);--color-heading: var(--vt-c-text-dark-1);--color-text: var(--vt-c-text-dark-2)}}*,*:before,*:after{box-sizing:border-box;margin:0;position:relative;font-weight:400}body{min-height:100vh;color:var(--color-text);background:var(--color-background);transition:color .5s,background-color .5s;line-height:1.6;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:15px;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#app{max-width:1280px;margin:0 auto;padding:2rem;font-weight:400}a,.green{text-decoration:none;color:#00bd7e;transition:.4s}@media (hover: hover){a:hover{background-color:#00bd7e33}}@media (min-width: 1024px){body{display:flex;place-items:center}#app{display:grid;grid-template-columns:1fr 1fr;padding:0 2rem}} diff --git a/demo/ui/vue3/favicon.ico b/demo/ui/vue3/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 Binary files /dev/null and b/demo/ui/vue3/favicon.ico differ diff --git a/demo/ui/vue3/index.html b/demo/ui/vue3/index.html new file mode 100644 index 0000000000000000000000000000000000000000..ec8c08405e893bd34d3e7446f9ff110052eae173 --- /dev/null +++ b/demo/ui/vue3/index.html @@ -0,0 +1,15 @@ + + + + + + + Vite App + + + + +
+ + + diff --git a/demo/widgets/README.md b/demo/widgets/README.md new file mode 100644 index 0000000000000000000000000000000000000000..94b1e110424057f6663dc0f5e0753a63c1c8516a --- /dev/null +++ b/demo/widgets/README.md @@ -0,0 +1 @@ +# Dyform diff --git a/demo/widgets/dyform/compile.js b/demo/widgets/dyform/compile.js new file mode 100644 index 0000000000000000000000000000000000000000..1a8ea400114e92847d956a57fef8b1877014d6e4 --- /dev/null +++ b/demo/widgets/dyform/compile.js @@ -0,0 +1,58 @@ +/** + * The DSL compiler. + * Translate the customize DSL to Models, Processes, Flows, Tables, etc. + */ + +/** + * Source + * Where to get the source of DSL + */ +function Source() { + var sources = {}; + tpls = Process("models.template.Get", { select: ["id", "dsl"], limit: 2000 }); + if (tpls.code && tpls.message) { + log.Error("Load dyform sources: %s", tpls.message); + return sources; + } + + tpls.forEach((tpl) => { + tpl = tpl || {}; + try { + instance = `instance_${tpl.id}`; + dsl = JSON.parse(tpl.dsl); + sources[instance] = dsl; + } catch (e) { + log.Error("Source %v DSL: %s", tpl.id, e.message); + return; + } + }); + + return sources; +} + +/** + * Compile + * Translate or extend the customize DSL + * @param {*} dsl + */ +function Compile(name, dsl) { + return dsl; +} + +/** + * OnLoad + * When the widget instance are loaded, the function will be called. + * For preparing the sources the widget need. + * @param {DSL} dsl + */ +function OnLoad(name, dsl) { + log.Info("[Widget] dyform %s loaded", name); +} + +/** + * Migrate + * When the migrate command executes, the function will be called + * @param {DSL} dsl + * @param {bool} force + */ +function Migrate(dsl, force) {} diff --git a/demo/widgets/dyform/export.js b/demo/widgets/dyform/export.js new file mode 100644 index 0000000000000000000000000000000000000000..8292824fef6409963ae0c8a8dbdcd4c7d731dec6 --- /dev/null +++ b/demo/widgets/dyform/export.js @@ -0,0 +1,36 @@ +/** + * Export Models, APIs, Tables, Tasks, Schedules, etc. + */ + +/** + * Export API + */ +function APIs() {} + +/** + * Export Models + * @param {*} name + * @param {*} dsl + */ +function Models(name, dsl) { + var exportModels = {}; + const models = Process("widgets.dyform.Model", name, dsl); + models.forEach((model) => { + exportModels[model.name] = model.dsl; + }); + return exportModels; +} + +/** + * Export Tables + * @param {*} name + * @param {*} dsl + */ +function Tables(name, dsl) { + var exportTables = {}; + const tables = Process("widgets.dyform.Table", name, dsl); + tables.forEach((table) => { + exportTables[table.name] = table.dsl; + }); + return exportTables; +} diff --git a/demo/widgets/dyform/process.js b/demo/widgets/dyform/process.js new file mode 100644 index 0000000000000000000000000000000000000000..1dfbe0877c52d77de01f880d5d32ad4b4742a9e0 --- /dev/null +++ b/demo/widgets/dyform/process.js @@ -0,0 +1,316 @@ +/** + * Export the widget processes + * Export() defined witch function in this file will be registered as YAO PROCESS + * The process name is widgets.. + * The process args are [, ] + * + * @todo: + * The processes can be used in compile.js and export.js DIRECTLY + */ + +/** + * Model + * Convert DSL to yao model + * + * @debug + * yao run widgets.dyform.Model test '::{"name":"TEST", "decription":"A TEST DYFORM", "columns":[{"title":"First Name","name":"name","type":"input","search":true,"props":{"placeholder":"Please input your first name"}},{"title":"Amount","name":"amount","type":"input","search":true,"props":{"placeholder":"Please input amount"}},{"title":"Description","name":"desc","type":"textArea","props":{"placeholder":"Please input Description"}}]}' + * + * @name: widgets.dyform.Model + * @param {String} instance the instance name + * @param {*} payload + */ +function Model(instance, dsl) { + const name = `dyform.${instance}`; + return [{ name: name, dsl: toModel(instance, dsl) }]; +} + +/** + * Table + * Convert DSL to yao table + * + * @debug + * yao run widgets.dyform.Table test '::{"name":"TEST", "decription":"A TEST DYFORM", "columns":[{"title":"First Name","name":"name","type":"input","search":true,"props":{"placeholder":"Please input your first name"}},{"title":"Amount","name":"amount","type":"input","search":true,"props":{"placeholder":"Please input amount"}},{"title":"Description","name":"desc","type":"textArea","props":{"placeholder":"Please input Description"}}]}' + * + * @name: widgets.dyform.Model + * @param {String} instance the instance name + * @param {*} payload + */ +function Table(instance, dsl) { + const name = `dyform.${instance}`; + return [{ name: name, dsl: toTable(instance, dsl) }]; +} + +/** + * Save + * MIGRATE the given instance shcema, and (re)load the instance + * + * @debug + * yao run widgets.dyform.Save test '::{"name":"TEST", "decription":"A TEST DYFORM", "columns":[{"title":"First Name","name":"name","type":"input","search":true,"props":{"placeholder":"Please input your first name"}},{"title":"Amount","name":"amount","type":"input","search":true,"props":{"placeholder":"Please input amount"}},{"title":"Description","name":"desc","type":"textArea","props":{"placeholder":"Please input Description"}}]}' + * + * @param {*} instance + * @param {*} dsl + */ +function Save(instance, dsl) { + if (migrateModel(instance, dsl) === false) { + return false; + } + + // Reload Instance + log.Info("[Widget] dyform reload %s", instance); + var res = Process("widgets.dyform.Reload", instance, JSON.stringify(dsl)); + if (res && res.code != 200 && res.message) { + log.Error("widgets.dyform.Save: %s", res.message); + return false; + } + return true; +} + +/** + * Delete + * REMOVE the given instance schema + * + * @debug + * yao run widgets.dyform.Delete test + * + * @param {*} instance + */ +function Delete(instance) { + var res = Process("schemas.default.TableDrop", `dyform_${instance}`); + if (res && res.code != 200 && res.message) { + log.Error("widgets.dyform.Delete: %s", res.message); + return false; + } + return true; +} + +/** + * migrateModel + * @param {*} instance + * @param {*} dsl + */ +function migrateModel(instance, dsl) { + if (!instance) { + log.Error("widgets.dyform.Save: missing instance"); + return false; + } + + dsl = dsl || {}; + var schNew = toModel(instance, dsl); + + // Customize the table creation logic + // var schOld = Process("schemas.default.TableGet", `dyform_${instance}`); + // if (schOld.code != 200 && schOld.message) { + // if (!schOld.message.includes("not exists")) { + // log.Error("widgets.dyform.Save: %s", schOld.message); + // return false; + // } + + // // Create schema + // var res = Process( + // "schemas.default.TableCreate", + // `dyform_${instance}`, + // schNew + // ); + // if (res && res.code != 200 && res.message) { + // log.Error("widgets.dyform.Save: %s", res.message); + // return false; + // } + // return true; + // } + + // Upgrade schema + var res = Process("schemas.default.TableSave", `dyform_${instance}`, schNew); + if (res && res.code != 200 && res.message) { + log.Error("widgets.dyform.Save: %s", res.message); + return false; + } + + return true; +} + +/** + * Generate a model + * @param {*} instance + * @param {*} payload + * @returns + */ +function toModel(instance, payload) { + payload = payload || {}; + const tableName = `dyform_${instance}`; // the shcema table name + const columns = payload.columns || []; + var modelTemplate = { + name: `AUTO GENERATE BY DYFORM ${instance}`, + table: { name: tableName, comment: "dyform data store" }, + columns: [{ label: "ID", name: "id", type: "ID", comment: "ID" }], + indexes: [], + }; + + columns.forEach((column) => { + var col = castModelColumn(column); + if (col) { + modelTemplate.columns.push(col); + } + }); + + return modelTemplate; +} + +/** + * Generate a table + * @param {*} instance + * @param {*} payload + */ +function toTable(instance, payload) { + payload = payload || {}; + const columns = payload.columns || []; + const modelName = `dyform.${instance}`; // the model name + var tableTemplate = { + name: payload.name || instance, + version: "1.0.0", + decription: payload.decription || "a dyform instance", + bind: { model: modelName }, + columns: {}, + filters: {}, + list: { + primary: "id", + layout: { columns: [], filters: [] }, + actions: { + pagination: { props: { showTotal: true } }, + create: { props: { label: "Create" } }, + }, + option: { operation: { unfold: true } }, + }, + edit: { + primary: "id", + layout: { + fieldset: [{ columns: [] }], + }, + actions: { + cancel: {}, + save: {}, + delete: { type: "button", props: { label: "Delete" } }, + }, + option: { dev: true }, + }, + }; + + columns.forEach((column) => { + var col = castTableColumn(column); + if (col) { + col.columns.forEach((c) => (tableTemplate.columns[c.name] = c.component)); + col.filters.forEach((f) => (tableTemplate.filters[f.name] = f.filter)); + col.edit.forEach((c) => + tableTemplate.edit.layout.fieldset[0].columns.push(c) + ); + col.list.columns.forEach((c) => + tableTemplate.list.layout.columns.push(c) + ); + col.list.filters.forEach((f) => + tableTemplate.list.layout.filters.push(f) + ); + } + }); + + return tableTemplate; +} + +function castTableColumn(column) { + column = column || {}; + const props = column.props || {}; + const title = column.title; + const name = column.name; + const bind = `:${name}`; + if (!name) { + log.Error("castTableColumn: missing name"); + return false; + } + + if (!title) { + log.Error("castTableColumn: missing title"); + return false; + } + + var res = { + columns: [], + filters: [], + list: { columns: [], filters: [] }, + edit: [], + }; + + // Converted to custom component, here converted to Yao table widget + var component = { + label: title, + view: { type: "label", props: { value: `:${name}` } }, + edit: {}, + }; + + switch (column.type) { + case "input": + component.edit = { type: "input", props: { value: bind } }; + res.list.columns.push({ name: title }); + res.edit.push({ name: title, width: 24 }); + break; + case "textArea": + component.edit = { type: "textArea", props: { value: bind } }; + res.list.columns.push({ name: title }); + res.edit.push({ name: title, width: 24 }); + break; + default: + log.Error("castTableColumn: Type %s does not support", column.type); + return false; + } + + res.columns.push({ name: title, component: component }); + + // Convert to filter based on DSL description + if (column.search) { + var filter = { + label: title, + bind: `where.${name}.match`, + input: { + type: "input", + props: { placeholder: props.placeholder || `type ${title}...` }, + }, + }; + res.filters.push({ name: title, filter: filter }); + res.list.filters.push({ name: title }); + } + + return res; +} + +function castModelColumn(column) { + column = column || {}; + if (!column.name) { + log.Error("castModelColumn: missing name"); + return false; + } + + var col = { + name: column.name, + label: column.title, + comment: column.title, + index: column.search ? true : false, + }; + + // Convert to data model based on custom component type for storing data + switch (column.type) { + case "input": + col.type = "string"; + col.length = 200; + return col; + case "textArea": + col.type = "text"; + return col; + } + + log.Error("castModelColumn: Type %s does not support", column.type); + return false; +} + +/** + * Export processes + */ +function Export() { + return { Model: "Model", Table: "Table", Save: "Save", Delete: "Delete" }; +} diff --git a/demo/widgets/dyform/widget.json b/demo/widgets/dyform/widget.json new file mode 100644 index 0000000000000000000000000000000000000000..761c4f00ea27421c3874f59f6512e245eafbd9f3 --- /dev/null +++ b/demo/widgets/dyform/widget.json @@ -0,0 +1,8 @@ +{ + "label": "Dynamic Form", + "description": "A form widget. users can design forms online", + "version": "0.1.0", + "root": "dyforms", + "extension": ".form.json", + "modules": ["Models", "Tables"] +} diff --git a/demo/yao/icons/icon.icns b/demo/yao/icons/icon.icns new file mode 100644 index 0000000000000000000000000000000000000000..4bbac95c101a35adacb3c324feae79755c4e1675 Binary files /dev/null and b/demo/yao/icons/icon.icns differ diff --git a/demo/yao/icons/icon.ico b/demo/yao/icons/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..2b21446fae631b549e8f52c2dedf4fb074fe3744 Binary files /dev/null and b/demo/yao/icons/icon.ico differ diff --git a/demo/yao/icons/icon.png b/demo/yao/icons/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..8a18f60b3fd6251a1165364678ebe80a3b91b3f3 Binary files /dev/null and b/demo/yao/icons/icon.png differ