@antscorp/antsomi-ui 1.3.3-beta.6 → 1.3.3-beta.60
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/images/iphone-top-bar.png +0 -0
- package/es/assets/images/iphone.png +0 -0
- package/es/assets/images/stars_slider.png +0 -0
- package/es/components/atoms/Button/index.d.ts +1 -8
- package/es/components/atoms/Empty/Empty.d.ts +6 -5
- package/es/components/atoms/Empty/Empty.js +7 -1
- package/es/components/atoms/Flex/Flex.d.ts +2 -0
- package/es/components/atoms/Flex/Flex.js +1 -0
- package/es/components/atoms/Flex/index.d.ts +1 -0
- package/es/components/atoms/Flex/index.js +1 -0
- package/es/components/atoms/Input/Input.d.ts +14 -3
- package/es/components/atoms/Input/Input.js +7 -3
- package/es/components/atoms/InputDynamic/EditCaretPositioning.d.ts +2 -0
- package/es/components/atoms/InputDynamic/EditCaretPositioning.js +89 -0
- package/es/components/atoms/InputDynamic/InputDynamic.d.ts +30 -0
- package/es/components/atoms/InputDynamic/InputDynamic.js +320 -0
- package/es/components/atoms/InputDynamic/PopupShortLink.d.ts +16 -0
- package/es/components/atoms/InputDynamic/PopupShortLink.js +85 -0
- package/es/components/atoms/InputDynamic/index.d.ts +2 -0
- package/es/components/atoms/InputDynamic/index.js +1 -0
- package/es/components/atoms/InputDynamic/styled.d.ts +12 -0
- package/es/components/atoms/InputDynamic/styled.js +281 -0
- package/es/components/atoms/InputDynamic/utils.d.ts +22 -0
- package/es/components/atoms/InputDynamic/utils.js +751 -0
- package/es/components/atoms/MobileFrame/MobileFrame.d.ts +4 -0
- package/es/components/atoms/MobileFrame/MobileFrame.js +22 -0
- package/es/components/atoms/MobileFrame/constants.d.ts +4 -0
- package/es/components/atoms/MobileFrame/constants.js +4 -0
- package/es/components/atoms/MobileFrame/index.d.ts +2 -0
- package/es/components/atoms/MobileFrame/index.js +1 -0
- package/es/components/atoms/MobileFrame/styled.d.ts +3 -0
- package/es/components/atoms/MobileFrame/styled.js +33 -0
- package/es/components/atoms/Pagination/index.d.ts +1 -0
- package/es/components/atoms/Popover/Popover.d.ts +1 -1
- package/es/components/atoms/Popover/styled.d.ts +1 -1
- package/es/components/atoms/PreviewTabs/PreviewTabs.d.ts +7 -0
- package/es/components/atoms/PreviewTabs/PreviewTabs.js +67 -0
- package/es/components/atoms/PreviewTabs/index.d.ts +2 -0
- package/es/components/atoms/PreviewTabs/index.js +1 -0
- package/es/components/atoms/PreviewTabs/styled.d.ts +6 -0
- package/es/components/atoms/PreviewTabs/styled.js +79 -0
- package/es/components/atoms/Progress/Progress.d.ts +1 -1
- package/es/components/atoms/Radio/index.d.ts +3 -3
- package/es/components/atoms/RateV2/RateV2.d.ts +18 -0
- package/es/components/atoms/RateV2/RateV2.js +73 -0
- package/es/components/atoms/RateV2/index.d.ts +1 -0
- package/es/components/atoms/RateV2/index.js +1 -0
- package/es/components/atoms/RequiredLabel/index.d.ts +1 -0
- package/es/components/atoms/RequiredLabel/index.js +4 -3
- package/es/components/atoms/Slider/index.d.ts +2 -1
- package/es/components/atoms/Slider/index.js +7 -14
- package/es/components/atoms/SliderV2/index.d.ts +6 -0
- package/es/components/atoms/SliderV2/index.js +21 -0
- package/es/components/atoms/Space/Space.d.ts +1 -1
- package/es/components/atoms/Spin/Spin.d.ts +2 -1
- package/es/components/atoms/Statistic/Statistic.d.ts +1 -4
- package/es/components/atoms/index.d.ts +8 -0
- package/es/components/atoms/index.js +6 -0
- package/es/components/common/ConfigProvider/ConfigProvider.js +6 -0
- package/es/components/common/ConfigProvider/GlobalStyle.js +271 -27
- package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
- package/es/components/icons/AudioRecordIcon.d.ts +2 -1
- package/es/components/icons/BugIcon.d.ts +2 -1
- package/es/components/icons/CameraIcon.d.ts +2 -1
- package/es/components/icons/CaptureIcon.d.ts +2 -1
- package/es/components/icons/CheckSlimIcon.d.ts +2 -1
- package/es/components/icons/CloseIcon.d.ts +2 -1
- package/es/components/icons/CommentIcon.d.ts +2 -1
- package/es/components/icons/EventIcon.d.ts +2 -1
- package/es/components/icons/FreeDrawIcon.d.ts +2 -1
- package/es/components/icons/GPTIcon.d.ts +2 -1
- package/es/components/icons/GPTIconV2.d.ts +2 -1
- package/es/components/icons/GPTIconV3.d.ts +2 -1
- package/es/components/icons/HighlightIcon.d.ts +2 -1
- package/es/components/icons/IdeaIcon.d.ts +2 -1
- package/es/components/icons/InvisibleIcon.d.ts +2 -1
- package/es/components/icons/MuteIcon.d.ts +2 -1
- package/es/components/icons/OpenUrlIcon.d.ts +2 -1
- package/es/components/icons/PauseIcon.d.ts +2 -1
- package/es/components/icons/PlaneIcon.d.ts +2 -1
- package/es/components/icons/RequestIcon.d.ts +2 -1
- package/es/components/icons/StopRecordIcon.d.ts +2 -1
- package/es/components/icons/UserIcon.d.ts +2 -1
- package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
- package/es/components/icons/WarningIcon.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
- package/es/components/molecules/Collapse/Collapse.d.ts +3 -3
- package/es/components/molecules/Collapse/Collapse.js +9 -0
- package/es/components/molecules/ColorSetting/styled.d.ts +1 -8
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.d.ts +2 -2
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +258 -111
- package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.d.ts +66 -25
- package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.js +109 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +48 -4
- package/es/components/molecules/DatePicker/components/AdvancedPicker/types.d.ts +22 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +20 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.js +90 -1
- package/es/components/molecules/Drawer/Drawer.d.ts +5 -1
- package/es/components/molecules/Drawer/Drawer.js +3 -1
- package/es/components/molecules/Drawer/index.d.ts +1 -0
- package/es/components/molecules/Form/Form.d.ts +1 -0
- package/es/components/molecules/Form/Form.js +1 -0
- package/es/components/molecules/Form/index.d.ts +1 -0
- package/es/components/molecules/Form/index.js +1 -0
- package/es/components/molecules/IconSelection/styled.d.ts +1 -8
- package/es/components/molecules/Modal/Modal.d.ts +2 -2
- package/es/components/molecules/Modal/index.d.ts +1 -0
- package/es/components/molecules/Modal/styled.d.ts +1 -1
- package/es/components/molecules/ModalV2/ModalV2.d.ts +5 -0
- package/es/components/molecules/ModalV2/ModalV2.js +26 -0
- package/es/components/molecules/ModalV2/index.d.ts +2 -0
- package/es/components/molecules/ModalV2/index.js +1 -0
- package/es/components/molecules/ModalV2/styled.d.ts +7 -0
- package/es/components/molecules/ModalV2/styled.js +22 -0
- package/es/components/molecules/Popconfirm/Popconfirm.d.ts +1 -1
- package/es/components/molecules/PreviewModal/PreviewModal.d.ts +7 -0
- package/es/components/molecules/PreviewModal/PreviewModal.js +30 -0
- package/es/components/molecules/PreviewModal/index.d.ts +2 -0
- package/es/components/molecules/PreviewModal/index.js +1 -0
- package/es/components/molecules/PreviewModal/styled.d.ts +4 -0
- package/es/components/molecules/PreviewModal/styled.js +39 -0
- package/es/components/molecules/ResizeGrid/ResizeGrid.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/ResizeGrid.js +728 -0
- package/es/components/molecules/ResizeGrid/components/Cell/Cell.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +87 -0
- package/es/components/molecules/ResizeGrid/components/Cell/index.d.ts +1 -0
- package/es/components/molecules/ResizeGrid/components/Cell/index.js +1 -0
- package/es/components/molecules/ResizeGrid/components/Cell/styled.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/components/Cell/styled.js +80 -0
- package/es/components/molecules/ResizeGrid/constant.d.ts +35 -0
- package/es/components/molecules/ResizeGrid/constant.js +111 -0
- package/es/components/molecules/ResizeGrid/index.d.ts +2 -0
- package/es/components/molecules/ResizeGrid/index.js +1 -0
- package/es/components/molecules/ResizeGrid/styled.d.ts +10 -0
- package/es/components/molecules/ResizeGrid/styled.js +56 -0
- package/es/components/molecules/ResizeGrid/types.d.ts +147 -0
- package/es/components/molecules/ResizeGrid/types.js +1 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +11 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +53 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.d.ts +16 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.js +105 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.d.ts +20 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.js +135 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/constants.d.ts +2 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/constants.js +765 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/index.d.ts +3 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/index.js +2 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/styled.d.ts +9 -0
- package/es/components/molecules/RichMenu/RichMenuBlock/styled.js +17 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.d.ts +10 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.js +32 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.d.ts +6 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.js +15 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.d.ts +4 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.js +47 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/index.d.ts +2 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/index.js +1 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +9 -0
- package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +37 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +10 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +37 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/index.d.ts +1 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/index.js +1 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/styled.d.ts +6 -0
- package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +20 -0
- package/es/components/molecules/RichMenu/index.d.ts +3 -0
- package/es/components/molecules/RichMenu/index.js +3 -0
- package/es/components/molecules/Select/Select.d.ts +5 -1
- package/es/components/molecules/Select/Select.js +23 -2
- package/es/components/molecules/Select/Test.d.ts +2 -1
- package/es/components/molecules/ShareAccess/ShareAccess.d.ts +3 -0
- package/es/components/molecules/ShareAccess/ShareAccess.js +23 -0
- package/es/components/molecules/ShareAccess/actions.d.ts +16 -0
- package/es/components/molecules/ShareAccess/actions.js +12 -0
- package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.d.ts +2 -0
- package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.js +70 -0
- package/es/components/molecules/ShareAccess/components/GeneralAccess/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/GeneralAccess/index.js +1 -0
- package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.js +57 -0
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.d.ts +3 -0
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +14 -0
- package/es/components/molecules/ShareAccess/components/LayoutContent/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/LayoutContent/index.js +1 -0
- package/es/components/molecules/ShareAccess/components/LayoutContent/styled.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/LayoutContent/styled.js +7 -0
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/ModalTransferOwnerShip.d.ts +2 -0
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/ModalTransferOwnerShip.js +43 -0
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/index.d.ts +0 -0
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/index.js +1 -0
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.d.ts +7 -0
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.js +18 -0
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.d.ts +5 -0
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +92 -0
- package/es/components/molecules/ShareAccess/components/PeopleAccess/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/PeopleAccess/index.js +1 -0
- package/es/components/molecules/ShareAccess/components/PeopleAccess/styled.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/PeopleAccess/styled.js +46 -0
- package/es/components/molecules/ShareAccess/components/SearchUser/SearchUser.d.ts +5 -0
- package/es/components/molecules/ShareAccess/components/SearchUser/SearchUser.js +73 -0
- package/es/components/molecules/ShareAccess/components/SearchUser/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/SearchUser/index.js +1 -0
- package/es/components/molecules/ShareAccess/components/SearchUser/styled.d.ts +2 -0
- package/es/components/molecules/ShareAccess/components/SearchUser/styled.js +29 -0
- package/es/components/molecules/ShareAccess/components/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/components/index.js +1 -0
- package/es/components/molecules/ShareAccess/constants.d.ts +61 -0
- package/es/components/molecules/ShareAccess/constants.js +79 -0
- package/es/components/molecules/ShareAccess/context.d.ts +4 -0
- package/es/components/molecules/ShareAccess/context.js +3 -0
- package/es/components/molecules/ShareAccess/hooks/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/hooks/index.js +1 -0
- package/es/components/molecules/ShareAccess/hooks/useShareAccess.d.ts +15 -0
- package/es/components/molecules/ShareAccess/hooks/useShareAccess.js +15 -0
- package/es/components/molecules/ShareAccess/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/index.js +1 -0
- package/es/components/molecules/ShareAccess/reducer.d.ts +2 -0
- package/es/components/molecules/ShareAccess/reducer.js +19 -0
- package/es/components/molecules/ShareAccess/types.d.ts +46 -0
- package/es/components/molecules/ShareAccess/types.js +1 -0
- package/es/components/molecules/ShareAccess/utils.d.ts +14 -0
- package/es/components/molecules/ShareAccess/utils.js +22 -0
- package/es/components/molecules/TreeSelect/TreeSelect.d.ts +2 -1
- package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
- package/es/components/molecules/index.d.ts +10 -2
- package/es/components/molecules/index.js +8 -2
- package/es/components/organism/Help/styled.d.ts +4 -10
- package/es/components/organism/Table/ExplorePivotTable/styled.d.ts +1 -0
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/richMenu.d.ts +19 -0
- package/es/constants/richMenu.js +19 -0
- package/es/constants/storybook.d.ts +7 -1
- package/es/constants/storybook.js +12 -0
- package/es/constants/theme.js +30 -3
- package/es/hooks/useDebounceCallback.d.ts +1 -0
- package/es/hooks/useDebounceCallback.js +5 -0
- package/es/hooks/useDebounceV2.d.ts +1 -0
- package/es/hooks/useDebounceV2.js +11 -0
- package/es/hooks/useDeepCompareEffect.d.ts +1 -0
- package/es/hooks/useDeepCompareEffect.js +21 -0
- package/es/hooks/usePrevious.d.ts +2 -0
- package/es/hooks/usePrevious.js +9 -0
- package/es/locales/en/translation.json +3 -1
- package/es/locales/i18n.d.ts +3 -0
- package/es/locales/translations.d.ts +2 -0
- package/es/locales/vi/translation.json +2 -1
- package/es/test.d.ts +2 -1
- package/es/test.js +164 -66
- package/es/types/index.d.ts +12 -0
- package/es/types/index.js +2 -1
- package/es/types/richMenu.d.ts +214 -0
- package/es/types/richMenu.js +1 -0
- package/es/types/variables.d.ts +2 -0
- package/es/types/variables.js +1 -0
- package/es/utils/common.d.ts +3 -0
- package/es/utils/common.js +20 -0
- package/es/utils/handleError.d.ts +32 -2
- package/es/utils/handleError.js +42 -4
- package/package.json +12 -9
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const Button: import("react").ForwardRefExoticComponent<
|
|
3
|
-
href: string;
|
|
4
|
-
target?: string | undefined;
|
|
5
|
-
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
6
|
-
} & import("antd/es/button/button").BaseButtonProps & Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, "type" | "onClick"> & {
|
|
7
|
-
htmlType?: "button" | "reset" | "submit" | undefined;
|
|
8
|
-
onClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
9
|
-
} & Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onClick">> & import("react").RefAttributes<HTMLElement>> & {
|
|
2
|
+
export declare const Button: import("react").ForwardRefExoticComponent<import("antd").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
|
|
10
3
|
Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
|
|
11
4
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EmptyProps } from 'antd';
|
|
3
|
+
export interface IEmpty extends EmptyProps {
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Empty: React.FC<IEmpty>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { Empty as AntdEmpty } from 'antd';
|
|
2
|
-
|
|
3
|
+
import { Spin } from '../Spin';
|
|
4
|
+
import { LoadingOutlined } from '@ant-design/icons';
|
|
5
|
+
export const Empty = props => {
|
|
6
|
+
const { loading, description } = props;
|
|
7
|
+
return (React.createElement(AntdEmpty, Object.assign({}, props, { description: loading ? (React.createElement(Spin, { indicator: React.createElement(LoadingOutlined, { style: { fontSize: 24 }, spin: true }) })) : (description) })));
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Flex } from 'antd';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Flex';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Flex';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="hoist-non-react-statics" />
|
|
1
2
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { InputProps as AntdInputProps } from 'antd';
|
|
3
|
+
import { InputProps as AntdInputProps, Input as AntdInput } from 'antd';
|
|
3
4
|
export interface InputProps extends AntdInputProps {
|
|
4
5
|
noborder?: 'true' | 'false' | boolean;
|
|
5
6
|
debounce?: number;
|
|
@@ -7,14 +8,24 @@ export interface InputProps extends AntdInputProps {
|
|
|
7
8
|
onAfterChange?: (value: any) => void;
|
|
8
9
|
errorArchive?: string;
|
|
9
10
|
required?: boolean;
|
|
11
|
+
isReverseMask?: boolean;
|
|
12
|
+
labelColor?: string;
|
|
13
|
+
isHideErrMessage?: boolean;
|
|
10
14
|
focused?: boolean;
|
|
11
15
|
errorMsg?: string;
|
|
12
16
|
disableUndo?: boolean;
|
|
13
17
|
}
|
|
14
|
-
export declare const Input: import("styled-components").
|
|
18
|
+
export declare const Input: string & import("styled-components").StyledComponentBase<React.ForwardRefExoticComponent<AntdInputProps & React.RefAttributes<import("antd").InputRef>> & {
|
|
15
19
|
Group: React.FC<import("antd/es/input").GroupProps>;
|
|
16
20
|
Search: React.ForwardRefExoticComponent<import("antd/es/input").SearchProps & React.RefAttributes<import("antd").InputRef>>;
|
|
17
21
|
TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
|
|
18
22
|
Password: React.ForwardRefExoticComponent<import("antd/es/input").PasswordProps & React.RefAttributes<import("antd").InputRef>>;
|
|
19
|
-
}, any, InputProps, never
|
|
23
|
+
}, any, InputProps, never> & import("hoist-non-react-statics").NonReactStatics<React.ForwardRefExoticComponent<AntdInputProps & React.RefAttributes<import("antd").InputRef>> & {
|
|
24
|
+
Group: React.FC<import("antd/es/input").GroupProps>;
|
|
25
|
+
Search: React.ForwardRefExoticComponent<import("antd/es/input").SearchProps & React.RefAttributes<import("antd").InputRef>>;
|
|
26
|
+
TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
|
|
27
|
+
Password: React.ForwardRefExoticComponent<import("antd/es/input").PasswordProps & React.RefAttributes<import("antd").InputRef>>;
|
|
28
|
+
}, {}> & {
|
|
29
|
+
DefaultInput: typeof AntdInput;
|
|
30
|
+
};
|
|
20
31
|
export declare const TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
|
|
@@ -13,6 +13,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
/* eslint-disable react/destructuring-assignment */
|
|
14
14
|
// Libraries
|
|
15
15
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
16
|
+
// Types
|
|
17
|
+
import { Input as AntdInput } from 'antd';
|
|
16
18
|
// Components
|
|
17
19
|
import { RequiredLabel, Text } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
18
20
|
// Utils
|
|
@@ -22,7 +24,7 @@ import { StyledInput } from './styled';
|
|
|
22
24
|
const PATH = '@antscorp/antsomi-ui/es/components/atoms/Input/Input.tsx';
|
|
23
25
|
const OriginInput = props => {
|
|
24
26
|
// Props
|
|
25
|
-
const { debounce, errorArchive, required, focused, label, onAfterChange, onChange, errorMsg } = props, restProps = __rest(props, ["debounce", "errorArchive", "required", "focused", "label", "onAfterChange", "onChange", "errorMsg"]);
|
|
27
|
+
const { debounce, errorArchive, required, labelColor, isReverseMask, isHideErrMessage, focused, label, onAfterChange, onChange, errorMsg } = props, restProps = __rest(props, ["debounce", "errorArchive", "required", "labelColor", "isReverseMask", "isHideErrMessage", "focused", "label", "onAfterChange", "onChange", "errorMsg"]);
|
|
26
28
|
// State
|
|
27
29
|
const [value, setValue] = useState(props.value);
|
|
28
30
|
const [isFocused, setFocused] = useState(false);
|
|
@@ -66,7 +68,7 @@ const OriginInput = props => {
|
|
|
66
68
|
};
|
|
67
69
|
const renderRequiredLabel = (label) => {
|
|
68
70
|
if (required) {
|
|
69
|
-
return (React.createElement(RequiredLabel, { color:
|
|
71
|
+
return (React.createElement(RequiredLabel, { isReverseMask: isReverseMask, color: labelColor || '#666666', style: { marginBottom: 5 } }, label));
|
|
70
72
|
}
|
|
71
73
|
return (React.createElement(Text, { color: "#666666", style: { marginBottom: 5 } }, label));
|
|
72
74
|
};
|
|
@@ -82,11 +84,13 @@ const OriginInput = props => {
|
|
|
82
84
|
}
|
|
83
85
|
restProps.onBlur && restProps.onBlur(e);
|
|
84
86
|
}, onChange: onChangeInput }, getPreventKeyboardAction(listDisableActions))),
|
|
85
|
-
restProps.status === 'error' || errorArchive || requiredMsg ? (React.createElement(Text, { color: "#ff4d4f", style: { marginLeft: 8, marginTop: 5 } }, errorMsg || errorArchive || requiredMsg)) : null));
|
|
87
|
+
(restProps.status === 'error' || errorArchive || requiredMsg) && !isHideErrMessage ? (React.createElement(Text, { color: "#ff4d4f", style: { marginLeft: 8, marginTop: 5 } }, errorMsg || errorArchive || requiredMsg)) : null));
|
|
86
88
|
};
|
|
87
89
|
OriginInput.defaultProps = {
|
|
88
90
|
debounce: 400,
|
|
91
|
+
isHideErrMessage: false,
|
|
89
92
|
};
|
|
90
93
|
export const Input = OriginInput;
|
|
91
94
|
Input.TextArea = StyledInput.TextArea;
|
|
95
|
+
Input.DefaultInput = AntdInput;
|
|
92
96
|
export const { TextArea } = StyledInput;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* eslint-disable no-cond-assign */
|
|
2
|
+
/* eslint-disable no-plusplus */
|
|
3
|
+
/* eslint-disable one-var */
|
|
4
|
+
/* eslint-disable func-names */
|
|
5
|
+
/* eslint-disable object-shorthand */
|
|
6
|
+
/* eslint-disable prefer-const */
|
|
7
|
+
const EditCaretPositioning = {};
|
|
8
|
+
if (window.getSelection && document.createRange) {
|
|
9
|
+
// saves caret position(s)
|
|
10
|
+
EditCaretPositioning.saveSelection = function (containerEl) {
|
|
11
|
+
var _a;
|
|
12
|
+
try {
|
|
13
|
+
let range = (_a = window === null || window === void 0 ? void 0 : window.getSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
14
|
+
let preSelectionRange = range === null || range === void 0 ? void 0 : range.cloneRange();
|
|
15
|
+
preSelectionRange === null || preSelectionRange === void 0 ? void 0 : preSelectionRange.selectNodeContents(containerEl);
|
|
16
|
+
preSelectionRange === null || preSelectionRange === void 0 ? void 0 : preSelectionRange.setEnd(range === null || range === void 0 ? void 0 : range.startContainer, range === null || range === void 0 ? void 0 : range.startOffset);
|
|
17
|
+
let start = preSelectionRange === null || preSelectionRange === void 0 ? void 0 : preSelectionRange.toString().length;
|
|
18
|
+
return {
|
|
19
|
+
start: start,
|
|
20
|
+
end: start + (range === null || range === void 0 ? void 0 : range.toString().length),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log('err:>', e);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
start: 0,
|
|
29
|
+
end: 0,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
// restores caret position(s)
|
|
33
|
+
EditCaretPositioning.restoreSelection = function (containerEl, savedSel) {
|
|
34
|
+
let charIndex = 0, range = document.createRange();
|
|
35
|
+
range.setStart(containerEl, 0);
|
|
36
|
+
range.collapse(true);
|
|
37
|
+
let nodeStack = [containerEl], node, foundStart = false, stop = false;
|
|
38
|
+
while (!stop && (node = nodeStack.pop())) {
|
|
39
|
+
if (node.nodeType === 3) {
|
|
40
|
+
let nextCharIndex = charIndex + node.length;
|
|
41
|
+
if (!foundStart &&
|
|
42
|
+
savedSel &&
|
|
43
|
+
savedSel.start >= charIndex &&
|
|
44
|
+
savedSel.start <= nextCharIndex) {
|
|
45
|
+
range.setStart(node, savedSel.start - charIndex);
|
|
46
|
+
foundStart = true;
|
|
47
|
+
}
|
|
48
|
+
if (foundStart && savedSel.end >= charIndex && savedSel.end <= nextCharIndex) {
|
|
49
|
+
range.setEnd(node, savedSel.end - charIndex);
|
|
50
|
+
stop = true;
|
|
51
|
+
}
|
|
52
|
+
charIndex = nextCharIndex;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
let i = node.childNodes.length;
|
|
56
|
+
while (i--) {
|
|
57
|
+
nodeStack.push(node.childNodes[i]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let sel = window.getSelection();
|
|
62
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
63
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else if (document.selection && document.body.createTextRange) {
|
|
67
|
+
// saves caret position(s)
|
|
68
|
+
EditCaretPositioning.saveSelection = function (containerEl) {
|
|
69
|
+
let selectedTextRange = document.selection.createRange();
|
|
70
|
+
let preSelectionTextRange = document.body.createTextRange();
|
|
71
|
+
preSelectionTextRange.moveToElementText(containerEl);
|
|
72
|
+
preSelectionTextRange.setEndPoint('EndToStart', selectedTextRange);
|
|
73
|
+
let start = preSelectionTextRange.text.length;
|
|
74
|
+
return {
|
|
75
|
+
start: start,
|
|
76
|
+
end: start + selectedTextRange.text.length,
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
// restores caret position(s)
|
|
80
|
+
EditCaretPositioning.restoreSelection = function (containerEl, savedSel) {
|
|
81
|
+
let textRange = document.body.createTextRange();
|
|
82
|
+
textRange.moveToElementText(containerEl);
|
|
83
|
+
textRange.collapse(true);
|
|
84
|
+
textRange.moveEnd('character', savedSel.end);
|
|
85
|
+
textRange.moveStart('character', savedSel.start);
|
|
86
|
+
textRange.select();
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export default EditCaretPositioning;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DisableShortLinkTypeProps } from './PopupShortLink';
|
|
3
|
+
export type KeyTagType = 'shortlink' | 'shortlink_static';
|
|
4
|
+
export type SelectedPropertiesProps = {
|
|
5
|
+
keyTag: KeyTagType;
|
|
6
|
+
link: string;
|
|
7
|
+
urlDetected: string;
|
|
8
|
+
};
|
|
9
|
+
export type InputDynamicProps = {
|
|
10
|
+
value: string;
|
|
11
|
+
isViewMode?: boolean;
|
|
12
|
+
errors?: string[];
|
|
13
|
+
disabledOpts?: DisableShortLinkTypeProps;
|
|
14
|
+
canMultipleLine?: boolean;
|
|
15
|
+
onError?: Function;
|
|
16
|
+
onChange: (valueOut: string) => any;
|
|
17
|
+
addMessageToQueue?: Function;
|
|
18
|
+
};
|
|
19
|
+
export declare const InputDynamic: {
|
|
20
|
+
(props: InputDynamicProps): React.JSX.Element;
|
|
21
|
+
defaultProps: {
|
|
22
|
+
value: string;
|
|
23
|
+
isViewMode: boolean;
|
|
24
|
+
errors: never[];
|
|
25
|
+
canMultipleLine: boolean;
|
|
26
|
+
onError: () => void;
|
|
27
|
+
onChange: () => void;
|
|
28
|
+
addMessageToQueue: () => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useState, useLayoutEffect, useEffect, useRef, useCallback, } from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
// Components
|
|
5
|
+
import CaretPositioning from './EditCaretPositioning';
|
|
6
|
+
import { WrapperInputStyle, TooltipHover } from './styled';
|
|
7
|
+
import { PopupShortLink } from './PopupShortLink';
|
|
8
|
+
import Icon from '@antscorp/icons';
|
|
9
|
+
// Utils
|
|
10
|
+
import { getObjectPropSafely, random, safeParse } from '@antscorp/antsomi-ui/es/utils';
|
|
11
|
+
import { convertBreakTag, convertDivToBreakTag, convertHtmlText, genShortLinkValue, getInsertLinkPatternWithAppendSpaceEnd, handleUpdateInputPersonalization, initialValue, pasteHtmlAtCaret, removeHtmlTag, spacingNonTracking, validateHTMLTags, } from './utils';
|
|
12
|
+
// Hooks
|
|
13
|
+
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
|
|
14
|
+
const PATH = 'src/components/atoms/InputDynamic/InputDynamic.tsx';
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
value: '',
|
|
17
|
+
isViewMode: false,
|
|
18
|
+
errors: [],
|
|
19
|
+
canMultipleLine: false,
|
|
20
|
+
onError: () => { },
|
|
21
|
+
onChange: () => { },
|
|
22
|
+
addMessageToQueue: () => { },
|
|
23
|
+
};
|
|
24
|
+
export const InputDynamic = (props) => {
|
|
25
|
+
const { value, isViewMode, errors, disabledOpts, canMultipleLine, onError, onChange, addMessageToQueue, } = props;
|
|
26
|
+
// States
|
|
27
|
+
const [textValue, setTextValue] = useState(initialValue(value));
|
|
28
|
+
const [initSelectedProperties, setInitSelectedProperties] = useState({
|
|
29
|
+
keyTag: 'shortlink_static',
|
|
30
|
+
link: '',
|
|
31
|
+
urlDetected: '',
|
|
32
|
+
});
|
|
33
|
+
const [popoverOpenShortLink, setPopoverOpenShortLink] = useState(false);
|
|
34
|
+
const [tooltipHoverDebounce, _tooltipHover, setTooltipHover] = useDebounce({ x: 0, y: 0 }, 200);
|
|
35
|
+
// Refs
|
|
36
|
+
const caretPositionRef = useRef(null);
|
|
37
|
+
const personalizationInputRef = useRef(null);
|
|
38
|
+
const onTriggerChange = (event = null) => {
|
|
39
|
+
var _a;
|
|
40
|
+
try {
|
|
41
|
+
let tmp = (_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
42
|
+
if (event !== null) {
|
|
43
|
+
caretPositionRef.current = CaretPositioning.saveSelection(event.currentTarget);
|
|
44
|
+
tmp = event.currentTarget.innerHTML;
|
|
45
|
+
}
|
|
46
|
+
tmp = tmp === null || tmp === void 0 ? void 0 : tmp.replace(
|
|
47
|
+
// replace old non tracking url to detect url
|
|
48
|
+
/<button(?=[^>]*class="insert-word")[^>]*value=['"]#(?:{nontrackurl\()?(https?:\/\/[0-9a-zA-Z-{}|"\./?_=&%:#*@;]+)(?:\)})?['"][^>]*>.*?<\/button>/g, match => {
|
|
49
|
+
const url = match.match(/(https?:\/\/[0-9a-zA-Z-\./?_=&%:#*@;]+)/);
|
|
50
|
+
if (url) {
|
|
51
|
+
return `<span id="${random(5)}" class="detect-url">${url[1]}</span>`;
|
|
52
|
+
}
|
|
53
|
+
return match; // If no match found, return the original string
|
|
54
|
+
}).replace(
|
|
55
|
+
// replace url to detect url
|
|
56
|
+
/((?<!class="detect-url">|#{shortlink(?:_static)?\(|<span style="line-height: 20px;margin-right: 8px;pointer-events:none;">)\bhttps*:\/\/[0-9a-zA-Z-{}|"\./?_=&%:#*@;]+)/g, match => `<span id="${random(5)}" class="detect-url">${match}</span>`);
|
|
57
|
+
tmp = convertDivToBreakTag(tmp);
|
|
58
|
+
setTextValue(tmp);
|
|
59
|
+
const text = convertHtmlText(tmp, 'raw', {}, {}, 'input', 'add');
|
|
60
|
+
const textConverted = convertBreakTag(text);
|
|
61
|
+
onChange(removeHtmlTag(textConverted));
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (typeof addMessageToQueue === 'function') {
|
|
65
|
+
addMessageToQueue({
|
|
66
|
+
path: 'app/containers/UIDev/UIEditorPersonalization/Input/index.jsx',
|
|
67
|
+
func: 'onTriggerChange',
|
|
68
|
+
data: error,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// eslint-disable-next-line no-console
|
|
72
|
+
console.error(error);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const callback = (type, data) => {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
switch (type) {
|
|
78
|
+
case 'REPLACE_DETECTED_URL': {
|
|
79
|
+
const innerHTML = getObjectPropSafely(() => { var _a; return (_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML; }, '');
|
|
80
|
+
if (innerHTML) {
|
|
81
|
+
// remove span url và focus vào vị trí remove để add tag shortlink vào vị trí này.
|
|
82
|
+
const index = Array.from((_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.childNodes).findIndex((element) => element.id === data.id);
|
|
83
|
+
const range = document.createRange(); // Tạo một đối tượng Range
|
|
84
|
+
const sel = window.getSelection(); // Lấy đối tượng Selection hiện tại
|
|
85
|
+
range.setStart((_b = personalizationInputRef.current) === null || _b === void 0 ? void 0 : _b.childNodes[index], 0); // Đặt điểm bắt đầu của Range
|
|
86
|
+
range.collapse(true); // Thu gọn Range để tập trung vào điểm bắt đầu
|
|
87
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges(); // Xóa tất cả các Range hiện có
|
|
88
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range); // Thêm Range mới vào Selection
|
|
89
|
+
caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
|
|
90
|
+
const newDataUpdate = innerHTML.replace(data.outerHTML, '');
|
|
91
|
+
personalizationInputRef.current.innerHTML = newDataUpdate;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const onPaste = (e) => {
|
|
100
|
+
// cancel paste
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
// get text representation of clipboard
|
|
103
|
+
const text = (e.originalEvent || e).clipboardData.getData('text/plain');
|
|
104
|
+
// insert text manually
|
|
105
|
+
document.execCommand('insertHTML', false, text);
|
|
106
|
+
};
|
|
107
|
+
const handleInsertSortLink = (url, type) => {
|
|
108
|
+
try {
|
|
109
|
+
const { id, value: linkValue, label: linkLabel } = genShortLinkValue(url, type);
|
|
110
|
+
setPopoverOpenShortLink(false);
|
|
111
|
+
if (personalizationInputRef.current instanceof HTMLElement) {
|
|
112
|
+
CaretPositioning.restoreSelection(personalizationInputRef.current, caretPositionRef.current);
|
|
113
|
+
pasteHtmlAtCaret(getInsertLinkPatternWithAppendSpaceEnd(id, linkValue, linkLabel), null);
|
|
114
|
+
onTriggerChange();
|
|
115
|
+
caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
|
|
116
|
+
}
|
|
117
|
+
setInitSelectedProperties({ link: '', keyTag: 'shortlink_static', urlDetected: '' });
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
if (typeof addMessageToQueue === 'function') {
|
|
121
|
+
addMessageToQueue({
|
|
122
|
+
path: 'app/containers/UIDev/UIEditorPersonalization/Input/index.jsx',
|
|
123
|
+
func: 'handleInsertText',
|
|
124
|
+
data: err,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleKeyPress = (e) => {
|
|
130
|
+
if (canMultipleLine)
|
|
131
|
+
return;
|
|
132
|
+
if (+e.charCode === 13) {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const getDangerouslySetInnerHTML = (text) => {
|
|
137
|
+
if (text) {
|
|
138
|
+
const regex = /<[^<>]+>/g;
|
|
139
|
+
let tag;
|
|
140
|
+
// eslint-disable-next-line no-cond-assign
|
|
141
|
+
while ((tag = regex.exec(text))) {
|
|
142
|
+
if (!validateHTMLTags.isValidTag(tag[0])) {
|
|
143
|
+
const finalTag = tag[0].replace('<', '<').replace('>', '>');
|
|
144
|
+
text = text.replace(tag[0], finalTag);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
text = text.replaceAll('\n', '<br>');
|
|
148
|
+
if (spacingNonTracking(text)) {
|
|
149
|
+
return text;
|
|
150
|
+
}
|
|
151
|
+
return safeParse(text, '').concat('<br />');
|
|
152
|
+
}
|
|
153
|
+
return '';
|
|
154
|
+
};
|
|
155
|
+
const toggleShortLinkModal = useCallback(() => {
|
|
156
|
+
setPopoverOpenShortLink(!popoverOpenShortLink);
|
|
157
|
+
}, [popoverOpenShortLink]);
|
|
158
|
+
/**
|
|
159
|
+
* [NOTE:open shortlink modal to edit]
|
|
160
|
+
*/
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const handleClickTag = (e) => {
|
|
163
|
+
try {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
if (e.target) {
|
|
166
|
+
const { value = '' } = e.target;
|
|
167
|
+
const shortLink = value.replace(/#|{|}|/g, '').split('(');
|
|
168
|
+
if (shortLink && shortLink.length >= 2) {
|
|
169
|
+
const link = shortLink[1].substring(0, shortLink[1].length - 1) || '';
|
|
170
|
+
setInitSelectedProperties(prev => (Object.assign(Object.assign({}, prev), { link, keyTag: shortLink[0], urlDetected: e.currentTarget })));
|
|
171
|
+
toggleShortLinkModal();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
// eslint-disable-next-line no-console
|
|
177
|
+
console.log('err', err);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const listTags = Array.from(document.querySelectorAll('#ants-ui-input-personalization .input-personal .insert-word'));
|
|
181
|
+
if (listTags && listTags.length > 0) {
|
|
182
|
+
listTags.forEach((tag) => {
|
|
183
|
+
tag.addEventListener('click', handleClickTag);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return () => {
|
|
187
|
+
listTags.forEach((tag) => {
|
|
188
|
+
tag.removeEventListener('click', handleClickTag);
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
}, [textValue, toggleShortLinkModal]);
|
|
192
|
+
/** Anchor tooltip */
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
let listElement = [];
|
|
195
|
+
const handleMouseOver = (e, targetRect) => {
|
|
196
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
197
|
+
const viewportTop = window.pageYOffset;
|
|
198
|
+
const viewportLeft = window.pageXOffset;
|
|
199
|
+
const offsetWidth = targetRect.width / 2;
|
|
200
|
+
const offsetHeight = targetRect.height / 2;
|
|
201
|
+
const tooltipHeight = 16;
|
|
202
|
+
const x = targetRect.left - viewportLeft + offsetWidth;
|
|
203
|
+
const y = targetRect.top - viewportTop - offsetHeight - tooltipHeight;
|
|
204
|
+
setTooltipHover({
|
|
205
|
+
x,
|
|
206
|
+
y,
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
const handleMouseOut = (e) => {
|
|
210
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
211
|
+
setTooltipHover({ x: 0, y: 0 });
|
|
212
|
+
};
|
|
213
|
+
const handleClickDetectUrl = (e) => {
|
|
214
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
215
|
+
setInitSelectedProperties(prev => {
|
|
216
|
+
var _a;
|
|
217
|
+
return (Object.assign(Object.assign({}, prev), { link: ((_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.textContent) || '', urlDetected: e === null || e === void 0 ? void 0 : e.currentTarget }));
|
|
218
|
+
});
|
|
219
|
+
toggleShortLinkModal();
|
|
220
|
+
};
|
|
221
|
+
if (!isViewMode) {
|
|
222
|
+
const elements = document.querySelectorAll('#ants-ui-input-personalization .detect-url');
|
|
223
|
+
listElement = Array.from(elements);
|
|
224
|
+
if (listElement.length) {
|
|
225
|
+
listElement.forEach((element) => {
|
|
226
|
+
element.addEventListener('mouseover', e => handleMouseOver(e, element.getBoundingClientRect()));
|
|
227
|
+
element.addEventListener('mouseout', handleMouseOut);
|
|
228
|
+
/** Open shortlink modal */
|
|
229
|
+
element.addEventListener('click', handleClickDetectUrl);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return () => {
|
|
234
|
+
listElement.forEach((element) => {
|
|
235
|
+
element.removeEventListener('mouseover', handleMouseOver);
|
|
236
|
+
element.removeEventListener('mouseout', handleMouseOut);
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
}, [textValue, isViewMode, setTooltipHover, toggleShortLinkModal]);
|
|
240
|
+
/** Style & remove for tag shortlink button & icon remove */
|
|
241
|
+
useLayoutEffect(() => {
|
|
242
|
+
// get button Els [x] to create hover and style it
|
|
243
|
+
const iconRemoveEls = document.querySelectorAll('.editor-icon-remove');
|
|
244
|
+
const listIconRemove = iconRemoveEls && Array.from(iconRemoveEls);
|
|
245
|
+
// get button elements
|
|
246
|
+
const buttonElement = document.querySelectorAll('.insert-word');
|
|
247
|
+
const listBtnElement = buttonElement && Array.from(buttonElement);
|
|
248
|
+
const handleRemoveTag = (e) => {
|
|
249
|
+
var _a, _b, _c, _d, _e;
|
|
250
|
+
if (e && ((_a = e.target) === null || _a === void 0 ? void 0 : _a.nodeName) === 'EM' && ((_b = e.target) === null || _b === void 0 ? void 0 : _b.className) === 'editor-icon-remove') {
|
|
251
|
+
e.stopPropagation();
|
|
252
|
+
(_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.remove();
|
|
253
|
+
setTextValue(personalizationInputRef && ((_e = personalizationInputRef.current) === null || _e === void 0 ? void 0 : _e.innerHTML));
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
listIconRemove.forEach(eachIcon => {
|
|
257
|
+
eachIcon.addEventListener('click', handleRemoveTag);
|
|
258
|
+
});
|
|
259
|
+
handleUpdateInputPersonalization(listIconRemove, listBtnElement);
|
|
260
|
+
return () => {
|
|
261
|
+
listIconRemove.forEach(eachIcon => {
|
|
262
|
+
eachIcon.removeEventListener('click', handleRemoveTag);
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
}, [textValue]);
|
|
266
|
+
useLayoutEffect(() => {
|
|
267
|
+
try {
|
|
268
|
+
// save caret position
|
|
269
|
+
if (!personalizationInputRef.current) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
// Perhaps React (whose VDOM gets outdated because we often prevent
|
|
273
|
+
// rerendering) did not update the DOM. So we update it manually now.
|
|
274
|
+
if (caretPositionRef && caretPositionRef.current) {
|
|
275
|
+
CaretPositioning.restoreSelection(personalizationInputRef.current, caretPositionRef.current);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (typeof addMessageToQueue === 'function') {
|
|
280
|
+
addMessageToQueue({
|
|
281
|
+
path: PATH,
|
|
282
|
+
func: 'useLayoutEffect',
|
|
283
|
+
data: error,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (typeof onError === 'function') {
|
|
287
|
+
onError(error, {
|
|
288
|
+
component: PATH,
|
|
289
|
+
action: 'useLayoutEffect saved caret position',
|
|
290
|
+
args: {},
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}, [addMessageToQueue, onError, textValue]);
|
|
295
|
+
return (React.createElement(WrapperInputStyle, { id: "ants-ui-input-personalization" },
|
|
296
|
+
React.createElement("div", { className: classnames({
|
|
297
|
+
'input-wrapper-outter': true,
|
|
298
|
+
'styles-input-wrapper': !isViewMode,
|
|
299
|
+
'input-error': (errors === null || errors === void 0 ? void 0 : errors.length) && (errors === null || errors === void 0 ? void 0 : errors.length) > 0,
|
|
300
|
+
}), style: Object.assign(Object.assign({}, (isViewMode && {
|
|
301
|
+
padding: 0,
|
|
302
|
+
minHeight: 0,
|
|
303
|
+
fontSize: 12,
|
|
304
|
+
border: 'none',
|
|
305
|
+
})), { width: '100%' }), onClick: () => { var _a; return (_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } },
|
|
306
|
+
React.createElement("div", { className: "input-personal", style: {
|
|
307
|
+
display: textValue && textValue !== '<br>' ? 'inline-block' : undefined,
|
|
308
|
+
}, contentEditable: !isViewMode, onBlur: onTriggerChange, onKeyPress: handleKeyPress, ref: personalizationInputRef,
|
|
309
|
+
// eslint-disable-next-line react/no-danger
|
|
310
|
+
dangerouslySetInnerHTML: {
|
|
311
|
+
__html: getDangerouslySetInnerHTML(textValue),
|
|
312
|
+
}, onPaste: onPaste }),
|
|
313
|
+
!isViewMode && (React.createElement(Icon, { type: "icon-ants-person-alt", onClick: e => {
|
|
314
|
+
e.stopPropagation();
|
|
315
|
+
toggleShortLinkModal();
|
|
316
|
+
}, className: "customize-antsomi-profile", style: { width: 24, height: 24 } }))),
|
|
317
|
+
React.createElement(TooltipHover, { isShow: tooltipHoverDebounce.x > 0 && tooltipHoverDebounce.y > 0, top: tooltipHoverDebounce.y, left: tooltipHoverDebounce.x }, "Click on the link to convert it to a shortlink"),
|
|
318
|
+
popoverOpenShortLink && (React.createElement(PopupShortLink, { open: popoverOpenShortLink, disabledOpts: disabledOpts, onOk: handleInsertSortLink, onClose: toggleShortLinkModal, initSelectedProperties: initSelectedProperties, callback: callback }))));
|
|
319
|
+
};
|
|
320
|
+
InputDynamic.defaultProps = defaultProps;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import type { SelectedPropertiesProps } from './InputDynamic';
|
|
3
|
+
type PopupShortLinkProps = {
|
|
4
|
+
open: any;
|
|
5
|
+
onClose: Function;
|
|
6
|
+
onOk: Function;
|
|
7
|
+
disabledOpts?: DisableShortLinkTypeProps;
|
|
8
|
+
initSelectedProperties: SelectedPropertiesProps;
|
|
9
|
+
callback: Function;
|
|
10
|
+
};
|
|
11
|
+
export type ShortLinkType = 'individual' | 'general';
|
|
12
|
+
export type DisableShortLinkTypeProps = {
|
|
13
|
+
[key in ShortLinkType]?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const PopupShortLink: FC<PopupShortLinkProps>;
|
|
16
|
+
export {};
|