@openremote/or-json-forms 1.8.0-snapshot.20250725074716 → 1.8.0-snapshot.20250725120000
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/README.md +113 -113
- package/custom-elements.json +2 -2
- package/dist/umd/index.js +1105 -1105
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.orbundle.js +1163 -1163
- package/dist/umd/index.orbundle.js.map +1 -1
- package/lib/base-element.js +57 -1
- package/lib/controls/control-array-element.js +277 -83
- package/lib/controls/control-base-element.js +48 -1
- package/lib/controls/control-input-element.js +157 -20
- package/lib/index.js +141 -7
- package/lib/layouts/layout-base-element.js +29 -1
- package/lib/layouts/layout-vertical-element.js +340 -128
- package/lib/standard-renderers.js +188 -12
- package/lib/styles.js +156 -148
- package/lib/util.js +291 -23
- package/package.json +4 -4
package/lib/base-element.js
CHANGED
|
@@ -1 +1,57 @@
|
|
|
1
|
-
var __decorate
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
export class BaseElement extends LitElement {
|
|
10
|
+
set props(props) {
|
|
11
|
+
delete props.id;
|
|
12
|
+
Object.assign(this, props);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
__decorate([
|
|
16
|
+
property({ type: Object })
|
|
17
|
+
], BaseElement.prototype, "state", void 0);
|
|
18
|
+
__decorate([
|
|
19
|
+
property({ type: Object })
|
|
20
|
+
], BaseElement.prototype, "uischema", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
property({ type: Object })
|
|
23
|
+
], BaseElement.prototype, "schema", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
property({ type: String, attribute: false })
|
|
26
|
+
], BaseElement.prototype, "data", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
property({ type: Array })
|
|
29
|
+
], BaseElement.prototype, "renderers", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
property({ type: Array })
|
|
32
|
+
], BaseElement.prototype, "cells", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
property({ type: String, attribute: false })
|
|
35
|
+
], BaseElement.prototype, "config", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
property({ type: Array })
|
|
38
|
+
], BaseElement.prototype, "uischemas", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ type: Boolean })
|
|
41
|
+
], BaseElement.prototype, "enabled", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
property({ type: Boolean })
|
|
44
|
+
], BaseElement.prototype, "visible", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ type: String })
|
|
47
|
+
], BaseElement.prototype, "path", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property({ type: String })
|
|
50
|
+
], BaseElement.prototype, "label", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: Boolean })
|
|
53
|
+
], BaseElement.prototype, "required", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
property()
|
|
56
|
+
], BaseElement.prototype, "errors", void 0);
|
|
57
|
+
//# sourceMappingURL=base-element.js.map
|
|
@@ -1,93 +1,287 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { computeLabel, createDefaultValue, mapDispatchToArrayControlProps, Paths, Resolve, update } from "@jsonforms/core";
|
|
8
|
+
import { css, html, unsafeCSS } from "lit";
|
|
9
|
+
import { customElement, property } from "lit/decorators.js";
|
|
10
|
+
import { controlWithoutLabel, getCombinatorInfos, getTemplateFromProps, showJsonEditor } from "../util";
|
|
11
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
12
|
+
import { i18next } from "@openremote/or-translate";
|
|
13
|
+
import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";
|
|
14
|
+
import "@openremote/or-mwc-components/or-mwc-list";
|
|
15
|
+
import { addItemOrParameterDialogStyle, baseStyle, panelStyle } from "../styles";
|
|
16
|
+
import { DefaultColor4, DefaultColor5 } from "@openremote/core";
|
|
17
|
+
import { ControlBaseElement } from "./control-base-element";
|
|
18
|
+
import { getTemplateWrapper } from "../index";
|
|
19
|
+
// language=CSS
|
|
20
|
+
const style = css `
|
|
21
|
+
.item-border, .drag-handle {
|
|
22
|
+
border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
border-width: 1px;
|
|
25
|
+
border-style: solid;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.item-wrapper {
|
|
29
|
+
display: flex;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.item-wrapper > .item-container {
|
|
33
|
+
flex: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.item-wrapper + .item-wrapper {
|
|
37
|
+
padding-top: 10px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.item-wrapper > .item-container > .item-container {
|
|
41
|
+
margin: 0;
|
|
42
|
+
flex: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.item-wrapper > .item-container > .item-container > .delete-container {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.item-wrapper > .item-container > .item-container :first-child {
|
|
50
|
+
padding: 0;
|
|
51
|
+
margin: 0;
|
|
52
|
+
flex: 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.item-wrapper.dragging > .item-container {
|
|
56
|
+
opacity: 0.5;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.item-wrapper.indicator-after {
|
|
60
|
+
border-bottom-width: 3px;
|
|
61
|
+
border-bottom-style: solid;
|
|
62
|
+
border-bottom-color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.item-wrapper.indicator-before {
|
|
66
|
+
border-top-width: 3px;
|
|
67
|
+
border-top-style: solid;
|
|
68
|
+
border-top-color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.drag-container > button {
|
|
72
|
+
cursor: grab;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
let ControlArrayElement = class ControlArrayElement extends ControlBaseElement {
|
|
76
|
+
static get styles() {
|
|
77
|
+
return [
|
|
78
|
+
baseStyle,
|
|
79
|
+
panelStyle,
|
|
80
|
+
style
|
|
81
|
+
];
|
|
7
82
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
83
|
+
shouldUpdate(_changedProperties) {
|
|
84
|
+
if (_changedProperties.has("schema")) {
|
|
85
|
+
this.itemInfos = undefined;
|
|
86
|
+
this.resolvedSchema = Resolve.schema(this.schema, 'items', this.rootSchema);
|
|
87
|
+
if (Array.isArray(this.resolvedSchema.anyOf)) {
|
|
88
|
+
this.itemInfos = getCombinatorInfos(this.resolvedSchema.anyOf, this.rootSchema);
|
|
89
|
+
}
|
|
90
|
+
else if (Array.isArray(this.resolvedSchema.oneOf)) {
|
|
91
|
+
this.itemInfos = getCombinatorInfos(this.resolvedSchema.oneOf, this.rootSchema);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (_changedProperties.has("state")) {
|
|
95
|
+
const dispatchMethods = mapDispatchToArrayControlProps(this.state.dispatch);
|
|
96
|
+
this.addItem = (value) => dispatchMethods.addItem(this.path, value)();
|
|
97
|
+
this.removeItem = (index) => {
|
|
98
|
+
dispatchMethods.removeItems(this.path, [index])();
|
|
99
|
+
};
|
|
100
|
+
this.moveItem = (fromIndex, toIndex) => {
|
|
101
|
+
const move = (input, from, to) => {
|
|
102
|
+
let numberOfDeletedElm = 1;
|
|
103
|
+
const elm = input.splice(from, numberOfDeletedElm)[0];
|
|
104
|
+
numberOfDeletedElm = 0;
|
|
105
|
+
input.splice(to, numberOfDeletedElm, elm);
|
|
106
|
+
};
|
|
107
|
+
this.state.dispatch(update(this.path, array => {
|
|
108
|
+
move(array, fromIndex, toIndex);
|
|
109
|
+
return array;
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return super.shouldUpdate(_changedProperties);
|
|
11
114
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
115
|
+
render() {
|
|
116
|
+
var _a;
|
|
117
|
+
const maxItems = (_a = this.schema.maxItems) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
|
|
118
|
+
const itemCount = Array.isArray(this.data) ? this.data.length : 0;
|
|
119
|
+
const header = this.minimal ? `` : html `
|
|
120
|
+
<span slot="header">${this.label ? computeLabel(this.label, this.required, false) : ""}</span>
|
|
121
|
+
<div id="header-description" slot="header-description">
|
|
122
|
+
<div id="errors">
|
|
123
|
+
${!this.errors ? `` : html `<or-icon icon="alert"></or-icon><span>${this.errors}</span>`}
|
|
124
|
+
</div>
|
|
125
|
+
<div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined label="json" icon="pencil" @or-mwc-input-changed="${(ev) => this._showJson(ev)}"></or-mwc-input></div>
|
|
126
|
+
</div>
|
|
127
|
+
`;
|
|
128
|
+
const content = html `
|
|
129
|
+
${header}
|
|
130
|
+
<div id="content-wrapper" slot="content">
|
|
131
|
+
<div id="content" @dragover="${(ev) => this._onDragOver(ev)}">
|
|
132
|
+
|
|
133
|
+
${!Array.isArray(this.data) ? `` : this.data.map((item, index) => {
|
|
134
|
+
const childPath = Paths.compose(this.path, "" + index);
|
|
135
|
+
const props = {
|
|
136
|
+
renderers: this.renderers,
|
|
137
|
+
uischema: controlWithoutLabel("#"),
|
|
138
|
+
schema: this.resolvedSchema,
|
|
139
|
+
path: childPath
|
|
140
|
+
};
|
|
141
|
+
return this.getArrayItemWrapper(getTemplateFromProps(this.state, props) || html ``, index);
|
|
142
|
+
})}
|
|
143
|
+
|
|
144
|
+
</div>
|
|
145
|
+
${this.errors ? `` : html `
|
|
146
|
+
<div id="footer">
|
|
147
|
+
<or-mwc-input .disabled="${itemCount && itemCount >= maxItems}" .type="${InputType.BUTTON}" label="addItem" icon="plus" @or-mwc-input-changed="${() => this.doAddItem()}"></or-mwc-input>
|
|
148
|
+
</div>
|
|
149
|
+
`}
|
|
150
|
+
</div>
|
|
151
|
+
`;
|
|
152
|
+
return this.minimal ? html `<div>${content}</div>` : html `<or-collapsible-panel>${content}</or-collapsible-panel>`;
|
|
15
153
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
154
|
+
getArrayItemWrapper(elementTemplate, index) {
|
|
155
|
+
return html `
|
|
156
|
+
<div class="item-wrapper" data-index="${index}">
|
|
157
|
+
<div class="drag-container">
|
|
158
|
+
<button draggable="true" @dragstart="${(ev) => this._onDragStart(ev)}" @dragend="${(ev) => this._onDragEnd(ev)}" class="draggable button-clear"><or-icon icon="menu"></or-icon></input>
|
|
159
|
+
</div>
|
|
160
|
+
${getTemplateWrapper(elementTemplate, () => this.removeItem(index))}
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
19
163
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
164
|
+
_onDragStart(ev) {
|
|
165
|
+
const buttonElem = ev.currentTarget;
|
|
166
|
+
const itemWrapperElem = buttonElem.parentElement.parentElement;
|
|
167
|
+
itemWrapperElem.classList.add("dragging");
|
|
168
|
+
const itemContainerElem = itemWrapperElem.lastElementChild;
|
|
169
|
+
ev.dataTransfer.setDragImage(itemContainerElem, (itemContainerElem.getBoundingClientRect().width / 2) - 50, 0);
|
|
24
170
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
171
|
+
_onDragEnd(ev) {
|
|
172
|
+
const draggables = [...this.shadowRoot.querySelectorAll(".item-wrapper")];
|
|
173
|
+
const buttonElem = ev.currentTarget;
|
|
174
|
+
const itemWrapperElem = buttonElem.parentElement.parentElement;
|
|
175
|
+
itemWrapperElem.classList.remove("dragging");
|
|
176
|
+
const index = Number(itemWrapperElem.getAttribute("data-index"));
|
|
177
|
+
const afterIndex = Math.max(0, (itemWrapperElem.getAttribute("data-after-index") !== null ? Number(itemWrapperElem.getAttribute("data-after-index")) : draggables.length) - 1);
|
|
178
|
+
draggables.forEach(draggable => draggable.classList.remove("indicator-before", "indicator-after"));
|
|
179
|
+
if (index === afterIndex) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.moveItem(index, afterIndex);
|
|
28
183
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
184
|
+
_onDragOver(ev) {
|
|
185
|
+
const dragging = this.shadowRoot.querySelector(".dragging");
|
|
186
|
+
if (!dragging) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
ev.preventDefault();
|
|
190
|
+
const draggables = [...this.shadowRoot.querySelectorAll(".item-wrapper:not(.dragging)")];
|
|
191
|
+
const initial = { offset: Number.NEGATIVE_INFINITY, element: null };
|
|
192
|
+
const afterItem = draggables.reduce((closest, child) => {
|
|
193
|
+
const box = child.getBoundingClientRect();
|
|
194
|
+
const offset = ev.clientY - box.top - box.height / 2;
|
|
195
|
+
if (offset < 0 && offset > closest.offset) {
|
|
196
|
+
return { offset: offset, element: child };
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return closest;
|
|
200
|
+
}
|
|
201
|
+
}, initial).element;
|
|
202
|
+
draggables.forEach(draggable => draggable.classList.remove("indicator-before", "indicator-after"));
|
|
203
|
+
if (afterItem === null) {
|
|
204
|
+
draggables[draggables.length - 1].classList.add("indicator-after");
|
|
205
|
+
dragging.removeAttribute("data-after-index");
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
afterItem.classList.add("indicator-before");
|
|
209
|
+
const afterIndex = afterItem.getAttribute("data-index");
|
|
210
|
+
dragging.setAttribute("data-after-index", afterIndex);
|
|
211
|
+
}
|
|
34
212
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
213
|
+
_showJson(ev) {
|
|
214
|
+
ev.stopPropagation();
|
|
215
|
+
showJsonEditor(this.title || this.schema.title || "", this.data, ((newValue) => {
|
|
216
|
+
this.handleChange(this.path || "", newValue);
|
|
217
|
+
}));
|
|
38
218
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
219
|
+
doAddItem() {
|
|
220
|
+
if (!this.resolvedSchema) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (this.itemInfos) {
|
|
224
|
+
this.showAddDialog();
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
this.addItem(createDefaultValue(this.resolvedSchema, this.rootSchema));
|
|
228
|
+
}
|
|
44
229
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
230
|
+
showAddDialog() {
|
|
231
|
+
let selectedItemInfo;
|
|
232
|
+
const listItems = this.itemInfos.map((itemInfo, index) => {
|
|
233
|
+
const labelStr = itemInfo.title ? computeLabel(itemInfo.title, false, true) : "";
|
|
234
|
+
return {
|
|
235
|
+
text: labelStr,
|
|
236
|
+
value: labelStr,
|
|
237
|
+
data: itemInfo
|
|
238
|
+
};
|
|
239
|
+
});
|
|
240
|
+
const onParamChanged = (itemInfo) => {
|
|
241
|
+
selectedItemInfo = itemInfo;
|
|
242
|
+
const descElem = dialog.shadowRoot.getElementById("parameter-desc");
|
|
243
|
+
descElem.innerHTML = itemInfo.description || "";
|
|
244
|
+
dialog.shadowRoot.getElementById("add-btn").disabled = false;
|
|
245
|
+
};
|
|
246
|
+
const dialog = showDialog(new OrMwcDialog()
|
|
247
|
+
.setContent(html `
|
|
248
|
+
<div class="col">
|
|
249
|
+
<form id="mdc-dialog-form-add" class="row">
|
|
250
|
+
<div id="type-list" class="col">
|
|
251
|
+
<or-mwc-list @or-mwc-list-changed="${(evt) => { if (evt.detail.length === 1)
|
|
252
|
+
onParamChanged(evt.detail[0].data); }}" .listItems="${listItems.sort((a, b) => a.text.localeCompare(b.text))}" id="parameter-list"></or-mwc-list>
|
|
253
|
+
</div>
|
|
254
|
+
<div id="parameter-desc" class="col"></div>
|
|
255
|
+
</form>
|
|
256
|
+
</div>
|
|
257
|
+
`)
|
|
258
|
+
.setStyles(addItemOrParameterDialogStyle)
|
|
259
|
+
.setHeading((this.label ? computeLabel(this.label, this.required, false) + " - " : "") + i18next.t("addItem"))
|
|
260
|
+
.setActions([
|
|
261
|
+
{
|
|
262
|
+
actionName: "cancel",
|
|
263
|
+
content: "cancel"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
default: true,
|
|
267
|
+
actionName: "add",
|
|
268
|
+
action: () => {
|
|
269
|
+
if (selectedItemInfo) {
|
|
270
|
+
const value = selectedItemInfo.defaultValueCreator();
|
|
271
|
+
this.addItem(value);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
content: html `<or-mwc-input id="add-btn" .type="${InputType.BUTTON}" disabled label="add"></or-mwc-input>`
|
|
275
|
+
}
|
|
276
|
+
])
|
|
277
|
+
.setDismissAction(null));
|
|
50
278
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
</div>
|
|
61
|
-
<div id="header-buttons"><or-mwc-input .type="${f.BUTTON}" outlined label="json" icon="pencil" @or-mwc-input-changed="${e=>this._showJson(e)}"></or-mwc-input></div>
|
|
62
|
-
</div>
|
|
63
|
-
`,s=n`
|
|
64
|
-
${a}
|
|
65
|
-
<div id="content-wrapper" slot="content">
|
|
66
|
-
<div id="content" @dragover="${e=>this._onDragOver(e)}">
|
|
67
|
-
|
|
68
|
-
${!Array.isArray(this.data)?"":this.data.map((e,t)=>{let r=i.compose(this.path,""+t),o={renderers:this.renderers,uischema:c("#"),schema:this.resolvedSchema,path:r};return this.getArrayItemWrapper(h(this.state,o)||n``,t)})}
|
|
69
|
-
|
|
70
|
-
</div>
|
|
71
|
-
${this.errors?"":n`
|
|
72
|
-
<div id="footer">
|
|
73
|
-
<or-mwc-input .disabled="${o&&o>=r}" .type="${f.BUTTON}" label="addItem" icon="plus" @or-mwc-input-changed="${()=>this.doAddItem()}"></or-mwc-input>
|
|
74
|
-
</div>
|
|
75
|
-
`}
|
|
76
|
-
</div>
|
|
77
|
-
`;return this.minimal?n`<div>${s}</div>`:n`<or-collapsible-panel>${s}</or-collapsible-panel>`}getArrayItemWrapper(e,t){return n`
|
|
78
|
-
<div class="item-wrapper" data-index="${t}">
|
|
79
|
-
<div class="drag-container">
|
|
80
|
-
<button draggable="true" @dragstart="${e=>this._onDragStart(e)}" @dragend="${e=>this._onDragEnd(e)}" class="draggable button-clear"><or-icon icon="menu"></or-icon></input>
|
|
81
|
-
</div>
|
|
82
|
-
${E(e,()=>this.removeItem(t))}
|
|
83
|
-
</div>
|
|
84
|
-
`}_onDragStart(e){let t=e.currentTarget.parentElement.parentElement;t.classList.add("dragging");let r=t.lastElementChild;e.dataTransfer.setDragImage(r,r.getBoundingClientRect().width/2-50,0)}_onDragEnd(e){let t=[...this.shadowRoot.querySelectorAll(".item-wrapper")],r=e.currentTarget.parentElement.parentElement;r.classList.remove("dragging");let i=Number(r.getAttribute("data-index")),o=Math.max(0,(null!==r.getAttribute("data-after-index")?Number(r.getAttribute("data-after-index")):t.length)-1);t.forEach(e=>e.classList.remove("indicator-before","indicator-after")),i!==o&&this.moveItem(i,o)}_onDragOver(e){let t=this.shadowRoot.querySelector(".dragging");if(!t)return;e.preventDefault();let r=[...this.shadowRoot.querySelectorAll(".item-wrapper:not(.dragging)")],i=r.reduce((t,r)=>{let i=r.getBoundingClientRect(),o=e.clientY-i.top-i.height/2;return o<0&&o>t.offset?{offset:o,element:r}:t},{offset:-1/0,element:null}).element;if(r.forEach(e=>e.classList.remove("indicator-before","indicator-after")),null===i)r[r.length-1].classList.add("indicator-after"),t.removeAttribute("data-after-index");else{i.classList.add("indicator-before");let e=i.getAttribute("data-index");t.setAttribute("data-after-index",e)}}_showJson(e){e.stopPropagation(),g(this.title||this.schema.title||"",this.data,e=>{this.handleChange(this.path||"",e)})}doAddItem(){this.resolvedSchema&&(this.itemInfos?this.showAddDialog():this.addItem(t(this.resolvedSchema,this.rootSchema)))}showAddDialog(){let t,r=this.itemInfos.map((t,r)=>{let i=t.title?e(t.title,!1,!0):"";return{text:i,value:i,data:t}}),i=b(new v().setContent(n`
|
|
85
|
-
<div class="col">
|
|
86
|
-
<form id="mdc-dialog-form-add" class="row">
|
|
87
|
-
<div id="type-list" class="col">
|
|
88
|
-
<or-mwc-list @or-mwc-list-changed="${e=>{var r;1===e.detail.length&&(t=r=e.detail[0].data,i.shadowRoot.getElementById("parameter-desc").innerHTML=r.description||"",i.shadowRoot.getElementById("add-btn").disabled=!1)}}" .listItems="${r.sort((e,t)=>e.text.localeCompare(t.text))}" id="parameter-list"></or-mwc-list>
|
|
89
|
-
</div>
|
|
90
|
-
<div id="parameter-desc" class="col"></div>
|
|
91
|
-
</form>
|
|
92
|
-
</div>
|
|
93
|
-
`).setStyles(w).setHeading((this.label?e(this.label,this.required,!1)+" - ":"")+u.t("addItem")).setActions([{actionName:"cancel",content:"cancel"},{default:!0,actionName:"add",action:()=>{if(t){let e=t.defaultValueCreator();this.addItem(e)}},content:n`<or-mwc-input id="add-btn" .type="${f.BUTTON}" disabled label="add"></or-mwc-input>`}]).setDismissAction(null))}};__decorate([m()],ControlArrayElement.prototype,"minimal",void 0),ControlArrayElement=__decorate([l("or-json-forms-array-control")],ControlArrayElement);export{ControlArrayElement};
|
|
279
|
+
};
|
|
280
|
+
__decorate([
|
|
281
|
+
property()
|
|
282
|
+
], ControlArrayElement.prototype, "minimal", void 0);
|
|
283
|
+
ControlArrayElement = __decorate([
|
|
284
|
+
customElement("or-json-forms-array-control")
|
|
285
|
+
], ControlArrayElement);
|
|
286
|
+
export { ControlArrayElement };
|
|
287
|
+
//# sourceMappingURL=control-array-element.js.map
|
|
@@ -1 +1,48 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { createId, isControl, mapDispatchToControlProps, removeId } from "@jsonforms/core";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import { BaseElement } from "../base-element";
|
|
10
|
+
export class ControlBaseElement extends BaseElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
}
|
|
14
|
+
updated(_changedProperties) {
|
|
15
|
+
super.updated(_changedProperties);
|
|
16
|
+
if (_changedProperties.has("state")) {
|
|
17
|
+
const { handleChange } = mapDispatchToControlProps(this.state.dispatch);
|
|
18
|
+
this.handleChange = handleChange;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
shouldUpdate(changedProperties) {
|
|
22
|
+
var _a;
|
|
23
|
+
if (changedProperties.has("uischema")) {
|
|
24
|
+
if (isControl(this.uischema)) {
|
|
25
|
+
const oldSchemaValue = changedProperties.get("uischema");
|
|
26
|
+
if ((oldSchemaValue === null || oldSchemaValue === void 0 ? void 0 : oldSchemaValue.scope) !== ((_a = this.uischema) === null || _a === void 0 ? void 0 : _a.scope)) {
|
|
27
|
+
if (this.id) {
|
|
28
|
+
removeId(this.id);
|
|
29
|
+
}
|
|
30
|
+
this.id = createId(this.uischema.scope);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
if (isControl(this.uischema)) {
|
|
38
|
+
removeId(this.id);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
__decorate([
|
|
43
|
+
property()
|
|
44
|
+
], ControlBaseElement.prototype, "description", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
property()
|
|
47
|
+
], ControlBaseElement.prototype, "rootSchema", void 0);
|
|
48
|
+
//# sourceMappingURL=control-base-element.js.map
|