@pacem/pacem-scaffolding 1.0.0-abel
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 +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-scaffolding.js +10430 -0
- package/dist/browser/pacem-scaffolding.js.map +1 -0
- package/dist/browser/pacem-scaffolding.min.js +2 -0
- package/dist/browser/pacem-scaffolding.min.js.map +1 -0
- package/dist/bundle/pacem-scaffolding.min.mjs +380 -0
- package/dist/bundle/pacem-scaffolding.mjs +10046 -0
- package/dist/bundle/pacem-scaffolding.mjs.map +7 -0
- package/dist/esm/calendar-picker.js +478 -0
- package/dist/esm/char-counter.js +43 -0
- package/dist/esm/checkbox-list.js +75 -0
- package/dist/esm/checkbox.js +112 -0
- package/dist/esm/childform.js +237 -0
- package/dist/esm/contenteditable.js +326 -0
- package/dist/esm/datetime-picker.js +310 -0
- package/dist/esm/form.js +630 -0
- package/dist/esm/formfield.js +1065 -0
- package/dist/esm/geolocate.js +197 -0
- package/dist/esm/hierarchy.js +509 -0
- package/dist/esm/index-components-scaffolding.js +39 -0
- package/dist/esm/index-components.js +1 -0
- package/dist/esm/index-iife.js +3 -0
- package/dist/esm/index-root.js +2 -0
- package/dist/esm/index-scaffolding.js +3 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/input-chars.js +185 -0
- package/dist/esm/input-color.js +80 -0
- package/dist/esm/input-email.js +32 -0
- package/dist/esm/input-file.js +691 -0
- package/dist/esm/input-hidden.js +25 -0
- package/dist/esm/input-image.js +391 -0
- package/dist/esm/input-number.js +58 -0
- package/dist/esm/input-password.js +71 -0
- package/dist/esm/input-search.js +27 -0
- package/dist/esm/input-tel.js +31 -0
- package/dist/esm/input-text.js +36 -0
- package/dist/esm/input-url.js +32 -0
- package/dist/esm/input.js +215 -0
- package/dist/esm/l10n.js +66 -0
- package/dist/esm/latlng.js +178 -0
- package/dist/esm/namevalue-list.js +139 -0
- package/dist/esm/property-picker.js +84 -0
- package/dist/esm/radio-list.js +70 -0
- package/dist/esm/radio.js +79 -0
- package/dist/esm/select.js +126 -0
- package/dist/esm/slider.js +284 -0
- package/dist/esm/snapshot.js +325 -0
- package/dist/esm/suggest.js +545 -0
- package/dist/esm/tags.js +174 -0
- package/dist/esm/textarea-markdown.js +75 -0
- package/dist/esm/textarea.js +51 -0
- package/dist/esm/types-components.js +611 -0
- package/dist/esm/types.js +8 -0
- package/dist/esm/validators.js +409 -0
- package/package.json +38 -0
- package/typings/index.d.ts +2283 -0
|
@@ -0,0 +1,509 @@
|
|
|
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 { Components, PropertyConverters, Utils, P, PCSS, CustomElement, Watch, Defaults, ViewChild, CustomEventUtils, CustomElementUtils, avoidHandler, UI } from '@pacem/pacem-core';
|
|
8
|
+
import { Components as ComponentsUI } from '@pacem/pacem-ui';
|
|
9
|
+
import { PacemBaseElement } from './types-components';
|
|
10
|
+
//namespace Components.Scaffolding {
|
|
11
|
+
class HierarchyChangeEvent extends CustomEvent {
|
|
12
|
+
constructor(v) {
|
|
13
|
+
super('hierarchychange', { detail: v, bubbles: false, cancelable: false });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const HIERARCHYITEM_CSSCLASS = 'hierarchy-item';
|
|
17
|
+
const HIERARCHYITEM_CSSCLASS_FULL = HIERARCHYITEM_CSSCLASS + ' ' + PCSS + '-anim anim-fade-in anim-sudden';
|
|
18
|
+
const HIERARCHYITEM_CSSCLASS_ATTR = "{{ { 'item-disabled' : ^item.disabled } }}";
|
|
19
|
+
const BINDER_HIERARCHYDATAKEY = 'pacemHierarchy';
|
|
20
|
+
const HIERARCHYITEM_CONTENT_CSSCLASS = 'item-content';
|
|
21
|
+
const HIERARCHYITEM_LINK_CSSCLASS = 'item-link';
|
|
22
|
+
const HIERARCHYITEM_LINK_CSSCLASS_FULL = HIERARCHYITEM_LINK_CSSCLASS + ' icon-rotate rotate-135';
|
|
23
|
+
const HIERARCHYITEM_LINK_ICON = 'link';
|
|
24
|
+
const HIERARCHYITEM_MOVE_CSSCLASS = 'item-move';
|
|
25
|
+
const HIERARCHYITEM_MOVE_ICON = 'drag_indicator';
|
|
26
|
+
const DEFAULT_PARENTSPROPERTY = 'parents';
|
|
27
|
+
let PacemHierarchyElement = class PacemHierarchyElement extends PacemBaseElement {
|
|
28
|
+
getViewValue(value) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
convertValueAttributeToProperty(attr) {
|
|
32
|
+
return Utils.Json.parse(attr);
|
|
33
|
+
}
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
this.#bindings = new Map();
|
|
37
|
+
this.#dropTargets = new Map();
|
|
38
|
+
this.unlinkCaption = 'Delete';
|
|
39
|
+
this._binderClickHandler = (evt) => {
|
|
40
|
+
const origType = evt.originalEvent.type;
|
|
41
|
+
if (origType === 'mousedown' && evt.originalEvent.button === 1) {
|
|
42
|
+
avoidHandler(evt.originalEvent);
|
|
43
|
+
const binder = evt.srcElement;
|
|
44
|
+
this._unlink(binder);
|
|
45
|
+
}
|
|
46
|
+
else if (origType === 'click' || origType === 'contextmenu') {
|
|
47
|
+
avoidHandler(evt.originalEvent);
|
|
48
|
+
this.#unlinkingBinder = evt.srcElement;
|
|
49
|
+
const balloon = this._balloon;
|
|
50
|
+
balloon.target = { x: evt.pageX, y: evt.pageY };
|
|
51
|
+
balloon.popup();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
// #region drag-drop
|
|
55
|
+
this._dragInitHandler = (evt) => {
|
|
56
|
+
let args = evt.detail;
|
|
57
|
+
const dragger = this._dragger;
|
|
58
|
+
dragger.floater = document.createElement('span');
|
|
59
|
+
dragger.dropTargets = Array.from(this.#dropTargets.keys()).filter(i => i !== args.element);
|
|
60
|
+
if (!Utils.isNull(this.#dragBinder)) {
|
|
61
|
+
this.#dragBinder.remove();
|
|
62
|
+
}
|
|
63
|
+
const binder = this.#dragBinder = new ComponentsUI.UI.PacemBinderElement();
|
|
64
|
+
binder.from = args.element;
|
|
65
|
+
this.#shell.appendChild(binder);
|
|
66
|
+
};
|
|
67
|
+
this._dragStartHandler = (evt) => {
|
|
68
|
+
Utils.addClass(evt.detail.element, 'item-drag');
|
|
69
|
+
};
|
|
70
|
+
this._dragHandler = (evt) => {
|
|
71
|
+
this.#dragBinder.to = evt.detail.currentPosition;
|
|
72
|
+
};
|
|
73
|
+
this._dragEndHandler = (evt) => {
|
|
74
|
+
Utils.removeClass(evt.detail.element, 'item-drag');
|
|
75
|
+
this.#dragBinder.remove();
|
|
76
|
+
this.#dragBinder = null;
|
|
77
|
+
};
|
|
78
|
+
this._dropHandler = (evt) => {
|
|
79
|
+
const source = evt.detail.data, target = this.#dropTargets.get(evt.detail.target);
|
|
80
|
+
// set source as a parent of target
|
|
81
|
+
// just in case (double-check)
|
|
82
|
+
if (!this._isInAncestors(source, target) && !this._isInDescendants(source, target)) {
|
|
83
|
+
// set new relation
|
|
84
|
+
this._compileHierarchy({ source, target });
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this._dragOverHandler = (evt) => {
|
|
88
|
+
const source = evt.detail.data, target = this.#dropTargets.get(evt.detail.target);
|
|
89
|
+
if (target.disabled || this._isInAncestors(source, target) || this._isInDescendants(source, target)) {
|
|
90
|
+
evt.preventDefault();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
this._dragOutHandler = (evt) => {
|
|
94
|
+
};
|
|
95
|
+
// #endregion
|
|
96
|
+
// #region balloon
|
|
97
|
+
this._popoutHandler = (evt) => {
|
|
98
|
+
this._balloon.popout();
|
|
99
|
+
};
|
|
100
|
+
this.#key = Utils.uniqueCode();
|
|
101
|
+
}
|
|
102
|
+
#key;
|
|
103
|
+
#bindings;
|
|
104
|
+
#dragBinder;
|
|
105
|
+
#unlinkingBinder;
|
|
106
|
+
#dropTargets;
|
|
107
|
+
#shell;
|
|
108
|
+
get inputFields() {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
toggleReadonlyView(readonly) {
|
|
112
|
+
this._dragger.disabled = readonly;
|
|
113
|
+
if (!Utils.isNull(this._adaptedDatasource)) {
|
|
114
|
+
this._databind();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
onChange(evt) {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
if (CustomEventUtils.isInstanceOf(evt, HierarchyChangeEvent)) {
|
|
120
|
+
resolve(this.value = evt.detail);
|
|
121
|
+
}
|
|
122
|
+
resolve(this.value);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
acceptValue(val) {
|
|
126
|
+
// nothing peculiar to do...
|
|
127
|
+
}
|
|
128
|
+
viewActivatedCallback() {
|
|
129
|
+
super.viewActivatedCallback();
|
|
130
|
+
this.#shell = CustomElementUtils.findAncestorShell(this);
|
|
131
|
+
this._setupItemTemplate();
|
|
132
|
+
this._setupDragger();
|
|
133
|
+
this._setupBalloon();
|
|
134
|
+
}
|
|
135
|
+
propertyChangedCallback(name, old, val, first) {
|
|
136
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
137
|
+
switch (name) {
|
|
138
|
+
case 'datasource':
|
|
139
|
+
case 'textProperty':
|
|
140
|
+
case 'disabledProperty':
|
|
141
|
+
case 'valueProperty':
|
|
142
|
+
cancelAnimationFrame(this._handle);
|
|
143
|
+
this._handle = requestAnimationFrame(() => {
|
|
144
|
+
this._buildAdaptedDatasource();
|
|
145
|
+
});
|
|
146
|
+
break;
|
|
147
|
+
case 'itemtemplate':
|
|
148
|
+
if (!first) {
|
|
149
|
+
this._setupItemTemplate();
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case '_adaptedDatasource':
|
|
153
|
+
case 'value':
|
|
154
|
+
cancelAnimationFrame(this._handle2);
|
|
155
|
+
this._handle2 = requestAnimationFrame(() => {
|
|
156
|
+
this._databind();
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
disconnectedCallback() {
|
|
162
|
+
this._disposeDragger();
|
|
163
|
+
this._disposeBalloon();
|
|
164
|
+
super.disconnectedCallback();
|
|
165
|
+
}
|
|
166
|
+
_buildAdaptedDatasource(ds = this.datasource) {
|
|
167
|
+
this._adaptedDatasource = ds && ds.map(i => this._mapEntityToItem(i));
|
|
168
|
+
}
|
|
169
|
+
_mapEntityToValue(entity) {
|
|
170
|
+
let value = entity, prop;
|
|
171
|
+
if (prop = this.valueProperty) {
|
|
172
|
+
value = entity[prop];
|
|
173
|
+
}
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
_mapEntityToViewValue(entity) {
|
|
177
|
+
let viewValue = entity.toString(), prop;
|
|
178
|
+
if (prop = this.textProperty) {
|
|
179
|
+
viewValue = entity[prop];
|
|
180
|
+
}
|
|
181
|
+
return viewValue;
|
|
182
|
+
}
|
|
183
|
+
_mapEntityToItem(entity) {
|
|
184
|
+
if (entity == null) {
|
|
185
|
+
throw new Error('Entity cannot be null');
|
|
186
|
+
}
|
|
187
|
+
// databound
|
|
188
|
+
let disabled = false;
|
|
189
|
+
const disabledProp = this.disabledProperty;
|
|
190
|
+
if (!Utils.isNullOrEmpty(disabledProp)) {
|
|
191
|
+
disabled = entity[disabledProp] || false;
|
|
192
|
+
}
|
|
193
|
+
return { value: this._mapEntityToValue(entity), viewValue: this._mapEntityToViewValue(entity), disabled: disabled, data: entity };
|
|
194
|
+
}
|
|
195
|
+
_unlink(arg) {
|
|
196
|
+
var binder;
|
|
197
|
+
if (arg instanceof ComponentsUI.UI.PacemBinderElement) {
|
|
198
|
+
binder = arg;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
arg.preventDefault();
|
|
202
|
+
arg.stopPropagation();
|
|
203
|
+
binder = this.#unlinkingBinder;
|
|
204
|
+
}
|
|
205
|
+
const { parent, child } = JSON.parse(binder.dataset[BINDER_HIERARCHYDATAKEY]);
|
|
206
|
+
const ds = this._adaptedDatasource, source = ds.find(i => i.value === parent), target = ds.find(i => i.value === child);
|
|
207
|
+
if (!source.disabled && !target.disabled) {
|
|
208
|
+
this._compileHierarchy({ source, target }, true);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
_buildHierarchyItemDomId(itemId) {
|
|
212
|
+
return `hierarchyitem_${this.#key}_${itemId}`;
|
|
213
|
+
}
|
|
214
|
+
_itemCreate(evt) {
|
|
215
|
+
const item = evt.detail.dom.find(i => i instanceof HTMLElement && i.classList.contains(HIERARCHYITEM_CSSCLASS)), index = evt.detail.index, hierarchyItem = evt.detail.item;
|
|
216
|
+
item.id = this._buildHierarchyItemDomId(hierarchyItem.value);
|
|
217
|
+
if (hierarchyItem.disabled) {
|
|
218
|
+
item.setAttribute('behaviors', '{{ [#' + this._dragger2.id + '] }}');
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
item.setAttribute('behaviors', '{{ [#' + this._dragger.id + ', #' + this._dragger2.id + '] }}');
|
|
222
|
+
}
|
|
223
|
+
for (let parent of hierarchyItem.parents || []) {
|
|
224
|
+
const binder = new ComponentsUI.UI.PacemBinderElement();
|
|
225
|
+
binder.to = item;
|
|
226
|
+
binder.toAnchor = ComponentsUI.UI.BinderAnchor.Top;
|
|
227
|
+
binder.toEnd = ComponentsUI.UI.BinderEnd.Arrow;
|
|
228
|
+
binder.setAttribute('from', '{{ #' + this._buildHierarchyItemDomId(parent.value) + ' }}');
|
|
229
|
+
binder.fromAnchor = ComponentsUI.UI.BinderAnchor.Bottom;
|
|
230
|
+
binder.cssClass = ['hierarchy-binder'];
|
|
231
|
+
binder.interactive = !this.readonly && !hierarchyItem.disabled && !parent.disabled;
|
|
232
|
+
binder.addEventListener(ComponentsUI.UI.BinderInteractionEventName, this._binderClickHandler, false);
|
|
233
|
+
binder.dataset[BINDER_HIERARCHYDATAKEY] = JSON.stringify({ parent: parent.value, child: hierarchyItem.value });
|
|
234
|
+
this.#bindings.set(hierarchyItem.value, binder);
|
|
235
|
+
this.#shell.appendChild(binder);
|
|
236
|
+
}
|
|
237
|
+
if (!this.#dropTargets.has(item)) {
|
|
238
|
+
this.#dropTargets.set(item, hierarchyItem);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
_itemRemove(evt) {
|
|
242
|
+
const item = evt.detail.dom.find(i => i instanceof HTMLElement && i.classList.contains(HIERARCHYITEM_CSSCLASS)), hierarchyItem = evt.detail.item, bindings = this.#bindings;
|
|
243
|
+
if (bindings.has(hierarchyItem.value)) {
|
|
244
|
+
const binder = bindings.get(hierarchyItem.value);
|
|
245
|
+
binder.removeEventListener(ComponentsUI.UI.BinderInteractionEventName, this._binderClickHandler, false);
|
|
246
|
+
binder.remove();
|
|
247
|
+
bindings.delete(hierarchyItem.value);
|
|
248
|
+
}
|
|
249
|
+
if (this.#dropTargets.has(item)) {
|
|
250
|
+
this.#dropTargets.delete(item);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
_setupItemTemplate() {
|
|
254
|
+
if (this.itemtemplate instanceof HTMLTemplateElement) {
|
|
255
|
+
const frag = this.itemtemplate.cloneNode(true).content;
|
|
256
|
+
const tmpl = document.createElement('template');
|
|
257
|
+
const wrapper = document.createElement(P + '-panel');
|
|
258
|
+
wrapper.className = HIERARCHYITEM_CSSCLASS_FULL;
|
|
259
|
+
wrapper.setAttribute('css-class', HIERARCHYITEM_CSSCLASS_ATTR);
|
|
260
|
+
const move = new ComponentsUI.UI.PacemIconElement();
|
|
261
|
+
move.setAttribute('icon', HIERARCHYITEM_MOVE_ICON);
|
|
262
|
+
move.className = HIERARCHYITEM_MOVE_CSSCLASS;
|
|
263
|
+
wrapper.appendChild(move);
|
|
264
|
+
const content = document.createElement('div');
|
|
265
|
+
content.className = HIERARCHYITEM_CONTENT_CSSCLASS;
|
|
266
|
+
content.append(frag);
|
|
267
|
+
wrapper.appendChild(content);
|
|
268
|
+
const link = new ComponentsUI.UI.PacemIconElement();
|
|
269
|
+
link.setAttribute('icon', HIERARCHYITEM_LINK_ICON);
|
|
270
|
+
link.className = HIERARCHYITEM_LINK_CSSCLASS_FULL;
|
|
271
|
+
wrapper.appendChild(link);
|
|
272
|
+
tmpl.content.appendChild(wrapper);
|
|
273
|
+
this._template = tmpl;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this._template = this._defaultTemplate;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
_compileHierarchy(relation, remove = false) {
|
|
280
|
+
const value = /* clone to detach any referemce with the original value, thus allowing `reset` */ Utils.clone(this.value || []);
|
|
281
|
+
const newParent = relation.source.value, newChild = relation.target.value;
|
|
282
|
+
const parentsProperty = this.parentsProperty || DEFAULT_PARENTSPROPERTY;
|
|
283
|
+
var found = value.find(i => i[this.valueProperty] === newChild);
|
|
284
|
+
if (remove) {
|
|
285
|
+
if (!Utils.isNull(found)) {
|
|
286
|
+
const parents = found[parentsProperty] || [], ndx = parents.indexOf(newParent);
|
|
287
|
+
if (ndx >= 0) {
|
|
288
|
+
parents.splice(ndx, 1);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
if (Utils.isNull(found)) {
|
|
294
|
+
found = {};
|
|
295
|
+
found[this.valueProperty] = newChild;
|
|
296
|
+
found[parentsProperty] = [];
|
|
297
|
+
value.push(found);
|
|
298
|
+
}
|
|
299
|
+
found[parentsProperty].push(newParent);
|
|
300
|
+
}
|
|
301
|
+
// cleanup
|
|
302
|
+
this._cleanupHierarchy(value);
|
|
303
|
+
//
|
|
304
|
+
this.changeHandler(new HierarchyChangeEvent(value));
|
|
305
|
+
}
|
|
306
|
+
_cleanupHierarchy(value = []) {
|
|
307
|
+
const valueProperty = this.valueProperty, parentsProperty = this.parentsProperty || DEFAULT_PARENTSPROPERTY;
|
|
308
|
+
const isInAncestors = (sourceId, targetId) => {
|
|
309
|
+
const target = value.find(i => i[valueProperty] == targetId);
|
|
310
|
+
if (Utils.isNull(target) || Utils.isNullOrEmpty(target[parentsProperty])) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
const parents = target[parentsProperty];
|
|
314
|
+
if (parents.indexOf(sourceId) >= 0) {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
return parents.some(p => isInAncestors(sourceId, p));
|
|
318
|
+
};
|
|
319
|
+
// bottom-up: if a parent is also an ancestor, then remove the link
|
|
320
|
+
for (let v of value) {
|
|
321
|
+
const parents = v[parentsProperty] || [];
|
|
322
|
+
for (let j = parents.length - 1; j >= 0; j--) {
|
|
323
|
+
const parent = parents[j];
|
|
324
|
+
const otherParents = parents.filter(p0 => p0 !== parent);
|
|
325
|
+
for (let otherParent of otherParents) {
|
|
326
|
+
if (isInAncestors(parent, otherParent)) {
|
|
327
|
+
parents.splice(j, 1);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
_setupDragger() {
|
|
335
|
+
const dragger = this._dragger;
|
|
336
|
+
dragger.id = 'hierarchy_link_' + this.#key;
|
|
337
|
+
dragger.handleSelector = '.' + HIERARCHYITEM_LINK_CSSCLASS;
|
|
338
|
+
dragger.dropBehavior = UI.DropBehavior.None;
|
|
339
|
+
dragger.spillBehavior = UI.DropTargetMissedBehavior.None;
|
|
340
|
+
dragger.mode = UI.DragDataMode.Copy;
|
|
341
|
+
dragger.addEventListener(UI.DragDropEventType.Drop, this._dropHandler, false);
|
|
342
|
+
dragger.addEventListener(UI.DragDropEventType.Drag, this._dragHandler, false);
|
|
343
|
+
dragger.addEventListener(UI.DragDropEventType.Init, this._dragInitHandler, false);
|
|
344
|
+
dragger.addEventListener(UI.DragDropEventType.Start, this._dragStartHandler, false);
|
|
345
|
+
dragger.addEventListener(UI.DragDropEventType.End, this._dragEndHandler, false);
|
|
346
|
+
dragger.addEventListener(UI.DragDropEventType.Over, this._dragOverHandler, false);
|
|
347
|
+
dragger.addEventListener(UI.DragDropEventType.Out, this._dragOutHandler, false);
|
|
348
|
+
const dragger2 = this._dragger2;
|
|
349
|
+
dragger2.id = 'hierarchy_move_' + this.#key;
|
|
350
|
+
dragger2.mode = UI.DragDataMode.Self;
|
|
351
|
+
dragger2.dropBehavior = UI.DropBehavior.None;
|
|
352
|
+
dragger2.spillBehavior = UI.DropTargetMissedBehavior.None;
|
|
353
|
+
dragger2.handleSelector = '.' + HIERARCHYITEM_MOVE_CSSCLASS;
|
|
354
|
+
}
|
|
355
|
+
_disposeDragger() {
|
|
356
|
+
const dragger = this._dragger;
|
|
357
|
+
if (!Utils.isNull(dragger)) {
|
|
358
|
+
dragger.removeEventListener(UI.DragDropEventType.Drop, this._dropHandler, false);
|
|
359
|
+
dragger.removeEventListener(UI.DragDropEventType.Drag, this._dragHandler, false);
|
|
360
|
+
dragger.removeEventListener(UI.DragDropEventType.Init, this._dragInitHandler, false);
|
|
361
|
+
dragger.removeEventListener(UI.DragDropEventType.Start, this._dragStartHandler, false);
|
|
362
|
+
dragger.removeEventListener(UI.DragDropEventType.End, this._dragEndHandler, false);
|
|
363
|
+
dragger.removeEventListener(UI.DragDropEventType.Over, this._dragOverHandler, false);
|
|
364
|
+
dragger.removeEventListener(UI.DragDropEventType.Out, this._dragOutHandler, false);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
_setupBalloon() {
|
|
368
|
+
this._balloon = this._shellProxy.dom.find(i => i instanceof ComponentsUI.UI.PacemBalloonElement);
|
|
369
|
+
window.addEventListener('mousedown', this._popoutHandler, false);
|
|
370
|
+
}
|
|
371
|
+
_disposeBalloon() {
|
|
372
|
+
window.removeEventListener('mousedown', this._popoutHandler, false);
|
|
373
|
+
}
|
|
374
|
+
// #endregion
|
|
375
|
+
_isInAncestors(source, target) {
|
|
376
|
+
if (Utils.isNull(target) || Utils.isNullOrEmpty(target.parents)) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
if (target.parents.indexOf(source) >= 0) {
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
return target.parents.some(p => this._isInAncestors(source, p));
|
|
383
|
+
}
|
|
384
|
+
_isInDescendants(source, target) {
|
|
385
|
+
return this._isInAncestors(target, source);
|
|
386
|
+
}
|
|
387
|
+
_databind() {
|
|
388
|
+
// clear binders
|
|
389
|
+
this._repeater.datasource = [];
|
|
390
|
+
// check value property
|
|
391
|
+
const valueProperty = this.valueProperty;
|
|
392
|
+
if (Utils.isNullOrEmpty(valueProperty)) {
|
|
393
|
+
throw new Error('Missing valueProperty.');
|
|
394
|
+
}
|
|
395
|
+
// merge datasource and value
|
|
396
|
+
const ds = Utils.clone(this._adaptedDatasource || []), mapping = this.value || [], parentsProperty = this.parentsProperty || DEFAULT_PARENTSPROPERTY;
|
|
397
|
+
for (let item of ds) {
|
|
398
|
+
const found = mapping.find(i => i[valueProperty] === item.value);
|
|
399
|
+
if (!Utils.isNull(found)) {
|
|
400
|
+
item.parents = (found[parentsProperty] || []).map(i => ds.find(i0 => i0.value === i)).filter(i => !Utils.isNull(i));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// layerize and bind to repeater
|
|
404
|
+
this._databindByParents(ds);
|
|
405
|
+
}
|
|
406
|
+
_databindByParents(ds) {
|
|
407
|
+
// naive algo:
|
|
408
|
+
// find topmost then loop-find direct-only children until no more descendant remains.
|
|
409
|
+
const levelMatrix = [];
|
|
410
|
+
function count() {
|
|
411
|
+
return levelMatrix.reduce((previousLength, item) => previousLength + item.length, 0);
|
|
412
|
+
}
|
|
413
|
+
do {
|
|
414
|
+
if (Utils.isNullOrEmpty(levelMatrix)) {
|
|
415
|
+
// topmost
|
|
416
|
+
const topmost = ds.filter((i) => Utils.isNullOrEmpty(i.parents));
|
|
417
|
+
levelMatrix.push(topmost);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
// other levels
|
|
421
|
+
const upperLevels = Array.prototype.concat.apply([], levelMatrix), upperLevel = levelMatrix[levelMatrix.length - 1];
|
|
422
|
+
const level = ds.filter((i) => {
|
|
423
|
+
if (Utils.isNullOrEmpty(i.parents)) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
return i.parents.every(p => upperLevels.indexOf(p) >= 0) && i.parents.some(p => upperLevel.indexOf(p) >= 0);
|
|
427
|
+
});
|
|
428
|
+
levelMatrix.push(level);
|
|
429
|
+
}
|
|
430
|
+
} while (count() < ds.length);
|
|
431
|
+
// databind
|
|
432
|
+
this._repeater.datasource = levelMatrix;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
__decorate([
|
|
436
|
+
ViewChild('template[default]')
|
|
437
|
+
], PacemHierarchyElement.prototype, "_defaultTemplate", void 0);
|
|
438
|
+
__decorate([
|
|
439
|
+
ViewChild(P + '-repeater')
|
|
440
|
+
], PacemHierarchyElement.prototype, "_repeater", void 0);
|
|
441
|
+
__decorate([
|
|
442
|
+
ViewChild(P + '-drag-drop')
|
|
443
|
+
], PacemHierarchyElement.prototype, "_dragger", void 0);
|
|
444
|
+
__decorate([
|
|
445
|
+
ViewChild(P + '-drag-drop[move]')
|
|
446
|
+
], PacemHierarchyElement.prototype, "_dragger2", void 0);
|
|
447
|
+
__decorate([
|
|
448
|
+
ViewChild(P + '-shell-proxy')
|
|
449
|
+
], PacemHierarchyElement.prototype, "_shellProxy", void 0);
|
|
450
|
+
__decorate([
|
|
451
|
+
Watch({ emit: false, converter: PropertyConverters.Json })
|
|
452
|
+
], PacemHierarchyElement.prototype, "datasource", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
455
|
+
], PacemHierarchyElement.prototype, "valueProperty", void 0);
|
|
456
|
+
__decorate([
|
|
457
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
458
|
+
], PacemHierarchyElement.prototype, "textProperty", void 0);
|
|
459
|
+
__decorate([
|
|
460
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
461
|
+
], PacemHierarchyElement.prototype, "disabledProperty", void 0);
|
|
462
|
+
__decorate([
|
|
463
|
+
Watch({ converter: PropertyConverters.String })
|
|
464
|
+
], PacemHierarchyElement.prototype, "unlinkCaption", void 0);
|
|
465
|
+
__decorate([
|
|
466
|
+
Watch({ converter: PropertyConverters.Json })
|
|
467
|
+
], PacemHierarchyElement.prototype, "_adaptedDatasource", void 0);
|
|
468
|
+
__decorate([
|
|
469
|
+
Watch({ emit: false, converter: PropertyConverters.Element })
|
|
470
|
+
], PacemHierarchyElement.prototype, "itemtemplate", void 0);
|
|
471
|
+
__decorate([
|
|
472
|
+
Watch({ converter: PropertyConverters.Element })
|
|
473
|
+
], PacemHierarchyElement.prototype, "_template", void 0);
|
|
474
|
+
__decorate([
|
|
475
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
476
|
+
], PacemHierarchyElement.prototype, "parentsProperty", void 0);
|
|
477
|
+
PacemHierarchyElement = __decorate([
|
|
478
|
+
CustomElement({
|
|
479
|
+
tagName: P + '-hierarchy', shadow: Defaults.USE_SHADOW_ROOT,
|
|
480
|
+
template: `<${P}-repeater>
|
|
481
|
+
<template>
|
|
482
|
+
<${P}-repeater on-${Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">
|
|
483
|
+
<div class="hierarchy-level">
|
|
484
|
+
<${P}-template-proxy target="{{ :host._template }}"></${P}-template-proxy>
|
|
485
|
+
</div>
|
|
486
|
+
</${P}-repeater>
|
|
487
|
+
</template>
|
|
488
|
+
</div>
|
|
489
|
+
</${P}-repeater><${P}-content></${P}-content>
|
|
490
|
+
<${P}-drag-drop></${P}-drag-drop>
|
|
491
|
+
<${P}-drag-drop move></${P}-drag-drop>
|
|
492
|
+
<template default>
|
|
493
|
+
<${P}-panel class="${HIERARCHYITEM_CSSCLASS_FULL} item-default" css-class="${HIERARCHYITEM_CSSCLASS_ATTR}">
|
|
494
|
+
<${P}-icon class="${HIERARCHYITEM_MOVE_CSSCLASS}" icon="${HIERARCHYITEM_MOVE_ICON}"></${P}-icon>
|
|
495
|
+
<pacem-span class="${HIERARCHYITEM_CONTENT_CSSCLASS}" content="{{ ^item.viewValue }}"></${P}-span>
|
|
496
|
+
<${P}-icon class="${HIERARCHYITEM_LINK_CSSCLASS_FULL}" icon="${HIERARCHYITEM_LINK_ICON}"></${P}-icon>
|
|
497
|
+
</${P}-panel>
|
|
498
|
+
</template>
|
|
499
|
+
<${P}-shell-proxy>
|
|
500
|
+
<${P}-balloon options="{{ { behavior: ComponentsUI.UI.BalloonBehavior.Inert } }}">
|
|
501
|
+
<${P}-button icon-glyph="link_off" class="${PCSS}-margin margin-0 button-flat display-flex flex-middle icon-rotate rotate-135"
|
|
502
|
+
on-click=":host._unlink($event)"
|
|
503
|
+
on-mousedown="$event.stopPropagation()"
|
|
504
|
+
on-mouseup="::_balloon.popout()"><${P}-text class="${PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${P}-text></${P}-button>
|
|
505
|
+
</${P}-balloon>
|
|
506
|
+
</${P}-shell-proxy>`
|
|
507
|
+
})
|
|
508
|
+
], PacemHierarchyElement);
|
|
509
|
+
export { PacemHierarchyElement };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export * from './contenteditable/index';
|
|
2
|
+
export * from './contenteditable';
|
|
3
|
+
export * from './calendar-picker';
|
|
4
|
+
export * from './char-counter';
|
|
5
|
+
export * from './checkbox';
|
|
6
|
+
export * from './checkbox-list';
|
|
7
|
+
export * from './childform';
|
|
8
|
+
export * from './datetime-picker';
|
|
9
|
+
export * from './form';
|
|
10
|
+
export * from './formfield';
|
|
11
|
+
export * from './geolocate';
|
|
12
|
+
export * from './hierarchy';
|
|
13
|
+
export * from './input';
|
|
14
|
+
export * from './input-chars';
|
|
15
|
+
export * from './input-color';
|
|
16
|
+
export * from './input-email';
|
|
17
|
+
export * from './input-file';
|
|
18
|
+
export * from './input-hidden';
|
|
19
|
+
export * from './input-image';
|
|
20
|
+
export * from './input-number';
|
|
21
|
+
export * from './input-password';
|
|
22
|
+
export * from './input-search';
|
|
23
|
+
export * from './input-tel';
|
|
24
|
+
export * from './input-text';
|
|
25
|
+
export * from './input-url';
|
|
26
|
+
export * from './latlng';
|
|
27
|
+
export * from './namevalue-list';
|
|
28
|
+
export * from './property-picker';
|
|
29
|
+
export * from './radio';
|
|
30
|
+
export * from './radio-list';
|
|
31
|
+
export * from './select';
|
|
32
|
+
export * from './slider';
|
|
33
|
+
export * from './snapshot';
|
|
34
|
+
export * from './suggest';
|
|
35
|
+
export * from './tags';
|
|
36
|
+
export * from './textarea';
|
|
37
|
+
export * from './textarea-markdown';
|
|
38
|
+
export * from './types-components';
|
|
39
|
+
export * from './validators';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Scaffolding from './index-components-scaffolding';
|