diff --git a/.eslintrc.json b/.eslintrc.json index 2d525873a..f93c56b43 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,7 +2,8 @@ "env": { "browser": true, "es6": true, - "jest": true + "jest": true, + "node": true }, "parserOptions": { "ecmaVersion": 2019, diff --git a/.prettierrc b/.prettierrc index ce02997c9..e23b0be75 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,6 @@ "semi": false, "singleQuote": false, "trailingComma": "es5", - "plugins": ["prettier-plugin-svelte"] + "plugins": ["prettier-plugin-svelte"], + "svelteSortOrder" : "scripts-markup-styles" } \ No newline at end of file diff --git a/package.json b/package.json index 57a3080fb..7a4116e74 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "eslint-plugin-svelte3": "^2.7.3", "lerna": "^3.14.1", "prettier": "^1.19.1", - "prettier-plugin-svelte": "^0.7.0" + "prettier-plugin-svelte": "^0.7.0", + "svelte": "^3.18.1" }, "dependencies": {}, "scripts": { @@ -18,6 +19,7 @@ "dev": "lerna run --parallel --stream dev:builder", "test": "lerna run test", "lint": "eslint packages", - "format": "prettier --write \"{,!(node_modules)/**/}*.{js,jsx}\"" + "lint:fix": "eslint --fix packages", + "format": "prettier --write \"{,!(node_modules)/**/}*.{js,jsx,svelte}\"" } } diff --git a/packages/bootstrap-components/dist/generators.js b/packages/bootstrap-components/dist/generators.js index 1021b0975..d4187e4fc 100644 --- a/packages/bootstrap-components/dist/generators.js +++ b/packages/bootstrap-components/dist/generators.js @@ -1,450 +1,444 @@ const buttons = () => [ - { - name: "common/Primary Button", - description: "Bootstrap primary button ", - inherits: "@budibase/standard-components/button", - props: { - className: "btn btn-primary" - } + { + name: "common/Primary Button", + description: "Bootstrap primary button ", + inherits: "@budibase/standard-components/button", + props: { + className: "btn btn-primary", }, - { - name: "common/Default Button", - description: "Bootstrap default button", - inherits: "@budibase/standard-components/button", - props: { - className: "btn btn-secondary" - } - } -]; + }, + { + name: "common/Default Button", + description: "Bootstrap default button", + inherits: "@budibase/standard-components/button", + props: { + className: "btn btn-secondary", + }, + }, +] -const forms = ({records, indexes, helpers}) => - [ - ...records.map(root), - ...buttons() - ]; +const forms = ({ records, indexes, helpers }) => [ + ...records.map(root), + ...buttons(), +] -const formName = record => `${record.name}/${record.name} Form`; +const formName = record => `${record.name}/${record.name} Form` const root = record => ({ - name: formName(record), - description: `Control for creating/updating '${record.nodeKey()}' `, - inherits: "@budibase/standard-components/div", - props: { - className:"p-1", - children: [ - { - component: { - _component: "@budibase/standard-components/h3", - text: `Edit ${record.name}`, - } - }, - form(record), - saveCancelButtons(record) - ] - } -}); + name: formName(record), + description: `Control for creating/updating '${record.nodeKey()}' `, + inherits: "@budibase/standard-components/div", + props: { + className: "p-1", + children: [ + { + component: { + _component: "@budibase/standard-components/h3", + text: `Edit ${record.name}`, + }, + }, + form(record), + saveCancelButtons(record), + ], + }, +}) const form = record => ({ - component: { - _component: "@budibase/standard-components/form", - formControls: - record.fields.map(f => formControl(record, f)) - } -}); + component: { + _component: "@budibase/standard-components/form", + formControls: record.fields.map(f => formControl(record, f)), + }, +}) const formControl = (record, field) => { - if(field.type === "string" && field.typeOptions.values && field.typeOptions.values.length > 0) { - return ({ - control: { - _component: "@budibase/standard-components/select", - options: field.typeOptions.values.map(v => ({id:v, value:v})), - value: { - "##bbstate":`${record.name}.${field.name}`, - "##bbsource":"store" - }, - className: "form-control" - }, - label: field.label - }); - } else { - return ({ - control: { - _component: "@budibase/standard-components/input", - value: { - "##bbstate":`${record.name}.${field.name}`, - "##bbsource":"store" - }, - className: "form-control", - type: field.type === "string" ? "text" - : field.type === "datetime" ? "date" - : field.type === "number" ? "number" - : "text" - }, - label: field.label - }); - } -}; - -const saveCancelButtons = (record) => ({ - component: { - _component: "@budibase/standard-components/stackpanel", - direction: "horizontal", - children: [ - paddedPanelForButton({ - _component: "common/Primary Button", - contentText: `Save ${record.name}`, - onClick: [ - { - "##eventHandlerType": "Save Record", - parameters: { - statePath: `${record.name}`, - } - }, - { - "##eventHandlerType": "Set State", - parameters: { - path: `isEditing${record.name}`, - value: "" - } - } - ] - }), - paddedPanelForButton({ - _component: "common/Default Button", - contentText: `Cancel`, - onClick: [ - { - "##eventHandlerType": "Set State", - parameters: { - path: `isEditing${record.name}`, - value: "" - } - } - ] - }) - ] + if ( + field.type === "string" && + field.typeOptions.values && + field.typeOptions.values.length > 0 + ) { + return { + control: { + _component: "@budibase/standard-components/select", + options: field.typeOptions.values.map(v => ({ id: v, value: v })), + value: { + "##bbstate": `${record.name}.${field.name}`, + "##bbsource": "store", + }, + className: "form-control", + }, + label: field.label, } -}); - -const paddedPanelForButton = (button) => ({ - control: { - _component: "@budibase/standard-components/div", - className: "btn-group", - children: [ - { - component: button - } - ] + } else { + return { + control: { + _component: "@budibase/standard-components/input", + value: { + "##bbstate": `${record.name}.${field.name}`, + "##bbsource": "store", + }, + className: "form-control", + type: + field.type === "string" + ? "text" + : field.type === "datetime" + ? "date" + : field.type === "number" + ? "number" + : "text", + }, + label: field.label, } -}); - -const getRecordPath = (record) => { - - const parts = []; - - return parts.reverse().join("/"); -}; - -const indexTables = ({indexes, helpers}) => - indexes.map(i => indexTable(i, helpers)); - -const excludedColumns = ["id", "isNew", "key", "type", "sortKey"]; - -const indexTableProps = (index, helpers) => ({ - data: { - "##bbstate":index.nodeKey(), - "##bbsource":"store" - }, - tableClass: "table table-hover", - theadClass: "thead-dark", - columns: helpers - .indexSchema(index) - .filter(c => !excludedColumns.includes(c.name)) - .map(column), - onRowClick: [ - { + } +} + +const saveCancelButtons = record => ({ + component: { + _component: "@budibase/standard-components/stackpanel", + direction: "horizontal", + children: [ + paddedPanelForButton({ + _component: "common/Primary Button", + contentText: `Save ${record.name}`, + onClick: [ + { + "##eventHandlerType": "Save Record", + parameters: { + statePath: `${record.name}`, + }, + }, + { + "##eventHandlerType": "Set State", + parameters: { + path: `isEditing${record.name}`, + value: "", + }, + }, + ], + }), + paddedPanelForButton({ + _component: "common/Default Button", + contentText: `Cancel`, + onClick: [ + { "##eventHandlerType": "Set State", parameters: { - path: `selectedrow_${index.name}`, - value: { - "##bbstate": "key", - "##bbsource": "event" - } + path: `isEditing${record.name}`, + value: "", }, - } - ] -}); + }, + ], + }), + ], + }, +}) + +const paddedPanelForButton = button => ({ + control: { + _component: "@budibase/standard-components/div", + className: "btn-group", + children: [ + { + component: button, + }, + ], + }, +}) + +const getRecordPath = record => { + const parts = [] + + return parts.reverse().join("/") +} + +const indexTables = ({ indexes, helpers }) => + indexes.map(i => indexTable(i, helpers)) + +const excludedColumns = ["id", "isNew", "key", "type", "sortKey"] + +const indexTableProps = (index, helpers) => ({ + data: { + "##bbstate": index.nodeKey(), + "##bbsource": "store", + }, + tableClass: "table table-hover", + theadClass: "thead-dark", + columns: helpers + .indexSchema(index) + .filter(c => !excludedColumns.includes(c.name)) + .map(column), + onRowClick: [ + { + "##eventHandlerType": "Set State", + parameters: { + path: `selectedrow_${index.name}`, + value: { + "##bbstate": "key", + "##bbsource": "event", + }, + }, + }, + ], +}) const getIndexTableName = (index, record) => { - record = record - || index.parent().type === "record" ? index.parent() : null; - - return (record - ? `${getRecordPath()}/${index.name} Table` - : `${index.name} Table`); -}; + record = record || index.parent().type === "record" ? index.parent() : null + + return record + ? `${getRecordPath()}/${index.name} Table` + : `${index.name} Table` +} const indexTable = (index, helpers) => ({ - name: getIndexTableName(index), - inherits: "@budibase/standard-components/table", - props: indexTableProps(index, helpers) -}); - -const column = (col) => ({ - title: col.name, - value: { - "##bbstate": col.name, - "##bbsource":"context" - } -}); + name: getIndexTableName(index), + inherits: "@budibase/standard-components/table", + props: indexTableProps(index, helpers), +}) + +const column = col => ({ + title: col.name, + value: { + "##bbstate": col.name, + "##bbsource": "context", + }, +}) -const recordHomePageComponents = ({indexes, records, helpers}) => - [ - ...recordHomepages({indexes, records}) - .map(component), +const recordHomePageComponents = ({ indexes, records, helpers }) => [ + ...recordHomepages({ indexes, records }).map(component), - ...recordHomepages({indexes, records}) - .map(homePageButtons), - - ...indexTables({indexes, records, helpers}), + ...recordHomepages({ indexes, records }).map(homePageButtons), - ...buttons() - ]; + ...indexTables({ indexes, records, helpers }), + ...buttons(), +] const findIndexForRecord = (indexes, record) => { - const forRecord = indexes.filter(i => i.allowedRecordNodeIds.includes(record.nodeId)); - if(forRecord.length === 0) return; - if(forRecord.length === 1) return forRecord[0]; - const noMap = forRecord.filter(i => !i.filter || !i.filter.trim()); - if(noMap.length === 0) forRecord[0]; - return noMap[0]; -}; - -const recordHomepages = ({indexes, records}) => - records.filter(r => r.parent().type === "root") - .map(r =>({ - record:r, - index:findIndexForRecord(indexes, r) - })) - .filter(r => r.index); - - -const homepageComponentName = (record) => - `${record.name}/${record.name} homepage`; - -const component = ({record, index}) => ({ - inherits: "@budibase/standard-components/div", - name: homepageComponentName(record), - props: { - className: "d-flex flex-column h-100", - children: [ + const forRecord = indexes.filter(i => + i.allowedRecordNodeIds.includes(record.nodeId) + ) + if (forRecord.length === 0) return + if (forRecord.length === 1) return forRecord[0] + const noMap = forRecord.filter(i => !i.filter || !i.filter.trim()) + if (noMap.length === 0) forRecord[0] + return noMap[0] +} + +const recordHomepages = ({ indexes, records }) => + records + .filter(r => r.parent().type === "root") + .map(r => ({ + record: r, + index: findIndexForRecord(indexes, r), + })) + .filter(r => r.index) + +const homepageComponentName = record => `${record.name}/${record.name} homepage` + +const component = ({ record, index }) => ({ + inherits: "@budibase/standard-components/div", + name: homepageComponentName(record), + props: { + className: "d-flex flex-column h-100", + children: [ + { + component: { + _component: `${record.name}/homepage buttons`, + }, + }, + { + component: { + _component: getIndexTableName(index), + }, + className: "flex-gow-1 overflow-auto", + }, + ], + onLoad: [ + { + "##eventHandlerType": "Set State", + parameters: { + path: `isEditing${record.name}`, + value: "", + }, + }, + { + "##eventHandlerType": "List Records", + parameters: { + statePath: index.nodeKey(), + indexKey: index.nodeKey(), + }, + }, + ], + }, +}) + +const homePageButtons = ({ index, record }) => ({ + inherits: "@budibase/standard-components/div", + name: `${record.name}/homepage buttons`, + props: { + className: "btn-toolbar mt-4 mb-2", + children: [ + { + component: { + _component: "@budibase/standard-components/div", + className: "btn-group mr-3", + children: [ { - component: { - _component: `${record.name}/homepage buttons`, - } + component: { + _component: "common/Default Button", + contentText: `Create ${record.name}`, + onClick: [ + { + "##eventHandlerType": "Get New Record", + parameters: { + statePath: record.name, + collectionKey: `/${record.collectionName}`, + childRecordType: record.name, + }, + }, + { + "##eventHandlerType": "Set State", + parameters: { + path: `isEditing${record.name}`, + value: "true", + }, + }, + ], + }, }, { - component: { - _component: getIndexTableName(index) - }, - className: "flex-gow-1 overflow-auto" - } - ], - onLoad: [ - { - "##eventHandlerType": "Set State", - parameters: { - path: `isEditing${record.name}`, - value: "" - } + component: { + _component: "common/Default Button", + contentText: `Refresh`, + onClick: [ + { + "##eventHandlerType": "List Records", + parameters: { + statePath: index.nodeKey(), + indexKey: index.nodeKey(), + }, + }, + ], + }, }, - { - "##eventHandlerType": "List Records", - parameters: { - statePath: index.nodeKey(), - indexKey: index.nodeKey() - } - } - ] - } - -}); - -const homePageButtons = ({index, record}) => ({ - inherits: "@budibase/standard-components/div", - name: `${record.name}/homepage buttons`, - props: { - className: "btn-toolbar mt-4 mb-2", - children: [ - { + ], + }, + }, + { + component: { + _component: "@budibase/standard-components/if", + condition: `$store.selectedrow_${index.name} && $store.selectedrow_${index.name}.length > 0`, + thenComponent: { + _component: "@budibase/standard-components/div", + className: "btn-group", + children: [ + { component: { - _component: "@budibase/standard-components/div", - className: "btn-group mr-3", - children: [ - { - component: { - _component: "common/Default Button", - contentText: `Create ${record.name}`, - onClick: [ - { - "##eventHandlerType": "Get New Record", - parameters: { - statePath: record.name, - collectionKey: `/${record.collectionName}`, - childRecordType: record.name - } - }, - { - "##eventHandlerType": "Set State", - parameters: { - path: `isEditing${record.name}`, - value: "true" - } - } - ] - } + _component: "common/Default Button", + contentText: `Edit ${record.name}`, + onClick: [ + { + "##eventHandlerType": "Load Record", + parameters: { + statePath: record.name, + recordKey: { + "##bbstate": `selectedrow_${index.name}`, + "##source": "store", }, - { - component: { - _component: "common/Default Button", - contentText: `Refresh`, - onClick: [ - { - "##eventHandlerType": "List Records", - parameters: { - statePath: index.nodeKey(), - indexKey: index.nodeKey() - } - } - ] - } - } - ] - } - }, - { + }, + }, + { + "##eventHandlerType": "Set State", + parameters: { + path: `isEditing${record.name}`, + value: "true", + }, + }, + ], + }, + }, + { component: { - _component: "@budibase/standard-components/if", - condition: `$store.selectedrow_${index.name} && $store.selectedrow_${index.name}.length > 0`, - thenComponent: { - _component: "@budibase/standard-components/div", - className: "btn-group", - children: [ - { - component: { - _component: "common/Default Button", - contentText: `Edit ${record.name}`, - onClick: [ - { - "##eventHandlerType": "Load Record", - parameters: { - statePath: record.name, - recordKey: { - "##bbstate" : `selectedrow_${index.name}`, - "##source": "store" - } - } - }, - { - "##eventHandlerType": "Set State", - parameters: { - path: `isEditing${record.name}`, - value: "true" - } - } - ] - } - }, - { - component: { - _component: "common/Default Button", - contentText: `Delete ${record.name}`, - onClick: [ - { - "##eventHandlerType": "Delete Record", - parameters: { - recordKey: { - "##bbstate" : `selectedrow_${index.name}`, - "##source": "store" - } - } - } - ] - } - } - ] - } - } - } - ] - } -}); - -const selectNavContent = ({indexes, records, helpers}) => - [ - ...recordHomepages({indexes, records}) - .map(component$1), - - ...recordHomePageComponents({indexes, records, helpers}), + _component: "common/Default Button", + contentText: `Delete ${record.name}`, + onClick: [ + { + "##eventHandlerType": "Delete Record", + parameters: { + recordKey: { + "##bbstate": `selectedrow_${index.name}`, + "##source": "store", + }, + }, + }, + ], + }, + }, + ], + }, + }, + }, + ], + }, +}) - ...forms({indexes, records, helpers}) +const selectNavContent = ({ indexes, records, helpers }) => [ + ...recordHomepages({ indexes, records }).map(component$1), - ]; + ...recordHomePageComponents({ indexes, records, helpers }), + ...forms({ indexes, records, helpers }), +] const navContentComponentName = record => - `${record.name}/${record.name} Nav Content`; - -const component$1 = ({record, index}) => ({ - inherits: "@budibase/standard-components/if", - description: `the component that gets displayed when the ${record.collectionName} nav is selected`, - name: navContentComponentName(record), - props: { - condition: `$store.isEditing${record.name}`, - thenComponent: { - _component: formName(record) - }, - elseComponent: { - _component: homepageComponentName(record) - } - } -}); - -const app = ({records, indexes, helpers}) => [ - { - name: "Application Root", - inherits: "@budibase/bootstrap-components/nav", - props: { - items: recordHomepages({indexes, records}) - .map(navItem), - orientation: "horizontal", - alignment: "start", - fill: false, - pills: true, - selectedItem: { - "##bbstate":"selectedNav", - "##bbstatefallback":`${records[0].name}`, - "##bbsource": "store" - }, - className: "p-3" - } + `${record.name}/${record.name} Nav Content` + +const component$1 = ({ record, index }) => ({ + inherits: "@budibase/standard-components/if", + description: `the component that gets displayed when the ${record.collectionName} nav is selected`, + name: navContentComponentName(record), + props: { + condition: `$store.isEditing${record.name}`, + thenComponent: { + _component: formName(record), }, - { - name: "Login", - inherits: "@budibase/standard-components/login", - props: {} + elseComponent: { + _component: homepageComponentName(record), }, - ...selectNavContent({records, indexes, helpers}) -]; - - -const navItem = ({record}) => ({ - title: record.collectionName, - component : { - _component: navContentComponentName(record) - } -}); + }, +}) -export { app, forms, indexTables, recordHomePageComponents as recordHomepages }; +const app = ({ records, indexes, helpers }) => [ + { + name: "Application Root", + inherits: "@budibase/bootstrap-components/nav", + props: { + items: recordHomepages({ indexes, records }).map(navItem), + orientation: "horizontal", + alignment: "start", + fill: false, + pills: true, + selectedItem: { + "##bbstate": "selectedNav", + "##bbstatefallback": `${records[0].name}`, + "##bbsource": "store", + }, + className: "p-3", + }, + }, + { + name: "Login", + inherits: "@budibase/standard-components/login", + props: {}, + }, + ...selectNavContent({ records, indexes, helpers }), +] + +const navItem = ({ record }) => ({ + title: record.collectionName, + component: { + _component: navContentComponentName(record), + }, +}) + +export { app, forms, indexTables, recordHomePageComponents as recordHomepages } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdG9ycy5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL2dlbm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3JkKSxcclxuICAgICAgICAgICAgc2F2ZUNhbmNlbEJ1dHRvbnMocmVjb3JkKVxyXG4gICAgICAgIF1cclxuICAgIH1cclxufSkgXHJcblxyXG5jb25zdCBmb3JtID0gcmVjb3JkID0+ICh7XHJcbiAgICBjb21wb25lbnQ6IHtcclxuICAgICAgICBfY29tcG9uZW50OiBcIkBidWRpYmFzZS9zdGFuZGFyZC1jb21wb25lbnRzL2Zvcm1cIixcclxuICAgICAgICBmb3JtQ29udHJvbHM6IFxyXG4gICAgICAgICAgICByZWNvcmQuZmllbGRzLm1hcChmID0+IGZvcm1Db250cm9sKHJlY29yZCwgZikpXHJcbiAgICB9XHJcbn0pXHJcblxyXG5jb25zdCBmb3JtQ29udHJvbCA9IChyZWNvcmQsIGZpZWxkKSA9PiB7XHJcbiAgICBpZihmaWVsZC50eXBlID09PSBcInN0cmluZ1wiICYmIGZpZWxkLnR5cGVPcHRpb25zLnZhbHVlcyAmJiBmaWVsZC50eXBlT3B0aW9ucy52YWx1ZXMubGVuZ3RoID4gMCkge1xyXG4gICAgICAgIHJldHVybiAoe1xyXG4gICAgICAgICAgICBjb250cm9sOiB7XHJcbiAgICAgICAgICAgICAgICBfY29tcG9uZW50OiBcIkBidWRpYmFzZS9zdGFuZGFyZC1jb21wb25lbnRzL3NlbGVjdFwiLFxyXG4gICAgICAgICAgICAgICAgb3B0aW9uczogZmllbGQudHlwZU9wdGlvbnMudmFsdWVzLm1hcCh2ID0+ICh7aWQ6diwgdmFsdWU6dn0pKSxcclxuICAgICAgICAgICAgICAgIHZhbHVlOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgXCIjI2Jic3RhdGVcIjpgJHtyZWNvcmQubmFtZX0uJHtmaWVsZC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgXCIjI2Jic291cmNlXCI6XCJzdG9yZVwiXHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgY2xhc3NOYW1lOiBcImZvcm0tY29udHJvbFwiXHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgIGxhYmVsOiBmaWVsZC5sYWJlbFxyXG4gICAgICAgIH0pO1xyXG4gICAgfSBlbHNlIHtcclxuICAgICAgICByZXR1cm4gKHtcclxuICAgICAgICAgICAgY29udHJvbDoge1xyXG4gICAgICAgICAgICAgICAgX2NvbXBvbmVudDogXCJAYnVkaWJhc2Uvc3RhbmRhcmQtY29tcG9uZW50cy9pbnB1dFwiLFxyXG4gICAgICAgICAgICAgICAgdmFsdWU6IHtcclxuICAgICAgICAgICAgICAgICAgICBcIiMjYmJzdGF0ZVwiOmAke3JlY29yZC5uYW1lfS4ke2ZpZWxkLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICBcIiMjYmJzb3VyY2VcIjpcInN0b3JlXCJcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICBjbGFzc05hbWU6IFwiZm9ybS1jb250cm9sXCIsXHJcbiAgICAgICAgICAgICAgICB0eXBlOiBmaWVsZC50eXBlID09PSBcInN0cmluZ1wiID8gXCJ0ZXh0XCJcclxuICAgICAgICAgICAgICAgICAgICA6IGZpZWxkLnR5cGUgPT09IFwiZGF0ZXRpbWVcIiA/IFwiZGF0ZVwiXHJcbiAgICAgICAgICAgICAgICAgICAgOiBmaWVsZC50eXBlID09PSBcIm51bWJlclwiID8gXCJudW1iZXJcIlxyXG4gICAgICAgICAgICAgICAgICAgIDogXCJ0ZXh0XCJcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgbGFiZWw6IGZpZWxkLmxhYmVsXHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcbn1cclxuXHJcbmNvbnN0IHNhdmVDYW5jZWxCdXR0b25zID0gKHJlY29yZCkgPT4gKHtcclxuICAgIGNvbXBvbmVudDoge1xyXG4gICAgICAgIF9jb21wb25lbnQ6IFwiQGJ1ZGliYXNlL3N0YW5kYXJkLWNvbXBvbmVudHMvc3RhY2twYW5lbFwiLFxyXG4gICAgICAgIGRpcmVjdGlvbjogXCJob3Jpem9udGFsXCIsXHJcbiAgICAgICAgY2hpbGRyZW46IFtcclxuICAgICAgICAgICAgcGFkZGVkUGFuZWxGb3JCdXR0b24oe1xyXG4gICAgICAgICAgICAgICAgX2NvbXBvbmVudDogXCJjb21tb24vUHJpbWFyeSBCdXR0b25cIixcclxuICAgICAgICAgICAgICAgIGNvbnRlbnRUZXh0OiBgU2F2ZSAke3JlY29yZC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICBvbkNsaWNrOiBbICAgICAgICAgICAgICAgIFxyXG4gICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgXCIjI2V2ZW50SGFuZGxlclR5cGVcIjogXCJTYXZlIFJlY29yZFwiLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZVBhdGg6IGAke3JlY29yZC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgXCIjI2V2ZW50SGFuZGxlclR5cGVcIjogXCJTZXQgU3RhdGVcIixcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1ldGVyczoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aDogYGlzRWRpdGluZyR7cmVjb3JkLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBcIlwiXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBdXHJcbiAgICAgICAgICAgIH0pLFxyXG4gICAgICAgICAgICBwYWRkZWRQYW5lbEZvckJ1dHRvbih7XHJcbiAgICAgICAgICAgICAgICBfY29tcG9uZW50OiBcImNvbW1vbi9EZWZhdWx0IEJ1dHRvblwiLFxyXG4gICAgICAgICAgICAgICAgY29udGVudFRleHQ6IGBDYW5jZWxgLFxyXG4gICAgICAgICAgICAgICAgb25DbGljazogW1xyXG4gICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgXCIjI2V2ZW50SGFuZGxlclR5cGVcIjogXCJTZXQgU3RhdGVcIixcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1ldGVyczoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aDogYGlzRWRpdGluZyR7cmVjb3JkLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBcIlwiXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBdXHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgXVxyXG4gICAgfVxyXG59KVxyXG5cclxuY29uc3QgcGFkZGVkUGFuZWxGb3JCdXR0b24gPSAoYnV0dG9uKSA9PiAoe1xyXG4gICAgY29udHJvbDoge1xyXG4gICAgICAgIF9jb21wb25lbnQ6IFwiQGJ1ZGliYXNlL3N0YW5kYXJkLWNvbXBvbmVudHMvZGl2XCIsXHJcbiAgICAgICAgY2xhc3NOYW1lOiBcImJ0bi1ncm91cFwiLFxyXG4gICAgICAgIGNoaWxkcmVuOiBbXHJcbiAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgIGNvbXBvbmVudDogYnV0dG9uXHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICBdXHJcbiAgICB9XHJcbn0pO1xyXG5cclxuIiwiZXhwb3J0IGNvbnN0IGdldFJlY29yZFBhdGggPSAocmVjb3JkKSA9PiB7XHJcblxyXG4gICAgY29uc3QgcGFydHMgPSBbXTtcclxuXHJcbiAgICBjb25zdCBhZGQgPSAoY3VycmVudCk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5pbmNsdWRlcyhjLm5hbWUpKVxyXG4gICAgICAgICAgICAgICAgLm1hcChjb2x1bW4pLFxyXG4gICAgb25Sb3dDbGljazogW1xyXG4gICAgICAgIHtcclxuICAgICAgICAgICAgXCIjI2V2ZW50SGFuZGxlclR5cGVcIjogXCJTZXQgU3RhdGVcIixcclxuICAgICAgICAgICAgcGFyYW1ldGVyczoge1xyXG4gICAgICAgICAgICAgICAgcGF0aDogYHNlbGVjdGVkcm93XyR7aW5kZXgubmFtZX1gLFxyXG4gICAgICAgICAgICAgICAgdmFsdWU6IHtcclxuICAgICAgICAgICAgICAgICAgICBcIiMjYmJzdGF0ZVwiOiBcImtleVwiLFxyXG4gICAgICAgICAgICAgICAgICAgIFwiIyNiYnNvdXJjZVwiOiBcImV2ZW50XCJcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSxcclxuICAgICAgICB9XHJcbiAgICBdXHJcbn0pO1xyXG5cclxuZXhwb3J0IGNvbnN0IGdldEluZGV4VGFibGVOYW1lID0gKGluZGV4LCByZWNvcmQpID0+IHtcclxuICAgIHJlY29yZCA9IHJlY29yZCBcclxuICAgICAgICAgICAgIHx8IGluZGV4LnBhcmVudCgpLnR5cGUgPT09IFwicmVjb3JkXCIgPyBpbmRleC5wYXJlbnQoKSA6IG51bGw7XHJcbiAgICBcclxuICAgIHJldHVybiAocmVjb3JkXHJcbiAgICAgICAgICAgID8gYCR7Z2V0UmVjb3JkUGF0aChyZWNvcmQpfS8ke2luZGV4Lm5hbWV9IFRhYmxlYFxyXG4gICAgICAgICAgICA6IGAke2luZGV4Lm5hbWV9IFRhYmxlYCk7XHJcbn1cclxuXHJcbmNvbnN0IGluZGV4VGFibGUgPSAoaW5kZXgsIGhlbHBlcnMpID0+ICh7XHJcbiAgICBuYW1lOiBnZXRJbmRleFRhYmxlTmFtZShpbmRleCksXHJcbiAgICBpbmhlcml0czogXCJAYnVkaWJhc2Uvc3RhbmRhcmQtY29tcG9uZW50cy90YWJsZVw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bWVwYWdlQ29tcG9uZW50TmFtZShyZWNvcmQpLFxyXG4gICAgcHJvcHM6IHtcclxuICAgICAgICBjbGFzc05hbWU6IFwiZC1mbGV4IGZsZXgtY29sdW1uIGgtMTAwXCIsXHJcbiAgICAgICAgY2hpbGRyZW46IFtcclxuICAgICAgICAgICAge1xyXG4gICAgICAgICAgICAgICAgY29tcG9uZW50OiB7XHJcbiAgICAgICAgICAgICAgICAgICAgX2NvbXBvbmVudDogYCR7cmVjb3JkLm5hbWV9L2hvbWVwYWdlIGJ1dHRvbnNgLFxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICBjb21wb25lbnQ6IHtcclxuICAgICAgICAgICAgICAgICAgICBfY29tcG9uZW50OiBnZXRJbmRleFRhYmxlTmFtZShpbmRleClcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICBjbGFzc05hbWU6IFwiZmxleC1nb3ctMSBvdmVyZmxvdy1hdXRvXCJcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIF0sXHJcbiAgICAgICAgb25Mb2FkOiBbXHJcbiAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgIFwiIyNldmVudEhhbmRsZXJUeXBlXCI6IFwiU2V0IFN0YXRlXCIsXHJcbiAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcGF0aDogYGlzRWRpdGluZyR7cmVjb3JkLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogXCJcIlxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICBcIiMjZXZlbnRIYW5kbGVyVHlwZVwiOiBcIkxpc3QgUmVjb3Jkc1wiLFxyXG4gICAgICAgICAgICAgICAgcGFyYW1ldGVyczoge1xyXG4gICAgICAgICAgICAgICAgICAgIHN0YXRlUGF0aDogaW5kZXgubm9kZUtleSgpLFxyXG4gICAgICAgICAgICAgICAgICAgIGluZGV4S2V5OiBpbmRleC5ub2RlS2V5KClcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIF1cclxuICAgIH1cclxuXHJcbn0pO1xyXG5cclxuY29uc3QgaG9tZVBhZ2VCdXR0b25zID0gKHtpbmRleCwgcmVjb3JkfSkgPT4gKHtcclxuICAgIGluaGVyaXRzOiBcIkBidWRpYmFzZS9zdGFuZGFyZC1jb21wb25lbnRzL2RpdlwiLFxyXG4gICAgbmFtZTogYCR7cmVjb3JkLm5hbWV9L2hvbWVwYWdlIGJ1dHRvbnNgLFxyXG4gICAgcHJvcHM6IHtcclxuICAgICAgICBjbGFzc05hbWU6IFwiYnRuLXRvb2xiYXIgbXQtNCBtYi0yXCIsXHJcbiAgICAgICAgY2hpbGRyZW46IFtcclxuICAgICAgICAgICAge1xyXG4gICAgICAgICAgICAgICAgY29tcG9uZW50OiB7XHJcbiAgICAgICAgICAgICAgICAgICAgX2NvbXBvbmVudDogXCJAYnVkaWJhc2Uvc3RhbmRhcmQtY29tcG9uZW50cy9kaXZcIixcclxuICAgICAgICAgICAgICAgICAgICBjbGFzc05hbWU6IFwiYnRuLWdyb3VwIG1yLTNcIixcclxuICAgICAgICAgICAgICAgICAgICBjaGlsZHJlbjogW1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb25lbnQ6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY29tcG9uZW50OiBcImNvbW1vbi9EZWZhdWx0IEJ1dHRvblwiLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRUZXh0OiBgQ3JlYXRlICR7cmVjb3JkLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkNsaWNrOiBbXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiIyNldmVudEhhbmRsZXJUeXBlXCI6IFwiR2V0IE5ldyBSZWNvcmRcIixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcnM6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZVBhdGg6IHJlY29yZC5uYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3Rpb25LZXk6IGAvJHtyZWNvcmQuY29sbGVjdGlvbk5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZFJlY29yZFR5cGU6IHJlY29yZC5uYW1lXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiMjZXZlbnRIYW5kbGVyVHlwZVwiOiBcIlNldCBTdGF0ZVwiLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1ldGVyczoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IGBpc0VkaXRpbmcke3JlY29yZC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IFwidHJ1ZVwiXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBdXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jb21wb25lbnQ6IFwiY29tbW9uL0RlZmF1bHQgQnV0dG9uXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudFRleHQ6IGBSZWZyZXNoYCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkNsaWNrOiBbXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiIyNldmVudEhhbmRsZXJUeXBlXCI6IFwiTGlzdCBSZWNvcmRzXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGVQYXRoOiBpbmRleC5ub2RlS2V5KCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXhLZXk6IGluZGV4Lm5vZGVLZXkoKVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgXVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICBjb21wb25lbnQ6IHtcclxuICAgICAgICAgICAgICAgICAgICBfY29tcG9uZW50OiBcIkBidWRpYmFzZS9zdGFuZGFyZC1jb21wb25lbnRzL2lmXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgY29uZGl0aW9uOiBgJHN0b3JlLnNlbGVjdGVkcm93XyR7aW5kZXgubmFtZX0gJiYgJHN0b3JlLnNlbGVjdGVkcm93XyR7aW5kZXgubmFtZX0ubGVuZ3RoID4gMGAsXHJcbiAgICAgICAgICAgICAgICAgICAgdGhlbkNvbXBvbmVudDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBfY29tcG9uZW50OiBcIkBidWRpYmFzZS9zdGFuZGFyZC1jb21wb25lbnRzL2RpdlwiLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGFzc05hbWU6IFwiYnRuLWdyb3VwXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkcmVuOiBbXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50OiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jb21wb25lbnQ6IFwiY29tbW9uL0RlZmF1bHQgQnV0dG9uXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRUZXh0OiBgRWRpdCAke3JlY29yZC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uQ2xpY2s6IFtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiMjZXZlbnRIYW5kbGVyVHlwZVwiOiBcIkxvYWQgUmVjb3JkXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1ldGVyczoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZVBhdGg6IHJlY29yZC5uYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWNvcmRLZXk6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiIyNiYnN0YXRlXCIgOiBgc2VsZWN0ZWRyb3dfJHtpbmRleC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiMjc291cmNlXCI6IFwic3RvcmVcIlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIjI2V2ZW50SGFuZGxlclR5cGVcIjogXCJTZXQgU3RhdGVcIixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IGBpc0VkaXRpbmcke3JlY29yZC5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBcInRydWVcIlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50OiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jb21wb25lbnQ6IFwiY29tbW9uL0RlZmF1bHQgQnV0dG9uXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRUZXh0OiBgRGVsZXRlICR7cmVjb3JkLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb25DbGljazogW1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiIyNldmVudEhhbmRsZXJUeXBlXCI6IFwiRGVsZXRlIFJlY29yZFwiLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcnM6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjb3JkS2V5OiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiMjYmJzdGF0ZVwiIDogYHNlbGVjdGVkcm93XyR7aW5kZXgubmFtZX1gLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIjI3NvdXJjZVwiOiBcInN0b3JlXCJcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgXVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIF1cclxuICAgIH1cclxufSkiLCJpbXBvcnQgeyBcclxuICAgIHJlY29yZEhvbWVwYWdlcywgXHJcbiAgICBob21lcGFnZUNvbXBvbmVudE5hbWUsXHJcbiAgICByZWNvcmRIb21lUGFnZUNvbXBvbmVudHNcclxufSBmcm9tIFwiLi9yZWNvcmRIb21lUGFnZUdlbmVyYXRvclwiO1xyXG5pbXBvcnQgeyBmb3JtTmFtZSwgZm9ybXMgfSBmcm9tIFwiLi9mb3Jtc0dlbmVyYXRvclwiO1xyXG5cclxuZXhwb3J0IGNvbnN0IHNlbGVjdE5hdkNvbnRlbnQgPSAoe2luZGV4ZXMsIHJlY29yZHMsIGhlbHBlcnN9KSA9PiBcclxuICAgIFtcclxuICAgICAgICAuLi5yZWNvcmRIb21lcGFnZXMoe2luZGV4ZXMsIHJlY29yZHN9KVxyXG4gICAgICAgICAgICAubWFwKGNvbXBvbmVudCksXHJcblxyXG4gICAgICAgIC4uLnJlY29yZEhvbWVQYWdlQ29tcG9uZW50cyh7aW5kZXhlcywgcmVjb3JkcywgaGVscGVyc30pLFxyXG5cclxuICAgICAgICAuLi5mb3Jtcyh7aW5kZXhlcywgcmVjb3JkcywgaGVscGVyc30pXHJcblxyXG4gICAgXVxyXG5cclxuXHJcbmV4cG9ydCBjb25zdCBuYXZDb250ZW50Q29tcG9uZW50TmFtZSA9IHJlY29yZCA9PlxyXG4gICAgYCR7cmVjb3JkLm5hbWV9LyR7cmVjb3J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mhlcml0czogXCJAYnVkaWJhc2UvYm9vdHN0cmFwLWNvbXBvbmVudHMvbmF2XCIsXHJcbiAgICAgICAgcHJvcHM6IHtcclxuICAgICAgICAgICAgaXRlbXM6IHJlY29yZEhvbWVwYWdlcyh7aW5kZXhlcywgcmVjb3Jkc30pXHJcbiAgICAgICAgICAgICAgICAgICAgLm1hcChuYXZJdGVtKSxcclxuICAgICAgICAgICAgb3JpZW50YXRpb246IFwiaG9yaXpvbnRhbFwiLFxyXG4gICAgICAgICAgICBhbGlnbm1lbnQ6IFwic3RhcnRcIixcclxuICAgICAgICAgICAgZmlsbDogZmFsc2UsXHJcbiAgICAgICAgICAgIHBpbGxzOiB0cnVlLFxyXG4gICAgICAgICAgICBzZWxlY3RlZEl0ZW06IHtcclxuICAgICAgICAgICAgICAgIFwiIyNiYnN0YXRlXCI6XCJzZWxlY3RlZE5hdlwiLFxyXG4gICAgICAgICAgICAgICAgXCIjI2Jic3RhdGVmYWxsYmFja1wiOmAke3JlY29yZHNbMF0ubmFtZX1gLFxyXG4gICAgICAgICAgICAgICAgXCIjI2Jic291cmNlXCI6IFwic3RvcmVcIlxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICBjbGFzc05hbWU6IFwicC0zXCJcclxuICAgICAgICB9XHJcbiAgICB9LFxyXG4gICAge1xyXG4gICAgICAgIG5hbWU6IFwiTG9naW5cIixcclxuICAgICAgICBpbmhlcml0czogXCJAYnVkaWJhc2Uvc3RhbmRhcmQtY29tcG9uZW50cy9sb2dpblwiLFxyXG4gICAgICAgIHByb3BzOiB7fVxyXG4gICAgfSxcclxuICAgIC4uLnNlbGVjdE5hdkNvbnRlbnQoe3JlY29yZHMsIGluZGV4ZXMsIGhlbHBlcnN9KVxyXG5dXHJcblxyXG5cclxuZXhwb3J0IGNvbnN0IG5hdkl0ZW0gPSAoe3JlY29yZH0pID0+ICh7XHJcbiAgICB0aXRsZTogcmVjb3JkLmNvbGxlY3Rpb25OYW1lLFxyXG4gICAg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0FDOUM7Q0FDSixDQUFDOzs7OyJ9 diff --git a/packages/bootstrap-components/public/bundle.js b/packages/bootstrap-components/public/bundle.js index 949818b21..0ce8731d3 100644 --- a/packages/bootstrap-components/public/bundle.js +++ b/packages/bootstrap-components/public/bundle.js @@ -1,6253 +1,13098 @@ - -(function(l, i, v, e) { v = l.createElement(i); v.async = 1; v.src = '//' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; e = l.getElementsByTagName(i)[0]; e.parentNode.insertBefore(v, e)})(document, 'script'); -var app = (function () { - 'use strict'; - - function noop() { } - function assign(tar, src) { - // @ts-ignore - for (const k in src) - tar[k] = src[k]; - return tar; +;(function(l, i, v, e) { + v = l.createElement(i) + v.async = 1 + v.src = + "//" + + (location.host || "localhost").split(":")[0] + + ":35729/livereload.js?snipver=1" + e = l.getElementsByTagName(i)[0] + e.parentNode.insertBefore(v, e) +})(document, "script") +var app = (function() { + "use strict" + + function noop() {} + function assign(tar, src) { + // @ts-ignore + for (const k in src) tar[k] = src[k] + return tar + } + function is_promise(value) { + return ( + value && typeof value === "object" && typeof value.then === "function" + ) + } + function add_location(element, file, line, column, char) { + element.__svelte_meta = { + loc: { file, line, column, char }, } - function is_promise(value) { - return value && typeof value === 'object' && typeof value.then === 'function'; + } + function run(fn) { + return fn() + } + function blank_object() { + return Object.create(null) + } + function run_all(fns) { + fns.forEach(run) + } + function is_function(thing) { + return typeof thing === "function" + } + function safe_not_equal(a, b) { + return a != a + ? b == b + : a !== b || (a && typeof a === "object") || typeof a === "function" + } + function create_slot(definition, ctx, fn) { + if (definition) { + const slot_ctx = get_slot_context(definition, ctx, fn) + return definition[0](slot_ctx) } - function add_location(element, file, line, column, char) { - element.__svelte_meta = { - loc: { file, line, column, char } - }; + } + function get_slot_context(definition, ctx, fn) { + return definition[1] + ? assign({}, assign(ctx.$$scope.ctx, definition[1](fn ? fn(ctx) : {}))) + : ctx.$$scope.ctx + } + function get_slot_changes(definition, ctx, changed, fn) { + return definition[1] + ? assign( + {}, + assign( + ctx.$$scope.changed || {}, + definition[1](fn ? fn(changed) : {}) + ) + ) + : ctx.$$scope.changed || {} + } + function null_to_empty(value) { + return value == null ? "" : value + } + + function append(target, node) { + target.appendChild(node) + } + function insert(target, node, anchor) { + target.insertBefore(node, anchor || null) + } + function detach(node) { + node.parentNode.removeChild(node) + } + function destroy_each(iterations, detaching) { + for (let i = 0; i < iterations.length; i += 1) { + if (iterations[i]) iterations[i].d(detaching) } - function run(fn) { - return fn(); + } + function element(name) { + return document.createElement(name) + } + function svg_element(name) { + return document.createElementNS("http://www.w3.org/2000/svg", name) + } + function text(data) { + return document.createTextNode(data) + } + function space() { + return text(" ") + } + function empty() { + return text("") + } + function listen(node, event, handler, options) { + node.addEventListener(event, handler, options) + return () => node.removeEventListener(event, handler, options) + } + function attr(node, attribute, value) { + if (value == null) node.removeAttribute(attribute) + else node.setAttribute(attribute, value) + } + function children(element) { + return Array.from(element.childNodes) + } + function claim_element(nodes, name, attributes, svg) { + for (let i = 0; i < nodes.length; i += 1) { + const node = nodes[i] + if (node.nodeName === name) { + for (let j = 0; j < node.attributes.length; j += 1) { + const attribute = node.attributes[j] + if (!attributes[attribute.name]) node.removeAttribute(attribute.name) + } + return nodes.splice(i, 1)[0] // TODO strip unwanted attributes + } } - function blank_object() { - return Object.create(null); + return svg ? svg_element(name) : element(name) + } + function claim_text(nodes, data) { + for (let i = 0; i < nodes.length; i += 1) { + const node = nodes[i] + if (node.nodeType === 3) { + node.data = "" + data + return nodes.splice(i, 1)[0] + } } - function run_all(fns) { - fns.forEach(run); + return text(data) + } + function claim_space(nodes) { + return claim_text(nodes, " ") + } + function set_input_value(input, value) { + if (value != null || input.value) { + input.value = value } - function is_function(thing) { - return typeof thing === 'function'; + } + function set_style(node, key, value, important) { + node.style.setProperty(key, value, important ? "important" : "") + } + function toggle_class(element, name, toggle) { + element.classList[toggle ? "add" : "remove"](name) + } + function custom_event(type, detail) { + const e = document.createEvent("CustomEvent") + e.initCustomEvent(type, false, false, detail) + return e + } + + let current_component + function set_current_component(component) { + current_component = component + } + function get_current_component() { + if (!current_component) + throw new Error(`Function called outside component initialization`) + return current_component + } + // TODO figure out if we still want to support + // shorthand events, or if we want to implement + // a real bubbling mechanism + function bubble(component, event) { + const callbacks = component.$$.callbacks[event.type] + if (callbacks) { + callbacks.slice().forEach(fn => fn(event)) } - function safe_not_equal(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); + } + + const dirty_components = [] + const binding_callbacks = [] + const render_callbacks = [] + const flush_callbacks = [] + const resolved_promise = Promise.resolve() + let update_scheduled = false + function schedule_update() { + if (!update_scheduled) { + update_scheduled = true + resolved_promise.then(flush) } - function create_slot(definition, ctx, fn) { - if (definition) { - const slot_ctx = get_slot_context(definition, ctx, fn); - return definition[0](slot_ctx); + } + function add_render_callback(fn) { + render_callbacks.push(fn) + } + function flush() { + const seen_callbacks = new Set() + do { + // first, call beforeUpdate functions + // and update components + while (dirty_components.length) { + const component = dirty_components.shift() + set_current_component(component) + update(component.$$) + } + while (binding_callbacks.length) binding_callbacks.pop()() + // then, once components are updated, call + // afterUpdate functions. This may cause + // subsequent updates... + for (let i = 0; i < render_callbacks.length; i += 1) { + const callback = render_callbacks[i] + if (!seen_callbacks.has(callback)) { + callback() + // ...so guard against infinite loops + seen_callbacks.add(callback) } + } + render_callbacks.length = 0 + } while (dirty_components.length) + while (flush_callbacks.length) { + flush_callbacks.pop()() } - function get_slot_context(definition, ctx, fn) { - return definition[1] - ? assign({}, assign(ctx.$$scope.ctx, definition[1](fn ? fn(ctx) : {}))) - : ctx.$$scope.ctx; - } - function get_slot_changes(definition, ctx, changed, fn) { - return definition[1] - ? assign({}, assign(ctx.$$scope.changed || {}, definition[1](fn ? fn(changed) : {}))) - : ctx.$$scope.changed || {}; + update_scheduled = false + } + function update($$) { + if ($$.fragment) { + $$.update($$.dirty) + run_all($$.before_update) + $$.fragment.p($$.dirty, $$.ctx) + $$.dirty = null + $$.after_update.forEach(add_render_callback) } - function null_to_empty(value) { - return value == null ? '' : value; + } + const outroing = new Set() + let outros + function group_outros() { + outros = { + r: 0, + c: [], + p: outros, // parent group } - - function append(target, node) { - target.appendChild(node); + } + function check_outros() { + if (!outros.r) { + run_all(outros.c) } - function insert(target, node, anchor) { - target.insertBefore(node, anchor || null); + outros = outros.p + } + function transition_in(block, local) { + if (block && block.i) { + outroing.delete(block) + block.i(local) } - function detach(node) { - node.parentNode.removeChild(node); + } + function transition_out(block, local, detach, callback) { + if (block && block.o) { + if (outroing.has(block)) return + outroing.add(block) + outros.c.push(() => { + outroing.delete(block) + if (callback) { + if (detach) block.d(1) + callback() + } + }) + block.o(local) } - function destroy_each(iterations, detaching) { - for (let i = 0; i < iterations.length; i += 1) { - if (iterations[i]) - iterations[i].d(detaching); + } + + function handle_promise(promise, info) { + const token = (info.token = {}) + function update(type, index, key, value) { + if (info.token !== token) return + info.resolved = key && { [key]: value } + const child_ctx = assign(assign({}, info.ctx), info.resolved) + const block = type && (info.current = type)(child_ctx) + if (info.block) { + if (info.blocks) { + info.blocks.forEach((block, i) => { + if (i !== index && block) { + group_outros() + transition_out(block, 1, 1, () => { + info.blocks[i] = null + }) + check_outros() + } + }) + } else { + info.block.d(1) } + block.c() + transition_in(block, 1) + block.m(info.mount(), info.anchor) + flush() + } + info.block = block + if (info.blocks) info.blocks[index] = block } - function element(name) { - return document.createElement(name); - } - function svg_element(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); - } - function text(data) { - return document.createTextNode(data); - } - function space() { - return text(' '); - } - function empty() { - return text(''); - } - function listen(node, event, handler, options) { - node.addEventListener(event, handler, options); - return () => node.removeEventListener(event, handler, options); + if (is_promise(promise)) { + const current_component = get_current_component() + promise.then( + value => { + set_current_component(current_component) + update(info.then, 1, info.value, value) + set_current_component(null) + }, + error => { + set_current_component(current_component) + update(info.catch, 2, info.error, error) + set_current_component(null) + } + ) + // if we previously had a then/catch block, destroy it + if (info.current !== info.pending) { + update(info.pending, 0) + return true + } + } else { + if (info.current !== info.then) { + update(info.then, 1, info.value, promise) + return true + } + info.resolved = { [info.value]: promise } } - function attr(node, attribute, value) { - if (value == null) - node.removeAttribute(attribute); - else - node.setAttribute(attribute, value); + } + + const globals = typeof window !== "undefined" ? window : global + function mount_component(component, target, anchor) { + const { fragment, on_mount, on_destroy, after_update } = component.$$ + fragment.m(target, anchor) + // onMount happens before the initial afterUpdate + add_render_callback(() => { + const new_on_destroy = on_mount.map(run).filter(is_function) + if (on_destroy) { + on_destroy.push(...new_on_destroy) + } else { + // Edge case - component was destroyed immediately, + // most likely as a result of a binding initialising + run_all(new_on_destroy) + } + component.$$.on_mount = [] + }) + after_update.forEach(add_render_callback) + } + function destroy_component(component, detaching) { + if (component.$$.fragment) { + run_all(component.$$.on_destroy) + component.$$.fragment.d(detaching) + // TODO null out other refs, including component.$$ (but need to + // preserve final state?) + component.$$.on_destroy = component.$$.fragment = null + component.$$.ctx = {} } - function children(element) { - return Array.from(element.childNodes); + } + function make_dirty(component, key) { + if (!component.$$.dirty) { + dirty_components.push(component) + schedule_update() + component.$$.dirty = blank_object() } - function claim_element(nodes, name, attributes, svg) { - for (let i = 0; i < nodes.length; i += 1) { - const node = nodes[i]; - if (node.nodeName === name) { - for (let j = 0; j < node.attributes.length; j += 1) { - const attribute = node.attributes[j]; - if (!attributes[attribute.name]) - node.removeAttribute(attribute.name); - } - return nodes.splice(i, 1)[0]; // TODO strip unwanted attributes - } - } - return svg ? svg_element(name) : element(name); + component.$$.dirty[key] = true + } + function init( + component, + options, + instance, + create_fragment, + not_equal, + prop_names + ) { + const parent_component = current_component + set_current_component(component) + const props = options.props || {} + const $$ = (component.$$ = { + fragment: null, + ctx: null, + // state + props: prop_names, + update: noop, + not_equal, + bound: blank_object(), + // lifecycle + on_mount: [], + on_destroy: [], + before_update: [], + after_update: [], + context: new Map(parent_component ? parent_component.$$.context : []), + // everything else + callbacks: blank_object(), + dirty: null, + }) + let ready = false + $$.ctx = instance + ? instance(component, props, (key, ret, value = ret) => { + if ($$.ctx && not_equal($$.ctx[key], ($$.ctx[key] = value))) { + if ($$.bound[key]) $$.bound[key](value) + if (ready) make_dirty(component, key) + } + return ret + }) + : props + $$.update() + ready = true + run_all($$.before_update) + $$.fragment = create_fragment($$.ctx) + if (options.target) { + if (options.hydrate) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment.l(children(options.target)) + } else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment.c() + } + if (options.intro) transition_in(component.$$.fragment) + mount_component(component, options.target, options.anchor) + flush() } - function claim_text(nodes, data) { - for (let i = 0; i < nodes.length; i += 1) { - const node = nodes[i]; - if (node.nodeType === 3) { - node.data = '' + data; - return nodes.splice(i, 1)[0]; - } + set_current_component(parent_component) + } + let SvelteElement + if (typeof HTMLElement !== "undefined") { + SvelteElement = class extends HTMLElement { + constructor() { + super() + this.attachShadow({ mode: "open" }) + } + connectedCallback() { + // @ts-ignore todo: improve typings + for (const key in this.$$.slotted) { + // @ts-ignore todo: improve typings + this.appendChild(this.$$.slotted[key]) } - return text(data); - } - function claim_space(nodes) { - return claim_text(nodes, ' '); - } - function set_input_value(input, value) { - if (value != null || input.value) { - input.value = value; + } + attributeChangedCallback(attr, _oldValue, newValue) { + this[attr] = newValue + } + $destroy() { + destroy_component(this, 1) + this.$destroy = noop + } + $on(type, callback) { + // TODO should this delegate to addEventListener? + const callbacks = + this.$$.callbacks[type] || (this.$$.callbacks[type] = []) + callbacks.push(callback) + return () => { + const index = callbacks.indexOf(callback) + if (index !== -1) callbacks.splice(index, 1) } + } + $set() { + // overridden by instance, if it has props + } } - function set_style(node, key, value, important) { - node.style.setProperty(key, value, important ? 'important' : ''); + } + class SvelteComponent { + $destroy() { + destroy_component(this, 1) + this.$destroy = noop } - function toggle_class(element, name, toggle) { - element.classList[toggle ? 'add' : 'remove'](name); + $on(type, callback) { + const callbacks = + this.$$.callbacks[type] || (this.$$.callbacks[type] = []) + callbacks.push(callback) + return () => { + const index = callbacks.indexOf(callback) + if (index !== -1) callbacks.splice(index, 1) + } } - function custom_event(type, detail) { - const e = document.createEvent('CustomEvent'); - e.initCustomEvent(type, false, false, detail); - return e; + $set() { + // overridden by instance, if it has props } - - let current_component; - function set_current_component(component) { - current_component = component; + } + + function dispatch_dev(type, detail) { + document.dispatchEvent(custom_event(type, detail)) + } + function append_dev(target, node) { + dispatch_dev("SvelteDOMInsert", { target, node }) + append(target, node) + } + function insert_dev(target, node, anchor) { + dispatch_dev("SvelteDOMInsert", { target, node, anchor }) + insert(target, node, anchor) + } + function detach_dev(node) { + dispatch_dev("SvelteDOMRemove", { node }) + detach(node) + } + function listen_dev( + node, + event, + handler, + options, + has_prevent_default, + has_stop_propagation + ) { + const modifiers = + options === true + ? ["capture"] + : options + ? Array.from(Object.keys(options)) + : [] + if (has_prevent_default) modifiers.push("preventDefault") + if (has_stop_propagation) modifiers.push("stopPropagation") + dispatch_dev("SvelteDOMAddEventListener", { + node, + event, + handler, + modifiers, + }) + const dispose = listen(node, event, handler, options) + return () => { + dispatch_dev("SvelteDOMRemoveEventListener", { + node, + event, + handler, + modifiers, + }) + dispose() } - function get_current_component() { - if (!current_component) - throw new Error(`Function called outside component initialization`); - return current_component; + } + function attr_dev(node, attribute, value) { + attr(node, attribute, value) + if (value == null) + dispatch_dev("SvelteDOMRemoveAttribute", { node, attribute }) + else dispatch_dev("SvelteDOMSetAttribute", { node, attribute, value }) + } + function prop_dev(node, property, value) { + node[property] = value + dispatch_dev("SvelteDOMSetProperty", { node, property, value }) + } + function set_data_dev(text, data) { + data = "" + data + if (text.data === data) return + dispatch_dev("SvelteDOMSetData", { node: text, data }) + text.data = data + } + class SvelteComponentDev extends SvelteComponent { + constructor(options) { + if (!options || (!options.target && !options.$$inline)) { + throw new Error(`'target' is a required option`) + } + super() } - // TODO figure out if we still want to support - // shorthand events, or if we want to implement - // a real bubbling mechanism - function bubble(component, event) { - const callbacks = component.$$.callbacks[event.type]; - if (callbacks) { - callbacks.slice().forEach(fn => fn(event)); - } + $destroy() { + super.$destroy() + this.$destroy = () => { + console.warn(`Component was already destroyed`) // eslint-disable-line no-console + } } - - const dirty_components = []; - const binding_callbacks = []; - const render_callbacks = []; - const flush_callbacks = []; - const resolved_promise = Promise.resolve(); - let update_scheduled = false; - function schedule_update() { - if (!update_scheduled) { - update_scheduled = true; - resolved_promise.then(flush); + } + + const subscriber_queue = [] + /** + * Create a `Writable` store that allows both updating and reading by subscription. + * @param {*=}value initial value + * @param {StartStopNotifier=}start start and stop notifications for subscriptions + */ + function writable(value, start = noop) { + let stop + const subscribers = [] + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value + if (stop) { + // store is ready + const run_queue = !subscriber_queue.length + for (let i = 0; i < subscribers.length; i += 1) { + const s = subscribers[i] + s[1]() + subscriber_queue.push(s, value) + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]) + } + subscriber_queue.length = 0 + } } + } } - function add_render_callback(fn) { - render_callbacks.push(fn); + function update(fn) { + set(fn(value)) } - function flush() { - const seen_callbacks = new Set(); - do { - // first, call beforeUpdate functions - // and update components - while (dirty_components.length) { - const component = dirty_components.shift(); - set_current_component(component); - update(component.$$); - } - while (binding_callbacks.length) - binding_callbacks.pop()(); - // then, once components are updated, call - // afterUpdate functions. This may cause - // subsequent updates... - for (let i = 0; i < render_callbacks.length; i += 1) { - const callback = render_callbacks[i]; - if (!seen_callbacks.has(callback)) { - callback(); - // ...so guard against infinite loops - seen_callbacks.add(callback); - } - } - render_callbacks.length = 0; - } while (dirty_components.length); - while (flush_callbacks.length) { - flush_callbacks.pop()(); - } - update_scheduled = false; - } - function update($$) { - if ($$.fragment) { - $$.update($$.dirty); - run_all($$.before_update); - $$.fragment.p($$.dirty, $$.ctx); - $$.dirty = null; - $$.after_update.forEach(add_render_callback); - } - } - const outroing = new Set(); - let outros; - function group_outros() { - outros = { - r: 0, - c: [], - p: outros // parent group - }; - } - function check_outros() { - if (!outros.r) { - run_all(outros.c); - } - outros = outros.p; - } - function transition_in(block, local) { - if (block && block.i) { - outroing.delete(block); - block.i(local); - } - } - function transition_out(block, local, detach, callback) { - if (block && block.o) { - if (outroing.has(block)) - return; - outroing.add(block); - outros.c.push(() => { - outroing.delete(block); - if (callback) { - if (detach) - block.d(1); - callback(); - } - }); - block.o(local); - } - } - - function handle_promise(promise, info) { - const token = info.token = {}; - function update(type, index, key, value) { - if (info.token !== token) - return; - info.resolved = key && { [key]: value }; - const child_ctx = assign(assign({}, info.ctx), info.resolved); - const block = type && (info.current = type)(child_ctx); - if (info.block) { - if (info.blocks) { - info.blocks.forEach((block, i) => { - if (i !== index && block) { - group_outros(); - transition_out(block, 1, 1, () => { - info.blocks[i] = null; - }); - check_outros(); - } - }); - } - else { - info.block.d(1); - } - block.c(); - transition_in(block, 1); - block.m(info.mount(), info.anchor); - flush(); - } - info.block = block; - if (info.blocks) - info.blocks[index] = block; - } - if (is_promise(promise)) { - const current_component = get_current_component(); - promise.then(value => { - set_current_component(current_component); - update(info.then, 1, info.value, value); - set_current_component(null); - }, error => { - set_current_component(current_component); - update(info.catch, 2, info.error, error); - set_current_component(null); - }); - // if we previously had a then/catch block, destroy it - if (info.current !== info.pending) { - update(info.pending, 0); - return true; - } + function subscribe(run, invalidate = noop) { + const subscriber = [run, invalidate] + subscribers.push(subscriber) + if (subscribers.length === 1) { + stop = start(set) || noop + } + run(value) + return () => { + const index = subscribers.indexOf(subscriber) + if (index !== -1) { + subscribers.splice(index, 1) } - else { - if (info.current !== info.then) { - update(info.then, 1, info.value, promise); - return true; - } - info.resolved = { [info.value]: promise }; + if (subscribers.length === 0) { + stop() + stop = null } + } } + return { set, update, subscribe } + } - const globals = (typeof window !== 'undefined' ? window : global); - function mount_component(component, target, anchor) { - const { fragment, on_mount, on_destroy, after_update } = component.$$; - fragment.m(target, anchor); - // onMount happens before the initial afterUpdate - add_render_callback(() => { - const new_on_destroy = on_mount.map(run).filter(is_function); - if (on_destroy) { - on_destroy.push(...new_on_destroy); - } - else { - // Edge case - component was destroyed immediately, - // most likely as a result of a binding initialising - run_all(new_on_destroy); - } - component.$$.on_mount = []; - }); - after_update.forEach(add_render_callback); - } - function destroy_component(component, detaching) { - if (component.$$.fragment) { - run_all(component.$$.on_destroy); - component.$$.fragment.d(detaching); - // TODO null out other refs, including component.$$ (but need to - // preserve final state?) - component.$$.on_destroy = component.$$.fragment = null; - component.$$.ctx = {}; - } - } - function make_dirty(component, key) { - if (!component.$$.dirty) { - dirty_components.push(component); - schedule_update(); - component.$$.dirty = blank_object(); - } - component.$$.dirty[key] = true; - } - function init(component, options, instance, create_fragment, not_equal, prop_names) { - const parent_component = current_component; - set_current_component(component); - const props = options.props || {}; - const $$ = component.$$ = { - fragment: null, - ctx: null, - // state - props: prop_names, - update: noop, - not_equal, - bound: blank_object(), - // lifecycle - on_mount: [], - on_destroy: [], - before_update: [], - after_update: [], - context: new Map(parent_component ? parent_component.$$.context : []), - // everything else - callbacks: blank_object(), - dirty: null - }; - let ready = false; - $$.ctx = instance - ? instance(component, props, (key, ret, value = ret) => { - if ($$.ctx && not_equal($$.ctx[key], $$.ctx[key] = value)) { - if ($$.bound[key]) - $$.bound[key](value); - if (ready) - make_dirty(component, key); - } - return ret; - }) - : props; - $$.update(); - ready = true; - run_all($$.before_update); - $$.fragment = create_fragment($$.ctx); - if (options.target) { - if (options.hydrate) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - $$.fragment.l(children(options.target)); - } - else { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - $$.fragment.c(); - } - if (options.intro) - transition_in(component.$$.fragment); - mount_component(component, options.target, options.anchor); - flush(); - } - set_current_component(parent_component); - } - let SvelteElement; - if (typeof HTMLElement !== 'undefined') { - SvelteElement = class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ mode: 'open' }); - } - connectedCallback() { - // @ts-ignore todo: improve typings - for (const key in this.$$.slotted) { - // @ts-ignore todo: improve typings - this.appendChild(this.$$.slotted[key]); - } - } - attributeChangedCallback(attr, _oldValue, newValue) { - this[attr] = newValue; - } - $destroy() { - destroy_component(this, 1); - this.$destroy = noop; - } - $on(type, callback) { - // TODO should this delegate to addEventListener? - const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); - callbacks.push(callback); - return () => { - const index = callbacks.indexOf(callback); - if (index !== -1) - callbacks.splice(index, 1); - }; - } - $set() { - // overridden by instance, if it has props - } - }; - } - class SvelteComponent { - $destroy() { - destroy_component(this, 1); - this.$destroy = noop; - } - $on(type, callback) { - const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); - callbacks.push(callback); - return () => { - const index = callbacks.indexOf(callback); - if (index !== -1) - callbacks.splice(index, 1); - }; - } - $set() { - // overridden by instance, if it has props - } - } - - function dispatch_dev(type, detail) { - document.dispatchEvent(custom_event(type, detail)); - } - function append_dev(target, node) { - dispatch_dev("SvelteDOMInsert", { target, node }); - append(target, node); - } - function insert_dev(target, node, anchor) { - dispatch_dev("SvelteDOMInsert", { target, node, anchor }); - insert(target, node, anchor); - } - function detach_dev(node) { - dispatch_dev("SvelteDOMRemove", { node }); - detach(node); - } - function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) { - const modifiers = options === true ? ["capture"] : options ? Array.from(Object.keys(options)) : []; - if (has_prevent_default) - modifiers.push('preventDefault'); - if (has_stop_propagation) - modifiers.push('stopPropagation'); - dispatch_dev("SvelteDOMAddEventListener", { node, event, handler, modifiers }); - const dispose = listen(node, event, handler, options); - return () => { - dispatch_dev("SvelteDOMRemoveEventListener", { node, event, handler, modifiers }); - dispose(); - }; - } - function attr_dev(node, attribute, value) { - attr(node, attribute, value); - if (value == null) - dispatch_dev("SvelteDOMRemoveAttribute", { node, attribute }); - else - dispatch_dev("SvelteDOMSetAttribute", { node, attribute, value }); - } - function prop_dev(node, property, value) { - node[property] = value; - dispatch_dev("SvelteDOMSetProperty", { node, property, value }); - } - function set_data_dev(text, data) { - data = '' + data; - if (text.data === data) - return; - dispatch_dev("SvelteDOMSetData", { node: text, data }); - text.data = data; - } - class SvelteComponentDev extends SvelteComponent { - constructor(options) { - if (!options || (!options.target && !options.$$inline)) { - throw new Error(`'target' is a required option`); - } - super(); + /* src\Textbox.svelte generated by Svelte v3.12.1 */ + + const file = "src\\Textbox.svelte" + + // (32:0) {:else} + function create_else_block(ctx) { + var input, input_class_value + + const block = { + c: function create() { + input = element("input") + this.h() + }, + + l: function claim(nodes) { + input = claim_element( + nodes, + "INPUT", + { class: true, type: true, value: true }, + false + ) + var input_nodes = children(input) + + input_nodes.forEach(detach_dev) + this.h() + }, + + h: function hydrate() { + attr_dev( + input, + "class", + (input_class_value = + "" + null_to_empty(ctx.className) + " svelte-1ec4wqj") + ) + attr_dev(input, "type", "text") + input.value = ctx.actualValue + add_location(input, file, 32, 0, 546) + }, + + m: function mount(target, anchor) { + insert_dev(target, input, anchor) + }, + + p: function update(changed, ctx) { + if ( + changed.className && + input_class_value !== + (input_class_value = + "" + null_to_empty(ctx.className) + " svelte-1ec4wqj") + ) { + attr_dev(input, "class", input_class_value) } - $destroy() { - super.$destroy(); - this.$destroy = () => { - console.warn(`Component was already destroyed`); // eslint-disable-line no-console - }; + + if (changed.actualValue) { + prop_dev(input, "value", ctx.actualValue) + } + }, + + d: function destroy(detaching) { + if (detaching) { + detach_dev(input) } + }, } + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_else_block.name, + type: "else", + source: "(32:0) {:else}", + ctx, + }) + return block + } + + // (28:0) {#if hideValue} + function create_if_block(ctx) { + var input, input_class_value, dispose + + const block = { + c: function create() { + input = element("input") + this.h() + }, - const subscriber_queue = []; - /** - * Create a `Writable` store that allows both updating and reading by subscription. - * @param {*=}value initial value - * @param {StartStopNotifier=}start start and stop notifications for subscriptions - */ - function writable(value, start = noop) { - let stop; - const subscribers = []; - function set(new_value) { - if (safe_not_equal(value, new_value)) { - value = new_value; - if (stop) { // store is ready - const run_queue = !subscriber_queue.length; - for (let i = 0; i < subscribers.length; i += 1) { - const s = subscribers[i]; - s[1](); - subscriber_queue.push(s, value); - } - if (run_queue) { - for (let i = 0; i < subscriber_queue.length; i += 2) { - subscriber_queue[i][0](subscriber_queue[i + 1]); - } - subscriber_queue.length = 0; - } - } - } + l: function claim(nodes) { + input = claim_element( + nodes, + "INPUT", + { class: true, type: true, value: true }, + false + ) + var input_nodes = children(input) + + input_nodes.forEach(detach_dev) + this.h() + }, + + h: function hydrate() { + attr_dev( + input, + "class", + (input_class_value = + "" + null_to_empty(ctx.className) + " svelte-1ec4wqj") + ) + attr_dev(input, "type", "password") + input.value = ctx.actualValue + add_location(input, file, 28, 0, 455) + dispose = listen_dev(input, "change", ctx.change_handler) + }, + + m: function mount(target, anchor) { + insert_dev(target, input, anchor) + }, + + p: function update(changed, ctx) { + if ( + changed.className && + input_class_value !== + (input_class_value = + "" + null_to_empty(ctx.className) + " svelte-1ec4wqj") + ) { + attr_dev(input, "class", input_class_value) } - function update(fn) { - set(fn(value)); + + if (changed.actualValue) { + prop_dev(input, "value", ctx.actualValue) + } + }, + + d: function destroy(detaching) { + if (detaching) { + detach_dev(input) } - function subscribe(run, invalidate = noop) { - const subscriber = [run, invalidate]; - subscribers.push(subscriber); - if (subscribers.length === 1) { - stop = start(set) || noop; - } - run(value); - return () => { - const index = subscribers.indexOf(subscriber); - if (index !== -1) { - subscribers.splice(index, 1); - } - if (subscribers.length === 0) { - stop(); - stop = null; - } - }; - } - return { set, update, subscribe }; - } - - /* src\Textbox.svelte generated by Svelte v3.12.1 */ - - const file = "src\\Textbox.svelte"; - - // (32:0) {:else} - function create_else_block(ctx) { - var input, input_class_value; - - const block = { - c: function create() { - input = element("input"); - this.h(); - }, - - l: function claim(nodes) { - input = claim_element(nodes, "INPUT", { class: true, type: true, value: true }, false); - var input_nodes = children(input); - - input_nodes.forEach(detach_dev); - this.h(); - }, - - h: function hydrate() { - attr_dev(input, "class", input_class_value = "" + null_to_empty(ctx.className) + " svelte-1ec4wqj"); - attr_dev(input, "type", "text"); - input.value = ctx.actualValue; - add_location(input, file, 32, 0, 546); - }, - - m: function mount(target, anchor) { - insert_dev(target, input, anchor); - }, - - p: function update(changed, ctx) { - if ((changed.className) && input_class_value !== (input_class_value = "" + null_to_empty(ctx.className) + " svelte-1ec4wqj")) { - attr_dev(input, "class", input_class_value); - } - - if (changed.actualValue) { - prop_dev(input, "value", ctx.actualValue); - } - }, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(input); - } - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block.name, type: "else", source: "(32:0) {:else}", ctx }); - return block; - } - - // (28:0) {#if hideValue} - function create_if_block(ctx) { - var input, input_class_value, dispose; - - const block = { - c: function create() { - input = element("input"); - this.h(); - }, - - l: function claim(nodes) { - input = claim_element(nodes, "INPUT", { class: true, type: true, value: true }, false); - var input_nodes = children(input); - - input_nodes.forEach(detach_dev); - this.h(); - }, - - h: function hydrate() { - attr_dev(input, "class", input_class_value = "" + null_to_empty(ctx.className) + " svelte-1ec4wqj"); - attr_dev(input, "type", "password"); - input.value = ctx.actualValue; - add_location(input, file, 28, 0, 455); - dispose = listen_dev(input, "change", ctx.change_handler); - }, - - m: function mount(target, anchor) { - insert_dev(target, input, anchor); - }, - - p: function update(changed, ctx) { - if ((changed.className) && input_class_value !== (input_class_value = "" + null_to_empty(ctx.className) + " svelte-1ec4wqj")) { - attr_dev(input, "class", input_class_value); - } - - if (changed.actualValue) { - prop_dev(input, "value", ctx.actualValue); - } - }, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(input); - } - - dispose(); - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block.name, type: "if", source: "(28:0) {#if hideValue}", ctx }); - return block; - } - - function create_fragment(ctx) { - var if_block_anchor; - - function select_block_type(changed, ctx) { - if (ctx.hideValue) return create_if_block; - return create_else_block; - } - - var current_block_type = select_block_type(null, ctx); - var if_block = current_block_type(ctx); - - const block = { - c: function create() { - if_block.c(); - if_block_anchor = empty(); - }, - - l: function claim(nodes) { - if_block.l(nodes); - if_block_anchor = empty(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insert_dev(target, if_block_anchor, anchor); - }, - - p: function update(changed, ctx) { - if (current_block_type === (current_block_type = select_block_type(changed, ctx)) && if_block) { - if_block.p(changed, ctx); - } else { - if_block.d(1); - if_block = current_block_type(ctx); - if (if_block) { - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } - }, - - i: noop, - o: noop, - - d: function destroy(detaching) { - if_block.d(detaching); - - if (detaching) { - detach_dev(if_block_anchor); - } - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); - return block; - } - - function instance($$self, $$props, $$invalidate) { - let { value="", hideValue = false, className = "default", _bb } = $$props; - - let actualValue = ""; - - const writable_props = ['value', 'hideValue', 'className', '_bb']; - Object.keys($$props).forEach(key => { - if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(` was created with unknown prop '${key}'`); - }); - - function change_handler(event) { - bubble($$self, event); - } - - $$self.$set = $$props => { - if ('value' in $$props) $$invalidate('value', value = $$props.value); - if ('hideValue' in $$props) $$invalidate('hideValue', hideValue = $$props.hideValue); - if ('className' in $$props) $$invalidate('className', className = $$props.className); - if ('_bb' in $$props) $$invalidate('_bb', _bb = $$props._bb); - }; - - $$self.$capture_state = () => { - return { value, hideValue, className, _bb, actualValue }; - }; - - $$self.$inject_state = $$props => { - if ('value' in $$props) $$invalidate('value', value = $$props.value); - if ('hideValue' in $$props) $$invalidate('hideValue', hideValue = $$props.hideValue); - if ('className' in $$props) $$invalidate('className', className = $$props.className); - if ('_bb' in $$props) $$invalidate('_bb', _bb = $$props._bb); - if ('actualValue' in $$props) $$invalidate('actualValue', actualValue = $$props.actualValue); - }; - - $$self.$$.update = ($$dirty = { _bb: 1, value: 1 }) => { - if ($$dirty._bb || $$dirty.value) { { - if(_bb && value._isstate) { - _bb.store.subscribe(s => { - $$invalidate('actualValue', actualValue = _bb.store.getValue(s, value)); - }); - } - } } - }; - - return { - value, - hideValue, - className, - _bb, - actualValue, - change_handler - }; - } - - class Textbox extends SvelteComponentDev { - constructor(options) { - super(options); - init(this, options, instance, create_fragment, safe_not_equal, ["value", "hideValue", "className", "_bb"]); - dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Textbox", options, id: create_fragment.name }); - - const { ctx } = this.$$; - const props = options.props || {}; - if (ctx._bb === undefined && !('_bb' in props)) { - console.warn(" was created without expected prop '_bb'"); - } - } - - get value() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set value(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - - get hideValue() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set hideValue(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - - get className() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set className(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - - get _bb() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set _bb(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - } - - /* src\Form.svelte generated by Svelte v3.12.1 */ - - const file$1 = "src\\Form.svelte"; - - function get_each_context(ctx, list, i) { - const child_ctx = Object.create(ctx); - child_ctx.child = list[i]; - child_ctx.index = i; - return child_ctx; - } - - // (30:4) {#each formControls as child, index} - function create_each_block(ctx) { - var div0, t0_value = ctx.labels[ctx.index] + "", t0, t1, div1, index = ctx.index; - - const assign_div1 = () => ctx.div1_binding(div1, index); - const unassign_div1 = () => ctx.div1_binding(null, index); - - const block = { - c: function create() { - div0 = element("div"); - t0 = text(t0_value); - t1 = space(); - div1 = element("div"); - this.h(); - }, - - l: function claim(nodes) { - div0 = claim_element(nodes, "DIV", { class: true }, false); - var div0_nodes = children(div0); - - t0 = claim_text(div0_nodes, t0_value); - div0_nodes.forEach(detach_dev); - t1 = claim_space(nodes); - - div1 = claim_element(nodes, "DIV", { class: true }, false); - var div1_nodes = children(div1); - - div1_nodes.forEach(detach_dev); - this.h(); - }, - - h: function hydrate() { - attr_dev(div0, "class", "label svelte-m9d6ue"); - add_location(div0, file$1, 30, 4, 559); - attr_dev(div1, "class", "control svelte-m9d6ue"); - add_location(div1, file$1, 31, 4, 604); - }, - - m: function mount(target, anchor) { - insert_dev(target, div0, anchor); - append_dev(div0, t0); - insert_dev(target, t1, anchor); - insert_dev(target, div1, anchor); - assign_div1(); - }, - - p: function update(changed, new_ctx) { - ctx = new_ctx; - if ((changed.labels) && t0_value !== (t0_value = ctx.labels[ctx.index] + "")) { - set_data_dev(t0, t0_value); - } - - if (index !== ctx.index) { - unassign_div1(); - index = ctx.index; - assign_div1(); - } - }, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(div0); - detach_dev(t1); - detach_dev(div1); - } - - unassign_div1(); - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block.name, type: "each", source: "(30:4) {#each formControls as child, index}", ctx }); - return block; - } - - function create_fragment$1(ctx) { - var div, div_class_value; - - let each_value = ctx.formControls; - - let each_blocks = []; - - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); - } - - const block = { - c: function create() { - div = element("div"); - - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - this.h(); - }, - - l: function claim(nodes) { - div = claim_element(nodes, "DIV", { class: true }, false); - var div_nodes = children(div); - - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].l(div_nodes); - } - - div_nodes.forEach(detach_dev); - this.h(); - }, - - h: function hydrate() { - attr_dev(div, "class", div_class_value = "form-root " + ctx.containerClass + " svelte-m9d6ue"); - add_location(div, file$1, 28, 0, 473); - }, - - m: function mount(target, anchor) { - insert_dev(target, div, anchor); - - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(div, null); - } - }, - - p: function update(changed, ctx) { - if (changed.htmlElements || changed.labels || changed.formControls) { - each_value = ctx.formControls; - - let i; - for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx, each_value, i); - - if (each_blocks[i]) { - each_blocks[i].p(changed, child_ctx); - } else { - each_blocks[i] = create_each_block(child_ctx); - each_blocks[i].c(); - each_blocks[i].m(div, null); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } - each_blocks.length = each_value.length; - } - - if ((changed.containerClass) && div_class_value !== (div_class_value = "form-root " + ctx.containerClass + " svelte-m9d6ue")) { - attr_dev(div, "class", div_class_value); - } - }, - - i: noop, - o: noop, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(div); - } - - destroy_each(each_blocks, detaching); - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$1.name, type: "component", source: "", ctx }); - return block; - } - - function instance$1($$self, $$props, $$invalidate) { - let { containerClass = "", formControls = [], _bb } = $$props; - - let htmlElements = {}; - let labels = {}; - - const writable_props = ['containerClass', 'formControls', '_bb']; - Object.keys($$props).forEach(key => { - if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`
was created with unknown prop '${key}'`); - }); - - function div1_binding($$value, index) { - if (htmlElements[index] === $$value) return; - binding_callbacks[$$value ? 'unshift' : 'push'](() => { - htmlElements[index] = $$value; - $$invalidate('htmlElements', htmlElements); - }); - } - - $$self.$set = $$props => { - if ('containerClass' in $$props) $$invalidate('containerClass', containerClass = $$props.containerClass); - if ('formControls' in $$props) $$invalidate('formControls', formControls = $$props.formControls); - if ('_bb' in $$props) $$invalidate('_bb', _bb = $$props._bb); - }; - - $$self.$capture_state = () => { - return { containerClass, formControls, _bb, htmlElements, labels }; - }; - - $$self.$inject_state = $$props => { - if ('containerClass' in $$props) $$invalidate('containerClass', containerClass = $$props.containerClass); - if ('formControls' in $$props) $$invalidate('formControls', formControls = $$props.formControls); - if ('_bb' in $$props) $$invalidate('_bb', _bb = $$props._bb); - if ('htmlElements' in $$props) $$invalidate('htmlElements', htmlElements = $$props.htmlElements); - if ('labels' in $$props) $$invalidate('labels', labels = $$props.labels); - }; - - $$self.$$.update = ($$dirty = { formControls: 1, _bb: 1, htmlElements: 1 }) => { - if ($$dirty.formControls || $$dirty._bb || $$dirty.htmlElements) { { - let cIndex = 0; - for(let c of formControls) { - $$invalidate('labels', labels[cIndex] = c.label, labels); - cIndex++; - } - - if(_bb && htmlElements) { - for(let el in htmlElements) { - _bb.initialiseComponent( - formControls[el].control, - htmlElements[el] - ); - } - } - } } - }; - - return { - containerClass, - formControls, - _bb, - htmlElements, - labels, - div1_binding - }; - } - - class Form extends SvelteComponentDev { - constructor(options) { - super(options); - init(this, options, instance$1, create_fragment$1, safe_not_equal, ["containerClass", "formControls", "_bb"]); - dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "Form", options, id: create_fragment$1.name }); - - const { ctx } = this.$$; - const props = options.props || {}; - if (ctx._bb === undefined && !('_bb' in props)) { - console.warn(" was created without expected prop '_bb'"); - } - } - - get containerClass() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set containerClass(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - - get formControls() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set formControls(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - - get _bb() { - throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); - } - - set _bb(value) { - throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); - } - } - - /* src\Button.svelte generated by Svelte v3.12.1 */ - - const file$2 = "src\\Button.svelte"; - - // (30:4) {:else} - function create_else_block$1(ctx) { - var current; - - const default_slot_template = ctx.$$slots.default; - const default_slot = create_slot(default_slot_template, ctx, null); - - const block = { - c: function create() { - if (default_slot) default_slot.c(); - }, - - l: function claim(nodes) { - if (default_slot) default_slot.l(nodes); - }, - - m: function mount(target, anchor) { - if (default_slot) { - default_slot.m(target, anchor); - } - - current = true; - }, - - p: function update(changed, ctx) { - if (default_slot && default_slot.p && changed.$$scope) { - default_slot.p( - get_slot_changes(default_slot_template, ctx, changed, null), - get_slot_context(default_slot_template, ctx, null) - ); - } - }, - - i: function intro(local) { - if (current) return; - transition_in(default_slot, local); - current = true; - }, - - o: function outro(local) { - transition_out(default_slot, local); - current = false; - }, - - d: function destroy(detaching) { - if (default_slot) default_slot.d(detaching); - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block$1.name, type: "else", source: "(30:4) {:else}", ctx }); - return block; - } - - // (28:26) - function create_if_block_1(ctx) { - var t; - - const block = { - c: function create() { - t = text(ctx.contentText); - }, - - l: function claim(nodes) { - t = claim_text(nodes, ctx.contentText); - }, - - m: function mount(target, anchor) { - insert_dev(target, t, anchor); - }, - - p: function update(changed, ctx) { - if (changed.contentText) { - set_data_dev(t, ctx.contentText); - } - }, - - i: noop, - o: noop, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(t); - } - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1.name, type: "if", source: "(28:26) ", ctx }); - return block; - } - - // (25:4) {#if contentComponent && contentComponent._component} - function create_if_block$1(ctx) { - var div; - - const block = { - c: function create() { - div = element("div"); - this.h(); - }, - - l: function claim(nodes) { - div = claim_element(nodes, "DIV", {}, false); - var div_nodes = children(div); - - div_nodes.forEach(detach_dev); - this.h(); - }, - - h: function hydrate() { - add_location(div, file$2, 25, 1, 543); - }, - - m: function mount(target, anchor) { - insert_dev(target, div, anchor); - ctx.div_binding(div); - }, - - p: noop, - i: noop, - o: noop, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(div); - } - - ctx.div_binding(null); - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block$1.name, type: "if", source: "(25:4) {#if contentComponent && contentComponent._component}", ctx }); - return block; - } - - function create_fragment$2(ctx) { - var button, current_block_type_index, if_block, button_class_value, current, dispose; - - var if_block_creators = [ - create_if_block$1, - create_if_block_1, - create_else_block$1 - ]; - - var if_blocks = []; - - function select_block_type(changed, ctx) { - if (ctx.contentComponent && ctx.contentComponent._component) return 0; - if (ctx.contentText) return 1; - return 2; - } - - current_block_type_index = select_block_type(null, ctx); - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - - const block = { - c: function create() { - button = element("button"); - if_block.c(); - this.h(); - }, - - l: function claim(nodes) { - button = claim_element(nodes, "BUTTON", { class: true, disabled: true }, false); - var button_nodes = children(button); - - if_block.l(button_nodes); - button_nodes.forEach(detach_dev); - this.h(); - }, - - h: function hydrate() { - attr_dev(button, "class", button_class_value = "" + null_to_empty(ctx.className) + " svelte-1q8lga0"); - button.disabled = ctx.disabled; - add_location(button, file$2, 23, 0, 422); - dispose = listen_dev(button, "click", ctx.clickHandler); - }, - - m: function mount(target, anchor) { - insert_dev(target, button, anchor); - if_blocks[current_block_type_index].m(button, null); - current = true; - }, - - p: function update(changed, ctx) { - var previous_block_index = current_block_type_index; - current_block_type_index = select_block_type(changed, ctx); - if (current_block_type_index === previous_block_index) { - if_blocks[current_block_type_index].p(changed, ctx); - } else { - group_outros(); - transition_out(if_blocks[previous_block_index], 1, 1, () => { - if_blocks[previous_block_index] = null; - }); - check_outros(); - - if_block = if_blocks[current_block_type_index]; - if (!if_block) { - if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); - if_block.c(); - } - transition_in(if_block, 1); - if_block.m(button, null); - } - - if ((!current || changed.className) && button_class_value !== (button_class_value = "" + null_to_empty(ctx.className) + " svelte-1q8lga0")) { - attr_dev(button, "class", button_class_value); - } - - if (!current || changed.disabled) { - prop_dev(button, "disabled", ctx.disabled); - } - }, - - i: function intro(local) { - if (current) return; - transition_in(if_block); - current = true; - }, - - o: function outro(local) { - transition_out(if_block); - current = false; - }, - - d: function destroy(detaching) { - if (detaching) { - detach_dev(button); - } - - if_blocks[current_block_type_index].d(); - dispose(); - } - }; - dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$2.name, type: "component", source: "", ctx }); - return block; - } - - function instance$2($$self, $$props, $$invalidate) { - let { className = "default", disabled = false, contentText, contentComponent, onClick = () => {} } = $$props; - - let { _bb } = $$props; - let contentComponentContainer; + dispose() + }, + } + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_if_block.name, + type: "if", + source: "(28:0) {#if hideValue}", + ctx, + }) + return block + } + + function create_fragment(ctx) { + var if_block_anchor + + function select_block_type(changed, ctx) { + if (ctx.hideValue) return create_if_block + return create_else_block + } - const clickHandler = () => { - if(onClick) onClick(); - }; - - const writable_props = ['className', 'disabled', 'contentText', 'contentComponent', 'onClick', '_bb']; - Object.keys($$props).forEach(key => { - if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(` - -
- {#each initialOptions as option} - {option.key} : {option.value} removeOption(option)}>{@html getIcon("trash-2")} - {/each} -
+ + +
+ + + + + + + +
+ +
+ + + +
+
+ {#each initialOptions as option} + + {option.key} : {option.value} + removeOption(option)}> + {@html getIcon('trash-2')} + + + {/each}
+
- - - - + + + + - - \ No newline at end of file + } + diff --git a/packages/builder/src/actionsAndTriggers/Actions.svelte b/packages/builder/src/actionsAndTriggers/Actions.svelte index 9a5503e0f..d87ed307d 100644 --- a/packages/builder/src/actionsAndTriggers/Actions.svelte +++ b/packages/builder/src/actionsAndTriggers/Actions.svelte @@ -1,112 +1,111 @@

Actions

{#if actionsArray} - +
- - - - - - - + + + + + + - {#each actionsArray as action} + {#each actionsArray as action} - - - - - + + + + + - {/each} + {/each} -
DescriptionBehaviour SourceBehaviour NameDefault Options
DescriptionBehaviour SourceBehaviour NameDefault Options +
{action.name}{action.behaviourSource}{action.behaviourName}{@html getDefaultOptionsHtml(action.initialOptions)} - onActionEdit(action)}>{@html getIcon("edit")} - onActionDelete(action)}>{@html getIcon("trash")} - {action.name}{action.behaviourSource}{action.behaviourName} + {@html getDefaultOptionsHtml(action.initialOptions)} + + onActionEdit(action)}> + {@html getIcon('edit')} + + onActionDelete(action)}> + {@html getIcon('trash')} + +
-{:else} -(no actions added) -{/if} - + +{:else}(no actions added){/if} - {#if isEditing} - - {/if} + {#if isEditing} + + {/if} - \ No newline at end of file + font-size: 0.9rem; + } + diff --git a/packages/builder/src/actionsAndTriggers/ActionsAndTriggersRoot.svelte b/packages/builder/src/actionsAndTriggers/ActionsAndTriggersRoot.svelte index 5af9c2812..696531a4d 100644 --- a/packages/builder/src/actionsAndTriggers/ActionsAndTriggersRoot.svelte +++ b/packages/builder/src/actionsAndTriggers/ActionsAndTriggersRoot.svelte @@ -1,129 +1,130 @@
-
- - - - -
- -
- - - -
+
+ + + + +
+ +
+ + + +
\ No newline at end of file + } + diff --git a/packages/builder/src/actionsAndTriggers/TriggerView.svelte b/packages/builder/src/actionsAndTriggers/TriggerView.svelte index 6502da9ec..24f19cff7 100644 --- a/packages/builder/src/actionsAndTriggers/TriggerView.svelte +++ b/packages/builder/src/actionsAndTriggers/TriggerView.svelte @@ -1,68 +1,71 @@
- + + +
- - - - - - + + + + - + - - - - + + + +
\ No newline at end of file + diff --git a/packages/builder/src/actionsAndTriggers/Triggers.svelte b/packages/builder/src/actionsAndTriggers/Triggers.svelte index 1f3194b12..104a5d49c 100644 --- a/packages/builder/src/actionsAndTriggers/Triggers.svelte +++ b/packages/builder/src/actionsAndTriggers/Triggers.svelte @@ -1,94 +1,90 @@

Triggers

{#if $store.triggers} - +
- - - - - - - + + + + + + - {#each $store.triggers as trigger} + {#each $store.triggers as trigger} - - - - - + + + + + - {/each} + {/each} -
EventActionConditionCreate Options
EventActionConditionCreate Options +
{trigger.eventName}{trigger.actionName}{trigger.condition}{trigger.optionsCreator} - onTriggerEdit(trigger)}>{@html getIcon("edit")} - onTriggerDelete(trigger)}>{@html getIcon("trash")} - {trigger.eventName}{trigger.actionName}{trigger.condition}{trigger.optionsCreator} + onTriggerEdit(trigger)}> + {@html getIcon('edit')} + + onTriggerDelete(trigger)}> + {@html getIcon('trash')} + +
-{:else} -(no triggers added) -{/if} - + +{:else}(no triggers added){/if} - {#if isEditing} - - {/if} + {#if isEditing} + + {/if} \ No newline at end of file + } + diff --git a/packages/builder/src/builderStore/api.js b/packages/builder/src/builderStore/api.js index cf7732c02..49ae3ed58 100644 --- a/packages/builder/src/builderStore/api.js +++ b/packages/builder/src/builderStore/api.js @@ -1,17 +1,20 @@ -const apiCall = (method) => (url, body) => - fetch(url, { - method: method, - headers: { - 'Content-Type': 'application/json', - }, - body: body && JSON.stringify(body), - }); +const apiCall = method => (url, body) => + fetch(url, { + method: method, + headers: { + "Content-Type": "application/json", + }, + body: body && JSON.stringify(body), + }) -const post = apiCall("POST"); -const get = apiCall("GET"); -const patch = apiCall("PATCH"); -const del = apiCall("DELETE"); +const post = apiCall("POST") +const get = apiCall("GET") +const patch = apiCall("PATCH") +const del = apiCall("DELETE") export default { - post, get, patch, delete:del -}; \ No newline at end of file + post, + get, + patch, + delete: del, +} diff --git a/packages/builder/src/builderStore/buildCodeForScreens.js b/packages/builder/src/builderStore/buildCodeForScreens.js index fdd2c8d79..66512b703 100644 --- a/packages/builder/src/builderStore/buildCodeForScreens.js +++ b/packages/builder/src/builderStore/buildCodeForScreens.js @@ -1,35 +1,33 @@ +const buildCodeForSingleScreen = screen => { + let code = "" + const walkProps = props => { + if (props._code && props._code.trim().length > 0) { + code += buildComponentCode(props) + } + if (!props._children) return -const buildCodeForSingleScreen = (screen) => { - let code = ""; - const walkProps = (props) => { - if(props._code && props._code.trim().length > 0) { - code += buildComponentCode(props) - } - - if(!props._children) return; - - for(let child of props._children) { - walkProps(child); - } + for (let child of props._children) { + walkProps(child) } + } - walkProps(screen.props); + walkProps(screen.props) - return code; + return code } export const buildCodeForScreens = screens => { - let allfunctions = ""; - for(let screen of screens) { - allfunctions += buildCodeForSingleScreen(screen); - } - - return (`return ({ ${allfunctions} });`); + let allfunctions = "" + for (let screen of screens) { + allfunctions += buildCodeForSingleScreen(screen) + } + + return `return ({ ${allfunctions} });` } -const buildComponentCode = (componentProps) => -`"${componentProps._id}" : (render, context) => { +const buildComponentCode = componentProps => + `"${componentProps._id}" : (render, context) => { ${componentProps._code} }, -`; \ No newline at end of file +` diff --git a/packages/builder/src/builderStore/createPackage.js b/packages/builder/src/builderStore/createPackage.js index 5df88b7df..c67585af6 100644 --- a/packages/builder/src/builderStore/createPackage.js +++ b/packages/builder/src/builderStore/createPackage.js @@ -1,12 +1,12 @@ -import {createNewHierarchy} from "../common/core"; +import { createNewHierarchy } from "../common/core" export const createPackage = (packageInfo, store) => { - packageInfo.createNewPackage(""); - const root = createNewHierarchy(); - store.importAppDefinition({ - hierarchy:root, - actions:[], - triggers:[], - accessLevels: {version:0, levels:[]} - }); -}; + packageInfo.createNewPackage("") + const root = createNewHierarchy() + store.importAppDefinition({ + hierarchy: root, + actions: [], + triggers: [], + accessLevels: { version: 0, levels: [] }, + }) +} diff --git a/packages/builder/src/builderStore/generate_css.js b/packages/builder/src/builderStore/generate_css.js index 29ddb1624..212a032a6 100644 --- a/packages/builder/src/builderStore/generate_css.js +++ b/packages/builder/src/builderStore/generate_css.js @@ -1,118 +1,113 @@ -import { filter, map, reduce, toPairs } from "lodash/fp"; -import { pipe } from "../common/core"; +import { filter, map, reduce, toPairs } from "lodash/fp" +import { pipe } from "../common/core" -const self = n => n; -const join_with = delimiter => a => a.join(delimiter); -const empty_string_to_unset = s => s.length ? s : "0"; -const add_suffix = suffix => s => s + suffix; +const self = n => n +const join_with = delimiter => a => a.join(delimiter) +const empty_string_to_unset = s => (s.length ? s : "0") +const add_suffix = suffix => s => s + suffix -export const make_margin = (values) => pipe(values, [ - map(empty_string_to_unset), - map(add_suffix('px')), - join_with(' ') -]); - -const tap = message => x => { - console.log(x); - return x; -} +export const make_margin = values => + pipe(values, [ + map(empty_string_to_unset), + map(add_suffix("px")), + join_with(" "), + ]) const css_map = { - templaterows: { - name: 'grid-template-columns', - generate: self - }, - templatecolumns: { - name: 'grid-template-rows', - generate: self - }, - gridarea: { - name: 'grid-area', - generate: make_margin - }, - gap: { - name: 'grid-gap', - generate: n => `${n}px` - }, - columnstart: { - name: 'grid-column-start', - generate: self - }, - columnend: { - name: 'grid-column-end', - generate: self - }, - rowstart: { - name: 'grid-row-start', - generate: self - }, - rowend: { - name: 'grid-row-end', - generate: self - }, - padding: { - name: 'padding', - generate: make_margin - }, - margin: { - name: 'margin', - generate: make_margin - }, - zindex: { - name: 'z-index', - generate: self - } + templaterows: { + name: "grid-template-columns", + generate: self, + }, + templatecolumns: { + name: "grid-template-rows", + generate: self, + }, + gridarea: { + name: "grid-area", + generate: make_margin, + }, + gap: { + name: "grid-gap", + generate: n => `${n}px`, + }, + columnstart: { + name: "grid-column-start", + generate: self, + }, + columnend: { + name: "grid-column-end", + generate: self, + }, + rowstart: { + name: "grid-row-start", + generate: self, + }, + rowend: { + name: "grid-row-end", + generate: self, + }, + padding: { + name: "padding", + generate: make_margin, + }, + margin: { + name: "margin", + generate: make_margin, + }, + zindex: { + name: "z-index", + generate: self, + }, } export const generate_rule = ([name, values]) => - `${css_map[name].name}: ${css_map[name].generate(values)};` + `${css_map[name].name}: ${css_map[name].generate(values)};` const handle_grid = (acc, [name, value]) => { - let tmp = []; + let tmp = [] - if (name === 'row' || name === 'column') { - if (value[0]) tmp.push([`${name}start`, value[0]]); - if (value[1]) tmp.push([`${name}end`, value[1]]); - return acc.concat(tmp) - } + if (name === "row" || name === "column") { + if (value[0]) tmp.push([`${name}start`, value[0]]) + if (value[1]) tmp.push([`${name}end`, value[1]]) + return acc.concat(tmp) + } - return acc.concat([[name, value]]); + return acc.concat([[name, value]]) } const object_to_css_string = [ - toPairs, - reduce(handle_grid, []), - filter(v => Array.isArray(v[1]) ? v[1].some(s => s.length) : v[1].length), - map(generate_rule), - join_with('\n'), -]; + toPairs, + reduce(handle_grid, []), + filter(v => (Array.isArray(v[1]) ? v[1].some(s => s.length) : v[1].length)), + map(generate_rule), + join_with("\n"), +] export const generate_css = ({ layout, position }) => { - let _layout = pipe(layout, object_to_css_string); - _layout = _layout.length ? _layout + "\ndisplay: grid;" : _layout; + let _layout = pipe(layout, object_to_css_string) + _layout = _layout.length ? _layout + "\ndisplay: grid;" : _layout - return { - layout: _layout, - position: pipe(position, object_to_css_string) - } + return { + layout: _layout, + position: pipe(position, object_to_css_string), + } } -const apply_class = (id, name, styles) => `.${name}-${id} {\n${styles}\n}`; - -export const generate_screen_css = (component_array) => { - let styles = ""; +const apply_class = (id, name, styles) => `.${name}-${id} {\n${styles}\n}` - for (let i = 0; i < component_array.length; i += 1) { - const { _styles, _id, _children } = component_array[i]; - const { layout, position } = generate_css(_styles); +export const generate_screen_css = component_array => { + let styles = "" - styles += apply_class(_id, 'pos', position) + "\n"; - styles += apply_class(_id, 'lay', layout) + "\n"; + for (let i = 0; i < component_array.length; i += 1) { + const { _styles, _id, _children } = component_array[i] + const { layout, position } = generate_css(_styles) - if (_children && _children.length) { - styles += generate_screen_css(_children) + "\n"; - } + styles += apply_class(_id, "pos", position) + "\n" + styles += apply_class(_id, "lay", layout) + "\n" - } - return styles.trim(); + if (_children && _children.length) { + styles += generate_screen_css(_children) + "\n" + } + } + return styles.trim() } diff --git a/packages/builder/src/builderStore/index.js b/packages/builder/src/builderStore/index.js index a1029f4d4..119fb60de 100644 --- a/packages/builder/src/builderStore/index.js +++ b/packages/builder/src/builderStore/index.js @@ -1,29 +1,27 @@ -import {createPackage} from "./createPackage"; -import getStore from "./store"; +import { createPackage } from "./createPackage" +import getStore from "./store" -export const store = getStore(); +export const store = getStore() -export const createNewPackage = () => - createPackage(packageInfo, store); +export const createNewPackage = () => createPackage(packageInfo, store) export const initialise = async () => { - try { - setupRouter(store); - await store.initialise(); - } catch(err) { - console.log(err); - } - -} + try { + setupRouter(store) + await store.initialise() + } catch (err) { + console.log(err) + } +} -const setupRouter = (writable) => { - const pushState = history.pushState; - history.pushState = () => { - pushState.apply(history, arguments); - //fireEvents('pushState', arguments); - writable.initialise(); - } - window.addEventListener('hashchange',()=>{ - writable.initialise(); - }) +const setupRouter = writable => { + const pushState = history.pushState + history.pushState = () => { + pushState.apply(history, arguments) + //fireEvents('pushState', arguments); + writable.initialise() + } + window.addEventListener("hashchange", () => { + writable.initialise() + }) } diff --git a/packages/builder/src/builderStore/loadComponentLibraries.js b/packages/builder/src/builderStore/loadComponentLibraries.js index 1dfa99025..e178eb324 100644 --- a/packages/builder/src/builderStore/loadComponentLibraries.js +++ b/packages/builder/src/builderStore/loadComponentLibraries.js @@ -1,50 +1,47 @@ -import { map } from "lodash/fp"; +import { map } from "lodash/fp" export const loadLibs = async (appName, appPackage) => { + const allLibraries = {} + for (let lib of appPackage.pages.componentLibraries) { + const libModule = await import(makeLibraryUrl(appName, lib)) + allLibraries[lib] = libModule + } - const allLibraries = {}; - for(let lib of appPackage.pages.componentLibraries) { - const libModule = await import(makeLibraryUrl(appName, lib)); - allLibraries[lib] = libModule; - } - - return allLibraries; + return allLibraries } export const loadGeneratorLibs = async (appName, appPackage) => { + const allGeneratorLibs = {} + for (let lib of appPackage.pages.componentLibraries) { + const generatorModule = await import(makeGeneratorLibraryUrl(appName, lib)) + allGeneratorLibs[lib] = generatorModule + } - const allGeneratorLibs = {}; - for(let lib of appPackage.pages.componentLibraries) { - const generatorModule = await import(makeGeneratorLibraryUrl(appName, lib)); - allGeneratorLibs[lib] = generatorModule; - } - - return allGeneratorLibs; + return allGeneratorLibs } export const loadLibUrls = (appName, appPackage) => { + const allLibraries = [] + for (let lib of appPackage.pages.componentLibraries) { + const libUrl = makeLibraryUrl(appName, lib) + allLibraries.push({ libName: lib, importPath: libUrl }) + } - const allLibraries = []; - for(let lib of appPackage.pages.componentLibraries) { - const libUrl = makeLibraryUrl(appName, lib); - allLibraries.push({libName:lib, importPath:libUrl}); - } - - return allLibraries; + return allLibraries } export const loadLib = async (appName, lib, allLibs) => { - allLibs[lib] = await import(makeLibraryUrl(appName, lib)); - return allLibs; + allLibs[lib] = await import(makeLibraryUrl(appName, lib)) + return allLibs } export const loadGeneratorLib = async (appName, lib, allGeneratorLibs) => { - allGeneratorLibs[lib] = await import(makeGeneratorLibraryUrl(appName, lib)); - return allGeneratorLibs; + allGeneratorLibs[lib] = await import(makeGeneratorLibraryUrl(appName, lib)) + return allGeneratorLibs } -export const makeLibraryUrl = (appName, lib) => - `/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}` +export const makeLibraryUrl = (appName, lib) => + `/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}` -export const makeGeneratorLibraryUrl = (appName, lib) => - `/_builder/${appName}/componentlibraryGenerators?lib=${encodeURI(lib)}` \ No newline at end of file +export const makeGeneratorLibraryUrl = (appName, lib) => + `/_builder/${appName}/componentlibraryGenerators?lib=${encodeURI(lib)}` diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 7e52a0e88..2ef057761 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -1,796 +1,796 @@ +import { hierarchy as hierarchyFunctions } from "../../../core/src" import { - hierarchy as hierarchyFunctions, -} from "../../../core/src"; + filter, + cloneDeep, + sortBy, + map, + last, + keys, + concat, + keyBy, + find, + isEmpty, + values, +} from "lodash/fp" import { - filter, cloneDeep, sortBy, - map, last, keys, concat, keyBy, - find, isEmpty, values, -} from "lodash/fp"; -import { - pipe, getNode, validate, - constructHierarchy, templateApi -} from "../common/core"; -import { writable } from "svelte/store"; + pipe, + getNode, + validate, + constructHierarchy, + templateApi, +} from "../common/core" +import { writable } from "svelte/store" import { defaultPagesObject } from "../userInterface/pagesParsing/defaultPagesObject" import { buildPropsHierarchy } from "../userInterface/pagesParsing/buildPropsHierarchy" -import api from "./api"; -import { isRootComponent, getExactComponent } from "../userInterface/pagesParsing/searchComponents"; -import { rename } from "../userInterface/pagesParsing/renameScreen"; +import api from "./api" +import { + isRootComponent, + getExactComponent, +} from "../userInterface/pagesParsing/searchComponents" +import { rename } from "../userInterface/pagesParsing/renameScreen" import { - getNewComponentInfo, getScreenInfo, -} from "../userInterface/pagesParsing/createProps"; + getNewComponentInfo, + getScreenInfo, +} from "../userInterface/pagesParsing/createProps" import { - loadLibs, loadLibUrls, loadGeneratorLibs -} from "./loadComponentLibraries"; -import { buildCodeForScreens } from "./buildCodeForScreens"; -import { uuid } from './uuid'; -import { generate_screen_css } from './generate_css'; + loadLibs, + loadLibUrls, + loadGeneratorLibs, +} from "./loadComponentLibraries" +import { buildCodeForScreens } from "./buildCodeForScreens" +import { uuid } from "./uuid" +import { generate_screen_css } from "./generate_css" -let appname = ""; +let appname = "" export const getStore = () => { - - const initial = { - apps: [], - appname: "", - hierarchy: {}, - actions: [], - triggers: [], - pages: defaultPagesObject(), - mainUi: {}, - unauthenticatedUi: {}, - components: [], - currentFrontEndItem: null, - currentComponentInfo: null, - currentFrontEndType: "none", - currentPageName: "", - currentComponentProps: null, - currentNodeIsNew: false, - errors: [], - activeNav: "database", - isBackend: true, - hasAppPackage: false, - accessLevels: { version: 0, levels: [] }, - currentNode: null, - libraries: null, - showSettings: false, - useAnalytics: true, - }; - - const store = writable(initial); - - store.initialise = initialise(store, initial); - store.newChildRecord = newRecord(store, false); - store.newRootRecord = newRecord(store, true); - store.selectExistingNode = selectExistingNode(store); - store.newChildIndex = newIndex(store, false); - store.newRootIndex = newIndex(store, true); - store.saveCurrentNode = saveCurrentNode(store); - store.importAppDefinition = importAppDefinition(store); - store.deleteCurrentNode = deleteCurrentNode(store); - store.saveField = saveField(store); - store.deleteField = deleteField(store); - store.saveAction = saveAction(store); - store.deleteAction = deleteAction(store); - store.saveTrigger = saveTrigger(store); - store.deleteTrigger = deleteTrigger(store); - store.saveLevel = saveLevel(store); - store.deleteLevel = deleteLevel(store); - store.setActiveNav = setActiveNav(store); - store.saveScreen = saveScreen(store); - store.refreshComponents = refreshComponents(store); - store.addComponentLibrary = addComponentLibrary(store); - store.renameScreen = renameScreen(store); - store.deleteScreen = deleteScreen(store); - store.setCurrentScreen = setCurrentScreen(store); - store.setCurrentPage = setCurrentPage(store); - store.createScreen = createScreen(store); - store.removeComponentLibrary = removeComponentLibrary(store); - store.addStylesheet = addStylesheet(store); - store.removeStylesheet = removeStylesheet(store); - store.savePage = savePage(store); - store.showFrontend = showFrontend(store); - store.showBackend = showBackend(store); - store.showSettings = showSettings(store); - store.useAnalytics = useAnalytics(store); - store.createGeneratedComponents = createGeneratedComponents(store); - store.addChildComponent = addChildComponent(store); - store.selectComponent = selectComponent(store); - store.setComponentProp = setComponentProp(store); - store.setComponentStyle = setComponentStyle(store); - store.setComponentCode = setComponentCode(store); - return store; -} - -export default getStore; + const initial = { + apps: [], + appname: "", + hierarchy: {}, + actions: [], + triggers: [], + pages: defaultPagesObject(), + mainUi: {}, + unauthenticatedUi: {}, + components: [], + currentFrontEndItem: null, + currentComponentInfo: null, + currentFrontEndType: "none", + currentPageName: "", + currentComponentProps: null, + currentNodeIsNew: false, + errors: [], + activeNav: "database", + isBackend: true, + hasAppPackage: false, + accessLevels: { version: 0, levels: [] }, + currentNode: null, + libraries: null, + showSettings: false, + useAnalytics: true, + } + + const store = writable(initial) + + store.initialise = initialise(store, initial) + store.newChildRecord = newRecord(store, false) + store.newRootRecord = newRecord(store, true) + store.selectExistingNode = selectExistingNode(store) + store.newChildIndex = newIndex(store, false) + store.newRootIndex = newIndex(store, true) + store.saveCurrentNode = saveCurrentNode(store) + store.importAppDefinition = importAppDefinition(store) + store.deleteCurrentNode = deleteCurrentNode(store) + store.saveField = saveField(store) + store.deleteField = deleteField(store) + store.saveAction = saveAction(store) + store.deleteAction = deleteAction(store) + store.saveTrigger = saveTrigger(store) + store.deleteTrigger = deleteTrigger(store) + store.saveLevel = saveLevel(store) + store.deleteLevel = deleteLevel(store) + store.setActiveNav = setActiveNav(store) + store.saveScreen = saveScreen(store) + store.refreshComponents = refreshComponents(store) + store.addComponentLibrary = addComponentLibrary(store) + store.renameScreen = renameScreen(store) + store.deleteScreen = deleteScreen(store) + store.setCurrentScreen = setCurrentScreen(store) + store.setCurrentPage = setCurrentPage(store) + store.createScreen = createScreen(store) + store.removeComponentLibrary = removeComponentLibrary(store) + store.addStylesheet = addStylesheet(store) + store.removeStylesheet = removeStylesheet(store) + store.savePage = savePage(store) + store.showFrontend = showFrontend(store) + store.showBackend = showBackend(store) + store.showSettings = showSettings(store) + store.useAnalytics = useAnalytics(store) + store.createGeneratedComponents = createGeneratedComponents(store) + store.addChildComponent = addChildComponent(store) + store.selectComponent = selectComponent(store) + store.setComponentProp = setComponentProp(store) + store.setComponentStyle = setComponentStyle(store) + store.setComponentCode = setComponentCode(store) + return store +} + +export default getStore const initialise = (store, initial) => async () => { - - appname = window.location.hash - ? last(window.location.hash.substr(1).split("/")) - : ""; - - if (!appname) { - initial.apps = await api.get(`/_builder/api/apps`).then(r => r.json()); - initial.hasAppPackage = false; - store.set(initial); - return initial; - } - - const pkg = await api.get(`/_builder/api/${appname}/appPackage`) - .then(r => r.json()); - - initial.libraries = await loadLibs(appname, pkg); - initial.generatorLibraries = await loadGeneratorLibs(appname, pkg); - initial.loadLibraryUrls = () => loadLibUrls(appname, pkg); - initial.appname = appname; - initial.pages = pkg.pages; - initial.hasAppPackage = true; - initial.hierarchy = pkg.appDefinition.hierarchy; - initial.accessLevels = pkg.accessLevels; - initial.screens = values(pkg.screens); - initial.generators = generatorsArray(pkg.components.generators); - initial.components = values(pkg.components.components); - initial.actions = values(pkg.appDefinition.actions); - initial.triggers = pkg.appDefinition.triggers; - - if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) { - initial.hierarchy = constructHierarchy(initial.hierarchy); - const shadowHierarchy = createShadowHierarchy(initial.hierarchy); - if (initial.currentNode !== null) - initial.currentNode = getNode( - shadowHierarchy, initial.currentNode.nodeId - ); - } - - store.set(initial); - return initial; + appname = window.location.hash + ? last(window.location.hash.substr(1).split("/")) + : "" + + if (!appname) { + initial.apps = await api.get(`/_builder/api/apps`).then(r => r.json()) + initial.hasAppPackage = false + store.set(initial) + return initial + } + + const pkg = await api + .get(`/_builder/api/${appname}/appPackage`) + .then(r => r.json()) + + initial.libraries = await loadLibs(appname, pkg) + initial.generatorLibraries = await loadGeneratorLibs(appname, pkg) + initial.loadLibraryUrls = () => loadLibUrls(appname, pkg) + initial.appname = appname + initial.pages = pkg.pages + initial.hasAppPackage = true + initial.hierarchy = pkg.appDefinition.hierarchy + initial.accessLevels = pkg.accessLevels + initial.screens = values(pkg.screens) + initial.generators = generatorsArray(pkg.components.generators) + initial.components = values(pkg.components.components) + initial.actions = values(pkg.appDefinition.actions) + initial.triggers = pkg.appDefinition.triggers + + if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) { + initial.hierarchy = constructHierarchy(initial.hierarchy) + const shadowHierarchy = createShadowHierarchy(initial.hierarchy) + if (initial.currentNode !== null) + initial.currentNode = getNode(shadowHierarchy, initial.currentNode.nodeId) + } + + store.set(initial) + return initial } const generatorsArray = generators => - pipe(generators, [ - keys, - filter(k => k !== "_lib"), - map(k => generators[k]) - ]); - + pipe(generators, [keys, filter(k => k !== "_lib"), map(k => generators[k])]) const showSettings = store => show => { - store.update(s => { - s.showSettings = !s.showSettings; - return s; - }); + store.update(s => { + s.showSettings = !s.showSettings + return s + }) } const useAnalytics = store => useAnalytics => { - store.update(s => { - s.useAnalytics = !s.useAnalytics; - return s; - }); + store.update(s => { + s.useAnalytics = !s.useAnalytics + return s + }) } const showBackend = store => () => { - store.update(s => { - s.isBackend = true; - return s; - }) + store.update(s => { + s.isBackend = true + return s + }) } const showFrontend = store => () => { - store.update(s => { - s.isBackend = false; - return s; - }) + store.update(s => { + s.isBackend = false + return s + }) } const newRecord = (store, useRoot) => () => { - store.update(s => { - s.currentNodeIsNew = true; - const shadowHierarchy = createShadowHierarchy(s.hierarchy); - parent = useRoot ? shadowHierarchy - : getNode( - shadowHierarchy, - s.currentNode.nodeId); - s.errors = []; - s.currentNode = templateApi(shadowHierarchy) - .getNewRecordTemplate(parent, "", true); - return s; - }); -} - - -const selectExistingNode = (store) => (nodeId) => { - store.update(s => { - const shadowHierarchy = createShadowHierarchy(s.hierarchy); - s.currentNode = getNode( - shadowHierarchy, nodeId - ); - s.currentNodeIsNew = false; - s.errors = []; - s.activeNav = "database"; - return s; - }) + store.update(s => { + s.currentNodeIsNew = true + const shadowHierarchy = createShadowHierarchy(s.hierarchy) + parent = useRoot + ? shadowHierarchy + : getNode(shadowHierarchy, s.currentNode.nodeId) + s.errors = [] + s.currentNode = templateApi(shadowHierarchy).getNewRecordTemplate( + parent, + "", + true + ) + return s + }) +} + +const selectExistingNode = store => nodeId => { + store.update(s => { + const shadowHierarchy = createShadowHierarchy(s.hierarchy) + s.currentNode = getNode(shadowHierarchy, nodeId) + s.currentNodeIsNew = false + s.errors = [] + s.activeNav = "database" + return s + }) } const newIndex = (store, useRoot) => () => { - store.update(s => { - s.currentNodeIsNew = true; - s.errors = []; - const shadowHierarchy = createShadowHierarchy(s.hierarchy); - parent = useRoot ? shadowHierarchy - : getNode( - shadowHierarchy, - s.currentNode.nodeId); - - s.currentNode = templateApi(shadowHierarchy) - .getNewIndexTemplate(parent); - return s; - }); -} - -const saveCurrentNode = (store) => () => { - store.update(s => { - - const errors = validate.node(s.currentNode); - s.errors = errors; - if (errors.length > 0) { - return s; - } - - const parentNode = getNode( - s.hierarchy, s.currentNode.parent().nodeId); - - const existingNode = getNode( - s.hierarchy, s.currentNode.nodeId); - - let index = parentNode.children.length; - if (!!existingNode) { - // remove existing - index = existingNode.parent().children.indexOf(existingNode); - existingNode.parent().children = pipe(existingNode.parent().children, [ - filter(c => c.nodeId !== existingNode.nodeId) - ]); - } - - // should add node into existing hierarchy - const cloned = cloneDeep(s.currentNode); - templateApi(s.hierarchy).constructNode( - parentNode, - cloned - ); - - const newIndexOfchild = child => { - if (child === cloned) return index; - const currentIndex = parentNode.children.indexOf(child); - return currentIndex >= index ? currentIndex + 1 : currentIndex; - } - - parentNode.children = pipe(parentNode.children, [ - sortBy(newIndexOfchild) - ]); - - if (!existingNode && s.currentNode.type === "record") { - const defaultIndex = templateApi(s.hierarchy) - .getNewIndexTemplate(cloned.parent()); - defaultIndex.name = `all_${cloned.collectionName}`; - defaultIndex.allowedRecordNodeIds = [cloned.nodeId]; - } - - s.currentNodeIsNew = false; - - savePackage(store, s); - - return s; - }); + store.update(s => { + s.currentNodeIsNew = true + s.errors = [] + const shadowHierarchy = createShadowHierarchy(s.hierarchy) + parent = useRoot + ? shadowHierarchy + : getNode(shadowHierarchy, s.currentNode.nodeId) + + s.currentNode = templateApi(shadowHierarchy).getNewIndexTemplate(parent) + return s + }) +} + +const saveCurrentNode = store => () => { + store.update(s => { + const errors = validate.node(s.currentNode) + s.errors = errors + if (errors.length > 0) { + return s + } + + const parentNode = getNode(s.hierarchy, s.currentNode.parent().nodeId) + + const existingNode = getNode(s.hierarchy, s.currentNode.nodeId) + + let index = parentNode.children.length + if (existingNode) { + // remove existing + index = existingNode.parent().children.indexOf(existingNode) + existingNode.parent().children = pipe(existingNode.parent().children, [ + filter(c => c.nodeId !== existingNode.nodeId), + ]) + } + + // should add node into existing hierarchy + const cloned = cloneDeep(s.currentNode) + templateApi(s.hierarchy).constructNode(parentNode, cloned) + + const newIndexOfchild = child => { + if (child === cloned) return index + const currentIndex = parentNode.children.indexOf(child) + return currentIndex >= index ? currentIndex + 1 : currentIndex + } + + parentNode.children = pipe(parentNode.children, [sortBy(newIndexOfchild)]) + + if (!existingNode && s.currentNode.type === "record") { + const defaultIndex = templateApi(s.hierarchy).getNewIndexTemplate( + cloned.parent() + ) + defaultIndex.name = `all_${cloned.collectionName}` + defaultIndex.allowedRecordNodeIds = [cloned.nodeId] + } + + s.currentNodeIsNew = false + + savePackage(store, s) + + return s + }) } const importAppDefinition = store => appDefinition => { - store.update(s => { - s.hierarchy = appDefinition.hierarchy; - s.currentNode = appDefinition.hierarchy.children.length > 0 - ? appDefinition.hierarchy.children[0] - : null; - s.actions = appDefinition.actions; - s.triggers = appDefinition.triggers; - s.currentNodeIsNew = false; - return s; - }); + store.update(s => { + s.hierarchy = appDefinition.hierarchy + s.currentNode = + appDefinition.hierarchy.children.length > 0 + ? appDefinition.hierarchy.children[0] + : null + s.actions = appDefinition.actions + s.triggers = appDefinition.triggers + s.currentNodeIsNew = false + return s + }) } const deleteCurrentNode = store => () => { - store.update(s => { - const nodeToDelete = getNode(s.hierarchy, s.currentNode.nodeId); - s.currentNode = hierarchyFunctions.isRoot(nodeToDelete.parent()) - ? find(n => n != s.currentNode) - (s.hierarchy.children) - : nodeToDelete.parent(); - if (hierarchyFunctions.isRecord(nodeToDelete)) { - nodeToDelete.parent().children = filter(c => c.nodeId !== nodeToDelete.nodeId) - (nodeToDelete.parent().children); - } else { - nodeToDelete.parent().indexes = filter(c => c.nodeId !== nodeToDelete.nodeId) - (nodeToDelete.parent().indexes); - } - s.errors = []; - savePackage(store, s); - return s; - }); -} - -const saveField = databaseStore => (field) => { - databaseStore.update(db => { - db.currentNode.fields = filter(f => f.name !== field.name) - (db.currentNode.fields); - - templateApi(db.hierarchy).addField(db.currentNode, field); - return db; - }); + store.update(s => { + const nodeToDelete = getNode(s.hierarchy, s.currentNode.nodeId) + s.currentNode = hierarchyFunctions.isRoot(nodeToDelete.parent()) + ? find(n => n != s.currentNode)(s.hierarchy.children) + : nodeToDelete.parent() + if (hierarchyFunctions.isRecord(nodeToDelete)) { + nodeToDelete.parent().children = filter( + c => c.nodeId !== nodeToDelete.nodeId + )(nodeToDelete.parent().children) + } else { + nodeToDelete.parent().indexes = filter( + c => c.nodeId !== nodeToDelete.nodeId + )(nodeToDelete.parent().indexes) + } + s.errors = [] + savePackage(store, s) + return s + }) } +const saveField = databaseStore => field => { + databaseStore.update(db => { + db.currentNode.fields = filter(f => f.name !== field.name)( + db.currentNode.fields + ) + + templateApi(db.hierarchy).addField(db.currentNode, field) + return db + }) +} const deleteField = databaseStore => field => { - databaseStore.update(db => { - db.currentNode.fields = filter(f => f.name !== field.name) - (db.currentNode.fields); + databaseStore.update(db => { + db.currentNode.fields = filter(f => f.name !== field.name)( + db.currentNode.fields + ) - return db; - }); + return db + }) } - const saveAction = store => (newAction, isNew, oldAction = null) => { - store.update(s => { - - const existingAction = isNew - ? null - : find(a => a.name === oldAction.name)(s.actions); - - if (existingAction) { - s.actions = pipe(s.actions, [ - map(a => a === existingAction ? newAction : a) - ]); - } else { - s.actions.push(newAction); - } - savePackage(store, s); - return s; - }); + store.update(s => { + const existingAction = isNew + ? null + : find(a => a.name === oldAction.name)(s.actions) + + if (existingAction) { + s.actions = pipe(s.actions, [ + map(a => (a === existingAction ? newAction : a)), + ]) + } else { + s.actions.push(newAction) + } + savePackage(store, s) + return s + }) } const deleteAction = store => action => { - store.update(s => { - s.actions = filter(a => a.name !== action.name)(s.actions); - savePackage(store, s); - return s; - }); + store.update(s => { + s.actions = filter(a => a.name !== action.name)(s.actions) + savePackage(store, s) + return s + }) } const saveTrigger = store => (newTrigger, isNew, oldTrigger = null) => { - store.update(s => { - - const existingTrigger = isNew - ? null - : find(a => a.name === oldTrigger.name)(s.triggers); - - if (existingTrigger) { - s.triggers = pipe(s.triggers, [ - map(a => a === existingTrigger ? newTrigger : a) - ]); - } else { - s.triggers.push(newTrigger); - } - savePackage(store, s); - return s; - }); + store.update(s => { + const existingTrigger = isNew + ? null + : find(a => a.name === oldTrigger.name)(s.triggers) + + if (existingTrigger) { + s.triggers = pipe(s.triggers, [ + map(a => (a === existingTrigger ? newTrigger : a)), + ]) + } else { + s.triggers.push(newTrigger) + } + savePackage(store, s) + return s + }) } const deleteTrigger = store => trigger => { - store.update(s => { - s.triggers = filter(t => t.name !== trigger.name)(s.triggers); - return s; - }); + store.update(s => { + s.triggers = filter(t => t.name !== trigger.name)(s.triggers) + return s + }) } -const incrementAccessLevelsVersion = (s) => - s.accessLevels.version = (s.accessLevels.version || 0) + 1; +const incrementAccessLevelsVersion = s => + (s.accessLevels.version = (s.accessLevels.version || 0) + 1) const saveLevel = store => (newLevel, isNew, oldLevel = null) => { - store.update(s => { - - const levels = s.accessLevels.levels; - - const existingLevel = isNew - ? null - : find(a => a.name === oldLevel.name)(levels); - - if (existingLevel) { - s.accessLevels.levels = pipe(levels, [ - map(a => a === existingLevel ? newLevel : a) - ]); - } else { - s.accessLevels.levels.push(newLevel); - } + store.update(s => { + const levels = s.accessLevels.levels + + const existingLevel = isNew + ? null + : find(a => a.name === oldLevel.name)(levels) + + if (existingLevel) { + s.accessLevels.levels = pipe(levels, [ + map(a => (a === existingLevel ? newLevel : a)), + ]) + } else { + s.accessLevels.levels.push(newLevel) + } - incrementAccessLevelsVersion(s); + incrementAccessLevelsVersion(s) - savePackage(store, s); - return s; - }); + savePackage(store, s) + return s + }) } const deleteLevel = store => level => { - store.update(s => { - s.accessLevels.levels = filter(t => t.name !== level.name)(s.accessLevels.levels); - incrementAccessLevelsVersion(s); - savePackage(store, s); - return s; - }); + store.update(s => { + s.accessLevels.levels = filter(t => t.name !== level.name)( + s.accessLevels.levels + ) + incrementAccessLevelsVersion(s) + savePackage(store, s) + return s + }) } const setActiveNav = store => navName => { - store.update(s => { - s.activeNav = navName; - return s; - }); + store.update(s => { + s.activeNav = navName + return s + }) } const createShadowHierarchy = hierarchy => - constructHierarchy(JSON.parse(JSON.stringify(hierarchy))); + constructHierarchy(JSON.parse(JSON.stringify(hierarchy))) -const saveScreen = store => (screen) => { - store.update(s => { - return _saveScreen(store, s, screen); - }) -}; +const saveScreen = store => screen => { + store.update(s => { + return _saveScreen(store, s, screen) + }) +} const _saveScreen = (store, s, screen) => { - const screens = pipe(s.screens, [ - filter(c => c.name !== screen.name), - concat([screen]) - ]); + const screens = pipe(s.screens, [ + filter(c => c.name !== screen.name), + concat([screen]), + ]) - s.screens = screens; - s.currentFrontEndItem = screen; - s.currentComponentInfo = getScreenInfo( - s.components, screen); + s.screens = screens + s.currentFrontEndItem = screen + s.currentComponentInfo = getScreenInfo(s.components, screen) - api.post(`/_builder/api/${s.appname}/screen`, screen) - .then(() => savePackage(store, s)); + api + .post(`/_builder/api/${s.appname}/screen`, screen) + .then(() => savePackage(store, s)) - return s; + return s } const _save = (appname, screen, store, s) => - api.post(`/_builder/api/${appname}/screen`, screen) - .then(() => savePackage(store, s)); + api + .post(`/_builder/api/${appname}/screen`, screen) + .then(() => savePackage(store, s)) const createScreen = store => (screenName, layoutComponentName) => { - store.update(s => { - const newComponentInfo = getNewComponentInfo( - s.components, layoutComponentName, screenName); + store.update(s => { + const newComponentInfo = getNewComponentInfo( + s.components, + layoutComponentName, + screenName + ) - s.currentFrontEndItem = newComponentInfo.component; - s.currentComponentInfo = newComponentInfo; - s.currentFrontEndType = "screen"; + s.currentFrontEndItem = newComponentInfo.component + s.currentComponentInfo = newComponentInfo + s.currentFrontEndType = "screen" - return _saveScreen(store, s, newComponentInfo.component); - }); -}; + return _saveScreen(store, s, newComponentInfo.component) + }) +} const createGeneratedComponents = store => components => { - store.update(s => { - s.components = [...s.components, ...components]; - s.screens = [...s.screens, ...components]; + store.update(s => { + s.components = [...s.components, ...components] + s.screens = [...s.screens, ...components] - const doCreate = async () => { - for (let c of components) { - await api.post(`/_builder/api/${s.appname}/screen`, c); - } + const doCreate = async () => { + for (let c of components) { + await api.post(`/_builder/api/${s.appname}/screen`, c) + } - await savePackage(store, s); - } + await savePackage(store, s) + } - doCreate(); + doCreate() - return s; - }); -}; + return s + }) +} const deleteScreen = store => name => { - store.update(s => { - - const components = pipe(s.components, [ - filter(c => c.name !== name) - ]); + store.update(s => { + const components = pipe(s.components, [filter(c => c.name !== name)]) - const screens = pipe(s.screens, [ - filter(c => c.name !== name) - ]); + const screens = pipe(s.screens, [filter(c => c.name !== name)]) - s.components = components; - s.screens = screens; - if (s.currentFrontEndItem.name === name) { - s.currentFrontEndItem = null; - s.currentFrontEndType = ""; - } + s.components = components + s.screens = screens + if (s.currentFrontEndItem.name === name) { + s.currentFrontEndItem = null + s.currentFrontEndType = "" + } - api.delete(`/_builder/api/${s.appname}/screen/${name}`); + api.delete(`/_builder/api/${s.appname}/screen/${name}`) - return s; - }) + return s + }) } const renameScreen = store => (oldname, newname) => { - store.update(s => { - - const { - screens, pages, error, changedScreens - } = rename(s.pages, s.screens, oldname, newname); - - if (error) { - // should really do something with this - return s; - } - - s.screens = screens; - s.pages = pages; - if (s.currentFrontEndItem.name === oldname) - s.currentFrontEndItem.name = newname; - - const saveAllChanged = async () => { - for (let screenName of changedScreens) { - const changedScreen - = getExactComponent(screens, screenName); - await api.post(`/_builder/api/${s.appname}/screen`, changedScreen); - } - } - - api.patch(`/_builder/api/${s.appname}/screen`, { - oldname, newname - }) - .then(() => saveAllChanged()) - .then(() => { - savePackage(store, s); - }); - - return s; - }) -} - -const savePage = store => async page => { - store.update(s => { - if (s.currentFrontEndType !== "page" || !s.currentPageName) { - return s; - } - - s.pages[s.currentPageName] = page; - savePackage(store, s); - return s; - }); -} - -const addComponentLibrary = store => async lib => { - - const response = - await api.get(`/_builder/api/${appname}/componentlibrary?lib=${encodeURI(lib)}`, undefined, false); + store.update(s => { + const { screens, pages, error, changedScreens } = rename( + s.pages, + s.screens, + oldname, + newname + ) + + if (error) { + // should really do something with this + return s + } - const success = response.status === 200; + s.screens = screens + s.pages = pages + if (s.currentFrontEndItem.name === oldname) + s.currentFrontEndItem.name = newname - const error = response.status === 404 - ? `Could not find library ${lib}` - : success - ? "" - : response.statusText; + const saveAllChanged = async () => { + for (let screenName of changedScreens) { + const changedScreen = getExactComponent(screens, screenName) + await api.post(`/_builder/api/${s.appname}/screen`, changedScreen) + } + } - const components = success - ? await response.json() - : []; + api + .patch(`/_builder/api/${s.appname}/screen`, { + oldname, + newname, + }) + .then(() => saveAllChanged()) + .then(() => { + savePackage(store, s) + }) - store.update(s => { - if (success) { + return s + }) +} - const componentsArray = []; - for (let c in components) { - componentsArray.push(components[c]); - } +const savePage = store => async page => { + store.update(s => { + if (s.currentFrontEndType !== "page" || !s.currentPageName) { + return s + } - s.components = pipe(s.components, [ - filter(c => !c.name.startsWith(`${lib}/`)), - concat(componentsArray) - ]); + s.pages[s.currentPageName] = page + savePackage(store, s) + return s + }) +} - s.pages.componentLibraries.push(lib); - savePackage(store, s); - } +const addComponentLibrary = store => async lib => { + const response = await api.get( + `/_builder/api/${appname}/componentlibrary?lib=${encodeURI(lib)}`, + undefined, + false + ) + + const success = response.status === 200 + + const error = + response.status === 404 + ? `Could not find library ${lib}` + : success + ? "" + : response.statusText + + const components = success ? await response.json() : [] + + store.update(s => { + if (success) { + const componentsArray = [] + for (let c in components) { + componentsArray.push(components[c]) + } + + s.components = pipe(s.components, [ + filter(c => !c.name.startsWith(`${lib}/`)), + concat(componentsArray), + ]) + + s.pages.componentLibraries.push(lib) + savePackage(store, s) + } - return s; - }) + return s + }) } const removeComponentLibrary = store => lib => { - store.update(s => { - - - s.pages.componentLibraries = filter(l => l !== lib)( - s.pages.componentLibraries); - savePackage(store, s); + store.update(s => { + s.pages.componentLibraries = filter(l => l !== lib)( + s.pages.componentLibraries + ) + savePackage(store, s) - - return s; - }) + return s + }) } const addStylesheet = store => stylesheet => { - store.update(s => { - s.pages.stylesheets.push(stylesheet); - savePackage(store, s); - return s; - }) + store.update(s => { + s.pages.stylesheets.push(stylesheet) + savePackage(store, s) + return s + }) } const removeStylesheet = store => stylesheet => { - store.update(s => { - s.pages.stylesheets = filter(s => s !== stylesheet)(s.pages.stylesheets); - savePackage(store, s); - return s; - }); + store.update(s => { + s.pages.stylesheets = filter(s => s !== stylesheet)(s.pages.stylesheets) + savePackage(store, s) + return s + }) } const refreshComponents = store => async () => { + const componentsAndGenerators = await api + .get(`/_builder/api/${db.appname}/components`) + .then(r => r.json()) - const componentsAndGenerators = - await api.get(`/_builder/api/${db.appname}/components`).then(r => r.json()); - - const components = pipe(componentsAndGenerators.components, [ - keys, - map(k => ({ ...componentsAndGenerators[k], name: k })) - ]); + const components = pipe(componentsAndGenerators.components, [ + keys, + map(k => ({ ...componentsAndGenerators[k], name: k })), + ]) - store.update(s => { - s.components = pipe(s.components, [ - filter(c => !isRootComponent(c)), - concat(components) - ]); - s.generators = componentsAndGenerators.generators; - return s; - }); -}; + store.update(s => { + s.components = pipe(s.components, [ + filter(c => !isRootComponent(c)), + concat(components), + ]) + s.generators = componentsAndGenerators.generators + return s + }) +} const savePackage = (store, s) => { - - const appDefinition = { - hierarchy: s.hierarchy, - triggers: s.triggers, - actions: keyBy("name")(s.actions), - props: { - main: buildPropsHierarchy( - s.components, - s.screens, - s.pages.main.appBody), - unauthenticated: buildPropsHierarchy( - s.components, - s.screens, - s.pages.unauthenticated.appBody) - }, - uiFunctions: buildCodeForScreens(s.screens) - }; - - const data = { - appDefinition, - accessLevels: s.accessLevels, - pages: s.pages, - } - - return api.post(`/_builder/api/${s.appname}/appPackage`, data); + const appDefinition = { + hierarchy: s.hierarchy, + triggers: s.triggers, + actions: keyBy("name")(s.actions), + props: { + main: buildPropsHierarchy(s.components, s.screens, s.pages.main.appBody), + unauthenticated: buildPropsHierarchy( + s.components, + s.screens, + s.pages.unauthenticated.appBody + ), + }, + uiFunctions: buildCodeForScreens(s.screens), + } + + const data = { + appDefinition, + accessLevels: s.accessLevels, + pages: s.pages, + } + + return api.post(`/_builder/api/${s.appname}/appPackage`, data) } const setCurrentScreen = store => screenName => { - store.update(s => { - const screen = getExactComponent(s.screens, screenName); - s.currentFrontEndItem = screen; - s.currentFrontEndType = "screen"; - s.currentComponentInfo = getScreenInfo(s.components, screen); - setCurrentScreenFunctions(s); - return s; - }) + store.update(s => { + const screen = getExactComponent(s.screens, screenName) + s.currentFrontEndItem = screen + s.currentFrontEndType = "screen" + s.currentComponentInfo = getScreenInfo(s.components, screen) + setCurrentScreenFunctions(s) + return s + }) } const setCurrentPage = store => pageName => { - store.update(s => { - s.currentFrontEndType = "page"; - s.currentPageName = pageName; - setCurrentScreenFunctions(s); - return s; - }); + store.update(s => { + s.currentFrontEndType = "page" + s.currentPageName = pageName + setCurrentScreenFunctions(s) + return s + }) } const addChildComponent = store => component => { + store.update(s => { + const newComponent = getNewComponentInfo(s.components, component) + + let children = s.currentComponentInfo.component + ? s.currentComponentInfo.component.props._children + : s.currentComponentInfo._children + + const component_definition = Object.assign( + cloneDeep(newComponent.fullProps), + { + _component: component, + _styles: { position: {}, layout: {} }, + _id: uuid(), + } + ) + + if (children) { + if (s.currentComponentInfo.component) { + s.currentComponentInfo.component.props._children = children.concat( + component_definition + ) + } else { + s.currentComponentInfo._children = children.concat(component_definition) + } + } else { + if (s.currentComponentInfo.component) { + s.currentComponentInfo.component.props._children = [ + component_definition, + ] + } else { + s.currentComponentInfo._children = [component_definition] + } + } - store.update(s => { - const newComponent = getNewComponentInfo( - s.components, component); - - let children = s.currentComponentInfo.component ? - s.currentComponentInfo.component.props._children : - s.currentComponentInfo._children; - - const component_definition = Object.assign( - cloneDeep(newComponent.fullProps), { - _component: component, - _styles: { position: {}, layout: {} }, - _id: uuid() - }) - - if (children) { - if (s.currentComponentInfo.component) { - s.currentComponentInfo.component.props._children = children.concat(component_definition); - } else { - s.currentComponentInfo._children = children.concat(component_definition) - } - } else { - if (s.currentComponentInfo.component) { - s.currentComponentInfo.component.props._children = [component_definition]; - } else { - s.currentComponentInfo._children = [component_definition] - } - } - - _saveScreen(store, s, s.currentFrontEndItem); + _saveScreen(store, s, s.currentFrontEndItem) - _saveScreen(store, s, s.currentFrontEndItem); + _saveScreen(store, s, s.currentFrontEndItem) - return s; - }) + return s + }) } const selectComponent = store => component => { - store.update(s => { - s.currentComponentInfo = component; - return s; - }) - + store.update(s => { + s.currentComponentInfo = component + return s + }) } const setComponentProp = store => (name, value) => { - store.update(s => { - const current_component = s.currentComponentInfo; - s.currentComponentInfo[name] = value; - _saveScreen(store, s, s.currentFrontEndItem); - s.currentComponentInfo = current_component; - return s; - }) + store.update(s => { + const current_component = s.currentComponentInfo + s.currentComponentInfo[name] = value + _saveScreen(store, s, s.currentFrontEndItem) + s.currentComponentInfo = current_component + return s + }) } const setComponentStyle = store => (type, name, value) => { - store.update(s => { - if (!s.currentComponentInfo._styles) { - s.currentComponentInfo._styles = {}; - } - s.currentComponentInfo._styles[type][name] = value; - s.currentFrontEndItem._css = generate_screen_css(s.currentFrontEndItem.props._children) + store.update(s => { + if (!s.currentComponentInfo._styles) { + s.currentComponentInfo._styles = {} + } + s.currentComponentInfo._styles[type][name] = value + s.currentFrontEndItem._css = generate_screen_css( + s.currentFrontEndItem.props._children + ) - // save without messing with the store - _save(s.appname, s.currentFrontEndItem, store, s) + // save without messing with the store + _save(s.appname, s.currentFrontEndItem, store, s) - return s; - }) + return s + }) } -const setComponentCode = store => (code) => { - store.update(s => { - s.currentComponentInfo._code = code; +const setComponentCode = store => code => { + store.update(s => { + s.currentComponentInfo._code = code + + setCurrentScreenFunctions(s) + // save without messing with the store + _save(s.appname, s.currentFrontEndItem, store, s) - setCurrentScreenFunctions(s); - // save without messing with the store - _save(s.appname, s.currentFrontEndItem, store, s) - - return s; - }) + return s + }) } -const setCurrentScreenFunctions = (s) => { - s.currentScreenFunctions = - s.currentFrontEndItem === "screen" - ? buildCodeForScreens([s.currentFrontEndItem]) - : "({});"; +const setCurrentScreenFunctions = s => { + s.currentScreenFunctions = + s.currentFrontEndItem === "screen" + ? buildCodeForScreens([s.currentFrontEndItem]) + : "({});" } diff --git a/packages/builder/src/builderStore/store.js.orig b/packages/builder/src/builderStore/store.js.orig deleted file mode 100644 index 9c753a180..000000000 --- a/packages/builder/src/builderStore/store.js.orig +++ /dev/null @@ -1,799 +0,0 @@ -import { - hierarchy as hierarchyFunctions, -} from "../../../core/src"; -import { - filter, cloneDeep, sortBy, - map, last, keys, concat, keyBy, - find, isEmpty, values, -} from "lodash/fp"; -import { - pipe, getNode, validate, - constructHierarchy, templateApi -} from "../common/core"; -import { writable } from "svelte/store"; -import { defaultPagesObject } from "../userInterface/pagesParsing/defaultPagesObject" -import { buildPropsHierarchy } from "../userInterface/pagesParsing/buildPropsHierarchy" -import api from "./api"; -import { isRootComponent, getExactComponent } from "../userInterface/pagesParsing/searchComponents"; -import { rename } from "../userInterface/pagesParsing/renameScreen"; -import { - getNewComponentInfo, getScreenInfo, -} from "../userInterface/pagesParsing/createProps"; -import { - loadLibs, loadLibUrls, loadGeneratorLibs -} from "./loadComponentLibraries"; -<<<<<<< HEAD -import { buildCodeForScreens } from "./buildCodeForScreens"; -======= -import { uuid } from './uuid'; -import { generate_screen_css } from './generate_css'; ->>>>>>> master - -let appname = ""; - -export const getStore = () => { - - const initial = { - apps: [], - appname: "", - hierarchy: {}, - actions: [], - triggers: [], - pages: defaultPagesObject(), - mainUi: {}, - unauthenticatedUi: {}, - components: [], - currentFrontEndItem: null, - currentComponentInfo: null, - currentFrontEndType: "none", - currentPageName: "", - currentComponentProps: null, - currentNodeIsNew: false, - errors: [], - activeNav: "database", - isBackend: true, - hasAppPackage: false, - accessLevels: { version: 0, levels: [] }, - currentNode: null, - libraries: null, - showSettings: false, - useAnalytics: true, - }; - - const store = writable(initial); - - store.initialise = initialise(store, initial); - store.newChildRecord = newRecord(store, false); - store.newRootRecord = newRecord(store, true); - store.selectExistingNode = selectExistingNode(store); - store.newChildIndex = newIndex(store, false); - store.newRootIndex = newIndex(store, true); - store.saveCurrentNode = saveCurrentNode(store); - store.importAppDefinition = importAppDefinition(store); - store.deleteCurrentNode = deleteCurrentNode(store); - store.saveField = saveField(store); - store.deleteField = deleteField(store); - store.saveAction = saveAction(store); - store.deleteAction = deleteAction(store); - store.saveTrigger = saveTrigger(store); - store.deleteTrigger = deleteTrigger(store); - store.saveLevel = saveLevel(store); - store.deleteLevel = deleteLevel(store); - store.setActiveNav = setActiveNav(store); - store.saveScreen = saveScreen(store); - store.refreshComponents = refreshComponents(store); - store.addComponentLibrary = addComponentLibrary(store); - store.renameScreen = renameScreen(store); - store.deleteScreen = deleteScreen(store); - store.setCurrentScreen = setCurrentScreen(store); - store.setCurrentPage = setCurrentPage(store); - store.createScreen = createScreen(store); - store.removeComponentLibrary = removeComponentLibrary(store); - store.addStylesheet = addStylesheet(store); - store.removeStylesheet = removeStylesheet(store); - store.savePage = savePage(store); - store.showFrontend = showFrontend(store); - store.showBackend = showBackend(store); - store.showSettings = showSettings(store); - store.useAnalytics = useAnalytics(store); - store.createGeneratedComponents = createGeneratedComponents(store); - store.addChildComponent = addChildComponent(store); - store.selectComponent = selectComponent(store); - store.setComponentProp = setComponentProp(store); - store.setComponentStyle = setComponentStyle(store); - store.setComponentCode = setComponentCode(store); - return store; -} - -export default getStore; - -const initialise = (store, initial) => async () => { - - appname = window.location.hash - ? last(window.location.hash.substr(1).split("/")) - : ""; - - if (!appname) { - initial.apps = await api.get(`/_builder/api/apps`).then(r => r.json()); - initial.hasAppPackage = false; - store.set(initial); - return initial; - } - - const pkg = await api.get(`/_builder/api/${appname}/appPackage`) - .then(r => r.json()); - - initial.libraries = await loadLibs(appname, pkg); - initial.generatorLibraries = await loadGeneratorLibs(appname, pkg); - initial.loadLibraryUrls = () => loadLibUrls(appname, pkg); - initial.appname = appname; - initial.pages = pkg.pages; - initial.hasAppPackage = true; - initial.hierarchy = pkg.appDefinition.hierarchy; - initial.accessLevels = pkg.accessLevels; - initial.screens = values(pkg.screens); - initial.generators = generatorsArray(pkg.components.generators); - initial.components = values(pkg.components.components); - initial.actions = values(pkg.appDefinition.actions); - initial.triggers = pkg.appDefinition.triggers; - - if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) { - initial.hierarchy = constructHierarchy(initial.hierarchy); - const shadowHierarchy = createShadowHierarchy(initial.hierarchy); - if (initial.currentNode !== null) - initial.currentNode = getNode( - shadowHierarchy, initial.currentNode.nodeId - ); - } - - store.set(initial); - return initial; -} - -const generatorsArray = generators => - pipe(generators, [ - keys, - filter(k => k !== "_lib"), - map(k => generators[k]) - ]); - - -const showSettings = store => show => { - store.update(s => { - s.showSettings = !s.showSettings; - return s; - }); -} - -const useAnalytics = store => useAnalytics => { - store.update(s => { - s.useAnalytics = !s.useAnalytics; - return s; - }); -} - -const showBackend = store => () => { - store.update(s => { - s.isBackend = true; - return s; - }) -} - -const showFrontend = store => () => { - store.update(s => { - s.isBackend = false; - return s; - }) -} - -const newRecord = (store, useRoot) => () => { - store.update(s => { - s.currentNodeIsNew = true; - const shadowHierarchy = createShadowHierarchy(s.hierarchy); - parent = useRoot ? shadowHierarchy - : getNode( - shadowHierarchy, - s.currentNode.nodeId); - s.errors = []; - s.currentNode = templateApi(shadowHierarchy) - .getNewRecordTemplate(parent, "", true); - return s; - }); -} - - -const selectExistingNode = (store) => (nodeId) => { - store.update(s => { - const shadowHierarchy = createShadowHierarchy(s.hierarchy); - s.currentNode = getNode( - shadowHierarchy, nodeId - ); - s.currentNodeIsNew = false; - s.errors = []; - s.activeNav = "database"; - return s; - }) -} - -const newIndex = (store, useRoot) => () => { - store.update(s => { - s.currentNodeIsNew = true; - s.errors = []; - const shadowHierarchy = createShadowHierarchy(s.hierarchy); - parent = useRoot ? shadowHierarchy - : getNode( - shadowHierarchy, - s.currentNode.nodeId); - - s.currentNode = templateApi(shadowHierarchy) - .getNewIndexTemplate(parent); - return s; - }); -} - -const saveCurrentNode = (store) => () => { - store.update(s => { - - const errors = validate.node(s.currentNode); - s.errors = errors; - if (errors.length > 0) { - return s; - } - - const parentNode = getNode( - s.hierarchy, s.currentNode.parent().nodeId); - - const existingNode = getNode( - s.hierarchy, s.currentNode.nodeId); - - let index = parentNode.children.length; - if (!!existingNode) { - // remove existing - index = existingNode.parent().children.indexOf(existingNode); - existingNode.parent().children = pipe(existingNode.parent().children, [ - filter(c => c.nodeId !== existingNode.nodeId) - ]); - } - - // should add node into existing hierarchy - const cloned = cloneDeep(s.currentNode); - templateApi(s.hierarchy).constructNode( - parentNode, - cloned - ); - - const newIndexOfchild = child => { - if (child === cloned) return index; - const currentIndex = parentNode.children.indexOf(child); - return currentIndex >= index ? currentIndex + 1 : currentIndex; - } - - parentNode.children = pipe(parentNode.children, [ - sortBy(newIndexOfchild) - ]); - - if (!existingNode && s.currentNode.type === "record") { - const defaultIndex = templateApi(s.hierarchy) - .getNewIndexTemplate(cloned.parent()); - defaultIndex.name = `all_${cloned.collectionName}`; - defaultIndex.allowedRecordNodeIds = [cloned.nodeId]; - } - - s.currentNodeIsNew = false; - - savePackage(store, s); - - return s; - }); -} - -const importAppDefinition = store => appDefinition => { - store.update(s => { - s.hierarchy = appDefinition.hierarchy; - s.currentNode = appDefinition.hierarchy.children.length > 0 - ? appDefinition.hierarchy.children[0] - : null; - s.actions = appDefinition.actions; - s.triggers = appDefinition.triggers; - s.currentNodeIsNew = false; - return s; - }); -} - -const deleteCurrentNode = store => () => { - store.update(s => { - const nodeToDelete = getNode(s.hierarchy, s.currentNode.nodeId); - s.currentNode = hierarchyFunctions.isRoot(nodeToDelete.parent()) - ? find(n => n != s.currentNode) - (s.hierarchy.children) - : nodeToDelete.parent(); - if (hierarchyFunctions.isRecord(nodeToDelete)) { - nodeToDelete.parent().children = filter(c => c.nodeId !== nodeToDelete.nodeId) - (nodeToDelete.parent().children); - } else { - nodeToDelete.parent().indexes = filter(c => c.nodeId !== nodeToDelete.nodeId) - (nodeToDelete.parent().indexes); - } - s.errors = []; - savePackage(store, s); - return s; - }); -} - -const saveField = databaseStore => (field) => { - databaseStore.update(db => { - db.currentNode.fields = filter(f => f.name !== field.name) - (db.currentNode.fields); - - templateApi(db.hierarchy).addField(db.currentNode, field); - return db; - }); -} - - -const deleteField = databaseStore => field => { - databaseStore.update(db => { - db.currentNode.fields = filter(f => f.name !== field.name) - (db.currentNode.fields); - - return db; - }); -} - - -const saveAction = store => (newAction, isNew, oldAction = null) => { - store.update(s => { - - const existingAction = isNew - ? null - : find(a => a.name === oldAction.name)(s.actions); - - if (existingAction) { - s.actions = pipe(s.actions, [ - map(a => a === existingAction ? newAction : a) - ]); - } else { - s.actions.push(newAction); - } - savePackage(store, s); - return s; - }); -} - -const deleteAction = store => action => { - store.update(s => { - s.actions = filter(a => a.name !== action.name)(s.actions); - savePackage(store, s); - return s; - }); -} - -const saveTrigger = store => (newTrigger, isNew, oldTrigger = null) => { - store.update(s => { - - const existingTrigger = isNew - ? null - : find(a => a.name === oldTrigger.name)(s.triggers); - - if (existingTrigger) { - s.triggers = pipe(s.triggers, [ - map(a => a === existingTrigger ? newTrigger : a) - ]); - } else { - s.triggers.push(newTrigger); - } - savePackage(store, s); - return s; - }); -} - -const deleteTrigger = store => trigger => { - store.update(s => { - s.triggers = filter(t => t.name !== trigger.name)(s.triggers); - return s; - }); -} - -const incrementAccessLevelsVersion = (s) => - s.accessLevels.version = (s.accessLevels.version || 0) + 1; - -const saveLevel = store => (newLevel, isNew, oldLevel = null) => { - store.update(s => { - - const levels = s.accessLevels.levels; - - const existingLevel = isNew - ? null - : find(a => a.name === oldLevel.name)(levels); - - if (existingLevel) { - s.accessLevels.levels = pipe(levels, [ - map(a => a === existingLevel ? newLevel : a) - ]); - } else { - s.accessLevels.levels.push(newLevel); - } - - incrementAccessLevelsVersion(s); - - savePackage(store, s); - return s; - }); -} - -const deleteLevel = store => level => { - store.update(s => { - s.accessLevels.levels = filter(t => t.name !== level.name)(s.accessLevels.levels); - incrementAccessLevelsVersion(s); - savePackage(store, s); - return s; - }); -} - -const setActiveNav = store => navName => { - store.update(s => { - s.activeNav = navName; - return s; - }); -} - -const createShadowHierarchy = hierarchy => - constructHierarchy(JSON.parse(JSON.stringify(hierarchy))); - -const saveScreen = store => (screen) => { - store.update(s => { - return _saveScreen(store, s, screen); - }) -}; - -const _saveScreen = (store, s, screen) => { - const screens = pipe(s.screens, [ - filter(c => c.name !== screen.name), - concat([screen]) - ]); - - s.screens = screens; - s.currentFrontEndItem = screen; - s.currentComponentInfo = getScreenInfo( - s.components, screen); - - api.post(`/_builder/api/${s.appname}/screen`, screen) - .then(() => savePackage(store, s)); - - return s; -} - -const _save = (appname, screen, store, s) => - api.post(`/_builder/api/${appname}/screen`, screen) - .then(() => savePackage(store, s)); - -const createScreen = store => (screenName, layoutComponentName) => { - store.update(s => { - const newComponentInfo = getNewComponentInfo( - s.components, layoutComponentName, screenName); - - s.currentFrontEndItem = newComponentInfo.component; - s.currentComponentInfo = newComponentInfo; - s.currentFrontEndType = "screen"; - - return _saveScreen(store, s, newComponentInfo.component); - }); -}; - -const createGeneratedComponents = store => components => { - store.update(s => { - s.components = [...s.components, ...components]; - s.screens = [...s.screens, ...components]; - - const doCreate = async () => { - for (let c of components) { - await api.post(`/_builder/api/${s.appname}/screen`, c); - } - - await savePackage(store, s); - } - - doCreate(); - - return s; - }); -}; - -const deleteScreen = store => name => { - store.update(s => { - - const components = pipe(s.components, [ - filter(c => c.name !== name) - ]); - - const screens = pipe(s.screens, [ - filter(c => c.name !== name) - ]); - - s.components = components; - s.screens = screens; - if (s.currentFrontEndItem.name === name) { - s.currentFrontEndItem = null; - s.currentFrontEndType = ""; - } - - api.delete(`/_builder/api/${s.appname}/screen/${name}`); - - return s; - }) -} - -const renameScreen = store => (oldname, newname) => { - store.update(s => { - - const { - screens, pages, error, changedScreens - } = rename(s.pages, s.screens, oldname, newname); - - if (error) { - // should really do something with this - return s; - } - - s.screens = screens; - s.pages = pages; - if (s.currentFrontEndItem.name === oldname) - s.currentFrontEndItem.name = newname; - - const saveAllChanged = async () => { - for (let screenName of changedScreens) { - const changedScreen - = getExactComponent(screens, screenName); - await api.post(`/_builder/api/${s.appname}/screen`, changedScreen); - } - } - - api.patch(`/_builder/api/${s.appname}/screen`, { - oldname, newname - }) - .then(() => saveAllChanged()) - .then(() => { - savePackage(store, s); - }); - - return s; - }) -} - -const savePage = store => async page => { - store.update(s => { - if (s.currentFrontEndType !== "page" || !s.currentPageName) { - return s; - } - - s.pages[s.currentPageName] = page; - savePackage(store, s); - return s; - }); -} - -const addComponentLibrary = store => async lib => { - - const response = - await api.get(`/_builder/api/${appname}/componentlibrary?lib=${encodeURI(lib)}`, undefined, false); - - const success = response.status === 200; - - const error = response.status === 404 - ? `Could not find library ${lib}` - : success - ? "" - : response.statusText; - - const components = success - ? await response.json() - : []; - - store.update(s => { - if (success) { - - const componentsArray = []; - for (let c in components) { - componentsArray.push(components[c]); - } - - s.components = pipe(s.components, [ - filter(c => !c.name.startsWith(`${lib}/`)), - concat(componentsArray) - ]); - - s.pages.componentLibraries.push(lib); - savePackage(store, s); - } - - return s; - }) -} - -const removeComponentLibrary = store => lib => { - store.update(s => { - - - s.pages.componentLibraries = filter(l => l !== lib)( - s.pages.componentLibraries); - savePackage(store, s); - - - return s; - }) -} - -const addStylesheet = store => stylesheet => { - store.update(s => { - s.pages.stylesheets.push(stylesheet); - savePackage(store, s); - return s; - }) -} - -const removeStylesheet = store => stylesheet => { - store.update(s => { - s.pages.stylesheets = filter(s => s !== stylesheet)(s.pages.stylesheets); - savePackage(store, s); - return s; - }); -} - -const refreshComponents = store => async () => { - - const componentsAndGenerators = - await api.get(`/_builder/api/${db.appname}/components`).then(r => r.json()); - - const components = pipe(componentsAndGenerators.components, [ - keys, - map(k => ({ ...componentsAndGenerators[k], name: k })) - ]); - - store.update(s => { - s.components = pipe(s.components, [ - filter(c => !isRootComponent(c)), - concat(components) - ]); - s.generators = componentsAndGenerators.generators; - return s; - }); -}; - -const savePackage = (store, s) => { - - const appDefinition = { - hierarchy: s.hierarchy, - triggers: s.triggers, - actions: keyBy("name")(s.actions), - props: { - main: buildPropsHierarchy( - s.components, - s.screens, - s.pages.main.appBody), - unauthenticated: buildPropsHierarchy( - s.components, - s.screens, - s.pages.unauthenticated.appBody) - }, - uiFunctions: buildCodeForScreens(s.screens) - }; - - const data = { - appDefinition, - accessLevels: s.accessLevels, - pages: s.pages, - } - - return api.post(`/_builder/api/${s.appname}/appPackage`, data); -} - -const setCurrentScreen = store => screenName => { - store.update(s => { - const screen = getExactComponent(s.screens, screenName); - s.currentFrontEndItem = screen; - s.currentFrontEndType = "screen"; - s.currentComponentInfo = getScreenInfo(s.components, screen); - setCurrentScreenFunctions(s); - return s; - }) -} - -const setCurrentPage = store => pageName => { - store.update(s => { - s.currentFrontEndType = "page"; - s.currentPageName = pageName; - setCurrentScreenFunctions(s); - return s; - }); -} - -const addChildComponent = store => component => { - - store.update(s => { - const newComponent = getNewComponentInfo( - s.components, component); - - let children = s.currentComponentInfo.component ? - s.currentComponentInfo.component.props._children : - s.currentComponentInfo._children; - - const component_definition = Object.assign( - cloneDeep(newComponent.fullProps), { - _component: component, - _styles: { position: {}, layout: {} }, - _id: uuid() - }) - - if (children) { - if (s.currentComponentInfo.component) { - s.currentComponentInfo.component.props._children = children.concat(component_definition); - } else { - s.currentComponentInfo._children = children.concat(component_definition) - } - } else { - if (s.currentComponentInfo.component) { - s.currentComponentInfo.component.props._children = [component_definition]; - } else { - s.currentComponentInfo._children = [component_definition] - } - } - - _saveScreen(store, s, s.currentFrontEndItem); - - _saveScreen(store, s, s.currentFrontEndItem); - - return s; - }) -} - -const selectComponent = store => component => { - store.update(s => { - s.currentComponentInfo = component; - return s; - }) - -} - -const setComponentProp = store => (name, value) => { - store.update(s => { - const current_component = s.currentComponentInfo; - s.currentComponentInfo[name] = value; - _saveScreen(store, s, s.currentFrontEndItem); - s.currentComponentInfo = current_component; - return s; - }) -} - -const setComponentStyle = store => (type, name, value) => { - store.update(s => { - if (!s.currentComponentInfo._styles) { - s.currentComponentInfo._styles = {}; - } - s.currentComponentInfo._styles[type][name] = value; - s.currentFrontEndItem._css = generate_screen_css(s.currentFrontEndItem.props._children) - - // save without messing with the store - _save(s.appname, s.currentFrontEndItem, store, s) - - return s; - }) -} - -const setComponentCode = store => (code) => { - store.update(s => { - s.currentComponentInfo._code = code; - - setCurrentScreenFunctions(s); - // save without messing with the store - _save(s.appname, s.currentFrontEndItem, store, s) - - return s; - }) -} - -const setCurrentScreenFunctions = (s) => { - s.currentScreenFunctions = - s.currentFrontEndItem === "screen" - ? buildCodeForScreens([s.currentFrontEndItem]) - : "({});"; -} diff --git a/packages/builder/src/builderStore/uuid.js b/packages/builder/src/builderStore/uuid.js index 79ad68af9..5a1893b56 100644 --- a/packages/builder/src/builderStore/uuid.js +++ b/packages/builder/src/builderStore/uuid.js @@ -1,7 +1,7 @@ export function uuid() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { - const r = (Math.random() * 16) | 0, - v = c == 'x' ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { + const r = (Math.random() * 16) | 0, + v = c == "x" ? r : (r & 0x3) | 0x8 + return v.toString(16) + }) } diff --git a/packages/builder/src/common/ActionButton.svelte b/packages/builder/src/common/ActionButton.svelte index fca74c09f..46278e8b6 100644 --- a/packages/builder/src/common/ActionButton.svelte +++ b/packages/builder/src/common/ActionButton.svelte @@ -1,11 +1,22 @@ + + - - diff --git a/packages/builder/src/common/Button.svelte b/packages/builder/src/common/Button.svelte index fd54140ba..5b8f2fb59 100644 --- a/packages/builder/src/common/Button.svelte +++ b/packages/builder/src/common/Button.svelte @@ -1,163 +1,167 @@ - \ No newline at end of file + } + diff --git a/packages/builder/src/common/ButtonGroup.svelte b/packages/builder/src/common/ButtonGroup.svelte index e0842f08d..699695bcf 100644 --- a/packages/builder/src/common/ButtonGroup.svelte +++ b/packages/builder/src/common/ButtonGroup.svelte @@ -1,27 +1,25 @@ -
- +
+
\ No newline at end of file + } + diff --git a/packages/builder/src/common/Checkbox.svelte b/packages/builder/src/common/Checkbox.svelte index c1cea90df..9f777ca70 100644 --- a/packages/builder/src/common/Checkbox.svelte +++ b/packages/builder/src/common/Checkbox.svelte @@ -1,16 +1,13 @@ -{label} + +{label} \ No newline at end of file + input { + margin-right: 7px; + } + diff --git a/packages/builder/src/common/CodeArea.svelte b/packages/builder/src/common/CodeArea.svelte index af60b9b34..47f563b04 100644 --- a/packages/builder/src/common/CodeArea.svelte +++ b/packages/builder/src/common/CodeArea.svelte @@ -1,24 +1,22 @@
{label}
- + -
+ +
+ -
-
- {"}"} -
+

+ Use the code box below to control how this component is displayed, with + javascript. +

+ +
+
+ function(render, context, store) {'{'} +
+
+