@lobehub/ui 4.33.4 → 4.34.1
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/README.md +3 -3
- package/es/A/index.mjs.map +1 -1
- package/es/Accordion/Accordion.d.mts +2 -2
- package/es/Accordion/Accordion.mjs +1 -1
- package/es/Accordion/Accordion.mjs.map +1 -1
- package/es/Accordion/AccordionItem.d.mts +2 -2
- package/es/Accordion/AccordionItem.mjs +13 -13
- package/es/Accordion/AccordionItem.mjs.map +1 -1
- package/es/Accordion/context.mjs +2 -2
- package/es/Accordion/context.mjs.map +1 -1
- package/es/ActionIcon/ActionIcon.d.mts +2 -2
- package/es/ActionIcon/ActionIcon.mjs +2 -2
- package/es/ActionIcon/ActionIcon.mjs.map +1 -1
- package/es/ActionIcon/style.mjs.map +1 -1
- package/es/ActionIconGroup/ActionIconGroup.mjs +3 -3
- package/es/ActionIconGroup/ActionIconGroup.mjs.map +1 -1
- package/es/ActionIconGroup/style.mjs.map +1 -1
- package/es/Alert/Alert.d.mts +2 -2
- package/es/Alert/Alert.mjs +6 -6
- package/es/Alert/Alert.mjs.map +1 -1
- package/es/Alert/style.mjs.map +1 -1
- package/es/AutoComplete/Select.mjs +1 -1
- package/es/AutoComplete/Select.mjs.map +1 -1
- package/es/AutoComplete/style.mjs.map +1 -1
- package/es/Avatar/Avatar.mjs +4 -4
- package/es/Avatar/Avatar.mjs.map +1 -1
- package/es/Avatar/AvatarGroup/index.d.mts +2 -2
- package/es/Avatar/AvatarGroup/index.mjs +5 -5
- package/es/Avatar/AvatarGroup/index.mjs.map +1 -1
- package/es/Avatar/index.mjs.map +1 -1
- package/es/Avatar/style.mjs.map +1 -1
- package/es/Avatar/utils.mjs.map +1 -1
- package/es/Block/style.mjs.map +1 -1
- package/es/Burger/Burger.d.mts +2 -2
- package/es/Burger/Burger.mjs +2 -2
- package/es/Burger/Burger.mjs.map +1 -1
- package/es/Burger/type.d.mts +1 -1
- package/es/Button/Button.mjs +7 -7
- package/es/Button/Button.mjs.map +1 -1
- package/es/Button/style.mjs.map +1 -1
- package/es/Checkbox/Checkbox.mjs +6 -6
- package/es/Checkbox/Checkbox.mjs.map +1 -1
- package/es/Checkbox/CheckboxGroup.mjs +2 -2
- package/es/Checkbox/CheckboxGroup.mjs.map +1 -1
- package/es/Checkbox/index.mjs.map +1 -1
- package/es/CodeDiff/CodeDiff.d.mts +2 -2
- package/es/CodeDiff/CodeDiff.mjs +3 -3
- package/es/CodeDiff/CodeDiff.mjs.map +1 -1
- package/es/CodeDiff/PatchDiff.d.mts +2 -2
- package/es/CodeDiff/PatchDiff.mjs +3 -3
- package/es/CodeDiff/PatchDiff.mjs.map +1 -1
- package/es/CodeDiff/style.mjs.map +1 -1
- package/es/CodeEditor/CodeEditor.d.mts +2 -2
- package/es/CodeEditor/CodeEditor.mjs +3 -3
- package/es/CodeEditor/CodeEditor.mjs.map +1 -1
- package/es/CodeEditor/style.mjs.map +1 -1
- package/es/Collapse/Collapse.d.mts +2 -2
- package/es/Collapse/Collapse.mjs +5 -5
- package/es/Collapse/Collapse.mjs.map +1 -1
- package/es/Collapse/style.mjs.map +1 -1
- package/es/ColorSwatches/ColorSwatches.mjs +9 -9
- package/es/ColorSwatches/ColorSwatches.mjs.map +1 -1
- package/es/ConfigProvider/index.d.mts +3 -3
- package/es/ConfigProvider/index.mjs.map +1 -1
- package/es/ContextMenu/ContextMenuHost.d.mts +3 -3
- package/es/ContextMenu/ContextMenuHost.mjs +10 -3
- package/es/ContextMenu/ContextMenuHost.mjs.map +1 -1
- package/es/ContextMenu/ContextMenuTrigger.mjs.map +1 -1
- package/es/ContextMenu/renderItems.d.mts +1 -1
- package/es/ContextMenu/renderItems.mjs +39 -14
- package/es/ContextMenu/renderItems.mjs.map +1 -1
- package/es/ContextMenu/store.d.mts +3 -1
- package/es/ContextMenu/store.mjs +1 -0
- package/es/ContextMenu/store.mjs.map +1 -1
- package/es/CopyButton/CopyButton.d.mts +2 -2
- package/es/DatePicker/DatePicker.d.mts +2 -2
- package/es/DatePicker/DatePicker.mjs +1 -1
- package/es/DatePicker/DatePicker.mjs.map +1 -1
- package/es/DatePicker/style.mjs.map +1 -1
- package/es/DraggablePanel/DraggablePanel.mjs +7 -7
- package/es/DraggablePanel/DraggablePanel.mjs.map +1 -1
- package/es/DraggablePanel/components/DraggablePanelBody.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelContainer.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelFooter.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelFooter.mjs +1 -1
- package/es/DraggablePanel/components/DraggablePanelFooter.mjs.map +1 -1
- package/es/DraggablePanel/components/DraggablePanelHeader.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelHeader.mjs +5 -5
- package/es/DraggablePanel/components/DraggablePanelHeader.mjs.map +1 -1
- package/es/DraggablePanel/index.mjs +1 -1
- package/es/DraggablePanel/index.mjs.map +1 -1
- package/es/DraggablePanel/style.mjs.map +1 -1
- package/es/DraggableSideNav/DraggableSideNav.d.mts +2 -2
- package/es/DraggableSideNav/DraggableSideNav.mjs +3 -3
- package/es/DraggableSideNav/DraggableSideNav.mjs.map +1 -1
- package/es/Drawer/Drawer.d.mts +2 -2
- package/es/Drawer/Drawer.mjs +5 -5
- package/es/Drawer/Drawer.mjs.map +1 -1
- package/es/Dropdown/Dropdown.d.mts +2 -2
- package/es/DropdownMenu/DropdownMenu.d.mts +2 -2
- package/es/DropdownMenu/DropdownMenu.mjs +7 -3
- package/es/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/es/DropdownMenu/atoms.d.mts +33 -17
- package/es/DropdownMenu/atoms.mjs +20 -6
- package/es/DropdownMenu/atoms.mjs.map +1 -1
- package/es/DropdownMenu/index.d.mts +2 -2
- package/es/DropdownMenu/index.mjs +2 -2
- package/es/DropdownMenu/renderItems.d.mts +1 -1
- package/es/DropdownMenu/renderItems.mjs +36 -14
- package/es/DropdownMenu/renderItems.mjs.map +1 -1
- package/es/DropdownMenu/type.d.mts +8 -1
- package/es/EditableText/ControlInput.mjs +29 -29
- package/es/EditableText/ControlInput.mjs.map +1 -1
- package/es/EditableText/EditableText.d.mts +2 -2
- package/es/EditableText/EditableText.mjs +14 -14
- package/es/EditableText/EditableText.mjs.map +1 -1
- package/es/EditorSlashMenu/EditorSlashMenu.mjs +2 -2
- package/es/EditorSlashMenu/EditorSlashMenu.mjs.map +1 -1
- package/es/EditorSlashMenu/MenuItemRenderer.mjs +1 -1
- package/es/EditorSlashMenu/MenuItemRenderer.mjs.map +1 -1
- package/es/EditorSlashMenu/atoms.d.mts +10 -1
- package/es/EditorSlashMenu/atoms.mjs +3 -4
- package/es/EditorSlashMenu/atoms.mjs.map +1 -1
- package/es/EmojiPicker/AvatarUploader.mjs +5 -5
- package/es/EmojiPicker/AvatarUploader.mjs.map +1 -1
- package/es/EmojiPicker/EmojiPicker.d.mts +2 -2
- package/es/EmojiPicker/EmojiPicker.mjs +20 -20
- package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
- package/es/Empty/Empty.mjs +2 -2
- package/es/Empty/Empty.mjs.map +1 -1
- package/es/FileTypeIcon/components/FileIcon.mjs.map +1 -1
- package/es/FileTypeIcon/components/FolderIcon.mjs.map +1 -1
- package/es/Flex/FlexBasic.d.mts +2 -2
- package/es/FluentEmoji/FluentEmoji.mjs +1 -1
- package/es/FluentEmoji/FluentEmoji.mjs.map +1 -1
- package/es/FontLoader/index.d.mts +2 -2
- package/es/Footer/Footer.d.mts +2 -2
- package/es/Footer/Footer.mjs +1 -1
- package/es/Footer/Footer.mjs.map +1 -1
- package/es/Form/Form.mjs +12 -12
- package/es/Form/Form.mjs.map +1 -1
- package/es/Form/components/FormGroup.d.mts +2 -2
- package/es/Form/components/FormGroup.mjs +5 -5
- package/es/Form/components/FormGroup.mjs.map +1 -1
- package/es/Form/components/FormItem.d.mts +2 -2
- package/es/Form/components/FormProvider.mjs.map +1 -1
- package/es/Form/components/FormSubmitFooter.d.mts +2 -2
- package/es/Form/components/FormSubmitFooter.mjs +5 -5
- package/es/Form/components/FormSubmitFooter.mjs.map +1 -1
- package/es/Form/components/FormTitle.mjs +1 -1
- package/es/Form/components/FormTitle.mjs.map +1 -1
- package/es/Form/components/merge.mjs.map +1 -1
- package/es/Form/index.mjs +1 -1
- package/es/Form/index.mjs.map +1 -1
- package/es/Form/style.mjs.map +1 -1
- package/es/Form/type.d.mts +1 -1
- package/es/FormModal/FormModal.d.mts +2 -2
- package/es/FormModal/FormModal.mjs +10 -10
- package/es/FormModal/FormModal.mjs.map +1 -1
- package/es/GroupAvatar/style.mjs.map +1 -1
- package/es/GroupAvatar/type.d.mts +1 -1
- package/es/GuideCard/GuideCard.d.mts +2 -2
- package/es/GuideCard/style.mjs.map +1 -1
- package/es/Header/Header.d.mts +2 -2
- package/es/Header/Header.mjs +5 -5
- package/es/Header/Header.mjs.map +1 -1
- package/es/Highlighter/FullFeatured.mjs +9 -9
- package/es/Highlighter/FullFeatured.mjs.map +1 -1
- package/es/Highlighter/Highlighter.d.mts +2 -2
- package/es/Highlighter/Highlighter.mjs +4 -4
- package/es/Highlighter/Highlighter.mjs.map +1 -1
- package/es/Highlighter/LangSelect.mjs +6 -6
- package/es/Highlighter/LangSelect.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.mjs +2 -2
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/index.d.mts +2 -2
- package/es/Highlighter/SyntaxHighlighter/style.mjs.map +1 -1
- package/es/Highlighter/style.mjs.map +1 -1
- package/es/Hotkey/Hotkey.d.mts +2 -2
- package/es/Hotkey/Hotkey.mjs +5 -5
- package/es/Hotkey/Hotkey.mjs.map +1 -1
- package/es/Hotkey/style.mjs.map +1 -1
- package/es/HotkeyInput/HotkeyInput.d.mts +2 -2
- package/es/HotkeyInput/HotkeyInput.mjs +8 -8
- package/es/HotkeyInput/HotkeyInput.mjs.map +1 -1
- package/es/HotkeyInput/style.mjs.map +1 -1
- package/es/Icon/Icon.d.mts +2 -2
- package/es/Icon/Icon.mjs.map +1 -1
- package/es/Icon/components/IconProvider.d.mts +3 -3
- package/es/Icon/components/IconProvider.mjs.map +1 -1
- package/es/Icon/style.mjs.map +1 -1
- package/es/Image/Image.mjs +3 -3
- package/es/Image/Image.mjs.map +1 -1
- package/es/Image/PreviewGroup.d.mts +2 -2
- package/es/Image/PreviewGroup.mjs.map +1 -1
- package/es/Image/components/Preview.mjs.map +1 -1
- package/es/Image/components/Toolbar.mjs +1 -1
- package/es/Image/components/Toolbar.mjs.map +1 -1
- package/es/Image/components/usePreviewGroup.mjs.map +1 -1
- package/es/Image/style.mjs.map +1 -1
- package/es/ImageSelect/ImageSelect.d.mts +2 -2
- package/es/ImageSelect/ImageSelect.mjs +5 -5
- package/es/ImageSelect/ImageSelect.mjs.map +1 -1
- package/es/Img/index.mjs.map +1 -1
- package/es/Input/Input.d.mts +2 -2
- package/es/Input/Input.mjs +2 -2
- package/es/Input/Input.mjs.map +1 -1
- package/es/Input/InputNumber.d.mts +2 -2
- package/es/Input/InputNumber.mjs +2 -2
- package/es/Input/InputNumber.mjs.map +1 -1
- package/es/Input/InputOPT.d.mts +2 -2
- package/es/Input/InputOPT.mjs +2 -2
- package/es/Input/InputOPT.mjs.map +1 -1
- package/es/Input/InputPassword.d.mts +2 -2
- package/es/Input/InputPassword.mjs +2 -2
- package/es/Input/InputPassword.mjs.map +1 -1
- package/es/Input/TextArea.d.mts +2 -2
- package/es/Input/TextArea.mjs +2 -2
- package/es/Input/TextArea.mjs.map +1 -1
- package/es/Input/style.mjs.map +1 -1
- package/es/Layout/Layout.mjs +1 -1
- package/es/Layout/Layout.mjs.map +1 -1
- package/es/Layout/components/LayoutFooter.d.mts +2 -2
- package/es/Layout/components/LayoutHeader.d.mts +2 -2
- package/es/Layout/components/LayoutMain.d.mts +2 -2
- package/es/Layout/components/LayoutSidebar.d.mts +2 -2
- package/es/Layout/components/LayoutSidebarInner.d.mts +2 -2
- package/es/Layout/components/LayoutToc.d.mts +2 -2
- package/es/Layout/index.mjs.map +1 -1
- package/es/List/List.mjs +6 -6
- package/es/List/List.mjs.map +1 -1
- package/es/List/ListItem/index.d.mts +2 -2
- package/es/List/ListItem/index.mjs +11 -11
- package/es/List/ListItem/index.mjs.map +1 -1
- package/es/LobeSelect/LobeSelect.d.mts +2 -2
- package/es/LobeSelect/LobeSelect.mjs +16 -16
- package/es/LobeSelect/LobeSelect.mjs.map +1 -1
- package/es/LobeSelect/atoms.d.mts +19 -19
- package/es/LobeSelect/atoms.mjs +1 -1
- package/es/LobeSelect/atoms.mjs.map +1 -1
- package/es/LobeSwitch/LobeSwitch.d.mts +2 -2
- package/es/LobeSwitch/LobeSwitch.mjs +2 -2
- package/es/LobeSwitch/LobeSwitch.mjs.map +1 -1
- package/es/LobeSwitch/atoms.d.mts +4 -4
- package/es/LobeSwitch/atoms.mjs +8 -8
- package/es/LobeSwitch/atoms.mjs.map +1 -1
- package/es/Markdown/Markdown.d.mts +2 -2
- package/es/Markdown/Markdown.mjs +3 -3
- package/es/Markdown/Markdown.mjs.map +1 -1
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.mjs.map +1 -1
- package/es/Markdown/Typography.d.mts +2 -2
- package/es/Markdown/components/CodeBlock.mjs.map +1 -1
- package/es/Markdown/components/Footnotes.mjs +3 -3
- package/es/Markdown/components/Footnotes.mjs.map +1 -1
- package/es/Markdown/components/MarkdownProvider.mjs.map +1 -1
- package/es/Markdown/components/SearchResultCards/SearchResultCard.mjs +3 -3
- package/es/Markdown/components/SearchResultCards/SearchResultCard.mjs.map +1 -1
- package/es/Markdown/components/SearchResultCards/index.d.mts +2 -2
- package/es/Markdown/components/SearchResultCards/index.mjs +1 -1
- package/es/Markdown/components/SearchResultCards/index.mjs.map +1 -1
- package/es/Markdown/plugins/rehypeCustomFootnotes.mjs.map +1 -1
- package/es/Markdown/plugins/rehypeKatexDir.mjs.map +1 -1
- package/es/Markdown/plugins/rehypeStreamAnimated.mjs.map +1 -1
- package/es/Markdown/plugins/remarkColor.mjs +1 -1
- package/es/Markdown/plugins/remarkColor.mjs.map +1 -1
- package/es/Markdown/plugins/remarkCustomFootnotes.mjs.map +1 -1
- package/es/Markdown/plugins/remarkVideo.mjs +3 -3
- package/es/Markdown/plugins/remarkVideo.mjs.map +1 -1
- package/es/Markdown/style.mjs.map +1 -1
- package/es/MaskShadow/MaskShadow.d.mts +2 -2
- package/es/MaskShadow/style.mjs.map +1 -1
- package/es/Menu/Menu.d.mts +2 -2
- package/es/Menu/Menu.mjs.map +1 -1
- package/es/Menu/checkboxItem.d.mts +1 -0
- package/es/Menu/index.d.mts +2 -2
- package/es/Menu/renderUtils.d.mts +4 -1
- package/es/Menu/renderUtils.mjs.map +1 -1
- package/es/Menu/sharedStyle.d.mts +4 -0
- package/es/Menu/sharedStyle.mjs +24 -0
- package/es/Menu/sharedStyle.mjs.map +1 -1
- package/es/Menu/style.mjs.map +1 -1
- package/es/Menu/switchItem.d.mts +1 -0
- package/es/Menu/type.d.mts +3 -1
- package/es/Mermaid/FullFeatured.mjs +7 -7
- package/es/Mermaid/FullFeatured.mjs.map +1 -1
- package/es/Mermaid/Mermaid.d.mts +2 -2
- package/es/Mermaid/Mermaid.mjs +1 -1
- package/es/Mermaid/Mermaid.mjs.map +1 -1
- package/es/Mermaid/SyntaxMermaid/StaticMermaid.mjs +3 -3
- package/es/Mermaid/SyntaxMermaid/StaticMermaid.mjs.map +1 -1
- package/es/Mermaid/SyntaxMermaid/StreamMermaid.mjs +3 -3
- package/es/Mermaid/SyntaxMermaid/StreamMermaid.mjs.map +1 -1
- package/es/Mermaid/SyntaxMermaid/index.d.mts +2 -2
- package/es/Mermaid/SyntaxMermaid/style.mjs.map +1 -1
- package/es/Modal/Modal.d.mts +2 -2
- package/es/Modal/Modal.mjs +25 -25
- package/es/Modal/Modal.mjs.map +1 -1
- package/es/Modal/ModalProvider.d.mts +2 -2
- package/es/Modal/ModalStackItem.mjs +1 -1
- package/es/Modal/ModalStackItem.mjs.map +1 -1
- package/es/Modal/imperative.d.mts +2 -2
- package/es/Modal/imperative.mjs +5 -5
- package/es/Modal/imperative.mjs.map +1 -1
- package/es/MotionProvider/index.d.mts +2 -2
- package/es/MotionProvider/index.mjs.map +1 -1
- package/es/Popover/ArrowIcon.d.mts +2 -2
- package/es/Popover/Popover.mjs +2 -2
- package/es/Popover/Popover.mjs.map +1 -1
- package/es/Popover/PopoverGroup.mjs +2 -2
- package/es/Popover/PopoverGroup.mjs.map +1 -1
- package/es/Popover/PopoverInGroup.mjs +2 -2
- package/es/Popover/PopoverInGroup.mjs.map +1 -1
- package/es/Popover/PopoverStandalone.mjs +1 -1
- package/es/Popover/PopoverStandalone.mjs.map +1 -1
- package/es/Popover/atoms.d.mts +9 -9
- package/es/Popover/atoms.mjs +1 -1
- package/es/Popover/atoms.mjs.map +1 -1
- package/es/Popover/context.d.mts +2 -2
- package/es/Popover/context.mjs.map +1 -1
- package/es/Popover/groupContext.mjs.map +1 -1
- package/es/ScrollArea/atoms.d.mts +7 -7
- package/es/ScrollArea/type.d.mts +1 -1
- package/es/ScrollShadow/style.mjs.map +1 -1
- package/es/ScrollShadow/useScrollOverflow.mjs.map +1 -1
- package/es/SearchBar/SearchBar.d.mts +2 -2
- package/es/SearchBar/SearchBar.mjs +12 -12
- package/es/SearchBar/SearchBar.mjs.map +1 -1
- package/es/Segmented/Segmented.d.mts +2 -2
- package/es/Segmented/style.mjs.map +1 -1
- package/es/Select/Select.d.mts +2 -2
- package/es/Select/Select.mjs +2 -2
- package/es/Select/Select.mjs.map +1 -1
- package/es/Select/style.mjs.map +1 -1
- package/es/SideNav/SideNav.d.mts +2 -2
- package/es/Skeleton/Skeleton.mjs +1 -1
- package/es/Skeleton/Skeleton.mjs.map +1 -1
- package/es/Skeleton/SkeletonBlock.mjs.map +1 -1
- package/es/Skeleton/SkeletonTags.mjs +3 -3
- package/es/Skeleton/SkeletonTags.mjs.map +1 -1
- package/es/Skeleton/SkeletonTitle.mjs +1 -1
- package/es/Skeleton/SkeletonTitle.mjs.map +1 -1
- package/es/SliderWithInput/SliderWithInput.d.mts +2 -2
- package/es/SliderWithInput/SliderWithInput.mjs +3 -3
- package/es/SliderWithInput/SliderWithInput.mjs.map +1 -1
- package/es/Snippet/Snippet.mjs +1 -1
- package/es/Snippet/Snippet.mjs.map +1 -1
- package/es/Snippet/style.mjs.map +1 -1
- package/es/SortableList/SortableList.d.mts +2 -2
- package/es/SortableList/SortableList.mjs +1 -1
- package/es/SortableList/SortableList.mjs.map +1 -1
- package/es/SortableList/components/DragHandle.d.mts +2 -2
- package/es/SortableList/components/DragHandle.mjs +3 -3
- package/es/SortableList/components/DragHandle.mjs.map +1 -1
- package/es/SortableList/components/SortableItem.d.mts +2 -2
- package/es/SortableList/components/SortableItem.mjs +1 -1
- package/es/SortableList/components/SortableItem.mjs.map +1 -1
- package/es/SortableList/components/SortableOverlay.mjs.map +1 -1
- package/es/SortableList/style.mjs.map +1 -1
- package/es/SortableList/type.d.mts +4 -4
- package/es/Tabs/style.mjs.map +1 -1
- package/es/Tag/Tag.mjs +2 -2
- package/es/Tag/Tag.mjs.map +1 -1
- package/es/Tag/styles.mjs.map +1 -1
- package/es/Text/Text.mjs +23 -24
- package/es/Text/Text.mjs.map +1 -1
- package/es/ThemeProvider/ConfigProvider.mjs.map +1 -1
- package/es/ThemeProvider/GlobalStyle/antdOverride.mjs.map +1 -1
- package/es/ThemeProvider/GlobalStyle/global.mjs.map +1 -1
- package/es/ThemeProvider/ThemeProvider.d.mts +2 -2
- package/es/ThemeProvider/ThemeProvider.mjs.map +1 -1
- package/es/ThemeSwitch/ThemeSwitch.mjs +4 -4
- package/es/ThemeSwitch/ThemeSwitch.mjs.map +1 -1
- package/es/Toast/Toast.mjs +3 -3
- package/es/Toast/Toast.mjs.map +1 -1
- package/es/Toast/imperative.d.mts +3 -3
- package/es/Toast/imperative.mjs +1 -1
- package/es/Toast/imperative.mjs.map +1 -1
- package/es/Toc/Toc.d.mts +2 -2
- package/es/Toc/Toc.mjs.map +1 -1
- package/es/Toc/TocMobile.mjs +4 -4
- package/es/Toc/TocMobile.mjs.map +1 -1
- package/es/Toc/utils.mjs.map +1 -1
- package/es/Tooltip/Tooltip.mjs +2 -2
- package/es/Tooltip/Tooltip.mjs.map +1 -1
- package/es/Tooltip/TooltipContent.mjs.map +1 -1
- package/es/Tooltip/TooltipGroup.mjs +3 -3
- package/es/Tooltip/TooltipGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipInGroup.mjs +3 -3
- package/es/Tooltip/TooltipInGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipStandalone.mjs +2 -2
- package/es/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/Tooltip/groupContext.mjs.map +1 -1
- package/es/Tooltip/type.d.mts +1 -1
- package/es/Video/index.d.mts +2 -2
- package/es/Video/index.mjs +8 -8
- package/es/Video/index.mjs.map +1 -1
- package/es/Video/style.mjs.map +1 -1
- package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
- package/es/awesome/BottomGradientButton/BottomGradientButton.d.mts +2 -2
- package/es/awesome/BottomGradientButton/BottomGradientButton.mjs +1 -1
- package/es/awesome/BottomGradientButton/BottomGradientButton.mjs.map +1 -1
- package/es/awesome/Features/FeatureItem.mjs +1 -1
- package/es/awesome/Features/FeatureItem.mjs.map +1 -1
- package/es/awesome/Features/Features.d.mts +2 -2
- package/es/awesome/Features/Features.mjs +4 -4
- package/es/awesome/Features/Features.mjs.map +1 -1
- package/es/awesome/Features/type.d.mts +1 -1
- package/es/awesome/Giscus/Giscus.d.mts +2 -2
- package/es/awesome/GradientButton/GradientButton.d.mts +2 -2
- package/es/awesome/GradientButton/GradientButton.mjs +2 -2
- package/es/awesome/GradientButton/GradientButton.mjs.map +1 -1
- package/es/awesome/GridBackground/GridBackground.d.mts +2 -2
- package/es/awesome/GridBackground/GridShowcase.d.mts +2 -2
- package/es/awesome/GridBackground/GridShowcase.mjs +5 -5
- package/es/awesome/GridBackground/GridShowcase.mjs.map +1 -1
- package/es/awesome/GridBackground/components/Grid.mjs.map +1 -1
- package/es/awesome/Hero/Hero.d.mts +2 -2
- package/es/awesome/Hero/Hero.mjs +3 -3
- package/es/awesome/Hero/Hero.mjs.map +1 -1
- package/es/awesome/Hero/type.d.mts +1 -1
- package/es/awesome/Spline/ParentSize.mjs.map +1 -1
- package/es/awesome/Spline/Spine.d.mts +2 -2
- package/es/awesome/Spline/Spine.mjs +2 -2
- package/es/awesome/Spline/Spine.mjs.map +1 -1
- package/es/awesome/Spotlight/Spotlight.d.mts +2 -2
- package/es/awesome/SpotlightCard/SpotlightCard.d.mts +2 -2
- package/es/awesome/TypewriterEffect/TypewriterEffect.d.mts +2 -2
- package/es/brand/BrandLoading/index.mjs.map +1 -1
- package/es/brand/LobeChat/index.d.mts +2 -2
- package/es/brand/LobeChat/index.mjs +3 -3
- package/es/brand/LobeChat/index.mjs.map +1 -1
- package/es/brand/LobeChatText/index.mjs.map +1 -1
- package/es/brand/LobeHub/index.d.mts +2 -2
- package/es/brand/LobeHub/index.mjs +3 -3
- package/es/brand/LobeHub/index.mjs.map +1 -1
- package/es/brand/LobeHubText/index.mjs.map +1 -1
- package/es/brand/Logo3d/index.mjs.map +1 -1
- package/es/brand/LogoThree/Loading.mjs +2 -2
- package/es/brand/LogoThree/Loading.mjs.map +1 -1
- package/es/brand/LogoThree/LogoSpline.d.mts +2 -2
- package/es/brand/LogoThree/LogoSpline.mjs +1 -1
- package/es/brand/LogoThree/LogoSpline.mjs.map +1 -1
- package/es/brand/LogoThree/index.d.mts +2 -2
- package/es/brand/LogoThree/index.mjs +4 -4
- package/es/brand/LogoThree/index.mjs.map +1 -1
- package/es/brand/components/Divider.mjs.map +1 -1
- package/es/chat/BackBottom/BackBottom.d.mts +2 -2
- package/es/chat/BackBottom/BackBottom.mjs +2 -2
- package/es/chat/BackBottom/BackBottom.mjs.map +1 -1
- package/es/chat/ChatHeader/ChatHeader.mjs +6 -6
- package/es/chat/ChatHeader/ChatHeader.mjs.map +1 -1
- package/es/chat/ChatHeader/ChatHeaderTitle.mjs +4 -4
- package/es/chat/ChatHeader/ChatHeaderTitle.mjs.map +1 -1
- package/es/chat/ChatInputArea/ChatInputArea.mjs +3 -3
- package/es/chat/ChatInputArea/ChatInputArea.mjs.map +1 -1
- package/es/chat/ChatInputArea/components/ChatInputActionBar.mjs +3 -3
- package/es/chat/ChatInputArea/components/ChatInputActionBar.mjs.map +1 -1
- package/es/chat/ChatInputArea/components/ChatInputAreaInner.d.mts +2 -2
- package/es/chat/ChatInputArea/components/ChatInputAreaInner.mjs +3 -3
- package/es/chat/ChatInputArea/components/ChatInputAreaInner.mjs.map +1 -1
- package/es/chat/ChatInputArea/components/ChatSendButton.mjs +5 -5
- package/es/chat/ChatInputArea/components/ChatSendButton.mjs.map +1 -1
- package/es/chat/ChatItem/ChatItem.d.mts +2 -2
- package/es/chat/ChatItem/ChatItem.mjs +9 -9
- package/es/chat/ChatItem/ChatItem.mjs.map +1 -1
- package/es/chat/ChatItem/components/Actions.mjs.map +1 -1
- package/es/chat/ChatItem/components/Avatar.mjs +2 -2
- package/es/chat/ChatItem/components/Avatar.mjs.map +1 -1
- package/es/chat/ChatItem/components/ErrorContent.mjs +1 -1
- package/es/chat/ChatItem/components/ErrorContent.mjs.map +1 -1
- package/es/chat/ChatItem/components/Loading.mjs +2 -2
- package/es/chat/ChatItem/components/Loading.mjs.map +1 -1
- package/es/chat/ChatItem/components/MessageContent.mjs +4 -4
- package/es/chat/ChatItem/components/MessageContent.mjs.map +1 -1
- package/es/chat/ChatItem/components/Title.mjs.map +1 -1
- package/es/chat/ChatList/ChatList.d.mts +2 -2
- package/es/chat/ChatList/components/ChatListItem.mjs +14 -14
- package/es/chat/ChatList/components/ChatListItem.mjs.map +1 -1
- package/es/chat/ChatList/type.d.mts +1 -1
- package/es/chat/EditableMessage/EditableMessage.d.mts +2 -2
- package/es/chat/EditableMessage/EditableMessage.mjs +15 -15
- package/es/chat/EditableMessage/EditableMessage.mjs.map +1 -1
- package/es/chat/EditableMessageList/EditableMessageList.d.mts +2 -2
- package/es/chat/EditableMessageList/EditableMessageList.mjs +17 -17
- package/es/chat/EditableMessageList/EditableMessageList.mjs.map +1 -1
- package/es/chat/MessageInput/MessageInput.d.mts +2 -2
- package/es/chat/MessageInput/MessageInput.mjs +8 -8
- package/es/chat/MessageInput/MessageInput.mjs.map +1 -1
- package/es/chat/MessageModal/MessageModal.d.mts +2 -2
- package/es/chat/MessageModal/MessageModal.mjs +12 -12
- package/es/chat/MessageModal/MessageModal.mjs.map +1 -1
- package/es/chat/TokenTag/TokenTag.mjs +2 -2
- package/es/chat/TokenTag/TokenTag.mjs.map +1 -1
- package/es/chat/types/error.mjs.map +1 -1
- package/es/color/ColorScales/ScaleRow.mjs +3 -3
- package/es/color/ColorScales/ScaleRow.mjs.map +1 -1
- package/es/color/ColorScales/index.d.mts +2 -2
- package/es/color/ColorScales/index.mjs +4 -4
- package/es/color/ColorScales/index.mjs.map +1 -1
- package/es/color/CssVar/ScaleRow.mjs +4 -4
- package/es/color/CssVar/ScaleRow.mjs.map +1 -1
- package/es/color/CssVar/VarRow.mjs +2 -2
- package/es/color/CssVar/VarRow.mjs.map +1 -1
- package/es/color/CssVar/index.d.mts +2 -2
- package/es/color/CssVar/index.mjs +4 -4
- package/es/color/CssVar/index.mjs.map +1 -1
- package/es/color/colors/blue.mjs.map +1 -1
- package/es/color/colors/cyan.mjs.map +1 -1
- package/es/color/colors/geekblue.mjs.map +1 -1
- package/es/color/colors/gold.mjs.map +1 -1
- package/es/color/colors/gray.mjs.map +1 -1
- package/es/color/colors/green.mjs.map +1 -1
- package/es/color/colors/lime.mjs.map +1 -1
- package/es/color/colors/magenta.mjs.map +1 -1
- package/es/color/colors/orange.mjs.map +1 -1
- package/es/color/colors/primary.mjs.map +1 -1
- package/es/color/colors/purple.mjs.map +1 -1
- package/es/color/colors/red.mjs.map +1 -1
- package/es/color/colors/volcano.mjs.map +1 -1
- package/es/color/colors/yellow.mjs.map +1 -1
- package/es/color/neutrals/mauve.mjs.map +1 -1
- package/es/color/neutrals/olive.mjs.map +1 -1
- package/es/color/neutrals/sage.mjs.map +1 -1
- package/es/color/neutrals/sand.mjs.map +1 -1
- package/es/color/neutrals/slate.mjs.map +1 -1
- package/es/hooks/useFloatingLayer.mjs +2 -2
- package/es/hooks/useFloatingLayer.mjs.map +1 -1
- package/es/hooks/useHighlight.mjs.map +1 -1
- package/es/hooks/useMarkdown/latex.mjs +12 -12
- package/es/hooks/useMarkdown/latex.mjs.map +1 -1
- package/es/hooks/useMarkdown/useMarkdownComponents.mjs +1 -1
- package/es/hooks/useMarkdown/useMarkdownComponents.mjs.map +1 -1
- package/es/hooks/useMarkdown/utils.mjs +4 -4
- package/es/hooks/useMarkdown/utils.mjs.map +1 -1
- package/es/hooks/useNativeButton.mjs.map +1 -1
- package/es/hooks/useStreamHighlight.mjs.map +1 -1
- package/es/i18n/context.d.mts +3 -3
- package/es/i18n/context.mjs.map +1 -1
- package/es/icons/Authelia/components/Color.mjs.map +1 -1
- package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
- package/es/icons/lucideExtra/CreateBotIcon.d.mts +2 -2
- package/es/icons/lucideExtra/DiscordIcon.d.mts +2 -2
- package/es/icons/lucideExtra/GlobeOffIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +3 -3
- package/es/icons/lucideExtra/LeftClickIcon.d.mts +2 -2
- package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/McpIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ProviderIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +2 -2
- package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +3 -3
- package/es/mdx/Callout/index.mjs +1 -1
- package/es/mdx/Callout/index.mjs.map +1 -1
- package/es/mdx/Cards/Card.mjs +2 -2
- package/es/mdx/Cards/Card.mjs.map +1 -1
- package/es/mdx/FileTree/File.mjs +1 -1
- package/es/mdx/FileTree/File.mjs.map +1 -1
- package/es/mdx/FileTree/Folder.mjs +1 -1
- package/es/mdx/FileTree/Folder.mjs.map +1 -1
- package/es/mdx/FileTree/index.mjs.map +1 -1
- package/es/mdx/Mdx/index.d.mts +2 -2
- package/es/mdx/Mdx/index.mjs +3 -3
- package/es/mdx/Mdx/index.mjs.map +1 -1
- package/es/mdx/Steps/index.mjs.map +1 -1
- package/es/mdx/Tabs/Tab.mjs.map +1 -1
- package/es/mdx/Tabs/index.mjs +1 -1
- package/es/mdx/Tabs/index.mjs.map +1 -1
- package/es/mdx/mdxComponents/Citation/PopoverPanel.mjs +3 -3
- package/es/mdx/mdxComponents/Citation/PopoverPanel.mjs.map +1 -1
- package/es/mdx/mdxComponents/Citation/index.mjs.map +1 -1
- package/es/mdx/mdxComponents/Link.mjs +1 -1
- package/es/mdx/mdxComponents/Link.mjs.map +1 -1
- package/es/mobile/ChatHeader/ChatHeader.mjs +4 -4
- package/es/mobile/ChatHeader/ChatHeader.mjs.map +1 -1
- package/es/mobile/ChatHeader/ChatHeaderTitle.d.mts +2 -2
- package/es/mobile/ChatHeader/ChatHeaderTitle.mjs +5 -5
- package/es/mobile/ChatHeader/ChatHeaderTitle.mjs.map +1 -1
- package/es/mobile/ChatInputArea/ChatInputArea.mjs +9 -9
- package/es/mobile/ChatInputArea/ChatInputArea.mjs.map +1 -1
- package/es/mobile/ChatInputArea/components/ChatSendButton.d.mts +2 -2
- package/es/mobile/ChatInputArea/components/ChatSendButton.mjs +2 -2
- package/es/mobile/ChatInputArea/components/ChatSendButton.mjs.map +1 -1
- package/es/mobile/SafeArea/SafeArea.mjs.map +1 -1
- package/es/mobile/TabBar/TabBar.mjs +1 -1
- package/es/mobile/TabBar/TabBar.mjs.map +1 -1
- package/es/storybook/StoryBook/index.d.mts +2 -2
- package/es/storybook/StoryBook/index.mjs.map +1 -1
- package/es/styles/theme/algorithms/darkAlgorithm.mjs.map +1 -1
- package/es/styles/theme/algorithms/lightAlgorithm.mjs.map +1 -1
- package/es/styles/theme/antdTheme.mjs.map +1 -1
- package/es/styles/theme/customStylish.mjs.map +1 -1
- package/es/styles/theme/customToken.mjs.map +1 -1
- package/es/styles/theme/generateColorPalette.mjs.map +1 -1
- package/es/styles/theme/token/base.mjs.map +1 -1
- package/es/styles/theme/token/dark.mjs.map +1 -1
- package/es/styles/theme/token/light.mjs.map +1 -1
- package/package.json +79 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["DropdownMenuRoot: typeof Menu.Root","Menu"],"sources":["../../src/DropdownMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Menu } from '@base-ui/react/menu';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Switch } from 'antd';\nimport { cx } from 'antd-style';\nimport clsx from 'clsx';\nimport type React from 'react';\nimport { cloneElement, isValidElement, useCallback, useState } from 'react';\nimport { mergeRefs } from 'react-merge-refs';\n\nimport { styles } from '@/Menu/sharedStyle';\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { usePortalContainer } from '@/hooks/usePortalContainer';\nimport { CLASSNAMES } from '@/styles/classNames';\nimport { placementMap } from '@/utils/placement';\n\nimport type { DropdownMenuPlacement } from './type';\n\nexport const DROPDOWN_MENU_CONTAINER_ATTR = 'data-lobe-ui-dropdown-menu-container';\n\nexport const DropdownMenuRoot: typeof Menu.Root = (props) => <Menu.Root modal={false} {...props} />;\nexport const DropdownMenuSubmenuRoot = Menu.SubmenuRoot;\nexport const DropdownMenuCheckboxItemIndicator = Menu.CheckboxItemIndicator;\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => cx(base, className(state));\n return cx(base, className);\n};\n\nexport type DropdownMenuTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Menu.Trigger>,\n 'children' | 'render'\n> & {\n children: React.ReactNode;\n};\n\nexport const DropdownMenuTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DropdownMenuTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n className: clsx(CLASSNAMES.DropdownMenuTrigger, className, mergedProps.className),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return <Menu.Trigger {...rest} nativeButton={resolvedNativeButton} render={renderer as any} />;\n }\n\n return (\n <Menu.Trigger\n {...rest}\n className={clsx(CLASSNAMES.DropdownMenuTrigger, className)}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Menu.Trigger>\n );\n};\n\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\nexport type DropdownMenuPortalProps = React.ComponentProps<typeof Menu.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const DropdownMenuPortal = ({ container, ...rest }: DropdownMenuPortalProps) => {\n const defaultContainer = usePortalContainer(DROPDOWN_MENU_CONTAINER_ATTR);\n return <Menu.Portal container={container ?? defaultContainer} {...rest} />;\n};\n\nDropdownMenuPortal.displayName = 'DropdownMenuPortal';\n\nexport type DropdownMenuPositionerProps = React.ComponentProps<typeof Menu.Positioner> & {\n hoverTrigger?: boolean;\n placement?: DropdownMenuPlacement;\n};\n\nexport const DropdownMenuPositioner = ({\n className,\n placement,\n hoverTrigger,\n align,\n side,\n sideOffset,\n children,\n ...rest\n}: DropdownMenuPositionerProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <Menu.Positioner\n {...rest}\n align={align ?? placementConfig?.align}\n className={mergeStateClassName(styles.positioner, className as any) as any}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={setPositionerNode}\n side={side ?? placementConfig?.side}\n sideOffset={sideOffset ?? (placementConfig ? 6 : undefined)}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </Menu.Positioner>\n );\n};\n\nDropdownMenuPositioner.displayName = 'DropdownMenuPositioner';\n\nexport type DropdownMenuPopupProps = React.ComponentProps<typeof Menu.Popup>;\n\nexport const DropdownMenuPopup = ({ className, ...rest }: DropdownMenuPopupProps) => {\n return (\n <Menu.Popup {...rest} className={mergeStateClassName(styles.popup, className as any) as any} />\n );\n};\n\nDropdownMenuPopup.displayName = 'DropdownMenuPopup';\n\nexport type DropdownMenuItemProps = React.ComponentProps<typeof Menu.Item> & { danger?: boolean };\n\nexport const DropdownMenuItem = ({ className, danger, ...rest }: DropdownMenuItemProps) => {\n return (\n <Menu.Item\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport type DropdownMenuCheckboxItemProps = React.ComponentProps<typeof Menu.CheckboxItem> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuCheckboxItemPrimitive = ({\n className,\n danger,\n ...rest\n}: DropdownMenuCheckboxItemProps) => {\n return (\n <Menu.CheckboxItem\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuCheckboxItemPrimitive.displayName = 'DropdownMenuCheckboxItemPrimitive';\n\nexport type DropdownMenuSeparatorProps = React.ComponentProps<typeof Menu.Separator>;\n\nexport const DropdownMenuSeparator = ({ className, ...rest }: DropdownMenuSeparatorProps) => {\n return (\n <Menu.Separator\n {...rest}\n className={(state) =>\n cx(styles.separator, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\nexport const DropdownMenuGroup = Menu.Group;\n\nexport type DropdownMenuGroupLabelProps = React.ComponentProps<typeof Menu.GroupLabel>;\n\nexport const DropdownMenuGroupLabel = ({ className, ...rest }: DropdownMenuGroupLabelProps) => {\n return (\n <Menu.GroupLabel\n {...rest}\n className={(state) =>\n cx(styles.groupLabel, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuGroupLabel.displayName = 'DropdownMenuGroupLabel';\n\nexport type DropdownMenuSubmenuTriggerProps = React.ComponentProps<typeof Menu.SubmenuTrigger> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuSubmenuTrigger = ({\n className,\n danger,\n ...rest\n}: DropdownMenuSubmenuTriggerProps) => {\n return (\n <Menu.SubmenuTrigger\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuSubmenuTrigger.displayName = 'DropdownMenuSubmenuTrigger';\n\nexport type DropdownMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemContent = ({ className, ...rest }: DropdownMenuItemContentProps) => {\n return <div {...rest} className={cx(styles.itemContent, className)} />;\n};\n\nDropdownMenuItemContent.displayName = 'DropdownMenuItemContent';\n\nexport type DropdownMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemIcon = ({ className, ...rest }: DropdownMenuItemIconProps) => {\n return <span {...rest} className={cx(styles.icon, className)} />;\n};\n\nDropdownMenuItemIcon.displayName = 'DropdownMenuItemIcon';\n\nexport type DropdownMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemLabel = ({ className, ...rest }: DropdownMenuItemLabelProps) => {\n return <span {...rest} className={cx(styles.label, className)} />;\n};\n\nDropdownMenuItemLabel.displayName = 'DropdownMenuItemLabel';\n\nexport type DropdownMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemExtra = ({ className, ...rest }: DropdownMenuItemExtraProps) => {\n return <span {...rest} className={cx(styles.extra, className)} />;\n};\n\nDropdownMenuItemExtra.displayName = 'DropdownMenuItemExtra';\n\nexport type DropdownMenuSubmenuArrowProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuSubmenuArrow = ({ className, ...rest }: DropdownMenuSubmenuArrowProps) => {\n return <span {...rest} className={cx(styles.submenuArrow, className)} />;\n};\n\nDropdownMenuSubmenuArrow.displayName = 'DropdownMenuSubmenuArrow';\n\nexport type DropdownMenuSwitchItemProps = Omit<\n React.ComponentProps<typeof Menu.Item>,\n 'onClick'\n> & {\n checked?: boolean;\n closeOnClick?: boolean;\n danger?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n};\n\nexport const DropdownMenuSwitchItem = ({\n checked: checkedProp,\n className,\n closeOnClick = false,\n danger,\n defaultChecked,\n disabled,\n onCheckedChange,\n children,\n ...rest\n}: DropdownMenuSwitchItemProps) => {\n const [internalChecked, setInternalChecked] = useState(defaultChecked ?? false);\n const isControlled = checkedProp !== undefined;\n const checked = isControlled ? checkedProp : internalChecked;\n\n const handleCheckedChange = useCallback(\n (newChecked: boolean) => {\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n onCheckedChange?.(newChecked);\n },\n [isControlled, onCheckedChange],\n );\n\n return (\n <Menu.Item\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n closeOnClick={closeOnClick}\n disabled={disabled}\n onClick={(e) => {\n e.preventDefault();\n if (!disabled) {\n handleCheckedChange(!checked);\n }\n }}\n >\n {children}\n <Switch\n checked={checked}\n disabled={disabled}\n onChange={handleCheckedChange}\n onClick={(_, e) => e.stopPropagation()}\n size=\"small\"\n style={{ marginInlineStart: 16 }}\n />\n </Menu.Item>\n );\n};\n\nDropdownMenuSwitchItem.displayName = 'DropdownMenuSwitchItem';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,MAAa,+BAA+B;AAE5C,MAAaA,oBAAsC,UAAU,oBAACC,OAAK;CAAK,OAAO;CAAO,GAAI;EAAS;AACnG,MAAa,0BAA0BA,OAAK;AAC5C,MAAa,oCAAoCA,OAAK;AAEtD,MAAM,uBACJ,MACA,cACG;AACH,KAAI,OAAO,cAAc,WAAY,SAAQ,UAAkB,GAAG,MAAM,UAAU,MAAM,CAAC;AACzF,QAAO,GAAG,MAAM,UAAU;;AAU5B,MAAa,uBAAuB,EAClC,UACA,WACA,cACA,KAAK,SACL,GAAG,WAC2B;CAC9B,MAAM,EAAE,8BAA8B,yBAAyB,gBAAgB;EAC7E;EACA;EACD,CAAC;CAEF,MAAM,YAAY,UAAe;EAG/B,MAAM,uBAAuB;AAC3B,OAAI,6BAA8B,QAAO;GAEzC,MAAM,EAAE,MAAM,GAAG,cAAc;AAC/B,UAAO;MACL;EAEJ,MAAM,cAAc,WAAY,SAAiB,OAAO,cAAc;AACtE,SAAO,aAAa,UAAiB;GACnC,GAAG;GACH,WAAW,KAAK,WAAW,qBAAqB,WAAW,YAAY,UAAU;GACjF,KAAK,UAAU;IAAE,SAAiB;IAAM,MAAc;IAAK;IAAQ,CAAC;GAC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Ac;AAIpC,MAAa,yBAAyB,EAAE,WAAW,GAAG,WAAuC;AAC3F,QAAO,oBAAC;EAAK,GAAI;EAAM,WAAW,GAAG,OAAO,OAAO,UAAU;GAAI;;AAGnE,sBAAsB,cAAc;AAIpC,MAAa,4BAA4B,EAAE,WAAW,GAAG,WAA0C;AACjG,QAAO,oBAAC;EAAK,GAAI;EAAM,WAAW,GAAG,OAAO,cAAc,UAAU;GAAI;;AAG1E,yBAAyB,cAAc;AAavC,MAAa,0BAA0B,EACrC,SAAS,aACT,WACA,eAAe,OACf,QACA,gBACA,UACA,iBACA,UACA,GAAG,WAC8B;CACjC,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,kBAAkB,MAAM;CAC/E,MAAM,eAAe,gBAAgB;CACrC,MAAM,UAAU,eAAe,cAAc;CAE7C,MAAM,sBAAsB,aACzB,eAAwB;AACvB,MAAI,CAAC,aACH,oBAAmB,WAAW;AAEhC,oBAAkB,WAAW;IAE/B,CAAC,cAAc,gBAAgB,CAChC;AAED,QACE,qBAACA,OAAK;EACJ,GAAI;EACJ,YAAY,UACV,GACE,OAAO,MACP,UAAU,OAAO,QACjB,OAAO,cAAc,aAAa,UAAU,MAAM,GAAG,UACtD;EAEW;EACJ;EACV,UAAU,MAAM;AACd,KAAE,gBAAgB;AAClB,OAAI,CAAC,SACH,qBAAoB,CAAC,QAAQ;;aAIhC,UACD,oBAAC;GACU;GACC;GACV,UAAU;GACV,UAAU,GAAG,MAAM,EAAE,iBAAiB;GACtC,MAAK;GACL,OAAO,EAAE,mBAAmB,IAAI;IAChC;GACQ;;AAIhB,uBAAuB,cAAc"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["DropdownMenuRoot: typeof Menu.Root","Menu"],"sources":["../../src/DropdownMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Menu } from '@base-ui/react/menu';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Switch } from 'antd';\nimport { cx } from 'antd-style';\nimport clsx from 'clsx';\nimport type React from 'react';\nimport { cloneElement, isValidElement, useCallback, useState } from 'react';\nimport { mergeRefs } from 'react-merge-refs';\n\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { usePortalContainer } from '@/hooks/usePortalContainer';\nimport { styles } from '@/Menu/sharedStyle';\nimport { CLASSNAMES } from '@/styles/classNames';\nimport { placementMap } from '@/utils/placement';\n\nimport { type DropdownMenuPlacement } from './type';\n\nexport const DROPDOWN_MENU_CONTAINER_ATTR = 'data-lobe-ui-dropdown-menu-container';\n\nexport const DropdownMenuRoot: typeof Menu.Root = (props) => <Menu.Root modal={false} {...props} />;\nexport const DropdownMenuSubmenuRoot = Menu.SubmenuRoot;\nexport const DropdownMenuCheckboxItemIndicator = Menu.CheckboxItemIndicator;\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => cx(base, className(state));\n return cx(base, className);\n};\n\nexport type DropdownMenuTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Menu.Trigger>,\n 'children' | 'render'\n> & {\n children: React.ReactNode;\n};\n\nexport const DropdownMenuTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DropdownMenuTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n className: clsx(CLASSNAMES.DropdownMenuTrigger, className, mergedProps.className),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return <Menu.Trigger {...rest} nativeButton={resolvedNativeButton} render={renderer as any} />;\n }\n\n return (\n <Menu.Trigger\n {...rest}\n className={clsx(CLASSNAMES.DropdownMenuTrigger, className)}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Menu.Trigger>\n );\n};\n\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\nexport type DropdownMenuPortalProps = React.ComponentProps<typeof Menu.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const DropdownMenuPortal = ({ container, ...rest }: DropdownMenuPortalProps) => {\n const defaultContainer = usePortalContainer(DROPDOWN_MENU_CONTAINER_ATTR);\n return <Menu.Portal container={container ?? defaultContainer} {...rest} />;\n};\n\nDropdownMenuPortal.displayName = 'DropdownMenuPortal';\n\nexport type DropdownMenuPositionerProps = React.ComponentProps<typeof Menu.Positioner> & {\n hoverTrigger?: boolean;\n placement?: DropdownMenuPlacement;\n};\n\nexport const DropdownMenuPositioner = ({\n className,\n placement,\n hoverTrigger,\n align,\n side,\n sideOffset,\n children,\n ...rest\n}: DropdownMenuPositionerProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <Menu.Positioner\n {...rest}\n align={align ?? placementConfig?.align}\n className={mergeStateClassName(styles.positioner, className as any) as any}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={setPositionerNode}\n side={side ?? placementConfig?.side}\n sideOffset={sideOffset ?? (placementConfig ? 6 : undefined)}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </Menu.Positioner>\n );\n};\n\nDropdownMenuPositioner.displayName = 'DropdownMenuPositioner';\n\nexport type DropdownMenuPopupProps = React.ComponentProps<typeof Menu.Popup>;\n\nexport const DropdownMenuPopup = ({ className, ...rest }: DropdownMenuPopupProps) => {\n return (\n <Menu.Popup {...rest} className={mergeStateClassName(styles.popup, className as any) as any} />\n );\n};\n\nDropdownMenuPopup.displayName = 'DropdownMenuPopup';\n\nexport type DropdownMenuItemProps = React.ComponentProps<typeof Menu.Item> & { danger?: boolean };\n\nexport const DropdownMenuItem = ({ className, danger, ...rest }: DropdownMenuItemProps) => {\n return (\n <Menu.Item\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport type DropdownMenuCheckboxItemProps = React.ComponentProps<typeof Menu.CheckboxItem> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuCheckboxItemPrimitive = ({\n className,\n danger,\n ...rest\n}: DropdownMenuCheckboxItemProps) => {\n return (\n <Menu.CheckboxItem\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuCheckboxItemPrimitive.displayName = 'DropdownMenuCheckboxItemPrimitive';\n\nexport type DropdownMenuSeparatorProps = React.ComponentProps<typeof Menu.Separator>;\n\nexport const DropdownMenuSeparator = ({ className, ...rest }: DropdownMenuSeparatorProps) => {\n return (\n <Menu.Separator\n {...rest}\n className={(state) =>\n cx(styles.separator, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\nexport const DropdownMenuGroup = Menu.Group;\n\nexport type DropdownMenuGroupLabelProps = React.ComponentProps<typeof Menu.GroupLabel>;\n\nexport const DropdownMenuGroupLabel = ({ className, ...rest }: DropdownMenuGroupLabelProps) => {\n return (\n <Menu.GroupLabel\n {...rest}\n className={(state) =>\n cx(styles.groupLabel, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuGroupLabel.displayName = 'DropdownMenuGroupLabel';\n\nexport type DropdownMenuSubmenuTriggerProps = React.ComponentProps<typeof Menu.SubmenuTrigger> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuSubmenuTrigger = ({\n className,\n danger,\n ...rest\n}: DropdownMenuSubmenuTriggerProps) => {\n return (\n <Menu.SubmenuTrigger\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuSubmenuTrigger.displayName = 'DropdownMenuSubmenuTrigger';\n\nexport type DropdownMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemContent = ({ className, ...rest }: DropdownMenuItemContentProps) => {\n return <div {...rest} className={cx(styles.itemContent, className)} />;\n};\n\nDropdownMenuItemContent.displayName = 'DropdownMenuItemContent';\n\nexport type DropdownMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemIcon = ({ className, ...rest }: DropdownMenuItemIconProps) => {\n return <span {...rest} className={cx(styles.icon, className)} />;\n};\n\nDropdownMenuItemIcon.displayName = 'DropdownMenuItemIcon';\n\nexport type DropdownMenuItemLabelGroupProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemLabelGroup = ({\n className,\n ...rest\n}: DropdownMenuItemLabelGroupProps) => {\n return <div {...rest} className={cx(styles.labelGroup, className)} />;\n};\n\nDropdownMenuItemLabelGroup.displayName = 'DropdownMenuItemLabelGroup';\n\nexport type DropdownMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemLabel = ({ className, ...rest }: DropdownMenuItemLabelProps) => {\n return <span {...rest} className={cx(styles.label, className)} />;\n};\n\nDropdownMenuItemLabel.displayName = 'DropdownMenuItemLabel';\n\nexport type DropdownMenuItemDescProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemDesc = ({ className, ...rest }: DropdownMenuItemDescProps) => {\n return <span {...rest} className={cx(styles.desc, className)} />;\n};\n\nDropdownMenuItemDesc.displayName = 'DropdownMenuItemDesc';\n\nexport type DropdownMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemExtra = ({ className, ...rest }: DropdownMenuItemExtraProps) => {\n return <span {...rest} className={cx(styles.extra, className)} />;\n};\n\nDropdownMenuItemExtra.displayName = 'DropdownMenuItemExtra';\n\nexport type DropdownMenuSubmenuArrowProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuSubmenuArrow = ({ className, ...rest }: DropdownMenuSubmenuArrowProps) => {\n return <span {...rest} className={cx(styles.submenuArrow, className)} />;\n};\n\nDropdownMenuSubmenuArrow.displayName = 'DropdownMenuSubmenuArrow';\n\nexport type DropdownMenuSwitchItemProps = Omit<\n React.ComponentProps<typeof Menu.Item>,\n 'onClick'\n> & {\n checked?: boolean;\n closeOnClick?: boolean;\n danger?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n};\n\nexport const DropdownMenuSwitchItem = ({\n checked: checkedProp,\n className,\n closeOnClick = false,\n danger,\n defaultChecked,\n disabled,\n onCheckedChange,\n children,\n ...rest\n}: DropdownMenuSwitchItemProps) => {\n const [internalChecked, setInternalChecked] = useState(defaultChecked ?? false);\n const isControlled = checkedProp !== undefined;\n const checked = isControlled ? checkedProp : internalChecked;\n\n const handleCheckedChange = useCallback(\n (newChecked: boolean) => {\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n onCheckedChange?.(newChecked);\n },\n [isControlled, onCheckedChange],\n );\n\n return (\n <Menu.Item\n {...rest}\n closeOnClick={closeOnClick}\n disabled={disabled}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n onClick={(e) => {\n e.preventDefault();\n if (!disabled) {\n handleCheckedChange(!checked);\n }\n }}\n >\n {children}\n <Switch\n checked={checked}\n disabled={disabled}\n size=\"small\"\n style={{ marginInlineStart: 16 }}\n onChange={handleCheckedChange}\n onClick={(_, e) => e.stopP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G,OAAO,OAAO,UAAU;GAAI;;AAGnE,sBAAsB,cAAc;AAIpC,MAAa,4BAA4B,EAAE,WAAW,GAAG,WAA0C;AACjG,QAAO,oBAAC;EAAK,GAAI;EAAM,WAAW,GAAG,OAAO,cAAc,UAAU;GAAI;;AAG1E,yBAAyB,cAAc;AAavC,MAAa,0BAA0B,EACrC,SAAS,aACT,WACA,eAAe,OACf,QACA,gBACA,UACA,iBACA,UACA,GAAG,WAC8B;CACjC,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,kBAAkB,MAAM;CAC/E,MAAM,eAAe,gBAAgB;CACrC,MAAM,UAAU,eAAe,cAAc;CAE7C,MAAM,sBAAsB,aACzB,eAAwB;AACvB,MAAI,CAAC,aACH,oBAAmB,WAAW;AAEhC,oBAAkB,WAAW;IAE/B,CAAC,cAAc,gBAAgB,CAChC;AAED,QACE,qBAACA,OAAK;EACJ,GAAI;EACU;EACJ;EACV,YAAY,UACV,GACE,OAAO,MACP,UAAU,OAAO,QACjB,OAAO,cAAc,aAAa,UAAU,MAAM,GAAG,UACtD;EAEH,UAAU,MAAM;AACd,KAAE,gBAAgB;AAClB,OAAI,CAAC,SACH,qBAAoB,CAAC,QAAQ;;aAIhC,UACD,oBAAC;GACU;GACC;GACV,MAAK;GACL,OAAO,EAAE,mBAAmB,IAAI;GAChC,UAAU;GACV,UAAU,GAAG,MAAM,EAAE,iBAAiB;IACtC;GACQ;;AAIhB,uBAAuB,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconSpaceMode } from "../Menu/renderUtils.mjs";
|
|
2
2
|
import { renderDropdownMenuItems } from "./renderItems.mjs";
|
|
3
3
|
import { DropdownItem, DropdownMenuCheckboxItem, DropdownMenuPlacement, DropdownMenuProps, DropdownMenuSwitchItem as DropdownMenuSwitchItem$1 } from "./type.mjs";
|
|
4
|
-
import { DROPDOWN_MENU_CONTAINER_ATTR, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuCheckboxItemProps, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuGroupLabelProps, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemContentProps, DropdownMenuItemExtra, DropdownMenuItemExtraProps, DropdownMenuItemIcon, DropdownMenuItemIconProps, DropdownMenuItemLabel, DropdownMenuItemLabelProps, DropdownMenuItemProps, DropdownMenuPopup, DropdownMenuPopupProps, DropdownMenuPortal, DropdownMenuPortalProps, DropdownMenuPositioner, DropdownMenuPositionerProps, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSubmenuTriggerProps, DropdownMenuSwitchItem, DropdownMenuSwitchItemProps, DropdownMenuTrigger, DropdownMenuTriggerProps } from "./atoms.mjs";
|
|
4
|
+
import { DROPDOWN_MENU_CONTAINER_ATTR, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuCheckboxItemProps, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuGroupLabelProps, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemContentProps, DropdownMenuItemDesc, DropdownMenuItemDescProps, DropdownMenuItemExtra, DropdownMenuItemExtraProps, DropdownMenuItemIcon, DropdownMenuItemIconProps, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, DropdownMenuItemLabelGroupProps, DropdownMenuItemLabelProps, DropdownMenuItemProps, DropdownMenuPopup, DropdownMenuPopupProps, DropdownMenuPortal, DropdownMenuPortalProps, DropdownMenuPositioner, DropdownMenuPositionerProps, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSubmenuTriggerProps, DropdownMenuSwitchItem, DropdownMenuSwitchItemProps, DropdownMenuTrigger, DropdownMenuTriggerProps } from "./atoms.mjs";
|
|
5
5
|
import { DropdownMenu } from "./DropdownMenu.mjs";
|
|
6
|
-
export { DROPDOWN_MENU_CONTAINER_ATTR, type DropdownItem, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, type DropdownMenuCheckboxItemProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuSwitchItem, type DropdownMenuSwitchItemProps, type DropdownMenuSwitchItem$1 as DropdownMenuSwitchItemType, DropdownMenuTrigger, type DropdownMenuTriggerProps, type IconSpaceMode, DropdownMenu as default, renderDropdownMenuItems };
|
|
6
|
+
export { DROPDOWN_MENU_CONTAINER_ATTR, type DropdownItem, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, type DropdownMenuCheckboxItemProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemDesc, type DropdownMenuItemDescProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, type DropdownMenuItemLabelGroupProps, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuSwitchItem, type DropdownMenuSwitchItemProps, type DropdownMenuSwitchItem$1 as DropdownMenuSwitchItemType, DropdownMenuTrigger, type DropdownMenuTriggerProps, type IconSpaceMode, DropdownMenu as default, renderDropdownMenuItems };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DROPDOWN_MENU_CONTAINER_ATTR, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSwitchItem, DropdownMenuTrigger } from "./atoms.mjs";
|
|
1
|
+
import { DROPDOWN_MENU_CONTAINER_ATTR, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemDesc, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSwitchItem, DropdownMenuTrigger } from "./atoms.mjs";
|
|
2
2
|
import { renderDropdownMenuItems } from "./renderItems.mjs";
|
|
3
3
|
import DropdownMenu_default from "./DropdownMenu.mjs";
|
|
4
4
|
|
|
5
|
-
export { DROPDOWN_MENU_CONTAINER_ATTR, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSwitchItem, DropdownMenuTrigger, DropdownMenu_default as default, renderDropdownMenuItems };
|
|
5
|
+
export { DROPDOWN_MENU_CONTAINER_ATTR, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemDesc, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSwitchItem, DropdownMenuTrigger, DropdownMenu_default as default, renderDropdownMenuItems };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { styles } from "../Menu/sharedStyle.mjs";
|
|
2
|
+
import { DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemDesc, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSwitchItem } from "./atoms.mjs";
|
|
2
3
|
import { getItemKey, getItemLabel, hasAnyIcon, hasCheckboxAndIcon, renderIcon } from "../Menu/renderUtils.mjs";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { Check, ChevronRight } from "lucide-react";
|
|
@@ -6,20 +7,28 @@ import { Check, ChevronRight } from "lucide-react";
|
|
|
6
7
|
//#region src/DropdownMenu/renderItems.tsx
|
|
7
8
|
const renderItemContent = (item, options, iconNode) => {
|
|
8
9
|
const label = getItemLabel(item);
|
|
10
|
+
const desc = "desc" in item ? item.desc : void 0;
|
|
9
11
|
const extra = "extra" in item ? item.extra : void 0;
|
|
10
12
|
const indicatorOnRight = options?.indicatorOnRight;
|
|
13
|
+
const alignStart = Boolean(desc) && options?.iconAlign === "start";
|
|
11
14
|
const hasCustomIcon = iconNode !== void 0 && !indicatorOnRight;
|
|
12
15
|
const hasIcon = hasCustomIcon ? Boolean(iconNode) : Boolean(item.icon);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const shouldRenderIcon = hasCustomIcon ? Boolean(options?.reserveIconSpace || iconNode) : Boolean(hasIcon || options?.reserveIconSpace);
|
|
17
|
+
const labelNode = desc ? /* @__PURE__ */ jsxs(DropdownMenuItemLabelGroup, { children: [/* @__PURE__ */ jsx(DropdownMenuItemLabel, { children: label }), /* @__PURE__ */ jsx(DropdownMenuItemDesc, { children: desc })] }) : /* @__PURE__ */ jsx(DropdownMenuItemLabel, { children: label });
|
|
18
|
+
return /* @__PURE__ */ jsxs(DropdownMenuItemContent, {
|
|
19
|
+
className: alignStart ? styles.itemContentAlignStart : void 0,
|
|
20
|
+
children: [
|
|
21
|
+
shouldRenderIcon ? /* @__PURE__ */ jsx(DropdownMenuItemIcon, {
|
|
22
|
+
"aria-hidden": !hasIcon,
|
|
23
|
+
className: alignStart ? styles.iconAlignStart : void 0,
|
|
24
|
+
children: hasCustomIcon ? iconNode : hasIcon ? renderIcon(item.icon) : null
|
|
25
|
+
}) : null,
|
|
26
|
+
labelNode,
|
|
27
|
+
extra ? /* @__PURE__ */ jsx(DropdownMenuItemExtra, { children: extra }) : null,
|
|
28
|
+
indicatorOnRight && iconNode ? iconNode : null,
|
|
29
|
+
options?.submenu ? /* @__PURE__ */ jsx(DropdownMenuSubmenuArrow, { children: /* @__PURE__ */ jsx(ChevronRight, { size: 16 }) }) : null
|
|
30
|
+
]
|
|
31
|
+
});
|
|
23
32
|
};
|
|
24
33
|
const invokeItemClick = (item, keyPath, event) => {
|
|
25
34
|
if (!item.onClick) return;
|
|
@@ -33,6 +42,7 @@ const invokeItemClick = (item, keyPath, event) => {
|
|
|
33
42
|
item.onClick(info);
|
|
34
43
|
};
|
|
35
44
|
const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
45
|
+
const iconAlign = options?.iconAlign;
|
|
36
46
|
const iconSpaceMode = options?.iconSpaceMode ?? "global";
|
|
37
47
|
const reserveIconSpace = options?.reserveIconSpace ?? hasAnyIcon(items, iconSpaceMode === "global");
|
|
38
48
|
const indicatorOnRight = options?.indicatorOnRight ?? hasCheckboxAndIcon(items);
|
|
@@ -55,6 +65,7 @@ const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
|
55
65
|
label: labelText$1,
|
|
56
66
|
onCheckedChange: (checked) => checkboxItem.onCheckedChange?.(checked),
|
|
57
67
|
children: renderItemContent(checkboxItem, {
|
|
68
|
+
iconAlign,
|
|
58
69
|
indicatorOnRight,
|
|
59
70
|
reserveIconSpace
|
|
60
71
|
}, indicator)
|
|
@@ -73,7 +84,10 @@ const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
|
73
84
|
disabled: switchItem.disabled,
|
|
74
85
|
label: labelText$1,
|
|
75
86
|
onCheckedChange: (checked) => switchItem.onCheckedChange?.(checked),
|
|
76
|
-
children: renderItemContent(switchItem, {
|
|
87
|
+
children: renderItemContent(switchItem, {
|
|
88
|
+
iconAlign,
|
|
89
|
+
reserveIconSpace
|
|
90
|
+
})
|
|
77
91
|
}, itemKey);
|
|
78
92
|
}
|
|
79
93
|
if (item.type === "divider") return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, itemKey);
|
|
@@ -82,6 +96,7 @@ const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
|
82
96
|
const groupReserveIconSpace = iconSpaceMode === "group" ? group.children ? hasAnyIcon(group.children) : false : reserveIconSpace;
|
|
83
97
|
const groupIndicatorOnRight = group.children ? hasCheckboxAndIcon(group.children) : false;
|
|
84
98
|
return /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [group.label ? /* @__PURE__ */ jsx(DropdownMenuGroupLabel, { children: group.label }) : null, group.children ? renderDropdownMenuItems(group.children, nextKeyPath, {
|
|
99
|
+
iconAlign,
|
|
85
100
|
iconSpaceMode,
|
|
86
101
|
indicatorOnRight: groupIndicatorOnRight,
|
|
87
102
|
reserveIconSpace: groupReserveIconSpace
|
|
@@ -96,6 +111,7 @@ const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
|
96
111
|
disabled: submenu.disabled,
|
|
97
112
|
label: labelText$1,
|
|
98
113
|
children: renderItemContent(submenu, {
|
|
114
|
+
iconAlign,
|
|
99
115
|
reserveIconSpace,
|
|
100
116
|
submenu: true
|
|
101
117
|
})
|
|
@@ -103,7 +119,10 @@ const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
|
103
119
|
alignOffset: -4,
|
|
104
120
|
"data-submenu": "",
|
|
105
121
|
sideOffset: -1,
|
|
106
|
-
children: /* @__PURE__ */ jsx(DropdownMenuPopup, { children: submenu.children ? renderDropdownMenuItems(submenu.children, nextKeyPath, {
|
|
122
|
+
children: /* @__PURE__ */ jsx(DropdownMenuPopup, { children: submenu.children ? renderDropdownMenuItems(submenu.children, nextKeyPath, {
|
|
123
|
+
iconAlign,
|
|
124
|
+
iconSpaceMode
|
|
125
|
+
}) : null })
|
|
107
126
|
}) })] }, itemKey);
|
|
108
127
|
}
|
|
109
128
|
const menuItem = item;
|
|
@@ -116,7 +135,10 @@ const renderDropdownMenuItems = (items, keyPath = [], options) => {
|
|
|
116
135
|
disabled: menuItem.disabled,
|
|
117
136
|
label: labelText,
|
|
118
137
|
onClick: (event) => invokeItemClick(menuItem, nextKeyPath, event),
|
|
119
|
-
children: renderItemContent(menuItem, {
|
|
138
|
+
children: renderItemContent(menuItem, {
|
|
139
|
+
iconAlign,
|
|
140
|
+
reserveIconSpace
|
|
141
|
+
})
|
|
120
142
|
}, itemKey);
|
|
121
143
|
});
|
|
122
144
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderItems.mjs","names":["info: MenuInfo","label","labelText","isDanger"],"sources":["../../src/DropdownMenu/renderItems.tsx"],"sourcesContent":["import { Check, ChevronRight } from 'lucide-react';\nimport type { MenuInfo } from 'rc-menu/es/interface';\nimport type {\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n} from 'react';\n\nimport {\n type MenuDividerType,\n type MenuItemGroupType,\n type MenuItemType,\n type RenderItemContentOptions,\n type RenderOptions,\n type SubMenuType,\n getItemKey,\n getItemLabel,\n hasAnyIcon,\n hasCheckboxAndIcon,\n renderIcon,\n} from '@/Menu';\n\nimport {\n DropdownMenuCheckboxItemIndicator,\n DropdownMenuCheckboxItemPrimitive,\n DropdownMenuGroup,\n DropdownMenuGroupLabel,\n DropdownMenuItem,\n DropdownMenuItemContent,\n DropdownMenuItemExtra,\n DropdownMenuItemIcon,\n DropdownMenuItemLabel,\n DropdownMenuPopup,\n DropdownMenuPortal,\n DropdownMenuPositioner,\n DropdownMenuSeparator,\n DropdownMenuSubmenuArrow,\n DropdownMenuSubmenuRoot,\n DropdownMenuSubmenuTrigger,\n DropdownMenuSwitchItem,\n} from './atoms';\nimport type {\n DropdownItem,\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemType,\n DropdownMenuSwitchItem as DropdownMenuSwitchItemType,\n} from './type';\n\nexport type { IconSpaceMode } from '@/Menu';\n\nconst renderItemContent = (\n item: MenuItemType | SubMenuType | DropdownMenuCheckboxItemType | DropdownMenuSwitchItemType,\n options?: RenderItemContentOptions,\n iconNode?: ReactNode,\n) => {\n const label = getItemLabel(item);\n const extra = 'extra' in item ? item.extra : undefined;\n const indicatorOnRight = options?.indicatorOnRight;\n const hasCustomIcon = iconNode !== undefined && !indicatorOnRight;\n const hasIcon = hasCustomIcon ? Boolean(iconNode) : Boolean(item.icon);\n const shouldRenderIcon = hasCustomIcon\n ? Boolean(options?.reserveIconSpace || iconNode)\n : Boolean(hasIcon || options?.reserveIconSpace);\n\n return (\n <DropdownMenuItemContent>\n {shouldRenderIcon ? (\n <DropdownMenuItemIcon aria-hidden={!hasIcon}>\n {hasCustomIcon ? iconNode : hasIcon ? renderIcon(item.icon) : null}\n </DropdownMenuItemIcon>\n ) : null}\n <DropdownMenuItemLabel>{label}</DropdownMenuItemLabel>\n {extra ? <DropdownMenuItemExtra>{extra}</DropdownMenuItemExtra> : null}\n {indicatorOnRight && iconNode ? iconNode : null}\n {options?.submenu ? (\n <DropdownMenuSubmenuArrow>\n <ChevronRight size={16} />\n </DropdownMenuSubmenuArrow>\n ) : null}\n </DropdownMenuItemContent>\n );\n};\n\nconst invokeItemClick = (\n item: MenuItemType,\n keyPath: string[],\n event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>,\n) => {\n if (!item.onClick) return;\n const key = item.key ?? keyPath.at(-1) ?? '';\n const info: MenuInfo = {\n domEvent: event,\n item: event.currentTarget as MenuInfo['item'],\n key: String(key),\n keyPath,\n };\n item.onClick(info);\n};\n\nexport const renderDropdownMenuItems = (\n items: DropdownItem[],\n keyPath: string[] = [],\n options?: RenderOptions,\n): ReactNode[] => {\n const iconSpaceMode = options?.iconSpaceMode ?? 'global';\n const reserveIconSpace =\n options?.reserveIconSpace ?? hasAnyIcon(items, iconSpaceMode === 'global');\n const indicatorOnRight = options?.indicatorOnRight ?? hasCheckboxAndIcon(items);\n\n return items.map((item, index) => {\n if (!item) return null;\n\n const fallbackKey = `${keyPath.join('-') || 'root'}-${index}`;\n const itemKey = getItemKey(item, fallbackKey);\n const nextKeyPath = [...keyPath, String(itemKey)];\n\n if ((item as DropdownMenuCheckboxItemType).type === 'checkbox') {\n const checkboxItem = item as DropdownMenuCheckboxItemType;\n const label = getItemLabel(checkboxItem);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = Boolean(checkboxItem.danger);\n const indicator = (\n <DropdownMenuCheckboxItemIndicator>{renderIcon(Check)}</DropdownMenuCheckboxItemIndicator>\n );\n\n return (\n <DropdownMenuCheckboxItemPrimitive\n checked={checkboxItem.checked}\n closeOnClick={checkboxItem.closeOnClick}\n danger={isDanger}\n defaultChecked={checkboxItem.defaultChecked}\n disabled={checkboxItem.disabled}\n key={itemKey}\n label={labelText}\n onCheckedChange={(checked) => checkboxItem.onCheckedChange?.(checked)}\n >\n {renderItemContent(checkboxItem, { indicatorOnRight, reserveIconSpace }, indicator)}\n </DropdownMenuCheckboxItemPrimitive>\n );\n }\n\n if ((item as DropdownMenuSwitchItemType).type === 'switch') {\n const switchItem = item as DropdownMenuSwitchItemType;\n const label = getItemLabel(switchItem);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = Boolean(switchItem.danger);\n\n return (\n <DropdownMenuSwitchItem\n checked={switchItem.checked}\n closeOnClick={switchItem.closeOnClick}\n danger={isDanger}\n defaultChecked={switchItem.defaultChecked}\n disabled={switchItem.disabled}\n key={itemKey}\n label={labelText}\n onCheckedChange={(checked) => switchItem.onCheckedChange?.(checked)}\n >\n {renderItemContent(switchItem, { reserveIconSpace })}\n </DropdownMenuSwitchItem>\n );\n }\n\n if ((item as MenuDividerType).type === 'divider') {\n return <DropdownMenuSeparator key={itemKey} />;\n }\n\n if ((item as MenuItemGroupType).type === 'group') {\n const group = item as MenuItemGroupType;\n const groupReserveIconSpace =\n iconSpaceMode === 'group'\n ? group.children\n ? hasAnyIcon(group.children)\n : false\n : reserveIconSpace;\n const groupIndicatorOnRight = group.children ? hasCheckboxAndIcon(group.children) : false;\n return (\n <DropdownMenuGroup key={itemKey}>\n {group.label ? <DropdownMenuGroupLabel>{group.label}</DropdownMenuGroupLabel> : null}\n {group.children\n ? renderDropdownMenuItems(group.children, nextKeyPath, {\n iconSpaceMode,\n indicatorOnRight: groupIndicatorOnRight,\n reserveIconSpace: groupReserveIconSpace,\n })\n : null}\n </DropdownMenuGroup>\n );\n }\n\n if ((item as SubMenuType).type === 'submenu' || 'children' in item) {\n const submenu = item as SubMenuType;\n const label = getItemLabel(submenu);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = 'danger' in submenu && Boolean(submenu.danger);\n\n return (\n <DropdownMenuSubmenuRoot key={itemKey}>\n <DropdownMenuSubmenuTrigger\n danger={isDanger}\n disabled={submenu.disabled}\n label={labelText}\n >\n {renderItemContent(submenu, {\n reserveIconSpace,\n submenu: true,\n })}\n </DropdownMenuSubmenuTrigger>\n <DropdownMenuPortal>\n <DropdownMenuPositioner alignOffset={-4} data-submenu=\"\" sideOffset={-1}>\n <DropdownMenuPopup>\n {submenu.children\n ? renderDropdownMenuItems(submenu.children, nextKeyPath, { iconSpaceMode })\n : null}\n </DropdownMenuPopup>\n </DropdownMenuPositioner>\n </DropdownMenuPortal>\n </DropdownMenuSubmenuRoot>\n );\n }\n\n const menuItem = item as MenuItemType;\n const label = getItemLabel(menuItem);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = 'danger' in menuItem && Boolean(menuItem.danger);\n\n return (\n <DropdownMenuItem\n closeOnClick={menuItem.closeOnClick}\n danger={isDanger}\n disabled={menuItem.disabled}\n key={itemKey}\n label={labelText}\n onClick={(event) => invokeItemClick(menuItem, nextKeyPath, event)}\n >\n {renderItemContent(menuItem, { reserveIconSpace })}\n </DropdownMenuItem>\n );\n });\n};\n"],"mappings":";;;;;;AAiDA,MAAM,qBACJ,MACA,SACA,aACG;CACH,MAAM,QAAQ,aAAa,KAAK;CAChC,MAAM,QAAQ,WAAW,OAAO,KAAK,QAAQ;CAC7C,MAAM,mBAAmB,SAAS;CAClC,MAAM,gBAAgB,aAAa,UAAa,CAAC;CACjD,MAAM,UAAU,gBAAgB,QAAQ,SAAS,GAAG,QAAQ,KAAK,KAAK;AAKtE,QACE,qBAAC;GALsB,gBACrB,QAAQ,SAAS,oBAAoB,SAAS,GAC9C,QAAQ,WAAW,SAAS,iBAAiB,IAK3C,oBAAC;GAAqB,eAAa,CAAC;aACjC,gBAAgB,WAAW,UAAU,WAAW,KAAK,KAAK,GAAG;IACzC,GACrB;EACJ,oBAAC,mCAAuB,QAA8B;EACrD,QAAQ,oBAAC,mCAAuB,QAA8B,GAAG;EACjE,oBAAoB,WAAW,WAAW;EAC1C,SAAS,UACR,oBAAC,sCACC,oBAAC,gBAAa,MAAM,KAAM,GACD,GACzB;KACoB;;AAI9B,MAAM,mBACJ,MACA,SACA,UACG;AACH,KAAI,CAAC,KAAK,QAAS;CACnB,MAAM,MAAM,KAAK,OAAO,QAAQ,GAAG,GAAG,IAAI;CAC1C,MAAMA,OAAiB;EACrB,UAAU;EACV,MAAM,MAAM;EACZ,KAAK,OAAO,IAAI;EAChB;EACD;AACD,MAAK,QAAQ,KAAK;;AAGpB,MAAa,2BACX,OACA,UAAoB,EAAE,EACtB,YACgB;CAChB,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,mBACJ,SAAS,oBAAoB,WAAW,OAAO,kBAAkB,SAAS;CAC5E,MAAM,mBAAmB,SAAS,oBAAoB,mBAAmB,MAAM;AAE/E,QAAO,MAAM,KAAK,MAAM,UAAU;AAChC,MAAI,CAAC,KAAM,QAAO;EAGlB,MAAM,UAA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,QAAQ,oBAAC,oCAAwB,MAAM,QAA+B,GAAG,MAC/E,MAAM,WACH,wBAAwB,MAAM,UAAU,aAAa;IACnD;IACA,kBAAkB;IAClB,kBAAkB;IACnB,CAAC,GACF,SARkB,QASJ;;AAIxB,MAAK,KAAqB,SAAS,aAAa,cAAc,MAAM;GAClE,MAAM,UAAU;GAChB,MAAMD,UAAQ,aAAa,QAAQ;GACnC,MAAMC,cAAY,OAAOD,YAAU,WAAWA,UAAQ;AAGtD,UACE,qBAAC,sCACC,oBAAC;IACC,QALW,YAAY,WAAW,QAAQ,QAAQ,OAAO;IAMzD,UAAU,QAAQ;IAClB,OAAOC;cAEN,kBAAkB,SAAS;KAC1B;KACA,SAAS;KACV,CAAC;KACyB,EAC7B,oBAAC,gCACC,oBAAC;IAAuB,aAAa;IAAI,gBAAa;IAAG,YAAY;cACnE,oBAAC,+BACE,QAAQ,WACL,wBAAwB,QAAQ,UAAU,aAAa,EAAE,eAAe,CAAC,GACzE,OACc;KACG,GACN,KAnBO,QAoBJ;;EAI9B,MAAM,WAAW;EACjB,MAAM,QAAQ,aAAa,SAAS;EACpC,MAAM,YAAY,OAAO,UAAU,WAAW,QAAQ;EACtD,MAAM,WAAW,YAAY,YAAY,QAAQ,SAAS,OAAO;AAEjE,SACE,oBAAC;GACC,cAAc,SAAS;GACvB,QAAQ;GACR,UAAU,SAAS;GAEnB,OAAO;GACP,UAAU,UAAU,gBAAgB,UAAU,aAAa,MAAM;aAEhE,kBAAkB,UAAU,EAAE,kBAAkB,CAAC;KAJ7C,QAKY;GAErB"}
|
|
1
|
+
{"version":3,"file":"renderItems.mjs","names":["info: MenuInfo","label","labelText","isDanger"],"sources":["../../src/DropdownMenu/renderItems.tsx"],"sourcesContent":["import { Check, ChevronRight } from 'lucide-react';\nimport { type MenuInfo } from 'rc-menu/es/interface';\nimport {\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n} from 'react';\n\nimport {\n getItemKey,\n getItemLabel,\n hasAnyIcon,\n hasCheckboxAndIcon,\n type MenuDividerType,\n type MenuItemGroupType,\n type MenuItemType,\n renderIcon,\n type RenderItemContentOptions,\n type RenderOptions,\n type SubMenuType,\n} from '@/Menu';\nimport { styles } from '@/Menu/sharedStyle';\n\nimport {\n DropdownMenuCheckboxItemIndicator,\n DropdownMenuCheckboxItemPrimitive,\n DropdownMenuGroup,\n DropdownMenuGroupLabel,\n DropdownMenuItem,\n DropdownMenuItemContent,\n DropdownMenuItemDesc,\n DropdownMenuItemExtra,\n DropdownMenuItemIcon,\n DropdownMenuItemLabel,\n DropdownMenuItemLabelGroup,\n DropdownMenuPopup,\n DropdownMenuPortal,\n DropdownMenuPositioner,\n DropdownMenuSeparator,\n DropdownMenuSubmenuArrow,\n DropdownMenuSubmenuRoot,\n DropdownMenuSubmenuTrigger,\n DropdownMenuSwitchItem,\n} from './atoms';\nimport {\n type DropdownItem,\n type DropdownMenuCheckboxItem as DropdownMenuCheckboxItemType,\n type DropdownMenuSwitchItem as DropdownMenuSwitchItemType,\n} from './type';\n\nexport type { IconAlign, IconSpaceMode } from '@/Menu';\n\nconst renderItemContent = (\n item: MenuItemType | SubMenuType | DropdownMenuCheckboxItemType | DropdownMenuSwitchItemType,\n options?: RenderItemContentOptions,\n iconNode?: ReactNode,\n) => {\n const label = getItemLabel(item);\n const desc = 'desc' in item ? item.desc : undefined;\n const extra = 'extra' in item ? item.extra : undefined;\n const indicatorOnRight = options?.indicatorOnRight;\n const alignStart = Boolean(desc) && options?.iconAlign === 'start';\n\n const hasCustomIcon = iconNode !== undefined && !indicatorOnRight;\n const hasIcon = hasCustomIcon ? Boolean(iconNode) : Boolean(item.icon);\n const shouldRenderIcon = hasCustomIcon\n ? Boolean(options?.reserveIconSpace || iconNode)\n : Boolean(hasIcon || options?.reserveIconSpace);\n\n const labelNode = desc ? (\n <DropdownMenuItemLabelGroup>\n <DropdownMenuItemLabel>{label}</DropdownMenuItemLabel>\n <DropdownMenuItemDesc>{desc}</DropdownMenuItemDesc>\n </DropdownMenuItemLabelGroup>\n ) : (\n <DropdownMenuItemLabel>{label}</DropdownMenuItemLabel>\n );\n\n return (\n <DropdownMenuItemContent className={alignStart ? styles.itemContentAlignStart : undefined}>\n {shouldRenderIcon ? (\n <DropdownMenuItemIcon\n aria-hidden={!hasIcon}\n className={alignStart ? styles.iconAlignStart : undefined}\n >\n {hasCustomIcon ? iconNode : hasIcon ? renderIcon(item.icon) : null}\n </DropdownMenuItemIcon>\n ) : null}\n {labelNode}\n {extra ? <DropdownMenuItemExtra>{extra}</DropdownMenuItemExtra> : null}\n {indicatorOnRight && iconNode ? iconNode : null}\n {options?.submenu ? (\n <DropdownMenuSubmenuArrow>\n <ChevronRight size={16} />\n </DropdownMenuSubmenuArrow>\n ) : null}\n </DropdownMenuItemContent>\n );\n};\n\nconst invokeItemClick = (\n item: MenuItemType,\n keyPath: string[],\n event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>,\n) => {\n if (!item.onClick) return;\n const key = item.key ?? keyPath.at(-1) ?? '';\n const info: MenuInfo = {\n domEvent: event,\n item: event.currentTarget as MenuInfo['item'],\n key: String(key),\n keyPath,\n };\n item.onClick(info);\n};\n\nexport const renderDropdownMenuItems = (\n items: DropdownItem[],\n keyPath: string[] = [],\n options?: RenderOptions,\n): ReactNode[] => {\n const iconAlign = options?.iconAlign;\n const iconSpaceMode = options?.iconSpaceMode ?? 'global';\n const reserveIconSpace =\n options?.reserveIconSpace ?? hasAnyIcon(items, iconSpaceMode === 'global');\n const indicatorOnRight = options?.indicatorOnRight ?? hasCheckboxAndIcon(items);\n\n return items.map((item, index) => {\n if (!item) return null;\n\n const fallbackKey = `${keyPath.join('-') || 'root'}-${index}`;\n const itemKey = getItemKey(item, fallbackKey);\n const nextKeyPath = [...keyPath, String(itemKey)];\n\n if ((item as DropdownMenuCheckboxItemType).type === 'checkbox') {\n const checkboxItem = item as DropdownMenuCheckboxItemType;\n const label = getItemLabel(checkboxItem);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = Boolean(checkboxItem.danger);\n const indicator = (\n <DropdownMenuCheckboxItemIndicator>{renderIcon(Check)}</DropdownMenuCheckboxItemIndicator>\n );\n\n return (\n <DropdownMenuCheckboxItemPrimitive\n checked={checkboxItem.checked}\n closeOnClick={checkboxItem.closeOnClick}\n danger={isDanger}\n defaultChecked={checkboxItem.defaultChecked}\n disabled={checkboxItem.disabled}\n key={itemKey}\n label={labelText}\n onCheckedChange={(checked) => checkboxItem.onCheckedChange?.(checked)}\n >\n {renderItemContent(\n checkboxItem,\n { iconAlign, indicatorOnRight, reserveIconSpace },\n indicator,\n )}\n </DropdownMenuCheckboxItemPrimitive>\n );\n }\n\n if ((item as DropdownMenuSwitchItemType).type === 'switch') {\n const switchItem = item as DropdownMenuSwitchItemType;\n const label = getItemLabel(switchItem);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = Boolean(switchItem.danger);\n\n return (\n <DropdownMenuSwitchItem\n checked={switchItem.checked}\n closeOnClick={switchItem.closeOnClick}\n danger={isDanger}\n defaultChecked={switchItem.defaultChecked}\n disabled={switchItem.disabled}\n key={itemKey}\n label={labelText}\n onCheckedChange={(checked) => switchItem.onCheckedChange?.(checked)}\n >\n {renderItemContent(switchItem, { iconAlign, reserveIconSpace })}\n </DropdownMenuSwitchItem>\n );\n }\n\n if ((item as MenuDividerType).type === 'divider') {\n return <DropdownMenuSeparator key={itemKey} />;\n }\n\n if ((item as MenuItemGroupType).type === 'group') {\n const group = item as MenuItemGroupType;\n const groupReserveIconSpace =\n iconSpaceMode === 'group'\n ? group.children\n ? hasAnyIcon(group.children)\n : false\n : reserveIconSpace;\n const groupIndicatorOnRight = group.children ? hasCheckboxAndIcon(group.children) : false;\n return (\n <DropdownMenuGroup key={itemKey}>\n {group.label ? <DropdownMenuGroupLabel>{group.label}</DropdownMenuGroupLabel> : null}\n {group.children\n ? renderDropdownMenuItems(group.children, nextKeyPath, {\n iconAlign,\n iconSpaceMode,\n indicatorOnRight: groupIndicatorOnRight,\n reserveIconSpace: groupReserveIconSpace,\n })\n : null}\n </DropdownMenuGroup>\n );\n }\n\n if ((item as SubMenuType).type === 'submenu' || 'children' in item) {\n const submenu = item as SubMenuType;\n const label = getItemLabel(submenu);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = 'danger' in submenu && Boolean(submenu.danger);\n\n return (\n <DropdownMenuSubmenuRoot key={itemKey}>\n <DropdownMenuSubmenuTrigger\n danger={isDanger}\n disabled={submenu.disabled}\n label={labelText}\n >\n {renderItemContent(submenu, {\n iconAlign,\n reserveIconSpace,\n submenu: true,\n })}\n </DropdownMenuSubmenuTrigger>\n <DropdownMenuPortal>\n <DropdownMenuPositioner alignOffset={-4} data-submenu=\"\" sideOffset={-1}>\n <DropdownMenuPopup>\n {submenu.children\n ? renderDropdownMenuItems(submenu.children, nextKeyPath, {\n iconAlign,\n iconSpaceMode,\n })\n : null}\n </DropdownMenuPopup>\n </DropdownMenuPositioner>\n </DropdownMenuPortal>\n </DropdownMenuSubmenuRoot>\n );\n }\n\n const menuItem = item as MenuItemType;\n const label = getItemLabel(menuItem);\n const labelText = typeof label === 'string' ? label : undefined;\n const isDanger = 'danger' in menuItem && Boolean(menuItem.danger);\n\n return (\n <DropdownMenuItem\n closeOnClick={menuItem.closeOnClick}\n danger={isDanger}\n disabled={menuItem.disabled}\n key={itemKey}\n label={labelText}\n onClick={(event) => invokeItemClick(menuItem, nextKeyPath, event)}\n >\n {renderItemContent(menuItem, { iconAlign, reserveIconSpace })}\n </DropdownMenuItem>\n );\n });\n};\n"],"mappings":";;;;;;;AAoDA,MAAM,qBACJ,MACA,SACA,aACG;CACH,MAAM,QAAQ,aAAa,KAAK;CAChC,MAAM,OAAO,UAAU,OAAO,KAAK,OAAO;CAC1C,MAAM,QAAQ,WAAW,OAAO,KAAK,QAAQ;CAC7C,MAAM,mBAAmB,SAAS;CAClC,MAAM,aAAa,QAAQ,KAAK,IAAI,SAAS,cAA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,GAAG,MAC/E,MAAM,WACH,wBAAwB,MAAM,UAAU,aAAa;IACnD;IACA;IACA,kBAAkB;IAClB,kBAAkB;IACnB,CAAC,GACF,SATkB,QAUJ;;AAIxB,MAAK,KAAqB,SAAS,aAAa,cAAc,MAAM;GAClE,MAAM,UAAU;GAChB,MAAMD,UAAQ,aAAa,QAAQ;GACnC,MAAMC,cAAY,OAAOD,YAAU,WAAWA,UAAQ;AAGtD,UACE,qBAAC,sCACC,oBAAC;IACC,QALW,YAAY,WAAW,QAAQ,QAAQ,OAAO;IAMzD,UAAU,QAAQ;IAClB,OAAOC;cAEN,kBAAkB,SAAS;KAC1B;KACA;KACA,SAAS;KACV,CAAC;KACyB,EAC7B,oBAAC,gCACC,oBAAC;IAAuB,aAAa;IAAI,gBAAa;IAAG,YAAY;cACnE,oBAAC,+BACE,QAAQ,WACL,wBAAwB,QAAQ,UAAU,aAAa;KACrD;KACA;KACD,CAAC,GACF,OACc;KACG,GACN,KAvBO,QAwBJ;;EAI9B,MAAM,WAAW;EACjB,MAAM,QAAQ,aAAa,SAAS;EACpC,MAAM,YAAY,OAAO,UAAU,WAAW,QAAQ;EACtD,MAAM,WAAW,YAAY,YAAY,QAAQ,SAAS,OAAO;AAEjE,SACE,oBAAC;GACC,cAAc,SAAS;GACvB,QAAQ;GACR,UAAU,SAAS;GAEnB,OAAO;GACP,UAAU,UAAU,gBAAgB,UAAU,aAAa,MAAM;aAEhE,kBAAkB,UAAU;IAAE;IAAW;IAAkB,CAAC;KAJxD,QAKY;GAErB"}
|
|
@@ -4,7 +4,7 @@ import { Placement } from "../utils/placement.mjs";
|
|
|
4
4
|
import { MenuCheckboxItemType } from "../Menu/checkboxItem.mjs";
|
|
5
5
|
import { MenuSwitchItemType } from "../Menu/switchItem.mjs";
|
|
6
6
|
import { BaseMenuItemType } from "../Menu/baseItem.mjs";
|
|
7
|
-
import { IconSpaceMode } from "../Menu/renderUtils.mjs";
|
|
7
|
+
import { IconAlign, IconSpaceMode } from "../Menu/renderUtils.mjs";
|
|
8
8
|
import "../Menu/index.mjs";
|
|
9
9
|
import "./renderItems.mjs";
|
|
10
10
|
import { ReactNode } from "react";
|
|
@@ -17,6 +17,13 @@ type DropdownMenuSwitchItem = MenuSwitchItemType;
|
|
|
17
17
|
type DropdownItem = BaseMenuItemType;
|
|
18
18
|
interface DropdownMenuProps<Payload = unknown> extends Omit<MenuRootProps<Payload>, 'children'> {
|
|
19
19
|
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* 图标与 label+desc 的垂直对齐方式
|
|
22
|
+
* - 'center': 图标垂直居中(默认)
|
|
23
|
+
* - 'start': 图标与第一行文本顶部对齐,仅在 item 有 desc 时生效
|
|
24
|
+
* @default 'center'
|
|
25
|
+
*/
|
|
26
|
+
iconAlign?: IconAlign;
|
|
20
27
|
/**
|
|
21
28
|
* 图标空间保留模式
|
|
22
29
|
* - 'global': 当任何一个选项有图标时,所有 item 都保留图标位
|
|
@@ -22,58 +22,58 @@ const ControlInput = memo(({ value, onChange, onValueChanging, onChangeEnd, onCo
|
|
|
22
22
|
};
|
|
23
23
|
return /* @__PURE__ */ jsx(Input_default, {
|
|
24
24
|
autoFocus: true,
|
|
25
|
-
onChange: (e) => {
|
|
26
|
-
setInput(e.target.value);
|
|
27
|
-
onValueChanging?.(e.target.value);
|
|
28
|
-
},
|
|
29
|
-
onCompositionEnd: (e) => {
|
|
30
|
-
isChineseInput.current = false;
|
|
31
|
-
onCompositionEnd?.(e);
|
|
32
|
-
},
|
|
33
|
-
onCompositionStart: (e) => {
|
|
34
|
-
isChineseInput.current = true;
|
|
35
|
-
onCompositionStart?.(e);
|
|
36
|
-
},
|
|
37
|
-
onFocus,
|
|
38
|
-
onPressEnter: (e) => {
|
|
39
|
-
if (!e.shiftKey && !isChineseInput.current) {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
handleUpload();
|
|
42
|
-
onPressEnter?.(e);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
25
|
ref,
|
|
26
|
+
value: input,
|
|
46
27
|
style: {
|
|
47
28
|
width: "100%",
|
|
48
29
|
...style
|
|
49
30
|
},
|
|
50
31
|
suffix: value === input ? /* @__PURE__ */ jsx("span", {}) : /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
51
|
-
gap: 2,
|
|
52
32
|
horizontal: true,
|
|
33
|
+
gap: 2,
|
|
53
34
|
style: {
|
|
54
35
|
marginRight: -4,
|
|
55
36
|
zIndex: 1
|
|
56
37
|
},
|
|
57
38
|
children: [/* @__PURE__ */ jsx(ActionIcon_default, {
|
|
58
39
|
icon: RotateCcw,
|
|
40
|
+
size: "small",
|
|
41
|
+
title: texts?.reset || "Reset",
|
|
59
42
|
onClick: (e) => {
|
|
60
43
|
e.preventDefault();
|
|
61
44
|
setInput(value || "");
|
|
62
|
-
}
|
|
63
|
-
size: "small",
|
|
64
|
-
title: texts?.reset || "Reset"
|
|
45
|
+
}
|
|
65
46
|
}), /* @__PURE__ */ jsx(ActionIcon_default, {
|
|
66
47
|
icon: submitIcon || Save,
|
|
48
|
+
size: "small",
|
|
49
|
+
title: texts?.submit || "Submit",
|
|
50
|
+
variant: "filled",
|
|
67
51
|
onClick: (e) => {
|
|
68
52
|
e.preventDefault();
|
|
69
53
|
handleUpload();
|
|
70
|
-
}
|
|
71
|
-
size: "small",
|
|
72
|
-
title: texts?.submit || "Submit",
|
|
73
|
-
variant: "filled"
|
|
54
|
+
}
|
|
74
55
|
})]
|
|
75
56
|
}),
|
|
76
|
-
|
|
57
|
+
onFocus,
|
|
58
|
+
onChange: (e) => {
|
|
59
|
+
setInput(e.target.value);
|
|
60
|
+
onValueChanging?.(e.target.value);
|
|
61
|
+
},
|
|
62
|
+
onCompositionEnd: (e) => {
|
|
63
|
+
isChineseInput.current = false;
|
|
64
|
+
onCompositionEnd?.(e);
|
|
65
|
+
},
|
|
66
|
+
onCompositionStart: (e) => {
|
|
67
|
+
isChineseInput.current = true;
|
|
68
|
+
onCompositionStart?.(e);
|
|
69
|
+
},
|
|
70
|
+
onPressEnter: (e) => {
|
|
71
|
+
if (!e.shiftKey && !isChineseInput.current) {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
handleUpload();
|
|
74
|
+
onPressEnter?.(e);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
77
|
...rest
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlInput.mjs","names":["Input","Flexbox","ActionIcon"],"sources":["../../src/EditableText/ControlInput.tsx"],"sourcesContent":["'use client';\n\nimport type { InputRef } from 'antd';\nimport { RotateCcw, Save } from 'lucide-react';\nimport { memo, useEffect, useRef, useState } from 'react';\n\nimport ActionIcon, { type ActionIconProps } from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\nimport Input, { type InputProps } from '@/Input';\n\nexport interface ControlInputProps extends Omit<InputProps, 'onChange' | 'value' | 'onAbort'> {\n onChange?: (value: string) => void;\n onChangeEnd?: (value: string) => void;\n onValueChanging?: (value: string) => void;\n submitIcon?: ActionIconProps['icon'];\n texts?: {\n reset?: string;\n submit?: string;\n };\n value?: string;\n}\n\nconst ControlInput = memo<ControlInputProps>(\n ({\n value,\n onChange,\n onValueChanging,\n onChangeEnd,\n onCompositionEnd,\n onCompositionStart,\n onPressEnter,\n onFocus,\n submitIcon,\n style,\n texts,\n ...rest\n }) => {\n const ref = useRef<InputRef>(null);\n const [input, setInput] = useState<string>(value || '');\n\n const isChineseInput = useRef(false);\n\n useEffect(() => {\n if (value !== undefined) setInput(value);\n }, [value]);\n\n const handleUpload = () => {\n onChange?.(input);\n ref?.current?.blur();\n onChangeEnd?.(input);\n };\n\n return (\n <Input\n autoFocus\n
|
|
1
|
+
{"version":3,"file":"ControlInput.mjs","names":["Input","Flexbox","ActionIcon"],"sources":["../../src/EditableText/ControlInput.tsx"],"sourcesContent":["'use client';\n\nimport type { InputRef } from 'antd';\nimport { RotateCcw, Save } from 'lucide-react';\nimport { memo, useEffect, useRef, useState } from 'react';\n\nimport ActionIcon, { type ActionIconProps } from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\nimport Input, { type InputProps } from '@/Input';\n\nexport interface ControlInputProps extends Omit<InputProps, 'onChange' | 'value' | 'onAbort'> {\n onChange?: (value: string) => void;\n onChangeEnd?: (value: string) => void;\n onValueChanging?: (value: string) => void;\n submitIcon?: ActionIconProps['icon'];\n texts?: {\n reset?: string;\n submit?: string;\n };\n value?: string;\n}\n\nconst ControlInput = memo<ControlInputProps>(\n ({\n value,\n onChange,\n onValueChanging,\n onChangeEnd,\n onCompositionEnd,\n onCompositionStart,\n onPressEnter,\n onFocus,\n submitIcon,\n style,\n texts,\n ...rest\n }) => {\n const ref = useRef<InputRef>(null);\n const [input, setInput] = useState<string>(value || '');\n\n const isChineseInput = useRef(false);\n\n useEffect(() => {\n if (value !== undefined) setInput(value);\n }, [value]);\n\n const handleUpload = () => {\n onChange?.(input);\n ref?.current?.blur();\n onChangeEnd?.(input);\n };\n\n return (\n <Input\n autoFocus\n ref={ref}\n value={input}\n style={{\n width: '100%',\n ...style,\n }}\n suffix={\n value === input ? (\n <span />\n ) : (\n <Flexbox\n horizontal\n gap={2}\n style={{\n marginRight: -4,\n zIndex: 1,\n }}\n >\n <ActionIcon\n icon={RotateCcw}\n size=\"small\"\n title={texts?.reset || 'Reset'}\n onClick={(e) => {\n e.preventDefault();\n setInput(value || '');\n }}\n />\n <ActionIcon\n icon={submitIcon || Save}\n size=\"small\"\n title={texts?.submit || 'Submit'}\n variant={'filled'}\n onClick={(e) => {\n e.preventDefault();\n handleUpload();\n }}\n />\n </Flexbox>\n )\n }\n onFocus={onFocus}\n onChange={(e) => {\n setInput(e.target.value);\n onValueChanging?.(e.target.value);\n }}\n onCompositionEnd={(e) => {\n isChineseInput.current = false;\n onCompositionEnd?.(e);\n }}\n onCompositionStart={(e) => {\n isChineseInput.current = true;\n onCompositionStart?.(e);\n }}\n onPressEnter={(e) => {\n if (!e.shiftKey && !isChineseInput.current) {\n e.preventDefault();\n handleUpload();\n onPressEnter?.(e);\n }\n }}\n {...rest}\n />\n );\n },\n);\n\nControlInput.displayName = 'ControlInput';\n\nexport default ControlInput;\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,eAAe,MAClB,EACC,OACA,UACA,iBACA,aACA,kBACA,oBACA,cACA,SACA,YACA,OACA,OACA,GAAG,WACC;CACJ,MAAM,MAAM,OAAiB,KAAK;CAClC,MAAM,CAAC,OAAO,YAAY,SAAiB,SAAS,GAAG;CAEvD,MAAM,iBAAiB,OAAO,MAAM;AAEpC,iBAAgB;AACd,MAAI,UAAU,OAAW,UAAS,MAAM;IACvC,CAAC,MAAM,CAAC;CAEX,MAAM,qBAAqB;AACzB,aAAW,MAAM;AACjB,OAAK,SAAS,MAAM;AACpB,gBAAc,MAAM;;AAGtB,QACE,oBAACA;EACC;EACK;EACL,OAAO;EACP,OAAO;GACL,OAAO;GACP,GAAG;GACJ;EACD,QACE,UAAU,QACR,oBAAC,WAAO,GAER,qBAACC;GACC;GACA,KAAK;GACL,OAAO;IACL,aAAa;IACb,QAAQ;IACT;cAED,oBAACC;IACC,MAAM;IACN,MAAK;IACL,OAAO,OAAO,SAAS;IACvB,UAAU,MAAM;AACd,OAAE,gBAAgB;AAClB,cAAS,SAAS,GAAG;;KAEvB,EACF,oBAACA;IACC,MAAM,cAAc;IACpB,MAAK;IACL,OAAO,OAAO,UAAU;IACxB,SAAS;IACT,UAAU,MAAM;AACd,OAAE,gBAAgB;AAClB,mBAAc;;KAEhB;IACM;EAGL;EACT,WAAW,MAAM;AACf,YAAS,EAAE,OAAO,MAAM;AACxB,qBAAkB,EAAE,OAAO,MAAM;;EAEnC,mBAAmB,MAAM;AACvB,kBAAe,UAAU;AACzB,sBAAmB,EAAE;;EAEvB,qBAAqB,MAAM;AACzB,kBAAe,UAAU;AACzB,wBAAqB,EAAE;;EAEzB,eAAe,MAAM;AACnB,OAAI,CAAC,EAAE,YAAY,CAAC,eAAe,SAAS;AAC1C,MAAE,gBAAgB;AAClB,kBAAc;AACd,mBAAe,EAAE;;;EAGrB,GAAI;GACJ;EAGP;AAED,aAAa,cAAc;AAE3B,2BAAe"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditableTextProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react77 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/EditableText/EditableText.d.ts
|
|
5
|
-
declare const EditableText:
|
|
5
|
+
declare const EditableText: react77.NamedExoticComponent<EditableTextProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { EditableText };
|
|
8
8
|
//# sourceMappingURL=EditableText.d.mts.map
|
|
@@ -33,37 +33,37 @@ const EditableText = memo(({ value, showEditIcon = true, onChange, editing, onEd
|
|
|
33
33
|
}, [size]);
|
|
34
34
|
const input = /* @__PURE__ */ jsx(ControlInput_default, {
|
|
35
35
|
className: cx(className, classNames?.input),
|
|
36
|
-
onBlur,
|
|
37
|
-
onChange,
|
|
38
|
-
onChangeEnd: (v) => {
|
|
39
|
-
onChangeEnd?.(v);
|
|
40
|
-
setEdited(false);
|
|
41
|
-
},
|
|
42
|
-
onFocus,
|
|
43
|
-
onValueChanging,
|
|
44
36
|
size,
|
|
37
|
+
value,
|
|
38
|
+
variant,
|
|
45
39
|
style: {
|
|
46
40
|
height,
|
|
47
41
|
...style,
|
|
48
42
|
...styles?.input
|
|
49
43
|
},
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
onBlur,
|
|
45
|
+
onChange,
|
|
46
|
+
onFocus,
|
|
47
|
+
onValueChanging,
|
|
48
|
+
onChangeEnd: (v) => {
|
|
49
|
+
onChangeEnd?.(v);
|
|
50
|
+
setEdited(false);
|
|
51
|
+
},
|
|
52
52
|
...inputProps
|
|
53
53
|
});
|
|
54
54
|
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: value }), showEditIcon && /* @__PURE__ */ jsx(ActionIcon_default, {
|
|
55
55
|
icon: Edit3,
|
|
56
|
+
size: "small",
|
|
57
|
+
title: "Edit",
|
|
56
58
|
onClick: () => {
|
|
57
59
|
setEdited(!edited);
|
|
58
|
-
}
|
|
59
|
-
size: "small",
|
|
60
|
-
title: "Edit"
|
|
60
|
+
}
|
|
61
61
|
})] });
|
|
62
62
|
return /* @__PURE__ */ jsx(FlexBasic_default, {
|
|
63
|
+
horizontal: true,
|
|
63
64
|
align: "center",
|
|
64
65
|
className: cx(className, classNames?.container),
|
|
65
66
|
gap,
|
|
66
|
-
horizontal: true,
|
|
67
67
|
style: {
|
|
68
68
|
height,
|
|
69
69
|
width: "100%",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.mjs","names":["useControlledState","ControlInput","ActionIcon","Flexbox"],"sources":["../../src/EditableText/EditableText.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { Edit3 } from 'lucide-react';\nimport { memo, useMemo } from 'react';\nimport { useHotkeys } from 'react-hotkeys-hook';\nimport useControlledState from 'use-merge-value';\n\nimport ActionIcon from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\n\nimport ControlInput from './ControlInput';\nimport type { EditableTextProps } from './type';\n\nconst EditableText = memo<EditableTextProps>(\n ({\n value,\n showEditIcon = true,\n onChange,\n editing,\n onEditingChange,\n onChangeEnd,\n onFocus,\n onBlur,\n className,\n inputProps,\n onValueChanging,\n gap = 8,\n style,\n size = 'small',\n styles,\n classNames,\n variant = 'borderless',\n ...rest\n }) => {\n const [edited, setEdited] = useControlledState(false, {\n onChange: onEditingChange,\n value: editing,\n });\n\n useHotkeys(\n 'esc',\n () => {\n setEdited(false);\n },\n {\n enableOnFormTags: true,\n enabled: edited,\n preventDefault: true,\n },\n );\n\n const height = useMemo(() => {\n if (!size) return 32;\n switch (size) {\n case 'large': {\n return 40;\n }\n case 'middle': {\n return 32;\n }\n case 'small': {\n return 24;\n }\n }\n }, [size]);\n\n const input = (\n <ControlInput\n className={cx(className, classNames?.input)}\n
|
|
1
|
+
{"version":3,"file":"EditableText.mjs","names":["useControlledState","ControlInput","ActionIcon","Flexbox"],"sources":["../../src/EditableText/EditableText.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { Edit3 } from 'lucide-react';\nimport { memo, useMemo } from 'react';\nimport { useHotkeys } from 'react-hotkeys-hook';\nimport useControlledState from 'use-merge-value';\n\nimport ActionIcon from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\n\nimport ControlInput from './ControlInput';\nimport type { EditableTextProps } from './type';\n\nconst EditableText = memo<EditableTextProps>(\n ({\n value,\n showEditIcon = true,\n onChange,\n editing,\n onEditingChange,\n onChangeEnd,\n onFocus,\n onBlur,\n className,\n inputProps,\n onValueChanging,\n gap = 8,\n style,\n size = 'small',\n styles,\n classNames,\n variant = 'borderless',\n ...rest\n }) => {\n const [edited, setEdited] = useControlledState(false, {\n onChange: onEditingChange,\n value: editing,\n });\n\n useHotkeys(\n 'esc',\n () => {\n setEdited(false);\n },\n {\n enableOnFormTags: true,\n enabled: edited,\n preventDefault: true,\n },\n );\n\n const height = useMemo(() => {\n if (!size) return 32;\n switch (size) {\n case 'large': {\n return 40;\n }\n case 'middle': {\n return 32;\n }\n case 'small': {\n return 24;\n }\n }\n }, [size]);\n\n const input = (\n <ControlInput\n className={cx(className, classNames?.input)}\n size={size}\n value={value as string}\n variant={variant}\n style={{\n height,\n ...style,\n ...styles?.input,\n }}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n onValueChanging={onValueChanging}\n onChangeEnd={(v) => {\n onChangeEnd?.(v);\n setEdited(false);\n }}\n {...inputProps}\n />\n );\n\n const content = (\n <>\n <span>{value}</span>\n {showEditIcon && (\n <ActionIcon\n icon={Edit3}\n size=\"small\"\n title={'Edit'}\n onClick={() => {\n setEdited(!edited);\n }}\n />\n )}\n </>\n );\n\n return (\n <Flexbox\n horizontal\n align={'center'}\n className={cx(className, classNames?.container)}\n gap={gap}\n style={{\n height,\n width: '100%',\n ...style,\n ...styles?.container,\n }}\n {...rest}\n >\n {edited ? input : content}\n </Flexbox>\n );\n },\n);\n\nEditableText.displayName = 'EditableText';\n\nexport default EditableText;\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,eAAe,MAClB,EACC,OACA,eAAe,MACf,UACA,SACA,iBACA,aACA,SACA,QACA,WACA,YACA,iBACA,MAAM,GACN,OACA,OAAO,SACP,QACA,YACA,UAAU,cACV,GAAG,WACC;CACJ,MAAM,CAAC,QAAQ,aAAaA,cAAmB,OAAO;EACpD,UAAU;EACV,OAAO;EACR,CAAC;AAEF,YACE,aACM;AACJ,YAAU,MAAM;IAElB;EACE,kBAAkB;EAClB,SAAS;EACT,gBAAgB;EACjB,CACF;CAED,MAAM,SAAS,cAAc;AAC3B,MAAI,CAAC,KAAM,QAAO;AAClB,UAAQ,MAAR;GACE,KAAK,QACH,QAAO;GAET,KAAK,SACH,QAAO;GAET,KAAK,QACH,QAAO;;IAGV,CAAC,KAAK,CAAC;CAEV,MAAM,QACJ,oBAACC;EACC,WAAW,GAAG,WAAW,YAAY,MAAM;EACrC;EACC;EACE;EACT,OAAO;GACL;GACA,GAAG;GACH,GAAG,QAAQ;GACZ;EACO;EACE;EACD;EACQ;EACjB,cAAc,MAAM;AAClB,iBAAc,EAAE;AAChB,aAAU,MAAM;;EAElB,GAAI;GACJ;CAGJ,MAAM,UACJ,8CACE,oBAAC,oBAAM,QAAa,EACnB,gBACC,oBAACC;EACC,MAAM;EACN,MAAK;EACL,OAAO;EACP,eAAe;AACb,aAAU,CAAC,OAAO;;GAEpB,IAEH;AAGL,QACE,oBAACC;EACC;EACA,OAAO;EACP,WAAW,GAAG,WAAW,YAAY,UAAU;EAC1C;EACL,OAAO;GACL;GACA,OAAO;GACP,GAAG;GACH,GAAG,QAAQ;GACZ;EACD,GAAI;YAEH,SAAS,QAAQ;GACV;EAGf;AAED,aAAa,cAAc;AAE3B,2BAAe"}
|
|
@@ -57,11 +57,11 @@ const EditorSlashMenu = memo(({ items, anchor, open, defaultOpen, onOpenChange,
|
|
|
57
57
|
defaultValue,
|
|
58
58
|
itemToStringValue,
|
|
59
59
|
items: resolvedItems,
|
|
60
|
+
open,
|
|
61
|
+
value,
|
|
60
62
|
onOpenChange: handleOpenChange,
|
|
61
63
|
onOpenChangeComplete,
|
|
62
64
|
onValueChange: handleValueChange,
|
|
63
|
-
open,
|
|
64
|
-
value,
|
|
65
65
|
children: [withHiddenInput ? /* @__PURE__ */ jsx(EditorSlashMenuHiddenInput, { ...hiddenInputProps }) : null, /* @__PURE__ */ jsx(EditorSlashMenuPortal, {
|
|
66
66
|
...portalProps,
|
|
67
67
|
children: /* @__PURE__ */ jsx(EditorSlashMenuPositioner, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSlashMenu.mjs","names":["item"],"sources":["../../src/EditorSlashMenu/EditorSlashMenu.tsx"],"sourcesContent":["'use client';\n\nimport
|
|
1
|
+
{"version":3,"file":"EditorSlashMenu.mjs","names":["item"],"sources":["../../src/EditorSlashMenu/EditorSlashMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n type AutocompleteRootChangeEventDetails,\n type AutocompleteRootProps,\n} from '@base-ui/react/autocomplete';\nimport type React from 'react';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport {\n EditorSlashMenuEmpty,\n EditorSlashMenuGroup,\n EditorSlashMenuGroupLabel,\n EditorSlashMenuHiddenInput,\n EditorSlashMenuList,\n EditorSlashMenuPopup,\n EditorSlashMenuPortal,\n EditorSlashMenuPositioner,\n EditorSlashMenuRoot,\n} from './atoms';\nimport { MenuItemRenderer } from './MenuItemRenderer';\nimport { type EditorSlashMenuItems, type EditorSlashMenuOption as ItemType } from './type';\nimport { useKeyboardNavigation } from './useKeyboardNavigation';\nimport { useNormalizedItems } from './useNormalizedItems';\nimport { isGroup } from './utils';\n\ntype Props = {\n /** Anchor for positioning (caret virtual element, dom element, ref, etc.) */\n anchor?: React.ComponentProps<typeof EditorSlashMenuPositioner>['anchor'];\n defaultOpen?: boolean;\n\n /** Initial query string (uncontrolled) */\n defaultValue?: string;\n /** Optional custom empty state */\n empty?: React.ReactNode;\n hiddenInputProps?: React.ComponentProps<typeof EditorSlashMenuHiddenInput>;\n items: EditorSlashMenuItems;\n\n listProps?: React.ComponentProps<typeof EditorSlashMenuList>;\n onOpenChange?: (open: boolean, details: AutocompleteRootChangeEventDetails) => void;\n onOpenChangeComplete?: (open: boolean) => void;\n /** Called when a command is selected. */\n onSelect?: (item: ItemType, details: AutocompleteRootChangeEventDetails) => void;\n\n /** Called when query changes. By default, changes caused by item selection are ignored. */\n onValueChange?: (value: string, details: AutocompleteRootChangeEventDetails) => void;\n\n open?: boolean;\n popupProps?: React.ComponentProps<typeof EditorSlashMenuPopup>;\n portalProps?: Omit<React.ComponentProps<typeof EditorSlashMenuPortal>, 'container'> & {\n container?: HTMLElement | null;\n };\n positionerProps?: Omit<React.ComponentProps<typeof EditorSlashMenuPositioner>, 'anchor'>;\n\n /** Optional custom group label renderer */\n renderGroupLabel?: (label: string) => React.ReactNode;\n /** Optional custom item renderer */\n renderItem?: (item: ItemType) => React.ReactNode;\n /** Reserve icon space even when icon is missing */\n reserveIconSpace?: boolean;\n /** Pass-through props */\n rootProps?: Omit<\n AutocompleteRootProps<ItemType>,\n | 'items'\n | 'value'\n | 'defaultValue'\n | 'onValueChange'\n | 'open'\n | 'defaultOpen'\n | 'onOpenChange'\n | 'onOpenChangeComplete'\n | 'itemToStringValue'\n >;\n /** Whether selecting an item should propagate its filled value via `onValueChange`. */\n updateValueOnSelect?: boolean;\n\n /** Current query string (controlled) */\n value?: string;\n /**\n * Render a visually-hidden input element for keyboard navigation / screen readers.\n * Default is `false` because slash menus usually live inside an editor input.\n */\n withHiddenInput?: boolean;\n};\n\nconst EditorSlashMenu = memo<Props>(\n ({\n items,\n anchor,\n\n open,\n defaultOpen,\n onOpenChange,\n onOpenChangeComplete,\n\n value,\n defaultValue,\n onValueChange,\n updateValueOnSelect = false,\n\n onSelect,\n\n empty = 'No results',\n renderGroupLabel,\n renderItem,\n reserveIconSpace = true,\n\n rootProps,\n portalProps,\n positionerProps,\n popupProps,\n listProps,\n\n withHiddenInput = false,\n hiddenInputProps,\n }) => {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen ?? false);\n\n useEffect(() => {\n if (open === undefined) return;\n setUncontrolledOpen(open);\n }, [open]);\n\n const resolvedOpen = open ?? uncontrolledOpen;\n\n const { resolvedItems, hasAnyIcon } = useNormalizedItems(items);\n const { listRef } = useKeyboardNavigation({ isOpen: resolvedOpen });\n\n const itemToStringValue = useCallback((item: ItemType) => {\n const kws = item.keywords?.length ? ` ${item.keywords.join(' ')}` : '';\n return `${item.label}${kws}`;\n }, []);\n\n const handleValueChange = useCallback(\n (nextValue: string, details: AutocompleteRootChangeEventDetails) => {\n if (!updateValueOnSelect && details.reason === 'item-press') return;\n onValueChange?.(nextValue, details);\n },\n [onValueChange, updateValueOnSelect],\n );\n\n const handleSelect = useCallback(\n (item: ItemType, details: AutocompleteRootChangeEventDetails) => {\n onSelect?.(item, details);\n },\n [onSelect],\n );\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean, details: AutocompleteRootChangeEventDetails) => {\n setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen, details);\n },\n [onOpenChange],\n );\n\n // Stable ref callback that doesn't depend on listProps object\n const setListRef = useCallback(\n (node: HTMLDivElement | null) => {\n listRef.current = node;\n const externalRef = (listProps as any)?.ref;\n if (!externalRef) return;\n if (typeof externalRef === 'function') {\n externalRef(node);\n } else {\n (externalRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [listRef, listProps],\n );\n\n // Memoize render props to prevent recreating on every render\n const menuItemProps = useMemo(\n () => ({\n hasAnyIcon,\n onSelect: handleSelect,\n renderItem,\n reserveIconSpace,\n }),\n [hasAnyIcon, handleSelect, renderItem, reserveIconSpace],\n );\n\n return (\n <EditorSlashMenuRoot<ItemType>\n {...(rootProps as any)}\n defaultOpen={defaultOpen}\n defaultValue={defaultValue}\n itemToStringValue={itemToStringValue as any}\n items={resolvedItems as any}\n open={open}\n value={value}\n onOpenChange={handleOpenChange}\n onOpenChangeComplete={onOpenChangeComplete}\n onValueChange={handleValueChange}\n >\n {withHiddenInput ? <EditorSlashMenuHiddenInput {...(hiddenInputProps as any)} /> : null}\n\n <EditorSlashMenuPortal {...(portalProps as any)}>\n <EditorSlashMenuPositioner {...(positionerProps as any)} anchor={anchor}>\n <EditorSlashMenuPopup {...(popupProps as any)}>\n <EditorSlashMenuList {...(listProps as any)} ref={setListRef as any}>\n {(entry: any) => {\n if (isGroup(entry)) {\n return (\n <EditorSlashMenuGroup\n key={entry.label ?? entry.items.map((i: any) => i.value).join('|')}\n >\n {entry.label\n ? (renderGroupLabel?.(entry.label) ?? (\n <EditorSlashMenuGroupLabel>{entry.label}</EditorSlashMenuGroupLabel>\n ))\n : null}\n {entry.items.map((item: ItemType) => (\n <MenuItemRenderer {...menuItemProps} item={item} key={item.value} />\n ))}\n </EditorSlashMenuGroup>\n );\n }\n\n const item = entry as ItemType;\n return <MenuItemRenderer {...menuItemProps} item={item} key={item.value} />;\n }}\n </EditorSlashMenuList>\n\n <EditorSlashMenuEmpty>{empty}</EditorSlashMenuEmpty>\n </EditorSlashMenuPopup>\n </EditorSlashMenuPositioner>\n </EditorSlashMenuPortal>\n </EditorSlashMenuRoot>\n );\n },\n);\n\nEditorSlashMenu.displayName = 'EditorSlashMenu';\n\nexport default EditorSlashMenu;\n"],"mappings":";;;;;;;;;;;AAqFA,MAAM,kBAAkB,MACrB,EACC,OACA,QAEA,MACA,aACA,cACA,sBAEA,OACA,cACA,eACA,sBAAsB,OAEtB,UAEA,QAAQ,cACR,kBACA,YACA,mBAAmB,MAEnB,WACA,aACA,iBACA,YACA,WAEA,kBAAkB,OAClB,uBACI;CACJ,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,eAAe,MAAM;AAE9E,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KAAqB,GAAK;gBACzB,oBAAC;MAAoB,GAAK;MAAmB,KAAK;iBAC9C,UAAe;AACf,WAAI,QAAQ,MAAM,CAChB,QACE,qBAAC,mCAGE,MAAM,QACF,mBAAmB,MAAM,MAAM,IAC9B,oBAAC,uCAA2B,MAAM,QAAkC,GAEtE,MACH,MAAM,MAAM,KAAK,WAChB,8BAAC;QAAiB,GAAI;QAAe,MAAMA;QAAM,KAAKA,OAAK;SAAS,CACpE,KATG,MAAM,SAAS,MAAM,MAAM,KAAK,MAAW,EAAE,MAAM,CAAC,KAAK,IAAI,CAU7C;OAI3B,MAAM,OAAO;AACb,cAAO,8BAAC;QAAiB,GAAI;QAAqB;QAAM,KAAK,KAAK;SAAS;;OAEzD,EAEtB,oBAAC,kCAAsB,QAA6B;MAC/B;KACG;IACN;GACJ;EAG3B;AAED,gBAAgB,cAAc;AAE9B,8BAAe"}
|
|
@@ -21,6 +21,7 @@ const MenuItemRenderer = memo(({ hasAnyIcon, item, onSelect, renderItem, reserve
|
|
|
21
21
|
return /* @__PURE__ */ jsx(EditorSlashMenuItem, {
|
|
22
22
|
danger: item.danger,
|
|
23
23
|
disabled: item.disabled,
|
|
24
|
+
value: item,
|
|
24
25
|
onClick: (e) => {
|
|
25
26
|
if (item.disabled) {
|
|
26
27
|
e.preventDefault();
|
|
@@ -31,7 +32,6 @@ const MenuItemRenderer = memo(({ hasAnyIcon, item, onSelect, renderItem, reserve
|
|
|
31
32
|
reason: "item-press"
|
|
32
33
|
});
|
|
33
34
|
},
|
|
34
|
-
value: item,
|
|
35
35
|
children: content
|
|
36
36
|
}, item.value);
|
|
37
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItemRenderer.mjs","names":[],"sources":["../../src/EditorSlashMenu/MenuItemRenderer.tsx"],"sourcesContent":["import type { AutocompleteRootChangeEventDetails } from '@base-ui/react/autocomplete';\nimport { memo } from 'react';\n\nimport {\n EditorSlashMenuItem,\n EditorSlashMenuItemContent,\n EditorSlashMenuItemExtra,\n EditorSlashMenuItemIcon,\n EditorSlashMenuItemLabel,\n} from './atoms';\nimport type { EditorSlashMenuOption } from './type';\n\ninterface MenuItemRendererProps {\n hasAnyIcon: boolean;\n item: EditorSlashMenuOption;\n onSelect: (item: EditorSlashMenuOption, details: AutocompleteRootChangeEventDetails) => void;\n renderItem?: (item: EditorSlashMenuOption) => React.ReactNode;\n reserveIconSpace: boolean;\n}\n\nconst DefaultItemContent = memo<{\n hasAnyIcon: boolean;\n item: EditorSlashMenuOption;\n reserveIconSpace: boolean;\n}>(({ item, hasAnyIcon, reserveIconSpace }) => (\n <EditorSlashMenuItemContent>\n <EditorSlashMenuItemIcon aria-hidden={!hasAnyIcon && !reserveIconSpace}>\n {item.icon ?? (reserveIconSpace && hasAnyIcon ? <span /> : null)}\n </EditorSlashMenuItemIcon>\n <EditorSlashMenuItemLabel>{item.label}</EditorSlashMenuItemLabel>\n {item.extra ? <EditorSlashMenuItemExtra>{item.extra}</EditorSlashMenuItemExtra> : null}\n </EditorSlashMenuItemContent>\n));\n\nDefaultItemContent.displayName = 'DefaultItemContent';\n\nexport const MenuItemRenderer = memo<MenuItemRendererProps>(\n ({ hasAnyIcon, item, onSelect, renderItem, reserveIconSpace }) => {\n const content = renderItem?.(item) ?? (\n <DefaultItemContent hasAnyIcon={hasAnyIcon} item={item} reserveIconSpace={reserveIconSpace} />\n );\n\n return (\n <EditorSlashMenuItem\n danger={item.danger}\n disabled={item.disabled}\n key={item.value}\n onClick={(e) => {\n if (item.disabled) {\n e.preventDefault();\n return;\n }\n onSelect(item, { event: e as any, reason: 'item-press' } as any);\n }}\n
|
|
1
|
+
{"version":3,"file":"MenuItemRenderer.mjs","names":[],"sources":["../../src/EditorSlashMenu/MenuItemRenderer.tsx"],"sourcesContent":["import type { AutocompleteRootChangeEventDetails } from '@base-ui/react/autocomplete';\nimport { memo } from 'react';\n\nimport {\n EditorSlashMenuItem,\n EditorSlashMenuItemContent,\n EditorSlashMenuItemExtra,\n EditorSlashMenuItemIcon,\n EditorSlashMenuItemLabel,\n} from './atoms';\nimport type { EditorSlashMenuOption } from './type';\n\ninterface MenuItemRendererProps {\n hasAnyIcon: boolean;\n item: EditorSlashMenuOption;\n onSelect: (item: EditorSlashMenuOption, details: AutocompleteRootChangeEventDetails) => void;\n renderItem?: (item: EditorSlashMenuOption) => React.ReactNode;\n reserveIconSpace: boolean;\n}\n\nconst DefaultItemContent = memo<{\n hasAnyIcon: boolean;\n item: EditorSlashMenuOption;\n reserveIconSpace: boolean;\n}>(({ item, hasAnyIcon, reserveIconSpace }) => (\n <EditorSlashMenuItemContent>\n <EditorSlashMenuItemIcon aria-hidden={!hasAnyIcon && !reserveIconSpace}>\n {item.icon ?? (reserveIconSpace && hasAnyIcon ? <span /> : null)}\n </EditorSlashMenuItemIcon>\n <EditorSlashMenuItemLabel>{item.label}</EditorSlashMenuItemLabel>\n {item.extra ? <EditorSlashMenuItemExtra>{item.extra}</EditorSlashMenuItemExtra> : null}\n </EditorSlashMenuItemContent>\n));\n\nDefaultItemContent.displayName = 'DefaultItemContent';\n\nexport const MenuItemRenderer = memo<MenuItemRendererProps>(\n ({ hasAnyIcon, item, onSelect, renderItem, reserveIconSpace }) => {\n const content = renderItem?.(item) ?? (\n <DefaultItemContent hasAnyIcon={hasAnyIcon} item={item} reserveIconSpace={reserveIconSpace} />\n );\n\n return (\n <EditorSlashMenuItem\n danger={item.danger}\n disabled={item.disabled}\n key={item.value}\n value={item as any}\n onClick={(e) => {\n if (item.disabled) {\n e.preventDefault();\n return;\n }\n onSelect(item, { event: e as any, reason: 'item-press' } as any);\n }}\n >\n {content}\n </EditorSlashMenuItem>\n );\n },\n);\n\nMenuItemRenderer.displayName = 'MenuItemRenderer';\n"],"mappings":";;;;;AAoBA,MAAM,qBAAqB,MAIvB,EAAE,MAAM,YAAY,uBACtB,qBAAC;CACC,oBAAC;EAAwB,eAAa,CAAC,cAAc,CAAC;YACnD,KAAK,SAAS,oBAAoB,aAAa,oBAAC,WAAO,GAAG;GACnC;CAC1B,oBAAC,sCAA0B,KAAK,QAAiC;CAChE,KAAK,QAAQ,oBAAC,sCAA0B,KAAK,QAAiC,GAAG;IACvD,CAC7B;AAEF,mBAAmB,cAAc;AAEjC,MAAa,mBAAmB,MAC7B,EAAE,YAAY,MAAM,UAAU,YAAY,uBAAuB;CAChE,MAAM,UAAU,aAAa,KAAK,IAChC,oBAAC;EAA+B;EAAkB;EAAwB;GAAoB;AAGhG,QACE,oBAAC;EACC,QAAQ,KAAK;EACb,UAAU,KAAK;EAEf,OAAO;EACP,UAAU,MAAM;AACd,OAAI,KAAK,UAAU;AACjB,MAAE,gBAAgB;AAClB;;AAEF,YAAS,MAAM;IAAE,OAAO;IAAU,QAAQ;IAAc,CAAQ;;YAGjE;IAVI,KAAK,MAWU;EAG3B;AAED,iBAAiB,cAAc"}
|