@passui/tanstack 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +76 -2
- package/package.json +165 -5
- package/src/auth-shell/auth-shell.tsx +26 -0
- package/src/auth-shell/index.ts +1 -0
- package/src/document/compose-viewport.tsx +96 -0
- package/src/document/index.ts +1 -0
- package/src/form-fields/fields.tsx +192 -0
- package/src/form-fields/index.ts +2 -0
- package/src/form-fields/selection.tsx +149 -0
- package/src/form-fields/submit.tsx +40 -0
- package/src/forms/contexts.ts +8 -0
- package/src/forms/elements/form-alert.tsx +30 -0
- package/src/forms/elements/submit.tsx +1 -0
- package/src/forms/fields/avatar-picker.tsx +399 -0
- package/src/forms/fields/avatar.tsx +299 -0
- package/src/forms/fields/checkbox.tsx +1 -0
- package/src/forms/fields/index.ts +32 -0
- package/src/forms/fields/input.tsx +1 -0
- package/src/forms/fields/multiselect.tsx +1 -0
- package/src/forms/fields/otp.tsx +1 -0
- package/src/forms/fields/radio-card.tsx +1 -0
- package/src/forms/fields/switch.tsx +1 -0
- package/src/forms/fields/textarea.tsx +1 -0
- package/src/forms/index.ts +30 -0
- package/src/mutation/index.ts +1 -0
- package/src/mutation/use-app-mutation.ts +156 -0
- package/src/route-boundary/default-boundary.tsx +61 -0
- package/src/route-boundary/default-loader.tsx +19 -0
- package/src/route-boundary/index.ts +3 -0
- package/src/route-boundary/not-founder.tsx +50 -0
- package/src/settings/index.ts +1 -0
- package/src/settings/setting-list.tsx +252 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/optimistic.ts +7 -0
- package/src/shared/table.ts +30 -0
- package/src/solid/auth-shell/auth-shell.tsx +20 -0
- package/src/solid/auth-shell/index.ts +1 -0
- package/src/solid/document/compose-viewport.tsx +69 -0
- package/src/solid/document/index.ts +1 -0
- package/src/solid/form-fields/avatar.tsx +370 -0
- package/src/solid/form-fields/fields.tsx +336 -0
- package/src/solid/form-fields/index.ts +3 -0
- package/src/solid/form-fields/submit.tsx +31 -0
- package/src/solid/forms/contexts.ts +7 -0
- package/src/solid/forms/form-alert.tsx +19 -0
- package/src/solid/forms/index.ts +32 -0
- package/src/solid/mutation/index.ts +5 -0
- package/src/solid/mutation/use-app-mutation.ts +171 -0
- package/src/solid/route-boundary/boundaries.tsx +104 -0
- package/src/solid/route-boundary/index.ts +1 -0
- package/src/solid/settings/index.ts +1 -0
- package/src/solid/settings/setting-list.tsx +185 -0
- package/src/solid/styles.css +2 -0
- package/src/solid/tables/columns.tsx +40 -0
- package/src/solid/tables/data-table.tsx +448 -0
- package/src/solid/tables/filter-row.tsx +161 -0
- package/src/solid/tables/index.ts +4 -0
- package/src/solid/tables/pagination.tsx +78 -0
- package/src/styles.css +12 -0
- package/src/tables/columns.tsx +39 -0
- package/src/tables/data-table.tsx +617 -0
- package/src/tables/filter-row.tsx +260 -0
- package/src/tables/index.ts +3 -0
- package/src/tables/pagination.tsx +93 -0
- package/src/tables/utils.ts +5 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IconButton,
|
|
3
|
+
type IconButtonSize,
|
|
4
|
+
} from "@passui/react/icon-button"
|
|
5
|
+
import {
|
|
6
|
+
ArrowRight01Icon,
|
|
7
|
+
Copy01Icon,
|
|
8
|
+
Tick02Icon,
|
|
9
|
+
} from "@hugeicons/core-free-icons"
|
|
10
|
+
import { HugeiconsIcon } from "@hugeicons/react"
|
|
11
|
+
import { cn } from "@passui/react/cn"
|
|
12
|
+
import { Link } from "@tanstack/react-router"
|
|
13
|
+
import type { LinkProps } from "@tanstack/react-router"
|
|
14
|
+
import type { ReactNode } from "react"
|
|
15
|
+
import { useState } from "react"
|
|
16
|
+
|
|
17
|
+
type SettingListProps = {
|
|
18
|
+
id?: string
|
|
19
|
+
/** h3 when the list sits inside an Area that already has the h2. */
|
|
20
|
+
as?: "h2" | "h3"
|
|
21
|
+
/** A Glyph beside the heading; rows themselves stay plain. */
|
|
22
|
+
icon?: ReactNode
|
|
23
|
+
title?: string
|
|
24
|
+
description?: string
|
|
25
|
+
/** Right of the heading: an Add button, or a Coming soon badge. */
|
|
26
|
+
action?: ReactNode
|
|
27
|
+
/** "tile": the rounded, lifted card of the account app's overview. */
|
|
28
|
+
variant?: "inset" | "tile"
|
|
29
|
+
children: ReactNode
|
|
30
|
+
className?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type RowProps = {
|
|
34
|
+
icon?: ReactNode
|
|
35
|
+
title: ReactNode
|
|
36
|
+
description?: ReactNode
|
|
37
|
+
/** The current value, muted on the right, like "On" or an email. */
|
|
38
|
+
value?: ReactNode
|
|
39
|
+
trailing?: ReactNode
|
|
40
|
+
to?: LinkProps["to"]
|
|
41
|
+
params?: LinkProps["params"]
|
|
42
|
+
hash?: string
|
|
43
|
+
onClick?: () => void
|
|
44
|
+
/** Show the chevron without a destination, for a preview row. */
|
|
45
|
+
chevron?: boolean
|
|
46
|
+
tone?: "default" | "destructive"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A titled group of settings in one inset card, hairlines between rows
|
|
51
|
+
* (even rows wrapped in a Preview), a soft highlight under the one you point at.
|
|
52
|
+
*/
|
|
53
|
+
export function SettingList({
|
|
54
|
+
id,
|
|
55
|
+
as: Heading = "h2",
|
|
56
|
+
icon,
|
|
57
|
+
title,
|
|
58
|
+
description,
|
|
59
|
+
action,
|
|
60
|
+
variant = "inset",
|
|
61
|
+
children,
|
|
62
|
+
className,
|
|
63
|
+
}: SettingListProps) {
|
|
64
|
+
const lines = cn(
|
|
65
|
+
"[&>*+*]:border-t [&>*+*]:border-border/40",
|
|
66
|
+
"[&_.setting-row+.setting-row]:border-t [&_.setting-row+.setting-row]:border-border/40"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
// the account app's tile: the heading lives inside the card, on a tinted band
|
|
70
|
+
if (variant === "tile")
|
|
71
|
+
return (
|
|
72
|
+
<section
|
|
73
|
+
id={id}
|
|
74
|
+
className={cn(
|
|
75
|
+
"flex scroll-mt-24 flex-col overflow-hidden rounded-3xl border border-separator/70 bg-elevated shadow-sm",
|
|
76
|
+
className
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
{title && (
|
|
80
|
+
<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
|
+
{icon}
|
|
82
|
+
<div className="flex min-w-0 flex-1 flex-col">
|
|
83
|
+
<Heading className="text-base">
|
|
84
|
+
{title}
|
|
85
|
+
</Heading>
|
|
86
|
+
{description && (
|
|
87
|
+
<p className="text-[13px] text-muted-foreground">
|
|
88
|
+
{description}
|
|
89
|
+
</p>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
{action}
|
|
93
|
+
</div>
|
|
94
|
+
)}
|
|
95
|
+
<div
|
|
96
|
+
className={cn(
|
|
97
|
+
"flex flex-col py-1 [&_.setting-row]:min-h-16 [&_.setting-row]:px-4 sm:[&_.setting-row]:px-5 [&_.setting-row_h3]:text-subheadline [&_.setting-row_p]:text-footnote",
|
|
98
|
+
lines
|
|
99
|
+
)}
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</div>
|
|
103
|
+
</section>
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<section
|
|
108
|
+
id={id}
|
|
109
|
+
className={cn(
|
|
110
|
+
"flex scroll-mt-20 flex-col gap-3",
|
|
111
|
+
"[&>div:last-child]:rounded-2xl [&>div:last-child]:shadow-xs",
|
|
112
|
+
"[&>div:first-child_h2]:text-subheadline [&>div:first-child_h2]:font-semibold",
|
|
113
|
+
"[&>div:first-child_p]:text-footnote [&>div:first-child_p]:text-label-secondary",
|
|
114
|
+
"[&_.setting-row]:min-h-16 [&_.setting-row]:px-4 [&_.setting-row]:py-3",
|
|
115
|
+
"[&_.setting-row_h3]:whitespace-normal [&_.setting-row_h3]:wrap-anywhere [&_.setting-row_h3]:text-subheadline",
|
|
116
|
+
"[&_.setting-row_p]:wrap-anywhere [&_.setting-row_p]:text-footnote [&_.setting-row_p]:text-label-secondary",
|
|
117
|
+
"[&_.setting-row>span]:whitespace-normal [&_.setting-row>span]:wrap-anywhere",
|
|
118
|
+
className
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{title && (
|
|
122
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
123
|
+
<div className="flex min-w-0 flex-1 items-start gap-3">
|
|
124
|
+
{icon}
|
|
125
|
+
<div className="min-w-0 wrap-anywhere">
|
|
126
|
+
<Heading>{title}</Heading>
|
|
127
|
+
{description && (
|
|
128
|
+
<p className="text-sm">
|
|
129
|
+
{description}
|
|
130
|
+
</p>
|
|
131
|
+
)}
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
{action}
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
<div
|
|
138
|
+
className={cn(
|
|
139
|
+
"flex flex-col overflow-hidden rounded-xl border border-border/35 bg-card shadow-xs",
|
|
140
|
+
lines
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</div>
|
|
145
|
+
</section>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function Row({
|
|
150
|
+
icon,
|
|
151
|
+
title,
|
|
152
|
+
description,
|
|
153
|
+
value,
|
|
154
|
+
trailing,
|
|
155
|
+
to,
|
|
156
|
+
params,
|
|
157
|
+
hash,
|
|
158
|
+
onClick,
|
|
159
|
+
chevron,
|
|
160
|
+
tone = "default",
|
|
161
|
+
}: RowProps) {
|
|
162
|
+
const interactive = Boolean(to || onClick)
|
|
163
|
+
const className = cn(
|
|
164
|
+
"setting-row flex min-h-10 w-full items-center gap-3 px-3.5 py-1.5 text-left",
|
|
165
|
+
interactive &&
|
|
166
|
+
"cursor-pointer transition-colors hover:bg-foreground/[0.035] focus-visible:bg-foreground/[0.05] focus-visible:outline-none",
|
|
167
|
+
tone === "destructive" && "[&_h3]:text-destructive"
|
|
168
|
+
)
|
|
169
|
+
const body = (
|
|
170
|
+
<>
|
|
171
|
+
{icon}
|
|
172
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
173
|
+
<h3 className="truncate text-sm">{title}</h3>
|
|
174
|
+
{description && (
|
|
175
|
+
<p className="text-xs">{description}</p>
|
|
176
|
+
)}
|
|
177
|
+
</span>
|
|
178
|
+
{value && (
|
|
179
|
+
<span className="max-w-[45%] truncate text-sm text-muted-foreground">
|
|
180
|
+
{value}
|
|
181
|
+
</span>
|
|
182
|
+
)}
|
|
183
|
+
{trailing}
|
|
184
|
+
{(chevron ?? interactive) && (
|
|
185
|
+
<HugeiconsIcon
|
|
186
|
+
icon={ArrowRight01Icon}
|
|
187
|
+
className="size-4 shrink-0 text-muted-foreground/60"
|
|
188
|
+
/>
|
|
189
|
+
)}
|
|
190
|
+
</>
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
if (to) {
|
|
194
|
+
return (
|
|
195
|
+
<Link
|
|
196
|
+
to={to}
|
|
197
|
+
params={params}
|
|
198
|
+
hash={hash}
|
|
199
|
+
className={className}
|
|
200
|
+
>
|
|
201
|
+
{body}
|
|
202
|
+
</Link>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
if (onClick) {
|
|
206
|
+
return (
|
|
207
|
+
<button
|
|
208
|
+
type="button"
|
|
209
|
+
onClick={onClick}
|
|
210
|
+
className={className}
|
|
211
|
+
>
|
|
212
|
+
{body}
|
|
213
|
+
</button>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
return <div className={className}>{body}</div>
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** A row's trailing copy button; shows a tick for a moment after copying. */
|
|
220
|
+
function Copy({
|
|
221
|
+
value,
|
|
222
|
+
label = "Copy",
|
|
223
|
+
size = "icon-xs",
|
|
224
|
+
}: {
|
|
225
|
+
value: string
|
|
226
|
+
label?: string
|
|
227
|
+
/** Quiet and row-sized by default; any of Passui's icon sizes. */
|
|
228
|
+
size?: IconButtonSize
|
|
229
|
+
}) {
|
|
230
|
+
const [copied, setCopied] = useState(false)
|
|
231
|
+
return (
|
|
232
|
+
<IconButton
|
|
233
|
+
variant="ghost"
|
|
234
|
+
size={size}
|
|
235
|
+
label={label}
|
|
236
|
+
onClick={async (event) => {
|
|
237
|
+
event.stopPropagation()
|
|
238
|
+
await navigator.clipboard.writeText(value)
|
|
239
|
+
setCopied(true)
|
|
240
|
+
setTimeout(() => setCopied(false), 1500)
|
|
241
|
+
}}
|
|
242
|
+
>
|
|
243
|
+
<HugeiconsIcon
|
|
244
|
+
icon={copied ? Tick02Icon : Copy01Icon}
|
|
245
|
+
className="size-4"
|
|
246
|
+
/>
|
|
247
|
+
</IconButton>
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
SettingList.Row = Row
|
|
252
|
+
SettingList.Copy = Copy
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function isArrayValuedColumn<TData>(
|
|
2
|
+
data: TData[],
|
|
3
|
+
colId: string
|
|
4
|
+
): boolean {
|
|
5
|
+
return data.some((row) =>
|
|
6
|
+
Array.isArray((row as Record<string, unknown>)[colId])
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
export function getColumnLabel(column: {
|
|
10
|
+
columnDef: { header?: unknown }
|
|
11
|
+
id: string
|
|
12
|
+
}) {
|
|
13
|
+
const header = column.columnDef.header
|
|
14
|
+
return typeof header === "string"
|
|
15
|
+
? header
|
|
16
|
+
: column.id
|
|
17
|
+
.replace(/([A-Z])/g, " $1")
|
|
18
|
+
.replace(/^./, (value) => value.toUpperCase())
|
|
19
|
+
}
|
|
20
|
+
export function columnIdOf(column: {
|
|
21
|
+
id?: string
|
|
22
|
+
accessorKey?: unknown
|
|
23
|
+
}): string | undefined {
|
|
24
|
+
return (
|
|
25
|
+
column.id ||
|
|
26
|
+
(typeof column.accessorKey === "string"
|
|
27
|
+
? column.accessorKey
|
|
28
|
+
: undefined)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @jsxImportSource solid-js */
|
|
2
|
+
import { Outlet, useLocation } from "@tanstack/solid-router"
|
|
3
|
+
import { Show, type JSX } from "solid-js"
|
|
4
|
+
export function AuthShell(props: { brand: JSX.Element }) {
|
|
5
|
+
const location = useLocation()
|
|
6
|
+
return (
|
|
7
|
+
<section class="relative isolate flex min-h-dvh flex-col items-center justify-center px-4 py-12">
|
|
8
|
+
<div class="flex w-full max-w-[26rem] flex-col items-start gap-6">
|
|
9
|
+
{props.brand}
|
|
10
|
+
<Show when={location().pathname} keyed>
|
|
11
|
+
{(_pathname) => (
|
|
12
|
+
<div class="w-full motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-right-4 motion-safe:duration-500">
|
|
13
|
+
<Outlet />
|
|
14
|
+
</div>
|
|
15
|
+
)}
|
|
16
|
+
</Show>
|
|
17
|
+
</div>
|
|
18
|
+
</section>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth-shell"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** @jsxImportSource solid-js */
|
|
2
|
+
import { splitProps, type JSX } from "solid-js"
|
|
3
|
+
import { HydrationScript } from "solid-js/web"
|
|
4
|
+
import { cn } from "@passui/solid/cn"
|
|
5
|
+
function Window(
|
|
6
|
+
props: JSX.HTMLAttributes<HTMLBodyElement> & {
|
|
7
|
+
after?: JSX.Element
|
|
8
|
+
before?: JSX.Element
|
|
9
|
+
className?: string
|
|
10
|
+
}
|
|
11
|
+
) {
|
|
12
|
+
const [local, rest] = splitProps(props, [
|
|
13
|
+
"children",
|
|
14
|
+
"after",
|
|
15
|
+
"before",
|
|
16
|
+
"class",
|
|
17
|
+
"className",
|
|
18
|
+
])
|
|
19
|
+
return (
|
|
20
|
+
<body
|
|
21
|
+
{...rest}
|
|
22
|
+
class={cn(
|
|
23
|
+
"fixed h-svh w-full min-w-full bg-background overflow-x-hidden typeset wrap-anywhere flex flex-col",
|
|
24
|
+
local.class,
|
|
25
|
+
local.className
|
|
26
|
+
)}
|
|
27
|
+
>
|
|
28
|
+
{local.before}
|
|
29
|
+
<main class="flex flex-1 flex-col min-h-svh overflow-auto no-scrollbar">
|
|
30
|
+
{local.children}
|
|
31
|
+
</main>
|
|
32
|
+
{local.after}
|
|
33
|
+
</body>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
export const ComposeViewport = Object.assign(
|
|
37
|
+
function ComposeViewport(
|
|
38
|
+
props: JSX.IntrinsicElements["html"] & {
|
|
39
|
+
className?: string
|
|
40
|
+
head?: JSX.Element
|
|
41
|
+
}
|
|
42
|
+
) {
|
|
43
|
+
const [local, rest] = splitProps(props, [
|
|
44
|
+
"class",
|
|
45
|
+
"className",
|
|
46
|
+
"lang",
|
|
47
|
+
"head",
|
|
48
|
+
"children",
|
|
49
|
+
])
|
|
50
|
+
return (
|
|
51
|
+
<html
|
|
52
|
+
{...rest}
|
|
53
|
+
lang={local.lang ?? "en"}
|
|
54
|
+
class={cn(
|
|
55
|
+
"antialiased blur-none",
|
|
56
|
+
local.class,
|
|
57
|
+
local.className
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
<head>
|
|
61
|
+
<HydrationScript />
|
|
62
|
+
{local.head}
|
|
63
|
+
</head>
|
|
64
|
+
{local.children}
|
|
65
|
+
</html>
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
{ Window }
|
|
69
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./compose-viewport"
|