@astryxdesign/core 0.4.7 → 0.5.0-canary.009bcb3
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 +161 -1
- package/dist/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +45 -20
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +3 -2
- package/dist/AspectRatio/AspectRatio.d.ts +24 -0
- package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
- package/dist/AspectRatio/AspectRatio.js +23 -4
- package/dist/Avatar/Avatar.d.ts +25 -1
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +58 -19
- package/dist/Avatar/index.d.ts +2 -2
- package/dist/Avatar/index.d.ts.map +1 -1
- package/dist/Avatar/index.js +1 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts +9 -2
- package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroup.js +8 -4
- package/dist/AvatarGroup/AvatarGroupContext.d.ts +2 -1
- package/dist/AvatarGroup/AvatarGroupContext.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.js +10 -6
- package/dist/Banner/Banner.d.ts +49 -15
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +62 -20
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +17 -4
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +3 -2
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +11 -10
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +11 -6
- package/dist/ButtonGroup/ButtonGroup.d.ts +5 -1
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +26 -7
- package/dist/Calendar/Calendar.d.ts +7 -3
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +21 -23
- package/dist/Calendar/getInitialFocusDate.d.ts +46 -0
- package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -0
- package/dist/Calendar/getInitialFocusDate.js +62 -0
- package/dist/Calendar/styles.d.ts +5 -14
- package/dist/Calendar/styles.d.ts.map +1 -1
- package/dist/Calendar/styles.js +15 -15
- package/dist/Card/Card.d.ts +12 -12
- package/dist/Card/Card.d.ts.map +1 -1
- package/dist/Card/Card.js +17 -9
- package/dist/Card/index.d.ts +35 -1
- package/dist/Card/index.d.ts.map +1 -1
- package/dist/Card/index.js +21 -1
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +3 -3
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -3
- package/dist/Chat/ChatLayout.d.ts.map +1 -1
- package/dist/Chat/ChatLayout.js +3 -3
- package/dist/Chat/ChatMessageList.d.ts +22 -3
- package/dist/Chat/ChatMessageList.d.ts.map +1 -1
- package/dist/Chat/ChatMessageList.js +6 -3
- package/dist/Chat/ChatTokenizedText.d.ts +2 -0
- package/dist/Chat/ChatTokenizedText.d.ts.map +1 -1
- package/dist/Chat/ChatTokenizedText.js +11 -6
- package/dist/Chat/useChatComposerTokens.js +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +10 -3
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +3 -3
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +15 -4
- package/dist/CodeBlock/highlightRanges.js +1 -1
- package/dist/CodeBlock/highlightStyles.js +13 -13
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +3 -2
- package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteItem.js +3 -2
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +1 -3
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +4 -3
- package/dist/DateInput/DateInput.d.ts +43 -0
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +22 -2
- package/dist/DateInput/NativeDateField.d.ts +10 -0
- package/dist/DateInput/NativeDateField.d.ts.map +1 -0
- package/dist/DateInput/NativeDateField.js +494 -0
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +82 -23
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.d.ts.map +1 -1
- package/dist/DateInput/nativeDateSegments.d.ts +22 -0
- package/dist/DateInput/nativeDateSegments.d.ts.map +1 -0
- package/dist/DateInput/nativeDateSegments.js +111 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts +4 -2
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts +21 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +406 -12
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.d.ts.map +1 -1
- package/dist/Dialog/Dialog.d.ts +21 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +110 -58
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -13
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +6 -5
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +9 -1
- package/dist/Field/InputClearButton.d.ts +9 -3
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +14 -3
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +3 -2
- package/dist/Heading/Heading.d.ts.map +1 -1
- package/dist/Heading/Heading.js +6 -3
- package/dist/HoverCard/HoverCard.d.ts +6 -0
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +104 -3
- package/dist/HoverCard/useHoverCard.d.ts +19 -2
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +74 -26
- package/dist/Indicator/CheckboxIndicator.d.ts.map +1 -1
- package/dist/Indicator/CheckboxIndicator.js +6 -2
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +4 -2
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +2 -19
- package/dist/Layer/LayerDepthContext.d.ts +52 -0
- package/dist/Layer/LayerDepthContext.d.ts.map +1 -0
- package/dist/Layer/LayerDepthContext.js +66 -0
- package/dist/Layer/gestureCounter.d.ts +8 -0
- package/dist/Layer/gestureCounter.d.ts.map +1 -0
- package/dist/Layer/gestureCounter.js +53 -0
- package/dist/Layer/index.d.ts +3 -0
- package/dist/Layer/index.d.ts.map +1 -1
- package/dist/Layer/index.js +4 -0
- package/dist/Layer/layerStack.d.ts +98 -0
- package/dist/Layer/layerStack.d.ts.map +1 -0
- package/dist/Layer/layerStack.js +306 -0
- package/dist/Layer/useLayer.d.ts +23 -13
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +128 -8
- package/dist/Layer/useLayerDismissal.d.ts +93 -0
- package/dist/Layer/useLayerDismissal.d.ts.map +1 -0
- package/dist/Layer/useLayerDismissal.js +91 -0
- package/dist/Lightbox/Lightbox.d.ts +1 -0
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +103 -81
- package/dist/List/List.d.ts +1 -1
- package/dist/List/List.d.ts.map +1 -1
- package/dist/List/List.js +15 -4
- package/dist/Markdown/Markdown.d.ts +1 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +20 -7
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.d.ts.map +1 -1
- package/dist/Markdown/parser.d.ts +38 -1
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +182 -32
- package/dist/MetadataList/MetadataListItem.d.ts +1 -1
- package/dist/MetadataList/MetadataListItem.d.ts.map +1 -1
- package/dist/MetadataList/MetadataListItem.js +4 -1
- package/dist/MobileNav/MobileNav.d.ts +6 -1
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +61 -36
- package/dist/MultiSelector/MultiSelector.d.ts +32 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +73 -15
- package/dist/MultiSelector/hooks.d.ts +7 -1
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +3 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.d.ts.map +1 -1
- package/dist/NavIcon/NavIcon.d.ts.map +1 -1
- package/dist/NavIcon/NavIcon.js +5 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts +1 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenu.js +9 -5
- package/dist/NumberInput/NumberInput.d.ts +6 -1
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +54 -104
- package/dist/NumberInput/numberInputCommit.d.ts +34 -0
- package/dist/NumberInput/numberInputCommit.d.ts.map +1 -0
- package/dist/NumberInput/numberInputCommit.js +71 -0
- package/dist/NumberInput/numberParser.d.ts +64 -0
- package/dist/NumberInput/numberParser.d.ts.map +1 -0
- package/dist/NumberInput/numberParser.js +350 -0
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +3 -2
- package/dist/OverflowList/OverflowList.d.ts.map +1 -1
- package/dist/OverflowList/OverflowList.js +3 -2
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +3 -2
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +1 -9
- package/dist/Popover/usePopover.d.ts +7 -41
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +40 -21
- package/dist/PowerSearch/PowerSearch.d.ts +8 -2
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +19 -6
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +3 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +28 -6
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts +3 -1
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +110 -27
- package/dist/PowerSearch/types.d.ts +2 -0
- package/dist/PowerSearch/types.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchSource.d.ts +6 -1
- package/dist/PowerSearch/usePowerSearchSource.d.ts.map +1 -1
- package/dist/PowerSearch/usePowerSearchSource.js +14 -5
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +18 -5
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +3 -2
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +3 -2
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +12 -3
- package/dist/Selector/Selector.d.ts +18 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +91 -18
- package/dist/Selector/hooks.d.ts +7 -1
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +3 -2
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +4 -3
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +8 -7
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +4 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +37 -5
- package/dist/Spinner/Spinner.d.ts +3 -3
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +130 -78
- package/dist/StatusDot/StatusDot.d.ts.map +1 -1
- package/dist/StatusDot/StatusDot.js +6 -1
- package/dist/Stepper/Step.d.ts +140 -0
- package/dist/Stepper/Step.d.ts.map +1 -0
- package/dist/Stepper/Step.js +1045 -0
- package/dist/Stepper/StepStatus.d.ts +24 -0
- package/dist/Stepper/StepStatus.d.ts.map +1 -0
- package/dist/Stepper/StepStatus.js +1 -0
- package/dist/Stepper/Stepper.d.ts +93 -0
- package/dist/Stepper/Stepper.d.ts.map +1 -0
- package/dist/Stepper/Stepper.js +184 -0
- package/dist/Stepper/StepperContext.d.ts +41 -0
- package/dist/Stepper/StepperContext.d.ts.map +1 -0
- package/dist/Stepper/StepperContext.js +34 -0
- package/dist/Stepper/index.d.ts +8 -0
- package/dist/Stepper/index.d.ts.map +1 -0
- package/dist/Stepper/index.js +7 -0
- package/dist/Stepper/stepper.stylex.d.ts +15 -0
- package/dist/Stepper/stepper.stylex.d.ts.map +1 -0
- package/dist/Stepper/stepper.stylex.js +20 -0
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +8 -3
- package/dist/TabList/Tab.d.ts +15 -2
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +32 -7
- package/dist/TabList/TabList.d.ts +46 -7
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +353 -23
- package/dist/TabList/TabListContext.d.ts +11 -1
- package/dist/TabList/TabListContext.d.ts.map +1 -1
- package/dist/TabList/TabListContext.js +11 -2
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +3 -2
- package/dist/TabList/index.d.ts +2 -2
- package/dist/TabList/index.d.ts.map +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +10 -2
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +3 -6
- package/dist/Table/TableRow.d.ts +16 -5
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +16 -5
- package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.js +73 -4
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts +26 -0
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -1
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +54 -11
- package/dist/Table/plugins/pagination/useTablePagination.d.ts +3 -0
- package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +21 -4
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +7 -2
- package/dist/Table/plugins/rowStatus/useTableRowStatus.d.ts.map +1 -1
- package/dist/Table/plugins/rowStatus/useTableRowStatus.js +10 -3
- package/dist/Table/plugins/selection/useTableSelection.d.ts +16 -0
- package/dist/Table/plugins/selection/useTableSelection.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelection.js +43 -5
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +3 -4
- package/dist/Table/types.d.ts +22 -4
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +5 -0
- package/dist/Text/Text.d.ts.map +1 -1
- package/dist/Text/Text.js +6 -3
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +16 -10
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +3 -2
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +3 -2
- package/dist/Timestamp/Timestamp.d.ts +1 -1
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +15 -21
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +22 -7
- package/dist/Toast/ToastViewport.d.ts +1 -0
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +71 -18
- package/dist/Token/Token.d.ts +1 -1
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +20 -9
- package/dist/Token/TokenLink.d.ts +1 -1
- package/dist/Token/TokenLink.d.ts.map +1 -1
- package/dist/Token/TokenLink.js +7 -4
- package/dist/Tokenizer/Tokenizer.d.ts +14 -1
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +33 -21
- package/dist/Tooltip/Tooltip.d.ts +5 -0
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +5 -0
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +39 -24
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +5 -4
- package/dist/TopNav/TopNavMegaMenu.d.ts +1 -1
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +31 -11
- package/dist/TopNav/TopNavMenu.d.ts +1 -1
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +22 -7
- package/dist/TreeList/TreeList.d.ts +1 -1
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +7 -2
- package/dist/Typeahead/BaseTypeahead.d.ts +35 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +119 -37
- package/dist/Typeahead/Typeahead.d.ts +8 -1
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +5 -2
- package/dist/Typeahead/TypeaheadItem.d.ts +1 -1
- package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
- package/dist/Typeahead/TypeaheadItem.js +7 -2
- package/dist/astryx.css +113 -11
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useFocusTrap.d.ts +7 -4
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +60 -95
- package/dist/hooks/useHotkeys.d.ts.map +1 -1
- package/dist/hooks/useHotkeys.js +3 -18
- package/dist/hooks/useMergedRefs.d.ts +18 -0
- package/dist/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/hooks/useMergedRefs.js +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/theme/Theme.d.ts.map +1 -1
- package/dist/theme/Theme.js +46 -10
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +24 -4
- package/dist/theme/generateThemeRules.d.ts +21 -0
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +26 -0
- package/dist/theme/syntax/tokens.d.ts +1 -1
- package/dist/theme/syntax/tokens.d.ts.map +1 -1
- package/dist/theme/syntax/tokens.js +5 -2
- package/dist/utils/groupItems.d.ts +5 -1
- package/dist/utils/groupItems.d.ts.map +1 -1
- package/dist/utils/groupItems.js +9 -9
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/isApplePlatform.d.ts +18 -0
- package/dist/utils/isApplePlatform.d.ts.map +1 -0
- package/dist/utils/isApplePlatform.js +37 -0
- package/dist/utils/sharedResizeObserver.d.ts.map +1 -1
- package/dist/utils/sharedResizeObserver.js +10 -1
- package/dist/utils/timeParser.d.ts +1 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +26 -12
- package/locales/af-ZA.json +6 -6
- package/locales/ar-SA.json +6 -6
- package/locales/ca-ES.json +5 -5
- package/locales/cs-CZ.json +6 -6
- package/locales/da-DK.json +6 -6
- package/locales/de-DE.json +6 -6
- package/locales/el-GR.json +6 -6
- package/locales/en.json +163 -11
- package/locales/es-ES.json +5 -5
- package/locales/fi-FI.json +6 -6
- package/locales/fr-FR.json +6 -6
- package/locales/he-IL.json +6 -6
- package/locales/hu-HU.json +6 -6
- package/locales/it-IT.json +6 -6
- package/locales/ja-JP.json +6 -6
- package/locales/ko-KR.json +6 -6
- package/locales/nl-NL.json +6 -6
- package/locales/no-NO.json +6 -6
- package/locales/pl-PL.json +6 -6
- package/locales/pseudo.json +114 -0
- package/locales/pt-BR.json +6 -6
- package/locales/pt-PT.json +6 -6
- package/locales/ro-RO.json +6 -6
- package/locales/ru-RU.json +6 -6
- package/locales/sr-SP.json +6 -6
- package/locales/sv-SE.json +6 -6
- package/locales/tr-TR.json +6 -6
- package/locales/uk-UA.json +6 -6
- package/locales/vi-VN.json +6 -6
- package/locales/zh-CN.json +6 -6
- package/locales/zh-TW.json +6 -6
- package/package.json +8 -3
- package/src/AlertDialog/AlertDialog.doc.mjs +114 -30
- package/src/AlertDialog/AlertDialog.test.tsx +211 -2
- package/src/AlertDialog/AlertDialog.tsx +62 -20
- package/src/AppShell/AppShell.tsx +3 -2
- package/src/AspectRatio/AspectRatio.doc.mjs +6 -3
- package/src/AspectRatio/AspectRatio.test.tsx +57 -10
- package/src/AspectRatio/AspectRatio.tsx +40 -1
- package/src/Avatar/Avatar.doc.mjs +14 -3
- package/src/Avatar/Avatar.test.tsx +97 -0
- package/src/Avatar/Avatar.tsx +125 -52
- package/src/Avatar/index.ts +2 -2
- package/src/AvatarGroup/AvatarGroup.doc.mjs +8 -2
- package/src/AvatarGroup/AvatarGroup.test.tsx +24 -0
- package/src/AvatarGroup/AvatarGroup.tsx +15 -6
- package/src/AvatarGroup/AvatarGroupContext.ts +5 -3
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +10 -4
- package/src/Banner/Banner.doc.mjs +22 -11
- package/src/Banner/Banner.test.tsx +177 -25
- package/src/Banner/Banner.tsx +93 -27
- package/src/BottomSheet/BottomSheet.test.tsx +123 -0
- package/src/BottomSheet/BottomSheet.tsx +17 -4
- package/src/BottomSheet/BottomSheetSwitcher.tsx +3 -2
- package/src/Breadcrumbs/BreadcrumbItem.tsx +9 -5
- package/src/Button/Button.doc.mjs +24 -1
- package/src/Button/Button.test.tsx +32 -4
- package/src/Button/Button.tsx +12 -5
- package/src/ButtonGroup/ButtonGroup.doc.mjs +10 -1
- package/src/ButtonGroup/ButtonGroup.test.tsx +404 -1
- package/src/ButtonGroup/ButtonGroup.tsx +23 -5
- package/src/Calendar/Calendar.doc.mjs +7 -6
- package/src/Calendar/Calendar.test.tsx +143 -0
- package/src/Calendar/Calendar.tsx +30 -26
- package/src/Calendar/getInitialFocusDate.test.ts +94 -0
- package/src/Calendar/getInitialFocusDate.ts +93 -0
- package/src/Calendar/styles.ts +49 -31
- package/src/Card/Card.doc.mjs +10 -7
- package/src/Card/Card.test.tsx +113 -19
- package/src/Card/Card.tsx +67 -89
- package/src/Card/index.ts +36 -1
- package/src/Carousel/Carousel.tsx +3 -2
- package/src/Chat/ChatComposerInput.tsx +5 -1
- package/src/Chat/ChatLayout.tsx +3 -2
- package/src/Chat/ChatMessageList.doc.mjs +9 -1
- package/src/Chat/ChatMessageList.test.tsx +46 -0
- package/src/Chat/ChatMessageList.tsx +28 -4
- package/src/Chat/ChatTokenizedText.tsx +17 -10
- package/src/Chat/useChatComposerTokens.ts +1 -1
- package/src/CheckboxInput/CheckboxInput.doc.mjs +2 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +15 -0
- package/src/CheckboxInput/CheckboxInput.tsx +8 -2
- package/src/ClickableCard/ClickableCard.tsx +3 -2
- package/src/CodeBlock/CodeBlock.doc.mjs +16 -4
- package/src/CodeBlock/CodeBlock.test.tsx +37 -0
- package/src/CodeBlock/CodeBlock.tsx +20 -4
- package/src/CodeBlock/highlightRanges.ts +1 -1
- package/src/CodeBlock/highlightStyles.ts +13 -13
- package/src/CommandPalette/CommandPaletteInput.tsx +3 -2
- package/src/CommandPalette/CommandPaletteItem.tsx +3 -2
- package/src/ComplexSelector/ComplexSelector.test.tsx +32 -0
- package/src/ComplexSelector/ComplexSelector.tsx +1 -3
- package/src/ContextMenu/ContextMenu.doc.mjs +5 -0
- package/src/ContextMenu/ContextMenu.tsx +4 -3
- package/src/DateInput/DateInput.doc.mjs +16 -0
- package/src/DateInput/DateInput.tsx +55 -2
- package/src/DateInput/DateInputTouch.test.tsx +146 -32
- package/src/DateInput/NativeDateField.test.tsx +635 -0
- package/src/DateInput/NativeDateField.tsx +641 -0
- package/src/DateInput/TouchDateField.tsx +108 -24
- package/src/DateInput/index.ts +1 -0
- package/src/DateInput/nativeDateSegments.ts +127 -0
- package/src/DateRangeInput/DateRangeInput.doc.mjs +2 -2
- package/src/DateRangeInput/DateRangeInput.test.tsx +22 -0
- package/src/DateRangeInput/DateRangeInput.tsx +4 -2
- package/src/DateTimeInput/DateTimeInput.doc.mjs +18 -0
- package/src/DateTimeInput/DateTimeInput.test.tsx +1088 -0
- package/src/DateTimeInput/DateTimeInput.tsx +556 -24
- package/src/DateTimeInput/index.ts +1 -0
- package/src/Dialog/Dialog.doc.mjs +8 -3
- package/src/Dialog/Dialog.test.tsx +429 -2
- package/src/Dialog/Dialog.tsx +133 -58
- package/src/DropdownMenu/DropdownMenu.doc.mjs +6 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +44 -10
- package/src/DropdownMenu/DropdownMenu.tsx +4 -13
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +8 -5
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +8 -11
- package/src/Field/Field.doc.mjs +13 -2
- package/src/Field/FieldLabel.test.tsx +29 -0
- package/src/Field/FieldLabel.tsx +7 -0
- package/src/Field/InputClearButton.test.tsx +15 -1
- package/src/Field/InputClearButton.tsx +28 -4
- package/src/FileInput/FileInput.tsx +3 -2
- package/src/Heading/Heading.test.tsx +23 -1
- package/src/Heading/Heading.tsx +6 -3
- package/src/HoverCard/HoverCard.doc.mjs +13 -2
- package/src/HoverCard/HoverCard.test.tsx +154 -4
- package/src/HoverCard/HoverCard.tsx +143 -3
- package/src/HoverCard/useHoverCard.tsx +104 -33
- package/src/Indicator/CheckboxIndicator.tsx +14 -8
- package/src/Indicator/Indicator.doc.mjs +2 -0
- package/src/Item/Item.tsx +5 -4
- package/src/Kbd/Kbd.tsx +2 -19
- package/src/Layer/LayerDepthContext.tsx +62 -0
- package/src/Layer/gestureCounter.ts +57 -0
- package/src/Layer/index.ts +9 -0
- package/src/Layer/layerDismissalFamilies.test.tsx +359 -0
- package/src/Layer/layerDismissalInvariants.test.tsx +417 -0
- package/src/Layer/layerStack.ts +362 -0
- package/src/Layer/useLayer.test.tsx +324 -15
- package/src/Layer/useLayer.tsx +164 -8
- package/src/Layer/useLayerDismissal.test.tsx +469 -0
- package/src/Layer/useLayerDismissal.ts +173 -0
- package/src/Layout/Layout.doc.mjs +2 -2
- package/src/Layout/__tests__/edgeCompensation.test.tsx +1 -1
- package/src/Lightbox/Lightbox.doc.mjs +12 -0
- package/src/Lightbox/Lightbox.tsx +124 -102
- package/src/Link/Link.doc.mjs +39 -0
- package/src/List/List.test.tsx +38 -0
- package/src/List/List.tsx +8 -1
- package/src/Markdown/Markdown.doc.mjs +5 -0
- package/src/Markdown/Markdown.test.tsx +37 -0
- package/src/Markdown/Markdown.tsx +16 -5
- package/src/Markdown/incremental.test.ts +16 -2
- package/src/Markdown/index.ts +1 -0
- package/src/Markdown/parser.perf.test.ts +96 -1
- package/src/Markdown/parser.test.ts +178 -2
- package/src/Markdown/parser.ts +253 -32
- package/src/MetadataList/MetadataList.test.tsx +75 -2
- package/src/MetadataList/MetadataListItem.tsx +5 -2
- package/src/MobileNav/MobileNav.tsx +62 -36
- package/src/MoreMenu/MoreMenu.doc.mjs +7 -1
- package/src/MultiSelector/MultiSelector.doc.mjs +49 -1
- package/src/MultiSelector/MultiSelector.test.tsx +311 -0
- package/src/MultiSelector/MultiSelector.tsx +151 -15
- package/src/MultiSelector/hooks.ts +9 -2
- package/src/MultiSelector/index.ts +1 -0
- package/src/NavIcon/NavIcon.doc.mjs +8 -2
- package/src/NavIcon/NavIcon.test.tsx +9 -0
- package/src/NavIcon/NavIcon.tsx +5 -1
- package/src/NavMenu/NavHeadingMenu.test.tsx +30 -0
- package/src/NavMenu/NavHeadingMenu.tsx +9 -5
- package/src/NumberInput/NumberInput.doc.mjs +31 -7
- package/src/NumberInput/NumberInput.test.tsx +436 -8
- package/src/NumberInput/NumberInput.tsx +62 -114
- package/src/NumberInput/numberInputCommit.test.ts +72 -0
- package/src/NumberInput/numberInputCommit.ts +103 -0
- package/src/NumberInput/numberParser.docblock.test.ts +234 -0
- package/src/NumberInput/numberParser.test.ts +222 -0
- package/src/NumberInput/numberParser.ts +403 -0
- package/src/Outline/Outline.tsx +3 -2
- package/src/OverflowList/OverflowList.tsx +3 -2
- package/src/Overlay/Overlay.tsx +3 -2
- package/src/Pagination/Pagination.test.tsx +3 -2
- package/src/Popover/Popover.test.tsx +14 -0
- package/src/Popover/Popover.tsx +1 -9
- package/src/Popover/usePopover.tsx +57 -32
- package/src/PowerSearch/PowerSearch.doc.mjs +160 -28
- package/src/PowerSearch/PowerSearch.test.tsx +240 -1
- package/src/PowerSearch/PowerSearch.tsx +34 -5
- package/src/PowerSearch/PowerSearchEditPopover.test.tsx +288 -0
- package/src/PowerSearch/PowerSearchEditPopover.tsx +29 -2
- package/src/PowerSearch/PowerSearchValueEditor.test.tsx +111 -1
- package/src/PowerSearch/PowerSearchValueEditor.tsx +124 -10
- package/src/PowerSearch/types.ts +2 -0
- package/src/PowerSearch/usePowerSearchSource.test.ts +82 -2
- package/src/PowerSearch/usePowerSearchSource.ts +13 -3
- package/src/ProgressBar/ProgressBar.doc.mjs +42 -6
- package/src/ProgressBar/ProgressBar.test.tsx +24 -0
- package/src/ProgressBar/ProgressBar.tsx +28 -8
- package/src/Resizable/ResizeHandle.tsx +3 -2
- package/src/SegmentedControl/SegmentedControl.tsx +3 -2
- package/src/SelectableCard/SelectableCard.doc.mjs +3 -0
- package/src/SelectableCard/SelectableCard.tsx +19 -2
- package/src/Selector/Selector.doc.mjs +26 -1
- package/src/Selector/Selector.test.tsx +346 -1
- package/src/Selector/Selector.tsx +148 -21
- package/src/Selector/hooks.ts +17 -2
- package/src/SideNav/SideNav.doc.mjs +6 -6
- package/src/SideNav/SideNav.tsx +4 -2
- package/src/SideNav/SideNavHeading.tsx +12 -12
- package/src/SideNav/SideNavItem.tsx +4 -2
- package/src/Slider/Slider.test.tsx +106 -1
- package/src/Slider/Slider.tsx +55 -3
- package/src/Spinner/Spinner.test.tsx +147 -1
- package/src/Spinner/Spinner.tsx +120 -101
- package/src/StatusDot/StatusDot.doc.mjs +8 -2
- package/src/StatusDot/StatusDot.test.tsx +9 -0
- package/src/StatusDot/StatusDot.tsx +7 -1
- package/src/Stepper/Step.doc.mjs +98 -0
- package/src/Stepper/Step.tsx +1638 -0
- package/src/Stepper/StepStatus.ts +26 -0
- package/src/Stepper/Stepper.doc.mjs +370 -0
- package/src/Stepper/Stepper.test.tsx +1024 -0
- package/src/Stepper/Stepper.tsx +258 -0
- package/src/Stepper/StepperContext.ts +71 -0
- package/src/Stepper/index.ts +18 -0
- package/src/Stepper/stepper.stylex.ts +19 -0
- package/src/Switch/Switch.doc.mjs +2 -0
- package/src/Switch/Switch.test.tsx +10 -0
- package/src/Switch/Switch.tsx +6 -2
- package/src/TabList/Tab.doc.mjs +13 -1
- package/src/TabList/Tab.tsx +67 -7
- package/src/TabList/TabList.doc.mjs +22 -6
- package/src/TabList/TabList.test.tsx +559 -0
- package/src/TabList/TabList.tsx +490 -22
- package/src/TabList/TabListContext.ts +13 -2
- package/src/TabList/TabMenu.tsx +3 -2
- package/src/TabList/index.ts +6 -2
- package/src/Table/BaseTable.tsx +12 -4
- package/src/Table/Table.doc.mjs +9 -2
- package/src/Table/Table.test.tsx +132 -14
- package/src/Table/Table.tsx +3 -8
- package/src/Table/TableBody.doc.mjs +40 -0
- package/src/Table/TableFooter.doc.mjs +40 -0
- package/src/Table/TableHeader.doc.mjs +40 -0
- package/src/Table/TableRow.tsx +16 -5
- package/src/Table/plugins/filtering/useTableFiltering.test.tsx +44 -6
- package/src/Table/plugins/filtering/useTableFiltering.tsx +100 -4
- package/src/Table/plugins/groupedRows/useTableGroupedRows-perf.test.tsx +112 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.test.tsx +100 -0
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +67 -12
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +34 -4
- package/src/Table/plugins/pagination/useTablePagination.tsx +35 -3
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +9 -2
- package/src/Table/plugins/rowStatus/useTableRowStatus.test.tsx +13 -7
- package/src/Table/plugins/rowStatus/useTableRowStatus.tsx +12 -3
- package/src/Table/plugins/selection/useTableSelection.test.tsx +138 -0
- package/src/Table/plugins/selection/useTableSelection.tsx +63 -7
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +1 -2
- package/src/Table/types.ts +22 -4
- package/src/Table/useBaseTablePlugins.ts +5 -0
- package/src/Table/useTableGroupedRows.doc.mjs +5 -4
- package/src/Table/useTablePagination.doc.mjs +7 -0
- package/src/Table/useTableRowStatus.doc.mjs +1 -1
- package/src/Table/useTableSelection.doc.mjs +31 -0
- package/src/Text/Text.test.tsx +67 -1
- package/src/Text/Text.tsx +6 -3
- package/src/TextArea/TextArea.doc.mjs +12 -2
- package/src/TextArea/TextArea.test.tsx +11 -0
- package/src/TextArea/TextArea.tsx +37 -24
- package/src/TextInput/TextInput.doc.mjs +10 -0
- package/src/TextInput/TextInput.tsx +3 -2
- package/src/Thumbnail/Thumbnail.doc.mjs +1 -1
- package/src/TimeInput/TimeInput.tsx +2 -2
- package/src/Timestamp/Timestamp.test.tsx +58 -0
- package/src/Timestamp/Timestamp.tsx +12 -10
- package/src/Toast/Toast.doc.mjs +26 -12
- package/src/Toast/Toast.tsx +28 -4
- package/src/Toast/ToastViewport.test.tsx +536 -8
- package/src/Toast/ToastViewport.tsx +81 -12
- package/src/Token/Token.test.tsx +95 -0
- package/src/Token/Token.tsx +15 -10
- package/src/Token/TokenLink.tsx +14 -5
- package/src/Tokenizer/Tokenizer.doc.mjs +43 -3
- package/src/Tokenizer/Tokenizer.test.tsx +161 -0
- package/src/Tokenizer/Tokenizer.tsx +53 -24
- package/src/Toolbar/Toolbar.doc.mjs +5 -0
- package/src/Tooltip/Tooltip.doc.mjs +5 -0
- package/src/Tooltip/Tooltip.test.tsx +32 -0
- package/src/Tooltip/Tooltip.tsx +5 -0
- package/src/Tooltip/useTooltip.tsx +47 -24
- package/src/TopNav/TopNavHeading.tsx +5 -4
- package/src/TopNav/TopNavMegaMenu.test.tsx +104 -0
- package/src/TopNav/TopNavMegaMenu.tsx +47 -5
- package/src/TopNav/TopNavMenu.test.tsx +133 -1
- package/src/TopNav/TopNavMenu.tsx +38 -7
- package/src/TreeList/TreeList.test.tsx +49 -0
- package/src/TreeList/TreeList.tsx +7 -2
- package/src/Typeahead/BaseTypeahead.doc.mjs +24 -0
- package/src/Typeahead/BaseTypeahead.tsx +181 -39
- package/src/Typeahead/Typeahead.doc.mjs +11 -0
- package/src/Typeahead/Typeahead.test.tsx +203 -0
- package/src/Typeahead/Typeahead.tsx +12 -2
- package/src/Typeahead/TypeaheadItem.test.tsx +43 -0
- package/src/Typeahead/TypeaheadItem.tsx +8 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useAnnounce.doc.mjs +96 -0
- package/src/hooks/useContainerReveal.doc.mjs +2 -2
- package/src/hooks/useDevWarning.doc.mjs +96 -0
- package/src/hooks/useFocusTrap.test.tsx +14 -0
- package/src/hooks/useFocusTrap.ts +62 -111
- package/src/hooks/useFocusTrapEscapeShim.test.tsx +165 -0
- package/src/hooks/useHotkeys.ts +3 -18
- package/src/hooks/useIndicatorFocusRing.doc.mjs +104 -0
- package/src/hooks/useInputStatusIcon.doc.mjs +142 -0
- package/src/hooks/useInteractiveRole.doc.mjs +119 -0
- package/src/hooks/useLongPress.doc.mjs +123 -0
- package/src/hooks/useMergedRefs.doc.mjs +79 -0
- package/src/hooks/useMergedRefs.test.tsx +62 -0
- package/src/hooks/useMergedRefs.ts +36 -0
- package/src/hooks/useTypeahead.doc.mjs +153 -0
- package/src/index.ts +1 -0
- package/src/raw-import.d.ts +14 -0
- package/src/theme/MediaTheme.doc.mjs +5 -5
- package/src/theme/Theme.test.tsx +104 -2
- package/src/theme/Theme.tsx +49 -14
- package/src/theme/defineTheme.test.ts +23 -0
- package/src/theme/derivedVarRegistry.test.ts +26 -3
- package/src/theme/derivedVarRegistry.ts +23 -4
- package/src/theme/generateThemeRules.test.ts +99 -1
- package/src/theme/generateThemeRules.ts +28 -0
- package/src/theme/syntax/tokens.ts +5 -2
- package/src/utils/groupItems.ts +12 -6
- package/src/utils/index.ts +1 -1
- package/src/utils/isApplePlatform.test.ts +61 -0
- package/src/utils/isApplePlatform.ts +37 -0
- package/src/utils/sharedResizeObserver.ts +10 -2
- package/src/utils/timeParser.test.ts +6 -1
- package/src/utils/timeParser.ts +35 -13
- package/src/__tests__/inputWidthContract.test.tsx +0 -69
package/src/Markdown/parser.ts
CHANGED
|
@@ -24,7 +24,15 @@ export type InlineNode =
|
|
|
24
24
|
| {type: 'citation'; sourceId: string}
|
|
25
25
|
| {type: 'break'};
|
|
26
26
|
|
|
27
|
-
export type BlockNode =
|
|
27
|
+
export type BlockNode = BlockNodeKind & {
|
|
28
|
+
/**
|
|
29
|
+
* Where this block came from in the source, when parsed with the
|
|
30
|
+
* `sourceRanges` option. Top-level blocks only.
|
|
31
|
+
*/
|
|
32
|
+
range?: SourceRange;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type BlockNodeKind =
|
|
28
36
|
| {type: 'heading'; level: 1 | 2 | 3 | 4 | 5 | 6; children: InlineNode[]}
|
|
29
37
|
| {type: 'paragraph'; children: InlineNode[]}
|
|
30
38
|
| {type: 'codeblock'; language: string; content: string}
|
|
@@ -47,6 +55,17 @@ export type BlockNode =
|
|
|
47
55
|
| {type: 'hr'}
|
|
48
56
|
| {type: 'image'; src: string; alt: string};
|
|
49
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Where a block sits in the source string handed to `parseMarkdown`:
|
|
60
|
+
* `source.slice(start, end)` is the block, and `end` excludes the block's
|
|
61
|
+
* trailing blank lines.
|
|
62
|
+
*
|
|
63
|
+
* An object rather than a `[start, end]` tuple so a second way of addressing
|
|
64
|
+
* the same block — line numbers, once a consumer needs them — can be added as
|
|
65
|
+
* optional fields without breaking anyone.
|
|
66
|
+
*/
|
|
67
|
+
export type SourceRange = {readonly start: number; readonly end: number};
|
|
68
|
+
|
|
50
69
|
export type ListItemNode = {checked?: boolean; children: BlockNode[]};
|
|
51
70
|
export type TableCellNode = {children: InlineNode[]};
|
|
52
71
|
export type TableAlignment = 'left' | 'center' | 'right' | null;
|
|
@@ -78,11 +97,28 @@ export type ParseOptions = {
|
|
|
78
97
|
* suffix is not rejected (Astryx accepts any plausible TLD shape).
|
|
79
98
|
*/
|
|
80
99
|
autolink?: 'gfm';
|
|
100
|
+
/**
|
|
101
|
+
* When true, every top-level block carries a `range` — the offsets it
|
|
102
|
+
* occupies in the string passed in. Lets a consumer that still holds the
|
|
103
|
+
* source slice the original markdown for a block instead of reconstructing
|
|
104
|
+
* it from the parsed node (or from the rendered DOM). Off by default: the
|
|
105
|
+
* field is absent unless asked for, so nothing that compares nodes changes.
|
|
106
|
+
*
|
|
107
|
+
* Blocks nested inside a list item or a blockquote do not carry one.
|
|
108
|
+
*/
|
|
109
|
+
sourceRanges?: boolean;
|
|
81
110
|
};
|
|
82
111
|
|
|
83
112
|
type ResolvedOptions = {
|
|
84
113
|
readonly sourceIds: ReadonlySet<string> | undefined;
|
|
85
114
|
readonly autolink: 'gfm' | undefined;
|
|
115
|
+
readonly sourceRanges?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Offset of this parse's input within the document the ranges are reported
|
|
118
|
+
* against. Internal only — the incremental parser parses slices and needs
|
|
119
|
+
* their blocks' ranges to come out absolute.
|
|
120
|
+
*/
|
|
121
|
+
readonly baseOffset?: number;
|
|
86
122
|
/**
|
|
87
123
|
* Link reference definitions (`[label]: url`) collected from the whole
|
|
88
124
|
* document, keyed by normalized label. Internal only — populated by the
|
|
@@ -109,7 +145,11 @@ function resolveOptions(
|
|
|
109
145
|
return {sourceIds: arg as ReadonlySet<string>, autolink: undefined};
|
|
110
146
|
}
|
|
111
147
|
const opts = arg as ParseOptions;
|
|
112
|
-
return {
|
|
148
|
+
return {
|
|
149
|
+
sourceIds: opts.sourceIds,
|
|
150
|
+
autolink: opts.autolink,
|
|
151
|
+
sourceRanges: opts.sourceRanges,
|
|
152
|
+
};
|
|
113
153
|
}
|
|
114
154
|
|
|
115
155
|
// ---------------------------------------------------------------------------
|
|
@@ -174,6 +214,11 @@ function matchLinkDefinition(
|
|
|
174
214
|
function extractLinkDefinitions(input: string): {
|
|
175
215
|
defs: ReadonlyMap<string, string>;
|
|
176
216
|
cleaned: string;
|
|
217
|
+
/**
|
|
218
|
+
* For each line of `cleaned`, the line of `input` it came from. Undefined
|
|
219
|
+
* when nothing was stripped and the two are the same text.
|
|
220
|
+
*/
|
|
221
|
+
lineMap?: number[];
|
|
177
222
|
} {
|
|
178
223
|
const lines = input.split('\n');
|
|
179
224
|
const defs = new Map<string, string>();
|
|
@@ -235,8 +280,14 @@ function extractLinkDefinitions(input: string): {
|
|
|
235
280
|
if (defs.size === 0) {
|
|
236
281
|
return {defs, cleaned: input};
|
|
237
282
|
}
|
|
238
|
-
const
|
|
239
|
-
|
|
283
|
+
const lineMap: number[] = [];
|
|
284
|
+
for (let index = 0; index < lines.length; index++) {
|
|
285
|
+
if (keep[index]) {
|
|
286
|
+
lineMap.push(index);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const cleaned = lineMap.map(index => lines[index]).join('\n');
|
|
290
|
+
return {defs, cleaned, lineMap};
|
|
240
291
|
}
|
|
241
292
|
|
|
242
293
|
/** Order-independent signature of a link-definition set, for cache checks. */
|
|
@@ -318,7 +369,7 @@ function matchReferenceImage(
|
|
|
318
369
|
const rawLabel = text.slice(altClose + 2, labelClose);
|
|
319
370
|
const label = rawLabel === '' ? alt : rawLabel;
|
|
320
371
|
const src = linkDefs.get(normalizeLinkLabel(label));
|
|
321
|
-
if (src != null) {
|
|
372
|
+
if (src != null && isSafeUrl(src)) {
|
|
322
373
|
return {node: {type: 'image', src, alt}, end: labelClose + 1};
|
|
323
374
|
}
|
|
324
375
|
// No match — fall back to a shortcut `![alt]`.
|
|
@@ -328,7 +379,7 @@ function matchReferenceImage(
|
|
|
328
379
|
return null;
|
|
329
380
|
}
|
|
330
381
|
const src = linkDefs.get(normalizeLinkLabel(alt));
|
|
331
|
-
if (src == null) {
|
|
382
|
+
if (src == null || !isSafeUrl(src)) {
|
|
332
383
|
return null;
|
|
333
384
|
}
|
|
334
385
|
return {node: {type: 'image', src, alt}, end: altClose + 1};
|
|
@@ -1042,6 +1093,16 @@ function isTableSeparator(line: string): boolean {
|
|
|
1042
1093
|
return nonEmpty.length > 0 && nonEmpty.every(cell => /^:?-+:?$/.test(cell));
|
|
1043
1094
|
}
|
|
1044
1095
|
|
|
1096
|
+
/**
|
|
1097
|
+
* The same options for content parsed out of an enclosing block. Ranges are a
|
|
1098
|
+
* top-level contract: a list item's or a blockquote's children are parsed from
|
|
1099
|
+
* text the caller reassembled (markers and `>` prefixes stripped), so an
|
|
1100
|
+
* offset into it would not address the document.
|
|
1101
|
+
*/
|
|
1102
|
+
function nested(opts: ResolvedOptions): ResolvedOptions {
|
|
1103
|
+
return opts.sourceRanges ? {...opts, sourceRanges: false} : opts;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1045
1106
|
/**
|
|
1046
1107
|
* Returns true when a line could start a new block — used to stop paragraph
|
|
1047
1108
|
* continuation. Every regex here uses bounded or single-class quantifiers
|
|
@@ -1213,7 +1274,7 @@ function parseList(
|
|
|
1213
1274
|
itemText += '\n' + deindented.join('\n');
|
|
1214
1275
|
}
|
|
1215
1276
|
|
|
1216
|
-
items.push({checked, children: parseMarkdownImpl(itemText, opts)});
|
|
1277
|
+
items.push({checked, children: parseMarkdownImpl(itemText, nested(opts))});
|
|
1217
1278
|
|
|
1218
1279
|
// CommonMark loose list: blank line(s) between items of the same style
|
|
1219
1280
|
// and indent still form one list. Skip the blanks and continue if the
|
|
@@ -1274,7 +1335,7 @@ function parseMarkdownImpl(
|
|
|
1274
1335
|
// definitions win on conflict, matching CommonMark's first-definition-wins
|
|
1275
1336
|
// in document order; locally-nested definitions still resolve within this
|
|
1276
1337
|
// parse.
|
|
1277
|
-
const {defs, cleaned} = extractLinkDefinitions(input);
|
|
1338
|
+
const {defs, cleaned, lineMap} = extractLinkDefinitions(input);
|
|
1278
1339
|
const inherited = baseOpts.linkDefs;
|
|
1279
1340
|
let linkDefs: ReadonlyMap<string, string> | undefined;
|
|
1280
1341
|
if (defs.size === 0) {
|
|
@@ -1288,9 +1349,25 @@ function parseMarkdownImpl(
|
|
|
1288
1349
|
linkDefs != null ? {...baseOpts, linkDefs} : baseOpts;
|
|
1289
1350
|
const lines = cleaned.split('\n');
|
|
1290
1351
|
const blocks: BlockNode[] = [];
|
|
1352
|
+
// The line each block started on, parallel to `blocks`. Only collected when
|
|
1353
|
+
// ranges were asked for; a block's end is resolved after the loop, since the
|
|
1354
|
+
// branch that produced it has already moved `index` past whatever it read.
|
|
1355
|
+
const blockStartLines: number[] | null = opts.sourceRanges ? [] : null;
|
|
1356
|
+
// Set only by a block that consumes blank lines as content, where the
|
|
1357
|
+
// positional end derivation would trim them away.
|
|
1358
|
+
const blockEndLines: (number | undefined)[] | null = opts.sourceRanges
|
|
1359
|
+
? []
|
|
1360
|
+
: null;
|
|
1361
|
+
let blockStartLine = 0;
|
|
1362
|
+
const pushBlock = (node: BlockNode, endLine?: number) => {
|
|
1363
|
+
blocks.push(node);
|
|
1364
|
+
blockStartLines?.push(blockStartLine);
|
|
1365
|
+
blockEndLines?.push(endLine);
|
|
1366
|
+
};
|
|
1291
1367
|
let index = 0;
|
|
1292
1368
|
|
|
1293
1369
|
while (index < lines.length) {
|
|
1370
|
+
blockStartLine = index;
|
|
1294
1371
|
const line = lines[index];
|
|
1295
1372
|
if (line.trim() === '') {
|
|
1296
1373
|
index++;
|
|
@@ -1309,14 +1386,20 @@ function parseMarkdownImpl(
|
|
|
1309
1386
|
index++;
|
|
1310
1387
|
}
|
|
1311
1388
|
index++; // skip closing fence
|
|
1312
|
-
|
|
1389
|
+
// A fence owns its blank lines, and an unterminated one (mid-stream)
|
|
1390
|
+
// can end on them, so it states its own end rather than letting the
|
|
1391
|
+
// positional derivation trim them off.
|
|
1392
|
+
pushBlock(
|
|
1393
|
+
{type: 'codeblock', language, content: codeLines.join('\n')},
|
|
1394
|
+
Math.min(index, lines.length) - 1,
|
|
1395
|
+
);
|
|
1313
1396
|
continue;
|
|
1314
1397
|
}
|
|
1315
1398
|
|
|
1316
1399
|
// --- Heading ---
|
|
1317
1400
|
const headingMatch = line.match(/^(#{1,6}) +(.*)/);
|
|
1318
1401
|
if (headingMatch) {
|
|
1319
|
-
|
|
1402
|
+
pushBlock({
|
|
1320
1403
|
type: 'heading',
|
|
1321
1404
|
level: headingMatch[1].length as 1 | 2 | 3 | 4 | 5 | 6,
|
|
1322
1405
|
children: parseInlineEntry(headingMatch[2], opts),
|
|
@@ -1327,15 +1410,21 @@ function parseMarkdownImpl(
|
|
|
1327
1410
|
|
|
1328
1411
|
// --- HR (must precede list check to handle `- - -`, `* * *`, `_ _ _`) ---
|
|
1329
1412
|
if (isHorizontalRule(line)) {
|
|
1330
|
-
|
|
1413
|
+
pushBlock({type: 'hr'});
|
|
1331
1414
|
index++;
|
|
1332
1415
|
continue;
|
|
1333
1416
|
}
|
|
1334
1417
|
|
|
1335
1418
|
// --- Standalone image ---
|
|
1419
|
+
// An unsafe src falls through to the paragraph path and renders as
|
|
1420
|
+
// literal text, the same rule the inline image path applies.
|
|
1336
1421
|
const imageMatch = line.match(/^!\[([^\]]*)\]\(([^)]+)\)/);
|
|
1337
|
-
if (
|
|
1338
|
-
|
|
1422
|
+
if (
|
|
1423
|
+
imageMatch &&
|
|
1424
|
+
line.trim() === imageMatch[0] &&
|
|
1425
|
+
isSafeUrl(imageMatch[2])
|
|
1426
|
+
) {
|
|
1427
|
+
pushBlock({type: 'image', alt: imageMatch[1], src: imageMatch[2]});
|
|
1339
1428
|
index++;
|
|
1340
1429
|
continue;
|
|
1341
1430
|
}
|
|
@@ -1347,7 +1436,7 @@ function parseMarkdownImpl(
|
|
|
1347
1436
|
isTableSeparator(lines[index + 1])
|
|
1348
1437
|
) {
|
|
1349
1438
|
const tableResult = parseTable(lines, index, opts);
|
|
1350
|
-
|
|
1439
|
+
pushBlock(tableResult.node);
|
|
1351
1440
|
index = tableResult.nextIndex;
|
|
1352
1441
|
continue;
|
|
1353
1442
|
}
|
|
@@ -1362,9 +1451,9 @@ function parseMarkdownImpl(
|
|
|
1362
1451
|
quoteLines.push(lines[index].replace(/^> ?/, ''));
|
|
1363
1452
|
index++;
|
|
1364
1453
|
}
|
|
1365
|
-
|
|
1454
|
+
pushBlock({
|
|
1366
1455
|
type: 'blockquote',
|
|
1367
|
-
children: parseMarkdownImpl(quoteLines.join('\n'), opts),
|
|
1456
|
+
children: parseMarkdownImpl(quoteLines.join('\n'), nested(opts)),
|
|
1368
1457
|
});
|
|
1369
1458
|
continue;
|
|
1370
1459
|
}
|
|
@@ -1372,7 +1461,7 @@ function parseMarkdownImpl(
|
|
|
1372
1461
|
// --- Unordered list ---
|
|
1373
1462
|
if (/^ {0,9}[-*+] /.test(line)) {
|
|
1374
1463
|
const listResult = parseList(lines, index, false, opts);
|
|
1375
|
-
|
|
1464
|
+
pushBlock(listResult.node);
|
|
1376
1465
|
index = listResult.nextIndex;
|
|
1377
1466
|
continue;
|
|
1378
1467
|
}
|
|
@@ -1380,7 +1469,7 @@ function parseMarkdownImpl(
|
|
|
1380
1469
|
// --- Ordered list ---
|
|
1381
1470
|
if (/^ {0,9}\d+[.)] /.test(line)) {
|
|
1382
1471
|
const listResult = parseList(lines, index, true, opts);
|
|
1383
|
-
|
|
1472
|
+
pushBlock(listResult.node);
|
|
1384
1473
|
index = listResult.nextIndex;
|
|
1385
1474
|
continue;
|
|
1386
1475
|
}
|
|
@@ -1396,14 +1485,76 @@ function parseMarkdownImpl(
|
|
|
1396
1485
|
paraLines.push(lines[index]);
|
|
1397
1486
|
index++;
|
|
1398
1487
|
}
|
|
1399
|
-
|
|
1488
|
+
pushBlock({
|
|
1400
1489
|
type: 'paragraph',
|
|
1401
1490
|
children: parseInlineEntry(paraLines.join('\n'), opts),
|
|
1402
1491
|
});
|
|
1403
1492
|
}
|
|
1493
|
+
if (blockStartLines != null) {
|
|
1494
|
+
stampSourceRanges(
|
|
1495
|
+
blocks,
|
|
1496
|
+
blockStartLines,
|
|
1497
|
+
blockEndLines ?? [],
|
|
1498
|
+
lines,
|
|
1499
|
+
lineMap,
|
|
1500
|
+
input,
|
|
1501
|
+
opts,
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
1404
1504
|
return blocks;
|
|
1405
1505
|
}
|
|
1406
1506
|
|
|
1507
|
+
/**
|
|
1508
|
+
* Give each block the offsets it occupies in the original input.
|
|
1509
|
+
*
|
|
1510
|
+
* Blocks are contiguous and in source order, so a block runs from its own
|
|
1511
|
+
* first line to the line before the next block starts, minus the blank lines
|
|
1512
|
+
* between them. Offsets are computed against the *input*, not the text the
|
|
1513
|
+
* block loop saw: link reference definitions are stripped before parsing, and
|
|
1514
|
+
* `lineMap` says which input line each surviving line came from.
|
|
1515
|
+
*/
|
|
1516
|
+
function stampSourceRanges(
|
|
1517
|
+
blocks: BlockNode[],
|
|
1518
|
+
blockStartLines: number[],
|
|
1519
|
+
blockEndLines: (number | undefined)[],
|
|
1520
|
+
lines: string[],
|
|
1521
|
+
lineMap: number[] | undefined,
|
|
1522
|
+
input: string,
|
|
1523
|
+
opts: ResolvedOptions,
|
|
1524
|
+
): void {
|
|
1525
|
+
const base = opts.baseOffset ?? 0;
|
|
1526
|
+
// Offset of the first character of every line of the input.
|
|
1527
|
+
const inputLineStarts = [0];
|
|
1528
|
+
for (let i = 0; i < input.length; i++) {
|
|
1529
|
+
if (input[i] === '\n') {
|
|
1530
|
+
inputLineStarts.push(i + 1);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
// Stripping removes whole lines and never edits one, so a parsed line's
|
|
1534
|
+
// length is its input line's length.
|
|
1535
|
+
const lineStart = (line: number): number =>
|
|
1536
|
+
base + inputLineStarts[lineMap != null ? lineMap[line] : line];
|
|
1537
|
+
|
|
1538
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
1539
|
+
const startLine = blockStartLines[i];
|
|
1540
|
+
let endLine = blockEndLines[i];
|
|
1541
|
+
if (endLine == null) {
|
|
1542
|
+
const nextStart =
|
|
1543
|
+
i + 1 < blocks.length ? blockStartLines[i + 1] : lines.length;
|
|
1544
|
+
endLine = nextStart - 1;
|
|
1545
|
+
while (endLine > startLine && lines[endLine].trim() === '') {
|
|
1546
|
+
endLine--;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
// Exactly the block's own lines, verbatim — a CRLF document's trailing
|
|
1550
|
+
// `\r` included, since the parser reads it as part of the line too and a
|
|
1551
|
+
// range that dropped it would slice to something that re-parses
|
|
1552
|
+
// differently.
|
|
1553
|
+
const end = lineStart(endLine) + lines[endLine].length;
|
|
1554
|
+
blocks[i] = {...blocks[i], range: {start: lineStart(startLine), end}};
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1407
1558
|
// ---------------------------------------------------------------------------
|
|
1408
1559
|
// Incremental parsing
|
|
1409
1560
|
// ---------------------------------------------------------------------------
|
|
@@ -1420,6 +1571,12 @@ export interface IncrementalState {
|
|
|
1420
1571
|
* with newly-arriving content.
|
|
1421
1572
|
*/
|
|
1422
1573
|
autolink?: 'gfm';
|
|
1574
|
+
/**
|
|
1575
|
+
* The `sourceRanges` option the cached `settledBlocks` were parsed with.
|
|
1576
|
+
* Flipping it invalidates them the same way `autolink` does: they either
|
|
1577
|
+
* lack the ranges the caller now asks for, or carry ones it did not.
|
|
1578
|
+
*/
|
|
1579
|
+
sourceRanges?: boolean;
|
|
1423
1580
|
/**
|
|
1424
1581
|
* Signature of the link reference definitions the cached `settledBlocks`
|
|
1425
1582
|
* were parsed with. Definitions are document-global and typically arrive
|
|
@@ -1435,12 +1592,26 @@ export function createIncrementalState(): IncrementalState {
|
|
|
1435
1592
|
|
|
1436
1593
|
/**
|
|
1437
1594
|
* Find the line-index of the last blank line that is NOT inside a fenced code
|
|
1438
|
-
* block
|
|
1595
|
+
* block, and report whether a fence is still open at the end of the input.
|
|
1596
|
+
* Returns -1 when nothing is settled.
|
|
1597
|
+
*
|
|
1598
|
+
* This index must never move backwards as more of the document arrives. The
|
|
1599
|
+
* caller's cache is keyed on the settled text staying a prefix of what it was,
|
|
1600
|
+
* so a boundary that retracts by one line costs a re-parse of every block in
|
|
1601
|
+
* the document. Two things used to retract it: a blank last line, which is
|
|
1602
|
+
* just the newline the stream has written so far and stops being blank as soon
|
|
1603
|
+
* as the next chunk appends to it; and an open fence, which used to collapse
|
|
1604
|
+
* the boundary to -1 even though the content before the fence opened cannot be
|
|
1605
|
+
* changed by anything typed inside it.
|
|
1439
1606
|
*/
|
|
1440
|
-
function findSettledBoundary(lines: string[]):
|
|
1607
|
+
function findSettledBoundary(lines: string[]): {
|
|
1608
|
+
boundary: number;
|
|
1609
|
+
openFence: boolean;
|
|
1610
|
+
} {
|
|
1441
1611
|
let inFence = false;
|
|
1442
1612
|
let fenceMarker = '';
|
|
1443
1613
|
let lastBoundary = -1;
|
|
1614
|
+
let boundaryBeforeFence = -1;
|
|
1444
1615
|
|
|
1445
1616
|
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
1446
1617
|
const line = lines[lineIndex];
|
|
@@ -1451,6 +1622,7 @@ function findSettledBoundary(lines: string[]): number {
|
|
|
1451
1622
|
if (!inFence) {
|
|
1452
1623
|
inFence = true;
|
|
1453
1624
|
fenceMarker = fenceMatch[1];
|
|
1625
|
+
boundaryBeforeFence = lastBoundary;
|
|
1454
1626
|
} else if (
|
|
1455
1627
|
fenceMatch[1].startsWith(fenceMarker[0]) &&
|
|
1456
1628
|
fenceMatch[1].length >= fenceMarker.length
|
|
@@ -1460,12 +1632,20 @@ function findSettledBoundary(lines: string[]): number {
|
|
|
1460
1632
|
}
|
|
1461
1633
|
}
|
|
1462
1634
|
|
|
1463
|
-
if (
|
|
1635
|
+
if (
|
|
1636
|
+
!inFence &&
|
|
1637
|
+
line.trim() === '' &&
|
|
1638
|
+
lineIndex > 0 &&
|
|
1639
|
+
lineIndex < lines.length - 1
|
|
1640
|
+
) {
|
|
1464
1641
|
lastBoundary = lineIndex;
|
|
1465
1642
|
}
|
|
1466
1643
|
}
|
|
1467
1644
|
|
|
1468
|
-
return
|
|
1645
|
+
return {
|
|
1646
|
+
boundary: inFence ? boundaryBeforeFence : lastBoundary,
|
|
1647
|
+
openFence: inFence,
|
|
1648
|
+
};
|
|
1469
1649
|
}
|
|
1470
1650
|
|
|
1471
1651
|
/**
|
|
@@ -1689,6 +1869,15 @@ function trimUnsettledStructural(text: string): string {
|
|
|
1689
1869
|
return lines.join('\n');
|
|
1690
1870
|
}
|
|
1691
1871
|
|
|
1872
|
+
/**
|
|
1873
|
+
* The same options, for parsing a slice that starts at `offset` of the
|
|
1874
|
+
* document — so the slice's blocks report ranges into the whole document
|
|
1875
|
+
* rather than into the slice.
|
|
1876
|
+
*/
|
|
1877
|
+
function atOffset(opts: ResolvedOptions, offset: number): ResolvedOptions {
|
|
1878
|
+
return opts.sourceRanges ? {...opts, baseOffset: offset} : opts;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1692
1881
|
/**
|
|
1693
1882
|
* Concatenate freshly-parsed delta blocks with previously-settled blocks,
|
|
1694
1883
|
* merging adjacent same-style lists into a single loose list. The boundary
|
|
@@ -1718,6 +1907,11 @@ function mergeSettledBlocks(
|
|
|
1718
1907
|
delimiter: prevLast.delimiter,
|
|
1719
1908
|
loose: true,
|
|
1720
1909
|
items: [...prevLast.items, ...deltaFirst.items],
|
|
1910
|
+
// One list now, so one range: from where the first half started to
|
|
1911
|
+
// where the second half ended.
|
|
1912
|
+
...(prevLast.range != null && deltaFirst.range != null
|
|
1913
|
+
? {range: {start: prevLast.range.start, end: deltaFirst.range.end}}
|
|
1914
|
+
: null),
|
|
1721
1915
|
};
|
|
1722
1916
|
return [...prev.slice(0, -1), merged, ...delta.slice(1)];
|
|
1723
1917
|
}
|
|
@@ -1740,15 +1934,19 @@ export function parseMarkdownIncremental(
|
|
|
1740
1934
|
arg?: ReadonlySet<string> | ParseOptions,
|
|
1741
1935
|
): BlockNode[] {
|
|
1742
1936
|
const opts = resolveOptions(arg);
|
|
1743
|
-
// Invalidate cache when the autolink option flips — cached
|
|
1744
|
-
// were parsed with the previous setting and would otherwise
|
|
1745
|
-
// unchanged.
|
|
1746
|
-
if (
|
|
1937
|
+
// Invalidate cache when the autolink or sourceRanges option flips — cached
|
|
1938
|
+
// settled blocks were parsed with the previous setting and would otherwise
|
|
1939
|
+
// be reused unchanged.
|
|
1940
|
+
if (
|
|
1941
|
+
state.autolink !== opts.autolink ||
|
|
1942
|
+
Boolean(state.sourceRanges) !== Boolean(opts.sourceRanges)
|
|
1943
|
+
) {
|
|
1747
1944
|
state.prevInput = '';
|
|
1748
1945
|
state.settledText = '';
|
|
1749
1946
|
state.settledBlocks = [];
|
|
1750
1947
|
state.settledUpTo = 0;
|
|
1751
1948
|
state.autolink = opts.autolink;
|
|
1949
|
+
state.sourceRanges = opts.sourceRanges;
|
|
1752
1950
|
}
|
|
1753
1951
|
if (input === '') {
|
|
1754
1952
|
state.prevInput = '';
|
|
@@ -1776,17 +1974,23 @@ export function parseMarkdownIncremental(
|
|
|
1776
1974
|
linkDefs.size > 0 ? {...opts, linkDefs} : opts;
|
|
1777
1975
|
|
|
1778
1976
|
const lines = input.split('\n');
|
|
1779
|
-
const boundary = findSettledBoundary(lines);
|
|
1977
|
+
const {boundary, openFence} = findSettledBoundary(lines);
|
|
1780
1978
|
|
|
1781
1979
|
if (boundary < 0) {
|
|
1782
|
-
//
|
|
1980
|
+
// Nothing settled yet — no blank line, or a fence opened before the first
|
|
1981
|
+
// one — so there is no prefix to keep and the whole input is re-parsed.
|
|
1783
1982
|
state.prevInput = input;
|
|
1784
1983
|
return parseMarkdownImpl(input, parseOpts);
|
|
1785
1984
|
}
|
|
1786
1985
|
|
|
1787
1986
|
const settledText = lines.slice(0, boundary).join('\n');
|
|
1788
1987
|
const unsettledRaw = lines.slice(boundary).join('\n').trim();
|
|
1789
|
-
|
|
1988
|
+
// Structural trimming holds back lines that look like an incomplete list or
|
|
1989
|
+
// table, which inside a fence is ordinary code: a TypeScript union or a `- `
|
|
1990
|
+
// would disappear from the code block as it streams.
|
|
1991
|
+
const unsettledText = openFence
|
|
1992
|
+
? unsettledRaw
|
|
1993
|
+
: trimUnsettledStructural(unsettledRaw);
|
|
1790
1994
|
|
|
1791
1995
|
let settledBlocks: BlockNode[];
|
|
1792
1996
|
|
|
@@ -1799,15 +2003,32 @@ export function parseMarkdownIncremental(
|
|
|
1799
2003
|
) {
|
|
1800
2004
|
// Settled portion grew — parse only the new delta
|
|
1801
2005
|
const delta = settledText.slice(state.settledText.length);
|
|
1802
|
-
const deltaBlocks = parseMarkdownImpl(
|
|
2006
|
+
const deltaBlocks = parseMarkdownImpl(
|
|
2007
|
+
delta,
|
|
2008
|
+
atOffset(parseOpts, state.settledText.length),
|
|
2009
|
+
);
|
|
1803
2010
|
settledBlocks = mergeSettledBlocks(state.settledBlocks, deltaBlocks);
|
|
1804
2011
|
} else {
|
|
1805
2012
|
// Content before the boundary changed — full re-parse of settled portion
|
|
1806
2013
|
settledBlocks = parseMarkdownImpl(settledText, parseOpts);
|
|
1807
2014
|
}
|
|
1808
2015
|
|
|
2016
|
+
// The unsettled tail is trimmed before parsing, so its offset in the
|
|
2017
|
+
// document is where that trimmed text actually starts — not the boundary,
|
|
2018
|
+
// which is a line index. If it somehow can't be located, parse it without
|
|
2019
|
+
// ranges rather than report wrong ones. Only worth searching for when
|
|
2020
|
+
// ranges were asked for: this runs on every streamed chunk.
|
|
2021
|
+
const unsettledStart =
|
|
2022
|
+
unsettledText && opts.sourceRanges
|
|
2023
|
+
? input.indexOf(unsettledText, settledText.length)
|
|
2024
|
+
: -1;
|
|
1809
2025
|
const unsettledBlocks = unsettledText
|
|
1810
|
-
? parseMarkdownImpl(
|
|
2026
|
+
? parseMarkdownImpl(
|
|
2027
|
+
unsettledText,
|
|
2028
|
+
unsettledStart >= 0
|
|
2029
|
+
? atOffset(parseOpts, unsettledStart)
|
|
2030
|
+
: nested(parseOpts),
|
|
2031
|
+
)
|
|
1811
2032
|
: [];
|
|
1812
2033
|
|
|
1813
2034
|
state.settledText = settledText;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
import {describe, it, expect} from 'vitest';
|
|
4
|
-
import {render, screen} from '@testing-library/react';
|
|
3
|
+
import {describe, it, expect, vi} from 'vitest';
|
|
4
|
+
import {render, screen, fireEvent} from '@testing-library/react';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
6
6
|
import {MetadataList} from './MetadataList';
|
|
7
7
|
import {MetadataListItem} from './MetadataListItem';
|
|
@@ -223,3 +223,76 @@ describe('MetadataListItem', () => {
|
|
|
223
223
|
expect(wrapper?.querySelector('dd')).toBeInTheDocument();
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
|
+
|
|
227
|
+
describe('MetadataListItem pass-through props', () => {
|
|
228
|
+
it('forwards pass-through props to the item element', () => {
|
|
229
|
+
render(
|
|
230
|
+
<MetadataList>
|
|
231
|
+
<MetadataListItem
|
|
232
|
+
label="Owner"
|
|
233
|
+
aria-label="Owner field"
|
|
234
|
+
id="owner"
|
|
235
|
+
data-source="crm"
|
|
236
|
+
data-testid="item">
|
|
237
|
+
Alice
|
|
238
|
+
</MetadataListItem>
|
|
239
|
+
</MetadataList>,
|
|
240
|
+
);
|
|
241
|
+
const item = screen.getByTestId('item-label');
|
|
242
|
+
expect(item).toHaveAttribute('aria-label', 'Owner field');
|
|
243
|
+
expect(item).toHaveAttribute('id', 'owner');
|
|
244
|
+
expect(item).toHaveAttribute('data-source', 'crm');
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('forwards pass-through props in the stacked layout', () => {
|
|
248
|
+
render(
|
|
249
|
+
<MetadataList orientation="horizontal">
|
|
250
|
+
<MetadataListItem label="Owner" id="owner-stacked" data-testid="item">
|
|
251
|
+
Alice
|
|
252
|
+
</MetadataListItem>
|
|
253
|
+
</MetadataList>,
|
|
254
|
+
);
|
|
255
|
+
expect(screen.getByTestId('item')).toHaveAttribute('id', 'owner-stacked');
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('MetadataListItem pass-through target', () => {
|
|
260
|
+
it('lands pass-through props on the <dt> in the inline layout, where the ref also goes', () => {
|
|
261
|
+
const handleClick = vi.fn();
|
|
262
|
+
render(
|
|
263
|
+
<MetadataList>
|
|
264
|
+
<MetadataListItem
|
|
265
|
+
label="Owner"
|
|
266
|
+
onClick={handleClick}
|
|
267
|
+
data-testid="item">
|
|
268
|
+
Alice
|
|
269
|
+
</MetadataListItem>
|
|
270
|
+
</MetadataList>,
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const label = screen.getByTestId('item-label');
|
|
274
|
+
expect(label.tagName).toBe('DT');
|
|
275
|
+
fireEvent.click(label);
|
|
276
|
+
expect(handleClick).toHaveBeenCalledOnce();
|
|
277
|
+
|
|
278
|
+
fireEvent.click(screen.getByTestId('item-value'));
|
|
279
|
+
expect(handleClick).toHaveBeenCalledOnce();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('lands them on the wrapper in the stacked layout, so both halves are covered', () => {
|
|
283
|
+
const handleClick = vi.fn();
|
|
284
|
+
render(
|
|
285
|
+
<MetadataList orientation="horizontal">
|
|
286
|
+
<MetadataListItem
|
|
287
|
+
label="Owner"
|
|
288
|
+
onClick={handleClick}
|
|
289
|
+
data-testid="item">
|
|
290
|
+
Alice
|
|
291
|
+
</MetadataListItem>
|
|
292
|
+
</MetadataList>,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
fireEvent.click(screen.getByText('Alice'));
|
|
296
|
+
expect(handleClick).toHaveBeenCalledOnce();
|
|
297
|
+
});
|
|
298
|
+
});
|
|
@@ -144,6 +144,7 @@ export function MetadataListItem({
|
|
|
144
144
|
style,
|
|
145
145
|
'data-testid': testId,
|
|
146
146
|
ref,
|
|
147
|
+
...rest
|
|
147
148
|
}: MetadataListItemProps) {
|
|
148
149
|
const ctx = use(MetadataListContext);
|
|
149
150
|
const labelPosition = ctx?.labelConfig.position ?? 'start';
|
|
@@ -170,7 +171,8 @@ export function MetadataListItem({
|
|
|
170
171
|
stylex.props(styles.stackedWrapper, xstyle),
|
|
171
172
|
className,
|
|
172
173
|
style,
|
|
173
|
-
)}
|
|
174
|
+
)}
|
|
175
|
+
{...rest}>
|
|
174
176
|
<dt {...stylex.props(styles.stackedLabel)}>{labelContent}</dt>
|
|
175
177
|
<dd {...stylex.props(styles.stackedValue)}>{children}</dd>
|
|
176
178
|
</div>
|
|
@@ -188,7 +190,8 @@ export function MetadataListItem({
|
|
|
188
190
|
stylex.props(styles.label, xstyle),
|
|
189
191
|
className,
|
|
190
192
|
style,
|
|
191
|
-
)}
|
|
193
|
+
)}
|
|
194
|
+
{...rest}>
|
|
192
195
|
{labelContent}
|
|
193
196
|
</dt>
|
|
194
197
|
<dd
|