@rjsf/shadcn 6.6.0 → 6.6.2
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.cjs +117 -100
- package/dist/index.cjs.map +3 -3
- package/dist/rjsf-shadcn.esm.js +105 -124
- package/dist/rjsf-shadcn.esm.js.map +3 -3
- package/dist/rjsf-shadcn.umd.js +96 -80
- package/lib/AddButton/AddButton.d.ts +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +6 -6
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +5 -5
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -4
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +1 -1
- package/lib/ErrorList/ErrorList.d.ts +1 -1
- package/lib/ErrorList/ErrorList.js +1 -3
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +1 -3
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/Form/Form.d.ts +3 -3
- package/lib/Form/Form.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +1 -1
- package/lib/IconButton/IconButton.d.ts +15 -8
- package/lib/IconButton/IconButton.js +14 -6
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +6 -6
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +2 -2
- package/lib/RangeWidget/RangeWidget.js +2 -2
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +1 -1
- package/lib/SelectWidget/SelectWidget.js +8 -8
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +1 -1
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.js +4 -4
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/Theme/Theme.d.ts +2 -2
- package/lib/TitleField/TitleField.d.ts +1 -1
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/components/ui/alert.d.ts +1 -1
- package/lib/components/ui/badge.d.ts +1 -1
- package/lib/components/ui/button.d.ts +1 -1
- package/lib/components/ui/checkbox.d.ts +1 -1
- package/lib/components/ui/command.d.ts +1 -1
- package/lib/components/ui/command.js +1 -3
- package/lib/components/ui/command.js.map +1 -1
- package/lib/components/ui/dialog.d.ts +1 -1
- package/lib/components/ui/fancy-multi-select.d.ts +3 -3
- package/lib/components/ui/fancy-multi-select.js +2 -2
- package/lib/components/ui/fancy-multi-select.js.map +1 -1
- package/lib/components/ui/fancy-select.d.ts +3 -3
- package/lib/components/ui/fancy-select.js +1 -1
- package/lib/components/ui/fancy-select.js.map +1 -1
- package/lib/components/ui/input.d.ts +1 -1
- package/lib/components/ui/label.d.ts +1 -1
- package/lib/components/ui/radio-group.d.ts +1 -1
- package/lib/components/ui/separator.d.ts +1 -1
- package/lib/components/ui/slider.d.ts +1 -1
- package/lib/components/ui/slider.js +10 -2
- package/lib/components/ui/slider.js.map +1 -1
- package/lib/components/ui/textarea.d.ts +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -9
- package/src/AddButton/AddButton.tsx +2 -1
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +2 -8
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -9
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +13 -19
- package/src/CheckboxWidget/CheckboxWidget.tsx +8 -17
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +7 -10
- package/src/DescriptionField/DescriptionField.tsx +1 -1
- package/src/ErrorList/ErrorList.tsx +6 -4
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +8 -8
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
- package/src/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/Form/Form.tsx +4 -3
- package/src/GridTemplate/GridTemplate.tsx +1 -1
- package/src/IconButton/IconButton.tsx +19 -9
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +4 -14
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
- package/src/RadioWidget/RadioWidget.tsx +10 -13
- package/src/RangeWidget/RangeWidget.tsx +5 -4
- package/src/SelectWidget/SelectWidget.tsx +11 -14
- package/src/SubmitButton/SubmitButton.tsx +2 -1
- package/src/Templates/Templates.ts +1 -1
- package/src/TextareaWidget/TextareaWidget.tsx +10 -9
- package/src/Theme/Theme.tsx +2 -2
- package/src/TitleField/TitleField.tsx +2 -1
- package/src/Widgets/Widgets.ts +1 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/ui/alert.tsx +1 -1
- package/src/components/ui/badge.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/command.tsx +13 -14
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/fancy-multi-select.tsx +5 -13
- package/src/components/ui/fancy-select.tsx +7 -3
- package/src/components/ui/input.tsx +1 -1
- package/src/components/ui/label.tsx +1 -1
- package/src/components/ui/radio-group.tsx +1 -1
- package/src/components/ui/separator.tsx +1 -1
- package/src/components/ui/slider.tsx +12 -6
- package/src/components/ui/textarea.tsx +1 -1
package/dist/index.cjs
CHANGED
|
@@ -267,10 +267,10 @@ function BaseInputTemplate({
|
|
|
267
267
|
...extraProps,
|
|
268
268
|
...(0, import_utils7.getInputProps)(schema, type, options)
|
|
269
269
|
};
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
const
|
|
270
|
+
const handleChange = ({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue);
|
|
271
|
+
const handleBlur = ({ target }) => onBlur(id, target && target.value);
|
|
272
|
+
const handleFocus = ({ target }) => onFocus(id, target && target.value);
|
|
273
|
+
const handleClear = (0, import_react.useCallback)(
|
|
274
274
|
(e) => {
|
|
275
275
|
e.preventDefault();
|
|
276
276
|
e.stopPropagation();
|
|
@@ -294,13 +294,13 @@ function BaseInputTemplate({
|
|
|
294
294
|
list: schema.examples ? (0, import_utils7.examplesId)(id) : void 0,
|
|
295
295
|
...inputProps,
|
|
296
296
|
value: value || value === 0 ? value : "",
|
|
297
|
-
onChange: onChangeOverride ||
|
|
298
|
-
onBlur:
|
|
299
|
-
onFocus:
|
|
297
|
+
onChange: onChangeOverride || handleChange,
|
|
298
|
+
onBlur: handleBlur,
|
|
299
|
+
onFocus: handleFocus,
|
|
300
300
|
"aria-describedby": (0, import_utils7.ariaDescribedByIds)(id, !!schema.examples)
|
|
301
301
|
}
|
|
302
302
|
),
|
|
303
|
-
options.allowClearTextInputs && !readonly && !disabled && value && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClearButton2, { onClick:
|
|
303
|
+
options.allowClearTextInputs && !readonly && !disabled && value && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClearButton2, { onClick: handleClear, registry }),
|
|
304
304
|
children,
|
|
305
305
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core.SchemaExamples, { id, schema })
|
|
306
306
|
] });
|
|
@@ -374,27 +374,29 @@ function ErrorList({
|
|
|
374
374
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Alert, { variant: "destructive", className: "mb-2", children: [
|
|
375
375
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react2.AlertCircle, { className: "h-4 w-4" }),
|
|
376
376
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AlertTitle, { children: translateString(import_utils10.TranslatableString.ErrorsLabel) }),
|
|
377
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AlertDescription, { className: "flex flex-col gap-1", children: errors.map((error, i) =>
|
|
378
|
-
|
|
377
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AlertDescription, { className: "flex flex-col gap-1", children: errors.map((error, i) => (
|
|
378
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
379
380
|
"\u2022 ",
|
|
380
381
|
error.stack
|
|
381
|
-
] }, i)
|
|
382
|
-
|
|
382
|
+
] }, i)
|
|
383
|
+
)) })
|
|
383
384
|
] });
|
|
384
385
|
}
|
|
385
386
|
|
|
386
387
|
// src/FieldErrorTemplate/FieldErrorTemplate.tsx
|
|
387
388
|
var import_utils11 = require("@rjsf/utils");
|
|
388
|
-
var import_jsx_runtime10 =
|
|
389
|
+
var import_jsx_runtime10 = (
|
|
390
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
391
|
+
require("react/jsx-runtime")
|
|
392
|
+
);
|
|
389
393
|
function FieldErrorTemplate(props) {
|
|
390
394
|
const { errors = [], fieldPathId } = props;
|
|
391
395
|
if (errors.length === 0) {
|
|
392
396
|
return null;
|
|
393
397
|
}
|
|
394
398
|
const id = (0, import_utils11.errorId)(fieldPathId);
|
|
395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex flex-col gap-1", id, children: errors.map((error, i) => {
|
|
396
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-xs font-medium text-destructive mb-1", children: error }, i);
|
|
397
|
-
}) });
|
|
399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex flex-col gap-1", id, children: errors.map((error, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-xs font-medium text-destructive mb-1", children: error }, i)) });
|
|
398
400
|
}
|
|
399
401
|
|
|
400
402
|
// src/FieldHelpTemplate/FieldHelpTemplate.tsx
|
|
@@ -508,20 +510,24 @@ function GridTemplate(props) {
|
|
|
508
510
|
}
|
|
509
511
|
|
|
510
512
|
// src/IconButton/IconButton.tsx
|
|
513
|
+
var import_react2 = require("react");
|
|
511
514
|
var import_utils17 = require("@rjsf/utils");
|
|
512
515
|
var import_lucide_react3 = require("lucide-react");
|
|
513
516
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
514
|
-
function
|
|
517
|
+
function IconButtonFn(props) {
|
|
515
518
|
const { icon, iconType, className, uiSchema, registry, ...otherProps } = props;
|
|
516
519
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { size: "icon", variant: "outline", className, ...otherProps, type: "button", children: icon });
|
|
517
520
|
}
|
|
518
|
-
|
|
521
|
+
var IconButton = (0, import_react2.memo)(IconButtonFn);
|
|
522
|
+
var IconButton_default = IconButton;
|
|
523
|
+
function CopyButtonFn(props) {
|
|
519
524
|
const {
|
|
520
525
|
registry: { translateString }
|
|
521
526
|
} = props;
|
|
522
527
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(IconButton, { title: translateString(import_utils17.TranslatableString.CopyButton), ...props, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Copy, { className: "h-4 w-4" }) });
|
|
523
528
|
}
|
|
524
|
-
|
|
529
|
+
var CopyButton = (0, import_react2.memo)(CopyButtonFn);
|
|
530
|
+
function MoveDownButtonFn(props) {
|
|
525
531
|
const {
|
|
526
532
|
registry: { translateString }
|
|
527
533
|
} = props;
|
|
@@ -534,7 +540,8 @@ function MoveDownButton(props) {
|
|
|
534
540
|
}
|
|
535
541
|
);
|
|
536
542
|
}
|
|
537
|
-
|
|
543
|
+
var MoveDownButton = (0, import_react2.memo)(MoveDownButtonFn);
|
|
544
|
+
function MoveUpButtonFn(props) {
|
|
538
545
|
const {
|
|
539
546
|
registry: { translateString }
|
|
540
547
|
} = props;
|
|
@@ -547,7 +554,8 @@ function MoveUpButton(props) {
|
|
|
547
554
|
}
|
|
548
555
|
);
|
|
549
556
|
}
|
|
550
|
-
|
|
557
|
+
var MoveUpButton = (0, import_react2.memo)(MoveUpButtonFn);
|
|
558
|
+
function RemoveButtonFn(props) {
|
|
551
559
|
const {
|
|
552
560
|
registry: { translateString }
|
|
553
561
|
} = props;
|
|
@@ -561,12 +569,14 @@ function RemoveButton(props) {
|
|
|
561
569
|
}
|
|
562
570
|
);
|
|
563
571
|
}
|
|
564
|
-
|
|
572
|
+
var RemoveButton = (0, import_react2.memo)(RemoveButtonFn);
|
|
573
|
+
function ClearButtonFn(props) {
|
|
565
574
|
const {
|
|
566
575
|
registry: { translateString }
|
|
567
576
|
} = props;
|
|
568
577
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(IconButton, { title: translateString(import_utils17.TranslatableString.ClearButton), ...props, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.X, {}) });
|
|
569
578
|
}
|
|
579
|
+
var ClearButton = (0, import_react2.memo)(ClearButtonFn);
|
|
570
580
|
|
|
571
581
|
// src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx
|
|
572
582
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
@@ -631,7 +641,7 @@ function ObjectFieldTemplate({
|
|
|
631
641
|
),
|
|
632
642
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
633
643
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
634
|
-
properties.map((element
|
|
644
|
+
properties.map((element) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `${element.hidden ? "hidden" : ""} flex`, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-full", children: element.content }) }, element.name)),
|
|
635
645
|
(0, import_utils19.canExpand)(schema, uiSchema, formData) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
636
646
|
AddButton2,
|
|
637
647
|
{
|
|
@@ -654,7 +664,7 @@ function OptionalDataControlsTemplate(props) {
|
|
|
654
664
|
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
655
665
|
if (onAddClick) {
|
|
656
666
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
657
|
-
|
|
667
|
+
IconButton_default,
|
|
658
668
|
{
|
|
659
669
|
id,
|
|
660
670
|
registry,
|
|
@@ -665,7 +675,8 @@ function OptionalDataControlsTemplate(props) {
|
|
|
665
675
|
size: "xs"
|
|
666
676
|
}
|
|
667
677
|
);
|
|
668
|
-
}
|
|
678
|
+
}
|
|
679
|
+
if (onRemoveClick) {
|
|
669
680
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
670
681
|
RemoveButton,
|
|
671
682
|
{
|
|
@@ -904,11 +915,11 @@ function CheckboxesWidget({
|
|
|
904
915
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
905
916
|
const optionValueFormat = (0, import_utils27.getOptionValueFormat)(options);
|
|
906
917
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
907
|
-
const
|
|
908
|
-
const
|
|
918
|
+
const handleBlur = ({ target }) => onBlur(id, (0, import_utils27.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
919
|
+
const handleFocus = ({ target }) => onFocus(id, (0, import_utils27.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
909
920
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: cn({ "flex flex-col gap-2": !inline, "flex flex-row gap-4 flex-wrap": inline }), children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
910
921
|
const checked = (0, import_utils27.enumOptionsIsSelected)(option.value, checkboxesValues);
|
|
911
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
922
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
912
923
|
const indexOptionId = (0, import_utils27.optionId)(id, index);
|
|
913
924
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
914
925
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
@@ -928,8 +939,8 @@ function CheckboxesWidget({
|
|
|
928
939
|
className,
|
|
929
940
|
checked,
|
|
930
941
|
autoFocus: autofocus && index === 0,
|
|
931
|
-
onBlur:
|
|
932
|
-
onFocus:
|
|
942
|
+
onBlur: handleBlur,
|
|
943
|
+
onFocus: handleFocus,
|
|
933
944
|
"aria-describedby": (0, import_utils27.ariaDescribedByIds)(id)
|
|
934
945
|
}
|
|
935
946
|
),
|
|
@@ -966,9 +977,9 @@ function CheckboxWidget(props) {
|
|
|
966
977
|
registry,
|
|
967
978
|
options
|
|
968
979
|
);
|
|
969
|
-
const
|
|
970
|
-
const
|
|
971
|
-
const
|
|
980
|
+
const handleChange = (checked) => onChange(checked);
|
|
981
|
+
const handleBlur = () => onBlur(id, value);
|
|
982
|
+
const handleFocus = () => onFocus(id, value);
|
|
972
983
|
const description = options.description || schema.description;
|
|
973
984
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
974
985
|
"div",
|
|
@@ -996,9 +1007,9 @@ function CheckboxWidget(props) {
|
|
|
996
1007
|
required,
|
|
997
1008
|
disabled: disabled || readonly,
|
|
998
1009
|
autoFocus: autofocus,
|
|
999
|
-
onCheckedChange:
|
|
1000
|
-
onBlur:
|
|
1001
|
-
onFocus:
|
|
1010
|
+
onCheckedChange: handleChange,
|
|
1011
|
+
onBlur: handleBlur,
|
|
1012
|
+
onFocus: handleFocus,
|
|
1002
1013
|
className
|
|
1003
1014
|
}
|
|
1004
1015
|
),
|
|
@@ -1050,9 +1061,9 @@ function RadioWidget({
|
|
|
1050
1061
|
}) {
|
|
1051
1062
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1052
1063
|
const optionValueFormat = (0, import_utils31.getOptionValueFormat)(options);
|
|
1053
|
-
const
|
|
1054
|
-
const
|
|
1055
|
-
const
|
|
1064
|
+
const handleChange = (enumValue) => onChange((0, import_utils31.enumOptionValueDecoder)(enumValue, enumOptions, optionValueFormat, emptyValue));
|
|
1065
|
+
const handleBlur = ({ target }) => onBlur(id, (0, import_utils31.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1066
|
+
const handleFocus = ({ target }) => onFocus(id, (0, import_utils31.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1056
1067
|
const inline = Boolean(options && options.inline);
|
|
1057
1068
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "mb-0", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1058
1069
|
RadioGroup,
|
|
@@ -1061,15 +1072,15 @@ function RadioWidget({
|
|
|
1061
1072
|
required,
|
|
1062
1073
|
disabled: disabled || readonly,
|
|
1063
1074
|
onValueChange: (e) => {
|
|
1064
|
-
|
|
1075
|
+
handleChange(e);
|
|
1065
1076
|
},
|
|
1066
|
-
onBlur:
|
|
1067
|
-
onFocus:
|
|
1077
|
+
onBlur: handleBlur,
|
|
1078
|
+
onFocus: handleFocus,
|
|
1068
1079
|
"aria-describedby": (0, import_utils31.ariaDescribedByIds)(id),
|
|
1069
1080
|
orientation: inline ? "horizontal" : "vertical",
|
|
1070
1081
|
className: cn("flex flex-wrap", { "flex-col": !inline }, className),
|
|
1071
1082
|
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
1072
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
1083
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
1073
1084
|
const checked = (0, import_utils31.enumOptionsIsSelected)(option.value, value);
|
|
1074
1085
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1075
1086
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
@@ -1093,14 +1104,19 @@ var import_utils34 = require("@rjsf/utils");
|
|
|
1093
1104
|
var import_pick = __toESM(require("lodash/pick"), 1);
|
|
1094
1105
|
|
|
1095
1106
|
// src/components/ui/slider.tsx
|
|
1096
|
-
var
|
|
1107
|
+
var import_react3 = require("react");
|
|
1097
1108
|
var import_react_slider = require("@radix-ui/react-slider");
|
|
1098
1109
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1099
1110
|
function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }) {
|
|
1100
|
-
const
|
|
1101
|
-
(
|
|
1102
|
-
|
|
1103
|
-
|
|
1111
|
+
const enumValues = (0, import_react3.useMemo)(() => {
|
|
1112
|
+
if (Array.isArray(value)) {
|
|
1113
|
+
return value;
|
|
1114
|
+
}
|
|
1115
|
+
if (Array.isArray(defaultValue)) {
|
|
1116
|
+
return defaultValue;
|
|
1117
|
+
}
|
|
1118
|
+
return [min, max];
|
|
1119
|
+
}, [value, defaultValue, min, max]);
|
|
1104
1120
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
1105
1121
|
import_react_slider.Root,
|
|
1106
1122
|
{
|
|
@@ -1131,7 +1147,7 @@ function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }
|
|
|
1131
1147
|
)
|
|
1132
1148
|
}
|
|
1133
1149
|
),
|
|
1134
|
-
Array.from({ length:
|
|
1150
|
+
Array.from({ length: enumValues.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1135
1151
|
import_react_slider.Thumb,
|
|
1136
1152
|
{
|
|
1137
1153
|
"data-slot": "slider-thumb",
|
|
@@ -1171,7 +1187,7 @@ function RangeWidget({
|
|
|
1171
1187
|
label,
|
|
1172
1188
|
id
|
|
1173
1189
|
}) {
|
|
1174
|
-
const
|
|
1190
|
+
const handleChange = (newValue) => onChange(newValue[0]);
|
|
1175
1191
|
const sliderProps = { value, label, id, ...(0, import_utils34.rangeSpec)(schema) };
|
|
1176
1192
|
const uiProps = { id, ...(0, import_pick.default)(options.props || {}, allowedProps) };
|
|
1177
1193
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
@@ -1183,7 +1199,7 @@ function RangeWidget({
|
|
|
1183
1199
|
max: sliderProps.max,
|
|
1184
1200
|
step: sliderProps.step,
|
|
1185
1201
|
value: [value],
|
|
1186
|
-
onValueChange:
|
|
1202
|
+
onValueChange: handleChange,
|
|
1187
1203
|
...uiProps,
|
|
1188
1204
|
"aria-describedby": (0, import_utils34.ariaDescribedByIds)(id)
|
|
1189
1205
|
}
|
|
@@ -1196,7 +1212,7 @@ function RangeWidget({
|
|
|
1196
1212
|
var import_utils40 = require("@rjsf/utils");
|
|
1197
1213
|
|
|
1198
1214
|
// src/components/ui/fancy-multi-select.tsx
|
|
1199
|
-
var
|
|
1215
|
+
var import_react5 = require("react");
|
|
1200
1216
|
var import_cmdk2 = require("cmdk");
|
|
1201
1217
|
var import_isEqual = __toESM(require("lodash/isEqual"), 1);
|
|
1202
1218
|
var import_lucide_react8 = require("lucide-react");
|
|
@@ -1232,7 +1248,7 @@ function Badge({
|
|
|
1232
1248
|
}
|
|
1233
1249
|
|
|
1234
1250
|
// src/components/ui/command.tsx
|
|
1235
|
-
var
|
|
1251
|
+
var import_react4 = require("react");
|
|
1236
1252
|
var import_cmdk = require("cmdk");
|
|
1237
1253
|
var import_lucide_react7 = require("lucide-react");
|
|
1238
1254
|
|
|
@@ -1243,23 +1259,21 @@ var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
|
1243
1259
|
|
|
1244
1260
|
// src/components/ui/command.tsx
|
|
1245
1261
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1246
|
-
var Command = (0,
|
|
1247
|
-
({ className, ...props }, ref) =>
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
);
|
|
1260
|
-
}
|
|
1262
|
+
var Command = (0, import_react4.forwardRef)(
|
|
1263
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1264
|
+
import_cmdk.Command,
|
|
1265
|
+
{
|
|
1266
|
+
ref,
|
|
1267
|
+
"data-slot": "command",
|
|
1268
|
+
className: cn(
|
|
1269
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
1270
|
+
className
|
|
1271
|
+
),
|
|
1272
|
+
...props
|
|
1273
|
+
}
|
|
1274
|
+
)
|
|
1261
1275
|
);
|
|
1262
|
-
var CommandInput = (0,
|
|
1276
|
+
var CommandInput = (0, import_react4.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center border-b px-3", ...{ "cmdk-input-wrapper": "" }, children: [
|
|
1263
1277
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react7.Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
1264
1278
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1265
1279
|
import_cmdk.Command.Input,
|
|
@@ -1327,18 +1341,18 @@ function FancyMultiSelect({
|
|
|
1327
1341
|
className,
|
|
1328
1342
|
id
|
|
1329
1343
|
}) {
|
|
1330
|
-
const inputRef = (0,
|
|
1331
|
-
const [open, setOpen] = (0,
|
|
1332
|
-
const [inputValue, setInputValue] = (0,
|
|
1333
|
-
const selectedItems = (0,
|
|
1344
|
+
const inputRef = (0, import_react5.useRef)(null);
|
|
1345
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
1346
|
+
const [inputValue, setInputValue] = (0, import_react5.useState)("");
|
|
1347
|
+
const selectedItems = (0, import_react5.useMemo)(
|
|
1334
1348
|
() => items.filter((item) => selected.some((selectedValue) => (0, import_isEqual.default)(item.value, selectedValue))),
|
|
1335
1349
|
[items, selected]
|
|
1336
1350
|
);
|
|
1337
|
-
const selectables = (0,
|
|
1351
|
+
const selectables = (0, import_react5.useMemo)(
|
|
1338
1352
|
() => items.filter((framework) => !selectedItems.some((item) => (0, import_isEqual.default)(item.value, framework.value))),
|
|
1339
1353
|
[items, selectedItems]
|
|
1340
1354
|
);
|
|
1341
|
-
const handleUnselect = (0,
|
|
1355
|
+
const handleUnselect = (0, import_react5.useCallback)(
|
|
1342
1356
|
(framework) => {
|
|
1343
1357
|
if (disabled) {
|
|
1344
1358
|
return;
|
|
@@ -1348,7 +1362,7 @@ function FancyMultiSelect({
|
|
|
1348
1362
|
},
|
|
1349
1363
|
[selectedItems, onValueChange, disabled]
|
|
1350
1364
|
);
|
|
1351
|
-
const handleKeyDown = (0,
|
|
1365
|
+
const handleKeyDown = (0, import_react5.useCallback)(
|
|
1352
1366
|
(e) => {
|
|
1353
1367
|
if (disabled || !inputRef.current || inputRef.current.value !== "") {
|
|
1354
1368
|
return;
|
|
@@ -1362,18 +1376,18 @@ function FancyMultiSelect({
|
|
|
1362
1376
|
},
|
|
1363
1377
|
[selectedItems, onValueChange, disabled]
|
|
1364
1378
|
);
|
|
1365
|
-
const handleSelect = (0,
|
|
1379
|
+
const handleSelect = (0, import_react5.useCallback)(
|
|
1366
1380
|
(item) => {
|
|
1367
1381
|
if (disabled) {
|
|
1368
1382
|
return;
|
|
1369
1383
|
}
|
|
1370
1384
|
setInputValue("");
|
|
1371
1385
|
const newSelected = multiple ? [...selectedItems, item] : [item];
|
|
1372
|
-
onValueChange?.(newSelected.map((
|
|
1386
|
+
onValueChange?.(newSelected.map((selectedItem) => selectedItem.index));
|
|
1373
1387
|
},
|
|
1374
1388
|
[multiple, selectedItems, onValueChange, disabled]
|
|
1375
1389
|
);
|
|
1376
|
-
const handleFocus = (0,
|
|
1390
|
+
const handleFocus = (0, import_react5.useCallback)(
|
|
1377
1391
|
(e) => {
|
|
1378
1392
|
if (!disabled) {
|
|
1379
1393
|
setOpen(true);
|
|
@@ -1470,7 +1484,7 @@ function FancyMultiSelect({
|
|
|
1470
1484
|
}
|
|
1471
1485
|
|
|
1472
1486
|
// src/components/ui/fancy-select.tsx
|
|
1473
|
-
var
|
|
1487
|
+
var import_react6 = require("react");
|
|
1474
1488
|
var import_lucide_react9 = require("lucide-react");
|
|
1475
1489
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1476
1490
|
function FancySelect({
|
|
@@ -1487,11 +1501,11 @@ function FancySelect({
|
|
|
1487
1501
|
onBlur,
|
|
1488
1502
|
className
|
|
1489
1503
|
}) {
|
|
1490
|
-
const [open, setOpen] = (0,
|
|
1504
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1491
1505
|
const selectedItem = items?.find((item) => item.value === selected);
|
|
1492
|
-
const selectedRef = (0,
|
|
1493
|
-
const containerRef = (0,
|
|
1494
|
-
(0,
|
|
1506
|
+
const selectedRef = (0, import_react6.useRef)(null);
|
|
1507
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
1508
|
+
(0, import_react6.useEffect)(() => {
|
|
1495
1509
|
if (open && selectedRef.current) {
|
|
1496
1510
|
requestAnimationFrame(() => {
|
|
1497
1511
|
selectedRef.current?.scrollIntoView({ block: "nearest" });
|
|
@@ -1519,7 +1533,10 @@ function FancySelect({
|
|
|
1519
1533
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
1520
1534
|
"div",
|
|
1521
1535
|
{
|
|
1536
|
+
role: "button",
|
|
1537
|
+
tabIndex: disabled ? -1 : 0,
|
|
1522
1538
|
onClick: () => !disabled && setOpen(!open),
|
|
1539
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && !disabled && setOpen(!open),
|
|
1523
1540
|
className: cn(
|
|
1524
1541
|
"flex h-9 w-full items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
1525
1542
|
!selectedItem && required && "border-red-500",
|
|
@@ -1590,17 +1607,17 @@ function SelectWidget({
|
|
|
1590
1607
|
}) {
|
|
1591
1608
|
const { enumOptions, enumDisabled, emptyValue: optEmptyValue } = options;
|
|
1592
1609
|
const optionValueFormat = (0, import_utils40.getOptionValueFormat)(options);
|
|
1593
|
-
const
|
|
1610
|
+
const handleFancyFocus = () => {
|
|
1594
1611
|
onFocus(id, (0, import_utils40.enumOptionValueDecoder)(value, enumOptions, optionValueFormat, optEmptyValue));
|
|
1595
1612
|
};
|
|
1596
|
-
const
|
|
1613
|
+
const handleFancyBlur = () => {
|
|
1597
1614
|
onBlur(id, (0, import_utils40.enumOptionValueDecoder)(value, enumOptions, optionValueFormat, optEmptyValue));
|
|
1598
1615
|
};
|
|
1599
|
-
const items = enumOptions?.map(({ value:
|
|
1600
|
-
value: multiple ?
|
|
1601
|
-
label,
|
|
1616
|
+
const items = enumOptions?.map(({ value: enumValue, label: enumLabel }, index) => ({
|
|
1617
|
+
value: multiple ? enumValue : (0, import_utils40.enumOptionValueEncoder)(enumValue, index, optionValueFormat),
|
|
1618
|
+
label: enumLabel,
|
|
1602
1619
|
index,
|
|
1603
|
-
disabled: Array.isArray(enumDisabled) && enumDisabled.includes(
|
|
1620
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue)
|
|
1604
1621
|
}));
|
|
1605
1622
|
const cnClassName = cn({ "border-destructive": rawErrors.length > 0 }, className);
|
|
1606
1623
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "p-0.5", children: !multiple ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -1616,8 +1633,8 @@ function SelectWidget({
|
|
|
1616
1633
|
required,
|
|
1617
1634
|
placeholder,
|
|
1618
1635
|
className: cnClassName,
|
|
1619
|
-
onFocus:
|
|
1620
|
-
onBlur:
|
|
1636
|
+
onFocus: handleFancyFocus,
|
|
1637
|
+
onBlur: handleFancyBlur,
|
|
1621
1638
|
ariaDescribedby: (0, import_utils40.ariaDescribedByIds)(id)
|
|
1622
1639
|
}
|
|
1623
1640
|
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -1633,8 +1650,8 @@ function SelectWidget({
|
|
|
1633
1650
|
onValueChange: (values) => {
|
|
1634
1651
|
onChange((0, import_utils40.enumOptionValueDecoder)(values.map(String), enumOptions, optionValueFormat, optEmptyValue));
|
|
1635
1652
|
},
|
|
1636
|
-
onFocus:
|
|
1637
|
-
onBlur:
|
|
1653
|
+
onFocus: handleFancyFocus,
|
|
1654
|
+
onBlur: handleFancyBlur
|
|
1638
1655
|
}
|
|
1639
1656
|
) });
|
|
1640
1657
|
}
|
|
@@ -1675,9 +1692,9 @@ function TextareaWidget({
|
|
|
1675
1692
|
options,
|
|
1676
1693
|
className
|
|
1677
1694
|
}) {
|
|
1678
|
-
const
|
|
1679
|
-
const
|
|
1680
|
-
const
|
|
1695
|
+
const handleChange = ({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue);
|
|
1696
|
+
const handleBlur = ({ target }) => onBlur(id, target && target.value);
|
|
1697
|
+
const handleFocus = ({ target }) => onFocus(id, target && target.value);
|
|
1681
1698
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "flex p-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
1682
1699
|
Textarea,
|
|
1683
1700
|
{
|
|
@@ -1690,9 +1707,9 @@ function TextareaWidget({
|
|
|
1690
1707
|
required,
|
|
1691
1708
|
autoFocus: autofocus,
|
|
1692
1709
|
rows: options.rows || 5,
|
|
1693
|
-
onChange:
|
|
1694
|
-
onBlur:
|
|
1695
|
-
onFocus:
|
|
1710
|
+
onChange: handleChange,
|
|
1711
|
+
onBlur: handleBlur,
|
|
1712
|
+
onFocus: handleFocus,
|
|
1696
1713
|
"aria-describedby": (0, import_utils43.ariaDescribedByIds)(id),
|
|
1697
1714
|
className
|
|
1698
1715
|
}
|