@sankhyalabs/sankhyablocks 1.1.25 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +75 -75
- package/package.json +94 -49
- package/react/.keepfolder +1 -0
- package/dist/cjs/ApplicationUtils-05b74ee9.js +0 -39
- package/dist/cjs/AssetsUtils-7e3c38f9.js +0 -24
- package/dist/cjs/CSSVarsUtils-75ca9c64.js +0 -19
- package/dist/cjs/ez-action-chip.cjs.entry.js +0 -27
- package/dist/cjs/ez-application.cjs.entry.js +0 -26
- package/dist/cjs/ez-button_4.cjs.entry.js +0 -660
- package/dist/cjs/ez-calendar.cjs.entry.js +0 -223
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +0 -47
- package/dist/cjs/ez-combo-box.cjs.entry.js +0 -278
- package/dist/cjs/ez-date-input.cjs.entry.js +0 -102
- package/dist/cjs/ez-date-time-input.cjs.entry.js +0 -145
- package/dist/cjs/ez-dialog.cjs.entry.js +0 -89
- package/dist/cjs/ez-form.cjs.entry.js +0 -463
- package/dist/cjs/ez-grid.cjs.entry.js +0 -647
- package/dist/cjs/ez-icon.cjs.entry.js +0 -41
- package/dist/cjs/ez-label-chip.cjs.entry.js +0 -104
- package/dist/cjs/ez-modal_2.cjs.entry.js +0 -316
- package/dist/cjs/ez-number-input.cjs.entry.js +0 -86
- package/dist/cjs/ez-popover.cjs.entry.js +0 -120
- package/dist/cjs/ez-popup.cjs.entry.js +0 -48
- package/dist/cjs/ez-search.cjs.entry.js +0 -64
- package/dist/cjs/ez-tabselector.cjs.entry.js +0 -198
- package/dist/cjs/ez-text-area.cjs.entry.js +0 -114
- package/dist/cjs/ez-text-input.cjs.entry.js +0 -201
- package/dist/cjs/ez-time-input.cjs.entry.js +0 -118
- package/dist/cjs/ez-toast.cjs.entry.js +0 -44
- package/dist/cjs/ez-upload.cjs.entry.js +0 -356
- package/dist/cjs/index-682c98b2.js +0 -1771
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/cjs/sankhyablocks.cjs.js +0 -19
- package/dist/cjs/snk-application.cjs.entry.js +0 -7065
- package/dist/cjs/test-du.cjs.entry.js +0 -76
- package/dist/collection/collection-manifest.json +0 -47
- package/dist/collection/components/snk-application/snk-application.css +0 -5
- package/dist/collection/components/snk-application/snk-application.js +0 -495
- package/dist/collection/index.js +0 -1
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +0 -158
- package/dist/collection/lib/http/data-fetcher/fetchers/application-config-fetcher.js +0 -23
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +0 -188
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +0 -25
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +0 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +0 -59
- package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +0 -30
- package/dist/collection/lib/http/data-fetcher/state/LoadStateManager.js +0 -66
- package/dist/collection/lib/utils/pesquisa.js +0 -16
- package/dist/collection/lib/utils/urlutils.js +0 -23
- package/dist/collection/lib/workspace/workspace.js +0 -7
- package/dist/components/ApplicationUtils.js +0 -37
- package/dist/components/AssetsUtils.js +0 -22
- package/dist/components/CSSVarsUtils.js +0 -17
- package/dist/components/ez-action-chip.js +0 -44
- package/dist/components/ez-application.js +0 -39
- package/dist/components/ez-button.js +0 -6
- package/dist/components/ez-button2.js +0 -105
- package/dist/components/ez-calendar.js +0 -6
- package/dist/components/ez-calendar2.js +0 -242
- package/dist/components/ez-check.js +0 -6
- package/dist/components/ez-check2.js +0 -94
- package/dist/components/ez-collapsible-box.js +0 -67
- package/dist/components/ez-combo-box.js +0 -6
- package/dist/components/ez-combo-box2.js +0 -311
- package/dist/components/ez-date-input.js +0 -135
- package/dist/components/ez-date-time-input.js +0 -179
- package/dist/components/ez-dialog.js +0 -124
- package/dist/components/ez-form.js +0 -6
- package/dist/components/ez-form2.js +0 -485
- package/dist/components/ez-grid.js +0 -738
- package/dist/components/ez-icon.js +0 -6
- package/dist/components/ez-icon2.js +0 -56
- package/dist/components/ez-label-chip.js +0 -125
- package/dist/components/ez-list.js +0 -6
- package/dist/components/ez-list2.js +0 -523
- package/dist/components/ez-modal.js +0 -6
- package/dist/components/ez-modal2.js +0 -82
- package/dist/components/ez-number-input.js +0 -115
- package/dist/components/ez-popover.js +0 -145
- package/dist/components/ez-popup.js +0 -67
- package/dist/components/ez-search.js +0 -100
- package/dist/components/ez-tabselector.js +0 -6
- package/dist/components/ez-tabselector2.js +0 -213
- package/dist/components/ez-text-area.js +0 -137
- package/dist/components/ez-text-input.js +0 -6
- package/dist/components/ez-text-input2.js +0 -223
- package/dist/components/ez-time-input.js +0 -153
- package/dist/components/ez-toast.js +0 -64
- package/dist/components/ez-upload.js +0 -382
- package/dist/components/grid-config.js +0 -6
- package/dist/components/grid-config2.js +0 -318
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/components/select-box.js +0 -6
- package/dist/components/select-box2.js +0 -47
- package/dist/components/snk-application.d.ts +0 -11
- package/dist/components/snk-application.js +0 -7094
- package/dist/components/test-du.js +0 -101
- package/dist/esm/ApplicationUtils-e0b6d857.js +0 -37
- package/dist/esm/AssetsUtils-6e6624dc.js +0 -22
- package/dist/esm/CSSVarsUtils-0787c3f3.js +0 -17
- package/dist/esm/ez-action-chip.entry.js +0 -23
- package/dist/esm/ez-application.entry.js +0 -22
- package/dist/esm/ez-button_4.entry.js +0 -653
- package/dist/esm/ez-calendar.entry.js +0 -219
- package/dist/esm/ez-collapsible-box.entry.js +0 -43
- package/dist/esm/ez-combo-box.entry.js +0 -274
- package/dist/esm/ez-date-input.entry.js +0 -98
- package/dist/esm/ez-date-time-input.entry.js +0 -141
- package/dist/esm/ez-dialog.entry.js +0 -85
- package/dist/esm/ez-form.entry.js +0 -459
- package/dist/esm/ez-grid.entry.js +0 -643
- package/dist/esm/ez-icon.entry.js +0 -37
- package/dist/esm/ez-label-chip.entry.js +0 -100
- package/dist/esm/ez-modal_2.entry.js +0 -311
- package/dist/esm/ez-number-input.entry.js +0 -82
- package/dist/esm/ez-popover.entry.js +0 -116
- package/dist/esm/ez-popup.entry.js +0 -44
- package/dist/esm/ez-search.entry.js +0 -60
- package/dist/esm/ez-tabselector.entry.js +0 -194
- package/dist/esm/ez-text-area.entry.js +0 -110
- package/dist/esm/ez-text-input.entry.js +0 -197
- package/dist/esm/ez-time-input.entry.js +0 -114
- package/dist/esm/ez-toast.entry.js +0 -40
- package/dist/esm/ez-upload.entry.js +0 -352
- package/dist/esm/index-35088a3f.js +0 -1740
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +0 -17
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/sankhyablocks.js +0 -17
- package/dist/esm/snk-application.entry.js +0 -7061
- package/dist/esm/test-du.entry.js +0 -72
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +0 -67
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +0 -3
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +0 -180
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +0 -319
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +0 -327
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +0 -162
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +0 -217
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +0 -49
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +0 -44
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +0 -527
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +0 -5
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +0 -31
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +0 -129
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +0 -10
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +0 -176
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +0 -139
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +0 -335
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +0 -358
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +0 -4
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +0 -44
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +0 -405
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +0 -3
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +0 -138
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +0 -165
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +0 -196
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +0 -10
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +0 -127
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +0 -568
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +0 -3
- package/dist/sankhyablocks/index.esm.js +0 -0
- package/dist/sankhyablocks/p-0183d259.entry.js +0 -1
- package/dist/sankhyablocks/p-01f23a70.entry.js +0 -1
- package/dist/sankhyablocks/p-07c32f68.entry.js +0 -1
- package/dist/sankhyablocks/p-0f90499d.entry.js +0 -1
- package/dist/sankhyablocks/p-105724a3.entry.js +0 -1
- package/dist/sankhyablocks/p-2ac02d48.entry.js +0 -1
- package/dist/sankhyablocks/p-35364a97.entry.js +0 -1
- package/dist/sankhyablocks/p-3f6aa9a7.entry.js +0 -1
- package/dist/sankhyablocks/p-5f9af495.entry.js +0 -1
- package/dist/sankhyablocks/p-60967cf0.js +0 -1
- package/dist/sankhyablocks/p-6ce33b60.entry.js +0 -57
- package/dist/sankhyablocks/p-70ad6c16.entry.js +0 -1
- package/dist/sankhyablocks/p-710bfffe.entry.js +0 -1
- package/dist/sankhyablocks/p-735440c1.entry.js +0 -1
- package/dist/sankhyablocks/p-811b4b9d.js +0 -1
- package/dist/sankhyablocks/p-813fe4f7.js +0 -1
- package/dist/sankhyablocks/p-85a9446b.js +0 -2
- package/dist/sankhyablocks/p-89a1100f.entry.js +0 -1
- package/dist/sankhyablocks/p-8b543003.entry.js +0 -1
- package/dist/sankhyablocks/p-9750632b.entry.js +0 -1
- package/dist/sankhyablocks/p-a96272f7.entry.js +0 -1
- package/dist/sankhyablocks/p-ac8842e5.entry.js +0 -1
- package/dist/sankhyablocks/p-ba64cc41.entry.js +0 -1
- package/dist/sankhyablocks/p-c1ede043.entry.js +0 -1
- package/dist/sankhyablocks/p-d90ebb85.entry.js +0 -1
- package/dist/sankhyablocks/p-e17dfaae.entry.js +0 -1
- package/dist/sankhyablocks/p-e5355a29.entry.js +0 -1
- package/dist/sankhyablocks/p-ef04b633.entry.js +0 -1
- package/dist/sankhyablocks/p-f6db07fb.entry.js +0 -1
- package/dist/sankhyablocks/p-fcd9bd92.entry.js +0 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +0 -1
- package/dist/types/components/snk-application/snk-application.d.ts +0 -44
- package/dist/types/components.d.ts +0 -66
- package/dist/types/index.d.ts +0 -1
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +0 -15
- package/dist/types/lib/http/data-fetcher/fetchers/application-config-fetcher.d.ts +0 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +0 -12
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +0 -5
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +0 -2
- package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +0 -13
- package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +0 -6
- package/dist/types/lib/http/data-fetcher/state/LoadStateManager.d.ts +0 -23
- package/dist/types/lib/utils/pesquisa.d.ts +0 -2
- package/dist/types/lib/utils/urlutils.d.ts +0 -4
- package/dist/types/lib/workspace/workspace.d.ts +0 -4
- package/dist/types/stencil-public-runtime.d.ts +0 -1565
- package/loader/cdn.js +0 -3
- package/loader/index.cjs.js +0 -3
- package/loader/index.d.ts +0 -12
- package/loader/index.es2017.js +0 -3
- package/loader/index.js +0 -4
- package/loader/package.json +0 -10
- package/react/components.d.ts +0 -32
- package/react/components.js +0 -35
- package/react/components.js.map +0 -1
- package/react/react-component-lib/createComponent.d.ts +0 -10
- package/react/react-component-lib/createComponent.js +0 -75
- package/react/react-component-lib/createComponent.js.map +0 -1
- package/react/react-component-lib/createOverlayComponent.d.ts +0 -21
- package/react/react-component-lib/createOverlayComponent.js +0 -109
- package/react/react-component-lib/createOverlayComponent.js.map +0 -1
- package/react/react-component-lib/index.d.ts +0 -2
- package/react/react-component-lib/index.js +0 -3
- package/react/react-component-lib/index.js.map +0 -1
- package/react/react-component-lib/interfaces.d.ts +0 -29
- package/react/react-component-lib/interfaces.js +0 -1
- package/react/react-component-lib/interfaces.js.map +0 -1
- package/react/react-component-lib/utils/attachProps.d.ts +0 -12
- package/react/react-component-lib/utils/attachProps.js +0 -98
- package/react/react-component-lib/utils/attachProps.js.map +0 -1
- package/react/react-component-lib/utils/case.d.ts +0 -2
- package/react/react-component-lib/utils/case.js +0 -7
- package/react/react-component-lib/utils/case.js.map +0 -1
- package/react/react-component-lib/utils/dev.d.ts +0 -2
- package/react/react-component-lib/utils/dev.js +0 -13
- package/react/react-component-lib/utils/dev.js.map +0 -1
- package/react/react-component-lib/utils/index.d.ts +0 -10
- package/react/react-component-lib/utils/index.js +0 -34
- package/react/react-component-lib/utils/index.js.map +0 -1
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
import { h, r as registerInstance, f as forceUpdate, H as Host, g as getElement } from './index-35088a3f.js';
|
|
2
|
-
import { UserInterface, ApplicationContext, Action, DataUnitAction, DataUnit } from '@sankhyalabs/core';
|
|
3
|
-
import { createStore } from 'redux';
|
|
4
|
-
import { A as ApplicationUtils } from './ApplicationUtils-e0b6d857.js';
|
|
5
|
-
|
|
6
|
-
const buildTextArea = ({ name, label, readOnly }) => {
|
|
7
|
-
return (h("div", { class: "col col--sd-12 padding-horizontal--small", key: name },
|
|
8
|
-
h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const buildTextInput = ({ name, label }) => {
|
|
12
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
13
|
-
h("ez-text-input", { label: label, "data-field-name": name, key: name })));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const buildSwitch = (fieldConfig) => {
|
|
17
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
18
|
-
};
|
|
19
|
-
const buildCheckBox = (fieldConfig) => {
|
|
20
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
21
|
-
};
|
|
22
|
-
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
23
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 align--middle padding-horizontal--small padding-bottom--large" },
|
|
24
|
-
h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? "switch" : "regular", "data-field-name": fieldName, key: fieldName })));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const buildComboBox = ({ name, label, readOnly }, properties) => {
|
|
28
|
-
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
29
|
-
let options;
|
|
30
|
-
if (typeof prop === "string") {
|
|
31
|
-
const parsed = JSON.parse(prop);
|
|
32
|
-
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
options = prop;
|
|
36
|
-
}
|
|
37
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
38
|
-
h("ez-combo-box", { enabled: !readOnly, label: label, "data-field-name": name, key: name, options: options })));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const buildSearch = ({ name, label, readOnly }) => {
|
|
42
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
43
|
-
h("ez-search", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const buildFile = ({ name, label, readOnly }) => {
|
|
47
|
-
return (h("div", { class: "col col--sd-12 padding-horizontal--small" },
|
|
48
|
-
h("ez-upload", { enabled: !readOnly, label: label, urlUpload: "", requestHeaders: "", maxFiles: 10, "data-field-name": name, key: name })));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const buildDate = ({ name, label, readOnly }) => {
|
|
52
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
53
|
-
h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
54
|
-
};
|
|
55
|
-
const buildTime = ({ name, label }) => {
|
|
56
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
57
|
-
h("ez-time-input", { label: label, "data-field-name": name, key: name })));
|
|
58
|
-
};
|
|
59
|
-
const buildTimeDate = ({ name, label }) => {
|
|
60
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
61
|
-
h("ez-date-time-input", { label: label, "data-field-name": name, key: name })));
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
65
|
-
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
66
|
-
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
67
|
-
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
68
|
-
};
|
|
69
|
-
const buildInteger = ({ name, label, readOnly }) => {
|
|
70
|
-
return buildNumeric(name, label, readOnly, 0, 0);
|
|
71
|
-
};
|
|
72
|
-
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
73
|
-
return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
|
|
74
|
-
h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const uiBuilders = new Map();
|
|
78
|
-
uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
|
|
79
|
-
uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
|
|
80
|
-
uiBuilders.set(UserInterface.SWITCH, buildSwitch);
|
|
81
|
-
uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
82
|
-
uiBuilders.set(UserInterface.SEARCH, buildSearch);
|
|
83
|
-
uiBuilders.set(UserInterface.FILE, buildFile);
|
|
84
|
-
uiBuilders.set(UserInterface.DATE, buildDate);
|
|
85
|
-
uiBuilders.set(UserInterface.TIME, buildTime);
|
|
86
|
-
uiBuilders.set(UserInterface.DATETIME, buildTimeDate);
|
|
87
|
-
uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
|
|
88
|
-
uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
|
|
89
|
-
const buildField = (field) => {
|
|
90
|
-
const descriptor = field.descriptor;
|
|
91
|
-
const config = Object.assign({}, field.config);
|
|
92
|
-
let builder;
|
|
93
|
-
let props;
|
|
94
|
-
if (descriptor) {
|
|
95
|
-
if (!config.label) {
|
|
96
|
-
config.label = descriptor.label;
|
|
97
|
-
}
|
|
98
|
-
if (!config.name) {
|
|
99
|
-
config.name = descriptor.name;
|
|
100
|
-
}
|
|
101
|
-
if (config.required === undefined) {
|
|
102
|
-
config.required = descriptor.required;
|
|
103
|
-
}
|
|
104
|
-
if (config.readOnly === undefined) {
|
|
105
|
-
config.readOnly = descriptor.readOnly;
|
|
106
|
-
}
|
|
107
|
-
props = descriptor.properties;
|
|
108
|
-
builder = uiBuilders.get(descriptor.userInterface);
|
|
109
|
-
}
|
|
110
|
-
if (config.required) {
|
|
111
|
-
config.label = `* ${config.label} (obrigatório)`;
|
|
112
|
-
}
|
|
113
|
-
if (!builder) {
|
|
114
|
-
builder = buildTextInput;
|
|
115
|
-
}
|
|
116
|
-
return builder(config, props);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const FormItem = ({ source }) => {
|
|
120
|
-
if ("items" in source) {
|
|
121
|
-
const fieldSet = source;
|
|
122
|
-
return h("ez-collapsible-box", { label: source.label }, fieldSet.items.map(fi => buildField(fi)));
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
return buildField(source);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const FormSheet = ({ store, source }) => {
|
|
130
|
-
return (h("div", { class: "box__container" },
|
|
131
|
-
h("div", { class: "row padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
class FormMetadata {
|
|
135
|
-
constructor() {
|
|
136
|
-
this._sheets = new Map();
|
|
137
|
-
this._requiredFields = [];
|
|
138
|
-
this._cleanOnCopyFields = [];
|
|
139
|
-
}
|
|
140
|
-
getSheet(name) {
|
|
141
|
-
return this._sheets.get(name);
|
|
142
|
-
}
|
|
143
|
-
getAllSheets() {
|
|
144
|
-
return this._sheets;
|
|
145
|
-
}
|
|
146
|
-
addSheet(sheet) {
|
|
147
|
-
this._sheets.set(sheet.name, sheet);
|
|
148
|
-
this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
|
|
149
|
-
this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
|
|
150
|
-
}
|
|
151
|
-
getRequiredFields() {
|
|
152
|
-
return this._requiredFields;
|
|
153
|
-
}
|
|
154
|
-
getCleanOnCopyFields() {
|
|
155
|
-
return this._cleanOnCopyFields;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const buildFromDataUnit = (dataUnit) => {
|
|
159
|
-
var _a;
|
|
160
|
-
const unitMD = dataUnit.metadata;
|
|
161
|
-
const metadata = new FormMetadata();
|
|
162
|
-
if (unitMD) {
|
|
163
|
-
const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
|
|
164
|
-
metadata.addSheet({
|
|
165
|
-
label: unitMD.label,
|
|
166
|
-
name: unitMD.name,
|
|
167
|
-
items: visibleFields.map(descriptor => { return { descriptor }; }),
|
|
168
|
-
requiredFields: visibleFields
|
|
169
|
-
.filter(descriptor => descriptor.required)
|
|
170
|
-
.map(descriptor => descriptor.name),
|
|
171
|
-
cleanOnCopyFields: visibleFields
|
|
172
|
-
.filter(descriptor => { var _a; return (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; })
|
|
173
|
-
.map(descriptor => descriptor.name)
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
return metadata;
|
|
177
|
-
};
|
|
178
|
-
function getTabConfig(tab, sheets) {
|
|
179
|
-
const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
|
|
180
|
-
return tabConfig || { label: tab, visible: true };
|
|
181
|
-
}
|
|
182
|
-
const buildFromConfig = (fields, dataUnit) => {
|
|
183
|
-
const sheets = new Map();
|
|
184
|
-
const requiredFields = [];
|
|
185
|
-
const cleanOnCopyFields = [];
|
|
186
|
-
fields.forEach(config => {
|
|
187
|
-
var _a;
|
|
188
|
-
if (config.visible !== false) {
|
|
189
|
-
const tabConfig = getTabConfig(config.tab || "Geral", sheets);
|
|
190
|
-
const descriptor = dataUnit.getField(config.name);
|
|
191
|
-
if (descriptor && tabConfig.visible) {
|
|
192
|
-
if (!sheets.has(tabConfig)) {
|
|
193
|
-
sheets.set(tabConfig, new Map());
|
|
194
|
-
}
|
|
195
|
-
const tabItens = sheets.get(tabConfig);
|
|
196
|
-
const isRequired = config.required === undefined ? descriptor.required : config.required;
|
|
197
|
-
if (isRequired) {
|
|
198
|
-
requiredFields.push(config.name);
|
|
199
|
-
}
|
|
200
|
-
const clearOnCopy = config.cleanOnCopy === undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : config.cleanOnCopy;
|
|
201
|
-
if (clearOnCopy) {
|
|
202
|
-
cleanOnCopyFields.push(config.name);
|
|
203
|
-
}
|
|
204
|
-
const fieldMD = { config, descriptor };
|
|
205
|
-
const group = config.group;
|
|
206
|
-
if (group) {
|
|
207
|
-
const key = `group::${group}`;
|
|
208
|
-
if (!tabItens.has(key)) {
|
|
209
|
-
tabItens.set(key, { label: group, items: [fieldMD] });
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
tabItens.get(key).items.push(fieldMD);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
tabItens.set(config.name, fieldMD);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
const metadata = new FormMetadata();
|
|
222
|
-
Array.from(sheets.entries())
|
|
223
|
-
.sort((a, b) => (a[0].order || 10000) - (b[0].order || 10000))
|
|
224
|
-
.forEach(([key, value]) => {
|
|
225
|
-
metadata.addSheet({
|
|
226
|
-
label: key.label,
|
|
227
|
-
name: key.label,
|
|
228
|
-
items: Array.from(value.values()),
|
|
229
|
-
requiredFields,
|
|
230
|
-
cleanOnCopyFields
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
return metadata;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
const inicialState = {};
|
|
237
|
-
/////////////////////////////// REDUCERS ///////////////////////////////
|
|
238
|
-
function formReducer(state = inicialState, action) {
|
|
239
|
-
switch (action.type) {
|
|
240
|
-
case FormActions.METADATA_LOADED:
|
|
241
|
-
return Object.assign(Object.assign({}, state), { formMetadata: action.payload });
|
|
242
|
-
case FormActions.CHANGE_TAB:
|
|
243
|
-
return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
|
|
244
|
-
default:
|
|
245
|
-
return state;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/////////////////////////////// ACTION CREATORS ///////////////////////////////
|
|
249
|
-
function loadMetadata(formMetadata) {
|
|
250
|
-
return {
|
|
251
|
-
type: FormActions.METADATA_LOADED,
|
|
252
|
-
payload: formMetadata
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function changeTab(currentSheet) {
|
|
256
|
-
return {
|
|
257
|
-
type: FormActions.CHANGE_TAB,
|
|
258
|
-
payload: currentSheet.tabKey
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
/////////////////////////////// SELECTORS ///////////////////////////////
|
|
262
|
-
function selectFormMetadata(state) {
|
|
263
|
-
return state.formMetadata;
|
|
264
|
-
}
|
|
265
|
-
function selectCurrentSheet(state) {
|
|
266
|
-
return state.currentSheet ? state.formMetadata.getSheet(state.currentSheet) : Array.from(state.formMetadata.getAllSheets().values())[0];
|
|
267
|
-
}
|
|
268
|
-
/////////////////////////////// TYPES ///////////////////////////////
|
|
269
|
-
var FormActions;
|
|
270
|
-
(function (FormActions) {
|
|
271
|
-
FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
|
|
272
|
-
FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
|
|
273
|
-
})(FormActions || (FormActions = {}));
|
|
274
|
-
|
|
275
|
-
class DataBinder {
|
|
276
|
-
constructor(dataUnit) {
|
|
277
|
-
this._fields = new Map();
|
|
278
|
-
this._dataUnit = dataUnit;
|
|
279
|
-
this._dataUnit.subscribe(_action => {
|
|
280
|
-
var _a;
|
|
281
|
-
(_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
282
|
-
this.updateValue(field.fieldName, field.field);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
bind(fields) {
|
|
287
|
-
fields.forEach(fieldElement => {
|
|
288
|
-
const fieldName = fieldElement.dataset.fieldName;
|
|
289
|
-
this.updateBind(fieldName, fieldElement);
|
|
290
|
-
this.updateValue(fieldName, fieldElement);
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
updateValue(fieldName, field) {
|
|
294
|
-
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
295
|
-
}
|
|
296
|
-
updateBind(fieldName, field) {
|
|
297
|
-
const oldBind = this._fields.get(fieldName);
|
|
298
|
-
if (oldBind) {
|
|
299
|
-
oldBind.destroy();
|
|
300
|
-
}
|
|
301
|
-
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
302
|
-
this.bindSearchOptionsLoader(fieldName, field);
|
|
303
|
-
}
|
|
304
|
-
setFieldValue(fieldName, newValue) {
|
|
305
|
-
if (this._dataUnit.records.length === 0) {
|
|
306
|
-
this._dataUnit.addRecord();
|
|
307
|
-
}
|
|
308
|
-
this._dataUnit.setFieldValue(fieldName, newValue);
|
|
309
|
-
}
|
|
310
|
-
bindSearchOptionsLoader(fieldName, field) {
|
|
311
|
-
if (field.nodeName === "EZ-SEARCH" && field["optionLoader"] === undefined) {
|
|
312
|
-
const loader = ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
|
|
313
|
-
if (loader) {
|
|
314
|
-
field["optionLoader"] = (arg) => {
|
|
315
|
-
return loader(arg, fieldName, this._dataUnit);
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
class Bind {
|
|
322
|
-
destroy() {
|
|
323
|
-
this.field.removeEventListener(this.eventName, this.eventListener);
|
|
324
|
-
}
|
|
325
|
-
static create(fieldName, field, callback) {
|
|
326
|
-
const b = new Bind();
|
|
327
|
-
b.fieldName = fieldName;
|
|
328
|
-
b.field = field;
|
|
329
|
-
//FIXME: Verificar se o field é um EzField
|
|
330
|
-
b.eventListener = (evt) => { callback(fieldName, evt.detail); };
|
|
331
|
-
b.eventName = "ezChange";
|
|
332
|
-
b.field.addEventListener(b.eventName, b.eventListener);
|
|
333
|
-
return b;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}";
|
|
338
|
-
|
|
339
|
-
const EzForm = class {
|
|
340
|
-
constructor(hostRef) {
|
|
341
|
-
registerInstance(this, hostRef);
|
|
342
|
-
}
|
|
343
|
-
submit() {
|
|
344
|
-
return Promise.resolve();
|
|
345
|
-
}
|
|
346
|
-
cancel() {
|
|
347
|
-
return Promise.resolve();
|
|
348
|
-
}
|
|
349
|
-
validate() {
|
|
350
|
-
return new Promise((accept, reject) => {
|
|
351
|
-
const metadata = selectFormMetadata(this._store.getState());
|
|
352
|
-
const requiredFields = this._staticFields
|
|
353
|
-
.filter(f => f.dataset.required)
|
|
354
|
-
.map(f => f.dataset.fieldName)
|
|
355
|
-
.concat(metadata.getRequiredFields());
|
|
356
|
-
const records = this.dataUnit.records;
|
|
357
|
-
for (let i = 0; i < records.length; i++) {
|
|
358
|
-
if (!this.validateRequired(requiredFields, records[i])) {
|
|
359
|
-
reject();
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
accept();
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
configChanged() {
|
|
367
|
-
this.processMetadata();
|
|
368
|
-
}
|
|
369
|
-
validateRequired(requiredFields, record) {
|
|
370
|
-
const invalidFields = [];
|
|
371
|
-
requiredFields.forEach(field => {
|
|
372
|
-
const value = record[field];
|
|
373
|
-
const fieldElem = this._element.querySelector(`[data-field-name=${field}]`);
|
|
374
|
-
if (value === null || value === undefined || value === "") {
|
|
375
|
-
invalidFields.push(field);
|
|
376
|
-
fieldElem["errorMessage"] = "Essa informação é obrigatória";
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
fieldElem["errorMessage"] = "";
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
const isValid = invalidFields.length === 0;
|
|
383
|
-
if (!isValid) {
|
|
384
|
-
ApplicationUtils.info("Há pelo menos um campo obrigatório não preenchido.");
|
|
385
|
-
}
|
|
386
|
-
return isValid;
|
|
387
|
-
}
|
|
388
|
-
getDynamicContent() {
|
|
389
|
-
var _a;
|
|
390
|
-
const formMD = selectFormMetadata(this._store.getState());
|
|
391
|
-
if (!formMD)
|
|
392
|
-
return null;
|
|
393
|
-
const currentSheet = selectCurrentSheet((_a = this._store) === null || _a === void 0 ? void 0 : _a.getState());
|
|
394
|
-
if (!currentSheet) {
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
const allSheets = Array.from(formMD.getAllSheets().values());
|
|
398
|
-
const result = [];
|
|
399
|
-
if (allSheets.length > 1) {
|
|
400
|
-
result.push(h("ez-tabselector", { onEzChange: (evt) => this._store.dispatch(changeTab(evt.detail)), selectedTab: currentSheet.name }, allSheets.map(s => h("ez-tab", { tabKey: s.name, label: s.label }))));
|
|
401
|
-
}
|
|
402
|
-
result.push(h(FormSheet, { store: this._store, source: currentSheet }));
|
|
403
|
-
return result;
|
|
404
|
-
}
|
|
405
|
-
processMetadata() {
|
|
406
|
-
if (!this.isStatic()) {
|
|
407
|
-
const metadata = this.config && this.config.length > 0 ? buildFromConfig(this.config, this.dataUnit) : buildFromDataUnit(this.dataUnit);
|
|
408
|
-
this._store.dispatch(loadMetadata(metadata));
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
isStatic() {
|
|
412
|
-
var _a;
|
|
413
|
-
return ((_a = this._staticFields) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
414
|
-
}
|
|
415
|
-
interceptAction(action) {
|
|
416
|
-
if (action.type === Action.RECORDS_COPIED) {
|
|
417
|
-
const metadata = selectFormMetadata(this._store.getState());
|
|
418
|
-
const cleanFields = metadata.getCleanOnCopyFields();
|
|
419
|
-
if (cleanFields) {
|
|
420
|
-
const records = action.payload;
|
|
421
|
-
return new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
|
422
|
-
const newRecord = Object.assign({}, record);
|
|
423
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
424
|
-
return newRecord;
|
|
425
|
-
}));
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return action;
|
|
429
|
-
}
|
|
430
|
-
componentWillLoad() {
|
|
431
|
-
if (this.dataUnit === undefined) {
|
|
432
|
-
this.dataUnit = new DataUnit("ez-form");
|
|
433
|
-
}
|
|
434
|
-
this.dataUnit.addInterceptor(this);
|
|
435
|
-
this.dataUnit.subscribe(action => {
|
|
436
|
-
if (action.type === Action.METADATA_LOADED) {
|
|
437
|
-
this.processMetadata();
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
this._dataBinder = new DataBinder(this.dataUnit);
|
|
441
|
-
this._store = createStore(formReducer);
|
|
442
|
-
this._store.subscribe(() => forceUpdate(this));
|
|
443
|
-
this._staticFields = Array.from(this._element.querySelectorAll("[data-field-name]"));
|
|
444
|
-
this.processMetadata();
|
|
445
|
-
}
|
|
446
|
-
componentDidRender() {
|
|
447
|
-
this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")));
|
|
448
|
-
}
|
|
449
|
-
render() {
|
|
450
|
-
return (h(Host, null, this.isStatic() ? null : this.getDynamicContent()));
|
|
451
|
-
}
|
|
452
|
-
get _element() { return getElement(this); }
|
|
453
|
-
static get watchers() { return {
|
|
454
|
-
"config": ["configChanged"]
|
|
455
|
-
}; }
|
|
456
|
-
};
|
|
457
|
-
EzForm.style = ezFormCss;
|
|
458
|
-
|
|
459
|
-
export { EzForm as ez_form };
|