@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
@@ -14,16 +14,26 @@ export const Alert = ({ color = "primary", variant = "outline", title, descripti
14
14
  const [actionsAutoPlacement, setActionsAutoPlacement] = useState("end");
15
15
  // @ts-expect-error -- Type issue in usehooks-ts
16
16
  const { width: containerWidth } = useResizeObserver({ ref: containerRef });
17
+ const dismissible = onDismiss !== undefined;
18
+ // Measured again when the actions change too (another button, Dismiss added), not only the width
17
19
  useEffect(() => {
18
- const actionsWidth = actionsRef.current?.clientWidth ?? 0;
20
+ const actionsWidth = actionsWidthOf(actionsRef.current);
19
21
  if (actionsWidth && containerWidth) {
20
22
  // If actions are larger than a third of the container width, wrap them.
21
23
  const placement = actionsWidth > containerWidth / 3 ? "bottom" : "end";
22
24
  setActionsAutoPlacement(placement);
23
25
  }
24
- }, [containerWidth]);
26
+ }, [containerWidth, actions, dismissible]);
25
27
  return (_jsxs("div", { ref: mergeRefs([ref, containerRef]), className: clsx(s.Alert, className), "data-variant": variant, "data-color": color, role: color === "danger" ? "alert" : undefined, "data-actions-placement": actionsPlacement ?? actionsAutoPlacement, "data-banner": banner ? "" : undefined, "data-mobile-actions": mobileActions === "own" ? "own" : undefined, ...restProps, children: [indicator === false ? null : (_jsx("div", { className: s.Indicator, children: indicator ?? _jsx(Indicator, { color: color }) })), _jsxs("div", { className: s.Content, children: [_jsxs("div", { className: s.Message, children: [title && _jsx("div", { className: s.Title, children: title }), description && _jsx("div", { className: s.Description, children: description })] }), (actions || onDismiss) && (_jsxs("div", { className: clsx(s.Actions, actionsClassName), ref: actionsRef, children: [actions, onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: color, variant: "soft", pill: true, className: s.DismissButton, children: "Dismiss" }))] }))] }), onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: "secondary", variant: "soft", size: "sm", uniform: true, pill: true, "aria-label": "Dismiss", className: s.CloseButton, children: _jsx(X, {}) }))] }));
26
28
  };
29
+ /** The actions' own width: their row stretches to the alert's width when they sit at the bottom */
30
+ const actionsWidthOf = (element) => {
31
+ if (!element)
32
+ return 0;
33
+ const children = Array.from(element.children);
34
+ const gap = parseFloat(getComputedStyle(element).columnGap) || 0;
35
+ return children.reduce((width, child) => width + child.offsetWidth, 0) + gap * Math.max(0, children.length - 1);
36
+ };
27
37
  export const Indicator = ({ color }) => {
28
38
  // Choose a default icon based on the color (which signals intention)
29
39
  switch (color) {
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAA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AAC,OAAO,QAAC,IAAI,sBAAY,SAAS,EAAC,SAAS,EAAE,CAAC,CAAC,WAAW,YAC7I,KAAC,CAAC,KAAG,GACE,CACV,IACG,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAkC,EAAE,EAAE;IACrE,qEAAqE;IACrE,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,KAAC,OAAO,KAAG,CAAA;QACpB,KAAK,SAAS;YACZ,OAAO,KAAC,WAAW,KAAG,CAAA;QACxB;YACE,OAAO,KAAC,IAAI,KAAG,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref, useEffect, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport { CheckCircle, Info, Warning, X } from \"../Icon\"\nimport { Button } from \"../Button\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\nexport type AlertMobileActions = \"capsules\" | \"own\"\n\nexport type AlertProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /** Title displayed in the alert. */\n title?: ReactNode\n /** Description text displayed in the alert */\n description?: ReactNode\n /** Actions associated with the Alert. */\n actions?: ReactNode\n /** Sets the placement of `actions` always on the end or the bottom. Default behavior is automatic placement based on sizing. */\n actionsPlacement?: \"end\" | \"bottom\"\n /**\n * How the actions show at 767px and below: 50px capsules side by side, as the buttons of an iOS tip (TipKit), or\n * the buttons as given, at their own size, for an alert inside a block of buttons of its own.\n * @default \"capsules\"\n */\n mobileActions?: AlertMobileActions\n /** Optional override for the default indicator of the alert. When `false`, no indicator is shown. */\n indicator?: ReactNode | false\n /** Class applied to the alert container */\n className?: string\n /** Class applied to the actions container */\n actionsClassName?: string\n /** Callback when dismiss button is clicked. Shows dismiss button when provided. */\n onDismiss?: () => void\n /**\n * A full-width strip across the top or bottom of a page or panel (offline,\n * read-only, a new version): square corners and lines above and below only.\n * @default false\n */\n banner?: boolean\n /** Ref applied to the alert container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Alert = ({\n color = \"primary\",\n variant = \"outline\",\n title,\n description,\n actions,\n actionsPlacement,\n mobileActions = \"capsules\",\n indicator,\n className,\n actionsClassName,\n onDismiss,\n banner = false,\n ref,\n ...restProps\n}: AlertProps) => {\n const containerRef = useRef<HTMLDivElement>(null)\n const actionsRef = useRef<HTMLDivElement>(null)\n const [actionsAutoPlacement, setActionsAutoPlacement] = useState<\"end\" | \"bottom\">(\"end\")\n // @ts-expect-error -- Type issue in usehooks-ts\n const { width: containerWidth } = useResizeObserver({ ref: containerRef })\n\n useEffect(() => {\n const actionsWidth = actionsRef.current?.clientWidth ?? 0\n\n if (actionsWidth && containerWidth) {\n // If actions are larger than a third of the container width, wrap them.\n const placement = actionsWidth > containerWidth / 3 ? \"bottom\" : \"end\"\n setActionsAutoPlacement(placement)\n }\n }, [containerWidth])\n\n return (\n <div\n ref={mergeRefs([ref, containerRef])}\n className={clsx(s.Alert, className)}\n data-variant={variant}\n data-color={color}\n role={color === \"danger\" ? \"alert\" : undefined}\n data-actions-placement={actionsPlacement ?? actionsAutoPlacement}\n data-banner={banner ? \"\" : undefined}\n data-mobile-actions={mobileActions === \"own\" ? \"own\" : undefined}\n {...restProps}\n >\n {indicator === false ? null : (\n <div className={s.Indicator}>{indicator ?? <Indicator color={color} />}</div>\n )}\n <div className={s.Content}>\n <div className={s.Message}>\n {title && <div className={s.Title}>{title}</div>}\n {description && <div className={s.Description}>{description}</div>}\n </div>\n {(actions || onDismiss) && (\n <div className={clsx(s.Actions, actionsClassName)} ref={actionsRef}>\n {actions}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color={color} variant=\"soft\" pill className={s.DismissButton}>\n Dismiss\n </Button>\n )}\n </div>\n )}\n </div>\n {/* On a phone the alert is dismissed with a close button in its corner, as an iOS tip is */}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color=\"secondary\" variant=\"soft\" size=\"sm\" uniform pill aria-label=\"Dismiss\" className={s.CloseButton}>\n <X />\n </Button>\n )}\n </div>\n )\n}\n\nexport const Indicator = ({ color }: { color: AlertProps[\"color\"] }) => {\n // Choose a default icon based on the color (which signals intention)\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return <Warning />\n case \"success\":\n return <CheckCircle />\n default:\n return <Info />\n }\n}\n"]}
1
+ {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAiDhE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,SAAS,EACnB,KAAK,EACL,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,aAAa,GAAG,UAAU,EAC1B,SAAS,EACT,SAAS,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,OAAO,CAAC,CAAA;IACtB,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAkB,CAAA;IAC9D,MAAM,GAAG,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAChE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACjH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAkC,EAAE,EAAE;IACrE,qEAAqE;IACrE,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,KAAC,OAAO,KAAG,CAAA;QACpB,KAAK,SAAS;YACZ,OAAO,KAAC,WAAW,KAAG,CAAA;QACxB;YACE,OAAO,KAAC,IAAI,KAAG,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref, useEffect, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport { CheckCircle, Info, Warning, X } from \"../Icon\"\nimport { Button } from \"../Button\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\nexport type AlertMobileActions = \"capsules\" | \"own\"\n\nexport type AlertProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /** Title displayed in the alert. */\n title?: ReactNode\n /** Description text displayed in the alert */\n description?: ReactNode\n /** Actions associated with the Alert. */\n actions?: ReactNode\n /** Sets the placement of `actions` always on the end or the bottom. Default behavior is automatic placement based on sizing. */\n actionsPlacement?: \"end\" | \"bottom\"\n /**\n * How the actions show at 767px and below: 50px capsules side by side, as the buttons of an iOS tip (TipKit), or\n * the buttons as given, at their own size, for an alert inside a block of buttons of its own.\n * @default \"capsules\"\n */\n mobileActions?: AlertMobileActions\n /** Optional override for the default indicator of the alert. When `false`, no indicator is shown. */\n indicator?: ReactNode | false\n /** Class applied to the alert container */\n className?: string\n /** Class applied to the actions container */\n actionsClassName?: string\n /** Callback when dismiss button is clicked. Shows dismiss button when provided. */\n onDismiss?: () => void\n /**\n * A full-width strip across the top or bottom of a page or panel (offline,\n * read-only, a new version): square corners and lines above and below only.\n * @default false\n */\n banner?: boolean\n /** Ref applied to the alert container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Alert = ({\n color = \"primary\",\n variant = \"outline\",\n title,\n description,\n actions,\n actionsPlacement,\n mobileActions = \"capsules\",\n indicator,\n className,\n actionsClassName,\n onDismiss,\n banner = false,\n ref,\n ...restProps\n}: AlertProps) => {\n const containerRef = useRef<HTMLDivElement>(null)\n const actionsRef = useRef<HTMLDivElement>(null)\n const [actionsAutoPlacement, setActionsAutoPlacement] = useState<\"end\" | \"bottom\">(\"end\")\n // @ts-expect-error -- Type issue in usehooks-ts\n const { width: containerWidth } = useResizeObserver({ ref: containerRef })\n\n const dismissible = onDismiss !== undefined\n // Measured again when the actions change too (another button, Dismiss added), not only the width\n useEffect(() => {\n const actionsWidth = actionsWidthOf(actionsRef.current)\n\n if (actionsWidth && containerWidth) {\n // If actions are larger than a third of the container width, wrap them.\n const placement = actionsWidth > containerWidth / 3 ? \"bottom\" : \"end\"\n setActionsAutoPlacement(placement)\n }\n }, [containerWidth, actions, dismissible])\n\n return (\n <div\n ref={mergeRefs([ref, containerRef])}\n className={clsx(s.Alert, className)}\n data-variant={variant}\n data-color={color}\n role={color === \"danger\" ? \"alert\" : undefined}\n data-actions-placement={actionsPlacement ?? actionsAutoPlacement}\n data-banner={banner ? \"\" : undefined}\n data-mobile-actions={mobileActions === \"own\" ? \"own\" : undefined}\n {...restProps}\n >\n {indicator === false ? null : (\n <div className={s.Indicator}>{indicator ?? <Indicator color={color} />}</div>\n )}\n <div className={s.Content}>\n <div className={s.Message}>\n {title && <div className={s.Title}>{title}</div>}\n {description && <div className={s.Description}>{description}</div>}\n </div>\n {(actions || onDismiss) && (\n <div className={clsx(s.Actions, actionsClassName)} ref={actionsRef}>\n {actions}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color={color} variant=\"soft\" pill className={s.DismissButton}>\n Dismiss\n </Button>\n )}\n </div>\n )}\n </div>\n {/* On a phone the alert is dismissed with a close button in its corner, as an iOS tip is */}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color=\"secondary\" variant=\"soft\" size=\"sm\" uniform pill aria-label=\"Dismiss\" className={s.CloseButton}>\n <X />\n </Button>\n )}\n </div>\n )\n}\n\n/** The actions' own width: their row stretches to the alert's width when they sit at the bottom */\nconst actionsWidthOf = (element: HTMLElement | null) => {\n if (!element) return 0\n const children = Array.from(element.children) as HTMLElement[]\n const gap = parseFloat(getComputedStyle(element).columnGap) || 0\n return children.reduce((width, child) => width + child.offsetWidth, 0) + gap * Math.max(0, children.length - 1)\n}\n\nexport const Indicator = ({ color }: { color: AlertProps[\"color\"] }) => {\n // Choose a default icon based on the color (which signals intention)\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return <Warning />\n case \"success\":\n return <CheckCircle />\n default:\n return <Info />\n }\n}\n"]}
@@ -14,9 +14,9 @@ import { alphaPercent, channelTrack, COLOR_PICKER_CHANNELS, COLOR_PICKER_GRID_CO
14
14
  const BLACK = { r: 0, g: 0, b: 0, a: 1 };
15
15
  const GRID_CELLS = COLOR_PICKER_GRID_COLUMNS * 10;
16
16
  const NAVIGATION_KEYS = ["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp", "Home", "End"];
17
- /** A slider on a colored track, after the kit's Opacity slider (515:47434): a 36px ring on a 40px capsule. */
18
- function ColorSlider({ labelId, value, max, track, valueText, onChange }) {
19
- return (_jsx("div", { className: s.Track, style: { "--color-picker-track": track }, children: _jsxs(RadixSlider.Root, { className: s.SliderRoot, min: 0, max: max, step: 1, value: [value], onValueChange: ([next]) => onChange(next), children: [_jsx(RadixSlider.Track, { className: s.SliderTrack }), _jsx(RadixSlider.Thumb, { className: s.Knob, "aria-labelledby": labelId, "aria-valuetext": valueText })] }) }));
17
+ /** A slider on a colored track, after the kit's Opacity slider (515:47434): a ring filled with the color on a capsule. */
18
+ function ColorSlider({ labelId, value, max, track, fill, valueText, onChange }) {
19
+ return (_jsx("div", { className: s.Track, style: { "--color-picker-track": track }, children: _jsxs(RadixSlider.Root, { className: s.SliderRoot, min: 0, max: max, step: 1, value: [value], onValueChange: ([next]) => onChange(next), children: [_jsx(RadixSlider.Track, { className: s.SliderTrack }), _jsx(RadixSlider.Thumb, { className: s.Knob, style: { backgroundColor: fill }, "aria-labelledby": labelId, "aria-valuetext": valueText })] }) }));
20
20
  }
21
21
  /** The value beside a slider, after the kit's Percentage field (515:47438); typing a value and Enter or leaving it applies it. */
22
22
  function ColorField({ value, label, labelledBy, inputMode, wide = false, onCommit }) {
@@ -37,8 +37,9 @@ function ColorField({ value, label, labelledBy, inputMode, wide = false, onCommi
37
37
  } }));
38
38
  }
39
39
  /**
40
- * The system color picker of iOS 26 (kit Color Picker - iPhone 0:5275): Grid, Spectrum and Sliders, the Opacity
41
- * slider, and the saved colors with Add. Show it inside a Popover or a Sheet, or use `ColorWell`, which does.
40
+ * The system color picker of iOS 27.2 (UIColorPickerViewController, after the iOS 26 kit's Color Picker - iPhone
41
+ * 0:5275): Grid, Spectrum and Sliders, the Opacity slider, and the saved colors with Add. Show it inside a Popover or
42
+ * a Sheet, or use `ColorWell`, which does.
42
43
  */
43
44
  export function ColorPicker({ id, value: valueProp, defaultValue, onChange, supportsAlpha = true, mode: modeProp, defaultMode = "grid", onModeChange, swatches: swatchesProp, defaultSwatches, onSwatchesChange, "aria-label": ariaLabel = "Colors", className, }) {
44
45
  const uid = useId();
@@ -71,7 +72,7 @@ export function ColorPicker({ id, value: valueProp, defaultValue, onChange, supp
71
72
  setInternalSwatches(next);
72
73
  onSwatchesChange?.(next);
73
74
  };
74
- return (_jsxs("div", { id: id, role: "group", "aria-label": ariaLabel, className: clsx(s.ColorPicker, className), "data-mode": mode, children: [_jsx(SegmentedControl, { "aria-label": "Mode", value: mode, onChange: changeMode, block: true, className: s.Modes, children: COLOR_PICKER_MODES.map((option) => (_jsx(SegmentedControl.Option, { value: option.value, children: option.label }, option.value))) }), _jsxs("div", { className: s.Body, children: [mode === "grid" && _jsx(ColorGrid, { color: color, onSelect: commit }), mode === "spectrum" && _jsx(ColorSpectrum, { color: color, onSelect: commit }), mode === "sliders" && _jsx(ColorSliders, { uid: uid, color: color, onSelect: commit })] }), supportsAlpha && (_jsxs("div", { className: s.Opacity, children: [_jsx("span", { id: `${uid}-opacity`, className: s.Label, children: "Opacity" }), _jsxs("div", { className: s.Row, children: [_jsx(ColorSlider, { labelId: `${uid}-opacity`, value: alphaPercent(color.a), max: 100, track: opacityTrack(color), valueText: `${alphaPercent(color.a)}%`, onChange: (percent) => commit({ ...colorRef.current, a: percent / 100 }) }), _jsx(ColorField, { value: `${alphaPercent(color.a)}%`, labelledBy: `${uid}-opacity`, inputMode: "numeric", onCommit: (text) => {
75
+ return (_jsxs("div", { id: id, role: "group", "aria-label": ariaLabel, className: clsx(s.ColorPicker, className), "data-mode": mode, children: [_jsx(SegmentedControl, { "aria-label": "Mode", value: mode, onChange: changeMode, block: true, className: s.Modes, "data-mobile-size": "small", children: COLOR_PICKER_MODES.map((option) => (_jsx(SegmentedControl.Option, { value: option.value, children: option.label }, option.value))) }), _jsxs("div", { className: s.Body, children: [mode === "grid" && _jsx(ColorGrid, { color: color, onSelect: commit }), mode === "spectrum" && _jsx(ColorSpectrum, { color: color, onSelect: commit }), mode === "sliders" && _jsx(ColorSliders, { uid: uid, color: color, onSelect: commit })] }), supportsAlpha && (_jsxs("div", { className: s.Opacity, children: [_jsx("span", { id: `${uid}-opacity`, className: s.Label, children: "Opacity" }), _jsxs("div", { className: s.Row, children: [_jsx(ColorSlider, { labelId: `${uid}-opacity`, value: alphaPercent(color.a), max: 100, track: opacityTrack(color), fill: cssColor(color), valueText: `${alphaPercent(color.a)}%`, onChange: (percent) => commit({ ...colorRef.current, a: percent / 100 }) }), _jsx(ColorField, { value: `${alphaPercent(color.a)}%`, labelledBy: `${uid}-opacity`, inputMode: "numeric", onCommit: (text) => {
75
76
  const percent = parseNumber(text, 0, 100);
76
77
  if (percent !== null)
77
78
  commit({ ...colorRef.current, a: percent / 100 });
@@ -152,20 +153,21 @@ function ColorSpectrum({ color, onSelect }) {
152
153
  function ColorSliders({ uid, color, onSelect }) {
153
154
  return (_jsxs("div", { className: s.Sliders, children: [COLOR_PICKER_CHANNELS.map(({ channel, label }) => {
154
155
  const labelId = `${uid}-${channel}`;
155
- return (_jsxs("div", { className: s.Channel, children: [_jsx("span", { id: labelId, className: s.Label, children: label }), _jsxs("div", { className: s.Row, children: [_jsx(ColorSlider, { labelId: labelId, value: color[channel], max: 255, track: channelTrack(color, channel), valueText: String(color[channel]), onChange: (next) => onSelect({ ...color, [channel]: next }) }), _jsx(ColorField, { value: String(color[channel]), labelledBy: labelId, inputMode: "numeric", onCommit: (text) => {
156
+ return (_jsxs("div", { className: s.Channel, children: [_jsx("span", { id: labelId, className: s.Label, children: label }), _jsxs("div", { className: s.Row, children: [_jsx(ColorSlider, { labelId: labelId, value: color[channel], max: 255, track: channelTrack(color, channel), fill: cssColor(color, 1), valueText: String(color[channel]), onChange: (next) => onSelect({ ...color, [channel]: next }) }), _jsx(ColorField, { value: String(color[channel]), labelledBy: labelId, inputMode: "numeric", onCommit: (text) => {
156
157
  const next = parseNumber(text, 0, 255);
157
158
  if (next !== null)
158
159
  onSelect({ ...color, [channel]: next });
159
160
  } })] })] }, channel));
160
- }), _jsxs("div", { className: s.Hex, children: [_jsx("span", { id: `${uid}-hex`, className: s.Label, children: "Hex Color #" }), _jsx(ColorField, { value: hexDigits(color), labelledBy: `${uid}-hex`, inputMode: "text", wide: true, onCommit: (text) => {
161
+ }), _jsxs("div", { className: s.Hex, children: [_jsx("span", { id: `${uid}-hex`, className: s.HexLabel, children: "Hex Color #" }), _jsx(ColorField, { value: hexDigits(color), labelledBy: `${uid}-hex`, inputMode: "text", wide: true, onCommit: (text) => {
161
162
  const next = parseColor(text);
162
163
  if (next)
163
164
  onSelect({ ...next, a: color.a });
164
165
  } })] })] }));
165
166
  }
166
167
  /**
167
- * The current color, and the saved colors in pages of two rows of five with Add after the last (kit Swatches
168
- * 515:46585). A saved color is a radio; Delete or Backspace, or Delete in its context menu, removes it.
168
+ * The current color, and the saved colors in pages of two rows of six with Add after the last (iOS 27.2; kit
169
+ * Swatches 515:46585 had rows of five). A saved color is a radio; Delete or Backspace, or Delete in its context
170
+ * menu, removes it.
169
171
  */
170
172
  function ColorSwatches({ color, swatches, onSelect, onChange }) {
171
173
  const pagesRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EACL,KAAK,EACL,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM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AAK,CAAC,CAAA;gCACd,YAAY,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,YAAY,CAAC,WAAW,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;4BAC3H,CAAC,GACD,CACH,GACG,IACF,IACF,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Slider as RadixSlider } from \"radix-ui\"\nimport {\n useId,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent,\n} from \"react\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { prefersReducedMotion } from \"../../lib/helpers\"\nimport { ContextMenu } from \"../ContextMenu\"\nimport { Plus, RemoveTrash } from \"../Icon\"\nimport { PageControl } from \"../PageControl\"\nimport { SegmentedControl } from \"../SegmentedControl\"\nimport {\n alphaPercent,\n channelTrack,\n COLOR_PICKER_CHANNELS,\n COLOR_PICKER_GRID_COLUMNS,\n COLOR_PICKER_MODES,\n COLOR_PICKER_SWATCHES_PER_PAGE,\n cssColor,\n formatColor,\n gridColor,\n gridIndex,\n gridMove,\n hexDigits,\n listMove,\n opacityTrack,\n parseColor,\n parseNumber,\n sameRgb,\n spectrumColor,\n spectrumPoint,\n swatchPageCount,\n type ColorPickerMode,\n type Rgba,\n type SpectrumPoint,\n} from \"./shared\"\n\nconst BLACK: Rgba = { r: 0, g: 0, b: 0, a: 1 }\nconst GRID_CELLS = COLOR_PICKER_GRID_COLUMNS * 10\nconst NAVIGATION_KEYS = [\"ArrowRight\", \"ArrowLeft\", \"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"]\n\nexport type ColorPickerProps = {\n /** The `id` of the picker. */\n id?: string\n /** The controlled color, `#rrggbb` or `#rrggbbaa`. Use with `onChange`. */\n value?: string\n /** The color when it is initially rendered. Use when you do not need to control the color. @default \"#000000\" */\n defaultValue?: string\n /** Called with the next color: `#rrggbb`, or `#rrggbbaa` when it is not opaque. */\n onChange?: (value: string) => void\n /** Shows the Opacity slider, as `supportsAlpha` of the system picker. @default true */\n supportsAlpha?: boolean\n /** The controlled way to choose a color. Use with `onModeChange`. */\n mode?: ColorPickerMode\n /** The way to choose a color when the picker is initially rendered. @default \"grid\" */\n defaultMode?: ColorPickerMode\n /** Called when another of Grid, Spectrum and Sliders is chosen. */\n onModeChange?: (mode: ColorPickerMode) => void\n /** The controlled saved colors. Use with `onSwatchesChange`. */\n swatches?: string[]\n /** The saved colors when the picker is initially rendered. @default [] */\n defaultSwatches?: string[]\n /** Called with the saved colors after Add saves the current color or Delete removes one. */\n onSwatchesChange?: (swatches: string[]) => void\n /** Accessible name of the picker. @default \"Colors\" */\n \"aria-label\"?: string\n /** CSS classes applied to the picker */\n className?: string\n}\n\ntype ColorSliderProps = {\n labelId: string\n value: number\n max: number\n track: string\n valueText: string\n onChange: (value: number) => void\n}\n\n/** A slider on a colored track, after the kit's Opacity slider (515:47434): a 36px ring on a 40px capsule. */\nfunction ColorSlider({ labelId, value, max, track, valueText, onChange }: ColorSliderProps) {\n return (\n <div className={s.Track} style={{ \"--color-picker-track\": track } as CSSProperties}>\n <RadixSlider.Root className={s.SliderRoot} min={0} max={max} step={1} value={[value]} onValueChange={([next]) => onChange(next)}>\n <RadixSlider.Track className={s.SliderTrack} />\n <RadixSlider.Thumb className={s.Knob} aria-labelledby={labelId} aria-valuetext={valueText} />\n </RadixSlider.Root>\n </div>\n )\n}\n\ntype ColorFieldProps = {\n value: string\n label?: string\n labelledBy?: string\n inputMode: \"numeric\" | \"text\"\n wide?: boolean\n onCommit: (text: string) => void\n}\n\n/** The value beside a slider, after the kit's Percentage field (515:47438); typing a value and Enter or leaving it applies it. */\nfunction ColorField({ value, label, labelledBy, inputMode, wide = false, onCommit }: ColorFieldProps) {\n const [draft, setDraft] = useState<string | null>(null)\n const commit = () => {\n if (draft !== null) onCommit(draft)\n setDraft(null)\n }\n return (\n <input\n className={s.Field}\n data-wide={wide ? \"\" : undefined}\n type=\"text\"\n inputMode={inputMode}\n autoComplete=\"off\"\n spellCheck={false}\n aria-label={label}\n aria-labelledby={labelledBy}\n value={draft ?? value}\n onFocus={(event) => {\n setDraft(value)\n event.currentTarget.select()\n }}\n onChange={(event) => setDraft(event.currentTarget.value)}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\") return\n event.preventDefault()\n commit()\n }}\n />\n )\n}\n\n/**\n * The system color picker of iOS 26 (kit Color Picker - iPhone 0:5275): Grid, Spectrum and Sliders, the Opacity\n * slider, and the saved colors with Add. Show it inside a Popover or a Sheet, or use `ColorWell`, which does.\n */\nexport function ColorPicker({\n id,\n value: valueProp,\n defaultValue,\n onChange,\n supportsAlpha = true,\n mode: modeProp,\n defaultMode = \"grid\",\n onModeChange,\n swatches: swatchesProp,\n defaultSwatches,\n onSwatchesChange,\n \"aria-label\": ariaLabel = \"Colors\",\n className,\n}: ColorPickerProps) {\n const uid = useId()\n const [internalValue, setInternalValue] = useState(() => defaultValue ?? \"#000000\")\n const value = valueProp ?? internalValue\n const color = parseColor(value) ?? BLACK\n const colorRef = useLatestValue(color)\n const options = useLatestValue({ controlled: valueProp !== undefined, supportsAlpha, onChange })\n\n const [internalMode, setInternalMode] = useState<ColorPickerMode>(defaultMode)\n const mode = modeProp ?? internalMode\n\n const [internalSwatches, setInternalSwatches] = useState(() => defaultSwatches ?? [])\n const swatches = swatchesProp ?? internalSwatches\n\n const commit = (next: Rgba) => {\n const formatted = formatColor(options.current.supportsAlpha ? next : { ...next, a: 1 })\n // Only a color other than the one shown is reported; an owner that keeps its color hears every new choice.\n if (formatted === formatColor(colorRef.current)) return\n // A controlled color changes only when the owner passes it back, as in Vue.\n if (!options.current.controlled) setInternalValue(formatted)\n options.current.onChange?.(formatted)\n }\n\n const changeMode = (next: ColorPickerMode) => {\n if (modeProp === undefined) setInternalMode(next)\n onModeChange?.(next)\n }\n\n const changeSwatches = (next: string[]) => {\n if (swatchesProp === undefined) setInternalSwatches(next)\n onSwatchesChange?.(next)\n }\n\n return (\n <div id={id} role=\"group\" aria-label={ariaLabel} className={clsx(s.ColorPicker, className)} data-mode={mode}>\n <SegmentedControl<ColorPickerMode> aria-label=\"Mode\" value={mode} onChange={changeMode} block className={s.Modes}>\n {COLOR_PICKER_MODES.map((option) => (\n <SegmentedControl.Option key={option.value} value={option.value}>{option.label}</SegmentedControl.Option>\n ))}\n </SegmentedControl>\n <div className={s.Body}>\n {mode === \"grid\" && <ColorGrid color={color} onSelect={commit} />}\n {mode === \"spectrum\" && <ColorSpectrum color={color} onSelect={commit} />}\n {mode === \"sliders\" && <ColorSliders uid={uid} color={color} onSelect={commit} />}\n </div>\n {supportsAlpha && (\n <div className={s.Opacity}>\n <span id={`${uid}-opacity`} className={s.Label}>Opacity</span>\n <div className={s.Row}>\n <ColorSlider\n labelId={`${uid}-opacity`}\n value={alphaPercent(color.a)}\n max={100}\n track={opacityTrack(color)}\n valueText={`${alphaPercent(color.a)}%`}\n onChange={(percent) => commit({ ...colorRef.current, a: percent / 100 })}\n />\n <ColorField\n value={`${alphaPercent(color.a)}%`}\n labelledBy={`${uid}-opacity`}\n inputMode=\"numeric\"\n onCommit={(text) => {\n const percent = parseNumber(text, 0, 100)\n if (percent !== null) commit({ ...colorRef.current, a: percent / 100 })\n }}\n />\n </div>\n </div>\n )}\n <ColorSwatches color={color} swatches={swatches} onSelect={commit} onChange={changeSwatches} />\n </div>\n )\n}\n\ntype PartProps = { color: Rgba; onSelect: (color: Rgba) => void }\n\n/** The kit's Color Grid: twelve hues across, grays then nine shades down; the selected cell has a 3px white ring. */\nfunction ColorGrid({ color, onSelect }: PartProps) {\n const selected = gridIndex(color)\n const focusable = selected === -1 ? 0 : selected\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const from = Number((event.target as HTMLElement).dataset.index)\n if (!Number.isInteger(from) || !NAVIGATION_KEYS.includes(event.key)) return\n event.preventDefault()\n const next = gridMove(from, event.key)\n if (next === from) return\n const cell = event.currentTarget.querySelector<HTMLElement>(`[data-index=\"${next}\"]`)\n cell?.focus()\n onSelect({ ...(parseColor(gridColor(next)) ?? BLACK), a: color.a })\n }\n\n return (\n <div role=\"radiogroup\" aria-label=\"Grid\" className={s.Grid} onKeyDown={onKeyDown}>\n {Array.from({ length: GRID_CELLS }, (_, index) => {\n const hex = gridColor(index)\n return (\n <button\n key={hex}\n type=\"button\"\n role=\"radio\"\n aria-checked={index === selected}\n aria-label={hex.toUpperCase()}\n tabIndex={index === focusable ? 0 : -1}\n data-index={index}\n className={s.Cell}\n style={{ backgroundColor: hex }}\n onClick={() => onSelect({ ...(parseColor(hex) ?? BLACK), a: color.a })}\n />\n )\n })}\n </div>\n )\n}\n\nconst SPECTRUM_STEP = 0.01\n\n/**\n * The spectrum: hue from top to bottom, white to the full hue to black across. Up and Down change the hue, Left\n * and Right the lightness, by 1% (10% with Shift or Page Up and Page Down).\n */\nfunction ColorSpectrum({ color, onSelect }: PartProps) {\n const [held, setHeld] = useState<{ point: SpectrumPoint; digits: string }>(() => ({ point: spectrumPoint(color), digits: hexDigits(color) }))\n // The point the picker last chose stays while the color is the one it chose: a hex color loses the exact point,\n // and a gray or white has no hue of its own.\n const point = held.digits === hexDigits(color) ? held.point : spectrumPoint(color, held.point)\n\n const choose = (next: SpectrumPoint) => {\n const clamped = { x: Math.min(1, Math.max(0, next.x)), y: Math.min(1, Math.max(0, next.y)) }\n const chosen = spectrumColor(clamped, color.a)\n setHeld({ point: clamped, digits: hexDigits(chosen) })\n onSelect(chosen)\n }\n\n const fromPointer = (event: PointerEvent<HTMLDivElement>) => {\n const box = event.currentTarget.getBoundingClientRect()\n if (box.width === 0 || box.height === 0) return\n choose({ x: (event.clientX - box.left) / box.width, y: (event.clientY - box.top) / box.height })\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const step = event.shiftKey ? SPECTRUM_STEP * 10 : SPECTRUM_STEP\n const moves: Record<string, SpectrumPoint> = {\n ArrowLeft: { x: point.x - step, y: point.y },\n ArrowRight: { x: point.x + step, y: point.y },\n ArrowUp: { x: point.x, y: point.y - step },\n ArrowDown: { x: point.x, y: point.y + step },\n PageUp: { x: point.x, y: point.y - SPECTRUM_STEP * 10 },\n PageDown: { x: point.x, y: point.y + SPECTRUM_STEP * 10 },\n }\n const next = moves[event.key]\n if (!next) return\n event.preventDefault()\n choose(next)\n }\n\n const hue = Math.round(point.y * 360)\n return (\n <div\n role=\"slider\"\n tabIndex={0}\n aria-label=\"Spectrum\"\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={hue}\n aria-valuetext={`#${hexDigits(color)}, hue ${hue}°, lightness ${Math.round((1 - point.x) * 100)}%`}\n className={s.Spectrum}\n onPointerDown={(event) => {\n if (event.button !== 0) return\n event.currentTarget.setPointerCapture?.(event.pointerId)\n event.currentTarget.focus({ preventScroll: true })\n fromPointer(event)\n }}\n onPointerMove={(event) => {\n if (event.currentTarget.hasPointerCapture?.(event.pointerId)) fromPointer(event)\n }}\n onKeyDown={onKeyDown}\n >\n <span\n className={s.Loupe}\n style={{ left: `${point.x * 100}%`, top: `${point.y * 100}%`, backgroundColor: cssColor(color, 1) }}\n />\n </div>\n )\n}\n\n/** Red, Green and Blue, each a slider and a field from 0 to 255, then the Hex field. */\nfunction ColorSliders({ uid, color, onSelect }: PartProps & { uid: string }) {\n return (\n <div className={s.Sliders}>\n {COLOR_PICKER_CHANNELS.map(({ channel, label }) => {\n const labelId = `${uid}-${channel}`\n return (\n <div key={channel} className={s.Channel}>\n <span id={labelId} className={s.Label}>{label}</span>\n <div className={s.Row}>\n <ColorSlider\n labelId={labelId}\n value={color[channel]}\n max={255}\n track={channelTrack(color, channel)}\n valueText={String(color[channel])}\n onChange={(next) => onSelect({ ...color, [channel]: next })}\n />\n <ColorField\n value={String(color[channel])}\n labelledBy={labelId}\n inputMode=\"numeric\"\n onCommit={(text) => {\n const next = parseNumber(text, 0, 255)\n if (next !== null) onSelect({ ...color, [channel]: next })\n }}\n />\n </div>\n </div>\n )\n })}\n <div className={s.Hex}>\n <span id={`${uid}-hex`} className={s.Label}>Hex Color #</span>\n <ColorField\n value={hexDigits(color)}\n labelledBy={`${uid}-hex`}\n inputMode=\"text\"\n wide\n onCommit={(text) => {\n const next = parseColor(text)\n if (next) onSelect({ ...next, a: color.a })\n }}\n />\n </div>\n </div>\n )\n}\n\ntype ColorSwatchesProps = PartProps & { swatches: string[]; onChange: (swatches: string[]) => void }\n\n/**\n * The current color, and the saved colors in pages of two rows of five with Add after the last (kit Swatches\n * 515:46585). A saved color is a radio; Delete or Backspace, or Delete in its context menu, removes it.\n */\nfunction ColorSwatches({ color, swatches, onSelect, onChange }: ColorSwatchesProps) {\n const pagesRef = useRef<HTMLDivElement>(null)\n const [page, setPage] = useState(0)\n const saved = swatches.map((hex) => parseColor(hex) ?? BLACK)\n const current = formatColor(color)\n const checked = saved.findIndex((swatch) => sameRgb(swatch, color) && alphaPercent(swatch.a) === alphaPercent(color.a))\n const focusable = checked === -1 ? 0 : checked\n const pageCount = swatchPageCount(swatches.length)\n\n const reveal = (element: HTMLElement | null | undefined) => element?.scrollIntoView?.({ block: \"nearest\", inline: \"nearest\" })\n\n const remove = (index: number, pages: HTMLElement | null) => {\n onChange(swatches.filter((_, i) => i !== index))\n // Focus stays in the list: on the color that takes the place, the one before at the end, or Add.\n const target = Math.min(index, swatches.length - 2)\n requestAnimationFrame(() => {\n const next = target >= 0 ? pages?.querySelector<HTMLElement>(`[data-swatch=\"${target}\"]`) : pages?.querySelector<HTMLElement>(\"[data-add]\")\n next?.focus()\n reveal(next)\n })\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const from = Number((event.target as HTMLElement).dataset.swatch)\n if (!Number.isInteger(from)) return\n if (event.key === \"Delete\" || event.key === \"Backspace\") {\n event.preventDefault()\n remove(from, event.currentTarget)\n return\n }\n if (!NAVIGATION_KEYS.includes(event.key)) return\n event.preventDefault()\n const next = listMove(from, swatches.length, event.key)\n if (next === from) return\n const element = event.currentTarget.querySelector<HTMLElement>(`[data-swatch=\"${next}\"]`)\n element?.focus()\n reveal(element)\n onSelect(saved[next])\n }\n\n const items = [...swatches.map((hex, index) => ({ hex, index })), null]\n const pages = Array.from({ length: pageCount }, (_, p) => items.slice(p * COLOR_PICKER_SWATCHES_PER_PAGE, (p + 1) * COLOR_PICKER_SWATCHES_PER_PAGE))\n\n return (\n <div className={s.Swatches}>\n <div role=\"img\" aria-label={`Selected color #${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`} className={s.Current}>\n <span className={s.CurrentFill} style={{ backgroundColor: cssColor(color) }} />\n </div>\n <div className={s.Saved}>\n <div\n ref={pagesRef}\n role=\"radiogroup\"\n aria-label=\"Saved colors\"\n className={s.Pages}\n onKeyDown={onKeyDown}\n onScroll={(event) => {\n const { scrollLeft, clientWidth } = event.currentTarget\n if (clientWidth > 0) setPage(Math.round(scrollLeft / clientWidth))\n }}\n >\n {pages.map((pageItems, p) => (\n <div key={p} className={s.Page}>\n {pageItems.map((item) => item === null ? (\n <button\n key=\"add\"\n type=\"button\"\n data-add=\"\"\n className={s.Add}\n aria-label=\"Add color\"\n onClick={(event) => {\n onChange([...swatches, current])\n const add = event.currentTarget\n requestAnimationFrame(() => reveal(add))\n }}\n >\n <Plus />\n </button>\n ) : (\n <ContextMenu key={`${item.index}-${item.hex}`}>\n <ContextMenu.Trigger>\n <button\n type=\"button\"\n role=\"radio\"\n aria-checked={item.index === checked}\n aria-label={`#${hexDigits(saved[item.index])}${saved[item.index].a < 1 ? `, ${alphaPercent(saved[item.index].a)}% opacity` : \"\"}`}\n tabIndex={item.index === focusable ? 0 : -1}\n data-swatch={item.index}\n className={s.Swatch}\n onClick={() => onSelect(saved[item.index])}\n >\n <span className={s.SwatchFill} style={{ backgroundColor: cssColor(saved[item.index]) }} />\n </button>\n </ContextMenu.Trigger>\n <ContextMenu.Content>\n <ContextMenu.Item danger onSelect={() => remove(item.index, pagesRef.current)}>\n <RemoveTrash width={20} height={20} /> Delete\n </ContextMenu.Item>\n </ContextMenu.Content>\n </ContextMenu>\n ))}\n </div>\n ))}\n </div>\n {/* The row of the page control keeps its height with one page, so the picker does not change size. */}\n <div className={s.PageControlRow}>\n {pageCount > 1 && (\n <PageControl\n count={pageCount}\n value={Math.min(page, pageCount - 1)}\n aria-label=\"Saved color pages\"\n onChange={(index) => {\n const pagesElement = pagesRef.current\n if (!pagesElement) return\n setPage(index)\n pagesElement.scrollTo?.({ left: index * pagesElement.clientWidth, behavior: prefersReducedMotion() ? \"auto\" : \"smooth\" })\n }}\n />\n )}\n </div>\n </div>\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EACL,KAAK,EACL,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,8BAA8B,EAC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MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;4BAC3H,CAAC,GACD,CACH,GACG,IACF,IACF,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Slider as RadixSlider } from \"radix-ui\"\nimport {\n useId,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent,\n} from \"react\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { prefersReducedMotion } from \"../../lib/helpers\"\nimport { ContextMenu } from \"../ContextMenu\"\nimport { Plus, RemoveTrash } from \"../Icon\"\nimport { PageControl } from \"../PageControl\"\nimport { SegmentedControl } from \"../SegmentedControl\"\nimport {\n alphaPercent,\n channelTrack,\n COLOR_PICKER_CHANNELS,\n COLOR_PICKER_GRID_COLUMNS,\n COLOR_PICKER_MODES,\n COLOR_PICKER_SWATCHES_PER_PAGE,\n cssColor,\n formatColor,\n gridColor,\n gridIndex,\n gridMove,\n hexDigits,\n listMove,\n opacityTrack,\n parseColor,\n parseNumber,\n sameRgb,\n spectrumColor,\n spectrumPoint,\n swatchPageCount,\n type ColorPickerMode,\n type Rgba,\n type SpectrumPoint,\n} from \"./shared\"\n\nconst BLACK: Rgba = { r: 0, g: 0, b: 0, a: 1 }\nconst GRID_CELLS = COLOR_PICKER_GRID_COLUMNS * 10\nconst NAVIGATION_KEYS = [\"ArrowRight\", \"ArrowLeft\", \"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"]\n\nexport type ColorPickerProps = {\n /** The `id` of the picker. */\n id?: string\n /** The controlled color, `#rrggbb` or `#rrggbbaa`. Use with `onChange`. */\n value?: string\n /** The color when it is initially rendered. Use when you do not need to control the color. @default \"#000000\" */\n defaultValue?: string\n /** Called with the next color: `#rrggbb`, or `#rrggbbaa` when it is not opaque. */\n onChange?: (value: string) => void\n /** Shows the Opacity slider, as `supportsAlpha` of the system picker. @default true */\n supportsAlpha?: boolean\n /** The controlled way to choose a color. Use with `onModeChange`. */\n mode?: ColorPickerMode\n /** The way to choose a color when the picker is initially rendered. @default \"grid\" */\n defaultMode?: ColorPickerMode\n /** Called when another of Grid, Spectrum and Sliders is chosen. */\n onModeChange?: (mode: ColorPickerMode) => void\n /** The controlled saved colors. Use with `onSwatchesChange`. */\n swatches?: string[]\n /** The saved colors when the picker is initially rendered. @default [] */\n defaultSwatches?: string[]\n /** Called with the saved colors after Add saves the current color or Delete removes one. */\n onSwatchesChange?: (swatches: string[]) => void\n /** Accessible name of the picker. @default \"Colors\" */\n \"aria-label\"?: string\n /** CSS classes applied to the picker */\n className?: string\n}\n\ntype ColorSliderProps = {\n labelId: string\n value: number\n max: number\n track: string\n /** The knob's fill: the current color, as iOS 27.2 fills it (opaque on a channel, at its opacity on Opacity). */\n fill: string\n valueText: string\n onChange: (value: number) => void\n}\n\n/** A slider on a colored track, after the kit's Opacity slider (515:47434): a ring filled with the color on a capsule. */\nfunction ColorSlider({ labelId, value, max, track, fill, valueText, onChange }: ColorSliderProps) {\n return (\n <div className={s.Track} style={{ \"--color-picker-track\": track } as CSSProperties}>\n <RadixSlider.Root className={s.SliderRoot} min={0} max={max} step={1} value={[value]} onValueChange={([next]) => onChange(next)}>\n <RadixSlider.Track className={s.SliderTrack} />\n <RadixSlider.Thumb className={s.Knob} style={{ backgroundColor: fill }} aria-labelledby={labelId} aria-valuetext={valueText} />\n </RadixSlider.Root>\n </div>\n )\n}\n\ntype ColorFieldProps = {\n value: string\n label?: string\n labelledBy?: string\n inputMode: \"numeric\" | \"text\"\n wide?: boolean\n onCommit: (text: string) => void\n}\n\n/** The value beside a slider, after the kit's Percentage field (515:47438); typing a value and Enter or leaving it applies it. */\nfunction ColorField({ value, label, labelledBy, inputMode, wide = false, onCommit }: ColorFieldProps) {\n const [draft, setDraft] = useState<string | null>(null)\n const commit = () => {\n if (draft !== null) onCommit(draft)\n setDraft(null)\n }\n return (\n <input\n className={s.Field}\n data-wide={wide ? \"\" : undefined}\n type=\"text\"\n inputMode={inputMode}\n autoComplete=\"off\"\n spellCheck={false}\n aria-label={label}\n aria-labelledby={labelledBy}\n value={draft ?? value}\n onFocus={(event) => {\n setDraft(value)\n event.currentTarget.select()\n }}\n onChange={(event) => setDraft(event.currentTarget.value)}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\") return\n event.preventDefault()\n commit()\n }}\n />\n )\n}\n\n/**\n * The system color picker of iOS 27.2 (UIColorPickerViewController, after the iOS 26 kit's Color Picker - iPhone\n * 0:5275): Grid, Spectrum and Sliders, the Opacity slider, and the saved colors with Add. Show it inside a Popover or\n * a Sheet, or use `ColorWell`, which does.\n */\nexport function ColorPicker({\n id,\n value: valueProp,\n defaultValue,\n onChange,\n supportsAlpha = true,\n mode: modeProp,\n defaultMode = \"grid\",\n onModeChange,\n swatches: swatchesProp,\n defaultSwatches,\n onSwatchesChange,\n \"aria-label\": ariaLabel = \"Colors\",\n className,\n}: ColorPickerProps) {\n const uid = useId()\n const [internalValue, setInternalValue] = useState(() => defaultValue ?? \"#000000\")\n const value = valueProp ?? internalValue\n const color = parseColor(value) ?? BLACK\n const colorRef = useLatestValue(color)\n const options = useLatestValue({ controlled: valueProp !== undefined, supportsAlpha, onChange })\n\n const [internalMode, setInternalMode] = useState<ColorPickerMode>(defaultMode)\n const mode = modeProp ?? internalMode\n\n const [internalSwatches, setInternalSwatches] = useState(() => defaultSwatches ?? [])\n const swatches = swatchesProp ?? internalSwatches\n\n const commit = (next: Rgba) => {\n const formatted = formatColor(options.current.supportsAlpha ? next : { ...next, a: 1 })\n // Only a color other than the one shown is reported; an owner that keeps its color hears every new choice.\n if (formatted === formatColor(colorRef.current)) return\n // A controlled color changes only when the owner passes it back, as in Vue.\n if (!options.current.controlled) setInternalValue(formatted)\n options.current.onChange?.(formatted)\n }\n\n const changeMode = (next: ColorPickerMode) => {\n if (modeProp === undefined) setInternalMode(next)\n onModeChange?.(next)\n }\n\n const changeSwatches = (next: string[]) => {\n if (swatchesProp === undefined) setInternalSwatches(next)\n onSwatchesChange?.(next)\n }\n\n return (\n <div id={id} role=\"group\" aria-label={ariaLabel} className={clsx(s.ColorPicker, className)} data-mode={mode}>\n <SegmentedControl<ColorPickerMode> aria-label=\"Mode\" value={mode} onChange={changeMode} block className={s.Modes} data-mobile-size=\"small\">\n {COLOR_PICKER_MODES.map((option) => (\n <SegmentedControl.Option key={option.value} value={option.value}>{option.label}</SegmentedControl.Option>\n ))}\n </SegmentedControl>\n <div className={s.Body}>\n {mode === \"grid\" && <ColorGrid color={color} onSelect={commit} />}\n {mode === \"spectrum\" && <ColorSpectrum color={color} onSelect={commit} />}\n {mode === \"sliders\" && <ColorSliders uid={uid} color={color} onSelect={commit} />}\n </div>\n {supportsAlpha && (\n <div className={s.Opacity}>\n <span id={`${uid}-opacity`} className={s.Label}>Opacity</span>\n <div className={s.Row}>\n <ColorSlider\n labelId={`${uid}-opacity`}\n value={alphaPercent(color.a)}\n max={100}\n track={opacityTrack(color)}\n fill={cssColor(color)}\n valueText={`${alphaPercent(color.a)}%`}\n onChange={(percent) => commit({ ...colorRef.current, a: percent / 100 })}\n />\n <ColorField\n value={`${alphaPercent(color.a)}%`}\n labelledBy={`${uid}-opacity`}\n inputMode=\"numeric\"\n onCommit={(text) => {\n const percent = parseNumber(text, 0, 100)\n if (percent !== null) commit({ ...colorRef.current, a: percent / 100 })\n }}\n />\n </div>\n </div>\n )}\n <ColorSwatches color={color} swatches={swatches} onSelect={commit} onChange={changeSwatches} />\n </div>\n )\n}\n\ntype PartProps = { color: Rgba; onSelect: (color: Rgba) => void }\n\n/** The kit's Color Grid: twelve hues across, grays then nine shades down; the selected cell has a 3px white ring. */\nfunction ColorGrid({ color, onSelect }: PartProps) {\n const selected = gridIndex(color)\n const focusable = selected === -1 ? 0 : selected\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const from = Number((event.target as HTMLElement).dataset.index)\n if (!Number.isInteger(from) || !NAVIGATION_KEYS.includes(event.key)) return\n event.preventDefault()\n const next = gridMove(from, event.key)\n if (next === from) return\n const cell = event.currentTarget.querySelector<HTMLElement>(`[data-index=\"${next}\"]`)\n cell?.focus()\n onSelect({ ...(parseColor(gridColor(next)) ?? BLACK), a: color.a })\n }\n\n return (\n <div role=\"radiogroup\" aria-label=\"Grid\" className={s.Grid} onKeyDown={onKeyDown}>\n {Array.from({ length: GRID_CELLS }, (_, index) => {\n const hex = gridColor(index)\n return (\n <button\n key={hex}\n type=\"button\"\n role=\"radio\"\n aria-checked={index === selected}\n aria-label={hex.toUpperCase()}\n tabIndex={index === focusable ? 0 : -1}\n data-index={index}\n className={s.Cell}\n style={{ backgroundColor: hex }}\n onClick={() => onSelect({ ...(parseColor(hex) ?? BLACK), a: color.a })}\n />\n )\n })}\n </div>\n )\n}\n\nconst SPECTRUM_STEP = 0.01\n\n/**\n * The spectrum: hue from top to bottom, white to the full hue to black across. Up and Down change the hue, Left\n * and Right the lightness, by 1% (10% with Shift or Page Up and Page Down).\n */\nfunction ColorSpectrum({ color, onSelect }: PartProps) {\n const [held, setHeld] = useState<{ point: SpectrumPoint; digits: string }>(() => ({ point: spectrumPoint(color), digits: hexDigits(color) }))\n // The point the picker last chose stays while the color is the one it chose: a hex color loses the exact point,\n // and a gray or white has no hue of its own.\n const point = held.digits === hexDigits(color) ? held.point : spectrumPoint(color, held.point)\n\n const choose = (next: SpectrumPoint) => {\n const clamped = { x: Math.min(1, Math.max(0, next.x)), y: Math.min(1, Math.max(0, next.y)) }\n const chosen = spectrumColor(clamped, color.a)\n setHeld({ point: clamped, digits: hexDigits(chosen) })\n onSelect(chosen)\n }\n\n const fromPointer = (event: PointerEvent<HTMLDivElement>) => {\n const box = event.currentTarget.getBoundingClientRect()\n if (box.width === 0 || box.height === 0) return\n choose({ x: (event.clientX - box.left) / box.width, y: (event.clientY - box.top) / box.height })\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const step = event.shiftKey ? SPECTRUM_STEP * 10 : SPECTRUM_STEP\n const moves: Record<string, SpectrumPoint> = {\n ArrowLeft: { x: point.x - step, y: point.y },\n ArrowRight: { x: point.x + step, y: point.y },\n ArrowUp: { x: point.x, y: point.y - step },\n ArrowDown: { x: point.x, y: point.y + step },\n PageUp: { x: point.x, y: point.y - SPECTRUM_STEP * 10 },\n PageDown: { x: point.x, y: point.y + SPECTRUM_STEP * 10 },\n }\n const next = moves[event.key]\n if (!next) return\n event.preventDefault()\n choose(next)\n }\n\n const hue = Math.round(point.y * 360)\n return (\n <div\n role=\"slider\"\n tabIndex={0}\n aria-label=\"Spectrum\"\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={hue}\n aria-valuetext={`#${hexDigits(color)}, hue ${hue}°, lightness ${Math.round((1 - point.x) * 100)}%`}\n className={s.Spectrum}\n onPointerDown={(event) => {\n if (event.button !== 0) return\n event.currentTarget.setPointerCapture?.(event.pointerId)\n event.currentTarget.focus({ preventScroll: true })\n fromPointer(event)\n }}\n onPointerMove={(event) => {\n if (event.currentTarget.hasPointerCapture?.(event.pointerId)) fromPointer(event)\n }}\n onKeyDown={onKeyDown}\n >\n <span\n className={s.Loupe}\n style={{ left: `${point.x * 100}%`, top: `${point.y * 100}%`, backgroundColor: cssColor(color, 1) }}\n />\n </div>\n )\n}\n\n/** Red, Green and Blue, each a slider and a field from 0 to 255, then the Hex field. */\nfunction ColorSliders({ uid, color, onSelect }: PartProps & { uid: string }) {\n return (\n <div className={s.Sliders}>\n {COLOR_PICKER_CHANNELS.map(({ channel, label }) => {\n const labelId = `${uid}-${channel}`\n return (\n <div key={channel} className={s.Channel}>\n <span id={labelId} className={s.Label}>{label}</span>\n <div className={s.Row}>\n <ColorSlider\n labelId={labelId}\n value={color[channel]}\n max={255}\n track={channelTrack(color, channel)}\n fill={cssColor(color, 1)}\n valueText={String(color[channel])}\n onChange={(next) => onSelect({ ...color, [channel]: next })}\n />\n <ColorField\n value={String(color[channel])}\n labelledBy={labelId}\n inputMode=\"numeric\"\n onCommit={(text) => {\n const next = parseNumber(text, 0, 255)\n if (next !== null) onSelect({ ...color, [channel]: next })\n }}\n />\n </div>\n </div>\n )\n })}\n <div className={s.Hex}>\n <span id={`${uid}-hex`} className={s.HexLabel}>Hex Color #</span>\n <ColorField\n value={hexDigits(color)}\n labelledBy={`${uid}-hex`}\n inputMode=\"text\"\n wide\n onCommit={(text) => {\n const next = parseColor(text)\n if (next) onSelect({ ...next, a: color.a })\n }}\n />\n </div>\n </div>\n )\n}\n\ntype ColorSwatchesProps = PartProps & { swatches: string[]; onChange: (swatches: string[]) => void }\n\n/**\n * The current color, and the saved colors in pages of two rows of six with Add after the last (iOS 27.2; kit\n * Swatches 515:46585 had rows of five). A saved color is a radio; Delete or Backspace, or Delete in its context\n * menu, removes it.\n */\nfunction ColorSwatches({ color, swatches, onSelect, onChange }: ColorSwatchesProps) {\n const pagesRef = useRef<HTMLDivElement>(null)\n const [page, setPage] = useState(0)\n const saved = swatches.map((hex) => parseColor(hex) ?? BLACK)\n const current = formatColor(color)\n const checked = saved.findIndex((swatch) => sameRgb(swatch, color) && alphaPercent(swatch.a) === alphaPercent(color.a))\n const focusable = checked === -1 ? 0 : checked\n const pageCount = swatchPageCount(swatches.length)\n\n const reveal = (element: HTMLElement | null | undefined) => element?.scrollIntoView?.({ block: \"nearest\", inline: \"nearest\" })\n\n const remove = (index: number, pages: HTMLElement | null) => {\n onChange(swatches.filter((_, i) => i !== index))\n // Focus stays in the list: on the color that takes the place, the one before at the end, or Add.\n const target = Math.min(index, swatches.length - 2)\n requestAnimationFrame(() => {\n const next = target >= 0 ? pages?.querySelector<HTMLElement>(`[data-swatch=\"${target}\"]`) : pages?.querySelector<HTMLElement>(\"[data-add]\")\n next?.focus()\n reveal(next)\n })\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const from = Number((event.target as HTMLElement).dataset.swatch)\n if (!Number.isInteger(from)) return\n if (event.key === \"Delete\" || event.key === \"Backspace\") {\n event.preventDefault()\n remove(from, event.currentTarget)\n return\n }\n if (!NAVIGATION_KEYS.includes(event.key)) return\n event.preventDefault()\n const next = listMove(from, swatches.length, event.key)\n if (next === from) return\n const element = event.currentTarget.querySelector<HTMLElement>(`[data-swatch=\"${next}\"]`)\n element?.focus()\n reveal(element)\n onSelect(saved[next])\n }\n\n const items = [...swatches.map((hex, index) => ({ hex, index })), null]\n const pages = Array.from({ length: pageCount }, (_, p) => items.slice(p * COLOR_PICKER_SWATCHES_PER_PAGE, (p + 1) * COLOR_PICKER_SWATCHES_PER_PAGE))\n\n return (\n <div className={s.Swatches}>\n <div role=\"img\" aria-label={`Selected color #${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`} className={s.Current}>\n <span className={s.CurrentFill} style={{ backgroundColor: cssColor(color) }} />\n </div>\n <div className={s.Saved}>\n <div\n ref={pagesRef}\n role=\"radiogroup\"\n aria-label=\"Saved colors\"\n className={s.Pages}\n onKeyDown={onKeyDown}\n onScroll={(event) => {\n const { scrollLeft, clientWidth } = event.currentTarget\n if (clientWidth > 0) setPage(Math.round(scrollLeft / clientWidth))\n }}\n >\n {pages.map((pageItems, p) => (\n <div key={p} className={s.Page}>\n {pageItems.map((item) => item === null ? (\n <button\n key=\"add\"\n type=\"button\"\n data-add=\"\"\n className={s.Add}\n aria-label=\"Add color\"\n onClick={(event) => {\n onChange([...swatches, current])\n const add = event.currentTarget\n requestAnimationFrame(() => reveal(add))\n }}\n >\n <Plus />\n </button>\n ) : (\n <ContextMenu key={`${item.index}-${item.hex}`}>\n <ContextMenu.Trigger>\n <button\n type=\"button\"\n role=\"radio\"\n aria-checked={item.index === checked}\n aria-label={`#${hexDigits(saved[item.index])}${saved[item.index].a < 1 ? `, ${alphaPercent(saved[item.index].a)}% opacity` : \"\"}`}\n tabIndex={item.index === focusable ? 0 : -1}\n data-swatch={item.index}\n className={s.Swatch}\n onClick={() => onSelect(saved[item.index])}\n >\n <span className={s.SwatchFill} style={{ backgroundColor: cssColor(saved[item.index]) }} />\n </button>\n </ContextMenu.Trigger>\n <ContextMenu.Content>\n <ContextMenu.Item danger onSelect={() => remove(item.index, pagesRef.current)}>\n <RemoveTrash width={20} height={20} /> Delete\n </ContextMenu.Item>\n </ContextMenu.Content>\n </ContextMenu>\n ))}\n </div>\n ))}\n </div>\n {/* The row of the page control keeps its height with one page, so the picker does not change size. */}\n <div className={s.PageControlRow}>\n {pageCount > 1 && (\n <PageControl\n count={pageCount}\n value={Math.min(page, pageCount - 1)}\n aria-label=\"Saved color pages\"\n onChange={(index) => {\n const pagesElement = pagesRef.current\n if (!pagesElement) return\n setPage(index)\n pagesElement.scrollTo?.({ left: index * pagesElement.clientWidth, behavior: prefersReducedMotion() ? \"auto\" : \"smooth\" })\n }}\n />\n )}\n </div>\n </div>\n </div>\n )\n}\n"]}
@@ -53,6 +53,6 @@ export function ColorWell({ id, value: valueProp, defaultValue = null, onChange,
53
53
  const well = (_jsxs("button", { id: id, type: "button", className: clsx(s.Well, className), "data-size": size, "data-selected": color ? "" : undefined, disabled: disabled, "aria-label": ariaLabelledBy ? undefined : ariaLabel ?? "Color", "aria-labelledby": ariaLabelledBy, "aria-describedby": color ? valueId : undefined, style: color ? { "--color-well-color": cssColor(color) } : undefined, children: [color && _jsx("span", { className: s.WellColor }), color && _jsx("span", { id: valueId, hidden: true, children: `#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : ""}` })] }));
54
54
  const picker = (_jsx(ColorPicker, { ...pickerProps, value: formatColor(color ?? { r: 0, g: 0, b: 0, a: 1 }), onChange: choose, "aria-label": title }));
55
55
  const eyedropperButton = (glass) => supportsEyedropper && canPick && (_jsx(Button, { color: "secondary", variant: glass ? "soft" : "ghost", mobileMaterial: glass ? "glass" : undefined, size: glass ? "lg" : "sm", uniform: true, pill: true, "aria-label": "Eyedropper", onClick: () => void pick(), children: _jsx(Eyedropper, {}) }));
56
- return (_jsxs(_Fragment, { children: [name !== undefined && _jsx("input", { type: "hidden", name: name, value: value ?? "", disabled: disabled }), wide ? (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(Popover.Trigger, { children: well }), _jsxs(Popover.Content, { className: s.Popover, width: "auto", side: "bottom", align: "center", children: [_jsxs("div", { className: s.PopoverHeader, children: [_jsx("div", { className: s.PopoverLeading, children: eyedropperButton(false) }), _jsx("span", { className: s.PopoverTitle, children: title }), _jsx("div", { className: s.PopoverTrailing, children: _jsx(Button, { color: "secondary", variant: "ghost", size: "sm", uniform: true, pill: true, "aria-label": "Close", onClick: () => setOpen(false), children: _jsx(X, {}) }) })] }), picker] })] })) : (_jsxs(Dialog, { open: open, onOpenChange: setOpen, children: [_jsx(Dialog.Trigger, { children: well }), _jsxs(Dialog.Content, { mobileVariant: "sheet", showClose: false, className: s.Sheet, children: [_jsxs(Toolbar, { background: "solid", children: [_jsx(Toolbar.Leading, { children: eyedropperButton(true) }), _jsx(Toolbar.Title, { children: title }), _jsx(Toolbar.Trailing, { children: _jsx(Dialog.Close, { children: _jsx(NavigationButton, { action: "close" }) }) })] }), _jsx(Dialog.Header, { children: _jsx(Dialog.Title, { children: title }) }), _jsx(Dialog.Body, { className: s.SheetBody, children: picker })] })] }))] }));
56
+ return (_jsxs(_Fragment, { children: [name !== undefined && _jsx("input", { type: "hidden", name: name, value: value ?? "", disabled: disabled }), wide ? (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(Popover.Trigger, { children: well }), _jsxs(Popover.Content, { className: s.Popover, width: "auto", side: "bottom", align: "center", children: [_jsxs("div", { className: s.PopoverHeader, children: [_jsx("div", { className: s.PopoverLeading, children: eyedropperButton(false) }), _jsx("span", { className: s.PopoverTitle, children: title }), _jsx("div", { className: s.PopoverTrailing, children: _jsx(Button, { color: "secondary", variant: "ghost", size: "sm", uniform: true, pill: true, "aria-label": "Close", onClick: () => setOpen(false), children: _jsx(X, {}) }) })] }), picker] })] })) : (_jsxs(Dialog, { open: open, onOpenChange: setOpen, children: [_jsx(Dialog.Trigger, { children: well }), _jsxs(Dialog.Content, { mobileVariant: "sheet", surface: "grouped", showClose: false, className: s.Sheet, children: [_jsxs(Toolbar, { background: "solid", children: [_jsx(Toolbar.Leading, { children: _jsx(Dialog.Close, { children: _jsx(NavigationButton, { action: "close" }) }) }), _jsx(Toolbar.Title, { children: title }), _jsx(Toolbar.Trailing, { children: eyedropperButton(true) })] }), _jsx(Dialog.Header, { children: _jsx(Dialog.Title, { children: title }) }), _jsx(Dialog.Body, { className: s.SheetBody, children: picker })] })] }))] }));
57
57
  }
58
58
  //# sourceMappingURL=ColorWell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorWell.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/ColorWell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAA;AAC9F,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,WAAW,EAAyB,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA6BjG;;;GAGG;AACH,MAAM,UA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Z,KAAC,MAAM,CAAC,KAAK,cAAE,KAAK,GAAgB,GACtB,EAChB,KAAC,MAAM,CAAC,IAAI,IAAC,SAAS,EAAE,CAAC,CAAC,SAAS,YAAG,MAAM,GAAe,IAC5C,IACV,CACV,IACA,CACJ,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from \"react\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { useBreakpoint } from \"../../hooks/useBreakpoints\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Button, NavigationButton } from \"../Button\"\nimport { Dialog } from \"../Dialog\"\nimport { Eyedropper, X } from \"../Icon\"\nimport { Popover } from \"../Popover\"\nimport { Toolbar } from \"../Toolbar\"\nimport { ColorPicker, type ColorPickerProps } from \"./ColorPicker\"\nimport { alphaPercent, cssColor, eyeDropper, formatColor, hexDigits, parseColor } from \"./shared\"\n\nexport type ColorWellProps = Omit<ColorPickerProps, \"value\" | \"defaultValue\" | \"onChange\" | \"aria-label\" | \"className\" | \"id\"> & {\n /** The `id` of the well. */\n id?: string\n /** The controlled color, `#rrggbb` or `#rrggbbaa`; `null` shows the rainbow well with no color. Use with `onChange`. */\n value?: string | null\n /** The color when it is initially rendered. Use when you do not need to control the color. @default null */\n defaultValue?: string | null\n /** Called with the color the picker chose. */\n onChange?: (value: string) => void\n /** The title of the picker. @default \"Colors\" */\n title?: string\n /** Shows the eyedropper in the picker where the browser can pick a color from the screen (EyeDropper API). @default true */\n supportsEyedropper?: boolean\n /** The kit's Picker Button sizes: `sm` 28px, `lg` 36px. @default \"sm\" */\n size?: \"sm\" | \"lg\"\n /** When `true`, prevents the user from opening the picker. */\n disabled?: boolean\n /** The name of the well. Submits its color with the owning form. */\n name?: string\n /** Accessible name of the well. @default \"Color\" */\n \"aria-label\"?: string\n /** The `id` of the visible label of the well. */\n \"aria-labelledby\"?: string\n /** CSS classes applied to the well */\n className?: string\n}\n\n/**\n * A color well, as `UIColorWell`: the kit's Picker Button (5739:34128), a rainbow ring around the chosen color. It\n * opens the color picker, in a Popover from the well, and on a phone in a sheet, as the system picker.\n */\nexport function ColorWell({\n id,\n value: valueProp,\n defaultValue = null,\n onChange,\n title = \"Colors\",\n supportsEyedropper = true,\n size = \"sm\",\n disabled = false,\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n ...pickerProps\n}: ColorWellProps) {\n const wide = useBreakpoint(\"md\")\n const valueId = `${useId()}-value`\n const [open, setOpen] = useState(false)\n const [internalValue, setInternalValue] = useState<string | null>(defaultValue)\n const value = valueProp === undefined ? internalValue : valueProp\n const color = parseColor(value)\n const options = useLatestValue({ controlled: valueProp !== undefined, onChange })\n // The EyeDropper API exists only in a browser, so the button appears after hydration.\n const [canPick, setCanPick] = useState(false)\n useEffect(() => setCanPick(eyeDropper() !== null), [])\n const picking = useRef(false)\n\n const choose = (next: string) => {\n if (!options.current.controlled) setInternalValue(next)\n options.current.onChange?.(next)\n }\n\n const pick = async () => {\n const EyeDropper = eyeDropper()\n if (!EyeDropper || picking.current) return\n picking.current = true\n try {\n const picked = parseColor((await new EyeDropper().open()).sRGBHex)\n if (picked) choose(formatColor({ ...picked, a: color?.a ?? 1 }))\n } catch {\n // Escape, or a click the browser did not hand to the page, cancels the pick.\n } finally {\n picking.current = false\n }\n }\n\n const well = (\n <button\n id={id}\n type=\"button\"\n className={clsx(s.Well, className)}\n data-size={size}\n data-selected={color ? \"\" : undefined}\n disabled={disabled}\n aria-label={ariaLabelledBy ? undefined : ariaLabel ?? \"Color\"}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={color ? valueId : undefined}\n style={color ? { \"--color-well-color\": cssColor(color) } as CSSProperties : undefined}\n >\n {color && <span className={s.WellColor} />}\n {/* The color, read as the well's description. */}\n {color && <span id={valueId} hidden>{`#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`}</span>}\n </button>\n )\n\n const picker = (\n <ColorPicker {...pickerProps} value={formatColor(color ?? { r: 0, g: 0, b: 0, a: 1 })} onChange={choose} aria-label={title} />\n )\n const eyedropperButton = (glass: boolean): ReactNode => supportsEyedropper && canPick && (\n <Button\n color=\"secondary\"\n variant={glass ? \"soft\" : \"ghost\"}\n mobileMaterial={glass ? \"glass\" : undefined}\n size={glass ? \"lg\" : \"sm\"}\n uniform\n pill\n aria-label=\"Eyedropper\"\n onClick={() => void pick()}\n >\n <Eyedropper />\n </Button>\n )\n\n return (\n <>\n {name !== undefined && <input type=\"hidden\" name={name} value={value ?? \"\"} disabled={disabled} />}\n {wide ? (\n <Popover open={open} onOpenChange={setOpen}>\n <Popover.Trigger>{well}</Popover.Trigger>\n <Popover.Content className={s.Popover} width=\"auto\" side=\"bottom\" align=\"center\">\n <div className={s.PopoverHeader}>\n <div className={s.PopoverLeading}>{eyedropperButton(false)}</div>\n <span className={s.PopoverTitle}>{title}</span>\n <div className={s.PopoverTrailing}>\n <Button color=\"secondary\" variant=\"ghost\" size=\"sm\" uniform pill aria-label=\"Close\" onClick={() => setOpen(false)}>\n <X />\n </Button>\n </div>\n </div>\n {picker}\n </Popover.Content>\n </Popover>\n ) : (\n <Dialog open={open} onOpenChange={setOpen}>\n <Dialog.Trigger>{well}</Dialog.Trigger>\n <Dialog.Content mobileVariant=\"sheet\" showClose={false} className={s.Sheet}>\n <Toolbar background=\"solid\">\n <Toolbar.Leading>{eyedropperButton(true)}</Toolbar.Leading>\n <Toolbar.Title>{title}</Toolbar.Title>\n <Toolbar.Trailing>\n <Dialog.Close>\n <NavigationButton action=\"close\" />\n </Dialog.Close>\n </Toolbar.Trailing>\n </Toolbar>\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n </Dialog.Header>\n <Dialog.Body className={s.SheetBody}>{picker}</Dialog.Body>\n </Dialog.Content>\n </Dialog>\n )}\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"ColorWell.js","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AM,IAAC,KAAK,EAAC,WAAW,EAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,QAAC,IAAI,sBAAY,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,YAC/G,KAAC,CAAC,KAAG,GACE,GACL,IACF,EACL,MAAM,IACS,IACV,CACX,CAAC,CAAC,CAAC,CACF,MAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,aACvC,KAAC,MAAM,CAAC,OAAO,cAAE,IAAI,GAAkB,EACvC,MAAC,MAAM,CAAC,OAAO,IAAC,aAAa,EAAC,OAAO,EAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,aAG1F,MAAC,OAAO,IAAC,UAAU,EAAC,OAAO,aACzB,KAAC,OAAO,CAAC,OAAO,cACd,KAAC,MAAM,CAAC,KAAK,cACX,KAAC,gBAAgB,IAAC,MAAM,EAAC,OAAO,GAAG,GACtB,GACC,EAClB,KAAC,OAAO,CAAC,KAAK,cAAE,KAAK,GAAiB,EACtC,KAAC,OAAO,CAAC,QAAQ,cAAE,gBAAgB,CAAC,IAAI,CAAC,GAAoB,IACrD,EACV,KAAC,MAAM,CAAC,MAAM,cACZ,KAAC,MAAM,CAAC,KAAK,cAAE,KAAK,GAAgB,GACtB,EAChB,KAAC,MAAM,CAAC,IAAI,IAAC,SAAS,EAAE,CAAC,CAAC,SAAS,YAAG,MAAM,GAAe,IAC5C,IACV,CACV,IACA,CACJ,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from \"react\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { useBreakpoint } from \"../../hooks/useBreakpoints\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Button, NavigationButton } from \"../Button\"\nimport { Dialog } from \"../Dialog\"\nimport { Eyedropper, X } from \"../Icon\"\nimport { Popover } from \"../Popover\"\nimport { Toolbar } from \"../Toolbar\"\nimport { ColorPicker, type ColorPickerProps } from \"./ColorPicker\"\nimport { alphaPercent, cssColor, eyeDropper, formatColor, hexDigits, parseColor } from \"./shared\"\n\nexport type ColorWellProps = Omit<ColorPickerProps, \"value\" | \"defaultValue\" | \"onChange\" | \"aria-label\" | \"className\" | \"id\"> & {\n /** The `id` of the well. */\n id?: string\n /** The controlled color, `#rrggbb` or `#rrggbbaa`; `null` shows the rainbow well with no color. Use with `onChange`. */\n value?: string | null\n /** The color when it is initially rendered. Use when you do not need to control the color. @default null */\n defaultValue?: string | null\n /** Called with the color the picker chose. */\n onChange?: (value: string) => void\n /** The title of the picker. @default \"Colors\" */\n title?: string\n /** Shows the eyedropper in the picker where the browser can pick a color from the screen (EyeDropper API). @default true */\n supportsEyedropper?: boolean\n /** The kit's Picker Button sizes: `sm` 28px, `lg` 36px. @default \"sm\" */\n size?: \"sm\" | \"lg\"\n /** When `true`, prevents the user from opening the picker. */\n disabled?: boolean\n /** The name of the well. Submits its color with the owning form. */\n name?: string\n /** Accessible name of the well. @default \"Color\" */\n \"aria-label\"?: string\n /** The `id` of the visible label of the well. */\n \"aria-labelledby\"?: string\n /** CSS classes applied to the well */\n className?: string\n}\n\n/**\n * A color well, as `UIColorWell`: the kit's Picker Button (5739:34128), a rainbow ring around the chosen color. It\n * opens the color picker, in a Popover from the well, and on a phone in a sheet, as the system picker.\n */\nexport function ColorWell({\n id,\n value: valueProp,\n defaultValue = null,\n onChange,\n title = \"Colors\",\n supportsEyedropper = true,\n size = \"sm\",\n disabled = false,\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n ...pickerProps\n}: ColorWellProps) {\n const wide = useBreakpoint(\"md\")\n const valueId = `${useId()}-value`\n const [open, setOpen] = useState(false)\n const [internalValue, setInternalValue] = useState<string | null>(defaultValue)\n const value = valueProp === undefined ? internalValue : valueProp\n const color = parseColor(value)\n const options = useLatestValue({ controlled: valueProp !== undefined, onChange })\n // The EyeDropper API exists only in a browser, so the button appears after hydration.\n const [canPick, setCanPick] = useState(false)\n useEffect(() => setCanPick(eyeDropper() !== null), [])\n const picking = useRef(false)\n\n const choose = (next: string) => {\n if (!options.current.controlled) setInternalValue(next)\n options.current.onChange?.(next)\n }\n\n const pick = async () => {\n const EyeDropper = eyeDropper()\n if (!EyeDropper || picking.current) return\n picking.current = true\n try {\n const picked = parseColor((await new EyeDropper().open()).sRGBHex)\n if (picked) choose(formatColor({ ...picked, a: color?.a ?? 1 }))\n } catch {\n // Escape, or a click the browser did not hand to the page, cancels the pick.\n } finally {\n picking.current = false\n }\n }\n\n const well = (\n <button\n id={id}\n type=\"button\"\n className={clsx(s.Well, className)}\n data-size={size}\n data-selected={color ? \"\" : undefined}\n disabled={disabled}\n aria-label={ariaLabelledBy ? undefined : ariaLabel ?? \"Color\"}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={color ? valueId : undefined}\n style={color ? { \"--color-well-color\": cssColor(color) } as CSSProperties : undefined}\n >\n {color && <span className={s.WellColor} />}\n {/* The color, read as the well's description. */}\n {color && <span id={valueId} hidden>{`#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`}</span>}\n </button>\n )\n\n const picker = (\n <ColorPicker {...pickerProps} value={formatColor(color ?? { r: 0, g: 0, b: 0, a: 1 })} onChange={choose} aria-label={title} />\n )\n const eyedropperButton = (glass: boolean): ReactNode => supportsEyedropper && canPick && (\n <Button\n color=\"secondary\"\n variant={glass ? \"soft\" : \"ghost\"}\n mobileMaterial={glass ? \"glass\" : undefined}\n size={glass ? \"lg\" : \"sm\"}\n uniform\n pill\n aria-label=\"Eyedropper\"\n onClick={() => void pick()}\n >\n <Eyedropper />\n </Button>\n )\n\n return (\n <>\n {name !== undefined && <input type=\"hidden\" name={name} value={value ?? \"\"} disabled={disabled} />}\n {wide ? (\n <Popover open={open} onOpenChange={setOpen}>\n <Popover.Trigger>{well}</Popover.Trigger>\n <Popover.Content className={s.Popover} width=\"auto\" side=\"bottom\" align=\"center\">\n <div className={s.PopoverHeader}>\n <div className={s.PopoverLeading}>{eyedropperButton(false)}</div>\n <span className={s.PopoverTitle}>{title}</span>\n <div className={s.PopoverTrailing}>\n <Button color=\"secondary\" variant=\"ghost\" size=\"sm\" uniform pill aria-label=\"Close\" onClick={() => setOpen(false)}>\n <X />\n </Button>\n </div>\n </div>\n {picker}\n </Popover.Content>\n </Popover>\n ) : (\n <Dialog open={open} onOpenChange={setOpen}>\n <Dialog.Trigger>{well}</Dialog.Trigger>\n <Dialog.Content mobileVariant=\"sheet\" surface=\"grouped\" showClose={false} className={s.Sheet}>\n {/* iOS 27.2 sets Close first and the eyedropper last (UIColorPickerViewController on an iPhone 17); the\n iOS 26 kit had them the other way round. */}\n <Toolbar background=\"solid\">\n <Toolbar.Leading>\n <Dialog.Close>\n <NavigationButton action=\"close\" />\n </Dialog.Close>\n </Toolbar.Leading>\n <Toolbar.Title>{title}</Toolbar.Title>\n <Toolbar.Trailing>{eyedropperButton(true)}</Toolbar.Trailing>\n </Toolbar>\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n </Dialog.Header>\n <Dialog.Body className={s.SheetBody}>{picker}</Dialog.Body>\n </Dialog.Content>\n </Dialog>\n )}\n </>\n )\n}\n"]}
@@ -18,9 +18,10 @@ export const COLOR_PICKER_GRID = [
18
18
  ];
19
19
  export const COLOR_PICKER_GRID_COLUMNS = 12;
20
20
  const GRID = COLOR_PICKER_GRID.flat();
21
- /** Saved colors fill pages of two rows of five, with the Add button after the last one (kit Swatches 515:52724). */
22
- export const COLOR_PICKER_SWATCHES_PER_PAGE = 10;
23
- export const COLOR_PICKER_SWATCHES_PER_ROW = 5;
21
+ /** Saved colors fill pages of two rows of six, with the Add button after the last one, as iOS 27.2's picker lays them
22
+ * out (UIColorPickerViewController on an iPhone 17; the iOS 26 kit's Swatches 515:52724 had rows of five). */
23
+ export const COLOR_PICKER_SWATCHES_PER_PAGE = 12;
24
+ export const COLOR_PICKER_SWATCHES_PER_ROW = 6;
24
25
  const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
25
26
  const byte = (value) => clamp(Math.round(value), 0, 255);
26
27
  /** Reads `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, in either case; anything else is `null`. */
@@ -79,7 +80,7 @@ export function listMove(index, count, key) {
79
80
  };
80
81
  return next[key] ?? index;
81
82
  }
82
- /** Pages of saved colors: the colors and the Add button after them, ten to a page. */
83
+ /** Pages of saved colors: the colors and the Add button after them, twelve to a page. */
83
84
  export const swatchPageCount = (count) => Math.max(1, Math.ceil((count + 1) / COLOR_PICKER_SWATCHES_PER_PAGE));
84
85
  function rgbToHsl({ r, g, b }) {
85
86
  const [red, green, blue] = [r / 255, g / 255, b / 255];
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/shared.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,kBAAkB,GAAyD;IACtF,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;CACvC,CAAA;AAED,+GAA+G;AAC/G,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IACpI,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAA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KAAK,EAAE,CAAC,CAAC,OAAO,CAAA;AAI9H,MAAM,CAAC,MAAM,qBAAqB,GAAwD;IACxF,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;IAC9B,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;IAChC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE;CAChC,CAAA;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAW,EAAE,OAAqB,EAAE,EAAE,CACjE,6BAA6B,QAAQ,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAA;AAEvH,6FAA6F;AAC7F,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,GAAW,EAAE,GAAW;IAChE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC7E,CAAC;AAKD,MAAM,UAAU,UAAU;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IAC9C,OAAQ,MAA0D,CAAC,UAAU,IAAI,IAAI,CAAA;AACvF,CAAC","sourcesContent":["/** A color as the picker holds it: channels 0 to 255 and an alpha from 0 to 1. */\nexport type Rgba = { r: number; g: number; b: number; a: number }\n\n/** The three ways to choose a color, as the segments of the system picker. */\nexport type ColorPickerMode = \"grid\" | \"spectrum\" | \"sliders\"\n\nexport const COLOR_PICKER_MODES: readonly { value: ColorPickerMode; label: string }[] = [\n { value: \"grid\", label: \"Grid\" },\n { value: \"spectrum\", label: \"Spectrum\" },\n { value: \"sliders\", label: \"Sliders\" },\n]\n\n/** The kit's Color Grid (515:48178): a row of grays, then nine rows from dark to light, twelve hues across. */\nexport const COLOR_PICKER_GRID: readonly (readonly string[])[] = [\n [\"#fefffe\", \"#ebebeb\", \"#d6d6d6\", \"#c2c2c2\", \"#adadad\", \"#999999\", \"#858585\", \"#707070\", \"#5c5c5c\", \"#474747\", \"#333333\", \"#000000\"],\n [\"#00374a\", \"#011d57\", \"#11053b\", \"#2e063d\", \"#3c071b\", \"#5c0701\", \"#5a1c00\", \"#583300\", \"#563d00\", \"#666100\", \"#4f5504\", \"#263e0f\"],\n [\"#004d65\", \"#012f7b\", \"#1a0a52\", \"#450d59\", \"#551029\", \"#831100\", \"#7b2900\", \"#7a4a00\", \"#785800\", \"#8d8602\", \"#6f760a\", \"#38571a\"],\n [\"#016e8f\", \"#0042a9\", \"#2c0977\", \"#61187c\", \"#791a3d\", \"#b51a00\", \"#ad3e00\", \"#a96800\", \"#a67b01\", \"#c4bc00\", \"#9ba50e\", \"#4e7a27\"],\n [\"#008cb4\", \"#0056d6\", \"#371a94\", \"#7a219e\", \"#99244f\", \"#e22400\", \"#da5100\", \"#d38301\", \"#d19d01\", \"#f5ec00\", \"#c3d117\", \"#669d34\"],\n [\"#00a1d8\", \"#0061fd\", \"#4d22b2\", \"#982abc\", \"#b92d5d\", \"#ff4015\", \"#ff6a00\", \"#ffab01\", \"#fcc700\", \"#fefb41\", \"#d9ec37\", \"#76bb40\"],\n [\"#01c7fc\", \"#3a87fd\", \"#5e30eb\", \"#be38f3\", \"#e63b7a\", \"#fe6250\", \"#fe8648\", \"#feb43f\", \"#fecb3e\", \"#fff76b\", \"#e4ef65\", \"#96d35f\"],\n [\"#52d6fc\", \"#74a7ff\", \"#864ffd\", \"#d357fe\", \"#ee719e\", \"#ff8c82\", \"#fea57d\", \"#fec777\", \"#fed977\", \"#fff994\", \"#eaf28f\", \"#b1dd8b\"],\n [\"#93e3fc\", \"#a7c6ff\", \"#b18cfe\", \"#e292fe\", \"#f4a4c0\", \"#ffb5af\", \"#ffc5ab\", \"#fed9a8\", \"#fde4a8\", \"#fffbb9\", \"#f1f7b7\", \"#cde8b5\"],\n [\"#cbf0ff\", \"#d2e2fe\", \"#d8c9fe\", \"#efcafe\", \"#f9d3e0\", \"#ffdad8\", \"#ffe2d6\", \"#feecd4\", \"#fef1d5\", \"#fdfbdd\", \"#f6fadb\", \"#deeed4\"],\n]\n\nexport const COLOR_PICKER_GRID_COLUMNS = 12\nconst GRID = COLOR_PICKER_GRID.flat()\n\n/** Saved colors fill pages of two rows of five, with the Add button after the last one (kit Swatches 515:52724). */\nexport const COLOR_PICKER_SWATCHES_PER_PAGE = 10\nexport const COLOR_PICKER_SWATCHES_PER_ROW = 5\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value))\nconst byte = (value: number) => clamp(Math.round(value), 0, 255)\n\n/** Reads `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, in either case; anything else is `null`. */\nexport function parseColor(input: string | null | undefined): Rgba | null {\n const match = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec((input ?? \"\").trim())\n if (!match) return null\n let hex = match[1]\n if (hex.length <= 4) hex = [...hex].map((digit) => digit + digit).join(\"\")\n const channel = (index: number) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16)\n return { r: channel(0), g: channel(1), b: channel(2), a: hex.length === 8 ? channel(3) / 255 : 1 }\n}\n\nconst two = (value: number) => byte(value).toString(16).padStart(2, \"0\")\n\n/** `#rrggbb`, or `#rrggbbaa` when the color is not opaque. */\nexport function formatColor({ r, g, b, a }: Rgba): string {\n const opaque = Math.round(clamp(a, 0, 1) * 255) === 255\n return `#${two(r)}${two(g)}${two(b)}${opaque ? \"\" : two(clamp(a, 0, 1) * 255)}`\n}\n\n/** The six digits the Hex field shows, as the system picker does: upper case, no `#`. */\nexport const hexDigits = ({ r, g, b }: Rgba) => `${two(r)}${two(g)}${two(b)}`.toUpperCase()\n\n/** A CSS color for a fill. */\nexport const cssColor = ({ r, g, b, a }: Rgba, alpha = a) => `rgb(${byte(r)} ${byte(g)} ${byte(b)} / ${Math.round(clamp(alpha, 0, 1) * 1000) / 10}%)`\n\nexport const sameRgb = (one: Rgba, other: Rgba) => byte(one.r) === byte(other.r) && byte(one.g) === byte(other.g) && byte(one.b) === byte(other.b)\n\n/** Whole percent of opacity, as the Opacity field shows it. */\nexport const alphaPercent = (a: number) => Math.round(clamp(a, 0, 1) * 100)\n\n/** The grid cell of a color, or -1 when the grid has no such color. */\nexport const gridIndex = (color: Rgba) => GRID.findIndex((hex) => {\n const cell = parseColor(hex)\n return cell !== null && sameRgb(cell, color)\n})\n\nexport const gridColor = (index: number) => GRID[index]\n\n/** The cell an arrow key, Home or End moves to from `index`, or `index` itself at an edge. */\nexport function gridMove(index: number, key: string): number {\n const columns = COLOR_PICKER_GRID_COLUMNS\n const column = index % columns\n const next: Record<string, number> = {\n ArrowRight: column < columns - 1 ? index + 1 : index,\n ArrowLeft: column > 0 ? index - 1 : index,\n ArrowDown: index + columns < GRID.length ? index + columns : index,\n ArrowUp: index - columns >= 0 ? index - columns : index,\n Home: index - column,\n End: index - column + columns - 1,\n }\n return next[key] ?? index\n}\n\n/** The item a key moves to in a list of `count` items (saved colors), or `index` itself. */\nexport function listMove(index: number, count: number, key: string): number {\n const next: Record<string, number> = {\n ArrowRight: Math.min(count - 1, index + 1),\n ArrowDown: Math.min(count - 1, index + 1),\n ArrowLeft: Math.max(0, index - 1),\n ArrowUp: Math.max(0, index - 1),\n Home: 0,\n End: count - 1,\n }\n return next[key] ?? index\n}\n\n/** Pages of saved colors: the colors and the Add button after them, ten to a page. */\nexport const swatchPageCount = (count: number) => Math.max(1, Math.ceil((count + 1) / COLOR_PICKER_SWATCHES_PER_PAGE))\n\nfunction rgbToHsl({ r, g, b }: Rgba) {\n const [red, green, blue] = [r / 255, g / 255, b / 255]\n const max = Math.max(red, green, blue)\n const min = Math.min(red, green, blue)\n const lightness = (max + min) / 2\n const delta = max - min\n if (delta === 0) return { h: null, s: 0, l: lightness }\n const saturation = delta / (1 - Math.abs(2 * lightness - 1))\n const sector = max === red ? ((green - blue) / delta + 6) % 6 : max === green ? (blue - red) / delta + 2 : (red - green) / delta + 4\n return { h: sector * 60, s: saturation, l: lightness }\n}\n\nfunction hslToRgb(hue: number, saturation: number, lightness: number) {\n const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation\n const sector = (((hue % 360) + 360) % 360) / 60\n const second = chroma * (1 - Math.abs((sector % 2) - 1))\n const [red, green, blue] =\n sector < 1 ? [chroma, second, 0] : sector < 2 ? [second, chroma, 0] : sector < 3 ? [0, chroma, second]\n : sector < 4 ? [0, second, chroma] : sector < 5 ? [second, 0, chroma] : [chroma, 0, second]\n const match = lightness - chroma / 2\n return { r: byte((red + match) * 255), g: byte((green + match) * 255), b: byte((blue + match) * 255) }\n}\n\n/**\n * A point of the spectrum: hue from top to bottom, and from white at the leading edge through the full hue at the\n * middle to black at the trailing edge, as the system picker draws it (UIColorPickerViewController overview image).\n */\nexport type SpectrumPoint = { x: number; y: number }\n\nexport function spectrumColor({ x, y }: SpectrumPoint, alpha: number): Rgba {\n return { ...hslToRgb(clamp(y, 0, 1) * 360, 1, 1 - clamp(x, 0, 1)), a: alpha }\n}\n\n/** Where a color sits on the spectrum; a gray keeps the hue of `previous`, as it has none. */\nexport function spectrumPoint(color: Rgba, previous?: SpectrumPoint): SpectrumPoint {\n const { h, l } = rgbToHsl(color)\n return { x: 1 - l, y: h === null ? previous?.y ?? 0 : h / 360 }\n}\n\n/** The track of the Opacity slider: the color from clear to opaque over the kit's 12% to 88% (515:47434). */\nexport const opacityTrack = (color: Rgba) => `linear-gradient(to right, ${cssColor(color, 0)} 12%, ${cssColor(color, 1)} 88%)`\n\nexport type ColorChannel = \"r\" | \"g\" | \"b\"\n\nexport const COLOR_PICKER_CHANNELS: readonly { channel: ColorChannel; label: string }[] = [\n { channel: \"r\", label: \"Red\" },\n { channel: \"g\", label: \"Green\" },\n { channel: \"b\", label: \"Blue\" },\n]\n\n/** The track of a channel slider: the color with that channel from 0 to 255. */\nexport const channelTrack = (color: Rgba, channel: ColorChannel) =>\n `linear-gradient(to right, ${cssColor({ ...color, [channel]: 0 }, 1)}, ${cssColor({ ...color, [channel]: 255 }, 1)})`\n\n/** A number typed in a field, kept within `min` and `max`; text with no number is `null`. */\nexport function parseNumber(text: string, min: number, max: number): number | null {\n const number = Number.parseFloat(text.replace(/[%\\s]/g, \"\"))\n return Number.isFinite(number) ? clamp(Math.round(number), min, max) : null\n}\n\n/** The EyeDropper API (Chromium), when the browser has it. */\ntype EyeDropperConstructor = new () => { open: () => Promise<{ sRGBHex: string }> }\n\nexport function eyeDropper(): EyeDropperConstructor | null {\n if (typeof window === \"undefined\") return null\n return (window as Window & { EyeDropper?: EyeDropperConstructor }).EyeDropper ?? null\n}\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/shared.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,kBAAkB,GAAyD;IACtF,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;CACvC,CAAA;AAED,+GAA+G;AAC/G,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IACpI,C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picker holds it: channels 0 to 255 and an alpha from 0 to 1. */\nexport type Rgba = { r: number; g: number; b: number; a: number }\n\n/** The three ways to choose a color, as the segments of the system picker. */\nexport type ColorPickerMode = \"grid\" | \"spectrum\" | \"sliders\"\n\nexport const COLOR_PICKER_MODES: readonly { value: ColorPickerMode; label: string }[] = [\n { value: \"grid\", label: \"Grid\" },\n { value: \"spectrum\", label: \"Spectrum\" },\n { value: \"sliders\", label: \"Sliders\" },\n]\n\n/** The kit's Color Grid (515:48178): a row of grays, then nine rows from dark to light, twelve hues across. */\nexport const COLOR_PICKER_GRID: readonly (readonly string[])[] = [\n [\"#fefffe\", \"#ebebeb\", \"#d6d6d6\", \"#c2c2c2\", \"#adadad\", \"#999999\", \"#858585\", \"#707070\", \"#5c5c5c\", \"#474747\", \"#333333\", \"#000000\"],\n [\"#00374a\", \"#011d57\", \"#11053b\", \"#2e063d\", \"#3c071b\", \"#5c0701\", \"#5a1c00\", \"#583300\", \"#563d00\", \"#666100\", \"#4f5504\", \"#263e0f\"],\n [\"#004d65\", \"#012f7b\", \"#1a0a52\", \"#450d59\", \"#551029\", \"#831100\", \"#7b2900\", \"#7a4a00\", \"#785800\", \"#8d8602\", \"#6f760a\", \"#38571a\"],\n [\"#016e8f\", \"#0042a9\", \"#2c0977\", \"#61187c\", \"#791a3d\", \"#b51a00\", \"#ad3e00\", \"#a96800\", \"#a67b01\", \"#c4bc00\", \"#9ba50e\", \"#4e7a27\"],\n [\"#008cb4\", \"#0056d6\", \"#371a94\", \"#7a219e\", \"#99244f\", \"#e22400\", \"#da5100\", \"#d38301\", \"#d19d01\", \"#f5ec00\", \"#c3d117\", \"#669d34\"],\n [\"#00a1d8\", \"#0061fd\", \"#4d22b2\", \"#982abc\", \"#b92d5d\", \"#ff4015\", \"#ff6a00\", \"#ffab01\", \"#fcc700\", \"#fefb41\", \"#d9ec37\", \"#76bb40\"],\n [\"#01c7fc\", \"#3a87fd\", \"#5e30eb\", \"#be38f3\", \"#e63b7a\", \"#fe6250\", \"#fe8648\", \"#feb43f\", \"#fecb3e\", \"#fff76b\", \"#e4ef65\", \"#96d35f\"],\n [\"#52d6fc\", \"#74a7ff\", \"#864ffd\", \"#d357fe\", \"#ee719e\", \"#ff8c82\", \"#fea57d\", \"#fec777\", \"#fed977\", \"#fff994\", \"#eaf28f\", \"#b1dd8b\"],\n [\"#93e3fc\", \"#a7c6ff\", \"#b18cfe\", \"#e292fe\", \"#f4a4c0\", \"#ffb5af\", \"#ffc5ab\", \"#fed9a8\", \"#fde4a8\", \"#fffbb9\", \"#f1f7b7\", \"#cde8b5\"],\n [\"#cbf0ff\", \"#d2e2fe\", \"#d8c9fe\", \"#efcafe\", \"#f9d3e0\", \"#ffdad8\", \"#ffe2d6\", \"#feecd4\", \"#fef1d5\", \"#fdfbdd\", \"#f6fadb\", \"#deeed4\"],\n]\n\nexport const COLOR_PICKER_GRID_COLUMNS = 12\nconst GRID = COLOR_PICKER_GRID.flat()\n\n/** Saved colors fill pages of two rows of six, with the Add button after the last one, as iOS 27.2's picker lays them\n * out (UIColorPickerViewController on an iPhone 17; the iOS 26 kit's Swatches 515:52724 had rows of five). */\nexport const COLOR_PICKER_SWATCHES_PER_PAGE = 12\nexport const COLOR_PICKER_SWATCHES_PER_ROW = 6\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value))\nconst byte = (value: number) => clamp(Math.round(value), 0, 255)\n\n/** Reads `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, in either case; anything else is `null`. */\nexport function parseColor(input: string | null | undefined): Rgba | null {\n const match = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec((input ?? \"\").trim())\n if (!match) return null\n let hex = match[1]\n if (hex.length <= 4) hex = [...hex].map((digit) => digit + digit).join(\"\")\n const channel = (index: number) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16)\n return { r: channel(0), g: channel(1), b: channel(2), a: hex.length === 8 ? channel(3) / 255 : 1 }\n}\n\nconst two = (value: number) => byte(value).toString(16).padStart(2, \"0\")\n\n/** `#rrggbb`, or `#rrggbbaa` when the color is not opaque. */\nexport function formatColor({ r, g, b, a }: Rgba): string {\n const opaque = Math.round(clamp(a, 0, 1) * 255) === 255\n return `#${two(r)}${two(g)}${two(b)}${opaque ? \"\" : two(clamp(a, 0, 1) * 255)}`\n}\n\n/** The six digits the Hex field shows, as the system picker does: upper case, no `#`. */\nexport const hexDigits = ({ r, g, b }: Rgba) => `${two(r)}${two(g)}${two(b)}`.toUpperCase()\n\n/** A CSS color for a fill. */\nexport const cssColor = ({ r, g, b, a }: Rgba, alpha = a) => `rgb(${byte(r)} ${byte(g)} ${byte(b)} / ${Math.round(clamp(alpha, 0, 1) * 1000) / 10}%)`\n\nexport const sameRgb = (one: Rgba, other: Rgba) => byte(one.r) === byte(other.r) && byte(one.g) === byte(other.g) && byte(one.b) === byte(other.b)\n\n/** Whole percent of opacity, as the Opacity field shows it. */\nexport const alphaPercent = (a: number) => Math.round(clamp(a, 0, 1) * 100)\n\n/** The grid cell of a color, or -1 when the grid has no such color. */\nexport const gridIndex = (color: Rgba) => GRID.findIndex((hex) => {\n const cell = parseColor(hex)\n return cell !== null && sameRgb(cell, color)\n})\n\nexport const gridColor = (index: number) => GRID[index]\n\n/** The cell an arrow key, Home or End moves to from `index`, or `index` itself at an edge. */\nexport function gridMove(index: number, key: string): number {\n const columns = COLOR_PICKER_GRID_COLUMNS\n const column = index % columns\n const next: Record<string, number> = {\n ArrowRight: column < columns - 1 ? index + 1 : index,\n ArrowLeft: column > 0 ? index - 1 : index,\n ArrowDown: index + columns < GRID.length ? index + columns : index,\n ArrowUp: index - columns >= 0 ? index - columns : index,\n Home: index - column,\n End: index - column + columns - 1,\n }\n return next[key] ?? index\n}\n\n/** The item a key moves to in a list of `count` items (saved colors), or `index` itself. */\nexport function listMove(index: number, count: number, key: string): number {\n const next: Record<string, number> = {\n ArrowRight: Math.min(count - 1, index + 1),\n ArrowDown: Math.min(count - 1, index + 1),\n ArrowLeft: Math.max(0, index - 1),\n ArrowUp: Math.max(0, index - 1),\n Home: 0,\n End: count - 1,\n }\n return next[key] ?? index\n}\n\n/** Pages of saved colors: the colors and the Add button after them, twelve to a page. */\nexport const swatchPageCount = (count: number) => Math.max(1, Math.ceil((count + 1) / COLOR_PICKER_SWATCHES_PER_PAGE))\n\nfunction rgbToHsl({ r, g, b }: Rgba) {\n const [red, green, blue] = [r / 255, g / 255, b / 255]\n const max = Math.max(red, green, blue)\n const min = Math.min(red, green, blue)\n const lightness = (max + min) / 2\n const delta = max - min\n if (delta === 0) return { h: null, s: 0, l: lightness }\n const saturation = delta / (1 - Math.abs(2 * lightness - 1))\n const sector = max === red ? ((green - blue) / delta + 6) % 6 : max === green ? (blue - red) / delta + 2 : (red - green) / delta + 4\n return { h: sector * 60, s: saturation, l: lightness }\n}\n\nfunction hslToRgb(hue: number, saturation: number, lightness: number) {\n const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation\n const sector = (((hue % 360) + 360) % 360) / 60\n const second = chroma * (1 - Math.abs((sector % 2) - 1))\n const [red, green, blue] =\n sector < 1 ? [chroma, second, 0] : sector < 2 ? [second, chroma, 0] : sector < 3 ? [0, chroma, second]\n : sector < 4 ? [0, second, chroma] : sector < 5 ? [second, 0, chroma] : [chroma, 0, second]\n const match = lightness - chroma / 2\n return { r: byte((red + match) * 255), g: byte((green + match) * 255), b: byte((blue + match) * 255) }\n}\n\n/**\n * A point of the spectrum: hue from top to bottom, and from white at the leading edge through the full hue at the\n * middle to black at the trailing edge, as the system picker draws it (UIColorPickerViewController overview image).\n */\nexport type SpectrumPoint = { x: number; y: number }\n\nexport function spectrumColor({ x, y }: SpectrumPoint, alpha: number): Rgba {\n return { ...hslToRgb(clamp(y, 0, 1) * 360, 1, 1 - clamp(x, 0, 1)), a: alpha }\n}\n\n/** Where a color sits on the spectrum; a gray keeps the hue of `previous`, as it has none. */\nexport function spectrumPoint(color: Rgba, previous?: SpectrumPoint): SpectrumPoint {\n const { h, l } = rgbToHsl(color)\n return { x: 1 - l, y: h === null ? previous?.y ?? 0 : h / 360 }\n}\n\n/** The track of the Opacity slider: the color from clear to opaque over the kit's 12% to 88% (515:47434). */\nexport const opacityTrack = (color: Rgba) => `linear-gradient(to right, ${cssColor(color, 0)} 12%, ${cssColor(color, 1)} 88%)`\n\nexport type ColorChannel = \"r\" | \"g\" | \"b\"\n\nexport const COLOR_PICKER_CHANNELS: readonly { channel: ColorChannel; label: string }[] = [\n { channel: \"r\", label: \"Red\" },\n { channel: \"g\", label: \"Green\" },\n { channel: \"b\", label: \"Blue\" },\n]\n\n/** The track of a channel slider: the color with that channel from 0 to 255. */\nexport const channelTrack = (color: Rgba, channel: ColorChannel) =>\n `linear-gradient(to right, ${cssColor({ ...color, [channel]: 0 }, 1)}, ${cssColor({ ...color, [channel]: 255 }, 1)})`\n\n/** A number typed in a field, kept within `min` and `max`; text with no number is `null`. */\nexport function parseNumber(text: string, min: number, max: number): number | null {\n const number = Number.parseFloat(text.replace(/[%\\s]/g, \"\"))\n return Number.isFinite(number) ? clamp(Math.round(number), min, max) : null\n}\n\n/** The EyeDropper API (Chromium), when the browser has it. */\ntype EyeDropperConstructor = new () => { open: () => Promise<{ sRGBHex: string }> }\n\nexport function eyeDropper(): EyeDropperConstructor | null {\n if (typeof window === \"undefined\") return null\n return (window as Window & { EyeDropper?: EyeDropperConstructor }).EyeDropper ?? null\n}\n"]}