@zeyolabs/ui 0.0.0-stage → 2026.11.6

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 (143) hide show
  1. package/README.md +43 -2
  2. package/back-button/BackButton.svelte +26 -0
  3. package/badge/Badge.svelte +73 -0
  4. package/badge/PromoBadge.svelte +319 -0
  5. package/badge/color.ts +10 -0
  6. package/bar/Bar.svelte +63 -0
  7. package/base.css +47 -0
  8. package/boundary/Boundary.svelte +59 -0
  9. package/boundary/BoundaryFailed.svelte +40 -0
  10. package/boundary/PendingTracker.svelte +14 -0
  11. package/boundary/pending-context.ts +15 -0
  12. package/boundary/pending-flag.svelte.ts +33 -0
  13. package/boundary/report-boundary-error.ts +13 -0
  14. package/card/Card.svelte +239 -0
  15. package/card/CardBody.svelte +41 -0
  16. package/card/CardFooter.svelte +36 -0
  17. package/card/CardHeader.svelte +36 -0
  18. package/copy/CopyArea.svelte +37 -0
  19. package/copy/CopyButton.svelte +59 -0
  20. package/copy/copy-state.svelte.ts +23 -0
  21. package/copy/types.ts +1 -0
  22. package/dialog/ConfirmDialog.svelte +61 -0
  23. package/dialog/Dialog.svelte +31 -0
  24. package/dialog/DialogBody.svelte +88 -0
  25. package/dialog/DialogCloseButton.svelte +26 -0
  26. package/dialog/DialogFooter.svelte +23 -0
  27. package/dialog/DialogTrigger.svelte +15 -0
  28. package/distribution-bar/DistributionBar.svelte +37 -0
  29. package/drawer/Drawer.svelte +31 -0
  30. package/drawer/DrawerBody.svelte +61 -0
  31. package/empty-state/EmptyState.svelte +74 -0
  32. package/error/ErrorPage.svelte +54 -0
  33. package/eyebrow/Eyebrow.svelte +10 -0
  34. package/faq/FAQList.svelte +89 -0
  35. package/filter/FilterChipGroup.svelte +78 -0
  36. package/filter/FilterOptionList.svelte +188 -0
  37. package/filter/FilterPopover.svelte +122 -0
  38. package/filter/filter-draft.svelte.ts +25 -0
  39. package/form/Button.svelte +73 -0
  40. package/form/Field.svelte +111 -0
  41. package/form/FieldLabel.svelte +19 -0
  42. package/form/Form.svelte +133 -0
  43. package/form/PhoneField.svelte +214 -0
  44. package/form/UnsavedBar.svelte +22 -0
  45. package/form/field-view.svelte.ts +213 -0
  46. package/form/fields/CheckboxField.svelte +85 -0
  47. package/form/fields/Combobox.svelte +327 -0
  48. package/form/fields/ComboboxAction.svelte +16 -0
  49. package/form/fields/DateField.svelte +31 -0
  50. package/form/fields/DateRangeField.svelte +188 -0
  51. package/form/fields/DateRangePresetField.svelte +119 -0
  52. package/form/fields/EmailField.svelte +63 -0
  53. package/form/fields/FileField.svelte +145 -0
  54. package/form/fields/HexColorField.svelte +83 -0
  55. package/form/fields/IntervalField.svelte +100 -0
  56. package/form/fields/MessageField.svelte +99 -0
  57. package/form/fields/NumberField.svelte +64 -0
  58. package/form/fields/Option.svelte +48 -0
  59. package/form/fields/OptionRegistrar.svelte +15 -0
  60. package/form/fields/PasswordField.svelte +44 -0
  61. package/form/fields/RadioField.svelte +60 -0
  62. package/form/fields/RichTextField.svelte +221 -0
  63. package/form/fields/SelectField.svelte +216 -0
  64. package/form/fields/SliderField.svelte +182 -0
  65. package/form/fields/SwitchField.svelte +102 -0
  66. package/form/fields/TextField.svelte +72 -0
  67. package/form/fields/TimeField.svelte +31 -0
  68. package/form/fields/index.ts +19 -0
  69. package/form/fields/select-field-context.ts +21 -0
  70. package/form/index.ts +21 -0
  71. package/form/primitives/Checkbox.svelte +103 -0
  72. package/form/primitives/DateInput.svelte +51 -0
  73. package/form/primitives/IconInputWrapper.svelte +40 -0
  74. package/form/primitives/Input.svelte +47 -0
  75. package/form/primitives/SearchBar.svelte +37 -0
  76. package/form/primitives/Select.svelte +139 -0
  77. package/form/primitives/TextArea.svelte +51 -0
  78. package/form/primitives/index.ts +6 -0
  79. package/gallery/ImageGallery.svelte +133 -0
  80. package/gallery/flickity-fullscreen.d.ts +2 -0
  81. package/grouped-grid/GroupedGrid.svelte +143 -0
  82. package/grouped-grid/types.ts +25 -0
  83. package/layout/Cluster.svelte +92 -0
  84. package/layout/Container.svelte +9 -0
  85. package/layout/Grid.svelte +131 -0
  86. package/layout/Section.svelte +146 -0
  87. package/layout/Shell.svelte +32 -0
  88. package/layout/SplitShell.svelte +47 -0
  89. package/layout/Stack.svelte +78 -0
  90. package/list-row/ListRow.svelte +77 -0
  91. package/menu/MenuButton.svelte +101 -0
  92. package/mini-stat/MiniStat.svelte +13 -0
  93. package/package.json +171 -5
  94. package/page-hero/PageHero.svelte +35 -0
  95. package/pagination/Pagination.svelte +44 -0
  96. package/pagination/finder-pagination.svelte.ts +55 -0
  97. package/pagination/finder-search.svelte.ts +292 -0
  98. package/percentage-ring/PercentageRing.svelte +76 -0
  99. package/percentage-ring/types.ts +1 -0
  100. package/popover/InfoTip.svelte +36 -0
  101. package/popover/Popover.svelte +157 -0
  102. package/query-state/QueryState.svelte +42 -0
  103. package/schema.ts +20 -0
  104. package/sidebar/Sidebar.svelte +73 -0
  105. package/sidebar/SidebarBrand.svelte +32 -0
  106. package/sidebar/SidebarButton.svelte +31 -0
  107. package/sidebar/SidebarGroup.svelte +39 -0
  108. package/sidebar/SidebarItem.svelte +48 -0
  109. package/skeleton/Skeleton.svelte +86 -0
  110. package/skeleton/SkeletonButton.svelte +27 -0
  111. package/skeleton/SkeletonCard.svelte +49 -0
  112. package/skeleton/SkeletonCircle.svelte +25 -0
  113. package/skeleton/SkeletonField.svelte +19 -0
  114. package/skeleton/SkeletonRow.svelte +47 -0
  115. package/skeleton/SkeletonText.svelte +46 -0
  116. package/skeleton/TableSkeleton.svelte +60 -0
  117. package/spacing.css +32 -0
  118. package/stat/NextPayoutCountdown.svelte +52 -0
  119. package/stat/Stat.svelte +103 -0
  120. package/stat/ValueBox.svelte +38 -0
  121. package/status-row/StatusRow.svelte +176 -0
  122. package/status-row/types.ts +5 -0
  123. package/table/SelectAllCell.svelte +34 -0
  124. package/table/SelectAllTableCell.svelte +25 -0
  125. package/table/SelectRowCell.svelte +31 -0
  126. package/table/SelectRowTableCell.svelte +25 -0
  127. package/table/SelectionBar.svelte +68 -0
  128. package/table/SelectionOverlay.svelte +83 -0
  129. package/table/Table.svelte +64 -0
  130. package/table/TableCell.svelte +185 -0
  131. package/table/TableRow.svelte +86 -0
  132. package/table/index.ts +9 -0
  133. package/table/selection.svelte.ts +79 -0
  134. package/tabs/TabBlock.svelte +56 -0
  135. package/tabs/TabButton.svelte +33 -0
  136. package/template.css +1393 -0
  137. package/text/Span.svelte +83 -0
  138. package/text/Text.svelte +94 -0
  139. package/text/Title.svelte +75 -0
  140. package/text/color.ts +41 -0
  141. package/theme/theme.svelte.ts +33 -0
  142. package/tokens.css +62 -0
  143. package/typography.css +164 -0
@@ -0,0 +1,68 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { Button } from '@zeyolabs/ui/form';
5
+
6
+ /**
7
+ * Bulk-action bar for a selectable table/list — "N selected" + caller-supplied action
8
+ * buttons + a built-in Clear. Renders nothing while `count` is 0. Positioning (inline in a
9
+ * toolbar, an overlay on the header row, ...) is the caller's call — this only owns content.
10
+ *
11
+ * `totalCount`/`allMatchingSelected`/`onSelectAllMatching` are optional — omit all three for
12
+ * a page with no pagination (or that doesn't need the distinction), where `count` already
13
+ * covers everything selectable. Pass them once `count` can be less than the full matching set
14
+ * (a paginated list) to offer "select all N matching" as a follow-up to selecting a page.
15
+ */
16
+ let {
17
+ allMatchingSelected = false,
18
+ children,
19
+ count,
20
+ onClear,
21
+ onSelectAllMatching,
22
+ totalCount,
23
+ }: {
24
+ allMatchingSelected?: boolean;
25
+ children: Snippet;
26
+ count: number;
27
+ onClear: () => void;
28
+ onSelectAllMatching?: () => void;
29
+ totalCount?: number;
30
+ } = $props();
31
+ </script>
32
+
33
+ {#if count > 0}
34
+ <div class="selection-bar">
35
+ <span class="count">
36
+ <strong>{count}</strong> selected
37
+ </span>
38
+ {#if !allMatchingSelected && totalCount != null && count < totalCount && onSelectAllMatching}
39
+ <Button onclick={onSelectAllMatching} variant="link">
40
+ Select all {totalCount} matching
41
+ </Button>
42
+ {/if}
43
+ <div class="actions">
44
+ {@render children()}
45
+ </div>
46
+ <Button onclick={onClear} variant="link">Clear</Button>
47
+ </div>
48
+ {/if}
49
+
50
+ <style>
51
+ .selection-bar {
52
+ display: flex;
53
+ align-items: center;
54
+ gap: 10px;
55
+ }
56
+ .count {
57
+ font-size: 13px;
58
+ color: var(--tx);
59
+ }
60
+ .count strong {
61
+ font-weight: 400;
62
+ }
63
+ .actions {
64
+ display: flex;
65
+ align-items: center;
66
+ gap: 6px;
67
+ }
68
+ </style>
@@ -0,0 +1,83 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import SelectionBar from './SelectionBar.svelte';
5
+
6
+ /**
7
+ * Bulk-action bar that floats ON TOP of a Table's header row once something's selected —
8
+ * pass it as `<Table>`'s `overlay` snippet. Because the header row stays in the DOM
9
+ * underneath, column widths never shift when selection toggles. Renders nothing while
10
+ * `count` is 0, matching `SelectionBar`'s own self-gating.
11
+ *
12
+ * The 40px left offset matches `SelectAllTableCell`'s fixed checkbox-column width exactly
13
+ * (skips it so the header checkbox stays clickable); the 41px height matches a default,
14
+ * non-compact `TableCell` head row (13px padding × 2 + text). `pointer-events` is `none` on
15
+ * the wrapper and re-enabled only on its rendered content — the wrapper's own box still spans
16
+ * the full row width for layout purposes, and without this a click anywhere the wrapper covers
17
+ * but has nothing drawn (including that 40px checkbox column) would get swallowed instead of
18
+ * reaching the header checkbox underneath.
19
+ */
20
+ let {
21
+ allMatchingSelected = false,
22
+ children,
23
+ count,
24
+ onClear,
25
+ onSelectAllMatching,
26
+ sticky = false,
27
+ totalCount,
28
+ }: {
29
+ allMatchingSelected?: boolean;
30
+ children: Snippet;
31
+ count: number;
32
+ onClear: () => void;
33
+ onSelectAllMatching?: () => void;
34
+ /** Set when the table underneath pins its header via `TableRow`'s/`GroupedGrid`'s
35
+ * `sticky`/`stickyHeader` — switches from `position: absolute` (out of flow — fine for a
36
+ * plain non-scrolling table) to `position: sticky` (tracks the same scroll boundary as the
37
+ * header row, so this stays pinned alongside it instead of scrolling out from under it;
38
+ * `margin-bottom` cancels the flow height it then occupies, so the table underneath still
39
+ * never shifts when selection toggles). */
40
+ sticky?: boolean;
41
+ totalCount?: number;
42
+ } = $props();
43
+ </script>
44
+
45
+ {#if count > 0}
46
+ <div class="overlay" class:sticky>
47
+ <SelectionBar {allMatchingSelected} {count} {onClear} {onSelectAllMatching} {totalCount}>
48
+ {@render children()}
49
+ </SelectionBar>
50
+ </div>
51
+ {/if}
52
+
53
+ <style>
54
+ .overlay {
55
+ position: absolute;
56
+ top: 0;
57
+ left: 0;
58
+ right: 0;
59
+ z-index: 5;
60
+ display: flex;
61
+ align-items: center;
62
+ height: 41px;
63
+ margin-left: 40px;
64
+ padding: 0 var(--spacing-md);
65
+ background: var(--sf);
66
+ /* The <th> underneath bakes in uppercase + letter-spacing via the global table
67
+ styles, and SelectionBar/the caller's own buttons render content this component
68
+ has no classes for — only a wildcard selector can strip that cascade. */
69
+ font-size: 13px;
70
+ font-weight: 400;
71
+ color: var(--tx);
72
+ pointer-events: none;
73
+ }
74
+ .overlay :global(*) {
75
+ text-transform: none;
76
+ letter-spacing: 0;
77
+ pointer-events: auto;
78
+ }
79
+ .overlay.sticky {
80
+ position: sticky;
81
+ margin-bottom: -41px;
82
+ }
83
+ </style>
@@ -0,0 +1,64 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ let {
5
+ bordered = false,
6
+ children,
7
+ minWidth = '700px',
8
+ overlay,
9
+ }: {
10
+ /** Adds a vertical rule between columns (a full grid, spreadsheet-style). */
11
+ bordered?: boolean;
12
+ children: Snippet;
13
+ minWidth?: string;
14
+ /** A `SelectionOverlay` (or any absolutely-positioned overlay) anchored to the header
15
+ * row — can't go inside `children` since a `<table>` only accepts row/section markup. */
16
+ overlay?: Snippet;
17
+ } = $props();
18
+ </script>
19
+
20
+ <div class="overflow">
21
+ {@render overlay?.()}
22
+ <table style="min-width: {minWidth};" class:bordered>
23
+ {@render children()}
24
+ </table>
25
+ </div>
26
+
27
+ <style>
28
+ .overflow {
29
+ position: relative;
30
+ overflow-x: auto;
31
+ border: 1px solid var(--bd);
32
+ border-radius: var(--radius-lg);
33
+ }
34
+ /* Inside a Card the Card already draws the rounded frame — a second border here reads as a
35
+ doubled edge. Keep the radius (minus the Card's 1px border) so the header row's
36
+ background still clips to the Card's corners. */
37
+ :global(.card) .overflow {
38
+ border: none;
39
+ border-radius: calc(var(--radius-lg) - 1px);
40
+ }
41
+ table {
42
+ width: 100%;
43
+ /* Not `collapse` — a sticky header row (see TableRow's `sticky`) loses its collapsed
44
+ borders in Chrome, since collapsed-border painting doesn't track sticky repositioning.
45
+ `separate` + zero spacing paints each cell's own border independently, immune to that,
46
+ and looks identical here since adjacent cells never declare conflicting borders. */
47
+ border-collapse: separate;
48
+ border-spacing: 0;
49
+ }
50
+ :global(tr:last-child td) {
51
+ border-bottom: none;
52
+ }
53
+ :global(tr.elevated > td) {
54
+ position: relative;
55
+ z-index: 9999;
56
+ }
57
+ :global(table.bordered th),
58
+ :global(table.bordered td) {
59
+ border-right: 1px solid var(--bd);
60
+ }
61
+ :global(table.bordered tr > :last-child) {
62
+ border-right: none;
63
+ }
64
+ </style>
@@ -0,0 +1,185 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { ChevronDown, ChevronsUpDown, ChevronUp } from '@lucide/svelte';
5
+ import { getContext } from 'svelte';
6
+
7
+ let {
8
+ align = 'left',
9
+ children,
10
+ colspan,
11
+ compact = false,
12
+ mono = false,
13
+ muted = false,
14
+ onSort,
15
+ sortDirection = null,
16
+ stickyLeft,
17
+ stopPropagation = false,
18
+ style = '',
19
+ valign = 'middle',
20
+ }: {
21
+ align?: 'left' | 'right';
22
+ children?: Snippet;
23
+ colspan?: number;
24
+ // Tighter padding for a dense data grid (e.g. a drill-down table) — opt in per usage, the
25
+ // default stays the general-purpose spacing every other Table consumer already renders at.
26
+ compact?: boolean;
27
+ mono?: boolean;
28
+ muted?: boolean;
29
+ // Head cell only. Presence makes the header clickable; caller owns the actual sort
30
+ // state/logic and passes the current direction back via `sortDirection`.
31
+ onSort?: () => void;
32
+ sortDirection?: 'asc' | 'desc' | null;
33
+ // A CSS length (must be a px value, e.g. '0px'/'32px') — pins this cell via
34
+ // position: sticky at that left offset. Apply to the matching header AND body cell for
35
+ // a given column. See GroupedGrid's `sticky` column flag for automatic offset math.
36
+ stickyLeft?: string;
37
+ stopPropagation?: boolean;
38
+ style?: string;
39
+ valign?: 'middle' | 'top';
40
+ } = $props();
41
+
42
+ const isHead = getContext<boolean>('table:head');
43
+ const isBoldHead = getContext<boolean>('table:head-bold');
44
+ const sticky = $derived(stickyLeft != null);
45
+
46
+ function handleClick(e: MouseEvent) {
47
+ e.stopPropagation();
48
+ }
49
+
50
+ function handleHeadClick(e: MouseEvent) {
51
+ if (stopPropagation) e.stopPropagation();
52
+ onSort?.();
53
+ }
54
+ </script>
55
+
56
+ {#if isHead}
57
+ <th
58
+ {style}
59
+ style:left={stickyLeft}
60
+ class:bold-head={isBoldHead}
61
+ class:compact
62
+ class:num={align === 'right'}
63
+ class:sortable={!!onSort}
64
+ class:sticky
65
+ onclick={onSort || stopPropagation ? handleHeadClick : undefined}
66
+ >
67
+ {#if onSort}
68
+ <span class="sort-label">
69
+ {@render children?.()}
70
+ {#if sortDirection === 'asc'}
71
+ <ChevronUp size={11} />
72
+ {:else if sortDirection === 'desc'}
73
+ <ChevronDown size={11} />
74
+ {:else}
75
+ <span class="sort-icon-idle"><ChevronsUpDown size={11} /></span>
76
+ {/if}
77
+ </span>
78
+ {:else}
79
+ {@render children?.()}
80
+ {/if}
81
+ </th>
82
+ {:else}
83
+ <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_noninteractive_element_interactions -->
84
+ <td
85
+ {style}
86
+ style:left={stickyLeft}
87
+ class:compact
88
+ class:mono
89
+ class:muted
90
+ class:num={align === 'right'}
91
+ class:sticky
92
+ class:top={valign === 'top'}
93
+ {colspan}
94
+ onclick={stopPropagation ? handleClick : undefined}
95
+ >
96
+ {@render children?.()}
97
+ </td>
98
+ {/if}
99
+
100
+ <style>
101
+ th {
102
+ text-align: left;
103
+ font-size: 11px;
104
+ font-weight: 400;
105
+ letter-spacing: 0.05em;
106
+ text-transform: uppercase;
107
+ color: var(--txt);
108
+ padding: 13px 18px;
109
+ border-bottom: 1px solid var(--bds);
110
+ background: var(--sf);
111
+ white-space: nowrap;
112
+ }
113
+ th.num {
114
+ text-align: right;
115
+ }
116
+ /* Same heading font/weight as `Title` (var(--font-heading)), scaled down for a table row —
117
+ for a header that needs to read as more prominent than the default small tracked-out
118
+ uppercase label. */
119
+ th.bold-head {
120
+ font-family: var(--font-heading);
121
+ font-size: 15px;
122
+ font-weight: 400;
123
+ letter-spacing: normal;
124
+ text-transform: none;
125
+ color: var(--tx);
126
+ }
127
+ th.compact {
128
+ padding: 7px 10px;
129
+ }
130
+ th.sortable {
131
+ cursor: pointer;
132
+ user-select: none;
133
+ }
134
+ th.sortable:hover {
135
+ color: var(--tx);
136
+ }
137
+ .sort-label {
138
+ display: inline-flex;
139
+ align-items: center;
140
+ gap: 3px;
141
+ }
142
+ .sort-icon-idle {
143
+ display: inline-flex;
144
+ opacity: 0.4;
145
+ }
146
+ th.sticky,
147
+ td.sticky {
148
+ position: sticky;
149
+ z-index: 1;
150
+ }
151
+ th.sticky {
152
+ z-index: 2;
153
+ background: var(--sf);
154
+ }
155
+ td.sticky {
156
+ background: var(--row-bg, var(--bg));
157
+ }
158
+ td {
159
+ padding: 14px 18px;
160
+ font-size: 13px;
161
+ color: var(--tx);
162
+ background: var(--row-bg, var(--bg));
163
+ border-bottom: 1px solid var(--bds);
164
+ vertical-align: middle;
165
+ }
166
+ td.compact {
167
+ padding: 6px 10px;
168
+ }
169
+ td.top {
170
+ vertical-align: top;
171
+ }
172
+ td.num {
173
+ text-align: right;
174
+ font-variant-numeric: tabular-nums;
175
+ }
176
+ td.muted {
177
+ color: var(--txs);
178
+ font-size: 13px;
179
+ }
180
+ td.mono {
181
+ font-family: var(--font-mono);
182
+ font-variant-numeric: tabular-nums;
183
+ font-size: 13px;
184
+ }
185
+ </style>
@@ -0,0 +1,86 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { setContext } from 'svelte';
5
+
6
+ let {
7
+ boldHeader = false,
8
+ children,
9
+ elevated = false,
10
+ head = false,
11
+ hoverable = false,
12
+ onclick,
13
+ selected = false,
14
+ sticky = false,
15
+ warning = false,
16
+ }: {
17
+ /** Head row only — renders column labels in the shared heading font/weight (same
18
+ * treatment as `Title`) instead of the default small uppercase tracked-out label,
19
+ * for a table whose header needs to read as more prominent. Opt-in — every existing
20
+ * Table keeps the default label style unless it asks for this. */
21
+ boldHeader?: boolean;
22
+ children: Snippet;
23
+ elevated?: boolean;
24
+ head?: boolean;
25
+ hoverable?: boolean;
26
+ onclick?: () => void;
27
+ selected?: boolean;
28
+ /** Head row only — pins it via position: sticky while the table body scrolls past.
29
+ * Each TableCell head cell already renders an opaque background, so no extra
30
+ * backdrop is needed here. */
31
+ sticky?: boolean;
32
+ /** Row-wide tint (e.g. "this row has invalid data") via a `--row-bg` custom property
33
+ * every TableCell's background reads — unlike `selected`, this DOES need to paint
34
+ * through, including sticky cells, so it's a custom property rather than a `tr`
35
+ * background: a `td`'s own opaque background would otherwise hide a plain `tr` tint. */
36
+ warning?: boolean;
37
+ } = $props();
38
+
39
+ // svelte-ignore state_referenced_locally
40
+ setContext('table:head', head);
41
+ // svelte-ignore state_referenced_locally
42
+ setContext('table:head-bold', boldHeader);
43
+ </script>
44
+
45
+ <tr
46
+ class:clickable={!!onclick}
47
+ class:elevated
48
+ class:hoverable={!onclick && hoverable}
49
+ class:selected
50
+ class:sticky
51
+ class:warning
52
+ {onclick}
53
+ >
54
+ {@render children()}
55
+ </tr>
56
+
57
+ <style>
58
+ tr.clickable,
59
+ tr.hoverable {
60
+ transition: background 0.1s ease;
61
+ }
62
+ tr.clickable {
63
+ cursor: pointer;
64
+ }
65
+ tr.clickable:hover,
66
+ tr.hoverable:hover {
67
+ background: var(--sf);
68
+ }
69
+ /* No background tint on `.selected` — a sticky checkbox column (TableCell's `td.sticky`)
70
+ always paints its own opaque `var(--bg)` so pinned content stays readable while scrolling,
71
+ which can't pick up a semi-transparent row tint sitting behind it. Tinting the rest of the
72
+ row while that one cell stayed plain background looked like a rendering bug, not a design
73
+ choice — the checkbox's own checked state already communicates "selected" on its own. */
74
+ tr.elevated {
75
+ position: relative;
76
+ z-index: 9999;
77
+ }
78
+ tr.sticky {
79
+ position: sticky;
80
+ top: 0;
81
+ z-index: 3;
82
+ }
83
+ tr.warning {
84
+ --row-bg: color-mix(in srgb, var(--w) 10%, var(--bg));
85
+ }
86
+ </style>
package/table/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export { default as SelectAllCell } from './SelectAllCell.svelte';
2
+ export { default as SelectAllTableCell } from './SelectAllTableCell.svelte';
3
+ export { default as SelectionBar } from './SelectionBar.svelte';
4
+ export { default as SelectionOverlay } from './SelectionOverlay.svelte';
5
+ export { default as SelectRowCell } from './SelectRowCell.svelte';
6
+ export { default as SelectRowTableCell } from './SelectRowTableCell.svelte';
7
+ export { default as Table } from './Table.svelte';
8
+ export { default as TableCell } from './TableCell.svelte';
9
+ export { default as TableRow } from './TableRow.svelte';
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Shared row-selection state for a paginated, selectable list — exclusion-based so "select all N
3
+ * matching" never materializes the full matching set into memory. `scope: 'ids'` is the ordinary
4
+ * case (`ids` holds the selected rows); `scope: 'allMatching'` means "everything the current
5
+ * filter matches, except `ids`" — so `ids` stays small (only what's been manually deselected)
6
+ * regardless of how big the matching set actually is.
7
+ *
8
+ * In `'allMatching'` scope the header checkbox (`toggleAll`) is a master toggle: any click clears
9
+ * the whole selection rather than excluding just the visible page. Per-row checkboxes (`toggle`)
10
+ * are how individual rows get excluded while the rest of the matching set stays selected.
11
+ */
12
+ export function createSelectionState() {
13
+ let scope = $state<'allMatching' | 'ids'>('ids');
14
+ let ids = $state(new Set<string>());
15
+
16
+ function toggle(id: string) {
17
+ const next = new Set(ids);
18
+ if (next.has(id)) next.delete(id);
19
+ else next.add(id);
20
+ ids = next;
21
+ }
22
+
23
+ function toggleAll(pageIds: string[]) {
24
+ if (scope === 'allMatching') {
25
+ // The header checkbox is a master toggle once everything matching is already selected —
26
+ // there's nothing "more" to select, so any click on it means "give up the whole
27
+ // selection," not "toggle just the visible page." Per-row checkboxes (toggle()) remain
28
+ // the way to exclude specific rows while keeping the rest of the matching set selected.
29
+ clear();
30
+ return;
31
+ }
32
+ const allSelected = pageIds.length > 0 && pageIds.every((id) => ids.has(id));
33
+ ids = allSelected
34
+ ? new Set([...ids].filter((id) => !pageIds.includes(id)))
35
+ : new Set([...ids, ...pageIds]);
36
+ }
37
+
38
+ function selectAllMatching() {
39
+ scope = 'allMatching';
40
+ ids = new Set();
41
+ }
42
+
43
+ function clear() {
44
+ scope = 'ids';
45
+ ids = new Set();
46
+ }
47
+
48
+ /** Selected count given the total matching the current filter — feeds straight into
49
+ * `SelectionBar`/`SelectionOverlay`'s `count` prop. */
50
+ function countGiven(total: number): number {
51
+ return scope === 'ids' ? ids.size : Math.max(0, total - ids.size);
52
+ }
53
+
54
+ /** Is a given row currently selected, given whether it's part of the matching set at all
55
+ * (always true for a row actually rendered on a page that matches the active filter). */
56
+ function has(id: string): boolean {
57
+ return scope === 'ids' ? ids.has(id) : !ids.has(id);
58
+ }
59
+
60
+ return {
61
+ get allMatchingSelected() {
62
+ return scope === 'allMatching';
63
+ },
64
+ clear,
65
+ countGiven,
66
+ has,
67
+ get ids() {
68
+ return ids;
69
+ },
70
+ get scope() {
71
+ return scope;
72
+ },
73
+ selectAllMatching,
74
+ toggle,
75
+ toggleAll,
76
+ };
77
+ }
78
+
79
+ export type SelectionState = ReturnType<typeof createSelectionState>;
@@ -0,0 +1,56 @@
1
+ <script generics="V" lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { setContext } from 'svelte';
5
+
6
+ type Props = {
7
+ 'aria-invalid'?: 'false' | 'true' | boolean;
8
+ children: Snippet;
9
+ class?: string;
10
+ disabled?: boolean;
11
+ onChange?: (value: V) => void;
12
+ readonly?: boolean;
13
+ value?: V;
14
+ vertical?: boolean;
15
+ };
16
+
17
+ let {
18
+ 'aria-invalid': ariaInvalid,
19
+ children,
20
+ class: className,
21
+ disabled = false,
22
+ onChange,
23
+ readonly = false,
24
+ value = $bindable(undefined),
25
+ vertical = false,
26
+ }: Props = $props();
27
+
28
+ setContext(Symbol.for('tab'), {
29
+ get disabled() {
30
+ return disabled;
31
+ },
32
+ isActive: (v: unknown) => value === v,
33
+ get readonly() {
34
+ return readonly;
35
+ },
36
+ select(v: unknown) {
37
+ value = v as V;
38
+ onChange?.(v as V);
39
+ },
40
+ });
41
+ </script>
42
+
43
+ <div
44
+ class={[
45
+ 'tab',
46
+ vertical && 'tab--vertical',
47
+ disabled && 'tab--disabled',
48
+ !disabled && readonly && 'tab--readonly',
49
+ ariaInvalid && 'tab--invalid',
50
+ className,
51
+ ]
52
+ .filter(Boolean)
53
+ .join(' ')}
54
+ >
55
+ {@render children()}
56
+ </div>
@@ -0,0 +1,33 @@
1
+ <script generics="V" lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { getContext } from 'svelte';
5
+
6
+ type TabCtx = {
7
+ disabled: boolean;
8
+ isActive: (v: unknown) => boolean;
9
+ readonly: boolean;
10
+ select: (v: unknown) => void;
11
+ };
12
+
13
+ type Props = {
14
+ children: Snippet;
15
+ value: V;
16
+ };
17
+
18
+ let { children, value }: Props = $props();
19
+
20
+ const ctx = getContext<TabCtx>(Symbol.for('tab'));
21
+ </script>
22
+
23
+ <button
24
+ class="tab-btn"
25
+ data-state={ctx.isActive(value) ? 'active' : 'inactive'}
26
+ onclick={() => {
27
+ if (ctx.disabled || ctx.readonly) return;
28
+ ctx.select(value);
29
+ }}
30
+ type="button"
31
+ >
32
+ {@render children()}
33
+ </button>