@antscorp/antsomi-ui 1.3.7-beta.6 → 1.3.7-beta.61
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/components/atoms/Input/Input.js +3 -1
- package/es/components/atoms/InputDynamic/InputDynamic.js +3 -3
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +2 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +2 -0
- package/es/components/icons/QRCodeManagementIcon.d.ts +3 -0
- package/es/components/icons/QRCodeManagementIcon.js +7 -0
- package/es/components/icons/QRSetDashboardIcon.d.ts +3 -0
- package/es/components/icons/QRSetDashboardIcon.js +7 -0
- package/es/components/icons/index.d.ts +2 -0
- package/es/components/icons/index.js +2 -0
- package/es/components/molecules/AddDynamicContent/AddDynamicContent.js +28 -2
- package/es/components/molecules/AddDynamicContent/constants.d.ts +2 -0
- package/es/components/molecules/AddDynamicContent/constants.js +2 -0
- package/es/components/molecules/ColorPicker/index.d.ts +2 -0
- package/es/components/molecules/ColorPicker/index.js +8 -3
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +2 -2
- package/es/components/molecules/EmojiPopover/styled.d.ts +2 -2
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/HeaderV2/HeaderV2.d.ts +1 -1
- package/es/components/molecules/Modal/Modal.js +7 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +2 -2
- package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
- package/es/components/molecules/SearchPopover/styled.js +1 -2
- package/es/components/molecules/SearchPopover/types.d.ts +4 -3
- package/es/components/molecules/Select/Select.js +1 -1
- package/es/components/molecules/ShareAccess/ShareAccess.d.ts +2 -1
- package/es/components/molecules/ShareAccess/ShareAccess.js +12 -9
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +5 -5
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +2 -2
- package/es/components/molecules/ShareAccess/hooks/useShareAccess.d.ts +2 -1
- package/es/components/molecules/ShareAccess/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/reducer.d.ts +1 -1
- package/es/components/molecules/ShareAccess/reducer.js +7 -4
- package/es/components/molecules/ShareAccess/types.d.ts +22 -0
- package/es/components/molecules/ShareAccess/utils.d.ts +3 -1
- package/es/components/molecules/ShareAccess/utils.js +35 -2
- package/es/components/molecules/TagifyInput/TagifyInput.js +48 -27
- package/es/components/molecules/TagifyInput/types.d.ts +14 -8
- package/es/components/molecules/TagifyInput/utils.d.ts +6 -1
- package/es/components/molecules/TagifyInput/utils.js +19 -0
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +3 -7
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -327
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
- package/es/components/molecules/VirtualizedMenu/styled.js +14 -3
- package/es/components/molecules/VirtualizedMenu/types.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/utils.js +1 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.d.ts +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.js +11 -4
- package/es/components/organism/AccountSharing/styled.js +1 -1
- package/es/components/organism/ActivityTimeline/ActivityTimeline.js +3 -3
- package/es/components/organism/ActivityTimeline/constants.d.ts +9 -9
- package/es/components/organism/ActivityTimeline/constants.js +3 -3
- package/es/components/organism/ActivityTimeline/index.d.ts +530 -1
- package/es/components/organism/ActivityTimeline/index.js +9 -1
- package/es/components/organism/ActivityTimeline/utils.js +175 -8
- package/es/components/organism/LeftMenu/LeftMenu.js +3 -3
- package/es/components/organism/LeftMenu/hooks/usePermission.js +1 -1
- package/es/components/organism/LeftMenu/types/index.d.ts +7 -0
- package/es/components/organism/LeftMenu/utils/index.js +1 -1
- package/es/components/organism/Login/Login.js +12 -3
- package/es/components/organism/Login/components/SignIn/SignIn.js +2 -2
- package/es/components/organism/Login/types/index.d.ts +2 -0
- package/es/components/organism/TextEditor/TextEditor.d.ts +9 -2
- package/es/components/organism/TextEditor/TextEditor.js +203 -42
- package/es/components/organism/TextEditor/constants.d.ts +9 -0
- package/es/components/organism/TextEditor/constants.js +66 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +6 -128
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +7 -292
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +1 -1
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +4 -0
- package/es/components/organism/TextEditor/extensions/Link.js +33 -14
- package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
- package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +5 -6
- package/es/components/organism/TextEditor/extensions/SmartTag.js +96 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.js +7 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +2 -1
- package/es/components/organism/TextEditor/index.d.ts +7 -5
- package/es/components/organism/TextEditor/index.scss +4 -7
- package/es/components/organism/TextEditor/provider.d.ts +1 -0
- package/es/components/organism/TextEditor/provider.js +6 -3
- package/es/components/organism/TextEditor/store.d.ts +11 -4
- package/es/components/organism/TextEditor/store.js +22 -2
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
- package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
- package/es/components/organism/TextEditor/stories/shared.js +57 -0
- package/es/components/organism/TextEditor/styled.d.ts +1 -1
- package/es/components/organism/TextEditor/styled.js +1 -0
- package/es/components/organism/TextEditor/types.d.ts +161 -11
- package/es/components/organism/TextEditor/types.js +1 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +2 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +80 -51
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +1 -1
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +1 -1
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +2 -2
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +12 -2
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +1 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +1 -3
- package/es/components/organism/TextEditor/ui/Toolbar/{Toolbar.d.ts → FormattingToolbar.d.ts} +3 -4
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +90 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +4 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +2 -2
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +6 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +14 -0
- package/es/components/organism/TextEditor/utils/documentState.js +25 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +60 -0
- package/es/components/organism/TextEditor/utils/link.d.ts +10 -1
- package/es/components/organism/TextEditor/utils/link.js +161 -7
- package/es/components/organism/TextEditor/utils/menu.js +2 -1
- package/es/components/organism/TextEditor/utils/selection.js +3 -2
- package/es/components/organism/TextEditor/utils/smartTag.js +2 -1
- package/es/components/organism/index.d.ts +1 -1
- package/es/hooks/index.d.ts +1 -1
- package/es/hooks/index.js +1 -1
- package/es/providers/ConfigProvider/ConfigProvider.d.ts +4 -0
- package/es/providers/ConfigProvider/ConfigProvider.js +2 -3
- package/es/providers/ConfigProvider/GlobalStyle.d.ts +2 -2
- package/es/providers/ConfigProvider/GlobalStyle.js +67 -64
- package/es/services/MediaTemplateDesign/UploadFile/index.js +4 -4
- package/es/utils/common.d.ts +1 -1
- package/es/utils/common.js +3 -3
- package/es/utils/cookie.js +2 -1
- package/package.json +18 -23
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -39
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MENU_PERMISSION, PEOPLE_ACTIONS, PEOPLE_ACTION_KEYS, PUBLIC_ROLE, REGEX_REMOVE_NAME, ROLE_ACCESS_LABEL, ROLE_MAPPING, } from './constants';
|
|
2
|
-
import { remove } from 'lodash';
|
|
2
|
+
import { remove, mapKeys, camelCase, snakeCase } from 'lodash';
|
|
3
3
|
import { snakeCaseToCamelCase } from '@antscorp/antsomi-ui/es/utils';
|
|
4
4
|
export const mergePermission = (objectPermissionAllow, menuPermissionValue) => {
|
|
5
5
|
const valueMapping = {
|
|
@@ -87,9 +87,42 @@ export const safeParseAccessInfo = (accessInfo) => {
|
|
|
87
87
|
return {
|
|
88
88
|
...accessInfo,
|
|
89
89
|
ownerId: +(ownerId || -1),
|
|
90
|
-
listAccess: accessInfo?.listAccess?.map(user => ({
|
|
90
|
+
listAccess: accessInfo?.listAccess?.map(user => ({
|
|
91
|
+
...user,
|
|
92
|
+
userId: +user.userId,
|
|
93
|
+
role: +user.role,
|
|
94
|
+
allowView: +user.allowView,
|
|
95
|
+
allowEdit: +user.allowEdit,
|
|
96
|
+
allowComment: +user.allowComment,
|
|
97
|
+
})),
|
|
91
98
|
};
|
|
92
99
|
};
|
|
100
|
+
export const fromRaw = (raw) => ({
|
|
101
|
+
isPublic: raw.is_public,
|
|
102
|
+
publicRole: raw.public_role,
|
|
103
|
+
ownerId: raw.owner_id ?? -1,
|
|
104
|
+
listAccess: raw.list_access.map(u => ({
|
|
105
|
+
...mapKeys(u, (_v, key) => camelCase(key)),
|
|
106
|
+
userId: u.user_id,
|
|
107
|
+
role: u.role,
|
|
108
|
+
allowView: u.allow_view,
|
|
109
|
+
allowEdit: u.allow_edit,
|
|
110
|
+
allowComment: u.allow_comment,
|
|
111
|
+
})),
|
|
112
|
+
});
|
|
113
|
+
export const toRaw = (info) => ({
|
|
114
|
+
is_public: info.isPublic,
|
|
115
|
+
public_role: info.publicRole,
|
|
116
|
+
owner_id: info.ownerId,
|
|
117
|
+
list_access: info.listAccess.map(u => ({
|
|
118
|
+
...mapKeys(u, (_v, key) => snakeCase(key)),
|
|
119
|
+
user_id: u.userId,
|
|
120
|
+
role: u.role,
|
|
121
|
+
allow_view: u.allowView,
|
|
122
|
+
allow_edit: u.allowEdit,
|
|
123
|
+
allow_comment: u.allowComment,
|
|
124
|
+
})),
|
|
125
|
+
});
|
|
93
126
|
export const mappingOutData = (shareAccess) => {
|
|
94
127
|
const result = { ...shareAccess };
|
|
95
128
|
result.listAccess = result.listAccess.map(accessInfo => {
|
|
@@ -17,7 +17,7 @@ import '@yaireo/tagify/dist/tagify.css';
|
|
|
17
17
|
// Styled
|
|
18
18
|
import { TagTextArea, TagifyWrapper, WrapperPlaceHolder } from './styled';
|
|
19
19
|
// Utils
|
|
20
|
-
import { parseTagStringToTagify, convertInputStringToOriginal, emojiManufacturer, getEmojiTag, isPersonalizeTagType, generateTagContent, unescapeString, hasLineBreak, selectRange, isTagClickable, findURLInTextNodes, getAttributesString, isAnchorNodeChildOfElement, isShortLinkTagType, isCustomTagType, sanitizeTagAttributes, getTagAttributes, applyTagAttributes, getTagContentAttributes, isCaretAtEndOfTextNodeWithNextTag, getCurrentSelectionAndCloneRange, handleEnterWithNextTag, handleTextNodeBackspace, } from './utils';
|
|
20
|
+
import { parseTagStringToTagify, convertInputStringToOriginal, emojiManufacturer, getEmojiTag, isPersonalizeTagType, generateTagContent, unescapeString, hasLineBreak, selectRange, isTagClickable, findURLInTextNodes, getAttributesString, isAnchorNodeChildOfElement, isShortLinkTagType, isCustomTagType, sanitizeTagAttributes, getTagAttributes, applyTagAttributes, getTagContentAttributes, isCaretAtEndOfTextNodeWithNextTag, getCurrentSelectionAndCloneRange, handleEnterWithNextTag, handleTextNodeBackspace, extractTagValues, preventUndoRedo, } from './utils';
|
|
21
21
|
import { acceptablePatternChecking, detectURLRegex, getCachedRegex, getCustomTagId, getPersonalizeTagInfo, getShortLinkTagInfo, patternHandlers, } from './patternHandlers';
|
|
22
22
|
// Constants
|
|
23
23
|
import { DETECT_LINK, EMOJI, PERSONALIZE_PTN, SHORT_LINK, SHORT_LINK_PTN, SHORT_LINK_V2, TAG_TYPE, UNSUBSCRIBE_WHATSAPP, defaultCssVariables, tagifyDefaultProps, TAG_CUSTOM_ATTRIBUTES, } from './constants';
|
|
@@ -25,7 +25,7 @@ const { CUSTOM_TAG } = TAG_TYPE;
|
|
|
25
25
|
const { PREPARING_ST, INVALID_TAG, MESSAGE_TAG, FORCE_SHOW_TOOLTIP } = TAG_CUSTOM_ATTRIBUTES;
|
|
26
26
|
const TagifyInput = forwardRef((props, ref) => {
|
|
27
27
|
// Props
|
|
28
|
-
const { initialValue, escapeHTML, status, readonly, readonlyTag, readonlyText,
|
|
28
|
+
const { initialValue, escapeHTML, status, readonly, readonlyTag, readonlyText, realtime, disabled, maxLength, maxHeight, minWidth, placeholder, minWidthPlaceholder, isSingleLineText, acceptableTagPattern, tagProperties, mapAttributes = {}, mapErrorAttributes = {}, maxPersonalizeTags, name, children, cssTagifyVariables, disableEditableIfContainsTags, onTagClick, onAddTag, onTagRemove, onChange, onRestoreTagProperty, onBlur, } = props;
|
|
29
29
|
// States
|
|
30
30
|
const [isLineBreak, setIsLineBreak] = useState(hasLineBreak(initialValue));
|
|
31
31
|
const [tooltipRefresher, setTooltipRefresher] = useState(1);
|
|
@@ -456,6 +456,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
456
456
|
}
|
|
457
457
|
setLabelTagRefreshness(prev => prev + 1);
|
|
458
458
|
},
|
|
459
|
+
getInputValues: () => extractTagValues(tagifyRef.current),
|
|
459
460
|
}), [acceptableTagPattern, escapeHTML, onInjectTagAtCaret, placeCaretAfterNode]);
|
|
460
461
|
const onTagItemClick = useCallback((event) => {
|
|
461
462
|
event.stopPropagation();
|
|
@@ -471,7 +472,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
471
472
|
}, [onTagClick]);
|
|
472
473
|
const onTagifyRemoveTag = useCallback((event) => {
|
|
473
474
|
if (event.detail && onTagRemove) {
|
|
474
|
-
onTagRemove(event.detail);
|
|
475
|
+
onTagRemove(event.detail, extractTagValues(event.detail.tagify));
|
|
475
476
|
}
|
|
476
477
|
}, [onTagRemove]);
|
|
477
478
|
// Used to trigger replace URL detection and line break
|
|
@@ -767,27 +768,6 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
767
768
|
});
|
|
768
769
|
}
|
|
769
770
|
}, [maxLength, customizeTag]);
|
|
770
|
-
useEffect(() => {
|
|
771
|
-
if (!tagifyRef.current)
|
|
772
|
-
return;
|
|
773
|
-
// Skip if neither readonlyText nor readonlyWhenNotEmpty is defined
|
|
774
|
-
if (typeof readonlyText === 'undefined' && !readonlyWhenNotEmpty)
|
|
775
|
-
return;
|
|
776
|
-
const inputEl = tagifyRef.current.DOM.input;
|
|
777
|
-
// readonlyWhenNotEmpty takes priority if both are set
|
|
778
|
-
if (readonlyWhenNotEmpty) {
|
|
779
|
-
const cleanValue = tagifyRef.current.getInputValue();
|
|
780
|
-
const hasContent = cleanValue.length > 0;
|
|
781
|
-
inputEl.setAttribute('contenteditable', hasContent ? 'false' : 'true');
|
|
782
|
-
}
|
|
783
|
-
else if (typeof readonlyText === 'function') {
|
|
784
|
-
const isReadonlyText = readonlyText(tagifyRef.current.getCleanValue());
|
|
785
|
-
inputEl.setAttribute('contenteditable', isReadonlyText ? 'false' : 'true');
|
|
786
|
-
}
|
|
787
|
-
else if (typeof readonlyText !== 'undefined') {
|
|
788
|
-
inputEl.setAttribute('contenteditable', readonlyText ? 'false' : 'true');
|
|
789
|
-
}
|
|
790
|
-
}, [readonlyText, readonlyWhenNotEmpty, tagLength]);
|
|
791
771
|
const onTagifyWrapperClick = useCallback(event => {
|
|
792
772
|
event.preventDefault();
|
|
793
773
|
event.stopPropagation();
|
|
@@ -799,6 +779,22 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
799
779
|
return;
|
|
800
780
|
const { classList } = DOM?.scope;
|
|
801
781
|
const { classNames } = settings;
|
|
782
|
+
if (disableEditableIfContainsTags) {
|
|
783
|
+
// Empty input is always editable
|
|
784
|
+
const isEmpty = classList.contains(classNames.empty);
|
|
785
|
+
let shouldBeEditable = isEmpty;
|
|
786
|
+
// If not empty, check if input contains restricted tags
|
|
787
|
+
if (!isEmpty) {
|
|
788
|
+
const { listTags } = extractTagValues(tagifyRef.current);
|
|
789
|
+
const hasRestrictedTag = listTags.some(tag => disableEditableIfContainsTags.includes(tag.type));
|
|
790
|
+
shouldBeEditable = !hasRestrictedTag;
|
|
791
|
+
}
|
|
792
|
+
// Apply contenteditable attribute
|
|
793
|
+
DOM.input.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
|
|
794
|
+
// Exit early if input should not be editable
|
|
795
|
+
if (!shouldBeEditable)
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
802
798
|
if (!classList.contains(classNames.focus) && DOM?.input) {
|
|
803
799
|
try {
|
|
804
800
|
const { lastChild } = DOM?.input;
|
|
@@ -834,6 +830,12 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
834
830
|
}
|
|
835
831
|
}
|
|
836
832
|
}
|
|
833
|
+
}, [disableEditableIfContainsTags]);
|
|
834
|
+
const onContentEditable = useCallback((editable) => {
|
|
835
|
+
if (!tagifyRef.current)
|
|
836
|
+
return;
|
|
837
|
+
const inputEl = tagifyRef.current.DOM.input;
|
|
838
|
+
inputEl.setAttribute('contenteditable', editable ? 'true' : 'false');
|
|
837
839
|
}, []);
|
|
838
840
|
// Initialization tagify
|
|
839
841
|
useLayoutEffect(() => {
|
|
@@ -845,7 +847,12 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
845
847
|
};
|
|
846
848
|
}, [initializeTagify]);
|
|
847
849
|
useEffect(() => {
|
|
848
|
-
if (
|
|
850
|
+
if (typeof readonlyText !== 'boolean')
|
|
851
|
+
return;
|
|
852
|
+
onContentEditable(!readonlyText);
|
|
853
|
+
}, [readonlyText, onContentEditable]);
|
|
854
|
+
useEffect(() => {
|
|
855
|
+
if (tagifyRef.current && typeof tagLength === 'number' && _.isFunction(onTagRemove)) {
|
|
849
856
|
// Because the remove tag event is not triggered when the tag is removed with Backspace or drag selection tags
|
|
850
857
|
// we need to listen to the input element to detect when a tag is removed
|
|
851
858
|
let mutationQueue = [];
|
|
@@ -874,8 +881,11 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
874
881
|
try {
|
|
875
882
|
node.dataset.__removed_by_mutation = 'true';
|
|
876
883
|
const tagData = tagifyRef.current?.getSetTagData(node);
|
|
877
|
-
if (
|
|
878
|
-
|
|
884
|
+
if (tagifyRef.current &&
|
|
885
|
+
tagData &&
|
|
886
|
+
tagData.type === CUSTOM_TAG &&
|
|
887
|
+
!tagData?.__removed) {
|
|
888
|
+
onTagRemove({ data: tagData }, extractTagValues(tagifyRef.current));
|
|
879
889
|
}
|
|
880
890
|
}
|
|
881
891
|
catch (error) {
|
|
@@ -987,8 +997,13 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
987
997
|
tagifyInstance.on('change', onTagifyChangedDebounce);
|
|
988
998
|
tagifyInstance.on('remove', onTagifyRemoveTag);
|
|
989
999
|
tagifyInstance.on('keydown', onKeyDown);
|
|
1000
|
+
if (onAddTag)
|
|
1001
|
+
tagifyInstance.on('add', onAddTag);
|
|
990
1002
|
if (onBlur)
|
|
991
1003
|
tagifyInstance.on('blur', onBlur);
|
|
1004
|
+
if (tagifyInstance.DOM.input) {
|
|
1005
|
+
tagifyInstance.DOM.input.addEventListener('keydown', preventUndoRedo);
|
|
1006
|
+
}
|
|
992
1007
|
}
|
|
993
1008
|
// Off listen to Tagify events
|
|
994
1009
|
return () => {
|
|
@@ -998,11 +1013,17 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
998
1013
|
tagifyInstance.off('change', onTagifyChangedDebounce);
|
|
999
1014
|
tagifyInstance.off('remove', onTagifyRemoveTag);
|
|
1000
1015
|
tagifyInstance.off('keydown', onKeyDown);
|
|
1016
|
+
if (onAddTag)
|
|
1017
|
+
tagifyInstance.off('add', onAddTag);
|
|
1001
1018
|
if (onBlur)
|
|
1002
1019
|
tagifyInstance.off('blur', onBlur);
|
|
1020
|
+
if (tagifyInstance.DOM.input) {
|
|
1021
|
+
tagifyInstance.DOM.input.removeEventListener('keydown', preventUndoRedo);
|
|
1022
|
+
}
|
|
1003
1023
|
}
|
|
1004
1024
|
};
|
|
1005
1025
|
}, [
|
|
1026
|
+
onAddTag,
|
|
1006
1027
|
onBlur,
|
|
1007
1028
|
onTagItemClick,
|
|
1008
1029
|
onInputTagifyDebounce,
|
|
@@ -15,6 +15,10 @@ export type TagStatus = (typeof TAG_STATUS)[keyof typeof TAG_STATUS];
|
|
|
15
15
|
export type MapAttributesProps = Record<string, Record<string, any>>;
|
|
16
16
|
export type StatusType = 'error' | 'success' | 'warning';
|
|
17
17
|
export type BackgroundColorPersonalizeType = Exclude<keyof typeof TAG_COLOR, 'detect_link' | 'emoji' | 'shortlink'>;
|
|
18
|
+
export interface TagValues {
|
|
19
|
+
listTags: TagDataCustomize[];
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* Interface defining the properties for the Tagify input component.
|
|
20
24
|
* Provides configuration options and event handlers to manage Tagify's behavior and appearance.
|
|
@@ -134,11 +138,16 @@ export interface TagifyInputProps {
|
|
|
134
138
|
* Receives the tag detail as parameter, allowing custom actions on tag click.
|
|
135
139
|
*/
|
|
136
140
|
onTagClick?: (tagDetail: Tagify.ClickEventData<TagDataCustomize>) => void;
|
|
141
|
+
/**
|
|
142
|
+
* Event handler triggered when a tag is added.
|
|
143
|
+
* Receives the tag detail as parameter, allowing custom actions on tag addition.
|
|
144
|
+
*/
|
|
145
|
+
onAddTag?: (event: CustomEvent<Tagify.AddEventData<TagDataCustomize>>) => void;
|
|
137
146
|
/**
|
|
138
147
|
* Event handler triggered when a tag is removed.
|
|
139
148
|
* Receives the tag detail as parameter, allowing custom actions on tag removal.
|
|
140
149
|
*/
|
|
141
|
-
onTagRemove?: (tagDetail: Tagify.RemoveEventData<TagDataCustomize
|
|
150
|
+
onTagRemove?: (tagDetail: Tagify.RemoveEventData<TagDataCustomize>, values: TagValues) => void;
|
|
142
151
|
/**
|
|
143
152
|
* Event handler triggered when the input value changes.
|
|
144
153
|
* Receives the updated input value as a string, allowing for controlled component updates.
|
|
@@ -159,21 +168,18 @@ export interface TagifyInputProps {
|
|
|
159
168
|
/**
|
|
160
169
|
* Defines whether the input text is read but not the whole tags.
|
|
161
170
|
*/
|
|
162
|
-
readonlyText?: boolean
|
|
171
|
+
readonlyText?: boolean;
|
|
163
172
|
/**
|
|
164
|
-
*
|
|
165
|
-
* when the input is not empty (has tags or content).
|
|
166
|
-
* This is a convenience prop that internally uses readonlyText callback.
|
|
167
|
-
*
|
|
168
|
-
* @default false
|
|
173
|
+
* Tags that, when present in input, make the entire input non-editable
|
|
169
174
|
*/
|
|
170
|
-
|
|
175
|
+
disableEditableIfContainsTags?: TagType[];
|
|
171
176
|
}
|
|
172
177
|
export interface TagifyInputRef {
|
|
173
178
|
onAddNewTag: (newTag: TagDataCustomize | string) => void;
|
|
174
179
|
onReplaceTag: (currentTagEle: HTMLElement, newTag: TagDataCustomize) => void;
|
|
175
180
|
onReload: (newValue: string) => void;
|
|
176
181
|
onLabelTagRefreshness: () => void;
|
|
182
|
+
getInputValues: () => TagValues;
|
|
177
183
|
}
|
|
178
184
|
export type EmojiCollection = (typeof EMOJI_COLLECTIONS)[keyof typeof EMOJI_COLLECTIONS];
|
|
179
185
|
export type ShortLinkType = (typeof SHORT_LINK_TYPE)[keyof typeof SHORT_LINK_TYPE];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="yaireo__tagify" />
|
|
2
2
|
import Tagify from '@yaireo/tagify';
|
|
3
|
-
import { AcceptablePattern, TagAttribute, EmojiCollection, EmojiTag, TagDataCustomize, TagProperty, TagType } from './types';
|
|
3
|
+
import { AcceptablePattern, TagAttribute, EmojiCollection, EmojiTag, TagDataCustomize, TagProperty, TagType, TagValues } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Parses the input string and replaces matching patterns with processed tags.
|
|
6
6
|
* This function iterates over predefined regex patterns and replaces each match
|
|
@@ -202,3 +202,8 @@ export declare const getCurrentSelectionAndCloneRange: () => {
|
|
|
202
202
|
};
|
|
203
203
|
export declare const handleTextNodeBackspace: (range: Range) => void;
|
|
204
204
|
export declare const handleEnterWithNextTag: (range: Range) => void;
|
|
205
|
+
export declare const removeInvisibleChars: (str: string) => string;
|
|
206
|
+
export declare const extractTagValues: (tagify: Tagify<TagDataCustomize>) => TagValues;
|
|
207
|
+
export declare function preventUndoRedo(e: CustomEvent<Tagify.KeydownEventData<TagDataCustomize>>['detail']['event'], { disableRedo }?: {
|
|
208
|
+
disableRedo?: boolean | undefined;
|
|
209
|
+
}): void;
|
|
@@ -796,3 +796,22 @@ export const handleEnterWithNextTag = (range) => {
|
|
|
796
796
|
return;
|
|
797
797
|
insertZeroWidthSpaceBeforeTag(currentNode);
|
|
798
798
|
};
|
|
799
|
+
export const removeInvisibleChars = (str) => str.replace(/[\r\n\u200B-\u200D\uFEFF]/g, '');
|
|
800
|
+
export const extractTagValues = (tagify) => {
|
|
801
|
+
if (!tagify)
|
|
802
|
+
return { listTags: [], value: '' };
|
|
803
|
+
return {
|
|
804
|
+
listTags: tagify.getCleanValue(),
|
|
805
|
+
value: tagify.getInputValue(),
|
|
806
|
+
};
|
|
807
|
+
};
|
|
808
|
+
export function preventUndoRedo(e, { disableRedo = false } = {}) {
|
|
809
|
+
const key = e.key.toLowerCase();
|
|
810
|
+
const isUndo = (e.ctrlKey || e.metaKey) && key === 'z';
|
|
811
|
+
const isRedo = (disableRedo && (e.ctrlKey || e.metaKey) && key === 'y') ||
|
|
812
|
+
((e.ctrlKey || e.metaKey) && e.shiftKey && key === 'z');
|
|
813
|
+
if (isUndo || isRedo) {
|
|
814
|
+
e.preventDefault();
|
|
815
|
+
e.stopPropagation();
|
|
816
|
+
}
|
|
817
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo, useRef,
|
|
2
|
+
import { memo, useMemo, useRef, useCallback } from 'react';
|
|
3
3
|
import { Typography } from '../../../../atoms/Typography';
|
|
4
4
|
import { MenuItemRoot } from '../../styled';
|
|
5
5
|
import clsx from 'clsx';
|
|
@@ -69,11 +69,7 @@ export const Item = memo((props) => {
|
|
|
69
69
|
}, [item.id, normalizeTreeItems, selectedKeys]);
|
|
70
70
|
const className = clsx(itemClassName, {
|
|
71
71
|
[CLS.Item.selectedDescendant]: isSelectedDescendant,
|
|
72
|
+
[CLS.Item.focused]: isFocused,
|
|
72
73
|
});
|
|
73
|
-
|
|
74
|
-
if (isFocused) {
|
|
75
|
-
itemRef.current?.focus({ preventScroll: true });
|
|
76
|
-
}
|
|
77
|
-
}, [isFocused]);
|
|
78
|
-
return (_jsxs(MenuItemRoot, { ref: handleItemRef, role: displayOnly ? 'none' : 'treeitem', tabIndex: displayOnly ? -1 : isFocused ? 0 : -1, "aria-selected": displayOnly ? undefined : selected, "aria-disabled": displayOnly ? undefined : disabled, "aria-expanded": displayOnly ? undefined : expanded, "aria-level": displayOnly ? undefined : item.level, "aria-posinset": displayOnly ? undefined : index + 1, "aria-setsize": displayOnly ? undefined : items.length, className: className, style: itemStyle, onClick: e => handleOnClick(e, 'item'), children: [_jsx("div", { className: CLS.ItemLabel.default, children: labelContent }), actionContent] }));
|
|
74
|
+
return (_jsxs(MenuItemRoot, { "data-selected": !!selected, "data-focused": isFocused, ref: handleItemRef, role: displayOnly ? 'none' : 'treeitem', "aria-selected": displayOnly ? undefined : selected, "aria-disabled": displayOnly ? undefined : disabled, "aria-expanded": displayOnly ? undefined : expanded, "aria-level": displayOnly ? undefined : item.level, "aria-posinset": displayOnly ? undefined : index + 1, "aria-setsize": displayOnly ? undefined : items.length, className: className, style: itemStyle, onClick: e => handleOnClick(e, 'item'), children: [_jsx("div", { className: CLS.ItemLabel.default, children: labelContent }), actionContent] }));
|
|
79
75
|
}, areEqual);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
items: ItemType[];
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const MenuInline: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Partial<{
|
|
3
|
+
items: import("../../types").ItemType[];
|
|
5
4
|
inlineIndent: number;
|
|
6
5
|
inlinePadding: number;
|
|
7
6
|
itemSpacing: number;
|
|
@@ -9,15 +8,16 @@ export declare const MenuInline: React.MemoExoticComponent<React.ForwardRefExoti
|
|
|
9
8
|
className: string;
|
|
10
9
|
itemSize: number;
|
|
11
10
|
selected: string | string[];
|
|
11
|
+
focusedKey: string;
|
|
12
12
|
expanded: string[];
|
|
13
13
|
onClick: (args: {
|
|
14
|
-
item: ItemType;
|
|
15
|
-
domEvent?:
|
|
14
|
+
item: import("../../types").ItemType;
|
|
15
|
+
domEvent?: import("react").MouseEvent<Element, MouseEvent> | undefined;
|
|
16
16
|
elKey: "item" | "item-expand-el";
|
|
17
17
|
}) => void;
|
|
18
|
-
action:
|
|
19
|
-
expandEl:
|
|
20
|
-
}) =>
|
|
18
|
+
action: import("react").ReactNode | ((item: import("../../types").ItemType, others: {
|
|
19
|
+
expandEl: import("react").ReactNode;
|
|
20
|
+
}) => import("react").ReactNode);
|
|
21
21
|
}> & {
|
|
22
22
|
mode?: "inline" | undefined;
|
|
23
|
-
} &
|
|
23
|
+
} & import("react").RefAttributes<import("../../types").VirtualizedMenuBaseHandle>>>;
|