@swiftwc/ui 0.0.0-dev.1 → 0.0.0-dev.101
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/README.md +15 -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 +30 -2
- package/generated/client/index.js +279 -8
- package/generated/components/alert-dialog.d.ts +11 -0
- package/generated/components/alert-dialog.js +102 -0
- package/generated/components/body-view.d.ts +13 -0
- package/generated/components/body-view.js +17 -0
- package/generated/components/bordered-button.d.ts +17 -0
- package/generated/components/bordered-button.js +56 -0
- package/generated/components/bordered-prominent-button.d.ts +17 -0
- package/generated/components/bordered-prominent-button.js +56 -0
- package/generated/components/borderless-button.d.ts +17 -0
- package/generated/components/borderless-button.js +56 -0
- package/generated/components/color-scheme.d.ts +12 -0
- package/generated/components/color-scheme.js +54 -0
- package/generated/components/confirmation-dialog.d.ts +12 -0
- package/generated/components/confirmation-dialog.js +116 -0
- package/generated/components/content-unavailable.d.ts +30 -0
- package/generated/components/content-unavailable.js +82 -0
- package/generated/components/date-picker.d.ts +52 -0
- package/generated/components/date-picker.js +480 -0
- package/generated/components/detail-placeholder.d.ts +11 -0
- package/generated/components/detail-placeholder.js +19 -0
- package/generated/components/disclosure-group.d.ts +17 -0
- package/generated/components/disclosure-group.js +66 -0
- package/generated/components/fine-tooltip.d.ts +15 -0
- package/generated/components/fine-tooltip.js +111 -0
- package/generated/components/form-view.d.ts +16 -0
- package/generated/components/form-view.js +65 -0
- package/generated/components/glass-button.d.ts +16 -0
- package/generated/components/glass-button.js +53 -0
- package/generated/components/glass-prominent-button.d.ts +16 -0
- package/generated/components/glass-prominent-button.js +53 -0
- package/generated/components/h-stack.d.ts +22 -0
- package/generated/components/h-stack.js +26 -0
- package/generated/components/image-view.d.ts +18 -0
- package/generated/components/image-view.js +68 -0
- package/generated/components/index.d.ts +49 -1
- package/generated/components/index.js +49 -6
- package/generated/components/label-view.d.ts +27 -0
- package/generated/components/label-view.js +87 -0
- package/generated/components/labeled-content.d.ts +33 -0
- package/generated/components/labeled-content.js +163 -0
- package/generated/components/list-view.d.ts +18 -0
- package/generated/components/list-view.js +25 -0
- package/generated/components/menu-view.d.ts +20 -0
- package/generated/components/menu-view.js +140 -0
- package/generated/components/navigation-large-title.d.ts +18 -0
- package/generated/components/navigation-large-title.js +188 -0
- package/generated/components/navigation-split-view.d.ts +15 -0
- package/generated/components/navigation-split-view.js +25 -0
- package/generated/components/navigation-stack.d.ts +15 -0
- package/generated/components/navigation-stack.js +29 -0
- package/generated/components/navigation-title.d.ts +18 -0
- package/generated/components/navigation-title.js +72 -0
- package/generated/components/picker-view.d.ts +68 -0
- package/generated/components/picker-view.js +1153 -0
- package/generated/components/plain-button.d.ts +7 -0
- package/generated/components/plain-button.js +22 -0
- package/generated/components/progress-view.d.ts +20 -0
- package/generated/components/progress-view.js +125 -0
- package/generated/components/screen-view.d.ts +5 -0
- package/generated/components/screen-view.js +11 -0
- package/generated/components/scroll-view-proxy.d.ts +13 -0
- package/generated/components/scroll-view-proxy.js +17 -0
- package/generated/components/scroll-view.d.ts +22 -0
- package/generated/components/scroll-view.js +237 -0
- package/generated/components/search-view.d.ts +12 -0
- package/generated/components/search-view.js +27 -0
- package/generated/components/section-view.d.ts +21 -0
- package/generated/components/section-view.js +64 -0
- package/generated/components/sheet-view.d.ts +11 -0
- package/generated/components/sheet-view.js +45 -0
- package/generated/components/sidebar-toggle.d.ts +15 -0
- package/generated/components/sidebar-toggle.js +88 -0
- package/generated/components/sidebar-view.d.ts +10 -0
- package/generated/components/sidebar-view.js +37 -0
- package/generated/components/sticky-container.d.ts +11 -0
- package/generated/components/sticky-container.js +26 -0
- package/generated/components/tab-bar.d.ts +10 -0
- package/generated/components/tab-bar.js +40 -0
- package/generated/components/tab-item.d.ts +10 -0
- package/generated/components/tab-item.js +134 -0
- package/generated/components/tab-view.d.ts +31 -0
- package/generated/components/tab-view.js +198 -0
- package/generated/components/table-view.d.ts +26 -0
- package/generated/components/table-view.js +161 -0
- package/generated/components/text-field.d.ts +42 -0
- package/generated/components/text-field.js +526 -0
- package/generated/components/text-view.d.ts +11 -0
- package/generated/components/text-view.js +19 -0
- package/generated/components/toggle-view.d.ts +43 -0
- package/generated/components/toggle-view.js +371 -0
- package/generated/components/tool-bar-item-group.d.ts +13 -0
- package/generated/components/tool-bar-item-group.js +31 -0
- package/generated/components/tool-bar-item.d.ts +16 -0
- package/generated/components/tool-bar-item.js +69 -0
- package/generated/components/tool-bar.d.ts +26 -0
- package/generated/components/tool-bar.js +95 -0
- package/generated/components/v-keyboard.d.ts +18 -0
- package/generated/components/v-keyboard.js +87 -0
- package/generated/components/v-stack.d.ts +25 -0
- package/generated/components/v-stack.js +29 -0
- package/generated/css/index.css +10732 -0
- package/generated/events/alert-dialog.d.ts +13 -0
- package/generated/events/alert-dialog.js +1 -0
- package/generated/events/confirmation-dialog.d.ts +14 -0
- package/generated/events/confirmation-dialog.js +1 -0
- package/generated/events/date-picker.d.ts +13 -0
- package/generated/events/date-picker.js +1 -0
- package/generated/events/index.d.ts +9 -0
- package/generated/events/index.js +9 -0
- package/generated/events/lifecycle-observer.d.ts +18 -0
- package/generated/events/lifecycle-observer.js +1 -0
- package/generated/events/picker-view.d.ts +29 -0
- package/generated/events/picker-view.js +1 -0
- package/generated/events/scroll-view.d.ts +18 -0
- package/generated/events/scroll-view.js +1 -0
- package/generated/events/tab-view.d.ts +54 -0
- package/generated/events/tab-view.js +1 -0
- package/generated/events/text-field.d.ts +13 -0
- package/generated/events/text-field.js +1 -0
- package/generated/events/toggle-view.d.ts +14 -0
- package/generated/events/toggle-view.js +1 -0
- package/generated/i18n/index.d.ts +33 -0
- package/generated/i18n/index.js +164 -0
- 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/index.js +1 -1
- package/generated/internal/class/cleanup-registry.d.ts +5 -0
- package/generated/internal/class/cleanup-registry.js +38 -0
- package/generated/internal/class/css-style-observer.d.ts +8 -0
- package/generated/internal/class/css-style-observer.js +26 -0
- package/generated/internal/class/form-associated-base.d.ts +16 -0
- package/generated/internal/class/form-associated-base.js +78 -0
- 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.d.ts +10 -0
- package/generated/internal/class/mutation-observer-singleton.js +64 -0
- package/generated/internal/class/navigation-path.d.ts +15 -0
- package/generated/internal/class/navigation-path.js +84 -0
- package/generated/internal/class/navigation-view.d.ts +8 -0
- package/generated/internal/class/navigation-view.js +72 -0
- package/generated/internal/class/resize-observer-singleton.d.ts +7 -0
- package/generated/internal/class/resize-observer-singleton.js +22 -0
- 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 +5 -0
- package/generated/internal/decorators/custom-element.js +5 -0
- 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 +14 -0
- package/generated/internal/privateNamespace.js +168 -0
- package/generated/internal/utils/add.d.ts +1 -0
- package/generated/internal/utils/add.js +7 -0
- package/generated/internal/utils/cash/ancestors.d.ts +1 -0
- package/generated/internal/utils/cash/ancestors.js +27 -0
- package/generated/internal/utils/cash/index.d.ts +24 -0
- package/generated/internal/utils/cash/index.js +27 -0
- package/generated/internal/utils/cash/next-all.d.ts +1 -0
- package/generated/internal/utils/cash/next-all.js +10 -0
- package/generated/internal/utils/cash/next.d.ts +1 -0
- package/generated/internal/utils/cash/next.js +9 -0
- package/generated/internal/utils/cash/prev-all.d.ts +1 -0
- package/generated/internal/utils/cash/prev-all.js +10 -0
- package/generated/internal/utils/cash/prev.d.ts +1 -0
- package/generated/internal/utils/cash/prev.js +9 -0
- package/generated/internal/utils/cash/prop.d.ts +18 -0
- package/generated/internal/utils/cash/prop.js +30 -0
- package/generated/internal/utils/cash/siblings.d.ts +1 -0
- package/generated/internal/utils/cash/siblings.js +10 -0
- package/generated/internal/utils/clamp.d.ts +1 -0
- package/generated/internal/utils/clamp.js +4 -0
- package/generated/internal/utils/compare-big-decimals.d.ts +1 -0
- package/generated/internal/utils/compare-big-decimals.js +80 -0
- package/generated/internal/utils/css-time.d.ts +1 -0
- package/generated/internal/utils/css-time.js +3 -0
- package/generated/internal/utils/debounce.d.ts +1 -0
- package/generated/internal/utils/debounce.js +13 -0
- package/generated/internal/utils/define-translations.d.ts +1 -0
- package/generated/internal/utils/define-translations.js +3 -0
- 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 +41 -0
- package/generated/internal/utils/frame.d.ts +1 -0
- package/generated/internal/utils/frame.js +6 -0
- package/generated/internal/utils/index.d.ts +20 -1
- package/generated/internal/utils/index.js +23 -1
- 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.d.ts +1 -1
- package/generated/internal/utils/kebab-case.js +6 -9
- package/generated/internal/utils/list-active.d.ts +7 -0
- package/generated/internal/utils/list-active.js +83 -0
- package/generated/internal/utils/microtask.d.ts +1 -0
- package/generated/internal/utils/microtask.js +3 -0
- package/generated/internal/utils/onoff.d.ts +45 -0
- package/generated/internal/utils/onoff.js +31 -0
- package/generated/internal/utils/set.d.ts +1 -0
- package/generated/internal/utils/set.js +7 -0
- package/generated/internal/utils/sleep.d.ts +1 -0
- package/generated/internal/utils/sleep.js +3 -0
- package/generated/internal/utils/slow-hide-show.d.ts +1 -0
- package/generated/internal/utils/slow-hide-show.js +16 -0
- package/generated/internal/utils/timeout.d.ts +5 -0
- package/generated/internal/utils/timeout.js +16 -0
- package/generated/internal/utils/touch-glass.d.ts +7 -0
- package/generated/internal/utils/touch-glass.js +19 -0
- 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 +45 -0
- package/generated/namespace-browser/base.js +115 -0
- package/generated/namespace-browser/event.d.ts +10 -0
- package/generated/namespace-browser/event.js +1 -0
- package/generated/namespace-browser/index.d.ts +7 -0
- package/generated/namespace-browser/index.js +1 -0
- package/generated/snapshot/index.d.ts +9 -0
- package/generated/snapshot/index.js +60 -0
- 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/package.json +49 -8
- package/scss/_base.scss +5 -0
- package/scss/_components.scss +90 -0
- package/scss/_final.scss +1 -0
- package/scss/_functions.scss +31 -0
- package/scss/_maps.scss +293 -0
- package/scss/_mixins.scss +7 -0
- package/scss/_placeholders.scss +3 -0
- package/scss/_transitions.scss +32 -0
- package/scss/_utils.scss +9 -0
- package/scss/_vars.scss +68 -0
- package/scss/base/_layout.scss +66 -0
- package/scss/base/_reboot.scss +191 -0
- package/scss/base/_root.scss +415 -0
- package/scss/colors/_index.scss +881 -0
- package/scss/components/_alert-dialog.scss +111 -0
- package/scss/components/_body-view.scss +17 -0
- package/scss/components/_bordered-button.scss +59 -0
- package/scss/components/_bordered-prominent-button.scss +65 -0
- package/scss/components/_borderless-button.scss +45 -0
- package/scss/components/_confirmation-dialog.scss +102 -0
- package/scss/components/_content-unavailable.scss +57 -0
- package/scss/components/_date-picker.scss +30 -0
- package/scss/components/_detail-placeholder.scss +153 -0
- package/scss/components/_disclosure-group.scss +179 -0
- package/scss/components/_fine-tooltip.scss +84 -0
- package/scss/components/_form-view.scss +234 -0
- package/scss/components/_full-screen.scss +15 -0
- package/scss/components/_glass-button.scss +61 -0
- package/scss/components/_glass-prominent-button.scss +71 -0
- package/scss/components/_group-box.scss +27 -0
- package/scss/components/_h-divider.scss +13 -0
- package/scss/components/_h-flex-stack.scss +23 -0
- package/scss/components/_h-stack.scss +28 -0
- package/scss/components/_image-view.scss +20 -0
- package/scss/components/_index.scss +272 -0
- package/scss/components/_label-view copy.scss.txt +420 -0
- package/scss/components/_label-view.scss +371 -0
- package/scss/components/_label-view.scss.txt +536 -0
- package/scss/components/_labeled-content.scss +75 -0
- package/scss/components/_list-view.scss +270 -0
- package/scss/components/_menu-view.scss +223 -0
- package/scss/components/_navigation-large-title.scss +44 -0
- package/scss/components/_navigation-split-view.scss +424 -0
- package/scss/components/_navigation-stack.scss +11 -0
- package/scss/components/_navigation-title.scss +10 -0
- package/scss/components/_picker-view.scss +329 -0
- package/scss/components/_plain-button.scss +19 -0
- package/scss/components/_progress-view.scss +98 -0
- package/scss/components/_scroll-view-proxy.scss +81 -0
- package/scss/components/_scroll-view-toolbars.scss +132 -0
- package/scss/components/_scroll-view.scss +134 -0
- package/scss/components/_search-view.scss +23 -0
- package/scss/components/_section-view.scss +120 -0
- package/scss/components/_sheet-view.scss +103 -0
- package/scss/components/_sidebar-toggle.scss +121 -0
- package/scss/components/_sidebar-view.scss +53 -0
- package/scss/components/_sticky-container.scss +42 -0
- package/scss/components/_tab-bar.scss +268 -0
- package/scss/components/_tab-item.scss +25 -0
- package/scss/components/_tab-view.scss +320 -0
- package/scss/components/_table-column.scss +54 -0
- package/scss/components/_table-row.scss +240 -0
- package/scss/components/_table-view.scss +232 -0
- package/scss/components/_text-field.scss +57 -0
- package/scss/components/_text-view.scss +57 -0
- package/scss/components/_toggle-view.scss +161 -0
- package/scss/components/_tool-bar-item-group.scss +48 -0
- package/scss/components/_tool-bar-item.scss +97 -0
- package/scss/components/_tool-bar.scss +153 -0
- package/scss/components/_v-divider.scss +13 -0
- package/scss/components/_v-flex-stack.scss +29 -0
- package/scss/components/_v-keyboard.scss +14 -0
- package/scss/components/_v-stack.scss +24 -0
- package/scss/final/_touch-glass.scss +98 -0
- package/scss/index.scss +18 -1
- package/scss/mixins/_button.scss +44 -0
- package/scss/mixins/_color.scss +16 -0
- package/scss/mixins/_dialog.scss +89 -0
- package/scss/mixins/_index.scss +473 -0
- package/scss/placeholders/_buttons.scss +118 -0
- package/scss/placeholders/_lists.scss +622 -0
- package/scss/transitions/_alert-dialog.scss +18 -0
- package/scss/transitions/_bwd.navbar.scss +19 -0
- package/scss/transitions/_bwd.scss +39 -0
- package/scss/transitions/_confirmation-dialog.scss +27 -0
- package/scss/transitions/_disclosure-group.scss +35 -0
- package/scss/transitions/_fine-tooltip.scss +21 -0
- package/scss/transitions/_fwd.navbar.scss +41 -0
- package/scss/transitions/_fwd.scss +24 -0
- package/scss/transitions/_glass-button.scss +12 -0
- package/scss/transitions/_glass-prominent-button.scss +12 -0
- package/scss/transitions/_index.scss +74 -0
- package/scss/transitions/_menu-view.scss +28 -0
- package/scss/transitions/_navigation-split-view.scss +23 -0
- package/scss/transitions/_progress-view.scss +23 -0
- package/scss/transitions/_sheet-view.scss +30 -0
- package/scss/transitions/_sidebar-view.scss +36 -0
- package/scss/transitions/_tab-bar.scss +20 -0
- package/scss/utils/_frame.scss +103 -0
- package/scss/utils/_index.scss +54 -0
- package/scss/utils/_scroll-view.scss +14 -0
- package/scss/utils/_spacing.scss +25 -0
- package/scss/utils/_stacks.scss +112 -0
- package/web-components.css-data/en.json +28 -0
- package/web-components.html-data/en.json +2612 -0
- package/generated/internal/snapshot.d.ts +0 -5
- package/generated/internal/snapshot.js +0 -23
- package/generated/styles.css +0 -1
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
+
import { FormAssociatedBase, getInternals } from '../internal/class/form-associated-base';
|
|
4
|
+
import { MutationObserverSet } from '../internal/class/mutation-observer-set';
|
|
5
|
+
import { $, devFlags, kebabCase, onoff, touchGlass } from '../internal/utils';
|
|
6
|
+
import { queryMorph } from '../morphdom';
|
|
7
|
+
import { html } from '../tpl';
|
|
8
|
+
const toggleStyles = ['switch', 'button'];
|
|
9
|
+
/**
|
|
10
|
+
* @summary A control that switches between on and off states.
|
|
11
|
+
*
|
|
12
|
+
* @example <toggle-view label="Custom Label"></toggle-view> — Creates a toggle that displays a custom label
|
|
13
|
+
*
|
|
14
|
+
* @fires toggle:change — User toggled the control
|
|
15
|
+
*
|
|
16
|
+
* @slot label
|
|
17
|
+
* @slot {HTMLOptionElement[]} validity-options
|
|
18
|
+
*/
|
|
19
|
+
export class ToggleView extends FormAssociatedBase {
|
|
20
|
+
static get observedAttributes() {
|
|
21
|
+
return [
|
|
22
|
+
'label',
|
|
23
|
+
'name',
|
|
24
|
+
'value',
|
|
25
|
+
/**
|
|
26
|
+
* @type {boolean}
|
|
27
|
+
*/
|
|
28
|
+
'is-on',
|
|
29
|
+
/**
|
|
30
|
+
* @type {boolean}
|
|
31
|
+
*/
|
|
32
|
+
'required',
|
|
33
|
+
/**
|
|
34
|
+
* @type {boolean}
|
|
35
|
+
*/
|
|
36
|
+
'disabled',
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
static #template;
|
|
40
|
+
static get template() {
|
|
41
|
+
return (this.#template ??= $(html `<label part="root toggle-stack">
|
|
42
|
+
<div part="root toggle-label-stack">
|
|
43
|
+
<slot name="label"></slot>
|
|
44
|
+
</div>
|
|
45
|
+
<div part="root toggle-input-stack">
|
|
46
|
+
<div part="root toggle-track" tabindex="0"></div>
|
|
47
|
+
</div>
|
|
48
|
+
<slot name="validity-options" hidden></slot>
|
|
49
|
+
</label>`));
|
|
50
|
+
}
|
|
51
|
+
#renderValidityMsgs = (entries) => {
|
|
52
|
+
if (devFlags.debug)
|
|
53
|
+
console.debug(`${_a.name} ⚡️ mutation`);
|
|
54
|
+
this.setValidity(this.validity, this.validationMessage);
|
|
55
|
+
};
|
|
56
|
+
#shadowRoot;
|
|
57
|
+
#customValidity = '';
|
|
58
|
+
#slots = new Map();
|
|
59
|
+
#validityObservers = new MutationObserverSet(this.#renderValidityMsgs);
|
|
60
|
+
#track;
|
|
61
|
+
#value = 'on';
|
|
62
|
+
#isOn = false;
|
|
63
|
+
#didDrag = false;
|
|
64
|
+
#trackWidth = 0;
|
|
65
|
+
#dotSize = 0;
|
|
66
|
+
get #trackMinX() {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
get #trackMaxX() {
|
|
70
|
+
return this.#trackWidth - this.#dotSize;
|
|
71
|
+
}
|
|
72
|
+
#handleMeasure = ([{ target, borderBoxSize }]) => {
|
|
73
|
+
if (devFlags.debug)
|
|
74
|
+
console.debug(`${_a.name} ⚡️ measure`);
|
|
75
|
+
if (!(target instanceof HTMLElement))
|
|
76
|
+
return;
|
|
77
|
+
this.#trackWidth = borderBoxSize.at(0)?.inlineSize ?? 0;
|
|
78
|
+
this.#dotSize = borderBoxSize.at(0)?.blockSize ?? 0;
|
|
79
|
+
};
|
|
80
|
+
#resizeObserver = new ResizeObserver(this.#handleMeasure);
|
|
81
|
+
#dragOffsetX = 0;
|
|
82
|
+
get #isDragging() {
|
|
83
|
+
return '0ms' === this.#track?.style.getPropertyValue('--toggle--dot-transition-duration');
|
|
84
|
+
}
|
|
85
|
+
get #internals() {
|
|
86
|
+
return getInternals(this);
|
|
87
|
+
}
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
91
|
+
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
92
|
+
for (const slot of this.#shadowRoot.querySelectorAll('slot'))
|
|
93
|
+
this.#slots?.set(slot.name, slot);
|
|
94
|
+
CleanupRegistry.register(this, () => {
|
|
95
|
+
this.#slots = new Map();
|
|
96
|
+
});
|
|
97
|
+
CleanupRegistry.unregister(this, 'validities');
|
|
98
|
+
CleanupRegistry.register(this, onoff('slotchange', this.#handleValiditiesSlotchange, this.#slots?.get('validity-options')).on(), 'validities');
|
|
99
|
+
this.#track = this.#shadowRoot.querySelector('[part*=toggle-track]') ?? undefined;
|
|
100
|
+
CleanupRegistry.register(this, onoff([{ types: 'focusin', listener: this.#handleFocusin }], this).on());
|
|
101
|
+
CleanupRegistry.register(this, onoff([
|
|
102
|
+
{ types: 'keydown', listener: this.#handleTrackKeydown },
|
|
103
|
+
{ types: 'click', listener: this.#handleTrackClick },
|
|
104
|
+
{ types: 'pointerdown', listener: this.#handleTrackPointerdown },
|
|
105
|
+
{ types: 'pointerup', listener: this.#handleTrackPointerup },
|
|
106
|
+
{ types: 'pointercancel', listener: this.#handleTrackPointercancel },
|
|
107
|
+
{ types: 'pointermove', listener: this.#handleTrackPointermove },
|
|
108
|
+
{ types: 'lostpointercapture', listener: this.#handleTrackPointercancel },
|
|
109
|
+
], this.#track).on());
|
|
110
|
+
CleanupRegistry.register(this, onoff([{ types: 'blur', listener: this.#handleWindowBlur }], self).on());
|
|
111
|
+
}
|
|
112
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
113
|
+
if (devFlags.debug)
|
|
114
|
+
console.debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
115
|
+
switch (name) {
|
|
116
|
+
case 'value':
|
|
117
|
+
this.value = String(newValue); // this.#input?.setAttribute('checked', newValue ?? '')
|
|
118
|
+
this.#sendValueToForm(false);
|
|
119
|
+
break;
|
|
120
|
+
case 'is-on':
|
|
121
|
+
this.isOn = newValue !== null; // this.#input?.setAttribute('checked', newValue ?? '')
|
|
122
|
+
this.#sendValueToForm(false);
|
|
123
|
+
break;
|
|
124
|
+
case 'required':
|
|
125
|
+
// this.#input?.setAttribute(name, newValue ?? '')
|
|
126
|
+
this.#sendValueToForm(false);
|
|
127
|
+
break;
|
|
128
|
+
case 'name':
|
|
129
|
+
this.#sendValueToForm(false);
|
|
130
|
+
break;
|
|
131
|
+
case 'label':
|
|
132
|
+
queryMorph('[slot=label]', html `<label-view slot="label">${newValue ? html `<span>${newValue}</span>` : null}</label-view>`, this);
|
|
133
|
+
break;
|
|
134
|
+
case 'disabled':
|
|
135
|
+
for (const el of this.#shadowRoot.querySelectorAll('input'))
|
|
136
|
+
el.toggleAttribute('disabled', !newValue);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
disconnectedCallback() {
|
|
141
|
+
super.disconnectedCallback();
|
|
142
|
+
if (this.#track)
|
|
143
|
+
this.#resizeObserver.unobserve(this.#track);
|
|
144
|
+
this.#validityObservers.unobserveAll();
|
|
145
|
+
}
|
|
146
|
+
connectedCallback() {
|
|
147
|
+
super.connectedCallback();
|
|
148
|
+
if (this.hasAttribute('is-on'))
|
|
149
|
+
this.isOn = this.hasAttribute('is-on');
|
|
150
|
+
this.#sendValueToForm(false);
|
|
151
|
+
if (this.#track)
|
|
152
|
+
this.#resizeObserver.observe(this.#track);
|
|
153
|
+
CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t, ({ clientX, clientY }) => this.#measurePointerIsOverDot(clientX, clientY) ?? false), this).on());
|
|
154
|
+
}
|
|
155
|
+
get toggleStyle() {
|
|
156
|
+
return toggleStyles.includes(this.getAttribute('toggle-style') ?? '') ? this.getAttribute('toggle-style') : 'switch';
|
|
157
|
+
}
|
|
158
|
+
get isOn() {
|
|
159
|
+
return this.#isOn;
|
|
160
|
+
}
|
|
161
|
+
set isOn(v) {
|
|
162
|
+
this.#isOn = Boolean(v);
|
|
163
|
+
this.#value = this.#isOn ? (this.getAttribute('value') ?? 'on') : null;
|
|
164
|
+
this.ariaChecked = `${this.#isOn}`;
|
|
165
|
+
}
|
|
166
|
+
#handleValiditiesSlotchange = ({ type, target: slot }) => {
|
|
167
|
+
if (devFlags.debug)
|
|
168
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
169
|
+
if (!(slot instanceof HTMLSlotElement))
|
|
170
|
+
return;
|
|
171
|
+
const assigned = slot.assignedElements();
|
|
172
|
+
this.#validityObservers.syncObservations(assigned, ['value', 'label']);
|
|
173
|
+
this.#renderValidityMsgs([]);
|
|
174
|
+
};
|
|
175
|
+
#handleFocusin = ({ type, target }) => {
|
|
176
|
+
if (devFlags.debug)
|
|
177
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
178
|
+
if (target === this)
|
|
179
|
+
this.#track?.focus();
|
|
180
|
+
};
|
|
181
|
+
#handleTrackClick = ({ type }) => {
|
|
182
|
+
if (devFlags.debug)
|
|
183
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
184
|
+
if (this.#didDrag)
|
|
185
|
+
return (this.#didDrag = false);
|
|
186
|
+
this.#applyIsOnWithFlip(!this.isOn);
|
|
187
|
+
this.#sendValueToForm(true);
|
|
188
|
+
};
|
|
189
|
+
#measurePointerIsOverDot = (clientX, clientY) => {
|
|
190
|
+
if (!this.#track)
|
|
191
|
+
return;
|
|
192
|
+
const { left, top, height } = this.#track.getBoundingClientRect();
|
|
193
|
+
const dotLeft = left + parseFloat(self.getComputedStyle(this.#track, '::before').left);
|
|
194
|
+
const dotCenterX = dotLeft + this.#dotSize / 2;
|
|
195
|
+
const dotCenterY = top + height / 2;
|
|
196
|
+
return Math.hypot(clientX - dotCenterX, clientY - dotCenterY) <= this.#dotSize / 2;
|
|
197
|
+
};
|
|
198
|
+
get #baseX() {
|
|
199
|
+
return this.isOn ? this.#trackMaxX : this.#trackMinX;
|
|
200
|
+
}
|
|
201
|
+
#handleTrackPointerdown = ({ type, pointerId, clientX, clientY }) => {
|
|
202
|
+
if (devFlags.debug)
|
|
203
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
204
|
+
if (!this.#track)
|
|
205
|
+
return;
|
|
206
|
+
if (!this.#measurePointerIsOverDot(clientX, clientY))
|
|
207
|
+
return; // ignore taps elsewhere on the track
|
|
208
|
+
this.#didDrag = true; // dot was engaged — settle() will own the outcome, click must be swallowed
|
|
209
|
+
const currentDelta = parseFloat(self.getComputedStyle(this.#track).getPropertyValue('--toggle--dot-translate-x')) || 0, currentAbsoluteX = this.#baseX + currentDelta;
|
|
210
|
+
this.#dragOffsetX = clientX - this.#track.getBoundingClientRect().left - currentAbsoluteX;
|
|
211
|
+
this.#track.style.setProperty('--toggle--dot-transition-duration', '0ms');
|
|
212
|
+
this.#track.setPointerCapture(pointerId);
|
|
213
|
+
};
|
|
214
|
+
#handleTrackPointermove = ({ type, clientX }) => {
|
|
215
|
+
if (devFlags.debug)
|
|
216
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
217
|
+
if (!this.#isDragging)
|
|
218
|
+
return;
|
|
219
|
+
this.#updateFromEvent(clientX);
|
|
220
|
+
};
|
|
221
|
+
#handleTrackPointerup = ({ type, pointerId }) => {
|
|
222
|
+
if (devFlags.debug)
|
|
223
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
224
|
+
if (!this.#isDragging)
|
|
225
|
+
return; // pointerdown never engaged (missed the dot) — plain click, nothing to settle
|
|
226
|
+
this.#track?.style.removeProperty('--toggle--dot-transition-duration');
|
|
227
|
+
this.#track?.releasePointerCapture(pointerId);
|
|
228
|
+
this.#settle();
|
|
229
|
+
};
|
|
230
|
+
#handleTrackPointercancel = ({ type }) => {
|
|
231
|
+
if (devFlags.debug)
|
|
232
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
233
|
+
if (!this.#isDragging)
|
|
234
|
+
return; // already settled via pointerup, or nothing to settle
|
|
235
|
+
this.#track?.style.removeProperty('--toggle--dot-transition-duration');
|
|
236
|
+
this.#settle();
|
|
237
|
+
};
|
|
238
|
+
#handleWindowBlur = () => {
|
|
239
|
+
if (!this.#isDragging)
|
|
240
|
+
return;
|
|
241
|
+
this.#track?.style.removeProperty('--toggle--dot-transition-duration');
|
|
242
|
+
this.#settle();
|
|
243
|
+
};
|
|
244
|
+
#updateFromEvent = (clientX) => {
|
|
245
|
+
if (!this.#track)
|
|
246
|
+
return;
|
|
247
|
+
const { left } = this.#track.getBoundingClientRect();
|
|
248
|
+
const scaleShiftStart = this.#isOn ? 5 : 0, scaleShiftEnd = this.#isOn ? 0 : 4;
|
|
249
|
+
const absoluteX = Math.min(Math.max(clientX - left - this.#dragOffsetX, this.#trackMinX + scaleShiftStart), this.#trackMaxX - scaleShiftEnd);
|
|
250
|
+
this.#track.style.setProperty('--toggle--dot-translate-x', `${Math.round(absoluteX - this.#baseX)}px`);
|
|
251
|
+
};
|
|
252
|
+
#settle = () => {
|
|
253
|
+
if (!this.#track)
|
|
254
|
+
return;
|
|
255
|
+
const deltaX = parseFloat(self.getComputedStyle(this.#track).getPropertyValue('--toggle--dot-translate-x')) || 0;
|
|
256
|
+
const absoluteX = this.#baseX + deltaX;
|
|
257
|
+
const nextIsOn = absoluteX > this.#trackMaxX / 2;
|
|
258
|
+
if (nextIsOn === this.isOn)
|
|
259
|
+
return this.#track.style.removeProperty('--toggle--dot-translate-x'); // pure transform animation back to rest, inset untouched
|
|
260
|
+
this.#applyIsOnWithFlip(nextIsOn);
|
|
261
|
+
this.#sendValueToForm(true);
|
|
262
|
+
};
|
|
263
|
+
#handleTrackKeydown = (evt) => {
|
|
264
|
+
if (devFlags.debug)
|
|
265
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
266
|
+
if (' ' !== evt.key)
|
|
267
|
+
return;
|
|
268
|
+
evt.preventDefault();
|
|
269
|
+
this.#applyIsOnWithFlip(!this.isOn);
|
|
270
|
+
this.#sendValueToForm(true);
|
|
271
|
+
};
|
|
272
|
+
#applyIsOnWithFlip = (nextIsOn) => {
|
|
273
|
+
if (!this.#track || nextIsOn === this.isOn)
|
|
274
|
+
return;
|
|
275
|
+
// capture current visual position under the OLD base, before flipping state
|
|
276
|
+
const deltaX = parseFloat(self.getComputedStyle(this.#track).getPropertyValue('--toggle--dot-translate-x')) || 0, oldAbsoluteX = this.#baseX + deltaX;
|
|
277
|
+
this.isOn = nextIsOn; // changes --toggle--dot-inset-inline-start/-end via aria-checked
|
|
278
|
+
const compensationX = oldAbsoluteX - this.#baseX; // baseX now reflects the NEW state
|
|
279
|
+
// make inset + transform jump together, instantly, so nothing is visibly out of sync
|
|
280
|
+
this.#track.style.setProperty('--toggle--dot-transition-duration', '0ms');
|
|
281
|
+
this.#track.style.setProperty('--toggle--dot-translate-x', `${Math.round(compensationX)}px`);
|
|
282
|
+
void this.#track.offsetWidth; // force reflow so the instant jump is committed before re-enabling transitions
|
|
283
|
+
this.#track.style.removeProperty('--toggle--dot-transition-duration');
|
|
284
|
+
self.requestAnimationFrame(() => {
|
|
285
|
+
this.#track?.style.removeProperty('--toggle--dot-translate-x'); // only transform animates from here — single source of motion
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
#sendValueToForm = (dispatchEvent = true) => {
|
|
289
|
+
// input.value has already been updated/synced !!
|
|
290
|
+
if (this.matches(':disabled'))
|
|
291
|
+
return this.setValidity({});
|
|
292
|
+
if (this.hasAttribute('required') && !this.isOn) {
|
|
293
|
+
this.setValidity({ valueMissing: true });
|
|
294
|
+
}
|
|
295
|
+
else
|
|
296
|
+
this.setValidity({});
|
|
297
|
+
const entries = new FormData();
|
|
298
|
+
if (this.value)
|
|
299
|
+
entries.append(this.name, this.value);
|
|
300
|
+
this.#internals.setFormValue(entries);
|
|
301
|
+
if (dispatchEvent)
|
|
302
|
+
this.dispatchEvent(new CustomEvent('toggle:change', { detail: { value: this.value, isOn: this.isOn }, bubbles: true, composed: true }));
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Form participation property
|
|
306
|
+
*/
|
|
307
|
+
get name() {
|
|
308
|
+
return this.getAttribute('name') ?? this.getAttribute('label') ?? this.querySelector(':scope>[slot=label]')?.textContent ?? '';
|
|
309
|
+
}
|
|
310
|
+
get value() {
|
|
311
|
+
return this.#value;
|
|
312
|
+
}
|
|
313
|
+
set value(v) {
|
|
314
|
+
this.#value = this.isOn ? String(v) : null;
|
|
315
|
+
}
|
|
316
|
+
setValidity = (flags, message, anchor) => {
|
|
317
|
+
// let msg
|
|
318
|
+
// if (message)
|
|
319
|
+
for (const k in flags) {
|
|
320
|
+
const key = k; // ✅ type-safe cast
|
|
321
|
+
if (true !== flags[key])
|
|
322
|
+
continue;
|
|
323
|
+
for (const el of this.#slots?.get('validity-options')?.assignedElements({ flatten: true }) ?? []) {
|
|
324
|
+
if (!el.matches('option'))
|
|
325
|
+
continue;
|
|
326
|
+
const { label, value } = el;
|
|
327
|
+
if (`${kebabCase(key)}` === value) {
|
|
328
|
+
message = label;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
else if (`${kebabCase(key)}:${message}` === value) {
|
|
332
|
+
message = label;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (!message)
|
|
338
|
+
for (const k in flags) {
|
|
339
|
+
const key = k; // ✅ type-safe cast
|
|
340
|
+
if (true !== flags[key])
|
|
341
|
+
continue;
|
|
342
|
+
message = kebabCase(key);
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (devFlags.debug)
|
|
346
|
+
console.debug(`${_a.name} ⚡️ validity-change`);
|
|
347
|
+
return this.#internals.setValidity(flags, this.#customValidity || message, anchor ?? this.#track);
|
|
348
|
+
};
|
|
349
|
+
setCustomValidity = (message) => {
|
|
350
|
+
this.#customValidity = message;
|
|
351
|
+
if (this.#customValidity)
|
|
352
|
+
this.#internals.setValidity({ ...this.#internals.validity, customError: true }, message);
|
|
353
|
+
else
|
|
354
|
+
this.#sendValueToForm(false);
|
|
355
|
+
};
|
|
356
|
+
formStateRestoreCallback(state, reason) {
|
|
357
|
+
this.value = state;
|
|
358
|
+
}
|
|
359
|
+
formAssociatedCallback(form) {
|
|
360
|
+
this.#sendValueToForm(false);
|
|
361
|
+
}
|
|
362
|
+
formDisabledCallback(disabled) {
|
|
363
|
+
for (const el of this.#shadowRoot.querySelectorAll('input'))
|
|
364
|
+
el.toggleAttribute('disabled', !disabled);
|
|
365
|
+
}
|
|
366
|
+
formResetCallback() {
|
|
367
|
+
this.value = '';
|
|
368
|
+
this.#sendValueToForm(false);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
_a = ToggleView;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary A container view that groups items together in the toolbar or navigation bar.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ToolBarItemGroup extends HTMLElement {
|
|
5
|
+
constructor();
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'tool-bar-item-group': ToolBarItemGroup;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var ToolBarItemGroup_1;
|
|
8
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
9
|
+
import { adaptiveSlot } from '../internal/decorators';
|
|
10
|
+
import { devFlags } from '../internal/utils';
|
|
11
|
+
/**
|
|
12
|
+
* @summary A container view that groups items together in the toolbar or navigation bar.
|
|
13
|
+
*/
|
|
14
|
+
let ToolBarItemGroup = ToolBarItemGroup_1 = class ToolBarItemGroup extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
if (devFlags.debug)
|
|
20
|
+
console.debug(`${ToolBarItemGroup_1.name} ⚡️ connect`);
|
|
21
|
+
}
|
|
22
|
+
disconnectedCallback() {
|
|
23
|
+
if (devFlags.debug)
|
|
24
|
+
console.debug(`${ToolBarItemGroup_1.name} ⚡️ disconnect`);
|
|
25
|
+
CleanupRegistry.unregister(this);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
ToolBarItemGroup = ToolBarItemGroup_1 = __decorate([
|
|
29
|
+
adaptiveSlot()
|
|
30
|
+
], ToolBarItemGroup);
|
|
31
|
+
export { ToolBarItemGroup };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary A view placed in the toolbar or navigation bar.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ToolBarItem extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static get observedAttributes(): string[];
|
|
7
|
+
constructor();
|
|
8
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'tool-bar-item': ToolBarItem;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var ToolBarItem_1;
|
|
8
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
9
|
+
import { adaptiveSlot } from '../internal/decorators';
|
|
10
|
+
import { devFlags, ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
|
|
11
|
+
import { Snapshot } from '../snapshot';
|
|
12
|
+
/**
|
|
13
|
+
* @summary A view placed in the toolbar or navigation bar.
|
|
14
|
+
*/
|
|
15
|
+
let ToolBarItem = ToolBarItem_1 = class ToolBarItem extends HTMLElement {
|
|
16
|
+
static get observedAttributes() {
|
|
17
|
+
return ['slot', 'data-previous-slot', 'title-key'];
|
|
18
|
+
}
|
|
19
|
+
#mutationObserver;
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
24
|
+
if (devFlags.debug)
|
|
25
|
+
console.debug(`${ToolBarItem_1.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
26
|
+
switch (name) {
|
|
27
|
+
case 'slot':
|
|
28
|
+
case 'data-previous-slot':
|
|
29
|
+
case 'title-key': {
|
|
30
|
+
this.#mutationObserver?.disconnect();
|
|
31
|
+
const role = this.getAttribute('data-previous-slot') ?? this.getAttribute('slot') ?? '', tKey = this.getAttribute('title-key');
|
|
32
|
+
if (['confirmation-action', 'cancellation-action'].includes(role))
|
|
33
|
+
Snapshot.waitReady.then(() => {
|
|
34
|
+
ensurePlaceholder(this.querySelector(':scope>button:not(:has(> :not([slot])))'), role, tKey, Snapshot.config);
|
|
35
|
+
this.#mutationObserver = new MutationObserver((mutations) => {
|
|
36
|
+
for (const { target } of mutations)
|
|
37
|
+
if (target instanceof HTMLElement)
|
|
38
|
+
ensurePlaceholder(this.querySelector(':scope>button:not(:has(> :not([slot])))'), role, tKey, Snapshot.config);
|
|
39
|
+
});
|
|
40
|
+
this.#mutationObserver.observe(this, {
|
|
41
|
+
childList: true,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
disconnectedCallback() {
|
|
49
|
+
if (devFlags.debug)
|
|
50
|
+
console.debug(`${ToolBarItem_1.name} ⚡️ disconnect`);
|
|
51
|
+
this.#mutationObserver?.disconnect();
|
|
52
|
+
CleanupRegistry.unregister(this);
|
|
53
|
+
}
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
if (devFlags.debug)
|
|
56
|
+
console.debug(`${ToolBarItem_1.name} ⚡️ connect`);
|
|
57
|
+
CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t.closest('tool-bar-item-group') ?? t, ({ target }) => {
|
|
58
|
+
if (!(target instanceof HTMLElement))
|
|
59
|
+
return true;
|
|
60
|
+
if (target.closest('menu-view[open]'))
|
|
61
|
+
return false;
|
|
62
|
+
return true;
|
|
63
|
+
}), this).on());
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
ToolBarItem = ToolBarItem_1 = __decorate([
|
|
67
|
+
adaptiveSlot((el) => !el.closest('tool-bar-item-group'))
|
|
68
|
+
], ToolBarItem);
|
|
69
|
+
export { ToolBarItem };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary A list of items placed into the toolbar or navigation bar around your content.
|
|
3
|
+
*
|
|
4
|
+
* @slot cancellation-action — The item represents a cancellation action for a modal interface. Places the item in the leading edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
5
|
+
* @slot primary-action — The item represents a primary action. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
6
|
+
* @slot confirmation-action — The item represents a confirmation action for a modal interface. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
7
|
+
* @slot destructive-action — The item represents a destructive action for a modal interface. Places the item in the leading edge of the top bar and on the leading edge of the bottom bar when fine modal
|
|
8
|
+
* @slot top-bar-leading — Places the item in the leading edge of the top bar
|
|
9
|
+
* @slot top-bar-principal — Places the item in the middle of the top bar
|
|
10
|
+
* @slot top-bar-trailing — Places the item in the trailing edge of the top bar
|
|
11
|
+
* @slot bottom-bar-leading — Places the item in the leading edge of the bottom bar
|
|
12
|
+
* @slot bottom-bar-principal — Places the item in the middle of the bottom bar
|
|
13
|
+
* @slot bottom-bar-trailing — Places the item in the trailing edge of the bottom bar
|
|
14
|
+
*/
|
|
15
|
+
export declare class ToolBar extends HTMLElement {
|
|
16
|
+
#private;
|
|
17
|
+
static get template(): DocumentFragment;
|
|
18
|
+
constructor();
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
disconnectedCallback(): void;
|
|
21
|
+
}
|
|
22
|
+
declare global {
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'tool-bar': ToolBar;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ResizeObserverSingleton } from '../internal/class/resize-observer-singleton';
|
|
3
|
+
import { $, devFlags } from '../internal/utils';
|
|
4
|
+
import { html } from '../tpl';
|
|
5
|
+
const observers = new ResizeObserverSingleton();
|
|
6
|
+
/**
|
|
7
|
+
* @summary A list of items placed into the toolbar or navigation bar around your content.
|
|
8
|
+
*
|
|
9
|
+
* @slot cancellation-action — The item represents a cancellation action for a modal interface. Places the item in the leading edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
10
|
+
* @slot primary-action — The item represents a primary action. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
11
|
+
* @slot confirmation-action — The item represents a confirmation action for a modal interface. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
12
|
+
* @slot destructive-action — The item represents a destructive action for a modal interface. Places the item in the leading edge of the top bar and on the leading edge of the bottom bar when fine modal
|
|
13
|
+
* @slot top-bar-leading — Places the item in the leading edge of the top bar
|
|
14
|
+
* @slot top-bar-principal — Places the item in the middle of the top bar
|
|
15
|
+
* @slot top-bar-trailing — Places the item in the trailing edge of the top bar
|
|
16
|
+
* @slot bottom-bar-leading — Places the item in the leading edge of the bottom bar
|
|
17
|
+
* @slot bottom-bar-principal — Places the item in the middle of the bottom bar
|
|
18
|
+
* @slot bottom-bar-trailing — Places the item in the trailing edge of the bottom bar
|
|
19
|
+
*/
|
|
20
|
+
export class ToolBar extends HTMLElement {
|
|
21
|
+
static #template;
|
|
22
|
+
static get template() {
|
|
23
|
+
// <!--exportparts="toolbar-leading-stack,toolbar-principal-stack,toolbar-trailing-stack"-->
|
|
24
|
+
return (this.#template ??= $(html `<div part="root top-bar">
|
|
25
|
+
<div part="root toolbar-leading-stack">
|
|
26
|
+
<slot name="cancellation-action"></slot>
|
|
27
|
+
<slot name="destructive-action"></slot>
|
|
28
|
+
<slot name="top-bar-leading"></slot>
|
|
29
|
+
</div>
|
|
30
|
+
<div part="root toolbar-principal-stack">
|
|
31
|
+
<slot name="top-bar-principal"></slot>
|
|
32
|
+
</div>
|
|
33
|
+
<div part="root toolbar-trailing-stack">
|
|
34
|
+
<slot name="top-bar-trailing"></slot>
|
|
35
|
+
<slot name="primary-action"></slot>
|
|
36
|
+
<slot name="confirmation-action"></slot>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div part="root bottom-bar">
|
|
40
|
+
<div part="root toolbar-leading-stack">
|
|
41
|
+
<slot name="bottom-bar-leading"></slot>
|
|
42
|
+
</div>
|
|
43
|
+
<div part="root toolbar-principal-stack">
|
|
44
|
+
<slot name="bottom-bar-principal"></slot>
|
|
45
|
+
</div>
|
|
46
|
+
<div part="root toolbar-trailing-stack">
|
|
47
|
+
<slot name="bottom-bar-trailing"></slot>
|
|
48
|
+
</div>
|
|
49
|
+
</div>`));
|
|
50
|
+
}
|
|
51
|
+
#shadowRoot;
|
|
52
|
+
get #scrollView() {
|
|
53
|
+
return this.parentElement?.querySelector(':scope>scroll-view') ?? undefined; //this.previousElementSibling ?? undefined
|
|
54
|
+
}
|
|
55
|
+
constructor() {
|
|
56
|
+
super();
|
|
57
|
+
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
58
|
+
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
59
|
+
}
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
if (devFlags.debug)
|
|
62
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
63
|
+
// NOTE: wait for config
|
|
64
|
+
// Snapshot.waitReady.then(() => {
|
|
65
|
+
for (const el of this.#shadowRoot.querySelectorAll(`[part*="toolbar-leading-stack"],[part*="toolbar-trailing-stack"]`))
|
|
66
|
+
observers.observe(el, this.#measureStacks.bind(this));
|
|
67
|
+
// })
|
|
68
|
+
}
|
|
69
|
+
disconnectedCallback() {
|
|
70
|
+
if (devFlags.debug)
|
|
71
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
72
|
+
observers.unobserve(this);
|
|
73
|
+
}
|
|
74
|
+
#measureStacks(entry) {
|
|
75
|
+
if (devFlags.debug)
|
|
76
|
+
console.debug(`${_a.name} ⚡️ measure`);
|
|
77
|
+
if (this.closest('[hidden]'))
|
|
78
|
+
return;
|
|
79
|
+
const leading = 'toolbar-leading-stack', trailing = 'toolbar-trailing-stack';
|
|
80
|
+
const parentMap = {
|
|
81
|
+
'top-bar': 'navbar',
|
|
82
|
+
'bottom-bar': 'toolbar', //'bottombar',
|
|
83
|
+
};
|
|
84
|
+
const { contentRect: { width }, target, } = entry;
|
|
85
|
+
const parentPart = target.parentElement?.part.contains('top-bar') ? 'top-bar' : target.parentElement?.part.contains('bottom-bar') ? 'bottom-bar' : null;
|
|
86
|
+
if (!parentPart)
|
|
87
|
+
return;
|
|
88
|
+
const side = target.part.contains(leading) ? 'inline-start' : target.part.contains(trailing) ? 'inline-end' : null;
|
|
89
|
+
if (!side)
|
|
90
|
+
return;
|
|
91
|
+
const prop = `--${parentMap[parentPart]}-padding-${side}`;
|
|
92
|
+
this.#scrollView?.style?.setProperty(prop, `${Math.round(width)}px`); // $.prop(prop, `${Math.round(width)}px`, this.#scrollView) //
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
_a = ToolBar;
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BUG: Safari on IOS reports inaccurate innerHeight (which is what we really want) on orientationchange.
|
|
3
|
+
* So we live with a pescy body-scrollbar that shows up on resize on desktops.
|
|
4
|
+
*
|
|
5
|
+
* @summary Required component, used to handle the virtual keyboard on touch devices.
|
|
6
|
+
*
|
|
7
|
+
* @attr {Inter} system-font — Prefers the "Inter" font family, if loaded.
|
|
8
|
+
*/
|
|
1
9
|
export declare class VKeyboard extends HTMLElement {
|
|
10
|
+
#private;
|
|
11
|
+
constructor();
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
set shouldKeyboardBeOpen(fn: () => boolean);
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'v-keyboard': VKeyboard;
|
|
19
|
+
}
|
|
2
20
|
}
|