dssoca 0.20.0 → 0.22.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 +3 -3
- package/dist/components/Accordion.svelte +23 -52
- package/dist/components/BottomNav.svelte +18 -28
- package/dist/components/BoxPlot.svelte +7 -6
- package/dist/components/BumpChart.svelte +9 -12
- package/dist/components/Chart.svelte +9 -12
- package/dist/components/Checkbox.svelte +210 -0
- package/dist/components/Checkbox.svelte.d.ts +38 -0
- package/dist/components/FileDrop.svelte +52 -83
- package/dist/components/FileDrop.svelte.d.ts +6 -2
- package/dist/components/Heatmap.svelte +8 -8
- package/dist/components/Image.svelte +44 -44
- package/dist/components/Input.svelte +8 -3
- package/dist/components/LogStream.svelte +15 -25
- package/dist/components/Menu.svelte +69 -94
- package/dist/components/Menu.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +61 -14
- package/dist/components/Modal.svelte.d.ts +7 -2
- package/dist/components/NumberField.svelte +18 -19
- package/dist/components/Pagination.svelte +47 -37
- package/dist/components/Pagination.svelte.d.ts +6 -2
- package/dist/components/Popover.svelte +404 -0
- package/dist/components/Popover.svelte.d.ts +55 -0
- package/dist/components/RadioGroup.svelte +227 -0
- package/dist/components/RadioGroup.svelte.d.ts +42 -0
- package/dist/components/ScatterPlot.svelte +11 -13
- package/dist/components/SearchPalette.svelte +124 -120
- package/dist/components/SearchPalette.svelte.d.ts +6 -4
- package/dist/components/SegmentedControl.svelte +41 -62
- package/dist/components/SegmentedControl.svelte.d.ts +7 -2
- package/dist/components/ShortcutsHelp.svelte +48 -47
- package/dist/components/Sidebar.svelte +48 -60
- package/dist/components/Switch.svelte +20 -10
- package/dist/components/Switch.svelte.d.ts +6 -2
- package/dist/components/Table.svelte +15 -37
- package/dist/components/Tabs.svelte +223 -0
- package/dist/components/Tabs.svelte.d.ts +51 -0
- package/dist/components/TierList.svelte +41 -38
- package/dist/components/TierList.svelte.d.ts +7 -3
- package/dist/components/Toaster.svelte +29 -29
- package/dist/components/Tooltip.svelte +37 -21
- package/dist/components/Topbar.svelte +13 -38
- package/dist/core/accordion.d.ts +32 -0
- package/dist/core/accordion.js +53 -0
- package/dist/core/behaviors/focusable.d.ts +5 -0
- package/dist/core/behaviors/focusable.js +14 -0
- package/dist/core/behaviors/roving.d.ts +13 -0
- package/dist/core/behaviors/roving.js +29 -0
- package/dist/core/bottom-nav.d.ts +36 -0
- package/dist/core/bottom-nav.js +33 -0
- package/dist/core/chart-nav.d.ts +53 -0
- package/dist/{chart-nav.js → core/chart-nav.js} +27 -0
- package/dist/core/checkbox.d.ts +36 -0
- package/dist/core/checkbox.js +29 -0
- package/dist/core/file-drop.d.ts +75 -0
- package/dist/core/file-drop.js +101 -0
- package/dist/core/image.d.ts +59 -0
- package/dist/core/image.js +64 -0
- package/dist/core/input.d.ts +21 -0
- package/dist/core/input.js +17 -0
- package/dist/core/log-stream.d.ts +51 -0
- package/dist/core/log-stream.js +50 -0
- package/dist/core/menu.d.ts +70 -0
- package/dist/core/menu.js +84 -0
- package/dist/core/modal.d.ts +59 -0
- package/dist/core/modal.js +44 -0
- package/dist/core/number-field.d.ts +47 -0
- package/dist/core/number-field.js +64 -0
- package/dist/core/pagination.d.ts +59 -0
- package/dist/core/pagination.js +65 -0
- package/dist/core/popover.d.ts +111 -0
- package/dist/core/popover.js +86 -0
- package/dist/core/radio.d.ts +36 -0
- package/dist/core/radio.js +48 -0
- package/dist/core/search-palette.d.ts +124 -0
- package/dist/core/search-palette.js +149 -0
- package/dist/core/segmented.d.ts +46 -0
- package/dist/core/segmented.js +66 -0
- package/dist/core/shortcuts-help.d.ts +56 -0
- package/dist/core/shortcuts-help.js +50 -0
- package/dist/core/sidebar.d.ts +63 -0
- package/dist/core/sidebar.js +84 -0
- package/dist/core/switch.d.ts +19 -0
- package/dist/core/switch.js +11 -0
- package/dist/core/table.d.ts +40 -0
- package/dist/core/table.js +57 -0
- package/dist/core/tabs.d.ts +84 -0
- package/dist/core/tabs.js +90 -0
- package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +62 -0
- package/dist/{tierlist-core.js → core/tierlist.js} +34 -0
- package/dist/core/toast.d.ts +112 -0
- package/dist/{toast-core.js → core/toast.js} +48 -2
- package/dist/core/tooltip.d.ts +47 -0
- package/dist/core/tooltip.js +51 -0
- package/dist/core/topbar.d.ts +41 -0
- package/dist/core/topbar.js +52 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +4 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +9 -1
- package/dist/theme.css +47 -0
- package/dist/toast.svelte.d.ts +2 -2
- package/dist/toast.svelte.js +1 -1
- package/dist/tokens.css +47 -0
- package/dist/vanilla/accordion.js +28 -29
- package/dist/vanilla/checkbox.d.ts +8 -0
- package/dist/vanilla/checkbox.js +43 -0
- package/dist/vanilla/delegate.d.ts +2 -0
- package/dist/vanilla/delegate.js +9 -0
- package/dist/vanilla/fields.js +37 -32
- package/dist/vanilla/index.d.ts +4 -0
- package/dist/vanilla/index.js +16 -3
- package/dist/vanilla/menu.js +92 -86
- package/dist/vanilla/modal.d.ts +3 -1
- package/dist/vanilla/modal.js +65 -15
- package/dist/vanilla/popover.d.ts +10 -0
- package/dist/vanilla/popover.js +199 -0
- package/dist/vanilla/radio.d.ts +3 -0
- package/dist/vanilla/radio.js +54 -0
- package/dist/vanilla/segmented.js +49 -51
- package/dist/vanilla/switch.d.ts +2 -1
- package/dist/vanilla/switch.js +13 -8
- package/dist/vanilla/tabs.d.ts +2 -0
- package/dist/vanilla/tabs.js +87 -0
- package/dist/vanilla/tierlist.d.ts +1 -1
- package/dist/vanilla/tierlist.js +32 -25
- package/dist/vanilla/toast.d.ts +2 -2
- package/dist/vanilla/toast.js +16 -14
- package/dist/vanilla/tooltip.js +35 -23
- package/dist/vanilla.css +364 -42
- package/package.json +1 -1
- package/dist/chart-nav.d.ts +0 -13
- package/dist/toast-core.d.ts +0 -61
package/dist/dssoca.config.js
CHANGED
|
@@ -77,6 +77,7 @@ export const COMPONENT_NAMES = [
|
|
|
77
77
|
'Button',
|
|
78
78
|
'Card',
|
|
79
79
|
'Chart',
|
|
80
|
+
'Checkbox',
|
|
80
81
|
'Container',
|
|
81
82
|
'DateField',
|
|
82
83
|
'EmptyState',
|
|
@@ -93,6 +94,8 @@ export const COMPONENT_NAMES = [
|
|
|
93
94
|
'Modal',
|
|
94
95
|
'NumberField',
|
|
95
96
|
'Pagination',
|
|
97
|
+
'Popover',
|
|
98
|
+
'RadioGroup',
|
|
96
99
|
'SearchPalette',
|
|
97
100
|
'SegmentedControl',
|
|
98
101
|
'Select',
|
|
@@ -102,6 +105,7 @@ export const COMPONENT_NAMES = [
|
|
|
102
105
|
'Spinner',
|
|
103
106
|
'Switch',
|
|
104
107
|
'Table',
|
|
108
|
+
'Tabs',
|
|
105
109
|
'Textarea',
|
|
106
110
|
'TierList',
|
|
107
111
|
'Toaster',
|
package/dist/index.d.ts
CHANGED
|
@@ -19,9 +19,11 @@ export { default as LogStream, type LogLevel, type LogLine } from './components/
|
|
|
19
19
|
export { default as Toaster } from './components/Toaster.svelte';
|
|
20
20
|
export { default as EmptyState } from './components/EmptyState.svelte';
|
|
21
21
|
export { default as Menu, type MenuItem } from './components/Menu.svelte';
|
|
22
|
+
export type { MenuReason, MenuOpenChangeDetails } from './core/menu.js';
|
|
22
23
|
export { default as Accordion, type AccordionItem } from './components/Accordion.svelte';
|
|
23
24
|
export { default as Link } from './components/Link.svelte';
|
|
24
25
|
export { default as SegmentedControl, type SegmentOption, } from './components/SegmentedControl.svelte';
|
|
26
|
+
export type { SegmentedReason, SegmentedChangeDetails } from './core/segmented.js';
|
|
25
27
|
export { default as BottomNav, type BottomNavItem } from './components/BottomNav.svelte';
|
|
26
28
|
export { default as Image, type ImageSource } from './components/Image.svelte';
|
|
27
29
|
export { default as Heading } from './components/Heading.svelte';
|
|
@@ -34,20 +36,31 @@ export { default as Table, type TableColumn, type TableSort } from './components
|
|
|
34
36
|
export { default as Select } from './components/Select.svelte';
|
|
35
37
|
export type { SelectOption, SelectOptGroup } from './components/Select.svelte';
|
|
36
38
|
export { default as Modal } from './components/Modal.svelte';
|
|
39
|
+
export type { ModalReason, ModalCloseDetails } from './core/modal.js';
|
|
37
40
|
export { default as DateField } from './components/DateField.svelte';
|
|
38
41
|
export { default as FileDrop } from './components/FileDrop.svelte';
|
|
42
|
+
export type { FileDropReason, FileDropChangeDetails } from './core/file-drop.js';
|
|
39
43
|
export { default as NumberField } from './components/NumberField.svelte';
|
|
40
44
|
export { default as Tooltip } from './components/Tooltip.svelte';
|
|
41
45
|
export { default as Avatar } from './components/Avatar.svelte';
|
|
42
46
|
export { default as Pagination } from './components/Pagination.svelte';
|
|
47
|
+
export type { PaginationReason, PaginationChangeDetails } from './core/pagination.js';
|
|
43
48
|
export { default as Switch } from './components/Switch.svelte';
|
|
49
|
+
export type { SwitchReason, SwitchChangeDetails } from './core/switch.js';
|
|
44
50
|
export { default as SearchPalette, type SearchPaletteItem } from './components/SearchPalette.svelte';
|
|
51
|
+
export type { SearchPaletteReason, SearchPaletteOpenDetails } from './core/search-palette.js';
|
|
45
52
|
export { default as ScatterPlot, type ScatterPoint } from './components/ScatterPlot.svelte';
|
|
46
53
|
export { default as BoxPlot, type BoxGroup } from './components/BoxPlot.svelte';
|
|
47
54
|
export { default as BumpChart, type BumpSeries } from './components/BumpChart.svelte';
|
|
48
55
|
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
49
56
|
export { default as TierList } from './components/TierList.svelte';
|
|
50
|
-
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, type TierListTier, type TierListItem, type TierListPlacements, } from './tierlist
|
|
57
|
+
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, type TierListTier, type TierListItem, type TierListPlacements, type TierListChangeDetails, type TierListChangeReason, } from './core/tierlist.js';
|
|
58
|
+
export { default as Checkbox } from './components/Checkbox.svelte';
|
|
59
|
+
export { default as RadioGroup, type RadioOption } from './components/RadioGroup.svelte';
|
|
60
|
+
export { default as Tabs, type TabItem } from './components/Tabs.svelte';
|
|
61
|
+
export type { TabsReason, TabsActivation, TabsChangeDetails } from './core/tabs.js';
|
|
62
|
+
export { default as Popover } from './components/Popover.svelte';
|
|
63
|
+
export type { PopoverReason, PopoverOpenChangeDetails, PopoverOpenOn } from './core/popover.js';
|
|
51
64
|
export { default as Kbd } from './components/Kbd.svelte';
|
|
52
65
|
export { default as ShortcutsHelp } from './components/ShortcutsHelp.svelte';
|
|
53
66
|
export { shortcuts, shortcut, formatShortcut, ariaKeyshortcuts, type ShortcutOptions, type ShortcutInfo, type ShortcutOverride, type ShortcutOverrides, type ShortcutScope, type ShortcutPlatform, type ShortcutFormat, type FormatShortcutOptions, } from './shortcuts.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,15 @@ export { default as BumpChart } from './components/BumpChart.svelte';
|
|
|
55
55
|
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
56
56
|
// TierList (DS-0159): ranked rows + tray with pointer and keyboard sorting.
|
|
57
57
|
export { default as TierList } from './components/TierList.svelte';
|
|
58
|
-
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, } from './tierlist
|
|
58
|
+
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, } from './core/tierlist.js';
|
|
59
|
+
// Checkbox (DS-0197): native checkbox with a mixed state.
|
|
60
|
+
export { default as Checkbox } from './components/Checkbox.svelte';
|
|
61
|
+
// RadioGroup (DS-0197): native radios in a named radiogroup.
|
|
62
|
+
export { default as RadioGroup } from './components/RadioGroup.svelte';
|
|
63
|
+
// Tabs (DS-0197): WAI-ARIA tablist + panels.
|
|
64
|
+
export { default as Tabs } from './components/Tabs.svelte';
|
|
65
|
+
// Popover (DS-0197): non-modal floating panel anchored to a trigger.
|
|
66
|
+
export { default as Popover } from './components/Popover.svelte';
|
|
59
67
|
// Keyboard-shortcuts feature (DS-0135): registry core + display chip.
|
|
60
68
|
export { default as Kbd } from './components/Kbd.svelte';
|
|
61
69
|
export { default as ShortcutsHelp } from './components/ShortcutsHelp.svelte';
|
package/dist/theme.css
CHANGED
|
@@ -636,6 +636,53 @@
|
|
|
636
636
|
--ss-tier-gap: var(--ss-s-2);
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
+
:root,
|
|
640
|
+
[data-size-variant=md] {
|
|
641
|
+
--ss-tabs-font: var(--ss-ui-md);
|
|
642
|
+
--ss-tabs-py: 9px;
|
|
643
|
+
--ss-tabs-px: 14px;
|
|
644
|
+
--ss-tabs-gap: 8px;
|
|
645
|
+
--ss-tabs-panel-py: 16px;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
[data-size-variant=sm] {
|
|
649
|
+
--ss-tabs-font: var(--ss-ui-sm);
|
|
650
|
+
--ss-tabs-py: 5px;
|
|
651
|
+
--ss-tabs-px: 10px;
|
|
652
|
+
--ss-tabs-gap: 6px;
|
|
653
|
+
--ss-tabs-panel-py: 10px;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
[data-size-variant=lg] {
|
|
657
|
+
--ss-tabs-font: var(--ss-ui-lg);
|
|
658
|
+
--ss-tabs-py: 12px;
|
|
659
|
+
--ss-tabs-px: 18px;
|
|
660
|
+
--ss-tabs-gap: 10px;
|
|
661
|
+
--ss-tabs-panel-py: 20px;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
:root,
|
|
665
|
+
[data-size-variant=md] {
|
|
666
|
+
--ss-popover-pad: 14px;
|
|
667
|
+
--ss-popover-min-w: 200px;
|
|
668
|
+
--ss-popover-max-w: 340px;
|
|
669
|
+
--ss-popover-offset: 6px;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
[data-size-variant=sm] {
|
|
673
|
+
--ss-popover-pad: 10px;
|
|
674
|
+
--ss-popover-min-w: 160px;
|
|
675
|
+
--ss-popover-max-w: 280px;
|
|
676
|
+
--ss-popover-offset: 5px;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
[data-size-variant=lg] {
|
|
680
|
+
--ss-popover-pad: 18px;
|
|
681
|
+
--ss-popover-min-w: 240px;
|
|
682
|
+
--ss-popover-max-w: 400px;
|
|
683
|
+
--ss-popover-offset: 8px;
|
|
684
|
+
}
|
|
685
|
+
|
|
639
686
|
html {
|
|
640
687
|
font-family: var(--ss-font-body);
|
|
641
688
|
font-size: clamp(16px, 1vw + 12px, 20px);
|
package/dist/toast.svelte.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from './toast
|
|
2
|
-
export type { Toast, ToastKind, ToastAction, ToastOptions, ToastPatch, PromiseMessages, } from './toast
|
|
1
|
+
import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from './core/toast.js';
|
|
2
|
+
export type { Toast, ToastKind, ToastAction, ToastOptions, ToastPatch, PromiseMessages, } from './core/toast.js';
|
|
3
3
|
/**
|
|
4
4
|
* Module-singleton toast store (Svelte 5 runes). One instance is shared by
|
|
5
5
|
* every consumer of the package, so `toast.success(...)` from anywhere shows
|
package/dist/toast.svelte.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from './toast
|
|
1
|
+
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from './core/toast.js';
|
|
2
2
|
/**
|
|
3
3
|
* Module-singleton toast store (Svelte 5 runes). One instance is shared by
|
|
4
4
|
* every consumer of the package, so `toast.success(...)` from anywhere shows
|
package/dist/tokens.css
CHANGED
|
@@ -620,3 +620,50 @@
|
|
|
620
620
|
--ss-tier-label-font: var(--ss-size-h3);
|
|
621
621
|
--ss-tier-gap: var(--ss-s-2);
|
|
622
622
|
}
|
|
623
|
+
|
|
624
|
+
:root,
|
|
625
|
+
[data-size-variant=md] {
|
|
626
|
+
--ss-tabs-font: var(--ss-ui-md);
|
|
627
|
+
--ss-tabs-py: 9px;
|
|
628
|
+
--ss-tabs-px: 14px;
|
|
629
|
+
--ss-tabs-gap: 8px;
|
|
630
|
+
--ss-tabs-panel-py: 16px;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
[data-size-variant=sm] {
|
|
634
|
+
--ss-tabs-font: var(--ss-ui-sm);
|
|
635
|
+
--ss-tabs-py: 5px;
|
|
636
|
+
--ss-tabs-px: 10px;
|
|
637
|
+
--ss-tabs-gap: 6px;
|
|
638
|
+
--ss-tabs-panel-py: 10px;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
[data-size-variant=lg] {
|
|
642
|
+
--ss-tabs-font: var(--ss-ui-lg);
|
|
643
|
+
--ss-tabs-py: 12px;
|
|
644
|
+
--ss-tabs-px: 18px;
|
|
645
|
+
--ss-tabs-gap: 10px;
|
|
646
|
+
--ss-tabs-panel-py: 20px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
:root,
|
|
650
|
+
[data-size-variant=md] {
|
|
651
|
+
--ss-popover-pad: 14px;
|
|
652
|
+
--ss-popover-min-w: 200px;
|
|
653
|
+
--ss-popover-max-w: 340px;
|
|
654
|
+
--ss-popover-offset: 6px;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
[data-size-variant=sm] {
|
|
658
|
+
--ss-popover-pad: 10px;
|
|
659
|
+
--ss-popover-min-w: 160px;
|
|
660
|
+
--ss-popover-max-w: 280px;
|
|
661
|
+
--ss-popover-offset: 5px;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
[data-size-variant=lg] {
|
|
665
|
+
--ss-popover-pad: 18px;
|
|
666
|
+
--ss-popover-min-w: 240px;
|
|
667
|
+
--ss-popover-max-w: 400px;
|
|
668
|
+
--ss-popover-offset: 8px;
|
|
669
|
+
}
|
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
* `aria-controls`, mirroring Accordion.svelte: single-open by default (opening one closes the
|
|
4
4
|
* others), `data-ss-multiple` on the root allows several, Arrow/Home/End rove between headers.
|
|
5
5
|
* Emits `ss:change` on the root with `{ value }` (open ids: string | string[] | undefined).
|
|
6
|
+
* The behaviour itself comes from `../core/accordion.js`, shared with the Svelte component
|
|
7
|
+
* (DS-0197): this file reads the state from the DOM, asks the core, and writes the result back.
|
|
6
8
|
*/
|
|
7
|
-
import { on, emit,
|
|
9
|
+
import { on, emit, all, byId } from './delegate.js';
|
|
10
|
+
import { accordionHeaderAttrs, accordionHeaderKey, accordionToggle, accordionValue, } from '../core/accordion.js';
|
|
8
11
|
const HEAD = '.ss-accordion .head[aria-controls]';
|
|
12
|
+
/** The root's own headers (not those of a nested accordion), in DOM order. */
|
|
13
|
+
function heads(root) {
|
|
14
|
+
return all(root, '.head[aria-controls]').filter((h) => h.closest('.ss-accordion') === root);
|
|
15
|
+
}
|
|
16
|
+
const isOpen = (head) => head.getAttribute('aria-expanded') === 'true';
|
|
17
|
+
/** A section's id on the plain-HTML path is its panel id (`aria-controls`). */
|
|
18
|
+
const idOf = (head) => head.getAttribute('aria-controls');
|
|
9
19
|
function setOpen(head, open) {
|
|
10
|
-
head.setAttribute('aria-expanded',
|
|
20
|
+
head.setAttribute('aria-expanded', accordionHeaderAttrs(open)['aria-expanded']);
|
|
11
21
|
head.closest('.item')?.classList.toggle('open', open);
|
|
12
22
|
const panel = byId(head.getAttribute('aria-controls'));
|
|
13
23
|
if (!panel)
|
|
@@ -18,23 +28,20 @@ function setOpen(head, open) {
|
|
|
18
28
|
panel.toggleAttribute('inert', !open);
|
|
19
29
|
}
|
|
20
30
|
export function toggleAccordion(head) {
|
|
21
|
-
if (head.getAttribute('aria-disabled') === 'true')
|
|
22
|
-
return;
|
|
23
31
|
const root = head.closest('.ss-accordion');
|
|
24
32
|
if (!root)
|
|
25
33
|
return;
|
|
26
34
|
const multiple = root.hasAttribute('data-ss-multiple');
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
emit(root, 'ss:change', { value: multiple ? openIds : openIds[0] });
|
|
35
|
+
const list = heads(root);
|
|
36
|
+
// The DOM is the store: read the open ids, ask the core, write the result back.
|
|
37
|
+
const next = accordionToggle({ open: list.filter(isOpen).map(idOf), multiple }, idOf(head), head.getAttribute('aria-disabled') === 'true');
|
|
38
|
+
if (!next)
|
|
39
|
+
return;
|
|
40
|
+
for (const h of list)
|
|
41
|
+
setOpen(h, next.includes(idOf(h)));
|
|
42
|
+
// Reported in DOM order, whatever order the sections were opened in.
|
|
43
|
+
const openIds = list.map(idOf).filter((id) => next.includes(id));
|
|
44
|
+
emit(root, 'ss:change', { value: accordionValue(openIds, multiple) });
|
|
38
45
|
}
|
|
39
46
|
export function installAccordion() {
|
|
40
47
|
on('click', HEAD, (head) => toggleAccordion(head));
|
|
@@ -42,20 +49,12 @@ export function installAccordion() {
|
|
|
42
49
|
const root = head.closest('.ss-accordion');
|
|
43
50
|
if (!root)
|
|
44
51
|
return;
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
if (e.key === 'ArrowDown')
|
|
49
|
-
target = wrap(i + 1, heads.length);
|
|
50
|
-
else if (e.key === 'ArrowUp')
|
|
51
|
-
target = wrap(i - 1, heads.length);
|
|
52
|
-
else if (e.key === 'Home')
|
|
53
|
-
target = 0;
|
|
54
|
-
else if (e.key === 'End')
|
|
55
|
-
target = heads.length - 1;
|
|
56
|
-
if (target < 0)
|
|
52
|
+
const list = heads(root);
|
|
53
|
+
const result = accordionHeaderKey(list.length, list.indexOf(head), e.key);
|
|
54
|
+
if (!result)
|
|
57
55
|
return;
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
if (result.preventDefault)
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
list[result.focus]?.focus();
|
|
60
59
|
});
|
|
61
60
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Write a state to a checkbox (property + `data-indeterminate`). Emits nothing. */
|
|
2
|
+
export declare function setCheckbox(input: HTMLInputElement, state: {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
indeterminate?: boolean;
|
|
5
|
+
}): void;
|
|
6
|
+
/** Copy `data-indeterminate="true"` onto the `indeterminate` property under `root`. */
|
|
7
|
+
export declare function mountCheckboxes(root?: ParentNode): void;
|
|
8
|
+
export declare function installCheckbox(): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox (DS-0197) — `.ss-checkbox .input[type=checkbox]` is a native checkbox, so toggling,
|
|
3
|
+
* Space, label presses and form submission need no script. This module adds what HTML cannot
|
|
4
|
+
* express: the mixed state (`data-indeterminate="true"` on the input → the `indeterminate`
|
|
5
|
+
* property, applied by `mount()`), the shared rule that a mixed checkbox toggles to checked, and
|
|
6
|
+
* an `ss:change` event on the root with `{ checked }`. No `reason`: the browser reports a press
|
|
7
|
+
* on the box, on the label and Space as the same `change` event. The decision comes from
|
|
8
|
+
* `../core/checkbox.js`, shared with the Svelte component; state is read from the DOM.
|
|
9
|
+
*/
|
|
10
|
+
import { on, emit, all, setAttrs } from './delegate.js';
|
|
11
|
+
import { checkboxInputAttrs, checkboxToggle } from '../core/checkbox.js';
|
|
12
|
+
const INPUT = '.ss-checkbox .input[type="checkbox"]';
|
|
13
|
+
/** Write a state to a checkbox (property + `data-indeterminate`). Emits nothing. */
|
|
14
|
+
export function setCheckbox(input, state) {
|
|
15
|
+
if (state.checked !== undefined)
|
|
16
|
+
input.checked = state.checked;
|
|
17
|
+
if (state.indeterminate !== undefined) {
|
|
18
|
+
input.indeterminate = state.indeterminate;
|
|
19
|
+
setAttrs(input, checkboxInputAttrs(state.indeterminate));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Copy `data-indeterminate="true"` onto the `indeterminate` property under `root`. */
|
|
23
|
+
export function mountCheckboxes(root = document) {
|
|
24
|
+
for (const input of all(root, `${INPUT}[data-indeterminate="true"]`)) {
|
|
25
|
+
input.indeterminate = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function installCheckbox() {
|
|
29
|
+
on('change', INPUT, (el) => {
|
|
30
|
+
const input = el;
|
|
31
|
+
// The browser has already flipped `checked` and cleared `indeterminate`; the state from
|
|
32
|
+
// before the press is the inverse value plus the attribute the markup still carries.
|
|
33
|
+
const next = checkboxToggle({
|
|
34
|
+
checked: !input.checked,
|
|
35
|
+
indeterminate: input.dataset.indeterminate === 'true',
|
|
36
|
+
disabled: input.disabled,
|
|
37
|
+
});
|
|
38
|
+
if (!next)
|
|
39
|
+
return;
|
|
40
|
+
setCheckbox(input, next);
|
|
41
|
+
emit(input.closest('.ss-checkbox') ?? input, 'ss:change', { checked: next.checked });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -13,4 +13,6 @@ export declare function wrap(i: number, n: number): number;
|
|
|
13
13
|
export declare function all<E extends Element = HTMLElement>(root: ParentNode, selector: string): E[];
|
|
14
14
|
/** Resolve an `aria-controls` / `#id` reference, preferring the nearest root. */
|
|
15
15
|
export declare function byId(id: string | null): HTMLElement | null;
|
|
16
|
+
/** Write a core's attribute bag onto an element; `undefined` removes the attribute. */
|
|
17
|
+
export declare function setAttrs(el: Element, attrs: Record<string, string | number | undefined>): void;
|
|
16
18
|
export {};
|
package/dist/vanilla/delegate.js
CHANGED
|
@@ -31,3 +31,12 @@ export function byId(id) {
|
|
|
31
31
|
return null;
|
|
32
32
|
return document.getElementById(id.startsWith('#') ? id.slice(1) : id);
|
|
33
33
|
}
|
|
34
|
+
/** Write a core's attribute bag onto an element; `undefined` removes the attribute. */
|
|
35
|
+
export function setAttrs(el, attrs) {
|
|
36
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
el.removeAttribute(name);
|
|
39
|
+
else
|
|
40
|
+
el.setAttribute(name, String(value));
|
|
41
|
+
}
|
|
42
|
+
}
|
package/dist/vanilla/fields.js
CHANGED
|
@@ -4,76 +4,81 @@
|
|
|
4
4
|
* - Input `clearable`: `.ss-field .clear` empties `.ss-input`, refocuses it and hides itself;
|
|
5
5
|
* typing shows it again (Input.svelte removes the button entirely — vanilla toggles `hidden`).
|
|
6
6
|
* - NumberField steppers: `.ss-numberfield .step.dec/.inc` nudge by `step`, clamped to
|
|
7
|
-
* `min`/`max` (
|
|
7
|
+
* `min`/`max` (decided in `core/number-field.ts`, like the component). At a bound a stepper becomes an
|
|
8
8
|
* `aria-disabled` no-op (still focusable, so focus never drops to <body>); it is natively
|
|
9
9
|
* `disabled` only when the input is disabled/readonly. Each nudge writes the new value to
|
|
10
10
|
* the field's polite `.live` region.
|
|
11
11
|
* - Textarea autosize: `.ss-textarea .field.autosize` grows with content. Browsers with
|
|
12
12
|
* `field-sizing: content` do it in CSS; the JS `scrollHeight` sync is the fallback.
|
|
13
13
|
*/
|
|
14
|
-
import { on, all } from './delegate.js';
|
|
14
|
+
import { on, all, setAttrs } from './delegate.js';
|
|
15
|
+
import { inputClear, inputShowClear } from '../core/input.js';
|
|
16
|
+
import { numberFieldAnnouncement, numberFieldOption, numberFieldParse, numberFieldStep, numberFieldStepperAttrs, } from '../core/number-field.js';
|
|
15
17
|
const fire = (el, type) => el.dispatchEvent(new Event(type, { bubbles: true }));
|
|
16
18
|
// ── Input clearable ─────────────────────────────────────────────────────────
|
|
19
|
+
// The decisions come from `../core/input.js`, shared with Input.svelte; state is read from the DOM.
|
|
20
|
+
const clearState = (input) => ({
|
|
21
|
+
value: input.value,
|
|
22
|
+
readonly: input.readOnly,
|
|
23
|
+
disabled: input.disabled,
|
|
24
|
+
});
|
|
17
25
|
function syncClear(input) {
|
|
18
26
|
const btn = input.closest('.control')?.querySelector('.clear');
|
|
19
27
|
if (btn)
|
|
20
|
-
btn.hidden = !input
|
|
28
|
+
btn.hidden = !inputShowClear(clearState(input));
|
|
21
29
|
}
|
|
22
30
|
export function clearInput(btn) {
|
|
23
31
|
const input = btn.closest('.control')?.querySelector('.ss-input');
|
|
24
32
|
if (!input)
|
|
25
33
|
return;
|
|
26
|
-
|
|
34
|
+
const result = inputClear(clearState(input));
|
|
35
|
+
if (!result)
|
|
36
|
+
return;
|
|
37
|
+
input.value = result.value;
|
|
27
38
|
fire(input, 'input');
|
|
28
39
|
syncClear(input);
|
|
29
|
-
|
|
40
|
+
if (result.focusInput)
|
|
41
|
+
input.focus();
|
|
30
42
|
}
|
|
31
43
|
// ── NumberField steppers ───────────────────────────────────────────────────
|
|
32
|
-
|
|
44
|
+
// Parsing, clamping, stepping and the stepper state come from `../core/number-field.js`,
|
|
45
|
+
// shared with NumberField.svelte; this side only reads the input and writes the result back.
|
|
46
|
+
const numberState = (input) => ({
|
|
47
|
+
value: numberFieldParse(input.value, input.valueAsNumber),
|
|
48
|
+
min: numberFieldOption(input.getAttribute('min')),
|
|
49
|
+
max: numberFieldOption(input.getAttribute('max')),
|
|
50
|
+
step: numberFieldOption(input.getAttribute('step')),
|
|
51
|
+
locked: input.disabled || input.readOnly,
|
|
52
|
+
});
|
|
33
53
|
function syncSteppers(input) {
|
|
34
54
|
const control = input.closest('.control');
|
|
35
55
|
if (!control)
|
|
36
56
|
return;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const max = num(input.getAttribute('max'));
|
|
40
|
-
const locked = input.disabled || input.readOnly;
|
|
41
|
-
const dec = control.querySelector('.step.dec');
|
|
42
|
-
const inc = control.querySelector('.step.inc');
|
|
43
|
-
const bound = (btn, atBound) => {
|
|
57
|
+
const state = numberState(input);
|
|
58
|
+
const apply = (btn, dir) => {
|
|
44
59
|
if (!btn)
|
|
45
60
|
return;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
else
|
|
50
|
-
btn.removeAttribute('aria-disabled');
|
|
61
|
+
const { disabled, ...aria } = numberFieldStepperAttrs(state, dir);
|
|
62
|
+
btn.disabled = disabled;
|
|
63
|
+
setAttrs(btn, aria);
|
|
51
64
|
};
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
apply(control.querySelector('.step.dec'), -1);
|
|
66
|
+
apply(control.querySelector('.step.inc'), 1);
|
|
54
67
|
}
|
|
55
68
|
export function nudgeNumber(btn) {
|
|
56
69
|
const input = btn.closest('.control')?.querySelector('.ss-input');
|
|
57
70
|
if (!input || btn.disabled || btn.getAttribute('aria-disabled') === 'true')
|
|
58
71
|
return;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const step = num(input.getAttribute('step')) ?? 1;
|
|
63
|
-
const current = input.value === '' || Number.isNaN(input.valueAsNumber) ? null : input.valueAsNumber;
|
|
64
|
-
const base = current ?? (dir > 0 ? (min ?? 0) : (max ?? 0));
|
|
65
|
-
let next = base + dir * step;
|
|
66
|
-
if (min != null && next < min)
|
|
67
|
-
next = min;
|
|
68
|
-
if (max != null && next > max)
|
|
69
|
-
next = max;
|
|
72
|
+
const next = numberFieldStep(numberState(input), btn.classList.contains('inc') ? 1 : -1);
|
|
73
|
+
if (next === null)
|
|
74
|
+
return;
|
|
70
75
|
input.value = String(next);
|
|
71
76
|
fire(input, 'input');
|
|
72
77
|
fire(input, 'change');
|
|
73
78
|
syncSteppers(input);
|
|
74
79
|
const live = input.closest('.ss-numberfield')?.querySelector('.live');
|
|
75
80
|
if (live)
|
|
76
|
-
live.textContent =
|
|
81
|
+
live.textContent = numberFieldAnnouncement(next);
|
|
77
82
|
}
|
|
78
83
|
// ── Textarea autosize ──────────────────────────────────────────────────────
|
|
79
84
|
export const supportsFieldSizing = typeof CSS !== 'undefined' &&
|
package/dist/vanilla/index.d.ts
CHANGED
|
@@ -9,7 +9,11 @@ export { showTooltip, hideTooltip } from './tooltip.js';
|
|
|
9
9
|
export { toggleSwitch } from './switch.js';
|
|
10
10
|
export { selectSegment } from './segmented.js';
|
|
11
11
|
export { toggleGrab, readPlacements } from './tierlist.js';
|
|
12
|
+
export { selectTab } from './tabs.js';
|
|
13
|
+
export { openPopover, closePopover } from './popover.js';
|
|
12
14
|
export { clearInput, nudgeNumber, autosize } from './fields.js';
|
|
15
|
+
export { setCheckbox } from './checkbox.js';
|
|
16
|
+
export { selectRadio } from './radio.js';
|
|
13
17
|
export { applyDesignConfig, designAttributes, getDesignConfig, paletteToCss, type DesignConfig, type ColorTheme, type Size, } from '../config.js';
|
|
14
18
|
/** Hydrate icon placeholders and initialise setup-type behaviours under `root`. */
|
|
15
19
|
export declare function mount(root?: ParentNode): void;
|
package/dist/vanilla/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* consumption path. Importing this module wires every behaviour once via document-level event
|
|
4
4
|
* delegation (so markup added later just works) and runs `mount()` when the DOM is ready.
|
|
5
5
|
*
|
|
6
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
7
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
8
|
-
* <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
6
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.21/dist/theme.css">
|
|
7
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.21/dist/vanilla.css">
|
|
8
|
+
* <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.21/dist/vanilla/index.js"></script>
|
|
9
9
|
*
|
|
10
10
|
* Call `mount(root)` after injecting HTML that contains `[data-ss-icon]` placeholders or
|
|
11
11
|
* autosizing textareas. Nothing here imports Svelte or a `.svelte` module.
|
|
@@ -17,7 +17,11 @@ import { installTooltip } from './tooltip.js';
|
|
|
17
17
|
import { installSwitch } from './switch.js';
|
|
18
18
|
import { installSegmented } from './segmented.js';
|
|
19
19
|
import { installTierlist } from './tierlist.js';
|
|
20
|
+
import { installTabs } from './tabs.js';
|
|
21
|
+
import { installPopover } from './popover.js';
|
|
20
22
|
import { installFields, mountFields } from './fields.js';
|
|
23
|
+
import { installCheckbox, mountCheckboxes } from './checkbox.js';
|
|
24
|
+
import { installRadio } from './radio.js';
|
|
21
25
|
import { hydrateIcons } from './icons.js';
|
|
22
26
|
export { toast, toasts } from './toast.js';
|
|
23
27
|
export { iconSvg, hydrateIcons } from './icons.js';
|
|
@@ -29,12 +33,17 @@ export { showTooltip, hideTooltip } from './tooltip.js';
|
|
|
29
33
|
export { toggleSwitch } from './switch.js';
|
|
30
34
|
export { selectSegment } from './segmented.js';
|
|
31
35
|
export { toggleGrab, readPlacements } from './tierlist.js';
|
|
36
|
+
export { selectTab } from './tabs.js';
|
|
37
|
+
export { openPopover, closePopover } from './popover.js';
|
|
32
38
|
export { clearInput, nudgeNumber, autosize } from './fields.js';
|
|
39
|
+
export { setCheckbox } from './checkbox.js';
|
|
40
|
+
export { selectRadio } from './radio.js';
|
|
33
41
|
export { applyDesignConfig, designAttributes, getDesignConfig, paletteToCss, } from '../config.js';
|
|
34
42
|
/** Hydrate icon placeholders and initialise setup-type behaviours under `root`. */
|
|
35
43
|
export function mount(root = document) {
|
|
36
44
|
hydrateIcons(root);
|
|
37
45
|
mountFields(root);
|
|
46
|
+
mountCheckboxes(root);
|
|
38
47
|
}
|
|
39
48
|
const FLAG = '__dssocaVanilla';
|
|
40
49
|
/** Register every delegated behaviour once per document. Safe to call repeatedly. */
|
|
@@ -52,7 +61,11 @@ export function install() {
|
|
|
52
61
|
installSwitch();
|
|
53
62
|
installSegmented();
|
|
54
63
|
installTierlist();
|
|
64
|
+
installTabs();
|
|
65
|
+
installPopover();
|
|
55
66
|
installFields();
|
|
67
|
+
installCheckbox();
|
|
68
|
+
installRadio();
|
|
56
69
|
if (document.readyState === 'loading') {
|
|
57
70
|
document.addEventListener('DOMContentLoaded', () => mount(), { once: true });
|
|
58
71
|
}
|