@swiftwc/ui 0.0.0-dev.22 → 0.0.0-dev.23
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 +1 -0
- package/generated/components/index.js +1 -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 +236 -149
- package/generated/internal/utils/button-role.d.ts +1 -1
- package/generated/internal/utils/button-role.js +8 -3
- package/package.json +1 -1
- package/scss/_components.scss +2 -0
- package/scss/_mixins.scss +4 -0
- package/scss/_transitions.scss +2 -0
- package/scss/base/_reboot.scss +5 -0
- package/scss/base/_root.scss +63 -67
- package/scss/colors/_index.scss +57 -26
- package/scss/components/_alert-dialog.scss +4 -5
- package/scss/components/_confirmation-dialog.scss +1 -1
- package/scss/components/_fine-tooltip.scss +82 -0
- package/scss/components/_index.scss +21 -20
- package/scss/components/_menu-view.scss +17 -0
- package/scss/components/_navigation-split-view.scss +3 -3
- 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/web-components.html-data/en.json +12 -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';
|
|
@@ -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';
|
|
@@ -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
|
}
|