dtable-ui-component 7.0.13 → 7.0.15
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/lib/ActionSheet/index.js +58 -49
- package/lib/ActivityIndicator/index.js +17 -16
- package/lib/AsyncUserSelect/index.js +20 -46
- package/lib/AsyncUserSelect/user-item.js +6 -5
- package/lib/AutoNumberFormatter/index.js +4 -3
- package/lib/Badge/index.js +27 -29
- package/lib/ButtonFormatter/index.js +8 -6
- package/lib/CTimeFormatter/index.js +4 -3
- package/lib/CheckboxEditor/index.js +16 -13
- package/lib/CheckboxEditor/mb-editor.js +20 -9
- package/lib/CheckboxEditor/pc-editor.js +24 -12
- package/lib/CheckboxFormatter/index.js +5 -4
- package/lib/CollaboratorEditor/index.js +17 -14
- package/lib/CollaboratorEditor/mb-editor/index.js +19 -11
- package/lib/CollaboratorEditor/pc-editor/index.js +35 -26
- package/lib/CollaboratorFormatter/index.js +10 -8
- package/lib/CollaboratorItem/index.js +5 -4
- package/lib/CollapsibleSettingLayout/index.js +8 -10
- package/lib/Comment/body/comment.js +19 -11
- package/lib/Comment/body/index.js +8 -8
- package/lib/Comment/footer/btns/index.js +7 -4
- package/lib/Comment/footer/index.js +21 -10
- package/lib/Comment/footer/input/index.js +55 -34
- package/lib/Comment/footer/input/participant/index.js +6 -5
- package/lib/Comment/footer/participants/index.js +5 -4
- package/lib/Comment/footer/participants/participant/index.js +3 -1
- package/lib/Comment/footer/participants/participant-select/index.js +26 -10
- package/lib/Comment/index.js +57 -39
- package/lib/Comment/utils/utilities.js +22 -16
- package/lib/CreatorFormatter/index.js +8 -6
- package/lib/DTableColorPicker/ColorPickerPortal/index.js +26 -28
- package/lib/DTableColorPicker/index.js +53 -67
- package/lib/DTableColorPicker/utils.js +7 -5
- package/lib/DTableColumnIcon/index.js +7 -6
- package/lib/DTableCommonAddTool/index.js +10 -8
- package/lib/DTableCustomFooter/index.js +3 -1
- package/lib/DTableCustomizeSearchInput/index.js +41 -26
- package/lib/DTableCustomizeSelect/index.js +24 -19
- package/lib/DTableDropdownItem/index.js +28 -24
- package/lib/DTableDropdownMenu/index.js +17 -14
- package/lib/DTableEmptyTip/index.js +5 -4
- package/lib/DTableFiltersPopover/index.js +42 -27
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +3 -1
- package/lib/DTableFiltersPopover/utils/index.js +114 -64
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +9 -8
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +13 -16
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +15 -18
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +14 -8
- package/lib/DTableFiltersPopover/widgets/filter-group.js +57 -36
- package/lib/DTableFiltersPopover/widgets/filter-item.js +165 -106
- package/lib/DTableFiltersPopover/widgets/filter-list/index.js +162 -137
- package/lib/DTableFiltersPopover/widgets/rate-item.js +25 -20
- package/lib/DTableIcon/index.js +11 -10
- package/lib/DTableIcon/svg-icon.js +11 -9
- package/lib/DTableModalHeader/index.js +7 -7
- package/lib/DTablePopover/index.js +16 -12
- package/lib/DTableRadio/index.js +9 -10
- package/lib/DTableRadioGroup/index.js +20 -11
- package/lib/DTableSearchInput/index.js +29 -19
- package/lib/DTableSelect/dtable-select-label.js +6 -7
- package/lib/DTableSelect/index.js +26 -25
- package/lib/DTableSelect/select-dropdown-indicator/index.js +3 -1
- package/lib/DTableSelect/utils.js +83 -47
- package/lib/DTableSubDropdownMenu/index.js +16 -12
- package/lib/DTableSubDropdownToggle/index.js +16 -17
- package/lib/DTableSwitch/index.js +11 -12
- package/lib/DTableToolTip/index.js +12 -11
- package/lib/DateEditor/index.js +28 -30
- package/lib/DateEditor/mb-editor/index.js +31 -18
- package/lib/DateEditor/pc-editor.js +46 -27
- package/lib/DateFormatter/index.js +5 -4
- package/lib/DatePicker/index.js +15 -9
- package/lib/DatePicker/utils.js +7 -5
- package/lib/DeleteTip/index.js +6 -5
- package/lib/DepartmentMultipleSelectEditor/index.js +26 -28
- package/lib/DepartmentSelectFilter/index.js +13 -8
- package/lib/DepartmentSingleSelectEditor/index.js +16 -13
- package/lib/DepartmentSingleSelectEditor/mb-editor/index.js +49 -50
- package/lib/DepartmentSingleSelectEditor/pc-editor/department-single-select.js +64 -42
- package/lib/DepartmentSingleSelectEditor/pc-editor/index.js +19 -13
- package/lib/DepartmentSingleSelectFormatter/index.js +6 -4
- package/lib/DigitalSignEditor/index.js +16 -13
- package/lib/DigitalSignEditor/mb-editor/index.js +24 -16
- package/lib/DigitalSignEditor/pc-editor/index.js +31 -23
- package/lib/DigitalSignEditor/service.js +5 -3
- package/lib/DigitalSignEditor/signature-board/index.js +10 -7
- package/lib/DigitalSignEditor/utils.js +4 -2
- package/lib/DigitalSignFormatter/index.js +15 -12
- package/lib/DigitalSignFormatter/utils.js +6 -5
- package/lib/Drawer/index.js +3 -2
- package/lib/DurationEditor/index.js +31 -21
- package/lib/DurationFormatter/index.js +5 -4
- package/lib/EditEditorButton/index.js +3 -1
- package/lib/EmailFormatter/index.js +4 -3
- package/lib/FieldDisplaySetting/field-item.js +13 -13
- package/lib/FieldDisplaySetting/index.js +20 -20
- package/lib/FileEditor/files-previewer/index.js +16 -13
- package/lib/FileEditor/files-previewer/mb-previewer/file-previewer/index.js +20 -12
- package/lib/FileEditor/files-previewer/mb-previewer/index.js +8 -7
- package/lib/FileEditor/files-previewer/pc-previewer/file-previewer/dropdown-menu.js +4 -3
- package/lib/FileEditor/files-previewer/pc-previewer/file-previewer/file-name-editor/index.js +6 -5
- package/lib/FileEditor/files-previewer/pc-previewer/file-previewer/index.js +24 -17
- package/lib/FileEditor/files-previewer/pc-previewer/index.js +57 -29
- package/lib/FileEditor/index.js +16 -13
- package/lib/FileEditor/mb-editor/index.js +20 -28
- package/lib/FileEditor/pc-editor/addition-previewer/index.js +4 -2
- package/lib/FileEditor/pc-editor/addition-previewer/local-file-addition/index.js +31 -17
- package/lib/FileEditor/pc-editor/index.js +30 -22
- package/lib/FileFormatter/index.js +20 -27
- package/lib/FileItemFormatter/index.js +10 -7
- package/lib/FileUploader/index.js +46 -29
- package/lib/FormulaFormatter/index.js +44 -24
- package/lib/GeolocationEditor/index.js +32 -27
- package/lib/GeolocationEditor/map-editor-utils.js +23 -21
- package/lib/GeolocationEditor/mb-editor/country-editor.js +14 -17
- package/lib/GeolocationEditor/mb-editor/index.js +28 -22
- package/lib/GeolocationEditor/mb-editor/location-editor.js +15 -18
- package/lib/GeolocationEditor/mb-editor/map-editor/index.js +77 -47
- package/lib/GeolocationEditor/mb-editor/map-selection-editor/index.js +89 -50
- package/lib/GeolocationEditor/mb-editor/province-city-editor.js +14 -17
- package/lib/GeolocationEditor/mb-editor/province-editor.js +14 -17
- package/lib/GeolocationEditor/pc-editor/country-editor.js +25 -12
- package/lib/GeolocationEditor/pc-editor/index.js +41 -27
- package/lib/GeolocationEditor/pc-editor/location-editor.js +33 -28
- package/lib/GeolocationEditor/pc-editor/map-editor/index.js +67 -43
- package/lib/GeolocationEditor/pc-editor/map-editor/large-editor/index.js +69 -42
- package/lib/GeolocationEditor/pc-editor/map-selection-editor/index.js +86 -42
- package/lib/GeolocationEditor/pc-editor/map-selection-editor/large-editor/index.js +85 -39
- package/lib/GeolocationEditor/pc-editor/province-city-editor.js +26 -20
- package/lib/GeolocationEditor/pc-editor/province-editor.js +15 -8
- package/lib/GeolocationEditor/pc-editor/selector-header-item.js +6 -5
- package/lib/GeolocationEditor/pc-editor/selector-list.js +8 -7
- package/lib/GeolocationFormatter/index.js +5 -4
- package/lib/HtmlLongTextFormatter/index.js +13 -5
- package/lib/Icon/index.js +13 -15
- package/lib/Icon/load-sprite.js +13 -2
- package/lib/IconButton/index.js +12 -13
- package/lib/ImageEditor/images-previewer/image-preview/index.js +22 -13
- package/lib/ImageEditor/images-previewer/index.js +9 -3
- package/lib/ImageEditor/index.js +16 -13
- package/lib/ImageEditor/mb-editor/index.js +20 -28
- package/lib/ImageEditor/pc-editor/addition-previewer/image-link/index.js +6 -2
- package/lib/ImageEditor/pc-editor/addition-previewer/index.js +5 -3
- package/lib/ImageEditor/pc-editor/addition-previewer/local-image-addition/index.js +26 -12
- package/lib/ImageEditor/pc-editor/images-previewer/index.js +10 -4
- package/lib/ImageEditor/pc-editor/index.js +16 -11
- package/lib/ImageFormatter/images-lazy-load.js +11 -19
- package/lib/ImageFormatter/index.js +14 -12
- package/lib/ImagePreviewerLightbox/index.js +15 -19
- package/lib/ImageThumbnail/index.js +15 -12
- package/lib/InputItem/custom-input.js +55 -35
- package/lib/InputItem/custom-keyboard.js +42 -42
- package/lib/InputItem/index.js +82 -63
- package/lib/InputItem/input.js +9 -11
- package/lib/LastModifierFormatter/index.js +8 -6
- package/lib/LinkEditor/index.js +53 -33
- package/lib/LinkEditor/link-editor-option.js +4 -3
- package/lib/LinkEditor/mb-popover/index.js +22 -9
- package/lib/LinkEditor/pc-popover/index.js +13 -7
- package/lib/LinkFormatter/index.js +37 -21
- package/lib/List/index.js +17 -19
- package/lib/List/list-item.js +59 -55
- package/lib/LongTextFormatter/index.js +5 -4
- package/lib/MBEditorHeader/index.js +9 -8
- package/lib/MTimeFormatter/index.js +4 -3
- package/lib/MobileFullScreenPage/body/index.js +6 -4
- package/lib/MobileFullScreenPage/header/index.js +10 -8
- package/lib/MobileFullScreenPage/index.js +12 -14
- package/lib/MobileModal/index.js +7 -8
- package/lib/MobileOperationSheet/index.js +8 -7
- package/lib/MobileSelector/empty/index.js +3 -1
- package/lib/MobileSelector/index.js +7 -5
- package/lib/MobileSelector/option/index.js +5 -3
- package/lib/MobileSelector/options/index.css +0 -4
- package/lib/MobileSelector/options/index.js +3 -1
- package/lib/MobileSelector/search/index.js +5 -3
- package/lib/MobileUpload/index.js +5 -4
- package/lib/Modal/alert.js +2 -2
- package/lib/Modal/modal.js +28 -30
- package/lib/Modal/prompt.js +14 -14
- package/lib/MultipleSelectEditor/index.js +7 -7
- package/lib/MultipleSelectFormatter/index.js +9 -7
- package/lib/NotificationPopover/index.js +5 -4
- package/lib/NumberEditor/index.js +21 -12
- package/lib/NumberFormatter/index.js +5 -4
- package/lib/PhoneNumberLink/index.js +5 -3
- package/lib/Picker/AbstractPicker.js +35 -33
- package/lib/Popover/index.js +9 -11
- package/lib/Popover/item.js +22 -24
- package/lib/Progress/index.js +18 -17
- package/lib/Radio/Radio.js +17 -15
- package/lib/Radio/RadioItem.js +23 -19
- package/lib/RateFormatter/index.js +15 -15
- package/lib/RoleStatusEditor/index.js +18 -19
- package/lib/RowExpand/index.js +7 -6
- package/lib/RowExpandDialog/body/index.js +57 -40
- package/lib/RowExpandDialog/column-content/index.js +10 -6
- package/lib/RowExpandDialog/header/index.js +12 -9
- package/lib/RowExpandDialog/index.js +59 -63
- package/lib/RowExpandEditor/add-btn/index.js +7 -6
- package/lib/RowExpandEditor/checkbox-editor/index.js +7 -6
- package/lib/RowExpandEditor/checkbox-editor/mb-editor/index.js +5 -4
- package/lib/RowExpandEditor/checkbox-editor/pc-editor.js +10 -8
- package/lib/RowExpandEditor/collaborator-editor/index.js +7 -6
- package/lib/RowExpandEditor/collaborator-editor/mb-editor/index.js +33 -22
- package/lib/RowExpandEditor/collaborator-editor/pc-editor/index.js +40 -26
- package/lib/RowExpandEditor/date-editor/index.js +7 -6
- package/lib/RowExpandEditor/date-editor/mb-editor.js +18 -12
- package/lib/RowExpandEditor/date-editor/pc-editor.js +20 -15
- package/lib/RowExpandEditor/department-editor/index.js +7 -6
- package/lib/RowExpandEditor/department-editor/mb-editor.js +11 -16
- package/lib/RowExpandEditor/department-editor/pc-editor.js +14 -19
- package/lib/RowExpandEditor/digital-sign-editor/index.js +7 -6
- package/lib/RowExpandEditor/digital-sign-editor/mb-editor/index.js +38 -24
- package/lib/RowExpandEditor/digital-sign-editor/pc-editor/index.js +39 -25
- package/lib/RowExpandEditor/duration-editor/index.js +7 -6
- package/lib/RowExpandEditor/duration-editor/mb-editor.js +17 -10
- package/lib/RowExpandEditor/duration-editor/pc-editor.js +19 -13
- package/lib/RowExpandEditor/email-editor/index.js +7 -6
- package/lib/RowExpandEditor/email-editor/mb-editor/index.js +20 -10
- package/lib/RowExpandEditor/email-editor/pc-editor/index.js +25 -14
- package/lib/RowExpandEditor/file-editor/index.js +7 -6
- package/lib/RowExpandEditor/file-editor/mb-editor/index.js +31 -18
- package/lib/RowExpandEditor/file-editor/pc-editor/index.js +23 -16
- package/lib/RowExpandEditor/geolocation-editor/index.js +7 -6
- package/lib/RowExpandEditor/geolocation-editor/mb-editor/index.js +29 -17
- package/lib/RowExpandEditor/geolocation-editor/pc-editor/index.js +26 -13
- package/lib/RowExpandEditor/image-editor/index.js +7 -6
- package/lib/RowExpandEditor/image-editor/mb-editor/index.js +26 -16
- package/lib/RowExpandEditor/image-editor/pc-editor/index.js +24 -14
- package/lib/RowExpandEditor/index.js +16 -11
- package/lib/RowExpandEditor/long-text-editor/index.js +7 -6
- package/lib/RowExpandEditor/long-text-editor/mb-editor/editor/index.js +18 -17
- package/lib/RowExpandEditor/long-text-editor/mb-editor/index.js +16 -10
- package/lib/RowExpandEditor/long-text-editor/pc-editor/index.js +23 -16
- package/lib/RowExpandEditor/multiple-select-editor/index.js +7 -6
- package/lib/RowExpandEditor/multiple-select-editor/mb-editor/index.js +20 -12
- package/lib/RowExpandEditor/multiple-select-editor/pc-editor/index.js +38 -27
- package/lib/RowExpandEditor/number-editor/index.js +7 -6
- package/lib/RowExpandEditor/number-editor/mb-editor/index.js +14 -8
- package/lib/RowExpandEditor/number-editor/pc-editor.js +20 -13
- package/lib/RowExpandEditor/rate-editor/index.js +7 -6
- package/lib/RowExpandEditor/rate-editor/mb-editor.js +26 -13
- package/lib/RowExpandEditor/rate-editor/pc-editor.js +41 -25
- package/lib/RowExpandEditor/single-select-editor/index.js +7 -6
- package/lib/RowExpandEditor/single-select-editor/mb-editor/index.js +32 -21
- package/lib/RowExpandEditor/single-select-editor/pc-editor/index.js +37 -25
- package/lib/RowExpandEditor/text-editor/index.js +7 -6
- package/lib/RowExpandEditor/text-editor/mb-editor/index.js +5 -4
- package/lib/RowExpandEditor/text-editor/pc-editor/index.js +26 -15
- package/lib/RowExpandEditor/url-editor/index.js +7 -6
- package/lib/RowExpandEditor/url-editor/mb-editor/index.js +15 -7
- package/lib/RowExpandEditor/url-editor/pc-editor/index.js +20 -11
- package/lib/RowExpandFormatter/department-formatter/index.js +6 -3
- package/lib/RowExpandFormatter/department-formatter/mb-formatter.js +4 -2
- package/lib/RowExpandFormatter/department-formatter/pc-formatter.js +4 -2
- package/lib/RowExpandFormatter/email-formatter/index.js +8 -5
- package/lib/RowExpandFormatter/file-formatter/index.js +9 -8
- package/lib/RowExpandFormatter/file-formatter/row-expand-file-item-formatter.js +14 -12
- package/lib/RowExpandFormatter/formula-formatter/index.js +51 -30
- package/lib/RowExpandFormatter/image-formatter/index.js +11 -9
- package/lib/RowExpandFormatter/image-formatter/row-expand-image-item-formatter.js +10 -9
- package/lib/RowExpandFormatter/index.js +52 -34
- package/lib/RowExpandFormatter/link-formatter/collaborator-item-formatter.js +15 -9
- package/lib/RowExpandFormatter/link-formatter/index.js +25 -17
- package/lib/RowExpandFormatter/link-formatter/value-display-utils.js +5 -3
- package/lib/RowExpandFormatter/rate-formatter/index.js +14 -13
- package/lib/RowExpandFormatter/text/index.js +5 -4
- package/lib/RowExpandFormatter/url-formatter/index.js +9 -6
- package/lib/RowExpandView/body/index.js +43 -32
- package/lib/RowExpandView/column-content/index.js +7 -3
- package/lib/RowExpandView/index.js +52 -53
- package/lib/SelectItem/index.js +7 -5
- package/lib/SelectOptionGroup/index.js +40 -30
- package/lib/SelectedDepartments/index.js +12 -10
- package/lib/SimpleLongTextFormatter/index.js +18 -12
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +4 -3
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +21 -12
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +4 -3
- package/lib/SingleSelectEditor/index.js +7 -7
- package/lib/SingleSelectFormatter/index.js +9 -8
- package/lib/TabBar/Tab.js +26 -24
- package/lib/TabBar/index.js +28 -24
- package/lib/Tabs/index.js +13 -10
- package/lib/TextEditor/index.js +23 -14
- package/lib/TextFormatter/index.js +4 -3
- package/lib/TextareaItem/index.js +53 -48
- package/lib/Toast/index.js +9 -8
- package/lib/UrlFormatter/index.js +4 -3
- package/lib/common/editor-base.js +12 -7
- package/lib/formatterConfig/index.js +3 -3
- package/lib/hooks/common-hooks.js +4 -2
- package/lib/select-editor/index.js +16 -13
- package/lib/select-editor/mb-editor/index.js +28 -17
- package/lib/select-editor/pc-editor/index.js +47 -32
- package/lib/toaster/alert.js +8 -7
- package/lib/toaster/toast.js +4 -3
- package/lib/toaster/toastManager.js +13 -13
- package/lib/toaster/toaster.js +12 -9
- package/lib/utils/cell.js +11 -8
- package/lib/utils/class.js +3 -3
- package/lib/utils/column-utils.js +14 -8
- package/lib/utils/departments.js +6 -5
- package/lib/utils/getLocale.js +11 -5
- package/lib/utils/object-utils.js +5 -4
- package/lib/utils/url.js +29 -22
- package/lib/utils/utils.js +6 -2
- package/package.json +2 -2
|
@@ -42,16 +42,19 @@ class Input extends _react.default.Component {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
this.setPopoverPosition = () => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const {
|
|
46
|
+
caretPosition
|
|
47
|
+
} = this.state;
|
|
48
|
+
let {
|
|
49
|
+
right,
|
|
50
|
+
left
|
|
51
|
+
} = this.commentRef.getBoundingClientRect();
|
|
52
|
+
this.commentPopoverRef.style.left = `${caretPosition.x + FONT_SIZE_WIDTH}px`;
|
|
53
|
+
this.commentPopoverRef.style.top = `${caretPosition.y - this.commentPopoverRef.offsetHeight}px`;
|
|
51
54
|
if (caretPosition.x + FONT_SIZE_WIDTH > right - PADDING_WIDTH) {
|
|
52
55
|
// is last code
|
|
53
|
-
this.commentPopoverRef.style.left =
|
|
54
|
-
this.commentPopoverRef.style.top =
|
|
56
|
+
this.commentPopoverRef.style.left = `${left + PADDING_WIDTH + FONT_SIZE_WIDTH}px`;
|
|
57
|
+
this.commentPopoverRef.style.top = `${caretPosition.y - this.commentPopoverRef.offsetHeight + LINE_HEIGHT}px`;
|
|
55
58
|
}
|
|
56
59
|
if (caretPosition.x + FONT_SIZE_WIDTH + this.commentPopoverRef.offsetWidth > document.body.clientWidth) {
|
|
57
60
|
this.commentPopoverRef.style.right = 0;
|
|
@@ -105,9 +108,10 @@ class Input extends _react.default.Component {
|
|
|
105
108
|
this.props.onInputBlur && this.props.onInputBlur();
|
|
106
109
|
};
|
|
107
110
|
this.setScrollTop = (offsetTop, itemOffsetHeight, mouseDownType) => {
|
|
108
|
-
let
|
|
109
|
-
offsetHeight
|
|
110
|
-
scrollTop
|
|
111
|
+
let {
|
|
112
|
+
offsetHeight,
|
|
113
|
+
scrollTop
|
|
114
|
+
} = this.commentPopoverRef;
|
|
111
115
|
if (mouseDownType === DOWN) {
|
|
112
116
|
if (offsetTop + itemOffsetHeight - scrollTop - offsetHeight + POPOVER_PADDING_HEIGHT > 0) {
|
|
113
117
|
let top = offsetTop + itemOffsetHeight - offsetHeight + POPOVER_PADDING_HEIGHT;
|
|
@@ -128,7 +132,9 @@ class Input extends _react.default.Component {
|
|
|
128
132
|
};
|
|
129
133
|
this.onInsertElement = (content, nodeType) => {
|
|
130
134
|
const selection = window.getSelection();
|
|
131
|
-
let
|
|
135
|
+
let {
|
|
136
|
+
range
|
|
137
|
+
} = this.state;
|
|
132
138
|
let newRange = this.commentUtilities.onInsertElement({
|
|
133
139
|
selection,
|
|
134
140
|
range,
|
|
@@ -160,7 +166,7 @@ class Input extends _react.default.Component {
|
|
|
160
166
|
spanNode2 = document.createElement('span');
|
|
161
167
|
spanNode1.className = 'at-text';
|
|
162
168
|
spanNode1.contentEditable = 'false';
|
|
163
|
-
spanNode1.innerHTML =
|
|
169
|
+
spanNode1.innerHTML = `@${content.name}`;
|
|
164
170
|
spanNode2.innerHTML = ' ';
|
|
165
171
|
}
|
|
166
172
|
let frag = document.createDocumentFragment();
|
|
@@ -189,7 +195,9 @@ class Input extends _react.default.Component {
|
|
|
189
195
|
};
|
|
190
196
|
this.onSelectCollaborator = collaborator => {
|
|
191
197
|
const selection = window.getSelection();
|
|
192
|
-
let
|
|
198
|
+
let {
|
|
199
|
+
range
|
|
200
|
+
} = this.state;
|
|
193
201
|
let callBack = () => {
|
|
194
202
|
this.onHidePopover();
|
|
195
203
|
this.props.addParticipant(collaborator.email);
|
|
@@ -271,10 +279,14 @@ class Input extends _react.default.Component {
|
|
|
271
279
|
});
|
|
272
280
|
};
|
|
273
281
|
this.checkMentionOperation = event => {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
282
|
+
const {
|
|
283
|
+
keyCode
|
|
284
|
+
} = event;
|
|
285
|
+
const {
|
|
286
|
+
Escape,
|
|
287
|
+
LeftArrow,
|
|
288
|
+
RightArrow
|
|
289
|
+
} = _constants.KeyCodes;
|
|
278
290
|
if (keyCode === Escape || keyCode === LeftArrow || keyCode === RightArrow) {
|
|
279
291
|
return false;
|
|
280
292
|
}
|
|
@@ -289,11 +301,15 @@ class Input extends _react.default.Component {
|
|
|
289
301
|
return this.onHidePopover();
|
|
290
302
|
}
|
|
291
303
|
const selection = window.getSelection();
|
|
292
|
-
const
|
|
304
|
+
const {
|
|
305
|
+
collaborators
|
|
306
|
+
} = this.props;
|
|
293
307
|
let filteredCollaborators = [];
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
308
|
+
const {
|
|
309
|
+
isCollapsed,
|
|
310
|
+
anchorNode,
|
|
311
|
+
anchorOffset
|
|
312
|
+
} = selection;
|
|
297
313
|
if (!isCollapsed || !anchorNode || !anchorNode.data) {
|
|
298
314
|
return this.onHidePopover();
|
|
299
315
|
}
|
|
@@ -326,9 +342,10 @@ class Input extends _react.default.Component {
|
|
|
326
342
|
};
|
|
327
343
|
this.handleSelectingCollaborator = (event, direction) => {
|
|
328
344
|
event.stopPropagation();
|
|
329
|
-
const
|
|
330
|
-
filteredCollaborators
|
|
331
|
-
activeCollaboratorIndex
|
|
345
|
+
const {
|
|
346
|
+
filteredCollaborators,
|
|
347
|
+
activeCollaboratorIndex
|
|
348
|
+
} = this.state;
|
|
332
349
|
const collaboratorsLen = filteredCollaborators.length;
|
|
333
350
|
if (collaboratorsLen === 0) {
|
|
334
351
|
return;
|
|
@@ -350,9 +367,10 @@ class Input extends _react.default.Component {
|
|
|
350
367
|
});
|
|
351
368
|
};
|
|
352
369
|
this.handleSelectCollaborator = () => {
|
|
353
|
-
const
|
|
354
|
-
filteredCollaborators
|
|
355
|
-
activeCollaboratorIndex
|
|
370
|
+
const {
|
|
371
|
+
filteredCollaborators,
|
|
372
|
+
activeCollaboratorIndex
|
|
373
|
+
} = this.state;
|
|
356
374
|
if (filteredCollaborators.length === 0) {
|
|
357
375
|
return;
|
|
358
376
|
}
|
|
@@ -378,12 +396,15 @@ class Input extends _react.default.Component {
|
|
|
378
396
|
document.removeEventListener('mousedown', this.hidePopover);
|
|
379
397
|
}
|
|
380
398
|
render() {
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
399
|
+
const {
|
|
400
|
+
api
|
|
401
|
+
} = this.props;
|
|
402
|
+
const {
|
|
403
|
+
imageUrlList,
|
|
404
|
+
largeImageIndex,
|
|
405
|
+
filteredCollaborators,
|
|
406
|
+
activeCollaboratorIndex
|
|
407
|
+
} = this.state;
|
|
387
408
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
388
409
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
389
410
|
className: (0, _classnames.default)('dtable-ui-comment-input', {
|
|
@@ -28,13 +28,14 @@ class Participant extends _react.default.Component {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
render() {
|
|
31
|
-
const
|
|
32
|
-
participant
|
|
33
|
-
index
|
|
34
|
-
activeIndex
|
|
31
|
+
const {
|
|
32
|
+
participant,
|
|
33
|
+
index,
|
|
34
|
+
activeIndex
|
|
35
|
+
} = this.props;
|
|
35
36
|
const active = index === activeIndex;
|
|
36
37
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
37
|
-
className:
|
|
38
|
+
className: `comment-participant-item ${active ? 'active' : ''}`,
|
|
38
39
|
ref: ref => this.participantItem = ref,
|
|
39
40
|
onClick: this.onSelect,
|
|
40
41
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -30,10 +30,11 @@ class Participants extends _react.default.Component {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
render() {
|
|
33
|
-
const
|
|
34
|
-
canUpdate
|
|
35
|
-
participants
|
|
36
|
-
collaborators
|
|
33
|
+
const {
|
|
34
|
+
canUpdate,
|
|
35
|
+
participants,
|
|
36
|
+
collaborators
|
|
37
|
+
} = this.props;
|
|
37
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
38
39
|
className: "dtable-ui-comments-participants mb-2 position-relative",
|
|
39
40
|
ref: ref => this.ref = ref,
|
|
@@ -11,7 +11,9 @@ var _DTableToolTip = _interopRequireDefault(require("../../../../DTableToolTip")
|
|
|
11
11
|
require("./index.css");
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
const Participant = _ref => {
|
|
14
|
-
let
|
|
14
|
+
let {
|
|
15
|
+
participant
|
|
16
|
+
} = _ref;
|
|
15
17
|
const ref = (0, _react.useRef)(null);
|
|
16
18
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
17
19
|
className: "dtable-ui-participant-avatar",
|
|
@@ -32,12 +32,18 @@ class ParticipantSelect extends _react.Component {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
this.getFilteredParticipants = () => {
|
|
35
|
-
let
|
|
36
|
-
|
|
35
|
+
let {
|
|
36
|
+
collaborators
|
|
37
|
+
} = window.app.state;
|
|
38
|
+
let {
|
|
39
|
+
searchVal
|
|
40
|
+
} = this.state;
|
|
37
41
|
return (0, _dtableUtils.searchCollaborators)(collaborators, searchVal);
|
|
38
42
|
};
|
|
39
43
|
this.removeParticipant = participant => {
|
|
40
|
-
let
|
|
44
|
+
let {
|
|
45
|
+
participants
|
|
46
|
+
} = this.state;
|
|
41
47
|
let updatedValue = participants.slice(0);
|
|
42
48
|
let participant_index = participants.findIndex(participantItem => participantItem.email === participant.email);
|
|
43
49
|
updatedValue.splice(participant_index, 1);
|
|
@@ -47,7 +53,9 @@ class ParticipantSelect extends _react.Component {
|
|
|
47
53
|
});
|
|
48
54
|
};
|
|
49
55
|
this.onChangeSearch = event => {
|
|
50
|
-
let
|
|
56
|
+
let {
|
|
57
|
+
searchVal
|
|
58
|
+
} = this.state;
|
|
51
59
|
if (searchVal === event.target.value) {
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
@@ -57,7 +65,9 @@ class ParticipantSelect extends _react.Component {
|
|
|
57
65
|
});
|
|
58
66
|
};
|
|
59
67
|
this.onSelectParticipant = participant => {
|
|
60
|
-
let
|
|
68
|
+
let {
|
|
69
|
+
participants
|
|
70
|
+
} = this.state;
|
|
61
71
|
participants = participants.slice(0);
|
|
62
72
|
let participant_index = participants.findIndex(participantItem => participantItem.email === participant.email);
|
|
63
73
|
if (participant_index > -1) {
|
|
@@ -71,7 +81,9 @@ class ParticipantSelect extends _react.Component {
|
|
|
71
81
|
});
|
|
72
82
|
};
|
|
73
83
|
this.renderMenuContent = () => {
|
|
74
|
-
let
|
|
84
|
+
let {
|
|
85
|
+
participants
|
|
86
|
+
} = this.state;
|
|
75
87
|
let filteredParticipants = this.getFilteredParticipants();
|
|
76
88
|
if (filteredParticipants.length > 0) {
|
|
77
89
|
return filteredParticipants.map(participant => {
|
|
@@ -115,18 +127,20 @@ class ParticipantSelect extends _react.Component {
|
|
|
115
127
|
}
|
|
116
128
|
componentDidMount() {
|
|
117
129
|
let collaboratorListHeight = this.participantsRef.offsetHeight;
|
|
118
|
-
this.participantsRef.style.top =
|
|
130
|
+
this.participantsRef.style.top = `${-collaboratorListHeight + 10}px`;
|
|
119
131
|
this.registerHandlers();
|
|
120
132
|
}
|
|
121
133
|
componentDidUpdate() {
|
|
122
134
|
let collaboratorListHeight = this.participantsRef.offsetHeight;
|
|
123
|
-
this.participantsRef.style.top =
|
|
135
|
+
this.participantsRef.style.top = `${-collaboratorListHeight + 10}px`;
|
|
124
136
|
}
|
|
125
137
|
componentWillUnmount() {
|
|
126
138
|
this.unregisterHandlers();
|
|
127
139
|
}
|
|
128
140
|
renderParticipantList() {
|
|
129
|
-
const
|
|
141
|
+
const {
|
|
142
|
+
collaborators
|
|
143
|
+
} = this.props;
|
|
130
144
|
const selectedParticipants = collaborators.filter(item => {
|
|
131
145
|
return this.state.participants.find(participant => participant.email === item.email);
|
|
132
146
|
});
|
|
@@ -144,7 +158,9 @@ class ParticipantSelect extends _react.Component {
|
|
|
144
158
|
});
|
|
145
159
|
}
|
|
146
160
|
render() {
|
|
147
|
-
const
|
|
161
|
+
const {
|
|
162
|
+
target
|
|
163
|
+
} = this.props;
|
|
148
164
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
149
165
|
ref: ref => this.outerRef = ref,
|
|
150
166
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.Popover, {
|
package/lib/Comment/index.js
CHANGED
|
@@ -42,7 +42,9 @@ class Comment extends _react.default.Component {
|
|
|
42
42
|
let isGetCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
43
43
|
_this.initComments(row, 1, pageNum);
|
|
44
44
|
if (!isGetCount) return;
|
|
45
|
-
const
|
|
45
|
+
const {
|
|
46
|
+
api
|
|
47
|
+
} = _this.props;
|
|
46
48
|
api.getCount(row).then(res => {
|
|
47
49
|
const count = res.data.count;
|
|
48
50
|
_this.updateCount(row, count);
|
|
@@ -53,7 +55,9 @@ class Comment extends _react.default.Component {
|
|
|
53
55
|
this.initComments = function (row) {
|
|
54
56
|
let page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
55
57
|
let perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
56
|
-
const
|
|
58
|
+
const {
|
|
59
|
+
api
|
|
60
|
+
} = _this.props;
|
|
57
61
|
api.get(row, page, perPage).then(res => {
|
|
58
62
|
let comments = res.data.comment_list || [];
|
|
59
63
|
let newComments = [];
|
|
@@ -70,11 +74,14 @@ class Comment extends _react.default.Component {
|
|
|
70
74
|
});
|
|
71
75
|
};
|
|
72
76
|
this.addComment = (newComment, _ref) => {
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
let {
|
|
78
|
+
successCallback,
|
|
79
|
+
failCallback
|
|
80
|
+
} = _ref;
|
|
81
|
+
const {
|
|
82
|
+
row,
|
|
83
|
+
api
|
|
84
|
+
} = this.props;
|
|
78
85
|
api.add(row, newComment).then(res => api.getCount(row)).then(res => {
|
|
79
86
|
const count = res.data.count;
|
|
80
87
|
this.updateCount(row, count);
|
|
@@ -89,9 +96,10 @@ class Comment extends _react.default.Component {
|
|
|
89
96
|
};
|
|
90
97
|
this.resolveComment = (event, commentID) => {
|
|
91
98
|
event.persist();
|
|
92
|
-
const
|
|
93
|
-
row
|
|
94
|
-
api
|
|
99
|
+
const {
|
|
100
|
+
row,
|
|
101
|
+
api
|
|
102
|
+
} = this.props;
|
|
95
103
|
api.update(row, commentID, null, 1).then(() => {
|
|
96
104
|
this.reCalculateComments(row);
|
|
97
105
|
}).catch(error => {
|
|
@@ -99,9 +107,10 @@ class Comment extends _react.default.Component {
|
|
|
99
107
|
});
|
|
100
108
|
};
|
|
101
109
|
this.deleteComment = (event, commentID) => {
|
|
102
|
-
const
|
|
103
|
-
api
|
|
104
|
-
row
|
|
110
|
+
const {
|
|
111
|
+
api,
|
|
112
|
+
row
|
|
113
|
+
} = this.props;
|
|
105
114
|
api.delete(row, commentID).then(() => {
|
|
106
115
|
this.reCalculateComments(row);
|
|
107
116
|
}).catch(e => {
|
|
@@ -110,14 +119,17 @@ class Comment extends _react.default.Component {
|
|
|
110
119
|
};
|
|
111
120
|
// notification
|
|
112
121
|
this.onNewNotification = notification => {
|
|
113
|
-
const
|
|
122
|
+
const {
|
|
123
|
+
msg_type
|
|
124
|
+
} = notification;
|
|
114
125
|
if (msg_type !== ROW_COMMENT) return;
|
|
115
126
|
this.setState({
|
|
116
127
|
isFirstLoading: true
|
|
117
128
|
});
|
|
118
|
-
const
|
|
119
|
-
row
|
|
120
|
-
api
|
|
129
|
+
const {
|
|
130
|
+
row,
|
|
131
|
+
api
|
|
132
|
+
} = this.props;
|
|
121
133
|
api.getCount(row).then(res => {
|
|
122
134
|
const count = res.data.count;
|
|
123
135
|
this.updateCount(row, count);
|
|
@@ -128,9 +140,11 @@ class Comment extends _react.default.Component {
|
|
|
128
140
|
};
|
|
129
141
|
// collaborators
|
|
130
142
|
this.initCollaborators = props => {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
const {
|
|
144
|
+
columns,
|
|
145
|
+
row,
|
|
146
|
+
collaborators
|
|
147
|
+
} = props;
|
|
134
148
|
let collaboratorColumnKeyList = [];
|
|
135
149
|
columns.forEach(column => {
|
|
136
150
|
if (column.type === _dtableUtils.CellType.COLLABORATOR) {
|
|
@@ -179,12 +193,14 @@ class Comment extends _react.default.Component {
|
|
|
179
193
|
};
|
|
180
194
|
this.onScroll = () => {
|
|
181
195
|
if (this.body.offsetHeight + this.body.scrollTop + 1 < this.bodyContent.offsetHeight + 32) return; // 16 is padding height
|
|
182
|
-
const
|
|
183
|
-
api
|
|
184
|
-
row
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
const {
|
|
197
|
+
api,
|
|
198
|
+
row
|
|
199
|
+
} = this.props;
|
|
200
|
+
const {
|
|
201
|
+
comments,
|
|
202
|
+
count
|
|
203
|
+
} = this.state;
|
|
188
204
|
let currentCommentsLength = comments.length;
|
|
189
205
|
if (currentCommentsLength < count) {
|
|
190
206
|
// Have pagination
|
|
@@ -241,19 +257,21 @@ class Comment extends _react.default.Component {
|
|
|
241
257
|
this.unsubscribeNotification();
|
|
242
258
|
}
|
|
243
259
|
render() {
|
|
244
|
-
const
|
|
245
|
-
collaborators
|
|
246
|
-
comments
|
|
247
|
-
isLoading
|
|
248
|
-
isFirstLoading
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
260
|
+
const {
|
|
261
|
+
collaborators,
|
|
262
|
+
comments,
|
|
263
|
+
isLoading,
|
|
264
|
+
isFirstLoading
|
|
265
|
+
} = this.state;
|
|
266
|
+
const {
|
|
267
|
+
autoFocusInput,
|
|
268
|
+
row,
|
|
269
|
+
columns,
|
|
270
|
+
onInputFocus,
|
|
271
|
+
onInputBlur,
|
|
272
|
+
api,
|
|
273
|
+
uploadFile
|
|
274
|
+
} = this.props;
|
|
257
275
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
258
276
|
className: "dtable-ui-comments h-100 w-100",
|
|
259
277
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -9,11 +9,13 @@ var _getEventTransfer = _interopRequireDefault(require("../../utils/get-event-tr
|
|
|
9
9
|
class Utilities {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.onInsertElement = _ref => {
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
let {
|
|
13
|
+
commentRef,
|
|
14
|
+
selection,
|
|
15
|
+
range,
|
|
16
|
+
content,
|
|
17
|
+
nodeType
|
|
18
|
+
} = _ref;
|
|
17
19
|
if (range) {
|
|
18
20
|
selection.removeAllRanges();
|
|
19
21
|
selection.addRange(range);
|
|
@@ -46,11 +48,13 @@ class Utilities {
|
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
this.createHtmlElement = _ref2 => {
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
let {
|
|
52
|
+
commentRef,
|
|
53
|
+
selection,
|
|
54
|
+
range,
|
|
55
|
+
content,
|
|
56
|
+
nodeType
|
|
57
|
+
} = _ref2;
|
|
54
58
|
let spanNode1;
|
|
55
59
|
let spanNode2;
|
|
56
60
|
let imageContainer;
|
|
@@ -70,7 +74,7 @@ class Utilities {
|
|
|
70
74
|
spanNode2 = document.createElement('span');
|
|
71
75
|
spanNode1.className = 'at-text';
|
|
72
76
|
spanNode1.contentEditable = 'true';
|
|
73
|
-
spanNode1.innerHTML =
|
|
77
|
+
spanNode1.innerHTML = `@${content.name}`;
|
|
74
78
|
spanNode2.innerHTML = ' ';
|
|
75
79
|
}
|
|
76
80
|
let frag = document.createDocumentFragment();
|
|
@@ -93,11 +97,13 @@ class Utilities {
|
|
|
93
97
|
return range;
|
|
94
98
|
};
|
|
95
99
|
this.onSelectParticipant = _ref3 => {
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
let {
|
|
101
|
+
selection,
|
|
102
|
+
range,
|
|
103
|
+
participant,
|
|
104
|
+
callBack,
|
|
105
|
+
commentRef
|
|
106
|
+
} = _ref3;
|
|
101
107
|
if (range) {
|
|
102
108
|
// delete '@xxx';
|
|
103
109
|
selection.removeAllRanges();
|
|
@@ -20,9 +20,10 @@ class CreatorFormatter extends _react.default.PureComponent {
|
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
22
|
this.getCollaborators = () => {
|
|
23
|
-
let
|
|
24
|
-
value
|
|
25
|
-
collaborators
|
|
23
|
+
let {
|
|
24
|
+
value,
|
|
25
|
+
collaborators
|
|
26
|
+
} = this.props;
|
|
26
27
|
if (!Array.isArray(value)) {
|
|
27
28
|
value = [value];
|
|
28
29
|
}
|
|
@@ -42,9 +43,10 @@ class CreatorFormatter extends _react.default.PureComponent {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
render() {
|
|
45
|
-
const
|
|
46
|
-
containerClassName
|
|
47
|
-
value
|
|
46
|
+
const {
|
|
47
|
+
containerClassName,
|
|
48
|
+
value
|
|
49
|
+
} = this.props;
|
|
48
50
|
const classname = (0, _classnames.default)('dtable-ui cell-formatter-container creator-formatter', containerClassName);
|
|
49
51
|
if (!value || Array.isArray(value) && value.length === 0) {
|
|
50
52
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = ColorPickerPortal;
|
|
9
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
11
|
var _utils = require("../../utils/utils");
|
|
14
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
13
|
function ColorPickerPortal(_ref) {
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throttleDelay =
|
|
20
|
-
children
|
|
14
|
+
let {
|
|
15
|
+
target,
|
|
16
|
+
scrollContainerId,
|
|
17
|
+
throttleDelay = 16,
|
|
18
|
+
children
|
|
19
|
+
} = _ref;
|
|
21
20
|
const containerRef = (0, _react.useRef)(null);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
visibility: 'hidden'
|
|
31
|
-
};
|
|
32
|
-
}),
|
|
33
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
34
|
-
position = _useState4[0],
|
|
35
|
-
setPosition = _useState4[1];
|
|
21
|
+
const [isPositioned, setIsPositioned] = (0, _react.useState)(false);
|
|
22
|
+
const [position, setPosition] = (0, _react.useState)(() => {
|
|
23
|
+
return {
|
|
24
|
+
top: '-9999px',
|
|
25
|
+
left: '-9999px',
|
|
26
|
+
visibility: 'hidden'
|
|
27
|
+
};
|
|
28
|
+
});
|
|
36
29
|
const updatePosition = (0, _react.useCallback)(() => {
|
|
37
30
|
if (!target || !containerRef.current) return;
|
|
38
31
|
const targetRect = target.getBoundingClientRect();
|
|
39
|
-
const
|
|
40
|
-
|
|
32
|
+
const {
|
|
33
|
+
top: spaceAbove,
|
|
34
|
+
left
|
|
35
|
+
} = targetRect;
|
|
41
36
|
const portalRectHeight = containerRef.current.clientHeight;
|
|
42
37
|
const newPosition = {
|
|
43
|
-
left:
|
|
38
|
+
left: `${left + 1}px`,
|
|
44
39
|
visibility: 'visible'
|
|
45
40
|
};
|
|
46
41
|
if (spaceAbove < portalRectHeight) {
|
|
47
|
-
newPosition.top =
|
|
42
|
+
newPosition.top = `calc(${spaceAbove}px + 2.375rem)`;
|
|
48
43
|
} else {
|
|
49
|
-
newPosition.top =
|
|
44
|
+
newPosition.top = `calc(${spaceAbove - portalRectHeight}px)`;
|
|
50
45
|
}
|
|
51
|
-
setPosition(prev => (
|
|
46
|
+
setPosition(prev => ({
|
|
47
|
+
...prev,
|
|
48
|
+
...newPosition
|
|
49
|
+
}));
|
|
52
50
|
if (!isPositioned) {
|
|
53
51
|
setIsPositioned(true);
|
|
54
52
|
}
|