@abgov/react-components 7.3.0 → 7.5.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,22 +149,30 @@ 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,
142
172
  onClick,
143
173
  actionArgs,
144
174
  actionArg,
175
+ ariaLabel,
145
176
  children,
146
177
  ...rest
147
178
  }) {
@@ -170,6 +201,7 @@ function GoabButton({
170
201
  disabled: disabled ? "true" : void 0,
171
202
  "action-arg": actionArg,
172
203
  "action-args": JSON.stringify(actionArgs),
204
+ arialabel: ariaLabel || void 0,
173
205
  ..._props,
174
206
  version: "2",
175
207
  children
@@ -244,6 +276,8 @@ function GoabCheckbox({
244
276
  description,
245
277
  reveal,
246
278
  onChange,
279
+ onFocus,
280
+ onBlur,
247
281
  name,
248
282
  children,
249
283
  size = "default",
@@ -260,11 +294,23 @@ function GoabCheckbox({
260
294
  const detail = e.detail;
261
295
  onChange == null ? void 0 : onChange({ ...detail, event: e });
262
296
  };
297
+ const focusListener = (e) => {
298
+ const detail = e.detail;
299
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
300
+ };
301
+ const blurListener = (e) => {
302
+ const detail = e.detail;
303
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
304
+ };
263
305
  current.addEventListener("_change", listener);
306
+ current.addEventListener("_focus", focusListener);
307
+ current.addEventListener("_blur", blurListener);
264
308
  return () => {
265
309
  current.removeEventListener("_change", listener);
310
+ current.removeEventListener("_focus", focusListener);
311
+ current.removeEventListener("_blur", blurListener);
266
312
  };
267
- }, [name, onChange]);
313
+ }, [name, onChange, onFocus, onBlur]);
268
314
  return /* @__PURE__ */ jsxs(
269
315
  "goa-checkbox",
270
316
  {
@@ -296,6 +342,8 @@ function GoabCheckboxList({
296
342
  size = "default",
297
343
  children,
298
344
  onChange,
345
+ onFocus,
346
+ onBlur,
299
347
  mt,
300
348
  mr,
301
349
  mb,
@@ -309,11 +357,23 @@ function GoabCheckboxList({
309
357
  const detail = e.detail;
310
358
  onChange == null ? void 0 : onChange({ ...detail, event: e });
311
359
  };
360
+ const focusListener = (e) => {
361
+ const detail = e.detail;
362
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
363
+ };
364
+ const blurListener = (e) => {
365
+ const detail = e.detail;
366
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
367
+ };
312
368
  current.addEventListener("_change", listener);
369
+ current.addEventListener("_focus", focusListener);
370
+ current.addEventListener("_blur", blurListener);
313
371
  return () => {
314
372
  current.removeEventListener("_change", listener);
373
+ current.removeEventListener("_focus", focusListener);
374
+ current.removeEventListener("_blur", blurListener);
315
375
  };
316
- }, [onChange]);
376
+ }, [onChange, onFocus, onBlur]);
317
377
  return /* @__PURE__ */ jsx(
318
378
  "goa-checkbox-list",
319
379
  {
@@ -2612,6 +2672,8 @@ function GoabDatePicker({
2612
2672
  disabled,
2613
2673
  relative,
2614
2674
  onChange,
2675
+ onFocus,
2676
+ onBlur,
2615
2677
  ...rest
2616
2678
  }) {
2617
2679
  const ref = useRef(null);
@@ -2632,15 +2694,27 @@ function GoabDatePicker({
2632
2694
  const detail = e.detail;
2633
2695
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2634
2696
  };
2697
+ const handleFocus = (e) => {
2698
+ const detail = e.detail;
2699
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
2700
+ };
2701
+ const handleBlur = (e) => {
2702
+ const detail = e.detail;
2703
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
2704
+ };
2635
2705
  if (onChange) {
2636
2706
  current.addEventListener("_change", handleChange);
2637
2707
  }
2708
+ current.addEventListener("_focus", handleFocus);
2709
+ current.addEventListener("_blur", handleBlur);
2638
2710
  return () => {
2639
2711
  if (onChange) {
2640
2712
  current.removeEventListener("_change", handleChange);
2641
2713
  }
2714
+ current.removeEventListener("_focus", handleFocus);
2715
+ current.removeEventListener("_blur", handleBlur);
2642
2716
  };
2643
- }, [onChange]);
2717
+ }, [onChange, onFocus, onBlur]);
2644
2718
  const formatValue = (val) => {
2645
2719
  if (!val) return "";
2646
2720
  if (val instanceof Date) {
@@ -2736,6 +2810,8 @@ function stringify(value) {
2736
2810
  function GoabDropdown({
2737
2811
  value,
2738
2812
  onChange,
2813
+ onFocus,
2814
+ onBlur,
2739
2815
  disabled,
2740
2816
  error,
2741
2817
  filterable,
@@ -2757,15 +2833,27 @@ function GoabDropdown({
2757
2833
  const detail = e.detail;
2758
2834
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2759
2835
  };
2836
+ const focusListener = (e) => {
2837
+ const detail = e.detail;
2838
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
2839
+ };
2840
+ const blurListener = (e) => {
2841
+ const detail = e.detail;
2842
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
2843
+ };
2760
2844
  if (onChange) {
2761
2845
  current.addEventListener("_change", handler);
2762
2846
  }
2847
+ current.addEventListener("_focus", focusListener);
2848
+ current.addEventListener("_blur", blurListener);
2763
2849
  return () => {
2764
2850
  if (onChange) {
2765
2851
  current.removeEventListener("_change", handler);
2766
2852
  }
2853
+ current.removeEventListener("_focus", focusListener);
2854
+ current.removeEventListener("_blur", blurListener);
2767
2855
  };
2768
- }, [el, onChange]);
2856
+ }, [el, onChange, onFocus, onBlur]);
2769
2857
  return /* @__PURE__ */ jsx(
2770
2858
  "goa-dropdown",
2771
2859
  {
@@ -2794,7 +2882,8 @@ function GoabDropdownItem({
2794
2882
  label,
2795
2883
  filter,
2796
2884
  name,
2797
- mountType = "append"
2885
+ mountType = "append",
2886
+ children
2798
2887
  }) {
2799
2888
  return /* @__PURE__ */ jsx(
2800
2889
  "goa-dropdown-item",
@@ -2803,7 +2892,71 @@ function GoabDropdownItem({
2803
2892
  label,
2804
2893
  filter,
2805
2894
  name,
2806
- mount: mountType
2895
+ mount: mountType,
2896
+ children
2897
+ }
2898
+ );
2899
+ }
2900
+ function GoabDropdownMultiselect({
2901
+ name,
2902
+ value = [],
2903
+ placeholder,
2904
+ disabled,
2905
+ error,
2906
+ filterable,
2907
+ leadingIcon,
2908
+ showSelectAll,
2909
+ testId,
2910
+ ariaLabel,
2911
+ ariaLabelledBy,
2912
+ maxHeight,
2913
+ width,
2914
+ size = "default",
2915
+ labelFormat,
2916
+ children,
2917
+ onChange,
2918
+ mt,
2919
+ mr,
2920
+ mb,
2921
+ ml
2922
+ }) {
2923
+ const el = useRef(null);
2924
+ useEffect(() => {
2925
+ if (!el.current) return;
2926
+ const current = el.current;
2927
+ const listener = (e) => {
2928
+ const detail = e.detail;
2929
+ onChange == null ? void 0 : onChange({ ...detail, event: e });
2930
+ };
2931
+ current.addEventListener("_change", listener);
2932
+ return () => {
2933
+ current.removeEventListener("_change", listener);
2934
+ };
2935
+ }, [onChange]);
2936
+ return /* @__PURE__ */ jsx(
2937
+ "goa-dropdown-multiselect",
2938
+ {
2939
+ ref: el,
2940
+ name,
2941
+ value,
2942
+ placeholder,
2943
+ disabled: disabled ? "true" : void 0,
2944
+ error: error ? "true" : void 0,
2945
+ filterable: filterable ? "true" : void 0,
2946
+ "leading-icon": leadingIcon,
2947
+ testid: testId,
2948
+ "aria-label": ariaLabel,
2949
+ "aria-labelledby": ariaLabelledBy,
2950
+ "max-height": maxHeight,
2951
+ width,
2952
+ size,
2953
+ "label-format": labelFormat ? labelFormat : void 0,
2954
+ "show-select-all": showSelectAll ? "true" : void 0,
2955
+ mt,
2956
+ mr,
2957
+ mb,
2958
+ ml,
2959
+ children
2807
2960
  }
2808
2961
  );
2809
2962
  }
@@ -3168,6 +3321,7 @@ function GoabHeroBannerActions({
3168
3321
  }
3169
3322
  function GoabIconButton({
3170
3323
  variant = "color",
3324
+ type = "default",
3171
3325
  size = "medium",
3172
3326
  theme = "outline",
3173
3327
  disabled,
@@ -3178,7 +3332,7 @@ function GoabIconButton({
3178
3332
  ...rest
3179
3333
  }) {
3180
3334
  const ref = useRef(null);
3181
- const _props = transformProps({ variant, size, theme, ...rest }, lowercase);
3335
+ const _props = transformProps({ variant, type, size, theme, ...rest }, lowercase);
3182
3336
  useEffect(() => {
3183
3337
  if (!ref.current) {
3184
3338
  return;
@@ -3207,12 +3361,13 @@ function GoabIconButton({
3207
3361
  }
3208
3362
  );
3209
3363
  }
3210
- function GoabIcon({ inverted, ...rest }) {
3364
+ function GoabIcon({ inverted, ariaHidden, ...rest }) {
3211
3365
  const _props = transformProps(rest, lowercase);
3212
3366
  return /* @__PURE__ */ jsx(
3213
3367
  "goa-icon",
3214
3368
  {
3215
3369
  inverted: typeof inverted === "boolean" ? inverted ? "true" : void 0 : inverted,
3370
+ ariahidden: ariaHidden ? "true" : void 0,
3216
3371
  ..._props
3217
3372
  }
3218
3373
  );
@@ -3834,6 +3989,8 @@ function GoabRadioGroup({
3834
3989
  disabled,
3835
3990
  error,
3836
3991
  onChange,
3992
+ onFocus,
3993
+ onBlur,
3837
3994
  name,
3838
3995
  children,
3839
3996
  size = "default",
@@ -3847,16 +4004,28 @@ function GoabRadioGroup({
3847
4004
  const detail = e.detail;
3848
4005
  onChange == null ? void 0 : onChange({ ...detail, event: e });
3849
4006
  };
4007
+ const focusListener = (e) => {
4008
+ const detail = e.detail;
4009
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
4010
+ };
4011
+ const blurListener = (e) => {
4012
+ const detail = e.detail;
4013
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
4014
+ };
3850
4015
  const currentEl = el.current;
3851
4016
  if (onChange) {
3852
4017
  currentEl.addEventListener("_change", listener);
3853
4018
  }
4019
+ currentEl.addEventListener("_focus", focusListener);
4020
+ currentEl.addEventListener("_blur", blurListener);
3854
4021
  return () => {
3855
4022
  if (onChange) {
3856
4023
  currentEl.removeEventListener("_change", listener);
3857
4024
  }
4025
+ currentEl.removeEventListener("_focus", focusListener);
4026
+ currentEl.removeEventListener("_blur", blurListener);
3858
4027
  };
3859
- }, [name, onChange]);
4028
+ }, [name, onChange, onFocus, onBlur]);
3860
4029
  return /* @__PURE__ */ jsx(
3861
4030
  "goa-radio-group",
3862
4031
  {
@@ -3969,14 +4138,25 @@ function GoabScrollPanel({
3969
4138
  footer,
3970
4139
  height,
3971
4140
  testId,
4141
+ direction = "vertical",
3972
4142
  ...rest
3973
4143
  }) {
3974
4144
  const hostStyle = height ? { height } : void 0;
3975
- return /* @__PURE__ */ jsxs("goa-scroll-panel", { height, testid: testId, style: hostStyle, ...rest, children: [
3976
- header && /* @__PURE__ */ jsx("div", { slot: "header", children: header }),
3977
- children,
3978
- footer && /* @__PURE__ */ jsx("div", { slot: "footer", children: footer })
3979
- ] });
4145
+ return /* @__PURE__ */ jsxs(
4146
+ "goa-scroll-panel",
4147
+ {
4148
+ height,
4149
+ testid: testId,
4150
+ direction,
4151
+ style: hostStyle,
4152
+ ...rest,
4153
+ children: [
4154
+ header && /* @__PURE__ */ jsx("div", { slot: "header", children: header }),
4155
+ children,
4156
+ footer && /* @__PURE__ */ jsx("div", { slot: "footer", children: footer })
4157
+ ]
4158
+ }
4159
+ );
3980
4160
  }
3981
4161
  function GoabTable({ onSort, onMultiSort, sortMode, ...props }) {
3982
4162
  const ref = useRef(null);
@@ -4120,6 +4300,7 @@ function GoabTextArea({
4120
4300
  error,
4121
4301
  onChange,
4122
4302
  onKeyPress,
4303
+ onFocus,
4123
4304
  onBlur,
4124
4305
  ...rest
4125
4306
  }) {
@@ -4138,19 +4319,25 @@ function GoabTextArea({
4138
4319
  const detail = e.detail;
4139
4320
  onKeyPress == null ? void 0 : onKeyPress({ ...detail, event: e });
4140
4321
  };
4322
+ const focusListener = (e) => {
4323
+ const detail = e.detail;
4324
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
4325
+ };
4141
4326
  const blurListener = (e) => {
4142
4327
  const detail = e.detail;
4143
4328
  onBlur == null ? void 0 : onBlur({ ...detail, event: e });
4144
4329
  };
4145
4330
  current.addEventListener("_change", changeListener);
4146
4331
  current.addEventListener("_keyPress", keypressListener);
4332
+ current.addEventListener("_focus", focusListener);
4147
4333
  current.addEventListener("_blur", blurListener);
4148
4334
  return () => {
4149
4335
  current.removeEventListener("_change", changeListener);
4150
4336
  current.removeEventListener("_keyPress", keypressListener);
4337
+ current.removeEventListener("_focus", focusListener);
4151
4338
  current.removeEventListener("_blur", blurListener);
4152
4339
  };
4153
- }, [el, onChange, onKeyPress, onBlur]);
4340
+ }, [el, onChange, onKeyPress, onFocus, onBlur]);
4154
4341
  return /* @__PURE__ */ jsx(
4155
4342
  "goa-textarea",
4156
4343
  {
@@ -4209,6 +4396,7 @@ function GoabTwoColumnLayout(props) {
4209
4396
  );
4210
4397
  }
4211
4398
  const GoabFilterChip = ({
4399
+ content,
4212
4400
  iconTheme = "outline",
4213
4401
  error,
4214
4402
  onClick,
@@ -4229,9 +4417,11 @@ const GoabFilterChip = ({
4229
4417
  "goa-filter-chip",
4230
4418
  {
4231
4419
  ref: el,
4420
+ content: typeof content === "string" ? content : void 0,
4232
4421
  error: error ? "true" : void 0,
4233
4422
  version: "2",
4234
- ..._props
4423
+ ..._props,
4424
+ children: typeof content !== "string" && content != null && /* @__PURE__ */ jsx("div", { slot: "content", children: content })
4235
4425
  }
4236
4426
  );
4237
4427
  };
@@ -4591,6 +4781,7 @@ export {
4591
4781
  GoabDrawer,
4592
4782
  GoabDropdown,
4593
4783
  GoabDropdownItem,
4784
+ GoabDropdownMultiselect,
4594
4785
  GoabDropdownOption,
4595
4786
  GoabFieldset,
4596
4787
  GoabFileUploadCard,