@abgov/react-components 7.2.0-dev.4 → 7.2.0-dev.6
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 +74 -16
- package/index.js.map +1 -1
- package/index.mjs +76 -18
- package/index.mjs.map +1 -1
- package/lib/accordion/accordion.d.ts +7 -2
- package/lib/theme/theme-context.d.ts +14 -0
- 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,
|
|
@@ -4304,30 +4316,28 @@ function GoabWorkSideMenu({
|
|
|
4304
4316
|
}) {
|
|
4305
4317
|
const el = react.useRef(null);
|
|
4306
4318
|
react.useEffect(() => {
|
|
4307
|
-
|
|
4308
|
-
if (!
|
|
4319
|
+
const node = el.current;
|
|
4320
|
+
if (!node || !onToggle) {
|
|
4309
4321
|
return;
|
|
4310
4322
|
}
|
|
4311
|
-
|
|
4323
|
+
node.addEventListener("_toggle", onToggle);
|
|
4312
4324
|
return () => {
|
|
4313
|
-
|
|
4314
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_toggle", onToggle);
|
|
4325
|
+
node.removeEventListener("_toggle", onToggle);
|
|
4315
4326
|
};
|
|
4316
|
-
}, [
|
|
4327
|
+
}, [onToggle]);
|
|
4317
4328
|
react.useEffect(() => {
|
|
4318
|
-
|
|
4319
|
-
if (!
|
|
4329
|
+
const node = el.current;
|
|
4330
|
+
if (!node || !onNavigate) {
|
|
4320
4331
|
return;
|
|
4321
4332
|
}
|
|
4322
4333
|
const handler = (e) => {
|
|
4323
4334
|
onNavigate(e.detail.url);
|
|
4324
4335
|
};
|
|
4325
|
-
|
|
4336
|
+
node.addEventListener("_navigate", handler);
|
|
4326
4337
|
return () => {
|
|
4327
|
-
|
|
4328
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_navigate", handler);
|
|
4338
|
+
node.removeEventListener("_navigate", handler);
|
|
4329
4339
|
};
|
|
4330
|
-
}, [
|
|
4340
|
+
}, [onNavigate]);
|
|
4331
4341
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4332
4342
|
"goa-work-side-menu",
|
|
4333
4343
|
{
|
|
@@ -4372,6 +4382,7 @@ function GoabWorkSideMenuItem(props) {
|
|
|
4372
4382
|
type: props.type,
|
|
4373
4383
|
children: [
|
|
4374
4384
|
props.popoverContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "popoverContent", children: props.popoverContent }),
|
|
4385
|
+
props.trailingContent && /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "trailingContent", children: props.trailingContent }),
|
|
4375
4386
|
props.children
|
|
4376
4387
|
]
|
|
4377
4388
|
}
|
|
@@ -4449,6 +4460,51 @@ function GoabWorkSideNotificationPanel({
|
|
|
4449
4460
|
}
|
|
4450
4461
|
);
|
|
4451
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
|
+
}
|
|
4452
4508
|
exports.GoALinkButton = GoALinkButton;
|
|
4453
4509
|
exports.GoabAccordion = GoabAccordion;
|
|
4454
4510
|
exports.GoabAppFooter = GoabAppFooter;
|
|
@@ -4537,6 +4593,7 @@ exports.GoabTemporaryNotificationCtrl = GoabTemporaryNotificationCtrl;
|
|
|
4537
4593
|
exports.GoabText = GoabText;
|
|
4538
4594
|
exports.GoabTextArea = GoabTextArea;
|
|
4539
4595
|
exports.GoabTextarea = GoabTextArea;
|
|
4596
|
+
exports.GoabThemeProvider = GoabThemeProvider;
|
|
4540
4597
|
exports.GoabThreeColumnLayout = GoabThreeColumnLayout;
|
|
4541
4598
|
exports.GoabTooltip = GoabTooltip;
|
|
4542
4599
|
exports.GoabTwoColumnLayout = GoabTwoColumnLayout;
|
|
@@ -4546,4 +4603,5 @@ exports.GoabWorkSideMenuItem = GoabWorkSideMenuItem;
|
|
|
4546
4603
|
exports.GoabWorkSideNotificationItem = GoabWorkSideNotificationItem;
|
|
4547
4604
|
exports.GoabWorkSideNotificationPanel = GoabWorkSideNotificationPanel;
|
|
4548
4605
|
exports.usePublicFormController = usePublicFormController;
|
|
4606
|
+
exports.useTheme = useTheme;
|
|
4549
4607
|
//# sourceMappingURL=index.js.map
|