@rjsf/react-bootstrap 6.0.0-beta.20 → 6.0.0-beta.21

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.
Files changed (36) hide show
  1. package/dist/index.cjs +111 -43
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/react-bootstrap.esm.js +107 -39
  4. package/dist/react-bootstrap.esm.js.map +4 -4
  5. package/dist/react-bootstrap.umd.js +70 -9
  6. package/lib/AddButton/AddButton.js +1 -1
  7. package/lib/AddButton/AddButton.js.map +1 -1
  8. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +3 -3
  9. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  10. package/lib/IconButton/IconButton.d.ts +6 -5
  11. package/lib/IconButton/IconButton.js +1 -1
  12. package/lib/IconButton/IconButton.js.map +1 -1
  13. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
  14. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +3 -2
  15. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  16. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
  17. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +22 -0
  18. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
  19. package/lib/OptionalDataControlsTemplate/index.d.ts +2 -0
  20. package/lib/OptionalDataControlsTemplate/index.js +3 -0
  21. package/lib/OptionalDataControlsTemplate/index.js.map +1 -0
  22. package/lib/Templates/Templates.js +2 -0
  23. package/lib/Templates/Templates.js.map +1 -1
  24. package/lib/TitleField/TitleField.d.ts +1 -1
  25. package/lib/TitleField/TitleField.js +9 -2
  26. package/lib/TitleField/TitleField.js.map +1 -1
  27. package/lib/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +7 -7
  29. package/src/AddButton/AddButton.tsx +1 -1
  30. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +20 -6
  31. package/src/IconButton/IconButton.tsx +12 -6
  32. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +4 -0
  33. package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +47 -0
  34. package/src/OptionalDataControlsTemplate/index.ts +2 -0
  35. package/src/Templates/Templates.ts +2 -0
  36. package/src/TitleField/TitleField.tsx +19 -2
@@ -15,10 +15,10 @@ function AddButton({
15
15
  return /* @__PURE__ */ jsx(
16
16
  Button,
17
17
  {
18
+ title: translateString(TranslatableString.AddItemButton),
18
19
  ...props,
19
20
  style: { width: "100%" },
20
21
  className: `ml-1 ${props.className}`,
21
- title: translateString(TranslatableString.AddItemButton),
22
22
  children: /* @__PURE__ */ jsx(BsPlus, {})
23
23
  }
24
24
  );
@@ -63,7 +63,20 @@ import {
63
63
  } from "@rjsf/utils";
64
64
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
65
65
  function ArrayFieldTemplate(props) {
66
- const { canAdd, disabled, fieldPathId, uiSchema, items, onAddClick, readonly, registry, required, schema, title } = props;
66
+ const {
67
+ canAdd,
68
+ disabled,
69
+ fieldPathId,
70
+ uiSchema,
71
+ items,
72
+ optionalDataControl,
73
+ onAddClick,
74
+ readonly,
75
+ registry,
76
+ required,
77
+ schema,
78
+ title
79
+ } = props;
67
80
  const uiOptions = getUiOptions2(uiSchema);
68
81
  const ArrayFieldDescriptionTemplate = getTemplate2(
69
82
  "ArrayFieldDescriptionTemplate",
@@ -80,6 +93,7 @@ function ArrayFieldTemplate(props) {
80
93
  registry,
81
94
  uiOptions
82
95
  );
96
+ const showOptionalDataControlInTitle = !readonly && !disabled;
83
97
  const {
84
98
  ButtonTemplates: { AddButton: AddButton2 }
85
99
  } = registry.templates;
@@ -92,7 +106,8 @@ function ArrayFieldTemplate(props) {
92
106
  schema,
93
107
  uiSchema,
94
108
  required,
95
- registry
109
+ registry,
110
+ optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
96
111
  }
97
112
  ),
98
113
  /* @__PURE__ */ jsx3(
@@ -106,7 +121,8 @@ function ArrayFieldTemplate(props) {
106
121
  }
107
122
  ),
108
123
  /* @__PURE__ */ jsxs2(Container, { fluid: true, className: "p-0 m-0", children: [
109
- items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx3(ArrayFieldItemTemplate2, { ...itemProps }, key)),
124
+ !showOptionalDataControlInTitle ? optionalDataControl : void 0,
125
+ items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx3(ArrayFieldItemTemplate2, { ...itemProps }, key)),
110
126
  canAdd && /* @__PURE__ */ jsx3(Container, { className: "", children: /* @__PURE__ */ jsxs2(Row2, { className: "mt-2", children: [
111
127
  /* @__PURE__ */ jsx3(Col2, { xs: 9 }),
112
128
  /* @__PURE__ */ jsx3(Col2, { xs: 3, className: "py-4 col-lg-3 col-3", children: /* @__PURE__ */ jsx3(
@@ -253,8 +269,8 @@ function RemoveButton(props) {
253
269
  IconButton,
254
270
  {
255
271
  title: translateString(TranslatableString3.RemoveButton),
256
- ...props,
257
272
  variant: "danger",
273
+ ...props,
258
274
  icon: /* @__PURE__ */ jsx7(IoIosRemove, {})
259
275
  }
260
276
  );
@@ -399,6 +415,7 @@ function ObjectFieldTemplate({
399
415
  fieldPathId,
400
416
  schema,
401
417
  formData,
418
+ optionalDataControl,
402
419
  onAddClick,
403
420
  disabled,
404
421
  readonly,
@@ -411,6 +428,7 @@ function ObjectFieldTemplate({
411
428
  registry,
412
429
  uiOptions
413
430
  );
431
+ const showOptionalDataControlInTitle = !readonly && !disabled;
414
432
  const {
415
433
  ButtonTemplates: { AddButton: AddButton2 }
416
434
  } = registry.templates;
@@ -423,7 +441,8 @@ function ObjectFieldTemplate({
423
441
  required,
424
442
  schema,
425
443
  uiSchema,
426
- registry
444
+ registry,
445
+ optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
427
446
  }
428
447
  ),
429
448
  description && /* @__PURE__ */ jsx13(
@@ -437,6 +456,7 @@ function ObjectFieldTemplate({
437
456
  }
438
457
  ),
439
458
  /* @__PURE__ */ jsxs7(Container2, { fluid: true, className: "p-0", children: [
459
+ !showOptionalDataControlInTitle ? optionalDataControl : void 0,
440
460
  properties.map((element, index) => /* @__PURE__ */ jsx13(Row4, { style: { marginBottom: "10px" }, className: element.hidden ? "d-none" : void 0, children: /* @__PURE__ */ jsxs7(Col4, { xs: 12, children: [
441
461
  " ",
442
462
  element.content
@@ -456,30 +476,77 @@ function ObjectFieldTemplate({
456
476
  ] });
457
477
  }
458
478
 
479
+ // src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx
480
+ import { BsPlus as BsPlus2 } from "@react-icons/all-files/bs/BsPlus";
481
+ import { jsx as jsx14 } from "react/jsx-runtime";
482
+ function OptionalDataControlsTemplate(props) {
483
+ const { id, registry, label, onAddClick, onRemoveClick } = props;
484
+ if (onAddClick) {
485
+ return /* @__PURE__ */ jsx14(
486
+ IconButton,
487
+ {
488
+ id,
489
+ registry,
490
+ className: "rjsf-add-optional-data",
491
+ icon: /* @__PURE__ */ jsx14(BsPlus2, {}),
492
+ onClick: onAddClick,
493
+ title: label,
494
+ size: "sm",
495
+ variant: "secondary"
496
+ }
497
+ );
498
+ } else if (onRemoveClick) {
499
+ return /* @__PURE__ */ jsx14(
500
+ RemoveButton,
501
+ {
502
+ id,
503
+ registry,
504
+ className: "rjsf-remove-optional-data",
505
+ onClick: onRemoveClick,
506
+ title: label,
507
+ size: "sm",
508
+ variant: "secondary"
509
+ }
510
+ );
511
+ }
512
+ return /* @__PURE__ */ jsx14("em", { id, children: label });
513
+ }
514
+
459
515
  // src/SubmitButton/SubmitButton.tsx
460
516
  import Button3 from "react-bootstrap/Button";
461
517
  import { getSubmitButtonOptions } from "@rjsf/utils";
462
- import { jsx as jsx14 } from "react/jsx-runtime";
518
+ import { jsx as jsx15 } from "react/jsx-runtime";
463
519
  function SubmitButton(props) {
464
520
  const { submitText, norender, props: submitButtonProps } = getSubmitButtonOptions(props.uiSchema);
465
521
  if (norender) {
466
522
  return null;
467
523
  }
468
- return /* @__PURE__ */ jsx14("div", { children: /* @__PURE__ */ jsx14(Button3, { variant: "primary", type: "submit", ...submitButtonProps, children: submitText }) });
524
+ return /* @__PURE__ */ jsx15("div", { children: /* @__PURE__ */ jsx15(Button3, { variant: "primary", type: "submit", ...submitButtonProps, children: submitText }) });
469
525
  }
470
526
 
471
527
  // src/TitleField/TitleField.tsx
472
528
  import { getUiOptions as getUiOptions5 } from "@rjsf/utils";
473
- import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
529
+ import Row5 from "react-bootstrap/Row";
530
+ import Col5 from "react-bootstrap/Col";
531
+ import Container3 from "react-bootstrap/Container";
532
+ import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
474
533
  function TitleField({
475
534
  id,
476
535
  title,
477
- uiSchema
536
+ uiSchema,
537
+ optionalDataControl
478
538
  }) {
479
539
  const uiOptions = getUiOptions5(uiSchema);
540
+ let heading = /* @__PURE__ */ jsx16("h5", { children: uiOptions.title || title });
541
+ if (optionalDataControl) {
542
+ heading = /* @__PURE__ */ jsx16(Container3, { fluid: true, className: "p-0", children: /* @__PURE__ */ jsxs8(Row5, { children: [
543
+ /* @__PURE__ */ jsx16(Col5, { xs: "11", children: heading }),
544
+ /* @__PURE__ */ jsx16(Col5, { xs: "1", style: { marginLeft: "-5px" }, children: optionalDataControl })
545
+ ] }) });
546
+ }
480
547
  return /* @__PURE__ */ jsxs8("div", { id, className: "my-1", children: [
481
- /* @__PURE__ */ jsx15("h5", { children: uiOptions.title || title }),
482
- /* @__PURE__ */ jsx15("hr", { className: "border-0 bg-secondary", style: { height: "1px" } })
548
+ heading,
549
+ /* @__PURE__ */ jsx16("hr", { className: "border-0 bg-secondary mt-0", style: { height: "1px" } })
483
550
  ] });
484
551
  }
485
552
 
@@ -489,10 +556,10 @@ import {
489
556
  buttonId as buttonId3,
490
557
  TranslatableString as TranslatableString4
491
558
  } from "@rjsf/utils";
492
- import Row5 from "react-bootstrap/Row";
493
- import Col5 from "react-bootstrap/Col";
559
+ import Row6 from "react-bootstrap/Row";
560
+ import Col6 from "react-bootstrap/Col";
494
561
  import Form4 from "react-bootstrap/Form";
495
- import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
562
+ import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
496
563
  function WrapIfAdditionalTemplate({
497
564
  classNames,
498
565
  style,
@@ -513,14 +580,14 @@ function WrapIfAdditionalTemplate({
513
580
  const keyLabel = translateString(TranslatableString4.KeyLabel, [label]);
514
581
  const additional = ADDITIONAL_PROPERTY_FLAG in schema;
515
582
  if (!additional) {
516
- return /* @__PURE__ */ jsx16("div", { className: classNames, style, children });
583
+ return /* @__PURE__ */ jsx17("div", { className: classNames, style, children });
517
584
  }
518
585
  const handleBlur = ({ target }) => onKeyChange(target.value);
519
586
  const keyId = `${id}-key`;
520
- return /* @__PURE__ */ jsxs9(Row5, { className: classNames, style, children: [
521
- /* @__PURE__ */ jsx16(Col5, { xs: 5, children: /* @__PURE__ */ jsxs9(Form4.Group, { children: [
522
- /* @__PURE__ */ jsx16(Form4.Label, { htmlFor: keyId, children: keyLabel }),
523
- /* @__PURE__ */ jsx16(
587
+ return /* @__PURE__ */ jsxs9(Row6, { className: classNames, style, children: [
588
+ /* @__PURE__ */ jsx17(Col6, { xs: 5, children: /* @__PURE__ */ jsxs9(Form4.Group, { children: [
589
+ /* @__PURE__ */ jsx17(Form4.Label, { htmlFor: keyId, children: keyLabel }),
590
+ /* @__PURE__ */ jsx17(
524
591
  Form4.Control,
525
592
  {
526
593
  required,
@@ -533,8 +600,8 @@ function WrapIfAdditionalTemplate({
533
600
  }
534
601
  )
535
602
  ] }) }),
536
- /* @__PURE__ */ jsx16(Col5, { xs: 5, children }),
537
- /* @__PURE__ */ jsx16(Col5, { xs: 2, className: "py-4 d-grid gap-2", children: /* @__PURE__ */ jsx16(
603
+ /* @__PURE__ */ jsx17(Col6, { xs: 5, children }),
604
+ /* @__PURE__ */ jsx17(Col6, { xs: 2, className: "py-4 d-grid gap-2", children: /* @__PURE__ */ jsx17(
538
605
  RemoveButton2,
539
606
  {
540
607
  id: buttonId3(id, "remove"),
@@ -570,6 +637,7 @@ function generateTemplates() {
570
637
  GridTemplate,
571
638
  MultiSchemaFieldTemplate,
572
639
  ObjectFieldTemplate,
640
+ OptionalDataControlsTemplate,
573
641
  TitleFieldTemplate: TitleField,
574
642
  WrapIfAdditionalTemplate
575
643
  };
@@ -585,7 +653,7 @@ import {
585
653
  schemaRequiresTrueValue
586
654
  } from "@rjsf/utils";
587
655
  import Form5 from "react-bootstrap/Form";
588
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
656
+ import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
589
657
  function CheckboxWidget(props) {
590
658
  const {
591
659
  id,
@@ -614,7 +682,7 @@ function CheckboxWidget(props) {
614
682
  const _onFocus = ({ target }) => onFocus(id, target && target.checked);
615
683
  const description = options.description || schema.description;
616
684
  return /* @__PURE__ */ jsxs10(Form5.Group, { className: disabled || readonly ? "disabled" : "", "aria-describedby": ariaDescribedByIds2(id), children: [
617
- !hideLabel && description && /* @__PURE__ */ jsx17(
685
+ !hideLabel && description && /* @__PURE__ */ jsx18(
618
686
  DescriptionFieldTemplate,
619
687
  {
620
688
  id: descriptionId2(id),
@@ -624,7 +692,7 @@ function CheckboxWidget(props) {
624
692
  registry
625
693
  }
626
694
  ),
627
- /* @__PURE__ */ jsx17(
695
+ /* @__PURE__ */ jsx18(
628
696
  Form5.Check,
629
697
  {
630
698
  id,
@@ -653,7 +721,7 @@ import {
653
721
  enumOptionsValueForIndex,
654
722
  optionId
655
723
  } from "@rjsf/utils";
656
- import { jsx as jsx18 } from "react/jsx-runtime";
724
+ import { jsx as jsx19 } from "react/jsx-runtime";
657
725
  function CheckboxesWidget({ id, disabled, options, value, autofocus, readonly, required, onChange, onBlur, onFocus }) {
658
726
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
659
727
  const checkboxesValues = Array.isArray(value) ? value : [value];
@@ -666,10 +734,10 @@ function CheckboxesWidget({ id, disabled, options, value, autofocus, readonly, r
666
734
  };
667
735
  const _onBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
668
736
  const _onFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
669
- return /* @__PURE__ */ jsx18(Form6.Group, { children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
737
+ return /* @__PURE__ */ jsx19(Form6.Group, { children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
670
738
  const checked = enumOptionsIsSelected(option.value, checkboxesValues);
671
739
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
672
- return /* @__PURE__ */ jsx18(
740
+ return /* @__PURE__ */ jsx19(
673
741
  Form6.Check,
674
742
  {
675
743
  inline,
@@ -700,7 +768,7 @@ import {
700
768
  enumOptionsValueForIndex as enumOptionsValueForIndex2,
701
769
  optionId as optionId2
702
770
  } from "@rjsf/utils";
703
- import { jsx as jsx19 } from "react/jsx-runtime";
771
+ import { jsx as jsx20 } from "react/jsx-runtime";
704
772
  function RadioWidget({
705
773
  id,
706
774
  options,
@@ -717,10 +785,10 @@ function RadioWidget({
717
785
  const _onBlur = ({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
718
786
  const _onFocus = ({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
719
787
  const inline = Boolean(options && options.inline);
720
- return /* @__PURE__ */ jsx19(Form7.Group, { className: "mb-0", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
788
+ return /* @__PURE__ */ jsx20(Form7.Group, { className: "mb-0", children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
721
789
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
722
790
  const checked = enumOptionsIsSelected2(option.value, value);
723
- const radio = /* @__PURE__ */ jsx19(
791
+ const radio = /* @__PURE__ */ jsx20(
724
792
  Form7.Check,
725
793
  {
726
794
  inline,
@@ -746,7 +814,7 @@ function RadioWidget({
746
814
  // src/RangeWidget/RangeWidget.tsx
747
815
  import { rangeSpec } from "@rjsf/utils";
748
816
  import FormRange from "react-bootstrap/FormRange";
749
- import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
817
+ import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
750
818
  function RangeWidget(props) {
751
819
  const { id, value, disabled, onChange, onBlur, onFocus, schema } = props;
752
820
  const _onChange = ({ target: { value: value2 } }) => onChange(value2);
@@ -763,8 +831,8 @@ function RangeWidget(props) {
763
831
  ...rangeSpec(schema)
764
832
  };
765
833
  return /* @__PURE__ */ jsxs11(Fragment3, { children: [
766
- /* @__PURE__ */ jsx20(FormRange, { ...rangeProps }),
767
- /* @__PURE__ */ jsx20("span", { className: "range-view", children: value })
834
+ /* @__PURE__ */ jsx21(FormRange, { ...rangeProps }),
835
+ /* @__PURE__ */ jsx21("span", { className: "range-view", children: value })
768
836
  ] });
769
837
  }
770
838
 
@@ -775,7 +843,7 @@ import {
775
843
  enumOptionsIndexForValue,
776
844
  enumOptionsValueForIndex as enumOptionsValueForIndex3
777
845
  } from "@rjsf/utils";
778
- import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
846
+ import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
779
847
  function SelectWidget({
780
848
  schema,
781
849
  id,
@@ -828,10 +896,10 @@ function SelectWidget({
828
896
  },
829
897
  "aria-describedby": ariaDescribedByIds5(id),
830
898
  children: [
831
- showPlaceholderOption && /* @__PURE__ */ jsx21("option", { value: "", children: placeholder }),
899
+ showPlaceholderOption && /* @__PURE__ */ jsx22("option", { value: "", children: placeholder }),
832
900
  enumOptions.map(({ value: value2, label }, i) => {
833
901
  const disabled2 = Array.isArray(enumDisabled) && enumDisabled.indexOf(value2) != -1;
834
- return /* @__PURE__ */ jsx21("option", { id: label, value: String(i), disabled: disabled2, children: label }, i);
902
+ return /* @__PURE__ */ jsx22("option", { id: label, value: String(i), disabled: disabled2, children: label }, i);
835
903
  })
836
904
  ]
837
905
  }
@@ -842,7 +910,7 @@ function SelectWidget({
842
910
  import { ariaDescribedByIds as ariaDescribedByIds6 } from "@rjsf/utils";
843
911
  import FormControl from "react-bootstrap/FormControl";
844
912
  import InputGroup from "react-bootstrap/InputGroup";
845
- import { jsx as jsx22 } from "react/jsx-runtime";
913
+ import { jsx as jsx23 } from "react/jsx-runtime";
846
914
  function TextareaWidget({
847
915
  id,
848
916
  placeholder,
@@ -859,7 +927,7 @@ function TextareaWidget({
859
927
  const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
860
928
  const _onBlur = ({ target }) => onBlur(id, target && target.value);
861
929
  const _onFocus = ({ target }) => onFocus(id, target && target.value);
862
- return /* @__PURE__ */ jsx22(InputGroup, { children: /* @__PURE__ */ jsx22(
930
+ return /* @__PURE__ */ jsx23(InputGroup, { children: /* @__PURE__ */ jsx23(
863
931
  FormControl,
864
932
  {
865
933
  id,