@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,152 +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, min, max) {
|
|
46
|
-
const length = value === null || value === void 0 ? void 0 : value.length;
|
|
47
|
-
if (isValid === false) return {
|
|
48
|
-
key: 'customValidation',
|
|
49
|
-
isValid: false
|
|
50
|
-
};
|
|
51
|
-
if (!length && required) return {
|
|
52
|
-
key: 'required',
|
|
53
|
-
isValid: false
|
|
54
|
-
};
|
|
55
|
-
if (min && length < min) return {
|
|
56
|
-
key: 'min',
|
|
57
|
-
isValid: false
|
|
58
|
-
};
|
|
59
|
-
if (max && length > max) return {
|
|
60
|
-
key: 'max',
|
|
61
|
-
isValid: false
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
key: null,
|
|
65
|
-
isValid: true
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const MultiSelectDropdownField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
69
|
-
const {
|
|
70
|
-
onChange,
|
|
71
|
-
value,
|
|
72
|
-
isValid,
|
|
73
|
-
required,
|
|
74
|
-
min,
|
|
75
|
-
max,
|
|
76
|
-
isFieldValid,
|
|
77
|
-
valueKey,
|
|
78
|
-
forceAllowValidation,
|
|
79
|
-
...restProps
|
|
80
|
-
} = props;
|
|
81
|
-
const isControlled = 'value' in props && typeof value !== 'undefined';
|
|
82
|
-
const [val, setVal] = useState(value || []);
|
|
83
|
-
const [validationState, setValidationState] = useState(true);
|
|
84
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
85
|
-
const validate = useCallback(() => checkValidation(required, isValid, val, min, max).isValid, [required, isValid, val, min, max]);
|
|
86
|
-
const handleChange = useCallback(e => {
|
|
87
|
-
const validation = checkValidation(required, isValid, e, min, max);
|
|
88
|
-
setValidationState(validation.isValid);
|
|
89
|
-
setVal(e.map(item => item[valueKey]));
|
|
90
|
-
onChange && onChange(e, validation.isValid, validation.key);
|
|
91
|
-
}, [required, isValid, min, max, onChange, valueKey]);
|
|
92
|
-
|
|
93
|
-
// we use this because need to show field validation after onClose
|
|
94
|
-
const onBlur = useCallback(() => setAllowValidation(true), []);
|
|
95
|
-
const onClear = useCallback(() => {
|
|
96
|
-
const validState = checkValidation(required, isValid, []).isValid;
|
|
97
|
-
setValidationState(validState);
|
|
98
|
-
}, [required, isValid]);
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
isControlled && setValidationState(validate());
|
|
101
|
-
}, [isControlled, validate]);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
setVal(value);
|
|
104
|
-
}, [value]);
|
|
105
|
-
|
|
106
|
-
// need this for handling user's `isValid` prop
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
setValidationState(isValid);
|
|
109
|
-
}, [isValid]);
|
|
110
|
-
|
|
111
|
-
// call function when validation state changes
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
isFieldValid(validationState);
|
|
114
|
-
}, [validationState]);
|
|
115
|
-
|
|
116
|
-
// set Allow validation true if submit button clicked
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
forceAllowValidation && setAllowValidation(true);
|
|
119
|
-
}, [forceAllowValidation]);
|
|
120
|
-
useMount(() => setValidationState(validate()));
|
|
121
|
-
return /*#__PURE__*/React__default.createElement(Dropdown, _extends({
|
|
122
|
-
required: required,
|
|
123
|
-
ref: ref,
|
|
124
|
-
value: val,
|
|
125
|
-
isMultiSelect: true,
|
|
126
|
-
isValid: !allowValidation || validationState,
|
|
127
|
-
onChange: handleChange,
|
|
128
|
-
onBlur: onBlur,
|
|
129
|
-
valueKey: valueKey,
|
|
130
|
-
onClear: onClear
|
|
131
|
-
}, restProps));
|
|
132
|
-
});
|
|
133
|
-
MultiSelectDropdownField.propTypes = {
|
|
134
|
-
min: PropTypes.number,
|
|
135
|
-
max: PropTypes.number,
|
|
136
|
-
valueKey: PropTypes.string,
|
|
137
|
-
value: PropTypes.any,
|
|
138
|
-
onChange: PropTypes.func,
|
|
139
|
-
required: PropTypes.bool,
|
|
140
|
-
readOnly: PropTypes.bool,
|
|
141
|
-
isValid: PropTypes.bool,
|
|
142
|
-
forceAllowValidation: PropTypes.bool,
|
|
143
|
-
isFieldValid: PropTypes.func
|
|
144
|
-
};
|
|
145
|
-
MultiSelectDropdownField.defaultProps = {
|
|
146
|
-
required: false,
|
|
147
|
-
readOnly: false,
|
|
148
|
-
isFieldValid: noop,
|
|
149
|
-
valueKey: 'value'
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export { MultiSelectDropdownField as default };
|
|
@@ -1,204 +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 } from '../index-5f37f281.js';
|
|
5
|
-
import useMount from '../hooks/useMount.js';
|
|
6
|
-
import '../configs-00612ce0.js';
|
|
7
|
-
import ExtendedInput from '../ExtendedInput/index.js';
|
|
8
|
-
import '../dateValidation-67caec66.js';
|
|
9
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
10
|
-
import 'react-dom';
|
|
11
|
-
import '../index-031ff73c.js';
|
|
12
|
-
import '../hooks/useDeviceType.js';
|
|
13
|
-
import '../hooks/useWindowSize.js';
|
|
14
|
-
import '../hooks/useDebounce.js';
|
|
15
|
-
import '../useEllipsisDetection-c1c9ad94.js';
|
|
16
|
-
import '../Icon/index.js';
|
|
17
|
-
import '../style-inject.es-746bb8ed.js';
|
|
18
|
-
import '../SuggestionList/index.js';
|
|
19
|
-
import '../hooks/useKeyDown.js';
|
|
20
|
-
import '../hooks/useClickOutside.js';
|
|
21
|
-
import '../config-1053d64d.js';
|
|
22
|
-
import '../Scrollbar/index.js';
|
|
23
|
-
import '../callAfterDelay-7272faca.js';
|
|
24
|
-
import '../index-65217440.js';
|
|
25
|
-
import '../tslib.es6-f211516f.js';
|
|
26
|
-
import '../GeneUIProvider/index.js';
|
|
27
|
-
|
|
28
|
-
const validateMin = (value, min) => value >= min;
|
|
29
|
-
const validateMax = (value, max) => value <= max;
|
|
30
|
-
const validateFloat = (value, precisionMin, precisionMax) => {
|
|
31
|
-
const decimalPlaces = (value.split('.')[1] || []).length;
|
|
32
|
-
if (precisionMax && decimalPlaces > precisionMax) return false;
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
function checkValidation(required, isValid, min, max, numberType, precisionMin, precisionMax) {
|
|
36
|
-
let value = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : '';
|
|
37
|
-
const numberedValue = Number(value);
|
|
38
|
-
if (isValid === false) return {
|
|
39
|
-
key: 'customValidation',
|
|
40
|
-
isValid: false
|
|
41
|
-
};
|
|
42
|
-
if (numberType === 'integer' && !Number.isInteger(numberedValue)) return {
|
|
43
|
-
key: 'isInteger',
|
|
44
|
-
isValid: false
|
|
45
|
-
};
|
|
46
|
-
if (numberType === 'float' && !validateFloat(value, precisionMin, precisionMax)) return {
|
|
47
|
-
key: 'isFloat',
|
|
48
|
-
isValid: false
|
|
49
|
-
};
|
|
50
|
-
if (min != null && value && !validateMin(numberedValue, min)) return {
|
|
51
|
-
key: 'min',
|
|
52
|
-
isValid: false
|
|
53
|
-
};
|
|
54
|
-
if (max != null && value && !validateMax(numberedValue, max)) return {
|
|
55
|
-
key: 'max',
|
|
56
|
-
isValid: false
|
|
57
|
-
};
|
|
58
|
-
if (required && !value.length) return {
|
|
59
|
-
key: 'required',
|
|
60
|
-
isValid: false
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
key: null,
|
|
64
|
-
isValid: true
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
68
|
-
const {
|
|
69
|
-
onBlur,
|
|
70
|
-
required,
|
|
71
|
-
isValid,
|
|
72
|
-
numberType,
|
|
73
|
-
precisionMin,
|
|
74
|
-
precisionMax,
|
|
75
|
-
min,
|
|
76
|
-
max,
|
|
77
|
-
onChange,
|
|
78
|
-
value,
|
|
79
|
-
isFieldValid,
|
|
80
|
-
forceAllowValidation,
|
|
81
|
-
forceValidateDuringChange,
|
|
82
|
-
...restProps
|
|
83
|
-
} = props;
|
|
84
|
-
const isControlled = 'value' in props && typeof value !== 'undefined';
|
|
85
|
-
const [validationState, setValidationState] = useState(true);
|
|
86
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
87
|
-
const validate = useCallback(() => checkValidation(required, isValid, min, max, numberType, precisionMin, precisionMax, value || '').isValid, [required, isValid, min, max, value, numberType, precisionMin, precisionMax]);
|
|
88
|
-
const handleChange = useCallback(e => {
|
|
89
|
-
const {
|
|
90
|
-
value
|
|
91
|
-
} = e.target;
|
|
92
|
-
const validation = checkValidation(required, isValid, min, max, numberType, precisionMin, precisionMax, value);
|
|
93
|
-
setValidationState(validation.isValid);
|
|
94
|
-
onChange(e, validation.isValid, validation.key);
|
|
95
|
-
forceValidateDuringChange && setAllowValidation(true);
|
|
96
|
-
}, [onChange, min, max, required, isValid, numberType, precisionMin, precisionMax, forceValidateDuringChange]);
|
|
97
|
-
|
|
98
|
-
// we use this because need to show field validation after onBlur
|
|
99
|
-
const handleBlur = useCallback(e => {
|
|
100
|
-
const {
|
|
101
|
-
value,
|
|
102
|
-
validity
|
|
103
|
-
} = e.target;
|
|
104
|
-
if (validity.badInput && !value.length) {
|
|
105
|
-
e.target.value = '';
|
|
106
|
-
}
|
|
107
|
-
onBlur(e);
|
|
108
|
-
setAllowValidation(true);
|
|
109
|
-
}, [onBlur]);
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
isControlled && setValidationState(validate());
|
|
112
|
-
}, [isControlled, validate]);
|
|
113
|
-
|
|
114
|
-
// this for handling required prop changes
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
setValidationState(validate());
|
|
117
|
-
}, [required]);
|
|
118
|
-
|
|
119
|
-
// need this for handling user's `isValid` prop
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
setValidationState(isValid);
|
|
122
|
-
}, [isValid]);
|
|
123
|
-
|
|
124
|
-
// call function when validation state changes
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
isFieldValid(validationState);
|
|
127
|
-
}, [validationState]);
|
|
128
|
-
|
|
129
|
-
// set Allow validation true if submit button clicked
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
forceAllowValidation && setAllowValidation(true);
|
|
132
|
-
}, [forceAllowValidation]);
|
|
133
|
-
useMount(() => setValidationState(validate()));
|
|
134
|
-
return /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({
|
|
135
|
-
min: min,
|
|
136
|
-
max: max,
|
|
137
|
-
ref: ref,
|
|
138
|
-
value: value,
|
|
139
|
-
isValid: !allowValidation || validationState,
|
|
140
|
-
onChange: handleChange,
|
|
141
|
-
onBlur: handleBlur,
|
|
142
|
-
required: required,
|
|
143
|
-
type: "number"
|
|
144
|
-
}, restProps));
|
|
145
|
-
});
|
|
146
|
-
NumberInput.propTypes = {
|
|
147
|
-
/**
|
|
148
|
-
* Maximum value
|
|
149
|
-
*/
|
|
150
|
-
min: PropTypes.number,
|
|
151
|
-
/**
|
|
152
|
-
* Minimum value
|
|
153
|
-
*/
|
|
154
|
-
max: PropTypes.number,
|
|
155
|
-
/**
|
|
156
|
-
* Value for number field
|
|
157
|
-
*/
|
|
158
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
159
|
-
/**
|
|
160
|
-
* Callback fires when field changes
|
|
161
|
-
*/
|
|
162
|
-
onChange: PropTypes.func,
|
|
163
|
-
/**
|
|
164
|
-
* Callback fires when input loose focus
|
|
165
|
-
*/
|
|
166
|
-
onBlur: PropTypes.func,
|
|
167
|
-
/**
|
|
168
|
-
* Callback fires when field validation state changes
|
|
169
|
-
*/
|
|
170
|
-
isFieldValid: PropTypes.func,
|
|
171
|
-
/**
|
|
172
|
-
* Additional validation state
|
|
173
|
-
*/
|
|
174
|
-
isValid: PropTypes.bool,
|
|
175
|
-
/**
|
|
176
|
-
* Allow validation without onBlur, validate field when mount
|
|
177
|
-
*/
|
|
178
|
-
forceAllowValidation: PropTypes.bool,
|
|
179
|
-
/**
|
|
180
|
-
* Define number type
|
|
181
|
-
*/
|
|
182
|
-
numberType: PropTypes.oneOf(['integer', 'float']),
|
|
183
|
-
/**
|
|
184
|
-
* Precision minimum count
|
|
185
|
-
*/
|
|
186
|
-
precisionMin: PropTypes.number,
|
|
187
|
-
/**
|
|
188
|
-
* Precision maximum count
|
|
189
|
-
*/
|
|
190
|
-
precisionMax: PropTypes.number,
|
|
191
|
-
/**
|
|
192
|
-
* We use this props if we need to show validation of a field during onChange
|
|
193
|
-
*/
|
|
194
|
-
forceValidateDuringChange: PropTypes.bool
|
|
195
|
-
};
|
|
196
|
-
NumberInput.defaultProps = {
|
|
197
|
-
isValid: true,
|
|
198
|
-
precisionMin: 0,
|
|
199
|
-
isFieldValid: noop,
|
|
200
|
-
onChange: noop,
|
|
201
|
-
onBlur: noop
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export { NumberInput as default };
|
|
@@ -1,116 +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 } from '../index-5f37f281.js';
|
|
5
|
-
import useMount from '../hooks/useMount.js';
|
|
6
|
-
import '../configs-00612ce0.js';
|
|
7
|
-
import RadioGroup from '../RadioGroup/index.js';
|
|
8
|
-
import '../dateValidation-67caec66.js';
|
|
9
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
10
|
-
import 'react-dom';
|
|
11
|
-
import '../index-031ff73c.js';
|
|
12
|
-
import '../Radio/index.js';
|
|
13
|
-
import '../checkboxRadioSwitcher-5b69d7bd.js';
|
|
14
|
-
import '../style-inject.es-746bb8ed.js';
|
|
15
|
-
import '../guid-8ddf77b3.js';
|
|
16
|
-
|
|
17
|
-
function checkValidation(required, isValid) {
|
|
18
|
-
let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
19
|
-
if (isValid === false) return {
|
|
20
|
-
key: 'customValidation',
|
|
21
|
-
isValid: false
|
|
22
|
-
};
|
|
23
|
-
if (required && (!value || value.length === 0)) return {
|
|
24
|
-
key: 'required',
|
|
25
|
-
isValid: false
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
key: null,
|
|
29
|
-
isValid: true
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const Radio = /*#__PURE__*/forwardRef((props, ref) => {
|
|
33
|
-
const {
|
|
34
|
-
onChange,
|
|
35
|
-
value,
|
|
36
|
-
isValid,
|
|
37
|
-
required,
|
|
38
|
-
isFieldValid,
|
|
39
|
-
forceAllowValidation,
|
|
40
|
-
...restProps
|
|
41
|
-
} = props;
|
|
42
|
-
const isControlled = 'value' in props && typeof value !== 'undefined';
|
|
43
|
-
const [validationState, setValidationState] = useState(true);
|
|
44
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
45
|
-
const validate = useCallback(() => checkValidation(required, isValid, value).isValid, [value, required, isValid]);
|
|
46
|
-
const handleChange = useCallback(e => {
|
|
47
|
-
const {
|
|
48
|
-
value
|
|
49
|
-
} = e.target;
|
|
50
|
-
const validation = checkValidation(required, isValid, value);
|
|
51
|
-
setValidationState(validation.isValid);
|
|
52
|
-
onChange(e, validation.isValid, validation.key);
|
|
53
|
-
}, [onChange, required, isValid]);
|
|
54
|
-
|
|
55
|
-
// we use this because need to show field validation after onBlur
|
|
56
|
-
const onBlur = useCallback(() => setAllowValidation(true), []);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
isControlled && setValidationState(validate());
|
|
59
|
-
}, [isControlled, validate]);
|
|
60
|
-
|
|
61
|
-
// need this for handling user's `isValid` prop
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
setValidationState(isValid);
|
|
64
|
-
}, [isValid]);
|
|
65
|
-
|
|
66
|
-
// call function when validation state changes
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
isFieldValid(validationState);
|
|
69
|
-
}, [validationState]);
|
|
70
|
-
|
|
71
|
-
// set Allow validation true if submit button clicked
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
forceAllowValidation && setAllowValidation(true);
|
|
74
|
-
}, [forceAllowValidation]);
|
|
75
|
-
useMount(() => setValidationState(validate()));
|
|
76
|
-
return /*#__PURE__*/React__default.createElement(RadioGroup, _extends({
|
|
77
|
-
ref: ref,
|
|
78
|
-
value: value,
|
|
79
|
-
isValid: !allowValidation || validationState,
|
|
80
|
-
onChange: handleChange,
|
|
81
|
-
onBlur: onBlur
|
|
82
|
-
}, restProps));
|
|
83
|
-
});
|
|
84
|
-
Radio.propTypes = {
|
|
85
|
-
/**
|
|
86
|
-
* Value for radio field
|
|
87
|
-
*/
|
|
88
|
-
value: PropTypes.string,
|
|
89
|
-
/**
|
|
90
|
-
* Callback fires when radio field changes
|
|
91
|
-
*/
|
|
92
|
-
onChange: PropTypes.func,
|
|
93
|
-
/**
|
|
94
|
-
* Define is field required or no.
|
|
95
|
-
*/
|
|
96
|
-
required: PropTypes.bool,
|
|
97
|
-
/**
|
|
98
|
-
* Callback fires when field validation state changes
|
|
99
|
-
*/
|
|
100
|
-
isFieldValid: PropTypes.func,
|
|
101
|
-
/**
|
|
102
|
-
* Additional validation state
|
|
103
|
-
*/
|
|
104
|
-
isValid: PropTypes.bool,
|
|
105
|
-
/**
|
|
106
|
-
* Allow validation without onBlur, validate field when mount
|
|
107
|
-
*/
|
|
108
|
-
forceAllowValidation: PropTypes.bool
|
|
109
|
-
};
|
|
110
|
-
Radio.defaultProps = {
|
|
111
|
-
isValid: true,
|
|
112
|
-
isFieldValid: noop,
|
|
113
|
-
onChange: noop
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export { Radio as default };
|
|
@@ -1,93 +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 } from '../index-5f37f281.js';
|
|
5
|
-
import useMount from '../hooks/useMount.js';
|
|
6
|
-
import '../configs-00612ce0.js';
|
|
7
|
-
import Switcher from '../Switcher/index.js';
|
|
8
|
-
import '../dateValidation-67caec66.js';
|
|
9
|
-
import '../_commonjsHelpers-24198af3.js';
|
|
10
|
-
import 'react-dom';
|
|
11
|
-
import '../index-031ff73c.js';
|
|
12
|
-
import '../hooks/useKeyDown.js';
|
|
13
|
-
import '../checkboxRadioSwitcher-5b69d7bd.js';
|
|
14
|
-
import '../style-inject.es-746bb8ed.js';
|
|
15
|
-
import '../guid-8ddf77b3.js';
|
|
16
|
-
|
|
17
|
-
function checkValidation(value, required, isValid) {
|
|
18
|
-
if (required && !value) return {
|
|
19
|
-
key: 'required',
|
|
20
|
-
isValid: false
|
|
21
|
-
};
|
|
22
|
-
if (isValid === false) return {
|
|
23
|
-
key: 'customValidation',
|
|
24
|
-
isValid: false
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
key: null,
|
|
28
|
-
isValid: true
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const SwitcherElement = /*#__PURE__*/forwardRef((props, ref) => {
|
|
32
|
-
const {
|
|
33
|
-
onChange,
|
|
34
|
-
isValid,
|
|
35
|
-
required,
|
|
36
|
-
isFieldValid,
|
|
37
|
-
forceAllowValidation,
|
|
38
|
-
...restProps
|
|
39
|
-
} = props;
|
|
40
|
-
const isControlled = ('checked' in props);
|
|
41
|
-
const [validationState, setValidationState] = useState(true);
|
|
42
|
-
const [allowValidation, setAllowValidation] = useState(false);
|
|
43
|
-
const [value, setValue] = useState(false);
|
|
44
|
-
const localValue = isControlled ? props.checked : value;
|
|
45
|
-
const validate = useCallback(() => checkValidation(localValue, required, isValid).isValid, [localValue, required, isValid]);
|
|
46
|
-
const handleChange = useCallback(e => {
|
|
47
|
-
const validation = checkValidation(e.target.checked, required, isValid);
|
|
48
|
-
setAllowValidation(true);
|
|
49
|
-
!isControlled && setValidationState(validation.isValid);
|
|
50
|
-
setValue(e.target.checked);
|
|
51
|
-
onChange(e, validation.isValid, validation.key);
|
|
52
|
-
}, [required, isValid, isControlled, onChange]);
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
isControlled && setValidationState(validate());
|
|
55
|
-
}, [isControlled, validate]);
|
|
56
|
-
|
|
57
|
-
// need this for handling user's `isValid` prop
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
setValidationState(isValid);
|
|
60
|
-
}, [isValid]);
|
|
61
|
-
|
|
62
|
-
// call function when validation state changes
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
isFieldValid(validationState);
|
|
65
|
-
}, [validationState]);
|
|
66
|
-
|
|
67
|
-
// set Allow validation true if submit button clicked
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
forceAllowValidation && setAllowValidation(true);
|
|
70
|
-
}, [forceAllowValidation]);
|
|
71
|
-
useMount(() => setValidationState(validate()));
|
|
72
|
-
return /*#__PURE__*/React__default.createElement(Switcher, _extends({
|
|
73
|
-
ref: ref,
|
|
74
|
-
isValid: !allowValidation || validationState,
|
|
75
|
-
onChange: handleChange,
|
|
76
|
-
required: required
|
|
77
|
-
}, restProps));
|
|
78
|
-
});
|
|
79
|
-
SwitcherElement.propTypes = {
|
|
80
|
-
onChange: PropTypes.func,
|
|
81
|
-
required: PropTypes.bool,
|
|
82
|
-
checked: PropTypes.bool,
|
|
83
|
-
isFieldValid: PropTypes.func,
|
|
84
|
-
isValid: PropTypes.bool,
|
|
85
|
-
forceAllowValidation: PropTypes.bool
|
|
86
|
-
};
|
|
87
|
-
SwitcherElement.defaultProps = {
|
|
88
|
-
isValid: true,
|
|
89
|
-
isFieldValid: noop,
|
|
90
|
-
onChange: noop
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export { SwitcherElement as default };
|