@ankhorage/zora 27.10.3 → 27.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/features/color/ColorHexField.d.ts +9 -0
- package/dist/features/color/ColorHexField.d.ts.map +1 -0
- package/dist/features/color/ColorHexField.js +17 -0
- package/dist/features/color/ColorHexField.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.d.ts +9 -0
- package/dist/features/color/ColorHorizontalPointerProxy.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.js +2 -0
- package/dist/features/color/ColorHorizontalPointerProxy.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts +4 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.js +5 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts +5 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.js +26 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.js.map +1 -0
- package/dist/features/color/ColorHueScale.d.ts.map +1 -1
- package/dist/features/color/ColorHueScale.js +18 -7
- package/dist/features/color/ColorHueScale.js.map +1 -1
- package/dist/features/color/ColorPicker.d.ts.map +1 -1
- package/dist/features/color/ColorPicker.js +37 -10
- package/dist/features/color/ColorPicker.js.map +1 -1
- package/dist/features/color/ColorSpectrumSlider.d.ts +9 -0
- package/dist/features/color/ColorSpectrumSlider.d.ts.map +1 -0
- package/dist/features/color/ColorSpectrumSlider.js +38 -0
- package/dist/features/color/ColorSpectrumSlider.js.map +1 -0
- package/dist/features/color/ColorTone.d.ts.map +1 -1
- package/dist/features/color/ColorTone.js +71 -12
- package/dist/features/color/ColorTone.js.map +1 -1
- package/dist/features/color/ColorWheel.d.ts.map +1 -1
- package/dist/features/color/ColorWheel.js +64 -36
- package/dist/features/color/ColorWheel.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.d.ts +10 -0
- package/dist/features/color/ColorWheelPointerProxy.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.js +2 -0
- package/dist/features/color/ColorWheelPointerProxy.js.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts +4 -0
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.native.js +5 -0
- package/dist/features/color/ColorWheelPointerProxy.native.js.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts +5 -0
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.web.js +26 -0
- package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +14 -2
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
- package/dist/types/color.d.ts +2 -0
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/color.js.map +1 -1
- package/package.json +2 -2
- package/src/features/color/ColorHexField.tsx +45 -0
- package/src/features/color/ColorHorizontalPointerProxy.native.tsx +6 -0
- package/src/features/color/ColorHorizontalPointerProxy.tsx +10 -0
- package/src/features/color/ColorHorizontalPointerProxy.web.tsx +45 -0
- package/src/features/color/ColorHueScale.tsx +48 -29
- package/src/features/color/ColorPicker.layout.test.tsx +72 -0
- package/src/features/color/ColorPicker.tsx +74 -20
- package/src/features/color/ColorSpectrumSlider.tsx +79 -0
- package/src/features/color/ColorTone.tsx +138 -21
- package/src/features/color/ColorWheel.tsx +173 -92
- package/src/features/color/ColorWheelPointerProxy.native.tsx +6 -0
- package/src/features/color/ColorWheelPointerProxy.tsx +11 -0
- package/src/features/color/ColorWheelPointerProxy.web.tsx +51 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +18 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +18 -2
- package/src/types/color.ts +2 -0
- package/web-dist/chunks/{Accordion-mxad79vq.js → Accordion-0kr0h68p.js} +4568 -669
- package/web-dist/chunks/{Accordion-0jkpvxwd.js → Accordion-1etqb3cj.js} +2 -2
- package/web-dist/chunks/{Accordion-jr0201qc.js → Accordion-1mxnyexh.js} +17 -17
- package/web-dist/chunks/{Accordion-9kkfz7s8.js → Accordion-3ecnh8d0.js} +4 -4
- package/web-dist/chunks/{Accordion-jsapannb.js → Accordion-3jkeydhb.js} +4 -4
- package/web-dist/chunks/{Accordion-r6gwemh9.js → Accordion-3wkd5x2q.js} +3 -3
- package/web-dist/chunks/{Accordion-0bgzetnd.js → Accordion-3zw817fr.js} +6 -6
- package/web-dist/chunks/{Accordion-91v243pz.js → Accordion-49w9bc2f.js} +2 -2
- package/web-dist/chunks/{Accordion-8vw4k0s6.js → Accordion-4g54je0w.js} +2 -2
- package/web-dist/chunks/{Accordion-1andv7gg.js → Accordion-5vs1k81g.js} +8 -8
- package/web-dist/chunks/{Accordion-ttjyk97v.js → Accordion-6m3k4avp.js} +2 -2
- package/web-dist/chunks/{Accordion-dnfrzbpb.js → Accordion-6nrpdbmb.js} +7 -7
- package/web-dist/chunks/{Accordion-y524ph0g.js → Accordion-6yv4beha.js} +1 -1
- package/web-dist/chunks/{Accordion-9cpm8x92.js → Accordion-705yrq6w.js} +1 -1
- package/web-dist/chunks/{Accordion-th8pkeqc.js → Accordion-8g9c7890.js} +4 -4
- package/web-dist/chunks/{Accordion-6qesggn9.js → Accordion-9c63jn3m.js} +4 -4
- package/web-dist/chunks/{Accordion-1mjn0atk.js → Accordion-aws0caav.js} +3 -3
- package/web-dist/chunks/{Accordion-hha54x4c.js → Accordion-bd6q61s1.js} +5 -5
- package/web-dist/chunks/{Accordion-8rkwd0wx.js → Accordion-c0a7mhq3.js} +2 -2
- package/web-dist/chunks/{Accordion-j5wsx41j.js → Accordion-c3nna2bz.js} +1 -1
- package/web-dist/chunks/{Accordion-r6mc7qtj.js → Accordion-dfq04q82.js} +9 -9
- package/web-dist/chunks/{Accordion-nbje2ywp.js → Accordion-e3r3573t.js} +3 -3
- package/web-dist/chunks/{Accordion-hqg1zbxk.js → Accordion-e5jr9ahb.js} +1 -1
- package/web-dist/chunks/{Accordion-pkbvsn5y.js → Accordion-eak89n4n.js} +6 -6
- package/web-dist/chunks/{Accordion-7e0mb55z.js → Accordion-f60g73bp.js} +6 -6
- package/web-dist/chunks/{Accordion-grtf75xt.js → Accordion-g451f3g9.js} +4 -4
- package/web-dist/chunks/{Accordion-27rxpbvf.js → Accordion-gezcm372.js} +4 -4
- package/web-dist/chunks/{Accordion-45tbe5v0.js → Accordion-h0e95qxp.js} +9 -9
- package/web-dist/chunks/{Accordion-m7jt3c87.js → Accordion-h2nd5y0z.js} +5 -5
- package/web-dist/chunks/{Accordion-f6k281sv.js → Accordion-j0zhpq4s.js} +7 -7
- package/web-dist/chunks/{Accordion-q6xnm1k4.js → Accordion-jbwey4za.js} +17 -17
- package/web-dist/chunks/{Accordion-vdqc8rxv.js → Accordion-jd26f516.js} +3 -3
- package/web-dist/chunks/{Accordion-1k7pyxdd.js → Accordion-ne91vwkd.js} +2 -2
- package/web-dist/chunks/{Accordion-k058095e.js → Accordion-p29kmwh9.js} +1 -1
- package/web-dist/chunks/{Accordion-0pbcs0xf.js → Accordion-pcj256bc.js} +5 -5
- package/web-dist/chunks/{Accordion-8wq38d9b.js → Accordion-phtyg3k4.js} +7 -7
- package/web-dist/chunks/{Accordion-b991pn6e.js → Accordion-pmfdf08d.js} +1 -1
- package/web-dist/chunks/{Accordion-xp2t3pkj.js → Accordion-q1tdazgq.js} +8 -8
- package/web-dist/chunks/{Accordion-v21vz0cg.js → Accordion-qhn8z92r.js} +3 -3
- package/web-dist/chunks/Accordion-r1wkgt7c.js +1074 -0
- package/web-dist/chunks/{Accordion-ctcxh9pk.js → Accordion-rzf52xq8.js} +2 -2
- package/web-dist/chunks/{Accordion-hrxdchkq.js → Accordion-vewhx028.js} +8 -8
- package/web-dist/chunks/{Accordion-jsdjgfn2.js → Accordion-vk2v1zwv.js} +2 -2
- package/web-dist/chunks/{Accordion-19zt3dyq.js → Accordion-vnrqvfca.js} +1 -1
- package/web-dist/chunks/{Accordion-rt4jfq2r.js → Accordion-x0p3wxfp.js} +2 -2
- package/web-dist/chunks/{Accordion-w1ag7sr4.js → Accordion-x7ynjdv7.js} +1 -1
- package/web-dist/chunks/{Accordion-ga82tcs9.js → Accordion-xb174981.js} +10 -10
- package/web-dist/chunks/{Accordion-yskcfahv.js → Accordion-xwstve3k.js} +2 -2
- package/web-dist/chunks/{Accordion-xb2nj0q6.js → Accordion-ysmzrvhn.js} +3 -3
- package/web-dist/chunks/{Accordion-tnq8bt8v.js → Accordion-z4qakakw.js} +2 -2
- package/web-dist/chunks/{Accordion-w9vbdg9r.js → Accordion-z8ryq8cb.js} +11 -11
- package/web-dist/chunks/{Accordion-x3em7tpd.js → Accordion-zx8gmww4.js} +9 -9
- package/web-dist/components/accordion/Accordion.js +10 -10
- package/web-dist/components/accordion-item/AccordionItem.js +10 -10
- package/web-dist/components/activity-indicator/ActivityIndicator.js +3 -3
- package/web-dist/components/app-bar/AppBar.js +15 -16
- package/web-dist/components/app-header/AppHeader.js +15 -16
- package/web-dist/components/app-shell/AppShell.js +4 -4
- package/web-dist/components/auth-screen/AuthScreen.js +20 -21
- package/web-dist/components/avatar/Avatar.js +10 -10
- package/web-dist/components/avatar-group/AvatarGroup.js +10 -10
- package/web-dist/components/badge/Badge.js +5 -5
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +18 -19
- package/web-dist/components/bottom-sheet/BottomSheet.js +6 -6
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +6 -6
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +6 -6
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +6 -6
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +6 -6
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +6 -6
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +15 -16
- package/web-dist/components/button/Button.js +13 -14
- package/web-dist/components/button-group/ButtonGroup.js +11 -12
- package/web-dist/components/calendar/Calendar.js +12 -13
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +18 -19
- package/web-dist/components/card/Card.js +17 -18
- package/web-dist/components/card-back/CardBack.js +4 -4
- package/web-dist/components/card-hand/CardHand.js +4 -4
- package/web-dist/components/carousel/Carousel.js +2 -2
- package/web-dist/components/chat-list-item/ChatListItem.js +14 -14
- package/web-dist/components/checkbox/Checkbox.js +10 -10
- package/web-dist/components/checkbox-group/CheckboxGroup.js +10 -10
- package/web-dist/components/chess-board/ChessBoard.js +4 -4
- package/web-dist/components/chip/Chip.js +11 -11
- package/web-dist/components/chip-group/ChipGroup.js +11 -11
- package/web-dist/components/collection-editor/CollectionEditor.js +21 -22
- package/web-dist/components/color-hue-scale/ColorHueScale.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +2 -0
- package/web-dist/components/color-tone/ColorTone.js +15 -14
- package/web-dist/components/color-wheel/ColorWheel.js +15 -14
- package/web-dist/components/content-rail/ContentRail.js +13 -14
- package/web-dist/components/data-table/DataTable.js +27 -28
- package/web-dist/components/date-picker/DatePicker.js +19 -20
- package/web-dist/components/dialog/Dialog.js +9 -9
- package/web-dist/components/divider/Divider.js +4 -4
- package/web-dist/components/empty-state/EmptyState.js +18 -19
- package/web-dist/components/explorer/Explorer.js +11 -11
- package/web-dist/components/field/Field.js +10 -10
- package/web-dist/components/file-explorer/FileExplorer.js +11 -11
- package/web-dist/components/flat-list/FlatList.js +11 -11
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +20 -21
- package/web-dist/components/form/Form.js +14 -15
- package/web-dist/components/form-actions/FormActions.js +14 -15
- package/web-dist/components/form-error/FormError.js +14 -15
- package/web-dist/components/game/Game.js +5 -5
- package/web-dist/components/game-entity/GameEntity.js +5 -5
- package/web-dist/components/game-field/GameField.js +5 -5
- package/web-dist/components/game-input-zone/GameInputZone.js +5 -5
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +5 -5
- package/web-dist/components/game-overlay/GameOverlay.js +5 -5
- package/web-dist/components/gradient/Gradient.js +5 -5
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +5 -5
- package/web-dist/components/graph-view/GraphView.js +9 -2
- package/web-dist/components/grid/Grid.js +4 -4
- package/web-dist/components/grid-line-overlay/GridLineOverlay.js +4 -4
- package/web-dist/components/grid-ruler/GridRuler.js +4 -4
- package/web-dist/components/heading/Heading.js +5 -5
- package/web-dist/components/hero/Hero.js +20 -21
- package/web-dist/components/icon/Icon.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +11 -12
- package/web-dist/components/image/Image.js +8 -8
- package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +3 -3
- package/web-dist/components/list/List.js +11 -11
- package/web-dist/components/list-item/ListItem.js +11 -11
- package/web-dist/components/list-section/ListSection.js +11 -11
- package/web-dist/components/master-detail/MasterDetail.js +4 -4
- package/web-dist/components/matrix-grid/MatrixGrid.js +4 -4
- package/web-dist/components/media-card/MediaCard.js +17 -18
- package/web-dist/components/media-explorer/MediaExplorer.js +11 -11
- package/web-dist/components/message-bubble/MessageBubble.js +14 -14
- package/web-dist/components/metric-card/MetricCard.js +17 -18
- package/web-dist/components/missing-element/MissingElement.js +9 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +20 -21
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +20 -21
- package/web-dist/components/opening-book/OpeningBook.js +4 -4
- package/web-dist/components/otp-form/OtpForm.js +20 -21
- package/web-dist/components/pagination/Pagination.js +18 -19
- package/web-dist/components/palette-item/PaletteItem.js +17 -18
- package/web-dist/components/playing-card/PlayingCard.js +4 -4
- package/web-dist/components/poker-training-table/PokerTrainingTable.js +4 -4
- package/web-dist/components/popover-menu/PopoverMenu.js +10 -10
- package/web-dist/components/post-card/PostCard.js +17 -18
- package/web-dist/components/product-card/ProductCard.js +17 -18
- package/web-dist/components/progress/Progress.js +8 -8
- package/web-dist/components/progress-ring/ProgressRing.js +8 -8
- package/web-dist/components/radio/Radio.js +12 -12
- package/web-dist/components/radio-group/RadioGroup.js +12 -12
- package/web-dist/components/rating/Rating.js +7 -7
- package/web-dist/components/reader/Reader.js +20 -21
- package/web-dist/components/scan-overlay/ScanOverlay.js +18 -19
- package/web-dist/components/screen/Screen.js +4 -4
- package/web-dist/components/screen-section/ScreenSection.js +8 -8
- package/web-dist/components/scroll-view/ScrollView.js +4 -4
- package/web-dist/components/search-input/SearchInput.js +12 -13
- package/web-dist/components/section-header/SectionHeader.js +8 -8
- package/web-dist/components/section-list/SectionList.js +11 -11
- package/web-dist/components/select/Select.js +16 -17
- package/web-dist/components/selectable-item/SelectableItem.js +3 -3
- package/web-dist/components/selection-provider/SelectionProvider.js +3 -3
- package/web-dist/components/sign-in-form/SignInForm.js +20 -21
- package/web-dist/components/sign-up-form/SignUpForm.js +20 -21
- package/web-dist/components/skeleton/Skeleton.js +20 -21
- package/web-dist/components/skeleton-card/SkeletonCard.js +20 -21
- package/web-dist/components/skeleton-list/SkeletonList.js +20 -21
- package/web-dist/components/skeleton-text/SkeletonText.js +20 -21
- package/web-dist/components/surface/Surface.js +5 -5
- package/web-dist/components/switch/Switch.js +5 -5
- package/web-dist/components/tab/Tab.js +5 -5
- package/web-dist/components/tab-list/TabList.js +5 -5
- package/web-dist/components/tab-panel/TabPanel.js +5 -5
- package/web-dist/components/tabletop-table/TabletopTable.js +4 -4
- package/web-dist/components/tabs/Tabs.js +5 -5
- package/web-dist/components/text/Text.js +5 -5
- package/web-dist/components/text-input/TextInput.js +12 -13
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +12 -13
- package/web-dist/components/time-picker/TimePicker.js +19 -20
- package/web-dist/components/timeline/Timeline.js +10 -10
- package/web-dist/components/toast/Toast.js +7 -7
- package/web-dist/components/toast-provider/ToastProvider.js +7 -7
- package/web-dist/components/toolbar/Toolbar.js +17 -18
- package/web-dist/components/tree-item/TreeItem.js +17 -18
- package/web-dist/components/uploader/Uploader.js +26 -27
- package/web-dist/components/view/View.js +4 -4
- package/web-dist/manifest.json +1417 -1459
- package/web-dist/runtime/ZoraProvider.js +6 -6
- package/web-dist/chunks/Accordion-fjnb7anx.js +0 -548
- package/web-dist/chunks/Accordion-ztcmb44y.js +0 -3928
- package/web-dist/chunks/{Accordion-ng79nxzz.js → Accordion-an5prgty.js} +18 -18
|
@@ -0,0 +1,1074 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
isHexColor,
|
|
4
|
+
parseHexColorOrThrow,
|
|
5
|
+
converter_default,
|
|
6
|
+
formatHex,
|
|
7
|
+
generateHarmonyRoleColors,
|
|
8
|
+
generateColorSwatch
|
|
9
|
+
} from "./Accordion-an5prgty.js";
|
|
10
|
+
import {
|
|
11
|
+
Pressable
|
|
12
|
+
} from "./Accordion-rzf52xq8.js";
|
|
13
|
+
import {
|
|
14
|
+
withZoraThemeScope
|
|
15
|
+
} from "./Accordion-e5jr9ahb.js";
|
|
16
|
+
import {
|
|
17
|
+
View2
|
|
18
|
+
} from "./Accordion-qhn8z92r.js";
|
|
19
|
+
import {
|
|
20
|
+
Text3
|
|
21
|
+
} from "./Accordion-aws0caav.js";
|
|
22
|
+
import {
|
|
23
|
+
TextInput3
|
|
24
|
+
} from "./Accordion-6yv4beha.js";
|
|
25
|
+
import {
|
|
26
|
+
Icon2
|
|
27
|
+
} from "./Accordion-1etqb3cj.js";
|
|
28
|
+
import {
|
|
29
|
+
Button2,
|
|
30
|
+
Circle,
|
|
31
|
+
Defs,
|
|
32
|
+
Line,
|
|
33
|
+
LinearGradient,
|
|
34
|
+
Path,
|
|
35
|
+
Polygon,
|
|
36
|
+
RadialGradient,
|
|
37
|
+
Rect,
|
|
38
|
+
Stop,
|
|
39
|
+
Svg,
|
|
40
|
+
IconButton2
|
|
41
|
+
} from "./Accordion-0kr0h68p.js";
|
|
42
|
+
import {
|
|
43
|
+
Tab2,
|
|
44
|
+
TabList2,
|
|
45
|
+
TabPanel2,
|
|
46
|
+
Tabs2
|
|
47
|
+
} from "./Accordion-3jkeydhb.js";
|
|
48
|
+
import {
|
|
49
|
+
useZoraTheme2
|
|
50
|
+
} from "./Accordion-c3nna2bz.js";
|
|
51
|
+
|
|
52
|
+
// src/features/color/ColorHexField.tsx
|
|
53
|
+
import React from "react";
|
|
54
|
+
import { jsx } from "react/jsx-runtime";
|
|
55
|
+
function ColorHexField({
|
|
56
|
+
disabled,
|
|
57
|
+
onChange,
|
|
58
|
+
value
|
|
59
|
+
}) {
|
|
60
|
+
const [input, setInput] = React.useState(value);
|
|
61
|
+
const { theme } = useZoraTheme2();
|
|
62
|
+
return /* @__PURE__ */ jsx(TextInput3, {
|
|
63
|
+
accessibilityLabel: "Color hex value",
|
|
64
|
+
disabled,
|
|
65
|
+
leadingAccessory: /* @__PURE__ */ jsx(View2, {
|
|
66
|
+
bg: value,
|
|
67
|
+
borderColor: theme.semantics.border.default,
|
|
68
|
+
borderWidth: 1,
|
|
69
|
+
height: 30,
|
|
70
|
+
radius: "s",
|
|
71
|
+
width: 30
|
|
72
|
+
}),
|
|
73
|
+
onChangeText: (nextValue) => {
|
|
74
|
+
setInput(nextValue);
|
|
75
|
+
if (isHexColor(nextValue))
|
|
76
|
+
onChange(nextValue);
|
|
77
|
+
},
|
|
78
|
+
trailingAccessory: /* @__PURE__ */ jsx(Icon2, {
|
|
79
|
+
color: "textMuted",
|
|
80
|
+
name: "copy-outline",
|
|
81
|
+
size: "m"
|
|
82
|
+
}),
|
|
83
|
+
value: input
|
|
84
|
+
}, value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/features/color/ColorSpectrumSlider.tsx
|
|
88
|
+
import React3 from "react";
|
|
89
|
+
|
|
90
|
+
// src/features/color/ColorHorizontalPointerProxy.web.tsx
|
|
91
|
+
import React2 from "react";
|
|
92
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
93
|
+
function ColorHorizontalPointerProxy({
|
|
94
|
+
children,
|
|
95
|
+
disabled,
|
|
96
|
+
onChange,
|
|
97
|
+
width
|
|
98
|
+
}) {
|
|
99
|
+
const dragging = React2.useRef(false);
|
|
100
|
+
const changeAt = (event) => {
|
|
101
|
+
const target = event.currentTarget;
|
|
102
|
+
const rect = target.getBoundingClientRect();
|
|
103
|
+
onChange((event.clientX - rect.left) / rect.width * width);
|
|
104
|
+
};
|
|
105
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
106
|
+
onMouseDown: (event) => {
|
|
107
|
+
if (disabled)
|
|
108
|
+
return;
|
|
109
|
+
dragging.current = true;
|
|
110
|
+
changeAt(event);
|
|
111
|
+
},
|
|
112
|
+
onMouseMove: (event) => {
|
|
113
|
+
if (!disabled && dragging.current)
|
|
114
|
+
changeAt(event);
|
|
115
|
+
},
|
|
116
|
+
onMouseUp: (event) => {
|
|
117
|
+
if (!disabled && dragging.current)
|
|
118
|
+
changeAt(event);
|
|
119
|
+
dragging.current = false;
|
|
120
|
+
},
|
|
121
|
+
style: { touchAction: "none" },
|
|
122
|
+
children
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// src/features/color/utils/resolveOklchColor.ts
|
|
126
|
+
function resolveOklchColor(target, hue) {
|
|
127
|
+
const formatted = formatHex({ mode: "oklch", l: target.lightness, c: target.chroma, h: hue });
|
|
128
|
+
if (!formatted)
|
|
129
|
+
throw new Error("The supplied OKLCH target cannot be represented as a hex color.");
|
|
130
|
+
return parseHexColorOrThrow(formatted);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/features/color/ColorSpectrumSlider.tsx
|
|
134
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
135
|
+
var SPECTRUM_WIDTH = 280;
|
|
136
|
+
var SPECTRUM_HUES = [0, 60, 120, 180, 240, 300, 360];
|
|
137
|
+
function ColorSpectrumSlider({
|
|
138
|
+
disabled,
|
|
139
|
+
hue,
|
|
140
|
+
label = "Hue",
|
|
141
|
+
onChange
|
|
142
|
+
}) {
|
|
143
|
+
const { theme } = useZoraTheme2();
|
|
144
|
+
const [trackWidth, setTrackWidth] = React3.useState(SPECTRUM_WIDTH);
|
|
145
|
+
const gradientId = `color-spectrum-${React3.useId().replaceAll(":", "")}`;
|
|
146
|
+
const changeAt = (locationX) => {
|
|
147
|
+
if (!disabled)
|
|
148
|
+
onChange(Math.max(0, Math.min(360, locationX / trackWidth * 360)));
|
|
149
|
+
};
|
|
150
|
+
return /* @__PURE__ */ jsxs(View2, {
|
|
151
|
+
gap: "xxs",
|
|
152
|
+
width: "100%",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsxs(View2, {
|
|
155
|
+
direction: "row",
|
|
156
|
+
justify: "space-between",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx3(Text3, {
|
|
159
|
+
variant: "label",
|
|
160
|
+
children: label
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ jsx3(Text3, {
|
|
163
|
+
variant: "label",
|
|
164
|
+
children: `${Math.round(hue)}°`
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ jsx3(ColorHorizontalPointerProxy, {
|
|
169
|
+
disabled,
|
|
170
|
+
onChange: changeAt,
|
|
171
|
+
width: SPECTRUM_WIDTH,
|
|
172
|
+
children: /* @__PURE__ */ jsxs(Svg, {
|
|
173
|
+
accessibilityLabel: `${label} spectrum`,
|
|
174
|
+
height: 36,
|
|
175
|
+
onLayout: (event) => setTrackWidth(Math.max(1, event.nativeEvent.layout.width)),
|
|
176
|
+
viewBox: `0 0 ${SPECTRUM_WIDTH} 36`,
|
|
177
|
+
width: "100%",
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx3(Defs, {
|
|
180
|
+
children: /* @__PURE__ */ jsx3(LinearGradient, {
|
|
181
|
+
id: gradientId,
|
|
182
|
+
x1: "0",
|
|
183
|
+
x2: "1",
|
|
184
|
+
y1: "0",
|
|
185
|
+
y2: "0",
|
|
186
|
+
children: SPECTRUM_HUES.map((stopHue, index) => /* @__PURE__ */ jsx3(Stop, {
|
|
187
|
+
offset: String(index / (SPECTRUM_HUES.length - 1)),
|
|
188
|
+
stopColor: resolveOklchColor({ lightness: 0.65, chroma: 0.2 }, stopHue)
|
|
189
|
+
}, stopHue))
|
|
190
|
+
})
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx3(Rect, {
|
|
193
|
+
fill: `url(#${gradientId})`,
|
|
194
|
+
height: 12,
|
|
195
|
+
rx: 6,
|
|
196
|
+
width: SPECTRUM_WIDTH,
|
|
197
|
+
y: 12
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ jsx3(Circle, {
|
|
200
|
+
cx: hue / 360 * SPECTRUM_WIDTH,
|
|
201
|
+
cy: 18,
|
|
202
|
+
fill: "white",
|
|
203
|
+
r: 10,
|
|
204
|
+
stroke: theme.semantics.content.default,
|
|
205
|
+
strokeWidth: 2
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ jsx3(Rect, {
|
|
208
|
+
fill: "transparent",
|
|
209
|
+
height: 36,
|
|
210
|
+
onResponderGrant: (event) => changeAt(event.nativeEvent.locationX),
|
|
211
|
+
onResponderMove: (event) => changeAt(event.nativeEvent.locationX),
|
|
212
|
+
onResponderRelease: (event) => changeAt(event.nativeEvent.locationX),
|
|
213
|
+
onStartShouldSetResponder: () => !disabled,
|
|
214
|
+
width: SPECTRUM_WIDTH
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/features/color/utils/resolveColorAtHue.ts
|
|
224
|
+
var toOklch = converter_default("oklch");
|
|
225
|
+
function resolveColorAtHue(color, hue) {
|
|
226
|
+
const parsed = toOklch(color);
|
|
227
|
+
if (!parsed || typeof parsed.l !== "number" || typeof parsed.c !== "number")
|
|
228
|
+
return color;
|
|
229
|
+
const formatted = formatHex({ mode: "oklch", l: parsed.l, c: parsed.c, h: hue });
|
|
230
|
+
return formatted ? parseHexColorOrThrow(formatted) : color;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/features/color/utils/resolveColorHue.ts
|
|
234
|
+
var toOklch2 = converter_default("oklch");
|
|
235
|
+
function resolveColorHue(color) {
|
|
236
|
+
const parsed = toOklch2(color);
|
|
237
|
+
return typeof parsed?.h === "number" ? parsed.h : 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/features/color/ColorHueScale.tsx
|
|
241
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
242
|
+
var ColorHueScale2 = withZoraThemeScope(ColorHueScaleInner);
|
|
243
|
+
function ColorHueScaleInner({
|
|
244
|
+
themeId: _themeId,
|
|
245
|
+
mode: _mode,
|
|
246
|
+
inverted: _inverted,
|
|
247
|
+
interactionPolicy,
|
|
248
|
+
value,
|
|
249
|
+
onChange,
|
|
250
|
+
testID
|
|
251
|
+
}) {
|
|
252
|
+
const { theme } = useZoraTheme2();
|
|
253
|
+
const { swatch } = generateColorSwatch(value);
|
|
254
|
+
const swatches = Object.entries(swatch);
|
|
255
|
+
return /* @__PURE__ */ jsxs2(View2, {
|
|
256
|
+
gap: "m",
|
|
257
|
+
testID,
|
|
258
|
+
children: [
|
|
259
|
+
/* @__PURE__ */ jsx4(ColorSpectrumSlider, {
|
|
260
|
+
disabled: interactionPolicy === "passive",
|
|
261
|
+
hue: resolveColorHue(value),
|
|
262
|
+
onChange: (nextHue) => onChange(resolveColorAtHue(value, nextHue))
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ jsx4(Text3, {
|
|
265
|
+
variant: "label",
|
|
266
|
+
children: "Intensity"
|
|
267
|
+
}),
|
|
268
|
+
/* @__PURE__ */ jsx4(View2, {
|
|
269
|
+
accessibilityLabel: "Color scale previews; choose a preview as the next 500 base color",
|
|
270
|
+
direction: "row",
|
|
271
|
+
gap: "xs",
|
|
272
|
+
wrap: "wrap",
|
|
273
|
+
children: swatches.map(([step, color]) => /* @__PURE__ */ jsx4(Pressable, {
|
|
274
|
+
accessibilityLabel: Number(step) === 500 ? `Current editable base color 500: ${color}` : `Use generated ${step} preview ${color} as the next base color 500`,
|
|
275
|
+
bg: color,
|
|
276
|
+
borderColor: theme.semantics.border.default,
|
|
277
|
+
borderWidth: Number(step) === 500 ? 3 : 1,
|
|
278
|
+
disabled: interactionPolicy === "passive",
|
|
279
|
+
height: 48,
|
|
280
|
+
onPress: () => onChange(color),
|
|
281
|
+
radius: "s",
|
|
282
|
+
width: "18%",
|
|
283
|
+
children: /* @__PURE__ */ jsx4(Text3, {
|
|
284
|
+
align: "center",
|
|
285
|
+
variant: "caption",
|
|
286
|
+
children: step
|
|
287
|
+
})
|
|
288
|
+
}, step))
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx4(ColorHexField, {
|
|
291
|
+
disabled: interactionPolicy === "passive",
|
|
292
|
+
onChange,
|
|
293
|
+
value
|
|
294
|
+
}, value)
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/features/color/ColorTone.tsx
|
|
300
|
+
import React5 from "react";
|
|
301
|
+
|
|
302
|
+
// src/features/color/ColorWheelPointerProxy.web.tsx
|
|
303
|
+
import React4 from "react";
|
|
304
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
305
|
+
function ColorWheelPointerProxy({
|
|
306
|
+
children,
|
|
307
|
+
disabled,
|
|
308
|
+
height,
|
|
309
|
+
onChange,
|
|
310
|
+
width
|
|
311
|
+
}) {
|
|
312
|
+
const dragging = React4.useRef(false);
|
|
313
|
+
const changeAt = (event) => {
|
|
314
|
+
const target = event.currentTarget;
|
|
315
|
+
const rect = target.getBoundingClientRect();
|
|
316
|
+
onChange((event.clientX - rect.left) / rect.width * width, (event.clientY - rect.top) / rect.height * height);
|
|
317
|
+
};
|
|
318
|
+
return /* @__PURE__ */ jsx5("div", {
|
|
319
|
+
onMouseDown: (event) => {
|
|
320
|
+
if (disabled)
|
|
321
|
+
return;
|
|
322
|
+
dragging.current = true;
|
|
323
|
+
changeAt(event);
|
|
324
|
+
},
|
|
325
|
+
onMouseMove: (event) => {
|
|
326
|
+
if (!disabled && dragging.current)
|
|
327
|
+
changeAt(event);
|
|
328
|
+
},
|
|
329
|
+
onMouseUp: (event) => {
|
|
330
|
+
if (!disabled && dragging.current)
|
|
331
|
+
changeAt(event);
|
|
332
|
+
dragging.current = false;
|
|
333
|
+
},
|
|
334
|
+
style: { touchAction: "none" },
|
|
335
|
+
children
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/features/color/utils/resolveWheelColorComponents.ts
|
|
340
|
+
var toOklch3 = converter_default("oklch");
|
|
341
|
+
function resolveWheelColorComponents(color) {
|
|
342
|
+
const parsed = toOklch3(color);
|
|
343
|
+
return {
|
|
344
|
+
chroma: typeof parsed?.c === "number" ? parsed.c : 0,
|
|
345
|
+
lightness: typeof parsed?.l === "number" ? parsed.l : 0.65
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// src/features/color/ColorTone.tsx
|
|
350
|
+
import { jsx as jsx6, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
|
|
351
|
+
var MAX_TONE_COLORS = 4;
|
|
352
|
+
var TONE_MAP_WIDTH = 280;
|
|
353
|
+
var TONE_MAP_HEIGHT = 220;
|
|
354
|
+
var TONE_MAX_CHROMA = 0.2;
|
|
355
|
+
var ColorTone2 = withZoraThemeScope(ColorToneInner);
|
|
356
|
+
function ColorToneInner({
|
|
357
|
+
themeId: _themeId,
|
|
358
|
+
mode: _mode,
|
|
359
|
+
inverted: _inverted,
|
|
360
|
+
interactionPolicy,
|
|
361
|
+
tones,
|
|
362
|
+
selectionMode = "single",
|
|
363
|
+
value,
|
|
364
|
+
onChange,
|
|
365
|
+
testID
|
|
366
|
+
}) {
|
|
367
|
+
const { theme } = useZoraTheme2();
|
|
368
|
+
const [editingColorIndex, setEditingColorIndex] = React5.useState(0);
|
|
369
|
+
const selectedTone = tones.find((tone) => tone.id === value?.toneId);
|
|
370
|
+
const colors = value ? selectionMode === "single" ? value.colors.slice(0, 1) : value.colors.slice(0, MAX_TONE_COLORS) : [];
|
|
371
|
+
const currentEditingColorIndex = Math.min(editingColorIndex, Math.max(0, colors.length - 1));
|
|
372
|
+
const selectedColor = colors.at(currentEditingColorIndex);
|
|
373
|
+
const selectTone = (tone) => {
|
|
374
|
+
const hue = selectedColor ? resolveColorHue(selectedColor) : 0;
|
|
375
|
+
setEditingColorIndex(0);
|
|
376
|
+
onChange({ toneId: tone.id, colors: [resolveOklchColor(tone.accentTarget, hue)] });
|
|
377
|
+
};
|
|
378
|
+
return /* @__PURE__ */ jsxs3(View2, {
|
|
379
|
+
gap: "m",
|
|
380
|
+
testID,
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ jsxs3(View2, {
|
|
383
|
+
gap: "xs",
|
|
384
|
+
children: [
|
|
385
|
+
/* @__PURE__ */ jsx6(Text3, {
|
|
386
|
+
variant: "label",
|
|
387
|
+
children: "Tone"
|
|
388
|
+
}),
|
|
389
|
+
/* @__PURE__ */ jsx6(Text3, {
|
|
390
|
+
emphasis: "muted",
|
|
391
|
+
variant: "caption",
|
|
392
|
+
children: "Choose a catalog tone"
|
|
393
|
+
})
|
|
394
|
+
]
|
|
395
|
+
}),
|
|
396
|
+
/* @__PURE__ */ jsx6(View2, {
|
|
397
|
+
direction: "row",
|
|
398
|
+
gap: "s",
|
|
399
|
+
wrap: "wrap",
|
|
400
|
+
children: tones.map((tone) => {
|
|
401
|
+
const selected = value?.toneId === tone.id;
|
|
402
|
+
const color = selected && selectedColor ? selectedColor : resolveOklchColor(tone.accentTarget, 0);
|
|
403
|
+
return /* @__PURE__ */ jsx6(Pressable, {
|
|
404
|
+
accessibilityLabel: tone.accent,
|
|
405
|
+
accessibilityRole: "radio",
|
|
406
|
+
accessibilityState: { checked: selected },
|
|
407
|
+
bg: color,
|
|
408
|
+
borderColor: theme.semantics.border.default,
|
|
409
|
+
borderWidth: selected ? 3 : 1,
|
|
410
|
+
disabled: interactionPolicy === "passive",
|
|
411
|
+
height: 56,
|
|
412
|
+
onPress: () => selectTone(tone),
|
|
413
|
+
radius: "m",
|
|
414
|
+
width: 56,
|
|
415
|
+
children: /* @__PURE__ */ jsx6(Text3, {
|
|
416
|
+
align: "center",
|
|
417
|
+
variant: "caption",
|
|
418
|
+
children: tone.accent
|
|
419
|
+
})
|
|
420
|
+
}, tone.id);
|
|
421
|
+
})
|
|
422
|
+
}),
|
|
423
|
+
selectedTone && selectedColor && value ? /* @__PURE__ */ jsxs3(Fragment, {
|
|
424
|
+
children: [
|
|
425
|
+
/* @__PURE__ */ jsx6(ColorToneMap, {
|
|
426
|
+
color: selectedColor,
|
|
427
|
+
disabled: interactionPolicy === "passive",
|
|
428
|
+
onChange: (lightness, chroma) => onChange({
|
|
429
|
+
toneId: selectedTone.id,
|
|
430
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex ? resolveOklchColor({ chroma, lightness }, resolveColorHue(entry)) : entry)
|
|
431
|
+
})
|
|
432
|
+
}),
|
|
433
|
+
/* @__PURE__ */ jsxs3(View2, {
|
|
434
|
+
direction: "row",
|
|
435
|
+
gap: "xs",
|
|
436
|
+
wrap: "wrap",
|
|
437
|
+
children: [
|
|
438
|
+
colors.map((color, index) => /* @__PURE__ */ jsx6(Pressable, {
|
|
439
|
+
accessibilityLabel: `Selected ${selectedTone.accent} color ${index + 1}: ${color}`,
|
|
440
|
+
accessibilityRole: "radio",
|
|
441
|
+
accessibilityState: { checked: currentEditingColorIndex === index },
|
|
442
|
+
bg: color,
|
|
443
|
+
borderColor: theme.semantics.border.default,
|
|
444
|
+
borderWidth: currentEditingColorIndex === index ? 3 : 1,
|
|
445
|
+
disabled: interactionPolicy === "passive",
|
|
446
|
+
height: 44,
|
|
447
|
+
onPress: () => setEditingColorIndex(index),
|
|
448
|
+
radius: "m",
|
|
449
|
+
width: 44
|
|
450
|
+
}, `${color}-${index}`)),
|
|
451
|
+
selectionMode === "multiple" ? /* @__PURE__ */ jsx6(Button2, {
|
|
452
|
+
disabled: interactionPolicy === "passive" || colors.length >= MAX_TONE_COLORS,
|
|
453
|
+
onPress: () => {
|
|
454
|
+
setEditingColorIndex(colors.length);
|
|
455
|
+
onChange({
|
|
456
|
+
toneId: selectedTone.id,
|
|
457
|
+
colors: [...colors, resolveOklchColor(selectedTone.accentTarget, 0)]
|
|
458
|
+
});
|
|
459
|
+
},
|
|
460
|
+
children: "Add color"
|
|
461
|
+
}) : null,
|
|
462
|
+
selectionMode === "multiple" && colors.length > 1 ? /* @__PURE__ */ jsx6(Button2, {
|
|
463
|
+
disabled: interactionPolicy === "passive",
|
|
464
|
+
onPress: () => {
|
|
465
|
+
const nextColors = colors.filter((_, index) => index !== currentEditingColorIndex);
|
|
466
|
+
setEditingColorIndex(Math.min(currentEditingColorIndex, nextColors.length - 1));
|
|
467
|
+
onChange({ toneId: selectedTone.id, colors: nextColors });
|
|
468
|
+
},
|
|
469
|
+
children: "Remove color"
|
|
470
|
+
}) : null
|
|
471
|
+
]
|
|
472
|
+
}),
|
|
473
|
+
/* @__PURE__ */ jsx6(ColorSpectrumSlider, {
|
|
474
|
+
disabled: interactionPolicy === "passive",
|
|
475
|
+
hue: resolveColorHue(selectedColor),
|
|
476
|
+
onChange: (nextHue) => onChange({
|
|
477
|
+
toneId: selectedTone.id,
|
|
478
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex ? resolveOklchColor(selectedTone.accentTarget, nextHue) : entry)
|
|
479
|
+
})
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsx6(ColorHexField, {
|
|
482
|
+
disabled: interactionPolicy === "passive",
|
|
483
|
+
onChange: (color) => onChange({
|
|
484
|
+
toneId: selectedTone.id,
|
|
485
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex ? color : entry)
|
|
486
|
+
}),
|
|
487
|
+
value: selectedColor
|
|
488
|
+
}, selectedColor)
|
|
489
|
+
]
|
|
490
|
+
}) : null
|
|
491
|
+
]
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
function ColorToneMap({
|
|
495
|
+
color,
|
|
496
|
+
disabled,
|
|
497
|
+
onChange
|
|
498
|
+
}) {
|
|
499
|
+
const hue = resolveColorHue(color);
|
|
500
|
+
const { chroma, lightness } = resolveWheelColorComponents(color);
|
|
501
|
+
const gradientId = `color-tone-${React5.useId().replaceAll(":", "")}`;
|
|
502
|
+
const changeAt = (x, y) => {
|
|
503
|
+
if (disabled)
|
|
504
|
+
return;
|
|
505
|
+
onChange(Math.max(0, Math.min(1, 1 - y / TONE_MAP_HEIGHT)), Math.max(0, Math.min(TONE_MAX_CHROMA, x / TONE_MAP_WIDTH * TONE_MAX_CHROMA)));
|
|
506
|
+
};
|
|
507
|
+
return /* @__PURE__ */ jsx6(ColorWheelPointerProxy, {
|
|
508
|
+
disabled,
|
|
509
|
+
height: TONE_MAP_HEIGHT,
|
|
510
|
+
onChange: changeAt,
|
|
511
|
+
width: TONE_MAP_WIDTH,
|
|
512
|
+
children: /* @__PURE__ */ jsxs3(Svg, {
|
|
513
|
+
accessibilityLabel: "Tone color plane",
|
|
514
|
+
height: TONE_MAP_HEIGHT,
|
|
515
|
+
width: TONE_MAP_WIDTH,
|
|
516
|
+
children: [
|
|
517
|
+
/* @__PURE__ */ jsxs3(Defs, {
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ jsxs3(LinearGradient, {
|
|
520
|
+
id: `${gradientId}-white`,
|
|
521
|
+
x1: "0",
|
|
522
|
+
x2: "1",
|
|
523
|
+
y1: "0",
|
|
524
|
+
y2: "0",
|
|
525
|
+
children: [
|
|
526
|
+
/* @__PURE__ */ jsx6(Stop, {
|
|
527
|
+
offset: "0",
|
|
528
|
+
stopColor: "white"
|
|
529
|
+
}),
|
|
530
|
+
/* @__PURE__ */ jsx6(Stop, {
|
|
531
|
+
offset: "1",
|
|
532
|
+
stopColor: resolveOklchColor({ chroma: TONE_MAX_CHROMA, lightness: 0.65 }, hue)
|
|
533
|
+
})
|
|
534
|
+
]
|
|
535
|
+
}),
|
|
536
|
+
/* @__PURE__ */ jsxs3(LinearGradient, {
|
|
537
|
+
id: `${gradientId}-black`,
|
|
538
|
+
x1: "0",
|
|
539
|
+
x2: "0",
|
|
540
|
+
y1: "0",
|
|
541
|
+
y2: "1",
|
|
542
|
+
children: [
|
|
543
|
+
/* @__PURE__ */ jsx6(Stop, {
|
|
544
|
+
offset: "0",
|
|
545
|
+
stopColor: "transparent"
|
|
546
|
+
}),
|
|
547
|
+
/* @__PURE__ */ jsx6(Stop, {
|
|
548
|
+
offset: "1",
|
|
549
|
+
stopColor: "black"
|
|
550
|
+
})
|
|
551
|
+
]
|
|
552
|
+
})
|
|
553
|
+
]
|
|
554
|
+
}),
|
|
555
|
+
/* @__PURE__ */ jsx6(Rect, {
|
|
556
|
+
fill: `url(#${gradientId}-white)`,
|
|
557
|
+
height: TONE_MAP_HEIGHT,
|
|
558
|
+
width: TONE_MAP_WIDTH
|
|
559
|
+
}),
|
|
560
|
+
/* @__PURE__ */ jsx6(Rect, {
|
|
561
|
+
fill: `url(#${gradientId}-black)`,
|
|
562
|
+
height: TONE_MAP_HEIGHT,
|
|
563
|
+
width: TONE_MAP_WIDTH
|
|
564
|
+
}),
|
|
565
|
+
/* @__PURE__ */ jsx6(Circle, {
|
|
566
|
+
cx: chroma / TONE_MAX_CHROMA * TONE_MAP_WIDTH,
|
|
567
|
+
cy: (1 - lightness) * TONE_MAP_HEIGHT,
|
|
568
|
+
fill: "none",
|
|
569
|
+
r: 10,
|
|
570
|
+
stroke: "white",
|
|
571
|
+
strokeWidth: 3
|
|
572
|
+
}),
|
|
573
|
+
/* @__PURE__ */ jsx6(Rect, {
|
|
574
|
+
fill: "transparent",
|
|
575
|
+
height: TONE_MAP_HEIGHT,
|
|
576
|
+
onResponderGrant: (event) => changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY),
|
|
577
|
+
onResponderMove: (event) => changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY),
|
|
578
|
+
onResponderRelease: (event) => changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY),
|
|
579
|
+
onStartShouldSetResponder: () => !disabled,
|
|
580
|
+
width: TONE_MAP_WIDTH
|
|
581
|
+
})
|
|
582
|
+
]
|
|
583
|
+
})
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// src/features/color/ColorWheel.tsx
|
|
588
|
+
import React6 from "react";
|
|
589
|
+
|
|
590
|
+
// src/features/color/ColorWheelKeyboardProxy.web.tsx
|
|
591
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
592
|
+
function ColorWheelKeyboardProxy({
|
|
593
|
+
children,
|
|
594
|
+
chroma,
|
|
595
|
+
disabled,
|
|
596
|
+
hue,
|
|
597
|
+
onChange
|
|
598
|
+
}) {
|
|
599
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
600
|
+
"aria-label": `Color wheel, hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`,
|
|
601
|
+
"aria-valuemax": 360,
|
|
602
|
+
"aria-valuemin": 0,
|
|
603
|
+
"aria-valuenow": Math.round(hue),
|
|
604
|
+
"aria-valuetext": `Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`,
|
|
605
|
+
"aria-disabled": disabled,
|
|
606
|
+
onKeyDown: (event) => {
|
|
607
|
+
const nextValue = resolveKeyboardWheelValue(event.key, hue, chroma);
|
|
608
|
+
if (!nextValue || disabled)
|
|
609
|
+
return;
|
|
610
|
+
event.preventDefault();
|
|
611
|
+
onChange(nextValue.hue, nextValue.chroma);
|
|
612
|
+
},
|
|
613
|
+
role: "slider",
|
|
614
|
+
tabIndex: disabled ? -1 : 0,
|
|
615
|
+
children
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
function resolveKeyboardWheelValue(key, hue, chroma) {
|
|
619
|
+
if (key === "ArrowLeft")
|
|
620
|
+
return { chroma, hue: normalizeHue(hue - 5) };
|
|
621
|
+
if (key === "ArrowRight")
|
|
622
|
+
return { chroma, hue: normalizeHue(hue + 5) };
|
|
623
|
+
if (key === "ArrowDown")
|
|
624
|
+
return { chroma: Math.max(0, chroma - 0.02), hue };
|
|
625
|
+
if (key === "ArrowUp")
|
|
626
|
+
return { chroma: Math.min(0.2, chroma + 0.02), hue };
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
function normalizeHue(hue) {
|
|
630
|
+
return hue < 0 ? hue + 360 : hue >= 360 ? hue - 360 : hue;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// src/features/color/utils/resolveWheelColor.ts
|
|
634
|
+
function resolveWheelColor(color, x, y, center, radius, maxChroma) {
|
|
635
|
+
const { lightness } = resolveWheelColorComponents(color);
|
|
636
|
+
const deltaX = x - center;
|
|
637
|
+
const deltaY = y - center;
|
|
638
|
+
const distance = Math.min(Math.hypot(deltaX, deltaY), radius);
|
|
639
|
+
const hue = normalizeHue2(Math.atan2(deltaY, deltaX) * 180 / Math.PI + 90);
|
|
640
|
+
const chroma = distance / radius * maxChroma;
|
|
641
|
+
return resolveOklchColor({ lightness, chroma }, hue);
|
|
642
|
+
}
|
|
643
|
+
function normalizeHue2(hue) {
|
|
644
|
+
return hue < 0 ? hue + 360 : hue;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// src/features/color/ColorWheel.tsx
|
|
648
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
649
|
+
var WHEEL_SIZE = 280;
|
|
650
|
+
var WHEEL_CENTER = WHEEL_SIZE / 2;
|
|
651
|
+
var WHEEL_RADIUS = 128;
|
|
652
|
+
var WHEEL_SEGMENT_COUNT = 72;
|
|
653
|
+
var WHEEL_MAX_CHROMA = 0.2;
|
|
654
|
+
var ColorWheel2 = withZoraThemeScope(ColorWheelInner);
|
|
655
|
+
function ColorWheelInner({
|
|
656
|
+
themeId: _themeId,
|
|
657
|
+
mode: _mode,
|
|
658
|
+
inverted: _inverted,
|
|
659
|
+
interactionPolicy,
|
|
660
|
+
value,
|
|
661
|
+
harmony = null,
|
|
662
|
+
harmonies,
|
|
663
|
+
onChange,
|
|
664
|
+
testID
|
|
665
|
+
}) {
|
|
666
|
+
const { theme } = useZoraTheme2();
|
|
667
|
+
const hue = resolveColorHue(value);
|
|
668
|
+
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
669
|
+
const harmonyColors = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];
|
|
670
|
+
const selectedPoint = resolveWheelPoint(hue, Math.min(1, chroma / WHEEL_MAX_CHROMA));
|
|
671
|
+
const harmonyPoints = harmonyColors.map((color) => resolveWheelPoint(color.hueDegrees));
|
|
672
|
+
const harmonyLines = resolveHarmonyLines(harmonyPoints, selectedPoint, theme.semantics.content.default);
|
|
673
|
+
const wheelGradientId = `color-wheel-${React6.useId().replaceAll(":", "")}`;
|
|
674
|
+
const changeColorAt = (x, y) => {
|
|
675
|
+
if (interactionPolicy === "passive")
|
|
676
|
+
return;
|
|
677
|
+
onChange({
|
|
678
|
+
color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),
|
|
679
|
+
harmony
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
const changeLightness = (nextLightness) => onChange({
|
|
683
|
+
color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, nextLightness)) }, hue),
|
|
684
|
+
harmony
|
|
685
|
+
});
|
|
686
|
+
return /* @__PURE__ */ jsxs4(View2, {
|
|
687
|
+
align: "center",
|
|
688
|
+
gap: "s",
|
|
689
|
+
testID,
|
|
690
|
+
children: [
|
|
691
|
+
/* @__PURE__ */ jsx8(ColorWheelKeyboardProxy, {
|
|
692
|
+
chroma,
|
|
693
|
+
disabled: interactionPolicy === "passive",
|
|
694
|
+
hue,
|
|
695
|
+
onChange: (nextHue, nextChroma) => onChange({
|
|
696
|
+
color: resolveOklchColor({ lightness: resolveWheelLightness(value), chroma: nextChroma }, nextHue),
|
|
697
|
+
harmony
|
|
698
|
+
}),
|
|
699
|
+
children: /* @__PURE__ */ jsx8(ColorWheelPointerProxy, {
|
|
700
|
+
disabled: interactionPolicy === "passive",
|
|
701
|
+
height: WHEEL_SIZE,
|
|
702
|
+
onChange: changeColorAt,
|
|
703
|
+
width: WHEEL_SIZE,
|
|
704
|
+
children: /* @__PURE__ */ jsxs4(Svg, {
|
|
705
|
+
accessibilityLabel: "Color wheel",
|
|
706
|
+
height: WHEEL_SIZE,
|
|
707
|
+
onResponderGrant: (event) => {
|
|
708
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
709
|
+
changeColorAt(locationX, locationY);
|
|
710
|
+
},
|
|
711
|
+
onResponderMove: (event) => {
|
|
712
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
713
|
+
changeColorAt(locationX, locationY);
|
|
714
|
+
},
|
|
715
|
+
onResponderRelease: (event) => {
|
|
716
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
717
|
+
changeColorAt(locationX, locationY);
|
|
718
|
+
},
|
|
719
|
+
onStartShouldSetResponder: () => interactionPolicy !== "passive",
|
|
720
|
+
width: WHEEL_SIZE,
|
|
721
|
+
children: [
|
|
722
|
+
/* @__PURE__ */ jsx8(Defs, {
|
|
723
|
+
children: resolveWheelSegments().map((segment) => /* @__PURE__ */ jsxs4(RadialGradient, {
|
|
724
|
+
cx: WHEEL_CENTER,
|
|
725
|
+
cy: WHEEL_CENTER,
|
|
726
|
+
id: `${wheelGradientId}-${segment.hue}`,
|
|
727
|
+
r: WHEEL_RADIUS,
|
|
728
|
+
children: [
|
|
729
|
+
/* @__PURE__ */ jsx8(Stop, {
|
|
730
|
+
offset: "0",
|
|
731
|
+
stopColor: resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)
|
|
732
|
+
}),
|
|
733
|
+
/* @__PURE__ */ jsx8(Stop, {
|
|
734
|
+
offset: "1",
|
|
735
|
+
stopColor: segment.color
|
|
736
|
+
})
|
|
737
|
+
]
|
|
738
|
+
}, segment.hue))
|
|
739
|
+
}),
|
|
740
|
+
resolveWheelSegments().map((segment) => /* @__PURE__ */ jsx8(Path, {
|
|
741
|
+
d: segment.path,
|
|
742
|
+
fill: `url(#${wheelGradientId}-${segment.hue})`
|
|
743
|
+
}, segment.hue)),
|
|
744
|
+
harmony === "triadic" && harmonyPoints.length === 3 ? /* @__PURE__ */ jsx8(Polygon, {
|
|
745
|
+
fill: "none",
|
|
746
|
+
points: harmonyPoints.map((point) => `${point.x},${point.y}`).join(" "),
|
|
747
|
+
stroke: theme.semantics.content.default,
|
|
748
|
+
strokeWidth: 2
|
|
749
|
+
}) : harmonyLines,
|
|
750
|
+
harmonyPoints.map((point) => /* @__PURE__ */ jsx8(Circle, {
|
|
751
|
+
cx: point.x,
|
|
752
|
+
cy: point.y,
|
|
753
|
+
fill: theme.semantics.content.default,
|
|
754
|
+
r: 5
|
|
755
|
+
}, `${point.x}-${point.y}`)),
|
|
756
|
+
/* @__PURE__ */ jsx8(Circle, {
|
|
757
|
+
cx: selectedPoint.x,
|
|
758
|
+
cy: selectedPoint.y,
|
|
759
|
+
fill: "none",
|
|
760
|
+
r: 9,
|
|
761
|
+
stroke: theme.semantics.content.default,
|
|
762
|
+
strokeWidth: 3
|
|
763
|
+
})
|
|
764
|
+
]
|
|
765
|
+
})
|
|
766
|
+
})
|
|
767
|
+
}),
|
|
768
|
+
/* @__PURE__ */ jsx8(ColorLightnessSlider, {
|
|
769
|
+
chroma,
|
|
770
|
+
disabled: interactionPolicy === "passive",
|
|
771
|
+
hue,
|
|
772
|
+
lightness,
|
|
773
|
+
onChange: changeLightness,
|
|
774
|
+
selectionBorderColor: theme.semantics.content.default
|
|
775
|
+
}),
|
|
776
|
+
/* @__PURE__ */ jsx8(ColorHexField, {
|
|
777
|
+
disabled: interactionPolicy === "passive",
|
|
778
|
+
onChange: (color) => onChange({ color, harmony }),
|
|
779
|
+
value
|
|
780
|
+
}, value),
|
|
781
|
+
harmonies ? /* @__PURE__ */ jsxs4(View2, {
|
|
782
|
+
direction: "row",
|
|
783
|
+
gap: "xs",
|
|
784
|
+
wrap: "wrap",
|
|
785
|
+
children: [
|
|
786
|
+
/* @__PURE__ */ jsx8(Button2, {
|
|
787
|
+
disabled: interactionPolicy === "passive",
|
|
788
|
+
onPress: () => onChange({ color: value, harmony: null }),
|
|
789
|
+
variant: harmony === null ? "solid" : "outline",
|
|
790
|
+
children: "None"
|
|
791
|
+
}),
|
|
792
|
+
harmonies.map((candidate) => /* @__PURE__ */ jsx8(Button2, {
|
|
793
|
+
disabled: interactionPolicy === "passive",
|
|
794
|
+
onPress: () => onChange({ color: value, harmony: candidate }),
|
|
795
|
+
variant: harmony === candidate ? "solid" : "outline",
|
|
796
|
+
children: candidate
|
|
797
|
+
}, candidate))
|
|
798
|
+
]
|
|
799
|
+
}) : null
|
|
800
|
+
]
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
function ColorLightnessSlider({
|
|
804
|
+
chroma,
|
|
805
|
+
disabled,
|
|
806
|
+
hue,
|
|
807
|
+
lightness,
|
|
808
|
+
onChange,
|
|
809
|
+
selectionBorderColor
|
|
810
|
+
}) {
|
|
811
|
+
const changeAt = (locationX) => {
|
|
812
|
+
if (!disabled)
|
|
813
|
+
onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));
|
|
814
|
+
};
|
|
815
|
+
return /* @__PURE__ */ jsxs4(View2, {
|
|
816
|
+
gap: "xxs",
|
|
817
|
+
width: WHEEL_SIZE,
|
|
818
|
+
children: [
|
|
819
|
+
/* @__PURE__ */ jsxs4(View2, {
|
|
820
|
+
direction: "row",
|
|
821
|
+
justify: "space-between",
|
|
822
|
+
children: [
|
|
823
|
+
/* @__PURE__ */ jsx8(Text3, {
|
|
824
|
+
variant: "label",
|
|
825
|
+
children: "Lightness"
|
|
826
|
+
}),
|
|
827
|
+
/* @__PURE__ */ jsx8(Text3, {
|
|
828
|
+
variant: "label",
|
|
829
|
+
children: `${Math.round(lightness * 100)}%`
|
|
830
|
+
})
|
|
831
|
+
]
|
|
832
|
+
}),
|
|
833
|
+
/* @__PURE__ */ jsx8(ColorHorizontalPointerProxy, {
|
|
834
|
+
disabled,
|
|
835
|
+
onChange: changeAt,
|
|
836
|
+
width: WHEEL_SIZE,
|
|
837
|
+
children: /* @__PURE__ */ jsxs4(Svg, {
|
|
838
|
+
accessibilityLabel: "Color lightness",
|
|
839
|
+
height: 36,
|
|
840
|
+
width: WHEEL_SIZE,
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ jsx8(Defs, {
|
|
843
|
+
children: /* @__PURE__ */ jsxs4(LinearGradient, {
|
|
844
|
+
id: "color-lightness",
|
|
845
|
+
x1: "0",
|
|
846
|
+
x2: "1",
|
|
847
|
+
y1: "0",
|
|
848
|
+
y2: "0",
|
|
849
|
+
children: [
|
|
850
|
+
/* @__PURE__ */ jsx8(Stop, {
|
|
851
|
+
offset: "0",
|
|
852
|
+
stopColor: resolveOklchColor({ chroma, lightness: 0 }, hue)
|
|
853
|
+
}),
|
|
854
|
+
/* @__PURE__ */ jsx8(Stop, {
|
|
855
|
+
offset: "1",
|
|
856
|
+
stopColor: resolveOklchColor({ chroma, lightness: 1 }, hue)
|
|
857
|
+
})
|
|
858
|
+
]
|
|
859
|
+
})
|
|
860
|
+
}),
|
|
861
|
+
/* @__PURE__ */ jsx8(Rect, {
|
|
862
|
+
fill: "url(#color-lightness)",
|
|
863
|
+
height: 10,
|
|
864
|
+
rx: 5,
|
|
865
|
+
y: 13,
|
|
866
|
+
width: WHEEL_SIZE
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ jsx8(Circle, {
|
|
869
|
+
cx: lightness * WHEEL_SIZE,
|
|
870
|
+
cy: 18,
|
|
871
|
+
fill: "white",
|
|
872
|
+
r: 10,
|
|
873
|
+
stroke: selectionBorderColor,
|
|
874
|
+
strokeWidth: 2
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ jsx8(Rect, {
|
|
877
|
+
fill: "transparent",
|
|
878
|
+
height: 36,
|
|
879
|
+
onResponderGrant: (event) => changeAt(event.nativeEvent.locationX),
|
|
880
|
+
onResponderMove: (event) => changeAt(event.nativeEvent.locationX),
|
|
881
|
+
onResponderRelease: (event) => changeAt(event.nativeEvent.locationX),
|
|
882
|
+
onStartShouldSetResponder: () => !disabled,
|
|
883
|
+
width: WHEEL_SIZE
|
|
884
|
+
})
|
|
885
|
+
]
|
|
886
|
+
})
|
|
887
|
+
})
|
|
888
|
+
]
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
function resolveWheelSegments() {
|
|
892
|
+
return Array.from({ length: WHEEL_SEGMENT_COUNT }, (_, index) => {
|
|
893
|
+
const hue = index * 360 / WHEEL_SEGMENT_COUNT;
|
|
894
|
+
return {
|
|
895
|
+
color: resolveOklchColor({ lightness: 0.65, chroma: WHEEL_MAX_CHROMA }, hue),
|
|
896
|
+
hue,
|
|
897
|
+
path: resolveSegmentPath(hue, hue + 360 / WHEEL_SEGMENT_COUNT)
|
|
898
|
+
};
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
function resolveSegmentPath(startHue, endHue) {
|
|
902
|
+
const start = resolveWheelPoint(startHue);
|
|
903
|
+
const end = resolveWheelPoint(endHue);
|
|
904
|
+
return `M ${WHEEL_CENTER} ${WHEEL_CENTER} L ${start.x} ${start.y} A ${WHEEL_RADIUS} ${WHEEL_RADIUS} 0 0 1 ${end.x} ${end.y} Z`;
|
|
905
|
+
}
|
|
906
|
+
function resolveWheelPoint(hue, radiusRatio = 1) {
|
|
907
|
+
const radians = (hue - 90) * Math.PI / 180;
|
|
908
|
+
return {
|
|
909
|
+
x: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.cos(radians),
|
|
910
|
+
y: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.sin(radians)
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function resolveHarmonyLines(points, selectedPoint, stroke) {
|
|
914
|
+
return points.slice(1).reduce(({ lines, previous }, point) => ({
|
|
915
|
+
lines: [
|
|
916
|
+
...lines,
|
|
917
|
+
/* @__PURE__ */ jsx8(Line, {
|
|
918
|
+
stroke,
|
|
919
|
+
strokeWidth: 2,
|
|
920
|
+
x1: previous.x,
|
|
921
|
+
x2: point.x,
|
|
922
|
+
y1: previous.y,
|
|
923
|
+
y2: point.y
|
|
924
|
+
}, `${previous.x}-${previous.y}-${point.x}-${point.y}`)
|
|
925
|
+
],
|
|
926
|
+
previous: point
|
|
927
|
+
}), { lines: [], previous: points.at(0) ?? selectedPoint }).lines;
|
|
928
|
+
}
|
|
929
|
+
function resolveWheelLightness(color) {
|
|
930
|
+
const { lightness } = resolveWheelColorComponents(color);
|
|
931
|
+
return lightness;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/features/color/ColorPicker.tsx
|
|
935
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
936
|
+
var ColorPicker2 = withZoraThemeScope(ColorPickerInner);
|
|
937
|
+
function ColorPickerInner({
|
|
938
|
+
themeId: _themeId,
|
|
939
|
+
mode: _mode,
|
|
940
|
+
inverted: _inverted,
|
|
941
|
+
tabs,
|
|
942
|
+
value,
|
|
943
|
+
onValueChange,
|
|
944
|
+
onSelectionChange,
|
|
945
|
+
onDismiss,
|
|
946
|
+
hideTabListWhenSingle = true,
|
|
947
|
+
wheel,
|
|
948
|
+
tone,
|
|
949
|
+
hue,
|
|
950
|
+
testID
|
|
951
|
+
}) {
|
|
952
|
+
const { theme } = useZoraTheme2();
|
|
953
|
+
if (tabs.length === 0)
|
|
954
|
+
throw new Error("ColorPicker requires at least one tab.");
|
|
955
|
+
if (!tabs.includes(value.tab))
|
|
956
|
+
throw new Error("ColorPicker value must be configured in tabs.");
|
|
957
|
+
const previewColor = resolvePickerPreviewColor(value);
|
|
958
|
+
return /* @__PURE__ */ jsxs5(View2, {
|
|
959
|
+
alignSelf: "center",
|
|
960
|
+
bg: theme.semantics.surface.raised,
|
|
961
|
+
borderColor: theme.semantics.border.default,
|
|
962
|
+
borderWidth: 1,
|
|
963
|
+
flexShrink: 1,
|
|
964
|
+
gap: "s",
|
|
965
|
+
maxWidth: 400,
|
|
966
|
+
p: "m",
|
|
967
|
+
radius: "l",
|
|
968
|
+
testID,
|
|
969
|
+
width: "100%",
|
|
970
|
+
children: [
|
|
971
|
+
/* @__PURE__ */ jsxs5(View2, {
|
|
972
|
+
align: "center",
|
|
973
|
+
direction: "row",
|
|
974
|
+
justify: "space-between",
|
|
975
|
+
children: [
|
|
976
|
+
/* @__PURE__ */ jsx9(Text3, {
|
|
977
|
+
variant: "lead",
|
|
978
|
+
weight: "semiBold",
|
|
979
|
+
children: "Color"
|
|
980
|
+
}),
|
|
981
|
+
/* @__PURE__ */ jsxs5(View2, {
|
|
982
|
+
align: "center",
|
|
983
|
+
direction: "row",
|
|
984
|
+
gap: "s",
|
|
985
|
+
children: [
|
|
986
|
+
/* @__PURE__ */ jsx9(View2, {
|
|
987
|
+
bg: previewColor,
|
|
988
|
+
borderColor: theme.semantics.border.default,
|
|
989
|
+
borderWidth: 1,
|
|
990
|
+
height: 38,
|
|
991
|
+
radius: "s",
|
|
992
|
+
width: 38
|
|
993
|
+
}),
|
|
994
|
+
onDismiss ? /* @__PURE__ */ jsx9(IconButton2, {
|
|
995
|
+
iconName: "close",
|
|
996
|
+
label: "Close color picker",
|
|
997
|
+
onPress: onDismiss
|
|
998
|
+
}) : null
|
|
999
|
+
]
|
|
1000
|
+
})
|
|
1001
|
+
]
|
|
1002
|
+
}),
|
|
1003
|
+
/* @__PURE__ */ jsxs5(Tabs2, {
|
|
1004
|
+
defaultValue: value.tab,
|
|
1005
|
+
onValueChange: (nextValue) => {
|
|
1006
|
+
if (isColorPickerTab(nextValue) && tabs.includes(nextValue))
|
|
1007
|
+
onValueChange({ ...value, tab: nextValue });
|
|
1008
|
+
},
|
|
1009
|
+
testID: testID ? `${testID}-tabs` : undefined,
|
|
1010
|
+
value: value.tab,
|
|
1011
|
+
variant: "attached",
|
|
1012
|
+
children: [
|
|
1013
|
+
tabs.length > 1 || !hideTabListWhenSingle ? /* @__PURE__ */ jsx9(View2, {
|
|
1014
|
+
borderColor: theme.semantics.border.default,
|
|
1015
|
+
borderWidth: 1,
|
|
1016
|
+
overflow: "hidden",
|
|
1017
|
+
radius: "m",
|
|
1018
|
+
children: /* @__PURE__ */ jsx9(TabList2, {
|
|
1019
|
+
fill: true,
|
|
1020
|
+
children: tabs.map((tab) => /* @__PURE__ */ jsx9(Tab2, {
|
|
1021
|
+
label: tab,
|
|
1022
|
+
value: tab
|
|
1023
|
+
}, tab))
|
|
1024
|
+
})
|
|
1025
|
+
}) : null,
|
|
1026
|
+
tabs.map((tab) => /* @__PURE__ */ jsx9(TabPanel2, {
|
|
1027
|
+
value: tab,
|
|
1028
|
+
children: resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)
|
|
1029
|
+
}, tab))
|
|
1030
|
+
]
|
|
1031
|
+
})
|
|
1032
|
+
]
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
function isColorPickerTab(value) {
|
|
1036
|
+
return value === "wheel" || value === "tone" || value === "hue";
|
|
1037
|
+
}
|
|
1038
|
+
function resolvePickerPreviewColor(value) {
|
|
1039
|
+
if (value.tab === "hue")
|
|
1040
|
+
return value.hue;
|
|
1041
|
+
if (value.tab === "tone")
|
|
1042
|
+
return value.tone?.colors.at(0) ?? value.wheel.color;
|
|
1043
|
+
return value.wheel.color;
|
|
1044
|
+
}
|
|
1045
|
+
function resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange) {
|
|
1046
|
+
if (tab === "wheel")
|
|
1047
|
+
return wheel ? /* @__PURE__ */ jsx9(ColorWheel2, {
|
|
1048
|
+
...wheel,
|
|
1049
|
+
harmony: value.wheel.harmony,
|
|
1050
|
+
onChange: (next) => {
|
|
1051
|
+
onValueChange({ ...value, wheel: next });
|
|
1052
|
+
onSelectionChange?.({ mode: "wheel", value: next });
|
|
1053
|
+
},
|
|
1054
|
+
value: value.wheel.color
|
|
1055
|
+
}) : null;
|
|
1056
|
+
if (tab === "tone")
|
|
1057
|
+
return tone ? /* @__PURE__ */ jsx9(ColorTone2, {
|
|
1058
|
+
...tone,
|
|
1059
|
+
onChange: (next) => {
|
|
1060
|
+
onValueChange({ ...value, tone: next });
|
|
1061
|
+
onSelectionChange?.({ mode: "tone", value: next });
|
|
1062
|
+
},
|
|
1063
|
+
value: value.tone
|
|
1064
|
+
}) : null;
|
|
1065
|
+
return hue ? /* @__PURE__ */ jsx9(ColorHueScale2, {
|
|
1066
|
+
...hue,
|
|
1067
|
+
onChange: (next) => {
|
|
1068
|
+
onValueChange({ ...value, hue: next });
|
|
1069
|
+
onSelectionChange?.({ mode: "hue", value: next });
|
|
1070
|
+
},
|
|
1071
|
+
value: value.hue
|
|
1072
|
+
}) : null;
|
|
1073
|
+
}
|
|
1074
|
+
export { ColorHueScale2, ColorTone2, ColorWheel2, ColorPicker2 };
|