@satoshibits/react-json-schema-builder 1.1.2 → 1.1.3
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/index.cjs14.js +1 -1
- package/dist/index.cjs16.js +1 -1
- package/dist/index.cjs21.js +1 -1
- package/dist/index.cjs21.js.map +1 -1
- package/dist/index.cjs31.js +1 -1
- package/dist/index.cjs34.js +1 -1
- package/dist/index.cjs36.js +1 -1
- package/dist/index.cjs37.js +1 -1
- package/dist/index.cjs37.js.map +1 -1
- package/dist/index.cjs38.js +1 -6
- package/dist/index.cjs38.js.map +1 -1
- package/dist/index.cjs39.js +1 -6
- package/dist/index.cjs39.js.map +1 -1
- package/dist/index.cjs40.js +1 -6
- package/dist/index.cjs40.js.map +1 -1
- package/dist/index.cjs41.js +1 -1
- package/dist/index.cjs41.js.map +1 -1
- package/dist/index.cjs42.js +1 -1
- package/dist/index.cjs42.js.map +1 -1
- package/dist/index.cjs43.js +1 -1
- package/dist/index.cjs43.js.map +1 -1
- package/dist/index.cjs44.js +6 -1
- package/dist/index.cjs44.js.map +1 -1
- package/dist/index.cjs45.js +6 -1
- package/dist/index.cjs45.js.map +1 -1
- package/dist/index.cjs46.js +6 -1
- package/dist/index.cjs46.js.map +1 -1
- package/dist/index.cjs47.js +1 -1
- package/dist/index.cjs55.js +5 -1
- package/dist/index.cjs55.js.map +1 -1
- package/dist/index.cjs56.js +1 -1
- package/dist/index.cjs56.js.map +1 -1
- package/dist/index.cjs57.js +1 -1
- package/dist/index.cjs57.js.map +1 -1
- package/dist/index.cjs58.js +1 -1
- package/dist/index.cjs58.js.map +1 -1
- package/dist/index.cjs59.js +1 -1
- package/dist/index.cjs59.js.map +1 -1
- package/dist/index.cjs60.js +1 -1
- package/dist/index.cjs60.js.map +1 -1
- package/dist/index.cjs61.js +1 -1
- package/dist/index.cjs61.js.map +1 -1
- package/dist/index.cjs62.js +1 -1
- package/dist/index.cjs62.js.map +1 -1
- package/dist/index.cjs63.js +1 -1
- package/dist/index.cjs63.js.map +1 -1
- package/dist/index.cjs64.js +1 -1
- package/dist/index.cjs64.js.map +1 -1
- package/dist/index.cjs65.js +1 -1
- package/dist/index.cjs65.js.map +1 -1
- package/dist/index.cjs66.js +1 -1
- package/dist/index.cjs66.js.map +1 -1
- package/dist/index.cjs67.js +1 -1
- package/dist/index.cjs67.js.map +1 -1
- package/dist/index.cjs68.js +1 -1
- package/dist/index.cjs68.js.map +1 -1
- package/dist/index.cjs69.js +1 -1
- package/dist/index.cjs69.js.map +1 -1
- package/dist/index.cjs70.js +1 -1
- package/dist/index.cjs70.js.map +1 -1
- package/dist/index.cjs71.js +1 -1
- package/dist/index.cjs71.js.map +1 -1
- package/dist/index.cjs72.js +1 -1
- package/dist/index.cjs72.js.map +1 -1
- package/dist/index.cjs73.js +1 -1
- package/dist/index.cjs73.js.map +1 -1
- package/dist/index.cjs74.js +1 -1
- package/dist/index.cjs74.js.map +1 -1
- package/dist/index.cjs75.js +1 -1
- package/dist/index.cjs75.js.map +1 -1
- package/dist/index.cjs76.js +1 -5
- package/dist/index.cjs76.js.map +1 -1
- package/dist/index.cjs77.js +1 -1
- package/dist/index.cjs77.js.map +1 -1
- package/dist/index.cjs78.js +1 -1
- package/dist/index.cjs78.js.map +1 -1
- package/dist/index.cjs79.js +1 -1
- package/dist/index.cjs79.js.map +1 -1
- package/dist/index.cjs80.js +1 -1
- package/dist/index.cjs80.js.map +1 -1
- package/dist/index.cjs81.js +1 -1
- package/dist/index.cjs81.js.map +1 -1
- package/dist/index.cjs82.js +1 -1
- package/dist/index.cjs82.js.map +1 -1
- package/dist/index.cjs87.js +1 -1
- package/dist/index.cjs89.js +1 -1
- package/dist/index.cjs94.js +1 -38
- package/dist/index.cjs94.js.map +1 -1
- package/dist/index.cjs95.js +38 -1
- package/dist/index.cjs95.js.map +1 -1
- package/dist/index.cjs96.js +1 -1
- package/dist/index.cjs96.js.map +1 -1
- package/dist/index.cjs97.js +1 -1
- package/dist/index.cjs97.js.map +1 -1
- package/dist/index.cjs98.js +1 -1
- package/dist/index.cjs98.js.map +1 -1
- package/dist/index.es14.js +4 -4
- package/dist/index.es16.js +5 -5
- package/dist/index.es21.js +53 -50
- package/dist/index.es21.js.map +1 -1
- package/dist/index.es31.js +1 -1
- package/dist/index.es34.js +1 -1
- package/dist/index.es36.js +7 -7
- package/dist/index.es37.js +97 -815
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +56 -10
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +24 -10
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es40.js +45 -10
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +71 -99
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +56 -52
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +827 -19
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +10 -45
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +10 -86
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +10 -60
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +4 -4
- package/dist/index.es55.js +252 -30
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +21 -6
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +32 -26
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +23 -62
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +6 -29
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es60.js +64 -4
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +29 -24
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +5 -3
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +24 -45
- package/dist/index.es63.js.map +1 -1
- package/dist/index.es64.js +3 -7
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +44 -123
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +7 -14
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +116 -125
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +14 -10
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +127 -209
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es70.js +10 -12
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +215 -7
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +13 -4
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +7 -27
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +3 -49
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +28 -9
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +48 -253
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +8 -21
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +67 -11
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +10 -203
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es80.js +203 -20
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +21 -392
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +386 -61
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es87.js +1 -1
- package/dist/index.es89.js +4 -4
- package/dist/index.es94.js +65 -69
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +68 -8
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +9 -14
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +14 -62
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +61 -64
- package/dist/index.es98.js.map +1 -1
- package/dist/packages/builder/add-dialog.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es41.js
CHANGED
|
@@ -1,117 +1,89 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import u from "
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
function y({
|
|
32
|
-
className: t,
|
|
33
|
-
children: a,
|
|
34
|
-
...s
|
|
35
|
-
}) {
|
|
36
|
-
return /* @__PURE__ */ n(m, { "data-slot": "dialog-portal", children: [
|
|
37
|
-
/* @__PURE__ */ e(p, {}),
|
|
38
|
-
/* @__PURE__ */ n(
|
|
39
|
-
i,
|
|
40
|
-
{
|
|
41
|
-
"data-slot": "dialog-content",
|
|
42
|
-
className: o(
|
|
43
|
-
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
44
|
-
t
|
|
45
|
-
),
|
|
46
|
-
...s,
|
|
47
|
-
children: [
|
|
48
|
-
a,
|
|
49
|
-
/* @__PURE__ */ n(r, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", children: [
|
|
50
|
-
/* @__PURE__ */ e(u, {}),
|
|
51
|
-
/* @__PURE__ */ e("span", { className: "sr-only", children: "Close" })
|
|
52
|
-
] })
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
] });
|
|
57
|
-
}
|
|
58
|
-
function N({ className: t, ...a }) {
|
|
59
|
-
return /* @__PURE__ */ e(
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import { Slot as f } from "./index.es34.js";
|
|
4
|
+
import { FormProvider as u, Controller as F, useFormContext as x, useFormState as I } from "react-hook-form";
|
|
5
|
+
import { cn as a } from "./index.es22.js";
|
|
6
|
+
import { Label as g } from "./index.es15.js";
|
|
7
|
+
const S = u, c = s.createContext(
|
|
8
|
+
{}
|
|
9
|
+
), $ = ({
|
|
10
|
+
...e
|
|
11
|
+
}) => /* @__PURE__ */ m(c.Provider, { value: { name: e.name }, children: /* @__PURE__ */ m(F, { ...e }) }), d = () => {
|
|
12
|
+
const e = s.useContext(c), r = s.useContext(l), { getFieldState: t } = x(), o = I({ name: e.name }), n = t(e.name, o);
|
|
13
|
+
if (!e)
|
|
14
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
15
|
+
const { id: i } = r;
|
|
16
|
+
return {
|
|
17
|
+
id: i,
|
|
18
|
+
name: e.name,
|
|
19
|
+
formItemId: `${i}-form-item`,
|
|
20
|
+
formDescriptionId: `${i}-form-item-description`,
|
|
21
|
+
formMessageId: `${i}-form-item-message`,
|
|
22
|
+
...n
|
|
23
|
+
};
|
|
24
|
+
}, l = s.createContext(
|
|
25
|
+
{}
|
|
26
|
+
);
|
|
27
|
+
function M({ className: e, ...r }) {
|
|
28
|
+
const t = s.useId();
|
|
29
|
+
return /* @__PURE__ */ m(l.Provider, { value: { id: t }, children: /* @__PURE__ */ m(
|
|
60
30
|
"div",
|
|
61
31
|
{
|
|
62
|
-
"data-slot": "
|
|
63
|
-
className:
|
|
64
|
-
...
|
|
32
|
+
"data-slot": "form-item",
|
|
33
|
+
className: a("grid gap-2", e),
|
|
34
|
+
...r
|
|
65
35
|
}
|
|
66
|
-
);
|
|
36
|
+
) });
|
|
67
37
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
38
|
+
function w({
|
|
39
|
+
className: e,
|
|
40
|
+
...r
|
|
41
|
+
}) {
|
|
42
|
+
const { error: t, formItemId: o } = d();
|
|
43
|
+
return /* @__PURE__ */ m(
|
|
44
|
+
g,
|
|
71
45
|
{
|
|
72
|
-
"data-slot": "
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...a
|
|
46
|
+
"data-slot": "form-label",
|
|
47
|
+
"data-error": !!t,
|
|
48
|
+
className: a("data-[error=true]:text-destructive-foreground", e),
|
|
49
|
+
htmlFor: o,
|
|
50
|
+
...r
|
|
78
51
|
}
|
|
79
52
|
);
|
|
80
53
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return /* @__PURE__ */ e(
|
|
86
|
-
d,
|
|
54
|
+
function N({ ...e }) {
|
|
55
|
+
const { error: r, formItemId: t, formDescriptionId: o, formMessageId: n } = d();
|
|
56
|
+
return /* @__PURE__ */ m(
|
|
57
|
+
f,
|
|
87
58
|
{
|
|
88
|
-
"data-slot": "
|
|
89
|
-
|
|
90
|
-
|
|
59
|
+
"data-slot": "form-control",
|
|
60
|
+
id: t,
|
|
61
|
+
"aria-describedby": r ? `${o} ${n}` : `${o}`,
|
|
62
|
+
"aria-invalid": !!r,
|
|
63
|
+
...e
|
|
91
64
|
}
|
|
92
65
|
);
|
|
93
66
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return /* @__PURE__ */ e(
|
|
99
|
-
c,
|
|
67
|
+
function P({ className: e, ...r }) {
|
|
68
|
+
const { error: t, formMessageId: o } = d(), n = t ? String(t?.message ?? "") : r.children;
|
|
69
|
+
return n ? /* @__PURE__ */ m(
|
|
70
|
+
"p",
|
|
100
71
|
{
|
|
101
|
-
"data-slot": "
|
|
102
|
-
|
|
103
|
-
|
|
72
|
+
"data-slot": "form-message",
|
|
73
|
+
id: o,
|
|
74
|
+
className: a("text-destructive-foreground text-sm", e),
|
|
75
|
+
...r,
|
|
76
|
+
children: n
|
|
104
77
|
}
|
|
105
|
-
);
|
|
78
|
+
) : null;
|
|
106
79
|
}
|
|
107
80
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
w as DialogTitle
|
|
81
|
+
S as Form,
|
|
82
|
+
N as FormControl,
|
|
83
|
+
$ as FormField,
|
|
84
|
+
M as FormItem,
|
|
85
|
+
w as FormLabel,
|
|
86
|
+
P as FormMessage,
|
|
87
|
+
d as useFormField
|
|
116
88
|
};
|
|
117
89
|
//# sourceMappingURL=index.es41.js.map
|
package/dist/index.es41.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es41.js","sources":["../src/components/ui/
|
|
1
|
+
{"version":3,"file":"index.es41.js","sources":["../src/components/ui/form.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Label } from \"@/components/ui/label\";\n\nconst Form = FormProvider;\n\ninterface FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> {\n name: TName;\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ninterface FormItemContextValue {\n id: string;\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<\"div\">) {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n data-slot=\"form-item\"\n className={cn(\"grid gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n}\n\nfunction FormLabel({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive-foreground\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<\"p\">) {\n const { error, formMessageId } = useFormField();\n\n const body = error ? String(error?.message ?? \"\") : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive-foreground text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n );\n}\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormMessage","body"],"mappings":";;;;;;AAgBA,MAAMA,IAAOC,GASPC,IAAmBC,EAAM;AAAA,EAC7B,CAAA;AACF,GAEMC,IAAY,CAGhB;AAAA,EACA,GAAGC;AACL,MAEK,gBAAAC,EAAAJ,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMG,EAAM,KAAA,GAC9C,UAAA,gBAAAC,EAACC,GAAY,EAAA,GAAGF,EAAO,CAAA,GACzB,GAIEG,IAAe,MAAM;AACnB,QAAAC,IAAeN,EAAM,WAAWD,CAAgB,GAChDQ,IAAcP,EAAM,WAAWQ,CAAe,GAC9C,EAAE,eAAAC,EAAc,IAAIC,EAAe,GACnCC,IAAYC,EAAa,EAAE,MAAMN,EAAa,MAAM,GACpDO,IAAaJ,EAAcH,EAAa,MAAMK,CAAS;AAE7D,MAAI,CAACL;AACG,UAAA,IAAI,MAAM,gDAAgD;AAG5D,QAAA,EAAE,IAAAQ,MAAOP;AAER,SAAA;AAAA,IACL,IAAAO;AAAA,IACA,MAAMR,EAAa;AAAA,IACnB,YAAY,GAAGQ,CAAE;AAAA,IACjB,mBAAmB,GAAGA,CAAE;AAAA,IACxB,eAAe,GAAGA,CAAE;AAAA,IACpB,GAAGD;AAAA,EACL;AACF,GAMML,IAAkBR,EAAM;AAAA,EAC5B,CAAA;AACF;AAEA,SAASe,EAAS,EAAE,WAAAC,GAAW,GAAGd,KAAsC;AAChE,QAAAY,IAAKd,EAAM,MAAM;AAEvB,2BACGQ,EAAgB,UAAhB,EAAyB,OAAO,EAAE,IAAAM,KACjC,UAAA,gBAAAX;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWc,EAAG,cAAcD,CAAS;AAAA,MACpC,GAAGd;AAAA,IAAA;AAAA,EAAA,GAER;AAEJ;AAEA,SAASgB,EAAU;AAAA,EACjB,WAAAF;AAAA,EACA,GAAGd;AACL,GAAqD;AACnD,QAAM,EAAE,OAAAiB,GAAO,YAAAC,EAAW,IAAIf,EAAa;AAGzC,SAAA,gBAAAF;AAAA,IAACkB;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,cAAY,CAAC,CAACF;AAAA,MACd,WAAWF,EAAG,iDAAiDD,CAAS;AAAA,MACxE,SAASI;AAAA,MACR,GAAGlB;AAAA,IAAA;AAAA,EACN;AAEJ;AAEA,SAASoB,EAAY,EAAE,GAAGpB,KAA4C;AACpE,QAAM,EAAE,OAAAiB,GAAO,YAAAC,GAAY,mBAAAG,GAAmB,eAAAC,EAAA,IAC5CnB,EAAa;AAGb,SAAA,gBAAAF;AAAA,IAACsB;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIL;AAAA,MACJ,oBACGD,IAEG,GAAGI,CAAiB,IAAIC,CAAa,KADrC,GAAGD,CAAiB;AAAA,MAG1B,gBAAc,CAAC,CAACJ;AAAA,MACf,GAAGjB;AAAA,IAAA;AAAA,EACN;AAEJ;AAeA,SAASwB,EAAY,EAAE,WAAAV,GAAW,GAAGd,KAAoC;AACvE,QAAM,EAAE,OAAAiB,GAAO,eAAAK,EAAc,IAAInB,EAAa,GAExCsB,IAAOR,IAAQ,OAAOA,GAAO,WAAW,EAAE,IAAIjB,EAAM;AAE1D,SAAKyB,IAKH,gBAAAxB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIqB;AAAA,MACJ,WAAWP,EAAG,uCAAuCD,CAAS;AAAA,MAC7D,GAAGd;AAAA,MAEH,UAAAyB;AAAA,IAAA;AAAA,EACH,IAXO;AAaX;"}
|
package/dist/index.es42.js
CHANGED
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Label as h } from "./index.es15.js";
|
|
3
|
+
import { Input as x } from "./index.es28.js";
|
|
4
|
+
import { InputErrorWrapper as y } from "./index.es29.js";
|
|
5
|
+
import { useState as p } from "react";
|
|
6
|
+
import E from "./index.es30.js";
|
|
7
|
+
const w = ({
|
|
8
|
+
values: t,
|
|
9
|
+
onAddValue: s,
|
|
10
|
+
renderValues: o,
|
|
11
|
+
maxValues: n,
|
|
12
|
+
onRemoveValue: c,
|
|
13
|
+
...u
|
|
10
14
|
}) => {
|
|
11
|
-
const [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
const [i, d] = p(), [l, f] = p();
|
|
16
|
+
return /* @__PURE__ */ m(
|
|
17
|
+
y,
|
|
18
|
+
{
|
|
19
|
+
errorCode: i,
|
|
20
|
+
errorDescription: l,
|
|
21
|
+
showError: !!i,
|
|
22
|
+
className: "space-y-2",
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ e(h, { children: "Add Input" }),
|
|
25
|
+
/* @__PURE__ */ e(
|
|
26
|
+
x,
|
|
27
|
+
{
|
|
28
|
+
...u,
|
|
29
|
+
onKeyDown: (r) => {
|
|
30
|
+
r.key === "Enter" && (r.preventDefault(), r.stopPropagation());
|
|
31
|
+
},
|
|
32
|
+
onKeyUp: (r) => {
|
|
33
|
+
if (r.key === "Enter") {
|
|
34
|
+
if (n && t.length >= n) {
|
|
35
|
+
d("Maximum reached"), f(
|
|
36
|
+
"You have reached the maximum number of values"
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
s?.(r.currentTarget.value), r.currentTarget.value = "";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
o ? o() : /* @__PURE__ */ e("div", { className: "space-x-2 flex", children: t.map((r, a) => /* @__PURE__ */ m(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: "flex items-center text-xs border rounded p-1 w-max mt-2",
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ e("span", { children: r }),
|
|
51
|
+
/* @__PURE__ */ e("button", { onClick: () => c(a), children: /* @__PURE__ */ e(E, { size: 16 }) })
|
|
52
|
+
]
|
|
34
53
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
) }),
|
|
41
|
-
/* @__PURE__ */ t(
|
|
42
|
-
v,
|
|
43
|
-
{
|
|
44
|
-
type: "button",
|
|
45
|
-
variant: "outline",
|
|
46
|
-
size: "icon",
|
|
47
|
-
onClick: d,
|
|
48
|
-
disabled: !n,
|
|
49
|
-
"aria-label": "Add constraint",
|
|
50
|
-
children: /* @__PURE__ */ t(g, { className: "h-4 w-4" })
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
] })
|
|
54
|
+
`${a}-${r}`
|
|
55
|
+
)) })
|
|
56
|
+
]
|
|
57
|
+
}
|
|
54
58
|
);
|
|
55
59
|
};
|
|
56
60
|
export {
|
|
57
|
-
|
|
61
|
+
w as default
|
|
58
62
|
};
|
|
59
63
|
//# sourceMappingURL=index.es42.js.map
|
package/dist/index.es42.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es42.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.es42.js","sources":["../src/components/multi-input.tsx"],"sourcesContent":["import { Label } from \"@/components/ui/label\";\nimport { Input } from \"@/components/ui/input\";\nimport { X } from \"lucide-react\";\nimport { InputErrorWrapper } from \"@/components/input-error\";\nimport { useState } from \"react\";\n\ninterface MultiInputProps {\n renderValues?: () => React.ReactNode;\n values: string[];\n onAddValue: (newVal: string) => void;\n onRemoveValue: (index: number) => void;\n maxValues?: number;\n}\n\nconst MultiInput = ({\n values,\n onAddValue,\n renderValues,\n maxValues,\n onRemoveValue,\n ...props\n}: MultiInputProps &\n Omit<React.ComponentProps<\"input\">, \"value\" | \"onChange\">) => {\n const [primaryError, setPrimaryError] = useState<string>();\n const [errorDescription, setErrorDescription] = useState<string>();\n\n return (\n <InputErrorWrapper\n errorCode={primaryError}\n errorDescription={errorDescription}\n showError={!!primaryError}\n className=\"space-y-2\"\n >\n <Label>Add Input</Label>\n <Input\n {...props}\n onKeyDown={(e) => {\n // Prevent form submission on Enter key press\n if (e.key === \"Enter\") {\n e.preventDefault();\n //prevent bubbling up\n e.stopPropagation();\n }\n }}\n onKeyUp={(e) => {\n // Add value on Enter key press\n if (e.key === \"Enter\") {\n if (maxValues && values.length >= maxValues) {\n setPrimaryError(\"Maximum reached\");\n setErrorDescription(\n \"You have reached the maximum number of values\",\n );\n return;\n }\n onAddValue?.(e.currentTarget.value);\n e.currentTarget.value = \"\";\n }\n }}\n />\n {renderValues ? (\n renderValues()\n ) : (\n <div className=\"space-x-2 flex\">\n {values.map((value, i) => (\n <div\n key={`${i}-${value}`}\n className=\"flex items-center text-xs border rounded p-1 w-max mt-2\"\n >\n <span>{value}</span>\n <button onClick={() => onRemoveValue(i)}>\n <X size={16} />\n </button>\n </div>\n ))}\n </div>\n )}\n </InputErrorWrapper>\n );\n};\n\nexport default MultiInput;\n"],"names":["MultiInput","values","onAddValue","renderValues","maxValues","onRemoveValue","props","primaryError","setPrimaryError","useState","errorDescription","setErrorDescription","jsxs","InputErrorWrapper","jsx","Label","Input","e","value","i","X"],"mappings":";;;;;;AAcA,MAAMA,IAAa,CAAC;AAAA,EAClB,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACL,MACgE;AAC9D,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAiB,GACnD,CAACC,GAAkBC,CAAmB,IAAIF,EAAiB;AAG/D,SAAA,gBAAAG;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWN;AAAA,MACX,kBAAAG;AAAA,MACA,WAAW,CAAC,CAACH;AAAA,MACb,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,gBAAAO,EAACC,KAAM,UAAS,YAAA,CAAA;AAAA,QAChB,gBAAAD;AAAA,UAACE;AAAA,UAAA;AAAA,YACE,GAAGV;AAAA,YACJ,WAAW,CAACW,MAAM;AAEZ,cAAAA,EAAE,QAAQ,YACZA,EAAE,eAAe,GAEjBA,EAAE,gBAAgB;AAAA,YAEtB;AAAA,YACA,SAAS,CAACA,MAAM;AAEV,kBAAAA,EAAE,QAAQ,SAAS;AACjB,oBAAAb,KAAaH,EAAO,UAAUG,GAAW;AAC3C,kBAAAI,EAAgB,iBAAiB,GACjCG;AAAA,oBACE;AAAA,kBACF;AACA;AAAA,gBAAA;AAEW,gBAAAT,IAAAe,EAAE,cAAc,KAAK,GAClCA,EAAE,cAAc,QAAQ;AAAA,cAAA;AAAA,YAC1B;AAAA,UACF;AAAA,QACF;AAAA,QACCd,IACCA,EAAa,IAEZ,gBAAAW,EAAA,OAAA,EAAI,WAAU,kBACZ,UAAOb,EAAA,IAAI,CAACiB,GAAOC,MAClB,gBAAAP;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WAAU;AAAA,YAEV,UAAA;AAAA,cAAA,gBAAAE,EAAC,UAAM,UAAMI,EAAA,CAAA;AAAA,cACb,gBAAAJ,EAAC,UAAO,EAAA,SAAS,MAAMT,EAAcc,CAAC,GACpC,UAAC,gBAAAL,EAAAM,GAAA,EAAE,MAAM,GAAI,CAAA,EACf,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UANK,GAAGD,CAAC,IAAID,CAAK;AAAA,QAAA,CAQrB,EACH,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ;AAEJ;"}
|