@plexui/ui 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/es/components/Alert/Alert.js +12 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/ColorPicker/ColorPicker.js +12 -10
  4. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -1
  5. package/dist/es/components/ColorPicker/ColorWell.js +1 -1
  6. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -1
  7. package/dist/es/components/ColorPicker/shared.js +5 -4
  8. package/dist/es/components/ColorPicker/shared.js.map +1 -1
  9. package/dist/es/components/ContextMenu/ContextMenu.js +9 -9
  10. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -1
  11. package/dist/es/components/ContextMenu/shared.js +25 -5
  12. package/dist/es/components/ContextMenu/shared.js.map +1 -1
  13. package/dist/es/components/DatePicker/DatePicker.js +3 -3
  14. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  15. package/dist/es/components/DatePicker/useCalendarCollisionPadding.js +25 -0
  16. package/dist/es/components/DatePicker/useCalendarCollisionPadding.js.map +1 -0
  17. package/dist/es/components/DateRangePicker/DateRangePicker.js +3 -3
  18. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  19. package/dist/es/components/Dialog/Dialog.js +1 -1
  20. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  21. package/dist/es/components/Input/Input.js +1 -1
  22. package/dist/es/components/Input/Input.js.map +1 -1
  23. package/dist/es/components/Menu/Menu.js +15 -2
  24. package/dist/es/components/Menu/Menu.js.map +1 -1
  25. package/dist/es/components/PhoneLayout/PhoneLayout.js +6 -1
  26. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -1
  27. package/dist/es/components/Popover/Popover.js.map +1 -1
  28. package/dist/es/components/ProgressSteps/ProgressSteps.js +1 -1
  29. package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
  30. package/dist/es/components/ProgressSteps/index.js.map +1 -1
  31. package/dist/es/components/Select/Select.js +155 -25
  32. package/dist/es/components/Select/Select.js.map +1 -1
  33. package/dist/es/components/SelectControl/SelectControl.js +1 -1
  34. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  35. package/dist/es/components/Slider/Slider.js +19 -12
  36. package/dist/es/components/Slider/Slider.js.map +1 -1
  37. package/dist/es/components/Sortable/Sortable.js +1 -1
  38. package/dist/es/components/Sortable/Sortable.js.map +1 -1
  39. package/dist/es/components/StatCard/index.js +5 -1
  40. package/dist/es/components/StatCard/index.js.map +1 -1
  41. package/dist/es/components/StatsCard/StatsCard.js +48 -0
  42. package/dist/es/components/StatsCard/StatsCard.js.map +1 -0
  43. package/dist/es/components/StatsCard/index.js +2 -0
  44. package/dist/es/components/StatsCard/index.js.map +1 -0
  45. package/dist/es/components/SwipeActions/SwipeActions.js +30 -8
  46. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -1
  47. package/dist/es/components/TabBar/TabBar.js +11 -4
  48. package/dist/es/components/TabBar/TabBar.js.map +1 -1
  49. package/dist/es/components/Tabs/Tabs.js +200 -7
  50. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  51. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  52. package/dist/es/lib/menuTriggerCover.js +40 -3
  53. package/dist/es/lib/menuTriggerCover.js.map +1 -1
  54. package/dist/types/components/ColorPicker/ColorPicker.d.ts +3 -2
  55. package/dist/types/components/ColorPicker/shared.d.ts +5 -4
  56. package/dist/types/components/ContextMenu/shared.d.ts +28 -6
  57. package/dist/types/components/DatePicker/useCalendarCollisionPadding.d.ts +8 -0
  58. package/dist/types/components/Dialog/Dialog.d.ts +1 -1
  59. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +5 -0
  60. package/dist/types/components/Popover/Popover.d.ts +2 -2
  61. package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +11 -4
  62. package/dist/types/components/ProgressSteps/index.d.ts +1 -1
  63. package/dist/types/components/Select/Select.d.ts +11 -3
  64. package/dist/types/components/StatCard/index.d.ts +5 -1
  65. package/dist/types/components/{StatCard/StatCard.d.ts → StatsCard/StatsCard.d.ts} +7 -7
  66. package/dist/types/components/StatsCard/index.d.ts +1 -0
  67. package/dist/types/components/SwipeActions/SwipeActions.d.ts +1 -1
  68. package/dist/types/components/TabBar/TabBar.d.ts +12 -2
  69. package/dist/types/components/Tabs/Tabs.d.ts +12 -0
  70. package/dist/types/components/Toolbar/Toolbar.d.ts +1 -1
  71. package/dist/types/lib/menuTriggerCover.d.ts +16 -2
  72. package/package.json +2 -2
  73. package/dist/es/components/DatePicker/useCalendarGutter.js +0 -8
  74. package/dist/es/components/DatePicker/useCalendarGutter.js.map +0 -1
  75. package/dist/es/components/StatCard/StatCard.js +0 -39
  76. package/dist/es/components/StatCard/StatCard.js.map +0 -1
  77. package/dist/types/components/DatePicker/useCalendarGutter.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SelectControl.js","sourceRoot":"","sources":["../../../../src/components/SelectControl/SelectControl.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,CAAC,MAAM,kEAAkE,CAAA;A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s\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers\"\nimport { isHoverPointer } from \"../../lib/inputMode\"\nimport { isNestedSelectControl } from \"../../lib/selectPress\"\nimport type { ControlSize, Variants } from \"../../types\"\nimport { Button } from \"../Button\"\nimport { ChevronDown, Dropdown, X } from \"../Icon\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport s from \"@plexui/styles/components/SelectControl/SelectControl.module.css\"\n\nexport type DropdownIconType = \"chevronDown\" | \"dropdown\" | \"none\"\n\nexport type SelectControlProps = Omit<React.HTMLAttributes<HTMLSpanElement>, \"onClick\"> & {\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"soft\" | \"outline\" | \"ghost\">\n /**\n * Determines if the control should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Extends the control to 100% of available width.\n * @default true\n */\n block?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the control\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /**\n * Disables the control visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Visually indicates that the control is in an invalid state\n * @default false\n */\n invalid?: boolean\n /**\n * Indicates that the control is selected. An unselected state will display placeholder styles.\n * @default false\n */\n selected?: boolean\n /**\n * Display a clear action that allows the select to be unset.\n * @default false\n */\n onClearClick?: () => void\n /**\n * Primary handler for when the control is selected with pointer or keyboard events\n */\n onInteract?: () => void\n /**\n * Enter interacts too, as on a combobox button. Off by default, as Enter\n * may be an attempt to submit a form.\n * @default false\n */\n interactOnEnter?: boolean\n /**\n * Determines size of the size and spacing of the control.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n * @default md\n */\n size?: ControlSize\n /**\n * Displays loading indicator on top of button contents\n * @default false\n */\n loading?: boolean\n /**\n * Icon displayed in the far right of the select trigger\n * @default dropdown\n */\n dropdownIconType?: DropdownIconType\n /** Icon displayed at the start of the control */\n StartIcon?: React.ComponentType<React.SVGProps<SVGSVGElement>>\n /** Custom class applied to the control element */\n className?: string\n /** Content rendered for the control */\n children: ReactNode\n ref?: React.Ref<HTMLSpanElement | null>\n}\n\nexport const SelectControl = ({\n ref,\n onPointerDown,\n onPointerCancel,\n onKeyDown,\n onPointerEnter,\n onInteract,\n interactOnEnter = false,\n invalid,\n disabled,\n children,\n className,\n variant = \"outline\",\n size = \"md\",\n block,\n opticallyAlign,\n pill = false,\n loading,\n onClearClick,\n selected = false,\n StartIcon,\n dropdownIconType = \"dropdown\",\n ...restProps\n}: SelectControlProps) => {\n const controlRef = useRef<HTMLSpanElement>(null)\n const mouseClickHandled = useRef(false)\n // Popover/Menu clone their private click handler into the trigger.\n const triggerProps: React.HTMLAttributes<HTMLSpanElement> = restProps\n const clearable = !!onClearClick\n const showClearAction = clearable && selected && !loading && !disabled\n const hasDropdownIcon = dropdownIconType && dropdownIconType !== \"none\" && !loading\n const hasAnyTertiaryIndicator = showClearAction || loading || hasDropdownIcon\n const isInteractive = !loading && !disabled\n\n // Act like a <button> and fire the click handler on keyboard actions\n const handleKeyDown = (evt: React.KeyboardEvent<HTMLSpanElement>) => {\n // Enter and Space on a nested control (the clear button) activate that\n // control: neither this handler nor a wrapping trigger's may take them\n if (evt.target !== evt.currentTarget && (evt.key === \" \" || evt.key === \"Enter\")) {\n return\n }\n onKeyDown?.(evt)\n if (evt.defaultPrevented || evt.nativeEvent.isComposing || evt.keyCode === 229) return\n switch (evt.key) {\n case \"Enter\":\n case \"ArrowDown\":\n case \"ArrowUp\":\n case \" \":\n // NOTE: \"Enter\" may be an attempt to submit a form\n if (evt.key === \"Enter\" && !interactOnEnter) {\n break\n }\n\n evt.stopPropagation()\n evt.preventDefault()\n\n controlRef.current?.click()\n break\n default:\n break\n }\n }\n\n const handlePointerDown = (evt: React.PointerEvent<HTMLSpanElement>) => {\n mouseClickHandled.current = false\n if (isNestedSelectControl(evt)) return\n onPointerDown?.(evt)\n if (evt.defaultPrevented) {\n mouseClickHandled.current = true\n return\n }\n if (evt.button !== 0) return\n // A touch may become a scroll. Wait for its click, which the browser cancels\n // when scrolling; desktop mouse keeps press-drag-select.\n if (evt.pointerType === \"pen\" || !isHoverPointer(evt)) return\n evt.stopPropagation()\n mouseClickHandled.current = true\n if (onInteract) {\n evt.preventDefault()\n onInteract()\n } else {\n triggerProps.onClick?.(evt)\n }\n }\n\n const handleClick = (evt: React.MouseEvent<HTMLSpanElement>) => {\n const handled = mouseClickHandled.current\n mouseClickHandled.current = false\n if (!isInteractive || evt.defaultPrevented || evt.button !== 0 || isNestedSelectControl(evt)) return\n if (handled && evt.detail !== 0) return\n evt.stopPropagation()\n if (onInteract) onInteract()\n else triggerProps.onClick?.(evt)\n }\n\n return (\n // Intentionally not using <button> and rebuilding the semantics\n <span\n ref={mergeRefs([controlRef, ref])}\n className={clsx(s.SelectControl, className)}\n // Recreate <button> semantics\n role=\"button\"\n data-slot=\"select-control\"\n tabIndex={disabled ? -1 : 0}\n onPointerEnter={(evt: React.PointerEvent<HTMLAnchorElement>) => {\n handlePressableMouseEnter(evt)\n onPointerEnter?.(evt)\n }}\n onPointerDown={isInteractive ? handlePointerDown : undefined}\n onKeyDown={isInteractive ? handleKeyDown : undefined}\n data-variant={variant}\n data-block={block ? \"\" : undefined}\n data-pill={pill ? \"\" : undefined}\n data-size={size}\n data-optically-align={opticallyAlign}\n aria-busy={loading ? \"true\" : undefined}\n data-selected={selected}\n data-loading={loading ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n aria-disabled={disabled}\n {...restProps}\n onClick={handleClick}\n onPointerCancel={(evt) => {\n mouseClickHandled.current = false\n onPointerCancel?.(evt)\n }}\n >\n {StartIcon && <StartIcon className={s.StartIcon} />}\n <span className={s.TriggerText}>{children}</span>\n {hasAnyTertiaryIndicator && (\n <div className={s.IndicatorWrapper}>\n {showClearAction && (\n <Button\n aria-label=\"Clear current value\"\n className={s.Clear}\n onPointerDown={(evt: React.PointerEvent<HTMLButtonElement>) => {\n // Prevent pointerDown on trigger from being captured\n evt.stopPropagation()\n }}\n onClick={(evt) => {\n evt.stopPropagation()\n evt.preventDefault()\n if (disabled || loading) return\n // The clear button disappears when the value becomes empty.\n controlRef.current?.focus({ preventScroll: true })\n onClearClick()\n }}\n color=\"secondary\"\n variant={hasDropdownIcon ? \"ghost\" : \"solid\"}\n // Mostly custom sizing through variables\n size=\"3xs\"\n uniform\n pill={pill}\n data-only-child={!hasDropdownIcon ? \"\" : undefined}\n >\n <X />\n </Button>\n )}\n {loading && <LoadingIndicator className={s.LoadingIndicator} />}\n {/* Using raw SVG canvases (opposed to fixed icon canvases) led to less pixelation. */}\n {hasDropdownIcon && <DropdownIcon iconType={dropdownIconType} />}\n </div>\n )}\n </span>\n )\n}\n\ntype DropdownIconProps = {\n iconType: Exclude<DropdownIconType, \"none\">\n}\n\nexport const DropdownIcon = ({ iconType }: DropdownIconProps) => {\n return iconType === \"chevronDown\" ? (\n <ChevronDown data-no-autosize=\"\" className={clsx(s.DropdownIcon, s.DropdownIconChevron)} />\n ) : (\n <span className={s.DropdownIcon} aria-hidden=\"true\">\n <Dropdown data-no-autosize=\"\" className={s.DropdownGlyph} />\n <svg data-no-autosize=\"\" className={s.MobileDropdownGlyph} width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M9.41074 2.74408C9.73618 2.41864 10.2638 2.41864 10.5893 2.74408L14.7559 6.91074C15.0814 7.23618 15.0814 7.76382 14.7559 8.08926C14.4305 8.41469 13.9028 8.41469 13.5774 8.08926L10 4.51184L6.42259 8.08926C6.09715 8.41469 5.56951 8.41469 5.24408 8.08926C4.91864 7.76382 4.91864 7.23618 5.24408 6.91074L9.41074 2.74408ZM5.24408 11.9107C5.56951 11.5853 6.09715 11.5853 6.42259 11.9107L10 15.4882L13.5774 11.9107C13.9028 11.5853 14.4305 11.5853 14.7559 11.9107C15.0814 12.2362 15.0814 12.7638 14.7559 13.0893L10.5893 17.2559C10.2638 17.5814 9.73618 17.5814 9.41074 17.2559L5.24408 13.0893C4.91864 12.7638 4.91864 12.2362 5.24408 11.9107Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n </svg>\n </span>\n )\n}\n"]}
1
+ {"version":3,"file":"SelectControl.js","sourceRoot":"","sources":["../../../../src/components/SelectControl/SelectControl.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAmFhF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,GAAG,EACH,aAAa,EACb,eAAe,EACf,SAAS,EACT,cAAc,EACd,UAAU,EACV,eAAe,GAAG,KAAK,EACvB,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,KAAK,EACL,cAAc,EACd,IAAI,GAAG,KAAK,EACZ,OAAO,EACP,YAAY,EACZ,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,gBAAgB,GAAG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KAAC,YAAY,IAAC,QAAQ,EAAE,gBAAgB,GAAI,IAC5D,CACP,IACI,CACR,CAAA;AACH,CAAC,CAAA;AAMD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAqB,EAAE,EAAE;IAC9D,OAAO,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,CAClC,KAAC,WAAW,wBAAkB,EAAE,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAI,CAC5F,CAAC,CAAC,CAAC,CACF,gBAAM,SAAS,EAAE,CAAC,CAAC,YAAY,iBAAc,MAAM,aACjD,KAAC,QAAQ,wBAAkB,EAAE,EAAC,SAAS,EAAE,CAAC,CAAC,aAAa,GAAI,EAC5D,kCAAsB,EAAE,EAAC,SAAS,EAAE,CAAC,CAAC,mBAAmB,EAAE,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,YAClI,eACE,CAAC,EAAC,0nBAA0nB,EAC5nB,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,GAClB,GACE,IACD,CACR,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useRef, type ReactNode } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers\"\nimport { isHoverPointer } from \"../../lib/inputMode\"\nimport { isNestedSelectControl } from \"../../lib/selectPress\"\nimport type { ControlSize, Variants } from \"../../types\"\nimport { Button } from \"../Button\"\nimport { ChevronDown, Dropdown, X } from \"../Icon\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport s from \"@plexui/styles/components/SelectControl/SelectControl.module.css\"\n\nexport type DropdownIconType = \"chevronDown\" | \"dropdown\" | \"none\"\n\nexport type SelectControlProps = Omit<React.HTMLAttributes<HTMLSpanElement>, \"onClick\"> & {\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"soft\" | \"outline\" | \"ghost\">\n /**\n * Determines if the control should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Extends the control to 100% of available width.\n * @default true\n */\n block?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the control\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /**\n * Disables the control visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Visually indicates that the control is in an invalid state\n * @default false\n */\n invalid?: boolean\n /**\n * Indicates that the control is selected. An unselected state will display placeholder styles.\n * @default false\n */\n selected?: boolean\n /**\n * Display a clear action that allows the select to be unset.\n * @default false\n */\n onClearClick?: () => void\n /**\n * Primary handler for when the control is selected with pointer or keyboard events\n */\n onInteract?: () => void\n /**\n * Enter interacts too, as on a combobox button. Off by default, as Enter\n * may be an attempt to submit a form.\n * @default false\n */\n interactOnEnter?: boolean\n /**\n * Determines size of the size and spacing of the control.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n * @default md\n */\n size?: ControlSize\n /**\n * Displays loading indicator on top of button contents\n * @default false\n */\n loading?: boolean\n /**\n * Icon displayed in the far right of the select trigger\n * @default dropdown\n */\n dropdownIconType?: DropdownIconType\n /** Icon displayed at the start of the control */\n StartIcon?: React.ComponentType<React.SVGProps<SVGSVGElement>>\n /** Custom class applied to the control element */\n className?: string\n /** Content rendered for the control */\n children: ReactNode\n ref?: React.Ref<HTMLSpanElement | null>\n}\n\nexport const SelectControl = ({\n ref,\n onPointerDown,\n onPointerCancel,\n onKeyDown,\n onPointerEnter,\n onInteract,\n interactOnEnter = false,\n invalid,\n disabled,\n children,\n className,\n variant = \"outline\",\n size = \"md\",\n block,\n opticallyAlign,\n pill = false,\n loading,\n onClearClick,\n selected = false,\n StartIcon,\n dropdownIconType = \"dropdown\",\n ...restProps\n}: SelectControlProps) => {\n const controlRef = useRef<HTMLSpanElement>(null)\n const mouseClickHandled = useRef(false)\n // Popover/Menu clone their private click handler into the trigger.\n const triggerProps: React.HTMLAttributes<HTMLSpanElement> = restProps\n const clearable = !!onClearClick\n const showClearAction = clearable && selected && !loading && !disabled\n const hasDropdownIcon = dropdownIconType && dropdownIconType !== \"none\" && !loading\n const hasAnyTertiaryIndicator = showClearAction || loading || hasDropdownIcon\n const isInteractive = !loading && !disabled\n\n // Act like a <button> and fire the click handler on keyboard actions\n const handleKeyDown = (evt: React.KeyboardEvent<HTMLSpanElement>) => {\n // Enter and Space on a nested control (the clear button) activate that\n // control: neither this handler nor a wrapping trigger's may take them\n if (evt.target !== evt.currentTarget && (evt.key === \" \" || evt.key === \"Enter\")) {\n return\n }\n onKeyDown?.(evt)\n if (evt.defaultPrevented || evt.nativeEvent.isComposing || evt.keyCode === 229) return\n switch (evt.key) {\n case \"Enter\":\n case \"ArrowDown\":\n case \"ArrowUp\":\n case \" \":\n // NOTE: \"Enter\" may be an attempt to submit a form\n if (evt.key === \"Enter\" && !interactOnEnter) {\n break\n }\n\n evt.stopPropagation()\n evt.preventDefault()\n\n controlRef.current?.click()\n break\n default:\n break\n }\n }\n\n const handlePointerDown = (evt: React.PointerEvent<HTMLSpanElement>) => {\n mouseClickHandled.current = false\n if (isNestedSelectControl(evt)) return\n onPointerDown?.(evt)\n if (evt.defaultPrevented) {\n mouseClickHandled.current = true\n return\n }\n if (evt.button !== 0) return\n // A touch may become a scroll. Wait for its click, which the browser cancels\n // when scrolling; desktop mouse keeps press-drag-select.\n if (evt.pointerType === \"pen\" || !isHoverPointer(evt)) return\n evt.stopPropagation()\n mouseClickHandled.current = true\n if (onInteract) {\n evt.preventDefault()\n onInteract()\n } else {\n triggerProps.onClick?.(evt)\n }\n }\n\n const handleClick = (evt: React.MouseEvent<HTMLSpanElement>) => {\n const handled = mouseClickHandled.current\n mouseClickHandled.current = false\n if (!isInteractive || evt.defaultPrevented || evt.button !== 0 || isNestedSelectControl(evt)) return\n if (handled && evt.detail !== 0) return\n evt.stopPropagation()\n if (onInteract) onInteract()\n else triggerProps.onClick?.(evt)\n }\n\n return (\n // Intentionally not using <button> and rebuilding the semantics\n <span\n ref={mergeRefs([controlRef, ref])}\n className={clsx(s.SelectControl, className)}\n // Recreate <button> semantics\n role=\"button\"\n data-slot=\"select-control\"\n tabIndex={disabled ? -1 : 0}\n onPointerEnter={(evt: React.PointerEvent<HTMLAnchorElement>) => {\n handlePressableMouseEnter(evt)\n onPointerEnter?.(evt)\n }}\n onPointerDown={isInteractive ? handlePointerDown : undefined}\n onKeyDown={isInteractive ? handleKeyDown : undefined}\n data-variant={variant}\n data-block={block ? \"\" : undefined}\n data-pill={pill ? \"\" : undefined}\n data-size={size}\n data-optically-align={opticallyAlign}\n aria-busy={loading ? \"true\" : undefined}\n data-selected={selected}\n data-loading={loading ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n aria-disabled={disabled}\n {...restProps}\n // A wrapping trigger (Menu.Trigger, Radix's Slot) passes its own data-disabled, undefined while it is enabled:\n // the control's disabled state stays, and a disabled trigger still marks it\n data-disabled={disabled ? \"\" : (restProps as { \"data-disabled\"?: string })[\"data-disabled\"]}\n onClick={handleClick}\n onPointerCancel={(evt) => {\n mouseClickHandled.current = false\n onPointerCancel?.(evt)\n }}\n >\n {StartIcon && <StartIcon className={s.StartIcon} />}\n <span className={s.TriggerText}>{children}</span>\n {hasAnyTertiaryIndicator && (\n <div className={s.IndicatorWrapper}>\n {showClearAction && (\n <Button\n aria-label=\"Clear current value\"\n className={s.Clear}\n onPointerDown={(evt: React.PointerEvent<HTMLButtonElement>) => {\n // Prevent pointerDown on trigger from being captured\n evt.stopPropagation()\n }}\n onClick={(evt) => {\n evt.stopPropagation()\n evt.preventDefault()\n if (disabled || loading) return\n // The clear button disappears when the value becomes empty.\n controlRef.current?.focus({ preventScroll: true })\n onClearClick()\n }}\n color=\"secondary\"\n variant={hasDropdownIcon ? \"ghost\" : \"solid\"}\n // Mostly custom sizing through variables\n size=\"3xs\"\n uniform\n pill={pill}\n data-only-child={!hasDropdownIcon ? \"\" : undefined}\n >\n <X />\n </Button>\n )}\n {loading && <LoadingIndicator className={s.LoadingIndicator} />}\n {/* Using raw SVG canvases (opposed to fixed icon canvases) led to less pixelation. */}\n {hasDropdownIcon && <DropdownIcon iconType={dropdownIconType} />}\n </div>\n )}\n </span>\n )\n}\n\ntype DropdownIconProps = {\n iconType: Exclude<DropdownIconType, \"none\">\n}\n\nexport const DropdownIcon = ({ iconType }: DropdownIconProps) => {\n return iconType === \"chevronDown\" ? (\n <ChevronDown data-no-autosize=\"\" className={clsx(s.DropdownIcon, s.DropdownIconChevron)} />\n ) : (\n <span className={s.DropdownIcon} aria-hidden=\"true\">\n <Dropdown data-no-autosize=\"\" className={s.DropdownGlyph} />\n <svg data-no-autosize=\"\" className={s.MobileDropdownGlyph} width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M9.41074 2.74408C9.73618 2.41864 10.2638 2.41864 10.5893 2.74408L14.7559 6.91074C15.0814 7.23618 15.0814 7.76382 14.7559 8.08926C14.4305 8.41469 13.9028 8.41469 13.5774 8.08926L10 4.51184L6.42259 8.08926C6.09715 8.41469 5.56951 8.41469 5.24408 8.08926C4.91864 7.76382 4.91864 7.23618 5.24408 6.91074L9.41074 2.74408ZM5.24408 11.9107C5.56951 11.5853 6.09715 11.5853 6.42259 11.9107L10 15.4882L13.5774 11.9107C13.9028 11.5853 14.4305 11.5853 14.7559 11.9107C15.0814 12.2362 15.0814 12.7638 14.7559 13.0893L10.5893 17.2559C10.2638 17.5814 9.73618 17.5814 9.41074 17.2559L5.24408 13.0893C4.91864 12.7638 4.91864 12.2362 5.24408 11.9107Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n </svg>\n </span>\n )\n}\n"]}
@@ -6,6 +6,7 @@ import round from "lodash/round.js";
6
6
  import { Direction, Slider as RadixSlider } from "radix-ui";
7
7
  import { memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
8
8
  import { useDebounceCallback, useResizeObserver } from "usehooks-ts";
9
+ import { useBreakpoint } from "../../hooks/useBreakpoints.js";
9
10
  import { useIsMounted } from "../../hooks/useIsMounted.js";
10
11
  import { useLatestValue } from "../../hooks/useLatestValue.js";
11
12
  import { usePrevious } from "../../hooks/usePrevious.js";
@@ -35,6 +36,14 @@ const focusThumbToMove = (event, root, values, min, max, vertical, rtl) => {
35
36
  if (thumb && thumb !== document.activeElement)
36
37
  thumb.focus({ preventScroll: true, focusVisible: false });
37
38
  };
39
+ /** A knob's value from 0 to 1, by which a phone stands the knob on its value as iOS does (Slider.module.css). */
40
+ const thumbPercentStyle = (value, min, max) => ({ "--slider-thumb-percent": String(max > min ? clamp((value - min) / (max - min), 0, 1) : 0) });
41
+ /**
42
+ * Where a knob's centre stands at a value (0 to 1), from the start of a track `width` wide. Radix eases the knob
43
+ * over the whole track to keep it inside; on a phone it stands on the value and stops half its width from each
44
+ * end, as iOS (`clamped`, Slider.module.css).
45
+ */
46
+ const thumbCentre = (percent, width, thumbHalf, clamped) => clamped ? clamp(percent * width, thumbHalf, width - thumbHalf) : percent * width + thumbHalf * (1 - 2 * percent);
38
47
  export const Slider = memo((props) => {
39
48
  const { className, onChange, min, max, step, disabled, value, onBlur, onFocus, unit, prefixUnit, label, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, marks: propMarks = [], trackColor, rangeColor, orientation = "horizontal", ref: forwardedRef, } = props;
40
49
  const isRange = props.range === true;
@@ -261,13 +270,13 @@ export const Slider = memo((props) => {
261
270
  "slider-duration": `${animationDurationMS}ms`,
262
271
  "slider-track-color": trackColor,
263
272
  "slider-range-color": rangeColor,
264
- }), children: [_jsx(RadixSlider.Track, { className: s.Track, children: _jsx(RadixSlider.Range, { className: s.Range }) }), isRange ? (value.map((_, i) => (_jsx(RadixSlider.Thumb, { id: `${id}-thumb-${i}`, className: s.Thumb,
273
+ }), children: [_jsx(RadixSlider.Track, { className: s.Track, children: _jsx(RadixSlider.Range, { className: s.Range }) }), isRange ? (value.map((_, i) => (_jsx(RadixSlider.Thumb, { id: `${id}-thumb-${i}`, className: s.Thumb, style: thumbPercentStyle(value[i], min, max),
265
274
  // The marks measure the first thumb (all thumbs are the same size)
266
275
  ref: i === 0 ? thumbRef : undefined, "aria-labelledby": nameId ? `${nameId} ${id}-thumb-${i}` : undefined, ...(!nameId && ariaLabel
267
276
  ? {
268
277
  "aria-label": `${ariaLabel} ${rangeThumbName(i, value.length)}`.trim(),
269
278
  }
270
- : {}) }, i)))) : (_jsx(RadixSlider.Thumb, { className: s.Thumb, ref: thumbRef, "aria-labelledby": nameId, ...(!nameId && ariaLabel ? { "aria-label": ariaLabel } : {}) }))] }), showMarks && _jsx(SliderMarks, { marks: marks, thumbRef: thumbRef, min: min, max: max })] })] }));
279
+ : {}) }, i)))) : (_jsx(RadixSlider.Thumb, { className: s.Thumb, style: thumbPercentStyle(value, min, max), ref: thumbRef, "aria-labelledby": nameId, ...(!nameId && ariaLabel ? { "aria-label": ariaLabel } : {}) }))] }), showMarks && _jsx(SliderMarks, { marks: marks, thumbRef: thumbRef, min: min, max: max })] })] }));
271
280
  });
272
281
  Slider.displayName = "Slider";
273
282
  // Matches the names Radix gives range thumbs on its own
@@ -283,13 +292,17 @@ const SliderMarks = memo(({ marks, thumbRef, min, max }) => {
283
292
  // without marks do not pay a performance penalty.
284
293
  // @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663
285
294
  const { width: sliderWidth } = useResizeObserver({ ref: measureRef });
295
+ // The knob's travel changes at the phone breakpoint (Slider.module.css), also where the width stays
296
+ const tabletAndUp = useBreakpoint("md");
286
297
  useLayoutEffect(() => {
287
298
  // Impossible
288
299
  if (!thumbRef.current || !marksContainerRef.current) {
289
300
  return;
290
301
  }
291
302
  const markElements = Array.from(marksContainerRef.current.querySelectorAll("[data-mark]"));
292
- const thumbHalfWidth = thumbRef.current.getBoundingClientRect().width / 2;
303
+ // Its layout width: a pressed knob is scaled into the lens
304
+ const thumbHalfWidth = thumbRef.current.offsetWidth / 2;
305
+ const clamped = getComputedStyle(thumbRef.current).getPropertyValue("--slider-thumb-travel").trim() === "clamped";
293
306
  // Wipe all styles so we can accurately determine the positions of the marks
294
307
  markElements.forEach((markEl) => {
295
308
  markEl.style.width = "";
@@ -304,14 +317,8 @@ const SliderMarks = memo(({ marks, thumbRef, min, max }) => {
304
317
  const valuePercent = (markValue - min) / (max - min);
305
318
  const markWidth = markEl.getBoundingClientRect().width;
306
319
  const markHalfWidth = markWidth / 2;
307
- // Radix smoothes the width of the thumb over the entire track so
308
- // that the thumb is always within bounds. We need to duplicate
309
- // this smoothing so that the marks match the observed breakpoints.
310
- const smoothedThumb = thumbHalfWidth - valuePercent * (thumbHalfWidth / 0.5);
311
- // Calculate where we would naively put the mark based on the value
312
- const naiveLeftOffset = valuePercent * sliderWidth;
313
- // Add the thumb smoothing, and account for the width of the mark itself
314
- let left = naiveLeftOffset + smoothedThumb - markHalfWidth;
320
+ // Under the knob's centre at the mark's value, accounting for the width of the mark itself
321
+ let left = thumbCentre(valuePercent, sliderWidth, thumbHalfWidth, clamped) - markHalfWidth;
315
322
  // Clamp to the left and right bounds of the container
316
323
  left = Math.max(0, Math.min(left, sliderWidth - markWidth));
317
324
  markEl.style.left = `${left}px`;
@@ -348,7 +355,7 @@ const SliderMarks = memo(({ marks, thumbRef, min, max }) => {
348
355
  // Placed against the slider's width: the marks show, at their own height (Slider.module.css)
349
356
  if (sliderWidth)
350
357
  marksContainerRef.current.dataset.measured = "";
351
- }, [marks, thumbRef, marksContainerRef, min, max, sliderWidth]);
358
+ }, [marks, thumbRef, marksContainerRef, min, max, sliderWidth, tabletAndUp]);
352
359
  return (_jsx("div", { className: s.MarksContainer, ref: marksContainerRef, children: _jsx("div", { ref: measureRef, children: marks.map((mark) => (_jsx("div", { className: s.Mark, "data-mark": true, children: _jsx("span", { className: s.MarkLabel, children: mark.label }) }, mark.value))) }) }));
353
360
  });
354
361
  SliderMarks.displayName = "SliderMarks";
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAKL,IAAI,EAEJ,WAAW,EACX,SAAS,EACT,KAAK,EACL,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,CAAC,MAAM,oDAAoD,CAAA;AA6GlE;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,CAAC,KAAmB,EAAE,IAAiB,EAAE,MAAgB,EAAE,GAAW,EAAE,GA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AAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,CAAA;AAC5E,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport clamp from \"lodash/clamp\"\nimport round from \"lodash/round\"\nimport { Direction, Slider as RadixSlider } from \"radix-ui\"\nimport {\n type ChangeEventHandler,\n type ElementRef,\n type FocusEventHandler,\n type KeyboardEventHandler,\n memo,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useDebounceCallback, useResizeObserver } from \"usehooks-ts\"\nimport { useIsMounted } from \"../../hooks/useIsMounted\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { usePrevious } from \"../../hooks/usePrevious\"\nimport { useStableCallback } from \"../../hooks/useStableCallback\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport { Button } from \"../Button\"\nimport { Reload } from \"../Icon\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/Slider/Slider.module.css\"\n\nexport type SliderMark = {\n value: number\n label: string\n}\n\ntype SliderBaseProps = {\n /**\n * The minimum value the slider can have\n */\n min: number\n /**\n * The maximum value the slider can have\n */\n max: number\n /**\n * The step increment between slider values\n */\n step: number\n /**\n * Unit to display next to the slider value (e.g., ms, px)\n */\n unit?: string\n /**\n * Unit to display to the right of the slider value (e.g., $)\n */\n prefixUnit?: string\n /**\n * Optional label for the slider, which can be a string or React node.\n */\n label?: ReactNode\n /**\n * Accessible name for the slider when there is no visible `label`\n */\n \"aria-label\"?: string\n /**\n * Id of an element that names the slider; takes precedence over `label`\n */\n \"aria-labelledby\"?: string\n /**\n * List of marks to display below the slider track\n */\n marks?: SliderMark[]\n /**\n * Color of the slider track\n */\n trackColor?: string\n /**\n * Color of the slider progress along the track\n */\n rangeColor?: string\n className?: string\n disabled?: boolean\n /**\n * Orientation of the slider\n * @default \"horizontal\"\n */\n orientation?: \"horizontal\" | \"vertical\"\n onBlur?: FocusEventHandler<HTMLInputElement>\n onFocus?: FocusEventHandler<HTMLInputElement>\n ref?: React.Ref<ElementRef<typeof RadixSlider.Root> | null>\n}\n\ntype SingleSliderProps = SliderBaseProps & {\n /**\n * When false or omitted, the slider has a single thumb\n */\n range?: false\n /**\n * The current value of the slider\n */\n value: number\n /**\n * Callback function invoked when the slider value changes.\n */\n onChange: (value: number) => void\n /**\n * Value that will be offered as a \"reset to default\" option\n */\n resetValue?: number\n /**\n * String that will be displayed in the tooltip\n * @default Reset to default\n */\n resetTooltip?: string\n}\n\ntype RangeSliderProps = SliderBaseProps & {\n /**\n * When true, the slider supports multiple thumbs\n */\n range: true\n /**\n * Array of values, one per thumb\n */\n value: number[]\n /**\n * Callback function invoked when slider values change.\n */\n onChange: (value: number[]) => void\n /**\n * Minimum number of steps between thumbs\n */\n minStepsBetweenThumbs?: number\n}\n\nexport type SliderProps = SingleSliderProps | RangeSliderProps\n\n/**\n * A press on the track of a range moves the thumb whose value lies nearest the press, which Radix focuses only\n * once that value changes. Focusing it at once lets a phone draw the knob being pressed as the lens of glass\n * (Slider.module.css), even when the press leaves the value as it is. The thumb is the one Radix moves: the\n * pointer mapped onto min to max across the root (from the right in a right-to-left direction, which Radix\n * takes from a DirectionProvider), the nearest value, the first on a tie. A press on a thumb itself is left\n * to Radix, which focuses that thumb.\n */\nconst focusThumbToMove = (event: PointerEvent, root: HTMLElement, values: number[], min: number, max: number, vertical: boolean, rtl: boolean) => {\n const thumbs = Array.from(root.querySelectorAll<HTMLElement>('[role=\"slider\"]'))\n if (thumbs.includes(event.target as HTMLElement)) return\n const rect = root.getBoundingClientRect()\n const ratio = vertical ? (rect.bottom - event.clientY) / rect.height : (rtl ? rect.right - event.clientX : event.clientX - rect.left) / rect.width\n const pointerValue = min + ratio * (max - min)\n const distances = values.map((value) => Math.abs(value - pointerValue))\n const thumb = thumbs[distances.indexOf(Math.min(...distances))]\n if (thumb && thumb !== document.activeElement) thumb.focus({ preventScroll: true, focusVisible: false } as FocusOptions)\n}\n\nexport const Slider = memo((props: SliderProps) => {\n const {\n className,\n onChange,\n min,\n max,\n step,\n disabled,\n value,\n onBlur,\n onFocus,\n unit,\n prefixUnit,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n marks: propMarks = [],\n trackColor,\n rangeColor,\n orientation = \"horizontal\",\n ref: forwardedRef,\n } = props\n\n const isRange = props.range === true\n const isVertical = orientation === \"vertical\"\n // The direction Radix slides in: no `dir` is passed, so it is the one of a DirectionProvider, else left to right.\n const direction = Direction.useDirection()\n\n const id = useId()\n const labelId = `${id}-label`\n // What names the thumbs: an explicit labelledby, else the visible label\n const nameId = ariaLabelledBy ?? (label ? labelId : undefined)\n const precision = useMemo(() => String(step).split(\".\")[1]?.length ?? 0, [step])\n\n // Single-mode state for editable input\n const singleValue = isRange ? 0 : (value as number)\n const [inputValue, setInputValue] = useState<string>(\n isRange ? \"\" : String((value as number).toFixed(precision)),\n )\n const setInputValueNumber = useCallback(\n (nextValue: number) => {\n setInputValue(nextValue.toFixed(precision))\n },\n [precision],\n )\n\n // prevents input from jumping around while the user is typing\n const singleOnChange = isRange ? undefined : (onChange as (v: number) => void)\n // One debounced function for the slider's lifetime (calling the latest\n // onChange), so an immediate change can cancel the pending typed one\n const debouncedOnChange = useDebounceCallback(\n useStableCallback((nextValue: number) => {\n if (!disabled) singleOnChange?.(nextValue)\n }),\n 250,\n )\n const [pointerDown, setPointerDown] = useState(false)\n const [resetPending, setResetPending] = useState(false)\n // Read the controlled owner after a reset request, including a refused request.\n useEffect(() => {\n if (!resetPending) return\n setResetPending(false)\n if (!isRange) setInputValueNumber(singleValue)\n }, [resetPending, isRange, singleValue, setInputValueNumber])\n useEffect(() => () => debouncedOnChange.cancel(), [debouncedOnChange])\n useEffect(() => {\n if (!disabled) return\n debouncedOnChange.cancel()\n setPointerDown(false)\n if (!isRange) setInputValueNumber(singleValue)\n }, [disabled, isRange, singleValue, setInputValueNumber, debouncedOnChange])\n const isMounted = useIsMounted()\n\n // Used to position the input over the thumb\n const inputRef = useRef<HTMLInputElement>(null)\n\n const inputWidth = getValueWidth(inputValue)\n\n // Calculate animation duration based on the distance the thumb needs to move\n // Skip custom animation for range mode — let Radix handle it\n const percent = isRange ? 0 : ((value as number) - min) / (max - min)\n const previousPercent = usePrevious(percent)\n const animationDurationMS =\n isRange || !isMounted || pointerDown\n ? 0\n : Math.max(Math.abs(percent - previousPercent) * 300, 100)\n\n // We assume that the width of the thumb does not change from render to render\n const thumbRef = useRef<HTMLDivElement>(null)\n\n // Sort marks for collision detection, again only when a value or label changes\n const marksKey = JSON.stringify(propMarks.map(({ value, label }) => [value, label]))\n const marks = useMemo<SliderMark[]>(\n () => [...propMarks].sort((a, b) => a.value - b.value),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [marksKey],\n )\n\n // Validate marks\n useEffect(() => {\n if (!marks) return\n const markValues = new Set<number>()\n for (const mark of marks) {\n if (mark.value < min || mark.value > max) {\n throw new Error(`Slider mark value ${mark.value} is out of bounds [${min}, ${max}]`)\n }\n if (markValues.has(mark.value)) {\n throw new Error(\"Slider marks must have unique values\")\n }\n markValues.add(mark.value)\n }\n }, [marks, max, min])\n\n // Update value if out of bounds (single mode only)\n const latestValue = useLatestValue(value)\n const latestOnChange = useLatestValue(onChange)\n useEffect(() => {\n if (isRange) return\n const v = latestValue.current as number\n const clamped = clamp(v, min, max)\n if (clamped !== v) {\n ;(latestOnChange.current as (v: number) => void)(clamped)\n setInputValueNumber(clamped)\n }\n }, [max, min, latestValue, latestOnChange, setInputValueNumber, isRange])\n\n useEffect(() => {\n if (isRange) return\n if (inputRef.current !== document.activeElement) {\n setInputValueNumber(value as number)\n }\n }, [value, setInputValueNumber, isRange])\n\n // Single-mode keyboard handler: a key's change replaces a pending typed one\n const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (evt) => {\n if (disabled || isRange || !singleOnChange) return\n if (evt.key === \"Home\") {\n evt.preventDefault()\n debouncedOnChange.cancel()\n singleOnChange(min)\n setInputValueNumber(min)\n }\n if (evt.key === \"End\") {\n evt.preventDefault()\n debouncedOnChange.cancel()\n singleOnChange(max)\n setInputValueNumber(max)\n }\n if (evt.key === \"ArrowUp\") {\n evt.preventDefault()\n const multiplier = evt.shiftKey ? 10 : 1\n const next = clamp(singleValue + step * multiplier, min, max)\n debouncedOnChange.cancel()\n singleOnChange(next)\n setInputValueNumber(next)\n }\n if (evt.key === \"ArrowDown\") {\n evt.preventDefault()\n const multiplier = evt.shiftKey ? 10 : 1\n const next = clamp(singleValue - step * multiplier, min, max)\n debouncedOnChange.cancel()\n singleOnChange(next)\n setInputValueNumber(next)\n }\n if (evt.key === \"Enter\" || evt.key === \"Escape\") {\n evt.preventDefault()\n evt.currentTarget.blur()\n }\n }\n\n const handleInputChange: ChangeEventHandler<HTMLInputElement> = (evt) => {\n if (disabled || isRange || !singleOnChange) return\n // Mobile decimal keyboards may use a comma. A minus is valid only below zero.\n const nextValue = evt.currentTarget.value.trim().replace(/,/g, \".\").replace(min < 0 ? /(?!^-)[^\\d.]/g : /[^\\d.]/g, \"\")\n debouncedOnChange.cancel()\n let parsed = parseFloat(nextValue || \"0\")\n if (Number.isNaN(parsed)) {\n // A lone \"-\" or \".\" is a number still being typed: nothing to report yet\n setInputValue(nextValue)\n return\n }\n parsed = clamp(parsed, min, max)\n if (step >= 1) {\n parsed = Math.floor(parsed)\n }\n debouncedOnChange(parsed)\n setInputValue(nextValue)\n }\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = (evt) => {\n if (isRange || !singleOnChange) return\n // Blur commits the typed text, so its pending debounced change is dropped\n debouncedOnChange.cancel()\n if (disabled) {\n setInputValueNumber(singleValue)\n onBlur?.(evt)\n return\n }\n let parsed = parseFloat(evt.target.value.trim().replace(/,/g, \".\")) || 0\n if (step >= 1) {\n parsed = Math.floor(parsed)\n } else {\n parsed = round(parsed, precision)\n }\n parsed = clamp(parsed, min, max)\n if (parsed !== singleValue) {\n singleOnChange(parsed)\n }\n setInputValueNumber(parsed)\n onBlur?.(evt)\n }\n\n // Radix value/onChange wiring\n const radixValue = isRange ? (value as number[]) : [value as number]\n const handleValueChange = (values: number[]) => {\n if (disabled) return\n debouncedOnChange.cancel()\n if (isRange) (onChange as (v: number[]) => void)(values)\n else (onChange as (v: number) => void)(values[0])\n }\n\n // Single-mode props\n const resetValue = !isRange ? (props as SingleSliderProps).resetValue : undefined\n const resetTooltip = !isRange\n ? (props as SingleSliderProps).resetTooltip ?? \"Reset to default\"\n : undefined\n\n // Range-mode props\n const minStepsBetweenThumbs = isRange\n ? (props as RangeSliderProps).minStepsBetweenThumbs\n : undefined\n\n // Show marks only in horizontal orientation\n const showMarks = marks.length > 0 && !isVertical\n\n // Format range display text\n const rangeDisplayText = isRange\n ? (value as number[])\n .map((v) => `${prefixUnit ?? \"\"}${v.toFixed(precision)}${unit ?? \"\"}`)\n .join(\" – \")\n : \"\"\n\n return (\n <div\n className={clsx(s.SliderWrap, className)}\n data-orientation={orientation}\n >\n {label && (\n <div className={s.SliderLabel}>\n {/* Range mode renders no value input, so the label only names the thumbs */}\n <label htmlFor={isRange ? undefined : id} id={labelId} className=\"flex-1\">\n {label}\n </label>\n {!isRange && resetValue !== undefined && (\n <Tooltip content={resetTooltip!} compact>\n <Button\n size=\"2xs\"\n variant=\"ghost\"\n color=\"secondary\"\n className={s.Reset}\n aria-label={resetTooltip}\n disabled={disabled}\n data-hide={disabled || (resetValue === singleValue && !pointerDown)}\n onClick={() => {\n if (disabled) return\n debouncedOnChange.cancel()\n singleOnChange?.(resetValue)\n setResetPending(true)\n }}\n >\n <Reload />\n </Button>\n </Tooltip>\n )}\n {isRange ? (\n <span className={s.RangeDisplay}>{rangeDisplayText}</span>\n ) : (\n <div className={s.SliderValue} onClick={() => { if (!disabled) inputRef.current?.focus() }}>\n {prefixUnit && <span className={s.ValueUnit}>{prefixUnit}</span>}\n <input\n id={id}\n className={s.ValueInput}\n ref={inputRef}\n style={{ width: inputWidth }}\n onKeyDown={handleKeyDown}\n value={inputValue}\n type=\"text\"\n inputMode={min < 0 ? \"text\" : Number.isInteger(min) && Number.isInteger(max) && Number.isInteger(step) ? \"numeric\" : \"decimal\"}\n onClick={(e) => e.stopPropagation()}\n onBlur={handleInputBlur}\n onFocus={(e) => {\n e.currentTarget.setSelectionRange(0, e.currentTarget.value.length)\n onFocus?.(e)\n }}\n onChange={handleInputChange}\n disabled={disabled}\n />\n {unit && <span className={s.ValueUnit}>{unit}</span>}\n </div>\n )}\n </div>\n )}\n <div className={s.SliderContainer}>\n <RadixSlider.Root\n ref={forwardedRef}\n className={s.Slider}\n onValueChange={handleValueChange}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n value={radixValue}\n orientation={orientation}\n minStepsBetweenThumbs={minStepsBetweenThumbs}\n onBlur={onBlur}\n onFocus={onFocus}\n onPointerDown={(event) => {\n if (disabled) return\n setPointerDown(true)\n if (isRange) focusThumbToMove(event.nativeEvent, event.currentTarget, radixValue, min, max, isVertical, direction === \"rtl\")\n }}\n onPointerUp={() => setPointerDown(false)}\n onPointerCancel={() => setPointerDown(false)}\n data-pressed={pointerDown ? \"\" : undefined}\n data-range={isRange ? \"\" : undefined}\n style={toCssVariables({\n \"slider-duration\": `${animationDurationMS}ms`,\n \"slider-track-color\": trackColor,\n \"slider-range-color\": rangeColor,\n })}\n >\n <RadixSlider.Track className={s.Track}>\n <RadixSlider.Range className={s.Range} />\n </RadixSlider.Track>\n {isRange ? (\n (value as number[]).map((_, i) => (\n <RadixSlider.Thumb\n key={i}\n id={`${id}-thumb-${i}`}\n className={s.Thumb}\n // The marks measure the first thumb (all thumbs are the same size)\n ref={i === 0 ? thumbRef : undefined}\n // Name plus the thumb's own Radix name (\"Minimum\" / \"Maximum\"),\n // so the endpoints stay distinguishable\n aria-labelledby={nameId ? `${nameId} ${id}-thumb-${i}` : undefined}\n // Only pass aria-label when set: an explicit undefined would\n // replace the name Radix gives the thumb\n {...(!nameId && ariaLabel\n ? {\n \"aria-label\":\n `${ariaLabel} ${rangeThumbName(i, (value as number[]).length)}`.trim(),\n }\n : {})}\n />\n ))\n ) : (\n <RadixSlider.Thumb\n className={s.Thumb}\n ref={thumbRef}\n aria-labelledby={nameId}\n {...(!nameId && ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n />\n )}\n </RadixSlider.Root>\n {showMarks && <SliderMarks marks={marks} thumbRef={thumbRef} min={min} max={max} />}\n </div>\n </div>\n )\n})\nSlider.displayName = \"Slider\"\n\n// Matches the names Radix gives range thumbs on its own\nconst rangeThumbName = (index: number, count: number) =>\n count === 2 ? (index === 0 ? \"Minimum\" : \"Maximum\") : count > 2 ? `Value ${index + 1} of ${count}` : \"\"\n\ntype MarksProps = {\n marks: SliderMark[]\n thumbRef: React.RefObject<HTMLDivElement | null>\n min: number\n max: number\n}\n\n// The minimum difference we enforce between marks, in pixels\nconst MINIMUM_MARK_SPACING_PX = 16\n\nconst SliderMarks = memo(({ marks, thumbRef, min, max }: MarksProps) => {\n // We seperate the container and measure divs so that our resize observer\n // does not fire when we adjust the height of the marks container.\n const marksContainerRef = useRef<HTMLDivElement>(null)\n const measureRef = useRef<HTMLDivElement>(null)\n\n // We measure the width of the slider within this component so that sliders\n // without marks do not pay a performance penalty.\n // @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663\n const { width: sliderWidth } = useResizeObserver({ ref: measureRef })\n\n useLayoutEffect(() => {\n // Impossible\n if (!thumbRef.current || !marksContainerRef.current) {\n return\n }\n\n const markElements = Array.from(\n marksContainerRef.current.querySelectorAll(\"[data-mark]\"),\n ) as HTMLDivElement[]\n\n const thumbHalfWidth = thumbRef.current.getBoundingClientRect().width / 2\n\n // Wipe all styles so we can accurately determine the positions of the marks\n markElements.forEach((markEl) => {\n markEl.style.width = \"\"\n markEl.style.display = \"\"\n })\n\n const positionMarks = () => {\n if (!sliderWidth) {\n return\n }\n\n markElements.forEach((markEl, index) => {\n const markValue = marks[index].value\n const valuePercent = (markValue - min) / (max - min)\n const markWidth = markEl.getBoundingClientRect().width\n const markHalfWidth = markWidth / 2\n\n // Radix smoothes the width of the thumb over the entire track so\n // that the thumb is always within bounds. We need to duplicate\n // this smoothing so that the marks match the observed breakpoints.\n const smoothedThumb = thumbHalfWidth - valuePercent * (thumbHalfWidth / 0.5)\n\n // Calculate where we would naively put the mark based on the value\n const naiveLeftOffset = valuePercent * sliderWidth\n\n // Add the thumb smoothing, and account for the width of the mark itself\n let left = naiveLeftOffset + smoothedThumb - markHalfWidth\n\n // Clamp to the left and right bounds of the container\n left = Math.max(0, Math.min(left, sliderWidth - markWidth))\n\n markEl.style.left = `${left}px`\n })\n }\n\n const marksHaveCollisions = () => {\n for (let i = 0; i < markElements.length - 1; i++) {\n const currentRect = markElements[i].getBoundingClientRect()\n const nextRect = markElements[i + 1].getBoundingClientRect()\n\n if (currentRect.right + MINIMUM_MARK_SPACING_PX > nextRect.left) {\n return true\n }\n }\n return false\n }\n\n positionMarks()\n\n // If we have collisions, try to wrap the content\n if (marksHaveCollisions()) {\n markElements.forEach((markEl) => {\n markEl.style.width = \"min-content\"\n })\n\n positionMarks()\n\n // Hide all marks if we still have collisions\n if (marksHaveCollisions()) {\n markElements.forEach((markEl) => {\n markEl.style.display = \"none\"\n })\n }\n }\n\n const tallestHeight = Math.max(\n ...markElements.map((markEl) => markEl.getBoundingClientRect().height),\n )\n\n // Give our container a height so that we allocate space on the page\n // for the marks and push down other content when we have to wrap\n marksContainerRef.current.style.height = tallestHeight > 0 ? `${tallestHeight}px` : \"\"\n // Placed against the slider's width: the marks show, at their own height (Slider.module.css)\n if (sliderWidth) marksContainerRef.current.dataset.measured = \"\"\n }, [marks, thumbRef, marksContainerRef, min, max, sliderWidth])\n\n return (\n <div className={s.MarksContainer} ref={marksContainerRef}>\n <div ref={measureRef}>\n {marks.map((mark) => (\n <div key={mark.value} className={s.Mark} data-mark>\n <span className={s.MarkLabel}>{mark.label}</span>\n </div>\n ))}\n </div>\n </div>\n )\n})\nSliderMarks.displayName = \"SliderMarks\"\n\n/**\n * The value field is as wide as its characters at any font size: tabular digits are one `ch` each, and a sign,\n * a decimal point or a separator about half of one, so a right-aligned value sits next to its prefix unit.\n */\nconst getValueWidth = (text: string): string => {\n const digits = text.replace(/[^0-9]/g, \"\").length\n return `calc(${Math.max(digits + (text.length - digits) / 2, 1)}ch + 1px)`\n}\n"]}
1
+ {"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAKL,IAAI,EAEJ,WAAW,EACX,SAAS,EACT,KAAK,EACL,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,CAAC,MAAM,oDAAoD,CAAA;AA6GlE;;;;;;;GAOG;AACH,MAAM,gBAA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,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QACtF,6FAA6F;QAC7F,IAAI,WAAW;YAAE,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAA;IAClE,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAA;IAE5E,OAAO,CACL,cAAK,SAAS,EAAE,CAAC,CAAC,cAAc,EAAE,GAAG,EAAE,iBAAiB,YACtD,cAAK,GAAG,EAAE,UAAU,YACjB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,cAAsB,SAAS,EAAE,CAAC,CAAC,IAAI,+BACrC,eAAM,SAAS,EAAE,CAAC,CAAC,SAAS,YAAG,IAAI,CAAC,KAAK,GAAQ,IADzC,IAAI,CAAC,KAAK,CAEd,CACP,CAAC,GACE,GACF,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AACF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAA;AAEvC;;;GAGG;AACH,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,MAAM,CAAA;IACjD,OAAO,QAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,CAAA;AAC5E,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport clamp from \"lodash/clamp\"\nimport round from \"lodash/round\"\nimport { Direction, Slider as RadixSlider } from \"radix-ui\"\nimport {\n type ChangeEventHandler,\n type ElementRef,\n type FocusEventHandler,\n type KeyboardEventHandler,\n memo,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useDebounceCallback, useResizeObserver } from \"usehooks-ts\"\nimport { useBreakpoint } from \"../../hooks/useBreakpoints\"\nimport { useIsMounted } from \"../../hooks/useIsMounted\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { usePrevious } from \"../../hooks/usePrevious\"\nimport { useStableCallback } from \"../../hooks/useStableCallback\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport { Button } from \"../Button\"\nimport { Reload } from \"../Icon\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/Slider/Slider.module.css\"\n\nexport type SliderMark = {\n value: number\n label: string\n}\n\ntype SliderBaseProps = {\n /**\n * The minimum value the slider can have\n */\n min: number\n /**\n * The maximum value the slider can have\n */\n max: number\n /**\n * The step increment between slider values\n */\n step: number\n /**\n * Unit to display next to the slider value (e.g., ms, px)\n */\n unit?: string\n /**\n * Unit to display to the right of the slider value (e.g., $)\n */\n prefixUnit?: string\n /**\n * Optional label for the slider, which can be a string or React node.\n */\n label?: ReactNode\n /**\n * Accessible name for the slider when there is no visible `label`\n */\n \"aria-label\"?: string\n /**\n * Id of an element that names the slider; takes precedence over `label`\n */\n \"aria-labelledby\"?: string\n /**\n * List of marks to display below the slider track\n */\n marks?: SliderMark[]\n /**\n * Color of the slider track\n */\n trackColor?: string\n /**\n * Color of the slider progress along the track\n */\n rangeColor?: string\n className?: string\n disabled?: boolean\n /**\n * Orientation of the slider\n * @default \"horizontal\"\n */\n orientation?: \"horizontal\" | \"vertical\"\n onBlur?: FocusEventHandler<HTMLInputElement>\n onFocus?: FocusEventHandler<HTMLInputElement>\n ref?: React.Ref<ElementRef<typeof RadixSlider.Root> | null>\n}\n\ntype SingleSliderProps = SliderBaseProps & {\n /**\n * When false or omitted, the slider has a single thumb\n */\n range?: false\n /**\n * The current value of the slider\n */\n value: number\n /**\n * Callback function invoked when the slider value changes.\n */\n onChange: (value: number) => void\n /**\n * Value that will be offered as a \"reset to default\" option\n */\n resetValue?: number\n /**\n * String that will be displayed in the tooltip\n * @default Reset to default\n */\n resetTooltip?: string\n}\n\ntype RangeSliderProps = SliderBaseProps & {\n /**\n * When true, the slider supports multiple thumbs\n */\n range: true\n /**\n * Array of values, one per thumb\n */\n value: number[]\n /**\n * Callback function invoked when slider values change.\n */\n onChange: (value: number[]) => void\n /**\n * Minimum number of steps between thumbs\n */\n minStepsBetweenThumbs?: number\n}\n\nexport type SliderProps = SingleSliderProps | RangeSliderProps\n\n/**\n * A press on the track of a range moves the thumb whose value lies nearest the press, which Radix focuses only\n * once that value changes. Focusing it at once lets a phone draw the knob being pressed as the lens of glass\n * (Slider.module.css), even when the press leaves the value as it is. The thumb is the one Radix moves: the\n * pointer mapped onto min to max across the root (from the right in a right-to-left direction, which Radix\n * takes from a DirectionProvider), the nearest value, the first on a tie. A press on a thumb itself is left\n * to Radix, which focuses that thumb.\n */\nconst focusThumbToMove = (event: PointerEvent, root: HTMLElement, values: number[], min: number, max: number, vertical: boolean, rtl: boolean) => {\n const thumbs = Array.from(root.querySelectorAll<HTMLElement>('[role=\"slider\"]'))\n if (thumbs.includes(event.target as HTMLElement)) return\n const rect = root.getBoundingClientRect()\n const ratio = vertical ? (rect.bottom - event.clientY) / rect.height : (rtl ? rect.right - event.clientX : event.clientX - rect.left) / rect.width\n const pointerValue = min + ratio * (max - min)\n const distances = values.map((value) => Math.abs(value - pointerValue))\n const thumb = thumbs[distances.indexOf(Math.min(...distances))]\n if (thumb && thumb !== document.activeElement) thumb.focus({ preventScroll: true, focusVisible: false } as FocusOptions)\n}\n\n/** A knob's value from 0 to 1, by which a phone stands the knob on its value as iOS does (Slider.module.css). */\nconst thumbPercentStyle = (value: number, min: number, max: number) =>\n ({ \"--slider-thumb-percent\": String(max > min ? clamp((value - min) / (max - min), 0, 1) : 0) }) as React.CSSProperties\n\n/**\n * Where a knob's centre stands at a value (0 to 1), from the start of a track `width` wide. Radix eases the knob\n * over the whole track to keep it inside; on a phone it stands on the value and stops half its width from each\n * end, as iOS (`clamped`, Slider.module.css).\n */\nconst thumbCentre = (percent: number, width: number, thumbHalf: number, clamped: boolean) =>\n clamped ? clamp(percent * width, thumbHalf, width - thumbHalf) : percent * width + thumbHalf * (1 - 2 * percent)\n\nexport const Slider = memo((props: SliderProps) => {\n const {\n className,\n onChange,\n min,\n max,\n step,\n disabled,\n value,\n onBlur,\n onFocus,\n unit,\n prefixUnit,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n marks: propMarks = [],\n trackColor,\n rangeColor,\n orientation = \"horizontal\",\n ref: forwardedRef,\n } = props\n\n const isRange = props.range === true\n const isVertical = orientation === \"vertical\"\n // The direction Radix slides in: no `dir` is passed, so it is the one of a DirectionProvider, else left to right.\n const direction = Direction.useDirection()\n\n const id = useId()\n const labelId = `${id}-label`\n // What names the thumbs: an explicit labelledby, else the visible label\n const nameId = ariaLabelledBy ?? (label ? labelId : undefined)\n const precision = useMemo(() => String(step).split(\".\")[1]?.length ?? 0, [step])\n\n // Single-mode state for editable input\n const singleValue = isRange ? 0 : (value as number)\n const [inputValue, setInputValue] = useState<string>(\n isRange ? \"\" : String((value as number).toFixed(precision)),\n )\n const setInputValueNumber = useCallback(\n (nextValue: number) => {\n setInputValue(nextValue.toFixed(precision))\n },\n [precision],\n )\n\n // prevents input from jumping around while the user is typing\n const singleOnChange = isRange ? undefined : (onChange as (v: number) => void)\n // One debounced function for the slider's lifetime (calling the latest\n // onChange), so an immediate change can cancel the pending typed one\n const debouncedOnChange = useDebounceCallback(\n useStableCallback((nextValue: number) => {\n if (!disabled) singleOnChange?.(nextValue)\n }),\n 250,\n )\n const [pointerDown, setPointerDown] = useState(false)\n const [resetPending, setResetPending] = useState(false)\n // Read the controlled owner after a reset request, including a refused request.\n useEffect(() => {\n if (!resetPending) return\n setResetPending(false)\n if (!isRange) setInputValueNumber(singleValue)\n }, [resetPending, isRange, singleValue, setInputValueNumber])\n useEffect(() => () => debouncedOnChange.cancel(), [debouncedOnChange])\n useEffect(() => {\n if (!disabled) return\n debouncedOnChange.cancel()\n setPointerDown(false)\n if (!isRange) setInputValueNumber(singleValue)\n }, [disabled, isRange, singleValue, setInputValueNumber, debouncedOnChange])\n const isMounted = useIsMounted()\n\n // Used to position the input over the thumb\n const inputRef = useRef<HTMLInputElement>(null)\n\n const inputWidth = getValueWidth(inputValue)\n\n // Calculate animation duration based on the distance the thumb needs to move\n // Skip custom animation for range mode — let Radix handle it\n const percent = isRange ? 0 : ((value as number) - min) / (max - min)\n const previousPercent = usePrevious(percent)\n const animationDurationMS =\n isRange || !isMounted || pointerDown\n ? 0\n : Math.max(Math.abs(percent - previousPercent) * 300, 100)\n\n // We assume that the width of the thumb does not change from render to render\n const thumbRef = useRef<HTMLDivElement>(null)\n\n // Sort marks for collision detection, again only when a value or label changes\n const marksKey = JSON.stringify(propMarks.map(({ value, label }) => [value, label]))\n const marks = useMemo<SliderMark[]>(\n () => [...propMarks].sort((a, b) => a.value - b.value),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [marksKey],\n )\n\n // Validate marks\n useEffect(() => {\n if (!marks) return\n const markValues = new Set<number>()\n for (const mark of marks) {\n if (mark.value < min || mark.value > max) {\n throw new Error(`Slider mark value ${mark.value} is out of bounds [${min}, ${max}]`)\n }\n if (markValues.has(mark.value)) {\n throw new Error(\"Slider marks must have unique values\")\n }\n markValues.add(mark.value)\n }\n }, [marks, max, min])\n\n // Update value if out of bounds (single mode only)\n const latestValue = useLatestValue(value)\n const latestOnChange = useLatestValue(onChange)\n useEffect(() => {\n if (isRange) return\n const v = latestValue.current as number\n const clamped = clamp(v, min, max)\n if (clamped !== v) {\n ;(latestOnChange.current as (v: number) => void)(clamped)\n setInputValueNumber(clamped)\n }\n }, [max, min, latestValue, latestOnChange, setInputValueNumber, isRange])\n\n useEffect(() => {\n if (isRange) return\n if (inputRef.current !== document.activeElement) {\n setInputValueNumber(value as number)\n }\n }, [value, setInputValueNumber, isRange])\n\n // Single-mode keyboard handler: a key's change replaces a pending typed one\n const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (evt) => {\n if (disabled || isRange || !singleOnChange) return\n if (evt.key === \"Home\") {\n evt.preventDefault()\n debouncedOnChange.cancel()\n singleOnChange(min)\n setInputValueNumber(min)\n }\n if (evt.key === \"End\") {\n evt.preventDefault()\n debouncedOnChange.cancel()\n singleOnChange(max)\n setInputValueNumber(max)\n }\n if (evt.key === \"ArrowUp\") {\n evt.preventDefault()\n const multiplier = evt.shiftKey ? 10 : 1\n const next = clamp(singleValue + step * multiplier, min, max)\n debouncedOnChange.cancel()\n singleOnChange(next)\n setInputValueNumber(next)\n }\n if (evt.key === \"ArrowDown\") {\n evt.preventDefault()\n const multiplier = evt.shiftKey ? 10 : 1\n const next = clamp(singleValue - step * multiplier, min, max)\n debouncedOnChange.cancel()\n singleOnChange(next)\n setInputValueNumber(next)\n }\n if (evt.key === \"Enter\" || evt.key === \"Escape\") {\n evt.preventDefault()\n evt.currentTarget.blur()\n }\n }\n\n const handleInputChange: ChangeEventHandler<HTMLInputElement> = (evt) => {\n if (disabled || isRange || !singleOnChange) return\n // Mobile decimal keyboards may use a comma. A minus is valid only below zero.\n const nextValue = evt.currentTarget.value.trim().replace(/,/g, \".\").replace(min < 0 ? /(?!^-)[^\\d.]/g : /[^\\d.]/g, \"\")\n debouncedOnChange.cancel()\n let parsed = parseFloat(nextValue || \"0\")\n if (Number.isNaN(parsed)) {\n // A lone \"-\" or \".\" is a number still being typed: nothing to report yet\n setInputValue(nextValue)\n return\n }\n parsed = clamp(parsed, min, max)\n if (step >= 1) {\n parsed = Math.floor(parsed)\n }\n debouncedOnChange(parsed)\n setInputValue(nextValue)\n }\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = (evt) => {\n if (isRange || !singleOnChange) return\n // Blur commits the typed text, so its pending debounced change is dropped\n debouncedOnChange.cancel()\n if (disabled) {\n setInputValueNumber(singleValue)\n onBlur?.(evt)\n return\n }\n let parsed = parseFloat(evt.target.value.trim().replace(/,/g, \".\")) || 0\n if (step >= 1) {\n parsed = Math.floor(parsed)\n } else {\n parsed = round(parsed, precision)\n }\n parsed = clamp(parsed, min, max)\n if (parsed !== singleValue) {\n singleOnChange(parsed)\n }\n setInputValueNumber(parsed)\n onBlur?.(evt)\n }\n\n // Radix value/onChange wiring\n const radixValue = isRange ? (value as number[]) : [value as number]\n const handleValueChange = (values: number[]) => {\n if (disabled) return\n debouncedOnChange.cancel()\n if (isRange) (onChange as (v: number[]) => void)(values)\n else (onChange as (v: number) => void)(values[0])\n }\n\n // Single-mode props\n const resetValue = !isRange ? (props as SingleSliderProps).resetValue : undefined\n const resetTooltip = !isRange\n ? (props as SingleSliderProps).resetTooltip ?? \"Reset to default\"\n : undefined\n\n // Range-mode props\n const minStepsBetweenThumbs = isRange\n ? (props as RangeSliderProps).minStepsBetweenThumbs\n : undefined\n\n // Show marks only in horizontal orientation\n const showMarks = marks.length > 0 && !isVertical\n\n // Format range display text\n const rangeDisplayText = isRange\n ? (value as number[])\n .map((v) => `${prefixUnit ?? \"\"}${v.toFixed(precision)}${unit ?? \"\"}`)\n .join(\" – \")\n : \"\"\n\n return (\n <div\n className={clsx(s.SliderWrap, className)}\n data-orientation={orientation}\n >\n {label && (\n <div className={s.SliderLabel}>\n {/* Range mode renders no value input, so the label only names the thumbs */}\n <label htmlFor={isRange ? undefined : id} id={labelId} className=\"flex-1\">\n {label}\n </label>\n {!isRange && resetValue !== undefined && (\n <Tooltip content={resetTooltip!} compact>\n <Button\n size=\"2xs\"\n variant=\"ghost\"\n color=\"secondary\"\n className={s.Reset}\n aria-label={resetTooltip}\n disabled={disabled}\n data-hide={disabled || (resetValue === singleValue && !pointerDown)}\n onClick={() => {\n if (disabled) return\n debouncedOnChange.cancel()\n singleOnChange?.(resetValue)\n setResetPending(true)\n }}\n >\n <Reload />\n </Button>\n </Tooltip>\n )}\n {isRange ? (\n <span className={s.RangeDisplay}>{rangeDisplayText}</span>\n ) : (\n <div className={s.SliderValue} onClick={() => { if (!disabled) inputRef.current?.focus() }}>\n {prefixUnit && <span className={s.ValueUnit}>{prefixUnit}</span>}\n <input\n id={id}\n className={s.ValueInput}\n ref={inputRef}\n style={{ width: inputWidth }}\n onKeyDown={handleKeyDown}\n value={inputValue}\n type=\"text\"\n inputMode={min < 0 ? \"text\" : Number.isInteger(min) && Number.isInteger(max) && Number.isInteger(step) ? \"numeric\" : \"decimal\"}\n onClick={(e) => e.stopPropagation()}\n onBlur={handleInputBlur}\n onFocus={(e) => {\n e.currentTarget.setSelectionRange(0, e.currentTarget.value.length)\n onFocus?.(e)\n }}\n onChange={handleInputChange}\n disabled={disabled}\n />\n {unit && <span className={s.ValueUnit}>{unit}</span>}\n </div>\n )}\n </div>\n )}\n <div className={s.SliderContainer}>\n <RadixSlider.Root\n ref={forwardedRef}\n className={s.Slider}\n onValueChange={handleValueChange}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n value={radixValue}\n orientation={orientation}\n minStepsBetweenThumbs={minStepsBetweenThumbs}\n onBlur={onBlur}\n onFocus={onFocus}\n onPointerDown={(event) => {\n if (disabled) return\n setPointerDown(true)\n if (isRange) focusThumbToMove(event.nativeEvent, event.currentTarget, radixValue, min, max, isVertical, direction === \"rtl\")\n }}\n onPointerUp={() => setPointerDown(false)}\n onPointerCancel={() => setPointerDown(false)}\n data-pressed={pointerDown ? \"\" : undefined}\n data-range={isRange ? \"\" : undefined}\n style={toCssVariables({\n \"slider-duration\": `${animationDurationMS}ms`,\n \"slider-track-color\": trackColor,\n \"slider-range-color\": rangeColor,\n })}\n >\n <RadixSlider.Track className={s.Track}>\n <RadixSlider.Range className={s.Range} />\n </RadixSlider.Track>\n {isRange ? (\n (value as number[]).map((_, i) => (\n <RadixSlider.Thumb\n key={i}\n id={`${id}-thumb-${i}`}\n className={s.Thumb}\n style={thumbPercentStyle((value as number[])[i], min, max)}\n // The marks measure the first thumb (all thumbs are the same size)\n ref={i === 0 ? thumbRef : undefined}\n // Name plus the thumb's own Radix name (\"Minimum\" / \"Maximum\"),\n // so the endpoints stay distinguishable\n aria-labelledby={nameId ? `${nameId} ${id}-thumb-${i}` : undefined}\n // Only pass aria-label when set: an explicit undefined would\n // replace the name Radix gives the thumb\n {...(!nameId && ariaLabel\n ? {\n \"aria-label\":\n `${ariaLabel} ${rangeThumbName(i, (value as number[]).length)}`.trim(),\n }\n : {})}\n />\n ))\n ) : (\n <RadixSlider.Thumb\n className={s.Thumb}\n style={thumbPercentStyle(value as number, min, max)}\n ref={thumbRef}\n aria-labelledby={nameId}\n {...(!nameId && ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n />\n )}\n </RadixSlider.Root>\n {showMarks && <SliderMarks marks={marks} thumbRef={thumbRef} min={min} max={max} />}\n </div>\n </div>\n )\n})\nSlider.displayName = \"Slider\"\n\n// Matches the names Radix gives range thumbs on its own\nconst rangeThumbName = (index: number, count: number) =>\n count === 2 ? (index === 0 ? \"Minimum\" : \"Maximum\") : count > 2 ? `Value ${index + 1} of ${count}` : \"\"\n\ntype MarksProps = {\n marks: SliderMark[]\n thumbRef: React.RefObject<HTMLDivElement | null>\n min: number\n max: number\n}\n\n// The minimum difference we enforce between marks, in pixels\nconst MINIMUM_MARK_SPACING_PX = 16\n\nconst SliderMarks = memo(({ marks, thumbRef, min, max }: MarksProps) => {\n // We seperate the container and measure divs so that our resize observer\n // does not fire when we adjust the height of the marks container.\n const marksContainerRef = useRef<HTMLDivElement>(null)\n const measureRef = useRef<HTMLDivElement>(null)\n\n // We measure the width of the slider within this component so that sliders\n // without marks do not pay a performance penalty.\n // @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663\n const { width: sliderWidth } = useResizeObserver({ ref: measureRef })\n // The knob's travel changes at the phone breakpoint (Slider.module.css), also where the width stays\n const tabletAndUp = useBreakpoint(\"md\")\n\n useLayoutEffect(() => {\n // Impossible\n if (!thumbRef.current || !marksContainerRef.current) {\n return\n }\n\n const markElements = Array.from(\n marksContainerRef.current.querySelectorAll(\"[data-mark]\"),\n ) as HTMLDivElement[]\n\n // Its layout width: a pressed knob is scaled into the lens\n const thumbHalfWidth = thumbRef.current.offsetWidth / 2\n const clamped = getComputedStyle(thumbRef.current).getPropertyValue(\"--slider-thumb-travel\").trim() === \"clamped\"\n\n // Wipe all styles so we can accurately determine the positions of the marks\n markElements.forEach((markEl) => {\n markEl.style.width = \"\"\n markEl.style.display = \"\"\n })\n\n const positionMarks = () => {\n if (!sliderWidth) {\n return\n }\n\n markElements.forEach((markEl, index) => {\n const markValue = marks[index].value\n const valuePercent = (markValue - min) / (max - min)\n const markWidth = markEl.getBoundingClientRect().width\n const markHalfWidth = markWidth / 2\n\n // Under the knob's centre at the mark's value, accounting for the width of the mark itself\n let left = thumbCentre(valuePercent, sliderWidth, thumbHalfWidth, clamped) - markHalfWidth\n\n // Clamp to the left and right bounds of the container\n left = Math.max(0, Math.min(left, sliderWidth - markWidth))\n\n markEl.style.left = `${left}px`\n })\n }\n\n const marksHaveCollisions = () => {\n for (let i = 0; i < markElements.length - 1; i++) {\n const currentRect = markElements[i].getBoundingClientRect()\n const nextRect = markElements[i + 1].getBoundingClientRect()\n\n if (currentRect.right + MINIMUM_MARK_SPACING_PX > nextRect.left) {\n return true\n }\n }\n return false\n }\n\n positionMarks()\n\n // If we have collisions, try to wrap the content\n if (marksHaveCollisions()) {\n markElements.forEach((markEl) => {\n markEl.style.width = \"min-content\"\n })\n\n positionMarks()\n\n // Hide all marks if we still have collisions\n if (marksHaveCollisions()) {\n markElements.forEach((markEl) => {\n markEl.style.display = \"none\"\n })\n }\n }\n\n const tallestHeight = Math.max(\n ...markElements.map((markEl) => markEl.getBoundingClientRect().height),\n )\n\n // Give our container a height so that we allocate space on the page\n // for the marks and push down other content when we have to wrap\n marksContainerRef.current.style.height = tallestHeight > 0 ? `${tallestHeight}px` : \"\"\n // Placed against the slider's width: the marks show, at their own height (Slider.module.css)\n if (sliderWidth) marksContainerRef.current.dataset.measured = \"\"\n }, [marks, thumbRef, marksContainerRef, min, max, sliderWidth, tabletAndUp])\n\n return (\n <div className={s.MarksContainer} ref={marksContainerRef}>\n <div ref={measureRef}>\n {marks.map((mark) => (\n <div key={mark.value} className={s.Mark} data-mark>\n <span className={s.MarkLabel}>{mark.label}</span>\n </div>\n ))}\n </div>\n </div>\n )\n})\nSliderMarks.displayName = \"SliderMarks\"\n\n/**\n * The value field is as wide as its characters at any font size: tabular digits are one `ch` each, and a sign,\n * a decimal point or a separator about half of one, so a right-aligned value sits next to its prefix unit.\n */\nconst getValueWidth = (text: string): string => {\n const digits = text.replace(/[^0-9]/g, \"\").length\n return `calc(${Math.max(digits + (text.length - digits) / 2, 1)}ch + 1px)`\n}\n"]}
@@ -48,7 +48,7 @@ export function Sortable({ value, onChange, layout = "list", as: Tag = "div", di
48
48
  }
49
49
  /** The grip of an item. Arrow keys move the item while the handle has focus. */
50
50
  function SortableHandle({ "aria-label": ariaLabel = "Reorder", className, children, ...rest }) {
51
- return (_jsx("button", { ...rest, type: "button", className: clsx(s.Handle, className), "data-sortable-handle": "", "aria-label": ariaLabel, children: children ?? _jsxs(_Fragment, { children: [_jsx(GripVertical, { className: s.DesktopGrip, "aria-hidden": true }), _jsx(Hamburger, { className: s.PhoneGrip, "aria-hidden": true })] }) }));
51
+ return (_jsx("button", { ...rest, type: "button", className: clsx(s.Handle, className), "data-sortable-handle": "", "aria-label": ariaLabel, children: children ?? _jsxs(_Fragment, { children: [_jsx(GripVertical, { className: s.DesktopGrip, "aria-hidden": true }), _jsx(Hamburger, { className: s.PhoneGrip, "aria-hidden": true, preserveAspectRatio: "none" })] }) }));
52
52
  }
53
53
  /** A place outside the lists that takes an item whole: a folder, a category in a side list. */
54
54
  function SortableTarget({ group, name, as: Tag = "div", className, ...rest }) {
@@ -1 +1 @@
1
- {"version":3,"file":"Sortable.js","sourceRoot":"","sources":["../../../../src/components/Sortable/Sortable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM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H,CAAC;AAkBD,+FAA+F;AAC/F,SAAS,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAuB;IAC/F,OAAO,KAAC,GAAG,OAAK,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,0BAAwB,KAAK,eAAa,IAAI,GAAI,CAAA;AAC9G,CAAC;AAED,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA;AAChC,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useRef, type ComponentProps, type DragEvent, type ElementType, type KeyboardEvent, type PointerEvent, type ReactNode } from \"react\"\nimport { flushSync } from \"react-dom\"\n\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { moveItem, sortableKeyDown, sortablePointerDown, type SortableLayout, type SortableMove } from \"../../lib/sortable\"\nimport { GripVertical, Hamburger } from \"../Icon\"\n\nimport s from \"@plexui/styles/components/Sortable/Sortable.module.css\"\n\nexport type SortableProps<T> = {\n /**\n * The list, in the order of the children\n */\n value: readonly T[]\n /**\n * Called with the new order after a drop\n */\n onChange?: (value: T[]) => void\n /**\n * `list` for rows one under another, `grid` for items that stand side by side\n * @default list\n */\n layout?: SortableLayout\n /**\n * Element to render, such as `TableBody` for table rows\n * @default div\n */\n as?: ElementType\n /**\n * Turns dragging off\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the grips of `Sortable.Handle`. A hidden grip still takes the keyboard, and the item drags from anywhere but a control.\n * @default true in a table, otherwise false\n */\n handles?: boolean\n /**\n * Lists of one group trade items, and a `Sortable.Target` of that group takes them. Give each list a `name`.\n */\n group?: string\n /**\n * Names the list in `onMove`\n */\n name?: string\n /**\n * An item moved, inside this list or out of it. Out of it the app updates both lists: `onChange` is for a move inside one.\n */\n onMove?: (move: SortableMove<T>) => void\n /**\n * A drag rests on a `Sortable.Target` of the group: open what it stands for or go there\n */\n onHold?: (name: string) => void\n /**\n * The items, one direct child per entry of `value`, keyed by the entry and not by its index\n */\n children?: ReactNode\n} & Omit<ComponentProps<\"div\">, \"children\" | \"onChange\">\n\nconst preventNativeDrag = (event: DragEvent) => event.preventDefault()\n\n/** Reorders its direct children by dragging, from anywhere but a control, or by a `Sortable.Handle` where grips are shown. */\nexport function Sortable<T>({\n value,\n onChange,\n layout = \"list\",\n as: Tag = \"div\",\n disabled = false,\n handles,\n group,\n name,\n onMove,\n onHold,\n className,\n children,\n onPointerDown,\n onKeyDown,\n ...rest\n}: SortableProps<T>) {\n const latest = useLatestValue({ value, onChange, onMove, onHold, name })\n const cancelDrag = useRef<ReturnType<typeof sortablePointerDown>>(undefined)\n useEffect(() => () => cancelDrag.current?.(), [])\n useEffect(() => {\n if (disabled) {\n cancelDrag.current?.()\n cancelDrag.current = undefined\n }\n }, [disabled])\n\n const commit = (from: number, to: number) => {\n const { value: items, onChange: change, onMove: move, name: list } = latest.current\n flushSync(() => {\n change?.(moveItem(items, from, to))\n move?.({ item: items[from], from: list as string, fromIndex: from, to: list as string, toIndex: to })\n })\n }\n\n const link = {\n move: (fromIndex: number, to: string, toIndex?: number) => {\n const { value: items, onMove: move, name: from } = latest.current\n flushSync(() => move?.({ item: items[fromIndex], from: from as string, fromIndex, to, toIndex }))\n },\n hold: (target: string) => latest.current.onHold?.(target),\n }\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n onPointerDown?.(event)\n if (!disabled && !event.defaultPrevented) {\n cancelDrag.current = sortablePointerDown(event.nativeEvent, event.currentTarget, layout, commit, link) ?? cancelDrag.current\n }\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event)\n if (!disabled && !event.defaultPrevented) void sortableKeyDown(event.nativeEvent, event.currentTarget, commit, link)\n }\n\n return (\n <Tag\n {...rest}\n className={clsx(s.Sortable, className)}\n data-sortable=\"\"\n data-layout={layout}\n data-disabled={disabled ? \"\" : undefined}\n data-handles={handles?.toString()}\n data-group={group}\n data-name={name}\n onPointerDown={handlePointerDown}\n onKeyDown={handleKeyDown}\n onDragStart={preventNativeDrag}\n >\n {children}\n </Tag>\n )\n}\n\nexport type SortableHandleProps = {\n /**\n * Name of the handle for assistive technology\n * @default Reorder\n */\n \"aria-label\"?: string\n} & ComponentProps<\"button\">\n\n/** The grip of an item. Arrow keys move the item while the handle has focus. */\nfunction SortableHandle({ \"aria-label\": ariaLabel = \"Reorder\", className, children, ...rest }: SortableHandleProps) {\n return (\n <button {...rest} type=\"button\" className={clsx(s.Handle, className)} data-sortable-handle=\"\" aria-label={ariaLabel}>\n {children ?? <><GripVertical className={s.DesktopGrip} aria-hidden /><Hamburger className={s.PhoneGrip} aria-hidden /></>}\n </button>\n )\n}\n\nexport type SortableTargetProps = {\n /**\n * The `group` of the lists whose items it takes\n */\n group: string\n /**\n * Names the target in `onMove` and `onHold` on the list\n */\n name: string\n /**\n * Element to render\n * @default div\n */\n as?: ElementType\n} & ComponentProps<\"div\">\n\n/** A place outside the lists that takes an item whole: a folder, a category in a side list. */\nfunction SortableTarget({ group, name, as: Tag = \"div\", className, ...rest }: SortableTargetProps) {\n return <Tag {...rest} className={clsx(s.Target, className)} data-sortable-target={group} data-name={name} />\n}\n\nSortable.Handle = SortableHandle\nSortable.Target = SortableTarget\n"]}
1
+ {"version":3,"file":"Sortable.js","sourceRoot":"","sources":["../../../../src/components/Sortable/Sortable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAgH,MAAM,OAAO,CAAA;AACvJ,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAA0C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,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,0BAAwB,KAAK,eAAa,IAAI,GAAI,CAAA;AAC9G,CAAC;AAED,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA;AAChC,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useRef, type ComponentProps, type DragEvent, type ElementType, type KeyboardEvent, type PointerEvent, type ReactNode } from \"react\"\nimport { flushSync } from \"react-dom\"\n\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { moveItem, sortableKeyDown, sortablePointerDown, type SortableLayout, type SortableMove } from \"../../lib/sortable\"\nimport { GripVertical, Hamburger } from \"../Icon\"\n\nimport s from \"@plexui/styles/components/Sortable/Sortable.module.css\"\n\nexport type SortableProps<T> = {\n /**\n * The list, in the order of the children\n */\n value: readonly T[]\n /**\n * Called with the new order after a drop\n */\n onChange?: (value: T[]) => void\n /**\n * `list` for rows one under another, `grid` for items that stand side by side\n * @default list\n */\n layout?: SortableLayout\n /**\n * Element to render, such as `TableBody` for table rows\n * @default div\n */\n as?: ElementType\n /**\n * Turns dragging off\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the grips of `Sortable.Handle`. A hidden grip still takes the keyboard, and the item drags from anywhere but a control.\n * @default true in a table, otherwise false\n */\n handles?: boolean\n /**\n * Lists of one group trade items, and a `Sortable.Target` of that group takes them. Give each list a `name`.\n */\n group?: string\n /**\n * Names the list in `onMove`\n */\n name?: string\n /**\n * An item moved, inside this list or out of it. Out of it the app updates both lists: `onChange` is for a move inside one.\n */\n onMove?: (move: SortableMove<T>) => void\n /**\n * A drag rests on a `Sortable.Target` of the group: open what it stands for or go there\n */\n onHold?: (name: string) => void\n /**\n * The items, one direct child per entry of `value`, keyed by the entry and not by its index\n */\n children?: ReactNode\n} & Omit<ComponentProps<\"div\">, \"children\" | \"onChange\">\n\nconst preventNativeDrag = (event: DragEvent) => event.preventDefault()\n\n/** Reorders its direct children by dragging, from anywhere but a control, or by a `Sortable.Handle` where grips are shown. */\nexport function Sortable<T>({\n value,\n onChange,\n layout = \"list\",\n as: Tag = \"div\",\n disabled = false,\n handles,\n group,\n name,\n onMove,\n onHold,\n className,\n children,\n onPointerDown,\n onKeyDown,\n ...rest\n}: SortableProps<T>) {\n const latest = useLatestValue({ value, onChange, onMove, onHold, name })\n const cancelDrag = useRef<ReturnType<typeof sortablePointerDown>>(undefined)\n useEffect(() => () => cancelDrag.current?.(), [])\n useEffect(() => {\n if (disabled) {\n cancelDrag.current?.()\n cancelDrag.current = undefined\n }\n }, [disabled])\n\n const commit = (from: number, to: number) => {\n const { value: items, onChange: change, onMove: move, name: list } = latest.current\n flushSync(() => {\n change?.(moveItem(items, from, to))\n move?.({ item: items[from], from: list as string, fromIndex: from, to: list as string, toIndex: to })\n })\n }\n\n const link = {\n move: (fromIndex: number, to: string, toIndex?: number) => {\n const { value: items, onMove: move, name: from } = latest.current\n flushSync(() => move?.({ item: items[fromIndex], from: from as string, fromIndex, to, toIndex }))\n },\n hold: (target: string) => latest.current.onHold?.(target),\n }\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n onPointerDown?.(event)\n if (!disabled && !event.defaultPrevented) {\n cancelDrag.current = sortablePointerDown(event.nativeEvent, event.currentTarget, layout, commit, link) ?? cancelDrag.current\n }\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event)\n if (!disabled && !event.defaultPrevented) void sortableKeyDown(event.nativeEvent, event.currentTarget, commit, link)\n }\n\n return (\n <Tag\n {...rest}\n className={clsx(s.Sortable, className)}\n data-sortable=\"\"\n data-layout={layout}\n data-disabled={disabled ? \"\" : undefined}\n data-handles={handles?.toString()}\n data-group={group}\n data-name={name}\n onPointerDown={handlePointerDown}\n onKeyDown={handleKeyDown}\n onDragStart={preventNativeDrag}\n >\n {children}\n </Tag>\n )\n}\n\nexport type SortableHandleProps = {\n /**\n * Name of the handle for assistive technology\n * @default Reorder\n */\n \"aria-label\"?: string\n} & ComponentProps<\"button\">\n\n/** The grip of an item. Arrow keys move the item while the handle has focus. */\nfunction SortableHandle({ \"aria-label\": ariaLabel = \"Reorder\", className, children, ...rest }: SortableHandleProps) {\n return (\n <button {...rest} type=\"button\" className={clsx(s.Handle, className)} data-sortable-handle=\"\" aria-label={ariaLabel}>\n {children ?? <><GripVertical className={s.DesktopGrip} aria-hidden /><Hamburger className={s.PhoneGrip} aria-hidden preserveAspectRatio=\"none\" /></>}\n </button>\n )\n}\n\nexport type SortableTargetProps = {\n /**\n * The `group` of the lists whose items it takes\n */\n group: string\n /**\n * Names the target in `onMove` and `onHold` on the list\n */\n name: string\n /**\n * Element to render\n * @default div\n */\n as?: ElementType\n} & ComponentProps<\"div\">\n\n/** A place outside the lists that takes an item whole: a folder, a category in a side list. */\nfunction SortableTarget({ group, name, as: Tag = \"div\", className, ...rest }: SortableTargetProps) {\n return <Tag {...rest} className={clsx(s.Target, className)} data-sortable-target={group} data-name={name} />\n}\n\nSortable.Handle = SortableHandle\nSortable.Target = SortableTarget\n"]}
@@ -1,2 +1,6 @@
1
- export { StatCard } from "./StatCard.js";
1
+ // Backward-compatible alias: StatCard is now StatsCard (packages/ui/src/components/StatsCard), the name of the
2
+ // metric cards it follows. The old import keeps working.
3
+ import { StatsCard } from "../StatsCard/index.js";
4
+ /** @deprecated Renamed to `StatsCard`: `import { StatsCard } from "@plexui/ui/components/StatsCard"`. */
5
+ export const StatCard = StatsCard;
2
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/StatCard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAA","sourcesContent":["export { StatCard, type StatCardProps } from \"./StatCard\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/StatCard/index.tsx"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,yDAAyD;AACzD,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAA;AAE7D,yGAAyG;AACzG,MAAM,CAAC,MAAM,QAAQ,GAAqB,SAAS,CAAA","sourcesContent":["// Backward-compatible alias: StatCard is now StatsCard (packages/ui/src/components/StatsCard), the name of the\n// metric cards it follows. The old import keeps working.\nimport { StatsCard, type StatsCardProps } from \"../StatsCard\"\n\n/** @deprecated Renamed to `StatsCard`: `import { StatsCard } from \"@plexui/ui/components/StatsCard\"`. */\nexport const StatCard: typeof StatsCard = StatsCard\n/** @deprecated Renamed to `StatsCardProps`. */\nexport type StatCardProps = StatsCardProps\n"]}
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import {} from "react";
5
+ import { Badge } from "../Badge/index.js";
6
+ import { InfoCircle, Trending } from "../Icon/index.js";
7
+ import { Tooltip } from "../Tooltip/index.js";
8
+ import s from "@plexui/styles/components/StatsCard/StatsCard.module.css";
9
+ export const StatsCard = ({ label, value, description, trend, invertTrend, icon, sparkline, progress, progressLabel, tooltip, trendPosition = "value", trendVariant = "text", size = "default", variant = "default", accentColor = "primary", className, ref, ...restProps }) => {
10
+ const trendValue = trend?.value ?? 0;
11
+ const trendClassName = trendValue === 0
12
+ ? s.TrendNeutral
13
+ : trendValue > 0
14
+ ? invertTrend
15
+ ? s.TrendNegative
16
+ : s.TrendPositive
17
+ : invertTrend
18
+ ? s.TrendPositive
19
+ : s.TrendNegative;
20
+ const trendText = `${trendValue > 0 ? "+" : ""}${trendValue}%`;
21
+ const progressValue = progress === undefined ? undefined : Math.min(100, Math.max(0, progress));
22
+ const trendBadgeColor = trendValue === 0
23
+ ? "secondary"
24
+ : trendValue > 0
25
+ ? invertTrend
26
+ ? "danger"
27
+ : "success"
28
+ : invertTrend
29
+ ? "success"
30
+ : "danger";
31
+ // A trend line points the way the value moved, whichever colour that is (shadcn's metric cards draw lucide's
32
+ // trending-up and trending-down); a fall is the rise mirrored
33
+ const trendContent = (_jsxs(_Fragment, { children: [trendValue !== 0 && _jsx(Trending, { className: trendValue < 0 ? s.TrendDown : undefined }), trendText] }));
34
+ const trendEl = trend != null && (trendVariant === "badge" ? (_jsx(Badge, { size: "sm", color: trendBadgeColor, children: trendContent })) : (_jsx("div", { className: clsx(s.Trend, trendClassName), children: trendContent })));
35
+ // The icon's tile stands at the end of the header, as the trend may (shadcn's metric card with an icon)
36
+ const iconEl = icon ? _jsx("div", { className: s.IconWrapper, children: icon }) : null;
37
+ const headerTrendEl = trendPosition === "header" ? trendEl : null;
38
+ const headerEl = (_jsxs("div", { className: s.Header, children: [_jsxs("div", { className: s.LabelRow, children: [_jsx("div", { className: s.Label, children: label }), tooltip && (_jsx(Tooltip, { content: tooltip, children: _jsx("span", { className: s.InfoIcon, tabIndex: 0, role: "img", "aria-label": "More information", children: _jsx(InfoCircle, {}) }) }))] }), (headerTrendEl || iconEl) && (_jsxs("div", { className: s.HeaderEnd, children: [headerTrendEl, iconEl] }))] }));
39
+ const valueRowEl = (_jsx("div", { className: s.ValueRow, children: _jsx("div", { className: s.Value, children: value }) }));
40
+ // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend in
41
+ // the header leaves its label there
42
+ const trendRowEl = trend != null && (trendPosition === "value" || trend.label) ? (_jsxs("div", { className: s.TrendRow, children: [trendPosition === "value" && trendEl, trend.label && _jsx("span", { className: s.TrendLabel, children: trend.label })] })) : null;
43
+ const descriptionEl = description ? _jsx("div", { className: s.Description, children: description }) : null;
44
+ const progressEl = (progressValue !== undefined || progressLabel) ? (_jsxs("div", { className: s.Progress, children: [_jsx("div", { className: s.ProgressTrack, children: _jsx("div", { className: s.ProgressBar, style: { width: `${progressValue ?? 0}%` }, "aria-hidden": true }) }), progressLabel && _jsx("div", { className: s.ProgressLabel, children: progressLabel })] })) : null;
45
+ const sparklineEl = sparkline ? _jsx("div", { className: s.Sparkline, children: sparkline }) : null;
46
+ return (_jsxs("div", { ref: ref, className: clsx(s.StatsCard, className), "data-variant": variant, "data-size": size, "data-accent-color": accentColor, ...restProps, children: [headerEl, valueRowEl, trendRowEl, descriptionEl, progressEl, sparklineEl] }));
47
+ };
48
+ //# sourceMappingURL=StatsCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatsCard.js","sourceRoot":"","sources":["../../../../src/components/StatsCard/StatsCard.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,CAAC,MAAM,0DAA0D,CAAA;AAiExE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,EACL,WAAW,EACX,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,aAAa,EACb,OAAO,EACP,aAAa,GAAG,OAAO,EACvB,YAAY,GAAG,MAAM,EACrB,IAAI,GAAG,SAAS,EAChB,OAAO,GAAG,SAAS,EACnB,WAAW,GAAG,SAAS,EACvB,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACG,EAAE,EAAE;IACnB,MAAM,UAAU,GAAG,KAAK,EAAE,KAAK,IAAI,CAAC,CAAA;IACpC,MAAM,cAAc,GAClB,UAAU,KAAK,CAAC;QACd,CAAC,CAAC,CAAC,CAAC,YAAY;QAChB,CAAC,CAAC,UAAU,GAAG,CAAC;YACd,CAAC,CAAC,WAAW;gBACX,CAAC,CAAC,CAAC,CAAC,aAAa;gBACjB,CAAC,CAAC,CAAC,CAAC,aAAa;YACnB,CAAC,CAAC,WAAW;gBACX,CAAC,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AC,CAAC,CAAC,cAAK,SAAS,EAAE,CAAC,CAAC,WAAW,YAAG,WAAW,GAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IAE7F,MAAM,UAAU,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAClE,eAAK,SAAS,EAAE,CAAC,CAAC,QAAQ,aACxB,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,YAC7B,cACE,SAAS,EAAE,CAAC,CAAC,WAAW,EACxB,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,aAAa,IAAI,CAAC,GAAG,EAAE,wBAE1C,GACE,EACL,aAAa,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,YAAG,aAAa,GAAO,IACpE,CACP,CAAC,CAAC,CAAC,IAAI,CAAA;IAER,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,cAAK,SAAS,EAAE,CAAC,CAAC,SAAS,YAAG,SAAS,GAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IAErF,OAAO,CACL,eACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,kBACzB,OAAO,eACV,IAAI,uBACI,WAAW,KAC1B,SAAS,aAEZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,IACR,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref } from \"react\"\nimport { Badge } from \"../Badge\"\nimport { InfoCircle, Trending } from \"../Icon\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/StatsCard/StatsCard.module.css\"\n\nexport type StatsCardProps = {\n /** Label describing the metric */\n label: string\n /** The primary metric value (e.g. \"1,234\" or \"$50K\") */\n value: ReactNode\n /** Optional description or subtitle below the value */\n description?: string\n /** Trend indicator with percentage change */\n trend?: {\n /** The percentage change value (e.g. 12.5 for +12.5%) */\n value: number\n /** Optional label for the trend (e.g. \"vs last month\") */\n label?: string\n }\n /** When true, a positive trend is bad (red) and negative is good (green). Use for metrics like \"Error Rate\" or \"Avg Completion Time\". */\n invertTrend?: boolean\n /** Icon in a small tile with a soft background, at the end of the header */\n icon?: ReactNode\n /** Optional ReactNode for a sparkline/chart rendered at the bottom */\n sparkline?: ReactNode\n /** Progress value from 0 to 100. Shows a progress bar at the bottom. */\n progress?: number\n /** Label displayed after the progress bar */\n progressLabel?: string\n /** Tooltip text — renders an (i) icon next to the label with a tooltip on hover */\n tooltip?: string\n /**\n * Where the trend indicator is positioned\n * - `\"value\"` — under the value, with its label (default)\n * - `\"header\"` — right-aligned in the header row, its label under the value\n * @default \"value\"\n */\n trendPosition?: \"value\" | \"header\"\n /**\n * Visual style of the trend indicator\n * - `\"text\"` — plain colored text (default)\n * - `\"badge\"` — wrapped in a Badge component\n * @default \"text\"\n */\n trendVariant?: \"text\" | \"badge\"\n /**\n * Size of the card\n * - `\"default\"` — standard dashboard card\n * - `\"sm\"` — compact card for dense layouts\n * @default \"default\"\n */\n size?: \"default\" | \"sm\"\n /**\n * Visual variant of the card\n * @default \"default\"\n */\n variant?: \"default\" | \"accent\"\n /**\n * Color of the accent variant's bar\n * @default \"primary\"\n */\n accentColor?: \"primary\" | \"secondary\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"discovery\" | \"caution\"\n /** Class applied to the card container */\n className?: string\n /** Ref applied to the card container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const StatsCard = ({\n label,\n value,\n description,\n trend,\n invertTrend,\n icon,\n sparkline,\n progress,\n progressLabel,\n tooltip,\n trendPosition = \"value\",\n trendVariant = \"text\",\n size = \"default\",\n variant = \"default\",\n accentColor = \"primary\",\n className,\n ref,\n ...restProps\n}: StatsCardProps) => {\n const trendValue = trend?.value ?? 0\n const trendClassName =\n trendValue === 0\n ? s.TrendNeutral\n : trendValue > 0\n ? invertTrend\n ? s.TrendNegative\n : s.TrendPositive\n : invertTrend\n ? s.TrendPositive\n : s.TrendNegative\n\n const trendText = `${trendValue > 0 ? \"+\" : \"\"}${trendValue}%`\n const progressValue =\n progress === undefined ? undefined : Math.min(100, Math.max(0, progress))\n\n const trendBadgeColor =\n trendValue === 0\n ? \"secondary\"\n : trendValue > 0\n ? invertTrend\n ? \"danger\"\n : \"success\"\n : invertTrend\n ? \"success\"\n : \"danger\"\n\n // A trend line points the way the value moved, whichever colour that is (shadcn's metric cards draw lucide's\n // trending-up and trending-down); a fall is the rise mirrored\n const trendContent = (\n <>\n {trendValue !== 0 && <Trending className={trendValue < 0 ? s.TrendDown : undefined} />}\n {trendText}\n </>\n )\n\n const trendEl = trend != null && (\n trendVariant === \"badge\" ? (\n <Badge size=\"sm\" color={trendBadgeColor as \"secondary\" | \"success\" | \"danger\"}>\n {trendContent}\n </Badge>\n ) : (\n <div className={clsx(s.Trend, trendClassName)}>\n {trendContent}\n </div>\n )\n )\n\n // The icon's tile stands at the end of the header, as the trend may (shadcn's metric card with an icon)\n const iconEl = icon ? <div className={s.IconWrapper}>{icon}</div> : null\n const headerTrendEl = trendPosition === \"header\" ? trendEl : null\n\n const headerEl = (\n <div className={s.Header}>\n <div className={s.LabelRow}>\n <div className={s.Label}>{label}</div>\n {tooltip && (\n <Tooltip content={tooltip}>\n {/* Focusable and named so keyboard and screen-reader users reach the tooltip */}\n <span className={s.InfoIcon} tabIndex={0} role=\"img\" aria-label=\"More information\">\n <InfoCircle />\n </span>\n </Tooltip>\n )}\n </div>\n {(headerTrendEl || iconEl) && (\n <div className={s.HeaderEnd}>\n {headerTrendEl}\n {iconEl}\n </div>\n )}\n </div>\n )\n\n const valueRowEl = (\n <div className={s.ValueRow}>\n <div className={s.Value}>{value}</div>\n </div>\n )\n\n // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend in\n // the header leaves its label there\n const trendRowEl = trend != null && (trendPosition === \"value\" || trend.label) ? (\n <div className={s.TrendRow}>\n {trendPosition === \"value\" && trendEl}\n {trend.label && <span className={s.TrendLabel}>{trend.label}</span>}\n </div>\n ) : null\n\n const descriptionEl = description ? <div className={s.Description}>{description}</div> : null\n\n const progressEl = (progressValue !== undefined || progressLabel) ? (\n <div className={s.Progress}>\n <div className={s.ProgressTrack}>\n <div\n className={s.ProgressBar}\n style={{ width: `${progressValue ?? 0}%` }}\n aria-hidden\n />\n </div>\n {progressLabel && <div className={s.ProgressLabel}>{progressLabel}</div>}\n </div>\n ) : null\n\n const sparklineEl = sparkline ? <div className={s.Sparkline}>{sparkline}</div> : null\n\n return (\n <div\n ref={ref}\n className={clsx(s.StatsCard, className)}\n data-variant={variant}\n data-size={size}\n data-accent-color={accentColor}\n {...restProps}\n >\n {headerEl}\n {valueRowEl}\n {trendRowEl}\n {descriptionEl}\n {progressEl}\n {sparklineEl}\n </div>\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { StatsCard } from "./StatsCard.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/StatsCard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAA","sourcesContent":["export { StatsCard, type StatsCardProps } from \"./StatsCard\"\n"]}