@geneui/components 3.0.0-next-06dadf3-29102024 → 3.0.0-next-48d0ef7-31102024
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/Avatar.js +63 -0
- package/Divider.js +23 -0
- package/{GeneUIProvider/index.js → GeneUIProvider.js} +51 -64
- package/HelperText.js +69 -0
- package/Info.js +64 -0
- package/Label.js +38 -0
- package/Loader.js +21 -0
- package/Pill.js +64 -0
- package/TextLink.js +20 -0
- package/{index-c7646e48.js → Tooltip.js} +101 -79
- package/{lib → components}/atoms/Avatar/Avatar.d.ts +7 -6
- package/components/atoms/Avatar/index.d.ts +1 -0
- package/{lib → components}/atoms/Divider/Divider.d.ts +5 -5
- package/components/atoms/Divider/index.d.ts +1 -0
- package/{lib → components}/atoms/HelperText/HelperText.d.ts +6 -5
- package/components/atoms/HelperText/index.d.ts +1 -0
- package/{lib → components}/atoms/Info/Info.d.ts +5 -5
- package/components/atoms/Info/index.d.ts +1 -0
- package/{lib → components}/atoms/Label/Label.d.ts +3 -3
- package/components/atoms/Label/index.d.ts +1 -0
- package/{lib → components}/atoms/Loader/Loader.d.ts +5 -5
- package/components/atoms/Loader/index.d.ts +1 -0
- package/{lib → components}/atoms/Pill/Pill.d.ts +7 -6
- package/components/atoms/Pill/index.d.ts +1 -0
- package/{lib → components}/atoms/TextLink/TextLink.d.ts +5 -5
- package/components/atoms/TextLink/index.d.ts +1 -0
- package/{lib → components}/molecules/Tooltip/Tooltip.d.ts +26 -21
- package/components/molecules/Tooltip/index.d.ts +1 -0
- package/components/providers/GeneUIProvider/GeneUIProvider.d.ts +30 -0
- package/components/providers/GeneUIProvider/index.d.ts +1 -0
- package/hooks/index.d.ts +2 -20
- package/hooks/useDebounceCallback/index.d.ts +1 -0
- package/hooks/useDebounceCallback/useDebounceCallback.d.ts +2 -0
- package/hooks/useEllipsisDetection/index.d.ts +1 -1
- package/hooks/useEllipsisDetection/useEllipsisDetection.d.ts +2 -2
- package/{index-031ff73c.js → index-ce02421b.js} +4 -4
- package/index.d.ts +11 -121
- package/index.js +12 -159
- package/package.json +24 -43
- package/tokens-0abb4e1b.js +6 -0
- package/types/index.d.ts +0 -3
- package/useEllipsisDetection-46d712b6.js +34 -0
- package/ActionableList/index.js +0 -1694
- package/AdvancedSearch/index.js +0 -892
- package/Alert/index.js +0 -98
- package/Avatar/index.js +0 -58
- package/Badge/index.js +0 -29
- package/Breadcrumb/index.js +0 -130
- package/BusyLoader/index.js +0 -31
- package/Button/index.js +0 -30
- package/Card/index.js +0 -502
- package/CardList/index.js +0 -662
- package/CellMeasurerCache-26f3693c.js +0 -229
- package/Charts/index.js +0 -17662
- package/Checkbox/index.js +0 -229
- package/CheckboxGroup/index.js +0 -203
- package/CheckboxGroupWithSearch/index.js +0 -280
- package/Collapse/index.js +0 -195
- package/ColorPicker/index.js +0 -210
- package/ComboBox/index.js +0 -524
- package/Copy/index.js +0 -56
- package/Counter/index.js +0 -312
- package/DateFilter/index.js +0 -183
- package/DatePicker/index.js +0 -1229
- package/DatePickerInput/index.js +0 -883
- package/Divider/index.js +0 -23
- package/Drawer/index.js +0 -261
- package/Dropdown/index.js +0 -43
- package/Editor/index.js +0 -22975
- package/Empty/index.js +0 -76
- package/ExtendedInput/index.js +0 -590
- package/Form/index.js +0 -85
- package/FormContainer/index.js +0 -189
- package/FormableCheckbox/index.js +0 -24
- package/FormableDatePicker/index.js +0 -43
- package/FormableDropdown/index.js +0 -50
- package/FormableEditor/index.js +0 -26
- package/FormableHOC-85f89a81.js +0 -83
- package/FormableMultiSelectDropdown/index.js +0 -50
- package/FormableNumberInput/index.js +0 -34
- package/FormableRadio/index.js +0 -22
- package/FormableSwitcher/index.js +0 -22
- package/FormableTextInput/index.js +0 -34
- package/FormableUploader/index.js +0 -44
- package/Grid/index.js +0 -167
- package/HelperText/index.js +0 -86
- package/Holder/index.js +0 -261
- package/Icon/index.js +0 -62
- package/Image/index.js +0 -45
- package/ImagePreview/index.js +0 -217
- package/Info/index.js +0 -41
- package/InfoOutline-dd2e89d9.js +0 -29
- package/InteractiveWidget/index.js +0 -78
- package/KeyValue/index.js +0 -22
- package/Label/index.js +0 -48
- package/LinkButton/index.js +0 -34
- package/Loader/index.js +0 -23
- package/Menu/index.js +0 -281
- package/MobileNavigation/index.js +0 -94
- package/MobilePopup/index.js +0 -182
- package/Modal/index.js +0 -251
- package/ModuleTitle/index.js +0 -141
- package/NavigationMenu/index.js +0 -222
- package/Notification/index.js +0 -120
- package/Option/index.js +0 -184
- package/Overlay/index.js +0 -187
- package/Overspread/index.js +0 -291
- package/Pagination/index.js +0 -261
- package/Paper/index.js +0 -96
- package/Pill/index.js +0 -67
- package/Popover/index.js +0 -725
- package/PopoverV2/index.js +0 -19
- package/Portal/index.js +0 -58
- package/Products/index.js +0 -115
- package/Profile/index.js +0 -589
- package/Progress/index.js +0 -200
- package/QRCode/index.js +0 -814
- package/Radio/index.js +0 -151
- package/RadioGroup/index.js +0 -104
- package/Range/index.js +0 -191
- package/Rating/index.js +0 -174
- package/RichEditor/index.js +0 -13
- package/RichEditor-6ca8346f.js +0 -228
- package/Scrollbar/index.js +0 -1585
- package/Search/index.js +0 -75
- package/SearchWithDropdown/index.js +0 -140
- package/Section/index.js +0 -61
- package/SkeletonLoader/index.js +0 -81
- package/Slider/index.js +0 -261
- package/Status/index.js +0 -97
- package/Steps/index.js +0 -314
- package/SuggestionList/index.js +0 -385
- package/Switcher/index.js +0 -193
- package/Table/index.js +0 -57
- package/TableCompositions/index.js +0 -16995
- package/Tabs/index.js +0 -235
- package/Tag/index.js +0 -102
- package/TextLink/index.js +0 -20
- package/Textarea/index.js +0 -242
- package/Time/index.js +0 -62
- package/TimePicker/index.js +0 -575
- package/Timeline/index.js +0 -113
- package/Title/index.js +0 -65
- package/Toaster/index.js +0 -116
- package/Tooltip/index.js +0 -6
- package/TransferList/index.js +0 -493
- package/Uploader/index.js +0 -992
- package/ValidatableCheckbox/index.js +0 -123
- package/ValidatableDatePicker/index.js +0 -316
- package/ValidatableDropdown/index.js +0 -141
- package/ValidatableElements/index.js +0 -67
- package/ValidatableMultiSelectDropdown/index.js +0 -152
- package/ValidatableNumberInput/index.js +0 -204
- package/ValidatableRadio/index.js +0 -116
- package/ValidatableSwitcher/index.js +0 -93
- package/ValidatableTextInput/index.js +0 -167
- package/ValidatableTimeInput/index.js +0 -174
- package/ValidatableUploader/index.js +0 -98
- package/Widget/index.js +0 -225
- package/_commonjsHelpers-24198af3.js +0 -35
- package/_rollupPluginBabelHelpers-a83240e1.js +0 -11
- package/callAfterDelay-7272faca.js +0 -12
- package/checkTimeValidation-e56771be.js +0 -16
- package/checkboxRadioSwitcher-5b69d7bd.js +0 -4
- package/clsx.m-2bb6df4b.js +0 -3
- package/config-1053d64d.js +0 -20
- package/configs-00612ce0.js +0 -103
- package/configs.js +0 -111
- package/dateValidation-67caec66.js +0 -225
- package/debounce-4419bc2f.js +0 -17
- package/guid-8ddf77b3.js +0 -16
- package/hooks/useBodyScroll.js +0 -16
- package/hooks/useClick.js +0 -18
- package/hooks/useClickOutside.js +0 -25
- package/hooks/useDebounce.js +0 -28
- package/hooks/useDeviceType.js +0 -17
- package/hooks/useDidMount.js +0 -15
- package/hooks/useForceUpdate.js +0 -8
- package/hooks/useHover.js +0 -20
- package/hooks/useImgDownload.js +0 -18
- package/hooks/useKeyDown.js +0 -21
- package/hooks/useMount.js +0 -13
- package/hooks/useMutationObserver.js +0 -21
- package/hooks/usePrevious.js +0 -10
- package/hooks/useThrottle.js +0 -16
- package/hooks/useToggle.js +0 -11
- package/hooks/useUpdatableRef.js +0 -14
- package/hooks/useUpdate.js +0 -10
- package/hooks/useWidth.js +0 -16
- package/hooks/useWindowSize.js +0 -40
- package/index-122432cd.js +0 -270
- package/index-262edd7a.js +0 -77
- package/index-3188e46e.js +0 -1940
- package/index-45eafea6.js +0 -90
- package/index-5f37f281.js +0 -168
- package/index-ce12e4a9.js +0 -10032
- package/index-d0ecb950.js +0 -6483
- package/index-fcbae78d.js +0 -4
- package/index.mobile.d.ts +0 -14
- package/lib/atoms/Avatar/index.d.ts +0 -1
- package/lib/atoms/Badge/Badge.d.ts +0 -36
- package/lib/atoms/Badge/index.d.ts +0 -1
- package/lib/atoms/BusyLoader/BusyLoader.d.ts +0 -32
- package/lib/atoms/BusyLoader/BusyLoaderHolderHOC.d.ts +0 -8
- package/lib/atoms/BusyLoader/index.d.ts +0 -1
- package/lib/atoms/Button/Button.d.ts +0 -70
- package/lib/atoms/Button/index.d.ts +0 -1
- package/lib/atoms/Divider/index.d.ts +0 -1
- package/lib/atoms/Empty/Empty.d.ts +0 -39
- package/lib/atoms/Empty/index.d.ts +0 -1
- package/lib/atoms/Empty/utils.d.ts +0 -9
- package/lib/atoms/HelperText/index.d.ts +0 -1
- package/lib/atoms/Image/Image.d.ts +0 -51
- package/lib/atoms/Image/index.d.ts +0 -1
- package/lib/atoms/ImagePreview/ImagePreview.d.ts +0 -56
- package/lib/atoms/ImagePreview/ImagePreviewHOC.d.ts +0 -4
- package/lib/atoms/ImagePreview/Magnifier.d.ts +0 -40
- package/lib/atoms/ImagePreview/index.d.ts +0 -1
- package/lib/atoms/Info/index.d.ts +0 -1
- package/lib/atoms/KeyValue/KeyValue.d.ts +0 -29
- package/lib/atoms/KeyValue/index.d.ts +0 -1
- package/lib/atoms/Label/index.d.ts +0 -1
- package/lib/atoms/LinkButton/LinkButton.d.ts +0 -46
- package/lib/atoms/LinkButton/index.d.ts +0 -1
- package/lib/atoms/Loader/index.d.ts +0 -1
- package/lib/atoms/Pill/index.d.ts +0 -1
- package/lib/atoms/Rating/DefaultSvg.d.ts +0 -3
- package/lib/atoms/Rating/Rating.d.ts +0 -49
- package/lib/atoms/Rating/index.d.ts +0 -1
- package/lib/atoms/TextLink/index.d.ts +0 -1
- package/lib/molecules/Copy/Copy.d.ts +0 -38
- package/lib/molecules/Copy/index.d.ts +0 -1
- package/lib/molecules/InteractiveWidget/InteractiveWidget.d.ts +0 -70
- package/lib/molecules/InteractiveWidget/InteractiveWidgetIcon.d.ts +0 -8
- package/lib/molecules/InteractiveWidget/index.d.ts +0 -1
- package/lib/molecules/Tooltip/index.d.ts +0 -1
- package/lib/providers/GeneUIProvider/GeneUIProvider.d.ts +0 -30
- package/lib/providers/GeneUIProvider/index.d.ts +0 -1
- package/localization-4ba17032.js +0 -46
- package/objectWithoutPropertiesLoose-e1596bdb.js +0 -62
- package/rangeAndSlider-740a236c.js +0 -8676
- package/react-beautiful-dnd.esm-8c7b5a83.js +0 -10116
- package/react-lifecycles-compat.es-6e1f3768.js +0 -158
- package/redux-e591c1b8.js +0 -536
- package/tokens-8ab1179c.js +0 -6
- package/tslib.es6-f211516f.js +0 -35
- package/useEllipsisDetection-c1c9ad94.js +0 -38
package/ComboBox/index.js
DELETED
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
2
|
-
import React__default, { forwardRef, useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { c as classnames } from '../index-031ff73c.js';
|
|
5
|
-
import { i as inputConfig } from '../configs-00612ce0.js';
|
|
6
|
-
import { s as stopEvent, n as noop } from '../index-5f37f281.js';
|
|
7
|
-
import useClickOutside from '../hooks/useClickOutside.js';
|
|
8
|
-
import { k as keyDownKeys, a as actionTypes, S as SPACE_HEIGHT } from '../config-1053d64d.js';
|
|
9
|
-
import Icon from '../Icon/index.js';
|
|
10
|
-
import CustomScrollbar from '../Scrollbar/index.js';
|
|
11
|
-
import { T as Tooltip } from '../index-c7646e48.js';
|
|
12
|
-
import useKeyDown from '../hooks/useKeyDown.js';
|
|
13
|
-
import Tag from '../Tag/index.js';
|
|
14
|
-
import { s as styleInject } from '../style-inject.es-746bb8ed.js';
|
|
15
|
-
import { c as callAfterDelay } from '../callAfterDelay-7272faca.js';
|
|
16
|
-
import '../dateValidation-67caec66.js';
|
|
17
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
18
|
-
import 'react-dom';
|
|
19
|
-
import '../tslib.es6-f211516f.js';
|
|
20
|
-
import '../GeneUIProvider/index.js';
|
|
21
|
-
|
|
22
|
-
var css_248z$1 = "[data-gene-ui-version=\"2.16.4\"] .tag-wrapper{align-items:center;display:flex;max-width:100%}[data-gene-ui-version=\"2.16.4\"] .tag-wrapper.flex-basis{align-self:center;flex-basis:20px}[data-gene-ui-version=\"2.16.4\"] .tag-wrapper .input{background:#0000;border:none;caret-color:var(--background-sc);color:var(--background-sc);flex:1 1;margin:1px 0;outline:none;padding:0;width:100%}[data-gene-ui-version=\"2.16.4\"] .tag-wrapper span{align-self:flex-start;background:#fff;border:none;color:#000;display:flex;flex:1 1;height:0;outline:none;padding:0;visibility:hidden;white-space:pre}";
|
|
23
|
-
styleInject(css_248z$1);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Tag Wrapper
|
|
27
|
-
*/
|
|
28
|
-
const TagWrapper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
29
|
-
const {
|
|
30
|
-
createInputRef,
|
|
31
|
-
activeRowRef
|
|
32
|
-
} = ref;
|
|
33
|
-
const {
|
|
34
|
-
isValid,
|
|
35
|
-
label,
|
|
36
|
-
editMode,
|
|
37
|
-
index,
|
|
38
|
-
onChangeHandler,
|
|
39
|
-
onDeleteHandler,
|
|
40
|
-
placeholder,
|
|
41
|
-
hasTags,
|
|
42
|
-
hasIcon,
|
|
43
|
-
onKeyPress,
|
|
44
|
-
activeTagIndex,
|
|
45
|
-
setEditModeIndex,
|
|
46
|
-
setActiveTagIndex,
|
|
47
|
-
withEdit
|
|
48
|
-
} = props;
|
|
49
|
-
const [hasTooltip, setHasTooltip] = useState(false);
|
|
50
|
-
const [inputValue, setInputValue] = useState('');
|
|
51
|
-
const [isEditMode, setIsEditMode] = useState(editMode);
|
|
52
|
-
const inputRef = useRef(null);
|
|
53
|
-
const tagRef = useRef(null);
|
|
54
|
-
const isActive = useMemo(() => index === activeTagIndex, [activeTagIndex, index]);
|
|
55
|
-
const createMode = useMemo(() => index === undefined, [index]);
|
|
56
|
-
const editModeChangeHandler = useCallback(() => {
|
|
57
|
-
setIsEditMode(editMode);
|
|
58
|
-
editMode && callAfterDelay(() => {
|
|
59
|
-
var _inputRef$current;
|
|
60
|
-
return inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
61
|
-
});
|
|
62
|
-
}, [editMode, inputRef]);
|
|
63
|
-
const stopEventHandler = e => stopEvent(e, true);
|
|
64
|
-
const keyDownHandler = useCallback(e => {
|
|
65
|
-
switch (e.key) {
|
|
66
|
-
case keyDownKeys.tab:
|
|
67
|
-
case keyDownKeys.enter:
|
|
68
|
-
e.key === keyDownKeys.tab && (isEditMode && !createMode || createMode && inputValue && inputValue.trim().length) && stopEventHandler(e);
|
|
69
|
-
setEditModeIndex && setEditModeIndex(null);
|
|
70
|
-
if (inputValue && inputValue.trim().length && isEditMode) {
|
|
71
|
-
setInputValue(createMode ? '' : inputValue);
|
|
72
|
-
onChangeHandler({
|
|
73
|
-
label: inputValue,
|
|
74
|
-
index
|
|
75
|
-
});
|
|
76
|
-
!createMode && setIsEditMode(false);
|
|
77
|
-
} else if (!inputValue && !createMode) {
|
|
78
|
-
onDeleteHandler(index);
|
|
79
|
-
setIsEditMode(false);
|
|
80
|
-
} else if (activeTagIndex !== null && setEditModeIndex) {
|
|
81
|
-
e.key === keyDownKeys.enter && setEditModeIndex(activeTagIndex);
|
|
82
|
-
e.key === keyDownKeys.tab && setActiveTagIndex(null);
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
case keyDownKeys.escape:
|
|
86
|
-
setEditModeIndex && setEditModeIndex(null);
|
|
87
|
-
setActiveTagIndex && setActiveTagIndex(null);
|
|
88
|
-
if (!createMode) {
|
|
89
|
-
setIsEditMode(false);
|
|
90
|
-
setInputValue(label || '');
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
case keyDownKeys.arrowRight:
|
|
94
|
-
case keyDownKeys.backspace:
|
|
95
|
-
case keyDownKeys.arrowLeft:
|
|
96
|
-
case keyDownKeys.delete:
|
|
97
|
-
createMode && !inputValue && withEdit && onKeyPress(e.key);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}, [activeTagIndex, createMode, index, inputValue, isEditMode, label, onChangeHandler, onDeleteHandler, onKeyPress, setActiveTagIndex, setEditModeIndex, withEdit]);
|
|
101
|
-
const dblclickHandler = useCallback(() => {
|
|
102
|
-
const handleClick = () => {
|
|
103
|
-
if (createMode || !withEdit || isEditMode) return;
|
|
104
|
-
setIsEditMode(prev => !prev);
|
|
105
|
-
setEditModeIndex(index);
|
|
106
|
-
setActiveTagIndex(null);
|
|
107
|
-
(createInputRef || inputRef).current.focus();
|
|
108
|
-
};
|
|
109
|
-
const element = tagRef === null || tagRef === void 0 ? void 0 : tagRef.current;
|
|
110
|
-
element && element.addEventListener('dblclick', handleClick);
|
|
111
|
-
return () => {
|
|
112
|
-
element && element.removeEventListener('dblclick', handleClick);
|
|
113
|
-
};
|
|
114
|
-
}, [createMode, isEditMode, createInputRef, withEdit, setEditModeIndex, index, setActiveTagIndex]);
|
|
115
|
-
const handleOutsideClick = useClickOutside(event => {
|
|
116
|
-
if (tagRef && !tagRef.current.contains(event.target)) {
|
|
117
|
-
if (!createMode && isEditMode) {
|
|
118
|
-
setIsEditMode(false);
|
|
119
|
-
if (label !== inputValue) {
|
|
120
|
-
if (inputValue && inputValue.trim().length) {
|
|
121
|
-
onChangeHandler({
|
|
122
|
-
label: inputValue,
|
|
123
|
-
index
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
onDeleteHandler(index);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
} else if (inputValue && createMode) {
|
|
130
|
-
inputValue.trim().length && onChangeHandler({
|
|
131
|
-
label: inputValue,
|
|
132
|
-
index
|
|
133
|
-
});
|
|
134
|
-
setInputValue('');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
const handleChangeLabel = useCallback(() => {
|
|
139
|
-
var _tagRef$current, _tagRef$current2, _tagRef$current2$offs;
|
|
140
|
-
setHasTooltip((tagRef === null || tagRef === void 0 ? void 0 : (_tagRef$current = tagRef.current) === null || _tagRef$current === void 0 ? void 0 : _tagRef$current.offsetWidth) + 130 > (tagRef === null || tagRef === void 0 ? void 0 : (_tagRef$current2 = tagRef.current) === null || _tagRef$current2 === void 0 ? void 0 : (_tagRef$current2$offs = _tagRef$current2.offsetParent) === null || _tagRef$current2$offs === void 0 ? void 0 : _tagRef$current2$offs.offsetWidth));
|
|
141
|
-
}, [setHasTooltip, tagRef]);
|
|
142
|
-
const inputChangeHandler = useCallback(e => {
|
|
143
|
-
setInputValue(e.target.value);
|
|
144
|
-
createMode && setActiveTagIndex(null);
|
|
145
|
-
}, [createMode, setActiveTagIndex]);
|
|
146
|
-
useKeyDown(keyDownHandler, [keyDownHandler], createInputRef || inputRef, [keyDownKeys.enter, keyDownKeys.escape, keyDownKeys.arrowLeft, keyDownKeys.arrowRight, keyDownKeys.backspace, keyDownKeys.tab, keyDownKeys.delete]);
|
|
147
|
-
useEffect(dblclickHandler, [createInputRef, tagRef, inputRef, withEdit, isEditMode]);
|
|
148
|
-
useEffect(() => label && setInputValue(label), [label]);
|
|
149
|
-
useEffect(editModeChangeHandler, [editMode, inputRef]);
|
|
150
|
-
useEffect(handleChangeLabel, [tagRef, label]);
|
|
151
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
152
|
-
className: classnames('tag-wrapper', {
|
|
153
|
-
'flex-basis': hasTags
|
|
154
|
-
}),
|
|
155
|
-
ref: tagRef
|
|
156
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
157
|
-
ref: handleOutsideClick
|
|
158
|
-
}, isEditMode ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("input", {
|
|
159
|
-
ref: createInputRef || inputRef,
|
|
160
|
-
onChange: inputChangeHandler,
|
|
161
|
-
onClick: stopEventHandler,
|
|
162
|
-
placeholder: placeholder,
|
|
163
|
-
className: "input",
|
|
164
|
-
value: inputValue
|
|
165
|
-
}), /*#__PURE__*/React__default.createElement("span", null, inputValue.replaceAll(' ', '-'))) : /*#__PURE__*/React__default.createElement("div", {
|
|
166
|
-
ref: isActive ? activeRowRef : null
|
|
167
|
-
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
168
|
-
position: "auto",
|
|
169
|
-
title: hasTooltip ? label : ''
|
|
170
|
-
}, /*#__PURE__*/React__default.createElement(Tag, _extends({}, hasIcon ? {
|
|
171
|
-
icons: /*#__PURE__*/React__default.createElement(Icon, {
|
|
172
|
-
type: "bc-icon-clear-small",
|
|
173
|
-
onClick: () => onDeleteHandler(index)
|
|
174
|
-
})
|
|
175
|
-
} : {}, {
|
|
176
|
-
appearance: isActive ? 'colored' : 'light'
|
|
177
|
-
}, !isValid && {
|
|
178
|
-
color: 'red'
|
|
179
|
-
}, {
|
|
180
|
-
cornerRadius: "smooth-radius",
|
|
181
|
-
onClick: stopEventHandler,
|
|
182
|
-
name: label
|
|
183
|
-
}))))));
|
|
184
|
-
});
|
|
185
|
-
TagWrapper.propTypes = {
|
|
186
|
-
isValid: PropTypes.bool,
|
|
187
|
-
label: PropTypes.string,
|
|
188
|
-
editMode: PropTypes.bool,
|
|
189
|
-
index: PropTypes.number,
|
|
190
|
-
onChangeHandler: PropTypes.func,
|
|
191
|
-
onDeleteHandler: PropTypes.func,
|
|
192
|
-
placeholder: PropTypes.string,
|
|
193
|
-
hasTags: PropTypes.bool,
|
|
194
|
-
hasIcon: PropTypes.bool,
|
|
195
|
-
onKeyPress: PropTypes.func,
|
|
196
|
-
activeTagIndex: PropTypes.number,
|
|
197
|
-
setEditModeIndex: PropTypes.func,
|
|
198
|
-
setActiveTagIndex: PropTypes.func,
|
|
199
|
-
withEdit: PropTypes.bool
|
|
200
|
-
};
|
|
201
|
-
TagWrapper.defaultProps = {
|
|
202
|
-
isValid: false,
|
|
203
|
-
isActive: false
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
var css_248z = "[data-gene-ui-version=\"2.16.4\"] .combo-box{--element-height:4.6rem;--element-min-width:25rem;--message-padding-side:2rem;--input-message-padding-side:2rem;--element-border-color:rgba(var(--background-sc-rgb),0.2);height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;max-width:100%;min-width:var(--element-min-width);position:relative;transition:opacity .3s;-webkit-user-select:none;user-select:none;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}[data-gene-ui-version=\"2.16.4\"] .combo-box.read-only{--element-border-color:rgba(var(--background-sc-rgb),0.05)}[data-gene-ui-version=\"2.16.4\"] .combo-box.filled:not(:focus-within){--element-border-color:rgba(var(--background-sc-rgb),0.3)}[data-gene-ui-version=\"2.16.4\"] .combo-box:not(.read-only):focus-within{--element-border-color:var(--hero)}[data-gene-ui-version=\"2.16.4\"] .combo-box:not(.f-content-size){width:100%}[data-gene-ui-version=\"2.16.4\"] .combo-box.disabled{opacity:.5;pointer-events:none}[data-gene-ui-version=\"2.16.4\"] .combo-box.disabled:not(.read-only):focus-within{--element-border-color:rgba(var(--background-sc-rgb),0.2)}[data-gene-ui-version=\"2.16.4\"] .combo-box.read-only{cursor:inherit}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container{border:1px solid var(--element-border-color,#0000);border-radius:10px;overflow:hidden;width:100%}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .swap-label{display:flex;font:600 1rem/1.8rem var(--font-family);left:0;padding:0 var(--input-message-padding-side);position:absolute;top:-.9rem;width:100%;z-index:5}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .swap-label .icon{font-size:1.8rem;transition:none}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .swap{max-width:100%;overflow:hidden}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .swap-animate{align-items:center;background:var(--background);box-shadow:inset 0 -.8rem 0 var(--input-element-background);color:var(--swap-label-color);display:flex;max-width:100%;padding:0 .4rem;transition:transform .3s,opacity .3s .1s,color .3s}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .swap-animate>*+*{margin-inline-start:.5rem}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .swap-animate.hide{opacity:0;transform:translateY(100%)}[data-gene-ui-version=\"2.16.4\"] .combo-box .combo-box-container .boxes{display:flex;flex-wrap:wrap;gap:8px;min-height:4.2rem;padding:8px 16px}[data-gene-ui-version=\"2.16.4\"] .information-message{cursor:default;font:600 1.2rem/1.42 var(--font-family);margin:.6rem 0 0;padding:0 var(--input-message-padding-side);width:100%}[data-gene-ui-version=\"2.16.4\"] .information-message:empty{display:none}[data-gene-ui-version=\"2.16.4\"] .input-description{cursor:default;font:600 1.4rem/2rem var(--font-family);margin:1rem 0 0;max-width:100%;opacity:.7}[data-gene-ui-version=\"2.16.4\"] .input-structure~.input-description{padding:0 1rem}[data-gene-ui-version=\"2.16.4\"] .title{align-items:center;cursor:default;display:flex;font:600 1.4rem/2rem var(--font-family);margin:0 0 .4rem;max-width:100%;opacity:.5;padding:0 var(--message-padding-side)}[data-gene-ui-version=\"2.16.4\"] .title>*+*{margin-inline-start:.5rem}";
|
|
207
|
-
styleInject(css_248z);
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Combo box
|
|
211
|
-
*/
|
|
212
|
-
function ComboBox(props) {
|
|
213
|
-
const {
|
|
214
|
-
infoIconTooltipProps,
|
|
215
|
-
labelAppearance,
|
|
216
|
-
withInfoIcon,
|
|
217
|
-
flexibility,
|
|
218
|
-
placeholder,
|
|
219
|
-
withDelete,
|
|
220
|
-
className,
|
|
221
|
-
maxHeight,
|
|
222
|
-
required,
|
|
223
|
-
tabIndex,
|
|
224
|
-
onChange,
|
|
225
|
-
readOnly,
|
|
226
|
-
withEdit,
|
|
227
|
-
disabled,
|
|
228
|
-
label,
|
|
229
|
-
regEx
|
|
230
|
-
} = props;
|
|
231
|
-
const inputLabel = label || placeholder;
|
|
232
|
-
const asterisk = required ? '*' : '';
|
|
233
|
-
const isControlled = 'value' in props && props.value;
|
|
234
|
-
const [activeTagIndex, setActiveTagIndex] = useState(null);
|
|
235
|
-
const [editModeIndex, setEditModeIndex] = useState(null);
|
|
236
|
-
const [values, setValues] = useState([]);
|
|
237
|
-
const scrollbarRef = useRef();
|
|
238
|
-
const activeRowRef = useRef();
|
|
239
|
-
const inputRef = useRef();
|
|
240
|
-
const checkIsValid = useCallback(value => regEx ? new RegExp(regEx).test(value) : true, [regEx]);
|
|
241
|
-
const onValueChangeHandler = useCallback(_ref => {
|
|
242
|
-
let {
|
|
243
|
-
label,
|
|
244
|
-
index
|
|
245
|
-
} = _ref;
|
|
246
|
-
const valuesClone = [...values];
|
|
247
|
-
const isValid = checkIsValid(label);
|
|
248
|
-
const added = index === undefined;
|
|
249
|
-
if (added) {
|
|
250
|
-
valuesClone.push({
|
|
251
|
-
label,
|
|
252
|
-
isValid
|
|
253
|
-
});
|
|
254
|
-
} else {
|
|
255
|
-
valuesClone[index].label = label;
|
|
256
|
-
valuesClone[index].isValid = isValid;
|
|
257
|
-
inputRef.current.focus();
|
|
258
|
-
setEditModeIndex(null);
|
|
259
|
-
}
|
|
260
|
-
!isControlled && setValues(valuesClone);
|
|
261
|
-
onChange({
|
|
262
|
-
value: valuesClone,
|
|
263
|
-
additional: {
|
|
264
|
-
type: added ? actionTypes.add : actionTypes.edit,
|
|
265
|
-
index: added ? valuesClone.length - 1 : index,
|
|
266
|
-
isValid,
|
|
267
|
-
label
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}, [values, checkIsValid, isControlled, onChange, setEditModeIndex]);
|
|
271
|
-
const onDeleteHandler = useCallback(index => {
|
|
272
|
-
const valuesClone = [...values];
|
|
273
|
-
const item = valuesClone[index];
|
|
274
|
-
valuesClone.splice(index, 1);
|
|
275
|
-
!isControlled && setValues(valuesClone);
|
|
276
|
-
!valuesClone.length && setActiveTagIndex(null);
|
|
277
|
-
onChange({
|
|
278
|
-
value: valuesClone,
|
|
279
|
-
additional: {
|
|
280
|
-
type: actionTypes.delete,
|
|
281
|
-
index,
|
|
282
|
-
...item
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
inputRef.current && callAfterDelay(() => inputRef.current.focus());
|
|
286
|
-
}, [values, isControlled, onChange, inputRef]);
|
|
287
|
-
const init = useCallback(() => {
|
|
288
|
-
if (isControlled && Array.isArray(props.value)) {
|
|
289
|
-
setValues(props.value.map(row => ({
|
|
290
|
-
...row,
|
|
291
|
-
isValid: checkIsValid(row === null || row === void 0 ? void 0 : row.label)
|
|
292
|
-
})));
|
|
293
|
-
} else if (props.defaultValue && Array.isArray(props.defaultValue)) {
|
|
294
|
-
setValues(props.defaultValue.map(row => ({
|
|
295
|
-
...row,
|
|
296
|
-
isValid: checkIsValid(row === null || row === void 0 ? void 0 : row.label)
|
|
297
|
-
})));
|
|
298
|
-
}
|
|
299
|
-
}, [checkIsValid, isControlled, props.defaultValue, props.value]);
|
|
300
|
-
const handleOutsideClick = useClickOutside(() => {
|
|
301
|
-
scrollbarRef.current.scrollTop(0, 0);
|
|
302
|
-
setActiveTagIndex(null);
|
|
303
|
-
});
|
|
304
|
-
const onClickHandler = useCallback(() => {
|
|
305
|
-
if (disabled || readOnly) return;
|
|
306
|
-
inputRef.current && callAfterDelay(() => inputRef.current.focus());
|
|
307
|
-
}, [disabled, readOnly, inputRef]);
|
|
308
|
-
const onKeyPress = useCallback(type => {
|
|
309
|
-
switch (type) {
|
|
310
|
-
case keyDownKeys.arrowLeft:
|
|
311
|
-
if (values.length && activeTagIndex !== 0) {
|
|
312
|
-
setActiveTagIndex(activeTagIndex === null ? values.length - 1 : activeTagIndex - 1);
|
|
313
|
-
}
|
|
314
|
-
break;
|
|
315
|
-
case keyDownKeys.arrowRight:
|
|
316
|
-
if (values.length && activeTagIndex !== null && activeTagIndex < values.length - 1) {
|
|
317
|
-
setActiveTagIndex(activeTagIndex + 1);
|
|
318
|
-
}
|
|
319
|
-
break;
|
|
320
|
-
case keyDownKeys.delete:
|
|
321
|
-
case keyDownKeys.backspace:
|
|
322
|
-
if (withDelete) {
|
|
323
|
-
if (activeTagIndex !== null) {
|
|
324
|
-
activeTagIndex > 0 && setActiveTagIndex(activeTagIndex - 1);
|
|
325
|
-
onDeleteHandler(activeTagIndex);
|
|
326
|
-
} else if (values.length) {
|
|
327
|
-
onDeleteHandler(values.length - 1);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
}, [activeTagIndex, onDeleteHandler, values.length, withDelete]);
|
|
333
|
-
const onFocusHandler = useCallback(() => {
|
|
334
|
-
var _inputRef$current;
|
|
335
|
-
return editModeIndex === null && !disabled && !readOnly && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus());
|
|
336
|
-
}, [editModeIndex, disabled, readOnly, inputRef]);
|
|
337
|
-
useEffect(init, [props.defaultValue, props.value]);
|
|
338
|
-
useEffect(() => {
|
|
339
|
-
if (activeTagIndex && activeRowRef.current) {
|
|
340
|
-
const scrollbarRefBounding = scrollbarRef.current.container.getBoundingClientRect();
|
|
341
|
-
const activeRowRefBounding = activeRowRef.current.getBoundingClientRect();
|
|
342
|
-
if (scrollbarRefBounding.top > activeRowRefBounding.top - SPACE_HEIGHT) {
|
|
343
|
-
scrollbarRef.current.scrollTop(scrollbarRef.current.viewScrollTop - activeRowRefBounding.height - SPACE_HEIGHT);
|
|
344
|
-
} else if (activeRowRefBounding.top + activeRowRefBounding.height + SPACE_HEIGHT > scrollbarRefBounding.top + maxHeight) {
|
|
345
|
-
scrollbarRef.current.scrollTop(scrollbarRef.current.viewScrollTop + activeRowRefBounding.height + SPACE_HEIGHT);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}, [activeTagIndex, scrollbarRef]);
|
|
349
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
350
|
-
onFocus: onFocusHandler,
|
|
351
|
-
ref: handleOutsideClick,
|
|
352
|
-
tabIndex: tabIndex,
|
|
353
|
-
className: classnames('combo-box', "f-".concat(flexibility), className, {
|
|
354
|
-
'read-only': readOnly,
|
|
355
|
-
disabled
|
|
356
|
-
})
|
|
357
|
-
}, labelAppearance === inputConfig.labelAppearance[1] && /*#__PURE__*/React__default.createElement("div", {
|
|
358
|
-
className: "title ellipsis-text"
|
|
359
|
-
}, /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
360
|
-
position: "auto"
|
|
361
|
-
}, infoIconTooltipProps), /*#__PURE__*/React__default.createElement("span", {
|
|
362
|
-
className: "ellipsis-text"
|
|
363
|
-
}, asterisk, " ", inputLabel)), withInfoIcon && /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
364
|
-
position: "auto"
|
|
365
|
-
}, infoIconTooltipProps), /*#__PURE__*/React__default.createElement(Icon, {
|
|
366
|
-
type: "bc-icon-info"
|
|
367
|
-
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
368
|
-
className: "combo-box-container",
|
|
369
|
-
onClick: onClickHandler
|
|
370
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
371
|
-
className: "element-back"
|
|
372
|
-
}, labelAppearance === inputConfig.labelAppearance[2] && /*#__PURE__*/React__default.createElement("div", {
|
|
373
|
-
className: "swap-label"
|
|
374
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
375
|
-
className: "swap"
|
|
376
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
377
|
-
className: classnames('input-swap-animate ellipsis-text', {
|
|
378
|
-
hide: !values.length
|
|
379
|
-
})
|
|
380
|
-
}, /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
381
|
-
position: "auto"
|
|
382
|
-
}, infoIconTooltipProps), /*#__PURE__*/React__default.createElement("span", {
|
|
383
|
-
className: "ellipsis-text"
|
|
384
|
-
}, asterisk, " ", inputLabel)), withInfoIcon && /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
385
|
-
position: "auto"
|
|
386
|
-
}, infoIconTooltipProps), /*#__PURE__*/React__default.createElement(Icon, {
|
|
387
|
-
type: "bc-icon-info"
|
|
388
|
-
})))))), /*#__PURE__*/React__default.createElement("div", {
|
|
389
|
-
className: classnames({
|
|
390
|
-
'pointer-events-none': disabled || readOnly
|
|
391
|
-
})
|
|
392
|
-
}, /*#__PURE__*/React__default.createElement(CustomScrollbar, {
|
|
393
|
-
autoHeight: true,
|
|
394
|
-
autoHeightMax: maxHeight,
|
|
395
|
-
ref: scrollbarRef
|
|
396
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
397
|
-
className: "boxes"
|
|
398
|
-
}, values.map((value, index) => /*#__PURE__*/React__default.createElement(TagWrapper, _extends({
|
|
399
|
-
key: "".concat(JSON.stringify(value)).concat(index),
|
|
400
|
-
onChangeHandler: onValueChangeHandler,
|
|
401
|
-
setActiveTagIndex: setActiveTagIndex,
|
|
402
|
-
setEditModeIndex: setEditModeIndex,
|
|
403
|
-
editMode: editModeIndex === index,
|
|
404
|
-
hasIcon: !readOnly && withDelete,
|
|
405
|
-
onDeleteHandler: onDeleteHandler,
|
|
406
|
-
activeTagIndex: activeTagIndex,
|
|
407
|
-
activeRowRef: activeRowRef,
|
|
408
|
-
onKeyPress: onKeyPress,
|
|
409
|
-
ref: {
|
|
410
|
-
activeRowRef
|
|
411
|
-
},
|
|
412
|
-
withEdit: withEdit,
|
|
413
|
-
hasTags: true,
|
|
414
|
-
index: index
|
|
415
|
-
}, value))), withEdit && !disabled && !readOnly && /*#__PURE__*/React__default.createElement(TagWrapper, {
|
|
416
|
-
placeholder: !values.length ? placeholder : '',
|
|
417
|
-
onChangeHandler: onValueChangeHandler,
|
|
418
|
-
setActiveTagIndex: setActiveTagIndex,
|
|
419
|
-
setEditModeIndex: setEditModeIndex,
|
|
420
|
-
activeTagIndex: activeTagIndex,
|
|
421
|
-
hasTags: !!values.length,
|
|
422
|
-
onKeyPress: onKeyPress,
|
|
423
|
-
withEdit: withEdit,
|
|
424
|
-
editMode: true,
|
|
425
|
-
ref: {
|
|
426
|
-
createInputRef: inputRef
|
|
427
|
-
}
|
|
428
|
-
}))))));
|
|
429
|
-
}
|
|
430
|
-
ComboBox.propTypes = {
|
|
431
|
-
/**
|
|
432
|
-
* Additional className
|
|
433
|
-
*/
|
|
434
|
-
className: PropTypes.string,
|
|
435
|
-
/**
|
|
436
|
-
* Specify a "label" appearance
|
|
437
|
-
*/
|
|
438
|
-
labelAppearance: PropTypes.oneOf(inputConfig.labelAppearance),
|
|
439
|
-
/**
|
|
440
|
-
* How to display inscription in relation to it's parent in ExtendedInput
|
|
441
|
-
*/
|
|
442
|
-
flexibility: PropTypes.oneOf(inputConfig.flexibility),
|
|
443
|
-
/**
|
|
444
|
-
* Define is input required or no.
|
|
445
|
-
*/
|
|
446
|
-
required: PropTypes.bool,
|
|
447
|
-
/**
|
|
448
|
-
* Define is need input info icon required.
|
|
449
|
-
*/
|
|
450
|
-
withInfoIcon: PropTypes.bool,
|
|
451
|
-
/**
|
|
452
|
-
* Tooltip props
|
|
453
|
-
*/
|
|
454
|
-
infoIconTooltipProps: PropTypes.shape({
|
|
455
|
-
...Tooltip.propTypes
|
|
456
|
-
}),
|
|
457
|
-
/**
|
|
458
|
-
* validation regex
|
|
459
|
-
*/
|
|
460
|
-
regEx: PropTypes.string,
|
|
461
|
-
/**
|
|
462
|
-
* On change handler
|
|
463
|
-
*/
|
|
464
|
-
onChange: PropTypes.func,
|
|
465
|
-
/**
|
|
466
|
-
* Use this prop to get specified value when "onChange" is fired
|
|
467
|
-
*/
|
|
468
|
-
value: PropTypes.arrayOf(PropTypes.shape({
|
|
469
|
-
label: PropTypes.string
|
|
470
|
-
})),
|
|
471
|
-
/**
|
|
472
|
-
* Initial Combobox value.
|
|
473
|
-
*/
|
|
474
|
-
defaultValue: PropTypes.arrayOf(PropTypes.shape({
|
|
475
|
-
label: PropTypes.string
|
|
476
|
-
})),
|
|
477
|
-
/**
|
|
478
|
-
* Combobox disabled state
|
|
479
|
-
*/
|
|
480
|
-
disabled: PropTypes.bool,
|
|
481
|
-
/**
|
|
482
|
-
* Combobox readOnly state
|
|
483
|
-
*/
|
|
484
|
-
readOnly: PropTypes.bool,
|
|
485
|
-
/**
|
|
486
|
-
* Is Combobox in edit mode
|
|
487
|
-
*/
|
|
488
|
-
withEdit: PropTypes.bool,
|
|
489
|
-
/**
|
|
490
|
-
* Can Delete tags
|
|
491
|
-
*/
|
|
492
|
-
withDelete: PropTypes.bool,
|
|
493
|
-
/**
|
|
494
|
-
* Max height of Combobox
|
|
495
|
-
*/
|
|
496
|
-
maxHeight: PropTypes.number,
|
|
497
|
-
/**
|
|
498
|
-
* Since the editor has its own modal windows, there may be a problem with
|
|
499
|
-
* the zIndex so you can change it using this prop
|
|
500
|
-
*/
|
|
501
|
-
tabIndex: PropTypes.number
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
// toDo Add validation scheme fot form
|
|
505
|
-
ComboBox.defaultProps = {
|
|
506
|
-
labelAppearance: inputConfig.labelAppearance[0],
|
|
507
|
-
flexibility: inputConfig.flexibility[0],
|
|
508
|
-
label: '',
|
|
509
|
-
placeholder: '',
|
|
510
|
-
onChange: noop,
|
|
511
|
-
regEx: '',
|
|
512
|
-
withInfoIcon: false,
|
|
513
|
-
required: false,
|
|
514
|
-
disabled: false,
|
|
515
|
-
readOnly: false,
|
|
516
|
-
withEdit: true,
|
|
517
|
-
withDelete: true,
|
|
518
|
-
maxHeight: 510,
|
|
519
|
-
tabIndex: 0,
|
|
520
|
-
infoIconTooltipProps: {}
|
|
521
|
-
};
|
|
522
|
-
ComboBox.displayName = 'ComboBox';
|
|
523
|
-
|
|
524
|
-
export { ComboBox as default };
|
package/Copy/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useMemo, useCallback } from 'react';
|
|
2
|
-
import { c as classnames } from '../index-031ff73c.js';
|
|
3
|
-
import 'prop-types';
|
|
4
|
-
import '../dateValidation-67caec66.js';
|
|
5
|
-
import { c as callAfterDelay } from '../callAfterDelay-7272faca.js';
|
|
6
|
-
import '../configs-00612ce0.js';
|
|
7
|
-
import useHover from '../hooks/useHover.js';
|
|
8
|
-
import Icon from '../Icon/index.js';
|
|
9
|
-
import { T as Tooltip } from '../index-c7646e48.js';
|
|
10
|
-
import { s as styleInject } from '../style-inject.es-746bb8ed.js';
|
|
11
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
12
|
-
import 'react-dom';
|
|
13
|
-
import '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
14
|
-
import '../tslib.es6-f211516f.js';
|
|
15
|
-
import '../GeneUIProvider/index.js';
|
|
16
|
-
|
|
17
|
-
var css_248z = "[data-gene-ui-version=\"2.16.4\"] .copy{cursor:pointer;max-height:-webkit-fit-content;max-height:-moz-fit-content;max-height:fit-content;max-width:-webkit-fit-content;max-width:-moz-fit-content;max-width:fit-content}[data-gene-ui-version=\"2.16.4\"] .copy-controlVisibility{visibility:hidden}[data-gene-ui-version=\"2.16.4\"] .copy-pointerNon{cursor:auto}[data-gene-ui-version=\"2.16.4\"] .copy-isVisible{visibility:visible}[data-gene-ui-version=\"2.16.4\"] .copy__showOnHover{visibility:hidden}[data-gene-ui-version=\"2.16.4\"] .copy__showOnHover-show{visibility:visible}[data-gene-ui-version=\"2.16.4\"] .copy__icon{max-height:-webkit-fit-content;max-height:-moz-fit-content;max-height:fit-content;max-width:-webkit-fit-content;max-width:-moz-fit-content;max-width:fit-content}[data-gene-ui-version=\"2.16.4\"] .copy__icon-big{font-size:3.2rem}[data-gene-ui-version=\"2.16.4\"] .copy__icon-small{font-size:1.4rem}[data-gene-ui-version=\"2.16.4\"] .copy:hover{visibility:visible}";
|
|
18
|
-
styleInject(css_248z);
|
|
19
|
-
|
|
20
|
-
const Copy = ({ size, value, isVisible, className, contentRef, showOnHover, copyTooltipText, copiedTooltipText }) => {
|
|
21
|
-
const [isCopied, setIsCopied] = useState(false);
|
|
22
|
-
const isControlledVisibility = useMemo(() => isVisible !== undefined, [isVisible]);
|
|
23
|
-
const isHovered = contentRef ? useHover(contentRef) : false;
|
|
24
|
-
const copyContent = useCallback((e) => {
|
|
25
|
-
var _a;
|
|
26
|
-
e.stopPropagation();
|
|
27
|
-
if (isCopied)
|
|
28
|
-
return;
|
|
29
|
-
const content = ((_a = contentRef === null || contentRef === void 0 ? void 0 : contentRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || value;
|
|
30
|
-
if (!content)
|
|
31
|
-
return;
|
|
32
|
-
navigator.clipboard
|
|
33
|
-
.writeText(content)
|
|
34
|
-
.then(() => {
|
|
35
|
-
setIsCopied(true);
|
|
36
|
-
callAfterDelay(() => {
|
|
37
|
-
setIsCopied(false);
|
|
38
|
-
}, 2000);
|
|
39
|
-
})
|
|
40
|
-
.catch((error) => console.error('Failed to copy:', error));
|
|
41
|
-
}, [contentRef, isCopied, value]);
|
|
42
|
-
return (
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
React__default.createElement(Tooltip, { title: isCopied ? copiedTooltipText : copyTooltipText, isVisible: true },
|
|
45
|
-
React__default.createElement("div", { className: classnames('copy', className, Object.assign({ copy__showOnHover: showOnHover && !value, 'copy__showOnHover-show': isHovered && !value && !isControlledVisibility, 'copy-pointerNon': isCopied, 'copy-controlVisibility': isControlledVisibility }, (isControlledVisibility ? { 'copy-isVisible': isVisible } : {}))), onClick: copyContent },
|
|
46
|
-
React__default.createElement(Icon, { className: `copy__icon copy__icon-${size}`, type: isCopied ? 'bc-icon-checkbox-checked' : 'bc-icon-copy-mirror' }))));
|
|
47
|
-
};
|
|
48
|
-
Copy.defaultProps = {
|
|
49
|
-
size: 'medium',
|
|
50
|
-
showOnHover: false,
|
|
51
|
-
copyTooltipText: 'Copy',
|
|
52
|
-
copiedTooltipText: 'Copied!'
|
|
53
|
-
};
|
|
54
|
-
Copy.displayName = 'Copy';
|
|
55
|
-
|
|
56
|
-
export { Copy as default };
|