@antscorp/antsomi-ui 2.0.86-text-editor-beta.5 → 2.0.86
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 -4
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
- package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +3 -13
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
- package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
- package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
- package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
- package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
- package/es/components/molecules/index.d.ts +0 -1
- package/es/components/molecules/index.js +0 -1
- package/es/components/organism/index.d.ts +0 -1
- package/es/components/organism/index.js +0 -1
- package/es/components/template/Layout/constants/permission.d.ts +1 -0
- package/es/components/template/Layout/constants/permission.js +1 -1
- package/es/hooks/index.d.ts +0 -1
- package/es/hooks/index.js +0 -1
- package/es/utils/common.d.ts +9 -6
- package/es/utils/common.js +23 -44
- package/es/utils/index.d.ts +0 -1
- package/es/utils/index.js +0 -1
- package/es/utils/web.d.ts +0 -4
- package/es/utils/web.js +0 -25
- package/package.json +3 -29
- package/es/components/index.scss +0 -2
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -128
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -20
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -17
- package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/constants.js +0 -5
- package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/index.js +0 -1
- package/es/components/molecules/FontSizeInput/styled.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/styled.js +0 -22
- package/es/components/molecules/FontSizeInput/styles.scss +0 -15
- package/es/components/molecules/FontSizeInput/types.d.ts +0 -24
- package/es/components/molecules/FontSizeInput/types.js +0 -1
- package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/utils.js +0 -9
- package/es/components/molecules/index.scss +0 -1
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
- package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
- package/es/components/organism/TextEditor/TextEditor.js +0 -251
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
- package/es/components/organism/TextEditor/constants.d.ts +0 -135
- package/es/components/organism/TextEditor/constants.js +0 -280
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -130
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -247
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
- package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Color.js +0 -41
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
- package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -43
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -32
- package/es/components/organism/TextEditor/extensions/FontSize.js +0 -47
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
- package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
- package/es/components/organism/TextEditor/extensions/Highlight.d.ts +0 -1
- package/es/components/organism/TextEditor/extensions/Highlight.js +0 -14
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -28
- package/es/components/organism/TextEditor/extensions/Indent.js +0 -68
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
- package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
- package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/Link.js +0 -50
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
- package/es/components/organism/TextEditor/extensions/Selection.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Selection.js +0 -40
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
- package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -31
- package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -37
- package/es/components/organism/TextEditor/hooks/index.d.ts +0 -7
- package/es/components/organism/TextEditor/hooks/index.js +0 -7
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +0 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.js +0 -6
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
- package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
- package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
- package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
- package/es/components/organism/TextEditor/index.d.ts +0 -14
- package/es/components/organism/TextEditor/index.js +0 -6
- package/es/components/organism/TextEditor/index.scss +0 -61
- package/es/components/organism/TextEditor/provider.d.ts +0 -12
- package/es/components/organism/TextEditor/provider.js +0 -34
- package/es/components/organism/TextEditor/store.d.ts +0 -13
- package/es/components/organism/TextEditor/store.js +0 -20
- package/es/components/organism/TextEditor/styled.d.ts +0 -8
- package/es/components/organism/TextEditor/styled.js +0 -90
- package/es/components/organism/TextEditor/types.d.ts +0 -92
- package/es/components/organism/TextEditor/types.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -43
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -132
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -20
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
- package/es/components/organism/TextEditor/utils/documentState.js +0 -100
- package/es/components/organism/TextEditor/utils/font.d.ts +0 -84
- package/es/components/organism/TextEditor/utils/font.js +0 -175
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -319
- package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
- package/es/components/organism/TextEditor/utils/index.js +0 -16
- package/es/components/organism/TextEditor/utils/link.d.ts +0 -100
- package/es/components/organism/TextEditor/utils/link.js +0 -149
- package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
- package/es/components/organism/TextEditor/utils/menu.js +0 -317
- package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
- package/es/components/organism/TextEditor/utils/selection.js +0 -57
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
- package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
- package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
- package/es/components/organism/TextEditor/utils/style.js +0 -193
- package/es/components/organism/index.scss +0 -1
- package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
- package/es/hooks/useBroadcastedLocalStorage.js +0 -71
- package/es/hooks/useElementSize.d.ts +0 -7
- package/es/hooks/useElementSize.js +0 -56
- package/es/utils/tree.d.ts +0 -225
- package/es/utils/tree.js +0 -469
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
-
import { ItemType } from './types';
|
|
3
|
-
|
|
4
|
-
export declare const itemToTreeNode: (item: ItemType) => any;
|
|
5
|
-
export declare const serializeItems: (args: {
|
|
2
|
+
import { ItemType, SerializedItemType } from './types';
|
|
3
|
+
export declare const getFlattenItems: (args: {
|
|
6
4
|
items: ItemType[];
|
|
7
|
-
}) =>
|
|
5
|
+
}) => SerializedItemType[];
|
|
8
6
|
export declare const CLS: {
|
|
9
7
|
readonly Root: {
|
|
10
8
|
readonly default: string;
|
|
@@ -29,8 +27,7 @@ export declare const CLS: {
|
|
|
29
27
|
readonly disabled: string;
|
|
30
28
|
readonly selected: string;
|
|
31
29
|
readonly expanded: string;
|
|
32
|
-
readonly selectedDescendant: string;
|
|
33
30
|
};
|
|
34
31
|
};
|
|
35
|
-
export declare const getItemSize: ((itemSize
|
|
36
|
-
export declare const calInlineListSize: (itemLength: number, itemSize
|
|
32
|
+
export declare const getItemSize: ((itemSize: number, itemSpacing: number) => (index: number) => number) & import("lodash").MemoizedFunction;
|
|
33
|
+
export declare const calInlineListSize: (itemLength: number, itemSize: number, itemSpacing: number) => number;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { antsomiClsx } from '@antscorp/antsomi-ui/es/utils';
|
|
2
|
-
import { COMPONENT_NAME,
|
|
2
|
+
import { COMPONENT_NAME, MODE } from './config';
|
|
3
3
|
import { memoize } from 'lodash';
|
|
4
|
-
|
|
5
|
-
export const itemToTreeNode = (item) => ({
|
|
6
|
-
id: item.key,
|
|
7
|
-
data: item,
|
|
8
|
-
children: item.children?.map(itemToTreeNode),
|
|
9
|
-
});
|
|
10
|
-
export const serializeItems = (args) => {
|
|
4
|
+
export const getFlattenItems = (args) => {
|
|
11
5
|
const { items } = args;
|
|
12
|
-
const
|
|
13
|
-
|
|
6
|
+
const result = [];
|
|
7
|
+
function recursively(items, level, pathKey, parent) {
|
|
8
|
+
items.forEach((item, idx) => {
|
|
9
|
+
const currentPathKey = [...pathKey, idx, item.key.toString()];
|
|
10
|
+
result.push({ ...item, level, pathKey: currentPathKey, parent });
|
|
11
|
+
if (item.children && item.children.length > 0) {
|
|
12
|
+
recursively(item.children, level + 1, currentPathKey, item);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (items.length) {
|
|
17
|
+
recursively(items, 1, [], null);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
14
20
|
};
|
|
15
21
|
const componentCls = antsomiClsx(COMPONENT_NAME);
|
|
16
22
|
export const CLS = {
|
|
@@ -37,16 +43,15 @@ export const CLS = {
|
|
|
37
43
|
disabled: componentCls('item-disabled'),
|
|
38
44
|
selected: componentCls('item-selected'),
|
|
39
45
|
expanded: componentCls('item-expanded'),
|
|
40
|
-
selectedDescendant: componentCls('item-selected-descendant'),
|
|
41
46
|
},
|
|
42
47
|
};
|
|
43
|
-
export const getItemSize = memoize((itemSize
|
|
48
|
+
export const getItemSize = memoize((itemSize, itemSpacing) => (index) => {
|
|
44
49
|
if (index === 0) {
|
|
45
50
|
return itemSize;
|
|
46
51
|
}
|
|
47
52
|
return itemSize + itemSpacing;
|
|
48
53
|
});
|
|
49
|
-
export const calInlineListSize = (itemLength, itemSize
|
|
54
|
+
export const calInlineListSize = (itemLength, itemSize, itemSpacing) => {
|
|
50
55
|
let result = 0;
|
|
51
56
|
const calItemSize = getItemSize(itemSize, itemSpacing);
|
|
52
57
|
for (let i = 0; i < itemLength; i++) {
|
|
@@ -67,7 +67,6 @@ export * from './EmojiCollections';
|
|
|
67
67
|
export * from './EmojiPopover';
|
|
68
68
|
export * from './DisplayFormat';
|
|
69
69
|
export * from './CodeStructure';
|
|
70
|
-
export * from './FontSizeInput';
|
|
71
70
|
export { EditorScript } from './EditorScript';
|
|
72
71
|
export { EditorTab } from './EditorTab';
|
|
73
72
|
export { SelectAccount } from './SelectAccount';
|
|
@@ -67,7 +67,6 @@ export * from './EmojiCollections';
|
|
|
67
67
|
export * from './EmojiPopover';
|
|
68
68
|
export * from './DisplayFormat';
|
|
69
69
|
export * from './CodeStructure';
|
|
70
|
-
export * from './FontSizeInput';
|
|
71
70
|
export { EditorScript } from './EditorScript';
|
|
72
71
|
export { EditorTab } from './EditorTab';
|
|
73
72
|
export { SelectAccount } from './SelectAccount';
|
|
@@ -15,5 +15,4 @@ export { AccountProfile, type AccountSettingProps } from './AccountProfile';
|
|
|
15
15
|
export * from './Login';
|
|
16
16
|
export * from './Filter';
|
|
17
17
|
export { ActivityTimeline, type ActivityTimeLineProps } from './ActivityTimeline';
|
|
18
|
-
export { TextEditor, TextEditorProvider, type TextEditorProps, type TextEditorRef, type TextEditorJSONContent, } from './TextEditor';
|
|
19
18
|
export { WhatsappMobile, SAMPLE_PREVIEW } from './PreviewCollections';
|
|
@@ -15,5 +15,4 @@ export { AccountProfile } from './AccountProfile';
|
|
|
15
15
|
export * from './Login';
|
|
16
16
|
export * from './Filter';
|
|
17
17
|
export { ActivityTimeline } from './ActivityTimeline';
|
|
18
|
-
export { TextEditor, TextEditorProvider, } from './TextEditor';
|
|
19
18
|
export { WhatsappMobile, SAMPLE_PREVIEW } from './PreviewCollections';
|
|
@@ -16,6 +16,7 @@ export declare const MARKETING_CHANNEL_CODE: {
|
|
|
16
16
|
export declare const MENU_PERMISSIONS: {
|
|
17
17
|
DF_DATA_SOURCE: string;
|
|
18
18
|
DESTINATION: string;
|
|
19
|
+
WEB_PERSONALIZE: string;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* In the dev environment, menu items will be removed the hash from menu_item_path,
|
|
@@ -17,7 +17,7 @@ export const MENU_PERMISSIONS = {
|
|
|
17
17
|
DF_DATA_SOURCE: 'DF_DATA_SOURCE',
|
|
18
18
|
DESTINATION: 'DESTINATION',
|
|
19
19
|
// REPORT: 'REPORT',
|
|
20
|
-
|
|
20
|
+
WEB_PERSONALIZE: 'WEB_PERSONALIZE',
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* In the dev environment, menu items will be removed the hash from menu_item_path,
|
package/es/hooks/index.d.ts
CHANGED
package/es/hooks/index.js
CHANGED
package/es/utils/common.d.ts
CHANGED
|
@@ -66,14 +66,17 @@ export declare const searchParamsToObject: (searchParams?: string) => Record<str
|
|
|
66
66
|
export declare const getShuffleArray: <T>(array: T[]) => T[];
|
|
67
67
|
export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any> | Record<string, any>[], recursive?: boolean) => T;
|
|
68
68
|
export declare const camelCaseToSnakeCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
|
|
69
|
-
export declare function generateKey():
|
|
69
|
+
export declare function generateKey(): any;
|
|
70
70
|
export declare const formatUserId: (userId?: number) => string;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
* Function to remove accent
|
|
73
|
+
* @param str - String want to remove accent
|
|
74
|
+
* @returns {string} - Result after remove accent
|
|
75
|
+
*/
|
|
76
|
+
export declare const removeAccent: (str: string) => string;
|
|
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
|
+
/**
|
|
77
80
|
* @param str target string
|
|
78
81
|
* @param queryStr search query
|
|
79
82
|
* @returns true if target string includes search query
|
package/es/utils/common.js
CHANGED
|
@@ -430,56 +430,35 @@ 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
|
-
*
|
|
436
|
-
* 3. Removing all whitespace.
|
|
437
|
-
* @param str The string to normalize.
|
|
438
|
-
* @returns The normalized string.
|
|
433
|
+
* Function to remove accent
|
|
434
|
+
* @param str - String want to remove accent
|
|
435
|
+
* @returns {string} - Result after remove accent
|
|
439
436
|
*/
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
437
|
+
export const removeAccent = (str) => {
|
|
438
|
+
str = str.replace(/[àáạảãâầấậẩẫăằắặẳẵ]/g, 'a');
|
|
439
|
+
str = str.replace(/[èéẹẻẽêềếệểễ]/g, 'e');
|
|
440
|
+
str = str.replace(/[ìíịỉĩ]/g, 'i');
|
|
441
|
+
str = str.replace(/[òóọỏõôồốộổỗơờớợởỡ]/g, 'o');
|
|
442
|
+
str = str.replace(/[ùúụủũưừứựửữ]/g, 'u');
|
|
443
|
+
str = str.replace(/[ỳýỵỷỹ]/g, 'y');
|
|
444
|
+
str = str.replace(/đ/g, 'd');
|
|
445
|
+
str = str.replace(/[ÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴ]/g, 'A');
|
|
446
|
+
str = str.replace(/[ÈÉẸẺẼÊỀẾỆỂỄ]/g, 'E');
|
|
447
|
+
str = str.replace(/[ÌÍỊỈĨ]/g, 'I');
|
|
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()) || '';
|
|
450
456
|
/**
|
|
451
|
-
* Checks string matching based on a query, supporting fuzzy matching,
|
|
452
|
-
* where the query characters must appear in order within the target string.
|
|
453
|
-
* Allows for missing characters in the query relative to the target,
|
|
454
|
-
* and ignores case, diacritics, and spaces.
|
|
455
|
-
*
|
|
456
457
|
* @param str target string
|
|
457
458
|
* @param queryStr search query
|
|
458
459
|
* @returns true if target string includes search query
|
|
459
460
|
*/
|
|
460
|
-
export const searchStringQuery = (str, queryStr) =>
|
|
461
|
-
const normalizedQuery = normalizeStringForSearch(queryStr);
|
|
462
|
-
const normalizedItem = normalizeStringForSearch(str);
|
|
463
|
-
// Optimization: if normalized query is longer than normalized item,
|
|
464
|
-
// it cannot be a subsequence.
|
|
465
|
-
if (normalizedQuery.length > normalizedItem.length) {
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
// Subsequence check:
|
|
469
|
-
// Iterate through both normalized strings.
|
|
470
|
-
// If characters match, advance the query pointer.
|
|
471
|
-
// Always advance the item pointer.
|
|
472
|
-
let queryIndex = 0;
|
|
473
|
-
let itemIndex = 0;
|
|
474
|
-
while (queryIndex < normalizedQuery.length && itemIndex < normalizedItem.length) {
|
|
475
|
-
if (normalizedQuery[queryIndex] === normalizedItem[itemIndex]) {
|
|
476
|
-
queryIndex++;
|
|
477
|
-
}
|
|
478
|
-
itemIndex++;
|
|
479
|
-
}
|
|
480
|
-
// If queryIndex reached the end of normalizedQuery, all its characters were found in order.
|
|
481
|
-
return queryIndex === normalizedQuery.length;
|
|
482
|
-
};
|
|
461
|
+
export const searchStringQuery = (str, queryStr) => simplifyString(str).includes(simplifyString(queryStr || ''));
|
|
483
462
|
/**
|
|
484
463
|
* Checks if any of the provided values match the search value.
|
|
485
464
|
*
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
package/es/utils/web.d.ts
CHANGED
|
@@ -8,7 +8,3 @@ export declare const getPreventKeyboardAction: (actions?: Array<'undo' | 'copy'
|
|
|
8
8
|
onKeyDown: (e: React.KeyboardEvent | KeyboardEvent) => false | undefined;
|
|
9
9
|
onKeyUp: (e: React.KeyboardEvent | KeyboardEvent) => void;
|
|
10
10
|
};
|
|
11
|
-
export declare const getPlatform: () => "mac" | "window" | "linux" | "unknown";
|
|
12
|
-
export declare const isMacOS: () => boolean;
|
|
13
|
-
export declare const isWindows: () => boolean;
|
|
14
|
-
export declare const isLinux: () => boolean;
|
package/es/utils/web.js
CHANGED
|
@@ -24,28 +24,3 @@ export const getPreventKeyboardAction = (actions = []) => ({
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
|
-
export const getPlatform = () => {
|
|
28
|
-
// Modern API (userAgentData)
|
|
29
|
-
const navAny = navigator;
|
|
30
|
-
if (navAny.userAgentData && typeof navAny.userAgentData.platform === 'string') {
|
|
31
|
-
const platform = navAny.userAgentData.platform.toLowerCase();
|
|
32
|
-
if (platform.includes('mac'))
|
|
33
|
-
return 'mac';
|
|
34
|
-
if (platform.includes('win'))
|
|
35
|
-
return 'window';
|
|
36
|
-
if (platform.includes('linux') || platform.includes('x11'))
|
|
37
|
-
return 'linux';
|
|
38
|
-
}
|
|
39
|
-
// Fallback for older browsers
|
|
40
|
-
const ua = navigator.userAgent.toLowerCase();
|
|
41
|
-
if (ua.includes('mac'))
|
|
42
|
-
return 'mac';
|
|
43
|
-
if (ua.includes('win'))
|
|
44
|
-
return 'window';
|
|
45
|
-
if (ua.includes('linux') || ua.includes('x11'))
|
|
46
|
-
return 'linux';
|
|
47
|
-
return 'unknown';
|
|
48
|
-
};
|
|
49
|
-
export const isMacOS = () => getPlatform() === 'mac';
|
|
50
|
-
export const isWindows = () => getPlatform() === 'window';
|
|
51
|
-
export const isLinux = () => getPlatform() === 'linux';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "2.0.86
|
|
3
|
+
"version": "2.0.86",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test:ui": "vitest --ui",
|
|
37
37
|
"coverage": "vitest run --coverage",
|
|
38
38
|
"ts-compile": "tsc -p tsconfig.esm.json",
|
|
39
|
-
"copy-files": "copyfiles -u 1
|
|
39
|
+
"copy-files": "copyfiles -u 1 src/**/*.json src/**/*.svg src/**/*.scss src/**/*.png es",
|
|
40
40
|
"icons:export": "sh -e scripts/generate-export-icon.sh",
|
|
41
41
|
"icons:format": "prettier --loglevel warn --write \"src/components/icons/*.tsx\"",
|
|
42
42
|
"icons:update": "sh -e scripts/update-icons.sh",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"@dnd-kit/sortable": "^8.0.0",
|
|
70
70
|
"@dnd-kit/utilities": "^3.2.2",
|
|
71
71
|
"@emotion/react": "^11.11.1",
|
|
72
|
-
"@floating-ui/react": "^0.27.8",
|
|
73
72
|
"@fortawesome/fontawesome-svg-core": "6.1.1",
|
|
74
73
|
"@fortawesome/free-brands-svg-icons": "6.1.1",
|
|
75
74
|
"@fortawesome/free-regular-svg-icons": "6.1.1",
|
|
@@ -79,26 +78,6 @@
|
|
|
79
78
|
"@tanstack/react-query": "4.20.4",
|
|
80
79
|
"@tanstack/react-query-devtools": "4.20.4",
|
|
81
80
|
"@tinymce/tinymce-react": "^3.7.0",
|
|
82
|
-
"@tiptap/core": "^2.12.0",
|
|
83
|
-
"@tiptap/extension-color": "^2.12.0",
|
|
84
|
-
"@tiptap/extension-font-family": "^2.12.0",
|
|
85
|
-
"@tiptap/extension-highlight": "^2.12.0",
|
|
86
|
-
"@tiptap/extension-image": "^2.12.0",
|
|
87
|
-
"@tiptap/extension-link": "^2.12.0",
|
|
88
|
-
"@tiptap/extension-list-item": "^2.12.0",
|
|
89
|
-
"@tiptap/extension-strike": "^2.12.0",
|
|
90
|
-
"@tiptap/extension-subscript": "^2.12.0",
|
|
91
|
-
"@tiptap/extension-superscript": "^2.12.0",
|
|
92
|
-
"@tiptap/extension-task-item": "^2.12.0",
|
|
93
|
-
"@tiptap/extension-task-list": "^2.12.0",
|
|
94
|
-
"@tiptap/extension-text-align": "^2.12.0",
|
|
95
|
-
"@tiptap/extension-text-style": "^2.12.0",
|
|
96
|
-
"@tiptap/extension-typography": "^2.12.0",
|
|
97
|
-
"@tiptap/extension-underline": "^2.12.0",
|
|
98
|
-
"@tiptap/pm": "^2.12.0",
|
|
99
|
-
"@tiptap/react": "^2.12.0",
|
|
100
|
-
"@tiptap/starter-kit": "^2.12.0",
|
|
101
|
-
"@tiptap/suggestion": "^2.12.0",
|
|
102
81
|
"@types/currency-formatter": "1.5.1",
|
|
103
82
|
"@types/react-custom-scrollbars": "^4.0.13",
|
|
104
83
|
"@types/react-frame-component": "^4.1.6",
|
|
@@ -129,7 +108,6 @@
|
|
|
129
108
|
"immer": "3.0.0",
|
|
130
109
|
"konva": "^9.3.6",
|
|
131
110
|
"lodash": "^4.17.21",
|
|
132
|
-
"lucide-react": "^0.510.0",
|
|
133
111
|
"moment": "2.29.2",
|
|
134
112
|
"pako": "2.0.4",
|
|
135
113
|
"qs": "6.10.3",
|
|
@@ -142,7 +120,6 @@
|
|
|
142
120
|
"react-custom-scrollbars": "^4.2.1",
|
|
143
121
|
"react-device-detect": "^2.2.3",
|
|
144
122
|
"react-draggable": "^4.4.5",
|
|
145
|
-
"react-fast-compare": "^3.2.1",
|
|
146
123
|
"react-frame-component": "^5.2.6",
|
|
147
124
|
"react-google-recaptcha": "^3.1.0",
|
|
148
125
|
"react-helmet": "^6.1.0",
|
|
@@ -159,11 +136,9 @@
|
|
|
159
136
|
"socket.io-client": "^4.7.5",
|
|
160
137
|
"string-replace-to-array": "^2.1.0",
|
|
161
138
|
"swiper": "^11.0.7",
|
|
162
|
-
"tinycolor2": "^1.6.0",
|
|
163
139
|
"tui-image-editor": "^3.15.3",
|
|
164
140
|
"uniqid": "^5.4.0",
|
|
165
141
|
"use-context-selector": "^1.4.4",
|
|
166
|
-
"use-debounce": "^10.0.4",
|
|
167
142
|
"use-image": "^1.1.1",
|
|
168
143
|
"use-immer": "^0.4.1",
|
|
169
144
|
"zustand": "^4.5.2"
|
|
@@ -212,8 +187,6 @@
|
|
|
212
187
|
"@types/react-resizable": "^3.0.7",
|
|
213
188
|
"@types/react-syntax-highlighter": "^15.5.11",
|
|
214
189
|
"@types/styled-components": "^5.1.26",
|
|
215
|
-
"@types/tinycolor2": "^1.4.6",
|
|
216
|
-
"@types/uniqid": "^5.3.4",
|
|
217
190
|
"@types/yaireo__tagify": "^4.27.0",
|
|
218
191
|
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
219
192
|
"@typescript-eslint/parser": "^5.55.0",
|
|
@@ -253,6 +226,7 @@
|
|
|
253
226
|
"prettier": "^3.3.3",
|
|
254
227
|
"react": "18.2.0",
|
|
255
228
|
"react-dom": "18.2.0",
|
|
229
|
+
"react-fast-compare": "^3.2.1",
|
|
256
230
|
"react-i18next": "11.16.7",
|
|
257
231
|
"react-router-dom": "5.1.0 || 6.14.2",
|
|
258
232
|
"sass": "^1.77.8",
|
package/es/components/index.scss
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useState, useImperativeHandle, useEffect, useRef, useMemo, } from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { useElementSize } from '@antscorp/antsomi-ui/es/hooks';
|
|
5
|
-
import { DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE_OPTIONS } from './constants';
|
|
6
|
-
import { CLS } from './utils';
|
|
7
|
-
import { FontSizeDropdown } from './components/FontSizeDropdown';
|
|
8
|
-
import { FontSizeControl } from './components/FontSizeControl';
|
|
9
|
-
const getFontSizeLabel = (value) => `${value} px`;
|
|
10
|
-
export const FontSizeInput = forwardRef((props, ref) => {
|
|
11
|
-
const { min = 1, max = 300, value: valueProp, defaultValue = DEFAULT_FONT_SIZE, options = DEFAULT_FONT_SIZE_OPTIONS, placeholder, style, className, disabled, dropdownProps, onFocus, onBlur, onChange = () => undefined, } = props;
|
|
12
|
-
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
13
|
-
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
14
|
-
const [popoverValue, setPopoverValue] = useState(null);
|
|
15
|
-
const [inputRef, { width: inputWidth }] = useElementSize();
|
|
16
|
-
const isControlled = valueProp !== undefined;
|
|
17
|
-
const value = isControlled ? +valueProp : +uncontrolledValue;
|
|
18
|
-
const popoverItemRefs = useRef(new Map());
|
|
19
|
-
const fontSizeOptions = useMemo(() => options.map(option => ({
|
|
20
|
-
size: option,
|
|
21
|
-
label: getFontSizeLabel(option),
|
|
22
|
-
className: clsx(CLS.PopoverListItem, {
|
|
23
|
-
[CLS.PopoverListItemSelected]: option === value,
|
|
24
|
-
}),
|
|
25
|
-
})), [options, value]);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!isPopoverOpen) {
|
|
28
|
-
setPopoverValue(null);
|
|
29
|
-
}
|
|
30
|
-
if (isPopoverOpen && popoverValue) {
|
|
31
|
-
popoverItemRefs.current.get(popoverValue)?.focus({
|
|
32
|
-
preventScroll: true,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}, [popoverValue, isPopoverOpen]);
|
|
36
|
-
const handleInputFocus = (event) => {
|
|
37
|
-
onFocus?.(value, event);
|
|
38
|
-
setIsPopoverOpen(true);
|
|
39
|
-
};
|
|
40
|
-
const handleInputBlur = (event) => {
|
|
41
|
-
onBlur?.(value, event);
|
|
42
|
-
if (!popoverValue) {
|
|
43
|
-
setIsPopoverOpen(false);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const handleValueChange = useCallback((newValue, info) => {
|
|
47
|
-
if (!isControlled) {
|
|
48
|
-
setUncontrolledValue(newValue);
|
|
49
|
-
}
|
|
50
|
-
onChange(newValue, info);
|
|
51
|
-
}, [isControlled, onChange]);
|
|
52
|
-
const handleKeyDown = useCallback((e) => {
|
|
53
|
-
const currentSize = popoverValue ?? value;
|
|
54
|
-
const currentFocusIndex = fontSizeOptions.findIndex(item => item.size === currentSize);
|
|
55
|
-
const firstFontSize = fontSizeOptions.at(0);
|
|
56
|
-
const lastFontSize = fontSizeOptions.at(-1);
|
|
57
|
-
switch (e.key) {
|
|
58
|
-
case 'Enter': {
|
|
59
|
-
inputRef.current?.blur();
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
case 'ArrowDown': {
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
if (currentFocusIndex !== -1) {
|
|
65
|
-
const nextFocusIndex = Math.min(fontSizeOptions.length - 1, currentFocusIndex + 1);
|
|
66
|
-
setPopoverValue(fontSizeOptions[nextFocusIndex].size);
|
|
67
|
-
}
|
|
68
|
-
else if (firstFontSize) {
|
|
69
|
-
setPopoverValue(firstFontSize.size);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
case 'ArrowUp': {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
if (currentFocusIndex !== -1) {
|
|
76
|
-
const nextFocusIndex = Math.max(0, currentFocusIndex - 1);
|
|
77
|
-
setPopoverValue(fontSizeOptions[nextFocusIndex].size);
|
|
78
|
-
}
|
|
79
|
-
else if (lastFontSize) {
|
|
80
|
-
setPopoverValue(lastFontSize.size);
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
default:
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}, [fontSizeOptions, inputRef, value, popoverValue]);
|
|
88
|
-
const handleClickPopoverItem = useCallback((size) => {
|
|
89
|
-
handleValueChange(size, { type: 'dropdown' });
|
|
90
|
-
setIsPopoverOpen(false);
|
|
91
|
-
inputRef.current?.blur();
|
|
92
|
-
}, [handleValueChange, inputRef]);
|
|
93
|
-
const handlePopoverItemKeydown = useCallback((e, size) => {
|
|
94
|
-
const currentFocusIndex = fontSizeOptions.findIndex(item => item.size === popoverValue);
|
|
95
|
-
switch (e.key) {
|
|
96
|
-
case 'Enter': {
|
|
97
|
-
handleClickPopoverItem(size);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case 'ArrowDown': {
|
|
101
|
-
const nextFocusIndex = Math.min(fontSizeOptions.length - 1, currentFocusIndex + 1);
|
|
102
|
-
setPopoverValue(fontSizeOptions[nextFocusIndex].size);
|
|
103
|
-
e.stopPropagation();
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case 'ArrowUp': {
|
|
107
|
-
const nextFocusIndex = Math.max(0, currentFocusIndex - 1);
|
|
108
|
-
setPopoverValue(fontSizeOptions[nextFocusIndex].size);
|
|
109
|
-
e.stopPropagation();
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
default:
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}, [fontSizeOptions, popoverValue, handleClickPopoverItem]);
|
|
116
|
-
useImperativeHandle(ref, () => ({
|
|
117
|
-
closeDropdown: () => setIsPopoverOpen(false),
|
|
118
|
-
}));
|
|
119
|
-
const content = (_jsx(FontSizeControl, { disabled: disabled, ref: inputRef, className: className, value: popoverValue ?? value, max: max, min: min, keyboard: false, defaultValue: defaultValue, style: style, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleKeyDown, onChange: newValue => {
|
|
120
|
-
if (newValue === null)
|
|
121
|
-
return;
|
|
122
|
-
handleValueChange(Number(newValue), { type: 'input' });
|
|
123
|
-
}, onIncrement: () => handleValueChange(value + 1, { type: 'input' }), onDecrement: () => handleValueChange(value - 1, { type: 'input' }) }));
|
|
124
|
-
if (options.length) {
|
|
125
|
-
return (_jsx(FontSizeDropdown, { isOpen: isPopoverOpen, options: fontSizeOptions, popoverValue: popoverValue, width: inputWidth, itemRefs: popoverItemRefs, onItemClick: handleClickPopoverItem, onItemKeyDown: handlePopoverItemKeydown, onClose: () => setIsPopoverOpen(false), getPopupContainer: () => dropdownProps?.getPopupContainer?.() || document.body, children: content }));
|
|
126
|
-
}
|
|
127
|
-
return content;
|
|
128
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { InputNumberProps } from 'antd';
|
|
3
|
-
interface FontSizeControlProps extends InputNumberProps {
|
|
4
|
-
onIncrement: () => void;
|
|
5
|
-
onDecrement: () => void;
|
|
6
|
-
}
|
|
7
|
-
export declare const FontSizeControl: import("react").ForwardRefExoticComponent<FontSizeControlProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, InputNumber } from 'antd';
|
|
3
|
-
import { MinusIcon, PlusIcon } from 'lucide-react';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
5
|
-
import { InputRoot } from '../styled';
|
|
6
|
-
import { CLS } from '../utils';
|
|
7
|
-
import clsx from 'clsx';
|
|
8
|
-
export const FontSizeControl = forwardRef(({ onIncrement, onDecrement, ...rest }, ref) => (_jsxs(InputRoot, { children: [_jsx(Button, { size: "small", type: "text", onClick: onDecrement, disabled: rest.disabled ||
|
|
9
|
-
typeof rest.value !== 'number' ||
|
|
10
|
-
typeof rest.min !== 'number' ||
|
|
11
|
-
rest.value <= rest.min, children: _jsx(MinusIcon, { size: 14 }) }), _jsx(InputNumber, { ref: ref, className: clsx(CLS.Input, rest.className), formatter: value => `${value} px`, parser: value => value?.replace(/[^\d]/g, ''), controls: false, ...rest }), _jsx(Button, { size: "small", type: "text", onClick: onIncrement, disabled: rest.disabled ||
|
|
12
|
-
typeof rest.value !== 'number' ||
|
|
13
|
-
typeof rest.max !== 'number' ||
|
|
14
|
-
rest.value >= rest.max, children: _jsx(PlusIcon, { size: 14 }) })] })));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
type FontSizeOption = {
|
|
3
|
-
size: number;
|
|
4
|
-
label: string;
|
|
5
|
-
className: string;
|
|
6
|
-
};
|
|
7
|
-
interface FontSizeDropdownProps {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
isOpen: boolean;
|
|
10
|
-
options: FontSizeOption[];
|
|
11
|
-
popoverValue: number | null;
|
|
12
|
-
width: number;
|
|
13
|
-
itemRefs: RefObject<Map<number, HTMLLIElement>>;
|
|
14
|
-
onItemClick: (size: number) => void;
|
|
15
|
-
onItemKeyDown: (e: React.KeyboardEvent, size: number) => void;
|
|
16
|
-
onClose: () => void;
|
|
17
|
-
getPopupContainer?: () => HTMLElement;
|
|
18
|
-
}
|
|
19
|
-
export declare const FontSizeDropdown: ({ children, isOpen, options, popoverValue, width, itemRefs, onItemClick, onItemKeyDown, onClose, getPopupContainer, }: FontSizeDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Popover } from 'antd';
|
|
3
|
-
import { StyledListFont, StyledListItemFont } from '../styled';
|
|
4
|
-
import { CLS } from '../utils';
|
|
5
|
-
export const FontSizeDropdown = ({ children, isOpen, options, popoverValue, width, itemRefs, onItemClick, onItemKeyDown, onClose, getPopupContainer, }) => {
|
|
6
|
-
const content = (_jsx(StyledListFont, { role: "list", className: CLS.PopoverList, style: { width: `${width}px` }, onMouseDown: e => e.preventDefault(), children: options.map((i, idx) => {
|
|
7
|
-
const isFocused = i.size === popoverValue;
|
|
8
|
-
return (_jsx(StyledListItemFont, { ref: el => {
|
|
9
|
-
if (!el || !itemRefs.current)
|
|
10
|
-
return;
|
|
11
|
-
itemRefs.current.set(i.size, el);
|
|
12
|
-
}, role: "listitem", className: i.className, "aria-posinset": idx + 1, "aria-setsize": options.length, tabIndex: isFocused ? 0 : -1, onClick: () => onItemClick(i.size), onKeyDown: e => onItemKeyDown(e, i.size), ...(isFocused && {
|
|
13
|
-
onBlur: onClose,
|
|
14
|
-
}), children: i.label }));
|
|
15
|
-
}) }));
|
|
16
|
-
return (_jsx(Popover, { arrow: false, open: isOpen, overlayClassName: CLS.Popover, content: content, getPopupContainer: getPopupContainer, children: children }));
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FontSizeInput';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const StyledListFont: import("styled-components").StyledComponent<"ul", any, {}, never>;
|
|
2
|
-
export declare const StyledListItemFont: import("styled-components").StyledComponent<"li", any, {}, never>;
|
|
3
|
-
export declare const InputRoot: import("styled-components").StyledComponent<"div", any, {}, never>;
|