@ankhorage/zora 27.10.4 → 27.10.6

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 (265) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/dist/features/carousel/Carousel.js +3 -1
  4. package/dist/features/carousel/Carousel.js.map +1 -1
  5. package/dist/features/carousel/useCarouselPlayback.d.ts.map +1 -1
  6. package/dist/features/carousel/useCarouselPlayback.js +2 -1
  7. package/dist/features/carousel/useCarouselPlayback.js.map +1 -1
  8. package/dist/features/color/ColorHexField.d.ts +9 -0
  9. package/dist/features/color/ColorHexField.d.ts.map +1 -0
  10. package/dist/features/color/ColorHexField.js +17 -0
  11. package/dist/features/color/ColorHexField.js.map +1 -0
  12. package/dist/features/color/ColorHorizontalPointerProxy.d.ts +9 -0
  13. package/dist/features/color/ColorHorizontalPointerProxy.d.ts.map +1 -0
  14. package/dist/features/color/ColorHorizontalPointerProxy.js +2 -0
  15. package/dist/features/color/ColorHorizontalPointerProxy.js.map +1 -0
  16. package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts +4 -0
  17. package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts.map +1 -0
  18. package/dist/features/color/ColorHorizontalPointerProxy.native.js +5 -0
  19. package/dist/features/color/ColorHorizontalPointerProxy.native.js.map +1 -0
  20. package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts +5 -0
  21. package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts.map +1 -0
  22. package/dist/features/color/ColorHorizontalPointerProxy.web.js +26 -0
  23. package/dist/features/color/ColorHorizontalPointerProxy.web.js.map +1 -0
  24. package/dist/features/color/ColorHueScale.d.ts.map +1 -1
  25. package/dist/features/color/ColorHueScale.js +18 -7
  26. package/dist/features/color/ColorHueScale.js.map +1 -1
  27. package/dist/features/color/ColorPicker.d.ts.map +1 -1
  28. package/dist/features/color/ColorPicker.js +37 -10
  29. package/dist/features/color/ColorPicker.js.map +1 -1
  30. package/dist/features/color/ColorSpectrumSlider.d.ts +9 -0
  31. package/dist/features/color/ColorSpectrumSlider.d.ts.map +1 -0
  32. package/dist/features/color/ColorSpectrumSlider.js +38 -0
  33. package/dist/features/color/ColorSpectrumSlider.js.map +1 -0
  34. package/dist/features/color/ColorTone.d.ts.map +1 -1
  35. package/dist/features/color/ColorTone.js +71 -12
  36. package/dist/features/color/ColorTone.js.map +1 -1
  37. package/dist/features/color/ColorWheel.d.ts.map +1 -1
  38. package/dist/features/color/ColorWheel.js +64 -36
  39. package/dist/features/color/ColorWheel.js.map +1 -1
  40. package/dist/features/color/ColorWheelPointerProxy.d.ts +10 -0
  41. package/dist/features/color/ColorWheelPointerProxy.d.ts.map +1 -0
  42. package/dist/features/color/ColorWheelPointerProxy.js +2 -0
  43. package/dist/features/color/ColorWheelPointerProxy.js.map +1 -0
  44. package/dist/features/color/ColorWheelPointerProxy.native.d.ts +4 -0
  45. package/dist/features/color/ColorWheelPointerProxy.native.d.ts.map +1 -0
  46. package/dist/features/color/ColorWheelPointerProxy.native.js +5 -0
  47. package/dist/features/color/ColorWheelPointerProxy.native.js.map +1 -0
  48. package/dist/features/color/ColorWheelPointerProxy.web.d.ts +5 -0
  49. package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -0
  50. package/dist/features/color/ColorWheelPointerProxy.web.js +26 -0
  51. package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -0
  52. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
  53. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +14 -2
  54. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
  55. package/dist/types/color.d.ts +2 -0
  56. package/dist/types/color.d.ts.map +1 -1
  57. package/dist/types/color.js.map +1 -1
  58. package/package.json +1 -1
  59. package/src/features/carousel/Carousel.test.ts +1 -0
  60. package/src/features/carousel/Carousel.tsx +3 -1
  61. package/src/features/carousel/useCarouselPlayback.ts +2 -1
  62. package/src/features/color/ColorHexField.tsx +45 -0
  63. package/src/features/color/ColorHorizontalPointerProxy.native.tsx +6 -0
  64. package/src/features/color/ColorHorizontalPointerProxy.tsx +10 -0
  65. package/src/features/color/ColorHorizontalPointerProxy.web.tsx +45 -0
  66. package/src/features/color/ColorHueScale.tsx +48 -29
  67. package/src/features/color/ColorPicker.layout.test.tsx +72 -0
  68. package/src/features/color/ColorPicker.tsx +74 -20
  69. package/src/features/color/ColorSpectrumSlider.tsx +79 -0
  70. package/src/features/color/ColorTone.tsx +138 -21
  71. package/src/features/color/ColorWheel.tsx +173 -92
  72. package/src/features/color/ColorWheelPointerProxy.native.tsx +6 -0
  73. package/src/features/color/ColorWheelPointerProxy.tsx +11 -0
  74. package/src/features/color/ColorWheelPointerProxy.web.tsx +51 -0
  75. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +18 -0
  76. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +18 -2
  77. package/src/types/color.ts +2 -0
  78. package/web-dist/chunks/{Accordion-mxad79vq.js → Accordion-0kr0h68p.js} +4568 -669
  79. package/web-dist/chunks/{Accordion-0jkpvxwd.js → Accordion-1etqb3cj.js} +2 -2
  80. package/web-dist/chunks/{Accordion-jr0201qc.js → Accordion-1mxnyexh.js} +17 -17
  81. package/web-dist/chunks/{Accordion-9kkfz7s8.js → Accordion-3ecnh8d0.js} +4 -4
  82. package/web-dist/chunks/{Accordion-jsapannb.js → Accordion-3jkeydhb.js} +4 -4
  83. package/web-dist/chunks/{Accordion-r6gwemh9.js → Accordion-3wkd5x2q.js} +3 -3
  84. package/web-dist/chunks/{Accordion-0bgzetnd.js → Accordion-3zw817fr.js} +6 -6
  85. package/web-dist/chunks/{Accordion-91v243pz.js → Accordion-49w9bc2f.js} +2 -2
  86. package/web-dist/chunks/{Accordion-8vw4k0s6.js → Accordion-4g54je0w.js} +2 -2
  87. package/web-dist/chunks/{Accordion-1andv7gg.js → Accordion-5vs1k81g.js} +8 -8
  88. package/web-dist/chunks/{Accordion-ttjyk97v.js → Accordion-6m3k4avp.js} +2 -2
  89. package/web-dist/chunks/{Accordion-dnfrzbpb.js → Accordion-6nrpdbmb.js} +7 -7
  90. package/web-dist/chunks/{Accordion-y524ph0g.js → Accordion-6yv4beha.js} +1 -1
  91. package/web-dist/chunks/{Accordion-9cpm8x92.js → Accordion-705yrq6w.js} +1 -1
  92. package/web-dist/chunks/{Accordion-th8pkeqc.js → Accordion-8g9c7890.js} +4 -4
  93. package/web-dist/chunks/{Accordion-6qesggn9.js → Accordion-9c63jn3m.js} +4 -4
  94. package/web-dist/chunks/{Accordion-1mjn0atk.js → Accordion-aws0caav.js} +3 -3
  95. package/web-dist/chunks/{Accordion-hha54x4c.js → Accordion-bd6q61s1.js} +5 -5
  96. package/web-dist/chunks/{Accordion-8rkwd0wx.js → Accordion-c0a7mhq3.js} +2 -2
  97. package/web-dist/chunks/{Accordion-j5wsx41j.js → Accordion-c3nna2bz.js} +1 -1
  98. package/web-dist/chunks/{Accordion-r6mc7qtj.js → Accordion-dfq04q82.js} +9 -9
  99. package/web-dist/chunks/{Accordion-nbje2ywp.js → Accordion-e3r3573t.js} +3 -3
  100. package/web-dist/chunks/{Accordion-hqg1zbxk.js → Accordion-e5jr9ahb.js} +1 -1
  101. package/web-dist/chunks/{Accordion-pkbvsn5y.js → Accordion-eak89n4n.js} +6 -6
  102. package/web-dist/chunks/{Accordion-7e0mb55z.js → Accordion-f60g73bp.js} +6 -6
  103. package/web-dist/chunks/{Accordion-grtf75xt.js → Accordion-g451f3g9.js} +4 -4
  104. package/web-dist/chunks/{Accordion-27rxpbvf.js → Accordion-gezcm372.js} +4 -4
  105. package/web-dist/chunks/{Accordion-45tbe5v0.js → Accordion-h0e95qxp.js} +9 -9
  106. package/web-dist/chunks/{Accordion-m7jt3c87.js → Accordion-h2nd5y0z.js} +5 -5
  107. package/web-dist/chunks/{Accordion-f6k281sv.js → Accordion-j0zhpq4s.js} +7 -7
  108. package/web-dist/chunks/{Accordion-q6xnm1k4.js → Accordion-jbwey4za.js} +17 -17
  109. package/web-dist/chunks/{Accordion-vdqc8rxv.js → Accordion-jd26f516.js} +3 -3
  110. package/web-dist/chunks/{Accordion-1k7pyxdd.js → Accordion-ne91vwkd.js} +2 -2
  111. package/web-dist/chunks/{Accordion-k058095e.js → Accordion-p29kmwh9.js} +1 -1
  112. package/web-dist/chunks/{Accordion-0pbcs0xf.js → Accordion-pcj256bc.js} +5 -5
  113. package/web-dist/chunks/{Accordion-8wq38d9b.js → Accordion-phtyg3k4.js} +7 -7
  114. package/web-dist/chunks/{Accordion-b991pn6e.js → Accordion-pmfdf08d.js} +1 -1
  115. package/web-dist/chunks/{Accordion-xp2t3pkj.js → Accordion-q1tdazgq.js} +8 -8
  116. package/web-dist/chunks/{Accordion-v21vz0cg.js → Accordion-qhn8z92r.js} +3 -3
  117. package/web-dist/chunks/Accordion-r1wkgt7c.js +1074 -0
  118. package/web-dist/chunks/{Accordion-ctcxh9pk.js → Accordion-rzf52xq8.js} +2 -2
  119. package/web-dist/chunks/{Accordion-hrxdchkq.js → Accordion-vewhx028.js} +8 -8
  120. package/web-dist/chunks/{Accordion-jsdjgfn2.js → Accordion-vk2v1zwv.js} +2 -2
  121. package/web-dist/chunks/{Accordion-19zt3dyq.js → Accordion-vnrqvfca.js} +1 -1
  122. package/web-dist/chunks/{Accordion-rt4jfq2r.js → Accordion-x0p3wxfp.js} +2 -2
  123. package/web-dist/chunks/{Accordion-w1ag7sr4.js → Accordion-x7ynjdv7.js} +1 -1
  124. package/web-dist/chunks/{Accordion-ga82tcs9.js → Accordion-xb174981.js} +10 -10
  125. package/web-dist/chunks/{Accordion-yskcfahv.js → Accordion-xwstve3k.js} +2 -2
  126. package/web-dist/chunks/{Accordion-xb2nj0q6.js → Accordion-ysmzrvhn.js} +3 -3
  127. package/web-dist/chunks/{Accordion-tnq8bt8v.js → Accordion-z4qakakw.js} +2 -2
  128. package/web-dist/chunks/{Accordion-w9vbdg9r.js → Accordion-z8ryq8cb.js} +11 -11
  129. package/web-dist/chunks/{Accordion-x3em7tpd.js → Accordion-zx8gmww4.js} +9 -9
  130. package/web-dist/components/accordion/Accordion.js +10 -10
  131. package/web-dist/components/accordion-item/AccordionItem.js +10 -10
  132. package/web-dist/components/activity-indicator/ActivityIndicator.js +3 -3
  133. package/web-dist/components/app-bar/AppBar.js +15 -16
  134. package/web-dist/components/app-header/AppHeader.js +15 -16
  135. package/web-dist/components/app-shell/AppShell.js +4 -4
  136. package/web-dist/components/auth-screen/AuthScreen.js +20 -21
  137. package/web-dist/components/avatar/Avatar.js +10 -10
  138. package/web-dist/components/avatar-group/AvatarGroup.js +10 -10
  139. package/web-dist/components/badge/Badge.js +5 -5
  140. package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +18 -19
  141. package/web-dist/components/bottom-sheet/BottomSheet.js +6 -6
  142. package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +6 -6
  143. package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +6 -6
  144. package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +6 -6
  145. package/web-dist/components/bottom-sheet-view/BottomSheetView.js +6 -6
  146. package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +6 -6
  147. package/web-dist/components/breadcrumbs/Breadcrumbs.js +15 -16
  148. package/web-dist/components/button/Button.js +13 -14
  149. package/web-dist/components/button-group/ButtonGroup.js +11 -12
  150. package/web-dist/components/calendar/Calendar.js +12 -13
  151. package/web-dist/components/camera-permission-view/CameraPermissionView.js +18 -19
  152. package/web-dist/components/card/Card.js +17 -18
  153. package/web-dist/components/card-back/CardBack.js +4 -4
  154. package/web-dist/components/card-hand/CardHand.js +4 -4
  155. package/web-dist/components/carousel/Carousel.js +7 -4
  156. package/web-dist/components/chat-list-item/ChatListItem.js +14 -14
  157. package/web-dist/components/checkbox/Checkbox.js +10 -10
  158. package/web-dist/components/checkbox-group/CheckboxGroup.js +10 -10
  159. package/web-dist/components/chess-board/ChessBoard.js +4 -4
  160. package/web-dist/components/chip/Chip.js +11 -11
  161. package/web-dist/components/chip-group/ChipGroup.js +11 -11
  162. package/web-dist/components/collection-editor/CollectionEditor.js +21 -22
  163. package/web-dist/components/color-hue-scale/ColorHueScale.js +15 -14
  164. package/web-dist/components/color-picker/ColorPicker.js +15 -14
  165. package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +2 -0
  166. package/web-dist/components/color-tone/ColorTone.js +15 -14
  167. package/web-dist/components/color-wheel/ColorWheel.js +15 -14
  168. package/web-dist/components/content-rail/ContentRail.js +13 -14
  169. package/web-dist/components/data-table/DataTable.js +27 -28
  170. package/web-dist/components/date-picker/DatePicker.js +19 -20
  171. package/web-dist/components/dialog/Dialog.js +9 -9
  172. package/web-dist/components/divider/Divider.js +4 -4
  173. package/web-dist/components/empty-state/EmptyState.js +18 -19
  174. package/web-dist/components/explorer/Explorer.js +11 -11
  175. package/web-dist/components/field/Field.js +10 -10
  176. package/web-dist/components/file-explorer/FileExplorer.js +11 -11
  177. package/web-dist/components/flat-list/FlatList.js +11 -11
  178. package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +20 -21
  179. package/web-dist/components/form/Form.js +14 -15
  180. package/web-dist/components/form-actions/FormActions.js +14 -15
  181. package/web-dist/components/form-error/FormError.js +14 -15
  182. package/web-dist/components/game/Game.js +5 -5
  183. package/web-dist/components/game-entity/GameEntity.js +5 -5
  184. package/web-dist/components/game-field/GameField.js +5 -5
  185. package/web-dist/components/game-input-zone/GameInputZone.js +5 -5
  186. package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +5 -5
  187. package/web-dist/components/game-overlay/GameOverlay.js +5 -5
  188. package/web-dist/components/gradient/Gradient.js +5 -5
  189. package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +5 -5
  190. package/web-dist/components/graph-view/GraphView.js +9 -2
  191. package/web-dist/components/grid/Grid.js +4 -4
  192. package/web-dist/components/grid-line-overlay/GridLineOverlay.js +4 -4
  193. package/web-dist/components/grid-ruler/GridRuler.js +4 -4
  194. package/web-dist/components/heading/Heading.js +5 -5
  195. package/web-dist/components/hero/Hero.js +20 -21
  196. package/web-dist/components/icon/Icon.js +4 -4
  197. package/web-dist/components/icon-button/IconButton.js +11 -12
  198. package/web-dist/components/image/Image.js +8 -8
  199. package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +3 -3
  200. package/web-dist/components/list/List.js +11 -11
  201. package/web-dist/components/list-item/ListItem.js +11 -11
  202. package/web-dist/components/list-section/ListSection.js +11 -11
  203. package/web-dist/components/master-detail/MasterDetail.js +4 -4
  204. package/web-dist/components/matrix-grid/MatrixGrid.js +4 -4
  205. package/web-dist/components/media-card/MediaCard.js +17 -18
  206. package/web-dist/components/media-explorer/MediaExplorer.js +11 -11
  207. package/web-dist/components/message-bubble/MessageBubble.js +14 -14
  208. package/web-dist/components/metric-card/MetricCard.js +17 -18
  209. package/web-dist/components/missing-element/MissingElement.js +9 -9
  210. package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +20 -21
  211. package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +20 -21
  212. package/web-dist/components/opening-book/OpeningBook.js +4 -4
  213. package/web-dist/components/otp-form/OtpForm.js +20 -21
  214. package/web-dist/components/pagination/Pagination.js +18 -19
  215. package/web-dist/components/palette-item/PaletteItem.js +17 -18
  216. package/web-dist/components/playing-card/PlayingCard.js +4 -4
  217. package/web-dist/components/poker-training-table/PokerTrainingTable.js +4 -4
  218. package/web-dist/components/popover-menu/PopoverMenu.js +10 -10
  219. package/web-dist/components/post-card/PostCard.js +17 -18
  220. package/web-dist/components/product-card/ProductCard.js +17 -18
  221. package/web-dist/components/progress/Progress.js +8 -8
  222. package/web-dist/components/progress-ring/ProgressRing.js +8 -8
  223. package/web-dist/components/radio/Radio.js +12 -12
  224. package/web-dist/components/radio-group/RadioGroup.js +12 -12
  225. package/web-dist/components/rating/Rating.js +7 -7
  226. package/web-dist/components/reader/Reader.js +20 -21
  227. package/web-dist/components/scan-overlay/ScanOverlay.js +18 -19
  228. package/web-dist/components/screen/Screen.js +4 -4
  229. package/web-dist/components/screen-section/ScreenSection.js +8 -8
  230. package/web-dist/components/scroll-view/ScrollView.js +4 -4
  231. package/web-dist/components/search-input/SearchInput.js +12 -13
  232. package/web-dist/components/section-header/SectionHeader.js +8 -8
  233. package/web-dist/components/section-list/SectionList.js +11 -11
  234. package/web-dist/components/select/Select.js +16 -17
  235. package/web-dist/components/selectable-item/SelectableItem.js +3 -3
  236. package/web-dist/components/selection-provider/SelectionProvider.js +3 -3
  237. package/web-dist/components/sign-in-form/SignInForm.js +20 -21
  238. package/web-dist/components/sign-up-form/SignUpForm.js +20 -21
  239. package/web-dist/components/skeleton/Skeleton.js +20 -21
  240. package/web-dist/components/skeleton-card/SkeletonCard.js +20 -21
  241. package/web-dist/components/skeleton-list/SkeletonList.js +20 -21
  242. package/web-dist/components/skeleton-text/SkeletonText.js +20 -21
  243. package/web-dist/components/surface/Surface.js +5 -5
  244. package/web-dist/components/switch/Switch.js +5 -5
  245. package/web-dist/components/tab/Tab.js +5 -5
  246. package/web-dist/components/tab-list/TabList.js +5 -5
  247. package/web-dist/components/tab-panel/TabPanel.js +5 -5
  248. package/web-dist/components/tabletop-table/TabletopTable.js +4 -4
  249. package/web-dist/components/tabs/Tabs.js +5 -5
  250. package/web-dist/components/text/Text.js +5 -5
  251. package/web-dist/components/text-input/TextInput.js +12 -13
  252. package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +12 -13
  253. package/web-dist/components/time-picker/TimePicker.js +19 -20
  254. package/web-dist/components/timeline/Timeline.js +10 -10
  255. package/web-dist/components/toast/Toast.js +7 -7
  256. package/web-dist/components/toast-provider/ToastProvider.js +7 -7
  257. package/web-dist/components/toolbar/Toolbar.js +17 -18
  258. package/web-dist/components/tree-item/TreeItem.js +17 -18
  259. package/web-dist/components/uploader/Uploader.js +26 -27
  260. package/web-dist/components/view/View.js +4 -4
  261. package/web-dist/manifest.json +1417 -1459
  262. package/web-dist/runtime/ZoraProvider.js +6 -6
  263. package/web-dist/chunks/Accordion-fjnb7anx.js +0 -548
  264. package/web-dist/chunks/Accordion-ztcmb44y.js +0 -3928
  265. package/web-dist/chunks/{Accordion-ng79nxzz.js → Accordion-an5prgty.js} +18 -18
@@ -0,0 +1,72 @@
1
+ import { join } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+
4
+ import { expect, test } from 'bun:test';
5
+ import { Window } from 'happy-dom';
6
+ import React from 'react';
7
+ import { renderToStaticMarkup } from 'react-dom/server';
8
+
9
+ import type { ColorPicker as ColorPickerComponent } from './ColorPicker';
10
+
11
+ const webDistRoot = join(import.meta.dir, '../../../web-dist');
12
+
13
+ /*** Loads the generated public web artifact that consumers actually render. */
14
+ function load(path: string) {
15
+ return import(pathToFileURL(join(webDistRoot, path)).href);
16
+ }
17
+
18
+ test('keeps the selected hue grid inside the responsive picker surface in both theme modes', async () => {
19
+ const [{ ColorPicker }, { ZoraProvider }] = (await Promise.all([
20
+ load('components/color-picker/index.js'),
21
+ load('runtime/ZoraProvider.js'),
22
+ ])) as [
23
+ { ColorPicker: typeof ColorPickerComponent },
24
+ {
25
+ ZoraProvider: React.ComponentType<{
26
+ readonly children?: React.ReactNode;
27
+ readonly mode: string;
28
+ }>;
29
+ },
30
+ ];
31
+
32
+ const markupFor = (mode: 'dark' | 'light') =>
33
+ renderToStaticMarkup(
34
+ <ZoraProvider mode={mode}>
35
+ <ColorPicker
36
+ hue={{}}
37
+ onDismiss={() => undefined}
38
+ onValueChange={() => undefined}
39
+ tabs={['wheel', 'tone', 'hue']}
40
+ testID={`picker-${mode}`}
41
+ value={{
42
+ hue: '#2563eb',
43
+ tab: 'hue',
44
+ tone: null,
45
+ wheel: { color: '#2563eb', harmony: null },
46
+ }}
47
+ />
48
+ </ZoraProvider>,
49
+ );
50
+
51
+ for (const mode of ['dark', 'light'] as const) {
52
+ const browser = new Window();
53
+ browser.document.body.innerHTML = markupFor(mode);
54
+ try {
55
+ const picker = browser.document.querySelector(`[data-testid="picker-${mode}"]`);
56
+ const scale = browser.document.querySelector('[aria-label^="Color scale previews"]');
57
+ const swatches = scale?.querySelectorAll('[role="button"]') ?? [];
58
+
59
+ expect(picker?.getAttribute('style')).toContain('width:100%');
60
+ expect(picker?.getAttribute('style')).toContain('max-width:400px');
61
+ expect(browser.document.querySelector('[aria-label="Close color picker"]')).not.toBeNull();
62
+ expect(browser.document.querySelectorAll('[aria-label="Color hex value"]')).toHaveLength(1);
63
+ expect(scale?.getAttribute('style')).toContain('flex-wrap:wrap');
64
+ expect(swatches).toHaveLength(11);
65
+ expect(
66
+ Array.from(swatches).every((swatch) => swatch.getAttribute('style')?.includes('width:18%')),
67
+ ).toBe(true);
68
+ } finally {
69
+ browser.close();
70
+ }
71
+ }
72
+ });
@@ -1,8 +1,12 @@
1
1
  import React from 'react';
2
2
 
3
3
  import type { ColorPickerProps, ColorPickerTab, ColorPickerValue } from '../../types/color';
4
+ import { IconButton } from '../button/public';
5
+ import { View } from '../layout/public';
4
6
  import { Tab, TabList, TabPanel, Tabs } from '../tabs/public';
5
7
  import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
8
+ import { useZoraTheme } from '../theme/composition/useZoraTheme';
9
+ import { Text } from '../typography/public';
6
10
  import { ColorHueScale } from './ColorHueScale';
7
11
  import { ColorTone } from './ColorTone';
8
12
  import { ColorWheel } from './ColorWheel';
@@ -19,38 +23,81 @@ function ColorPickerInner({
19
23
  value,
20
24
  onValueChange,
21
25
  onSelectionChange,
26
+ onDismiss,
22
27
  hideTabListWhenSingle = true,
23
28
  wheel,
24
29
  tone,
25
30
  hue,
26
31
  testID,
27
32
  }: ColorPickerProps) {
33
+ const { theme } = useZoraTheme();
28
34
  if (tabs.length === 0) throw new Error('ColorPicker requires at least one tab.');
29
35
  if (!tabs.includes(value.tab)) throw new Error('ColorPicker value must be configured in tabs.');
36
+ const previewColor = resolvePickerPreviewColor(value);
30
37
 
31
38
  return (
32
- <Tabs
33
- defaultValue={value.tab}
34
- onValueChange={(nextValue) => {
35
- if (isColorPickerTab(nextValue) && tabs.includes(nextValue))
36
- onValueChange({ ...value, tab: nextValue });
37
- }}
39
+ <View
40
+ alignSelf="center"
41
+ bg={theme.semantics.surface.raised}
42
+ borderColor={theme.semantics.border.default}
43
+ borderWidth={1}
44
+ flexShrink={1}
45
+ gap="s"
46
+ maxWidth={400}
47
+ p="m"
48
+ radius="l"
38
49
  testID={testID}
39
- value={value.tab}
50
+ width="100%"
40
51
  >
41
- {tabs.length > 1 || !hideTabListWhenSingle ? (
42
- <TabList fill>
43
- {tabs.map((tab) => (
44
- <Tab key={tab} label={tab} value={tab} />
45
- ))}
46
- </TabList>
47
- ) : null}
48
- {tabs.map((tab) => (
49
- <TabPanel key={tab} value={tab}>
50
- {resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)}
51
- </TabPanel>
52
- ))}
53
- </Tabs>
52
+ <View align="center" direction="row" justify="space-between">
53
+ <Text variant="lead" weight="semiBold">
54
+ Color
55
+ </Text>
56
+ <View align="center" direction="row" gap="s">
57
+ <View
58
+ bg={previewColor}
59
+ borderColor={theme.semantics.border.default}
60
+ borderWidth={1}
61
+ height={38}
62
+ radius="s"
63
+ width={38}
64
+ />
65
+ {onDismiss ? (
66
+ <IconButton iconName="close" label="Close color picker" onPress={onDismiss} />
67
+ ) : null}
68
+ </View>
69
+ </View>
70
+ <Tabs
71
+ defaultValue={value.tab}
72
+ onValueChange={(nextValue) => {
73
+ if (isColorPickerTab(nextValue) && tabs.includes(nextValue))
74
+ onValueChange({ ...value, tab: nextValue });
75
+ }}
76
+ testID={testID ? `${testID}-tabs` : undefined}
77
+ value={value.tab}
78
+ variant="attached"
79
+ >
80
+ {tabs.length > 1 || !hideTabListWhenSingle ? (
81
+ <View
82
+ borderColor={theme.semantics.border.default}
83
+ borderWidth={1}
84
+ overflow="hidden"
85
+ radius="m"
86
+ >
87
+ <TabList fill>
88
+ {tabs.map((tab) => (
89
+ <Tab key={tab} label={tab} value={tab} />
90
+ ))}
91
+ </TabList>
92
+ </View>
93
+ ) : null}
94
+ {tabs.map((tab) => (
95
+ <TabPanel key={tab} value={tab}>
96
+ {resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)}
97
+ </TabPanel>
98
+ ))}
99
+ </Tabs>
100
+ </View>
54
101
  );
55
102
  }
56
103
 
@@ -59,6 +106,13 @@ function isColorPickerTab(value: string): value is ColorPickerTab {
59
106
  return value === 'wheel' || value === 'tone' || value === 'hue';
60
107
  }
61
108
 
109
+ /*** Resolves the visible active-tab color without introducing a second picker state. */
110
+ function resolvePickerPreviewColor(value: ColorPickerValue) {
111
+ if (value.tab === 'hue') return value.hue;
112
+ if (value.tab === 'tone') return value.tone?.colors.at(0) ?? value.wheel.color;
113
+ return value.wheel.color;
114
+ }
115
+
62
116
  /*** Resolve the configured control for one picker tab without adding fallback feature modes. */
63
117
  function resolveTabContent(
64
118
  tab: ColorPickerTab,
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { Circle, Defs, LinearGradient, Rect, Stop, Svg } from 'react-native-svg';
3
+
4
+ import { View } from '../layout/public';
5
+ import { useZoraTheme } from '../theme/composition/useZoraTheme';
6
+ import { Text } from '../typography/public';
7
+ import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
8
+ import { resolveOklchColor } from './utils/resolveOklchColor';
9
+
10
+ const SPECTRUM_WIDTH = 280;
11
+ const SPECTRUM_HUES = [0, 60, 120, 180, 240, 300, 360] as const;
12
+
13
+ /*** Selects a controlled hue across the same full-spectrum track used by Studio tabs. */
14
+ export function ColorSpectrumSlider({
15
+ disabled,
16
+ hue,
17
+ label = 'Hue',
18
+ onChange,
19
+ }: {
20
+ readonly disabled: boolean;
21
+ readonly hue: number;
22
+ readonly label?: string;
23
+ readonly onChange: (hue: number) => void;
24
+ }) {
25
+ const { theme } = useZoraTheme();
26
+ const [trackWidth, setTrackWidth] = React.useState(SPECTRUM_WIDTH);
27
+ const gradientId = `color-spectrum-${React.useId().replaceAll(':', '')}`;
28
+ const changeAt = (locationX: number) => {
29
+ if (!disabled) onChange(Math.max(0, Math.min(360, (locationX / trackWidth) * 360)));
30
+ };
31
+
32
+ return (
33
+ <View gap="xxs" width="100%">
34
+ <View direction="row" justify="space-between">
35
+ <Text variant="label">{label}</Text>
36
+ <Text variant="label">{`${Math.round(hue)}°`}</Text>
37
+ </View>
38
+ <ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={SPECTRUM_WIDTH}>
39
+ <Svg
40
+ accessibilityLabel={`${label} spectrum`}
41
+ height={36}
42
+ onLayout={(event) => setTrackWidth(Math.max(1, event.nativeEvent.layout.width))}
43
+ viewBox={`0 0 ${SPECTRUM_WIDTH} 36`}
44
+ width="100%"
45
+ >
46
+ <Defs>
47
+ <LinearGradient id={gradientId} x1="0" x2="1" y1="0" y2="0">
48
+ {SPECTRUM_HUES.map((stopHue, index) => (
49
+ <Stop
50
+ key={stopHue}
51
+ offset={String(index / (SPECTRUM_HUES.length - 1))}
52
+ stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0.2 }, stopHue)}
53
+ />
54
+ ))}
55
+ </LinearGradient>
56
+ </Defs>
57
+ <Rect fill={`url(#${gradientId})`} height={12} rx={6} width={SPECTRUM_WIDTH} y={12} />
58
+ <Circle
59
+ cx={(hue / 360) * SPECTRUM_WIDTH}
60
+ cy={18}
61
+ fill="white"
62
+ r={10}
63
+ stroke={theme.semantics.content.default}
64
+ strokeWidth={2}
65
+ />
66
+ <Rect
67
+ fill="transparent"
68
+ height={36}
69
+ onResponderGrant={(event) => changeAt(event.nativeEvent.locationX)}
70
+ onResponderMove={(event) => changeAt(event.nativeEvent.locationX)}
71
+ onResponderRelease={(event) => changeAt(event.nativeEvent.locationX)}
72
+ onStartShouldSetResponder={() => !disabled}
73
+ width={SPECTRUM_WIDTH}
74
+ />
75
+ </Svg>
76
+ </ColorHorizontalPointerProxy>
77
+ </View>
78
+ );
79
+ }
@@ -1,14 +1,24 @@
1
+ import { type HexColor } from '@ankhorage/color-theory';
1
2
  import { Button, Pressable } from '@ankhorage/surface';
2
3
  import React from 'react';
4
+ import { Circle, Defs, LinearGradient, Rect, Stop, Svg } from 'react-native-svg';
3
5
 
4
6
  import type { ColorToneProps } from '../../types/color';
5
7
  import { View } from '../layout/public';
6
8
  import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
7
- import { ColorWheel } from './ColorWheel';
9
+ import { useZoraTheme } from '../theme/composition/useZoraTheme';
10
+ import { Text } from '../typography/public';
11
+ import { ColorHexField } from './ColorHexField';
12
+ import { ColorSpectrumSlider } from './ColorSpectrumSlider';
13
+ import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
8
14
  import { resolveColorHue } from './utils/resolveColorHue';
9
15
  import { resolveOklchColor } from './utils/resolveOklchColor';
16
+ import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
10
17
 
11
18
  const MAX_TONE_COLORS = 4;
19
+ const TONE_MAP_WIDTH = 280;
20
+ const TONE_MAP_HEIGHT = 220;
21
+ const TONE_MAX_CHROMA = 0.2;
12
22
 
13
23
  /*** Selects consumer-provided OKLCH tone targets while keeping hue adjustable. */
14
24
  export const ColorTone = withZoraThemeScope(ColorToneInner);
@@ -25,6 +35,7 @@ function ColorToneInner({
25
35
  onChange,
26
36
  testID,
27
37
  }: ColorToneProps) {
38
+ const { theme } = useZoraTheme();
28
39
  const [editingColorIndex, setEditingColorIndex] = React.useState(0);
29
40
  const selectedTone = tones.find((tone) => tone.id === value?.toneId);
30
41
  const colors = value
@@ -41,8 +52,14 @@ function ColorToneInner({
41
52
  };
42
53
 
43
54
  return (
44
- <View gap="sm" testID={testID}>
45
- <View direction="row" wrap="wrap" gap="sm">
55
+ <View gap="m" testID={testID}>
56
+ <View gap="xs">
57
+ <Text variant="label">Tone</Text>
58
+ <Text emphasis="muted" variant="caption">
59
+ Choose a catalog tone
60
+ </Text>
61
+ </View>
62
+ <View direction="row" gap="s" wrap="wrap">
46
63
  {tones.map((tone) => {
47
64
  const selected = value?.toneId === tone.id;
48
65
  const color =
@@ -54,19 +71,37 @@ function ColorToneInner({
54
71
  accessibilityRole="radio"
55
72
  accessibilityState={{ checked: selected }}
56
73
  bg={color}
57
- borderColor="border"
74
+ borderColor={theme.semantics.border.default}
58
75
  borderWidth={selected ? 3 : 1}
59
76
  disabled={interactionPolicy === 'passive'}
60
- height={44}
77
+ height={56}
61
78
  onPress={() => selectTone(tone)}
62
- radius="md"
63
- width={44}
64
- />
79
+ radius="m"
80
+ width={56}
81
+ >
82
+ <Text align="center" variant="caption">
83
+ {tone.accent}
84
+ </Text>
85
+ </Pressable>
65
86
  );
66
87
  })}
67
88
  </View>
68
89
  {selectedTone && selectedColor && value ? (
69
90
  <>
91
+ <ColorToneMap
92
+ color={selectedColor}
93
+ disabled={interactionPolicy === 'passive'}
94
+ onChange={(lightness, chroma) =>
95
+ onChange({
96
+ toneId: selectedTone.id,
97
+ colors: colors.map((entry, index) =>
98
+ index === currentEditingColorIndex
99
+ ? resolveOklchColor({ chroma, lightness }, resolveColorHue(entry))
100
+ : entry,
101
+ ),
102
+ })
103
+ }
104
+ />
70
105
  <View direction="row" gap="xs" wrap="wrap">
71
106
  {colors.map((color, index) => (
72
107
  <Pressable
@@ -75,12 +110,12 @@ function ColorToneInner({
75
110
  accessibilityRole="radio"
76
111
  accessibilityState={{ checked: currentEditingColorIndex === index }}
77
112
  bg={color}
78
- borderColor="border"
113
+ borderColor={theme.semantics.border.default}
79
114
  borderWidth={currentEditingColorIndex === index ? 3 : 1}
80
115
  disabled={interactionPolicy === 'passive'}
81
116
  height={44}
82
117
  onPress={() => setEditingColorIndex(index)}
83
- radius="md"
118
+ radius="m"
84
119
  width={44}
85
120
  />
86
121
  ))}
@@ -113,21 +148,31 @@ function ColorToneInner({
113
148
  </Button>
114
149
  ) : null}
115
150
  </View>
116
- <ColorWheel
117
- harmony={null}
118
- interactionPolicy={interactionPolicy}
119
- onChange={({ color }) => {
120
- const nextColor = resolveOklchColor(
121
- selectedTone.accentTarget,
122
- resolveColorHue(color),
123
- );
151
+ <ColorSpectrumSlider
152
+ disabled={interactionPolicy === 'passive'}
153
+ hue={resolveColorHue(selectedColor)}
154
+ onChange={(nextHue) =>
155
+ onChange({
156
+ toneId: selectedTone.id,
157
+ colors: colors.map((entry, index) =>
158
+ index === currentEditingColorIndex
159
+ ? resolveOklchColor(selectedTone.accentTarget, nextHue)
160
+ : entry,
161
+ ),
162
+ })
163
+ }
164
+ />
165
+ <ColorHexField
166
+ disabled={interactionPolicy === 'passive'}
167
+ key={selectedColor}
168
+ onChange={(color) =>
124
169
  onChange({
125
170
  toneId: selectedTone.id,
126
171
  colors: colors.map((entry, index) =>
127
- index === currentEditingColorIndex ? nextColor : entry,
172
+ index === currentEditingColorIndex ? color : entry,
128
173
  ),
129
- });
130
- }}
174
+ })
175
+ }
131
176
  value={selectedColor}
132
177
  />
133
178
  </>
@@ -135,3 +180,75 @@ function ColorToneInner({
135
180
  </View>
136
181
  );
137
182
  }
183
+
184
+ /*** Renders the Studio-style saturation and lightness plane for the active catalog color. */
185
+ function ColorToneMap({
186
+ color,
187
+ disabled,
188
+ onChange,
189
+ }: {
190
+ readonly color: HexColor;
191
+ readonly disabled: boolean;
192
+ readonly onChange: (lightness: number, chroma: number) => void;
193
+ }) {
194
+ const hue = resolveColorHue(color);
195
+ const { chroma, lightness } = resolveWheelColorComponents(color);
196
+ const gradientId = `color-tone-${React.useId().replaceAll(':', '')}`;
197
+ const changeAt = (x: number, y: number) => {
198
+ if (disabled) return;
199
+ onChange(
200
+ Math.max(0, Math.min(1, 1 - y / TONE_MAP_HEIGHT)),
201
+ Math.max(0, Math.min(TONE_MAX_CHROMA, (x / TONE_MAP_WIDTH) * TONE_MAX_CHROMA)),
202
+ );
203
+ };
204
+
205
+ return (
206
+ <ColorWheelPointerProxy
207
+ disabled={disabled}
208
+ height={TONE_MAP_HEIGHT}
209
+ onChange={changeAt}
210
+ width={TONE_MAP_WIDTH}
211
+ >
212
+ <Svg accessibilityLabel="Tone color plane" height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH}>
213
+ <Defs>
214
+ <LinearGradient id={`${gradientId}-white`} x1="0" x2="1" y1="0" y2="0">
215
+ <Stop offset="0" stopColor="white" />
216
+ <Stop
217
+ offset="1"
218
+ stopColor={resolveOklchColor({ chroma: TONE_MAX_CHROMA, lightness: 0.65 }, hue)}
219
+ />
220
+ </LinearGradient>
221
+ <LinearGradient id={`${gradientId}-black`} x1="0" x2="0" y1="0" y2="1">
222
+ <Stop offset="0" stopColor="transparent" />
223
+ <Stop offset="1" stopColor="black" />
224
+ </LinearGradient>
225
+ </Defs>
226
+ <Rect fill={`url(#${gradientId}-white)`} height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH} />
227
+ <Rect fill={`url(#${gradientId}-black)`} height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH} />
228
+ <Circle
229
+ cx={(chroma / TONE_MAX_CHROMA) * TONE_MAP_WIDTH}
230
+ cy={(1 - lightness) * TONE_MAP_HEIGHT}
231
+ fill="none"
232
+ r={10}
233
+ stroke="white"
234
+ strokeWidth={3}
235
+ />
236
+ <Rect
237
+ fill="transparent"
238
+ height={TONE_MAP_HEIGHT}
239
+ onResponderGrant={(event) =>
240
+ changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)
241
+ }
242
+ onResponderMove={(event) =>
243
+ changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)
244
+ }
245
+ onResponderRelease={(event) =>
246
+ changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)
247
+ }
248
+ onStartShouldSetResponder={() => !disabled}
249
+ width={TONE_MAP_WIDTH}
250
+ />
251
+ </Svg>
252
+ </ColorWheelPointerProxy>
253
+ );
254
+ }