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