@geneui/components 3.0.0-next-9ffcb93-16102024 → 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/CHANGELOG.md +7 -0
- package/Divider.js +23 -0
- package/{GeneUIProvider/index.js → GeneUIProvider.js} +52 -65
- 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-65217440.js → Tooltip.js} +104 -80
- 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-80be385d.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-78c2617e.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-2f5aa51e.js +0 -6483
- package/index-370f9acd.js +0 -4
- package/index-45eafea6.js +0 -90
- package/index-480fd7d9.js +0 -10032
- package/index-5f37f281.js +0 -168
- package/index-73aaa093.js +0 -1940
- 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-693a3d41.js +0 -8684
- package/react-beautiful-dnd.esm-b637016a.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
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
2
|
-
import React__default, { forwardRef, useState, useCallback, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { n as noop, i as interceptValue } from '../index-5f37f281.js';
|
|
5
|
-
import useMount from '../hooks/useMount.js';
|
|
6
|
-
import '../configs-00612ce0.js';
|
|
7
|
-
import Checkbox from '../Checkbox/index.js';
|
|
8
|
-
import '../dateValidation-67caec66.js';
|
|
9
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
10
|
-
import 'react-dom';
|
|
11
|
-
import '../index-031ff73c.js';
|
|
12
|
-
import '../index-65217440.js';
|
|
13
|
-
import '../tslib.es6-f211516f.js';
|
|
14
|
-
import '../GeneUIProvider/index.js';
|
|
15
|
-
import '../style-inject.es-746bb8ed.js';
|
|
16
|
-
import '../checkboxRadioSwitcher-5b69d7bd.js';
|
|
17
|
-
import '../guid-8ddf77b3.js';
|
|
18
|
-
|
|
19
|
-
function checkValidation(required, isValid, checked) {
|
|
20
|
-
if (isValid === false) return {
|
|
21
|
-
key: 'customValidation',
|
|
22
|
-
isValid: false
|
|
23
|
-
};
|
|
24
|
-
if (required && !checked) return {
|
|
25
|
-
key: 'required',
|
|
26
|
-
isValid: false
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
key: null,
|
|
30
|
-
isValid: true
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const CheckboxField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
34
|
-
const {
|
|
35
|
-
onChange,
|
|
36
|
-
value,
|
|
37
|
-
isValid,
|
|
38
|
-
required,
|
|
39
|
-
isFieldValid,
|
|
40
|
-
forceAllowValidation,
|
|
41
|
-
...restProps
|
|
42
|
-
} = props;
|
|
43
|
-
const isControlled = 'value' in props && typeof value !== 'undefined';
|
|
44
|
-
const [validationState, setValidationState] = useState(true);
|
|
45
|
-
const [checked, setChecked] = useState(false);
|
|
46
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
47
|
-
const validate = useCallback(() => checkValidation(required, isValid, checked).isValid, [checked, required, isValid]);
|
|
48
|
-
const handleChange = useCallback(e => {
|
|
49
|
-
const {
|
|
50
|
-
checked
|
|
51
|
-
} = e.target;
|
|
52
|
-
const {
|
|
53
|
-
isValid: isCheckboxValid,
|
|
54
|
-
key
|
|
55
|
-
} = checkValidation(required, isValid, checked);
|
|
56
|
-
setValidationState(isCheckboxValid);
|
|
57
|
-
setChecked(checked);
|
|
58
|
-
onChange(interceptValue(e, value), isCheckboxValid, key);
|
|
59
|
-
}, [onChange, required, isValid]);
|
|
60
|
-
|
|
61
|
-
// we use this because need to show field validation after onBlur
|
|
62
|
-
const onBlur = useCallback(() => setAllowValidation(true), []);
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
isControlled && setValidationState(validate());
|
|
65
|
-
}, [isControlled, validate]);
|
|
66
|
-
|
|
67
|
-
// need this for handling user's `isValid` prop
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
setValidationState(isValid);
|
|
70
|
-
}, [isValid]);
|
|
71
|
-
|
|
72
|
-
// call function when validation state changes
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
isFieldValid(validationState);
|
|
75
|
-
}, [validationState]);
|
|
76
|
-
|
|
77
|
-
// set Allow validation true if submit button clicked
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
forceAllowValidation && setAllowValidation(true);
|
|
80
|
-
}, [forceAllowValidation]);
|
|
81
|
-
useMount(() => setValidationState(validate()));
|
|
82
|
-
return /*#__PURE__*/React__default.createElement(Checkbox, _extends({
|
|
83
|
-
required: required,
|
|
84
|
-
ref: ref,
|
|
85
|
-
value: value,
|
|
86
|
-
isValid: !allowValidation || validationState,
|
|
87
|
-
onChange: handleChange,
|
|
88
|
-
onBlur: onBlur
|
|
89
|
-
}, restProps));
|
|
90
|
-
});
|
|
91
|
-
CheckboxField.propTypes = {
|
|
92
|
-
/**
|
|
93
|
-
* Value for checkbox
|
|
94
|
-
*/
|
|
95
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
96
|
-
/**
|
|
97
|
-
* Callback fires when checkbox changes
|
|
98
|
-
*/
|
|
99
|
-
onChange: PropTypes.func,
|
|
100
|
-
/**
|
|
101
|
-
* Define is field required or no.
|
|
102
|
-
*/
|
|
103
|
-
required: PropTypes.bool,
|
|
104
|
-
/**
|
|
105
|
-
* Callback fires when field validation state changes
|
|
106
|
-
*/
|
|
107
|
-
isFieldValid: PropTypes.func,
|
|
108
|
-
/**
|
|
109
|
-
* Additional validation state
|
|
110
|
-
*/
|
|
111
|
-
isValid: PropTypes.bool,
|
|
112
|
-
/**
|
|
113
|
-
* Allow validation without onBlur, validate field when mount
|
|
114
|
-
*/
|
|
115
|
-
forceAllowValidation: PropTypes.bool
|
|
116
|
-
};
|
|
117
|
-
CheckboxField.defaultProps = {
|
|
118
|
-
isValid: true,
|
|
119
|
-
isFieldValid: noop,
|
|
120
|
-
onChange: noop
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export { CheckboxField as default };
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
2
|
-
import React__default, { forwardRef, useCallback, useState, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { n as noop } from '../index-5f37f281.js';
|
|
5
|
-
import useMount from '../hooks/useMount.js';
|
|
6
|
-
import '../configs-00612ce0.js';
|
|
7
|
-
import DatePickerInput from '../DatePickerInput/index.js';
|
|
8
|
-
import { d as dayjsWithPlugins, v as validateDatePickerField } from '../dateValidation-67caec66.js';
|
|
9
|
-
import { c as checkTimeValidation } from '../checkTimeValidation-e56771be.js';
|
|
10
|
-
import { g as getBrowserDateFormat } from '../localization-4ba17032.js';
|
|
11
|
-
import 'react-dom';
|
|
12
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
13
|
-
import '../style-inject.es-746bb8ed.js';
|
|
14
|
-
import '../index-031ff73c.js';
|
|
15
|
-
import '../hooks/useClick.js';
|
|
16
|
-
import '../hooks/useKeyDown.js';
|
|
17
|
-
import '../hooks/useDeviceType.js';
|
|
18
|
-
import '../hooks/useWindowSize.js';
|
|
19
|
-
import '../hooks/useDebounce.js';
|
|
20
|
-
import '../index-73aaa093.js';
|
|
21
|
-
import '../index-122432cd.js';
|
|
22
|
-
import '../hooks/useClickOutside.js';
|
|
23
|
-
import '../Scrollbar/index.js';
|
|
24
|
-
import '../GeneUIProvider/index.js';
|
|
25
|
-
import '../debounce-4419bc2f.js';
|
|
26
|
-
import '../ExtendedInput/index.js';
|
|
27
|
-
import '../useEllipsisDetection-c1c9ad94.js';
|
|
28
|
-
import '../Icon/index.js';
|
|
29
|
-
import '../SuggestionList/index.js';
|
|
30
|
-
import '../config-1053d64d.js';
|
|
31
|
-
import '../callAfterDelay-7272faca.js';
|
|
32
|
-
import '../index-65217440.js';
|
|
33
|
-
import '../tslib.es6-f211516f.js';
|
|
34
|
-
import '../DatePicker/index.js';
|
|
35
|
-
import '../guid-8ddf77b3.js';
|
|
36
|
-
import '../Button/index.js';
|
|
37
|
-
|
|
38
|
-
const nonLettersRegex = /[\W_]+/g;
|
|
39
|
-
const hourFormats = ['H', 'HH', 'h', 'hh'];
|
|
40
|
-
const minuteFormats = ['m', 'mm'];
|
|
41
|
-
const secondFormats = ['s', 'ss'];
|
|
42
|
-
const getFormatSeparator = format => format[format.search(nonLettersRegex)];
|
|
43
|
-
|
|
44
|
-
/*
|
|
45
|
-
* Splitting time to { format, value } object
|
|
46
|
-
* For checking is value fit format
|
|
47
|
-
* Formats are taken from day.js date formats list
|
|
48
|
-
* */
|
|
49
|
-
function splitTimeToObjects(dateParts, formatParts) {
|
|
50
|
-
const hour = {};
|
|
51
|
-
const minute = {};
|
|
52
|
-
const second = {};
|
|
53
|
-
formatParts.forEach((item, index) => {
|
|
54
|
-
if (hourFormats.includes(item)) {
|
|
55
|
-
hour.value = dateParts[index];
|
|
56
|
-
hour.format = item;
|
|
57
|
-
} else if (minuteFormats.includes(item)) {
|
|
58
|
-
minute.value = dateParts[index];
|
|
59
|
-
minute.format = item;
|
|
60
|
-
} else if (secondFormats.includes(item)) {
|
|
61
|
-
second.value = dateParts[index];
|
|
62
|
-
second.format = item;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
hour,
|
|
67
|
-
minute,
|
|
68
|
-
second
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const isHourInRightFormat = _ref => {
|
|
72
|
-
let {
|
|
73
|
-
value,
|
|
74
|
-
format
|
|
75
|
-
} = _ref;
|
|
76
|
-
return value && ((format === 'H' || format === 'h') && value.length <= 2 && Number(value[0]) !== 0 || (format === 'HH' || format === 'hh') && value.length === 2);
|
|
77
|
-
};
|
|
78
|
-
const isMinuteInRightFormat = _ref2 => {
|
|
79
|
-
let {
|
|
80
|
-
value,
|
|
81
|
-
format
|
|
82
|
-
} = _ref2;
|
|
83
|
-
return value && (format === 'm' && value.length <= 2 && (value.length !== 2 || Number(value[0]) !== 0) || format === 'mm' && value.length === 2);
|
|
84
|
-
};
|
|
85
|
-
const isSecondInRightFormat = _ref3 => {
|
|
86
|
-
let {
|
|
87
|
-
value,
|
|
88
|
-
format
|
|
89
|
-
} = _ref3;
|
|
90
|
-
return !format || value && (format === 's' && value.length <= 2 && (value.length !== 2 || Number(value[0]) !== 0) || format === 'ss' && value.length === 2);
|
|
91
|
-
};
|
|
92
|
-
const checkTimeFormat = _ref4 => {
|
|
93
|
-
let {
|
|
94
|
-
hour,
|
|
95
|
-
minute,
|
|
96
|
-
second
|
|
97
|
-
} = _ref4;
|
|
98
|
-
return isHourInRightFormat(hour) && isMinuteInRightFormat(minute) && isSecondInRightFormat(second);
|
|
99
|
-
};
|
|
100
|
-
function validateTimeField(value, required, isValid, min, max, format) {
|
|
101
|
-
const time = value ? dayjsWithPlugins(value).format(format).split(' ')[1] : '';
|
|
102
|
-
const timeFormat = format ? format.split(' ')[1] : '';
|
|
103
|
-
const date = dayjsWithPlugins(value);
|
|
104
|
-
const separator = getFormatSeparator(timeFormat);
|
|
105
|
-
const dateParts = time.split(separator);
|
|
106
|
-
const formatParts = timeFormat.split(separator);
|
|
107
|
-
const timeObject = splitTimeToObjects(dateParts, formatParts);
|
|
108
|
-
const isValidFormat = checkTimeFormat(timeObject);
|
|
109
|
-
const isValidDate = checkTimeValidation(timeObject);
|
|
110
|
-
const isBefore = !max || date.isBefore(dayjsWithPlugins(max, format));
|
|
111
|
-
const isAfter = !min || date.isAfter(dayjsWithPlugins(min, format));
|
|
112
|
-
if (!time.length) {
|
|
113
|
-
return required ? {
|
|
114
|
-
key: 'required',
|
|
115
|
-
isValid: false
|
|
116
|
-
} : {
|
|
117
|
-
key: null,
|
|
118
|
-
isValid: true
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (!isValidFormat) return {
|
|
122
|
-
key: 'isValidFormat',
|
|
123
|
-
isValid: false
|
|
124
|
-
};
|
|
125
|
-
if (!isValidDate) return {
|
|
126
|
-
key: 'isValidDate',
|
|
127
|
-
isValid: false
|
|
128
|
-
};
|
|
129
|
-
if (!isBefore) return {
|
|
130
|
-
key: 'isBefore',
|
|
131
|
-
isValid: false
|
|
132
|
-
};
|
|
133
|
-
if (!isAfter) return {
|
|
134
|
-
key: 'isAfter',
|
|
135
|
-
isValid: false
|
|
136
|
-
};
|
|
137
|
-
if (!isValid) return {
|
|
138
|
-
key: 'customValidation',
|
|
139
|
-
isValid: false
|
|
140
|
-
};
|
|
141
|
-
return {
|
|
142
|
-
key: null,
|
|
143
|
-
isValid: true
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function validateTimePickerField(required, isValid, min, max, format) {
|
|
147
|
-
let value = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
|
|
148
|
-
if (typeof value === 'string') {
|
|
149
|
-
return validateTimeField(value, required, isValid, min, max, format);
|
|
150
|
-
}
|
|
151
|
-
const [start, end] = value;
|
|
152
|
-
const startDateValidation = validateTimeField(start || '', required, isValid, min, max, format);
|
|
153
|
-
const endDateValidation = validateTimeField(end || '', required, isValid, min, max, format);
|
|
154
|
-
const isRangeInvalid = dayjsWithPlugins(start, format).isAfter(dayjsWithPlugins(end, format));
|
|
155
|
-
if (!startDateValidation.isValid) return startDateValidation;
|
|
156
|
-
if (!endDateValidation.isValid) return endDateValidation;
|
|
157
|
-
if (isRangeInvalid) return {
|
|
158
|
-
key: 'isValidRange',
|
|
159
|
-
isValid: false
|
|
160
|
-
};
|
|
161
|
-
return {
|
|
162
|
-
key: null,
|
|
163
|
-
isValid: true
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const EMPTY_OBJECT = {};
|
|
168
|
-
const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
169
|
-
let {
|
|
170
|
-
onChange,
|
|
171
|
-
value,
|
|
172
|
-
isValid,
|
|
173
|
-
required,
|
|
174
|
-
isFieldValid,
|
|
175
|
-
withRange,
|
|
176
|
-
min,
|
|
177
|
-
max,
|
|
178
|
-
format,
|
|
179
|
-
withTime,
|
|
180
|
-
onBlur,
|
|
181
|
-
forceAllowValidation,
|
|
182
|
-
...restProps
|
|
183
|
-
} = _ref;
|
|
184
|
-
const localValue = value || (withRange ? [null, null] : null);
|
|
185
|
-
const checkValidation = useCallback(value => {
|
|
186
|
-
const validFormat = format || getBrowserDateFormat(!!withTime);
|
|
187
|
-
// We need null, because other values `dayjs` turns to valid date
|
|
188
|
-
const formatted = withRange ? [value[0] || null, value[1] || null] : value;
|
|
189
|
-
const {
|
|
190
|
-
isValid: isValidDate,
|
|
191
|
-
key: dateKey
|
|
192
|
-
} = validateDatePickerField(formatted, required, isValid, min, max, validFormat);
|
|
193
|
-
const {
|
|
194
|
-
isValid: isValidTime = true,
|
|
195
|
-
key: timeKey = null
|
|
196
|
-
} = !withTime || !validFormat.split(' ')[1] ? EMPTY_OBJECT : validateTimePickerField(required, isValid, min, max, validFormat, formatted);
|
|
197
|
-
return {
|
|
198
|
-
isValid: isValidDate && isValidTime,
|
|
199
|
-
key: dateKey || timeKey || null
|
|
200
|
-
};
|
|
201
|
-
}, [required, isValid, min, max, format, withTime, withRange]);
|
|
202
|
-
const [validationState, setValidationState] = useState(true);
|
|
203
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
204
|
-
const handleChange = useCallback(value => {
|
|
205
|
-
const validation = checkValidation(value);
|
|
206
|
-
setValidationState(validation.isValid);
|
|
207
|
-
onChange && onChange(value, validation.isValid, validation.key);
|
|
208
|
-
}, [checkValidation, onChange]);
|
|
209
|
-
|
|
210
|
-
// we use this because need to show field validation after onBlur
|
|
211
|
-
const onClickOutside = useCallback(() => setAllowValidation(true), []);
|
|
212
|
-
const handleBlur = useCallback(e => {
|
|
213
|
-
setAllowValidation(true);
|
|
214
|
-
onBlur(e);
|
|
215
|
-
}, [onBlur]);
|
|
216
|
-
useEffect(() => {
|
|
217
|
-
setValidationState(checkValidation(localValue).isValid);
|
|
218
|
-
}, [localValue, required, min, max]);
|
|
219
|
-
|
|
220
|
-
// need this for handling user's `isValid` prop
|
|
221
|
-
useEffect(() => {
|
|
222
|
-
setValidationState(isValid);
|
|
223
|
-
}, [isValid]);
|
|
224
|
-
|
|
225
|
-
// call function when validation state changes
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
isFieldValid(validationState);
|
|
228
|
-
}, [validationState]);
|
|
229
|
-
|
|
230
|
-
// set Allow validation true if submit button clicked
|
|
231
|
-
useEffect(() => {
|
|
232
|
-
forceAllowValidation && setAllowValidation(true);
|
|
233
|
-
}, [forceAllowValidation]);
|
|
234
|
-
useMount(() => setValidationState(checkValidation(localValue).isValid));
|
|
235
|
-
return withRange ? /*#__PURE__*/React__default.createElement(DatePickerInput.WithRange, _extends({
|
|
236
|
-
ref: ref,
|
|
237
|
-
min: min,
|
|
238
|
-
max: max,
|
|
239
|
-
value: value,
|
|
240
|
-
isValid: !allowValidation || validationState,
|
|
241
|
-
onChange: handleChange,
|
|
242
|
-
format: format,
|
|
243
|
-
onClickOutside: onClickOutside,
|
|
244
|
-
withTime: withTime,
|
|
245
|
-
required: required,
|
|
246
|
-
onBlur: handleBlur
|
|
247
|
-
}, restProps)) : /*#__PURE__*/React__default.createElement(DatePickerInput, _extends({
|
|
248
|
-
ref: ref,
|
|
249
|
-
min: min,
|
|
250
|
-
max: max,
|
|
251
|
-
value: value,
|
|
252
|
-
isValid: !allowValidation || validationState,
|
|
253
|
-
onChange: handleChange,
|
|
254
|
-
format: format,
|
|
255
|
-
onClickOutside: onClickOutside,
|
|
256
|
-
required: required,
|
|
257
|
-
onBlur: handleBlur
|
|
258
|
-
}, restProps));
|
|
259
|
-
});
|
|
260
|
-
DatePicker.propTypes = {
|
|
261
|
-
/**
|
|
262
|
-
* Value for date picker
|
|
263
|
-
*/
|
|
264
|
-
value: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]),
|
|
265
|
-
/**
|
|
266
|
-
* Callback fires when date changes
|
|
267
|
-
*/
|
|
268
|
-
onChange: PropTypes.func,
|
|
269
|
-
/**
|
|
270
|
-
* Callback fires when input blur
|
|
271
|
-
*/
|
|
272
|
-
onBlur: PropTypes.func,
|
|
273
|
-
/**
|
|
274
|
-
* Define is field required or no.
|
|
275
|
-
*/
|
|
276
|
-
required: PropTypes.bool,
|
|
277
|
-
/**
|
|
278
|
-
* Define is range picker with time or no
|
|
279
|
-
*/
|
|
280
|
-
withTime: PropTypes.bool,
|
|
281
|
-
/**
|
|
282
|
-
* Define is single date picker or with range
|
|
283
|
-
*/
|
|
284
|
-
withRange: PropTypes.bool,
|
|
285
|
-
/**
|
|
286
|
-
* Callback fires when field validation state changes
|
|
287
|
-
*/
|
|
288
|
-
isFieldValid: PropTypes.func,
|
|
289
|
-
/**
|
|
290
|
-
* Additional validation state
|
|
291
|
-
*/
|
|
292
|
-
isValid: PropTypes.bool,
|
|
293
|
-
/**
|
|
294
|
-
* Minimum date value
|
|
295
|
-
*/
|
|
296
|
-
min: PropTypes.string,
|
|
297
|
-
/**
|
|
298
|
-
* Maximum date value
|
|
299
|
-
*/
|
|
300
|
-
max: PropTypes.string,
|
|
301
|
-
/**
|
|
302
|
-
* Date format
|
|
303
|
-
*/
|
|
304
|
-
format: PropTypes.string,
|
|
305
|
-
/**
|
|
306
|
-
* Allow validation without onBlur, validate field when mount
|
|
307
|
-
*/
|
|
308
|
-
forceAllowValidation: PropTypes.bool
|
|
309
|
-
};
|
|
310
|
-
DatePicker.defaultProps = {
|
|
311
|
-
isValid: true,
|
|
312
|
-
onBlur: noop,
|
|
313
|
-
isFieldValid: noop
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export { DatePicker as default };
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
2
|
-
import React__default, { forwardRef, useState, useCallback, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import useMount from '../hooks/useMount.js';
|
|
5
|
-
import '../configs-00612ce0.js';
|
|
6
|
-
import { n as noop } from '../index-5f37f281.js';
|
|
7
|
-
import { D as Dropdown } from '../index-480fd7d9.js';
|
|
8
|
-
import '../dateValidation-67caec66.js';
|
|
9
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
10
|
-
import 'react-dom';
|
|
11
|
-
import '../objectWithoutPropertiesLoose-e1596bdb.js';
|
|
12
|
-
import '../react-lifecycles-compat.es-6e1f3768.js';
|
|
13
|
-
import '../clsx.m-2bb6df4b.js';
|
|
14
|
-
import '../index-031ff73c.js';
|
|
15
|
-
import '../hooks/useClick.js';
|
|
16
|
-
import '../hooks/useKeyDown.js';
|
|
17
|
-
import '../hooks/useDeviceType.js';
|
|
18
|
-
import '../hooks/useWindowSize.js';
|
|
19
|
-
import '../hooks/useDebounce.js';
|
|
20
|
-
import '../hooks/useClickOutside.js';
|
|
21
|
-
import '../hooks/useUpdatableRef.js';
|
|
22
|
-
import '../hooks/useForceUpdate.js';
|
|
23
|
-
import '../useEllipsisDetection-c1c9ad94.js';
|
|
24
|
-
import '../BusyLoader/index.js';
|
|
25
|
-
import '../Icon/index.js';
|
|
26
|
-
import '../style-inject.es-746bb8ed.js';
|
|
27
|
-
import '../Empty/index.js';
|
|
28
|
-
import '../tslib.es6-f211516f.js';
|
|
29
|
-
import '../index-73aaa093.js';
|
|
30
|
-
import '../index-122432cd.js';
|
|
31
|
-
import '../Scrollbar/index.js';
|
|
32
|
-
import '../GeneUIProvider/index.js';
|
|
33
|
-
import '../debounce-4419bc2f.js';
|
|
34
|
-
import '../index-65217440.js';
|
|
35
|
-
import '../ExtendedInput/index.js';
|
|
36
|
-
import '../SuggestionList/index.js';
|
|
37
|
-
import '../config-1053d64d.js';
|
|
38
|
-
import '../callAfterDelay-7272faca.js';
|
|
39
|
-
import '../Checkbox/index.js';
|
|
40
|
-
import '../checkboxRadioSwitcher-5b69d7bd.js';
|
|
41
|
-
import '../guid-8ddf77b3.js';
|
|
42
|
-
import '../index-370f9acd.js';
|
|
43
|
-
import '../Tag/index.js';
|
|
44
|
-
|
|
45
|
-
function checkValidation(required, isValid, value) {
|
|
46
|
-
if (isValid === false) return {
|
|
47
|
-
key: 'customValidation',
|
|
48
|
-
isValid: false
|
|
49
|
-
};
|
|
50
|
-
if ((value === 'undefined' || value === null) && required) return {
|
|
51
|
-
key: 'required',
|
|
52
|
-
isValid: false
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
key: null,
|
|
56
|
-
isValid: true
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const DropdownField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
60
|
-
const {
|
|
61
|
-
onChange,
|
|
62
|
-
value,
|
|
63
|
-
isValid,
|
|
64
|
-
required,
|
|
65
|
-
isFieldValid,
|
|
66
|
-
forceAllowValidation,
|
|
67
|
-
valueKey,
|
|
68
|
-
...restProps
|
|
69
|
-
} = props;
|
|
70
|
-
const isControlled = 'value' in props && typeof value !== 'undefined';
|
|
71
|
-
const [val, setVal] = useState(value || null);
|
|
72
|
-
const [validationState, setValidationState] = useState(true);
|
|
73
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
74
|
-
const validate = useCallback(() => checkValidation(required, isValid, val).isValid, [val, required, isValid]);
|
|
75
|
-
const handleChange = useCallback(param => {
|
|
76
|
-
const {
|
|
77
|
-
[valueKey]: value = null
|
|
78
|
-
} = param || {};
|
|
79
|
-
const validation = checkValidation(required, isValid, value);
|
|
80
|
-
setValidationState(validation.isValid);
|
|
81
|
-
setVal(value);
|
|
82
|
-
onChange(param, validation.isValid, validation.key);
|
|
83
|
-
}, [onChange, required, isValid, valueKey]);
|
|
84
|
-
|
|
85
|
-
// we use this because need to show field validation after onClose
|
|
86
|
-
const onBlur = useCallback(() => setAllowValidation(true), []);
|
|
87
|
-
const onClear = useCallback(() => {
|
|
88
|
-
const validState = checkValidation(required, isValid, null).isValid;
|
|
89
|
-
setValidationState(validState);
|
|
90
|
-
}, [required, isValid]);
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
isControlled && setValidationState(validate());
|
|
93
|
-
}, [isControlled, validate]);
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
setVal(value);
|
|
96
|
-
}, [value]);
|
|
97
|
-
|
|
98
|
-
// need this for handling user's `isValid` prop
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
setValidationState(isValid);
|
|
101
|
-
}, [isValid]);
|
|
102
|
-
|
|
103
|
-
// call function when validation state changes
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
isFieldValid(validationState);
|
|
106
|
-
}, [validationState]);
|
|
107
|
-
|
|
108
|
-
// set Allow validation true if submit button clicked
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
forceAllowValidation && setAllowValidation(true);
|
|
111
|
-
}, [forceAllowValidation]);
|
|
112
|
-
useMount(() => setValidationState(validate()));
|
|
113
|
-
return /*#__PURE__*/React__default.createElement(Dropdown, _extends({
|
|
114
|
-
required: required,
|
|
115
|
-
ref: ref,
|
|
116
|
-
value: val,
|
|
117
|
-
isValid: !allowValidation || validationState,
|
|
118
|
-
onChange: handleChange,
|
|
119
|
-
onBlur: onBlur,
|
|
120
|
-
onClear: onClear,
|
|
121
|
-
valueKey: valueKey
|
|
122
|
-
}, restProps));
|
|
123
|
-
});
|
|
124
|
-
DropdownField.propTypes = {
|
|
125
|
-
value: PropTypes.any,
|
|
126
|
-
onChange: PropTypes.func,
|
|
127
|
-
required: PropTypes.bool,
|
|
128
|
-
readOnly: PropTypes.bool,
|
|
129
|
-
isValid: PropTypes.bool,
|
|
130
|
-
forceAllowValidation: PropTypes.bool,
|
|
131
|
-
isFieldValid: PropTypes.func
|
|
132
|
-
};
|
|
133
|
-
DropdownField.defaultProps = {
|
|
134
|
-
required: false,
|
|
135
|
-
readOnly: false,
|
|
136
|
-
valueKey: 'value',
|
|
137
|
-
isFieldValid: noop,
|
|
138
|
-
onChange: noop
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export { DropdownField as default };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export { default as ValidatableDropdown } from '../ValidatableDropdown/index.js';
|
|
2
|
-
export { default as MultiSelectDropdownField } from '../ValidatableMultiSelectDropdown/index.js';
|
|
3
|
-
export { default as ValidatableEditor } from '../Editor/index.js';
|
|
4
|
-
export { default as ValidatableUploader } from '../ValidatableUploader/index.js';
|
|
5
|
-
export { default as ValidatableRadio } from '../ValidatableRadio/index.js';
|
|
6
|
-
export { default as ValidatableCheckbox } from '../ValidatableCheckbox/index.js';
|
|
7
|
-
export { default as ValidatableSwitcher } from '../ValidatableSwitcher/index.js';
|
|
8
|
-
export { default as ValidatableNumberInput } from '../ValidatableNumberInput/index.js';
|
|
9
|
-
export { default as ValidatableTextInput } from '../ValidatableTextInput/index.js';
|
|
10
|
-
export { default as ValidatableDatePicker } from '../ValidatableDatePicker/index.js';
|
|
11
|
-
import '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
12
|
-
import 'react';
|
|
13
|
-
import 'prop-types';
|
|
14
|
-
import '../hooks/useMount.js';
|
|
15
|
-
import '../index-5f37f281.js';
|
|
16
|
-
import '../dateValidation-67caec66.js';
|
|
17
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
18
|
-
import 'react-dom';
|
|
19
|
-
import '../configs-00612ce0.js';
|
|
20
|
-
import '../index-480fd7d9.js';
|
|
21
|
-
import '../objectWithoutPropertiesLoose-e1596bdb.js';
|
|
22
|
-
import '../react-lifecycles-compat.es-6e1f3768.js';
|
|
23
|
-
import '../clsx.m-2bb6df4b.js';
|
|
24
|
-
import '../index-031ff73c.js';
|
|
25
|
-
import '../hooks/useClick.js';
|
|
26
|
-
import '../hooks/useKeyDown.js';
|
|
27
|
-
import '../hooks/useDeviceType.js';
|
|
28
|
-
import '../hooks/useWindowSize.js';
|
|
29
|
-
import '../hooks/useDebounce.js';
|
|
30
|
-
import '../hooks/useClickOutside.js';
|
|
31
|
-
import '../hooks/useUpdatableRef.js';
|
|
32
|
-
import '../hooks/useForceUpdate.js';
|
|
33
|
-
import '../useEllipsisDetection-c1c9ad94.js';
|
|
34
|
-
import '../BusyLoader/index.js';
|
|
35
|
-
import '../Icon/index.js';
|
|
36
|
-
import '../style-inject.es-746bb8ed.js';
|
|
37
|
-
import '../Empty/index.js';
|
|
38
|
-
import '../tslib.es6-f211516f.js';
|
|
39
|
-
import '../index-73aaa093.js';
|
|
40
|
-
import '../index-122432cd.js';
|
|
41
|
-
import '../Scrollbar/index.js';
|
|
42
|
-
import '../GeneUIProvider/index.js';
|
|
43
|
-
import '../debounce-4419bc2f.js';
|
|
44
|
-
import '../index-65217440.js';
|
|
45
|
-
import '../ExtendedInput/index.js';
|
|
46
|
-
import '../SuggestionList/index.js';
|
|
47
|
-
import '../config-1053d64d.js';
|
|
48
|
-
import '../callAfterDelay-7272faca.js';
|
|
49
|
-
import '../Checkbox/index.js';
|
|
50
|
-
import '../checkboxRadioSwitcher-5b69d7bd.js';
|
|
51
|
-
import '../guid-8ddf77b3.js';
|
|
52
|
-
import '../index-370f9acd.js';
|
|
53
|
-
import '../Tag/index.js';
|
|
54
|
-
import '../index-45eafea6.js';
|
|
55
|
-
import '../Button/index.js';
|
|
56
|
-
import '../Uploader/index.js';
|
|
57
|
-
import '../Grid/index.js';
|
|
58
|
-
import '../hooks/useWidth.js';
|
|
59
|
-
import '../hooks/useImgDownload.js';
|
|
60
|
-
import '../Image/index.js';
|
|
61
|
-
import '../RadioGroup/index.js';
|
|
62
|
-
import '../Radio/index.js';
|
|
63
|
-
import '../Switcher/index.js';
|
|
64
|
-
import '../DatePickerInput/index.js';
|
|
65
|
-
import '../DatePicker/index.js';
|
|
66
|
-
import '../localization-4ba17032.js';
|
|
67
|
-
import '../checkTimeValidation-e56771be.js';
|