@swiftwc/ui 0.0.0-dev.8 → 0.0.0-dev.80
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 +32 -59
- 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
|
@@ -0,0 +1,224 @@
|
|
|
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, renderLabel } from '../internal/utils';
|
|
6
|
+
const toggleStyles = ['switch', 'button'];
|
|
7
|
+
/**
|
|
8
|
+
* @slot label
|
|
9
|
+
* @slot validity-options
|
|
10
|
+
*/
|
|
11
|
+
export class ToggleView extends FormAssociatedBase {
|
|
12
|
+
// declare addEventListener: TypedEventTargetMethods<ToggleViewEventMap>['addEventListener']
|
|
13
|
+
// declare removeEventListener: TypedEventTargetMethods<ToggleViewEventMap>['removeEventListener']
|
|
14
|
+
static get observedAttributes() {
|
|
15
|
+
return ['label', 'name', 'value', 'is-on', 'keyboard-type', 'required', 'disabled'];
|
|
16
|
+
}
|
|
17
|
+
static #template;
|
|
18
|
+
static get template() {
|
|
19
|
+
return (this.#template ??= $(String.raw `
|
|
20
|
+
<label part="root toggle-stack">
|
|
21
|
+
<div part="root toggle-label-stack">
|
|
22
|
+
<slot name="label"></slot>
|
|
23
|
+
</div>
|
|
24
|
+
<div part="root toggle-input-stack">
|
|
25
|
+
<!--<input type="checkbox" part="root input toggle-form-input">-->
|
|
26
|
+
<div part="root toggle-form-input" tabindex="0"></div>
|
|
27
|
+
</div>
|
|
28
|
+
<slot name="validity-options" hidden></slot>
|
|
29
|
+
</label>`));
|
|
30
|
+
}
|
|
31
|
+
#renderValidityMsgs = (entries) => {
|
|
32
|
+
if (devFlags.debug)
|
|
33
|
+
console.debug(`${_a.name} ⚡️ mutation`);
|
|
34
|
+
this.setValidity(this.validity, this.validationMessage);
|
|
35
|
+
};
|
|
36
|
+
#shadowRoot;
|
|
37
|
+
#customValidity = '';
|
|
38
|
+
#slots = new Map();
|
|
39
|
+
#validityObservers = new MutationObserverSet(this.#renderValidityMsgs);
|
|
40
|
+
#input;
|
|
41
|
+
#value = 'on';
|
|
42
|
+
#isOn = false;
|
|
43
|
+
#connected = false;
|
|
44
|
+
get #internals() {
|
|
45
|
+
return getInternals(this);
|
|
46
|
+
}
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
50
|
+
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
51
|
+
for (const slot of this.#shadowRoot.querySelectorAll('slot'))
|
|
52
|
+
this.#slots?.set(slot.name, slot);
|
|
53
|
+
CleanupRegistry.register(this, () => {
|
|
54
|
+
this.#slots = new Map();
|
|
55
|
+
});
|
|
56
|
+
CleanupRegistry.unregister(this, 'validities');
|
|
57
|
+
CleanupRegistry.register(this, onoff('slotchange', this.#handleValiditiesSlotchange, this.#slots?.get('validity-options')).on(), 'validities');
|
|
58
|
+
this.#input = this.#shadowRoot.querySelector('[part*=toggle-form-input]') ?? undefined;
|
|
59
|
+
this.#input?.addEventListener('click', () => {
|
|
60
|
+
this.isOn = !this.isOn;
|
|
61
|
+
this.#sendValueToForm(this.#connected);
|
|
62
|
+
});
|
|
63
|
+
CleanupRegistry.register(this, onoff([{ types: 'focusin', listener: this.#handleFocusin }], this).on());
|
|
64
|
+
CleanupRegistry.register(this, onoff([{ types: 'keydown', listener: this.#handleInputKeydown }], this.#input).on());
|
|
65
|
+
// CleanupRegistry.register(this, onoff([{ types: 'input', listener: this.#handleInputInput }], this.#input).on())
|
|
66
|
+
}
|
|
67
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
68
|
+
if (devFlags.debug)
|
|
69
|
+
console.debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
70
|
+
switch (name) {
|
|
71
|
+
case 'value':
|
|
72
|
+
this.value = String(newValue); // this.#input?.setAttribute('checked', newValue ?? '')
|
|
73
|
+
this.#sendValueToForm(this.#connected);
|
|
74
|
+
break;
|
|
75
|
+
case 'is-on':
|
|
76
|
+
this.isOn = newValue !== null; // this.#input?.setAttribute('checked', newValue ?? '')
|
|
77
|
+
this.#sendValueToForm(this.#connected);
|
|
78
|
+
break;
|
|
79
|
+
case 'required':
|
|
80
|
+
// this.#input?.setAttribute(name, newValue ?? '')
|
|
81
|
+
this.#sendValueToForm(this.#connected);
|
|
82
|
+
break;
|
|
83
|
+
case 'name':
|
|
84
|
+
this.#sendValueToForm(this.#connected);
|
|
85
|
+
break;
|
|
86
|
+
case 'label':
|
|
87
|
+
renderLabel(':scope>label-view[slot=label]', `<label-view slot="label"><span></span></label-view>`, this, newValue);
|
|
88
|
+
break;
|
|
89
|
+
case 'disabled':
|
|
90
|
+
for (const el of this.#shadowRoot.querySelectorAll('input'))
|
|
91
|
+
el.toggleAttribute('disabled', !newValue);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
disconnectedCallback() {
|
|
96
|
+
super.disconnectedCallback();
|
|
97
|
+
this.#validityObservers.unobserveAll();
|
|
98
|
+
}
|
|
99
|
+
connectedCallback() {
|
|
100
|
+
super.connectedCallback();
|
|
101
|
+
// finally
|
|
102
|
+
// if (this.hasAttribute('value')) this.value = this.getAttribute('value') ?? ''
|
|
103
|
+
if (this.hasAttribute('is-on'))
|
|
104
|
+
this.isOn = this.hasAttribute('is-on');
|
|
105
|
+
this.#sendValueToForm(false);
|
|
106
|
+
this.#connected = true;
|
|
107
|
+
}
|
|
108
|
+
get toggleStyle() {
|
|
109
|
+
return toggleStyles.includes(this.getAttribute('toggle-style') ?? '') ? this.getAttribute('toggle-style') : 'switch';
|
|
110
|
+
}
|
|
111
|
+
get isOn() {
|
|
112
|
+
return this.#isOn;
|
|
113
|
+
}
|
|
114
|
+
set isOn(v) {
|
|
115
|
+
this.#isOn = Boolean(v);
|
|
116
|
+
this.#value = this.#isOn ? (this.getAttribute('value') ?? 'on') : null;
|
|
117
|
+
this.ariaChecked = `${this.#isOn}`;
|
|
118
|
+
}
|
|
119
|
+
#handleValiditiesSlotchange = ({ type, target: slot }) => {
|
|
120
|
+
if (devFlags.debug)
|
|
121
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
122
|
+
if (!(slot instanceof HTMLSlotElement))
|
|
123
|
+
return;
|
|
124
|
+
const assigned = slot.assignedElements();
|
|
125
|
+
this.#validityObservers.syncObservations(assigned, ['value', 'label']);
|
|
126
|
+
this.#renderValidityMsgs([]);
|
|
127
|
+
};
|
|
128
|
+
#handleFocusin = ({ type, target }) => {
|
|
129
|
+
if (devFlags.debug)
|
|
130
|
+
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
131
|
+
if (target === this)
|
|
132
|
+
this.#input?.focus();
|
|
133
|
+
};
|
|
134
|
+
#sendValueToForm = (dispatchEvent = true) => {
|
|
135
|
+
// input.value has already been updated/synced !!
|
|
136
|
+
if (this.matches(':disabled'))
|
|
137
|
+
return this.setValidity({});
|
|
138
|
+
if (this.hasAttribute('required') && !this.isOn) {
|
|
139
|
+
this.setValidity({ valueMissing: true });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.setValidity({});
|
|
143
|
+
}
|
|
144
|
+
const entries = new FormData();
|
|
145
|
+
if (this.value)
|
|
146
|
+
entries.append(this.name, this.value);
|
|
147
|
+
this.#internals.setFormValue(entries);
|
|
148
|
+
if (dispatchEvent)
|
|
149
|
+
this.dispatchEvent(new CustomEvent('toggle:change', { detail: { value: this.value, isOn: this.isOn }, bubbles: true, composed: true }));
|
|
150
|
+
};
|
|
151
|
+
#handleInputKeydown = (evt) => {
|
|
152
|
+
if (devFlags.debug)
|
|
153
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
154
|
+
this.isOn = !this.isOn;
|
|
155
|
+
this.#sendValueToForm();
|
|
156
|
+
};
|
|
157
|
+
#handleInputInput = (evt) => {
|
|
158
|
+
if (devFlags.debug)
|
|
159
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
160
|
+
this.#sendValueToForm();
|
|
161
|
+
};
|
|
162
|
+
// Optional: form participation properties
|
|
163
|
+
get name() {
|
|
164
|
+
return this.getAttribute('name') ?? this.getAttribute('label') ?? this.querySelector(':scope>[slot=label]')?.textContent ?? '';
|
|
165
|
+
}
|
|
166
|
+
get value() {
|
|
167
|
+
return this.#value;
|
|
168
|
+
}
|
|
169
|
+
set value(v) {
|
|
170
|
+
this.#value = this.isOn ? String(v) : null;
|
|
171
|
+
}
|
|
172
|
+
setValidity = (flags, message, anchor) => {
|
|
173
|
+
// let msg
|
|
174
|
+
// if (message)
|
|
175
|
+
for (const k in flags) {
|
|
176
|
+
const key = k; // ✅ type-safe cast
|
|
177
|
+
if (true !== flags[key])
|
|
178
|
+
continue;
|
|
179
|
+
for (const el of this.#slots?.get('validity-options')?.assignedElements({ flatten: true }) ?? []) {
|
|
180
|
+
if (!el.matches('option'))
|
|
181
|
+
continue;
|
|
182
|
+
const { label, value } = el;
|
|
183
|
+
if (`${kebabCase(key)}` === value) {
|
|
184
|
+
message = label;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
else if (`${kebabCase(key)}:${message}` === value) {
|
|
188
|
+
message = label;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (!message)
|
|
194
|
+
for (const k in flags) {
|
|
195
|
+
const key = k; // ✅ type-safe cast
|
|
196
|
+
if (true !== flags[key])
|
|
197
|
+
continue;
|
|
198
|
+
message = kebabCase(key);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
if (devFlags.debug)
|
|
202
|
+
console.debug(`${_a.name} ⚡️ validity-change`);
|
|
203
|
+
return this.#internals.setValidity(flags, this.#customValidity || message, anchor ?? this.#input);
|
|
204
|
+
};
|
|
205
|
+
setCustomValidity = (message) => {
|
|
206
|
+
this.#customValidity = message;
|
|
207
|
+
if (this.#customValidity)
|
|
208
|
+
this.#internals.setValidity({ ...this.#internals.validity, customError: true }, message);
|
|
209
|
+
else
|
|
210
|
+
this.#sendValueToForm(false);
|
|
211
|
+
};
|
|
212
|
+
formAssociatedCallback = (form) => {
|
|
213
|
+
this.#sendValueToForm();
|
|
214
|
+
};
|
|
215
|
+
formDisabledCallback = (disabled) => {
|
|
216
|
+
for (const el of this.#shadowRoot.querySelectorAll('input'))
|
|
217
|
+
el.toggleAttribute('disabled', !disabled);
|
|
218
|
+
};
|
|
219
|
+
formResetCallback = () => {
|
|
220
|
+
this.value = '';
|
|
221
|
+
this.#sendValueToForm();
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
_a = ToggleView;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
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
|
+
let ToolBarItemGroup = ToolBarItemGroup_1 = class ToolBarItemGroup extends HTMLElement {
|
|
2
12
|
constructor() {
|
|
3
13
|
super();
|
|
4
14
|
}
|
|
5
15
|
connectedCallback() {
|
|
6
|
-
|
|
16
|
+
if (devFlags.debug)
|
|
17
|
+
console.debug(`${ToolBarItemGroup_1.name} ⚡️ connect`);
|
|
7
18
|
}
|
|
8
19
|
disconnectedCallback() {
|
|
9
|
-
|
|
20
|
+
if (devFlags.debug)
|
|
21
|
+
console.debug(`${ToolBarItemGroup_1.name} ⚡️ disconnect`);
|
|
22
|
+
CleanupRegistry.unregister(this);
|
|
10
23
|
}
|
|
11
|
-
}
|
|
24
|
+
};
|
|
25
|
+
ToolBarItemGroup = ToolBarItemGroup_1 = __decorate([
|
|
26
|
+
adaptiveSlot()
|
|
27
|
+
], ToolBarItemGroup);
|
|
28
|
+
export { ToolBarItemGroup };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare class ToolBarItem extends HTMLElement {
|
|
2
|
+
#private;
|
|
3
|
+
static get observedAttributes(): string[];
|
|
2
4
|
constructor();
|
|
3
|
-
|
|
5
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
4
6
|
disconnectedCallback(): void;
|
|
7
|
+
connectedCallback(): void;
|
|
5
8
|
}
|
|
@@ -1,19 +1,66 @@
|
|
|
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;
|
|
1
8
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
3
|
-
|
|
9
|
+
import { adaptiveSlot } from '../internal/decorators';
|
|
10
|
+
import { devFlags, ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
|
|
11
|
+
import { Snapshot } from '../snapshot';
|
|
12
|
+
let ToolBarItem = ToolBarItem_1 = class ToolBarItem extends HTMLElement {
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return ['slot', 'data-previous-slot', 'title-key'];
|
|
15
|
+
}
|
|
16
|
+
#mutationObserver;
|
|
4
17
|
constructor() {
|
|
5
18
|
super();
|
|
6
19
|
}
|
|
20
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
21
|
+
if (devFlags.debug)
|
|
22
|
+
console.debug(`${ToolBarItem_1.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
23
|
+
switch (name) {
|
|
24
|
+
case 'slot':
|
|
25
|
+
case 'data-previous-slot':
|
|
26
|
+
case 'title-key': {
|
|
27
|
+
this.#mutationObserver?.disconnect();
|
|
28
|
+
const role = this.getAttribute('data-previous-slot') ?? this.getAttribute('slot') ?? '', tKey = this.getAttribute('title-key');
|
|
29
|
+
if (['confirmation-action', 'cancellation-action'].includes(role))
|
|
30
|
+
Snapshot.waitReady.then(() => {
|
|
31
|
+
ensurePlaceholder(this.querySelector(':scope>button'), role, tKey);
|
|
32
|
+
this.#mutationObserver = new MutationObserver((mutations) => {
|
|
33
|
+
for (const { target } of mutations)
|
|
34
|
+
if (target instanceof HTMLElement)
|
|
35
|
+
ensurePlaceholder(this.querySelector(':scope>button'), role, tKey);
|
|
36
|
+
});
|
|
37
|
+
this.#mutationObserver.observe(this, {
|
|
38
|
+
childList: true,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
if (devFlags.debug)
|
|
47
|
+
console.debug(`${ToolBarItem_1.name} ⚡️ disconnect`);
|
|
48
|
+
this.#mutationObserver?.disconnect();
|
|
49
|
+
CleanupRegistry.unregister(this);
|
|
50
|
+
}
|
|
7
51
|
connectedCallback() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
52
|
+
if (devFlags.debug)
|
|
53
|
+
console.debug(`${ToolBarItem_1.name} ⚡️ connect`);
|
|
54
|
+
CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t.closest('tool-bar-item-group') ?? t, ({ target }) => {
|
|
55
|
+
if (!(target instanceof HTMLElement))
|
|
56
|
+
return true;
|
|
57
|
+
if (target.closest('menu-view[open]'))
|
|
11
58
|
return false;
|
|
12
59
|
return true;
|
|
13
60
|
}), this).on());
|
|
14
61
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
62
|
+
};
|
|
63
|
+
ToolBarItem = ToolBarItem_1 = __decorate([
|
|
64
|
+
adaptiveSlot((el) => !el.closest('tool-bar-item-group'))
|
|
65
|
+
], ToolBarItem);
|
|
66
|
+
export { ToolBarItem };
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @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
|
|
3
|
+
* @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
|
|
4
|
+
* @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
|
|
5
|
+
* @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
|
|
6
|
+
* @slot top-bar-leading - Places the item in the leading edge of the top bar
|
|
7
|
+
* @slot top-bar-principal - Places the item in the middle of the top bar
|
|
8
|
+
* @slot top-bar-trailing - Places the item in the trailing edge of the top bar
|
|
9
|
+
* @slot bottom-bar-leading - Places the item in the leading edge of the bottom bar
|
|
10
|
+
* @slot bottom-bar-principal - Places the item in the middle of the bottom bar
|
|
11
|
+
* @slot bottom-bar-trailing - Places the item in the trailing edge of the bottom bar
|
|
12
|
+
*/
|
|
1
13
|
export declare class ToolBar extends HTMLElement {
|
|
2
14
|
#private;
|
|
3
15
|
static get template(): DocumentFragment;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { ResizeObserverSingleton } from '../internal/class/resize-observer-singleton';
|
|
3
|
-
import {
|
|
3
|
+
import { $, devFlags } from '../internal/utils';
|
|
4
4
|
const observers = new ResizeObserverSingleton();
|
|
5
|
+
/**
|
|
6
|
+
* @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
|
|
7
|
+
* @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
|
|
8
|
+
* @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
|
|
9
|
+
* @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
|
|
10
|
+
* @slot top-bar-leading - Places the item in the leading edge of the top bar
|
|
11
|
+
* @slot top-bar-principal - Places the item in the middle of the top bar
|
|
12
|
+
* @slot top-bar-trailing - Places the item in the trailing edge of the top bar
|
|
13
|
+
* @slot bottom-bar-leading - Places the item in the leading edge of the bottom bar
|
|
14
|
+
* @slot bottom-bar-principal - Places the item in the middle of the bottom bar
|
|
15
|
+
* @slot bottom-bar-trailing - Places the item in the trailing edge of the bottom bar
|
|
16
|
+
*/
|
|
5
17
|
export class ToolBar extends HTMLElement {
|
|
6
18
|
static #template;
|
|
7
19
|
static get template() {
|
|
@@ -9,6 +21,8 @@ export class ToolBar extends HTMLElement {
|
|
|
9
21
|
return (this.#template ??= $(String.raw `
|
|
10
22
|
<div part="root top-bar">
|
|
11
23
|
<div part="root toolbar-leading-stack">
|
|
24
|
+
<slot name="cancellation-action"></slot>
|
|
25
|
+
<slot name="destructive-action"></slot>
|
|
12
26
|
<slot name="top-bar-leading"></slot>
|
|
13
27
|
</div>
|
|
14
28
|
<div part="root toolbar-principal-stack">
|
|
@@ -16,6 +30,8 @@ export class ToolBar extends HTMLElement {
|
|
|
16
30
|
</div>
|
|
17
31
|
<div part="root toolbar-trailing-stack">
|
|
18
32
|
<slot name="top-bar-trailing"></slot>
|
|
33
|
+
<slot name="primary-action"></slot>
|
|
34
|
+
<slot name="confirmation-action"></slot>
|
|
19
35
|
</div>
|
|
20
36
|
</div>
|
|
21
37
|
<div part="root bottom-bar">
|
|
@@ -28,22 +44,20 @@ export class ToolBar extends HTMLElement {
|
|
|
28
44
|
<div part="root toolbar-trailing-stack">
|
|
29
45
|
<slot name="bottom-bar-trailing"></slot>
|
|
30
46
|
</div>
|
|
31
|
-
</div
|
|
47
|
+
</div>`));
|
|
32
48
|
}
|
|
33
49
|
#shadowRoot;
|
|
34
50
|
get #scrollView() {
|
|
35
|
-
return this.parentElement?.querySelector(':scope
|
|
51
|
+
return this.parentElement?.querySelector(':scope>scroll-view') ?? undefined; //this.previousElementSibling ?? undefined
|
|
36
52
|
}
|
|
37
53
|
constructor() {
|
|
38
54
|
super();
|
|
39
55
|
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
40
|
-
// NOTE: wait for config
|
|
41
|
-
// Snapshot.waitReady.then(() => {
|
|
42
56
|
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
43
|
-
// })
|
|
44
57
|
}
|
|
45
58
|
connectedCallback() {
|
|
46
|
-
|
|
59
|
+
if (devFlags.debug)
|
|
60
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
47
61
|
// NOTE: wait for config
|
|
48
62
|
// Snapshot.waitReady.then(() => {
|
|
49
63
|
for (const el of this.#shadowRoot.querySelectorAll(`[part*="toolbar-leading-stack"],[part*="toolbar-trailing-stack"]`))
|
|
@@ -51,11 +65,13 @@ export class ToolBar extends HTMLElement {
|
|
|
51
65
|
// })
|
|
52
66
|
}
|
|
53
67
|
disconnectedCallback() {
|
|
54
|
-
|
|
68
|
+
if (devFlags.debug)
|
|
69
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
55
70
|
observers.unobserve(this);
|
|
56
71
|
}
|
|
57
72
|
#measureStacks(entry) {
|
|
58
|
-
|
|
73
|
+
if (devFlags.debug)
|
|
74
|
+
console.debug(`${_a.name} ⚡️ measure`);
|
|
59
75
|
if (this.closest('[hidden]'))
|
|
60
76
|
return;
|
|
61
77
|
const leading = 'toolbar-leading-stack', trailing = 'toolbar-trailing-stack';
|
|
@@ -63,7 +79,7 @@ export class ToolBar extends HTMLElement {
|
|
|
63
79
|
'top-bar': 'navbar',
|
|
64
80
|
'bottom-bar': 'toolbar', //'bottombar',
|
|
65
81
|
};
|
|
66
|
-
const { contentRect, target } = entry;
|
|
82
|
+
const { contentRect: { width }, target, } = entry;
|
|
67
83
|
const parentPart = target.parentElement?.part.contains('top-bar') ? 'top-bar' : target.parentElement?.part.contains('bottom-bar') ? 'bottom-bar' : null;
|
|
68
84
|
if (!parentPart)
|
|
69
85
|
return;
|
|
@@ -71,7 +87,7 @@ export class ToolBar extends HTMLElement {
|
|
|
71
87
|
if (!side)
|
|
72
88
|
return;
|
|
73
89
|
const prop = `--${parentMap[parentPart]}-padding-${side}`;
|
|
74
|
-
|
|
90
|
+
this.#scrollView?.style?.setProperty(prop, `${Math.round(width)}px`); // $.prop(prop, `${Math.round(width)}px`, this.#scrollView) //
|
|
75
91
|
}
|
|
76
92
|
}
|
|
77
93
|
_a = ToolBar;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* BUG: Safari on IOS reports inaccurate innerHeight (which is what we really want) on orientationchange.
|
|
3
3
|
* So we live with a pescy body-scrollbar that shows up on resize on desktops.
|
|
4
4
|
*
|
|
5
|
-
* @summary Required component,
|
|
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.
|
|
6
8
|
*/
|
|
7
9
|
export declare class VKeyboard extends HTMLElement {
|
|
8
10
|
#private;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
-
import { $, frame, onoff, sleep } from '../internal/utils';
|
|
3
|
+
import { $, devFlags, frame, onoff, sleep } from '../internal/utils';
|
|
4
4
|
import { Snapshot } from '../snapshot';
|
|
5
5
|
/**
|
|
6
6
|
* BUG: Safari on IOS reports inaccurate innerHeight (which is what we really want) on orientationchange.
|
|
7
7
|
* So we live with a pescy body-scrollbar that shows up on resize on desktops.
|
|
8
8
|
*
|
|
9
|
-
* @summary Required component,
|
|
9
|
+
* @summary Required component, used to handle the virtual keyboard on touch devices.
|
|
10
|
+
*
|
|
11
|
+
* @attr {Inter} system-font - Prefers the "Inter" font family, if loaded.
|
|
10
12
|
*/
|
|
11
13
|
export class VKeyboard extends HTMLElement {
|
|
12
14
|
/**
|
|
@@ -20,11 +22,13 @@ export class VKeyboard extends HTMLElement {
|
|
|
20
22
|
super();
|
|
21
23
|
}
|
|
22
24
|
disconnectedCallback() {
|
|
23
|
-
|
|
25
|
+
if (devFlags.debug)
|
|
26
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
24
27
|
CleanupRegistry.unregister(this);
|
|
25
28
|
}
|
|
26
29
|
connectedCallback() {
|
|
27
|
-
|
|
30
|
+
if (devFlags.debug)
|
|
31
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
28
32
|
this.inert = true;
|
|
29
33
|
CleanupRegistry.register(this, onoff([
|
|
30
34
|
{ types: 'scroll', listener: this.#handleWindowScroll },
|
|
@@ -56,13 +60,15 @@ export class VKeyboard extends HTMLElement {
|
|
|
56
60
|
self.scrollTo(0, 0);
|
|
57
61
|
};
|
|
58
62
|
#handleWindowOrientationchange = async () => {
|
|
59
|
-
|
|
63
|
+
if (devFlags.debug)
|
|
64
|
+
console.debug(`${_a.name} ⚡️ orientationchange`);
|
|
60
65
|
if (!(await frame(this)))
|
|
61
66
|
return; //self.requestAnimationFrame(this.#ifKeyboardScrollIntoActiveElement)
|
|
62
67
|
this.#ifKeyboardScrollIntoActiveElement();
|
|
63
68
|
};
|
|
64
69
|
#handleBodyFocusin = async () => {
|
|
65
|
-
|
|
70
|
+
if (devFlags.debug)
|
|
71
|
+
console.debug(`${_a.name} ⚡️ focusin`);
|
|
66
72
|
await sleep(100); // self.setTimeout(this.#ifKeyboardScrollIntoActiveElement, 100)
|
|
67
73
|
if (!this.isConnected)
|
|
68
74
|
return;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @attr {leading|"leading fill"|center|trailing|fill|space-between} distribution - The distribution of cols
|
|
3
|
+
*
|
|
4
|
+
* @attr {"auto spacer"|"auto auto spacer"|"auto auto auto spacer"} template
|
|
5
|
+
*
|
|
6
|
+
* @attr {@spacingSet} spacing - The gap between the primary axis
|
|
7
|
+
*
|
|
8
|
+
* @attr {@alignmentSet} alignment - The cross-axis alignment
|
|
9
|
+
* @attr {@distributionSet} distribution - The main-axis alignment
|
|
10
|
+
* @attr {@placementSet} placement - The main-axis alignment
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
1
13
|
export declare class VStack extends HTMLElement {
|
|
2
14
|
constructor();
|
|
3
15
|
connectedCallback(): void;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
+
import { devFlags } from '../internal/utils';
|
|
2
|
+
/**
|
|
3
|
+
* @attr {leading|"leading fill"|center|trailing|fill|space-between} distribution - The distribution of cols
|
|
4
|
+
*
|
|
5
|
+
* @attr {"auto spacer"|"auto auto spacer"|"auto auto auto spacer"} template
|
|
6
|
+
*
|
|
7
|
+
* @attr {@spacingSet} spacing - The gap between the primary axis
|
|
8
|
+
*
|
|
9
|
+
* @attr {@alignmentSet} alignment - The cross-axis alignment
|
|
10
|
+
* @attr {@distributionSet} distribution - The main-axis alignment
|
|
11
|
+
* @attr {@placementSet} placement - The main-axis alignment
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
1
14
|
export class VStack extends HTMLElement {
|
|
2
15
|
constructor() {
|
|
3
16
|
super();
|
|
4
17
|
}
|
|
5
18
|
connectedCallback() {
|
|
6
|
-
|
|
19
|
+
if (devFlags.debug)
|
|
20
|
+
console.debug(`${VStack.name} ⚡️ connect`);
|
|
7
21
|
}
|
|
8
22
|
disconnectedCallback() {
|
|
9
|
-
|
|
23
|
+
if (devFlags.debug)
|
|
24
|
+
console.debug(`${VStack.name} ⚡️ disconnect`);
|
|
10
25
|
}
|
|
11
26
|
}
|