@swiftwc/ui 0.0.0-dev.11 → 0.0.0-dev.111
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/css-data/en.json +28 -0
- 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 +24 -10
- package/generated/client/index.js +179 -194
- package/generated/components/alert-dialog.d.ts +11 -0
- package/generated/components/alert-dialog.js +94 -0
- package/generated/components/body-view.d.ts +8 -0
- package/generated/components/body-view.js +6 -2
- package/generated/components/bordered-button.d.ts +10 -0
- package/generated/components/bordered-button.js +36 -3
- package/generated/components/bordered-prominent-button.d.ts +10 -0
- package/generated/components/bordered-prominent-button.js +36 -3
- package/generated/components/borderless-button.d.ts +9 -1
- package/generated/components/borderless-button.js +29 -11
- package/generated/components/color-scheme.d.ts +12 -0
- package/generated/components/color-scheme.js +51 -0
- package/generated/components/confirmation-dialog.d.ts +4 -1
- package/generated/components/confirmation-dialog.js +38 -32
- package/generated/components/content-unavailable.d.ts +30 -0
- package/generated/components/content-unavailable.js +79 -0
- package/generated/components/date-picker.d.ts +21 -15
- package/generated/components/date-picker.js +126 -88
- package/generated/components/detail-placeholder.d.ts +11 -0
- package/generated/components/detail-placeholder.js +15 -0
- package/generated/components/disclosure-group.d.ts +8 -0
- package/generated/components/disclosure-group.js +18 -7
- package/generated/components/fine-tooltip.d.ts +15 -0
- package/generated/components/fine-tooltip.js +108 -0
- package/generated/components/form-view.d.ts +10 -0
- package/generated/components/form-view.js +8 -3
- package/generated/components/glass-button.d.ts +10 -0
- package/generated/components/glass-button.js +36 -3
- package/generated/components/glass-prominent-button.d.ts +10 -0
- package/generated/components/glass-prominent-button.js +36 -3
- package/generated/components/h-divider.d.ts +11 -0
- package/generated/components/h-divider.js +15 -0
- package/generated/components/h-stack.d.ts +22 -0
- package/generated/components/h-stack.js +24 -0
- package/generated/components/image-view.d.ts +18 -0
- package/generated/components/image-view.js +65 -0
- package/generated/components/index.d.ts +15 -3
- package/generated/components/index.js +15 -3
- package/generated/components/label-view.d.ts +19 -1
- package/generated/components/label-view.js +63 -62
- package/generated/components/labeled-content.d.ts +33 -0
- package/generated/components/labeled-content.js +160 -0
- package/generated/components/list-view.d.ts +14 -0
- package/generated/components/list-view.js +12 -17
- package/generated/components/menu-view.d.ts +12 -1
- package/generated/components/menu-view.js +63 -65
- package/generated/components/navigation-large-title.d.ts +11 -0
- package/generated/components/navigation-large-title.js +11 -5
- package/generated/components/navigation-split-view.d.ts +9 -1
- package/generated/components/navigation-split-view.js +10 -6
- package/generated/components/navigation-stack.d.ts +9 -1
- package/generated/components/navigation-stack.js +13 -11
- package/generated/components/navigation-title.d.ts +11 -1
- package/generated/components/navigation-title.js +58 -55
- package/generated/components/picker-view.d.ts +48 -7
- package/generated/components/picker-view.js +971 -261
- package/generated/components/plain-button.js +3 -3
- package/generated/components/progress-view.d.ts +20 -0
- package/generated/components/progress-view.js +120 -0
- package/generated/components/screen-view.js +2 -1
- package/generated/components/scroll-view-proxy.d.ts +13 -0
- package/generated/components/scroll-view-proxy.js +15 -0
- package/generated/components/scroll-view.d.ts +13 -1
- package/generated/components/scroll-view.js +140 -97
- package/generated/components/search-view.d.ts +12 -0
- package/generated/components/search-view.js +24 -0
- package/generated/components/section-view.d.ts +13 -1
- package/generated/components/section-view.js +38 -58
- package/generated/components/sheet-view.d.ts +4 -2
- package/generated/components/sheet-view.js +10 -39
- package/generated/components/sidebar-toggle.d.ts +9 -1
- package/generated/components/sidebar-toggle.js +46 -69
- package/generated/components/sidebar-view.d.ts +3 -0
- package/generated/components/sidebar-view.js +16 -9
- package/generated/components/sticky-container.d.ts +6 -1
- package/generated/components/sticky-container.js +9 -7
- package/generated/components/tab-bar.d.ts +3 -0
- package/generated/components/tab-bar.js +17 -13
- package/generated/components/tab-item.d.ts +3 -0
- package/generated/components/tab-item.js +20 -13
- package/generated/components/tab-view.d.ts +13 -4
- package/generated/components/tab-view.js +25 -89
- package/generated/components/table-view.d.ts +19 -0
- package/generated/components/table-view.js +88 -107
- package/generated/components/text-field.d.ts +19 -6
- package/generated/components/text-field.js +127 -99
- package/generated/components/text-view.d.ts +11 -0
- package/generated/components/text-view.js +16 -0
- package/generated/components/toggle-view.d.ts +43 -0
- package/generated/components/toggle-view.js +366 -0
- package/generated/components/tool-bar-item-group.d.ts +8 -0
- package/generated/components/tool-bar-item-group.js +22 -4
- package/generated/components/tool-bar-item.d.ts +12 -1
- package/generated/components/tool-bar-item.js +57 -10
- package/generated/components/tool-bar.d.ts +19 -0
- package/generated/components/tool-bar.js +48 -33
- package/generated/components/v-divider.d.ts +11 -0
- package/generated/components/v-divider.js +15 -0
- package/generated/components/v-keyboard.d.ts +8 -1
- package/generated/components/v-keyboard.js +11 -9
- package/generated/components/v-stack.d.ts +20 -0
- package/generated/components/v-stack.js +18 -2
- package/generated/css/index.css +4617 -1266
- package/generated/events/alert-dialog.d.ts +13 -0
- package/generated/events/alert-dialog.js +1 -0
- package/generated/events/confirmation-dialog.d.ts +7 -2
- package/generated/events/date-picker.d.ts +6 -1
- package/generated/events/index.d.ts +2 -0
- package/generated/events/index.js +2 -0
- package/generated/events/lifecycle-observer.d.ts +10 -2
- package/generated/events/picker-view.d.ts +22 -1
- package/generated/events/scroll-view.d.ts +10 -2
- package/generated/events/tab-view.d.ts +38 -8
- package/generated/events/text-field.d.ts +6 -1
- package/generated/events/toggle-view.d.ts +14 -0
- package/generated/events/toggle-view.js +1 -0
- package/generated/i18n/index.d.ts +19 -10
- package/generated/i18n/index.js +79 -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 +2 -2
- package/generated/internal/class/form-associated-base.d.ts +0 -4
- package/generated/internal/class/form-associated-base.js +22 -39
- 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 +36 -43
- package/generated/internal/decorators/adaptive-slot.d.ts +1 -0
- package/generated/internal/decorators/adaptive-slot.js +47 -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/flags.d.ts +4 -0
- package/generated/internal/flags.js +1 -0
- package/generated/internal/privateNamespace.d.ts +10 -0
- package/generated/internal/privateNamespace.js +159 -1
- package/generated/internal/utils/$.d.ts +9 -0
- package/generated/internal/utils/$.js +11 -0
- package/generated/internal/utils/compare-big-decimals.js +7 -17
- package/generated/internal/utils/debug.d.ts +1 -0
- package/generated/internal/utils/debug.js +4 -0
- package/generated/internal/utils/define-translations.d.ts +1 -0
- package/generated/internal/utils/define-translations.js +3 -0
- package/generated/internal/utils/ensure-placeholder.d.ts +1 -0
- package/generated/internal/utils/ensure-placeholder.js +41 -0
- package/generated/internal/utils/index.d.ts +39 -2
- package/generated/internal/utils/index.js +39 -3
- package/generated/internal/utils/is-inside.d.ts +1 -0
- package/generated/internal/utils/is-inside.js +4 -0
- package/generated/internal/utils/kebab-case.js +6 -9
- package/generated/internal/utils/list-active.js +67 -12
- package/generated/internal/utils/touch-glass.js +5 -5
- package/generated/internal/vendor/morphdom.d.ts +6 -0
- package/generated/internal/vendor/morphdom.js +720 -0
- package/generated/morphdom/index.d.ts +8 -0
- package/generated/morphdom/index.js +8 -0
- package/generated/morphdom/morph.d.ts +4 -0
- package/generated/morphdom/morph.js +10 -0
- package/generated/morphdom/query-morph.d.ts +5 -0
- package/generated/morphdom/query-morph.js +12 -0
- package/generated/morphdom/render-to-string.d.ts +12 -0
- package/generated/morphdom/render-to-string.js +48 -0
- package/generated/morphdom/unsafe-html.d.ts +2 -0
- package/generated/morphdom/unsafe-html.js +4 -0
- 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 +23 -2
- package/generated/tpl/html.d.ts +5 -0
- package/generated/tpl/html.js +7 -0
- package/generated/tpl/index.d.ts +6 -0
- package/generated/tpl/index.js +6 -0
- package/generated/tpl/is-template-result.d.ts +3 -0
- package/generated/tpl/is-template-result.js +1 -0
- package/generated/tpl/render.d.ts +2 -0
- package/generated/tpl/render.js +132 -0
- package/html-data/en.json +2620 -0
- package/package.json +32 -7
- package/scss/_components.scss +15 -0
- package/scss/_functions.scss +10 -0
- package/scss/_maps.scss +293 -0
- package/scss/_mixins.scss +4 -0
- package/scss/_transitions.scss +6 -1
- package/scss/_utils.scss +2 -0
- package/scss/_vars.scss +9 -115
- package/scss/base/_layout.scss +17 -7
- package/scss/base/_reboot.scss +34 -1
- package/scss/base/_root.scss +143 -124
- package/scss/colors/_index.scss +328 -88
- package/scss/components/_alert-dialog.scss +111 -0
- package/scss/components/_bordered-button.scss +37 -0
- package/scss/components/_bordered-prominent-button.scss +46 -0
- package/scss/components/_borderless-button.scss +26 -0
- package/scss/components/_confirmation-dialog.scss +41 -49
- package/scss/components/_content-unavailable.scss +57 -0
- package/scss/components/_date-picker.scss +15 -15
- package/scss/components/_detail-placeholder.scss +1 -3
- package/scss/components/_disclosure-group.scss +85 -34
- package/scss/components/_fine-tooltip.scss +84 -0
- package/scss/components/_form-view.scss +63 -24
- package/scss/components/_glass-button.scss +37 -0
- package/scss/components/_glass-prominent-button.scss +47 -0
- package/scss/components/_group-box.scss +27 -0
- package/scss/components/_h-flex-stack.scss +23 -0
- package/scss/components/_h-stack.scss +6 -17
- package/scss/components/_image-view.scss +20 -0
- package/scss/components/_index.scss +69 -36
- package/scss/components/_label-view copy.scss.txt +420 -0
- package/scss/components/_label-view.scss +105 -120
- package/scss/components/_label-view.scss.txt +536 -0
- package/scss/components/_labeled-content.scss +67 -1
- package/scss/components/_list-view.scss +70 -29
- package/scss/components/_menu-view.scss +96 -61
- package/scss/components/_navigation-large-title.scss +23 -0
- package/scss/components/_navigation-split-view.scss +3 -3
- package/scss/components/_navigation-title.scss +1 -1
- package/scss/components/_picker-view.scss +270 -63
- package/scss/components/_plain-button.scss +8 -0
- package/scss/components/_progress-view.scss +98 -0
- package/scss/components/_scroll-view-proxy.scss +24 -22
- package/scss/components/_scroll-view-toolbars.scss +8 -2
- package/scss/components/_scroll-view.scss +16 -0
- package/scss/components/_search-view.scss +23 -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 +12 -2
- package/scss/components/_table-column.scss +4 -2
- package/scss/components/_table-row.scss +71 -3
- package/scss/components/_table-view.scss +27 -18
- package/scss/components/_text-field.scss +37 -17
- package/scss/components/_text-view.scss +57 -0
- package/scss/components/_toggle-view.scss +171 -0
- package/scss/components/_tool-bar-item.scss +34 -82
- package/scss/components/_tool-bar.scss +77 -57
- package/scss/components/_v-stack.scss +8 -2
- package/scss/final/_touch-glass.scss +31 -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 +73 -5
- package/scss/placeholders/_buttons.scss +46 -11
- package/scss/placeholders/_lists.scss +159 -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/_background.scss +52 -0
- package/scss/utils/_frame.scss +59 -40
- package/scss/utils/_index.scss +45 -56
- package/scss/utils/_scroll-view.scss +1 -1
- package/scss/utils/_spacing.scss +1 -1
- package/scss/utils/_stacks.scss +34 -164
- package/generated/confirmation-dialog/index.d.ts +0 -1
- package/generated/confirmation-dialog/index.js +0 -1
- package/generated/internal/utils/cash/index.d.ts +0 -22
- package/generated/internal/utils/cash/index.js +0 -23
- package/generated/lifecycle-observer/index.d.ts +0 -1
- package/generated/lifecycle-observer/index.js +0 -1
- package/scss/transitions/_dialog.scss +0 -28
- package/web-components.html-data/en.json +0 -330
- /package/generated/internal/utils/{cash/ancestors.d.ts → ancestors.d.ts} +0 -0
- /package/generated/internal/utils/{cash/ancestors.js → ancestors.js} +0 -0
- /package/generated/internal/utils/{cash/next-all.d.ts → next-all.d.ts} +0 -0
- /package/generated/internal/utils/{cash/next-all.js → next-all.js} +0 -0
- /package/generated/internal/utils/{cash/next.d.ts → next.d.ts} +0 -0
- /package/generated/internal/utils/{cash/next.js → next.js} +0 -0
- /package/generated/internal/utils/{cash/prev-all.d.ts → prev-all.d.ts} +0 -0
- /package/generated/internal/utils/{cash/prev-all.js → prev-all.js} +0 -0
- /package/generated/internal/utils/{cash/prev.d.ts → prev.d.ts} +0 -0
- /package/generated/internal/utils/{cash/prev.js → prev.js} +0 -0
- /package/generated/internal/utils/{cash/prop.d.ts → prop.d.ts} +0 -0
- /package/generated/internal/utils/{cash/prop.js → prop.js} +0 -0
- /package/generated/internal/utils/{cash/siblings.d.ts → siblings.d.ts} +0 -0
- /package/generated/internal/utils/{cash/siblings.js → siblings.js} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as morph } from './morph';
|
|
2
|
+
export * from './morph';
|
|
3
|
+
export { default as queryMorph } from './query-morph';
|
|
4
|
+
export * from './query-morph';
|
|
5
|
+
export { default as renderToString } from './render-to-string';
|
|
6
|
+
export * from './render-to-string';
|
|
7
|
+
export { default as unsafeHtml } from './unsafe-html';
|
|
8
|
+
export * from './unsafe-html';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as morph } from './morph';
|
|
2
|
+
export * from './morph';
|
|
3
|
+
export { default as queryMorph } from './query-morph';
|
|
4
|
+
export * from './query-morph';
|
|
5
|
+
export { default as renderToString } from './render-to-string';
|
|
6
|
+
export * from './render-to-string';
|
|
7
|
+
export { default as unsafeHtml } from './unsafe-html';
|
|
8
|
+
export * from './unsafe-html';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import morphdom from '../internal/vendor/morphdom';
|
|
2
|
+
import renderToString from './render-to-string';
|
|
3
|
+
export default function (markup, fromEl, options) {
|
|
4
|
+
if (!fromEl)
|
|
5
|
+
return;
|
|
6
|
+
morphdom(fromEl, renderToString(markup).toString(), {
|
|
7
|
+
onBeforeElUpdated: (fromEl, toEl) => !fromEl.isEqualNode(toEl),
|
|
8
|
+
onBeforeElChildrenUpdated: (fromEl, toEl) => !toEl.matches('image-view,navigation-title'), // NOTE: image-view will alter it's contents! This is required to not empty it up again!
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $ } from '../internal/utils';
|
|
2
|
+
import morph from './morph';
|
|
3
|
+
export default function (scopedSelector, template, container, options) {
|
|
4
|
+
if (false === options?.cb?.())
|
|
5
|
+
return;
|
|
6
|
+
if ('boolean' === typeof options?.removeIf && options?.removeIf)
|
|
7
|
+
return container?.querySelector(`:scope>${scopedSelector}`)?.remove();
|
|
8
|
+
const fromEl = container?.querySelector(`:scope>${scopedSelector}`) ?? container?.appendChild($(template, '>1'));
|
|
9
|
+
if (!fromEl)
|
|
10
|
+
return;
|
|
11
|
+
morph(template, fromEl);
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TemplateResult } from '../tpl';
|
|
2
|
+
export declare class TrustedMarkup {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
constructor(value: string);
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Flatten a TemplateResult (from `html`) into an escaped TrustedMarkup
|
|
9
|
+
* string. Use this only at morph/queryMorph call sites — anywhere feeding
|
|
10
|
+
* `render()` should keep passing the raw TemplateResult straight through.
|
|
11
|
+
*/
|
|
12
|
+
export default function renderToString(template: TemplateResult): TrustedMarkup;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isTemplateResult } from '../tpl';
|
|
2
|
+
// morph.ts and queryMorph.ts only need something with `.toString()` that
|
|
3
|
+
// yields a safe, escaped HTML string — this is that, built on top of the
|
|
4
|
+
// same TemplateResult instead of a separate tag function.
|
|
5
|
+
// values built via `raw` itself are trusted markup; wrap them so `stringify`
|
|
6
|
+
// knows to skip escaping — same idea as lit-html's `unsafeHTML`
|
|
7
|
+
export class TrustedMarkup {
|
|
8
|
+
value;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return this.value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const ESCAPE_MAP = {
|
|
17
|
+
'&': '&',
|
|
18
|
+
'<': '<',
|
|
19
|
+
'>': '>',
|
|
20
|
+
'"': '"',
|
|
21
|
+
"'": ''',
|
|
22
|
+
};
|
|
23
|
+
function escapeHtml(str) {
|
|
24
|
+
return str.replace(/[&<>"']/g, (ch) => ESCAPE_MAP[ch]);
|
|
25
|
+
}
|
|
26
|
+
function stringifyValue(value) {
|
|
27
|
+
if (value === null || value === undefined || value === false)
|
|
28
|
+
return '';
|
|
29
|
+
if (value instanceof TrustedMarkup)
|
|
30
|
+
return value.value;
|
|
31
|
+
if (isTemplateResult(value))
|
|
32
|
+
return renderToString(value).value;
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
return value.map(stringifyValue).join('');
|
|
35
|
+
return escapeHtml(String(value));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Flatten a TemplateResult (from `html`) into an escaped TrustedMarkup
|
|
39
|
+
* string. Use this only at morph/queryMorph call sites — anywhere feeding
|
|
40
|
+
* `render()` should keep passing the raw TemplateResult straight through.
|
|
41
|
+
*/
|
|
42
|
+
export default function renderToString(template) {
|
|
43
|
+
let out = template.strings[0];
|
|
44
|
+
for (let i = 0; i < template.values.length; i++) {
|
|
45
|
+
out += stringifyValue(template.values[i]) + template.strings[i + 1];
|
|
46
|
+
}
|
|
47
|
+
return new TrustedMarkup(out.replace(/>\s+</g, '><').trim());
|
|
48
|
+
}
|
|
@@ -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 { debug, 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,20 @@ 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
|
+
debug(this.#config);
|
|
36
49
|
}
|
|
50
|
+
static #handleMediaChange = ({ type, matches, media }, kind) => {
|
|
51
|
+
debug(`${Snapshot.name} ⚡️ ${type}`);
|
|
52
|
+
this.#breakpoints?.set('fine_dialog_sheet', matches);
|
|
53
|
+
this.on.dispatchEvent(new MediaQueryListEvent(kind, {
|
|
54
|
+
matches,
|
|
55
|
+
media,
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
37
58
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Purely structural — captures strings/values as-is. render.ts relies on
|
|
2
|
+
// `strings` identity (TemplateStringsArray) for its template cache, so this
|
|
3
|
+
// must stay exactly this shape: no wrapping, no cloning, no new object
|
|
4
|
+
// allocation beyond the literal { strings, values }.
|
|
5
|
+
export default function (strings, ...values) {
|
|
6
|
+
return { strings, values };
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (v) => !!v && typeof v === 'object' && 'strings' in v && 'values' in v;
|
|
@@ -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
|
+
}
|