@slurp-ui/react 1.1.0 → 1.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @slurp-ui/react
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 75167a1: Use context-neutral examples in the props documentation (no prices or product names).
8
+ - 239f077: Fix motion on touch screens and on narrow Docks:
9
+
10
+ - Button, Chip, Tile, Card and Rating lift, grow or tilt on hover only with a fine pointer (`(hover: hover) and (pointer: fine)`), so they no longer stay raised after a tap. Colour changes on hover are unchanged.
11
+ - Button, Tile and Card press in 120ms and release more softly (240ms for Button and Chip, 300ms for Tile and Card) instead of using one slow transition both ways.
12
+ - On phones, Dock crumbs before the current one shrink first (to a 44px target), so the current page keeps its name instead of collapsing to a letter.
13
+
14
+ - Updated dependencies [f3d9909]
15
+ - @slurp-ui/tokens@1.1.0
16
+
3
17
  ## 1.1.0
4
18
 
5
19
  ### Minor Changes
@@ -4,7 +4,7 @@ import { ElementType, ReactNode } from "react";
4
4
  export interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {
5
5
  title: ReactNode;
6
6
  description?: ReactNode;
7
- /** A value shown strong in the description pill ("1.239 €"). */
7
+ /** A value shown strong in the description pill ("9.1", "24"). */
8
8
  value?: ReactNode;
9
9
  /** Before the value ("da"). */
10
10
  valuePrefix?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","names":[],"sources":["../../src/Card/Card.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport { onColor } from '../lib/color';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {\n title: ReactNode;\n description?: ReactNode;\n /** A value shown strong in the description pill (\"1.239 €\"). */\n value?: ReactNode;\n /** Before the value (\"da\"). */\n valuePrefix?: ReactNode;\n /** Pill at the top right (\"−15%\"). */\n badge?: ReactNode;\n /** Tint (any hex); default the accent. */\n color?: string;\n /** The media in the middle (illustration, photo), decorative. */\n media?: ReactNode;\n /** Renders a link. */\n href?: string;\n}\n\nexport type CardProps<E extends ElementType = 'a'> = PolymorphicProps<E, CardOwnProps>;\n\n/**\n * One tinted rounded surface (like a Tile): the media in the middle, the title and description pills inside at the\n * bottom left, never covering it. A link with `href`, a button with `onClick`.\n */\nexport function Card<E extends ElementType = 'a'>(props: CardProps<E>) {\n const {\n as,\n css,\n className,\n title,\n description,\n value,\n valuePrefix,\n badge,\n color,\n media,\n href,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Card', props as CardProps);\n const Root = (as ?? (href ? 'a' : rest.onClick ? 'button' : 'div')) as ElementType;\n const styled = useCss('Card', 'root', css);\n const { part, style: partsStyle } = useParts('Card', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const vars = {\n ...(color\n ? {\n '--slurp-card-color': color,\n '--slurp-card-on': /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : 'var(--slurp-fg)',\n '--slurp-animation-tint': color,\n }\n : null),\n ...style,\n } as CSSProperties;\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-card', styled.className, className)}\n href={href}\n style={vars}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n {part('media', 'span', {\n className: 'slurp-card-media',\n 'aria-hidden': true,\n children: (\n <>\n <span className=\"slurp-stage-glow\" />\n <span className=\"slurp-stage-ring\" />\n {media != null && <span className=\"slurp-card-art\">{media}</span>}\n </>\n ),\n })}\n {badge != null && part('badge', 'span', { className: 'slurp-card-badge', children: badge })}\n {part('title', 'span', { className: 'slurp-card-title', children: title })}\n {(description != null || value != null) &&\n part('description', 'span', {\n className: 'slurp-card-description',\n children: (\n <>\n {description != null && <span>{description}</span>}\n {value != null && (\n <strong>\n {valuePrefix != null && <>{valuePrefix} </>}\n {value}\n </strong>\n )}\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,KAAkC,OAAqB;CACrE,MAAM,EACJ,IACA,KACA,WACA,OACA,aACA,OACA,aACA,OACA,OACA,OACA,MACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,OAAQ,OAAO,OAAO,MAAM,KAAK,UAAU,WAAW;CAC5D,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,EAAE,MAAM,OAAO,eAAe,SAAS,QAAQ;EAAE;EAAO;EAAW;CAAW,CAAC;CACrF,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,OAAO;EACX,GAAI,QACA;GACE,sBAAsB;GACtB,mBAAmB,kBAAkB,KAAK,KAAK,IAAI,QAAQ,KAAK,IAAI;GACpE,0BAA0B;EAC5B,IACA;EACJ,GAAG;CACL;CACA,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACjD;GACN,OAAO;GACP,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;GAC9C,GAAI;GALN,UAAA;IAOG,KAAK,SAAS,QAAQ;KACrB,WAAW;KACX,eAAe;KACf,UACE,qBAAA,UAAA,EAAA,UAAA;MACE,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA;MACpC,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA;MACnC,SAAS,QAAQ,oBAAC,QAAD;OAAM,WAAU;OAAkB,UAAA;MAAY,CAAA;KAChE,EAAA,CAAA;IAEN,CAAC;IACA,SAAS,QAAQ,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;IACzF,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;KACvE,eAAe,QAAQ,SAAS,SAChC,KAAK,eAAe,QAAQ;KAC1B,WAAW;KACX,UACE,qBAAA,UAAA,EAAA,UAAA,CACG,eAAe,QAAQ,oBAAC,QAAD,EAAA,UAAO,YAAkB,CAAA,GAChD,SAAS,QACR,qBAAC,UAAD,EAAA,UAAA,CACG,eAAe,QAAQ,qBAAA,UAAA,EAAA,UAAA,CAAG,aAAY,GAAG,EAAA,CAAA,GACzC,KACK,EAAA,CAAA,CAEV,EAAA,CAAA;IAEN,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Card.js","names":[],"sources":["../../src/Card/Card.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport { onColor } from '../lib/color';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {\n title: ReactNode;\n description?: ReactNode;\n /** A value shown strong in the description pill (\"9.1\", \"24\"). */\n value?: ReactNode;\n /** Before the value (\"da\"). */\n valuePrefix?: ReactNode;\n /** Pill at the top right (\"−15%\"). */\n badge?: ReactNode;\n /** Tint (any hex); default the accent. */\n color?: string;\n /** The media in the middle (illustration, photo), decorative. */\n media?: ReactNode;\n /** Renders a link. */\n href?: string;\n}\n\nexport type CardProps<E extends ElementType = 'a'> = PolymorphicProps<E, CardOwnProps>;\n\n/**\n * One tinted rounded surface (like a Tile): the media in the middle, the title and description pills inside at the\n * bottom left, never covering it. A link with `href`, a button with `onClick`.\n */\nexport function Card<E extends ElementType = 'a'>(props: CardProps<E>) {\n const {\n as,\n css,\n className,\n title,\n description,\n value,\n valuePrefix,\n badge,\n color,\n media,\n href,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Card', props as CardProps);\n const Root = (as ?? (href ? 'a' : rest.onClick ? 'button' : 'div')) as ElementType;\n const styled = useCss('Card', 'root', css);\n const { part, style: partsStyle } = useParts('Card', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const vars = {\n ...(color\n ? {\n '--slurp-card-color': color,\n '--slurp-card-on': /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : 'var(--slurp-fg)',\n '--slurp-animation-tint': color,\n }\n : null),\n ...style,\n } as CSSProperties;\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-card', styled.className, className)}\n href={href}\n style={vars}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n {part('media', 'span', {\n className: 'slurp-card-media',\n 'aria-hidden': true,\n children: (\n <>\n <span className=\"slurp-stage-glow\" />\n <span className=\"slurp-stage-ring\" />\n {media != null && <span className=\"slurp-card-art\">{media}</span>}\n </>\n ),\n })}\n {badge != null && part('badge', 'span', { className: 'slurp-card-badge', children: badge })}\n {part('title', 'span', { className: 'slurp-card-title', children: title })}\n {(description != null || value != null) &&\n part('description', 'span', {\n className: 'slurp-card-description',\n children: (\n <>\n {description != null && <span>{description}</span>}\n {value != null && (\n <strong>\n {valuePrefix != null && <>{valuePrefix} </>}\n {value}\n </strong>\n )}\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,KAAkC,OAAqB;CACrE,MAAM,EACJ,IACA,KACA,WACA,OACA,aACA,OACA,aACA,OACA,OACA,OACA,MACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,OAAQ,OAAO,OAAO,MAAM,KAAK,UAAU,WAAW;CAC5D,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,EAAE,MAAM,OAAO,eAAe,SAAS,QAAQ;EAAE;EAAO;EAAW;CAAW,CAAC;CACrF,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,OAAO;EACX,GAAI,QACA;GACE,sBAAsB;GACtB,mBAAmB,kBAAkB,KAAK,KAAK,IAAI,QAAQ,KAAK,IAAI;GACpE,0BAA0B;EAC5B,IACA;EACJ,GAAG;CACL;CACA,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACjD;GACN,OAAO;GACP,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;GAC9C,GAAI;GALN,UAAA;IAOG,KAAK,SAAS,QAAQ;KACrB,WAAW;KACX,eAAe;KACf,UACE,qBAAA,UAAA,EAAA,UAAA;MACE,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA;MACpC,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA;MACnC,SAAS,QAAQ,oBAAC,QAAD;OAAM,WAAU;OAAkB,UAAA;MAAY,CAAA;KAChE,EAAA,CAAA;IAEN,CAAC;IACA,SAAS,QAAQ,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;IACzF,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;KACvE,eAAe,QAAQ,SAAS,SAChC,KAAK,eAAe,QAAQ;KAC1B,WAAW;KACX,UACE,qBAAA,UAAA,EAAA,UAAA,CACG,eAAe,QAAQ,oBAAC,QAAD,EAAA,UAAO,YAAkB,CAAA,GAChD,SAAS,QACR,qBAAC,UAAD,EAAA,UAAA,CACG,eAAe,QAAQ,qBAAA,UAAA,EAAA,UAAA,CAAG,aAAY,GAAG,EAAA,CAAA,GACzC,KACK,EAAA,CAAA,CAEV,EAAA,CAAA;IAEN,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
@@ -10,7 +10,7 @@ export interface DockLabels {
10
10
  back: string;
11
11
  /** Name of the search field and of the phone search action. */
12
12
  search: string;
13
- /** Placeholder: say where it looks ("Cerca in Smartphone…"). */
13
+ /** Placeholder: say where it looks ("Cerca in Archivio…"). */
14
14
  searchPlaceholder: string;
15
15
  /** Find in page with no match. */
16
16
  noResults: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Dock.js","names":[],"sources":["../../src/Dock/Dock.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { CRUMB_TAN, crumbPath, type CrumbEnd } from '../lib/crumb';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst, moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\nimport { COMPACT_QUERY, useMediaQuery } from '../utils/useMediaQuery';\n\nexport interface DockLabels {\n /** Name of the navigation landmark. */\n navigation: string;\n /** Name of the breadcrumb list. */\n crumbs: string;\n /** Name of the back button. */\n back: string;\n /** Name of the search field and of the phone search action. */\n search: string;\n /** Placeholder: say where it looks (\"Cerca in Smartphone…\"). */\n searchPlaceholder: string;\n /** Find in page with no match. */\n noResults: string;\n /** Spoken count of find in page. */\n matches: (index: number, count: number) => string;\n /** Name of the \"2/5\" counter button. */\n nextMatch: (index: number, count: number) => string;\n /** How to move into results from the field. */\n resultsHint: string;\n}\n\nexport const DOCK_LABELS: DockLabels = {\n navigation: 'Navigazione',\n crumbs: 'Percorso',\n back: 'Indietro',\n search: 'Cerca',\n searchPlaceholder: 'Cerca…',\n noResults: 'Nessun risultato',\n matches: (i, n) => `${n === 1 ? '1 corrispondenza' : `${n} corrispondenze`}, ${i} di ${n}`,\n nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,\n resultsHint: 'Freccia giù per scorrere i risultati, Esc per chiuderli.',\n};\n\ninterface DockContextValue {\n compact: boolean;\n labels: DockLabels;\n panelId: string;\n panelInner: HTMLElement | null;\n /** The panel shows results (ArrowDown moves into them from the field). */\n hasPanel: boolean;\n searchOpen: boolean;\n setSearchOpen: (open: boolean) => void;\n searchInput: RefObject<HTMLInputElement | null>;\n focusResults: () => boolean;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nfunction useDock(name: string) {\n const ctx = useContext(DockContext);\n if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);\n return ctx;\n}\n\nexport interface DockOwnProps {\n /** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */\n children?: ReactNode;\n /** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */\n panel?: ReactNode;\n /** Name of the panel region (\"Filtri\"). */\n panelLabel?: string;\n /**\n * Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.\n */\n focusPanel?: boolean;\n /** A press outside, Escape or Tab out: close your panel here. */\n onDismiss?: () => void;\n /** In the flow (previews, docs) instead of fixed at the bottom. */\n inline?: boolean;\n labels?: Partial<DockLabels>;\n}\n\nexport type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;\n\n/**\n * The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search\n * and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press\n * outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.\n */\nfunction DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>) {\n const {\n as,\n css,\n className,\n children,\n panel,\n panelLabel,\n focusPanel = true,\n onDismiss,\n inline = false,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Dock', props as DockProps);\n const labels = { ...DOCK_LABELS, ...labelsProp };\n const compact = useMediaQuery(COMPACT_QUERY);\n const [searchOpen, setSearchOpen] = useState(false);\n const [panelInner, setPanelInner] = useState<HTMLElement | null>(null);\n const bar = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const searchInput = useRef<HTMLInputElement>(null);\n const panelId = `${useId()}-panel`;\n const searching = compact && searchOpen;\n const shown = searching ? null : panel;\n const open = searching || (panel != null && panel !== false);\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Dock', 'root', css);\n const root = useAnimationRoot(rest);\n\n const dismiss = useDismiss({\n ref: bar,\n open,\n onDismiss: () => {\n setSearchOpen(false);\n if (panel != null) onDismiss?.();\n },\n fallbackFocus: () => searchInput.current,\n });\n\n const { opened } = dismiss;\n\n // Menus and filters take focus when they open: the panel sits before the bar, Tab would never reach it.\n const hadPanel = useRef(false);\n useEffect(() => {\n const has = shown != null && shown !== false;\n if (has && !hadPanel.current && focusPanel) {\n // Escape gives focus back to the control that opened the panel.\n if (document.activeElement instanceof HTMLElement) opened(document.activeElement);\n focusFirst(panelRef.current);\n }\n hadPanel.current = has;\n }, [shown, focusPanel, opened]);\n\n const focusResults = () => !!moveFocusFirst(panelRef.current);\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-dock-wrap', styled.className, className)}\n data-inline={inline || undefined}\n aria-label={labels.navigation}\n {...root}\n >\n <div\n ref={bar}\n className=\"slurp-dock\"\n onKeyDown={dismiss.containerProps.onKeyDown}\n onBlur={dismiss.containerProps.onBlur}\n >\n <div\n ref={panelRef}\n id={panelId}\n className=\"slurp-dock-panel\"\n data-open={open || undefined}\n role={open ? 'region' : undefined}\n aria-label={open ? (searching ? labels.search : panelLabel) : undefined}\n inert={!open}\n onKeyDown={(e) =>\n moveFocus(e, panelRef.current, '[data-result]', () => searchInput.current?.focus())\n }\n >\n <div ref={setPanelInner} className=\"slurp-dock-panel-inner\">\n {shown}\n </div>\n </div>\n <DockContext\n value={{\n compact,\n labels,\n panelId,\n panelInner,\n hasPanel: shown != null && shown !== false,\n searchOpen: searching,\n setSearchOpen,\n searchInput,\n focusResults,\n }}\n >\n <div className=\"slurp-dock-row\">{children}</div>\n </DockContext>\n </div>\n </Root>\n </>\n );\n}\n\nfunction moveFocusFirst(root: HTMLElement | null) {\n const first = root?.querySelector<HTMLElement>('[data-result]');\n first?.focus();\n return first;\n}\n\n// ---------- Crumbs ----------\n\nconst CrumbPlace = createContext<{ first: boolean; last: boolean }>({ first: true, last: true });\n\nexport interface DockCrumbsProps {\n children?: ReactNode;\n /** Name of the list; default `labels.crumbs`. */\n label?: string;\n}\n\n/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */\nfunction DockCrumbs({ children, label }: DockCrumbsProps) {\n const { labels } = useDock('Dock.Crumbs');\n const items = Children.toArray(children).filter(isValidElement);\n return (\n <ol className=\"slurp-dock-crumbs\" aria-label={label ?? labels.crumbs}>\n {items.map((child, i) => (\n <CrumbPlace key={child.key ?? i} value={{ first: i === 0, last: i === items.length - 1 }}>\n <li>{child}</li>\n </CrumbPlace>\n ))}\n </ol>\n );\n}\n\ntype CrumbShapeProps = {\n left: CrumbEnd;\n right: CrumbEnd;\n className?: string;\n children?: ReactNode;\n} & Record<string, unknown>;\n\n/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */\nfunction CrumbShape({ left, right, className, children, ref, ...rest }: CrumbShapeProps) {\n const own = useRef<HTMLButtonElement>(null);\n const [size, setSize] = useState<{ w: number; h: number } | null>(null);\n const merged = useForkRef(ref as never, own);\n useLayoutEffect(() => {\n const el = own.current;\n if (!el || typeof ResizeObserver === 'undefined') return;\n const measure = () =>\n setSize((s) =>\n s && s.w === el.offsetWidth && s.h === el.offsetHeight\n ? s\n : { w: el.offsetWidth, h: el.offsetHeight },\n );\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const s = size ? size.h * CRUMB_TAN : 0;\n return (\n <button\n ref={merged}\n type=\"button\"\n className={cx('slurp-crumb', className)}\n data-drawn={size ? '' : undefined}\n data-left={left}\n data-right={right}\n {...rest}\n >\n {size && size.w > 0 && (\n <svg\n className=\"slurp-crumb-shape\"\n aria-hidden=\"true\"\n width={size.w + s}\n height={size.h}\n viewBox={`0 0 ${size.w + s} ${size.h}`}\n style={{ left: -s / 2 }}\n >\n <path d={crumbPath(size.w, size.h, left, right)} />\n </svg>\n )}\n {children}\n </button>\n );\n}\n\nexport type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n { label?: string }\n>;\n\n/** The back button: the first crumb (the root), round on the left. */\nfunction DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>) {\n const { label, className, css: _css, ...rest } = props as DockBackProps;\n const { labels } = useDock('Dock.Back');\n const { last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n return (\n <CrumbShape\n left=\"round\"\n right={last ? 'round' : 'slant'}\n className={cx('slurp-crumb-back', className)}\n aria-label={label ?? labels.back}\n data-crumb=\"0\"\n {...root}\n >\n <ArrowLeftIcon />\n </CrumbShape>\n );\n}\n\nexport interface DockCrumbOwnProps {\n /** The level's name. */\n children: ReactNode;\n /** The page you are on: accent-filled, `aria-current=\"page\"`. */\n current?: boolean;\n /** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */\n icon?: ReactNode;\n /** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */\n expanded?: boolean;\n}\n\nexport type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockCrumbOwnProps\n>;\n\n/** A level of the path. Every crumb triggers the transition: give it an animationId. */\nfunction DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>) {\n const {\n children,\n current = false,\n icon,\n expanded,\n className,\n css: _css,\n ...rest\n } = props as DockCrumbProps;\n const { compact, panelId } = useDock('Dock.Crumb');\n const { first, last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n const iconOnly = compact && !current && icon != null;\n const name = typeof children === 'string' ? children : undefined;\n return (\n <CrumbShape\n left={first ? 'round' : 'slant'}\n right={last ? 'round' : 'slant'}\n className={className}\n data-current={current || undefined}\n data-icon={iconOnly || undefined}\n aria-current={current ? 'page' : undefined}\n aria-label={iconOnly ? name : undefined}\n title={iconOnly ? name : undefined}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n {...root}\n >\n {iconOnly ? (\n <span className=\"slurp-crumb-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : (\n <span className=\"slurp-crumb-label\">{children}</span>\n )}\n {expanded !== undefined && (\n <span className=\"slurp-crumb-arrow\" data-up={expanded || undefined} aria-hidden=\"true\">\n <ArrowDownIcon size={16} />\n </span>\n )}\n </CrumbShape>\n );\n}\n\n// ---------- Search ----------\n\nexport interface DockSearchProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Name of the field; default `labels.search`. */\n label?: string;\n /** Default `labels.searchPlaceholder`: say where it looks. */\n placeholder?: string;\n /** Enter, when this is not find in page. */\n onSearch?: (value: string) => void;\n /** Find in page: how many matches (shows \"2/5\" or \"Nessun risultato\"). */\n count?: number;\n /** Find in page: the active match, 0-based. */\n index?: number;\n /** Find in page: Enter / Shift+Enter / a tap on the counter. */\n onStep?: (delta: 1 | -1) => void;\n}\n\n/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */\nfunction DockSearch({\n value: valueProp,\n defaultValue = '',\n onValueChange,\n label,\n placeholder,\n onSearch,\n count,\n index = 0,\n onStep,\n}: DockSearchProps) {\n const ctx = useDock('Dock.Search');\n const { labels } = ctx;\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const name = label ?? labels.search;\n const typed = value.trim() !== '';\n\n const counter =\n count != null && typed ? (\n <>\n {count ? (\n <button\n type=\"button\"\n className=\"slurp-dock-search-count\"\n aria-label={labels.nextMatch(index + 1, count)}\n onClick={(e) => {\n e.preventDefault();\n onStep?.(1);\n }}\n >\n {index + 1}/{count}\n </button>\n ) : (\n <span className=\"slurp-dock-search-count\" data-empty=\"\" aria-hidden=\"true\">\n {labels.noResults}\n </span>\n )}\n <span className=\"slurp-visually-hidden\" role=\"status\">\n {count ? labels.matches(index + 1, count) : labels.noResults}\n </span>\n </>\n ) : null;\n\n const field = (inPanel: boolean) => (\n <label className=\"slurp-dock-search\">\n <SearchIcon size={18} />\n <span className=\"slurp-visually-hidden\">{name}</span>\n <input\n ref={ctx.searchInput}\n type=\"search\"\n value={value}\n placeholder={placeholder ?? labels.searchPlaceholder}\n enterKeyHint={onStep ? 'next' : 'search'}\n autoComplete=\"off\"\n autoFocus={inPanel}\n aria-controls={ctx.hasPanel ? ctx.panelId : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n if (onStep) onStep(e.shiftKey ? -1 : 1);\n else onSearch?.(value);\n } else if (e.key === 'ArrowDown' && ctx.hasPanel && ctx.focusResults()) {\n e.preventDefault();\n }\n }}\n />\n {counter}\n </label>\n );\n\n if (!ctx.compact) return field(false);\n return (\n <>\n <DockAction\n label={typed ? `${name}: “${value.trim()}”` : name}\n expanded={ctx.searchOpen}\n dot={typed && !ctx.searchOpen}\n onClick={() => ctx.setSearchOpen(!ctx.searchOpen)}\n >\n <SearchIcon />\n </DockAction>\n {ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)}\n </>\n );\n}\n\n// ---------- Actions ----------\n\n/** Actions at the right end of the bar (search before filters). */\nfunction DockActions({ children }: { children?: ReactNode }) {\n return <div className=\"slurp-dock-actions\">{children}</div>;\n}\n\nexport interface DockActionOwnProps {\n /** Accessible name (\"Filtri\"); the count is added to it. */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Its panel is open: accent fill and aria-expanded. */\n expanded?: boolean;\n /** Badge count (active filters). */\n count?: number;\n /** How the count is said; default `${n} attivi`. */\n countLabel?: (count: number) => string;\n /** A small accent dot (a query is active while the search panel is closed). */\n dot?: boolean;\n}\n\nexport type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockActionOwnProps\n>;\n\n/** Round 48px action of the bar (filters, the phone search). */\nfunction DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>) {\n const {\n label,\n children,\n expanded,\n count,\n countLabel = (n) => (n === 1 ? '1 attivo' : `${n} attivi`),\n dot,\n className,\n css: _css,\n onClick,\n ...rest\n } = props as DockActionProps;\n const { panelId } = useDock('Dock.Action');\n const root = useAnimationRoot(rest);\n return (\n <button\n type=\"button\"\n className={cx('slurp-dock-action', className)}\n data-active={expanded || undefined}\n aria-label={count ? `${label}, ${countLabel(count)}` : label}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n onClick={onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined}\n {...root}\n >\n <span aria-hidden=\"true\" className=\"slurp-dock-action-icon\">\n {children}\n </span>\n {count ? (\n <span className=\"slurp-dock-action-count\" aria-hidden=\"true\">\n {count}\n </span>\n ) : null}\n {dot ? <span className=\"slurp-dock-action-dot\" aria-hidden=\"true\" /> : null}\n </button>\n );\n}\n\ntype DockComponent = typeof DockRoot & {\n Crumbs: typeof DockCrumbs;\n Back: typeof DockBack;\n Crumb: typeof DockCrumb;\n Search: typeof DockSearch;\n Actions: typeof DockActions;\n Action: typeof DockAction;\n};\n\nexport const Dock = Object.assign(DockRoot, {\n Crumbs: DockCrumbs,\n Back: DockBack,\n Crumb: DockCrumb,\n Search: DockSearch,\n Actions: DockActions,\n Action: DockAction,\n}) as DockComponent;\n\nexport { DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };\n"],"mappings":";;;;;;;;;;;;;;;AAoDA,MAAa,cAA0B;CACrC,YAAY;CACZ,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,mBAAmB;CACnB,WAAW;CACX,UAAU,GAAG,MAAM,GAAG,MAAM,IAAI,qBAAqB,GAAG,EAAE,iBAAiB,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AA,IAAY,UAAU,KAAA;EACzC;EACT,GAAI;EARN,UAAA;GAUE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC;GACG,CAAA;GACL,QACC,oBAAC,QAAD;IAAM,WAAU;IAA0B,eAAY;IACnD,UAAA;GACG,CAAA,IACJ;GACH,MAAM,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;GAAQ,CAAA,IAAI;EACjE;;AAEZ;AAWA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"Dock.js","names":[],"sources":["../../src/Dock/Dock.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { CRUMB_TAN, crumbPath, type CrumbEnd } from '../lib/crumb';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst, moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\nimport { COMPACT_QUERY, useMediaQuery } from '../utils/useMediaQuery';\n\nexport interface DockLabels {\n /** Name of the navigation landmark. */\n navigation: string;\n /** Name of the breadcrumb list. */\n crumbs: string;\n /** Name of the back button. */\n back: string;\n /** Name of the search field and of the phone search action. */\n search: string;\n /** Placeholder: say where it looks (\"Cerca in Archivio…\"). */\n searchPlaceholder: string;\n /** Find in page with no match. */\n noResults: string;\n /** Spoken count of find in page. */\n matches: (index: number, count: number) => string;\n /** Name of the \"2/5\" counter button. */\n nextMatch: (index: number, count: number) => string;\n /** How to move into results from the field. */\n resultsHint: string;\n}\n\nexport const DOCK_LABELS: DockLabels = {\n navigation: 'Navigazione',\n crumbs: 'Percorso',\n back: 'Indietro',\n search: 'Cerca',\n searchPlaceholder: 'Cerca…',\n noResults: 'Nessun risultato',\n matches: (i, n) => `${n === 1 ? '1 corrispondenza' : `${n} corrispondenze`}, ${i} di ${n}`,\n nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,\n resultsHint: 'Freccia giù per scorrere i risultati, Esc per chiuderli.',\n};\n\ninterface DockContextValue {\n compact: boolean;\n labels: DockLabels;\n panelId: string;\n panelInner: HTMLElement | null;\n /** The panel shows results (ArrowDown moves into them from the field). */\n hasPanel: boolean;\n searchOpen: boolean;\n setSearchOpen: (open: boolean) => void;\n searchInput: RefObject<HTMLInputElement | null>;\n focusResults: () => boolean;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nfunction useDock(name: string) {\n const ctx = useContext(DockContext);\n if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);\n return ctx;\n}\n\nexport interface DockOwnProps {\n /** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */\n children?: ReactNode;\n /** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */\n panel?: ReactNode;\n /** Name of the panel region (\"Filtri\"). */\n panelLabel?: string;\n /**\n * Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.\n */\n focusPanel?: boolean;\n /** A press outside, Escape or Tab out: close your panel here. */\n onDismiss?: () => void;\n /** In the flow (previews, docs) instead of fixed at the bottom. */\n inline?: boolean;\n labels?: Partial<DockLabels>;\n}\n\nexport type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;\n\n/**\n * The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search\n * and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press\n * outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.\n */\nfunction DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>) {\n const {\n as,\n css,\n className,\n children,\n panel,\n panelLabel,\n focusPanel = true,\n onDismiss,\n inline = false,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Dock', props as DockProps);\n const labels = { ...DOCK_LABELS, ...labelsProp };\n const compact = useMediaQuery(COMPACT_QUERY);\n const [searchOpen, setSearchOpen] = useState(false);\n const [panelInner, setPanelInner] = useState<HTMLElement | null>(null);\n const bar = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const searchInput = useRef<HTMLInputElement>(null);\n const panelId = `${useId()}-panel`;\n const searching = compact && searchOpen;\n const shown = searching ? null : panel;\n const open = searching || (panel != null && panel !== false);\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Dock', 'root', css);\n const root = useAnimationRoot(rest);\n\n const dismiss = useDismiss({\n ref: bar,\n open,\n onDismiss: () => {\n setSearchOpen(false);\n if (panel != null) onDismiss?.();\n },\n fallbackFocus: () => searchInput.current,\n });\n\n const { opened } = dismiss;\n\n // Menus and filters take focus when they open: the panel sits before the bar, Tab would never reach it.\n const hadPanel = useRef(false);\n useEffect(() => {\n const has = shown != null && shown !== false;\n if (has && !hadPanel.current && focusPanel) {\n // Escape gives focus back to the control that opened the panel.\n if (document.activeElement instanceof HTMLElement) opened(document.activeElement);\n focusFirst(panelRef.current);\n }\n hadPanel.current = has;\n }, [shown, focusPanel, opened]);\n\n const focusResults = () => !!moveFocusFirst(panelRef.current);\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-dock-wrap', styled.className, className)}\n data-inline={inline || undefined}\n aria-label={labels.navigation}\n {...root}\n >\n <div\n ref={bar}\n className=\"slurp-dock\"\n onKeyDown={dismiss.containerProps.onKeyDown}\n onBlur={dismiss.containerProps.onBlur}\n >\n <div\n ref={panelRef}\n id={panelId}\n className=\"slurp-dock-panel\"\n data-open={open || undefined}\n role={open ? 'region' : undefined}\n aria-label={open ? (searching ? labels.search : panelLabel) : undefined}\n inert={!open}\n onKeyDown={(e) =>\n moveFocus(e, panelRef.current, '[data-result]', () => searchInput.current?.focus())\n }\n >\n <div ref={setPanelInner} className=\"slurp-dock-panel-inner\">\n {shown}\n </div>\n </div>\n <DockContext\n value={{\n compact,\n labels,\n panelId,\n panelInner,\n hasPanel: shown != null && shown !== false,\n searchOpen: searching,\n setSearchOpen,\n searchInput,\n focusResults,\n }}\n >\n <div className=\"slurp-dock-row\">{children}</div>\n </DockContext>\n </div>\n </Root>\n </>\n );\n}\n\nfunction moveFocusFirst(root: HTMLElement | null) {\n const first = root?.querySelector<HTMLElement>('[data-result]');\n first?.focus();\n return first;\n}\n\n// ---------- Crumbs ----------\n\nconst CrumbPlace = createContext<{ first: boolean; last: boolean }>({ first: true, last: true });\n\nexport interface DockCrumbsProps {\n children?: ReactNode;\n /** Name of the list; default `labels.crumbs`. */\n label?: string;\n}\n\n/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */\nfunction DockCrumbs({ children, label }: DockCrumbsProps) {\n const { labels } = useDock('Dock.Crumbs');\n const items = Children.toArray(children).filter(isValidElement);\n return (\n <ol className=\"slurp-dock-crumbs\" aria-label={label ?? labels.crumbs}>\n {items.map((child, i) => (\n <CrumbPlace key={child.key ?? i} value={{ first: i === 0, last: i === items.length - 1 }}>\n <li>{child}</li>\n </CrumbPlace>\n ))}\n </ol>\n );\n}\n\ntype CrumbShapeProps = {\n left: CrumbEnd;\n right: CrumbEnd;\n className?: string;\n children?: ReactNode;\n} & Record<string, unknown>;\n\n/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */\nfunction CrumbShape({ left, right, className, children, ref, ...rest }: CrumbShapeProps) {\n const own = useRef<HTMLButtonElement>(null);\n const [size, setSize] = useState<{ w: number; h: number } | null>(null);\n const merged = useForkRef(ref as never, own);\n useLayoutEffect(() => {\n const el = own.current;\n if (!el || typeof ResizeObserver === 'undefined') return;\n const measure = () =>\n setSize((s) =>\n s && s.w === el.offsetWidth && s.h === el.offsetHeight\n ? s\n : { w: el.offsetWidth, h: el.offsetHeight },\n );\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const s = size ? size.h * CRUMB_TAN : 0;\n return (\n <button\n ref={merged}\n type=\"button\"\n className={cx('slurp-crumb', className)}\n data-drawn={size ? '' : undefined}\n data-left={left}\n data-right={right}\n {...rest}\n >\n {size && size.w > 0 && (\n <svg\n className=\"slurp-crumb-shape\"\n aria-hidden=\"true\"\n width={size.w + s}\n height={size.h}\n viewBox={`0 0 ${size.w + s} ${size.h}`}\n style={{ left: -s / 2 }}\n >\n <path d={crumbPath(size.w, size.h, left, right)} />\n </svg>\n )}\n {children}\n </button>\n );\n}\n\nexport type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n { label?: string }\n>;\n\n/** The back button: the first crumb (the root), round on the left. */\nfunction DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>) {\n const { label, className, css: _css, ...rest } = props as DockBackProps;\n const { labels } = useDock('Dock.Back');\n const { last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n return (\n <CrumbShape\n left=\"round\"\n right={last ? 'round' : 'slant'}\n className={cx('slurp-crumb-back', className)}\n aria-label={label ?? labels.back}\n data-crumb=\"0\"\n {...root}\n >\n <ArrowLeftIcon />\n </CrumbShape>\n );\n}\n\nexport interface DockCrumbOwnProps {\n /** The level's name. */\n children: ReactNode;\n /** The page you are on: accent-filled, `aria-current=\"page\"`. */\n current?: boolean;\n /** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */\n icon?: ReactNode;\n /** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */\n expanded?: boolean;\n}\n\nexport type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockCrumbOwnProps\n>;\n\n/** A level of the path. Every crumb triggers the transition: give it an animationId. */\nfunction DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>) {\n const {\n children,\n current = false,\n icon,\n expanded,\n className,\n css: _css,\n ...rest\n } = props as DockCrumbProps;\n const { compact, panelId } = useDock('Dock.Crumb');\n const { first, last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n const iconOnly = compact && !current && icon != null;\n const name = typeof children === 'string' ? children : undefined;\n return (\n <CrumbShape\n left={first ? 'round' : 'slant'}\n right={last ? 'round' : 'slant'}\n className={className}\n data-current={current || undefined}\n data-icon={iconOnly || undefined}\n aria-current={current ? 'page' : undefined}\n aria-label={iconOnly ? name : undefined}\n title={iconOnly ? name : undefined}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n {...root}\n >\n {iconOnly ? (\n <span className=\"slurp-crumb-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : (\n <span className=\"slurp-crumb-label\">{children}</span>\n )}\n {expanded !== undefined && (\n <span className=\"slurp-crumb-arrow\" data-up={expanded || undefined} aria-hidden=\"true\">\n <ArrowDownIcon size={16} />\n </span>\n )}\n </CrumbShape>\n );\n}\n\n// ---------- Search ----------\n\nexport interface DockSearchProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Name of the field; default `labels.search`. */\n label?: string;\n /** Default `labels.searchPlaceholder`: say where it looks. */\n placeholder?: string;\n /** Enter, when this is not find in page. */\n onSearch?: (value: string) => void;\n /** Find in page: how many matches (shows \"2/5\" or \"Nessun risultato\"). */\n count?: number;\n /** Find in page: the active match, 0-based. */\n index?: number;\n /** Find in page: Enter / Shift+Enter / a tap on the counter. */\n onStep?: (delta: 1 | -1) => void;\n}\n\n/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */\nfunction DockSearch({\n value: valueProp,\n defaultValue = '',\n onValueChange,\n label,\n placeholder,\n onSearch,\n count,\n index = 0,\n onStep,\n}: DockSearchProps) {\n const ctx = useDock('Dock.Search');\n const { labels } = ctx;\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const name = label ?? labels.search;\n const typed = value.trim() !== '';\n\n const counter =\n count != null && typed ? (\n <>\n {count ? (\n <button\n type=\"button\"\n className=\"slurp-dock-search-count\"\n aria-label={labels.nextMatch(index + 1, count)}\n onClick={(e) => {\n e.preventDefault();\n onStep?.(1);\n }}\n >\n {index + 1}/{count}\n </button>\n ) : (\n <span className=\"slurp-dock-search-count\" data-empty=\"\" aria-hidden=\"true\">\n {labels.noResults}\n </span>\n )}\n <span className=\"slurp-visually-hidden\" role=\"status\">\n {count ? labels.matches(index + 1, count) : labels.noResults}\n </span>\n </>\n ) : null;\n\n const field = (inPanel: boolean) => (\n <label className=\"slurp-dock-search\">\n <SearchIcon size={18} />\n <span className=\"slurp-visually-hidden\">{name}</span>\n <input\n ref={ctx.searchInput}\n type=\"search\"\n value={value}\n placeholder={placeholder ?? labels.searchPlaceholder}\n enterKeyHint={onStep ? 'next' : 'search'}\n autoComplete=\"off\"\n autoFocus={inPanel}\n aria-controls={ctx.hasPanel ? ctx.panelId : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n if (onStep) onStep(e.shiftKey ? -1 : 1);\n else onSearch?.(value);\n } else if (e.key === 'ArrowDown' && ctx.hasPanel && ctx.focusResults()) {\n e.preventDefault();\n }\n }}\n />\n {counter}\n </label>\n );\n\n if (!ctx.compact) return field(false);\n return (\n <>\n <DockAction\n label={typed ? `${name}: “${value.trim()}”` : name}\n expanded={ctx.searchOpen}\n dot={typed && !ctx.searchOpen}\n onClick={() => ctx.setSearchOpen(!ctx.searchOpen)}\n >\n <SearchIcon />\n </DockAction>\n {ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)}\n </>\n );\n}\n\n// ---------- Actions ----------\n\n/** Actions at the right end of the bar (search before filters). */\nfunction DockActions({ children }: { children?: ReactNode }) {\n return <div className=\"slurp-dock-actions\">{children}</div>;\n}\n\nexport interface DockActionOwnProps {\n /** Accessible name (\"Filtri\"); the count is added to it. */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Its panel is open: accent fill and aria-expanded. */\n expanded?: boolean;\n /** Badge count (active filters). */\n count?: number;\n /** How the count is said; default `${n} attivi`. */\n countLabel?: (count: number) => string;\n /** A small accent dot (a query is active while the search panel is closed). */\n dot?: boolean;\n}\n\nexport type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockActionOwnProps\n>;\n\n/** Round 48px action of the bar (filters, the phone search). */\nfunction DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>) {\n const {\n label,\n children,\n expanded,\n count,\n countLabel = (n) => (n === 1 ? '1 attivo' : `${n} attivi`),\n dot,\n className,\n css: _css,\n onClick,\n ...rest\n } = props as DockActionProps;\n const { panelId } = useDock('Dock.Action');\n const root = useAnimationRoot(rest);\n return (\n <button\n type=\"button\"\n className={cx('slurp-dock-action', className)}\n data-active={expanded || undefined}\n aria-label={count ? `${label}, ${countLabel(count)}` : label}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n onClick={onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined}\n {...root}\n >\n <span aria-hidden=\"true\" className=\"slurp-dock-action-icon\">\n {children}\n </span>\n {count ? (\n <span className=\"slurp-dock-action-count\" aria-hidden=\"true\">\n {count}\n </span>\n ) : null}\n {dot ? <span className=\"slurp-dock-action-dot\" aria-hidden=\"true\" /> : null}\n </button>\n );\n}\n\ntype DockComponent = typeof DockRoot & {\n Crumbs: typeof DockCrumbs;\n Back: typeof DockBack;\n Crumb: typeof DockCrumb;\n Search: typeof DockSearch;\n Actions: typeof DockActions;\n Action: typeof DockAction;\n};\n\nexport const Dock = Object.assign(DockRoot, {\n Crumbs: DockCrumbs,\n Back: DockBack,\n Crumb: DockCrumb,\n Search: DockSearch,\n Actions: DockActions,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ACL,SACA,GAAG,SACD;CACJ,MAAM,EAAE,YAAY,QAAQ,aAAa;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAC,UAAD;EACE,MAAK;EACL,WAAW,GAAG,qBAAqB,SAAS;EAC5C,eAAa,YAAY,KAAA;EACzB,cAAY,QAAQ,GAAG,MAAM,IAAI,WAAW,KAAK,MAAM;EACvD,iBAAe;EACf,iBAAe,aAAa,KAAA,IAAY,UAAU,KAAA;EACzC;EACT,GAAI;EARN,UAAA;GAUE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC;GACG,CAAA;GACL,QACC,oBAAC,QAAD;IAAM,WAAU;IAA0B,eAAY;IACnD,UAAA;GACG,CAAA,IACJ;GACH,MAAM,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;GAAQ,CAAA,IAAI;EACjE;;AAEZ;AAWA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;AACV,CAAC"}
@@ -9,7 +9,7 @@ export interface ListRowOwnProps extends PartsProps<'mark' | 'title' | 'tag' | '
9
9
  /** Leading mark (an icon, a logo); default the first letter of the title. */
10
10
  mark?: ReactNode;
11
11
  meta?: ReactNode;
12
- /** Trailing value ("9.1", "1.239 €"). */
12
+ /** Trailing value ("9.1", "24"). */
13
13
  value?: ReactNode;
14
14
  /** Highlight tag next to the title ("Consigliato"): with a check, never colour alone. */
15
15
  tag?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"ListRow.js","names":[],"sources":["../../src/ListRow/ListRow.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"1.239 €\"). */\n value?: ReactNode;\n /** Highlight tag next to the title (\"Consigliato\"): with a check, never colour alone. */\n tag?: ReactNode;\n /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */\n highlighted?: boolean;\n /** Text of the trailing link; the row's title is added for assistive tech. */\n actionLabel?: ReactNode;\n href?: string;\n}\n\nexport type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;\n\n/** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */\nexport function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>) {\n const {\n as,\n css,\n className,\n title,\n mark,\n meta,\n value,\n tag,\n highlighted = false,\n actionLabel,\n href,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('ListRow', props as ListRowProps);\n const inList = useContext(InList);\n const Root = (as ?? (inList ? 'li' : 'div')) as ElementType;\n const styled = useCss('ListRow', 'root', css);\n const { part, style } = useParts('ListRow', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const initial = typeof title === 'string' ? title.charAt(0) : null;\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-list-row', styled.className, className)}\n data-highlighted={highlighted || undefined}\n {...root}\n >\n {part('mark', 'span', {\n className: 'slurp-list-row-mark',\n 'aria-hidden': true,\n children: mark ?? initial,\n })}\n <span className=\"slurp-list-row-info\">\n {part('title', 'span', {\n className: 'slurp-list-row-title',\n children: (\n <>\n {title}\n {tag != null &&\n part('tag', 'span', {\n className: 'slurp-list-row-tag',\n children: (\n <>\n <CheckIcon size={12} />\n {tag}\n </>\n ),\n })}\n </>\n ),\n })}\n {meta != null &&\n part('meta', 'span', { className: 'slurp-list-row-meta', children: meta })}\n </span>\n {value != null &&\n part('value', 'span', { className: 'slurp-list-row-value', children: value })}\n {actionLabel != null &&\n part('action', 'a', {\n className: 'slurp-list-row-action',\n href: href ?? '#',\n // \"Vedi\" alone repeats on every row: the row's title completes the link's name.\n 'aria-label':\n typeof actionLabel === 'string' && typeof title === 'string'\n ? `${actionLabel} ${title}`\n : undefined,\n children: actionLabel,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,cAAc,KAAK;;AAKlC,SAAgB,KAAmC,OAAqB;CACtE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC1F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;EAClE,UAAA,oBAAC,QAAD;GAAQ,OAAO,SAAS,QAAQ,SAAS;GAAO;EAAiB,CAAA;CAC7D,CAAA,CACN,EAAA,CAAA;AAEN;;AAuBA,SAAgB,QAAuC,OAAwB;CAC7E,MAAM,EACJ,IACA,KACA,WACA,OACA,MACA,MACA,OACA,KACA,cAAc,OACd,aACA,MACA,OACA,WACA,YACA,GAAG,SACD,cAAc,WAAW,KAAqB;CACl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.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"24\"). */\n value?: ReactNode;\n /** Highlight tag next to the title (\"Consigliato\"): with a check, never colour alone. */\n tag?: ReactNode;\n /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */\n highlighted?: boolean;\n /** Text of the trailing link; the row's title is added for assistive tech. */\n actionLabel?: ReactNode;\n href?: string;\n}\n\nexport type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;\n\n/** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */\nexport function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>) {\n const {\n as,\n css,\n className,\n title,\n mark,\n meta,\n value,\n tag,\n highlighted = false,\n actionLabel,\n href,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('ListRow', props as ListRowProps);\n const inList = useContext(InList);\n const Root = (as ?? (inList ? 'li' : 'div')) as ElementType;\n const styled = useCss('ListRow', 'root', css);\n const { part, style } = useParts('ListRow', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const initial = typeof title === 'string' ? title.charAt(0) : null;\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-list-row', styled.className, className)}\n data-highlighted={highlighted || undefined}\n {...root}\n >\n {part('mark', 'span', {\n className: 'slurp-list-row-mark',\n 'aria-hidden': true,\n children: mark ?? initial,\n })}\n <span className=\"slurp-list-row-info\">\n {part('title', 'span', {\n className: 'slurp-list-row-title',\n children: (\n <>\n {title}\n {tag != null &&\n part('tag', 'span', {\n className: 'slurp-list-row-tag',\n children: (\n <>\n <CheckIcon size={12} />\n {tag}\n </>\n ),\n })}\n </>\n ),\n })}\n {meta != null &&\n part('meta', 'span', { className: 'slurp-list-row-meta', children: meta })}\n </span>\n {value != null &&\n part('value', 'span', { className: 'slurp-list-row-value', children: value })}\n {actionLabel != null &&\n part('action', 'a', {\n className: 'slurp-list-row-action',\n href: href ?? '#',\n // \"Vedi\" alone repeats on every row: the row's title completes the link's name.\n 'aria-label':\n typeof actionLabel === 'string' && typeof title === 'string'\n ? `${actionLabel} ${title}`\n : undefined,\n children: actionLabel,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,cAAc,KAAK;;AAKlC,SAAgB,KAAmC,OAAqB;CACtE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC1F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;EAClE,UAAA,oBAAC,QAAD;GAAQ,OAAO,SAAS,QAAQ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AK;KAClB,WAAW;KACX,MAAM,QAAQ;KAEd,cACE,OAAO,gBAAgB,YAAY,OAAO,UAAU,WAChD,GAAG,YAAY,GAAG,UAClB,KAAA;KACN,UAAU;IACZ,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
@@ -13,7 +13,7 @@ export interface RangeOwnProps extends PartsProps<'label' | 'value' | 'control'>
13
13
  max?: number;
14
14
  /** Default 1. */
15
15
  step?: number;
16
- /** Text of the value, shown next to the label and read by screen readers ("1.200 €"). */
16
+ /** Text of the value, shown next to the label and read by screen readers ("75%", "3 di 5"). */
17
17
  formatValue?: (value: number) => string;
18
18
  /** Shows the value next to the label. Default true. */
19
19
  showValue?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Range.js","names":[],"sources":["../../src/Range/Range.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type CSSProperties,\n type ElementType,\n type ReactNode,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface RangeOwnProps extends PartsProps<'label' | 'value' | 'control'> {\n /** Visible label. */\n label: ReactNode;\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n /** Default 0. */\n min?: number;\n /** Default 100. */\n max?: number;\n /** Default 1. */\n step?: number;\n /** Text of the value, shown next to the label and read by screen readers (\"1.200 €\"). */\n formatValue?: (value: number) => string;\n /** Shows the value next to the label. Default true. */\n showValue?: boolean;\n name?: string;\n disabled?: boolean;\n}\n\nexport type RangeProps<E extends ElementType = 'div'> = PolymorphicProps<E, RangeOwnProps>;\n\n/** Slider on a native range input: 44px thumb target, accent-ink fill, arrow keys / Page keys / Home / End. */\nexport function Range<E extends ElementType = 'div'>(props: RangeProps<E>) {\n const {\n as,\n css,\n className,\n label,\n value: valueProp,\n defaultValue,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n formatValue = String,\n showValue = true,\n name,\n disabled,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Range', props as RangeProps);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue: defaultValue ?? min,\n onChange: onValueChange,\n });\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Range', 'root', css);\n const { part, style: partsStyle } = useParts('Range', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const ratio = max > min ? (Math.min(max, Math.max(min, value)) - min) / (max - min) : 0;\n const text = formatValue(value);\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-range', styled.className, className)}\n data-disabled={disabled ? '' : undefined}\n style={{ '--slurp-range-ratio': ratio, ...style } as CSSProperties}\n {...root}\n >\n <div className=\"slurp-range-head\">\n {part('label', 'label', { htmlFor: id, className: 'slurp-range-label', children: label })}\n {showValue &&\n part('value', 'output', {\n htmlFor: id,\n className: 'slurp-range-value',\n children: text,\n })}\n </div>\n {part('control', 'input', {\n id,\n type: 'range',\n className: 'slurp-range-control',\n name,\n min,\n max,\n step,\n disabled,\n value,\n 'aria-valuetext': text,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(Number(e.target.value)),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqCA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EACJ,IACA,KACA,WACA,OACA,OAAO,WACP,cACA,eACA,MAAM,GACN,MAAM,KACN,OAAO,GACP,cAAc,QACd,YAAY,MACZ,MACA,UACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,CAAC,OAAO,YAAY,cAAc;EACtC,OAAO;EACP,cAAc,gBAAgB;EAC9B,UAAU;CACZ,CAAC;CACD,MAAM,KAAK,MAAM;CACjB,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,EAAE,MAAM,OAAO,eAAe,SAAS,SAAS;EAAE;EAAO;EAAW;CAAW,CAAC;CACtF,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,IAAI,QAAQ,MAAM,OAAO;CACtF,MAAM,OAAO,YAAY,KAAK;CAC9B,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;GACxD,iBAAe,WAAW,KAAK,KAAA;GAC/B,OAAO;IAAE,uBAAuB;IAAO,GAAG;GAAM;GAChD,GAAI;GAJN,UAAA,CAME,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,KAAK,SAAS,SAAS;KAAE,SAAS;KAAI,WAAW;KAAqB,UAAU;IAAM,CAAC,GACvF,aACC,KAAK,SAAS,UAAU;KACtB,SAAS;KACT,WAAW;KACX,UAAU;IACZ,CAAC,CACA;GACJ,CAAA,GAAA,KAAK,WAAW,SAAS;IACxB;IACA,MAAM;IACN,WAAW;IACX;IACA;IACA;IACA;IACA;IACA;IACA,kBAAkB;IAClB,WAAW,MAAqC,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;GACjF,CAAC,CACG;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Range.js","names":[],"sources":["../../src/Range/Range.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type CSSProperties,\n type ElementType,\n type ReactNode,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface RangeOwnProps extends PartsProps<'label' | 'value' | 'control'> {\n /** Visible label. */\n label: ReactNode;\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n /** Default 0. */\n min?: number;\n /** Default 100. */\n max?: number;\n /** Default 1. */\n step?: number;\n /** Text of the value, shown next to the label and read by screen readers (\"75%\", \"3 di 5\"). */\n formatValue?: (value: number) => string;\n /** Shows the value next to the label. Default true. */\n showValue?: boolean;\n name?: string;\n disabled?: boolean;\n}\n\nexport type RangeProps<E extends ElementType = 'div'> = PolymorphicProps<E, RangeOwnProps>;\n\n/** Slider on a native range input: 44px thumb target, accent-ink fill, arrow keys / Page keys / Home / End. */\nexport function Range<E extends ElementType = 'div'>(props: RangeProps<E>) {\n const {\n as,\n css,\n className,\n label,\n value: valueProp,\n defaultValue,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n formatValue = String,\n showValue = true,\n name,\n disabled,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Range', props as RangeProps);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue: defaultValue ?? min,\n onChange: onValueChange,\n });\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Range', 'root', css);\n const { part, style: partsStyle } = useParts('Range', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const ratio = max > min ? (Math.min(max, Math.max(min, value)) - min) / (max - min) : 0;\n const text = formatValue(value);\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-range', styled.className, className)}\n data-disabled={disabled ? '' : undefined}\n style={{ '--slurp-range-ratio': ratio, ...style } as CSSProperties}\n {...root}\n >\n <div className=\"slurp-range-head\">\n {part('label', 'label', { htmlFor: id, className: 'slurp-range-label', children: label })}\n {showValue &&\n part('value', 'output', {\n htmlFor: id,\n className: 'slurp-range-value',\n children: text,\n })}\n </div>\n {part('control', 'input', {\n id,\n type: 'range',\n className: 'slurp-range-control',\n name,\n min,\n max,\n step,\n disabled,\n value,\n 'aria-valuetext': text,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(Number(e.target.value)),\n })}\n </Root>\n </>\n );\n}\n"],"mapp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CACN,EAAA,CAAA;AAEN"}
@@ -5,7 +5,7 @@ import { ElementType } from "react";
5
5
  export interface SearchLabels {
6
6
  /** Name of the field (read by screen readers; hidden). */
7
7
  label: string;
8
- /** Says where it looks: "Cerca in Smartphone…". */
8
+ /** Says where it looks: "Cerca in Archivio…". */
9
9
  placeholder: string;
10
10
  /** Name of the clear button. */
11
11
  clear: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","names":[],"sources":["../../src/Search/Search.tsx"],"sourcesContent":["import { CloseIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { splitInputProps, type InputAttributes } from '../Field/Field';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface SearchLabels {\n /** Name of the field (read by screen readers; hidden). */\n label: string;\n /** Says where it looks: \"Cerca in Smartphone…\". */\n placeholder: string;\n /** Name of the clear button. */\n clear: string;\n /** Result count, announced politely while typing. */\n results: (count: number) => string;\n}\n\nexport const SEARCH_LABELS: SearchLabels = {\n label: 'Cerca',\n placeholder: 'Cerca…',\n clear: 'Cancella la ricerca',\n results: (n) => (n === 0 ? 'Nessun risultato' : n === 1 ? '1 risultato' : `${n} risultati`),\n};\n\nexport interface SearchOwnProps\n extends Omit<InputAttributes, 'type'>, PartsProps<'icon' | 'control' | 'clear' | 'status'> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Enter. */\n onSearch?: (value: string) => void;\n /** Number of results: shown at the end of the field and announced (polite live region). */\n count?: number;\n labels?: Partial<SearchLabels>;\n}\n\nexport type SearchProps<E extends ElementType = 'div'> = PolymorphicProps<E, SearchOwnProps>;\n\n/** Search field: icon, contextual placeholder, result count, clear button. */\nexport function Search<E extends ElementType = 'div'>(props: SearchProps<E>) {\n const {\n as,\n css,\n className,\n value: valueProp,\n defaultValue = '',\n onValueChange,\n onSearch,\n count,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...others\n } = useThemeProps('Search', props as SearchProps);\n const labels = { ...SEARCH_LABELS, ...labelsProp };\n const { input, root: rest } = splitInputProps(others);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const statusId = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Search', 'root', css);\n const { part, style } = useParts('Search', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const typed = value.trim() !== '';\n const userKeyDown = input.onKeyDown as ((e: KeyboardEvent<HTMLInputElement>) => void) | undefined;\n return (\n <>\n {styled.style}\n {style}\n <Root\n role=\"search\"\n className={cx('slurp-search', styled.className, className)}\n data-typed={typed ? '' : undefined}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-search-icon',\n 'aria-hidden': true,\n children: <SearchIcon size={18} />,\n })}\n {part('control', 'input', {\n ...input,\n type: 'search',\n className: 'slurp-search-control',\n 'aria-label': labels.label,\n 'aria-describedby': count != null && typed ? statusId : undefined,\n placeholder: input.placeholder ?? labels.placeholder,\n enterKeyHint: input.enterKeyHint ?? 'search',\n autoComplete: input.autoComplete ?? 'off',\n value,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value),\n onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => {\n userKeyDown?.(e);\n if (e.key === 'Enter' && !e.defaultPrevented) onSearch?.(value);\n },\n })}\n {part('status', 'span', {\n id: statusId,\n className: 'slurp-search-count',\n role: 'status',\n children: count != null && typed ? labels.results(count) : '',\n })}\n {typed &&\n part('clear', Bubble, {\n className: 'slurp-search-clear',\n label: labels.clear,\n size: 'sm',\n onClick: (e: MouseEvent<HTMLElement>) => {\n setValue('');\n e.currentTarget.parentElement?.querySelector('input')?.foc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OAAO;KACzC,cAAc,MAAM,gBAAgB;KACpC,cAAc,MAAM,gBAAgB;KACpC;KACA,WAAW,MAAqC,SAAS,EAAE,OAAO,KAAK;KACvE,YAAY,MAAuC;MACjD,cAAc,CAAC;MACf,IAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,kBAAkB,WAAW,KAAK;KAChE;IACF,CAAC;IACA,KAAK,UAAU,QAAQ;KACtB,IAAI;KACJ,WAAW;KACX,MAAM;KACN,UAAU,SAAS,QAAQ,QAAQ,OAAO,QAAQ,KAAK,IAAI;IAC7D,CAAC;IACA,SACC,KAAK,SAAS,QAAQ;KACpB,WAAW;KACX,OAAO,OAAO;KACd,MAAM;KACN,UAAU,MAA+B;MACvC,SAAS,EAAE;MACX,EAAE,cAAc,eAAe,cAAc,OAAO,CAAC,EAAE,MAAM;KAC/D;KACA,UAAU,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;IAClC,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Search.js","names":[],"sources":["../../src/Search/Search.tsx"],"sourcesContent":["import { CloseIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { splitInputProps, type InputAttributes } from '../Field/Field';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface SearchLabels {\n /** Name of the field (read by screen readers; hidden). */\n label: string;\n /** Says where it looks: \"Cerca in Archivio…\". */\n placeholder: string;\n /** Name of the clear button. */\n clear: string;\n /** Result count, announced politely while typing. */\n results: (count: number) => string;\n}\n\nexport const SEARCH_LABELS: SearchLabels = {\n label: 'Cerca',\n placeholder: 'Cerca…',\n clear: 'Cancella la ricerca',\n results: (n) => (n === 0 ? 'Nessun risultato' : n === 1 ? '1 risultato' : `${n} risultati`),\n};\n\nexport interface SearchOwnProps\n extends Omit<InputAttributes, 'type'>, PartsProps<'icon' | 'control' | 'clear' | 'status'> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Enter. */\n onSearch?: (value: string) => void;\n /** Number of results: shown at the end of the field and announced (polite live region). */\n count?: number;\n labels?: Partial<SearchLabels>;\n}\n\nexport type SearchProps<E extends ElementType = 'div'> = PolymorphicProps<E, SearchOwnProps>;\n\n/** Search field: icon, contextual placeholder, result count, clear button. */\nexport function Search<E extends ElementType = 'div'>(props: SearchProps<E>) {\n const {\n as,\n css,\n className,\n value: valueProp,\n defaultValue = '',\n onValueChange,\n onSearch,\n count,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...others\n } = useThemeProps('Search', props as SearchProps);\n const labels = { ...SEARCH_LABELS, ...labelsProp };\n const { input, root: rest } = splitInputProps(others);\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const statusId = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Search', 'root', css);\n const { part, style } = useParts('Search', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const typed = value.trim() !== '';\n const userKeyDown = input.onKeyDown as ((e: KeyboardEvent<HTMLInputElement>) => void) | undefined;\n return (\n <>\n {styled.style}\n {style}\n <Root\n role=\"search\"\n className={cx('slurp-search', styled.className, className)}\n data-typed={typed ? '' : undefined}\n {...root}\n >\n {part('icon', 'span', {\n className: 'slurp-search-icon',\n 'aria-hidden': true,\n children: <SearchIcon size={18} />,\n })}\n {part('control', 'input', {\n ...input,\n type: 'search',\n className: 'slurp-search-control',\n 'aria-label': labels.label,\n 'aria-describedby': count != null && typed ? statusId : undefined,\n placeholder: input.placeholder ?? labels.placeholder,\n enterKeyHint: input.enterKeyHint ?? 'search',\n autoComplete: input.autoComplete ?? 'off',\n value,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value),\n onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => {\n userKeyDown?.(e);\n if (e.key === 'Enter' && !e.defaultPrevented) onSearch?.(value);\n },\n })}\n {part('status', 'span', {\n id: statusId,\n className: 'slurp-search-count',\n role: 'status',\n children: count != null && typed ? labels.results(count) : '',\n })}\n {typed &&\n part('clear', Bubble, {\n className: 'slurp-search-clear',\n label: labels.clear,\n size: 'sm',\n onClick: (e: MouseEvent<HTMLElement>) => {\n setValue('');\n e.currentTarget.parentElement?.querySelector('input')?.focus();\n },\n children: <CloseIcon size={18} />,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,MAAa,gBAA8B;CACzC,OAAO;CACP,aAAa;CACb,OAAO;CACP,UAAU,MAAO,MAAM,IAAI,qBAAqB,MAAM,IAAI,gBAAgB,GAAG,EAAE;AACjF;;AAiBA,SAAgB,OAAsC,OAAuB;CAC3E,MAAM,EACJ,IACA,KACA,WACA,OAAO,WACP,eAAe,IACf,eACA,UACA,OACA,QAAQ,YACR,OACA,WACA,YACA,GAAG,WACD,cAAc,UAAU,KAAoB;CAChD,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG;CAAW;CACjD,MAAM,EAAE,OAAO,MAAM,SAAS,gBAAgB,MAAM;CACpD,MAAM,CAAC,OAAO,YAAY,cAAc;EACtC,OAAO;EACP;EACA,UAAU;CACZ,CAAC;CACD,MAAM,WAAW,MAAM;CACvB,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,EAAE,MAAM,UAAU,SAAS,UAAU;EAAE;EAAO;EAAW;CAAW,CAAC;CAC3E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,MAAM,KAAK,MAAM;CAC/B,MAAM,cAAc,MAAM;CAC1B,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,MAAK;GACL,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;GACzD,cAAY,QAAQ,KAAK,KAAA;GACzB,GAAI;GAJN,UAAA;IAMG,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,eAAe;KACf,UAAU,oBAAC,YAAD,EAAY,MAAM,GAAK,CAAA;IACnC,CAAC;IACA,KAAK,WAAW,SAAS;KACxB,GAAG;KACH,MAAM;KACN,WAAW;KACX,cAAc,OAAO;KACrB,oBAAoB,SAAS,QAAQ,QAAQ,WAAW,KAAA;KACxD,aAAa,MAAM,eAAe,OAAO;KACzC,cAAc,MAAM,gBAAgB;KACpC,cAAc,MAAM,gBAAgB;KACpC;KACA,WAAW,MAAqC,SAAS,EAAE,OAAO,KAAK;KACvE,YAAY,MAAuC;MACjD,cAAc,CAAC;MACf,IAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,kBAAkB,WAAW,KAAK;KAChE;IACF,CAAC;IACA,KAAK,UAAU,QAAQ;KACtB,IAAI;KACJ,WAAW;KACX,MAAM;KACN,UAAU,SAAS,QAAQ,QAAQ,OAAO,QAAQ,KAAK,IAAI;IAC7D,CAAC;IACA,SACC,KAAK,SAAS,QAAQ;KACpB,WAAW;KACX,OAAO,OAAO;KACd,MAAM;KACN,UAAU,MAA+B;MACvC,SAAS,EAAE;MACX,EAAE,cAAc,eAAe,cAAc,OAAO,CAAC,EAAE,MAAM;KAC/D;KACA,UAAU,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;IAClC,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
package/dist/styles.css CHANGED
@@ -76,6 +76,7 @@
76
76
  --slurp-blob-opacity-dark: 0.3;
77
77
  --slurp-font-family-display: Poppins, system-ui, sans-serif;
78
78
  --slurp-font-family-sans: Poppins, system-ui, sans-serif;
79
+ --slurp-font-family-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
79
80
  --slurp-font-display-xl-size: 52px;
80
81
  --slurp-font-display-xl-line-height: 1.1;
81
82
  --slurp-font-display-xl-weight: 600;
@@ -591,7 +592,7 @@
591
592
  cursor: pointer;
592
593
  -webkit-tap-highlight-color: transparent;
593
594
  transition:
594
- transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
595
+ transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1),
595
596
  box-shadow 0.4s,
596
597
  background-color 0.25s,
597
598
  color 0.25s;
@@ -602,12 +603,25 @@
602
603
  outline-offset: 2px;
603
604
  }
604
605
 
605
- .slurp-button:hover:not(:disabled, [aria-disabled='true']) {
606
- transform: translateY(-2px);
606
+ /* Lift only where hover is real: a tap leaves :hover on, and the button would stay raised. */
607
+ @media (hover: hover) and (pointer: fine) {
608
+ .slurp-button:hover:not(:disabled, [aria-disabled='true']) {
609
+ transform: translateY(-2px);
610
+ }
611
+
612
+ .slurp-button[data-appearance='fill'][data-tone='accent']:hover:not(:disabled) {
613
+ box-shadow: 0 14px 30px -12px var(--slurp-accent);
614
+ }
607
615
  }
608
616
 
617
+ /* The press lands while the finger is down (120ms); the release, back on the base transition, is softer. */
609
618
  .slurp-button:active:not(:disabled, [aria-disabled='true']) {
610
619
  transform: scale(0.97);
620
+ transition:
621
+ transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1),
622
+ box-shadow 0.4s,
623
+ background-color 0.25s,
624
+ color 0.25s;
611
625
  }
612
626
 
613
627
  .slurp-button:disabled,
@@ -626,10 +640,6 @@
626
640
  --slurp-button-pad: var(--slurp-space-8);
627
641
  }
628
642
 
629
- .slurp-button[data-appearance='fill'][data-tone='accent']:hover:not(:disabled) {
630
- box-shadow: 0 14px 30px -12px var(--slurp-accent);
631
- }
632
-
633
643
  .slurp-button[data-appearance='fill'][data-tone='neutral'] {
634
644
  --slurp-button-bg: var(--slurp-surface-2);
635
645
  --slurp-button-fg: var(--slurp-fg);
@@ -684,7 +694,8 @@
684
694
  }
685
695
 
686
696
  @media (prefers-reduced-motion: reduce) {
687
- .slurp-button {
697
+ .slurp-button,
698
+ .slurp-button:active:not(:disabled, [aria-disabled='true']) {
688
699
  transition: none;
689
700
  }
690
701
 
@@ -721,19 +732,28 @@
721
732
  text-align: left;
722
733
  text-decoration: none;
723
734
  container-type: inline-size;
724
- transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
735
+ transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
725
736
  }
726
737
 
727
738
  :is(a, button).slurp-card {
728
739
  cursor: pointer;
729
740
  }
730
741
 
731
- :is(a, button).slurp-card:hover {
732
- transform: translateY(-6px);
742
+ /* Lift only where hover is real: after a tap the card would stay raised. */
743
+ @media (hover: hover) and (pointer: fine) {
744
+ :is(a, button).slurp-card:hover {
745
+ transform: translateY(-6px);
746
+ }
747
+
748
+ :is(a, button).slurp-card:hover .slurp-card-art {
749
+ transform: scale(1.06) rotate(-3deg);
750
+ }
733
751
  }
734
752
 
753
+ /* Quick press, softer release (the base transition). */
735
754
  :is(a, button).slurp-card:active {
736
755
  transform: scale(0.98);
756
+ transition-duration: 0.12s;
737
757
  }
738
758
 
739
759
  .slurp-card:focus-visible {
@@ -775,10 +795,6 @@
775
795
  max-width: 100%;
776
796
  }
777
797
 
778
- :is(a, button).slurp-card:hover .slurp-card-art {
779
- transform: scale(1.06) rotate(-3deg);
780
- }
781
-
782
798
  .slurp-card-badge {
783
799
  position: absolute;
784
800
  top: 14px;
@@ -1040,14 +1056,20 @@
1040
1056
  transition:
1041
1057
  background-color 0.35s,
1042
1058
  color 0.35s,
1043
- transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
1059
+ transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
1044
1060
  }
1045
1061
 
1046
1062
  .slurp-chip:hover:not(:disabled) {
1047
- transform: translateY(-1px);
1048
1063
  background: var(--slurp-accent-soft);
1049
1064
  }
1050
1065
 
1066
+ /* The lift only where hover is real; the tint above shows on every pointer. */
1067
+ @media (hover: hover) and (pointer: fine) {
1068
+ .slurp-chip:hover:not(:disabled) {
1069
+ transform: translateY(-1px);
1070
+ }
1071
+ }
1072
+
1051
1073
  .slurp-chip:focus-visible {
1052
1074
  outline: 2px solid var(--slurp-focus);
1053
1075
  outline-offset: 2px;
@@ -1601,6 +1623,28 @@
1601
1623
  .slurp-crumb-label {
1602
1624
  max-width: none;
1603
1625
  }
1626
+
1627
+ /*
1628
+ * An earlier crumb without an icon keeps its label, but it gives way first: it shrinks to a 44px stub (still a
1629
+ * full target) before the current crumb loses a letter, so the page you are on stays readable.
1630
+ */
1631
+ .slurp-dock-crumbs > li:not(:first-child):has(> .slurp-crumb:not([data-current], [data-icon])) {
1632
+ flex-shrink: 1000;
1633
+ min-width: 44px;
1634
+ }
1635
+
1636
+ .slurp-dock-crumbs > li > .slurp-crumb:not([data-current], [data-icon], .slurp-crumb-back),
1637
+ .slurp-crumb[data-current][data-left='slant'] {
1638
+ padding-left: var(--slurp-space-3);
1639
+ }
1640
+
1641
+ .slurp-dock-crumbs > li > .slurp-crumb:not([data-current], [data-icon], .slurp-crumb-back) {
1642
+ padding-right: var(--slurp-space-3);
1643
+ }
1644
+
1645
+ .slurp-crumb[data-current][data-right='round'] {
1646
+ padding-right: var(--slurp-space-4);
1647
+ }
1604
1648
  }
1605
1649
 
1606
1650
  @media (prefers-reduced-motion: reduce) {
@@ -2786,8 +2830,11 @@
2786
2830
  fill: none;
2787
2831
  }
2788
2832
 
2789
- .slurp-rating:not([data-disabled]) .slurp-rating-star:hover .slurp-rating-icon {
2790
- transform: scale(1.12);
2833
+ /* The star grows only where hover is real: after a tap it would stay enlarged. */
2834
+ @media (hover: hover) and (pointer: fine) {
2835
+ .slurp-rating:not([data-disabled]) .slurp-rating-star:hover .slurp-rating-icon {
2836
+ transform: scale(1.12);
2837
+ }
2791
2838
  }
2792
2839
 
2793
2840
  .slurp-rating[data-disabled] .slurp-rating-stars {
@@ -4024,7 +4071,7 @@
4024
4071
  text-decoration: none;
4025
4072
  cursor: pointer;
4026
4073
  container-type: size;
4027
- transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
4074
+ transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
4028
4075
  }
4029
4076
 
4030
4077
  :where([data-theme='dark']) .slurp-tile {
@@ -4041,12 +4088,21 @@
4041
4088
  --slurp-tile-tint: 22%;
4042
4089
  }
4043
4090
 
4044
- .slurp-tile:hover {
4045
- transform: translateY(-6px) scale(1.015);
4091
+ /* Lift only where hover is real: after a tap the tile would stay raised. */
4092
+ @media (hover: hover) and (pointer: fine) {
4093
+ .slurp-tile:hover {
4094
+ transform: translateY(-6px) scale(1.015);
4095
+ }
4096
+
4097
+ .slurp-tile:hover .slurp-tile-media {
4098
+ transform: translateY(-50%) scale(1.08) rotate(-5deg);
4099
+ }
4046
4100
  }
4047
4101
 
4102
+ /* Quick press, softer release (the base transition). */
4048
4103
  .slurp-tile:active {
4049
4104
  transform: scale(0.97);
4105
+ transition-duration: 0.12s;
4050
4106
  }
4051
4107
 
4052
4108
  .slurp-tile:focus-visible {
@@ -4138,10 +4194,6 @@
4138
4194
  width: min(46cqi, 46cqh);
4139
4195
  }
4140
4196
 
4141
- .slurp-tile:hover .slurp-tile-media {
4142
- transform: translateY(-50%) scale(1.08) rotate(-5deg);
4143
- }
4144
-
4145
4197
  @container (max-width: 240px) {
4146
4198
  .slurp-tile-subtitle {
4147
4199
  display: none;
package/dist/tokens.css CHANGED
@@ -40,6 +40,7 @@
40
40
  --slurp-blob-opacity-dark: 0.3;
41
41
  --slurp-font-family-display: Poppins, system-ui, sans-serif;
42
42
  --slurp-font-family-sans: Poppins, system-ui, sans-serif;
43
+ --slurp-font-family-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
43
44
  --slurp-font-display-xl-size: 52px;
44
45
  --slurp-font-display-xl-line-height: 1.1;
45
46
  --slurp-font-display-xl-weight: 600;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slurp-ui/react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Slurp UI: ready-made React components of the Slurp design system, with optional collapse/expand motion.",
5
5
  "keywords": [
6
6
  "react",
@@ -75,7 +75,7 @@
75
75
  "dependencies": {
76
76
  "@slurp-ui/icons": "^1.1.0",
77
77
  "@slurp-ui/motion": "^1.0.1",
78
- "@slurp-ui/tokens": "^1.0.1"
78
+ "@slurp-ui/tokens": "^1.1.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@arethetypeswrong/cli": "^0.18.5",