@plexui/ui 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/Alert/Alert.js +2 -2
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/Avatar/Avatar.js +3 -1
- package/dist/es/components/Avatar/Avatar.js.map +1 -1
- package/dist/es/components/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/es/components/ButtonGroup/index.js.map +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +1 -3
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +227 -0
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/es/components/ColorPicker/ColorWell.js +58 -0
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
- package/dist/es/components/ColorPicker/index.js +3 -0
- package/dist/es/components/ColorPicker/index.js.map +1 -0
- package/dist/es/components/ColorPicker/shared.js +132 -0
- package/dist/es/components/ColorPicker/shared.js.map +1 -0
- package/dist/es/components/ContextMenu/ContextMenu.js +164 -0
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
- package/dist/es/components/ContextMenu/index.js +2 -0
- package/dist/es/components/ContextMenu/index.js.map +1 -0
- package/dist/es/components/ContextMenu/shared.js +57 -0
- package/dist/es/components/ContextMenu/shared.js.map +1 -0
- package/dist/es/components/DatePicker/DatePicker.js +4 -2
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +118 -24
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/dialogSteps.js +85 -0
- package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
- package/dist/es/components/Dialog/dialogViewport.js +74 -0
- package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
- package/dist/es/components/Dialog/index.js +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +2 -1
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +3 -3
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/FieldGroup/FieldGroup.js +4 -2
- package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/Icon/index.js +1 -0
- package/dist/es/components/Icon/index.js.map +1 -1
- package/dist/es/components/Icon/svg/Eyedropper.js +6 -0
- package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
- package/dist/es/components/IndexBar/IndexBar.js +164 -0
- package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
- package/dist/es/components/IndexBar/index.js +2 -0
- package/dist/es/components/IndexBar/index.js.map +1 -0
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Input/Input.js +2 -2
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +142 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +109 -29
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Page/Page.js +41 -14
- package/dist/es/components/Page/Page.js.map +1 -1
- package/dist/es/components/PageControl/PageControl.js +146 -0
- package/dist/es/components/PageControl/PageControl.js.map +1 -0
- package/dist/es/components/PageControl/index.js +2 -0
- package/dist/es/components/PageControl/index.js.map +1 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js +41 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
- package/dist/es/components/PhoneLayout/index.js +2 -0
- package/dist/es/components/PhoneLayout/index.js.map +1 -0
- package/dist/es/components/Popover/Popover.js +2 -1
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Select/Select.js +11 -6
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +1 -1
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +21 -8
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +43 -8
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Stepper/Stepper.js +114 -0
- package/dist/es/components/Stepper/Stepper.js.map +1 -0
- package/dist/es/components/Stepper/index.js +2 -0
- package/dist/es/components/Stepper/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +321 -0
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
- package/dist/es/components/SwipeActions/index.js +2 -0
- package/dist/es/components/SwipeActions/index.js.map +1 -0
- package/dist/es/components/TabBar/TabBar.js +128 -0
- package/dist/es/components/TabBar/TabBar.js.map +1 -0
- package/dist/es/components/TabBar/index.js +2 -0
- package/dist/es/components/TabBar/index.js.map +1 -0
- package/dist/es/components/Tabs/Tabs.js +13 -6
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/TagInput/TagInput.js +5 -65
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +1 -1
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Tip/Tip.js +106 -0
- package/dist/es/components/Tip/Tip.js.map +1 -0
- package/dist/es/components/Tip/index.js +2 -0
- package/dist/es/components/Tip/index.js.map +1 -0
- package/dist/es/components/Toast/ToastRenderer.js +22 -9
- package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
- package/dist/es/components/Toast/Toaster.js +17 -6
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/toastLifecycle.js +113 -1
- package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js +31 -5
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/components/Toolbar/index.js.map +1 -1
- package/dist/es/hooks/useEscCloseStack.js +10 -3
- package/dist/es/hooks/useEscCloseStack.js.map +1 -1
- package/dist/es/lib/fieldRow.js +7 -1
- package/dist/es/lib/fieldRow.js.map +1 -1
- package/dist/es/lib/floatingBoundary.js +3 -1
- package/dist/es/lib/floatingBoundary.js.map +1 -1
- package/dist/es/lib/helpers.js +21 -0
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/menuSubmenuPlacement.js +51 -6
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +70 -0
- package/dist/es/lib/menuTriggerCover.js.map +1 -0
- package/dist/es/lib/phoneLayout.js +16 -0
- package/dist/es/lib/phoneLayout.js.map +1 -0
- package/dist/es/lib/scrollEdges.js +34 -0
- package/dist/es/lib/scrollEdges.js.map +1 -0
- package/dist/es/lib/toastRegion.js +6 -0
- package/dist/es/lib/toastRegion.js.map +1 -0
- package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +8 -1
- package/dist/types/components/ButtonGroup/index.d.ts +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +34 -0
- package/dist/types/components/ColorPicker/ColorWell.d.ts +32 -0
- package/dist/types/components/ColorPicker/index.d.ts +3 -0
- package/dist/types/components/ColorPicker/shared.d.ts +69 -0
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +78 -0
- package/dist/types/components/ContextMenu/index.d.ts +1 -0
- package/dist/types/components/ContextMenu/shared.d.ts +51 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +6 -1
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +1 -0
- package/dist/types/components/Dialog/Dialog.d.ts +52 -3
- package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
- package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +11 -2
- package/dist/types/components/FieldGroup/FieldGroup.d.ts +11 -2
- package/dist/types/components/Icon/index.d.ts +1 -0
- package/dist/types/components/Icon/svg/Eyedropper.d.ts +6 -0
- package/dist/types/components/IndexBar/IndexBar.d.ts +35 -0
- package/dist/types/components/IndexBar/index.d.ts +1 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +1 -1
- package/dist/types/components/Menu/Menu.d.ts +79 -10
- package/dist/types/components/Page/Page.d.ts +8 -4
- package/dist/types/components/PageControl/PageControl.d.ts +52 -0
- package/dist/types/components/PageControl/index.d.ts +1 -0
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +18 -0
- package/dist/types/components/PhoneLayout/index.d.ts +1 -0
- package/dist/types/components/Select/Select.d.ts +3 -3
- package/dist/types/components/Stepper/Stepper.d.ts +56 -0
- package/dist/types/components/Stepper/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +46 -0
- package/dist/types/components/SwipeActions/index.d.ts +1 -0
- package/dist/types/components/TabBar/TabBar.d.ts +88 -0
- package/dist/types/components/TabBar/index.d.ts +1 -0
- package/dist/types/components/Tip/Tip.d.ts +57 -0
- package/dist/types/components/Tip/index.d.ts +1 -0
- package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +19 -5
- package/dist/types/components/Toolbar/index.d.ts +1 -1
- package/dist/types/hooks/useEscCloseStack.d.ts +5 -1
- package/dist/types/lib/fieldRow.d.ts +6 -0
- package/dist/types/lib/helpers.d.ts +6 -0
- package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
- package/dist/types/lib/menuTriggerCover.d.ts +23 -0
- package/dist/types/lib/phoneLayout.d.ts +11 -0
- package/dist/types/lib/scrollEdges.d.ts +16 -0
- package/dist/types/lib/toastRegion.d.ts +5 -0
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
5
5
|
import { mergeRefs } from "react-merge-refs";
|
|
6
6
|
import { useResizeObserver } from "usehooks-ts";
|
|
7
7
|
import {} from "../../types.js";
|
|
8
|
-
import { CheckCircle, Info, Warning } from "../Icon/index.js";
|
|
8
|
+
import { CheckCircle, Info, Warning, X } from "../Icon/index.js";
|
|
9
9
|
import { Button } from "../Button/index.js";
|
|
10
10
|
import s from "@plexui/styles/components/Alert/Alert.module.css";
|
|
11
11
|
export const Alert = ({ color = "primary", variant = "outline", title, description, actions, actionsPlacement, indicator, className, actionsClassName, onDismiss, banner = false, ref, ...restProps }) => {
|
|
@@ -22,7 +22,7 @@ export const Alert = ({ color = "primary", variant = "outline", title, descripti
|
|
|
22
22
|
setActionsAutoPlacement(placement);
|
|
23
23
|
}
|
|
24
24
|
}, [containerWidth]);
|
|
25
|
-
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, ...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, children: "Dismiss" }))] }))] })] }));
|
|
25
|
+
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, ...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
26
|
};
|
|
27
27
|
export const Indicator = ({ color }) => {
|
|
28
28
|
// Choose a default icon based on the color (which signals intention)
|
|
@@ -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,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
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,iB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,EAAC,IAAI,EAAC,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 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 /** 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 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 {...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"]}
|
|
@@ -53,8 +53,10 @@ const AvatarImage = ({ url, status, onLoad, onError, }) => {
|
|
|
53
53
|
onLoad();
|
|
54
54
|
}, src: url, className: s.AvatarImage, "data-loaded": status === "loaded" ? "" : undefined, onLoad: onLoad, onError: onError, alt: "", role: "presentation" }) }));
|
|
55
55
|
};
|
|
56
|
+
// The first character of the name, past any leading space and whole even when it is an emoji (a surrogate pair)
|
|
57
|
+
const initialOf = (name) => (Array.from(name.trim())[0] ?? "").toUpperCase();
|
|
56
58
|
const AvatarInitial = ({ name = "" }) => {
|
|
57
|
-
const firstInitial = useMemo(() => name
|
|
59
|
+
const firstInitial = useMemo(() => initialOf(name), [name]);
|
|
58
60
|
return _jsx("span", { className: s.AvatarInitial, children: firstInitial });
|
|
59
61
|
};
|
|
60
62
|
const AvatarOverflowCount = ({ count }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAiClE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAkB,E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;AAED,gHAAgH;AAChH,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;AAE5F,MAAM,aAAa,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAqB,EAAE,EAAE;IACzD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAE3D,OAAO,eAAM,SAAS,EAAE,CAAC,CAAC,aAAa,YAAG,YAAY,GAAQ,CAAA;AAChE,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IAC3D,MAAM,cAAc,GAAG,OAAO,CAAS,GAAG,EAAE;QAC1C,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;YACjC,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,OAAO;YACvB,qBAAqB,EAAE,CAAC;SACzB,CAAC;aACC,MAAM,CAAC,KAAK,CAAC;aACb,iBAAiB,EAAE,CAAA;IACxB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,CACL,gBAAM,SAAS,EAAE,CAAC,CAAC,mBAAmB,uBAAqB,cAAc,CAAC,MAAM,aAC9E,eAAM,SAAS,EAAE,CAAC,CAAC,yBAAyB,kBAAU,EACrD,cAAc,IACV,CACR,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useMemo, useState } from \"react\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport s from \"@plexui/styles/components/Avatar/Avatar.module.css\"\n\ntype ImageStatus = undefined | \"error\" | \"loaded\"\n\nexport type AvatarProps = {\n /** Class name applied to the avatar */\n className?: string\n /** Size of the avatar's width & height, in pixels. */\n size?: number\n /** Display a formatted count of overflow objects. */\n overflowCount?: number\n /** Name used to display initials from */\n name?: string\n /**\n * Color used for the avatar\n * @default secondary\n */\n color?: SemanticColors<\"primary\" | \"secondary\" | \"success\" | \"info\" | \"discovery\" | \"danger\">\n /**\n * Style variant of the avatar\n * @default soft\n */\n variant?: Variants<\"soft\" | \"solid\">\n /** URL of the image to display as the avatar */\n imageUrl?: string\n /** Icon to render in the avatar circle */\n Icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>\n /** Optional click handler, which also enables semantic interactions */\n onClick?: () => void\n /** Optional pointer handler, which also enables semantic interactions */\n onPointerDown?: () => void\n}\n\nexport const Avatar = (props: AvatarProps) => {\n // Validate the image url before sending to the component\n const validImageUrl = validateImageUrl(props.imageUrl)\n\n // Keying off of imageUrl allows us to refresh imageStatus automatically through React rendering\n return <AvatarInner {...props} imageUrl={validImageUrl} key={validImageUrl} />\n}\n\nexport const AvatarInner = (props: AvatarProps) => {\n const {\n className,\n size,\n overflowCount,\n name,\n color = \"secondary\",\n variant = \"soft\",\n imageUrl,\n Icon,\n // asChild support\n ...restProps\n } = props\n const [imageStatus, setImageStatus] = useState<ImageStatus>()\n const isInteractive = !!(restProps.onPointerDown || restProps.onClick)\n const TagName = isInteractive ? \"button\" : \"span\"\n\n return (\n <TagName\n className={clsx(s.Avatar, className)}\n style={toCssVariables({\n \"avatar-size\": size,\n })}\n role={isInteractive ? undefined : \"presentation\"}\n // An interactive avatar is a button; name it by the full name, not the initial\n aria-label={isInteractive ? name : undefined}\n data-color={color}\n data-variant={variant}\n type={isInteractive ? \"button\" : undefined}\n {...restProps}\n >\n {(() => {\n // Render a placeholder layer (initials / overflow / icon) behind the\n // image so slow networks never leave the avatar visually empty while\n // the image is loading. The image overlays it once loaded and hides\n // it when it fails — either way the avatar is never blank.\n const placeholder = overflowCount ? (\n <AvatarOverflowCount count={overflowCount} />\n ) : Icon ? (\n <Icon className={s.AvatarIcon} />\n ) : (\n <AvatarInitial name={name} />\n )\n\n if (imageUrl && imageStatus !== \"error\") {\n return (\n <>\n {placeholder}\n <AvatarImage\n status={imageStatus}\n url={imageUrl}\n onError={() => setImageStatus(\"error\")}\n onLoad={() => setImageStatus(\"loaded\")}\n />\n </>\n )\n }\n return placeholder\n })()}\n </TagName>\n )\n}\n\nconst validateImageUrl = (imageUrl?: string): string | undefined => {\n if (!imageUrl) {\n return\n }\n\n // Avoid specific pattern of images from gravatar.com, which use a pair of initials, instead of a single initial.\n if (imageUrl.includes(\"gravatar.com\") && imageUrl.includes(\"cdn.auth0.com\")) {\n return\n }\n\n return imageUrl\n}\n\nconst AvatarImage = ({\n url,\n status,\n onLoad,\n onError,\n}: {\n url: string\n status: ImageStatus\n onLoad: () => void\n onError: () => void\n}) => {\n return (\n <span className={s.AvatarImageContainer}>\n <img\n // An image that loaded before hydration fired its load event before\n // React listened for it, and React does not replay it: read the\n // element instead\n ref={(img) => {\n if (img && status !== \"loaded\" && img.complete && img.naturalWidth > 0) onLoad()\n }}\n src={url}\n className={s.AvatarImage}\n data-loaded={status === \"loaded\" ? \"\" : undefined}\n onLoad={onLoad}\n onError={onError}\n alt=\"\"\n role=\"presentation\"\n />\n </span>\n )\n}\n\n// The first character of the name, past any leading space and whole even when it is an emoji (a surrogate pair)\nconst initialOf = (name: string): string => (Array.from(name.trim())[0] ?? \"\").toUpperCase()\n\nconst AvatarInitial = ({ name = \"\" }: { name?: string }) => {\n const firstInitial = useMemo(() => initialOf(name), [name])\n\n return <span className={s.AvatarInitial}>{firstInitial}</span>\n}\n\nconst AvatarOverflowCount = ({ count }: { count: number }) => {\n const formattedCount = useMemo<string>(() => {\n return new Intl.NumberFormat(\"en\", {\n notation: \"compact\",\n compactDisplay: \"short\",\n maximumFractionDigits: 0,\n })\n .format(count)\n .toLocaleLowerCase()\n }, [count])\n\n return (\n <span className={s.AvatarOverflowCount} data-letter-count={formattedCount.length}>\n <span className={s.AvatarOverflowCountSymbol}>+</span>\n {formattedCount}\n </span>\n )\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { Slot } from "radix-ui";
|
|
|
5
5
|
import {} from "react";
|
|
6
6
|
import { Separator } from "../Separator/index.js";
|
|
7
7
|
import s from "@plexui/styles/components/ButtonGroup/ButtonGroup.module.css";
|
|
8
|
-
const ButtonGroupRoot = ({ orientation = "horizontal", className, ref, ...restProps }) => (_jsx("div", { ref: ref, role: "group", "data-slot": "button-group", "data-orientation": orientation, className: clsx(s.Root, className), ...restProps }));
|
|
8
|
+
const ButtonGroupRoot = ({ orientation = "horizontal", mobileMaterial, className, ref, ...restProps }) => (_jsx("div", { ref: ref, role: "group", "data-slot": "button-group", "data-orientation": orientation, "data-mobile-material": mobileMaterial, className: clsx(s.Root, className), ...restProps }));
|
|
9
9
|
const ButtonGroupSeparator = ({ className, orientation, ...restProps }) => (_jsx(Separator, { "data-slot": "button-group-separator", orientation: orientation ?? "vertical", className: clsx(s.Separator, className), ...restProps }));
|
|
10
10
|
const ButtonGroupText = ({ asChild = false, className, ref, ...restProps }) => {
|
|
11
11
|
const Comp = asChild ? Slot.Root : "div";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/ButtonGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAsD,MAAM,OAAO,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,CAAC,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/ButtonGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,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C,IAAI,GAAG,eAAe,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport { type ComponentProps, type HTMLAttributes, type Ref } from \"react\"\nimport { Separator } from \"../Separator\"\nimport s from \"@plexui/styles/components/ButtonGroup/ButtonGroup.module.css\"\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nexport type ButtonGroupMobileMaterial = \"glass\" | \"flat\"\n\nexport type ButtonGroupProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Direction of the joined buttons.\n * @default \"horizontal\"\n */\n orientation?: ButtonGroupOrientation\n /**\n * Phone surface (below 768px, with touch.css). `\"glass\"` makes the group one glass capsule, the Button Group\n * of the iOS 27 kit, for controls over the content; a group in a Toolbar is one already. `\"flat\"` keeps the\n * joined buttons in a Toolbar.\n */\n mobileMaterial?: ButtonGroupMobileMaterial\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nconst ButtonGroupRoot = ({\n orientation = \"horizontal\",\n mobileMaterial,\n className,\n ref,\n ...restProps\n}: ButtonGroupProps) => (\n <div\n ref={ref}\n role=\"group\"\n data-slot=\"button-group\"\n data-orientation={orientation}\n data-mobile-material={mobileMaterial}\n className={clsx(s.Root, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Separator — thin divider between items */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupSeparatorProps = Omit<\n ComponentProps<typeof Separator>,\n \"orientation\"\n> & {\n /**\n * When omitted, uses `\"vertical\"`, the axis that looks right between\n * horizontal items. Pass explicitly inside a vertical group.\n * @default \"vertical\"\n */\n orientation?: ButtonGroupOrientation\n}\n\nconst ButtonGroupSeparator = ({\n className,\n orientation,\n ...restProps\n}: ButtonGroupSeparatorProps) => (\n <Separator\n data-slot=\"button-group-separator\"\n orientation={orientation ?? \"vertical\"}\n className={clsx(s.Separator, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Text — muted label/pill sharing the group's joined geometry */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupTextProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Swap the rendered element for a child (label, span, etc.) while\n * keeping the group's visual treatment.\n * @default false\n */\n asChild?: boolean\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nconst ButtonGroupText = ({\n asChild = false,\n className,\n ref,\n ...restProps\n}: ButtonGroupTextProps) => {\n const Comp = asChild ? Slot.Root : \"div\"\n return (\n <Comp\n ref={ref}\n data-slot=\"button-group-text\"\n className={clsx(s.Text, className)}\n {...restProps}\n />\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* Export — compound API */\n/* ------------------------------------------------------------------ */\n\ntype ButtonGroupComponent = typeof ButtonGroupRoot & {\n Separator: typeof ButtonGroupSeparator\n Text: typeof ButtonGroupText\n}\n\nexport const ButtonGroup = ButtonGroupRoot as ButtonGroupComponent\nButtonGroup.Separator = ButtonGroupSeparator\nButtonGroup.Text = ButtonGroupText\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAKZ,MAAM,eAAe,CAAA","sourcesContent":["export {\n ButtonGroup,\n type ButtonGroupProps,\n type ButtonGroupMobileMaterial,\n type ButtonGroupOrientation,\n type ButtonGroupSeparatorProps,\n} from \"./ButtonGroup\"\n"]}
|
|
@@ -17,8 +17,6 @@ export const Checkbox = ({ className, label, description, id: propsId, disabled,
|
|
|
17
17
|
if (!event.defaultPrevented && event.detail > 1)
|
|
18
18
|
event.preventDefault();
|
|
19
19
|
}, children: label }));
|
|
20
|
-
return (_jsxs("div", { "data-disabled": disabled ? "" : undefined, "data-has-label": label ? "" : undefined, "data-orientation": orientation, className: clsx(className, s.Container), children: [_jsx(RadixCheckbox.Root, { className: s.Checkbox, id: id, disabled: disabled, "data-pill": pill ? "" : undefined, "data-variant": variant, ...restProps, "aria-describedby": ariaDescribedBy, children: _jsx("span", { className: s.IndicatorBox, "aria-hidden": "true", children: variant === "ghost" ? (
|
|
21
|
-
// A ghost marks the choice with the PlexUI icons of a list row, not with drawn arms.
|
|
22
|
-
_jsxs(RadixCheckbox.Indicator, { className: s.GhostMark, forceMount: true, children: [_jsx(Check, { className: s.GhostCheck }), _jsx(Minus, { className: s.GhostDash })] })) : (_jsx(RadixCheckbox.Indicator, { className: s.CheckMark, forceMount: true })) }) }), descriptionId ? (_jsxs("div", { className: s.LabelGroup, children: [labelElement, _jsx("span", { id: descriptionId, className: s.Description, children: description })] })) : (labelElement)] }));
|
|
20
|
+
return (_jsxs("div", { "data-disabled": disabled ? "" : undefined, "data-has-label": label ? "" : undefined, "data-orientation": orientation, className: clsx(className, s.Container), children: [_jsx(RadixCheckbox.Root, { className: s.Checkbox, id: id, disabled: disabled, "data-pill": pill ? "" : undefined, "data-variant": variant, ...restProps, "aria-describedby": ariaDescribedBy, children: _jsx("span", { className: s.IndicatorBox, "aria-hidden": "true", children: _jsxs(RadixCheckbox.Indicator, { className: variant === "ghost" ? s.GhostMark : s.CheckMark, forceMount: true, children: [_jsx(Check, { className: s.MarkCheck }), _jsx(Minus, { className: s.MarkDash })] }) }) }), descriptionId ? (_jsxs("div", { className: s.LabelGroup, children: [labelElement, _jsx("span", { id: descriptionId, className: s.Description, children: description })] })) : (labelElement)] }));
|
|
23
21
|
};
|
|
24
22
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI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f,eAAK,SAAS,EAAE,CAAC,CAAC,UAAU,aACzB,YAAY,EACb,eAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,WAAW,YAC9C,WAAW,GACP,IACH,CACP,CAAC,CAAC,CAAC,CACF,YAAY,CACb,IACG,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Checkbox as RadixCheckbox } from \"radix-ui\"\nimport { type FocusEventHandler, type ReactNode, useId } from \"react\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\nimport { Check, Minus } from \"../Icon\"\n\nexport type CheckboxProps = {\n /** The `id` of the checkbox. */\n id?: string\n /** The state of the checkbox when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked?: boolean | \"indeterminate\"\n /** The controlled state of the checkbox. Must be used in conjunction with `onCheckedChange`. */\n checked?: boolean | \"indeterminate\"\n /** Optional accessible label rendered to the right of the checkbox. */\n label?: ReactNode\n /** Optional second line below the label. Linked via `aria-describedby`. */\n description?: ReactNode\n /** Event handler called when the state of the checkbox changes. */\n onCheckedChange?: (nextState: boolean) => void\n /** Event handler called when the checkbox looses focus. */\n onBlur?: FocusEventHandler<HTMLButtonElement>\n /** Event handler called when the checkbox gains focus. */\n onFocus?: FocusEventHandler<HTMLButtonElement>\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled?: boolean\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required?: boolean\n /** The name of the checkbox. Submitted with its owning form as part of a name/value pair. */\n name?: string\n /** The value given as data when submitted with a `name`. */\n value?: string\n /** CSS classes applied to wrapper node */\n className?: string\n /**\n * The orientation of the checkbox relative to the label.\n *\n * @default \"left\"\n */\n orientation?: \"left\" | \"right\"\n /**\n * Determines if the checkbox should be a fully rounded pill shape.\n * @default false\n */\n pill?: boolean\n /**\n * Visual style variant for the checkbox indicator.\n * - `\"solid\"` — filled background when checked (default)\n * - `\"ghost\"` — no border or background, checkmark only\n * @default \"solid\"\n */\n variant?: \"solid\" | \"ghost\"\n}\n\nexport const Checkbox = ({\n className,\n label,\n description,\n id: propsId,\n disabled,\n orientation = \"left\",\n pill = false,\n variant = \"solid\",\n ...restProps\n}: CheckboxProps) => {\n const reactId = useId()\n const id = propsId ?? reactId\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = label && description ? `${id}-label-description` : undefined\n const ariaDescribedBy =\n [descriptionId, (restProps as { \"aria-describedby\"?: string })[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n const labelElement = label && (\n <label\n htmlFor={id}\n className={s.Label}\n onMouseDown={(event) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }}\n >\n {label}\n </label>\n )\n\n return (\n <div\n data-disabled={disabled ? \"\" : undefined}\n data-has-label={label ? \"\" : undefined}\n data-orientation={orientation}\n className={clsx(className, s.Container)}\n >\n <RadixCheckbox.Root\n className={s.Checkbox}\n id={id}\n disabled={disabled}\n data-pill={pill ? \"\" : undefined}\n data-variant={variant}\n {...restProps}\n aria-describedby={ariaDescribedBy}\n >\n <span className={s.IndicatorBox} aria-hidden=\"true\">\n {/* The mark is the PlexUI Check icon, and Minus when indeterminate: white on a solid box,\n in the text color for a ghost. */}\n <RadixCheckbox.Indicator className={variant === \"ghost\" ? s.GhostMark : s.CheckMark} forceMount>\n <Check className={s.MarkCheck} />\n <Minus className={s.MarkDash} />\n </RadixCheckbox.Indicator>\n </span>\n </RadixCheckbox.Root>\n {descriptionId ? (\n <div className={s.LabelGroup}>\n {labelElement}\n <span id={descriptionId} className={s.Description}>\n {description}\n </span>\n </div>\n ) : (\n labelElement\n )}\n </div>\n )\n}\n"]}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { Slider as RadixSlider } from "radix-ui";
|
|
5
|
+
import { useId, useRef, useState, } from "react";
|
|
6
|
+
import s from "@plexui/styles/components/ColorPicker/ColorPicker.module.css";
|
|
7
|
+
import { useLatestValue } from "../../hooks/useLatestValue.js";
|
|
8
|
+
import { prefersReducedMotion } from "../../lib/helpers.js";
|
|
9
|
+
import { ContextMenu } from "../ContextMenu/index.js";
|
|
10
|
+
import { Plus, RemoveTrash } from "../Icon/index.js";
|
|
11
|
+
import { PageControl } from "../PageControl/index.js";
|
|
12
|
+
import { SegmentedControl } from "../SegmentedControl/index.js";
|
|
13
|
+
import { alphaPercent, channelTrack, COLOR_PICKER_CHANNELS, COLOR_PICKER_GRID_COLUMNS, COLOR_PICKER_MODES, COLOR_PICKER_SWATCHES_PER_PAGE, cssColor, formatColor, gridColor, gridIndex, gridMove, hexDigits, listMove, opacityTrack, parseColor, parseNumber, sameRgb, spectrumColor, spectrumPoint, swatchPageCount, } from "./shared.js";
|
|
14
|
+
const BLACK = { r: 0, g: 0, b: 0, a: 1 };
|
|
15
|
+
const GRID_CELLS = COLOR_PICKER_GRID_COLUMNS * 10;
|
|
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 })] }) }));
|
|
20
|
+
}
|
|
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
|
+
function ColorField({ value, label, labelledBy, inputMode, wide = false, onCommit }) {
|
|
23
|
+
const [draft, setDraft] = useState(null);
|
|
24
|
+
const commit = () => {
|
|
25
|
+
if (draft !== null)
|
|
26
|
+
onCommit(draft);
|
|
27
|
+
setDraft(null);
|
|
28
|
+
};
|
|
29
|
+
return (_jsx("input", { className: s.Field, "data-wide": wide ? "" : undefined, type: "text", inputMode: inputMode, autoComplete: "off", spellCheck: false, "aria-label": label, "aria-labelledby": labelledBy, value: draft ?? value, onFocus: (event) => {
|
|
30
|
+
setDraft(value);
|
|
31
|
+
event.currentTarget.select();
|
|
32
|
+
}, onChange: (event) => setDraft(event.currentTarget.value), onBlur: commit, onKeyDown: (event) => {
|
|
33
|
+
if (event.key !== "Enter")
|
|
34
|
+
return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
commit();
|
|
37
|
+
} }));
|
|
38
|
+
}
|
|
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.
|
|
42
|
+
*/
|
|
43
|
+
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
|
+
const uid = useId();
|
|
45
|
+
const [internalValue, setInternalValue] = useState(() => defaultValue ?? "#000000");
|
|
46
|
+
const value = valueProp ?? internalValue;
|
|
47
|
+
const color = parseColor(value) ?? BLACK;
|
|
48
|
+
const colorRef = useLatestValue(color);
|
|
49
|
+
const options = useLatestValue({ controlled: valueProp !== undefined, supportsAlpha, onChange });
|
|
50
|
+
const [internalMode, setInternalMode] = useState(defaultMode);
|
|
51
|
+
const mode = modeProp ?? internalMode;
|
|
52
|
+
const [internalSwatches, setInternalSwatches] = useState(() => defaultSwatches ?? []);
|
|
53
|
+
const swatches = swatchesProp ?? internalSwatches;
|
|
54
|
+
const commit = (next) => {
|
|
55
|
+
const formatted = formatColor(options.current.supportsAlpha ? next : { ...next, a: 1 });
|
|
56
|
+
// Only a color other than the one shown is reported; an owner that keeps its color hears every new choice.
|
|
57
|
+
if (formatted === formatColor(colorRef.current))
|
|
58
|
+
return;
|
|
59
|
+
// A controlled color changes only when the owner passes it back, as in Vue.
|
|
60
|
+
if (!options.current.controlled)
|
|
61
|
+
setInternalValue(formatted);
|
|
62
|
+
options.current.onChange?.(formatted);
|
|
63
|
+
};
|
|
64
|
+
const changeMode = (next) => {
|
|
65
|
+
if (modeProp === undefined)
|
|
66
|
+
setInternalMode(next);
|
|
67
|
+
onModeChange?.(next);
|
|
68
|
+
};
|
|
69
|
+
const changeSwatches = (next) => {
|
|
70
|
+
if (swatchesProp === undefined)
|
|
71
|
+
setInternalSwatches(next);
|
|
72
|
+
onSwatchesChange?.(next);
|
|
73
|
+
};
|
|
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
|
+
const percent = parseNumber(text, 0, 100);
|
|
76
|
+
if (percent !== null)
|
|
77
|
+
commit({ ...colorRef.current, a: percent / 100 });
|
|
78
|
+
} })] })] })), _jsx(ColorSwatches, { color: color, swatches: swatches, onSelect: commit, onChange: changeSwatches })] }));
|
|
79
|
+
}
|
|
80
|
+
/** The kit's Color Grid: twelve hues across, grays then nine shades down; the selected cell has a 3px white ring. */
|
|
81
|
+
function ColorGrid({ color, onSelect }) {
|
|
82
|
+
const selected = gridIndex(color);
|
|
83
|
+
const focusable = selected === -1 ? 0 : selected;
|
|
84
|
+
const onKeyDown = (event) => {
|
|
85
|
+
const from = Number(event.target.dataset.index);
|
|
86
|
+
if (!Number.isInteger(from) || !NAVIGATION_KEYS.includes(event.key))
|
|
87
|
+
return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
const next = gridMove(from, event.key);
|
|
90
|
+
if (next === from)
|
|
91
|
+
return;
|
|
92
|
+
const cell = event.currentTarget.querySelector(`[data-index="${next}"]`);
|
|
93
|
+
cell?.focus();
|
|
94
|
+
onSelect({ ...(parseColor(gridColor(next)) ?? BLACK), a: color.a });
|
|
95
|
+
};
|
|
96
|
+
return (_jsx("div", { role: "radiogroup", "aria-label": "Grid", className: s.Grid, onKeyDown: onKeyDown, children: Array.from({ length: GRID_CELLS }, (_, index) => {
|
|
97
|
+
const hex = gridColor(index);
|
|
98
|
+
return (_jsx("button", { type: "button", role: "radio", "aria-checked": index === selected, "aria-label": hex.toUpperCase(), tabIndex: index === focusable ? 0 : -1, "data-index": index, className: s.Cell, style: { backgroundColor: hex }, onClick: () => onSelect({ ...(parseColor(hex) ?? BLACK), a: color.a }) }, hex));
|
|
99
|
+
}) }));
|
|
100
|
+
}
|
|
101
|
+
const SPECTRUM_STEP = 0.01;
|
|
102
|
+
/**
|
|
103
|
+
* The spectrum: hue from top to bottom, white to the full hue to black across. Up and Down change the hue, Left
|
|
104
|
+
* and Right the lightness, by 1% (10% with Shift or Page Up and Page Down).
|
|
105
|
+
*/
|
|
106
|
+
function ColorSpectrum({ color, onSelect }) {
|
|
107
|
+
const [held, setHeld] = useState(() => ({ point: spectrumPoint(color), digits: hexDigits(color) }));
|
|
108
|
+
// The point the picker last chose stays while the color is the one it chose: a hex color loses the exact point,
|
|
109
|
+
// and a gray or white has no hue of its own.
|
|
110
|
+
const point = held.digits === hexDigits(color) ? held.point : spectrumPoint(color, held.point);
|
|
111
|
+
const choose = (next) => {
|
|
112
|
+
const clamped = { x: Math.min(1, Math.max(0, next.x)), y: Math.min(1, Math.max(0, next.y)) };
|
|
113
|
+
const chosen = spectrumColor(clamped, color.a);
|
|
114
|
+
setHeld({ point: clamped, digits: hexDigits(chosen) });
|
|
115
|
+
onSelect(chosen);
|
|
116
|
+
};
|
|
117
|
+
const fromPointer = (event) => {
|
|
118
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
119
|
+
if (box.width === 0 || box.height === 0)
|
|
120
|
+
return;
|
|
121
|
+
choose({ x: (event.clientX - box.left) / box.width, y: (event.clientY - box.top) / box.height });
|
|
122
|
+
};
|
|
123
|
+
const onKeyDown = (event) => {
|
|
124
|
+
const step = event.shiftKey ? SPECTRUM_STEP * 10 : SPECTRUM_STEP;
|
|
125
|
+
const moves = {
|
|
126
|
+
ArrowLeft: { x: point.x - step, y: point.y },
|
|
127
|
+
ArrowRight: { x: point.x + step, y: point.y },
|
|
128
|
+
ArrowUp: { x: point.x, y: point.y - step },
|
|
129
|
+
ArrowDown: { x: point.x, y: point.y + step },
|
|
130
|
+
PageUp: { x: point.x, y: point.y - SPECTRUM_STEP * 10 },
|
|
131
|
+
PageDown: { x: point.x, y: point.y + SPECTRUM_STEP * 10 },
|
|
132
|
+
};
|
|
133
|
+
const next = moves[event.key];
|
|
134
|
+
if (!next)
|
|
135
|
+
return;
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
choose(next);
|
|
138
|
+
};
|
|
139
|
+
const hue = Math.round(point.y * 360);
|
|
140
|
+
return (_jsx("div", { role: "slider", tabIndex: 0, "aria-label": "Spectrum", "aria-valuemin": 0, "aria-valuemax": 360, "aria-valuenow": hue, "aria-valuetext": `#${hexDigits(color)}, hue ${hue}°, lightness ${Math.round((1 - point.x) * 100)}%`, className: s.Spectrum, onPointerDown: (event) => {
|
|
141
|
+
if (event.button !== 0)
|
|
142
|
+
return;
|
|
143
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
144
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
145
|
+
fromPointer(event);
|
|
146
|
+
}, onPointerMove: (event) => {
|
|
147
|
+
if (event.currentTarget.hasPointerCapture?.(event.pointerId))
|
|
148
|
+
fromPointer(event);
|
|
149
|
+
}, onKeyDown: onKeyDown, children: _jsx("span", { className: s.Loupe, style: { left: `${point.x * 100}%`, top: `${point.y * 100}%`, backgroundColor: cssColor(color, 1) } }) }));
|
|
150
|
+
}
|
|
151
|
+
/** Red, Green and Blue, each a slider and a field from 0 to 255, then the Hex field. */
|
|
152
|
+
function ColorSliders({ uid, color, onSelect }) {
|
|
153
|
+
return (_jsxs("div", { className: s.Sliders, children: [COLOR_PICKER_CHANNELS.map(({ channel, label }) => {
|
|
154
|
+
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
|
+
const next = parseNumber(text, 0, 255);
|
|
157
|
+
if (next !== null)
|
|
158
|
+
onSelect({ ...color, [channel]: next });
|
|
159
|
+
} })] })] }, 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
|
+
const next = parseColor(text);
|
|
162
|
+
if (next)
|
|
163
|
+
onSelect({ ...next, a: color.a });
|
|
164
|
+
} })] })] }));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
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.
|
|
169
|
+
*/
|
|
170
|
+
function ColorSwatches({ color, swatches, onSelect, onChange }) {
|
|
171
|
+
const pagesRef = useRef(null);
|
|
172
|
+
const [page, setPage] = useState(0);
|
|
173
|
+
const saved = swatches.map((hex) => parseColor(hex) ?? BLACK);
|
|
174
|
+
const current = formatColor(color);
|
|
175
|
+
const checked = saved.findIndex((swatch) => sameRgb(swatch, color) && alphaPercent(swatch.a) === alphaPercent(color.a));
|
|
176
|
+
const focusable = checked === -1 ? 0 : checked;
|
|
177
|
+
const pageCount = swatchPageCount(swatches.length);
|
|
178
|
+
const reveal = (element) => element?.scrollIntoView?.({ block: "nearest", inline: "nearest" });
|
|
179
|
+
const remove = (index, pages) => {
|
|
180
|
+
onChange(swatches.filter((_, i) => i !== index));
|
|
181
|
+
// Focus stays in the list: on the color that takes the place, the one before at the end, or Add.
|
|
182
|
+
const target = Math.min(index, swatches.length - 2);
|
|
183
|
+
requestAnimationFrame(() => {
|
|
184
|
+
const next = target >= 0 ? pages?.querySelector(`[data-swatch="${target}"]`) : pages?.querySelector("[data-add]");
|
|
185
|
+
next?.focus();
|
|
186
|
+
reveal(next);
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
const onKeyDown = (event) => {
|
|
190
|
+
const from = Number(event.target.dataset.swatch);
|
|
191
|
+
if (!Number.isInteger(from))
|
|
192
|
+
return;
|
|
193
|
+
if (event.key === "Delete" || event.key === "Backspace") {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
remove(from, event.currentTarget);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (!NAVIGATION_KEYS.includes(event.key))
|
|
199
|
+
return;
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
const next = listMove(from, swatches.length, event.key);
|
|
202
|
+
if (next === from)
|
|
203
|
+
return;
|
|
204
|
+
const element = event.currentTarget.querySelector(`[data-swatch="${next}"]`);
|
|
205
|
+
element?.focus();
|
|
206
|
+
reveal(element);
|
|
207
|
+
onSelect(saved[next]);
|
|
208
|
+
};
|
|
209
|
+
const items = [...swatches.map((hex, index) => ({ hex, index })), null];
|
|
210
|
+
const pages = Array.from({ length: pageCount }, (_, p) => items.slice(p * COLOR_PICKER_SWATCHES_PER_PAGE, (p + 1) * COLOR_PICKER_SWATCHES_PER_PAGE));
|
|
211
|
+
return (_jsxs("div", { className: s.Swatches, children: [_jsx("div", { role: "img", "aria-label": `Selected color #${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : ""}`, className: s.Current, children: _jsx("span", { className: s.CurrentFill, style: { backgroundColor: cssColor(color) } }) }), _jsxs("div", { className: s.Saved, children: [_jsx("div", { ref: pagesRef, role: "radiogroup", "aria-label": "Saved colors", className: s.Pages, onKeyDown: onKeyDown, onScroll: (event) => {
|
|
212
|
+
const { scrollLeft, clientWidth } = event.currentTarget;
|
|
213
|
+
if (clientWidth > 0)
|
|
214
|
+
setPage(Math.round(scrollLeft / clientWidth));
|
|
215
|
+
}, children: pages.map((pageItems, p) => (_jsx("div", { className: s.Page, children: pageItems.map((item) => item === null ? (_jsx("button", { type: "button", "data-add": "", className: s.Add, "aria-label": "Add color", onClick: (event) => {
|
|
216
|
+
onChange([...swatches, current]);
|
|
217
|
+
const add = event.currentTarget;
|
|
218
|
+
requestAnimationFrame(() => reveal(add));
|
|
219
|
+
}, children: _jsx(Plus, {}) }, "add")) : (_jsxs(ContextMenu, { children: [_jsx(ContextMenu.Trigger, { children: _jsx("button", { type: "button", role: "radio", "aria-checked": item.index === checked, "aria-label": `#${hexDigits(saved[item.index])}${saved[item.index].a < 1 ? `, ${alphaPercent(saved[item.index].a)}% opacity` : ""}`, tabIndex: item.index === focusable ? 0 : -1, "data-swatch": item.index, className: s.Swatch, onClick: () => onSelect(saved[item.index]), children: _jsx("span", { className: s.SwatchFill, style: { backgroundColor: cssColor(saved[item.index]) } }) }) }), _jsx(ContextMenu.Content, { children: _jsxs(ContextMenu.Item, { danger: true, onSelect: () => remove(item.index, pagesRef.current), children: [_jsx(RemoveTrash, { width: 20, height: 20 }), " Delete"] }) })] }, `${item.index}-${item.hex}`))) }, p))) }), _jsx("div", { className: s.PageControlRow, children: pageCount > 1 && (_jsx(PageControl, { count: pageCount, value: Math.min(page, pageCount - 1), "aria-label": "Saved color pages", onChange: (index) => {
|
|
220
|
+
const pagesElement = pagesRef.current;
|
|
221
|
+
if (!pagesElement)
|
|
222
|
+
return;
|
|
223
|
+
setPage(index);
|
|
224
|
+
pagesElement.scrollTo?.({ left: index * pagesElement.clientWidth, behavior: prefersReducedMotion() ? "auto" : "smooth" });
|
|
225
|
+
} })) })] })] }));
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=ColorPicker.js.map
|
|
@@ -0,0 +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,mBAAmB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE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AE,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"]}
|