@ankhorage/zora 27.11.3 → 28.1.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/CHANGELOG.md +12 -0
- package/README.md +4 -3
- package/dist/features/bottom-sheet/adapters/inbound/BottomSheet.js.map +1 -1
- package/dist/features/color/ColorHexField.d.ts +1 -1
- package/dist/features/color/ColorHexField.d.ts.map +1 -1
- package/dist/features/color/ColorHexField.js +30 -4
- package/dist/features/color/ColorHexField.js.map +1 -1
- package/dist/features/color/ColorPicker.d.ts +1 -1
- package/dist/features/color/ColorPicker.d.ts.map +1 -1
- package/dist/features/color/ColorPicker.js +174 -59
- package/dist/features/color/ColorPicker.js.map +1 -1
- package/dist/features/color/ColorWheel.d.ts +1 -1
- package/dist/features/color/ColorWheel.d.ts.map +1 -1
- package/dist/features/color/ColorWheel.js +61 -117
- package/dist/features/color/ColorWheel.js.map +1 -1
- package/dist/features/color/ColorWheelKeyboardProxy.d.ts +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.d.ts.map +1 -1
- package/dist/features/color/ColorWheelKeyboardProxy.js.map +1 -1
- package/dist/features/color/ColorWheelKeyboardProxy.web.d.ts +1 -1
- package/dist/features/color/ColorWheelKeyboardProxy.web.d.ts.map +1 -1
- package/dist/features/color/ColorWheelKeyboardProxy.web.js +4 -4
- package/dist/features/color/ColorWheelKeyboardProxy.web.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.d.ts +1 -0
- package/dist/features/color/ColorWheelPointerProxy.d.ts.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts +3 -2
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.native.js +12 -3
- package/dist/features/color/ColorWheelPointerProxy.native.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts +2 -2
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.web.js +8 -5
- package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -1
- package/dist/features/color/public.d.ts +1 -1
- package/dist/features/color/public.d.ts.map +1 -1
- package/dist/features/color/public.js.map +1 -1
- package/dist/features/color/resolveColorPickerGeometry.d.ts +31 -0
- package/dist/features/color/resolveColorPickerGeometry.d.ts.map +1 -0
- package/dist/features/color/resolveColorPickerGeometry.js +94 -0
- package/dist/features/color/resolveColorPickerGeometry.js.map +1 -0
- package/dist/features/color/utils/resolveWheelColor.d.ts +2 -2
- package/dist/features/color/utils/resolveWheelColor.d.ts.map +1 -1
- package/dist/features/color/utils/resolveWheelColor.js +2 -3
- package/dist/features/color/utils/resolveWheelColor.js.map +1 -1
- package/dist/features/form/select/adapters/inbound/Select.native.js.map +1 -1
- package/dist/features/form/select/composition/SelectTrigger.d.ts.map +1 -1
- package/dist/features/form/select/composition/SelectTrigger.js +2 -2
- package/dist/features/form/select/composition/SelectTrigger.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/color.d.ts +34 -26
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/color.js.map +1 -1
- package/dist/types/select.d.ts +2 -0
- package/dist/types/select.d.ts.map +1 -1
- package/dist/types/select.js.map +1 -1
- package/package.json +6 -6
- package/src/features/bottom-sheet/adapters/inbound/BottomSheet.tsx +1 -1
- package/src/features/color/ColorHexField.tsx +67 -23
- package/src/features/color/ColorPicker.layout.test.tsx +28 -24
- package/src/features/color/ColorPicker.tsx +449 -121
- package/src/features/color/ColorWheel.tsx +124 -248
- package/src/features/color/ColorWheelKeyboardProxy.tsx +1 -0
- package/src/features/color/ColorWheelKeyboardProxy.web.tsx +4 -3
- package/src/features/color/ColorWheelPointerProxy.native.tsx +25 -3
- package/src/features/color/ColorWheelPointerProxy.tsx +1 -0
- package/src/features/color/ColorWheelPointerProxy.web.tsx +12 -5
- package/src/features/color/public.ts +0 -2
- package/src/features/color/resolveColorPickerGeometry.test.ts +43 -0
- package/src/features/color/resolveColorPickerGeometry.ts +116 -0
- package/src/features/color/utils/resolveWheelColor.ts +2 -3
- package/src/features/form/select/adapters/inbound/Select.native.tsx +1 -1
- package/src/features/form/select/composition/SelectTrigger.tsx +2 -1
- package/src/index.ts +6 -2
- package/src/types/color.ts +34 -22
- package/src/types/select.ts +2 -0
- package/web-dist/chunks/{Accordion-h2nd5y0z.js → Accordion-01bsg7zt.js} +5 -5
- package/web-dist/chunks/{Accordion-6nrpdbmb.js → Accordion-01zvarrn.js} +8 -9
- package/web-dist/chunks/{Accordion-pmfdf08d.js → Accordion-0dj1r7w3.js} +1 -1
- package/web-dist/chunks/{Accordion-3zw817fr.js → Accordion-0xaq2k2h.js} +8 -8
- package/web-dist/chunks/{Accordion-gezcm372.js → Accordion-15sxxjym.js} +4 -5
- package/web-dist/chunks/{Accordion-eq27a9ms.js → Accordion-1fz55hk4.js} +1 -1
- package/web-dist/chunks/{Accordion-j0zhpq4s.js → Accordion-22cda3h5.js} +7 -8
- package/web-dist/chunks/{Accordion-jd26f516.js → Accordion-27yg9ktv.js} +3 -3
- package/web-dist/chunks/{Accordion-f60g73bp.js → Accordion-34b3rwbc.js} +6 -8
- package/web-dist/chunks/{Accordion-1etqb3cj.js → Accordion-3zzzw7a8.js} +2 -2
- package/web-dist/chunks/Accordion-46n609yq.js +253 -0
- package/web-dist/chunks/{Accordion-3jkeydhb.js → Accordion-4zb6dcys.js} +4 -7
- package/web-dist/chunks/{Accordion-dfq04q82.js → Accordion-5cjhz94e.js} +5 -5
- package/web-dist/chunks/{Accordion-49w9bc2f.js → Accordion-5mga7hty.js} +2 -2
- package/web-dist/chunks/{Accordion-kcx57mk5.js → Accordion-76b0qz8y.js} +24 -22
- package/web-dist/chunks/{Accordion-vewhx028.js → Accordion-78tknqmc.js} +4 -4
- package/web-dist/chunks/{Accordion-5vs1k81g.js → Accordion-7bd6zq4s.js} +9 -9
- package/web-dist/chunks/{Accordion-phtyg3k4.js → Accordion-8c4w7366.js} +5 -5
- package/web-dist/chunks/{Accordion-vk2v1zwv.js → Accordion-8t6vh482.js} +3 -4
- package/web-dist/chunks/{Accordion-an5prgty.js → Accordion-9d38cgqj.js} +88 -92
- package/web-dist/chunks/{Accordion-1mxnyexh.js → Accordion-9k7ktksc.js} +212 -215
- package/web-dist/chunks/{Accordion-aws0caav.js → Accordion-afpjg1d6.js} +3 -4
- package/web-dist/chunks/{Accordion-c3nna2bz.js → Accordion-b1y5mjac.js} +1 -1
- package/web-dist/chunks/{Accordion-eak89n4n.js → Accordion-b8w0f8s0.js} +6 -7
- package/web-dist/chunks/{Accordion-ne91vwkd.js → Accordion-bexwrnfh.js} +3 -4
- package/web-dist/chunks/Accordion-chdbfcm6.js +93 -0
- package/web-dist/chunks/{Accordion-6yv4beha.js → Accordion-d405whfb.js} +2 -2
- package/web-dist/chunks/{Accordion-xb174981.js → Accordion-de8srt4x.js} +8 -8
- package/web-dist/chunks/{Accordion-e3r3573t.js → Accordion-epv5yhch.js} +3 -3
- package/web-dist/chunks/{Accordion-g451f3g9.js → Accordion-f4919ghm.js} +4 -4
- package/web-dist/chunks/{Accordion-qhn8z92r.js → Accordion-f8a49gy8.js} +19 -22
- package/web-dist/chunks/{Accordion-3s7zeagv.js → Accordion-fdzyyqe9.js} +1 -1
- package/web-dist/chunks/Accordion-gnxmybxx.js +1331 -0
- package/web-dist/chunks/{Accordion-z8ryq8cb.js → Accordion-h1q243zq.js} +13 -11
- package/web-dist/chunks/{Accordion-dtt4qkrb.js → Accordion-h63c9k9k.js} +1 -1
- package/web-dist/chunks/{Accordion-rzf52xq8.js → Accordion-hdyzyw8q.js} +3 -3
- package/web-dist/chunks/{Accordion-3wkd5x2q.js → Accordion-htvmkx8s.js} +118 -118
- package/web-dist/chunks/{Accordion-0kr0h68p.js → Accordion-jmxe6kw0.js} +9 -11
- package/web-dist/chunks/{Accordion-705yrq6w.js → Accordion-kcm6jcpp.js} +2 -3
- package/web-dist/chunks/{Accordion-fcczvwgg.js → Accordion-mrstcjcm.js} +1 -0
- package/web-dist/chunks/{Accordion-p29kmwh9.js → Accordion-mx7nkg85.js} +1 -1
- package/web-dist/chunks/{Accordion-x0p3wxfp.js → Accordion-pdjhezmz.js} +2 -2
- package/web-dist/chunks/{Accordion-8g9c7890.js → Accordion-q046ws5p.js} +6 -6
- package/web-dist/chunks/{Accordion-jbwey4za.js → Accordion-q11svb96.js} +19 -19
- package/web-dist/chunks/{Accordion-bd6q61s1.js → Accordion-qkkeyr18.js} +6 -8
- package/web-dist/chunks/{Accordion-q1tdazgq.js → Accordion-qrt9xz0h.js} +7 -8
- package/web-dist/chunks/{Accordion-h0e95qxp.js → Accordion-qsppnx7g.js} +10 -11
- package/web-dist/chunks/{Accordion-neg1cgeh.js → Accordion-rhjddvkh.js} +1 -2
- package/web-dist/chunks/{Accordion-ysmzrvhn.js → Accordion-rtamzg9j.js} +47 -28
- package/web-dist/chunks/{Accordion-xwstve3k.js → Accordion-sfvqf4fz.js} +134 -132
- package/web-dist/chunks/{Accordion-9c63jn3m.js → Accordion-sh79sr5g.js} +5 -5
- package/web-dist/chunks/{Accordion-4g54je0w.js → Accordion-t9n4ey2r.js} +5 -3
- package/web-dist/chunks/{Accordion-e5jr9ahb.js → Accordion-tk8zf9ff.js} +3 -3
- package/web-dist/chunks/{Accordion-zypyr9xw.js → Accordion-tnyqv1xv.js} +296 -305
- package/web-dist/chunks/{Accordion-c0a7mhq3.js → Accordion-v6vhyv31.js} +95 -165
- package/web-dist/chunks/{Accordion-6m3k4avp.js → Accordion-vkqqktc5.js} +3 -3
- package/web-dist/chunks/{Accordion-z4qakakw.js → Accordion-vzq344av.js} +2 -3
- package/web-dist/chunks/{Accordion-pcj256bc.js → Accordion-wb9pmykz.js} +5 -6
- package/web-dist/chunks/{Accordion-x7ynjdv7.js → Accordion-ww4f12ty.js} +1 -1
- package/web-dist/chunks/{Accordion-zx8gmww4.js → Accordion-xb9zhdhp.js} +42 -45
- package/web-dist/chunks/{Accordion-3ecnh8d0.js → Accordion-xfkg7dcw.js} +4 -5
- package/web-dist/chunks/{Accordion-6ec4gxv2.js → Accordion-xzaa9s7f.js} +12 -23
- package/web-dist/chunks/{Accordion-vnrqvfca.js → Accordion-yrac5a7m.js} +1 -1
- package/web-dist/chunks/{zip-reader-f0yphjb9.js → zip-reader-5xrcmjr8.js} +1 -1
- package/web-dist/components/accordion/Accordion.js +11 -11
- package/web-dist/components/accordion-item/AccordionItem.js +11 -11
- package/web-dist/components/activity-indicator/ActivityIndicator.js +4 -4
- package/web-dist/components/app-bar/AppBar.js +18 -18
- package/web-dist/components/app-header/AppHeader.js +18 -18
- package/web-dist/components/app-shell/AppShell.js +5 -5
- package/web-dist/components/auth-screen/AuthScreen.js +21 -21
- package/web-dist/components/avatar/Avatar.js +11 -11
- package/web-dist/components/avatar-group/AvatarGroup.js +11 -11
- package/web-dist/components/badge/Badge.js +6 -6
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +19 -19
- package/web-dist/components/bottom-sheet/BottomSheet.js +10 -7
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +10 -7
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +10 -7
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +10 -7
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +10 -7
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +10 -7
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +13 -13
- package/web-dist/components/button/Button.js +11 -11
- package/web-dist/components/button-group/ButtonGroup.js +11 -11
- package/web-dist/components/calendar/Calendar.js +14 -14
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +19 -19
- package/web-dist/components/card/Card.js +18 -18
- package/web-dist/components/card-back/CardBack.js +5 -5
- package/web-dist/components/card-hand/CardHand.js +5 -5
- package/web-dist/components/carousel/Carousel.js +2 -2
- package/web-dist/components/chat-list-item/ChatListItem.js +15 -15
- package/web-dist/components/checkbox/Checkbox.js +11 -11
- package/web-dist/components/checkbox-group/CheckboxGroup.js +11 -11
- package/web-dist/components/chess-board/ChessBoard.js +6 -6
- package/web-dist/components/chip/Chip.js +12 -12
- package/web-dist/components/chip-group/ChipGroup.js +12 -12
- package/web-dist/components/collection-editor/CollectionEditor.js +18 -18
- package/web-dist/components/color-hue-scale/ColorHueScale.js +28 -17
- package/web-dist/components/color-picker/ColorPicker.d.ts +2 -2
- package/web-dist/components/color-picker/ColorPicker.js +28 -17
- package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +34 -45
- package/web-dist/components/color-picker/index.d.ts +1 -1
- package/web-dist/components/color-tone/ColorTone.js +28 -17
- package/web-dist/components/color-wheel/ColorWheel.d.ts +1 -1
- package/web-dist/components/color-wheel/ColorWheel.js +28 -17
- package/web-dist/components/color-wheel/ColorWheel.types-0.d.ts +10 -0
- package/web-dist/components/content-rail/ContentRail.js +12 -12
- package/web-dist/components/data-table/DataTable.js +26 -26
- package/web-dist/components/date-picker/DatePicker.js +20 -20
- package/web-dist/components/dialog/Dialog.js +11 -11
- package/web-dist/components/divider/Divider.js +5 -5
- package/web-dist/components/empty-state/EmptyState.js +19 -19
- package/web-dist/components/explorer/Explorer.js +13 -13
- package/web-dist/components/field/Field.js +11 -11
- package/web-dist/components/file-explorer/FileExplorer.js +13 -13
- package/web-dist/components/flat-list/FlatList.js +12 -12
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +21 -21
- package/web-dist/components/form/Form.js +15 -15
- package/web-dist/components/form-actions/FormActions.js +15 -15
- package/web-dist/components/form-error/FormError.js +15 -15
- package/web-dist/components/game/Game.js +7 -6
- package/web-dist/components/game-entity/GameEntity.js +7 -6
- package/web-dist/components/game-field/GameField.js +7 -6
- package/web-dist/components/game-input-zone/GameInputZone.js +7 -6
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +7 -6
- package/web-dist/components/game-overlay/GameOverlay.js +7 -6
- package/web-dist/components/gradient/Gradient.js +6 -6
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +6 -6
- package/web-dist/components/graph-view/GraphView.js +2 -2
- package/web-dist/components/grid/Grid.js +5 -5
- package/web-dist/components/grid-interactions/GridInteractions.js +1 -1
- package/web-dist/components/grid-line-overlay/GridLineOverlay.js +5 -5
- package/web-dist/components/grid-ruler/GridRuler.js +5 -5
- package/web-dist/components/grid-view/GridView.js +1 -1
- package/web-dist/components/heading/Heading.js +6 -6
- package/web-dist/components/hero/Hero.js +18 -18
- package/web-dist/components/icon/Icon.js +5 -5
- package/web-dist/components/icon-button/IconButton.js +11 -11
- package/web-dist/components/image/Image.js +9 -9
- package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +4 -4
- package/web-dist/components/list/List.js +12 -12
- package/web-dist/components/list-item/ListItem.js +12 -12
- package/web-dist/components/list-section/ListSection.js +12 -12
- package/web-dist/components/master-detail/MasterDetail.js +5 -5
- package/web-dist/components/matrix-grid/MatrixGrid.js +9 -9
- package/web-dist/components/media-card/MediaCard.js +18 -18
- package/web-dist/components/media-explorer/MediaExplorer.js +13 -13
- package/web-dist/components/message-bubble/MessageBubble.js +15 -15
- package/web-dist/components/metric-card/MetricCard.js +18 -18
- package/web-dist/components/missing-element/MissingElement.js +10 -10
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +21 -21
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +21 -21
- package/web-dist/components/opening-book/OpeningBook.js +6 -6
- package/web-dist/components/otp-form/OtpForm.js +21 -21
- package/web-dist/components/pagination/Pagination.js +12 -12
- package/web-dist/components/palette-item/PaletteItem.js +18 -18
- package/web-dist/components/playing-card/PlayingCard.js +5 -5
- package/web-dist/components/poker-training-table/PokerTrainingTable.js +5 -5
- package/web-dist/components/popover-menu/PopoverMenu.js +13 -13
- package/web-dist/components/post-card/PostCard.js +18 -18
- package/web-dist/components/product-card/ProductCard.js +18 -18
- package/web-dist/components/progress/Progress.js +9 -9
- package/web-dist/components/progress-ring/ProgressRing.js +9 -9
- package/web-dist/components/radio/Radio.js +13 -13
- package/web-dist/components/radio-group/RadioGroup.js +13 -13
- package/web-dist/components/rating/Rating.js +8 -8
- package/web-dist/components/reader/Reader.js +34 -34
- package/web-dist/components/scan-overlay/ScanOverlay.js +19 -19
- package/web-dist/components/screen/Screen.js +5 -5
- package/web-dist/components/screen-section/ScreenSection.js +9 -9
- package/web-dist/components/scroll-view/ScrollView.js +5 -5
- package/web-dist/components/search-input/SearchInput.js +13 -13
- package/web-dist/components/section-header/SectionHeader.js +9 -9
- package/web-dist/components/section-list/SectionList.js +12 -12
- package/web-dist/components/select/Select.js +23 -259
- package/web-dist/components/select/Select.types-0.d.ts +2 -0
- package/web-dist/components/selectable-item/SelectableItem.js +4 -4
- package/web-dist/components/selection-provider/SelectionProvider.js +4 -4
- package/web-dist/components/sign-in-form/SignInForm.js +21 -21
- package/web-dist/components/sign-up-form/SignUpForm.js +21 -21
- package/web-dist/components/skeleton/Skeleton.js +21 -21
- package/web-dist/components/skeleton-card/SkeletonCard.js +21 -21
- package/web-dist/components/skeleton-list/SkeletonList.js +21 -21
- package/web-dist/components/skeleton-text/SkeletonText.js +21 -21
- package/web-dist/components/spatial-grid/SpatialGrid.js +1 -1
- package/web-dist/components/surface/Surface.js +6 -6
- package/web-dist/components/switch/Switch.js +8 -8
- package/web-dist/components/tab/Tab.js +6 -6
- package/web-dist/components/tab-list/TabList.js +6 -6
- package/web-dist/components/tab-panel/TabPanel.js +6 -6
- package/web-dist/components/tabletop-table/TabletopTable.js +5 -5
- package/web-dist/components/tabs/Tabs.js +6 -6
- package/web-dist/components/text/Text.js +6 -6
- package/web-dist/components/text-input/TextInput.js +13 -13
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +11 -11
- package/web-dist/components/tile-grid/TileGrid.js +1 -1
- package/web-dist/components/time-grid/TimeGrid.js +2 -2
- package/web-dist/components/time-picker/TimePicker.js +18 -18
- package/web-dist/components/timeline/Timeline.js +11 -11
- package/web-dist/components/toast/Toast.js +9 -9
- package/web-dist/components/toast-provider/ToastProvider.js +9 -9
- package/web-dist/components/toolbar/Toolbar.js +18 -18
- package/web-dist/components/tree-item/TreeItem.js +17 -17
- package/web-dist/components/tree-view/TreeView.js +1 -1
- package/web-dist/components/uploader/Uploader.js +23 -23
- package/web-dist/components/view/View.js +5 -5
- package/web-dist/manifest.json +1950 -1877
- package/web-dist/runtime/ZoraProvider.js +9 -9
- package/web-dist/chunks/Accordion-r1wkgt7c.js +0 -1074
- package/web-dist/chunks/{Accordion-vgkvvdvg.js → Accordion-ykk40jz9.js} +36 -36
|
@@ -1,159 +1,487 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COLOR_HARMONY_CATALOG,
|
|
3
|
+
type ColorHarmony,
|
|
4
|
+
generateHarmonyRoleColors,
|
|
5
|
+
type HexColor,
|
|
6
|
+
} from '@ankhorage/color-theory';
|
|
7
|
+
import { Pressable } from '@ankhorage/surface';
|
|
1
8
|
import React from 'react';
|
|
9
|
+
import { View as NativeView } from 'react-native';
|
|
2
10
|
|
|
3
|
-
import type { ColorPickerProps, ColorPickerTab,
|
|
11
|
+
import type { ColorPickerProps, ColorPickerTab, ColorToneDefinition } from '../../types/color';
|
|
4
12
|
import { IconButton } from '../button/public';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
13
|
+
import { Card } from '../card/public';
|
|
14
|
+
import { Select } from '../form/select/public';
|
|
15
|
+
import { Gradient } from '../gradient/public';
|
|
16
|
+
import { Icon } from '../icon/public';
|
|
17
|
+
import { Divider, View } from '../layout/public';
|
|
7
18
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
8
19
|
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
9
|
-
import { Text } from '../typography/public';
|
|
10
|
-
import {
|
|
11
|
-
import { ColorTone } from './ColorTone';
|
|
20
|
+
import { Heading, Text } from '../typography/public';
|
|
21
|
+
import { ColorHexField } from './ColorHexField';
|
|
12
22
|
import { ColorWheel } from './ColorWheel';
|
|
23
|
+
import { resolveColorPickerGeometry } from './resolveColorPickerGeometry';
|
|
24
|
+
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
13
25
|
|
|
14
|
-
|
|
26
|
+
const DEFAULT_TABS: readonly ColorPickerTab[] = ['grid', 'wheel'];
|
|
27
|
+
|
|
28
|
+
/*** Replaces the former Tone/Hue picker with one controlled Grid/Wheel presentation. */
|
|
15
29
|
export const ColorPicker = withZoraThemeScope(ColorPickerInner);
|
|
16
30
|
|
|
17
|
-
/*** Coordinates
|
|
31
|
+
/*** Coordinates the shared colour, tone and harmony state across both picker presentations. */
|
|
18
32
|
function ColorPickerInner({
|
|
19
33
|
themeId: _themeId,
|
|
20
34
|
mode: _mode,
|
|
21
35
|
inverted: _inverted,
|
|
22
|
-
tabs,
|
|
23
|
-
|
|
36
|
+
tabs = DEFAULT_TABS,
|
|
37
|
+
primaryColor,
|
|
38
|
+
harmony,
|
|
39
|
+
tone,
|
|
40
|
+
tones = [],
|
|
41
|
+
width = 560,
|
|
42
|
+
height,
|
|
43
|
+
infoLine,
|
|
44
|
+
onInsufficientSpaceChange,
|
|
45
|
+
activeTab,
|
|
24
46
|
onValueChange,
|
|
25
|
-
|
|
47
|
+
onActiveTabChange,
|
|
26
48
|
onDismiss,
|
|
27
49
|
hideTabListWhenSingle = true,
|
|
28
50
|
wheel,
|
|
29
|
-
|
|
30
|
-
hue,
|
|
51
|
+
interactionPolicy,
|
|
31
52
|
testID,
|
|
32
53
|
}: ColorPickerProps) {
|
|
33
54
|
const { theme } = useZoraTheme();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
const [hostBounds, setHostBounds] = React.useState<{
|
|
56
|
+
readonly height: number;
|
|
57
|
+
readonly width: number;
|
|
58
|
+
}>();
|
|
59
|
+
const enabledTabs = resolveEnabledTabs(tabs);
|
|
60
|
+
const firstTab = enabledTabs.at(0);
|
|
61
|
+
if (!firstTab) throw new Error('ColorPicker requires at least one tab.');
|
|
62
|
+
const [uncontrolledTab, setUncontrolledTab] = React.useState<ColorPickerTab>(firstTab);
|
|
63
|
+
const resolvedTab =
|
|
64
|
+
activeTab && enabledTabs.includes(activeTab)
|
|
65
|
+
? activeTab
|
|
66
|
+
: enabledTabs.includes(uncontrolledTab)
|
|
67
|
+
? uncontrolledTab
|
|
68
|
+
: firstTab;
|
|
69
|
+
const geometry = resolveColorPickerGeometry({
|
|
70
|
+
height,
|
|
71
|
+
hostHeight: hostBounds && hostBounds.height > 0 ? hostBounds.height : undefined,
|
|
72
|
+
hostWidth: hostBounds && hostBounds.width > 0 ? hostBounds.width : undefined,
|
|
73
|
+
showTabs: enabledTabs.length > 1 || !hideTabListWhenSingle,
|
|
74
|
+
width,
|
|
75
|
+
});
|
|
76
|
+
const selectedTone = tones.find((entry) => entry.id === tone);
|
|
77
|
+
const emit = (next: {
|
|
78
|
+
readonly harmony?: ColorHarmony;
|
|
79
|
+
readonly primaryColor?: HexColor;
|
|
80
|
+
readonly tone?: string;
|
|
81
|
+
}) =>
|
|
82
|
+
onValueChange({
|
|
83
|
+
primaryColor: next.primaryColor ?? primaryColor,
|
|
84
|
+
...(Object.hasOwn(next, 'harmony') ? { harmony: next.harmony } : harmony ? { harmony } : {}),
|
|
85
|
+
...(Object.hasOwn(next, 'tone') ? { tone: next.tone } : tone ? { tone } : {}),
|
|
86
|
+
});
|
|
87
|
+
const settings = (children: React.ReactNode) => (
|
|
88
|
+
<PickerRow
|
|
89
|
+
geometry={geometry}
|
|
90
|
+
tone={tone}
|
|
91
|
+
tones={tones}
|
|
92
|
+
harmony={harmony}
|
|
93
|
+
interactionPolicy={interactionPolicy}
|
|
94
|
+
onHarmonyChange={(next) => emit({ harmony: next })}
|
|
95
|
+
onToneChange={(next) => emit({ tone: next })}
|
|
96
|
+
>
|
|
97
|
+
{children}
|
|
98
|
+
</PickerRow>
|
|
99
|
+
);
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (activeTab && activeTab !== resolvedTab) onActiveTabChange?.(resolvedTab);
|
|
102
|
+
}, [activeTab, onActiveTabChange, resolvedTab]);
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
onInsufficientSpaceChange?.(geometry.insufficientSpace);
|
|
105
|
+
}, [geometry.insufficientSpace, onInsufficientSpaceChange]);
|
|
106
|
+
return (
|
|
107
|
+
<NativeView
|
|
108
|
+
onLayout={(event) =>
|
|
109
|
+
setHostBounds({
|
|
110
|
+
height: event.nativeEvent.layout.height,
|
|
111
|
+
width: event.nativeEvent.layout.width,
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
style={{
|
|
115
|
+
alignSelf: 'stretch',
|
|
116
|
+
flexShrink: 1,
|
|
117
|
+
height: height ?? '100%',
|
|
118
|
+
maxHeight: '100%',
|
|
119
|
+
maxWidth: '100%',
|
|
120
|
+
width: '100%',
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{!geometry.insufficientSpace ? (
|
|
124
|
+
<View
|
|
125
|
+
alignSelf="center"
|
|
126
|
+
borderColor={theme.semantics.action.primary.base}
|
|
127
|
+
borderWidth={geometry.border}
|
|
128
|
+
radius="l"
|
|
129
|
+
testID={testID}
|
|
130
|
+
width={geometry.width}
|
|
131
|
+
>
|
|
132
|
+
<Gradient
|
|
133
|
+
colors={[theme.semantics.surface.raised, theme.semantics.neutral.surface]}
|
|
134
|
+
end={{ x: 0, y: 1 }}
|
|
135
|
+
radius="l"
|
|
136
|
+
start={{ x: 0, y: 0 }}
|
|
137
|
+
>
|
|
138
|
+
<View
|
|
139
|
+
gap={geometry.footerGap}
|
|
140
|
+
pb={geometry.footerInset}
|
|
141
|
+
pt={geometry.padding}
|
|
142
|
+
px={geometry.padding}
|
|
143
|
+
>
|
|
144
|
+
<View gap={geometry.mainGap}>
|
|
145
|
+
<View
|
|
146
|
+
align="center"
|
|
147
|
+
direction="row"
|
|
148
|
+
justify="space-between"
|
|
149
|
+
minHeight={geometry.headerHeight}
|
|
150
|
+
>
|
|
151
|
+
<Heading level={2}>Color</Heading>
|
|
152
|
+
<View align="center" direction="row" gap="s">
|
|
153
|
+
<View
|
|
154
|
+
bg={primaryColor}
|
|
155
|
+
borderColor={theme.semantics.border.default}
|
|
156
|
+
borderWidth={1}
|
|
157
|
+
height={36 * geometry.scale}
|
|
158
|
+
radius="s"
|
|
159
|
+
width={52 * geometry.scale}
|
|
160
|
+
/>
|
|
161
|
+
{onDismiss ? (
|
|
162
|
+
<IconButton iconName="close" label="Close color picker" onPress={onDismiss} />
|
|
163
|
+
) : null}
|
|
164
|
+
</View>
|
|
165
|
+
</View>
|
|
166
|
+
{enabledTabs.length > 1 || !hideTabListWhenSingle ? (
|
|
167
|
+
<ColorPickerTabSelector
|
|
168
|
+
activeTab={resolvedTab}
|
|
169
|
+
geometry={geometry}
|
|
170
|
+
interactionPolicy={interactionPolicy}
|
|
171
|
+
tabs={enabledTabs}
|
|
172
|
+
onChange={(next) => {
|
|
173
|
+
setUncontrolledTab(next);
|
|
174
|
+
onActiveTabChange?.(next);
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
) : null}
|
|
178
|
+
{resolvedTab === 'grid'
|
|
179
|
+
? settings(
|
|
180
|
+
<ColorGrid
|
|
181
|
+
disabled={interactionPolicy === 'passive'}
|
|
182
|
+
harmony={harmony}
|
|
183
|
+
onSelect={(color) => emit({ primaryColor: color })}
|
|
184
|
+
palette={resolvePalette(selectedTone, primaryColor, harmony)}
|
|
185
|
+
primaryIndicatorColor={theme.semantics.action.primary.base}
|
|
186
|
+
selectionBorderColor={theme.semantics.content.default}
|
|
187
|
+
selected={primaryColor}
|
|
188
|
+
size={geometry.stage}
|
|
189
|
+
/>,
|
|
190
|
+
)
|
|
191
|
+
: settings(
|
|
192
|
+
<ColorWheel
|
|
193
|
+
{...wheel}
|
|
194
|
+
harmony={harmony ?? null}
|
|
195
|
+
interactionPolicy={interactionPolicy}
|
|
196
|
+
onChange={(next) =>
|
|
197
|
+
emit({ primaryColor: next.color, harmony: next.harmony ?? undefined })
|
|
198
|
+
}
|
|
199
|
+
size={geometry.stage}
|
|
200
|
+
toneTarget={selectedTone?.accentTarget}
|
|
201
|
+
value={primaryColor}
|
|
202
|
+
/>,
|
|
203
|
+
)}
|
|
204
|
+
<View height={geometry.infoLineHeight} justify="center">
|
|
205
|
+
{infoLine ? (
|
|
206
|
+
<Text accessibilityLabel={infoLine} numberOfLines={1} variant="caption">
|
|
207
|
+
{infoLine}
|
|
208
|
+
</Text>
|
|
209
|
+
) : null}
|
|
210
|
+
</View>
|
|
211
|
+
</View>
|
|
212
|
+
<View gap={geometry.footerGap}>
|
|
213
|
+
<Divider />
|
|
214
|
+
<View height={geometry.footerHeight} justify="center">
|
|
215
|
+
<ColorHexField
|
|
216
|
+
disabled={interactionPolicy === 'passive'}
|
|
217
|
+
onChange={(color) => emit({ primaryColor: color })}
|
|
218
|
+
value={primaryColor}
|
|
219
|
+
/>
|
|
220
|
+
</View>
|
|
221
|
+
</View>
|
|
222
|
+
</View>
|
|
223
|
+
</Gradient>
|
|
224
|
+
</View>
|
|
225
|
+
) : (
|
|
226
|
+
<View
|
|
227
|
+
accessibilityLabel="Color picker needs more space"
|
|
228
|
+
testID={testID ? `${testID}-insufficient-space` : undefined}
|
|
229
|
+
/>
|
|
230
|
+
)}
|
|
231
|
+
</NativeView>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
37
234
|
|
|
235
|
+
/*** Renders the ColorPicker's primary-accent tab choices without inheriting generic panel surfaces. */
|
|
236
|
+
function ColorPickerTabSelector({
|
|
237
|
+
activeTab,
|
|
238
|
+
geometry,
|
|
239
|
+
interactionPolicy,
|
|
240
|
+
tabs,
|
|
241
|
+
onChange,
|
|
242
|
+
}: {
|
|
243
|
+
readonly activeTab: ColorPickerTab;
|
|
244
|
+
readonly geometry: ReturnType<typeof resolveColorPickerGeometry>;
|
|
245
|
+
readonly interactionPolicy?: ColorPickerProps['interactionPolicy'];
|
|
246
|
+
readonly tabs: readonly ColorPickerTab[];
|
|
247
|
+
readonly onChange: (tab: ColorPickerTab) => void;
|
|
248
|
+
}) {
|
|
249
|
+
const { theme } = useZoraTheme();
|
|
38
250
|
return (
|
|
39
251
|
<View
|
|
40
|
-
alignSelf="center"
|
|
41
|
-
bg={theme.semantics.surface.raised}
|
|
42
252
|
borderColor={theme.semantics.border.default}
|
|
43
253
|
borderWidth={1}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
p="m"
|
|
48
|
-
radius="l"
|
|
49
|
-
testID={testID}
|
|
50
|
-
width="100%"
|
|
254
|
+
direction="row"
|
|
255
|
+
overflow="hidden"
|
|
256
|
+
radius="m"
|
|
51
257
|
>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
258
|
+
{tabs.map((tab) => {
|
|
259
|
+
const selected = tab === activeTab;
|
|
260
|
+
return (
|
|
261
|
+
<Pressable
|
|
262
|
+
accessibilityLabel={`${tab === 'grid' ? 'Grid' : 'Wheel'} color picker tab`}
|
|
263
|
+
accessibilityRole="tab"
|
|
264
|
+
accessibilityState={{ selected }}
|
|
265
|
+
disabled={interactionPolicy === 'passive'}
|
|
266
|
+
key={tab}
|
|
267
|
+
onPress={() => onChange(tab)}
|
|
268
|
+
style={{ flex: 1 }}
|
|
269
|
+
>
|
|
270
|
+
<View
|
|
271
|
+
align="center"
|
|
272
|
+
bg={selected ? theme.semantics.action.primary.base : 'transparent'}
|
|
273
|
+
direction="row"
|
|
274
|
+
gap="xs"
|
|
275
|
+
height={geometry.tabHeight - geometry.border * 2}
|
|
276
|
+
justify="center"
|
|
277
|
+
radius="s"
|
|
278
|
+
>
|
|
279
|
+
<Icon
|
|
280
|
+
color={selected ? theme.semantics.action.primary.onSolidText : undefined}
|
|
281
|
+
name={tab === 'grid' ? 'grid' : 'color-palette'}
|
|
282
|
+
size={16 * geometry.scale}
|
|
283
|
+
/>
|
|
284
|
+
<Text
|
|
285
|
+
style={selected ? { color: theme.semantics.action.primary.onSolidText } : undefined}
|
|
286
|
+
variant="label"
|
|
287
|
+
weight="medium"
|
|
288
|
+
>
|
|
289
|
+
{tab === 'grid' ? 'Grid' : 'Wheel'}
|
|
290
|
+
</Text>
|
|
291
|
+
</View>
|
|
292
|
+
</Pressable>
|
|
293
|
+
);
|
|
294
|
+
})}
|
|
295
|
+
</View>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/*** Keeps the settings rail identical while the stage changes presentation. */
|
|
300
|
+
function PickerRow({
|
|
301
|
+
children,
|
|
302
|
+
geometry,
|
|
303
|
+
tone,
|
|
304
|
+
tones,
|
|
305
|
+
harmony,
|
|
306
|
+
interactionPolicy,
|
|
307
|
+
onToneChange,
|
|
308
|
+
onHarmonyChange,
|
|
309
|
+
}: {
|
|
310
|
+
readonly children: React.ReactNode;
|
|
311
|
+
readonly geometry: ReturnType<typeof resolveColorPickerGeometry>;
|
|
312
|
+
readonly tone?: string;
|
|
313
|
+
readonly tones: readonly ColorToneDefinition[];
|
|
314
|
+
readonly harmony?: ColorHarmony;
|
|
315
|
+
readonly interactionPolicy?: ColorPickerProps['interactionPolicy'];
|
|
316
|
+
readonly onToneChange: (tone?: string) => void;
|
|
317
|
+
readonly onHarmonyChange: (harmony?: ColorHarmony) => void;
|
|
318
|
+
}) {
|
|
319
|
+
return (
|
|
320
|
+
<View align="flex-start" direction="row" gap={geometry.gap}>
|
|
321
|
+
<View gap={geometry.cardGap} width={geometry.rail}>
|
|
322
|
+
<SettingCard
|
|
323
|
+
geometry={geometry}
|
|
324
|
+
icon="diamond"
|
|
325
|
+
interactionPolicy={interactionPolicy}
|
|
326
|
+
label="Tone"
|
|
327
|
+
onClear={tone ? () => onToneChange(undefined) : undefined}
|
|
328
|
+
>
|
|
329
|
+
<Select
|
|
330
|
+
compact
|
|
331
|
+
interactionPolicy={interactionPolicy}
|
|
332
|
+
onValueChange={onToneChange}
|
|
333
|
+
options={tones.map((entry) => ({ label: entry.accent, value: entry.id }))}
|
|
334
|
+
placeholder="Any tone"
|
|
335
|
+
value={tone}
|
|
64
336
|
/>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
337
|
+
</SettingCard>
|
|
338
|
+
<SettingCard
|
|
339
|
+
geometry={geometry}
|
|
340
|
+
icon="color-palette"
|
|
341
|
+
interactionPolicy={interactionPolicy}
|
|
342
|
+
label="Harmony"
|
|
343
|
+
onClear={harmony ? () => onHarmonyChange(undefined) : undefined}
|
|
344
|
+
>
|
|
345
|
+
<Select
|
|
346
|
+
compact
|
|
347
|
+
interactionPolicy={interactionPolicy}
|
|
348
|
+
onValueChange={onHarmonyChange}
|
|
349
|
+
options={COLOR_HARMONY_CATALOG.map((entry) => ({
|
|
350
|
+
label: entry.label,
|
|
351
|
+
value: entry.id,
|
|
352
|
+
}))}
|
|
353
|
+
placeholder="None"
|
|
354
|
+
value={harmony}
|
|
355
|
+
/>
|
|
356
|
+
</SettingCard>
|
|
69
357
|
</View>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
358
|
+
{children}
|
|
359
|
+
</View>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/*** Renders one compact, geometry-owned Tone or Harmony setting control. */
|
|
364
|
+
function SettingCard({
|
|
365
|
+
children,
|
|
366
|
+
geometry,
|
|
367
|
+
icon,
|
|
368
|
+
interactionPolicy,
|
|
369
|
+
label,
|
|
370
|
+
onClear,
|
|
371
|
+
}: {
|
|
372
|
+
readonly children: React.ReactNode;
|
|
373
|
+
readonly geometry: ReturnType<typeof resolveColorPickerGeometry>;
|
|
374
|
+
readonly icon: 'color-palette' | 'diamond';
|
|
375
|
+
readonly interactionPolicy?: ColorPickerProps['interactionPolicy'];
|
|
376
|
+
readonly label: string;
|
|
377
|
+
readonly onClear?: () => void;
|
|
378
|
+
}) {
|
|
379
|
+
return (
|
|
380
|
+
<Card compact minHeight={geometry.cardHeight} padding="s" radius="m" tone="subtle">
|
|
381
|
+
<View align="center" direction="row" gap="xs" justify="space-between">
|
|
382
|
+
<View align="center" direction="row" gap="xs">
|
|
383
|
+
<Icon name={icon} size={20 * geometry.scale} />
|
|
384
|
+
<Text numberOfLines={1} variant="label" weight="medium">
|
|
385
|
+
{label}
|
|
386
|
+
</Text>
|
|
387
|
+
</View>
|
|
388
|
+
{onClear ? (
|
|
389
|
+
<IconButton
|
|
390
|
+
disabled={interactionPolicy === 'passive'}
|
|
391
|
+
iconName="close"
|
|
392
|
+
label={`Clear ${label}`}
|
|
393
|
+
onPress={onClear}
|
|
394
|
+
size="s"
|
|
395
|
+
/>
|
|
93
396
|
) : null}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
397
|
+
</View>
|
|
398
|
+
{children}
|
|
399
|
+
</Card>
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/*** Renders all 64 deterministic OKLCH candidates without scrolling or virtualisation. */
|
|
404
|
+
function ColorGrid({
|
|
405
|
+
palette,
|
|
406
|
+
primaryIndicatorColor,
|
|
407
|
+
selectionBorderColor,
|
|
408
|
+
selected,
|
|
409
|
+
size,
|
|
410
|
+
onSelect,
|
|
411
|
+
disabled = false,
|
|
412
|
+
harmony,
|
|
413
|
+
}: {
|
|
414
|
+
readonly palette: readonly HexColor[];
|
|
415
|
+
readonly primaryIndicatorColor: string;
|
|
416
|
+
readonly selectionBorderColor: string;
|
|
417
|
+
readonly selected: HexColor;
|
|
418
|
+
readonly size: number;
|
|
419
|
+
readonly onSelect: (color: HexColor) => void;
|
|
420
|
+
readonly disabled?: boolean;
|
|
421
|
+
readonly harmony?: ColorHarmony;
|
|
422
|
+
}) {
|
|
423
|
+
const gap = Math.max(3, Math.round(size / 68));
|
|
424
|
+
const cell = (size - 7 * gap) / 8;
|
|
425
|
+
const harmonyColors = new Set(
|
|
426
|
+
harmony ? generateHarmonyRoleColors(selected, harmony).colors.map((role) => role.hex) : [],
|
|
427
|
+
);
|
|
428
|
+
return (
|
|
429
|
+
<View accessibilityLabel="Color grid" direction="row" gap={gap} width={size} wrap="wrap">
|
|
430
|
+
{palette.map((color) => (
|
|
431
|
+
<Pressable
|
|
432
|
+
accessibilityLabel={`Select ${color}`}
|
|
433
|
+
bg={color}
|
|
434
|
+
borderColor={
|
|
435
|
+
color === selected
|
|
436
|
+
? selectionBorderColor
|
|
437
|
+
: harmonyColors.has(color)
|
|
438
|
+
? primaryIndicatorColor
|
|
439
|
+
: 'transparent'
|
|
440
|
+
}
|
|
441
|
+
borderWidth={color === selected ? 3 : harmonyColors.has(color) ? 1 : 0}
|
|
442
|
+
disabled={disabled}
|
|
443
|
+
height={cell}
|
|
444
|
+
key={color}
|
|
445
|
+
onPress={() => onSelect(color)}
|
|
446
|
+
radius="s"
|
|
447
|
+
width={cell}
|
|
448
|
+
/>
|
|
449
|
+
))}
|
|
100
450
|
</View>
|
|
101
451
|
);
|
|
102
452
|
}
|
|
103
453
|
|
|
104
|
-
/***
|
|
105
|
-
function
|
|
106
|
-
|
|
454
|
+
/*** Samples hue, chroma and lightness deterministically into the 8-by-8 grid. */
|
|
455
|
+
function resolvePalette(
|
|
456
|
+
tone: ColorToneDefinition | undefined,
|
|
457
|
+
primaryColor: HexColor,
|
|
458
|
+
harmony: ColorHarmony | undefined,
|
|
459
|
+
): readonly HexColor[] {
|
|
460
|
+
const target = tone?.accentTarget;
|
|
461
|
+
const candidates = Array.from({ length: 64 }, (_, index) =>
|
|
462
|
+
resolveOklchColor(
|
|
463
|
+
{
|
|
464
|
+
chroma: target?.chroma ?? 0.08 + (index % 8) * 0.018,
|
|
465
|
+
lightness: target?.lightness ?? 0.35 + Math.floor(index / 8) * 0.065,
|
|
466
|
+
},
|
|
467
|
+
(index * 137.508) % 360,
|
|
468
|
+
),
|
|
469
|
+
);
|
|
470
|
+
const roleColors = harmony
|
|
471
|
+
? generateHarmonyRoleColors(primaryColor, harmony).colors.map((role) => role.hex)
|
|
472
|
+
: [];
|
|
473
|
+
return Array.from(new Set([primaryColor, ...roleColors, ...candidates])).slice(0, 64);
|
|
107
474
|
}
|
|
108
475
|
|
|
109
|
-
/***
|
|
110
|
-
function
|
|
111
|
-
if (
|
|
112
|
-
if (
|
|
113
|
-
|
|
476
|
+
/*** Rejects empty and legacy tab configurations before they render focusable controls. */
|
|
477
|
+
function resolveEnabledTabs(tabs: readonly ColorPickerTab[]) {
|
|
478
|
+
if (tabs.length === 0) throw new Error('ColorPicker requires at least one tab.');
|
|
479
|
+
if (tabs.some((tab) => !isColorPickerTab(tab)))
|
|
480
|
+
throw new Error('ColorPicker supports only Grid and Wheel tabs.');
|
|
481
|
+
return tabs;
|
|
114
482
|
}
|
|
115
483
|
|
|
116
|
-
/***
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
value: ColorPickerValue,
|
|
120
|
-
wheel: ColorPickerProps['wheel'],
|
|
121
|
-
tone: ColorPickerProps['tone'],
|
|
122
|
-
hue: ColorPickerProps['hue'],
|
|
123
|
-
onValueChange: (value: ColorPickerValue) => void,
|
|
124
|
-
onSelectionChange: ColorPickerProps['onSelectionChange'],
|
|
125
|
-
) {
|
|
126
|
-
if (tab === 'wheel')
|
|
127
|
-
return wheel ? (
|
|
128
|
-
<ColorWheel
|
|
129
|
-
{...wheel}
|
|
130
|
-
harmony={value.wheel.harmony}
|
|
131
|
-
onChange={(next) => {
|
|
132
|
-
onValueChange({ ...value, wheel: next });
|
|
133
|
-
onSelectionChange?.({ mode: 'wheel', value: next });
|
|
134
|
-
}}
|
|
135
|
-
value={value.wheel.color}
|
|
136
|
-
/>
|
|
137
|
-
) : null;
|
|
138
|
-
if (tab === 'tone')
|
|
139
|
-
return tone ? (
|
|
140
|
-
<ColorTone
|
|
141
|
-
{...tone}
|
|
142
|
-
onChange={(next) => {
|
|
143
|
-
onValueChange({ ...value, tone: next });
|
|
144
|
-
onSelectionChange?.({ mode: 'tone', value: next });
|
|
145
|
-
}}
|
|
146
|
-
value={value.tone}
|
|
147
|
-
/>
|
|
148
|
-
) : null;
|
|
149
|
-
return hue ? (
|
|
150
|
-
<ColorHueScale
|
|
151
|
-
{...hue}
|
|
152
|
-
onChange={(next) => {
|
|
153
|
-
onValueChange({ ...value, hue: next });
|
|
154
|
-
onSelectionChange?.({ mode: 'hue', value: next });
|
|
155
|
-
}}
|
|
156
|
-
value={value.hue}
|
|
157
|
-
/>
|
|
158
|
-
) : null;
|
|
484
|
+
/*** Narrows a Surface tab value to the new ColorPicker vocabulary. */
|
|
485
|
+
function isColorPickerTab(value: string): value is ColorPickerTab {
|
|
486
|
+
return value === 'grid' || value === 'wheel';
|
|
159
487
|
}
|