@abgov/react-components 7.2.0-dev.2 → 7.2.0-dev.20

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
@@ -62,6 +62,7 @@ export * from './lib/side-menu/side-menu';
62
62
  export * from './lib/skeleton/skeleton';
63
63
  export * from './lib/spacer/spacer';
64
64
  export * from './lib/spinner/spinner';
65
+ export * from './lib/scroll-panel/scroll-panel';
65
66
  export * from './lib/table/table';
66
67
  export * from './lib/table/table-sort-header';
67
68
  export * from './lib/tabs/tabs';
@@ -79,3 +80,5 @@ export * from './lib/work-side-menu-group/work-side-menu-group';
79
80
  export * from './lib/work-side-menu-item/work-side-menu-item';
80
81
  export * from './lib/work-side-notification-item/work-side-notification-item';
81
82
  export * from './lib/work-side-notification-panel/work-side-notification-panel';
83
+ export * from './lib/theme/theme-context';
84
+ export * from './lib/workspace-layout/workspace-layout';
package/index.js CHANGED
@@ -30,6 +30,8 @@ function GoabAccordion({
30
30
  open,
31
31
  onChange,
32
32
  headingContent,
33
+ headingType,
34
+ actions,
33
35
  children,
34
36
  ...rest
35
37
  }) {
@@ -48,10 +50,20 @@ function GoabAccordion({
48
50
  };
49
51
  }
50
52
  }, [onChange]);
51
- return /* @__PURE__ */ jsxRuntime.jsxs("goa-accordion", { ref, open: open ? "true" : void 0, ..._props, children: [
52
- headingContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "headingcontent", children: headingContent }),
53
- children
54
- ] });
53
+ return /* @__PURE__ */ jsxRuntime.jsxs(
54
+ "goa-accordion",
55
+ {
56
+ ref,
57
+ open: open ? "true" : void 0,
58
+ "heading-type": headingType,
59
+ ..._props,
60
+ children: [
61
+ headingContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "headingcontent", children: headingContent }),
62
+ actions && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "actions", children: actions }),
63
+ children
64
+ ]
65
+ }
66
+ );
55
67
  }
56
68
  function GoabAppHeader({
57
69
  onMenuClick,
@@ -123,9 +135,14 @@ function GoabBadge({
123
135
  }
124
136
  );
125
137
  }
126
- function GoabBlock({ testId, children, ...rest }) {
138
+ function GoabBlock({
139
+ testId,
140
+ stretch,
141
+ children,
142
+ ...rest
143
+ }) {
127
144
  const _props = transformProps({ testid: testId, ...rest }, kebab);
128
- return /* @__PURE__ */ jsxRuntime.jsx("goa-block", { ..._props, children });
145
+ return /* @__PURE__ */ jsxRuntime.jsx("goa-block", { ..._props, stretch: stretch ? "true" : void 0, children });
129
146
  }
130
147
  function GoabButton({
131
148
  disabled,
@@ -234,6 +251,8 @@ function GoabCheckbox({
234
251
  description,
235
252
  reveal,
236
253
  onChange,
254
+ onFocus,
255
+ onBlur,
237
256
  name,
238
257
  children,
239
258
  size = "default",
@@ -250,11 +269,23 @@ function GoabCheckbox({
250
269
  const detail = e.detail;
251
270
  onChange == null ? void 0 : onChange({ ...detail, event: e });
252
271
  };
272
+ const focusListener = (e) => {
273
+ const detail = e.detail;
274
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
275
+ };
276
+ const blurListener = (e) => {
277
+ const detail = e.detail;
278
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
279
+ };
253
280
  current.addEventListener("_change", listener);
281
+ current.addEventListener("_focus", focusListener);
282
+ current.addEventListener("_blur", blurListener);
254
283
  return () => {
255
284
  current.removeEventListener("_change", listener);
285
+ current.removeEventListener("_focus", focusListener);
286
+ current.removeEventListener("_blur", blurListener);
256
287
  };
257
- }, [name, onChange]);
288
+ }, [name, onChange, onFocus, onBlur]);
258
289
  return /* @__PURE__ */ jsxRuntime.jsxs(
259
290
  "goa-checkbox",
260
291
  {
@@ -286,6 +317,8 @@ function GoabCheckboxList({
286
317
  size = "default",
287
318
  children,
288
319
  onChange,
320
+ onFocus,
321
+ onBlur,
289
322
  mt,
290
323
  mr,
291
324
  mb,
@@ -299,11 +332,23 @@ function GoabCheckboxList({
299
332
  const detail = e.detail;
300
333
  onChange == null ? void 0 : onChange({ ...detail, event: e });
301
334
  };
335
+ const focusListener = (e) => {
336
+ const detail = e.detail;
337
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
338
+ };
339
+ const blurListener = (e) => {
340
+ const detail = e.detail;
341
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
342
+ };
302
343
  current.addEventListener("_change", listener);
344
+ current.addEventListener("_focus", focusListener);
345
+ current.addEventListener("_blur", blurListener);
303
346
  return () => {
304
347
  current.removeEventListener("_change", listener);
348
+ current.removeEventListener("_focus", focusListener);
349
+ current.removeEventListener("_blur", blurListener);
305
350
  };
306
- }, [onChange]);
351
+ }, [onChange, onFocus, onBlur]);
307
352
  return /* @__PURE__ */ jsxRuntime.jsx(
308
353
  "goa-checkbox-list",
309
354
  {
@@ -400,6 +445,9 @@ function GoabDataGrid({
400
445
  }
401
446
  );
402
447
  }
448
+ const GoabWorkspaceLayoutScrollState = {
449
+ NO_SCROLL: "no-scroll"
450
+ };
403
451
  function dispatch(el, eventName, detail, opts) {
404
452
  if (!el) {
405
453
  console.error("dispatch element is null");
@@ -2599,6 +2647,8 @@ function GoabDatePicker({
2599
2647
  disabled,
2600
2648
  relative,
2601
2649
  onChange,
2650
+ onFocus,
2651
+ onBlur,
2602
2652
  ...rest
2603
2653
  }) {
2604
2654
  const ref = react.useRef(null);
@@ -2619,15 +2669,27 @@ function GoabDatePicker({
2619
2669
  const detail = e.detail;
2620
2670
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2621
2671
  };
2672
+ const handleFocus = (e) => {
2673
+ const detail = e.detail;
2674
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
2675
+ };
2676
+ const handleBlur = (e) => {
2677
+ const detail = e.detail;
2678
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
2679
+ };
2622
2680
  if (onChange) {
2623
2681
  current.addEventListener("_change", handleChange);
2624
2682
  }
2683
+ current.addEventListener("_focus", handleFocus);
2684
+ current.addEventListener("_blur", handleBlur);
2625
2685
  return () => {
2626
2686
  if (onChange) {
2627
2687
  current.removeEventListener("_change", handleChange);
2628
2688
  }
2689
+ current.removeEventListener("_focus", handleFocus);
2690
+ current.removeEventListener("_blur", handleBlur);
2629
2691
  };
2630
- }, [onChange]);
2692
+ }, [onChange, onFocus, onBlur]);
2631
2693
  const formatValue = (val) => {
2632
2694
  if (!val) return "";
2633
2695
  if (val instanceof Date) {
@@ -2723,6 +2785,8 @@ function stringify(value) {
2723
2785
  function GoabDropdown({
2724
2786
  value,
2725
2787
  onChange,
2788
+ onFocus,
2789
+ onBlur,
2726
2790
  disabled,
2727
2791
  error,
2728
2792
  filterable,
@@ -2744,15 +2808,27 @@ function GoabDropdown({
2744
2808
  const detail = e.detail;
2745
2809
  onChange == null ? void 0 : onChange({ ...detail, event: e });
2746
2810
  };
2811
+ const focusListener = (e) => {
2812
+ const detail = e.detail;
2813
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
2814
+ };
2815
+ const blurListener = (e) => {
2816
+ const detail = e.detail;
2817
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
2818
+ };
2747
2819
  if (onChange) {
2748
2820
  current.addEventListener("_change", handler);
2749
2821
  }
2822
+ current.addEventListener("_focus", focusListener);
2823
+ current.addEventListener("_blur", blurListener);
2750
2824
  return () => {
2751
2825
  if (onChange) {
2752
2826
  current.removeEventListener("_change", handler);
2753
2827
  }
2828
+ current.removeEventListener("_focus", focusListener);
2829
+ current.removeEventListener("_blur", blurListener);
2754
2830
  };
2755
- }, [el, onChange]);
2831
+ }, [el, onChange, onFocus, onBlur]);
2756
2832
  return /* @__PURE__ */ jsxRuntime.jsx(
2757
2833
  "goa-dropdown",
2758
2834
  {
@@ -3821,6 +3897,8 @@ function GoabRadioGroup({
3821
3897
  disabled,
3822
3898
  error,
3823
3899
  onChange,
3900
+ onFocus,
3901
+ onBlur,
3824
3902
  name,
3825
3903
  children,
3826
3904
  size = "default",
@@ -3834,16 +3912,28 @@ function GoabRadioGroup({
3834
3912
  const detail = e.detail;
3835
3913
  onChange == null ? void 0 : onChange({ ...detail, event: e });
3836
3914
  };
3915
+ const focusListener = (e) => {
3916
+ const detail = e.detail;
3917
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
3918
+ };
3919
+ const blurListener = (e) => {
3920
+ const detail = e.detail;
3921
+ onBlur == null ? void 0 : onBlur({ ...detail, event: e });
3922
+ };
3837
3923
  const currentEl = el.current;
3838
3924
  if (onChange) {
3839
3925
  currentEl.addEventListener("_change", listener);
3840
3926
  }
3927
+ currentEl.addEventListener("_focus", focusListener);
3928
+ currentEl.addEventListener("_blur", blurListener);
3841
3929
  return () => {
3842
3930
  if (onChange) {
3843
3931
  currentEl.removeEventListener("_change", listener);
3844
3932
  }
3933
+ currentEl.removeEventListener("_focus", focusListener);
3934
+ currentEl.removeEventListener("_blur", blurListener);
3845
3935
  };
3846
- }, [name, onChange]);
3936
+ }, [name, onChange, onFocus, onBlur]);
3847
3937
  return /* @__PURE__ */ jsxRuntime.jsx(
3848
3938
  "goa-radio-group",
3849
3939
  {
@@ -3950,6 +4040,21 @@ function GoabSpinner({
3950
4040
  }
3951
4041
  );
3952
4042
  }
4043
+ function GoabScrollPanel({
4044
+ header,
4045
+ children,
4046
+ footer,
4047
+ height,
4048
+ testId,
4049
+ ...rest
4050
+ }) {
4051
+ const hostStyle = height ? { height } : void 0;
4052
+ return /* @__PURE__ */ jsxRuntime.jsxs("goa-scroll-panel", { height, testid: testId, style: hostStyle, ...rest, children: [
4053
+ header && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "header", children: header }),
4054
+ children,
4055
+ footer && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "footer", children: footer })
4056
+ ] });
4057
+ }
3953
4058
  function GoabTable({ onSort, onMultiSort, sortMode, ...props }) {
3954
4059
  const ref = react.useRef(null);
3955
4060
  react.useEffect(() => {
@@ -4003,6 +4108,7 @@ function GoabTableSortHeader({
4003
4108
  name,
4004
4109
  direction,
4005
4110
  "sort-order": sortOrder,
4111
+ version: "2",
4006
4112
  ...rest,
4007
4113
  children
4008
4114
  }
@@ -4091,6 +4197,7 @@ function GoabTextArea({
4091
4197
  error,
4092
4198
  onChange,
4093
4199
  onKeyPress,
4200
+ onFocus,
4094
4201
  onBlur,
4095
4202
  ...rest
4096
4203
  }) {
@@ -4109,19 +4216,25 @@ function GoabTextArea({
4109
4216
  const detail = e.detail;
4110
4217
  onKeyPress == null ? void 0 : onKeyPress({ ...detail, event: e });
4111
4218
  };
4219
+ const focusListener = (e) => {
4220
+ const detail = e.detail;
4221
+ onFocus == null ? void 0 : onFocus({ ...detail, event: e });
4222
+ };
4112
4223
  const blurListener = (e) => {
4113
4224
  const detail = e.detail;
4114
4225
  onBlur == null ? void 0 : onBlur({ ...detail, event: e });
4115
4226
  };
4116
4227
  current.addEventListener("_change", changeListener);
4117
4228
  current.addEventListener("_keyPress", keypressListener);
4229
+ current.addEventListener("_focus", focusListener);
4118
4230
  current.addEventListener("_blur", blurListener);
4119
4231
  return () => {
4120
4232
  current.removeEventListener("_change", changeListener);
4121
4233
  current.removeEventListener("_keyPress", keypressListener);
4234
+ current.removeEventListener("_focus", focusListener);
4122
4235
  current.removeEventListener("_blur", blurListener);
4123
4236
  };
4124
- }, [el, onChange, onKeyPress, onBlur]);
4237
+ }, [el, onChange, onKeyPress, onFocus, onBlur]);
4125
4238
  return /* @__PURE__ */ jsxRuntime.jsx(
4126
4239
  "goa-textarea",
4127
4240
  {
@@ -4303,30 +4416,28 @@ function GoabWorkSideMenu({
4303
4416
  }) {
4304
4417
  const el = react.useRef(null);
4305
4418
  react.useEffect(() => {
4306
- var _a;
4307
- if (!(el == null ? void 0 : el.current) || !onToggle) {
4419
+ const node = el.current;
4420
+ if (!node || !onToggle) {
4308
4421
  return;
4309
4422
  }
4310
- (_a = el.current) == null ? void 0 : _a.addEventListener("_toggle", onToggle);
4423
+ node.addEventListener("_toggle", onToggle);
4311
4424
  return () => {
4312
- var _a2;
4313
- (_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_toggle", onToggle);
4425
+ node.removeEventListener("_toggle", onToggle);
4314
4426
  };
4315
- }, [el, onToggle]);
4427
+ }, [onToggle]);
4316
4428
  react.useEffect(() => {
4317
- var _a;
4318
- if (!(el == null ? void 0 : el.current) || !onNavigate) {
4429
+ const node = el.current;
4430
+ if (!node || !onNavigate) {
4319
4431
  return;
4320
4432
  }
4321
4433
  const handler = (e) => {
4322
4434
  onNavigate(e.detail.url);
4323
4435
  };
4324
- (_a = el.current) == null ? void 0 : _a.addEventListener("_navigate", handler);
4436
+ node.addEventListener("_navigate", handler);
4325
4437
  return () => {
4326
- var _a2;
4327
- (_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_navigate", handler);
4438
+ node.removeEventListener("_navigate", handler);
4328
4439
  };
4329
- }, [el, onNavigate]);
4440
+ }, [onNavigate]);
4330
4441
  return /* @__PURE__ */ jsxRuntime.jsxs(
4331
4442
  "goa-work-side-menu",
4332
4443
  {
@@ -4371,6 +4482,7 @@ function GoabWorkSideMenuItem(props) {
4371
4482
  type: props.type,
4372
4483
  children: [
4373
4484
  props.popoverContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "popoverContent", children: props.popoverContent }),
4485
+ props.trailingContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "trailingContent", children: props.trailingContent }),
4374
4486
  props.children
4375
4487
  ]
4376
4488
  }
@@ -4448,6 +4560,95 @@ function GoabWorkSideNotificationPanel({
4448
4560
  }
4449
4561
  );
4450
4562
  }
4563
+ const STORAGE_KEY = "goab-theme";
4564
+ const ATTRIBUTE = "data-theme";
4565
+ const GoabThemeContext = react.createContext(null);
4566
+ function readInitialMode(defaultMode) {
4567
+ if (typeof window === "undefined") return defaultMode;
4568
+ try {
4569
+ const stored = window.localStorage.getItem(STORAGE_KEY);
4570
+ if (stored === "light" || stored === "dark") return stored;
4571
+ } catch {
4572
+ }
4573
+ const fromAttribute = document.documentElement.getAttribute(ATTRIBUTE);
4574
+ if (fromAttribute === "light" || fromAttribute === "dark") return fromAttribute;
4575
+ if (window.matchMedia("(prefers-color-scheme: dark)").matches) return "dark";
4576
+ return defaultMode;
4577
+ }
4578
+ function GoabThemeProvider({
4579
+ children,
4580
+ defaultMode = "light"
4581
+ }) {
4582
+ const [mode, setModeState] = react.useState(
4583
+ () => readInitialMode(defaultMode)
4584
+ );
4585
+ react.useEffect(() => {
4586
+ if (typeof document === "undefined") return;
4587
+ document.documentElement.setAttribute(ATTRIBUTE, mode);
4588
+ try {
4589
+ window.localStorage.setItem(STORAGE_KEY, mode);
4590
+ } catch {
4591
+ }
4592
+ }, [mode]);
4593
+ const setMode = react.useCallback((next) => {
4594
+ setModeState(next);
4595
+ }, []);
4596
+ const toggle = react.useCallback(() => {
4597
+ setModeState((prev) => prev === "light" ? "dark" : "light");
4598
+ }, []);
4599
+ return /* @__PURE__ */ jsxRuntime.jsx(GoabThemeContext.Provider, { value: { mode, setMode, toggle }, children });
4600
+ }
4601
+ function useTheme() {
4602
+ const ctx = react.useContext(GoabThemeContext);
4603
+ if (!ctx) {
4604
+ throw new Error("useTheme must be used within a GoabThemeProvider");
4605
+ }
4606
+ return ctx;
4607
+ }
4608
+ const GoabWorkspaceLayoutScrollStateDefault = {
4609
+ scrollPosition: GoabWorkspaceLayoutScrollState.NO_SCROLL,
4610
+ isScrollable: false
4611
+ };
4612
+ const GoabWorkspaceLayoutScrollStateContext = react.createContext(
4613
+ GoabWorkspaceLayoutScrollStateDefault
4614
+ );
4615
+ function useGoabWorkspaceLayoutScrollState() {
4616
+ return react.useContext(GoabWorkspaceLayoutScrollStateContext);
4617
+ }
4618
+ function GoabWorkspaceLayout({
4619
+ sideMenu,
4620
+ pageHeader,
4621
+ pageFooter,
4622
+ pushDrawer,
4623
+ children,
4624
+ testId,
4625
+ onScrollStateChange,
4626
+ ...rest
4627
+ }) {
4628
+ const ref = react.useRef(null);
4629
+ const [scrollState, setScrollState] = react.useState(GoabWorkspaceLayoutScrollStateDefault);
4630
+ react.useEffect(() => {
4631
+ const el = ref.current;
4632
+ if (!el) return;
4633
+ const listener = (e) => {
4634
+ const detail = e.detail;
4635
+ setScrollState({
4636
+ scrollPosition: detail.state,
4637
+ isScrollable: detail.isScrollable
4638
+ });
4639
+ onScrollStateChange == null ? void 0 : onScrollStateChange({ ...detail, event: e });
4640
+ };
4641
+ el.addEventListener("_scrollStateChange", listener);
4642
+ return () => el.removeEventListener("_scrollStateChange", listener);
4643
+ }, [onScrollStateChange]);
4644
+ return /* @__PURE__ */ jsxRuntime.jsx(GoabWorkspaceLayoutScrollStateContext.Provider, { value: scrollState, children: /* @__PURE__ */ jsxRuntime.jsxs("goa-workspace-layout", { ref, testid: testId, ...rest, children: [
4645
+ sideMenu && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "side-menu", children: sideMenu }),
4646
+ pageHeader && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "page-header", children: pageHeader }),
4647
+ children,
4648
+ pageFooter && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "page-footer", children: pageFooter }),
4649
+ pushDrawer && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "push-drawer", children: pushDrawer })
4650
+ ] }) });
4651
+ }
4451
4652
  exports.GoALinkButton = GoALinkButton;
4452
4653
  exports.GoabAccordion = GoabAccordion;
4453
4654
  exports.GoabAppFooter = GoabAppFooter;
@@ -4522,6 +4723,7 @@ exports.GoabPublicSubformIndex = GoabPublicSubformIndex;
4522
4723
  exports.GoabPushDrawer = GoabPushDrawer;
4523
4724
  exports.GoabRadioGroup = GoabRadioGroup;
4524
4725
  exports.GoabRadioItem = GoabRadioItem;
4726
+ exports.GoabScrollPanel = GoabScrollPanel;
4525
4727
  exports.GoabSideMenu = GoabSideMenu;
4526
4728
  exports.GoabSideMenuGroup = GoabSideMenuGroup;
4527
4729
  exports.GoabSideMenuHeading = GoabSideMenuHeading;
@@ -4536,6 +4738,7 @@ exports.GoabTemporaryNotificationCtrl = GoabTemporaryNotificationCtrl;
4536
4738
  exports.GoabText = GoabText;
4537
4739
  exports.GoabTextArea = GoabTextArea;
4538
4740
  exports.GoabTextarea = GoabTextArea;
4741
+ exports.GoabThemeProvider = GoabThemeProvider;
4539
4742
  exports.GoabThreeColumnLayout = GoabThreeColumnLayout;
4540
4743
  exports.GoabTooltip = GoabTooltip;
4541
4744
  exports.GoabTwoColumnLayout = GoabTwoColumnLayout;
@@ -4544,5 +4747,8 @@ exports.GoabWorkSideMenuGroup = GoabWorkSideMenuGroup;
4544
4747
  exports.GoabWorkSideMenuItem = GoabWorkSideMenuItem;
4545
4748
  exports.GoabWorkSideNotificationItem = GoabWorkSideNotificationItem;
4546
4749
  exports.GoabWorkSideNotificationPanel = GoabWorkSideNotificationPanel;
4750
+ exports.GoabWorkspaceLayout = GoabWorkspaceLayout;
4751
+ exports.useGoabWorkspaceLayoutScrollState = useGoabWorkspaceLayoutScrollState;
4547
4752
  exports.usePublicFormController = usePublicFormController;
4753
+ exports.useTheme = useTheme;
4548
4754
  //# sourceMappingURL=index.js.map