nextworks 0.1.0-alpha.4 → 0.1.0-alpha.5
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 +1 -1
- package/dist/kits/auth-core/components/ui/button.tsx +84 -17
- package/dist/kits/auth-core/components/ui/input.tsx +5 -3
- package/dist/kits/auth-core/components/ui/label.tsx +10 -4
- package/dist/kits/forms/.nextworks/docs/FORMS_QUICKSTART.md +1 -0
- package/dist/kits/forms/.nextworks/docs/FORMS_README.md +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,24 +5,27 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
|
|
7
7
|
const buttonVariants = cva(
|
|
8
|
-
"inline-flex items-center justify-center
|
|
8
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
12
|
-
default:
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground hover:bg-primary/90 shadow-xs",
|
|
13
14
|
destructive:
|
|
14
|
-
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
15
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 shadow-xs",
|
|
15
16
|
outline:
|
|
16
|
-
"
|
|
17
|
-
secondary:
|
|
18
|
-
|
|
17
|
+
"bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs",
|
|
18
|
+
secondary:
|
|
19
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-xs",
|
|
20
|
+
ghost:
|
|
21
|
+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
19
22
|
link: "text-primary underline-offset-4 hover:underline",
|
|
20
23
|
},
|
|
21
24
|
size: {
|
|
22
|
-
default: "h-
|
|
23
|
-
sm: "h-
|
|
24
|
-
lg: "h-
|
|
25
|
-
icon: "
|
|
25
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
26
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
27
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
28
|
+
icon: "size-9",
|
|
26
29
|
},
|
|
27
30
|
},
|
|
28
31
|
defaultVariants: {
|
|
@@ -32,24 +35,88 @@ const buttonVariants = cva(
|
|
|
32
35
|
},
|
|
33
36
|
);
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
type ButtonProps = React.ComponentProps<"button"> &
|
|
39
|
+
VariantProps<typeof buttonVariants> & {
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
/** When true, bypasses tokenized buttonVariants so callers fully control classes */
|
|
42
|
+
unstyled?: boolean;
|
|
43
|
+
/** Opt-in: force inline CSS var styles for color/bg/border/ring */
|
|
44
|
+
forceInlineVars?: boolean;
|
|
45
|
+
};
|
|
40
46
|
|
|
41
47
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
42
|
-
(
|
|
48
|
+
(
|
|
49
|
+
{
|
|
50
|
+
className,
|
|
51
|
+
variant,
|
|
52
|
+
size,
|
|
53
|
+
asChild = false,
|
|
54
|
+
unstyled = false,
|
|
55
|
+
forceInlineVars = false,
|
|
56
|
+
...props
|
|
57
|
+
},
|
|
58
|
+
ref,
|
|
59
|
+
) => {
|
|
43
60
|
const Comp = asChild ? Slot : "button";
|
|
61
|
+
|
|
62
|
+
// Use caller-provided style; only inject inline var-driven colors when explicitly requested
|
|
63
|
+
const incomingStyle =
|
|
64
|
+
(props.style as React.CSSProperties | undefined) ?? undefined;
|
|
65
|
+
const finalStyle =
|
|
66
|
+
forceInlineVars && !unstyled
|
|
67
|
+
? {
|
|
68
|
+
...incomingStyle,
|
|
69
|
+
color: "var(--btn-fg)",
|
|
70
|
+
backgroundColor: "var(--btn-bg)",
|
|
71
|
+
borderColor: "var(--btn-border)",
|
|
72
|
+
"--tw-ring-color": "var(--btn-ring)",
|
|
73
|
+
}
|
|
74
|
+
: incomingStyle;
|
|
75
|
+
|
|
76
|
+
// Only enable CSS variable hooks when explicitly requested via inline vars
|
|
77
|
+
// or when the caller sets any [--btn-*] classes in className.
|
|
78
|
+
const wantsVarHooks =
|
|
79
|
+
!unstyled &&
|
|
80
|
+
(forceInlineVars ||
|
|
81
|
+
(typeof className === "string" && className.includes("[--btn-")));
|
|
82
|
+
|
|
44
83
|
return (
|
|
45
84
|
<Comp
|
|
46
|
-
className={cn(buttonVariants({ variant, size, className }))}
|
|
47
85
|
ref={ref}
|
|
86
|
+
data-slot="button"
|
|
87
|
+
className={
|
|
88
|
+
unstyled
|
|
89
|
+
? cn(
|
|
90
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap disabled:pointer-events-none disabled:opacity-50",
|
|
91
|
+
className,
|
|
92
|
+
)
|
|
93
|
+
: cn(
|
|
94
|
+
buttonVariants({ variant, size }),
|
|
95
|
+
wantsVarHooks && [
|
|
96
|
+
// Color var hooks (apply only when CSS vars are provided)
|
|
97
|
+
"text-[var(--btn-fg)]",
|
|
98
|
+
"bg-[var(--btn-bg)]",
|
|
99
|
+
"hover:bg-[var(--btn-hover-bg)]",
|
|
100
|
+
"hover:text-[var(--btn-hover-fg)]",
|
|
101
|
+
// explicit dark variants to compete with dark: utilities from variants like outline
|
|
102
|
+
"dark:bg-[var(--btn-bg)]",
|
|
103
|
+
"dark:hover:bg-[var(--btn-hover-bg)]",
|
|
104
|
+
"dark:hover:text-[var(--btn-hover-fg)]",
|
|
105
|
+
// Focus ring and border hooks
|
|
106
|
+
"focus-visible:ring-[var(--btn-ring)]",
|
|
107
|
+
"border-[var(--btn-border)]",
|
|
108
|
+
"dark:border-[var(--btn-border)]",
|
|
109
|
+
],
|
|
110
|
+
className,
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
style={finalStyle}
|
|
48
114
|
{...props}
|
|
49
115
|
/>
|
|
50
116
|
);
|
|
51
117
|
},
|
|
52
118
|
);
|
|
119
|
+
|
|
53
120
|
Button.displayName = "Button";
|
|
54
121
|
|
|
55
122
|
export { Button, buttonVariants };
|
|
@@ -2,8 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "@/lib/utils";
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
5
|
+
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
7
6
|
|
|
8
7
|
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
9
8
|
({ className, type, ...props }, ref) => {
|
|
@@ -11,7 +10,10 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
11
10
|
<input
|
|
12
11
|
type={type}
|
|
13
12
|
className={cn(
|
|
14
|
-
|
|
13
|
+
// Base structural + token fallbacks
|
|
14
|
+
"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/30 dark:aria-invalid:focus-visible:ring-destructive/40 flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
15
|
+
// CSS variable hooks (preset-first). When vars are unset, these are ignored and tokens above apply.
|
|
16
|
+
"focus-visible:ring-offset-background border-[var(--input-border)] bg-[var(--input-bg)] text-[var(--input-fg)] placeholder:text-[var(--input-placeholder)] focus-visible:ring-[var(--input-focus-ring,var(--ring))] focus-visible:ring-offset-2",
|
|
15
17
|
className,
|
|
16
18
|
)}
|
|
17
19
|
ref={ref}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
1
|
import * as React from "react";
|
|
4
2
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
4
|
|
|
6
5
|
import { cn } from "@/lib/utils";
|
|
7
6
|
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
"text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
9
|
+
);
|
|
10
|
+
|
|
8
11
|
const Label = React.forwardRef<
|
|
9
12
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
10
|
-
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof labelVariants>
|
|
11
15
|
>(({ className, ...props }, ref) => (
|
|
12
16
|
<LabelPrimitive.Root
|
|
13
17
|
ref={ref}
|
|
14
18
|
className={cn(
|
|
15
|
-
|
|
19
|
+
labelVariants(),
|
|
20
|
+
// Optional color override via var; falls back to inherited color when unset
|
|
21
|
+
"text-[var(--label-fg)]",
|
|
16
22
|
className,
|
|
17
23
|
)}
|
|
18
24
|
{...props}
|
|
@@ -30,6 +30,7 @@ How to try it locally
|
|
|
30
30
|
http://localhost:3000/examples/forms/basic
|
|
31
31
|
|
|
32
32
|
Note: Some examples that hit the server (such as the wizard/server-action flows) assume you have a Prisma schema and database configured in your app, often via Auth Core/Data. If you haven’t set that up yet, expect those examples to need additional setup.
|
|
33
|
+
The Forms kit does **not** include a Prisma schema; you must define your own `prisma/schema.prisma` and run Prisma migrations if you want the server-action and wizard examples to use a real database.
|
|
33
34
|
|
|
34
35
|
Tip: If you change the Prisma schema, run:
|
|
35
36
|
npx prisma generate
|
|
@@ -21,6 +21,7 @@ What the kit includes
|
|
|
21
21
|
Notes
|
|
22
22
|
|
|
23
23
|
- The forms primitives are UI-only and do not require Prisma or NextAuth.
|
|
24
|
+
- The Forms kit does **not** ship a Prisma schema; if you use the server-action or wizard examples against a real database, you must add a `prisma/schema.prisma` in your app and run `npx prisma generate` and `npx prisma migrate dev`.
|
|
24
25
|
- The wizard example assumes a basic app/api/wizard/route.ts endpoint; adjust it as needed for your project.
|
|
25
26
|
- Keep this kit folder in sync with cli_manifests/forms_manifest.json.
|
|
26
27
|
|