@antscorp/antsomi-ui 2.0.110 → 2.0.112
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/es/assets/css/main.scss +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.d.ts +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.js +53 -0
- package/es/components/atoms/Eyedropper/index.d.ts +0 -0
- package/es/components/atoms/Eyedropper/index.js +1 -0
- package/es/components/atoms/Eyedropper/styled.d.ts +9 -0
- package/es/components/atoms/Eyedropper/styled.js +45 -0
- package/es/components/atoms/Eyedropper/types.d.ts +5 -0
- package/es/components/atoms/Eyedropper/types.js +1 -0
- package/es/components/icons/ALignRightIcon.d.ts +3 -0
- package/es/components/icons/ALignRightIcon.js +7 -0
- package/es/components/icons/AlignCenterIcon.d.ts +3 -0
- package/es/components/icons/AlignCenterIcon.js +7 -0
- package/es/components/icons/AlignJustifyIcon.d.ts +3 -0
- package/es/components/icons/AlignJustifyIcon.js +7 -0
- package/es/components/icons/AlignLeftIcon.d.ts +3 -0
- package/es/components/icons/AlignLeftIcon.js +7 -0
- package/es/components/icons/ArrowDropDownIcon.d.ts +3 -0
- package/es/components/icons/ArrowDropDownIcon.js +7 -0
- package/es/components/icons/ChevronRightIcon.d.ts +3 -0
- package/es/components/icons/ChevronRightIcon.js +7 -0
- package/es/components/icons/ColorizeIcon.d.ts +3 -0
- package/es/components/icons/ColorizeIcon.js +7 -0
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +9 -0
- package/es/components/icons/LinkOffIcon.d.ts +3 -0
- package/es/components/icons/LinkOffIcon.js +7 -0
- package/es/components/icons/MinusIcon.d.ts +3 -0
- package/es/components/icons/MinusIcon.js +7 -0
- package/es/components/icons/index.d.ts +9 -0
- package/es/components/icons/index.js +9 -0
- package/es/components/index.scss +1 -0
- package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
- package/es/components/molecules/EmojiCollections/types.d.ts +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +2 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +11 -0
- package/es/components/molecules/EyedropperButton/EyedropperButton.js +34 -0
- package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
- package/es/components/molecules/EyedropperButton/index.js +1 -0
- package/es/components/molecules/EyedropperButton/styled.d.ts +7 -0
- package/es/components/molecules/EyedropperButton/styled.js +23 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +134 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +8 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +14 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +21 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +19 -0
- package/es/components/molecules/FontSizeInput/constants.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/constants.js +5 -0
- package/es/components/molecules/FontSizeInput/index.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/index.js +1 -0
- package/es/components/molecules/FontSizeInput/styled.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/styled.js +39 -0
- package/es/components/molecules/FontSizeInput/types.d.ts +23 -0
- package/es/components/molecules/FontSizeInput/types.js +1 -0
- package/es/components/molecules/FontSizeInput/utils.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/utils.js +9 -0
- package/es/components/molecules/SearchPopover/SearchPopover.d.ts +2 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +3 -3
- package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
- package/es/components/molecules/SearchPopover/styled.js +1 -2
- package/es/components/molecules/SearchPopover/types.d.ts +4 -3
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +6 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +49 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
- package/es/components/molecules/VirtualizedMenu/styled.js +24 -3
- package/es/components/molecules/VirtualizedMenu/types.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.js +2 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/molecules/index.scss +1 -0
- package/es/components/organism/TextEditor/TextEditor.d.ts +10 -0
- package/es/components/organism/TextEditor/TextEditor.js +403 -0
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +47 -0
- package/es/components/organism/TextEditor/constants.d.ts +196 -0
- package/es/components/organism/TextEditor/constants.js +398 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +43 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +18 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +81 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +35 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +16 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.js +30 -0
- package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/Color.js +34 -0
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
- package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +31 -0
- package/es/components/organism/TextEditor/extensions/FontSize.js +46 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
- package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.js +101 -0
- package/es/components/organism/TextEditor/extensions/Link.d.ts +22 -0
- package/es/components/organism/TextEditor/extensions/Link.js +197 -0
- package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
- package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +33 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.js +194 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +30 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.js +36 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
- package/es/components/organism/TextEditor/hooks/index.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/index.js +6 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.js +29 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +69 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
- package/es/components/organism/TextEditor/index.d.ts +18 -0
- package/es/components/organism/TextEditor/index.js +8 -0
- package/es/components/organism/TextEditor/index.scss +65 -0
- package/es/components/organism/TextEditor/provider.d.ts +15 -0
- package/es/components/organism/TextEditor/provider.js +36 -0
- package/es/components/organism/TextEditor/store.d.ts +20 -0
- package/es/components/organism/TextEditor/store.js +40 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
- package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
- package/es/components/organism/TextEditor/stories/shared.js +57 -0
- package/es/components/organism/TextEditor/styled.d.ts +9 -0
- package/es/components/organism/TextEditor/styled.js +61 -0
- package/es/components/organism/TextEditor/types.d.ts +324 -0
- package/es/components/organism/TextEditor/types.js +6 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +3 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +114 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/Button/Button.js +35 -0
- package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.js +27 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +102 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +36 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.d.ts +35 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +58 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +75 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +85 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +93 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +20 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +32 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +41 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +8 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +51 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.js +45 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +67 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -0
- package/es/components/organism/TextEditor/utils/documentState.d.ts +73 -0
- package/es/components/organism/TextEditor/utils/documentState.js +149 -0
- package/es/components/organism/TextEditor/utils/font.d.ts +74 -0
- package/es/components/organism/TextEditor/utils/font.js +147 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +87 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +460 -0
- package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
- package/es/components/organism/TextEditor/utils/indent.js +56 -0
- package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
- package/es/components/organism/TextEditor/utils/index.js +16 -0
- package/es/components/organism/TextEditor/utils/link.d.ts +116 -0
- package/es/components/organism/TextEditor/utils/link.js +304 -0
- package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
- package/es/components/organism/TextEditor/utils/menu.js +321 -0
- package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
- package/es/components/organism/TextEditor/utils/selection.js +58 -0
- package/es/components/organism/TextEditor/utils/shared.d.ts +13 -0
- package/es/components/organism/TextEditor/utils/shared.js +52 -0
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
- package/es/components/organism/TextEditor/utils/smartTag.js +90 -0
- package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
- package/es/components/organism/TextEditor/utils/style.js +193 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/organism/index.scss +1 -0
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/web.d.ts +8 -0
- package/es/constants/web.js +57 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
- package/es/hooks/useBroadcastedLocalStorage.js +71 -0
- package/es/hooks/useElementSize.d.ts +7 -0
- package/es/hooks/useElementSize.js +56 -0
- package/es/hooks/useEyedropper/attach.d.ts +4 -0
- package/es/hooks/useEyedropper/attach.js +9 -0
- package/es/hooks/useEyedropper/eyedropper.d.ts +69 -0
- package/es/hooks/useEyedropper/eyedropper.js +205 -0
- package/es/hooks/useEyedropper/index.d.ts +2 -0
- package/es/hooks/useEyedropper/index.js +7 -0
- package/es/hooks/useEyedropper/support.d.ts +1 -0
- package/es/hooks/useEyedropper/support.js +3 -0
- package/es/hooks/useEyedropper/types.d.ts +9 -0
- package/es/hooks/useEyedropper/types.js +1 -0
- package/es/hooks/useEyedropper/useEyedropper.d.ts +8 -0
- package/es/hooks/useEyedropper/useEyedropper.js +50 -0
- package/es/hooks/useEyedropper/utils.d.ts +11 -0
- package/es/hooks/useEyedropper/utils.js +17 -0
- package/es/hooks/useIsMounted.d.ts +1 -0
- package/es/hooks/useIsMounted.js +11 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/locales/i18n.d.ts +1 -1
- package/es/types/index.d.ts +9 -0
- package/es/utils/common.d.ts +15 -9
- package/es/utils/common.js +62 -24
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/web.d.ts +80 -0
- package/es/utils/web.js +226 -0
- package/package.json +26 -17
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/* eslint-disable no-bitwise */
|
|
2
|
+
import html2canvas from 'html2canvas-pro';
|
|
3
|
+
import { errors, px } from './utils';
|
|
4
|
+
/** Global `isOpen` state */
|
|
5
|
+
const isOpenState = {
|
|
6
|
+
value: false,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* EyeDropper API polyfill
|
|
10
|
+
* https://wicg.github.io/eyedropper-api/#dom-colorselectionoptions
|
|
11
|
+
*/
|
|
12
|
+
export class EyeDropperPolyfill {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.magnification = {
|
|
15
|
+
size: 4,
|
|
16
|
+
scale: 12,
|
|
17
|
+
};
|
|
18
|
+
this.onMouseMove = this.onMouseMove.bind(this);
|
|
19
|
+
this.onClick = this.onClick.bind(this);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Opens the polyfilled eyedropper
|
|
23
|
+
*
|
|
24
|
+
* §3.3 EyeDropper interface ► `open()`
|
|
25
|
+
*/
|
|
26
|
+
async open(options = {}) {
|
|
27
|
+
// §3.3 EyeDropper interface ► `open()` ► p.2
|
|
28
|
+
// Prevent opening if already open
|
|
29
|
+
if (isOpenState.value) {
|
|
30
|
+
return Promise.reject(new DOMException('Invalid state', 'InvalidStateError'));
|
|
31
|
+
}
|
|
32
|
+
// §3.3 EyeDropper interface ► `open()` ► p.3
|
|
33
|
+
// Create a promise to handle the color selection
|
|
34
|
+
const result = new Promise((resolve, reject) => {
|
|
35
|
+
// §3.3 EyeDropper interface ► `open()` ► p.4
|
|
36
|
+
// Handle possible signal abortion
|
|
37
|
+
if (options.signal) {
|
|
38
|
+
if (options.signal.aborted) {
|
|
39
|
+
this.stop();
|
|
40
|
+
reject(options.signal.reason || new DOMException('Aborted', 'AbortError'));
|
|
41
|
+
}
|
|
42
|
+
const abortListener = () => {
|
|
43
|
+
this.stop();
|
|
44
|
+
if (options.signal) {
|
|
45
|
+
reject(options.signal.reason || new DOMException('Aborted', 'AbortError'));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
options.signal.addEventListener('abort', abortListener);
|
|
49
|
+
}
|
|
50
|
+
// §3.3 EyeDropper interface ► `open()` ► p.5
|
|
51
|
+
// Store the resolve function and start the eyedropper
|
|
52
|
+
this.resolve = resolve;
|
|
53
|
+
this.start();
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Starting eyedropper mode
|
|
59
|
+
*/
|
|
60
|
+
async start() {
|
|
61
|
+
document.body.style.overflow = 'hidden';
|
|
62
|
+
this.setWaitingCursor();
|
|
63
|
+
await this.createScreenshot();
|
|
64
|
+
this.revertWaitingCursor();
|
|
65
|
+
this.bindEvents();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Stopping eyedropper mode
|
|
69
|
+
*/
|
|
70
|
+
stop() {
|
|
71
|
+
document.body.style.overflow = '';
|
|
72
|
+
this.unbindEvents();
|
|
73
|
+
this.removeScreenshot();
|
|
74
|
+
this.colorSelectionResult = undefined;
|
|
75
|
+
this.lastPoint = undefined;
|
|
76
|
+
isOpenState.value = false;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates fake screenshot of page and assign it to the body
|
|
80
|
+
*/
|
|
81
|
+
async createScreenshot() {
|
|
82
|
+
this.canvas = await html2canvas(document.body, {
|
|
83
|
+
allowTaint: true,
|
|
84
|
+
useCORS: true,
|
|
85
|
+
height: document.body.scrollHeight,
|
|
86
|
+
width: document.body.scrollWidth,
|
|
87
|
+
});
|
|
88
|
+
this.addCanvasStyle(this.canvas);
|
|
89
|
+
this.canvasCtx = this.canvas.getContext('2d', {
|
|
90
|
+
willReadFrequently: true,
|
|
91
|
+
});
|
|
92
|
+
document.body.appendChild(this.canvas);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Removes screenshot from page
|
|
96
|
+
*/
|
|
97
|
+
removeScreenshot() {
|
|
98
|
+
if (!this.canvas) {
|
|
99
|
+
throw new Error(errors.canvasError);
|
|
100
|
+
}
|
|
101
|
+
document.body.removeChild(this.canvas);
|
|
102
|
+
this.canvas = undefined;
|
|
103
|
+
this.canvasCtx = undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Sets waiting cursor
|
|
107
|
+
*/
|
|
108
|
+
setWaitingCursor() {
|
|
109
|
+
this.previousDocumentCursor = document.documentElement.style.cursor;
|
|
110
|
+
document.documentElement.style.cursor = 'wait';
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Removes waiting cursor
|
|
114
|
+
*/
|
|
115
|
+
revertWaitingCursor() {
|
|
116
|
+
if (this.previousDocumentCursor) {
|
|
117
|
+
document.documentElement.style.cursor = this.previousDocumentCursor;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
document.documentElement.style.cursor = '';
|
|
121
|
+
}
|
|
122
|
+
this.previousDocumentCursor = undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Binds events
|
|
126
|
+
*/
|
|
127
|
+
bindEvents() {
|
|
128
|
+
window.addEventListener('mousemove', this.onMouseMove);
|
|
129
|
+
window.addEventListener('click', this.onClick);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Unbinds `mousemove` events
|
|
133
|
+
*/
|
|
134
|
+
unbindEvents() {
|
|
135
|
+
window.removeEventListener('mousemove', this.onMouseMove);
|
|
136
|
+
window.removeEventListener('click', this.onClick);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* `click` handler
|
|
140
|
+
*/
|
|
141
|
+
onClick() {
|
|
142
|
+
if (!this.lastPoint) {
|
|
143
|
+
throw new Error(errors.color);
|
|
144
|
+
}
|
|
145
|
+
this.detectColor(this.lastPoint);
|
|
146
|
+
const newValue = this.colorSelectionResult;
|
|
147
|
+
this.stop();
|
|
148
|
+
if (newValue && this.resolve) {
|
|
149
|
+
this.resolve(newValue);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* `mousemove` handler
|
|
154
|
+
*/
|
|
155
|
+
onMouseMove(event) {
|
|
156
|
+
if (!this.canvas || !this.canvasCtx) {
|
|
157
|
+
throw new Error(errors.canvasError);
|
|
158
|
+
}
|
|
159
|
+
const dpr = window.devicePixelRatio;
|
|
160
|
+
this.lastPoint = {
|
|
161
|
+
x: (event.clientX + window.scrollX) * dpr,
|
|
162
|
+
y: (event.clientY + window.scrollY) * dpr,
|
|
163
|
+
};
|
|
164
|
+
// Move magnifier
|
|
165
|
+
// const position = `${this.lastPoint.x / dpr} ${this.lastPoint.y / dpr}px`;
|
|
166
|
+
const position = [px(this.lastPoint.x / dpr), px(this.lastPoint.y / dpr)].join(' ');
|
|
167
|
+
Object.assign(this.canvas.style, {
|
|
168
|
+
opacity: 1,
|
|
169
|
+
transformOrigin: position,
|
|
170
|
+
clipPath: `circle(${px(this.magnification.size)} at ${position})`,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Detects color from canvas data
|
|
175
|
+
*/
|
|
176
|
+
detectColor(point) {
|
|
177
|
+
if (!this.canvasCtx) {
|
|
178
|
+
throw new Error(errors.canvasError);
|
|
179
|
+
}
|
|
180
|
+
const pixelData = this.canvasCtx.getImageData(point.x, point.y, 1, 1).data;
|
|
181
|
+
const red = pixelData[0];
|
|
182
|
+
const green = pixelData[1];
|
|
183
|
+
const blue = pixelData[2];
|
|
184
|
+
const hex = ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1);
|
|
185
|
+
this.colorSelectionResult = {
|
|
186
|
+
sRGBHex: `#${hex}`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Canvas styles creator
|
|
191
|
+
*/
|
|
192
|
+
addCanvasStyle(canvas) {
|
|
193
|
+
Object.assign(canvas.style, {
|
|
194
|
+
position: 'fixed',
|
|
195
|
+
top: '0px',
|
|
196
|
+
marginTop: `${-window.scrollY}px`,
|
|
197
|
+
left: '0px',
|
|
198
|
+
zIndex: 999999,
|
|
199
|
+
opacity: 0,
|
|
200
|
+
transform: `scale(${this.magnification.scale})`,
|
|
201
|
+
imageRendering: 'pixelated',
|
|
202
|
+
border: '1px solid #000000',
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEyeDropperSupported(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface UseEyedropperResult {
|
|
2
|
+
pickedColor: string | null;
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
apiSupported: boolean;
|
|
5
|
+
pickColor: () => Promise<string | null>;
|
|
6
|
+
copyToClipboard: (color: string) => Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useEyedropper: (defaultColor?: string) => UseEyedropperResult;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
export const useEyedropper = (defaultColor) => {
|
|
4
|
+
const [pickedColor, setPickedColor] = useState(defaultColor || null);
|
|
5
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
6
|
+
const apiSupported = 'EyeDropper' in window;
|
|
7
|
+
const pickColor = useCallback(async () => {
|
|
8
|
+
if (!apiSupported) {
|
|
9
|
+
message.error('Trình duyệt của bạn không hỗ trợ EyeDropper API.');
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
setIsLoading(true);
|
|
13
|
+
try {
|
|
14
|
+
const eyeDropper = new window.EyeDropper();
|
|
15
|
+
const { sRGBHex } = await eyeDropper.open();
|
|
16
|
+
setPickedColor(sRGBHex);
|
|
17
|
+
return sRGBHex;
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
if (e instanceof Error && e.name === 'AbortError') {
|
|
21
|
+
message.info('Người dùng đã hủy chọn màu.');
|
|
22
|
+
}
|
|
23
|
+
else if (e instanceof Error) {
|
|
24
|
+
message.error(`Đã xảy ra lỗi khi chọn màu: ${e.message}`);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
setIsLoading(false);
|
|
30
|
+
}
|
|
31
|
+
}, [apiSupported]);
|
|
32
|
+
const copyToClipboard = useCallback(async (color) => {
|
|
33
|
+
try {
|
|
34
|
+
await navigator.clipboard.writeText(color);
|
|
35
|
+
message.success(`Đã copy màu ${color} vào clipboard!`);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
message.error('Không thể copy màu vào clipboard.');
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
return {
|
|
44
|
+
pickedColor,
|
|
45
|
+
isLoading,
|
|
46
|
+
apiSupported,
|
|
47
|
+
pickColor,
|
|
48
|
+
copyToClipboard,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const prefix = `[EyeDropper]`;
|
|
2
|
+
/**
|
|
3
|
+
* Errors text
|
|
4
|
+
*/
|
|
5
|
+
export const errors = {
|
|
6
|
+
canvasError: `${prefix} Error getting canvas`,
|
|
7
|
+
color: `${prefix} Cannot get color`,
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Returns px value
|
|
11
|
+
*/
|
|
12
|
+
export function px(value) {
|
|
13
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
14
|
+
throw new Error();
|
|
15
|
+
}
|
|
16
|
+
return `${value}px`;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsMounted: () => () => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export const useIsMounted = () => {
|
|
3
|
+
const isMountedRef = useRef(false);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
isMountedRef.current = true;
|
|
6
|
+
return () => {
|
|
7
|
+
isMountedRef.current = false;
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
return useCallback(() => isMountedRef.current, []);
|
|
11
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './queries';
|
|
|
4
4
|
export * from './providers';
|
|
5
5
|
export { ENV } from './config';
|
|
6
6
|
export { QUERY_KEYS, POST_MESSAGE_TYPES, CDP_API, ANTALYSER_API, MEDIA_TEMPLATE_API, } from './constants';
|
|
7
|
-
export { snakeCaseToCamelCase, camelCaseToSnakeCase, getCategoriesFromObjectTemplate, } from './utils';
|
|
7
|
+
export { snakeCaseToCamelCase, camelCaseToSnakeCase, getCategoriesFromObjectTemplate, analyzeFontFamily, getPrimaryFontFamily, isPrimaryFontWebSafe, isWebSafeFont, } from './utils';
|
|
8
8
|
export { translate, translations } from './locales';
|
|
9
9
|
export * from './hooks';
|
|
10
10
|
export { ConfigProvider as AntdConfigProvider } from 'antd';
|
package/es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export * from './queries';
|
|
|
4
4
|
export * from './providers';
|
|
5
5
|
export { ENV } from './config';
|
|
6
6
|
export { QUERY_KEYS, POST_MESSAGE_TYPES, CDP_API, ANTALYSER_API, MEDIA_TEMPLATE_API, } from './constants';
|
|
7
|
-
export { snakeCaseToCamelCase, camelCaseToSnakeCase, getCategoriesFromObjectTemplate, } from './utils';
|
|
7
|
+
export { snakeCaseToCamelCase, camelCaseToSnakeCase, getCategoriesFromObjectTemplate, analyzeFontFamily, getPrimaryFontFamily, isPrimaryFontWebSafe, isWebSafeFont, } from './utils';
|
|
8
8
|
export { translate, translations } from './locales';
|
|
9
9
|
// Hooks
|
|
10
10
|
export * from './hooks';
|
package/es/locales/i18n.d.ts
CHANGED
|
@@ -10966,6 +10966,6 @@ export declare const translationsJson: {
|
|
|
10966
10966
|
};
|
|
10967
10967
|
};
|
|
10968
10968
|
};
|
|
10969
|
-
declare const i18nInstance: import("i18next").i18n;
|
|
10969
|
+
declare const i18nInstance: import("node_modules/i18next").i18n;
|
|
10970
10970
|
export declare const getTranslateMessage: (id: string, defaultMessage?: string, value?: Record<string, unknown>) => string;
|
|
10971
10971
|
export default i18nInstance;
|
package/es/types/index.d.ts
CHANGED
|
@@ -3,6 +3,15 @@ export type THandleErrorPayload = {
|
|
|
3
3
|
name: string;
|
|
4
4
|
args: Record<string, any>;
|
|
5
5
|
};
|
|
6
|
+
/** Generic data attributes to set on components */
|
|
7
|
+
export type DataAttribute = {
|
|
8
|
+
/** The key for the attribute */
|
|
9
|
+
key: `data-${string}`;
|
|
10
|
+
/** The value */
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
/** An array of data attributes */
|
|
14
|
+
export type DataAttributes = DataAttribute[];
|
|
6
15
|
export type TLocale = 'en' | 'vi';
|
|
7
16
|
export type GenericFunction = (...args: any[]) => any;
|
|
8
17
|
export type TConfigErrorInfo = {
|
package/es/utils/common.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataAttributes } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* Function to reorder list
|
|
3
4
|
* @param {Object[]} list - list of item want to reorder
|
|
@@ -66,17 +67,14 @@ export declare const searchParamsToObject: (searchParams?: string) => Record<str
|
|
|
66
67
|
export declare const getShuffleArray: <T>(array: T[]) => T[];
|
|
67
68
|
export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any> | Record<string, any>[], recursive?: boolean) => T;
|
|
68
69
|
export declare const camelCaseToSnakeCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
|
|
69
|
-
export declare function generateKey():
|
|
70
|
+
export declare function generateKey(): string;
|
|
70
71
|
export declare const formatUserId: (userId?: number) => string;
|
|
71
72
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/** Remove all accents and convert string to lower case, remove leading and trailing white space */
|
|
78
|
-
export declare const simplifyString: (str: string) => string;
|
|
79
|
-
/**
|
|
73
|
+
* Checks string matching based on a query, supporting fuzzy matching,
|
|
74
|
+
* where the query characters must appear in order within the target string.
|
|
75
|
+
* Allows for missing characters in the query relative to the target,
|
|
76
|
+
* and ignores case, diacritics, and spaces.
|
|
77
|
+
*
|
|
80
78
|
* @param str target string
|
|
81
79
|
* @param queryStr search query
|
|
82
80
|
* @returns true if target string includes search query
|
|
@@ -165,5 +163,13 @@ export declare const convertNumberByDisplayFormat: (value: number | string, grou
|
|
|
165
163
|
export declare function numberWithCommas(n: number): string;
|
|
166
164
|
export declare const multiPercentageValue: (value?: string) => string;
|
|
167
165
|
export declare const antsomiClsx: (componentName: string) => (className: string) => string;
|
|
166
|
+
/**
|
|
167
|
+
* Take an array of data attribute key/value pairs and return an object which
|
|
168
|
+
* can be spread into a component's definition
|
|
169
|
+
*
|
|
170
|
+
* @param attributes
|
|
171
|
+
* @returns A spreadable object of data-attributes
|
|
172
|
+
*/
|
|
173
|
+
export declare const dataAttrArrayToObject: (attributes?: DataAttributes) => Record<string, string>;
|
|
168
174
|
export declare function arrayToMapByProperty<T extends object, K extends keyof T>(array: T[], propertyName: K): Map<T[K], T>;
|
|
169
175
|
export declare function compareStrings(a: any, b: any): number;
|
package/es/utils/common.js
CHANGED
|
@@ -6,7 +6,7 @@ import uniqid from 'uniqid';
|
|
|
6
6
|
import { MESSAGES, PORTAL_KEYS } from '@antscorp/antsomi-ui/es/services/constants';
|
|
7
7
|
// Utils
|
|
8
8
|
import { handleError } from './handleError';
|
|
9
|
-
import { keyBy, sortBy } from 'lodash';
|
|
9
|
+
import { kebabCase, keyBy, sortBy, toString } from 'lodash';
|
|
10
10
|
import clsx from 'clsx';
|
|
11
11
|
import { ANTSOMI_COMPONENT_PREFIX_CLS } from '../constants';
|
|
12
12
|
const PATH = 'src/utils/common.ts';
|
|
@@ -430,35 +430,57 @@ export function generateKey() {
|
|
|
430
430
|
}
|
|
431
431
|
export const formatUserId = (userId) => String(userId || '').replace(/(\d{3})(\d{3})(\d{0,})/, `$1-$2-$3`);
|
|
432
432
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
433
|
+
* Normalizes a string for searching by:
|
|
434
|
+
* 1. Converting to NFD Unicode form and removing diacritics.
|
|
435
|
+
* 2. Converting to lowercase.
|
|
436
|
+
* 3. Removing all whitespace.
|
|
437
|
+
* @param str The string to normalize.
|
|
438
|
+
* @returns The normalized string.
|
|
436
439
|
*/
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
str = str.replace(/[ÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠ]/g, 'O');
|
|
449
|
-
str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, 'U');
|
|
450
|
-
str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, 'Y');
|
|
451
|
-
str = str.replace(/Đ/g, 'D');
|
|
452
|
-
return str;
|
|
453
|
-
};
|
|
454
|
-
/** Remove all accents and convert string to lower case, remove leading and trailing white space */
|
|
455
|
-
export const simplifyString = (str) => removeAccent(`${str || ''}`.toLowerCase().trim()) || '';
|
|
440
|
+
function normalizeStringForSearch(str) {
|
|
441
|
+
const normalizedStr = typeof str !== 'string' ? toString(str) : str;
|
|
442
|
+
if (!normalizedStr) {
|
|
443
|
+
return ''; // Handle null, undefined, or empty string inputs
|
|
444
|
+
}
|
|
445
|
+
return normalizedStr
|
|
446
|
+
.normalize('NFD') // Decompose accented characters (e.g., "á" -> "a" + "´")
|
|
447
|
+
.replace(/[\u0300-\u036f]/g, '') // Remove diacritical marks
|
|
448
|
+
.toLowerCase() // Convert to lowercase
|
|
449
|
+
.replace(/\s+/g, ''); // Remove all whitespace
|
|
450
|
+
}
|
|
456
451
|
/**
|
|
452
|
+
* Checks string matching based on a query, supporting fuzzy matching,
|
|
453
|
+
* where the query characters must appear in order within the target string.
|
|
454
|
+
* Allows for missing characters in the query relative to the target,
|
|
455
|
+
* and ignores case, diacritics, and spaces.
|
|
456
|
+
*
|
|
457
457
|
* @param str target string
|
|
458
458
|
* @param queryStr search query
|
|
459
459
|
* @returns true if target string includes search query
|
|
460
460
|
*/
|
|
461
|
-
export const searchStringQuery = (str, queryStr) =>
|
|
461
|
+
export const searchStringQuery = (str, queryStr) => {
|
|
462
|
+
const normalizedQuery = normalizeStringForSearch(queryStr);
|
|
463
|
+
const normalizedItem = normalizeStringForSearch(str);
|
|
464
|
+
// Optimization: if normalized query is longer than normalized item,
|
|
465
|
+
// it cannot be a subsequence.
|
|
466
|
+
if (normalizedQuery.length > normalizedItem.length) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
// Subsequence check:
|
|
470
|
+
// Iterate through both normalized strings.
|
|
471
|
+
// If characters match, advance the query pointer.
|
|
472
|
+
// Always advance the item pointer.
|
|
473
|
+
let queryIndex = 0;
|
|
474
|
+
let itemIndex = 0;
|
|
475
|
+
while (queryIndex < normalizedQuery.length && itemIndex < normalizedItem.length) {
|
|
476
|
+
if (normalizedQuery[queryIndex] === normalizedItem[itemIndex]) {
|
|
477
|
+
queryIndex++;
|
|
478
|
+
}
|
|
479
|
+
itemIndex++;
|
|
480
|
+
}
|
|
481
|
+
// If queryIndex reached the end of normalizedQuery, all its characters were found in order.
|
|
482
|
+
return queryIndex === normalizedQuery.length;
|
|
483
|
+
};
|
|
462
484
|
/**
|
|
463
485
|
* Checks if any of the provided values match the search value.
|
|
464
486
|
*
|
|
@@ -742,6 +764,22 @@ export const antsomiClsx = (componentName) => (className) => {
|
|
|
742
764
|
});
|
|
743
765
|
return clsx(classNames);
|
|
744
766
|
};
|
|
767
|
+
/**
|
|
768
|
+
* Take an array of data attribute key/value pairs and return an object which
|
|
769
|
+
* can be spread into a component's definition
|
|
770
|
+
*
|
|
771
|
+
* @param attributes
|
|
772
|
+
* @returns A spreadable object of data-attributes
|
|
773
|
+
*/
|
|
774
|
+
export const dataAttrArrayToObject = (attributes = []) => attributes.reduce((output, current) => {
|
|
775
|
+
// Ensure we follow the correct syntax so we will just return the output if not
|
|
776
|
+
if (!/^data-([a-z]+-)*[a-z]+$/g.test(kebabCase(current.key)))
|
|
777
|
+
return output;
|
|
778
|
+
// Assign the key/value pair to the output object
|
|
779
|
+
output[kebabCase(current.key)] = current.value;
|
|
780
|
+
// return the object
|
|
781
|
+
return output;
|
|
782
|
+
}, {});
|
|
745
783
|
export function arrayToMapByProperty(array, propertyName) {
|
|
746
784
|
// Đảm bảo đầu vào là một mảng và không rỗng
|
|
747
785
|
if (!Array.isArray(array) || array.length === 0) {
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
package/es/utils/web.d.ts
CHANGED
|
@@ -1,4 +1,70 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* Parses a font family string and extracts individual font names
|
|
4
|
+
* Handles quoted fonts, fallbacks, and CSS font-family syntax
|
|
5
|
+
* @param fontFamily - Font family string (e.g., "'Roboto', Arial, sans-serif")
|
|
6
|
+
* @returns Array of individual font names
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseFontFamily(fontFamily: string): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a given font name is considered a web safe font
|
|
11
|
+
* @param fontName - The font name to check (case insensitive)
|
|
12
|
+
* @param includeGeneric - Whether to consider generic font families as web safe (default: false)
|
|
13
|
+
* @returns boolean - True if the font is web safe, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function isWebSafeFont(fontName: string, includeGeneric?: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Extracts the primary font from a font-family string
|
|
18
|
+
* @param fontFamily Font family string (may contain fallbacks)
|
|
19
|
+
* @returns Primary font name
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPrimaryFontFamily(fontFamily: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the first font in a font family string is web safe
|
|
24
|
+
* @param fontFamily - Font family string
|
|
25
|
+
* @returns boolean - True if the primary font is web safe
|
|
26
|
+
*/
|
|
27
|
+
export declare function isPrimaryFontWebSafe(fontFamily: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a font name is a generic font family (CSS keyword)
|
|
30
|
+
* @param fontName - The font name to check
|
|
31
|
+
* @returns boolean - True if it's a generic font family
|
|
32
|
+
*/
|
|
33
|
+
export declare function isGenericFontFamily(fontName: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a font family string (with potential fallbacks) contains any web safe fonts
|
|
36
|
+
* @param fontFamily - Font family string with potential fallbacks (e.g., "'Custom Font', Arial, sans-serif")
|
|
37
|
+
* @param options - Configuration options
|
|
38
|
+
* @returns Object with detailed analysis
|
|
39
|
+
*/
|
|
40
|
+
export declare function analyzeFontFamily(fontFamily: string, options?: {
|
|
41
|
+
includeGenericAsWebSafe?: boolean;
|
|
42
|
+
}): {
|
|
43
|
+
hasWebSafeFonts: boolean;
|
|
44
|
+
webSafeFonts: string[];
|
|
45
|
+
nonWebSafeFonts: string[];
|
|
46
|
+
genericFonts: string[];
|
|
47
|
+
allFonts: string[];
|
|
48
|
+
isFullyWebSafe: boolean;
|
|
49
|
+
isPrimaryFontWebSafe: boolean;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Gets all available web safe fonts
|
|
53
|
+
* @returns Array of web safe font names
|
|
54
|
+
*/
|
|
55
|
+
export declare function getWebSafeFonts(): readonly string[];
|
|
56
|
+
/**
|
|
57
|
+
* Finds web safe font alternatives for a given font
|
|
58
|
+
* @param fontName - The font name to find alternatives for
|
|
59
|
+
* @returns Array of similar web safe fonts
|
|
60
|
+
*/
|
|
61
|
+
export declare function getWebSafeFontAlternatives(fontName: string): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Creates a font stack with appropriate fallbacks
|
|
64
|
+
* @param primaryFont Primary font family
|
|
65
|
+
* @returns Complete font stack string
|
|
66
|
+
*/
|
|
67
|
+
export declare function createFontStack(primaryFont: string): string;
|
|
2
68
|
/**
|
|
3
69
|
* Function to parse search params string to object
|
|
4
70
|
* @param {string} searchParams - search params
|
|
@@ -21,3 +87,17 @@ export declare const isLinux: () => boolean;
|
|
|
21
87
|
* @returns Platform-appropriate modifier key
|
|
22
88
|
*/
|
|
23
89
|
export declare const getModifierKey: () => "⌘" | "Ctrl";
|
|
90
|
+
/**
|
|
91
|
+
* Formats a hotkey string with the appropriate modifier
|
|
92
|
+
* @param key The key to format
|
|
93
|
+
* @returns Formatted hotkey string
|
|
94
|
+
*/
|
|
95
|
+
export declare const formatHotkey: (key: string) => string;
|
|
96
|
+
/**
|
|
97
|
+
* Chuyển đổi giá trị CSS 'px' thành số nguyên.
|
|
98
|
+
* Ví dụ: "16px" => 16
|
|
99
|
+
*
|
|
100
|
+
* @param fontSizeString - Chuỗi kích thước font, ví dụ: "16px".
|
|
101
|
+
* @returns Số nguyên hoặc null nếu chuỗi không hợp lệ.
|
|
102
|
+
*/
|
|
103
|
+
export declare function convertPxToNumber(fontSizeString: unknown): number | null;
|