@deepfuture/dui-components 0.0.20 → 1.0.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 +56 -65
- package/_install.js +11 -0
- package/accordion/accordion-item.d.ts +3 -20
- package/accordion/accordion-item.js +93 -292
- package/accordion/accordion.d.ts +3 -18
- package/accordion/accordion.js +9 -247
- package/accordion/index.d.ts +6 -6
- package/accordion/index.js +5 -5
- package/alert-dialog/alert-dialog-close.d.ts +3 -14
- package/alert-dialog/alert-dialog-close.js +4 -34
- package/alert-dialog/alert-dialog-popup.d.ts +3 -32
- package/alert-dialog/alert-dialog-popup.js +68 -317
- package/alert-dialog/alert-dialog-trigger.d.ts +3 -14
- package/alert-dialog/alert-dialog-trigger.js +4 -51
- package/alert-dialog/alert-dialog.d.ts +3 -30
- package/alert-dialog/alert-dialog.js +8 -158
- package/alert-dialog/index.d.ts +11 -11
- package/alert-dialog/index.js +9 -9
- package/all.d.ts +159 -123
- package/all.js +134 -231
- package/avatar/avatar.d.ts +3 -39
- package/avatar/avatar.js +18 -238
- package/avatar/index.d.ts +4 -4
- package/avatar/index.js +3 -3
- package/badge/badge.d.ts +3 -10
- package/badge/badge.js +88 -22
- package/badge/index.d.ts +2 -3
- package/badge/index.js +2 -3
- package/breadcrumb/breadcrumb-ellipsis.d.ts +3 -12
- package/breadcrumb/breadcrumb-ellipsis.js +8 -34
- package/breadcrumb/breadcrumb-item.d.ts +3 -11
- package/breadcrumb/breadcrumb-item.js +7 -26
- package/breadcrumb/breadcrumb-link.d.ts +3 -12
- package/breadcrumb/breadcrumb-link.js +16 -26
- package/breadcrumb/breadcrumb-page.d.ts +3 -11
- package/breadcrumb/breadcrumb-page.js +8 -31
- package/breadcrumb/breadcrumb-separator.d.ts +3 -12
- package/breadcrumb/breadcrumb-separator.js +8 -31
- package/breadcrumb/breadcrumb.d.ts +3 -12
- package/breadcrumb/breadcrumb.js +10 -33
- package/breadcrumb/index.d.ts +12 -13
- package/breadcrumb/index.js +12 -13
- package/button/button.d.ts +3 -32
- package/button/button.js +221 -165
- package/button/index.d.ts +3 -3
- package/button/index.js +3 -3
- package/calendar/calendar.d.ts +3 -31
- package/calendar/calendar.js +71 -481
- package/calendar/index.d.ts +3 -3
- package/calendar/index.js +3 -3
- package/card/card.d.ts +3 -27
- package/card/card.js +80 -163
- package/card/index.d.ts +2 -3
- package/card/index.js +2 -3
- package/card-grid/card-grid.d.ts +3 -15
- package/card-grid/card-grid.js +8 -106
- package/card-grid/index.d.ts +2 -3
- package/card-grid/index.js +2 -3
- package/checkbox/checkbox-group.d.ts +3 -34
- package/checkbox/checkbox-group.js +11 -188
- package/checkbox/checkbox.d.ts +3 -47
- package/checkbox/checkbox.js +43 -341
- package/checkbox/index.d.ts +6 -6
- package/checkbox/index.js +5 -5
- package/collapsible/collapsible.d.ts +3 -20
- package/collapsible/collapsible.js +83 -277
- package/collapsible/index.d.ts +3 -3
- package/collapsible/index.js +3 -3
- package/combobox/combobox.d.ts +3 -47
- package/combobox/combobox.js +136 -538
- package/combobox/index.d.ts +4 -4
- package/combobox/index.js +3 -3
- package/command/command-empty.d.ts +3 -8
- package/command/command-empty.js +10 -88
- package/command/command-group.d.ts +3 -13
- package/command/command-group.js +15 -114
- package/command/command-input.d.ts +3 -11
- package/command/command-input.js +20 -136
- package/command/command-item.d.ts +3 -18
- package/command/command-item.js +24 -212
- package/command/command-list.d.ts +3 -7
- package/command/command-list.js +11 -79
- package/command/command-separator.d.ts +3 -5
- package/command/command-separator.js +10 -11
- package/command/command-shortcut.d.ts +3 -5
- package/command/command-shortcut.js +9 -12
- package/command/command.d.ts +3 -23
- package/command/command.js +10 -339
- package/command/index.d.ts +17 -19
- package/command/index.js +16 -18
- package/data-table/data-table.d.ts +3 -57
- package/data-table/data-table.js +86 -449
- package/data-table/index.d.ts +3 -4
- package/data-table/index.js +2 -3
- package/dialog/dialog-close.d.ts +3 -14
- package/dialog/dialog-close.js +4 -34
- package/dialog/dialog-popup.d.ts +3 -34
- package/dialog/dialog-popup.js +70 -336
- package/dialog/dialog-trigger.d.ts +3 -14
- package/dialog/dialog-trigger.js +4 -51
- package/dialog/dialog.d.ts +3 -30
- package/dialog/dialog.js +8 -158
- package/dialog/index.d.ts +11 -11
- package/dialog/index.js +9 -9
- package/dropzone/dropzone.d.ts +3 -72
- package/dropzone/dropzone.js +29 -407
- package/dropzone/index.d.ts +4 -4
- package/dropzone/index.js +3 -3
- package/field/field.d.ts +3 -30
- package/field/field.js +34 -353
- package/field/index.d.ts +1 -0
- package/field/index.js +1 -0
- package/fieldset/fieldset.d.ts +3 -18
- package/fieldset/fieldset.js +21 -110
- package/fieldset/index.d.ts +1 -0
- package/fieldset/index.js +1 -0
- package/icon/icon.d.ts +3 -15
- package/icon/icon.js +4 -33
- package/icon/index.d.ts +2 -3
- package/icon/index.js +2 -3
- package/input/index.d.ts +3 -3
- package/input/index.js +3 -3
- package/input/input.d.ts +3 -49
- package/input/input.js +57 -238
- package/menu/index.d.ts +4 -5
- package/menu/index.js +4 -5
- package/menu/menu-item.d.ts +3 -13
- package/menu/menu-item.js +41 -91
- package/menu/menu.d.ts +3 -15
- package/menu/menu.js +27 -277
- package/menubar/index.d.ts +3 -4
- package/menubar/index.js +2 -3
- package/menubar/menubar.d.ts +3 -19
- package/menubar/menubar.js +12 -183
- package/number-field/index.d.ts +3 -3
- package/number-field/index.js +3 -3
- package/number-field/number-field.d.ts +3 -55
- package/number-field/number-field.js +205 -698
- package/package.json +126 -113
- package/popover/index.d.ts +11 -11
- package/popover/index.js +9 -9
- package/popover/popover-close.d.ts +3 -12
- package/popover/popover-close.js +4 -32
- package/popover/popover-popup.d.ts +3 -18
- package/popover/popover-popup.js +28 -205
- package/popover/popover-trigger.d.ts +3 -13
- package/popover/popover-trigger.js +4 -73
- package/popover/popover.d.ts +3 -29
- package/popover/popover.js +8 -207
- package/portal/index.d.ts +3 -4
- package/portal/index.js +2 -3
- package/portal/portal.d.ts +3 -27
- package/portal/portal.js +8 -157
- package/preview-card/index.d.ts +9 -9
- package/preview-card/index.js +7 -7
- package/preview-card/preview-card-popup.d.ts +3 -14
- package/preview-card/preview-card-popup.js +29 -193
- package/preview-card/preview-card-trigger.d.ts +3 -12
- package/preview-card/preview-card-trigger.js +4 -74
- package/preview-card/preview-card.d.ts +3 -33
- package/preview-card/preview-card.js +8 -239
- package/progress/index.d.ts +2 -3
- package/progress/index.js +2 -3
- package/progress/progress.d.ts +3 -17
- package/progress/progress.js +28 -130
- package/radio/index.d.ts +6 -6
- package/radio/index.js +5 -5
- package/radio/radio-group.d.ts +3 -37
- package/radio/radio-group.js +8 -200
- package/radio/radio.d.ts +3 -28
- package/radio/radio.js +38 -213
- package/scroll-area/index.d.ts +2 -3
- package/scroll-area/index.js +2 -3
- package/scroll-area/scroll-area.d.ts +3 -36
- package/scroll-area/scroll-area.js +25 -546
- package/select/index.d.ts +3 -4
- package/select/index.js +2 -3
- package/select/select.d.ts +3 -37
- package/select/select.js +115 -403
- package/separator/index.d.ts +2 -3
- package/separator/index.js +2 -3
- package/separator/separator.d.ts +3 -10
- package/separator/separator.js +23 -84
- package/sidebar/index.d.ts +29 -29
- package/sidebar/index.js +27 -32
- package/sidebar/sidebar-content.d.ts +3 -12
- package/sidebar/sidebar-content.js +7 -29
- package/sidebar/sidebar-footer.d.ts +3 -10
- package/sidebar/sidebar-footer.js +7 -20
- package/sidebar/sidebar-group-label.d.ts +3 -15
- package/sidebar/sidebar-group-label.js +17 -41
- package/sidebar/sidebar-group.d.ts +3 -13
- package/sidebar/sidebar-group.js +7 -24
- package/sidebar/sidebar-header.d.ts +3 -10
- package/sidebar/sidebar-header.js +7 -16
- package/sidebar/sidebar-inset.d.ts +3 -13
- package/sidebar/sidebar-inset.js +7 -28
- package/sidebar/sidebar-menu-button.d.ts +3 -26
- package/sidebar/sidebar-menu-button.js +60 -217
- package/sidebar/sidebar-menu-item.d.ts +3 -10
- package/sidebar/sidebar-menu-item.js +7 -19
- package/sidebar/sidebar-menu.d.ts +3 -12
- package/sidebar/sidebar-menu.js +7 -25
- package/sidebar/sidebar-provider.d.ts +3 -34
- package/sidebar/sidebar-provider.js +22 -232
- package/sidebar/sidebar-separator.d.ts +3 -10
- package/sidebar/sidebar-separator.js +9 -19
- package/sidebar/sidebar-trigger.d.ts +3 -14
- package/sidebar/sidebar-trigger.js +10 -46
- package/sidebar/sidebar.d.ts +3 -19
- package/sidebar/sidebar.js +65 -262
- package/slider/index.d.ts +3 -3
- package/slider/index.js +3 -3
- package/slider/slider.d.ts +3 -45
- package/slider/slider.js +97 -382
- package/spinner/index.d.ts +2 -3
- package/spinner/index.js +2 -3
- package/spinner/spinner.d.ts +3 -11
- package/spinner/spinner.js +20 -163
- package/split-button/index.d.ts +3 -1
- package/split-button/index.js +3 -1
- package/split-button/split-button.d.ts +3 -31
- package/split-button/split-button.js +307 -384
- package/stepper/index.d.ts +3 -3
- package/stepper/index.js +3 -3
- package/stepper/stepper.d.ts +3 -41
- package/stepper/stepper.js +57 -381
- package/switch/index.d.ts +3 -3
- package/switch/index.js +3 -3
- package/switch/switch.d.ts +3 -30
- package/switch/switch.js +63 -228
- package/tabs/index.d.ts +12 -12
- package/tabs/index.js +11 -11
- package/tabs/tab.d.ts +3 -14
- package/tabs/tab.js +33 -131
- package/tabs/tabs-indicator.d.ts +3 -9
- package/tabs/tabs-indicator.js +17 -22
- package/tabs/tabs-list.d.ts +3 -15
- package/tabs/tabs-list.js +14 -113
- package/tabs/tabs-panel.d.ts +3 -16
- package/tabs/tabs-panel.js +32 -114
- package/tabs/tabs.d.ts +3 -22
- package/tabs/tabs.js +8 -170
- package/textarea/index.d.ts +4 -4
- package/textarea/index.js +3 -3
- package/textarea/textarea.d.ts +3 -36
- package/textarea/textarea.js +63 -220
- package/toggle/index.d.ts +6 -6
- package/toggle/index.js +5 -5
- package/toggle/toggle-group.d.ts +3 -27
- package/toggle/toggle-group.js +9 -224
- package/toggle/toggle.d.ts +3 -26
- package/toggle/toggle.js +94 -178
- package/tokens/properties.css +361 -0
- package/tokens/prose.css +250 -0
- package/tokens/prose.d.ts +2 -0
- package/tokens/prose.js +4 -0
- package/tokens/tokens-raw.d.ts +2 -0
- package/tokens/tokens-raw.js +2 -0
- package/tokens/tokens.css +409 -0
- package/tokens/tokens.d.ts +2 -0
- package/tokens/tokens.js +5 -0
- package/toolbar/index.d.ts +2 -3
- package/toolbar/index.js +2 -3
- package/toolbar/toolbar.d.ts +3 -11
- package/toolbar/toolbar.js +25 -116
- package/tooltip/index.d.ts +9 -9
- package/tooltip/index.js +7 -7
- package/tooltip/tooltip-popup.d.ts +3 -14
- package/tooltip/tooltip-popup.js +32 -185
- package/tooltip/tooltip-trigger.d.ts +3 -14
- package/tooltip/tooltip-trigger.js +5 -148
- package/tooltip/tooltip.d.ts +3 -35
- package/tooltip/tooltip.js +8 -253
- package/trunc/index.d.ts +2 -3
- package/trunc/index.js +2 -3
- package/trunc/trunc.d.ts +3 -17
- package/trunc/trunc.js +10 -108
- package/_deprecated/center/center.d.ts +0 -14
- package/_deprecated/center/center.js +0 -37
- package/_deprecated/center/index.d.ts +0 -3
- package/_deprecated/center/index.js +0 -3
- package/_deprecated/center/register.js +0 -4
- package/_deprecated/hstack/hstack.d.ts +0 -25
- package/_deprecated/hstack/hstack.js +0 -187
- package/_deprecated/hstack/index.d.ts +0 -4
- package/_deprecated/hstack/index.js +0 -3
- package/_deprecated/hstack/register.d.ts +0 -1
- package/_deprecated/hstack/register.js +0 -4
- package/_deprecated/page-inset/index.d.ts +0 -3
- package/_deprecated/page-inset/index.js +0 -3
- package/_deprecated/page-inset/page-inset.d.ts +0 -28
- package/_deprecated/page-inset/page-inset.js +0 -151
- package/_deprecated/page-inset/register.d.ts +0 -1
- package/_deprecated/page-inset/register.js +0 -4
- package/_deprecated/vstack/index.d.ts +0 -3
- package/_deprecated/vstack/index.js +0 -3
- package/_deprecated/vstack/register.d.ts +0 -1
- package/_deprecated/vstack/register.js +0 -4
- package/_deprecated/vstack/vstack.d.ts +0 -17
- package/_deprecated/vstack/vstack.js +0 -125
- package/accordion/accordion-context.d.ts +0 -15
- package/accordion/accordion-context.js +0 -3
- package/alert-dialog/alert-dialog-context.d.ts +0 -13
- package/alert-dialog/alert-dialog-context.js +0 -3
- package/checkbox/checkbox-group-context.d.ts +0 -11
- package/checkbox/checkbox-group-context.js +0 -3
- package/command/command-context.d.ts +0 -30
- package/command/command-context.js +0 -3
- package/command/command-score.d.ts +0 -6
- package/command/command-score.js +0 -31
- package/dialog/dialog-context.d.ts +0 -13
- package/dialog/dialog-context.js +0 -3
- package/global.d.ts +0 -179
- package/menubar/menubar-context.d.ts +0 -9
- package/menubar/menubar-context.js +0 -2
- package/popover/popover-context.d.ts +0 -17
- package/popover/popover-context.js +0 -3
- package/preview-card/preview-card-context.d.ts +0 -16
- package/preview-card/preview-card-context.js +0 -3
- package/radio/radio-group-context.d.ts +0 -11
- package/radio/radio-group-context.js +0 -2
- package/sidebar/sidebar-context.d.ts +0 -15
- package/sidebar/sidebar-context.js +0 -3
- package/split-button/register.d.ts +0 -1
- package/split-button/register.js +0 -4
- package/tabs/tabs-context.d.ts +0 -8
- package/tabs/tabs-context.js +0 -2
- package/toggle/toggle-group-context.d.ts +0 -9
- package/toggle/toggle-group-context.js +0 -2
- package/tooltip/tooltip-context.d.ts +0 -17
- package/tooltip/tooltip-context.js +0 -3
- /package/{_deprecated/center/register.d.ts → _install.d.ts} +0 -0
|
@@ -1,397 +1,320 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiSplitButtonPrimitive } from "@deepfuture/dui-primitives/split-button";
|
|
3
|
+
import "../_install.js";
|
|
4
|
+
const styles = css `
|
|
5
|
+
/* =================================================================
|
|
6
|
+
* Reuses the button's two-axis variant system:
|
|
7
|
+
* variant → semantic intent (neutral, primary, danger)
|
|
8
|
+
* appearance → visual treatment (filled, outline, ghost)
|
|
9
|
+
*
|
|
10
|
+
* The whole .Root renders as one unified button shape. The action
|
|
11
|
+
* and trigger zones share the same background/border/radius.
|
|
12
|
+
* ================================================================= */
|
|
13
|
+
|
|
14
|
+
/* ---------------------------------------------------------------
|
|
15
|
+
* Layer 1 — Intent (sets --_intent-* private tokens)
|
|
16
|
+
* --------------------------------------------------------------- */
|
|
17
|
+
|
|
18
|
+
:host,
|
|
19
|
+
:host([variant=""]),
|
|
20
|
+
:host([variant="neutral"]) {
|
|
21
|
+
--_intent-base: var(--foreground);
|
|
22
|
+
--_intent-base-fg: var(--background);
|
|
23
|
+
--_intent-subtle: oklch(from var(--foreground) l c h / 0.08);
|
|
24
|
+
--_intent-subtle-fg: var(--text-1);
|
|
25
|
+
--_intent-border: var(--border);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([variant="primary"]) {
|
|
29
|
+
--_intent-base: var(--accent);
|
|
30
|
+
--_intent-base-fg: oklch(from var(--accent) 0.98 0.01 h);
|
|
31
|
+
--_intent-subtle: var(--accent-subtle);
|
|
32
|
+
--_intent-subtle-fg: var(--accent-text);
|
|
33
|
+
--_intent-border: oklch(from var(--accent) l c h / 0.5);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([variant="danger"]) {
|
|
37
|
+
--_intent-base: var(--destructive);
|
|
38
|
+
--_intent-base-fg: oklch(from var(--destructive) 0.98 0.01 h);
|
|
39
|
+
--_intent-subtle: var(--destructive-subtle);
|
|
40
|
+
--_intent-subtle-fg: var(--destructive-text);
|
|
41
|
+
--_intent-border: oklch(from var(--destructive) l c h / 0.5);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ---------------------------------------------------------------
|
|
45
|
+
* Layer 2 — Appearance (maps --_intent-* to --sb-*)
|
|
46
|
+
* --------------------------------------------------------------- */
|
|
47
|
+
|
|
48
|
+
:host,
|
|
49
|
+
:host([appearance=""]),
|
|
50
|
+
:host([appearance="filled"]) {
|
|
51
|
+
--sb-bg: var(--_intent-base);
|
|
52
|
+
--sb-fg: var(--_intent-base-fg);
|
|
53
|
+
--sb-border: transparent;
|
|
54
|
+
--sb-divider: oklch(from var(--_intent-base-fg) l c h / 0.25);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([appearance="outline"]) {
|
|
58
|
+
--sb-bg: transparent;
|
|
59
|
+
--sb-fg: var(--_intent-subtle-fg);
|
|
60
|
+
--sb-border: var(--border);
|
|
61
|
+
--sb-divider: var(--border);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:host([appearance="ghost"]) {
|
|
65
|
+
--sb-bg: transparent;
|
|
66
|
+
--sb-fg: var(--_intent-subtle-fg);
|
|
67
|
+
--sb-border: transparent;
|
|
68
|
+
--sb-divider: var(--border);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([appearance="soft"]) {
|
|
72
|
+
--sb-bg: var(--_intent-subtle);
|
|
73
|
+
--sb-fg: var(--_intent-subtle-fg);
|
|
74
|
+
--sb-border: transparent;
|
|
75
|
+
--sb-divider: oklch(from var(--_intent-base) l c h / 0.15);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* ---------------------------------------------------------------
|
|
79
|
+
* Sizes
|
|
80
|
+
* --------------------------------------------------------------- */
|
|
81
|
+
|
|
49
82
|
:host {
|
|
50
|
-
|
|
83
|
+
--sb-height: var(--component-height-md);
|
|
84
|
+
--sb-action-padding-y: var(--space-2);
|
|
85
|
+
--sb-action-padding-x: var(--space-2_5);
|
|
86
|
+
--sb-trigger-padding-x: var(--space-1_5);
|
|
87
|
+
--sb-gap: var(--space-1_5);
|
|
88
|
+
--sb-radius: var(--radius-md);
|
|
89
|
+
--sb-font-size: var(--text-sm);
|
|
90
|
+
--sb-icon-size: var(--space-4_5);
|
|
91
|
+
--sb-trigger-icon-size: var(--space-4);
|
|
51
92
|
}
|
|
52
|
-
|
|
53
|
-
|
|
93
|
+
|
|
94
|
+
:host([size="xs"]) {
|
|
95
|
+
--sb-height: var(--component-height-xs);
|
|
96
|
+
--sb-action-padding-y: var(--space-1);
|
|
97
|
+
--sb-action-padding-x: var(--space-1_5);
|
|
98
|
+
--sb-trigger-padding-x: var(--space-1);
|
|
99
|
+
--sb-gap: var(--space-1);
|
|
100
|
+
--sb-font-size: var(--text-xs);
|
|
101
|
+
--sb-icon-size: var(--space-3_5);
|
|
102
|
+
--sb-trigger-icon-size: var(--space-3);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host([size="sm"]) {
|
|
106
|
+
--sb-height: var(--component-height-sm);
|
|
107
|
+
--sb-action-padding-y: var(--space-1_5);
|
|
108
|
+
--sb-action-padding-x: var(--space-2);
|
|
109
|
+
--sb-trigger-padding-x: var(--space-1_5);
|
|
110
|
+
--sb-gap: var(--space-1);
|
|
111
|
+
--sb-font-size: var(--text-xs);
|
|
112
|
+
--sb-icon-size: var(--space-4);
|
|
113
|
+
--sb-trigger-icon-size: var(--space-3_5);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([size="lg"]) {
|
|
117
|
+
--sb-height: var(--component-height-lg);
|
|
118
|
+
--sb-action-padding-y: var(--space-2_5);
|
|
119
|
+
--sb-action-padding-x: var(--space-3);
|
|
120
|
+
--sb-trigger-padding-x: var(--space-2);
|
|
121
|
+
--sb-gap: var(--space-1_5);
|
|
122
|
+
--sb-font-size: var(--text-sm);
|
|
123
|
+
--sb-icon-size: var(--space-4_5);
|
|
124
|
+
--sb-trigger-icon-size: var(--space-4);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* ---------------------------------------------------------------
|
|
128
|
+
* Root container — unified button shape
|
|
129
|
+
* --------------------------------------------------------------- */
|
|
130
|
+
|
|
54
131
|
.Root {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
132
|
+
height: var(--sb-height);
|
|
133
|
+
border: var(--border-width-thin) solid var(--sb-border);
|
|
134
|
+
border-radius: var(--sb-radius);
|
|
135
|
+
background: var(--sb-bg);
|
|
136
|
+
color: var(--sb-fg);
|
|
137
|
+
font-family: var(--font-sans);
|
|
138
|
+
font-weight: var(--font-weight-medium);
|
|
139
|
+
font-size: var(--sb-font-size);
|
|
140
|
+
letter-spacing: var(--letter-spacing-tight);
|
|
141
|
+
line-height: var(--line-height-snug);
|
|
142
|
+
text-box: trim-both cap alphabetic;
|
|
143
|
+
white-space: nowrap;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ---------------------------------------------------------------
|
|
148
|
+
* Action button (left)
|
|
149
|
+
* --------------------------------------------------------------- */
|
|
150
|
+
|
|
151
|
+
[part="action"] {
|
|
152
|
+
--icon-size: var(--sb-icon-size);
|
|
153
|
+
--icon-color: var(--sb-fg);
|
|
154
|
+
gap: var(--sb-gap);
|
|
155
|
+
padding: var(--sb-action-padding-y) var(--sb-action-padding-x);
|
|
156
|
+
height: 100%;
|
|
157
|
+
color: inherit;
|
|
67
158
|
font: inherit;
|
|
159
|
+
letter-spacing: inherit;
|
|
160
|
+
line-height: inherit;
|
|
161
|
+
transition-property: background, filter;
|
|
162
|
+
transition-duration: var(--duration-faster);
|
|
163
|
+
transition-timing-function: var(--ease-out-3);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* ---------------------------------------------------------------
|
|
167
|
+
* Divider
|
|
168
|
+
* --------------------------------------------------------------- */
|
|
169
|
+
|
|
170
|
+
[part="divider"] {
|
|
171
|
+
border-left: var(--border-width-thin) solid var(--sb-divider);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* ---------------------------------------------------------------
|
|
175
|
+
* Trigger button (right)
|
|
176
|
+
* --------------------------------------------------------------- */
|
|
177
|
+
|
|
178
|
+
[part="trigger"] {
|
|
179
|
+
--icon-size: var(--sb-trigger-icon-size);
|
|
180
|
+
--icon-color: var(--sb-fg);
|
|
181
|
+
padding: 0 var(--sb-trigger-padding-x);
|
|
182
|
+
height: 100%;
|
|
183
|
+
background: var(--sb-trigger-bg, var(--sb-bg));
|
|
68
184
|
color: inherit;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
box-sizing: border-box;
|
|
185
|
+
transition-property: background, filter;
|
|
186
|
+
transition-duration: var(--duration-faster);
|
|
187
|
+
transition-timing-function: var(--ease-out-3);
|
|
73
188
|
}
|
|
74
189
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
190
|
+
/* ---------------------------------------------------------------
|
|
191
|
+
* Interactive states — filled uses filter, outline/ghost use alpha
|
|
192
|
+
* --------------------------------------------------------------- */
|
|
193
|
+
|
|
194
|
+
/* Filled hover */
|
|
195
|
+
:host(:not([appearance="outline"]):not([appearance="ghost"]):not([appearance="soft"]))
|
|
196
|
+
[part="action"]:hover:not(:disabled) {
|
|
197
|
+
filter: brightness(0.88);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
:host(:not([appearance="outline"]):not([appearance="ghost"]):not([appearance="soft"]))
|
|
201
|
+
[part="trigger"]:hover:not(:disabled) {
|
|
202
|
+
filter: brightness(0.88);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Filled active */
|
|
206
|
+
:host(:not([appearance="outline"]):not([appearance="ghost"]):not([appearance="soft"]))
|
|
207
|
+
[part="action"]:active:not(:disabled) {
|
|
208
|
+
filter: brightness(0.80);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
:host(:not([appearance="outline"]):not([appearance="ghost"]):not([appearance="soft"]))
|
|
212
|
+
[part="trigger"]:active:not(:disabled) {
|
|
213
|
+
filter: brightness(0.80);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Filled trigger open state */
|
|
217
|
+
:host(:not([appearance="outline"]):not([appearance="ghost"]):not([appearance="soft"]))
|
|
218
|
+
[part="trigger"][data-open]:not(:disabled) {
|
|
219
|
+
filter: brightness(0.80);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Ghost / outline hover */
|
|
223
|
+
:host([appearance="ghost"]) [part="action"]:hover:not(:disabled),
|
|
224
|
+
:host([appearance="outline"]) [part="action"]:hover:not(:disabled) {
|
|
225
|
+
background: oklch(from var(--_intent-base) l c h / 0.05);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
:host([appearance="ghost"]) [part="trigger"]:hover:not(:disabled),
|
|
229
|
+
:host([appearance="outline"]) [part="trigger"]:hover:not(:disabled) {
|
|
230
|
+
background: oklch(from var(--_intent-base) l c h / 0.05);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Ghost / outline active */
|
|
234
|
+
:host([appearance="ghost"]) [part="action"]:active:not(:disabled),
|
|
235
|
+
:host([appearance="outline"]) [part="action"]:active:not(:disabled) {
|
|
236
|
+
background: oklch(from var(--_intent-base) l c h / 0.10);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
:host([appearance="ghost"]) [part="trigger"]:active:not(:disabled),
|
|
240
|
+
:host([appearance="outline"]) [part="trigger"]:active:not(:disabled) {
|
|
241
|
+
background: oklch(from var(--_intent-base) l c h / 0.10);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* Ghost / outline trigger open state */
|
|
245
|
+
:host([appearance="ghost"]) [part="trigger"][data-open]:not(:disabled),
|
|
246
|
+
:host([appearance="outline"]) [part="trigger"][data-open]:not(:disabled) {
|
|
247
|
+
background: oklch(from var(--_intent-base) l c h / 0.10);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Soft hover */
|
|
251
|
+
:host([appearance="soft"]) [part="action"]:hover:not(:disabled) {
|
|
252
|
+
background: oklch(from var(--_intent-base) l c h / 0.12);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
:host([appearance="soft"]) [part="trigger"]:hover:not(:disabled) {
|
|
256
|
+
background: oklch(from var(--_intent-base) l c h / 0.12);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* Soft active */
|
|
260
|
+
:host([appearance="soft"]) [part="action"]:active:not(:disabled) {
|
|
261
|
+
background: oklch(from var(--_intent-base) l c h / 0.18);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
:host([appearance="soft"]) [part="trigger"]:active:not(:disabled) {
|
|
265
|
+
background: oklch(from var(--_intent-base) l c h / 0.18);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* Soft trigger open state */
|
|
269
|
+
:host([appearance="soft"]) [part="trigger"][data-open]:not(:disabled) {
|
|
270
|
+
background: oklch(from var(--_intent-base) l c h / 0.18);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* Focus visible */
|
|
274
|
+
[part="action"]:focus-visible,
|
|
275
|
+
[part="trigger"]:focus-visible {
|
|
276
|
+
outline: none;
|
|
277
|
+
box-shadow:
|
|
278
|
+
0 0 0 var(--focus-ring-offset) var(--background),
|
|
279
|
+
0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
|
|
280
|
+
z-index: 1;
|
|
281
|
+
position: relative;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/* Disabled */
|
|
285
|
+
:host([disabled]) .Root {
|
|
286
|
+
opacity: 0.4;
|
|
287
|
+
cursor: not-allowed;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
[part="action"]:disabled,
|
|
291
|
+
[part="trigger"]:disabled {
|
|
292
|
+
cursor: not-allowed;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* ---------------------------------------------------------------
|
|
296
|
+
* Popup (rendered in portal shadow root)
|
|
297
|
+
* --------------------------------------------------------------- */
|
|
298
|
+
|
|
299
|
+
.Popup {
|
|
300
|
+
background: var(--surface-3);
|
|
301
|
+
border: var(--border-width-thin) solid var(--border);
|
|
302
|
+
border-radius: var(--radius-md);
|
|
303
|
+
box-shadow: var(--shadow-md);
|
|
304
|
+
transition-duration: var(--duration-fast);
|
|
305
|
+
transition-timing-function: var(--ease-out-3);
|
|
79
306
|
}
|
|
80
307
|
|
|
81
|
-
.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
align-self: stretch;
|
|
308
|
+
.Popup[data-starting-style],
|
|
309
|
+
.Popup[data-ending-style] {
|
|
310
|
+
transform: translateY(calc(var(--space-1) * -1));
|
|
85
311
|
}
|
|
86
312
|
|
|
87
|
-
.
|
|
88
|
-
|
|
89
|
-
align-items: center;
|
|
90
|
-
justify-content: center;
|
|
91
|
-
flex-shrink: 0;
|
|
313
|
+
.Menu {
|
|
314
|
+
padding: var(--space-1);
|
|
92
315
|
}
|
|
93
316
|
`;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
max-height: 240px;
|
|
99
|
-
overflow-y: auto;
|
|
100
|
-
overscroll-behavior: contain;
|
|
101
|
-
opacity: 1;
|
|
102
|
-
transform: translateY(0);
|
|
103
|
-
transition-property: opacity, transform;
|
|
104
|
-
pointer-events: auto;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.Popup[data-starting-style],
|
|
108
|
-
.Popup[data-ending-style] {
|
|
109
|
-
opacity: 0;
|
|
110
|
-
}
|
|
111
|
-
`,
|
|
112
|
-
];
|
|
113
|
-
/**
|
|
114
|
-
* `<dui-split-button>` — A button with an attached dropdown menu trigger.
|
|
115
|
-
*
|
|
116
|
-
* The action zone (left) performs a primary action. The menu trigger (right)
|
|
117
|
-
* opens a dropdown of `dui-menu-item` children for secondary actions.
|
|
118
|
-
*
|
|
119
|
-
* @slot - Action button label / content.
|
|
120
|
-
* @slot icon - Custom icon for the dropdown trigger (defaults to chevron-down).
|
|
121
|
-
* @slot menu - `dui-menu-item` elements rendered inside the dropdown popup.
|
|
122
|
-
* @csspart root - The outer container wrapping both zones.
|
|
123
|
-
* @csspart action - The left action button element.
|
|
124
|
-
* @csspart divider - The vertical separator between action and trigger.
|
|
125
|
-
* @csspart trigger - The right dropdown trigger button element.
|
|
126
|
-
* @fires dui-action - Fired when the action button is clicked. Detail: {}
|
|
127
|
-
*/
|
|
128
|
-
let DuiSplitButton = (() => {
|
|
129
|
-
let _classSuper = LitElement;
|
|
130
|
-
let _variant_decorators;
|
|
131
|
-
let _variant_initializers = [];
|
|
132
|
-
let _variant_extraInitializers = [];
|
|
133
|
-
let _appearance_decorators;
|
|
134
|
-
let _appearance_initializers = [];
|
|
135
|
-
let _appearance_extraInitializers = [];
|
|
136
|
-
let _size_decorators;
|
|
137
|
-
let _size_initializers = [];
|
|
138
|
-
let _size_extraInitializers = [];
|
|
139
|
-
let _disabled_decorators;
|
|
140
|
-
let _disabled_initializers = [];
|
|
141
|
-
let _disabled_extraInitializers = [];
|
|
142
|
-
let _private_highlightedIndex_decorators;
|
|
143
|
-
let _private_highlightedIndex_initializers = [];
|
|
144
|
-
let _private_highlightedIndex_extraInitializers = [];
|
|
145
|
-
let _private_highlightedIndex_descriptor;
|
|
146
|
-
return class DuiSplitButton extends _classSuper {
|
|
147
|
-
static {
|
|
148
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
149
|
-
_variant_decorators = [property({ reflect: true })];
|
|
150
|
-
_appearance_decorators = [property({ reflect: true })];
|
|
151
|
-
_size_decorators = [property({ reflect: true })];
|
|
152
|
-
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
153
|
-
_private_highlightedIndex_decorators = [state()];
|
|
154
|
-
__esDecorate(this, null, _variant_decorators, { kind: "accessor", name: "variant", static: false, private: false, access: { has: obj => "variant" in obj, get: obj => obj.variant, set: (obj, value) => { obj.variant = value; } }, metadata: _metadata }, _variant_initializers, _variant_extraInitializers);
|
|
155
|
-
__esDecorate(this, null, _appearance_decorators, { kind: "accessor", name: "appearance", static: false, private: false, access: { has: obj => "appearance" in obj, get: obj => obj.appearance, set: (obj, value) => { obj.appearance = value; } }, metadata: _metadata }, _appearance_initializers, _appearance_extraInitializers);
|
|
156
|
-
__esDecorate(this, null, _size_decorators, { kind: "accessor", name: "size", static: false, private: false, access: { has: obj => "size" in obj, get: obj => obj.size, set: (obj, value) => { obj.size = value; } }, metadata: _metadata }, _size_initializers, _size_extraInitializers);
|
|
157
|
-
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
158
|
-
__esDecorate(this, _private_highlightedIndex_descriptor = { get: __setFunctionName(function () { return this.#highlightedIndex_accessor_storage; }, "#highlightedIndex", "get"), set: __setFunctionName(function (value) { this.#highlightedIndex_accessor_storage = value; }, "#highlightedIndex", "set") }, _private_highlightedIndex_decorators, { kind: "accessor", name: "#highlightedIndex", static: false, private: true, access: { has: obj => #highlightedIndex in obj, get: obj => obj.#highlightedIndex, set: (obj, value) => { obj.#highlightedIndex = value; } }, metadata: _metadata }, _private_highlightedIndex_initializers, _private_highlightedIndex_extraInitializers);
|
|
159
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
160
|
-
}
|
|
161
|
-
static tagName = "dui-split-button";
|
|
162
|
-
static styles = [base, hostStyles, componentStyles];
|
|
163
|
-
#variant_accessor_storage = __runInitializers(this, _variant_initializers, "");
|
|
164
|
-
/** Visual variant — mapped to theme styles (e.g. neutral, primary, danger). */
|
|
165
|
-
get variant() { return this.#variant_accessor_storage; }
|
|
166
|
-
set variant(value) { this.#variant_accessor_storage = value; }
|
|
167
|
-
#appearance_accessor_storage = (__runInitializers(this, _variant_extraInitializers), __runInitializers(this, _appearance_initializers, ""));
|
|
168
|
-
/** Visual appearance — mapped to theme styles (e.g. filled, outline, ghost). */
|
|
169
|
-
get appearance() { return this.#appearance_accessor_storage; }
|
|
170
|
-
set appearance(value) { this.#appearance_accessor_storage = value; }
|
|
171
|
-
#size_accessor_storage = (__runInitializers(this, _appearance_extraInitializers), __runInitializers(this, _size_initializers, ""));
|
|
172
|
-
/** Size — mapped to theme styles (e.g. xs, sm, md, lg). */
|
|
173
|
-
get size() { return this.#size_accessor_storage; }
|
|
174
|
-
set size(value) { this.#size_accessor_storage = value; }
|
|
175
|
-
#disabled_accessor_storage = (__runInitializers(this, _size_extraInitializers), __runInitializers(this, _disabled_initializers, false));
|
|
176
|
-
/** Whether the entire split button is disabled. */
|
|
177
|
-
get disabled() { return this.#disabled_accessor_storage; }
|
|
178
|
-
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
179
|
-
#highlightedIndex_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _private_highlightedIndex_initializers, -1));
|
|
180
|
-
get #highlightedIndex() { return _private_highlightedIndex_descriptor.get.call(this); }
|
|
181
|
-
set #highlightedIndex(value) { return _private_highlightedIndex_descriptor.set.call(this, value); }
|
|
182
|
-
#menuId = (__runInitializers(this, _private_highlightedIndex_extraInitializers), `split-menu-${crypto.randomUUID().slice(0, 8)}`);
|
|
183
|
-
#popup = new FloatingPortalController(this, {
|
|
184
|
-
getAnchor: () => this.shadowRoot?.querySelector(".Root"),
|
|
185
|
-
matchWidth: false,
|
|
186
|
-
styles: portalPopupStyles,
|
|
187
|
-
contentContainer: ".Menu",
|
|
188
|
-
contentSelector: "dui-menu-item",
|
|
189
|
-
onOpen: () => {
|
|
190
|
-
this.#highlightedIndex = -1;
|
|
191
|
-
},
|
|
192
|
-
onClose: () => {
|
|
193
|
-
this.#highlightedIndex = -1;
|
|
194
|
-
},
|
|
195
|
-
renderPopup: (portal) => html `
|
|
196
|
-
<div
|
|
197
|
-
class="Popup"
|
|
198
|
-
?data-starting-style="${portal.isStarting}"
|
|
199
|
-
?data-ending-style="${portal.isEnding}"
|
|
200
|
-
>
|
|
201
|
-
<div
|
|
202
|
-
class="Menu"
|
|
203
|
-
id="${this.#menuId}"
|
|
204
|
-
role="menu"
|
|
205
|
-
@click="${this.#onItemSlotClick}"
|
|
206
|
-
@mousemove="${this.#onMenuMouseMove}"
|
|
207
|
-
></div>
|
|
208
|
-
</div>
|
|
209
|
-
`,
|
|
210
|
-
});
|
|
211
|
-
get #items() {
|
|
212
|
-
const container = this.#popup.renderRoot?.querySelector(".Menu") ?? this;
|
|
213
|
-
return [...container.querySelectorAll("dui-menu-item")];
|
|
214
|
-
}
|
|
215
|
-
updated() {
|
|
216
|
-
const items = this.#items;
|
|
217
|
-
for (let i = 0; i < items.length; i++) {
|
|
218
|
-
if (i === this.#highlightedIndex) {
|
|
219
|
-
items[i].setAttribute("data-highlighted", "");
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
items[i].removeAttribute("data-highlighted");
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
// ---- Action zone handlers ----
|
|
227
|
-
#onActionClick = (e) => {
|
|
228
|
-
e.stopPropagation();
|
|
229
|
-
if (this.disabled)
|
|
230
|
-
return;
|
|
231
|
-
this.dispatchEvent(actionEvent({}));
|
|
232
|
-
};
|
|
233
|
-
#onActionKeyDown = (e) => {
|
|
234
|
-
if (this.disabled)
|
|
235
|
-
return;
|
|
236
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
237
|
-
e.preventDefault();
|
|
238
|
-
this.dispatchEvent(actionEvent({}));
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
// ---- Trigger zone handlers ----
|
|
242
|
-
#onTriggerClick = (e) => {
|
|
243
|
-
e.stopPropagation();
|
|
244
|
-
if (this.disabled)
|
|
245
|
-
return;
|
|
246
|
-
if (this.#popup.isOpen) {
|
|
247
|
-
this.#popup.close();
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
this.#popup.open();
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
#onTriggerKeyDown = (e) => {
|
|
254
|
-
if (this.disabled)
|
|
255
|
-
return;
|
|
256
|
-
const items = this.#items;
|
|
257
|
-
switch (e.key) {
|
|
258
|
-
case "Enter":
|
|
259
|
-
case " ": {
|
|
260
|
-
if (this.#popup.isOpen && this.#highlightedIndex >= 0) {
|
|
261
|
-
e.preventDefault();
|
|
262
|
-
const item = items[this.#highlightedIndex];
|
|
263
|
-
if (item && !item.disabled) {
|
|
264
|
-
item.click();
|
|
265
|
-
this.#popup.close();
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else if (!this.#popup.isOpen) {
|
|
269
|
-
e.preventDefault();
|
|
270
|
-
this.#popup.open();
|
|
271
|
-
}
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
case "ArrowDown": {
|
|
275
|
-
e.preventDefault();
|
|
276
|
-
if (!this.#popup.isOpen) {
|
|
277
|
-
this.#popup.open();
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
let next = this.#highlightedIndex + 1;
|
|
281
|
-
while (next < items.length && items[next]?.disabled)
|
|
282
|
-
next++;
|
|
283
|
-
if (next < items.length)
|
|
284
|
-
this.#highlightedIndex = next;
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case "ArrowUp": {
|
|
289
|
-
e.preventDefault();
|
|
290
|
-
if (!this.#popup.isOpen) {
|
|
291
|
-
this.#popup.open();
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
let prev = this.#highlightedIndex - 1;
|
|
295
|
-
while (prev >= 0 && items[prev]?.disabled)
|
|
296
|
-
prev--;
|
|
297
|
-
if (prev >= 0)
|
|
298
|
-
this.#highlightedIndex = prev;
|
|
299
|
-
}
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
case "Home": {
|
|
303
|
-
if (this.#popup.isOpen) {
|
|
304
|
-
e.preventDefault();
|
|
305
|
-
const firstEnabled = items.findIndex((item) => !item.disabled);
|
|
306
|
-
if (firstEnabled >= 0)
|
|
307
|
-
this.#highlightedIndex = firstEnabled;
|
|
308
|
-
}
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
case "End": {
|
|
312
|
-
if (this.#popup.isOpen) {
|
|
313
|
-
e.preventDefault();
|
|
314
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
|
315
|
-
if (!items[i]?.disabled) {
|
|
316
|
-
this.#highlightedIndex = i;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
case "Escape": {
|
|
324
|
-
if (this.#popup.isOpen) {
|
|
325
|
-
e.preventDefault();
|
|
326
|
-
this.#popup.close();
|
|
327
|
-
this.#focusTrigger();
|
|
328
|
-
}
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
case "Tab": {
|
|
332
|
-
if (this.#popup.isOpen) {
|
|
333
|
-
this.#popup.close();
|
|
334
|
-
}
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
// ---- Menu handlers ----
|
|
340
|
-
#onItemSlotClick = (e) => {
|
|
341
|
-
const item = e
|
|
342
|
-
.composedPath()
|
|
343
|
-
.find((el) => el instanceof HTMLElement && el.matches(DuiMenuItem.tagName));
|
|
344
|
-
if (item && !item.disabled) {
|
|
345
|
-
this.#popup.close();
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
#onMenuMouseMove = () => {
|
|
349
|
-
if (this.#highlightedIndex >= 0) {
|
|
350
|
-
this.#highlightedIndex = -1;
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
#focusTrigger() {
|
|
354
|
-
this.shadowRoot?.querySelector(".Trigger")?.focus();
|
|
355
|
-
}
|
|
356
|
-
render() {
|
|
357
|
-
return html `
|
|
358
|
-
<div class="Root" part="root">
|
|
359
|
-
<button
|
|
360
|
-
class="Action"
|
|
361
|
-
part="action"
|
|
362
|
-
type="button"
|
|
363
|
-
?disabled="${this.disabled}"
|
|
364
|
-
@click="${this.#onActionClick}"
|
|
365
|
-
@keydown="${this.#onActionKeyDown}"
|
|
366
|
-
>
|
|
367
|
-
<slot></slot>
|
|
368
|
-
</button>
|
|
369
|
-
|
|
370
|
-
<span part="divider" class="Divider"></span>
|
|
371
|
-
|
|
372
|
-
<button
|
|
373
|
-
class="Trigger"
|
|
374
|
-
part="trigger"
|
|
375
|
-
type="button"
|
|
376
|
-
?disabled="${this.disabled}"
|
|
377
|
-
aria-haspopup="menu"
|
|
378
|
-
aria-expanded="${this.#popup.isOpen}"
|
|
379
|
-
aria-controls="${this.#menuId}"
|
|
380
|
-
?data-open="${this.#popup.isOpen || nothing}"
|
|
381
|
-
@click="${this.#onTriggerClick}"
|
|
382
|
-
@keydown="${this.#onTriggerKeyDown}"
|
|
383
|
-
>
|
|
384
|
-
<slot name="icon">
|
|
385
|
-
<dui-icon>
|
|
386
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
|
387
|
-
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
388
|
-
stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
|
|
389
|
-
</dui-icon>
|
|
390
|
-
</slot>
|
|
391
|
-
</button>
|
|
392
|
-
</div>
|
|
393
|
-
`;
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
})();
|
|
397
|
-
export { DuiSplitButton };
|
|
317
|
+
export class DuiSplitButton extends DuiSplitButtonPrimitive {
|
|
318
|
+
static styles = [...DuiSplitButtonPrimitive.styles, styles];
|
|
319
|
+
}
|
|
320
|
+
customElements.define(DuiSplitButton.tagName, DuiSplitButton);
|