@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,157 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
import { fade } from 'svelte/transition';
|
|
5
|
+
|
|
6
|
+
// Floating popover anchored to its own parent element. Rendered with
|
|
7
|
+
// position: fixed (viewport coords computed on open) so it escapes any
|
|
8
|
+
// `overflow: auto` clip from ancestors — e.g. a table's horizontal scroll
|
|
9
|
+
// wrapper. Place <Popover> as a direct child of the element you want to
|
|
10
|
+
// anchor under (the trigger cell/wrapper); it reads that parent's rect.
|
|
11
|
+
let {
|
|
12
|
+
/** Anchor edge the panel lines up with: 'right' = right-aligned (default). */
|
|
13
|
+
align = 'right',
|
|
14
|
+
ariaLabel = 'Popover',
|
|
15
|
+
children,
|
|
16
|
+
/** Panel max-height in px (content scrolls inside). */
|
|
17
|
+
maxHeight = 360,
|
|
18
|
+
/** Fired after the popover closes via outside click / Esc. */
|
|
19
|
+
onClose,
|
|
20
|
+
open = $bindable(false),
|
|
21
|
+
/** Where the panel opens: under the anchor (default) or beside it (`align` is ignored). */
|
|
22
|
+
side = 'bottom',
|
|
23
|
+
/** Panel width in px. Also used to keep the panel inside the viewport. */
|
|
24
|
+
width = 260,
|
|
25
|
+
}: {
|
|
26
|
+
align?: 'left' | 'right';
|
|
27
|
+
ariaLabel?: string;
|
|
28
|
+
children: Snippet;
|
|
29
|
+
maxHeight?: number;
|
|
30
|
+
onClose?: () => void;
|
|
31
|
+
open?: boolean;
|
|
32
|
+
side?: 'bottom' | 'right';
|
|
33
|
+
width?: number;
|
|
34
|
+
} = $props();
|
|
35
|
+
|
|
36
|
+
let panelEl: HTMLDivElement | undefined = $state();
|
|
37
|
+
let pos = $state({ left: 0, top: 0 });
|
|
38
|
+
|
|
39
|
+
function close() {
|
|
40
|
+
open = false;
|
|
41
|
+
onClose?.();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Outside-click / Escape detection via document-level listeners instead of a
|
|
45
|
+
// full-viewport backdrop element. A backdrop is a real hit target covering the
|
|
46
|
+
// whole page, so it swallows any click made while the popover is open — e.g.
|
|
47
|
+
// rapid-clicking a second row's trigger closed the first popover but the click
|
|
48
|
+
// never reached the second trigger, and nothing opened. Listeners observe
|
|
49
|
+
// without being a target, so the same click closes this popover AND still
|
|
50
|
+
// reaches whatever it landed on.
|
|
51
|
+
$effect(() => {
|
|
52
|
+
if (!open) return;
|
|
53
|
+
|
|
54
|
+
const onPointerDown = (e: PointerEvent) => {
|
|
55
|
+
const target = e.target as Node;
|
|
56
|
+
// The anchor (panel's parent) holds the trigger, and every consumer's
|
|
57
|
+
// trigger toggles `open` — closing here too would make that click
|
|
58
|
+
// reopen the popover it just closed. Excluding the anchor also means
|
|
59
|
+
// the click that opened the popover can never immediately close it.
|
|
60
|
+
if (panelEl?.contains(target) || panelEl?.parentElement?.contains(target)) return;
|
|
61
|
+
close();
|
|
62
|
+
};
|
|
63
|
+
const onKeydown = (e: KeyboardEvent) => {
|
|
64
|
+
if (e.key === 'Escape') close();
|
|
65
|
+
};
|
|
66
|
+
// capture: true so a stopPropagation() anywhere in the page's bubble phase
|
|
67
|
+
// (including this panel's own onclick/onkeydown) can't suppress the checks.
|
|
68
|
+
document.addEventListener('pointerdown', onPointerDown, { capture: true });
|
|
69
|
+
document.addEventListener('keydown', onKeydown, { capture: true });
|
|
70
|
+
return () => {
|
|
71
|
+
document.removeEventListener('pointerdown', onPointerDown, { capture: true });
|
|
72
|
+
document.removeEventListener('keydown', onKeydown, { capture: true });
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
$effect(() => {
|
|
77
|
+
if (!open || !panelEl) return;
|
|
78
|
+
const anchor = panelEl.parentElement;
|
|
79
|
+
if (!anchor) return;
|
|
80
|
+
|
|
81
|
+
const reposition = () => {
|
|
82
|
+
const r = anchor.getBoundingClientRect();
|
|
83
|
+
const panelHeight = panelEl?.offsetHeight ?? 0;
|
|
84
|
+
if (side === 'right') {
|
|
85
|
+
const rightLeft = r.right + 4;
|
|
86
|
+
const left = Math.max(
|
|
87
|
+
8,
|
|
88
|
+
rightLeft + width > window.innerWidth - 8 ? r.left - width - 4 : rightLeft
|
|
89
|
+
);
|
|
90
|
+
const maxTop = window.innerHeight - panelHeight - 8;
|
|
91
|
+
pos = { left, top: Math.max(8, Math.min(maxTop, r.top)) };
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const spaceBelow = window.innerHeight - r.bottom;
|
|
95
|
+
const spaceAbove = r.top;
|
|
96
|
+
const top =
|
|
97
|
+
spaceBelow < panelHeight + 4 && spaceAbove > spaceBelow
|
|
98
|
+
? Math.max(8, r.top - panelHeight - 4)
|
|
99
|
+
: r.bottom + 4;
|
|
100
|
+
// Align to the chosen edge, but never let the panel run off-screen.
|
|
101
|
+
const desiredLeft = align === 'right' ? r.right - width : r.left;
|
|
102
|
+
const left = Math.max(8, Math.min(window.innerWidth - width - 8, desiredLeft));
|
|
103
|
+
pos = { left, top };
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
reposition();
|
|
107
|
+
// Keep the panel glued to the anchor as the page scrolls or resizes.
|
|
108
|
+
// capture: true catches scroll on any ancestor (e.g. a table's own
|
|
109
|
+
// overflow-x: auto wrapper), not just window. passive: true because we
|
|
110
|
+
// never preventDefault. Listeners are removed in the effect cleanup.
|
|
111
|
+
window.addEventListener('scroll', reposition, { capture: true, passive: true });
|
|
112
|
+
window.addEventListener('resize', reposition, { passive: true });
|
|
113
|
+
return () => {
|
|
114
|
+
window.removeEventListener('scroll', reposition, { capture: true });
|
|
115
|
+
window.removeEventListener('resize', reposition);
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
{#if open}
|
|
121
|
+
<div
|
|
122
|
+
bind:this={panelEl}
|
|
123
|
+
style:top="{pos.top}px"
|
|
124
|
+
style:left="{pos.left}px"
|
|
125
|
+
style:width="{width}px"
|
|
126
|
+
style:max-height="{maxHeight}px"
|
|
127
|
+
class="popover"
|
|
128
|
+
aria-label={ariaLabel}
|
|
129
|
+
onclick={(e) => e.stopPropagation()}
|
|
130
|
+
onkeydown={(e) => e.stopPropagation()}
|
|
131
|
+
role="dialog"
|
|
132
|
+
tabindex="-1"
|
|
133
|
+
transition:fade={{
|
|
134
|
+
duration: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 120,
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
{@render children()}
|
|
138
|
+
</div>
|
|
139
|
+
{/if}
|
|
140
|
+
|
|
141
|
+
<style>
|
|
142
|
+
.popover {
|
|
143
|
+
/* position: fixed (with computed top/left in JS) escapes any ancestor's
|
|
144
|
+
overflow clip — see the $effect block in <script>. */
|
|
145
|
+
position: fixed;
|
|
146
|
+
z-index: 9100;
|
|
147
|
+
background: var(--bg);
|
|
148
|
+
border: 1px solid var(--bd);
|
|
149
|
+
border-radius: var(--radius);
|
|
150
|
+
box-shadow: 0 8px 24px rgba(20, 18, 24, 0.12);
|
|
151
|
+
display: flex;
|
|
152
|
+
flex-direction: column;
|
|
153
|
+
gap: 4px;
|
|
154
|
+
padding: 6px;
|
|
155
|
+
overflow-y: auto;
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script generics="T" lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
import { getHttpStatus } from '@zeyolabs/kit/utils/errors';
|
|
5
|
+
|
|
6
|
+
import SkeletonRow from '../skeleton/SkeletonRow.svelte';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The standard load/error/ready gate for a remote `query`. Renders `children(data)` once the
|
|
10
|
+
* query resolves, a muted error line on failure, and a skeleton while loading — so pages stop
|
|
11
|
+
* re-implementing the `{#if current}{:else if error}{:else}` boilerplate.
|
|
12
|
+
*/
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
errorMessage,
|
|
16
|
+
failed = 'Failed to load.',
|
|
17
|
+
loading,
|
|
18
|
+
query,
|
|
19
|
+
skeletonCols = 2,
|
|
20
|
+
}: {
|
|
21
|
+
children: Snippet<[T]>;
|
|
22
|
+
/** Status-aware error text, e.g. distinguishing a 404 from a 500. Overrides `failed`. */
|
|
23
|
+
errorMessage?: (status: null | number) => string;
|
|
24
|
+
failed?: string;
|
|
25
|
+
/** Custom loading state; defaults to a skeleton row. */
|
|
26
|
+
loading?: Snippet;
|
|
27
|
+
query: { current: T | undefined; error?: unknown };
|
|
28
|
+
skeletonCols?: number;
|
|
29
|
+
} = $props();
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
{#if query.current !== undefined}
|
|
33
|
+
{@render children(query.current)}
|
|
34
|
+
{:else if query.error}
|
|
35
|
+
<div style="color: var(--txs);" class="py-10 text-center">
|
|
36
|
+
{errorMessage ? errorMessage(getHttpStatus(query.error)) : failed}
|
|
37
|
+
</div>
|
|
38
|
+
{:else if loading}
|
|
39
|
+
{@render loading()}
|
|
40
|
+
{:else}
|
|
41
|
+
<div class="py-6"><SkeletonRow avatar={false} cols={skeletonCols} /></div>
|
|
42
|
+
{/if}
|
package/schema.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Checked only at compile time — a value cast past the type system (`as CssVariable`) is not validated
|
|
2
|
+
// at runtime.
|
|
3
|
+
export type CssVariable = `var(--${string})`;
|
|
4
|
+
|
|
5
|
+
type Bounded<Brand extends string> = number & { readonly __brand: Brand };
|
|
6
|
+
|
|
7
|
+
// 0-100, clamped at construction — a raw number isn't assignable without going through toPercentage.
|
|
8
|
+
export type Percentage = Bounded<'Percentage'>;
|
|
9
|
+
export const toPercentage = (value: number): Percentage =>
|
|
10
|
+
Math.min(100, Math.max(0, value)) as Percentage;
|
|
11
|
+
|
|
12
|
+
// 0-1, clamped at construction — a raw number isn't assignable without going through toOpacity.
|
|
13
|
+
export type Opacity = Bounded<'Opacity'>;
|
|
14
|
+
export const toOpacity = (value: number): Opacity => Math.min(1, Math.max(0, value)) as Opacity;
|
|
15
|
+
|
|
16
|
+
// A closed set of severity states, not a color value — a consumer maps each to its own color/class.
|
|
17
|
+
export type StatusColor = 'error' | 'ok' | 'warning';
|
|
18
|
+
|
|
19
|
+
// A background-color Tailwind class referencing a design token, e.g. bg-[var(--ok)].
|
|
20
|
+
export type BackgroundColorClass = `bg-[${CssVariable}]`;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
type Radius = 'full' | 'lg' | 'md' | 'sm' | 'xl' | 'xs';
|
|
3
|
+
type Variant = 'pulse' | 'shimmer';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
class: klass = '',
|
|
7
|
+
h = '1rem',
|
|
8
|
+
radius = 'xs',
|
|
9
|
+
style = '',
|
|
10
|
+
variant = 'pulse',
|
|
11
|
+
w = '100%',
|
|
12
|
+
}: {
|
|
13
|
+
class?: string;
|
|
14
|
+
h?: string;
|
|
15
|
+
/** A step on the radius scale (see @zeyolabs/ui/base.css); defaults to 'xs'. */
|
|
16
|
+
radius?: Radius;
|
|
17
|
+
style?: string;
|
|
18
|
+
variant?: Variant;
|
|
19
|
+
w?: string;
|
|
20
|
+
} = $props();
|
|
21
|
+
|
|
22
|
+
const resolvedRadius = $derived(`var(--radius-${radius})`);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<span
|
|
26
|
+
style="width: {w}; height: {h}; border-radius: {resolvedRadius}; {style}"
|
|
27
|
+
class="sk {variant === 'shimmer' ? 'sk-shimmer' : 'sk-pulse'} {klass}"
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
></span>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.sk {
|
|
33
|
+
display: block;
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
background-color: var(--bd, #e5e3e0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sk-pulse {
|
|
39
|
+
animation: sk-pulse 1.5s ease-in-out infinite;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sk-shimmer {
|
|
43
|
+
position: relative;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
46
|
+
.sk-shimmer::after {
|
|
47
|
+
content: '';
|
|
48
|
+
position: absolute;
|
|
49
|
+
inset: 0;
|
|
50
|
+
transform: translateX(-100%);
|
|
51
|
+
background: linear-gradient(
|
|
52
|
+
90deg,
|
|
53
|
+
transparent,
|
|
54
|
+
var(--sfh, rgba(255, 255, 255, 0.55)),
|
|
55
|
+
transparent
|
|
56
|
+
);
|
|
57
|
+
animation: sk-shimmer 1.6s ease-in-out infinite;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@keyframes sk-pulse {
|
|
61
|
+
0%,
|
|
62
|
+
100% {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
}
|
|
65
|
+
50% {
|
|
66
|
+
opacity: 0.45;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@keyframes sk-shimmer {
|
|
71
|
+
100% {
|
|
72
|
+
transform: translateX(100%);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@media (prefers-reduced-motion: reduce) {
|
|
77
|
+
.sk-pulse {
|
|
78
|
+
animation: none;
|
|
79
|
+
opacity: 0.7;
|
|
80
|
+
}
|
|
81
|
+
.sk-shimmer::after {
|
|
82
|
+
animation: none;
|
|
83
|
+
display: none;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Skeleton from './Skeleton.svelte';
|
|
3
|
+
|
|
4
|
+
/** Mirrors `<Button size>`: omit for the default 35px button. */
|
|
5
|
+
type Size = 'sm' | 'xs';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: klass = '',
|
|
9
|
+
size,
|
|
10
|
+
variant = 'pulse',
|
|
11
|
+
w = '6rem',
|
|
12
|
+
}: {
|
|
13
|
+
class?: string;
|
|
14
|
+
size?: Size;
|
|
15
|
+
variant?: 'pulse' | 'shimmer';
|
|
16
|
+
/** Button width — any CSS length. */
|
|
17
|
+
w?: string;
|
|
18
|
+
} = $props();
|
|
19
|
+
|
|
20
|
+
const HEIGHTS: Record<Size, string> = {
|
|
21
|
+
sm: 'var(--control-h-sm)',
|
|
22
|
+
xs: '20px',
|
|
23
|
+
};
|
|
24
|
+
const h = $derived(size ? HEIGHTS[size] : 'var(--control-h)');
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<Skeleton class={klass} {h} radius="md" {variant} {w} />
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Skeleton from './Skeleton.svelte';
|
|
3
|
+
import SkeletonCircle from './SkeletonCircle.svelte';
|
|
4
|
+
import SkeletonText from './SkeletonText.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
avatar = false,
|
|
8
|
+
class: klass = '',
|
|
9
|
+
lines = 2,
|
|
10
|
+
variant = 'pulse',
|
|
11
|
+
}: {
|
|
12
|
+
/** Show a leading avatar header. */
|
|
13
|
+
avatar?: boolean;
|
|
14
|
+
class?: string;
|
|
15
|
+
/** Body text lines. */
|
|
16
|
+
lines?: number;
|
|
17
|
+
variant?: 'pulse' | 'shimmer';
|
|
18
|
+
} = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class="sk-card {klass}">
|
|
22
|
+
<div class="sk-card-head">
|
|
23
|
+
{#if avatar}
|
|
24
|
+
<SkeletonCircle size="md" {variant} />
|
|
25
|
+
{/if}
|
|
26
|
+
<Skeleton h="0.75rem" radius="xs" {variant} w="45%" />
|
|
27
|
+
</div>
|
|
28
|
+
<Skeleton h="1.75rem" radius="xs" {variant} w="60%" />
|
|
29
|
+
{#if lines > 0}
|
|
30
|
+
<SkeletonText lastLineWidth="50%" {lines} size="sm" {variant} />
|
|
31
|
+
{/if}
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.sk-card {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 0.75rem;
|
|
39
|
+
padding: 1rem;
|
|
40
|
+
border: 1px solid var(--bd, #e5e3e0);
|
|
41
|
+
border-radius: var(--radius-md);
|
|
42
|
+
width: 100%;
|
|
43
|
+
}
|
|
44
|
+
.sk-card-head {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 0.625rem;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Skeleton from './Skeleton.svelte';
|
|
3
|
+
|
|
4
|
+
type Size = 'lg' | 'md' | 'sm';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
class: klass = '',
|
|
8
|
+
size = 'md',
|
|
9
|
+
variant = 'pulse',
|
|
10
|
+
}: {
|
|
11
|
+
class?: string;
|
|
12
|
+
/** Diameter preset, or any CSS length for a custom size. */
|
|
13
|
+
size?: Size | string;
|
|
14
|
+
variant?: 'pulse' | 'shimmer';
|
|
15
|
+
} = $props();
|
|
16
|
+
|
|
17
|
+
const PRESETS: Record<Size, string> = {
|
|
18
|
+
lg: '3.5rem',
|
|
19
|
+
md: '2.5rem',
|
|
20
|
+
sm: '1.5rem',
|
|
21
|
+
};
|
|
22
|
+
const d = $derived((PRESETS as Record<string, string>)[size] ?? size);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Skeleton class={klass} h={d} radius="full" {variant} w={d} />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Stack from '../layout/Stack.svelte';
|
|
3
|
+
import Skeleton from './Skeleton.svelte';
|
|
4
|
+
import SkeletonButton from './SkeletonButton.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
labelWidth = '6rem',
|
|
8
|
+
variant = 'pulse',
|
|
9
|
+
}: {
|
|
10
|
+
/** Width of the label placeholder above the field. */
|
|
11
|
+
labelWidth?: string;
|
|
12
|
+
variant?: 'pulse' | 'shimmer';
|
|
13
|
+
} = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Stack gap="xs">
|
|
17
|
+
<Skeleton h="0.7rem" radius="xs" {variant} w={labelWidth} />
|
|
18
|
+
<SkeletonButton {variant} w="100%" />
|
|
19
|
+
</Stack>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Skeleton from './Skeleton.svelte';
|
|
3
|
+
import SkeletonCircle from './SkeletonCircle.svelte';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
avatar = true,
|
|
7
|
+
class: klass = '',
|
|
8
|
+
cols = 2,
|
|
9
|
+
variant = 'pulse',
|
|
10
|
+
}: {
|
|
11
|
+
/** Show a leading avatar/circle. */
|
|
12
|
+
avatar?: boolean;
|
|
13
|
+
class?: string;
|
|
14
|
+
/** Number of text columns after the avatar. */
|
|
15
|
+
cols?: number;
|
|
16
|
+
variant?: 'pulse' | 'shimmer';
|
|
17
|
+
} = $props();
|
|
18
|
+
|
|
19
|
+
// Decreasing widths so columns look like name / detail / value.
|
|
20
|
+
const WIDTHS = ['40%', '24%', '16%', '12%'];
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div class="sk-row {klass}">
|
|
24
|
+
{#if avatar}
|
|
25
|
+
<SkeletonCircle size="sm" {variant} />
|
|
26
|
+
{/if}
|
|
27
|
+
<div class="sk-row-cols">
|
|
28
|
+
{#each Array.from({ length: cols }) as _, i (i)}
|
|
29
|
+
<Skeleton h="0.75rem" radius="xs" {variant} w={WIDTHS[i] ?? '20%'} />
|
|
30
|
+
{/each}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.sk-row {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 0.75rem;
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
.sk-row-cols {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: 1rem;
|
|
45
|
+
flex: 1;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Skeleton from './Skeleton.svelte';
|
|
3
|
+
|
|
4
|
+
type Size = 'lg' | 'md' | 'sm';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
class: klass = '',
|
|
8
|
+
gap = '0.5rem',
|
|
9
|
+
lastLineWidth = '60%',
|
|
10
|
+
lines = 1,
|
|
11
|
+
size = 'md',
|
|
12
|
+
variant = 'pulse',
|
|
13
|
+
}: {
|
|
14
|
+
class?: string;
|
|
15
|
+
/** Vertical gap between lines. */
|
|
16
|
+
gap?: string;
|
|
17
|
+
/** Width of the final line (ragged-edge effect). Ignored when lines === 1. */
|
|
18
|
+
lastLineWidth?: string;
|
|
19
|
+
/** Number of text lines. */
|
|
20
|
+
lines?: number;
|
|
21
|
+
/** Line height preset. */
|
|
22
|
+
size?: Size;
|
|
23
|
+
variant?: 'pulse' | 'shimmer';
|
|
24
|
+
} = $props();
|
|
25
|
+
|
|
26
|
+
const HEIGHTS: Record<Size, string> = {
|
|
27
|
+
lg: '1.25rem',
|
|
28
|
+
md: '0.875rem',
|
|
29
|
+
sm: '0.625rem',
|
|
30
|
+
};
|
|
31
|
+
const h = $derived(HEIGHTS[size]);
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<span style="gap: {gap};" class="sk-text {klass}">
|
|
35
|
+
{#each Array.from({ length: lines }) as _, i (i)}
|
|
36
|
+
<Skeleton {h} radius="xs" {variant} w={lines > 1 && i === lines - 1 ? lastLineWidth : '100%'} />
|
|
37
|
+
{/each}
|
|
38
|
+
</span>
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
.sk-text {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Skeleton from './Skeleton.svelte';
|
|
3
|
+
|
|
4
|
+
// Matches SelectAllTableCell/SelectRowTableCell's fixed column width.
|
|
5
|
+
const CHECKBOX_COL_WIDTH = '40px';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
checkbox = false,
|
|
9
|
+
cols = 2,
|
|
10
|
+
rows = 6,
|
|
11
|
+
variant = 'pulse',
|
|
12
|
+
}: {
|
|
13
|
+
/** Leading checkbox-shaped placeholder, for a table with a select column. Counts as one
|
|
14
|
+
* of `cols` — checkbox + cols=2 still shows 2 columns total, not 3. Always a fixed-width
|
|
15
|
+
* column, matching the real checkbox column it's standing in for. */
|
|
16
|
+
checkbox?: boolean;
|
|
17
|
+
/** Total number of columns per row, checkbox included. */
|
|
18
|
+
cols?: number;
|
|
19
|
+
rows?: number;
|
|
20
|
+
variant?: 'pulse' | 'shimmer';
|
|
21
|
+
} = $props();
|
|
22
|
+
|
|
23
|
+
const barCols = $derived(checkbox ? cols - 1 : cols);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div class="flex flex-col">
|
|
27
|
+
<div
|
|
28
|
+
style="background: var(--sf);"
|
|
29
|
+
class="flex items-center gap-3 border-b border-(--bds) px-4 py-3.5"
|
|
30
|
+
>
|
|
31
|
+
{#if checkbox}
|
|
32
|
+
<div style:width={CHECKBOX_COL_WIDTH} class="flex shrink-0 justify-center"></div>
|
|
33
|
+
{/if}
|
|
34
|
+
<div
|
|
35
|
+
style:grid-template-columns="repeat({barCols}, 1fr)"
|
|
36
|
+
class="grid flex-1 items-center gap-4"
|
|
37
|
+
>
|
|
38
|
+
{#each Array.from({ length: barCols }) as _, j (j)}
|
|
39
|
+
<Skeleton h="0.5rem" radius="xs" {variant} w="40%" />
|
|
40
|
+
{/each}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
{#each Array.from({ length: rows }) as _, i (i)}
|
|
44
|
+
<div class="flex items-center gap-3 border-b border-(--bds) px-4 py-3.5 last:border-b-0">
|
|
45
|
+
{#if checkbox}
|
|
46
|
+
<div style:width={CHECKBOX_COL_WIDTH} class="flex shrink-0 justify-center">
|
|
47
|
+
<Skeleton h="1rem" radius="xs" {variant} w="1rem" />
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
50
|
+
<div
|
|
51
|
+
style:grid-template-columns="repeat({barCols}, 1fr)"
|
|
52
|
+
class="grid flex-1 items-center gap-4"
|
|
53
|
+
>
|
|
54
|
+
{#each Array.from({ length: barCols }) as _, j (j)}
|
|
55
|
+
<Skeleton h="0.75rem" radius="xs" {variant} />
|
|
56
|
+
{/each}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
{/each}
|
|
60
|
+
</div>
|
package/spacing.css
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* Spacing scale, shared across every app: named steps on top of Tailwind v4's dynamic
|
|
2
|
+
--spacing multiplier, for the layout components' gap/spacing/padding props and Card's
|
|
3
|
+
padding prop, reached for before a new one-off arbitrary value (gap-3.5, px-4.5, etc).
|
|
4
|
+
|
|
5
|
+
Deliberately plain CSS custom properties, not a Tailwind @theme block: Tailwind's own
|
|
6
|
+
max-w-* / max-h-* utilities resolve named sizes (xs/sm/md/lg/xl/2xl/etc) through this
|
|
7
|
+
exact --spacing-* namespace ahead of their own --container-* scale whenever a matching
|
|
8
|
+
key exists. Registering these under @theme silently shrank every max-w-md (etc) in the
|
|
9
|
+
app to this scale's tiny values instead of Tailwind's real ~448px default. Plain :root
|
|
10
|
+
custom properties are still fully readable via var(--spacing-md) everywhere, including
|
|
11
|
+
inside @theme-registered component CSS, they just do not participate in Tailwind's own
|
|
12
|
+
utility generation/resolution. Do not move this back into @theme without re-checking
|
|
13
|
+
that collision. */
|
|
14
|
+
:root {
|
|
15
|
+
--spacing-xs: calc(var(--spacing) * 2); /* 8px */
|
|
16
|
+
--spacing-sm: calc(var(--spacing) * 3); /* 12px */
|
|
17
|
+
--spacing-md: calc(var(--spacing) * 5); /* 20px */
|
|
18
|
+
--spacing-lg: calc(var(--spacing) * 8); /* 32px */
|
|
19
|
+
--spacing-xl: calc(var(--spacing) * 12); /* 48px */
|
|
20
|
+
/* Section-band tier — page-level bands (a colored full-bleed section's own vertical
|
|
21
|
+
padding) need a bigger range than component-internal gaps ever do. */
|
|
22
|
+
--spacing-2xl: calc(var(--spacing) * 16); /* 64px */
|
|
23
|
+
--spacing-3xl: calc(var(--spacing) * 24); /* 96px */
|
|
24
|
+
--spacing-4xl: calc(var(--spacing) * 32); /* 128px */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Sidebar width — the fixed sidebar and every app's matching margin-left read these.
|
|
28
|
+
v2-parity: v2 measures 240px expanded / ~58px collapsed (was 256px / 56px). */
|
|
29
|
+
:root {
|
|
30
|
+
--sidebar-width-expanded: 15rem; /* 240px */
|
|
31
|
+
--sidebar-width-collapsed: 3.625rem; /* 58px */
|
|
32
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
getLocalTimeZone,
|
|
4
|
+
now,
|
|
5
|
+
today,
|
|
6
|
+
toZoned,
|
|
7
|
+
type ZonedDateTime,
|
|
8
|
+
} from '@internationalized/date';
|
|
9
|
+
// The next affiliate payout run — the 1st of next month, at midnight in the viewer's own
|
|
10
|
+
// timezone. Shared by apps/affiliate's payments page and apps/admin's affiliate drawer so
|
|
11
|
+
// admins see the same clock affiliates do.
|
|
12
|
+
import { Datetime } from '@zeyolabs/kit/utils/datetime';
|
|
13
|
+
|
|
14
|
+
import ValueBox from './ValueBox.svelte';
|
|
15
|
+
|
|
16
|
+
let nextPayoutDate = $state<null | ZonedDateTime>(null);
|
|
17
|
+
let payoutCountdownMs = $state(0);
|
|
18
|
+
|
|
19
|
+
// $effect (not top-level script) because getLocalTimeZone() reads the runtime's zone; running
|
|
20
|
+
// this during SSR would compute the server's zone instead of the browser's.
|
|
21
|
+
$effect(() => {
|
|
22
|
+
const zone = getLocalTimeZone();
|
|
23
|
+
const firstOfThisMonth = today(zone).set({ day: 1 });
|
|
24
|
+
const target = toZoned(firstOfThisMonth.add({ months: 1 }), zone);
|
|
25
|
+
nextPayoutDate = target;
|
|
26
|
+
|
|
27
|
+
const tick = () => {
|
|
28
|
+
payoutCountdownMs = Math.max(0, target.compare(now(zone)));
|
|
29
|
+
};
|
|
30
|
+
tick();
|
|
31
|
+
const interval = setInterval(tick, 1000);
|
|
32
|
+
return () => clearInterval(interval);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const payoutCountdownText = $derived.by(() => {
|
|
36
|
+
const totalSeconds = Math.floor(payoutCountdownMs / 1000);
|
|
37
|
+
const pad = (n: number) => String(n).padStart(2, '0');
|
|
38
|
+
return [
|
|
39
|
+
Math.floor(totalSeconds / 3600),
|
|
40
|
+
Math.floor((totalSeconds % 3600) / 60),
|
|
41
|
+
totalSeconds % 60,
|
|
42
|
+
]
|
|
43
|
+
.map(pad)
|
|
44
|
+
.join(':');
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<ValueBox
|
|
49
|
+
label="Next payout date"
|
|
50
|
+
value={nextPayoutDate ? Datetime.formatLocalDateNum(nextPayoutDate) : '—'}
|
|
51
|
+
/>
|
|
52
|
+
<ValueBox label="Time remaining" value={payoutCountdownText} />
|