@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,63 @@
1
+ <script generics="Input extends RemoteFormInput, T = string" lang="ts">
2
+ import type { RemoteForm, RemoteFormInput } from '$app/server';
3
+ import type { Snippet } from 'svelte';
4
+ import type { HTMLInputAttributes } from 'svelte/elements';
5
+ import type { ZodType } from 'zod';
6
+
7
+ import Field from '../Field.svelte';
8
+
9
+ interface Props {
10
+ autocapitalize?: HTMLInputAttributes['autocapitalize'];
11
+ autocomplete?: HTMLInputAttributes['autocomplete'];
12
+ children?: Snippet;
13
+ class?: string;
14
+ disabled?: HTMLInputAttributes['disabled'];
15
+ form?: Omit<RemoteForm<Input, unknown>, 'for'> | RemoteForm<Input, unknown>;
16
+ name: keyof Input & string;
17
+ onChange?: (value: T) => void;
18
+ onInput?: (value: T) => void;
19
+ onkeydown?: HTMLInputAttributes['onkeydown'];
20
+ optional?: boolean;
21
+ placeholder?: string;
22
+ schema?: ZodType;
23
+ spellcheck?: HTMLInputAttributes['spellcheck'];
24
+ value?: T;
25
+ }
26
+
27
+ let {
28
+ autocapitalize,
29
+ autocomplete,
30
+ children,
31
+ class: className,
32
+ disabled,
33
+ form,
34
+ name,
35
+ onChange,
36
+ onInput,
37
+ onkeydown,
38
+ optional,
39
+ placeholder,
40
+ schema,
41
+ spellcheck,
42
+ value = $bindable(),
43
+ }: Props = $props();
44
+ </script>
45
+
46
+ <Field
47
+ {name}
48
+ class={className}
49
+ {autocapitalize}
50
+ {autocomplete}
51
+ {children}
52
+ {disabled}
53
+ {form}
54
+ {onChange}
55
+ {onInput}
56
+ {onkeydown}
57
+ {optional}
58
+ {placeholder}
59
+ {schema}
60
+ {spellcheck}
61
+ type="email"
62
+ bind:value
63
+ />
@@ -0,0 +1,145 @@
1
+ <!--
2
+ Standalone copy of web-svelte's FileField (same global classes → same CSS). Two modes:
3
+ standalone (`onSelect`), where the file is read or PUT directly rather than submitted; and
4
+ form-bound (`form` + `name`, the same pair every other field here takes), where the real input
5
+ carries the remote field's attributes and submits natively with the enclosing form.
6
+ -->
7
+ <script generics="Input extends RemoteFormInput = RemoteFormInput" lang="ts">
8
+ import type { RemoteForm, RemoteFormInput } from '$app/server';
9
+ import type { Snippet } from 'svelte';
10
+
11
+ import Upload from '@lucide/svelte/icons/upload';
12
+
13
+ import { createFormView } from '../field-view.svelte.js';
14
+
15
+ type BaseProps = {
16
+ accept?: string;
17
+ children?: Snippet;
18
+ disabled?: boolean;
19
+ multiple?: boolean;
20
+ /** Fired with the current selection. The only way to read files in standalone mode. */
21
+ onSelect?: (files: File[]) => void;
22
+ variant?: 'button' | 'dropzone';
23
+ };
24
+
25
+ /** `form` and `name` come as a pair or not at all — one without the other would silently fall
26
+ * back to standalone, leaving the enclosing form with no file field and nothing to say so. */
27
+ type Props = BaseProps &
28
+ (
29
+ | {
30
+ form: Omit<RemoteForm<Input, unknown>, 'for'> | RemoteForm<Input, unknown>;
31
+ name: keyof Input & string;
32
+ }
33
+ | { form?: never; name?: never }
34
+ );
35
+
36
+ let {
37
+ accept,
38
+ children,
39
+ disabled = false,
40
+ form,
41
+ multiple = false,
42
+ name,
43
+ onSelect,
44
+ variant = 'button',
45
+ }: Props = $props();
46
+
47
+ // Fixed for a field instance, so reading them once is intended.
48
+ // svelte-ignore state_referenced_locally
49
+ const view =
50
+ form && name ? createFormView(form, name, multiple ? 'file multiple' : 'file') : undefined;
51
+
52
+ let input = $state<HTMLInputElement>();
53
+ let files = $state<File[]>([]);
54
+ let dragging = $state(false);
55
+
56
+ const label = $derived(
57
+ files.length === 0
58
+ ? 'No file chosen'
59
+ : files.length === 1
60
+ ? files[0].name
61
+ : `${files.length} files selected`
62
+ );
63
+
64
+ function sync() {
65
+ files = input?.files ? Array.from(input.files) : [];
66
+ onSelect?.(files);
67
+ }
68
+
69
+ function open() {
70
+ if (!disabled) input?.click();
71
+ }
72
+
73
+ function onKey(e: KeyboardEvent) {
74
+ if (e.key === 'Enter' || e.key === ' ') {
75
+ e.preventDefault();
76
+ open();
77
+ }
78
+ }
79
+
80
+ function onDragOver(e: DragEvent) {
81
+ e.preventDefault();
82
+ if (!disabled) dragging = true;
83
+ }
84
+
85
+ function onDrop(e: DragEvent) {
86
+ e.preventDefault();
87
+ dragging = false;
88
+ if (disabled || !input || !e.dataTransfer) return;
89
+ input.files = e.dataTransfer.files;
90
+ sync();
91
+ }
92
+ </script>
93
+
94
+ <div class="form-field">
95
+ {#if children}
96
+ <span class="form-label">{@render children()}</span>
97
+ {/if}
98
+
99
+ <!-- Spread onto the real submitted input, so the multipart entry is what a bare input gave. -->
100
+ <input
101
+ bind:this={input}
102
+ class="form-file-input"
103
+ {accept}
104
+ {disabled}
105
+ {multiple}
106
+ {...view?.attrs ?? {}}
107
+ onchange={sync}
108
+ type="file"
109
+ />
110
+
111
+ {#if variant === 'dropzone'}
112
+ <div
113
+ class={[
114
+ 'form-file-dropzone',
115
+ dragging && 'form-file-dropzone--over',
116
+ disabled && 'form-file-dropzone--disabled',
117
+ ]
118
+ .filter(Boolean)
119
+ .join(' ')}
120
+ onclick={open}
121
+ ondragleave={() => (dragging = false)}
122
+ ondragover={onDragOver}
123
+ ondrop={onDrop}
124
+ onkeydown={onKey}
125
+ role="button"
126
+ tabindex={disabled ? -1 : 0}
127
+ >
128
+ <Upload class="form-file-dropzone-icon" />
129
+ <span class="form-file-dropzone-text">Drag &amp; drop or click to upload</span>
130
+ <span class="form-file-name">{label}</span>
131
+ </div>
132
+ {:else}
133
+ <div class="form-file-button-row">
134
+ <button class="btn ghost" {disabled} onclick={open} type="button">
135
+ <Upload class="form-file-button-icon" />
136
+ Choose file{multiple ? 's' : ''}
137
+ </button>
138
+ <span class="form-file-name">{label}</span>
139
+ </div>
140
+ {/if}
141
+
142
+ {#each view?.issues() ?? [] as issue, i (i)}
143
+ <p class="form-error">{issue.message}</p>
144
+ {/each}
145
+ </div>
@@ -0,0 +1,83 @@
1
+ <script generics="Input extends RemoteFormInput" lang="ts">
2
+ import type { RemoteForm, RemoteFormInput } from '$app/server';
3
+ import type { Snippet } from 'svelte';
4
+ import type { ZodType } from 'zod';
5
+
6
+ import ColorPicker from 'svelte-awesome-color-picker';
7
+
8
+ import { createFormView, createLocalTextView, type FieldView } from '../field-view.svelte.js';
9
+ import FieldLabel from '../FieldLabel.svelte';
10
+
11
+ interface Props {
12
+ children?: Snippet;
13
+ form?: Omit<RemoteForm<Input, unknown>, 'for'> | RemoteForm<Input, unknown>;
14
+ name: keyof Input & string;
15
+ onChange?: (value: string) => void;
16
+ onInput?: (value: string) => void;
17
+ optional?: boolean;
18
+ schema?: ZodType;
19
+ value?: string;
20
+ }
21
+
22
+ let {
23
+ children,
24
+ form,
25
+ name,
26
+ onChange,
27
+ onInput,
28
+ optional,
29
+ schema,
30
+ value = $bindable(''),
31
+ }: Props = $props();
32
+
33
+ // `as('text')` is reached only via the `form` branch; standalone uses local state.
34
+ // svelte-ignore state_referenced_locally
35
+ const view: FieldView = form
36
+ ? createFormView(form, name, 'text')
37
+ : createLocalTextView<string>({
38
+ get: () => value,
39
+ name,
40
+ onChange,
41
+ onInput,
42
+ schema,
43
+ write: (v) => (value = v),
44
+ });
45
+
46
+ const attrs = $derived(view.attrs);
47
+ const required = $derived(!optional);
48
+
49
+ // Current stored value without the leading '#'.
50
+ const current = $derived(String(attrs.value ?? ''));
51
+
52
+ // ColorPicker expects '#rrggbb'; the field stores without '#'. ColorPicker's hex
53
+ // prop has a fallback, so it must never be bound to undefined. Writable derived:
54
+ // tracks the stored value, but ColorPicker can override it via `bind:hex`.
55
+ const DEFAULT_HEX = '#000000';
56
+ let hex: string = $derived(current ? `#${current}` : DEFAULT_HEX);
57
+ let hiddenInput: HTMLInputElement | undefined = $state();
58
+
59
+ $effect(() => {
60
+ const raw = hex.slice(1);
61
+ if (current !== raw) {
62
+ if (!current && hex === DEFAULT_HEX) return;
63
+ view.set(raw);
64
+ if (hiddenInput) {
65
+ // Set DOM value synchronously before dispatching so handle_input reads the correct
66
+ // value instead of the stale pre-update value, which would cause an infinite loop.
67
+ hiddenInput.value = raw;
68
+ hiddenInput.dispatchEvent(new Event('input', { bubbles: true }));
69
+ }
70
+ }
71
+ });
72
+ </script>
73
+
74
+ {#if children}
75
+ <FieldLabel for={attrs.name} {required}>{@render children()}</FieldLabel>
76
+ {/if}
77
+ <!-- Hidden input puts the value into FormData so validate() and submit pick it up.
78
+ Value is managed directly in the $effect above — not via reactive binding. -->
79
+ <input bind:this={hiddenInput} name={attrs.name} type="hidden" />
80
+ <ColorPicker isAlpha={false} position="responsive" bind:hex />
81
+ {#each view.issues() as issue (`${issue.path}`)}
82
+ <p class="form-error">{issue.message}</p>
83
+ {/each}
@@ -0,0 +1,100 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { untrack } from 'svelte';
5
+
6
+ import FieldLabel from '../FieldLabel.svelte';
7
+ import NumberField from './NumberField.svelte';
8
+ import SelectField from './SelectField.svelte';
9
+
10
+ export type IntervalUnit = 'days' | 'hours' | 'minutes';
11
+
12
+ const UNIT_SECONDS: Record<IntervalUnit, number> = { days: 86_400, hours: 3600, minutes: 60 };
13
+ const UNIT_LABELS: Record<IntervalUnit, string> = {
14
+ days: 'Days',
15
+ hours: 'Hours',
16
+ minutes: 'Minutes',
17
+ };
18
+ const UNIT_ORDER: IntervalUnit[] = ['days', 'hours', 'minutes']; // coarsest first
19
+
20
+ /** Coarsest unit (among `units`) that divides `totalSeconds` exactly, so e.g. a stored 86400
21
+ * shows as "1 Days" rather than "1440 Minutes". Falls back to minutes (rounded) — not just
22
+ * "whatever's last in `units`" — for zero/blank or a value that doesn't divide evenly into
23
+ * any of the allowed units; falls back further to the first allowed unit if minutes itself
24
+ * isn't offered. */
25
+ function secondsToParts(
26
+ totalSeconds: number,
27
+ units: IntervalUnit[]
28
+ ): { amount: number; unit: IntervalUnit } {
29
+ for (const unit of UNIT_ORDER) {
30
+ if (!units.includes(unit)) continue;
31
+ if (totalSeconds > 0 && totalSeconds % UNIT_SECONDS[unit] === 0) {
32
+ return { amount: totalSeconds / UNIT_SECONDS[unit], unit };
33
+ }
34
+ }
35
+ const fallback = units.includes('minutes') ? 'minutes' : units[0];
36
+ return { amount: Math.round(totalSeconds / UNIT_SECONDS[fallback]), unit: fallback };
37
+ }
38
+
39
+ let {
40
+ children,
41
+ disabled = false,
42
+ name,
43
+ optional,
44
+ units = ['days', 'hours', 'minutes'],
45
+ value = $bindable(0),
46
+ }: {
47
+ children?: Snippet;
48
+ disabled?: boolean;
49
+ /** Renders a hidden `<input>` under this name (the composed seconds value) so a real
50
+ * `<Form>` picks it up on submit — omit for pure standalone `bind:value` use. */
51
+ name?: string;
52
+ optional?: boolean;
53
+ /** Which units are offered, coarsest first (last one is the fallback when a value
54
+ * doesn't divide evenly). Default: days/hours/minutes. */
55
+ units?: IntervalUnit[];
56
+ /** The composed interval, in seconds. */
57
+ value?: number;
58
+ } = $props();
59
+
60
+ // `untrack` — only the initial `value` seeds the split; after that, local edits are the
61
+ // source of truth and push back out via the `$effect` below (same seed-in/push-out shape as
62
+ // `WarmupFields.svelte`'s local warmup state).
63
+ const seeded = untrack(() => secondsToParts(value, units));
64
+ let amount = $state(seeded.amount);
65
+ let unit = $state<IntervalUnit>(seeded.unit);
66
+
67
+ $effect(() => {
68
+ if (amount < 0) amount = 0;
69
+ });
70
+
71
+ const seconds = $derived(Math.max(0, Math.trunc(amount || 0)) * UNIT_SECONDS[unit]);
72
+ $effect(() => {
73
+ value = seconds;
74
+ });
75
+
76
+ const fieldId = $derived(name ?? 'interval');
77
+ </script>
78
+
79
+ <div class="form-field">
80
+ {#if children}
81
+ <FieldLabel for="{fieldId}_amount" required={!optional}>{@render children()}</FieldLabel>
82
+ {/if}
83
+ <div class="flex gap-2">
84
+ <div class="w-24">
85
+ <NumberField name="{fieldId}_amount" {disabled} bind:value={amount} />
86
+ </div>
87
+ <div class="min-w-0 flex-1">
88
+ <SelectField
89
+ name="{fieldId}_unit"
90
+ getLabel={(u) => UNIT_LABELS[u]}
91
+ items={units}
92
+ placeholder="Unit…"
93
+ bind:value={unit}
94
+ />
95
+ </div>
96
+ </div>
97
+ {#if name}
98
+ <input {name} type="hidden" value={seconds} />
99
+ {/if}
100
+ </div>
@@ -0,0 +1,99 @@
1
+ <script generics="Input extends RemoteFormInput, T = string" lang="ts">
2
+ import type { RemoteForm, RemoteFormInput } from '$app/server';
3
+ import type { Component, Snippet } from 'svelte';
4
+ import type { HTMLTextareaAttributes } from 'svelte/elements';
5
+ import type { ZodType } from 'zod';
6
+
7
+ import { createFormView, createLocalTextView, type FieldView } from '../field-view.svelte.js';
8
+ import FieldLabel from '../FieldLabel.svelte';
9
+ import TextArea from '../primitives/TextArea.svelte';
10
+
11
+ interface Props {
12
+ /** Native autocomplete hint — passed through to the underlying <textarea>. */
13
+ autocomplete?: HTMLTextareaAttributes['autocomplete'];
14
+ children?: Snippet;
15
+ class?: string;
16
+ defaultHeight?: number;
17
+ /** Passed through to the underlying <textarea>. */
18
+ disabled?: HTMLTextareaAttributes['disabled'];
19
+ form?: Omit<RemoteForm<Input, unknown>, 'for'> | RemoteForm<Input, unknown>;
20
+ icon?: Component;
21
+ name: keyof Input & string;
22
+ onChange?: (value: T) => void;
23
+ onInput?: (value: T) => void;
24
+ /** Raw native keydown — passed through to the underlying <textarea> (e.g. Enter-to-submit). */
25
+ onkeydown?: HTMLTextareaAttributes['onkeydown'];
26
+ optional?: boolean;
27
+ placeholder?: string;
28
+ resize?: boolean;
29
+ schema?: ZodType;
30
+ /** Native spellcheck hint — passed through to the underlying <textarea>. */
31
+ spellcheck?: HTMLTextareaAttributes['spellcheck'];
32
+ value?: T;
33
+ }
34
+
35
+ let {
36
+ autocomplete,
37
+ children,
38
+ class: className,
39
+ defaultHeight = 100,
40
+ disabled,
41
+ form,
42
+ icon,
43
+ name,
44
+ onChange,
45
+ onInput,
46
+ onkeydown,
47
+ optional,
48
+ placeholder,
49
+ resize = false,
50
+ schema,
51
+ spellcheck,
52
+ value = $bindable(),
53
+ }: Props = $props();
54
+
55
+ // `as('text')` is reached only via the `form` branch; standalone uses local state.
56
+ // svelte-ignore state_referenced_locally
57
+ const view: FieldView = form
58
+ ? createFormView(form, name, 'text')
59
+ : createLocalTextView<T>({
60
+ get: () => value as T,
61
+ name,
62
+ onChange,
63
+ onInput,
64
+ schema,
65
+ write: (v) => (value = v),
66
+ });
67
+
68
+ const required = $derived(!optional);
69
+
70
+ // With a label the asterisk carries the required/optional cue. Without one,
71
+ // required fields just show the placeholder; optional fields get an (Optional)
72
+ // suffix so the cue reads naturally after the placeholder text.
73
+ const displayPlaceholder = $derived(
74
+ children || required ? placeholder : placeholder ? `${placeholder} (Optional)` : '(Optional)'
75
+ );
76
+ </script>
77
+
78
+ <div class="form-field">
79
+ {#if children}
80
+ <FieldLabel for={view.attrs.name} {required}>{@render children()}</FieldLabel>
81
+ {/if}
82
+ <TextArea
83
+ id={view.attrs.name}
84
+ class={className}
85
+ {autocomplete}
86
+ {defaultHeight}
87
+ {disabled}
88
+ {icon}
89
+ {onkeydown}
90
+ placeholder={displayPlaceholder}
91
+ {required}
92
+ {resize}
93
+ {spellcheck}
94
+ {...view.attrs}
95
+ />
96
+ {#each view.issues() as issue (`${issue.path}`)}
97
+ <p class="form-error">{issue.message}</p>
98
+ {/each}
99
+ </div>
@@ -0,0 +1,64 @@
1
+ <script generics="Input extends RemoteFormInput, T = string" lang="ts">
2
+ import type { RemoteForm, RemoteFormInput } from '$app/server';
3
+ import type { Component, Snippet } from 'svelte';
4
+ import type { HTMLInputAttributes } from 'svelte/elements';
5
+ import type { ZodType } from 'zod';
6
+
7
+ import Field from '../Field.svelte';
8
+
9
+ interface Props {
10
+ autocomplete?: HTMLInputAttributes['autocomplete'];
11
+ children?: Snippet;
12
+ class?: string;
13
+ disabled?: HTMLInputAttributes['disabled'];
14
+ form?: Omit<RemoteForm<Input, unknown>, 'for'> | RemoteForm<Input, unknown>;
15
+ icon?: Component;
16
+ /** Mobile keyboard hint — e.g. 'numeric' to avoid the native spinner while keeping the numeric pad. */
17
+ inputmode?: HTMLInputAttributes['inputmode'];
18
+ name: keyof Input & string;
19
+ onChange?: (value: T) => void;
20
+ onInput?: (value: T) => void;
21
+ onkeydown?: HTMLInputAttributes['onkeydown'];
22
+ optional?: boolean;
23
+ placeholder?: string;
24
+ schema?: ZodType;
25
+ value?: T;
26
+ }
27
+
28
+ let {
29
+ autocomplete,
30
+ children,
31
+ class: className,
32
+ disabled,
33
+ form,
34
+ icon,
35
+ inputmode,
36
+ name,
37
+ onChange,
38
+ onInput,
39
+ onkeydown,
40
+ optional,
41
+ placeholder,
42
+ schema,
43
+ value = $bindable(),
44
+ }: Props = $props();
45
+ </script>
46
+
47
+ <Field
48
+ {name}
49
+ class={className}
50
+ {autocomplete}
51
+ {children}
52
+ {disabled}
53
+ {form}
54
+ {icon}
55
+ {inputmode}
56
+ {onChange}
57
+ {onInput}
58
+ {onkeydown}
59
+ {optional}
60
+ {placeholder}
61
+ {schema}
62
+ type="number"
63
+ bind:value
64
+ />
@@ -0,0 +1,48 @@
1
+ <script generics="V extends number | string" lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import Check from '@lucide/svelte/icons/check';
5
+ import { fuzzySearch } from '@zeyolabs/kit/utils/strings/normalize';
6
+ import { Select } from 'bits-ui';
7
+ import { getContext } from 'svelte';
8
+
9
+ import { SELECT_FIELD_CONTEXT, type SelectFieldContext } from './select-field-context.js';
10
+
11
+ interface Props {
12
+ /** The visible option content — plain text or rich markup (e.g. an icon). */
13
+ children: Snippet;
14
+ disabled?: boolean;
15
+ /** Plain-text label for typeahead/accessibility. Defaults to `String(value)`. */
16
+ label?: string;
17
+ value: V;
18
+ }
19
+
20
+ let { children: content, disabled = false, label, value }: Props = $props();
21
+
22
+ // `<Option>` is a static declaration (like a native `<option>`) — `value` is captured once,
23
+ // not tracked reactively across later prop changes.
24
+ // svelte-ignore state_referenced_locally
25
+ const key = String(value);
26
+ const resolvedLabel = $derived(label ?? key);
27
+
28
+ const ctx = getContext<SelectFieldContext>(SELECT_FIELD_CONTEXT);
29
+ // Registers this option's rich content against its key so the parent `<SelectField>` can
30
+ // re-render the SAME snippet as the closed-trigger display when this option is selected —
31
+ // called synchronously at init (not inside `$effect`, which only runs post-mount and would
32
+ // flash the placeholder for one frame on first render). `<Option>` is a static declaration
33
+ // (like a native `<option>`) — this is a one-time snapshot, not meant to track later prop changes.
34
+ // svelte-ignore state_referenced_locally
35
+ ctx.register(key, { content, label: resolvedLabel, value });
36
+
37
+ const query = $derived(ctx.getQuery?.() ?? '');
38
+ const visible = $derived(query.trim() === '' || fuzzySearch(query, resolvedLabel));
39
+ </script>
40
+
41
+ {#if visible && !ctx.registerOnly}
42
+ <Select.Item class="form-select-item" {disabled} label={resolvedLabel} value={key}>
43
+ {#snippet children({ selected })}
44
+ <span class="form-select-item-label">{@render content()}</span>
45
+ {#if selected}<Check class="form-select-item-check" size={14} />{/if}
46
+ {/snippet}
47
+ </Select.Item>
48
+ {/if}
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { setContext } from 'svelte';
5
+
6
+ import { SELECT_FIELD_CONTEXT, type SelectFieldContext } from './select-field-context.js';
7
+
8
+ let { children, context }: { children: Snippet; context: SelectFieldContext } = $props();
9
+
10
+ // svelte-ignore state_referenced_locally
11
+ setContext(SELECT_FIELD_CONTEXT, { ...context, registerOnly: true });
12
+ </script>
13
+
14
+ <!-- Anything besides <Option>s in the children (empty/loading rows) must not show here. -->
15
+ <div hidden>{@render children()}</div>
@@ -0,0 +1,44 @@
1
+ <script generics="Input extends RemoteFormInput, T = string" lang="ts">
2
+ import type { RemoteForm, RemoteFormInput } from '$app/server';
3
+ import type { Snippet } from 'svelte';
4
+ import type { ZodType } from 'zod';
5
+
6
+ import Field from '../Field.svelte';
7
+
8
+ interface Props {
9
+ children?: Snippet;
10
+ form?: Omit<RemoteForm<Input, unknown>, 'for'> | RemoteForm<Input, unknown>;
11
+ name: keyof Input & string;
12
+ onChange?: (value: T) => void;
13
+ onInput?: (value: T) => void;
14
+ optional?: boolean;
15
+ placeholder?: string;
16
+ schema?: ZodType;
17
+ value?: T;
18
+ }
19
+
20
+ let {
21
+ children,
22
+ form,
23
+ name,
24
+ onChange,
25
+ onInput,
26
+ optional,
27
+ placeholder,
28
+ schema,
29
+ value = $bindable(),
30
+ }: Props = $props();
31
+ </script>
32
+
33
+ <Field
34
+ {name}
35
+ {children}
36
+ {form}
37
+ {onChange}
38
+ {onInput}
39
+ {optional}
40
+ {placeholder}
41
+ {schema}
42
+ type="password"
43
+ bind:value
44
+ />