@ankhorage/zora 27.10.3 → 27.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/features/color/ColorHexField.d.ts +9 -0
- package/dist/features/color/ColorHexField.d.ts.map +1 -0
- package/dist/features/color/ColorHexField.js +17 -0
- package/dist/features/color/ColorHexField.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.d.ts +9 -0
- package/dist/features/color/ColorHorizontalPointerProxy.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.js +2 -0
- package/dist/features/color/ColorHorizontalPointerProxy.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts +4 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.js +5 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts +5 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.js +26 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.js.map +1 -0
- package/dist/features/color/ColorHueScale.d.ts.map +1 -1
- package/dist/features/color/ColorHueScale.js +18 -7
- package/dist/features/color/ColorHueScale.js.map +1 -1
- package/dist/features/color/ColorPicker.d.ts.map +1 -1
- package/dist/features/color/ColorPicker.js +37 -10
- package/dist/features/color/ColorPicker.js.map +1 -1
- package/dist/features/color/ColorSpectrumSlider.d.ts +9 -0
- package/dist/features/color/ColorSpectrumSlider.d.ts.map +1 -0
- package/dist/features/color/ColorSpectrumSlider.js +38 -0
- package/dist/features/color/ColorSpectrumSlider.js.map +1 -0
- package/dist/features/color/ColorTone.d.ts.map +1 -1
- package/dist/features/color/ColorTone.js +71 -12
- package/dist/features/color/ColorTone.js.map +1 -1
- package/dist/features/color/ColorWheel.d.ts.map +1 -1
- package/dist/features/color/ColorWheel.js +64 -36
- package/dist/features/color/ColorWheel.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.d.ts +10 -0
- package/dist/features/color/ColorWheelPointerProxy.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.js +2 -0
- package/dist/features/color/ColorWheelPointerProxy.js.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts +4 -0
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.native.js +5 -0
- package/dist/features/color/ColorWheelPointerProxy.native.js.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts +5 -0
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.web.js +26 -0
- package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +14 -2
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
- package/dist/types/color.d.ts +2 -0
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/color.js.map +1 -1
- package/package.json +2 -2
- package/src/features/color/ColorHexField.tsx +45 -0
- package/src/features/color/ColorHorizontalPointerProxy.native.tsx +6 -0
- package/src/features/color/ColorHorizontalPointerProxy.tsx +10 -0
- package/src/features/color/ColorHorizontalPointerProxy.web.tsx +45 -0
- package/src/features/color/ColorHueScale.tsx +48 -29
- package/src/features/color/ColorPicker.layout.test.tsx +72 -0
- package/src/features/color/ColorPicker.tsx +74 -20
- package/src/features/color/ColorSpectrumSlider.tsx +79 -0
- package/src/features/color/ColorTone.tsx +138 -21
- package/src/features/color/ColorWheel.tsx +173 -92
- package/src/features/color/ColorWheelPointerProxy.native.tsx +6 -0
- package/src/features/color/ColorWheelPointerProxy.tsx +11 -0
- package/src/features/color/ColorWheelPointerProxy.web.tsx +51 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +18 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +18 -2
- package/src/types/color.ts +2 -0
- package/web-dist/chunks/{Accordion-mxad79vq.js → Accordion-0kr0h68p.js} +4568 -669
- package/web-dist/chunks/{Accordion-0jkpvxwd.js → Accordion-1etqb3cj.js} +2 -2
- package/web-dist/chunks/{Accordion-jr0201qc.js → Accordion-1mxnyexh.js} +17 -17
- package/web-dist/chunks/{Accordion-9kkfz7s8.js → Accordion-3ecnh8d0.js} +4 -4
- package/web-dist/chunks/{Accordion-jsapannb.js → Accordion-3jkeydhb.js} +4 -4
- package/web-dist/chunks/{Accordion-r6gwemh9.js → Accordion-3wkd5x2q.js} +3 -3
- package/web-dist/chunks/{Accordion-0bgzetnd.js → Accordion-3zw817fr.js} +6 -6
- package/web-dist/chunks/{Accordion-91v243pz.js → Accordion-49w9bc2f.js} +2 -2
- package/web-dist/chunks/{Accordion-8vw4k0s6.js → Accordion-4g54je0w.js} +2 -2
- package/web-dist/chunks/{Accordion-1andv7gg.js → Accordion-5vs1k81g.js} +8 -8
- package/web-dist/chunks/{Accordion-ttjyk97v.js → Accordion-6m3k4avp.js} +2 -2
- package/web-dist/chunks/{Accordion-dnfrzbpb.js → Accordion-6nrpdbmb.js} +7 -7
- package/web-dist/chunks/{Accordion-y524ph0g.js → Accordion-6yv4beha.js} +1 -1
- package/web-dist/chunks/{Accordion-9cpm8x92.js → Accordion-705yrq6w.js} +1 -1
- package/web-dist/chunks/{Accordion-th8pkeqc.js → Accordion-8g9c7890.js} +4 -4
- package/web-dist/chunks/{Accordion-6qesggn9.js → Accordion-9c63jn3m.js} +4 -4
- package/web-dist/chunks/{Accordion-1mjn0atk.js → Accordion-aws0caav.js} +3 -3
- package/web-dist/chunks/{Accordion-hha54x4c.js → Accordion-bd6q61s1.js} +5 -5
- package/web-dist/chunks/{Accordion-8rkwd0wx.js → Accordion-c0a7mhq3.js} +2 -2
- package/web-dist/chunks/{Accordion-j5wsx41j.js → Accordion-c3nna2bz.js} +1 -1
- package/web-dist/chunks/{Accordion-r6mc7qtj.js → Accordion-dfq04q82.js} +9 -9
- package/web-dist/chunks/{Accordion-nbje2ywp.js → Accordion-e3r3573t.js} +3 -3
- package/web-dist/chunks/{Accordion-hqg1zbxk.js → Accordion-e5jr9ahb.js} +1 -1
- package/web-dist/chunks/{Accordion-pkbvsn5y.js → Accordion-eak89n4n.js} +6 -6
- package/web-dist/chunks/{Accordion-7e0mb55z.js → Accordion-f60g73bp.js} +6 -6
- package/web-dist/chunks/{Accordion-grtf75xt.js → Accordion-g451f3g9.js} +4 -4
- package/web-dist/chunks/{Accordion-27rxpbvf.js → Accordion-gezcm372.js} +4 -4
- package/web-dist/chunks/{Accordion-45tbe5v0.js → Accordion-h0e95qxp.js} +9 -9
- package/web-dist/chunks/{Accordion-m7jt3c87.js → Accordion-h2nd5y0z.js} +5 -5
- package/web-dist/chunks/{Accordion-f6k281sv.js → Accordion-j0zhpq4s.js} +7 -7
- package/web-dist/chunks/{Accordion-q6xnm1k4.js → Accordion-jbwey4za.js} +17 -17
- package/web-dist/chunks/{Accordion-vdqc8rxv.js → Accordion-jd26f516.js} +3 -3
- package/web-dist/chunks/{Accordion-1k7pyxdd.js → Accordion-ne91vwkd.js} +2 -2
- package/web-dist/chunks/{Accordion-k058095e.js → Accordion-p29kmwh9.js} +1 -1
- package/web-dist/chunks/{Accordion-0pbcs0xf.js → Accordion-pcj256bc.js} +5 -5
- package/web-dist/chunks/{Accordion-8wq38d9b.js → Accordion-phtyg3k4.js} +7 -7
- package/web-dist/chunks/{Accordion-b991pn6e.js → Accordion-pmfdf08d.js} +1 -1
- package/web-dist/chunks/{Accordion-xp2t3pkj.js → Accordion-q1tdazgq.js} +8 -8
- package/web-dist/chunks/{Accordion-v21vz0cg.js → Accordion-qhn8z92r.js} +3 -3
- package/web-dist/chunks/Accordion-r1wkgt7c.js +1074 -0
- package/web-dist/chunks/{Accordion-ctcxh9pk.js → Accordion-rzf52xq8.js} +2 -2
- package/web-dist/chunks/{Accordion-hrxdchkq.js → Accordion-vewhx028.js} +8 -8
- package/web-dist/chunks/{Accordion-jsdjgfn2.js → Accordion-vk2v1zwv.js} +2 -2
- package/web-dist/chunks/{Accordion-19zt3dyq.js → Accordion-vnrqvfca.js} +1 -1
- package/web-dist/chunks/{Accordion-rt4jfq2r.js → Accordion-x0p3wxfp.js} +2 -2
- package/web-dist/chunks/{Accordion-w1ag7sr4.js → Accordion-x7ynjdv7.js} +1 -1
- package/web-dist/chunks/{Accordion-ga82tcs9.js → Accordion-xb174981.js} +10 -10
- package/web-dist/chunks/{Accordion-yskcfahv.js → Accordion-xwstve3k.js} +2 -2
- package/web-dist/chunks/{Accordion-xb2nj0q6.js → Accordion-ysmzrvhn.js} +3 -3
- package/web-dist/chunks/{Accordion-tnq8bt8v.js → Accordion-z4qakakw.js} +2 -2
- package/web-dist/chunks/{Accordion-w9vbdg9r.js → Accordion-z8ryq8cb.js} +11 -11
- package/web-dist/chunks/{Accordion-x3em7tpd.js → Accordion-zx8gmww4.js} +9 -9
- package/web-dist/components/accordion/Accordion.js +10 -10
- package/web-dist/components/accordion-item/AccordionItem.js +10 -10
- package/web-dist/components/activity-indicator/ActivityIndicator.js +3 -3
- package/web-dist/components/app-bar/AppBar.js +15 -16
- package/web-dist/components/app-header/AppHeader.js +15 -16
- package/web-dist/components/app-shell/AppShell.js +4 -4
- package/web-dist/components/auth-screen/AuthScreen.js +20 -21
- package/web-dist/components/avatar/Avatar.js +10 -10
- package/web-dist/components/avatar-group/AvatarGroup.js +10 -10
- package/web-dist/components/badge/Badge.js +5 -5
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +18 -19
- package/web-dist/components/bottom-sheet/BottomSheet.js +6 -6
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +6 -6
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +6 -6
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +6 -6
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +6 -6
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +6 -6
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +15 -16
- package/web-dist/components/button/Button.js +13 -14
- package/web-dist/components/button-group/ButtonGroup.js +11 -12
- package/web-dist/components/calendar/Calendar.js +12 -13
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +18 -19
- package/web-dist/components/card/Card.js +17 -18
- package/web-dist/components/card-back/CardBack.js +4 -4
- package/web-dist/components/card-hand/CardHand.js +4 -4
- package/web-dist/components/carousel/Carousel.js +2 -2
- package/web-dist/components/chat-list-item/ChatListItem.js +14 -14
- package/web-dist/components/checkbox/Checkbox.js +10 -10
- package/web-dist/components/checkbox-group/CheckboxGroup.js +10 -10
- package/web-dist/components/chess-board/ChessBoard.js +4 -4
- package/web-dist/components/chip/Chip.js +11 -11
- package/web-dist/components/chip-group/ChipGroup.js +11 -11
- package/web-dist/components/collection-editor/CollectionEditor.js +21 -22
- package/web-dist/components/color-hue-scale/ColorHueScale.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +2 -0
- package/web-dist/components/color-tone/ColorTone.js +15 -14
- package/web-dist/components/color-wheel/ColorWheel.js +15 -14
- package/web-dist/components/content-rail/ContentRail.js +13 -14
- package/web-dist/components/data-table/DataTable.js +27 -28
- package/web-dist/components/date-picker/DatePicker.js +19 -20
- package/web-dist/components/dialog/Dialog.js +9 -9
- package/web-dist/components/divider/Divider.js +4 -4
- package/web-dist/components/empty-state/EmptyState.js +18 -19
- package/web-dist/components/explorer/Explorer.js +11 -11
- package/web-dist/components/field/Field.js +10 -10
- package/web-dist/components/file-explorer/FileExplorer.js +11 -11
- package/web-dist/components/flat-list/FlatList.js +11 -11
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +20 -21
- package/web-dist/components/form/Form.js +14 -15
- package/web-dist/components/form-actions/FormActions.js +14 -15
- package/web-dist/components/form-error/FormError.js +14 -15
- package/web-dist/components/game/Game.js +5 -5
- package/web-dist/components/game-entity/GameEntity.js +5 -5
- package/web-dist/components/game-field/GameField.js +5 -5
- package/web-dist/components/game-input-zone/GameInputZone.js +5 -5
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +5 -5
- package/web-dist/components/game-overlay/GameOverlay.js +5 -5
- package/web-dist/components/gradient/Gradient.js +5 -5
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +5 -5
- package/web-dist/components/graph-view/GraphView.js +9 -2
- package/web-dist/components/grid/Grid.js +4 -4
- package/web-dist/components/grid-line-overlay/GridLineOverlay.js +4 -4
- package/web-dist/components/grid-ruler/GridRuler.js +4 -4
- package/web-dist/components/heading/Heading.js +5 -5
- package/web-dist/components/hero/Hero.js +20 -21
- package/web-dist/components/icon/Icon.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +11 -12
- package/web-dist/components/image/Image.js +8 -8
- package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +3 -3
- package/web-dist/components/list/List.js +11 -11
- package/web-dist/components/list-item/ListItem.js +11 -11
- package/web-dist/components/list-section/ListSection.js +11 -11
- package/web-dist/components/master-detail/MasterDetail.js +4 -4
- package/web-dist/components/matrix-grid/MatrixGrid.js +4 -4
- package/web-dist/components/media-card/MediaCard.js +17 -18
- package/web-dist/components/media-explorer/MediaExplorer.js +11 -11
- package/web-dist/components/message-bubble/MessageBubble.js +14 -14
- package/web-dist/components/metric-card/MetricCard.js +17 -18
- package/web-dist/components/missing-element/MissingElement.js +9 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +20 -21
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +20 -21
- package/web-dist/components/opening-book/OpeningBook.js +4 -4
- package/web-dist/components/otp-form/OtpForm.js +20 -21
- package/web-dist/components/pagination/Pagination.js +18 -19
- package/web-dist/components/palette-item/PaletteItem.js +17 -18
- package/web-dist/components/playing-card/PlayingCard.js +4 -4
- package/web-dist/components/poker-training-table/PokerTrainingTable.js +4 -4
- package/web-dist/components/popover-menu/PopoverMenu.js +10 -10
- package/web-dist/components/post-card/PostCard.js +17 -18
- package/web-dist/components/product-card/ProductCard.js +17 -18
- package/web-dist/components/progress/Progress.js +8 -8
- package/web-dist/components/progress-ring/ProgressRing.js +8 -8
- package/web-dist/components/radio/Radio.js +12 -12
- package/web-dist/components/radio-group/RadioGroup.js +12 -12
- package/web-dist/components/rating/Rating.js +7 -7
- package/web-dist/components/reader/Reader.js +20 -21
- package/web-dist/components/scan-overlay/ScanOverlay.js +18 -19
- package/web-dist/components/screen/Screen.js +4 -4
- package/web-dist/components/screen-section/ScreenSection.js +8 -8
- package/web-dist/components/scroll-view/ScrollView.js +4 -4
- package/web-dist/components/search-input/SearchInput.js +12 -13
- package/web-dist/components/section-header/SectionHeader.js +8 -8
- package/web-dist/components/section-list/SectionList.js +11 -11
- package/web-dist/components/select/Select.js +16 -17
- package/web-dist/components/selectable-item/SelectableItem.js +3 -3
- package/web-dist/components/selection-provider/SelectionProvider.js +3 -3
- package/web-dist/components/sign-in-form/SignInForm.js +20 -21
- package/web-dist/components/sign-up-form/SignUpForm.js +20 -21
- package/web-dist/components/skeleton/Skeleton.js +20 -21
- package/web-dist/components/skeleton-card/SkeletonCard.js +20 -21
- package/web-dist/components/skeleton-list/SkeletonList.js +20 -21
- package/web-dist/components/skeleton-text/SkeletonText.js +20 -21
- package/web-dist/components/surface/Surface.js +5 -5
- package/web-dist/components/switch/Switch.js +5 -5
- package/web-dist/components/tab/Tab.js +5 -5
- package/web-dist/components/tab-list/TabList.js +5 -5
- package/web-dist/components/tab-panel/TabPanel.js +5 -5
- package/web-dist/components/tabletop-table/TabletopTable.js +4 -4
- package/web-dist/components/tabs/Tabs.js +5 -5
- package/web-dist/components/text/Text.js +5 -5
- package/web-dist/components/text-input/TextInput.js +12 -13
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +12 -13
- package/web-dist/components/time-picker/TimePicker.js +19 -20
- package/web-dist/components/timeline/Timeline.js +10 -10
- package/web-dist/components/toast/Toast.js +7 -7
- package/web-dist/components/toast-provider/ToastProvider.js +7 -7
- package/web-dist/components/toolbar/Toolbar.js +17 -18
- package/web-dist/components/tree-item/TreeItem.js +17 -18
- package/web-dist/components/uploader/Uploader.js +26 -27
- package/web-dist/components/view/View.js +4 -4
- package/web-dist/manifest.json +1417 -1459
- package/web-dist/runtime/ZoraProvider.js +6 -6
- package/web-dist/chunks/Accordion-fjnb7anx.js +0 -548
- package/web-dist/chunks/Accordion-ztcmb44y.js +0 -3928
- package/web-dist/chunks/{Accordion-ng79nxzz.js → Accordion-an5prgty.js} +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorTone.js","sourceRoot":"","sources":["../../../src/features/color/ColorTone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,kFAAkF;AAClF,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;AAE5D,kFAAkF;AAClF,SAAS,cAAc,CAAC,EACtB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,QAAQ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,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"]}
|
|
1
|
+
{"version":3,"file":"ColorTone.js","sourceRoot":"","sources":["../../../src/features/color/ColorTone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAA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AAC,IAAI,CACH,IAAI,CAAC,aAAa,CAClB,MAAM,CAAC,CAAC,eAAe,CAAC,CACxB,gBAAgB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1B,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,CACnE,CAAC,CACD,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CACzB,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,CACnE,CAAC,CACD,kBAAkB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAC5B,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,CACnE,CAAC,CACD,yBAAyB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAC3C,KAAK,CAAC,CAAC,cAAc,CAAC,EAE1B;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,sBAAsB,CAAC,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { type HexColor } from '@ankhorage/color-theory';\nimport { Button, Pressable } from '@ankhorage/surface';\nimport React from 'react';\nimport { Circle, Defs, LinearGradient, Rect, Stop, Svg } from 'react-native-svg';\n\nimport type { ColorToneProps } from '../../types/color';\nimport { View } from '../layout/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { Text } from '../typography/public';\nimport { ColorHexField } from './ColorHexField';\nimport { ColorSpectrumSlider } from './ColorSpectrumSlider';\nimport { ColorWheelPointerProxy } from './ColorWheelPointerProxy';\nimport { resolveColorHue } from './utils/resolveColorHue';\nimport { resolveOklchColor } from './utils/resolveOklchColor';\nimport { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';\n\nconst MAX_TONE_COLORS = 4;\nconst TONE_MAP_WIDTH = 280;\nconst TONE_MAP_HEIGHT = 220;\nconst TONE_MAX_CHROMA = 0.2;\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 { theme } = useZoraTheme();\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=\"m\" testID={testID}>\n <View gap=\"xs\">\n <Text variant=\"label\">Tone</Text>\n <Text emphasis=\"muted\" variant=\"caption\">\n Choose a catalog tone\n </Text>\n </View>\n <View direction=\"row\" gap=\"s\" wrap=\"wrap\">\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={theme.semantics.border.default}\n borderWidth={selected ? 3 : 1}\n disabled={interactionPolicy === 'passive'}\n height={56}\n onPress={() => selectTone(tone)}\n radius=\"m\"\n width={56}\n >\n <Text align=\"center\" variant=\"caption\">\n {tone.accent}\n </Text>\n </Pressable>\n );\n })}\n </View>\n {selectedTone && selectedColor && value ? (\n <>\n <ColorToneMap\n color={selectedColor}\n disabled={interactionPolicy === 'passive'}\n onChange={(lightness, chroma) =>\n onChange({\n toneId: selectedTone.id,\n colors: colors.map((entry, index) =>\n index === currentEditingColorIndex\n ? resolveOklchColor({ chroma, lightness }, resolveColorHue(entry))\n : entry,\n ),\n })\n }\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={theme.semantics.border.default}\n borderWidth={currentEditingColorIndex === index ? 3 : 1}\n disabled={interactionPolicy === 'passive'}\n height={44}\n onPress={() => setEditingColorIndex(index)}\n radius=\"m\"\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 <ColorSpectrumSlider\n disabled={interactionPolicy === 'passive'}\n hue={resolveColorHue(selectedColor)}\n onChange={(nextHue) =>\n onChange({\n toneId: selectedTone.id,\n colors: colors.map((entry, index) =>\n index === currentEditingColorIndex\n ? resolveOklchColor(selectedTone.accentTarget, nextHue)\n : entry,\n ),\n })\n }\n />\n <ColorHexField\n disabled={interactionPolicy === 'passive'}\n key={selectedColor}\n onChange={(color) =>\n onChange({\n toneId: selectedTone.id,\n colors: colors.map((entry, index) =>\n index === currentEditingColorIndex ? color : entry,\n ),\n })\n }\n value={selectedColor}\n />\n </>\n ) : null}\n </View>\n );\n}\n\n/*** Renders the Studio-style saturation and lightness plane for the active catalog color. */\nfunction ColorToneMap({\n color,\n disabled,\n onChange,\n}: {\n readonly color: HexColor;\n readonly disabled: boolean;\n readonly onChange: (lightness: number, chroma: number) => void;\n}) {\n const hue = resolveColorHue(color);\n const { chroma, lightness } = resolveWheelColorComponents(color);\n const gradientId = `color-tone-${React.useId().replaceAll(':', '')}`;\n const changeAt = (x: number, y: number) => {\n if (disabled) return;\n onChange(\n Math.max(0, Math.min(1, 1 - y / TONE_MAP_HEIGHT)),\n Math.max(0, Math.min(TONE_MAX_CHROMA, (x / TONE_MAP_WIDTH) * TONE_MAX_CHROMA)),\n );\n };\n\n return (\n <ColorWheelPointerProxy\n disabled={disabled}\n height={TONE_MAP_HEIGHT}\n onChange={changeAt}\n width={TONE_MAP_WIDTH}\n >\n <Svg accessibilityLabel=\"Tone color plane\" height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH}>\n <Defs>\n <LinearGradient id={`${gradientId}-white`} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n <Stop offset=\"0\" stopColor=\"white\" />\n <Stop\n offset=\"1\"\n stopColor={resolveOklchColor({ chroma: TONE_MAX_CHROMA, lightness: 0.65 }, hue)}\n />\n </LinearGradient>\n <LinearGradient id={`${gradientId}-black`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <Stop offset=\"0\" stopColor=\"transparent\" />\n <Stop offset=\"1\" stopColor=\"black\" />\n </LinearGradient>\n </Defs>\n <Rect fill={`url(#${gradientId}-white)`} height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH} />\n <Rect fill={`url(#${gradientId}-black)`} height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH} />\n <Circle\n cx={(chroma / TONE_MAX_CHROMA) * TONE_MAP_WIDTH}\n cy={(1 - lightness) * TONE_MAP_HEIGHT}\n fill=\"none\"\n r={10}\n stroke=\"white\"\n strokeWidth={3}\n />\n <Rect\n fill=\"transparent\"\n height={TONE_MAP_HEIGHT}\n onResponderGrant={(event) =>\n changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)\n }\n onResponderMove={(event) =>\n changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)\n }\n onResponderRelease={(event) =>\n changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)\n }\n onStartShouldSetResponder={() => !disabled}\n width={TONE_MAP_WIDTH}\n />\n </Svg>\n </ColorWheelPointerProxy>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorWheel.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorWheel.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAoBzD,yFAAyF;AACzF,eAAO,MAAM,UAAU,uDAAsC,CAAC"}
|
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
import { generateHarmonyRoleColors
|
|
2
|
-
import { Button
|
|
1
|
+
import { generateHarmonyRoleColors } from '@ankhorage/color-theory';
|
|
2
|
+
import { Button } from '@ankhorage/surface';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Circle, Line, Path, Polygon, Svg } from 'react-native-svg';
|
|
4
|
+
import { Circle, Defs, Line, LinearGradient, Path, Polygon, RadialGradient, Rect, Stop, Svg, } from 'react-native-svg';
|
|
5
5
|
import { View } from '../layout/public';
|
|
6
6
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
7
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
8
|
+
import { Text } from '../typography/public';
|
|
9
|
+
import { ColorHexField } from './ColorHexField';
|
|
10
|
+
import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
|
|
7
11
|
import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
|
|
12
|
+
import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
|
|
8
13
|
import { resolveColorHue } from './utils/resolveColorHue';
|
|
9
14
|
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
10
15
|
import { resolveWheelColor } from './utils/resolveWheelColor';
|
|
11
16
|
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
12
|
-
const WHEEL_SIZE =
|
|
17
|
+
const WHEEL_SIZE = 280;
|
|
13
18
|
const WHEEL_CENTER = WHEEL_SIZE / 2;
|
|
14
|
-
const WHEEL_RADIUS =
|
|
15
|
-
const WHEEL_SEGMENT_COUNT =
|
|
19
|
+
const WHEEL_RADIUS = 128;
|
|
20
|
+
const WHEEL_SEGMENT_COUNT = 72;
|
|
16
21
|
const WHEEL_MAX_CHROMA = 0.2;
|
|
17
22
|
/*** Selects an OKLCH hue and optionally visualizes the existing color-theory harmony. */
|
|
18
23
|
export const ColorWheel = withZoraThemeScope(ColorWheelInner);
|
|
19
24
|
/*** Renders a directly manipulable hue wheel and harmony controls without returning derived colors. */
|
|
20
25
|
function ColorWheelInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, value, harmony = null, harmonies, onChange, testID, }) {
|
|
26
|
+
const { theme } = useZoraTheme();
|
|
21
27
|
const hue = resolveColorHue(value);
|
|
22
28
|
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
23
29
|
const harmonyColors = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];
|
|
24
30
|
const selectedPoint = resolveWheelPoint(hue, Math.min(1, chroma / WHEEL_MAX_CHROMA));
|
|
25
31
|
const harmonyPoints = harmonyColors.map((color) => resolveWheelPoint(color.hueDegrees));
|
|
26
|
-
const harmonyLines = resolveHarmonyLines(harmonyPoints, selectedPoint);
|
|
32
|
+
const harmonyLines = resolveHarmonyLines(harmonyPoints, selectedPoint, theme.semantics.content.default);
|
|
33
|
+
const wheelGradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
|
|
27
34
|
const changeColorAt = (x, y) => {
|
|
28
35
|
if (interactionPolicy === 'passive')
|
|
29
36
|
return;
|
|
@@ -32,37 +39,41 @@ function ColorWheelInner({ themeId: _themeId, mode: _mode, inverted: _inverted,
|
|
|
32
39
|
harmony,
|
|
33
40
|
});
|
|
34
41
|
};
|
|
35
|
-
const changeLightness = (
|
|
36
|
-
color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1,
|
|
42
|
+
const changeLightness = (nextLightness) => onChange({
|
|
43
|
+
color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, nextLightness)) }, hue),
|
|
37
44
|
harmony,
|
|
38
45
|
});
|
|
39
|
-
return (<View align="center" gap="
|
|
46
|
+
return (<View align="center" gap="s" testID={testID}>
|
|
40
47
|
<ColorWheelKeyboardProxy chroma={chroma} disabled={interactionPolicy === 'passive'} hue={hue} onChange={(nextHue, nextChroma) => onChange({
|
|
41
48
|
color: resolveOklchColor({ lightness: resolveWheelLightness(value), chroma: nextChroma }, nextHue),
|
|
42
49
|
harmony,
|
|
43
50
|
})}>
|
|
44
|
-
<
|
|
51
|
+
<ColorWheelPointerProxy disabled={interactionPolicy === 'passive'} height={WHEEL_SIZE} onChange={changeColorAt} width={WHEEL_SIZE}>
|
|
52
|
+
<Svg accessibilityLabel="Color wheel" height={WHEEL_SIZE} onResponderGrant={(event) => {
|
|
45
53
|
const { locationX, locationY } = event.nativeEvent;
|
|
46
54
|
changeColorAt(locationX, locationY);
|
|
47
55
|
}} onResponderMove={(event) => {
|
|
48
56
|
const { locationX, locationY } = event.nativeEvent;
|
|
49
57
|
changeColorAt(locationX, locationY);
|
|
58
|
+
}} onResponderRelease={(event) => {
|
|
59
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
60
|
+
changeColorAt(locationX, locationY);
|
|
50
61
|
}} onStartShouldSetResponder={() => interactionPolicy !== 'passive'} width={WHEEL_SIZE}>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
<Defs>
|
|
63
|
+
{resolveWheelSegments().map((segment) => (<RadialGradient cx={WHEEL_CENTER} cy={WHEEL_CENTER} id={`${wheelGradientId}-${segment.hue}`} key={segment.hue} r={WHEEL_RADIUS}>
|
|
64
|
+
<Stop offset="0" stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)}/>
|
|
65
|
+
<Stop offset="1" stopColor={segment.color}/>
|
|
66
|
+
</RadialGradient>))}
|
|
67
|
+
</Defs>
|
|
68
|
+
{resolveWheelSegments().map((segment) => (<Path d={segment.path} fill={`url(#${wheelGradientId}-${segment.hue})`} key={segment.hue}/>))}
|
|
69
|
+
{harmony === 'triadic' && harmonyPoints.length === 3 ? (<Polygon fill="none" points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')} stroke={theme.semantics.content.default} strokeWidth={2}/>) : (harmonyLines)}
|
|
70
|
+
{harmonyPoints.map((point) => (<Circle cx={point.x} cy={point.y} fill={theme.semantics.content.default} key={`${point.x}-${point.y}`} r={5}/>))}
|
|
71
|
+
<Circle cx={selectedPoint.x} cy={selectedPoint.y} fill="none" r={9} stroke={theme.semantics.content.default} strokeWidth={3}/>
|
|
72
|
+
</Svg>
|
|
73
|
+
</ColorWheelPointerProxy>
|
|
56
74
|
</ColorWheelKeyboardProxy>
|
|
57
|
-
<
|
|
58
|
-
|
|
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}/>
|
|
75
|
+
<ColorLightnessSlider chroma={chroma} disabled={interactionPolicy === 'passive'} hue={hue} lightness={lightness} onChange={changeLightness} selectionBorderColor={theme.semantics.content.default}/>
|
|
76
|
+
<ColorHexField disabled={interactionPolicy === 'passive'} key={value} onChange={(color) => onChange({ color, harmony })} value={value}/>
|
|
66
77
|
{harmonies ? (<View direction="row" gap="xs" wrap="wrap">
|
|
67
78
|
<Button disabled={interactionPolicy === 'passive'} onPress={() => onChange({ color: value, harmony: null })} variant={harmony === null ? 'solid' : 'outline'}>
|
|
68
79
|
None
|
|
@@ -73,6 +84,32 @@ function ColorWheelInner({ themeId: _themeId, mode: _mode, inverted: _inverted,
|
|
|
73
84
|
</View>) : null}
|
|
74
85
|
</View>);
|
|
75
86
|
}
|
|
87
|
+
/*** Renders a continuous OKLCH lightness track without adding a second color persistence model. */
|
|
88
|
+
function ColorLightnessSlider({ chroma, disabled, hue, lightness, onChange, selectionBorderColor, }) {
|
|
89
|
+
const changeAt = (locationX) => {
|
|
90
|
+
if (!disabled)
|
|
91
|
+
onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));
|
|
92
|
+
};
|
|
93
|
+
return (<View gap="xxs" width={WHEEL_SIZE}>
|
|
94
|
+
<View direction="row" justify="space-between">
|
|
95
|
+
<Text variant="label">Lightness</Text>
|
|
96
|
+
<Text variant="label">{`${Math.round(lightness * 100)}%`}</Text>
|
|
97
|
+
</View>
|
|
98
|
+
<ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={WHEEL_SIZE}>
|
|
99
|
+
<Svg accessibilityLabel="Color lightness" height={36} width={WHEEL_SIZE}>
|
|
100
|
+
<Defs>
|
|
101
|
+
<LinearGradient id="color-lightness" x1="0" x2="1" y1="0" y2="0">
|
|
102
|
+
<Stop offset="0" stopColor={resolveOklchColor({ chroma, lightness: 0 }, hue)}/>
|
|
103
|
+
<Stop offset="1" stopColor={resolveOklchColor({ chroma, lightness: 1 }, hue)}/>
|
|
104
|
+
</LinearGradient>
|
|
105
|
+
</Defs>
|
|
106
|
+
<Rect fill="url(#color-lightness)" height={10} rx={5} y={13} width={WHEEL_SIZE}/>
|
|
107
|
+
<Circle cx={lightness * WHEEL_SIZE} cy={18} fill="white" r={10} stroke={selectionBorderColor} strokeWidth={2}/>
|
|
108
|
+
<Rect fill="transparent" height={36} onResponderGrant={(event) => changeAt(event.nativeEvent.locationX)} onResponderMove={(event) => changeAt(event.nativeEvent.locationX)} onResponderRelease={(event) => changeAt(event.nativeEvent.locationX)} onStartShouldSetResponder={() => !disabled} width={WHEEL_SIZE}/>
|
|
109
|
+
</Svg>
|
|
110
|
+
</ColorHorizontalPointerProxy>
|
|
111
|
+
</View>);
|
|
112
|
+
}
|
|
76
113
|
/*** Build the wheel's OKLCH segments from the existing conversion tool. */
|
|
77
114
|
function resolveWheelSegments() {
|
|
78
115
|
return Array.from({ length: WHEEL_SEGMENT_COUNT }, (_, index) => {
|
|
@@ -99,11 +136,11 @@ function resolveWheelPoint(hue, radiusRatio = 1) {
|
|
|
99
136
|
};
|
|
100
137
|
}
|
|
101
138
|
/*** Connect consecutive harmony points without dynamic collection indexing. */
|
|
102
|
-
function resolveHarmonyLines(points, selectedPoint) {
|
|
139
|
+
function resolveHarmonyLines(points, selectedPoint, stroke) {
|
|
103
140
|
return points.slice(1).reduce(({ lines, previous }, point) => ({
|
|
104
141
|
lines: [
|
|
105
142
|
...lines,
|
|
106
|
-
<Line key={`${previous.x}-${previous.y}-${point.x}-${point.y}`} stroke=
|
|
143
|
+
<Line key={`${previous.x}-${previous.y}-${point.x}-${point.y}`} stroke={stroke} strokeWidth={2} x1={previous.x} x2={point.x} y1={previous.y} y2={point.y}/>,
|
|
107
144
|
],
|
|
108
145
|
previous: point,
|
|
109
146
|
}), { lines: [], previous: points.at(0) ?? selectedPoint }).lines;
|
|
@@ -113,13 +150,4 @@ function resolveWheelLightness(color) {
|
|
|
113
150
|
const { lightness } = resolveWheelColorComponents(color);
|
|
114
151
|
return lightness;
|
|
115
152
|
}
|
|
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
153
|
//# sourceMappingURL=ColorWheel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorWheel.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAiB,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,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f,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CACf,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CACZ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CACf,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EACZ;SACH;QACD,QAAQ,EAAE,KAAK;KAChB,CAAC,EACF,EAAE,KAAK,EAAE,EAAuB,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAC5E,CAAC,KAAK,CAAC;AACV,CAAC;AAED,kFAAkF;AAClF,SAAS,qBAAqB,CAAC,KAAe;IAC5C,MAAM,EAAE,SAAS,EAAE,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"]}
|
|
1
|
+
{"version":3,"file":"ColorWheel.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAiB,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,OAAO,EACP,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,GAAG,GACJ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,aA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import { Button } from '@ankhorage/surface';\nimport React from 'react';\nimport {\n Circle,\n Defs,\n Line,\n LinearGradient,\n Path,\n Polygon,\n RadialGradient,\n Rect,\n Stop,\n Svg,\n} from 'react-native-svg';\n\nimport type { ColorWheelProps } from '../../types/color';\nimport { View } from '../layout/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { Text } from '../typography/public';\nimport { ColorHexField } from './ColorHexField';\nimport { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';\nimport { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';\nimport { ColorWheelPointerProxy } from './ColorWheelPointerProxy';\nimport { resolveColorHue } from './utils/resolveColorHue';\nimport { resolveOklchColor } from './utils/resolveOklchColor';\nimport { resolveWheelColor } from './utils/resolveWheelColor';\nimport { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';\n\nconst WHEEL_SIZE = 280;\nconst WHEEL_CENTER = WHEEL_SIZE / 2;\nconst WHEEL_RADIUS = 128;\nconst WHEEL_SEGMENT_COUNT = 72;\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 { theme } = useZoraTheme();\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(\n harmonyPoints,\n selectedPoint,\n theme.semantics.content.default,\n );\n const wheelGradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;\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 = (nextLightness: number) =>\n onChange({\n color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, nextLightness)) }, hue),\n harmony,\n });\n\n return (\n <View align=\"center\" gap=\"s\" 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 <ColorWheelPointerProxy\n disabled={interactionPolicy === 'passive'}\n height={WHEEL_SIZE}\n onChange={changeColorAt}\n width={WHEEL_SIZE}\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 onResponderRelease={(event) => {\n const { locationX, locationY } = event.nativeEvent;\n changeColorAt(locationX, locationY);\n }}\n onStartShouldSetResponder={() => interactionPolicy !== 'passive'}\n width={WHEEL_SIZE}\n >\n <Defs>\n {resolveWheelSegments().map((segment) => (\n <RadialGradient\n cx={WHEEL_CENTER}\n cy={WHEEL_CENTER}\n id={`${wheelGradientId}-${segment.hue}`}\n key={segment.hue}\n r={WHEEL_RADIUS}\n >\n <Stop\n offset=\"0\"\n stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)}\n />\n <Stop offset=\"1\" stopColor={segment.color} />\n </RadialGradient>\n ))}\n </Defs>\n {resolveWheelSegments().map((segment) => (\n <Path\n d={segment.path}\n fill={`url(#${wheelGradientId}-${segment.hue})`}\n key={segment.hue}\n />\n ))}\n {harmony === 'triadic' && harmonyPoints.length === 3 ? (\n <Polygon\n fill=\"none\"\n points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}\n stroke={theme.semantics.content.default}\n strokeWidth={2}\n />\n ) : (\n harmonyLines\n )}\n {harmonyPoints.map((point) => (\n <Circle\n cx={point.x}\n cy={point.y}\n fill={theme.semantics.content.default}\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={theme.semantics.content.default}\n strokeWidth={3}\n />\n </Svg>\n </ColorWheelPointerProxy>\n </ColorWheelKeyboardProxy>\n <ColorLightnessSlider\n chroma={chroma}\n disabled={interactionPolicy === 'passive'}\n hue={hue}\n lightness={lightness}\n onChange={changeLightness}\n selectionBorderColor={theme.semantics.content.default}\n />\n <ColorHexField\n disabled={interactionPolicy === 'passive'}\n key={value}\n onChange={(color) => onChange({ color, harmony })}\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/*** Renders a continuous OKLCH lightness track without adding a second color persistence model. */\nfunction ColorLightnessSlider({\n chroma,\n disabled,\n hue,\n lightness,\n onChange,\n selectionBorderColor,\n}: {\n readonly chroma: number;\n readonly disabled: boolean;\n readonly hue: number;\n readonly lightness: number;\n readonly onChange: (lightness: number) => void;\n readonly selectionBorderColor: string;\n}) {\n const changeAt = (locationX: number) => {\n if (!disabled) onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));\n };\n return (\n <View gap=\"xxs\" width={WHEEL_SIZE}>\n <View direction=\"row\" justify=\"space-between\">\n <Text variant=\"label\">Lightness</Text>\n <Text variant=\"label\">{`${Math.round(lightness * 100)}%`}</Text>\n </View>\n <ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={WHEEL_SIZE}>\n <Svg accessibilityLabel=\"Color lightness\" height={36} width={WHEEL_SIZE}>\n <Defs>\n <LinearGradient id=\"color-lightness\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n <Stop offset=\"0\" stopColor={resolveOklchColor({ chroma, lightness: 0 }, hue)} />\n <Stop offset=\"1\" stopColor={resolveOklchColor({ chroma, lightness: 1 }, hue)} />\n </LinearGradient>\n </Defs>\n <Rect fill=\"url(#color-lightness)\" height={10} rx={5} y={13} width={WHEEL_SIZE} />\n <Circle\n cx={lightness * WHEEL_SIZE}\n cy={18}\n fill=\"white\"\n r={10}\n stroke={selectionBorderColor}\n strokeWidth={2}\n />\n <Rect\n fill=\"transparent\"\n height={36}\n onResponderGrant={(event) => changeAt(event.nativeEvent.locationX)}\n onResponderMove={(event) => changeAt(event.nativeEvent.locationX)}\n onResponderRelease={(event) => changeAt(event.nativeEvent.locationX)}\n onStartShouldSetResponder={() => !disabled}\n width={WHEEL_SIZE}\n />\n </Svg>\n </ColorHorizontalPointerProxy>\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 stroke: string,\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={stroke}\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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export { ColorWheelPointerProxy } from './ColorWheelPointerProxy.native';
|
|
3
|
+
export interface ColorWheelPointerProxyProps {
|
|
4
|
+
readonly children: React.ReactNode;
|
|
5
|
+
readonly disabled: boolean;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
readonly onChange: (x: number, y: number) => void;
|
|
8
|
+
readonly width: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ColorWheelPointerProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelPointerProxy.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheelPointerProxy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelPointerProxy.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheelPointerProxy.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["import type React from 'react';\n\nexport { ColorWheelPointerProxy } from './ColorWheelPointerProxy.native';\n\nexport interface ColorWheelPointerProxyProps {\n readonly children: React.ReactNode;\n readonly disabled: boolean;\n readonly height: number;\n readonly onChange: (x: number, y: number) => void;\n readonly width: number;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';
|
|
2
|
+
/*** Leaves native SVG responders in charge of direct color-wheel gestures. */
|
|
3
|
+
export declare function ColorWheelPointerProxy({ children }: ColorWheelPointerProxyProps): import("react").ReactNode;
|
|
4
|
+
//# sourceMappingURL=ColorWheelPointerProxy.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelPointerProxy.native.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheelPointerProxy.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,EAAE,2BAA2B,6BAE/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelPointerProxy.native.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheelPointerProxy.native.tsx"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,UAAU,sBAAsB,CAAC,EAAE,QAAQ,EAA+B;IAC9E,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';\n\n/*** Leaves native SVG responders in charge of direct color-wheel gestures. */\nexport function ColorWheelPointerProxy({ children }: ColorWheelPointerProxyProps) {\n return children;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';
|
|
3
|
+
/*** Maps browser pointer coordinates into the fixed SVG wheel viewport for click and drag selection. */
|
|
4
|
+
export declare function ColorWheelPointerProxy({ children, disabled, height, onChange, width, }: ColorWheelPointerProxyProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=ColorWheelPointerProxy.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelPointerProxy.web.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheelPointerProxy.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,wGAAwG;AACxG,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,GACN,EAAE,2BAA2B,qBA8B7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/*** Maps browser pointer coordinates into the fixed SVG wheel viewport for click and drag selection. */
|
|
3
|
+
export function ColorWheelPointerProxy({ children, disabled, height, onChange, width, }) {
|
|
4
|
+
const dragging = React.useRef(false);
|
|
5
|
+
const changeAt = (event) => {
|
|
6
|
+
const target = event.currentTarget;
|
|
7
|
+
const rect = target.getBoundingClientRect();
|
|
8
|
+
onChange(((event.clientX - rect.left) / rect.width) * width, ((event.clientY - rect.top) / rect.height) * height);
|
|
9
|
+
};
|
|
10
|
+
return (<div onMouseDown={(event) => {
|
|
11
|
+
if (disabled)
|
|
12
|
+
return;
|
|
13
|
+
dragging.current = true;
|
|
14
|
+
changeAt(event);
|
|
15
|
+
}} onMouseMove={(event) => {
|
|
16
|
+
if (!disabled && dragging.current)
|
|
17
|
+
changeAt(event);
|
|
18
|
+
}} onMouseUp={(event) => {
|
|
19
|
+
if (!disabled && dragging.current)
|
|
20
|
+
changeAt(event);
|
|
21
|
+
dragging.current = false;
|
|
22
|
+
}} style={{ touchAction: 'none' }}>
|
|
23
|
+
{children}
|
|
24
|
+
</div>);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ColorWheelPointerProxy.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorWheelPointerProxy.web.js","sourceRoot":"","sources":["../../../src/features/color/ColorWheelPointerProxy.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,wGAAwG;AACxG,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,GACuB;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,CAAC,KAAuC,EAAE,EAAE;QAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,aAAgD,CAAC;QACtE,MAAM,IAAI,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;QAC5C,QAAQ,CACN,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,EAClD,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CACpD,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,GAAG,CACF,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO;gBAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC,CACF,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACnB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO;gBAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnD,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAC3B,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAE/B;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';\n\n/*** Maps browser pointer coordinates into the fixed SVG wheel viewport for click and drag selection. */\nexport function ColorWheelPointerProxy({\n children,\n disabled,\n height,\n onChange,\n width,\n}: ColorWheelPointerProxyProps) {\n const dragging = React.useRef(false);\n const changeAt = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.currentTarget as unknown as BrowserPointerTarget;\n const rect = target.getBoundingClientRect();\n onChange(\n ((event.clientX - rect.left) / rect.width) * width,\n ((event.clientY - rect.top) / rect.height) * height,\n );\n };\n\n return (\n <div\n onMouseDown={(event) => {\n if (disabled) return;\n dragging.current = true;\n changeAt(event);\n }}\n onMouseMove={(event) => {\n if (!disabled && dragging.current) changeAt(event);\n }}\n onMouseUp={(event) => {\n if (!disabled && dragging.current) changeAt(event);\n dragging.current = false;\n }}\n style={{ touchAction: 'none' }}\n >\n {children}\n </div>\n );\n}\n\ninterface BrowserPointerTarget {\n readonly getBoundingClientRect: () => {\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly width: number;\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphRuntime.d.ts","sourceRoot":"","sources":["../../../../../../src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAkB,EAAa,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExE,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EAEzB,qBAAqB,EACrB,aAAa,EAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAkBhF,KAAK,cAAc,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;AACpD,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAE9E,MAAM,WAAW,YAAY;IAC3B,OAAO,IAAI,IAAI,CAAC;IAChB,sBAAsB,CACpB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,yBAAyB,EAC/B,eAAe,CAAC,EAAE,eAAe,GAChC,IAAI,CAAC;IACR,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IACnD,kBAAkB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;IACjE,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI,CAAC;IACnE,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACzC;
|
|
1
|
+
{"version":3,"file":"createGraphRuntime.d.ts","sourceRoot":"","sources":["../../../../../../src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAkB,EAAa,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExE,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EAEzB,qBAAqB,EACrB,aAAa,EAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAkBhF,KAAK,cAAc,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;AACpD,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAE9E,MAAM,WAAW,YAAY;IAC3B,OAAO,IAAI,IAAI,CAAC;IAChB,sBAAsB,CACpB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,yBAAyB,EAC/B,eAAe,CAAC,EAAE,eAAe,GAChC,IAAI,CAAC;IACR,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IACnD,kBAAkB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;IACjE,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI,CAAC;IACnE,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACzC;AAgCD,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,cAAc,EACzB,YAAY,EAAE;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,EAC7C,qBAAqB,GAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAoB,GAC9D,YAAY,CAqBd"}
|
|
@@ -63,6 +63,7 @@ function createRuntimeState(cy, container, callbacksRef, readLatestPointerDown)
|
|
|
63
63
|
labelSizedNodeIds: new Set(),
|
|
64
64
|
loopSizer: createGraphLoopSizer(cy),
|
|
65
65
|
pendingInitialFitRef: { current: false },
|
|
66
|
+
preservedTopologyRef: { current: false },
|
|
66
67
|
preservedTopologyMeasurementRef: { current: false },
|
|
67
68
|
readyRef,
|
|
68
69
|
settledLayoutRef: { current: null },
|
|
@@ -166,7 +167,10 @@ function beginPreservedTopologyMeasurementWindow(state, previous, input, preserv
|
|
|
166
167
|
const topologyChanged = previous !== null &&
|
|
167
168
|
getGraphTopologyKey(previous.nodes, previous.edges) !==
|
|
168
169
|
getGraphTopologyKey(input.nodes, input.edges);
|
|
169
|
-
|
|
170
|
+
const preservedTopology = preservesTopology && topologyChanged;
|
|
171
|
+
state.preservedTopologyRef.current =
|
|
172
|
+
preservesTopology && (state.preservedTopologyRef.current || topologyChanged);
|
|
173
|
+
state.preservedTopologyMeasurementRef.current = preservedTopology;
|
|
170
174
|
if (!state.preservedTopologyMeasurementRef.current)
|
|
171
175
|
return;
|
|
172
176
|
scheduleGraphFrame(() => {
|
|
@@ -246,6 +250,7 @@ function completeCurrentLayout(state, generation) {
|
|
|
246
250
|
state.viewport.settle(shouldFit);
|
|
247
251
|
state.settledLayoutRef.current = input.layout;
|
|
248
252
|
state.settledTopologyRef.current = topology;
|
|
253
|
+
state.preservedTopologyRef.current = false;
|
|
249
254
|
const fitRequest = state.fitRequestRef.current;
|
|
250
255
|
state.fitRequestRef.current = null;
|
|
251
256
|
if (fitRequest)
|
|
@@ -338,10 +343,17 @@ function setNodeSize(state, id, size) {
|
|
|
338
343
|
return;
|
|
339
344
|
state.nodeSizes.set(id, size);
|
|
340
345
|
applyNodeSize(state.cy, id, size);
|
|
341
|
-
if (state
|
|
346
|
+
if (preservesSettledTopology(state))
|
|
342
347
|
return;
|
|
343
348
|
scheduleMeasuredNodeRelayout(state);
|
|
344
349
|
}
|
|
350
|
+
/*** Retain a user-owned stable topology until the next layout generation settles. */
|
|
351
|
+
function preservesSettledTopology(state) {
|
|
352
|
+
return (state.readyRef.current &&
|
|
353
|
+
!state.pendingInitialFitRef.current &&
|
|
354
|
+
state.preservedTopologyRef.current &&
|
|
355
|
+
state.latestUpdateRef.current?.topologyUpdatePolicy === 'preserve-positions');
|
|
356
|
+
}
|
|
345
357
|
/*** Apply every known rich-node size after Cytoscape elements are replaced. */
|
|
346
358
|
function applyKnownNodeSizes(state) {
|
|
347
359
|
for (const [id, size] of state.nodeSizes)
|