@ankhorage/zora 27.3.9 → 27.4.1
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 +1 -1
- package/dist/features/color/ColorHueScale.d.ts +4 -0
- package/dist/features/color/ColorHueScale.d.ts.map +1 -0
- package/dist/features/color/ColorHueScale.js +22 -0
- package/dist/features/color/ColorHueScale.js.map +1 -0
- package/dist/features/color/ColorPicker.d.ts +5 -0
- package/dist/features/color/ColorPicker.d.ts.map +1 -0
- package/dist/features/color/ColorPicker.js +48 -0
- package/dist/features/color/ColorPicker.js.map +1 -0
- package/dist/features/color/ColorTone.d.ts +5 -0
- package/dist/features/color/ColorTone.d.ts.map +1 -0
- package/dist/features/color/ColorTone.js +65 -0
- package/dist/features/color/ColorTone.js.map +1 -0
- package/dist/features/color/ColorWheel.d.ts +5 -0
- package/dist/features/color/ColorWheel.d.ts.map +1 -0
- package/dist/features/color/ColorWheel.js +125 -0
- package/dist/features/color/ColorWheel.js.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.d.ts +10 -0
- package/dist/features/color/ColorWheelKeyboardProxy.d.ts.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.js +2 -0
- package/dist/features/color/ColorWheelKeyboardProxy.js.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.d.ts +4 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.js +17 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.js.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.d.ts +5 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.js +29 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.js.map +1 -0
- package/dist/features/color/public.d.ts +6 -0
- package/dist/features/color/public.d.ts.map +1 -0
- package/dist/features/color/public.js +5 -0
- package/dist/features/color/public.js.map +1 -0
- package/dist/features/color/utils/resolveColorAtHue.d.ts +4 -0
- package/dist/features/color/utils/resolveColorAtHue.d.ts.map +1 -0
- package/dist/features/color/utils/resolveColorAtHue.js +12 -0
- package/dist/features/color/utils/resolveColorAtHue.js.map +1 -0
- package/dist/features/color/utils/resolveColorHue.d.ts +4 -0
- package/dist/features/color/utils/resolveColorHue.d.ts.map +1 -0
- package/dist/features/color/utils/resolveColorHue.js +8 -0
- package/dist/features/color/utils/resolveColorHue.js.map +1 -0
- package/dist/features/color/utils/resolveOklchColor.d.ts +5 -0
- package/dist/features/color/utils/resolveOklchColor.d.ts.map +1 -0
- package/dist/features/color/utils/resolveOklchColor.js +10 -0
- package/dist/features/color/utils/resolveOklchColor.js.map +1 -0
- package/dist/features/color/utils/resolveWheelColor.d.ts +4 -0
- package/dist/features/color/utils/resolveWheelColor.d.ts.map +1 -0
- package/dist/features/color/utils/resolveWheelColor.js +17 -0
- package/dist/features/color/utils/resolveWheelColor.js.map +1 -0
- package/dist/features/color/utils/resolveWheelColorComponents.d.ts +7 -0
- package/dist/features/color/utils/resolveWheelColorComponents.d.ts.map +1 -0
- package/dist/features/color/utils/resolveWheelColorComponents.js +11 -0
- package/dist/features/color/utils/resolveWheelColorComponents.js.map +1 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/GraphView.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/GraphView.js +11 -7
- package/dist/features/graph-view/adapters/inbound/web-artifact/GraphView.js.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/bindGraphEvents.d.ts +2 -2
- package/dist/features/graph-view/adapters/inbound/web-artifact/bindGraphEvents.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/bindGraphEvents.js +7 -7
- package/dist/features/graph-view/adapters/inbound/web-artifact/bindGraphEvents.js.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphPointerDownReader.d.ts +7 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphPointerDownReader.d.ts.map +1 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphPointerDownReader.js +40 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphPointerDownReader.js.map +1 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts +1 -1
- 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 +28 -4
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
- package/dist/features/selection/application/resolveSelectionEventIntent.d.ts +1 -1
- package/dist/features/selection/application/resolveSelectionEventIntent.d.ts.map +1 -1
- package/dist/features/selection/application/resolveSelectionEventIntent.js +14 -5
- package/dist/features/selection/application/resolveSelectionEventIntent.js.map +1 -1
- package/dist/index.d.ts +2 -0
- 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 +70 -0
- package/dist/types/color.d.ts.map +1 -0
- package/dist/types/color.js +2 -0
- package/dist/types/color.js.map +1 -0
- package/package.json +3 -1
- package/src/audit.test.ts +3 -3
- package/src/features/color/ColorHueScale.tsx +57 -0
- package/src/features/color/ColorPicker.tsx +105 -0
- package/src/features/color/ColorTone.tsx +137 -0
- package/src/features/color/ColorWheel.tsx +251 -0
- package/src/features/color/ColorWheelKeyboardProxy.native.tsx +34 -0
- package/src/features/color/ColorWheelKeyboardProxy.tsx +11 -0
- package/src/features/color/ColorWheelKeyboardProxy.web.tsx +47 -0
- package/src/features/color/public.ts +17 -0
- package/src/features/color/utils/colorMath.test.ts +37 -0
- package/src/features/color/utils/resolveColorAtHue.ts +14 -0
- package/src/features/color/utils/resolveColorHue.ts +10 -0
- package/src/features/color/utils/resolveOklchColor.ts +13 -0
- package/src/features/color/utils/resolveWheelColor.ts +28 -0
- package/src/features/color/utils/resolveWheelColorComponents.ts +16 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/GraphView.tsx +16 -4
- package/src/features/graph-view/adapters/inbound/web-artifact/bindGraphEvents.ts +24 -4
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphPointerDownReader.test.ts +28 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphPointerDownReader.ts +48 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +16 -6
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +34 -3
- package/src/features/selection/application/resolveSelectionEventIntent.test.ts +1 -0
- package/src/features/selection/application/resolveSelectionEventIntent.ts +18 -4
- package/src/index.ts +14 -0
- package/src/types/color.ts +75 -0
- package/src/webPackageExports.test.ts +15 -0
- package/web-dist/authoring/index.js +6 -5
- package/web-dist/chunks/{Accordion-5w8chhxm.js → Accordion-001ymezm.js} +3 -63
- package/web-dist/chunks/{Accordion-2d5jdxeg.js → Accordion-01s50nga.js} +2 -2
- package/web-dist/chunks/{Accordion-dhnd347t.js → Accordion-09jkcm1x.js} +695 -4591
- package/web-dist/chunks/Accordion-0z2t95zw.js +548 -0
- package/web-dist/chunks/{Accordion-z1k4wg10.js → Accordion-120nmpbe.js} +3 -3
- package/web-dist/chunks/{Accordion-zrn4dy6s.js → Accordion-401452az.js} +6 -6
- package/web-dist/chunks/{Accordion-yy6qy5y2.js → Accordion-44bcsg35.js} +6 -6
- package/web-dist/chunks/{Accordion-5hvq2r84.js → Accordion-49m38edd.js} +4 -4
- package/web-dist/chunks/{Accordion-x4bpna1q.js → Accordion-49mzcav8.js} +4 -4
- package/web-dist/chunks/{Accordion-h3r90b65.js → Accordion-52a3dpsm.js} +4 -4
- package/web-dist/chunks/{Accordion-bhr3r525.js → Accordion-549akrjn.js} +4 -4
- package/web-dist/chunks/{Accordion-7atd70rg.js → Accordion-64px84rh.js} +10 -10
- package/web-dist/chunks/{Accordion-enracgev.js → Accordion-6ec9bfd8.js} +4 -4
- package/web-dist/chunks/Accordion-6jb7b67v.js +66 -0
- package/web-dist/chunks/{Accordion-5gbd0wzf.js → Accordion-8ac6dkcs.js} +1 -1
- package/web-dist/chunks/{Accordion-w18jbs39.js → Accordion-8q7hn9aj.js} +1 -1
- package/web-dist/chunks/{Accordion-825x4t0z.js → Accordion-8vcs6nz6.js} +1 -1
- package/web-dist/chunks/{Accordion-qqv9mak2.js → Accordion-9d3rd7ne.js} +1 -1
- package/web-dist/chunks/{Accordion-zfsnh03k.js → Accordion-9hcbf56f.js} +2 -2
- package/web-dist/chunks/{Accordion-rrmy3736.js → Accordion-a6xxvydp.js} +2 -2
- package/web-dist/chunks/{Accordion-dv281jw0.js → Accordion-b4yr6yq3.js} +2 -2
- package/web-dist/chunks/{Accordion-c1x8bqnr.js → Accordion-b8t2gq8g.js} +9 -9
- package/web-dist/chunks/{Accordion-25xjvp3t.js → Accordion-dk40hsc0.js} +2 -2
- package/web-dist/chunks/{Accordion-1dr6ktbf.js → Accordion-dxhs3xwx.js} +7 -7
- package/web-dist/chunks/{Accordion-q5swmcwm.js → Accordion-e1krqvc4.js} +3 -3
- package/web-dist/chunks/{Accordion-md1g54wg.js → Accordion-eq27a9ms.js} +6 -5
- package/web-dist/chunks/{Accordion-b7jgtnvm.js → Accordion-ew2cebyd.js} +3 -3
- package/web-dist/chunks/{Accordion-j3twwxyt.js → Accordion-g9m813fh.js} +2 -2
- package/web-dist/chunks/{Accordion-b36h9a7g.js → Accordion-gysa24fk.js} +1 -1
- package/web-dist/chunks/{Accordion-2xdwc579.js → Accordion-h21ah8w3.js} +6 -6
- package/web-dist/chunks/{Accordion-2rtkfs9t.js → Accordion-hfb983jm.js} +3 -3
- package/web-dist/chunks/{Accordion-5p0pc8wp.js → Accordion-j61qh3rb.js} +2 -2
- package/web-dist/chunks/{Accordion-tf459afq.js → Accordion-kexh248h.js} +2 -2
- package/web-dist/chunks/{Accordion-gbe84kyw.js → Accordion-kx6695j5.js} +2 -2
- package/web-dist/chunks/{Accordion-w42y21pt.js → Accordion-mrhkw8n6.js} +1 -1
- package/web-dist/chunks/{Accordion-vyr0wyp9.js → Accordion-ng9pnz9r.js} +9 -9
- package/web-dist/chunks/{Accordion-x3shxr1k.js → Accordion-p43psvv8.js} +6 -6
- package/web-dist/chunks/{Accordion-6y9ac3ad.js → Accordion-rcs75kj4.js} +3 -3
- package/web-dist/chunks/Accordion-rj3ayvn5.js +3925 -0
- package/web-dist/chunks/{Accordion-4d12nnq0.js → Accordion-sheqvs8c.js} +11 -11
- package/web-dist/chunks/{Accordion-j77vvja1.js → Accordion-ss57gqjb.js} +5 -5
- package/web-dist/chunks/{Accordion-hsnh2dgt.js → Accordion-sttjd4rs.js} +7 -7
- package/web-dist/chunks/{Accordion-n95zwem8.js → Accordion-sz17szqm.js} +8 -8
- package/web-dist/chunks/{Accordion-0ecj6p6b.js → Accordion-tchccn9f.js} +5 -5
- package/web-dist/chunks/{Accordion-4d4xahgg.js → Accordion-tpd1vvy9.js} +77 -74
- package/web-dist/chunks/{Accordion-bm75sm6d.js → Accordion-vzgpdtr2.js} +1 -1
- package/web-dist/chunks/{Accordion-4hthnyjj.js → Accordion-wdefxczv.js} +9 -9
- package/web-dist/chunks/{Accordion-2pq8kbaq.js → Accordion-wtqev4qa.js} +7 -7
- package/web-dist/chunks/{Accordion-s6n61fx6.js → Accordion-x33am5bc.js} +3 -3
- package/web-dist/chunks/{Accordion-5zx8d19h.js → Accordion-xfdp8w37.js} +13 -13
- package/web-dist/chunks/{Accordion-st7rj6hc.js → Accordion-xs9aspze.js} +4 -4
- package/web-dist/chunks/{Accordion-nf16vayy.js → Accordion-z4m47w0b.js} +2 -2
- package/web-dist/chunks/{Accordion-x2d68rrj.js → Accordion-z5kr43w5.js} +4 -4
- package/web-dist/chunks/{Accordion-nks69epp.js → Accordion-z8c7y6d8.js} +5 -5
- 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 +16 -15
- package/web-dist/components/app-header/AppHeader.js +16 -15
- package/web-dist/components/app-shell/AppShell.js +4 -4
- package/web-dist/components/auth-screen/AuthScreen.js +21 -19
- 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 +19 -18
- 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 -14
- package/web-dist/components/button/Button.js +11 -10
- package/web-dist/components/button-group/ButtonGroup.js +11 -10
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +19 -18
- package/web-dist/components/card/Card.js +18 -17
- package/web-dist/components/card-back/CardBack.js +4 -4
- package/web-dist/components/card-hand/CardHand.js +4 -4
- 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 +20 -19
- package/web-dist/components/color-hue-scale/ColorHueScale.d.ts +6 -0
- package/web-dist/components/color-hue-scale/ColorHueScale.js +33 -0
- package/web-dist/components/color-hue-scale/index.d.ts +1 -0
- package/web-dist/components/color-hue-scale/index.js +2 -0
- package/web-dist/components/color-picker/ColorPicker.d.ts +6 -0
- package/web-dist/components/color-picker/ColorPicker.js +33 -0
- package/web-dist/components/color-picker/index.d.ts +1 -0
- package/web-dist/components/color-picker/index.js +2 -0
- package/web-dist/components/color-tone/ColorTone.d.ts +6 -0
- package/web-dist/components/color-tone/ColorTone.js +33 -0
- package/web-dist/components/color-tone/index.d.ts +1 -0
- package/web-dist/components/color-tone/index.js +2 -0
- package/web-dist/components/color-wheel/ColorWheel.d.ts +6 -0
- package/web-dist/components/color-wheel/ColorWheel.js +33 -0
- package/web-dist/components/color-wheel/index.d.ts +1 -0
- package/web-dist/components/color-wheel/index.js +2 -0
- package/web-dist/components/content-rail/ContentRail.js +14 -13
- package/web-dist/components/data-table/DataTable.js +25 -24
- package/web-dist/components/date-picker/DatePicker.js +16 -15
- 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 +19 -18
- 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 +21 -19
- package/web-dist/components/form/Form.js +15 -14
- package/web-dist/components/form-actions/FormActions.js +15 -14
- package/web-dist/components/form-error/FormError.js +15 -14
- 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 +81 -18
- 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 -19
- package/web-dist/components/icon/Icon.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +11 -10
- 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/matrix-grid/MatrixGrid.js +5 -5
- package/web-dist/components/media-card/MediaCard.js +18 -17
- 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 +18 -17
- package/web-dist/components/missing-element/MissingElement.js +9 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +21 -19
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +21 -19
- package/web-dist/components/opening-book/OpeningBook.js +4 -4
- package/web-dist/components/otp-form/OtpForm.js +21 -19
- package/web-dist/components/pagination/Pagination.js +14 -13
- package/web-dist/components/palette-item/PaletteItem.js +18 -17
- 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 +18 -17
- package/web-dist/components/product-card/ProductCard.js +18 -17
- 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 +21 -20
- package/web-dist/components/scan-overlay/ScanOverlay.js +19 -18
- 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 +14 -12
- 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 +14 -13
- 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 +21 -19
- package/web-dist/components/sign-up-form/SignUpForm.js +21 -19
- package/web-dist/components/skeleton/Skeleton.js +21 -20
- package/web-dist/components/skeleton-card/SkeletonCard.js +21 -20
- package/web-dist/components/skeleton-list/SkeletonList.js +21 -20
- package/web-dist/components/skeleton-text/SkeletonText.js +21 -20
- 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 +14 -12
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +13 -12
- package/web-dist/components/time-picker/TimePicker.js +16 -15
- package/web-dist/components/timeline/Timeline.js +9 -9
- 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 +18 -17
- package/web-dist/components/tree-item/TreeItem.js +19 -18
- package/web-dist/components/tree-view/TreeView.js +1 -1
- package/web-dist/components/uploader/Uploader.js +23 -22
- package/web-dist/components/view/View.js +4 -4
- package/web-dist/manifest.json +1473 -1271
- package/web-dist/runtime/ZoraProvider.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 27.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fc3a199: Preserve native Control and Command modifier intent for GraphView node selection callbacks.
|
|
8
|
+
|
|
9
|
+
## 27.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 5f86e60: Add controlled ColorPicker, ColorWheel, ColorTone, and ColorHueScale components for Web and React Native consumers.
|
|
14
|
+
|
|
3
15
|
## 27.3.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# ZORA
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Provides opinionated React Native and React Native Web UI components, theme primitives, registries, and reader surfaces built on @ankhorage/surface.
|
|
9
9
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorHueScaleProps } from '../../types/color';
|
|
2
|
+
/*** Edits the 500 base color and previews its canonical 50-to-950 swatch. */
|
|
3
|
+
export declare const ColorHueScale: (props: ColorHueScaleProps) => React.ReactElement | null;
|
|
4
|
+
//# sourceMappingURL=ColorHueScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHueScale.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHueScale.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,6EAA6E;AAC7E,eAAO,MAAM,aAAa,0DAAyC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { generateColorSwatch } from '@ankhorage/color-theory';
|
|
2
|
+
import { Pressable } from '@ankhorage/surface';
|
|
3
|
+
import { View } from '../layout/public';
|
|
4
|
+
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
5
|
+
import { Text } from '../typography/public';
|
|
6
|
+
/*** Edits the 500 base color and previews its canonical 50-to-950 swatch. */
|
|
7
|
+
export const ColorHueScale = withZoraThemeScope(ColorHueScaleInner);
|
|
8
|
+
/*** Maps generated previews to an explicitly editable 500 base without misreporting preview selection. */
|
|
9
|
+
function ColorHueScaleInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, value, onChange, testID, }) {
|
|
10
|
+
const { swatch } = generateColorSwatch(value);
|
|
11
|
+
const swatches = Object.entries(swatch);
|
|
12
|
+
return (<View accessibilityLabel="Color scale previews; choose a preview as the next 500 base color" direction="row" gap="xs" testID={testID} wrap="wrap">
|
|
13
|
+
{swatches.map(([step, color]) => (<Pressable key={step} accessibilityLabel={Number(step) === 500
|
|
14
|
+
? `Current editable base color 500: ${color}`
|
|
15
|
+
: `Use generated ${step} preview ${color} as the next base color 500`} bg={color} borderColor="border" borderWidth={Number(step) === 500 ? 3 : 1} disabled={interactionPolicy === 'passive'} height={48} onPress={() => onChange(color)} radius="sm" width={48}>
|
|
16
|
+
<Text align="center" variant="caption">
|
|
17
|
+
{step}
|
|
18
|
+
</Text>
|
|
19
|
+
</Pressable>))}
|
|
20
|
+
</View>);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ColorHueScale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHueScale.js","sourceRoot":"","sources":["../../../src/features/color/ColorHueScale.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;AAEpE,0GAA0G;AAC1G,SAAS,kBAAkB,CAA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AAI,CACP;UAAA,EAAE,IAAI,CACR;QAAA,EAAE,SAAS,CAAC,CACb,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { generateColorSwatch } from '@ankhorage/color-theory';\nimport { Pressable } from '@ankhorage/surface';\n\nimport type { ColorHueScaleProps } from '../../types/color';\nimport { View } from '../layout/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { Text } from '../typography/public';\n\n/*** Edits the 500 base color and previews its canonical 50-to-950 swatch. */\nexport const ColorHueScale = withZoraThemeScope(ColorHueScaleInner);\n\n/*** Maps generated previews to an explicitly editable 500 base without misreporting preview selection. */\nfunction ColorHueScaleInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n interactionPolicy,\n value,\n onChange,\n testID,\n}: ColorHueScaleProps) {\n const { swatch } = generateColorSwatch(value);\n const swatches = Object.entries(swatch);\n\n return (\n <View\n accessibilityLabel=\"Color scale previews; choose a preview as the next 500 base color\"\n direction=\"row\"\n gap=\"xs\"\n testID={testID}\n wrap=\"wrap\"\n >\n {swatches.map(([step, color]) => (\n <Pressable\n key={step}\n accessibilityLabel={\n Number(step) === 500\n ? `Current editable base color 500: ${color}`\n : `Use generated ${step} preview ${color} as the next base color 500`\n }\n bg={color}\n borderColor=\"border\"\n borderWidth={Number(step) === 500 ? 3 : 1}\n disabled={interactionPolicy === 'passive'}\n height={48}\n onPress={() => onChange(color)}\n radius=\"sm\"\n width={48}\n >\n <Text align=\"center\" variant=\"caption\">\n {step}\n </Text>\n </Pressable>\n ))}\n </View>\n );\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorPickerProps } from '../../types/color';
|
|
3
|
+
/*** Composes independently usable color controls into an ordered, consumer-configured picker. */
|
|
4
|
+
export declare const ColorPicker: (props: ColorPickerProps) => React.ReactElement | null;
|
|
5
|
+
//# sourceMappingURL=ColorPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAoC,MAAM,mBAAmB,CAAC;AAO5F,iGAAiG;AACjG,eAAO,MAAM,WAAW,wDAAuC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tab, TabList, TabPanel, Tabs } from '../tabs/public';
|
|
3
|
+
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
4
|
+
import { ColorHueScale } from './ColorHueScale';
|
|
5
|
+
import { ColorTone } from './ColorTone';
|
|
6
|
+
import { ColorWheel } from './ColorWheel';
|
|
7
|
+
/*** Composes independently usable color controls into an ordered, consumer-configured picker. */
|
|
8
|
+
export const ColorPicker = withZoraThemeScope(ColorPickerInner);
|
|
9
|
+
/*** Coordinates persistent controlled color selections across independently usable picker tabs. */
|
|
10
|
+
function ColorPickerInner({ themeId: _themeId, mode: _mode, inverted: _inverted, tabs, value, onValueChange, onSelectionChange, hideTabListWhenSingle = true, wheel, tone, hue, testID, }) {
|
|
11
|
+
if (tabs.length === 0)
|
|
12
|
+
throw new Error('ColorPicker requires at least one tab.');
|
|
13
|
+
if (!tabs.includes(value.tab))
|
|
14
|
+
throw new Error('ColorPicker value must be configured in tabs.');
|
|
15
|
+
return (<Tabs defaultValue={value.tab} onValueChange={(nextValue) => {
|
|
16
|
+
if (isColorPickerTab(nextValue) && tabs.includes(nextValue))
|
|
17
|
+
onValueChange({ ...value, tab: nextValue });
|
|
18
|
+
}} testID={testID} value={value.tab}>
|
|
19
|
+
{tabs.length > 1 || !hideTabListWhenSingle ? (<TabList fill>
|
|
20
|
+
{tabs.map((tab) => (<Tab key={tab} label={tab} value={tab}/>))}
|
|
21
|
+
</TabList>) : null}
|
|
22
|
+
{tabs.map((tab) => (<TabPanel key={tab} value={tab}>
|
|
23
|
+
{resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)}
|
|
24
|
+
</TabPanel>))}
|
|
25
|
+
</Tabs>);
|
|
26
|
+
}
|
|
27
|
+
/*** Check whether a Surface tab value belongs to the configured picker vocabulary. */
|
|
28
|
+
function isColorPickerTab(value) {
|
|
29
|
+
return value === 'wheel' || value === 'tone' || value === 'hue';
|
|
30
|
+
}
|
|
31
|
+
/*** Resolve the configured control for one picker tab without adding fallback feature modes. */
|
|
32
|
+
function resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange) {
|
|
33
|
+
if (tab === 'wheel')
|
|
34
|
+
return wheel ? (<ColorWheel {...wheel} harmony={value.wheel.harmony} onChange={(next) => {
|
|
35
|
+
onValueChange({ ...value, wheel: next });
|
|
36
|
+
onSelectionChange?.({ mode: 'wheel', value: next });
|
|
37
|
+
}} value={value.wheel.color}/>) : null;
|
|
38
|
+
if (tab === 'tone')
|
|
39
|
+
return tone ? (<ColorTone {...tone} onChange={(next) => {
|
|
40
|
+
onValueChange({ ...value, tone: next });
|
|
41
|
+
onSelectionChange?.({ mode: 'tone', value: next });
|
|
42
|
+
}} value={value.tone}/>) : null;
|
|
43
|
+
return hue ? (<ColorHueScale {...hue} onChange={(next) => {
|
|
44
|
+
onValueChange({ ...value, hue: next });
|
|
45
|
+
onSelectionChange?.({ mode: 'hue', value: next });
|
|
46
|
+
}} value={value.hue}/>) : null;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ColorPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CA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,CAAC;gBACzC,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EACzB,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;IACX,IAAI,GAAG,KAAK,MAAM;QAChB,OAAO,IAAI,CAAC,CAAC,CAAC,CACZ,CAAC,SAAS,CACR,IAAI,IAAI,CAAC,CACT,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjB,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBACxC,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACrD,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAClB,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;IACX,OAAO,GAAG,CAAC,CAAC,CAAC,CACX,CAAC,aAAa,CACZ,IAAI,GAAG,CAAC,CACR,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;YACjB,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ColorPickerProps, ColorPickerTab, ColorPickerValue } from '../../types/color';\nimport { Tab, TabList, TabPanel, Tabs } from '../tabs/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { ColorHueScale } from './ColorHueScale';\nimport { ColorTone } from './ColorTone';\nimport { ColorWheel } from './ColorWheel';\n\n/*** Composes independently usable color controls into an ordered, consumer-configured picker. */\nexport const ColorPicker = withZoraThemeScope(ColorPickerInner);\n\n/*** Coordinates persistent controlled color selections across independently usable picker tabs. */\nfunction ColorPickerInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n tabs,\n value,\n onValueChange,\n onSelectionChange,\n hideTabListWhenSingle = true,\n wheel,\n tone,\n hue,\n testID,\n}: ColorPickerProps) {\n if (tabs.length === 0) throw new Error('ColorPicker requires at least one tab.');\n if (!tabs.includes(value.tab)) throw new Error('ColorPicker value must be configured in tabs.');\n\n return (\n <Tabs\n defaultValue={value.tab}\n onValueChange={(nextValue) => {\n if (isColorPickerTab(nextValue) && tabs.includes(nextValue))\n onValueChange({ ...value, tab: nextValue });\n }}\n testID={testID}\n value={value.tab}\n >\n {tabs.length > 1 || !hideTabListWhenSingle ? (\n <TabList fill>\n {tabs.map((tab) => (\n <Tab key={tab} label={tab} value={tab} />\n ))}\n </TabList>\n ) : null}\n {tabs.map((tab) => (\n <TabPanel key={tab} value={tab}>\n {resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)}\n </TabPanel>\n ))}\n </Tabs>\n );\n}\n\n/*** Check whether a Surface tab value belongs to the configured picker vocabulary. */\nfunction isColorPickerTab(value: string): value is ColorPickerTab {\n return value === 'wheel' || value === 'tone' || value === 'hue';\n}\n\n/*** Resolve the configured control for one picker tab without adding fallback feature modes. */\nfunction resolveTabContent(\n tab: ColorPickerTab,\n value: ColorPickerValue,\n wheel: ColorPickerProps['wheel'],\n tone: ColorPickerProps['tone'],\n hue: ColorPickerProps['hue'],\n onValueChange: (value: ColorPickerValue) => void,\n onSelectionChange: ColorPickerProps['onSelectionChange'],\n) {\n if (tab === 'wheel')\n return wheel ? (\n <ColorWheel\n {...wheel}\n harmony={value.wheel.harmony}\n onChange={(next) => {\n onValueChange({ ...value, wheel: next });\n onSelectionChange?.({ mode: 'wheel', value: next });\n }}\n value={value.wheel.color}\n />\n ) : null;\n if (tab === 'tone')\n return tone ? (\n <ColorTone\n {...tone}\n onChange={(next) => {\n onValueChange({ ...value, tone: next });\n onSelectionChange?.({ mode: 'tone', value: next });\n }}\n value={value.tone}\n />\n ) : null;\n return hue ? (\n <ColorHueScale\n {...hue}\n onChange={(next) => {\n onValueChange({ ...value, hue: next });\n onSelectionChange?.({ mode: 'hue', value: next });\n }}\n value={value.hue}\n />\n ) : null;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorToneProps } from '../../types/color';
|
|
3
|
+
/*** Selects consumer-provided OKLCH tone targets while keeping hue adjustable. */
|
|
4
|
+
export declare const ColorTone: (props: ColorToneProps) => React.ReactElement | null;
|
|
5
|
+
//# sourceMappingURL=ColorTone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorTone.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorTone.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AASxD,kFAAkF;AAClF,eAAO,MAAM,SAAS,sDAAqC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Button, Pressable } from '@ankhorage/surface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { View } from '../layout/public';
|
|
4
|
+
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
5
|
+
import { ColorWheel } from './ColorWheel';
|
|
6
|
+
import { resolveColorHue } from './utils/resolveColorHue';
|
|
7
|
+
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
8
|
+
const MAX_TONE_COLORS = 4;
|
|
9
|
+
/*** Selects consumer-provided OKLCH tone targets while keeping hue adjustable. */
|
|
10
|
+
export const ColorTone = withZoraThemeScope(ColorToneInner);
|
|
11
|
+
/*** Renders one supplied tone and its actual, editable OKLCH color selections. */
|
|
12
|
+
function ColorToneInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, tones, selectionMode = 'single', value, onChange, testID, }) {
|
|
13
|
+
const [editingColorIndex, setEditingColorIndex] = React.useState(0);
|
|
14
|
+
const selectedTone = tones.find((tone) => tone.id === value?.toneId);
|
|
15
|
+
const colors = value
|
|
16
|
+
? selectionMode === 'single'
|
|
17
|
+
? value.colors.slice(0, 1)
|
|
18
|
+
: value.colors.slice(0, MAX_TONE_COLORS)
|
|
19
|
+
: [];
|
|
20
|
+
const currentEditingColorIndex = Math.min(editingColorIndex, Math.max(0, colors.length - 1));
|
|
21
|
+
const selectedColor = colors.at(currentEditingColorIndex);
|
|
22
|
+
const selectTone = (tone) => {
|
|
23
|
+
const hue = selectedColor ? resolveColorHue(selectedColor) : 0;
|
|
24
|
+
setEditingColorIndex(0);
|
|
25
|
+
onChange({ toneId: tone.id, colors: [resolveOklchColor(tone.accentTarget, hue)] });
|
|
26
|
+
};
|
|
27
|
+
return (<View gap="sm" testID={testID}>
|
|
28
|
+
<View direction="row" wrap="wrap" gap="sm">
|
|
29
|
+
{tones.map((tone) => {
|
|
30
|
+
const selected = value?.toneId === tone.id;
|
|
31
|
+
const color = selected && selectedColor ? selectedColor : resolveOklchColor(tone.accentTarget, 0);
|
|
32
|
+
return (<Pressable key={tone.id} accessibilityLabel={tone.accent} accessibilityRole="radio" accessibilityState={{ checked: selected }} bg={color} borderColor="border" borderWidth={selected ? 3 : 1} disabled={interactionPolicy === 'passive'} height={44} onPress={() => selectTone(tone)} radius="md" width={44}/>);
|
|
33
|
+
})}
|
|
34
|
+
</View>
|
|
35
|
+
{selectedTone && selectedColor && value ? (<>
|
|
36
|
+
<View direction="row" gap="xs" wrap="wrap">
|
|
37
|
+
{colors.map((color, index) => (<Pressable key={`${color}-${index}`} accessibilityLabel={`Selected ${selectedTone.accent} color ${index + 1}: ${color}`} accessibilityRole="radio" accessibilityState={{ checked: currentEditingColorIndex === index }} bg={color} borderColor="border" borderWidth={currentEditingColorIndex === index ? 3 : 1} disabled={interactionPolicy === 'passive'} height={44} onPress={() => setEditingColorIndex(index)} radius="md" width={44}/>))}
|
|
38
|
+
{selectionMode === 'multiple' ? (<Button disabled={interactionPolicy === 'passive' || colors.length >= MAX_TONE_COLORS} onPress={() => {
|
|
39
|
+
setEditingColorIndex(colors.length);
|
|
40
|
+
onChange({
|
|
41
|
+
toneId: selectedTone.id,
|
|
42
|
+
colors: [...colors, resolveOklchColor(selectedTone.accentTarget, 0)],
|
|
43
|
+
});
|
|
44
|
+
}}>
|
|
45
|
+
Add color
|
|
46
|
+
</Button>) : null}
|
|
47
|
+
{selectionMode === 'multiple' && colors.length > 1 ? (<Button disabled={interactionPolicy === 'passive'} onPress={() => {
|
|
48
|
+
const nextColors = colors.filter((_, index) => index !== currentEditingColorIndex);
|
|
49
|
+
setEditingColorIndex(Math.min(currentEditingColorIndex, nextColors.length - 1));
|
|
50
|
+
onChange({ toneId: selectedTone.id, colors: nextColors });
|
|
51
|
+
}}>
|
|
52
|
+
Remove color
|
|
53
|
+
</Button>) : null}
|
|
54
|
+
</View>
|
|
55
|
+
<ColorWheel harmony={null} interactionPolicy={interactionPolicy} onChange={({ color }) => {
|
|
56
|
+
const nextColor = resolveOklchColor(selectedTone.accentTarget, resolveColorHue(color));
|
|
57
|
+
onChange({
|
|
58
|
+
toneId: selectedTone.id,
|
|
59
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex ? nextColor : entry),
|
|
60
|
+
});
|
|
61
|
+
}} value={selectedColor}/>
|
|
62
|
+
</>) : null}
|
|
63
|
+
</View>);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ColorTone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorTone.js","sourceRoot":"","sources":["../../../src/features/color/ColorTone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA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AAO,CAAC,CAAC,IAAI,CAAC,CACd,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;gBACtB,MAAM,SAAS,GAAG,iBAAiB,CACjC,YAAY,CAAC,YAAY,EACzB,eAAe,CAAC,KAAK,CAAC,CACvB,CAAC;gBACF,QAAQ,CAAC;oBACP,MAAM,EAAE,YAAY,CAAC,EAAE;oBACvB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAClC,KAAK,KAAK,wBAAwB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CACvD;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,aAAa,CAAC,EAEzB;QAAA,GAAG,CACJ,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { Button, Pressable } from '@ankhorage/surface';\nimport React from 'react';\n\nimport type { ColorToneProps } from '../../types/color';\nimport { View } from '../layout/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { ColorWheel } from './ColorWheel';\nimport { resolveColorHue } from './utils/resolveColorHue';\nimport { resolveOklchColor } from './utils/resolveOklchColor';\n\nconst MAX_TONE_COLORS = 4;\n\n/*** Selects consumer-provided OKLCH tone targets while keeping hue adjustable. */\nexport const ColorTone = withZoraThemeScope(ColorToneInner);\n\n/*** Renders one supplied tone and its actual, editable OKLCH color selections. */\nfunction ColorToneInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n interactionPolicy,\n tones,\n selectionMode = 'single',\n value,\n onChange,\n testID,\n}: ColorToneProps) {\n const [editingColorIndex, setEditingColorIndex] = React.useState(0);\n const selectedTone = tones.find((tone) => tone.id === value?.toneId);\n const colors = value\n ? selectionMode === 'single'\n ? value.colors.slice(0, 1)\n : value.colors.slice(0, MAX_TONE_COLORS)\n : [];\n const currentEditingColorIndex = Math.min(editingColorIndex, Math.max(0, colors.length - 1));\n const selectedColor = colors.at(currentEditingColorIndex);\n const selectTone = (tone: ColorToneProps['tones'][number]) => {\n const hue = selectedColor ? resolveColorHue(selectedColor) : 0;\n setEditingColorIndex(0);\n onChange({ toneId: tone.id, colors: [resolveOklchColor(tone.accentTarget, hue)] });\n };\n\n return (\n <View gap=\"sm\" testID={testID}>\n <View direction=\"row\" wrap=\"wrap\" gap=\"sm\">\n {tones.map((tone) => {\n const selected = value?.toneId === tone.id;\n const color =\n selected && selectedColor ? selectedColor : resolveOklchColor(tone.accentTarget, 0);\n return (\n <Pressable\n key={tone.id}\n accessibilityLabel={tone.accent}\n accessibilityRole=\"radio\"\n accessibilityState={{ checked: selected }}\n bg={color}\n borderColor=\"border\"\n borderWidth={selected ? 3 : 1}\n disabled={interactionPolicy === 'passive'}\n height={44}\n onPress={() => selectTone(tone)}\n radius=\"md\"\n width={44}\n />\n );\n })}\n </View>\n {selectedTone && selectedColor && value ? (\n <>\n <View direction=\"row\" gap=\"xs\" wrap=\"wrap\">\n {colors.map((color, index) => (\n <Pressable\n key={`${color}-${index}`}\n accessibilityLabel={`Selected ${selectedTone.accent} color ${index + 1}: ${color}`}\n accessibilityRole=\"radio\"\n accessibilityState={{ checked: currentEditingColorIndex === index }}\n bg={color}\n borderColor=\"border\"\n borderWidth={currentEditingColorIndex === index ? 3 : 1}\n disabled={interactionPolicy === 'passive'}\n height={44}\n onPress={() => setEditingColorIndex(index)}\n radius=\"md\"\n width={44}\n />\n ))}\n {selectionMode === 'multiple' ? (\n <Button\n disabled={interactionPolicy === 'passive' || colors.length >= MAX_TONE_COLORS}\n onPress={() => {\n setEditingColorIndex(colors.length);\n onChange({\n toneId: selectedTone.id,\n colors: [...colors, resolveOklchColor(selectedTone.accentTarget, 0)],\n });\n }}\n >\n Add color\n </Button>\n ) : null}\n {selectionMode === 'multiple' && colors.length > 1 ? (\n <Button\n disabled={interactionPolicy === 'passive'}\n onPress={() => {\n const nextColors = colors.filter(\n (_, index) => index !== currentEditingColorIndex,\n );\n setEditingColorIndex(Math.min(currentEditingColorIndex, nextColors.length - 1));\n onChange({ toneId: selectedTone.id, colors: nextColors });\n }}\n >\n Remove color\n </Button>\n ) : null}\n </View>\n <ColorWheel\n harmony={null}\n interactionPolicy={interactionPolicy}\n onChange={({ color }) => {\n const nextColor = resolveOklchColor(\n selectedTone.accentTarget,\n resolveColorHue(color),\n );\n onChange({\n toneId: selectedTone.id,\n colors: colors.map((entry, index) =>\n index === currentEditingColorIndex ? nextColor : entry,\n ),\n });\n }}\n value={selectedColor}\n />\n </>\n ) : null}\n </View>\n );\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorWheelProps } from '../../types/color';
|
|
3
|
+
/*** Selects an OKLCH hue and optionally visualizes the existing color-theory harmony. */
|
|
4
|
+
export declare const ColorWheel: (props: ColorWheelProps) => React.ReactElement | null;
|
|
5
|
+
//# sourceMappingURL=ColorWheel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheel.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAezD,yFAAyF;AACzF,eAAO,MAAM,UAAU,uDAAsC,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { generateHarmonyRoleColors, isHexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { Button, TextInput } from '@ankhorage/surface';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Circle, Line, Path, Polygon, Svg } from 'react-native-svg';
|
|
5
|
+
import { View } from '../layout/public';
|
|
6
|
+
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
7
|
+
import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
|
|
8
|
+
import { resolveColorHue } from './utils/resolveColorHue';
|
|
9
|
+
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
10
|
+
import { resolveWheelColor } from './utils/resolveWheelColor';
|
|
11
|
+
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
12
|
+
const WHEEL_SIZE = 240;
|
|
13
|
+
const WHEEL_CENTER = WHEEL_SIZE / 2;
|
|
14
|
+
const WHEEL_RADIUS = 104;
|
|
15
|
+
const WHEEL_SEGMENT_COUNT = 36;
|
|
16
|
+
const WHEEL_MAX_CHROMA = 0.2;
|
|
17
|
+
/*** Selects an OKLCH hue and optionally visualizes the existing color-theory harmony. */
|
|
18
|
+
export const ColorWheel = withZoraThemeScope(ColorWheelInner);
|
|
19
|
+
/*** Renders a directly manipulable hue wheel and harmony controls without returning derived colors. */
|
|
20
|
+
function ColorWheelInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, value, harmony = null, harmonies, onChange, testID, }) {
|
|
21
|
+
const hue = resolveColorHue(value);
|
|
22
|
+
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
23
|
+
const harmonyColors = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];
|
|
24
|
+
const selectedPoint = resolveWheelPoint(hue, Math.min(1, chroma / WHEEL_MAX_CHROMA));
|
|
25
|
+
const harmonyPoints = harmonyColors.map((color) => resolveWheelPoint(color.hueDegrees));
|
|
26
|
+
const harmonyLines = resolveHarmonyLines(harmonyPoints, selectedPoint);
|
|
27
|
+
const changeColorAt = (x, y) => {
|
|
28
|
+
if (interactionPolicy === 'passive')
|
|
29
|
+
return;
|
|
30
|
+
onChange({
|
|
31
|
+
color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),
|
|
32
|
+
harmony,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const changeLightness = (offset) => onChange({
|
|
36
|
+
color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, lightness + offset)) }, hue),
|
|
37
|
+
harmony,
|
|
38
|
+
});
|
|
39
|
+
return (<View align="center" gap="sm" testID={testID}>
|
|
40
|
+
<ColorWheelKeyboardProxy chroma={chroma} disabled={interactionPolicy === 'passive'} hue={hue} onChange={(nextHue, nextChroma) => onChange({
|
|
41
|
+
color: resolveOklchColor({ lightness: resolveWheelLightness(value), chroma: nextChroma }, nextHue),
|
|
42
|
+
harmony,
|
|
43
|
+
})}>
|
|
44
|
+
<Svg accessibilityLabel="Color wheel" height={WHEEL_SIZE} onResponderGrant={(event) => {
|
|
45
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
46
|
+
changeColorAt(locationX, locationY);
|
|
47
|
+
}} onResponderMove={(event) => {
|
|
48
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
49
|
+
changeColorAt(locationX, locationY);
|
|
50
|
+
}} onStartShouldSetResponder={() => interactionPolicy !== 'passive'} width={WHEEL_SIZE}>
|
|
51
|
+
{resolveWheelSegments().map((segment) => (<Path d={segment.path} fill={segment.color} key={segment.hue}/>))}
|
|
52
|
+
{harmony === 'triadic' && harmonyPoints.length === 3 ? (<Polygon fill="none" points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')} stroke="currentColor" strokeWidth={2}/>) : (harmonyLines)}
|
|
53
|
+
{harmonyPoints.map((point) => (<Circle cx={point.x} cy={point.y} fill="currentColor" key={`${point.x}-${point.y}`} r={5}/>))}
|
|
54
|
+
<Circle cx={selectedPoint.x} cy={selectedPoint.y} fill="none" r={9} stroke="currentColor" strokeWidth={3}/>
|
|
55
|
+
</Svg>
|
|
56
|
+
</ColorWheelKeyboardProxy>
|
|
57
|
+
<View direction="row" gap="xs" wrap="wrap">
|
|
58
|
+
<Button disabled={interactionPolicy === 'passive' || lightness <= 0} onPress={() => changeLightness(-0.05)}>
|
|
59
|
+
Lightness -
|
|
60
|
+
</Button>
|
|
61
|
+
<Button disabled={interactionPolicy === 'passive' || lightness >= 1} onPress={() => changeLightness(0.05)}>
|
|
62
|
+
Lightness +
|
|
63
|
+
</Button>
|
|
64
|
+
</View>
|
|
65
|
+
<ColorHexInput disabled={interactionPolicy === 'passive'} harmony={harmony} key={value} onChange={onChange} value={value}/>
|
|
66
|
+
{harmonies ? (<View direction="row" gap="xs" wrap="wrap">
|
|
67
|
+
<Button disabled={interactionPolicy === 'passive'} onPress={() => onChange({ color: value, harmony: null })} variant={harmony === null ? 'solid' : 'outline'}>
|
|
68
|
+
None
|
|
69
|
+
</Button>
|
|
70
|
+
{harmonies.map((candidate) => (<Button key={candidate} disabled={interactionPolicy === 'passive'} onPress={() => onChange({ color: value, harmony: candidate })} variant={harmony === candidate ? 'solid' : 'outline'}>
|
|
71
|
+
{candidate}
|
|
72
|
+
</Button>))}
|
|
73
|
+
</View>) : null}
|
|
74
|
+
</View>);
|
|
75
|
+
}
|
|
76
|
+
/*** Build the wheel's OKLCH segments from the existing conversion tool. */
|
|
77
|
+
function resolveWheelSegments() {
|
|
78
|
+
return Array.from({ length: WHEEL_SEGMENT_COUNT }, (_, index) => {
|
|
79
|
+
const hue = (index * 360) / WHEEL_SEGMENT_COUNT;
|
|
80
|
+
return {
|
|
81
|
+
color: resolveOklchColor({ lightness: 0.65, chroma: WHEEL_MAX_CHROMA }, hue),
|
|
82
|
+
hue,
|
|
83
|
+
path: resolveSegmentPath(hue, hue + 360 / WHEEL_SEGMENT_COUNT),
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/*** Describe one wedge in the visual hue wheel. */
|
|
88
|
+
function resolveSegmentPath(startHue, endHue) {
|
|
89
|
+
const start = resolveWheelPoint(startHue);
|
|
90
|
+
const end = resolveWheelPoint(endHue);
|
|
91
|
+
return `M ${WHEEL_CENTER} ${WHEEL_CENTER} L ${start.x} ${start.y} A ${WHEEL_RADIUS} ${WHEEL_RADIUS} 0 0 1 ${end.x} ${end.y} Z`;
|
|
92
|
+
}
|
|
93
|
+
/*** Convert a hue degree to the corresponding visual wheel coordinate. */
|
|
94
|
+
function resolveWheelPoint(hue, radiusRatio = 1) {
|
|
95
|
+
const radians = ((hue - 90) * Math.PI) / 180;
|
|
96
|
+
return {
|
|
97
|
+
x: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.cos(radians),
|
|
98
|
+
y: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.sin(radians),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/*** Connect consecutive harmony points without dynamic collection indexing. */
|
|
102
|
+
function resolveHarmonyLines(points, selectedPoint) {
|
|
103
|
+
return points.slice(1).reduce(({ lines, previous }, point) => ({
|
|
104
|
+
lines: [
|
|
105
|
+
...lines,
|
|
106
|
+
<Line key={`${previous.x}-${previous.y}-${point.x}-${point.y}`} stroke="currentColor" strokeWidth={2} x1={previous.x} x2={point.x} y1={previous.y} y2={point.y}/>,
|
|
107
|
+
],
|
|
108
|
+
previous: point,
|
|
109
|
+
}), { lines: [], previous: points.at(0) ?? selectedPoint }).lines;
|
|
110
|
+
}
|
|
111
|
+
/*** Read the selected color's lightness for wheel-only hue and chroma changes. */
|
|
112
|
+
function resolveWheelLightness(color) {
|
|
113
|
+
const { lightness } = resolveWheelColorComponents(color);
|
|
114
|
+
return lightness;
|
|
115
|
+
}
|
|
116
|
+
/*** Retains in-progress hexadecimal input while resetting for an externally controlled color. */
|
|
117
|
+
function ColorHexInput({ disabled, harmony, onChange, value, }) {
|
|
118
|
+
const [input, setInput] = React.useState(value);
|
|
119
|
+
return (<TextInput accessibilityLabel="Color hex value" disabled={disabled} onChangeText={(nextValue) => {
|
|
120
|
+
setInput(nextValue);
|
|
121
|
+
if (isHexColor(nextValue))
|
|
122
|
+
onChange({ color: nextValue, harmony: harmony ?? null });
|
|
123
|
+
}} value={input}/>);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=ColorWheel.js.map
|
|
@@ -0,0 +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E,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,iGAAiG;AACjG,SAAS,aAAa,CAAC,EACrB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,KAAK,GACoF;IACzF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,CAAC;IACxD,OAAO,CACL,CAAC,SAAS,CACR,kBAAkB,CAAC,iBAAiB,CACpC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,YAAY,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1B,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,IAAI,UAAU,CAAC,SAAS,CAAC;gBAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;QACtF,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,KAAK,CAAC,EACb,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { generateHarmonyRoleColors, type HexColor, isHexColor } from '@ankhorage/color-theory';\nimport { Button, TextInput } from '@ankhorage/surface';\nimport React from 'react';\nimport { Circle, Line, Path, Polygon, Svg } from 'react-native-svg';\n\nimport type { ColorWheelProps } from '../../types/color';\nimport { View } from '../layout/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';\nimport { resolveColorHue } from './utils/resolveColorHue';\nimport { resolveOklchColor } from './utils/resolveOklchColor';\nimport { resolveWheelColor } from './utils/resolveWheelColor';\nimport { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';\n\nconst WHEEL_SIZE = 240;\nconst WHEEL_CENTER = WHEEL_SIZE / 2;\nconst WHEEL_RADIUS = 104;\nconst WHEEL_SEGMENT_COUNT = 36;\nconst WHEEL_MAX_CHROMA = 0.2;\n\n/*** Selects an OKLCH hue and optionally visualizes the existing color-theory harmony. */\nexport const ColorWheel = withZoraThemeScope(ColorWheelInner);\n\n/*** Renders a directly manipulable hue wheel and harmony controls without returning derived colors. */\nfunction ColorWheelInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n interactionPolicy,\n value,\n harmony = null,\n harmonies,\n onChange,\n testID,\n}: ColorWheelProps) {\n const hue = resolveColorHue(value);\n const { chroma, lightness } = resolveWheelColorComponents(value);\n const harmonyColors = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];\n const selectedPoint = resolveWheelPoint(hue, Math.min(1, chroma / WHEEL_MAX_CHROMA));\n const harmonyPoints = harmonyColors.map((color) => resolveWheelPoint(color.hueDegrees));\n const harmonyLines = resolveHarmonyLines(harmonyPoints, selectedPoint);\n const changeColorAt = (x: number, y: number) => {\n if (interactionPolicy === 'passive') return;\n onChange({\n color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),\n harmony,\n });\n };\n const changeLightness = (offset: number) =>\n onChange({\n color: resolveOklchColor(\n { chroma, lightness: Math.max(0, Math.min(1, lightness + offset)) },\n hue,\n ),\n harmony,\n });\n\n return (\n <View align=\"center\" gap=\"sm\" testID={testID}>\n <ColorWheelKeyboardProxy\n chroma={chroma}\n disabled={interactionPolicy === 'passive'}\n hue={hue}\n onChange={(nextHue, nextChroma) =>\n onChange({\n color: resolveOklchColor(\n { lightness: resolveWheelLightness(value), chroma: nextChroma },\n nextHue,\n ),\n harmony,\n })\n }\n >\n <Svg\n accessibilityLabel=\"Color wheel\"\n height={WHEEL_SIZE}\n onResponderGrant={(event) => {\n const { locationX, locationY } = event.nativeEvent;\n changeColorAt(locationX, locationY);\n }}\n onResponderMove={(event) => {\n const { locationX, locationY } = event.nativeEvent;\n changeColorAt(locationX, locationY);\n }}\n onStartShouldSetResponder={() => interactionPolicy !== 'passive'}\n width={WHEEL_SIZE}\n >\n {resolveWheelSegments().map((segment) => (\n <Path d={segment.path} fill={segment.color} key={segment.hue} />\n ))}\n {harmony === 'triadic' && harmonyPoints.length === 3 ? (\n <Polygon\n fill=\"none\"\n points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}\n stroke=\"currentColor\"\n strokeWidth={2}\n />\n ) : (\n harmonyLines\n )}\n {harmonyPoints.map((point) => (\n <Circle\n cx={point.x}\n cy={point.y}\n fill=\"currentColor\"\n key={`${point.x}-${point.y}`}\n r={5}\n />\n ))}\n <Circle\n cx={selectedPoint.x}\n cy={selectedPoint.y}\n fill=\"none\"\n r={9}\n stroke=\"currentColor\"\n strokeWidth={3}\n />\n </Svg>\n </ColorWheelKeyboardProxy>\n <View direction=\"row\" gap=\"xs\" wrap=\"wrap\">\n <Button\n disabled={interactionPolicy === 'passive' || lightness <= 0}\n onPress={() => changeLightness(-0.05)}\n >\n Lightness -\n </Button>\n <Button\n disabled={interactionPolicy === 'passive' || lightness >= 1}\n onPress={() => changeLightness(0.05)}\n >\n Lightness +\n </Button>\n </View>\n <ColorHexInput\n disabled={interactionPolicy === 'passive'}\n harmony={harmony}\n key={value}\n onChange={onChange}\n value={value}\n />\n {harmonies ? (\n <View direction=\"row\" gap=\"xs\" wrap=\"wrap\">\n <Button\n disabled={interactionPolicy === 'passive'}\n onPress={() => onChange({ color: value, harmony: null })}\n variant={harmony === null ? 'solid' : 'outline'}\n >\n None\n </Button>\n {harmonies.map((candidate) => (\n <Button\n key={candidate}\n disabled={interactionPolicy === 'passive'}\n onPress={() => onChange({ color: value, harmony: candidate })}\n variant={harmony === candidate ? 'solid' : 'outline'}\n >\n {candidate}\n </Button>\n ))}\n </View>\n ) : null}\n </View>\n );\n}\n\n/*** Build the wheel's OKLCH segments from the existing conversion tool. */\nfunction resolveWheelSegments(): readonly {\n readonly color: HexColor;\n readonly hue: number;\n readonly path: string;\n}[] {\n return Array.from({ length: WHEEL_SEGMENT_COUNT }, (_, index) => {\n const hue = (index * 360) / WHEEL_SEGMENT_COUNT;\n return {\n color: resolveOklchColor({ lightness: 0.65, chroma: WHEEL_MAX_CHROMA }, hue),\n hue,\n path: resolveSegmentPath(hue, hue + 360 / WHEEL_SEGMENT_COUNT),\n };\n });\n}\n\n/*** Describe one wedge in the visual hue wheel. */\nfunction resolveSegmentPath(startHue: number, endHue: number): string {\n const start = resolveWheelPoint(startHue);\n const end = resolveWheelPoint(endHue);\n return `M ${WHEEL_CENTER} ${WHEEL_CENTER} L ${start.x} ${start.y} A ${WHEEL_RADIUS} ${WHEEL_RADIUS} 0 0 1 ${end.x} ${end.y} Z`;\n}\n\n/*** Convert a hue degree to the corresponding visual wheel coordinate. */\nfunction resolveWheelPoint(\n hue: number,\n radiusRatio = 1,\n): { readonly x: number; readonly y: number } {\n const radians = ((hue - 90) * Math.PI) / 180;\n return {\n x: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.cos(radians),\n y: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.sin(radians),\n };\n}\n\n/*** Connect consecutive harmony points without dynamic collection indexing. */\nfunction resolveHarmonyLines(\n points: readonly { readonly x: number; readonly y: number }[],\n selectedPoint: { readonly x: number; readonly y: number },\n) {\n return points.slice(1).reduce(\n ({ lines, previous }, point) => ({\n lines: [\n ...lines,\n <Line\n key={`${previous.x}-${previous.y}-${point.x}-${point.y}`}\n stroke=\"currentColor\"\n strokeWidth={2}\n x1={previous.x}\n x2={point.x}\n y1={previous.y}\n y2={point.y}\n />,\n ],\n previous: point,\n }),\n { lines: [] as React.ReactNode[], previous: points.at(0) ?? selectedPoint },\n ).lines;\n}\n\n/*** Read the selected color's lightness for wheel-only hue and chroma changes. */\nfunction resolveWheelLightness(color: HexColor): number {\n const { lightness } = resolveWheelColorComponents(color);\n return lightness;\n}\n\n/*** Retains in-progress hexadecimal input while resetting for an externally controlled color. */\nfunction ColorHexInput({\n disabled,\n harmony,\n onChange,\n value,\n}: Pick<ColorWheelProps, 'harmony' | 'onChange' | 'value'> & { readonly disabled: boolean }) {\n const [input, setInput] = React.useState<string>(value);\n return (\n <TextInput\n accessibilityLabel=\"Color hex value\"\n disabled={disabled}\n onChangeText={(nextValue) => {\n setInput(nextValue);\n if (isHexColor(nextValue)) onChange({ color: nextValue, harmony: harmony ?? null });\n }}\n value={input}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy.native';
|
|
3
|
+
export interface ColorWheelKeyboardProxyProps {
|
|
4
|
+
readonly children: React.ReactNode;
|
|
5
|
+
readonly chroma: number;
|
|
6
|
+
readonly disabled: boolean;
|
|
7
|
+
readonly hue: number;
|
|
8
|
+
readonly onChange: (hue: number, chroma: number) => void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ColorWheelKeyboardProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelKeyboardProxy.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheelKeyboardProxy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelKeyboardProxy.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheelKeyboardProxy.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["import type React from 'react';\n\nexport { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy.native';\n\nexport interface ColorWheelKeyboardProxyProps {\n readonly children: React.ReactNode;\n readonly chroma: number;\n readonly disabled: boolean;\n readonly hue: number;\n readonly onChange: (hue: number, chroma: number) => void;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorWheelKeyboardProxyProps } from './ColorWheelKeyboardProxy';
|
|
2
|
+
/*** Exposes native accessibility increment and decrement actions for the controlled color wheel. */
|
|
3
|
+
export declare function ColorWheelKeyboardProxy({ children, chroma, disabled, hue, onChange, }: ColorWheelKeyboardProxyProps): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=ColorWheelKeyboardProxy.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelKeyboardProxy.native.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheelKeyboardProxy.native.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE9E,oGAAoG;AACpG,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,GAAG,EACH,QAAQ,GACT,EAAE,4BAA4B,+BAsB9B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
/*** Exposes native accessibility increment and decrement actions for the controlled color wheel. */
|
|
3
|
+
export function ColorWheelKeyboardProxy({ children, chroma, disabled, hue, onChange, }) {
|
|
4
|
+
return (<View accessible accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]} accessibilityLabel="Color wheel" accessibilityRole="adjustable" accessibilityState={{ disabled }} accessibilityValue={{
|
|
5
|
+
max: 360,
|
|
6
|
+
min: 0,
|
|
7
|
+
now: Math.round(hue),
|
|
8
|
+
text: `Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`,
|
|
9
|
+
}} onAccessibilityAction={(event) => {
|
|
10
|
+
if (disabled)
|
|
11
|
+
return;
|
|
12
|
+
onChange(event.nativeEvent.actionName === 'increment' ? hue + 5 : hue - 5, chroma);
|
|
13
|
+
}}>
|
|
14
|
+
{children}
|
|
15
|
+
</View>);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ColorWheelKeyboardProxy.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelKeyboardProxy.native.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheelKeyboardProxy.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,oGAAoG;AACpG,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,GAAG,EACH,QAAQ,GACqB;IAC7B,OAAO,CACL,CAAC,IAAI,CACH,UAAU,CACV,oBAAoB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CACrE,kBAAkB,CAAC,aAAa,CAChC,iBAAiB,CAAC,YAAY,CAC9B,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CACjC,kBAAkB,CAAC,CAAC;YAClB,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,CAAC;YACN,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YACpB,IAAI,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;SAC5D,CAAC,CACF,qBAAqB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/B,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QACrF,CAAC,CAAC,CAEF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { View } from 'react-native';\n\nimport type { ColorWheelKeyboardProxyProps } from './ColorWheelKeyboardProxy';\n\n/*** Exposes native accessibility increment and decrement actions for the controlled color wheel. */\nexport function ColorWheelKeyboardProxy({\n children,\n chroma,\n disabled,\n hue,\n onChange,\n}: ColorWheelKeyboardProxyProps) {\n return (\n <View\n accessible\n accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}\n accessibilityLabel=\"Color wheel\"\n accessibilityRole=\"adjustable\"\n accessibilityState={{ disabled }}\n accessibilityValue={{\n max: 360,\n min: 0,\n now: Math.round(hue),\n text: `Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`,\n }}\n onAccessibilityAction={(event) => {\n if (disabled) return;\n onChange(event.nativeEvent.actionName === 'increment' ? hue + 5 : hue - 5, chroma);\n }}\n >\n {children}\n </View>\n );\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ColorWheelKeyboardProxyProps } from './ColorWheelKeyboardProxy';
|
|
3
|
+
/*** Bridges browser keyboard input to controlled OKLCH wheel hue and chroma changes. */
|
|
4
|
+
export declare function ColorWheelKeyboardProxy({ children, chroma, disabled, hue, onChange, }: ColorWheelKeyboardProxyProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=ColorWheelKeyboardProxy.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelKeyboardProxy.web.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheelKeyboardProxy.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE9E,wFAAwF;AACxF,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,GAAG,EACH,QAAQ,GACT,EAAE,4BAA4B,qBAqB9B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*** Bridges browser keyboard input to controlled OKLCH wheel hue and chroma changes. */
|
|
2
|
+
export function ColorWheelKeyboardProxy({ children, chroma, disabled, hue, onChange, }) {
|
|
3
|
+
return (<div aria-label={`Color wheel, hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`} aria-valuemax={360} aria-valuemin={0} aria-valuenow={Math.round(hue)} aria-valuetext={`Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`} aria-disabled={disabled} onKeyDown={(event) => {
|
|
4
|
+
const nextValue = resolveKeyboardWheelValue(event.key, hue, chroma);
|
|
5
|
+
if (!nextValue || disabled)
|
|
6
|
+
return;
|
|
7
|
+
event.preventDefault();
|
|
8
|
+
onChange(nextValue.hue, nextValue.chroma);
|
|
9
|
+
}} role="slider" tabIndex={disabled ? -1 : 0}>
|
|
10
|
+
{children}
|
|
11
|
+
</div>);
|
|
12
|
+
}
|
|
13
|
+
/*** Resolve portable arrow keys into bounded color-wheel increments. */
|
|
14
|
+
function resolveKeyboardWheelValue(key, hue, chroma) {
|
|
15
|
+
if (key === 'ArrowLeft')
|
|
16
|
+
return { chroma, hue: normalizeHue(hue - 5) };
|
|
17
|
+
if (key === 'ArrowRight')
|
|
18
|
+
return { chroma, hue: normalizeHue(hue + 5) };
|
|
19
|
+
if (key === 'ArrowDown')
|
|
20
|
+
return { chroma: Math.max(0, chroma - 0.02), hue };
|
|
21
|
+
if (key === 'ArrowUp')
|
|
22
|
+
return { chroma: Math.min(0.2, chroma + 0.02), hue };
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/*** Normalize keyboard hue increments to the slider's documented range. */
|
|
26
|
+
function normalizeHue(hue) {
|
|
27
|
+
return hue < 0 ? hue + 360 : hue >= 360 ? hue - 360 : hue;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ColorWheelKeyboardProxy.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelKeyboardProxy.web.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheelKeyboardProxy.web.tsx"],"names":[],"mappings":"AAIA,wFAAwF;AACxF,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,GAAG,EACH,QAAQ,GACqB;IAC7B,OAAO,CACL,CAAC,GAAG,CACF,UAAU,CAAC,CAAC,oBAAoB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAC/E,aAAa,CAAC,CAAC,GAAG,CAAC,CACnB,aAAa,CAAC,CAAC,CAAC,CAAC,CACjB,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAC/B,cAAc,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CACtE,aAAa,CAAC,CAAC,QAAQ,CAAC,CACxB,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACnB,MAAM,SAAS,GAAG,yBAAyB,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YACpE,IAAI,CAAC,SAAS,IAAI,QAAQ;gBAAE,OAAO;YACnC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC,CAAC,CACF,IAAI,CAAC,QAAQ,CACb,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAE5B;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,SAAS,yBAAyB,CAAC,GAAW,EAAE,GAAW,EAAE,MAAc;IACzE,IAAI,GAAG,KAAK,WAAW;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;IACvE,IAAI,GAAG,KAAK,YAAY;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;IACxE,IAAI,GAAG,KAAK,WAAW;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAC5E,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAC5E,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,2EAA2E;AAC3E,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAC5D,CAAC","sourcesContent":["import type React from 'react';\n\nimport type { ColorWheelKeyboardProxyProps } from './ColorWheelKeyboardProxy';\n\n/*** Bridges browser keyboard input to controlled OKLCH wheel hue and chroma changes. */\nexport function ColorWheelKeyboardProxy({\n children,\n chroma,\n disabled,\n hue,\n onChange,\n}: ColorWheelKeyboardProxyProps) {\n return (\n <div\n aria-label={`Color wheel, hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`}\n aria-valuemax={360}\n aria-valuemin={0}\n aria-valuenow={Math.round(hue)}\n aria-valuetext={`Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`}\n aria-disabled={disabled}\n onKeyDown={(event) => {\n const nextValue = resolveKeyboardWheelValue(event.key, hue, chroma);\n if (!nextValue || disabled) return;\n event.preventDefault();\n onChange(nextValue.hue, nextValue.chroma);\n }}\n role=\"slider\"\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </div>\n );\n}\n\n/*** Resolve portable arrow keys into bounded color-wheel increments. */\nfunction resolveKeyboardWheelValue(key: string, hue: number, chroma: number) {\n if (key === 'ArrowLeft') return { chroma, hue: normalizeHue(hue - 5) };\n if (key === 'ArrowRight') return { chroma, hue: normalizeHue(hue + 5) };\n if (key === 'ArrowDown') return { chroma: Math.max(0, chroma - 0.02), hue };\n if (key === 'ArrowUp') return { chroma: Math.min(0.2, chroma + 0.02), hue };\n return undefined;\n}\n\n/*** Normalize keyboard hue increments to the slider's documented range. */\nfunction normalizeHue(hue: number): number {\n return hue < 0 ? hue + 360 : hue >= 360 ? hue - 360 : hue;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ColorHueScaleProps, ColorPickerProps, ColorPickerSelection, ColorPickerTab, ColorPickerValue, ColorToneDefinition, ColorToneProps, ColorToneSelection, ColorToneTarget, ColorWheelProps, ColorWheelSelection, } from '../../types/color';
|
|
2
|
+
export { ColorHueScale } from './ColorHueScale';
|
|
3
|
+
export { ColorPicker } from './ColorPicker';
|
|
4
|
+
export { ColorTone } from './ColorTone';
|
|
5
|
+
export { ColorWheel } from './ColorWheel';
|
|
6
|
+
//# sourceMappingURL=public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/features/color/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/features/color/public.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export type {\n ColorHueScaleProps,\n ColorPickerProps,\n ColorPickerSelection,\n ColorPickerTab,\n ColorPickerValue,\n ColorToneDefinition,\n ColorToneProps,\n ColorToneSelection,\n ColorToneTarget,\n ColorWheelProps,\n ColorWheelSelection,\n} from '../../types/color';\nexport { ColorHueScale } from './ColorHueScale';\nexport { ColorPicker } from './ColorPicker';\nexport { ColorTone } from './ColorTone';\nexport { ColorWheel } from './ColorWheel';\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
/*** Preserve the selected color's lightness and chroma while changing its hue. */
|
|
3
|
+
export declare function resolveColorAtHue(color: HexColor, hue: number): HexColor;
|
|
4
|
+
//# sourceMappingURL=resolveColorAtHue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveColorAtHue.d.ts","sourceRoot":"","sources":["../../../../src/features/color/utils/resolveColorAtHue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAMxD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAMxE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { parseHexColorOrThrow } from '@ankhorage/color-theory';
|
|
2
|
+
import { converter, formatHex } from '@ankhorage/color-theory/culori/fn';
|
|
3
|
+
const toOklch = converter('oklch');
|
|
4
|
+
/*** Preserve the selected color's lightness and chroma while changing its hue. */
|
|
5
|
+
export function resolveColorAtHue(color, hue) {
|
|
6
|
+
const parsed = toOklch(color);
|
|
7
|
+
if (!parsed || typeof parsed.l !== 'number' || typeof parsed.c !== 'number')
|
|
8
|
+
return color;
|
|
9
|
+
const formatted = formatHex({ mode: 'oklch', l: parsed.l, c: parsed.c, h: hue });
|
|
10
|
+
return formatted ? parseHexColorOrThrow(formatted) : color;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=resolveColorAtHue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveColorAtHue.js","sourceRoot":"","sources":["../../../../src/features/color/utils/resolveColorAtHue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAEzE,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;AAEnC,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,KAAe,EAAE,GAAW;IAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE1F,MAAM,SAAS,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjF,OAAO,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC","sourcesContent":["import type { HexColor } from '@ankhorage/color-theory';\nimport { parseHexColorOrThrow } from '@ankhorage/color-theory';\nimport { converter, formatHex } from '@ankhorage/color-theory/culori/fn';\n\nconst toOklch = converter('oklch');\n\n/*** Preserve the selected color's lightness and chroma while changing its hue. */\nexport function resolveColorAtHue(color: HexColor, hue: number): HexColor {\n const parsed = toOklch(color);\n if (!parsed || typeof parsed.l !== 'number' || typeof parsed.c !== 'number') return color;\n\n const formatted = formatHex({ mode: 'oklch', l: parsed.l, c: parsed.c, h: hue });\n return formatted ? parseHexColorOrThrow(formatted) : color;\n}\n"]}
|