@fragments-sdk/ui 0.17.0 → 0.18.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/dist/assets/ui.css +320 -183
- package/dist/components/Header/Header.module.scss.cjs +42 -21
- package/dist/components/Header/Header.module.scss.js +42 -21
- package/dist/components/Header/index.cjs +121 -3
- package/dist/components/Header/index.d.ts +26 -3
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +122 -4
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +42 -42
- package/dist/components/Sidebar/Sidebar.module.scss.js +42 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/fragments.json +1 -1
- package/package.json +3 -3
- package/src/components/Accordion/Accordion.contract.json +169 -0
- package/src/components/Alert/Alert.contract.json +157 -0
- package/src/components/AppShell/AppShell.contract.json +155 -0
- package/src/components/Avatar/Avatar.contract.json +189 -0
- package/src/components/Badge/Badge.contract.json +187 -0
- package/src/components/BentoGrid/BentoGrid.contract.json +135 -0
- package/src/components/Box/Box.contract.json +423 -0
- package/src/components/Breadcrumbs/Breadcrumbs.contract.json +143 -0
- package/src/components/Button/Button.contract.json +205 -0
- package/src/components/ButtonGroup/ButtonGroup.contract.json +140 -0
- package/src/components/Card/Card.contract.json +185 -0
- package/src/components/Chart/Chart.contract.json +129 -0
- package/src/components/Checkbox/Checkbox.contract.json +246 -0
- package/src/components/Chip/Chip.contract.json +212 -0
- package/src/components/CodeBlock/CodeBlock.contract.json +388 -0
- package/src/components/Collapsible/Collapsible.contract.json +154 -0
- package/src/components/ColorPicker/ColorPicker.contract.json +212 -0
- package/src/components/Combobox/Combobox.contract.json +297 -0
- package/src/components/Command/Command.contract.json +165 -0
- package/src/components/ConversationList/ConversationList.contract.json +151 -0
- package/src/components/DataTable/DataTable.contract.json +302 -0
- package/src/components/DatePicker/DatePicker.contract.json +288 -0
- package/src/components/Dialog/Dialog.contract.json +159 -0
- package/src/components/Drawer/Drawer.contract.json +160 -0
- package/src/components/Editor/Editor.contract.json +263 -0
- package/src/components/EmptyState/EmptyState.contract.json +133 -0
- package/src/components/Field/Field.contract.json +157 -0
- package/src/components/Fieldset/Fieldset.contract.json +117 -0
- package/src/components/Form/Form.contract.json +145 -0
- package/src/components/Grid/Grid.contract.json +195 -0
- package/src/components/Header/Header.contract.json +194 -0
- package/src/components/Header/Header.module.scss +99 -0
- package/src/components/Header/index.tsx +191 -10
- package/src/components/Icon/Icon.contract.json +194 -0
- package/src/components/Image/Image.contract.json +209 -0
- package/src/components/Input/Input.contract.json +344 -0
- package/src/components/Link/Link.contract.json +180 -0
- package/src/components/List/List.contract.json +154 -0
- package/src/components/Listbox/Listbox.contract.json +158 -0
- package/src/components/Loading/Loading.contract.json +167 -0
- package/src/components/Markdown/Markdown.contract.json +127 -0
- package/src/components/Menu/Menu.contract.json +177 -0
- package/src/components/Message/Message.contract.json +183 -0
- package/src/components/NavigationMenu/NavigationMenu.contract.json +203 -0
- package/src/components/Pagination/Pagination.contract.json +163 -0
- package/src/components/Popover/Popover.contract.json +163 -0
- package/src/components/Progress/Progress.contract.json +176 -0
- package/src/components/Prompt/Prompt.contract.json +211 -0
- package/src/components/RadioGroup/RadioGroup.contract.json +226 -0
- package/src/components/ScrollArea/ScrollArea.contract.json +131 -0
- package/src/components/Select/Select.contract.json +269 -0
- package/src/components/Separator/Separator.contract.json +143 -0
- package/src/components/Sidebar/Sidebar.contract.json +258 -0
- package/src/components/Sidebar/Sidebar.module.scss +6 -4
- package/src/components/Skeleton/Skeleton.contract.json +166 -0
- package/src/components/Slider/Slider.contract.json +248 -0
- package/src/components/Stack/Stack.contract.json +220 -0
- package/src/components/Table/Table.contract.json +171 -0
- package/src/components/TableOfContents/TableOfContents.contract.json +145 -0
- package/src/components/Tabs/Tabs.contract.json +159 -0
- package/src/components/Text/Text.contract.json +239 -0
- package/src/components/Textarea/Textarea.contract.json +308 -0
- package/src/components/Theme/Theme.contract.json +152 -0
- package/src/components/ThinkingIndicator/ThinkingIndicator.contract.json +165 -0
- package/src/components/Toast/Toast.contract.json +181 -0
- package/src/components/Toggle/Toggle.contract.json +231 -0
- package/src/components/ToggleGroup/ToggleGroup.contract.json +206 -0
- package/src/components/Tooltip/Tooltip.contract.json +214 -0
- package/src/components/VisuallyHidden/VisuallyHidden.contract.json +116 -0
- package/src/index.ts +1 -0
- package/src/tokens/_derive.scss +4 -1
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const header = "
|
|
4
|
-
const fixed = "
|
|
5
|
-
const sticky = "
|
|
6
|
-
const container = "
|
|
7
|
-
const brand = "
|
|
8
|
-
const nav = "
|
|
9
|
-
const navList = "
|
|
10
|
-
const navItem = "
|
|
11
|
-
const navItemActive = "
|
|
12
|
-
const navMenuTrigger = "
|
|
13
|
-
const navMenuChevron = "
|
|
14
|
-
const navMenuPositioner = "
|
|
15
|
-
const navMenuPopup = "
|
|
16
|
-
const navMenuItem = "
|
|
17
|
-
const navMenuItemActive = "
|
|
18
|
-
const search = "
|
|
19
|
-
const searchExpandable = "
|
|
20
|
-
const actions = "
|
|
21
|
-
const trigger = "
|
|
22
|
-
const spacer = "
|
|
23
|
-
const
|
|
3
|
+
const header = "_header_1ult6_1";
|
|
4
|
+
const fixed = "_fixed_1ult6_13";
|
|
5
|
+
const sticky = "_sticky_1ult6_20";
|
|
6
|
+
const container = "_container_1ult6_25";
|
|
7
|
+
const brand = "_brand_1ult6_38";
|
|
8
|
+
const nav = "_nav_1ult6_56";
|
|
9
|
+
const navList = "_navList_1ult6_66";
|
|
10
|
+
const navItem = "_navItem_1ult6_75";
|
|
11
|
+
const navItemActive = "_navItemActive_1ult6_123";
|
|
12
|
+
const navMenuTrigger = "_navMenuTrigger_1ult6_137";
|
|
13
|
+
const navMenuChevron = "_navMenuChevron_1ult6_142";
|
|
14
|
+
const navMenuPositioner = "_navMenuPositioner_1ult6_150";
|
|
15
|
+
const navMenuPopup = "_navMenuPopup_1ult6_155";
|
|
16
|
+
const navMenuItem = "_navMenuItem_1ult6_176";
|
|
17
|
+
const navMenuItemActive = "_navMenuItemActive_1ult6_212";
|
|
18
|
+
const search = "_search_1ult6_234";
|
|
19
|
+
const searchExpandable = "_searchExpandable_1ult6_244";
|
|
20
|
+
const actions = "_actions_1ult6_248";
|
|
21
|
+
const trigger = "_trigger_1ult6_255";
|
|
22
|
+
const spacer = "_spacer_1ult6_297";
|
|
23
|
+
const mobileNavBackdrop = "_mobileNavBackdrop_1ult6_301";
|
|
24
|
+
const mobileNavDrawer = "_mobileNavDrawer_1ult6_309";
|
|
25
|
+
const mobileNavHeader = "_mobileNavHeader_1ult6_323";
|
|
26
|
+
const mobileNavClose = "_mobileNavClose_1ult6_331";
|
|
27
|
+
const mobileNavBody = "_mobileNavBody_1ult6_369";
|
|
28
|
+
const mobileNavLink = "_mobileNavLink_1ult6_375";
|
|
29
|
+
const mobileNavLinkActive = "_mobileNavLinkActive_1ult6_409";
|
|
30
|
+
const skipLink = "_skipLink_1ult6_436";
|
|
24
31
|
const styles = {
|
|
25
32
|
header,
|
|
26
33
|
fixed,
|
|
@@ -42,6 +49,13 @@ const styles = {
|
|
|
42
49
|
actions,
|
|
43
50
|
trigger,
|
|
44
51
|
spacer,
|
|
52
|
+
mobileNavBackdrop,
|
|
53
|
+
mobileNavDrawer,
|
|
54
|
+
mobileNavHeader,
|
|
55
|
+
mobileNavClose,
|
|
56
|
+
mobileNavBody,
|
|
57
|
+
mobileNavLink,
|
|
58
|
+
mobileNavLinkActive,
|
|
45
59
|
skipLink
|
|
46
60
|
};
|
|
47
61
|
exports.actions = actions;
|
|
@@ -50,6 +64,13 @@ exports.container = container;
|
|
|
50
64
|
exports.default = styles;
|
|
51
65
|
exports.fixed = fixed;
|
|
52
66
|
exports.header = header;
|
|
67
|
+
exports.mobileNavBackdrop = mobileNavBackdrop;
|
|
68
|
+
exports.mobileNavBody = mobileNavBody;
|
|
69
|
+
exports.mobileNavClose = mobileNavClose;
|
|
70
|
+
exports.mobileNavDrawer = mobileNavDrawer;
|
|
71
|
+
exports.mobileNavHeader = mobileNavHeader;
|
|
72
|
+
exports.mobileNavLink = mobileNavLink;
|
|
73
|
+
exports.mobileNavLinkActive = mobileNavLinkActive;
|
|
53
74
|
exports.nav = nav;
|
|
54
75
|
exports.navItem = navItem;
|
|
55
76
|
exports.navItemActive = navItemActive;
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
const header = "
|
|
2
|
-
const fixed = "
|
|
3
|
-
const sticky = "
|
|
4
|
-
const container = "
|
|
5
|
-
const brand = "
|
|
6
|
-
const nav = "
|
|
7
|
-
const navList = "
|
|
8
|
-
const navItem = "
|
|
9
|
-
const navItemActive = "
|
|
10
|
-
const navMenuTrigger = "
|
|
11
|
-
const navMenuChevron = "
|
|
12
|
-
const navMenuPositioner = "
|
|
13
|
-
const navMenuPopup = "
|
|
14
|
-
const navMenuItem = "
|
|
15
|
-
const navMenuItemActive = "
|
|
16
|
-
const search = "
|
|
17
|
-
const searchExpandable = "
|
|
18
|
-
const actions = "
|
|
19
|
-
const trigger = "
|
|
20
|
-
const spacer = "
|
|
21
|
-
const
|
|
1
|
+
const header = "_header_1ult6_1";
|
|
2
|
+
const fixed = "_fixed_1ult6_13";
|
|
3
|
+
const sticky = "_sticky_1ult6_20";
|
|
4
|
+
const container = "_container_1ult6_25";
|
|
5
|
+
const brand = "_brand_1ult6_38";
|
|
6
|
+
const nav = "_nav_1ult6_56";
|
|
7
|
+
const navList = "_navList_1ult6_66";
|
|
8
|
+
const navItem = "_navItem_1ult6_75";
|
|
9
|
+
const navItemActive = "_navItemActive_1ult6_123";
|
|
10
|
+
const navMenuTrigger = "_navMenuTrigger_1ult6_137";
|
|
11
|
+
const navMenuChevron = "_navMenuChevron_1ult6_142";
|
|
12
|
+
const navMenuPositioner = "_navMenuPositioner_1ult6_150";
|
|
13
|
+
const navMenuPopup = "_navMenuPopup_1ult6_155";
|
|
14
|
+
const navMenuItem = "_navMenuItem_1ult6_176";
|
|
15
|
+
const navMenuItemActive = "_navMenuItemActive_1ult6_212";
|
|
16
|
+
const search = "_search_1ult6_234";
|
|
17
|
+
const searchExpandable = "_searchExpandable_1ult6_244";
|
|
18
|
+
const actions = "_actions_1ult6_248";
|
|
19
|
+
const trigger = "_trigger_1ult6_255";
|
|
20
|
+
const spacer = "_spacer_1ult6_297";
|
|
21
|
+
const mobileNavBackdrop = "_mobileNavBackdrop_1ult6_301";
|
|
22
|
+
const mobileNavDrawer = "_mobileNavDrawer_1ult6_309";
|
|
23
|
+
const mobileNavHeader = "_mobileNavHeader_1ult6_323";
|
|
24
|
+
const mobileNavClose = "_mobileNavClose_1ult6_331";
|
|
25
|
+
const mobileNavBody = "_mobileNavBody_1ult6_369";
|
|
26
|
+
const mobileNavLink = "_mobileNavLink_1ult6_375";
|
|
27
|
+
const mobileNavLinkActive = "_mobileNavLinkActive_1ult6_409";
|
|
28
|
+
const skipLink = "_skipLink_1ult6_436";
|
|
22
29
|
const styles = {
|
|
23
30
|
header,
|
|
24
31
|
fixed,
|
|
@@ -40,6 +47,13 @@ const styles = {
|
|
|
40
47
|
actions,
|
|
41
48
|
trigger,
|
|
42
49
|
spacer,
|
|
50
|
+
mobileNavBackdrop,
|
|
51
|
+
mobileNavDrawer,
|
|
52
|
+
mobileNavHeader,
|
|
53
|
+
mobileNavClose,
|
|
54
|
+
mobileNavBody,
|
|
55
|
+
mobileNavLink,
|
|
56
|
+
mobileNavLinkActive,
|
|
43
57
|
skipLink
|
|
44
58
|
};
|
|
45
59
|
export {
|
|
@@ -49,6 +63,13 @@ export {
|
|
|
49
63
|
styles as default,
|
|
50
64
|
fixed,
|
|
51
65
|
header,
|
|
66
|
+
mobileNavBackdrop,
|
|
67
|
+
mobileNavBody,
|
|
68
|
+
mobileNavClose,
|
|
69
|
+
mobileNavDrawer,
|
|
70
|
+
mobileNavHeader,
|
|
71
|
+
mobileNavLink,
|
|
72
|
+
mobileNavLinkActive,
|
|
52
73
|
nav,
|
|
53
74
|
navItem,
|
|
54
75
|
navItemActive,
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
+
const reactDom = require("react-dom");
|
|
5
6
|
const menu = require("@base-ui/react/menu");
|
|
6
7
|
const react = require("@phosphor-icons/react");
|
|
8
|
+
const a11y = require("../../utils/a11y.cjs");
|
|
9
|
+
const index$1 = require("../ScrollArea/index.cjs");
|
|
7
10
|
const Header_module = require("./Header.module.scss.cjs");
|
|
8
11
|
const index = require("../Sidebar/index.cjs");
|
|
9
12
|
function _interopNamespaceDefault(e) {
|
|
@@ -23,6 +26,14 @@ function _interopNamespaceDefault(e) {
|
|
|
23
26
|
return Object.freeze(n);
|
|
24
27
|
}
|
|
25
28
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
29
|
+
const HeaderContext = React__namespace.createContext(null);
|
|
30
|
+
function useHeaderContext() {
|
|
31
|
+
const ctx = React__namespace.useContext(HeaderContext);
|
|
32
|
+
if (!ctx) {
|
|
33
|
+
throw new Error("Header compound components must be used within a Header");
|
|
34
|
+
}
|
|
35
|
+
return ctx;
|
|
36
|
+
}
|
|
26
37
|
const HeaderIconContext = React__namespace.createContext(void 0);
|
|
27
38
|
function useHeaderIcons() {
|
|
28
39
|
return React__namespace.useContext(HeaderIconContext);
|
|
@@ -59,6 +70,7 @@ function HeaderRoot({
|
|
|
59
70
|
style: styleProp,
|
|
60
71
|
...htmlProps
|
|
61
72
|
}) {
|
|
73
|
+
const [mobileOpen, setMobileOpen] = React__namespace.useState(false);
|
|
62
74
|
const classes = [
|
|
63
75
|
Header_module.default.header,
|
|
64
76
|
position === "fixed" && Header_module.default.fixed,
|
|
@@ -69,7 +81,11 @@ function HeaderRoot({
|
|
|
69
81
|
"--header-height": height,
|
|
70
82
|
...styleProp
|
|
71
83
|
};
|
|
72
|
-
|
|
84
|
+
const contextValue = React__namespace.useMemo(
|
|
85
|
+
() => ({ mobileOpen, setMobileOpen, icons }),
|
|
86
|
+
[mobileOpen, icons]
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HeaderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(HeaderIconContext.Provider, { value: icons, children: /* @__PURE__ */ jsxRuntime.jsx("header", { ...htmlProps, className: classes, style, "data-position": position, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: Header_module.default.container, children }) }) }) });
|
|
73
89
|
}
|
|
74
90
|
function HeaderBrand({ children, href, className, ...htmlProps }) {
|
|
75
91
|
const classes = [Header_module.default.brand, className].filter(Boolean).join(" ");
|
|
@@ -146,11 +162,17 @@ function HeaderTrigger({
|
|
|
146
162
|
...htmlProps
|
|
147
163
|
}) {
|
|
148
164
|
const isMobile = useIsMobile();
|
|
149
|
-
const
|
|
165
|
+
const sidebar = index.useSidebar();
|
|
166
|
+
const headerCtx = React__namespace.useContext(HeaderContext);
|
|
150
167
|
const icons = useHeaderIcons();
|
|
151
168
|
if (!isMobile) {
|
|
152
169
|
return null;
|
|
153
170
|
}
|
|
171
|
+
const hasSidebarProvider = sidebar.open !== void 0 && sidebar.setOpen !== void 0 && typeof sidebar.setOpen === "function";
|
|
172
|
+
const isUsingSidebar = hasSidebarProvider && sidebar.isMobile;
|
|
173
|
+
const open = isUsingSidebar ? sidebar.open : (headerCtx == null ? void 0 : headerCtx.mobileOpen) ?? false;
|
|
174
|
+
const setOpen = isUsingSidebar ? sidebar.setOpen : (headerCtx == null ? void 0 : headerCtx.setMobileOpen) ?? (() => {
|
|
175
|
+
});
|
|
154
176
|
const classes = [Header_module.default.trigger, className].filter(Boolean).join(" ");
|
|
155
177
|
const iconSlot = open ? icons == null ? void 0 : icons.close : icons == null ? void 0 : icons.menu;
|
|
156
178
|
const iconState = { slot: open ? "close" : "menu", open };
|
|
@@ -226,6 +248,98 @@ function HeaderNavMenuItem({
|
|
|
226
248
|
}
|
|
227
249
|
return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Item, { ...htmlProps, className: classes, children });
|
|
228
250
|
}
|
|
251
|
+
function HeaderMobileNav({ children, className }) {
|
|
252
|
+
const { mobileOpen, setMobileOpen, icons } = useHeaderContext();
|
|
253
|
+
const drawerRef = React__namespace.useRef(null);
|
|
254
|
+
a11y.useFocusTrap(drawerRef, mobileOpen);
|
|
255
|
+
React__namespace.useEffect(() => {
|
|
256
|
+
if (!mobileOpen) return;
|
|
257
|
+
document.body.style.overflow = "hidden";
|
|
258
|
+
return () => {
|
|
259
|
+
document.body.style.overflow = "";
|
|
260
|
+
};
|
|
261
|
+
}, [mobileOpen]);
|
|
262
|
+
React__namespace.useEffect(() => {
|
|
263
|
+
if (!mobileOpen) return;
|
|
264
|
+
const handleKeyDown = (e) => {
|
|
265
|
+
if (e.key === "Escape") setMobileOpen(false);
|
|
266
|
+
};
|
|
267
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
268
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
269
|
+
}, [mobileOpen, setMobileOpen]);
|
|
270
|
+
if (!mobileOpen) return null;
|
|
271
|
+
if (typeof document === "undefined") return null;
|
|
272
|
+
const closeIcon = renderHeaderIcon(icons == null ? void 0 : icons.mobileClose, {
|
|
273
|
+
slot: "mobileClose",
|
|
274
|
+
open: true
|
|
275
|
+
});
|
|
276
|
+
const drawerContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
277
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
278
|
+
"div",
|
|
279
|
+
{
|
|
280
|
+
className: Header_module.default.mobileNavBackdrop,
|
|
281
|
+
onClick: () => setMobileOpen(false),
|
|
282
|
+
"aria-hidden": true
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
286
|
+
"div",
|
|
287
|
+
{
|
|
288
|
+
ref: drawerRef,
|
|
289
|
+
className: [Header_module.default.mobileNavDrawer, className].filter(Boolean).join(" "),
|
|
290
|
+
role: "dialog",
|
|
291
|
+
"aria-modal": true,
|
|
292
|
+
"aria-label": "Navigation",
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: Header_module.default.mobileNavHeader, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
295
|
+
"button",
|
|
296
|
+
{
|
|
297
|
+
type: "button",
|
|
298
|
+
className: Header_module.default.mobileNavClose,
|
|
299
|
+
onClick: () => setMobileOpen(false),
|
|
300
|
+
"aria-label": "Close navigation",
|
|
301
|
+
children: closeIcon ?? /* @__PURE__ */ jsxRuntime.jsx(react.X, { size: 20, "aria-hidden": true })
|
|
302
|
+
}
|
|
303
|
+
) }),
|
|
304
|
+
/* @__PURE__ */ jsxRuntime.jsx(index$1.ScrollArea, { orientation: "vertical", className: Header_module.default.mobileNavBody, children })
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
)
|
|
308
|
+
] });
|
|
309
|
+
return reactDom.createPortal(drawerContent, document.body);
|
|
310
|
+
}
|
|
311
|
+
function HeaderMobileNavLink({
|
|
312
|
+
children,
|
|
313
|
+
href,
|
|
314
|
+
active = false,
|
|
315
|
+
asChild = false,
|
|
316
|
+
onClick,
|
|
317
|
+
className,
|
|
318
|
+
...htmlProps
|
|
319
|
+
}) {
|
|
320
|
+
const { setMobileOpen } = useHeaderContext();
|
|
321
|
+
const classes = [
|
|
322
|
+
Header_module.default.mobileNavLink,
|
|
323
|
+
active && Header_module.default.mobileNavLinkActive,
|
|
324
|
+
className
|
|
325
|
+
].filter(Boolean).join(" ");
|
|
326
|
+
const handleClick = (e) => {
|
|
327
|
+
onClick == null ? void 0 : onClick(e);
|
|
328
|
+
if (!e.defaultPrevented) setMobileOpen(false);
|
|
329
|
+
};
|
|
330
|
+
if (asChild && React__namespace.isValidElement(children)) {
|
|
331
|
+
const childProps = children.props;
|
|
332
|
+
return React__namespace.cloneElement(children, {
|
|
333
|
+
...htmlProps,
|
|
334
|
+
className: [classes, childProps.className].filter(Boolean).join(" "),
|
|
335
|
+
onClick: composeEventHandlers(childProps.onClick, handleClick)
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
if (href) {
|
|
339
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { ...htmlProps, href, className: classes, onClick: handleClick, children });
|
|
340
|
+
}
|
|
341
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { ...htmlProps, type: "button", className: classes, onClick: handleClick, children });
|
|
342
|
+
}
|
|
229
343
|
function HeaderSkipLink({
|
|
230
344
|
children = "Skip to main content",
|
|
231
345
|
href = "#main-content",
|
|
@@ -244,11 +358,15 @@ const Header = Object.assign(HeaderRoot, {
|
|
|
244
358
|
Actions: HeaderActions,
|
|
245
359
|
Trigger: HeaderTrigger,
|
|
246
360
|
Spacer: HeaderSpacer,
|
|
247
|
-
SkipLink: HeaderSkipLink
|
|
361
|
+
SkipLink: HeaderSkipLink,
|
|
362
|
+
MobileNav: HeaderMobileNav,
|
|
363
|
+
MobileNavLink: HeaderMobileNavLink
|
|
248
364
|
});
|
|
249
365
|
exports.Header = Header;
|
|
250
366
|
exports.HeaderActions = HeaderActions;
|
|
251
367
|
exports.HeaderBrand = HeaderBrand;
|
|
368
|
+
exports.HeaderMobileNav = HeaderMobileNav;
|
|
369
|
+
exports.HeaderMobileNavLink = HeaderMobileNavLink;
|
|
252
370
|
exports.HeaderNav = HeaderNav;
|
|
253
371
|
exports.HeaderNavItem = HeaderNavItem;
|
|
254
372
|
exports.HeaderNavMenu = HeaderNavMenu;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface HeaderIconRenderState {
|
|
3
|
-
slot: 'menu' | 'close' | 'navMenuChevron';
|
|
3
|
+
slot: 'menu' | 'close' | 'navMenuChevron' | 'mobileClose';
|
|
4
4
|
open?: boolean;
|
|
5
5
|
active?: boolean;
|
|
6
6
|
}
|
|
@@ -66,6 +66,12 @@ export interface HeaderNavMenuItemProps extends React.HTMLAttributes<HTMLElement
|
|
|
66
66
|
/** Render as child element (polymorphic) */
|
|
67
67
|
asChild?: boolean;
|
|
68
68
|
}
|
|
69
|
+
export interface HeaderMobileNavProps {
|
|
70
|
+
/** Content rendered inside the mobile drawer */
|
|
71
|
+
children: React.ReactNode;
|
|
72
|
+
/** Optional className for the drawer panel */
|
|
73
|
+
className?: string;
|
|
74
|
+
}
|
|
69
75
|
/**
|
|
70
76
|
* Header - Root header element
|
|
71
77
|
*/
|
|
@@ -91,7 +97,11 @@ declare function HeaderSearch({ children, expandable, className, ...htmlProps }:
|
|
|
91
97
|
*/
|
|
92
98
|
declare function HeaderActions({ children, className, ...htmlProps }: HeaderActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
93
99
|
/**
|
|
94
|
-
* Header.Trigger - Mobile menu trigger
|
|
100
|
+
* Header.Trigger - Mobile menu trigger
|
|
101
|
+
*
|
|
102
|
+
* Works in two modes:
|
|
103
|
+
* 1. With SidebarProvider — toggles sidebar open state (existing behavior)
|
|
104
|
+
* 2. Standalone — toggles Header's internal mobile nav drawer
|
|
95
105
|
*/
|
|
96
106
|
declare function HeaderTrigger({ children, 'aria-label': ariaLabel, className, onClick, ...htmlProps }: HeaderTriggerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
97
107
|
/**
|
|
@@ -108,6 +118,17 @@ declare function HeaderNavMenu({ label, active, className, children, ...htmlProp
|
|
|
108
118
|
* Header.NavMenuItem - Item inside a NavMenu dropdown
|
|
109
119
|
*/
|
|
110
120
|
declare function HeaderNavMenuItem({ children, href, active, asChild, className, ...htmlProps }: HeaderNavMenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
121
|
+
/**
|
|
122
|
+
* Header.MobileNav - Mobile navigation drawer
|
|
123
|
+
*
|
|
124
|
+
* Renders a full-screen slide-in drawer on mobile when the Header.Trigger is toggled.
|
|
125
|
+
* Place navigation links, actions, or any content as children.
|
|
126
|
+
*/
|
|
127
|
+
declare function HeaderMobileNav({ children, className }: HeaderMobileNavProps): React.ReactPortal | null;
|
|
128
|
+
/**
|
|
129
|
+
* Header.MobileNavLink - A link inside the mobile drawer
|
|
130
|
+
*/
|
|
131
|
+
declare function HeaderMobileNavLink({ children, href, active, asChild, onClick, className, ...htmlProps }: HeaderNavItemProps): import("react/jsx-runtime").JSX.Element;
|
|
111
132
|
/**
|
|
112
133
|
* Header.SkipLink - Skip to main content link (accessibility)
|
|
113
134
|
*/
|
|
@@ -127,6 +148,8 @@ export declare const Header: typeof HeaderRoot & {
|
|
|
127
148
|
Trigger: typeof HeaderTrigger;
|
|
128
149
|
Spacer: typeof HeaderSpacer;
|
|
129
150
|
SkipLink: typeof HeaderSkipLink;
|
|
151
|
+
MobileNav: typeof HeaderMobileNav;
|
|
152
|
+
MobileNavLink: typeof HeaderMobileNavLink;
|
|
130
153
|
};
|
|
131
|
-
export { HeaderRoot, HeaderBrand, HeaderNav, HeaderNavItem, HeaderNavMenu, HeaderNavMenuItem, HeaderSearch, HeaderActions, HeaderTrigger, HeaderSpacer, HeaderSkipLink, };
|
|
154
|
+
export { HeaderRoot, HeaderBrand, HeaderNav, HeaderNavItem, HeaderNavMenu, HeaderNavMenuItem, HeaderSearch, HeaderActions, HeaderTrigger, HeaderSpacer, HeaderSkipLink, HeaderMobileNav, HeaderMobileNavLink, };
|
|
132
155
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Header/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Header/index.tsx"],"names":[],"mappings":"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d,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,kBAAkB,2CAgCpB;AAED;;GAEG;AACH,iBAAS,iBAAiB,CAAC,EACzB,QAAQ,EACR,IAAI,EACJ,MAAc,EACd,OAAe,EACf,SAAS,EACT,GAAG,SAAS,EACb,EAAE,sBAAsB,2CA8BxB;AAED;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,oBAAoB,4BA+DrE;AAED;;GAEG;AACH,iBAAS,mBAAmB,CAAC,EAC3B,QAAQ,EACR,IAAI,EACJ,MAAc,EACd,OAAe,EACf,OAAO,EACP,SAAS,EACT,GAAG,SAAS,EACb,EAAE,kBAAkB,2CAuCpB;AAED;;GAEG;AACH,iBAAS,cAAc,CAAC,EACtB,QAAiC,EACjC,IAAsB,EACtB,SAAS,GACV,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAOA;AAMD,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAajB,CAAC;AAEH,OAAO,EACL,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,CAAC"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
3
4
|
import { Menu } from "@base-ui/react/menu";
|
|
4
5
|
import { X, List, CaretDown } from "@phosphor-icons/react";
|
|
6
|
+
import { useFocusTrap } from "../../utils/a11y.js";
|
|
7
|
+
import { ScrollArea } from "../ScrollArea/index.js";
|
|
5
8
|
import styles from "./Header.module.scss.js";
|
|
6
9
|
import { useSidebar } from "../Sidebar/index.js";
|
|
10
|
+
const HeaderContext = React.createContext(null);
|
|
11
|
+
function useHeaderContext() {
|
|
12
|
+
const ctx = React.useContext(HeaderContext);
|
|
13
|
+
if (!ctx) {
|
|
14
|
+
throw new Error("Header compound components must be used within a Header");
|
|
15
|
+
}
|
|
16
|
+
return ctx;
|
|
17
|
+
}
|
|
7
18
|
const HeaderIconContext = React.createContext(void 0);
|
|
8
19
|
function useHeaderIcons() {
|
|
9
20
|
return React.useContext(HeaderIconContext);
|
|
@@ -40,6 +51,7 @@ function HeaderRoot({
|
|
|
40
51
|
style: styleProp,
|
|
41
52
|
...htmlProps
|
|
42
53
|
}) {
|
|
54
|
+
const [mobileOpen, setMobileOpen] = React.useState(false);
|
|
43
55
|
const classes = [
|
|
44
56
|
styles.header,
|
|
45
57
|
position === "fixed" && styles.fixed,
|
|
@@ -50,7 +62,11 @@ function HeaderRoot({
|
|
|
50
62
|
"--header-height": height,
|
|
51
63
|
...styleProp
|
|
52
64
|
};
|
|
53
|
-
|
|
65
|
+
const contextValue = React.useMemo(
|
|
66
|
+
() => ({ mobileOpen, setMobileOpen, icons }),
|
|
67
|
+
[mobileOpen, icons]
|
|
68
|
+
);
|
|
69
|
+
return /* @__PURE__ */ jsx(HeaderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(HeaderIconContext.Provider, { value: icons, children: /* @__PURE__ */ jsx("header", { ...htmlProps, className: classes, style, "data-position": position, children: /* @__PURE__ */ jsx("div", { className: styles.container, children }) }) }) });
|
|
54
70
|
}
|
|
55
71
|
function HeaderBrand({ children, href, className, ...htmlProps }) {
|
|
56
72
|
const classes = [styles.brand, className].filter(Boolean).join(" ");
|
|
@@ -127,11 +143,17 @@ function HeaderTrigger({
|
|
|
127
143
|
...htmlProps
|
|
128
144
|
}) {
|
|
129
145
|
const isMobile = useIsMobile();
|
|
130
|
-
const
|
|
146
|
+
const sidebar = useSidebar();
|
|
147
|
+
const headerCtx = React.useContext(HeaderContext);
|
|
131
148
|
const icons = useHeaderIcons();
|
|
132
149
|
if (!isMobile) {
|
|
133
150
|
return null;
|
|
134
151
|
}
|
|
152
|
+
const hasSidebarProvider = sidebar.open !== void 0 && sidebar.setOpen !== void 0 && typeof sidebar.setOpen === "function";
|
|
153
|
+
const isUsingSidebar = hasSidebarProvider && sidebar.isMobile;
|
|
154
|
+
const open = isUsingSidebar ? sidebar.open : (headerCtx == null ? void 0 : headerCtx.mobileOpen) ?? false;
|
|
155
|
+
const setOpen = isUsingSidebar ? sidebar.setOpen : (headerCtx == null ? void 0 : headerCtx.setMobileOpen) ?? (() => {
|
|
156
|
+
});
|
|
135
157
|
const classes = [styles.trigger, className].filter(Boolean).join(" ");
|
|
136
158
|
const iconSlot = open ? icons == null ? void 0 : icons.close : icons == null ? void 0 : icons.menu;
|
|
137
159
|
const iconState = { slot: open ? "close" : "menu", open };
|
|
@@ -207,6 +229,98 @@ function HeaderNavMenuItem({
|
|
|
207
229
|
}
|
|
208
230
|
return /* @__PURE__ */ jsx(Menu.Item, { ...htmlProps, className: classes, children });
|
|
209
231
|
}
|
|
232
|
+
function HeaderMobileNav({ children, className }) {
|
|
233
|
+
const { mobileOpen, setMobileOpen, icons } = useHeaderContext();
|
|
234
|
+
const drawerRef = React.useRef(null);
|
|
235
|
+
useFocusTrap(drawerRef, mobileOpen);
|
|
236
|
+
React.useEffect(() => {
|
|
237
|
+
if (!mobileOpen) return;
|
|
238
|
+
document.body.style.overflow = "hidden";
|
|
239
|
+
return () => {
|
|
240
|
+
document.body.style.overflow = "";
|
|
241
|
+
};
|
|
242
|
+
}, [mobileOpen]);
|
|
243
|
+
React.useEffect(() => {
|
|
244
|
+
if (!mobileOpen) return;
|
|
245
|
+
const handleKeyDown = (e) => {
|
|
246
|
+
if (e.key === "Escape") setMobileOpen(false);
|
|
247
|
+
};
|
|
248
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
249
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
250
|
+
}, [mobileOpen, setMobileOpen]);
|
|
251
|
+
if (!mobileOpen) return null;
|
|
252
|
+
if (typeof document === "undefined") return null;
|
|
253
|
+
const closeIcon = renderHeaderIcon(icons == null ? void 0 : icons.mobileClose, {
|
|
254
|
+
slot: "mobileClose",
|
|
255
|
+
open: true
|
|
256
|
+
});
|
|
257
|
+
const drawerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
258
|
+
/* @__PURE__ */ jsx(
|
|
259
|
+
"div",
|
|
260
|
+
{
|
|
261
|
+
className: styles.mobileNavBackdrop,
|
|
262
|
+
onClick: () => setMobileOpen(false),
|
|
263
|
+
"aria-hidden": true
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
/* @__PURE__ */ jsxs(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
ref: drawerRef,
|
|
270
|
+
className: [styles.mobileNavDrawer, className].filter(Boolean).join(" "),
|
|
271
|
+
role: "dialog",
|
|
272
|
+
"aria-modal": true,
|
|
273
|
+
"aria-label": "Navigation",
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx("div", { className: styles.mobileNavHeader, children: /* @__PURE__ */ jsx(
|
|
276
|
+
"button",
|
|
277
|
+
{
|
|
278
|
+
type: "button",
|
|
279
|
+
className: styles.mobileNavClose,
|
|
280
|
+
onClick: () => setMobileOpen(false),
|
|
281
|
+
"aria-label": "Close navigation",
|
|
282
|
+
children: closeIcon ?? /* @__PURE__ */ jsx(X, { size: 20, "aria-hidden": true })
|
|
283
|
+
}
|
|
284
|
+
) }),
|
|
285
|
+
/* @__PURE__ */ jsx(ScrollArea, { orientation: "vertical", className: styles.mobileNavBody, children })
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
] });
|
|
290
|
+
return createPortal(drawerContent, document.body);
|
|
291
|
+
}
|
|
292
|
+
function HeaderMobileNavLink({
|
|
293
|
+
children,
|
|
294
|
+
href,
|
|
295
|
+
active = false,
|
|
296
|
+
asChild = false,
|
|
297
|
+
onClick,
|
|
298
|
+
className,
|
|
299
|
+
...htmlProps
|
|
300
|
+
}) {
|
|
301
|
+
const { setMobileOpen } = useHeaderContext();
|
|
302
|
+
const classes = [
|
|
303
|
+
styles.mobileNavLink,
|
|
304
|
+
active && styles.mobileNavLinkActive,
|
|
305
|
+
className
|
|
306
|
+
].filter(Boolean).join(" ");
|
|
307
|
+
const handleClick = (e) => {
|
|
308
|
+
onClick == null ? void 0 : onClick(e);
|
|
309
|
+
if (!e.defaultPrevented) setMobileOpen(false);
|
|
310
|
+
};
|
|
311
|
+
if (asChild && React.isValidElement(children)) {
|
|
312
|
+
const childProps = children.props;
|
|
313
|
+
return React.cloneElement(children, {
|
|
314
|
+
...htmlProps,
|
|
315
|
+
className: [classes, childProps.className].filter(Boolean).join(" "),
|
|
316
|
+
onClick: composeEventHandlers(childProps.onClick, handleClick)
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
if (href) {
|
|
320
|
+
return /* @__PURE__ */ jsx("a", { ...htmlProps, href, className: classes, onClick: handleClick, children });
|
|
321
|
+
}
|
|
322
|
+
return /* @__PURE__ */ jsx("button", { ...htmlProps, type: "button", className: classes, onClick: handleClick, children });
|
|
323
|
+
}
|
|
210
324
|
function HeaderSkipLink({
|
|
211
325
|
children = "Skip to main content",
|
|
212
326
|
href = "#main-content",
|
|
@@ -225,12 +339,16 @@ const Header = Object.assign(HeaderRoot, {
|
|
|
225
339
|
Actions: HeaderActions,
|
|
226
340
|
Trigger: HeaderTrigger,
|
|
227
341
|
Spacer: HeaderSpacer,
|
|
228
|
-
SkipLink: HeaderSkipLink
|
|
342
|
+
SkipLink: HeaderSkipLink,
|
|
343
|
+
MobileNav: HeaderMobileNav,
|
|
344
|
+
MobileNavLink: HeaderMobileNavLink
|
|
229
345
|
});
|
|
230
346
|
export {
|
|
231
347
|
Header,
|
|
232
348
|
HeaderActions,
|
|
233
349
|
HeaderBrand,
|
|
350
|
+
HeaderMobileNav,
|
|
351
|
+
HeaderMobileNavLink,
|
|
234
352
|
HeaderNav,
|
|
235
353
|
HeaderNavItem,
|
|
236
354
|
HeaderNavMenu,
|