@swiftwc/ui 0.0.0-dev.22 → 0.0.0-dev.24
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/client/index.d.ts +1 -1
- package/generated/client/index.js +97 -32
- package/generated/components/bordered-button.js +1 -1
- package/generated/components/bordered-prominent-button.js +1 -1
- package/generated/components/borderless-button.js +1 -1
- package/generated/components/fine-tooltip.d.ts +7 -0
- package/generated/components/fine-tooltip.js +93 -0
- package/generated/components/glass-button.js +1 -1
- package/generated/components/glass-prominent-button.js +1 -1
- package/generated/components/index.d.ts +2 -0
- package/generated/components/index.js +2 -0
- package/generated/components/label-view.js +9 -4
- package/generated/components/picker-view.js +1 -1
- package/generated/components/progress-view.d.ts +13 -0
- package/generated/components/progress-view.js +122 -0
- package/generated/components/tool-bar-item.d.ts +2 -0
- package/generated/components/tool-bar-item.js +18 -4
- package/generated/css/index.css +374 -233
- package/generated/internal/utils/button-role.d.ts +1 -1
- package/generated/internal/utils/button-role.js +7 -3
- package/package.json +1 -1
- package/scss/_components.scss +3 -0
- package/scss/_mixins.scss +4 -0
- package/scss/_transitions.scss +4 -0
- package/scss/base/_reboot.scss +5 -0
- package/scss/base/_root.scss +64 -67
- package/scss/colors/_index.scss +81 -41
- package/scss/components/_alert-dialog.scss +4 -5
- package/scss/components/_bordered-button.scss +3 -0
- package/scss/components/_bordered-prominent-button.scss +3 -0
- package/scss/components/_borderless-button.scss +3 -0
- package/scss/components/_confirmation-dialog.scss +1 -1
- package/scss/components/_content-unavailable-view.scss +1 -1
- package/scss/components/_fine-tooltip.scss +82 -0
- package/scss/components/_glass-button.scss +3 -0
- package/scss/components/_glass-prominent-button.scss +3 -0
- package/scss/components/_index.scss +23 -20
- package/scss/components/_label-view copy.scss.txt +420 -0
- package/scss/components/_label-view.scss +26 -116
- package/scss/components/_menu-view.scss +17 -0
- package/scss/components/_navigation-split-view.scss +3 -3
- package/scss/components/_progress-view.scss +98 -0
- package/scss/components/_tool-bar-item.scss +61 -62
- package/scss/mixins/_button.scss +42 -0
- package/scss/mixins/_color.scss +16 -0
- package/scss/mixins/_index.scss +1 -1
- package/scss/placeholders/_buttons.scss +1 -44
- package/scss/transitions/_fine-tooltip.scss +21 -0
- package/scss/transitions/_progress-view.scss +23 -0
- package/scss/utils/_index.scss +9 -0
- package/web-components.html-data/en.json +27 -1
|
@@ -17,7 +17,7 @@ export declare const alert: (title?: string, message?: string, actions?: {
|
|
|
17
17
|
role?: string;
|
|
18
18
|
}[], options?: {
|
|
19
19
|
titleVisibility?: boolean;
|
|
20
|
-
}) => Promise<
|
|
20
|
+
}) => Promise<void>;
|
|
21
21
|
export declare const confirmationDialog: (trigger: HTMLElement, title: string, actions?: {
|
|
22
22
|
label?: string;
|
|
23
23
|
image?: string;
|
|
@@ -101,6 +101,69 @@ if (0 < polyfills.size) {
|
|
|
101
101
|
}
|
|
102
102
|
// SECTION: Safari polyfill
|
|
103
103
|
document.addEventListener('touchstart', () => { }, { passive: true });
|
|
104
|
+
// SECTION
|
|
105
|
+
const handleHelp = ({ target, relatedTarget }) => {
|
|
106
|
+
if (!(target instanceof HTMLElement && target))
|
|
107
|
+
return;
|
|
108
|
+
const trigger = target.closest('[help]');
|
|
109
|
+
if (!trigger)
|
|
110
|
+
return;
|
|
111
|
+
if (relatedTarget instanceof HTMLElement && relatedTarget && trigger.contains(relatedTarget))
|
|
112
|
+
return;
|
|
113
|
+
const newAnchorName = `--help-${self.crypto.randomUUID()}`;
|
|
114
|
+
const tooltip = $(`<fine-tooltip></fine-tooltip>`, '>1');
|
|
115
|
+
trigger.style.setProperty('anchor-name', newAnchorName);
|
|
116
|
+
tooltip.style.setProperty('position-anchor', newAnchorName);
|
|
117
|
+
document.body.appendChild(tooltip);
|
|
118
|
+
// setInterval(() => {
|
|
119
|
+
// trigger.setAttribute('help', trigger.getAttribute('help') + 'h')
|
|
120
|
+
// }, 2000)
|
|
121
|
+
// console.log(999, trigger)
|
|
122
|
+
}, handleDone = ({ target, relatedTarget }) => {
|
|
123
|
+
if (!(target instanceof HTMLElement && target))
|
|
124
|
+
return;
|
|
125
|
+
const trigger = target.closest('[help]');
|
|
126
|
+
if (!trigger)
|
|
127
|
+
return;
|
|
128
|
+
if (relatedTarget instanceof HTMLElement && relatedTarget && trigger.contains(relatedTarget))
|
|
129
|
+
return;
|
|
130
|
+
const anchorName = trigger.style.anchorName;
|
|
131
|
+
if (!anchorName.startsWith('--help-'))
|
|
132
|
+
return;
|
|
133
|
+
// for (const el of document.querySelectorAll<HTMLElement>(`[style*="--help-${CSS.escape(anchorName)}"][help]`)) el.style.removeProperty('anchor-name') //trigger.style.removeProperty('anchor-name')
|
|
134
|
+
// for (const el of document.querySelectorAll(`[style*="${CSS.escape(anchorName)}"]:not([help])`)) el.remove()
|
|
135
|
+
// return
|
|
136
|
+
// }
|
|
137
|
+
const tooltip = document.querySelector(`[style*="${CSS.escape(anchorName)}"]:not([help])`);
|
|
138
|
+
if (!tooltip)
|
|
139
|
+
return;
|
|
140
|
+
// for (const el of document.querySelectorAll<HTMLElement>(`[style*="--help-${CSS.escape(anchorName)}"][help]`)) el.style.removeProperty('anchor-name') //trigger.style.removeProperty('anchor-name')
|
|
141
|
+
// for (const el of document.querySelectorAll(`[style*="${CSS.escape(anchorName)}"]:not([help])`)) el.remove()
|
|
142
|
+
// return
|
|
143
|
+
// }
|
|
144
|
+
// trigger.style.removeProperty('anchor-name')
|
|
145
|
+
tooltip.hidePopover(); // tooltip.remove?.()
|
|
146
|
+
};
|
|
147
|
+
const mediaQueryList = self.matchMedia(`(pointer: fine)`);
|
|
148
|
+
mediaQueryList.addEventListener('change', ({ matches }) => {
|
|
149
|
+
for (const [k, v] of [
|
|
150
|
+
['pointerover', handleHelp],
|
|
151
|
+
['pointerout', handleDone],
|
|
152
|
+
])
|
|
153
|
+
document.removeEventListener(k, v);
|
|
154
|
+
if (matches)
|
|
155
|
+
for (const [k, v] of [
|
|
156
|
+
['pointerover', handleHelp],
|
|
157
|
+
['pointerout', handleDone],
|
|
158
|
+
])
|
|
159
|
+
document.addEventListener(k, v, { passive: true });
|
|
160
|
+
});
|
|
161
|
+
if (mediaQueryList.matches)
|
|
162
|
+
for (const [k, v] of [
|
|
163
|
+
['pointerover', handleHelp],
|
|
164
|
+
['pointerout', handleDone],
|
|
165
|
+
])
|
|
166
|
+
document.addEventListener(k, v, { passive: true });
|
|
104
167
|
// SECTION: Transitions
|
|
105
168
|
const cleanup = (lm, type) => {
|
|
106
169
|
let arr = [Snapshot.config['vt-fwd-class-name'], 'fwdd', 'fwn', 'fwnn', 'bwd', 'bwdd', 'bwn', 'bwnn'];
|
|
@@ -253,39 +316,41 @@ export const startViewTransition = async (target, type = 'forwards', updateCallb
|
|
|
253
316
|
}
|
|
254
317
|
};
|
|
255
318
|
export const alert = async (title, message, actions, options) => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (message) {
|
|
263
|
-
const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
|
|
264
|
-
label.setAttribute('title', message);
|
|
265
|
-
vStack.insertAdjacentElement('beforeend', label);
|
|
266
|
-
}
|
|
267
|
-
for (const [index, action] of (actions ?? []).entries()) {
|
|
268
|
-
const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
|
|
269
|
-
btn.setAttribute('value', `${index}`);
|
|
270
|
-
if (action?.role)
|
|
271
|
-
btn.setAttribute('role', action.role);
|
|
272
|
-
if (action.label || action.image) {
|
|
273
|
-
const label = $(`<label-view title="${action.label}"></label-view>`, '>1');
|
|
274
|
-
if (action.label)
|
|
275
|
-
label.setAttribute('title', action.label);
|
|
276
|
-
if (action.image)
|
|
277
|
-
label.setAttribute('system-image', action.image);
|
|
278
|
-
btn.appendChild(label);
|
|
319
|
+
await navigator.locks.request('alert:', async () => {
|
|
320
|
+
const dialog = $(`<dialog is="alert-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
|
|
321
|
+
if (title) {
|
|
322
|
+
const label = $(`<label-view font="headline"></label-view>`, '>1');
|
|
323
|
+
label.setAttribute('title', title);
|
|
324
|
+
vStack.insertAdjacentElement('beforeend', label);
|
|
279
325
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
326
|
+
if (message) {
|
|
327
|
+
const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
|
|
328
|
+
label.setAttribute('title', message);
|
|
329
|
+
vStack.insertAdjacentElement('beforeend', label);
|
|
330
|
+
}
|
|
331
|
+
for (const [index, action] of (actions ?? []).entries()) {
|
|
332
|
+
const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
|
|
333
|
+
btn.setAttribute('value', `${index}`);
|
|
334
|
+
if (action?.role)
|
|
335
|
+
btn.setAttribute('role', action.role);
|
|
336
|
+
if (action.label || action.image) {
|
|
337
|
+
const label = $(`<label-view></label-view>`, '>1');
|
|
338
|
+
if (action.label)
|
|
339
|
+
label.setAttribute('title', action.label);
|
|
340
|
+
if (action.image)
|
|
341
|
+
label.setAttribute('system-image', action.image);
|
|
342
|
+
btn.appendChild(label);
|
|
343
|
+
}
|
|
344
|
+
dialog.insertAdjacentElement('beforeend', btn);
|
|
345
|
+
}
|
|
346
|
+
document.body.insertAdjacentElement('beforeend', dialog);
|
|
347
|
+
dialog.showModal();
|
|
348
|
+
const { promise, resolve } = Promise.withResolvers(), off = onoff('alert:return', (evt) => {
|
|
349
|
+
off();
|
|
350
|
+
resolve(evt.detail.returnValue);
|
|
351
|
+
}, alertDialog, { once: true }).on();
|
|
352
|
+
return promise;
|
|
353
|
+
});
|
|
289
354
|
};
|
|
290
355
|
export const confirmationDialog = async (trigger, title, actions, options) => {
|
|
291
356
|
const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
+
import { $, onoff } from '../internal/utils';
|
|
4
|
+
export class FineTooltip extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
#handleMutation = (mutations) => {
|
|
9
|
+
for (const { target, attributeName } of mutations)
|
|
10
|
+
if (target instanceof HTMLElement && target && attributeName)
|
|
11
|
+
this.#render(target.getAttribute(attributeName));
|
|
12
|
+
};
|
|
13
|
+
#handleMeasure = ([{ target, borderBoxSize }]) => {
|
|
14
|
+
console.debug(`${_a.name} ⚡️ measure`);
|
|
15
|
+
if (target.hasAttribute('closing'))
|
|
16
|
+
return;
|
|
17
|
+
if (!(target instanceof HTMLElement && target))
|
|
18
|
+
return;
|
|
19
|
+
const { top } = target.getBoundingClientRect();
|
|
20
|
+
const vpHeight = self.visualViewport?.height ?? 0, blockSize = borderBoxSize.at(0)?.blockSize ?? 0;
|
|
21
|
+
if (top > vpHeight - blockSize - 50) {
|
|
22
|
+
target.style.setProperty('position-area', 'top center');
|
|
23
|
+
target.style.setProperty('transform-origin', 'bottom');
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
#observer = new MutationObserver(this.#handleMutation);
|
|
27
|
+
#resizeObserver = new ResizeObserver(this.#handleMeasure);
|
|
28
|
+
get #queryTrigger() {
|
|
29
|
+
const positionAnchor = this.style.positionAnchor;
|
|
30
|
+
if (!positionAnchor.startsWith('--help-'))
|
|
31
|
+
return;
|
|
32
|
+
const trigger = document.querySelector(`[style*="${CSS.escape(positionAnchor)}"][help]`);
|
|
33
|
+
return trigger ?? undefined;
|
|
34
|
+
}
|
|
35
|
+
#render = (str) => {
|
|
36
|
+
const label = this.querySelector(':scope>label-view') ?? this.appendChild($(`<label-view></label-view>`, '>1'));
|
|
37
|
+
if (str)
|
|
38
|
+
label.setAttribute('title', str);
|
|
39
|
+
else
|
|
40
|
+
label.removeAttribute('title');
|
|
41
|
+
};
|
|
42
|
+
connectedCallback() {
|
|
43
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
44
|
+
this.removeAttribute('closing');
|
|
45
|
+
this.popover = 'manual';
|
|
46
|
+
this.inert = true;
|
|
47
|
+
CleanupRegistry.register(this, onoff('toggle', this.#handleToggle, this).on());
|
|
48
|
+
CleanupRegistry.register(this, onoff('beforetoggle', this.#handleBeforetoggle, this).on());
|
|
49
|
+
this.showPopover();
|
|
50
|
+
}
|
|
51
|
+
disconnectedCallback() {
|
|
52
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
53
|
+
this.#resizeObserver.unobserve(this);
|
|
54
|
+
this.#observer?.disconnect();
|
|
55
|
+
this.#queryTrigger?.style.removeProperty('anchor-name');
|
|
56
|
+
CleanupRegistry.unregister(this);
|
|
57
|
+
}
|
|
58
|
+
#handleToggle = ({ newState }) => {
|
|
59
|
+
if ('closed' !== newState)
|
|
60
|
+
return;
|
|
61
|
+
this.remove();
|
|
62
|
+
};
|
|
63
|
+
#handleBeforetoggle = (evt) => {
|
|
64
|
+
if ('open' !== evt.newState)
|
|
65
|
+
return;
|
|
66
|
+
const trigger = this.#queryTrigger;
|
|
67
|
+
if (!trigger) {
|
|
68
|
+
evt.preventDefault();
|
|
69
|
+
this.remove();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.#render(trigger.getAttribute('help'));
|
|
74
|
+
this.#observer.observe(trigger, {
|
|
75
|
+
attributes: true,
|
|
76
|
+
attributeFilter: ['help'],
|
|
77
|
+
});
|
|
78
|
+
this.#resizeObserver.observe(this);
|
|
79
|
+
}
|
|
80
|
+
this.toggleAttribute('open', 'open' === evt.newState);
|
|
81
|
+
};
|
|
82
|
+
hidePopover() {
|
|
83
|
+
if (this.hasAttribute('closing'))
|
|
84
|
+
return;
|
|
85
|
+
this.setAttribute('closing', '');
|
|
86
|
+
Promise.allSettled(this.getAnimations().map(({ finished }) => finished)).then(() => {
|
|
87
|
+
if (!this.hasAttribute('closing'))
|
|
88
|
+
return;
|
|
89
|
+
this?.remove();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_a = FineTooltip;
|
|
@@ -7,6 +7,7 @@ export * from './confirmation-dialog';
|
|
|
7
7
|
export * from './content-unavailable-view';
|
|
8
8
|
export * from './date-picker';
|
|
9
9
|
export * from './disclosure-group';
|
|
10
|
+
export * from './fine-tooltip';
|
|
10
11
|
export * from './form-view';
|
|
11
12
|
export * from './glass-button';
|
|
12
13
|
export * from './glass-prominent-button';
|
|
@@ -19,6 +20,7 @@ export * from './navigation-stack';
|
|
|
19
20
|
export * from './navigation-title';
|
|
20
21
|
export * from './picker-view';
|
|
21
22
|
export * from './plain-button';
|
|
23
|
+
export * from './progress-view';
|
|
22
24
|
export * from './screen-view';
|
|
23
25
|
export * from './scroll-view-proxy';
|
|
24
26
|
export * from './scroll-view';
|
|
@@ -7,6 +7,7 @@ export * from './confirmation-dialog';
|
|
|
7
7
|
export * from './content-unavailable-view';
|
|
8
8
|
export * from './date-picker';
|
|
9
9
|
export * from './disclosure-group';
|
|
10
|
+
export * from './fine-tooltip';
|
|
10
11
|
export * from './form-view';
|
|
11
12
|
export * from './glass-button';
|
|
12
13
|
export * from './glass-prominent-button';
|
|
@@ -19,6 +20,7 @@ export * from './navigation-stack';
|
|
|
19
20
|
export * from './navigation-title';
|
|
20
21
|
export * from './picker-view';
|
|
21
22
|
export * from './plain-button';
|
|
23
|
+
export * from './progress-view';
|
|
22
24
|
export * from './screen-view';
|
|
23
25
|
export * from './scroll-view-proxy';
|
|
24
26
|
export * from './scroll-view';
|
|
@@ -6,12 +6,17 @@ export class LabelView extends HTMLElement {
|
|
|
6
6
|
static #template;
|
|
7
7
|
static get template() {
|
|
8
8
|
return (this.#template ??= $(String.raw `
|
|
9
|
-
<div part="root label-image-stack">
|
|
10
9
|
<slot name="image"></slot>
|
|
11
|
-
</div>
|
|
12
|
-
<div part="root label-title-stack">
|
|
13
10
|
<slot></slot>
|
|
14
|
-
|
|
11
|
+
`
|
|
12
|
+
// String.raw`
|
|
13
|
+
// <div part="root label-image-stack">
|
|
14
|
+
// <slot name="image"></slot>
|
|
15
|
+
// </div>
|
|
16
|
+
// <div part="root label-title-stack">
|
|
17
|
+
// <slot></slot>
|
|
18
|
+
// </div>`
|
|
19
|
+
));
|
|
15
20
|
}
|
|
16
21
|
#shadowRoot;
|
|
17
22
|
constructor() {
|
|
@@ -20,8 +20,8 @@ export class PickerView extends FormAssociatedBase {
|
|
|
20
20
|
static #templates = new Map();
|
|
21
21
|
#lastRenderedStyle; //string | null
|
|
22
22
|
#shadowRoot;
|
|
23
|
-
#customValidity = '';
|
|
24
23
|
#slots = new Map();
|
|
24
|
+
#customValidity = '';
|
|
25
25
|
// #validitiesSlot?: HTMLSlotElement
|
|
26
26
|
// #datalistSlot?: HTMLSlotElement
|
|
27
27
|
// #tagSlot?: HTMLSlotElement
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*/
|
|
4
|
+
export declare class ProgressView extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static get observedAttributes(): string[];
|
|
7
|
+
get progressViewStyle(): "circular" | "linear";
|
|
8
|
+
get template(): DocumentFragment;
|
|
9
|
+
constructor();
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
+
import { CSSStyleObserver } from '../internal/class/css-style-observer';
|
|
4
|
+
import { $ } from '../internal/utils';
|
|
5
|
+
import { Snapshot } from '../snapshot';
|
|
6
|
+
const progressViewStyles = ['circular', 'linear'];
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export class ProgressView extends HTMLElement {
|
|
11
|
+
static get observedAttributes() {
|
|
12
|
+
return ['label', 'current-value-label', 'value'];
|
|
13
|
+
}
|
|
14
|
+
static #templates = new Map();
|
|
15
|
+
#cssStyleObserver;
|
|
16
|
+
#progressViewStyle;
|
|
17
|
+
#lastRenderedStyle;
|
|
18
|
+
#shadowRoot;
|
|
19
|
+
#slots = new Map();
|
|
20
|
+
get progressViewStyle() {
|
|
21
|
+
return this.#progressViewStyle ?? 'circular';
|
|
22
|
+
}
|
|
23
|
+
get template() {
|
|
24
|
+
if (!_a.#templates.has(this.progressViewStyle))
|
|
25
|
+
switch (this.progressViewStyle) {
|
|
26
|
+
case 'linear':
|
|
27
|
+
_a.#templates.set(this.progressViewStyle, $(String.raw `
|
|
28
|
+
<slot></slot>
|
|
29
|
+
<div part="root progress-control progress-line-control"></div>
|
|
30
|
+
<slot name="current-value"></slot>
|
|
31
|
+
`));
|
|
32
|
+
break;
|
|
33
|
+
case 'circular':
|
|
34
|
+
default:
|
|
35
|
+
_a.#templates.set(this.progressViewStyle, $(String.raw `
|
|
36
|
+
<div part="root progress-control progress-circular-control">
|
|
37
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-1"></div>
|
|
38
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-2"></div>
|
|
39
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-3"></div>
|
|
40
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-4"></div>
|
|
41
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-5"></div>
|
|
42
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-6"></div>
|
|
43
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-7"></div>
|
|
44
|
+
<div part="root progress-control progress-circular-blade progress-circular-blade-8"></div>
|
|
45
|
+
</div>
|
|
46
|
+
<slot></slot>
|
|
47
|
+
<slot name="current-value"></slot>
|
|
48
|
+
`));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return _a.#templates.get(this.progressViewStyle);
|
|
52
|
+
}
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
56
|
+
}
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
59
|
+
CleanupRegistry.unregister(this);
|
|
60
|
+
}
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
63
|
+
this.#cssStyleObserver = new CSSStyleObserver({
|
|
64
|
+
properties: ['--progress-view-style-index'],
|
|
65
|
+
});
|
|
66
|
+
this.#cssStyleObserver.observe(this, this.#handleStyleChange);
|
|
67
|
+
Snapshot.waitReady.then(() => self.requestAnimationFrame(this.#handleStyleChange));
|
|
68
|
+
}
|
|
69
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
70
|
+
console.debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
71
|
+
switch (name) {
|
|
72
|
+
case 'label': {
|
|
73
|
+
const label = this.querySelector(':scope>label-view:not([slot])') ?? this.appendChild($(`<label-view foreground="secondary"></label-view>`, '>1'));
|
|
74
|
+
if (newValue) {
|
|
75
|
+
label.setAttribute('title', newValue);
|
|
76
|
+
}
|
|
77
|
+
else
|
|
78
|
+
label.removeAttribute('title');
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'current-value-label': {
|
|
82
|
+
let label = this.querySelector(':scope>[slot=current-value]');
|
|
83
|
+
if (newValue) {
|
|
84
|
+
label ??= this.appendChild($(`<label-view slot="current-value" font="callout" foreground="secondary"></label-view>`, '>1'));
|
|
85
|
+
label.setAttribute('title', newValue);
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
label?.remove();
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
#handleStyleChange = () => {
|
|
94
|
+
console.debug(`${_a.name} ⚡️ style`);
|
|
95
|
+
const raw = self.getComputedStyle(this).getPropertyValue('--progress-view-style-index').trim();
|
|
96
|
+
const newValue = progressViewStyles[Number(raw)] ?? progressViewStyles[0];
|
|
97
|
+
if (newValue === this.#progressViewStyle)
|
|
98
|
+
return;
|
|
99
|
+
this.#progressViewStyle = newValue;
|
|
100
|
+
this.#render();
|
|
101
|
+
};
|
|
102
|
+
#render() {
|
|
103
|
+
console.debug(`${_a.name} ⚡️ render (${this.#progressViewStyle})`);
|
|
104
|
+
if (!this.isConnected)
|
|
105
|
+
return;
|
|
106
|
+
if (this.#lastRenderedStyle === this.#progressViewStyle)
|
|
107
|
+
return; // skip if already applied
|
|
108
|
+
this.#lastRenderedStyle = this.#progressViewStyle;
|
|
109
|
+
this.#shadowRoot.replaceChildren(document.importNode(this.template, true)); // clear shadow DOM
|
|
110
|
+
CleanupRegistry.unregister(this, 'slots');
|
|
111
|
+
for (const slot of this.#shadowRoot.querySelectorAll('slot'))
|
|
112
|
+
this.#slots?.set(slot.name, slot);
|
|
113
|
+
CleanupRegistry.register(this, () => {
|
|
114
|
+
this.#slots = new Map();
|
|
115
|
+
}, 'slots');
|
|
116
|
+
switch (this.#progressViewStyle
|
|
117
|
+
//
|
|
118
|
+
) {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
_a = ProgressView;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare class ToolBarItem extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
2
3
|
constructor();
|
|
3
4
|
connectedCallback(): void;
|
|
4
5
|
disconnectedCallback(): void;
|
|
6
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
5
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import { onoff, touchGlass } from '../internal/utils';
|
|
2
|
+
import { buttonRole, onoff, touchGlass } from '../internal/utils';
|
|
3
|
+
import { Snapshot } from '../snapshot';
|
|
3
4
|
export class ToolBarItem extends HTMLElement {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ['slot', 'data-previous-slot'];
|
|
7
|
+
}
|
|
7
8
|
constructor() {
|
|
8
9
|
super();
|
|
9
10
|
}
|
|
@@ -35,4 +36,17 @@ export class ToolBarItem extends HTMLElement {
|
|
|
35
36
|
console.debug(`${ToolBarItem.name} ⚡️ disconnect`);
|
|
36
37
|
CleanupRegistry.unregister(this);
|
|
37
38
|
}
|
|
39
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
40
|
+
console.debug(`${ToolBarItem.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
41
|
+
switch (name) {
|
|
42
|
+
case 'slot':
|
|
43
|
+
case 'data-previous-slot':
|
|
44
|
+
const target = this.querySelector(':scope>button');
|
|
45
|
+
if (target && ['confirmation-action'].includes(newValue ?? ''))
|
|
46
|
+
Snapshot.waitReady.then(() => {
|
|
47
|
+
buttonRole(target, newValue);
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
38
52
|
}
|