@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
|
@@ -24,36 +24,20 @@ function useQuickFilterValues<TData>(
|
|
|
24
24
|
if (exclude.includes(colId)) return []
|
|
25
25
|
if (isArrayColumn) {
|
|
26
26
|
const flattened = data.flatMap((row) => {
|
|
27
|
-
const value = (
|
|
28
|
-
row as Record<string, unknown>
|
|
29
|
-
)[colId]
|
|
27
|
+
const value = (row as Record<string, unknown>)[colId]
|
|
30
28
|
return Array.isArray(value) ? value : []
|
|
31
29
|
})
|
|
32
30
|
const unique = [
|
|
33
|
-
...new Set(
|
|
34
|
-
flattened.filter(
|
|
35
|
-
(v) =>
|
|
36
|
-
v !== null &&
|
|
37
|
-
v !== undefined &&
|
|
38
|
-
v !== ""
|
|
39
|
-
)
|
|
40
|
-
),
|
|
31
|
+
...new Set(flattened.filter((v) => v !== null && v !== undefined && v !== "")),
|
|
41
32
|
]
|
|
42
|
-
if (unique.length < 2 || unique.length > 20)
|
|
43
|
-
return []
|
|
33
|
+
if (unique.length < 2 || unique.length > 20) return []
|
|
44
34
|
return unique.map((v) => String(v))
|
|
45
35
|
}
|
|
46
|
-
const raw = data.map(
|
|
47
|
-
(row) => (row as Record<string, unknown>)[colId]
|
|
48
|
-
)
|
|
36
|
+
const raw = data.map((row) => (row as Record<string, unknown>)[colId])
|
|
49
37
|
const unique = [
|
|
50
38
|
...new Set(
|
|
51
39
|
raw.filter(
|
|
52
|
-
(v) =>
|
|
53
|
-
v !== null &&
|
|
54
|
-
v !== undefined &&
|
|
55
|
-
v !== "" &&
|
|
56
|
-
typeof v !== "object"
|
|
40
|
+
(v) => v !== null && v !== undefined && v !== "" && typeof v !== "object"
|
|
57
41
|
)
|
|
58
42
|
),
|
|
59
43
|
]
|
|
@@ -75,22 +59,14 @@ export function FilterRow<TData extends RowData>({
|
|
|
75
59
|
isArrayColumn: boolean
|
|
76
60
|
isDateColumn: boolean
|
|
77
61
|
}) {
|
|
78
|
-
const uniqueValues = useQuickFilterValues(
|
|
79
|
-
data,
|
|
80
|
-
column.id,
|
|
81
|
-
skip,
|
|
82
|
-
isArrayColumn
|
|
83
|
-
)
|
|
62
|
+
const uniqueValues = useQuickFilterValues(data, column.id, skip, isArrayColumn)
|
|
84
63
|
const label = getColumnLabel(column)
|
|
85
64
|
|
|
86
65
|
// A date column never gets the enumerated-values treatment below —
|
|
87
66
|
// every row realistically has its own distinct timestamp — a from/to
|
|
88
67
|
// range is what's actually useful.
|
|
89
68
|
if (isDateColumn) {
|
|
90
|
-
const [from, to] =
|
|
91
|
-
(column.getFilterValue() as
|
|
92
|
-
| [string?, string?]
|
|
93
|
-
| undefined) ?? []
|
|
69
|
+
const [from, to] = (column.getFilterValue() as [string?, string?] | undefined) ?? []
|
|
94
70
|
return (
|
|
95
71
|
<div className="flex items-center gap-3">
|
|
96
72
|
<span className="w-20 shrink-0 text-[11px] font-medium text-muted-foreground">
|
|
@@ -100,26 +76,14 @@ export function FilterRow<TData extends RowData>({
|
|
|
100
76
|
<input
|
|
101
77
|
type="date"
|
|
102
78
|
value={from ?? ""}
|
|
103
|
-
onChange={(e) =>
|
|
104
|
-
column.setFilterValue([
|
|
105
|
-
e.target.value || undefined,
|
|
106
|
-
to,
|
|
107
|
-
])
|
|
108
|
-
}
|
|
79
|
+
onChange={(e) => column.setFilterValue([e.target.value || undefined, to])}
|
|
109
80
|
className="h-7 rounded-none border border-dashed border-input/40 bg-background px-2 text-xs outline-none"
|
|
110
81
|
/>
|
|
111
|
-
<span className="text-[11px] text-muted-foreground">
|
|
112
|
-
to
|
|
113
|
-
</span>
|
|
82
|
+
<span className="text-[11px] text-muted-foreground">to</span>
|
|
114
83
|
<input
|
|
115
84
|
type="date"
|
|
116
85
|
value={to ?? ""}
|
|
117
|
-
onChange={(e) =>
|
|
118
|
-
column.setFilterValue([
|
|
119
|
-
from,
|
|
120
|
-
e.target.value || undefined,
|
|
121
|
-
])
|
|
122
|
-
}
|
|
86
|
+
onChange={(e) => column.setFilterValue([from, e.target.value || undefined])}
|
|
123
87
|
className="h-7 rounded-none border border-dashed border-input/40 bg-background px-2 text-xs outline-none"
|
|
124
88
|
/>
|
|
125
89
|
{(from || to) && (
|
|
@@ -127,17 +91,10 @@ export function FilterRow<TData extends RowData>({
|
|
|
127
91
|
label="Clear filter"
|
|
128
92
|
type="button"
|
|
129
93
|
size="icon-sm"
|
|
130
|
-
onClick={() =>
|
|
131
|
-
column.setFilterValue(
|
|
132
|
-
undefined
|
|
133
|
-
)
|
|
134
|
-
}
|
|
94
|
+
onClick={() => column.setFilterValue(undefined)}
|
|
135
95
|
className="text-muted-foreground hover:text-foreground"
|
|
136
96
|
>
|
|
137
|
-
<HugeiconsIcon
|
|
138
|
-
icon={Cancel01Icon}
|
|
139
|
-
className="size-3"
|
|
140
|
-
/>
|
|
97
|
+
<HugeiconsIcon icon={Cancel01Icon} className="size-3" />
|
|
141
98
|
</IconButton>
|
|
142
99
|
)}
|
|
143
100
|
</div>
|
|
@@ -149,10 +106,7 @@ export function FilterRow<TData extends RowData>({
|
|
|
149
106
|
// one-element array for an array-valued column (array-contains matching
|
|
150
107
|
// needs an array of values to check for overlap, even when only one is
|
|
151
108
|
// ever picked here).
|
|
152
|
-
const activeFilter = column.getFilterValue() as
|
|
153
|
-
| string
|
|
154
|
-
| string[]
|
|
155
|
-
| undefined
|
|
109
|
+
const activeFilter = column.getFilterValue() as string | string[] | undefined
|
|
156
110
|
const activeValue = isArrayColumn
|
|
157
111
|
? Array.isArray(activeFilter)
|
|
158
112
|
? activeFilter[0]
|
|
@@ -168,11 +122,7 @@ export function FilterRow<TData extends RowData>({
|
|
|
168
122
|
const active = activeValue === value
|
|
169
123
|
const setActive = () =>
|
|
170
124
|
column.setFilterValue(
|
|
171
|
-
active
|
|
172
|
-
? undefined
|
|
173
|
-
: isArrayColumn
|
|
174
|
-
? [value]
|
|
175
|
-
: value
|
|
125
|
+
active ? undefined : isArrayColumn ? [value] : value
|
|
176
126
|
)
|
|
177
127
|
return (
|
|
178
128
|
<div
|
|
@@ -187,9 +137,7 @@ export function FilterRow<TData extends RowData>({
|
|
|
187
137
|
checked={active}
|
|
188
138
|
onChange={setActive}
|
|
189
139
|
/>
|
|
190
|
-
<span className="text-xs">
|
|
191
|
-
{value}
|
|
192
|
-
</span>
|
|
140
|
+
<span className="text-xs">{value}</span>
|
|
193
141
|
</div>
|
|
194
142
|
)
|
|
195
143
|
})}
|
|
@@ -198,17 +146,10 @@ export function FilterRow<TData extends RowData>({
|
|
|
198
146
|
type="button"
|
|
199
147
|
variant="ghost"
|
|
200
148
|
size="sm"
|
|
201
|
-
onClick={() =>
|
|
202
|
-
column.setFilterValue(
|
|
203
|
-
undefined
|
|
204
|
-
)
|
|
205
|
-
}
|
|
149
|
+
onClick={() => column.setFilterValue(undefined)}
|
|
206
150
|
className="text-muted-foreground hover:text-foreground"
|
|
207
151
|
>
|
|
208
|
-
<HugeiconsIcon
|
|
209
|
-
icon={Cancel01Icon}
|
|
210
|
-
className="size-3"
|
|
211
|
-
/>
|
|
152
|
+
<HugeiconsIcon icon={Cancel01Icon} className="size-3" />
|
|
212
153
|
Clear
|
|
213
154
|
</Button>
|
|
214
155
|
)}
|
|
@@ -243,15 +184,10 @@ export function FilterRow<TData extends RowData>({
|
|
|
243
184
|
label="Clear filter"
|
|
244
185
|
type="button"
|
|
245
186
|
size="icon-sm"
|
|
246
|
-
onClick={() =>
|
|
247
|
-
column.setFilterValue(undefined)
|
|
248
|
-
}
|
|
187
|
+
onClick={() => column.setFilterValue(undefined)}
|
|
249
188
|
className="absolute top-1/2 right-1 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
|
250
189
|
>
|
|
251
|
-
<HugeiconsIcon
|
|
252
|
-
icon={Cancel01Icon}
|
|
253
|
-
className="size-3"
|
|
254
|
-
/>
|
|
190
|
+
<HugeiconsIcon icon={Cancel01Icon} className="size-3" />
|
|
255
191
|
</IconButton>
|
|
256
192
|
)}
|
|
257
193
|
</div>
|
|
@@ -6,10 +6,7 @@ import {
|
|
|
6
6
|
ChevronLeftIcon,
|
|
7
7
|
ChevronRightIcon,
|
|
8
8
|
} from "@hugeicons/core-free-icons"
|
|
9
|
-
import type {
|
|
10
|
-
ReactTable,
|
|
11
|
-
RowData,
|
|
12
|
-
} from "@tanstack/react-table"
|
|
9
|
+
import type { ReactTable, RowData } from "@tanstack/react-table"
|
|
13
10
|
import { Picker } from "@passui/react"
|
|
14
11
|
import type { DataTableFeatures } from "./data-table"
|
|
15
12
|
|
|
@@ -28,8 +25,7 @@ export function DataTablePagination<TData extends RowData>({
|
|
|
28
25
|
return (
|
|
29
26
|
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
|
|
30
27
|
<p className="shrink-0 whitespace-nowrap text-footnote text-label-secondary">
|
|
31
|
-
Page {pageCount ? pageIndex + 1 : 0} of{
|
|
32
|
-
{pageCount}
|
|
28
|
+
Page {pageCount ? pageIndex + 1 : 0} of {pageCount}
|
|
33
29
|
</p>
|
|
34
30
|
|
|
35
31
|
<div className="flex items-center gap-1">
|
|
@@ -65,9 +61,7 @@ export function DataTablePagination<TData extends RowData>({
|
|
|
65
61
|
type="button"
|
|
66
62
|
size="icon-sm"
|
|
67
63
|
disabled={!table.getCanNextPage()}
|
|
68
|
-
onClick={() =>
|
|
69
|
-
table.setPageIndex(pageCount - 1)
|
|
70
|
-
}
|
|
64
|
+
onClick={() => table.setPageIndex(pageCount - 1)}
|
|
71
65
|
>
|
|
72
66
|
<HugeiconsIcon icon={ChevronLastIcon} />
|
|
73
67
|
</IconButton>
|
|
@@ -78,9 +72,7 @@ export function DataTablePagination<TData extends RowData>({
|
|
|
78
72
|
className="w-full"
|
|
79
73
|
label="Rows per page"
|
|
80
74
|
value={String(pageSize)}
|
|
81
|
-
onChange={(value) =>
|
|
82
|
-
table.setPageSize(Number(value))
|
|
83
|
-
}
|
|
75
|
+
onChange={(value) => table.setPageSize(Number(value))}
|
|
84
76
|
options={pageSizeOptions.map((size) => ({
|
|
85
77
|
value: String(size),
|
|
86
78
|
label: String(size),
|