@sereno-ds/ui 0.42.1 → 0.43.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 +13 -2
- package/dist/core/ActionCard.d.ts +1 -1
- package/dist/core/ActionCard.js +9 -8
- package/dist/core/ActionCard.js.map +1 -1
- package/dist/core/Button.d.ts +1 -9
- package/dist/core/Button.js +1 -22
- package/dist/core/Button.js.map +1 -1
- package/dist/forms/AvatarUpload.js +1 -4
- package/dist/forms/AvatarUpload.js.map +1 -1
- package/dist/forms/Checkbox.js +6 -5
- package/dist/forms/Checkbox.js.map +1 -1
- package/dist/forms/Radio.js +6 -5
- package/dist/forms/Radio.js.map +1 -1
- package/dist/forms/_internal/choiceVars.d.ts +9 -0
- package/dist/forms/_internal/choiceVars.js +7 -0
- package/dist/forms/_internal/choiceVars.js.map +1 -0
- package/dist/navigation/_internal/SidebarNavItems.js +14 -31
- package/dist/navigation/_internal/SidebarNavItems.js.map +1 -1
- package/dist/styles.css +47 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,11 +23,22 @@ import '@sereno-ds/ui/styles.css'; // keyframes, structural rules, and the h
|
|
|
23
23
|
|
|
24
24
|
`tokens.css` **must** come first. Both are side-effect CSS: import them once (a root layout, `_app`, or `main.tsx`), not per-component.
|
|
25
25
|
|
|
26
|
-
**`styles.css` is required**, not decorative: `Button`, `IconButton` and `
|
|
26
|
+
**`styles.css` is required**, not decorative: `Button`, `IconButton`, `Card`, `ActionCard`, the rows of `SidebarNav`, `Checkbox`, `Radio` and the actions of `AvatarUpload` take their hover / press / focus states (and, for the first four, their colours and border) from it. Their values are on the element, the rules that switch between them are in the stylesheet, so without it they render unstyled or with no hover.
|
|
27
27
|
|
|
28
28
|
#### Restyling a state with plain CSS
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
These components carry a class the stylesheet's state rules hang on:
|
|
31
|
+
|
|
32
|
+
| Component | Class | Also |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `Button`, `IconButton` | `sereno-btn` | |
|
|
35
|
+
| `Card` | `sereno-card` | `data-interactive`, `data-clickable` |
|
|
36
|
+
| `ActionCard` | `sereno-action` | |
|
|
37
|
+
| `SidebarNav` items and sub items | `sereno-sidenav-row` | |
|
|
38
|
+
| `Checkbox`, `Radio` | `sereno-choice` on the row (the `<label>`), `sereno-check` / `sereno-radio` on the box | |
|
|
39
|
+
| the actions of `AvatarUpload` | `sereno-menuitem` | |
|
|
40
|
+
|
|
41
|
+
The state rules have the specificity of `.sereno-btn:hover` (one class and one pseudo-class), so a rule of yours with the same specificity **that comes later** wins, with no `!important`:
|
|
31
42
|
|
|
32
43
|
```css
|
|
33
44
|
/* a ghost button on a brand-coloured band: its hover fill vanishes on that colour */
|
|
@@ -28,6 +28,6 @@ interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
|
|
|
28
28
|
/** `primary` is the option to steer toward, `error` a destructive one. */
|
|
29
29
|
variant?: ActionCardVariant;
|
|
30
30
|
}
|
|
31
|
-
declare function ActionCard({ title, description, icon, trailing, selected, variant, disabled, style, ...rest }: ActionCardProps): React.JSX.Element;
|
|
31
|
+
declare function ActionCard({ title, description, icon, trailing, selected, variant, disabled, className, style, ...rest }: ActionCardProps): React.JSX.Element;
|
|
32
32
|
|
|
33
33
|
export { ActionCard, type ActionCardProps, type ActionCardVariant };
|
package/dist/core/ActionCard.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ChevronRight } from "lucide-react";
|
|
4
4
|
import { sx } from "../_internal/style.js";
|
|
5
|
-
import { useInteract } from "./Button.js";
|
|
6
5
|
import { Typography } from "./Typography.js";
|
|
7
6
|
const VARIANTS = {
|
|
8
7
|
default: { tileBg: "var(--bg-subtle)", tileFg: "var(--text-secondary)", edge: "var(--border-brand)" },
|
|
@@ -18,14 +17,15 @@ function ActionCard({
|
|
|
18
17
|
selected,
|
|
19
18
|
variant = "default",
|
|
20
19
|
disabled = false,
|
|
20
|
+
className,
|
|
21
21
|
style,
|
|
22
22
|
...rest
|
|
23
23
|
}) {
|
|
24
|
-
const st = useInteract(disabled);
|
|
25
24
|
const v = VARIANTS[variant] || VARIANTS.default;
|
|
26
25
|
const on = selected === true;
|
|
27
26
|
const arrow = trailing === void 0 ? /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75, "aria-hidden": true }) : trailing;
|
|
28
|
-
const ring = on ? "0 0 0 1.5px " + v.edge : "0 0 0 1px " + (
|
|
27
|
+
const ring = on ? "0 0 0 1.5px " + v.edge : "0 0 0 1px " + (disabled ? "var(--border-subtle)" : "var(--border-default)");
|
|
28
|
+
const ringHover = on ? ring : "0 0 0 1px " + v.edge;
|
|
29
29
|
const muted = disabled ? { color: "var(--text-disabled)" } : void 0;
|
|
30
30
|
const titleStyle = disabled ? muted : v.title ? { color: v.title } : void 0;
|
|
31
31
|
return /* @__PURE__ */ jsxs(
|
|
@@ -34,9 +34,13 @@ function ActionCard({
|
|
|
34
34
|
type: "button",
|
|
35
35
|
disabled,
|
|
36
36
|
"aria-pressed": selected,
|
|
37
|
-
...st.handlers,
|
|
38
37
|
...rest,
|
|
38
|
+
className: ["sereno-action", className].filter(Boolean).join(" "),
|
|
39
39
|
style: sx({
|
|
40
|
+
"--sd-bg": "var(--bg-surface)",
|
|
41
|
+
"--sd-bg-hover": disabled ? void 0 : hoverFill(v.edge),
|
|
42
|
+
"--sd-ring": ring,
|
|
43
|
+
"--sd-ring-hover": disabled ? void 0 : ringHover,
|
|
40
44
|
display: "flex",
|
|
41
45
|
alignItems: "center",
|
|
42
46
|
gap: "var(--space-3)",
|
|
@@ -48,12 +52,9 @@ function ActionCard({
|
|
|
48
52
|
color: "inherit",
|
|
49
53
|
border: "none",
|
|
50
54
|
borderRadius: "var(--radius-card)",
|
|
51
|
-
background: !disabled && st.hover ? hoverFill(v.edge) : "var(--bg-surface)",
|
|
52
|
-
boxShadow: [ring, st.focus ? "var(--focus-ring)" : null].filter(Boolean).join(", "),
|
|
53
|
-
transform: st.press && !disabled ? "scale(var(--press-scale))" : "none",
|
|
54
55
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
55
56
|
transition: "var(--transition-control)",
|
|
56
|
-
// The focus ring
|
|
57
|
+
// The focus ring is the box-shadow of `.sereno-action:focus-visible`, the same substitute `Button` and `Card` use.
|
|
57
58
|
outline: "none",
|
|
58
59
|
...style
|
|
59
60
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/ActionCard.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/core/ActionCard.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Typography } from './Typography';\n\nexport type ActionCardVariant = 'default' | 'primary' | 'error';\n\n/**\n * A whole card you press: an icon, a title, a line of explanation and an arrow, in a real\n * `<button>`. For the options of a decision (\"Reschedule\", \"Cancel the booking\") and for the\n * entries of a settings flow. A `Card` with `interactive` is the bare surface; this is the\n * finished control, with the keyboard, the focus ring and the disabled state taken care of.\n *\n * It is an action, not a radio: arrow keys do not move between cards. `selected` marks a card as\n * a toggle (`aria-pressed`); for \"choose exactly one of these\" the semantics are a radio group's,\n * which this is not.\n */\nexport interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title' | 'children'> {\n /** What the card does. Short: it is the name a screen reader says. */\n title: React.ReactNode;\n /** One line that says what happens. */\n description?: React.ReactNode;\n /** An icon (a `lucide-react` element), drawn in a tile on the left. Hidden from a screen reader: the title says it. */\n icon?: React.ReactNode;\n /** What sits on the right. An arrow by default; any node, or `null` for nothing. */\n trailing?: React.ReactNode;\n /**\n * Passing it (true or false) makes the card a toggle: it reports `aria-pressed` and, when true,\n * wears the brand ring. Leave it out for a plain action.\n */\n selected?: boolean;\n /** `primary` is the option to steer toward, `error` a destructive one. */\n variant?: ActionCardVariant;\n}\n\n// `title` is the text color of the variant, when it has one. The error one is `--status-error-fg`, not\n// `--interactive-error`: on the hover fill the latter is 3.53:1 in the light theme (4.2:1 in the dark one),\n// under AA for text this size, where the status text color stays at 4.86:1 and 6.69:1.\nconst VARIANTS: Record<ActionCardVariant, { tileBg: string; tileFg: string; edge: string; title?: string }> = {\n default: { tileBg: 'var(--bg-subtle)', tileFg: 'var(--text-secondary)', edge: 'var(--border-brand)' },\n primary: { tileBg: 'var(--interactive-primary)', tileFg: 'var(--interactive-primary-fg)', edge: 'var(--border-brand)' },\n error: { tileBg: 'var(--status-error-bg)', tileFg: 'var(--status-error-fg)', edge: 'var(--status-error-dot)', title: 'var(--status-error-fg)' },\n};\n\n// The fill of a hovered card: a few percent of the variant's own ring color over the surface. Not\n// `--interactive-ghost-hover`: that grey is the very color of the icon tile (`--bg-subtle`), so on hover the\n// tile vanished into the card. This tint keeps the tile showing (1.20:1 against it in the light theme, 1.17:1\n// in the dark one, close to the 1.28:1 and 1.23:1 it has against the idle card) and keeps every text above AA.\nconst hoverFill = (edge: string) => 'color-mix(in srgb, ' + edge + ' 6%, var(--bg-surface))';\n\nexport function ActionCard({\n title,\n description,\n icon,\n trailing,\n selected,\n variant = 'default',\n disabled = false,\n className,\n style,\n ...rest\n}: ActionCardProps) {\n const v = VARIANTS[variant] || VARIANTS.default;\n const on = selected === true;\n const arrow = trailing === undefined ? <ChevronRight size={18} strokeWidth={1.75} aria-hidden /> : trailing;\n\n // The ring and the fill, each with its hover value, as custom properties `.sereno-action` (styles.css) switches\n // between on `:hover`, `:active` and `:focus-visible` (SS-577): the card holds no hover / press / focus state.\n // A selected card wears the same ring hovered or not; a disabled one has no hover value at all.\n const ring = on ? '0 0 0 1.5px ' + v.edge : '0 0 0 1px ' + (disabled ? 'var(--border-subtle)' : 'var(--border-default)');\n const ringHover = on ? ring : '0 0 0 1px ' + v.edge;\n // Only set when disabled: a `color: undefined` in a style would wipe the Typography's own.\n const muted = disabled ? { color: 'var(--text-disabled)' } : undefined;\n const titleStyle = disabled ? muted : v.title ? { color: v.title } : undefined;\n\n return (\n <button\n type=\"button\"\n disabled={disabled}\n aria-pressed={selected}\n {...rest}\n className={['sereno-action', className].filter(Boolean).join(' ')}\n style={sx({\n '--sd-bg': 'var(--bg-surface)',\n '--sd-bg-hover': disabled ? undefined : hoverFill(v.edge),\n '--sd-ring': ring,\n '--sd-ring-hover': disabled ? undefined : ringHover,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n width: '100%',\n minWidth: 0,\n padding: 'var(--space-3) var(--space-4)',\n textAlign: 'left',\n fontFamily: 'var(--font-body)',\n color: 'inherit',\n border: 'none',\n borderRadius: 'var(--radius-card)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n // The focus ring is the box-shadow of `.sereno-action:focus-visible`, the same substitute `Button` and `Card` use.\n outline: 'none',\n ...style,\n })}\n >\n {icon ? (\n <span\n aria-hidden\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n flex: '0 0 auto',\n width: 40,\n height: 40,\n borderRadius: 'var(--radius-md)',\n background: disabled ? 'var(--interactive-disabled-bg)' : v.tileBg,\n color: disabled ? 'var(--interactive-disabled-fg)' : v.tileFg,\n })}\n >\n {icon}\n </span>\n ) : null}\n\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2, flex: '1 1 auto', minWidth: 0 })}>\n <Typography as=\"span\" variant=\"label\" style={titleStyle}>\n {title}\n </Typography>\n {description ? (\n <Typography as=\"span\" variant=\"bodySm\" style={muted}>\n {description}\n </Typography>\n ) : null}\n </span>\n\n {arrow ? (\n <span style={sx({ display: 'inline-flex', flex: '0 0 auto', color: disabled ? 'var(--text-disabled)' : 'var(--text-muted)' })}>\n {arrow}\n </span>\n ) : null}\n </button>\n );\n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,QACb,mBAAmB,WAAW,SAAY;AAAA,QAC1C,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,KAAK;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,SAAS;AAAA,QACT,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA;AAAA,QAEZ,SAAS;AAAA,QACT,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,eACC;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,YACX,OAAO,GAAG;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY,WAAW,mCAAmC,EAAE;AAAA,cAC5D,OAAO,WAAW,mCAAmC,EAAE;AAAA,YACzD,CAAC;AAAA,YAEA;AAAA;AAAA,QACH,IACE;AAAA,QAEJ,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,GAAG,MAAM,YAAY,UAAU,EAAE,CAAC,GACjG;AAAA,8BAAC,cAAW,IAAG,QAAO,SAAQ,SAAQ,OAAO,YAC1C,iBACH;AAAA,UACC,cACC,oBAAC,cAAW,IAAG,QAAO,SAAQ,UAAS,OAAO,OAC3C,uBACH,IACE;AAAA,WACN;AAAA,QAEC,QACC,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,eAAe,MAAM,YAAY,OAAO,WAAW,yBAAyB,oBAAoB,CAAC,GACzH,iBACH,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
package/dist/core/Button.d.ts
CHANGED
|
@@ -18,14 +18,6 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
18
18
|
iconRight?: React.ReactNode;
|
|
19
19
|
children?: React.ReactNode;
|
|
20
20
|
}
|
|
21
|
-
interface InteractState {
|
|
22
|
-
hover: boolean;
|
|
23
|
-
press: boolean;
|
|
24
|
-
focus: boolean;
|
|
25
|
-
handlers: React.HTMLAttributes<HTMLElement>;
|
|
26
|
-
}
|
|
27
|
-
/** Shared hover / press / focus-visible tracking used by Button, IconButton and Card. */
|
|
28
|
-
declare function useInteract(disabled: boolean): InteractState;
|
|
29
21
|
declare function Button({ variant, size, fullWidth, disabled, loading, iconLeft, iconRight, children, className, style, ...rest }: ButtonProps): React.JSX.Element;
|
|
30
22
|
|
|
31
|
-
export { Button, type ButtonProps
|
|
23
|
+
export { Button, type ButtonProps };
|
package/dist/core/Button.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
3
|
import { sx } from "../_internal/style.js";
|
|
5
|
-
function useInteract(disabled) {
|
|
6
|
-
const [hover, setHover] = React.useState(false);
|
|
7
|
-
const [press, setPress] = React.useState(false);
|
|
8
|
-
const [focus, setFocus] = React.useState(false);
|
|
9
|
-
const handlers = disabled ? {} : {
|
|
10
|
-
onMouseEnter: () => setHover(true),
|
|
11
|
-
onMouseLeave: () => {
|
|
12
|
-
setHover(false);
|
|
13
|
-
setPress(false);
|
|
14
|
-
},
|
|
15
|
-
onMouseDown: () => setPress(true),
|
|
16
|
-
onMouseUp: () => setPress(false),
|
|
17
|
-
onFocus: (e) => {
|
|
18
|
-
if (e.target.matches(":focus-visible")) setFocus(true);
|
|
19
|
-
},
|
|
20
|
-
onBlur: () => setFocus(false)
|
|
21
|
-
};
|
|
22
|
-
return { hover, press, focus, handlers };
|
|
23
|
-
}
|
|
24
4
|
const SIZES = {
|
|
25
5
|
sm: { h: "var(--control-height-sm)", px: "var(--space-3)", fs: "var(--text-sm)", gap: "6px" },
|
|
26
6
|
md: { h: "var(--control-height-md)", px: "var(--space-4)", fs: "var(--text-base)", gap: "8px" },
|
|
@@ -90,7 +70,6 @@ function Button({ variant = "primary", size = "md", fullWidth = false, disabled
|
|
|
90
70
|
);
|
|
91
71
|
}
|
|
92
72
|
export {
|
|
93
|
-
Button
|
|
94
|
-
useInteract
|
|
73
|
+
Button
|
|
95
74
|
};
|
|
96
75
|
//# sourceMappingURL=Button.js.map
|
package/dist/core/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Primary action control. `primary` for navigation-level commitment, `accent` for the single\n * conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the\n * same words as Badge / Alert / Toast. (No `info` - in Sereno that is the brand indigo = `primary`.)\n */\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual role. Only one `accent` button per screen. */\n variant?: 'primary' | 'accent' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'error';\n /** Control height. `lg`/`xl` are the mobile defaults (≥44px tap target). */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n fullWidth?: boolean;\n disabled?: boolean;\n /** Shows a spinner and blocks interaction. */\n loading?: boolean;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n children?: React.ReactNode;\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../src/core/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Primary action control. `primary` for navigation-level commitment, `accent` for the single\n * conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the\n * same words as Badge / Alert / Toast. (No `info` - in Sereno that is the brand indigo = `primary`.)\n */\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual role. Only one `accent` button per screen. */\n variant?: 'primary' | 'accent' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'error';\n /** Control height. `lg`/`xl` are the mobile defaults (≥44px tap target). */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n fullWidth?: boolean;\n disabled?: boolean;\n /** Shows a spinner and blocks interaction. */\n loading?: boolean;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n children?: React.ReactNode;\n}\n\nconst SIZES = {\n sm: { h: 'var(--control-height-sm)', px: 'var(--space-3)', fs: 'var(--text-sm)', gap: '6px' },\n md: { h: 'var(--control-height-md)', px: 'var(--space-4)', fs: 'var(--text-base)', gap: '8px' },\n lg: { h: 'var(--control-height-lg)', px: 'var(--space-5)', fs: 'var(--text-md)', gap: '10px' },\n xl: { h: 'var(--control-height-xl)', px: 'var(--space-6)', fs: 'var(--text-lg)', gap: '10px' },\n} as const;\n\n/**\n * What a variant looks like in each state, as the custom properties `.sereno-btn` (styles.css) reads:\n * the base, then only what differs on `:hover`, `:active` (pressed) and `:focus-visible` (SS-577). The\n * browser switches between them, so a button holds no hover / press / focus state and does not re-render when\n * the pointer crosses it. A property left out falls back to the one before it in the CSS.\n */\nfunction stateVars(variant: NonNullable<ButtonProps['variant']>): Record<string, string> {\n switch (variant) {\n case 'accent':\n return { '--sd-bg': 'var(--interactive-accent)', '--sd-bg-hover': 'var(--interactive-accent-hover)', '--sd-bg-active': 'var(--interactive-accent-active)', '--sd-fg': 'var(--interactive-accent-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)', '--sd-sh-hover': 'var(--shadow-accent)', '--sd-ring': 'var(--focus-ring-accent)' };\n case 'secondary':\n return { '--sd-bg': 'var(--interactive-secondary)', '--sd-bg-hover': 'var(--interactive-secondary-hover)', '--sd-bg-active': 'var(--interactive-secondary-active)', '--sd-fg': 'var(--interactive-secondary-fg)', '--sd-bd': 'var(--border-default)', '--sd-sh': 'var(--shadow-xs)' };\n case 'ghost':\n return { '--sd-bg': 'transparent', '--sd-bg-hover': 'var(--interactive-ghost-hover)', '--sd-fg': 'var(--text-secondary)', '--sd-bd': 'transparent', '--sd-sh': 'none' };\n case 'success':\n return { '--sd-bg': 'var(--interactive-success)', '--sd-bg-hover': 'var(--interactive-success-hover)', '--sd-fg': 'var(--interactive-success-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'warning':\n return { '--sd-bg': 'var(--interactive-warning)', '--sd-bg-hover': 'var(--interactive-warning-hover)', '--sd-fg': 'var(--interactive-warning-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'error':\n return { '--sd-bg': 'var(--interactive-error)', '--sd-bg-hover': 'var(--interactive-error-hover)', '--sd-fg': 'var(--interactive-error-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'link':\n return { '--sd-bg': 'transparent', '--sd-fg': 'var(--text-link)', '--sd-fg-hover': 'var(--text-link-hover)', '--sd-bd': 'transparent', '--sd-sh': 'none', '--sd-deco-hover': 'underline' };\n default:\n return { '--sd-bg': 'var(--interactive-primary)', '--sd-bg-hover': 'var(--interactive-primary-hover)', '--sd-bg-active': 'var(--interactive-primary-active)', '--sd-fg': 'var(--interactive-primary-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)', '--sd-sh-hover': 'var(--shadow-brand)' };\n }\n}\n\n/** A disabled control: one look, no hover, no press, no ring (the CSS rules exclude `:disabled`). */\nconst DISABLED_VARS = { '--sd-bg': 'var(--interactive-disabled-bg)', '--sd-fg': 'var(--interactive-disabled-fg)', '--sd-bd': 'transparent', '--sd-sh': 'none' };\n\nexport function Button({ variant = 'primary', size = 'md', fullWidth = false, disabled = false, loading = false, iconLeft, iconRight, children, className, style, ...rest }: ButtonProps) {\n const sz = SIZES[size] || SIZES.md;\n const isLink = variant === 'link';\n return (\n <button\n type=\"button\"\n disabled={disabled || loading}\n {...rest}\n className={['sereno-btn', className].filter(Boolean).join(' ')}\n style={sx({\n ...(disabled ? DISABLED_VARS : stateVars(variant)),\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: sz.gap,\n height: isLink ? 'auto' : sz.h,\n padding: isLink ? 0 : '0 ' + sz.px,\n width: fullWidth ? '100%' : undefined,\n fontFamily: 'var(--font-body)',\n fontSize: sz.fs,\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n borderRadius: isLink ? 'var(--radius-xs)' : 'var(--radius-control)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: loading ? 0.75 : 1,\n transition: 'var(--transition-control)',\n outline: 'none',\n textUnderlineOffset: '2px',\n ...style,\n })}\n >\n {loading ? (\n <span style={sx({ width: '1em', height: '1em', borderRadius: '999px', border: '2px solid currentColor', borderTopColor: 'transparent', display: 'inline-block', animation: 'sereno-spin .7s linear infinite' })} />\n ) : (\n iconLeft\n )}\n {children}\n {iconRight}\n </button>\n );\n}"],"mappings":";AAiEI,SA8BI,KA9BJ;AA9DJ,SAAS,UAAU;AAqBnB,MAAM,QAAQ;AAAA,EACZ,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,MAAM;AAAA,EAC5F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,oBAAoB,KAAK,MAAM;AAAA,EAC9F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO;AAAA,EAC7F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO;AAC/F;AAQA,SAAS,UAAU,SAAsE;AACvF,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,EAAE,WAAW,6BAA6B,iBAAiB,mCAAmC,kBAAkB,oCAAoC,WAAW,gCAAgC,WAAW,eAAe,WAAW,oBAAoB,iBAAiB,wBAAwB,aAAa,2BAA2B;AAAA,IAClV,KAAK;AACH,aAAO,EAAE,WAAW,gCAAgC,iBAAiB,sCAAsC,kBAAkB,uCAA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W,gBAAgB,UAAU,OAAO;AAAA,QAChD,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,KAAK,GAAG;AAAA,QACR,QAAQ,SAAS,SAAS,GAAG;AAAA,QAC7B,SAAS,SAAS,IAAI,OAAO,GAAG;AAAA,QAChC,OAAO,YAAY,SAAS;AAAA,QAC5B,YAAY;AAAA,QACZ,UAAU,GAAG;AAAA,QACb,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,cAAc,SAAS,qBAAqB;AAAA,QAC5C,aAAa;AAAA,QACb,aAAa;AAAA,QACb,QAAQ,WAAW,gBAAgB;AAAA,QACnC,SAAS,UAAU,OAAO;AAAA,QAC1B,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,qBAAqB;AAAA,QACrB,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,kBACC,oBAAC,UAAK,OAAO,GAAG,EAAE,OAAO,OAAO,QAAQ,OAAO,cAAc,SAAS,QAAQ,0BAA0B,gBAAgB,eAAe,SAAS,gBAAgB,WAAW,kCAAkC,CAAC,GAAG,IAEjN;AAAA,QAED;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -312,15 +312,13 @@ const AvatarUpload = React.forwardRef(function AvatarUpload2({
|
|
|
312
312
|
});
|
|
313
313
|
AvatarUpload.displayName = "AvatarUpload";
|
|
314
314
|
function MenuItem({ icon, label, onClick, danger }) {
|
|
315
|
-
const [hover, setHover] = React.useState(false);
|
|
316
315
|
return /* @__PURE__ */ jsxs(
|
|
317
316
|
"button",
|
|
318
317
|
{
|
|
319
318
|
type: "button",
|
|
320
319
|
role: "menuitem",
|
|
320
|
+
className: "sereno-menuitem",
|
|
321
321
|
onClick,
|
|
322
|
-
onMouseEnter: () => setHover(true),
|
|
323
|
-
onMouseLeave: () => setHover(false),
|
|
324
322
|
style: sx({
|
|
325
323
|
display: "flex",
|
|
326
324
|
alignItems: "center",
|
|
@@ -330,7 +328,6 @@ function MenuItem({ icon, label, onClick, danger }) {
|
|
|
330
328
|
padding: "0 var(--space-3)",
|
|
331
329
|
border: "none",
|
|
332
330
|
borderRadius: "var(--radius-sm)",
|
|
333
|
-
background: hover ? "var(--bg-subtle)" : "transparent",
|
|
334
331
|
cursor: "pointer",
|
|
335
332
|
fontFamily: "var(--font-body)",
|
|
336
333
|
fontSize: "var(--text-sm)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/AvatarUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Camera, ImagePlus, Pencil, Trash2 } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { CaptureDialog, type Step } from './_internal/AvatarCaptureDialog';\n\n/**\n * Profile-photo picker: an avatar disc with a camera button. Pick from the\n * library (or the camera on touch), frame the face in a circular crop, and it\n * hands back a **cropped, downscaled** `File` (JPEG). For attachments / documents\n * / multiple files use `FileUpload` instead.\n *\n * Client-side only downscales and re-encodes; it does not decode HEIC (no\n * browser but Safari can) - that is a server-side job. HEIC picks are rejected\n * with a message.\n */\n/** User-facing strings - English by default; pass overrides for another locale. */\nexport interface AvatarUploadLabels {\n trigger: string;\n upload: string;\n takePhoto: string;\n remove: string;\n cropTitle: string;\n cropHint: string;\n cameraTitle: string;\n cameraHint: string;\n capture: string;\n /** On the crop step, only shown for a shot taken with the camera; reopens it directly. */\n retake: string;\n cancel: string;\n save: string;\n zoom: string;\n heicError: string;\n notImage: string;\n tooLarge: (mb: number) => string;\n unreadable: string;\n cameraError: string;\n}\n\nconst EN: AvatarUploadLabels = {\n trigger: 'Change photo',\n upload: 'Upload a photo',\n takePhoto: 'Take a photo',\n remove: 'Remove photo',\n cropTitle: 'Adjust the photo',\n cropHint: 'Drag to reposition · scroll to zoom.',\n cameraTitle: 'Take a photo',\n cameraHint: 'Line your face up with the circle.',\n capture: 'Capture',\n retake: 'Retake',\n cancel: 'Cancel',\n save: 'Save',\n zoom: 'Zoom',\n heicError: \"That format (HEIC) won't open in the browser, upload a JPG or PNG.\",\n notImage: 'Choose an image file.',\n tooLarge: (mb) => `The image is over ${mb} MB.`,\n unreadable: \"Couldn't read that image. Try a JPG or PNG.\",\n cameraError: \"Couldn't open the camera: upload a photo from your library instead.\",\n};\n\nexport interface AvatarUploadProps {\n /** Full name - drives the initials fallback and the alt text. */\n name?: string;\n /** Current photo: a `File` (freshly cropped) or an existing URL string. */\n value?: File | string | null;\n onChange?: (file: File | null) => void;\n /** Disc diameter in px. */\n size?: number;\n /** Exported square size in px - the crop is drawn to this. */\n outputSize?: number;\n /** Reject picks larger than this (before crop). */\n maxSizeMB?: number;\n /** Override the English UI strings (menu, crop dialog, messages). */\n labels?: Partial<AvatarUploadLabels>;\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /**\n * Whether to allow taking a photo via camera (default true).\n * Set to `false` when picking an organization or brand logo, where taking a\n * live selfie/photo makes no sense.\n */\n allowCamera?: boolean;\n}\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nconst isHeic = (f: File) => /image\\/heic|image\\/heif/i.test(f.type) || /\\.(heic|heif)$/i.test(f.name);\n\nexport const AvatarUpload = React.forwardRef<HTMLInputElement, AvatarUploadProps>(function AvatarUpload(\n {\n name = '',\n value,\n onChange,\n size = 96,\n outputSize = 512,\n maxSizeMB = 8,\n labels: labelsProp,\n label,\n hint,\n error,\n required,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n allowCamera = true,\n },\n forwardedRef,\n) {\n const t = React.useMemo<AvatarUploadLabels>(() => ({ ...EN, ...labelsProp }), [labelsProp]);\n const autoId = React.useId();\n const rid = id || autoId;\n const libRef = React.useRef<HTMLInputElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const [menuOpen, setMenuOpen] = React.useState(false);\n const [menuPos, setMenuPos] = React.useState<{ top: number; left: number } | null>(null);\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [cropSrc, setCropSrc] = React.useState<string | null>(null);\n // Whether the photo now in the crop step came from the camera. Only then does the crop\n // modal offer \"Retake\" (a library pick already has its own way to change: cancel and pick\n // another file from the system's own dialog).\n const [cropFromCamera, setCropFromCamera] = React.useState(false);\n const [cameraOpen, setCameraOpen] = React.useState(false);\n const [internal, setInternal] = React.useState<File | null>(null);\n\n const current = value !== undefined ? value : internal;\n\n // Preview URL for the current photo.\n const [preview, setPreview] = React.useState<string | null>(typeof current === 'string' ? current : null);\n React.useEffect(() => {\n if (current instanceof File) {\n const u = URL.createObjectURL(current);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an object URL\n setPreview(u);\n return () => URL.revokeObjectURL(u);\n }\n setPreview(typeof current === 'string' ? current : null);\n }, [current]);\n\n const itemCount = (allowCamera ? 1 : 0) + 1 + (current ? 1 : 0);\n\n const toggleMenu = () => {\n if (!allowCamera && !current) {\n libRef.current?.click();\n return;\n }\n if (menuOpen) {\n setMenuOpen(false);\n return;\n }\n const r = triggerRef.current?.getBoundingClientRect();\n if (r) {\n const h = itemCount * 40 + 8;\n const flipUp = r.bottom + 6 + h > window.innerHeight - 8;\n setMenuPos({\n top: flipUp ? Math.max(8, r.top - 6 - h) : r.bottom + 6,\n left: Math.max(8, Math.min(r.left, window.innerWidth - 208)),\n });\n }\n setMenuOpen(true);\n };\n\n // Close the menu on outside click / Escape / scroll - it is portalled to <body>.\n React.useEffect(() => {\n if (!menuOpen) return;\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;\n setMenuOpen(false);\n };\n const close = () => setMenuOpen(false);\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', close, true);\n window.addEventListener('resize', close);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', close, true);\n window.removeEventListener('resize', close);\n };\n }, [menuOpen]);\n\n // One dialog for the flow, on whichever step is current: the crop once there is a photo,\n // else the live camera. A shot or a Retake flips both at once, so the step just changes.\n // The `Dialog` it is drawn in already locks the page scroll and closes on Escape (through the\n // `onClose` handed to it below), so nothing here does: a second lock of our own used to be\n // released after the Dialog's and left the page unable to scroll (SS-402).\n const step: Step | null = cropSrc ? 'crop' : allowCamera && cameraOpen ? 'camera' : null;\n\n const pick = (files: FileList | null) => {\n const f = files?.[0];\n if (!f) return;\n if (isHeic(f)) {\n setRejected(t.heicError);\n return;\n }\n if (!f.type.startsWith('image/')) {\n setRejected(t.notImage);\n return;\n }\n if (f.size > maxSizeMB * 1048576) {\n setRejected(t.tooLarge(maxSizeMB));\n return;\n }\n const url = URL.createObjectURL(f);\n const probe = new Image();\n probe.onload = () => {\n setRejected(null);\n setCropFromCamera(false);\n setCropSrc(url);\n };\n probe.onerror = () => {\n URL.revokeObjectURL(url);\n setRejected(t.unreadable);\n };\n probe.src = url;\n };\n\n const commit = (file: File | null) => {\n if (value === undefined) setInternal(file);\n onChange?.(file);\n };\n\n const onCropSave = (blob: Blob) => {\n const file = new File([blob], 'avatar.jpg', { type: 'image/jpeg' });\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n commit(file);\n };\n const onCropCancel = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n };\n\n const onCameraShot = (blob: Blob) => {\n setCameraOpen(false);\n setRejected(null);\n setCropFromCamera(true);\n setCropSrc(URL.createObjectURL(blob));\n };\n\n // Straight back to the live camera, no menu in between: the crop modal's \"Retake\".\n const onRetake = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n setCameraOpen(true);\n };\n\n const cameraBtn = Math.max(30, Math.round(size * 0.34));\n\n // What `Field` shows as the error: the consumer's, or a rejected pick's (type, size, unreadable).\n const shownError = error || rejected || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree: the pencil is what takes focus.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input ref={mergeRefs(libRef, forwardedRef)} id={rid} type=\"file\" accept=\"image/*\" disabled={disabled} onChange={(e) => pick(e.target.files)} style={{ display: 'none' }} />\n\n <div style={sx({ position: 'relative', width: size, height: size, flex: '0 0 auto', opacity: disabled ? 0.6 : 1 })}>\n <span\n style={sx({\n width: size,\n height: size,\n borderRadius: '999px',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: preview ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n border: '1px solid ' + (preview ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontWeight: 'var(--weight-bold)',\n fontSize: Math.round(size * 0.34),\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {preview ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={preview} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name) || <ImagePlus size={Math.round(size * 0.3)} strokeWidth={1.75} />\n )}\n </span>\n\n {!disabled && (\n <button\n ref={triggerRef}\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={t.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n {...a11y}\n onClick={toggleMenu}\n style={sx({\n position: 'absolute',\n right: -2,\n bottom: -2,\n width: cameraBtn,\n height: cameraBtn,\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-sm)',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <Pencil size={Math.round(cameraBtn * 0.46)} strokeWidth={1.75} />\n </button>\n )}\n\n </div>\n\n {menuOpen &&\n menuPos &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n style={sx({\n position: 'fixed',\n top: menuPos.top,\n left: menuPos.left,\n minWidth: 200,\n zIndex: 1000,\n padding: 'var(--space-1)',\n borderRadius: 'var(--radius-md)',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-lg)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n <MenuItem\n icon={<ImagePlus size={16} strokeWidth={1.75} />}\n label={t.upload}\n onClick={() => {\n setMenuOpen(false);\n libRef.current?.click();\n }}\n />\n {allowCamera && (\n <MenuItem\n icon={<Camera size={16} strokeWidth={1.75} />}\n label={t.takePhoto}\n onClick={() => {\n setMenuOpen(false);\n setRejected(null);\n setCameraOpen(true);\n }}\n />\n )}\n {current && (\n <MenuItem\n icon={<Trash2 size={16} strokeWidth={1.75} />}\n label={t.remove}\n danger\n onClick={() => {\n setMenuOpen(false);\n commit(null);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n\n {step && (\n <CaptureDialog\n step={step}\n src={cropSrc}\n outputSize={outputSize}\n labels={t}\n onClose={step === 'camera' ? () => setCameraOpen(false) : onCropCancel}\n onCameraShot={onCameraShot}\n onCameraError={() => {\n setCameraOpen(false);\n setRejected(t.cameraError);\n }}\n onSave={onCropSave}\n onRetake={cropFromCamera ? onRetake : undefined}\n />\n )}\n </Field>\n );\n});\n\nAvatarUpload.displayName = 'AvatarUpload';\n\nfunction MenuItem({ icon, label, onClick, danger }: { icon: React.ReactNode; label: string; onClick: () => void; danger?: boolean }) {\n const [hover, setHover] = React.useState(false);\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={onClick}\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n minHeight: 40,\n padding: '0 var(--space-3)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: hover ? 'var(--bg-subtle)' : 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: danger ? 'var(--interactive-error)' : 'var(--text-primary)',\n textAlign: 'left',\n })}\n >\n {icon}\n {label}\n </button>\n );\n}\n"],"mappings":";AA0RM,cAEA,YAFA;AAxRN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,WAAW,QAAQ,cAAc;AAClD,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,qBAAgC;AAmCzC,MAAM,KAAyB;AAAA,EAC7B,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU,CAAC,OAAO,qBAAqB,EAAE;AAAA,EACzC,YAAY;AAAA,EACZ,aAAa;AACf;AAkCA,SAAS,SAAS,MAAsB;AACtC,UAAQ,QAAQ,IACb,KAAK,EACL,MAAM,KAAK,EACX,MAAM,GAAG,CAAC,EACV,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EACrB,KAAK,EAAE,EACP,YAAY;AACj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Z,KAAK;AAAA,QACL,OAAO;AAAA,QACP,WAAW;AAAA,QACX,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,YAAY,QAAQ,qBAAqB;AAAA,QACzC,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,OAAO,SAAS,6BAA6B;AAAA,QAC7C,WAAW;AAAA,MACb,CAAC;AAAA,MAEA;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["AvatarUpload"]}
|
|
1
|
+
{"version":3,"sources":["../../src/forms/AvatarUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Camera, ImagePlus, Pencil, Trash2 } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { CaptureDialog, type Step } from './_internal/AvatarCaptureDialog';\n\n/**\n * Profile-photo picker: an avatar disc with a camera button. Pick from the\n * library (or the camera on touch), frame the face in a circular crop, and it\n * hands back a **cropped, downscaled** `File` (JPEG). For attachments / documents\n * / multiple files use `FileUpload` instead.\n *\n * Client-side only downscales and re-encodes; it does not decode HEIC (no\n * browser but Safari can) - that is a server-side job. HEIC picks are rejected\n * with a message.\n */\n/** User-facing strings - English by default; pass overrides for another locale. */\nexport interface AvatarUploadLabels {\n trigger: string;\n upload: string;\n takePhoto: string;\n remove: string;\n cropTitle: string;\n cropHint: string;\n cameraTitle: string;\n cameraHint: string;\n capture: string;\n /** On the crop step, only shown for a shot taken with the camera; reopens it directly. */\n retake: string;\n cancel: string;\n save: string;\n zoom: string;\n heicError: string;\n notImage: string;\n tooLarge: (mb: number) => string;\n unreadable: string;\n cameraError: string;\n}\n\nconst EN: AvatarUploadLabels = {\n trigger: 'Change photo',\n upload: 'Upload a photo',\n takePhoto: 'Take a photo',\n remove: 'Remove photo',\n cropTitle: 'Adjust the photo',\n cropHint: 'Drag to reposition · scroll to zoom.',\n cameraTitle: 'Take a photo',\n cameraHint: 'Line your face up with the circle.',\n capture: 'Capture',\n retake: 'Retake',\n cancel: 'Cancel',\n save: 'Save',\n zoom: 'Zoom',\n heicError: \"That format (HEIC) won't open in the browser, upload a JPG or PNG.\",\n notImage: 'Choose an image file.',\n tooLarge: (mb) => `The image is over ${mb} MB.`,\n unreadable: \"Couldn't read that image. Try a JPG or PNG.\",\n cameraError: \"Couldn't open the camera: upload a photo from your library instead.\",\n};\n\nexport interface AvatarUploadProps {\n /** Full name - drives the initials fallback and the alt text. */\n name?: string;\n /** Current photo: a `File` (freshly cropped) or an existing URL string. */\n value?: File | string | null;\n onChange?: (file: File | null) => void;\n /** Disc diameter in px. */\n size?: number;\n /** Exported square size in px - the crop is drawn to this. */\n outputSize?: number;\n /** Reject picks larger than this (before crop). */\n maxSizeMB?: number;\n /** Override the English UI strings (menu, crop dialog, messages). */\n labels?: Partial<AvatarUploadLabels>;\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /**\n * Whether to allow taking a photo via camera (default true).\n * Set to `false` when picking an organization or brand logo, where taking a\n * live selfie/photo makes no sense.\n */\n allowCamera?: boolean;\n}\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nconst isHeic = (f: File) => /image\\/heic|image\\/heif/i.test(f.type) || /\\.(heic|heif)$/i.test(f.name);\n\nexport const AvatarUpload = React.forwardRef<HTMLInputElement, AvatarUploadProps>(function AvatarUpload(\n {\n name = '',\n value,\n onChange,\n size = 96,\n outputSize = 512,\n maxSizeMB = 8,\n labels: labelsProp,\n label,\n hint,\n error,\n required,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n allowCamera = true,\n },\n forwardedRef,\n) {\n const t = React.useMemo<AvatarUploadLabels>(() => ({ ...EN, ...labelsProp }), [labelsProp]);\n const autoId = React.useId();\n const rid = id || autoId;\n const libRef = React.useRef<HTMLInputElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const [menuOpen, setMenuOpen] = React.useState(false);\n const [menuPos, setMenuPos] = React.useState<{ top: number; left: number } | null>(null);\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [cropSrc, setCropSrc] = React.useState<string | null>(null);\n // Whether the photo now in the crop step came from the camera. Only then does the crop\n // modal offer \"Retake\" (a library pick already has its own way to change: cancel and pick\n // another file from the system's own dialog).\n const [cropFromCamera, setCropFromCamera] = React.useState(false);\n const [cameraOpen, setCameraOpen] = React.useState(false);\n const [internal, setInternal] = React.useState<File | null>(null);\n\n const current = value !== undefined ? value : internal;\n\n // Preview URL for the current photo.\n const [preview, setPreview] = React.useState<string | null>(typeof current === 'string' ? current : null);\n React.useEffect(() => {\n if (current instanceof File) {\n const u = URL.createObjectURL(current);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an object URL\n setPreview(u);\n return () => URL.revokeObjectURL(u);\n }\n setPreview(typeof current === 'string' ? current : null);\n }, [current]);\n\n const itemCount = (allowCamera ? 1 : 0) + 1 + (current ? 1 : 0);\n\n const toggleMenu = () => {\n if (!allowCamera && !current) {\n libRef.current?.click();\n return;\n }\n if (menuOpen) {\n setMenuOpen(false);\n return;\n }\n const r = triggerRef.current?.getBoundingClientRect();\n if (r) {\n const h = itemCount * 40 + 8;\n const flipUp = r.bottom + 6 + h > window.innerHeight - 8;\n setMenuPos({\n top: flipUp ? Math.max(8, r.top - 6 - h) : r.bottom + 6,\n left: Math.max(8, Math.min(r.left, window.innerWidth - 208)),\n });\n }\n setMenuOpen(true);\n };\n\n // Close the menu on outside click / Escape / scroll - it is portalled to <body>.\n React.useEffect(() => {\n if (!menuOpen) return;\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;\n setMenuOpen(false);\n };\n const close = () => setMenuOpen(false);\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', close, true);\n window.addEventListener('resize', close);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', close, true);\n window.removeEventListener('resize', close);\n };\n }, [menuOpen]);\n\n // One dialog for the flow, on whichever step is current: the crop once there is a photo,\n // else the live camera. A shot or a Retake flips both at once, so the step just changes.\n // The `Dialog` it is drawn in already locks the page scroll and closes on Escape (through the\n // `onClose` handed to it below), so nothing here does: a second lock of our own used to be\n // released after the Dialog's and left the page unable to scroll (SS-402).\n const step: Step | null = cropSrc ? 'crop' : allowCamera && cameraOpen ? 'camera' : null;\n\n const pick = (files: FileList | null) => {\n const f = files?.[0];\n if (!f) return;\n if (isHeic(f)) {\n setRejected(t.heicError);\n return;\n }\n if (!f.type.startsWith('image/')) {\n setRejected(t.notImage);\n return;\n }\n if (f.size > maxSizeMB * 1048576) {\n setRejected(t.tooLarge(maxSizeMB));\n return;\n }\n const url = URL.createObjectURL(f);\n const probe = new Image();\n probe.onload = () => {\n setRejected(null);\n setCropFromCamera(false);\n setCropSrc(url);\n };\n probe.onerror = () => {\n URL.revokeObjectURL(url);\n setRejected(t.unreadable);\n };\n probe.src = url;\n };\n\n const commit = (file: File | null) => {\n if (value === undefined) setInternal(file);\n onChange?.(file);\n };\n\n const onCropSave = (blob: Blob) => {\n const file = new File([blob], 'avatar.jpg', { type: 'image/jpeg' });\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n commit(file);\n };\n const onCropCancel = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n };\n\n const onCameraShot = (blob: Blob) => {\n setCameraOpen(false);\n setRejected(null);\n setCropFromCamera(true);\n setCropSrc(URL.createObjectURL(blob));\n };\n\n // Straight back to the live camera, no menu in between: the crop modal's \"Retake\".\n const onRetake = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n setCameraOpen(true);\n };\n\n const cameraBtn = Math.max(30, Math.round(size * 0.34));\n\n // What `Field` shows as the error: the consumer's, or a rejected pick's (type, size, unreadable).\n const shownError = error || rejected || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree: the pencil is what takes focus.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input ref={mergeRefs(libRef, forwardedRef)} id={rid} type=\"file\" accept=\"image/*\" disabled={disabled} onChange={(e) => pick(e.target.files)} style={{ display: 'none' }} />\n\n <div style={sx({ position: 'relative', width: size, height: size, flex: '0 0 auto', opacity: disabled ? 0.6 : 1 })}>\n <span\n style={sx({\n width: size,\n height: size,\n borderRadius: '999px',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: preview ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n border: '1px solid ' + (preview ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontWeight: 'var(--weight-bold)',\n fontSize: Math.round(size * 0.34),\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {preview ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={preview} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name) || <ImagePlus size={Math.round(size * 0.3)} strokeWidth={1.75} />\n )}\n </span>\n\n {!disabled && (\n <button\n ref={triggerRef}\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={t.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n {...a11y}\n onClick={toggleMenu}\n style={sx({\n position: 'absolute',\n right: -2,\n bottom: -2,\n width: cameraBtn,\n height: cameraBtn,\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-sm)',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <Pencil size={Math.round(cameraBtn * 0.46)} strokeWidth={1.75} />\n </button>\n )}\n\n </div>\n\n {menuOpen &&\n menuPos &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n style={sx({\n position: 'fixed',\n top: menuPos.top,\n left: menuPos.left,\n minWidth: 200,\n zIndex: 1000,\n padding: 'var(--space-1)',\n borderRadius: 'var(--radius-md)',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-lg)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n <MenuItem\n icon={<ImagePlus size={16} strokeWidth={1.75} />}\n label={t.upload}\n onClick={() => {\n setMenuOpen(false);\n libRef.current?.click();\n }}\n />\n {allowCamera && (\n <MenuItem\n icon={<Camera size={16} strokeWidth={1.75} />}\n label={t.takePhoto}\n onClick={() => {\n setMenuOpen(false);\n setRejected(null);\n setCameraOpen(true);\n }}\n />\n )}\n {current && (\n <MenuItem\n icon={<Trash2 size={16} strokeWidth={1.75} />}\n label={t.remove}\n danger\n onClick={() => {\n setMenuOpen(false);\n commit(null);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n\n {step && (\n <CaptureDialog\n step={step}\n src={cropSrc}\n outputSize={outputSize}\n labels={t}\n onClose={step === 'camera' ? () => setCameraOpen(false) : onCropCancel}\n onCameraShot={onCameraShot}\n onCameraError={() => {\n setCameraOpen(false);\n setRejected(t.cameraError);\n }}\n onSave={onCropSave}\n onRetake={cropFromCamera ? onRetake : undefined}\n />\n )}\n </Field>\n );\n});\n\nAvatarUpload.displayName = 'AvatarUpload';\n\nfunction MenuItem({ icon, label, onClick, danger }: { icon: React.ReactNode; label: string; onClick: () => void; danger?: boolean }) {\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n className=\"sereno-menuitem\"\n onClick={onClick}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n minHeight: 40,\n padding: '0 var(--space-3)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n cursor: 'pointer',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: danger ? 'var(--interactive-error)' : 'var(--text-primary)',\n textAlign: 'left',\n })}\n >\n {icon}\n {label}\n </button>\n );\n}\n"],"mappings":";AA0RM,cAEA,YAFA;AAxRN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,WAAW,QAAQ,cAAc;AAClD,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,qBAAgC;AAmCzC,MAAM,KAAyB;AAAA,EAC7B,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU,CAAC,OAAO,qBAAqB,EAAE;AAAA,EACzC,YAAY;AAAA,EACZ,aAAa;AACf;AAkCA,SAAS,SAAS,MAAsB;AACtC,UAAQ,QAAQ,IACb,KAAK,EACL,MAAM,KAAK,EACX,MAAM,GAAG,CAAC,EACV,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EACrB,KAAK,EAAE,EACP,YAAY;AACjB;AAEA,MAAM,SAAS,C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A,QACZ,UAAU;AAAA,QACV,OAAO,SAAS,6BAA6B;AAAA,QAC7C,WAAW;AAAA,MACb,CAAC;AAAA,MAEA;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["AvatarUpload"]}
|
package/dist/forms/Checkbox.js
CHANGED
|
@@ -3,8 +3,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { sx } from "../_internal/style.js";
|
|
5
5
|
import { mergeRefs } from "../_internal/mergeRefs.js";
|
|
6
|
+
import { choiceVars } from "./_internal/choiceVars.js";
|
|
6
7
|
const Checkbox = React.forwardRef(function Checkbox2({ label, description, error, checked, defaultChecked, disabled, indeterminate, size = "md", preserveHelperSpace = false, onChange, style, ...rest }, forwardedRef) {
|
|
7
|
-
const [hover, setHover] = React.useState(false);
|
|
8
8
|
const box = size === "sm" ? 16 : 20;
|
|
9
9
|
const innerRef = React.useRef(null);
|
|
10
10
|
React.useEffect(() => {
|
|
@@ -13,9 +13,8 @@ const Checkbox = React.forwardRef(function Checkbox2({ label, description, error
|
|
|
13
13
|
return /* @__PURE__ */ jsxs(
|
|
14
14
|
"label",
|
|
15
15
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
style: sx({ display: "flex", gap: "var(--space-3)", alignItems: "flex-start", cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.6 : 1, ...style }),
|
|
16
|
+
className: "sereno-choice",
|
|
17
|
+
style: sx({ ...choiceVars(error), display: "flex", gap: "var(--space-3)", alignItems: "flex-start", cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.6 : 1, ...style }),
|
|
19
18
|
children: [
|
|
20
19
|
/* @__PURE__ */ jsx("span", { style: sx({ position: "relative", display: "inline-flex", flex: "0 0 auto", marginTop: size === "sm" ? 3 : 1 }), children: /* @__PURE__ */ jsx(
|
|
21
20
|
"input",
|
|
@@ -36,7 +35,9 @@ const Checkbox = React.forwardRef(function Checkbox2({ label, description, error
|
|
|
36
35
|
height: box,
|
|
37
36
|
margin: 0,
|
|
38
37
|
borderRadius: "var(--radius-sm)",
|
|
39
|
-
|
|
38
|
+
// The colour is the stylesheet's (`border-color` of `.sereno-check`), so the hover can change it.
|
|
39
|
+
borderWidth: "var(--border-width-emphasis)",
|
|
40
|
+
borderStyle: "solid",
|
|
40
41
|
// `backgroundColor`, not `background` - the shorthand would set an inline
|
|
41
42
|
// `background-size: auto` that overrides the `:checked` glyph scaling.
|
|
42
43
|
backgroundColor: "var(--bg-surface)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/Checkbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/** Opt-in control for consents and multi-select filters. Host must include the `.sereno-check:checked` and `.sereno-check:indeterminate` rules (see globals.css). */\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message - tints the box and the secondary line red. Replaces `description`. */\n error?: string;\n /** Mixed state - some but not all children selected. Visual only; a form still submits it as unchecked. */\n indeterminate?: boolean;\n /** Box size. `sm` (16px) for dense filter lists; `md` (20px) everywhere else. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set - keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, description, error, checked, defaultChecked, disabled, indeterminate, size = 'md', preserveHelperSpace = false, onChange, style, ...rest },\n forwardedRef,\n) {\n const
|
|
1
|
+
{"version":3,"sources":["../../src/forms/Checkbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { choiceVars } from './_internal/choiceVars';\n\n/** Opt-in control for consents and multi-select filters. Host must include the `.sereno-check:checked` and `.sereno-check:indeterminate` rules (see globals.css). */\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message - tints the box and the secondary line red. Replaces `description`. */\n error?: string;\n /** Mixed state - some but not all children selected. Visual only; a form still submits it as unchecked. */\n indeterminate?: boolean;\n /** Box size. `sm` (16px) for dense filter lists; `md` (20px) everywhere else. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set - keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, description, error, checked, defaultChecked, disabled, indeterminate, size = 'md', preserveHelperSpace = false, onChange, style, ...rest },\n forwardedRef,\n) {\n const box = size === 'sm' ? 16 : 20;\n const innerRef = React.useRef<HTMLInputElement>(null);\n // `indeterminate` is a DOM property, not an attribute - set it imperatively, and\n // re-assert on every render so a `checked` change never leaves it stale.\n React.useEffect(() => {\n if (innerRef.current) innerRef.current.indeterminate = Boolean(indeterminate);\n });\n return (\n <label\n className=\"sereno-choice\"\n // The border colours `.sereno-check` (styles.css) paints, idle and while the pointer is on the row (SS-577).\n style={sx({ ...choiceVars(error), display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n ref={mergeRefs(innerRef, forwardedRef)}\n type=\"checkbox\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n // Only the state: the error line is inside the <label>, so it is already part of the\n // name. `aria-describedby` would read it twice.\n aria-invalid={error ? true : rest['aria-invalid']}\n data-size={size}\n className=\"sereno-check\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-sm)',\n // The colour is the stylesheet's (`border-color` of `.sereno-check`), so the hover can change it.\n borderWidth: 'var(--border-width-emphasis)',\n borderStyle: 'solid',\n // `backgroundColor`, not `background` - the shorthand would set an inline\n // `background-size: auto` that overrides the `:checked` glyph scaling.\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {(description || error || preserveHelperSpace) && (\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n lineHeight: 1.45,\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n })}\n >\n {error || description}\n </span>\n )}\n </span>\n </label>\n );\n});\n\nCheckbox.displayName = 'Checkbox';"],"mappings":";AA4CQ,cA8BF,YA9BE;AA1CR,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAqBpB,MAAM,WAAW,MAAM,WAA4C,SAASA,UACjF,EAAE,OAAO,aAAa,OAAO,SAAS,gBAAgB,UAAU,eAAe,OAAO,MAAM,sBAAsB,OAAO,UAAU,OAAO,GAAG,KAAK,GAClJ,cACA;AACA,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,QAAM,WAAW,MAAM,OAAyB,IAAI;AAGpD,QAAM,UAAU,MAAM;AACpB,QAAI,SAAS,QAAS,UAAS,QAAQ,gBAAgB,QAAQ,aAAa;AAA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C;AAAA,cACnE,CAAC;AAAA,cAEA,mBAAS;AAAA;AAAA,UACZ;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,SAAS,cAAc;","names":["Checkbox"]}
|
package/dist/forms/Radio.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { sx } from "../_internal/style.js";
|
|
5
|
+
import { choiceVars } from "./_internal/choiceVars.js";
|
|
5
6
|
const Radio = React.forwardRef(function Radio2({ label, description, error, checked, defaultChecked, disabled, size = "md", preserveHelperSpace = false, onChange, style, ...rest }, ref) {
|
|
6
|
-
const [hover, setHover] = React.useState(false);
|
|
7
7
|
const box = size === "sm" ? 16 : 20;
|
|
8
8
|
return /* @__PURE__ */ jsxs(
|
|
9
9
|
"label",
|
|
10
10
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
style: sx({ display: "flex", gap: "var(--space-3)", alignItems: "flex-start", cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.6 : 1, ...style }),
|
|
11
|
+
className: "sereno-choice",
|
|
12
|
+
style: sx({ ...choiceVars(error), display: "flex", gap: "var(--space-3)", alignItems: "flex-start", cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.6 : 1, ...style }),
|
|
14
13
|
children: [
|
|
15
14
|
/* @__PURE__ */ jsx("span", { style: sx({ position: "relative", display: "inline-flex", flex: "0 0 auto", marginTop: size === "sm" ? 3 : 1 }), children: /* @__PURE__ */ jsx(
|
|
16
15
|
"input",
|
|
@@ -30,7 +29,9 @@ const Radio = React.forwardRef(function Radio2({ label, description, error, chec
|
|
|
30
29
|
height: box,
|
|
31
30
|
margin: 0,
|
|
32
31
|
borderRadius: "var(--radius-pill)",
|
|
33
|
-
|
|
32
|
+
// The colour is the stylesheet's (`border-color` of `.sereno-radio`), so the hover can change it.
|
|
33
|
+
borderWidth: "var(--border-width-emphasis)",
|
|
34
|
+
borderStyle: "solid",
|
|
34
35
|
backgroundColor: "var(--bg-surface)",
|
|
35
36
|
cursor: "inherit",
|
|
36
37
|
transition: "var(--transition-control)"
|
package/dist/forms/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` - same 20px\n * box, same hover and label/description rhythm - differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n *\n * Wrap every group in a `<fieldset>` / `<legend>` - `name` alone makes the browser treat\n * the options as one native group (arrow keys move between them, only one can be checked),\n * but without a `<legend>` a screen reader has no accessible name for what the choice is\n * between, only \"Online, radio button, 1 of 3\" with no context.\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message - tints the circle and the secondary line red. Replaces `description`. */\n error?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set - keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport const Radio = React.forwardRef<HTMLInputElement, RadioProps>(function Radio(\n { label, description, error, checked, defaultChecked, disabled, size = 'md', preserveHelperSpace = false, onChange, style, ...rest },\n ref,\n) {\n const
|
|
1
|
+
{"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { choiceVars } from './_internal/choiceVars';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` - same 20px\n * box, same hover and label/description rhythm - differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n *\n * Wrap every group in a `<fieldset>` / `<legend>` - `name` alone makes the browser treat\n * the options as one native group (arrow keys move between them, only one can be checked),\n * but without a `<legend>` a screen reader has no accessible name for what the choice is\n * between, only \"Online, radio button, 1 of 3\" with no context.\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message - tints the circle and the secondary line red. Replaces `description`. */\n error?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set - keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport const Radio = React.forwardRef<HTMLInputElement, RadioProps>(function Radio(\n { label, description, error, checked, defaultChecked, disabled, size = 'md', preserveHelperSpace = false, onChange, style, ...rest },\n ref,\n) {\n const box = size === 'sm' ? 16 : 20;\n return (\n <label\n className=\"sereno-choice\"\n // The border colours `.sereno-radio` (styles.css) paints, idle and while the pointer is on the row (SS-577).\n style={sx({ ...choiceVars(error), display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n ref={ref}\n type=\"radio\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-radio\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-pill)',\n // The colour is the stylesheet's (`border-color` of `.sereno-radio`), so the hover can change it.\n borderWidth: 'var(--border-width-emphasis)',\n borderStyle: 'solid',\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {(description || error || preserveHelperSpace) && (\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n lineHeight: 1.45,\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n })}\n >\n {error || description}\n </span>\n )}\n </span>\n </label>\n );\n});\n\nRadio.displayName = 'Radio';"],"mappings":";AA6CQ,cAyBF,YAzBE;AA3CR,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,kBAAkB;AA6BpB,MAAM,QAAQ,MAAM,WAAyC,SAASA,OAC3E,EAAE,OAAO,aAAa,OAAO,SAAS,gBAAgB,UAAU,OAAO,MAAM,sBAAsB,OAAO,UAAU,OAAO,GAAG,KAAK,GACnI,KACA;AACA,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MAEV,OAAO,GAAG,EAAE,GAAG,WAAW,KAAK,GAAG,SAAS,QAAQ,KAAK,kBAAkB,YAAY,cAAc,QAAQ,WAAW,gBAAgB,WAAW,SAAS,WAAW,MAAM,GAAG,GAAG,MAAM,CAAC;AAAA,MAEzL;AAAA,4BAAC,UAAK,OAAO,GAAG,EAAE,UAAU,YAAY,SAAS,eAAe,MAAM,YAAY,WAAW,SAAS,OAAO,IAAI,EAAE,CAAC,GAClH;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,MAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG;AAAA,YACJ,aAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,cAAc;AAAA;AAAA,cAEd,aAAa;AAAA,cACb,aAAa;AAAA,cACb,iBAAiB;AAAA,cACjB,QAAQ;AAAA,cACR,YAAY;AAAA,YACd,CAAC;AAAA;AAAA,QACH,GACF;AAAA,QACA,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,EAAE,CAAC,GACjE;AAAA,mBAAS,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,oBAAoB,OAAO,uBAAuB,YAAY,KAAK,CAAC,GAAI,iBAAM;AAAA,WAClJ,eAAe,SAAS,wBACxB;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,GAAG;AAAA,gBACR,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,OAAO,QAAQ,6BAA6B;AAAA,gBAC5C,YAAY;AAAA,gBACZ,WAAW,sBAAsB,gCAAgC;AAAA,cACnE,CAAC;AAAA,cAEA,mBAAS;AAAA;AAAA,UACZ;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,MAAM,cAAc;","names":["Radio"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The border colours of the box of a `Checkbox` or `Radio`, as the custom properties `.sereno-check` and
|
|
3
|
+
* `.sereno-radio` (styles.css) read: `--sd-bd` at rest and `--sd-bd-hover` while the pointer is on the row. An error
|
|
4
|
+
* keeps its own colour in both, so a hover does not hide it. Nothing is set without an error: the stylesheet's
|
|
5
|
+
* fallbacks (the strong border, then the brand one) are the idle and hover colours.
|
|
6
|
+
*/
|
|
7
|
+
declare function choiceVars(error: string | undefined): Record<string, string>;
|
|
8
|
+
|
|
9
|
+
export { choiceVars };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/_internal/choiceVars.ts"],"sourcesContent":["/**\n * The border colours of the box of a `Checkbox` or `Radio`, as the custom properties `.sereno-check` and\n * `.sereno-radio` (styles.css) read: `--sd-bd` at rest and `--sd-bd-hover` while the pointer is on the row. An error\n * keeps its own colour in both, so a hover does not hide it. Nothing is set without an error: the stylesheet's\n * fallbacks (the strong border, then the brand one) are the idle and hover colours.\n */\nexport function choiceVars(error: string | undefined): Record<string, string> {\n return error ? { '--sd-bd': 'var(--interactive-error)', '--sd-bd-hover': 'var(--interactive-error)' } : {};\n}\n"],"mappings":"AAMO,SAAS,WAAW,OAAmD;AAC5E,SAAO,QAAQ,EAAE,WAAW,4BAA4B,iBAAiB,2BAA2B,IAAI,CAAC;AAC3G;","names":[]}
|
|
@@ -3,7 +3,6 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ChevronDown } from "lucide-react";
|
|
5
5
|
import { sx } from "../../_internal/style.js";
|
|
6
|
-
import { useInteract } from "../../core/Button.js";
|
|
7
6
|
import { ParentDisabledContext, useSidebarNavContext } from "./sidebarNavContext.js";
|
|
8
7
|
import { SubmenuPopover } from "./SidebarSubmenuPopover.js";
|
|
9
8
|
const groupHead = sx({
|
|
@@ -69,7 +68,6 @@ function Item({ value, label, icon, count, href, disabled: disabledProp, childre
|
|
|
69
68
|
hideTip
|
|
70
69
|
} = useSidebarNavContext("Item");
|
|
71
70
|
const disabled = disabledProp ?? rootDisabled;
|
|
72
|
-
const st = useInteract(disabled);
|
|
73
71
|
const btnRef = React.useRef(null);
|
|
74
72
|
const labelRef = React.useRef(null);
|
|
75
73
|
const hasChildren = React.Children.count(children) > 0;
|
|
@@ -107,7 +105,10 @@ function Item({ value, label, icon, count, href, disabled: disabledProp, childre
|
|
|
107
105
|
fontFamily: "var(--font-body)",
|
|
108
106
|
fontSize: "var(--text-base)",
|
|
109
107
|
fontWeight: highlight || childActive ? "var(--weight-semibold)" : "var(--weight-medium)",
|
|
110
|
-
|
|
108
|
+
// The fill and its hover value, as custom properties `.sereno-sidenav-btn` (styles.css) switches between on `:hover`
|
|
109
|
+
// (SS-577). The current page keeps its own fill under the pointer, and a disabled row has no hover value.
|
|
110
|
+
"--sd-bg": highlight ? "var(--bg-brand-soft)" : open ? "var(--interactive-ghost-hover)" : "transparent",
|
|
111
|
+
"--sd-bg-hover": highlight || disabled ? void 0 : "var(--interactive-ghost-hover)",
|
|
111
112
|
color: disabled ? "var(--text-disabled)" : highlight || childActive ? "var(--text-brand)" : "var(--text-secondary)",
|
|
112
113
|
transition: "var(--transition-control)"
|
|
113
114
|
});
|
|
@@ -142,26 +143,19 @@ function Item({ value, label, icon, count, href, disabled: disabledProp, childre
|
|
|
142
143
|
] })
|
|
143
144
|
] });
|
|
144
145
|
const hoverHandlers = {
|
|
145
|
-
...st.handlers,
|
|
146
146
|
onMouseEnter: (e) => {
|
|
147
|
-
st.handlers.onMouseEnter?.(e);
|
|
148
147
|
if (railFlyout) openFlyout(value);
|
|
149
148
|
else showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
150
149
|
},
|
|
151
|
-
onMouseLeave: (
|
|
152
|
-
st.handlers.onMouseLeave?.(e);
|
|
150
|
+
onMouseLeave: () => {
|
|
153
151
|
if (railFlyout) closeFlyoutSoon();
|
|
154
152
|
else hideTip();
|
|
155
153
|
},
|
|
156
154
|
// Keyboard parity with hover - on the rail a Tab stop is otherwise just an unlabelled icon.
|
|
157
155
|
onFocus: (e) => {
|
|
158
|
-
st.handlers.onFocus?.(e);
|
|
159
156
|
if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
160
157
|
},
|
|
161
|
-
onBlur: (
|
|
162
|
-
st.handlers.onBlur?.(e);
|
|
163
|
-
hideTip();
|
|
164
|
-
},
|
|
158
|
+
onBlur: () => hideTip(),
|
|
165
159
|
// Dismissible without moving the pointer or focus (WCAG 1.4.13).
|
|
166
160
|
onKeyDown: (e) => {
|
|
167
161
|
if (e.key === "Escape") hideTip();
|
|
@@ -176,7 +170,7 @@ function Item({ value, label, icon, count, href, disabled: disabledProp, childre
|
|
|
176
170
|
Link,
|
|
177
171
|
{
|
|
178
172
|
href,
|
|
179
|
-
className: "sereno-sidenav-btn",
|
|
173
|
+
className: "sereno-sidenav-btn sereno-sidenav-row",
|
|
180
174
|
"aria-label": collapsed ? label : void 0,
|
|
181
175
|
"aria-current": selfActive ? "page" : void 0,
|
|
182
176
|
onClick: () => {
|
|
@@ -192,7 +186,7 @@ function Item({ value, label, icon, count, href, disabled: disabledProp, childre
|
|
|
192
186
|
{
|
|
193
187
|
ref: btnRef,
|
|
194
188
|
type: "button",
|
|
195
|
-
className: "sereno-sidenav-btn",
|
|
189
|
+
className: "sereno-sidenav-btn sereno-sidenav-row",
|
|
196
190
|
"aria-label": collapsed ? label : void 0,
|
|
197
191
|
"aria-current": selfActive ? "page" : void 0,
|
|
198
192
|
"aria-disabled": disabled || void 0,
|
|
@@ -233,12 +227,11 @@ function SubItem({ value, label, count, disabled: disabledProp, compact = false
|
|
|
233
227
|
const labelRef = React.useRef(null);
|
|
234
228
|
const disabled = disabledProp ?? parentDisabled ?? rootDisabled;
|
|
235
229
|
const active = activeValue === value;
|
|
236
|
-
const st = useInteract(disabled);
|
|
237
230
|
return /* @__PURE__ */ jsxs(
|
|
238
231
|
"button",
|
|
239
232
|
{
|
|
240
233
|
type: "button",
|
|
241
|
-
className: "sereno-sidenav-btn",
|
|
234
|
+
className: "sereno-sidenav-btn sereno-sidenav-row",
|
|
242
235
|
"aria-current": active ? "page" : void 0,
|
|
243
236
|
"aria-disabled": disabled || void 0,
|
|
244
237
|
tabIndex: disabled ? -1 : void 0,
|
|
@@ -246,23 +239,12 @@ function SubItem({ value, label, count, disabled: disabledProp, compact = false
|
|
|
246
239
|
hideTip();
|
|
247
240
|
if (!disabled) select(value);
|
|
248
241
|
},
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
},
|
|
242
|
+
onMouseEnter: (e) => showLabelTip(e.currentTarget, labelRef.current, label, showTip),
|
|
243
|
+
onMouseLeave: () => hideTip(),
|
|
258
244
|
onFocus: (e) => {
|
|
259
|
-
st.handlers.onFocus?.(e);
|
|
260
245
|
if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);
|
|
261
246
|
},
|
|
262
|
-
onBlur: (
|
|
263
|
-
st.handlers.onBlur?.(e);
|
|
264
|
-
hideTip();
|
|
265
|
-
},
|
|
247
|
+
onBlur: () => hideTip(),
|
|
266
248
|
onKeyDown: (e) => {
|
|
267
249
|
if (e.key === "Escape") hideTip();
|
|
268
250
|
},
|
|
@@ -280,7 +262,8 @@ function SubItem({ value, label, count, disabled: disabledProp, compact = false
|
|
|
280
262
|
fontFamily: "var(--font-body)",
|
|
281
263
|
fontSize: "var(--text-sm)",
|
|
282
264
|
fontWeight: active ? "var(--weight-semibold)" : "var(--weight-medium)",
|
|
283
|
-
|
|
265
|
+
"--sd-bg": active ? "var(--bg-brand-soft)" : "transparent",
|
|
266
|
+
"--sd-bg-hover": active || disabled ? void 0 : "var(--interactive-ghost-hover)",
|
|
284
267
|
color: disabled ? "var(--text-disabled)" : active ? "var(--text-brand)" : "var(--text-secondary)",
|
|
285
268
|
transition: "var(--transition-control)"
|
|
286
269
|
}),
|
|
@@ -1 +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,EACN,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,cAAc;AAAA;AAAA,EAEd,YAAY;AAAA,EACZ,OAAO,WAAW,yBAAyB,SAAS,sBAAsB;AAAA,EAC1E,WAAW,sBAAsB,WAAW,yBAAyB,SAAS,wBAAwB;AACxG,CAAC;AAGH,SAAS,cAAc,UAAqC;AAC1D,QAAM,MAAgB,CAAC;AACvB,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,QAAI,MAAM,eAAoC,KAAK,KAAK,OAAO,MAAM,MAAM,UAAU,SAAU,KAAI,KAAK,MAAM,MAAM,KAAK;AAAA,EAC3H,CAAC;AACD,SAAO;AACT;AAOA,SAAS,aAAa,KAAkB,SAA6B,OAAe,SAA4C;AAC9H,MAAI,WAAW,QAAQ,eAAe,QAAQ,YAAa;AAC3D,UAAQ,OAAO,IAAI,sBAAsB,CAAC;AAC5C;AAGA,SAAS,gBAAgB,IAA0B;AACjD,MAAI;AACF,WAAO,GAAG,QAAQ,gBAAgB;AAAA,EACpC,QAAQ;A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,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":[]}
|
|
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 { 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 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 // The fill and its hover value, as custom properties `.sereno-sidenav-btn` (styles.css) switches between on `:hover`\n // (SS-577). The current page keeps its own fill under the pointer, and a disabled row has no hover value.\n '--sd-bg': highlight ? 'var(--bg-brand-soft)' : open ? 'var(--interactive-ghost-hover)' : 'transparent',\n '--sd-bg-hover': highlight || disabled ? undefined : 'var(--interactive-ghost-hover)',\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 onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n if (railFlyout) openFlyout(value);\n else showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n },\n onMouseLeave: () => {\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 if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n },\n onBlur: () => hideTip(),\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 sereno-sidenav-row\"\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 sereno-sidenav-row\"\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 return (\n <button\n type=\"button\"\n className=\"sereno-sidenav-btn sereno-sidenav-row\"\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 onMouseEnter={(e) => showLabelTip(e.currentTarget, labelRef.current, label, showTip)}\n onMouseLeave={() => hideTip()}\n onFocus={(e) => {\n if (isKeyboardFocus(e.currentTarget)) showLabelTip(e.currentTarget, labelRef.current, label, showTip);\n }}\n onBlur={() => hideTip()}\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 '--sd-bg': active ? 'var(--bg-brand-soft)' : 'transparent',\n '--sd-bg-hover': active || disabled ? undefined : 'var(--interactive-ghost-hover)',\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":";AA2GI,SAoGI,UAnGsB,KAD1B;AAzGJ,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,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,EACN,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,cAAc;AAAA;AAAA,EAEd,YAAY;AAAA,EACZ,OAAO,WAAW,yBAAyB,SAAS,sBAAsB;AAAA,EAC1E,WAAW,sBAAsB,WAAW,yBAAyB,SAAS,wBAAwB;AACxG,CAAC;AAGH,SAAS,cAAc,UAAqC;AAC1D,QAAM,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,YAAY,SAAS,2BAA2B;AAAA,QAChD,WAAW,SAAS,yBAAyB;AAAA,QAC7C,iBAAiB,UAAU,WAAW,SAAY;AAAA,QAClD,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":[]}
|
package/dist/styles.css
CHANGED
|
@@ -86,6 +86,47 @@
|
|
|
86
86
|
box-shadow: var(--sd-ring-h), var(--sd-drop-h), var(--focus-ring);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/* ActionCard: the ring and the fill, each with its hover value (`--sd-ring`, `--sd-ring-hover`, `--sd-bg`,
|
|
90
|
+
`--sd-bg-hover`). A disabled card has no hover value and the rules leave it out; the focus ring goes on top of
|
|
91
|
+
whichever ring the card is showing, hovered or not. */
|
|
92
|
+
.sereno-action {
|
|
93
|
+
background: var(--sd-bg);
|
|
94
|
+
box-shadow: var(--sd-ring);
|
|
95
|
+
}
|
|
96
|
+
.sereno-action:hover:where(:not(:disabled)) {
|
|
97
|
+
background: var(--sd-bg-hover, var(--sd-bg));
|
|
98
|
+
box-shadow: var(--sd-ring-hover, var(--sd-ring));
|
|
99
|
+
}
|
|
100
|
+
.sereno-action:active:where(:not(:disabled)) {
|
|
101
|
+
transform: scale(var(--press-scale));
|
|
102
|
+
}
|
|
103
|
+
.sereno-action:focus-visible {
|
|
104
|
+
box-shadow: var(--sd-ring), var(--focus-ring);
|
|
105
|
+
}
|
|
106
|
+
.sereno-action:hover:focus-visible:where(:not(:disabled)) {
|
|
107
|
+
box-shadow: var(--sd-ring-hover, var(--sd-ring)), var(--focus-ring);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Checkbox / Radio: the border goes brand-coloured while the pointer is on the row (the whole label, text
|
|
111
|
+
included), unless the box is disabled or in error. The row declares the two colours as `--sd-bd` and
|
|
112
|
+
`--sd-bd-hover` (an error sets both to the error colour); `:checked` keeps its own `!important` fill below. */
|
|
113
|
+
.sereno-check,
|
|
114
|
+
.sereno-radio {
|
|
115
|
+
border-color: var(--sd-bd, var(--border-strong));
|
|
116
|
+
}
|
|
117
|
+
.sereno-choice:hover .sereno-check:where(:not(:disabled)),
|
|
118
|
+
.sereno-choice:hover .sereno-radio:where(:not(:disabled)) {
|
|
119
|
+
border-color: var(--sd-bd-hover, var(--border-brand));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* A row of a small menu with only a hover fill (the AvatarUpload actions). */
|
|
123
|
+
.sereno-menuitem {
|
|
124
|
+
background: transparent;
|
|
125
|
+
}
|
|
126
|
+
.sereno-menuitem:hover:where(:not(:disabled)) {
|
|
127
|
+
background: var(--bg-subtle);
|
|
128
|
+
}
|
|
129
|
+
|
|
89
130
|
/* ── Checkbox / Radio / Switch ───────────────────────────────────────────────
|
|
90
131
|
Checkbox and Radio render bare <input>s; Switch is a role="switch" <span>.
|
|
91
132
|
All three need these host rules for their checked / focus states. */
|
|
@@ -179,6 +220,12 @@
|
|
|
179
220
|
outline: 2px solid var(--border-focus);
|
|
180
221
|
outline-offset: -2px;
|
|
181
222
|
}
|
|
223
|
+
.sereno-sidenav-row {
|
|
224
|
+
background: var(--sd-bg, transparent);
|
|
225
|
+
}
|
|
226
|
+
.sereno-sidenav-row:hover {
|
|
227
|
+
background: var(--sd-bg-hover, var(--sd-bg, transparent));
|
|
228
|
+
}
|
|
182
229
|
.sereno-sidenav-toggle:hover {
|
|
183
230
|
background: var(--interactive-secondary-hover);
|
|
184
231
|
color: var(--text-primary);
|