@easemate/web-kit 0.1.0
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 +824 -0
- package/build/components/code/index.cjs +152 -0
- package/build/components/code/index.d.cts +11 -0
- package/build/components/code/index.d.ts +11 -0
- package/build/components/code/index.js +148 -0
- package/build/components/code/utils/highlight-api.cjs +18 -0
- package/build/components/code/utils/highlight-api.d.cts +7 -0
- package/build/components/code/utils/highlight-api.d.ts +7 -0
- package/build/components/code/utils/highlight-api.js +14 -0
- package/build/components/code/utils/syntax-grammars.cjs +62 -0
- package/build/components/code/utils/syntax-grammars.d.cts +7 -0
- package/build/components/code/utils/syntax-grammars.d.ts +7 -0
- package/build/components/code/utils/syntax-grammars.js +59 -0
- package/build/components/code/utils/syntax-highlighter-theme.cjs +27 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.cts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.ts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.js +23 -0
- package/build/components/code/utils/syntax-highlighter-types.cjs +2 -0
- package/build/components/code/utils/syntax-highlighter-types.d.cts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.d.ts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.js +1 -0
- package/build/components/code/utils/syntax-tokenizer.cjs +63 -0
- package/build/components/code/utils/syntax-tokenizer.d.cts +3 -0
- package/build/components/code/utils/syntax-tokenizer.d.ts +3 -0
- package/build/components/code/utils/syntax-tokenizer.js +58 -0
- package/build/components/curve/bezier-conversion.cjs +23 -0
- package/build/components/curve/bezier-conversion.d.cts +2 -0
- package/build/components/curve/bezier-conversion.d.ts +2 -0
- package/build/components/curve/bezier-conversion.js +19 -0
- package/build/components/curve/canvas-controls.cjs +300 -0
- package/build/components/curve/canvas-controls.d.cts +12 -0
- package/build/components/curve/canvas-controls.d.ts +12 -0
- package/build/components/curve/canvas-controls.js +296 -0
- package/build/components/curve/canvas.cjs +1208 -0
- package/build/components/curve/canvas.d.cts +24 -0
- package/build/components/curve/canvas.d.ts +24 -0
- package/build/components/curve/canvas.js +1204 -0
- package/build/components/curve/constants.cjs +203 -0
- package/build/components/curve/constants.d.cts +23 -0
- package/build/components/curve/constants.d.ts +23 -0
- package/build/components/curve/constants.js +200 -0
- package/build/components/curve/controls.cjs +942 -0
- package/build/components/curve/controls.d.cts +37 -0
- package/build/components/curve/controls.d.ts +37 -0
- package/build/components/curve/controls.js +938 -0
- package/build/components/curve/index.cjs +335 -0
- package/build/components/curve/index.d.cts +31 -0
- package/build/components/curve/index.d.ts +31 -0
- package/build/components/curve/index.js +330 -0
- package/build/components/curve/output.cjs +141 -0
- package/build/components/curve/output.d.cts +19 -0
- package/build/components/curve/output.d.ts +19 -0
- package/build/components/curve/output.js +137 -0
- package/build/components/curve/styles.cjs +493 -0
- package/build/components/curve/styles.d.cts +6 -0
- package/build/components/curve/styles.d.ts +6 -0
- package/build/components/curve/styles.js +490 -0
- package/build/components/curve/svg-renderer.cjs +185 -0
- package/build/components/curve/svg-renderer.d.cts +9 -0
- package/build/components/curve/svg-renderer.d.ts +9 -0
- package/build/components/curve/svg-renderer.js +175 -0
- package/build/components/curve/toolbar.cjs +368 -0
- package/build/components/curve/toolbar.d.cts +26 -0
- package/build/components/curve/toolbar.d.ts +26 -0
- package/build/components/curve/toolbar.js +364 -0
- package/build/components/curve/types.cjs +10 -0
- package/build/components/curve/types.d.cts +33 -0
- package/build/components/curve/types.d.ts +33 -0
- package/build/components/curve/types.js +7 -0
- package/build/components/curve/utils.cjs +541 -0
- package/build/components/curve/utils.d.cts +33 -0
- package/build/components/curve/utils.d.ts +33 -0
- package/build/components/curve/utils.js +521 -0
- package/build/components/index.cjs +18 -0
- package/build/components/index.d.cts +2 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/decorators/Component.cjs +127 -0
- package/build/decorators/Component.d.cts +28 -0
- package/build/decorators/Component.d.ts +28 -0
- package/build/decorators/Component.js +123 -0
- package/build/decorators/Listen.cjs +154 -0
- package/build/decorators/Listen.d.cts +18 -0
- package/build/decorators/Listen.d.ts +18 -0
- package/build/decorators/Listen.js +151 -0
- package/build/decorators/OutsideClick.cjs +64 -0
- package/build/decorators/OutsideClick.d.cts +16 -0
- package/build/decorators/OutsideClick.d.ts +16 -0
- package/build/decorators/OutsideClick.js +59 -0
- package/build/decorators/Prop.cjs +273 -0
- package/build/decorators/Prop.d.cts +22 -0
- package/build/decorators/Prop.d.ts +22 -0
- package/build/decorators/Prop.js +270 -0
- package/build/decorators/Query.cjs +79 -0
- package/build/decorators/Query.d.cts +27 -0
- package/build/decorators/Query.d.ts +27 -0
- package/build/decorators/Query.js +76 -0
- package/build/decorators/Watch.cjs +52 -0
- package/build/decorators/Watch.d.cts +11 -0
- package/build/decorators/Watch.d.ts +11 -0
- package/build/decorators/Watch.js +49 -0
- package/build/decorators/index.cjs +15 -0
- package/build/decorators/index.d.cts +6 -0
- package/build/decorators/index.d.ts +6 -0
- package/build/decorators/index.js +6 -0
- package/build/elements/button/index.cjs +214 -0
- package/build/elements/button/index.d.cts +11 -0
- package/build/elements/button/index.d.ts +11 -0
- package/build/elements/button/index.js +210 -0
- package/build/elements/checkbox/index.cjs +316 -0
- package/build/elements/checkbox/index.d.cts +14 -0
- package/build/elements/checkbox/index.d.ts +14 -0
- package/build/elements/checkbox/index.js +312 -0
- package/build/elements/color/index.cjs +154 -0
- package/build/elements/color/index.d.cts +18 -0
- package/build/elements/color/index.d.ts +18 -0
- package/build/elements/color/index.js +150 -0
- package/build/elements/color/picker.cjs +544 -0
- package/build/elements/color/picker.d.cts +37 -0
- package/build/elements/color/picker.d.ts +37 -0
- package/build/elements/color/picker.js +540 -0
- package/build/elements/color/utils.cjs +235 -0
- package/build/elements/color/utils.d.cts +37 -0
- package/build/elements/color/utils.d.ts +37 -0
- package/build/elements/color/utils.js +218 -0
- package/build/elements/dropdown/index.cjs +875 -0
- package/build/elements/dropdown/index.d.cts +30 -0
- package/build/elements/dropdown/index.d.ts +30 -0
- package/build/elements/dropdown/index.js +871 -0
- package/build/elements/field/index.cjs +82 -0
- package/build/elements/field/index.d.cts +4 -0
- package/build/elements/field/index.d.ts +4 -0
- package/build/elements/field/index.js +78 -0
- package/build/elements/icons/animation/chevron.cjs +57 -0
- package/build/elements/icons/animation/chevron.d.cts +10 -0
- package/build/elements/icons/animation/chevron.d.ts +10 -0
- package/build/elements/icons/animation/chevron.js +53 -0
- package/build/elements/icons/animation/clear.cjs +74 -0
- package/build/elements/icons/animation/clear.d.cts +3 -0
- package/build/elements/icons/animation/clear.d.ts +3 -0
- package/build/elements/icons/animation/clear.js +70 -0
- package/build/elements/icons/animation/grid.cjs +77 -0
- package/build/elements/icons/animation/grid.d.cts +8 -0
- package/build/elements/icons/animation/grid.d.ts +8 -0
- package/build/elements/icons/animation/grid.js +73 -0
- package/build/elements/icons/animation/loading.cjs +68 -0
- package/build/elements/icons/animation/loading.d.cts +3 -0
- package/build/elements/icons/animation/loading.d.ts +3 -0
- package/build/elements/icons/animation/loading.js +64 -0
- package/build/elements/icons/animation/snap.cjs +133 -0
- package/build/elements/icons/animation/snap.d.cts +8 -0
- package/build/elements/icons/animation/snap.d.ts +8 -0
- package/build/elements/icons/animation/snap.js +129 -0
- package/build/elements/icons/index.cjs +40 -0
- package/build/elements/icons/index.d.cts +24 -0
- package/build/elements/icons/index.d.ts +24 -0
- package/build/elements/icons/index.js +24 -0
- package/build/elements/icons/interface/anchor-add.cjs +35 -0
- package/build/elements/icons/interface/anchor-add.d.cts +3 -0
- package/build/elements/icons/interface/anchor-add.d.ts +3 -0
- package/build/elements/icons/interface/anchor-add.js +31 -0
- package/build/elements/icons/interface/anchor-remove.cjs +34 -0
- package/build/elements/icons/interface/anchor-remove.d.cts +3 -0
- package/build/elements/icons/interface/anchor-remove.d.ts +3 -0
- package/build/elements/icons/interface/anchor-remove.js +30 -0
- package/build/elements/icons/interface/arrow-up.cjs +30 -0
- package/build/elements/icons/interface/arrow-up.d.cts +3 -0
- package/build/elements/icons/interface/arrow-up.d.ts +3 -0
- package/build/elements/icons/interface/arrow-up.js +26 -0
- package/build/elements/icons/interface/arrows-vertical.cjs +30 -0
- package/build/elements/icons/interface/arrows-vertical.d.cts +3 -0
- package/build/elements/icons/interface/arrows-vertical.d.ts +3 -0
- package/build/elements/icons/interface/arrows-vertical.js +26 -0
- package/build/elements/icons/interface/bezier-angle.cjs +33 -0
- package/build/elements/icons/interface/bezier-angle.d.cts +3 -0
- package/build/elements/icons/interface/bezier-angle.d.ts +3 -0
- package/build/elements/icons/interface/bezier-angle.js +29 -0
- package/build/elements/icons/interface/bezier-distribute.cjs +34 -0
- package/build/elements/icons/interface/bezier-distribute.d.cts +3 -0
- package/build/elements/icons/interface/bezier-distribute.d.ts +3 -0
- package/build/elements/icons/interface/bezier-distribute.js +30 -0
- package/build/elements/icons/interface/bezier-length.cjs +31 -0
- package/build/elements/icons/interface/bezier-length.d.cts +3 -0
- package/build/elements/icons/interface/bezier-length.d.ts +3 -0
- package/build/elements/icons/interface/bezier-length.js +27 -0
- package/build/elements/icons/interface/bezier-mirror.cjs +31 -0
- package/build/elements/icons/interface/bezier-mirror.d.cts +3 -0
- package/build/elements/icons/interface/bezier-mirror.d.ts +3 -0
- package/build/elements/icons/interface/bezier-mirror.js +27 -0
- package/build/elements/icons/interface/bezier.cjs +26 -0
- package/build/elements/icons/interface/bezier.d.cts +3 -0
- package/build/elements/icons/interface/bezier.d.ts +3 -0
- package/build/elements/icons/interface/bezier.js +22 -0
- package/build/elements/icons/interface/check.cjs +30 -0
- package/build/elements/icons/interface/check.d.cts +3 -0
- package/build/elements/icons/interface/check.d.ts +3 -0
- package/build/elements/icons/interface/check.js +26 -0
- package/build/elements/icons/interface/circle-arrow-left.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-left.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.js +26 -0
- package/build/elements/icons/interface/circle-arrow-right.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-right.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.js +26 -0
- package/build/elements/icons/interface/code.cjs +30 -0
- package/build/elements/icons/interface/code.d.cts +3 -0
- package/build/elements/icons/interface/code.d.ts +3 -0
- package/build/elements/icons/interface/code.js +26 -0
- package/build/elements/icons/interface/dots.cjs +32 -0
- package/build/elements/icons/interface/dots.d.cts +3 -0
- package/build/elements/icons/interface/dots.d.ts +3 -0
- package/build/elements/icons/interface/dots.js +28 -0
- package/build/elements/icons/interface/mention.cjs +30 -0
- package/build/elements/icons/interface/mention.d.cts +3 -0
- package/build/elements/icons/interface/mention.d.ts +3 -0
- package/build/elements/icons/interface/mention.js +26 -0
- package/build/elements/icons/interface/minus.cjs +30 -0
- package/build/elements/icons/interface/minus.d.cts +3 -0
- package/build/elements/icons/interface/minus.d.ts +3 -0
- package/build/elements/icons/interface/minus.js +26 -0
- package/build/elements/icons/interface/picker.cjs +34 -0
- package/build/elements/icons/interface/picker.d.cts +3 -0
- package/build/elements/icons/interface/picker.d.ts +3 -0
- package/build/elements/icons/interface/picker.js +30 -0
- package/build/elements/icons/interface/plus.cjs +30 -0
- package/build/elements/icons/interface/plus.d.cts +3 -0
- package/build/elements/icons/interface/plus.d.ts +3 -0
- package/build/elements/icons/interface/plus.js +26 -0
- package/build/elements/icons/interface/settings.cjs +30 -0
- package/build/elements/icons/interface/settings.d.cts +3 -0
- package/build/elements/icons/interface/settings.d.ts +3 -0
- package/build/elements/icons/interface/settings.js +26 -0
- package/build/elements/index.cjs +62 -0
- package/build/elements/index.d.cts +22 -0
- package/build/elements/index.d.ts +22 -0
- package/build/elements/index.js +22 -0
- package/build/elements/input/index.cjs +273 -0
- package/build/elements/input/index.d.cts +17 -0
- package/build/elements/input/index.d.ts +17 -0
- package/build/elements/input/index.js +269 -0
- package/build/elements/logo/index.cjs +732 -0
- package/build/elements/logo/index.d.cts +17 -0
- package/build/elements/logo/index.d.ts +17 -0
- package/build/elements/logo/index.js +728 -0
- package/build/elements/monitor/fps.cjs +432 -0
- package/build/elements/monitor/fps.d.cts +21 -0
- package/build/elements/monitor/fps.d.ts +21 -0
- package/build/elements/monitor/fps.js +428 -0
- package/build/elements/monitor/index.cjs +670 -0
- package/build/elements/monitor/index.d.cts +112 -0
- package/build/elements/monitor/index.d.ts +112 -0
- package/build/elements/monitor/index.js +666 -0
- package/build/elements/number/index.cjs +173 -0
- package/build/elements/number/index.d.cts +19 -0
- package/build/elements/number/index.d.ts +19 -0
- package/build/elements/number/index.js +169 -0
- package/build/elements/origin/index.cjs +169 -0
- package/build/elements/origin/index.d.cts +12 -0
- package/build/elements/origin/index.d.ts +12 -0
- package/build/elements/origin/index.js +165 -0
- package/build/elements/popover/index.cjs +209 -0
- package/build/elements/popover/index.d.cts +19 -0
- package/build/elements/popover/index.d.ts +19 -0
- package/build/elements/popover/index.js +205 -0
- package/build/elements/radio/index.cjs +301 -0
- package/build/elements/radio/index.d.cts +13 -0
- package/build/elements/radio/index.d.ts +13 -0
- package/build/elements/radio/index.js +283 -0
- package/build/elements/radio/input.cjs +329 -0
- package/build/elements/radio/input.d.cts +15 -0
- package/build/elements/radio/input.d.ts +15 -0
- package/build/elements/radio/input.js +325 -0
- package/build/elements/radio/option.cjs +15 -0
- package/build/elements/radio/option.d.cts +3 -0
- package/build/elements/radio/option.d.ts +3 -0
- package/build/elements/radio/option.js +11 -0
- package/build/elements/shared.cjs +66 -0
- package/build/elements/shared.d.cts +40 -0
- package/build/elements/shared.d.ts +40 -0
- package/build/elements/shared.js +59 -0
- package/build/elements/slider/index.cjs +232 -0
- package/build/elements/slider/index.d.cts +20 -0
- package/build/elements/slider/index.d.ts +20 -0
- package/build/elements/slider/index.js +228 -0
- package/build/elements/state/index.cjs +681 -0
- package/build/elements/state/index.d.cts +86 -0
- package/build/elements/state/index.d.ts +86 -0
- package/build/elements/state/index.js +677 -0
- package/build/elements/toggle/index.cjs +151 -0
- package/build/elements/toggle/index.d.cts +9 -0
- package/build/elements/toggle/index.d.ts +9 -0
- package/build/elements/toggle/index.js +147 -0
- package/build/elements/tooltip/index.cjs +187 -0
- package/build/elements/tooltip/index.d.cts +17 -0
- package/build/elements/tooltip/index.d.ts +17 -0
- package/build/elements/tooltip/index.js +183 -0
- package/build/index.cjs +40 -0
- package/build/index.d.cts +6 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +12 -0
- package/build/init.cjs +325 -0
- package/build/init.d.cts +157 -0
- package/build/init.d.ts +157 -0
- package/build/init.js +289 -0
- package/build/internal/component-loaders.cjs +206 -0
- package/build/internal/component-loaders.d.cts +52 -0
- package/build/internal/component-loaders.d.ts +52 -0
- package/build/internal/component-loaders.js +167 -0
- package/build/internal/fonts.cjs +128 -0
- package/build/internal/fonts.d.cts +32 -0
- package/build/internal/fonts.d.ts +32 -0
- package/build/internal/fonts.js +123 -0
- package/build/internal/lazy-load.cjs +89 -0
- package/build/internal/lazy-load.d.cts +32 -0
- package/build/internal/lazy-load.d.ts +32 -0
- package/build/internal/lazy-load.js +86 -0
- package/build/internal/style-inject.cjs +236 -0
- package/build/internal/style-inject.d.cts +44 -0
- package/build/internal/style-inject.d.ts +44 -0
- package/build/internal/style-inject.js +226 -0
- package/build/register.cjs +36 -0
- package/build/register.d.cts +32 -0
- package/build/register.d.ts +32 -0
- package/build/register.js +34 -0
- package/build/theme/index.cjs +452 -0
- package/build/theme/index.d.cts +146 -0
- package/build/theme/index.d.ts +146 -0
- package/build/theme/index.js +423 -0
- package/build/theme/presets.cjs +54 -0
- package/build/theme/presets.d.cts +19 -0
- package/build/theme/presets.d.ts +19 -0
- package/build/theme/presets.js +51 -0
- package/build/theme/registry.cjs +204 -0
- package/build/theme/registry.d.cts +99 -0
- package/build/theme/registry.d.ts +99 -0
- package/build/theme/registry.js +194 -0
- package/build/theme/tokens.cjs +148 -0
- package/build/theme/tokens.d.cts +163 -0
- package/build/theme/tokens.d.ts +163 -0
- package/build/theme/tokens.js +145 -0
- package/build/utils/dismiss-controller.cjs +77 -0
- package/build/utils/dismiss-controller.d.cts +14 -0
- package/build/utils/dismiss-controller.d.ts +14 -0
- package/build/utils/dismiss-controller.js +73 -0
- package/build/utils/index.cjs +18 -0
- package/build/utils/index.d.cts +3 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +3 -0
- package/build/utils/outside-click.cjs +82 -0
- package/build/utils/outside-click.d.cts +18 -0
- package/build/utils/outside-click.d.ts +18 -0
- package/build/utils/outside-click.js +74 -0
- package/build/utils/template-helpers.cjs +39 -0
- package/build/utils/template-helpers.d.cts +13 -0
- package/build/utils/template-helpers.d.ts +13 -0
- package/build/utils/template-helpers.js +28 -0
- package/package.json +96 -0
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
import { html, nothing } from 'lit-html';
|
|
2
|
+
import { CONTROL_CHANGE_EVENT, dispatchControlEvent, setBooleanAttribute } from "../shared.js";
|
|
3
|
+
import { Component } from '~/decorators/Component';
|
|
4
|
+
import { Listen } from '~/decorators/Listen';
|
|
5
|
+
import { Prop } from '~/decorators/Prop';
|
|
6
|
+
import { Query } from '~/decorators/Query';
|
|
7
|
+
const readControlValue = (element) => {
|
|
8
|
+
if (typeof element.value === 'string' || typeof element.value === 'number') {
|
|
9
|
+
return element.value;
|
|
10
|
+
}
|
|
11
|
+
if (typeof element.checked === 'boolean') {
|
|
12
|
+
return element.checked;
|
|
13
|
+
}
|
|
14
|
+
if ('getAttribute' in element) {
|
|
15
|
+
const attr = element.getAttribute('value');
|
|
16
|
+
if (attr !== null) {
|
|
17
|
+
return attr;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return element.textContent?.trim() ?? null;
|
|
21
|
+
};
|
|
22
|
+
const getControlName = (element) => {
|
|
23
|
+
if (typeof element.name === 'string' && element.name) {
|
|
24
|
+
return element.name;
|
|
25
|
+
}
|
|
26
|
+
return element.getAttribute?.('name') ?? null;
|
|
27
|
+
};
|
|
28
|
+
@Component({
|
|
29
|
+
tag: 'ease-state',
|
|
30
|
+
shadowMode: 'open',
|
|
31
|
+
styles: `
|
|
32
|
+
:host {
|
|
33
|
+
--ease-state-transition-duration: 120ms;
|
|
34
|
+
--ease-state-transition-easing: cubic-bezier(.25, 0, .5, 1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[part="section"] {
|
|
38
|
+
display: block;
|
|
39
|
+
width: 100%;
|
|
40
|
+
max-width: var(--ease-panel-max-width, 332px);
|
|
41
|
+
border-radius: var(--ease-panel-radius, 12px);
|
|
42
|
+
border: 1px solid var(--ease-panel-border-color, var(--color-white-6));
|
|
43
|
+
background-clip: padding-box;
|
|
44
|
+
background: var(--ease-panel-background, var(--color-gray-1000));
|
|
45
|
+
box-shadow: var(--ease-panel-shadow, 0 0 40px 0 var(--color-white-2) inset);
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
padding: var(--ease-panel-padding, 12px);
|
|
48
|
+
margin: auto;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[part="header"] {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: 8px;
|
|
55
|
+
width: 100%;
|
|
56
|
+
margin-bottom: 12px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[part="headline"] {
|
|
60
|
+
font-size: var(--ease-panel-title-font-size, 14px);
|
|
61
|
+
font-weight: var(--ease-panel-title-font-weight, 500);
|
|
62
|
+
line-height: var(--ease-panel-title-line-height, 24px);
|
|
63
|
+
font-family: var(--ease-font-family, "Instrument Sans", sans-serif);
|
|
64
|
+
color: var(--ease-panel-title-color, var(--color-blue-100));
|
|
65
|
+
margin: 0 0 0 4px;
|
|
66
|
+
flex-grow: 1;
|
|
67
|
+
text-ellipsis: ellipsis;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[part="headline"]:has(+ [part="tabs"]:not(:empty)) {
|
|
73
|
+
display: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[part="tabs"] {
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: 2px;
|
|
80
|
+
flex-grow: 1;
|
|
81
|
+
margin: 0 0 0 4px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[part="tabs"]:empty {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[part="tab"] {
|
|
89
|
+
appearance: none;
|
|
90
|
+
font-size: var(--ease-panel-tab-font-size, 13px);
|
|
91
|
+
font-weight: var(--ease-panel-tab-font-weight, 500);
|
|
92
|
+
line-height: var(--ease-panel-tab-line-height, 24px);
|
|
93
|
+
font-family: var(--ease-font-family, "Instrument Sans", sans-serif);
|
|
94
|
+
color: var(--ease-panel-tab-color, var(--color-gray-600));
|
|
95
|
+
background: transparent;
|
|
96
|
+
border: none;
|
|
97
|
+
padding: 4px 8px;
|
|
98
|
+
margin: 0;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
border-radius: var(--ease-panel-tab-radius, 6px);
|
|
101
|
+
transition: color 0.2s, background-color 0.2s;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[part="tab"]:hover {
|
|
105
|
+
color: var(--ease-panel-tab-color-hover, var(--color-blue-100));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[part="tab"][aria-selected="true"] {
|
|
109
|
+
color: var(--ease-panel-tab-color-active, var(--color-blue-100));
|
|
110
|
+
background: var(--ease-panel-tab-background-active, var(--color-white-4));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
[part="actions"] {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: 4px;
|
|
117
|
+
margin-left: auto;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
slot[name="actions"]::slotted(button),
|
|
121
|
+
slot[name="actions"]::slotted(a) {
|
|
122
|
+
--ease-icon-size: var(--ease-panel-action-icon-size, 16px);
|
|
123
|
+
|
|
124
|
+
appearance: none;
|
|
125
|
+
flex: 0 0 24px;
|
|
126
|
+
border: none;
|
|
127
|
+
outline: none;
|
|
128
|
+
background-color: transparent;
|
|
129
|
+
padding: 4px;
|
|
130
|
+
margin: 0;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
color: var(--color-gray-600);
|
|
133
|
+
transition: color 0.2s;
|
|
134
|
+
text-decoration: none;
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
slot[name="actions"]::slotted(button:hover),
|
|
141
|
+
slot[name="actions"]::slotted(button:focus-visible),
|
|
142
|
+
slot[name="actions"]::slotted(a:hover),
|
|
143
|
+
slot[name="actions"]::slotted(a:focus-visible) {
|
|
144
|
+
color: var(--color-blue-100);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
slot[name="actions"]::slotted(ease-dropdown) {
|
|
148
|
+
flex: 0 0 auto;
|
|
149
|
+
width: auto;
|
|
150
|
+
|
|
151
|
+
--ease-icon-size: var(--ease-panel-action-icon-size, 16px);
|
|
152
|
+
--ease-dropdown-trigger-padding: 4px;
|
|
153
|
+
--ease-dropdown-radius: 6px;
|
|
154
|
+
--ease-dropdown-background: transparent;
|
|
155
|
+
--ease-dropdown-background-hover: transparent;
|
|
156
|
+
--ease-dropdown-shadow: none;
|
|
157
|
+
--ease-dropdown-color: var(--color-gray-600);
|
|
158
|
+
--ease-popover-placement: bottom-end;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
slot[name="actions"]::slotted(ease-dropdown:hover),
|
|
162
|
+
slot[name="actions"]::slotted(ease-dropdown:focus-within) {
|
|
163
|
+
--ease-dropdown-color: var(--color-blue-100);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[part="content"] {
|
|
167
|
+
display: block;
|
|
168
|
+
width: 100%;
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
margin: auto;
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[part="content"][data-animating="true"] {
|
|
175
|
+
transition: height var(--ease-state-transition-duration) var(--ease-state-transition-easing);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[part="form"] {
|
|
179
|
+
width: 100%;
|
|
180
|
+
position: relative;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[part="tab-panel"] {
|
|
184
|
+
width: 100%;
|
|
185
|
+
pointer-events: none;
|
|
186
|
+
display: none;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[part="tab-panel"][data-state="active"] {
|
|
190
|
+
display: block;
|
|
191
|
+
pointer-events: auto;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[part="tab-panel"][data-state="hidden"] {
|
|
195
|
+
display: none;
|
|
196
|
+
pointer-events: none;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[part="footer"] {
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: space-between;
|
|
203
|
+
width: 100%;
|
|
204
|
+
padding: var(--ease-panel-footer-padding, 12px);
|
|
205
|
+
box-sizing: border-box;
|
|
206
|
+
border-top: 1px solid var(--color-white-4);
|
|
207
|
+
|
|
208
|
+
&:not(:has([data-has-content="true"])) {
|
|
209
|
+
display: none;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
::slotted([slot="entry"]),
|
|
214
|
+
::slotted([slot^="tab-"]) {
|
|
215
|
+
display: grid;
|
|
216
|
+
gap: 12px;
|
|
217
|
+
box-sizing: border-box;
|
|
218
|
+
width: 100%;
|
|
219
|
+
}
|
|
220
|
+
`
|
|
221
|
+
})
|
|
222
|
+
export class State extends HTMLElement {
|
|
223
|
+
#controls = new Map();
|
|
224
|
+
#state = {};
|
|
225
|
+
#initialState = {};
|
|
226
|
+
#subscribers = new Map();
|
|
227
|
+
#tabs = [];
|
|
228
|
+
#isAnimating = false;
|
|
229
|
+
@Prop({ reflect: true })
|
|
230
|
+
accessor value;
|
|
231
|
+
@Prop({
|
|
232
|
+
type: Number,
|
|
233
|
+
reflect: true,
|
|
234
|
+
attribute: 'active-tab',
|
|
235
|
+
defaultValue: 0,
|
|
236
|
+
onChange(next, previous) {
|
|
237
|
+
const self = this;
|
|
238
|
+
if (next !== previous && previous !== undefined) {
|
|
239
|
+
self.handleActiveTabChange(previous, next);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
accessor activeTab = 0;
|
|
244
|
+
/** @internal */
|
|
245
|
+
handleActiveTabChange(previous, next) {
|
|
246
|
+
this.performTabAnimation(previous, next);
|
|
247
|
+
}
|
|
248
|
+
@Query('slot[name="entry"]')
|
|
249
|
+
accessor entrySlot;
|
|
250
|
+
@Query('output')
|
|
251
|
+
accessor outputElement;
|
|
252
|
+
@Query('[part="content"]')
|
|
253
|
+
accessor contentElement;
|
|
254
|
+
@Query('[part="form"]')
|
|
255
|
+
accessor formElement;
|
|
256
|
+
/**
|
|
257
|
+
* Get the current state object with all control values
|
|
258
|
+
*/
|
|
259
|
+
get state() {
|
|
260
|
+
return { ...this.#state };
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get a specific control value by name
|
|
264
|
+
* @param name - The control name
|
|
265
|
+
* @returns The control value or undefined
|
|
266
|
+
*/
|
|
267
|
+
get(name) {
|
|
268
|
+
return this.#state[name];
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Set a control value programmatically
|
|
272
|
+
* @param name - The control name
|
|
273
|
+
* @param value - The new value
|
|
274
|
+
*/
|
|
275
|
+
set(name, value) {
|
|
276
|
+
const control = this.#controls.get(name);
|
|
277
|
+
if (control) {
|
|
278
|
+
// Update the control element
|
|
279
|
+
if ('value' in control) {
|
|
280
|
+
control.value = value;
|
|
281
|
+
}
|
|
282
|
+
else if (typeof value === 'boolean' && 'checked' in control) {
|
|
283
|
+
control.checked = value;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
this.#updateState(name, value, new Event('programmatic'));
|
|
287
|
+
}
|
|
288
|
+
subscribe(nameOrCallback, callback) {
|
|
289
|
+
let name;
|
|
290
|
+
let cb;
|
|
291
|
+
if (typeof nameOrCallback === 'function') {
|
|
292
|
+
name = '*';
|
|
293
|
+
cb = nameOrCallback;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
name = nameOrCallback;
|
|
297
|
+
if (!callback) {
|
|
298
|
+
throw new Error('[ease-state] subscribe(name, callback) requires a callback');
|
|
299
|
+
}
|
|
300
|
+
cb = callback;
|
|
301
|
+
}
|
|
302
|
+
if (!this.#subscribers.has(name)) {
|
|
303
|
+
this.#subscribers.set(name, new Set());
|
|
304
|
+
}
|
|
305
|
+
this.#subscribers.get(name)?.add(cb);
|
|
306
|
+
return {
|
|
307
|
+
unsubscribe: () => {
|
|
308
|
+
this.#subscribers.get(name)?.delete(cb);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Reset all controls to their initial values
|
|
314
|
+
*/
|
|
315
|
+
reset() {
|
|
316
|
+
for (const [name, value] of Object.entries(this.#initialState)) {
|
|
317
|
+
this.set(name, value);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Switch to a specific tab by index
|
|
322
|
+
* @param index - The tab index (0-based)
|
|
323
|
+
*/
|
|
324
|
+
setTab(index) {
|
|
325
|
+
if (index >= 0 && index < this.#tabs.length && index !== this.activeTab) {
|
|
326
|
+
this.activeTab = index;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
connectedCallback() {
|
|
330
|
+
this.#syncTabs();
|
|
331
|
+
this.#attach();
|
|
332
|
+
this.entrySlot?.addEventListener('slotchange', this.#handleSlotChange);
|
|
333
|
+
}
|
|
334
|
+
disconnectedCallback() {
|
|
335
|
+
this.#detach();
|
|
336
|
+
this.entrySlot?.removeEventListener('slotchange', this.#handleSlotChange);
|
|
337
|
+
}
|
|
338
|
+
afterRender() {
|
|
339
|
+
if (this.outputElement) {
|
|
340
|
+
this.outputElement.value = this.value ?? '';
|
|
341
|
+
}
|
|
342
|
+
this.#syncTabs();
|
|
343
|
+
}
|
|
344
|
+
render() {
|
|
345
|
+
const hasTabs = this.#tabs.length > 0;
|
|
346
|
+
return html `
|
|
347
|
+
<section part="section">
|
|
348
|
+
<div part="header">
|
|
349
|
+
<h3 part="headline"><slot name="headline"></slot></h3>
|
|
350
|
+
${this.#renderTabs()}
|
|
351
|
+
<div part="actions">
|
|
352
|
+
<slot name="actions"></slot>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
<div part="content">
|
|
356
|
+
<div part="form">
|
|
357
|
+
${hasTabs ? this.#renderTabPanels() : html `<slot name="entry"></slot>`}
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
<div part="footer">
|
|
361
|
+
<slot name="footer"></slot>
|
|
362
|
+
</div>
|
|
363
|
+
</section>
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
#renderTabs() {
|
|
367
|
+
if (this.#tabs.length === 0) {
|
|
368
|
+
return nothing;
|
|
369
|
+
}
|
|
370
|
+
return html `
|
|
371
|
+
<div part="tabs" role="tablist">
|
|
372
|
+
${this.#tabs.map((tab, index) => html `
|
|
373
|
+
<button
|
|
374
|
+
part="tab"
|
|
375
|
+
role="tab"
|
|
376
|
+
aria-selected=${index === this.activeTab ? 'true' : 'false'}
|
|
377
|
+
aria-controls=${`panel-${tab.id}`}
|
|
378
|
+
tabindex=${index === this.activeTab ? 0 : -1}
|
|
379
|
+
@click=${(e) => this.#handleTabClick(index, tab.id, e)}
|
|
380
|
+
@keydown=${(e) => this.#handleTabKeydown(e, index)}
|
|
381
|
+
>
|
|
382
|
+
${tab.label}
|
|
383
|
+
</button>
|
|
384
|
+
`)}
|
|
385
|
+
</div>
|
|
386
|
+
`;
|
|
387
|
+
}
|
|
388
|
+
#renderTabPanels() {
|
|
389
|
+
return html `
|
|
390
|
+
${this.#tabs.map((tab, index) => html `
|
|
391
|
+
<div
|
|
392
|
+
part="tab-panel"
|
|
393
|
+
role="tabpanel"
|
|
394
|
+
id=${`panel-${tab.id}`}
|
|
395
|
+
aria-labelledby=${`tab-${tab.id}`}
|
|
396
|
+
data-state=${index === this.activeTab ? 'active' : 'hidden'}
|
|
397
|
+
data-index=${index}
|
|
398
|
+
>
|
|
399
|
+
<slot name=${`tab-${tab.id}`}></slot>
|
|
400
|
+
</div>
|
|
401
|
+
`)}
|
|
402
|
+
`;
|
|
403
|
+
}
|
|
404
|
+
#handleTabClick(index, id, event) {
|
|
405
|
+
if (index === this.activeTab) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
this.activeTab = index;
|
|
409
|
+
dispatchControlEvent(this, 'tab-change', {
|
|
410
|
+
index,
|
|
411
|
+
id,
|
|
412
|
+
event
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
#handleTabKeydown(event, currentIndex) {
|
|
416
|
+
let newIndex = currentIndex;
|
|
417
|
+
switch (event.key) {
|
|
418
|
+
case 'ArrowLeft':
|
|
419
|
+
event.preventDefault();
|
|
420
|
+
newIndex = currentIndex > 0 ? currentIndex - 1 : this.#tabs.length - 1;
|
|
421
|
+
break;
|
|
422
|
+
case 'ArrowRight':
|
|
423
|
+
event.preventDefault();
|
|
424
|
+
newIndex = currentIndex < this.#tabs.length - 1 ? currentIndex + 1 : 0;
|
|
425
|
+
break;
|
|
426
|
+
case 'Home':
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
newIndex = 0;
|
|
429
|
+
break;
|
|
430
|
+
case 'End':
|
|
431
|
+
event.preventDefault();
|
|
432
|
+
newIndex = this.#tabs.length - 1;
|
|
433
|
+
break;
|
|
434
|
+
default:
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (newIndex !== currentIndex) {
|
|
438
|
+
this.activeTab = newIndex;
|
|
439
|
+
// Focus the new tab button
|
|
440
|
+
queueMicrotask(() => {
|
|
441
|
+
const tabButtons = this.shadowRoot?.querySelectorAll('[part="tab"]');
|
|
442
|
+
const newTabButton = tabButtons?.[newIndex];
|
|
443
|
+
newTabButton?.focus();
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
async performTabAnimation(fromIndex, toIndex) {
|
|
448
|
+
if (this.#isAnimating) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
this.#isAnimating = true;
|
|
452
|
+
const duration = 120;
|
|
453
|
+
const easing = 'cubic-bezier(.25, 0, .5, 1)';
|
|
454
|
+
const content = this.contentElement;
|
|
455
|
+
if (!content) {
|
|
456
|
+
this.#isAnimating = false;
|
|
457
|
+
this.requestRender();
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
// Get the panels by data-index attribute for reliability
|
|
461
|
+
const fromPanel = this.shadowRoot?.querySelector(`[part="tab-panel"][data-index="${fromIndex}"]`);
|
|
462
|
+
const toPanel = this.shadowRoot?.querySelector(`[part="tab-panel"][data-index="${toIndex}"]`);
|
|
463
|
+
if (!fromPanel || !toPanel) {
|
|
464
|
+
this.#isAnimating = false;
|
|
465
|
+
this.requestRender();
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
// Lock the current height
|
|
469
|
+
const startHeight = content.getBoundingClientRect().height;
|
|
470
|
+
content.style.height = `${startHeight}px`;
|
|
471
|
+
// FIX: Ensure the new panel is hidden immediately.
|
|
472
|
+
// Changing activeTab triggers a render which sets data-state="active" (display: block).
|
|
473
|
+
// We must override this with inline styles to prevent the content from showing during the fade-out.
|
|
474
|
+
toPanel.style.display = 'none';
|
|
475
|
+
toPanel.style.opacity = '0';
|
|
476
|
+
// Fade out old content via WAAPI (avoids any "one-frame" flashes)
|
|
477
|
+
try {
|
|
478
|
+
const fadeOut = fromPanel.animate([{ opacity: 1 }, { opacity: 0 }], { duration, easing, fill: 'forwards' });
|
|
479
|
+
await fadeOut.finished;
|
|
480
|
+
fadeOut.cancel();
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
// ignore
|
|
484
|
+
}
|
|
485
|
+
fromPanel.setAttribute('data-state', 'hidden');
|
|
486
|
+
// Prepare and measure new panel while completely invisible
|
|
487
|
+
const previousToState = toPanel.getAttribute('data-state');
|
|
488
|
+
// Reset display to block (overriding our 'none' above) but keep invisible for measuring
|
|
489
|
+
toPanel.style.display = 'block';
|
|
490
|
+
toPanel.style.visibility = 'hidden';
|
|
491
|
+
toPanel.style.opacity = '0';
|
|
492
|
+
// Force layout, then measure
|
|
493
|
+
void toPanel.offsetHeight;
|
|
494
|
+
const endHeight = toPanel.getBoundingClientRect().height;
|
|
495
|
+
// Animate height
|
|
496
|
+
if (startHeight !== endHeight) {
|
|
497
|
+
content.setAttribute('data-animating', 'true');
|
|
498
|
+
void content.offsetHeight;
|
|
499
|
+
content.style.height = `${endHeight}px`;
|
|
500
|
+
await this.#wait(duration);
|
|
501
|
+
}
|
|
502
|
+
// Show panel but keep opacity at 0, then fade in
|
|
503
|
+
toPanel.style.visibility = 'visible';
|
|
504
|
+
toPanel.style.opacity = '0';
|
|
505
|
+
// Ensure the 0-opacity state is committed
|
|
506
|
+
void toPanel.offsetHeight;
|
|
507
|
+
try {
|
|
508
|
+
const fadeIn = toPanel.animate([{ opacity: 0 }, { opacity: 1 }], { duration, easing, fill: 'forwards' });
|
|
509
|
+
await fadeIn.finished;
|
|
510
|
+
fadeIn.cancel();
|
|
511
|
+
}
|
|
512
|
+
catch {
|
|
513
|
+
// ignore
|
|
514
|
+
}
|
|
515
|
+
// Finalize new tab state and cleanup
|
|
516
|
+
toPanel.style.display = '';
|
|
517
|
+
toPanel.style.visibility = '';
|
|
518
|
+
toPanel.style.opacity = '';
|
|
519
|
+
// Restore state attribute (we only want one active)
|
|
520
|
+
if (previousToState !== 'active') {
|
|
521
|
+
toPanel.setAttribute('data-state', 'active');
|
|
522
|
+
}
|
|
523
|
+
content.style.height = '';
|
|
524
|
+
content.removeAttribute('data-animating');
|
|
525
|
+
this.#isAnimating = false;
|
|
526
|
+
this.#detach();
|
|
527
|
+
this.#attach();
|
|
528
|
+
}
|
|
529
|
+
#wait(ms) {
|
|
530
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
531
|
+
}
|
|
532
|
+
#syncTabs() {
|
|
533
|
+
const tabs = [];
|
|
534
|
+
for (const child of Array.from(this.children)) {
|
|
535
|
+
const slot = child.getAttribute('slot');
|
|
536
|
+
if (slot?.startsWith('tab-')) {
|
|
537
|
+
const id = slot.replace('tab-', '');
|
|
538
|
+
const label = child.getAttribute('data-tab-label') || id;
|
|
539
|
+
tabs.push({ id, label });
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
this.#tabs = tabs.slice(0, 3);
|
|
543
|
+
if (this.activeTab >= this.#tabs.length && this.#tabs.length > 0) {
|
|
544
|
+
this.activeTab = 0;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
@Listen('input', { target: (host) => host })
|
|
548
|
+
handleInternalInput(event) {
|
|
549
|
+
this.#handleControlEvent(event);
|
|
550
|
+
}
|
|
551
|
+
@Listen('change', { target: (host) => host })
|
|
552
|
+
handleInternalChange(event) {
|
|
553
|
+
this.#handleControlEvent(event);
|
|
554
|
+
}
|
|
555
|
+
@Listen(CONTROL_CHANGE_EVENT, { target: (host) => host })
|
|
556
|
+
handleControlChange(event) {
|
|
557
|
+
this.#handleControlEvent(event);
|
|
558
|
+
}
|
|
559
|
+
@Listen('slotchange', { selector: 'slot[name="footer"]' })
|
|
560
|
+
onFooterSlotChange() {
|
|
561
|
+
this.updateFooterAttribute();
|
|
562
|
+
}
|
|
563
|
+
#handleControlEvent(event) {
|
|
564
|
+
if ('detail' in event && event.detail?.name) {
|
|
565
|
+
this.#updateState(event.detail.name, event.detail.value, event);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (!(event.target instanceof Element)) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
const control = event.target;
|
|
572
|
+
const name = getControlName(control);
|
|
573
|
+
if (!name || !this.#controls.has(name)) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
const value = readControlValue(control);
|
|
577
|
+
this.#updateState(name, value, event);
|
|
578
|
+
}
|
|
579
|
+
#handleSlotChange = () => {
|
|
580
|
+
this.#syncTabs();
|
|
581
|
+
this.#detach();
|
|
582
|
+
this.#attach();
|
|
583
|
+
};
|
|
584
|
+
#attach() {
|
|
585
|
+
const slots = [];
|
|
586
|
+
if (this.#tabs.length === 0) {
|
|
587
|
+
if (this.entrySlot) {
|
|
588
|
+
slots.push(this.entrySlot);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
const activeTab = this.#tabs[this.activeTab];
|
|
593
|
+
if (activeTab) {
|
|
594
|
+
const tabSlot = this.shadowRoot?.querySelector(`slot[name="tab-${activeTab.id}"]`);
|
|
595
|
+
if (tabSlot) {
|
|
596
|
+
slots.push(tabSlot);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const findControls = (el) => {
|
|
601
|
+
const controls = [];
|
|
602
|
+
const name = getControlName(el);
|
|
603
|
+
if (name) {
|
|
604
|
+
controls.push(el);
|
|
605
|
+
}
|
|
606
|
+
if (el.shadowRoot) {
|
|
607
|
+
for (const child of el.shadowRoot.querySelectorAll('[name]')) {
|
|
608
|
+
const childName = getControlName(child);
|
|
609
|
+
if (childName) {
|
|
610
|
+
controls.push(child);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
for (const child of el.querySelectorAll('[name]')) {
|
|
615
|
+
const childName = getControlName(child);
|
|
616
|
+
if (childName) {
|
|
617
|
+
controls.push(child);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return controls;
|
|
621
|
+
};
|
|
622
|
+
this.#controls.clear();
|
|
623
|
+
this.#state = {};
|
|
624
|
+
for (const slot of slots) {
|
|
625
|
+
const elements = slot.assignedElements({ flatten: true });
|
|
626
|
+
for (const element of elements) {
|
|
627
|
+
const controls = findControls(element);
|
|
628
|
+
for (const control of controls) {
|
|
629
|
+
const name = getControlName(control);
|
|
630
|
+
if (name) {
|
|
631
|
+
this.#controls.set(name, control);
|
|
632
|
+
const value = readControlValue(control);
|
|
633
|
+
this.#state[name] = value;
|
|
634
|
+
this.#initialState[name] = value;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
const first = this.#controls.values().next().value;
|
|
640
|
+
if (first) {
|
|
641
|
+
const name = getControlName(first);
|
|
642
|
+
this.value = name && this.#state[name] != null ? String(this.#state[name]) : null;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
#detach() {
|
|
646
|
+
this.#controls.clear();
|
|
647
|
+
}
|
|
648
|
+
#updateState(name, value, event) {
|
|
649
|
+
const prevValue = this.#state[name];
|
|
650
|
+
if (prevValue === value) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
this.#state[name] = value;
|
|
654
|
+
this.value = String(value);
|
|
655
|
+
for (const cb of this.#subscribers.get(name) ?? []) {
|
|
656
|
+
cb(value, name);
|
|
657
|
+
}
|
|
658
|
+
for (const cb of this.#subscribers.get('*') ?? []) {
|
|
659
|
+
cb(value, name);
|
|
660
|
+
}
|
|
661
|
+
dispatchControlEvent(this, 'state-change', {
|
|
662
|
+
name,
|
|
663
|
+
value,
|
|
664
|
+
state: this.state,
|
|
665
|
+
event
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
updateFooterAttribute() {
|
|
669
|
+
const footer = this.shadowRoot?.querySelector('[part="footer"]');
|
|
670
|
+
if (!footer) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const footerSlot = this.shadowRoot?.querySelector('slot[name="footer"]');
|
|
674
|
+
const hasFooter = Boolean(footerSlot?.assignedNodes({ flatten: true }).length > 0);
|
|
675
|
+
setBooleanAttribute(footer, 'data-has-content', hasFooter);
|
|
676
|
+
}
|
|
677
|
+
}
|