@regardio/react 0.5.5 → 0.6.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/background-slideshow/index.d.mts +36 -0
- package/dist/background-slideshow/index.mjs +110 -0
- package/dist/blurry-gradient/index.d.mts +17 -0
- package/dist/blurry-gradient/index.mjs +93 -0
- package/dist/button/index.d.mts +2 -0
- package/dist/button/index.mjs +3 -0
- package/dist/button-BiSQpBbc.mjs +129 -0
- package/dist/carousel/index.d.mts +40 -0
- package/dist/carousel/index.mjs +141 -0
- package/dist/checkbox/index.d.mts +37 -0
- package/dist/checkbox/index.mjs +70 -0
- package/dist/checkbox-group/index.d.mts +17 -0
- package/dist/checkbox-group/index.mjs +29 -0
- package/dist/chunk-BTpB_u-K.mjs +18 -0
- package/dist/countdown/index.d.mts +6 -0
- package/dist/countdown/index.mjs +58 -0
- package/dist/field/index.d.mts +66 -0
- package/dist/field/index.mjs +115 -0
- package/dist/fieldset/index.d.mts +33 -0
- package/dist/fieldset/index.mjs +61 -0
- package/dist/form/index.d.mts +22 -0
- package/dist/form/index.mjs +31 -0
- package/dist/generic-error/{index.d.ts → index.d.mts} +22 -18
- package/dist/generic-error/index.mjs +57 -0
- package/dist/grid/index.d.mts +1197 -0
- package/dist/grid/index.mjs +221 -0
- package/dist/heading/index.d.mts +31 -0
- package/dist/heading/index.mjs +29 -0
- package/dist/highlight/index.d.mts +18 -0
- package/dist/highlight/index.mjs +35 -0
- package/dist/hooks/{use-current-route-data.d.ts → use-current-route-data.d.mts} +3 -2
- package/dist/hooks/use-current-route-data.mjs +20 -0
- package/dist/hooks/{use-focus-search.d.ts → use-focus-search.d.mts} +4 -3
- package/dist/hooks/use-focus-search.mjs +21 -0
- package/dist/hooks/{use-matches-data.d.ts → use-matches-data.d.mts} +3 -2
- package/dist/hooks/use-matches-data.mjs +21 -0
- package/dist/hooks/{use-media-query.d.ts → use-media-query.d.mts} +3 -2
- package/dist/hooks/use-media-query.mjs +26 -0
- package/dist/hooks/use-mobile.d.mts +4 -0
- package/dist/hooks/use-mobile.mjs +20 -0
- package/dist/hooks/use-nonce.d.mts +8 -0
- package/dist/hooks/use-nonce.mjs +13 -0
- package/dist/hooks/{use-orientation.d.ts → use-orientation.d.mts} +3 -2
- package/dist/hooks/use-orientation.mjs +30 -0
- package/dist/hooks/use-user.d.mts +55 -0
- package/dist/hooks/use-user.mjs +39 -0
- package/dist/icon-button/index.d.mts +29 -0
- package/dist/icon-button/index.mjs +36 -0
- package/dist/if/index.d.mts +15 -0
- package/dist/if/index.mjs +21 -0
- package/dist/iframe/index.d.mts +11 -0
- package/dist/iframe/index.mjs +15 -0
- package/dist/index-Bm-tWhsb.d.mts +30 -0
- package/dist/index-YT2CkvL6.d.mts +36 -0
- package/dist/input/index.d.mts +2 -0
- package/dist/input/index.mjs +3 -0
- package/dist/input-CtR6aRVi.mjs +73 -0
- package/dist/link/index.d.mts +73 -0
- package/dist/link/index.mjs +129 -0
- package/dist/list/index.d.mts +71 -0
- package/dist/list/index.mjs +54 -0
- package/dist/markdown-container/index.d.mts +23 -0
- package/dist/markdown-container/index.mjs +71 -0
- package/dist/password-input/index.d.mts +24 -0
- package/dist/password-input/index.mjs +92 -0
- package/dist/picture/{index.d.ts → index.d.mts} +21 -20
- package/dist/picture/index.mjs +3 -0
- package/dist/picture-DkX3W5zl.mjs +69 -0
- package/dist/protected-email/{index.d.ts → index.d.mts} +14 -8
- package/dist/protected-email/index.mjs +37 -0
- package/dist/radio/index.d.mts +37 -0
- package/dist/radio/index.mjs +72 -0
- package/dist/radio-group/index.d.mts +17 -0
- package/dist/radio-group/index.mjs +29 -0
- package/dist/slider/index.d.mts +85 -0
- package/dist/slider/index.mjs +133 -0
- package/dist/switch/index.d.mts +38 -0
- package/dist/switch/index.mjs +87 -0
- package/dist/text/index.d.mts +26 -0
- package/dist/text/index.mjs +32 -0
- package/dist/text-CPlUND-Z.mjs +58 -0
- package/dist/toggle/index.d.mts +59 -0
- package/dist/toggle/index.mjs +82 -0
- package/dist/utils/author/index.d.mts +4 -0
- package/dist/utils/author/index.mjs +26 -0
- package/dist/utils/text/{index.d.ts → index.d.mts} +4 -3
- package/dist/utils/text/index.mjs +3 -0
- package/package.json +17 -129
- package/src/button/button.stories.tsx +161 -0
- package/src/button/button.test.tsx +73 -0
- package/src/button/button.tsx +112 -0
- package/src/button/index.ts +2 -0
- package/src/carousel/carousel-next.tsx +2 -2
- package/src/carousel/carousel-previous.tsx +2 -2
- package/src/checkbox/checkbox.stories.tsx +118 -0
- package/src/checkbox/checkbox.tsx +91 -0
- package/src/checkbox/index.ts +2 -0
- package/src/checkbox-group/checkbox-group.tsx +40 -0
- package/src/checkbox-group/index.ts +2 -0
- package/src/field/field.stories.tsx +105 -0
- package/src/field/field.test.tsx +61 -0
- package/src/field/field.tsx +165 -0
- package/src/field/index.ts +12 -0
- package/src/fieldset/fieldset.stories.tsx +204 -0
- package/src/fieldset/fieldset.test.tsx +63 -0
- package/src/fieldset/fieldset.tsx +75 -0
- package/src/fieldset/index.ts +7 -0
- package/src/form/form.stories.tsx +230 -0
- package/src/form/form.test.tsx +68 -0
- package/src/form/form.tsx +38 -0
- package/src/form/index.ts +2 -0
- package/src/icon-button/icon-button.stories.tsx +128 -7
- package/src/icon-button/icon-button.test.tsx +152 -0
- package/src/icon-button/icon-button.tsx +43 -9
- package/src/input/index.ts +2 -0
- package/src/input/input.stories.tsx +151 -0
- package/src/input/input.test.tsx +65 -0
- package/src/input/input.tsx +113 -0
- package/src/link/link.test.tsx +169 -0
- package/src/password-input/index.ts +1 -1
- package/src/password-input/password-input.tsx +104 -27
- package/src/radio/index.ts +2 -0
- package/src/radio/radio.tsx +92 -0
- package/src/radio-group/index.ts +2 -0
- package/src/radio-group/radio-group.tsx +36 -0
- package/src/slider/index.ts +18 -0
- package/src/slider/slider.tsx +179 -0
- package/src/switch/index.ts +2 -0
- package/src/switch/switch.stories.tsx +118 -0
- package/src/switch/switch.tsx +101 -0
- package/src/toggle/index.ts +2 -0
- package/src/toggle/toggle.stories.tsx +232 -0
- package/src/toggle/toggle.test.tsx +149 -0
- package/src/toggle/toggle.tsx +88 -0
- package/src/utils/text/text.test.tsx +110 -0
- package/dist/background-slideshow/index.d.ts +0 -24
- package/dist/background-slideshow/index.js +0 -165
- package/dist/blurry-gradient/index.d.ts +0 -16
- package/dist/blurry-gradient/index.js +0 -128
- package/dist/carousel/index.d.ts +0 -36
- package/dist/carousel/index.js +0 -171
- package/dist/countdown/index.d.ts +0 -5
- package/dist/countdown/index.js +0 -73
- package/dist/generic-error/index.js +0 -47
- package/dist/grid/index.d.ts +0 -1196
- package/dist/grid/index.js +0 -239
- package/dist/heading/index.d.ts +0 -24
- package/dist/heading/index.js +0 -99
- package/dist/highlight/index.d.ts +0 -13
- package/dist/highlight/index.js +0 -59
- package/dist/hooks/use-current-route-data.js +0 -16
- package/dist/hooks/use-focus-search.js +0 -19
- package/dist/hooks/use-matches-data.js +0 -15
- package/dist/hooks/use-media-query.js +0 -20
- package/dist/hooks/use-mobile.d.ts +0 -3
- package/dist/hooks/use-mobile.js +0 -19
- package/dist/hooks/use-nonce.d.ts +0 -7
- package/dist/hooks/use-nonce.js +0 -8
- package/dist/hooks/use-orientation.js +0 -29
- package/dist/hooks/use-user.d.ts +0 -50
- package/dist/hooks/use-user.js +0 -25
- package/dist/icon-button/index.d.ts +0 -9
- package/dist/icon-button/index.js +0 -17
- package/dist/if/index.d.ts +0 -10
- package/dist/if/index.js +0 -24
- package/dist/iframe/index.d.ts +0 -10
- package/dist/iframe/index.js +0 -17
- package/dist/link/index.d.ts +0 -55
- package/dist/link/index.js +0 -195
- package/dist/list/index.d.ts +0 -69
- package/dist/list/index.js +0 -65
- package/dist/markdown-container/index.d.ts +0 -22
- package/dist/markdown-container/index.js +0 -128
- package/dist/password-input/index.d.ts +0 -11
- package/dist/password-input/index.js +0 -46
- package/dist/picture/index.js +0 -68
- package/dist/protected-email/index.js +0 -30
- package/dist/text/index.d.ts +0 -20
- package/dist/text/index.js +0 -38
- package/dist/utils/author/index.d.ts +0 -3
- package/dist/utils/author/index.js +0 -33
- package/dist/utils/text/index.js +0 -73
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as react_jsx_runtime23 from "react/jsx-runtime";
|
|
3
|
+
import { CheckboxGroup as CheckboxGroup$1 } from "@base-ui/react/checkbox-group";
|
|
4
|
+
|
|
5
|
+
//#region src/checkbox-group/checkbox-group.d.ts
|
|
6
|
+
type CheckboxGroupOrientation = 'horizontal' | 'vertical';
|
|
7
|
+
interface CheckboxGroupProps extends Omit<ComponentProps<typeof CheckboxGroup$1>, 'className'> {
|
|
8
|
+
className?: string;
|
|
9
|
+
orientation?: CheckboxGroupOrientation;
|
|
10
|
+
}
|
|
11
|
+
declare const CheckboxGroup: ({
|
|
12
|
+
className,
|
|
13
|
+
orientation,
|
|
14
|
+
...props
|
|
15
|
+
}: CheckboxGroupProps) => react_jsx_runtime23.JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CheckboxGroup, type CheckboxGroupOrientation, type CheckboxGroupProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { CheckboxGroup as CheckboxGroup$1 } from "@base-ui/react/checkbox-group";
|
|
4
|
+
|
|
5
|
+
//#region src/checkbox-group/checkbox-group.tsx
|
|
6
|
+
const checkboxGroup = tv({
|
|
7
|
+
base: [
|
|
8
|
+
"flex",
|
|
9
|
+
"flex-col",
|
|
10
|
+
"gap-2"
|
|
11
|
+
],
|
|
12
|
+
defaultVariants: { orientation: "vertical" },
|
|
13
|
+
variants: { orientation: {
|
|
14
|
+
horizontal: ["flex-row", "gap-4"],
|
|
15
|
+
vertical: ["flex-col", "gap-2"]
|
|
16
|
+
} }
|
|
17
|
+
});
|
|
18
|
+
const CheckboxGroup = ({ className, orientation = "vertical", ...props }) => {
|
|
19
|
+
return /* @__PURE__ */ jsx(CheckboxGroup$1, {
|
|
20
|
+
className: checkboxGroup({
|
|
21
|
+
className,
|
|
22
|
+
orientation
|
|
23
|
+
}),
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { CheckboxGroup };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { cn } from "@regardio/tailwind/utils";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/countdown/countdown.tsx
|
|
6
|
+
function Countdown() {
|
|
7
|
+
const [timerValue, setTimerValue] = useState(0);
|
|
8
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setIsMounted(true);
|
|
11
|
+
const intervalId = setInterval(() => {
|
|
12
|
+
setTimerValue((prevValue) => {
|
|
13
|
+
return prevValue + 1;
|
|
14
|
+
});
|
|
15
|
+
}, 1e3);
|
|
16
|
+
return () => {
|
|
17
|
+
return clearInterval(intervalId);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return /* @__PURE__ */ jsx("div", {
|
|
21
|
+
className: cn("before:absolute", "before:bg-white", "before:content-[\"\"]", "before:h-[180px]", "before:rounded-full", "before:w-[180px]", "flex", "h-[240px]", "items-center", "justify-center", "relative", "rounded-full", "w-[240px]"),
|
|
22
|
+
style: { background: `conic-gradient(
|
|
23
|
+
transparent ${6 * (isMounted ? timerValue : 0)}deg,
|
|
24
|
+
hsl(var(--red-500)) 0deg,
|
|
25
|
+
hsl(var(--red-500)) 15deg,
|
|
26
|
+
hsl(var(--coral-500)) 15deg,
|
|
27
|
+
hsl(var(--coral-500)) 45deg,
|
|
28
|
+
hsl(var(--orange-500)) 45deg,
|
|
29
|
+
hsl(var(--orange-500)) 75deg,
|
|
30
|
+
hsl(var(--yellow-500)) 75deg,
|
|
31
|
+
hsl(var(--yellow-500)) 105deg,
|
|
32
|
+
hsl(var(--olive-500)) 105deg,
|
|
33
|
+
hsl(var(--olive-500)) 135deg,
|
|
34
|
+
hsl(var(--lime-500)) 135deg,
|
|
35
|
+
hsl(var(--lime-500)) 165deg,
|
|
36
|
+
hsl(var(--green-500)) 165deg,
|
|
37
|
+
hsl(var(--green-500)) 195deg,
|
|
38
|
+
hsl(var(--teal-500)) 195deg,
|
|
39
|
+
hsl(var(--teal-500)) 225deg,
|
|
40
|
+
hsl(var(--cyan-500)) 225deg,
|
|
41
|
+
hsl(var(--cyan-500)) 255deg,
|
|
42
|
+
hsl(var(--blue-500)) 255deg,
|
|
43
|
+
hsl(var(--blue-500)) 285deg,
|
|
44
|
+
hsl(var(--purple-500)) 285deg,
|
|
45
|
+
hsl(var(--purple-500)) 315deg,
|
|
46
|
+
hsl(var(--pink-500)) 315deg,
|
|
47
|
+
hsl(var(--pink-500)) 345deg,
|
|
48
|
+
hsl(var(--red-500)) 345deg
|
|
49
|
+
)` },
|
|
50
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
51
|
+
className: cn("text-foreground", "relative", "text-3xl", "font-bold"),
|
|
52
|
+
children: isMounted ? timerValue < 10 ? `0${timerValue}` : timerValue : 0
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { Countdown };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as react2 from "react";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as react_jsx_runtime12 from "react/jsx-runtime";
|
|
4
|
+
import * as _base_ui_react_field0 from "@base-ui/react/field";
|
|
5
|
+
import { Field as Field$1 } from "@base-ui/react/field";
|
|
6
|
+
|
|
7
|
+
//#region src/field/field.d.ts
|
|
8
|
+
declare const fieldRootVariants: {
|
|
9
|
+
readonly default: readonly [];
|
|
10
|
+
readonly required: readonly ["after:content-[\"*\"]", "after:ml-1", "after:text-red-500"];
|
|
11
|
+
};
|
|
12
|
+
type FieldRootVariant = keyof typeof fieldRootVariants;
|
|
13
|
+
type FieldLabelVariant = 'default' | 'error';
|
|
14
|
+
type FieldDescriptionVariant = 'default' | 'error';
|
|
15
|
+
type FieldItemLayout = 'default' | 'horizontal';
|
|
16
|
+
interface FieldRootProps extends Omit<ComponentProps<typeof Field$1.Root>, 'className'> {
|
|
17
|
+
className?: string;
|
|
18
|
+
variant?: FieldRootVariant;
|
|
19
|
+
}
|
|
20
|
+
interface FieldLabelProps extends Omit<ComponentProps<typeof Field$1.Label>, 'className'> {
|
|
21
|
+
className?: string;
|
|
22
|
+
variant?: FieldLabelVariant;
|
|
23
|
+
}
|
|
24
|
+
interface FieldDescriptionProps extends Omit<ComponentProps<typeof Field$1.Description>, 'className'> {
|
|
25
|
+
className?: string;
|
|
26
|
+
variant?: FieldDescriptionVariant;
|
|
27
|
+
}
|
|
28
|
+
interface FieldErrorProps extends Omit<ComponentProps<typeof Field$1.Error>, 'className'> {
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
interface FieldItemProps extends ComponentProps<'div'> {
|
|
32
|
+
className?: string;
|
|
33
|
+
layout?: FieldItemLayout;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare const Field: {
|
|
37
|
+
Control: react2.ForwardRefExoticComponent<_base_ui_react_field0.FieldControlProps & react2.RefAttributes<HTMLInputElement>>;
|
|
38
|
+
Description: ({
|
|
39
|
+
className,
|
|
40
|
+
variant,
|
|
41
|
+
...props
|
|
42
|
+
}: FieldDescriptionProps) => react_jsx_runtime12.JSX.Element;
|
|
43
|
+
Error: ({
|
|
44
|
+
className,
|
|
45
|
+
...props
|
|
46
|
+
}: FieldErrorProps) => react_jsx_runtime12.JSX.Element;
|
|
47
|
+
Item: ({
|
|
48
|
+
className,
|
|
49
|
+
layout,
|
|
50
|
+
children,
|
|
51
|
+
...props
|
|
52
|
+
}: FieldItemProps) => react_jsx_runtime12.JSX.Element;
|
|
53
|
+
Label: ({
|
|
54
|
+
className,
|
|
55
|
+
variant,
|
|
56
|
+
...props
|
|
57
|
+
}: FieldLabelProps) => react_jsx_runtime12.JSX.Element;
|
|
58
|
+
Root: ({
|
|
59
|
+
className,
|
|
60
|
+
variant,
|
|
61
|
+
...props
|
|
62
|
+
}: FieldRootProps) => react_jsx_runtime12.JSX.Element;
|
|
63
|
+
Validity: react2.FC<_base_ui_react_field0.FieldValidityProps>;
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { Field, type FieldDescriptionProps, type FieldDescriptionVariant, type FieldErrorProps, type FieldItemLayout, type FieldItemProps, type FieldLabelProps, type FieldLabelVariant, type FieldRootProps, type FieldRootVariant };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Field as Field$1 } from "@base-ui/react/field";
|
|
4
|
+
|
|
5
|
+
//#region src/field/field.tsx
|
|
6
|
+
const fieldRoot = tv({
|
|
7
|
+
base: ["space-y-1"],
|
|
8
|
+
defaultVariants: { variant: "default" },
|
|
9
|
+
variants: { variant: {
|
|
10
|
+
default: [],
|
|
11
|
+
required: [
|
|
12
|
+
"after:content-[\"*\"]",
|
|
13
|
+
"after:ml-1",
|
|
14
|
+
"after:text-red-500"
|
|
15
|
+
]
|
|
16
|
+
} }
|
|
17
|
+
});
|
|
18
|
+
const fieldLabel = tv({
|
|
19
|
+
base: [
|
|
20
|
+
"block",
|
|
21
|
+
"text-sm",
|
|
22
|
+
"font-medium",
|
|
23
|
+
"text-gray-700",
|
|
24
|
+
"mb-1"
|
|
25
|
+
],
|
|
26
|
+
defaultVariants: { variant: "default" },
|
|
27
|
+
variants: { variant: {
|
|
28
|
+
default: [],
|
|
29
|
+
error: ["text-red-600"]
|
|
30
|
+
} }
|
|
31
|
+
});
|
|
32
|
+
const fieldDescription = tv({
|
|
33
|
+
base: [
|
|
34
|
+
"text-sm",
|
|
35
|
+
"text-gray-500",
|
|
36
|
+
"mt-1"
|
|
37
|
+
],
|
|
38
|
+
defaultVariants: { variant: "default" },
|
|
39
|
+
variants: { variant: {
|
|
40
|
+
default: [],
|
|
41
|
+
error: ["text-red-600"]
|
|
42
|
+
} }
|
|
43
|
+
});
|
|
44
|
+
const fieldError = tv({ base: [
|
|
45
|
+
"text-sm",
|
|
46
|
+
"text-red-600",
|
|
47
|
+
"mt-1"
|
|
48
|
+
] });
|
|
49
|
+
const fieldItem = tv({
|
|
50
|
+
base: ["flex", "flex-col"],
|
|
51
|
+
defaultVariants: { layout: "default" },
|
|
52
|
+
variants: { layout: {
|
|
53
|
+
default: [],
|
|
54
|
+
horizontal: [
|
|
55
|
+
"flex-row",
|
|
56
|
+
"items-center",
|
|
57
|
+
"gap-2"
|
|
58
|
+
]
|
|
59
|
+
} }
|
|
60
|
+
});
|
|
61
|
+
const FieldRoot = ({ className, variant, ...props }) => {
|
|
62
|
+
return /* @__PURE__ */ jsx(Field$1.Root, {
|
|
63
|
+
className: fieldRoot({
|
|
64
|
+
className,
|
|
65
|
+
variant
|
|
66
|
+
}),
|
|
67
|
+
...props
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const FieldLabel = ({ className, variant, ...props }) => {
|
|
71
|
+
return /* @__PURE__ */ jsx(Field$1.Label, {
|
|
72
|
+
className: fieldLabel({
|
|
73
|
+
className,
|
|
74
|
+
variant
|
|
75
|
+
}),
|
|
76
|
+
...props
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const FieldDescription = ({ className, variant, ...props }) => {
|
|
80
|
+
return /* @__PURE__ */ jsx(Field$1.Description, {
|
|
81
|
+
className: fieldDescription({
|
|
82
|
+
className,
|
|
83
|
+
variant
|
|
84
|
+
}),
|
|
85
|
+
...props
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const FieldError = ({ className, ...props }) => {
|
|
89
|
+
return /* @__PURE__ */ jsx(Field$1.Error, {
|
|
90
|
+
className: fieldError({ className }),
|
|
91
|
+
...props
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const FieldItem = ({ className, layout, children, ...props }) => {
|
|
95
|
+
return /* @__PURE__ */ jsx("div", {
|
|
96
|
+
className: fieldItem({
|
|
97
|
+
className,
|
|
98
|
+
layout
|
|
99
|
+
}),
|
|
100
|
+
...props,
|
|
101
|
+
children
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const Field = {
|
|
105
|
+
Control: Field$1.Control,
|
|
106
|
+
Description: FieldDescription,
|
|
107
|
+
Error: FieldError,
|
|
108
|
+
Item: FieldItem,
|
|
109
|
+
Label: FieldLabel,
|
|
110
|
+
Root: FieldRoot,
|
|
111
|
+
Validity: Field$1.Validity
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { Field };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
3
|
+
import { Fieldset as Fieldset$1 } from "@base-ui/react/fieldset";
|
|
4
|
+
|
|
5
|
+
//#region src/fieldset/fieldset.d.ts
|
|
6
|
+
declare const fieldsetRootVariants: {
|
|
7
|
+
readonly compact: readonly ["space-y-2"];
|
|
8
|
+
readonly default: readonly ["space-y-4"];
|
|
9
|
+
};
|
|
10
|
+
type FieldsetRootVariant = keyof typeof fieldsetRootVariants;
|
|
11
|
+
type FieldsetLegendSize = 'default' | 'small';
|
|
12
|
+
interface FieldsetRootProps extends Omit<ComponentProps<typeof Fieldset$1.Root>, 'className'> {
|
|
13
|
+
className?: string;
|
|
14
|
+
variant?: FieldsetRootVariant;
|
|
15
|
+
}
|
|
16
|
+
interface FieldsetLegendProps extends Omit<ComponentProps<typeof Fieldset$1.Legend>, 'className'> {
|
|
17
|
+
className?: string;
|
|
18
|
+
size?: FieldsetLegendSize;
|
|
19
|
+
}
|
|
20
|
+
declare const Fieldset: {
|
|
21
|
+
Legend: ({
|
|
22
|
+
className,
|
|
23
|
+
size,
|
|
24
|
+
...props
|
|
25
|
+
}: FieldsetLegendProps) => react_jsx_runtime1.JSX.Element;
|
|
26
|
+
Root: ({
|
|
27
|
+
className,
|
|
28
|
+
variant,
|
|
29
|
+
...props
|
|
30
|
+
}: FieldsetRootProps) => react_jsx_runtime1.JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Fieldset, type FieldsetLegendProps, type FieldsetLegendSize, type FieldsetRootProps, type FieldsetRootVariant };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fieldset as Fieldset$1 } from "@base-ui/react/fieldset";
|
|
4
|
+
|
|
5
|
+
//#region src/fieldset/fieldset.tsx
|
|
6
|
+
const fieldsetRoot = tv({
|
|
7
|
+
base: [
|
|
8
|
+
"border",
|
|
9
|
+
"border-gray-200",
|
|
10
|
+
"rounded-lg",
|
|
11
|
+
"p-4"
|
|
12
|
+
],
|
|
13
|
+
defaultVariants: { variant: "default" },
|
|
14
|
+
variants: { variant: {
|
|
15
|
+
compact: ["space-y-2"],
|
|
16
|
+
default: ["space-y-4"]
|
|
17
|
+
} }
|
|
18
|
+
});
|
|
19
|
+
const fieldsetLegend = tv({
|
|
20
|
+
base: [
|
|
21
|
+
"text-lg",
|
|
22
|
+
"font-semibold",
|
|
23
|
+
"text-gray-900",
|
|
24
|
+
"mb-2"
|
|
25
|
+
],
|
|
26
|
+
defaultVariants: { size: "default" },
|
|
27
|
+
variants: { size: {
|
|
28
|
+
default: [],
|
|
29
|
+
small: [
|
|
30
|
+
"text-base",
|
|
31
|
+
"font-medium",
|
|
32
|
+
"text-gray-900",
|
|
33
|
+
"mb-1"
|
|
34
|
+
]
|
|
35
|
+
} }
|
|
36
|
+
});
|
|
37
|
+
const FieldsetRoot = ({ className, variant, ...props }) => {
|
|
38
|
+
return /* @__PURE__ */ jsx(Fieldset$1.Root, {
|
|
39
|
+
className: fieldsetRoot({
|
|
40
|
+
className,
|
|
41
|
+
variant
|
|
42
|
+
}),
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const FieldsetLegend = ({ className, size, ...props }) => {
|
|
47
|
+
return /* @__PURE__ */ jsx(Fieldset$1.Legend, {
|
|
48
|
+
className: fieldsetLegend({
|
|
49
|
+
className,
|
|
50
|
+
size
|
|
51
|
+
}),
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const Fieldset = {
|
|
56
|
+
Legend: FieldsetLegend,
|
|
57
|
+
Root: FieldsetRoot
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { Fieldset };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as react_jsx_runtime30 from "react/jsx-runtime";
|
|
3
|
+
import { Form as Form$1 } from "@base-ui/react/form";
|
|
4
|
+
|
|
5
|
+
//#region src/form/form.d.ts
|
|
6
|
+
declare const formVariants: {
|
|
7
|
+
readonly compact: readonly ["space-y-4"];
|
|
8
|
+
readonly default: readonly ["space-y-6"];
|
|
9
|
+
readonly inline: readonly ["flex", "flex-wrap", "gap-4", "items-end"];
|
|
10
|
+
};
|
|
11
|
+
type FormVariant = keyof typeof formVariants;
|
|
12
|
+
interface FormProps extends Omit<ComponentProps<typeof Form$1>, 'className'> {
|
|
13
|
+
className?: string;
|
|
14
|
+
variant?: FormVariant;
|
|
15
|
+
}
|
|
16
|
+
declare const Form: ({
|
|
17
|
+
className,
|
|
18
|
+
variant,
|
|
19
|
+
...props
|
|
20
|
+
}: FormProps) => react_jsx_runtime30.JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Form, type FormProps, type FormVariant };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Form as Form$1 } from "@base-ui/react/form";
|
|
4
|
+
|
|
5
|
+
//#region src/form/form.tsx
|
|
6
|
+
const form = tv({
|
|
7
|
+
base: [],
|
|
8
|
+
defaultVariants: { variant: "default" },
|
|
9
|
+
variants: { variant: {
|
|
10
|
+
compact: ["space-y-4"],
|
|
11
|
+
default: ["space-y-6"],
|
|
12
|
+
inline: [
|
|
13
|
+
"flex",
|
|
14
|
+
"flex-wrap",
|
|
15
|
+
"gap-4",
|
|
16
|
+
"items-end"
|
|
17
|
+
]
|
|
18
|
+
} }
|
|
19
|
+
});
|
|
20
|
+
const Form = ({ className, variant, ...props }) => {
|
|
21
|
+
return /* @__PURE__ */ jsx(Form$1, {
|
|
22
|
+
className: form({
|
|
23
|
+
className,
|
|
24
|
+
variant
|
|
25
|
+
}),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Form };
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { ReactElement } from
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/generic-error/generic-error.d.ts
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Descriptor returned from getErrorDescriptor to help apps localize messages.
|
|
5
7
|
*/
|
|
6
8
|
type ErrorDescriptor = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
type: 'http';
|
|
10
|
+
status: number;
|
|
11
|
+
statusText: string;
|
|
12
|
+
defaultId: string;
|
|
13
|
+
defaultMessage: string;
|
|
12
14
|
} | {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
type: 'error';
|
|
16
|
+
defaultId: string;
|
|
17
|
+
defaultMessage: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
stack?: string;
|
|
18
20
|
} | {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
type: 'unknown';
|
|
22
|
+
defaultId: string;
|
|
23
|
+
defaultMessage: string;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
26
|
* Compute a normalized error descriptor from a React Router error.
|
|
@@ -36,8 +38,10 @@ declare function getErrorDescriptor(error: unknown): ErrorDescriptor;
|
|
|
36
38
|
* - Wrap this component and use `getErrorDescriptor(useRouteError())` to map to i18n keys
|
|
37
39
|
* - Or provide a custom `renderMessage` to override the displayed details
|
|
38
40
|
*/
|
|
39
|
-
declare function GenericError({
|
|
40
|
-
|
|
41
|
+
declare function GenericError({
|
|
42
|
+
renderMessage
|
|
43
|
+
}?: {
|
|
44
|
+
renderMessage?: (descriptor: ErrorDescriptor) => ReactElement;
|
|
41
45
|
}): ReactElement;
|
|
42
|
-
|
|
43
|
-
export { type ErrorDescriptor, GenericError, getErrorDescriptor };
|
|
46
|
+
//#endregion
|
|
47
|
+
export { type ErrorDescriptor, GenericError, getErrorDescriptor };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isRouteErrorResponse, useRouteError } from "react-router";
|
|
3
|
+
|
|
4
|
+
//#region src/generic-error/generic-error.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Compute a normalized error descriptor from a React Router error.
|
|
7
|
+
* Apps can use this to map to i18n keys.
|
|
8
|
+
*/
|
|
9
|
+
function getErrorDescriptor(error) {
|
|
10
|
+
if (isRouteErrorResponse(error)) {
|
|
11
|
+
const status = error.status;
|
|
12
|
+
const statusText = error.statusText || "Error";
|
|
13
|
+
return {
|
|
14
|
+
defaultId: status === 404 ? "errors.404" : "errors.http",
|
|
15
|
+
defaultMessage: status === 404 ? "Not found" : `Error ${status}`,
|
|
16
|
+
status,
|
|
17
|
+
statusText,
|
|
18
|
+
type: "http"
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (error instanceof Error) return {
|
|
22
|
+
defaultId: "errors.runtime",
|
|
23
|
+
defaultMessage: "An unexpected error occurred.",
|
|
24
|
+
message: error.message,
|
|
25
|
+
type: "error",
|
|
26
|
+
...error.stack ? { stack: error.stack } : {}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
defaultId: "errors.unknown",
|
|
30
|
+
defaultMessage: "An unexpected error occurred.",
|
|
31
|
+
type: "unknown"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* GenericError
|
|
36
|
+
*
|
|
37
|
+
* A reusable error boundary component for React Router apps.
|
|
38
|
+
* - Displays status-based messages for route responses
|
|
39
|
+
* - Shows stack traces in development for non-response errors
|
|
40
|
+
*
|
|
41
|
+
* For localization, apps may either:
|
|
42
|
+
* - Wrap this component and use `getErrorDescriptor(useRouteError())` to map to i18n keys
|
|
43
|
+
* - Or provide a custom `renderMessage` to override the displayed details
|
|
44
|
+
*/
|
|
45
|
+
function GenericError({ renderMessage } = {}) {
|
|
46
|
+
const descriptor = getErrorDescriptor(useRouteError());
|
|
47
|
+
return /* @__PURE__ */ jsxs("main", {
|
|
48
|
+
className: "pt-2xl p-sm container mx-auto",
|
|
49
|
+
children: [/* @__PURE__ */ jsx("h1", { children: descriptor.type === "http" ? `Error ${descriptor.status}` : "Error" }), renderMessage ? renderMessage(descriptor) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", { children: descriptor.type === "http" ? descriptor.defaultMessage : descriptor.type === "error" ? descriptor.message || descriptor.defaultMessage : descriptor.defaultMessage }), import.meta.env.DEV && descriptor.type === "error" && descriptor.stack && /* @__PURE__ */ jsx("pre", {
|
|
50
|
+
className: "w-full p-sm overflow-x-auto",
|
|
51
|
+
children: /* @__PURE__ */ jsx("code", { children: descriptor.stack })
|
|
52
|
+
})] })]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { GenericError, getErrorDescriptor };
|