@conalog/ds-svelte 0.0.0-stage → 1.0.0-alpha.1

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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/SUPPORT.json +366 -0
  4. package/dist/ActionButton.svelte +11 -0
  5. package/dist/Badge.svelte +49 -0
  6. package/dist/Button.svelte +107 -0
  7. package/dist/Card.svelte +76 -0
  8. package/dist/Checkbox.svelte +60 -0
  9. package/dist/Chip.svelte +133 -0
  10. package/dist/CircularSpinner.svelte +30 -0
  11. package/dist/Divider.svelte +29 -0
  12. package/dist/DsTheme.svelte +14 -0
  13. package/dist/IconButton.svelte +7 -0
  14. package/dist/Menu.svelte +277 -0
  15. package/dist/Modal.svelte +86 -0
  16. package/dist/Navigation.svelte +87 -0
  17. package/dist/PageHeader.svelte +81 -0
  18. package/dist/ScopePicker.svelte +271 -0
  19. package/dist/SearchField.svelte +7 -0
  20. package/dist/SegmentedControl.svelte +154 -0
  21. package/dist/StatusBanner.svelte +48 -0
  22. package/dist/Table.svelte +180 -0
  23. package/dist/Tabs.svelte +121 -0
  24. package/dist/TextField.svelte +122 -0
  25. package/dist/Tooltip.svelte +147 -0
  26. package/dist/button-options.mjs +1 -0
  27. package/dist/button.css +514 -0
  28. package/dist/display.css +47 -0
  29. package/dist/draft-overlay.mjs +67 -0
  30. package/dist/draft.css +248 -0
  31. package/dist/icon-provenance.json +62 -0
  32. package/dist/icons/check/filled.d.mts +3 -0
  33. package/dist/icons/check/filled.mjs +1 -0
  34. package/dist/icons/check/filled.svelte +10 -0
  35. package/dist/icons/check.d.mts +1 -0
  36. package/dist/icons/check.mjs +1 -0
  37. package/dist/icons/headset/filled.d.mts +3 -0
  38. package/dist/icons/headset/filled.mjs +1 -0
  39. package/dist/icons/headset/filled.svelte +10 -0
  40. package/dist/icons/headset.d.mts +1 -0
  41. package/dist/icons/headset.mjs +1 -0
  42. package/dist/icons/notification-bell/filled.d.mts +3 -0
  43. package/dist/icons/notification-bell/filled.mjs +1 -0
  44. package/dist/icons/notification-bell/filled.svelte +10 -0
  45. package/dist/icons/notification-bell-off/filled.d.mts +3 -0
  46. package/dist/icons/notification-bell-off/filled.mjs +1 -0
  47. package/dist/icons/notification-bell-off/filled.svelte +10 -0
  48. package/dist/icons/notification-bell-off.d.mts +1 -0
  49. package/dist/icons/notification-bell-off.mjs +1 -0
  50. package/dist/icons/notification-bell.d.mts +1 -0
  51. package/dist/icons/notification-bell.mjs +1 -0
  52. package/dist/icons/plant/filled.d.mts +3 -0
  53. package/dist/icons/plant/filled.mjs +1 -0
  54. package/dist/icons/plant/filled.svelte +13 -0
  55. package/dist/icons/plant.d.mts +1 -0
  56. package/dist/icons/plant.mjs +1 -0
  57. package/dist/icons/search/outlined.d.mts +3 -0
  58. package/dist/icons/search/outlined.mjs +1 -0
  59. package/dist/icons/search/outlined.svelte +10 -0
  60. package/dist/icons/search.d.mts +1 -0
  61. package/dist/icons/search.mjs +1 -0
  62. package/dist/icons.d.mts +6 -0
  63. package/dist/icons.mjs +6 -0
  64. package/dist/index.d.ts +269 -0
  65. package/dist/index.mjs +21 -0
  66. package/dist/licenses/check/filled.txt +202 -0
  67. package/dist/licenses/headset/filled.txt +21 -0
  68. package/dist/licenses/notification-bell/filled.txt +21 -0
  69. package/dist/licenses/notification-bell-off/filled.txt +21 -0
  70. package/dist/licenses/plant/filled.txt +24 -0
  71. package/dist/licenses/search/outlined.txt +21 -0
  72. package/package.json +58 -4
  73. package/release-source.json +5 -0
@@ -0,0 +1,60 @@
1
+ <script>
2
+ import './display.css';
3
+
4
+ let { label, checked = $bindable(false), disabled = false, showLabel = true,
5
+ name, value = 'on', required = false, checkIcon: CheckIcon } = $props();
6
+ let styling = $derived.by(() => {
7
+ if (typeof label !== 'string' || !label.trim()) throw new TypeError('Checkbox label must contain text');
8
+ if (!CheckIcon) throw new TypeError('Checkbox requires the check icon component');
9
+ return `checkbox-${checked}-${disabled}`;
10
+ });
11
+ </script>
12
+
13
+ <label class={{ disabled, iconOnly: !showLabel }} data-ds-component="checkbox" data-ds-display={styling}>
14
+ <input type="checkbox" bind:checked {disabled} {name} {value} {required} aria-label={showLabel ? undefined : label} />
15
+ <span class="box" aria-hidden="true">{#if checked}<CheckIcon />{/if}</span>
16
+ {#if showLabel}<span class="text">{label}</span>{/if}
17
+ </label>
18
+
19
+ <style>
20
+ label {
21
+ align-items: center;
22
+ cursor: pointer;
23
+ display: inline-flex;
24
+ gap: var(--ds-display-row-column-gap);
25
+ min-block-size: var(--ds-display-row-min-height);
26
+ min-inline-size: var(--ds-display-row-min-height);
27
+ }
28
+ label.disabled { cursor: default; }
29
+ label.iconOnly { justify-content: center; }
30
+ input {
31
+ block-size: 1px;
32
+ clip-path: inset(50%);
33
+ inline-size: 1px;
34
+ margin: 0;
35
+ position: absolute;
36
+ }
37
+ .box {
38
+ align-items: center;
39
+ aspect-ratio: 1;
40
+ background: var(--ds-display-box-background-color);
41
+ border-radius: var(--ds-display-box-border-radius);
42
+ box-shadow: inset 0 0 0 var(--ds-display-box-border-width) var(--ds-display-box-border-color);
43
+ color: var(--ds-display-check-color);
44
+ display: flex;
45
+ flex: 0 0 var(--ds-display-box-width);
46
+ inline-size: var(--ds-display-box-width);
47
+ justify-content: center;
48
+ }
49
+ label:not(.disabled):is(:hover, :active) .box {
50
+ background: var(--ds-display-engaged-background-color);
51
+ box-shadow: inset 0 0 0 var(--ds-display-box-border-width) var(--ds-display-engaged-border-color);
52
+ }
53
+ input:focus-visible + .box { outline: var(--ds-display-box-outline-width) solid var(--ds-display-box-outline-color); }
54
+ .box :global(svg) { block-size: 100%; inline-size: 100%; }
55
+ .text {
56
+ color: var(--ds-display-label-color);
57
+ font: var(--ds-display-label-font-weight) var(--ds-display-label-font-size)/var(--ds-display-label-line-height) var(--ds-display-label-font-family);
58
+ letter-spacing: var(--ds-display-label-letter-spacing);
59
+ }
60
+ </style>
@@ -0,0 +1,133 @@
1
+ <script>
2
+ import './draft.css';
3
+ import Menu from './Menu.svelte';
4
+
5
+ let {
6
+ label, kind = 'toggle', tone = 'neutral', disabled = false, icon: Icon,
7
+ selected = $bindable(false), items = [], selectedId = $bindable(), defaultId, onchange, onselect,
8
+ } = $props();
9
+ let activeItem = $derived(items.find(item => item.id === selectedId));
10
+ let activeFilter = $derived(Boolean(activeItem && selectedId !== defaultId));
11
+ let menuItems = $derived(items.map(item => ({ ...item, kind: 'radio', checked: item.id === selectedId })));
12
+
13
+ function toggle() {
14
+ selected = !selected;
15
+ onchange?.(selected);
16
+ }
17
+
18
+ function choose(id) {
19
+ selectedId = id;
20
+ onselect?.(id);
21
+ }
22
+ </script>
23
+
24
+ {#if kind === 'dropdown'}
25
+ <Menu {label} items={menuItems} {disabled} onselect={choose} size="md">
26
+ {#snippet trigger({ expanded, controls, onclick, onkeydown })}
27
+ <button data-ds-component="chip" data-tone="neutral" class={{ active: activeFilter }}
28
+ type="button" {disabled} aria-haspopup="menu" aria-expanded={expanded} aria-controls={controls}
29
+ {onclick} {onkeydown}>
30
+ <span>{activeFilter ? activeItem.label : label}</span>
31
+ <span class="caret" aria-hidden="true"></span>
32
+ </button>
33
+ {/snippet}
34
+ </Menu>
35
+ {:else}
36
+ <button data-ds-component="chip" data-tone={tone} class={{ active: selected }}
37
+ type="button" aria-pressed={selected} {disabled} onclick={toggle}>
38
+ {#if tone !== 'neutral'}
39
+ <span class="marker" aria-hidden="true"></span>
40
+ {:else if Icon && !selected}
41
+ <span class="icon" aria-hidden="true"><Icon size={14} /></span>
42
+ {/if}
43
+ <span>{label}</span>
44
+ {#if selected}<span class="remove" aria-hidden="true">×</span>{/if}
45
+ </button>
46
+ {/if}
47
+
48
+ <style>
49
+ button {
50
+ --chip-background: var(--ds-draft-bg-layer-floating);
51
+ --chip-hover: var(--ds-draft-bg-layer-floating-pressed);
52
+ --chip-border: var(--ds-draft-stroke-neutral);
53
+ --chip-foreground: var(--ds-draft-fg-neutral);
54
+ box-sizing: border-box;
55
+ appearance: none;
56
+ display: inline-flex;
57
+ align-items: center;
58
+ gap: var(--ds-draft-dimension-x1);
59
+ min-block-size: var(--ds-draft-dimension-x7);
60
+ padding: 0 var(--ds-draft-dimension-x2);
61
+ border: 0;
62
+ border-radius: var(--ds-draft-radius-full);
63
+ background: var(--chip-background);
64
+ box-shadow: inset 0 0 0 1px var(--chip-border);
65
+ color: var(--chip-foreground);
66
+ font: var(--ds-draft-type-body-font-weight) var(--ds-draft-type-body-font-size) / var(--ds-draft-type-body-line-height) var(--ds-draft-type-body-font-family);
67
+ white-space: nowrap;
68
+ cursor: pointer;
69
+ }
70
+ button:not(:disabled):is(:hover, :active) { background: var(--chip-hover); }
71
+ button:focus-visible { outline: 2px solid var(--ds-draft-stroke-neutral-focused); }
72
+ button:disabled { color: var(--ds-draft-fg-disabled); cursor: default; }
73
+ button[data-tone='neutral'].active { box-shadow: inset 0 0 0 1.5px var(--ds-draft-gray-800); }
74
+ button[data-tone='attention'] {
75
+ --chip-background: var(--ds-draft-gray-50);
76
+ --chip-hover: var(--ds-draft-gray-100);
77
+ --chip-foreground: var(--ds-draft-gray-800);
78
+ --chip-marker: var(--ds-draft-gray-500);
79
+ --chip-active: var(--ds-draft-gray-500);
80
+ --chip-active-hover: var(--ds-draft-gray-600);
81
+ }
82
+ button[data-tone='critical'] {
83
+ --chip-background: var(--ds-draft-red-50);
84
+ --chip-hover: var(--ds-draft-red-100);
85
+ --chip-border: var(--ds-draft-stroke-critical);
86
+ --chip-foreground: var(--ds-draft-red-800);
87
+ --chip-marker: var(--ds-draft-red-500);
88
+ --chip-active: var(--ds-draft-bg-critical-solid);
89
+ --chip-active-hover: var(--ds-draft-bg-critical-solid-pressed);
90
+ }
91
+ button[data-tone='warning'] {
92
+ --chip-background: var(--ds-draft-yellow-50);
93
+ --chip-hover: var(--ds-draft-yellow-100);
94
+ --chip-border: var(--ds-draft-stroke-warning);
95
+ --chip-foreground: var(--ds-draft-yellow-900);
96
+ --chip-marker: var(--ds-draft-yellow-400);
97
+ --chip-active: var(--ds-draft-bg-warning-solid);
98
+ --chip-active-hover: var(--ds-draft-bg-warning-solid-pressed);
99
+ }
100
+ button[data-tone='positive'] {
101
+ --chip-background: var(--ds-draft-green-50);
102
+ --chip-hover: var(--ds-draft-green-100);
103
+ --chip-border: var(--ds-draft-stroke-positive);
104
+ --chip-foreground: var(--ds-draft-green-800);
105
+ --chip-marker: var(--ds-draft-green-400);
106
+ --chip-active: var(--ds-draft-bg-positive-solid);
107
+ --chip-active-hover: var(--ds-draft-bg-positive-solid-pressed);
108
+ }
109
+ button:not([data-tone='neutral']).active {
110
+ --chip-background: var(--chip-active);
111
+ --chip-hover: var(--chip-active-hover);
112
+ --chip-foreground: var(--ds-draft-fg-neutral-inverted);
113
+ --chip-marker: currentColor;
114
+ box-shadow: none;
115
+ }
116
+ button:disabled .marker { background: currentColor; }
117
+ .marker {
118
+ inline-size: var(--ds-draft-dimension-x1-5);
119
+ aspect-ratio: 1;
120
+ border-radius: var(--ds-draft-radius-full);
121
+ background: var(--chip-marker);
122
+ }
123
+ .icon { display: flex; }
124
+ .remove { font-size: var(--ds-draft-dimension-x3-5); line-height: 1; }
125
+ .caret {
126
+ inline-size: var(--ds-draft-dimension-x1-5);
127
+ block-size: var(--ds-draft-dimension-x1-5);
128
+ margin-block-start: -2px;
129
+ border-block-end: 1.5px solid currentColor;
130
+ border-inline-end: 1.5px solid currentColor;
131
+ transform: rotate(45deg);
132
+ }
133
+ </style>
@@ -0,0 +1,30 @@
1
+ <script>
2
+ import './display.css';
3
+
4
+ let { active, label } = $props();
5
+ let accessibleName = $derived.by(() => {
6
+ if (active && (typeof label !== 'string' || !label.trim())) throw new TypeError('Circular Spinner requires an accessible name');
7
+ return label;
8
+ });
9
+ </script>
10
+
11
+ {#if active}
12
+ <span role="status" aria-label={accessibleName} data-ds-component="circular-spinner" data-ds-display="circular-spinner">
13
+ <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
14
+ <path d="M8 1 A7 7 0 1 1 1.208 6.306" fill="none" stroke="currentColor" stroke-linecap="round" />
15
+ </svg>
16
+ </span>
17
+ {/if}
18
+
19
+ <style>
20
+ span { display: inline-flex; color: var(--ds-display-ring-color); }
21
+ svg {
22
+ inline-size: var(--ds-display-ring-width);
23
+ block-size: var(--ds-display-ring-height);
24
+ stroke-width: var(--ds-display-ring-border-width);
25
+ }
26
+ @media (prefers-reduced-motion: no-preference) {
27
+ svg { animation: spin 1s linear infinite; }
28
+ }
29
+ @keyframes spin { to { transform: rotate(1turn); } }
30
+ </style>
@@ -0,0 +1,29 @@
1
+ <script>
2
+ import './draft.css';
3
+
4
+ let { orientation = 'horizontal', tone = 'neutral', inset = 'none', decorative = false } = $props();
5
+ const insets = { none: '0px', 'spacing.card-edge': 'var(--ds-draft-spacing-card-edge)',
6
+ 'spacing-x.global-gutter': 'var(--ds-draft-spacing-x-global-gutter)' };
7
+ </script>
8
+
9
+ {#if orientation === 'vertical'}
10
+ <div role="separator" aria-orientation="vertical" aria-hidden={decorative || undefined}
11
+ class={['divider vertical', { weak: tone === 'weak' }]} style:--inset={insets[inset]}></div>
12
+ {:else}
13
+ <hr aria-hidden={decorative || undefined} class={['divider horizontal', { weak: tone === 'weak' }]}
14
+ style:--inset={insets[inset]} />
15
+ {/if}
16
+
17
+ <style>
18
+ .divider {
19
+ flex: none;
20
+ align-self: stretch;
21
+ display: block;
22
+ margin: 0;
23
+ border: 0;
24
+ background: var(--ds-draft-stroke-neutral);
25
+ }
26
+ .weak { background: var(--ds-draft-stroke-neutral-weak); }
27
+ .horizontal { block-size: 1px; margin-inline: var(--inset); }
28
+ .vertical { inline-size: 1px; min-block-size: 1px; margin-block: var(--inset); }
29
+ </style>
@@ -0,0 +1,14 @@
1
+ <script>
2
+ import { getTokens } from '@conalog/ds-core';
3
+ import '@conalog/ds-core/tokens.css';
4
+
5
+ let { theme, children } = $props();
6
+ let selectedTheme = $derived.by(() => {
7
+ getTokens(theme);
8
+ return theme;
9
+ });
10
+ </script>
11
+
12
+ <div data-ds-theme={selectedTheme}>
13
+ {@render children?.()}
14
+ </div>
@@ -0,0 +1,7 @@
1
+ <script>
2
+ import Button from './Button.svelte';
3
+
4
+ let { label, icon, color = 'neutral', variant = 'weak', size = 'md', presentation = 'enabled', onclick } = $props();
5
+ </script>
6
+
7
+ <Button kind="icon-button" {label} {icon} {color} {variant} {size} {presentation} {onclick} />
@@ -0,0 +1,277 @@
1
+ <script>
2
+ import { tick } from 'svelte';
3
+ import './draft.css';
4
+ import { attachOverlay } from './draft-overlay.mjs';
5
+
6
+ const id = $props.id();
7
+ let {
8
+ label, triggerLabel, items, size = 'md', width = 'auto', disabled = false,
9
+ open = $bindable(false), onselect, trigger,
10
+ } = $props();
11
+
12
+ let anchor = $state();
13
+ let wrapper = $state();
14
+ let panel = $state();
15
+ let path = $state([]);
16
+ let current = $derived(path.at(-1)?.children ?? items);
17
+ let groups = $derived.by(() => {
18
+ const result = [];
19
+ for (const item of current) {
20
+ if (!result.length || result.at(-1).label !== item.group) {
21
+ result.push({ label: item.group, items: [] });
22
+ }
23
+ result.at(-1).items.push(item);
24
+ }
25
+ return result;
26
+ });
27
+
28
+ function triggerElement() {
29
+ return anchor ?? wrapper?.querySelector('button');
30
+ }
31
+
32
+ function available() {
33
+ return [...(panel?.querySelectorAll('button[data-menu-item]:not(:disabled)') ?? [])];
34
+ }
35
+
36
+ async function focusItem(last = false, itemId) {
37
+ await tick();
38
+ if (!open) return;
39
+ const buttons = available();
40
+ const button = itemId ? buttons.find(candidate => candidate.dataset.menuItem === itemId)
41
+ : last ? buttons.at(-1) : buttons[0];
42
+ (button ?? panel)?.focus({ preventScroll: true });
43
+ button?.scrollIntoView({ block: 'nearest' });
44
+ }
45
+
46
+ function start(event, enter = false, last = false) {
47
+ if (disabled) return;
48
+ if (!open) path = [];
49
+ anchor = event.currentTarget;
50
+ open = true;
51
+ if (enter) void focusItem(last);
52
+ }
53
+
54
+ function finish(restore = true) {
55
+ if (!open) return;
56
+ open = false;
57
+ path = [];
58
+ if (restore) triggerElement()?.focus({ preventScroll: true });
59
+ }
60
+
61
+ function triggerClick(event) {
62
+ if (open) finish();
63
+ else start(event, event.detail === 0);
64
+ }
65
+
66
+ function triggerKeydown(event) {
67
+ if (disabled) return;
68
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
69
+ event.preventDefault();
70
+ start(event, true, event.key === 'ArrowUp');
71
+ } else if (event.key === 'Escape' && open) {
72
+ event.preventDefault();
73
+ event.stopPropagation();
74
+ finish();
75
+ }
76
+ }
77
+
78
+ function leaveLevel() {
79
+ const previous = path.at(-1);
80
+ path = path.slice(0, -1);
81
+ void focusItem(false, previous.id);
82
+ }
83
+
84
+ function choose(item) {
85
+ if (item.disabled) return;
86
+ if (item.children?.length) {
87
+ path = [...path, item];
88
+ void focusItem();
89
+ return;
90
+ }
91
+ if (item.kind !== 'checkbox') finish();
92
+ onselect?.(item.id, item.kind === 'checkbox' ? !item.checked : item.kind === 'radio' ? true : undefined);
93
+ }
94
+
95
+ function handleKeys(event) {
96
+ const buttons = available();
97
+ let next;
98
+ const index = buttons.indexOf(event.target);
99
+ switch (event.key) {
100
+ case 'Escape':
101
+ finish();
102
+ break;
103
+ case 'ArrowLeft':
104
+ if (!path.length) return;
105
+ leaveLevel();
106
+ break;
107
+ case 'ArrowRight': {
108
+ const item = current.find(candidate => candidate.id === event.target.dataset.menuItem);
109
+ if (!item?.children?.length) return;
110
+ choose(item);
111
+ break;
112
+ }
113
+ case 'Tab':
114
+ setTimeout(() => finish(false), 0);
115
+ return;
116
+ case 'Home': next = buttons[0]; break;
117
+ case 'End': next = buttons.at(-1); break;
118
+ case 'ArrowDown': next = buttons[(index + 1) % buttons.length]; break;
119
+ case 'ArrowUp': next = buttons[(index < 0 ? buttons.length - 1 : (index - 1 + buttons.length) % buttons.length)]; break;
120
+ default: return;
121
+ }
122
+ event.preventDefault();
123
+ event.stopPropagation();
124
+ next?.focus();
125
+ }
126
+
127
+ function handleToggle() {
128
+ if (open && !panel.matches(':popover-open')) finish(false);
129
+ }
130
+
131
+ function dismissOutside(event) {
132
+ if (!open || event.composedPath().includes(wrapper)) return;
133
+ finish(false);
134
+ }
135
+
136
+ </script>
137
+
138
+ <svelte:window onpointerdown={dismissOutside} />
139
+
140
+ <div data-ds-component="menu" class="menu" bind:this={wrapper}>
141
+ {#if trigger}
142
+ {@render trigger({ expanded: open, controls: id, onclick: triggerClick, onkeydown: triggerKeydown })}
143
+ {:else}
144
+ <button class="trigger" type="button" aria-haspopup="menu" aria-expanded={open} aria-controls={id}
145
+ {disabled} onclick={triggerClick} onkeydown={triggerKeydown}>
146
+ {triggerLabel ?? label} <span class="caret" aria-hidden="true"></span>
147
+ </button>
148
+ {/if}
149
+ <div id={id} bind:this={panel}
150
+ {@attach node => attachOverlay(triggerElement(), node, open, {
151
+ emphasizeAnchor: width === 'trigger' ? 'match' : true, onAnchorHidden: () => finish(false),
152
+ })}
153
+ class={['panel', { compact: size === 'sm' }]}
154
+ popover="auto" hidden={!open} role="menu" aria-label={path.at(-1)?.label ?? label} tabindex="-1"
155
+ onkeydown={handleKeys} ontoggle={handleToggle}>
156
+ {#each groups as group, groupIndex (group.items[0].id)}
157
+ {#if groupIndex > 0}<div class="divider" role="separator"></div>{/if}
158
+ <div role="group" aria-labelledby={group.label ? id + '-group-' + groupIndex : undefined}>
159
+ {#if group.label}<div class="group-label" id={id + '-group-' + groupIndex}>{group.label}</div>{/if}
160
+ {#each group.items as item (item.id)}
161
+ <button type="button"
162
+ role={item.kind === 'checkbox' ? 'menuitemcheckbox' : item.kind === 'radio' ? 'menuitemradio' : 'menuitem'}
163
+ aria-checked={item.kind === 'checkbox' || item.kind === 'radio' ? !!item.checked : undefined}
164
+ aria-haspopup={item.children?.length ? 'menu' : undefined}
165
+ aria-expanded={item.children?.length ? false : undefined}
166
+ class={['item', { critical: item.critical, selected: item.kind === 'radio' && item.checked }]}
167
+ disabled={item.disabled} tabindex="-1" data-menu-item={item.id} onclick={() => choose(item)}>
168
+ {#if item.kind === 'checkbox'}
169
+ <span class={['checkbox', { checked: item.checked }]} aria-hidden="true"></span>
170
+ {:else if item.icon}
171
+ <span class="item-icon" aria-hidden="true"><item.icon size={size === 'sm' ? 14 : 16} /></span>
172
+ {/if}
173
+ <span class="item-label">{item.label}</span>
174
+ {#if item.children?.length}<span class="arrow" aria-hidden="true"></span>{/if}
175
+ </button>
176
+ {/each}
177
+ </div>
178
+ {/each}
179
+ </div>
180
+ </div>
181
+
182
+ <style>
183
+ .menu { display: inline-block; max-inline-size: 100%; }
184
+ .trigger, .item {
185
+ font: var(--ds-draft-type-body-font-weight) var(--ds-draft-type-body-font-size) / var(--ds-draft-type-body-line-height) var(--ds-draft-type-body-font-family);
186
+ color: var(--ds-draft-fg-neutral);
187
+ }
188
+ .trigger {
189
+ display: inline-flex;
190
+ align-items: center;
191
+ gap: var(--ds-draft-dimension-x2);
192
+ min-block-size: var(--ds-draft-dimension-x8);
193
+ padding-inline: var(--ds-draft-dimension-x2);
194
+ border: 1px solid var(--ds-draft-stroke-neutral);
195
+ border-radius: var(--ds-draft-radius-r2);
196
+ background: var(--ds-draft-bg-layer-floating);
197
+ cursor: pointer;
198
+ text-align: start;
199
+ }
200
+ .trigger:not(:disabled):is(:hover, [aria-expanded='true']) { background: var(--ds-draft-bg-layer-floating-pressed); }
201
+ :is(.trigger, .item):focus-visible { outline: 2px solid var(--ds-draft-stroke-neutral-focused); outline-offset: -2px; }
202
+ :is(.trigger, .item):disabled { color: var(--ds-draft-fg-disabled); cursor: default; }
203
+ .panel {
204
+ position: fixed;
205
+ z-index: 10;
206
+ inset: auto;
207
+ margin: 0;
208
+ box-sizing: border-box;
209
+ overflow: auto;
210
+ overscroll-behavior: contain;
211
+ inline-size: max-content;
212
+ padding: var(--ds-draft-dimension-x1);
213
+ border: 1px solid var(--ds-draft-stroke-neutral);
214
+ border-radius: var(--ds-draft-radius-r3);
215
+ background: var(--ds-draft-bg-layer-floating);
216
+ box-shadow: var(--ds-draft-shadow-s2);
217
+ }
218
+ .panel[hidden] { display: none; }
219
+ .item {
220
+ display: flex;
221
+ align-items: center;
222
+ gap: var(--ds-draft-dimension-x2);
223
+ inline-size: 100%;
224
+ min-block-size: var(--ds-draft-dimension-x8);
225
+ padding: 0 var(--ds-draft-dimension-x2);
226
+ border: 0;
227
+ border-radius: var(--ds-draft-radius-r2);
228
+ text-align: start;
229
+ background: transparent;
230
+ cursor: pointer;
231
+ }
232
+ .compact .item { min-block-size: var(--ds-draft-dimension-x7); }
233
+ .item:not(:disabled):is(:hover, :active) { background: var(--ds-draft-bg-layer-floating-pressed); }
234
+ .item.critical:not(:disabled) { color: var(--ds-draft-fg-critical-contrast); }
235
+ .item.selected:not(:disabled) { color: var(--ds-draft-primary-500); background: var(--ds-draft-primary-50); }
236
+ .item.selected:not(:disabled):is(:hover, :active) { background: var(--ds-draft-bg-primary-weak); }
237
+ .item-icon { display: flex; color: var(--ds-draft-fg-neutral-muted); }
238
+ .item:is(.critical, .selected, :disabled) .item-icon { color: inherit; }
239
+ .item-label { overflow-wrap: anywhere; }
240
+ .caret, .arrow {
241
+ flex: none;
242
+ inline-size: var(--ds-draft-dimension-x1-5);
243
+ block-size: var(--ds-draft-dimension-x1-5);
244
+ border-block-end: 1.5px solid currentColor;
245
+ border-inline-end: 1.5px solid currentColor;
246
+ transform: rotate(45deg);
247
+ }
248
+ .arrow { transform: rotate(-45deg); margin-inline-start: auto; }
249
+ .arrow:dir(rtl) { transform: rotate(45deg); }
250
+ .checkbox {
251
+ position: relative;
252
+ flex: none;
253
+ box-sizing: border-box;
254
+ inline-size: var(--ds-draft-dimension-x4);
255
+ aspect-ratio: 1;
256
+ border: 1px solid var(--ds-draft-stroke-neutral);
257
+ border-radius: var(--ds-draft-radius-r1);
258
+ background: var(--ds-draft-bg-layer-floating);
259
+ }
260
+ .checkbox.checked { border-color: transparent; background: var(--ds-draft-bg-primary-solid); }
261
+ .checkbox.checked::after {
262
+ content: '';
263
+ position: absolute;
264
+ inset: 21% 27% 28% 33%;
265
+ transform: rotate(45deg);
266
+ border: solid var(--ds-draft-fg-neutral-inverted);
267
+ border-width: 0 1.5px 1.5px 0;
268
+ }
269
+ .item:disabled .checkbox { background: var(--ds-draft-bg-neutral-weak); }
270
+ .item:disabled .checkbox.checked { background: var(--ds-draft-fg-disabled); }
271
+ .divider { height: 1px; margin: var(--ds-draft-dimension-x1) var(--ds-draft-dimension-x2); background: var(--ds-draft-stroke-neutral); }
272
+ .group-label {
273
+ padding: var(--ds-draft-dimension-x2) var(--ds-draft-dimension-x2) var(--ds-draft-dimension-x1);
274
+ color: var(--ds-draft-fg-neutral-subtle);
275
+ font: var(--ds-draft-type-sub-font-weight) var(--ds-draft-type-sub-font-size) / var(--ds-draft-type-sub-line-height) var(--ds-draft-type-sub-font-family);
276
+ }
277
+ </style>
@@ -0,0 +1,86 @@
1
+ <script>
2
+ import './draft.css';
3
+
4
+ const heading = $props.id();
5
+ let { title, open = $bindable(false), closeLabel = '닫기', children, footer, onclose } = $props();
6
+ function syncDialog(dialog, show) {
7
+ if (show && !dialog.open) dialog.showModal();
8
+ if (!show && dialog.open) dialog.close();
9
+ }
10
+
11
+ function handleClose(event) {
12
+ const dialog = event.currentTarget;
13
+ if (dialog.open) return;
14
+ dialog.returnValue = '';
15
+ open = false;
16
+ onclose?.();
17
+ }
18
+ </script>
19
+
20
+ <dialog data-ds-component="modal" aria-labelledby={heading}
21
+ {@attach dialog => syncDialog(dialog, open)} onclose={handleClose}>
22
+ <header>
23
+ <h2 id={heading}>{title}</h2>
24
+ <button type="button" aria-label={closeLabel} onclick={(event) => event.currentTarget.closest('dialog')?.close()}>
25
+ <span aria-hidden="true">×</span>
26
+ </button>
27
+ </header>
28
+ <div class="body">{@render children()}</div>
29
+ {#if footer}<footer>{@render footer()}</footer>{/if}
30
+ </dialog>
31
+
32
+ <style>
33
+ dialog {
34
+ box-sizing: border-box;
35
+ padding: 0;
36
+ inline-size: max-content;
37
+ min-inline-size: min(18rem, calc(100% - var(--ds-draft-dimension-x8)));
38
+ max-inline-size: calc(100% - var(--ds-draft-dimension-x8));
39
+ max-block-size: calc(100% - var(--ds-draft-dimension-x8));
40
+ overflow: hidden;
41
+ border: 0;
42
+ border-radius: var(--ds-draft-radius-r5);
43
+ color: var(--ds-draft-fg-neutral);
44
+ background: var(--ds-draft-bg-layer-floating);
45
+ box-shadow: var(--ds-draft-shadow-s3);
46
+ font-family: var(--ds-draft-type-body-font-family);
47
+ }
48
+ dialog[open] { display: flex; flex-direction: column; }
49
+ dialog:modal { margin: auto; overscroll-behavior: contain; }
50
+ dialog::backdrop {
51
+ background: color-mix(in srgb, var(--ds-draft-gray-900) 40%, transparent);
52
+ overflow: hidden;
53
+ overscroll-behavior: contain;
54
+ }
55
+ header, footer { flex: none; padding: var(--ds-draft-dimension-x4); }
56
+ header {
57
+ display: flex;
58
+ align-items: center;
59
+ justify-content: space-between;
60
+ gap: var(--ds-draft-dimension-x4);
61
+ border-block-end: 1px solid var(--ds-draft-stroke-neutral-weak);
62
+ }
63
+ footer { border-block-start: 1px solid var(--ds-draft-stroke-neutral-weak); }
64
+ h2 {
65
+ margin: 0;
66
+ color: var(--ds-draft-fg-neutral-contrast);
67
+ font-size: var(--ds-draft-type-title-font-size);
68
+ font-weight: var(--ds-draft-type-title-font-weight);
69
+ }
70
+ button {
71
+ display: grid;
72
+ place-items: center;
73
+ inline-size: var(--ds-draft-dimension-x8);
74
+ block-size: var(--ds-draft-dimension-x8);
75
+ border: 0;
76
+ border-radius: var(--ds-draft-radius-r2);
77
+ background: var(--ds-draft-bg-neutral-weak);
78
+ color: var(--ds-draft-fg-neutral);
79
+ cursor: pointer;
80
+ font: inherit;
81
+ font-size: var(--ds-draft-dimension-x5);
82
+ }
83
+ button:hover { background: var(--ds-draft-bg-neutral-weak-pressed); }
84
+ button:focus-visible { outline: 2px solid var(--ds-draft-stroke-neutral-focused); }
85
+ .body { overflow: auto; overscroll-behavior: contain; padding: var(--ds-draft-dimension-x4); }
86
+ </style>