intelicoreact 0.0.6 → 0.0.9

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 (117) hide show
  1. package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +6 -2
  2. package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
  3. package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +2 -1
  4. package/dist/Atomic/FormElements/Dropdown/Dropdown.js +84 -28
  5. package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +27 -3
  6. package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +50 -7
  7. package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +20 -0
  8. package/dist/Atomic/FormElements/Dropdown/components/Loader.scss +57 -0
  9. package/dist/Atomic/FormElements/Input/Input.js +124 -50
  10. package/dist/Atomic/FormElements/Input/Input.stories.js +19 -15
  11. package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +33 -31
  12. package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +29 -19
  13. package/dist/Atomic/FormElements/InputDateRange/{components/InputDateRange.js → InputDateRange.js} +54 -62
  14. package/dist/Atomic/FormElements/InputDateRange/{components/InputDateRange.scss → InputDateRange.scss} +254 -228
  15. package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +15 -160
  16. package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +72 -34
  17. package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +26 -11
  18. package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +14 -6
  19. package/dist/Atomic/FormElements/InputDateRange/{index.js → dependencies.js} +19 -18
  20. package/dist/Atomic/FormElements/NumericInput/NumericInput.js +292 -0
  21. package/dist/Atomic/FormElements/NumericInput/NumericInput.scss +135 -0
  22. package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +117 -0
  23. package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +10 -3
  24. package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +4 -4
  25. package/dist/Atomic/FormElements/Table/Table.scss +1 -1
  26. package/dist/Atomic/FormElements/Textarea/Textarea.scss +1 -1
  27. package/dist/Atomic/MainMenu/MainMenu.scss +2 -2
  28. package/dist/Atomic/UI/Accordion/Accordion.scss +2 -2
  29. package/dist/Atomic/UI/Arrow/Arrow.js +6 -6
  30. package/dist/Atomic/UI/Arrow/Arrow.scss +0 -3
  31. package/dist/Atomic/UI/Calendar/Calendar.js +8 -5
  32. package/dist/Atomic/UI/Calendar/Calendar.scss +19 -3
  33. package/dist/Atomic/UI/Calendar/Calendar.stories.js +3 -2
  34. package/dist/Atomic/UI/Status/Status.scss +1 -1
  35. package/dist/Constants/index.constants.js +8 -0
  36. package/dist/Functions/inputExecutor.js +58 -0
  37. package/dist/Molecular/Datepicker/Datepicker.js +451 -0
  38. package/dist/Molecular/Datepicker/Datepicker.scss +8 -0
  39. package/dist/Molecular/Datepicker/Datepicker.stories.js +44 -0
  40. package/dist/{Atomic/FormElements/Calendar → Molecular/Datepicker/components}/Calendar.js +50 -39
  41. package/dist/scss/_vars.scss +3 -1
  42. package/dist/scss/main.scss +1 -1
  43. package/package.json +5 -4
  44. package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.js +12 -2
  45. package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
  46. package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +4 -3
  47. package/src/Atomic/FormElements/Dropdown/Dropdown.js +104 -39
  48. package/src/Atomic/FormElements/Dropdown/Dropdown.scss +27 -3
  49. package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +42 -15
  50. package/src/Atomic/FormElements/Dropdown/components/DropdownLoader.js +16 -0
  51. package/src/Atomic/FormElements/Dropdown/components/Loader.scss +57 -0
  52. package/src/Atomic/FormElements/Input/Input.js +108 -37
  53. package/src/Atomic/FormElements/Input/Input.stories.js +43 -22
  54. package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +18 -17
  55. package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +17 -14
  56. package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +219 -0
  57. package/src/Atomic/FormElements/InputDateRange/{components/InputDateRange.scss → InputDateRange.scss} +254 -228
  58. package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +38 -117
  59. package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +92 -53
  60. package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +14 -5
  61. package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +5 -3
  62. package/src/Atomic/FormElements/InputDateRange/{index.js → dependencies.js} +16 -12
  63. package/src/Atomic/FormElements/NumericInput/NumericInput.js +263 -0
  64. package/src/Atomic/FormElements/NumericInput/NumericInput.scss +135 -0
  65. package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +78 -0
  66. package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +6 -3
  67. package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +4 -4
  68. package/src/Atomic/FormElements/Table/Table.scss +1 -1
  69. package/src/Atomic/FormElements/Textarea/Textarea.scss +1 -1
  70. package/src/Atomic/MainMenu/MainMenu.scss +2 -2
  71. package/src/Atomic/UI/Accordion/Accordion.scss +2 -2
  72. package/src/Atomic/UI/Arrow/Arrow.js +4 -4
  73. package/src/Atomic/UI/Arrow/Arrow.scss +0 -3
  74. package/src/Atomic/UI/Calendar/Calendar.js +4 -4
  75. package/src/Atomic/UI/Calendar/Calendar.scss +19 -3
  76. package/src/Atomic/UI/Calendar/Calendar.stories.js +2 -1
  77. package/src/Atomic/UI/Status/Status.scss +1 -1
  78. package/src/Constants/index.constants.js +41 -0
  79. package/src/Functions/inputExecutor.js +53 -0
  80. package/src/Functions/utils.js +4 -1
  81. package/src/Molecular/Datepicker/Datepicker.js +346 -0
  82. package/src/Molecular/Datepicker/Datepicker.scss +8 -0
  83. package/src/Molecular/Datepicker/Datepicker.stories.js +27 -0
  84. package/src/Molecular/Datepicker/components/Calendar.js +118 -0
  85. package/src/scss/_vars.scss +3 -1
  86. package/src/scss/main.scss +1 -1
  87. package/dist/Atomic/FormElements/Calendar/Calendar.scss +0 -543
  88. package/dist/Atomic/FormElements/Calendar/Calendar.stories.js +0 -33
  89. package/dist/scss/anme/_anme-bootstrap-grid.scss +0 -748
  90. package/dist/scss/anme/_anme-elements.scss +0 -269
  91. package/dist/scss/anme/_anme-grid.scss +0 -111
  92. package/dist/scss/anme/_anme-justify.scss +0 -111
  93. package/dist/scss/anme/_anme-mixins-media.scss +0 -116
  94. package/dist/scss/anme/_anme-mixins.scss +0 -166
  95. package/dist/scss/anme/_anme-normalize.scss +0 -8
  96. package/dist/scss/anme/_anme-overall.scss +0 -34
  97. package/dist/scss/anme/_anme-padding-margins.scss +0 -419
  98. package/dist/scss/anme/_anme-table.scss +0 -81
  99. package/dist/scss/anme/_anme-theme.scss +0 -275
  100. package/dist/scss/anme/_anme-vars.scss +0 -91
  101. package/dist/scss/anme/_code-styling.scss +0 -23
  102. package/dist/scss/anme/styles.scss +0 -12
  103. package/src/Atomic/FormElements/InputDateRange/components/InputDateRange.js +0 -230
  104. package/src/scss/anme/_anme-bootstrap-grid.scss +0 -748
  105. package/src/scss/anme/_anme-elements.scss +0 -269
  106. package/src/scss/anme/_anme-grid.scss +0 -111
  107. package/src/scss/anme/_anme-justify.scss +0 -111
  108. package/src/scss/anme/_anme-mixins-media.scss +0 -116
  109. package/src/scss/anme/_anme-mixins.scss +0 -166
  110. package/src/scss/anme/_anme-normalize.scss +0 -8
  111. package/src/scss/anme/_anme-overall.scss +0 -34
  112. package/src/scss/anme/_anme-padding-margins.scss +0 -419
  113. package/src/scss/anme/_anme-table.scss +0 -81
  114. package/src/scss/anme/_anme-theme.scss +0 -275
  115. package/src/scss/anme/_anme-vars.scss +0 -91
  116. package/src/scss/anme/_code-styling.scss +0 -23
  117. package/src/scss/anme/styles.scss +0 -12
@@ -1,5 +1,5 @@
1
- import React, { useState } from 'react';
2
- import InputDateRange from '.';
1
+ import React, { /* useEffect, */ useState } from 'react';
2
+ import InputDateRange from './InputDateRange';
3
3
  import Table from '../Table/Table';
4
4
 
5
5
  global.lng = 'en';
@@ -17,126 +17,47 @@ export default {
17
17
  }
18
18
  };
19
19
 
20
- const tableData = {
21
- header: [
22
- { id: 1, label: 'state' },
23
- { id: 2, label: 'Tags' },
24
- { id: 3, label: 'status' },
25
- { id: 4, label: 'loanAmountApproved' },
26
- { id: 5, label: 'loanAmountRejected' },
27
- { id: 6, label: 'approveRate' },
28
- { id: 7, label: 'actions', type: 'actions' }
29
- ],
30
- rows: [
31
- {
32
- id: 1,
33
- link: { label: 'CA', link: '#s' },
34
- tags: [{ label: 'Label 1' }],
35
- status: { value: '90', status: 'active' },
36
- loanAmountApproved: { value: '$70,000' },
37
- loanAmountRejected: { value: '$30,000' },
38
- approveRate: { value: '70%' }
39
- },
40
- {
41
- id: 2,
42
- link: { label: 'NY', link: '#s' },
43
- advancedTags: [
44
- {
45
- labelLeft: 'home',
46
- labelRight: 'hoods',
47
- active: 3,
48
- pause: 1,
49
- merchants: 5
50
- },
51
- {
52
- labelRight: 'jewelry',
53
- active: 3,
54
- pause: 1,
55
- merchants: 5
56
- },
57
- {
58
- labelLeft: 'home',
59
- labelRight: 'improvement',
60
- active: 0,
61
- pause: 0,
62
- warnLeft: true,
63
- warnLeftMsg: 'landerNotIncluded',
64
- warnRightMsg: 'noMerchants'
65
- },
66
- {
67
- labelLeft: 'home',
68
- labelRight: 'hoods',
69
- active: 3,
70
- pause: 1,
71
- merchants: 5
72
- },
73
- {
74
- labelRight: 'jewelry',
75
- active: 3,
76
- pause: 1,
77
- merchants: 5
78
- }
79
- ],
80
- status: { label: 'Active', className: 'color--green-haze' },
81
- loanAmountApproved: { value: '$3,000' },
82
- loanAmountRejected: { value: '$7,000' },
83
- approveRate: { value: '30%' }
84
- },
85
- {
86
- id: 3,
87
- link: { label: 'NH', link: '#s' },
88
- tags: [{ label: 'Label 1' }, { label: 'Label 2' }, { label: 'Label 3' }],
89
- status: { status: 'error' },
90
- loanAmountApproved: { value: '$70,000' },
91
- loanAmountRejected: { value: '$30,000' },
92
- approveRate: { value: '70%' }
93
- }
94
- ]
95
- };
96
-
97
20
  const Template = args => {
98
- const { dateRange, ...restOfProps } = args;
99
- const [value, setValue] = useState(dateRange);
100
-
101
- const [state, setState] = useState(tableData);
102
-
103
- const rowsWithActions = state?.rows?.map(row => ({
104
- ...row,
105
- actions: row.isDeleted ? [{ type: 'undo' }] : [{ type: 'download' }, { type: 'edit' }, { type: 'delete' }]
106
- }));
107
-
108
- // return <InputDateRange {...restOfProps} value={value} onChange={setValue} />;
109
- return (
110
- <div>
111
- <div className="mb20">
112
- <InputDateRange {...restOfProps} value={value} onChange={setValue} />
113
- </div>
114
- <div>
115
- <Table header={state.header} rows={rowsWithActions} onChange={setState} />
116
- </div>
21
+ const { dateRange, ...restOfProps } = args;
22
+ const [value, setValue] = useState(dateRange);
23
+ // useEffect(() => console.log(value), [value]);
24
+
25
+ // return <InputDateRange {...restOfProps} value={value} onChange={setValue} />;
26
+ return (
27
+ <div>
28
+ <div className="mb20">
29
+ <InputDateRange {...restOfProps} value={value} onChange={setValue} />
117
30
  </div>
118
- );
31
+ </div>
32
+ );
119
33
  };
120
34
 
121
35
  export const InputDateRangeTemplate = Template.bind({});
122
36
 
123
37
  InputDateRangeTemplate.args = {
124
- txt: {},
125
- label: 'Date Range',
126
- dateRange: { intervalKey: 'today'},
127
- id: 'anyToggleButtonId',
128
- className: 'anyExternalContainerClassName',
129
- error: false,
130
- disabled: false,
131
- isHoverable: false,
132
- // short: true,
133
- isCompact: false,
134
- // isFocused: true,
135
- isIntervalsHidden: false,
136
- isCompareHidden: true,
137
- hideArrows: false,
138
- isOptionsRight: false,
139
- // limitRange,
140
- // isUseAbs,
141
- // absTooltip
38
+ txt: {},
39
+ buttonsTypes: {
40
+ // apply: 'ellipse-apply',
41
+ cancel: 'bark-outline'
42
+ },
43
+ label: 'Date Range',
44
+ dateRange: { intervalKey: 'today' },
45
+ id: 'anyToggleButtonId',
46
+ className: 'anyExternalContainerClassName',
47
+ error: false,
48
+ disabled: false,
49
+ isHoverable: false,
50
+ minDate: "",
51
+ maxDate: "",
52
+ // short: true,
53
+ isCompact: false,
54
+ // isFocused: true,
55
+ isIntervalsHidden: false,
56
+ isCompareHidden: true,
57
+ hideArrows: false,
58
+ isOptionsRight: false,
59
+ isShortWeekNames: false
60
+ // limitRange,
61
+ // isUseAbs,
62
+ // absTooltip
142
63
  };
@@ -3,6 +3,8 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import moment from 'moment-timezone';
4
4
  import cn from 'classnames';
5
5
 
6
+ import { getActualDateRange } from '../dependencies';
7
+
6
8
  import SelectInput from '../../Dropdown/Dropdown';
7
9
  import TextInput from '../../Input/Input';
8
10
  import Btn from '../../../UI/Button/Button';
@@ -28,6 +30,7 @@ const Datepicker = props => {
28
30
  const {
29
31
  txt,
30
32
  className,
33
+ buttonsTypes = {},
31
34
  values = {},
32
35
  onChange,
33
36
  onChangeCompare,
@@ -36,6 +39,11 @@ const Datepicker = props => {
36
39
  onChangeInterval,
37
40
  isCompareHidden,
38
41
  limitRange,
42
+ handleItemClick,
43
+ setActiveInterval,
44
+ isShortWeekNames,
45
+ minDate = null,
46
+ maxDate = null
39
47
  } = props;
40
48
  const { start = null, end = null, compare = false } = values;
41
49
  const startDateInputRef = useRef(null);
@@ -64,6 +72,10 @@ const Datepicker = props => {
64
72
  [startDate, endDate, isCompare],
65
73
  );
66
74
 
75
+ const setInterval = () => {
76
+ setActiveInterval(getActualDateRange({ start: startDate, end: endDate }).intervalKey)
77
+ };
78
+
67
79
  const prevEndHour = useRef(endHour);
68
80
 
69
81
  const getStartHourItems = () =>
@@ -127,6 +139,7 @@ const Datepicker = props => {
127
139
  setDate1(moment(startDate));
128
140
  setDate2(moment(endDate));
129
141
  }
142
+ setInterval();
130
143
  }, [startDate, endDate]);
131
144
 
132
145
  useEffect(() => {
@@ -180,7 +193,7 @@ const Datepicker = props => {
180
193
  const handleChangeStartHour = val => {
181
194
  setStartHour(+val);
182
195
  setStartDate(
183
- moment(startDate)
196
+ moment(startDate || moment())
184
197
  .set('hour', +val)
185
198
  .toDate(),
186
199
  );
@@ -189,26 +202,28 @@ const Datepicker = props => {
189
202
  const handleChangeEndHour = val => {
190
203
  const newHour = +val;
191
204
  setEndHour(newHour);
192
- let newEndDate;
193
- if (prevEndHour.current === 0 && newHour !== 0) {
194
- newEndDate = moment(endDate).subtract(1, 'days');
195
- } else if (prevEndHour.current !== 0 && newHour === 0) {
196
- newEndDate = moment(endDate).add(1, 'days');
197
- } else {
198
- newEndDate = endDate;
205
+ let newEndDate = moment();
206
+
207
+ if(endDate){
208
+ if (prevEndHour.current === 0 && newHour !== 0) {
209
+ newEndDate = moment(endDate).subtract(1, 'days');
210
+ } else if (prevEndHour.current !== 0 && newHour === 0) {
211
+ newEndDate = moment(endDate).add(1, 'days');
212
+ }
199
213
  }
214
+
200
215
  prevEndHour.current = newHour;
201
216
  setEndDate(moment(newEndDate).set('hour', newHour).toDate());
202
217
  };
203
218
 
204
219
  const renderButtons = () => (
205
220
  <>
206
- <Btn className="date-picker__button" onClick={() => onCancel()} variant="ellipse-cancel">
221
+ <Btn className="date-picker__button" onClick={() => onCancel()} variant={buttonsTypes?.cancel}>
207
222
  {txt?.buttons?.cancel || 'cancel'}
208
223
  </Btn>
209
224
  <Btn
210
225
  className="date-picker__button"
211
- variant="ellipse-apply"
226
+ variant={buttonsTypes?.apply}
212
227
  disabled={!startDate || !endDate}
213
228
  onClick={() =>
214
229
  onChange({
@@ -245,13 +260,22 @@ const Datepicker = props => {
245
260
 
246
261
  const handleStartDateBlur = e => {
247
262
  let newDate;
248
- if (moment(startDateInput).isValid()) {
249
- newDate = moment(startDateInput).set('hour', parseInt(startHour, 10)).toDate();
250
- setStartDate(newDate);
263
+
264
+ if(!moment(startDateInput).isValid()){
265
+ newDate = startDate;
251
266
  } else {
252
- newDate = startDate;
253
- setStartDateInput(newDate);
267
+ if(minDate && !moment(startDateInput).isSameOrAfter(minDate)){
268
+ newDate = minDate;
269
+ } else if(maxDate && !moment(startDateInput).isSameOrBefore(maxDate)){
270
+ newDate = maxDate;
271
+ } else {
272
+ newDate = moment(startDateInput);
273
+ }
254
274
  }
275
+
276
+ setStartDateInput(newDate);
277
+ setStartDate(newDate.set('hour', parseInt(startHour, 10)).toDate());
278
+
255
279
  doBlur('start', e);
256
280
  setDate1(
257
281
  moment(newDate).isSameOrAfter(moment(date2), 'month') ? moment(date2).subtract(1, 'month') : moment(newDate),
@@ -266,16 +290,24 @@ const Datepicker = props => {
266
290
 
267
291
  const handleEndDateBlur = e => {
268
292
  let newDate;
269
- if (moment(endDateInput).isValid()) {
270
- newDate = moment(endDateInput).set('hour', parseInt(endHour, 10)).toDate();
271
- setEndDate(addDay(newDate));
293
+
294
+ if(!moment(endDateInput).isValid()){
295
+ newDate = endDate;
272
296
  } else {
273
- newDate = endDate;
274
- setEndDateInput(newDate);
297
+ if(minDate && !moment(endDateInput).isSameOrAfter(minDate)){
298
+ newDate = minDate;
299
+ } else if(maxDate && !moment(endDateInput).isSameOrBefore(maxDate)){
300
+ newDate = maxDate;
301
+ } else {
302
+ newDate = moment(endDateInput);
303
+ }
275
304
  }
305
+
306
+ setEndDate(addDay(newDate.set('hour', parseInt(endHour, 10)).toDate()));
307
+ setEndDateInput(newDate);
308
+
276
309
  doBlur('end', e);
277
310
  setDate2(newDate);
278
- setEndDateInput();
279
311
  };
280
312
 
281
313
  const handleKeyPressed = (code, e, type) => {
@@ -283,20 +315,23 @@ const Datepicker = props => {
283
315
  if (code === 27) doBlur(type, e);
284
316
  };
285
317
 
318
+ const startDateValue = startDate ? moment(startDate).format('ll') : '';
319
+ const endDateValue = endDate ? moment(endDate).subtract(1, 'm').format('ll') : '';
320
+
286
321
  return (
287
322
  <div className={cn('date-picker', className)}>
288
323
  <div className="date-picker__header">
289
324
  <div className="date-picker__inputs-block">
290
325
  <TextInput
291
326
  dataTest="datepicker_start-date-input"
292
- className={cn('date-picker__date-input', { 'date-picker__date-input_active': hoverStatus === 'start' })}
293
- value={isStartFocused ? startDateInput : moment(startDate).format('ll')}
294
- disabled={!startDate}
327
+ className={cn( { 'date-picker__date-input_active': hoverStatus === 'start' })}
328
+ value={isStartFocused ? startDateInput : startDateValue}
295
329
  onChange={value => setStartDateInput(handleDateInputOnChange(value))}
296
330
  onFocus={handleStartDateFocus}
331
+ disabled={!startDate}
297
332
  onBlur={handleStartDateBlur}
298
333
  onKeyUp={(code, e) => handleKeyPressed(code, e, 'start')}
299
- ref={startDateInputRef}
334
+ //ref={startDateInputRef}
300
335
  // mask={moment(startDate).format('L').replace(/[0-9]/g, '9')}
301
336
  />
302
337
  <SelectInput
@@ -311,14 +346,14 @@ const Datepicker = props => {
311
346
  <div className="date-picker__inputs-separator date-picker__header--gray">—</div>
312
347
  <TextInput
313
348
  dataTest="datepicker_end-date-input"
314
- className={cn('date-picker__date-input', { 'date-picker__date-input_active': hoverStatus === 'end' })}
315
- value={isEndFocused ? endDateInput : moment(subtractDay(endDate)).format('ll')}
349
+ className={cn({ 'date-picker__date-input_active': hoverStatus === 'end' })}
350
+ value={isEndFocused ? endDateInput : endDateValue}
316
351
  disabled={!endDate}
317
352
  onChange={value => setEndDateInput(handleDateInputOnChange(value))}
318
353
  onFocus={handleEndDateFocus}
319
354
  onBlur={handleEndDateBlur}
320
355
  onKeyUp={(code, e) => handleKeyPressed(code, e, 'end')}
321
- ref={endDateInputRef}
356
+ //ref={endDateInputRef}
322
357
  />
323
358
  <SelectInput
324
359
  dataTest="datepicker_end-hour-select-input"
@@ -339,31 +374,35 @@ const Datepicker = props => {
339
374
 
340
375
 
341
376
  <div className="date-picker__calendars">
342
- <Calendar
343
- className="date-picker__calendar"
344
- date={date1}
345
- setDate={setDate1}
346
- allowNext={!isNearby}
347
- startDate={startDate}
348
- endDate={endDate}
349
- startPrevDate={startPrevDate}
350
- endPrevDate={endPrevDate}
351
- onClick={handleClick}
352
- onHover={handleHover}
353
- limitRange={limitRange}
354
- />
355
- <Calendar
356
- className="date-picker__calendar"
357
- date={date2}
358
- setDate={setDate2}
359
- allowPrev={!isNearby}
360
- startDate={startDate}
361
- endDate={endDate}
362
- startPrevDate={startPrevDate}
363
- endPrevDate={endPrevDate}
364
- onClick={handleClick}
365
- onHover={handleHover}
366
- />
377
+ <div className="date-picker__calendars-wrapper">
378
+ <Calendar
379
+ className="date-picker__calendar"
380
+ date={date1}
381
+ setDate={setDate1}
382
+ allowNext={!isNearby}
383
+ startDate={startDate}
384
+ endDate={endDate}
385
+ startPrevDate={startPrevDate}
386
+ endPrevDate={endPrevDate}
387
+ onClick={handleClick}
388
+ onHover={handleHover}
389
+ limitRange={limitRange}
390
+ isShortWeekNames={isShortWeekNames}
391
+ />
392
+ <Calendar
393
+ className="date-picker__calendar"
394
+ date={date2}
395
+ setDate={setDate2}
396
+ allowPrev={!isNearby}
397
+ startDate={startDate}
398
+ endDate={endDate}
399
+ startPrevDate={startPrevDate}
400
+ endPrevDate={endPrevDate}
401
+ onClick={handleClick}
402
+ onHover={handleHover}
403
+ isShortWeekNames={isShortWeekNames}
404
+ />
405
+ </div>
367
406
  </div>
368
407
  <div className={cn('date-picker__footer', {
369
408
  'date-picker__footer_once-element': isCompareHidden
@@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react';
2
2
  import moment from 'moment-timezone';
3
3
  import cn from 'classnames';
4
4
 
5
- import {INTERVALS as intervals, CUSTOM_INTERVAL_KEY as customKey } from '..';
5
+ import {INTERVALS as intervals, CUSTOM_INTERVAL_KEY as customKey, CUSTOM_INTERVAL_KEY_TEXT } from '../dependencies';
6
6
 
7
7
  import SelectItem from './SelectItem';
8
8
  import Datepicker from './Datepicker';
@@ -10,6 +10,7 @@ import Datepicker from './Datepicker';
10
10
  const OpenedPart = React.forwardRef((props, ref) => {
11
11
  const {
12
12
  txt,
13
+ buttonsTypes,
13
14
  actualValues,
14
15
  onChange = () => {},
15
16
  isHoverable,
@@ -24,12 +25,15 @@ const OpenedPart = React.forwardRef((props, ref) => {
24
25
  isCompare,
25
26
  setIsCompare,
26
27
  toggleOff,
28
+ isShortWeekNames,
29
+ minDate = null,
30
+ maxDate = null
27
31
  } = props;
28
32
 
29
- // const [styles, setStyles] = useState({});
30
-
31
33
  const items = isCompact ? [...Object.keys(intervals)] : [...Object.keys(intervals), customKey];
32
34
 
35
+ const [activeInterval, setActiveInterval] = useState(actualValues.intervalKey);
36
+
33
37
  const handleItemClick = item => {
34
38
  if (item !== customKey) {
35
39
  onChange({
@@ -75,8 +79,8 @@ const OpenedPart = React.forwardRef((props, ref) => {
75
79
  <SelectItem
76
80
  key={index}
77
81
  item={item}
78
- label={(txt?.labels && txt?.labels[item]) || intervals[item]?.label || item}
79
- isActive={actualValues.intervalKey === item}
82
+ label={(txt?.labels && txt?.labels[item]) || intervals[item]?.label || (item === customKey ? CUSTOM_INTERVAL_KEY_TEXT : item )}
83
+ isActive={activeInterval === item}
80
84
  onItemClick={() => handleItemClick(item.value || item)}
81
85
  disabled={item === customKey}
82
86
  />
@@ -86,6 +90,7 @@ const OpenedPart = React.forwardRef((props, ref) => {
86
90
  {!isCompact && (
87
91
  <Datepicker
88
92
  className={cn('opened-part__date-picker')}
93
+ buttonsTypes={buttonsTypes}
89
94
  values={actualValues}
90
95
  onChange={data => {
91
96
  onChange({
@@ -100,6 +105,10 @@ const OpenedPart = React.forwardRef((props, ref) => {
100
105
  onCancel={toggleOff}
101
106
  isCompareHidden={isCompareHidden}
102
107
  limitRange={limitRange}
108
+ setActiveInterval={setActiveInterval}
109
+ isShortWeekNames={isShortWeekNames}
110
+ minDate={minDate}
111
+ maxDate={maxDate}
103
112
  />
104
113
  )}
105
114
  </div>
@@ -1,8 +1,6 @@
1
1
  import React from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
- import icon from '../../../../../../assets/icons/check.svg'
5
-
6
4
  const SelectItem = ({ item, label, isActive, onItemClick, onMouseEnter, disabled }) => (
7
5
  <div
8
6
  className={cn(
@@ -15,7 +13,11 @@ const SelectItem = ({ item, label, isActive, onItemClick, onMouseEnter, disabled
15
13
  onMouseEnter={onMouseEnter}
16
14
  data-item={item}
17
15
  >
18
- {isActive && <object data={icon} className={cn('opened-part__intervals-item-icon-active')} />}
16
+ {isActive && (
17
+ <svg className={cn('opened-part__intervals-item-icon-active')} width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
18
+ <path d="M13.3333 4L5.99999 11.3333L2.66666 8" stroke="black" strokeWidth="1.33333" strokeLinecap="round" strokeLinejoin="round"/>
19
+ </svg>
20
+ )}
19
21
  {label}
20
22
  </div>
21
23
  );
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect, useRef, useCallback } from 'react';
2
2
  import moment from 'moment-timezone';
3
3
 
4
- import InputDateRange from './components/InputDateRange';
4
+ import InputDateRange from './InputDateRange';
5
5
 
6
6
  export const useClickOutside = (hideComponent, additionalComponent) => {
7
7
  const ref = useRef(null);
@@ -89,7 +89,7 @@ export const INTERVALS = {
89
89
  end: () => moment().startOf('month'),
90
90
  },
91
91
  last6Months: {
92
- label: 'Last 6 Months',
92
+ label: '6 Months',
93
93
  start: () => moment().subtract(6, 'month').startOf('month'),
94
94
  end: () => moment().startOf('month'),
95
95
  },
@@ -115,10 +115,9 @@ export const CUSTOM_INTERVAL_KEY_TEXT = 'Custom Date';
115
115
 
116
116
  export const getActualDateRange = inputDateRange => {
117
117
  const actualIntervalKey = (() => {
118
- if (inputDateRange.intervalKey && inputDateRange.intervalKey !== CUSTOM_INTERVAL_KEY) {
118
+ if (inputDateRange.intervalKey && Object.keys(INTERVALS).includes(inputDateRange.intervalKey)) {
119
119
  return inputDateRange.intervalKey;
120
- }
121
- if (inputDateRange.start && inputDateRange.end) {
120
+ } else if (inputDateRange.start && inputDateRange.end) {
122
121
  for (const [key, interval] of Object.entries(INTERVALS)) {
123
122
  if (
124
123
  moment(inputDateRange.start).isSame(interval.start()) &&
@@ -127,20 +126,29 @@ export const getActualDateRange = inputDateRange => {
127
126
  return key;
128
127
  }
129
128
  }
129
+ return CUSTOM_INTERVAL_KEY;
130
130
  }
131
- return null;
131
+ return ALL_TIME_KEY;
132
132
  })();
133
+ if (actualIntervalKey === ALL_TIME_KEY) return {
134
+ intervalKey: ALL_TIME_KEY,
135
+ start: null,
136
+ end: null,
137
+ compare: inputDateRange.compare,
138
+ startPrevDate: null,
139
+ endPrevDate:null
140
+ };
133
141
  const actualValues = {
134
142
  // intervalKey: inputDateRange.intervalKey || customIntervalKey,
135
143
  intervalKey: actualIntervalKey || CUSTOM_INTERVAL_KEY,
136
144
  start:
137
145
  inputDateRange.intervalKey === CUSTOM_INTERVAL_KEY
138
146
  ? inputDateRange?.start
139
- : INTERVALS[inputDateRange.intervalKey]?.start()?.toDate(),
147
+ : INTERVALS[inputDateRange.intervalKey]?.start()?.format('YYYY-MM-DDTHH:mm'),
140
148
  end:
141
149
  inputDateRange.intervalKey === CUSTOM_INTERVAL_KEY
142
150
  ? inputDateRange?.end
143
- : INTERVALS[inputDateRange.intervalKey]?.end()?.toDate(),
151
+ : INTERVALS[inputDateRange.intervalKey]?.end()?.format('YYYY-MM-DDTHH:mm'),
144
152
  compare: inputDateRange.compare,
145
153
  };
146
154
 
@@ -151,7 +159,3 @@ export const getActualDateRange = inputDateRange => {
151
159
  }
152
160
  return actualValues;
153
161
  };
154
-
155
- const component = props => <InputDateRange {...props} />;
156
- export default component;
157
-