@plexui/ui 0.30.0 → 0.32.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 (102) hide show
  1. package/dist/es/components/ButtonGroup/ButtonGroup.js +1 -1
  2. package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
  3. package/dist/es/components/ButtonGroup/index.js.map +1 -1
  4. package/dist/es/components/ContextMenu/shared.js +3 -2
  5. package/dist/es/components/ContextMenu/shared.js.map +1 -1
  6. package/dist/es/components/Dialog/Dialog.js +42 -29
  7. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  8. package/dist/es/components/Dialog/dialogSteps.js +85 -0
  9. package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
  10. package/dist/es/components/Dialog/dialogViewport.js +74 -0
  11. package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
  12. package/dist/es/components/Dialog/index.js +1 -1
  13. package/dist/es/components/Dialog/index.js.map +1 -1
  14. package/dist/es/components/Dialog/sheetDrag.js +2 -1
  15. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  16. package/dist/es/components/IndexBar/IndexBar.js +164 -0
  17. package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
  18. package/dist/es/components/IndexBar/index.js +2 -0
  19. package/dist/es/components/IndexBar/index.js.map +1 -0
  20. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +142 -1
  21. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  22. package/dist/es/components/Menu/Menu.js +57 -35
  23. package/dist/es/components/Menu/Menu.js.map +1 -1
  24. package/dist/es/components/Page/Page.js +1 -1
  25. package/dist/es/components/Page/Page.js.map +1 -1
  26. package/dist/es/components/PhoneLayout/PhoneLayout.js +41 -0
  27. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
  28. package/dist/es/components/PhoneLayout/index.js +2 -0
  29. package/dist/es/components/PhoneLayout/index.js.map +1 -0
  30. package/dist/es/components/Slider/Slider.js +33 -3
  31. package/dist/es/components/Slider/Slider.js.map +1 -1
  32. package/dist/es/components/SwipeActions/SwipeActions.js +321 -0
  33. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
  34. package/dist/es/components/SwipeActions/index.js +2 -0
  35. package/dist/es/components/SwipeActions/index.js.map +1 -0
  36. package/dist/es/components/TabBar/TabBar.js +4 -4
  37. package/dist/es/components/TabBar/TabBar.js.map +1 -1
  38. package/dist/es/components/TabBar/index.js.map +1 -1
  39. package/dist/es/components/Tabs/Tabs.js +1 -1
  40. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  41. package/dist/es/components/TagInput/TagInput.js +5 -65
  42. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  43. package/dist/es/components/Textarea/Textarea.js +1 -1
  44. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  45. package/dist/es/components/Tip/Tip.js +106 -0
  46. package/dist/es/components/Tip/Tip.js.map +1 -0
  47. package/dist/es/components/Tip/index.js +2 -0
  48. package/dist/es/components/Tip/index.js.map +1 -0
  49. package/dist/es/components/Toast/ToastRenderer.js +22 -9
  50. package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
  51. package/dist/es/components/Toast/Toaster.js +17 -6
  52. package/dist/es/components/Toast/Toaster.js.map +1 -1
  53. package/dist/es/components/Toast/toastLifecycle.js +113 -1
  54. package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
  55. package/dist/es/components/Toolbar/Toolbar.js +1 -1
  56. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  57. package/dist/es/hooks/useEscCloseStack.js +10 -3
  58. package/dist/es/hooks/useEscCloseStack.js.map +1 -1
  59. package/dist/es/hooks/usePhoneSubmenu.js +6 -3
  60. package/dist/es/hooks/usePhoneSubmenu.js.map +1 -1
  61. package/dist/es/lib/floatingBoundary.js +3 -1
  62. package/dist/es/lib/floatingBoundary.js.map +1 -1
  63. package/dist/es/lib/helpers.js +21 -0
  64. package/dist/es/lib/helpers.js.map +1 -1
  65. package/dist/es/lib/menuInitialFocus.js +5 -3
  66. package/dist/es/lib/menuInitialFocus.js.map +1 -1
  67. package/dist/es/lib/menuSubmenuPlacement.js +129 -5
  68. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
  69. package/dist/es/lib/menuTriggerCover.js +10 -4
  70. package/dist/es/lib/menuTriggerCover.js.map +1 -1
  71. package/dist/es/lib/phoneLayout.js +16 -0
  72. package/dist/es/lib/phoneLayout.js.map +1 -0
  73. package/dist/es/lib/toastRegion.js +6 -0
  74. package/dist/es/lib/toastRegion.js.map +1 -0
  75. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +8 -1
  76. package/dist/types/components/ButtonGroup/index.d.ts +1 -1
  77. package/dist/types/components/ContextMenu/shared.d.ts +3 -2
  78. package/dist/types/components/Dialog/Dialog.d.ts +48 -3
  79. package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
  80. package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
  81. package/dist/types/components/Dialog/index.d.ts +1 -1
  82. package/dist/types/components/IndexBar/IndexBar.d.ts +35 -0
  83. package/dist/types/components/IndexBar/index.d.ts +1 -0
  84. package/dist/types/components/Menu/Menu.d.ts +6 -2
  85. package/dist/types/components/Page/Page.d.ts +1 -1
  86. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +18 -0
  87. package/dist/types/components/PhoneLayout/index.d.ts +1 -0
  88. package/dist/types/components/SwipeActions/SwipeActions.d.ts +46 -0
  89. package/dist/types/components/SwipeActions/index.d.ts +1 -0
  90. package/dist/types/components/TabBar/TabBar.d.ts +18 -4
  91. package/dist/types/components/TabBar/index.d.ts +1 -1
  92. package/dist/types/components/Tip/Tip.d.ts +57 -0
  93. package/dist/types/components/Tip/index.d.ts +1 -0
  94. package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
  95. package/dist/types/components/Toolbar/Toolbar.d.ts +5 -3
  96. package/dist/types/hooks/useEscCloseStack.d.ts +5 -1
  97. package/dist/types/hooks/usePhoneSubmenu.d.ts +2 -1
  98. package/dist/types/lib/helpers.d.ts +6 -0
  99. package/dist/types/lib/menuSubmenuPlacement.d.ts +9 -2
  100. package/dist/types/lib/phoneLayout.d.ts +11 -0
  101. package/dist/types/lib/toastRegion.d.ts +5 -0
  102. package/package.json +2 -2
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import clamp from "lodash/clamp.js";
5
5
  import round from "lodash/round.js";
6
- import { Slider as RadixSlider } from "radix-ui";
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
9
  import { useIsMounted } from "../../hooks/useIsMounted.js";
@@ -15,10 +15,32 @@ import { Button } from "../Button/index.js";
15
15
  import { Reload } from "../Icon/index.js";
16
16
  import { Tooltip } from "../Tooltip/index.js";
17
17
  import s from "@plexui/styles/components/Slider/Slider.module.css";
18
+ /**
19
+ * A press on the track of a range moves the thumb whose value lies nearest the press, which Radix focuses only
20
+ * once that value changes. Focusing it at once lets a phone draw the knob being pressed as the lens of glass
21
+ * (Slider.module.css), even when the press leaves the value as it is. The thumb is the one Radix moves: the
22
+ * pointer mapped onto min to max across the root (from the right in a right-to-left direction, which Radix
23
+ * takes from a DirectionProvider), the nearest value, the first on a tie. A press on a thumb itself is left
24
+ * to Radix, which focuses that thumb.
25
+ */
26
+ const focusThumbToMove = (event, root, values, min, max, vertical, rtl) => {
27
+ const thumbs = Array.from(root.querySelectorAll('[role="slider"]'));
28
+ if (thumbs.includes(event.target))
29
+ return;
30
+ const rect = root.getBoundingClientRect();
31
+ const ratio = vertical ? (rect.bottom - event.clientY) / rect.height : (rtl ? rect.right - event.clientX : event.clientX - rect.left) / rect.width;
32
+ const pointerValue = min + ratio * (max - min);
33
+ const distances = values.map((value) => Math.abs(value - pointerValue));
34
+ const thumb = thumbs[distances.indexOf(Math.min(...distances))];
35
+ if (thumb && thumb !== document.activeElement)
36
+ thumb.focus({ preventScroll: true, focusVisible: false });
37
+ };
18
38
  export const Slider = memo((props) => {
19
39
  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;
20
40
  const isRange = props.range === true;
21
41
  const isVertical = orientation === "vertical";
42
+ // The direction Radix slides in: no `dir` is passed, so it is the one of a DirectionProvider, else left to right.
43
+ const direction = Direction.useDirection();
22
44
  const id = useId();
23
45
  const labelId = `${id}-label`;
24
46
  // What names the thumbs: an explicit labelledby, else the visible label
@@ -229,8 +251,13 @@ export const Slider = memo((props) => {
229
251
  inputRef.current?.focus(); }, children: [prefixUnit && _jsx("span", { className: s.ValueUnit, children: prefixUnit }), _jsx("input", { id: id, className: s.ValueInput, ref: inputRef, style: { width: inputWidth }, onKeyDown: handleKeyDown, value: inputValue, type: "text", inputMode: min < 0 ? "text" : Number.isInteger(min) && Number.isInteger(max) && Number.isInteger(step) ? "numeric" : "decimal", onClick: (e) => e.stopPropagation(), onBlur: handleInputBlur, onFocus: (e) => {
230
252
  e.currentTarget.setSelectionRange(0, e.currentTarget.value.length);
231
253
  onFocus?.(e);
232
- }, onChange: handleInputChange, disabled: disabled }), unit && _jsx("span", { className: s.ValueUnit, children: unit })] }))] })), _jsxs("div", { className: s.SliderContainer, children: [_jsxs(RadixSlider.Root, { ref: forwardedRef, className: s.Slider, onValueChange: handleValueChange, min: min, max: max, step: step, disabled: disabled, value: radixValue, orientation: orientation, minStepsBetweenThumbs: minStepsBetweenThumbs, onBlur: onBlur, onFocus: onFocus, onPointerDown: () => { if (!disabled)
233
- setPointerDown(true); }, onPointerUp: () => setPointerDown(false), style: toCssVariables({
254
+ }, onChange: handleInputChange, disabled: disabled }), unit && _jsx("span", { className: s.ValueUnit, children: unit })] }))] })), _jsxs("div", { className: s.SliderContainer, children: [_jsxs(RadixSlider.Root, { ref: forwardedRef, className: s.Slider, onValueChange: handleValueChange, min: min, max: max, step: step, disabled: disabled, value: radixValue, orientation: orientation, minStepsBetweenThumbs: minStepsBetweenThumbs, onBlur: onBlur, onFocus: onFocus, onPointerDown: (event) => {
255
+ if (disabled)
256
+ return;
257
+ setPointerDown(true);
258
+ if (isRange)
259
+ focusThumbToMove(event.nativeEvent, event.currentTarget, radixValue, min, max, isVertical, direction === "rtl");
260
+ }, onPointerUp: () => setPointerDown(false), onPointerCancel: () => setPointerDown(false), "data-pressed": pointerDown ? "" : undefined, "data-range": isRange ? "" : undefined, style: toCssVariables({
234
261
  "slider-duration": `${animationDurationMS}ms`,
235
262
  "slider-track-color": trackColor,
236
263
  "slider-range-color": rangeColor,
@@ -318,6 +345,9 @@ const SliderMarks = memo(({ marks, thumbRef, min, max }) => {
318
345
  // Give our container a height so that we allocate space on the page
319
346
  // for the marks and push down other content when we have to wrap
320
347
  marksContainerRef.current.style.height = tallestHeight > 0 ? `${tallestHeight}px` : "";
348
+ // Placed against the slider's width: the marks show, at their own height (Slider.module.css)
349
+ if (sliderWidth)
350
+ marksContainerRef.current.dataset.measured = "";
321
351
  }, [marks, thumbRef, marksContainerRef, min, max, sliderWidth]);
322
352
  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))) }) }));
323
353
  });
@@ -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,MAAM,IAAI,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;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 { 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\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\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={() => { if (!disabled) setPointerDown(true) }}\n onPointerUp={() => setPointerDown(false)}\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 }, [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,YAAY,EAAE,MAA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AAC,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 { 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"]}
@@ -0,0 +1,321 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { useEffect, useRef, useState, } from "react";
5
+ import s from "@plexui/styles/components/SwipeActions/SwipeActions.module.css";
6
+ import { useLatestValue } from "../../hooks/useLatestValue.js";
7
+ /** A finger has to travel this far, and farther across than down, before the row follows it. */
8
+ const SLOP = 10;
9
+ /** The width an open row moves by is the border box of its actions, edge and content gaps included. */
10
+ const BORDER_BOX = { box: "border-box" };
11
+ /** Controls that take a horizontal drag themselves. */
12
+ const OWN_DRAG = 'input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="slider"]';
13
+ /** The open row: opening another one closes it, as a list keeps one row open. */
14
+ let closeOpenRow = null;
15
+ /** The row keeps the finger past its edges; a pointer that is no longer active (it lifted between events) cannot be held. */
16
+ const capture = (element, pointerId) => {
17
+ try {
18
+ element.setPointerCapture?.(pointerId);
19
+ }
20
+ catch {
21
+ // The swipe goes on with the events the row still gets.
22
+ }
23
+ };
24
+ const sideOf = (offset) => offset > 0 ? "leading" : offset < 0 ? "trailing" : undefined;
25
+ /**
26
+ * Where the content goes for a swipe of `raw` px toward the trailing edge (negative: toward the leading edge), and
27
+ * whether that is a full swipe. A side without actions stays shut. Past its actions the content follows the finger
28
+ * where a full swipe is allowed, and a third as fast where it is not; past the middle between the open actions and
29
+ * the far edge of the row the swipe is full.
30
+ */
31
+ export const swipeActionsOffset = (raw, widths, rowWidth, fullSwipe) => {
32
+ const side = sideOf(raw);
33
+ const width = side ? widths[side] : 0;
34
+ if (!side || !(width > 0))
35
+ return { offset: 0, full: false };
36
+ const sign = Math.sign(raw);
37
+ const distance = Math.abs(raw);
38
+ if (distance <= width)
39
+ return { offset: raw, full: false };
40
+ if (!fullSwipe)
41
+ return { offset: sign * (width + (distance - width) / 3), full: false };
42
+ const travel = Math.min(distance, Math.max(width, rowWidth));
43
+ return { offset: sign * travel, full: travel >= (width + rowWidth) / 2 };
44
+ };
45
+ /**
46
+ * Actions behind a row of a list, as the swipe actions of an iOS list: a swipe toward the leading edge reveals the
47
+ * trailing actions, a swipe toward the trailing edge the leading ones, and a full swipe runs the first action of
48
+ * that side. The row is a `data-row` of a FieldGroup. Each action is also a button in the order of the screen, and
49
+ * the focus on one shows its side.
50
+ */
51
+ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hidden", fullSwipe = true, className, children, }) {
52
+ const [offset, setOffset] = useState(0);
53
+ const [full, setFull] = useState(false);
54
+ const [swiping, setSwiping] = useState(false);
55
+ const [rtl, setRtl] = useState(false);
56
+ const root = useRef(null);
57
+ const sides = useRef({ leading: null, trailing: null });
58
+ const gesture = useRef(null);
59
+ const current = useRef({ offset: 0, full: false });
60
+ const suppressClick = useRef(false);
61
+ const observer = useRef(null);
62
+ const actionsRef = useLatestValue({ leading, trailing });
63
+ const revealed = sideOf(offset);
64
+ const widthOf = (side) => sides.current[side]?.getBoundingClientRect().width ?? 0;
65
+ const isRtl = () => !!root.current && getComputedStyle(root.current).direction === "rtl";
66
+ const move = (next, nextFull = false) => {
67
+ current.current = { offset: next, full: nextFull };
68
+ setOffset(next);
69
+ setFull(nextFull);
70
+ };
71
+ /** Lets go of the gesture: the listeners for its end go, and the row no longer follows the finger. */
72
+ const release = () => {
73
+ const state = gesture.current;
74
+ gesture.current = null;
75
+ state?.detach();
76
+ return state;
77
+ };
78
+ /** The handlers of the latest render, for listeners and observers set up once. */
79
+ const latest = useRef({ close: () => { }, release, finish: () => { }, cancel: () => { }, sync: () => { } });
80
+ /** One function for the life of the row, so the list knows which row is open; another row that opens ends this one's gesture too. */
81
+ const closer = useRef(() => {
82
+ const state = latest.current.release();
83
+ if (state) {
84
+ setSwiping(false);
85
+ // The finger of the ended swipe still lifts over this row: its click is not a click on the content.
86
+ if (state.swiping)
87
+ suppressClick.current = true;
88
+ }
89
+ latest.current.close();
90
+ }).current;
91
+ const close = () => {
92
+ if (closeOpenRow === closer)
93
+ closeOpenRow = null;
94
+ move(0);
95
+ };
96
+ /** This row takes the place of the open one. */
97
+ const claim = () => {
98
+ if (closeOpenRow && closeOpenRow !== closer)
99
+ closeOpenRow();
100
+ closeOpenRow = closer;
101
+ };
102
+ /** Shows a side as wide as its actions (`width` when known), or closes the row when that side has none (any more). */
103
+ const open = (side, width = widthOf(side)) => {
104
+ if (!(width > 0))
105
+ return close();
106
+ claim();
107
+ setRtl(isRtl());
108
+ move(side === "leading" ? width : -width);
109
+ };
110
+ /** An open row follows its actions: more of them, other labels or another width move it to their new width. */
111
+ const sync = () => {
112
+ const side = sideOf(current.current.offset);
113
+ if (!side || gesture.current?.swiping || current.current.full)
114
+ return;
115
+ const width = widthOf(side);
116
+ if (!(width > 0))
117
+ return close();
118
+ const target = side === "leading" ? width : -width;
119
+ if (target !== current.current.offset)
120
+ move(target);
121
+ };
122
+ const settle = (state) => {
123
+ const { offset: last, full: wasFull } = current.current;
124
+ const side = sideOf(last);
125
+ if (!side)
126
+ return close();
127
+ if (wasFull) {
128
+ actionsRef.current[side][0]?.onSelect?.();
129
+ return close();
130
+ }
131
+ // The widths from the start of the swipe: a full swipe may have stretched the actions since.
132
+ if (Math.abs(last) >= state.widths[side] / 2)
133
+ open(side, state.widths[side]);
134
+ else
135
+ close();
136
+ };
137
+ /** The finger lifted (anywhere): a swipe settles, a press on an open row closes it. */
138
+ const finish = () => {
139
+ const state = release();
140
+ if (!state)
141
+ return;
142
+ if (state.swiping) {
143
+ suppressClick.current = true;
144
+ setSwiping(false);
145
+ settle(state);
146
+ }
147
+ else if (state.start !== 0) {
148
+ if (state.swiping === undefined)
149
+ suppressClick.current = true;
150
+ close();
151
+ }
152
+ };
153
+ /** The browser took the gesture (a scroll) or the row lost the finger: the row goes back to where it was. */
154
+ const cancel = () => {
155
+ const state = release();
156
+ if (!state)
157
+ return;
158
+ setSwiping(false);
159
+ const side = sideOf(state.start);
160
+ if (state.swiping && side)
161
+ open(side, state.widths[side]);
162
+ else
163
+ close();
164
+ };
165
+ latest.current = { close, release, finish, cancel, sync };
166
+ // After each render, and whenever the actions change size, an open row takes their width.
167
+ useEffect(() => {
168
+ latest.current.sync();
169
+ for (const element of [sides.current.leading, sides.current.trailing])
170
+ if (element)
171
+ observer.current?.observe(element, BORDER_BOX);
172
+ });
173
+ useEffect(() => {
174
+ if (typeof ResizeObserver !== "undefined")
175
+ observer.current = new ResizeObserver(() => latest.current.sync());
176
+ for (const element of [sides.current.leading, sides.current.trailing])
177
+ if (element)
178
+ observer.current?.observe(element, BORDER_BOX);
179
+ // The open row lets go of the list, and of the finger, when it goes away.
180
+ return () => {
181
+ observer.current?.disconnect();
182
+ observer.current = null;
183
+ latest.current.release();
184
+ if (closeOpenRow === closer)
185
+ closeOpenRow = null;
186
+ };
187
+ }, [closer, latest]);
188
+ // A press anywhere outside the open row closes it.
189
+ useEffect(() => {
190
+ if (!revealed || swiping)
191
+ return;
192
+ const handlePointerDown = (event) => {
193
+ if (event.target instanceof Node && root.current?.contains(event.target))
194
+ return;
195
+ latest.current.close();
196
+ };
197
+ document.addEventListener("pointerdown", handlePointerDown, true);
198
+ return () => document.removeEventListener("pointerdown", handlePointerDown, true);
199
+ }, [revealed, swiping, latest]);
200
+ const handlePointerDown = (event) => {
201
+ if (event.button !== 0 || gesture.current)
202
+ return;
203
+ // A new press of the primary pointer starts clean: a swipe that another row ended and that was then cancelled leaves
204
+ // no click to swallow. Another finger's press keeps it, as only the primary pointer clicks.
205
+ if (event.isPrimary)
206
+ suppressClick.current = false;
207
+ if (leading.length < 1 && trailing.length < 1)
208
+ return;
209
+ // A drag in a text field or along a slider belongs to that control.
210
+ if (event.target instanceof Element && event.target.closest(OWN_DRAG))
211
+ return;
212
+ const pointerId = event.pointerId;
213
+ // The end of the gesture is heard wherever the finger lifts, inside the row or not.
214
+ const handleUp = (end) => {
215
+ if (end.pointerId === pointerId)
216
+ latest.current.finish();
217
+ };
218
+ const handleCancel = (end) => {
219
+ if (end.pointerId === pointerId)
220
+ latest.current.cancel();
221
+ };
222
+ window.addEventListener("pointerup", handleUp, true);
223
+ window.addEventListener("pointercancel", handleCancel, true);
224
+ gesture.current = {
225
+ pointerId,
226
+ x: event.clientX,
227
+ y: event.clientY,
228
+ start: current.current.offset,
229
+ swiping: undefined,
230
+ rtl: isRtl(),
231
+ widths: { leading: widthOf("leading"), trailing: widthOf("trailing") },
232
+ rowWidth: root.current?.clientWidth ?? 0,
233
+ detach: () => {
234
+ window.removeEventListener("pointerup", handleUp, true);
235
+ window.removeEventListener("pointercancel", handleCancel, true);
236
+ },
237
+ };
238
+ };
239
+ const handlePointerMove = (event) => {
240
+ const state = gesture.current;
241
+ if (!state || state.pointerId !== event.pointerId || state.swiping === false)
242
+ return;
243
+ const across = (event.clientX - state.x) * (state.rtl ? -1 : 1);
244
+ const down = event.clientY - state.y;
245
+ if (state.swiping === undefined) {
246
+ if (Math.abs(across) < SLOP && Math.abs(down) < SLOP)
247
+ return;
248
+ if (Math.abs(across) <= Math.abs(down)) {
249
+ state.swiping = false;
250
+ return;
251
+ }
252
+ state.swiping = true;
253
+ capture(event.currentTarget, event.pointerId);
254
+ window.getSelection?.()?.removeAllRanges();
255
+ claim();
256
+ setRtl(state.rtl);
257
+ setSwiping(true);
258
+ }
259
+ const next = swipeActionsOffset(state.start + across, state.widths, state.rowWidth, fullSwipe);
260
+ move(next.offset, next.full);
261
+ };
262
+ /** The content lost the finger it held. A child that loses the finger to the content (as a touch moves its implicit capture) ends nothing. */
263
+ const handleLostPointerCapture = (event) => {
264
+ if (event.target === event.currentTarget && gesture.current?.pointerId === event.pointerId)
265
+ cancel();
266
+ };
267
+ /** A swipe or a press that closed the row is not a click on the content; a click from the keys still is. */
268
+ const handleClickCapture = (event) => {
269
+ if (!suppressClick.current || event.detail === 0)
270
+ return;
271
+ suppressClick.current = false;
272
+ event.preventDefault();
273
+ event.stopPropagation();
274
+ };
275
+ /** The focus on an action shows its side; on the content it closes the row. */
276
+ const handleFocus = (event) => {
277
+ if (gesture.current?.swiping)
278
+ return;
279
+ const side = ["leading", "trailing"].find((name) => sides.current[name]?.contains(event.target));
280
+ if (side) {
281
+ if (sideOf(current.current.offset) !== side)
282
+ open(side);
283
+ }
284
+ else if (current.current.offset !== 0) {
285
+ close();
286
+ }
287
+ };
288
+ const handleBlur = (event) => {
289
+ if (gesture.current?.swiping)
290
+ return;
291
+ if (event.relatedTarget instanceof Node && root.current?.contains(event.relatedTarget))
292
+ return;
293
+ if (current.current.offset !== 0)
294
+ close();
295
+ };
296
+ const select = (action, event) => {
297
+ action.onSelect?.();
298
+ // A press closes the row, as iOS does. From the keys the action keeps the focus, so its side stays open until
299
+ // the focus leaves the row.
300
+ if (event.detail === 0)
301
+ return;
302
+ event.currentTarget.blur();
303
+ close();
304
+ };
305
+ const renderSide = (side, actions) => {
306
+ if (actions.length < 1)
307
+ return null;
308
+ const shown = side === "leading" ? actions : [...actions].reverse();
309
+ const isFull = full && revealed === side;
310
+ return (_jsx("div", { ref: (element) => {
311
+ sides.current[side] = element;
312
+ }, className: s.Actions, "data-side": side, "data-full": isFull ? "" : undefined, style: isFull ? { width: Math.abs(offset) } : undefined, children: shown.map((action) => {
313
+ const color = action.color ?? "secondary";
314
+ const labelInside = labelPlacement === "inside" || !action.Icon;
315
+ const labelBelow = labelPlacement === "below" && !!action.Icon;
316
+ return (_jsxs("button", { type: "button", className: s.Action, "data-color": color, "data-first": action === actions[0] ? "" : undefined, "aria-label": labelInside || labelBelow ? undefined : action.label, onClick: (event) => select(action, event), children: [_jsxs("span", { className: s.Capsule, children: [action.Icon && _jsx(action.Icon, { className: s.Icon, "aria-hidden": "true" }), labelInside && _jsx("span", { className: s.Label, children: action.label })] }), labelBelow && _jsx("span", { className: s.Caption, children: action.label })] }, action.id));
317
+ }) }));
318
+ };
319
+ return (_jsxs("div", { ref: root, className: clsx(s.SwipeActions, className), "data-row": "", "data-swipe-actions": "", "data-label-placement": labelPlacement, "data-revealed": revealed, "data-swiping": swiping ? "" : undefined, onFocus: handleFocus, onBlur: handleBlur, children: [renderSide("leading", leading), _jsx("div", { className: s.Content, "data-swipe-content": "", style: offset !== 0 ? { "--swipe-actions-offset": `${rtl ? -offset : offset}px` } : undefined, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onLostPointerCapture: handleLostPointerCapture, onClickCapture: handleClickCapture, children: children }), renderSide("trailing", trailing)] }));
320
+ }
321
+ //# sourceMappingURL=SwipeActions.js.map