@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.
- package/dist/{types/src/auth-shell → auth-shell}/auth-shell.d.ts +3 -3
- package/dist/auth-shell/auth-shell.js +17 -0
- package/dist/auth-shell.d.ts +2 -0
- package/dist/auth-shell.js +1 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +3 -0
- package/dist/{types/src/document → document}/compose-viewport.d.ts +11 -11
- package/dist/document/compose-viewport.js +43 -0
- package/dist/document.d.ts +2 -0
- package/dist/document.js +1 -0
- package/dist/form-fields/fields.d.ts +30 -0
- package/dist/form-fields/fields.js +160 -0
- package/dist/form-fields/selection.d.ts +21 -0
- package/dist/form-fields/selection.js +73 -0
- package/dist/form-fields/submit.d.ts +3 -0
- package/dist/form-fields/submit.js +26 -0
- package/dist/form-fields.d.ts +7 -0
- package/dist/form-fields.js +7 -0
- package/dist/forms/contexts.js +4 -0
- package/dist/{types/src/forms → forms}/elements/form-alert.d.ts +4 -4
- package/dist/forms/elements/form-alert.js +19 -0
- package/dist/forms/fields/avatar-picker.d.ts +10 -0
- package/dist/forms/fields/avatar-picker.js +228 -0
- package/dist/forms/fields/avatar.d.ts +30 -0
- package/dist/forms/fields/avatar.js +188 -0
- package/dist/forms/fields/checkbox.d.ts +2 -0
- package/dist/forms/fields/index.d.ts +21 -0
- package/dist/forms/fields/index.js +15 -0
- package/dist/forms/fields/input.d.ts +2 -0
- package/dist/forms/fields/multiselect.d.ts +2 -0
- package/dist/forms/fields/otp.d.ts +2 -0
- package/dist/forms/fields/radio-card.d.ts +2 -0
- package/dist/forms/fields/switch.d.ts +2 -0
- package/dist/forms/fields/textarea.d.ts +2 -0
- package/dist/forms.d.ts +45 -0
- package/dist/forms.js +16 -0
- package/dist/mutation/use-app-mutation.d.ts +23 -0
- package/dist/mutation/use-app-mutation.js +41 -0
- package/dist/mutation.d.ts +3 -0
- package/dist/mutation.js +3 -0
- package/dist/route-boundary/default-boundary.d.ts +2 -0
- package/dist/route-boundary/default-boundary.js +40 -0
- package/dist/route-boundary/default-loader.d.ts +6 -0
- package/dist/route-boundary/default-loader.js +17 -0
- package/dist/{types/src/route-boundary → route-boundary}/not-founder.d.ts +2 -2
- package/dist/route-boundary/not-founder.js +44 -0
- package/dist/route-boundary.d.ts +4 -0
- package/dist/route-boundary.js +4 -0
- package/dist/settings/setting-list.d.ts +51 -0
- package/dist/settings/setting-list.js +122 -0
- package/dist/settings.d.ts +2 -0
- package/dist/settings.js +1 -0
- package/dist/{types/src/shared → shared}/optimistic.d.ts +2 -2
- package/dist/shared/optimistic.js +16 -0
- package/dist/{types/src/shared → shared}/table.d.ts +7 -7
- package/dist/shared/table.js +12 -0
- package/dist/tables/columns.d.ts +3 -0
- package/dist/tables/columns.js +21 -0
- package/dist/tables/data-table.d.ts +76 -0
- package/dist/tables/data-table.js +307 -0
- package/dist/tables/filter-row.js +137 -0
- package/dist/tables/pagination.d.ts +8 -0
- package/dist/tables/pagination.js +86 -0
- package/dist/tables.d.ts +4 -0
- package/dist/tables.js +4 -0
- package/package.json +129 -128
- package/src/styles.css +1 -0
- package/dist/types/src/auth-shell/index.d.ts +0 -1
- package/dist/types/src/document/index.d.ts +0 -1
- package/dist/types/src/form-fields/fields.d.ts +0 -24
- package/dist/types/src/form-fields/index.d.ts +0 -2
- package/dist/types/src/form-fields/selection.d.ts +0 -21
- package/dist/types/src/form-fields/submit.d.ts +0 -3
- package/dist/types/src/forms/contexts.d.ts +0 -1
- package/dist/types/src/forms/elements/submit.d.ts +0 -1
- package/dist/types/src/forms/fields/avatar-picker.d.ts +0 -30
- package/dist/types/src/forms/fields/avatar.d.ts +0 -30
- package/dist/types/src/forms/fields/checkbox.d.ts +0 -1
- package/dist/types/src/forms/fields/index.d.ts +0 -21
- package/dist/types/src/forms/fields/input.d.ts +0 -1
- package/dist/types/src/forms/fields/multiselect.d.ts +0 -1
- package/dist/types/src/forms/fields/otp.d.ts +0 -1
- package/dist/types/src/forms/fields/radio-card.d.ts +0 -1
- package/dist/types/src/forms/fields/switch.d.ts +0 -1
- package/dist/types/src/forms/fields/textarea.d.ts +0 -1
- package/dist/types/src/forms/index.d.ts +0 -41
- package/dist/types/src/mutation/index.d.ts +0 -1
- package/dist/types/src/mutation/use-app-mutation.d.ts +0 -22
- package/dist/types/src/route-boundary/default-boundary.d.ts +0 -2
- package/dist/types/src/route-boundary/default-loader.d.ts +0 -6
- package/dist/types/src/route-boundary/index.d.ts +0 -3
- package/dist/types/src/settings/index.d.ts +0 -1
- package/dist/types/src/settings/setting-list.d.ts +0 -51
- package/dist/types/src/shared/index.d.ts +0 -2
- package/dist/types/src/tables/columns.d.ts +0 -3
- package/dist/types/src/tables/data-table.d.ts +0 -76
- package/dist/types/src/tables/filter-row.d.ts +0 -9
- package/dist/types/src/tables/index.d.ts +0 -3
- package/dist/types/src/tables/pagination.d.ts +0 -8
- package/dist/types/src/tables/utils.d.ts +0 -1
- package/src/auth-shell/auth-shell.tsx +0 -16
- package/src/auth-shell/index.ts +0 -1
- package/src/document/compose-viewport.tsx +0 -80
- package/src/document/index.ts +0 -1
- package/src/form-fields/fields.tsx +0 -147
- package/src/form-fields/index.ts +0 -2
- package/src/form-fields/selection.tsx +0 -109
- package/src/form-fields/submit.tsx +0 -35
- package/src/forms/contexts.ts +0 -4
- package/src/forms/elements/form-alert.tsx +0 -21
- package/src/forms/elements/submit.tsx +0 -1
- package/src/forms/fields/avatar-picker.tsx +0 -319
- package/src/forms/fields/avatar.tsx +0 -269
- package/src/forms/fields/checkbox.tsx +0 -1
- package/src/forms/fields/index.ts +0 -29
- package/src/forms/fields/input.tsx +0 -1
- package/src/forms/fields/multiselect.tsx +0 -1
- package/src/forms/fields/otp.tsx +0 -1
- package/src/forms/fields/radio-card.tsx +0 -1
- package/src/forms/fields/switch.tsx +0 -1
- package/src/forms/fields/textarea.tsx +0 -1
- package/src/forms/index.ts +0 -26
- package/src/mutation/index.ts +0 -1
- package/src/mutation/use-app-mutation.ts +0 -100
- package/src/route-boundary/default-boundary.tsx +0 -46
- package/src/route-boundary/default-loader.tsx +0 -23
- package/src/route-boundary/index.ts +0 -3
- package/src/route-boundary/not-founder.tsx +0 -39
- package/src/settings/index.ts +0 -1
- package/src/settings/setting-list.tsx +0 -221
- package/src/shared/index.ts +0 -2
- package/src/shared/optimistic.ts +0 -19
- package/src/shared/table.ts +0 -12
- package/src/tables/columns.tsx +0 -30
- package/src/tables/data-table.tsx +0 -522
- package/src/tables/filter-row.tsx +0 -196
- package/src/tables/index.ts +0 -3
- package/src/tables/pagination.tsx +0 -85
- package/src/tables/utils.ts +0 -5
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Button, buttonVariants } from "@passui/react/button";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@passui/react/cn";
|
|
4
|
+
import { ErrorComponent, Link, useLocation, useRouter } from "@tanstack/react-router";
|
|
5
|
+
// src/route-boundary/default-boundary.tsx
|
|
6
|
+
function DefaultBoundary({ error }) {
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
const isRoot = useLocation({ select: (location) => location.pathname === "/" });
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: "flex min-h-100 w-full flex-col items-center justify-center gap-6 p-6 text-center",
|
|
11
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
12
|
+
className: "border-destructive/20 bg-destructive/5 w-full max-w-md overflow-hidden rounded-md border p-4 text-left",
|
|
13
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
14
|
+
className: "text-caption text-destructive mb-2 font-semibold tracking-wider uppercase",
|
|
15
|
+
children: "Application Error"
|
|
16
|
+
}), /* @__PURE__ */ jsx(ErrorComponent, { error })]
|
|
17
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: "flex flex-wrap items-center justify-center gap-2",
|
|
19
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
20
|
+
onClick: () => router.invalidate(),
|
|
21
|
+
variant: "secondary",
|
|
22
|
+
size: "sm",
|
|
23
|
+
children: "Try Again"
|
|
24
|
+
}), isRoot ? /* @__PURE__ */ jsx(Link, {
|
|
25
|
+
to: "/",
|
|
26
|
+
className: cn(buttonVariants({
|
|
27
|
+
variant: "default",
|
|
28
|
+
size: "sm"
|
|
29
|
+
})),
|
|
30
|
+
children: "Go Home"
|
|
31
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
32
|
+
onClick: () => router.history.back(),
|
|
33
|
+
variant: "default",
|
|
34
|
+
size: "sm",
|
|
35
|
+
children: "Go Back"
|
|
36
|
+
})]
|
|
37
|
+
})]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export { DefaultBoundary };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type DefaultLoaderProps = {
|
|
2
|
+
/** Translated loading status for assistive technology; never displayed visually. */
|
|
3
|
+
label?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function DefaultLoader({ label, className }?: DefaultLoaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Spinner } from "@passui/react/spinner";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@passui/react/cn";
|
|
4
|
+
// src/route-boundary/default-loader.tsx
|
|
5
|
+
function DefaultLoader({ label, className } = {}) {
|
|
6
|
+
return /* @__PURE__ */ jsx("section", {
|
|
7
|
+
role: "status",
|
|
8
|
+
"aria-label": label,
|
|
9
|
+
className: cn("flex min-h-80 flex-1 items-center justify-center p-6", className),
|
|
10
|
+
children: /* @__PURE__ */ jsx(Spinner, {
|
|
11
|
+
className: "size-6",
|
|
12
|
+
role: "presentation",
|
|
13
|
+
"aria-hidden": "true"
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { DefaultLoader };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Button, buttonVariants } from "@passui/react/button";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@passui/react/cn";
|
|
4
|
+
import { Link, useRouter } from "@tanstack/react-router";
|
|
5
|
+
// src/route-boundary/not-founder.tsx
|
|
6
|
+
function NotFound({ children }) {
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
return /* @__PURE__ */ jsx("div", {
|
|
9
|
+
className: "flex min-h-[80svh] w-full flex-col items-center justify-center text-center",
|
|
10
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
11
|
+
className: "mx-auto flex w-full max-w-sm flex-col items-center justify-center gap-4",
|
|
12
|
+
children: [children ?? /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "flex flex-col items-center gap-2",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx("span", {
|
|
16
|
+
className: "text-caption text-destructive font-mono font-semibold tracking-widest uppercase",
|
|
17
|
+
children: "Error 404"
|
|
18
|
+
}),
|
|
19
|
+
/* @__PURE__ */ jsx("h2", {
|
|
20
|
+
className: "text-foreground text-2xl font-bold tracking-tight",
|
|
21
|
+
children: "Page Not Found"
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ jsx("p", {
|
|
24
|
+
className: "text-subheadline text-muted-foreground max-w-70",
|
|
25
|
+
children: "The page you are looking for might have been moved, renamed, or deleted."
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: "mt-2 flex items-center gap-2",
|
|
30
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
31
|
+
onClick: () => router.history.back(),
|
|
32
|
+
variant: "secondary",
|
|
33
|
+
size: "sm",
|
|
34
|
+
children: "Go back"
|
|
35
|
+
}), /* @__PURE__ */ jsx(Link, {
|
|
36
|
+
to: "/",
|
|
37
|
+
className: cn(buttonVariants({ size: "sm" })),
|
|
38
|
+
children: "Start Over"
|
|
39
|
+
})]
|
|
40
|
+
})]
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export { NotFound };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DefaultBoundary } from "./route-boundary/default-boundary.js";
|
|
2
|
+
import { DefaultLoader, DefaultLoaderProps } from "./route-boundary/default-loader.js";
|
|
3
|
+
import { NotFound } from "./route-boundary/not-founder.js";
|
|
4
|
+
export { DefaultBoundary, DefaultLoader, DefaultLoaderProps, NotFound };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ButtonSize } from "@passui/react/button";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { LinkProps } from "@tanstack/react-router";
|
|
4
|
+
type SettingListProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
/** h3 when the list sits inside an Area that already has the h2. */
|
|
7
|
+
as?: "h2" | "h3";
|
|
8
|
+
/** A Glyph beside the heading; rows themselves stay plain. */
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Right of the heading: an Add button, or a Coming soon badge. */
|
|
13
|
+
action?: ReactNode;
|
|
14
|
+
/** "tile": the rounded, lifted card of the account app's overview. */
|
|
15
|
+
variant?: "inset" | "tile";
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
type RowProps = {
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
title: ReactNode;
|
|
22
|
+
description?: ReactNode;
|
|
23
|
+
/** The current value, muted on the right, like "On" or an email. */
|
|
24
|
+
value?: ReactNode;
|
|
25
|
+
trailing?: ReactNode;
|
|
26
|
+
to?: LinkProps["to"];
|
|
27
|
+
params?: LinkProps["params"];
|
|
28
|
+
hash?: string;
|
|
29
|
+
onClick?: () => void;
|
|
30
|
+
/** Show the chevron without a destination, for a preview row. */
|
|
31
|
+
chevron?: boolean;
|
|
32
|
+
tone?: "default" | "destructive";
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A titled group of settings in one inset card, hairlines between rows
|
|
36
|
+
* (even rows wrapped in a Preview), a soft highlight under the one you point at.
|
|
37
|
+
*/
|
|
38
|
+
export declare function SettingList({ id, as: Heading, icon, title, description, action, variant, children, className }: SettingListProps): import("react").JSX.Element;
|
|
39
|
+
export declare namespace SettingList {
|
|
40
|
+
export { Row };
|
|
41
|
+
export { Copy };
|
|
42
|
+
}
|
|
43
|
+
declare function Row({ icon, title, description, value, trailing, to, params, hash, onClick, chevron, tone }: RowProps): import("react").JSX.Element;
|
|
44
|
+
/** A row's trailing copy button; shows a tick for a moment after copying. */
|
|
45
|
+
declare function Copy({ value, label, size }: {
|
|
46
|
+
value: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
/** Quiet and row-sized by default; any of Passui's icon sizes. */
|
|
49
|
+
size?: ButtonSize;
|
|
50
|
+
}): import("react").JSX.Element;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cn } from "@passui/react/cn";
|
|
5
|
+
import { ChevronRightIcon } from "@passui/icons/chevron-right";
|
|
6
|
+
import { Link } from "@tanstack/react-router";
|
|
7
|
+
import { CheckIcon } from "@passui/icons/check";
|
|
8
|
+
import { CopyIcon } from "@passui/icons/copy";
|
|
9
|
+
// src/settings/setting-list.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A titled group of settings in one inset card, hairlines between rows
|
|
12
|
+
* (even rows wrapped in a Preview), a soft highlight under the one you point at.
|
|
13
|
+
*/
|
|
14
|
+
function SettingList({ id, as: Heading = "h2", icon, title, description, action, variant = "inset", children, className }) {
|
|
15
|
+
const lines = cn("[&>*+*]:border-border/40 [&>*+*]:border-t", "[&_.setting-row+.setting-row]:border-border/40 [&_.setting-row+.setting-row]:border-t");
|
|
16
|
+
if (variant === "tile") return /* @__PURE__ */ jsxs("section", {
|
|
17
|
+
id,
|
|
18
|
+
className: cn("border-separator/70 bg-elevated flex scroll-mt-24 flex-col overflow-hidden rounded-3xl border shadow-sm", className),
|
|
19
|
+
children: [title && /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "border-separator/60 flex items-center gap-3 border-b px-4 py-4 sm:px-5 [&>span:first-child]:size-9 [&>span:first-child_.glyph]:size-4",
|
|
21
|
+
children: [
|
|
22
|
+
icon,
|
|
23
|
+
/* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
25
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
26
|
+
className: "text-callout",
|
|
27
|
+
children: title
|
|
28
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
29
|
+
className: "text-footnote text-muted-foreground",
|
|
30
|
+
children: description
|
|
31
|
+
})]
|
|
32
|
+
}),
|
|
33
|
+
action
|
|
34
|
+
]
|
|
35
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: cn("[&_.setting-row_h3]:text-subheadline [&_.setting-row_p]:text-footnote flex flex-col py-1 [&_.setting-row]:min-h-16 [&_.setting-row]:px-4 sm:[&_.setting-row]:px-5", lines),
|
|
37
|
+
children
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
41
|
+
id,
|
|
42
|
+
className: cn("flex scroll-mt-20 flex-col gap-3", "[&>div:last-child]:rounded-2xl [&>div:last-child]:shadow-xs", "[&>div:first-child_h2]:text-subheadline [&>div:first-child_h2]:font-semibold", "[&>div:first-child_p]:text-footnote [&>div:first-child_p]:text-label-secondary", "[&_.setting-row]:min-h-16 [&_.setting-row]:px-4 [&_.setting-row]:py-3", "[&_.setting-row_h3]:text-subheadline [&_.setting-row_h3]:wrap-anywhere [&_.setting-row_h3]:whitespace-normal", "[&_.setting-row_p]:text-footnote [&_.setting-row_p]:text-label-secondary [&_.setting-row_p]:wrap-anywhere", "[&_.setting-row>span]:wrap-anywhere [&_.setting-row>span]:whitespace-normal", className),
|
|
43
|
+
children: [title && /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: "flex flex-wrap items-start justify-between gap-3",
|
|
45
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: "flex min-w-0 flex-1 items-start gap-3",
|
|
47
|
+
children: [icon, /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
className: "min-w-0 wrap-anywhere",
|
|
49
|
+
children: [/* @__PURE__ */ jsx(Heading, { children: title }), description && /* @__PURE__ */ jsx("p", {
|
|
50
|
+
className: "text-subheadline",
|
|
51
|
+
children: description
|
|
52
|
+
})]
|
|
53
|
+
})]
|
|
54
|
+
}), action]
|
|
55
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: cn("border-border/35 bg-card flex flex-col overflow-hidden rounded-xl border shadow-xs", lines),
|
|
57
|
+
children
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function Row({ icon, title, description, value, trailing, to, params, hash, onClick, chevron, tone = "default" }) {
|
|
62
|
+
const interactive = Boolean(to || onClick);
|
|
63
|
+
const className = cn("setting-row flex min-h-10 w-full items-center gap-3 px-3.5 py-1.5 text-left", interactive && "hover:bg-foreground/[0.035] focus-visible:bg-foreground/[0.05] cursor-pointer transition-colors focus-visible:outline-none", tone === "destructive" && "[&_h3]:text-destructive");
|
|
64
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
+
icon,
|
|
66
|
+
/* @__PURE__ */ jsxs("span", {
|
|
67
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
68
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
69
|
+
className: "text-subheadline truncate",
|
|
70
|
+
children: title
|
|
71
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
72
|
+
className: "text-caption",
|
|
73
|
+
children: description
|
|
74
|
+
})]
|
|
75
|
+
}),
|
|
76
|
+
value && /* @__PURE__ */ jsx("span", {
|
|
77
|
+
className: "text-subheadline text-muted-foreground max-w-[45%] truncate",
|
|
78
|
+
children: value
|
|
79
|
+
}),
|
|
80
|
+
trailing,
|
|
81
|
+
(chevron ?? interactive) && /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
82
|
+
size: 16,
|
|
83
|
+
className: "text-label-tertiary shrink-0"
|
|
84
|
+
})
|
|
85
|
+
] });
|
|
86
|
+
if (to) return /* @__PURE__ */ jsx(Link, {
|
|
87
|
+
to,
|
|
88
|
+
params,
|
|
89
|
+
hash,
|
|
90
|
+
className,
|
|
91
|
+
children: body
|
|
92
|
+
});
|
|
93
|
+
if (onClick) return /* @__PURE__ */ jsx("button", {
|
|
94
|
+
type: "button",
|
|
95
|
+
onClick,
|
|
96
|
+
className,
|
|
97
|
+
children: body
|
|
98
|
+
});
|
|
99
|
+
return /* @__PURE__ */ jsx("div", {
|
|
100
|
+
className,
|
|
101
|
+
children: body
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** A row's trailing copy button; shows a tick for a moment after copying. */
|
|
105
|
+
function Copy({ value, label = "Copy", size = "icon-xs" }) {
|
|
106
|
+
const [copied, setCopied] = useState(false);
|
|
107
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
108
|
+
variant: "ghost",
|
|
109
|
+
size,
|
|
110
|
+
"aria-label": label,
|
|
111
|
+
onClick: async (event) => {
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
await navigator.clipboard.writeText(value);
|
|
114
|
+
setCopied(true);
|
|
115
|
+
setTimeout(() => setCopied(false), 1500);
|
|
116
|
+
},
|
|
117
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 16 }) : /* @__PURE__ */ jsx(CopyIcon, { size: 16 })
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
SettingList.Row = Row;
|
|
121
|
+
SettingList.Copy = Copy;
|
|
122
|
+
export { SettingList };
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SettingList } from "./settings/setting-list.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { QueryClient, QueryKey } from "@tanstack/react-query";
|
|
2
2
|
/** Restore only the snapshot this mutation wrote, preserving newer concurrent writes. */
|
|
3
3
|
export declare function shouldRestoreOptimisticSnapshot<T>(current: T | undefined, expected: T): boolean;
|
|
4
4
|
/** Remove a new optimistic cache entry when no cache value existed before the mutation. */
|
|
5
|
-
export declare function restoreOptimisticSnapshot<T>(client: Pick<QueryClient, "getQueryData" | "setQueryData" | "removeQueries">, queryKey: QueryKey, previous: T | undefined, expected: T): boolean;
|
|
5
|
+
export declare function restoreOptimisticSnapshot<T>(client: Pick<QueryClient, "getQueryData" | "setQueryData" | "removeQueries">, queryKey: QueryKey, previous: T | undefined, expected: T): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/shared/optimistic.ts
|
|
2
|
+
/** Restore only the snapshot this mutation wrote, preserving newer concurrent writes. */
|
|
3
|
+
function shouldRestoreOptimisticSnapshot(current, expected) {
|
|
4
|
+
return current === expected;
|
|
5
|
+
}
|
|
6
|
+
/** Remove a new optimistic cache entry when no cache value existed before the mutation. */
|
|
7
|
+
function restoreOptimisticSnapshot(client, queryKey, previous, expected) {
|
|
8
|
+
if (!shouldRestoreOptimisticSnapshot(client.getQueryData(queryKey), expected)) return false;
|
|
9
|
+
if (previous === void 0) client.removeQueries({
|
|
10
|
+
queryKey,
|
|
11
|
+
exact: true
|
|
12
|
+
});
|
|
13
|
+
else client.setQueryData(queryKey, previous);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
export { restoreOptimisticSnapshot, shouldRestoreOptimisticSnapshot };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare function isArrayValuedColumn<TData>(data: TData[], colId: string): boolean;
|
|
2
2
|
export declare function getColumnLabel(column: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
columnDef: {
|
|
4
|
+
header?: unknown;
|
|
5
|
+
};
|
|
6
|
+
id: string;
|
|
7
7
|
}): string;
|
|
8
8
|
export declare function columnIdOf(column: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}): string | undefined;
|
|
9
|
+
id?: string;
|
|
10
|
+
accessorKey?: unknown;
|
|
11
|
+
}): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/shared/table.ts
|
|
2
|
+
function isArrayValuedColumn(data, colId) {
|
|
3
|
+
return data.some((row) => Array.isArray(row[colId]));
|
|
4
|
+
}
|
|
5
|
+
function getColumnLabel(column) {
|
|
6
|
+
const header = column.columnDef.header;
|
|
7
|
+
return typeof header === "string" ? header : column.id.replace(/([A-Z])/g, " $1").replace(/^./, (value) => value.toUpperCase());
|
|
8
|
+
}
|
|
9
|
+
function columnIdOf(column) {
|
|
10
|
+
return column.id || (typeof column.accessorKey === "string" ? column.accessorKey : void 0);
|
|
11
|
+
}
|
|
12
|
+
export { columnIdOf, getColumnLabel, isArrayValuedColumn };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from "@passui/react/checkbox";
|
|
3
|
+
// src/tables/columns.tsx
|
|
4
|
+
function selectColumn() {
|
|
5
|
+
return {
|
|
6
|
+
id: "select",
|
|
7
|
+
enableColumnFilter: false,
|
|
8
|
+
enableGlobalFilter: false,
|
|
9
|
+
header: ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
10
|
+
"aria-label": "Select all",
|
|
11
|
+
checked: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
|
|
12
|
+
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked === true)
|
|
13
|
+
}),
|
|
14
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
15
|
+
"aria-label": "Select row",
|
|
16
|
+
checked: row.getIsSelected(),
|
|
17
|
+
onCheckedChange: (checked) => row.toggleSelected(checked === true)
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export { selectColumn };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ColumnDef, ColumnVisibilityState, RowData } from "@tanstack/react-table";
|
|
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 {};
|