@pyck/react 0.0.5 → 0.0.7
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/checkmark-rF75Pk98.js +75 -0
- package/dist/close-button-DAgpEZYq.js +172 -0
- package/dist/components/avatar/index.js +118 -20
- package/dist/components/button/index.js +1 -1
- package/dist/components/carousel/index.js +52 -12
- package/dist/components/checkbox/index.d.ts +1 -1
- package/dist/components/checkbox/index.js +151 -34
- package/dist/components/checkmark/index.js +1 -1
- package/dist/components/clipboard/index.js +3 -2
- package/dist/components/combobox/index.js +46 -9
- package/dist/components/data-list/index.d.ts +3 -2
- package/dist/components/data-list/index.js +23 -8
- package/dist/components/date-picker/index.js +17 -10
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/index.js +156 -95
- package/dist/components/display-date-value/index.d.ts +1 -1
- package/dist/components/display-date-value/index.js +2 -2
- package/dist/components/display-value/index.js +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.js +22 -1
- package/dist/components/drilldown-menu/index.js +268 -87
- package/dist/components/field/index.js +110 -27
- package/dist/components/floating-panel/index.d.ts +1 -1
- package/dist/components/floating-panel/index.js +91 -43
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/form/index.js +142 -26
- package/dist/components/highlight/index.d.ts +1 -1
- package/dist/components/highlight/index.js +63 -14
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/image/index.js +33 -2
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/input/index.js +67 -4
- package/dist/components/input-group/index.js +79 -14
- package/dist/components/json-form-builder/index.d.ts +1 -1
- package/dist/components/json-form-builder/index.js +383 -99
- package/dist/components/loader/index.js +35 -15
- package/dist/components/logo/index.js +97 -19
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/menu/index.js +41 -7
- package/dist/components/number-input/index.d.ts +1 -1
- package/dist/components/number-input/index.js +68 -13
- package/dist/components/page-header/index.js +67 -12
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +52 -13
- package/dist/components/picker/index.js +56 -28
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/popover/index.js +2 -1
- package/dist/components/progress/index.js +57 -23
- package/dist/components/progress-circle/index.js +82 -30
- package/dist/components/radio-group/index.js +60 -19
- package/dist/components/scroll-area/index.js +80 -19
- package/dist/components/segment-group/index.d.ts +1 -1
- package/dist/components/segment-group/index.js +40 -5
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.js +119 -22
- package/dist/components/show/index.js +1 -1
- package/dist/components/skeleton/index.js +55 -4
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +174 -55
- package/dist/components/spotlight/index.js +447 -126
- package/dist/components/steps/index.js +35 -13
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/index.js +210 -43
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.js +435 -67
- package/dist/components/tags-input/index.d.ts +1 -1
- package/dist/components/tags-input/index.js +25 -9
- package/dist/components/textarea/index.d.ts +1 -1
- package/dist/components/textarea/index.js +66 -4
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/index.js +56 -22
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.js +87 -25
- package/dist/components/tree-view/index.d.ts +1 -1
- package/dist/components/tree-view/index.js +64 -8
- package/dist/display-date-value-CSPbdE60.js +45 -0
- package/dist/{display-date-value-CdfgVuB7.d.ts → display-date-value-RbzRgYHt.d.ts} +1 -1
- package/dist/display-value-R2nHrGQo.js +81 -0
- package/dist/{featured-icon-DPysOpSf.js → featured-icon-DBnAKGXC.js} +31 -4
- package/dist/show-B7zG1Vci.js +28 -0
- package/dist/utils/index.js +164 -73
- package/package.json +6 -3
- package/dist/checkmark-CW-yHMvN.js +0 -18
- package/dist/close-button-BM7ikbYh.js +0 -52
- package/dist/display-date-value-gTlidtNz.js +0 -21
- package/dist/display-value-BNKxQ99u.js +0 -37
- package/dist/show-IaI-36v9.js +0 -12
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import { forwardRef } from "react";
|
|
2
3
|
import { ark } from "@ark-ui/react/factory";
|
|
3
4
|
import { createStyleContext } from "@pyck/styled-system/jsx";
|
|
4
5
|
import { inputGroup } from "@pyck/styled-system/recipes";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
7
|
import { Show } from "@pyck/react/show";
|
|
6
8
|
|
|
7
9
|
//#region src/components/input-group/input-group.tsx
|
|
@@ -9,20 +11,83 @@ const { withProvider, withContext } = createStyleContext(inputGroup);
|
|
|
9
11
|
const Root = withProvider(ark.div, "root");
|
|
10
12
|
const Element = withContext(ark.div, "element");
|
|
11
13
|
const InputGroup = forwardRef(function InputGroup(props, ref) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const $ = c(21);
|
|
15
|
+
let children;
|
|
16
|
+
let endElement;
|
|
17
|
+
let rest;
|
|
18
|
+
let startElement;
|
|
19
|
+
if ($[0] !== props) {
|
|
20
|
+
({startElement, endElement, children, ...rest} = props);
|
|
21
|
+
$[0] = props;
|
|
22
|
+
$[1] = children;
|
|
23
|
+
$[2] = endElement;
|
|
24
|
+
$[3] = rest;
|
|
25
|
+
$[4] = startElement;
|
|
26
|
+
} else {
|
|
27
|
+
children = $[1];
|
|
28
|
+
endElement = $[2];
|
|
29
|
+
rest = $[3];
|
|
30
|
+
startElement = $[4];
|
|
31
|
+
}
|
|
32
|
+
let t0;
|
|
33
|
+
if ($[5] !== startElement) {
|
|
34
|
+
t0 = /* @__PURE__ */ jsx(Element, {
|
|
35
|
+
insetInlineStart: "0",
|
|
36
|
+
top: "0",
|
|
37
|
+
children: startElement
|
|
38
|
+
});
|
|
39
|
+
$[5] = startElement;
|
|
40
|
+
$[6] = t0;
|
|
41
|
+
} else t0 = $[6];
|
|
42
|
+
let t1;
|
|
43
|
+
if ($[7] !== startElement || $[8] !== t0) {
|
|
44
|
+
t1 = /* @__PURE__ */ jsx(Show, {
|
|
45
|
+
when: startElement,
|
|
46
|
+
children: t0
|
|
47
|
+
});
|
|
48
|
+
$[7] = startElement;
|
|
49
|
+
$[8] = t0;
|
|
50
|
+
$[9] = t1;
|
|
51
|
+
} else t1 = $[9];
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[10] !== endElement) {
|
|
54
|
+
t2 = /* @__PURE__ */ jsx(Element, {
|
|
55
|
+
insetInlineEnd: "0",
|
|
56
|
+
top: "0",
|
|
57
|
+
children: endElement
|
|
58
|
+
});
|
|
59
|
+
$[10] = endElement;
|
|
60
|
+
$[11] = t2;
|
|
61
|
+
} else t2 = $[11];
|
|
62
|
+
let t3;
|
|
63
|
+
if ($[12] !== endElement || $[13] !== t2) {
|
|
64
|
+
t3 = /* @__PURE__ */ jsx(Show, {
|
|
65
|
+
when: endElement,
|
|
66
|
+
children: t2
|
|
67
|
+
});
|
|
68
|
+
$[12] = endElement;
|
|
69
|
+
$[13] = t2;
|
|
70
|
+
$[14] = t3;
|
|
71
|
+
} else t3 = $[14];
|
|
72
|
+
let t4;
|
|
73
|
+
if ($[15] !== children || $[16] !== ref || $[17] !== rest || $[18] !== t1 || $[19] !== t3) {
|
|
74
|
+
t4 = /* @__PURE__ */ jsxs(Root, {
|
|
75
|
+
ref,
|
|
76
|
+
...rest,
|
|
77
|
+
children: [
|
|
78
|
+
t1,
|
|
79
|
+
children,
|
|
80
|
+
t3
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
$[15] = children;
|
|
84
|
+
$[16] = ref;
|
|
85
|
+
$[17] = rest;
|
|
86
|
+
$[18] = t1;
|
|
87
|
+
$[19] = t3;
|
|
88
|
+
$[20] = t4;
|
|
89
|
+
} else t4 = $[20];
|
|
90
|
+
return t4;
|
|
26
91
|
});
|
|
27
92
|
|
|
28
93
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ZodTypeAny, z } from "zod";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
import { FieldValues, UseFormReturn } from "react-hook-form";
|
|
4
5
|
import { CollectionItem } from "@ark-ui/react";
|
|
5
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/json-form-builder/types.d.ts
|
|
8
8
|
interface LayoutNode {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { P, match } from "ts-pattern";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { Fragment } from "react";
|
|
4
5
|
import { Box, HStack, Stack } from "@pyck/styled-system/jsx";
|
|
5
|
-
import {
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { CheckboxField } from "@pyck/react/checkbox";
|
|
7
8
|
import { Field } from "@pyck/react/field";
|
|
8
9
|
import { Controller, FormProvider, useForm, useFormContext } from "react-hook-form";
|
|
10
|
+
import { capitalize } from "@pyck/react/utils";
|
|
9
11
|
import { Portal } from "@ark-ui/react/portal";
|
|
10
12
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
11
13
|
import { Form } from "@pyck/react/form";
|
|
@@ -18,68 +20,184 @@ import { SelectField } from "@pyck/react/select";
|
|
|
18
20
|
import { TagsInput } from "@pyck/react/tags-input";
|
|
19
21
|
|
|
20
22
|
//#region src/components/json-form-builder/components/combobox-from-items.tsx
|
|
21
|
-
const ComboboxFromItems = (
|
|
22
|
-
const
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const ComboboxFromItems = (t0) => {
|
|
24
|
+
const $ = c(14);
|
|
25
|
+
const { name, label, helperText, items, required } = t0;
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t1 = { sensitivity: "base" };
|
|
29
|
+
$[0] = t1;
|
|
30
|
+
} else t1 = $[0];
|
|
31
|
+
const { contains } = useFilter(t1);
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[1] !== contains || $[2] !== items) {
|
|
34
|
+
t2 = {
|
|
35
|
+
initialItems: items,
|
|
36
|
+
filter: contains
|
|
37
|
+
};
|
|
38
|
+
$[1] = contains;
|
|
39
|
+
$[2] = items;
|
|
40
|
+
$[3] = t2;
|
|
41
|
+
} else t2 = $[3];
|
|
42
|
+
const { collection, filter } = useListCollection$1(t2);
|
|
27
43
|
const { control } = useFormContext();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
let t3;
|
|
45
|
+
if ($[4] !== collection || $[5] !== filter || $[6] !== helperText || $[7] !== label || $[8] !== required) {
|
|
46
|
+
t3 = (t4) => {
|
|
47
|
+
const { field, fieldState } = t4;
|
|
48
|
+
return /* @__PURE__ */ jsx(Field, {
|
|
49
|
+
label,
|
|
50
|
+
helperText,
|
|
51
|
+
invalid: !!fieldState.error,
|
|
52
|
+
errorText: fieldState.error?.message,
|
|
53
|
+
required,
|
|
54
|
+
children: /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
55
|
+
name: field.name,
|
|
56
|
+
multiple: true,
|
|
57
|
+
collection,
|
|
58
|
+
onInputValueChange: (e) => filter(e.inputValue),
|
|
59
|
+
value: field.value ?? [],
|
|
60
|
+
onValueChange: (e_0) => field.onChange(e_0.value),
|
|
61
|
+
disabled: field.disabled,
|
|
62
|
+
invalid: !!fieldState.error,
|
|
63
|
+
children: [/* @__PURE__ */ jsxs(Combobox.Control, { children: [/* @__PURE__ */ jsx(Combobox.Input, {
|
|
64
|
+
placeholder: "Search...",
|
|
65
|
+
onBlur: field.onBlur
|
|
66
|
+
}), /* @__PURE__ */ jsxs(Combobox.IndicatorGroup, { children: [/* @__PURE__ */ jsx(Combobox.ClearTrigger, {}), /* @__PURE__ */ jsx(Combobox.Trigger, {})] })] }), /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, { children: /* @__PURE__ */ jsxs(Combobox.Content, { children: [/* @__PURE__ */ jsx(Combobox.Empty, { children: "No results found" }), collection.items.map(_temp$2)] }) }) })]
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
$[4] = collection;
|
|
71
|
+
$[5] = filter;
|
|
72
|
+
$[6] = helperText;
|
|
73
|
+
$[7] = label;
|
|
74
|
+
$[8] = required;
|
|
75
|
+
$[9] = t3;
|
|
76
|
+
} else t3 = $[9];
|
|
77
|
+
let t4;
|
|
78
|
+
if ($[10] !== control || $[11] !== name || $[12] !== t3) {
|
|
79
|
+
t4 = /* @__PURE__ */ jsx(Controller, {
|
|
80
|
+
name,
|
|
81
|
+
control,
|
|
82
|
+
render: t3
|
|
83
|
+
});
|
|
84
|
+
$[10] = control;
|
|
85
|
+
$[11] = name;
|
|
86
|
+
$[12] = t3;
|
|
87
|
+
$[13] = t4;
|
|
88
|
+
} else t4 = $[13];
|
|
89
|
+
return t4;
|
|
90
|
+
};
|
|
91
|
+
function _temp$2(item) {
|
|
92
|
+
return /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
93
|
+
item,
|
|
94
|
+
children: [/* @__PURE__ */ jsx(Combobox.ItemText, { children: item.label }), /* @__PURE__ */ jsx(Combobox.ItemIndicator, {})]
|
|
95
|
+
}, item.value);
|
|
96
|
+
}
|
|
53
97
|
|
|
54
98
|
//#endregion
|
|
55
99
|
//#region src/components/json-form-builder/components/select-field-from-items.tsx
|
|
56
|
-
const SelectFieldFromItems = (
|
|
57
|
-
const
|
|
100
|
+
const SelectFieldFromItems = (t0) => {
|
|
101
|
+
const $ = c(12);
|
|
102
|
+
const { name, label, helperText, placeholder, items, required } = t0;
|
|
103
|
+
let t1;
|
|
104
|
+
if ($[0] !== items) {
|
|
105
|
+
t1 = { initialItems: items };
|
|
106
|
+
$[0] = items;
|
|
107
|
+
$[1] = t1;
|
|
108
|
+
} else t1 = $[1];
|
|
109
|
+
const { collection } = useListCollection(t1);
|
|
58
110
|
if (items.length === 0) return null;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
111
|
+
const t2 = placeholder ?? `Select ${label}`;
|
|
112
|
+
let t3;
|
|
113
|
+
if ($[2] !== items) {
|
|
114
|
+
t3 = items.map(_temp$1);
|
|
115
|
+
$[2] = items;
|
|
116
|
+
$[3] = t3;
|
|
117
|
+
} else t3 = $[3];
|
|
118
|
+
let t4;
|
|
119
|
+
if ($[4] !== collection || $[5] !== helperText || $[6] !== label || $[7] !== name || $[8] !== required || $[9] !== t2 || $[10] !== t3) {
|
|
120
|
+
t4 = /* @__PURE__ */ jsx(SelectField.Root, {
|
|
121
|
+
name,
|
|
122
|
+
label,
|
|
123
|
+
helperText,
|
|
124
|
+
placeholder: t2,
|
|
125
|
+
collection,
|
|
126
|
+
multiple: false,
|
|
127
|
+
required,
|
|
128
|
+
children: t3
|
|
129
|
+
});
|
|
130
|
+
$[4] = collection;
|
|
131
|
+
$[5] = helperText;
|
|
132
|
+
$[6] = label;
|
|
133
|
+
$[7] = name;
|
|
134
|
+
$[8] = required;
|
|
135
|
+
$[9] = t2;
|
|
136
|
+
$[10] = t3;
|
|
137
|
+
$[11] = t4;
|
|
138
|
+
} else t4 = $[11];
|
|
139
|
+
return t4;
|
|
65
140
|
};
|
|
141
|
+
function _temp$1(item) {
|
|
142
|
+
return /* @__PURE__ */ jsxs(SelectField.Item, {
|
|
143
|
+
item,
|
|
144
|
+
children: [item.label, /* @__PURE__ */ jsx(SelectField.ItemIndicator, {})]
|
|
145
|
+
}, item.value);
|
|
146
|
+
}
|
|
66
147
|
|
|
67
148
|
//#endregion
|
|
68
149
|
//#region src/components/json-form-builder/components/tags-input-field.tsx
|
|
69
|
-
const TagsInputField = (
|
|
150
|
+
const TagsInputField = (t0) => {
|
|
151
|
+
const $ = c(10);
|
|
152
|
+
const { name, label, helperText, placeholder, required, disabled } = t0;
|
|
70
153
|
const { control } = useFormContext();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
154
|
+
let t1;
|
|
155
|
+
if ($[0] !== disabled || $[1] !== helperText || $[2] !== label || $[3] !== placeholder || $[4] !== required) {
|
|
156
|
+
t1 = (t2) => {
|
|
157
|
+
const { field, fieldState } = t2;
|
|
158
|
+
return /* @__PURE__ */ jsx(Field, {
|
|
159
|
+
label,
|
|
160
|
+
helperText,
|
|
161
|
+
invalid: !!fieldState.error,
|
|
162
|
+
errorText: fieldState.error?.message,
|
|
163
|
+
required,
|
|
164
|
+
disabled: field.disabled || disabled,
|
|
165
|
+
children: /* @__PURE__ */ jsxs(TagsInput.Root, {
|
|
166
|
+
name: field.name,
|
|
167
|
+
value: field.value ?? [],
|
|
168
|
+
onValueChange: (e) => {
|
|
169
|
+
field.onChange(e.value);
|
|
170
|
+
field.onBlur();
|
|
171
|
+
},
|
|
172
|
+
disabled: field.disabled || disabled,
|
|
173
|
+
invalid: !!fieldState.error,
|
|
174
|
+
children: [/* @__PURE__ */ jsxs(TagsInput.Control, { children: [/* @__PURE__ */ jsx(TagsInput.Items, {}), /* @__PURE__ */ jsx(TagsInput.Input, {
|
|
175
|
+
placeholder: placeholder ?? "Add tag...",
|
|
176
|
+
onBlur: field.onBlur
|
|
177
|
+
})] }), /* @__PURE__ */ jsx(TagsInput.HiddenInput, {})]
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
$[0] = disabled;
|
|
182
|
+
$[1] = helperText;
|
|
183
|
+
$[2] = label;
|
|
184
|
+
$[3] = placeholder;
|
|
185
|
+
$[4] = required;
|
|
186
|
+
$[5] = t1;
|
|
187
|
+
} else t1 = $[5];
|
|
188
|
+
let t2;
|
|
189
|
+
if ($[6] !== control || $[7] !== name || $[8] !== t1) {
|
|
190
|
+
t2 = /* @__PURE__ */ jsx(Controller, {
|
|
191
|
+
name,
|
|
192
|
+
control,
|
|
193
|
+
render: t1
|
|
194
|
+
});
|
|
195
|
+
$[6] = control;
|
|
196
|
+
$[7] = name;
|
|
197
|
+
$[8] = t1;
|
|
198
|
+
$[9] = t2;
|
|
199
|
+
} else t2 = $[9];
|
|
200
|
+
return t2;
|
|
83
201
|
};
|
|
84
202
|
|
|
85
203
|
//#endregion
|
|
@@ -100,28 +218,68 @@ const renderField = (schema, key, options) => {
|
|
|
100
218
|
type: "string",
|
|
101
219
|
enum: P.select(P.array(P.string))
|
|
102
220
|
}, (enumValues) => {
|
|
103
|
-
|
|
104
|
-
|
|
221
|
+
return /* @__PURE__ */ jsx(SelectFieldFromItems, {
|
|
222
|
+
name: key,
|
|
223
|
+
label,
|
|
224
|
+
helperText: schema.description ?? "",
|
|
225
|
+
items: toSelectItems(enumValues),
|
|
226
|
+
required
|
|
227
|
+
}, key);
|
|
105
228
|
}).with({
|
|
106
229
|
type: "string",
|
|
107
230
|
oneOf: P.array({ const: P.string })
|
|
108
|
-
}, (s) =>
|
|
231
|
+
}, (s) => /* @__PURE__ */ jsx(SelectFieldFromItems, {
|
|
232
|
+
name: key,
|
|
233
|
+
label,
|
|
234
|
+
helperText,
|
|
235
|
+
items: toSelectItems(s.oneOf.map((e) => e.const)),
|
|
236
|
+
required
|
|
237
|
+
}, key)).with({
|
|
109
238
|
type: "string",
|
|
110
239
|
format: P.optional(P.string),
|
|
111
240
|
maxLength: P.optional(P.number)
|
|
112
|
-
}, (s) =>
|
|
241
|
+
}, (s) => /* @__PURE__ */ jsx(InputField, {
|
|
242
|
+
name: key,
|
|
243
|
+
label,
|
|
244
|
+
helperText,
|
|
245
|
+
type: s.format === "email" || s.format === "date" ? s.format : "text",
|
|
246
|
+
maxLength: s.maxLength,
|
|
247
|
+
required
|
|
248
|
+
}, key)).with({
|
|
113
249
|
type: P.union("number", "integer"),
|
|
114
250
|
minimum: P.optional(P.number),
|
|
115
251
|
maximum: P.optional(P.number)
|
|
116
|
-
}, (s) =>
|
|
252
|
+
}, (s) => /* @__PURE__ */ jsx(NumberInputField, {
|
|
253
|
+
name: key,
|
|
254
|
+
label,
|
|
255
|
+
helperText,
|
|
256
|
+
min: s.minimum,
|
|
257
|
+
max: s.maximum,
|
|
258
|
+
required
|
|
259
|
+
}, key)).with({ type: "boolean" }, () => /* @__PURE__ */ jsx(CheckboxField, {
|
|
260
|
+
name: key,
|
|
261
|
+
label,
|
|
262
|
+
helperText,
|
|
263
|
+
required
|
|
264
|
+
}, key)).with({
|
|
117
265
|
type: "array",
|
|
118
266
|
items: { enum: P.select(P.array(P.string)) }
|
|
119
267
|
}, (enumValues) => {
|
|
120
|
-
return
|
|
268
|
+
return /* @__PURE__ */ jsx(ComboboxFromItems, {
|
|
269
|
+
name: key,
|
|
270
|
+
label,
|
|
271
|
+
items: toSelectItems(enumValues),
|
|
272
|
+
required
|
|
273
|
+
}, key);
|
|
121
274
|
}).with({
|
|
122
275
|
type: "array",
|
|
123
276
|
items: { type: "string" }
|
|
124
|
-
}, () =>
|
|
277
|
+
}, () => /* @__PURE__ */ jsx(TagsInputField, {
|
|
278
|
+
name: key,
|
|
279
|
+
label,
|
|
280
|
+
helperText,
|
|
281
|
+
required
|
|
282
|
+
}, key)).otherwise(() => null);
|
|
125
283
|
};
|
|
126
284
|
|
|
127
285
|
//#endregion
|
|
@@ -240,13 +398,51 @@ const buildZodForProperty = (prop) => {
|
|
|
240
398
|
* <Builder /> renders fields in the order they appear in the schema without layout control.
|
|
241
399
|
* It is intentionally minimal. Use <UiSchemaForm /> if you need structured layouts.
|
|
242
400
|
*/
|
|
243
|
-
const Builder = (
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
401
|
+
const Builder = (t0) => {
|
|
402
|
+
const $ = c(10);
|
|
403
|
+
const { jsonSchema } = t0;
|
|
404
|
+
let t1;
|
|
405
|
+
let t2;
|
|
406
|
+
if ($[0] !== jsonSchema) {
|
|
407
|
+
const zodSchema = createZodSchemaFromJson(jsonSchema);
|
|
408
|
+
t2 = useForm;
|
|
409
|
+
t1 = zodResolver(zodSchema);
|
|
410
|
+
$[0] = jsonSchema;
|
|
411
|
+
$[1] = t1;
|
|
412
|
+
$[2] = t2;
|
|
413
|
+
} else {
|
|
414
|
+
t1 = $[1];
|
|
415
|
+
t2 = $[2];
|
|
416
|
+
}
|
|
417
|
+
let t3;
|
|
418
|
+
if ($[3] !== t1) {
|
|
419
|
+
t3 = { resolver: t1 };
|
|
420
|
+
$[3] = t1;
|
|
421
|
+
$[4] = t3;
|
|
422
|
+
} else t3 = $[4];
|
|
423
|
+
const form = t2(t3);
|
|
424
|
+
let t4;
|
|
425
|
+
if ($[5] !== jsonSchema.properties) {
|
|
426
|
+
t4 = Object.entries(jsonSchema.properties).map(_temp);
|
|
427
|
+
$[5] = jsonSchema.properties;
|
|
428
|
+
$[6] = t4;
|
|
429
|
+
} else t4 = $[6];
|
|
430
|
+
let t5;
|
|
431
|
+
if ($[7] !== form || $[8] !== t4) {
|
|
432
|
+
t5 = /* @__PURE__ */ jsx(Form, {
|
|
433
|
+
value: form,
|
|
434
|
+
children: t4
|
|
435
|
+
});
|
|
436
|
+
$[7] = form;
|
|
437
|
+
$[8] = t4;
|
|
438
|
+
$[9] = t5;
|
|
439
|
+
} else t5 = $[9];
|
|
440
|
+
return t5;
|
|
441
|
+
};
|
|
442
|
+
function _temp(t0) {
|
|
443
|
+
const [key, schema] = t0;
|
|
444
|
+
return renderField(schema, key);
|
|
445
|
+
}
|
|
250
446
|
|
|
251
447
|
//#endregion
|
|
252
448
|
//#region src/components/json-form-builder/utils/scope-resolver.ts
|
|
@@ -297,14 +493,18 @@ const renderNode = (jsonSchema, node) => {
|
|
|
297
493
|
};
|
|
298
494
|
const renderLayoutNode = (jsonSchema, node) => {
|
|
299
495
|
const children = node.nodes.map((child, index) => {
|
|
300
|
-
return
|
|
496
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderNode(jsonSchema, child) }, `layout-${child.type}-${index}`);
|
|
497
|
+
});
|
|
498
|
+
if (node.format === "horizontal") return /* @__PURE__ */ jsx(HStack, {
|
|
499
|
+
gap: "3",
|
|
500
|
+
"data-testid": "layout-horizontal",
|
|
501
|
+
children
|
|
502
|
+
});
|
|
503
|
+
return /* @__PURE__ */ jsx(Stack, {
|
|
504
|
+
gap: "5",
|
|
505
|
+
"data-testid": "layout-vertical",
|
|
506
|
+
children
|
|
301
507
|
});
|
|
302
|
-
if (node.format === "horizontal") return <HStack gap="3" data-testid="layout-horizontal">
|
|
303
|
-
{children}
|
|
304
|
-
</HStack>;
|
|
305
|
-
return <Stack gap="5" data-testid="layout-vertical">
|
|
306
|
-
{children}
|
|
307
|
-
</Stack>;
|
|
308
508
|
};
|
|
309
509
|
const renderFieldNode = (jsonSchema, node) => {
|
|
310
510
|
const resolved = resolveScope(jsonSchema, node.scope);
|
|
@@ -315,32 +515,116 @@ const renderFieldNode = (jsonSchema, node) => {
|
|
|
315
515
|
const required = jsonSchema.required?.includes(resolved.key) ?? false;
|
|
316
516
|
return renderField(resolved.schema, resolved.key, { required });
|
|
317
517
|
};
|
|
318
|
-
const UiSchemaForm = (
|
|
518
|
+
const UiSchemaForm = (t0) => {
|
|
519
|
+
const $ = c(36);
|
|
520
|
+
const { id, value, onSubmit, jsonSchema, uiFieldset, form: providedForm, footer, error } = t0;
|
|
319
521
|
const form = providedForm || value;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
522
|
+
let t1;
|
|
523
|
+
if ($[0] !== form || $[1] !== onSubmit) {
|
|
524
|
+
t1 = form.handleSubmit(onSubmit);
|
|
525
|
+
$[0] = form;
|
|
526
|
+
$[1] = onSubmit;
|
|
527
|
+
$[2] = t1;
|
|
528
|
+
} else t1 = $[2];
|
|
529
|
+
let t2;
|
|
530
|
+
if ($[3] !== uiFieldset.legend) {
|
|
531
|
+
t2 = /* @__PURE__ */ jsx(Fieldset.Legend, { children: uiFieldset.legend });
|
|
532
|
+
$[3] = uiFieldset.legend;
|
|
533
|
+
$[4] = t2;
|
|
534
|
+
} else t2 = $[4];
|
|
535
|
+
let t3;
|
|
536
|
+
if ($[5] !== uiFieldset.description) {
|
|
537
|
+
t3 = uiFieldset.description && /* @__PURE__ */ jsx(Fieldset.Description, { children: uiFieldset.description });
|
|
538
|
+
$[5] = uiFieldset.description;
|
|
539
|
+
$[6] = t3;
|
|
540
|
+
} else t3 = $[6];
|
|
541
|
+
let t4;
|
|
542
|
+
if ($[7] !== t2 || $[8] !== t3) {
|
|
543
|
+
t4 = /* @__PURE__ */ jsxs(Fieldset.Header, { children: [t2, t3] });
|
|
544
|
+
$[7] = t2;
|
|
545
|
+
$[8] = t3;
|
|
546
|
+
$[9] = t4;
|
|
547
|
+
} else t4 = $[9];
|
|
548
|
+
let t5;
|
|
549
|
+
if ($[10] !== jsonSchema || $[11] !== uiFieldset.nodes) {
|
|
550
|
+
let t6;
|
|
551
|
+
if ($[13] !== jsonSchema) {
|
|
552
|
+
t6 = (node, index) => /* @__PURE__ */ jsx(Fragment, { children: renderNode(jsonSchema, node) }, `fieldset-${node.type}-${index}`);
|
|
553
|
+
$[13] = jsonSchema;
|
|
554
|
+
$[14] = t6;
|
|
555
|
+
} else t6 = $[14];
|
|
556
|
+
t5 = uiFieldset.nodes.map(t6);
|
|
557
|
+
$[10] = jsonSchema;
|
|
558
|
+
$[11] = uiFieldset.nodes;
|
|
559
|
+
$[12] = t5;
|
|
560
|
+
} else t5 = $[12];
|
|
561
|
+
let t6;
|
|
562
|
+
if ($[15] !== t5) {
|
|
563
|
+
t6 = /* @__PURE__ */ jsx(Fieldset.Body, { children: /* @__PURE__ */ jsx(Stack, {
|
|
564
|
+
gap: "4",
|
|
565
|
+
children: t5
|
|
566
|
+
}) });
|
|
567
|
+
$[15] = t5;
|
|
568
|
+
$[16] = t6;
|
|
569
|
+
} else t6 = $[16];
|
|
570
|
+
let t7;
|
|
571
|
+
if ($[17] !== error) {
|
|
572
|
+
t7 = error && /* @__PURE__ */ jsx(Fieldset.ErrorText, { children: error });
|
|
573
|
+
$[17] = error;
|
|
574
|
+
$[18] = t7;
|
|
575
|
+
} else t7 = $[18];
|
|
576
|
+
let t8;
|
|
577
|
+
if ($[19] !== footer || $[20] !== t7) {
|
|
578
|
+
t8 = /* @__PURE__ */ jsxs(Fieldset.Footer, { children: [t7, footer] });
|
|
579
|
+
$[19] = footer;
|
|
580
|
+
$[20] = t7;
|
|
581
|
+
$[21] = t8;
|
|
582
|
+
} else t8 = $[21];
|
|
583
|
+
let t9;
|
|
584
|
+
if ($[22] !== t4 || $[23] !== t6 || $[24] !== t8) {
|
|
585
|
+
t9 = /* @__PURE__ */ jsxs(Fieldset.Root, { children: [
|
|
586
|
+
t4,
|
|
587
|
+
t6,
|
|
588
|
+
t8
|
|
589
|
+
] });
|
|
590
|
+
$[22] = t4;
|
|
591
|
+
$[23] = t6;
|
|
592
|
+
$[24] = t8;
|
|
593
|
+
$[25] = t9;
|
|
594
|
+
} else t9 = $[25];
|
|
595
|
+
let t10;
|
|
596
|
+
if ($[26] !== form || $[27] !== t9) {
|
|
597
|
+
t10 = /* @__PURE__ */ jsx(FormProvider, {
|
|
598
|
+
...form,
|
|
599
|
+
children: t9
|
|
600
|
+
});
|
|
601
|
+
$[26] = form;
|
|
602
|
+
$[27] = t9;
|
|
603
|
+
$[28] = t10;
|
|
604
|
+
} else t10 = $[28];
|
|
605
|
+
let t11;
|
|
606
|
+
if ($[29] !== form || $[30] !== t1 || $[31] !== t10) {
|
|
607
|
+
t11 = /* @__PURE__ */ jsx(Form, {
|
|
608
|
+
value: form,
|
|
609
|
+
onSubmit: t1,
|
|
610
|
+
children: t10
|
|
611
|
+
});
|
|
612
|
+
$[29] = form;
|
|
613
|
+
$[30] = t1;
|
|
614
|
+
$[31] = t10;
|
|
615
|
+
$[32] = t11;
|
|
616
|
+
} else t11 = $[32];
|
|
617
|
+
let t12;
|
|
618
|
+
if ($[33] !== id || $[34] !== t11) {
|
|
619
|
+
t12 = /* @__PURE__ */ jsx(Box, {
|
|
620
|
+
id,
|
|
621
|
+
children: t11
|
|
622
|
+
});
|
|
623
|
+
$[33] = id;
|
|
624
|
+
$[34] = t11;
|
|
625
|
+
$[35] = t12;
|
|
626
|
+
} else t12 = $[35];
|
|
627
|
+
return t12;
|
|
344
628
|
};
|
|
345
629
|
|
|
346
630
|
//#endregion
|