@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.
- package/README.md +43 -2
- package/back-button/BackButton.svelte +26 -0
- package/badge/Badge.svelte +73 -0
- package/badge/PromoBadge.svelte +319 -0
- package/badge/color.ts +10 -0
- package/bar/Bar.svelte +63 -0
- package/base.css +47 -0
- package/boundary/Boundary.svelte +59 -0
- package/boundary/BoundaryFailed.svelte +40 -0
- package/boundary/PendingTracker.svelte +14 -0
- package/boundary/pending-context.ts +15 -0
- package/boundary/pending-flag.svelte.ts +33 -0
- package/boundary/report-boundary-error.ts +13 -0
- package/card/Card.svelte +239 -0
- package/card/CardBody.svelte +41 -0
- package/card/CardFooter.svelte +36 -0
- package/card/CardHeader.svelte +36 -0
- package/copy/CopyArea.svelte +37 -0
- package/copy/CopyButton.svelte +59 -0
- package/copy/copy-state.svelte.ts +23 -0
- package/copy/types.ts +1 -0
- package/dialog/ConfirmDialog.svelte +61 -0
- package/dialog/Dialog.svelte +31 -0
- package/dialog/DialogBody.svelte +88 -0
- package/dialog/DialogCloseButton.svelte +26 -0
- package/dialog/DialogFooter.svelte +23 -0
- package/dialog/DialogTrigger.svelte +15 -0
- package/distribution-bar/DistributionBar.svelte +37 -0
- package/drawer/Drawer.svelte +31 -0
- package/drawer/DrawerBody.svelte +61 -0
- package/empty-state/EmptyState.svelte +74 -0
- package/error/ErrorPage.svelte +54 -0
- package/eyebrow/Eyebrow.svelte +10 -0
- package/faq/FAQList.svelte +89 -0
- package/filter/FilterChipGroup.svelte +78 -0
- package/filter/FilterOptionList.svelte +188 -0
- package/filter/FilterPopover.svelte +122 -0
- package/filter/filter-draft.svelte.ts +25 -0
- package/form/Button.svelte +73 -0
- package/form/Field.svelte +111 -0
- package/form/FieldLabel.svelte +19 -0
- package/form/Form.svelte +133 -0
- package/form/PhoneField.svelte +214 -0
- package/form/UnsavedBar.svelte +22 -0
- package/form/field-view.svelte.ts +213 -0
- package/form/fields/CheckboxField.svelte +85 -0
- package/form/fields/Combobox.svelte +327 -0
- package/form/fields/ComboboxAction.svelte +16 -0
- package/form/fields/DateField.svelte +31 -0
- package/form/fields/DateRangeField.svelte +188 -0
- package/form/fields/DateRangePresetField.svelte +119 -0
- package/form/fields/EmailField.svelte +63 -0
- package/form/fields/FileField.svelte +145 -0
- package/form/fields/HexColorField.svelte +83 -0
- package/form/fields/IntervalField.svelte +100 -0
- package/form/fields/MessageField.svelte +99 -0
- package/form/fields/NumberField.svelte +64 -0
- package/form/fields/Option.svelte +48 -0
- package/form/fields/OptionRegistrar.svelte +15 -0
- package/form/fields/PasswordField.svelte +44 -0
- package/form/fields/RadioField.svelte +60 -0
- package/form/fields/RichTextField.svelte +221 -0
- package/form/fields/SelectField.svelte +216 -0
- package/form/fields/SliderField.svelte +182 -0
- package/form/fields/SwitchField.svelte +102 -0
- package/form/fields/TextField.svelte +72 -0
- package/form/fields/TimeField.svelte +31 -0
- package/form/fields/index.ts +19 -0
- package/form/fields/select-field-context.ts +21 -0
- package/form/index.ts +21 -0
- package/form/primitives/Checkbox.svelte +103 -0
- package/form/primitives/DateInput.svelte +51 -0
- package/form/primitives/IconInputWrapper.svelte +40 -0
- package/form/primitives/Input.svelte +47 -0
- package/form/primitives/SearchBar.svelte +37 -0
- package/form/primitives/Select.svelte +139 -0
- package/form/primitives/TextArea.svelte +51 -0
- package/form/primitives/index.ts +6 -0
- package/gallery/ImageGallery.svelte +133 -0
- package/gallery/flickity-fullscreen.d.ts +2 -0
- package/grouped-grid/GroupedGrid.svelte +143 -0
- package/grouped-grid/types.ts +25 -0
- package/layout/Cluster.svelte +92 -0
- package/layout/Container.svelte +9 -0
- package/layout/Grid.svelte +131 -0
- package/layout/Section.svelte +146 -0
- package/layout/Shell.svelte +32 -0
- package/layout/SplitShell.svelte +47 -0
- package/layout/Stack.svelte +78 -0
- package/list-row/ListRow.svelte +77 -0
- package/menu/MenuButton.svelte +101 -0
- package/mini-stat/MiniStat.svelte +13 -0
- package/package.json +169 -5
- package/page-hero/PageHero.svelte +35 -0
- package/pagination/Pagination.svelte +44 -0
- package/pagination/finder-pagination.svelte.ts +55 -0
- package/pagination/finder-search.svelte.ts +292 -0
- package/percentage-ring/PercentageRing.svelte +76 -0
- package/percentage-ring/types.ts +1 -0
- package/popover/InfoTip.svelte +36 -0
- package/popover/Popover.svelte +157 -0
- package/query-state/QueryState.svelte +42 -0
- package/schema.ts +20 -0
- package/skeleton/Skeleton.svelte +86 -0
- package/skeleton/SkeletonButton.svelte +27 -0
- package/skeleton/SkeletonCard.svelte +49 -0
- package/skeleton/SkeletonCircle.svelte +25 -0
- package/skeleton/SkeletonField.svelte +19 -0
- package/skeleton/SkeletonRow.svelte +47 -0
- package/skeleton/SkeletonText.svelte +46 -0
- package/skeleton/TableSkeleton.svelte +60 -0
- package/spacing.css +32 -0
- package/stat/NextPayoutCountdown.svelte +52 -0
- package/stat/Stat.svelte +103 -0
- package/stat/ValueBox.svelte +38 -0
- package/status-row/StatusRow.svelte +176 -0
- package/status-row/types.ts +5 -0
- package/table/SelectAllCell.svelte +34 -0
- package/table/SelectAllTableCell.svelte +25 -0
- package/table/SelectRowCell.svelte +31 -0
- package/table/SelectRowTableCell.svelte +25 -0
- package/table/SelectionBar.svelte +68 -0
- package/table/SelectionOverlay.svelte +83 -0
- package/table/Table.svelte +64 -0
- package/table/TableCell.svelte +185 -0
- package/table/TableRow.svelte +86 -0
- package/table/index.ts +9 -0
- package/table/selection.svelte.ts +79 -0
- package/tabs/TabBlock.svelte +56 -0
- package/tabs/TabButton.svelte +33 -0
- package/template.css +1393 -0
- package/text/Span.svelte +83 -0
- package/text/Text.svelte +94 -0
- package/text/Title.svelte +75 -0
- package/text/color.ts +41 -0
- package/theme/theme.svelte.ts +33 -0
- package/tokens.css +62 -0
- package/typography.css +164 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { HTMLTextareaAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
type Props = HTMLTextareaAttributes & {
|
|
6
|
+
class?: string;
|
|
7
|
+
defaultHeight?: number;
|
|
8
|
+
icon?: Component;
|
|
9
|
+
resize?: boolean;
|
|
10
|
+
value?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
class: className,
|
|
15
|
+
defaultHeight = 100,
|
|
16
|
+
icon,
|
|
17
|
+
resize = false,
|
|
18
|
+
value = $bindable(),
|
|
19
|
+
...rest
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if icon}
|
|
24
|
+
{@const Icon = icon}
|
|
25
|
+
<div class="form-input-wrapper">
|
|
26
|
+
<div class="form-input-icon form-input-icon--top">
|
|
27
|
+
<Icon />
|
|
28
|
+
</div>
|
|
29
|
+
<textarea
|
|
30
|
+
style="height: {defaultHeight}px; min-height: {defaultHeight}px;"
|
|
31
|
+
class={[
|
|
32
|
+
'form-input',
|
|
33
|
+
'form-textarea',
|
|
34
|
+
'form-input--with-icon',
|
|
35
|
+
resize && 'form-textarea--resize',
|
|
36
|
+
className,
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(' ')}
|
|
40
|
+
bind:value
|
|
41
|
+
{...rest}></textarea>
|
|
42
|
+
</div>
|
|
43
|
+
{:else}
|
|
44
|
+
<textarea
|
|
45
|
+
style="height: {defaultHeight}px; min-height: {defaultHeight}px;"
|
|
46
|
+
class={['form-input', 'form-textarea', resize && 'form-textarea--resize', className]
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.join(' ')}
|
|
49
|
+
bind:value
|
|
50
|
+
{...rest}></textarea>
|
|
51
|
+
{/if}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Checkbox } from './Checkbox.svelte';
|
|
2
|
+
export { default as DateInput } from './DateInput.svelte';
|
|
3
|
+
export { default as Input } from './Input.svelte';
|
|
4
|
+
export { default as SearchBar } from './SearchBar.svelte';
|
|
5
|
+
export { default as Select } from './Select.svelte';
|
|
6
|
+
export { default as TextArea } from './TextArea.svelte';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/// <reference path="./flickity-fullscreen.d.ts" />
|
|
3
|
+
import type Flickity from 'flickity';
|
|
4
|
+
|
|
5
|
+
import { onMount } from 'svelte';
|
|
6
|
+
import 'flickity-fullscreen/fullscreen.css';
|
|
7
|
+
import 'flickity/css/flickity.css';
|
|
8
|
+
|
|
9
|
+
type Image = { alt?: string; src: string };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A product-style image gallery on Flickity: a swipeable slideshow with arrows and fullscreen,
|
|
13
|
+
* driven by a thumbnail strip. `src` is the final image URL; `name` is the fallback alt text.
|
|
14
|
+
*/
|
|
15
|
+
let { images, name }: { images: Image[]; name: string } = $props();
|
|
16
|
+
|
|
17
|
+
let slideshow = $state<HTMLElement>();
|
|
18
|
+
let thumbnails = $state<HTMLElement>();
|
|
19
|
+
|
|
20
|
+
// Same setup as the legacy product page: a fullscreen-capable slideshow, driven by a thumbnail
|
|
21
|
+
// strip. Flickity touches `window` on import, so it is only loaded in the browser.
|
|
22
|
+
onMount(() => {
|
|
23
|
+
let main: Flickity | undefined;
|
|
24
|
+
let nav: Flickity | undefined;
|
|
25
|
+
let cancelled = false;
|
|
26
|
+
|
|
27
|
+
void (async () => {
|
|
28
|
+
const { default: FlickityClass } = await import('flickity');
|
|
29
|
+
await import('flickity-fullscreen');
|
|
30
|
+
if (cancelled || !slideshow) return;
|
|
31
|
+
main = new FlickityClass(slideshow, {
|
|
32
|
+
fullscreen: true,
|
|
33
|
+
imagesLoaded: true,
|
|
34
|
+
pageDots: false,
|
|
35
|
+
} as Flickity.Options);
|
|
36
|
+
if (thumbnails) {
|
|
37
|
+
nav = new FlickityClass(thumbnails, {
|
|
38
|
+
asNavFor: slideshow,
|
|
39
|
+
contain: true,
|
|
40
|
+
freeScroll: true,
|
|
41
|
+
imagesLoaded: true,
|
|
42
|
+
pageDots: false,
|
|
43
|
+
prevNextButtons: false,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
cancelled = true;
|
|
50
|
+
nav?.destroy();
|
|
51
|
+
main?.destroy();
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
{#if images.length > 0}
|
|
57
|
+
<div class="gallery">
|
|
58
|
+
<div bind:this={slideshow} class="slideshow" aria-label="{name} images">
|
|
59
|
+
{#each images as image (image.src)}
|
|
60
|
+
<div class="slide">
|
|
61
|
+
<img alt={image.alt || name} src={image.src} />
|
|
62
|
+
</div>
|
|
63
|
+
{/each}
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
{#if images.length > 1}
|
|
67
|
+
<div bind:this={thumbnails} class="thumbnails" aria-label="Choose an image">
|
|
68
|
+
{#each images as image (image.src)}
|
|
69
|
+
<div class="thumb"><img alt="" src={image.src} /></div>
|
|
70
|
+
{/each}
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
73
|
+
</div>
|
|
74
|
+
{/if}
|
|
75
|
+
|
|
76
|
+
<style>
|
|
77
|
+
/* Before Flickity starts (and without JavaScript) show the first slide, not a stacked column. */
|
|
78
|
+
.slideshow:not(:global(.flickity-enabled)),
|
|
79
|
+
.thumbnails:not(:global(.flickity-enabled)) {
|
|
80
|
+
display: flex;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.slideshow {
|
|
85
|
+
border: 1px solid var(--bd);
|
|
86
|
+
border-radius: var(--radius-lg);
|
|
87
|
+
margin-bottom: 0.75rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.slide {
|
|
91
|
+
width: 100%;
|
|
92
|
+
aspect-ratio: 1;
|
|
93
|
+
background: var(--sf);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.slide img {
|
|
97
|
+
width: 100%;
|
|
98
|
+
height: 100%;
|
|
99
|
+
object-fit: contain;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.thumb {
|
|
103
|
+
width: 5rem;
|
|
104
|
+
aspect-ratio: 1;
|
|
105
|
+
margin-right: 0.5rem;
|
|
106
|
+
border-radius: var(--radius-md);
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
opacity: 0.65;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.thumb img {
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
object-fit: cover;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.thumb:global(.is-selected),
|
|
119
|
+
.thumb:global(.is-nav-selected) {
|
|
120
|
+
opacity: 1;
|
|
121
|
+
outline: 2px solid var(--primary-strong);
|
|
122
|
+
outline-offset: -2px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Flickity's own controls, in the shop's colours. */
|
|
126
|
+
.gallery :global(.flickity-button) {
|
|
127
|
+
color: var(--tx);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.gallery :global(.flickity-button:focus-visible) {
|
|
131
|
+
box-shadow: 0 0 0 2px var(--primary-strong);
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<script generics="T" lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
import type { GridColumn, GridGroup } from './types';
|
|
5
|
+
|
|
6
|
+
import Table from '../table/Table.svelte';
|
|
7
|
+
import TableCell from '../table/TableCell.svelte';
|
|
8
|
+
import TableRow from '../table/TableRow.svelte';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A real <table> (not CSS grid), so column widths sync across rows natively. Supply either `rows`
|
|
12
|
+
* (flat, no groups), `rows` + `groupBy` (flat rows the component buckets itself), or pre-built
|
|
13
|
+
* `groups` (full control over bucketing/sorting, e.g. merging two row sources). `columns` and their
|
|
14
|
+
* `cell` snippets decide everything about content — this component only owns table/grouping mechanics.
|
|
15
|
+
*/
|
|
16
|
+
let {
|
|
17
|
+
bordered = false,
|
|
18
|
+
columns,
|
|
19
|
+
compact = false,
|
|
20
|
+
empty,
|
|
21
|
+
groupBy,
|
|
22
|
+
groupMarker,
|
|
23
|
+
groups,
|
|
24
|
+
overlay,
|
|
25
|
+
rowKey,
|
|
26
|
+
rows,
|
|
27
|
+
rowSelected,
|
|
28
|
+
rowWarning,
|
|
29
|
+
showHeader = true,
|
|
30
|
+
stickyHeader = false,
|
|
31
|
+
}: {
|
|
32
|
+
// Vertical rules between columns — see Table's `bordered`.
|
|
33
|
+
bordered?: boolean;
|
|
34
|
+
columns: GridColumn<T>[];
|
|
35
|
+
// Tighter row padding for a dense drill-down grid — see TableCell's `compact`.
|
|
36
|
+
compact?: boolean;
|
|
37
|
+
// Rendered as a single row spanning every column when there are no rows at all.
|
|
38
|
+
empty?: Snippet;
|
|
39
|
+
groupBy?: (row: T) => string;
|
|
40
|
+
// Rendered once per row (not per group), so a caller's own decoration (e.g. a colored left
|
|
41
|
+
// border) reads as continuous down a group's rows via plain CSS.
|
|
42
|
+
groupMarker?: Snippet<[group: GridGroup<T>]>;
|
|
43
|
+
groups?: GridGroup<T>[];
|
|
44
|
+
// A `SelectionOverlay` anchored to the header row — see Table's own `overlay`.
|
|
45
|
+
overlay?: Snippet;
|
|
46
|
+
// Independent of which columns are shown — a row's identity can't depend on what's visible.
|
|
47
|
+
rowKey: (row: T) => string;
|
|
48
|
+
rows?: T[];
|
|
49
|
+
// Highlights a row (see TableRow's `selected`) — caller decides what "selected" means.
|
|
50
|
+
rowSelected?: (row: T) => boolean;
|
|
51
|
+
// Tints a row (see TableRow's `warning`) — caller decides what "warning" means.
|
|
52
|
+
rowWarning?: (row: T) => boolean;
|
|
53
|
+
showHeader?: boolean;
|
|
54
|
+
// Pins the header row — see TableRow's `sticky`.
|
|
55
|
+
stickyHeader?: boolean;
|
|
56
|
+
} = $props();
|
|
57
|
+
|
|
58
|
+
const colspan = $derived(columns.length + (groupMarker ? 1 : 0));
|
|
59
|
+
|
|
60
|
+
const effectiveGroups = $derived.by((): GridGroup<T>[] => {
|
|
61
|
+
if (groups) return groups;
|
|
62
|
+
const source = rows ?? [];
|
|
63
|
+
if (!groupBy) return [{ key: '__ungrouped__', label: '', rows: source }];
|
|
64
|
+
const rowsByKey = new Map<string, T[]>();
|
|
65
|
+
for (const row of source) {
|
|
66
|
+
const key = groupBy(row);
|
|
67
|
+
const existing = rowsByKey.get(key);
|
|
68
|
+
if (existing) existing.push(row);
|
|
69
|
+
else rowsByKey.set(key, [row]);
|
|
70
|
+
}
|
|
71
|
+
return [...rowsByKey.entries()].map(([key, groupRows]) => ({
|
|
72
|
+
key,
|
|
73
|
+
label: key,
|
|
74
|
+
rows: groupRows,
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const isEmpty = $derived(effectiveGroups.every((group) => group.rows.length === 0));
|
|
79
|
+
|
|
80
|
+
// Cumulative left offset for each sticky column, in declaration order — `width` must be a
|
|
81
|
+
// pixel value for a sticky column so these sum meaningfully.
|
|
82
|
+
const stickyLefts = $derived.by(() => {
|
|
83
|
+
let offset = 0;
|
|
84
|
+
const map = new Map<string, string>();
|
|
85
|
+
for (const column of columns) {
|
|
86
|
+
if (!column.sticky) continue;
|
|
87
|
+
map.set(column.key, `${offset}px`);
|
|
88
|
+
offset += parseFloat(column.width ?? '0');
|
|
89
|
+
}
|
|
90
|
+
return map;
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<Table {bordered} {overlay}>
|
|
95
|
+
{#if showHeader}
|
|
96
|
+
<TableRow head sticky={stickyHeader}>
|
|
97
|
+
{#if groupMarker}
|
|
98
|
+
<TableCell style="padding: 0; width: 6px;" {compact} />
|
|
99
|
+
{/if}
|
|
100
|
+
{#each columns as column (column.key)}
|
|
101
|
+
<TableCell
|
|
102
|
+
style={column.width ? `width: ${column.width};` : ''}
|
|
103
|
+
align={column.align ?? 'left'}
|
|
104
|
+
{compact}
|
|
105
|
+
stickyLeft={stickyLefts.get(column.key)}
|
|
106
|
+
>
|
|
107
|
+
{#if column.headerCell}
|
|
108
|
+
{@render column.headerCell(column)}
|
|
109
|
+
{:else}
|
|
110
|
+
{column.label}
|
|
111
|
+
{/if}
|
|
112
|
+
</TableCell>
|
|
113
|
+
{/each}
|
|
114
|
+
</TableRow>
|
|
115
|
+
{/if}
|
|
116
|
+
{#each effectiveGroups as group (group.key)}
|
|
117
|
+
{#each group.rows as row, index (rowKey(row))}
|
|
118
|
+
<TableRow selected={rowSelected?.(row) ?? false} warning={rowWarning?.(row) ?? false}>
|
|
119
|
+
{#if groupMarker}
|
|
120
|
+
<TableCell style="padding: 0;" {compact}>
|
|
121
|
+
{@render groupMarker(group)}
|
|
122
|
+
</TableCell>
|
|
123
|
+
{/if}
|
|
124
|
+
{#each columns as column (column.key)}
|
|
125
|
+
<TableCell
|
|
126
|
+
align={column.align ?? 'left'}
|
|
127
|
+
{compact}
|
|
128
|
+
stickyLeft={stickyLefts.get(column.key)}
|
|
129
|
+
>
|
|
130
|
+
{@render column.cell(row, { column, group, isFirstInGroup: index === 0 })}
|
|
131
|
+
</TableCell>
|
|
132
|
+
{/each}
|
|
133
|
+
</TableRow>
|
|
134
|
+
{/each}
|
|
135
|
+
{/each}
|
|
136
|
+
{#if isEmpty && empty}
|
|
137
|
+
<TableRow>
|
|
138
|
+
<TableCell style="text-align: center;" {colspan}>
|
|
139
|
+
{@render empty()}
|
|
140
|
+
</TableCell>
|
|
141
|
+
</TableRow>
|
|
142
|
+
{/if}
|
|
143
|
+
</Table>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
|
|
3
|
+
export type GridGroup<T> = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
rows: T[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type GridColumn<T> = {
|
|
10
|
+
align?: 'left' | 'right';
|
|
11
|
+
cell: Snippet<
|
|
12
|
+
[row: T, context: { column: GridColumn<T>; group: GridGroup<T>; isFirstInGroup: boolean }]
|
|
13
|
+
>;
|
|
14
|
+
// Custom header content (e.g. an icon/badge alongside the label) — falls back to plain
|
|
15
|
+
// `label` text when omitted. Receives the column itself, so one shared snippet can render
|
|
16
|
+
// per-column data without a separate binding per instance.
|
|
17
|
+
headerCell?: Snippet<[column: GridColumn<T>]>;
|
|
18
|
+
key: string;
|
|
19
|
+
label: string;
|
|
20
|
+
// Pins this column via position: sticky at the cumulative left offset of the sticky
|
|
21
|
+
// columns before it (declaration order in `columns`). Requires `width` to be a pixel
|
|
22
|
+
// value ('160px', not '10rem'/'20%') so the offsets can be summed.
|
|
23
|
+
sticky?: boolean;
|
|
24
|
+
width?: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
/** Horizontal, wrapping flex row with a scale-backed gap — replaces the filter/toolbar row
|
|
5
|
+
* (flex items-center gap-2 flex-wrap) reimplemented with drifting gaps everywhere. */
|
|
6
|
+
let {
|
|
7
|
+
bg,
|
|
8
|
+
children,
|
|
9
|
+
class: cls = '',
|
|
10
|
+
gap = 'sm',
|
|
11
|
+
justify = 'start',
|
|
12
|
+
nowrap = false,
|
|
13
|
+
}: {
|
|
14
|
+
/** Omit for transparent (the historical default). 'rainbow' is the animated gradient
|
|
15
|
+
* panel used for feature/product-UI showcase blocks. */
|
|
16
|
+
bg?: 'bg' | 'rainbow' | 'sf' | 'sfh' | 'tertiary';
|
|
17
|
+
children: Snippet;
|
|
18
|
+
/** Layout-only, same rule as Button/Text — margin, or a conditional class computed by
|
|
19
|
+
* the caller (e.g. `class={active ? 'row-active' : ''}`) for state Cluster itself has
|
|
20
|
+
* no prop for. Don't sneak a color/gap override in through this — use the real props. */
|
|
21
|
+
class?: string;
|
|
22
|
+
gap?: 'md' | 'sm' | 'xs';
|
|
23
|
+
justify?: 'between' | 'center' | 'end' | 'start';
|
|
24
|
+
/** Keep every item on one line instead of wrapping (a row that truncates one item). */
|
|
25
|
+
nowrap?: boolean;
|
|
26
|
+
} = $props();
|
|
27
|
+
|
|
28
|
+
const JUSTIFY: Record<'between' | 'center' | 'end' | 'start', string> = {
|
|
29
|
+
between: 'space-between',
|
|
30
|
+
center: 'center',
|
|
31
|
+
end: 'flex-end',
|
|
32
|
+
start: 'flex-start',
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
style:justify-content={JUSTIFY[justify]}
|
|
38
|
+
class="cluster {cls}"
|
|
39
|
+
class:nowrap
|
|
40
|
+
data-bg={bg}
|
|
41
|
+
data-gap={gap}
|
|
42
|
+
>
|
|
43
|
+
{@render children()}
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<style>
|
|
47
|
+
.cluster {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-wrap: wrap;
|
|
50
|
+
align-items: center;
|
|
51
|
+
}
|
|
52
|
+
.cluster.nowrap {
|
|
53
|
+
flex-wrap: nowrap;
|
|
54
|
+
}
|
|
55
|
+
.cluster[data-gap='xs'] {
|
|
56
|
+
gap: var(--spacing-xs);
|
|
57
|
+
}
|
|
58
|
+
.cluster[data-gap='sm'] {
|
|
59
|
+
gap: var(--spacing-sm);
|
|
60
|
+
}
|
|
61
|
+
.cluster[data-gap='md'] {
|
|
62
|
+
gap: var(--spacing-md);
|
|
63
|
+
}
|
|
64
|
+
.cluster[data-bg='bg'] {
|
|
65
|
+
background: var(--bg);
|
|
66
|
+
}
|
|
67
|
+
.cluster[data-bg='sf'] {
|
|
68
|
+
background: var(--sf);
|
|
69
|
+
}
|
|
70
|
+
.cluster[data-bg='sfh'] {
|
|
71
|
+
background: var(--sfh);
|
|
72
|
+
}
|
|
73
|
+
.cluster[data-bg='tertiary'] {
|
|
74
|
+
background: var(--tertiary);
|
|
75
|
+
}
|
|
76
|
+
.cluster[data-bg='rainbow'] {
|
|
77
|
+
background-image: linear-gradient(160deg, #4f46e5, #3b82f6, #a855f7, #f59e0b, #ef4444, #0ea5e9);
|
|
78
|
+
background-size: 200% 200%;
|
|
79
|
+
animation: cluster-rainbow-shift 12s ease infinite;
|
|
80
|
+
}
|
|
81
|
+
@keyframes cluster-rainbow-shift {
|
|
82
|
+
0% {
|
|
83
|
+
background-position: 0% 0%;
|
|
84
|
+
}
|
|
85
|
+
50% {
|
|
86
|
+
background-position: 100% 100%;
|
|
87
|
+
}
|
|
88
|
+
100% {
|
|
89
|
+
background-position: 0% 0%;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
/** CSS grid wrapper — replaces both fixed grid-cols-N stat-card grids and inline
|
|
5
|
+
* grid-template-columns two-column splits with one prop.
|
|
6
|
+
*
|
|
7
|
+
* - `columns` as a number → `repeat(N, 1fr)`, equal columns.
|
|
8
|
+
* - `columns` as a string → used verbatim (e.g. "2fr 1fr" for an asymmetric split).
|
|
9
|
+
* - `minColumnWidth` set → ignores `columns`, uses `repeat(auto-fit, minmax(width, 1fr))`, so
|
|
10
|
+
* the column count adapts continuously to available width with no breakpoint to hand-pick. */
|
|
11
|
+
let {
|
|
12
|
+
bg,
|
|
13
|
+
children,
|
|
14
|
+
class: cls = '',
|
|
15
|
+
columns = 2,
|
|
16
|
+
fill = false,
|
|
17
|
+
gap = 'md',
|
|
18
|
+
minColumnWidth,
|
|
19
|
+
stack = false,
|
|
20
|
+
}: {
|
|
21
|
+
/** Omit for transparent (the historical default). 'rainbow' is the animated gradient
|
|
22
|
+
* panel used for feature/product-UI showcase blocks. */
|
|
23
|
+
bg?: 'bg' | 'rainbow' | 'sf' | 'sfh' | 'tertiary';
|
|
24
|
+
children: Snippet;
|
|
25
|
+
/** Layout-only, same rule as Button/Text — margin, or a conditional class computed by
|
|
26
|
+
* the caller (e.g. `class={active ? 'row-active' : ''}`) for state Grid itself has no
|
|
27
|
+
* prop for. Don't sneak a color/gap override in through this — use the real props. */
|
|
28
|
+
class?: string;
|
|
29
|
+
columns?: number | string;
|
|
30
|
+
/** In a flex column parent, takes the space left and lets the rows shrink to it, so cards
|
|
31
|
+
* with their own scrolling region scroll inside the grid instead of stretching it. */
|
|
32
|
+
fill?: boolean;
|
|
33
|
+
gap?: '2xl' | '3xl' | '4xl' | 'lg' | 'md' | 'none' | 'sm' | 'xl';
|
|
34
|
+
minColumnWidth?: string;
|
|
35
|
+
/** Collapse to a single column below 960px. */
|
|
36
|
+
stack?: boolean;
|
|
37
|
+
} = $props();
|
|
38
|
+
|
|
39
|
+
const templateColumns = $derived(
|
|
40
|
+
minColumnWidth
|
|
41
|
+
? `repeat(auto-fit, minmax(${minColumnWidth}, 1fr))`
|
|
42
|
+
: typeof columns === 'number'
|
|
43
|
+
? `repeat(${columns}, 1fr)`
|
|
44
|
+
: columns
|
|
45
|
+
);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
style:grid-template-columns={templateColumns}
|
|
50
|
+
class="grid-layout {cls}"
|
|
51
|
+
class:fill
|
|
52
|
+
class:stack
|
|
53
|
+
data-bg={bg}
|
|
54
|
+
data-gap={gap}
|
|
55
|
+
>
|
|
56
|
+
{@render children()}
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
.grid-layout {
|
|
61
|
+
display: grid;
|
|
62
|
+
}
|
|
63
|
+
.grid-layout.fill {
|
|
64
|
+
flex: 1;
|
|
65
|
+
min-height: 0;
|
|
66
|
+
}
|
|
67
|
+
.grid-layout[data-gap='none'] {
|
|
68
|
+
gap: 0;
|
|
69
|
+
}
|
|
70
|
+
.grid-layout[data-gap='sm'] {
|
|
71
|
+
gap: var(--spacing-sm);
|
|
72
|
+
}
|
|
73
|
+
.grid-layout[data-gap='md'] {
|
|
74
|
+
gap: var(--spacing-md);
|
|
75
|
+
}
|
|
76
|
+
.grid-layout[data-gap='lg'] {
|
|
77
|
+
gap: var(--spacing-lg);
|
|
78
|
+
}
|
|
79
|
+
.grid-layout[data-gap='xl'] {
|
|
80
|
+
gap: var(--spacing-xl);
|
|
81
|
+
}
|
|
82
|
+
.grid-layout[data-gap='2xl'] {
|
|
83
|
+
gap: var(--spacing-2xl);
|
|
84
|
+
}
|
|
85
|
+
.grid-layout[data-gap='3xl'] {
|
|
86
|
+
gap: var(--spacing-3xl);
|
|
87
|
+
}
|
|
88
|
+
.grid-layout[data-gap='4xl'] {
|
|
89
|
+
gap: var(--spacing-4xl);
|
|
90
|
+
}
|
|
91
|
+
.grid-layout[data-bg='bg'] {
|
|
92
|
+
background: var(--bg);
|
|
93
|
+
}
|
|
94
|
+
.grid-layout[data-bg='sf'] {
|
|
95
|
+
background: var(--sf);
|
|
96
|
+
}
|
|
97
|
+
.grid-layout[data-bg='sfh'] {
|
|
98
|
+
background: var(--sfh);
|
|
99
|
+
}
|
|
100
|
+
.grid-layout[data-bg='tertiary'] {
|
|
101
|
+
background: var(--tertiary);
|
|
102
|
+
}
|
|
103
|
+
.grid-layout[data-bg='rainbow'] {
|
|
104
|
+
background-image: linear-gradient(160deg, #4f46e5, #3b82f6, #a855f7, #f59e0b, #ef4444, #0ea5e9);
|
|
105
|
+
background-size: 200% 200%;
|
|
106
|
+
animation: grid-rainbow-shift 12s ease infinite;
|
|
107
|
+
}
|
|
108
|
+
@keyframes grid-rainbow-shift {
|
|
109
|
+
0% {
|
|
110
|
+
background-position: 0% 0%;
|
|
111
|
+
}
|
|
112
|
+
50% {
|
|
113
|
+
background-position: 100% 100%;
|
|
114
|
+
}
|
|
115
|
+
100% {
|
|
116
|
+
background-position: 0% 0%;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
@media (max-width: 960px) {
|
|
120
|
+
.grid-layout.stack {
|
|
121
|
+
grid-template-columns: 1fr !important;
|
|
122
|
+
}
|
|
123
|
+
/* Grid items default to min-width: auto, so a track can never shrink below an
|
|
124
|
+
item's min-content width — one unbreakable child (an email, a fixed-width
|
|
125
|
+
panel) forces the single 1fr track wider than the viewport and the excess is
|
|
126
|
+
clipped. Let stacked children shrink to the column instead. */
|
|
127
|
+
.grid-layout.stack > :global(*) {
|
|
128
|
+
min-width: 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
</style>
|