@abgov/react-components 6.4.1 → 6.5.0-alpha.1

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/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,213 @@ 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
+ const detail = e.detail;
894
+ onContinue == null ? void 0 : onContinue(detail);
895
+ };
896
+ const backListener = () => {
897
+ onBack == null ? void 0 : onBack();
898
+ };
899
+ const fieldsetChangeListener = (e) => {
900
+ const detail = e.detail;
901
+ onFieldsetChange == null ? void 0 : onFieldsetChange(detail);
902
+ };
903
+ const completeListener = (e) => {
904
+ const detail = e.detail;
905
+ onComplete == null ? void 0 : onComplete(detail);
906
+ };
907
+ if (onContinue) {
908
+ current.addEventListener("_continue", continueListener);
909
+ }
910
+ if (onBack) {
911
+ current.addEventListener("_back", backListener);
912
+ }
913
+ if (onFieldsetChange) {
914
+ current.addEventListener("_fieldsetChange", fieldsetChangeListener);
915
+ }
916
+ if (onComplete) {
917
+ current.addEventListener("_complete", completeListener);
918
+ }
919
+ return () => {
920
+ if (onContinue) {
921
+ current.removeEventListener("_continue", continueListener);
922
+ }
923
+ if (onBack) {
924
+ current.removeEventListener("_back", backListener);
925
+ }
926
+ if (onFieldsetChange) {
927
+ current.removeEventListener("_fieldsetChange", fieldsetChangeListener);
928
+ }
929
+ if (onComplete) {
930
+ current.removeEventListener("_complete", completeListener);
931
+ }
932
+ };
933
+ }, [ref, onContinue, onBack, onFieldsetChange, onComplete]);
934
+ return /* @__PURE__ */ jsx(
935
+ "goa-public-form-page",
936
+ {
937
+ ref,
938
+ id,
939
+ heading,
940
+ "sub-heading": subHeading,
941
+ "section-title": sectionTitle,
942
+ "back-url": backUrl,
943
+ type,
944
+ "button-text": buttonText,
945
+ "button-visibility": buttonVisibility,
946
+ first,
947
+ last,
948
+ "summary-heading": summaryHeading,
949
+ mt,
950
+ mr,
951
+ mb,
952
+ ml,
953
+ children
954
+ }
955
+ );
956
+ }
957
+ function GoabPublicFormSummary({
958
+ heading = ""
959
+ }) {
960
+ const ref = useRef(null);
961
+ return /* @__PURE__ */ jsx(
962
+ "goa-public-form-summary",
963
+ {
964
+ ref,
965
+ heading
966
+ }
967
+ );
968
+ }
969
+ function GoabPublicForm({
970
+ status = "complete",
971
+ name,
972
+ onInit,
973
+ onComplete,
974
+ onStateChange,
975
+ children
976
+ }) {
977
+ const ref = useRef(null);
978
+ const initialized = useRef(false);
979
+ useLayoutEffect(() => {
980
+ if (!ref.current) return;
981
+ const current = ref.current;
982
+ const initListener = (e) => {
983
+ const detail = e.detail;
984
+ if (detail == null ? void 0 : detail.el) {
985
+ onInit == null ? void 0 : onInit(detail);
986
+ }
987
+ };
988
+ if (onInit && !initialized.current) {
989
+ current.addEventListener("_init", initListener);
990
+ }
991
+ const completeListener = (e) => {
992
+ const detail = e.detail;
993
+ onComplete == null ? void 0 : onComplete(detail);
994
+ };
995
+ const stateChangeListener = (e) => {
996
+ const detail = e.detail;
997
+ onStateChange == null ? void 0 : onStateChange(detail.data);
998
+ };
999
+ if (onComplete) {
1000
+ current.addEventListener("_complete", completeListener);
1001
+ }
1002
+ if (onStateChange) {
1003
+ current.addEventListener("_stateChange", stateChangeListener);
1004
+ }
1005
+ return () => {
1006
+ if (onInit) {
1007
+ current.removeEventListener("_init", initListener);
1008
+ }
1009
+ if (onComplete) {
1010
+ current.removeEventListener("_complete", completeListener);
1011
+ }
1012
+ if (onStateChange) {
1013
+ current.removeEventListener("_stateChange", stateChangeListener);
1014
+ }
1015
+ };
1016
+ }, [onInit, onComplete, onStateChange]);
1017
+ return /* @__PURE__ */ jsx(
1018
+ "goa-public-form",
1019
+ {
1020
+ ref,
1021
+ status,
1022
+ name,
1023
+ children
1024
+ }
1025
+ );
1026
+ }
867
1027
  function GoabFormItem({
868
1028
  children,
869
1029
  helpText,
@@ -872,6 +1032,8 @@ function GoabFormItem({
872
1032
  label,
873
1033
  labelSize,
874
1034
  maxWidth,
1035
+ publicFormSummaryOrder,
1036
+ name,
875
1037
  mt,
876
1038
  mr,
877
1039
  mb,
@@ -888,6 +1050,8 @@ function GoabFormItem({
888
1050
  requirement,
889
1051
  helptext: typeof helpText === "string" ? helpText : void 0,
890
1052
  maxwidth: maxWidth,
1053
+ "public-form-summary-order": publicFormSummaryOrder,
1054
+ name,
891
1055
  mt,
892
1056
  mr,
893
1057
  mb,
@@ -2703,7 +2867,7 @@ function GoabInput({
2703
2867
  const current = ref.current;
2704
2868
  const changeListener = (e) => {
2705
2869
  const detail = e.detail;
2706
- onChange(detail);
2870
+ onChange == null ? void 0 : onChange(detail);
2707
2871
  };
2708
2872
  const clickListener = () => {
2709
2873
  onTrailingIconClick == null ? void 0 : onTrailingIconClick();
@@ -2776,15 +2940,15 @@ function GoabInput({
2776
2940
  const onDateChangeHandler = (onChange) => {
2777
2941
  return ({ name, value }) => {
2778
2942
  if (!value) {
2779
- onChange({ name, value: "" });
2943
+ onChange == null ? void 0 : onChange({ name, value: "" });
2780
2944
  return;
2781
2945
  }
2782
2946
  if (typeof value === "string" && isValid(new Date(value))) {
2783
- onChange({ name, value: parseISO(value) });
2947
+ onChange == null ? void 0 : onChange({ name, value: parseISO(value) });
2784
2948
  return;
2785
2949
  }
2786
2950
  if (isValid(value)) {
2787
- onChange({ name, value });
2951
+ onChange == null ? void 0 : onChange({ name, value });
2788
2952
  return;
2789
2953
  }
2790
2954
  };
@@ -2792,10 +2956,10 @@ const onDateChangeHandler = (onChange) => {
2792
2956
  const onTimeChangeHandler = (onChange) => {
2793
2957
  return ({ name, value }) => {
2794
2958
  if (!value) {
2795
- onChange({ name, value: "" });
2959
+ onChange == null ? void 0 : onChange({ name, value: "" });
2796
2960
  return;
2797
2961
  }
2798
- onChange({ name, value });
2962
+ onChange == null ? void 0 : onChange({ name, value });
2799
2963
  };
2800
2964
  };
2801
2965
  function toString(value, tmpl = "yyyy-MM-dd") {
@@ -2885,7 +3049,10 @@ function GoabInputFile(props) {
2885
3049
  id: props.id,
2886
3050
  name: props.name,
2887
3051
  type: "file",
2888
- onChange: (e) => props.onChange({ name: e.target.name, value: e.target.value }),
3052
+ onChange: (e) => {
3053
+ var _a;
3054
+ return (_a = props.onChange) == null ? void 0 : _a.call(props, { name: e.target.name, value: e.target.value });
3055
+ },
2889
3056
  style: { backgroundColor: "revert" }
2890
3057
  }
2891
3058
  );
@@ -2900,7 +3067,8 @@ function GoabInputNumber({
2900
3067
  ...props
2901
3068
  }) {
2902
3069
  const onNumberChange = ({ name, value: value2 }) => {
2903
- props.onChange({ name, value: parseFloat(value2) });
3070
+ var _a;
3071
+ (_a = props.onChange) == null ? void 0 : _a.call(props, { name, value: parseFloat(value2) });
2904
3072
  };
2905
3073
  const onFocus = ({ name, value: value2 }) => {
2906
3074
  var _a;
@@ -3218,6 +3386,7 @@ function GoabRadioGroup({
3218
3386
  orientation,
3219
3387
  disabled,
3220
3388
  error,
3389
+ id,
3221
3390
  testId,
3222
3391
  ariaLabel,
3223
3392
  mt,
@@ -3230,17 +3399,17 @@ function GoabRadioGroup({
3230
3399
  useEffect(() => {
3231
3400
  if (!el.current) return;
3232
3401
  const listener = (e) => {
3233
- if (!onChange) {
3234
- console.warn("Missing onChange function");
3235
- return;
3236
- }
3237
3402
  const detail = e.detail;
3238
- onChange(detail);
3403
+ onChange == null ? void 0 : onChange(detail);
3239
3404
  };
3240
3405
  const currentEl = el.current;
3241
- currentEl.addEventListener("_change", listener);
3406
+ if (onChange) {
3407
+ currentEl.addEventListener("_change", listener);
3408
+ }
3242
3409
  return () => {
3243
- currentEl.removeEventListener("_change", listener);
3410
+ if (onChange) {
3411
+ currentEl.removeEventListener("_change", listener);
3412
+ }
3244
3413
  };
3245
3414
  }, [name, onChange]);
3246
3415
  return /* @__PURE__ */ jsx(
@@ -3248,6 +3417,7 @@ function GoabRadioGroup({
3248
3417
  {
3249
3418
  testid: testId,
3250
3419
  ref: el,
3420
+ id,
3251
3421
  name,
3252
3422
  value,
3253
3423
  orientation,
@@ -3451,11 +3621,15 @@ function GoabTextArea({
3451
3621
  const current = el.current;
3452
3622
  const listener = (e) => {
3453
3623
  const detail = e.detail;
3454
- onChange(detail);
3624
+ onChange == null ? void 0 : onChange(detail);
3455
3625
  };
3456
- current.addEventListener("_change", listener);
3626
+ if (onChange) {
3627
+ current.addEventListener("_change", listener);
3628
+ }
3457
3629
  return () => {
3458
- current.removeEventListener("_change", listener);
3630
+ if (onChange) {
3631
+ current.removeEventListener("_change", listener);
3632
+ }
3459
3633
  };
3460
3634
  }, [el, onChange]);
3461
3635
  useEffect(() => {
@@ -3644,6 +3818,9 @@ export {
3644
3818
  GoabPages,
3645
3819
  GoabPagination,
3646
3820
  GoabPopover,
3821
+ GoabPublicForm,
3822
+ GoabPublicFormPage,
3823
+ GoabPublicFormSummary,
3647
3824
  GoabRadioGroup,
3648
3825
  GoabRadioItem,
3649
3826
  GoabSideMenu,