@abgov/react-components 7.3.0 → 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
  {
@@ -2612,6 +2670,8 @@ function GoabDatePicker({
2612
2670
  disabled,
2613
2671
  relative,
2614
2672
  onChange,
2673
+ onFocus,
2674
+ onBlur,
2615
2675
  ...rest
2616
2676
  }) {
2617
2677
  const ref = useRef(null);
@@ -2632,15 +2692,27 @@ function GoabDatePicker({
2632
2692
  const detail = e.detail;
2633
2693
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2634
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
+ };
2635
2703
  if (onChange) {
2636
2704
  current.addEventListener("_change", handleChange);
2637
2705
  }
2706
+ current.addEventListener("_focus", handleFocus);
2707
+ current.addEventListener("_blur", handleBlur);
2638
2708
  return () => {
2639
2709
  if (onChange) {
2640
2710
  current.removeEventListener("_change", handleChange);
2641
2711
  }
2712
+ current.removeEventListener("_focus", handleFocus);
2713
+ current.removeEventListener("_blur", handleBlur);
2642
2714
  };
2643
- }, [onChange]);
2715
+ }, [onChange, onFocus, onBlur]);
2644
2716
  const formatValue = (val) => {
2645
2717
  if (!val) return "";
2646
2718
  if (val instanceof Date) {
@@ -2736,6 +2808,8 @@ function stringify(value) {
2736
2808
  function GoabDropdown({
2737
2809
  value,
2738
2810
  onChange,
2811
+ onFocus,
2812
+ onBlur,
2739
2813
  disabled,
2740
2814
  error,
2741
2815
  filterable,
@@ -2757,15 +2831,27 @@ function GoabDropdown({
2757
2831
  const detail = e.detail;
2758
2832
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2759
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
+ };
2760
2842
  if (onChange) {
2761
2843
  current.addEventListener("_change", handler);
2762
2844
  }
2845
+ current.addEventListener("_focus", focusListener);
2846
+ current.addEventListener("_blur", blurListener);
2763
2847
  return () => {
2764
2848
  if (onChange) {
2765
2849
  current.removeEventListener("_change", handler);
2766
2850
  }
2851
+ current.removeEventListener("_focus", focusListener);
2852
+ current.removeEventListener("_blur", blurListener);
2767
2853
  };
2768
- }, [el, onChange]);
2854
+ }, [el, onChange, onFocus, onBlur]);
2769
2855
  return /* @__PURE__ */ jsx(
2770
2856
  "goa-dropdown",
2771
2857
  {
@@ -2794,7 +2880,8 @@ function GoabDropdownItem({
2794
2880
  label,
2795
2881
  filter,
2796
2882
  name,
2797
- mountType = "append"
2883
+ mountType = "append",
2884
+ children
2798
2885
  }) {
2799
2886
  return /* @__PURE__ */ jsx(
2800
2887
  "goa-dropdown-item",
@@ -2803,7 +2890,71 @@ function GoabDropdownItem({
2803
2890
  label,
2804
2891
  filter,
2805
2892
  name,
2806
- 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
2807
2958
  }
2808
2959
  );
2809
2960
  }
@@ -3168,6 +3319,7 @@ function GoabHeroBannerActions({
3168
3319
  }
3169
3320
  function GoabIconButton({
3170
3321
  variant = "color",
3322
+ type = "default",
3171
3323
  size = "medium",
3172
3324
  theme = "outline",
3173
3325
  disabled,
@@ -3178,7 +3330,7 @@ function GoabIconButton({
3178
3330
  ...rest
3179
3331
  }) {
3180
3332
  const ref = useRef(null);
3181
- const _props = transformProps({ variant, size, theme, ...rest }, lowercase);
3333
+ const _props = transformProps({ variant, type, size, theme, ...rest }, lowercase);
3182
3334
  useEffect(() => {
3183
3335
  if (!ref.current) {
3184
3336
  return;
@@ -3834,6 +3986,8 @@ function GoabRadioGroup({
3834
3986
  disabled,
3835
3987
  error,
3836
3988
  onChange,
3989
+ onFocus,
3990
+ onBlur,
3837
3991
  name,
3838
3992
  children,
3839
3993
  size = "default",
@@ -3847,16 +4001,28 @@ function GoabRadioGroup({
3847
4001
  const detail = e.detail;
3848
4002
  onChange == null ? void 0 : onChange({ ...detail, event: e });
3849
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
+ };
3850
4012
  const currentEl = el.current;
3851
4013
  if (onChange) {
3852
4014
  currentEl.addEventListener("_change", listener);
3853
4015
  }
4016
+ currentEl.addEventListener("_focus", focusListener);
4017
+ currentEl.addEventListener("_blur", blurListener);
3854
4018
  return () => {
3855
4019
  if (onChange) {
3856
4020
  currentEl.removeEventListener("_change", listener);
3857
4021
  }
4022
+ currentEl.removeEventListener("_focus", focusListener);
4023
+ currentEl.removeEventListener("_blur", blurListener);
3858
4024
  };
3859
- }, [name, onChange]);
4025
+ }, [name, onChange, onFocus, onBlur]);
3860
4026
  return /* @__PURE__ */ jsx(
3861
4027
  "goa-radio-group",
3862
4028
  {
@@ -3969,14 +4135,25 @@ function GoabScrollPanel({
3969
4135
  footer,
3970
4136
  height,
3971
4137
  testId,
4138
+ direction = "vertical",
3972
4139
  ...rest
3973
4140
  }) {
3974
4141
  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
- ] });
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
+ );
3980
4157
  }
3981
4158
  function GoabTable({ onSort, onMultiSort, sortMode, ...props }) {
3982
4159
  const ref = useRef(null);
@@ -4120,6 +4297,7 @@ function GoabTextArea({
4120
4297
  error,
4121
4298
  onChange,
4122
4299
  onKeyPress,
4300
+ onFocus,
4123
4301
  onBlur,
4124
4302
  ...rest
4125
4303
  }) {
@@ -4138,19 +4316,25 @@ function GoabTextArea({
4138
4316
  const detail = e.detail;
4139
4317
  onKeyPress == null ? void 0 : onKeyPress({ ...detail, event: e });
4140
4318
  };
4319
+ const focusListener = (e) => {
4320
+ const detail = e.detail;
4321
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
4322
+ };
4141
4323
  const blurListener = (e) => {
4142
4324
  const detail = e.detail;
4143
4325
  onBlur == null ? void 0 : onBlur({ ...detail, event: e });
4144
4326
  };
4145
4327
  current.addEventListener("_change", changeListener);
4146
4328
  current.addEventListener("_keyPress", keypressListener);
4329
+ current.addEventListener("_focus", focusListener);
4147
4330
  current.addEventListener("_blur", blurListener);
4148
4331
  return () => {
4149
4332
  current.removeEventListener("_change", changeListener);
4150
4333
  current.removeEventListener("_keyPress", keypressListener);
4334
+ current.removeEventListener("_focus", focusListener);
4151
4335
  current.removeEventListener("_blur", blurListener);
4152
4336
  };
4153
- }, [el, onChange, onKeyPress, onBlur]);
4337
+ }, [el, onChange, onKeyPress, onFocus, onBlur]);
4154
4338
  return /* @__PURE__ */ jsx(
4155
4339
  "goa-textarea",
4156
4340
  {
@@ -4209,6 +4393,7 @@ function GoabTwoColumnLayout(props) {
4209
4393
  );
4210
4394
  }
4211
4395
  const GoabFilterChip = ({
4396
+ content,
4212
4397
  iconTheme = "outline",
4213
4398
  error,
4214
4399
  onClick,
@@ -4229,9 +4414,11 @@ const GoabFilterChip = ({
4229
4414
  "goa-filter-chip",
4230
4415
  {
4231
4416
  ref: el,
4417
+ content: typeof content === "string" ? content : void 0,
4232
4418
  error: error ? "true" : void 0,
4233
4419
  version: "2",
4234
- ..._props
4420
+ ..._props,
4421
+ children: typeof content !== "string" && content != null && /* @__PURE__ */ jsx("div", { slot: "content", children: content })
4235
4422
  }
4236
4423
  );
4237
4424
  };
@@ -4591,6 +4778,7 @@ export {
4591
4778
  GoabDrawer,
4592
4779
  GoabDropdown,
4593
4780
  GoabDropdownItem,
4781
+ GoabDropdownMultiselect,
4594
4782
  GoabDropdownOption,
4595
4783
  GoabFieldset,
4596
4784
  GoabFileUploadCard,