@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,26 +1,9 @@
|
|
|
1
1
|
import { generateHarmonyRoleColors, type HexColor } from '@ankhorage/color-theory';
|
|
2
|
-
import { Button } from '@ankhorage/surface';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
Circle,
|
|
6
|
-
Defs,
|
|
7
|
-
Line,
|
|
8
|
-
LinearGradient,
|
|
9
|
-
Path,
|
|
10
|
-
Polygon,
|
|
11
|
-
RadialGradient,
|
|
12
|
-
Rect,
|
|
13
|
-
Stop,
|
|
14
|
-
Svg,
|
|
15
|
-
} from 'react-native-svg';
|
|
3
|
+
import { Circle, Defs, Line, Path, Polygon, RadialGradient, Stop, Svg } from 'react-native-svg';
|
|
16
4
|
|
|
17
5
|
import type { ColorWheelProps } from '../../types/color';
|
|
18
|
-
import { View } from '../layout/public';
|
|
19
6
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
20
|
-
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
21
|
-
import { Text } from '../typography/public';
|
|
22
|
-
import { ColorHexField } from './ColorHexField';
|
|
23
|
-
import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
|
|
24
7
|
import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
|
|
25
8
|
import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
|
|
26
9
|
import { resolveColorHue } from './utils/resolveColorHue';
|
|
@@ -28,16 +11,16 @@ import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
|
28
11
|
import { resolveWheelColor } from './utils/resolveWheelColor';
|
|
29
12
|
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
30
13
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
14
|
+
const VIEWBOX = 1000;
|
|
15
|
+
const CENTER = VIEWBOX / 2;
|
|
16
|
+
const RADIUS = 480;
|
|
17
|
+
const SEGMENTS = 720;
|
|
18
|
+
const MAX_CHROMA = 0.2;
|
|
36
19
|
|
|
37
|
-
/***
|
|
20
|
+
/*** Renders a size-owned, filled OKLCH wheel with controlled primary and harmony points. */
|
|
38
21
|
export const ColorWheel = withZoraThemeScope(ColorWheelInner);
|
|
39
22
|
|
|
40
|
-
/***
|
|
23
|
+
/*** Maps pointer and keyboard input through one viewBox into the controlled selected colour. */
|
|
41
24
|
function ColorWheelInner({
|
|
42
25
|
themeId: _themeId,
|
|
43
26
|
mode: _mode,
|
|
@@ -45,264 +28,163 @@ function ColorWheelInner({
|
|
|
45
28
|
interactionPolicy,
|
|
46
29
|
value,
|
|
47
30
|
harmony = null,
|
|
48
|
-
|
|
31
|
+
toneTarget,
|
|
49
32
|
onChange,
|
|
33
|
+
size = 340,
|
|
50
34
|
testID,
|
|
51
35
|
}: ColorWheelProps) {
|
|
52
|
-
const { theme } = useZoraTheme();
|
|
53
36
|
const hue = resolveColorHue(value);
|
|
54
37
|
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
38
|
+
const targetLightness = toneTarget?.lightness ?? lightness;
|
|
39
|
+
const maximumChroma = toneTarget?.chroma ?? MAX_CHROMA;
|
|
40
|
+
const primaryPoint = pointFor(hue, Math.min(1, chroma / maximumChroma));
|
|
41
|
+
const harmonyRoles = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];
|
|
42
|
+
const harmonyPoints = harmonyRoles.map((role) => ({
|
|
43
|
+
color: role.hex,
|
|
44
|
+
...pointFor(
|
|
45
|
+
role.hueDegrees,
|
|
46
|
+
Math.min(1, resolveWheelColorComponents(role.hex).chroma / maximumChroma),
|
|
47
|
+
),
|
|
48
|
+
}));
|
|
49
|
+
const gradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
|
|
50
|
+
const changeAt = (x: number, y: number) => {
|
|
51
|
+
if (interactionPolicy !== 'passive')
|
|
52
|
+
onChange({
|
|
53
|
+
color: resolveWheelColor(value, x, y, CENTER, RADIUS, maximumChroma, targetLightness),
|
|
54
|
+
harmony,
|
|
55
|
+
});
|
|
70
56
|
};
|
|
71
|
-
const changeLightness = (nextLightness: number) =>
|
|
72
|
-
onChange({
|
|
73
|
-
color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, nextLightness)) }, hue),
|
|
74
|
-
harmony,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
57
|
return (
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
58
|
+
<ColorWheelKeyboardProxy
|
|
59
|
+
chroma={chroma}
|
|
60
|
+
disabled={interactionPolicy === 'passive'}
|
|
61
|
+
hue={hue}
|
|
62
|
+
maxChroma={maximumChroma}
|
|
63
|
+
onChange={(nextHue, nextChroma) =>
|
|
64
|
+
onChange({
|
|
65
|
+
color: resolveOklchColor({ chroma: nextChroma, lightness: targetLightness }, nextHue),
|
|
66
|
+
harmony,
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
>
|
|
70
|
+
<ColorWheelPointerProxy
|
|
81
71
|
disabled={interactionPolicy === 'passive'}
|
|
82
|
-
|
|
83
|
-
onChange={
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{ lightness: resolveWheelLightness(value), chroma: nextChroma },
|
|
87
|
-
nextHue,
|
|
88
|
-
),
|
|
89
|
-
harmony,
|
|
90
|
-
})
|
|
91
|
-
}
|
|
72
|
+
height={VIEWBOX}
|
|
73
|
+
onChange={changeAt}
|
|
74
|
+
renderedSize={size}
|
|
75
|
+
width={VIEWBOX}
|
|
92
76
|
>
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
height={
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
<Svg
|
|
78
|
+
accessibilityLabel="Color wheel"
|
|
79
|
+
height={size}
|
|
80
|
+
testID={testID}
|
|
81
|
+
viewBox={`0 0 ${VIEWBOX} ${VIEWBOX}`}
|
|
82
|
+
width={size}
|
|
98
83
|
>
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onResponderMove={(event) => {
|
|
107
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
108
|
-
changeColorAt(locationX, locationY);
|
|
109
|
-
}}
|
|
110
|
-
onResponderRelease={(event) => {
|
|
111
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
112
|
-
changeColorAt(locationX, locationY);
|
|
113
|
-
}}
|
|
114
|
-
onStartShouldSetResponder={() => interactionPolicy !== 'passive'}
|
|
115
|
-
width={WHEEL_SIZE}
|
|
116
|
-
>
|
|
117
|
-
<Defs>
|
|
118
|
-
{resolveWheelSegments().map((segment) => (
|
|
119
|
-
<RadialGradient
|
|
120
|
-
cx={WHEEL_CENTER}
|
|
121
|
-
cy={WHEEL_CENTER}
|
|
122
|
-
id={`${wheelGradientId}-${segment.hue}`}
|
|
123
|
-
key={segment.hue}
|
|
124
|
-
r={WHEEL_RADIUS}
|
|
125
|
-
>
|
|
126
|
-
<Stop
|
|
127
|
-
offset="0"
|
|
128
|
-
stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)}
|
|
129
|
-
/>
|
|
130
|
-
<Stop offset="1" stopColor={segment.color} />
|
|
131
|
-
</RadialGradient>
|
|
132
|
-
))}
|
|
133
|
-
</Defs>
|
|
134
|
-
{resolveWheelSegments().map((segment) => (
|
|
135
|
-
<Path
|
|
136
|
-
d={segment.path}
|
|
137
|
-
fill={`url(#${wheelGradientId}-${segment.hue})`}
|
|
84
|
+
<Defs>
|
|
85
|
+
{segments(targetLightness, maximumChroma).map((segment) => (
|
|
86
|
+
<RadialGradient
|
|
87
|
+
cx={CENTER}
|
|
88
|
+
cy={CENTER}
|
|
89
|
+
gradientUnits="userSpaceOnUse"
|
|
90
|
+
id={`${gradientId}-${segment.hue}`}
|
|
138
91
|
key={segment.hue}
|
|
139
|
-
|
|
92
|
+
r={RADIUS}
|
|
93
|
+
>
|
|
94
|
+
<Stop offset="0" stopColor={segment.centerColor} />
|
|
95
|
+
<Stop offset="1" stopColor={segment.color} />
|
|
96
|
+
</RadialGradient>
|
|
140
97
|
))}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
98
|
+
</Defs>
|
|
99
|
+
{segments(targetLightness, maximumChroma).map((segment) => (
|
|
100
|
+
<Path d={segment.path} fill={`url(#${gradientId}-${segment.hue})`} key={segment.hue} />
|
|
101
|
+
))}
|
|
102
|
+
{harmonyPoints.length >= 3 ? (
|
|
103
|
+
<Polygon
|
|
104
|
+
fill="none"
|
|
105
|
+
points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}
|
|
106
|
+
stroke="white"
|
|
107
|
+
strokeWidth={6}
|
|
108
|
+
/>
|
|
109
|
+
) : (
|
|
110
|
+
linesFor(harmonyPoints, primaryPoint, 'white')
|
|
111
|
+
)}
|
|
112
|
+
{harmonyPoints
|
|
113
|
+
.filter((point) => point.color !== value)
|
|
114
|
+
.map((point) => (
|
|
152
115
|
<Circle
|
|
153
116
|
cx={point.x}
|
|
154
117
|
cy={point.y}
|
|
155
|
-
fill={
|
|
118
|
+
fill={point.color}
|
|
156
119
|
key={`${point.x}-${point.y}`}
|
|
157
|
-
|
|
120
|
+
stroke="white"
|
|
121
|
+
strokeWidth={6}
|
|
122
|
+
r={26}
|
|
158
123
|
/>
|
|
159
124
|
))}
|
|
160
|
-
<Circle
|
|
161
|
-
cx={selectedPoint.x}
|
|
162
|
-
cy={selectedPoint.y}
|
|
163
|
-
fill="none"
|
|
164
|
-
r={9}
|
|
165
|
-
stroke={theme.semantics.content.default}
|
|
166
|
-
strokeWidth={3}
|
|
167
|
-
/>
|
|
168
|
-
</Svg>
|
|
169
|
-
</ColorWheelPointerProxy>
|
|
170
|
-
</ColorWheelKeyboardProxy>
|
|
171
|
-
<ColorLightnessSlider
|
|
172
|
-
chroma={chroma}
|
|
173
|
-
disabled={interactionPolicy === 'passive'}
|
|
174
|
-
hue={hue}
|
|
175
|
-
lightness={lightness}
|
|
176
|
-
onChange={changeLightness}
|
|
177
|
-
selectionBorderColor={theme.semantics.content.default}
|
|
178
|
-
/>
|
|
179
|
-
<ColorHexField
|
|
180
|
-
disabled={interactionPolicy === 'passive'}
|
|
181
|
-
key={value}
|
|
182
|
-
onChange={(color) => onChange({ color, harmony })}
|
|
183
|
-
value={value}
|
|
184
|
-
/>
|
|
185
|
-
{harmonies ? (
|
|
186
|
-
<View direction="row" gap="xs" wrap="wrap">
|
|
187
|
-
<Button
|
|
188
|
-
disabled={interactionPolicy === 'passive'}
|
|
189
|
-
onPress={() => onChange({ color: value, harmony: null })}
|
|
190
|
-
variant={harmony === null ? 'solid' : 'outline'}
|
|
191
|
-
>
|
|
192
|
-
None
|
|
193
|
-
</Button>
|
|
194
|
-
{harmonies.map((candidate) => (
|
|
195
|
-
<Button
|
|
196
|
-
key={candidate}
|
|
197
|
-
disabled={interactionPolicy === 'passive'}
|
|
198
|
-
onPress={() => onChange({ color: value, harmony: candidate })}
|
|
199
|
-
variant={harmony === candidate ? 'solid' : 'outline'}
|
|
200
|
-
>
|
|
201
|
-
{candidate}
|
|
202
|
-
</Button>
|
|
203
|
-
))}
|
|
204
|
-
</View>
|
|
205
|
-
) : null}
|
|
206
|
-
</View>
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/*** Renders a continuous OKLCH lightness track without adding a second color persistence model. */
|
|
211
|
-
function ColorLightnessSlider({
|
|
212
|
-
chroma,
|
|
213
|
-
disabled,
|
|
214
|
-
hue,
|
|
215
|
-
lightness,
|
|
216
|
-
onChange,
|
|
217
|
-
selectionBorderColor,
|
|
218
|
-
}: {
|
|
219
|
-
readonly chroma: number;
|
|
220
|
-
readonly disabled: boolean;
|
|
221
|
-
readonly hue: number;
|
|
222
|
-
readonly lightness: number;
|
|
223
|
-
readonly onChange: (lightness: number) => void;
|
|
224
|
-
readonly selectionBorderColor: string;
|
|
225
|
-
}) {
|
|
226
|
-
const changeAt = (locationX: number) => {
|
|
227
|
-
if (!disabled) onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));
|
|
228
|
-
};
|
|
229
|
-
return (
|
|
230
|
-
<View gap="xxs" width={WHEEL_SIZE}>
|
|
231
|
-
<View direction="row" justify="space-between">
|
|
232
|
-
<Text variant="label">Lightness</Text>
|
|
233
|
-
<Text variant="label">{`${Math.round(lightness * 100)}%`}</Text>
|
|
234
|
-
</View>
|
|
235
|
-
<ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={WHEEL_SIZE}>
|
|
236
|
-
<Svg accessibilityLabel="Color lightness" height={36} width={WHEEL_SIZE}>
|
|
237
|
-
<Defs>
|
|
238
|
-
<LinearGradient id="color-lightness" x1="0" x2="1" y1="0" y2="0">
|
|
239
|
-
<Stop offset="0" stopColor={resolveOklchColor({ chroma, lightness: 0 }, hue)} />
|
|
240
|
-
<Stop offset="1" stopColor={resolveOklchColor({ chroma, lightness: 1 }, hue)} />
|
|
241
|
-
</LinearGradient>
|
|
242
|
-
</Defs>
|
|
243
|
-
<Rect fill="url(#color-lightness)" height={10} rx={5} y={13} width={WHEEL_SIZE} />
|
|
244
125
|
<Circle
|
|
245
|
-
cx={
|
|
246
|
-
cy={
|
|
247
|
-
fill=
|
|
248
|
-
r={
|
|
249
|
-
stroke=
|
|
250
|
-
strokeWidth={
|
|
126
|
+
cx={primaryPoint.x}
|
|
127
|
+
cy={primaryPoint.y}
|
|
128
|
+
fill={value}
|
|
129
|
+
r={36}
|
|
130
|
+
stroke="white"
|
|
131
|
+
strokeWidth={12}
|
|
251
132
|
/>
|
|
252
|
-
<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
width={WHEEL_SIZE}
|
|
133
|
+
<Circle
|
|
134
|
+
cx={primaryPoint.x}
|
|
135
|
+
cy={primaryPoint.y}
|
|
136
|
+
fill="none"
|
|
137
|
+
r={42}
|
|
138
|
+
stroke="white"
|
|
139
|
+
strokeWidth={6}
|
|
260
140
|
/>
|
|
261
141
|
</Svg>
|
|
262
|
-
</
|
|
263
|
-
</
|
|
142
|
+
</ColorWheelPointerProxy>
|
|
143
|
+
</ColorWheelKeyboardProxy>
|
|
264
144
|
);
|
|
265
145
|
}
|
|
266
146
|
|
|
267
|
-
/***
|
|
268
|
-
function
|
|
147
|
+
/*** Creates fine radial hue segments from the same OKLCH projection used for interaction. */
|
|
148
|
+
function segments(
|
|
149
|
+
lightness: number,
|
|
150
|
+
maximumChroma: number,
|
|
151
|
+
): readonly {
|
|
152
|
+
readonly centerColor: HexColor;
|
|
269
153
|
readonly color: HexColor;
|
|
270
154
|
readonly hue: number;
|
|
271
155
|
readonly path: string;
|
|
272
156
|
}[] {
|
|
273
|
-
return Array.from({ length:
|
|
274
|
-
const hue = (index * 360) /
|
|
157
|
+
return Array.from({ length: SEGMENTS }, (_, index) => {
|
|
158
|
+
const hue = (index * 360) / SEGMENTS;
|
|
275
159
|
return {
|
|
276
|
-
|
|
160
|
+
centerColor: resolveOklchColor({ chroma: 0, lightness }, hue),
|
|
161
|
+
color: resolveOklchColor({ chroma: maximumChroma, lightness }, hue),
|
|
277
162
|
hue,
|
|
278
|
-
path:
|
|
163
|
+
path: segmentPath(hue, hue + 360 / SEGMENTS),
|
|
279
164
|
};
|
|
280
165
|
});
|
|
281
166
|
}
|
|
282
167
|
|
|
283
|
-
/***
|
|
284
|
-
function
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
return `M ${
|
|
168
|
+
/*** Describes one filled wheel segment in the stable coordinate system. */
|
|
169
|
+
function segmentPath(start: number, end: number) {
|
|
170
|
+
const startPoint = pointFor(start);
|
|
171
|
+
const endPoint = pointFor(end);
|
|
172
|
+
return `M ${CENTER} ${CENTER} L ${startPoint.x} ${startPoint.y} A ${RADIUS} ${RADIUS} 0 0 1 ${endPoint.x} ${endPoint.y} Z`;
|
|
288
173
|
}
|
|
289
174
|
|
|
290
|
-
/***
|
|
291
|
-
function
|
|
292
|
-
hue: number,
|
|
293
|
-
radiusRatio = 1,
|
|
294
|
-
): { readonly x: number; readonly y: number } {
|
|
175
|
+
/*** Projects an OKLCH hue and chroma ratio into the wheel coordinate system. */
|
|
176
|
+
function pointFor(hue: number, ratio = 1) {
|
|
295
177
|
const radians = ((hue - 90) * Math.PI) / 180;
|
|
296
178
|
return {
|
|
297
|
-
x:
|
|
298
|
-
y:
|
|
179
|
+
x: CENTER + RADIUS * ratio * Math.cos(radians),
|
|
180
|
+
y: CENTER + RADIUS * ratio * Math.sin(radians),
|
|
299
181
|
};
|
|
300
182
|
}
|
|
301
183
|
|
|
302
|
-
/***
|
|
303
|
-
function
|
|
184
|
+
/*** Connects derived harmony points behind their corresponding knobs. */
|
|
185
|
+
function linesFor(
|
|
304
186
|
points: readonly { readonly x: number; readonly y: number }[],
|
|
305
|
-
|
|
187
|
+
primary: { readonly x: number; readonly y: number },
|
|
306
188
|
stroke: string,
|
|
307
189
|
) {
|
|
308
190
|
return points.slice(1).reduce(
|
|
@@ -312,7 +194,7 @@ function resolveHarmonyLines(
|
|
|
312
194
|
<Line
|
|
313
195
|
key={`${previous.x}-${previous.y}-${point.x}-${point.y}`}
|
|
314
196
|
stroke={stroke}
|
|
315
|
-
strokeWidth={
|
|
197
|
+
strokeWidth={6}
|
|
316
198
|
x1={previous.x}
|
|
317
199
|
x2={point.x}
|
|
318
200
|
y1={previous.y}
|
|
@@ -321,12 +203,6 @@ function resolveHarmonyLines(
|
|
|
321
203
|
],
|
|
322
204
|
previous: point,
|
|
323
205
|
}),
|
|
324
|
-
{ lines: [] as React.ReactNode[], previous: points.at(0) ??
|
|
206
|
+
{ lines: [] as React.ReactNode[], previous: points.at(0) ?? primary },
|
|
325
207
|
).lines;
|
|
326
208
|
}
|
|
327
|
-
|
|
328
|
-
/*** Read the selected color's lightness for wheel-only hue and chroma changes. */
|
|
329
|
-
function resolveWheelLightness(color: HexColor): number {
|
|
330
|
-
const { lightness } = resolveWheelColorComponents(color);
|
|
331
|
-
return lightness;
|
|
332
|
-
}
|
|
@@ -8,6 +8,7 @@ export function ColorWheelKeyboardProxy({
|
|
|
8
8
|
chroma,
|
|
9
9
|
disabled,
|
|
10
10
|
hue,
|
|
11
|
+
maxChroma = 0.2,
|
|
11
12
|
onChange,
|
|
12
13
|
}: ColorWheelKeyboardProxyProps) {
|
|
13
14
|
return (
|
|
@@ -19,7 +20,7 @@ export function ColorWheelKeyboardProxy({
|
|
|
19
20
|
aria-valuetext={`Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`}
|
|
20
21
|
aria-disabled={disabled}
|
|
21
22
|
onKeyDown={(event) => {
|
|
22
|
-
const nextValue = resolveKeyboardWheelValue(event.key, hue, chroma);
|
|
23
|
+
const nextValue = resolveKeyboardWheelValue(event.key, hue, chroma, maxChroma);
|
|
23
24
|
if (!nextValue || disabled) return;
|
|
24
25
|
event.preventDefault();
|
|
25
26
|
onChange(nextValue.hue, nextValue.chroma);
|
|
@@ -33,11 +34,11 @@ export function ColorWheelKeyboardProxy({
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/*** Resolve portable arrow keys into bounded color-wheel increments. */
|
|
36
|
-
function resolveKeyboardWheelValue(key: string, hue: number, chroma: number) {
|
|
37
|
+
function resolveKeyboardWheelValue(key: string, hue: number, chroma: number, maxChroma: number) {
|
|
37
38
|
if (key === 'ArrowLeft') return { chroma, hue: normalizeHue(hue - 5) };
|
|
38
39
|
if (key === 'ArrowRight') return { chroma, hue: normalizeHue(hue + 5) };
|
|
39
40
|
if (key === 'ArrowDown') return { chroma: Math.max(0, chroma - 0.02), hue };
|
|
40
|
-
if (key === 'ArrowUp') return { chroma: Math.min(
|
|
41
|
+
if (key === 'ArrowUp') return { chroma: Math.min(maxChroma, chroma + 0.02), hue };
|
|
41
42
|
return undefined;
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';
|
|
2
4
|
|
|
3
|
-
/***
|
|
4
|
-
export function ColorWheelPointerProxy({
|
|
5
|
-
|
|
5
|
+
/*** Adds the sole native responder path to the SVG wheel. */
|
|
6
|
+
export function ColorWheelPointerProxy({
|
|
7
|
+
children,
|
|
8
|
+
disabled,
|
|
9
|
+
height,
|
|
10
|
+
onChange,
|
|
11
|
+
width,
|
|
12
|
+
renderedSize = width,
|
|
13
|
+
}: ColorWheelPointerProxyProps) {
|
|
14
|
+
if (!React.isValidElement(children)) return children;
|
|
15
|
+
const changeAt = (event: {
|
|
16
|
+
readonly nativeEvent: { readonly locationX: number; readonly locationY: number };
|
|
17
|
+
}) =>
|
|
18
|
+
onChange(
|
|
19
|
+
(event.nativeEvent.locationX / renderedSize) * width,
|
|
20
|
+
(event.nativeEvent.locationY / renderedSize) * height,
|
|
21
|
+
);
|
|
22
|
+
return React.cloneElement(children as React.ReactElement<Record<string, unknown>>, {
|
|
23
|
+
onResponderGrant: disabled ? undefined : changeAt,
|
|
24
|
+
onResponderMove: disabled ? undefined : changeAt,
|
|
25
|
+
onResponderRelease: disabled ? undefined : changeAt,
|
|
26
|
+
onStartShouldSetResponder: () => !disabled,
|
|
27
|
+
});
|
|
6
28
|
}
|
|
@@ -2,16 +2,17 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';
|
|
4
4
|
|
|
5
|
-
/*** Maps
|
|
5
|
+
/*** Maps mouse, pen and touch coordinates into the wheel viewBox for click and drag selection. */
|
|
6
6
|
export function ColorWheelPointerProxy({
|
|
7
7
|
children,
|
|
8
8
|
disabled,
|
|
9
9
|
height,
|
|
10
10
|
onChange,
|
|
11
|
+
renderedSize: _renderedSize,
|
|
11
12
|
width,
|
|
12
13
|
}: ColorWheelPointerProxyProps) {
|
|
13
14
|
const dragging = React.useRef(false);
|
|
14
|
-
const changeAt = (event: React.
|
|
15
|
+
const changeAt = (event: React.PointerEvent<HTMLDivElement>) => {
|
|
15
16
|
const target = event.currentTarget as unknown as BrowserPointerTarget;
|
|
16
17
|
const rect = target.getBoundingClientRect();
|
|
17
18
|
onChange(
|
|
@@ -22,18 +23,24 @@ export function ColorWheelPointerProxy({
|
|
|
22
23
|
|
|
23
24
|
return (
|
|
24
25
|
<div
|
|
25
|
-
|
|
26
|
+
onPointerDown={(event) => {
|
|
26
27
|
if (disabled) return;
|
|
27
28
|
dragging.current = true;
|
|
29
|
+
(
|
|
30
|
+
event.currentTarget as unknown as { setPointerCapture: (pointerId: number) => void }
|
|
31
|
+
).setPointerCapture(event.pointerId);
|
|
28
32
|
changeAt(event);
|
|
29
33
|
}}
|
|
30
|
-
|
|
34
|
+
onPointerMove={(event) => {
|
|
31
35
|
if (!disabled && dragging.current) changeAt(event);
|
|
32
36
|
}}
|
|
33
|
-
|
|
37
|
+
onPointerUp={(event) => {
|
|
34
38
|
if (!disabled && dragging.current) changeAt(event);
|
|
35
39
|
dragging.current = false;
|
|
36
40
|
}}
|
|
41
|
+
onPointerCancel={() => {
|
|
42
|
+
dragging.current = false;
|
|
43
|
+
}}
|
|
37
44
|
style={{ touchAction: 'none' }}
|
|
38
45
|
>
|
|
39
46
|
{children}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { resolveColorPickerGeometry } from './resolveColorPickerGeometry';
|
|
4
|
+
|
|
5
|
+
test('keeps the reference Grid and Wheel stage geometry at the approved width', () => {
|
|
6
|
+
const geometry = resolveColorPickerGeometry({
|
|
7
|
+
height: 700,
|
|
8
|
+
hostHeight: 700,
|
|
9
|
+
hostWidth: 560,
|
|
10
|
+
showTabs: true,
|
|
11
|
+
width: 560,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
expect(geometry.insufficientSpace).toBe(false);
|
|
15
|
+
expect(geometry.footerInset).toBe(12);
|
|
16
|
+
expect(geometry.stage).toBe(340);
|
|
17
|
+
expect(geometry.width).toBe(560);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('uses the largest coherent geometry that fits a height-constrained host', () => {
|
|
21
|
+
const geometry = resolveColorPickerGeometry({
|
|
22
|
+
hostHeight: 500,
|
|
23
|
+
hostWidth: 560,
|
|
24
|
+
showTabs: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(geometry.insufficientSpace).toBe(false);
|
|
28
|
+
expect(geometry.height).toBeLessThanOrEqual(500);
|
|
29
|
+
expect(geometry.stage).toBeGreaterThanOrEqual(218);
|
|
30
|
+
expect(geometry.stage).toBeLessThan(340);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('reports insufficient host height instead of hiding a shrunken unusable picker', () => {
|
|
34
|
+
const geometry = resolveColorPickerGeometry({
|
|
35
|
+
hostHeight: 360,
|
|
36
|
+
hostWidth: 560,
|
|
37
|
+
showTabs: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(geometry.insufficientSpace).toBe(true);
|
|
41
|
+
expect(geometry.stage).toBeGreaterThanOrEqual(218);
|
|
42
|
+
expect(geometry.minimumHeight).toBeGreaterThan(360);
|
|
43
|
+
});
|