@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.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 } from "react";
|
|
12
|
+
import { useRef, useEffect, 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) {
|
|
@@ -28,6 +28,8 @@ function GoabAccordion({
|
|
|
28
28
|
open,
|
|
29
29
|
onChange,
|
|
30
30
|
headingContent,
|
|
31
|
+
headingType,
|
|
32
|
+
actions,
|
|
31
33
|
children,
|
|
32
34
|
...rest
|
|
33
35
|
}) {
|
|
@@ -46,10 +48,20 @@ function GoabAccordion({
|
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
}, [onChange]);
|
|
49
|
-
return /* @__PURE__ */ jsxs(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
return /* @__PURE__ */ jsxs(
|
|
52
|
+
"goa-accordion",
|
|
53
|
+
{
|
|
54
|
+
ref,
|
|
55
|
+
open: open ? "true" : void 0,
|
|
56
|
+
"heading-type": headingType,
|
|
57
|
+
..._props,
|
|
58
|
+
children: [
|
|
59
|
+
headingContent && /* @__PURE__ */ jsx("div", { slot: "headingcontent", children: headingContent }),
|
|
60
|
+
actions && /* @__PURE__ */ jsx("div", { slot: "actions", children: actions }),
|
|
61
|
+
children
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
53
65
|
}
|
|
54
66
|
function GoabAppHeader({
|
|
55
67
|
onMenuClick,
|
|
@@ -2676,14 +2688,19 @@ function GoabDrawer({
|
|
|
2676
2688
|
}) {
|
|
2677
2689
|
const el = useRef(null);
|
|
2678
2690
|
useEffect(() => {
|
|
2679
|
-
var _a;
|
|
2680
2691
|
if (!(el == null ? void 0 : el.current) || !onClose) {
|
|
2681
2692
|
return;
|
|
2682
2693
|
}
|
|
2683
|
-
|
|
2694
|
+
const current = el.current;
|
|
2695
|
+
const listener = (e) => {
|
|
2696
|
+
if (e.target !== current) {
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
onClose();
|
|
2700
|
+
};
|
|
2701
|
+
current.addEventListener("_close", listener);
|
|
2684
2702
|
return () => {
|
|
2685
|
-
|
|
2686
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_close", onClose);
|
|
2703
|
+
current.removeEventListener("_close", listener);
|
|
2687
2704
|
};
|
|
2688
2705
|
}, [el, onClose]);
|
|
2689
2706
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3121,9 +3138,10 @@ function GoabHeroBanner({
|
|
|
3121
3138
|
backgroundColor,
|
|
3122
3139
|
textColor,
|
|
3123
3140
|
children,
|
|
3141
|
+
actions,
|
|
3124
3142
|
testId
|
|
3125
3143
|
}) {
|
|
3126
|
-
return /* @__PURE__ */
|
|
3144
|
+
return /* @__PURE__ */ jsxs(
|
|
3127
3145
|
"goa-hero-banner",
|
|
3128
3146
|
{
|
|
3129
3147
|
heading,
|
|
@@ -3133,7 +3151,10 @@ function GoabHeroBanner({
|
|
|
3133
3151
|
backgroundcolor: backgroundColor,
|
|
3134
3152
|
textcolor: textColor,
|
|
3135
3153
|
testid: testId,
|
|
3136
|
-
children
|
|
3154
|
+
children: [
|
|
3155
|
+
children,
|
|
3156
|
+
actions && /* @__PURE__ */ jsx("div", { slot: "actions", children: actions })
|
|
3157
|
+
]
|
|
3137
3158
|
}
|
|
3138
3159
|
);
|
|
3139
3160
|
}
|
|
@@ -3574,7 +3595,10 @@ function GoabModal({
|
|
|
3574
3595
|
return;
|
|
3575
3596
|
}
|
|
3576
3597
|
const current = el.current;
|
|
3577
|
-
const listener = () => {
|
|
3598
|
+
const listener = (e) => {
|
|
3599
|
+
if (e.target !== current) {
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3578
3602
|
onClose == null ? void 0 : onClose();
|
|
3579
3603
|
};
|
|
3580
3604
|
current.addEventListener("_close", listener);
|
|
@@ -3725,14 +3749,19 @@ function GoabPushDrawer({
|
|
|
3725
3749
|
}) {
|
|
3726
3750
|
const el = useRef(null);
|
|
3727
3751
|
useEffect(() => {
|
|
3728
|
-
var _a;
|
|
3729
3752
|
if (!(el == null ? void 0 : el.current) || !onClose) {
|
|
3730
3753
|
return;
|
|
3731
3754
|
}
|
|
3732
|
-
|
|
3755
|
+
const current = el.current;
|
|
3756
|
+
const listener = (e) => {
|
|
3757
|
+
if (e.target !== current) {
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
onClose();
|
|
3761
|
+
};
|
|
3762
|
+
current.addEventListener("_close", listener);
|
|
3733
3763
|
return () => {
|
|
3734
|
-
|
|
3735
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_close", onClose);
|
|
3764
|
+
current.removeEventListener("_close", listener);
|
|
3736
3765
|
};
|
|
3737
3766
|
}, [el, onClose]);
|
|
3738
3767
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3984,6 +4013,7 @@ function GoabTableSortHeader({
|
|
|
3984
4013
|
name,
|
|
3985
4014
|
direction,
|
|
3986
4015
|
"sort-order": sortOrder,
|
|
4016
|
+
version: "2",
|
|
3987
4017
|
...rest,
|
|
3988
4018
|
children
|
|
3989
4019
|
}
|
|
@@ -4284,30 +4314,28 @@ function GoabWorkSideMenu({
|
|
|
4284
4314
|
}) {
|
|
4285
4315
|
const el = useRef(null);
|
|
4286
4316
|
useEffect(() => {
|
|
4287
|
-
|
|
4288
|
-
if (!
|
|
4317
|
+
const node = el.current;
|
|
4318
|
+
if (!node || !onToggle) {
|
|
4289
4319
|
return;
|
|
4290
4320
|
}
|
|
4291
|
-
|
|
4321
|
+
node.addEventListener("_toggle", onToggle);
|
|
4292
4322
|
return () => {
|
|
4293
|
-
|
|
4294
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_toggle", onToggle);
|
|
4323
|
+
node.removeEventListener("_toggle", onToggle);
|
|
4295
4324
|
};
|
|
4296
|
-
}, [
|
|
4325
|
+
}, [onToggle]);
|
|
4297
4326
|
useEffect(() => {
|
|
4298
|
-
|
|
4299
|
-
if (!
|
|
4327
|
+
const node = el.current;
|
|
4328
|
+
if (!node || !onNavigate) {
|
|
4300
4329
|
return;
|
|
4301
4330
|
}
|
|
4302
4331
|
const handler = (e) => {
|
|
4303
4332
|
onNavigate(e.detail.url);
|
|
4304
4333
|
};
|
|
4305
|
-
|
|
4334
|
+
node.addEventListener("_navigate", handler);
|
|
4306
4335
|
return () => {
|
|
4307
|
-
|
|
4308
|
-
(_a2 = el.current) == null ? void 0 : _a2.removeEventListener("_navigate", handler);
|
|
4336
|
+
node.removeEventListener("_navigate", handler);
|
|
4309
4337
|
};
|
|
4310
|
-
}, [
|
|
4338
|
+
}, [onNavigate]);
|
|
4311
4339
|
return /* @__PURE__ */ jsxs(
|
|
4312
4340
|
"goa-work-side-menu",
|
|
4313
4341
|
{
|
|
@@ -4352,6 +4380,7 @@ function GoabWorkSideMenuItem(props) {
|
|
|
4352
4380
|
type: props.type,
|
|
4353
4381
|
children: [
|
|
4354
4382
|
props.popoverContent && /* @__PURE__ */ jsx("div", { slot: "popoverContent", children: props.popoverContent }),
|
|
4383
|
+
props.trailingContent && /* @__PURE__ */ jsx("div", { slot: "trailingContent", children: props.trailingContent }),
|
|
4355
4384
|
props.children
|
|
4356
4385
|
]
|
|
4357
4386
|
}
|
|
@@ -4429,6 +4458,51 @@ function GoabWorkSideNotificationPanel({
|
|
|
4429
4458
|
}
|
|
4430
4459
|
);
|
|
4431
4460
|
}
|
|
4461
|
+
const STORAGE_KEY = "goab-theme";
|
|
4462
|
+
const ATTRIBUTE = "data-theme";
|
|
4463
|
+
const GoabThemeContext = createContext(null);
|
|
4464
|
+
function readInitialMode(defaultMode) {
|
|
4465
|
+
if (typeof window === "undefined") return defaultMode;
|
|
4466
|
+
try {
|
|
4467
|
+
const stored = window.localStorage.getItem(STORAGE_KEY);
|
|
4468
|
+
if (stored === "light" || stored === "dark") return stored;
|
|
4469
|
+
} catch {
|
|
4470
|
+
}
|
|
4471
|
+
const fromAttribute = document.documentElement.getAttribute(ATTRIBUTE);
|
|
4472
|
+
if (fromAttribute === "light" || fromAttribute === "dark") return fromAttribute;
|
|
4473
|
+
if (window.matchMedia("(prefers-color-scheme: dark)").matches) return "dark";
|
|
4474
|
+
return defaultMode;
|
|
4475
|
+
}
|
|
4476
|
+
function GoabThemeProvider({
|
|
4477
|
+
children,
|
|
4478
|
+
defaultMode = "light"
|
|
4479
|
+
}) {
|
|
4480
|
+
const [mode, setModeState] = useState(
|
|
4481
|
+
() => readInitialMode(defaultMode)
|
|
4482
|
+
);
|
|
4483
|
+
useEffect(() => {
|
|
4484
|
+
if (typeof document === "undefined") return;
|
|
4485
|
+
document.documentElement.setAttribute(ATTRIBUTE, mode);
|
|
4486
|
+
try {
|
|
4487
|
+
window.localStorage.setItem(STORAGE_KEY, mode);
|
|
4488
|
+
} catch {
|
|
4489
|
+
}
|
|
4490
|
+
}, [mode]);
|
|
4491
|
+
const setMode = useCallback((next) => {
|
|
4492
|
+
setModeState(next);
|
|
4493
|
+
}, []);
|
|
4494
|
+
const toggle = useCallback(() => {
|
|
4495
|
+
setModeState((prev) => prev === "light" ? "dark" : "light");
|
|
4496
|
+
}, []);
|
|
4497
|
+
return /* @__PURE__ */ jsx(GoabThemeContext.Provider, { value: { mode, setMode, toggle }, children });
|
|
4498
|
+
}
|
|
4499
|
+
function useTheme() {
|
|
4500
|
+
const ctx = useContext(GoabThemeContext);
|
|
4501
|
+
if (!ctx) {
|
|
4502
|
+
throw new Error("useTheme must be used within a GoabThemeProvider");
|
|
4503
|
+
}
|
|
4504
|
+
return ctx;
|
|
4505
|
+
}
|
|
4432
4506
|
export {
|
|
4433
4507
|
GoALinkButton,
|
|
4434
4508
|
GoabAccordion,
|
|
@@ -4518,6 +4592,7 @@ export {
|
|
|
4518
4592
|
GoabText,
|
|
4519
4593
|
GoabTextArea,
|
|
4520
4594
|
GoabTextArea as GoabTextarea,
|
|
4595
|
+
GoabThemeProvider,
|
|
4521
4596
|
GoabThreeColumnLayout,
|
|
4522
4597
|
GoabTooltip,
|
|
4523
4598
|
GoabTwoColumnLayout,
|
|
@@ -4526,6 +4601,7 @@ export {
|
|
|
4526
4601
|
GoabWorkSideMenuItem,
|
|
4527
4602
|
GoabWorkSideNotificationItem,
|
|
4528
4603
|
GoabWorkSideNotificationPanel,
|
|
4529
|
-
usePublicFormController
|
|
4604
|
+
usePublicFormController,
|
|
4605
|
+
useTheme
|
|
4530
4606
|
};
|
|
4531
4607
|
//# sourceMappingURL=index.mjs.map
|