@djangocfg/ui-tools 2.1.319 → 2.1.321
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/JsonSchemaForm-OSPUUUHM.cjs +13 -0
- package/dist/{JsonSchemaForm-IIYKSH6X.cjs.map → JsonSchemaForm-OSPUUUHM.cjs.map} +1 -1
- package/dist/JsonSchemaForm-TSLX2GRO.mjs +4 -0
- package/dist/{JsonSchemaForm-RN3XWSWX.mjs.map → JsonSchemaForm-TSLX2GRO.mjs.map} +1 -1
- package/dist/{chunk-L37FZYJU.cjs → chunk-4IW7GZFQ.cjs} +189 -74
- package/dist/chunk-4IW7GZFQ.cjs.map +1 -0
- package/dist/{chunk-JUGQNNDC.mjs → chunk-EXGXUK2N.mjs} +190 -76
- package/dist/chunk-EXGXUK2N.mjs.map +1 -0
- package/dist/index.cjs +28 -24
- package/dist/index.d.cts +240 -206
- package/dist/index.d.ts +240 -206
- package/dist/index.mjs +2 -2
- package/package.json +6 -6
- package/src/index.ts +15 -0
- package/src/tools/JsonForm/JsonForm.story.tsx +217 -1
- package/src/tools/JsonForm/JsonSchemaForm.tsx +15 -4
- package/src/tools/JsonForm/README.md +268 -0
- package/src/tools/JsonForm/index.ts +22 -1
- package/src/tools/JsonForm/templates/FieldTemplate.tsx +28 -5
- package/src/tools/JsonForm/templates/ObjectFieldTemplate.tsx +110 -3
- package/src/tools/JsonForm/types.ts +37 -5
- package/src/tools/JsonForm/utils.ts +25 -0
- package/src/tools/JsonForm/widgets/CheckboxWidget.tsx +6 -11
- package/src/tools/JsonForm/widgets/SelectWidget.tsx +20 -12
- package/src/tools/JsonForm/widgets/SliderWidget.tsx +9 -5
- package/src/tools/JsonForm/widgets/SwitchWidget.tsx +6 -10
- package/src/tools/JsonForm/widgets/_useWidgetEnv.ts +43 -0
- package/dist/JsonSchemaForm-IIYKSH6X.cjs +0 -13
- package/dist/JsonSchemaForm-RN3XWSWX.mjs +0 -4
- package/dist/chunk-JUGQNNDC.mjs.map +0 -1
- package/dist/chunk-L37FZYJU.cjs.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4IW7GZFQ_cjs = require('./chunk-4IW7GZFQ.cjs');
|
|
4
|
+
require('./chunk-WGEGR3DF.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "JsonSchemaForm", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk4IW7GZFQ_cjs.JsonSchemaForm; }
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=JsonSchemaForm-OSPUUUHM.cjs.map
|
|
13
|
+
//# sourceMappingURL=JsonSchemaForm-OSPUUUHM.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"JsonSchemaForm-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"JsonSchemaForm-OSPUUUHM.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"JsonSchemaForm-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"JsonSchemaForm-TSLX2GRO.mjs"}
|
|
@@ -33,24 +33,41 @@ function FieldTemplate(props) {
|
|
|
33
33
|
hidden,
|
|
34
34
|
rawErrors
|
|
35
35
|
} = props;
|
|
36
|
+
const formContext = props.formContext;
|
|
36
37
|
if (hidden) {
|
|
37
38
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden", children });
|
|
38
39
|
}
|
|
39
40
|
const hasError = rawErrors && rawErrors.length > 0;
|
|
41
|
+
const density = formContext?.density ?? "comfortable";
|
|
42
|
+
const compact = density === "compact";
|
|
43
|
+
const descriptionText = typeof description === "string" ? description : void 0;
|
|
44
|
+
const labelTitle = compact ? descriptionText : void 0;
|
|
45
|
+
const showDescription = !compact && Boolean(description);
|
|
40
46
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
41
47
|
"div",
|
|
42
48
|
{
|
|
43
|
-
className: lib.cn("space-y-2", classNames),
|
|
49
|
+
className: lib.cn(compact ? "space-y-1" : "space-y-2", classNames),
|
|
44
50
|
style,
|
|
45
51
|
children: [
|
|
46
|
-
displayLabel && label && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
displayLabel && label && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53
|
+
components.Label,
|
|
54
|
+
{
|
|
55
|
+
htmlFor: id,
|
|
56
|
+
className: lib.cn(
|
|
57
|
+
hasError && "text-destructive",
|
|
58
|
+
compact && "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70"
|
|
59
|
+
),
|
|
60
|
+
title: labelTitle,
|
|
61
|
+
children: [
|
|
62
|
+
label,
|
|
63
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ml-1", children: "*" })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
showDescription && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: description }),
|
|
51
68
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children }),
|
|
52
|
-
errors && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-destructive", children: errors }),
|
|
53
|
-
help && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: help })
|
|
69
|
+
errors && /* @__PURE__ */ jsxRuntime.jsx("div", { className: compact ? "text-xs text-destructive" : "text-sm text-destructive", children: errors }),
|
|
70
|
+
help && !compact && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: help })
|
|
54
71
|
]
|
|
55
72
|
}
|
|
56
73
|
);
|
|
@@ -64,14 +81,19 @@ function ObjectFieldTemplate(props) {
|
|
|
64
81
|
required,
|
|
65
82
|
uiSchema
|
|
66
83
|
} = props;
|
|
84
|
+
const formContext = props.formContext;
|
|
67
85
|
const isCollapsible = uiSchema?.["ui:collapsible"] === true;
|
|
68
86
|
const defaultCollapsed = uiSchema?.["ui:collapsed"] === true;
|
|
69
87
|
const gridCols = uiSchema?.["ui:grid"];
|
|
70
88
|
const className = uiSchema?.["ui:className"];
|
|
89
|
+
const uiGroups = uiSchema?.["ui:groups"];
|
|
90
|
+
const density = formContext?.density ?? "comfortable";
|
|
91
|
+
const compact = density === "compact";
|
|
71
92
|
const [isOpen, setIsOpen] = react.useState(!defaultCollapsed);
|
|
72
93
|
const isRoot = !title;
|
|
73
|
-
const gridClass = gridCols ? `grid gap-4 grid-cols-${gridCols}` : "space-y-4";
|
|
74
|
-
const
|
|
94
|
+
const gridClass = gridCols ? `grid gap-4 grid-cols-${gridCols}` : compact ? "space-y-2" : "space-y-4";
|
|
95
|
+
const groupedContent = uiGroups ? renderUiGroups({ properties, uiGroups, gridClass, className, compact }) : null;
|
|
96
|
+
const content = groupedContent ?? /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn(gridClass, className), children: properties.map((element) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "property-wrapper", children: element.content }, element.name)) });
|
|
75
97
|
if (isRoot) {
|
|
76
98
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-6", children: content });
|
|
77
99
|
}
|
|
@@ -110,6 +132,64 @@ function ObjectFieldTemplate(props) {
|
|
|
110
132
|
] });
|
|
111
133
|
}
|
|
112
134
|
chunkWGEGR3DF_cjs.__name(ObjectFieldTemplate, "ObjectFieldTemplate");
|
|
135
|
+
function renderUiGroups({
|
|
136
|
+
properties,
|
|
137
|
+
uiGroups,
|
|
138
|
+
gridClass,
|
|
139
|
+
className,
|
|
140
|
+
compact
|
|
141
|
+
}) {
|
|
142
|
+
const propsByName = new Map(properties.map((p) => [p.name, p]));
|
|
143
|
+
const groupedFieldNames = new Set(uiGroups.flatMap((g) => g.fields));
|
|
144
|
+
const ungrouped = properties.filter((p) => !groupedFieldNames.has(p.name));
|
|
145
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn(compact ? "space-y-2" : "space-y-3", className), children: [
|
|
146
|
+
ungrouped.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: ungrouped.map((element) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "property-wrapper", children: element.content }, element.name)) }) : null,
|
|
147
|
+
uiGroups.map((group) => {
|
|
148
|
+
const groupProps = group.fields.map((name) => propsByName.get(name)).filter((p) => Boolean(p));
|
|
149
|
+
if (groupProps.length === 0) return null;
|
|
150
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
151
|
+
UiGroupSection,
|
|
152
|
+
{
|
|
153
|
+
group,
|
|
154
|
+
gridClass,
|
|
155
|
+
compact,
|
|
156
|
+
children: groupProps.map((element) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "property-wrapper", children: element.content }, element.name))
|
|
157
|
+
},
|
|
158
|
+
group.title
|
|
159
|
+
);
|
|
160
|
+
})
|
|
161
|
+
] });
|
|
162
|
+
}
|
|
163
|
+
chunkWGEGR3DF_cjs.__name(renderUiGroups, "renderUiGroups");
|
|
164
|
+
function UiGroupSection({ group, gridClass, compact, children }) {
|
|
165
|
+
const [open, setOpen] = react.useState(group.defaultOpen ?? true);
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(components.Collapsible, { open, onOpenChange: setOpen, children: [
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
168
|
+
components.CollapsibleTrigger,
|
|
169
|
+
{
|
|
170
|
+
className: lib.cn(
|
|
171
|
+
"flex w-full items-center gap-1.5 py-1 transition-colors hover:text-foreground",
|
|
172
|
+
compact ? "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70" : "text-xs font-semibold uppercase tracking-wide text-muted-foreground"
|
|
173
|
+
),
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
176
|
+
lucideReact.ChevronRight,
|
|
177
|
+
{
|
|
178
|
+
className: lib.cn(
|
|
179
|
+
"h-3 w-3 shrink-0 transition-transform duration-200",
|
|
180
|
+
open && "rotate-90"
|
|
181
|
+
),
|
|
182
|
+
"aria-hidden": true
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: group.title })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.CollapsibleContent, { className: "overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("border-l border-border/40 pl-3 pb-2 pt-1", gridClass), children }) })
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
chunkWGEGR3DF_cjs.__name(UiGroupSection, "UiGroupSection");
|
|
113
193
|
function ArrayFieldTemplate(props) {
|
|
114
194
|
const {
|
|
115
195
|
title,
|
|
@@ -400,6 +480,18 @@ function getNestedValue(obj, path) {
|
|
|
400
480
|
return path.split(".").reduce((current, key) => current?.[key], obj);
|
|
401
481
|
}
|
|
402
482
|
chunkWGEGR3DF_cjs.__name(getNestedValue, "getNestedValue");
|
|
483
|
+
function evaluateDisabledWhen(rule, formData) {
|
|
484
|
+
if (!rule) return false;
|
|
485
|
+
const value = getNestedValue(formData, rule.path);
|
|
486
|
+
if ("eq" in rule) return value === rule.eq;
|
|
487
|
+
if ("notEq" in rule) return value !== rule.notEq;
|
|
488
|
+
if ("in" in rule) return rule.in.includes(value);
|
|
489
|
+
if ("notIn" in rule) return !rule.notIn.includes(value);
|
|
490
|
+
if ("truthy" in rule) return Boolean(value);
|
|
491
|
+
if ("falsy" in rule) return !value;
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
chunkWGEGR3DF_cjs.__name(evaluateDisabledWhen, "evaluateDisabledWhen");
|
|
403
495
|
function TextWidget(props) {
|
|
404
496
|
const {
|
|
405
497
|
id,
|
|
@@ -544,17 +636,26 @@ function NumberWidget(props) {
|
|
|
544
636
|
);
|
|
545
637
|
}
|
|
546
638
|
chunkWGEGR3DF_cjs.__name(NumberWidget, "NumberWidget");
|
|
639
|
+
|
|
640
|
+
// src/tools/JsonForm/widgets/_useWidgetEnv.ts
|
|
641
|
+
function useWidgetEnv(props) {
|
|
642
|
+
const { disabled, readonly, formContext, uiSchema, schema } = props;
|
|
643
|
+
const density = formContext?.density ?? "comfortable";
|
|
644
|
+
const compact = density === "compact";
|
|
645
|
+
const disabledWhen = uiSchema?.["ui:disabledWhen"];
|
|
646
|
+
const disabledByRule = evaluateDisabledWhen(disabledWhen, formContext?.formData);
|
|
647
|
+
const tooltipText = compact ? uiSchema?.["ui:description"] ?? schema?.description : void 0;
|
|
648
|
+
return {
|
|
649
|
+
density,
|
|
650
|
+
compact,
|
|
651
|
+
disabled: Boolean(disabled || readonly || disabledByRule),
|
|
652
|
+
tooltipText
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
chunkWGEGR3DF_cjs.__name(useWidgetEnv, "useWidgetEnv");
|
|
547
656
|
function CheckboxWidget(props) {
|
|
548
|
-
const {
|
|
549
|
-
|
|
550
|
-
value,
|
|
551
|
-
disabled,
|
|
552
|
-
readonly,
|
|
553
|
-
autofocus,
|
|
554
|
-
onChange,
|
|
555
|
-
onBlur,
|
|
556
|
-
onFocus
|
|
557
|
-
} = props;
|
|
657
|
+
const { id, value, autofocus, onChange, onBlur, onFocus } = props;
|
|
658
|
+
const { disabled, tooltipText } = useWidgetEnv(props);
|
|
558
659
|
const handleChange = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((checked) => {
|
|
559
660
|
onChange(checked);
|
|
560
661
|
}, "handleChange");
|
|
@@ -563,11 +664,12 @@ function CheckboxWidget(props) {
|
|
|
563
664
|
{
|
|
564
665
|
id,
|
|
565
666
|
checked: value || false,
|
|
566
|
-
disabled
|
|
667
|
+
disabled,
|
|
567
668
|
autoFocus: autofocus,
|
|
568
669
|
onCheckedChange: handleChange,
|
|
569
670
|
onBlur: () => onBlur(id, value),
|
|
570
|
-
onFocus: () => onFocus(id, value)
|
|
671
|
+
onFocus: () => onFocus(id, value),
|
|
672
|
+
title: tooltipText
|
|
571
673
|
}
|
|
572
674
|
);
|
|
573
675
|
}
|
|
@@ -578,8 +680,6 @@ function SelectWidget(props) {
|
|
|
578
680
|
options,
|
|
579
681
|
value,
|
|
580
682
|
required,
|
|
581
|
-
disabled,
|
|
582
|
-
readonly,
|
|
583
683
|
autofocus,
|
|
584
684
|
onChange,
|
|
585
685
|
onBlur,
|
|
@@ -587,6 +687,7 @@ function SelectWidget(props) {
|
|
|
587
687
|
placeholder,
|
|
588
688
|
rawErrors
|
|
589
689
|
} = props;
|
|
690
|
+
const { disabled, compact, tooltipText } = useWidgetEnv(props);
|
|
590
691
|
const enumOptions = react.useMemo(() => {
|
|
591
692
|
const opts = options?.enumOptions;
|
|
592
693
|
if (!Array.isArray(opts)) return [];
|
|
@@ -613,8 +714,9 @@ function SelectWidget(props) {
|
|
|
613
714
|
onChange: (e) => onChange(e.target.value),
|
|
614
715
|
onBlur: (e) => onBlur(id, e.target.value),
|
|
615
716
|
onFocus: (e) => onFocus(id, e.target.value),
|
|
616
|
-
disabled
|
|
617
|
-
readOnly:
|
|
717
|
+
disabled,
|
|
718
|
+
readOnly: disabled,
|
|
719
|
+
title: tooltipText,
|
|
618
720
|
className: `flex h-10 w-full rounded-md border ${hasError ? "border-destructive" : "border-input"} bg-transparent px-3 py-2 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,
|
|
619
721
|
placeholder
|
|
620
722
|
}
|
|
@@ -625,35 +727,32 @@ function SelectWidget(props) {
|
|
|
625
727
|
{
|
|
626
728
|
value: safeValue,
|
|
627
729
|
onValueChange: handleChange,
|
|
628
|
-
disabled
|
|
730
|
+
disabled,
|
|
629
731
|
required,
|
|
630
732
|
children: [
|
|
631
733
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
632
734
|
components.SelectTrigger,
|
|
633
735
|
{
|
|
634
736
|
id,
|
|
635
|
-
className: hasError ? "border-destructive" : "",
|
|
737
|
+
className: `${hasError ? "border-destructive" : ""} ${compact ? "h-7 text-xs" : ""}`.trim(),
|
|
636
738
|
autoFocus: autofocus,
|
|
637
739
|
onFocus: () => onFocus(id, value),
|
|
740
|
+
title: tooltipText,
|
|
638
741
|
children: /* @__PURE__ */ jsxRuntime.jsx(components.SelectValue, { placeholder: placeholder || "Select an option" })
|
|
639
742
|
}
|
|
640
743
|
),
|
|
641
|
-
/* @__PURE__ */ jsxRuntime.jsx(components.SelectContent, { children: enumOptions.map((option) =>
|
|
744
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.SelectContent, { children: enumOptions.map((option) => {
|
|
745
|
+
const optValue = String(option.value);
|
|
746
|
+
return /* @__PURE__ */ jsxRuntime.jsx(components.SelectItem, { value: optValue, children: option.label || optValue }, optValue || "__empty__");
|
|
747
|
+
}) })
|
|
642
748
|
]
|
|
643
749
|
}
|
|
644
750
|
);
|
|
645
751
|
}
|
|
646
752
|
chunkWGEGR3DF_cjs.__name(SelectWidget, "SelectWidget");
|
|
647
753
|
function SwitchWidget(props) {
|
|
648
|
-
const {
|
|
649
|
-
|
|
650
|
-
value,
|
|
651
|
-
disabled,
|
|
652
|
-
readonly,
|
|
653
|
-
onChange,
|
|
654
|
-
onBlur,
|
|
655
|
-
onFocus
|
|
656
|
-
} = props;
|
|
754
|
+
const { id, value, onChange, onBlur, onFocus } = props;
|
|
755
|
+
const { disabled, tooltipText } = useWidgetEnv(props);
|
|
657
756
|
const handleChange = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((checked) => {
|
|
658
757
|
onChange(checked);
|
|
659
758
|
}, "handleChange");
|
|
@@ -662,10 +761,11 @@ function SwitchWidget(props) {
|
|
|
662
761
|
{
|
|
663
762
|
id,
|
|
664
763
|
checked: value || false,
|
|
665
|
-
disabled
|
|
764
|
+
disabled,
|
|
666
765
|
onCheckedChange: handleChange,
|
|
667
766
|
onBlur: () => onBlur(id, value),
|
|
668
|
-
onFocus: () => onFocus(id, value)
|
|
767
|
+
onFocus: () => onFocus(id, value),
|
|
768
|
+
title: tooltipText
|
|
669
769
|
}
|
|
670
770
|
);
|
|
671
771
|
}
|
|
@@ -849,14 +949,13 @@ chunkWGEGR3DF_cjs.__name(ColorWidget, "ColorWidget");
|
|
|
849
949
|
function SliderWidget(props) {
|
|
850
950
|
const {
|
|
851
951
|
id,
|
|
852
|
-
disabled,
|
|
853
|
-
readonly,
|
|
854
952
|
value,
|
|
855
953
|
onChange,
|
|
856
954
|
schema,
|
|
857
955
|
options,
|
|
858
956
|
rawErrors
|
|
859
957
|
} = props;
|
|
958
|
+
const { disabled, tooltipText } = useWidgetEnv(props);
|
|
860
959
|
const config = react.useMemo(() => {
|
|
861
960
|
const min = schema.minimum ?? options?.min ?? 0;
|
|
862
961
|
const max = schema.maximum ?? options?.max ?? 100;
|
|
@@ -910,35 +1009,42 @@ function SliderWidget(props) {
|
|
|
910
1009
|
}
|
|
911
1010
|
return String(numericValue);
|
|
912
1011
|
}, [numericValue, config.unit]);
|
|
913
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1012
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1013
|
+
"div",
|
|
1014
|
+
{
|
|
1015
|
+
className: lib.cn("flex items-center gap-3", hasError && "text-destructive"),
|
|
1016
|
+
title: tooltipText,
|
|
1017
|
+
children: [
|
|
1018
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1019
|
+
components.Slider,
|
|
1020
|
+
{
|
|
1021
|
+
id,
|
|
1022
|
+
disabled,
|
|
1023
|
+
value: [numericValue],
|
|
1024
|
+
onValueChange: handleSliderChange,
|
|
1025
|
+
min: config.min,
|
|
1026
|
+
max: config.max,
|
|
1027
|
+
step: config.step,
|
|
1028
|
+
className: "flex-1"
|
|
1029
|
+
}
|
|
1030
|
+
),
|
|
1031
|
+
config.showInput ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1032
|
+
components.Input,
|
|
1033
|
+
{
|
|
1034
|
+
type: "text",
|
|
1035
|
+
value: displayValue,
|
|
1036
|
+
onChange: handleInputChange,
|
|
1037
|
+
disabled,
|
|
1038
|
+
readOnly: disabled,
|
|
1039
|
+
className: lib.cn(
|
|
1040
|
+
"w-20 text-center font-mono text-sm",
|
|
1041
|
+
hasError && "border-destructive"
|
|
1042
|
+
)
|
|
1043
|
+
}
|
|
1044
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-16 text-right font-mono text-sm text-muted-foreground", children: displayValue })
|
|
1045
|
+
]
|
|
1046
|
+
}
|
|
1047
|
+
);
|
|
942
1048
|
}
|
|
943
1049
|
chunkWGEGR3DF_cjs.__name(SliderWidget, "SliderWidget");
|
|
944
1050
|
function JsonSchemaForm(props) {
|
|
@@ -956,6 +1062,8 @@ function JsonSchemaForm(props) {
|
|
|
956
1062
|
className,
|
|
957
1063
|
showSubmitButton = true,
|
|
958
1064
|
submitButtonText = "Submit",
|
|
1065
|
+
density = "comfortable",
|
|
1066
|
+
formContext: callerFormContext,
|
|
959
1067
|
...restProps
|
|
960
1068
|
} = props;
|
|
961
1069
|
const validatedSchema = react.useMemo(() => {
|
|
@@ -1037,7 +1145,12 @@ function JsonSchemaForm(props) {
|
|
|
1037
1145
|
/* @__PURE__ */ jsxRuntime.jsx(components.AlertDescription, { children: "Invalid schema provided. Please check the schema format." })
|
|
1038
1146
|
] }) });
|
|
1039
1147
|
}
|
|
1040
|
-
|
|
1148
|
+
const formContext = react.useMemo(() => ({
|
|
1149
|
+
...callerFormContext,
|
|
1150
|
+
density,
|
|
1151
|
+
formData: normalizedFormData
|
|
1152
|
+
}), [callerFormContext, density, normalizedFormData]);
|
|
1153
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-jsonform-density": density, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1041
1154
|
Form__default.default,
|
|
1042
1155
|
{
|
|
1043
1156
|
schema: validatedSchema,
|
|
@@ -1046,6 +1159,7 @@ function JsonSchemaForm(props) {
|
|
|
1046
1159
|
validator: validator__default.default,
|
|
1047
1160
|
widgets,
|
|
1048
1161
|
templates,
|
|
1162
|
+
formContext,
|
|
1049
1163
|
onSubmit: handleSubmit,
|
|
1050
1164
|
onChange: handleChange,
|
|
1051
1165
|
onError: handleError,
|
|
@@ -1074,6 +1188,7 @@ exports.SelectWidget = SelectWidget;
|
|
|
1074
1188
|
exports.SliderWidget = SliderWidget;
|
|
1075
1189
|
exports.SwitchWidget = SwitchWidget;
|
|
1076
1190
|
exports.TextWidget = TextWidget;
|
|
1191
|
+
exports.evaluateDisabledWhen = evaluateDisabledWhen;
|
|
1077
1192
|
exports.getRequiredFields = getRequiredFields;
|
|
1078
1193
|
exports.hasRequiredFields = hasRequiredFields;
|
|
1079
1194
|
exports.mergeDefaults = mergeDefaults;
|
|
@@ -1082,5 +1197,5 @@ exports.safeJsonParse = safeJsonParse;
|
|
|
1082
1197
|
exports.safeJsonStringify = safeJsonStringify;
|
|
1083
1198
|
exports.validateRequiredFields = validateRequiredFields;
|
|
1084
1199
|
exports.validateSchema = validateSchema;
|
|
1085
|
-
//# sourceMappingURL=chunk-
|
|
1086
|
-
//# sourceMappingURL=chunk-
|
|
1200
|
+
//# sourceMappingURL=chunk-4IW7GZFQ.cjs.map
|
|
1201
|
+
//# sourceMappingURL=chunk-4IW7GZFQ.cjs.map
|