@abgov/react-components 7.2.2 → 7.4.0

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
@@ -9,7 +9,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
9
9
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
10
  var _PublicFormController_instances, updateObjectListState_fn, dispatchError_fn;
11
11
  import { jsxs, jsx } from "react/jsx-runtime";
12
- import { useRef, useEffect, useLayoutEffect, useState, useCallback, createContext, useContext } from "react";
12
+ import { useRef, useEffect, Children, isValidElement, Fragment, cloneElement, useLayoutEffect, useState, useCallback, createContext, useContext } from "react";
13
13
  const lowercase = (input) => input.toLowerCase();
14
14
  const kebab = (input) => input.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
15
15
  function transformProps(props, transform = lowercase) {
@@ -63,10 +63,26 @@ function GoabAccordion({
63
63
  }
64
64
  );
65
65
  }
66
+ function renderSlottedItems(children, slot) {
67
+ return Children.map(children, (child) => {
68
+ if (!isValidElement(child)) {
69
+ return child;
70
+ }
71
+ if (child.type === Fragment) {
72
+ const fragment = child;
73
+ return renderSlottedItems(fragment.props.children, slot);
74
+ }
75
+ return cloneElement(child, { slot });
76
+ });
77
+ }
66
78
  function GoabAppHeader({
67
79
  onMenuClick,
68
80
  children,
69
81
  secondaryText,
82
+ banner,
83
+ phase,
84
+ navigation,
85
+ utilities,
70
86
  ...rest
71
87
  }) {
72
88
  const el = useRef(null);
@@ -87,7 +103,7 @@ function GoabAppHeader({
87
103
  current.removeEventListener("_menuClick", listener);
88
104
  };
89
105
  }, [el, onMenuClick]);
90
- return /* @__PURE__ */ jsx(
106
+ return /* @__PURE__ */ jsxs(
91
107
  "goa-app-header",
92
108
  {
93
109
  ref: el,
@@ -95,7 +111,13 @@ function GoabAppHeader({
95
111
  secondarytext: secondaryText,
96
112
  ..._props,
97
113
  version: "2",
98
- children
114
+ children: [
115
+ children,
116
+ banner && /* @__PURE__ */ jsx("div", { slot: "banner", children: banner }),
117
+ phase && /* @__PURE__ */ jsx("div", { slot: "phase", children: phase }),
118
+ navigation && renderSlottedItems(navigation, "navigation"),
119
+ utilities && renderSlottedItems(utilities, "utilities")
120
+ ]
99
121
  }
100
122
  );
101
123
  }
@@ -114,6 +136,7 @@ function getIconValue(icon, iconType) {
114
136
  return iconType ? "true" : "false";
115
137
  }
116
138
  function GoabBadge({
139
+ content,
117
140
  icon,
118
141
  iconType,
119
142
  size = "medium",
@@ -126,16 +149,23 @@ function GoabBadge({
126
149
  {
127
150
  icon: getIconValue(icon, iconType),
128
151
  icontype: iconType,
152
+ content: typeof content === "string" ? content : void 0,
129
153
  ..._props,
130
154
  version: "2",
131
155
  size,
132
- emphasis
156
+ emphasis,
157
+ children: typeof content !== "string" && content != null && /* @__PURE__ */ jsx("div", { slot: "content", children: content })
133
158
  }
134
159
  );
135
160
  }
136
- function GoabBlock({ testId, children, ...rest }) {
161
+ function GoabBlock({
162
+ testId,
163
+ stretch,
164
+ children,
165
+ ...rest
166
+ }) {
137
167
  const _props = transformProps({ testid: testId, ...rest }, kebab);
138
- return /* @__PURE__ */ jsx("goa-block", { ..._props, children });
168
+ return /* @__PURE__ */ jsx("goa-block", { ..._props, stretch: stretch ? "true" : void 0, children });
139
169
  }
140
170
  function GoabButton({
141
171
  disabled,
@@ -244,6 +274,8 @@ function GoabCheckbox({
244
274
  description,
245
275
  reveal,
246
276
  onChange,
277
+ onFocus,
278
+ onBlur,
247
279
  name,
248
280
  children,
249
281
  size = "default",
@@ -260,11 +292,23 @@ function GoabCheckbox({
260
292
  const detail = e.detail;
261
293
  onChange == null ? void 0 : onChange({ ...detail, event: e });
262
294
  };
295
+ const focusListener = (e) => {
296
+ const detail = e.detail;
297
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
298
+ };
299
+ const blurListener = (e) => {
300
+ const detail = e.detail;
301
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
302
+ };
263
303
  current.addEventListener("_change", listener);
304
+ current.addEventListener("_focus", focusListener);
305
+ current.addEventListener("_blur", blurListener);
264
306
  return () => {
265
307
  current.removeEventListener("_change", listener);
308
+ current.removeEventListener("_focus", focusListener);
309
+ current.removeEventListener("_blur", blurListener);
266
310
  };
267
- }, [name, onChange]);
311
+ }, [name, onChange, onFocus, onBlur]);
268
312
  return /* @__PURE__ */ jsxs(
269
313
  "goa-checkbox",
270
314
  {
@@ -296,6 +340,8 @@ function GoabCheckboxList({
296
340
  size = "default",
297
341
  children,
298
342
  onChange,
343
+ onFocus,
344
+ onBlur,
299
345
  mt,
300
346
  mr,
301
347
  mb,
@@ -309,11 +355,23 @@ function GoabCheckboxList({
309
355
  const detail = e.detail;
310
356
  onChange == null ? void 0 : onChange({ ...detail, event: e });
311
357
  };
358
+ const focusListener = (e) => {
359
+ const detail = e.detail;
360
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
361
+ };
362
+ const blurListener = (e) => {
363
+ const detail = e.detail;
364
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
365
+ };
312
366
  current.addEventListener("_change", listener);
367
+ current.addEventListener("_focus", focusListener);
368
+ current.addEventListener("_blur", blurListener);
313
369
  return () => {
314
370
  current.removeEventListener("_change", listener);
371
+ current.removeEventListener("_focus", focusListener);
372
+ current.removeEventListener("_blur", blurListener);
315
373
  };
316
- }, [onChange]);
374
+ }, [onChange, onFocus, onBlur]);
317
375
  return /* @__PURE__ */ jsx(
318
376
  "goa-checkbox-list",
319
377
  {
@@ -410,6 +468,9 @@ function GoabDataGrid({
410
468
  }
411
469
  );
412
470
  }
471
+ const GoabWorkspaceLayoutScrollState = {
472
+ NO_SCROLL: "no-scroll"
473
+ };
413
474
  function dispatch(el, eventName, detail, opts) {
414
475
  if (!el) {
415
476
  console.error("dispatch element is null");
@@ -2609,6 +2670,8 @@ function GoabDatePicker({
2609
2670
  disabled,
2610
2671
  relative,
2611
2672
  onChange,
2673
+ onFocus,
2674
+ onBlur,
2612
2675
  ...rest
2613
2676
  }) {
2614
2677
  const ref = useRef(null);
@@ -2629,15 +2692,27 @@ function GoabDatePicker({
2629
2692
  const detail = e.detail;
2630
2693
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2631
2694
  };
2695
+ const handleFocus = (e) => {
2696
+ const detail = e.detail;
2697
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
2698
+ };
2699
+ const handleBlur = (e) => {
2700
+ const detail = e.detail;
2701
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
2702
+ };
2632
2703
  if (onChange) {
2633
2704
  current.addEventListener("_change", handleChange);
2634
2705
  }
2706
+ current.addEventListener("_focus", handleFocus);
2707
+ current.addEventListener("_blur", handleBlur);
2635
2708
  return () => {
2636
2709
  if (onChange) {
2637
2710
  current.removeEventListener("_change", handleChange);
2638
2711
  }
2712
+ current.removeEventListener("_focus", handleFocus);
2713
+ current.removeEventListener("_blur", handleBlur);
2639
2714
  };
2640
- }, [onChange]);
2715
+ }, [onChange, onFocus, onBlur]);
2641
2716
  const formatValue = (val) => {
2642
2717
  if (!val) return "";
2643
2718
  if (val instanceof Date) {
@@ -2733,6 +2808,8 @@ function stringify(value) {
2733
2808
  function GoabDropdown({
2734
2809
  value,
2735
2810
  onChange,
2811
+ onFocus,
2812
+ onBlur,
2736
2813
  disabled,
2737
2814
  error,
2738
2815
  filterable,
@@ -2754,15 +2831,27 @@ function GoabDropdown({
2754
2831
  const detail = e.detail;
2755
2832
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2756
2833
  };
2834
+ const focusListener = (e) => {
2835
+ const detail = e.detail;
2836
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
2837
+ };
2838
+ const blurListener = (e) => {
2839
+ const detail = e.detail;
2840
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
2841
+ };
2757
2842
  if (onChange) {
2758
2843
  current.addEventListener("_change", handler);
2759
2844
  }
2845
+ current.addEventListener("_focus", focusListener);
2846
+ current.addEventListener("_blur", blurListener);
2760
2847
  return () => {
2761
2848
  if (onChange) {
2762
2849
  current.removeEventListener("_change", handler);
2763
2850
  }
2851
+ current.removeEventListener("_focus", focusListener);
2852
+ current.removeEventListener("_blur", blurListener);
2764
2853
  };
2765
- }, [el, onChange]);
2854
+ }, [el, onChange, onFocus, onBlur]);
2766
2855
  return /* @__PURE__ */ jsx(
2767
2856
  "goa-dropdown",
2768
2857
  {
@@ -2791,7 +2880,8 @@ function GoabDropdownItem({
2791
2880
  label,
2792
2881
  filter,
2793
2882
  name,
2794
- mountType = "append"
2883
+ mountType = "append",
2884
+ children
2795
2885
  }) {
2796
2886
  return /* @__PURE__ */ jsx(
2797
2887
  "goa-dropdown-item",
@@ -2800,7 +2890,71 @@ function GoabDropdownItem({
2800
2890
  label,
2801
2891
  filter,
2802
2892
  name,
2803
- mount: mountType
2893
+ mount: mountType,
2894
+ children
2895
+ }
2896
+ );
2897
+ }
2898
+ function GoabDropdownMultiselect({
2899
+ name,
2900
+ value = [],
2901
+ placeholder,
2902
+ disabled,
2903
+ error,
2904
+ filterable,
2905
+ leadingIcon,
2906
+ showSelectAll,
2907
+ testId,
2908
+ ariaLabel,
2909
+ ariaLabelledBy,
2910
+ maxHeight,
2911
+ width,
2912
+ size = "default",
2913
+ labelFormat,
2914
+ children,
2915
+ onChange,
2916
+ mt,
2917
+ mr,
2918
+ mb,
2919
+ ml
2920
+ }) {
2921
+ const el = useRef(null);
2922
+ useEffect(() => {
2923
+ if (!el.current) return;
2924
+ const current = el.current;
2925
+ const listener = (e) => {
2926
+ const detail = e.detail;
2927
+ onChange == null ? void 0 : onChange({ ...detail, event: e });
2928
+ };
2929
+ current.addEventListener("_change", listener);
2930
+ return () => {
2931
+ current.removeEventListener("_change", listener);
2932
+ };
2933
+ }, [onChange]);
2934
+ return /* @__PURE__ */ jsx(
2935
+ "goa-dropdown-multiselect",
2936
+ {
2937
+ ref: el,
2938
+ name,
2939
+ value,
2940
+ placeholder,
2941
+ disabled: disabled ? "true" : void 0,
2942
+ error: error ? "true" : void 0,
2943
+ filterable: filterable ? "true" : void 0,
2944
+ "leading-icon": leadingIcon,
2945
+ testid: testId,
2946
+ "aria-label": ariaLabel,
2947
+ "aria-labelledby": ariaLabelledBy,
2948
+ "max-height": maxHeight,
2949
+ width,
2950
+ size,
2951
+ "label-format": labelFormat ? labelFormat : void 0,
2952
+ "show-select-all": showSelectAll ? "true" : void 0,
2953
+ mt,
2954
+ mr,
2955
+ mb,
2956
+ ml,
2957
+ children
2804
2958
  }
2805
2959
  );
2806
2960
  }
@@ -3165,6 +3319,7 @@ function GoabHeroBannerActions({
3165
3319
  }
3166
3320
  function GoabIconButton({
3167
3321
  variant = "color",
3322
+ type = "default",
3168
3323
  size = "medium",
3169
3324
  theme = "outline",
3170
3325
  disabled,
@@ -3175,7 +3330,7 @@ function GoabIconButton({
3175
3330
  ...rest
3176
3331
  }) {
3177
3332
  const ref = useRef(null);
3178
- const _props = transformProps({ variant, size, theme, ...rest }, lowercase);
3333
+ const _props = transformProps({ variant, type, size, theme, ...rest }, lowercase);
3179
3334
  useEffect(() => {
3180
3335
  if (!ref.current) {
3181
3336
  return;
@@ -3831,6 +3986,8 @@ function GoabRadioGroup({
3831
3986
  disabled,
3832
3987
  error,
3833
3988
  onChange,
3989
+ onFocus,
3990
+ onBlur,
3834
3991
  name,
3835
3992
  children,
3836
3993
  size = "default",
@@ -3844,16 +4001,28 @@ function GoabRadioGroup({
3844
4001
  const detail = e.detail;
3845
4002
  onChange == null ? void 0 : onChange({ ...detail, event: e });
3846
4003
  };
4004
+ const focusListener = (e) => {
4005
+ const detail = e.detail;
4006
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
4007
+ };
4008
+ const blurListener = (e) => {
4009
+ const detail = e.detail;
4010
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
4011
+ };
3847
4012
  const currentEl = el.current;
3848
4013
  if (onChange) {
3849
4014
  currentEl.addEventListener("_change", listener);
3850
4015
  }
4016
+ currentEl.addEventListener("_focus", focusListener);
4017
+ currentEl.addEventListener("_blur", blurListener);
3851
4018
  return () => {
3852
4019
  if (onChange) {
3853
4020
  currentEl.removeEventListener("_change", listener);
3854
4021
  }
4022
+ currentEl.removeEventListener("_focus", focusListener);
4023
+ currentEl.removeEventListener("_blur", blurListener);
3855
4024
  };
3856
- }, [name, onChange]);
4025
+ }, [name, onChange, onFocus, onBlur]);
3857
4026
  return /* @__PURE__ */ jsx(
3858
4027
  "goa-radio-group",
3859
4028
  {
@@ -3960,6 +4129,32 @@ function GoabSpinner({
3960
4129
  }
3961
4130
  );
3962
4131
  }
4132
+ function GoabScrollPanel({
4133
+ header,
4134
+ children,
4135
+ footer,
4136
+ height,
4137
+ testId,
4138
+ direction = "vertical",
4139
+ ...rest
4140
+ }) {
4141
+ const hostStyle = height ? { height } : void 0;
4142
+ return /* @__PURE__ */ jsxs(
4143
+ "goa-scroll-panel",
4144
+ {
4145
+ height,
4146
+ testid: testId,
4147
+ direction,
4148
+ style: hostStyle,
4149
+ ...rest,
4150
+ children: [
4151
+ header && /* @__PURE__ */ jsx("div", { slot: "header", children: header }),
4152
+ children,
4153
+ footer && /* @__PURE__ */ jsx("div", { slot: "footer", children: footer })
4154
+ ]
4155
+ }
4156
+ );
4157
+ }
3963
4158
  function GoabTable({ onSort, onMultiSort, sortMode, ...props }) {
3964
4159
  const ref = useRef(null);
3965
4160
  useEffect(() => {
@@ -4102,6 +4297,7 @@ function GoabTextArea({
4102
4297
  error,
4103
4298
  onChange,
4104
4299
  onKeyPress,
4300
+ onFocus,
4105
4301
  onBlur,
4106
4302
  ...rest
4107
4303
  }) {
@@ -4120,19 +4316,25 @@ function GoabTextArea({
4120
4316
  const detail = e.detail;
4121
4317
  onKeyPress == null ? void 0 : onKeyPress({ ...detail, event: e });
4122
4318
  };
4319
+ const focusListener = (e) => {
4320
+ const detail = e.detail;
4321
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
4322
+ };
4123
4323
  const blurListener = (e) => {
4124
4324
  const detail = e.detail;
4125
4325
  onBlur == null ? void 0 : onBlur({ ...detail, event: e });
4126
4326
  };
4127
4327
  current.addEventListener("_change", changeListener);
4128
4328
  current.addEventListener("_keyPress", keypressListener);
4329
+ current.addEventListener("_focus", focusListener);
4129
4330
  current.addEventListener("_blur", blurListener);
4130
4331
  return () => {
4131
4332
  current.removeEventListener("_change", changeListener);
4132
4333
  current.removeEventListener("_keyPress", keypressListener);
4334
+ current.removeEventListener("_focus", focusListener);
4133
4335
  current.removeEventListener("_blur", blurListener);
4134
4336
  };
4135
- }, [el, onChange, onKeyPress, onBlur]);
4337
+ }, [el, onChange, onKeyPress, onFocus, onBlur]);
4136
4338
  return /* @__PURE__ */ jsx(
4137
4339
  "goa-textarea",
4138
4340
  {
@@ -4191,6 +4393,7 @@ function GoabTwoColumnLayout(props) {
4191
4393
  );
4192
4394
  }
4193
4395
  const GoabFilterChip = ({
4396
+ content,
4194
4397
  iconTheme = "outline",
4195
4398
  error,
4196
4399
  onClick,
@@ -4211,9 +4414,11 @@ const GoabFilterChip = ({
4211
4414
  "goa-filter-chip",
4212
4415
  {
4213
4416
  ref: el,
4417
+ content: typeof content === "string" ? content : void 0,
4214
4418
  error: error ? "true" : void 0,
4215
4419
  version: "2",
4216
- ..._props
4420
+ ..._props,
4421
+ children: typeof content !== "string" && content != null && /* @__PURE__ */ jsx("div", { slot: "content", children: content })
4217
4422
  }
4218
4423
  );
4219
4424
  };
@@ -4503,6 +4708,50 @@ function useTheme() {
4503
4708
  }
4504
4709
  return ctx;
4505
4710
  }
4711
+ const GoabWorkspaceLayoutScrollStateDefault = {
4712
+ scrollPosition: GoabWorkspaceLayoutScrollState.NO_SCROLL,
4713
+ isScrollable: false
4714
+ };
4715
+ const GoabWorkspaceLayoutScrollStateContext = createContext(
4716
+ GoabWorkspaceLayoutScrollStateDefault
4717
+ );
4718
+ function useGoabWorkspaceLayoutScrollState() {
4719
+ return useContext(GoabWorkspaceLayoutScrollStateContext);
4720
+ }
4721
+ function GoabWorkspaceLayout({
4722
+ sideMenu,
4723
+ pageHeader,
4724
+ pageFooter,
4725
+ pushDrawer,
4726
+ children,
4727
+ testId,
4728
+ onScrollStateChange,
4729
+ ...rest
4730
+ }) {
4731
+ const ref = useRef(null);
4732
+ const [scrollState, setScrollState] = useState(GoabWorkspaceLayoutScrollStateDefault);
4733
+ useEffect(() => {
4734
+ const el = ref.current;
4735
+ if (!el) return;
4736
+ const listener = (e) => {
4737
+ const detail = e.detail;
4738
+ setScrollState({
4739
+ scrollPosition: detail.state,
4740
+ isScrollable: detail.isScrollable
4741
+ });
4742
+ onScrollStateChange == null ? void 0 : onScrollStateChange({ ...detail, event: e });
4743
+ };
4744
+ el.addEventListener("_scrollStateChange", listener);
4745
+ return () => el.removeEventListener("_scrollStateChange", listener);
4746
+ }, [onScrollStateChange]);
4747
+ return /* @__PURE__ */ jsx(GoabWorkspaceLayoutScrollStateContext.Provider, { value: scrollState, children: /* @__PURE__ */ jsxs("goa-workspace-layout", { ref, testid: testId, ...rest, children: [
4748
+ sideMenu && /* @__PURE__ */ jsx("div", { slot: "side-menu", children: sideMenu }),
4749
+ pageHeader && /* @__PURE__ */ jsx("div", { slot: "page-header", children: pageHeader }),
4750
+ children,
4751
+ pageFooter && /* @__PURE__ */ jsx("div", { slot: "page-footer", children: pageFooter }),
4752
+ pushDrawer && /* @__PURE__ */ jsx("div", { slot: "push-drawer", children: pushDrawer })
4753
+ ] }) });
4754
+ }
4506
4755
  export {
4507
4756
  GoALinkButton,
4508
4757
  GoabAccordion,
@@ -4529,6 +4778,7 @@ export {
4529
4778
  GoabDrawer,
4530
4779
  GoabDropdown,
4531
4780
  GoabDropdownItem,
4781
+ GoabDropdownMultiselect,
4532
4782
  GoabDropdownOption,
4533
4783
  GoabFieldset,
4534
4784
  GoabFileUploadCard,
@@ -4578,6 +4828,7 @@ export {
4578
4828
  GoabPushDrawer,
4579
4829
  GoabRadioGroup,
4580
4830
  GoabRadioItem,
4831
+ GoabScrollPanel,
4581
4832
  GoabSideMenu,
4582
4833
  GoabSideMenuGroup,
4583
4834
  GoabSideMenuHeading,
@@ -4601,6 +4852,8 @@ export {
4601
4852
  GoabWorkSideMenuItem,
4602
4853
  GoabWorkSideNotificationItem,
4603
4854
  GoabWorkSideNotificationPanel,
4855
+ GoabWorkspaceLayout,
4856
+ useGoabWorkspaceLayoutScrollState,
4604
4857
  usePublicFormController,
4605
4858
  useTheme
4606
4859
  };