intelicoreact 1.8.8 → 1.8.10

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 (128) hide show
  1. package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.jsx +18 -1
  2. package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.jsx +121 -1
  3. package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.jsx +507 -1
  4. package/dist/Atomic/FormElements/MultiSelect/MultiSelect.jsx +46 -1
  5. package/dist/Atomic/FormElements/NumericInput/NumericInput.jsx +337 -1
  6. package/dist/Atomic/FormElements/RadioGroup/RadioGroup.jsx +66 -1
  7. package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.jsx +78 -1
  8. package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.jsx +54 -1
  9. package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.jsx +183 -1
  10. package/dist/Atomic/FormElements/RangeList/RangeList.jsx +181 -1
  11. package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.jsx +41 -1
  12. package/dist/Atomic/FormElements/RangeSlider/RangeSlider.jsx +449 -1
  13. package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.jsx +865 -1
  14. package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.jsx +37 -1
  15. package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.jsx +48 -1
  16. package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.jsx +62 -1
  17. package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.jsx +175 -1
  18. package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.jsx +65 -1
  19. package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.jsx +118 -1
  20. package/dist/Atomic/FormElements/Text/Text.jsx +126 -1
  21. package/dist/Atomic/FormElements/Textarea/Textarea.jsx +61 -1
  22. package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.jsx +181 -1
  23. package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.jsx +60 -1
  24. package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.jsx +83 -1
  25. package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.jsx +80 -1
  26. package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.jsx +103 -1
  27. package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.jsx +115 -1
  28. package/dist/Atomic/Layout/Header/Header.jsx +86 -1
  29. package/dist/Atomic/Layout/MainMenu/MainMenu.jsx +164 -1
  30. package/dist/Atomic/UI/AccordionTable/AccordionTable.jsx +250 -1
  31. package/dist/Atomic/UI/AccordionText/AccordionText.jsx +68 -1
  32. package/dist/Atomic/UI/Arrow/Arrow.jsx +134 -1
  33. package/dist/Atomic/UI/Box/Box.jsx +53 -1
  34. package/dist/Atomic/UI/Chart/Chart.jsx +178 -1
  35. package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.jsx +78 -1
  36. package/dist/Atomic/UI/Chart/partial/optionsConstructor.jsx +334 -1
  37. package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.jsx +111 -1
  38. package/dist/Atomic/UI/DateTime/DateTime.jsx +57 -1
  39. package/dist/Atomic/UI/DebugContainer/DebugContainer.jsx +44 -1
  40. package/dist/Atomic/UI/DebugContainer/useDebugContainer.jsx +15 -1
  41. package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.jsx +223 -1
  42. package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.jsx +75 -1
  43. package/dist/Atomic/UI/MonoAccordion/MonoAccordion.jsx +86 -1
  44. package/dist/Atomic/UI/PieChart/PieChart.jsx +41 -1
  45. package/dist/Atomic/UI/Table/Partials/TdCell.jsx +87 -1
  46. package/dist/Atomic/UI/Table/Partials/TdHeader.jsx +36 -1
  47. package/dist/Atomic/UI/Table/Partials/TdRow.jsx +103 -1
  48. package/dist/Atomic/UI/Table/Partials/TdTitle.jsx +55 -1
  49. package/dist/Atomic/UI/Table/Table.jsx +63 -1
  50. package/dist/Atomic/UI/Table/TdTypes/TdActions.jsx +80 -1
  51. package/dist/Atomic/UI/Table/TdTypes/TdPriority.jsx +26 -1
  52. package/dist/Atomic/UI/Table/TdTypes/TdRange.jsx +13 -1
  53. package/dist/Atomic/UI/Table/TdTypes/TdWeight.jsx +56 -1
  54. package/dist/Atomic/UI/TagList/TagList.jsx +256 -1
  55. package/dist/Atomic/UI/WizardStepper/constructor.jsx +86 -1
  56. package/dist/Classes/RESTAPI/partials/CredentialsProcessing.jsx +254 -1
  57. package/dist/Functions/customEventListener.jsx +96 -1
  58. package/dist/Functions/operations.jsx +138 -1
  59. package/dist/Functions/useFormTools/functions/RenderFields.jsx +108 -1
  60. package/dist/Functions/useFormTools/index.jsx +777 -1
  61. package/dist/Functions/usePasswordChecker.jsx +128 -1
  62. package/dist/Functions/utils.jsx +492 -1
  63. package/dist/Molecular/CustomIcons/components/AffiliateNetworks.jsx +22 -1
  64. package/dist/Molecular/CustomIcons/components/AlertCircle.jsx +24 -1
  65. package/dist/Molecular/CustomIcons/components/AppStore.jsx +30 -1
  66. package/dist/Molecular/CustomIcons/components/Arrow.jsx +33 -1
  67. package/dist/Molecular/CustomIcons/components/ArrowDown.jsx +18 -1
  68. package/dist/Molecular/CustomIcons/components/ArrowLeft.jsx +23 -1
  69. package/dist/Molecular/CustomIcons/components/ArrowRight.jsx +23 -1
  70. package/dist/Molecular/CustomIcons/components/ArrowUp.jsx +18 -1
  71. package/dist/Molecular/CustomIcons/components/Bell.jsx +16 -1
  72. package/dist/Molecular/CustomIcons/components/Button.jsx +13 -1
  73. package/dist/Molecular/CustomIcons/components/Campaigns.jsx +17 -1
  74. package/dist/Molecular/CustomIcons/components/Check.jsx +15 -1
  75. package/dist/Molecular/CustomIcons/components/Check2.jsx +13 -1
  76. package/dist/Molecular/CustomIcons/components/ChevronDown.jsx +13 -1
  77. package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.jsx +12 -1
  78. package/dist/Molecular/CustomIcons/components/ChevronLeft.jsx +12 -1
  79. package/dist/Molecular/CustomIcons/components/ChevronRight.jsx +12 -1
  80. package/dist/Molecular/CustomIcons/components/ChevronUp.jsx +12 -1
  81. package/dist/Molecular/CustomIcons/components/ChevronUpDown.jsx +28 -1
  82. package/dist/Molecular/CustomIcons/components/Close.jsx +15 -1
  83. package/dist/Molecular/CustomIcons/components/ColumnsOrder.jsx +18 -1
  84. package/dist/Molecular/CustomIcons/components/Delete.jsx +17 -1
  85. package/dist/Molecular/CustomIcons/components/Edit.jsx +16 -1
  86. package/dist/Molecular/CustomIcons/components/Email.jsx +32 -1
  87. package/dist/Molecular/CustomIcons/components/FinturfLogo.jsx +19 -1
  88. package/dist/Molecular/CustomIcons/components/FinturfLogo2.jsx +36 -1
  89. package/dist/Molecular/CustomIcons/components/Flows.jsx +16 -1
  90. package/dist/Molecular/CustomIcons/components/Gift.jsx +26 -1
  91. package/dist/Molecular/CustomIcons/components/GoogleAuth.jsx +30 -1
  92. package/dist/Molecular/CustomIcons/components/GooglePlay.jsx +30 -1
  93. package/dist/Molecular/CustomIcons/components/HelpCircle.jsx +20 -1
  94. package/dist/Molecular/CustomIcons/components/HelpCircle2.jsx +21 -1
  95. package/dist/Molecular/CustomIcons/components/HelpCircleFilled.jsx +20 -1
  96. package/dist/Molecular/CustomIcons/components/Home.jsx +17 -1
  97. package/dist/Molecular/CustomIcons/components/Home2.jsx +23 -1
  98. package/dist/Molecular/CustomIcons/components/Key.jsx +24 -1
  99. package/dist/Molecular/CustomIcons/components/Landers.jsx +21 -1
  100. package/dist/Molecular/CustomIcons/components/Lock.jsx +16 -1
  101. package/dist/Molecular/CustomIcons/components/Mail.jsx +27 -1
  102. package/dist/Molecular/CustomIcons/components/Mastercard.jsx +74 -1
  103. package/dist/Molecular/CustomIcons/components/Minus.jsx +26 -1
  104. package/dist/Molecular/CustomIcons/components/Offers.jsx +17 -1
  105. package/dist/Molecular/CustomIcons/components/Pause.jsx +29 -1
  106. package/dist/Molecular/CustomIcons/components/PayPal.jsx +42 -1
  107. package/dist/Molecular/CustomIcons/components/PayPalLightLarge.jsx +29 -1
  108. package/dist/Molecular/CustomIcons/components/Phone.jsx +31 -1
  109. package/dist/Molecular/CustomIcons/components/Play.jsx +26 -1
  110. package/dist/Molecular/CustomIcons/components/Plus.jsx +26 -1
  111. package/dist/Molecular/CustomIcons/components/Profile.jsx +17 -1
  112. package/dist/Molecular/CustomIcons/components/QRCode.jsx +30 -1
  113. package/dist/Molecular/CustomIcons/components/Rectangle.jsx +13 -1
  114. package/dist/Molecular/CustomIcons/components/Revert.jsx +14 -1
  115. package/dist/Molecular/CustomIcons/components/Star.jsx +15 -1
  116. package/dist/Molecular/CustomIcons/components/Star2.jsx +17 -1
  117. package/dist/Molecular/CustomIcons/components/TrafficSources.jsx +15 -1
  118. package/dist/Molecular/CustomIcons/components/Trash.jsx +16 -1
  119. package/dist/Molecular/CustomIcons/components/TrashRed.jsx +16 -1
  120. package/dist/Molecular/CustomIcons/components/Triggers.jsx +16 -1
  121. package/dist/Molecular/CustomIcons/components/User.jsx +26 -1
  122. package/dist/Molecular/CustomIcons/components/Visa.jsx +32 -1
  123. package/dist/Molecular/CustomIcons/components/X.jsx +13 -1
  124. package/dist/Molecular/FormElement/FormElement.jsx +52 -1
  125. package/dist/Molecular/FormWithDependOn/FormWithDependOn.jsx +161 -1
  126. package/dist/Molecular/InputAddress/InputAddress.jsx +641 -1
  127. package/dist/Molecular/InputPassword/InputPassword.jsx +50 -1
  128. package/package.json +1 -1
@@ -1 +1,183 @@
1
- function e(e,a){(null==a||a>e.length)&&(a=e.length);for(var r=0,t=Array(a);r<a;r++)t[r]=e[r];return t}function a(a){return function(a){if(Array.isArray(a))return e(a)}(a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||r(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(a,r){if(a){if("string"==typeof a)return e(a,r);var t=Object.prototype.toString.call(a).slice(8,-1);if("Object"===t&&a.constructor&&(t=a.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e(a,r)}}import{jsx as t,jsxs as n}from"react/jsx-runtime";import o from"classnames";import d from"moment-timezone";import{useEffect as i,useMemo as l,useState as c}from"react";import s from"../../UI/Arrow/Arrow";import"./RangeCalendar.scss";export default function(e){var u,m=e.className,f=e.date,y=e.setDate,h=e.startDate,v=e.endDate,_=e.allowPrev,g=e.allowNext,p=e.onClick,b=void 0===p?function(){}:p,A=e.onHover,k=void 0===A?function(){}:A,w=e.startPrevDate,S=e.endPrevDate,D=e.limitRange,N=e.isShortWeekNames,O=e.minDate,j=e.maxDate,x=e.momentMinDate,M=e.momentMaxDate,I=e.isDontLimitFuture,C=e.testId,B=(u=c({}),function(e){if(Array.isArray(e))return e}(u)||function(e,a){var r,t,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],d=!0,i=!1;try{for(n=n.call(e);!(d=(r=n.next()).done)&&(o.push(r.value),o.length!==a);d=!0);}catch(e){i=!0,t=e}finally{try{d||null==n.return||n.return()}finally{if(i)throw t}}return o}}(u,2)||r(u,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),P=B[0],Y=B[1],E=l(function(){return"".concat(d(f).format("MMM")," ").concat(d(f).format("YYYY"))},[f]);i(function(){for(var e={},a=d(f).startOf("month"),r=a.daysInMonth(),t=0;t<r;t+=1){var n=a.week();11===a.month()&&1===n&&(n=53),0===a.month()&&53===n&&(n=0),Object.prototype.hasOwnProperty.call(e,n)||(e[n]={}),e[n][a.weekday()]={date:a.toDate()},a.add(1,"d")}Y(e)},[f]);var L=function(e,a){var r=P[e][a],n=r&&d(r.date).isAfter(d(),"day"),i=D?r&&d(r.date).isBefore(d().subtract(D,"days"),"day"):null,l=r&&d(r.date).isSame(h,"day"),c=r&&d(r.date).isSame(d(v).subtract(1,"hour"),"day"),s=r&&h&&v&&d(r.date).isAfter(h,"day")&&d(r.date).isBefore(d(v).subtract(1,"hour"),"day"),u=r&&(d(r.date).isSame(w,"day")||d(r.date).isSame(d(S).subtract(1,"day"),"day")),m=r&&w&&S&&d(r.date).isAfter(w,"day")&&d(r.date).isBefore(d(S).subtract(1,"day"),"day");return t("div",{className:o("range-calendar__day",{"range-calendar__day--clickable":r},{"range-calendar__day--disabled":i||O&&d(null==r?void 0:r.date).isBefore(x,"day")||!I&&(j?d(null==r?void 0:r.date).isAfter(M):n)},{"range-calendar__day--range-start":l},{"range-calendar__day--range-end":c},{"range-calendar__day--range-inside":s},{"range-calendar__day--prev-range-end":u},{"range-calendar__day--prev-range-inside":m}),onClick:r?function(e){return b(r.date,e)}:null,onMouseOver:r?function(){return k(r.date)}:null,onMouseLeave:function(){return k(null)},children:t("span",{className:"calendar__day-num",children:r&&r.date.getDate()})},"".concat(e,"_").concat(a))};return n("div",{className:o("range-calendar",m),"data-testid":void 0===C?"range-calendar":C,children:[n("div",{className:"range-calendar-header",children:[t(s,{type:"left",disabled:!(void 0===_||_)||O&&d(f).startOf("month").isSameOrBefore(x,"months"),onClick:function(){y(d(f).subtract(1,"month").toDate())},className:"range-calendar-header__prev"}),t("div",{className:"range-calendar-header__title",children:E}),t(s,{type:"right",disabled:!(void 0===g||g)||!I&&d(f).startOf("month").isSameOrAfter(j?M:d().add(1,"day").startOf("day"),"months"),onClick:function(){y(d(f).add(1,"month").toDate())},className:"range-calendar-header__next"})]}),t("div",{className:"range-calendar__week range-calendar__week-title",children:a(Array.from({length:7}).keys()).map(function(e){var a;return t("div",{className:"range-calendar__day range-calendar__day--title",children:(a=d().weekday(e).format("dd"),N?a.charAt(0):a)},"day-of-week_".concat(e))})}),Object.keys(P).map(function(e,r){return t("div",{className:"range-calendar__week",children:a(Array.from({length:7}).keys()).map(function(a){return L(e,a)})},"week_".concat(r))})]})}
1
+ import cn from 'classnames';
2
+
3
+ import moment from 'moment-timezone';
4
+ import { useEffect, useMemo, useState } from 'react';
5
+
6
+ import Arrow from '../../UI/Arrow/Arrow';
7
+
8
+ import './RangeCalendar.scss';
9
+
10
+ function RangeCalendar(props) {
11
+ const {
12
+ className,
13
+ date,
14
+ setDate,
15
+ startDate,
16
+ endDate,
17
+ allowPrev = true,
18
+ allowNext = true,
19
+ onClick = () => {},
20
+ onHover = () => {},
21
+ startPrevDate,
22
+ endPrevDate,
23
+ limitRange,
24
+ isShortWeekNames,
25
+ minDate,
26
+ maxDate,
27
+ momentMinDate,
28
+ momentMaxDate,
29
+ isDontLimitFuture,
30
+ testId = 'range-calendar',
31
+ } = props;
32
+
33
+ const [days, setDays] = useState({});
34
+
35
+ const title = useMemo(
36
+ () => `${moment(date).format('MMM')} ${moment(date).format('YYYY')}`,
37
+ [date],
38
+ );
39
+
40
+ useEffect(() => {
41
+ const result = {};
42
+ const day = moment(date).startOf('month');
43
+ const daysInMonth = day.daysInMonth();
44
+ for (let d = 0; d < daysInMonth; d += 1) {
45
+ let week = day.week();
46
+ if (day.month() === 11 && week === 1) week = 53;
47
+ if (day.month() === 0 && week === 53) week = 0;
48
+ if (!Object.prototype.hasOwnProperty.call(result, week)) {
49
+ result[week] = {};
50
+ }
51
+ result[week][day.weekday()] = { date: day.toDate() };
52
+ day.add(1, 'd');
53
+ }
54
+ setDays(result);
55
+ }, [date]);
56
+
57
+ const renderDay = (week, dayOfWeek) => {
58
+ const day = days[week][dayOfWeek];
59
+ const isFutureDay = day && moment(day.date).isAfter(moment(), 'day');
60
+ const isPastDay = limitRange
61
+ ? day
62
+ && moment(day.date).isBefore(moment().subtract(limitRange, 'days'), 'day')
63
+ : null;
64
+ const isRangeStart = day && moment(day.date).isSame(startDate, 'day');
65
+ const isRangeEnd
66
+ = day
67
+ && moment(day.date).isSame(moment(endDate).subtract(1, 'hour'), 'day');
68
+ const isRangeInside
69
+ = day
70
+ && startDate
71
+ && endDate
72
+ && moment(day.date).isAfter(startDate, 'day')
73
+ && moment(day.date).isBefore(moment(endDate).subtract(1, 'hour'), 'day');
74
+ const isPrevRangeEnd
75
+ = day
76
+ && (moment(day.date).isSame(startPrevDate, 'day')
77
+ || moment(day.date).isSame(moment(endPrevDate).subtract(1, 'day'), 'day'));
78
+ const isPrevRangeInside
79
+ = day
80
+ && startPrevDate
81
+ && endPrevDate
82
+ && moment(day.date).isAfter(startPrevDate, 'day')
83
+ && moment(day.date).isBefore(moment(endPrevDate).subtract(1, 'day'), 'day');
84
+ const classNames = cn(
85
+ 'range-calendar__day',
86
+ { 'range-calendar__day--clickable': day },
87
+ {
88
+ 'range-calendar__day--disabled':
89
+ isPastDay
90
+ || (minDate && moment(day?.date).isBefore(momentMinDate, 'day'))
91
+ || (!isDontLimitFuture
92
+ && (maxDate ? moment(day?.date).isAfter(momentMaxDate) : isFutureDay)),
93
+ },
94
+ { 'range-calendar__day--range-start': isRangeStart },
95
+ { 'range-calendar__day--range-end': isRangeEnd },
96
+ { 'range-calendar__day--range-inside': isRangeInside },
97
+ { 'range-calendar__day--prev-range-end': isPrevRangeEnd },
98
+ { 'range-calendar__day--prev-range-inside': isPrevRangeInside },
99
+ );
100
+
101
+ return (
102
+ <div
103
+ key={`${week}_${dayOfWeek}`}
104
+ className={classNames}
105
+ onClick={day ? e => onClick(day.date, e) : null}
106
+ onMouseOver={day ? () => onHover(day.date) : null}
107
+ onMouseLeave={() => onHover(null)}
108
+ >
109
+ <span className="calendar__day-num">{day && day.date.getDate()}</span>
110
+ </div>
111
+ );
112
+ };
113
+
114
+ const handlePrev = () => {
115
+ setDate(moment(date).subtract(1, 'month').toDate());
116
+ };
117
+
118
+ const handleNext = () => {
119
+ setDate(moment(date).add(1, 'month').toDate());
120
+ };
121
+
122
+ const getFormatedWeekName = input =>
123
+ isShortWeekNames ? input.charAt(0) : input;
124
+
125
+ return (
126
+ <div className={cn('range-calendar', className)} data-testid={testId}>
127
+ <div className="range-calendar-header">
128
+ <Arrow
129
+ type="left"
130
+ disabled={
131
+ !allowPrev
132
+ || (minDate
133
+ && moment(date)
134
+ .startOf('month')
135
+ .isSameOrBefore(momentMinDate, 'months'))
136
+ }
137
+ onClick={handlePrev}
138
+ className="range-calendar-header__prev"
139
+ />
140
+
141
+ <div className="range-calendar-header__title">{title}</div>
142
+
143
+ <Arrow
144
+ type="right"
145
+ disabled={
146
+ !allowNext
147
+ || (!isDontLimitFuture
148
+ && moment(date)
149
+ .startOf('month')
150
+ .isSameOrAfter(
151
+ maxDate
152
+ ? momentMaxDate
153
+ : moment().add(1, 'day').startOf('day'),
154
+ 'months',
155
+ ))
156
+ }
157
+ onClick={handleNext}
158
+ className="range-calendar-header__next"
159
+ />
160
+ </div>
161
+
162
+ <div className="range-calendar__week range-calendar__week-title">
163
+ {[...Array.from({ length: 7 }).keys()].map((dayOfWeek) => {
164
+ return (
165
+ <div
166
+ key={`day-of-week_${dayOfWeek}`}
167
+ className="range-calendar__day range-calendar__day--title"
168
+ >
169
+ {getFormatedWeekName(moment().weekday(dayOfWeek).format('dd'))}
170
+ </div>
171
+ );
172
+ })}
173
+ </div>
174
+ {Object.keys(days).map((week, index) => (
175
+ <div key={`week_${index}`} className="range-calendar__week">
176
+ {[...Array.from({ length: 7 }).keys()].map(dayOfWeek => renderDay(week, dayOfWeek))}
177
+ </div>
178
+ ))}
179
+ </div>
180
+ );
181
+ }
182
+
183
+ export default RangeCalendar;
@@ -1 +1,181 @@
1
- function r(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++)e[n]=r[n];return e}function t(r,t,n){return t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function n(r){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},o=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(e).filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),o.forEach(function(n){t(r,n,e[n])})}return r}function e(r,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):(function(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n.push.apply(n,e)}return n})(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))}),r}function o(t,n){return function(r){if(Array.isArray(r))return r}(t)||function(r,t){var n,e,o=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=o){var l=[],c=!0,a=!1;try{for(o=o.call(r);!(c=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);c=!0);}catch(r){a=!0,e=r}finally{try{c||null==o.return||o.return()}finally{if(a)throw e}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return r(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return r(t,n)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}import{jsx as l,jsxs as c}from"react/jsx-runtime";import a from"classnames";import{useRef as u,useState as i}from"react";import{addRangeDefault as f}from"../../../Functions/operations";import s from"../../UI/Button/Button";import m from"../Input/Input";import d,{RangeListCell as p}from"./partial/RangeListRow";import"./RangeList.scss";var b="range-list",y={from:"",to:""};export default function(r){var v=r.className,h=r.value,_=void 0===h?[]:h,O=r.disabled,g=r.validateErrors,N=r.onChange,j=r.isFloatValues,w=r.decimalPlaces,P=r.error,x=r.defaultErrorText,S=r.nullValueText,A=r.isOnlyOneRow,I=void 0!==A&&A,C=r.testId,E=void 0===C?"range-list":C,k=o(i(y),2),B=k[0],D=k[1],R=o(i(""),2),T=R[0],U=R[1],F=o(i(""),2),K=F[0],L=F[1],V=u(null),M=u(null),$=!!((null==B?void 0:B.from)&&(null==B?void 0:B.to)&&Number(null==B?void 0:B.from)<=Number(null==B?void 0:B.to)),q=I&&(null==_?void 0:_.length)===0||!I,z=function(r,o){return D(e(n({},B),t({},o,r)))},G=function(r,t){return(null==B?void 0:B.from)||(null==B?void 0:B.to)?(B["from"===t?"to":"from"]?($?U(""):U(x),g&&L(g(Number(B.from),Number(B.to)))):("from"===t?M.current:V.current).focus(),null):(U(""),L(""),r)},H=function(r){13===r&&($?V.current.blur():B.to?B.from&&V.current.select():M.current.focus())},J=function(r){13===r&&M.current.blur()};return c("div",{"data-testid":E,className:a(b,v,t({},"".concat(b,"_disabled"),O)),children:[c("div",{className:a("".concat(b,"__row"),"".concat(b,"__labels")),children:[l(p,{className:"".concat(b,"__cell-label"),children:"From"}),l(p,{className:"".concat(b,"__cell-label"),children:"To"})]}),q&&c("div",{className:a("".concat(b,"__row"),"".concat(b,"__inputs")),children:[l(p,{className:"".concat(b,"__cell-input"),children:l(m,{ref:V,onlyNumbers:j?{type:"float",decimalPlaces:w||0}:{type:"int"},value:B.from,onBlur:function(r){return G(r,"from")},onChange:function(r){return z(r,"from")},onKeyUp:function(r){return H(r)}})}),l(p,{className:"".concat(b,"__cell-input"),children:l(m,{ref:M,onlyNumbers:j?{type:"float",decimalPlaces:w||0}:{type:"int"},value:B.to,onBlur:function(r){return G(r,"to")},onChange:function(r){return z(r,"to")},onKeyUp:function(r){return J(r)}})}),l(p,{className:"".concat(b,"__cell-button"),children:l(s,{onClick:function(){var r;$&&(r=!(null==g?void 0:g(Number(B.from),Number(B.to))),r)?(N(f(Number(B.from),Number(B.to),_,j?w:null)),D(y),U(""),L("")):$?g&&L(g(Number(B.from),Number(B.to))):U(x)},children:"Add"})})]}),(T||K||P)&&l("span",{className:"".concat(b,"__error"),children:T||P||K}),!(null==_?void 0:_.length)&&l("div",{className:a("".concat(b,"__row"),"".concat(b,"__values"),"".concat(b,"__null-value")),children:null!=S?S:"No data"}),_.map(function(r,t){return l(d,e(n({"data-testid":"".concat(E,"-row-").concat(t)},r),{idx:t,actionClick:function(){var r;return r=t,N(_.filter(function(t,n){return n!==r}))}}),"idx-".concat(t,"-from-").concat(r.from,"-to").concat(r.to))})]})}
1
+ import cn from 'classnames';
2
+
3
+ import { useRef, useState } from 'react';
4
+
5
+ // import { numberFilter, numberFilterWithoutDots, rounded } from '../../../Functions/utils';
6
+ import { addRangeDefault } from '../../../Functions/operations';
7
+ import Button from '../../UI/Button/Button';
8
+ import Input from '../Input/Input';
9
+
10
+ import RangeListRow, { RangeListCell } from './partial/RangeListRow';
11
+
12
+ import './RangeList.scss';
13
+
14
+ const RC = 'range-list';
15
+ const DEFAULT_STATE = { from: '', to: '' };
16
+
17
+ function RangeList(props) {
18
+ const {
19
+ className,
20
+ value = [],
21
+ disabled,
22
+ validateErrors,
23
+ onChange,
24
+ isFloatValues,
25
+ decimalPlaces,
26
+ error,
27
+ defaultErrorText,
28
+ nullValueText,
29
+ isOnlyOneRow = false,
30
+ testId = 'range-list',
31
+ } = props;
32
+
33
+ const NULL_VALUE_TEXT = nullValueText ?? 'No data';
34
+
35
+ const [state, setState] = useState(DEFAULT_STATE);
36
+ const [innerError, setInnerError] = useState('');
37
+ const [outerError, setOuterError] = useState('');
38
+
39
+ const inputFromRef = useRef(null);
40
+ const inputToRef = useRef(null);
41
+
42
+ const isValidRange = Boolean(
43
+ state?.from && state?.to && Number(state?.from) <= Number(state?.to),
44
+ );
45
+ const isShowRow = (isOnlyOneRow && value?.length === 0) || !isOnlyOneRow;
46
+
47
+ const handle = {
48
+ inputsChange: (val, prop) => setState({ ...state, [prop]: val }),
49
+ addRange: () => {
50
+ if (
51
+ isValidRange
52
+ && (!validateErrors?.(Number(state.from), Number(state.to)) ?? true)
53
+ ) {
54
+ onChange(
55
+ addRangeDefault(
56
+ Number(state.from),
57
+ Number(state.to),
58
+ value,
59
+ isFloatValues ? decimalPlaces : null,
60
+ ),
61
+ );
62
+ setState(DEFAULT_STATE);
63
+ setInnerError('');
64
+ setOuterError('');
65
+ }
66
+ else if (!isValidRange) {
67
+ setInnerError(defaultErrorText);
68
+ }
69
+ else if (validateErrors) {
70
+ setOuterError(validateErrors(Number(state.from), Number(state.to)));
71
+ }
72
+ },
73
+ removeRange: index =>
74
+ onChange(value.filter((item, idx) => idx !== index)),
75
+ rangeValidation: (e, key) => {
76
+ const oppositeKey = key === 'from' ? 'to' : 'from';
77
+
78
+ if (!state?.from && !state?.to) {
79
+ setInnerError('');
80
+ setOuterError('');
81
+ return e;
82
+ }
83
+ if (!state[oppositeKey]) {
84
+ const mustToFocus
85
+ = key === 'from' ? inputToRef.current : inputFromRef.current;
86
+ mustToFocus.focus();
87
+ }
88
+ else if (!isValidRange) {
89
+ setInnerError(defaultErrorText);
90
+ if (validateErrors)
91
+ setOuterError(validateErrors(Number(state.from), Number(state.to)));
92
+ }
93
+ else {
94
+ setInnerError('');
95
+ if (validateErrors)
96
+ setOuterError(validateErrors(Number(state.from), Number(state.to)));
97
+ }
98
+ return null;
99
+ },
100
+ onKeyUpFromInput: (code) => {
101
+ if (code === 13) {
102
+ if (isValidRange) inputFromRef.current.blur();
103
+ else if (!state.to) inputToRef.current.focus();
104
+ else if (state.from) inputFromRef.current.select();
105
+ }
106
+ },
107
+ onKeyUpToInput: (code) => {
108
+ if (code === 13) inputToRef.current.blur();
109
+ },
110
+ };
111
+
112
+ const renderInputsAndAddButtonRow = () => (
113
+ <div className={cn(`${RC}__row`, `${RC}__inputs`)}>
114
+ <RangeListCell className={`${RC}__cell-input`}>
115
+ <Input
116
+ ref={inputFromRef}
117
+ onlyNumbers={
118
+ isFloatValues
119
+ ? { type: 'float', decimalPlaces: decimalPlaces || 0 }
120
+ : { type: 'int' }
121
+ }
122
+ value={state.from}
123
+ onBlur={e => handle.rangeValidation(e, 'from')}
124
+ onChange={val => handle.inputsChange(val, 'from')}
125
+ onKeyUp={code => handle.onKeyUpFromInput(code)}
126
+ />
127
+ </RangeListCell>
128
+ <RangeListCell className={`${RC}__cell-input`}>
129
+ <Input
130
+ ref={inputToRef}
131
+ onlyNumbers={
132
+ isFloatValues
133
+ ? { type: 'float', decimalPlaces: decimalPlaces || 0 }
134
+ : { type: 'int' }
135
+ }
136
+ value={state.to}
137
+ onBlur={e => handle.rangeValidation(e, 'to')}
138
+ onChange={val => handle.inputsChange(val, 'to')}
139
+ onKeyUp={code => handle.onKeyUpToInput(code)}
140
+ />
141
+ </RangeListCell>
142
+ <RangeListCell className={`${RC}__cell-button`}>
143
+ <Button onClick={handle.addRange}>Add</Button>
144
+ </RangeListCell>
145
+ </div>
146
+ );
147
+
148
+ return (
149
+ <div
150
+ data-testid={testId}
151
+ className={cn(RC, className, { [`${RC}_disabled`]: disabled })}
152
+ >
153
+ <div className={cn(`${RC}__row`, `${RC}__labels`)}>
154
+ <RangeListCell className={`${RC}__cell-label`}>From</RangeListCell>
155
+ <RangeListCell className={`${RC}__cell-label`}>To</RangeListCell>
156
+ </div>
157
+ {isShowRow && renderInputsAndAddButtonRow()}
158
+ {(innerError || outerError || error) && (
159
+ <span className={`${RC}__error`}>
160
+ {innerError || error || outerError}
161
+ </span>
162
+ )}
163
+ {!value?.length && (
164
+ <div className={cn(`${RC}__row`, `${RC}__values`, `${RC}__null-value`)}>
165
+ {NULL_VALUE_TEXT}
166
+ </div>
167
+ )}
168
+ {value.map((row, idx) => (
169
+ <RangeListRow
170
+ data-testid={`${testId}-row-${idx}`}
171
+ key={`idx-${idx}-from-${row.from}-to${row.to}`}
172
+ {...row}
173
+ idx={idx}
174
+ actionClick={() => handle.removeRange(idx)}
175
+ />
176
+ ))}
177
+ </div>
178
+ );
179
+ }
180
+
181
+ export default RangeList;
@@ -1 +1,41 @@
1
- function e(e,c,a){return c in e?Object.defineProperty(e,c,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[c]=a,e}import{jsx as c,jsxs as a}from"react/jsx-runtime";import l from"classnames";import{Trash2 as n}from"react-feather";var t="range-list";export function RangeListCell(a){var n=a.children,r=a.idx,i=a.className,o=a.onClick;return c("div",{className:l("".concat(t,"__cell"),i,e({},"".concat(t,"__cell-").concat(r),r)),onClick:o,children:n})}export default function(r){var i=r.from,o=r.to,s=r.idx,u=r.actionClick;return a("div",{className:l("".concat(t,"__row"),"".concat(t,"__values"),e({},"".concat(t,"__values_first-value"),0===s)),children:[c(RangeListCell,{idx:1,className:"".concat(t,"__cell-value"),children:i}),c(RangeListCell,{idx:2,className:"".concat(t,"__cell-value"),children:o}),c(RangeListCell,{idx:3,className:"".concat(t,"__cell-action"),onClick:function(){return u(s)},children:c(n,{})})]})}
1
+ import cn from 'classnames';
2
+ import { Trash2 } from 'react-feather';
3
+
4
+ const RC = 'range-list';
5
+
6
+ export function RangeListCell({ children, idx, className, onClick }) {
7
+ return (
8
+ <div
9
+ className={cn(`${RC}__cell`, className, { [`${RC}__cell-${idx}`]: idx })}
10
+ onClick={onClick}
11
+ >
12
+ {children}
13
+ </div>
14
+ );
15
+ }
16
+
17
+ function RangeListRow({ from, to, idx, actionClick }) {
18
+ return (
19
+ <div
20
+ className={cn(`${RC}__row`, `${RC}__values`, {
21
+ [`${RC}__values_first-value`]: idx === 0,
22
+ })}
23
+ >
24
+ <RangeListCell idx={1} className={`${RC}__cell-value`}>
25
+ {from}
26
+ </RangeListCell>
27
+ <RangeListCell idx={2} className={`${RC}__cell-value`}>
28
+ {to}
29
+ </RangeListCell>
30
+ <RangeListCell
31
+ idx={3}
32
+ className={`${RC}__cell-action`}
33
+ onClick={() => actionClick(idx)}
34
+ >
35
+ <Trash2 />
36
+ </RangeListCell>
37
+ </div>
38
+ );
39
+ }
40
+
41
+ export default RangeListRow;