@passui/tanstack 0.2.6 → 0.3.0

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 (139) hide show
  1. package/dist/{types/src/auth-shell → auth-shell}/auth-shell.d.ts +3 -3
  2. package/dist/auth-shell/auth-shell.js +17 -0
  3. package/dist/auth-shell.d.ts +2 -0
  4. package/dist/auth-shell.js +1 -0
  5. package/dist/core.d.ts +3 -0
  6. package/dist/core.js +3 -0
  7. package/dist/{types/src/document → document}/compose-viewport.d.ts +11 -11
  8. package/dist/document/compose-viewport.js +43 -0
  9. package/dist/document.d.ts +2 -0
  10. package/dist/document.js +1 -0
  11. package/dist/form-fields/fields.d.ts +30 -0
  12. package/dist/form-fields/fields.js +160 -0
  13. package/dist/form-fields/selection.d.ts +21 -0
  14. package/dist/form-fields/selection.js +73 -0
  15. package/dist/form-fields/submit.d.ts +3 -0
  16. package/dist/form-fields/submit.js +26 -0
  17. package/dist/form-fields.d.ts +7 -0
  18. package/dist/form-fields.js +7 -0
  19. package/dist/forms/contexts.js +4 -0
  20. package/dist/{types/src/forms → forms}/elements/form-alert.d.ts +4 -4
  21. package/dist/forms/elements/form-alert.js +19 -0
  22. package/dist/forms/fields/avatar-picker.d.ts +10 -0
  23. package/dist/forms/fields/avatar-picker.js +228 -0
  24. package/dist/forms/fields/avatar.d.ts +30 -0
  25. package/dist/forms/fields/avatar.js +188 -0
  26. package/dist/forms/fields/checkbox.d.ts +2 -0
  27. package/dist/forms/fields/index.d.ts +21 -0
  28. package/dist/forms/fields/index.js +15 -0
  29. package/dist/forms/fields/input.d.ts +2 -0
  30. package/dist/forms/fields/multiselect.d.ts +2 -0
  31. package/dist/forms/fields/otp.d.ts +2 -0
  32. package/dist/forms/fields/radio-card.d.ts +2 -0
  33. package/dist/forms/fields/switch.d.ts +2 -0
  34. package/dist/forms/fields/textarea.d.ts +2 -0
  35. package/dist/forms.d.ts +45 -0
  36. package/dist/forms.js +16 -0
  37. package/dist/mutation/use-app-mutation.d.ts +23 -0
  38. package/dist/mutation/use-app-mutation.js +41 -0
  39. package/dist/mutation.d.ts +3 -0
  40. package/dist/mutation.js +3 -0
  41. package/dist/route-boundary/default-boundary.d.ts +2 -0
  42. package/dist/route-boundary/default-boundary.js +40 -0
  43. package/dist/route-boundary/default-loader.d.ts +6 -0
  44. package/dist/route-boundary/default-loader.js +17 -0
  45. package/dist/{types/src/route-boundary → route-boundary}/not-founder.d.ts +2 -2
  46. package/dist/route-boundary/not-founder.js +44 -0
  47. package/dist/route-boundary.d.ts +4 -0
  48. package/dist/route-boundary.js +4 -0
  49. package/dist/settings/setting-list.d.ts +51 -0
  50. package/dist/settings/setting-list.js +122 -0
  51. package/dist/settings.d.ts +2 -0
  52. package/dist/settings.js +1 -0
  53. package/dist/{types/src/shared → shared}/optimistic.d.ts +2 -2
  54. package/dist/shared/optimistic.js +16 -0
  55. package/dist/{types/src/shared → shared}/table.d.ts +7 -7
  56. package/dist/shared/table.js +12 -0
  57. package/dist/tables/columns.d.ts +3 -0
  58. package/dist/tables/columns.js +21 -0
  59. package/dist/tables/data-table.d.ts +76 -0
  60. package/dist/tables/data-table.js +307 -0
  61. package/dist/tables/filter-row.js +137 -0
  62. package/dist/tables/pagination.d.ts +8 -0
  63. package/dist/tables/pagination.js +86 -0
  64. package/dist/tables.d.ts +4 -0
  65. package/dist/tables.js +4 -0
  66. package/package.json +129 -128
  67. package/src/styles.css +1 -0
  68. package/dist/types/src/auth-shell/index.d.ts +0 -1
  69. package/dist/types/src/document/index.d.ts +0 -1
  70. package/dist/types/src/form-fields/fields.d.ts +0 -24
  71. package/dist/types/src/form-fields/index.d.ts +0 -2
  72. package/dist/types/src/form-fields/selection.d.ts +0 -21
  73. package/dist/types/src/form-fields/submit.d.ts +0 -3
  74. package/dist/types/src/forms/contexts.d.ts +0 -1
  75. package/dist/types/src/forms/elements/submit.d.ts +0 -1
  76. package/dist/types/src/forms/fields/avatar-picker.d.ts +0 -30
  77. package/dist/types/src/forms/fields/avatar.d.ts +0 -30
  78. package/dist/types/src/forms/fields/checkbox.d.ts +0 -1
  79. package/dist/types/src/forms/fields/index.d.ts +0 -21
  80. package/dist/types/src/forms/fields/input.d.ts +0 -1
  81. package/dist/types/src/forms/fields/multiselect.d.ts +0 -1
  82. package/dist/types/src/forms/fields/otp.d.ts +0 -1
  83. package/dist/types/src/forms/fields/radio-card.d.ts +0 -1
  84. package/dist/types/src/forms/fields/switch.d.ts +0 -1
  85. package/dist/types/src/forms/fields/textarea.d.ts +0 -1
  86. package/dist/types/src/forms/index.d.ts +0 -41
  87. package/dist/types/src/mutation/index.d.ts +0 -1
  88. package/dist/types/src/mutation/use-app-mutation.d.ts +0 -22
  89. package/dist/types/src/route-boundary/default-boundary.d.ts +0 -2
  90. package/dist/types/src/route-boundary/default-loader.d.ts +0 -6
  91. package/dist/types/src/route-boundary/index.d.ts +0 -3
  92. package/dist/types/src/settings/index.d.ts +0 -1
  93. package/dist/types/src/settings/setting-list.d.ts +0 -51
  94. package/dist/types/src/shared/index.d.ts +0 -2
  95. package/dist/types/src/tables/columns.d.ts +0 -3
  96. package/dist/types/src/tables/data-table.d.ts +0 -76
  97. package/dist/types/src/tables/filter-row.d.ts +0 -9
  98. package/dist/types/src/tables/index.d.ts +0 -3
  99. package/dist/types/src/tables/pagination.d.ts +0 -8
  100. package/dist/types/src/tables/utils.d.ts +0 -1
  101. package/src/auth-shell/auth-shell.tsx +0 -16
  102. package/src/auth-shell/index.ts +0 -1
  103. package/src/document/compose-viewport.tsx +0 -80
  104. package/src/document/index.ts +0 -1
  105. package/src/form-fields/fields.tsx +0 -147
  106. package/src/form-fields/index.ts +0 -2
  107. package/src/form-fields/selection.tsx +0 -109
  108. package/src/form-fields/submit.tsx +0 -35
  109. package/src/forms/contexts.ts +0 -4
  110. package/src/forms/elements/form-alert.tsx +0 -21
  111. package/src/forms/elements/submit.tsx +0 -1
  112. package/src/forms/fields/avatar-picker.tsx +0 -319
  113. package/src/forms/fields/avatar.tsx +0 -269
  114. package/src/forms/fields/checkbox.tsx +0 -1
  115. package/src/forms/fields/index.ts +0 -29
  116. package/src/forms/fields/input.tsx +0 -1
  117. package/src/forms/fields/multiselect.tsx +0 -1
  118. package/src/forms/fields/otp.tsx +0 -1
  119. package/src/forms/fields/radio-card.tsx +0 -1
  120. package/src/forms/fields/switch.tsx +0 -1
  121. package/src/forms/fields/textarea.tsx +0 -1
  122. package/src/forms/index.ts +0 -26
  123. package/src/mutation/index.ts +0 -1
  124. package/src/mutation/use-app-mutation.ts +0 -100
  125. package/src/route-boundary/default-boundary.tsx +0 -46
  126. package/src/route-boundary/default-loader.tsx +0 -23
  127. package/src/route-boundary/index.ts +0 -3
  128. package/src/route-boundary/not-founder.tsx +0 -39
  129. package/src/settings/index.ts +0 -1
  130. package/src/settings/setting-list.tsx +0 -221
  131. package/src/shared/index.ts +0 -2
  132. package/src/shared/optimistic.ts +0 -19
  133. package/src/shared/table.ts +0 -12
  134. package/src/tables/columns.tsx +0 -30
  135. package/src/tables/data-table.tsx +0 -522
  136. package/src/tables/filter-row.tsx +0 -196
  137. package/src/tables/index.ts +0 -3
  138. package/src/tables/pagination.tsx +0 -85
  139. package/src/tables/utils.ts +0 -5
@@ -1,76 +0,0 @@
1
- import type { ColumnDef, ColumnVisibilityState, RowData } from "@tanstack/react-table";
2
- import type { ReactNode } from "react";
3
- export declare const baseTableFeatures: {
4
- globalFilteringFeature: import("@tanstack/react-table").TableFeature;
5
- columnFilteringFeature: import("@tanstack/react-table").TableFeature;
6
- rowSortingFeature: import("@tanstack/react-table").TableFeature;
7
- rowPaginationFeature: import("@tanstack/react-table").TableFeature;
8
- columnVisibilityFeature: import("@tanstack/react-table").TableFeature;
9
- rowSelectionFeature: import("@tanstack/react-table").TableFeature;
10
- filteredRowModel: (table: import("@tanstack/react-table").Table<any, any>) => () => import("@tanstack/react-table").RowModel<any, any>;
11
- sortedRowModel: (table: import("@tanstack/react-table").Table<any, any>) => () => import("@tanstack/react-table").RowModel<any, any>;
12
- paginatedRowModel: (table: import("@tanstack/react-table").Table<any, any>) => () => import("@tanstack/react-table").RowModel<any, any>;
13
- filterFns: {
14
- includesString: import("@tanstack/react-table").CreatedFilterFn<any, any>;
15
- inNumberRange: import("@tanstack/react-table").CreatedFilterFn<any, any>;
16
- equals: import("@tanstack/react-table").CreatedFilterFn<any, any>;
17
- arrIncludes: import("@tanstack/react-table").CreatedFilterFn<any, any>;
18
- arrIncludesSome: import("@tanstack/react-table").CreatedFilterFn<any, any>;
19
- inDateRange: import("@tanstack/react-table").CreatedFilterFn<any, any>;
20
- };
21
- sortFns: {
22
- text: import("@tanstack/react-table").CreatedSortFn<any, any>;
23
- alphanumeric: import("@tanstack/react-table").CreatedSortFn<any, any>;
24
- datetime: import("@tanstack/react-table").CreatedSortFn<any, any>;
25
- };
26
- };
27
- export type DataTableFeatures = typeof baseTableFeatures;
28
- /**
29
- * `filterVariant: 'date'` is the one thing a caller has to opt into
30
- * explicitly (`updatedAt`/`createdAt`, or a custom `type: 'date'` column):
31
- * unlike an array-valued column (detected automatically below, from the
32
- * actual data), a date is just a string or number at runtime, nothing to
33
- * sniff it from safely.
34
- */
35
- export type DataTableColumnMeta = {
36
- filterVariant?: "date";
37
- };
38
- export type DataTableColumnDef<TData extends RowData, TValue = unknown> = ColumnDef<DataTableFeatures, TData, TValue> & {
39
- meta?: DataTableColumnMeta;
40
- };
41
- type DataTableProps<TData extends RowData> = {
42
- data: TData[];
43
- columns: DataTableColumnDef<TData, any>[];
44
- /**
45
- * A stable id per row, used as the React key and by react-table's row
46
- * model. Without this, react-table falls back to the row's array index,
47
- * so deleting a row shifts every id below it onto a different row's
48
- * data, reusing DOM nodes (and any open dropdown/overlay state) across
49
- * what are now different rows. Required, not defaulted, so this can't
50
- * silently regress.
51
- */
52
- getRowId: (row: TData) => string;
53
- "aria-label": string;
54
- emptyMessage?: ReactNode;
55
- searchPlaceholder?: string;
56
- bulkActions?: (selectedRows: TData[], clearSelection: () => void) => ReactNode;
57
- /** Set false to render just the table. Default true. */
58
- pagination?: boolean;
59
- pageSizeOptions?: number[];
60
- onSelectedRowsChange?: (rows: TData[]) => void;
61
- /** Opens a row, e.g. its detail drawer. Ignored while rows are selectable. */
62
- onRowClick?: (row: TData) => void;
63
- /** A summary row rendered inside the table's own <tfoot>, below the data rows — e.g. a totals line. Gets the visible column count for its colSpan. */
64
- footer?: (columnCount: number) => ReactNode;
65
- /** True while a background refetch is in flight (e.g. after a mutation invalidates the query). Dims the existing rows and shows a small spinner rather than rendering nothing, since `data` still holds the last good result. */
66
- isLoading?: boolean;
67
- /** Columns hidden until someone turns them on from the Columns menu, keyed by column id. */
68
- initialColumnVisibility?: ColumnVisibilityState;
69
- };
70
- /**
71
- * Self-contained table: pass `data` + `columns`, get sorting, pagination,
72
- * search, column visibility, per-column filters, and row selection for
73
- * free. There's no `useTable` state to wire up on the caller's side.
74
- */
75
- export declare function DataTable<TData extends RowData>({ data, columns, getRowId, emptyMessage, searchPlaceholder, bulkActions, pagination, pageSizeOptions, onSelectedRowsChange, onRowClick, footer, isLoading, initialColumnVisibility, "aria-label": ariaLabel, }: DataTableProps<TData>): import("react").JSX.Element;
76
- export {};
@@ -1,9 +0,0 @@
1
- import type { Column, RowData } from "@tanstack/react-table";
2
- import type { DataTableFeatures } from "./data-table";
3
- export declare function FilterRow<TData extends RowData>({ column, data, skip, isArrayColumn, isDateColumn, }: {
4
- column: Column<DataTableFeatures, TData, unknown>;
5
- data: TData[];
6
- skip: string[];
7
- isArrayColumn: boolean;
8
- isDateColumn: boolean;
9
- }): import("react").JSX.Element;
@@ -1,3 +0,0 @@
1
- export * from "./data-table";
2
- export * from "./pagination";
3
- export * from "./columns";
@@ -1,8 +0,0 @@
1
- import type { ReactTable, RowData } from "@tanstack/react-table";
2
- import type { DataTableFeatures } from "./data-table";
3
- type DataTablePaginationProps<TData extends RowData> = {
4
- table: ReactTable<DataTableFeatures, TData>;
5
- pageSizeOptions?: number[];
6
- };
7
- export declare function DataTablePagination<TData extends RowData>({ table, pageSizeOptions, }: DataTablePaginationProps<TData>): import("react").JSX.Element;
8
- export {};
@@ -1 +0,0 @@
1
- export { isArrayValuedColumn, getColumnLabel, columnIdOf, } from "../shared/table";
@@ -1,16 +0,0 @@
1
- import { Outlet } from "@tanstack/react-router"
2
- import type { ReactNode } from "react"
3
-
4
- /** Auth routes share a stable frame; pages own their transitions. */
5
- export function AuthShell({ brand }: { brand: ReactNode }) {
6
- return (
7
- <section className="relative isolate flex min-h-dvh flex-col items-center justify-center-safe px-4 py-12">
8
- <div className="flex w-full max-w-[26rem] flex-col items-start gap-6">
9
- {brand}
10
- <div className="w-full">
11
- <Outlet />
12
- </div>
13
- </div>
14
- </section>
15
- )
16
- }
@@ -1 +0,0 @@
1
- export * from "./auth-shell"
@@ -1,80 +0,0 @@
1
- import { cn } from "@passui/react/cn"
2
- import { TanStackDevtools } from "@tanstack/react-devtools"
3
- import { ReactQueryDevtoolsPanel } from "@tanstack/react-query-devtools"
4
- import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools"
5
- import type { ComponentPropsWithoutRef, PropsWithChildren, ReactNode } from "react"
6
-
7
- /** Extra props (such as `data-theme`) land on `<html>` itself. */
8
- type ComposeViewportProps = PropsWithChildren<ComponentPropsWithoutRef<"html">>
9
-
10
- type WindowProps = ComponentPropsWithoutRef<"body"> & {
11
- /**
12
- * Rendered as direct `<body>` children, after `<main>`, not inside it.
13
- * `<Scripts />` (and devtools) belong here — TanStack Router's own docs
14
- * say `<Scripts />` "should be placed near the end of the document
15
- * body", not nested inside the app's content wrapper.
16
- */
17
- after?: ReactNode
18
- }
19
-
20
- export function ComposeViewport({
21
- children,
22
- lang = "en",
23
- className,
24
- ...props
25
- }: ComposeViewportProps) {
26
- return (
27
- <html
28
- lang={lang}
29
- className={cn("antialiased blur-none", className)}
30
- suppressHydrationWarning
31
- {...props}
32
- >
33
- {children}
34
- </html>
35
- )
36
- }
37
-
38
- function Window({ className, children, after, ...props }: WindowProps) {
39
- return (
40
- <body
41
- className={cn(
42
- "fixed h-svh w-full min-w-full bg-background",
43
- "overflow-x-hidden selection:bg-olive-500/15",
44
- "typeset wrap-anywhere duration-200",
45
- "flex flex-col",
46
- className
47
- )}
48
- {...props}
49
- >
50
- <main className={cn("flex flex-col flex-1 min-h-svh overflow-auto", "no-scrollbar")}>
51
- {children}
52
- </main>
53
- {after}
54
- </body>
55
- )
56
- }
57
-
58
- function Devtools() {
59
- return (
60
- <TanStackDevtools
61
- config={{
62
- triggerMode: "floating",
63
- position: "top-right",
64
- }}
65
- plugins={[
66
- {
67
- name: "TanStack Query",
68
- render: <ReactQueryDevtoolsPanel />,
69
- },
70
- {
71
- name: "Tanstack Router",
72
- render: <TanStackRouterDevtoolsPanel />,
73
- },
74
- ]}
75
- />
76
- )
77
- }
78
-
79
- ComposeViewport.Window = Window
80
- ComposeViewport.Devtools = Devtools
@@ -1 +0,0 @@
1
- export * from "./compose-viewport"
@@ -1,147 +0,0 @@
1
- import { TextField, type TextFieldProps } from "@passui/react/text-field"
2
- import { TextEditor } from "@passui/react/text-editor"
3
- import { Toggle } from "@passui/react/toggle"
4
- import { useFieldContext } from "../forms/contexts"
5
- import { createContext, useContext, type ComponentProps, type ReactNode } from "react"
6
-
7
- export const PeachFieldLabels = createContext<{ show: string; hide: string } | undefined>(undefined)
8
-
9
- export function FieldInput(props: Omit<TextFieldProps, "value" | "onChange" | "onBlur" | "name">) {
10
- const field = useFieldContext<string>()
11
- const revealLabels = useContext(PeachFieldLabels)
12
- return (
13
- <TextField
14
- revealLabels={revealLabels}
15
- {...props}
16
- name={field.name}
17
- value={field.state.value}
18
- onChange={(event) => field.handleChange(event.target.value)}
19
- onBlur={field.handleBlur}
20
- errors={
21
- field.state.meta.isTouched
22
- ? field.state.meta.errors.flatMap((error) =>
23
- error?.message ? [error.message] : []
24
- )
25
- : []
26
- }
27
- />
28
- )
29
- }
30
-
31
- export function FieldCheckbox({ label }: { label: string }) {
32
- const field = useFieldContext<boolean>()
33
- return (
34
- <Toggle
35
- style="checkbox"
36
- label={label}
37
- checked={field.state.value}
38
- onChange={(checked) => {
39
- field.handleChange(checked)
40
- field.handleBlur()
41
- }}
42
- />
43
- )
44
- }
45
-
46
- export function FieldSwitch({
47
- label,
48
- description,
49
- disabled,
50
- }: {
51
- label: string
52
- description?: string
53
- disabled?: boolean
54
- }) {
55
- const field = useFieldContext<boolean>()
56
- return (
57
- <div className="flex items-center justify-between gap-4">
58
- <div className="text-subheadline">
59
- {label}
60
- {description && <p className="text-footnote text-label-secondary">{description}</p>}
61
- </div>
62
- <Toggle
63
- label={label}
64
- checked={field.state.value}
65
- disabled={disabled}
66
- onChange={(checked) => {
67
- field.handleChange(checked)
68
- field.handleBlur()
69
- }}
70
- />
71
- </div>
72
- )
73
- }
74
-
75
- export function FieldTextarea({
76
- label,
77
- icon,
78
- ...props
79
- }: ComponentProps<"textarea"> & {
80
- label: string
81
- icon?: ReactNode
82
- }) {
83
- const field = useFieldContext<string>()
84
- const errors = field.state.meta.isTouched
85
- ? field.state.meta.errors.flatMap((error) => (error?.message ? [error.message] : []))
86
- : []
87
- return (
88
- <div className="flex flex-col gap-2">
89
- <label htmlFor={field.name} className="text-subheadline font-semibold">
90
- {icon}
91
- {label}
92
- </label>
93
- <TextEditor
94
- {...props}
95
- id={field.name}
96
- name={field.name}
97
- aria-invalid={errors.length > 0}
98
- aria-describedby={errors.length ? `${field.name}-errors` : undefined}
99
- value={field.state.value}
100
- onBlur={field.handleBlur}
101
- onChange={(event) => field.handleChange(event.target.value)}
102
- />
103
- {errors.length > 0 && (
104
- <p id={`${field.name}-errors`} role="alert" className="text-footnote text-danger">
105
- {Array.from(new Set(errors)).join(". ")}
106
- </p>
107
- )}
108
- </div>
109
- )
110
- }
111
-
112
- export function FieldOtp({
113
- label,
114
- maxLength = 6,
115
- onComplete,
116
- }: {
117
- label: string
118
- maxLength?: number
119
- onComplete?: (value: string) => void
120
- }) {
121
- const field = useFieldContext<string>()
122
- return (
123
- <TextField
124
- label={label}
125
- name={field.name}
126
- value={field.state.value}
127
- inputMode="numeric"
128
- autoComplete="one-time-code"
129
- pattern="[0-9]*"
130
- maxLength={maxLength}
131
- autoFocus
132
- onBlur={field.handleBlur}
133
- onChange={(event) => {
134
- const code = event.target.value.replace(/\D/g, "").slice(0, maxLength)
135
- field.handleChange(code)
136
- if (code.length === maxLength) onComplete?.(code)
137
- }}
138
- errors={
139
- field.state.meta.isTouched
140
- ? field.state.meta.errors.flatMap((error) =>
141
- error?.message ? [error.message] : []
142
- )
143
- : []
144
- }
145
- />
146
- )
147
- }
@@ -1,2 +0,0 @@
1
- export * from "../forms/index"
2
- export { PeachFieldLabels } from "./fields"
@@ -1,109 +0,0 @@
1
- import type { ReactNode } from "react"
2
- import { cn } from "@passui/react/cn"
3
- import { Toggle } from "@passui/react/toggle"
4
- import { useFieldContext } from "../forms/contexts"
5
-
6
- type Option = {
7
- label: string
8
- value: string
9
- description?: string
10
- icon?: ReactNode
11
- disabled?: boolean
12
- }
13
-
14
- export function FieldRadioCard({
15
- label,
16
- description,
17
- options,
18
- disabled,
19
- columns = 1,
20
- }: {
21
- label: string
22
- description?: string
23
- options: Option[]
24
- disabled?: boolean
25
- columns?: 1 | 2
26
- }) {
27
- const field = useFieldContext<string>()
28
- return (
29
- <fieldset disabled={disabled} className="flex flex-col gap-2">
30
- <legend className="text-subheadline font-semibold">{label}</legend>
31
- {description && <p className="text-footnote text-label-secondary">{description}</p>}
32
- <div className={cn("grid gap-2", columns === 2 && "md:grid-cols-2")}>
33
- {options.map((option) => (
34
- <label
35
- key={option.value}
36
- className={cn(
37
- "flex items-start gap-3 rounded-xl border p-3",
38
- field.state.value === option.value
39
- ? "border-accent-text bg-accent/10"
40
- : "border-separator bg-elevated",
41
- (disabled || option.disabled) && "opacity-40"
42
- )}
43
- >
44
- <input
45
- type="radio"
46
- name={field.name}
47
- value={option.value}
48
- checked={field.state.value === option.value}
49
- disabled={option.disabled}
50
- onBlur={field.handleBlur}
51
- onChange={() => field.handleChange(option.value)}
52
- className="mt-1 accent-accent-text"
53
- />
54
- {option.icon}
55
- <span className="text-subheadline">
56
- {option.label}
57
- {option.description && (
58
- <span className="block text-footnote text-label-secondary">
59
- {option.description}
60
- </span>
61
- )}
62
- </span>
63
- </label>
64
- ))}
65
- </div>
66
- </fieldset>
67
- )
68
- }
69
-
70
- export function FieldMultiselect({
71
- label,
72
- description,
73
- options,
74
- }: {
75
- label: string
76
- description?: string
77
- options: Option[]
78
- }) {
79
- const field = useFieldContext<string[]>()
80
- return (
81
- <fieldset className="flex flex-col gap-3">
82
- <legend className="text-subheadline font-semibold">{label}</legend>
83
- {description && <p className="text-footnote text-label-secondary">{description}</p>}
84
- {options.map((option) => (
85
- <div key={option.value}>
86
- <Toggle
87
- style="checkbox"
88
- label={option.label}
89
- disabled={option.disabled}
90
- checked={field.state.value.includes(option.value)}
91
- onChange={(checked) => {
92
- field.handleChange(
93
- checked
94
- ? Array.from(new Set([...field.state.value, option.value]))
95
- : field.state.value.filter((value) => value !== option.value)
96
- )
97
- field.handleBlur()
98
- }}
99
- />
100
- {option.description && (
101
- <p className="pl-8 text-footnote text-label-secondary">
102
- {option.description}
103
- </p>
104
- )}
105
- </div>
106
- ))}
107
- </fieldset>
108
- )
109
- }
@@ -1,35 +0,0 @@
1
- import { Button } from "@passui/react/button"
2
- import { useFormContext } from "../forms/contexts"
3
-
4
- export function Submit({ label }: { label: string }) {
5
- const form = useFormContext()
6
- return (
7
- <form.Subscribe
8
- selector={(state) => [
9
- state.isSubmitting,
10
- state.canSubmit,
11
- state.isDirty,
12
- state.isTouched,
13
- ]}
14
- >
15
- {([pending, valid, dirty, touched]) => (
16
- <Button
17
- type="submit"
18
- variant="default"
19
- size="default"
20
- aria-busy={pending}
21
- disabled={pending || !valid || !dirty || !touched}
22
- className="w-full"
23
- >
24
- {pending && (
25
- <span
26
- aria-hidden
27
- className="size-4 animate-spin rounded-full border-2 border-current border-r-transparent"
28
- />
29
- )}
30
- {label}
31
- </Button>
32
- )}
33
- </form.Subscribe>
34
- )
35
- }
@@ -1,4 +0,0 @@
1
- import { createFormHookContexts } from "@tanstack/react-form"
2
-
3
- export const { fieldContext, formContext, useFieldContext, useFormContext } =
4
- createFormHookContexts()
@@ -1,21 +0,0 @@
1
- import { Alert02Icon } from "@hugeicons/core-free-icons"
2
- import { HugeiconsIcon } from "@hugeicons/react"
3
- import type { ReactNode } from "react"
4
- import { cn } from "@passui/react/cn"
5
-
6
- /** A form-level error people can't miss: announced, tinted, and gently shaken in. */
7
- export function FormAlert({ children, className }: { children: ReactNode; className?: string }) {
8
- return (
9
- <div
10
- role="alert"
11
- className={cn(
12
- "flex items-start gap-2.5 rounded-2xl bg-destructive/12 px-4 py-3 text-sm font-medium text-destructive ring-1 ring-destructive/25 ring-inset",
13
- "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-300",
14
- className
15
- )}
16
- >
17
- <HugeiconsIcon icon={Alert02Icon} className="mt-px size-4 shrink-0" />
18
- <span className="min-w-0">{children}</span>
19
- </div>
20
- )
21
- }
@@ -1 +0,0 @@
1
- export { Submit } from "../../form-fields/submit"