@swiftwc/ui 0.0.0-dev.8 → 0.0.0-dev.81
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/buses/alert-dialog.d.ts +2 -0
- package/generated/buses/alert-dialog.js +1 -0
- package/generated/buses/confirmation-dialog.d.ts +2 -0
- package/generated/buses/confirmation-dialog.js +1 -0
- package/generated/buses/index.d.ts +6 -0
- package/generated/buses/index.js +6 -0
- package/generated/buses/lifecycle-observer.d.ts +2 -0
- package/generated/buses/lifecycle-observer.js +1 -0
- package/generated/client/index.d.ts +21 -10
- package/generated/client/index.js +177 -194
- package/generated/components/alert-dialog.d.ts +8 -0
- package/generated/components/alert-dialog.js +99 -0
- package/generated/components/body-view.js +5 -2
- package/generated/components/bordered-button.d.ts +10 -0
- package/generated/components/bordered-button.js +39 -3
- package/generated/components/bordered-prominent-button.d.ts +10 -0
- package/generated/components/bordered-prominent-button.js +39 -3
- package/generated/components/borderless-button.d.ts +9 -1
- package/generated/components/borderless-button.js +32 -11
- package/generated/components/color-scheme.d.ts +7 -0
- package/generated/components/color-scheme.js +54 -0
- package/generated/components/confirmation-dialog.d.ts +1 -1
- package/generated/components/confirmation-dialog.js +43 -32
- package/generated/components/content-unavailable-view.d.ts +24 -0
- package/generated/components/content-unavailable-view.js +81 -0
- package/generated/components/date-picker.d.ts +2 -12
- package/generated/components/date-picker.js +96 -65
- package/generated/components/disclosure-group.d.ts +5 -0
- package/generated/components/disclosure-group.js +18 -7
- package/generated/components/fine-tooltip.d.ts +7 -0
- package/generated/components/fine-tooltip.js +107 -0
- package/generated/components/form-view.d.ts +3 -0
- package/generated/components/form-view.js +8 -3
- package/generated/components/glass-button.d.ts +10 -0
- package/generated/components/glass-button.js +39 -3
- package/generated/components/glass-prominent-button.d.ts +10 -0
- package/generated/components/glass-prominent-button.js +39 -3
- package/generated/components/h-stack.d.ts +14 -0
- package/generated/components/h-stack.js +23 -0
- package/generated/components/image-view.d.ts +9 -0
- package/generated/components/image-view.js +64 -0
- package/generated/components/index.d.ts +11 -3
- package/generated/components/index.js +11 -3
- package/generated/components/label-view.d.ts +6 -1
- package/generated/components/label-view.js +40 -60
- package/generated/components/labeled-content.d.ts +9 -0
- package/generated/components/labeled-content.js +116 -0
- package/generated/components/list-view.d.ts +3 -0
- package/generated/components/list-view.js +20 -17
- package/generated/components/menu-view.d.ts +4 -1
- package/generated/components/menu-view.js +60 -51
- package/generated/components/navigation-large-title.js +9 -5
- package/generated/components/navigation-split-view.d.ts +4 -1
- package/generated/components/navigation-split-view.js +13 -6
- package/generated/components/navigation-stack.d.ts +4 -1
- package/generated/components/navigation-stack.js +16 -9
- package/generated/components/navigation-title.d.ts +1 -1
- package/generated/components/navigation-title.js +58 -55
- package/generated/components/picker-view.d.ts +32 -4
- package/generated/components/picker-view.js +924 -234
- package/generated/components/plain-button.js +5 -3
- package/generated/components/progress-view.d.ts +13 -0
- package/generated/components/progress-view.js +120 -0
- package/generated/components/screen-view.js +3 -1
- package/generated/components/scroll-view-proxy.d.ts +8 -0
- package/generated/components/scroll-view-proxy.js +17 -0
- package/generated/components/scroll-view.d.ts +1 -1
- package/generated/components/scroll-view.js +101 -85
- package/generated/components/search-view.d.ts +7 -0
- package/generated/components/search-view.js +30 -0
- package/generated/components/section-view.d.ts +1 -1
- package/generated/components/section-view.js +35 -30
- package/generated/components/sheet-view.d.ts +1 -2
- package/generated/components/sheet-view.js +32 -39
- package/generated/components/sidebar-toggle.js +44 -66
- package/generated/components/sidebar-view.js +13 -8
- package/generated/components/sticky-container.js +8 -4
- package/generated/components/tab-bar.d.ts +3 -0
- package/generated/components/tab-bar.js +20 -10
- package/generated/components/tab-item.js +24 -13
- package/generated/components/tab-view.js +25 -17
- package/generated/components/table-view.d.ts +5 -0
- package/generated/components/table-view.js +55 -77
- package/generated/components/text-field.d.ts +2 -2
- package/generated/components/text-field.js +95 -88
- package/generated/components/toggle-view.d.ts +28 -0
- package/generated/components/toggle-view.js +224 -0
- package/generated/components/tool-bar-item-group.js +21 -4
- package/generated/components/tool-bar-item.d.ts +4 -1
- package/generated/components/tool-bar-item.js +57 -10
- package/generated/components/tool-bar.d.ts +12 -0
- package/generated/components/tool-bar.js +27 -11
- package/generated/components/v-keyboard.d.ts +3 -1
- package/generated/components/v-keyboard.js +12 -6
- package/generated/components/v-stack.d.ts +12 -0
- package/generated/components/v-stack.js +17 -2
- package/generated/css/index.css +2533 -941
- package/generated/events/alert-dialog.d.ts +8 -0
- package/generated/events/alert-dialog.js +1 -0
- package/generated/events/confirmation-dialog.d.ts +2 -2
- package/generated/events/index.d.ts +2 -0
- package/generated/events/index.js +2 -0
- package/generated/events/picker-view.d.ts +7 -0
- package/generated/events/scroll-view.js +4 -0
- package/generated/events/tab-view.d.ts +6 -2
- package/generated/events/text-field.js +3 -0
- package/generated/events/toggle-view.d.ts +9 -0
- package/generated/events/toggle-view.js +4 -0
- package/generated/i18n/index.d.ts +20 -10
- package/generated/i18n/index.js +82 -54
- package/generated/i18n/locales/el.d.ts +16 -0
- package/generated/i18n/locales/el.js +16 -0
- package/generated/i18n/locales/en.d.ts +16 -0
- package/generated/i18n/locales/en.js +16 -0
- package/generated/i18n/locales/index.d.ts +4 -0
- package/generated/i18n/locales/index.js +4 -0
- package/generated/internal/class/css-style-observer.js +3 -2
- package/generated/internal/class/form-associated-base.d.ts +0 -4
- package/generated/internal/class/form-associated-base.js +23 -38
- package/generated/internal/class/mutation-observer-set.d.ts +9 -0
- package/generated/internal/class/mutation-observer-set.js +42 -0
- package/generated/internal/class/mutation-observer-singleton.js +18 -0
- package/generated/internal/class/navigation-view.d.ts +1 -1
- package/generated/internal/class/navigation-view.js +38 -43
- package/generated/internal/decorators/adaptive-slot.d.ts +1 -0
- package/generated/internal/decorators/adaptive-slot.js +50 -0
- package/generated/internal/decorators/custom-element.d.ts +1 -1
- package/generated/internal/decorators/custom-element.js +2 -1
- package/generated/internal/decorators/index.d.ts +6 -0
- package/generated/internal/decorators/index.js +6 -0
- package/generated/internal/decorators/microtask-on-connected.d.ts +39 -0
- package/generated/internal/decorators/microtask-on-connected.js +67 -0
- package/generated/internal/privateNamespace.d.ts +10 -0
- package/generated/internal/privateNamespace.js +168 -1
- package/generated/internal/utils/cash/index.d.ts +4 -3
- package/generated/internal/utils/cash/index.js +6 -4
- package/generated/internal/utils/dev-flags.d.ts +3 -0
- package/generated/internal/utils/dev-flags.js +5 -0
- package/generated/internal/utils/ensure-placeholder.d.ts +1 -0
- package/generated/internal/utils/ensure-placeholder.js +55 -0
- package/generated/internal/utils/index.d.ts +7 -2
- package/generated/internal/utils/index.js +9 -2
- package/generated/internal/utils/is-inside.d.ts +1 -0
- package/generated/internal/utils/is-inside.js +4 -0
- package/generated/internal/utils/list-active.js +67 -12
- package/generated/internal/utils/render-label-icon.d.ts +2 -0
- package/generated/internal/utils/render-label-icon.js +19 -0
- package/generated/internal/utils/render-label-title.d.ts +2 -0
- package/generated/internal/utils/render-label-title.js +16 -0
- package/generated/internal/utils/render-label.d.ts +1 -0
- package/generated/internal/utils/render-label.js +19 -0
- package/generated/internal/utils/touch-glass.js +5 -5
- package/generated/namespace-browser/base.d.ts +12 -3
- package/generated/namespace-browser/base.js +41 -18
- package/generated/namespace-browser/event.d.ts +10 -0
- package/generated/namespace-browser/event.js +1 -0
- package/generated/snapshot/index.d.ts +3 -1
- package/generated/snapshot/index.js +25 -2
- package/generated/tpl/html.d.ts +5 -0
- package/generated/tpl/html.js +3 -0
- package/generated/tpl/index.d.ts +4 -0
- package/generated/tpl/index.js +4 -0
- package/generated/tpl/render.d.ts +2 -0
- package/generated/tpl/render.js +132 -0
- package/package.json +18 -4
- package/scss/_components.scss +14 -0
- package/scss/_functions.scss +10 -0
- package/scss/_mixins.scss +4 -0
- package/scss/_transitions.scss +6 -1
- package/scss/_vars.scss +9 -2
- package/scss/base/_layout.scss +17 -7
- package/scss/base/_reboot.scss +34 -1
- package/scss/base/_root.scss +117 -114
- package/scss/colors/_index.scss +304 -85
- package/scss/components/_alert-dialog.scss +111 -0
- package/scss/components/_bordered-button.scss +35 -0
- package/scss/components/_bordered-prominent-button.scss +45 -0
- package/scss/components/_borderless-button.scss +25 -0
- package/scss/components/_confirmation-dialog.scss +41 -49
- package/scss/components/_content-unavailable-view.scss +56 -0
- package/scss/components/_date-picker.scss +15 -15
- package/scss/components/_detail-placeholder.scss +1 -3
- package/scss/components/_disclosure-group.scss +84 -33
- package/scss/components/_fine-tooltip.scss +84 -0
- package/scss/components/_form-view.scss +58 -20
- package/scss/components/_glass-button.scss +35 -0
- package/scss/components/_glass-prominent-button.scss +46 -0
- package/scss/components/_group-box.scss +27 -0
- package/scss/components/_h-flex-stack.scss +23 -0
- package/scss/components/_h-stack.scss +21 -15
- package/scss/components/_image-view.scss +20 -0
- package/scss/components/_index.scss +40 -20
- package/scss/components/_label-view copy.scss.txt +420 -0
- package/scss/components/_label-view.scss +94 -110
- package/scss/components/_label-view.scss.txt +536 -0
- package/scss/components/_labeled-content.scss +59 -1
- package/scss/components/_list-view.scss +65 -25
- package/scss/components/_menu-view.scss +95 -60
- package/scss/components/_navigation-large-title.scss +17 -0
- package/scss/components/_navigation-split-view.scss +3 -3
- package/scss/components/_picker-view.scss +259 -59
- package/scss/components/_plain-button.scss +7 -0
- package/scss/components/_progress-view.scss +98 -0
- package/scss/components/_scroll-view-proxy.scss +22 -20
- package/scss/components/_scroll-view.scss +4 -0
- package/scss/components/_search-view.scss +22 -0
- package/scss/components/_section-view.scss +23 -22
- package/scss/components/_sheet-view.scss +16 -6
- package/scss/components/_sidebar-toggle.scss +1 -4
- package/scss/components/_sticky-container.scss +1 -1
- package/scss/components/_tab-bar.scss +17 -3
- package/scss/components/_tab-view.scss +4 -2
- package/scss/components/_table-column.scss +2 -0
- package/scss/components/_table-row.scss +69 -1
- package/scss/components/_table-view.scss +22 -14
- package/scss/components/_text-field.scss +37 -17
- package/scss/components/_toggle-view.scss +112 -0
- package/scss/components/_tool-bar-item.scss +34 -82
- package/scss/components/_tool-bar.scss +77 -57
- package/scss/components/_v-stack.scss +9 -2
- package/scss/final/_touch-glass.scss +24 -0
- package/scss/mixins/_button.scss +44 -0
- package/scss/mixins/_color.scss +16 -0
- package/scss/mixins/_dialog.scss +1 -0
- package/scss/mixins/_index.scss +64 -2
- package/scss/placeholders/_buttons.scss +44 -10
- package/scss/placeholders/_lists.scss +133 -126
- package/scss/transitions/_alert-dialog.scss +18 -0
- package/scss/transitions/_confirmation-dialog.scss +8 -0
- package/scss/transitions/_fine-tooltip.scss +21 -0
- package/scss/transitions/_menu-view.scss +17 -15
- package/scss/transitions/_progress-view.scss +23 -0
- package/scss/transitions/_sheet-view.scss +30 -0
- package/scss/transitions/_tab-bar.scss +6 -5
- package/scss/utils/_frame.scss +42 -0
- package/scss/utils/_index.scss +67 -52
- package/scss/utils/_stacks.scss +56 -73
- package/web-components.html-data/en.json +623 -24
- package/generated/confirmation-dialog/index.d.ts +0 -1
- package/generated/confirmation-dialog/index.js +0 -1
- package/generated/lifecycle-observer/index.d.ts +0 -1
- package/generated/lifecycle-observer/index.js +0 -1
- package/scss/transitions/_dialog.scss +0 -28
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
// import * as _intl from './intl'
|
|
2
|
-
import cash from './cash'
|
|
2
|
+
// import cash from './cash'
|
|
3
3
|
export { default as add } from './add';
|
|
4
|
+
export { default as $ } from './cash';
|
|
4
5
|
export { default as clamp } from './clamp';
|
|
5
6
|
export { default as compareBigDecimals } from './compare-big-decimals';
|
|
6
7
|
export { default as cssTime } from './css-time';
|
|
7
8
|
export { default as debounce } from './debounce';
|
|
9
|
+
export { default as devFlags } from './dev-flags';
|
|
10
|
+
export { default as ensurePlaceholder } from './ensure-placeholder';
|
|
8
11
|
export { default as frame } from './frame';
|
|
12
|
+
export { default as isInside } from './is-inside';
|
|
9
13
|
export { default as kebabCase } from './kebab-case';
|
|
10
14
|
export { default as listActive } from './list-active';
|
|
11
15
|
export { default as microtask } from './microtask';
|
|
12
16
|
export { default as onoff } from './onoff';
|
|
17
|
+
export { default as renderLabel } from './render-label';
|
|
18
|
+
export { default as renderLabelIcon } from './render-label-icon';
|
|
19
|
+
export { default as renderLabelTitle } from './render-label-title';
|
|
13
20
|
export { default as set } from './set';
|
|
14
21
|
export { default as sleep } from './sleep';
|
|
15
22
|
export { default as slowHideShow } from './slow-hide-show';
|
|
16
23
|
export { default as timeout } from './timeout';
|
|
17
24
|
export { default as touchGlass } from './touch-glass';
|
|
18
|
-
export const
|
|
25
|
+
// export const $: typeof cash = cash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (x: number, y: number, rect: DOMRect): boolean;
|
|
@@ -1,28 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const touchList = new WeakMap();
|
|
2
|
+
function onDown({ target }) {
|
|
3
|
+
if (!(target instanceof HTMLElement))
|
|
4
|
+
return;
|
|
5
|
+
const el = target.closest('button,summary');
|
|
3
6
|
if (!el)
|
|
4
7
|
return;
|
|
8
|
+
touchList.set(el, setTimeout(() => {
|
|
9
|
+
if (!touchList.has(el))
|
|
10
|
+
return;
|
|
11
|
+
el.classList.add('active');
|
|
12
|
+
}, 70));
|
|
13
|
+
el.addEventListener('pointerleave', onLeave, { once: true, passive: true });
|
|
14
|
+
el.closest('scroll-view')?.addEventListener('scroll', onScroll, { once: true, passive: true });
|
|
15
|
+
}
|
|
16
|
+
function onOver({ target, buttons }) {
|
|
17
|
+
if (!(target instanceof HTMLElement))
|
|
18
|
+
return;
|
|
19
|
+
const el = target.closest('button,summary');
|
|
20
|
+
if (!el)
|
|
21
|
+
return;
|
|
22
|
+
if (0 === buttons)
|
|
23
|
+
return;
|
|
5
24
|
el.classList.add('active');
|
|
6
|
-
el.
|
|
25
|
+
el.removeEventListener('pointerover', onOver);
|
|
26
|
+
el.addEventListener('pointerleave', onLeave, { once: true, passive: true });
|
|
7
27
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
28
|
+
function onLeave({ target }) {
|
|
29
|
+
if (!(target instanceof HTMLElement))
|
|
30
|
+
return;
|
|
31
|
+
const el = target.closest('button,summary');
|
|
10
32
|
if (!el)
|
|
11
33
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
34
|
+
el.addEventListener('pointerover', onOver, { once: true, passive: true });
|
|
35
|
+
// self.requestAnimationFrame(() => {
|
|
36
|
+
el.removeEventListener('pointerleave', onLeave);
|
|
37
|
+
el.closest('scroll-view')?.removeEventListener('scroll', onScroll);
|
|
38
|
+
el.classList.remove('active');
|
|
39
|
+
if (touchList.has(el))
|
|
40
|
+
clearTimeout(touchList.get(el));
|
|
41
|
+
touchList.delete(el);
|
|
42
|
+
// })
|
|
43
|
+
}
|
|
44
|
+
function onCancel({ target }) {
|
|
45
|
+
if (!(target instanceof HTMLElement))
|
|
46
|
+
return;
|
|
47
|
+
const el = target.closest('button,summary');
|
|
48
|
+
if (!el)
|
|
49
|
+
return;
|
|
50
|
+
// self.requestAnimationFrame(() => {
|
|
51
|
+
el.removeEventListener('pointerleave', onLeave);
|
|
52
|
+
el.removeEventListener('pointerover', onOver);
|
|
53
|
+
el.closest('scroll-view')?.removeEventListener('scroll', onScroll);
|
|
54
|
+
el.classList.remove('active');
|
|
55
|
+
if (touchList.has(el))
|
|
56
|
+
clearTimeout(touchList.get(el));
|
|
57
|
+
touchList.delete(el);
|
|
58
|
+
// })
|
|
59
|
+
}
|
|
60
|
+
function onScroll({ target }) {
|
|
61
|
+
if (!(target instanceof HTMLElement))
|
|
62
|
+
return;
|
|
63
|
+
for (const el of target.querySelectorAll('button,summary') ?? []) {
|
|
14
64
|
el.classList.remove('active');
|
|
15
|
-
|
|
65
|
+
if (touchList.has(el))
|
|
66
|
+
clearTimeout(touchList.get(el));
|
|
67
|
+
touchList.delete(el);
|
|
68
|
+
el.removeEventListener('pointerleave', onLeave);
|
|
69
|
+
el.removeEventListener('pointerover', onOver);
|
|
70
|
+
}
|
|
16
71
|
}
|
|
17
|
-
const
|
|
18
|
-
return
|
|
72
|
+
const makePointerdownHandler = (target) => {
|
|
73
|
+
return onDown;
|
|
19
74
|
}, makePointerCancelHandler = (target) => {
|
|
20
75
|
return onCancel;
|
|
21
76
|
};
|
|
22
77
|
export default function (t) {
|
|
23
|
-
const
|
|
78
|
+
const downListener = makePointerdownHandler(t), offListener = makePointerCancelHandler(t);
|
|
24
79
|
return [
|
|
25
|
-
{ types: 'pointerdown', listener:
|
|
80
|
+
{ types: 'pointerdown', listener: downListener, addOptions: { passive: true } },
|
|
26
81
|
{ types: 'pointerup pointercancel', listener: offListener, addOptions: { passive: true } },
|
|
27
82
|
];
|
|
28
83
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import $ from './cash';
|
|
2
|
+
export default function (label, systemImage) {
|
|
3
|
+
const img = label.querySelector(':scope>[slot=icon]');
|
|
4
|
+
// image ??= this.appendChild($(`<i slot="icon" style="line-height: 1.05"></i>`, '>1'))
|
|
5
|
+
// image.setAttribute('class', `ph ph-${newValue}`)
|
|
6
|
+
if (systemImage) {
|
|
7
|
+
if (!img) {
|
|
8
|
+
// const newImg = $(`<i slot="icon" style="line-height: 1.05" class="ph ph-${systemImage}"></i>`, '>1')
|
|
9
|
+
const newImg = $(`<image-view slot="icon"></image-view>`, '>1');
|
|
10
|
+
newImg.setAttribute('system-name', systemImage);
|
|
11
|
+
// DOM manipulation last
|
|
12
|
+
label.appendChild(newImg);
|
|
13
|
+
}
|
|
14
|
+
else if (systemImage !== img.getAttribute('system-name'))
|
|
15
|
+
img.setAttribute('system-name', systemImage);
|
|
16
|
+
}
|
|
17
|
+
else
|
|
18
|
+
img?.remove();
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import $ from './cash';
|
|
2
|
+
export default function (label, textContent) {
|
|
3
|
+
const span = label.querySelector(':scope>:not([slot])');
|
|
4
|
+
if (textContent) {
|
|
5
|
+
if (!span) {
|
|
6
|
+
// const newSpan = $(`<span></span>`, '>1')
|
|
7
|
+
// newSpan.textContent = title
|
|
8
|
+
// DOM manipulation last
|
|
9
|
+
label.appendChild(Object.assign($(`<span></span>`, '>1'), { textContent }));
|
|
10
|
+
}
|
|
11
|
+
else if (textContent !== span.textContent)
|
|
12
|
+
span.textContent = textContent;
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
span?.remove();
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (selector: string, template: string, container?: Element, title?: string | null, systemImage?: string | null): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import $ from './cash';
|
|
2
|
+
import renderLabelIcon from './render-label-icon';
|
|
3
|
+
import renderLabelTitle from './render-label-title';
|
|
4
|
+
export default function (selector, template, container, title, systemImage) {
|
|
5
|
+
const existing = container?.querySelector(selector);
|
|
6
|
+
if (existing) {
|
|
7
|
+
for (const { name, value } of $(template, '>1').attributes)
|
|
8
|
+
if (!existing.hasAttribute(name))
|
|
9
|
+
existing.setAttribute(name, value);
|
|
10
|
+
renderLabelIcon(existing, systemImage ?? null);
|
|
11
|
+
renderLabelTitle(existing, title ?? null);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const newLabel = $(template, '>1');
|
|
15
|
+
renderLabelIcon(newLabel, systemImage ?? null);
|
|
16
|
+
renderLabelTitle(newLabel, title ?? null);
|
|
17
|
+
container?.appendChild(newLabel);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const
|
|
1
|
+
const makePointerdownHandler = (target, targetCallback, checkCallback) => {
|
|
2
2
|
return function (evt) {
|
|
3
3
|
// if (event.pointerType !== 'touch') return
|
|
4
4
|
if (!checkCallback(evt))
|
|
5
5
|
return;
|
|
6
6
|
targetCallback(target).toggleAttribute('touch-glass', true);
|
|
7
7
|
};
|
|
8
|
-
},
|
|
8
|
+
}, makePointercancelHandler = (target, targetCallback) => {
|
|
9
9
|
return function (evt) {
|
|
10
10
|
targetCallback(target).toggleAttribute('touch-glass', false);
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
export default function (t, targetCallback, checkCallback) {
|
|
14
|
-
const
|
|
14
|
+
const downListener = makePointerdownHandler(t, targetCallback, checkCallback), cancelListener = makePointercancelHandler(t, targetCallback);
|
|
15
15
|
return [
|
|
16
|
-
{ types: 'pointerdown', listener:
|
|
17
|
-
{ types: 'pointerup pointercancel pointerleave', listener:
|
|
16
|
+
{ types: 'pointerdown', listener: downListener, addOptions: { passive: true } },
|
|
17
|
+
{ types: 'pointerup pointercancel pointerleave', listener: cancelListener, addOptions: { passive: true } },
|
|
18
18
|
];
|
|
19
19
|
}
|
|
@@ -3,34 +3,43 @@ export declare abstract class DialogBase extends HTMLDialogElement {
|
|
|
3
3
|
static polyfillConnectedCallback(el: HTMLDialogElement): void;
|
|
4
4
|
static polyfillDisconnectedCallback(el: HTMLDialogElement): void;
|
|
5
5
|
static polyfillAttributeChangedCallback(entries: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
6
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
6
7
|
disconnectedCallback(): void;
|
|
7
8
|
connectedCallback(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class InputBase extends HTMLInputElement {
|
|
11
|
+
static polyfillExtends: "input";
|
|
12
|
+
static polyfillConnectedCallback(el: HTMLInputElement): void;
|
|
13
|
+
static polyfillDisconnectedCallback(el: HTMLInputElement): void;
|
|
14
|
+
static polyfillAttributeChangedCallback(entries: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
8
15
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
connectedCallback(): void;
|
|
9
18
|
}
|
|
10
19
|
export declare abstract class ButtonBase extends HTMLButtonElement {
|
|
11
20
|
static polyfillExtends: "button";
|
|
12
21
|
static polyfillConnectedCallback(el: HTMLButtonElement): void;
|
|
13
22
|
static polyfillDisconnectedCallback(el: HTMLButtonElement): void;
|
|
14
23
|
static polyfillAttributeChangedCallback(entries: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
24
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
15
25
|
disconnectedCallback(): void;
|
|
16
26
|
connectedCallback(): void;
|
|
17
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
18
27
|
}
|
|
19
28
|
export declare abstract class DetailsBase extends HTMLDetailsElement {
|
|
20
29
|
static polyfillExtends: "details";
|
|
21
30
|
static polyfillConnectedCallback(el: HTMLDetailsElement): void;
|
|
22
31
|
static polyfillDisconnectedCallback(el: HTMLDetailsElement): void;
|
|
23
32
|
static polyfillAttributeChangedCallback(entries: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
33
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
24
34
|
disconnectedCallback(): void;
|
|
25
35
|
connectedCallback(): void;
|
|
26
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
27
36
|
}
|
|
28
37
|
export declare abstract class FormBase extends HTMLFormElement {
|
|
29
38
|
static polyfillExtends: "form";
|
|
30
39
|
static polyfillConnectedCallback(el: HTMLFormElement): void;
|
|
31
40
|
static polyfillDisconnectedCallback(el: HTMLFormElement): void;
|
|
32
41
|
static polyfillAttributeChangedCallback(entries: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
42
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
33
43
|
disconnectedCallback(): void;
|
|
34
44
|
connectedCallback(): void;
|
|
35
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
36
45
|
}
|
|
@@ -3,6 +3,15 @@ export class DialogBase extends HTMLDialogElement {
|
|
|
3
3
|
static polyfillConnectedCallback(el) { }
|
|
4
4
|
static polyfillDisconnectedCallback(el) { }
|
|
5
5
|
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
6
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
7
|
+
const ctor = this.constructor;
|
|
8
|
+
const entry = {
|
|
9
|
+
attributeName: name,
|
|
10
|
+
oldValue,
|
|
11
|
+
target: this,
|
|
12
|
+
};
|
|
13
|
+
ctor.polyfillAttributeChangedCallback([entry]);
|
|
14
|
+
}
|
|
6
15
|
disconnectedCallback() {
|
|
7
16
|
const ctor = this.constructor;
|
|
8
17
|
ctor.polyfillDisconnectedCallback(this);
|
|
@@ -11,6 +20,12 @@ export class DialogBase extends HTMLDialogElement {
|
|
|
11
20
|
const ctor = this.constructor;
|
|
12
21
|
ctor.polyfillConnectedCallback(this);
|
|
13
22
|
}
|
|
23
|
+
}
|
|
24
|
+
export class InputBase extends HTMLInputElement {
|
|
25
|
+
static polyfillExtends = 'input';
|
|
26
|
+
static polyfillConnectedCallback(el) { }
|
|
27
|
+
static polyfillDisconnectedCallback(el) { }
|
|
28
|
+
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
14
29
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
15
30
|
const ctor = this.constructor;
|
|
16
31
|
const entry = {
|
|
@@ -20,12 +35,6 @@ export class DialogBase extends HTMLDialogElement {
|
|
|
20
35
|
};
|
|
21
36
|
ctor.polyfillAttributeChangedCallback([entry]);
|
|
22
37
|
}
|
|
23
|
-
}
|
|
24
|
-
export class ButtonBase extends HTMLButtonElement {
|
|
25
|
-
static polyfillExtends = 'button';
|
|
26
|
-
static polyfillConnectedCallback(el) { }
|
|
27
|
-
static polyfillDisconnectedCallback(el) { }
|
|
28
|
-
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
29
38
|
disconnectedCallback() {
|
|
30
39
|
const ctor = this.constructor;
|
|
31
40
|
ctor.polyfillDisconnectedCallback(this);
|
|
@@ -34,6 +43,12 @@ export class ButtonBase extends HTMLButtonElement {
|
|
|
34
43
|
const ctor = this.constructor;
|
|
35
44
|
ctor.polyfillConnectedCallback(this);
|
|
36
45
|
}
|
|
46
|
+
}
|
|
47
|
+
export class ButtonBase extends HTMLButtonElement {
|
|
48
|
+
static polyfillExtends = 'button';
|
|
49
|
+
static polyfillConnectedCallback(el) { }
|
|
50
|
+
static polyfillDisconnectedCallback(el) { }
|
|
51
|
+
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
37
52
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
38
53
|
const ctor = this.constructor;
|
|
39
54
|
const entry = {
|
|
@@ -43,12 +58,6 @@ export class ButtonBase extends HTMLButtonElement {
|
|
|
43
58
|
};
|
|
44
59
|
ctor.polyfillAttributeChangedCallback([entry]);
|
|
45
60
|
}
|
|
46
|
-
}
|
|
47
|
-
export class DetailsBase extends HTMLDetailsElement {
|
|
48
|
-
static polyfillExtends = 'details';
|
|
49
|
-
static polyfillConnectedCallback(el) { }
|
|
50
|
-
static polyfillDisconnectedCallback(el) { }
|
|
51
|
-
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
52
61
|
disconnectedCallback() {
|
|
53
62
|
const ctor = this.constructor;
|
|
54
63
|
ctor.polyfillDisconnectedCallback(this);
|
|
@@ -57,6 +66,12 @@ export class DetailsBase extends HTMLDetailsElement {
|
|
|
57
66
|
const ctor = this.constructor;
|
|
58
67
|
ctor.polyfillConnectedCallback(this);
|
|
59
68
|
}
|
|
69
|
+
}
|
|
70
|
+
export class DetailsBase extends HTMLDetailsElement {
|
|
71
|
+
static polyfillExtends = 'details';
|
|
72
|
+
static polyfillConnectedCallback(el) { }
|
|
73
|
+
static polyfillDisconnectedCallback(el) { }
|
|
74
|
+
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
60
75
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
61
76
|
const ctor = this.constructor;
|
|
62
77
|
const entry = {
|
|
@@ -66,12 +81,6 @@ export class DetailsBase extends HTMLDetailsElement {
|
|
|
66
81
|
};
|
|
67
82
|
ctor.polyfillAttributeChangedCallback([entry]);
|
|
68
83
|
}
|
|
69
|
-
}
|
|
70
|
-
export class FormBase extends HTMLFormElement {
|
|
71
|
-
static polyfillExtends = 'form';
|
|
72
|
-
static polyfillConnectedCallback(el) { }
|
|
73
|
-
static polyfillDisconnectedCallback(el) { }
|
|
74
|
-
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
75
84
|
disconnectedCallback() {
|
|
76
85
|
const ctor = this.constructor;
|
|
77
86
|
ctor.polyfillDisconnectedCallback(this);
|
|
@@ -80,6 +89,12 @@ export class FormBase extends HTMLFormElement {
|
|
|
80
89
|
const ctor = this.constructor;
|
|
81
90
|
ctor.polyfillConnectedCallback(this);
|
|
82
91
|
}
|
|
92
|
+
}
|
|
93
|
+
export class FormBase extends HTMLFormElement {
|
|
94
|
+
static polyfillExtends = 'form';
|
|
95
|
+
static polyfillConnectedCallback(el) { }
|
|
96
|
+
static polyfillDisconnectedCallback(el) { }
|
|
97
|
+
static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
|
|
83
98
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
84
99
|
const ctor = this.constructor;
|
|
85
100
|
const entry = {
|
|
@@ -89,4 +104,12 @@ export class FormBase extends HTMLFormElement {
|
|
|
89
104
|
};
|
|
90
105
|
ctor.polyfillAttributeChangedCallback([entry]);
|
|
91
106
|
}
|
|
107
|
+
disconnectedCallback() {
|
|
108
|
+
const ctor = this.constructor;
|
|
109
|
+
ctor.polyfillDisconnectedCallback(this);
|
|
110
|
+
}
|
|
111
|
+
connectedCallback() {
|
|
112
|
+
const ctor = this.constructor;
|
|
113
|
+
ctor.polyfillConnectedCallback(this);
|
|
114
|
+
}
|
|
92
115
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface TypedEventTargetMethods<M> {
|
|
2
|
+
addEventListener: {
|
|
3
|
+
<K extends keyof M>(type: K, listener: (this: HTMLElement, ev: M[K] extends Event ? M[K] : never) => void, options?: boolean | AddEventListenerOptions): void;
|
|
4
|
+
(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
|
|
5
|
+
};
|
|
6
|
+
removeEventListener: {
|
|
7
|
+
<K extends keyof M>(type: K, listener: (this: HTMLElement, ev: M[K] extends Event ? M[K] : never) => void, options?: boolean | EventListenerOptions): void;
|
|
8
|
+
(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare class Snapshot {
|
|
2
2
|
#private;
|
|
3
|
-
static
|
|
3
|
+
static get breakpoints(): ReadonlyMap<string, boolean> | undefined;
|
|
4
|
+
static on: EventTarget;
|
|
5
|
+
static readonly waitReady: Promise<[void, void]>;
|
|
4
6
|
static waitReadyFor<T extends HTMLElement>(element: T): Promise<T | null>;
|
|
5
7
|
static get config(): Record<string, string> | undefined;
|
|
6
8
|
static setOwnConfig(): Promise<void>;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { devFlags, onoff } from '../internal/utils';
|
|
1
2
|
export class Snapshot {
|
|
2
3
|
static #readyCalled = false;
|
|
3
4
|
static #config;
|
|
5
|
+
static #listeners;
|
|
6
|
+
static #breakpoints;
|
|
7
|
+
static get breakpoints() {
|
|
8
|
+
return this.#breakpoints;
|
|
9
|
+
}
|
|
10
|
+
static on = new EventTarget();
|
|
4
11
|
static waitReady = Promise.all([
|
|
5
|
-
'complete' === document.readyState ? Promise.resolve() : new Promise((r) => self.addEventListener('load', r, { once: true })),
|
|
12
|
+
'complete' === document.readyState ? Promise.resolve() : new Promise((r) => self.addEventListener('load', () => r(), { once: true })),
|
|
6
13
|
(async () => {
|
|
7
14
|
if (!this.#readyCalled)
|
|
8
15
|
await this.setOwnConfig();
|
|
@@ -32,6 +39,22 @@ export class Snapshot {
|
|
|
32
39
|
catch {
|
|
33
40
|
console.error('could-not-parse-config');
|
|
34
41
|
}
|
|
35
|
-
|
|
42
|
+
for (const off of this.#listeners ?? [])
|
|
43
|
+
off?.();
|
|
44
|
+
this.#listeners = new Set();
|
|
45
|
+
const mediaQueryList = self.matchMedia(`(pointer: fine) and (min-width: ${this.#config['ipad-sheet-view-inline-size']}) and (min-height: ${this.#config['ipad-sheet-view-height']})`);
|
|
46
|
+
this.#breakpoints = new Map([['fine_dialog_sheet', mediaQueryList.matches]]);
|
|
47
|
+
this.#listeners.add(onoff('change', (evt) => this.#handleMediaChange(evt, 'fine_dialog_sheet:change'), mediaQueryList).on());
|
|
48
|
+
if (devFlags.debug)
|
|
49
|
+
console.debug(this.#config);
|
|
36
50
|
}
|
|
51
|
+
static #handleMediaChange = ({ type, matches, media }, kind) => {
|
|
52
|
+
if (devFlags.debug)
|
|
53
|
+
console.debug(`${Snapshot.name} ⚡️ ${type}`);
|
|
54
|
+
this.#breakpoints?.set('fine_dialog_sheet', matches);
|
|
55
|
+
this.on.dispatchEvent(new MediaQueryListEvent(kind, {
|
|
56
|
+
matches,
|
|
57
|
+
media,
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
37
60
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// --- Template preparation (runs ONCE per unique template literal) -----
|
|
2
|
+
const MARKER = '\uD83D\uDD25PART\uD83D\uDD25'; // unlikely-collision sentinel
|
|
3
|
+
const templateCache = new WeakMap();
|
|
4
|
+
function prepare(strings) {
|
|
5
|
+
let cached = templateCache.get(strings);
|
|
6
|
+
if (cached)
|
|
7
|
+
return cached;
|
|
8
|
+
const partDescriptors = [];
|
|
9
|
+
let htmlStr = '';
|
|
10
|
+
strings.forEach((chunk, i) => {
|
|
11
|
+
htmlStr += chunk;
|
|
12
|
+
if (i < strings.length - 1) {
|
|
13
|
+
// Is this interpolation inside an attribute value?
|
|
14
|
+
// e.g. `...aria-checked="${...}"` — chunk ends with `attr="` or `attr='` or `attr=`
|
|
15
|
+
const attrMatch = /([a-zA-Z0-9_-]+)=(["']?)$/.exec(chunk);
|
|
16
|
+
if (attrMatch) {
|
|
17
|
+
partDescriptors.push({ type: 'attr', name: attrMatch[1] });
|
|
18
|
+
htmlStr += MARKER; // becomes the attribute's value
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
partDescriptors.push({ type: 'child' });
|
|
22
|
+
// start/end comment pair — gives us a stable region to patch later,
|
|
23
|
+
// and room to grow into list/array rendering without a redesign
|
|
24
|
+
htmlStr += `<!--${MARKER}-->`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const element = document.createElement('template');
|
|
29
|
+
element.innerHTML = htmlStr;
|
|
30
|
+
cached = { element, partDescriptors };
|
|
31
|
+
templateCache.set(strings, cached);
|
|
32
|
+
return cached;
|
|
33
|
+
}
|
|
34
|
+
const instanceCache = new WeakMap();
|
|
35
|
+
function createInstance(prepared) {
|
|
36
|
+
const fragment = prepared.element.content.cloneNode(true);
|
|
37
|
+
const parts = [];
|
|
38
|
+
// Walk the clone once, in the same order `prepare()` emitted markers,
|
|
39
|
+
// and bind each descriptor to a real node.
|
|
40
|
+
const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT);
|
|
41
|
+
let descriptorIndex = 0;
|
|
42
|
+
const descriptors = prepared.partDescriptors;
|
|
43
|
+
let node;
|
|
44
|
+
while ((node = walker.nextNode())) {
|
|
45
|
+
if (descriptorIndex >= descriptors.length)
|
|
46
|
+
break;
|
|
47
|
+
if (node.nodeType === Node.COMMENT_NODE && node.data === MARKER) {
|
|
48
|
+
parts.push({ type: 'child', anchor: node, nodes: [], committed: undefined });
|
|
49
|
+
descriptorIndex++;
|
|
50
|
+
}
|
|
51
|
+
else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
52
|
+
const el = node;
|
|
53
|
+
for (const attr of Array.from(el.attributes)) {
|
|
54
|
+
if (attr.value === MARKER) {
|
|
55
|
+
const desc = descriptors[descriptorIndex];
|
|
56
|
+
if (desc.type === 'attr') {
|
|
57
|
+
parts.push({ type: 'attr', el, name: desc.name, committed: undefined });
|
|
58
|
+
descriptorIndex++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { fragment, parts };
|
|
65
|
+
}
|
|
66
|
+
// --- Committing values into parts (the only thing that runs per update) -
|
|
67
|
+
function isTemplateResult(v) {
|
|
68
|
+
return !!v && typeof v === 'object' && 'strings' in v && 'values' in v;
|
|
69
|
+
}
|
|
70
|
+
function toNode(value) {
|
|
71
|
+
if (value instanceof Node)
|
|
72
|
+
return value;
|
|
73
|
+
if (isTemplateResult(value)) {
|
|
74
|
+
const { fragment, parts } = createInstance(prepare(value.strings));
|
|
75
|
+
parts.forEach((part, i) => {
|
|
76
|
+
const v = value.values[i];
|
|
77
|
+
part.type === 'child' ? commitChild(part, v) : commitAttr(part, v);
|
|
78
|
+
});
|
|
79
|
+
return fragment;
|
|
80
|
+
}
|
|
81
|
+
return document.createTextNode(String(value));
|
|
82
|
+
}
|
|
83
|
+
function commitChild(part, value) {
|
|
84
|
+
if (value === part.committed)
|
|
85
|
+
return; // dirty-check, skip untouched parts
|
|
86
|
+
for (const n of part.nodes)
|
|
87
|
+
n.remove();
|
|
88
|
+
const nodes = [];
|
|
89
|
+
for (const item of Array.isArray(value) ? value : [value]) {
|
|
90
|
+
if (item === null || item === undefined || item === false)
|
|
91
|
+
continue;
|
|
92
|
+
const node = toNode(item);
|
|
93
|
+
const inserted = node instanceof DocumentFragment ? Array.from(node.childNodes) : [node];
|
|
94
|
+
part.anchor.before(node);
|
|
95
|
+
nodes.push(...inserted);
|
|
96
|
+
}
|
|
97
|
+
part.nodes = nodes;
|
|
98
|
+
part.committed = value;
|
|
99
|
+
}
|
|
100
|
+
function commitAttr(part, value) {
|
|
101
|
+
if (value === part.committed)
|
|
102
|
+
return;
|
|
103
|
+
if (value === null || value === undefined || value === false) {
|
|
104
|
+
part.el.removeAttribute(part.name);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
part.el.setAttribute(part.name, String(value));
|
|
108
|
+
}
|
|
109
|
+
part.committed = value;
|
|
110
|
+
}
|
|
111
|
+
// --- Public render() ----------------------------------------------------
|
|
112
|
+
export default function (result, container) {
|
|
113
|
+
const prepared = prepare(result.strings);
|
|
114
|
+
let instance = instanceCache.get(container);
|
|
115
|
+
if (!instance || instance.strings !== result.strings) {
|
|
116
|
+
// first render, OR the template shape changed entirely — full (re)build
|
|
117
|
+
container.textContent = '';
|
|
118
|
+
const { fragment, parts } = createInstance(prepared);
|
|
119
|
+
container.append(fragment);
|
|
120
|
+
instance = { strings: result.strings, fragmentRoot: fragment, parts };
|
|
121
|
+
instanceCache.set(container, instance);
|
|
122
|
+
}
|
|
123
|
+
// same template shape as last time → patch existing DOM nodes only,
|
|
124
|
+
// no innerHTML, no re-clone, no focus/scroll loss
|
|
125
|
+
instance.parts.forEach((part, i) => {
|
|
126
|
+
const value = result.values[i];
|
|
127
|
+
if (part.type === 'child')
|
|
128
|
+
commitChild(part, value);
|
|
129
|
+
else
|
|
130
|
+
commitAttr(part, value);
|
|
131
|
+
});
|
|
132
|
+
}
|