@pacem/pacem 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-2d.js +2755 -0
- package/dist/browser/pacem-2d.js.map +6 -0
- package/dist/browser/pacem-2d.min.js +7 -0
- package/dist/browser/pacem-2d.min.js.map +6 -0
- package/dist/browser/pacem-3d.js +7723 -0
- package/dist/browser/pacem-3d.js.map +6 -0
- package/dist/browser/pacem-3d.min.js +7 -0
- package/dist/browser/pacem-3d.min.js.map +6 -0
- package/dist/browser/pacem-charts.js +1628 -0
- package/dist/browser/pacem-charts.js.map +6 -0
- package/dist/browser/pacem-charts.min.js +7 -0
- package/dist/browser/pacem-charts.min.js.map +6 -0
- package/dist/browser/pacem-cms.js +2220 -0
- package/dist/browser/pacem-cms.js.map +6 -0
- package/dist/browser/pacem-cms.min.js +7 -0
- package/dist/browser/pacem-cms.min.js.map +6 -0
- package/dist/browser/pacem-core.js +9104 -0
- package/dist/browser/pacem-core.js.map +6 -0
- package/dist/browser/pacem-core.min.js +7 -0
- package/dist/browser/pacem-core.min.js.map +6 -0
- package/dist/browser/pacem-foundation.js +2138 -0
- package/dist/browser/pacem-foundation.js.map +6 -0
- package/dist/browser/pacem-foundation.min.js +7 -0
- package/dist/browser/pacem-foundation.min.js.map +6 -0
- package/dist/browser/pacem-fx.js +870 -0
- package/dist/browser/pacem-fx.js.map +6 -0
- package/dist/browser/pacem-fx.min.js +7 -0
- package/dist/browser/pacem-fx.min.js.map +6 -0
- package/dist/browser/pacem-logging.js +175 -0
- package/dist/browser/pacem-logging.js.map +6 -0
- package/dist/browser/pacem-logging.min.js +7 -0
- package/dist/browser/pacem-logging.min.js.map +6 -0
- package/dist/browser/pacem-maps.js +3642 -0
- package/dist/browser/pacem-maps.js.map +6 -0
- package/dist/browser/pacem-maps.min.js +7 -0
- package/dist/browser/pacem-maps.min.js.map +6 -0
- package/dist/browser/pacem-media.js +284 -0
- package/dist/browser/pacem-media.js.map +6 -0
- package/dist/browser/pacem-media.min.js +7 -0
- package/dist/browser/pacem-media.min.js.map +6 -0
- package/dist/browser/pacem-networking.js +434 -0
- package/dist/browser/pacem-networking.js.map +6 -0
- package/dist/browser/pacem-networking.min.js +7 -0
- package/dist/browser/pacem-networking.min.js.map +6 -0
- package/dist/browser/pacem-numerical.js +2627 -0
- package/dist/browser/pacem-numerical.js.map +6 -0
- package/dist/browser/pacem-numerical.min.js +7 -0
- package/dist/browser/pacem-numerical.min.js.map +6 -0
- package/dist/browser/pacem-plus.js +2373 -0
- package/dist/browser/pacem-plus.js.map +6 -0
- package/dist/browser/pacem-plus.min.js +7 -0
- package/dist/browser/pacem-plus.min.js.map +6 -0
- package/dist/browser/pacem-scaffolding.js +10435 -0
- package/dist/browser/pacem-scaffolding.js.map +6 -0
- package/dist/browser/pacem-scaffolding.min.js +7 -0
- package/dist/browser/pacem-scaffolding.min.js.map +6 -0
- package/dist/browser/pacem-ui.js +6348 -0
- package/dist/browser/pacem-ui.js.map +6 -0
- package/dist/browser/pacem-ui.min.js +7 -0
- package/dist/browser/pacem-ui.min.js.map +6 -0
- package/dist/bundle/pacem.min.mjs +997 -0
- package/dist/bundle/pacem.mjs +47067 -0
- package/dist/bundle/pacem.mjs.map +12 -0
- package/dist/typings/index.d.ts +9757 -0
- package/package.json +130 -0
|
@@ -0,0 +1,2373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pacem/pacem v1.0.0-abel (https://js.pacem.it)
|
|
3
|
+
* Copyright 2026 Pacem (https://pacem.it)
|
|
4
|
+
* Licensed under Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
(function (pacemFoundation, pacemCore, pacemUi, pacemScaffolding) {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
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;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
15
|
+
class PacemBaseCellElement extends pacemCore.Components.PacemSafeContentElement {
|
|
16
|
+
viewActivatedCallback() {
|
|
17
|
+
super.viewActivatedCallback();
|
|
18
|
+
this.updateColumnPosition();
|
|
19
|
+
this.updateLayout(this.metadata);
|
|
20
|
+
}
|
|
21
|
+
updateColumnPosition(metadata = this.metadata, state = this.gridState) {
|
|
22
|
+
this.style.gridColumn = (state.orderedColumns.indexOf(metadata.prop) + 1).toString();
|
|
23
|
+
}
|
|
24
|
+
updateVisibility(state = this.state) {
|
|
25
|
+
this.hide = !!state.hidden;
|
|
26
|
+
}
|
|
27
|
+
propertyChangedCallback(name, old, val, first) {
|
|
28
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
29
|
+
if (!first) {
|
|
30
|
+
switch (name) {
|
|
31
|
+
case 'metadata':
|
|
32
|
+
this.updateLayout(val);
|
|
33
|
+
break;
|
|
34
|
+
case 'gridState':
|
|
35
|
+
this.updateColumnPosition();
|
|
36
|
+
break;
|
|
37
|
+
case 'state':
|
|
38
|
+
this.updateVisibility();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
__decorate$b([
|
|
45
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
46
|
+
], PacemBaseCellElement.prototype, "metadata", void 0);
|
|
47
|
+
__decorate$b([
|
|
48
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
49
|
+
], PacemBaseCellElement.prototype, "state", void 0);
|
|
50
|
+
__decorate$b([
|
|
51
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
52
|
+
], PacemBaseCellElement.prototype, "gridState", void 0);
|
|
53
|
+
|
|
54
|
+
var __decorate$a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
55
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
56
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
57
|
+
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;
|
|
58
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
59
|
+
};
|
|
60
|
+
const DefaultLocalizationOptions = {
|
|
61
|
+
headCell: (headCellProp, prop, dictionary) => {
|
|
62
|
+
switch (headCellProp) {
|
|
63
|
+
case 'name':
|
|
64
|
+
return dictionary['column_name_' + prop] ?? dictionary['name_' + prop];
|
|
65
|
+
case 'description':
|
|
66
|
+
return dictionary['column_description_' + prop] ?? dictionary['description_' + prop];
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
class DataGrids {
|
|
72
|
+
/**
|
|
73
|
+
* Localizes the metadata of a data grid **in place** using a translation dictionary.
|
|
74
|
+
* Only the `name` and `description` properties of data columns are localized.
|
|
75
|
+
*
|
|
76
|
+
* By default, this method uses an opinionated key lookup strategy and attempts to resolve translation keys in the following format:
|
|
77
|
+
* - `column_name_{key}` for column names
|
|
78
|
+
* - `column_description_{key}` for column descriptions/tooltips
|
|
79
|
+
*
|
|
80
|
+
* This behavior can be customized by providing a replacement strategy through the `options` parameter.
|
|
81
|
+
*
|
|
82
|
+
* @param metadata The metadata to localize.
|
|
83
|
+
* @param dictionary The translation dictionary.
|
|
84
|
+
* @param options Optional customization of the replacement strategy.
|
|
85
|
+
* @returns The localized metadata.
|
|
86
|
+
*/
|
|
87
|
+
static localizeMetadata(metadata, dictionary, options) {
|
|
88
|
+
options = pacemCore.Utils.extend({}, DefaultLocalizationOptions, options ?? {});
|
|
89
|
+
// do not clone (for now...)
|
|
90
|
+
for (let prop of metadata) {
|
|
91
|
+
const display = prop.headCell = prop.headCell ?? {};
|
|
92
|
+
display.name = options.headCell('name', prop.prop, dictionary) ?? display.name; // dictionary['column_name_' + prop.prop] ?? dictionary['name_' + prop.prop] ?? display.name;
|
|
93
|
+
display.description = options.headCell('description', prop.prop, dictionary) ?? /* dictionary['column_description_' + prop.prop] ?? dictionary['description_' + prop.prop] ?? */ display.description;
|
|
94
|
+
}
|
|
95
|
+
return metadata;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
__decorate$a([
|
|
99
|
+
pacemCore.Transformer('datagrids.localizeMetadata')
|
|
100
|
+
], DataGrids, "localizeMetadata", null);
|
|
101
|
+
|
|
102
|
+
var l10n = /*#__PURE__*/Object.freeze({
|
|
103
|
+
__proto__: null,
|
|
104
|
+
DataGrids: DataGrids
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
var indexPlus = /*#__PURE__*/Object.freeze({
|
|
108
|
+
__proto__: null,
|
|
109
|
+
L10n: l10n,
|
|
110
|
+
PacemBaseCellElement: PacemBaseCellElement
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
114
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
115
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
116
|
+
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;
|
|
117
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
118
|
+
};
|
|
119
|
+
const UI$5 = pacemUi.Components.UI;
|
|
120
|
+
/** @deprecated*/
|
|
121
|
+
let PacemCarouselElement = class PacemCarouselElement extends UI$5.PacemAdaptedIterativeElement {
|
|
122
|
+
constructor() {
|
|
123
|
+
super(...arguments);
|
|
124
|
+
this.interval = 4000;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
__decorate$9([
|
|
128
|
+
pacemCore.ViewChild(pacemCore.P + '-adapter')
|
|
129
|
+
], PacemCarouselElement.prototype, "adapter", void 0);
|
|
130
|
+
__decorate$9([
|
|
131
|
+
pacemCore.ViewChild(pacemCore.P + '-slideshow')
|
|
132
|
+
], PacemCarouselElement.prototype, "slideshow", void 0);
|
|
133
|
+
__decorate$9([
|
|
134
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Number })
|
|
135
|
+
], PacemCarouselElement.prototype, "interval", void 0);
|
|
136
|
+
__decorate$9([
|
|
137
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
138
|
+
], PacemCarouselElement.prototype, "pausable", void 0);
|
|
139
|
+
PacemCarouselElement = __decorate$9([
|
|
140
|
+
pacemCore.CustomElement({
|
|
141
|
+
tagName: pacemCore.P + '-carousel', shadow: pacemCore.Defaults.USE_SHADOW_ROOT,
|
|
142
|
+
template: `<${pacemCore.P}-repeater datasource="{{ :host.datasource }}">
|
|
143
|
+
<${pacemCore.P}-slideshow class="${pacemCore.PCSS}-carousel" adapter="{{ ::adapter }}" index="{{ :host.index, twoway }}" on-load="this.focus()">
|
|
144
|
+
|
|
145
|
+
<template>
|
|
146
|
+
|
|
147
|
+
<${pacemCore.P}-slide class="${pacemCore.PCSS}-carousel-item" css-class="{{ { '${pacemCore.PCSS}-carousel-previous': :host.isPrevious(^index, ::slideshow.index), '${pacemCore.PCSS}-carousel-next': :host.isNext(^index, ::slideshow.index), '${pacemCore.PCSS}-carousel-focus': ^index === ::slideshow.index } }}">
|
|
148
|
+
<${pacemCore.P}-a href="{{ ^item.url }}">
|
|
149
|
+
<${pacemCore.P}-img disabled="{{ !:host.isCloseTo(^index, ::slideshow.index) }}" class="${pacemCore.PCSS}-carousel-splash" adapt="cover" src="{{ ^item.image }}"></${pacemCore.P}-img>
|
|
150
|
+
<div class="${pacemCore.PCSS}-carousel-content">
|
|
151
|
+
<div class="${pacemCore.PCSS}-carousel-caption">
|
|
152
|
+
<h3><${pacemCore.P}-text text="{{ ^item.title }}"></${pacemCore.P}-text></h3>
|
|
153
|
+
<${pacemCore.P}-panel class="paragraph" content="{{ ^item.content }}"></${pacemCore.P}-panel>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</${pacemCore.P}-a>
|
|
157
|
+
</${pacemCore.P}-slide>
|
|
158
|
+
|
|
159
|
+
</template>
|
|
160
|
+
</${pacemCore.P}-slideshow>
|
|
161
|
+
|
|
162
|
+
</${pacemCore.P}-repeater><${pacemCore.P}-adapter pausable="{{ :host.pausable }}" class="${pacemCore.PCSS}-carousel-adapter" interval="{{ :host.interval }}"></${pacemCore.P}-adapter>`
|
|
163
|
+
})
|
|
164
|
+
], PacemCarouselElement);
|
|
165
|
+
|
|
166
|
+
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
167
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
168
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
169
|
+
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;
|
|
170
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
171
|
+
};
|
|
172
|
+
const UI$4 = pacemUi.Components.UI;
|
|
173
|
+
//namespace Pacem.Components.Plus {
|
|
174
|
+
class PacemContextMenuItemElement extends pacemCore.Components.PacemItemElement {
|
|
175
|
+
connectedCallback() {
|
|
176
|
+
super.connectedCallback();
|
|
177
|
+
pacemCore.Utils.addClass(this, pacemCore.PCSS + '-context-menuitem');
|
|
178
|
+
}
|
|
179
|
+
propertyChangedCallback(name, old, val, first) {
|
|
180
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
181
|
+
const container = this.container;
|
|
182
|
+
if (container instanceof PacemContextMenuElement) {
|
|
183
|
+
container.refresh();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
let PacemContextMenuItemCommandElement = class PacemContextMenuItemCommandElement extends PacemContextMenuItemElement {
|
|
188
|
+
createMenuItemElement() {
|
|
189
|
+
const retval = new UI$4.PacemButtonElement();
|
|
190
|
+
retval.commandArgument = this.commandArgument;
|
|
191
|
+
retval.commandName = this.commandName;
|
|
192
|
+
retval.textContent = this.caption;
|
|
193
|
+
retval.iconGlyph = this.iconGlyph;
|
|
194
|
+
retval.confirmationDialog = this.confirmationDialog;
|
|
195
|
+
retval.confirmationMessage = this.confirmationMessage;
|
|
196
|
+
retval.tooltip = this.tooltip;
|
|
197
|
+
retval.disabled = this.disabled;
|
|
198
|
+
retval.cssClass = this.buttonCssClass;
|
|
199
|
+
return retval;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
__decorate$8([
|
|
203
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
204
|
+
], PacemContextMenuItemCommandElement.prototype, "commandName", void 0);
|
|
205
|
+
__decorate$8([
|
|
206
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
207
|
+
], PacemContextMenuItemCommandElement.prototype, "caption", void 0);
|
|
208
|
+
__decorate$8([
|
|
209
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
210
|
+
], PacemContextMenuItemCommandElement.prototype, "tooltip", void 0);
|
|
211
|
+
__decorate$8([
|
|
212
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
213
|
+
], PacemContextMenuItemCommandElement.prototype, "iconGlyph", void 0);
|
|
214
|
+
__decorate$8([
|
|
215
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.StringArray })
|
|
216
|
+
], PacemContextMenuItemCommandElement.prototype, "buttonCssClass", void 0);
|
|
217
|
+
__decorate$8([
|
|
218
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
219
|
+
], PacemContextMenuItemCommandElement.prototype, "confirmationMessage", void 0);
|
|
220
|
+
__decorate$8([
|
|
221
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.Element })
|
|
222
|
+
], PacemContextMenuItemCommandElement.prototype, "confirmationDialog", void 0);
|
|
223
|
+
__decorate$8([
|
|
224
|
+
pacemCore.Watch({ emit: false, /* important */ reflectBack: true, converter: pacemCore.PropertyConverters.Json })
|
|
225
|
+
], PacemContextMenuItemCommandElement.prototype, "commandArgument", void 0);
|
|
226
|
+
PacemContextMenuItemCommandElement = __decorate$8([
|
|
227
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-context-menuitem-command' })
|
|
228
|
+
], PacemContextMenuItemCommandElement);
|
|
229
|
+
let PacemContextMenuItemSeparatorElement = class PacemContextMenuItemSeparatorElement extends PacemContextMenuItemElement {
|
|
230
|
+
createMenuItemElement() {
|
|
231
|
+
const retval = document.createElement('hr');
|
|
232
|
+
retval.style.pointerEvents = 'none';
|
|
233
|
+
return retval;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
PacemContextMenuItemSeparatorElement = __decorate$8([
|
|
237
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-context-menuitem-separator' })
|
|
238
|
+
], PacemContextMenuItemSeparatorElement);
|
|
239
|
+
// <${P}-button class="button-flat ${PCSS}-margin margin-0"><${P}-icon icon="{{ :host.icon || 'more_horiz' }}"></${P}-icon></${P}-button>
|
|
240
|
+
let PacemContextMenuElement = class PacemContextMenuElement extends pacemCore.Components.PacemItemsContainerElement {
|
|
241
|
+
constructor() {
|
|
242
|
+
super(...arguments);
|
|
243
|
+
this._dispatchCommand = (e) => {
|
|
244
|
+
pacemCore.avoidHandler(e);
|
|
245
|
+
this._onCommand(new pacemCore.CommandEvent({ commandName: e.detail.commandName, commandArgument: e.detail.commandArgument ?? this.commandArgument }));
|
|
246
|
+
};
|
|
247
|
+
this._slotchangeHandler = (evt) => {
|
|
248
|
+
this._resetLayout();
|
|
249
|
+
};
|
|
250
|
+
this._attributeChangeHandler = (evt) => this._refreshMenuItems;
|
|
251
|
+
this._mouseupHandler = (evt) => {
|
|
252
|
+
const balloon = this._ensureBalloon();
|
|
253
|
+
if (!pacemCore.Utils.isNull(balloon)) {
|
|
254
|
+
balloon.popout();
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
validate(item) {
|
|
259
|
+
return item instanceof PacemContextMenuItemElement;
|
|
260
|
+
}
|
|
261
|
+
#btn;
|
|
262
|
+
#icon;
|
|
263
|
+
#balloon;
|
|
264
|
+
_ensureButton() {
|
|
265
|
+
if (!pacemCore.Utils.isNull(this.#btn)) {
|
|
266
|
+
return this.#btn;
|
|
267
|
+
}
|
|
268
|
+
const btnSlot = this._slot;
|
|
269
|
+
if (pacemCore.Utils.isNull(btnSlot)) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const found = this._lookForAButton();
|
|
273
|
+
if (!pacemCore.Utils.isNull(found)) {
|
|
274
|
+
return this.#btn = found;
|
|
275
|
+
}
|
|
276
|
+
const retval = new UI$4.PacemButtonElement();
|
|
277
|
+
retval.setAttribute('slot', 'button');
|
|
278
|
+
retval.className = `${pacemCore.PCSS}-margin margin-0 button-flat`;
|
|
279
|
+
const icon = this.#icon = new UI$4.PacemIconElement();
|
|
280
|
+
retval.appendChild(icon);
|
|
281
|
+
this.appendChild(retval);
|
|
282
|
+
return this.#btn = retval;
|
|
283
|
+
}
|
|
284
|
+
_lookForAButton() {
|
|
285
|
+
const btnSlot = this._slot;
|
|
286
|
+
if (pacemCore.Utils.isNull(btnSlot)) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
const buttons = btnSlot.assignedElements({ flatten: true });
|
|
290
|
+
if (pacemCore.Utils.isNullOrEmpty(buttons)) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
return buttons[0];
|
|
294
|
+
}
|
|
295
|
+
_ensureBalloon() {
|
|
296
|
+
let balloon = this.#balloon;
|
|
297
|
+
if (!pacemCore.Utils.isNull(balloon)) {
|
|
298
|
+
return balloon;
|
|
299
|
+
}
|
|
300
|
+
const shell = pacemCore.CustomElementUtils.findAncestorShell(this);
|
|
301
|
+
if (pacemCore.Utils.isNull(shell)) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
balloon = new UI$4.PacemBalloonElement();
|
|
305
|
+
balloon.options = { trigger: UI$4.BalloonTrigger.Click, position: UI$4.BalloonPosition.HorizontalAuto, align: UI$4.BalloonAlignment.Auto, autoAdjust: true };
|
|
306
|
+
//balloon.target = this._btn;
|
|
307
|
+
balloon.addEventListener(pacemCore.CommandEventName, this._dispatchCommand, false);
|
|
308
|
+
balloon.className = `${pacemCore.PCSS}-contextmenu`;
|
|
309
|
+
shell.appendChild(balloon);
|
|
310
|
+
return this.#balloon = balloon;
|
|
311
|
+
}
|
|
312
|
+
register(item) {
|
|
313
|
+
const retval = super.register(item);
|
|
314
|
+
if (retval) {
|
|
315
|
+
item.addEventListener(pacemCore.AttributeChangeEventName, this._attributeChangeHandler, false);
|
|
316
|
+
this._refreshMenuItems();
|
|
317
|
+
}
|
|
318
|
+
return retval;
|
|
319
|
+
}
|
|
320
|
+
unregister(item) {
|
|
321
|
+
const retval = super.unregister(item);
|
|
322
|
+
if (retval) {
|
|
323
|
+
item.removeEventListener(pacemCore.AttributeChangeEventName, this._attributeChangeHandler, false);
|
|
324
|
+
this._refreshMenuItems();
|
|
325
|
+
}
|
|
326
|
+
return retval;
|
|
327
|
+
}
|
|
328
|
+
_onCommand(evt) {
|
|
329
|
+
this.dispatchEvent(new CustomEvent(pacemCore.CommandEventName, { detail: evt.detail, cancelable: true, bubbles: true }));
|
|
330
|
+
this.dispatchEvent(new CustomEvent(evt.detail.commandName.toLowerCase(), { detail: evt.detail.commandArgument, cancelable: true, bubbles: true }));
|
|
331
|
+
}
|
|
332
|
+
_resetLayout() {
|
|
333
|
+
const btn = this._ensureButton();
|
|
334
|
+
const balloon = this._ensureBalloon();
|
|
335
|
+
if (!pacemCore.Utils.isNull(btn) && !pacemCore.Utils.isNull(balloon)) {
|
|
336
|
+
balloon.target = btn;
|
|
337
|
+
}
|
|
338
|
+
this._toggleBtn();
|
|
339
|
+
this._toggleIcon();
|
|
340
|
+
}
|
|
341
|
+
_toggleBtn(disabled = this.disabled) {
|
|
342
|
+
const btn = this.#btn;
|
|
343
|
+
if (!pacemCore.Utils.isNull(btn) && btn instanceof pacemCore.Components.PacemElement) {
|
|
344
|
+
btn.disabled = disabled;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
_toggleIcon(icon = this.icon) {
|
|
348
|
+
const iconEl = this.#icon;
|
|
349
|
+
if (!pacemCore.Utils.isNull(iconEl)) {
|
|
350
|
+
iconEl.icon = icon;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
viewActivatedCallback() {
|
|
354
|
+
super.viewActivatedCallback();
|
|
355
|
+
this._resetLayout();
|
|
356
|
+
this._slot.addEventListener('slotchange', this._slotchangeHandler, false);
|
|
357
|
+
}
|
|
358
|
+
propertyChangedCallback(name, old, val, first) {
|
|
359
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
360
|
+
if (!first) {
|
|
361
|
+
switch (name) {
|
|
362
|
+
case 'icon':
|
|
363
|
+
this._toggleIcon(val);
|
|
364
|
+
break;
|
|
365
|
+
case 'disabled':
|
|
366
|
+
this._toggleBtn(val);
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
disconnectedCallback() {
|
|
372
|
+
this._disposeButton();
|
|
373
|
+
this._disposeSlot();
|
|
374
|
+
this._disposeBalloon();
|
|
375
|
+
super.disconnectedCallback();
|
|
376
|
+
}
|
|
377
|
+
refresh() {
|
|
378
|
+
this._refreshMenuItems();
|
|
379
|
+
}
|
|
380
|
+
_disposeButton() {
|
|
381
|
+
this.#btn = this.#icon = null;
|
|
382
|
+
}
|
|
383
|
+
_disposeSlot() {
|
|
384
|
+
const slot = this._slot;
|
|
385
|
+
if (!pacemCore.Utils.isNull(slot)) {
|
|
386
|
+
slot.removeEventListener('slotchange', this._slotchangeHandler, false);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
_disposeBalloon() {
|
|
390
|
+
const balloon = this.#balloon;
|
|
391
|
+
if (!pacemCore.Utils.isNull(balloon)) {
|
|
392
|
+
balloon.removeEventListener(pacemCore.CommandEventName, this._dispatchCommand, false);
|
|
393
|
+
this._disposeBalloonChildren(0);
|
|
394
|
+
balloon.remove();
|
|
395
|
+
this.#balloon = null;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
_disposeBalloonChildren(startAt) {
|
|
399
|
+
const balloon = this.#balloon;
|
|
400
|
+
const count = balloon.children.length;
|
|
401
|
+
for (let j = count - 1; j >= startAt; j--) {
|
|
402
|
+
// cleanup
|
|
403
|
+
const rem = balloon.children.item(j);
|
|
404
|
+
rem.removeEventListener('mouseup', this._mouseupHandler, false);
|
|
405
|
+
rem.remove();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
_refreshMenuItems() {
|
|
409
|
+
const balloon = this._ensureBalloon();
|
|
410
|
+
if (pacemCore.Utils.isNull(balloon)) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const count = balloon.children.length;
|
|
414
|
+
let cursor = 0;
|
|
415
|
+
for (let item of this.items) {
|
|
416
|
+
if (item.hide) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
const menuitem = item.createMenuItemElement();
|
|
420
|
+
menuitem.addEventListener('mouseup', this._mouseupHandler, false);
|
|
421
|
+
if (cursor < count) {
|
|
422
|
+
const repl = balloon.children.item(cursor);
|
|
423
|
+
repl.removeEventListener('mouseup', this._mouseupHandler, false);
|
|
424
|
+
repl.replaceWith(menuitem);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
balloon.appendChild(menuitem);
|
|
428
|
+
}
|
|
429
|
+
cursor++;
|
|
430
|
+
}
|
|
431
|
+
this._disposeBalloonChildren(cursor);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
__decorate$8([
|
|
435
|
+
pacemCore.ViewChild('slot[name=button]')
|
|
436
|
+
], PacemContextMenuElement.prototype, "_slot", void 0);
|
|
437
|
+
__decorate$8([
|
|
438
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
439
|
+
], PacemContextMenuElement.prototype, "commandArgument", void 0);
|
|
440
|
+
__decorate$8([
|
|
441
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
442
|
+
], PacemContextMenuElement.prototype, "icon", void 0);
|
|
443
|
+
__decorate$8([
|
|
444
|
+
pacemCore.Debounce(true)
|
|
445
|
+
], PacemContextMenuElement.prototype, "_refreshMenuItems", null);
|
|
446
|
+
PacemContextMenuElement = __decorate$8([
|
|
447
|
+
pacemCore.CustomElement({
|
|
448
|
+
tagName: pacemCore.P + '-context-menu', shadow: true,
|
|
449
|
+
template: `<slot name="button"></slot><slot></slot>`
|
|
450
|
+
})
|
|
451
|
+
], PacemContextMenuElement);
|
|
452
|
+
|
|
453
|
+
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
454
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
455
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
456
|
+
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;
|
|
457
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
458
|
+
};
|
|
459
|
+
const UI$3 = pacemUi.Components.UI;
|
|
460
|
+
const Scaffolding = pacemScaffolding.Components.Scaffolding;
|
|
461
|
+
//namespace Pacem.Components.Plus {
|
|
462
|
+
var EditMode;
|
|
463
|
+
(function (EditMode) {
|
|
464
|
+
EditMode["Text"] = "text";
|
|
465
|
+
EditMode["Html"] = "html";
|
|
466
|
+
EditMode["Image"] = "image";
|
|
467
|
+
EditMode["Markdown"] = "markdown";
|
|
468
|
+
})(EditMode || (EditMode = {}));
|
|
469
|
+
let PacemEditElement = class PacemEditElement extends pacemCore.Components.PacemElement {
|
|
470
|
+
constructor(_markdown = new UI$3.MarkdownService()) {
|
|
471
|
+
super();
|
|
472
|
+
this._markdown = _markdown;
|
|
473
|
+
// #endregion
|
|
474
|
+
// #endregion
|
|
475
|
+
this._dialogPropertyChangedHandler = (evt) => {
|
|
476
|
+
this._dialogPropertyChangedCallback(evt);
|
|
477
|
+
};
|
|
478
|
+
this._broadcastFetchRequestEventName = (evt) => {
|
|
479
|
+
this.dispatchEvent(new Scaffolding.ImageFetchRequestEvent(evt.detail));
|
|
480
|
+
};
|
|
481
|
+
this._innerValueChangedHandler = (evt) => {
|
|
482
|
+
if (evt.detail.propertyName === 'value' && !pacemCore.Utils.isNull(this._dialog))
|
|
483
|
+
this._dialog.state = evt.detail.currentValue;
|
|
484
|
+
};
|
|
485
|
+
this._editHandler = (evt) => {
|
|
486
|
+
this.edit(evt);
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
_addButton() {
|
|
490
|
+
/*<pacem-balloon options="{ position: '${UI.BalloonPosition.Top}', align: '${UI.BalloonAlignment.End}', behavior: '${UI.BalloonBehavior.Inert}', hoverDelay: 0 }" disabled="{{ :host.disabled }}" class="pacem-edit-balloon">
|
|
491
|
+
<pacem-button class="pacem-edit" on-click=":host.edit($event)"></pacem-button>
|
|
492
|
+
</pacem-balloon>*/
|
|
493
|
+
if (!pacemCore.Utils.isNull(this._button))
|
|
494
|
+
return;
|
|
495
|
+
//
|
|
496
|
+
var btn = document.createElement(pacemCore.P + '-button');
|
|
497
|
+
btn.className = pacemCore.PCSS + '-edit-button';
|
|
498
|
+
btn.addEventListener('click', this._editHandler, false);
|
|
499
|
+
this._target.appendChild(btn);
|
|
500
|
+
//
|
|
501
|
+
return this._button = btn;
|
|
502
|
+
}
|
|
503
|
+
_removeButton() {
|
|
504
|
+
var btn = this._button;
|
|
505
|
+
if (pacemCore.Utils.isNull(btn))
|
|
506
|
+
return;
|
|
507
|
+
btn.removeEventListener('click', this._editHandler, false);
|
|
508
|
+
btn.remove();
|
|
509
|
+
this._button = null;
|
|
510
|
+
}
|
|
511
|
+
// #region dialog
|
|
512
|
+
_addDialog() {
|
|
513
|
+
/* <pacem-dialog buttons="'${ UI.DialogButtons.OkCancel}'" on-${PropertyChangeEventName}=":host._dialogPropertyChangedCallback($event)"> */
|
|
514
|
+
var dialog = document.createElement(pacemCore.P + '-dialog');
|
|
515
|
+
dialog.buttons = UI$3.DialogButtons.OkCancel;
|
|
516
|
+
dialog.addEventListener(pacemCore.PropertyChangeEventName, this._dialogPropertyChangedHandler, false);
|
|
517
|
+
dialog.appendChild(this._addTextarea());
|
|
518
|
+
dialog.appendChild(this._addContenteditable());
|
|
519
|
+
dialog.appendChild(this._addEditImage());
|
|
520
|
+
document.body.appendChild(dialog);
|
|
521
|
+
//
|
|
522
|
+
return this._dialog = dialog;
|
|
523
|
+
}
|
|
524
|
+
_removeDialog() {
|
|
525
|
+
this._removeTextarea();
|
|
526
|
+
this._removeContenteditable();
|
|
527
|
+
this._removeEditImage();
|
|
528
|
+
if (!pacemCore.Utils.isNull(this._dialog)) {
|
|
529
|
+
this._dialog.removeEventListener(pacemCore.PropertyChangeEventName, this._dialogPropertyChangedHandler, false);
|
|
530
|
+
this._dialog.remove();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
// #region textarea
|
|
534
|
+
_addTextarea() {
|
|
535
|
+
/*<pacem-textarea hide="{{ :host.type === '${ EditMode.Html}' || :host.type === '${EditMode.Image}' }}" value="{{ ::_dialog.state, twoway }}"></pacem-textarea>*/
|
|
536
|
+
var textarea = document.createElement(pacemCore.P + '-textarea');
|
|
537
|
+
textarea.className = pacemCore.PCSS + '-edit-text';
|
|
538
|
+
textarea.addEventListener(pacemCore.PropertyChangeEventName, this._innerValueChangedHandler, false);
|
|
539
|
+
const type = this.type || EditMode.Text;
|
|
540
|
+
textarea.hide = type !== EditMode.Text && type !== EditMode.Markdown;
|
|
541
|
+
return this._textarea = textarea;
|
|
542
|
+
}
|
|
543
|
+
_removeTextarea() {
|
|
544
|
+
if (!pacemCore.Utils.isNull(this._textarea))
|
|
545
|
+
this._textarea.removeEventListener(pacemCore.PropertyChangeEventName, this._innerValueChangedHandler, false);
|
|
546
|
+
}
|
|
547
|
+
// #endregion
|
|
548
|
+
// #region contenteditable
|
|
549
|
+
_addContenteditable() {
|
|
550
|
+
/*<pacem-contenteditable hide="{{ :host.type != '${ EditMode.Html}' }}" value="{{ ::_dialog.state, twoway }}"></pacem-contenteditable> */
|
|
551
|
+
var contenteditable = document.createElement(pacemCore.P + '-contenteditable');
|
|
552
|
+
contenteditable.className = pacemCore.PCSS + '-edit-content';
|
|
553
|
+
contenteditable.addEventListener(pacemCore.PropertyChangeEventName, this._innerValueChangedHandler, false);
|
|
554
|
+
const type = this.type || EditMode.Text;
|
|
555
|
+
contenteditable.hide = type !== EditMode.Html;
|
|
556
|
+
return this._contenteditable = contenteditable;
|
|
557
|
+
}
|
|
558
|
+
_removeContenteditable() {
|
|
559
|
+
if (!pacemCore.Utils.isNull(this._contenteditable))
|
|
560
|
+
this._contenteditable.removeEventListener(pacemCore.PropertyChangeEventName, this._innerValueChangedHandler, false);
|
|
561
|
+
}
|
|
562
|
+
// #endregion
|
|
563
|
+
// #region edit-image
|
|
564
|
+
_addEditImage() {
|
|
565
|
+
/*<!-- img -->
|
|
566
|
+
<pacem-panel class="pacem-edit-image" hide="{{ :host.type != '${ EditMode.Image}' }}"
|
|
567
|
+
css-class="{{ {'pacem-uploading': ::_uploader.uploading, 'pacem-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.imageUploadUrl)} }}">
|
|
568
|
+
<pacem-input-search value="{{ :host.hint, twoway }}"></pacem-input-search>
|
|
569
|
+
<pacem-upload pattern="'.+\.(jpe?g|png)$'" url="{{ :host.imageUploadUrl }}" on-${ PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.imageUploadUrl) }}"></pacem-upload>
|
|
570
|
+
<pacem-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || !:host._open || :host._images.length >= :host.imageSet.total }}"></pacem-infinite-scroller>
|
|
571
|
+
<pacem-repeater datasource="{{ :host._images }}">
|
|
572
|
+
<template>
|
|
573
|
+
<pacem-img css-class="{{ {'pacem-selected': ^item.src === ::_dialog.state } }}" on-click="::_dialog.state = ^item.src" src="{{ ^item.thumb }}" adapt="'contain'"></pacem-img>
|
|
574
|
+
</template>
|
|
575
|
+
</pacem-repeater>
|
|
576
|
+
<pacem-progressbar></pacem-progressbar>
|
|
577
|
+
</pacem-panel>*/
|
|
578
|
+
var editImage = document.createElement(pacemCore.P + '-edit-image');
|
|
579
|
+
editImage.disabled = true;
|
|
580
|
+
editImage.addEventListener(pacemCore.PropertyChangeEventName, this._innerValueChangedHandler, false);
|
|
581
|
+
editImage.addEventListener(Scaffolding.ImageFetchRequestEventName, this._broadcastFetchRequestEventName, false);
|
|
582
|
+
const type = this.type || EditMode.Text;
|
|
583
|
+
editImage.hide = type !== EditMode.Image;
|
|
584
|
+
editImage.uploadUrl = this.imageUploadUrl;
|
|
585
|
+
editImage.allowSnapshot = this.allowSnapshot;
|
|
586
|
+
editImage.maxWidth = this.maxImageWidth;
|
|
587
|
+
editImage.maxHeight = this.maxImageHeight;
|
|
588
|
+
return this._editImage = editImage;
|
|
589
|
+
}
|
|
590
|
+
_removeEditImage() {
|
|
591
|
+
if (!pacemCore.Utils.isNull(this._editImage)) {
|
|
592
|
+
this._editImage.removeEventListener(pacemCore.PropertyChangeEventName, this._innerValueChangedHandler, false);
|
|
593
|
+
this._editImage.removeEventListener(Scaffolding.ImageFetchRequestEventName, this._broadcastFetchRequestEventName, false);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
_update(val) {
|
|
597
|
+
var cnt = this._content;
|
|
598
|
+
switch (this.type) {
|
|
599
|
+
case EditMode.Html:
|
|
600
|
+
cnt.innerHTML = val;
|
|
601
|
+
break;
|
|
602
|
+
case EditMode.Markdown:
|
|
603
|
+
switch (cnt.localName) {
|
|
604
|
+
case pacemCore.P + '-markdown':
|
|
605
|
+
cnt.value = val;
|
|
606
|
+
break;
|
|
607
|
+
default:
|
|
608
|
+
cnt.innerHTML = this._markdown.toHtml(val);
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
break;
|
|
612
|
+
case EditMode.Image:
|
|
613
|
+
switch (cnt.localName) {
|
|
614
|
+
case 'img':
|
|
615
|
+
case pacemCore.P + '-img':
|
|
616
|
+
cnt['src'] = val;
|
|
617
|
+
break;
|
|
618
|
+
default:
|
|
619
|
+
cnt.style.backgroundImage = `url(${val})`;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
break;
|
|
623
|
+
default:
|
|
624
|
+
this._content.textContent = val;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
_retrieve() {
|
|
629
|
+
var cnt = this._content;
|
|
630
|
+
switch (this.type) {
|
|
631
|
+
case EditMode.Html:
|
|
632
|
+
return cnt.innerHTML;
|
|
633
|
+
case EditMode.Image:
|
|
634
|
+
switch (cnt.localName) {
|
|
635
|
+
case pacemCore.P + '-img':
|
|
636
|
+
case 'img':
|
|
637
|
+
return cnt['src'];
|
|
638
|
+
default:
|
|
639
|
+
let styled = getComputedStyle(cnt).backgroundImage, matches = /url\(["']?([^'"]+)["']?\)/.exec(styled);
|
|
640
|
+
return matches && matches.length && matches[1];
|
|
641
|
+
}
|
|
642
|
+
case EditMode.Markdown:
|
|
643
|
+
return cnt['value'] || cnt.textContent;
|
|
644
|
+
default:
|
|
645
|
+
return cnt.textContent;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
_setup() {
|
|
649
|
+
const val = this.disabled;
|
|
650
|
+
if (val) {
|
|
651
|
+
pacemCore.Utils.removeClass(this._target, pacemCore.PCSS + '-editing');
|
|
652
|
+
this._removeButton();
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
pacemCore.Utils.addClass(this._target, pacemCore.PCSS + '-editing');
|
|
656
|
+
this._addButton();
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
_dialogPropertyChangedCallback(evt) {
|
|
660
|
+
if (evt.detail.propertyName === 'state') {
|
|
661
|
+
const val = evt.detail.currentValue;
|
|
662
|
+
if (!pacemCore.Utils.isNull(this._textarea))
|
|
663
|
+
this._textarea.value = val;
|
|
664
|
+
if (!pacemCore.Utils.isNull(this._contenteditable))
|
|
665
|
+
this._contenteditable.value = val;
|
|
666
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
667
|
+
this._editImage.value = val;
|
|
668
|
+
this._update(evt.detail.currentValue);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
get _target() {
|
|
672
|
+
var cnt = this.target;
|
|
673
|
+
if (pacemCore.Utils.isNull(cnt))
|
|
674
|
+
cnt = this.firstElementChild;
|
|
675
|
+
return cnt;
|
|
676
|
+
}
|
|
677
|
+
connectedCallback() {
|
|
678
|
+
super.connectedCallback();
|
|
679
|
+
this._addDialog();
|
|
680
|
+
}
|
|
681
|
+
viewActivatedCallback() {
|
|
682
|
+
super.viewActivatedCallback();
|
|
683
|
+
this._addButton();
|
|
684
|
+
this._setup();
|
|
685
|
+
}
|
|
686
|
+
disconnectedCallback() {
|
|
687
|
+
this._removeButton();
|
|
688
|
+
this._removeDialog();
|
|
689
|
+
super.disconnectedCallback();
|
|
690
|
+
}
|
|
691
|
+
propertyChangedCallback(name, old, val, first) {
|
|
692
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
693
|
+
switch (name) {
|
|
694
|
+
case 'imageUploadUrl':
|
|
695
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
696
|
+
this._editImage.uploadUrl = val;
|
|
697
|
+
break;
|
|
698
|
+
case 'allowSnapshot':
|
|
699
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
700
|
+
this._editImage.allowSnapshot = val;
|
|
701
|
+
break;
|
|
702
|
+
case 'imageSet':
|
|
703
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
704
|
+
this._editImage.imageSet = val;
|
|
705
|
+
break;
|
|
706
|
+
case 'disabled':
|
|
707
|
+
this._setup();
|
|
708
|
+
break;
|
|
709
|
+
case 'type':
|
|
710
|
+
const type = val;
|
|
711
|
+
if (!pacemCore.Utils.isNull(this._textarea))
|
|
712
|
+
this._textarea.hide = type !== EditMode.Text && type !== EditMode.Markdown;
|
|
713
|
+
if (!pacemCore.Utils.isNull(this._contenteditable))
|
|
714
|
+
this._contenteditable.hide = type !== EditMode.Html;
|
|
715
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
716
|
+
this._editImage.hide = type !== EditMode.Image;
|
|
717
|
+
break;
|
|
718
|
+
case 'maxImageHeight':
|
|
719
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
720
|
+
this._editImage.maxHeight = val;
|
|
721
|
+
break;
|
|
722
|
+
case 'maxImageWidth':
|
|
723
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
724
|
+
this._editImage.maxWidth = val;
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
edit(evt) {
|
|
729
|
+
pacemCore.avoidHandler(evt);
|
|
730
|
+
var cnt = this._target;
|
|
731
|
+
if (pacemCore.Utils.isNull(cnt))
|
|
732
|
+
return;
|
|
733
|
+
this._removeButton();
|
|
734
|
+
this._content = cnt;
|
|
735
|
+
var state = this._state = this._retrieve();
|
|
736
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
737
|
+
this._editImage.disabled = false;
|
|
738
|
+
this._dialog.open(state).then(args => {
|
|
739
|
+
switch (args.button) {
|
|
740
|
+
case UI$3.DialogButton.Cancel:
|
|
741
|
+
// reset value
|
|
742
|
+
this._update(this._state);
|
|
743
|
+
break;
|
|
744
|
+
case UI$3.DialogButton.Ok:
|
|
745
|
+
// save
|
|
746
|
+
this._update(args.state);
|
|
747
|
+
this.dispatchEvent(new CustomEvent('commit', { detail: { value: args.state } }));
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
this._content = null;
|
|
751
|
+
if (!pacemCore.Utils.isNull(this._editImage))
|
|
752
|
+
this._editImage.disabled = true;
|
|
753
|
+
this._addButton();
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
__decorate$7([
|
|
758
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
759
|
+
], PacemEditElement.prototype, "key", void 0);
|
|
760
|
+
__decorate$7([
|
|
761
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
762
|
+
], PacemEditElement.prototype, "type", void 0);
|
|
763
|
+
__decorate$7([
|
|
764
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Element })
|
|
765
|
+
], PacemEditElement.prototype, "target", void 0);
|
|
766
|
+
__decorate$7([
|
|
767
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
768
|
+
], PacemEditElement.prototype, "imageUploadUrl", void 0);
|
|
769
|
+
__decorate$7([
|
|
770
|
+
pacemCore.Watch({ emit: false })
|
|
771
|
+
], PacemEditElement.prototype, "imageSet", void 0);
|
|
772
|
+
__decorate$7([
|
|
773
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
774
|
+
], PacemEditElement.prototype, "maxImageWidth", void 0);
|
|
775
|
+
__decorate$7([
|
|
776
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
777
|
+
], PacemEditElement.prototype, "maxImageHeight", void 0);
|
|
778
|
+
__decorate$7([
|
|
779
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
780
|
+
], PacemEditElement.prototype, "allowSnapshot", void 0);
|
|
781
|
+
PacemEditElement = __decorate$7([
|
|
782
|
+
pacemCore.CustomElement({
|
|
783
|
+
tagName: pacemCore.P + '-edit'
|
|
784
|
+
})
|
|
785
|
+
], PacemEditElement);
|
|
786
|
+
|
|
787
|
+
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
788
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
789
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
790
|
+
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;
|
|
791
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
792
|
+
};
|
|
793
|
+
const UI$2 = pacemUi.Components.UI;
|
|
794
|
+
function getGallerySlideShowTemplate(captionTemplate = getDefaultCaptionTemplate(), imageProperty = 'image') {
|
|
795
|
+
return `<${pacemCore.P}-slide class="${pacemCore.PCSS}-gallery-item"
|
|
796
|
+
css-class="{{ { '${pacemCore.PCSS}-gallery-previous': :host.isPrevious(^index, ::_slideshow.index), '${pacemCore.PCSS}-gallery-next': :host.isNext(^index, ::_slideshow.index), '${pacemCore.PCSS}-gallery-focus': ^index === ::_slideshow.index } }}"
|
|
797
|
+
>
|
|
798
|
+
<${pacemCore.P}-img src="{{ ^item.${imageProperty} }}" disabled="{{ !::_lightbox.show || !(:host.isCloseTo(^index, ::_slideshow.index) || ^index === ::_slideshow.index) }}"
|
|
799
|
+
css="{{ {'visibility': (:host._poppingUp ? 'hidden' : ''), 'transition': (:host._poppingUp ? 'none' : '')} }}" class="${pacemCore.PCSS}-gallery-splash" adapt="contain"></${pacemCore.P}-img>
|
|
800
|
+
|
|
801
|
+
${captionTemplate}
|
|
802
|
+
|
|
803
|
+
</${pacemCore.P}-slide>`;
|
|
804
|
+
}
|
|
805
|
+
function getDefaultCaptionTemplate(captionProperty = 'caption') {
|
|
806
|
+
return `<${pacemCore.P}-panel hide="{{ $pacem.isNullOrEmpty(^item.${captionProperty}) }}" class="${pacemCore.PCSS}-gallery-caption gallery-caption-default">
|
|
807
|
+
<${pacemCore.P}-span class="paragraph" text="{{ ^item.${captionProperty} }}"></${pacemCore.P}-span>
|
|
808
|
+
</${pacemCore.P}-panel>`;
|
|
809
|
+
}
|
|
810
|
+
let PacemGalleryElement = class PacemGalleryElement extends UI$2.PacemAdaptedIterativeElement {
|
|
811
|
+
constructor() {
|
|
812
|
+
super(...arguments);
|
|
813
|
+
this._templateChangeHandler = (evt) => {
|
|
814
|
+
const proxy = evt.target;
|
|
815
|
+
this._setupWithCaptionTemplate(proxy.target);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
viewActivatedCallback() {
|
|
819
|
+
super.viewActivatedCallback();
|
|
820
|
+
this._setupWithCaptionTemplate();
|
|
821
|
+
this._databind();
|
|
822
|
+
}
|
|
823
|
+
propertyChangedCallback(name, old, val, first) {
|
|
824
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
825
|
+
if (!first) {
|
|
826
|
+
switch (name) {
|
|
827
|
+
case 'datasource':
|
|
828
|
+
this._databind();
|
|
829
|
+
break;
|
|
830
|
+
case 'captionTemplate':
|
|
831
|
+
this._setupWithCaptionTemplate(val, old);
|
|
832
|
+
break;
|
|
833
|
+
case 'imageProperty':
|
|
834
|
+
this._setupWithCaptionTemplate(this.captionTemplate, this.captionTemplate);
|
|
835
|
+
break;
|
|
836
|
+
case 'captionProperty':
|
|
837
|
+
if (pacemCore.Utils.isNull(this.captionTemplate)) {
|
|
838
|
+
this._setupDefaultTemplate();
|
|
839
|
+
}
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
disconnectedCallback() {
|
|
845
|
+
this._disposeTemplate();
|
|
846
|
+
super.disconnectedCallback();
|
|
847
|
+
}
|
|
848
|
+
_disposeTemplate(val = this.captionTemplate) {
|
|
849
|
+
if (val instanceof pacemCore.Components.PacemTemplateProxyElement) {
|
|
850
|
+
val.removeEventListener('templatechange', this._templateChangeHandler);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
_setupWithCaptionTemplate(val = this.captionTemplate, old) {
|
|
854
|
+
this._disposeTemplate(old);
|
|
855
|
+
if (pacemCore.Utils.isNull(val)) {
|
|
856
|
+
this._setupDefaultTemplate();
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
if (val instanceof pacemCore.Components.PacemTemplateProxyElement) {
|
|
860
|
+
val.addEventListener('templatechange', this._templateChangeHandler, false);
|
|
861
|
+
val = val.target;
|
|
862
|
+
}
|
|
863
|
+
const container = val.content.firstElementChild;
|
|
864
|
+
pacemCore.Utils.addClass(container, pacemCore.PCSS + '-gallery-caption');
|
|
865
|
+
const tmpl = document.createElement('template');
|
|
866
|
+
tmpl.innerHTML = getGallerySlideShowTemplate(val.innerHTML, this.imageProperty);
|
|
867
|
+
this._setupTemplate(tmpl);
|
|
868
|
+
}
|
|
869
|
+
_setupTemplate(val) {
|
|
870
|
+
this._templateProxy.target = val;
|
|
871
|
+
}
|
|
872
|
+
_setupDefaultTemplate() {
|
|
873
|
+
const tmpl = document.createElement('template');
|
|
874
|
+
tmpl.innerHTML = getGallerySlideShowTemplate(getDefaultCaptionTemplate(this.captionProperty), this.imageProperty);
|
|
875
|
+
this._setupTemplate(tmpl);
|
|
876
|
+
}
|
|
877
|
+
_databind() {
|
|
878
|
+
const rep = this._repeater;
|
|
879
|
+
if (!pacemCore.Utils.isNull(rep)) {
|
|
880
|
+
rep.datasource = this.datasource;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
get adapter() {
|
|
884
|
+
return this._adapter;
|
|
885
|
+
}
|
|
886
|
+
async _heroAnimate(fromEl, src) {
|
|
887
|
+
if (!pacemCore.Utils.isNull(fromEl)) {
|
|
888
|
+
let pImg = new UI$2.PacemImageElement();
|
|
889
|
+
let goalEl = this._heroPlaceholderProxy.dom[0];
|
|
890
|
+
const TRANSITION = 300;
|
|
891
|
+
pImg.src = src || /* assuming an img-ish element */ fromEl['src'];
|
|
892
|
+
pImg.adapt = 'contain';
|
|
893
|
+
let goal = pacemCore.Utils.offset(goalEl), from = pacemCore.Utils.offset(fromEl), style = pImg.style;
|
|
894
|
+
const cfrStyle = getComputedStyle(goalEl);
|
|
895
|
+
style.border = cfrStyle.border;
|
|
896
|
+
style.width = goalEl.clientWidth + 'px';
|
|
897
|
+
style.height = goalEl.clientHeight + 'px';
|
|
898
|
+
style.position = 'absolute';
|
|
899
|
+
style.zIndex = cfrStyle.zIndex;
|
|
900
|
+
style.top = goal.top + 'px';
|
|
901
|
+
style.left = goal.left + 'px';
|
|
902
|
+
const scaleX = fromEl.clientWidth / goalEl.clientWidth, scaleY = fromEl.clientHeight / goalEl.clientHeight, translateX = (from.left - goal.left) + 'px', translateY = (from.top - goal.top) + 'px';
|
|
903
|
+
style.transformOrigin = '0 0';
|
|
904
|
+
style.transition = `transform cubic-bezier(0.445, 0.05, 0.55, 0.95) ${TRANSITION}ms, opacity ${TRANSITION}ms`;
|
|
905
|
+
style.transform = `translate(${translateX}, ${translateY}) scale(${scaleX}, ${scaleY})`;
|
|
906
|
+
document.body.appendChild(pImg);
|
|
907
|
+
requestAnimationFrame(() => {
|
|
908
|
+
pImg.style.transform = '';
|
|
909
|
+
});
|
|
910
|
+
await pacemCore.Utils.waitForAnimationEnd(pImg, TRANSITION);
|
|
911
|
+
pImg.remove();
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
open(startIndex, heroFrom, src) {
|
|
915
|
+
this._poppingUp = true;
|
|
916
|
+
this._lightbox.show = true;
|
|
917
|
+
this._slideshow.index = startIndex; // reflects on 'this' (twoway)
|
|
918
|
+
this._heroAnimate(heroFrom, src)
|
|
919
|
+
.then(_ => {
|
|
920
|
+
this._poppingUp = false;
|
|
921
|
+
this._slideshow.focus();
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
__decorate$6([
|
|
926
|
+
pacemCore.ViewChild(pacemCore.P + '-adapter')
|
|
927
|
+
], PacemGalleryElement.prototype, "_adapter", void 0);
|
|
928
|
+
__decorate$6([
|
|
929
|
+
pacemCore.ViewChild(pacemCore.P + '-lightbox')
|
|
930
|
+
], PacemGalleryElement.prototype, "_lightbox", void 0);
|
|
931
|
+
__decorate$6([
|
|
932
|
+
pacemCore.ViewChild(pacemCore.P + '-slideshow')
|
|
933
|
+
], PacemGalleryElement.prototype, "_slideshow", void 0);
|
|
934
|
+
__decorate$6([
|
|
935
|
+
pacemCore.ViewChild(pacemCore.P + '-repeater')
|
|
936
|
+
], PacemGalleryElement.prototype, "_repeater", void 0);
|
|
937
|
+
__decorate$6([
|
|
938
|
+
pacemCore.ViewChild(pacemCore.P + '-template-proxy')
|
|
939
|
+
], PacemGalleryElement.prototype, "_templateProxy", void 0);
|
|
940
|
+
__decorate$6([
|
|
941
|
+
pacemCore.ViewChild(pacemCore.P + '-shell-proxy')
|
|
942
|
+
], PacemGalleryElement.prototype, "_heroPlaceholderProxy", void 0);
|
|
943
|
+
__decorate$6([
|
|
944
|
+
pacemCore.Watch()
|
|
945
|
+
], PacemGalleryElement.prototype, "_poppingUp", void 0);
|
|
946
|
+
__decorate$6([
|
|
947
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Element })
|
|
948
|
+
], PacemGalleryElement.prototype, "captionTemplate", void 0);
|
|
949
|
+
__decorate$6([
|
|
950
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
951
|
+
], PacemGalleryElement.prototype, "captionProperty", void 0);
|
|
952
|
+
__decorate$6([
|
|
953
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
954
|
+
], PacemGalleryElement.prototype, "imageProperty", void 0);
|
|
955
|
+
PacemGalleryElement = __decorate$6([
|
|
956
|
+
pacemCore.CustomElement({
|
|
957
|
+
tagName: pacemCore.P + '-gallery', shadow: pacemCore.Defaults.USE_SHADOW_ROOT,
|
|
958
|
+
template: `<${pacemCore.P}-lightbox class="${pacemCore.PCSS}-gallery">
|
|
959
|
+
<${pacemCore.P}-repeater>
|
|
960
|
+
<${pacemCore.P}-slideshow adapter="{{ ::_adapter }}" index="{{ :host.index, twoway }}" hide="{{ !::_lightbox.show }}">
|
|
961
|
+
<${pacemCore.P}-template-proxy></${pacemCore.P}-template-proxy>
|
|
962
|
+
</${pacemCore.P}-slideshow>
|
|
963
|
+
</${pacemCore.P}-repeater>
|
|
964
|
+
<${pacemCore.P}-adapter class="${pacemCore.PCSS}-gallery-adapter"></${pacemCore.P}-adapter>
|
|
965
|
+
</${pacemCore.P}-lightbox>
|
|
966
|
+
<${pacemCore.P}-shell-proxy><div class="${pacemCore.PCSS}-gallery-hero-target"></div></${pacemCore.P}-shell-proxy>`
|
|
967
|
+
})
|
|
968
|
+
], PacemGalleryElement);
|
|
969
|
+
|
|
970
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
971
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
972
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
973
|
+
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;
|
|
974
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
975
|
+
};
|
|
976
|
+
var PacemModalFormElement_1;
|
|
977
|
+
const UI$1 = pacemUi.Components.UI;
|
|
978
|
+
//namespace Pacem.Components.Plus {
|
|
979
|
+
// TODO: use onewaytosource as a binding mode
|
|
980
|
+
let PacemModalFormElement = PacemModalFormElement_1 = class PacemModalFormElement extends UI$1.PacemDialogBase {
|
|
981
|
+
get form() {
|
|
982
|
+
return this._form;
|
|
983
|
+
}
|
|
984
|
+
constructor() {
|
|
985
|
+
super();
|
|
986
|
+
this.suddenValidation = true;
|
|
987
|
+
this.method = pacemCore.Net.HttpMethod.Post;
|
|
988
|
+
this._keyupHandler = (evt) => {
|
|
989
|
+
if (evt.keyCode === /* Enter */ 13
|
|
990
|
+
// no modifiers
|
|
991
|
+
&& !evt.shiftKey && !evt.ctrlKey && !evt.altKey && !evt.metaKey) {
|
|
992
|
+
let btn = evt.currentTarget.querySelector(`.${pacemCore.PCSS}-dialog-buttons ${pacemCore.P}-button[type=submit]`);
|
|
993
|
+
if (!pacemCore.Utils.isNull(btn) && pacemCore.Utils.isVisible(btn) && !btn.disabled) {
|
|
994
|
+
btn.click();
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
this.#keepStateOnCommit = false;
|
|
999
|
+
this._emitter = new pacemScaffolding.Components.Scaffolding.FormEventEmitter(this);
|
|
1000
|
+
}
|
|
1001
|
+
viewActivatedCallback() {
|
|
1002
|
+
super.viewActivatedCallback();
|
|
1003
|
+
// HACK: move the buttons outside the .pacem-scrollable element in the lightbox
|
|
1004
|
+
//var lightboxCore = this.querySelector(`.${PCSS}-lightbox`);
|
|
1005
|
+
//lightboxCore.appendChild(
|
|
1006
|
+
// this._buttons = this.querySelector(`.${PCSS}-dialog-buttons`)
|
|
1007
|
+
//);
|
|
1008
|
+
//lightboxCore.appendChild(
|
|
1009
|
+
// this.querySelector(`.${PCSS}-dialog-heading`)
|
|
1010
|
+
//);
|
|
1011
|
+
//lightboxCore.appendChild(
|
|
1012
|
+
// this.querySelector(P + '-loader')
|
|
1013
|
+
//);
|
|
1014
|
+
//this.dispatchEvent(new PropertyChangeEvent({ propertyName: 'modalButtons', currentValue: this.modalButtons }));
|
|
1015
|
+
this.addEventListener('keyup', this._keyupHandler, false);
|
|
1016
|
+
this._emitter.start();
|
|
1017
|
+
}
|
|
1018
|
+
disconnectedCallback() {
|
|
1019
|
+
this._emitter.stop();
|
|
1020
|
+
this.removeEventListener('keyup', this._keyupHandler, false);
|
|
1021
|
+
super.disconnectedCallback();
|
|
1022
|
+
}
|
|
1023
|
+
_submit(evt) {
|
|
1024
|
+
if (this.readonly) {
|
|
1025
|
+
this.commit(UI$1.DialogButton.Ok, evt);
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
pacemCore.avoidHandler(evt);
|
|
1029
|
+
this._form.validate().then(valid => {
|
|
1030
|
+
if (valid) {
|
|
1031
|
+
if (pacemCore.Utils.isNullOrEmpty(this.action)) {
|
|
1032
|
+
this.commit(UI$1.DialogButton.Ok, evt);
|
|
1033
|
+
}
|
|
1034
|
+
else {
|
|
1035
|
+
this._form.submit(this._fetcher).then(_ => {
|
|
1036
|
+
this.commit(UI$1.DialogButton.Ok, evt);
|
|
1037
|
+
}, r => {
|
|
1038
|
+
// do nothing
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
_onSubmit(evt) {
|
|
1046
|
+
// no need to broadcast, event bubbles itself...
|
|
1047
|
+
// ...just handle it using the eventual listeners:
|
|
1048
|
+
this.emit(evt);
|
|
1049
|
+
}
|
|
1050
|
+
#keepStateOnCommit;
|
|
1051
|
+
open(state, keepStateOnCommit, setAsPristine = true) {
|
|
1052
|
+
if (pacemCore.Utils.isNull(state)) {
|
|
1053
|
+
throw `The state of a ${PacemModalFormElement_1} cannot be null.`;
|
|
1054
|
+
}
|
|
1055
|
+
this.#keepStateOnCommit = keepStateOnCommit;
|
|
1056
|
+
var retval = super.open(state);
|
|
1057
|
+
if (setAsPristine) {
|
|
1058
|
+
this._form.setPristine();
|
|
1059
|
+
}
|
|
1060
|
+
return retval;
|
|
1061
|
+
}
|
|
1062
|
+
commit(btn, evt) {
|
|
1063
|
+
super.commit(btn, evt);
|
|
1064
|
+
if (!this.#keepStateOnCommit) {
|
|
1065
|
+
pacemCore.Utils.waitForAnimationEnd(this, 500).then(_ => {
|
|
1066
|
+
// BREAKING change (v0.8.37): state destroyed when dialog committed
|
|
1067
|
+
// TODO: consider 'if' and 'how' to avoid this.
|
|
1068
|
+
this.state = {};
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
_cancel(evt) {
|
|
1073
|
+
this.commit(UI$1.DialogButton.Cancel, evt);
|
|
1074
|
+
this._form.reset();
|
|
1075
|
+
}
|
|
1076
|
+
_broadcast(evt) {
|
|
1077
|
+
this.dispatchEvent(new CustomEvent(evt.type, { detail: evt.detail }));
|
|
1078
|
+
}
|
|
1079
|
+
/** Gets the 'ok' and 'cancel' modal buttons. */
|
|
1080
|
+
get modalButtons() {
|
|
1081
|
+
const btns = this._buttons;
|
|
1082
|
+
return {
|
|
1083
|
+
ok: btns && btns.firstElementChild && btns.firstElementChild.firstElementChild,
|
|
1084
|
+
cancel: btns && btns.firstElementChild && btns.firstElementChild.lastElementChild
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
__decorate$5([
|
|
1089
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
1090
|
+
], PacemModalFormElement.prototype, "suddenValidation", void 0);
|
|
1091
|
+
__decorate$5([
|
|
1092
|
+
pacemCore.Watch({ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
1093
|
+
], PacemModalFormElement.prototype, "okCaption", void 0);
|
|
1094
|
+
__decorate$5([
|
|
1095
|
+
pacemCore.Watch({ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
1096
|
+
], PacemModalFormElement.prototype, "cancelCaption", void 0);
|
|
1097
|
+
__decorate$5([
|
|
1098
|
+
pacemCore.Watch({ reflectBack: true, converter: pacemCore.PropertyConverters.String })
|
|
1099
|
+
], PacemModalFormElement.prototype, "method", void 0);
|
|
1100
|
+
__decorate$5([
|
|
1101
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
1102
|
+
], PacemModalFormElement.prototype, "metadata", void 0);
|
|
1103
|
+
__decorate$5([
|
|
1104
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1105
|
+
], PacemModalFormElement.prototype, "action", void 0);
|
|
1106
|
+
__decorate$5([
|
|
1107
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1108
|
+
], PacemModalFormElement.prototype, "loaderType", void 0);
|
|
1109
|
+
__decorate$5([
|
|
1110
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
1111
|
+
], PacemModalFormElement.prototype, "success", void 0);
|
|
1112
|
+
__decorate$5([
|
|
1113
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
1114
|
+
], PacemModalFormElement.prototype, "fail", void 0);
|
|
1115
|
+
__decorate$5([
|
|
1116
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
1117
|
+
], PacemModalFormElement.prototype, "readonly", void 0);
|
|
1118
|
+
__decorate$5([
|
|
1119
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
1120
|
+
], PacemModalFormElement.prototype, "fetchHeaders", void 0);
|
|
1121
|
+
__decorate$5([
|
|
1122
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1123
|
+
], PacemModalFormElement.prototype, "fetchCredentials", void 0);
|
|
1124
|
+
__decorate$5([
|
|
1125
|
+
pacemCore.ViewChild(pacemCore.P + '-lightbox')
|
|
1126
|
+
], PacemModalFormElement.prototype, "lightbox", void 0);
|
|
1127
|
+
__decorate$5([
|
|
1128
|
+
pacemCore.ViewChild(pacemCore.P + '-form[entity]')
|
|
1129
|
+
], PacemModalFormElement.prototype, "_form", void 0);
|
|
1130
|
+
__decorate$5([
|
|
1131
|
+
pacemCore.ViewChild(pacemCore.P + '-fetch')
|
|
1132
|
+
], PacemModalFormElement.prototype, "_fetcher", void 0);
|
|
1133
|
+
PacemModalFormElement = PacemModalFormElement_1 = __decorate$5([
|
|
1134
|
+
pacemCore.CustomElement({
|
|
1135
|
+
tagName: pacemCore.P + '-modal-form', shadow: pacemCore.Defaults.USE_SHADOW_ROOT,
|
|
1136
|
+
template: `<${pacemCore.P}-lightbox modal="true" logger="{{ :host.logger }}">
|
|
1137
|
+
<${pacemCore.P}-form wrapper>
|
|
1138
|
+
<${pacemCore.P}-form logger="{{ :host.logger }}" on-submit=":host._onSubmit($event)" readonly="{{ :host.readonly }}" entity="{{ :host.state, twoway }}" on-success=":host._broadcast($event)"
|
|
1139
|
+
on-fail=":host._broadcast($event)" success="{{ :host.success, twoway }}" fail="{{ :host.fail, twoway }}" autogenerate="{{ !$pacem.isNull($this.entity) }}" metadata="{{ :host.metadata }}"
|
|
1140
|
+
fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" sudden-validation="{{ :host.suddenValidation }}"></${pacemCore.P}-form>
|
|
1141
|
+
</${pacemCore.P}-form>
|
|
1142
|
+
<${pacemCore.P}-fetch logger="{{ :host.logger }}" method="{{ :host.method }}" headers="{{ :host.fetchHeaders }}" credentials="{{ :host.fetchCredentials }}" autofetch="false" url="{{ :host.action }}"></${pacemCore.P}-fetch>
|
|
1143
|
+
<div class="${pacemCore.PCSS}-dialog-buttons ${pacemCore.PCSS}-buttonset buttons" slot="bottom">
|
|
1144
|
+
<div class="buttonset-left">
|
|
1145
|
+
<${pacemCore.P}-button on-click=":host._submit($event)" css-class="{{ {'buttonset-last': :host.readonly} }}" type="submit"
|
|
1146
|
+
class="button primary button-size size-small" disabled="{{ (:host.suddenValidation && !:host.readonly && !(::_form.valid && ::_form.dirty)) || ::_fetcher.fetching }}">
|
|
1147
|
+
<${pacemCore.P}-panel class="submit-spinner ${pacemCore.PCSS}-anim anim-pop" hide="{{ !::_form.fetching }}"><i class="${pacemCore.PCSS}-icon ${pacemCore.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${pacemCore.P}-panel>
|
|
1148
|
+
<${pacemCore.P}-text text="{{ :host.okCaption || 'OK' }}"></${pacemCore.P}-text>
|
|
1149
|
+
</${pacemCore.P}-button>
|
|
1150
|
+
<${pacemCore.P}-button on-click=":host._cancel($event)" hide="{{ :host.readonly }}" class="button button-size size-small" disabled="{{ ::_fetcher.fetching }}"><${pacemCore.P}-text text="{{ :host.cancelCaption || 'Cancel' }}"></${pacemCore.P}-text></${pacemCore.P}-button>
|
|
1151
|
+
</div></div>
|
|
1152
|
+
<div class="${pacemCore.PCSS}-dialog-heading" slot="top">
|
|
1153
|
+
<${pacemCore.P}-content></${pacemCore.P}-content>
|
|
1154
|
+
</div>
|
|
1155
|
+
<div class="pos-absolute absolute-top absolute-right absolute-left absolute-bottom overflow-hidden ${pacemCore.PCSS}-inert display-flex flex-center flex-middle">
|
|
1156
|
+
<${pacemCore.P}-loader type="{{ :host.loaderType }}" class="loader-primary loader-smaller ${pacemCore.PCSS}-anim anim-pop" active="{{ ::_fetcher.fetching }}"></${pacemCore.P}-loader>
|
|
1157
|
+
</div>
|
|
1158
|
+
</${pacemCore.P}-lightbox>`
|
|
1159
|
+
})
|
|
1160
|
+
], PacemModalFormElement);
|
|
1161
|
+
|
|
1162
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1163
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1164
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1165
|
+
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;
|
|
1166
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1167
|
+
};
|
|
1168
|
+
//namespace Pacem.Components.Plus {
|
|
1169
|
+
let PacemRouterHashStateElement = class PacemRouterHashStateElement extends pacemCore.PacemEventTarget {
|
|
1170
|
+
constructor() {
|
|
1171
|
+
super(...arguments);
|
|
1172
|
+
this.default = {};
|
|
1173
|
+
this.state = {};
|
|
1174
|
+
this.normalizedState = {};
|
|
1175
|
+
this._routerNavigatingHandler = (_) => {
|
|
1176
|
+
this.#locked = true;
|
|
1177
|
+
};
|
|
1178
|
+
this._routerNavigateHandler = (_) => {
|
|
1179
|
+
this.#locked = false;
|
|
1180
|
+
this._updateStateFromURI();
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
#locked;
|
|
1184
|
+
viewActivatedCallback() {
|
|
1185
|
+
super.viewActivatedCallback();
|
|
1186
|
+
this._updateStateFromURI();
|
|
1187
|
+
this._setupRouterHandlers(this.router);
|
|
1188
|
+
}
|
|
1189
|
+
propertyChangedCallback(name, old, val, first) {
|
|
1190
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
1191
|
+
switch (name) {
|
|
1192
|
+
case 'state':
|
|
1193
|
+
if (!first && !this.#locked) {
|
|
1194
|
+
this._updateNormalizedState();
|
|
1195
|
+
this._updateURIFromState();
|
|
1196
|
+
}
|
|
1197
|
+
break;
|
|
1198
|
+
case 'disabled':
|
|
1199
|
+
if (!!val) {
|
|
1200
|
+
this._updateStateFromURI();
|
|
1201
|
+
}
|
|
1202
|
+
break;
|
|
1203
|
+
case 'default':
|
|
1204
|
+
this._updateStateFromURI();
|
|
1205
|
+
break;
|
|
1206
|
+
case 'router':
|
|
1207
|
+
if (!first) {
|
|
1208
|
+
this._disposeRouterHandlers(old);
|
|
1209
|
+
this._setupRouterHandlers(val);
|
|
1210
|
+
}
|
|
1211
|
+
break;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
disconnectedCallback() {
|
|
1215
|
+
this._disposeRouterHandlers();
|
|
1216
|
+
super.disconnectedCallback();
|
|
1217
|
+
}
|
|
1218
|
+
_setupRouterHandlers(router = this.router) {
|
|
1219
|
+
if (!pacemCore.Utils.isNull(router)) {
|
|
1220
|
+
window.addEventListener('navigating', this._routerNavigatingHandler, false);
|
|
1221
|
+
window.addEventListener('navigate', this._routerNavigateHandler, false);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
_disposeRouterHandlers(router = this.router) {
|
|
1225
|
+
if (!pacemCore.Utils.isNull(router)) {
|
|
1226
|
+
window.removeEventListener('navigating', this._routerNavigatingHandler, false);
|
|
1227
|
+
window.removeEventListener('navigate', this._routerNavigateHandler, false);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
_currentBasePath() {
|
|
1231
|
+
const router = this.router;
|
|
1232
|
+
if (!pacemCore.Utils.isNull(router)) {
|
|
1233
|
+
const q = router.state.$querystring;
|
|
1234
|
+
return this._normalizePath(document.location.pathname, q);
|
|
1235
|
+
}
|
|
1236
|
+
return null;
|
|
1237
|
+
}
|
|
1238
|
+
_normalizePath(path, q) {
|
|
1239
|
+
if (pacemCore.Utils.isNullOrEmpty(path)) {
|
|
1240
|
+
return path;
|
|
1241
|
+
}
|
|
1242
|
+
if (path.endsWith('/')) {
|
|
1243
|
+
path = path.substring(0, path.length - 1);
|
|
1244
|
+
}
|
|
1245
|
+
q ??= '';
|
|
1246
|
+
return path + (q.length > 0 ? ('?' + q) : '');
|
|
1247
|
+
}
|
|
1248
|
+
_areStatesEquivalent(s1, s2) {
|
|
1249
|
+
const state1 = pacemCore.Utils.extend({}, s1 || {}), state2 = pacemCore.Utils.extend({}, s2 || {});
|
|
1250
|
+
for (let prop in state1) {
|
|
1251
|
+
if (!this._areSubstantiallyEquivalent(state1[prop], state2[prop])) {
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
delete state1[prop];
|
|
1255
|
+
delete state2[prop];
|
|
1256
|
+
}
|
|
1257
|
+
for (let prop in state2) {
|
|
1258
|
+
if (!this._areSubstantiallyEquivalent(state1[prop], state2[prop])) {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
return true;
|
|
1263
|
+
}
|
|
1264
|
+
_updateNormalizedState(state = this.state) {
|
|
1265
|
+
if (this.disabled || this.#locked) {
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
const normalizedState = this._normalizeState(state);
|
|
1269
|
+
if (!this._areStatesEquivalent(normalizedState, this.normalizedState)) {
|
|
1270
|
+
this.normalizedState = normalizedState;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
_updateStateFromURI() {
|
|
1274
|
+
if (this.disabled || this.#locked) {
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
var state = pacemCore.Utils.extend({}, this.default || {});
|
|
1278
|
+
const router = this.router;
|
|
1279
|
+
if (!pacemCore.Utils.isNull(router)) {
|
|
1280
|
+
const denormalized = this._denormalizeState(pacemCore.Utils.URIs.parseQuery(router.state && router.state.$hash || '{}'));
|
|
1281
|
+
pacemCore.Utils.extend(state, denormalized);
|
|
1282
|
+
}
|
|
1283
|
+
if (!this._areStatesEquivalent(this.state, state)) {
|
|
1284
|
+
this.state = state;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
_updateURIFromState(state = this.normalizedState) {
|
|
1288
|
+
if (this.disabled || this.#locked) {
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
const router = this.router;
|
|
1292
|
+
if (!pacemCore.Utils.isNull(router)) {
|
|
1293
|
+
const actual = this._currentBasePath();
|
|
1294
|
+
const currentState = pacemCore.Utils.URIs.parseQuery(router.state.$hash || '{}'), targetState = state || {};
|
|
1295
|
+
if (!this._areStatesEquivalent(currentState, targetState)) {
|
|
1296
|
+
// checked state equivalence to avoid superfluous navigation
|
|
1297
|
+
const clean = this._cleanupStateForURI(targetState);
|
|
1298
|
+
var url = actual;
|
|
1299
|
+
if (!pacemCore.Utils.isNullOrEmpty(clean)) {
|
|
1300
|
+
url = pacemCore.Utils.URIs.appendQuery(actual, clean, false, true);
|
|
1301
|
+
}
|
|
1302
|
+
// navigate
|
|
1303
|
+
router.path = url;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
_areSubstantiallyEquivalent(v1, v2) {
|
|
1308
|
+
v1 ??= '';
|
|
1309
|
+
v2 ??= '';
|
|
1310
|
+
return v1.toString() == v2.toString() || pacemCore.Utils.areSemanticallyEqual(v1, v2) || JSON.stringify(v1) === JSON.stringify(v2);
|
|
1311
|
+
}
|
|
1312
|
+
_cleanupStateForURI(state = this.state) {
|
|
1313
|
+
const copy = pacemCore.Utils.clone(state || {}), base = this.default;
|
|
1314
|
+
for (let key in copy) {
|
|
1315
|
+
if ((pacemCore.Utils.isNullOrEmpty(copy[key]) && (pacemCore.Utils.isNull(base) || !(key in base)))
|
|
1316
|
+
|| (!pacemCore.Utils.isNull(base) && (key in base) && this._areSubstantiallyEquivalent(base[key], copy[key]))) {
|
|
1317
|
+
delete copy[key];
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
return copy;
|
|
1321
|
+
}
|
|
1322
|
+
_normalizeState(state = this.state, mold = this.default) {
|
|
1323
|
+
var output = {};
|
|
1324
|
+
const base = mold;
|
|
1325
|
+
for (let key in state || {}) {
|
|
1326
|
+
const value = state[key];
|
|
1327
|
+
if (pacemCore.Utils.isNullOrEmpty(value)) {
|
|
1328
|
+
if (!pacemCore.Utils.isNull(base) && (key in base) && !pacemCore.Utils.isNullOrEmpty(base[key])) {
|
|
1329
|
+
output[key] = '';
|
|
1330
|
+
}
|
|
1331
|
+
continue;
|
|
1332
|
+
}
|
|
1333
|
+
switch (typeof value) {
|
|
1334
|
+
case 'number':
|
|
1335
|
+
case 'bigint':
|
|
1336
|
+
case 'boolean':
|
|
1337
|
+
Object.defineProperty(output, key, { enumerable: true, value: value.toString() });
|
|
1338
|
+
break;
|
|
1339
|
+
case 'symbol':
|
|
1340
|
+
case 'string':
|
|
1341
|
+
Object.defineProperty(output, key, { enumerable: true, value });
|
|
1342
|
+
break;
|
|
1343
|
+
default:
|
|
1344
|
+
if (pacemCore.Utils.Dates.isDate(value)) {
|
|
1345
|
+
Object.defineProperty(output, key, { enumerable: true, value: value.toISOString() });
|
|
1346
|
+
}
|
|
1347
|
+
else if (value instanceof RegExp) {
|
|
1348
|
+
Object.defineProperty(output, key, { enumerable: true, value: value.source });
|
|
1349
|
+
}
|
|
1350
|
+
else {
|
|
1351
|
+
throw new Error('Type not supported to be normalized into a URI hash.');
|
|
1352
|
+
}
|
|
1353
|
+
break;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
return output;
|
|
1357
|
+
}
|
|
1358
|
+
_denormalizeState(state = this.normalizedState, mold = this.default) {
|
|
1359
|
+
const output = {};
|
|
1360
|
+
const base = mold || {};
|
|
1361
|
+
for (let prop in state) {
|
|
1362
|
+
if (!(prop in base)) {
|
|
1363
|
+
output[prop] = state[prop];
|
|
1364
|
+
continue;
|
|
1365
|
+
}
|
|
1366
|
+
const moldProp = base[prop], value = state[prop];
|
|
1367
|
+
switch (typeof moldProp) {
|
|
1368
|
+
case 'boolean':
|
|
1369
|
+
Object.defineProperty(output, prop, { enumerable: true, value: pacemCore.PropertyConverters.Boolean.convert(value) });
|
|
1370
|
+
break;
|
|
1371
|
+
case 'number':
|
|
1372
|
+
case 'bigint':
|
|
1373
|
+
Object.defineProperty(output, prop, { enumerable: true, value: pacemCore.PropertyConverters.Number.convert(value) });
|
|
1374
|
+
break;
|
|
1375
|
+
case 'symbol':
|
|
1376
|
+
case 'string':
|
|
1377
|
+
Object.defineProperty(output, prop, { enumerable: true, value: pacemCore.PropertyConverters.String.convert(value) });
|
|
1378
|
+
break;
|
|
1379
|
+
default:
|
|
1380
|
+
if (moldProp instanceof Date) {
|
|
1381
|
+
Object.defineProperty(output, prop, { enumerable: true, value: pacemCore.PropertyConverters.Date.convert(value) });
|
|
1382
|
+
}
|
|
1383
|
+
else if (moldProp instanceof RegExp) {
|
|
1384
|
+
Object.defineProperty(output, prop, { enumerable: true, value: new RegExp(value, moldProp.flags) });
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
Object.defineProperty(output, prop, { enumerable: true, value });
|
|
1388
|
+
}
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return output;
|
|
1393
|
+
}
|
|
1394
|
+
set(key, value) {
|
|
1395
|
+
var obj = {};
|
|
1396
|
+
if (typeof key === 'string') {
|
|
1397
|
+
Object.defineProperty(obj, key, { enumerable: true, value });
|
|
1398
|
+
}
|
|
1399
|
+
else {
|
|
1400
|
+
obj = key;
|
|
1401
|
+
}
|
|
1402
|
+
this.state = pacemCore.Utils.extend({}, this.state || {}, obj);
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
__decorate$4([
|
|
1406
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Element })
|
|
1407
|
+
], PacemRouterHashStateElement.prototype, "router", void 0);
|
|
1408
|
+
__decorate$4([
|
|
1409
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json })
|
|
1410
|
+
], PacemRouterHashStateElement.prototype, "default", void 0);
|
|
1411
|
+
__decorate$4([
|
|
1412
|
+
pacemCore.Watch()
|
|
1413
|
+
], PacemRouterHashStateElement.prototype, "state", void 0);
|
|
1414
|
+
__decorate$4([
|
|
1415
|
+
pacemCore.Watch()
|
|
1416
|
+
], PacemRouterHashStateElement.prototype, "normalizedState", void 0);
|
|
1417
|
+
PacemRouterHashStateElement = __decorate$4([
|
|
1418
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-router-hash-state' })
|
|
1419
|
+
], PacemRouterHashStateElement);
|
|
1420
|
+
|
|
1421
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1422
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1423
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1424
|
+
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;
|
|
1425
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1426
|
+
};
|
|
1427
|
+
//namespace Pacem.Components.Plus {
|
|
1428
|
+
let PacemSearchElement = class PacemSearchElement extends pacemCore.Components.PacemElement {
|
|
1429
|
+
constructor() {
|
|
1430
|
+
super(...arguments);
|
|
1431
|
+
this.hintParameter = 'q';
|
|
1432
|
+
}
|
|
1433
|
+
propertyChangedCallback(name, old, val, first) {
|
|
1434
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
1435
|
+
if (name === 'hint') {
|
|
1436
|
+
let params = {};
|
|
1437
|
+
params[this.hintParameter] = val;
|
|
1438
|
+
this._fetcher.parameters = params;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
__decorate$3([
|
|
1443
|
+
pacemCore.ViewChild(pacemCore.P + '-fetch')
|
|
1444
|
+
], PacemSearchElement.prototype, "_fetcher", void 0);
|
|
1445
|
+
__decorate$3([
|
|
1446
|
+
pacemCore.Watch()
|
|
1447
|
+
], PacemSearchElement.prototype, "datasource", void 0);
|
|
1448
|
+
__decorate$3([
|
|
1449
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1450
|
+
], PacemSearchElement.prototype, "hint", void 0);
|
|
1451
|
+
__decorate$3([
|
|
1452
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1453
|
+
], PacemSearchElement.prototype, "url", void 0);
|
|
1454
|
+
__decorate$3([
|
|
1455
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1456
|
+
], PacemSearchElement.prototype, "method", void 0);
|
|
1457
|
+
__decorate$3([
|
|
1458
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
1459
|
+
], PacemSearchElement.prototype, "hintParameter", void 0);
|
|
1460
|
+
PacemSearchElement = __decorate$3([
|
|
1461
|
+
pacemCore.CustomElement({
|
|
1462
|
+
tagName: pacemCore.P + '-search', shadow: pacemCore.Defaults.USE_SHADOW_ROOT,
|
|
1463
|
+
template: `<${pacemCore.P}-fetch debounce="800" url="{{ :host.url }}" method="{{ :host.method }}">
|
|
1464
|
+
</${pacemCore.P}-fetch><${pacemCore.P}-input-search value="{{ :host.hint, twoway }}"></${pacemCore.P}-input-search>
|
|
1465
|
+
<${pacemCore.P}-repeater datasource="{{ ::_fetch.result }}">
|
|
1466
|
+
<${pacemCore.P}-content></${pacemCore.P}-content>
|
|
1467
|
+
</${pacemCore.P}-repeater>`
|
|
1468
|
+
})
|
|
1469
|
+
], PacemSearchElement);
|
|
1470
|
+
|
|
1471
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1472
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1473
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1474
|
+
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;
|
|
1475
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1476
|
+
};
|
|
1477
|
+
//namespace Pacem.Components.Plus {
|
|
1478
|
+
const DataRowSelectChangeEventName = "datarowselectchange";
|
|
1479
|
+
class DataRowSelectChangeEvent extends CustomEvent {
|
|
1480
|
+
constructor(detail) {
|
|
1481
|
+
super(DataRowSelectChangeEventName, { detail, bubbles: false, cancelable: true });
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
const EMPTY_CSS = {};
|
|
1485
|
+
const EMPTY_CSSCLASS = [];
|
|
1486
|
+
let PacemDataCellElement = class PacemDataCellElement extends PacemBaseCellElement {
|
|
1487
|
+
updateLayout(metadata = this.metadata) {
|
|
1488
|
+
this._setup(metadata);
|
|
1489
|
+
}
|
|
1490
|
+
connectedCallback() {
|
|
1491
|
+
super.connectedCallback();
|
|
1492
|
+
pacemCore.Utils.addClass(this, pacemCore.PCSS + '-datacell');
|
|
1493
|
+
}
|
|
1494
|
+
propertyChangedCallback(name, old, val, first) {
|
|
1495
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
1496
|
+
if (!first) {
|
|
1497
|
+
switch (name) {
|
|
1498
|
+
case '_contentTooltip':
|
|
1499
|
+
this._updateTooltipJustInCase();
|
|
1500
|
+
break;
|
|
1501
|
+
case 'gridState':
|
|
1502
|
+
case 'rowindex':
|
|
1503
|
+
this._updateSelection();
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
_updateTooltipJustInCase() {
|
|
1509
|
+
const tip = this.metadata.dataCell?.autoTooltip ?? true;
|
|
1510
|
+
if (tip && !pacemCore.Utils.isNullOrEmpty(this._contentTooltip)) {
|
|
1511
|
+
this.setAttribute('tooltip', this._contentTooltip);
|
|
1512
|
+
}
|
|
1513
|
+
else {
|
|
1514
|
+
this.removeAttribute('tooltip');
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
_inflateContent(item = this.dataitem, index = this.rowindex, metadata = this.metadata) {
|
|
1518
|
+
this._contentTooltip = '';
|
|
1519
|
+
let format = metadata.dataCell?.format;
|
|
1520
|
+
const nullValue = metadata.dataCell?.null ?? '';
|
|
1521
|
+
// is 'format' a custom function?
|
|
1522
|
+
if (typeof format === 'function') {
|
|
1523
|
+
const htmlOrNode = format(this, metadata, item, index);
|
|
1524
|
+
if (pacemCore.Utils.isNullOrEmpty(htmlOrNode)) {
|
|
1525
|
+
return nullValue;
|
|
1526
|
+
}
|
|
1527
|
+
if (typeof htmlOrNode === 'string') {
|
|
1528
|
+
return htmlOrNode;
|
|
1529
|
+
}
|
|
1530
|
+
return htmlOrNode;
|
|
1531
|
+
}
|
|
1532
|
+
// standard column
|
|
1533
|
+
const tget = pacemCore.CustomElementUtils.resolvePath(metadata.prop, item)?.target;
|
|
1534
|
+
const plainValue = tget?.value;
|
|
1535
|
+
if (pacemCore.Utils.isNullOrEmpty(plainValue)) {
|
|
1536
|
+
return nullValue;
|
|
1537
|
+
}
|
|
1538
|
+
const culture = pacemCore.Utils.lang(this);
|
|
1539
|
+
switch (metadata.dataType) {
|
|
1540
|
+
case "boolean":
|
|
1541
|
+
return `<${pacemCore.P}-icon icon="material ${(!plainValue ? 'radio_button_unchecked' : 'check_circle_outline')} text-big-steady"></${pacemCore.P}-icon>`;
|
|
1542
|
+
case "time":
|
|
1543
|
+
case "date":
|
|
1544
|
+
case "datetime":
|
|
1545
|
+
return this._contentTooltip = pacemCore.Utils.core.date(plainValue, format, culture);
|
|
1546
|
+
case "byte":
|
|
1547
|
+
case "int16":
|
|
1548
|
+
case "int32":
|
|
1549
|
+
case "int64":
|
|
1550
|
+
case "short":
|
|
1551
|
+
case "integer":
|
|
1552
|
+
case "int":
|
|
1553
|
+
case "long":
|
|
1554
|
+
case "double":
|
|
1555
|
+
case "decimal":
|
|
1556
|
+
case "float":
|
|
1557
|
+
case "single":
|
|
1558
|
+
case "number":
|
|
1559
|
+
return this._contentTooltip = pacemCore.Utils.core.number(plainValue, format || '', culture);
|
|
1560
|
+
case "currency":
|
|
1561
|
+
format ??= 'EUR';
|
|
1562
|
+
if (typeof format === 'string') {
|
|
1563
|
+
return this._contentTooltip = pacemCore.Utils.core.currency(plainValue, format, culture);
|
|
1564
|
+
}
|
|
1565
|
+
return this._contentTooltip = pacemCore.Utils.core.number(plainValue, format, culture);
|
|
1566
|
+
case "percent":
|
|
1567
|
+
case "percentage":
|
|
1568
|
+
format ??= { style: 'percent', maximumFractionDigits: 2 };
|
|
1569
|
+
if (typeof format === 'string') {
|
|
1570
|
+
return this._contentTooltip = pacemCore.Utils.core.currency(plainValue, format, culture);
|
|
1571
|
+
}
|
|
1572
|
+
return this._contentTooltip = pacemCore.Utils.core.number(plainValue, format, culture);
|
|
1573
|
+
case "url":
|
|
1574
|
+
case "emailaddress":
|
|
1575
|
+
case "phonenumber":
|
|
1576
|
+
// TODO: render links
|
|
1577
|
+
default:
|
|
1578
|
+
return this._contentTooltip = plainValue;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
// @Debounce(true)
|
|
1582
|
+
_inflateCssClass(item = this.dataitem, index = this.rowindex, metadata = this.metadata, datasource) {
|
|
1583
|
+
if (pacemCore.Utils.isNull(item) || pacemCore.Utils.isNullOrEmpty(metadata)) {
|
|
1584
|
+
return EMPTY_CSSCLASS;
|
|
1585
|
+
}
|
|
1586
|
+
const cssClass = metadata.dataCell && metadata.dataCell.cssClass || EMPTY_CSSCLASS;
|
|
1587
|
+
const retval = [];
|
|
1588
|
+
if (typeof cssClass === 'function') {
|
|
1589
|
+
Array.prototype.push.apply(retval, cssClass(this, metadata, item, index) || []);
|
|
1590
|
+
}
|
|
1591
|
+
else {
|
|
1592
|
+
Array.prototype.push.apply(retval, cssClass);
|
|
1593
|
+
}
|
|
1594
|
+
// alignment
|
|
1595
|
+
switch (metadata.dataCell?.verticalAlign?.toLowerCase()) {
|
|
1596
|
+
case 'top':
|
|
1597
|
+
retval.push('datacell-top');
|
|
1598
|
+
break;
|
|
1599
|
+
case 'bottom':
|
|
1600
|
+
retval.push('datacell-bottom');
|
|
1601
|
+
break;
|
|
1602
|
+
case 'middle':
|
|
1603
|
+
retval.push('datacell-middle');
|
|
1604
|
+
break;
|
|
1605
|
+
}
|
|
1606
|
+
switch (metadata.dataCell?.horizontalAlign?.toLowerCase()) {
|
|
1607
|
+
// headcell display is flex: set h-alignment at container-level
|
|
1608
|
+
case 'left':
|
|
1609
|
+
retval.push('datacell-left');
|
|
1610
|
+
break;
|
|
1611
|
+
case 'right':
|
|
1612
|
+
retval.push('datacell-right');
|
|
1613
|
+
break;
|
|
1614
|
+
case 'center':
|
|
1615
|
+
retval.push('datacell-center');
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
if (datasource?.length) {
|
|
1619
|
+
if (index === 0) {
|
|
1620
|
+
retval.push('datacell-firstrow');
|
|
1621
|
+
}
|
|
1622
|
+
if (index === (datasource.length - 1)) {
|
|
1623
|
+
retval.push('datacell-lastrow');
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return retval;
|
|
1627
|
+
}
|
|
1628
|
+
_inflateCss(item = this.dataitem, index = this.rowindex, metadata = this.metadata) {
|
|
1629
|
+
if (pacemCore.Utils.isNull(item) || pacemCore.Utils.isNullOrEmpty(metadata)) {
|
|
1630
|
+
return EMPTY_CSS;
|
|
1631
|
+
}
|
|
1632
|
+
const css = metadata.dataCell && metadata.dataCell.css || EMPTY_CSS;
|
|
1633
|
+
if (typeof css === 'function') {
|
|
1634
|
+
return css(this, metadata, item, index);
|
|
1635
|
+
}
|
|
1636
|
+
return css;
|
|
1637
|
+
}
|
|
1638
|
+
_setup(metadata = this.metadata) {
|
|
1639
|
+
this.setAttribute("css-class", "{{ this._inflateCssClass(^item, ^index, this.metadata, :host.datasource) }}");
|
|
1640
|
+
this.setAttribute("css", "{{ Pacem.Utils.extend({ 'grid-row': ^index+2 }, this._inflateCss(^item, ^index, this.metadata, :host.datasource)) }}");
|
|
1641
|
+
const truncate = !!(metadata.dataCell?.textEllipsis);
|
|
1642
|
+
const contentCssClass = truncate ? ['text-truncate'] : [];
|
|
1643
|
+
const selectMode = metadata?.dataCell?.selectMode?.toLowerCase();
|
|
1644
|
+
switch (selectMode) {
|
|
1645
|
+
case 'cell':
|
|
1646
|
+
case 'row':
|
|
1647
|
+
// make the content wrapper inert so that the click event can bubble
|
|
1648
|
+
contentCssClass.push(pacemCore.PCSS + '-inert');
|
|
1649
|
+
contentCssClass.push(pacemCore.PCSS + '-unselect');
|
|
1650
|
+
break;
|
|
1651
|
+
}
|
|
1652
|
+
this._content.cssClass = contentCssClass;
|
|
1653
|
+
this._updateSelection();
|
|
1654
|
+
}
|
|
1655
|
+
_updateSelection() {
|
|
1656
|
+
const selectedRows = this.gridState?.selectedRows ?? [];
|
|
1657
|
+
if (selectedRows.indexOf(this.rowindex) >= 0) {
|
|
1658
|
+
pacemCore.Utils.addClass(this, 'datarow-selected datacell-filled datacell-primary');
|
|
1659
|
+
}
|
|
1660
|
+
else {
|
|
1661
|
+
pacemCore.Utils.removeClass(this, 'datarow-selected datacell-filled datacell-primary');
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
__decorate$2([
|
|
1666
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Eval })
|
|
1667
|
+
], PacemDataCellElement.prototype, "dataitem", void 0);
|
|
1668
|
+
__decorate$2([
|
|
1669
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1670
|
+
], PacemDataCellElement.prototype, "rowindex", void 0);
|
|
1671
|
+
__decorate$2([
|
|
1672
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String, debounce: 200 })
|
|
1673
|
+
], PacemDataCellElement.prototype, "_contentTooltip", void 0);
|
|
1674
|
+
__decorate$2([
|
|
1675
|
+
pacemCore.ViewChild(pacemCore.P + '-span')
|
|
1676
|
+
], PacemDataCellElement.prototype, "_content", void 0);
|
|
1677
|
+
PacemDataCellElement = __decorate$2([
|
|
1678
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-datacell', shadow: false, template: `<${pacemCore.P}-span content="{{ :host._inflateContent(^item, ^index, :host.metadata) }}"></${pacemCore.P}-span>` })
|
|
1679
|
+
], PacemDataCellElement);
|
|
1680
|
+
|
|
1681
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1682
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1683
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1684
|
+
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;
|
|
1685
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1686
|
+
};
|
|
1687
|
+
const UI = pacemUi.Components.UI;
|
|
1688
|
+
//namespace Pacem.Components.Plus {
|
|
1689
|
+
const DataColumnSortEventName = "datacolumnsort";
|
|
1690
|
+
class DataColumnSortEvent extends CustomEvent {
|
|
1691
|
+
constructor(detail) {
|
|
1692
|
+
super(DataColumnSortEventName, { detail, bubbles: false, cancelable: true });
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
const DataColumnRescaleEventName = "datacolumnrescale";
|
|
1696
|
+
class DataColumnRescaleEvent extends CustomEvent {
|
|
1697
|
+
constructor(detail) {
|
|
1698
|
+
super(DataColumnRescaleEventName, { detail, bubbles: false, cancelable: true });
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
let PacemHeadCellElement = class PacemHeadCellElement extends PacemBaseCellElement {
|
|
1702
|
+
constructor(_md = new UI.MarkdownService()) {
|
|
1703
|
+
super();
|
|
1704
|
+
this._md = _md;
|
|
1705
|
+
//#region sort button
|
|
1706
|
+
this._sortButtonClickHandler = (evt) => {
|
|
1707
|
+
const metadata = this.metadata, gridState = this.gridState, column = metadata.prop;
|
|
1708
|
+
const dir = gridState.sort?.column === column ? (gridState.sort.dir === 'desc' ? 'asc' : 'desc') : (metadata.defaultSort || 'asc');
|
|
1709
|
+
this.dispatchEvent(new DataColumnSortEvent({ column, dir }));
|
|
1710
|
+
};
|
|
1711
|
+
this._rescaleHandler = (evt) => {
|
|
1712
|
+
evt.preventDefault();
|
|
1713
|
+
const detail = evt.detail;
|
|
1714
|
+
const width = Math.max(this.metadata.minPixelWidth ?? 24, detail.currentPosition.x - this._columnBBox.x);
|
|
1715
|
+
this.dispatchEvent(new DataColumnRescaleEvent({ width }));
|
|
1716
|
+
};
|
|
1717
|
+
this._rescaleStartHandler = (evt) => {
|
|
1718
|
+
this._columnBBox = pacemCore.Utils.offsetRect(this);
|
|
1719
|
+
};
|
|
1720
|
+
this._rescaleEndHandler = (evt) => {
|
|
1721
|
+
// nothing(?)
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
connectedCallback() {
|
|
1725
|
+
super.connectedCallback();
|
|
1726
|
+
pacemCore.Utils.addClass(this, pacemCore.PCSS + '-headcell');
|
|
1727
|
+
}
|
|
1728
|
+
propertyChangedCallback(name, old, val, first) {
|
|
1729
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
1730
|
+
if (!first && name === 'gridState') {
|
|
1731
|
+
this._updateSortButtonIconGlyph();
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
viewActivatedCallback() {
|
|
1735
|
+
super.viewActivatedCallback();
|
|
1736
|
+
this._ensureBalloon();
|
|
1737
|
+
}
|
|
1738
|
+
disconnectedCallback() {
|
|
1739
|
+
this._disposeBalloon();
|
|
1740
|
+
this._disposeRescaler();
|
|
1741
|
+
super.disconnectedCallback();
|
|
1742
|
+
}
|
|
1743
|
+
updateLayout(metadata = this.metadata) {
|
|
1744
|
+
this._setup(metadata);
|
|
1745
|
+
}
|
|
1746
|
+
_setupSortButton() {
|
|
1747
|
+
const btn = new UI.PacemButtonElement();
|
|
1748
|
+
btn.className = `button-flat headcell-sort ${pacemCore.PCSS}-inert`;
|
|
1749
|
+
this.addEventListener('click', this._sortButtonClickHandler, false);
|
|
1750
|
+
pacemCore.Utils.addClass(this, pacemCore.PCSS + '-clickable');
|
|
1751
|
+
return btn;
|
|
1752
|
+
}
|
|
1753
|
+
_disposeSortButton(btn = this._sortButton) {
|
|
1754
|
+
if (pacemCore.Utils.isNull(btn)) {
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
pacemCore.Utils.removeClass(this, pacemCore.PCSS + '-clickable');
|
|
1758
|
+
this.removeEventListener('click', this._sortButtonClickHandler, false);
|
|
1759
|
+
btn.remove();
|
|
1760
|
+
this._sortButton = null;
|
|
1761
|
+
}
|
|
1762
|
+
_updateSortButtonIconGlyph(btn = this._sortButton, state = this.gridState, metadata = this.metadata) {
|
|
1763
|
+
if (pacemCore.Utils.isNull(btn) || pacemCore.Utils.isNullOrEmpty(metadata)) {
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
btn.iconGlyph = state?.sort?.column === metadata.prop ? (state.sort.dir === 'desc' ? 'arrow_drop_down' : 'arrow_drop_up') : '';
|
|
1767
|
+
}
|
|
1768
|
+
_ensureRescaler() {
|
|
1769
|
+
if (pacemCore.Utils.isNull(this._rescaler)) {
|
|
1770
|
+
const r = this._rescaler = this._rescaler || new pacemCore.Components.PacemRescaleElement();
|
|
1771
|
+
r.handles = [pacemCore.UI.RescaleHandle.Right];
|
|
1772
|
+
r.addEventListener(pacemCore.UI.RescaleEventType.Rescale, this._rescaleHandler, false);
|
|
1773
|
+
r.addEventListener(pacemCore.UI.RescaleEventType.Start, this._rescaleStartHandler, false);
|
|
1774
|
+
r.addEventListener(pacemCore.UI.RescaleEventType.End, this._rescaleEndHandler, false);
|
|
1775
|
+
pacemCore.CustomElementUtils.findAncestorShell(this).appendChild(r);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
_setupRescaleContainer() {
|
|
1779
|
+
this._ensureRescaler();
|
|
1780
|
+
const c = new pacemCore.Components.PacemPanelElement();
|
|
1781
|
+
c.className = "headcell-rescale";
|
|
1782
|
+
c.behaviors = [this._rescaler];
|
|
1783
|
+
return c;
|
|
1784
|
+
}
|
|
1785
|
+
_disposeRescaleContainer(c = this._rescaleContainer) {
|
|
1786
|
+
if (pacemCore.Utils.isNull(c)) {
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
c.remove();
|
|
1790
|
+
this._rescaleContainer = null;
|
|
1791
|
+
}
|
|
1792
|
+
_disposeRescaler(r = this._rescaler) {
|
|
1793
|
+
if (pacemCore.Utils.isNull(r)) {
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
r.removeEventListener(pacemCore.UI.RescaleEventType.Rescale, this._rescaleHandler, false);
|
|
1797
|
+
r.removeEventListener(pacemCore.UI.RescaleEventType.Start, this._rescaleStartHandler, false);
|
|
1798
|
+
r.removeEventListener(pacemCore.UI.RescaleEventType.End, this._rescaleEndHandler, false);
|
|
1799
|
+
r.remove();
|
|
1800
|
+
this._rescaler = null;
|
|
1801
|
+
}
|
|
1802
|
+
//#endregion
|
|
1803
|
+
_setup(metadata = this.metadata) {
|
|
1804
|
+
this.setAttribute("css-class", "{{ this.metadata && this.metadata.headCell && this.metadata.headCell.cssClass || [] }}");
|
|
1805
|
+
this.setAttribute("css", "{{ this.metadata && this.metadata.headCell && this.metadata.headCell.css }}");
|
|
1806
|
+
const truncate = !!(metadata.headCell?.textEllipsis);
|
|
1807
|
+
const cssClass = truncate ? ['text-truncate'] : [];
|
|
1808
|
+
// alignment
|
|
1809
|
+
switch (metadata.headCell?.verticalAlign?.toLowerCase()) {
|
|
1810
|
+
case 'top':
|
|
1811
|
+
pacemCore.Utils.addClass(this, 'headcell-top');
|
|
1812
|
+
break;
|
|
1813
|
+
case 'bottom':
|
|
1814
|
+
pacemCore.Utils.addClass(this, 'headcell-bottom');
|
|
1815
|
+
break;
|
|
1816
|
+
case 'middle':
|
|
1817
|
+
pacemCore.Utils.addClass(this, 'headcell-middle');
|
|
1818
|
+
break;
|
|
1819
|
+
}
|
|
1820
|
+
switch (metadata.headCell?.horizontalAlign?.toLowerCase()) {
|
|
1821
|
+
// headcell display is grid: set h-alignment at content-level
|
|
1822
|
+
case 'left':
|
|
1823
|
+
cssClass.push('text-left');
|
|
1824
|
+
break;
|
|
1825
|
+
case 'right':
|
|
1826
|
+
cssClass.push('text-right');
|
|
1827
|
+
break;
|
|
1828
|
+
case 'center':
|
|
1829
|
+
cssClass.push('text-center');
|
|
1830
|
+
break;
|
|
1831
|
+
}
|
|
1832
|
+
// basic content
|
|
1833
|
+
this.removeAttribute('content');
|
|
1834
|
+
const css = !pacemCore.Utils.isNullOrEmpty(cssClass) ? ` class="${cssClass.join(' ')}"` : '';
|
|
1835
|
+
const headContent = metadata.headCell?.name ?? metadata.prop;
|
|
1836
|
+
this.innerHTML = `<div${css}>${headContent}</div>`;
|
|
1837
|
+
if (metadata.isSortable) {
|
|
1838
|
+
this._disposeSortButton();
|
|
1839
|
+
const btn = this._sortButton = this._setupSortButton();
|
|
1840
|
+
this._updateSortButtonIconGlyph(btn);
|
|
1841
|
+
this.appendChild(btn);
|
|
1842
|
+
}
|
|
1843
|
+
if (metadata.isRescalable) {
|
|
1844
|
+
this._disposeRescaleContainer();
|
|
1845
|
+
const cnt = this._rescaleContainer = this._setupRescaleContainer();
|
|
1846
|
+
this.appendChild(cnt);
|
|
1847
|
+
}
|
|
1848
|
+
if (metadata.isTogglable) ;
|
|
1849
|
+
}
|
|
1850
|
+
//#region balloon
|
|
1851
|
+
_normalizeTooltip() {
|
|
1852
|
+
const metadata = this.metadata.headCell?.tooltip || false;
|
|
1853
|
+
if (typeof metadata === 'object') {
|
|
1854
|
+
return metadata;
|
|
1855
|
+
}
|
|
1856
|
+
return { type: metadata };
|
|
1857
|
+
}
|
|
1858
|
+
_ensureBalloon() {
|
|
1859
|
+
var innerText, tooltip;
|
|
1860
|
+
const noBalloon = ((tooltip = this._normalizeTooltip()).type === false)
|
|
1861
|
+
|| pacemCore.Utils.isNullOrEmpty(innerText = this.metadata.headCell?.description);
|
|
1862
|
+
// balloon
|
|
1863
|
+
if (pacemCore.Utils.isNull(this._balloon) && !noBalloon) {
|
|
1864
|
+
let balloon = new UI.PacemBalloonElement();
|
|
1865
|
+
balloon.options = {
|
|
1866
|
+
behavior: UI.BalloonBehavior.Tooltip,
|
|
1867
|
+
trigger: tooltip.trigger || UI.BalloonTrigger.Hover,
|
|
1868
|
+
position: tooltip.position || UI.BalloonPosition.Top,
|
|
1869
|
+
hoverDelay: 200, hoverTimeout: 50,
|
|
1870
|
+
align: tooltip.align || UI.BalloonAlignment.Auto,
|
|
1871
|
+
};
|
|
1872
|
+
pacemCore.Utils.addClass(balloon, pacemCore.PCSS + '-headcell-tooltip');
|
|
1873
|
+
var shell = pacemCore.CustomElementUtils.findAncestorShell(this);
|
|
1874
|
+
shell.appendChild(this._balloon = balloon);
|
|
1875
|
+
}
|
|
1876
|
+
const balloon = this._balloon;
|
|
1877
|
+
if (!pacemCore.Utils.isNull(balloon)) {
|
|
1878
|
+
balloon.target = this;
|
|
1879
|
+
if (!(balloon.disabled = noBalloon)) {
|
|
1880
|
+
const content = innerText || '';
|
|
1881
|
+
switch (tooltip.type) {
|
|
1882
|
+
case 'md':
|
|
1883
|
+
case 'markdown':
|
|
1884
|
+
balloon.innerHTML = this._md.toHtml(content);
|
|
1885
|
+
break;
|
|
1886
|
+
case 'html':
|
|
1887
|
+
balloon.innerHTML = content;
|
|
1888
|
+
break;
|
|
1889
|
+
default:
|
|
1890
|
+
balloon.innerText = content;
|
|
1891
|
+
break;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
_disposeBalloon() {
|
|
1897
|
+
if (!pacemCore.Utils.isNull(this._balloon)) {
|
|
1898
|
+
this._balloon.remove();
|
|
1899
|
+
this._balloon = null;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
PacemHeadCellElement = __decorate$1([
|
|
1904
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-headcell' })
|
|
1905
|
+
], PacemHeadCellElement);
|
|
1906
|
+
|
|
1907
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1908
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1909
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1910
|
+
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;
|
|
1911
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1912
|
+
};
|
|
1913
|
+
//namespace Pacem.Components.Plus {
|
|
1914
|
+
const DataColumnRebuildEventName = 'datacolumnchange';
|
|
1915
|
+
const DataColumnStateChangeEventName = 'datacolumnstatechange';
|
|
1916
|
+
const DataGridConsts = {
|
|
1917
|
+
Defaults: {
|
|
1918
|
+
selectCaption: 'Details',
|
|
1919
|
+
editCaption: 'Edit',
|
|
1920
|
+
editIcon: 'edit',
|
|
1921
|
+
deleteCaption: 'Delete',
|
|
1922
|
+
deleteIcon: 'delete'
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
class DataGridBindEvent extends CustomEvent {
|
|
1926
|
+
constructor(detail) {
|
|
1927
|
+
super('databind', { cancelable: false, bubbles: false, detail });
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
class DataCellUIEvent extends pacemCore.CustomUIEvent {
|
|
1931
|
+
constructor(type, detail, orig) {
|
|
1932
|
+
super(type, detail, { bubbles: false, cancelable: true }, orig);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
let PacemDataColumnElement = class PacemDataColumnElement extends pacemCore.Components.PacemItemElement {
|
|
1936
|
+
propertyChangedCallback(name, old, val, first) {
|
|
1937
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
1938
|
+
if (!first) {
|
|
1939
|
+
switch (name) {
|
|
1940
|
+
case 'field':
|
|
1941
|
+
case 'headcellCss':
|
|
1942
|
+
case 'headcellCssClass':
|
|
1943
|
+
case 'datacellCss':
|
|
1944
|
+
case 'datacellCssClass':
|
|
1945
|
+
case 'resizable':
|
|
1946
|
+
case 'togglable':
|
|
1947
|
+
case 'sortable':
|
|
1948
|
+
case 'label':
|
|
1949
|
+
this.dispatchEvent(new Event(DataColumnRebuildEventName));
|
|
1950
|
+
break;
|
|
1951
|
+
case 'order':
|
|
1952
|
+
case 'hide':
|
|
1953
|
+
this.dispatchEvent(new Event(DataColumnStateChangeEventName));
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
};
|
|
1959
|
+
__decorate([
|
|
1960
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
1961
|
+
], PacemDataColumnElement.prototype, "field", void 0);
|
|
1962
|
+
__decorate([
|
|
1963
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
1964
|
+
], PacemDataColumnElement.prototype, "label", void 0);
|
|
1965
|
+
__decorate([
|
|
1966
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1967
|
+
], PacemDataColumnElement.prototype, "resizable", void 0);
|
|
1968
|
+
__decorate([
|
|
1969
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1970
|
+
], PacemDataColumnElement.prototype, "togglable", void 0);
|
|
1971
|
+
__decorate([
|
|
1972
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1973
|
+
], PacemDataColumnElement.prototype, "sortable", void 0);
|
|
1974
|
+
__decorate([
|
|
1975
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1976
|
+
], PacemDataColumnElement.prototype, "order", void 0);
|
|
1977
|
+
__decorate([
|
|
1978
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json /*OrString (TODO)*/ })
|
|
1979
|
+
], PacemDataColumnElement.prototype, "format", void 0);
|
|
1980
|
+
__decorate([
|
|
1981
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1982
|
+
], PacemDataColumnElement.prototype, "headcellCss", void 0);
|
|
1983
|
+
__decorate([
|
|
1984
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1985
|
+
], PacemDataColumnElement.prototype, "headcellCssClass", void 0);
|
|
1986
|
+
__decorate([
|
|
1987
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1988
|
+
], PacemDataColumnElement.prototype, "datacellCss", void 0);
|
|
1989
|
+
__decorate([
|
|
1990
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1991
|
+
], PacemDataColumnElement.prototype, "datacellCssClass", void 0);
|
|
1992
|
+
PacemDataColumnElement = __decorate([
|
|
1993
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-datacolumn' })
|
|
1994
|
+
], PacemDataColumnElement);
|
|
1995
|
+
function headColumnHtml(c) {
|
|
1996
|
+
return `<${pacemCore.P}-headcell metadata="{{ :host._getColumnMetadata('${c.prop}') }}" state="{{ :host._columnState.${c.prop} }}" grid-state="{{ :host._gridState }}"
|
|
1997
|
+
on-${DataColumnSortEventName}=":host._broadcastSortCommand($event)"
|
|
1998
|
+
on-${DataColumnRescaleEventName}=":host._broadcastRescaleCommand($event)"></${pacemCore.P}-headcell>`;
|
|
1999
|
+
}
|
|
2000
|
+
function dataColumnHtml(c, extra) {
|
|
2001
|
+
return `<${pacemCore.P}-datacell metadata="{{ :host._getColumnMetadata('${c.prop}') }}" state="{{ :host._columnState.${c.prop} }}" grid-state="{{ :host._gridState }}"
|
|
2002
|
+
dataitem="{{ ^item }}" rowindex="{{ ^index }}" ${extra}></${pacemCore.P}-datacell>`;
|
|
2003
|
+
}
|
|
2004
|
+
let PacemDataGridElement = class PacemDataGridElement extends pacemCore.Components.PacemItemsContainerElement {
|
|
2005
|
+
constructor(_key = pacemCore.Utils.uniqueCode()) {
|
|
2006
|
+
super();
|
|
2007
|
+
this._key = _key;
|
|
2008
|
+
this.state = {};
|
|
2009
|
+
// TODO: allow to persist states (key) on the session or location level...
|
|
2010
|
+
this._columnState = {};
|
|
2011
|
+
this._gridState = { sort: {}, orderedColumns: [], selectedRows: [] };
|
|
2012
|
+
this._itemDataColumnRebuildHandler = (evt) => {
|
|
2013
|
+
this._adaptColumnMetadata(this.items || []);
|
|
2014
|
+
};
|
|
2015
|
+
this._itemDataColumnChangeHandler = (evt) => {
|
|
2016
|
+
this._adaptColumnMetadata(this.items || []);
|
|
2017
|
+
};
|
|
2018
|
+
this._memoizer = {};
|
|
2019
|
+
}
|
|
2020
|
+
validate(item) {
|
|
2021
|
+
return item instanceof PacemDataColumnElement;
|
|
2022
|
+
}
|
|
2023
|
+
viewActivatedCallback() {
|
|
2024
|
+
super.viewActivatedCallback();
|
|
2025
|
+
this.addEventListener(pacemCore.CommandEventName, this._onCommand, false);
|
|
2026
|
+
this._adaptColumnMetadata();
|
|
2027
|
+
const cols = this._adaptedColumnMetadata || [];
|
|
2028
|
+
this._buildUpGrid(cols);
|
|
2029
|
+
}
|
|
2030
|
+
disconnectedCallback() {
|
|
2031
|
+
this.removeEventListener(pacemCore.CommandEventName, this._onCommand, false);
|
|
2032
|
+
super.disconnectedCallback();
|
|
2033
|
+
}
|
|
2034
|
+
propertyChangedCallback(name, old, val, first) {
|
|
2035
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
2036
|
+
if (!first) {
|
|
2037
|
+
switch (name) {
|
|
2038
|
+
case 'items':
|
|
2039
|
+
case 'metadata':
|
|
2040
|
+
this._adaptColumnMetadata();
|
|
2041
|
+
break;
|
|
2042
|
+
case '_adaptedColumnMetadata':
|
|
2043
|
+
this._buildUpGrid(val);
|
|
2044
|
+
break;
|
|
2045
|
+
case 'datasource':
|
|
2046
|
+
// cleanup row selection as datasource changes...
|
|
2047
|
+
const eventArgs = { keepRowSelection: false, datasource: val };
|
|
2048
|
+
const event = new DataGridBindEvent(eventArgs);
|
|
2049
|
+
this.dispatchEvent(event);
|
|
2050
|
+
if (!eventArgs.keepRowSelection) {
|
|
2051
|
+
this._setRowSelection();
|
|
2052
|
+
}
|
|
2053
|
+
break;
|
|
2054
|
+
case 'state':
|
|
2055
|
+
this._mergeState(val);
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
register(item) {
|
|
2061
|
+
if (super.register(item)) {
|
|
2062
|
+
// add listeners
|
|
2063
|
+
item.addEventListener(DataColumnRebuildEventName, this._itemDataColumnRebuildHandler, false);
|
|
2064
|
+
item.addEventListener(DataColumnStateChangeEventName, this._itemDataColumnChangeHandler, false);
|
|
2065
|
+
return true;
|
|
2066
|
+
}
|
|
2067
|
+
return false;
|
|
2068
|
+
}
|
|
2069
|
+
unregister(item) {
|
|
2070
|
+
if (super.unregister(item)) {
|
|
2071
|
+
// remove listeners
|
|
2072
|
+
item.removeEventListener(DataColumnRebuildEventName, this._itemDataColumnRebuildHandler, false);
|
|
2073
|
+
item.removeEventListener(DataColumnStateChangeEventName, this._itemDataColumnChangeHandler, false);
|
|
2074
|
+
return true;
|
|
2075
|
+
}
|
|
2076
|
+
return false;
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* Sets the selected rows among the current ones.
|
|
2080
|
+
* @param args
|
|
2081
|
+
*/
|
|
2082
|
+
setRowSelection(...args) {
|
|
2083
|
+
const indices = Array.from(args);
|
|
2084
|
+
this._setRowSelection(indices);
|
|
2085
|
+
}
|
|
2086
|
+
_setRowSelection(indices) {
|
|
2087
|
+
const args = (indices || []).map(i => { return { item: this.datasource[i], index: i }; });
|
|
2088
|
+
const evt = new DataRowSelectChangeEvent({ selectedRows: args });
|
|
2089
|
+
this.dispatchEvent(evt);
|
|
2090
|
+
if (!evt.defaultPrevented) {
|
|
2091
|
+
let retval = evt.detail.selectedRows;
|
|
2092
|
+
if (!pacemCore.Utils.isArray(retval)) {
|
|
2093
|
+
retval = [];
|
|
2094
|
+
}
|
|
2095
|
+
this._doSetRowSelection(retval.map(i => (i?.index ?? -1)).filter(i => i >= 0));
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
_doSetRowSelection(selectedRows) {
|
|
2099
|
+
const selection = { selectedRows };
|
|
2100
|
+
this._mergeState(selection);
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Merges and synchronizes grid states (public vs private).
|
|
2104
|
+
* @param state Partial state to be merged
|
|
2105
|
+
*/
|
|
2106
|
+
_mergeState(state = this.state) {
|
|
2107
|
+
state ??= {};
|
|
2108
|
+
// normalize selected rows into numbers
|
|
2109
|
+
const normalizedState = { selectedRows: (state.selectedRows || []).map((i) => typeof i === 'number' ? i : i.index) };
|
|
2110
|
+
const newState = this._gridState = pacemCore.Utils.extend({}, this._gridState, state, normalizedState);
|
|
2111
|
+
// does not trigger propertychange event (does not have to).
|
|
2112
|
+
this.state = pacemCore.Utils.extend(this.state ?? {}, newState);
|
|
2113
|
+
}
|
|
2114
|
+
_adaptColumnMetadata(items = this.items, metadata = this.metadata) {
|
|
2115
|
+
const output = Array.prototype.concat.apply((items || []).map(i => {
|
|
2116
|
+
const retval = {
|
|
2117
|
+
prop: i.field,
|
|
2118
|
+
// format: i.format,
|
|
2119
|
+
headCell: {
|
|
2120
|
+
name: i.label, cssClass: i.headcellCssClass || [], css: i.headcellCss || {}
|
|
2121
|
+
},
|
|
2122
|
+
dataCell: {
|
|
2123
|
+
format: i.format, cssClass: i.datacellCssClass || [], css: i.datacellCss || {}
|
|
2124
|
+
},
|
|
2125
|
+
hide: i.hide,
|
|
2126
|
+
isRescalable: i.resizable,
|
|
2127
|
+
isSortable: i.sortable,
|
|
2128
|
+
isTogglable: i.togglable,
|
|
2129
|
+
order: i.order,
|
|
2130
|
+
width: 1,
|
|
2131
|
+
};
|
|
2132
|
+
return retval;
|
|
2133
|
+
}), metadata || []);
|
|
2134
|
+
this._memoizer = {};
|
|
2135
|
+
this._adaptedColumnMetadata = output;
|
|
2136
|
+
}
|
|
2137
|
+
_getColumnMetadata(prop) {
|
|
2138
|
+
return this._memoizer[prop] = this._memoizer[prop] || this._adaptedColumnMetadata.find(m => m.prop === prop);
|
|
2139
|
+
}
|
|
2140
|
+
_buildUpGrid(metadata) {
|
|
2141
|
+
const container = this._tableContainer;
|
|
2142
|
+
if (pacemCore.Utils.isNull(container)) {
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
if (pacemCore.Utils.isNullOrEmpty(metadata)) {
|
|
2146
|
+
container.innerHTML = '';
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
const options = this.options = pacemCore.Utils.extend({}, DataGridConsts.Defaults, this.options || {}), hasCommands = options.allowDelete || options.allowEdit || options.allowSelect, multiSelect = options.allowMultiSelect && hasCommands;
|
|
2150
|
+
let css = multiSelect ? 'auto ' : '', headcells = multiSelect ? `<div class="${pacemCore.PCSS}-headcell"></div>` : '', datacells = multiSelect ? `<${pacemCore.P}-panel class="${pacemCore.PCSS}-datacell" style="grid-column: 1;" css="{{ {'grid-row': ^index+2} }}"></${pacemCore.P}-panel>` : '', footcells = multiSelect ? `<div class="${pacemCore.PCSS}-footcell"></div>` : '';
|
|
2151
|
+
const colCount = multiSelect ? (metadata.length + 2) : (hasCommands ? (metadata.length + 1) : metadata.length);
|
|
2152
|
+
this._gridState.orderedColumns = metadata.sort((i, j) => ((i.order ?? 0) - (j.order ?? 0))).map(i => i.prop);
|
|
2153
|
+
let extraUi = '';
|
|
2154
|
+
for (let evtType of pacemCore.Components.PacemElement.emittedEventTypes) {
|
|
2155
|
+
extraUi += ` on-${evtType}=":host._broadcastUiEvent(^item, ^index, $event)"`;
|
|
2156
|
+
}
|
|
2157
|
+
// loop
|
|
2158
|
+
for (let c of metadata) {
|
|
2159
|
+
this._columnState[c.prop] = {
|
|
2160
|
+
hidden: c.hide
|
|
2161
|
+
};
|
|
2162
|
+
// css
|
|
2163
|
+
css += this._getColumnSize(c).replaceAll(' ', '') + ' ';
|
|
2164
|
+
// headcell
|
|
2165
|
+
headcells += headColumnHtml(c);
|
|
2166
|
+
// datacell
|
|
2167
|
+
datacells += dataColumnHtml(c, extraUi);
|
|
2168
|
+
}
|
|
2169
|
+
datacells += `<${pacemCore.P}-panel class="${pacemCore.PCSS}-datarow" css-class="{{ {'datarow-alt': ^index % 2 === 1, 'datarow-first': ^index === 0, 'datarow-last': ^index === (:host.datasource.length - 1), 'datarow-selected': :host._gridState.selectedRows.indexOf(^index) >= 0 } }}" style="grid-column: 1 /span ${colCount};" css="{{ {'grid-row': ^index+2} }}"></${pacemCore.P}-panel>`;
|
|
2170
|
+
const html = `<${pacemCore.P}-repeater datasource="{{ :host.datasource }}">
|
|
2171
|
+
<${pacemCore.P}-panel class="${pacemCore.PCSS}-datatable" css="{{ {'grid-template-columns': :host._getColumnSizes(:host._columnState, '${css.trimEnd()}', :host._gridState) } }}">
|
|
2172
|
+
${headcells}
|
|
2173
|
+
<template>
|
|
2174
|
+
${datacells}
|
|
2175
|
+
</template>
|
|
2176
|
+
${footcells}
|
|
2177
|
+
</${pacemCore.P}-panel>`;
|
|
2178
|
+
container.innerHTML = html;
|
|
2179
|
+
}
|
|
2180
|
+
_getColumnSizes(state = this._columnState, css, grid = this._gridState) {
|
|
2181
|
+
if (pacemCore.Utils.isNullOrEmpty(state)) {
|
|
2182
|
+
return css;
|
|
2183
|
+
}
|
|
2184
|
+
const split = css.split(' ');
|
|
2185
|
+
for (let prop in state) {
|
|
2186
|
+
const col = state[prop];
|
|
2187
|
+
const ndx = grid.orderedColumns.indexOf(prop);
|
|
2188
|
+
if (col.hidden) {
|
|
2189
|
+
split[ndx] = 'auto';
|
|
2190
|
+
}
|
|
2191
|
+
else if (col.pixelWidth > 0) {
|
|
2192
|
+
split[ndx] = col.pixelWidth + 'px';
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
return split.join(' ');
|
|
2196
|
+
}
|
|
2197
|
+
_getColumnSize(c) {
|
|
2198
|
+
if (c.hide) {
|
|
2199
|
+
return 'auto';
|
|
2200
|
+
}
|
|
2201
|
+
const min = c.minPixelWidth, max = c.maxPixelWidth;
|
|
2202
|
+
if (max > 0 && min > 0) {
|
|
2203
|
+
return `minmax(${min}px, ${max}px)`;
|
|
2204
|
+
}
|
|
2205
|
+
else {
|
|
2206
|
+
const flexWidth = typeof c.width === 'number' ? (c.width + 'fr') : 'auto';
|
|
2207
|
+
if (min > 0) {
|
|
2208
|
+
return `minmax(${min}px, ${flexWidth})`;
|
|
2209
|
+
}
|
|
2210
|
+
if (max > 0) {
|
|
2211
|
+
return `minmax(${flexWidth}, ${max}px)`;
|
|
2212
|
+
}
|
|
2213
|
+
return flexWidth;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
//#endregion
|
|
2217
|
+
//#region events
|
|
2218
|
+
_onCommand(evt) {
|
|
2219
|
+
// DO NOT stop bubbling! Might be 'handy' in autogenerated forms...
|
|
2220
|
+
// Pacem.stopPropagationHandler(evt);
|
|
2221
|
+
// ...But might lead to unwanted behaviors in nested repeaters.
|
|
2222
|
+
// Thus include the 'originalEvent' in the outscoped one as a read-only property.
|
|
2223
|
+
// 'itemcommand' event fires first
|
|
2224
|
+
this.dispatchEvent(new pacemCore.Components.ItemCommandEvent(/* 'originalEvent' */ evt));
|
|
2225
|
+
// custom 'item<cmd>' event fires next
|
|
2226
|
+
this.dispatchEvent(new pacemCore.Components.CustomItemCommandEvent(/* 'originalEvent' */ evt));
|
|
2227
|
+
}
|
|
2228
|
+
_broadcastUiEvent(item, index, evt) {
|
|
2229
|
+
const evtType = evt.type.toLowerCase(), type = 'datacell' + evtType;
|
|
2230
|
+
const args = { dataitem: item, rowindex: index, datacell: evt.srcElement }, uiEvt = (evt instanceof MouseEvent || evt instanceof TouchEvent || evt instanceof KeyboardEvent) ? new DataCellUIEvent(type, args, evt) : new DataCellUIEvent(type, args);
|
|
2231
|
+
this.dispatchEvent(uiEvt);
|
|
2232
|
+
if (evtType === 'click' && !uiEvt.defaultPrevented) {
|
|
2233
|
+
const datacell = uiEvt.detail.datacell;
|
|
2234
|
+
const selectMode = datacell.metadata?.dataCell?.selectMode?.toLowerCase();
|
|
2235
|
+
switch (selectMode) {
|
|
2236
|
+
case 'cell':
|
|
2237
|
+
break;
|
|
2238
|
+
case 'row':
|
|
2239
|
+
this._broadcastSelectCommand(uiEvt.detail.rowindex);
|
|
2240
|
+
break;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
_broadcastSortCommand(evt) {
|
|
2245
|
+
const sort = evt.detail;
|
|
2246
|
+
const event = new DataColumnSortEvent(sort);
|
|
2247
|
+
this.dispatchEvent(event);
|
|
2248
|
+
if (!event.defaultPrevented) {
|
|
2249
|
+
const sort2 = { column: '' };
|
|
2250
|
+
if (typeof event.detail.column === 'string') {
|
|
2251
|
+
sort2.column = event.detail.column;
|
|
2252
|
+
}
|
|
2253
|
+
if (typeof event.detail.dir === 'string') {
|
|
2254
|
+
sort2.dir = event.detail.dir === 'desc' ? 'desc' : 'asc';
|
|
2255
|
+
}
|
|
2256
|
+
this._gridState = pacemCore.Utils.extend({}, this._gridState, /* let it be manipulated on the "other side" */ { sort: sort2 });
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
_broadcastRescaleCommand(evt) {
|
|
2260
|
+
const rescale = evt.detail;
|
|
2261
|
+
const event = new DataColumnRescaleEvent(rescale);
|
|
2262
|
+
this.dispatchEvent(event);
|
|
2263
|
+
if (!event.defaultPrevented) {
|
|
2264
|
+
let width2 = rescale.width;
|
|
2265
|
+
if (typeof event.detail.width === 'number' && event.detail.width > 0) {
|
|
2266
|
+
width2 = event.detail.width;
|
|
2267
|
+
}
|
|
2268
|
+
const column = evt.srcElement.metadata;
|
|
2269
|
+
const newState = {};
|
|
2270
|
+
newState[column.prop] = { pixelWidth: width2 };
|
|
2271
|
+
this._columnState = pacemCore.Utils.extend({}, this._columnState, newState);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
_broadcastSelectCommand(toggledRowIndex) {
|
|
2275
|
+
let actualRows = (this._gridState.selectedRows || []).slice(0);
|
|
2276
|
+
const ndx = actualRows.indexOf(toggledRowIndex);
|
|
2277
|
+
let trigger = true;
|
|
2278
|
+
if (ndx >= 0) {
|
|
2279
|
+
actualRows.splice(ndx, 1);
|
|
2280
|
+
}
|
|
2281
|
+
else {
|
|
2282
|
+
const options = this.options;
|
|
2283
|
+
if (options.allowMultiSelect) {
|
|
2284
|
+
actualRows.push(toggledRowIndex);
|
|
2285
|
+
}
|
|
2286
|
+
else if (options.allowSelect) {
|
|
2287
|
+
actualRows = [toggledRowIndex];
|
|
2288
|
+
}
|
|
2289
|
+
else {
|
|
2290
|
+
trigger = false;
|
|
2291
|
+
const msg = `Cannot select the row at index ${toggledRowIndex} since datagrid options do not allow any row selection.`;
|
|
2292
|
+
if (pacemCore.Utils.isNull(this.logger)) {
|
|
2293
|
+
console.warn(msg);
|
|
2294
|
+
}
|
|
2295
|
+
else {
|
|
2296
|
+
this.log(pacemCore.Logging.LogLevel.Warn, msg);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
if (trigger) {
|
|
2301
|
+
this._setRowSelection(actualRows);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
__decorate([
|
|
2306
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json })
|
|
2307
|
+
], PacemDataGridElement.prototype, "metadata", void 0);
|
|
2308
|
+
__decorate([
|
|
2309
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json })
|
|
2310
|
+
], PacemDataGridElement.prototype, "options", void 0);
|
|
2311
|
+
__decorate([
|
|
2312
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json })
|
|
2313
|
+
], PacemDataGridElement.prototype, "state", void 0);
|
|
2314
|
+
__decorate([
|
|
2315
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
2316
|
+
], PacemDataGridElement.prototype, "datasource", void 0);
|
|
2317
|
+
__decorate([
|
|
2318
|
+
pacemCore.ViewChild('.' + pacemCore.PCSS + '-datagrid')
|
|
2319
|
+
], PacemDataGridElement.prototype, "_tableContainer", void 0);
|
|
2320
|
+
__decorate([
|
|
2321
|
+
pacemCore.Watch()
|
|
2322
|
+
], PacemDataGridElement.prototype, "_adaptedColumnMetadata", void 0);
|
|
2323
|
+
__decorate([
|
|
2324
|
+
pacemCore.Watch()
|
|
2325
|
+
], PacemDataGridElement.prototype, "_columnState", void 0);
|
|
2326
|
+
__decorate([
|
|
2327
|
+
pacemCore.Watch()
|
|
2328
|
+
], PacemDataGridElement.prototype, "_gridState", void 0);
|
|
2329
|
+
__decorate([
|
|
2330
|
+
pacemCore.Debounce()
|
|
2331
|
+
], PacemDataGridElement.prototype, "_adaptColumnMetadata", null);
|
|
2332
|
+
PacemDataGridElement = __decorate([
|
|
2333
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-datagrid', shadow: false, template: `<div class="${pacemCore.PCSS}-datagrid"></div><${pacemCore.P}-content></${pacemCore.P}-content>` })
|
|
2334
|
+
], PacemDataGridElement);
|
|
2335
|
+
|
|
2336
|
+
var indexComponents = /*#__PURE__*/Object.freeze({
|
|
2337
|
+
__proto__: null,
|
|
2338
|
+
DataCellUIEvent: DataCellUIEvent,
|
|
2339
|
+
DataColumnRescaleEvent: DataColumnRescaleEvent,
|
|
2340
|
+
DataColumnRescaleEventName: DataColumnRescaleEventName,
|
|
2341
|
+
DataColumnSortEvent: DataColumnSortEvent,
|
|
2342
|
+
DataColumnSortEventName: DataColumnSortEventName,
|
|
2343
|
+
DataGridBindEvent: DataGridBindEvent,
|
|
2344
|
+
DataRowSelectChangeEvent: DataRowSelectChangeEvent,
|
|
2345
|
+
DataRowSelectChangeEventName: DataRowSelectChangeEventName,
|
|
2346
|
+
get EditMode () { return EditMode; },
|
|
2347
|
+
PacemBaseCellElement: PacemBaseCellElement,
|
|
2348
|
+
get PacemCarouselElement () { return PacemCarouselElement; },
|
|
2349
|
+
get PacemContextMenuElement () { return PacemContextMenuElement; },
|
|
2350
|
+
get PacemContextMenuItemCommandElement () { return PacemContextMenuItemCommandElement; },
|
|
2351
|
+
PacemContextMenuItemElement: PacemContextMenuItemElement,
|
|
2352
|
+
get PacemContextMenuItemSeparatorElement () { return PacemContextMenuItemSeparatorElement; },
|
|
2353
|
+
get PacemDataCellElement () { return PacemDataCellElement; },
|
|
2354
|
+
get PacemDataColumnElement () { return PacemDataColumnElement; },
|
|
2355
|
+
get PacemDataGridElement () { return PacemDataGridElement; },
|
|
2356
|
+
get PacemEditElement () { return PacemEditElement; },
|
|
2357
|
+
get PacemGalleryElement () { return PacemGalleryElement; },
|
|
2358
|
+
get PacemHeadCellElement () { return PacemHeadCellElement; },
|
|
2359
|
+
get PacemModalFormElement () { return PacemModalFormElement; },
|
|
2360
|
+
get PacemRouterHashStateElement () { return PacemRouterHashStateElement; },
|
|
2361
|
+
get PacemSearchElement () { return PacemSearchElement; }
|
|
2362
|
+
});
|
|
2363
|
+
|
|
2364
|
+
var Output = /*#__PURE__*/Object.freeze({
|
|
2365
|
+
__proto__: null,
|
|
2366
|
+
Components: indexComponents,
|
|
2367
|
+
Plus: indexPlus
|
|
2368
|
+
});
|
|
2369
|
+
|
|
2370
|
+
pacemFoundation.DeepMerger.merge(Output);
|
|
2371
|
+
|
|
2372
|
+
})(Pacem, Pacem, Pacem, Pacem);
|
|
2373
|
+
//# sourceMappingURL=pacem-plus.js.map
|