@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.d.ts CHANGED
@@ -17,12 +17,15 @@ export * from './lib/divider/divider';
17
17
  export * from './lib/drawer/drawer';
18
18
  export * from './lib/dropdown/dropdown';
19
19
  export * from './lib/dropdown/dropdown-item';
20
- export * from './lib/fieldset/fieldset';
21
20
  export * from './lib/file-upload-card/file-upload-card';
22
21
  export * from './lib/file-upload-input/file-upload-input';
23
22
  export * from './lib/footer/footer';
24
23
  export * from './lib/footer-meta-section/footer-meta-section';
25
24
  export * from './lib/footer-nav-section/footer-nav-section';
25
+ export * from './lib/form/fieldset';
26
+ export * from './lib/form/public-form-page';
27
+ export * from './lib/form/public-form-summary';
28
+ export * from './lib/form/public-form';
26
29
  export * from './lib/form-item/form-item';
27
30
  export * from './lib/form-step/form-step';
28
31
  export * from './lib/form-stepper/form-stepper';
package/index.js CHANGED
@@ -721,53 +721,6 @@ function GoabDropdownItem({
721
721
  }
722
722
  );
723
723
  }
724
- function GoabFieldset({
725
- heading,
726
- buttonText,
727
- id,
728
- onContinue,
729
- children,
730
- mt,
731
- mr,
732
- mb,
733
- ml,
734
- first,
735
- last
736
- }) {
737
- const ref = react.useRef(null);
738
- react.useEffect(() => {
739
- if (!ref.current) return;
740
- const current = ref.current;
741
- const _continue = (e) => {
742
- const event = e.detail;
743
- return onContinue == null ? void 0 : onContinue(event);
744
- };
745
- if (onContinue) {
746
- current.addEventListener("_continue", _continue);
747
- }
748
- return () => {
749
- if (onContinue) {
750
- current.removeEventListener("_continue", _continue);
751
- }
752
- };
753
- }, [ref, onContinue]);
754
- return /* @__PURE__ */ jsxRuntime.jsx(
755
- "goa-public-form-page",
756
- {
757
- ref,
758
- id,
759
- first: first ? "true" : void 0,
760
- last: last ? "true" : void 0,
761
- heading,
762
- buttontext: buttonText,
763
- mt,
764
- mr,
765
- mb,
766
- ml,
767
- children
768
- }
769
- );
770
- }
771
724
  function GoabFileUploadCard({
772
725
  filename,
773
726
  size,
@@ -866,6 +819,213 @@ function GoabAppFooterNavSection({
866
819
  }
867
820
  );
868
821
  }
822
+ function GoabFieldset({
823
+ id,
824
+ sectionTitle,
825
+ dispatchOn,
826
+ onContinue,
827
+ onChange,
828
+ children
829
+ }) {
830
+ const ref = react.useRef(null);
831
+ react.useEffect(() => {
832
+ if (!ref.current) return;
833
+ const current = ref.current;
834
+ const changeListener = (e) => {
835
+ const detail = e.detail;
836
+ onChange == null ? void 0 : onChange(detail);
837
+ };
838
+ const continueListener = (e) => {
839
+ const event = e.detail;
840
+ return onContinue == null ? void 0 : onContinue(event);
841
+ };
842
+ if (onContinue) {
843
+ current.addEventListener("_continue", continueListener);
844
+ }
845
+ if (onChange) {
846
+ current.addEventListener("_change", changeListener);
847
+ }
848
+ return () => {
849
+ if (onContinue) {
850
+ current.removeEventListener("_continue", continueListener);
851
+ }
852
+ if (onChange) {
853
+ current.removeEventListener("_change", changeListener);
854
+ }
855
+ };
856
+ }, [ref, onContinue]);
857
+ return /* @__PURE__ */ jsxRuntime.jsx(
858
+ "goa-fieldset",
859
+ {
860
+ ref,
861
+ id,
862
+ "section-title": sectionTitle,
863
+ "dispatch-on": dispatchOn,
864
+ children
865
+ }
866
+ );
867
+ }
868
+ function GoabPublicFormPage({
869
+ id = "",
870
+ heading = "",
871
+ subHeading = "",
872
+ summaryHeading = "",
873
+ sectionTitle = "",
874
+ backUrl = "",
875
+ type = "step",
876
+ buttonText = "",
877
+ buttonVisibility = "visible",
878
+ first = false,
879
+ last = false,
880
+ onContinue,
881
+ onBack,
882
+ onFieldsetChange,
883
+ onComplete,
884
+ children,
885
+ mt,
886
+ mr,
887
+ mb,
888
+ ml
889
+ }) {
890
+ const ref = react.useRef(null);
891
+ react.useEffect(() => {
892
+ if (!ref.current) return;
893
+ const current = ref.current;
894
+ const continueListener = (e) => {
895
+ const detail = e.detail;
896
+ onContinue == null ? void 0 : onContinue(detail);
897
+ };
898
+ const backListener = () => {
899
+ onBack == null ? void 0 : onBack();
900
+ };
901
+ const fieldsetChangeListener = (e) => {
902
+ const detail = e.detail;
903
+ onFieldsetChange == null ? void 0 : onFieldsetChange(detail);
904
+ };
905
+ const completeListener = (e) => {
906
+ const detail = e.detail;
907
+ onComplete == null ? void 0 : onComplete(detail);
908
+ };
909
+ if (onContinue) {
910
+ current.addEventListener("_continue", continueListener);
911
+ }
912
+ if (onBack) {
913
+ current.addEventListener("_back", backListener);
914
+ }
915
+ if (onFieldsetChange) {
916
+ current.addEventListener("_fieldsetChange", fieldsetChangeListener);
917
+ }
918
+ if (onComplete) {
919
+ current.addEventListener("_complete", completeListener);
920
+ }
921
+ return () => {
922
+ if (onContinue) {
923
+ current.removeEventListener("_continue", continueListener);
924
+ }
925
+ if (onBack) {
926
+ current.removeEventListener("_back", backListener);
927
+ }
928
+ if (onFieldsetChange) {
929
+ current.removeEventListener("_fieldsetChange", fieldsetChangeListener);
930
+ }
931
+ if (onComplete) {
932
+ current.removeEventListener("_complete", completeListener);
933
+ }
934
+ };
935
+ }, [ref, onContinue, onBack, onFieldsetChange, onComplete]);
936
+ return /* @__PURE__ */ jsxRuntime.jsx(
937
+ "goa-public-form-page",
938
+ {
939
+ ref,
940
+ id,
941
+ heading,
942
+ "sub-heading": subHeading,
943
+ "section-title": sectionTitle,
944
+ "back-url": backUrl,
945
+ type,
946
+ "button-text": buttonText,
947
+ "button-visibility": buttonVisibility,
948
+ first,
949
+ last,
950
+ "summary-heading": summaryHeading,
951
+ mt,
952
+ mr,
953
+ mb,
954
+ ml,
955
+ children
956
+ }
957
+ );
958
+ }
959
+ function GoabPublicFormSummary({
960
+ heading = ""
961
+ }) {
962
+ const ref = react.useRef(null);
963
+ return /* @__PURE__ */ jsxRuntime.jsx(
964
+ "goa-public-form-summary",
965
+ {
966
+ ref,
967
+ heading
968
+ }
969
+ );
970
+ }
971
+ function GoabPublicForm({
972
+ status = "complete",
973
+ name,
974
+ onInit,
975
+ onComplete,
976
+ onStateChange,
977
+ children
978
+ }) {
979
+ const ref = react.useRef(null);
980
+ const initialized = react.useRef(false);
981
+ react.useLayoutEffect(() => {
982
+ if (!ref.current) return;
983
+ const current = ref.current;
984
+ const initListener = (e) => {
985
+ const detail = e.detail;
986
+ if (detail == null ? void 0 : detail.el) {
987
+ onInit == null ? void 0 : onInit(detail);
988
+ }
989
+ };
990
+ if (onInit && !initialized.current) {
991
+ current.addEventListener("_init", initListener);
992
+ }
993
+ const completeListener = (e) => {
994
+ const detail = e.detail;
995
+ onComplete == null ? void 0 : onComplete(detail);
996
+ };
997
+ const stateChangeListener = (e) => {
998
+ const detail = e.detail;
999
+ onStateChange == null ? void 0 : onStateChange(detail.data);
1000
+ };
1001
+ if (onComplete) {
1002
+ current.addEventListener("_complete", completeListener);
1003
+ }
1004
+ if (onStateChange) {
1005
+ current.addEventListener("_stateChange", stateChangeListener);
1006
+ }
1007
+ return () => {
1008
+ if (onInit) {
1009
+ current.removeEventListener("_init", initListener);
1010
+ }
1011
+ if (onComplete) {
1012
+ current.removeEventListener("_complete", completeListener);
1013
+ }
1014
+ if (onStateChange) {
1015
+ current.removeEventListener("_stateChange", stateChangeListener);
1016
+ }
1017
+ };
1018
+ }, [onInit, onComplete, onStateChange]);
1019
+ return /* @__PURE__ */ jsxRuntime.jsx(
1020
+ "goa-public-form",
1021
+ {
1022
+ ref,
1023
+ status,
1024
+ name,
1025
+ children
1026
+ }
1027
+ );
1028
+ }
869
1029
  function GoabFormItem({
870
1030
  children,
871
1031
  helpText,
@@ -874,6 +1034,8 @@ function GoabFormItem({
874
1034
  label,
875
1035
  labelSize,
876
1036
  maxWidth,
1037
+ publicFormSummaryOrder,
1038
+ name,
877
1039
  mt,
878
1040
  mr,
879
1041
  mb,
@@ -890,6 +1052,8 @@ function GoabFormItem({
890
1052
  requirement,
891
1053
  helptext: typeof helpText === "string" ? helpText : void 0,
892
1054
  maxwidth: maxWidth,
1055
+ "public-form-summary-order": publicFormSummaryOrder,
1056
+ name,
893
1057
  mt,
894
1058
  mr,
895
1059
  mb,
@@ -2705,7 +2869,7 @@ function GoabInput({
2705
2869
  const current = ref.current;
2706
2870
  const changeListener = (e) => {
2707
2871
  const detail = e.detail;
2708
- onChange(detail);
2872
+ onChange == null ? void 0 : onChange(detail);
2709
2873
  };
2710
2874
  const clickListener = () => {
2711
2875
  onTrailingIconClick == null ? void 0 : onTrailingIconClick();
@@ -2778,15 +2942,15 @@ function GoabInput({
2778
2942
  const onDateChangeHandler = (onChange) => {
2779
2943
  return ({ name, value }) => {
2780
2944
  if (!value) {
2781
- onChange({ name, value: "" });
2945
+ onChange == null ? void 0 : onChange({ name, value: "" });
2782
2946
  return;
2783
2947
  }
2784
2948
  if (typeof value === "string" && isValid(new Date(value))) {
2785
- onChange({ name, value: parseISO(value) });
2949
+ onChange == null ? void 0 : onChange({ name, value: parseISO(value) });
2786
2950
  return;
2787
2951
  }
2788
2952
  if (isValid(value)) {
2789
- onChange({ name, value });
2953
+ onChange == null ? void 0 : onChange({ name, value });
2790
2954
  return;
2791
2955
  }
2792
2956
  };
@@ -2794,10 +2958,10 @@ const onDateChangeHandler = (onChange) => {
2794
2958
  const onTimeChangeHandler = (onChange) => {
2795
2959
  return ({ name, value }) => {
2796
2960
  if (!value) {
2797
- onChange({ name, value: "" });
2961
+ onChange == null ? void 0 : onChange({ name, value: "" });
2798
2962
  return;
2799
2963
  }
2800
- onChange({ name, value });
2964
+ onChange == null ? void 0 : onChange({ name, value });
2801
2965
  };
2802
2966
  };
2803
2967
  function toString(value, tmpl = "yyyy-MM-dd") {
@@ -2887,7 +3051,10 @@ function GoabInputFile(props) {
2887
3051
  id: props.id,
2888
3052
  name: props.name,
2889
3053
  type: "file",
2890
- onChange: (e) => props.onChange({ name: e.target.name, value: e.target.value }),
3054
+ onChange: (e) => {
3055
+ var _a;
3056
+ return (_a = props.onChange) == null ? void 0 : _a.call(props, { name: e.target.name, value: e.target.value });
3057
+ },
2891
3058
  style: { backgroundColor: "revert" }
2892
3059
  }
2893
3060
  );
@@ -2902,7 +3069,8 @@ function GoabInputNumber({
2902
3069
  ...props
2903
3070
  }) {
2904
3071
  const onNumberChange = ({ name, value: value2 }) => {
2905
- props.onChange({ name, value: parseFloat(value2) });
3072
+ var _a;
3073
+ (_a = props.onChange) == null ? void 0 : _a.call(props, { name, value: parseFloat(value2) });
2906
3074
  };
2907
3075
  const onFocus = ({ name, value: value2 }) => {
2908
3076
  var _a;
@@ -3220,6 +3388,7 @@ function GoabRadioGroup({
3220
3388
  orientation,
3221
3389
  disabled,
3222
3390
  error,
3391
+ id,
3223
3392
  testId,
3224
3393
  ariaLabel,
3225
3394
  mt,
@@ -3232,17 +3401,17 @@ function GoabRadioGroup({
3232
3401
  react.useEffect(() => {
3233
3402
  if (!el.current) return;
3234
3403
  const listener = (e) => {
3235
- if (!onChange) {
3236
- console.warn("Missing onChange function");
3237
- return;
3238
- }
3239
3404
  const detail = e.detail;
3240
- onChange(detail);
3405
+ onChange == null ? void 0 : onChange(detail);
3241
3406
  };
3242
3407
  const currentEl = el.current;
3243
- currentEl.addEventListener("_change", listener);
3408
+ if (onChange) {
3409
+ currentEl.addEventListener("_change", listener);
3410
+ }
3244
3411
  return () => {
3245
- currentEl.removeEventListener("_change", listener);
3412
+ if (onChange) {
3413
+ currentEl.removeEventListener("_change", listener);
3414
+ }
3246
3415
  };
3247
3416
  }, [name, onChange]);
3248
3417
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -3250,6 +3419,7 @@ function GoabRadioGroup({
3250
3419
  {
3251
3420
  testid: testId,
3252
3421
  ref: el,
3422
+ id,
3253
3423
  name,
3254
3424
  value,
3255
3425
  orientation,
@@ -3453,11 +3623,15 @@ function GoabTextArea({
3453
3623
  const current = el.current;
3454
3624
  const listener = (e) => {
3455
3625
  const detail = e.detail;
3456
- onChange(detail);
3626
+ onChange == null ? void 0 : onChange(detail);
3457
3627
  };
3458
- current.addEventListener("_change", listener);
3628
+ if (onChange) {
3629
+ current.addEventListener("_change", listener);
3630
+ }
3459
3631
  return () => {
3460
- current.removeEventListener("_change", listener);
3632
+ if (onChange) {
3633
+ current.removeEventListener("_change", listener);
3634
+ }
3461
3635
  };
3462
3636
  }, [el, onChange]);
3463
3637
  react.useEffect(() => {
@@ -3645,6 +3819,9 @@ exports.GoabPageBlock = GoabPageBlock;
3645
3819
  exports.GoabPages = GoabPages;
3646
3820
  exports.GoabPagination = GoabPagination;
3647
3821
  exports.GoabPopover = GoabPopover;
3822
+ exports.GoabPublicForm = GoabPublicForm;
3823
+ exports.GoabPublicFormPage = GoabPublicFormPage;
3824
+ exports.GoabPublicFormSummary = GoabPublicFormSummary;
3648
3825
  exports.GoabRadioGroup = GoabRadioGroup;
3649
3826
  exports.GoabRadioItem = GoabRadioItem;
3650
3827
  exports.GoabSideMenu = GoabSideMenu;