@sme.up/ketchup 5.2.1-SNAPSHOT → 6.1.0-SNAPSHOT
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/CHANGELOG.md +5 -0
- package/dist/cjs/{cell-utils-d96b2993.js → cell-utils-a78d6fac.js} +2 -2
- package/dist/cjs/{component-d1496215.js → component-72a5b626.js} +30 -0
- package/dist/cjs/{f-button-2b9b99b1.js → f-button-ac179257.js} +1 -1
- package/dist/cjs/{f-cell-8351cb84.js → f-cell-69294bca.js} +37 -37
- package/dist/cjs/{f-chip-df59e1b0.js → f-chip-b00897d7.js} +4 -3
- package/dist/cjs/{f-image-12bab3b5.js → f-image-89f25556.js} +1 -1
- package/dist/cjs/f-paginator-utils-8fa501b3.js +1898 -0
- package/dist/cjs/{f-text-field-e7c35b5b.js → f-text-field-e1e45ade.js} +1 -1
- package/dist/cjs/{f-text-field-mdc-a67f5dfe.js → f-text-field-mdc-85997738.js} +23 -305
- package/dist/cjs/ketchup.cjs.js +2 -2
- package/dist/cjs/kup-accordion.cjs.entry.js +4 -4
- package/dist/cjs/{kup-autocomplete_27.cjs.entry.js → kup-autocomplete_25.cjs.entry.js} +1493 -5418
- package/dist/cjs/{kup-echart.cjs.entry.js → kup-box_2.cjs.entry.js} +17101 -14787
- package/dist/cjs/kup-calendar.cjs.entry.js +41 -33
- package/dist/cjs/kup-cell.cjs.entry.js +7 -7
- package/dist/cjs/kup-dash-list.cjs.entry.js +3 -3
- package/dist/cjs/kup-dash_2.cjs.entry.js +2 -2
- package/dist/cjs/kup-drawer.cjs.entry.js +11 -4
- package/dist/cjs/kup-field.cjs.entry.js +1 -1
- package/dist/cjs/kup-form-editor.cjs.entry.js +404 -0
- package/dist/cjs/kup-iframe.cjs.entry.js +2 -2
- package/dist/cjs/kup-image-list.cjs.entry.js +228 -0
- package/dist/cjs/kup-lazy.cjs.entry.js +2 -2
- package/dist/cjs/kup-magic-box.cjs.entry.js +3 -3
- package/dist/cjs/kup-manager-7a941909.js +16703 -0
- package/dist/cjs/kup-nav-bar.cjs.entry.js +2 -2
- package/dist/cjs/kup-numeric-picker.cjs.entry.js +4 -4
- package/dist/cjs/kup-photo-frame.cjs.entry.js +4 -4
- package/dist/cjs/kup-probe.cjs.entry.js +1 -1
- package/dist/cjs/kup-qlik.cjs.entry.js +1 -1
- package/dist/cjs/kup-snackbar.cjs.entry.js +5 -5
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{utils-e99921c1.js → utils-6287d878.js} +1 -1
- package/dist/collection/assets/card.js +4 -5
- package/dist/collection/assets/data-table.js +0 -79
- package/dist/collection/assets/form-editor.js +338 -0
- package/dist/collection/assets/image-list.js +624 -0
- package/dist/collection/assets/index.js +8 -0
- package/dist/collection/assets/kupdata.js +0 -3
- package/dist/collection/assets/kuptooltip.js +53 -7
- package/dist/collection/assets/tree.js +0 -128
- package/dist/collection/collection-manifest.json +7 -6
- package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +1 -1
- package/dist/collection/components/kup-box/kup-box-declarations.js +0 -4
- package/dist/collection/components/kup-box/kup-box.js +7 -135
- package/dist/collection/components/kup-card/built-in/kup-card-clock.js +1 -1
- package/dist/collection/components/kup-card/built-in/kup-card-column-drop-menu.js +1 -2
- package/dist/collection/components/kup-card/kup-card.css +26 -8
- package/dist/collection/components/kup-card/kup-card.js +1 -2
- package/dist/collection/components/kup-card/standard/kup-card-standard.js +14 -6
- package/dist/collection/components/kup-combobox/kup-combobox.js +1 -1
- package/dist/collection/components/kup-data-table/kup-data-table-declarations.js +1 -3
- package/dist/collection/components/kup-data-table/kup-data-table.js +19 -136
- package/dist/collection/components/kup-drawer/kup-drawer.css +1 -0
- package/dist/collection/components/kup-drawer/kup-drawer.js +8 -1
- package/dist/collection/components/kup-form-editor/kup-form-editor-declarations.js +23 -0
- package/dist/collection/components/kup-form-editor/kup-form-editor.css +80 -0
- package/dist/collection/components/kup-form-editor/kup-form-editor.js +561 -0
- package/dist/collection/components/kup-image-list/kup-image-list-declarations.js +10 -0
- package/dist/collection/components/kup-image-list/kup-image-list.css +166 -0
- package/dist/collection/components/kup-image-list/kup-image-list.js +432 -0
- package/dist/collection/components/kup-photo-frame/kup-photo-frame.css +3 -13
- package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +1 -1
- package/dist/collection/components/kup-snackbar/kup-snackbar.css +4 -0
- package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +18 -19
- package/dist/collection/components/kup-time-picker/kup-time-picker.js +2 -2
- package/dist/collection/components/kup-tree/kup-tree-declarations.js +0 -4
- package/dist/collection/components/kup-tree/kup-tree.css +10 -3
- package/dist/collection/components/kup-tree/kup-tree.js +65 -140
- package/dist/collection/f-components/f-cell/f-cell.js +7 -7
- package/dist/collection/f-components/f-chip/f-chip.js +2 -1
- package/dist/collection/managers/kup-data/kup-data-node-helper.js +24 -0
- package/dist/collection/managers/kup-data/kup-data.js +4 -1
- package/dist/collection/managers/kup-dynamic-position/kup-dynamic-position.js +4 -2
- package/dist/collection/managers/kup-interact/kup-interact.js +1 -22
- package/dist/collection/managers/kup-language/kup-language-declarations.js +2 -0
- package/dist/collection/managers/kup-manager/kup-manager.js +21 -2
- package/dist/collection/managers/kup-theme/kup-theme-declarations.js +5 -0
- package/dist/collection/managers/kup-tooltip/kup-tooltip.js +53 -20
- package/dist/collection/types/GenericTypes.js +2 -0
- package/dist/collection/utils/kup-column-menu/kup-column-menu.js +7 -11
- package/dist/esm/{cell-utils-f4bdbbc8.js → cell-utils-964da6b5.js} +3 -3
- package/dist/esm/{component-c4eb6153.js → component-b1bedf1d.js} +27 -2
- package/dist/esm/{f-button-54a49fd8.js → f-button-871a544b.js} +1 -1
- package/dist/esm/{f-cell-d5dac50b.js → f-cell-521ef17a.js} +38 -38
- package/dist/esm/{f-chip-a3035b4b.js → f-chip-1dda722f.js} +5 -4
- package/dist/esm/{f-image-d32465e3.js → f-image-c468d8ae.js} +1 -1
- package/dist/esm/f-paginator-utils-7dff8ff0.js +1884 -0
- package/dist/esm/{f-text-field-c25cc63f.js → f-text-field-d6c61c73.js} +1 -1
- package/dist/esm/{f-text-field-mdc-9fbbefc3.js → f-text-field-mdc-d42d3f9e.js} +2 -284
- package/dist/esm/ketchup.js +2 -2
- package/dist/esm/kup-accordion.entry.js +5 -5
- package/dist/esm/{kup-autocomplete_27.entry.js → kup-autocomplete_25.entry.js} +1445 -5368
- package/dist/esm/{kup-echart.entry.js → kup-box_2.entry.js} +17101 -14788
- package/dist/esm/kup-calendar.entry.js +42 -34
- package/dist/esm/kup-cell.entry.js +7 -7
- package/dist/esm/kup-dash-list.entry.js +3 -3
- package/dist/esm/kup-dash_2.entry.js +2 -2
- package/dist/esm/kup-drawer.entry.js +11 -4
- package/dist/esm/kup-field.entry.js +1 -1
- package/dist/esm/kup-form-editor.entry.js +400 -0
- package/dist/esm/kup-iframe.entry.js +2 -2
- package/dist/esm/kup-image-list.entry.js +224 -0
- package/dist/esm/kup-lazy.entry.js +2 -2
- package/dist/esm/kup-magic-box.entry.js +3 -3
- package/dist/esm/kup-manager-58b075b4.js +16686 -0
- package/dist/esm/kup-nav-bar.entry.js +2 -2
- package/dist/esm/kup-numeric-picker.entry.js +5 -5
- package/dist/esm/kup-photo-frame.entry.js +4 -4
- package/dist/esm/kup-probe.entry.js +1 -1
- package/dist/esm/kup-qlik.entry.js +1 -1
- package/dist/esm/kup-snackbar.entry.js +5 -5
- package/dist/esm/loader.js +2 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/{tslib.es6-8f2d44b6.js → tslib.es6-3eea2234.js} +1 -1
- package/dist/esm/{utils-f24319a0.js → utils-d7e4b3c2.js} +2 -2
- package/dist/ketchup/ketchup.esm.js +1 -1
- package/dist/ketchup/{p-7a74ad17.js → p-1ae66cc5.js} +1 -1
- package/dist/ketchup/{p-e6709c26.entry.js → p-3c11e615.entry.js} +1 -1
- package/dist/ketchup/{p-669bde31.js → p-44ec4f03.js} +1 -1
- package/dist/ketchup/p-4ffbc3ff.js +1 -0
- package/dist/ketchup/p-5264a3e6.entry.js +1 -0
- package/dist/ketchup/{p-e8e3c9da.entry.js → p-65974e48.entry.js} +1 -1
- package/dist/ketchup/p-65b46587.entry.js +40 -0
- package/dist/ketchup/{p-09d708c4.entry.js → p-6dff70f8.entry.js} +1 -1
- package/dist/ketchup/{p-34748c91.js → p-7454cb92.js} +1 -1
- package/dist/ketchup/{p-a0b1d769.js → p-79b0730b.js} +1 -1
- package/dist/ketchup/p-7eff4eee.js +1 -0
- package/dist/ketchup/p-80968627.entry.js +1 -0
- package/dist/ketchup/{p-8c44c3b9.js → p-81605f08.js} +4 -5
- package/dist/ketchup/p-8cdf61a4.js +1 -0
- package/dist/ketchup/{p-8418e8fa.entry.js → p-954cc340.entry.js} +1 -1
- package/dist/ketchup/p-976244f9.entry.js +9 -0
- package/dist/ketchup/{p-4173422f.entry.js → p-99e0d768.entry.js} +1 -1
- package/dist/ketchup/{p-41741c28.entry.js → p-a0f6e25c.entry.js} +1 -1
- package/dist/ketchup/p-a203f78b.js +45 -0
- package/dist/ketchup/{p-9a61d8dc.entry.js → p-a615a92b.entry.js} +1 -1
- package/dist/ketchup/p-aca0e54b.js +30 -0
- package/dist/ketchup/p-b8939a8b.entry.js +1 -0
- package/dist/ketchup/p-bfc3bac7.js +1 -0
- package/dist/ketchup/p-c5ce8951.entry.js +1 -0
- package/dist/ketchup/{p-bb8844bf.entry.js → p-d2ee56dd.entry.js} +1 -1
- package/dist/ketchup/p-db71436b.entry.js +27 -0
- package/dist/ketchup/{p-40f97429.js → p-e0035c58.js} +1 -1
- package/dist/ketchup/p-e1039cf2.entry.js +1 -0
- package/dist/ketchup/{p-44192f30.entry.js → p-ea10176c.entry.js} +1 -1
- package/dist/ketchup/{p-67842f1e.entry.js → p-f09f2f98.entry.js} +1 -1
- package/dist/ketchup/{p-203d6295.entry.js → p-f71a1675.entry.js} +1 -1
- package/dist/ketchup/{p-11e72a8c.entry.js → p-fac1a08b.entry.js} +1 -1
- package/dist/types/components/kup-box/kup-box-declarations.d.ts +3 -5
- package/dist/types/components/kup-box/kup-box.d.ts +0 -22
- package/dist/types/components/kup-data-table/kup-data-table-declarations.d.ts +2 -4
- package/dist/types/components/kup-data-table/kup-data-table.d.ts +1 -19
- package/dist/types/components/kup-form-editor/kup-form-editor-declarations.d.ts +79 -0
- package/dist/types/components/kup-form-editor/kup-form-editor.d.ts +72 -0
- package/dist/types/components/kup-image-list/kup-image-list-declarations.d.ts +14 -0
- package/dist/types/components/kup-image-list/kup-image-list.d.ts +56 -0
- package/dist/types/components/kup-tab-bar/kup-tab-bar-declarations.d.ts +3 -9
- package/dist/types/components/kup-tab-bar/kup-tab-bar.d.ts +6 -6
- package/dist/types/components/kup-tree/kup-tree-declarations.d.ts +1 -5
- package/dist/types/components/kup-tree/kup-tree.d.ts +1 -24
- package/dist/types/components.d.ts +121 -231
- package/dist/types/managers/kup-data/kup-data-declarations.d.ts +1 -0
- package/dist/types/managers/kup-data/kup-data-node-helper.d.ts +7 -0
- package/dist/types/managers/kup-data/kup-data.d.ts +1 -0
- package/dist/types/managers/kup-language/kup-language-declarations.d.ts +2 -0
- package/dist/types/managers/kup-manager/kup-manager-declarations.d.ts +4 -0
- package/dist/types/managers/kup-manager/kup-manager.d.ts +12 -0
- package/dist/types/managers/kup-tooltip/kup-tooltip-declarations.d.ts +3 -3
- package/dist/types/managers/kup-tooltip/kup-tooltip.d.ts +17 -6
- package/dist/types/types/GenericTypes.d.ts +2 -0
- package/dist/types/utils/kup-column-menu/kup-column-menu.d.ts +1 -3
- package/package.json +15 -14
- package/dist/cjs/kup-manager-5c03da64.js +0 -8795
- package/dist/collection/assets/tooltip.js +0 -73
- package/dist/collection/components/kup-tooltip/kup-tooltip-declarations.js +0 -20
- package/dist/collection/components/kup-tooltip/kup-tooltip.css +0 -149
- package/dist/collection/components/kup-tooltip/kup-tooltip.js +0 -1205
- package/dist/collection/utils/helpers.js +0 -38
- package/dist/esm/kup-manager-9316a184.js +0 -8778
- package/dist/ketchup/p-12773ca8.js +0 -9
- package/dist/ketchup/p-44f8da2a.js +0 -1
- package/dist/ketchup/p-4f56932b.js +0 -1
- package/dist/ketchup/p-7ba8fa4a.entry.js +0 -39
- package/dist/ketchup/p-7de0d7e1.js +0 -1
- package/dist/ketchup/p-96bf19aa.entry.js +0 -1
- package/dist/ketchup/p-b0ddcce9.entry.js +0 -9
- package/dist/ketchup/p-b6c21223.entry.js +0 -27
- package/dist/ketchup/p-c58a2a81.entry.js +0 -1
- package/dist/ketchup/p-ca3d585b.entry.js +0 -1
- package/dist/ketchup/p-ecb7069b.js +0 -135
- package/dist/types/components/kup-tooltip/kup-tooltip-declarations.d.ts +0 -93
- package/dist/types/components/kup-tooltip/kup-tooltip.d.ts +0 -142
- package/dist/types/utils/helpers.d.ts +0 -4
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import { Component, Element, forceUpdate, h, Host, Method, Prop, State, Event, Watch, } from '@stencil/core';
|
|
2
|
+
import { FButton } from '../../f-components/f-button/f-button';
|
|
3
|
+
import { KupDebugCategory } from '../../managers/kup-debug/kup-debug-declarations';
|
|
4
|
+
import { KupDragEffect } from '../../managers/kup-interact/kup-interact-declarations';
|
|
5
|
+
import { KupLanguageGeneric } from '../../managers/kup-language/kup-language-declarations';
|
|
6
|
+
import { kupManagerInstance, } from '../../managers/kup-manager/kup-manager';
|
|
7
|
+
import { getProps, setProps } from '../../utils/utils';
|
|
8
|
+
import { componentWrapperId } from '../../variables/GenericVariables';
|
|
9
|
+
import { KupFormEditorDragTypes, KupFormEditorLabels, KupFormEditorProps, } from './kup-form-editor-declarations';
|
|
10
|
+
export class KupFormEditor {
|
|
11
|
+
constructor() {
|
|
12
|
+
/*-------------------------------------------------*/
|
|
13
|
+
/* S t a t e s */
|
|
14
|
+
/*-------------------------------------------------*/
|
|
15
|
+
/**
|
|
16
|
+
* Force render component by internal event.
|
|
17
|
+
*/
|
|
18
|
+
this.resetInternalData = false;
|
|
19
|
+
/*-------------------------------------------------*/
|
|
20
|
+
/* P r o p s */
|
|
21
|
+
/*-------------------------------------------------*/
|
|
22
|
+
/**
|
|
23
|
+
* Custom style of the component.
|
|
24
|
+
* @default ""
|
|
25
|
+
* @see https://ketchup.smeup.com/ketchup-showcase/#/customization
|
|
26
|
+
*/
|
|
27
|
+
this.customStyle = '';
|
|
28
|
+
/**
|
|
29
|
+
* The data of the component.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
this.data = null;
|
|
33
|
+
/*-------------------------------------------------*/
|
|
34
|
+
/* I n t e r n a l V a r i a b l e s */
|
|
35
|
+
/*-------------------------------------------------*/
|
|
36
|
+
/**
|
|
37
|
+
* Instance of the KupManager class.
|
|
38
|
+
*/
|
|
39
|
+
this.kupManager = kupManagerInstance();
|
|
40
|
+
/**
|
|
41
|
+
* Draggable type of Form (Components or Sections).
|
|
42
|
+
*/
|
|
43
|
+
this.dragType = KupFormEditorDragTypes.Components;
|
|
44
|
+
/**
|
|
45
|
+
* Internal data of the component.
|
|
46
|
+
*/
|
|
47
|
+
this.internalData = null;
|
|
48
|
+
/**
|
|
49
|
+
* Internal data backup of the component for refresh when changed content by drag&drop.
|
|
50
|
+
*/
|
|
51
|
+
this.internalDataBackup = null;
|
|
52
|
+
}
|
|
53
|
+
onKupSave() {
|
|
54
|
+
this.kupSave.emit({
|
|
55
|
+
comp: this,
|
|
56
|
+
id: this.rootElement.id,
|
|
57
|
+
data: this.internalData,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/*-------------------------------------------------*/
|
|
61
|
+
/* W a t c h e r s */
|
|
62
|
+
/*-------------------------------------------------*/
|
|
63
|
+
dataChanged() {
|
|
64
|
+
this.resetData();
|
|
65
|
+
}
|
|
66
|
+
/*-------------------------------------------------*/
|
|
67
|
+
/* P u b l i c M e t h o d s */
|
|
68
|
+
/*-------------------------------------------------*/
|
|
69
|
+
/**
|
|
70
|
+
* Used to retrieve component's props values.
|
|
71
|
+
* @param {boolean} descriptions - When provided and true, the result will be the list of props with their description.
|
|
72
|
+
* @returns {Promise<GenericObject>} List of props as object, each key will be a prop.
|
|
73
|
+
*/
|
|
74
|
+
async getProps(descriptions) {
|
|
75
|
+
return getProps(this, KupFormEditorProps, descriptions);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* This method is used to trigger a new render of the component.
|
|
79
|
+
*/
|
|
80
|
+
async refresh() {
|
|
81
|
+
forceUpdate(this);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sets the props to the component.
|
|
85
|
+
* @param {GenericObject} props - Object containing props that will be set to the component.
|
|
86
|
+
*/
|
|
87
|
+
async setProps(props) {
|
|
88
|
+
setProps(this, KupFormEditorProps, props);
|
|
89
|
+
}
|
|
90
|
+
/*-------------------------------------------------*/
|
|
91
|
+
/* P r i v a t e M e t h o d s */
|
|
92
|
+
/*-------------------------------------------------*/
|
|
93
|
+
buildHeader() {
|
|
94
|
+
const clearButtonProp = {
|
|
95
|
+
icon: 'cancel',
|
|
96
|
+
label: KupFormEditorLabels.Reset,
|
|
97
|
+
secondary: true,
|
|
98
|
+
onClick: () => {
|
|
99
|
+
this.resetData();
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const saveButtonProp = {
|
|
103
|
+
icon: 'save',
|
|
104
|
+
label: KupFormEditorLabels.Save,
|
|
105
|
+
onClick: () => this.onKupSave(),
|
|
106
|
+
};
|
|
107
|
+
const selRadioProp = [
|
|
108
|
+
{
|
|
109
|
+
label: KupFormEditorLabels.Components,
|
|
110
|
+
value: KupFormEditorDragTypes.Components,
|
|
111
|
+
checked: this.dragType == KupFormEditorDragTypes.Components,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: KupFormEditorLabels.Sections,
|
|
115
|
+
value: KupFormEditorDragTypes.Sections,
|
|
116
|
+
checked: this.dragType == KupFormEditorDragTypes.Sections,
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
return (h("div", { class: "header" },
|
|
120
|
+
h("kup-radio", { data: selRadioProp, "onKup-radio-change": (ev) => {
|
|
121
|
+
this.dragType = ev.detail
|
|
122
|
+
.value;
|
|
123
|
+
this.resetData(this.internalData);
|
|
124
|
+
} }),
|
|
125
|
+
h(FButton, Object.assign({}, clearButtonProp)),
|
|
126
|
+
h(FButton, Object.assign({}, saveButtonProp))));
|
|
127
|
+
}
|
|
128
|
+
buildForm(form, parent) {
|
|
129
|
+
const classes = {
|
|
130
|
+
form: true,
|
|
131
|
+
'layout-column': form && form.layout == 'column',
|
|
132
|
+
'layout-row': form && form.layout == 'row',
|
|
133
|
+
'form-dropzone': form &&
|
|
134
|
+
this.dragType == KupFormEditorDragTypes.Sections &&
|
|
135
|
+
form.sections != null &&
|
|
136
|
+
form.sections.length > 0,
|
|
137
|
+
};
|
|
138
|
+
return form ? (h("div", { class: classes, ref: (el) => {
|
|
139
|
+
if (!el)
|
|
140
|
+
return;
|
|
141
|
+
const kel = el;
|
|
142
|
+
kel.kupData = { parent: parent, form: form };
|
|
143
|
+
} }, form.sections.map((section) => this.buildSection(section, form)))) : (h("div", null, this.kupManager.language.translate(KupLanguageGeneric.EMPTY_DATA)));
|
|
144
|
+
}
|
|
145
|
+
buildSectionHeader(section, parent) {
|
|
146
|
+
const addButtonProp = {
|
|
147
|
+
icon: 'add',
|
|
148
|
+
slim: true,
|
|
149
|
+
onClick: () => {
|
|
150
|
+
if (!section.sections) {
|
|
151
|
+
section.sections = [];
|
|
152
|
+
}
|
|
153
|
+
const newSec = {
|
|
154
|
+
id: section.id + (section.sections.length + 1),
|
|
155
|
+
loaded: section.loaded,
|
|
156
|
+
layout: section.layout,
|
|
157
|
+
components: [],
|
|
158
|
+
};
|
|
159
|
+
if (section.components) {
|
|
160
|
+
section.components.forEach((x) => newSec.components.push(x));
|
|
161
|
+
section.components.splice(0);
|
|
162
|
+
}
|
|
163
|
+
section.sections.push(newSec);
|
|
164
|
+
this.resetData(this.internalData);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
const removeButtonProp = {
|
|
168
|
+
icon: 'remove',
|
|
169
|
+
slim: true,
|
|
170
|
+
secondary: true,
|
|
171
|
+
onClick: () => {
|
|
172
|
+
const idx = parent.sections.indexOf(section);
|
|
173
|
+
parent.sections.splice(idx, 1);
|
|
174
|
+
this.resetData(this.internalData);
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
return (h("div", { class: "section-header" },
|
|
178
|
+
h("div", null,
|
|
179
|
+
section.id,
|
|
180
|
+
' ',
|
|
181
|
+
section.dim ? '(' + section.dim + ')' : undefined,
|
|
182
|
+
" -",
|
|
183
|
+
' ',
|
|
184
|
+
section.layout),
|
|
185
|
+
h("div", null,
|
|
186
|
+
h("div", { class: "section-header-actions" },
|
|
187
|
+
h("kup-switch", { checked: section.loaded, label: KupFormEditorLabels.Loaded, "onKup-switch-change": (ev) => {
|
|
188
|
+
section.loaded = ev.detail.value == 'on';
|
|
189
|
+
} }),
|
|
190
|
+
h("kup-switch", { checked: section.layout == 'column', label: KupFormEditorLabels.Column, "onKup-switch-change": (ev) => {
|
|
191
|
+
section.layout =
|
|
192
|
+
ev.detail.value == 'on' ? 'column' : 'row';
|
|
193
|
+
this.resetData(this.internalData);
|
|
194
|
+
} }),
|
|
195
|
+
h(FButton, Object.assign({}, addButtonProp)),
|
|
196
|
+
h(FButton, Object.assign({}, removeButtonProp)),
|
|
197
|
+
section.components && section.components.length > 0 ? (h("kup-image", { resource: "widgets", sizeX: "24px", sizeY: "24px" })) : undefined))));
|
|
198
|
+
}
|
|
199
|
+
buildSection(section, parent) {
|
|
200
|
+
const classes = {
|
|
201
|
+
section: true,
|
|
202
|
+
'section-draggable': this.dragType == KupFormEditorDragTypes.Sections,
|
|
203
|
+
'section-dropzone': !section.sections ||
|
|
204
|
+
section.sections.length == 0 ||
|
|
205
|
+
this.dragType == KupFormEditorDragTypes.Sections,
|
|
206
|
+
};
|
|
207
|
+
const bodyClasses = {
|
|
208
|
+
'section-body': true,
|
|
209
|
+
'layout-column': section && section.layout == 'column',
|
|
210
|
+
'layout-row': section && section.layout == 'row',
|
|
211
|
+
};
|
|
212
|
+
let bodyStyles = {};
|
|
213
|
+
if (section.sections) {
|
|
214
|
+
let gridTemplate = '';
|
|
215
|
+
section.sections.forEach((childSection) => {
|
|
216
|
+
if (!childSection.dim)
|
|
217
|
+
gridTemplate += ' 1fr';
|
|
218
|
+
else
|
|
219
|
+
gridTemplate +=
|
|
220
|
+
childSection.dim.indexOf('%') < 0
|
|
221
|
+
? ' ' + childSection.dim + 'px'
|
|
222
|
+
: ' ' + childSection.dim;
|
|
223
|
+
});
|
|
224
|
+
if (section.layout == 'column')
|
|
225
|
+
bodyStyles['gridTemplateRows'] = gridTemplate;
|
|
226
|
+
if (section.layout == 'row')
|
|
227
|
+
bodyStyles['gridTemplateColumns'] = gridTemplate;
|
|
228
|
+
}
|
|
229
|
+
return (h("div", { class: classes, ref: (el) => {
|
|
230
|
+
if (!el)
|
|
231
|
+
return;
|
|
232
|
+
const kel = el;
|
|
233
|
+
kel.kupData = { parent: parent, section: section };
|
|
234
|
+
} },
|
|
235
|
+
this.dragType == KupFormEditorDragTypes.Sections
|
|
236
|
+
? this.buildSectionHeader(section, parent)
|
|
237
|
+
: undefined,
|
|
238
|
+
h("div", { class: bodyClasses, style: bodyStyles },
|
|
239
|
+
this.dragType == KupFormEditorDragTypes.Components &&
|
|
240
|
+
section.components
|
|
241
|
+
? section.components.map((component) => component.type == 'SCH' ? (this.buildForm(component, section)) : (h("div", { class: "component component-draggable", ref: (el) => {
|
|
242
|
+
if (!el)
|
|
243
|
+
return;
|
|
244
|
+
const kel = el;
|
|
245
|
+
kel.kupData = {
|
|
246
|
+
section: section,
|
|
247
|
+
componnent: component,
|
|
248
|
+
};
|
|
249
|
+
} },
|
|
250
|
+
component.id,
|
|
251
|
+
" - ",
|
|
252
|
+
component.type,
|
|
253
|
+
h("kup-switch", { checked: component.loaded, label: KupFormEditorLabels.Loaded, "onKup-switch-change": (ev) => {
|
|
254
|
+
component.loaded =
|
|
255
|
+
ev.detail.value == 'on';
|
|
256
|
+
} }))))
|
|
257
|
+
: undefined,
|
|
258
|
+
section.sections
|
|
259
|
+
? section.sections.map((childSection) => this.buildSection(childSection, section))
|
|
260
|
+
: undefined)));
|
|
261
|
+
}
|
|
262
|
+
didRenderInteractables() {
|
|
263
|
+
try {
|
|
264
|
+
const items = [];
|
|
265
|
+
this.rootElement.shadowRoot
|
|
266
|
+
.querySelectorAll('.component-draggable')
|
|
267
|
+
.forEach((x) => items.push(x));
|
|
268
|
+
this.rootElement.shadowRoot
|
|
269
|
+
.querySelectorAll('.section-draggable')
|
|
270
|
+
.forEach((x) => items.push(x));
|
|
271
|
+
items.forEach((item) => {
|
|
272
|
+
this.kupManager.interact.draggable(item, null, null, KupDragEffect.CLONE);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
this.kupManager.debug.logMessage(this, error, KupDebugCategory.ERROR);
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
const items = [];
|
|
280
|
+
this.rootElement.shadowRoot
|
|
281
|
+
.querySelectorAll('.section-dropzone')
|
|
282
|
+
.forEach((x) => items.push(x));
|
|
283
|
+
this.rootElement.shadowRoot
|
|
284
|
+
.querySelectorAll('.form-dropzone')
|
|
285
|
+
.forEach((x) => items.push(x));
|
|
286
|
+
items.forEach((item) => {
|
|
287
|
+
this.kupManager.interact.dropzone(item, null, null, {
|
|
288
|
+
drop: (ev) => {
|
|
289
|
+
ev.currentTarget.appendChild(ev.relatedTarget);
|
|
290
|
+
this.dropped(ev.currentTarget, ev.relatedTarget);
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
this.kupManager.debug.logMessage(this, error, KupDebugCategory.ERROR);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
dropped(parent, child) {
|
|
300
|
+
if (this.dragType == KupFormEditorDragTypes.Components) {
|
|
301
|
+
const idx = child.kupData.section.components.indexOf(child.kupData.componnent);
|
|
302
|
+
child.kupData.section.components.splice(idx, 1);
|
|
303
|
+
parent.kupData.section.components.push(child.kupData.componnent);
|
|
304
|
+
child.kupData.section = parent.kupData.section;
|
|
305
|
+
}
|
|
306
|
+
else if (this.dragType == KupFormEditorDragTypes.Sections) {
|
|
307
|
+
const idx = child.kupData.parent.sections.indexOf(child.kupData.section);
|
|
308
|
+
child.kupData.parent.sections.splice(idx, 1);
|
|
309
|
+
if (parent.kupData.form) {
|
|
310
|
+
// il nuovo target è la form.
|
|
311
|
+
if (!parent.kupData.form.sections)
|
|
312
|
+
parent.kupData.form.sections = [];
|
|
313
|
+
parent.kupData.form.sections.push(child.kupData.section);
|
|
314
|
+
child.kupData.parent = parent.kupData.form;
|
|
315
|
+
}
|
|
316
|
+
else if (parent.kupData.section) {
|
|
317
|
+
// il nuovo target è la section.
|
|
318
|
+
if (!parent.kupData.section.sections)
|
|
319
|
+
parent.kupData.section.sections = [];
|
|
320
|
+
if (parent.kupData.section.components &&
|
|
321
|
+
parent.kupData.section.components.length > 0) {
|
|
322
|
+
// devo creare una section contenitore e sposare i components
|
|
323
|
+
const newSec = {
|
|
324
|
+
id: parent.kupData.section.id + '1',
|
|
325
|
+
loaded: parent.kupData.section.loaded,
|
|
326
|
+
layout: parent.kupData.section.layout,
|
|
327
|
+
components: [],
|
|
328
|
+
};
|
|
329
|
+
parent.kupData.section.components.forEach((x) => newSec.components.push(x));
|
|
330
|
+
parent.kupData.section.components.splice(0);
|
|
331
|
+
parent.kupData.section.sections.push(newSec);
|
|
332
|
+
}
|
|
333
|
+
parent.kupData.section.sections.push(child.kupData.section);
|
|
334
|
+
child.kupData.parent = parent.kupData.section;
|
|
335
|
+
}
|
|
336
|
+
this.resetData(this.internalData);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
resetData(form = null) {
|
|
340
|
+
if (form)
|
|
341
|
+
this.internalDataBackup = form;
|
|
342
|
+
this.resetInternalData = true;
|
|
343
|
+
setTimeout(() => {
|
|
344
|
+
if (this.internalDataBackup) {
|
|
345
|
+
this.internalData = this.internalDataBackup;
|
|
346
|
+
this.internalDataBackup = null;
|
|
347
|
+
}
|
|
348
|
+
this.resetInternalData = false;
|
|
349
|
+
}, 250);
|
|
350
|
+
}
|
|
351
|
+
unregisterInteractables() {
|
|
352
|
+
this.kupManager.interact.unregister(Array.from(this.rootElement.shadowRoot.querySelectorAll('.component-draggable')));
|
|
353
|
+
this.kupManager.interact.unregister(Array.from(this.rootElement.shadowRoot.querySelectorAll('.section-dropzone')));
|
|
354
|
+
this.kupManager.interact.unregister(Array.from(this.rootElement.shadowRoot.querySelectorAll('.section-draggable')));
|
|
355
|
+
this.kupManager.interact.unregister(Array.from(this.rootElement.shadowRoot.querySelectorAll('.form-dropzone')));
|
|
356
|
+
}
|
|
357
|
+
/*-------------------------------------------------*/
|
|
358
|
+
/* L i f e c y c l e H o o k s */
|
|
359
|
+
/*-------------------------------------------------*/
|
|
360
|
+
componentWillLoad() {
|
|
361
|
+
this.kupManager.dates.register(this);
|
|
362
|
+
this.kupManager.debug.logLoad(this, false);
|
|
363
|
+
this.kupManager.language.register(this);
|
|
364
|
+
this.kupManager.theme.register(this);
|
|
365
|
+
}
|
|
366
|
+
componentDidLoad() {
|
|
367
|
+
this.kupManager.debug.logLoad(this, true);
|
|
368
|
+
}
|
|
369
|
+
componentWillRender() {
|
|
370
|
+
this.kupManager.debug.logRender(this, false);
|
|
371
|
+
if (this.resetInternalData) {
|
|
372
|
+
this.internalData = null;
|
|
373
|
+
this.unregisterInteractables();
|
|
374
|
+
}
|
|
375
|
+
else if (!this.internalData)
|
|
376
|
+
this.internalData = JSON.parse(JSON.stringify(this.data));
|
|
377
|
+
}
|
|
378
|
+
componentDidRender() {
|
|
379
|
+
this.kupManager.debug.logRender(this, true);
|
|
380
|
+
this.didRenderInteractables();
|
|
381
|
+
}
|
|
382
|
+
render() {
|
|
383
|
+
return (h(Host, null,
|
|
384
|
+
h("style", null, this.kupManager.theme.setKupStyle(this.rootElement)),
|
|
385
|
+
h("div", { id: componentWrapperId },
|
|
386
|
+
this.buildHeader(),
|
|
387
|
+
this.buildForm(this.internalData, null))));
|
|
388
|
+
}
|
|
389
|
+
disconnectedCallback() {
|
|
390
|
+
this.unregisterInteractables();
|
|
391
|
+
this.kupManager.dates.unregister(this);
|
|
392
|
+
this.kupManager.language.unregister(this);
|
|
393
|
+
this.kupManager.theme.unregister(this);
|
|
394
|
+
}
|
|
395
|
+
static get is() { return "kup-form-editor"; }
|
|
396
|
+
static get encapsulation() { return "shadow"; }
|
|
397
|
+
static get originalStyleUrls() { return {
|
|
398
|
+
"$": ["kup-form-editor.scss"]
|
|
399
|
+
}; }
|
|
400
|
+
static get styleUrls() { return {
|
|
401
|
+
"$": ["kup-form-editor.css"]
|
|
402
|
+
}; }
|
|
403
|
+
static get properties() { return {
|
|
404
|
+
"customStyle": {
|
|
405
|
+
"type": "string",
|
|
406
|
+
"mutable": false,
|
|
407
|
+
"complexType": {
|
|
408
|
+
"original": "string",
|
|
409
|
+
"resolved": "string",
|
|
410
|
+
"references": {}
|
|
411
|
+
},
|
|
412
|
+
"required": false,
|
|
413
|
+
"optional": false,
|
|
414
|
+
"docs": {
|
|
415
|
+
"tags": [{
|
|
416
|
+
"name": "default",
|
|
417
|
+
"text": "\"\""
|
|
418
|
+
}, {
|
|
419
|
+
"name": "see",
|
|
420
|
+
"text": "https://ketchup.smeup.com/ketchup-showcase/#/customization"
|
|
421
|
+
}],
|
|
422
|
+
"text": "Custom style of the component."
|
|
423
|
+
},
|
|
424
|
+
"attribute": "custom-style",
|
|
425
|
+
"reflect": false,
|
|
426
|
+
"defaultValue": "''"
|
|
427
|
+
},
|
|
428
|
+
"data": {
|
|
429
|
+
"type": "unknown",
|
|
430
|
+
"mutable": false,
|
|
431
|
+
"complexType": {
|
|
432
|
+
"original": "KupForm",
|
|
433
|
+
"resolved": "KupForm",
|
|
434
|
+
"references": {
|
|
435
|
+
"KupForm": {
|
|
436
|
+
"location": "import",
|
|
437
|
+
"path": "./kup-form-editor-declarations"
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
"required": false,
|
|
442
|
+
"optional": false,
|
|
443
|
+
"docs": {
|
|
444
|
+
"tags": [{
|
|
445
|
+
"name": "default",
|
|
446
|
+
"text": "false"
|
|
447
|
+
}],
|
|
448
|
+
"text": "The data of the component."
|
|
449
|
+
},
|
|
450
|
+
"defaultValue": "null"
|
|
451
|
+
}
|
|
452
|
+
}; }
|
|
453
|
+
static get states() { return {
|
|
454
|
+
"resetInternalData": {}
|
|
455
|
+
}; }
|
|
456
|
+
static get events() { return [{
|
|
457
|
+
"method": "kupSave",
|
|
458
|
+
"name": "kup-formeditor-save",
|
|
459
|
+
"bubbles": true,
|
|
460
|
+
"cancelable": false,
|
|
461
|
+
"composed": true,
|
|
462
|
+
"docs": {
|
|
463
|
+
"tags": [],
|
|
464
|
+
"text": ""
|
|
465
|
+
},
|
|
466
|
+
"complexType": {
|
|
467
|
+
"original": "KupFormEditorEventPayload",
|
|
468
|
+
"resolved": "KupFormEditorEventPayload",
|
|
469
|
+
"references": {
|
|
470
|
+
"KupFormEditorEventPayload": {
|
|
471
|
+
"location": "import",
|
|
472
|
+
"path": "./kup-form-editor-declarations"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}]; }
|
|
477
|
+
static get methods() { return {
|
|
478
|
+
"getProps": {
|
|
479
|
+
"complexType": {
|
|
480
|
+
"signature": "(descriptions?: boolean) => Promise<GenericObject>",
|
|
481
|
+
"parameters": [{
|
|
482
|
+
"tags": [{
|
|
483
|
+
"name": "param",
|
|
484
|
+
"text": "descriptions - When provided and true, the result will be the list of props with their description."
|
|
485
|
+
}],
|
|
486
|
+
"text": "- When provided and true, the result will be the list of props with their description."
|
|
487
|
+
}],
|
|
488
|
+
"references": {
|
|
489
|
+
"Promise": {
|
|
490
|
+
"location": "global"
|
|
491
|
+
},
|
|
492
|
+
"GenericObject": {
|
|
493
|
+
"location": "import",
|
|
494
|
+
"path": "../../types/GenericTypes"
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
"return": "Promise<GenericObject>"
|
|
498
|
+
},
|
|
499
|
+
"docs": {
|
|
500
|
+
"text": "Used to retrieve component's props values.",
|
|
501
|
+
"tags": [{
|
|
502
|
+
"name": "param",
|
|
503
|
+
"text": "descriptions - When provided and true, the result will be the list of props with their description."
|
|
504
|
+
}, {
|
|
505
|
+
"name": "returns",
|
|
506
|
+
"text": "List of props as object, each key will be a prop."
|
|
507
|
+
}]
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
"refresh": {
|
|
511
|
+
"complexType": {
|
|
512
|
+
"signature": "() => Promise<void>",
|
|
513
|
+
"parameters": [],
|
|
514
|
+
"references": {
|
|
515
|
+
"Promise": {
|
|
516
|
+
"location": "global"
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
"return": "Promise<void>"
|
|
520
|
+
},
|
|
521
|
+
"docs": {
|
|
522
|
+
"text": "This method is used to trigger a new render of the component.",
|
|
523
|
+
"tags": []
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
"setProps": {
|
|
527
|
+
"complexType": {
|
|
528
|
+
"signature": "(props: GenericObject) => Promise<void>",
|
|
529
|
+
"parameters": [{
|
|
530
|
+
"tags": [{
|
|
531
|
+
"name": "param",
|
|
532
|
+
"text": "props - Object containing props that will be set to the component."
|
|
533
|
+
}],
|
|
534
|
+
"text": "- Object containing props that will be set to the component."
|
|
535
|
+
}],
|
|
536
|
+
"references": {
|
|
537
|
+
"Promise": {
|
|
538
|
+
"location": "global"
|
|
539
|
+
},
|
|
540
|
+
"GenericObject": {
|
|
541
|
+
"location": "import",
|
|
542
|
+
"path": "../../types/GenericTypes"
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
"return": "Promise<void>"
|
|
546
|
+
},
|
|
547
|
+
"docs": {
|
|
548
|
+
"text": "Sets the props to the component.",
|
|
549
|
+
"tags": [{
|
|
550
|
+
"name": "param",
|
|
551
|
+
"text": "props - Object containing props that will be set to the component."
|
|
552
|
+
}]
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}; }
|
|
556
|
+
static get elementRef() { return "rootElement"; }
|
|
557
|
+
static get watchers() { return [{
|
|
558
|
+
"propName": "data",
|
|
559
|
+
"methodName": "dataChanged"
|
|
560
|
+
}]; }
|
|
561
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props of the kup-image-list component.
|
|
3
|
+
* Used to export every prop in an object.
|
|
4
|
+
*/
|
|
5
|
+
export var KupImageListProps;
|
|
6
|
+
(function (KupImageListProps) {
|
|
7
|
+
KupImageListProps["customStyle"] = "Custom style of the component.";
|
|
8
|
+
KupImageListProps["data"] = "Actual data of the component";
|
|
9
|
+
KupImageListProps["ripple"] = "When enabled displays Material's ripple effect on clicked items.";
|
|
10
|
+
})(KupImageListProps || (KupImageListProps = {}));
|