diginet-core-ui 1.3.74 → 1.3.75-beta.2

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.
@@ -8,15 +8,100 @@ import ControlComp from '../control';
8
8
  import PropTypes from 'prop-types';
9
9
  import theme from '../../../theme/settings';
10
10
  import { render } from 'react-dom';
11
- import { randomString, updatePosition, date as moment, capitalizeSentenceCase, isEqual } from '../../../utils';
11
+ import { randomString, updatePosition, date as moment, capitalizeSentenceCase, isEqual, classNames } from '../../../utils';
12
12
  import { getGlobal } from '../../../global';
13
13
  import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from '../calendar/function';
14
14
  import locale from '../../../locale';
15
- import { useTheme } from '../../../theme';
15
+ import { alignCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexCol, flexRow, justifyEnd, parseWidth, pointerEventsNone, positionFixed, textCenter, userSelectNone, whiteSpaceNoWrap } from '../../../styles/general';
16
16
  const {
17
- zIndex
18
- } = useTheme();
17
+ colors: {
18
+ system: {
19
+ white
20
+ }
21
+ },
22
+ spacing,
23
+ zIndex: zIndexCORE
24
+ } = theme;
25
+
26
+ const toLocalTimestamp = t => {
27
+ if (typeof t === 'object' && t.getTime) {
28
+ t = t.getTime();
29
+ }
30
+
31
+ if (typeof t === 'string' && !t.match(/\d{13}/)) {
32
+ t = Date.parse(t).getTime();
33
+ }
34
+
35
+ t = parseInt(t, 10) - new Date().getTimezoneOffset() * 60 * 1000;
36
+ return t;
37
+ };
38
+
39
+ const getDaysFrom1970 = t => {
40
+ return Math.floor(toLocalTimestamp(t) / 86400000);
41
+ };
42
+
43
+ const countDays = (start, end, startFromZero) => {
44
+ return Math.abs(getDaysFrom1970(start) - getDaysFrom1970(end)) + (startFromZero ? 0 : 1);
45
+ };
46
+
47
+ const formatValue = (value, format, utc = false) => {
48
+ return moment(value).format(format, utc);
49
+ };
50
+
51
+ const getDateOfWeek = date => {
52
+ let day = date.getDay();
53
+ if (day === 0) day = 7;
54
+ return day - 1;
55
+ };
56
+
57
+ const isValidDate = v => {
58
+ if (!v || v === null) return false;
59
+
60
+ if (Object.prototype.toString.call(v) === '[object Date]') {
61
+ return true;
62
+ }
63
+
64
+ if (!isNaN(Date.parse(new Date(v)))) {
65
+ return true;
66
+ }
67
+
68
+ return false;
69
+ };
70
+
71
+ const isValidValues = v => {
72
+ if (!v || !Array.isArray(v) || v.length !== 2) {
73
+ return false;
74
+ }
75
+
76
+ if (isValidDate(v[0]) && isValidDate(v[1]) && +moment(v[0]).diff(v[1]) <= 0) {
77
+ return true;
78
+ }
79
+
80
+ return false;
81
+ };
82
+
83
+ const isToday = day => {
84
+ return +moment(day).diff(new Date().setHours(0, 0, 0, 0)) === 0 ? unique.day.today : '';
85
+ };
86
+
87
+ const isLimit = (day, max, min) => {
88
+ return isBefore(min, day) || isAfter(max, day) ? unique.day.limit : '';
89
+ };
90
+
91
+ const isBefore = (min, time) => {
92
+ return min && isValidDate(min) && moment(time).diff(min) < 0;
93
+ };
94
+
95
+ const isAfter = (max, time) => {
96
+ return max && isValidDate(max) && moment(time).diff(max) > 0;
97
+ };
98
+
99
+ const parseDate = day => {
100
+ return Date.parse(new Date(day));
101
+ };
102
+
19
103
  const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
104
+ action = {},
20
105
  actionIconAt,
21
106
  controls,
22
107
  clearAble,
@@ -24,7 +109,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
24
109
  disabled,
25
110
  displayFormat,
26
111
  error,
27
- errorProps,
112
+ helperTextProps,
28
113
  inputProps,
29
114
  inputStyle,
30
115
  label,
@@ -80,196 +165,10 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
80
165
  right: useRef(null),
81
166
  content: useRef(null)
82
167
  };
83
- useImperativeHandle(reference, () => ({
84
- get: () => {
85
- return ref.current;
86
- }
87
- }));
88
- const [id] = useState(randomString(6, {
89
- allowSymbol: false
90
- }));
91
- const unique = {
92
- backGr: 'DGN-UI-Portal',
93
- close: 'DGN-UI-DateRangePickerV2-close',
94
- cancel: 'DGN-UI-DateRangePickerV2-cancel',
95
- confirm: 'DGN-UI-DateRangePickerV2-confirm',
96
- divider: 'DGN-UI-DateRangePickerV2-Divider',
97
- disabled: 'DGN-UI-DateRangePickerV2-disabled',
98
- error: 'DGN-UI-DateRangePickerV2-error',
99
- focus: 'DGN-UI-DateRangePickerV2-focus',
100
- footer: 'DGN-UI-DateRangePickerV2-Footer',
101
- picker: 'DGN-UI-DateRangePickerV2-Picker-' + id,
102
- wrapper: 'DGN-UI-DateRangePickerV2-Wrapper',
103
- container: 'DGN-UI-DateRangePickerV2',
104
- icon: 'DGN-UI-DateRangePickerV2-Icon',
105
- tooltip: 'DGN-UI-DateRangePickerV2-Tooltip',
106
- navigator: {
107
- navigator: 'DGN-UI-DateRangePickerV2-Navigator',
108
- around: 'DGN-UI-DateRangePickerV2-Navigator-Around',
109
- center: 'DGN-UI-DateRangePickerV2-Navigator-Center'
110
- },
111
- table: {
112
- container: 'DGN-UI-DateRangePickerV2-Table-Container',
113
- table: 'DGN-UI-DateRangePickerV2-Table-Table',
114
- header: 'DGN-UI-DateRangePickerV2-Table-Header',
115
- raw: 'DGN-UI-DateRangePickerV2-Table-Raw',
116
- data: 'DGN-UI-DateRangePickerV2-Table-Data'
117
- },
118
- day: {
119
- day: 'DGN-UI-DateRangePickerV2-Day',
120
- week: 'DGN-UI-DateRangePickerV2-Week',
121
- today: 'DGN-UI-DateRangePickerV2-Day-today',
122
- active: 'DGN-UI-DateRangePickerV2-Day-active',
123
- limit: 'DGN-UI-DateRangePickerV2-Day-limit',
124
- from: 'DGN-UI-DateRangePickerV2-Day-from',
125
- to: 'DGN-UI-DateRangePickerV2-Day-to',
126
- between: 'DGN-UI-DateRangePickerV2-Day-between'
127
- }
128
- };
129
168
  const closeText = getGlobal(['close']);
130
169
  const cancelText = getGlobal(['cancel']);
131
170
  const confirmText = getGlobal(['confirm']);
132
171
  const unitText = getGlobal([unitCount]);
133
- const iconAreaCSS = css`
134
- align-items: center;
135
- color: inherit;
136
- display: flex;
137
- width: 24px;
138
- & span {
139
- padding: 0;
140
- }
141
- .${unique.icon} {
142
- cursor: pointer;
143
- opacity: 0;
144
- transition: display 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
145
- opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
146
- display: none;
147
- will-change: display, opacity;
148
- }
149
- .${unique.icon}-accept {
150
- opacity: 1;
151
- display: block;
152
- }
153
- `;
154
- const hiddenStyle = {
155
- opacity: 0,
156
- display: 'none'
157
- };
158
- const activeStyle = {
159
- opacity: 1,
160
- pointerEvents: 'none',
161
- display: 'block'
162
- };
163
- const controlContainerCSS = css`
164
- display: flex;
165
- justify-content: flex-end;
166
- margin: 0 16px 16px;
167
- `;
168
- const buttonProps = {
169
- style: {
170
- display: 'none',
171
- margin: '0 2px',
172
- padding: '7px 8px',
173
- visibility: 'hidden'
174
- }
175
- };
176
-
177
- const typographyProps = className => {
178
- return {
179
- className,
180
- color: 'inherit',
181
- style: {
182
- alignItems: 'center',
183
- borderRadius: '50%',
184
- display: 'flex',
185
- height: 24,
186
- justifyContent: 'center',
187
- margin: 'auto',
188
- pointerEvents: 'none',
189
- transition: 'background-color 150ms linear',
190
- width: 24
191
- },
192
- type: 'h6'
193
- };
194
- };
195
-
196
- const dividerProps = {
197
- direction: 'vertical',
198
- className: unique.divider,
199
- height: '100%',
200
- style: {
201
- height: '226px',
202
- margin: '18px 2px 0px'
203
- }
204
- };
205
- const pickerCSS = {
206
- backGr: 'background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: 9001;',
207
- container: css`
208
- background-color: ${theme.colors.white};
209
- border-radius: ${theme.border.radius};
210
- box-shadow: ${theme.boxShadows.large};
211
- display: flex;
212
- flex-flow: column;
213
- .${unique.wrapper} {
214
- display: flex;
215
- min-width: 633px;
216
- }
217
- .${unique.tooltip} {
218
- background-color: rgba(21, 26, 48, 0.9);
219
- border-radius: ${theme.border.radius};
220
- height: 18px;
221
- min-width: 65px;
222
- padding: 3px 6px;
223
- pointer-events: none;
224
- position: fixed;
225
- text-align: center;
226
- transition: left 0.05s ease-in, top 0.05s ease-in;
227
- user-select: none;
228
- vertical-align: middle;
229
- visibility: hidden;
230
- white-space: nowrap;
231
- will-change: left top visibility;
232
- z-index: ${zIndex(3)};
233
- }
234
- @media only screen and (max-width: 599px) {
235
- max-width: 400px;
236
- .${unique.wrapper} {
237
- flex-direction: column;
238
- min-width: 260px;
239
- }
240
- .${unique.divider} {
241
- height: 1px !important;
242
- margin: 0px 16px !important;
243
- width: calc(100% - 32px) !important;
244
- }
245
- }
246
- `,
247
- picker: (position, width) => css`
248
- border-radius: ${theme.border.radius};
249
- height: max-content;
250
- left: ${position.left}px;
251
- max-width: 805px;
252
- min-width: ${window.innerWidth <= 633 ? 300 : 633}px;
253
- opacity: 0;
254
- position: fixed;
255
- top: ${position.top}px;
256
- transform: scale(0);
257
- transform-origin: ${position.transformOrigin};
258
- transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
259
- transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
260
- width: ${width}px;
261
- z-index: ${zIndex(2)};
262
- `,
263
- active: {
264
- opacity: 1,
265
- transform: 'scale(1)'
266
- },
267
- remove: {
268
- opacity: 0,
269
- pointerEvents: 'none',
270
- transform: 'scale(0)'
271
- }
272
- };
273
172
  const updateValues = useCallback(v => {
274
173
  values.current = v;
275
174
  setValues();
@@ -291,63 +190,6 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
291
190
  setValueTo();
292
191
  }, [valueTo]);
293
192
 
294
- const toLocalTimestamp = t => {
295
- if (typeof t === 'object' && t.getTime) {
296
- t = t.getTime();
297
- }
298
-
299
- if (typeof t === 'string' && !t.match(/\d{13}/)) {
300
- t = Date.parse(t).getTime();
301
- }
302
-
303
- t = parseInt(t, 10) - new Date().getTimezoneOffset() * 60 * 1000;
304
- return t;
305
- };
306
-
307
- const getDaysFrom1970 = t => {
308
- return Math.floor(toLocalTimestamp(t) / 86400000);
309
- };
310
-
311
- const countDays = (start, end) => {
312
- return Math.abs(getDaysFrom1970(start) - getDaysFrom1970(end)) + (startFromZero ? 0 : 1);
313
- };
314
-
315
- const formatValue = (value, format, utc = false) => {
316
- return moment(value).format(format, utc);
317
- };
318
-
319
- const getDateOfWeek = date => {
320
- let day = date.getDay();
321
- if (day === 0) day = 7;
322
- return day - 1;
323
- };
324
-
325
- const isValidDate = v => {
326
- if (!v || v === null) return false;
327
-
328
- if (Object.prototype.toString.call(v) === '[object Date]') {
329
- return true;
330
- }
331
-
332
- if (!isNaN(Date.parse(new Date(v)))) {
333
- return true;
334
- }
335
-
336
- return false;
337
- };
338
-
339
- const isValidValues = v => {
340
- if (!v || !Array.isArray(v) || v.length !== 2) {
341
- return false;
342
- }
343
-
344
- if (isValidDate(v[0]) && isValidDate(v[1]) && +moment(v[0]).diff(v[1]) <= 0) {
345
- return true;
346
- }
347
-
348
- return false;
349
- };
350
-
351
193
  const isActive = day => {
352
194
  if (values.current[0] && +moment(values.current[0]).diff(day) === 0) {
353
195
  if (values.current[1] && +moment(values.current[0]).diff(values.current[1]) < 0) {
@@ -362,10 +204,6 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
362
204
  return '';
363
205
  };
364
206
 
365
- const isToday = day => {
366
- return +moment(day).diff(new Date().setHours(0, 0, 0, 0)) === 0 ? unique.day.today : '';
367
- };
368
-
369
207
  const isBetween = dayParsed => {
370
208
  if (values.current[0] && values.current[1] && parseDate(values.current[0]) < dayParsed && dayParsed < parseDate(values.current[1])) {
371
209
  return unique.day.between;
@@ -374,18 +212,6 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
374
212
  return '';
375
213
  };
376
214
 
377
- const isLimit = (day, max, min) => {
378
- return isBefore(min, day) || isAfter(max, day) ? unique.day.limit : '';
379
- };
380
-
381
- const isBefore = (min, time) => {
382
- return min && isValidDate(min) && moment(time).diff(min) < 0;
383
- };
384
-
385
- const isAfter = (max, time) => {
386
- return max && isValidDate(max) && moment(time).diff(max) > 0;
387
- };
388
-
389
215
  const countDay = v => {
390
216
  if (v && Array.isArray(v) && v.length === 2) {
391
217
  return Number(+moment(v[1]).diff(v[0]) + (startFromZero ? 0 : 1));
@@ -447,10 +273,6 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
447
273
  }
448
274
  };
449
275
 
450
- const parseDate = day => {
451
- return Date.parse(new Date(day));
452
- };
453
-
454
276
  const renderCalendar = (time, type) => {
455
277
  time = new Date(time);
456
278
  const firstDay = new Date(new Date(time).setDate(1)),
@@ -472,7 +294,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
472
294
  tableData.push(jsx("td", {
473
295
  key: `previous_month-${prevDate - i + 1}`,
474
296
  "data-time": day - 1,
475
- className: `${[unique.table.data, 'previous_month', isBetween(day - 1)].join(' ').trim().replace(/ +(?= )/g, '')}`
297
+ className: classNames(unique.table.data, 'previous_month', isBetween(day - 1))
476
298
  }, jsx("span", {
477
299
  className: unique.day.day
478
300
  })));
@@ -487,9 +309,23 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
487
309
  tableData.push(jsx("td", {
488
310
  key: `this_month-${i + 1}`,
489
311
  "data-time": Date.parse(day),
490
- className: `${[unique.table.data, 'this_month', isToday(day), isActive(day), (max && max !== undefined || min && min !== undefined) && isLimit(day, new Date(max).setHours(0, 0, 0, 0), new Date(min).setHours(0, 0, 0, 0)), isBetween(Date.parse(day))].join(' ').trim().replace(/ +(?= )/g, '')}`,
312
+ className: classNames(unique.table.data, 'this_month', isToday(day), isActive(day), (max && max !== undefined || min && min !== undefined) && isLimit(day, new Date(max).setHours(0, 0, 0, 0), new Date(min).setHours(0, 0, 0, 0)), isBetween(Date.parse(day))),
491
313
  onClick: onDayClick
492
- }, jsx(Typography, { ...typographyProps(unique.day.day)
314
+ }, jsx(Typography, {
315
+ className: unique.day.day,
316
+ color: 'inherit',
317
+ style: {
318
+ alignItems: 'center',
319
+ borderRadius: '50%',
320
+ display: 'flex',
321
+ height: 24,
322
+ justifyContent: 'center',
323
+ margin: 'auto',
324
+ pointerEvents: 'none',
325
+ transition: 'background-color 150ms linear',
326
+ width: 24
327
+ },
328
+ type: 'h6'
493
329
  }, i + 1)));
494
330
  }
495
331
  /**
@@ -502,7 +338,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
502
338
  tableData.push(jsx("td", {
503
339
  key: `next_month-${i + 1}`,
504
340
  "data-time": i < 6 - weekDateLast && day + 1,
505
- className: `${[unique.table.data, 'next_month', i < 6 - weekDateLast && isBetween(day + 1)].join(' ').trim().replace(/ +(?= )/g, '')}`
341
+ className: classNames(unique.table.data, 'next_month', i < 6 - weekDateLast && isBetween(day + 1))
506
342
  }, jsx("span", {
507
343
  className: unique.day.day
508
344
  })));
@@ -512,7 +348,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
512
348
  for (let j = 0; j < 7; j++) {
513
349
  tableRaw.push(tableData[7 * i + j] || jsx("td", {
514
350
  key: 7 * i + j,
515
- className: `${[unique.table.data, 'next_month'].join(' ').trim().replace(/ +(?= )/g, '')}`
351
+ className: classNames(unique.table.data, 'next_month')
516
352
  }));
517
353
  }
518
354
 
@@ -569,7 +405,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
569
405
  }
570
406
  };
571
407
 
572
- const getPickerStyle = () => {
408
+ const getPickerStyle = anchor => {
573
409
  const {
574
410
  innerHeight,
575
411
  innerWidth
@@ -579,8 +415,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
579
415
  height,
580
416
  top,
581
417
  width
582
- } = ipConRef.current.getBoundingClientRect();
583
- const pickerHeight = width < 567 ? controls ? 550 : 495 : controls ? 310 : 256;
418
+ } = anchor instanceof Element ? anchor.getBoundingClientRect() : ipConRef.current.getBoundingClientRect();
419
+ const pickerHeight = innerWidth < 567 ? controls ? 550 : 495 : controls ? 310 : 256;
584
420
  let style = {};
585
421
  style.left = left;
586
422
  style.top = top + height + 4;
@@ -588,7 +424,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
588
424
 
589
425
  if (style.top + pickerHeight > innerHeight) {
590
426
  if (top > pickerHeight) {
591
- style.top = top - pickerHeight - 4;
427
+ style.top = innerHeight - pickerHeight - 4;
592
428
  style.transformOrigin = '50% 80%';
593
429
  } else {
594
430
  style.top = Math.round((innerHeight - pickerHeight - 16) / 2);
@@ -631,10 +467,10 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
631
467
  return background;
632
468
  };
633
469
 
634
- const createPicker = () => {
470
+ const createPicker = anchor => {
635
471
  const picker = document.createElement('div');
636
472
  picker.id = unique.picker;
637
- picker.style.cssText = getPickerStyle();
473
+ picker.style.cssText = getPickerStyle(anchor);
638
474
  return picker;
639
475
  };
640
476
 
@@ -869,7 +705,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
869
705
  }
870
706
 
871
707
  if (values.current[0] && !values.current[1]) {
872
- const dates = Math.abs(countDays(new Date(values.current), new Date(currentTime)));
708
+ const dates = Math.abs(countDays(new Date(values.current), new Date(currentTime), startFromZero));
873
709
  const tooltip = tooltipRef.current;
874
710
 
875
711
  if (onShowTooltip && dates > 0) {
@@ -919,9 +755,9 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
919
755
  renderCalendar(valueTo.current, 'to');
920
756
  };
921
757
 
922
- const openPicker = () => {
758
+ const openPicker = anchor => {
923
759
  const backGr = createBackground();
924
- const picker = createPicker();
760
+ const picker = createPicker(anchor);
925
761
  render(pickerComp, backGr.appendChild(picker));
926
762
  const arr = pickerRef.current.getElementsByTagName('td');
927
763
  updateTempValues(values.current.length === 1 ? [values.current[0], values.current[0]] : values.current);
@@ -1116,8 +952,23 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1116
952
  closePicker();
1117
953
  };
1118
954
  }, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
955
+ useImperativeHandle(reference, () => {
956
+ const currentRef = ref.current || {};
957
+ currentRef.element = ref.current;
958
+ currentRef.get = ref.current;
959
+ const _instance = {
960
+ show: el => openPicker(el),
961
+ close: closePicker,
962
+ ...action
963
+ }; // methods
964
+
965
+ _instance.__proto__ = {}; // hidden methods
966
+
967
+ currentRef.instance = _instance;
968
+ return currentRef;
969
+ });
1119
970
  const iconComp = jsx("div", {
1120
- css: iconAreaCSS,
971
+ css: IconAreaCSS,
1121
972
  ref: iconRef
1122
973
  }, jsx(ButtonIcon, {
1123
974
  viewType: 'ghost',
@@ -1135,7 +986,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1135
986
  const endIcon = actionIconAt === 'end' && iconComp;
1136
987
  const startIcon = actionIconAt === 'start' && iconComp;
1137
988
  const footerMemo = jsx("div", {
1138
- css: controlContainerCSS,
989
+ css: ControlContainerCSS,
1139
990
  className: unique.footer,
1140
991
  ref: footerRef
1141
992
  }, jsx(Button, { ...buttonProps,
@@ -1171,7 +1022,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1171
1022
  className: unique.tooltip,
1172
1023
  ref: tooltipRef
1173
1024
  }, jsx(Typography, {
1174
- color: theme.colors.white,
1025
+ color: white,
1175
1026
  type: 'p2'
1176
1027
  }));
1177
1028
  const pickerComp = jsx("div", {
@@ -1179,7 +1030,14 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1179
1030
  ref: pickerRef
1180
1031
  }, jsx("div", {
1181
1032
  className: unique.wrapper
1182
- }, leftCalendarComp, jsx(Divider, { ...dividerProps
1033
+ }, leftCalendarComp, jsx(Divider, {
1034
+ direction: 'vertical',
1035
+ className: unique.divider,
1036
+ height: '100%',
1037
+ style: {
1038
+ height: '226px',
1039
+ margin: spacing([4.5, 0.5, 0])
1040
+ }
1183
1041
  }), rightCalendarComp), tooltipComp, !!controls && footerMemo);
1184
1042
  return jsx(ControlComp, { ...props,
1185
1043
  disabled: disabled,
@@ -1209,10 +1067,162 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1209
1067
  className: 'non-effect allow-disabled'
1210
1068
  },
1211
1069
  endIcon: endIcon
1212
- }), !!error && jsx(HelperText, { ...errorProps,
1070
+ }), !!error && jsx(HelperText, { ...helperTextProps,
1213
1071
  disabled: disabled
1214
1072
  }, error));
1215
1073
  }));
1074
+ const unique = {
1075
+ backGr: 'DGN-UI-Portal',
1076
+ close: 'DGN-UI-DateRangePickerV2-close',
1077
+ cancel: 'DGN-UI-DateRangePickerV2-cancel',
1078
+ confirm: 'DGN-UI-DateRangePickerV2-confirm',
1079
+ divider: 'DGN-UI-DateRangePickerV2-Divider',
1080
+ disabled: 'DGN-UI-DateRangePickerV2-disabled',
1081
+ error: 'DGN-UI-DateRangePickerV2-error',
1082
+ focus: 'DGN-UI-DateRangePickerV2-focus',
1083
+ footer: 'DGN-UI-DateRangePickerV2-Footer',
1084
+ picker: 'DGN-UI-DateRangePickerV2-Picker-' + randomString(6, {
1085
+ allowSymbol: false
1086
+ }),
1087
+ wrapper: 'DGN-UI-DateRangePickerV2-Wrapper',
1088
+ container: 'DGN-UI-DateRangePickerV2',
1089
+ icon: 'DGN-UI-DateRangePickerV2-Icon',
1090
+ tooltip: 'DGN-UI-DateRangePickerV2-Tooltip',
1091
+ navigator: {
1092
+ navigator: 'DGN-UI-DateRangePickerV2-Navigator',
1093
+ around: 'DGN-UI-DateRangePickerV2-Navigator-Around',
1094
+ center: 'DGN-UI-DateRangePickerV2-Navigator-Center'
1095
+ },
1096
+ table: {
1097
+ container: 'DGN-UI-DateRangePickerV2-Table-Container',
1098
+ table: 'DGN-UI-DateRangePickerV2-Table-Table',
1099
+ header: 'DGN-UI-DateRangePickerV2-Table-Header',
1100
+ raw: 'DGN-UI-DateRangePickerV2-Table-Raw',
1101
+ data: 'DGN-UI-DateRangePickerV2-Table-Data'
1102
+ },
1103
+ day: {
1104
+ day: 'DGN-UI-DateRangePickerV2-Day',
1105
+ week: 'DGN-UI-DateRangePickerV2-Week',
1106
+ today: 'DGN-UI-DateRangePickerV2-Day-today',
1107
+ active: 'DGN-UI-DateRangePickerV2-Day-active',
1108
+ limit: 'DGN-UI-DateRangePickerV2-Day-limit',
1109
+ from: 'DGN-UI-DateRangePickerV2-Day-from',
1110
+ to: 'DGN-UI-DateRangePickerV2-Day-to',
1111
+ between: 'DGN-UI-DateRangePickerV2-Day-between'
1112
+ }
1113
+ };
1114
+ const hiddenStyle = {
1115
+ opacity: 0,
1116
+ display: 'none'
1117
+ };
1118
+ const activeStyle = {
1119
+ opacity: 1,
1120
+ pointerEvents: 'none',
1121
+ display: 'block'
1122
+ };
1123
+ const buttonProps = {
1124
+ style: {
1125
+ display: 'none',
1126
+ margin: spacing([0, 0.5]),
1127
+ padding: spacing([1.75, 2]),
1128
+ visibility: 'hidden'
1129
+ }
1130
+ };
1131
+ const IconAreaCSS = css`
1132
+ ${flexRow};
1133
+ ${alignCenter};
1134
+ ${parseWidth(24)};
1135
+ color: inherit;
1136
+ & span {
1137
+ padding: 0;
1138
+ }
1139
+ .${unique.icon} {
1140
+ ${displayNone};
1141
+ ${cursorPointer};
1142
+ opacity: 0;
1143
+ transition: display 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
1144
+ will-change: display, opacity;
1145
+ }
1146
+ .${unique.icon}-accept {
1147
+ ${displayBlock};
1148
+ opacity: 1;
1149
+ }
1150
+ `;
1151
+ const ControlContainerCSS = css`
1152
+ ${flexRow};
1153
+ ${justifyEnd};
1154
+ margin: ${spacing([0, 4, 4])};
1155
+ `;
1156
+ const pickerCSS = {
1157
+ backGr: `
1158
+ background-color: transparent;
1159
+ inset: 0px; pointer-events: auto;
1160
+ position: fixed;
1161
+ z-index: ${zIndexCORE(1)};`,
1162
+ container: css`
1163
+ ${flexCol};
1164
+ ${borderRadius4px};
1165
+ background-color: ${white};
1166
+ box-shadow: ${theme.boxShadows.large};
1167
+ .${unique.wrapper} {
1168
+ ${flexRow};
1169
+ min-width: 633px;
1170
+ }
1171
+ .${unique.tooltip} {
1172
+ ${borderRadius4px};
1173
+ ${pointerEventsNone};
1174
+ ${positionFixed};
1175
+ ${textCenter};
1176
+ ${userSelectNone};
1177
+ ${whiteSpaceNoWrap};
1178
+ background-color: rgba(21, 26, 48, 0.9);
1179
+ height: 18px;
1180
+ min-width: 65px;
1181
+ padding: ${spacing([0.75, 1.5])};
1182
+ transition: left 0.05s ease-in, top 0.05s ease-in;
1183
+ vertical-align: middle;
1184
+ visibility: hidden;
1185
+ will-change: left top visibility;
1186
+ z-index: ${zIndexCORE(3)};
1187
+ }
1188
+ @media only screen and (max-width: 599px) {
1189
+ max-width: 400px;
1190
+ .${unique.wrapper} {
1191
+ flex-direction: column;
1192
+ min-width: 260px;
1193
+ }
1194
+ .${unique.divider} {
1195
+ height: 1px !important;
1196
+ margin: ${spacing([0, 4])} !important;
1197
+ width: calc(100% - 32px) !important;
1198
+ }
1199
+ }
1200
+ `,
1201
+ picker: (position, width) => css`
1202
+ ${borderRadius4px};
1203
+ ${positionFixed};
1204
+ ${parseWidth(width)};
1205
+ height: max-content;
1206
+ left: ${position.left}px;
1207
+ max-width: 805px;
1208
+ min-width: ${window.innerWidth <= 633 ? 300 : 633}px;
1209
+ opacity: 0;
1210
+ top: ${position.top}px;
1211
+ transform: scale(0);
1212
+ transform-origin: ${position.transformOrigin};
1213
+ transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
1214
+ z-index: ${zIndexCORE(2)};
1215
+ `,
1216
+ active: {
1217
+ opacity: 1,
1218
+ transform: 'scale(1)'
1219
+ },
1220
+ remove: {
1221
+ opacity: 0,
1222
+ pointerEvents: 'none',
1223
+ transform: 'scale(0)'
1224
+ }
1225
+ };
1216
1226
  DateRangePickerV2.defaultProps = {
1217
1227
  actionIconAt: 'end',
1218
1228
  clearAble: false,
@@ -1231,82 +1241,85 @@ DateRangePickerV2.defaultProps = {
1231
1241
  viewType: 'underlined'
1232
1242
  };
1233
1243
  DateRangePickerV2.propTypes = {
1234
- /** action icons position */
1244
+ /** Position of action icons. */
1235
1245
  actionIconAt: PropTypes.oneOf(['end', 'start']),
1236
1246
 
1237
- /** display the clear icon if true */
1247
+ /** If `true`, display the clear icon. */
1238
1248
  clearAble: PropTypes.bool,
1239
1249
 
1240
- /** if 'true' the calendar will have a footer controls */
1250
+ /** If `true`, the calendar will have a footer controls. */
1241
1251
  controls: PropTypes.bool,
1242
1252
 
1243
- /** the count unit when select */
1253
+ /** The count unit when select. */
1244
1254
  unitCount: PropTypes.oneOf(['day', 'night']),
1245
1255
 
1246
- /** the default value of the component */
1256
+ /** Default value of the component. */
1247
1257
  defaultValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.instanceOf(Date)), PropTypes.arrayOf(PropTypes.string)]),
1248
1258
 
1249
- /** if 'true' the form control will be disabled */
1259
+ /** If `true`, the component is disabled. */
1250
1260
  disabled: PropTypes.bool,
1251
1261
 
1252
- /** format to display value */
1262
+ /** Format to display value. */
1253
1263
  displayFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
1254
1264
 
1255
- /** error of the form control */
1265
+ /** Error displayed below input. */
1256
1266
  error: PropTypes.string,
1257
1267
 
1258
- /** inputProps are properties of the input element */
1268
+ /** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) of helper text. */
1269
+ helperTextProps: PropTypes.object,
1270
+
1271
+ /** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-input-inputbase) of input base */
1259
1272
  inputProps: PropTypes.object,
1260
1273
 
1261
- /** inputStyle is style of input element */
1274
+ /** Consult [InputBase's](https://core.diginet.com.vn/ui/?path=/story/form-control-input-inputbase) documents. */
1262
1275
  inputStyle: PropTypes.object,
1263
1276
 
1264
- /** content of the label element */
1277
+ /** The label of the component. */
1265
1278
  label: PropTypes.string,
1266
1279
 
1267
- /** labelProps are properties if the label element */
1280
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) of label. */
1268
1281
  labelProps: PropTypes.object,
1269
1282
 
1270
- /** min value of date picker */
1283
+ /** Min value of date picker. */
1271
1284
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
1272
1285
 
1273
- /** max value of date picker */
1286
+ /** Max value of date picker. */
1274
1287
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
1275
1288
 
1276
- /** a callback function when value input change */
1289
+ /** Callback fired when the value is changed. */
1277
1290
  onChange: PropTypes.func,
1278
1291
 
1279
- /** hints for input */
1292
+ /** The short hint displayed in the input before the user enters a value. */
1280
1293
  placeholder: PropTypes.string,
1281
1294
 
1282
- /** allow close Popup when press ESC */
1295
+ /** If `true`, hitting escape will close component. */
1283
1296
  pressESCToClose: PropTypes.bool,
1284
1297
 
1285
- /** status read only of input */
1298
+ /** If `true`, the component is readOnly. */
1286
1299
  readOnly: PropTypes.bool,
1287
1300
 
1288
- /** required state of the form control */
1301
+ /** If `true`, the input element is required. */
1289
1302
  required: PropTypes.bool,
1290
1303
 
1291
- /** format of the returned value */
1304
+ /** Format of the returned value. */
1292
1305
  returnFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
1293
1306
 
1294
1307
  /** If `true`, show unit count. */
1295
1308
  showUnitCount: PropTypes.bool,
1296
1309
 
1297
- /** counter with start with 0 or 1 */
1310
+ /** Counter with start with 0 or 1. */
1298
1311
  startFromZero: PropTypes.bool,
1299
1312
 
1300
- /** style of the component */
1313
+ /** Style inline of component. */
1301
1314
  style: PropTypes.object,
1302
1315
 
1303
- /** text align of the input */
1316
+ /** Text align of the input. */
1304
1317
  textAlign: PropTypes.oneOf(['center', 'end', 'start']),
1305
1318
 
1306
- /** value of the component */
1319
+ /** The value of the input element, required for a controlled component. */
1307
1320
  value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string])),
1308
1321
 
1309
- /** view type of the form control */
1322
+ /** The variant to use. */
1310
1323
  viewType: PropTypes.oneOf(['outlined', 'underlined'])
1311
1324
  };
1312
1325
  export default DateRangePickerV2;