@passui/tanstack 0.1.2 → 0.2.1

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 (70) hide show
  1. package/README.md +56 -32
  2. package/dist/client/chunks/form-fields-DlWu70u5.js +630 -0
  3. package/dist/client/src/solid/auth-shell/index.js +28 -0
  4. package/dist/client/src/solid/document/index.js +51 -0
  5. package/dist/client/src/solid/form-fields/index.js +1 -0
  6. package/dist/client/src/solid/forms/index.js +33 -0
  7. package/dist/client/src/solid/mutation/index.js +46 -0
  8. package/dist/client/src/solid/route-boundary/index.js +73 -0
  9. package/dist/client/src/solid/settings/index.js +173 -0
  10. package/dist/client/src/solid/tables/index.js +500 -0
  11. package/dist/server/src/solid/auth-shell/index.js +28 -0
  12. package/dist/server/src/solid/document/index.js +55 -0
  13. package/dist/server/src/solid/form-fields/index.js +598 -0
  14. package/dist/server/src/solid/forms/index.js +33 -0
  15. package/dist/server/src/solid/mutation/index.js +46 -0
  16. package/dist/server/src/solid/route-boundary/index.js +73 -0
  17. package/dist/server/src/solid/settings/index.js +169 -0
  18. package/dist/server/src/solid/tables/index.js +480 -0
  19. package/dist/types/src/shared/optimistic.d.ts +2 -0
  20. package/dist/types/src/solid/auth-shell/auth-shell.d.ts +4 -0
  21. package/dist/types/src/solid/auth-shell/index.d.ts +1 -0
  22. package/dist/types/src/solid/document/compose-viewport.d.ts +14 -0
  23. package/dist/types/src/solid/document/index.d.ts +1 -0
  24. package/dist/types/src/solid/form-fields/avatar.d.ts +26 -0
  25. package/dist/types/src/solid/form-fields/fields.d.ts +45 -0
  26. package/dist/types/src/solid/form-fields/index.d.ts +3 -0
  27. package/dist/types/src/solid/form-fields/submit.d.ts +3 -0
  28. package/dist/types/src/solid/forms/contexts.d.ts +1 -0
  29. package/dist/types/src/solid/forms/form-alert.d.ts +6 -0
  30. package/dist/types/src/solid/forms/index.d.ts +43 -0
  31. package/dist/types/src/solid/mutation/index.d.ts +1 -0
  32. package/dist/types/src/solid/mutation/use-app-mutation.d.ts +22 -0
  33. package/dist/types/src/solid/route-boundary/boundaries.d.ts +8 -0
  34. package/dist/types/src/solid/route-boundary/index.d.ts +1 -0
  35. package/dist/types/src/solid/settings/index.d.ts +1 -0
  36. package/dist/types/src/solid/settings/setting-list.d.ts +37 -0
  37. package/dist/types/src/solid/tables/columns.d.ts +4 -0
  38. package/dist/types/src/solid/tables/data-table.d.ts +58 -0
  39. package/dist/types/src/solid/tables/filter-row.d.ts +9 -0
  40. package/dist/types/src/solid/tables/index.d.ts +4 -0
  41. package/dist/types/src/solid/tables/pagination.d.ts +7 -0
  42. package/package.json +154 -13
  43. package/src/mutation/use-app-mutation.ts +2 -6
  44. package/src/shared/index.ts +2 -0
  45. package/src/shared/optimistic.ts +7 -0
  46. package/src/shared/table.ts +30 -0
  47. package/src/solid/auth-shell/auth-shell.tsx +20 -0
  48. package/src/solid/auth-shell/index.ts +1 -0
  49. package/src/solid/document/compose-viewport.tsx +69 -0
  50. package/src/solid/document/index.ts +1 -0
  51. package/src/solid/form-fields/avatar.tsx +370 -0
  52. package/src/solid/form-fields/fields.tsx +336 -0
  53. package/src/solid/form-fields/index.ts +3 -0
  54. package/src/solid/form-fields/submit.tsx +31 -0
  55. package/src/solid/forms/contexts.ts +7 -0
  56. package/src/solid/forms/form-alert.tsx +19 -0
  57. package/src/solid/forms/index.ts +32 -0
  58. package/src/solid/mutation/index.ts +5 -0
  59. package/src/solid/mutation/use-app-mutation.ts +171 -0
  60. package/src/solid/route-boundary/boundaries.tsx +104 -0
  61. package/src/solid/route-boundary/index.ts +1 -0
  62. package/src/solid/settings/index.ts +1 -0
  63. package/src/solid/settings/setting-list.tsx +185 -0
  64. package/src/solid/styles.css +2 -0
  65. package/src/solid/tables/columns.tsx +40 -0
  66. package/src/solid/tables/data-table.tsx +448 -0
  67. package/src/solid/tables/filter-row.tsx +161 -0
  68. package/src/solid/tables/index.ts +4 -0
  69. package/src/solid/tables/pagination.tsx +78 -0
  70. package/src/tables/utils.ts +5 -35
@@ -0,0 +1,370 @@
1
+ /** @jsxImportSource solid-js */
2
+ import {
3
+ createEffect,
4
+ createSignal,
5
+ onCleanup,
6
+ Show,
7
+ type JSX,
8
+ } from "solid-js"
9
+ import {
10
+ Ambient,
11
+ Button,
12
+ ProfileImage,
13
+ ProfileImageContent,
14
+ ProfileImageFallback,
15
+ Sheet,
16
+ } from "@passui/solid"
17
+ import { useFieldContext } from "../forms/contexts"
18
+ export type FieldAvatarValue = File | null | false
19
+ export type FieldAvatarLabels = {
20
+ edit: string
21
+ remove: string
22
+ confirmHint: string
23
+ save: string
24
+ cancel: string
25
+ photo: string
26
+ photoDescription: string
27
+ choosePhoto: string
28
+ takePhoto: string
29
+ capture: string
30
+ monogram: string
31
+ removePhoto: string
32
+ }
33
+ export function FieldAvatar(props: {
34
+ compact?: boolean
35
+ existingImage?: string | null
36
+ label: string
37
+ accept?: string
38
+ clearable?: boolean
39
+ caption?: JSX.Element
40
+ labels?: Partial<FieldAvatarLabels>
41
+ }) {
42
+ const field = useFieldContext<FieldAvatarValue>()
43
+ const [pending, setPending] = createSignal<File | null>(
44
+ null
45
+ ),
46
+ [open, setOpen] = createSignal(false),
47
+ [camera, setCamera] = createSignal(false),
48
+ [preview, setPreview] = createSignal<string>(),
49
+ [error, setError] = createSignal("")
50
+ let input!: HTMLInputElement
51
+ const labels = () => ({
52
+ edit: "Edit",
53
+ remove: "Remove",
54
+ confirmHint:
55
+ "Press Enter to use this photo, Esc to cancel",
56
+ save: "Use photo",
57
+ cancel: "Cancel",
58
+ photo: "Photo",
59
+ photoDescription: "Choose how you appear.",
60
+ choosePhoto: "Choose Photo…",
61
+ takePhoto: "Take Photo",
62
+ capture: "Take photo",
63
+ monogram: "Monogram",
64
+ removePhoto: "Remove Photo",
65
+ ...props.labels,
66
+ })
67
+ createEffect(() => {
68
+ const shown = pending() ?? field().state.value
69
+ if (!(shown instanceof File)) {
70
+ setPreview(undefined)
71
+ return
72
+ }
73
+ const url = URL.createObjectURL(shown)
74
+ setPreview(url)
75
+ onCleanup(() => URL.revokeObjectURL(url))
76
+ })
77
+ const image = () =>
78
+ field().state.value === false && !pending()
79
+ ? undefined
80
+ : (preview() ?? props.existingImage ?? undefined)
81
+ function keep() {
82
+ const file = pending()
83
+ if (file) {
84
+ field().handleChange(file)
85
+ field().handleBlur()
86
+ setPending(null)
87
+ }
88
+ }
89
+ createEffect(() => {
90
+ if (!pending()) return
91
+ const key = (event: KeyboardEvent) => {
92
+ if (event.key === "Enter") {
93
+ event.preventDefault()
94
+ keep()
95
+ }
96
+ if (event.key === "Escape") setPending(null)
97
+ }
98
+ window.addEventListener("keydown", key)
99
+ onCleanup(() =>
100
+ window.removeEventListener("keydown", key)
101
+ )
102
+ })
103
+ function pick(files: FileList | null) {
104
+ const file = Array.from(files ?? []).find((file) =>
105
+ file.type.startsWith("image/")
106
+ )
107
+ if (file) setPending(file)
108
+ }
109
+ async function monogram() {
110
+ const canvas = document.createElement("canvas")
111
+ canvas.width = canvas.height = 512
112
+ const context = canvas.getContext("2d")
113
+ if (!context) return
114
+ const style = getComputedStyle(input.parentElement!)
115
+ context.fillStyle =
116
+ style.getPropertyValue("--color-accent").trim() ||
117
+ style.color
118
+ context.fillRect(0, 0, 512, 512)
119
+ context.fillStyle = "white"
120
+ context.font = "240px system-ui"
121
+ context.textAlign = "center"
122
+ context.textBaseline = "middle"
123
+ context.fillText(
124
+ props.label
125
+ .trim()
126
+ .split(/\s+/)
127
+ .map((word) => word[0])
128
+ .slice(0, 2)
129
+ .join("")
130
+ .toUpperCase(),
131
+ 256,
132
+ 270
133
+ )
134
+ const blob = await new Promise<Blob | null>(
135
+ (resolve) => canvas.toBlob(resolve, "image/png")
136
+ )
137
+ if (blob) {
138
+ field().handleChange(
139
+ new File([blob], "monogram.png", {
140
+ type: "image/png",
141
+ })
142
+ )
143
+ field().handleBlur()
144
+ setOpen(false)
145
+ }
146
+ }
147
+ return (
148
+ <Ambient
149
+ src={
150
+ props.caption && !props.compact
151
+ ? image()
152
+ : undefined
153
+ }
154
+ class={
155
+ props.compact
156
+ ? "flex flex-wrap items-center gap-4"
157
+ : "flex flex-col items-center gap-4"
158
+ }
159
+ >
160
+ <div class="flex flex-col items-center gap-3">
161
+ <button
162
+ type="button"
163
+ aria-label={`${labels().edit} ${props.label}`}
164
+ onClick={() => setOpen(true)}
165
+ onDragOver={(event) =>
166
+ event.preventDefault()
167
+ }
168
+ onDrop={(event) => {
169
+ event.preventDefault()
170
+ pick(
171
+ event.dataTransfer?.files ?? null
172
+ )
173
+ }}
174
+ onPaste={(event) =>
175
+ pick(
176
+ event.clipboardData?.files ?? null
177
+ )
178
+ }
179
+ class="rounded-full focus-visible:ring-2 focus-visible:ring-accent"
180
+ >
181
+ <ProfileImage
182
+ class={
183
+ props.compact
184
+ ? "size-16"
185
+ : "size-43"
186
+ }
187
+ >
188
+ <ProfileImageContent
189
+ src={image()}
190
+ alt={props.label}
191
+ />
192
+ <ProfileImageFallback>
193
+ {props.label
194
+ .slice(0, 1)
195
+ .toUpperCase()}
196
+ </ProfileImageFallback>
197
+ </ProfileImage>
198
+ </button>
199
+ <Show when={pending()}>
200
+ <p class="text-footnote text-label-secondary">
201
+ {labels().confirmHint}
202
+ </p>
203
+ <div class="flex gap-2">
204
+ <Button
205
+ variant="secondary"
206
+ onClick={() => setPending(null)}
207
+ >
208
+ {labels().cancel}
209
+ </Button>
210
+ <Button onClick={keep}>
211
+ {labels().save}
212
+ </Button>
213
+ </div>
214
+ </Show>
215
+ </div>
216
+ <Show when={!pending()}>{props.caption}</Show>
217
+ <input
218
+ ref={input}
219
+ hidden
220
+ type="file"
221
+ accept={
222
+ props.accept ??
223
+ "image/png,image/webp,image/jpeg,image/svg+xml"
224
+ }
225
+ onChange={(event) => {
226
+ pick(event.currentTarget.files)
227
+ event.currentTarget.value = ""
228
+ }}
229
+ />
230
+ <Sheet
231
+ open={open()}
232
+ label={labels().photo}
233
+ onClose={() => {
234
+ setOpen(false)
235
+ setCamera(false)
236
+ }}
237
+ >
238
+ <div class="flex flex-col gap-3 p-5">
239
+ <p>{labels().photoDescription}</p>
240
+ <Button
241
+ variant="secondary"
242
+ onClick={() => {
243
+ setOpen(false)
244
+ input.click()
245
+ }}
246
+ >
247
+ {labels().choosePhoto}
248
+ </Button>
249
+ <Button
250
+ variant="secondary"
251
+ onClick={() => {
252
+ setError("")
253
+ setCamera(true)
254
+ }}
255
+ >
256
+ {labels().takePhoto}
257
+ </Button>
258
+ <Button
259
+ variant="secondary"
260
+ onClick={() =>
261
+ void monogram().catch((error) =>
262
+ setError(String(error))
263
+ )
264
+ }
265
+ >
266
+ {labels().monogram}
267
+ </Button>
268
+ <Show when={props.clearable && image()}>
269
+ <Button
270
+ variant="destructive"
271
+ onClick={() => {
272
+ field().handleChange(false)
273
+ field().handleBlur()
274
+ setOpen(false)
275
+ }}
276
+ >
277
+ {labels().removePhoto}
278
+ </Button>
279
+ </Show>
280
+ <Show when={camera()}>
281
+ <Camera
282
+ captureLabel={labels().capture}
283
+ onError={setError}
284
+ onCapture={(file) => {
285
+ setPending(file)
286
+ setCamera(false)
287
+ setOpen(false)
288
+ }}
289
+ />
290
+ </Show>
291
+ <Show when={error()}>
292
+ <p role="alert">{error()}</p>
293
+ </Show>
294
+ <Button
295
+ variant="ghost"
296
+ onClick={() => {
297
+ setOpen(false)
298
+ setCamera(false)
299
+ }}
300
+ >
301
+ {labels().cancel}
302
+ </Button>
303
+ </div>
304
+ </Sheet>
305
+ </Ambient>
306
+ )
307
+ }
308
+ function Camera(props: {
309
+ captureLabel: string
310
+ onCapture: (file: File) => void
311
+ onError: (message: string) => void
312
+ }) {
313
+ let video!: HTMLVideoElement,
314
+ stream: MediaStream | undefined,
315
+ disposed = false
316
+ createEffect(() => {
317
+ void navigator.mediaDevices
318
+ .getUserMedia({ video: { facingMode: "user" } })
319
+ .then((value) => {
320
+ if (disposed) {
321
+ value.getTracks().forEach((track) => {
322
+ track.stop()
323
+ })
324
+ return
325
+ }
326
+ stream = value
327
+ video.srcObject = value
328
+ void video.play()
329
+ })
330
+ .catch((error) => props.onError(String(error)))
331
+ onCleanup(() => {
332
+ disposed = true
333
+ stream?.getTracks().forEach((track) => {
334
+ track.stop()
335
+ })
336
+ })
337
+ })
338
+ function capture() {
339
+ if (!video.videoWidth) return
340
+ const canvas = document.createElement("canvas")
341
+ canvas.width = video.videoWidth
342
+ canvas.height = video.videoHeight
343
+ canvas.getContext("2d")?.drawImage(video, 0, 0)
344
+ canvas.toBlob(
345
+ (blob) => {
346
+ if (blob && !disposed)
347
+ props.onCapture(
348
+ new File([blob], "photo.jpg", {
349
+ type: "image/jpeg",
350
+ })
351
+ )
352
+ },
353
+ "image/jpeg",
354
+ 0.92
355
+ )
356
+ }
357
+ return (
358
+ <div class="flex flex-col gap-3">
359
+ <video
360
+ ref={video}
361
+ muted
362
+ playsinline
363
+ class="max-h-64 rounded-xl"
364
+ />
365
+ <Button onClick={capture}>
366
+ {props.captureLabel}
367
+ </Button>
368
+ </div>
369
+ )
370
+ }
@@ -0,0 +1,336 @@
1
+ /** @jsxImportSource solid-js */
2
+ import {
3
+ createContext,
4
+ For,
5
+ Show,
6
+ splitProps,
7
+ useContext,
8
+ type JSX,
9
+ } from "solid-js"
10
+ import {
11
+ TextField,
12
+ type TextFieldProps,
13
+ } from "@passui/solid/text-field"
14
+ import { TextEditor } from "@passui/solid/text-editor"
15
+ import { Toggle } from "@passui/solid/toggle"
16
+ import { cn } from "@passui/solid/cn"
17
+ import { useFieldContext } from "../forms/contexts"
18
+ export const PeachFieldLabels = createContext<{
19
+ show: string
20
+ hide: string
21
+ }>()
22
+ function errors(values: unknown[]) {
23
+ return values.flatMap((error) =>
24
+ typeof error === "string"
25
+ ? [error]
26
+ : error &&
27
+ typeof error === "object" &&
28
+ "message" in error
29
+ ? [String(error.message)]
30
+ : []
31
+ )
32
+ }
33
+ export function FieldInput(
34
+ props: Omit<
35
+ TextFieldProps,
36
+ "value" | "onInput" | "onBlur" | "name"
37
+ >
38
+ ) {
39
+ const field = useFieldContext<string>(),
40
+ reveal = useContext(PeachFieldLabels)
41
+ return (
42
+ <TextField
43
+ revealLabels={reveal}
44
+ {...props}
45
+ name={field().name}
46
+ value={field().state.value}
47
+ onInput={(event) =>
48
+ field().handleChange(
49
+ event.currentTarget.value
50
+ )
51
+ }
52
+ onBlur={() => field().handleBlur()}
53
+ errors={
54
+ field().state.meta.isTouched
55
+ ? errors(field().state.meta.errors)
56
+ : []
57
+ }
58
+ />
59
+ )
60
+ }
61
+ export function FieldCheckbox(props: {
62
+ label: string
63
+ disabled?: boolean
64
+ }) {
65
+ const field = useFieldContext<boolean>()
66
+ return (
67
+ <Toggle
68
+ style="checkbox"
69
+ label={props.label}
70
+ disabled={props.disabled}
71
+ checked={field().state.value}
72
+ onChange={(checked) => {
73
+ field().handleChange(checked)
74
+ field().handleBlur()
75
+ }}
76
+ />
77
+ )
78
+ }
79
+ export function FieldSwitch(props: {
80
+ label: string
81
+ description?: string
82
+ disabled?: boolean
83
+ }) {
84
+ const field = useFieldContext<boolean>()
85
+ return (
86
+ <div class="flex items-center justify-between gap-4">
87
+ <div class="text-subheadline">
88
+ {props.label}
89
+ <Show when={props.description}>
90
+ <p class="text-footnote text-label-secondary">
91
+ {props.description}
92
+ </p>
93
+ </Show>
94
+ </div>
95
+ <Toggle
96
+ label={props.label}
97
+ checked={field().state.value}
98
+ disabled={props.disabled}
99
+ onChange={(checked) => {
100
+ field().handleChange(checked)
101
+ field().handleBlur()
102
+ }}
103
+ />
104
+ </div>
105
+ )
106
+ }
107
+ export function FieldTextarea(
108
+ props: Omit<
109
+ JSX.TextareaHTMLAttributes<HTMLTextAreaElement>,
110
+ "value" | "onInput" | "onBlur"
111
+ > & { label: string; icon?: JSX.Element }
112
+ ) {
113
+ const [local, rest] = splitProps(props, [
114
+ "label",
115
+ "icon",
116
+ ]),
117
+ field = useFieldContext<string>()
118
+ const messages = () =>
119
+ field().state.meta.isTouched
120
+ ? errors(field().state.meta.errors)
121
+ : []
122
+ return (
123
+ <div class="flex flex-col gap-2">
124
+ <label
125
+ for={field().name}
126
+ class="text-subheadline font-semibold"
127
+ >
128
+ {local.icon}
129
+ {local.label}
130
+ </label>
131
+ <TextEditor
132
+ {...rest}
133
+ id={field().name}
134
+ name={field().name}
135
+ aria-invalid={messages().length > 0}
136
+ aria-describedby={
137
+ messages().length
138
+ ? `${field().name}-errors`
139
+ : undefined
140
+ }
141
+ value={field().state.value}
142
+ onBlur={() => field().handleBlur()}
143
+ onInput={(event) =>
144
+ field().handleChange(
145
+ event.currentTarget.value
146
+ )
147
+ }
148
+ />
149
+ <Show when={messages().length}>
150
+ <p
151
+ id={`${field().name}-errors`}
152
+ role="alert"
153
+ class="text-footnote text-danger"
154
+ >
155
+ {Array.from(new Set(messages())).join(
156
+ ". "
157
+ )}
158
+ </p>
159
+ </Show>
160
+ </div>
161
+ )
162
+ }
163
+ export function FieldOtp(props: {
164
+ label: string
165
+ maxLength?: number
166
+ onComplete?: (value: string) => void
167
+ }) {
168
+ const field = useFieldContext<string>()
169
+ return (
170
+ <TextField
171
+ label={props.label}
172
+ name={field().name}
173
+ value={field().state.value}
174
+ inputmode="numeric"
175
+ autocomplete="one-time-code"
176
+ pattern="[0-9]*"
177
+ maxLength={props.maxLength ?? 6}
178
+ onBlur={() => field().handleBlur()}
179
+ onInput={(event) => {
180
+ const value = event.currentTarget.value
181
+ .replace(/\D/g, "")
182
+ .slice(0, props.maxLength ?? 6)
183
+ field().handleChange(value)
184
+ if (value.length === (props.maxLength ?? 6))
185
+ props.onComplete?.(value)
186
+ }}
187
+ errors={
188
+ field().state.meta.isTouched
189
+ ? errors(field().state.meta.errors)
190
+ : []
191
+ }
192
+ />
193
+ )
194
+ }
195
+ export type FieldOption = {
196
+ label: string
197
+ value: string
198
+ description?: string
199
+ icon?: JSX.Element
200
+ disabled?: boolean
201
+ }
202
+ export function FieldRadioCard(props: {
203
+ label: string
204
+ description?: string
205
+ options: FieldOption[]
206
+ disabled?: boolean
207
+ columns?: 1 | 2
208
+ }) {
209
+ const field = useFieldContext<string>()
210
+ return (
211
+ <fieldset
212
+ disabled={props.disabled}
213
+ class="flex flex-col gap-2"
214
+ >
215
+ <legend class="text-subheadline font-semibold">
216
+ {props.label}
217
+ </legend>
218
+ <Show when={props.description}>
219
+ <p class="text-footnote text-label-secondary">
220
+ {props.description}
221
+ </p>
222
+ </Show>
223
+ <div
224
+ class={cn(
225
+ "grid gap-2",
226
+ props.columns === 2 && "md:grid-cols-2"
227
+ )}
228
+ >
229
+ <For each={props.options}>
230
+ {(option) => (
231
+ <label
232
+ class={cn(
233
+ "flex items-start gap-3 rounded-xl border p-3",
234
+ field().state.value ===
235
+ option.value
236
+ ? "border-accent-text bg-accent/10"
237
+ : "border-separator bg-elevated",
238
+ (props.disabled ||
239
+ option.disabled) &&
240
+ "opacity-40"
241
+ )}
242
+ >
243
+ <input
244
+ type="radio"
245
+ name={field().name}
246
+ value={option.value}
247
+ checked={
248
+ field().state.value ===
249
+ option.value
250
+ }
251
+ disabled={option.disabled}
252
+ onBlur={() =>
253
+ field().handleBlur()
254
+ }
255
+ onChange={() =>
256
+ field().handleChange(
257
+ option.value
258
+ )
259
+ }
260
+ class="mt-1 accent-accent-text"
261
+ />
262
+ {option.icon}
263
+ <span class="text-subheadline">
264
+ {option.label}
265
+ <Show
266
+ when={option.description}
267
+ >
268
+ <span class="block text-footnote text-label-secondary">
269
+ {option.description}
270
+ </span>
271
+ </Show>
272
+ </span>
273
+ </label>
274
+ )}
275
+ </For>
276
+ </div>
277
+ </fieldset>
278
+ )
279
+ }
280
+ export function FieldMultiselect(props: {
281
+ label: string
282
+ description?: string
283
+ options: FieldOption[]
284
+ }) {
285
+ const field = useFieldContext<string[]>()
286
+ return (
287
+ <fieldset class="flex flex-col gap-3">
288
+ <legend class="text-subheadline font-semibold">
289
+ {props.label}
290
+ </legend>
291
+ <Show when={props.description}>
292
+ <p class="text-footnote text-label-secondary">
293
+ {props.description}
294
+ </p>
295
+ </Show>
296
+ <For each={props.options}>
297
+ {(option) => (
298
+ <div>
299
+ <Toggle
300
+ style="checkbox"
301
+ label={option.label}
302
+ disabled={option.disabled}
303
+ checked={field().state.value.includes(
304
+ option.value
305
+ )}
306
+ onChange={(checked) => {
307
+ field().handleChange(
308
+ checked
309
+ ? Array.from(
310
+ new Set([
311
+ ...field()
312
+ .state
313
+ .value,
314
+ option.value,
315
+ ])
316
+ )
317
+ : field().state.value.filter(
318
+ (value) =>
319
+ value !==
320
+ option.value
321
+ )
322
+ )
323
+ field().handleBlur()
324
+ }}
325
+ />
326
+ <Show when={option.description}>
327
+ <p class="pl-8 text-footnote text-label-secondary">
328
+ {option.description}
329
+ </p>
330
+ </Show>
331
+ </div>
332
+ )}
333
+ </For>
334
+ </fieldset>
335
+ )
336
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./fields"
2
+ export * from "./submit"
3
+ export * from "./avatar"