@rjsf/primereact 6.1.2 → 6.2.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.
@@ -69,6 +69,9 @@ function ArrayFieldTemplate(props) {
69
69
  title,
70
70
  registry,
71
71
  required,
72
+ // Destructure the following props out so that they aren't put into the DOM
73
+ formData,
74
+ rawErrors,
72
75
  ...rest
73
76
  } = props;
74
77
  const uiOptions = getUiOptions2(uiSchema);
@@ -147,13 +150,14 @@ function ArrayFieldTemplate(props) {
147
150
  }
148
151
 
149
152
  // src/BaseInputTemplate/BaseInputTemplate.tsx
153
+ import { useCallback } from "react";
150
154
  import {
151
155
  ariaDescribedByIds,
152
156
  examplesId,
153
157
  getInputProps
154
158
  } from "@rjsf/utils";
155
159
  import { InputText } from "primereact/inputtext";
156
- import { jsx as jsx4 } from "react/jsx-runtime";
160
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
157
161
  function BaseInputTemplate(props) {
158
162
  const {
159
163
  id,
@@ -174,35 +178,47 @@ function BaseInputTemplate(props) {
174
178
  registry,
175
179
  rawErrors = []
176
180
  } = props;
181
+ const { ClearButton: ClearButton2 } = registry.templates.ButtonTemplates;
177
182
  const { AutoCompleteWidget: AutoCompleteWidget2 } = registry.widgets;
178
- if (Array.isArray(schema.examples)) {
179
- return /* @__PURE__ */ jsx4(AutoCompleteWidget2, { ...props });
180
- }
181
183
  const inputProps = getInputProps(schema, type, options);
182
184
  const primeProps = options.prime || {};
183
185
  const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
184
186
  const _onBlur = () => onBlur && onBlur(id, value);
185
187
  const _onFocus = () => onFocus && onFocus(id, value);
186
- return /* @__PURE__ */ jsx4(
187
- InputText,
188
- {
189
- id,
190
- name: htmlName || id,
191
- placeholder,
192
- ...primeProps,
193
- ...inputProps,
194
- required,
195
- autoFocus: autofocus,
196
- disabled: disabled || readonly,
197
- list: schema.examples ? examplesId(id) : void 0,
198
- value: value || value === 0 ? value : "",
199
- invalid: rawErrors.length > 0,
200
- onChange: onChangeOverride || _onChange,
201
- onBlur: _onBlur,
202
- onFocus: _onFocus,
203
- "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
204
- }
188
+ const _onClear = useCallback(
189
+ (e) => {
190
+ e.preventDefault();
191
+ e.stopPropagation();
192
+ onChange(options.emptyValue ?? "");
193
+ },
194
+ [onChange, options.emptyValue]
205
195
  );
196
+ if (Array.isArray(schema.examples)) {
197
+ return /* @__PURE__ */ jsx4(AutoCompleteWidget2, { ...props });
198
+ }
199
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
200
+ /* @__PURE__ */ jsx4(
201
+ InputText,
202
+ {
203
+ id,
204
+ name: htmlName || id,
205
+ placeholder,
206
+ ...primeProps,
207
+ ...inputProps,
208
+ required,
209
+ autoFocus: autofocus,
210
+ disabled: disabled || readonly,
211
+ list: schema.examples ? examplesId(id) : void 0,
212
+ value: value || value === 0 ? value : "",
213
+ invalid: rawErrors.length > 0,
214
+ onChange: onChangeOverride || _onChange,
215
+ onBlur: _onBlur,
216
+ onFocus: _onFocus,
217
+ "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
218
+ }
219
+ ),
220
+ options.allowClearTextInputs && !readonly && !disabled && value && /* @__PURE__ */ jsx4(ClearButton2, { registry, onClick: _onClear })
221
+ ] });
206
222
  }
207
223
 
208
224
  // src/DescriptionField/DescriptionField.tsx
@@ -220,14 +236,14 @@ function DescriptionField(props) {
220
236
  import { Message } from "primereact/message";
221
237
  import { TimesCircleIcon } from "primereact/icons/timescircle";
222
238
  import { TranslatableString as TranslatableString2 } from "@rjsf/utils";
223
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
239
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
224
240
  function ErrorList({
225
241
  errors,
226
242
  registry
227
243
  }) {
228
244
  const { translateString } = registry;
229
- const content = /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column" }, children: [
230
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "row", alignItems: "center", gap: "0.5rem" }, children: [
245
+ const content = /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column" }, children: [
246
+ /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "row", alignItems: "center", gap: "0.5rem" }, children: [
231
247
  /* @__PURE__ */ jsx6(TimesCircleIcon, { style: { width: "1.5rem", height: "1.5rem" } }),
232
248
  /* @__PURE__ */ jsx6("div", { className: "p-message-summary", children: translateString(TranslatableString2.ErrorsLabel) })
233
249
  ] }),
@@ -283,6 +299,12 @@ function RemoveButton(props) {
283
299
  } = props;
284
300
  return /* @__PURE__ */ jsx7(IconButton, { title: translateString(TranslatableString3.RemoveButton), ...props, icon: "trash" });
285
301
  }
302
+ function ClearButton(props) {
303
+ const {
304
+ registry: { translateString }
305
+ } = props;
306
+ return /* @__PURE__ */ jsx7(IconButton, { title: translateString(TranslatableString3.ClearButton), ...props, icon: "times" });
307
+ }
286
308
 
287
309
  // src/FieldErrorTemplate/FieldErrorTemplate.tsx
288
310
  import { errorId } from "@rjsf/utils";
@@ -327,12 +349,12 @@ import {
327
349
  } from "@rjsf/utils";
328
350
 
329
351
  // src/util.tsx
330
- import { jsxs as jsxs4 } from "react/jsx-runtime";
352
+ import { jsxs as jsxs5 } from "react/jsx-runtime";
331
353
  function Label({ id, text, required }) {
332
354
  if (!text) {
333
355
  return null;
334
356
  }
335
- return /* @__PURE__ */ jsxs4("label", { htmlFor: id, children: [
357
+ return /* @__PURE__ */ jsxs5("label", { htmlFor: id, children: [
336
358
  text,
337
359
  " ",
338
360
  required ? "*" : ""
@@ -340,7 +362,7 @@ function Label({ id, text, required }) {
340
362
  }
341
363
 
342
364
  // src/FieldTemplate/FieldTemplate.tsx
343
- import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
365
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
344
366
  function FieldTemplate(props) {
345
367
  const { children, errors, help, displayLabel, description, rawDescription, hidden, uiSchema, registry } = props;
346
368
  const uiOptions = getUiOptions3(uiSchema);
@@ -353,7 +375,7 @@ function FieldTemplate(props) {
353
375
  return /* @__PURE__ */ jsx10("div", { style: { display: "none" }, children });
354
376
  }
355
377
  const isCheckbox = uiOptions.widget === "checkbox";
356
- return /* @__PURE__ */ jsx10(WrapIfAdditionalTemplate2, { ...props, children: /* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem", marginBottom: "1rem" }, children: [
378
+ return /* @__PURE__ */ jsx10(WrapIfAdditionalTemplate2, { ...props, children: /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem", marginBottom: "1rem" }, children: [
357
379
  displayLabel && !isCheckbox && /* @__PURE__ */ jsx10(Label, { id: props.id, text: props.label, required: props.required }),
358
380
  children,
359
381
  displayLabel && rawDescription && !isCheckbox && /* @__PURE__ */ jsx10("small", { children: description }),
@@ -364,10 +386,10 @@ function FieldTemplate(props) {
364
386
 
365
387
  // src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx
366
388
  import { Fieldset as Fieldset2 } from "primereact/fieldset";
367
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
389
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
368
390
  function MultiSchemaFieldTemplate(props) {
369
391
  const { selector, optionSchemaField } = props;
370
- return /* @__PURE__ */ jsxs6(Fieldset2, { children: [
392
+ return /* @__PURE__ */ jsxs7(Fieldset2, { children: [
371
393
  /* @__PURE__ */ jsx11("div", { style: { marginBottom: "1rem" }, children: selector }),
372
394
  optionSchemaField
373
395
  ] });
@@ -382,7 +404,7 @@ import {
382
404
  titleId,
383
405
  buttonId as buttonId2
384
406
  } from "@rjsf/utils";
385
- import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
407
+ import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
386
408
  function ObjectFieldTemplate(props) {
387
409
  const {
388
410
  description,
@@ -410,7 +432,7 @@ function ObjectFieldTemplate(props) {
410
432
  const {
411
433
  ButtonTemplates: { AddButton: AddButton2 }
412
434
  } = registry.templates;
413
- return /* @__PURE__ */ jsxs7(Fragment2, { children: [
435
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
414
436
  title && /* @__PURE__ */ jsx12(
415
437
  TitleFieldTemplate,
416
438
  {
@@ -497,7 +519,7 @@ function SubmitButton({ uiSchema }) {
497
519
  // src/TitleField/TitleField.tsx
498
520
  import { Divider } from "primereact/divider";
499
521
  import { getUiOptions as getUiOptions5, titleId as titleId2 } from "@rjsf/utils";
500
- import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
522
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
501
523
  function TitleField({
502
524
  id,
503
525
  title,
@@ -506,18 +528,18 @@ function TitleField({
506
528
  optionalDataControl
507
529
  }) {
508
530
  const uiOptions = getUiOptions5(uiSchema);
509
- let heading = /* @__PURE__ */ jsxs8("h5", { style: { margin: 0, fontSize: id === titleId2("root") ? "1.5rem" : "1.2rem" }, children: [
531
+ let heading = /* @__PURE__ */ jsxs9("h5", { style: { margin: 0, fontSize: id === titleId2("root") ? "1.5rem" : "1.2rem" }, children: [
510
532
  uiOptions.title || title,
511
533
  " ",
512
534
  required ? "*" : ""
513
535
  ] });
514
536
  if (optionalDataControl) {
515
- heading = /* @__PURE__ */ jsxs8("div", { style: { display: "flex" }, children: [
537
+ heading = /* @__PURE__ */ jsxs9("div", { style: { display: "flex" }, children: [
516
538
  /* @__PURE__ */ jsx15("div", { style: { flexGrow: 1 }, children: heading }),
517
539
  /* @__PURE__ */ jsx15("div", { style: { marginLeft: "-5px" }, children: optionalDataControl })
518
540
  ] });
519
541
  }
520
- return /* @__PURE__ */ jsxs8("div", { id, children: [
542
+ return /* @__PURE__ */ jsxs9("div", { id, children: [
521
543
  heading,
522
544
  /* @__PURE__ */ jsx15(Divider, { pt: { root: { style: { marginTop: "0.5rem" } } } })
523
545
  ] });
@@ -530,7 +552,7 @@ import {
530
552
  TranslatableString as TranslatableString4
531
553
  } from "@rjsf/utils";
532
554
  import { InputText as InputText2 } from "primereact/inputtext";
533
- import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
555
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
534
556
  function WrapIfAdditionalTemplate({
535
557
  classNames,
536
558
  style,
@@ -556,13 +578,13 @@ function WrapIfAdditionalTemplate({
556
578
  if (!additional) {
557
579
  return /* @__PURE__ */ jsx16("div", { className: classNames, style, children });
558
580
  }
559
- return /* @__PURE__ */ jsxs9(
581
+ return /* @__PURE__ */ jsxs10(
560
582
  "div",
561
583
  {
562
584
  className: classNames,
563
585
  style: { ...style, display: "flex", alignItems: "flex-start", gap: "1rem" },
564
586
  children: [
565
- /* @__PURE__ */ jsxs9("div", { style: { flex: 1 }, children: [
587
+ /* @__PURE__ */ jsxs10("div", { style: { flex: 1 }, children: [
566
588
  displayLabel && /* @__PURE__ */ jsx16("label", { htmlFor: `${id}-key`, style: { display: "block", marginBottom: "0.5rem" }, children: keyLabel }),
567
589
  /* @__PURE__ */ jsx16(
568
590
  InputText2,
@@ -599,16 +621,16 @@ import {
599
621
  getUiOptions as getUiOptions6,
600
622
  titleId as titleId3
601
623
  } from "@rjsf/utils";
602
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
624
+ import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
603
625
  function ArrayFieldTitleTemplate({ title, uiSchema, required, fieldPathId, optionalDataControl }) {
604
626
  const uiOptions = getUiOptions6(uiSchema);
605
- let heading = /* @__PURE__ */ jsxs10("h5", { id: titleId3(fieldPathId), style: { margin: 0, fontSize: "1.5rem", marginBottom: "0.2rem" }, children: [
627
+ let heading = /* @__PURE__ */ jsxs11("h5", { id: titleId3(fieldPathId), style: { margin: 0, fontSize: "1.5rem", marginBottom: "0.2rem" }, children: [
606
628
  uiOptions.title || title,
607
629
  " ",
608
630
  required ? "*" : ""
609
631
  ] });
610
632
  if (optionalDataControl) {
611
- heading = /* @__PURE__ */ jsxs10("div", { style: { display: "flex" }, children: [
633
+ heading = /* @__PURE__ */ jsxs11("div", { style: { display: "flex" }, children: [
612
634
  /* @__PURE__ */ jsx17("div", { style: { flexGrow: 1 }, children: heading }),
613
635
  /* @__PURE__ */ jsx17("div", { children: optionalDataControl })
614
636
  ] });
@@ -698,7 +720,8 @@ function generateTemplates() {
698
720
  MoveDownButton,
699
721
  MoveUpButton,
700
722
  RemoveButton,
701
- SubmitButton
723
+ SubmitButton,
724
+ ClearButton
702
725
  },
703
726
  DescriptionFieldTemplate: DescriptionField,
704
727
  ErrorListTemplate: ErrorList,
@@ -722,7 +745,7 @@ import {
722
745
  getInputProps as getInputProps2
723
746
  } from "@rjsf/utils";
724
747
  import { AutoComplete } from "primereact/autocomplete";
725
- import { Fragment as Fragment3, jsx as jsx19 } from "react/jsx-runtime";
748
+ import { Fragment as Fragment4, jsx as jsx19 } from "react/jsx-runtime";
726
749
  function AutoCompleteWidget(props) {
727
750
  const {
728
751
  id,
@@ -761,7 +784,7 @@ function AutoCompleteWidget(props) {
761
784
  placeholder,
762
785
  ...primeProps,
763
786
  ...inputProps,
764
- loadingIcon: /* @__PURE__ */ jsx19(Fragment3, {}),
787
+ loadingIcon: /* @__PURE__ */ jsx19(Fragment4, {}),
765
788
  required,
766
789
  autoFocus: autofocus,
767
790
  disabled: disabled || readonly,
@@ -802,7 +825,7 @@ import {
802
825
  schemaRequiresTrueValue
803
826
  } from "@rjsf/utils";
804
827
  import { Checkbox } from "primereact/checkbox";
805
- import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
828
+ import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
806
829
  function CheckboxWidget(props) {
807
830
  const {
808
831
  id,
@@ -833,7 +856,7 @@ function CheckboxWidget(props) {
833
856
  const _onFocus = () => onFocus && onFocus(id, value);
834
857
  const description = options.description ?? schema.description;
835
858
  const primeProps = options.prime || {};
836
- return /* @__PURE__ */ jsxs11(Fragment4, { children: [
859
+ return /* @__PURE__ */ jsxs12(Fragment5, { children: [
837
860
  !hideLabel && !!description && /* @__PURE__ */ jsx20(
838
861
  DescriptionFieldTemplate,
839
862
  {
@@ -844,7 +867,7 @@ function CheckboxWidget(props) {
844
867
  registry
845
868
  }
846
869
  ),
847
- /* @__PURE__ */ jsxs11("div", { style: { display: "flex", flexDirection: "row", gap: "0.5rem", alignItems: "center" }, children: [
870
+ /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "row", gap: "0.5rem", alignItems: "center" }, children: [
848
871
  /* @__PURE__ */ jsx20(
849
872
  Checkbox,
850
873
  {
@@ -877,7 +900,7 @@ import {
877
900
  descriptionId as descriptionId3,
878
901
  getTemplate as getTemplate6
879
902
  } from "@rjsf/utils";
880
- import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
903
+ import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
881
904
  function CheckboxesWidget(props) {
882
905
  const {
883
906
  id,
@@ -913,7 +936,7 @@ function CheckboxesWidget(props) {
913
936
  const _onBlur = () => onBlur(id, value);
914
937
  const _onFocus = () => onFocus(id, value);
915
938
  const description = options.description ?? schema.description;
916
- return /* @__PURE__ */ jsxs12(
939
+ return /* @__PURE__ */ jsxs13(
917
940
  "div",
918
941
  {
919
942
  id,
@@ -932,7 +955,7 @@ function CheckboxesWidget(props) {
932
955
  Array.isArray(enumOptions) && enumOptions.map((option, index) => {
933
956
  const checked = enumOptionsIsSelected(option.value, checkboxesValues);
934
957
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
935
- return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "row", gap: "0.5rem", alignItems: "center" }, children: [
958
+ return /* @__PURE__ */ jsxs13("div", { style: { display: "flex", flexDirection: "row", gap: "0.5rem", alignItems: "center" }, children: [
936
959
  /* @__PURE__ */ jsx21(
937
960
  Checkbox2,
938
961
  {
@@ -1068,7 +1091,7 @@ import {
1068
1091
  optionId as optionId2
1069
1092
  } from "@rjsf/utils";
1070
1093
  import { RadioButton } from "primereact/radiobutton";
1071
- import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
1094
+ import { jsx as jsx24, jsxs as jsxs14 } from "react/jsx-runtime";
1072
1095
  function RadioWidget(props) {
1073
1096
  const { id, htmlName, value, disabled, readonly, onChange, onBlur, onFocus, options } = props;
1074
1097
  const primeProps = options.prime || {};
@@ -1081,7 +1104,7 @@ function RadioWidget(props) {
1081
1104
  return /* @__PURE__ */ jsx24("div", { style: { display: "flex", flexDirection: "row", gap: "1rem" }, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
1082
1105
  const checked = enumOptionsIsSelected2(option.value, value);
1083
1106
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
1084
- return /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center" }, children: [
1107
+ return /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center" }, children: [
1085
1108
  /* @__PURE__ */ jsx24(
1086
1109
  RadioButton,
1087
1110
  {
@@ -1105,7 +1128,7 @@ function RadioWidget(props) {
1105
1128
  // src/RangeWidget/RangeWidget.tsx
1106
1129
  import { Slider } from "primereact/slider";
1107
1130
  import { ariaDescribedByIds as ariaDescribedByIds8, rangeSpec } from "@rjsf/utils";
1108
- import { Fragment as Fragment5, jsx as jsx25 } from "react/jsx-runtime";
1131
+ import { Fragment as Fragment6, jsx as jsx25 } from "react/jsx-runtime";
1109
1132
  function RangeWidget(props) {
1110
1133
  const { value, readonly, disabled, onBlur, onFocus, options, schema, onChange, id } = props;
1111
1134
  const primeProps = options.prime || {};
@@ -1115,7 +1138,7 @@ function RangeWidget(props) {
1115
1138
  };
1116
1139
  const _onBlur = ({ target }) => onBlur(id, target && target.value);
1117
1140
  const _onFocus = ({ target }) => onFocus(id, target && target.value);
1118
- return /* @__PURE__ */ jsx25(Fragment5, { children: /* @__PURE__ */ jsx25(
1141
+ return /* @__PURE__ */ jsx25(Fragment6, { children: /* @__PURE__ */ jsx25(
1119
1142
  Slider,
1120
1143
  {
1121
1144
  ...primeProps,