@brightlocal/ui-components 0.2.0 → 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/alert.cjs +1 -1
- package/dist/alert.d.ts +10 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +6 -2
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +6 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +89 -73
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +49 -25
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +57 -32
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/chip.cjs +1 -0
- package/dist/chip.d.ts +61 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +165 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +5 -2
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +89 -52
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +228 -210
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/header.cjs +1 -0
- package/dist/header.d.ts +42 -0
- package/dist/header.d.ts.map +1 -0
- package/dist/header.js +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +426 -396
- package/dist/input-chip.cjs +1 -0
- package/dist/input-chip.d.ts +117 -0
- package/dist/input-chip.d.ts.map +1 -0
- package/dist/input-chip.js +284 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +43 -36
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +140 -119
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +147 -19
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +197 -92
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +10 -0
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +45 -36
- package/dist/select.d.ts.map +1 -1
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +31 -3
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +53 -43
- package/dist/textarea.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert.tsx +10 -1
- package/src/components/card.tsx +66 -38
- package/src/components/centred-layout.tsx +115 -38
- package/src/components/checkbox.tsx +2 -2
- package/src/components/chip.tsx +249 -0
- package/src/components/combobox.tsx +17 -13
- package/src/components/date-picker.tsx +410 -266
- package/src/components/dropdown-menu.tsx +6 -1
- package/src/components/header.tsx +69 -0
- package/src/components/input-chip.tsx +548 -0
- package/src/components/input-group.tsx +4 -1
- package/src/components/input-otp.tsx +159 -91
- package/src/components/input-password.tsx +469 -129
- package/src/components/input.tsx +1 -1
- package/src/components/progress.tsx +21 -2
- package/src/components/select.tsx +1 -3
- package/src/components/slider.tsx +85 -15
- package/src/components/textarea.tsx +4 -1
- package/src/index.ts +3 -0
package/dist/slider.js
CHANGED
|
@@ -1,53 +1,63 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as k, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import * as u from "react";
|
|
3
|
+
import * as s from "@radix-ui/react-slider";
|
|
4
|
+
import { cn as h } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
const A = ["Slider"], S = ["Minimum value", "Maximum value"], L = u.forwardRef(
|
|
6
6
|
({
|
|
7
|
-
className:
|
|
8
|
-
dataHook:
|
|
9
|
-
defaultValue:
|
|
10
|
-
max:
|
|
11
|
-
min:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
className: f,
|
|
8
|
+
dataHook: m,
|
|
9
|
+
defaultValue: e,
|
|
10
|
+
max: d = 100,
|
|
11
|
+
min: i = 0,
|
|
12
|
+
mode: t = "single",
|
|
13
|
+
thumbLabels: n,
|
|
14
|
+
trackingEl: b,
|
|
15
|
+
trackingLabel: g,
|
|
15
16
|
value: r,
|
|
16
|
-
...
|
|
17
|
-
},
|
|
18
|
-
const u =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
...v
|
|
18
|
+
}, p) => {
|
|
19
|
+
const a = u.useMemo(() => Array.isArray(r) ? r.length : Array.isArray(e) ? e.length : t === "range" ? 2 : 1, [r, e, t]), w = u.useMemo(() => {
|
|
20
|
+
if (e !== void 0) return e;
|
|
21
|
+
if (r === void 0)
|
|
22
|
+
return t === "range" ? [i, d] : [i];
|
|
23
|
+
}, [e, r, t, i, d]), y = (l) => {
|
|
24
|
+
const o = n?.[l];
|
|
25
|
+
return o || ((a > 1 ? S : A)[l] ?? `Slider thumb ${l + 1}`);
|
|
26
|
+
};
|
|
27
|
+
return process.env.NODE_ENV === "development" && (r !== void 0 && e !== void 0 && console.warn(
|
|
28
|
+
'[Slider] Component is being used with both "value" and "defaultValue" props. This is likely a mistake. Use "value" with "onValueChange" for controlled mode, or "defaultValue" for uncontrolled mode, but not both.'
|
|
29
|
+
), n && n.length !== a && console.warn(
|
|
30
|
+
`[Slider] "thumbLabels" array length (${n.length}) doesn't match the number of thumbs (${a}). For ${t === "range" ? "range" : "single"} mode, provide ${a} label(s).`
|
|
31
|
+
)), /* @__PURE__ */ k(
|
|
32
|
+
s.Root,
|
|
24
33
|
{
|
|
25
|
-
ref:
|
|
26
|
-
className:
|
|
34
|
+
ref: p,
|
|
35
|
+
className: h(
|
|
27
36
|
"relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
28
|
-
|
|
37
|
+
f
|
|
29
38
|
),
|
|
30
|
-
"data-hook":
|
|
39
|
+
"data-hook": m,
|
|
40
|
+
"data-mode": t,
|
|
31
41
|
"data-slot": "slider",
|
|
32
|
-
"data-tracking-el":
|
|
33
|
-
"data-tracking-label":
|
|
34
|
-
defaultValue:
|
|
35
|
-
max:
|
|
36
|
-
min:
|
|
42
|
+
"data-tracking-el": b,
|
|
43
|
+
"data-tracking-label": g,
|
|
44
|
+
defaultValue: w,
|
|
45
|
+
max: d,
|
|
46
|
+
min: i,
|
|
37
47
|
value: r,
|
|
38
|
-
...
|
|
48
|
+
...v,
|
|
39
49
|
children: [
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
|
|
50
|
+
/* @__PURE__ */ c(
|
|
51
|
+
s.Track,
|
|
42
52
|
{
|
|
43
|
-
className:
|
|
53
|
+
className: h(
|
|
44
54
|
"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
45
55
|
),
|
|
46
56
|
"data-slot": "slider-track",
|
|
47
|
-
children: /* @__PURE__ */
|
|
48
|
-
|
|
57
|
+
children: /* @__PURE__ */ c(
|
|
58
|
+
s.Range,
|
|
49
59
|
{
|
|
50
|
-
className:
|
|
60
|
+
className: h(
|
|
51
61
|
"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
|
|
52
62
|
),
|
|
53
63
|
"data-slot": "slider-range"
|
|
@@ -55,21 +65,21 @@ const p = d.forwardRef(
|
|
|
55
65
|
)
|
|
56
66
|
}
|
|
57
67
|
),
|
|
58
|
-
Array.from({ length:
|
|
59
|
-
|
|
68
|
+
Array.from({ length: a }, (l, o) => /* @__PURE__ */ c(
|
|
69
|
+
s.Thumb,
|
|
60
70
|
{
|
|
61
|
-
"aria-label":
|
|
71
|
+
"aria-label": y(o),
|
|
62
72
|
className: "border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50",
|
|
63
73
|
"data-slot": "slider-thumb"
|
|
64
74
|
},
|
|
65
|
-
|
|
75
|
+
o
|
|
66
76
|
))
|
|
67
77
|
]
|
|
68
78
|
}
|
|
69
79
|
);
|
|
70
80
|
}
|
|
71
81
|
);
|
|
72
|
-
|
|
82
|
+
L.displayName = "Slider";
|
|
73
83
|
export {
|
|
74
|
-
|
|
84
|
+
L as Slider
|
|
75
85
|
};
|
package/dist/textarea.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/components/textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,UAAU,aAAc,SAAQ,IAAI,CAClC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,EAChC,UAAU,GAAG,IAAI,CAClB;IACC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/components/textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,UAAU,aAAc,SAAQ,IAAI,CAClC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,EAChC,UAAU,GAAG,IAAI,CAClB;IACC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,wGA6Bb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/components/alert.tsx
CHANGED
|
@@ -209,4 +209,13 @@ function AlertWarning({
|
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
export {
|
|
212
|
+
export {
|
|
213
|
+
Alert,
|
|
214
|
+
AlertTitle,
|
|
215
|
+
AlertDescription,
|
|
216
|
+
alertVariants,
|
|
217
|
+
AlertSuccess,
|
|
218
|
+
AlertInfo,
|
|
219
|
+
AlertDestructive,
|
|
220
|
+
AlertWarning,
|
|
221
|
+
};
|
package/src/components/card.tsx
CHANGED
|
@@ -3,6 +3,16 @@ import { cva } from "class-variance-authority";
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Card variant type
|
|
8
|
+
*/
|
|
9
|
+
type CardVariant = "default" | "transparent" | "border" | "transparent-flush";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Context to pass variant information to sub-components
|
|
13
|
+
*/
|
|
14
|
+
const CardContext = React.createContext<{ flush: boolean }>({ flush: false });
|
|
15
|
+
|
|
6
16
|
const cardVariants = cva(
|
|
7
17
|
["flex", "flex-col", "gap-8", "rounded-[14px]", "py-8", "transition-colors"],
|
|
8
18
|
{
|
|
@@ -21,6 +31,7 @@ const cardVariants = cva(
|
|
|
21
31
|
"border",
|
|
22
32
|
"border-border",
|
|
23
33
|
],
|
|
34
|
+
"transparent-flush": ["bg-transparent", "text-foreground"],
|
|
24
35
|
},
|
|
25
36
|
},
|
|
26
37
|
defaultVariants: {
|
|
@@ -37,7 +48,7 @@ type CardProps = React.ComponentProps<"div"> & {
|
|
|
37
48
|
* Visual style variant of the card
|
|
38
49
|
* @default "default"
|
|
39
50
|
*/
|
|
40
|
-
variant?:
|
|
51
|
+
variant?: CardVariant;
|
|
41
52
|
/**
|
|
42
53
|
* Data hook for automated testing (required)
|
|
43
54
|
*/
|
|
@@ -64,20 +75,27 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
64
75
|
dataHook,
|
|
65
76
|
trackingEl,
|
|
66
77
|
trackingLabel,
|
|
78
|
+
children,
|
|
67
79
|
...props
|
|
68
80
|
},
|
|
69
81
|
ref
|
|
70
82
|
) => {
|
|
83
|
+
const flush = variant === "transparent-flush";
|
|
84
|
+
|
|
71
85
|
return (
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
<CardContext.Provider value={{ flush }}>
|
|
87
|
+
<div
|
|
88
|
+
ref={ref}
|
|
89
|
+
className={cn(cardVariants({ variant }), className)}
|
|
90
|
+
data-hook={dataHook}
|
|
91
|
+
data-slot="card"
|
|
92
|
+
data-tracking-el={trackingEl || `card-${variant}`}
|
|
93
|
+
data-tracking-label={trackingLabel}
|
|
94
|
+
{...props}
|
|
95
|
+
>
|
|
96
|
+
{children}
|
|
97
|
+
</div>
|
|
98
|
+
</CardContext.Provider>
|
|
81
99
|
);
|
|
82
100
|
}
|
|
83
101
|
);
|
|
@@ -102,17 +120,21 @@ type CardSubComponentProps = React.ComponentProps<"div"> & {
|
|
|
102
120
|
* Header section of the Card containing title and description.
|
|
103
121
|
*/
|
|
104
122
|
const CardHeader = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
105
|
-
({ className, ...props }, ref) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
className
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
({ className, ...props }, ref) => {
|
|
124
|
+
const { flush } = React.useContext(CardContext);
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
ref={ref}
|
|
128
|
+
className={cn(
|
|
129
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
|
|
130
|
+
!flush && "px-8",
|
|
131
|
+
className
|
|
132
|
+
)}
|
|
133
|
+
data-slot="card-header"
|
|
134
|
+
{...props}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
116
138
|
);
|
|
117
139
|
CardHeader.displayName = "CardHeader";
|
|
118
140
|
|
|
@@ -171,14 +193,17 @@ CardAction.displayName = "CardAction";
|
|
|
171
193
|
* Main content area of the Card.
|
|
172
194
|
*/
|
|
173
195
|
const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
174
|
-
({ className, ...props }, ref) =>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
196
|
+
({ className, ...props }, ref) => {
|
|
197
|
+
const { flush } = React.useContext(CardContext);
|
|
198
|
+
return (
|
|
199
|
+
<div
|
|
200
|
+
ref={ref}
|
|
201
|
+
className={cn(!flush && "px-8", className)}
|
|
202
|
+
data-slot="card-content"
|
|
203
|
+
{...props}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
182
207
|
);
|
|
183
208
|
CardContent.displayName = "CardContent";
|
|
184
209
|
|
|
@@ -186,14 +211,17 @@ CardContent.displayName = "CardContent";
|
|
|
186
211
|
* Footer section of the Card for actions or metadata.
|
|
187
212
|
*/
|
|
188
213
|
const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
189
|
-
({ className, ...props }, ref) =>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
214
|
+
({ className, ...props }, ref) => {
|
|
215
|
+
const { flush } = React.useContext(CardContext);
|
|
216
|
+
return (
|
|
217
|
+
<div
|
|
218
|
+
ref={ref}
|
|
219
|
+
className={cn("flex items-center", !flush && "px-8", className)}
|
|
220
|
+
data-slot="card-footer"
|
|
221
|
+
{...props}
|
|
222
|
+
/>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
197
225
|
);
|
|
198
226
|
CardFooter.displayName = "CardFooter";
|
|
199
227
|
|
|
@@ -207,4 +235,4 @@ export {
|
|
|
207
235
|
CardContent,
|
|
208
236
|
};
|
|
209
237
|
|
|
210
|
-
export type { CardProps, CardSubComponentProps };
|
|
238
|
+
export type { CardProps, CardSubComponentProps, CardVariant };
|
|
@@ -2,28 +2,39 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
4
|
|
|
5
|
+
/* -------------------------------------------------------------------------------------------------
|
|
6
|
+
* CentredLayout Root
|
|
7
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
|
-
* CentredLayout provides a responsive centered container with max-width
|
|
7
|
-
* based on different breakpoint sizes.
|
|
10
|
+
* CentredLayout provides a responsive centered container with max-width constraint.
|
|
8
11
|
*
|
|
9
|
-
*
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* - SM: 640px (max-w-2xl)
|
|
12
|
+
* Spacing tokens used:
|
|
13
|
+
* - Padding: p-6 (spacing.6 = 24px) all around
|
|
14
|
+
* - Header to content gap: gap-4 (spacing.4 = 16px)
|
|
15
|
+
* - Max width: max-w-7xl (1280px) by default
|
|
14
16
|
*
|
|
15
|
-
* The component centers content horizontally and
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
17
|
+
* The component centers content horizontally and vertically.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Basic usage
|
|
21
|
+
* <CentredLayout dataHook="my-layout">
|
|
22
|
+
* <CentredLayoutContent>
|
|
23
|
+
* <Card>...</Card>
|
|
24
|
+
* </CentredLayoutContent>
|
|
25
|
+
* </CentredLayout>
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // With Header
|
|
29
|
+
* <CentredLayout dataHook="my-layout">
|
|
30
|
+
* <CentredLayoutHeader>
|
|
31
|
+
* <Header dataHook="my-header"><Logo /></Header>
|
|
32
|
+
* </CentredLayoutHeader>
|
|
33
|
+
* <CentredLayoutContent>
|
|
34
|
+
* <Card>...</Card>
|
|
35
|
+
* </CentredLayoutContent>
|
|
36
|
+
* </CentredLayout>
|
|
25
37
|
*/
|
|
26
|
-
export type CentredLayoutBreakpoint = "xl" | "lg" | "md" | "sm";
|
|
27
38
|
|
|
28
39
|
interface CentredLayoutProps extends React.ComponentProps<"div"> {
|
|
29
40
|
/**
|
|
@@ -39,12 +50,7 @@ interface CentredLayoutProps extends React.ComponentProps<"div"> {
|
|
|
39
50
|
*/
|
|
40
51
|
trackingLabel?: string;
|
|
41
52
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @default "xl"
|
|
44
|
-
*/
|
|
45
|
-
breakpoint?: CentredLayoutBreakpoint;
|
|
46
|
-
/**
|
|
47
|
-
* Custom max-width value (overrides breakpoint)
|
|
53
|
+
* Custom max-width value (overrides default 1280px)
|
|
48
54
|
*/
|
|
49
55
|
maxWidth?: string | number;
|
|
50
56
|
}
|
|
@@ -56,7 +62,6 @@ const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
|
|
|
56
62
|
(
|
|
57
63
|
{
|
|
58
64
|
className,
|
|
59
|
-
breakpoint = "xl",
|
|
60
65
|
maxWidth,
|
|
61
66
|
children,
|
|
62
67
|
dataHook,
|
|
@@ -66,15 +71,7 @@ const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
|
|
|
66
71
|
},
|
|
67
72
|
ref
|
|
68
73
|
) => {
|
|
69
|
-
//
|
|
70
|
-
const breakpointMaxWidthClass: Record<CentredLayoutBreakpoint, string> = {
|
|
71
|
-
xl: "max-w-7xl",
|
|
72
|
-
lg: "max-w-5xl",
|
|
73
|
-
md: "max-w-3xl",
|
|
74
|
-
sm: "max-w-2xl",
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// If custom maxWidth is provided, use inline style; otherwise use Tailwind class
|
|
74
|
+
// If custom maxWidth is provided, use inline style; otherwise use default max-w-7xl
|
|
78
75
|
const maxWidthStyle =
|
|
79
76
|
maxWidth !== undefined
|
|
80
77
|
? {
|
|
@@ -86,8 +83,9 @@ const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
|
|
|
86
83
|
<div
|
|
87
84
|
ref={ref}
|
|
88
85
|
className={cn(
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
// Base styles with p-6 padding (container-padding-x token) and gap-4 for header/content spacing
|
|
87
|
+
"bg-background flex min-h-screen flex-col items-center justify-center gap-4 p-6",
|
|
88
|
+
!maxWidth && "max-w-7xl",
|
|
91
89
|
className
|
|
92
90
|
)}
|
|
93
91
|
data-hook={dataHook}
|
|
@@ -105,6 +103,85 @@ const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
|
|
|
105
103
|
|
|
106
104
|
CentredLayout.displayName = "CentredLayout";
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
/* -------------------------------------------------------------------------------------------------
|
|
107
|
+
* CentredLayoutHeader
|
|
108
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
109
|
+
|
|
110
|
+
interface CentredLayoutHeaderProps extends React.ComponentProps<"div"> {
|
|
111
|
+
/**
|
|
112
|
+
* Header content (e.g., Header component with Logo)
|
|
113
|
+
*/
|
|
114
|
+
children: React.ReactNode;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* CentredLayoutHeader component for rendering header content at the top of CentredLayout.
|
|
119
|
+
* Content is centered on mobile/tablet, left-aligned from lg breakpoint onwards.
|
|
120
|
+
*/
|
|
121
|
+
const CentredLayoutHeader = React.forwardRef<
|
|
122
|
+
HTMLDivElement,
|
|
123
|
+
CentredLayoutHeaderProps
|
|
124
|
+
>(({ className, children, ...props }, ref) => {
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
ref={ref}
|
|
128
|
+
className={cn(
|
|
129
|
+
"flex w-full items-center justify-center lg:justify-start",
|
|
130
|
+
className
|
|
131
|
+
)}
|
|
132
|
+
data-slot="centred-layout-header"
|
|
133
|
+
{...props}
|
|
134
|
+
>
|
|
135
|
+
{children}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
CentredLayoutHeader.displayName = "CentredLayoutHeader";
|
|
141
|
+
|
|
142
|
+
/* -------------------------------------------------------------------------------------------------
|
|
143
|
+
* CentredLayoutContent
|
|
144
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
145
|
+
|
|
146
|
+
interface CentredLayoutContentProps extends React.ComponentProps<"div"> {
|
|
147
|
+
/**
|
|
148
|
+
* Main content to render inside the centered layout
|
|
149
|
+
*/
|
|
150
|
+
children: React.ReactNode;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* CentredLayoutContent component for rendering the main content area of CentredLayout.
|
|
155
|
+
*/
|
|
156
|
+
const CentredLayoutContent = React.forwardRef<
|
|
157
|
+
HTMLDivElement,
|
|
158
|
+
CentredLayoutContentProps
|
|
159
|
+
>(({ className, children, ...props }, ref) => {
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
ref={ref}
|
|
163
|
+
className={cn(
|
|
164
|
+
"flex flex-1 flex-col items-center justify-center",
|
|
165
|
+
className
|
|
166
|
+
)}
|
|
167
|
+
data-slot="centred-layout-content"
|
|
168
|
+
{...props}
|
|
169
|
+
>
|
|
170
|
+
{children}
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
CentredLayoutContent.displayName = "CentredLayoutContent";
|
|
176
|
+
|
|
177
|
+
/* -------------------------------------------------------------------------------------------------
|
|
178
|
+
* Exports
|
|
179
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
180
|
+
|
|
181
|
+
export { CentredLayout, CentredLayoutHeader, CentredLayoutContent };
|
|
109
182
|
|
|
110
|
-
export type {
|
|
183
|
+
export type {
|
|
184
|
+
CentredLayoutProps,
|
|
185
|
+
CentredLayoutHeaderProps,
|
|
186
|
+
CentredLayoutContentProps,
|
|
187
|
+
};
|
|
@@ -37,8 +37,8 @@ const checkboxVariants = cva(
|
|
|
37
37
|
|
|
38
38
|
export interface CheckboxProps
|
|
39
39
|
extends
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
Omit<React.ComponentProps<typeof CheckboxPrimitive.Root>, "disabled">,
|
|
41
|
+
VariantProps<typeof checkboxVariants> {
|
|
42
42
|
/** Whether the checkbox is disabled */
|
|
43
43
|
disabled?: boolean;
|
|
44
44
|
/** Data hook for automated testing (REQUIRED) */
|