@zeyolabs/ui 0.0.0-stage → 2026.11.5

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 (138) 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 +169 -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/skeleton/Skeleton.svelte +86 -0
  105. package/skeleton/SkeletonButton.svelte +27 -0
  106. package/skeleton/SkeletonCard.svelte +49 -0
  107. package/skeleton/SkeletonCircle.svelte +25 -0
  108. package/skeleton/SkeletonField.svelte +19 -0
  109. package/skeleton/SkeletonRow.svelte +47 -0
  110. package/skeleton/SkeletonText.svelte +46 -0
  111. package/skeleton/TableSkeleton.svelte +60 -0
  112. package/spacing.css +32 -0
  113. package/stat/NextPayoutCountdown.svelte +52 -0
  114. package/stat/Stat.svelte +103 -0
  115. package/stat/ValueBox.svelte +38 -0
  116. package/status-row/StatusRow.svelte +176 -0
  117. package/status-row/types.ts +5 -0
  118. package/table/SelectAllCell.svelte +34 -0
  119. package/table/SelectAllTableCell.svelte +25 -0
  120. package/table/SelectRowCell.svelte +31 -0
  121. package/table/SelectRowTableCell.svelte +25 -0
  122. package/table/SelectionBar.svelte +68 -0
  123. package/table/SelectionOverlay.svelte +83 -0
  124. package/table/Table.svelte +64 -0
  125. package/table/TableCell.svelte +185 -0
  126. package/table/TableRow.svelte +86 -0
  127. package/table/index.ts +9 -0
  128. package/table/selection.svelte.ts +79 -0
  129. package/tabs/TabBlock.svelte +56 -0
  130. package/tabs/TabButton.svelte +33 -0
  131. package/template.css +1393 -0
  132. package/text/Span.svelte +83 -0
  133. package/text/Text.svelte +94 -0
  134. package/text/Title.svelte +75 -0
  135. package/text/color.ts +41 -0
  136. package/theme/theme.svelte.ts +33 -0
  137. package/tokens.css +62 -0
  138. package/typography.css +164 -0
@@ -0,0 +1,103 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import Card from '@zeyolabs/ui/card/Card.svelte';
5
+
6
+ let {
7
+ chart,
8
+ class: className = '',
9
+ delta,
10
+ label,
11
+ loading = false,
12
+ numerals = 'display',
13
+ sub,
14
+ value,
15
+ }: {
16
+ /** Small visual under the value/sub — a sparkline SVG, typically. */
17
+ chart?: Snippet;
18
+ class?: string;
19
+ /** Up/down/neutral change badge next to the value — owns its own color coding, so
20
+ * callers don't each reimplement the up=green/down=red/neutral=muted logic. */
21
+ delta?: { dir: 'down' | 'neutral' | 'up'; pct: string };
22
+ label: Snippet;
23
+ /** Loading ring on the card while its value reloads; drive it from `pendingFlag()`. */
24
+ loading?: boolean;
25
+ /** Type treatment for the value. `display` (default) is the DM Sans heading face; `plain`
26
+ * keeps the body sans at a slightly smaller size, for dense metric grids where a row of
27
+ * display numerals reads too loud. */
28
+ numerals?: 'display' | 'plain';
29
+ sub?: Snippet;
30
+ value: Snippet;
31
+ } = $props();
32
+ </script>
33
+
34
+ <Card class="flex flex-col gap-3.5 min-h-27 py-5 px-5.5 {className}" hover {loading}>
35
+ <div class="eyebrow">{@render label()}</div>
36
+ <div class="stat-num-row">
37
+ <div class="stat-num" data-numerals={numerals}>{@render value()}</div>
38
+ {#if delta}
39
+ <span class="stat-delta" data-dir={delta.dir}>{delta.pct}</span>
40
+ {/if}
41
+ </div>
42
+ {#if sub}<div class="stat-sub">{@render sub()}</div>{/if}
43
+ {#if chart}<div class="stat-chart">{@render chart()}</div>{/if}
44
+ </Card>
45
+
46
+ <style>
47
+ .eyebrow {
48
+ font-size: 11px;
49
+ font-weight: 400;
50
+ letter-spacing: 0.05em;
51
+ text-transform: uppercase;
52
+ color: var(--txs);
53
+ line-height: 1;
54
+ }
55
+ .stat-num-row {
56
+ display: flex;
57
+ align-items: baseline;
58
+ justify-content: space-between;
59
+ gap: var(--spacing-sm);
60
+ }
61
+ .stat-num {
62
+ font-family: var(--font-heading);
63
+ font-size: 32px;
64
+ font-weight: 400;
65
+ letter-spacing: -1px;
66
+ color: var(--tx);
67
+ line-height: 1;
68
+ font-variant-numeric: tabular-nums;
69
+ }
70
+ .stat-num[data-numerals='plain'] {
71
+ font-family: inherit;
72
+ font-size: 32px;
73
+ font-weight: 400;
74
+ letter-spacing: -0.01em;
75
+ }
76
+ .stat-sub {
77
+ font-size: 11px;
78
+ font-weight: 400;
79
+ color: var(--txs);
80
+ font-variant-numeric: tabular-nums;
81
+ letter-spacing: -0.005em;
82
+ }
83
+ .stat-delta {
84
+ font-size: 11px;
85
+ font-weight: 400;
86
+ padding: 2px 6px;
87
+ border-radius: var(--radius-full);
88
+ letter-spacing: -0.005em;
89
+ background: var(--sf);
90
+ color: var(--txt);
91
+ }
92
+ .stat-delta[data-dir='up'] {
93
+ background: #ecfdf5;
94
+ color: var(--ok);
95
+ }
96
+ .stat-delta[data-dir='down'] {
97
+ background: #fef2f2;
98
+ color: var(--err);
99
+ }
100
+ .stat-chart {
101
+ margin-top: var(--spacing-xs);
102
+ }
103
+ </style>
@@ -0,0 +1,38 @@
1
+ <!--
2
+ Button-height bordered box showing one value, optionally captioned — sits inline beside a
3
+ Button (a payout amount, a countdown). `emphasis` draws it as the selected/result value.
4
+ -->
5
+ <script lang="ts">
6
+ import Span from '../text/Span.svelte';
7
+
8
+ let {
9
+ emphasis = false,
10
+ label,
11
+ value,
12
+ }: {
13
+ emphasis?: boolean;
14
+ /** Small uppercase caption under the value. */
15
+ label?: string;
16
+ value: string;
17
+ } = $props();
18
+ </script>
19
+
20
+ <div
21
+ class="flex flex-col items-center justify-center h-10 px-3.5 rounded-md box-border select-none {label
22
+ ? 'min-w-24'
23
+ : 'min-w-32'} {emphasis ? 'border-2 border-(--tx) bg-(--ch)' : 'border border-(--bd)'}"
24
+ >
25
+ {#if label}
26
+ <Span class="tracking-[-0.2px] leading-[1.2] tabular-nums">{value}</Span>
27
+ <Span class="xs uppercase tracking-wider leading-[1.2]" color="tertiary">{label}</Span>
28
+ {:else}
29
+ <Span
30
+ class="tracking-[-0.3px] tabular-nums"
31
+ bold={emphasis}
32
+ color={emphasis ? undefined : 'secondary'}
33
+ size="lg"
34
+ >
35
+ {value}
36
+ </Span>
37
+ {/if}
38
+ </div>
@@ -0,0 +1,176 @@
1
+ <script lang="ts">
2
+ import type { BackgroundColorClass, StatusColor } from '../schema';
3
+ import type { StatusRowHeight, TickDensity, TickLabelSize } from './types';
4
+
5
+ export type StatusRowSlotValue = {
6
+ color: StatusColor;
7
+ label?: string;
8
+ };
9
+
10
+ // Shared by every slot — real, empty, interactive, or not.
11
+ const baseSlotClass = 'min-w-0 flex-1 rounded-[1px]';
12
+
13
+ const heightClass: Record<StatusRowHeight, string> = {
14
+ 10: 'h-[10px]',
15
+ 20: 'h-[20px]',
16
+ 30: 'h-[30px]',
17
+ 40: 'h-[40px]',
18
+ 50: 'h-[50px]',
19
+ };
20
+
21
+ const tickLabelSizePresets: Record<TickLabelSize, { labelClass: string; spacingClass: string }> =
22
+ {
23
+ large: { labelClass: 'sm', spacingClass: 'mt-1.5' },
24
+ medium: { labelClass: 'xs', spacingClass: 'mt-1' },
25
+ small: { labelClass: 'xs', spacingClass: 'mt-0.5' },
26
+ };
27
+
28
+ const tickDensityPresets: Record<TickDensity, { markClass: string; tickCount: number }> = {
29
+ dense: { markClass: 'h-1 w-px', tickCount: 8 },
30
+ light: { markClass: 'h-1 w-px', tickCount: 3 },
31
+ normal: { markClass: 'h-1.5 w-px', tickCount: 5 },
32
+ };
33
+
34
+ const range = (length: number) => [...Array(length).keys()];
35
+
36
+ // Converts between a slot's array position and its actual key, anchored at `latestKey` (the
37
+ // newest real key, at array position maxSlots - 1) and spaced by `slotInterval` — shared by slot
38
+ // placement and tick-label computation so both agree on where a given timestamp falls.
39
+ const indexToKey = (index: number, latestKey: number, slotInterval: number) =>
40
+ latestKey - (maxSlots - 1 - index) * slotInterval;
41
+ const keyToIndex = (key: number, latestKey: number, slotInterval: number) =>
42
+ maxSlots - 1 - Math.round((latestKey - key) / slotInterval);
43
+
44
+ /**
45
+ * A fixed-width row of `maxSlots` status-colored segments, right-aligned to the newest key, with
46
+ * an optional axis below. `slots`' keys must form an arithmetic sequence with common difference:
47
+ *
48
+ * `slotInterval` — key(i+1) = key(i) + slotInterval
49
+ *
50
+ * A position with no matching key renders as an empty placeholder.
51
+ */
52
+ let {
53
+ backgroundClass = {
54
+ error: 'bg-[var(--err)]',
55
+ ok: 'bg-[var(--ok)]',
56
+ warning: 'bg-[var(--w)]',
57
+ },
58
+ formatTick,
59
+ height = 30,
60
+ maxSlots = 100,
61
+ onSelect,
62
+ selected,
63
+ slotInterval,
64
+ slots,
65
+ tickDensity = 'normal',
66
+ tickLabelSize = 'medium',
67
+ }: {
68
+ // Override to point each status at different design tokens; see BackgroundColorClass.
69
+ backgroundClass?: Record<StatusColor, BackgroundColorClass>;
70
+ // slot key -> tick label
71
+ // omit/null to render no axis at all
72
+ formatTick?: ((key: number) => string) | null;
73
+ height?: StatusRowHeight;
74
+ maxSlots?: number;
75
+ // slot key -> onSelect callback
76
+ // omit/null to render slots as non-interactive
77
+ onSelect?: ((key: number) => void) | null;
78
+ selected?: number;
79
+ // The expected gap between consecutive slot keys (e.g. the bucket interval in ms)
80
+ slotInterval: number;
81
+ // slot key -> (color, label)
82
+ // the slot key should correspond exactly with onSelect and formatTick and does not imply the actual
83
+ // relative position of the rendered slots due to potential gaps
84
+ slots: Map<number, StatusRowSlotValue>;
85
+ tickDensity?: TickDensity;
86
+ tickLabelSize?: TickLabelSize;
87
+ } = $props();
88
+
89
+ const orderedSlots = $derived([...slots.entries()].sort(([a], [b]) => a - b));
90
+
91
+ // One entry per rendered position (length `maxSlots`): undefined for empty positions (no history
92
+ // yet, or a gap in the data), the real [key, value] pair everywhere else.
93
+ const paddedSlots = $derived.by(() => {
94
+ const result: ([number, StatusRowSlotValue] | undefined)[] = Array(maxSlots).fill(undefined);
95
+ if (orderedSlots.length === 0) return result;
96
+ const [latestKey] = orderedSlots[orderedSlots.length - 1];
97
+ for (const entry of orderedSlots) {
98
+ const arrayIndex = keyToIndex(entry[0], latestKey, slotInterval);
99
+ if (arrayIndex >= 0 && arrayIndex < maxSlots) result[arrayIndex] = entry;
100
+ }
101
+ return result;
102
+ });
103
+
104
+ // `tickDensity`'s tick count, evenly spaced across the full `maxSlots` grid (including any empty
105
+ // left-padding).
106
+ const ticks = $derived.by(() => {
107
+ const tickCount = tickDensityPresets[tickDensity].tickCount;
108
+ if (!formatTick || orderedSlots.length === 0 || tickCount < 2 || maxSlots < 2) return [];
109
+ const [latestKey] = orderedSlots[orderedSlots.length - 1];
110
+ return range(tickCount).map((tickNumber) => {
111
+ const fractionAcrossGrid = tickNumber / (tickCount - 1);
112
+ const slotIndex = Math.round(fractionAcrossGrid * (maxSlots - 1));
113
+ return {
114
+ label: formatTick(indexToKey(slotIndex, latestKey, slotInterval)),
115
+ positionPercent: (slotIndex / (maxSlots - 1)) * 100,
116
+ };
117
+ });
118
+ });
119
+ </script>
120
+
121
+ <div>
122
+ <div class="flex {heightClass[height]} items-stretch gap-px">
123
+ {#each range(maxSlots) as index (index)}
124
+ {@const slot = paddedSlots[index]}
125
+ {#if slot}
126
+ {@const [key, value] = slot}
127
+ {@const isDeselected = selected !== undefined && selected !== key}
128
+ {@const slotColor = backgroundClass[value.color]}
129
+ {#if onSelect}
130
+ <button
131
+ class="{baseSlotClass} cursor-pointer {slotColor} transition-opacity hover:opacity-80"
132
+ class:opacity-35={isDeselected}
133
+ aria-label={value.label}
134
+ onclick={() => onSelect(key)}
135
+ type="button"
136
+ ></button>
137
+ {:else}
138
+ <div
139
+ class="{baseSlotClass} {slotColor}"
140
+ class:opacity-35={isDeselected}
141
+ title={value.label}
142
+ ></div>
143
+ {/if}
144
+ {:else}
145
+ <div class="{baseSlotClass} bg-[var(--bds)] opacity-40"></div>
146
+ {/if}
147
+ {/each}
148
+ </div>
149
+ <!-- Axis: tick marks + labels below the bar -->
150
+ {#if ticks.length > 0}
151
+ <div class="relative h-3 {tickLabelSizePresets[tickLabelSize].spacingClass}">
152
+ {#each ticks as tick, index (index)}
153
+ <!-- tick mark -->
154
+ <span
155
+ style="--tick-left: {tick.positionPercent}%;"
156
+ class="absolute top-0 left-[var(--tick-left)] w-px -translate-x-1/2 bg-[var(--bd)] {tickDensityPresets[
157
+ tickDensity
158
+ ].markClass}"
159
+ ></span>
160
+ <!-- tick label -->
161
+ <span
162
+ style="--tick-left: {tick.positionPercent}%;"
163
+ class="absolute top-2 left-[var(--tick-left)] tabular-nums whitespace-nowrap text-[var(--txt)] {tickLabelSizePresets[
164
+ tickLabelSize
165
+ ].labelClass} {index === 0
166
+ ? 'translate-x-0'
167
+ : index === ticks.length - 1
168
+ ? '-translate-x-full'
169
+ : '-translate-x-1/2'}"
170
+ >
171
+ {tick.label}
172
+ </span>
173
+ {/each}
174
+ </div>
175
+ {/if}
176
+ </div>
@@ -0,0 +1,5 @@
1
+ export type StatusRowHeight = 10 | 20 | 30 | 40 | 50;
2
+
3
+ export type TickLabelSize = 'large' | 'medium' | 'small';
4
+
5
+ export type TickDensity = 'dense' | 'light' | 'normal';
@@ -0,0 +1,34 @@
1
+ <script lang="ts">
2
+ import { Checkbox } from '@zeyolabs/ui/form/primitives';
3
+
4
+ /**
5
+ * Content for a table's select-all header cell — place inside a <TableCell> (or a
6
+ * GroupedGrid column's `headerCell`, which already provides one). Pair with `SelectRowCell`.
7
+ */
8
+ let {
9
+ allSelected,
10
+ onToggleAll,
11
+ someSelected = false,
12
+ }: {
13
+ allSelected: boolean;
14
+ onToggleAll: () => void;
15
+ someSelected?: boolean;
16
+ } = $props();
17
+ </script>
18
+
19
+ <div class="select-cell">
20
+ <Checkbox
21
+ aria-label="Select all rows"
22
+ checked={allSelected}
23
+ indeterminate={!allSelected && someSelected}
24
+ onCheckedChange={onToggleAll}
25
+ />
26
+ </div>
27
+
28
+ <style>
29
+ .select-cell {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ }
34
+ </style>
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import SelectAllCell from './SelectAllCell.svelte';
3
+ import TableCell from './TableCell.svelte';
4
+
5
+ /**
6
+ * SelectAllCell pre-wrapped in its own fixed-width <TableCell> — drop directly inside
7
+ * <TableRow head>, no manual width/padding needed. Use SelectAllCell directly instead only
8
+ * inside a GroupedGrid column (its headerCell already provides the TableCell wrapper).
9
+ */
10
+ let {
11
+ allSelected,
12
+ onToggleAll,
13
+ someSelected = false,
14
+ stickyLeft = '0px',
15
+ }: {
16
+ allSelected: boolean;
17
+ onToggleAll: () => void;
18
+ someSelected?: boolean;
19
+ stickyLeft?: string;
20
+ } = $props();
21
+ </script>
22
+
23
+ <TableCell style="width: 40px; padding: 0 8px 0 16px;" {stickyLeft}>
24
+ <SelectAllCell {allSelected} {onToggleAll} {someSelected} />
25
+ </TableCell>
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { Checkbox } from '@zeyolabs/ui/form/primitives';
3
+
4
+ /**
5
+ * Content for a table's select-row body cell — place inside a <TableCell> (or a
6
+ * GroupedGrid column's `cell`, which already provides one). Pair with `SelectAllCell`.
7
+ */
8
+ let {
9
+ label = 'row',
10
+ onToggle,
11
+ selected,
12
+ }: {
13
+ /** Used in the checkbox's aria-label, e.g. "Select {label}" — pass something identifying
14
+ * (a name, an id) when available; falls back to a generic "row". */
15
+ label?: string;
16
+ onToggle: () => void;
17
+ selected: boolean;
18
+ } = $props();
19
+ </script>
20
+
21
+ <div class="select-cell">
22
+ <Checkbox aria-label={`Select ${label}`} checked={selected} onCheckedChange={onToggle} />
23
+ </div>
24
+
25
+ <style>
26
+ .select-cell {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ }
31
+ </style>
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import SelectRowCell from './SelectRowCell.svelte';
3
+ import TableCell from './TableCell.svelte';
4
+
5
+ /**
6
+ * SelectRowCell pre-wrapped in its own fixed-width <TableCell> — drop directly inside
7
+ * <TableRow>, no manual width/padding needed. Use SelectRowCell directly instead only
8
+ * inside a GroupedGrid column (its cell already provides the TableCell wrapper).
9
+ */
10
+ let {
11
+ label = 'row',
12
+ onToggle,
13
+ selected,
14
+ stickyLeft = '0px',
15
+ }: {
16
+ label?: string;
17
+ onToggle: () => void;
18
+ selected: boolean;
19
+ stickyLeft?: string;
20
+ } = $props();
21
+ </script>
22
+
23
+ <TableCell style="width: 40px; padding: 0 8px 0 16px;" {stickyLeft} stopPropagation>
24
+ <SelectRowCell {label} {onToggle} {selected} />
25
+ </TableCell>
@@ -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>