@abgov/react-components 7.1.0 → 7.2.0-dev.10
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 +1 -0
- package/index.js +103 -27
- package/index.js.map +1 -1
- package/index.mjs +105 -29
- package/index.mjs.map +1 -1
- package/lib/accordion/accordion.d.ts +7 -2
- package/lib/chip/chip.d.ts +7 -7
- package/lib/container/container.d.ts +2 -2
- package/lib/dropdown/dropdown.d.ts +1 -1
- package/lib/hero-banner/hero-banner.d.ts +3 -1
- package/lib/input/input.d.ts +1 -0
- package/lib/microsite-header/microsite-header.d.ts +1 -1
- package/lib/radio-group/radio.d.ts +1 -1
- package/lib/tab/tab.d.ts +2 -2
- package/lib/table/table-sort-header.d.ts +1 -0
- package/lib/table/table.d.ts +0 -1
- package/lib/theme/theme-context.d.ts +14 -0
- package/lib/tooltip/tooltip.d.ts +1 -1
- package/lib/work-side-menu-item/work-side-menu-item.d.ts +4 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -79,3 +79,4 @@ export * from './lib/work-side-menu-group/work-side-menu-group';
|
|
|
79
79
|
export * from './lib/work-side-menu-item/work-side-menu-item';
|
|
80
80
|
export * from './lib/work-side-notification-item/work-side-notification-item';
|
|
81
81
|
export * from './lib/work-side-notification-panel/work-side-notification-panel';
|
|
82
|
+
export * from './lib/theme/theme-context';
|
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(
|
|
52
|
-
|
|
53
|
-
|
|
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,
|
|
@@ -2678,14 +2690,19 @@ function GoabDrawer({
|
|
|
2678
2690
|
}) {
|
|
2679
2691
|
const el = react.useRef(null);
|
|
2680
2692
|
react.useEffect(() => {
|
|
2681
|
-
var _a;
|
|
2682
2693
|
if (!(el == null ? void 0 : el.current) || !onClose) {
|
|
2683
2694
|
return;
|
|
2684
2695
|
}
|
|
2685
|
-
|
|
2696
|
+
const current = el.current;
|
|
2697
|
+
const listener = (e) => {
|
|
2698
|
+
if (e.target !== current) {
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
onClose();
|
|
2702
|
+
};
|
|
2703
|
+
current.addEventListener("_close", listener);
|
|
2686
2704
|
return () => {
|
|
2687
|
-
|
|
2688
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_close", onClose);
|
|
2705
|
+
current.removeEventListener("_close", listener);
|
|
2689
2706
|
};
|
|
2690
2707
|
}, [el, onClose]);
|
|
2691
2708
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3123,9 +3140,10 @@ function GoabHeroBanner({
|
|
|
3123
3140
|
backgroundColor,
|
|
3124
3141
|
textColor,
|
|
3125
3142
|
children,
|
|
3143
|
+
actions,
|
|
3126
3144
|
testId
|
|
3127
3145
|
}) {
|
|
3128
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
3146
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3129
3147
|
"goa-hero-banner",
|
|
3130
3148
|
{
|
|
3131
3149
|
heading,
|
|
@@ -3135,7 +3153,10 @@ function GoabHeroBanner({
|
|
|
3135
3153
|
backgroundcolor: backgroundColor,
|
|
3136
3154
|
textcolor: textColor,
|
|
3137
3155
|
testid: testId,
|
|
3138
|
-
children
|
|
3156
|
+
children: [
|
|
3157
|
+
children,
|
|
3158
|
+
actions && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "actions", children: actions })
|
|
3159
|
+
]
|
|
3139
3160
|
}
|
|
3140
3161
|
);
|
|
3141
3162
|
}
|
|
@@ -3576,7 +3597,10 @@ function GoabModal({
|
|
|
3576
3597
|
return;
|
|
3577
3598
|
}
|
|
3578
3599
|
const current = el.current;
|
|
3579
|
-
const listener = () => {
|
|
3600
|
+
const listener = (e) => {
|
|
3601
|
+
if (e.target !== current) {
|
|
3602
|
+
return;
|
|
3603
|
+
}
|
|
3580
3604
|
onClose == null ? void 0 : onClose();
|
|
3581
3605
|
};
|
|
3582
3606
|
current.addEventListener("_close", listener);
|
|
@@ -3727,14 +3751,19 @@ function GoabPushDrawer({
|
|
|
3727
3751
|
}) {
|
|
3728
3752
|
const el = react.useRef(null);
|
|
3729
3753
|
react.useEffect(() => {
|
|
3730
|
-
var _a;
|
|
3731
3754
|
if (!(el == null ? void 0 : el.current) || !onClose) {
|
|
3732
3755
|
return;
|
|
3733
3756
|
}
|
|
3734
|
-
|
|
3757
|
+
const current = el.current;
|
|
3758
|
+
const listener = (e) => {
|
|
3759
|
+
if (e.target !== current) {
|
|
3760
|
+
return;
|
|
3761
|
+
}
|
|
3762
|
+
onClose();
|
|
3763
|
+
};
|
|
3764
|
+
current.addEventListener("_close", listener);
|
|
3735
3765
|
return () => {
|
|
3736
|
-
|
|
3737
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_close", onClose);
|
|
3766
|
+
current.removeEventListener("_close", listener);
|
|
3738
3767
|
};
|
|
3739
3768
|
}, [el, onClose]);
|
|
3740
3769
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3986,6 +4015,7 @@ function GoabTableSortHeader({
|
|
|
3986
4015
|
name,
|
|
3987
4016
|
direction,
|
|
3988
4017
|
"sort-order": sortOrder,
|
|
4018
|
+
version: "2",
|
|
3989
4019
|
...rest,
|
|
3990
4020
|
children
|
|
3991
4021
|
}
|
|
@@ -4286,30 +4316,28 @@ function GoabWorkSideMenu({
|
|
|
4286
4316
|
}) {
|
|
4287
4317
|
const el = react.useRef(null);
|
|
4288
4318
|
react.useEffect(() => {
|
|
4289
|
-
|
|
4290
|
-
if (!
|
|
4319
|
+
const node = el.current;
|
|
4320
|
+
if (!node || !onToggle) {
|
|
4291
4321
|
return;
|
|
4292
4322
|
}
|
|
4293
|
-
|
|
4323
|
+
node.addEventListener("_toggle", onToggle);
|
|
4294
4324
|
return () => {
|
|
4295
|
-
|
|
4296
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_toggle", onToggle);
|
|
4325
|
+
node.removeEventListener("_toggle", onToggle);
|
|
4297
4326
|
};
|
|
4298
|
-
}, [
|
|
4327
|
+
}, [onToggle]);
|
|
4299
4328
|
react.useEffect(() => {
|
|
4300
|
-
|
|
4301
|
-
if (!
|
|
4329
|
+
const node = el.current;
|
|
4330
|
+
if (!node || !onNavigate) {
|
|
4302
4331
|
return;
|
|
4303
4332
|
}
|
|
4304
4333
|
const handler = (e) => {
|
|
4305
4334
|
onNavigate(e.detail.url);
|
|
4306
4335
|
};
|
|
4307
|
-
|
|
4336
|
+
node.addEventListener("_navigate", handler);
|
|
4308
4337
|
return () => {
|
|
4309
|
-
|
|
4310
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_navigate", handler);
|
|
4338
|
+
node.removeEventListener("_navigate", handler);
|
|
4311
4339
|
};
|
|
4312
|
-
}, [
|
|
4340
|
+
}, [onNavigate]);
|
|
4313
4341
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4314
4342
|
"goa-work-side-menu",
|
|
4315
4343
|
{
|
|
@@ -4354,6 +4382,7 @@ function GoabWorkSideMenuItem(props) {
|
|
|
4354
4382
|
type: props.type,
|
|
4355
4383
|
children: [
|
|
4356
4384
|
props.popoverContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "popoverContent", children: props.popoverContent }),
|
|
4385
|
+
props.trailingContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "trailingContent", children: props.trailingContent }),
|
|
4357
4386
|
props.children
|
|
4358
4387
|
]
|
|
4359
4388
|
}
|
|
@@ -4431,6 +4460,51 @@ function GoabWorkSideNotificationPanel({
|
|
|
4431
4460
|
}
|
|
4432
4461
|
);
|
|
4433
4462
|
}
|
|
4463
|
+
const STORAGE_KEY = "goab-theme";
|
|
4464
|
+
const ATTRIBUTE = "data-theme";
|
|
4465
|
+
const GoabThemeContext = react.createContext(null);
|
|
4466
|
+
function readInitialMode(defaultMode) {
|
|
4467
|
+
if (typeof window === "undefined") return defaultMode;
|
|
4468
|
+
try {
|
|
4469
|
+
const stored = window.localStorage.getItem(STORAGE_KEY);
|
|
4470
|
+
if (stored === "light" || stored === "dark") return stored;
|
|
4471
|
+
} catch {
|
|
4472
|
+
}
|
|
4473
|
+
const fromAttribute = document.documentElement.getAttribute(ATTRIBUTE);
|
|
4474
|
+
if (fromAttribute === "light" || fromAttribute === "dark") return fromAttribute;
|
|
4475
|
+
if (window.matchMedia("(prefers-color-scheme: dark)").matches) return "dark";
|
|
4476
|
+
return defaultMode;
|
|
4477
|
+
}
|
|
4478
|
+
function GoabThemeProvider({
|
|
4479
|
+
children,
|
|
4480
|
+
defaultMode = "light"
|
|
4481
|
+
}) {
|
|
4482
|
+
const [mode, setModeState] = react.useState(
|
|
4483
|
+
() => readInitialMode(defaultMode)
|
|
4484
|
+
);
|
|
4485
|
+
react.useEffect(() => {
|
|
4486
|
+
if (typeof document === "undefined") return;
|
|
4487
|
+
document.documentElement.setAttribute(ATTRIBUTE, mode);
|
|
4488
|
+
try {
|
|
4489
|
+
window.localStorage.setItem(STORAGE_KEY, mode);
|
|
4490
|
+
} catch {
|
|
4491
|
+
}
|
|
4492
|
+
}, [mode]);
|
|
4493
|
+
const setMode = react.useCallback((next) => {
|
|
4494
|
+
setModeState(next);
|
|
4495
|
+
}, []);
|
|
4496
|
+
const toggle = react.useCallback(() => {
|
|
4497
|
+
setModeState((prev) => prev === "light" ? "dark" : "light");
|
|
4498
|
+
}, []);
|
|
4499
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GoabThemeContext.Provider, { value: { mode, setMode, toggle }, children });
|
|
4500
|
+
}
|
|
4501
|
+
function useTheme() {
|
|
4502
|
+
const ctx = react.useContext(GoabThemeContext);
|
|
4503
|
+
if (!ctx) {
|
|
4504
|
+
throw new Error("useTheme must be used within a GoabThemeProvider");
|
|
4505
|
+
}
|
|
4506
|
+
return ctx;
|
|
4507
|
+
}
|
|
4434
4508
|
exports.GoALinkButton = GoALinkButton;
|
|
4435
4509
|
exports.GoabAccordion = GoabAccordion;
|
|
4436
4510
|
exports.GoabAppFooter = GoabAppFooter;
|
|
@@ -4519,6 +4593,7 @@ exports.GoabTemporaryNotificationCtrl = GoabTemporaryNotificationCtrl;
|
|
|
4519
4593
|
exports.GoabText = GoabText;
|
|
4520
4594
|
exports.GoabTextArea = GoabTextArea;
|
|
4521
4595
|
exports.GoabTextarea = GoabTextArea;
|
|
4596
|
+
exports.GoabThemeProvider = GoabThemeProvider;
|
|
4522
4597
|
exports.GoabThreeColumnLayout = GoabThreeColumnLayout;
|
|
4523
4598
|
exports.GoabTooltip = GoabTooltip;
|
|
4524
4599
|
exports.GoabTwoColumnLayout = GoabTwoColumnLayout;
|
|
@@ -4528,4 +4603,5 @@ exports.GoabWorkSideMenuItem = GoabWorkSideMenuItem;
|
|
|
4528
4603
|
exports.GoabWorkSideNotificationItem = GoabWorkSideNotificationItem;
|
|
4529
4604
|
exports.GoabWorkSideNotificationPanel = GoabWorkSideNotificationPanel;
|
|
4530
4605
|
exports.usePublicFormController = usePublicFormController;
|
|
4606
|
+
exports.useTheme = useTheme;
|
|
4531
4607
|
//# sourceMappingURL=index.js.map
|