@swiftwc/ui 1.0.1-canary.4 → 1.0.1-canary.5
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/generated/components/date-picker.js +18 -16
- package/generated/components/fine-tooltip.js +5 -3
- package/generated/components/menu-view.js +11 -9
- package/generated/components/navigation-large-title.js +6 -4
- package/generated/components/picker-view.js +46 -44
- package/generated/components/progress-view.js +8 -6
- package/generated/components/scroll-view.js +9 -7
- package/generated/components/sidebar-toggle.js +10 -8
- package/generated/components/tab-view.js +10 -8
- package/generated/components/table-view.js +7 -5
- package/generated/components/text-field.js +11 -9
- package/generated/components/toggle-view.js +14 -12
- package/generated/components/tool-bar.js +5 -3
- package/generated/components/v-keyboard.js +6 -4
- package/generated/i18n/index.js +2 -0
- package/generated/internal/class/css-style-observer.js +3 -1
- package/generated/internal/class/navigation-view.js +4 -2
- package/generated/snapshot/index.d.ts +1 -1
- package/generated/snapshot/index.js +7 -7
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { I18n } from '../i18n';
|
|
2
3
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
4
|
import { FormAssociatedBase, getInternals } from '../internal/class/form-associated-base';
|
|
@@ -38,7 +39,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
38
39
|
static #templates = new Map();
|
|
39
40
|
// #lastRenderedStyle?: DatePickerStyle //string | null
|
|
40
41
|
#renderValidityMsgs = (entries) => {
|
|
41
|
-
debug(`${
|
|
42
|
+
debug(`${_a.name} ⚡️ mutation`);
|
|
42
43
|
this.setValidity(this.validity, this.validationMessage);
|
|
43
44
|
};
|
|
44
45
|
#shadowRoot;
|
|
@@ -75,7 +76,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
75
76
|
// break
|
|
76
77
|
// }
|
|
77
78
|
// return DatePicker.#templates.get(this.datePickerStyle)!
|
|
78
|
-
return
|
|
79
|
+
return _a.#templates.getOrInsertComputed(this.datePickerStyle, () => {
|
|
79
80
|
switch (this.datePickerStyle) {
|
|
80
81
|
default:
|
|
81
82
|
return $(html `<label part="root date-picker-stack">
|
|
@@ -99,7 +100,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
99
100
|
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
100
101
|
}
|
|
101
102
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
102
|
-
debug(`${
|
|
103
|
+
debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
103
104
|
switch (name) {
|
|
104
105
|
case 'selection':
|
|
105
106
|
// nothing happens// const [y = '', m = '', d = ''] = (newValue ?? '').split(/\D+/)
|
|
@@ -152,7 +153,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
152
153
|
return datePickerStyles.includes(this.getAttribute('date-picker-style') ?? '') ? this.getAttribute('date-picker-style') : 'automatic';
|
|
153
154
|
}
|
|
154
155
|
#render() {
|
|
155
|
-
debug(`${
|
|
156
|
+
debug(`${_a.name} ⚡️ #render (${this.datePickerStyle})`);
|
|
156
157
|
// if (this.#lastRenderedStyle === this.datePickerStyle) return // skip if already applied
|
|
157
158
|
// this.#lastRenderedStyle = this.datePickerStyle
|
|
158
159
|
// clear shadow DOM
|
|
@@ -196,7 +197,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
#handleValiditiesSlotchange = ({ type, target: slot }) => {
|
|
199
|
-
debug(`${
|
|
200
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
200
201
|
if (!(slot instanceof HTMLSlotElement))
|
|
201
202
|
return;
|
|
202
203
|
const assigned = slot.assignedElements();
|
|
@@ -216,15 +217,15 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
216
217
|
for (const input of this.#inputs) {
|
|
217
218
|
const nv = v[input.name] ?? '', pattern = /^(\d+)?$/;
|
|
218
219
|
let finalValue = pattern.test(nv) ? nv : '', parsedValue = parseInt(finalValue);
|
|
219
|
-
if (
|
|
220
|
+
if (_a.#min(input) > parsedValue)
|
|
220
221
|
finalValue = '';
|
|
221
|
-
else if (
|
|
222
|
+
else if (_a.#max(input) < parsedValue)
|
|
222
223
|
finalValue = '';
|
|
223
224
|
input.value = finalValue;
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
227
|
#handleClick = (evt) => {
|
|
227
|
-
debug(`${
|
|
228
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
228
229
|
const { target } = evt;
|
|
229
230
|
if (!(target instanceof HTMLElement))
|
|
230
231
|
return;
|
|
@@ -267,7 +268,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
267
268
|
this.dispatchEvent(new CustomEvent('selection', { detail: { selection }, bubbles: true, composed: true }));
|
|
268
269
|
};
|
|
269
270
|
#handleInputPaste = (evt) => {
|
|
270
|
-
debug(`${
|
|
271
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
271
272
|
const { target: input } = evt;
|
|
272
273
|
if (!(input instanceof HTMLInputElement))
|
|
273
274
|
return;
|
|
@@ -289,7 +290,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
289
290
|
this.#sendValueToForm();
|
|
290
291
|
};
|
|
291
292
|
#handleInputBeforeinput = (evt) => {
|
|
292
|
-
debug(`${
|
|
293
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
293
294
|
const { target: input } = evt;
|
|
294
295
|
if (!(input instanceof HTMLInputElement))
|
|
295
296
|
return;
|
|
@@ -312,7 +313,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
312
313
|
}
|
|
313
314
|
};
|
|
314
315
|
#handleInputKeydown = ({ type, target, key }) => {
|
|
315
|
-
debug(`${
|
|
316
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
316
317
|
if (!(target instanceof HTMLInputElement))
|
|
317
318
|
return;
|
|
318
319
|
const input = target;
|
|
@@ -331,25 +332,25 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
331
332
|
this.#inputs[index]?.focus();
|
|
332
333
|
};
|
|
333
334
|
#handleInputFocus = (evt) => {
|
|
334
|
-
debug(`${
|
|
335
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
335
336
|
for (const input of this.#inputs)
|
|
336
337
|
input.classList.toggle('focus', input === evt.target);
|
|
337
338
|
};
|
|
338
339
|
#handleInputBlur = ({ target, type }) => {
|
|
339
|
-
debug(`${
|
|
340
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
340
341
|
if (!(target instanceof HTMLInputElement))
|
|
341
342
|
return;
|
|
342
343
|
const input = target;
|
|
343
344
|
if (0 === input.value.length)
|
|
344
345
|
return;
|
|
345
|
-
const finalText = `${clamp(this.value[input.name] ?? '0',
|
|
346
|
+
const finalText = `${clamp(this.value[input.name] ?? '0', _a.#min(input), _a.#max(input))}`.padStart(parseInt(input.getAttribute('maxlength') ?? '0'), '0');
|
|
346
347
|
if (!set(input, 'value', finalText))
|
|
347
348
|
return;
|
|
348
349
|
// this.selection = this.selection
|
|
349
350
|
this.#sendValueToForm();
|
|
350
351
|
};
|
|
351
352
|
#handleInputInput = (evt) => {
|
|
352
|
-
debug(`${
|
|
353
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
353
354
|
this.#sendValueToForm();
|
|
354
355
|
};
|
|
355
356
|
/**
|
|
@@ -460,7 +461,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
460
461
|
message = kebabCase(key);
|
|
461
462
|
break;
|
|
462
463
|
}
|
|
463
|
-
debug(`${
|
|
464
|
+
debug(`${_a.name} ⚡️ validity-change`);
|
|
464
465
|
return this.#internals.setValidity(flags, this.#customValidity || message, anchor ?? this.#inputs.at(0));
|
|
465
466
|
};
|
|
466
467
|
setCustomValidity = (message) => {
|
|
@@ -489,3 +490,4 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
489
490
|
this.#sendValueToForm(false);
|
|
490
491
|
}
|
|
491
492
|
}
|
|
493
|
+
_a = DatePicker;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
3
|
import { $, debug, onoff } from '../internal/utils';
|
|
3
4
|
import { html } from '../tpl';
|
|
@@ -19,7 +20,7 @@ export class FineTooltip extends HTMLElement {
|
|
|
19
20
|
this.#render(target.getAttribute(attributeName));
|
|
20
21
|
};
|
|
21
22
|
#handleMeasure = ([{ target, borderBoxSize }]) => {
|
|
22
|
-
debug(`${
|
|
23
|
+
debug(`${_a.name} ⚡️ measure`);
|
|
23
24
|
if (target.hasAttribute('closing'))
|
|
24
25
|
return;
|
|
25
26
|
if (!(target instanceof HTMLElement))
|
|
@@ -49,7 +50,7 @@ export class FineTooltip extends HTMLElement {
|
|
|
49
50
|
label.removeAttribute('title');
|
|
50
51
|
};
|
|
51
52
|
connectedCallback() {
|
|
52
|
-
debug(`${
|
|
53
|
+
debug(`${_a.name} ⚡️ connect`);
|
|
53
54
|
this.removeAttribute('closing');
|
|
54
55
|
this.popover = 'manual';
|
|
55
56
|
this.inert = true;
|
|
@@ -58,7 +59,7 @@ export class FineTooltip extends HTMLElement {
|
|
|
58
59
|
this.showPopover();
|
|
59
60
|
}
|
|
60
61
|
disconnectedCallback() {
|
|
61
|
-
debug(`${
|
|
62
|
+
debug(`${_a.name} ⚡️ disconnect`);
|
|
62
63
|
this.#resizeObserver.unobserve(this);
|
|
63
64
|
this.#mutationObserver?.disconnect();
|
|
64
65
|
this.#mutationObserver2?.disconnect();
|
|
@@ -104,3 +105,4 @@ export class FineTooltip extends HTMLElement {
|
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
}
|
|
108
|
+
_a = FineTooltip;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
3
|
import { $, debug, onoff, touchGlass } from '../internal/utils';
|
|
3
4
|
import { queryMorph } from '../morphdom';
|
|
@@ -33,14 +34,14 @@ export class MenuView extends HTMLElement {
|
|
|
33
34
|
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
34
35
|
}
|
|
35
36
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
36
|
-
debug(`${
|
|
37
|
+
debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
37
38
|
switch (name) {
|
|
38
39
|
case 'open':
|
|
39
40
|
if (!this.#dialog)
|
|
40
41
|
break;
|
|
41
42
|
this.#dialog.inert = null === newValue;
|
|
42
43
|
if (null === newValue && this.#dialog.open) {
|
|
43
|
-
debug(`${
|
|
44
|
+
debug(`${_a.name} ⚡️ will-close`);
|
|
44
45
|
this.setAttribute('closing', '');
|
|
45
46
|
Promise.allSettled(this.#dialog.getAnimations().map(({ finished }) => finished)).then(() => {
|
|
46
47
|
if (!this.hasAttribute('closing'))
|
|
@@ -50,7 +51,7 @@ export class MenuView extends HTMLElement {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
if ('' === newValue && !this.#dialog.open) {
|
|
53
|
-
debug(`${
|
|
54
|
+
debug(`${_a.name} ⚡️ will-open`);
|
|
54
55
|
this.removeAttribute('closing');
|
|
55
56
|
const form = this.#shadowRoot.querySelector('form');
|
|
56
57
|
form.scrollTop = 0;
|
|
@@ -63,14 +64,14 @@ export class MenuView extends HTMLElement {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
disconnectedCallback() {
|
|
66
|
-
debug(`${
|
|
67
|
+
debug(`${_a.name} ⚡️ disconnect`);
|
|
67
68
|
const summaryPart = this.#shadowRoot.querySelector('[part*=menu-summary]'), dialogPart = this.#shadowRoot.querySelector('[part*=menu-dialog]');
|
|
68
69
|
summaryPart?.style.removeProperty('anchor-name'); //$.prop('anchor-name', null, summaryPart)
|
|
69
70
|
dialogPart?.style.removeProperty('position-anchor'); //$.prop('position-anchor', null, dialogPart)
|
|
70
71
|
CleanupRegistry.unregister(this);
|
|
71
72
|
}
|
|
72
73
|
connectedCallback() {
|
|
73
|
-
debug(`${
|
|
74
|
+
debug(`${_a.name} ⚡️ connect`);
|
|
74
75
|
this.#dialog = this.#shadowRoot.querySelector('dialog') ?? undefined;
|
|
75
76
|
const trigger = this.#shadowRoot.querySelector('button') ?? undefined;
|
|
76
77
|
CleanupRegistry.register(this, onoff('click', this.#handleTriggerClick, trigger).on());
|
|
@@ -94,7 +95,7 @@ export class MenuView extends HTMLElement {
|
|
|
94
95
|
dialogPart?.style.setProperty('position-anchor', newAnchorName); // $.prop('position-anchor', newAnchorName, dialogPart) //
|
|
95
96
|
}
|
|
96
97
|
#handleDialogClick = ({ type, target }) => {
|
|
97
|
-
debug(`${
|
|
98
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
98
99
|
if (!(target instanceof HTMLElement))
|
|
99
100
|
return;
|
|
100
101
|
if (target.matches('dialog'))
|
|
@@ -111,19 +112,20 @@ export class MenuView extends HTMLElement {
|
|
|
111
112
|
// event.stopPropagation() //NOTE: add this only if not nested, disposes all nicely if ommited
|
|
112
113
|
};
|
|
113
114
|
#handleTriggerClick = (evt) => {
|
|
114
|
-
debug(`${
|
|
115
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
115
116
|
this.toggleAttribute('open', true);
|
|
116
117
|
};
|
|
117
118
|
// intercept to modify open attr
|
|
118
119
|
#handleDialogCancel = (evt) => {
|
|
119
|
-
debug(`${
|
|
120
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
120
121
|
if (!evt.cancelable)
|
|
121
122
|
return;
|
|
122
123
|
evt.preventDefault();
|
|
123
124
|
this.toggleAttribute('open', false);
|
|
124
125
|
};
|
|
125
126
|
#handleDialogClose = (evt) => {
|
|
126
|
-
debug(`${
|
|
127
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
127
128
|
this.toggleAttribute('open', this.#shadowRoot.querySelector('dialog')?.open ?? false);
|
|
128
129
|
};
|
|
129
130
|
}
|
|
131
|
+
_a = MenuView;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
3
|
import { CSSStyleObserver } from '../internal/class/css-style-observer';
|
|
3
4
|
import { add, debug, frame, onoff, slowHideShow, timeout } from '../internal/utils';
|
|
@@ -82,13 +83,13 @@ export class NavigationLargeTitle extends HTMLElement {
|
|
|
82
83
|
super();
|
|
83
84
|
}
|
|
84
85
|
disconnectedCallback() {
|
|
85
|
-
debug(`${
|
|
86
|
+
debug(`${_a.name} ⚡️ disconnect`);
|
|
86
87
|
this.#clearScrollState();
|
|
87
88
|
this.#styleObserver?.disconnect();
|
|
88
89
|
CleanupRegistry.unregister(this);
|
|
89
90
|
}
|
|
90
91
|
connectedCallback() {
|
|
91
|
-
debug(`${
|
|
92
|
+
debug(`${_a.name} ⚡️ connect`);
|
|
92
93
|
const root = this.closest('scroll-view') ?? undefined;
|
|
93
94
|
if (!root)
|
|
94
95
|
return;
|
|
@@ -111,7 +112,7 @@ export class NavigationLargeTitle extends HTMLElement {
|
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
#handleStyleChange = () => {
|
|
114
|
-
debug(`${
|
|
115
|
+
debug(`${_a.name} ⚡️ style`);
|
|
115
116
|
const root = this.closest('scroll-view') ?? undefined;
|
|
116
117
|
if (!root)
|
|
117
118
|
return;
|
|
@@ -156,7 +157,7 @@ export class NavigationLargeTitle extends HTMLElement {
|
|
|
156
157
|
// this.#applySlowness(root, isIntersecting)
|
|
157
158
|
// }
|
|
158
159
|
#handleIntersect = (entries, { root }) => {
|
|
159
|
-
debug(`${
|
|
160
|
+
debug(`${_a.name} ⚡️ intersect (${entries?.at(0)?.isIntersecting})`);
|
|
160
161
|
if (!(root instanceof HTMLElement))
|
|
161
162
|
return;
|
|
162
163
|
for (const { isIntersecting } of entries)
|
|
@@ -180,3 +181,4 @@ export class NavigationLargeTitle extends HTMLElement {
|
|
|
180
181
|
slowHideShow(isIntersecting ? 'show' : 'hide', this);
|
|
181
182
|
};
|
|
182
183
|
}
|
|
184
|
+
_a = NavigationLargeTitle;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { I18n } from '../i18n';
|
|
2
3
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
4
|
import { DictEntry, Dictionary } from '../internal/class/dict-entry';
|
|
@@ -130,7 +131,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
#spawnPage = (entries, tag, parentGroupId, searchable = false, title) => {
|
|
133
|
-
debug(`${
|
|
134
|
+
debug(`${_a.name} #spawnPage`);
|
|
134
135
|
const body = tag === 'sheet-view'
|
|
135
136
|
? $(html `<dialog is="sheet-view">
|
|
136
137
|
<scroll-view>
|
|
@@ -222,7 +223,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
222
223
|
list?.appendChild(group);
|
|
223
224
|
}
|
|
224
225
|
else {
|
|
225
|
-
const btn =
|
|
226
|
+
const btn = _a.#wrapOptionSpawnTag(el);
|
|
226
227
|
const groupId = parentGroupId ? `${parentGroupId}.${i}` : `${i}`;
|
|
227
228
|
btn.dataset.groupId = groupId;
|
|
228
229
|
btn.addEventListener('click', this.#makeGroupClickHandler(el, groupId));
|
|
@@ -253,7 +254,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
253
254
|
}
|
|
254
255
|
};
|
|
255
256
|
#renderButtons(source) {
|
|
256
|
-
debug(`${
|
|
257
|
+
debug(`${_a.name} #renderButtons`);
|
|
257
258
|
const { labels, icons } = Dictionary.flatten(source);
|
|
258
259
|
this.#lastRenderedLabelMap = labels;
|
|
259
260
|
this.#lastRenderedIconMap = icons;
|
|
@@ -363,11 +364,11 @@ export class PickerView extends FormAssociatedBase {
|
|
|
363
364
|
// this.#renderButtons({ mode: 'dictionary', source: dictionary })
|
|
364
365
|
// }
|
|
365
366
|
#renderSlotted = (entries) => {
|
|
366
|
-
debug(`${
|
|
367
|
+
debug(`${_a.name} ⚡️ mutation`);
|
|
367
368
|
this.#renderButtons(this.#resolveSource()); //this.#renderButtons({ mode: 'list', source: this.#slots?.get('list')?.assignedElements({ flatten: true }) ?? [] })
|
|
368
369
|
};
|
|
369
370
|
#renderValidityMsgs = (entries) => {
|
|
370
|
-
debug(`${
|
|
371
|
+
debug(`${_a.name} ⚡️ mutation`);
|
|
371
372
|
this.setValidity(this.validity, this.validationMessage);
|
|
372
373
|
};
|
|
373
374
|
#lastRenderedStyle; //string | null
|
|
@@ -522,7 +523,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
522
523
|
// break
|
|
523
524
|
// }
|
|
524
525
|
// return PickerView.#templates.get(this.pickerStyle)!
|
|
525
|
-
return
|
|
526
|
+
return _a.#templates.getOrInsertComputed(this.pickerStyle, () => {
|
|
526
527
|
switch (this.pickerStyle) {
|
|
527
528
|
case 'sheet':
|
|
528
529
|
case 'navigation-link':
|
|
@@ -631,7 +632,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
631
632
|
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
632
633
|
}
|
|
633
634
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
634
|
-
debug(`${
|
|
635
|
+
debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
635
636
|
switch (name) {
|
|
636
637
|
// case 'horizontal-radio-group-layout':
|
|
637
638
|
// if (oldValue === newValue) break
|
|
@@ -687,13 +688,13 @@ export class PickerView extends FormAssociatedBase {
|
|
|
687
688
|
}
|
|
688
689
|
}
|
|
689
690
|
disconnectedCallback() {
|
|
690
|
-
debug(`${
|
|
691
|
+
debug(`${_a.name} ⚡️ disconnect`);
|
|
691
692
|
CleanupRegistry.unregister(this);
|
|
692
693
|
this.#validityObservers.unobserveAll();
|
|
693
694
|
this.#observers.unobserveAll();
|
|
694
695
|
}
|
|
695
696
|
connectedCallback() {
|
|
696
|
-
debug(`${
|
|
697
|
+
debug(`${_a.name} ⚡️ connect`);
|
|
697
698
|
CleanupRegistry.register(this, onoff('localechange', () => {
|
|
698
699
|
this.#renderSlotted([]);
|
|
699
700
|
}, I18n.on).on());
|
|
@@ -717,7 +718,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
717
718
|
return Dictionary.fromElements(this.#slots?.get('list')?.assignedElements({ flatten: true }) ?? []);
|
|
718
719
|
}
|
|
719
720
|
#render() {
|
|
720
|
-
debug(`${
|
|
721
|
+
debug(`${_a.name} ⚡️ #render (${this.pickerStyle})`);
|
|
721
722
|
// const style = this.getAttribute('picker-style')
|
|
722
723
|
if (this.#lastRenderedStyle === this.pickerStyle)
|
|
723
724
|
return; // skip if already applied
|
|
@@ -761,7 +762,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
761
762
|
this.dispatchEvent(new CustomEvent('selection', { detail: { selection: this.#selection }, bubbles: true, composed: true }));
|
|
762
763
|
};
|
|
763
764
|
#handleTriggerClick = async ({ type, target }) => {
|
|
764
|
-
debug(`${
|
|
765
|
+
debug(`${_a.name} ⚡️ trigger.${type}`);
|
|
765
766
|
if (!(target instanceof HTMLElement))
|
|
766
767
|
return;
|
|
767
768
|
this.#spawn?.remove?.();
|
|
@@ -778,7 +779,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
778
779
|
});
|
|
779
780
|
};
|
|
780
781
|
#handlePageBtnClick = async (evt) => {
|
|
781
|
-
debug(`${
|
|
782
|
+
debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
782
783
|
evt.stopImmediatePropagation();
|
|
783
784
|
evt.preventDefault();
|
|
784
785
|
const { currentTarget: btn } = evt;
|
|
@@ -801,7 +802,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
801
802
|
});
|
|
802
803
|
};
|
|
803
804
|
#handleClick({ type, target }) {
|
|
804
|
-
debug(`${
|
|
805
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
805
806
|
if (!(target instanceof HTMLElement))
|
|
806
807
|
return;
|
|
807
808
|
const btn = target.closest('button');
|
|
@@ -813,7 +814,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
813
814
|
this.#sendValueToForm();
|
|
814
815
|
}
|
|
815
816
|
#handleInput({ type, target }) {
|
|
816
|
-
debug(`${
|
|
817
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
817
818
|
if (!(target instanceof HTMLElement))
|
|
818
819
|
return;
|
|
819
820
|
switch (this.pickerStyle) {
|
|
@@ -831,7 +832,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
831
832
|
}
|
|
832
833
|
}
|
|
833
834
|
#handleValiditiesSlotchange = ({ type, target: slot }) => {
|
|
834
|
-
debug(`${
|
|
835
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
835
836
|
if (!(slot instanceof HTMLSlotElement))
|
|
836
837
|
return;
|
|
837
838
|
const assigned = slot.assignedElements();
|
|
@@ -840,7 +841,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
840
841
|
this.#renderValidityMsgs([]);
|
|
841
842
|
};
|
|
842
843
|
#handleListSlotchange = ({ type, target: slot }) => {
|
|
843
|
-
debug(`${
|
|
844
|
+
debug(`${_a.name} ⚡️ ${type}`);
|
|
844
845
|
if (!(slot instanceof HTMLSlotElement))
|
|
845
846
|
return;
|
|
846
847
|
const assigned = slot.assignedElements();
|
|
@@ -849,31 +850,31 @@ export class PickerView extends FormAssociatedBase {
|
|
|
849
850
|
this.#renderSlotted([]);
|
|
850
851
|
};
|
|
851
852
|
static #wrapOptionSpawnTag(node) {
|
|
852
|
-
debug(`${
|
|
853
|
+
debug(`${_a.name} #wrapOptionSpawnTag`);
|
|
853
854
|
const mount = document.createElement('div');
|
|
854
855
|
render(html `<button type="button" tabindex="0" navigation-link>
|
|
855
856
|
<h-stack distribution="leading" template="auto spacer">
|
|
856
857
|
<label-view data-role="check" style="visibility: hidden">
|
|
857
858
|
<image-view slot="icon" system-name="check"></image-view>
|
|
858
859
|
</label-view>
|
|
859
|
-
${
|
|
860
|
+
${_a.#morphITSLabel(node)}
|
|
860
861
|
</h-stack>
|
|
861
862
|
</button>`, mount);
|
|
862
863
|
return mount.firstElementChild; //btn
|
|
863
864
|
}
|
|
864
865
|
#wrapOptionTag(node) {
|
|
865
|
-
debug(`${
|
|
866
|
+
debug(`${_a.name} #wrapOptionTag`);
|
|
866
867
|
const tag = node.value;
|
|
867
868
|
const mount = document.createElement('div');
|
|
868
869
|
switch (this.pickerStyle) {
|
|
869
870
|
case 'tabs':
|
|
870
|
-
render(
|
|
871
|
+
render(_a.#morphTabsBtn({ name: this.#guuid, node, tag }), mount);
|
|
871
872
|
return mount.firstElementChild; //btn
|
|
872
873
|
case 'palette':
|
|
873
|
-
render(
|
|
874
|
+
render(_a.#morphPaletteBtn({ name: this.#guuid, node, tag }), mount);
|
|
874
875
|
return mount.firstElementChild; //btn
|
|
875
876
|
case 'radio-group':
|
|
876
|
-
render(
|
|
877
|
+
render(_a.#morphRadioGroupBtn({ name: this.#guuid, node, tag }), mount);
|
|
877
878
|
return mount.firstElementChild; //btn
|
|
878
879
|
default:
|
|
879
880
|
render(html `<button type="button" tabindex="0" value="${tag}">
|
|
@@ -881,7 +882,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
881
882
|
<label-view data-role="check">
|
|
882
883
|
<image-view slot="icon" system-name="check"></image-view>
|
|
883
884
|
</label-view>
|
|
884
|
-
${
|
|
885
|
+
${_a.#morphITSLabel(node)}
|
|
885
886
|
</h-stack>
|
|
886
887
|
</button>`, mount);
|
|
887
888
|
return mount.firstElementChild; //btn
|
|
@@ -892,14 +893,14 @@ export class PickerView extends FormAssociatedBase {
|
|
|
892
893
|
return html `<label tabindex="0">
|
|
893
894
|
<h-stack distribution="fill" template="auto spacer" spacing="5">
|
|
894
895
|
<input type="radio" name="${name}" value="${tag}" />
|
|
895
|
-
${
|
|
896
|
+
${_a.#morphITSLabel(node)}
|
|
896
897
|
</h-stack>
|
|
897
898
|
</label>`;
|
|
898
899
|
else
|
|
899
900
|
return html `<label>
|
|
900
901
|
<h-stack distribution="fill" template="auto spacer" spacing="5">
|
|
901
902
|
<input type="radio" name="${name}" disabled />
|
|
902
|
-
${
|
|
903
|
+
${_a.#morphITSLabel(node)}
|
|
903
904
|
</h-stack>
|
|
904
905
|
</label>`;
|
|
905
906
|
}
|
|
@@ -909,7 +910,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
909
910
|
return html `<label tabindex="0">
|
|
910
911
|
<v-stack template="auto spacer" spacing="5">
|
|
911
912
|
<input type="radio" name="${name}" value="${tag}" style="${style}" />
|
|
912
|
-
${
|
|
913
|
+
${_a.#morphITSLabel(node)}
|
|
913
914
|
</v-stack>
|
|
914
915
|
</label>`;
|
|
915
916
|
}
|
|
@@ -917,7 +918,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
917
918
|
return html `<label>
|
|
918
919
|
<v-stack template="auto spacer" spacing="5">
|
|
919
920
|
<input type="radio" name="${name}" disabled />
|
|
920
|
-
${
|
|
921
|
+
${_a.#morphITSLabel(node)}
|
|
921
922
|
</v-stack>
|
|
922
923
|
</label>`;
|
|
923
924
|
}
|
|
@@ -940,13 +941,13 @@ export class PickerView extends FormAssociatedBase {
|
|
|
940
941
|
if ('string' === typeof tag) {
|
|
941
942
|
return html `<label tabindex="0">
|
|
942
943
|
<input type="radio" name="${name}" value="${tag}" />
|
|
943
|
-
${
|
|
944
|
+
${_a.#morphITSLabel(node)}
|
|
944
945
|
</label>`;
|
|
945
946
|
}
|
|
946
947
|
else
|
|
947
948
|
return html `<label>
|
|
948
949
|
<input type="radio" name="${name}" disabled />
|
|
949
|
-
${
|
|
950
|
+
${_a.#morphITSLabel(node)}
|
|
950
951
|
</label>`;
|
|
951
952
|
}
|
|
952
953
|
static #morphITSLabel({ title, subtitle, systemImage }) {
|
|
@@ -959,17 +960,17 @@ export class PickerView extends FormAssociatedBase {
|
|
|
959
960
|
</h-stack>`;
|
|
960
961
|
}
|
|
961
962
|
#wrapOptgroupTag(node) {
|
|
962
|
-
debug(`${
|
|
963
|
+
debug(`${_a.name} #wrapOptgroupTag`);
|
|
963
964
|
const mount = document.createElement('div');
|
|
964
965
|
switch (this.pickerStyle) {
|
|
965
966
|
case 'tabs':
|
|
966
|
-
render(
|
|
967
|
+
render(_a.#morphTabsBtn({ name: this.#guuid, node }), mount);
|
|
967
968
|
return mount.firstElementChild;
|
|
968
969
|
case 'palette':
|
|
969
|
-
render(
|
|
970
|
+
render(_a.#morphPaletteBtn({ name: this.#guuid, node }), mount);
|
|
970
971
|
return mount.firstElementChild;
|
|
971
972
|
case 'radio-group':
|
|
972
|
-
render(
|
|
973
|
+
render(_a.#morphRadioGroupBtn({ name: this.#guuid, node }), mount);
|
|
973
974
|
return mount.firstElementChild;
|
|
974
975
|
default:
|
|
975
976
|
render(html `<details is="disclosure-group" disclosure-style="marker-trailing">
|
|
@@ -978,7 +979,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
978
979
|
<label-view data-role="check" style="visibility: hidden">
|
|
979
980
|
<image-view slot="icon" system-name="check"></image-view>
|
|
980
981
|
</label-view>
|
|
981
|
-
${
|
|
982
|
+
${_a.#morphITSLabel(node)}
|
|
982
983
|
</h-stack>
|
|
983
984
|
</summary>
|
|
984
985
|
</details>`, mount);
|
|
@@ -989,13 +990,13 @@ export class PickerView extends FormAssociatedBase {
|
|
|
989
990
|
const mount = document.createElement('div');
|
|
990
991
|
switch (this.pickerStyle) {
|
|
991
992
|
case 'tabs':
|
|
992
|
-
render(
|
|
993
|
+
render(_a.#morphTabsBtn({ name: this.#guuid, node }), mount);
|
|
993
994
|
return mount.firstElementChild;
|
|
994
995
|
case 'palette':
|
|
995
|
-
render(
|
|
996
|
+
render(_a.#morphPaletteBtn({ name: this.#guuid, node }), mount);
|
|
996
997
|
return mount.firstElementChild;
|
|
997
998
|
case 'radio-group':
|
|
998
|
-
render(
|
|
999
|
+
render(_a.#morphRadioGroupBtn({ name: this.#guuid, node }), mount);
|
|
999
1000
|
return mount.firstElementChild;
|
|
1000
1001
|
default:
|
|
1001
1002
|
render(html `<menu-view tabindex="0">
|
|
@@ -1003,14 +1004,14 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1003
1004
|
<label-view data-role="check" style="visibility: hidden">
|
|
1004
1005
|
<image-view slot="icon" system-name="check"></image-view>
|
|
1005
1006
|
</label-view>
|
|
1006
|
-
${
|
|
1007
|
+
${_a.#morphITSLabel(node)}
|
|
1007
1008
|
</h-stack>
|
|
1008
1009
|
</menu-view>`, mount);
|
|
1009
1010
|
return mount.firstElementChild;
|
|
1010
1011
|
}
|
|
1011
1012
|
}
|
|
1012
1013
|
#reflectButtons(nodes, container) {
|
|
1013
|
-
debug(`${
|
|
1014
|
+
debug(`${_a.name} #reflectButtons`);
|
|
1014
1015
|
const flatten = ['radio-group', 'palette', 'tabs'].includes(this.pickerStyle);
|
|
1015
1016
|
for (const node of nodes) {
|
|
1016
1017
|
if (DictEntry.isLeaf(node)) {
|
|
@@ -1036,12 +1037,12 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1036
1037
|
// }
|
|
1037
1038
|
// }
|
|
1038
1039
|
#reflectLabel(value) {
|
|
1039
|
-
debug(`${
|
|
1040
|
+
debug(`${_a.name} #reflectLabel`);
|
|
1040
1041
|
queryMorph('[slot=label]', html `<label-view slot="label">${value ? html `<span>${value}</span>` : null}</label-view>`, this);
|
|
1041
1042
|
this.#renderSlotted([]);
|
|
1042
1043
|
}
|
|
1043
1044
|
#reflectSelectionOnButtons() {
|
|
1044
|
-
debug(`${
|
|
1045
|
+
debug(`${_a.name} #reflectSelectionOnButtons`);
|
|
1045
1046
|
self.requestAnimationFrame(() => {
|
|
1046
1047
|
this.ariaCurrent = this.#selection;
|
|
1047
1048
|
const groupMap = Dictionary.index(this.#lastIndexedRoot);
|
|
@@ -1087,7 +1088,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1087
1088
|
* Overwrite cvlabel with the label prop of the current(find[value === #selection]) option/dictentry
|
|
1088
1089
|
*/
|
|
1089
1090
|
#reflectSelectionOnCurrentValueLabel() {
|
|
1090
|
-
debug(`${
|
|
1091
|
+
debug(`${_a.name} #reflectSelectionOnCurrentValueLabel`);
|
|
1091
1092
|
self.requestAnimationFrame(() => {
|
|
1092
1093
|
switch (this.pickerStyle) {
|
|
1093
1094
|
case 'sheet':
|
|
@@ -1130,7 +1131,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1130
1131
|
});
|
|
1131
1132
|
}
|
|
1132
1133
|
#reflectTriggerHelp() {
|
|
1133
|
-
debug(`${
|
|
1134
|
+
debug(`${_a.name} #reflectTriggerHelp`);
|
|
1134
1135
|
let trigger;
|
|
1135
1136
|
switch (this.pickerStyle) {
|
|
1136
1137
|
case 'sheet':
|
|
@@ -1188,7 +1189,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1188
1189
|
message = kebabCase(key);
|
|
1189
1190
|
break;
|
|
1190
1191
|
}
|
|
1191
|
-
debug(`${
|
|
1192
|
+
debug(`${_a.name} ⚡️ validity-change`);
|
|
1192
1193
|
return this.#internals.setValidity(flags, this.#customValidity || message, anchor);
|
|
1193
1194
|
};
|
|
1194
1195
|
setCustomValidity = (message) => {
|
|
@@ -1215,3 +1216,4 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1215
1216
|
this.#sendValueToForm(false);
|
|
1216
1217
|
}
|
|
1217
1218
|
}
|
|
1219
|
+
_a = PickerView;
|