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