@geneui/components 3.0.0-next-06dadf3-29102024 → 3.0.0-next-63cb5e7-01112024

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.
Files changed (247) hide show
  1. package/Avatar.js +63 -0
  2. package/Divider.js +23 -0
  3. package/{GeneUIProvider/index.js → GeneUIProvider.js} +51 -64
  4. package/HelperText.js +69 -0
  5. package/Info.js +64 -0
  6. package/Label.js +38 -0
  7. package/Loader.js +21 -0
  8. package/Pill.js +64 -0
  9. package/TextLink.js +20 -0
  10. package/{index-c7646e48.js → Tooltip.js} +101 -79
  11. package/{lib → components}/atoms/Avatar/Avatar.d.ts +7 -6
  12. package/components/atoms/Avatar/index.d.ts +1 -0
  13. package/{lib → components}/atoms/Divider/Divider.d.ts +5 -5
  14. package/components/atoms/Divider/index.d.ts +1 -0
  15. package/{lib → components}/atoms/HelperText/HelperText.d.ts +6 -5
  16. package/components/atoms/HelperText/index.d.ts +1 -0
  17. package/{lib → components}/atoms/Info/Info.d.ts +5 -5
  18. package/components/atoms/Info/index.d.ts +1 -0
  19. package/{lib → components}/atoms/Label/Label.d.ts +3 -3
  20. package/components/atoms/Label/index.d.ts +1 -0
  21. package/{lib → components}/atoms/Loader/Loader.d.ts +5 -5
  22. package/components/atoms/Loader/index.d.ts +1 -0
  23. package/{lib → components}/atoms/Pill/Pill.d.ts +7 -6
  24. package/components/atoms/Pill/index.d.ts +1 -0
  25. package/{lib → components}/atoms/TextLink/TextLink.d.ts +5 -5
  26. package/components/atoms/TextLink/index.d.ts +1 -0
  27. package/{lib → components}/molecules/Tooltip/Tooltip.d.ts +26 -21
  28. package/components/molecules/Tooltip/index.d.ts +1 -0
  29. package/components/providers/GeneUIProvider/GeneUIProvider.d.ts +30 -0
  30. package/components/providers/GeneUIProvider/index.d.ts +1 -0
  31. package/hooks/index.d.ts +2 -20
  32. package/hooks/useDebounceCallback/index.d.ts +1 -0
  33. package/hooks/useDebounceCallback/useDebounceCallback.d.ts +2 -0
  34. package/hooks/useEllipsisDetection/index.d.ts +1 -1
  35. package/hooks/useEllipsisDetection/useEllipsisDetection.d.ts +2 -2
  36. package/{index-031ff73c.js → index-ce02421b.js} +4 -4
  37. package/index.d.ts +11 -121
  38. package/index.js +12 -159
  39. package/package.json +24 -43
  40. package/tokens-0abb4e1b.js +6 -0
  41. package/types/index.d.ts +0 -3
  42. package/useEllipsisDetection-46d712b6.js +34 -0
  43. package/ActionableList/index.js +0 -1694
  44. package/AdvancedSearch/index.js +0 -892
  45. package/Alert/index.js +0 -98
  46. package/Avatar/index.js +0 -58
  47. package/Badge/index.js +0 -29
  48. package/Breadcrumb/index.js +0 -130
  49. package/BusyLoader/index.js +0 -31
  50. package/Button/index.js +0 -30
  51. package/Card/index.js +0 -502
  52. package/CardList/index.js +0 -662
  53. package/CellMeasurerCache-26f3693c.js +0 -229
  54. package/Charts/index.js +0 -17662
  55. package/Checkbox/index.js +0 -229
  56. package/CheckboxGroup/index.js +0 -203
  57. package/CheckboxGroupWithSearch/index.js +0 -280
  58. package/Collapse/index.js +0 -195
  59. package/ColorPicker/index.js +0 -210
  60. package/ComboBox/index.js +0 -524
  61. package/Copy/index.js +0 -56
  62. package/Counter/index.js +0 -312
  63. package/DateFilter/index.js +0 -183
  64. package/DatePicker/index.js +0 -1229
  65. package/DatePickerInput/index.js +0 -883
  66. package/Divider/index.js +0 -23
  67. package/Drawer/index.js +0 -261
  68. package/Dropdown/index.js +0 -43
  69. package/Editor/index.js +0 -22975
  70. package/Empty/index.js +0 -76
  71. package/ExtendedInput/index.js +0 -590
  72. package/Form/index.js +0 -85
  73. package/FormContainer/index.js +0 -189
  74. package/FormableCheckbox/index.js +0 -24
  75. package/FormableDatePicker/index.js +0 -43
  76. package/FormableDropdown/index.js +0 -50
  77. package/FormableEditor/index.js +0 -26
  78. package/FormableHOC-85f89a81.js +0 -83
  79. package/FormableMultiSelectDropdown/index.js +0 -50
  80. package/FormableNumberInput/index.js +0 -34
  81. package/FormableRadio/index.js +0 -22
  82. package/FormableSwitcher/index.js +0 -22
  83. package/FormableTextInput/index.js +0 -34
  84. package/FormableUploader/index.js +0 -44
  85. package/Grid/index.js +0 -167
  86. package/HelperText/index.js +0 -86
  87. package/Holder/index.js +0 -261
  88. package/Icon/index.js +0 -62
  89. package/Image/index.js +0 -45
  90. package/ImagePreview/index.js +0 -217
  91. package/Info/index.js +0 -41
  92. package/InfoOutline-dd2e89d9.js +0 -29
  93. package/InteractiveWidget/index.js +0 -78
  94. package/KeyValue/index.js +0 -22
  95. package/Label/index.js +0 -48
  96. package/LinkButton/index.js +0 -34
  97. package/Loader/index.js +0 -23
  98. package/Menu/index.js +0 -281
  99. package/MobileNavigation/index.js +0 -94
  100. package/MobilePopup/index.js +0 -182
  101. package/Modal/index.js +0 -251
  102. package/ModuleTitle/index.js +0 -141
  103. package/NavigationMenu/index.js +0 -222
  104. package/Notification/index.js +0 -120
  105. package/Option/index.js +0 -184
  106. package/Overlay/index.js +0 -187
  107. package/Overspread/index.js +0 -291
  108. package/Pagination/index.js +0 -261
  109. package/Paper/index.js +0 -96
  110. package/Pill/index.js +0 -67
  111. package/Popover/index.js +0 -725
  112. package/PopoverV2/index.js +0 -19
  113. package/Portal/index.js +0 -58
  114. package/Products/index.js +0 -115
  115. package/Profile/index.js +0 -589
  116. package/Progress/index.js +0 -200
  117. package/QRCode/index.js +0 -814
  118. package/Radio/index.js +0 -151
  119. package/RadioGroup/index.js +0 -104
  120. package/Range/index.js +0 -191
  121. package/Rating/index.js +0 -174
  122. package/RichEditor/index.js +0 -13
  123. package/RichEditor-6ca8346f.js +0 -228
  124. package/Scrollbar/index.js +0 -1585
  125. package/Search/index.js +0 -75
  126. package/SearchWithDropdown/index.js +0 -140
  127. package/Section/index.js +0 -61
  128. package/SkeletonLoader/index.js +0 -81
  129. package/Slider/index.js +0 -261
  130. package/Status/index.js +0 -97
  131. package/Steps/index.js +0 -314
  132. package/SuggestionList/index.js +0 -385
  133. package/Switcher/index.js +0 -193
  134. package/Table/index.js +0 -57
  135. package/TableCompositions/index.js +0 -16995
  136. package/Tabs/index.js +0 -235
  137. package/Tag/index.js +0 -102
  138. package/TextLink/index.js +0 -20
  139. package/Textarea/index.js +0 -242
  140. package/Time/index.js +0 -62
  141. package/TimePicker/index.js +0 -575
  142. package/Timeline/index.js +0 -113
  143. package/Title/index.js +0 -65
  144. package/Toaster/index.js +0 -116
  145. package/Tooltip/index.js +0 -6
  146. package/TransferList/index.js +0 -493
  147. package/Uploader/index.js +0 -992
  148. package/ValidatableCheckbox/index.js +0 -123
  149. package/ValidatableDatePicker/index.js +0 -316
  150. package/ValidatableDropdown/index.js +0 -141
  151. package/ValidatableElements/index.js +0 -67
  152. package/ValidatableMultiSelectDropdown/index.js +0 -152
  153. package/ValidatableNumberInput/index.js +0 -204
  154. package/ValidatableRadio/index.js +0 -116
  155. package/ValidatableSwitcher/index.js +0 -93
  156. package/ValidatableTextInput/index.js +0 -167
  157. package/ValidatableTimeInput/index.js +0 -174
  158. package/ValidatableUploader/index.js +0 -98
  159. package/Widget/index.js +0 -225
  160. package/_commonjsHelpers-24198af3.js +0 -35
  161. package/_rollupPluginBabelHelpers-a83240e1.js +0 -11
  162. package/callAfterDelay-7272faca.js +0 -12
  163. package/checkTimeValidation-e56771be.js +0 -16
  164. package/checkboxRadioSwitcher-5b69d7bd.js +0 -4
  165. package/clsx.m-2bb6df4b.js +0 -3
  166. package/config-1053d64d.js +0 -20
  167. package/configs-00612ce0.js +0 -103
  168. package/configs.js +0 -111
  169. package/dateValidation-67caec66.js +0 -225
  170. package/debounce-4419bc2f.js +0 -17
  171. package/guid-8ddf77b3.js +0 -16
  172. package/hooks/useBodyScroll.js +0 -16
  173. package/hooks/useClick.js +0 -18
  174. package/hooks/useClickOutside.js +0 -25
  175. package/hooks/useDebounce.js +0 -28
  176. package/hooks/useDeviceType.js +0 -17
  177. package/hooks/useDidMount.js +0 -15
  178. package/hooks/useForceUpdate.js +0 -8
  179. package/hooks/useHover.js +0 -20
  180. package/hooks/useImgDownload.js +0 -18
  181. package/hooks/useKeyDown.js +0 -21
  182. package/hooks/useMount.js +0 -13
  183. package/hooks/useMutationObserver.js +0 -21
  184. package/hooks/usePrevious.js +0 -10
  185. package/hooks/useThrottle.js +0 -16
  186. package/hooks/useToggle.js +0 -11
  187. package/hooks/useUpdatableRef.js +0 -14
  188. package/hooks/useUpdate.js +0 -10
  189. package/hooks/useWidth.js +0 -16
  190. package/hooks/useWindowSize.js +0 -40
  191. package/index-122432cd.js +0 -270
  192. package/index-262edd7a.js +0 -77
  193. package/index-3188e46e.js +0 -1940
  194. package/index-45eafea6.js +0 -90
  195. package/index-5f37f281.js +0 -168
  196. package/index-ce12e4a9.js +0 -10032
  197. package/index-d0ecb950.js +0 -6483
  198. package/index-fcbae78d.js +0 -4
  199. package/index.mobile.d.ts +0 -14
  200. package/lib/atoms/Avatar/index.d.ts +0 -1
  201. package/lib/atoms/Badge/Badge.d.ts +0 -36
  202. package/lib/atoms/Badge/index.d.ts +0 -1
  203. package/lib/atoms/BusyLoader/BusyLoader.d.ts +0 -32
  204. package/lib/atoms/BusyLoader/BusyLoaderHolderHOC.d.ts +0 -8
  205. package/lib/atoms/BusyLoader/index.d.ts +0 -1
  206. package/lib/atoms/Button/Button.d.ts +0 -70
  207. package/lib/atoms/Button/index.d.ts +0 -1
  208. package/lib/atoms/Divider/index.d.ts +0 -1
  209. package/lib/atoms/Empty/Empty.d.ts +0 -39
  210. package/lib/atoms/Empty/index.d.ts +0 -1
  211. package/lib/atoms/Empty/utils.d.ts +0 -9
  212. package/lib/atoms/HelperText/index.d.ts +0 -1
  213. package/lib/atoms/Image/Image.d.ts +0 -51
  214. package/lib/atoms/Image/index.d.ts +0 -1
  215. package/lib/atoms/ImagePreview/ImagePreview.d.ts +0 -56
  216. package/lib/atoms/ImagePreview/ImagePreviewHOC.d.ts +0 -4
  217. package/lib/atoms/ImagePreview/Magnifier.d.ts +0 -40
  218. package/lib/atoms/ImagePreview/index.d.ts +0 -1
  219. package/lib/atoms/Info/index.d.ts +0 -1
  220. package/lib/atoms/KeyValue/KeyValue.d.ts +0 -29
  221. package/lib/atoms/KeyValue/index.d.ts +0 -1
  222. package/lib/atoms/Label/index.d.ts +0 -1
  223. package/lib/atoms/LinkButton/LinkButton.d.ts +0 -46
  224. package/lib/atoms/LinkButton/index.d.ts +0 -1
  225. package/lib/atoms/Loader/index.d.ts +0 -1
  226. package/lib/atoms/Pill/index.d.ts +0 -1
  227. package/lib/atoms/Rating/DefaultSvg.d.ts +0 -3
  228. package/lib/atoms/Rating/Rating.d.ts +0 -49
  229. package/lib/atoms/Rating/index.d.ts +0 -1
  230. package/lib/atoms/TextLink/index.d.ts +0 -1
  231. package/lib/molecules/Copy/Copy.d.ts +0 -38
  232. package/lib/molecules/Copy/index.d.ts +0 -1
  233. package/lib/molecules/InteractiveWidget/InteractiveWidget.d.ts +0 -70
  234. package/lib/molecules/InteractiveWidget/InteractiveWidgetIcon.d.ts +0 -8
  235. package/lib/molecules/InteractiveWidget/index.d.ts +0 -1
  236. package/lib/molecules/Tooltip/index.d.ts +0 -1
  237. package/lib/providers/GeneUIProvider/GeneUIProvider.d.ts +0 -30
  238. package/lib/providers/GeneUIProvider/index.d.ts +0 -1
  239. package/localization-4ba17032.js +0 -46
  240. package/objectWithoutPropertiesLoose-e1596bdb.js +0 -62
  241. package/rangeAndSlider-740a236c.js +0 -8676
  242. package/react-beautiful-dnd.esm-8c7b5a83.js +0 -10116
  243. package/react-lifecycles-compat.es-6e1f3768.js +0 -158
  244. package/redux-e591c1b8.js +0 -536
  245. package/tokens-8ab1179c.js +0 -6
  246. package/tslib.es6-f211516f.js +0 -35
  247. 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-c7646e48.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-3188e46e.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-c7646e48.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-ce12e4a9.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-3188e46e.js';
30
- import '../index-122432cd.js';
31
- import '../Scrollbar/index.js';
32
- import '../GeneUIProvider/index.js';
33
- import '../debounce-4419bc2f.js';
34
- import '../index-c7646e48.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-fcbae78d.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-ce12e4a9.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-3188e46e.js';
40
- import '../index-122432cd.js';
41
- import '../Scrollbar/index.js';
42
- import '../GeneUIProvider/index.js';
43
- import '../debounce-4419bc2f.js';
44
- import '../index-c7646e48.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-fcbae78d.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';