@sereno-ds/ui 0.45.0 → 0.46.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 CHANGED
@@ -40,6 +40,8 @@ These components carry a class the stylesheet's state rules hang on:
40
40
  | the collapse control of `SidebarNav` | `sereno-sidenav-toggle` | |
41
41
  | `Input` (its row), `Textarea`, the boxes of `Select`, `DatePicker` and `Autocomplete` | `sereno-field` | `data-active` while a popup is open |
42
42
  | `Switch` | `sereno-switch` on the track, `sereno-switch-thumb` on the thumb | |
43
+ | each segment of a `Stepper` | `sereno-step` | `data-state` is `done`, `active` or `todo` |
44
+ | `Card` | `sereno-card` | `data-selected` when `selected` |
43
45
 
44
46
  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`:
45
47
 
@@ -58,7 +60,7 @@ The class names and the `data-` attributes are the styling hooks. The `--sd-*` c
58
60
 
59
61
  #### High contrast (forced colors)
60
62
 
61
- In Windows High Contrast (`forced-colors: active`) the browser replaces every colour with a system one and drops every `box-shadow`. `styles.css` has a block for that mode: the keyboard focus of `Button`, `IconButton`, `Card`, `ActionCard`, `Switch` and the text fields is drawn as a `Highlight` outline, and the `Switch` is drawn with a border and system fills (it has no other way to show up). Nothing there applies outside forced colors, and an `outline` rule of your own on those classes still wins by coming later. If you restyle a focus ring as a shadow, do the same for forced colors.
63
+ In Windows High Contrast (`forced-colors: active`) the browser replaces every colour with a system one and drops every `box-shadow`. `styles.css` has a block for that mode: the keyboard focus of `Button`, `IconButton`, `Card`, `ActionCard`, `Switch` and the text fields is drawn as a `Highlight` outline, and the `Switch` is drawn with a border and system fills (it has no other way to show up). Current, selected and checked states survive too: the current page of a `Pagination`, the current item of a `SidebarNav` or `BottomNav`, a selected `Tab` (an underline), a selected `Table` row and a selected `Card` or `ActionCard` (a heavier border in the selection colour), the segments of a `Stepper` (system fills) and a checked `Checkbox` or `Radio` (filled, with the mark drawn in the matching text colour). Nothing there applies outside forced colors, and a rule of your own on those classes still wins by coming later. If you restyle a focus ring or a selected state as a shadow or a fill, do the same for forced colors; and never put a `Highlight` fill behind text, the browser draws a box behind the letters in this mode.
62
64
 
63
65
  ### 2. Provide the fonts
64
66
 
@@ -50,7 +50,6 @@ function ActionCard({
50
50
  textAlign: "left",
51
51
  fontFamily: "var(--font-body)",
52
52
  color: "inherit",
53
- border: "none",
54
53
  borderRadius: "var(--radius-card)",
55
54
  cursor: disabled ? "not-allowed" : "pointer",
56
55
  transition: "var(--transition-control)",
@@ -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 { 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 ...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}\n"],"mappings":";AAkEyC,cA0DnC,YA1DmC;AA/DzC,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAmC3B,MAAM,WAAwG;AAAA,EAC5G,SAAS,EAAE,QAAQ,oBAAoB,QAAQ,yBAAyB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AAO;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA,QACZ,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":[]}
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 borderRadius: 'var(--radius-card)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\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}\n"],"mappings":";AAkEyC,cAyDnC,YAzDmC;AA/DzC,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAmC3B,MAAM,WAAwG;AAAA,EAC5G,SAAS,EAAE,QAAQ,oBAAoB,QAAQ,yBAAyB,MAAM,sBAAsB;AAAA,EACpG,SAAS,EAAE,QAAQ,8BAA8B,QAAQ,iCAAiC,MAAM,sBAAsB;AAAA,EACtH,OAAO,EAAE,QAAQ,0BAA0B,QAAQ,0BAA0B,MAAM,2BAA2B,OAAO,yBAAyB;AAChJ;AAMA,MAAM,YAAY,CAAC,SAAiB,wBAAwB,OAAO;AAE5D,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoB;AAClB,QAAM,IAAI,SAAS,OAAO,KAAK,SAAS;AACxC,QAAM,KAAK,aAAa;AACxB,QAAM,QAAQ,aAAa,SAAY,oBAAC,gBAAa,MAAM,IAAI,aAAa,MAAM,eAAW,MAAC,IAAK;AAKnG,QAAM,OAAO,KAAK,iBAAiB,EAAE,OAAO,gBAAgB,WAAW,yBAAyB;AAChG,QAAM,YAAY,KAAK,OAAO,eAAe,EAAE;AAE/C,QAAM,QAAQ,WAAW,EAAE,OAAO,uBAAuB,IAAI;AAC7D,QAAM,a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AAA,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/Card.js CHANGED
@@ -27,6 +27,7 @@ function Card({ padding = "md", elevation = "sm", interactive = false, selected
27
27
  className: ["sereno-card", className].filter(Boolean).join(" "),
28
28
  "data-interactive": interactive || void 0,
29
29
  "data-clickable": clickable || void 0,
30
+ "data-selected": selected || void 0,
30
31
  style: sx({
31
32
  "--sd-ring": ring,
32
33
  "--sd-ring-h": ringHover,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/Card.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Neutral surface container: a crisp 1px ring + optional soft lift + 14px radius. The base of every list row and panel. */\nexport interface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n padding?: 'none' | 'sm' | 'md' | 'lg';\n elevation?: 'none' | 'sm' | 'md' | 'lg';\n /** Adds hover lift, press scale and pointer cursor. */\n interactive?: boolean;\n /** Brand-coloured ring for a chosen option. */\n selected?: boolean;\n children?: React.ReactNode;\n}\n\nconst PADS = { none: 0, sm: 'var(--space-3)', md: 'var(--space-4)', lg: 'var(--space-5)' } as const;\n// The edge is a box-shadow ring (pixel-crisp at any radius), with the elevation\n// drop-shadow layered beneath it - never a real `border` fighting the shadow.\nconst DROP = { none: '', sm: 'var(--shadow-xs)', md: 'var(--shadow-md)', lg: 'var(--shadow-lg)' } as const;\n/** A shadow that draws nothing: lets `box-shadow: ring, drop` stay valid when there is no drop (`elevation=\"none\"`). */\nconst NO_SHADOW = '0 0 0 0 transparent';\n\nexport function Card({ padding = 'md', elevation = 'sm', interactive = false, selected = false, children, style, className, onClick, onKeyDown, ...rest }: CardProps) {\n // A Card only needs real button semantics (SS-228) when it owns its own\n // onClick - `interactive` alone (no onClick) means it's just borrowing the\n // hover/press visual inside an already-interactive wrapper (e.g. the\n // landing page's Cards inside a <Link>), and giving it a tabIndex there\n // would nest one focusable control inside another.\n const clickable = interactive && !!onClick;\n\n // The edge is a ring and the lift a drop shadow, each with its hover value. `.sereno-card` (styles.css)\n // switches between them on :hover / :active / :focus-visible (SS-577), so the card keeps no state.\n const ring = selected ? '0 0 0 1.5px var(--border-brand)' : '0 0 0 1px var(--border-default)';\n const ringHover = selected ? ring : '0 0 0 1px var(--border-strong)';\n const drop = (selected ? 'var(--shadow-md)' : DROP[elevation]) || NO_SHADOW;\n const dropHover = selected ? 'var(--shadow-md)' : elevation === 'lg' ? 'var(--shadow-lg)' : 'var(--shadow-md)';\n\n return (\n <div\n role={clickable ? 'button' : undefined}\n tabIndex={clickable ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n clickable\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n // Not a real MouseEvent - every onClick in this codebase ignores\n // the event argument, so the cast is safe in practice.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- see above\n onClick(e as any);\n }\n onKeyDown?.(e);\n }\n : onKeyDown\n }\n {...rest}\n className={['sereno-card', className].filter(Boolean).join(' ')}\n data-interactive={interactive || undefined}\n data-clickable={clickable || undefined}\n style={sx({\n '--sd-ring': ring,\n '--sd-ring-h': ringHover,\n '--sd-drop': drop,\n '--sd-drop-h': dropHover,\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-card)',\n padding: PADS[padding],\n transition: 'var(--transition-control)',\n cursor: interactive ? 'pointer' : 'default',\n ...style,\n })}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";AAuCI;AApCJ,SAAS,UAAU;AAanB,MAAM,OAAO,EAAE,MAAM,GAAG,IAAI,kBAAkB,IAAI,kBAAkB,IAAI,iBAAiB;AAGzF,MAAM,OAAO,EAAE,MAAM,IAAI,IAAI,oBAAoB,IAAI,oBAAoB,IAAI,mBAAmB;AAEhG,MAAM,YAAY;AAEX,SAAS,KAAK,EAAE,UAAU,MAAM,YAAY,MAAM,cAAc,OAAO,WAAW,OAAO,UAAU,OAAO,WAAW,SAAS,WAAW,GAAG,KAAK,GAAc;AAMpK,QAAM,YAAY,eAAe,CAAC,CAAC;AAInC,QAAM,OAAO,WAAW,oCAAoC;AAC5D,QAAM,YAAY,WAAW,OAAO;AACpC,QAAM,QAAQ,WAAW,qBAAqB,KAAK,SAAS,MAAM;AAClE,QAAM,YAAY,WAAW,qBAAqB,cAAc,OAAO,qBAAqB;AAE5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM,YAAY,WAAW;AAAA,MAC7B,UAAU,YAAY,IAAI;AAAA,MAC1B;AAAA,MACA,WACE,YACI,CAAC,MAAM;AACL,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,YAAE,eAAe;AAIjB,kBAAQ,CAAQ;AAAA,QAClB;AACA,oBAAY,CAAC;AAAA,MACf,IACA;AAAA,MAEL,GAAG;AAAA,MACJ,WAAW,CAAC,eAAe,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC9D,oBAAkB,eAAe;AAAA,MACjC,kBAAgB,aAAa;AAAA,MAC7B,OAAO,GAAG;AAAA,QACR,aAAa;AAAA,QACb,eAAe;AAAA,QACf,aAAa;AAAA,QACb,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,SAAS,KAAK,OAAO;AAAA,QACrB,YAAY;AAAA,QACZ,QAAQ,cAAc,YAAY;AAAA,QAClC,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/core/Card.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Neutral surface container: a crisp 1px ring + optional soft lift + 14px radius. The base of every list row and panel. */\nexport interface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n padding?: 'none' | 'sm' | 'md' | 'lg';\n elevation?: 'none' | 'sm' | 'md' | 'lg';\n /** Adds hover lift, press scale and pointer cursor. */\n interactive?: boolean;\n /** Brand-coloured ring for a chosen option. */\n selected?: boolean;\n children?: React.ReactNode;\n}\n\nconst PADS = { none: 0, sm: 'var(--space-3)', md: 'var(--space-4)', lg: 'var(--space-5)' } as const;\n// The edge is a box-shadow ring (pixel-crisp at any radius), with the elevation\n// drop-shadow layered beneath it - never a real `border` fighting the shadow.\nconst DROP = { none: '', sm: 'var(--shadow-xs)', md: 'var(--shadow-md)', lg: 'var(--shadow-lg)' } as const;\n/** A shadow that draws nothing: lets `box-shadow: ring, drop` stay valid when there is no drop (`elevation=\"none\"`). */\nconst NO_SHADOW = '0 0 0 0 transparent';\n\nexport function Card({ padding = 'md', elevation = 'sm', interactive = false, selected = false, children, style, className, onClick, onKeyDown, ...rest }: CardProps) {\n // A Card only needs real button semantics (SS-228) when it owns its own\n // onClick - `interactive` alone (no onClick) means it's just borrowing the\n // hover/press visual inside an already-interactive wrapper (e.g. the\n // landing page's Cards inside a <Link>), and giving it a tabIndex there\n // would nest one focusable control inside another.\n const clickable = interactive && !!onClick;\n\n // The edge is a ring and the lift a drop shadow, each with its hover value. `.sereno-card` (styles.css)\n // switches between them on :hover / :active / :focus-visible (SS-577), so the card keeps no state.\n const ring = selected ? '0 0 0 1.5px var(--border-brand)' : '0 0 0 1px var(--border-default)';\n const ringHover = selected ? ring : '0 0 0 1px var(--border-strong)';\n const drop = (selected ? 'var(--shadow-md)' : DROP[elevation]) || NO_SHADOW;\n const dropHover = selected ? 'var(--shadow-md)' : elevation === 'lg' ? 'var(--shadow-lg)' : 'var(--shadow-md)';\n\n return (\n <div\n role={clickable ? 'button' : undefined}\n tabIndex={clickable ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n clickable\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n // Not a real MouseEvent - every onClick in this codebase ignores\n // the event argument, so the cast is safe in practice.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- see above\n onClick(e as any);\n }\n onKeyDown?.(e);\n }\n : onKeyDown\n }\n {...rest}\n className={['sereno-card', className].filter(Boolean).join(' ')}\n data-interactive={interactive || undefined}\n data-clickable={clickable || undefined}\n data-selected={selected || undefined}\n style={sx({\n '--sd-ring': ring,\n '--sd-ring-h': ringHover,\n '--sd-drop': drop,\n '--sd-drop-h': dropHover,\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-card)',\n padding: PADS[padding],\n transition: 'var(--transition-control)',\n cursor: interactive ? 'pointer' : 'default',\n ...style,\n })}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";AAuCI;AApCJ,SAAS,UAAU;AAanB,MAAM,OAAO,EAAE,MAAM,GAAG,IAAI,kBAAkB,IAAI,kBAAkB,IAAI,iBAAiB;AAGzF,MAAM,OAAO,EAAE,MAAM,IAAI,IAAI,oBAAoB,IAAI,oBAAoB,IAAI,mBAAmB;AAEhG,MAAM,YAAY;AAEX,SAAS,KAAK,EAAE,UAAU,MAAM,YAAY,MAAM,cAAc,OAAO,WAAW,OAAO,UAAU,OAAO,WAAW,SAAS,WAAW,GAAG,KAAK,GAAc;AAMpK,QAAM,YAAY,eAAe,CAAC,CAAC;AAInC,QAAM,OAAO,WAAW,oCAAoC;AAC5D,QAAM,YAAY,WAAW,OAAO;AACpC,QAAM,QAAQ,WAAW,qBAAqB,KAAK,SAAS,MAAM;AAClE,QAAM,YAAY,WAAW,qBAAqB,cAAc,OAAO,qBAAqB;AAE5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM,YAAY,WAAW;AAAA,MAC7B,UAAU,YAAY,IAAI;AAAA,MAC1B;AAAA,MACA,WACE,YACI,CAAC,MAAM;AACL,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,YAAE,eAAe;AAIjB,kBAAQ,CAAQ;AAAA,QAClB;AACA,oBAAY,CAAC;AAAA,MACf,IACA;AAAA,MAEL,GAAG;AAAA,MACJ,WAAW,CAAC,eAAe,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC9D,oBAAkB,eAAe;AAAA,MACjC,kBAAgB,aAAa;AAAA,MAC7B,iBAAe,YAAY;AAAA,MAC3B,OAAO,GAAG;AAAA,QACR,aAAa;AAAA,QACb,eAAe;AAAA,QACf,aAAa;AAAA,QACb,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,SAAS,KAAK,OAAO;AAAA,QACrB,YAAY;AAAA,QACZ,QAAQ,cAAc,YAAY;AAAA,QAClC,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -77,12 +77,13 @@ function Step({ label, index }) {
77
77
  const done = i < current;
78
78
  const active = i === current;
79
79
  const reachable = typeof onStepClick === "function" && i <= current;
80
+ const state = done ? "done" : active ? "active" : "todo";
80
81
  const common = {
81
82
  flex: dots ? "0 0 auto" : 1,
82
83
  border: "none",
83
84
  padding: 0,
84
85
  cursor: reachable ? "pointer" : "default",
85
- background: done || active ? "var(--interactive-primary)" : "var(--border-default)",
86
+ "--sd-bg": done || active ? "var(--interactive-primary)" : "var(--border-default)",
86
87
  transition: "background-color var(--duration-normal) var(--ease-standard)"
87
88
  };
88
89
  return dots ? /* @__PURE__ */ jsx(
@@ -90,6 +91,8 @@ function Step({ label, index }) {
90
91
  {
91
92
  "aria-label": label,
92
93
  "aria-current": active ? "step" : void 0,
94
+ className: "sereno-step",
95
+ "data-state": state,
93
96
  disabled: !reachable,
94
97
  onClick: () => reachable && onStepClick(i),
95
98
  style: sx({
@@ -105,6 +108,8 @@ function Step({ label, index }) {
105
108
  {
106
109
  "aria-label": label,
107
110
  "aria-current": active ? "step" : void 0,
111
+ className: "sereno-step",
112
+ "data-state": state,
108
113
  disabled: !reachable,
109
114
  onClick: () => reachable && onStepClick(i),
110
115
  style: sx({ ...common, height: 3, borderRadius: "var(--radius-pill)" })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/navigation/Stepper.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Progress indicator for a linear multi-step flow - a **compound component**\n * (onboarding, guided setup). Renders the segment track plus a\n * `<counter> · <label>` line (a dot separates the counter from the current\n * step's label). The counter defaults to `Step N of M` - the DS ships no\n * localised copy; pass `stepLabel` for another language.\n *\n * ```tsx\n * <Stepper current={step} onStepClick={setStep}>\n * <Stepper.Step label=\"Your profile\" />\n * <Stepper.Step label=\"First service\" />\n * <Stepper.Step label=\"Your schedule\" />\n * </Stepper>\n * ```\n */\nexport interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Zero-based index of the active step. */\n current?: number;\n /** When provided, completed and current steps become clickable (back-navigation only). */\n onStepClick?: (index: number) => void;\n /** `bar` = full-width segments (desktop wizards). `dots` = compact pills (mobile). */\n variant?: 'bar' | 'dots';\n /**\n * Formats the step counter (both args 1-based / total). Default:\n * `` `Step ${current} of ${total}` ``. Return `null` to drop the counter and\n * show only the current step's `label`.\n */\n stepLabel?: (current: number, total: number) => React.ReactNode;\n children: React.ReactNode;\n}\n\nexport interface StepperStepProps {\n /** Stable identifier - not read by `Stepper` itself, only for the caller's own use (e.g. a React `key`). */\n value?: string;\n /** Short label - shown next to the step counter while this step is active. */\n label: string;\n /** Set by the root via `cloneElement` - this step's position among its siblings. Not for consumers to pass. */\n index?: number;\n}\n\ninterface StepperContextValue {\n current: number;\n onStepClick?: (index: number) => void;\n variant: 'bar' | 'dots';\n}\n\nconst defaultStepLabel = (current: number, total: number) => `Step ${current} of ${total}`;\n\nconst StepperContext = React.createContext<StepperContextValue | null>(null);\n\nfunction useStepperContext(component: string): StepperContextValue {\n const ctx = React.useContext(StepperContext);\n if (!ctx) throw new Error(`<Stepper.${component}> must be rendered inside <Stepper>.`);\n return ctx;\n}\n\nfunction StepperRoot({ current = 0, onStepClick, variant = 'bar', stepLabel = defaultStepLabel, children, style, ...rest }: StepperProps) {\n const dots = variant === 'dots';\n // Steps render their own segment (DOM order does the layout, like `Tabs.Tab`);\n // the root only needs each one's position (to compare against `current`) and,\n // for the line below the track, the active one's `label`.\n const items = React.Children.toArray(children) as React.ReactElement<StepperStepProps>[];\n const activeLabel = items[current]?.props.label;\n\n const ctx: StepperContextValue = { current, onStepClick, variant };\n\n return (\n <StepperContext.Provider value={ctx}>\n <div {...rest} style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)', ...style })}>\n <div style={sx({ display: 'flex', gap: dots ? 'var(--space-2)' : 'var(--space-1)', alignItems: 'center' })}>\n {items.map((child, i) => React.cloneElement(child, { index: i, key: child.key ?? i }))}\n </div>\n {activeLabel !== undefined && (\n <div\n key={current}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n minWidth: 0,\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-out)',\n })}\n >\n {(() => {\n const counter = stepLabel(current + 1, items.length);\n return counter == null ? null : (\n <>\n <span\n style={sx({\n flex: '0 0 auto',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-wide)',\n textTransform: 'uppercase',\n color: 'var(--text-muted)',\n })}\n >\n {counter}\n </span>\n <span aria-hidden style={sx({ flex: '0 0 auto', width: 3, height: 3, borderRadius: '999px', background: 'var(--border-strong)' })} />\n </>\n );\n })()}\n <span\n style={sx({\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n })}\n >\n {activeLabel}\n </span>\n </div>\n )}\n </div>\n </StepperContext.Provider>\n );\n}\n\nfunction Step({ label, index }: StepperStepProps) {\n const { current, onStepClick, variant } = useStepperContext('Step');\n const dots = variant === 'dots';\n const i = index ?? 0;\n const done = i < current;\n const active = i === current;\n const reachable = typeof onStepClick === 'function' && i <= current;\n const common = {\n flex: dots ? '0 0 auto' : 1,\n border: 'none',\n padding: 0,\n cursor: reachable ? 'pointer' : 'default',\n background: done || active ? 'var(--interactive-primary)' : 'var(--border-default)',\n transition: 'background-color var(--duration-normal) var(--ease-standard)',\n };\n return dots ? (\n <button\n aria-label={label}\n aria-current={active ? 'step' : undefined}\n disabled={!reachable}\n onClick={() => reachable && onStepClick!(i)}\n style={sx({\n ...common,\n width: active ? 24 : 8,\n height: 8,\n borderRadius: 'var(--radius-pill)',\n transition: `${common.transition}, width var(--duration-normal) var(--ease-standard)`,\n })}\n />\n ) : (\n <button\n aria-label={label}\n aria-current={active ? 'step' : undefined}\n disabled={!reachable}\n onClick={() => reachable && onStepClick!(i)}\n style={sx({ ...common, height: 3, borderRadius: 'var(--radius-pill)' })}\n />\n );\n}\n\nexport const Stepper = Object.assign(StepperRoot, { Step });\n"],"mappings":";AA0EQ,SAiBQ,UAjBR,KAiBQ,YAjBR;AAxER,YAAY,WAAW;AACvB,SAAS,UAAU;AAgDnB,MAAM,mBAAmB,CAAC,SAAiB,UAAkB,QAAQ,OAAO,OAAO,KAAK;AAExF,MAAM,iBAAiB,MAAM,cAA0C,IAAI;AAE3E,SAAS,kBAAkB,WAAwC;AACjE,QAAM,MAAM,MAAM,WAAW,cAAc;AAC3C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,YAAY,SAAS,sCAAsC;AACrF,SAAO;AACT;AAEA,SAAS,YAAY,EAAE,UAAU,GAAG,aAAa,UAAU,OAAO,YAAY,kBAAkB,UAAU,OAAO,GAAG,KAAK,GAAiB;AACxI,QAAM,OAAO,YAAY;AAIzB,QAAM,QAAQ,MAAM,SAAS,QAAQ,QAAQ;AAC7C,QAAM,cAAc,MAAM,OAAO,GAAG,MAAM;AAE1C,QAAM,MAA2B,EAAE,SAAS,aAAa,QAAQ;AAEjE,SACE,oBAAC,eAAe,UAAf,EAAwB,OAAO,KAC9B,+BAAC,SAAK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AAAA,MA3CK;AAAA,IA4CP;AAAA,KAEJ,GACF;AAEJ;AAEA,SAAS,KAAK,EAAE,OAAO,MAAM,GAAqB;AAChD,QAAM,EAAE,SAAS,aAAa,QAAQ,IAAI,kBAAkB,MAAM;AAClE,QAAM,OAAO,YAAY;AACzB,QAAM,IAAI,SAAS;AACnB,QAAM,OAAO,IAAI;AACjB,QAAM,SAAS,MAAM;AACrB,QAAM,YAAY,OAAO,gBAAgB,cAAc,KAAK;AAC5D,QAAM,SAAS;AAAA,IACb,MAAM,OAAO,aAAa;AAAA,IAC1B,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,QAAQ,YAAY,YAAY;AAAA,IAChC,YAAY,QAAQ,SAAS,+BAA+B;AAAA,IAC5D,YAAY;AAAA,EACd;AACA,SAAO,OACL;AAAA,IAAC;AAAA;AAAA,MACC,cAAY;AAAA,MACZ,gBAAc,SAAS,SAAS;AAAA,MAChC,UAAU,CAAC;AAAA,MACX,SAAS,MAAM,aAAa,YAAa,CAAC;AAAA,MAC1C,OAAO,GAAG;AAAA,QACR,GAAG;AAAA,QACH,OAAO,SAAS,KAAK;AAAA,QACrB,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,YAAY,GAAG,OAAO,UAAU;AAAA,MAClC,CAAC;AAAA;AAAA,EACH,IAEA;AAAA,IAAC;AAAA;AAAA,MACC,cAAY;AAAA,MACZ,gBAAc,SAAS,SAAS;AAAA,MAChC,UAAU,CAAC;AAAA,MACX,SAAS,MAAM,aAAa,YAAa,CAAC;AAAA,MAC1C,OAAO,GAAG,EAAE,GAAG,QAAQ,QAAQ,GAAG,cAAc,qBAAqB,CAAC;AAAA;AAAA,EACxE;AAEJ;AAEO,MAAM,UAAU,OAAO,OAAO,aAAa,EAAE,KAAK,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/navigation/Stepper.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Progress indicator for a linear multi-step flow - a **compound component**\n * (onboarding, guided setup). Renders the segment track plus a\n * `<counter> · <label>` line (a dot separates the counter from the current\n * step's label). The counter defaults to `Step N of M` - the DS ships no\n * localised copy; pass `stepLabel` for another language.\n *\n * ```tsx\n * <Stepper current={step} onStepClick={setStep}>\n * <Stepper.Step label=\"Your profile\" />\n * <Stepper.Step label=\"First service\" />\n * <Stepper.Step label=\"Your schedule\" />\n * </Stepper>\n * ```\n */\nexport interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Zero-based index of the active step. */\n current?: number;\n /** When provided, completed and current steps become clickable (back-navigation only). */\n onStepClick?: (index: number) => void;\n /** `bar` = full-width segments (desktop wizards). `dots` = compact pills (mobile). */\n variant?: 'bar' | 'dots';\n /**\n * Formats the step counter (both args 1-based / total). Default:\n * `` `Step ${current} of ${total}` ``. Return `null` to drop the counter and\n * show only the current step's `label`.\n */\n stepLabel?: (current: number, total: number) => React.ReactNode;\n children: React.ReactNode;\n}\n\nexport interface StepperStepProps {\n /** Stable identifier - not read by `Stepper` itself, only for the caller's own use (e.g. a React `key`). */\n value?: string;\n /** Short label - shown next to the step counter while this step is active. */\n label: string;\n /** Set by the root via `cloneElement` - this step's position among its siblings. Not for consumers to pass. */\n index?: number;\n}\n\ninterface StepperContextValue {\n current: number;\n onStepClick?: (index: number) => void;\n variant: 'bar' | 'dots';\n}\n\nconst defaultStepLabel = (current: number, total: number) => `Step ${current} of ${total}`;\n\nconst StepperContext = React.createContext<StepperContextValue | null>(null);\n\nfunction useStepperContext(component: string): StepperContextValue {\n const ctx = React.useContext(StepperContext);\n if (!ctx) throw new Error(`<Stepper.${component}> must be rendered inside <Stepper>.`);\n return ctx;\n}\n\nfunction StepperRoot({ current = 0, onStepClick, variant = 'bar', stepLabel = defaultStepLabel, children, style, ...rest }: StepperProps) {\n const dots = variant === 'dots';\n // Steps render their own segment (DOM order does the layout, like `Tabs.Tab`);\n // the root only needs each one's position (to compare against `current`) and,\n // for the line below the track, the active one's `label`.\n const items = React.Children.toArray(children) as React.ReactElement<StepperStepProps>[];\n const activeLabel = items[current]?.props.label;\n\n const ctx: StepperContextValue = { current, onStepClick, variant };\n\n return (\n <StepperContext.Provider value={ctx}>\n <div {...rest} style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)', ...style })}>\n <div style={sx({ display: 'flex', gap: dots ? 'var(--space-2)' : 'var(--space-1)', alignItems: 'center' })}>\n {items.map((child, i) => React.cloneElement(child, { index: i, key: child.key ?? i }))}\n </div>\n {activeLabel !== undefined && (\n <div\n key={current}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n minWidth: 0,\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-out)',\n })}\n >\n {(() => {\n const counter = stepLabel(current + 1, items.length);\n return counter == null ? null : (\n <>\n <span\n style={sx({\n flex: '0 0 auto',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-wide)',\n textTransform: 'uppercase',\n color: 'var(--text-muted)',\n })}\n >\n {counter}\n </span>\n <span aria-hidden style={sx({ flex: '0 0 auto', width: 3, height: 3, borderRadius: '999px', background: 'var(--border-strong)' })} />\n </>\n );\n })()}\n <span\n style={sx({\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n })}\n >\n {activeLabel}\n </span>\n </div>\n )}\n </div>\n </StepperContext.Provider>\n );\n}\n\nfunction Step({ label, index }: StepperStepProps) {\n const { current, onStepClick, variant } = useStepperContext('Step');\n const dots = variant === 'dots';\n const i = index ?? 0;\n const done = i < current;\n const active = i === current;\n const reachable = typeof onStepClick === 'function' && i <= current;\n // The fill is `background: var(--sd-bg)` in styles.css, and `data-state` is what the forced-colors rules key on\n // (an inline colour would beat them, and the browser forces every authored colour in that mode).\n const state = done ? 'done' : active ? 'active' : 'todo';\n const common = {\n flex: dots ? '0 0 auto' : 1,\n border: 'none',\n padding: 0,\n cursor: reachable ? 'pointer' : 'default',\n '--sd-bg': done || active ? 'var(--interactive-primary)' : 'var(--border-default)',\n transition: 'background-color var(--duration-normal) var(--ease-standard)',\n };\n return dots ? (\n <button\n aria-label={label}\n aria-current={active ? 'step' : undefined}\n className=\"sereno-step\"\n data-state={state}\n disabled={!reachable}\n onClick={() => reachable && onStepClick!(i)}\n style={sx({\n ...common,\n width: active ? 24 : 8,\n height: 8,\n borderRadius: 'var(--radius-pill)',\n transition: `${common.transition}, width var(--duration-normal) var(--ease-standard)`,\n })}\n />\n ) : (\n <button\n aria-label={label}\n aria-current={active ? 'step' : undefined}\n className=\"sereno-step\"\n data-state={state}\n disabled={!reachable}\n onClick={() => reachable && onStepClick!(i)}\n style={sx({ ...common, height: 3, borderRadius: 'var(--radius-pill)' })}\n />\n );\n}\n\nexport const Stepper = Object.assign(StepperRoot, { Step });\n"],"mappings":";AA0EQ,SAiBQ,UAjBR,KAiBQ,YAjBR;AAxER,YAAY,WAAW;AACvB,SAAS,UAAU;AAgDnB,MAAM,mBAAmB,CAAC,SAAiB,UAAkB,QAAQ,OAAO,OAAO,KAAK;AAExF,MAAM,iBAAiB,MAAM,cAA0C,IAAI;AAE3E,SAAS,kBAAkB,WAAwC;AACjE,QAAM,MAAM,MAAM,WAAW,cAAc;AAC3C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,YAAY,SAAS,sCAAsC;AACrF,SAAO;AACT;AAEA,SAAS,YAAY,EAAE,UAAU,GAAG,aAAa,UAAU,OAAO,YAAY,kBAAkB,UAAU,OAAO,GAAG,KAAK,GAAiB;AACxI,QAAM,OAAO,YAAY;AAIzB,QAAM,QAAQ,MAAM,SAAS,QAAQ,QAAQ;AAC7C,QAAM,cAAc,MAAM,OAAO,GAAG,MAAM;AAE1C,QAAM,MAA2B,EAAE,SAAS,aAAa,QAAQ;AAEjE,SAC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O,OAAO,aAAa,EAAE,KAAK,CAAC;","names":[]}
package/dist/styles.css CHANGED
@@ -97,6 +97,7 @@
97
97
  whichever ring the card is showing, hovered or not. */
98
98
  .sereno-action {
99
99
  outline: none;
100
+ border: none;
100
101
  background: var(--sd-bg);
101
102
  box-shadow: var(--sd-ring);
102
103
  }
@@ -273,6 +274,11 @@ textarea.sereno-field {
273
274
  border-color: var(--sd-bd-hover, var(--sd-bd));
274
275
  }
275
276
 
277
+ /* Stepper segment: its fill is a --sd-bg value so the forced-colors rules can restyle it by `data-state`. */
278
+ .sereno-step {
279
+ background: var(--sd-bg);
280
+ }
281
+
276
282
  /* ── In-field affix button ───────────────────────────────────────────────────
277
283
  A bare icon button that sits inside the field frame (Input's password reveal,
278
284
  SearchInput's clear, FileUpload / AvatarUpload actions). NOTE: the class is
@@ -523,7 +529,102 @@ textarea.sereno-field {
523
529
  .sereno-switch[aria-checked='true'] .sereno-switch-thumb {
524
530
  background: HighlightText;
525
531
  }
532
+ .sereno-switch[aria-disabled='true'][aria-checked='true'] {
533
+ background: GrayText;
534
+ }
526
535
  .sereno-switch[aria-disabled='true'] .sereno-switch-thumb {
527
536
  background: GrayText;
528
537
  }
538
+ .sereno-switch[aria-disabled='true'][aria-checked='true'] .sereno-switch-thumb {
539
+ background: Canvas;
540
+ }
541
+
542
+ /* ── Current, selected and checked states (#141) ────────────────────────────────────
543
+ A state told only by a fill or a shadow is lost in this mode, so each one gets a cue that survives. For anything
544
+ that carries TEXT the cue is a border, an underline or both, never a fill: Chromium draws a Canvas-coloured backplate
545
+ behind text on any non-Canvas fill in forced colors (white text on a white box), so `Highlight` behind a label
546
+ makes the label unreadable. A fill is used only where there is no text: the Stepper segments, a Checkbox, a Radio. */
547
+
548
+ /* The edge of a card is a shadow ring in the normal mode, which is dropped: give both cards a border, and the selected
549
+ one a heavier one in the selection colour. */
550
+ .sereno-card,
551
+ .sereno-action {
552
+ border: 1px solid CanvasText;
553
+ }
554
+ .sereno-card[data-selected],
555
+ .sereno-action[aria-pressed='true'] {
556
+ border: 3px solid Highlight;
557
+ }
558
+
559
+ /* The current page of a Pagination (a Button with aria-current). */
560
+ .sereno-btn[aria-current='page'] {
561
+ border: 3px solid Highlight;
562
+ text-decoration: underline;
563
+ }
564
+
565
+ /* The current item of a SidebarNav or a BottomNav, and the selected Tab. */
566
+ .sereno-sidenav-row[aria-current='page'],
567
+ .sereno-bottom-nav-item[aria-current='page'],
568
+ .sereno-tab[aria-selected='true'] {
569
+ text-decoration: underline Highlight 2px;
570
+ text-underline-offset: 4px;
571
+ }
572
+
573
+ /* A selected Table row: a rule above and below it in the selection colour. */
574
+ .sereno-table tbody tr[data-selected] td {
575
+ border-top: 2px solid Highlight;
576
+ border-bottom: 2px solid Highlight;
577
+ }
578
+
579
+ /* Stepper: done and current segments in the selection colour, the ones to come in the disabled one. */
580
+ .sereno-step[data-state='done'],
581
+ .sereno-step[data-state='active'] {
582
+ background: Highlight;
583
+ }
584
+ .sereno-step[data-state='todo'] {
585
+ background: GrayText;
586
+ }
587
+
588
+ /* Checkbox and Radio: the check, the dash and the dot are images or inset shadows in the normal mode, and both are lost.
589
+ Here the box is filled with the selection colour and the mark is drawn with borders, in the matching text colour, so it
590
+ reads on any palette. `!important` only here: the normal-mode rules for a checked box are `!important` themselves. */
591
+ .sereno-check,
592
+ .sereno-radio {
593
+ position: relative;
594
+ }
595
+ .sereno-check:checked,
596
+ .sereno-check:indeterminate,
597
+ .sereno-radio:checked {
598
+ background-color: Highlight !important;
599
+ background-image: none !important;
600
+ border-color: Highlight !important;
601
+ box-shadow: none !important;
602
+ }
603
+ .sereno-check:checked::after {
604
+ content: '';
605
+ position: absolute;
606
+ left: 32%;
607
+ top: 12%;
608
+ width: 30%;
609
+ height: 55%;
610
+ border: solid HighlightText;
611
+ border-width: 0 2px 2px 0;
612
+ transform: rotate(45deg);
613
+ }
614
+ .sereno-check:indeterminate::after {
615
+ content: '';
616
+ position: absolute;
617
+ left: 22%;
618
+ right: 22%;
619
+ top: calc(50% - 1px);
620
+ height: 2px;
621
+ background: HighlightText;
622
+ }
623
+ .sereno-radio:checked::after {
624
+ content: '';
625
+ position: absolute;
626
+ inset: 30%;
627
+ border-radius: 50%;
628
+ background: HighlightText;
629
+ }
529
630
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sereno-ds/ui",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "Sereno Design System: React primitives (token-driven, inline styles, no UI base lib).",
5
5
  "license": "MIT",
6
6
  "author": "Sereno",