@astryxdesign/core 0.7.17-canary.gffd1c8e → 0.7.17

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 (922) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/README.md +26 -9
  3. package/dist/AlertDialog/AlertDialog.d.ts +1 -1
  4. package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
  5. package/dist/AlertDialog/AlertDialog.js +6 -8
  6. package/dist/AppShell/AppShell.d.ts +7 -3
  7. package/dist/AppShell/AppShell.d.ts.map +1 -1
  8. package/dist/AppShell/AppShell.js +74 -36
  9. package/dist/AppShell/unreadWidthPoint.d.ts +29 -0
  10. package/dist/AppShell/unreadWidthPoint.d.ts.map +1 -0
  11. package/dist/AppShell/unreadWidthPoint.js +134 -0
  12. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts +1 -1
  13. package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
  14. package/dist/AvatarGroup/AvatarGroupOverflow.js +5 -1
  15. package/dist/Badge/Badge.d.ts.map +1 -1
  16. package/dist/Badge/Badge.js +2 -2
  17. package/dist/Banner/Banner.d.ts +6 -4
  18. package/dist/Banner/Banner.d.ts.map +1 -1
  19. package/dist/Banner/Banner.js +32 -29
  20. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  21. package/dist/BottomSheet/BottomSheet.js +3 -1
  22. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  23. package/dist/BottomSheet/BottomSheetPanel.js +11 -7
  24. package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
  25. package/dist/BottomSheet/BottomSheetSwitcher.js +57 -2
  26. package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts +5 -0
  27. package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts.map +1 -1
  28. package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
  29. package/dist/BottomSheet/bottomSheetStack.js +6 -14
  30. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  31. package/dist/Breadcrumbs/BreadcrumbItem.js +12 -1
  32. package/dist/Button/Button.d.ts.map +1 -1
  33. package/dist/Button/Button.js +4 -0
  34. package/dist/Calendar/Calendar.js +8 -2
  35. package/dist/Calendar/styles.d.ts +10 -6
  36. package/dist/Calendar/styles.d.ts.map +1 -1
  37. package/dist/Calendar/styles.js +7 -3
  38. package/dist/Card/Card.d.ts.map +1 -1
  39. package/dist/Card/Card.js +23 -4
  40. package/dist/Chat/ChatComposer.d.ts +1 -1
  41. package/dist/Chat/ChatComposer.d.ts.map +1 -1
  42. package/dist/Chat/ChatComposer.js +4 -4
  43. package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
  44. package/dist/Chat/ChatComposerDrawer.js +8 -4
  45. package/dist/Chat/ChatDictationButton.d.ts.map +1 -1
  46. package/dist/Chat/ChatDictationButton.js +7 -0
  47. package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
  48. package/dist/Chat/ChatPastedTextToken.js +3 -9
  49. package/dist/Chat/ChatSendButton.d.ts.map +1 -1
  50. package/dist/Chat/ChatSendButton.js +3 -0
  51. package/dist/Chat/ChatSystemMessage.d.ts.map +1 -1
  52. package/dist/Chat/ChatSystemMessage.js +1 -0
  53. package/dist/Chat/ChatToolCalls.d.ts.map +1 -1
  54. package/dist/Chat/ChatToolCalls.js +8 -0
  55. package/dist/Chat/pastedTextLabel.d.ts +4 -0
  56. package/dist/Chat/pastedTextLabel.d.ts.map +1 -0
  57. package/dist/Chat/pastedTextLabel.js +21 -0
  58. package/dist/Chat/useChatPasteAsToken.d.ts.map +1 -1
  59. package/dist/Chat/useChatPasteAsToken.js +8 -8
  60. package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
  61. package/dist/Chat/useTriggerMenu.js +3 -3
  62. package/dist/CheckboxInput/CheckboxInput.d.ts +2 -1
  63. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  64. package/dist/CheckboxInput/CheckboxInput.js +69 -18
  65. package/dist/Citation/Citation.d.ts.map +1 -1
  66. package/dist/Citation/Citation.js +8 -1
  67. package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
  68. package/dist/CodeBlock/CodeBlock.js +17 -3
  69. package/dist/Collapsible/Collapsible.d.ts.map +1 -1
  70. package/dist/Collapsible/Collapsible.js +2 -0
  71. package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
  72. package/dist/CommandPalette/CommandPaletteItem.js +1 -0
  73. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  74. package/dist/ComplexSelector/ComplexSelector.js +8 -1
  75. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  76. package/dist/ContextMenu/ContextMenu.js +32 -5
  77. package/dist/DateInput/MonthScroller.d.ts.map +1 -1
  78. package/dist/DateInput/MonthScroller.js +1 -0
  79. package/dist/DateInput/PickerWheel.d.ts.map +1 -1
  80. package/dist/DateInput/PickerWheel.js +3 -2
  81. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  82. package/dist/DateInput/TouchDateField.js +2 -1
  83. package/dist/DateInput/Wheel.d.ts.map +1 -1
  84. package/dist/DateInput/Wheel.js +8 -8
  85. package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -1
  86. package/dist/DateInput/usePointerDragScroll.js +5 -2
  87. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  88. package/dist/DateRangeInput/DateRangeInput.js +7 -0
  89. package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
  90. package/dist/DateTimeInput/TouchDateTimeField.js +2 -1
  91. package/dist/DateTimeInput/nativePickerSegmentStyles.d.ts +2 -2
  92. package/dist/Dialog/Dialog.d.ts.map +1 -1
  93. package/dist/Dialog/Dialog.js +104 -18
  94. package/dist/Dialog/DialogContext.d.ts +5 -4
  95. package/dist/Dialog/DialogContext.d.ts.map +1 -1
  96. package/dist/Dialog/DialogHeader.d.ts.map +1 -1
  97. package/dist/Dialog/DialogHeader.js +38 -12
  98. package/dist/Drawer/DrawerHeader.d.ts.map +1 -1
  99. package/dist/Drawer/DrawerHeader.js +23 -8
  100. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  101. package/dist/DropdownMenu/DropdownMenu.js +23 -17
  102. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
  103. package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -3
  104. package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
  105. package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
  106. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
  107. package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -3
  108. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  109. package/dist/DropdownMenu/DropdownMenuSubMenu.js +19 -2
  110. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +6 -3
  111. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -1
  112. package/dist/DropdownMenu/lazyMenuBottomSheet.js +31 -7
  113. package/dist/DropdownMenu/menuRowCorners.stylex.d.ts +24 -0
  114. package/dist/DropdownMenu/menuRowCorners.stylex.d.ts.map +1 -0
  115. package/dist/DropdownMenu/menuRowCorners.stylex.js +29 -0
  116. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  117. package/dist/EmptyState/EmptyState.js +2 -2
  118. package/dist/Field/FieldLabel.d.ts.map +1 -1
  119. package/dist/Field/FieldLabel.js +2 -2
  120. package/dist/Field/inputDisabledFocus.d.ts +4 -0
  121. package/dist/Field/inputDisabledFocus.d.ts.map +1 -1
  122. package/dist/Field/inputDisabledFocus.js +5 -0
  123. package/dist/Field/inputStyles.stylex.d.ts +31 -4
  124. package/dist/Field/inputStyles.stylex.d.ts.map +1 -1
  125. package/dist/Field/inputStyles.stylex.js +30 -5
  126. package/dist/Grid/Grid.d.ts +2 -1
  127. package/dist/Grid/Grid.d.ts.map +1 -1
  128. package/dist/Grid/Grid.js +5 -2
  129. package/dist/Heading/Heading.d.ts +1 -1
  130. package/dist/Heading/Heading.d.ts.map +1 -1
  131. package/dist/Heading/Heading.js +15 -1
  132. package/dist/Icon/Icon.d.ts +1 -1
  133. package/dist/Icon/Icon.d.ts.map +1 -1
  134. package/dist/Icon/Icon.js +32 -2
  135. package/dist/Indicator/CheckboxIndicator.d.ts.map +1 -1
  136. package/dist/Indicator/CheckboxIndicator.js +12 -6
  137. package/dist/Indicator/RadioIndicator.d.ts.map +1 -1
  138. package/dist/Indicator/RadioIndicator.js +18 -4
  139. package/dist/Indicator/indicatorRegistry.d.ts +3 -26
  140. package/dist/Indicator/indicatorRegistry.d.ts.map +1 -1
  141. package/dist/Indicator/indicatorRegistry.js +2 -11
  142. package/dist/Indicator/themeIndicators.d.ts +15 -0
  143. package/dist/Indicator/themeIndicators.d.ts.map +1 -0
  144. package/dist/Indicator/themeIndicators.js +21 -0
  145. package/dist/Indicator/types.d.ts +14 -0
  146. package/dist/Indicator/types.d.ts.map +1 -1
  147. package/dist/Indicator/useThemeIndicator.d.ts +3 -0
  148. package/dist/Indicator/useThemeIndicator.d.ts.map +1 -0
  149. package/dist/Indicator/useThemeIndicator.js +19 -0
  150. package/dist/Item/Item.d.ts +6 -2
  151. package/dist/Item/Item.d.ts.map +1 -1
  152. package/dist/Item/Item.js +30 -2
  153. package/dist/Kbd/Kbd.d.ts.map +1 -1
  154. package/dist/Kbd/Kbd.js +9 -2
  155. package/dist/Layer/layerExitCopy.d.ts.map +1 -1
  156. package/dist/Layer/layerExitCopy.js +1 -1
  157. package/dist/Layer/layerSlideRules.d.ts +23 -15
  158. package/dist/Layer/layerSlideRules.d.ts.map +1 -1
  159. package/dist/Layer/layerSlideRules.js +54 -54
  160. package/dist/Layer/useLayer.d.ts +41 -29
  161. package/dist/Layer/useLayer.d.ts.map +1 -1
  162. package/dist/Layer/useLayer.js +199 -126
  163. package/dist/Layer/useLayerKeyboardClearance.d.ts +5 -5
  164. package/dist/Layer/useLayerKeyboardClearance.d.ts.map +1 -1
  165. package/dist/Layer/useLayerKeyboardClearance.js +5 -5
  166. package/dist/Layout/LayoutContainerContext.d.ts +4 -0
  167. package/dist/Layout/LayoutContainerContext.d.ts.map +1 -0
  168. package/dist/Layout/LayoutContainerContext.js +20 -0
  169. package/dist/Layout/LayoutContainerScope.d.ts +15 -0
  170. package/dist/Layout/LayoutContainerScope.d.ts.map +1 -0
  171. package/dist/Layout/LayoutContainerScope.js +23 -0
  172. package/dist/Layout/LayoutContent.d.ts +2 -1
  173. package/dist/Layout/LayoutContent.d.ts.map +1 -1
  174. package/dist/Layout/LayoutContent.js +7 -2
  175. package/dist/Layout/LayoutFooter.d.ts.map +1 -1
  176. package/dist/Layout/LayoutFooter.js +5 -1
  177. package/dist/Layout/LayoutHeader.d.ts.map +1 -1
  178. package/dist/Layout/LayoutHeader.js +5 -1
  179. package/dist/Layout/containerCorners.stylex.d.ts +15 -7
  180. package/dist/Layout/containerCorners.stylex.d.ts.map +1 -1
  181. package/dist/Layout/containerCorners.stylex.js +16 -7
  182. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  183. package/dist/Lightbox/Lightbox.js +324 -6
  184. package/dist/Link/Link.d.ts.map +1 -1
  185. package/dist/Link/Link.js +1 -1
  186. package/dist/List/List.d.ts.map +1 -1
  187. package/dist/List/List.js +14 -6
  188. package/dist/List/ListContext.d.ts +38 -1
  189. package/dist/List/ListContext.d.ts.map +1 -1
  190. package/dist/List/ListContext.js +50 -2
  191. package/dist/List/ListItem.js +2 -2
  192. package/dist/Markdown/Markdown.d.ts.map +1 -1
  193. package/dist/Markdown/Markdown.js +85 -96
  194. package/dist/Markdown/plugins/HeadingLinksRenderer.d.ts.map +1 -1
  195. package/dist/Markdown/plugins/HeadingLinksRenderer.js +12 -5
  196. package/dist/Markdown/plugins/protocol.js +3 -3
  197. package/dist/MetadataList/MetadataListItem.d.ts.map +1 -1
  198. package/dist/MetadataList/MetadataListItem.js +11 -3
  199. package/dist/MobileNav/MobileNav.d.ts +1 -1
  200. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  201. package/dist/MobileNav/MobileNav.js +6 -3
  202. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  203. package/dist/MultiSelector/MultiSelector.js +33 -9
  204. package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
  205. package/dist/NavMenu/NavHeadingMenu.js +5 -2
  206. package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
  207. package/dist/NavMenu/NavHeadingMenuItem.js +1 -0
  208. package/dist/NavMenu/NavMenuContext.d.ts +7 -0
  209. package/dist/NavMenu/NavMenuContext.d.ts.map +1 -1
  210. package/dist/NavMenu/NavMenuContext.js +9 -0
  211. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  212. package/dist/NumberInput/NumberInput.js +8 -2
  213. package/dist/Outline/Outline.d.ts +7 -3
  214. package/dist/Outline/Outline.d.ts.map +1 -1
  215. package/dist/Outline/Outline.js +11 -3
  216. package/dist/Outline/useScrollSpy.d.ts +1 -1
  217. package/dist/Outline/useScrollSpy.d.ts.map +1 -1
  218. package/dist/Outline/useScrollSpy.js +6 -2
  219. package/dist/OverflowList/OverflowList.d.ts.map +1 -1
  220. package/dist/OverflowList/OverflowList.js +51 -25
  221. package/dist/Pagination/Pagination.d.ts.map +1 -1
  222. package/dist/Pagination/Pagination.js +33 -13
  223. package/dist/Popover/Popover.d.ts.map +1 -1
  224. package/dist/Popover/Popover.js +5 -1
  225. package/dist/Popover/popoverAnchor.d.ts +11 -0
  226. package/dist/Popover/popoverAnchor.d.ts.map +1 -0
  227. package/dist/Popover/popoverAnchor.js +33 -0
  228. package/dist/Popover/usePopover.d.ts +20 -3
  229. package/dist/Popover/usePopover.d.ts.map +1 -1
  230. package/dist/Popover/usePopover.js +110 -10
  231. package/dist/PowerSearch/PowerSearch.d.ts +1 -0
  232. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  233. package/dist/PowerSearch/PowerSearch.js +46 -9
  234. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  235. package/dist/PowerSearch/PowerSearchEditPopover.js +1 -1
  236. package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
  237. package/dist/PowerSearch/PowerSearchFilterEditor.js +7 -1
  238. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  239. package/dist/PowerSearch/PowerSearchToken.js +7 -0
  240. package/dist/PowerSearch/PowerSearchValueEditor.d.ts +2 -4
  241. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  242. package/dist/PowerSearch/PowerSearchValueEditor.js +6 -13
  243. package/dist/ProgressBar/ProgressBar.d.ts +5 -4
  244. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  245. package/dist/ProgressBar/ProgressBar.js +26 -26
  246. package/dist/RadioList/RadioList.d.ts.map +1 -1
  247. package/dist/RadioList/RadioList.js +51 -0
  248. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  249. package/dist/RadioList/RadioListItem.js +1 -1
  250. package/dist/Resizable/ResizeHandle.d.ts +1 -1
  251. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  252. package/dist/Resizable/ResizeHandle.js +1 -1
  253. package/dist/Resizable/resizableModel.d.ts +45 -3
  254. package/dist/Resizable/resizableModel.d.ts.map +1 -1
  255. package/dist/Resizable/resizableModel.js +91 -3
  256. package/dist/Resizable/resizeGesture.d.ts +3 -0
  257. package/dist/Resizable/resizeGesture.d.ts.map +1 -1
  258. package/dist/Resizable/resizeGesture.js +6 -0
  259. package/dist/Resizable/useResizable.d.ts +1 -33
  260. package/dist/Resizable/useResizable.d.ts.map +1 -1
  261. package/dist/Resizable/useResizable.js +8 -72
  262. package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
  263. package/dist/SegmentedControl/SegmentedControlItem.js +1 -0
  264. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts +27 -5
  265. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -1
  266. package/dist/SegmentedControl/useSegmentedTouchTracking.js +70 -8
  267. package/dist/Selector/Selector.d.ts.map +1 -1
  268. package/dist/Selector/Selector.js +34 -14
  269. package/dist/Selector/hooks.d.ts +5 -0
  270. package/dist/Selector/hooks.d.ts.map +1 -1
  271. package/dist/Selector/hooks.js +72 -16
  272. package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
  273. package/dist/Selector/useSelectorPresentation.js +9 -3
  274. package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
  275. package/dist/SideNav/SideNavHeading.js +18 -5
  276. package/dist/Slider/Slider.d.ts.map +1 -1
  277. package/dist/Slider/Slider.js +2 -2
  278. package/dist/Spinner/Spinner.d.ts.map +1 -1
  279. package/dist/Spinner/Spinner.js +47 -33
  280. package/dist/Stepper/Step.d.ts.map +1 -1
  281. package/dist/Stepper/Step.js +21 -12
  282. package/dist/Swipe/useSwipeAction.js +3 -3
  283. package/dist/Switch/Switch.d.ts.map +1 -1
  284. package/dist/Switch/Switch.js +64 -46
  285. package/dist/Switch/useSwitchTouch.d.ts +22 -1
  286. package/dist/Switch/useSwitchTouch.d.ts.map +1 -1
  287. package/dist/Switch/useSwitchTouch.js +54 -3
  288. package/dist/TabList/Tab.d.ts.map +1 -1
  289. package/dist/TabList/Tab.js +3 -3
  290. package/dist/Table/BaseTable.d.ts.map +1 -1
  291. package/dist/Table/BaseTable.js +37 -18
  292. package/dist/Table/Table.d.ts +4 -3
  293. package/dist/Table/Table.d.ts.map +1 -1
  294. package/dist/Table/Table.js +32 -14
  295. package/dist/Table/TableBody.d.ts.map +1 -1
  296. package/dist/Table/TableBody.js +5 -1
  297. package/dist/Table/TableCell.d.ts.map +1 -1
  298. package/dist/Table/TableCell.js +6 -0
  299. package/dist/Table/TableHeaderCell.d.ts +1 -1
  300. package/dist/Table/TableHeaderCell.d.ts.map +1 -1
  301. package/dist/Table/TableHeaderCell.js +42 -9
  302. package/dist/Table/TableRow.d.ts.map +1 -1
  303. package/dist/Table/TableRow.js +9 -1
  304. package/dist/Table/TableRowPlacementContext.d.ts +18 -0
  305. package/dist/Table/TableRowPlacementContext.d.ts.map +1 -0
  306. package/dist/Table/TableRowPlacementContext.js +41 -0
  307. package/dist/Table/TableSelectionToolbar.d.ts.map +1 -1
  308. package/dist/Table/TableSelectionToolbar.js +7 -0
  309. package/dist/Table/columnUtils.d.ts +5 -0
  310. package/dist/Table/columnUtils.d.ts.map +1 -1
  311. package/dist/Table/columnUtils.js +9 -1
  312. package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -1
  313. package/dist/Table/plugins/rowIndex/useTableRowIndex.js +2 -2
  314. package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
  315. package/dist/Table/plugins/sortable/useTableSortable.js +8 -3
  316. package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
  317. package/dist/Table/plugins/sortable/useTableSortableState.js +10 -6
  318. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
  319. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +5 -1
  320. package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -1
  321. package/dist/Table/plugins/tree/useTableTreeData.js +2 -1
  322. package/dist/Table/table.stylex.d.ts +31 -5
  323. package/dist/Table/table.stylex.d.ts.map +1 -1
  324. package/dist/Table/table.stylex.js +33 -5
  325. package/dist/Table/types.d.ts +3 -1
  326. package/dist/Table/types.d.ts.map +1 -1
  327. package/dist/Text/TruncationTooltip.d.ts.map +1 -1
  328. package/dist/Text/TruncationTooltip.js +17 -6
  329. package/dist/Text/text.stylex.d.ts +2 -2
  330. package/dist/Text/useTruncation.d.ts.map +1 -1
  331. package/dist/Text/useTruncation.js +23 -4
  332. package/dist/TextArea/TextArea.d.ts.map +1 -1
  333. package/dist/TextArea/TextArea.js +15 -1
  334. package/dist/TextInput/TextInput.d.ts +9 -3
  335. package/dist/TextInput/TextInput.d.ts.map +1 -1
  336. package/dist/TextInput/TextInput.js +19 -18
  337. package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
  338. package/dist/Thumbnail/Thumbnail.js +13 -4
  339. package/dist/Timer/Timer.d.ts.map +1 -1
  340. package/dist/Timer/Timer.js +10 -7
  341. package/dist/Timestamp/Timestamp.d.ts.map +1 -1
  342. package/dist/Timestamp/Timestamp.js +55 -4
  343. package/dist/Toast/Toast.d.ts +1 -6
  344. package/dist/Toast/Toast.d.ts.map +1 -1
  345. package/dist/Toast/Toast.js +77 -44
  346. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  347. package/dist/Toast/ToastViewport.js +48 -21
  348. package/dist/Toast/types.d.ts +8 -0
  349. package/dist/Toast/types.d.ts.map +1 -1
  350. package/dist/Toast/useToast.d.ts.map +1 -1
  351. package/dist/Toast/useToast.js +14 -7
  352. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  353. package/dist/ToggleButton/ToggleButton.js +2 -1
  354. package/dist/Token/Token.d.ts +1 -1
  355. package/dist/Token/Token.d.ts.map +1 -1
  356. package/dist/Token/Token.js +6 -2
  357. package/dist/Tokenizer/Tokenizer.d.ts +2 -2
  358. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  359. package/dist/Tokenizer/Tokenizer.js +102 -62
  360. package/dist/Toolbar/Toolbar.d.ts.map +1 -1
  361. package/dist/Toolbar/Toolbar.js +33 -5
  362. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  363. package/dist/Tooltip/useTooltip.js +20 -1
  364. package/dist/TopNav/TopNav.d.ts.map +1 -1
  365. package/dist/TopNav/TopNav.js +24 -8
  366. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  367. package/dist/TopNav/TopNavHeading.js +21 -9
  368. package/dist/TopNav/TopNavMegaMenu.js +1 -1
  369. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  370. package/dist/TopNav/TopNavMenu.js +9 -2
  371. package/dist/TopNav/TopNavRenderContext.d.ts +13 -0
  372. package/dist/TopNav/TopNavRenderContext.d.ts.map +1 -1
  373. package/dist/TopNav/TopNavRenderContext.js +24 -9
  374. package/dist/TreeList/TreeList.d.ts.map +1 -1
  375. package/dist/TreeList/TreeList.js +7 -1
  376. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  377. package/dist/TreeList/TreeListItem.js +20 -2
  378. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  379. package/dist/Typeahead/BaseTypeahead.js +2 -1
  380. package/dist/Typeahead/Typeahead.d.ts.map +1 -1
  381. package/dist/Typeahead/Typeahead.js +24 -9
  382. package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
  383. package/dist/Typeahead/TypeaheadItem.js +7 -0
  384. package/dist/astryx.css +211 -56
  385. package/dist/gestures/GestureHost.d.ts +7 -0
  386. package/dist/gestures/GestureHost.d.ts.map +1 -1
  387. package/dist/gestures/GestureHost.js +37 -0
  388. package/dist/hooks/anchoredHint.d.ts.map +1 -1
  389. package/dist/hooks/anchoredHint.js +0 -1
  390. package/dist/hooks/computeOverflow.d.ts.map +1 -1
  391. package/dist/hooks/computeOverflow.js +7 -0
  392. package/dist/hooks/focusableSelector.d.ts +16 -9
  393. package/dist/hooks/focusableSelector.d.ts.map +1 -1
  394. package/dist/hooks/focusableSelector.js +53 -2
  395. package/dist/hooks/scrollEdgeFade.d.ts +34 -0
  396. package/dist/hooks/scrollEdgeFade.d.ts.map +1 -0
  397. package/dist/hooks/scrollEdgeFade.js +173 -0
  398. package/dist/hooks/statusButtonPress.d.ts +15 -0
  399. package/dist/hooks/statusButtonPress.d.ts.map +1 -0
  400. package/dist/hooks/statusButtonPress.js +19 -0
  401. package/dist/hooks/useAnnounce.d.ts.map +1 -1
  402. package/dist/hooks/useAnnounce.js +2 -1
  403. package/dist/hooks/useFocusTrap.d.ts +26 -16
  404. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  405. package/dist/hooks/useFocusTrap.js +75 -112
  406. package/dist/hooks/useGroupPressTracking.d.ts +1 -1
  407. package/dist/hooks/useGroupPressTracking.js +1 -1
  408. package/dist/hooks/useOverflow.d.ts +25 -2
  409. package/dist/hooks/useOverflow.d.ts.map +1 -1
  410. package/dist/hooks/useOverflow.js +137 -8
  411. package/dist/hooks/useResolvedRequired.d.ts +27 -0
  412. package/dist/hooks/useResolvedRequired.d.ts.map +1 -1
  413. package/dist/hooks/useResolvedRequired.js +30 -1
  414. package/dist/hooks/useTreeFocus.d.ts.map +1 -1
  415. package/dist/hooks/useTreeFocus.js +4 -2
  416. package/dist/hooks/useTypeahead.d.ts.map +1 -1
  417. package/dist/hooks/useTypeahead.js +8 -8
  418. package/dist/i18n/InternationalizationContext.d.ts +13 -6
  419. package/dist/i18n/InternationalizationContext.d.ts.map +1 -1
  420. package/dist/i18n/InternationalizationContext.js +11 -6
  421. package/dist/i18n/InternationalizationProvider.d.ts.map +1 -1
  422. package/dist/i18n/InternationalizationProvider.js +7 -0
  423. package/dist/i18n/defaultTranslator.d.ts +17 -0
  424. package/dist/i18n/defaultTranslator.d.ts.map +1 -0
  425. package/dist/i18n/defaultTranslator.js +18 -0
  426. package/dist/i18n/firstStrongDirection.d.ts +3 -2
  427. package/dist/i18n/firstStrongDirection.d.ts.map +1 -1
  428. package/dist/i18n/firstStrongDirection.js +50 -12
  429. package/dist/i18n/generated-english/Chat/ChatPastedTextToken.generated.d.ts.map +1 -1
  430. package/dist/i18n/generated-english/Chat/ChatPastedTextToken.generated.js +1 -2
  431. package/dist/i18n/generated-english/Chat/pastedTextLabel.generated.d.ts +8 -0
  432. package/dist/i18n/generated-english/Chat/pastedTextLabel.generated.d.ts.map +1 -0
  433. package/dist/i18n/generated-english/Chat/pastedTextLabel.generated.js +12 -0
  434. package/dist/i18n/generated-english/Chat/useTriggerMenu.generated.d.ts.map +1 -1
  435. package/dist/i18n/generated-english/Chat/useTriggerMenu.generated.js +1 -0
  436. package/dist/i18n/generated-english/CodeBlock/CodeBlock.generated.d.ts.map +1 -1
  437. package/dist/i18n/generated-english/CodeBlock/CodeBlock.generated.js +2 -1
  438. package/dist/i18n/generated-english/Markdown/plugins/HeadingLinksRenderer.generated.d.ts.map +1 -1
  439. package/dist/i18n/generated-english/Markdown/plugins/HeadingLinksRenderer.generated.js +2 -1
  440. package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.d.ts.map +1 -1
  441. package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.js +1 -0
  442. package/dist/i18n/generated-english/Slider/Slider.generated.d.ts.map +1 -1
  443. package/dist/i18n/generated-english/Slider/Slider.generated.js +2 -1
  444. package/dist/i18n/generated-english/TextArea/TextArea.generated.d.ts.map +1 -1
  445. package/dist/i18n/generated-english/TextArea/TextArea.generated.js +1 -0
  446. package/dist/i18n/generated-english/TextInput/TextInput.generated.d.ts.map +1 -1
  447. package/dist/i18n/generated-english/TextInput/TextInput.generated.js +1 -0
  448. package/dist/i18n/generated-english/Timestamp/Timestamp.generated.d.ts.map +1 -1
  449. package/dist/i18n/generated-english/Timestamp/Timestamp.generated.js +2 -1
  450. package/dist/i18n/generated-english/Tokenizer/Tokenizer.generated.d.ts.map +1 -1
  451. package/dist/i18n/generated-english/Tokenizer/Tokenizer.generated.js +1 -0
  452. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  453. package/dist/i18n/generated-locales/en.generated.js +9 -0
  454. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  455. package/dist/i18n/generated-locales/pseudo.generated.js +9 -0
  456. package/dist/i18n/publicContext.d.ts.map +1 -1
  457. package/dist/i18n/publicContext.js +4 -2
  458. package/dist/i18n/translatingContext.d.ts +2 -0
  459. package/dist/i18n/translatingContext.d.ts.map +1 -0
  460. package/dist/i18n/translatingContext.js +25 -0
  461. package/dist/i18n/useComponentTranslator.d.ts.map +1 -1
  462. package/dist/i18n/useComponentTranslator.js +3 -2
  463. package/dist/i18n/useListFormatter.d.ts.map +1 -1
  464. package/dist/i18n/useListFormatter.js +3 -2
  465. package/dist/i18n/useTranslator.d.ts.map +1 -1
  466. package/dist/i18n/useTranslator.js +3 -2
  467. package/dist/internal/touch.d.ts +2 -0
  468. package/dist/internal/touch.d.ts.map +1 -1
  469. package/dist/internal/touch.js +5 -1
  470. package/dist/keyboard/keyboardHeight.d.ts +34 -3
  471. package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
  472. package/dist/keyboard/keyboardHeight.js +101 -24
  473. package/dist/keyboard/keyboardTarget.d.ts +19 -16
  474. package/dist/keyboard/keyboardTarget.d.ts.map +1 -1
  475. package/dist/keyboard/keyboardTarget.js +529 -72
  476. package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -1
  477. package/dist/keyboard/useMobileKeyboard.js +1 -8
  478. package/dist/palette/color.d.ts +23 -0
  479. package/dist/palette/color.d.ts.map +1 -0
  480. package/dist/palette/color.js +126 -0
  481. package/dist/palette/generator.d.ts +69 -0
  482. package/dist/palette/generator.d.ts.map +1 -0
  483. package/dist/palette/generator.js +778 -0
  484. package/dist/palette/index.d.ts +12 -0
  485. package/dist/palette/index.d.ts.map +1 -0
  486. package/dist/palette/index.js +13 -0
  487. package/dist/palette/mapping.d.ts +319 -0
  488. package/dist/palette/mapping.d.ts.map +1 -0
  489. package/dist/palette/mapping.js +1312 -0
  490. package/dist/palette/themePalette.d.ts +20 -0
  491. package/dist/palette/themePalette.d.ts.map +1 -0
  492. package/dist/palette/themePalette.js +145 -0
  493. package/dist/palette/types.d.ts +178 -0
  494. package/dist/palette/types.d.ts.map +1 -0
  495. package/dist/palette/types.js +1 -0
  496. package/dist/privateAttributes/mediaDarkPage.d.ts +5 -0
  497. package/dist/privateAttributes/mediaDarkPage.d.ts.map +1 -0
  498. package/dist/privateAttributes/mediaDarkPage.js +27 -0
  499. package/dist/privateAttributes/pressGroupItem.stylex.d.ts +2 -1
  500. package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +1 -1
  501. package/dist/privateAttributes/pressGroupItem.stylex.js +2 -1
  502. package/dist/privateAttributes/scheme.d.ts +10 -0
  503. package/dist/privateAttributes/scheme.d.ts.map +1 -0
  504. package/dist/privateAttributes/scheme.js +34 -0
  505. package/dist/privateAttributes/travelling.stylex.d.ts.map +1 -1
  506. package/dist/privateAttributes/travelling.stylex.js +2 -2
  507. package/dist/theme/MediaDarkPage.d.ts +18 -0
  508. package/dist/theme/MediaDarkPage.d.ts.map +1 -0
  509. package/dist/theme/MediaDarkPage.js +35 -0
  510. package/dist/theme/MediaTheme.d.ts.map +1 -1
  511. package/dist/theme/MediaTheme.js +9 -1
  512. package/dist/theme/Theme.d.ts.map +1 -1
  513. package/dist/theme/Theme.js +99 -31
  514. package/dist/theme/defineTheme.d.ts +31 -6
  515. package/dist/theme/defineTheme.d.ts.map +1 -1
  516. package/dist/theme/defineTheme.js +65 -29
  517. package/dist/theme/derivedVarRegistry.d.ts +19 -0
  518. package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
  519. package/dist/theme/derivedVarRegistry.js +49 -4
  520. package/dist/theme/expandRadiusScale.d.ts +1 -2
  521. package/dist/theme/expandRadiusScale.d.ts.map +1 -1
  522. package/dist/theme/expandRadiusScale.js +1 -5
  523. package/dist/theme/generateThemeRules.d.ts +10 -3
  524. package/dist/theme/generateThemeRules.d.ts.map +1 -1
  525. package/dist/theme/generateThemeRules.js +310 -207
  526. package/dist/theme/index.d.ts +2 -1
  527. package/dist/theme/index.d.ts.map +1 -1
  528. package/dist/theme/index.js +2 -1
  529. package/dist/theme/invertedSurfaceSide.d.ts +17 -0
  530. package/dist/theme/invertedSurfaceSide.d.ts.map +1 -0
  531. package/dist/theme/invertedSurfaceSide.js +47 -0
  532. package/dist/theme/resolveThemeValues.d.ts +5 -2
  533. package/dist/theme/resolveThemeValues.d.ts.map +1 -1
  534. package/dist/theme/resolveThemeValues.js +7 -1
  535. package/dist/theme/statusRoleDefaults.d.ts +43 -0
  536. package/dist/theme/statusRoleDefaults.d.ts.map +1 -0
  537. package/dist/theme/statusRoleDefaults.js +196 -0
  538. package/dist/theme/statusRoleDerivation.d.ts +4 -0
  539. package/dist/theme/statusRoleDerivation.d.ts.map +1 -1
  540. package/dist/theme/statusRoleDerivation.js +3 -1
  541. package/dist/theme/syntax/SyntaxTheme.d.ts.map +1 -1
  542. package/dist/theme/syntax/SyntaxTheme.js +7 -0
  543. package/dist/theme/themeAdaptations.d.ts +24 -1
  544. package/dist/theme/themeAdaptations.d.ts.map +1 -1
  545. package/dist/theme/themeAdaptations.js +48 -5
  546. package/dist/theme/tokenDefaults.d.ts +3 -0
  547. package/dist/theme/tokenDefaults.d.ts.map +1 -0
  548. package/dist/theme/tokenDefaults.js +30 -0
  549. package/dist/theme/tokenValues.d.ts +26 -0
  550. package/dist/theme/tokenValues.d.ts.map +1 -0
  551. package/dist/theme/tokenValues.js +180 -0
  552. package/dist/theme/tokens.d.ts +3 -2
  553. package/dist/theme/tokens.d.ts.map +1 -1
  554. package/dist/theme/tokens.js +7 -161
  555. package/dist/theme/tokens.stylex.d.ts +4 -4
  556. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  557. package/dist/theme/tokens.stylex.js +7 -5
  558. package/dist/theme/useTheme.d.ts +40 -3
  559. package/dist/theme/useTheme.d.ts.map +1 -1
  560. package/dist/theme/useTheme.js +137 -32
  561. package/dist/utils/devWarning.d.ts +17 -0
  562. package/dist/utils/devWarning.d.ts.map +1 -1
  563. package/dist/utils/devWarning.js +20 -0
  564. package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
  565. package/dist/utils/focusOutline.stylex.js +7 -4
  566. package/dist/utils/focusReturn.d.ts +110 -0
  567. package/dist/utils/focusReturn.d.ts.map +1 -1
  568. package/dist/utils/focusReturn.js +418 -12
  569. package/dist/utils/hitArea.d.ts +28 -0
  570. package/dist/utils/hitArea.d.ts.map +1 -1
  571. package/dist/utils/hitArea.js +52 -18
  572. package/dist/utils/inputStream.d.ts +27 -0
  573. package/dist/utils/inputStream.d.ts.map +1 -1
  574. package/dist/utils/inputStream.js +72 -5
  575. package/dist/utils/nodeType.d.ts +2 -0
  576. package/dist/utils/nodeType.d.ts.map +1 -1
  577. package/dist/utils/nodeType.js +10 -0
  578. package/dist/utils/timeFormat.d.ts +14 -4
  579. package/dist/utils/timeFormat.d.ts.map +1 -1
  580. package/dist/utils/timeFormat.js +42 -4
  581. package/dist/utils/touchPresentation.d.ts +2 -2
  582. package/dist/utils/touchPresentation.d.ts.map +1 -1
  583. package/dist/utils/touchPresentation.js +10 -7
  584. package/dist/utils/touchPresentation.stylex.d.ts +4 -3
  585. package/dist/utils/touchPresentation.stylex.d.ts.map +1 -1
  586. package/dist/utils/touchPresentation.stylex.js +3 -3
  587. package/dist/utils/touchQueries.d.ts +3 -2
  588. package/dist/utils/touchQueries.d.ts.map +1 -1
  589. package/dist/utils/touchQueries.js +3 -2
  590. package/dist/utils/typeaheadMatch.d.ts +13 -0
  591. package/dist/utils/typeaheadMatch.d.ts.map +1 -1
  592. package/dist/utils/typeaheadMatch.js +15 -1
  593. package/dist/virtualization/useInlineListWindow.d.ts.map +1 -1
  594. package/dist/virtualization/useInlineListWindow.js +38 -22
  595. package/locales/en.json +36 -0
  596. package/locales/pseudo.json +27 -0
  597. package/package.json +10 -5
  598. package/scripts/agent-doc-state.mjs +71 -4
  599. package/src/AlertDialog/AlertDialog.doc.mjs +5 -1
  600. package/src/AlertDialog/AlertDialog.tsx +34 -7
  601. package/src/AppShell/AppShell.doc.mjs +22 -0
  602. package/src/AppShell/AppShell.tsx +112 -65
  603. package/src/AppShell/unreadWidthPoint.ts +162 -0
  604. package/src/AvatarGroup/AvatarGroupOverflow.tsx +6 -1
  605. package/src/Badge/Badge.tsx +5 -2
  606. package/src/Banner/Banner.doc.mjs +15 -0
  607. package/src/Banner/Banner.tsx +56 -45
  608. package/src/BottomSheet/BottomSheet.doc.mjs +6 -3
  609. package/src/BottomSheet/BottomSheet.tsx +3 -0
  610. package/src/BottomSheet/BottomSheetPanel.tsx +15 -7
  611. package/src/BottomSheet/BottomSheetSwitcher.tsx +73 -1
  612. package/src/BottomSheet/BottomSheetSwitcherContext.ts +5 -0
  613. package/src/BottomSheet/bottomSheetStack.ts +6 -14
  614. package/src/Breadcrumbs/BreadcrumbItem.tsx +14 -1
  615. package/src/Button/Button.doc.mjs +6 -0
  616. package/src/Button/Button.tsx +6 -0
  617. package/src/Calendar/Calendar.doc.mjs +16 -0
  618. package/src/Calendar/Calendar.tsx +32 -20
  619. package/src/Calendar/styles.ts +12 -3
  620. package/src/Card/Card.doc.mjs +2 -2
  621. package/src/Card/Card.tsx +22 -3
  622. package/src/Chat/Chat.doc.mjs +1 -1
  623. package/src/Chat/ChatComposer.doc.mjs +3 -3
  624. package/src/Chat/ChatComposer.tsx +11 -5
  625. package/src/Chat/ChatComposerDrawer.tsx +11 -7
  626. package/src/Chat/ChatDictationButton.tsx +12 -0
  627. package/src/Chat/ChatMessageBubble.tsx +2 -2
  628. package/src/Chat/ChatPastedTextToken.tsx +3 -9
  629. package/src/Chat/ChatSendButton.tsx +5 -0
  630. package/src/Chat/ChatSystemMessage.tsx +1 -0
  631. package/src/Chat/ChatToolCalls.tsx +16 -0
  632. package/src/Chat/pastedTextLabel.ts +23 -0
  633. package/src/Chat/useChatPasteAsToken.ts +9 -8
  634. package/src/Chat/useTriggerMenu.tsx +4 -1
  635. package/src/CheckboxInput/CheckboxInput.doc.mjs +20 -0
  636. package/src/CheckboxInput/CheckboxInput.tsx +83 -26
  637. package/src/CheckboxList/CheckboxList.doc.mjs +15 -0
  638. package/src/CheckboxList/CheckboxListItem.doc.mjs +3 -3
  639. package/src/Citation/Citation.tsx +16 -1
  640. package/src/CodeBlock/CodeBlock.tsx +29 -2
  641. package/src/Collapsible/Collapsible.tsx +2 -0
  642. package/src/CommandPalette/CommandPaletteItem.tsx +1 -0
  643. package/src/ComplexSelector/ComplexSelector.doc.mjs +30 -2
  644. package/src/ComplexSelector/ComplexSelector.tsx +19 -1
  645. package/src/ContextMenu/ContextMenu.doc.mjs +5 -1
  646. package/src/ContextMenu/ContextMenu.tsx +44 -5
  647. package/src/ContextMenu/ContextMenuItem.doc.mjs +55 -5
  648. package/src/DateInput/MonthScroller.tsx +1 -0
  649. package/src/DateInput/PickerWheel.tsx +1 -0
  650. package/src/DateInput/TouchDateField.tsx +2 -0
  651. package/src/DateInput/Wheel.tsx +1 -0
  652. package/src/DateInput/usePointerDragScroll.ts +6 -2
  653. package/src/DateRangeInput/DateRangeInput.tsx +16 -0
  654. package/src/DateTimeInput/TouchDateTimeField.tsx +2 -0
  655. package/src/Dialog/Dialog.doc.mjs +11 -1
  656. package/src/Dialog/Dialog.tsx +116 -19
  657. package/src/Dialog/DialogContext.ts +5 -4
  658. package/src/Dialog/DialogHeader.tsx +50 -12
  659. package/src/Drawer/DrawerHeader.tsx +31 -6
  660. package/src/DropdownMenu/DropdownMenu.doc.mjs +20 -1
  661. package/src/DropdownMenu/DropdownMenu.tsx +29 -22
  662. package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +4 -4
  663. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +3 -2
  664. package/src/DropdownMenu/DropdownMenuItem.doc.mjs +5 -5
  665. package/src/DropdownMenu/DropdownMenuItem.tsx +3 -1
  666. package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +4 -4
  667. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +3 -2
  668. package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +3 -3
  669. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +23 -1
  670. package/src/DropdownMenu/lazyMenuBottomSheet.ts +37 -9
  671. package/src/DropdownMenu/menuRowCorners.stylex.ts +40 -0
  672. package/src/EmptyState/EmptyState.tsx +2 -0
  673. package/src/Field/Field.doc.mjs +1 -1
  674. package/src/Field/FieldLabel.doc.mjs +3 -3
  675. package/src/Field/FieldLabel.tsx +9 -2
  676. package/src/Field/inputDisabledFocus.ts +18 -0
  677. package/src/Field/inputStyles.stylex.ts +52 -1
  678. package/src/Grid/Grid.doc.mjs +6 -3
  679. package/src/Grid/Grid.tsx +5 -2
  680. package/src/Heading/Heading.tsx +24 -1
  681. package/src/Icon/Icon.doc.mjs +1 -1
  682. package/src/Icon/Icon.tsx +40 -2
  683. package/src/Indicator/CheckboxIndicator.tsx +11 -6
  684. package/src/Indicator/Indicator.doc.mjs +1 -1
  685. package/src/Indicator/RadioIndicator.tsx +31 -4
  686. package/src/Indicator/indicatorRegistry.ts +7 -23
  687. package/src/Indicator/themeIndicators.ts +29 -0
  688. package/src/Indicator/types.ts +14 -0
  689. package/src/Indicator/useThemeIndicator.ts +24 -0
  690. package/src/Item/Item.doc.mjs +3 -3
  691. package/src/Item/Item.tsx +48 -7
  692. package/src/Kbd/Kbd.doc.mjs +6 -2
  693. package/src/Kbd/Kbd.tsx +16 -1
  694. package/src/Layer/layerExitCopy.ts +0 -1
  695. package/src/Layer/layerSlideRules.ts +62 -74
  696. package/src/Layer/useLayer.doc.mjs +2 -2
  697. package/src/Layer/useLayer.tsx +293 -137
  698. package/src/Layer/useLayerKeyboardClearance.ts +9 -12
  699. package/src/Layout/Layout.doc.mjs +3 -3
  700. package/src/Layout/LayoutContainerContext.ts +27 -0
  701. package/src/Layout/LayoutContainerScope.tsx +32 -0
  702. package/src/Layout/LayoutContent.tsx +5 -2
  703. package/src/Layout/LayoutFooter.tsx +3 -1
  704. package/src/Layout/LayoutHeader.tsx +3 -1
  705. package/src/Layout/containerCorners.stylex.ts +44 -7
  706. package/src/Lightbox/Lightbox.tsx +460 -8
  707. package/src/Link/Link.doc.mjs +18 -0
  708. package/src/Link/Link.tsx +3 -1
  709. package/src/List/List.tsx +14 -2
  710. package/src/List/ListContext.tsx +60 -1
  711. package/src/List/ListItem.doc.mjs +11 -9
  712. package/src/List/ListItem.tsx +4 -4
  713. package/src/Markdown/Markdown.doc.mjs +1 -1
  714. package/src/Markdown/Markdown.tsx +189 -190
  715. package/src/Markdown/plugins/HeadingLinksRenderer.tsx +14 -4
  716. package/src/Markdown/plugins/protocol.ts +3 -3
  717. package/src/MetadataList/MetadataListItem.tsx +18 -3
  718. package/src/MobileNav/MobileNav.doc.mjs +134 -52
  719. package/src/MobileNav/MobileNav.tsx +13 -9
  720. package/src/MultiSelector/MultiSelector.doc.mjs +2 -2
  721. package/src/MultiSelector/MultiSelector.tsx +51 -8
  722. package/src/NavMenu/NavHeadingMenu.tsx +5 -1
  723. package/src/NavMenu/NavHeadingMenuItem.tsx +1 -0
  724. package/src/NavMenu/NavMenu.doc.mjs +105 -2
  725. package/src/NavMenu/NavMenuContext.tsx +13 -0
  726. package/src/NumberInput/NumberInput.doc.mjs +12 -10
  727. package/src/NumberInput/NumberInput.tsx +19 -11
  728. package/src/Outline/Outline.doc.mjs +26 -8
  729. package/src/Outline/Outline.tsx +35 -5
  730. package/src/Outline/useScrollSpy.ts +8 -3
  731. package/src/OverflowList/OverflowList.doc.mjs +15 -0
  732. package/src/OverflowList/OverflowList.tsx +62 -26
  733. package/src/Pagination/Pagination.doc.mjs +12 -0
  734. package/src/Pagination/Pagination.tsx +40 -6
  735. package/src/Popover/Popover.doc.mjs +10 -0
  736. package/src/Popover/Popover.tsx +8 -4
  737. package/src/Popover/popoverAnchor.ts +47 -0
  738. package/src/Popover/usePopover.doc.mjs +16 -2
  739. package/src/Popover/usePopover.tsx +152 -16
  740. package/src/PowerSearch/PowerSearch.doc.mjs +8 -8
  741. package/src/PowerSearch/PowerSearch.tsx +65 -12
  742. package/src/PowerSearch/PowerSearchEditPopover.tsx +1 -0
  743. package/src/PowerSearch/PowerSearchFilterEditor.tsx +12 -0
  744. package/src/PowerSearch/PowerSearchToken.tsx +12 -0
  745. package/src/PowerSearch/PowerSearchValueEditor.tsx +14 -19
  746. package/src/ProgressBar/ProgressBar.doc.mjs +2 -2
  747. package/src/ProgressBar/ProgressBar.tsx +44 -30
  748. package/src/RadioList/RadioList.tsx +63 -0
  749. package/src/RadioList/RadioListItem.tsx +4 -1
  750. package/src/Resizable/ResizeHandle.tsx +2 -3
  751. package/src/Resizable/resizableModel.ts +105 -3
  752. package/src/Resizable/resizeGesture.ts +14 -0
  753. package/src/Resizable/useResizable.ts +14 -75
  754. package/src/SegmentedControl/SegmentedControlItem.tsx +1 -0
  755. package/src/SegmentedControl/useSegmentedTouchTracking.ts +76 -12
  756. package/src/Selector/Selector.doc.mjs +34 -7
  757. package/src/Selector/Selector.tsx +55 -25
  758. package/src/Selector/SelectorOption.doc.mjs +5 -5
  759. package/src/Selector/hooks.ts +92 -17
  760. package/src/Selector/useSelectorPresentation.ts +18 -3
  761. package/src/SideNav/SideNavHeading.tsx +15 -4
  762. package/src/SideNav/SideNavItem.doc.mjs +10 -10
  763. package/src/Slider/Slider.tsx +4 -1
  764. package/src/Spinner/Spinner.tsx +56 -41
  765. package/src/Stepper/Step.tsx +18 -3
  766. package/src/Stepper/Stepper.doc.mjs +14 -2
  767. package/src/Swipe/useSwipeAction.ts +3 -3
  768. package/src/Switch/Switch.doc.mjs +61 -5
  769. package/src/Switch/Switch.tsx +72 -35
  770. package/src/Switch/useSwitchTouch.ts +68 -3
  771. package/src/TabList/Tab.tsx +6 -0
  772. package/src/Table/BaseTable.tsx +73 -35
  773. package/src/Table/Table.doc.mjs +109 -5
  774. package/src/Table/Table.tsx +42 -17
  775. package/src/Table/TableBody.tsx +10 -1
  776. package/src/Table/TableCell.tsx +6 -0
  777. package/src/Table/TableHeaderCell.tsx +52 -7
  778. package/src/Table/TableRow.tsx +8 -1
  779. package/src/Table/TableRowPlacementContext.ts +58 -0
  780. package/src/Table/TableSelectionToolbar.tsx +12 -0
  781. package/src/Table/columnUtils.ts +9 -1
  782. package/src/Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs +1 -1
  783. package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +1 -0
  784. package/src/Table/plugins/sortable/useTableSortable.tsx +15 -2
  785. package/src/Table/plugins/sortable/useTableSortableState.doc.mjs +5 -5
  786. package/src/Table/plugins/sortable/useTableSortableState.tsx +15 -8
  787. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +8 -0
  788. package/src/Table/plugins/tree/useTableTreeData.tsx +2 -4
  789. package/src/Table/table.stylex.ts +44 -5
  790. package/src/Table/types.ts +3 -1
  791. package/src/Table/useTableColumnResize.doc.mjs +3 -3
  792. package/src/Table/useTableColumnSettings.doc.mjs +3 -3
  793. package/src/Table/useTableFilterState.doc.mjs +6 -3
  794. package/src/Table/useTableFiltering.doc.mjs +71 -4
  795. package/src/Table/useTableInfiniteScroll.doc.mjs +2 -2
  796. package/src/Table/useTablePagination.doc.mjs +24 -3
  797. package/src/Table/useTableSelection.doc.mjs +30 -6
  798. package/src/Table/useTableSelectionState.doc.mjs +30 -2
  799. package/src/Table/useTableSortable.doc.mjs +104 -17
  800. package/src/Table/useTableStickyColumns.doc.mjs +3 -3
  801. package/src/Text/Heading.doc.mjs +2 -2
  802. package/src/Text/Text.doc.mjs +1 -1
  803. package/src/Text/TruncationTooltip.tsx +18 -11
  804. package/src/Text/useTruncation.ts +20 -4
  805. package/src/TextArea/TextArea.doc.mjs +5 -5
  806. package/src/TextArea/TextArea.tsx +20 -1
  807. package/src/TextInput/TextInput.doc.mjs +5 -5
  808. package/src/TextInput/TextInput.tsx +23 -18
  809. package/src/Thumbnail/Thumbnail.tsx +2 -1
  810. package/src/Timer/Timer.tsx +21 -6
  811. package/src/Timestamp/Timestamp.tsx +67 -4
  812. package/src/Toast/Toast.doc.mjs +15 -5
  813. package/src/Toast/Toast.tsx +83 -62
  814. package/src/Toast/ToastViewport.tsx +62 -23
  815. package/src/Toast/types.ts +8 -0
  816. package/src/Toast/useToast.doc.mjs +80 -15
  817. package/src/Toast/useToast.tsx +18 -7
  818. package/src/ToggleButton/ToggleButton.doc.mjs +1 -1
  819. package/src/ToggleButton/ToggleButton.tsx +1 -0
  820. package/src/Token/Token.tsx +5 -1
  821. package/src/Tokenizer/Tokenizer.doc.mjs +15 -3
  822. package/src/Tokenizer/Tokenizer.tsx +130 -75
  823. package/src/Toolbar/Toolbar.tsx +55 -4
  824. package/src/Tooltip/useTooltip.tsx +26 -0
  825. package/src/TopNav/TopNav.doc.mjs +1 -1
  826. package/src/TopNav/TopNav.tsx +13 -3
  827. package/src/TopNav/TopNavHeading.tsx +22 -9
  828. package/src/TopNav/TopNavMegaMenu.tsx +4 -4
  829. package/src/TopNav/TopNavMenu.tsx +13 -0
  830. package/src/TopNav/TopNavRenderContext.ts +30 -9
  831. package/src/TreeList/TreeList.tsx +12 -0
  832. package/src/TreeList/TreeListItem.tsx +26 -5
  833. package/src/Typeahead/BaseTypeahead.doc.mjs +6 -0
  834. package/src/Typeahead/BaseTypeahead.tsx +2 -0
  835. package/src/Typeahead/Typeahead.doc.mjs +15 -2
  836. package/src/Typeahead/Typeahead.tsx +37 -13
  837. package/src/Typeahead/TypeaheadItem.tsx +12 -0
  838. package/src/gestures/GestureHost.ts +34 -0
  839. package/src/gestures/README.md +9 -6
  840. package/src/hooks/anchoredHint.tsx +1 -2
  841. package/src/hooks/computeOverflow.ts +10 -0
  842. package/src/hooks/focusableSelector.ts +59 -2
  843. package/src/hooks/scrollEdgeFade.ts +129 -0
  844. package/src/hooks/statusButtonPress.ts +26 -0
  845. package/src/hooks/useAnnounce.ts +2 -1
  846. package/src/hooks/useFocusTrap.ts +110 -141
  847. package/src/hooks/useGroupPressTracking.ts +1 -1
  848. package/src/hooks/useOverflow.ts +227 -13
  849. package/src/hooks/useResolvedRequired.ts +50 -1
  850. package/src/hooks/useTreeFocus.ts +8 -4
  851. package/src/hooks/useTypeahead.ts +12 -10
  852. package/src/i18n/InternationalizationContext.ts +16 -7
  853. package/src/i18n/InternationalizationProvider.doc.mjs +1 -1
  854. package/src/i18n/InternationalizationProvider.tsx +12 -0
  855. package/src/i18n/defaultTranslator.ts +25 -0
  856. package/src/i18n/firstStrongDirection.ts +54 -13
  857. package/src/i18n/generated-english/Chat/ChatPastedTextToken.generated.ts +1 -2
  858. package/src/i18n/generated-english/Chat/pastedTextLabel.generated.ts +13 -0
  859. package/src/i18n/generated-english/Chat/useTriggerMenu.generated.ts +1 -0
  860. package/src/i18n/generated-english/CodeBlock/CodeBlock.generated.ts +2 -1
  861. package/src/i18n/generated-english/Markdown/plugins/HeadingLinksRenderer.generated.ts +2 -1
  862. package/src/i18n/generated-english/MultiSelector/MultiSelector.generated.ts +1 -0
  863. package/src/i18n/generated-english/Slider/Slider.generated.ts +2 -1
  864. package/src/i18n/generated-english/TextArea/TextArea.generated.ts +1 -0
  865. package/src/i18n/generated-english/TextInput/TextInput.generated.ts +1 -0
  866. package/src/i18n/generated-english/Timestamp/Timestamp.generated.ts +2 -1
  867. package/src/i18n/generated-english/Tokenizer/Tokenizer.generated.ts +1 -0
  868. package/src/i18n/generated-locales/en.generated.ts +11 -0
  869. package/src/i18n/generated-locales/pseudo.generated.ts +11 -0
  870. package/src/i18n/publicContext.ts +4 -2
  871. package/src/i18n/translatingContext.ts +28 -0
  872. package/src/i18n/useComponentTranslator.ts +3 -2
  873. package/src/i18n/useListFormatter.ts +3 -2
  874. package/src/i18n/useTranslator.ts +3 -2
  875. package/src/internal/touch.ts +7 -0
  876. package/src/keyboard/README.md +58 -16
  877. package/src/keyboard/keyboardHeight.ts +138 -26
  878. package/src/keyboard/keyboardTarget.ts +667 -71
  879. package/src/keyboard/useMobileKeyboard.ts +1 -7
  880. package/src/palette/color.ts +205 -0
  881. package/src/palette/generator.ts +1134 -0
  882. package/src/palette/index.ts +35 -0
  883. package/src/palette/mapping.ts +1630 -0
  884. package/src/palette/themePalette.ts +175 -0
  885. package/src/palette/types.ts +194 -0
  886. package/src/privateAttributes/mediaDarkPage.ts +27 -0
  887. package/src/privateAttributes/pressGroupItem.stylex.ts +2 -1
  888. package/src/privateAttributes/scheme.ts +37 -0
  889. package/src/privateAttributes/travelling.stylex.ts +6 -4
  890. package/src/reset.css +1 -1
  891. package/src/theme/MediaDarkPage.tsx +41 -0
  892. package/src/theme/MediaTheme.tsx +8 -1
  893. package/src/theme/Theme.doc.mjs +4 -4
  894. package/src/theme/Theme.tsx +140 -35
  895. package/src/theme/defineTheme.ts +103 -40
  896. package/src/theme/derivedVarRegistry.ts +61 -4
  897. package/src/theme/expandRadiusScale.ts +1 -5
  898. package/src/theme/generateThemeRules.ts +398 -342
  899. package/src/theme/index.ts +2 -4
  900. package/src/theme/invertedSurfaceSide.ts +65 -0
  901. package/src/theme/resolveThemeValues.ts +8 -2
  902. package/src/theme/statusRoleDefaults.ts +330 -0
  903. package/src/theme/statusRoleDerivation.ts +2 -1
  904. package/src/theme/syntax/SyntaxTheme.tsx +12 -0
  905. package/src/theme/themeAdaptations.ts +53 -5
  906. package/src/theme/tokenDefaults.ts +44 -0
  907. package/src/theme/tokenValues.ts +193 -0
  908. package/src/theme/tokens.stylex.ts +7 -5
  909. package/src/theme/tokens.ts +14 -176
  910. package/src/theme/useTheme.ts +164 -35
  911. package/src/utils/devWarning.ts +24 -0
  912. package/src/utils/focusOutline.stylex.ts +7 -4
  913. package/src/utils/focusReturn.ts +578 -16
  914. package/src/utils/hitArea.ts +70 -33
  915. package/src/utils/inputStream.ts +81 -5
  916. package/src/utils/nodeType.ts +10 -0
  917. package/src/utils/timeFormat.ts +54 -4
  918. package/src/utils/touchPresentation.stylex.ts +7 -6
  919. package/src/utils/touchPresentation.ts +10 -7
  920. package/src/utils/touchQueries.ts +3 -2
  921. package/src/utils/typeaheadMatch.ts +20 -1
  922. package/src/virtualization/useInlineListWindow.ts +57 -33
@@ -0,0 +1,778 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file generator.ts
5
+ * @input A tonal palette request: families with seeds, anchors, vibrancy,
6
+ * neutral profile, mode strategy, stops, recipe
7
+ * @output Deterministic candidate palettes with per-ramp and cross-family
8
+ * diagnostics
9
+ * @position The one tonal palette engine. `defineTheme({palette})` and the
10
+ * CLI palette command both run it; the CLI holds a generated copy
11
+ */
12
+ import { hexToOklch, luminance, maxOklchChroma, normalizeColor, oklabCoordinates, oklabCoordinatesToHex, oklchClampedHex, toneToOklabLightness } from "./color.js";
13
+ /** The recipe a request that names none runs: the first one. */
14
+ export const PALETTE_RECIPE = 'astryx-oklch-v1';
15
+ /**
16
+ * The recipe whose pale stops follow the vibrancy and the seed's own
17
+ * chroma: a stop whose gamut cannot hold the most vivid request gives every
18
+ * request the same share of it, and coordination never raises a seed's
19
+ * chroma. A request runs it by naming it.
20
+ */
21
+ export const PALETTE_RECIPE_V2 = 'astryx-oklch-v2';
22
+ /** Every recipe the generator runs. */
23
+ export const PALETTE_RECIPES = Object.freeze([PALETTE_RECIPE, PALETTE_RECIPE_V2]);
24
+ /**
25
+ * Identity of this generator implementation. `PALETTE_RECIPE` names the
26
+ * normative algorithm; this names the code that ran it, so a receipt can tell
27
+ * two implementations of one recipe apart.
28
+ */
29
+ export const PALETTE_GENERATOR_VERSION = 'palette-generator-v1';
30
+ export const PALETTE_BLACK = '#000000';
31
+ export const PALETTE_WHITE = '#ffffff';
32
+ export const DEFAULT_21_STOPS = Object.freeze([0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]);
33
+ export const COMPACT_11_STOPS = Object.freeze([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
34
+ const DARK_CHROMA_FACTOR = 0.85;
35
+ const RESERVED_FAMILY_IDS = Object.freeze(['black', 'white']);
36
+ const NEUTRAL_PROFILES = ['neutral-v1', 'warm-v1', 'cool-v1', 'custom'];
37
+ function clamp(value, minimum, maximum) {
38
+ return Math.min(maximum, Math.max(minimum, value));
39
+ }
40
+ function normalizeHue(hue) {
41
+ return (hue % 360 + 360) % 360;
42
+ }
43
+ function hueDistance(a, b) {
44
+ const difference = Math.abs(normalizeHue(a) - normalizeHue(b));
45
+ return Math.min(difference, 360 - difference);
46
+ }
47
+ function signedHueDelta(from, to) {
48
+ return (normalizeHue(to) - normalizeHue(from) + 540) % 360 - 180;
49
+ }
50
+ function interpolateHue(a, b, amount) {
51
+ const delta = (b - a + 540) % 360 - 180;
52
+ return normalizeHue(a + delta * amount);
53
+ }
54
+ export function validateStops(stops) {
55
+ if (!Array.isArray(stops) || stops.length === 0) {
56
+ throw new Error('A palette requires at least one stop.');
57
+ }
58
+ for (const stop of stops) {
59
+ if (!Number.isFinite(stop) || stop < 0 || stop > 100) {
60
+ throw new Error(`Stop ${stop} must be a finite number from 0 to 100.`);
61
+ }
62
+ }
63
+ for (let index = 1; index < stops.length; index++) {
64
+ if (stops[index] <= stops[index - 1]) {
65
+ throw new Error('Stops must be unique and strictly increasing.');
66
+ }
67
+ }
68
+ return [...stops];
69
+ }
70
+ export function parseStopList(input) {
71
+ const values = String(input).split(',').map(value => value.trim());
72
+ if (values.some(value => value === '' || !Number.isFinite(Number(value)))) {
73
+ throw new Error('Every custom stop must be a number from 0 to 100.');
74
+ }
75
+ return validateStops(values.map(Number));
76
+ }
77
+
78
+ /**
79
+ * The fields the generator reads from a request, a family and an anchor
80
+ * (see TonalPaletteGenerationInput); any other field changes nothing.
81
+ */
82
+ export const GENERATION_INPUT_KEYS = Object.freeze(['recipe', 'vibrancy', 'neutralProfile', 'modeStrategy', 'darkChromaTaper', 'stops', 'families']);
83
+ const DARK_CHROMA_TAPER_KEYS = Object.freeze(['edgeMultiplier', 'throughStop', 'recoverAtStop', 'familyMultipliers']);
84
+ export const FAMILY_INPUT_KEYS = Object.freeze(['id', 'name', 'seed', 'kind', 'anchors']);
85
+ export const ANCHOR_INPUT_KEYS = Object.freeze(['mode', 'stop', 'color', 'policy', 'maxDeltaE']);
86
+
87
+ /**
88
+ * The modes a mode strategy generates.
89
+ */
90
+ export function modesForStrategy(strategy) {
91
+ if (strategy === 'light-only') {
92
+ return ['light'];
93
+ }
94
+ if (strategy === 'dark-only') {
95
+ return ['dark'];
96
+ }
97
+ if (strategy === 'light-and-dark') {
98
+ return ['light', 'dark'];
99
+ }
100
+ throw new Error(`Unknown mode strategy: ${strategy}`);
101
+ }
102
+ function hueBalanceFactor(hue) {
103
+ const normalized = normalizeHue(hue);
104
+ if (normalized >= 70 && normalized < 115) {
105
+ return 0.94;
106
+ }
107
+ if (normalized >= 115 && normalized < 175) {
108
+ return 0.78;
109
+ }
110
+ if (normalized >= 175 && normalized < 230) {
111
+ return 0.82;
112
+ }
113
+ if (normalized >= 285 && normalized < 340) {
114
+ return 0.9;
115
+ }
116
+ return 1;
117
+ }
118
+ function highToneChromaFactor(hue, tone) {
119
+ if (tone <= 60) {
120
+ return 1;
121
+ }
122
+ const taper = smoothstep((tone - 60) / 35);
123
+ const normalized = normalizeHue(hue);
124
+ if (normalized >= 115 && normalized < 175) {
125
+ return 1 - 0.28 * taper;
126
+ }
127
+ if (normalized >= 175 && normalized < 200) {
128
+ return 1 - 0.4 * taper;
129
+ }
130
+ return 1;
131
+ }
132
+ function toneAdjustedHue(hue, tone) {
133
+ const normalized = normalizeHue(hue);
134
+ if (normalized < 40 || normalized >= 70 || tone >= 50) {
135
+ return normalized;
136
+ }
137
+ const darkening = clamp((50 - tone) / 40, 0, 1);
138
+ return normalizeHue(normalized - 8 * Math.sqrt(darkening));
139
+ }
140
+ function toneChromaEnvelope(tone) {
141
+ const normalized = clamp(tone / 100, 0, 1);
142
+ return 0.18 + 0.82 * Math.sqrt(Math.max(0, Math.sin(Math.PI * normalized)));
143
+ }
144
+ function vibrancyMultiplier(vibrancy) {
145
+ if (!Number.isFinite(vibrancy) || vibrancy < 0 || vibrancy > 100) {
146
+ throw new Error('Vibrancy must be a number from 0 to 100.');
147
+ }
148
+ if (vibrancy <= 25) {
149
+ return vibrancy / 25 * 0.72;
150
+ }
151
+ if (vibrancy <= 50) {
152
+ return 0.72 + (vibrancy - 25) / 25 * 0.28;
153
+ }
154
+ return 1 + (vibrancy - 50) * 0.0096;
155
+ }
156
+
157
+ /**
158
+ * A family's chroma drawn toward the shared one, so its families sit
159
+ * together. As v2 shares a narrow stop's gamut it is never raised above the
160
+ * seed's own, so a dusty seed stays dusty in its pale stops.
161
+ * */
162
+ function coordinatedChroma(sourceChroma, recipe = PALETTE_RECIPE) {
163
+ const drawn = sourceChroma * 0.35 + 0.18 * 0.65;
164
+ return recipe === PALETTE_RECIPE_V2 ? Math.min(sourceChroma, drawn) : drawn;
165
+ }
166
+
167
+ /**
168
+ * How narrow a stop's gamut is for v2 to share it: the most vivid seed at
169
+ * the default vibrancy asks this many times what the stop holds. From the
170
+ * first the stop starts to share its gamut in proportion; from the second
171
+ * it shares it wholly.
172
+ */
173
+ const V2_SHARED_FROM = 1.3;
174
+ /** v2 shares only stops lighter than this tone: the pale side of a ramp. */
175
+ const V2_SHARED_ABOVE = 50;
176
+ const V2_SHARED_FULL = 2;
177
+
178
+ /**
179
+ * The share of its chroma a v2 gray family keeps at a lightness. It keeps
180
+ * all of it up to GRAY_FADE_FROM. Above that the share falls linearly to
181
+ * GRAY_FADE_LEAST at GRAY_FADE_TO, as gray scales fade their tint toward
182
+ * white: a slate's palest grays keep about a sixth of its color.
183
+ * @param lightness OKLab lightness
184
+ */
185
+ function grayFade(lightness) {
186
+ const t = clamp((lightness - GRAY_FADE_FROM) / (GRAY_FADE_TO - GRAY_FADE_FROM), 0, 1);
187
+ return 1 - (1 - GRAY_FADE_LEAST) * t;
188
+ }
189
+ const GRAY_FADE_FROM = 0.7;
190
+ const GRAY_FADE_TO = 0.97;
191
+ const GRAY_FADE_LEAST = 0.28;
192
+
193
+ /** The chroma of the most vivid seed sRGB holds, as v2 coordinates it. */
194
+ const MOST_VIVID_CHROMA = coordinatedChroma(0.32, PALETTE_RECIPE_V2);
195
+ function colorToPolar(color) {
196
+ const value = hexToOklch(color);
197
+ return {
198
+ lightness: value.L,
199
+ chroma: value.C,
200
+ hue: value.H
201
+ };
202
+ }
203
+ function neutralPolar(profile, seed) {
204
+ if (profile === 'custom') {
205
+ return colorToPolar(seed);
206
+ }
207
+ const hue = profile === 'warm-v1' ? 75 : profile === 'cool-v1' ? 250 : 0;
208
+ if (!['neutral-v1', 'warm-v1', 'cool-v1'].includes(profile)) {
209
+ throw new Error(`Unknown neutral profile: ${profile}`);
210
+ }
211
+ return {
212
+ lightness: 0.5,
213
+ chroma: profile === 'neutral-v1' ? 0 : 0.018,
214
+ hue
215
+ };
216
+ }
217
+ function anchorPolarAtStop(seed, anchors, stop) {
218
+ if (anchors.length === 0) {
219
+ return seed;
220
+ }
221
+ const sorted = [...anchors].sort((a, b) => a.stop - b.stop);
222
+ const lower = [...sorted].reverse().find(anchor => anchor.stop <= stop);
223
+ const upper = sorted.find(anchor => anchor.stop >= stop);
224
+ if (!lower || !upper || lower.stop === upper.stop) {
225
+ return colorToPolar(normalizeColor((lower ?? upper ?? sorted[0]).color));
226
+ }
227
+ const start = colorToPolar(normalizeColor(lower.color));
228
+ const end = colorToPolar(normalizeColor(upper.color));
229
+ const amount = (stop - lower.stop) / (upper.stop - lower.stop);
230
+ return {
231
+ lightness: start.lightness + (end.lightness - start.lightness) * amount,
232
+ chroma: start.chroma + (end.chroma - start.chroma) * amount,
233
+ hue: interpolateHue(start.hue, end.hue, amount)
234
+ };
235
+ }
236
+
237
+ /**
238
+ * @param [chromaMultiplier] Share of its in-gamut chroma the stop
239
+ * keeps (see darkChromaMultiplier).
240
+ */
241
+ function generateCandidate(source, tone, mode, vibrancy, coordinateWithOtherFamilies, chromaMultiplier = 1, recipe = PALETTE_RECIPE) {
242
+ const adjustedTone = tone;
243
+ const adjustedHue = toneAdjustedHue(source.hue, adjustedTone);
244
+ // Every recipe starts from v1's chroma, so a stop v2 does not share is
245
+ // drawn exactly as v1 draws it.
246
+ const baseChroma = coordinateWithOtherFamilies ? coordinatedChroma(source.chroma) : source.chroma;
247
+ let chroma = baseChroma * vibrancyMultiplier(vibrancy) * hueBalanceFactor(adjustedHue) * highToneChromaFactor(adjustedHue, adjustedTone) * toneChromaEnvelope(adjustedTone) * (mode === 'dark' ? DARK_CHROMA_FACTOR : 1);
248
+ const lightness = toneToOklabLightness(adjustedTone);
249
+ const maxChroma = maxOklchChroma(adjustedHue, lightness);
250
+ // v2: a gray family's color fades toward white the way a gray scale's
251
+ // does, so its pale stops (a page, a card on it) carry only a faint tint
252
+ // of its hue; its darker stops keep their color.
253
+ if (recipe === PALETTE_RECIPE_V2 && !coordinateWithOtherFamilies) {
254
+ chroma *= grayFade(lightness);
255
+ }
256
+ // v2, on the pale side of a ramp (above its middle): the narrower a
257
+ // stop's gamut is for the most vivid seed at the default vibrancy (a pale
258
+ // tint), the more every request shares that gamut in proportion (the most
259
+ // vivid seed at vibrancy 100 takes all of it), so such a stop follows the
260
+ // seed's chroma, never raised above the seed's own, and the vibrancy,
261
+ // instead of every request landing on the gamut's edge. A stop whose
262
+ // gamut holds the most vivid seed at the default vibrancy shares nothing,
263
+ // and the dark side never shares (role text and dark fills keep their
264
+ // strength): those stops are drawn exactly as v1 draws them, for every
265
+ // seed at every vibrancy.
266
+ if (recipe === PALETTE_RECIPE_V2 && coordinateWithOtherFamilies && adjustedTone > V2_SHARED_ABOVE) {
267
+ const shape = hueBalanceFactor(adjustedHue) * highToneChromaFactor(adjustedHue, adjustedTone) * toneChromaEnvelope(adjustedTone) * (mode === 'dark' ? DARK_CHROMA_FACTOR : 1);
268
+ const narrow = MOST_VIVID_CHROMA * vibrancyMultiplier(50) * shape / Math.max(maxChroma, 1e-6);
269
+ const share = smoothstep((narrow - V2_SHARED_FROM) / (V2_SHARED_FULL - V2_SHARED_FROM));
270
+ if (share > 0) {
271
+ const most = MOST_VIVID_CHROMA * vibrancyMultiplier(100) * shape;
272
+ const own = coordinatedChroma(source.chroma, recipe) * vibrancyMultiplier(vibrancy) * shape;
273
+ const shared = own / most * maxChroma;
274
+ chroma = (1 - share) * Math.min(chroma, maxChroma) + share * shared;
275
+ }
276
+ }
277
+ // A taper scales the chroma the stop shows after gamut mapping, so a stop
278
+ // the gamut already limits loses the same share as any other stop.
279
+ const shownChroma = chromaMultiplier === 1 ? chroma : Math.min(chroma, maxChroma) * chromaMultiplier;
280
+ return {
281
+ hex: oklchClampedHex(lightness, shownChroma, adjustedHue),
282
+ gamutMapped: chroma > maxChroma + 0.000001
283
+ };
284
+ }
285
+ export function perceptualDelta(colorA, colorB) {
286
+ const [lightnessA, aA, bA] = oklabCoordinates(colorA);
287
+ const [lightnessB, aB, bB] = oklabCoordinates(colorB);
288
+ return Math.sqrt((lightnessA - lightnessB) ** 2 + (aA - aB) ** 2 + (bA - bB) ** 2) * 100;
289
+ }
290
+ function interpolateColor(colorA, colorB, amount) {
291
+ const start = hexToOklch(colorA);
292
+ const end = hexToOklch(colorB);
293
+ return oklchClampedHex(start.L + (end.L - start.L) * amount, start.C + (end.C - start.C) * amount, interpolateHue(start.H, end.H, amount));
294
+ }
295
+ function applyAnchor(candidate, anchor) {
296
+ const target = normalizeColor(anchor.color);
297
+ let generatedColor = candidate;
298
+ if (anchor.policy === 'exact') {
299
+ generatedColor = target;
300
+ } else if (anchor.policy === 'bounded') {
301
+ const tolerance = Number(anchor.maxDeltaE);
302
+ if (!Number.isFinite(tolerance) || tolerance < 0) {
303
+ throw new Error(`Bounded anchor at stop ${anchor.stop} requires a non-negative maxDeltaE.`);
304
+ }
305
+ if (perceptualDelta(candidate, target) > tolerance) {
306
+ let low = 0;
307
+ let high = 1;
308
+ for (let index = 0; index < 18; index++) {
309
+ const amount = (low + high) / 2;
310
+ const mixed = interpolateColor(target, candidate, amount);
311
+ if (perceptualDelta(mixed, target) <= tolerance) {
312
+ low = amount;
313
+ } else {
314
+ high = amount;
315
+ }
316
+ }
317
+ generatedColor = interpolateColor(target, candidate, low);
318
+ }
319
+ } else if (anchor.policy === 'flexible') {
320
+ generatedColor = interpolateColor(candidate, target, 0.35);
321
+ } else {
322
+ throw new Error(`Unknown anchor policy: ${anchor.policy}`);
323
+ }
324
+ return {
325
+ ...anchor,
326
+ color: target,
327
+ generatedColor,
328
+ deltaE: perceptualDelta(generatedColor, target)
329
+ };
330
+ }
331
+ function smoothstep(amount) {
332
+ const value = clamp(amount, 0, 1);
333
+ return value * value * (3 - 2 * value);
334
+ }
335
+ function interpolateDelta(start, end, amount) {
336
+ return [start[0] + (end[0] - start[0]) * amount, start[1] + (end[1] - start[1]) * amount, start[2] + (end[2] - start[2]) * amount];
337
+ }
338
+ function correctionAtStop(corrections, stop) {
339
+ const zero = [0, 0, 0];
340
+ if (corrections.length === 0) {
341
+ return zero;
342
+ }
343
+ const first = corrections[0];
344
+ if (stop <= first.stop) {
345
+ const boundary = Math.max(0, first.stop - 25);
346
+ if (stop <= boundary && boundary !== first.stop) {
347
+ return zero;
348
+ }
349
+ const amount = boundary === first.stop ? 1 : smoothstep((stop - boundary) / (first.stop - boundary));
350
+ return interpolateDelta(zero, first.delta, amount);
351
+ }
352
+ const last = corrections[corrections.length - 1];
353
+ if (stop >= last.stop) {
354
+ const boundary = Math.min(100, last.stop + 25);
355
+ if (stop >= boundary && boundary !== last.stop) {
356
+ return zero;
357
+ }
358
+ const amount = boundary === last.stop ? 1 : smoothstep((stop - last.stop) / (boundary - last.stop));
359
+ return interpolateDelta(last.delta, zero, amount);
360
+ }
361
+ const upperIndex = corrections.findIndex(item => item.stop > stop);
362
+ const lower = corrections[upperIndex - 1];
363
+ const upper = corrections[upperIndex];
364
+ return interpolateDelta(lower.delta, upper.delta, smoothstep((stop - lower.stop) / (upper.stop - lower.stop)));
365
+ }
366
+ function applyAnchorCorrections(colors, stops, anchors) {
367
+ if (anchors.length === 0) {
368
+ return {
369
+ colors,
370
+ anchors: []
371
+ };
372
+ }
373
+ const corrections = anchors.map(anchor => {
374
+ const candidate = colors[anchor.stop];
375
+ const result = applyAnchor(candidate, anchor);
376
+ const base = oklabCoordinates(candidate);
377
+ const target = oklabCoordinates(result.generatedColor);
378
+ const delta = [target[0] - base[0], target[1] - base[1], target[2] - base[2]];
379
+ return {
380
+ stop: anchor.stop,
381
+ delta,
382
+ result
383
+ };
384
+ }).sort((a, b) => a.stop - b.stop);
385
+ const corrected = {};
386
+ for (const stop of stops) {
387
+ const base = oklabCoordinates(colors[stop]);
388
+ const delta = correctionAtStop(corrections, stop);
389
+ corrected[stop] = oklabCoordinatesToHex([base[0] + delta[0], base[1] + delta[1], base[2] + delta[2]]);
390
+ }
391
+ for (const correction of corrections) {
392
+ corrected[correction.stop] = correction.result.generatedColor;
393
+ }
394
+ return {
395
+ colors: corrected,
396
+ anchors: corrections.map(correction => correction.result)
397
+ };
398
+ }
399
+ function assertAnchorSet(anchors, stops) {
400
+ const seen = new Set();
401
+ for (const anchor of anchors) {
402
+ const color = normalizeColor(anchor.color);
403
+ if (!['light', 'dark'].includes(anchor.mode)) {
404
+ throw new Error(`Unknown anchor mode: ${anchor.mode}`);
405
+ }
406
+ if (!stops.includes(anchor.stop)) {
407
+ throw new Error(`Anchor stop ${anchor.stop} is not present in the requested stop layout.`);
408
+ }
409
+ if (anchor.stop === 0 && color !== PALETTE_BLACK || anchor.stop === 100 && color !== PALETTE_WHITE) {
410
+ throw new Error(`Anchor stop ${anchor.stop} is reserved for exact ${anchor.stop === 0 ? 'black' : 'white'}; use an interior stop for a tinted endpoint.`);
411
+ }
412
+ const key = `${anchor.mode}:${anchor.stop}`;
413
+ if (seen.has(key)) {
414
+ throw new Error(`Duplicate anchor for ${anchor.mode} stop ${anchor.stop}.`);
415
+ }
416
+ seen.add(key);
417
+ }
418
+ }
419
+ function buildDiagnostics(colors, stops, sourceHue, gamutMappedStops, anchors) {
420
+ let monotonic = true;
421
+ let minimumAdjacentDeltaE = Number.POSITIVE_INFINITY;
422
+ let maximumAdjacentDeltaE = 0;
423
+ let maximumHueDrift = 0;
424
+ let hueIdentityRisk = null;
425
+ for (let index = 0; index < stops.length; index++) {
426
+ const stop = stops[index];
427
+ const color = colors[stop];
428
+ const oklch = hexToOklch(color);
429
+ if (oklch.C >= 0.015) {
430
+ const drift = signedHueDelta(sourceHue, oklch.H);
431
+ maximumHueDrift = Math.max(maximumHueDrift, hueDistance(sourceHue, oklch.H));
432
+ if (sourceHue >= 230 && sourceHue < 285 && drift > 12) {
433
+ hueIdentityRisk = 'blue-to-purple';
434
+ }
435
+ if (sourceHue >= 70 && sourceHue < 115 && drift < -12) {
436
+ hueIdentityRisk = 'yellow-to-brown';
437
+ }
438
+ }
439
+ if (index === 0) {
440
+ continue;
441
+ }
442
+ const previous = colors[stops[index - 1]];
443
+ if (luminance(color) + 0.000001 < luminance(previous)) {
444
+ monotonic = false;
445
+ }
446
+ const adjacentDelta = perceptualDelta(previous, color);
447
+ minimumAdjacentDeltaE = Math.min(minimumAdjacentDeltaE, adjacentDelta);
448
+ maximumAdjacentDeltaE = Math.max(maximumAdjacentDeltaE, adjacentDelta);
449
+ }
450
+ return {
451
+ monotonic,
452
+ minimumAdjacentDeltaE: minimumAdjacentDeltaE === Number.POSITIVE_INFINITY ? 0 : minimumAdjacentDeltaE,
453
+ maximumAdjacentDeltaE,
454
+ maximumHueDrift,
455
+ hueIdentityRisk,
456
+ gamutMappedStops,
457
+ anchors
458
+ };
459
+ }
460
+
461
+ /**
462
+ * The share of its chroma a stop keeps under the request's
463
+ * `darkChromaTaper`: the edge multiplier through `throughStop`, a smoothstep
464
+ * back to 1 at `recoverAtStop`, and 1 from there on. Light ramps, neutral
465
+ * families, and the black and white endpoints keep all of it.
466
+ */
467
+ function darkChromaMultiplier(taper, family, mode, stop) {
468
+ if (!taper || mode !== 'dark' || family.kind === 'neutral') {
469
+ return 1;
470
+ }
471
+ if (stop <= 0 || stop >= 100 || stop >= taper.recoverAtStop) {
472
+ return 1;
473
+ }
474
+ // Read own keys only. A family id such as `constructor` must not get a
475
+ // multiplier from the object prototype.
476
+ const edge = Object.hasOwn(taper.familyMultipliers, family.id) ? taper.familyMultipliers[family.id] : taper.edgeMultiplier;
477
+ if (stop <= taper.throughStop) {
478
+ return edge;
479
+ }
480
+ const recovery = smoothstep((stop - taper.throughStop) / (taper.recoverAtStop - taper.throughStop));
481
+ return edge + (1 - edge) * recovery;
482
+ }
483
+ function generateRamp(request, family, mode) {
484
+ const seedHex = normalizeColor(family.seed);
485
+ const anchors = (family.anchors ?? []).filter(anchor => anchor.mode === mode);
486
+ assertAnchorSet(family.anchors ?? [], request.stops);
487
+ const seed = family.kind === 'neutral' ? neutralPolar(request.neutralProfile, seedHex) : colorToPolar(seedHex);
488
+ const colors = {};
489
+ const gamutMappedStops = [];
490
+ const diagnosticReference = generateCandidate(seed, 50, mode, request.vibrancy, family.kind !== 'neutral', darkChromaMultiplier(request.darkChromaTaper, family, mode, 50), request.recipe).hex;
491
+ for (const stop of request.stops) {
492
+ const source = anchorPolarAtStop(seed, anchors, stop);
493
+ const generated = generateCandidate(source, stop, mode, request.vibrancy, family.kind !== 'neutral', darkChromaMultiplier(request.darkChromaTaper, family, mode, stop), request.recipe);
494
+ colors[stop] = generated.hex;
495
+ if (generated.gamutMapped) {
496
+ gamutMappedStops.push(stop);
497
+ }
498
+ }
499
+ const corrected = applyAnchorCorrections(colors, request.stops, anchors);
500
+ const diagnostics = buildDiagnostics(corrected.colors, request.stops, hexToOklch(diagnosticReference).H, gamutMappedStops, corrected.anchors);
501
+ if (!diagnostics.monotonic) {
502
+ throw new Error(`${family.name} ${mode} ramp is not luminance-monotonic with the requested anchors.`);
503
+ }
504
+ return {
505
+ colors: corrected.colors,
506
+ diagnostics
507
+ };
508
+ }
509
+ function nearestStop(stops, target) {
510
+ return stops.reduce((best, stop) => Math.abs(stop - target) < Math.abs(best - target) ? stop : best);
511
+ }
512
+ function buildCoordinationDiagnostics(request, families) {
513
+ const stop = nearestStop(request.stops, 50);
514
+ const chromaticIds = new Set(request.families.filter(family => family.kind !== 'neutral').map(family => family.id));
515
+ return modesForStrategy(request.modeStrategy).map(mode => {
516
+ const samples = families.filter(family => chromaticIds.has(family.id) && family[mode]).map(family => {
517
+ const ramp = family[mode];
518
+ if (!ramp) {
519
+ throw new Error(`Missing ${mode} ramp for ${family.id}.`);
520
+ }
521
+ const color = ramp.colors[stop];
522
+ return {
523
+ id: family.id,
524
+ name: family.name,
525
+ color,
526
+ chroma: hexToOklch(color).C
527
+ };
528
+ });
529
+ let closestFamilies = null;
530
+ let minimumFamilyDeltaE = Number.POSITIVE_INFINITY;
531
+ for (let index = 0; index < samples.length; index++) {
532
+ for (let next = index + 1; next < samples.length; next++) {
533
+ const delta = perceptualDelta(samples[index].color, samples[next].color);
534
+ if (delta < minimumFamilyDeltaE) {
535
+ minimumFamilyDeltaE = delta;
536
+ closestFamilies = [samples[index].name, samples[next].name];
537
+ }
538
+ }
539
+ }
540
+ const byChroma = [...samples].sort((a, b) => a.chroma - b.chroma);
541
+ const weakest = byChroma[0];
542
+ const strongest = byChroma[byChroma.length - 1];
543
+ return {
544
+ mode,
545
+ stop,
546
+ closestFamilies,
547
+ minimumFamilyDeltaE: minimumFamilyDeltaE === Number.POSITIVE_INFINITY ? null : minimumFamilyDeltaE,
548
+ strongestFamily: strongest?.name ?? null,
549
+ weakestFamily: weakest?.name ?? null,
550
+ chromaRatio: weakest && strongest && weakest.chroma > 0.0001 ? strongest.chroma / weakest.chroma : null
551
+ };
552
+ });
553
+ }
554
+ function assertMultiplier(value, label) {
555
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > 1) {
556
+ throw new Error(`${label} must be a number from 0 to 1.`);
557
+ }
558
+ return value;
559
+ }
560
+
561
+ /**
562
+ * The request's dark chroma taper, checked against its stops and families,
563
+ * or undefined when the request has none. The receipt records the taper, so
564
+ * a field the taper does not read fails instead of changing nothing.
565
+ */
566
+ function normalizeDarkChromaTaper(taper, stops, families) {
567
+ if (taper == null) {
568
+ return undefined;
569
+ }
570
+ if (typeof taper !== 'object' || Array.isArray(taper)) {
571
+ throw new Error('darkChromaTaper must be an object.');
572
+ }
573
+ const fields = taper;
574
+ const unread = Object.keys(fields).filter(key => !DARK_CHROMA_TAPER_KEYS.includes(key));
575
+ if (unread.length > 0) {
576
+ throw new Error(`darkChromaTaper does not read ${unread.join(', ')}; it reads ${DARK_CHROMA_TAPER_KEYS.join(', ')}.`);
577
+ }
578
+ const {
579
+ edgeMultiplier,
580
+ throughStop,
581
+ recoverAtStop,
582
+ familyMultipliers
583
+ } = fields;
584
+ const edge = assertMultiplier(edgeMultiplier, 'darkChromaTaper.edgeMultiplier');
585
+ if (typeof throughStop !== 'number' || !stops.includes(throughStop)) {
586
+ throw new Error('darkChromaTaper.throughStop must be a stop in the requested stop layout.');
587
+ }
588
+ if (typeof recoverAtStop !== 'number' || !stops.includes(recoverAtStop) || recoverAtStop <= throughStop) {
589
+ throw new Error('darkChromaTaper.recoverAtStop must be a stop in the requested stop layout after throughStop.');
590
+ }
591
+ if (familyMultipliers != null && (typeof familyMultipliers !== 'object' || Array.isArray(familyMultipliers))) {
592
+ throw new Error('darkChromaTaper.familyMultipliers must be an object.');
593
+ }
594
+ const multipliers = {};
595
+ for (const [id, value] of Object.entries(familyMultipliers ?? {})) {
596
+ const family = families.find(candidate => candidate.id === id);
597
+ if (!family) {
598
+ throw new Error(`darkChromaTaper.familyMultipliers names unknown family ${id}.`);
599
+ }
600
+ if (family.kind === 'neutral') {
601
+ throw new Error(`darkChromaTaper.familyMultipliers names neutral family ${id}; the taper changes only chromatic families.`);
602
+ }
603
+ multipliers[id] = assertMultiplier(value, `darkChromaTaper.familyMultipliers.${id}`);
604
+ }
605
+ return {
606
+ edgeMultiplier: edge,
607
+ throughStop,
608
+ recoverAtStop,
609
+ familyMultipliers: multipliers
610
+ };
611
+ }
612
+ export function normalizeGenerationRequest(input) {
613
+ if (!input || typeof input !== 'object' || Array.isArray(input)) {
614
+ throw new Error('Palette generation config must be an object.');
615
+ }
616
+ const families = input.families;
617
+ if (!Array.isArray(families) || families.length === 0) {
618
+ throw new Error('Palette generation requires at least one family.');
619
+ }
620
+ // A request that names no recipe runs the first one, so a config written
621
+ // before v2 regenerates the same colors.
622
+ const recipe = input.recipe ?? PALETTE_RECIPE;
623
+ if (!PALETTE_RECIPES.includes(recipe)) {
624
+ throw new Error(`Unknown palette recipe: ${input.recipe} (known: ${PALETTE_RECIPES.join(', ')}).`);
625
+ }
626
+ const modeStrategy = input.modeStrategy ?? 'light-and-dark';
627
+ const modes = modesForStrategy(modeStrategy);
628
+ const stops = validateStops(input.stops ?? DEFAULT_21_STOPS);
629
+ const ids = new Set();
630
+ const normalizedFamilies = families.map((family, index) => {
631
+ if (!family || typeof family !== 'object' || Array.isArray(family)) {
632
+ throw new Error(`Family ${index} must be an object.`);
633
+ }
634
+ const id = `${family.id ?? ''}`.trim();
635
+ if (!/^[a-z][a-z0-9-]*$/.test(id)) {
636
+ throw new Error(`Family ${index} id must use lower-kebab-case characters.`);
637
+ }
638
+ if (RESERVED_FAMILY_IDS.includes(id)) {
639
+ throw new Error(`Family id ${id} is reserved for the standalone ${id} palette value.`);
640
+ }
641
+ if (ids.has(id)) {
642
+ throw new Error(`Duplicate family id: ${id}.`);
643
+ }
644
+ ids.add(id);
645
+ const kind = family.kind ?? 'chromatic';
646
+ if (!['chromatic', 'neutral'].includes(kind)) {
647
+ throw new Error(`Unknown family kind: ${kind}`);
648
+ }
649
+ if (family.anchors != null && !Array.isArray(family.anchors)) {
650
+ throw new Error(`Family ${id} anchors must be an array.`);
651
+ }
652
+ const anchors = (family.anchors ?? []).map((anchor, anchorIndex) => {
653
+ if (!anchor || typeof anchor !== 'object' || Array.isArray(anchor)) {
654
+ throw new Error(`Family ${id} anchor ${anchorIndex} must be an object.`);
655
+ }
656
+ if (!['light', 'dark'].includes(anchor.mode)) {
657
+ throw new Error(`Unknown anchor mode: ${anchor.mode}`);
658
+ }
659
+ if (!modes.includes(anchor.mode)) {
660
+ throw new Error(`Anchor mode ${anchor.mode} is not generated by mode strategy ${modeStrategy}.`);
661
+ }
662
+ if (!Number.isFinite(anchor.stop) || !stops.includes(anchor.stop)) {
663
+ throw new Error(`Anchor stop ${anchor.stop} is not present in the requested stop layout.`);
664
+ }
665
+ if (!['exact', 'bounded', 'flexible'].includes(anchor.policy)) {
666
+ throw new Error(`Unknown anchor policy: ${anchor.policy}`);
667
+ }
668
+ const maxDeltaE = anchor.maxDeltaE;
669
+ if (anchor.policy === 'bounded' && (typeof maxDeltaE !== 'number' || !Number.isFinite(maxDeltaE) || maxDeltaE < 0)) {
670
+ throw new Error(`Bounded anchor at stop ${anchor.stop} requires a non-negative maxDeltaE.`);
671
+ }
672
+ if (anchor.policy !== 'bounded' && maxDeltaE != null) {
673
+ throw new Error(`Anchor policy ${anchor.policy} does not accept maxDeltaE.`);
674
+ }
675
+ const color = normalizeColor(anchor.color);
676
+ if (anchor.stop === 0 && color !== PALETTE_BLACK || anchor.stop === 100 && color !== PALETTE_WHITE) {
677
+ throw new Error(`Anchor stop ${anchor.stop} is reserved for exact ${anchor.stop === 0 ? 'black' : 'white'}; use an interior stop for a tinted endpoint.`);
678
+ }
679
+ return {
680
+ mode: anchor.mode,
681
+ stop: anchor.stop,
682
+ color,
683
+ policy: anchor.policy,
684
+ ...(anchor.policy === 'bounded' ? {
685
+ maxDeltaE
686
+ } : {})
687
+ };
688
+ });
689
+ return {
690
+ id,
691
+ name: `${family.name ?? id}`,
692
+ seed: normalizeColor(family.seed),
693
+ kind,
694
+ anchors
695
+ };
696
+ });
697
+ const neutralProfile = input.neutralProfile ?? 'neutral-v1';
698
+ // The receipt records this request, so an unknown profile fails even when no
699
+ // neutral family reads it.
700
+ if (!NEUTRAL_PROFILES.includes(neutralProfile)) {
701
+ throw new Error(`Unknown neutral profile: ${neutralProfile}`);
702
+ }
703
+ const darkChromaTaper = normalizeDarkChromaTaper(input.darkChromaTaper, stops, normalizedFamilies);
704
+ const request = {
705
+ recipe,
706
+ vibrancy: input.vibrancy ?? 50,
707
+ neutralProfile,
708
+ modeStrategy,
709
+ ...(darkChromaTaper ? {
710
+ darkChromaTaper
711
+ } : {}),
712
+ stops,
713
+ families: normalizedFamilies
714
+ };
715
+ vibrancyMultiplier(request.vibrancy);
716
+ return request;
717
+ }
718
+ export function generatePaletteSet(input) {
719
+ const request = normalizeGenerationRequest(input);
720
+ const families = [];
721
+ const errors = [];
722
+ for (const family of request.families) {
723
+ try {
724
+ const generated = {
725
+ id: family.id,
726
+ name: family.name,
727
+ seed: family.seed
728
+ };
729
+ for (const mode of modesForStrategy(request.modeStrategy)) {
730
+ generated[mode] = generateRamp(request, family, mode);
731
+ }
732
+ families.push(generated);
733
+ } catch (error) {
734
+ errors.push({
735
+ familyId: family.id,
736
+ message: error instanceof Error ? error.message : String(error)
737
+ });
738
+ }
739
+ }
740
+ return {
741
+ recipe: request.recipe,
742
+ status: 'candidate',
743
+ request,
744
+ families,
745
+ coordination: buildCoordinationDiagnostics(request, families),
746
+ errors
747
+ };
748
+ }
749
+
750
+ /**
751
+ * Generate candidate palette data without reading or writing files.
752
+ */
753
+ export function generateTonalPalette(input) {
754
+ const result = generatePaletteSet(input);
755
+ if (result.errors.length > 0) {
756
+ throw new Error(result.errors.map(error => `${error.familyId}: ${error.message}`).join('\n'));
757
+ }
758
+ return {
759
+ schemaVersion: 1,
760
+ status: 'candidate',
761
+ recipe: result.recipe,
762
+ black: PALETTE_BLACK,
763
+ white: PALETTE_WHITE,
764
+ stops: [...result.request.stops],
765
+ palette: Object.fromEntries(result.families.map(family => [family.id, {
766
+ name: family.name,
767
+ ...(family.light ? {
768
+ light: family.light.colors
769
+ } : {}),
770
+ ...(family.dark ? {
771
+ dark: family.dark.colors
772
+ } : {})
773
+ }]))
774
+ };
775
+ }
776
+ export function serializeGenerationResult(result) {
777
+ return `${JSON.stringify(result, null, 2)}\n`;
778
+ }