@sereno-ds/ui 0.41.3 → 0.42.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/README.md +20 -1
- package/dist/core/Button.d.ts +1 -1
- package/dist/core/Button.js +15 -19
- package/dist/core/Button.js.map +1 -1
- package/dist/core/Card.d.ts +1 -1
- package/dist/core/Card.js +14 -11
- package/dist/core/Card.js.map +1 -1
- package/dist/core/IconButton.d.ts +1 -1
- package/dist/core/IconButton.js +13 -18
- package/dist/core/IconButton.js.map +1 -1
- package/dist/forms/AvatarUpload.js +3 -258
- package/dist/forms/AvatarUpload.js.map +1 -1
- package/dist/forms/_internal/AvatarCaptureDialog.d.ts +28 -0
- package/dist/forms/_internal/AvatarCaptureDialog.js +127 -0
- package/dist/forms/_internal/AvatarCaptureDialog.js.map +1 -0
- package/dist/forms/_internal/useCamera.d.ts +12 -0
- package/dist/forms/_internal/useCamera.js +58 -0
- package/dist/forms/_internal/useCamera.js.map +1 -0
- package/dist/forms/_internal/useCropper.d.ts +27 -0
- package/dist/forms/_internal/useCropper.js +92 -0
- package/dist/forms/_internal/useCropper.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/navigation/SidebarNav.d.ts +3 -43
- package/dist/navigation/SidebarNav.js +4 -415
- package/dist/navigation/SidebarNav.js.map +1 -1
- package/dist/navigation/_internal/SidebarNavItems.d.ts +46 -0
- package/dist/navigation/_internal/SidebarNavItems.js +299 -0
- package/dist/navigation/_internal/SidebarNavItems.js.map +1 -0
- package/dist/navigation/_internal/SidebarSubmenuPopover.d.ts +13 -0
- package/dist/navigation/_internal/SidebarSubmenuPopover.js +129 -0
- package/dist/navigation/_internal/SidebarSubmenuPopover.js.map +1 -0
- package/dist/navigation/_internal/sidebarNavContext.d.ts +24 -0
- package/dist/navigation/_internal/sidebarNavContext.js +14 -0
- package/dist/navigation/_internal/sidebarNavContext.js.map +1 -0
- package/dist/styles.css +54 -1
- package/package.json +1 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { sx } from "../../_internal/style.js";
|
|
6
|
+
import { useInteract } from "../../core/Button.js";
|
|
7
|
+
import { ParentDisabledContext, useSidebarNavContext } from "./sidebarNavContext.js";
|
|
8
|
+
import { SubmenuPopover } from "./SidebarSubmenuPopover.js";
|
|
9
|
+
const groupHead = sx({
|
|
10
|
+
fontFamily: "var(--font-body)",
|
|
11
|
+
fontSize: "var(--text-2xs)",
|
|
12
|
+
fontWeight: "var(--weight-bold)",
|
|
13
|
+
letterSpacing: "0.09em",
|
|
14
|
+
textTransform: "uppercase",
|
|
15
|
+
color: "var(--text-disabled)",
|
|
16
|
+
// No top padding: the section's own top gap is the section break; this hugs its items.
|
|
17
|
+
padding: "0 var(--space-3) var(--space-2)"
|
|
18
|
+
});
|
|
19
|
+
const countPill = (active, disabled = false) => sx({
|
|
20
|
+
marginLeft: "auto",
|
|
21
|
+
flex: "0 0 auto",
|
|
22
|
+
fontSize: "var(--text-2xs)",
|
|
23
|
+
fontWeight: "var(--weight-bold)",
|
|
24
|
+
lineHeight: 1,
|
|
25
|
+
padding: "2px 6px",
|
|
26
|
+
borderRadius: "999px",
|
|
27
|
+
// A bordered chip so it stays legible over the row's hover / active fill.
|
|
28
|
+
background: "var(--bg-surface)",
|
|
29
|
+
color: disabled ? "var(--text-disabled)" : active ? "var(--text-brand)" : "var(--text-muted)",
|
|
30
|
+
boxShadow: "inset 0 0 0 1px " + (disabled ? "var(--border-subtle)" : active ? "var(--border-brand)" : "var(--border-default)")
|
|
31
|
+
});
|
|
32
|
+
function childValuesOf(children) {
|
|
33
|
+
const out = [];
|
|
34
|
+
React.Children.forEach(children, (child) => {
|
|
35
|
+
if (React.isValidElement(child) && typeof child.props.value === "string") out.push(child.props.value);
|
|
36
|
+
});
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function showLabelTip(row, labelEl, label, showTip) {
|
|
40
|
+
if (labelEl && labelEl.scrollWidth <= labelEl.clientWidth) return;
|
|
41
|
+
showTip(label, row.getBoundingClientRect());
|
|
42
|
+
}
|
|
43
|
+
function isKeyboardFocus(el) {
|
|
44
|
+
try {
|
|
45
|
+
return el.matches(":focus-visible");
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function Section({ label, children }) {
|
|
51
|
+
const { collapsed } = useSidebarNavContext("Section");
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", { className: "sereno-sidenav-section", style: sx({ display: "flex", flexDirection: "column", gap: 2 }), children: [
|
|
53
|
+
label && !collapsed && /* @__PURE__ */ jsx("span", { style: groupHead, children: label }),
|
|
54
|
+
children
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
function Item({ value, label, icon, count, href, disabled: disabledProp, children }) {
|
|
58
|
+
const {
|
|
59
|
+
value: activeValue,
|
|
60
|
+
disabled: rootDisabled,
|
|
61
|
+
select,
|
|
62
|
+
collapsed,
|
|
63
|
+
linkComponent,
|
|
64
|
+
flyoutValue,
|
|
65
|
+
openFlyout,
|
|
66
|
+
closeFlyoutSoon,
|
|
67
|
+
closeFlyoutNow,
|
|
68
|
+
showTip,
|
|
69
|
+
hideTip
|
|
70
|
+
} = useSidebarNavContext("Item");
|
|
71
|
+
const disabled = disabledProp ?? rootDisabled;
|
|
72
|
+
const st = useInteract(disabled);
|
|
73
|
+
const btnRef = React.useRef(null);
|
|
74
|
+
const labelRef = React.useRef(null);
|
|
75
|
+
const hasChildren = React.Children.count(children) > 0;
|
|
76
|
+
const childVals = hasChildren ? childValuesOf(children) : [];
|
|
77
|
+
const selfActive = activeValue === value && !hasChildren;
|
|
78
|
+
const childActive = hasChildren && childVals.includes(activeValue ?? "");
|
|
79
|
+
const highlight = selfActive || collapsed && childActive;
|
|
80
|
+
const railFlyout = collapsed && hasChildren && !disabled;
|
|
81
|
+
const asLink = !hasChildren && !!href && !!linkComponent && !disabled;
|
|
82
|
+
const Link = linkComponent ?? "a";
|
|
83
|
+
const [localOpen, setLocalOpen] = React.useState(() => childActive);
|
|
84
|
+
const open = collapsed ? !disabled && flyoutValue === value : localOpen;
|
|
85
|
+
const onToggle = () => {
|
|
86
|
+
if (collapsed) {
|
|
87
|
+
if (flyoutValue === value) closeFlyoutNow();
|
|
88
|
+
else openFlyout(value);
|
|
89
|
+
} else {
|
|
90
|
+
setLocalOpen((o) => !o);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const rowStyle = sx({
|
|
94
|
+
position: "relative",
|
|
95
|
+
display: "flex",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
gap: "var(--space-3)",
|
|
98
|
+
width: "100%",
|
|
99
|
+
height: 40,
|
|
100
|
+
padding: collapsed ? 0 : "0 var(--space-3)",
|
|
101
|
+
justifyContent: collapsed ? "center" : "flex-start",
|
|
102
|
+
border: "none",
|
|
103
|
+
borderRadius: "var(--radius-control)",
|
|
104
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
105
|
+
textAlign: "left",
|
|
106
|
+
textDecoration: "none",
|
|
107
|
+
fontFamily: "var(--font-body)",
|
|
108
|
+
fontSize: "var(--text-base)",
|
|
109
|
+
fontWeight: highlight || childActive ? "var(--weight-semibold)" : "var(--weight-medium)",
|
|
110
|
+
background: highlight ? "var(--bg-brand-soft)" : open || st.hover ? "var(--interactive-ghost-hover)" : "transparent",
|
|
111
|
+
color: disabled ? "var(--text-disabled)" : highlight || childActive ? "var(--text-brand)" : "var(--text-secondary)",
|
|
112
|
+
transition: "var(--transition-control)"
|
|
113
|
+
});
|
|
114
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
115
|
+
icon && /* @__PURE__ */ jsx("span", { style: sx({ flex: "0 0 auto", display: "inline-flex", width: 20, height: 20, alignItems: "center", justifyContent: "center" }), children: icon }),
|
|
116
|
+
collapsed && !disabled && (count !== void 0 || childActive) && /* @__PURE__ */ jsx(
|
|
117
|
+
"span",
|
|
118
|
+
{
|
|
119
|
+
"aria-hidden": true,
|
|
120
|
+
style: sx({
|
|
121
|
+
position: "absolute",
|
|
122
|
+
top: 7,
|
|
123
|
+
right: 12,
|
|
124
|
+
width: 6,
|
|
125
|
+
height: 6,
|
|
126
|
+
borderRadius: "999px",
|
|
127
|
+
background: "var(--interactive-accent)"
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
!collapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
132
|
+
/* @__PURE__ */ jsx("span", { ref: labelRef, style: sx({ flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }), children: label }),
|
|
133
|
+
count !== void 0 && /* @__PURE__ */ jsx("span", { style: countPill(highlight, disabled), children: count }),
|
|
134
|
+
hasChildren && /* @__PURE__ */ jsx(
|
|
135
|
+
ChevronDown,
|
|
136
|
+
{
|
|
137
|
+
size: 16,
|
|
138
|
+
strokeWidth: 2,
|
|
139
|
+
style: { flex: "0 0 auto", transition: "transform var(--duration-fast) var(--ease-standard)", transform: open ? "rotate(180deg)" : "none" }
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] })
|
|
143
|
+
] });
|
|
144
|
+
const hoverHandlers = {
|
|
145
|
+
...st.handlers,
|
|
146
|
+
onMouseEnter: (e) => {
|
|
147
|
+
st.handlers.onMouseEnter?.(e);
|
|
148
|
+
if (railFlyout) openFlyout(value);
|
|
149
|
+
else showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
150
|
+
},
|
|
151
|
+
onMouseLeave: (e) => {
|
|
152
|
+
st.handlers.onMouseLeave?.(e);
|
|
153
|
+
if (railFlyout) closeFlyoutSoon();
|
|
154
|
+
else hideTip();
|
|
155
|
+
},
|
|
156
|
+
// Keyboard parity with hover - on the rail a Tab stop is otherwise just an unlabelled icon.
|
|
157
|
+
onFocus: (e) => {
|
|
158
|
+
st.handlers.onFocus?.(e);
|
|
159
|
+
if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
160
|
+
},
|
|
161
|
+
onBlur: (e) => {
|
|
162
|
+
st.handlers.onBlur?.(e);
|
|
163
|
+
hideTip();
|
|
164
|
+
},
|
|
165
|
+
// Dismissible without moving the pointer or focus (WCAG 1.4.13).
|
|
166
|
+
onKeyDown: (e) => {
|
|
167
|
+
if (e.key === "Escape") hideTip();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const compactChildren = React.Children.map(
|
|
171
|
+
children,
|
|
172
|
+
(child) => React.isValidElement(child) ? React.cloneElement(child, { compact: true }) : child
|
|
173
|
+
);
|
|
174
|
+
return /* @__PURE__ */ jsxs("div", { style: sx({ display: "flex", flexDirection: "column" }), children: [
|
|
175
|
+
asLink ? /* @__PURE__ */ jsx(
|
|
176
|
+
Link,
|
|
177
|
+
{
|
|
178
|
+
href,
|
|
179
|
+
className: "sereno-sidenav-btn",
|
|
180
|
+
"aria-label": collapsed ? label : void 0,
|
|
181
|
+
"aria-current": selfActive ? "page" : void 0,
|
|
182
|
+
onClick: () => {
|
|
183
|
+
hideTip();
|
|
184
|
+
select(value);
|
|
185
|
+
},
|
|
186
|
+
...hoverHandlers,
|
|
187
|
+
style: rowStyle,
|
|
188
|
+
children: inner
|
|
189
|
+
}
|
|
190
|
+
) : /* @__PURE__ */ jsx(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
ref: btnRef,
|
|
194
|
+
type: "button",
|
|
195
|
+
className: "sereno-sidenav-btn",
|
|
196
|
+
"aria-label": collapsed ? label : void 0,
|
|
197
|
+
"aria-current": selfActive ? "page" : void 0,
|
|
198
|
+
"aria-disabled": disabled || void 0,
|
|
199
|
+
tabIndex: disabled ? -1 : void 0,
|
|
200
|
+
"aria-haspopup": hasChildren ? "menu" : void 0,
|
|
201
|
+
"aria-expanded": hasChildren ? open : void 0,
|
|
202
|
+
onClick: () => {
|
|
203
|
+
if (disabled) return;
|
|
204
|
+
hideTip();
|
|
205
|
+
if (hasChildren) onToggle();
|
|
206
|
+
else select(value);
|
|
207
|
+
},
|
|
208
|
+
...hoverHandlers,
|
|
209
|
+
style: rowStyle,
|
|
210
|
+
children: inner
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
hasChildren && !collapsed && open && /* @__PURE__ */ jsx(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
style: sx({
|
|
217
|
+
display: "flex",
|
|
218
|
+
flexDirection: "column",
|
|
219
|
+
gap: 2,
|
|
220
|
+
margin: "2px 0 2px 19px",
|
|
221
|
+
paddingLeft: "var(--space-3)",
|
|
222
|
+
borderLeft: "var(--border-width-hairline) solid var(--border-default)"
|
|
223
|
+
}),
|
|
224
|
+
children: /* @__PURE__ */ jsx(ParentDisabledContext.Provider, { value: disabled, children })
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
railFlyout && open && /* @__PURE__ */ jsx(SubmenuPopover, { anchorRef: btnRef, label, icon, onClose: closeFlyoutNow, onMouseEnter: () => openFlyout(value), onMouseLeave: closeFlyoutSoon, children: /* @__PURE__ */ jsx(ParentDisabledContext.Provider, { value: disabled, children: compactChildren }) })
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
function SubItem({ value, label, count, disabled: disabledProp, compact = false }) {
|
|
231
|
+
const { value: activeValue, disabled: rootDisabled, select, showTip, hideTip } = useSidebarNavContext("SubItem");
|
|
232
|
+
const parentDisabled = React.useContext(ParentDisabledContext);
|
|
233
|
+
const labelRef = React.useRef(null);
|
|
234
|
+
const disabled = disabledProp ?? parentDisabled ?? rootDisabled;
|
|
235
|
+
const active = activeValue === value;
|
|
236
|
+
const st = useInteract(disabled);
|
|
237
|
+
return /* @__PURE__ */ jsxs(
|
|
238
|
+
"button",
|
|
239
|
+
{
|
|
240
|
+
type: "button",
|
|
241
|
+
className: "sereno-sidenav-btn",
|
|
242
|
+
"aria-current": active ? "page" : void 0,
|
|
243
|
+
"aria-disabled": disabled || void 0,
|
|
244
|
+
tabIndex: disabled ? -1 : void 0,
|
|
245
|
+
onClick: () => {
|
|
246
|
+
hideTip();
|
|
247
|
+
if (!disabled) select(value);
|
|
248
|
+
},
|
|
249
|
+
...st.handlers,
|
|
250
|
+
onMouseEnter: (e) => {
|
|
251
|
+
st.handlers.onMouseEnter?.(e);
|
|
252
|
+
showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
253
|
+
},
|
|
254
|
+
onMouseLeave: (e) => {
|
|
255
|
+
st.handlers.onMouseLeave?.(e);
|
|
256
|
+
hideTip();
|
|
257
|
+
},
|
|
258
|
+
onFocus: (e) => {
|
|
259
|
+
st.handlers.onFocus?.(e);
|
|
260
|
+
if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
261
|
+
},
|
|
262
|
+
onBlur: (e) => {
|
|
263
|
+
st.handlers.onBlur?.(e);
|
|
264
|
+
hideTip();
|
|
265
|
+
},
|
|
266
|
+
onKeyDown: (e) => {
|
|
267
|
+
if (e.key === "Escape") hideTip();
|
|
268
|
+
},
|
|
269
|
+
style: sx({
|
|
270
|
+
display: "flex",
|
|
271
|
+
alignItems: "center",
|
|
272
|
+
gap: "var(--space-2)",
|
|
273
|
+
width: "100%",
|
|
274
|
+
height: compact ? 32 : 34,
|
|
275
|
+
padding: "0 var(--space-2)",
|
|
276
|
+
border: "none",
|
|
277
|
+
borderRadius: "var(--radius-sm)",
|
|
278
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
279
|
+
textAlign: "left",
|
|
280
|
+
fontFamily: "var(--font-body)",
|
|
281
|
+
fontSize: "var(--text-sm)",
|
|
282
|
+
fontWeight: active ? "var(--weight-semibold)" : "var(--weight-medium)",
|
|
283
|
+
background: active ? "var(--bg-brand-soft)" : st.hover ? "var(--interactive-ghost-hover)" : "transparent",
|
|
284
|
+
color: disabled ? "var(--text-disabled)" : active ? "var(--text-brand)" : "var(--text-secondary)",
|
|
285
|
+
transition: "var(--transition-control)"
|
|
286
|
+
}),
|
|
287
|
+
children: [
|
|
288
|
+
/* @__PURE__ */ jsx("span", { ref: labelRef, style: sx({ flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }), children: label }),
|
|
289
|
+
count !== void 0 && /* @__PURE__ */ jsx("span", { style: countPill(active, disabled), children: count })
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
export {
|
|
295
|
+
Item,
|
|
296
|
+
Section,
|
|
297
|
+
SubItem
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=SidebarNavItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/navigation/_internal/SidebarNavItems.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown } from 'lucide-react';\nimport { sx } from '../../_internal/style';\nimport { useInteract } from '../../core/Button';\nimport { ParentDisabledContext, type SidebarNavContextValue, useSidebarNavContext } from './sidebarNavContext';\nimport { SubmenuPopover } from './SidebarSubmenuPopover';\n\nexport interface SidebarNavSectionProps {\n /** Small uppercase heading above the block. Omit for an unlabelled group - the divider still shows. */\n label?: string;\n children: React.ReactNode;\n}\n\nexport interface SidebarNavItemProps {\n value: string;\n label: string;\n /** A Lucide icon passed as a node - sized by the caller. */\n icon?: React.ReactNode;\n count?: number;\n /** Render this leaf as a real link (routing, new-tab, SSR-active) via `linkComponent`. Ignored while `disabled`. */\n href?: string;\n /**\n * Not selectable - e.g. a feature locked behind a higher plan. Inherits the\n * root's `disabled` when unset; an explicit `false` opts back in under a\n * disabled root.\n *\n * `aria-disabled` (not the native attribute), so the row is still in the\n * accessibility tree and a screen reader finds it - but it leaves the Tab\n * order (a locked area shouldn't cost a dead tab stop per item), a click\n * never fires `onChange`, `href` never navigates (it renders as a `<button>`,\n * never a link), and a parent `Item` doesn't toggle its accordion or open its\n * rail flyout. It can still be the current page: `value` pointing at it keeps\n * `aria-current` and the active look, just muted.\n */\n disabled?: boolean;\n /** `SidebarNav.SubItem`s - a second level. Present ⇒ this item is not a destination itself, it toggles them. */\n children?: React.ReactNode;\n}\n\nexport interface SidebarNavSubItemProps {\n value: string;\n label: string;\n count?: number;\n /** Not selectable. Inherits from its parent `Item` (which inherits the root); an explicit value wins. Same contract as `SidebarNav.Item`'s `disabled`. */\n disabled?: boolean;\n /** Set by the parent `Item` when rendering this into the collapsed rail's flyout popover - not for consumers to pass. */\n compact?: boolean;\n}\n\nconst groupHead = sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: '0.09em',\n textTransform: 'uppercase',\n color: 'var(--text-disabled)',\n // No top padding: the section's own top gap is the section break; this hugs its items.\n padding: '0 var(--space-3) var(--space-2)',\n});\n\nconst countPill = (active: boolean, disabled = false) =>\n sx({\n marginLeft: 'auto',\n flex: '0 0 auto',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-bold)',\n lineHeight: 1,\n padding: '2px 6px',\n borderRadius: '999px',\n // A bordered chip so it stays legible over the row's hover / active fill.\n background: 'var(--bg-surface)',\n color: disabled ? 'var(--text-disabled)' : active ? 'var(--text-brand)' : 'var(--text-muted)',\n boxShadow: 'inset 0 0 0 1px ' + (disabled ? 'var(--border-subtle)' : active ? 'var(--border-brand)' : 'var(--border-default)'),\n });\n\n/** The `value`s of a node's `SidebarNav.SubItem` children - used for \"does this branch hold the active leaf\". */\nfunction childValuesOf(children: React.ReactNode): string[] {\n const out: string[] = [];\n React.Children.forEach(children, (child) => {\n if (React.isValidElement<{ value?: unknown }>(child) && typeof child.props.value === 'string') out.push(child.props.value);\n });\n return out;\n}\n\n/**\n * Shows `label` as a tooltip beside `row`. On the icon-only rail every label is\n * hidden (`labelEl` is null), so it always shows; expanded, only when the\n * ellipsis is actually cutting the text off - a short label gets no redundant tooltip.\n */\nfunction showLabelTip(row: HTMLElement, labelEl: HTMLElement | null, label: string, showTip: SidebarNavContextValue['showTip']) {\n if (labelEl && labelEl.scrollWidth <= labelEl.clientWidth) return;\n showTip(label, row.getBoundingClientRect());\n}\n\n/** Keyboard focus only - a mouse click focuses the row too, but the pointer is already showing (or has dismissed) the tip. */\nfunction isKeyboardFocus(el: HTMLElement): boolean {\n try {\n return el.matches(':focus-visible');\n } catch {\n return false;\n }\n}\n\nexport function Section({ label, children }: SidebarNavSectionProps) {\n const { collapsed } = useSidebarNavContext('Section');\n return (\n <div className=\"sereno-sidenav-section\" style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && !collapsed && <span style={groupHead}>{label}</span>}\n {children}\n </div>\n );\n}\n\nexport function Item({ value, label, icon, count, href, disabled: disabledProp, children }: SidebarNavItemProps) {\n const {\n value: activeValue,\n disabled: rootDisabled,\n select,\n collapsed,\n linkComponent,\n flyoutValue,\n openFlyout,\n closeFlyoutSoon,\n closeFlyoutNow,\n showTip,\n hideTip,\n } = useSidebarNavContext('Item');\n // Its own `disabled` wins - including an explicit `false` under a disabled root.\n const disabled = disabledProp ?? rootDisabled;\n const st = useInteract(disabled);\n const btnRef = React.useRef<HTMLButtonElement>(null);\n const labelRef = React.useRef<HTMLSpanElement>(null);\n const hasChildren = React.Children.count(children) > 0;\n const childVals = hasChildren ? childValuesOf(children) : [];\n // Still the current page while disabled (a locked area can be showing you where you are) - just muted.\n const selfActive = activeValue === value && !hasChildren;\n const childActive = hasChildren && childVals.includes(activeValue ?? '');\n const highlight = selfActive || (collapsed && childActive);\n // A disabled parent has nothing to open: no rail flyout (it falls back to the plain label tooltip).\n const railFlyout = collapsed && hasChildren && !disabled;\n // A disabled item is never a real link - `href` must not navigate.\n const asLink = !hasChildren && !!href && !!linkComponent && !disabled;\n const Link = linkComponent ?? 'a';\n\n // Expanded: an inline accordion, local per-item and seeded open once (on\n // mount) for the branch holding the active child - that seed still applies\n // while disabled, so the \"you are here\" branch stays visible (it just can't\n // be toggled). Collapsed: a hover flyout instead - that one is cross-item\n // (only one open at a time), so it lives in the root's flyoutValue, not\n // here, and a disabled parent never opens it.\n const [localOpen, setLocalOpen] = React.useState(() => childActive);\n const open = collapsed ? !disabled && flyoutValue === value : localOpen;\n\n const onToggle = () => {\n if (collapsed) {\n if (flyoutValue === value) closeFlyoutNow();\n else openFlyout(value);\n } else {\n setLocalOpen((o) => !o);\n }\n };\n\n const rowStyle = sx({\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n width: '100%',\n height: 40,\n padding: collapsed ? 0 : '0 var(--space-3)',\n justifyContent: collapsed ? 'center' : 'flex-start',\n border: 'none',\n borderRadius: 'var(--radius-control)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n textAlign: 'left',\n textDecoration: 'none',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: highlight || childActive ? 'var(--weight-semibold)' : 'var(--weight-medium)',\n background: highlight ? 'var(--bg-brand-soft)' : open || st.hover ? 'var(--interactive-ghost-hover)' : 'transparent',\n color: disabled ? 'var(--text-disabled)' : highlight || childActive ? 'var(--text-brand)' : 'var(--text-secondary)',\n transition: 'var(--transition-control)',\n });\n\n const inner = (\n <>\n {icon && (\n <span style={sx({ flex: '0 0 auto', display: 'inline-flex', width: 20, height: 20, alignItems: 'center', justifyContent: 'center' })}>{icon}</span>\n )}\n {collapsed && !disabled && (count !== undefined || childActive) && (\n <span\n aria-hidden\n style={sx({\n position: 'absolute',\n top: 7,\n right: 12,\n width: 6,\n height: 6,\n borderRadius: '999px',\n background: 'var(--interactive-accent)',\n })}\n />\n )}\n {!collapsed && (\n <>\n <span ref={labelRef} style={sx({ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>\n {label}\n </span>\n {count !== undefined && <span style={countPill(highlight, disabled)}>{count}</span>}\n {hasChildren && (\n <ChevronDown\n size={16}\n strokeWidth={2}\n style={{ flex: '0 0 auto', transition: 'transform var(--duration-fast) var(--ease-standard)', transform: open ? 'rotate(180deg)' : 'none' }}\n />\n )}\n </>\n )}\n </>\n );\n\n const hoverHandlers = {\n ...st.handlers,\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n st.handlers.onMouseEnter?.(e);\n if (railFlyout) openFlyout(value);\n else showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n st.handlers.onMouseLeave?.(e);\n if (railFlyout) closeFlyoutSoon();\n else hideTip();\n },\n // Keyboard parity with hover - on the rail a Tab stop is otherwise just an unlabelled icon.\n onFocus: (e: React.FocusEvent<HTMLElement>) => {\n st.handlers.onFocus?.(e);\n if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n },\n onBlur: (e: React.FocusEvent<HTMLElement>) => {\n st.handlers.onBlur?.(e);\n hideTip();\n },\n // Dismissible without moving the pointer or focus (WCAG 1.4.13).\n onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Escape') hideTip();\n },\n };\n\n // The flyout popover reuses the same SubItem elements, just 2px shorter to\n // read as a compact menu rather than the accordion's own row height.\n const compactChildren = React.Children.map(children, (child) =>\n React.isValidElement<SidebarNavSubItemProps>(child) ? React.cloneElement(child, { compact: true }) : child,\n );\n\n return (\n <div style={sx({ display: 'flex', flexDirection: 'column' })}>\n {asLink ? (\n <Link\n href={href}\n className=\"sereno-sidenav-btn\"\n aria-label={collapsed ? label : undefined}\n aria-current={selfActive ? 'page' : undefined}\n onClick={() => {\n hideTip();\n select(value);\n }}\n {...hoverHandlers}\n style={rowStyle}\n >\n {inner}\n </Link>\n ) : (\n <button\n ref={btnRef}\n type=\"button\"\n className=\"sereno-sidenav-btn\"\n aria-label={collapsed ? label : undefined}\n aria-current={selfActive ? 'page' : undefined}\n aria-disabled={disabled || undefined}\n tabIndex={disabled ? -1 : undefined}\n aria-haspopup={hasChildren ? 'menu' : undefined}\n aria-expanded={hasChildren ? open : undefined}\n onClick={() => {\n if (disabled) return;\n hideTip();\n if (hasChildren) onToggle();\n else select(value);\n }}\n {...hoverHandlers}\n style={rowStyle}\n >\n {inner}\n </button>\n )}\n\n {/* Expanded: inline accordion. */}\n {hasChildren && !collapsed && open && (\n <div\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n margin: '2px 0 2px 19px',\n paddingLeft: 'var(--space-3)',\n borderLeft: 'var(--border-width-hairline) solid var(--border-default)',\n })}\n >\n <ParentDisabledContext.Provider value={disabled}>{children}</ParentDisabledContext.Provider>\n </div>\n )}\n\n {/* Collapsed rail: hover flyout. */}\n {railFlyout && open && (\n <SubmenuPopover anchorRef={btnRef} label={label} icon={icon} onClose={closeFlyoutNow} onMouseEnter={() => openFlyout(value)} onMouseLeave={closeFlyoutSoon}>\n <ParentDisabledContext.Provider value={disabled}>{compactChildren}</ParentDisabledContext.Provider>\n </SubmenuPopover>\n )}\n </div>\n );\n}\n\nexport function SubItem({ value, label, count, disabled: disabledProp, compact = false }: SidebarNavSubItemProps) {\n const { value: activeValue, disabled: rootDisabled, select, showTip, hideTip } = useSidebarNavContext('SubItem');\n const parentDisabled = React.useContext(ParentDisabledContext);\n const labelRef = React.useRef<HTMLSpanElement>(null);\n // Its own `disabled` wins, then its parent Item's (already resolved against the root), then the root's.\n const disabled = disabledProp ?? parentDisabled ?? rootDisabled;\n const active = activeValue === value;\n const st = useInteract(disabled);\n return (\n <button\n type=\"button\"\n className=\"sereno-sidenav-btn\"\n aria-current={active ? 'page' : undefined}\n aria-disabled={disabled || undefined}\n tabIndex={disabled ? -1 : undefined}\n onClick={() => {\n hideTip();\n if (!disabled) select(value);\n }}\n {...st.handlers}\n onMouseEnter={(e) => {\n st.handlers.onMouseEnter?.(e);\n showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n }}\n onMouseLeave={(e) => {\n st.handlers.onMouseLeave?.(e);\n hideTip();\n }}\n onFocus={(e) => {\n st.handlers.onFocus?.(e);\n if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n }}\n onBlur={(e) => {\n st.handlers.onBlur?.(e);\n hideTip();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') hideTip();\n }}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n height: compact ? 32 : 34,\n padding: '0 var(--space-2)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n textAlign: 'left',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: active ? 'var(--weight-semibold)' : 'var(--weight-medium)',\n background: active ? 'var(--bg-brand-soft)' : st.hover ? 'var(--interactive-ghost-hover)' : 'transparent',\n color: disabled ? 'var(--text-disabled)' : active ? 'var(--text-brand)' : 'var(--text-secondary)',\n transition: 'var(--transition-control)',\n })}\n >\n <span ref={labelRef} style={sx({ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>\n {label}\n </span>\n {count !== undefined && <span style={countPill(active, disabled)}>{count}</span>}\n </button>\n );\n}\n"],"mappings":";AA4GI,SAkGI,UAjGsB,KAD1B;AA1GJ,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,uBAAoD,4BAA4B;AACzF,SAAS,sBAAsB;AA4C/B,MAAM,YAAY,GAAG;AAAA,EACnB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,eAAe;AAAA,EACf,OAAO;AAAA;AAAA,EAEP,SAAS;AACX,CAAC;AAED,MAAM,YAAY,CAAC,QAAiB,WAAW,UAC7C,GAAG;AAAA,EACD,YAAY;AAAA,EACZ,MAAM;AAAA,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AAAA,MACA,cAAc,CAAC,MAAM;AACnB,WAAG,SAAS,eAAe,CAAC;AAC5B,gBAAQ;AAAA,MACV;AAAA,MACA,SAAS,CAAC,MAAM;AACd,WAAG,SAAS,UAAU,CAAC;AACvB,YAAI,gBAAgB,EAAE,aAAa,EAAG,cAAa,EAAE,eAAe,SAAS,SAAS,OAAO,OAAO;AAAA,MACtG;AAAA,MACA,QAAQ,CAAC,MAAM;AACb,WAAG,SAAS,SAAS,CAAC;AACtB,gBAAQ;AAAA,MACV;AAAA,MACA,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,SAAU,SAAQ;AAAA,MAClC;AAAA,MACA,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,KAAK;AAAA,QACL,OAAO;AAAA,QACP,QAAQ,UAAU,KAAK;AAAA,QACvB,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,QAAQ,WAAW,gBAAgB;AAAA,QACnC,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,YAAY,SAAS,2BAA2B;AAAA,QAChD,YAAY,SAAS,yBAAyB,GAAG,QAAQ,mCAAmC;AAAA,QAC5F,OAAO,WAAW,yBAAyB,SAAS,sBAAsB;AAAA,QAC1E,YAAY;AAAA,MACd,CAAC;AAAA,MAED;AAAA,4BAAC,UAAK,KAAK,UAAU,OAAO,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,UAAU,cAAc,YAAY,YAAY,SAAS,CAAC,GACxH,iBACH;AAAA,QACC,UAAU,UAAa,oBAAC,UAAK,OAAO,UAAU,QAAQ,QAAQ,GAAI,iBAAM;AAAA;AAAA;AAAA,EAC3E;AAEJ;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function SubmenuPopover({ anchorRef, label, icon, children, onClose, onMouseEnter, onMouseLeave, }: {
|
|
4
|
+
anchorRef: React.RefObject<HTMLButtonElement | null>;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
onMouseEnter?: () => void;
|
|
10
|
+
onMouseLeave?: () => void;
|
|
11
|
+
}): React.ReactPortal;
|
|
12
|
+
|
|
13
|
+
export { SubmenuPopover };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { sx } from "../../_internal/style.js";
|
|
6
|
+
function SubmenuPopover({
|
|
7
|
+
anchorRef,
|
|
8
|
+
label,
|
|
9
|
+
icon,
|
|
10
|
+
children,
|
|
11
|
+
onClose,
|
|
12
|
+
onMouseEnter,
|
|
13
|
+
onMouseLeave
|
|
14
|
+
}) {
|
|
15
|
+
const ref = React.useRef(null);
|
|
16
|
+
const [pos, setPos] = React.useState(null);
|
|
17
|
+
React.useLayoutEffect(() => {
|
|
18
|
+
const el = ref.current;
|
|
19
|
+
const anchor = anchorRef.current;
|
|
20
|
+
if (!el || !anchor) return;
|
|
21
|
+
const a = anchor.getBoundingClientRect();
|
|
22
|
+
const p = el.getBoundingClientRect();
|
|
23
|
+
let left = a.right + 10;
|
|
24
|
+
let onRight = true;
|
|
25
|
+
if (left + p.width > window.innerWidth - 8) {
|
|
26
|
+
left = Math.max(8, a.left - p.width - 10);
|
|
27
|
+
onRight = false;
|
|
28
|
+
}
|
|
29
|
+
let top = a.top - 4;
|
|
30
|
+
if (top + p.height > window.innerHeight - 8) top = Math.max(8, window.innerHeight - 8 - p.height);
|
|
31
|
+
const caret = onRight ? a.top + a.height / 2 - top : null;
|
|
32
|
+
setPos({ top, left, caret });
|
|
33
|
+
}, [anchorRef]);
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const onDown = (e) => {
|
|
36
|
+
const t = e.target;
|
|
37
|
+
if (!ref.current?.contains(t) && !anchorRef.current?.contains(t)) onClose();
|
|
38
|
+
};
|
|
39
|
+
const onKey = (e) => e.key === "Escape" && onClose();
|
|
40
|
+
document.addEventListener("mousedown", onDown);
|
|
41
|
+
document.addEventListener("keydown", onKey);
|
|
42
|
+
window.addEventListener("scroll", onClose, true);
|
|
43
|
+
window.addEventListener("resize", onClose);
|
|
44
|
+
return () => {
|
|
45
|
+
document.removeEventListener("mousedown", onDown);
|
|
46
|
+
document.removeEventListener("keydown", onKey);
|
|
47
|
+
window.removeEventListener("scroll", onClose, true);
|
|
48
|
+
window.removeEventListener("resize", onClose);
|
|
49
|
+
};
|
|
50
|
+
}, [anchorRef, onClose]);
|
|
51
|
+
return createPortal(
|
|
52
|
+
/* @__PURE__ */ jsxs(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
ref,
|
|
56
|
+
role: "menu",
|
|
57
|
+
"aria-label": label,
|
|
58
|
+
onMouseEnter,
|
|
59
|
+
onMouseLeave,
|
|
60
|
+
style: sx({
|
|
61
|
+
position: "fixed",
|
|
62
|
+
top: pos ? pos.top : -9999,
|
|
63
|
+
left: pos ? pos.left : -9999,
|
|
64
|
+
minWidth: 196,
|
|
65
|
+
maxWidth: 264,
|
|
66
|
+
padding: 5,
|
|
67
|
+
background: "var(--bg-surface)",
|
|
68
|
+
borderRadius: "var(--radius-md)",
|
|
69
|
+
boxShadow: "0 0 0 1px var(--border-default), var(--shadow-lg)",
|
|
70
|
+
zIndex: 1e3,
|
|
71
|
+
animation: "sereno-flyout-in var(--duration-fast) var(--ease-out)"
|
|
72
|
+
}),
|
|
73
|
+
children: [
|
|
74
|
+
pos?.caret != null && /* @__PURE__ */ jsx(
|
|
75
|
+
"span",
|
|
76
|
+
{
|
|
77
|
+
"aria-hidden": true,
|
|
78
|
+
style: sx({
|
|
79
|
+
position: "absolute",
|
|
80
|
+
left: -4,
|
|
81
|
+
top: pos.caret,
|
|
82
|
+
width: 8,
|
|
83
|
+
height: 8,
|
|
84
|
+
background: "var(--bg-surface)",
|
|
85
|
+
borderLeft: "var(--border-width-hairline) solid var(--border-default)",
|
|
86
|
+
borderBottom: "var(--border-width-hairline) solid var(--border-default)",
|
|
87
|
+
transform: "translateY(-50%) rotate(45deg)",
|
|
88
|
+
borderBottomLeftRadius: 2
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsxs(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
style: sx({
|
|
96
|
+
display: "flex",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
gap: "var(--space-2)",
|
|
99
|
+
padding: "5px 8px 8px",
|
|
100
|
+
marginBottom: 4,
|
|
101
|
+
borderBottom: "var(--border-width-hairline) solid var(--border-subtle)",
|
|
102
|
+
fontFamily: "var(--font-body)",
|
|
103
|
+
fontSize: "var(--text-sm)",
|
|
104
|
+
fontWeight: "var(--weight-semibold)",
|
|
105
|
+
color: "var(--text-primary)"
|
|
106
|
+
}),
|
|
107
|
+
children: [
|
|
108
|
+
icon && /* @__PURE__ */ jsx(
|
|
109
|
+
"span",
|
|
110
|
+
{
|
|
111
|
+
style: sx({ flex: "0 0 auto", display: "inline-flex", width: 16, height: 16, alignItems: "center", justifyContent: "center", color: "var(--text-muted)" }),
|
|
112
|
+
children: icon
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsx("span", { style: sx({ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }), children: label })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ jsx("div", { style: sx({ display: "flex", flexDirection: "column", gap: 1 }), children })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
document.body
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
SubmenuPopover
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=SidebarSubmenuPopover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/navigation/_internal/SidebarSubmenuPopover.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { sx } from '../../_internal/style';\n\nexport function SubmenuPopover({\n anchorRef,\n label,\n icon,\n children,\n onClose,\n onMouseEnter,\n onMouseLeave,\n}: {\n anchorRef: React.RefObject<HTMLButtonElement | null>;\n label: string;\n icon?: React.ReactNode;\n children: React.ReactNode;\n onClose: () => void;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [pos, setPos] = React.useState<{ top: number; left: number; caret: number | null } | null>(null);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n const anchor = anchorRef.current;\n if (!el || !anchor) return;\n const a = anchor.getBoundingClientRect();\n const p = el.getBoundingClientRect();\n let left = a.right + 10;\n let onRight = true;\n if (left + p.width > window.innerWidth - 8) {\n left = Math.max(8, a.left - p.width - 10);\n onRight = false;\n }\n let top = a.top - 4;\n if (top + p.height > window.innerHeight - 8) top = Math.max(8, window.innerHeight - 8 - p.height);\n const caret = onRight ? a.top + a.height / 2 - top : null;\n setPos({ top, left, caret });\n }, [anchorRef]);\n\n React.useEffect(() => {\n const onDown = (e: MouseEvent) => {\n const t = e.target as Node;\n if (!ref.current?.contains(t) && !anchorRef.current?.contains(t)) onClose();\n };\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', onClose, true);\n window.addEventListener('resize', onClose);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', onClose, true);\n window.removeEventListener('resize', onClose);\n };\n }, [anchorRef, onClose]);\n\n return createPortal(\n <div\n ref={ref}\n role=\"menu\"\n aria-label={label}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n style={sx({\n position: 'fixed',\n top: pos ? pos.top : -9999,\n left: pos ? pos.left : -9999,\n minWidth: 196,\n maxWidth: 264,\n padding: 5,\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-md)',\n boxShadow: '0 0 0 1px var(--border-default), var(--shadow-lg)',\n zIndex: 1000,\n animation: 'sereno-flyout-in var(--duration-fast) var(--ease-out)',\n })}\n >\n {pos?.caret != null && (\n <span\n aria-hidden\n style={sx({\n position: 'absolute',\n left: -4,\n top: pos.caret,\n width: 8,\n height: 8,\n background: 'var(--bg-surface)',\n borderLeft: 'var(--border-width-hairline) solid var(--border-default)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-default)',\n transform: 'translateY(-50%) rotate(45deg)',\n borderBottomLeftRadius: 2,\n })}\n />\n )}\n\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n padding: '5px 8px 8px',\n marginBottom: 4,\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n })}\n >\n {icon && (\n <span\n style={sx({ flex: '0 0 auto', display: 'inline-flex', width: 16, height: 16, alignItems: 'center', justifyContent: 'center', color: 'var(--text-muted)' })}\n >\n {icon}\n </span>\n )}\n <span style={sx({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>{label}</span>\n </div>\n\n <div style={sx({ display: 'flex', flexDirection: 'column', gap: 1 })}>{children}</div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AAoFQ,cAiBF,YAjBE;AAlFR,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AAEZ,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAQG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gBACH;AAAA,gBAEF,oBAAC,UAAK,OAAO,GAAG,EAAE,UAAU,UAAU,cAAc,YAAY,YAAY,SAAS,CAAC,GAAI,iBAAM;AAAA;AAAA;AAAA,UAClG;AAAA,UAEA,oBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,EAAE,CAAC,GAAI,UAAS;AAAA;AAAA;AAAA,IAClF;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface SidebarNavContextValue {
|
|
4
|
+
value?: string;
|
|
5
|
+
/** The root's `disabled` - what an `Item` falls back to when it doesn't set its own. */
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
/** Closes any open flyout, then calls the root's `onChange`. What `Item` / `SubItem` call on click. */
|
|
8
|
+
select: (value: string) => void;
|
|
9
|
+
collapsed: boolean;
|
|
10
|
+
linkComponent?: React.ElementType;
|
|
11
|
+
/** Which item's collapsed-rail flyout is open, if any - single, cross-item (opening one closes another). */
|
|
12
|
+
flyoutValue: string | null;
|
|
13
|
+
openFlyout: (value: string) => void;
|
|
14
|
+
closeFlyoutSoon: () => void;
|
|
15
|
+
closeFlyoutNow: () => void;
|
|
16
|
+
showTip: (label: string, rect: DOMRect) => void;
|
|
17
|
+
hideTip: () => void;
|
|
18
|
+
}
|
|
19
|
+
declare const SidebarNavContext: React.Context<SidebarNavContextValue | null>;
|
|
20
|
+
/** An `Item`'s effective `disabled`, handed to its `SubItem`s so they inherit from their parent (which itself inherited the root's). */
|
|
21
|
+
declare const ParentDisabledContext: React.Context<boolean | undefined>;
|
|
22
|
+
declare function useSidebarNavContext(component: string): SidebarNavContextValue;
|
|
23
|
+
|
|
24
|
+
export { ParentDisabledContext, SidebarNavContext, type SidebarNavContextValue, useSidebarNavContext };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SidebarNavContext = React.createContext(null);
|
|
3
|
+
const ParentDisabledContext = React.createContext(void 0);
|
|
4
|
+
function useSidebarNavContext(component) {
|
|
5
|
+
const ctx = React.useContext(SidebarNavContext);
|
|
6
|
+
if (!ctx) throw new Error(`<SidebarNav.${component}> must be rendered inside <SidebarNav>.`);
|
|
7
|
+
return ctx;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
ParentDisabledContext,
|
|
11
|
+
SidebarNavContext,
|
|
12
|
+
useSidebarNavContext
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=sidebarNavContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/navigation/_internal/sidebarNavContext.ts"],"sourcesContent":["import * as React from 'react';\n\nexport interface SidebarNavContextValue {\n value?: string;\n /** The root's `disabled` - what an `Item` falls back to when it doesn't set its own. */\n disabled: boolean;\n /** Closes any open flyout, then calls the root's `onChange`. What `Item` / `SubItem` call on click. */\n select: (value: string) => void;\n collapsed: boolean;\n linkComponent?: React.ElementType;\n /** Which item's collapsed-rail flyout is open, if any - single, cross-item (opening one closes another). */\n flyoutValue: string | null;\n openFlyout: (value: string) => void;\n closeFlyoutSoon: () => void;\n closeFlyoutNow: () => void;\n showTip: (label: string, rect: DOMRect) => void;\n hideTip: () => void;\n}\n\nexport const SidebarNavContext = React.createContext<SidebarNavContextValue | null>(null);\n\n/** An `Item`'s effective `disabled`, handed to its `SubItem`s so they inherit from their parent (which itself inherited the root's). */\nexport const ParentDisabledContext = React.createContext<boolean | undefined>(undefined);\n\nexport function useSidebarNavContext(component: string): SidebarNavContextValue {\n const ctx = React.useContext(SidebarNavContext);\n if (!ctx) throw new Error(`<SidebarNav.${component}> must be rendered inside <SidebarNav>.`);\n return ctx;\n}\n"],"mappings":"AAAA,YAAY,WAAW;AAmBhB,MAAM,oBAAoB,MAAM,cAA6C,IAAI;AAGjF,MAAM,wBAAwB,MAAM,cAAmC,MAAS;AAEhF,SAAS,qBAAqB,WAA2C;AAC9E,QAAM,MAAM,MAAM,WAAW,iBAAiB;AAC9C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,eAAe,SAAS,yCAAyC;AAC3F,SAAO;AACT;","names":[]}
|
package/dist/styles.css
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
The Sereno components are token-driven inline styles, but a handful of things
|
|
5
5
|
can't live in an inline `style`: @keyframes, pseudo-classes (:checked,
|
|
6
|
-
:focus-visible
|
|
6
|
+
:focus-visible, and the :hover / :active / :focus-visible of Button, IconButton
|
|
7
|
+
and Card, SS-577), pseudo-elements (::-webkit-scrollbar) and one narrow
|
|
7
8
|
responsive reflow. Those rules live here and MUST be loaded once, at the app
|
|
8
9
|
root, for the components to render correctly:
|
|
9
10
|
|
|
@@ -33,6 +34,58 @@
|
|
|
33
34
|
@keyframes sereno-toast-out { to { opacity: 0; transform: scale(0.96); } }
|
|
34
35
|
@keyframes sereno-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
|
|
35
36
|
|
|
37
|
+
/* ── Button / IconButton / Card: hover, press and keyboard focus (SS-577) ──────────────
|
|
38
|
+
The component declares what each state looks like as custom properties on the element
|
|
39
|
+
(`--sd-bg`, `--sd-bg-hover`, ...) and these rules switch between them, so the browser does
|
|
40
|
+
the work and a button holds no hover / press / focus state (before: three useState and five
|
|
41
|
+
handlers per instance, re-rendering on every hover). It also means an app can restyle a
|
|
42
|
+
state with plain CSS (`.sereno-btn:hover { ... }`) with no `!important`.
|
|
43
|
+
|
|
44
|
+
Order matters: hover, then active (a press while hovering), then focus-visible (the ring wins).
|
|
45
|
+
A property a variant does not set falls back to the one before it. `:disabled` is excluded:
|
|
46
|
+
a disabled control, and a `loading` one, has no states. The `:where()` keeps each state rule at the
|
|
47
|
+
specificity of `.sereno-btn:hover` (0,2,0), so an app's own `.my-button:hover` overrides it by being
|
|
48
|
+
later in the cascade; the base `.sereno-btn` stays (0,1,0) so it still beats a global `button {}` reset. */
|
|
49
|
+
.sereno-btn {
|
|
50
|
+
background: var(--sd-bg);
|
|
51
|
+
color: var(--sd-fg);
|
|
52
|
+
border-color: var(--sd-bd);
|
|
53
|
+
box-shadow: var(--sd-sh, none);
|
|
54
|
+
}
|
|
55
|
+
.sereno-btn:hover:where(:not(:disabled)) {
|
|
56
|
+
background: var(--sd-bg-hover, var(--sd-bg));
|
|
57
|
+
color: var(--sd-fg-hover, var(--sd-fg));
|
|
58
|
+
box-shadow: var(--sd-sh-hover, var(--sd-sh, none));
|
|
59
|
+
text-decoration: var(--sd-deco-hover, none);
|
|
60
|
+
}
|
|
61
|
+
.sereno-btn:active:where(:not(:disabled)) {
|
|
62
|
+
background: var(--sd-bg-active, var(--sd-bg-hover, var(--sd-bg)));
|
|
63
|
+
box-shadow: var(--sd-sh, none);
|
|
64
|
+
transform: scale(var(--press-scale));
|
|
65
|
+
}
|
|
66
|
+
.sereno-btn:focus-visible:where(:not(:disabled)) {
|
|
67
|
+
box-shadow: var(--sd-ring, var(--focus-ring));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Card: a ring and a drop shadow, each with its hover value; `data-interactive` lifts on hover and
|
|
71
|
+
scales on press, `data-clickable` (a card with its own onClick) also gets the focus ring. */
|
|
72
|
+
.sereno-card {
|
|
73
|
+
box-shadow: var(--sd-ring), var(--sd-drop);
|
|
74
|
+
}
|
|
75
|
+
.sereno-card[data-interactive]:hover {
|
|
76
|
+
box-shadow: var(--sd-ring-h), var(--sd-drop-h);
|
|
77
|
+
transform: translateY(var(--hover-lift));
|
|
78
|
+
}
|
|
79
|
+
.sereno-card[data-interactive]:active {
|
|
80
|
+
transform: scale(var(--press-scale));
|
|
81
|
+
}
|
|
82
|
+
.sereno-card[data-clickable]:focus-visible {
|
|
83
|
+
box-shadow: var(--sd-ring), var(--sd-drop), var(--focus-ring);
|
|
84
|
+
}
|
|
85
|
+
.sereno-card[data-clickable]:hover:focus-visible {
|
|
86
|
+
box-shadow: var(--sd-ring-h), var(--sd-drop-h), var(--focus-ring);
|
|
87
|
+
}
|
|
88
|
+
|
|
36
89
|
/* ── Checkbox / Radio / Switch ───────────────────────────────────────────────
|
|
37
90
|
Checkbox and Radio render bare <input>s; Switch is a role="switch" <span>.
|
|
38
91
|
All three need these host rules for their checked / focus states. */
|