@ankhorage/zora 27.11.3 → 28.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +4 -3
  3. package/dist/features/color/ColorHexField.d.ts +1 -1
  4. package/dist/features/color/ColorHexField.d.ts.map +1 -1
  5. package/dist/features/color/ColorHexField.js +2 -3
  6. package/dist/features/color/ColorHexField.js.map +1 -1
  7. package/dist/features/color/ColorPicker.d.ts +1 -1
  8. package/dist/features/color/ColorPicker.d.ts.map +1 -1
  9. package/dist/features/color/ColorPicker.js +106 -52
  10. package/dist/features/color/ColorPicker.js.map +1 -1
  11. package/dist/features/color/ColorWheel.d.ts +1 -1
  12. package/dist/features/color/ColorWheel.d.ts.map +1 -1
  13. package/dist/features/color/ColorWheel.js +50 -117
  14. package/dist/features/color/ColorWheel.js.map +1 -1
  15. package/dist/features/color/ColorWheelPointerProxy.web.d.ts +1 -1
  16. package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -1
  17. package/dist/features/color/ColorWheelPointerProxy.web.js +7 -4
  18. package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -1
  19. package/dist/features/color/public.d.ts +1 -1
  20. package/dist/features/color/public.d.ts.map +1 -1
  21. package/dist/features/color/public.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/types/color.d.ts +26 -26
  26. package/dist/types/color.d.ts.map +1 -1
  27. package/dist/types/color.js.map +1 -1
  28. package/package.json +2 -2
  29. package/src/features/color/ColorHexField.tsx +1 -3
  30. package/src/features/color/ColorPicker.layout.test.tsx +11 -16
  31. package/src/features/color/ColorPicker.tsx +217 -93
  32. package/src/features/color/ColorWheel.tsx +122 -248
  33. package/src/features/color/ColorWheelPointerProxy.web.tsx +11 -5
  34. package/src/features/color/public.ts +0 -2
  35. package/src/index.ts +0 -2
  36. package/src/types/color.ts +26 -22
  37. package/web-dist/chunks/Accordion-00h253nv.js +252 -0
  38. package/web-dist/chunks/{Accordion-qhn8z92r.js → Accordion-0gae3kzr.js} +3 -3
  39. package/web-dist/chunks/{Accordion-3jkeydhb.js → Accordion-0t53jhx1.js} +4 -4
  40. package/web-dist/chunks/{Accordion-vk2v1zwv.js → Accordion-1b2t4k36.js} +2 -2
  41. package/web-dist/chunks/{Accordion-aws0caav.js → Accordion-1dv8wytq.js} +3 -3
  42. package/web-dist/chunks/{Accordion-ysmzrvhn.js → Accordion-238zba4h.js} +3 -3
  43. package/web-dist/chunks/{Accordion-z8ryq8cb.js → Accordion-36674tfw.js} +7 -7
  44. package/web-dist/chunks/{Accordion-bd6q61s1.js → Accordion-36j1fw8r.js} +5 -5
  45. package/web-dist/chunks/{Accordion-jd26f516.js → Accordion-3ar6p84m.js} +3 -3
  46. package/web-dist/chunks/{Accordion-gezcm372.js → Accordion-3t2936t6.js} +4 -4
  47. package/web-dist/chunks/{Accordion-rzf52xq8.js → Accordion-43gp801f.js} +2 -2
  48. package/web-dist/chunks/{Accordion-c0a7mhq3.js → Accordion-52s4t1aq.js} +2 -2
  49. package/web-dist/chunks/{Accordion-vewhx028.js → Accordion-5adv6dv1.js} +4 -4
  50. package/web-dist/chunks/{Accordion-49w9bc2f.js → Accordion-5wx67nhg.js} +2 -2
  51. package/web-dist/chunks/{Accordion-p29kmwh9.js → Accordion-6225tr9r.js} +1 -1
  52. package/web-dist/chunks/{Accordion-x7ynjdv7.js → Accordion-6r1e7k5r.js} +1 -1
  53. package/web-dist/chunks/{Accordion-1mxnyexh.js → Accordion-6wcbzxzb.js} +13 -13
  54. package/web-dist/chunks/{Accordion-an5prgty.js → Accordion-7d0e5vhe.js} +1 -1
  55. package/web-dist/chunks/{Accordion-phtyg3k4.js → Accordion-7ppf31tg.js} +5 -5
  56. package/web-dist/chunks/{Accordion-5vs1k81g.js → Accordion-81rx3bh0.js} +8 -8
  57. package/web-dist/chunks/{Accordion-1etqb3cj.js → Accordion-8wm25z0h.js} +2 -2
  58. package/web-dist/chunks/{Accordion-f60g73bp.js → Accordion-94vndckf.js} +6 -6
  59. package/web-dist/chunks/{Accordion-ne91vwkd.js → Accordion-9fhsfynt.js} +2 -2
  60. package/web-dist/chunks/{Accordion-9c63jn3m.js → Accordion-ah1d9b6z.js} +4 -4
  61. package/web-dist/chunks/{Accordion-0kr0h68p.js → Accordion-b41rev86.js} +8 -8
  62. package/web-dist/chunks/{Accordion-q1tdazgq.js → Accordion-c8mmgjtj.js} +5 -5
  63. package/web-dist/chunks/{Accordion-pcj256bc.js → Accordion-d2kg4729.js} +5 -5
  64. package/web-dist/chunks/{Accordion-g451f3g9.js → Accordion-d4dp5ryp.js} +4 -4
  65. package/web-dist/chunks/{Accordion-dfq04q82.js → Accordion-dfv6p6gt.js} +4 -4
  66. package/web-dist/chunks/{Accordion-e3r3573t.js → Accordion-dpkp0y4p.js} +3 -3
  67. package/web-dist/chunks/{Accordion-pmfdf08d.js → Accordion-dxh9yn4f.js} +1 -1
  68. package/web-dist/chunks/{Accordion-zx8gmww4.js → Accordion-ec1tt3be.js} +9 -9
  69. package/web-dist/chunks/{Accordion-vnrqvfca.js → Accordion-epwpdegg.js} +1 -1
  70. package/web-dist/chunks/{Accordion-8g9c7890.js → Accordion-hbkzy0bg.js} +4 -4
  71. package/web-dist/chunks/{Accordion-c3nna2bz.js → Accordion-j6hgazmz.js} +1 -1
  72. package/web-dist/chunks/{Accordion-6nrpdbmb.js → Accordion-jara9sqj.js} +7 -7
  73. package/web-dist/chunks/{Accordion-3ecnh8d0.js → Accordion-knb3e18b.js} +4 -4
  74. package/web-dist/chunks/{Accordion-6m3k4avp.js → Accordion-m5baah44.js} +2 -2
  75. package/web-dist/chunks/{Accordion-3zw817fr.js → Accordion-nkppqfz4.js} +6 -6
  76. package/web-dist/chunks/{Accordion-3wkd5x2q.js → Accordion-phcp8d5v.js} +3 -3
  77. package/web-dist/chunks/{Accordion-x0p3wxfp.js → Accordion-pm2f2j32.js} +2 -2
  78. package/web-dist/chunks/{Accordion-j0zhpq4s.js → Accordion-q697hacs.js} +7 -7
  79. package/web-dist/chunks/{Accordion-eak89n4n.js → Accordion-re4r47xn.js} +6 -6
  80. package/web-dist/chunks/{Accordion-r1wkgt7c.js → Accordion-rev9ssd4.js} +516 -544
  81. package/web-dist/chunks/{Accordion-h2nd5y0z.js → Accordion-sn241nek.js} +5 -5
  82. package/web-dist/chunks/{Accordion-jbwey4za.js → Accordion-tppk4vwt.js} +9 -9
  83. package/web-dist/chunks/{Accordion-6yv4beha.js → Accordion-wbmzvfaw.js} +1 -1
  84. package/web-dist/chunks/{Accordion-4g54je0w.js → Accordion-wcw153f0.js} +2 -2
  85. package/web-dist/chunks/{Accordion-705yrq6w.js → Accordion-wpj8pd40.js} +1 -1
  86. package/web-dist/chunks/{Accordion-z4qakakw.js → Accordion-ytxgphds.js} +2 -2
  87. package/web-dist/chunks/{Accordion-h0e95qxp.js → Accordion-z1cq2mnx.js} +9 -9
  88. package/web-dist/chunks/{Accordion-xb174981.js → Accordion-z9yw0xy9.js} +8 -8
  89. package/web-dist/chunks/{Accordion-e5jr9ahb.js → Accordion-zte416jw.js} +1 -1
  90. package/web-dist/chunks/{Accordion-xwstve3k.js → Accordion-zzymcpty.js} +2 -2
  91. package/web-dist/components/accordion/Accordion.js +10 -10
  92. package/web-dist/components/accordion-item/AccordionItem.js +10 -10
  93. package/web-dist/components/activity-indicator/ActivityIndicator.js +3 -3
  94. package/web-dist/components/app-bar/AppBar.js +15 -15
  95. package/web-dist/components/app-header/AppHeader.js +15 -15
  96. package/web-dist/components/app-shell/AppShell.js +4 -4
  97. package/web-dist/components/auth-screen/AuthScreen.js +20 -20
  98. package/web-dist/components/avatar/Avatar.js +10 -10
  99. package/web-dist/components/avatar-group/AvatarGroup.js +10 -10
  100. package/web-dist/components/badge/Badge.js +5 -5
  101. package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +18 -18
  102. package/web-dist/components/bottom-sheet/BottomSheet.js +6 -6
  103. package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +6 -6
  104. package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +6 -6
  105. package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +6 -6
  106. package/web-dist/components/bottom-sheet-view/BottomSheetView.js +6 -6
  107. package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +6 -6
  108. package/web-dist/components/breadcrumbs/Breadcrumbs.js +12 -12
  109. package/web-dist/components/button/Button.js +10 -10
  110. package/web-dist/components/button-group/ButtonGroup.js +10 -10
  111. package/web-dist/components/calendar/Calendar.js +12 -12
  112. package/web-dist/components/camera-permission-view/CameraPermissionView.js +18 -18
  113. package/web-dist/components/card/Card.js +17 -17
  114. package/web-dist/components/card-back/CardBack.js +4 -4
  115. package/web-dist/components/card-hand/CardHand.js +4 -4
  116. package/web-dist/components/carousel/Carousel.js +2 -2
  117. package/web-dist/components/chat-list-item/ChatListItem.js +14 -14
  118. package/web-dist/components/checkbox/Checkbox.js +10 -10
  119. package/web-dist/components/checkbox-group/CheckboxGroup.js +10 -10
  120. package/web-dist/components/chess-board/ChessBoard.js +4 -4
  121. package/web-dist/components/chip/Chip.js +11 -11
  122. package/web-dist/components/chip-group/ChipGroup.js +11 -11
  123. package/web-dist/components/collection-editor/CollectionEditor.js +17 -17
  124. package/web-dist/components/color-hue-scale/ColorHueScale.js +27 -16
  125. package/web-dist/components/color-picker/ColorPicker.d.ts +2 -2
  126. package/web-dist/components/color-picker/ColorPicker.js +27 -16
  127. package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +26 -45
  128. package/web-dist/components/color-picker/index.d.ts +1 -1
  129. package/web-dist/components/color-tone/ColorTone.js +27 -16
  130. package/web-dist/components/color-wheel/ColorWheel.d.ts +1 -1
  131. package/web-dist/components/color-wheel/ColorWheel.js +27 -16
  132. package/web-dist/components/color-wheel/ColorWheel.types-0.d.ts +2 -0
  133. package/web-dist/components/content-rail/ContentRail.js +11 -11
  134. package/web-dist/components/data-table/DataTable.js +23 -23
  135. package/web-dist/components/date-picker/DatePicker.js +16 -16
  136. package/web-dist/components/dialog/Dialog.js +9 -9
  137. package/web-dist/components/divider/Divider.js +4 -4
  138. package/web-dist/components/empty-state/EmptyState.js +18 -18
  139. package/web-dist/components/explorer/Explorer.js +11 -11
  140. package/web-dist/components/field/Field.js +10 -10
  141. package/web-dist/components/file-explorer/FileExplorer.js +11 -11
  142. package/web-dist/components/flat-list/FlatList.js +11 -11
  143. package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +20 -20
  144. package/web-dist/components/form/Form.js +14 -14
  145. package/web-dist/components/form-actions/FormActions.js +14 -14
  146. package/web-dist/components/form-error/FormError.js +14 -14
  147. package/web-dist/components/game/Game.js +5 -5
  148. package/web-dist/components/game-entity/GameEntity.js +5 -5
  149. package/web-dist/components/game-field/GameField.js +5 -5
  150. package/web-dist/components/game-input-zone/GameInputZone.js +5 -5
  151. package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +5 -5
  152. package/web-dist/components/game-overlay/GameOverlay.js +5 -5
  153. package/web-dist/components/gradient/Gradient.js +5 -5
  154. package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +5 -5
  155. package/web-dist/components/grid/Grid.js +4 -4
  156. package/web-dist/components/grid-line-overlay/GridLineOverlay.js +4 -4
  157. package/web-dist/components/grid-ruler/GridRuler.js +4 -4
  158. package/web-dist/components/heading/Heading.js +5 -5
  159. package/web-dist/components/hero/Hero.js +17 -17
  160. package/web-dist/components/icon/Icon.js +4 -4
  161. package/web-dist/components/icon-button/IconButton.js +10 -10
  162. package/web-dist/components/image/Image.js +8 -8
  163. package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +3 -3
  164. package/web-dist/components/list/List.js +11 -11
  165. package/web-dist/components/list-item/ListItem.js +11 -11
  166. package/web-dist/components/list-section/ListSection.js +11 -11
  167. package/web-dist/components/master-detail/MasterDetail.js +4 -4
  168. package/web-dist/components/matrix-grid/MatrixGrid.js +4 -4
  169. package/web-dist/components/media-card/MediaCard.js +17 -17
  170. package/web-dist/components/media-explorer/MediaExplorer.js +11 -11
  171. package/web-dist/components/message-bubble/MessageBubble.js +14 -14
  172. package/web-dist/components/metric-card/MetricCard.js +17 -17
  173. package/web-dist/components/missing-element/MissingElement.js +9 -9
  174. package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +20 -20
  175. package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +20 -20
  176. package/web-dist/components/opening-book/OpeningBook.js +4 -4
  177. package/web-dist/components/otp-form/OtpForm.js +20 -20
  178. package/web-dist/components/pagination/Pagination.js +11 -11
  179. package/web-dist/components/palette-item/PaletteItem.js +17 -17
  180. package/web-dist/components/playing-card/PlayingCard.js +4 -4
  181. package/web-dist/components/poker-training-table/PokerTrainingTable.js +4 -4
  182. package/web-dist/components/popover-menu/PopoverMenu.js +10 -10
  183. package/web-dist/components/post-card/PostCard.js +17 -17
  184. package/web-dist/components/product-card/ProductCard.js +17 -17
  185. package/web-dist/components/progress/Progress.js +8 -8
  186. package/web-dist/components/progress-ring/ProgressRing.js +8 -8
  187. package/web-dist/components/radio/Radio.js +12 -12
  188. package/web-dist/components/radio-group/RadioGroup.js +12 -12
  189. package/web-dist/components/rating/Rating.js +7 -7
  190. package/web-dist/components/reader/Reader.js +18 -18
  191. package/web-dist/components/scan-overlay/ScanOverlay.js +18 -18
  192. package/web-dist/components/screen/Screen.js +4 -4
  193. package/web-dist/components/screen-section/ScreenSection.js +8 -8
  194. package/web-dist/components/scroll-view/ScrollView.js +4 -4
  195. package/web-dist/components/search-input/SearchInput.js +12 -12
  196. package/web-dist/components/section-header/SectionHeader.js +8 -8
  197. package/web-dist/components/section-list/SectionList.js +11 -11
  198. package/web-dist/components/select/Select.js +21 -257
  199. package/web-dist/components/selectable-item/SelectableItem.js +3 -3
  200. package/web-dist/components/selection-provider/SelectionProvider.js +3 -3
  201. package/web-dist/components/sign-in-form/SignInForm.js +20 -20
  202. package/web-dist/components/sign-up-form/SignUpForm.js +20 -20
  203. package/web-dist/components/skeleton/Skeleton.js +20 -20
  204. package/web-dist/components/skeleton-card/SkeletonCard.js +20 -20
  205. package/web-dist/components/skeleton-list/SkeletonList.js +20 -20
  206. package/web-dist/components/skeleton-text/SkeletonText.js +20 -20
  207. package/web-dist/components/surface/Surface.js +5 -5
  208. package/web-dist/components/switch/Switch.js +5 -5
  209. package/web-dist/components/tab/Tab.js +5 -5
  210. package/web-dist/components/tab-list/TabList.js +5 -5
  211. package/web-dist/components/tab-panel/TabPanel.js +5 -5
  212. package/web-dist/components/tabletop-table/TabletopTable.js +4 -4
  213. package/web-dist/components/tabs/Tabs.js +5 -5
  214. package/web-dist/components/text/Text.js +5 -5
  215. package/web-dist/components/text-input/TextInput.js +12 -12
  216. package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +10 -10
  217. package/web-dist/components/time-picker/TimePicker.js +15 -15
  218. package/web-dist/components/timeline/Timeline.js +10 -10
  219. package/web-dist/components/toast/Toast.js +7 -7
  220. package/web-dist/components/toast-provider/ToastProvider.js +7 -7
  221. package/web-dist/components/toolbar/Toolbar.js +17 -17
  222. package/web-dist/components/tree-item/TreeItem.js +15 -15
  223. package/web-dist/components/uploader/Uploader.js +20 -20
  224. package/web-dist/components/view/View.js +4 -4
  225. package/web-dist/manifest.json +1495 -1446
  226. package/web-dist/runtime/ZoraProvider.js +6 -6
@@ -1,26 +1,10 @@
1
1
  import { generateHarmonyRoleColors, type HexColor } from '@ankhorage/color-theory';
2
- import { Button } from '@ankhorage/surface';
3
2
  import React from 'react';
4
- import {
5
- Circle,
6
- Defs,
7
- Line,
8
- LinearGradient,
9
- Path,
10
- Polygon,
11
- RadialGradient,
12
- Rect,
13
- Stop,
14
- Svg,
15
- } from 'react-native-svg';
3
+ import { Circle, Defs, Line, Path, Polygon, RadialGradient, Stop, Svg } from 'react-native-svg';
16
4
 
17
5
  import type { ColorWheelProps } from '../../types/color';
18
- import { View } from '../layout/public';
19
6
  import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
20
7
  import { useZoraTheme } from '../theme/composition/useZoraTheme';
21
- import { Text } from '../typography/public';
22
- import { ColorHexField } from './ColorHexField';
23
- import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
24
8
  import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
25
9
  import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
26
10
  import { resolveColorHue } from './utils/resolveColorHue';
@@ -28,16 +12,16 @@ import { resolveOklchColor } from './utils/resolveOklchColor';
28
12
  import { resolveWheelColor } from './utils/resolveWheelColor';
29
13
  import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
30
14
 
31
- const WHEEL_SIZE = 280;
32
- const WHEEL_CENTER = WHEEL_SIZE / 2;
33
- const WHEEL_RADIUS = 128;
34
- const WHEEL_SEGMENT_COUNT = 72;
35
- const WHEEL_MAX_CHROMA = 0.2;
15
+ const VIEWBOX = 1000;
16
+ const CENTER = VIEWBOX / 2;
17
+ const RADIUS = 480;
18
+ const SEGMENTS = 96;
19
+ const MAX_CHROMA = 0.2;
36
20
 
37
- /*** Selects an OKLCH hue and optionally visualizes the existing color-theory harmony. */
21
+ /*** Renders a size-owned, filled OKLCH wheel with controlled primary and harmony points. */
38
22
  export const ColorWheel = withZoraThemeScope(ColorWheelInner);
39
23
 
40
- /*** Renders a directly manipulable hue wheel and harmony controls without returning derived colors. */
24
+ /*** Maps pointer and keyboard input through one viewBox into the controlled selected colour. */
41
25
  function ColorWheelInner({
42
26
  themeId: _themeId,
43
27
  mode: _mode,
@@ -45,264 +29,160 @@ function ColorWheelInner({
45
29
  interactionPolicy,
46
30
  value,
47
31
  harmony = null,
48
- harmonies,
49
32
  onChange,
33
+ size = 340,
50
34
  testID,
51
35
  }: ColorWheelProps) {
52
36
  const { theme } = useZoraTheme();
53
37
  const hue = resolveColorHue(value);
54
38
  const { chroma, lightness } = resolveWheelColorComponents(value);
55
- const harmonyColors = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];
56
- const selectedPoint = resolveWheelPoint(hue, Math.min(1, chroma / WHEEL_MAX_CHROMA));
57
- const harmonyPoints = harmonyColors.map((color) => resolveWheelPoint(color.hueDegrees));
58
- const harmonyLines = resolveHarmonyLines(
59
- harmonyPoints,
60
- selectedPoint,
61
- theme.semantics.content.default,
62
- );
63
- const wheelGradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
64
- const changeColorAt = (x: number, y: number) => {
65
- if (interactionPolicy === 'passive') return;
66
- onChange({
67
- color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),
68
- harmony,
69
- });
39
+ const primaryPoint = pointFor(hue, Math.min(1, chroma / MAX_CHROMA));
40
+ const harmonyPoints = harmony
41
+ ? generateHarmonyRoleColors(value, harmony).colors.map((color) => pointFor(color.hueDegrees))
42
+ : [];
43
+ const gradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
44
+ const changeAt = (x: number, y: number) => {
45
+ if (interactionPolicy !== 'passive')
46
+ onChange({ color: resolveWheelColor(value, x, y, CENTER, RADIUS, MAX_CHROMA), harmony });
70
47
  };
71
- const changeLightness = (nextLightness: number) =>
72
- onChange({
73
- color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, nextLightness)) }, hue),
74
- harmony,
75
- });
76
-
77
48
  return (
78
- <View align="center" gap="s" testID={testID}>
79
- <ColorWheelKeyboardProxy
80
- chroma={chroma}
49
+ <ColorWheelKeyboardProxy
50
+ chroma={chroma}
51
+ disabled={interactionPolicy === 'passive'}
52
+ hue={hue}
53
+ onChange={(nextHue, nextChroma) =>
54
+ onChange({ color: resolveOklchColor({ chroma: nextChroma, lightness }, nextHue), harmony })
55
+ }
56
+ >
57
+ <ColorWheelPointerProxy
81
58
  disabled={interactionPolicy === 'passive'}
82
- hue={hue}
83
- onChange={(nextHue, nextChroma) =>
84
- onChange({
85
- color: resolveOklchColor(
86
- { lightness: resolveWheelLightness(value), chroma: nextChroma },
87
- nextHue,
88
- ),
89
- harmony,
90
- })
91
- }
59
+ height={VIEWBOX}
60
+ onChange={changeAt}
61
+ width={VIEWBOX}
92
62
  >
93
- <ColorWheelPointerProxy
94
- disabled={interactionPolicy === 'passive'}
95
- height={WHEEL_SIZE}
96
- onChange={changeColorAt}
97
- width={WHEEL_SIZE}
63
+ <Svg
64
+ accessibilityLabel="Color wheel"
65
+ height={size}
66
+ onResponderGrant={(event) =>
67
+ changeAt(
68
+ (event.nativeEvent.locationX / size) * VIEWBOX,
69
+ (event.nativeEvent.locationY / size) * VIEWBOX,
70
+ )
71
+ }
72
+ onResponderMove={(event) =>
73
+ changeAt(
74
+ (event.nativeEvent.locationX / size) * VIEWBOX,
75
+ (event.nativeEvent.locationY / size) * VIEWBOX,
76
+ )
77
+ }
78
+ onResponderRelease={(event) =>
79
+ changeAt(
80
+ (event.nativeEvent.locationX / size) * VIEWBOX,
81
+ (event.nativeEvent.locationY / size) * VIEWBOX,
82
+ )
83
+ }
84
+ onStartShouldSetResponder={() => interactionPolicy !== 'passive'}
85
+ testID={testID}
86
+ viewBox={`0 0 ${VIEWBOX} ${VIEWBOX}`}
87
+ width={size}
98
88
  >
99
- <Svg
100
- accessibilityLabel="Color wheel"
101
- height={WHEEL_SIZE}
102
- onResponderGrant={(event) => {
103
- const { locationX, locationY } = event.nativeEvent;
104
- changeColorAt(locationX, locationY);
105
- }}
106
- onResponderMove={(event) => {
107
- const { locationX, locationY } = event.nativeEvent;
108
- changeColorAt(locationX, locationY);
109
- }}
110
- onResponderRelease={(event) => {
111
- const { locationX, locationY } = event.nativeEvent;
112
- changeColorAt(locationX, locationY);
113
- }}
114
- onStartShouldSetResponder={() => interactionPolicy !== 'passive'}
115
- width={WHEEL_SIZE}
116
- >
117
- <Defs>
118
- {resolveWheelSegments().map((segment) => (
119
- <RadialGradient
120
- cx={WHEEL_CENTER}
121
- cy={WHEEL_CENTER}
122
- id={`${wheelGradientId}-${segment.hue}`}
123
- key={segment.hue}
124
- r={WHEEL_RADIUS}
125
- >
126
- <Stop
127
- offset="0"
128
- stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)}
129
- />
130
- <Stop offset="1" stopColor={segment.color} />
131
- </RadialGradient>
132
- ))}
133
- </Defs>
134
- {resolveWheelSegments().map((segment) => (
135
- <Path
136
- d={segment.path}
137
- fill={`url(#${wheelGradientId}-${segment.hue})`}
89
+ <Defs>
90
+ {segments().map((segment) => (
91
+ <RadialGradient
92
+ cx={CENTER}
93
+ cy={CENTER}
94
+ id={`${gradientId}-${segment.hue}`}
138
95
  key={segment.hue}
139
- />
96
+ r={RADIUS}
97
+ >
98
+ <Stop
99
+ offset="0"
100
+ stopColor={resolveOklchColor({ chroma: 0, lightness: 0.72 }, segment.hue)}
101
+ />
102
+ <Stop offset="1" stopColor={segment.color} />
103
+ </RadialGradient>
140
104
  ))}
141
- {harmony === 'triadic' && harmonyPoints.length === 3 ? (
142
- <Polygon
143
- fill="none"
144
- points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}
145
- stroke={theme.semantics.content.default}
146
- strokeWidth={2}
147
- />
148
- ) : (
149
- harmonyLines
150
- )}
151
- {harmonyPoints.map((point) => (
152
- <Circle
153
- cx={point.x}
154
- cy={point.y}
155
- fill={theme.semantics.content.default}
156
- key={`${point.x}-${point.y}`}
157
- r={5}
158
- />
159
- ))}
160
- <Circle
161
- cx={selectedPoint.x}
162
- cy={selectedPoint.y}
105
+ </Defs>
106
+ {segments().map((segment) => (
107
+ <Path d={segment.path} fill={`url(#${gradientId}-${segment.hue})`} key={segment.hue} />
108
+ ))}
109
+ {harmonyPoints.length === 3 ? (
110
+ <Polygon
163
111
  fill="none"
164
- r={9}
112
+ points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}
165
113
  stroke={theme.semantics.content.default}
166
- strokeWidth={3}
114
+ strokeWidth={6}
115
+ />
116
+ ) : (
117
+ linesFor(harmonyPoints, primaryPoint, theme.semantics.content.default)
118
+ )}
119
+ {harmonyPoints.map((point) => (
120
+ <Circle
121
+ cx={point.x}
122
+ cy={point.y}
123
+ fill={theme.semantics.content.default}
124
+ key={`${point.x}-${point.y}`}
125
+ r={26}
167
126
  />
168
- </Svg>
169
- </ColorWheelPointerProxy>
170
- </ColorWheelKeyboardProxy>
171
- <ColorLightnessSlider
172
- chroma={chroma}
173
- disabled={interactionPolicy === 'passive'}
174
- hue={hue}
175
- lightness={lightness}
176
- onChange={changeLightness}
177
- selectionBorderColor={theme.semantics.content.default}
178
- />
179
- <ColorHexField
180
- disabled={interactionPolicy === 'passive'}
181
- key={value}
182
- onChange={(color) => onChange({ color, harmony })}
183
- value={value}
184
- />
185
- {harmonies ? (
186
- <View direction="row" gap="xs" wrap="wrap">
187
- <Button
188
- disabled={interactionPolicy === 'passive'}
189
- onPress={() => onChange({ color: value, harmony: null })}
190
- variant={harmony === null ? 'solid' : 'outline'}
191
- >
192
- None
193
- </Button>
194
- {harmonies.map((candidate) => (
195
- <Button
196
- key={candidate}
197
- disabled={interactionPolicy === 'passive'}
198
- onPress={() => onChange({ color: value, harmony: candidate })}
199
- variant={harmony === candidate ? 'solid' : 'outline'}
200
- >
201
- {candidate}
202
- </Button>
203
127
  ))}
204
- </View>
205
- ) : null}
206
- </View>
207
- );
208
- }
209
-
210
- /*** Renders a continuous OKLCH lightness track without adding a second color persistence model. */
211
- function ColorLightnessSlider({
212
- chroma,
213
- disabled,
214
- hue,
215
- lightness,
216
- onChange,
217
- selectionBorderColor,
218
- }: {
219
- readonly chroma: number;
220
- readonly disabled: boolean;
221
- readonly hue: number;
222
- readonly lightness: number;
223
- readonly onChange: (lightness: number) => void;
224
- readonly selectionBorderColor: string;
225
- }) {
226
- const changeAt = (locationX: number) => {
227
- if (!disabled) onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));
228
- };
229
- return (
230
- <View gap="xxs" width={WHEEL_SIZE}>
231
- <View direction="row" justify="space-between">
232
- <Text variant="label">Lightness</Text>
233
- <Text variant="label">{`${Math.round(lightness * 100)}%`}</Text>
234
- </View>
235
- <ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={WHEEL_SIZE}>
236
- <Svg accessibilityLabel="Color lightness" height={36} width={WHEEL_SIZE}>
237
- <Defs>
238
- <LinearGradient id="color-lightness" x1="0" x2="1" y1="0" y2="0">
239
- <Stop offset="0" stopColor={resolveOklchColor({ chroma, lightness: 0 }, hue)} />
240
- <Stop offset="1" stopColor={resolveOklchColor({ chroma, lightness: 1 }, hue)} />
241
- </LinearGradient>
242
- </Defs>
243
- <Rect fill="url(#color-lightness)" height={10} rx={5} y={13} width={WHEEL_SIZE} />
244
128
  <Circle
245
- cx={lightness * WHEEL_SIZE}
246
- cy={18}
247
- fill="white"
248
- r={10}
249
- stroke={selectionBorderColor}
250
- strokeWidth={2}
129
+ cx={primaryPoint.x}
130
+ cy={primaryPoint.y}
131
+ fill="none"
132
+ r={36}
133
+ stroke="white"
134
+ strokeWidth={12}
251
135
  />
252
- <Rect
253
- fill="transparent"
254
- height={36}
255
- onResponderGrant={(event) => changeAt(event.nativeEvent.locationX)}
256
- onResponderMove={(event) => changeAt(event.nativeEvent.locationX)}
257
- onResponderRelease={(event) => changeAt(event.nativeEvent.locationX)}
258
- onStartShouldSetResponder={() => !disabled}
259
- width={WHEEL_SIZE}
136
+ <Circle
137
+ cx={primaryPoint.x}
138
+ cy={primaryPoint.y}
139
+ fill="none"
140
+ r={42}
141
+ stroke={theme.semantics.content.default}
142
+ strokeWidth={6}
260
143
  />
261
144
  </Svg>
262
- </ColorHorizontalPointerProxy>
263
- </View>
145
+ </ColorWheelPointerProxy>
146
+ </ColorWheelKeyboardProxy>
264
147
  );
265
148
  }
266
149
 
267
- /*** Build the wheel's OKLCH segments from the existing conversion tool. */
268
- function resolveWheelSegments(): readonly {
150
+ /*** Creates continuous-looking radial hue segments for the wheel viewBox. */
151
+ function segments(): readonly {
269
152
  readonly color: HexColor;
270
153
  readonly hue: number;
271
154
  readonly path: string;
272
155
  }[] {
273
- return Array.from({ length: WHEEL_SEGMENT_COUNT }, (_, index) => {
274
- const hue = (index * 360) / WHEEL_SEGMENT_COUNT;
156
+ return Array.from({ length: SEGMENTS }, (_, index) => {
157
+ const hue = (index * 360) / SEGMENTS;
275
158
  return {
276
- color: resolveOklchColor({ lightness: 0.65, chroma: WHEEL_MAX_CHROMA }, hue),
159
+ color: resolveOklchColor({ chroma: MAX_CHROMA, lightness: 0.65 }, hue),
277
160
  hue,
278
- path: resolveSegmentPath(hue, hue + 360 / WHEEL_SEGMENT_COUNT),
161
+ path: segmentPath(hue, hue + 360 / SEGMENTS),
279
162
  };
280
163
  });
281
164
  }
282
165
 
283
- /*** Describe one wedge in the visual hue wheel. */
284
- function resolveSegmentPath(startHue: number, endHue: number): string {
285
- const start = resolveWheelPoint(startHue);
286
- const end = resolveWheelPoint(endHue);
287
- return `M ${WHEEL_CENTER} ${WHEEL_CENTER} L ${start.x} ${start.y} A ${WHEEL_RADIUS} ${WHEEL_RADIUS} 0 0 1 ${end.x} ${end.y} Z`;
166
+ /*** Describes one filled wheel segment in the stable coordinate system. */
167
+ function segmentPath(start: number, end: number) {
168
+ const startPoint = pointFor(start);
169
+ const endPoint = pointFor(end);
170
+ return `M ${CENTER} ${CENTER} L ${startPoint.x} ${startPoint.y} A ${RADIUS} ${RADIUS} 0 0 1 ${endPoint.x} ${endPoint.y} Z`;
288
171
  }
289
172
 
290
- /*** Convert a hue degree to the corresponding visual wheel coordinate. */
291
- function resolveWheelPoint(
292
- hue: number,
293
- radiusRatio = 1,
294
- ): { readonly x: number; readonly y: number } {
173
+ /*** Projects an OKLCH hue and chroma ratio into the wheel coordinate system. */
174
+ function pointFor(hue: number, ratio = 1) {
295
175
  const radians = ((hue - 90) * Math.PI) / 180;
296
176
  return {
297
- x: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.cos(radians),
298
- y: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.sin(radians),
177
+ x: CENTER + RADIUS * ratio * Math.cos(radians),
178
+ y: CENTER + RADIUS * ratio * Math.sin(radians),
299
179
  };
300
180
  }
301
181
 
302
- /*** Connect consecutive harmony points without dynamic collection indexing. */
303
- function resolveHarmonyLines(
182
+ /*** Connects derived harmony points behind their corresponding knobs. */
183
+ function linesFor(
304
184
  points: readonly { readonly x: number; readonly y: number }[],
305
- selectedPoint: { readonly x: number; readonly y: number },
185
+ primary: { readonly x: number; readonly y: number },
306
186
  stroke: string,
307
187
  ) {
308
188
  return points.slice(1).reduce(
@@ -312,7 +192,7 @@ function resolveHarmonyLines(
312
192
  <Line
313
193
  key={`${previous.x}-${previous.y}-${point.x}-${point.y}`}
314
194
  stroke={stroke}
315
- strokeWidth={2}
195
+ strokeWidth={6}
316
196
  x1={previous.x}
317
197
  x2={point.x}
318
198
  y1={previous.y}
@@ -321,12 +201,6 @@ function resolveHarmonyLines(
321
201
  ],
322
202
  previous: point,
323
203
  }),
324
- { lines: [] as React.ReactNode[], previous: points.at(0) ?? selectedPoint },
204
+ { lines: [] as React.ReactNode[], previous: points.at(0) ?? primary },
325
205
  ).lines;
326
206
  }
327
-
328
- /*** Read the selected color's lightness for wheel-only hue and chroma changes. */
329
- function resolveWheelLightness(color: HexColor): number {
330
- const { lightness } = resolveWheelColorComponents(color);
331
- return lightness;
332
- }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';
4
4
 
5
- /*** Maps browser pointer coordinates into the fixed SVG wheel viewport for click and drag selection. */
5
+ /*** Maps mouse, pen and touch coordinates into the wheel viewBox for click and drag selection. */
6
6
  export function ColorWheelPointerProxy({
7
7
  children,
8
8
  disabled,
@@ -11,7 +11,7 @@ export function ColorWheelPointerProxy({
11
11
  width,
12
12
  }: ColorWheelPointerProxyProps) {
13
13
  const dragging = React.useRef(false);
14
- const changeAt = (event: React.MouseEvent<HTMLDivElement>) => {
14
+ const changeAt = (event: React.PointerEvent<HTMLDivElement>) => {
15
15
  const target = event.currentTarget as unknown as BrowserPointerTarget;
16
16
  const rect = target.getBoundingClientRect();
17
17
  onChange(
@@ -22,18 +22,24 @@ export function ColorWheelPointerProxy({
22
22
 
23
23
  return (
24
24
  <div
25
- onMouseDown={(event) => {
25
+ onPointerDown={(event) => {
26
26
  if (disabled) return;
27
27
  dragging.current = true;
28
+ (
29
+ event.currentTarget as unknown as { setPointerCapture: (pointerId: number) => void }
30
+ ).setPointerCapture(event.pointerId);
28
31
  changeAt(event);
29
32
  }}
30
- onMouseMove={(event) => {
33
+ onPointerMove={(event) => {
31
34
  if (!disabled && dragging.current) changeAt(event);
32
35
  }}
33
- onMouseUp={(event) => {
36
+ onPointerUp={(event) => {
34
37
  if (!disabled && dragging.current) changeAt(event);
35
38
  dragging.current = false;
36
39
  }}
40
+ onPointerCancel={() => {
41
+ dragging.current = false;
42
+ }}
37
43
  style={{ touchAction: 'none' }}
38
44
  >
39
45
  {children}
@@ -1,9 +1,7 @@
1
1
  export type {
2
2
  ColorHueScaleProps,
3
3
  ColorPickerProps,
4
- ColorPickerSelection,
5
4
  ColorPickerTab,
6
- ColorPickerValue,
7
5
  ColorToneDefinition,
8
6
  ColorToneProps,
9
7
  ColorToneSelection,
package/src/index.ts CHANGED
@@ -19,9 +19,7 @@ export { Carousel } from './features/carousel/public';
19
19
  export type {
20
20
  ColorHueScaleProps,
21
21
  ColorPickerProps,
22
- ColorPickerSelection,
23
22
  ColorPickerTab,
24
- ColorPickerValue,
25
23
  ColorToneDefinition,
26
24
  ColorToneProps,
27
25
  ColorToneSelection,
@@ -2,7 +2,7 @@ import type { ColorHarmony, HexColor } from '@ankhorage/color-theory';
2
2
 
3
3
  import type { ZoraBaseProps } from './base';
4
4
 
5
- export type ColorPickerTab = 'wheel' | 'tone' | 'hue';
5
+ export type ColorPickerTab = 'grid' | 'wheel';
6
6
 
7
7
  /** A consumer-owned OKLCH target from the published Templates tone catalog. */
8
8
  export interface ColorToneTarget {
@@ -30,22 +30,10 @@ export interface ColorToneSelection {
30
30
  readonly colors: readonly HexColor[];
31
31
  }
32
32
 
33
- /** The persistent, controlled state for every independently selectable picker mode. */
34
- export interface ColorPickerValue {
35
- readonly tab: ColorPickerTab;
36
- readonly wheel: ColorWheelSelection;
37
- readonly tone: ColorToneSelection | null;
38
- readonly hue: HexColor;
39
- }
40
-
41
- /** A single mode-specific update emitted by the composed picker. */
42
- export type ColorPickerSelection =
43
- | { readonly mode: 'wheel'; readonly value: ColorWheelSelection }
44
- | { readonly mode: 'tone'; readonly value: ColorToneSelection }
45
- | { readonly mode: 'hue'; readonly value: HexColor };
46
-
47
33
  export interface ColorWheelProps extends ZoraBaseProps {
48
34
  readonly value: HexColor;
35
+ /** Square stage side derived by the owning ColorPicker geometry. */
36
+ readonly size?: number;
49
37
  readonly harmony?: ColorHarmony | null;
50
38
  readonly harmonies?: readonly ColorHarmony[];
51
39
  readonly onChange: (selection: ColorWheelSelection) => void;
@@ -64,14 +52,30 @@ export interface ColorHueScaleProps extends ZoraBaseProps {
64
52
  }
65
53
 
66
54
  export interface ColorPickerProps extends ZoraBaseProps {
67
- readonly tabs: readonly ColorPickerTab[];
68
- readonly value: ColorPickerValue;
69
- readonly onValueChange: (value: ColorPickerValue) => void;
70
- readonly onSelectionChange?: (selection: ColorPickerSelection) => void;
55
+ /** Enabled presentations, in Grid then Wheel order by default. */
56
+ readonly tabs?: readonly ColorPickerTab[];
57
+ /** The one authoritative selected colour. */
58
+ readonly primaryColor: HexColor;
59
+ /** Optional owner-provided harmony applied to both presentations. */
60
+ readonly harmony?: ColorHarmony;
61
+ /** Optional consumer-owned tone-family id. */
62
+ readonly tone?: string;
63
+ /** Consumer-owned tone catalogue; ZORA deliberately does not copy it. */
64
+ readonly tones?: readonly ColorToneDefinition[];
65
+ /** Requested outer logical width; hosts must provide at least 360 logical pixels. */
66
+ readonly width?: number;
67
+ /** Controlled active presentation. */
68
+ readonly activeTab?: ColorPickerTab;
69
+ /** Emits one canonical controlled selection payload. */
70
+ readonly onValueChange: (value: {
71
+ readonly primaryColor: HexColor;
72
+ readonly harmony?: ColorHarmony;
73
+ readonly tone?: string;
74
+ }) => void;
75
+ /** Notifies a consumer that a controlled active presentation must change. */
76
+ readonly onActiveTabChange?: (tab: ColorPickerTab) => void;
71
77
  /** Requests dismissal from the owning Popover or BottomSheet presentation. */
72
78
  readonly onDismiss?: () => void;
73
79
  readonly hideTabListWhenSingle?: boolean;
74
- readonly wheel?: Omit<ColorWheelProps, 'onChange' | 'value'>;
75
- readonly tone?: Omit<ColorToneProps, 'onChange' | 'value'>;
76
- readonly hue?: Omit<ColorHueScaleProps, 'onChange' | 'value'>;
80
+ readonly wheel?: Omit<ColorWheelProps, 'onChange' | 'value' | 'harmony'>;
77
81
  }