@abgov/react-components 6.4.1 → 6.5.0-alpha.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.
Files changed (85) hide show
  1. package/experimental/form/form.d.ts +1 -2
  2. package/experimental/form/task-list.d.ts +1 -2
  3. package/experimental/form/task.d.ts +1 -2
  4. package/experimental/resizable-panel/ResizablePanel.d.ts +0 -1
  5. package/experimental.js.map +1 -1
  6. package/experimental.mjs.map +1 -1
  7. package/icon-CK55b563.js.map +1 -1
  8. package/icon-CoYGOp1V.mjs.map +1 -1
  9. package/index.d.ts +4 -1
  10. package/index.js +238 -67
  11. package/index.js.map +1 -1
  12. package/index.mjs +239 -68
  13. package/index.mjs.map +1 -1
  14. package/lib/accordion/accordion.d.ts +1 -2
  15. package/lib/app-header/app-header.d.ts +0 -1
  16. package/lib/app-header-menu/app-header-menu.d.ts +1 -2
  17. package/lib/badge/badge.d.ts +1 -2
  18. package/lib/block/block.d.ts +1 -2
  19. package/lib/button/button.d.ts +1 -2
  20. package/lib/button-group/button-group.d.ts +1 -2
  21. package/lib/calendar/calendar.d.ts +1 -2
  22. package/lib/callout/callout.d.ts +0 -1
  23. package/lib/card/card-actions.d.ts +0 -1
  24. package/lib/card/card-content.d.ts +0 -1
  25. package/lib/card/card-group.d.ts +0 -1
  26. package/lib/card/card-image.d.ts +0 -1
  27. package/lib/card/card.d.ts +1 -2
  28. package/lib/checkbox/checkbox.d.ts +1 -2
  29. package/lib/chip/chip.d.ts +0 -1
  30. package/lib/circular-progress/circular-progress.d.ts +0 -1
  31. package/lib/container/container.d.ts +1 -2
  32. package/lib/date-picker/date-picker.d.ts +1 -2
  33. package/lib/details/details.d.ts +1 -2
  34. package/lib/divider/divider.d.ts +0 -1
  35. package/lib/drawer/drawer.d.ts +1 -2
  36. package/lib/dropdown/dropdown-item.d.ts +0 -1
  37. package/lib/dropdown/dropdown.d.ts +1 -2
  38. package/lib/file-upload-card/file-upload-card.d.ts +0 -1
  39. package/lib/file-upload-input/file-upload-input.d.ts +0 -1
  40. package/lib/filter-chip/filter-chip.d.ts +0 -1
  41. package/lib/footer/footer.d.ts +0 -1
  42. package/lib/footer-meta-section/footer-meta-section.d.ts +0 -1
  43. package/lib/footer-nav-section/footer-nav-section.d.ts +0 -1
  44. package/lib/form/fieldset.d.ts +25 -0
  45. package/lib/form/public-form-page.d.ts +59 -0
  46. package/lib/form/public-form-summary.d.ts +17 -0
  47. package/lib/form/public-form.d.ts +24 -0
  48. package/lib/form-item/form-item.d.ts +12 -3
  49. package/lib/form-step/form-step.d.ts +0 -1
  50. package/lib/form-stepper/form-stepper.d.ts +1 -2
  51. package/lib/grid/grid.d.ts +1 -2
  52. package/lib/hero-banner/hero-banner-actions.d.ts +0 -1
  53. package/lib/hero-banner/hero-banner.d.ts +0 -1
  54. package/lib/icon/icon.d.ts +1 -2
  55. package/lib/icon-button/icon-button.d.ts +1 -2
  56. package/lib/input/input.d.ts +4 -5
  57. package/lib/link/link.d.ts +1 -2
  58. package/lib/link-button/link-button.d.ts +1 -2
  59. package/lib/microsite-header/microsite-header.d.ts +1 -2
  60. package/lib/modal/modal.d.ts +1 -2
  61. package/lib/notification/notification.d.ts +0 -1
  62. package/lib/one-column-layout/one-column-layout.d.ts +0 -1
  63. package/lib/page-block/page-block.d.ts +0 -1
  64. package/lib/pages/pages.d.ts +1 -2
  65. package/lib/pagination/pagination.d.ts +0 -1
  66. package/lib/popover/popover.d.ts +1 -2
  67. package/lib/radio-group/radio-group.d.ts +5 -4
  68. package/lib/radio-group/radio.d.ts +1 -2
  69. package/lib/side-menu/side-menu.d.ts +0 -1
  70. package/lib/side-menu-group/side-menu-group.d.ts +1 -2
  71. package/lib/side-menu-heading/side-menu-heading.d.ts +1 -2
  72. package/lib/skeleton/skeleton.d.ts +0 -1
  73. package/lib/spacer/spacer.d.ts +0 -1
  74. package/lib/spinner/spinner.d.ts +1 -2
  75. package/lib/tab/tab.d.ts +0 -1
  76. package/lib/table/table-sort-header.d.ts +1 -2
  77. package/lib/table/table.d.ts +1 -2
  78. package/lib/tabs/tabs.d.ts +1 -2
  79. package/lib/text/text.d.ts +1 -2
  80. package/lib/textarea/textarea.d.ts +2 -3
  81. package/lib/three-column-layout/three-column-layout.d.ts +0 -1
  82. package/lib/tooltip/tooltip.d.ts +1 -2
  83. package/lib/two-column-layout/two-column-layout.d.ts +0 -1
  84. package/package.json +1 -1
  85. package/lib/fieldset/fieldset.d.ts +0 -30
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useRef, useEffect } from "react";
2
+ import { useRef, useEffect, useLayoutEffect } from "react";
3
3
  import { G, a } from "./icon-CoYGOp1V.mjs";
4
4
  function GoabAccordion({
5
5
  open,
@@ -719,53 +719,6 @@ function GoabDropdownItem({
719
719
  }
720
720
  );
721
721
  }
722
- function GoabFieldset({
723
- heading,
724
- buttonText,
725
- id,
726
- onContinue,
727
- children,
728
- mt,
729
- mr,
730
- mb,
731
- ml,
732
- first,
733
- last
734
- }) {
735
- const ref = useRef(null);
736
- useEffect(() => {
737
- if (!ref.current) return;
738
- const current = ref.current;
739
- const _continue = (e) => {
740
- const event = e.detail;
741
- return onContinue == null ? void 0 : onContinue(event);
742
- };
743
- if (onContinue) {
744
- current.addEventListener("_continue", _continue);
745
- }
746
- return () => {
747
- if (onContinue) {
748
- current.removeEventListener("_continue", _continue);
749
- }
750
- };
751
- }, [ref, onContinue]);
752
- return /* @__PURE__ */ jsx(
753
- "goa-public-form-page",
754
- {
755
- ref,
756
- id,
757
- first: first ? "true" : void 0,
758
- last: last ? "true" : void 0,
759
- heading,
760
- buttontext: buttonText,
761
- mt,
762
- mr,
763
- mb,
764
- ml,
765
- children
766
- }
767
- );
768
- }
769
722
  function GoabFileUploadCard({
770
723
  filename,
771
724
  size,
@@ -864,6 +817,209 @@ function GoabAppFooterNavSection({
864
817
  }
865
818
  );
866
819
  }
820
+ function GoabFieldset({
821
+ id,
822
+ sectionTitle,
823
+ dispatchOn,
824
+ onContinue,
825
+ onChange,
826
+ children
827
+ }) {
828
+ const ref = useRef(null);
829
+ useEffect(() => {
830
+ if (!ref.current) return;
831
+ const current = ref.current;
832
+ const changeListener = (e) => {
833
+ const detail = e.detail;
834
+ onChange == null ? void 0 : onChange(detail);
835
+ };
836
+ const continueListener = (e) => {
837
+ const event = e.detail;
838
+ return onContinue == null ? void 0 : onContinue(event);
839
+ };
840
+ if (onContinue) {
841
+ current.addEventListener("_continue", continueListener);
842
+ }
843
+ if (onChange) {
844
+ current.addEventListener("_change", changeListener);
845
+ }
846
+ return () => {
847
+ if (onContinue) {
848
+ current.removeEventListener("_continue", continueListener);
849
+ }
850
+ if (onChange) {
851
+ current.removeEventListener("_change", changeListener);
852
+ }
853
+ };
854
+ }, [ref, onContinue]);
855
+ return /* @__PURE__ */ jsx(
856
+ "goa-fieldset",
857
+ {
858
+ ref,
859
+ id,
860
+ "section-title": sectionTitle,
861
+ "dispatch-on": dispatchOn,
862
+ children
863
+ }
864
+ );
865
+ }
866
+ function GoabPublicFormPage({
867
+ id = "",
868
+ heading = "",
869
+ subHeading = "",
870
+ summaryHeading = "",
871
+ sectionTitle = "",
872
+ backUrl = "",
873
+ type = "step",
874
+ buttonText = "",
875
+ buttonVisibility = "visible",
876
+ first = false,
877
+ last = false,
878
+ onContinue,
879
+ onBack,
880
+ onFieldsetChange,
881
+ onComplete,
882
+ children,
883
+ mt,
884
+ mr,
885
+ mb,
886
+ ml
887
+ }) {
888
+ const ref = useRef(null);
889
+ useEffect(() => {
890
+ if (!ref.current) return;
891
+ const current = ref.current;
892
+ const continueListener = (e) => {
893
+ onContinue == null ? void 0 : onContinue(e);
894
+ };
895
+ const backListener = (e) => {
896
+ onBack == null ? void 0 : onBack(e);
897
+ };
898
+ const fieldsetChangeListener = (e) => {
899
+ const detail = e.detail;
900
+ onFieldsetChange == null ? void 0 : onFieldsetChange(detail);
901
+ };
902
+ const completeListener = (e) => {
903
+ const detail = e.detail;
904
+ onComplete == null ? void 0 : onComplete(detail);
905
+ };
906
+ if (onContinue) {
907
+ current.addEventListener("_continue", continueListener);
908
+ }
909
+ if (onBack) {
910
+ current.addEventListener("_back", backListener);
911
+ }
912
+ if (onFieldsetChange) {
913
+ current.addEventListener("_fieldsetChange", fieldsetChangeListener);
914
+ }
915
+ if (onComplete) {
916
+ current.addEventListener("_complete", completeListener);
917
+ }
918
+ return () => {
919
+ if (onContinue) {
920
+ current.removeEventListener("_continue", continueListener);
921
+ }
922
+ if (onBack) {
923
+ current.removeEventListener("_back", backListener);
924
+ }
925
+ if (onFieldsetChange) {
926
+ current.removeEventListener("_fieldsetChange", fieldsetChangeListener);
927
+ }
928
+ if (onComplete) {
929
+ current.removeEventListener("_complete", completeListener);
930
+ }
931
+ };
932
+ }, [ref, onContinue, onBack, onFieldsetChange, onComplete]);
933
+ return /* @__PURE__ */ jsx(
934
+ "goa-public-form-page",
935
+ {
936
+ ref,
937
+ id,
938
+ heading,
939
+ "sub-heading": subHeading,
940
+ "section-title": sectionTitle,
941
+ "back-url": backUrl,
942
+ type,
943
+ "button-text": buttonText,
944
+ "button-visibility": buttonVisibility,
945
+ first,
946
+ last,
947
+ "summary-heading": summaryHeading,
948
+ mt,
949
+ mr,
950
+ mb,
951
+ ml,
952
+ children
953
+ }
954
+ );
955
+ }
956
+ function GoabPublicFormSummary({
957
+ heading = ""
958
+ }) {
959
+ const ref = useRef(null);
960
+ return /* @__PURE__ */ jsx(
961
+ "goa-public-form-summary",
962
+ {
963
+ ref,
964
+ heading
965
+ }
966
+ );
967
+ }
968
+ function GoabPublicForm({
969
+ status = "complete",
970
+ name,
971
+ onInit,
972
+ onComplete,
973
+ onStateChange,
974
+ children
975
+ }) {
976
+ const ref = useRef(null);
977
+ const initialized = useRef(false);
978
+ useLayoutEffect(() => {
979
+ if (!ref.current) return;
980
+ const current = ref.current;
981
+ const initListener = (e) => {
982
+ onInit == null ? void 0 : onInit(e);
983
+ };
984
+ if (onInit && !initialized.current) {
985
+ current.addEventListener("_init", initListener);
986
+ }
987
+ const completeListener = (e) => {
988
+ const detail = e.detail;
989
+ onComplete == null ? void 0 : onComplete(detail);
990
+ };
991
+ const stateChangeListener = (e) => {
992
+ const detail = e.detail;
993
+ onStateChange == null ? void 0 : onStateChange(detail.data);
994
+ };
995
+ if (onComplete) {
996
+ current.addEventListener("_complete", completeListener);
997
+ }
998
+ if (onStateChange) {
999
+ current.addEventListener("_stateChange", stateChangeListener);
1000
+ }
1001
+ return () => {
1002
+ if (onInit) {
1003
+ current.removeEventListener("_init", initListener);
1004
+ }
1005
+ if (onComplete) {
1006
+ current.removeEventListener("_complete", completeListener);
1007
+ }
1008
+ if (onStateChange) {
1009
+ current.removeEventListener("_stateChange", stateChangeListener);
1010
+ }
1011
+ };
1012
+ }, [onInit, onComplete, onStateChange]);
1013
+ return /* @__PURE__ */ jsx(
1014
+ "goa-public-form",
1015
+ {
1016
+ ref,
1017
+ status,
1018
+ name,
1019
+ children
1020
+ }
1021
+ );
1022
+ }
867
1023
  function GoabFormItem({
868
1024
  children,
869
1025
  helpText,
@@ -872,6 +1028,8 @@ function GoabFormItem({
872
1028
  label,
873
1029
  labelSize,
874
1030
  maxWidth,
1031
+ publicFormSummaryOrder,
1032
+ name,
875
1033
  mt,
876
1034
  mr,
877
1035
  mb,
@@ -888,6 +1046,8 @@ function GoabFormItem({
888
1046
  requirement,
889
1047
  helptext: typeof helpText === "string" ? helpText : void 0,
890
1048
  maxwidth: maxWidth,
1049
+ "public-form-summary-order": publicFormSummaryOrder,
1050
+ name,
891
1051
  mt,
892
1052
  mr,
893
1053
  mb,
@@ -1766,8 +1926,6 @@ const lightFormatters = {
1766
1926
  }
1767
1927
  };
1768
1928
  const dayPeriodEnum = {
1769
- am: "am",
1770
- pm: "pm",
1771
1929
  midnight: "midnight",
1772
1930
  noon: "noon",
1773
1931
  morning: "morning",
@@ -2703,7 +2861,7 @@ function GoabInput({
2703
2861
  const current = ref.current;
2704
2862
  const changeListener = (e) => {
2705
2863
  const detail = e.detail;
2706
- onChange(detail);
2864
+ onChange == null ? void 0 : onChange(detail);
2707
2865
  };
2708
2866
  const clickListener = () => {
2709
2867
  onTrailingIconClick == null ? void 0 : onTrailingIconClick();
@@ -2776,15 +2934,15 @@ function GoabInput({
2776
2934
  const onDateChangeHandler = (onChange) => {
2777
2935
  return ({ name, value }) => {
2778
2936
  if (!value) {
2779
- onChange({ name, value: "" });
2937
+ onChange == null ? void 0 : onChange({ name, value: "" });
2780
2938
  return;
2781
2939
  }
2782
2940
  if (typeof value === "string" && isValid(new Date(value))) {
2783
- onChange({ name, value: parseISO(value) });
2941
+ onChange == null ? void 0 : onChange({ name, value: parseISO(value) });
2784
2942
  return;
2785
2943
  }
2786
2944
  if (isValid(value)) {
2787
- onChange({ name, value });
2945
+ onChange == null ? void 0 : onChange({ name, value });
2788
2946
  return;
2789
2947
  }
2790
2948
  };
@@ -2792,10 +2950,10 @@ const onDateChangeHandler = (onChange) => {
2792
2950
  const onTimeChangeHandler = (onChange) => {
2793
2951
  return ({ name, value }) => {
2794
2952
  if (!value) {
2795
- onChange({ name, value: "" });
2953
+ onChange == null ? void 0 : onChange({ name, value: "" });
2796
2954
  return;
2797
2955
  }
2798
- onChange({ name, value });
2956
+ onChange == null ? void 0 : onChange({ name, value });
2799
2957
  };
2800
2958
  };
2801
2959
  function toString(value, tmpl = "yyyy-MM-dd") {
@@ -2885,7 +3043,10 @@ function GoabInputFile(props) {
2885
3043
  id: props.id,
2886
3044
  name: props.name,
2887
3045
  type: "file",
2888
- onChange: (e) => props.onChange({ name: e.target.name, value: e.target.value }),
3046
+ onChange: (e) => {
3047
+ var _a;
3048
+ return (_a = props.onChange) == null ? void 0 : _a.call(props, { name: e.target.name, value: e.target.value });
3049
+ },
2889
3050
  style: { backgroundColor: "revert" }
2890
3051
  }
2891
3052
  );
@@ -2900,7 +3061,8 @@ function GoabInputNumber({
2900
3061
  ...props
2901
3062
  }) {
2902
3063
  const onNumberChange = ({ name, value: value2 }) => {
2903
- props.onChange({ name, value: parseFloat(value2) });
3064
+ var _a;
3065
+ (_a = props.onChange) == null ? void 0 : _a.call(props, { name, value: parseFloat(value2) });
2904
3066
  };
2905
3067
  const onFocus = ({ name, value: value2 }) => {
2906
3068
  var _a;
@@ -3218,6 +3380,7 @@ function GoabRadioGroup({
3218
3380
  orientation,
3219
3381
  disabled,
3220
3382
  error,
3383
+ id,
3221
3384
  testId,
3222
3385
  ariaLabel,
3223
3386
  mt,
@@ -3230,17 +3393,17 @@ function GoabRadioGroup({
3230
3393
  useEffect(() => {
3231
3394
  if (!el.current) return;
3232
3395
  const listener = (e) => {
3233
- if (!onChange) {
3234
- console.warn("Missing onChange function");
3235
- return;
3236
- }
3237
3396
  const detail = e.detail;
3238
- onChange(detail);
3397
+ onChange == null ? void 0 : onChange(detail);
3239
3398
  };
3240
3399
  const currentEl = el.current;
3241
- currentEl.addEventListener("_change", listener);
3400
+ if (onChange) {
3401
+ currentEl.addEventListener("_change", listener);
3402
+ }
3242
3403
  return () => {
3243
- currentEl.removeEventListener("_change", listener);
3404
+ if (onChange) {
3405
+ currentEl.removeEventListener("_change", listener);
3406
+ }
3244
3407
  };
3245
3408
  }, [name, onChange]);
3246
3409
  return /* @__PURE__ */ jsx(
@@ -3248,6 +3411,7 @@ function GoabRadioGroup({
3248
3411
  {
3249
3412
  testid: testId,
3250
3413
  ref: el,
3414
+ id,
3251
3415
  name,
3252
3416
  value,
3253
3417
  orientation,
@@ -3451,11 +3615,15 @@ function GoabTextArea({
3451
3615
  const current = el.current;
3452
3616
  const listener = (e) => {
3453
3617
  const detail = e.detail;
3454
- onChange(detail);
3618
+ onChange == null ? void 0 : onChange(detail);
3455
3619
  };
3456
- current.addEventListener("_change", listener);
3620
+ if (onChange) {
3621
+ current.addEventListener("_change", listener);
3622
+ }
3457
3623
  return () => {
3458
- current.removeEventListener("_change", listener);
3624
+ if (onChange) {
3625
+ current.removeEventListener("_change", listener);
3626
+ }
3459
3627
  };
3460
3628
  }, [el, onChange]);
3461
3629
  useEffect(() => {
@@ -3644,6 +3812,9 @@ export {
3644
3812
  GoabPages,
3645
3813
  GoabPagination,
3646
3814
  GoabPopover,
3815
+ GoabPublicForm,
3816
+ GoabPublicFormPage,
3817
+ GoabPublicFormSummary,
3647
3818
  GoabRadioGroup,
3648
3819
  GoabRadioItem,
3649
3820
  GoabSideMenu,