@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
/** Auth routes share a stable frame; pages own their transitions. */
|
|
3
3
|
export declare function AuthShell({ brand }: {
|
|
4
|
-
|
|
5
|
-
}): import("react").JSX.Element;
|
|
4
|
+
brand: ReactNode;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Outlet } from "@tanstack/react-router";
|
|
3
|
+
// src/auth-shell/auth-shell.tsx
|
|
4
|
+
/** Auth routes share a stable frame; pages own their transitions. */
|
|
5
|
+
function AuthShell({ brand }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("section", {
|
|
7
|
+
className: "relative isolate flex min-h-dvh flex-col items-center justify-center-safe px-4 py-12",
|
|
8
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
9
|
+
className: "flex w-full max-w-[26rem] flex-col items-start gap-6",
|
|
10
|
+
children: [brand, /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "w-full",
|
|
12
|
+
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
13
|
+
})]
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { AuthShell };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AuthShell } from "./auth-shell/auth-shell.js";
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { restoreOptimisticSnapshot, shouldRestoreOptimisticSnapshot } from "./shared/optimistic.js";
|
|
2
|
+
import { columnIdOf, getColumnLabel, isArrayValuedColumn } from "./shared/table.js";
|
|
3
|
+
export { columnIdOf, getColumnLabel, isArrayValuedColumn, restoreOptimisticSnapshot, shouldRestoreOptimisticSnapshot };
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { restoreOptimisticSnapshot, shouldRestoreOptimisticSnapshot } from "./shared/optimistic.js";
|
|
2
|
+
import { columnIdOf, getColumnLabel, isArrayValuedColumn } from "./shared/table.js";
|
|
3
|
+
export { columnIdOf, getColumnLabel, isArrayValuedColumn, restoreOptimisticSnapshot, shouldRestoreOptimisticSnapshot };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentPropsWithoutRef, PropsWithChildren, ReactNode } from "react";
|
|
2
2
|
/** Extra props (such as `data-theme`) land on `<html>` itself. */
|
|
3
3
|
type ComposeViewportProps = PropsWithChildren<ComponentPropsWithoutRef<"html">>;
|
|
4
4
|
type WindowProps = ComponentPropsWithoutRef<"body"> & {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Rendered as direct `<body>` children, after `<main>`, not inside it.
|
|
7
|
+
* `<Scripts />` (and devtools) belong here — TanStack Router's own docs
|
|
8
|
+
* say `<Scripts />` "should be placed near the end of the document
|
|
9
|
+
* body", not nested inside the app's content wrapper.
|
|
10
|
+
*/
|
|
11
|
+
after?: ReactNode;
|
|
12
12
|
};
|
|
13
13
|
export declare function ComposeViewport({ children, lang, className, ...props }: ComposeViewportProps): import("react").JSX.Element;
|
|
14
14
|
export declare namespace ComposeViewport {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export { Window };
|
|
16
|
+
export { Devtools };
|
|
17
17
|
}
|
|
18
18
|
declare function Window({ className, children, after, ...props }: WindowProps): import("react").JSX.Element;
|
|
19
19
|
declare function Devtools(): import("react").JSX.Element;
|
|
20
|
-
export {};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@passui/react/cn";
|
|
3
|
+
import { TanStackDevtools } from "@tanstack/react-devtools";
|
|
4
|
+
import { ReactQueryDevtoolsPanel } from "@tanstack/react-query-devtools";
|
|
5
|
+
import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools";
|
|
6
|
+
// src/document/compose-viewport.tsx
|
|
7
|
+
function ComposeViewport({ children, lang = "en", className, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx("html", {
|
|
9
|
+
lang,
|
|
10
|
+
className: cn("antialiased blur-none", className),
|
|
11
|
+
suppressHydrationWarning: true,
|
|
12
|
+
...props,
|
|
13
|
+
children
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function Window({ className, children, after, ...props }) {
|
|
17
|
+
return /* @__PURE__ */ jsxs("body", {
|
|
18
|
+
className: cn("bg-background fixed h-svh w-full min-w-full", "overflow-x-hidden selection:bg-olive-500/15", "typeset wrap-anywhere duration-200", "flex flex-col", className),
|
|
19
|
+
...props,
|
|
20
|
+
children: [/* @__PURE__ */ jsx("main", {
|
|
21
|
+
className: cn("flex min-h-svh flex-1 flex-col overflow-auto", "no-scrollbar"),
|
|
22
|
+
children
|
|
23
|
+
}), after]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function Devtools() {
|
|
27
|
+
return /* @__PURE__ */ jsx(TanStackDevtools, {
|
|
28
|
+
config: {
|
|
29
|
+
triggerMode: "floating",
|
|
30
|
+
position: "top-right"
|
|
31
|
+
},
|
|
32
|
+
plugins: [{
|
|
33
|
+
name: "TanStack Query",
|
|
34
|
+
render: /* @__PURE__ */ jsx(ReactQueryDevtoolsPanel, {})
|
|
35
|
+
}, {
|
|
36
|
+
name: "Tanstack Router",
|
|
37
|
+
render: /* @__PURE__ */ jsx(TanStackRouterDevtoolsPanel, {})
|
|
38
|
+
}]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
ComposeViewport.Window = Window;
|
|
42
|
+
ComposeViewport.Devtools = Devtools;
|
|
43
|
+
export { ComposeViewport };
|
package/dist/document.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComposeViewport } from "./document/compose-viewport.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
export declare const PeachFieldLabels: import("react").Context<{
|
|
3
|
+
show: string;
|
|
4
|
+
hide: string;
|
|
5
|
+
} | undefined>;
|
|
6
|
+
export type FieldInputProps = Omit<ComponentProps<"input">, "value" | "onChange" | "onBlur" | "name"> & {
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Leading icon or text inside the field. */
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/** A labelled input wired to the TanStack form field. Password fields get a show/hide button. */
|
|
13
|
+
export declare function FieldInput({ label, description, icon, type, id, ...props }: FieldInputProps): import("react").JSX.Element;
|
|
14
|
+
export declare function FieldCheckbox({ label }: {
|
|
15
|
+
label: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
export declare function FieldSwitch({ label, description, disabled }: {
|
|
18
|
+
label: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
export declare function FieldTextarea({ label, icon, ...props }: ComponentProps<"textarea"> & {
|
|
23
|
+
label: string;
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
export declare function FieldOtp({ label, maxLength, onComplete }: {
|
|
27
|
+
label: string;
|
|
28
|
+
maxLength?: number;
|
|
29
|
+
onComplete?: (value: string) => void;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useFieldContext } from "../forms/contexts.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { HiddenIcon } from "@passui/icons/hidden";
|
|
4
|
+
import { VisibleIcon } from "@passui/icons/visible";
|
|
5
|
+
import { Checkbox } from "@passui/react/checkbox";
|
|
6
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "@passui/react/field";
|
|
7
|
+
import { Input } from "@passui/react/input";
|
|
8
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from "@passui/react/input-group";
|
|
9
|
+
import { InputOTP } from "@passui/react/input-otp";
|
|
10
|
+
import { Switch } from "@passui/react/switch";
|
|
11
|
+
import { Textarea } from "@passui/react/textarea";
|
|
12
|
+
import { createContext, useContext, useId, useState } from "react";
|
|
13
|
+
// src/form-fields/fields.tsx
|
|
14
|
+
const PeachFieldLabels = createContext(void 0);
|
|
15
|
+
function useFieldErrors() {
|
|
16
|
+
const field = useFieldContext();
|
|
17
|
+
return field.state.meta.isTouched ? Array.from(new Set(field.state.meta.errors.flatMap((error) => error && typeof error === "object" && "message" in error && error.message ? [String(error.message)] : []))) : [];
|
|
18
|
+
}
|
|
19
|
+
/** A labelled input wired to the TanStack form field. Password fields get a show/hide button. */
|
|
20
|
+
function FieldInput({ label, description, icon, type, id, ...props }) {
|
|
21
|
+
const field = useFieldContext();
|
|
22
|
+
const reveal = useContext(PeachFieldLabels);
|
|
23
|
+
const [shown, setShown] = useState(false);
|
|
24
|
+
const generated = useId();
|
|
25
|
+
const inputId = id ?? generated;
|
|
26
|
+
const errors = useFieldErrors();
|
|
27
|
+
const invalid = errors.length > 0;
|
|
28
|
+
const describedBy = [description && `${inputId}-hint`, invalid && `${inputId}-error`].filter(Boolean).join(" ") || void 0;
|
|
29
|
+
const common = {
|
|
30
|
+
id: inputId,
|
|
31
|
+
name: field.name,
|
|
32
|
+
value: field.state.value,
|
|
33
|
+
onChange: (event) => field.handleChange(event.target.value),
|
|
34
|
+
onBlur: field.handleBlur,
|
|
35
|
+
"aria-invalid": invalid || void 0,
|
|
36
|
+
"aria-describedby": describedBy,
|
|
37
|
+
...props
|
|
38
|
+
};
|
|
39
|
+
const isPassword = type === "password";
|
|
40
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
41
|
+
invalid,
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
44
|
+
htmlFor: inputId,
|
|
45
|
+
children: label
|
|
46
|
+
}),
|
|
47
|
+
icon || isPassword ? /* @__PURE__ */ jsxs(InputGroup, { children: [
|
|
48
|
+
icon ? /* @__PURE__ */ jsx(InputGroupAddon, { children: icon }) : null,
|
|
49
|
+
/* @__PURE__ */ jsx(InputGroupInput, {
|
|
50
|
+
...common,
|
|
51
|
+
type: isPassword && shown ? "text" : type
|
|
52
|
+
}),
|
|
53
|
+
isPassword && reveal ? /* @__PURE__ */ jsx(InputGroupAddon, {
|
|
54
|
+
align: "end",
|
|
55
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
56
|
+
type: "button",
|
|
57
|
+
"aria-pressed": shown,
|
|
58
|
+
"aria-label": shown ? reveal.hide : reveal.show,
|
|
59
|
+
onClick: () => setShown(!shown),
|
|
60
|
+
className: "focus-visible:ring-accent/70 rounded-full p-1 outline-none focus-visible:ring-2",
|
|
61
|
+
children: shown ? /* @__PURE__ */ jsx(HiddenIcon, { size: 18 }) : /* @__PURE__ */ jsx(VisibleIcon, { size: 18 })
|
|
62
|
+
})
|
|
63
|
+
}) : null
|
|
64
|
+
] }) : /* @__PURE__ */ jsx(Input, {
|
|
65
|
+
...common,
|
|
66
|
+
type
|
|
67
|
+
}),
|
|
68
|
+
description ? /* @__PURE__ */ jsx(FieldDescription, {
|
|
69
|
+
id: `${inputId}-hint`,
|
|
70
|
+
children: description
|
|
71
|
+
}) : null,
|
|
72
|
+
invalid ? /* @__PURE__ */ jsx(FieldError, {
|
|
73
|
+
id: `${inputId}-error`,
|
|
74
|
+
children: errors.join(". ")
|
|
75
|
+
}) : null
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function FieldCheckbox({ label }) {
|
|
80
|
+
const field = useFieldContext();
|
|
81
|
+
return /* @__PURE__ */ jsx(Checkbox, {
|
|
82
|
+
name: field.name,
|
|
83
|
+
checked: field.state.value,
|
|
84
|
+
onCheckedChange: (checked) => {
|
|
85
|
+
field.handleChange(checked === true);
|
|
86
|
+
field.handleBlur();
|
|
87
|
+
},
|
|
88
|
+
children: label
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function FieldSwitch({ label, description, disabled }) {
|
|
92
|
+
const field = useFieldContext();
|
|
93
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
94
|
+
className: "flex items-center justify-between gap-4",
|
|
95
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
96
|
+
className: "text-subheadline",
|
|
97
|
+
children: [label, description && /* @__PURE__ */ jsx("p", {
|
|
98
|
+
className: "text-footnote text-label-secondary",
|
|
99
|
+
children: description
|
|
100
|
+
})]
|
|
101
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
102
|
+
"aria-label": label,
|
|
103
|
+
name: field.name,
|
|
104
|
+
checked: field.state.value,
|
|
105
|
+
disabled,
|
|
106
|
+
onCheckedChange: (checked) => {
|
|
107
|
+
field.handleChange(checked);
|
|
108
|
+
field.handleBlur();
|
|
109
|
+
}
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function FieldTextarea({ label, icon, ...props }) {
|
|
114
|
+
const field = useFieldContext();
|
|
115
|
+
const errors = useFieldErrors();
|
|
116
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
117
|
+
invalid: errors.length > 0,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsxs(FieldLabel, {
|
|
120
|
+
htmlFor: field.name,
|
|
121
|
+
children: [icon, label]
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
124
|
+
...props,
|
|
125
|
+
id: field.name,
|
|
126
|
+
name: field.name,
|
|
127
|
+
"aria-invalid": errors.length > 0 || void 0,
|
|
128
|
+
"aria-describedby": errors.length ? `${field.name}-errors` : void 0,
|
|
129
|
+
value: field.state.value,
|
|
130
|
+
onBlur: field.handleBlur,
|
|
131
|
+
onChange: (event) => field.handleChange(event.target.value)
|
|
132
|
+
}),
|
|
133
|
+
errors.length > 0 && /* @__PURE__ */ jsx(FieldError, {
|
|
134
|
+
id: `${field.name}-errors`,
|
|
135
|
+
children: errors.join(". ")
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function FieldOtp({ label, maxLength = 6, onComplete }) {
|
|
141
|
+
const field = useFieldContext();
|
|
142
|
+
const errors = useFieldErrors();
|
|
143
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
144
|
+
invalid: errors.length > 0,
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: label }),
|
|
147
|
+
/* @__PURE__ */ jsx(InputOTP, {
|
|
148
|
+
"aria-label": label,
|
|
149
|
+
name: field.name,
|
|
150
|
+
length: maxLength,
|
|
151
|
+
value: field.state.value,
|
|
152
|
+
invalid: errors.length > 0,
|
|
153
|
+
onValueChange: (code) => field.handleChange(code),
|
|
154
|
+
onComplete: (code) => onComplete?.(code)
|
|
155
|
+
}),
|
|
156
|
+
errors.length > 0 && /* @__PURE__ */ jsx(FieldError, { children: errors.join(". ") })
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
export { FieldCheckbox, FieldInput, FieldOtp, FieldSwitch, FieldTextarea, PeachFieldLabels };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type Option = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function FieldRadioCard({ label, description, options, disabled, columns }: {
|
|
10
|
+
label: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
options: Option[];
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
columns?: 1 | 2;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export declare function FieldMultiselect({ label, description, options }: {
|
|
17
|
+
label: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
options: Option[];
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useFieldContext } from "../forms/contexts.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Checkbox } from "@passui/react/checkbox";
|
|
4
|
+
import { cn } from "@passui/react/cn";
|
|
5
|
+
import { RadioGroup, RadioGroupItem } from "@passui/react/radio-group";
|
|
6
|
+
// src/form-fields/selection.tsx
|
|
7
|
+
function FieldRadioCard({ label, description, options, disabled, columns = 1 }) {
|
|
8
|
+
const field = useFieldContext();
|
|
9
|
+
return /* @__PURE__ */ jsxs(RadioGroup, {
|
|
10
|
+
name: field.name,
|
|
11
|
+
disabled,
|
|
12
|
+
value: field.state.value,
|
|
13
|
+
"aria-label": label,
|
|
14
|
+
onValueChange: (value) => {
|
|
15
|
+
if (value !== null) field.handleChange(value);
|
|
16
|
+
field.handleBlur();
|
|
17
|
+
},
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "text-subheadline font-semibold",
|
|
21
|
+
children: label
|
|
22
|
+
}),
|
|
23
|
+
description && /* @__PURE__ */ jsx("p", {
|
|
24
|
+
className: "text-footnote text-label-secondary",
|
|
25
|
+
children: description
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: cn("grid gap-2", columns === 2 && "md:grid-cols-2"),
|
|
29
|
+
children: options.map((option) => /* @__PURE__ */ jsxs(RadioGroupItem, {
|
|
30
|
+
value: option.value,
|
|
31
|
+
disabled: option.disabled,
|
|
32
|
+
className: cn("items-start rounded-xl border p-3", field.state.value === option.value ? "border-accent-text bg-accent/10" : "border-separator bg-elevated"),
|
|
33
|
+
children: [option.icon, /* @__PURE__ */ jsxs("span", {
|
|
34
|
+
className: "text-subheadline",
|
|
35
|
+
children: [option.label, option.description && /* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "text-footnote text-label-secondary block",
|
|
37
|
+
children: option.description
|
|
38
|
+
})]
|
|
39
|
+
})]
|
|
40
|
+
}, option.value))
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function FieldMultiselect({ label, description, options }) {
|
|
46
|
+
const field = useFieldContext();
|
|
47
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
48
|
+
className: "flex flex-col gap-3",
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsx("legend", {
|
|
51
|
+
className: "text-subheadline font-semibold",
|
|
52
|
+
children: label
|
|
53
|
+
}),
|
|
54
|
+
description && /* @__PURE__ */ jsx("p", {
|
|
55
|
+
className: "text-footnote text-label-secondary",
|
|
56
|
+
children: description
|
|
57
|
+
}),
|
|
58
|
+
options.map((option) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
59
|
+
disabled: option.disabled,
|
|
60
|
+
checked: field.state.value.includes(option.value),
|
|
61
|
+
onCheckedChange: (checked) => {
|
|
62
|
+
field.handleChange(checked === true ? Array.from(/* @__PURE__ */ new Set([...field.state.value, option.value])) : field.state.value.filter((value) => value !== option.value));
|
|
63
|
+
field.handleBlur();
|
|
64
|
+
},
|
|
65
|
+
children: option.label
|
|
66
|
+
}), option.description && /* @__PURE__ */ jsx("p", {
|
|
67
|
+
className: "text-footnote text-label-secondary pl-8",
|
|
68
|
+
children: option.description
|
|
69
|
+
})] }, option.value))
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export { FieldMultiselect, FieldRadioCard };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useFormContext } from "../forms/contexts.js";
|
|
2
|
+
import { Button } from "@passui/react/button";
|
|
3
|
+
import { Spinner } from "@passui/react/spinner";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/form-fields/submit.tsx
|
|
6
|
+
function Submit({ label }) {
|
|
7
|
+
const form = useFormContext();
|
|
8
|
+
return /* @__PURE__ */ jsx(form.Subscribe, {
|
|
9
|
+
selector: (state) => [
|
|
10
|
+
state.isSubmitting,
|
|
11
|
+
state.canSubmit,
|
|
12
|
+
state.isDirty,
|
|
13
|
+
state.isTouched
|
|
14
|
+
],
|
|
15
|
+
children: ([pending, valid, dirty, touched]) => /* @__PURE__ */ jsxs(Button, {
|
|
16
|
+
type: "submit",
|
|
17
|
+
variant: "default",
|
|
18
|
+
size: "default",
|
|
19
|
+
"aria-busy": pending,
|
|
20
|
+
disabled: pending || !valid || !dirty || !touched,
|
|
21
|
+
className: "w-full",
|
|
22
|
+
children: [pending && /* @__PURE__ */ jsx(Spinner, {}), label]
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { Submit };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormAlert } from "./forms/elements/form-alert.js";
|
|
2
|
+
import { useAppForm, useSelector, useStore, withForm } from "./forms.js";
|
|
3
|
+
import { FieldMultiselect, FieldRadioCard } from "./form-fields/selection.js";
|
|
4
|
+
import { FieldAvatar, FieldAvatarLabels, FieldAvatarValue } from "./forms/fields/avatar.js";
|
|
5
|
+
import { fields } from "./forms/fields/index.js";
|
|
6
|
+
import { FieldCheckbox, FieldInput, FieldOtp, FieldSwitch, FieldTextarea, PeachFieldLabels } from "./form-fields/fields.js";
|
|
7
|
+
export { FieldAvatar, FieldAvatarLabels, FieldAvatarValue, FieldCheckbox, FieldInput, FieldMultiselect, FieldOtp, FieldRadioCard, FieldSwitch, FieldTextarea, FormAlert, PeachFieldLabels, fields, useAppForm, useSelector, useStore, withForm };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useAppForm, useSelector, useStore, withForm } from "./forms.js";
|
|
2
|
+
import { FieldMultiselect, FieldRadioCard } from "./form-fields/selection.js";
|
|
3
|
+
import { FieldAvatar } from "./forms/fields/avatar.js";
|
|
4
|
+
import { fields } from "./forms/fields/index.js";
|
|
5
|
+
import { FormAlert } from "./forms/elements/form-alert.js";
|
|
6
|
+
import { FieldCheckbox, FieldInput, FieldOtp, FieldSwitch, FieldTextarea, PeachFieldLabels } from "./form-fields/fields.js";
|
|
7
|
+
export { FieldAvatar, FieldCheckbox, FieldInput, FieldMultiselect, FieldOtp, FieldRadioCard, FieldSwitch, FieldTextarea, FormAlert, PeachFieldLabels, fields, useAppForm, useSelector, useStore, withForm };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
/** A form-level error people can't miss: announced, tinted, and gently shaken in. */
|
|
3
3
|
export declare function FormAlert({ children, className }: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}): import("react").JSX.Element;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@passui/react/cn";
|
|
3
|
+
import { WarningIcon } from "@passui/icons/warning";
|
|
4
|
+
// src/forms/elements/form-alert.tsx
|
|
5
|
+
/** A form-level error people can't miss: announced, tinted, and gently shaken in. */
|
|
6
|
+
function FormAlert({ children, className }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
8
|
+
role: "alert",
|
|
9
|
+
className: cn("bg-destructive/12 text-subheadline text-destructive ring-destructive/25 flex items-start gap-2.5 rounded-2xl px-4 py-3 font-medium ring-1 ring-inset", "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-300", className),
|
|
10
|
+
children: [/* @__PURE__ */ jsx(WarningIcon, {
|
|
11
|
+
size: 16,
|
|
12
|
+
className: "mt-px shrink-0"
|
|
13
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
14
|
+
className: "min-w-0",
|
|
15
|
+
children
|
|
16
|
+
})]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { FormAlert };
|