@passui/tanstack 0.2.4 → 0.2.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.
- package/README.md +3 -42
- package/dist/types/src/auth-shell/auth-shell.d.ts +5 -0
- package/dist/types/src/document/compose-viewport.d.ts +20 -0
- package/dist/types/src/form-fields/fields.d.ts +24 -0
- package/dist/types/src/form-fields/index.d.ts +2 -0
- package/dist/types/src/form-fields/selection.d.ts +21 -0
- package/dist/types/src/form-fields/submit.d.ts +3 -0
- package/dist/types/src/forms/contexts.d.ts +1 -0
- package/dist/types/src/forms/elements/form-alert.d.ts +6 -0
- package/dist/types/src/forms/elements/submit.d.ts +1 -0
- package/dist/types/src/forms/fields/avatar-picker.d.ts +30 -0
- package/dist/types/src/forms/fields/avatar.d.ts +30 -0
- package/dist/types/src/forms/fields/checkbox.d.ts +1 -0
- package/dist/types/src/forms/fields/index.d.ts +21 -0
- package/dist/types/src/forms/fields/input.d.ts +1 -0
- package/dist/types/src/forms/fields/multiselect.d.ts +1 -0
- package/dist/types/src/forms/fields/otp.d.ts +1 -0
- package/dist/types/src/forms/fields/radio-card.d.ts +1 -0
- package/dist/types/src/forms/fields/switch.d.ts +1 -0
- package/dist/types/src/forms/fields/textarea.d.ts +1 -0
- package/dist/types/src/forms/index.d.ts +41 -0
- package/dist/types/src/mutation/index.d.ts +1 -0
- package/dist/types/src/mutation/use-app-mutation.d.ts +22 -0
- package/dist/types/src/route-boundary/default-boundary.d.ts +2 -0
- package/dist/types/src/route-boundary/default-loader.d.ts +6 -0
- package/dist/types/src/route-boundary/index.d.ts +3 -0
- package/dist/types/src/route-boundary/not-founder.d.ts +4 -0
- package/dist/types/src/settings/setting-list.d.ts +51 -0
- package/dist/types/src/shared/index.d.ts +2 -0
- package/dist/types/src/shared/optimistic.d.ts +3 -0
- package/dist/types/src/shared/table.d.ts +11 -0
- package/dist/types/src/{solid/tables → tables}/columns.d.ts +1 -2
- package/dist/types/src/tables/data-table.d.ts +76 -0
- package/dist/types/src/tables/filter-row.d.ts +9 -0
- package/dist/types/src/{solid/tables → tables}/index.d.ts +0 -1
- package/dist/types/src/tables/pagination.d.ts +8 -0
- package/dist/types/src/tables/utils.d.ts +1 -0
- package/package.json +8 -93
- package/src/document/compose-viewport.tsx +4 -20
- package/src/form-fields/fields.tsx +17 -62
- package/src/form-fields/selection.tsx +12 -52
- package/src/form-fields/submit.tsx +1 -6
- package/src/forms/contexts.ts +2 -6
- package/src/forms/elements/form-alert.tsx +2 -11
- package/src/forms/fields/avatar-picker.tsx +39 -119
- package/src/forms/fields/avatar.tsx +13 -43
- package/src/forms/fields/index.ts +1 -4
- package/src/forms/index.ts +1 -5
- package/src/mutation/use-app-mutation.ts +32 -88
- package/src/route-boundary/default-boundary.tsx +4 -19
- package/src/route-boundary/default-loader.tsx +14 -10
- package/src/route-boundary/not-founder.tsx +3 -14
- package/src/settings/setting-list.tsx +10 -41
- package/src/shared/optimistic.ts +15 -3
- package/src/shared/table.ts +6 -24
- package/src/tables/columns.tsx +4 -13
- package/src/tables/data-table.tsx +130 -225
- package/src/tables/filter-row.tsx +19 -83
- package/src/tables/pagination.tsx +4 -12
- package/dist/client/chunks/form-fields-DlWu70u5.js +0 -630
- package/dist/client/src/solid/auth-shell/index.js +0 -15
- package/dist/client/src/solid/document/index.js +0 -51
- package/dist/client/src/solid/form-fields/index.js +0 -1
- package/dist/client/src/solid/forms/index.js +0 -33
- package/dist/client/src/solid/mutation/index.js +0 -46
- package/dist/client/src/solid/route-boundary/index.js +0 -73
- package/dist/client/src/solid/settings/index.js +0 -173
- package/dist/client/src/solid/tables/index.js +0 -500
- package/dist/server/src/solid/auth-shell/index.js +0 -15
- package/dist/server/src/solid/document/index.js +0 -55
- package/dist/server/src/solid/form-fields/index.js +0 -598
- package/dist/server/src/solid/forms/index.js +0 -33
- package/dist/server/src/solid/mutation/index.js +0 -46
- package/dist/server/src/solid/route-boundary/index.js +0 -73
- package/dist/server/src/solid/settings/index.js +0 -169
- package/dist/server/src/solid/tables/index.js +0 -480
- package/dist/types/src/solid/auth-shell/auth-shell.d.ts +0 -4
- package/dist/types/src/solid/document/compose-viewport.d.ts +0 -14
- package/dist/types/src/solid/form-fields/avatar.d.ts +0 -26
- package/dist/types/src/solid/form-fields/fields.d.ts +0 -45
- package/dist/types/src/solid/form-fields/index.d.ts +0 -3
- package/dist/types/src/solid/form-fields/submit.d.ts +0 -3
- package/dist/types/src/solid/forms/contexts.d.ts +0 -1
- package/dist/types/src/solid/forms/form-alert.d.ts +0 -6
- package/dist/types/src/solid/forms/index.d.ts +0 -43
- package/dist/types/src/solid/mutation/index.d.ts +0 -1
- package/dist/types/src/solid/mutation/use-app-mutation.d.ts +0 -22
- package/dist/types/src/solid/route-boundary/boundaries.d.ts +0 -8
- package/dist/types/src/solid/route-boundary/index.d.ts +0 -1
- package/dist/types/src/solid/settings/setting-list.d.ts +0 -37
- package/dist/types/src/solid/tables/data-table.d.ts +0 -58
- package/dist/types/src/solid/tables/filter-row.d.ts +0 -9
- package/dist/types/src/solid/tables/pagination.d.ts +0 -7
- package/src/solid/auth-shell/auth-shell.tsx +0 -16
- package/src/solid/auth-shell/index.ts +0 -1
- package/src/solid/document/compose-viewport.tsx +0 -69
- package/src/solid/document/index.ts +0 -1
- package/src/solid/form-fields/avatar.tsx +0 -370
- package/src/solid/form-fields/fields.tsx +0 -336
- package/src/solid/form-fields/index.ts +0 -3
- package/src/solid/form-fields/submit.tsx +0 -31
- package/src/solid/forms/contexts.ts +0 -7
- package/src/solid/forms/form-alert.tsx +0 -19
- package/src/solid/forms/index.ts +0 -32
- package/src/solid/mutation/index.ts +0 -5
- package/src/solid/mutation/use-app-mutation.ts +0 -171
- package/src/solid/route-boundary/boundaries.tsx +0 -104
- package/src/solid/route-boundary/index.ts +0 -1
- package/src/solid/settings/index.ts +0 -1
- package/src/solid/settings/setting-list.tsx +0 -185
- package/src/solid/styles.css +0 -2
- package/src/solid/tables/columns.tsx +0 -40
- package/src/solid/tables/data-table.tsx +0 -448
- package/src/solid/tables/filter-row.tsx +0 -161
- package/src/solid/tables/index.ts +0 -4
- package/src/solid/tables/pagination.tsx +0 -78
- /package/dist/types/src/{solid/auth-shell → auth-shell}/index.d.ts +0 -0
- /package/dist/types/src/{solid/document → document}/index.d.ts +0 -0
- /package/dist/types/src/{solid/settings → settings}/index.d.ts +0 -0
|
@@ -20,27 +20,16 @@ export function NotFound({ children }: NotFoundProps) {
|
|
|
20
20
|
Page Not Found
|
|
21
21
|
</h2>
|
|
22
22
|
<p className="max-w-70 text-sm text-muted-foreground">
|
|
23
|
-
The page you are looking for might
|
|
24
|
-
have been moved, renamed, or
|
|
25
|
-
deleted.
|
|
23
|
+
The page you are looking for might have been moved, renamed, or deleted.
|
|
26
24
|
</p>
|
|
27
25
|
</div>
|
|
28
26
|
)}
|
|
29
27
|
|
|
30
28
|
<div className="mt-2 flex items-center gap-2">
|
|
31
|
-
<Button
|
|
32
|
-
onClick={() => router.history.back()}
|
|
33
|
-
variant="secondary"
|
|
34
|
-
size="sm"
|
|
35
|
-
>
|
|
29
|
+
<Button onClick={() => router.history.back()} variant="secondary" size="sm">
|
|
36
30
|
Go back
|
|
37
31
|
</Button>
|
|
38
|
-
<Link
|
|
39
|
-
to="/"
|
|
40
|
-
className={cn(
|
|
41
|
-
buttonStyle({ size: "sm" })
|
|
42
|
-
)}
|
|
43
|
-
>
|
|
32
|
+
<Link to="/" className={cn(buttonStyle({ size: "sm" }))}>
|
|
44
33
|
Start Over
|
|
45
34
|
</Link>
|
|
46
35
|
</div>
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type IconButtonSize,
|
|
4
|
-
} from "@passui/react/icon-button"
|
|
5
|
-
import {
|
|
6
|
-
ArrowRight01Icon,
|
|
7
|
-
Copy01Icon,
|
|
8
|
-
Tick02Icon,
|
|
9
|
-
} from "@hugeicons/core-free-icons"
|
|
1
|
+
import { IconButton, type IconButtonSize } from "@passui/react/icon-button"
|
|
2
|
+
import { ArrowRight01Icon, Copy01Icon, Tick02Icon } from "@hugeicons/core-free-icons"
|
|
10
3
|
import { HugeiconsIcon } from "@hugeicons/react"
|
|
11
4
|
import { cn } from "@passui/react/cn"
|
|
12
5
|
import { Link } from "@tanstack/react-router"
|
|
@@ -80,13 +73,9 @@ export function SettingList({
|
|
|
80
73
|
<div className="flex items-center gap-3 border-b border-separator/60 px-4 py-4 sm:px-5 [&>span:first-child]:size-9 [&>span:first-child_.glyph]:size-4">
|
|
81
74
|
{icon}
|
|
82
75
|
<div className="flex min-w-0 flex-1 flex-col">
|
|
83
|
-
<Heading className="text-base">
|
|
84
|
-
{title}
|
|
85
|
-
</Heading>
|
|
76
|
+
<Heading className="text-base">{title}</Heading>
|
|
86
77
|
{description && (
|
|
87
|
-
<p className="text-[13px] text-muted-foreground">
|
|
88
|
-
{description}
|
|
89
|
-
</p>
|
|
78
|
+
<p className="text-[13px] text-muted-foreground">{description}</p>
|
|
90
79
|
)}
|
|
91
80
|
</div>
|
|
92
81
|
{action}
|
|
@@ -124,11 +113,7 @@ export function SettingList({
|
|
|
124
113
|
{icon}
|
|
125
114
|
<div className="min-w-0 wrap-anywhere">
|
|
126
115
|
<Heading>{title}</Heading>
|
|
127
|
-
{description &&
|
|
128
|
-
<p className="text-sm">
|
|
129
|
-
{description}
|
|
130
|
-
</p>
|
|
131
|
-
)}
|
|
116
|
+
{description && <p className="text-sm">{description}</p>}
|
|
132
117
|
</div>
|
|
133
118
|
</div>
|
|
134
119
|
{action}
|
|
@@ -171,14 +156,10 @@ function Row({
|
|
|
171
156
|
{icon}
|
|
172
157
|
<span className="flex min-w-0 flex-1 flex-col">
|
|
173
158
|
<h3 className="truncate text-sm">{title}</h3>
|
|
174
|
-
{description &&
|
|
175
|
-
<p className="text-xs">{description}</p>
|
|
176
|
-
)}
|
|
159
|
+
{description && <p className="text-xs">{description}</p>}
|
|
177
160
|
</span>
|
|
178
161
|
{value && (
|
|
179
|
-
<span className="max-w-[45%] truncate text-sm text-muted-foreground">
|
|
180
|
-
{value}
|
|
181
|
-
</span>
|
|
162
|
+
<span className="max-w-[45%] truncate text-sm text-muted-foreground">{value}</span>
|
|
182
163
|
)}
|
|
183
164
|
{trailing}
|
|
184
165
|
{(chevron ?? interactive) && (
|
|
@@ -192,23 +173,14 @@ function Row({
|
|
|
192
173
|
|
|
193
174
|
if (to) {
|
|
194
175
|
return (
|
|
195
|
-
<Link
|
|
196
|
-
to={to}
|
|
197
|
-
params={params}
|
|
198
|
-
hash={hash}
|
|
199
|
-
className={className}
|
|
200
|
-
>
|
|
176
|
+
<Link to={to} params={params} hash={hash} className={className}>
|
|
201
177
|
{body}
|
|
202
178
|
</Link>
|
|
203
179
|
)
|
|
204
180
|
}
|
|
205
181
|
if (onClick) {
|
|
206
182
|
return (
|
|
207
|
-
<button
|
|
208
|
-
type="button"
|
|
209
|
-
onClick={onClick}
|
|
210
|
-
className={className}
|
|
211
|
-
>
|
|
183
|
+
<button type="button" onClick={onClick} className={className}>
|
|
212
184
|
{body}
|
|
213
185
|
</button>
|
|
214
186
|
)
|
|
@@ -240,10 +212,7 @@ function Copy({
|
|
|
240
212
|
setTimeout(() => setCopied(false), 1500)
|
|
241
213
|
}}
|
|
242
214
|
>
|
|
243
|
-
<HugeiconsIcon
|
|
244
|
-
icon={copied ? Tick02Icon : Copy01Icon}
|
|
245
|
-
className="size-4"
|
|
246
|
-
/>
|
|
215
|
+
<HugeiconsIcon icon={copied ? Tick02Icon : Copy01Icon} className="size-4" />
|
|
247
216
|
</IconButton>
|
|
248
217
|
)
|
|
249
218
|
}
|
package/src/shared/optimistic.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
import type { QueryClient, QueryKey } from "@tanstack/react-query"
|
|
2
|
+
|
|
1
3
|
/** Restore only the snapshot this mutation wrote, preserving newer concurrent writes. */
|
|
2
|
-
export function shouldRestoreOptimisticSnapshot<T>(
|
|
3
|
-
current
|
|
4
|
+
export function shouldRestoreOptimisticSnapshot<T>(current: T | undefined, expected: T) {
|
|
5
|
+
return current === expected
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Remove a new optimistic cache entry when no cache value existed before the mutation. */
|
|
9
|
+
export function restoreOptimisticSnapshot<T>(
|
|
10
|
+
client: Pick<QueryClient, "getQueryData" | "setQueryData" | "removeQueries">,
|
|
11
|
+
queryKey: QueryKey,
|
|
12
|
+
previous: T | undefined,
|
|
4
13
|
expected: T
|
|
5
14
|
) {
|
|
6
|
-
|
|
15
|
+
if (!shouldRestoreOptimisticSnapshot(client.getQueryData<T>(queryKey), expected)) return false
|
|
16
|
+
if (previous === undefined) client.removeQueries({ queryKey, exact: true })
|
|
17
|
+
else client.setQueryData(queryKey, previous)
|
|
18
|
+
return true
|
|
7
19
|
}
|
package/src/shared/table.ts
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
export function isArrayValuedColumn<TData>(
|
|
2
|
-
data
|
|
3
|
-
colId: string
|
|
4
|
-
): boolean {
|
|
5
|
-
return data.some((row) =>
|
|
6
|
-
Array.isArray((row as Record<string, unknown>)[colId])
|
|
7
|
-
)
|
|
1
|
+
export function isArrayValuedColumn<TData>(data: TData[], colId: string): boolean {
|
|
2
|
+
return data.some((row) => Array.isArray((row as Record<string, unknown>)[colId]))
|
|
8
3
|
}
|
|
9
|
-
export function getColumnLabel(column: {
|
|
10
|
-
columnDef: { header?: unknown }
|
|
11
|
-
id: string
|
|
12
|
-
}) {
|
|
4
|
+
export function getColumnLabel(column: { columnDef: { header?: unknown }; id: string }) {
|
|
13
5
|
const header = column.columnDef.header
|
|
14
6
|
return typeof header === "string"
|
|
15
7
|
? header
|
|
16
|
-
: column.id
|
|
17
|
-
.replace(/([A-Z])/g, " $1")
|
|
18
|
-
.replace(/^./, (value) => value.toUpperCase())
|
|
8
|
+
: column.id.replace(/([A-Z])/g, " $1").replace(/^./, (value) => value.toUpperCase())
|
|
19
9
|
}
|
|
20
|
-
export function columnIdOf(column: {
|
|
21
|
-
id
|
|
22
|
-
accessorKey?: unknown
|
|
23
|
-
}): string | undefined {
|
|
24
|
-
return (
|
|
25
|
-
column.id ||
|
|
26
|
-
(typeof column.accessorKey === "string"
|
|
27
|
-
? column.accessorKey
|
|
28
|
-
: undefined)
|
|
29
|
-
)
|
|
10
|
+
export function columnIdOf(column: { id?: string; accessorKey?: unknown }): string | undefined {
|
|
11
|
+
return column.id || (typeof column.accessorKey === "string" ? column.accessorKey : undefined)
|
|
30
12
|
}
|
package/src/tables/columns.tsx
CHANGED
|
@@ -2,9 +2,7 @@ import type { RowData } from "@tanstack/react-table"
|
|
|
2
2
|
import { Toggle } from "@passui/react/toggle"
|
|
3
3
|
import type { DataTableColumnDef } from "./data-table"
|
|
4
4
|
|
|
5
|
-
export function selectColumn<
|
|
6
|
-
TData extends RowData,
|
|
7
|
-
>(): DataTableColumnDef<TData> {
|
|
5
|
+
export function selectColumn<TData extends RowData>(): DataTableColumnDef<TData> {
|
|
8
6
|
return {
|
|
9
7
|
id: "select",
|
|
10
8
|
enableColumnFilter: false,
|
|
@@ -14,13 +12,8 @@ export function selectColumn<
|
|
|
14
12
|
style="checkbox"
|
|
15
13
|
labelHidden
|
|
16
14
|
checked={table.getIsAllPageRowsSelected()}
|
|
17
|
-
mixed={
|
|
18
|
-
|
|
19
|
-
!table.getIsAllPageRowsSelected()
|
|
20
|
-
}
|
|
21
|
-
onChange={(checked) =>
|
|
22
|
-
table.toggleAllPageRowsSelected(checked)
|
|
23
|
-
}
|
|
15
|
+
mixed={table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected()}
|
|
16
|
+
onChange={(checked) => table.toggleAllPageRowsSelected(checked)}
|
|
24
17
|
label="Select all"
|
|
25
18
|
/>
|
|
26
19
|
),
|
|
@@ -29,9 +22,7 @@ export function selectColumn<
|
|
|
29
22
|
style="checkbox"
|
|
30
23
|
labelHidden
|
|
31
24
|
checked={row.getIsSelected()}
|
|
32
|
-
onChange={(checked) =>
|
|
33
|
-
row.toggleSelected(checked)
|
|
34
|
-
}
|
|
25
|
+
onChange={(checked) => row.toggleSelected(checked)}
|
|
35
26
|
label="Select row"
|
|
36
27
|
/>
|
|
37
28
|
),
|