@rolster/react-components 18.12.9 → 18.13.0
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.
- package/dist/cjs/assets/{index-7UzJ6VgT.css → index-fykwrWLx.css} +747 -648
- package/dist/cjs/index.js +760 -776
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-7UzJ6VgT.css → index-fykwrWLx.css} +747 -648
- package/dist/es/index.js +760 -778
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Amount/Amount.css +3 -3
- package/dist/esm/components/atoms/Avatar/Avatar.css +7 -7
- package/dist/esm/components/atoms/Badge/Badge.css +7 -7
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.css +12 -12
- package/dist/esm/components/atoms/Button/Button.css +74 -53
- package/dist/esm/components/atoms/Button/Button.d.ts +1 -1
- package/dist/esm/components/atoms/Button/Button.js +1 -1
- package/dist/esm/components/atoms/Button/Button.js.map +1 -1
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.css +22 -22
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.d.ts +1 -1
- package/dist/esm/components/atoms/CheckBox/CheckBox.css +8 -8
- package/dist/esm/components/atoms/Icon/Icon.css +7 -8
- package/dist/esm/components/atoms/Input/Input.css +13 -15
- package/dist/esm/components/atoms/InputMoney/InputMoney.css +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.css +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.css +8 -8
- package/dist/esm/components/atoms/InputText/InputText.css +1 -1
- package/dist/esm/components/atoms/Label/Label.css +1 -1
- package/dist/esm/components/atoms/MessageIcon/MessageIcon.css +6 -6
- package/dist/esm/components/atoms/Poster/Poster.css +6 -6
- package/dist/esm/components/atoms/ProgressBar/ProgressBar.css +7 -7
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.css +44 -0
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.d.ts +7 -0
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.js +6 -0
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.js.map +1 -0
- package/dist/esm/components/atoms/RadioButton/RadioButton.css +6 -6
- package/dist/esm/components/atoms/SearchInput/SearchInput.css +4 -4
- package/dist/esm/components/atoms/Skeleton/Skeleton.css +6 -6
- package/dist/esm/components/atoms/SkeletonText/SkeletonText.css +6 -8
- package/dist/esm/components/atoms/Switch/Switch.css +16 -16
- package/dist/esm/components/atoms/TabularText/TabularText.css +2 -2
- package/dist/esm/components/atoms/index.d.ts +1 -0
- package/dist/esm/components/atoms/index.js +1 -0
- package/dist/esm/components/atoms/index.js.map +1 -1
- package/dist/esm/components/definitions.d.ts +1 -1
- package/dist/esm/components/molecules/Ballot/Ballot.css +27 -34
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.css +7 -0
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.d.ts +12 -0
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.js +8 -0
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.js.map +1 -0
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.css +32 -30
- package/dist/esm/components/molecules/CheckBoxLabel/CheckBoxLabel.css +8 -8
- package/dist/esm/components/molecules/DayPicker/DayPicker.css +39 -27
- package/dist/esm/components/molecules/DayPicker/DayPicker.d.ts +3 -1
- package/dist/esm/components/molecules/DayPicker/DayPicker.js +32 -24
- package/dist/esm/components/molecules/DayPicker/DayPicker.js.map +1 -1
- package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.css +28 -28
- package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.js +18 -21
- package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.js.map +1 -1
- package/dist/esm/components/molecules/MoneyField/MoneyField.css +1 -2
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.css +34 -19
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.d.ts +2 -1
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.js +30 -19
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.js.map +1 -1
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.css +6 -6
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.d.ts +1 -1
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.js +26 -21
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.js.map +1 -1
- package/dist/esm/components/molecules/NumberField/NumberField.css +1 -2
- package/dist/esm/components/molecules/Pagination/Pagination.css +29 -30
- package/dist/esm/components/molecules/PasswordField/PasswordField.css +4 -5
- package/dist/esm/components/molecules/RadioButtonLabel/RadioButtonLabel.css +8 -10
- package/dist/esm/components/molecules/SwitchLabel/SwitchLabel.css +8 -9
- package/dist/esm/components/molecules/TextField/TextField.css +1 -2
- package/dist/esm/components/molecules/Toolbar/Toolbar.css +10 -10
- package/dist/esm/components/molecules/YearPicker/YearPicker.css +42 -28
- package/dist/esm/components/molecules/YearPicker/YearPicker.d.ts +1 -1
- package/dist/esm/components/molecules/YearPicker/YearPicker.js +33 -26
- package/dist/esm/components/molecules/YearPicker/YearPicker.js.map +1 -1
- package/dist/esm/components/molecules/index.d.ts +1 -0
- package/dist/esm/components/molecules/index.js +1 -0
- package/dist/esm/components/molecules/index.js.map +1 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.css +22 -22
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.d.ts +1 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js +1 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js.map +1 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteFieldHook.d.ts +1 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteFieldHook.js +27 -81
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteFieldHook.js.map +1 -1
- package/dist/esm/components/organisms/Card/Card.css +5 -5
- package/dist/esm/components/organisms/Confirmation/Confirmation.css +38 -38
- package/dist/esm/components/organisms/DateField/DateField.css +15 -15
- package/dist/esm/components/organisms/DateField/DateField.d.ts +2 -2
- package/dist/esm/components/organisms/DateField/DateField.js +28 -16
- package/dist/esm/components/organisms/DateField/DateField.js.map +1 -1
- package/dist/esm/components/organisms/DatePicker/DatePicker.css +27 -24
- package/dist/esm/components/organisms/DatePicker/DatePicker.d.ts +2 -2
- package/dist/esm/components/organisms/DatePicker/DatePicker.js +38 -56
- package/dist/esm/components/organisms/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.css +13 -15
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.js +5 -5
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.js.map +1 -1
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.css +20 -20
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js +16 -36
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/esm/components/organisms/FormNavigation/FormNavigation.css +15 -14
- package/dist/esm/components/organisms/Modal/Modal.css +11 -11
- package/dist/esm/components/organisms/SelectField/SelectField.css +1 -1
- package/dist/esm/components/organisms/SelectField/SelectField.d.ts +1 -1
- package/dist/esm/components/organisms/SelectField/SelectField.js +1 -1
- package/dist/esm/components/organisms/SelectField/SelectField.js.map +1 -1
- package/dist/esm/components/organisms/SelectField/SelectFieldHook.d.ts +1 -1
- package/dist/esm/components/organisms/SelectField/SelectFieldHook.js +18 -35
- package/dist/esm/components/organisms/SelectField/SelectFieldHook.js.map +1 -1
- package/dist/esm/components/organisms/Snackbar/Snackbar.css +26 -26
- package/dist/esm/constants/index.d.ts +1 -0
- package/dist/esm/constants/index.js +2 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/constants/picker.constant.d.ts +1 -0
- package/dist/esm/constants/picker.constant.js +2 -0
- package/dist/esm/constants/picker.constant.js.map +1 -0
- package/dist/esm/helpers/date-range-picker.d.ts +1 -12
- package/dist/esm/helpers/date-range-picker.js +5 -105
- package/dist/esm/helpers/date-range-picker.js.map +1 -1
- package/dist/esm/helpers/index.d.ts +2 -0
- package/dist/esm/helpers/index.js +3 -0
- package/dist/esm/helpers/index.js.map +1 -0
- package/dist/esm/hooks/ListControlHook.d.ts +2 -3
- package/dist/esm/hooks/ListControlHook.js +22 -92
- package/dist/esm/hooks/ListControlHook.js.map +1 -1
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +7 -6
- package/dist/esm/helpers/date-picker.d.ts +0 -1
- package/dist/esm/helpers/date-picker.js +0 -5
- package/dist/esm/helpers/date-picker.js.map +0 -1
- package/dist/esm/helpers/day-picker.d.ts +0 -9
- package/dist/esm/helpers/day-picker.js +0 -84
- package/dist/esm/helpers/day-picker.js.map +0 -1
- package/dist/esm/helpers/month-picker.d.ts +0 -14
- package/dist/esm/helpers/month-picker.js +0 -78
- package/dist/esm/helpers/month-picker.js.map +0 -1
- package/dist/esm/helpers/year-picker.d.ts +0 -17
- package/dist/esm/helpers/year-picker.js +0 -83
- package/dist/esm/helpers/year-picker.js.map +0 -1
- package/dist/esm/models.d.ts +0 -58
- package/dist/esm/models.js +0 -9
- package/dist/esm/models.js.map +0 -1
- package/dist/esm/types.d.ts +0 -12
- package/dist/esm/types.js +0 -7
- package/dist/esm/types.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function RlsIcon({ value, skeleton }) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function RlsButton({ type, children, disabled, prefixIcon, suffixIcon, rlsTheme, onClick }) {
|
|
59
|
-
return (jsxRuntime.jsx("button", { className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxRuntime.jsxs("div", { className: renderClassStatus('rls-button__content', { type }), children: [prefixIcon && jsxRuntime.jsx(RlsIcon, { value: prefixIcon }), children &&
|
|
59
|
+
return (jsxRuntime.jsx("button", { className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxRuntime.jsxs("div", { className: renderClassStatus('rls-button__content', { type }), children: [prefixIcon && jsxRuntime.jsx(RlsIcon, { value: prefixIcon }), children && jsxRuntime.jsx("div", { className: "rls-button__label", children: children }), suffixIcon && jsxRuntime.jsx(RlsIcon, { value: suffixIcon })] }) }));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function RlsButtonAction({ icon, disabled, tooltip, onClick }) {
|
|
@@ -187,6 +187,10 @@ function RlsProgressBar({ indeterminate, percentage, rlsTheme }) {
|
|
|
187
187
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-progress-bar', { indeterminate }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
function RlsProgressCircular({ rlsTheme }) {
|
|
191
|
+
return (jsxRuntime.jsx("div", { className: "rls-progress-circular", "rls-theme": rlsTheme, children: jsxRuntime.jsx("svg", { className: "rls-progress-circular__svg", viewBox: "0 0 36 36", children: jsxRuntime.jsx("circle", { className: "rls-progress-circular__circle", cx: "18", cy: "18", r: "12" }) }) }));
|
|
192
|
+
}
|
|
193
|
+
|
|
190
194
|
function RlsRadioButton({ checked, disabled, rlsTheme, onClick }) {
|
|
191
195
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
192
196
|
}
|
|
@@ -216,6 +220,10 @@ function RlsBallot({ bordered, children, img, initials, skeleton, subtitle, rlsT
|
|
|
216
220
|
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-ballot', { bordered, skeleton }), "rls-theme": rlsTheme, children: [(img || initials) && (jsxRuntime.jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsxRuntime.jsx("img", { src: img }), initials && jsxRuntime.jsx("span", { children: initials })] })), jsxRuntime.jsxs("div", { className: "rls-ballot__component", children: [jsxRuntime.jsx("label", { className: "rls-ballot__title", children: jsxRuntime.jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsxRuntime.jsx("label", { className: "rls-ballot__subtitle", children: jsxRuntime.jsx(RlsSkeletonText, { active: skeleton, children: subtitle }) }))] })] }));
|
|
217
221
|
}
|
|
218
222
|
|
|
223
|
+
function RlsButtonProgress({ icon, disabled, onClick, progressing, rlsTheme }) {
|
|
224
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-button-progress', { progressing }), "rls-theme": rlsTheme, children: [!progressing && (jsxRuntime.jsx(RlsButtonAction, { icon: icon, onClick: onClick, disabled: disabled })), progressing && jsxRuntime.jsx(RlsProgressCircular, {})] }));
|
|
225
|
+
}
|
|
226
|
+
|
|
219
227
|
function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsTheme }) {
|
|
220
228
|
const componentRef = react.useRef(null);
|
|
221
229
|
const [firstAction] = options;
|
|
@@ -267,241 +275,541 @@ function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme
|
|
|
267
275
|
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-checkbox-label__component", onClick: onToggle, children: jsxRuntime.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-checkbox-label__text", children: children })] }));
|
|
268
276
|
}
|
|
269
277
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
278
|
+
function dateIsOutRangeMin(props) {
|
|
279
|
+
const { date, minDate } = props;
|
|
280
|
+
return !!minDate && helpersDate.dateIsBefore(helpersDate.normalizeMinTime(minDate), date);
|
|
281
|
+
}
|
|
282
|
+
function dateIsOutRangeMax(props) {
|
|
283
|
+
const { date, maxDate } = props;
|
|
284
|
+
return !!maxDate && helpersDate.dateIsAfter(helpersDate.normalizeMaxTime(maxDate), date);
|
|
285
|
+
}
|
|
286
|
+
function dateOutRange(props) {
|
|
287
|
+
return dateIsOutRangeMin(props) || dateIsOutRangeMax(props);
|
|
288
|
+
}
|
|
289
|
+
function checkDateRange(props) {
|
|
290
|
+
const { date, maxDate, minDate } = props;
|
|
291
|
+
return minDate && dateIsOutRangeMax(props)
|
|
292
|
+
? minDate
|
|
293
|
+
: maxDate && dateIsOutRangeMax(props)
|
|
294
|
+
? maxDate
|
|
295
|
+
: date;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const DAYS_WEEK = 7;
|
|
299
|
+
const COUNT_YEAR_RANGE = 4;
|
|
300
|
+
|
|
301
|
+
function createDayState(props, today, value) {
|
|
302
|
+
const { date, day, month, year } = props;
|
|
303
|
+
const dateValue = value && new Date(year, month, value);
|
|
304
|
+
return {
|
|
305
|
+
disabled: dayIsOutside(props, value || 0),
|
|
306
|
+
focused: !!value && day === value,
|
|
307
|
+
forbidden: !value,
|
|
308
|
+
selected: !!dateValue && helpersDate.dateIsEqualsWeight(date, dateValue),
|
|
309
|
+
today: !!dateValue && helpersDate.dateIsEqualsWeight(today, dateValue),
|
|
310
|
+
value
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function createFirstWeek$1(props, date, today) {
|
|
314
|
+
const days = [];
|
|
315
|
+
let day = 1;
|
|
316
|
+
for (let start = 0; start < date.getDay(); start++) {
|
|
317
|
+
days.push(createDayState(props, today));
|
|
318
|
+
}
|
|
319
|
+
for (let end = date.getDay(); end < 7; end++) {
|
|
320
|
+
days.push(createDayState(props, today, day));
|
|
321
|
+
day++;
|
|
322
|
+
}
|
|
323
|
+
return { days };
|
|
324
|
+
}
|
|
325
|
+
function createDaysPending$1(props, today, days) {
|
|
326
|
+
const daysPending = [];
|
|
327
|
+
const length = 7 - days;
|
|
328
|
+
for (let index = 0; index < length; index++) {
|
|
329
|
+
daysPending.push(createDayState(props, today));
|
|
330
|
+
}
|
|
331
|
+
return daysPending;
|
|
332
|
+
}
|
|
333
|
+
function createNextWeeks$1(props, date, today) {
|
|
334
|
+
const daysMonth = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
335
|
+
const weeks = [];
|
|
336
|
+
let days = [];
|
|
337
|
+
let countDays = 1;
|
|
338
|
+
let day = DAYS_WEEK - date.getDay() + 1;
|
|
339
|
+
do {
|
|
340
|
+
days.push(createDayState(props, today, day));
|
|
341
|
+
day++;
|
|
342
|
+
countDays++;
|
|
343
|
+
if (countDays > DAYS_WEEK) {
|
|
344
|
+
weeks.push({ days });
|
|
345
|
+
days = [];
|
|
346
|
+
countDays = 1;
|
|
347
|
+
}
|
|
348
|
+
} while (day <= daysMonth);
|
|
349
|
+
if (days.length && days.length < DAYS_WEEK) {
|
|
350
|
+
weeks.push({
|
|
351
|
+
days: [...days, ...createDaysPending$1(props, today, days.length)]
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return weeks;
|
|
355
|
+
}
|
|
356
|
+
function dayIsOutsideMin(props, day) {
|
|
357
|
+
const { month, year, minDate } = props;
|
|
358
|
+
return minDate
|
|
359
|
+
? helpersDate.getDateWeight(new Date(year, month, day)) < helpersDate.getDateWeight(minDate)
|
|
360
|
+
: false;
|
|
361
|
+
}
|
|
362
|
+
function dayIsOutsideMax(props, day) {
|
|
363
|
+
const { month, year, maxDate } = props;
|
|
364
|
+
return maxDate
|
|
365
|
+
? helpersDate.getDateWeight(new Date(year, month, day)) > helpersDate.getDateWeight(maxDate)
|
|
366
|
+
: false;
|
|
367
|
+
}
|
|
368
|
+
function dayIsOutside(props, day) {
|
|
369
|
+
return dayIsOutsideMin(props, day) || dayIsOutsideMax(props, day);
|
|
370
|
+
}
|
|
371
|
+
function checkDayPicker(props) {
|
|
372
|
+
const { day, maxDate, minDate } = props;
|
|
373
|
+
return minDate && dayIsOutsideMin(props, day)
|
|
374
|
+
? minDate.getDate()
|
|
375
|
+
: maxDate && dayIsOutsideMax(props, day)
|
|
376
|
+
? maxDate.getDate()
|
|
377
|
+
: undefined;
|
|
378
|
+
}
|
|
379
|
+
function createDayPicker(props) {
|
|
380
|
+
const date = new Date(props.year, props.month, 1);
|
|
381
|
+
const today = new Date();
|
|
382
|
+
const firstWeek = createFirstWeek$1(props, date, today);
|
|
383
|
+
const nextWeeks = createNextWeeks$1(props, date, today);
|
|
384
|
+
return [firstWeek, ...nextWeeks];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function dateIsSelected(base, date, day) {
|
|
388
|
+
return (date.getFullYear() === base.getFullYear() &&
|
|
389
|
+
date.getMonth() === base.getMonth() &&
|
|
390
|
+
day === date.getDate());
|
|
391
|
+
}
|
|
392
|
+
function sourceIsSelected({ sourceDate }, base, day) {
|
|
393
|
+
return dateIsSelected(base, sourceDate, day);
|
|
394
|
+
}
|
|
395
|
+
function rangeIsSelected({ range }, base, day) {
|
|
396
|
+
return (dateIsSelected(base, range.minDate, day) ||
|
|
397
|
+
dateIsSelected(base, range.maxDate, day));
|
|
398
|
+
}
|
|
399
|
+
function dayIsRange({ range }, base, day) {
|
|
400
|
+
return helpersDate.dateIsBetween(range.minDate, range.maxDate, helpersDate.assignDayInDate(base, day));
|
|
401
|
+
}
|
|
402
|
+
function createDayRangeState(props, base, day) {
|
|
403
|
+
return {
|
|
404
|
+
disabled: dayRangeIsOutside(props, day || 0),
|
|
405
|
+
end: day ? rangeIsSelected(props, base, day) : false,
|
|
406
|
+
forbidden: !day,
|
|
407
|
+
ranged: day ? dayIsRange(props, base, day) : false,
|
|
408
|
+
source: day ? sourceIsSelected(props, base, day) : false,
|
|
409
|
+
value: day
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function createFirstWeek(props, base) {
|
|
413
|
+
const days = [];
|
|
414
|
+
let day = 1;
|
|
415
|
+
for (let start = 0; start < base.getDay(); start++) {
|
|
416
|
+
days.push(createDayRangeState(props, base));
|
|
417
|
+
}
|
|
418
|
+
for (let end = base.getDay(); end < 7; end++) {
|
|
419
|
+
days.push(createDayRangeState(props, base, day));
|
|
420
|
+
day++;
|
|
421
|
+
}
|
|
422
|
+
return { days };
|
|
423
|
+
}
|
|
424
|
+
function createDaysPending(props, base, days) {
|
|
425
|
+
const daysPending = [];
|
|
426
|
+
const length = 7 - days;
|
|
427
|
+
for (let index = 0; index < length; index++) {
|
|
428
|
+
daysPending.push(createDayRangeState(props, base));
|
|
429
|
+
}
|
|
430
|
+
return daysPending;
|
|
431
|
+
}
|
|
432
|
+
function createNextWeeks(props, base) {
|
|
433
|
+
const weeks = [];
|
|
434
|
+
const { date } = props;
|
|
435
|
+
const dayCount = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
436
|
+
let days = [];
|
|
437
|
+
let countDays = 1;
|
|
438
|
+
let day = DAYS_WEEK - base.getDay() + 1;
|
|
439
|
+
do {
|
|
440
|
+
days.push(createDayRangeState(props, date, day));
|
|
441
|
+
day++;
|
|
442
|
+
countDays++;
|
|
443
|
+
if (countDays > 7) {
|
|
444
|
+
weeks.push({ days });
|
|
445
|
+
days = [];
|
|
446
|
+
countDays = 1;
|
|
447
|
+
}
|
|
448
|
+
} while (day <= dayCount);
|
|
449
|
+
if (days.length && days.length < DAYS_WEEK) {
|
|
450
|
+
weeks.push({
|
|
451
|
+
days: [...days, ...createDaysPending(props, base, days.length)]
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return weeks;
|
|
455
|
+
}
|
|
456
|
+
function dayRangeIsOutsideMin(props, day) {
|
|
457
|
+
const { date, minDate } = props;
|
|
458
|
+
return minDate
|
|
459
|
+
? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) < helpersDate.getDateWeight(minDate)
|
|
460
|
+
: false;
|
|
461
|
+
}
|
|
462
|
+
function dayRangeIsOutsideMax(props, day) {
|
|
463
|
+
const { date, maxDate } = props;
|
|
464
|
+
return maxDate
|
|
465
|
+
? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) > helpersDate.getDateWeight(maxDate)
|
|
466
|
+
: false;
|
|
467
|
+
}
|
|
468
|
+
function dayRangeIsOutside(props, day) {
|
|
469
|
+
return dayRangeIsOutsideMin(props, day) || dayRangeIsOutsideMax(props, day);
|
|
470
|
+
}
|
|
471
|
+
function createDayRangePicker(props) {
|
|
472
|
+
const date = new Date(props.date.getFullYear(), props.date.getMonth(), 1);
|
|
473
|
+
const firstWeek = createFirstWeek(props, date);
|
|
474
|
+
const nextWeeks = createNextWeeks(props, date);
|
|
475
|
+
return [firstWeek, ...nextWeeks];
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function createMonthState(props, value) {
|
|
479
|
+
const { date, month, year } = props;
|
|
480
|
+
return {
|
|
481
|
+
disabled: monthIsOutside(props, value),
|
|
482
|
+
focused: value === month,
|
|
483
|
+
label: helpersDate.MONTH_NAMES()[value],
|
|
484
|
+
selected: date.getFullYear() === year && value === date.getMonth(),
|
|
485
|
+
value
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
function monthIsOutsideMin(props, month) {
|
|
489
|
+
const { year, minDate } = props;
|
|
490
|
+
return minDate
|
|
491
|
+
? minDate.getFullYear() === year && month < minDate.getMonth()
|
|
492
|
+
: false;
|
|
493
|
+
}
|
|
494
|
+
function monthIsOutsideMax(props, month) {
|
|
495
|
+
const { year, maxDate } = props;
|
|
496
|
+
return maxDate
|
|
497
|
+
? maxDate.getFullYear() === year && month > maxDate.getMonth()
|
|
498
|
+
: false;
|
|
499
|
+
}
|
|
500
|
+
function monthIsOutside(props, month) {
|
|
501
|
+
return monthIsOutsideMin(props, month) || monthIsOutsideMax(props, month);
|
|
502
|
+
}
|
|
503
|
+
function checkMonthPicker(props) {
|
|
504
|
+
const { maxDate, minDate, month } = props;
|
|
505
|
+
return minDate && monthIsOutsideMin(props, month)
|
|
506
|
+
? minDate.getMonth()
|
|
507
|
+
: maxDate && monthIsOutsideMax(props, month)
|
|
508
|
+
? maxDate.getMonth()
|
|
509
|
+
: undefined;
|
|
510
|
+
}
|
|
511
|
+
function createMonthPicker(props) {
|
|
512
|
+
return [
|
|
513
|
+
createMonthState(props, helpersDate.Month.January),
|
|
514
|
+
createMonthState(props, helpersDate.Month.February),
|
|
515
|
+
createMonthState(props, helpersDate.Month.March),
|
|
516
|
+
createMonthState(props, helpersDate.Month.April),
|
|
517
|
+
createMonthState(props, helpersDate.Month.May),
|
|
518
|
+
createMonthState(props, helpersDate.Month.June),
|
|
519
|
+
createMonthState(props, helpersDate.Month.July),
|
|
520
|
+
createMonthState(props, helpersDate.Month.August),
|
|
521
|
+
createMonthState(props, helpersDate.Month.September),
|
|
522
|
+
createMonthState(props, helpersDate.Month.October),
|
|
523
|
+
createMonthState(props, helpersDate.Month.November),
|
|
524
|
+
createMonthState(props, helpersDate.Month.December)
|
|
525
|
+
];
|
|
526
|
+
}
|
|
527
|
+
function monthIsLimitMin(props) {
|
|
528
|
+
const { month, date, minDate } = props;
|
|
529
|
+
if (helpersAdvanced.itIsDefined(month) && date) {
|
|
530
|
+
const minYear = minDate ? minDate.getFullYear() : 0;
|
|
531
|
+
const minMonth = minDate ? minDate.getMonth() : 0;
|
|
532
|
+
return date.getFullYear() === minYear && month <= minMonth;
|
|
533
|
+
}
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
function monthIsLimitMax(props) {
|
|
537
|
+
const { month, date, maxDate } = props;
|
|
538
|
+
if (helpersAdvanced.itIsDefined(month) && date) {
|
|
539
|
+
const maxYear = maxDate ? maxDate.getFullYear() : 10000;
|
|
540
|
+
const maxMonth = maxDate ? maxDate.getMonth() : 11;
|
|
541
|
+
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
542
|
+
}
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
function monthLimitTemplate(props) {
|
|
546
|
+
return {
|
|
547
|
+
limitNext: monthIsLimitMax(props),
|
|
548
|
+
limitPrevious: monthIsLimitMin(props)
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
var PickerListenerType;
|
|
553
|
+
(function (PickerListenerType) {
|
|
554
|
+
PickerListenerType["Select"] = "PickerSelect";
|
|
555
|
+
PickerListenerType["Now"] = "PickerNow";
|
|
556
|
+
PickerListenerType["Cancel"] = "PickerCancel";
|
|
557
|
+
})(PickerListenerType || (PickerListenerType = {}));
|
|
558
|
+
|
|
559
|
+
function createYear(props, value) {
|
|
560
|
+
const { date, year } = props;
|
|
561
|
+
return {
|
|
562
|
+
disabled: !value,
|
|
563
|
+
focused: value === year,
|
|
564
|
+
selected: value === date.getFullYear(),
|
|
565
|
+
value
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function yearIsOutlineMin(props) {
|
|
569
|
+
const { year, minDate } = props;
|
|
570
|
+
return minDate ? year < minDate.getFullYear() : false;
|
|
571
|
+
}
|
|
572
|
+
function yearIsOutlineMax(props) {
|
|
573
|
+
const { year, maxDate } = props;
|
|
574
|
+
return maxDate ? year > maxDate.getFullYear() : false;
|
|
575
|
+
}
|
|
576
|
+
function checkYearPicker(props) {
|
|
577
|
+
const { maxDate, minDate } = props;
|
|
578
|
+
return minDate && yearIsOutlineMin(props)
|
|
579
|
+
? minDate.getFullYear()
|
|
580
|
+
: maxDate && yearIsOutlineMax(props)
|
|
581
|
+
? maxDate.getFullYear()
|
|
582
|
+
: undefined;
|
|
583
|
+
}
|
|
584
|
+
function createYearPicker(props) {
|
|
585
|
+
const { year, maxDate, minDate } = props;
|
|
586
|
+
const prevYears = [];
|
|
587
|
+
const nextYears = [];
|
|
588
|
+
let minRange = year;
|
|
589
|
+
let maxRange = year;
|
|
590
|
+
const minYear = minDate?.getFullYear() || 0;
|
|
591
|
+
const maxYear = maxDate?.getFullYear() || 10000;
|
|
592
|
+
for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
|
|
593
|
+
const prevValue = year - COUNT_YEAR_RANGE + index;
|
|
594
|
+
const nextValue = year + index + 1;
|
|
595
|
+
const prevYear = prevValue >= minYear ? prevValue : undefined;
|
|
596
|
+
const nextYear = nextValue <= maxYear ? nextValue : undefined;
|
|
597
|
+
const prevState = createYear(props, prevYear);
|
|
598
|
+
const nextState = createYear(props, nextYear);
|
|
599
|
+
prevYears.push(prevState);
|
|
600
|
+
nextYears.push(nextState);
|
|
601
|
+
if (!!prevState.value && minRange > prevState.value) {
|
|
602
|
+
minRange = prevState.value;
|
|
603
|
+
}
|
|
604
|
+
if (!!nextState.value && maxRange < nextState.value) {
|
|
605
|
+
maxRange = nextState.value;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const yearCenter = createYear(props, year);
|
|
609
|
+
return {
|
|
610
|
+
canPrevious: minYear < minRange,
|
|
611
|
+
canNext: maxYear > maxRange,
|
|
612
|
+
maxRange,
|
|
613
|
+
minRange,
|
|
614
|
+
years: [...prevYears, yearCenter, ...nextYears]
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function createEmptyStore() {
|
|
619
|
+
return {
|
|
620
|
+
coincidences: undefined,
|
|
621
|
+
pattern: '',
|
|
622
|
+
previous: null
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function searchForPattern(props) {
|
|
626
|
+
const { pattern, store } = props;
|
|
627
|
+
if (!store?.pattern) {
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
let newStore = store;
|
|
631
|
+
let search = false;
|
|
632
|
+
while (!search && newStore) {
|
|
633
|
+
search = helpersString.hasPattern(pattern || '', newStore.pattern, true);
|
|
634
|
+
if (!search) {
|
|
635
|
+
newStore = newStore.previous;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return newStore || createEmptyStore();
|
|
639
|
+
}
|
|
640
|
+
function createStoreAutocomplete(props) {
|
|
641
|
+
const { pattern, suggestions, reboot } = props;
|
|
642
|
+
if (!pattern) {
|
|
643
|
+
return { collection: suggestions, store: createEmptyStore() };
|
|
644
|
+
}
|
|
645
|
+
const store = reboot ? createEmptyStore() : searchForPattern(props);
|
|
646
|
+
const elements = store?.coincidences || suggestions;
|
|
647
|
+
const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
|
|
648
|
+
return {
|
|
649
|
+
collection: coincidences,
|
|
650
|
+
store: {
|
|
651
|
+
coincidences,
|
|
652
|
+
pattern,
|
|
653
|
+
previous: store
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const classElement = '.rls-list-field__element';
|
|
659
|
+
const POSITION_INITIAL = 0;
|
|
660
|
+
function locationListIsBottom(contentElement, listElement) {
|
|
661
|
+
if (contentElement && listElement) {
|
|
662
|
+
const { top, height } = contentElement.getBoundingClientRect();
|
|
663
|
+
const { clientHeight } = listElement;
|
|
664
|
+
return top + height + clientHeight < window.innerHeight;
|
|
665
|
+
}
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
function navigationInputDown(props) {
|
|
669
|
+
const { contentElement, listElement } = props;
|
|
670
|
+
if (!locationListIsBottom(contentElement, listElement)) {
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
674
|
+
if (elements?.length) {
|
|
675
|
+
elements.item(0).focus();
|
|
676
|
+
setTimeout(() => {
|
|
677
|
+
listElement?.scroll({ top: 0, behavior: 'smooth' });
|
|
678
|
+
}, 100);
|
|
679
|
+
}
|
|
680
|
+
return POSITION_INITIAL;
|
|
681
|
+
}
|
|
682
|
+
function navigationInputUp(props) {
|
|
683
|
+
const { contentElement, listElement } = props;
|
|
684
|
+
if (locationListIsBottom(contentElement, listElement)) {
|
|
685
|
+
return undefined;
|
|
686
|
+
}
|
|
687
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
688
|
+
if (!elements?.length) {
|
|
689
|
+
return POSITION_INITIAL;
|
|
690
|
+
}
|
|
691
|
+
const position = elements.length - 1;
|
|
692
|
+
const element = elements.item(position);
|
|
693
|
+
element?.focus();
|
|
694
|
+
setTimeout(() => {
|
|
695
|
+
listElement?.scroll({
|
|
696
|
+
top: element?.offsetTop + element?.offsetLeft,
|
|
697
|
+
behavior: 'smooth'
|
|
698
|
+
});
|
|
699
|
+
}, 100);
|
|
700
|
+
return position;
|
|
701
|
+
}
|
|
702
|
+
function navigationElementDown(props) {
|
|
703
|
+
const { contentElement, inputElement, listElement, position } = props;
|
|
704
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
705
|
+
const newPosition = position + 1;
|
|
706
|
+
if (newPosition < (elements?.length || 0)) {
|
|
707
|
+
elements?.item(newPosition)?.focus();
|
|
708
|
+
return newPosition;
|
|
709
|
+
}
|
|
710
|
+
if (!locationListIsBottom(contentElement, listElement)) {
|
|
711
|
+
inputElement?.focus();
|
|
712
|
+
}
|
|
713
|
+
return position;
|
|
714
|
+
}
|
|
715
|
+
function navigationElementUp(props) {
|
|
716
|
+
const { contentElement, inputElement, listElement, position } = props;
|
|
717
|
+
if (position > 0) {
|
|
718
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
719
|
+
const newPosition = position - 1;
|
|
720
|
+
elements?.item(newPosition)?.focus();
|
|
721
|
+
return newPosition;
|
|
722
|
+
}
|
|
723
|
+
if (locationListIsBottom(contentElement, listElement)) {
|
|
724
|
+
inputElement?.focus();
|
|
725
|
+
}
|
|
726
|
+
return POSITION_INITIAL;
|
|
727
|
+
}
|
|
728
|
+
function listNavigationInput(props) {
|
|
729
|
+
switch (props.event.code) {
|
|
730
|
+
case 'ArrowDown':
|
|
731
|
+
return navigationInputDown(props);
|
|
732
|
+
case 'ArrowUp':
|
|
733
|
+
return navigationInputUp(props);
|
|
734
|
+
default:
|
|
735
|
+
return undefined;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function listNavigationElement(props) {
|
|
739
|
+
const { event } = props;
|
|
740
|
+
switch (event.code) {
|
|
741
|
+
case 'ArrowDown':
|
|
742
|
+
return navigationElementDown(props);
|
|
743
|
+
case 'ArrowUp':
|
|
744
|
+
return navigationElementUp(props);
|
|
745
|
+
default:
|
|
746
|
+
return POSITION_INITIAL;
|
|
747
|
+
}
|
|
348
748
|
}
|
|
349
|
-
|
|
350
|
-
|
|
749
|
+
|
|
750
|
+
class ListCollection {
|
|
751
|
+
constructor(value) {
|
|
752
|
+
this.value = value;
|
|
753
|
+
}
|
|
754
|
+
find(element) {
|
|
755
|
+
return this.value.find((current) => current.compareTo(element));
|
|
756
|
+
}
|
|
351
757
|
}
|
|
352
758
|
|
|
353
|
-
function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme,
|
|
354
|
-
const
|
|
355
|
-
const initialDay = formControl?.state || initialDate.getDate();
|
|
759
|
+
function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
|
|
760
|
+
const currentDate = date || new Date(); // Initial date
|
|
356
761
|
const [weeks, setWeeks] = react.useState([]);
|
|
357
|
-
const [value, setValue] = react.useState(
|
|
762
|
+
const [value, setValue] = react.useState(formControl?.state || currentDate.getDate());
|
|
358
763
|
react.useEffect(() => {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
764
|
+
const props = createPickerProps();
|
|
765
|
+
const day = checkDayPicker(props);
|
|
766
|
+
day ? setDayValue(day) : setWeeks(createDayPicker(props));
|
|
767
|
+
}, [date, month, year, value, minDate, maxDate]);
|
|
768
|
+
react.useEffect(() => {
|
|
769
|
+
const day = checkDayPicker(createPickerProps());
|
|
770
|
+
day
|
|
771
|
+
? formControl?.setState(day)
|
|
772
|
+
: setValue(formControl?.state || currentDate.getDate());
|
|
773
|
+
}, [formControl?.state]);
|
|
774
|
+
function createPickerProps() {
|
|
775
|
+
return {
|
|
776
|
+
date: currentDate,
|
|
777
|
+
day: formControl?.state || value,
|
|
778
|
+
month: helpersAdvanced.itIsDefined(month) ? month : currentDate.getMonth(),
|
|
779
|
+
year: year || currentDate.getFullYear(),
|
|
362
780
|
minDate,
|
|
363
781
|
maxDate
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
}, [date]);
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
function setDayValue(value) {
|
|
785
|
+
formControl ? formControl.setState(value) : setValue(value);
|
|
786
|
+
}
|
|
371
787
|
function onChange(value) {
|
|
372
|
-
|
|
373
|
-
formControl?.setState(value);
|
|
788
|
+
setDayValue(value);
|
|
374
789
|
if (onValue) {
|
|
375
790
|
onValue(value);
|
|
376
791
|
}
|
|
377
792
|
}
|
|
378
|
-
return (jsxRuntime.jsxs("div", { className: "rls-day-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-picker__header", children: helpersDate.DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-day-picker__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-day-picker__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-day-picker__week", children: days.map(({ value, disabled, forbidden, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-day-picker__day', {
|
|
793
|
+
return (jsxRuntime.jsxs("div", { className: "rls-day-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-picker__header", children: helpersDate.DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-day-picker__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-day-picker__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-day-picker__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-day-picker__day', {
|
|
379
794
|
disabled: disabled || disabledPicker,
|
|
795
|
+
focused,
|
|
380
796
|
forbidden,
|
|
381
|
-
selected
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
onChange(value);
|
|
385
|
-
}
|
|
386
|
-
}, children: jsxRuntime.jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
797
|
+
selected,
|
|
798
|
+
today
|
|
799
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
387
800
|
}
|
|
388
801
|
|
|
389
802
|
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
390
|
-
class DateRangePickerFactory {
|
|
391
|
-
constructor(props) {
|
|
392
|
-
const { date, range, sourceDate, maxDate, minDate } = props;
|
|
393
|
-
this.date = new Date(date.getTime());
|
|
394
|
-
this.range = range;
|
|
395
|
-
this.sourceDate = sourceDate;
|
|
396
|
-
this.maxDate = maxDate;
|
|
397
|
-
this.minDate = minDate;
|
|
398
|
-
this.date.setDate(1);
|
|
399
|
-
}
|
|
400
|
-
static execute(props) {
|
|
401
|
-
const factory = new DateRangePickerFactory(props);
|
|
402
|
-
const firstWeek = factory.createFirstWeek();
|
|
403
|
-
const rightWeeks = factory.createRightWeeks();
|
|
404
|
-
return [firstWeek, ...rightWeeks];
|
|
405
|
-
}
|
|
406
|
-
createFirstWeek() {
|
|
407
|
-
const dayStart = this.date.getDay();
|
|
408
|
-
const days = [];
|
|
409
|
-
let day = 1;
|
|
410
|
-
for (let start = 0; start < dayStart; start++) {
|
|
411
|
-
days.push(this.createDayRangeState());
|
|
412
|
-
}
|
|
413
|
-
for (let end = dayStart; end < 7; end++) {
|
|
414
|
-
days.push(this.createDayRangeState(day));
|
|
415
|
-
day++;
|
|
416
|
-
}
|
|
417
|
-
return { days };
|
|
418
|
-
}
|
|
419
|
-
createRightWeeks() {
|
|
420
|
-
const rightWeeks = [];
|
|
421
|
-
const dayStart = this.date.getDay();
|
|
422
|
-
const dayCount = helpersDate.daysFromMonth(this.date.getFullYear(), this.date.getMonth());
|
|
423
|
-
let days = [];
|
|
424
|
-
let countDaysWeek = 1;
|
|
425
|
-
let day = 8 - dayStart;
|
|
426
|
-
do {
|
|
427
|
-
days.push(this.createDayRangeState(day));
|
|
428
|
-
day++;
|
|
429
|
-
countDaysWeek++;
|
|
430
|
-
if (countDaysWeek > 7) {
|
|
431
|
-
rightWeeks.push({ days });
|
|
432
|
-
days = [];
|
|
433
|
-
countDaysWeek = 1;
|
|
434
|
-
}
|
|
435
|
-
} while (day <= dayCount);
|
|
436
|
-
const daysPending = this.createDaysPending(days.length);
|
|
437
|
-
rightWeeks.push({ days: [...days, ...daysPending] });
|
|
438
|
-
return rightWeeks;
|
|
439
|
-
}
|
|
440
|
-
createDaysPending(daysWeek) {
|
|
441
|
-
const daysPending = [];
|
|
442
|
-
const length = 7 - daysWeek;
|
|
443
|
-
for (let index = 0; index < length; index++) {
|
|
444
|
-
daysPending.push(this.createDayRangeState());
|
|
445
|
-
}
|
|
446
|
-
return daysPending;
|
|
447
|
-
}
|
|
448
|
-
isSelectedSource(day) {
|
|
449
|
-
return this.isSelectedForDate(this.sourceDate, day);
|
|
450
|
-
}
|
|
451
|
-
isSelectedEnd(day) {
|
|
452
|
-
return (this.isSelectedForDate(this.range.minDate, day) ||
|
|
453
|
-
this.isSelectedForDate(this.range.maxDate, day));
|
|
454
|
-
}
|
|
455
|
-
isSelectedForDate(date, day) {
|
|
456
|
-
return (date.getFullYear() === this.date.getFullYear() &&
|
|
457
|
-
date.getMonth() === this.date.getMonth() &&
|
|
458
|
-
day === date.getDate());
|
|
459
|
-
}
|
|
460
|
-
isRangedFromDate(day) {
|
|
461
|
-
return helpersDate.between(this.range.minDate, this.range.maxDate, helpersDate.assignDay(this.date, day));
|
|
462
|
-
}
|
|
463
|
-
overflowDay(day) {
|
|
464
|
-
return this.minOverflowDay(day) || this.maxOverflowDay(day);
|
|
465
|
-
}
|
|
466
|
-
minOverflowDay(day) {
|
|
467
|
-
return this.minDate
|
|
468
|
-
? helpersDate.weight(helpersDate.assignDay(this.date, day)) < helpersDate.weight(this.minDate)
|
|
469
|
-
: false;
|
|
470
|
-
}
|
|
471
|
-
maxOverflowDay(day) {
|
|
472
|
-
return this.maxDate
|
|
473
|
-
? helpersDate.weight(helpersDate.assignDay(this.date, day)) > helpersDate.weight(this.maxDate)
|
|
474
|
-
: false;
|
|
475
|
-
}
|
|
476
|
-
createDayRangeState(day) {
|
|
477
|
-
return {
|
|
478
|
-
value: day,
|
|
479
|
-
disabled: this.overflowDay(day || 0),
|
|
480
|
-
forbidden: !day,
|
|
481
|
-
ranged: day ? this.isRangedFromDate(day) : false,
|
|
482
|
-
end: day ? this.isSelectedEnd(day) : false,
|
|
483
|
-
source: day ? this.isSelectedSource(day) : false
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
function formatRange(range) {
|
|
488
|
-
const minFormat = helpersDate.formatDate(range.minDate, DATE_RANGE_FORMAT);
|
|
489
|
-
const maxFormat = helpersDate.formatDate(range.maxDate, DATE_RANGE_FORMAT);
|
|
490
|
-
return `${minFormat} - ${maxFormat}`;
|
|
491
|
-
}
|
|
492
|
-
function createRangePicker(props) {
|
|
493
|
-
return DateRangePickerFactory.execute(props);
|
|
494
|
-
}
|
|
495
803
|
|
|
496
804
|
function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
const sourceDate = react.useRef(
|
|
805
|
+
const currentRange = formControl?.state || helpersDate.DateRange.now();
|
|
806
|
+
const currentDate = helpersDate.normalizeMinTime(date || currentRange.minDate);
|
|
807
|
+
const sourceDate = react.useRef(currentRange.minDate);
|
|
500
808
|
const [weeks, setWeeks] = react.useState([]);
|
|
501
|
-
const [range, setRange] = react.useState(
|
|
809
|
+
const [range, setRange] = react.useState(currentRange);
|
|
502
810
|
react.useEffect(() => {
|
|
503
|
-
setWeeks(
|
|
504
|
-
date:
|
|
811
|
+
setWeeks(createDayRangePicker({
|
|
812
|
+
date: currentDate,
|
|
505
813
|
range,
|
|
506
814
|
sourceDate: sourceDate.current,
|
|
507
815
|
minDate,
|
|
@@ -509,25 +817,21 @@ function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDat
|
|
|
509
817
|
}));
|
|
510
818
|
}, [range, date, minDate, maxDate]);
|
|
511
819
|
function onChange(value) {
|
|
512
|
-
const
|
|
513
|
-
const
|
|
514
|
-
? new helpersDate.DateRange(sourceDate.current,
|
|
515
|
-
: new helpersDate.DateRange(
|
|
516
|
-
sourceDate.current =
|
|
517
|
-
setRange(
|
|
518
|
-
formControl?.setState(
|
|
519
|
-
}
|
|
520
|
-
return (jsxRuntime.jsxs("div", { className: "rls-day-range-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-range-picker__title", children: helpersDate.
|
|
820
|
+
const date = helpersDate.assignDayInDate(currentDate, value);
|
|
821
|
+
const range = helpersDate.dateIsBefore(date, sourceDate.current)
|
|
822
|
+
? new helpersDate.DateRange(sourceDate.current, date)
|
|
823
|
+
: new helpersDate.DateRange(date, sourceDate.current);
|
|
824
|
+
sourceDate.current = date;
|
|
825
|
+
setRange(range);
|
|
826
|
+
formControl?.setState(range);
|
|
827
|
+
}
|
|
828
|
+
return (jsxRuntime.jsxs("div", { className: "rls-day-range-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-range-picker__title", children: helpersDate.dateFormatTemplate(sourceDate.current, DATE_RANGE_FORMAT) }), jsxRuntime.jsx("div", { className: "rls-day-range-picker__header", children: helpersDate.DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-day-range-picker__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-day-range-picker__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-day-range-picker__week", children: days.map(({ disabled, end, forbidden, source, ranged, value }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-day-range-picker__day', {
|
|
521
829
|
disabled: disabled || disabledPicker,
|
|
522
830
|
end,
|
|
523
831
|
forbidden,
|
|
524
832
|
ranged,
|
|
525
833
|
source
|
|
526
|
-
}), onClick: () => {
|
|
527
|
-
if (value && !disabled) {
|
|
528
|
-
onChange(value);
|
|
529
|
-
}
|
|
530
|
-
}, children: jsxRuntime.jsx("span", { className: "rls-day-range-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
834
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-day-range-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
531
835
|
}
|
|
532
836
|
|
|
533
837
|
function RlsMoneyField({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
|
|
@@ -538,156 +842,93 @@ function RlsMoneyField({ children, decimals, disabled, formControl, placeholder,
|
|
|
538
842
|
}, 'rls-money-field'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsx("div", { className: "rls-box-field__body", children: jsxRuntime.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
|
|
539
843
|
}
|
|
540
844
|
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
class MonthPickerFactory {
|
|
544
|
-
constructor(props) {
|
|
545
|
-
const { date, value, maxDate, minDate } = props;
|
|
546
|
-
this.value = value;
|
|
547
|
-
this.date = new Date(date.getTime());
|
|
548
|
-
this.maxDate = maxDate;
|
|
549
|
-
this.minDate = minDate;
|
|
550
|
-
}
|
|
551
|
-
static execute(props) {
|
|
552
|
-
const factory = new MonthPickerFactory(props);
|
|
553
|
-
return [
|
|
554
|
-
factory.createMonth(helpersDate.Month.January),
|
|
555
|
-
factory.createMonth(helpersDate.Month.February),
|
|
556
|
-
factory.createMonth(helpersDate.Month.March),
|
|
557
|
-
factory.createMonth(helpersDate.Month.April),
|
|
558
|
-
factory.createMonth(helpersDate.Month.May),
|
|
559
|
-
factory.createMonth(helpersDate.Month.June),
|
|
560
|
-
factory.createMonth(helpersDate.Month.July),
|
|
561
|
-
factory.createMonth(helpersDate.Month.August),
|
|
562
|
-
factory.createMonth(helpersDate.Month.September),
|
|
563
|
-
factory.createMonth(helpersDate.Month.October),
|
|
564
|
-
factory.createMonth(helpersDate.Month.November),
|
|
565
|
-
factory.createMonth(helpersDate.Month.December)
|
|
566
|
-
];
|
|
567
|
-
}
|
|
568
|
-
createMonth(value) {
|
|
569
|
-
return {
|
|
570
|
-
value,
|
|
571
|
-
label: helpersDate.MONTH_NAMES()[value],
|
|
572
|
-
disabled: this.overflowMonth(value),
|
|
573
|
-
selected: value === this.value
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
get minYear() {
|
|
577
|
-
return this.minDate?.getFullYear() || 0;
|
|
578
|
-
}
|
|
579
|
-
get maxYear() {
|
|
580
|
-
return this.maxDate?.getFullYear() || 10000;
|
|
581
|
-
}
|
|
582
|
-
get minMonth() {
|
|
583
|
-
return this.minDate ? this.minDate.getMonth() : MONTH_MIN_VALUE;
|
|
584
|
-
}
|
|
585
|
-
get maxMonth() {
|
|
586
|
-
return this.maxDate ? this.maxDate.getMonth() : MONTH_MAX_VALUE;
|
|
587
|
-
}
|
|
588
|
-
overflowMonth(month) {
|
|
589
|
-
return this.minOverflowMonth(month) || this.maxOverflowMonth(month);
|
|
590
|
-
}
|
|
591
|
-
minOverflowMonth(month) {
|
|
592
|
-
return this.date.getFullYear() === this.minYear && month < this.minMonth;
|
|
593
|
-
}
|
|
594
|
-
maxOverflowMonth(month) {
|
|
595
|
-
return this.date.getFullYear() === this.maxYear && month > this.maxMonth;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
function isMinLimitMonth(month, date, minDate) {
|
|
599
|
-
if (typeof month === 'number' && date) {
|
|
600
|
-
const minMonth = minDate ? minDate.getMonth() : MONTH_MIN_VALUE;
|
|
601
|
-
const minYear = minDate ? minDate.getFullYear() : 0;
|
|
602
|
-
return date.getFullYear() === minYear && month <= minMonth;
|
|
603
|
-
}
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
function isMaxLimitMonth(month, date, maxDate) {
|
|
607
|
-
if (typeof month === 'number' && date) {
|
|
608
|
-
const maxMonth = maxDate ? maxDate.getMonth() : MONTH_MAX_VALUE;
|
|
609
|
-
const maxYear = maxDate ? maxDate.getFullYear() : 10000;
|
|
610
|
-
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
611
|
-
}
|
|
612
|
-
return false;
|
|
613
|
-
}
|
|
614
|
-
function createMonthPicker(props) {
|
|
615
|
-
return MonthPickerFactory.execute(props);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme, onValue }) {
|
|
619
|
-
const initialDate = date || new Date();
|
|
620
|
-
const initialMonth = formControl?.state || initialDate.getMonth();
|
|
845
|
+
function RlsMonthPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
|
|
846
|
+
const currentDate = date || new Date();
|
|
621
847
|
const [months, setMonths] = react.useState([]);
|
|
622
|
-
const [value, setValue] = react.useState(
|
|
848
|
+
const [value, setValue] = react.useState(formControl?.state || currentDate.getMonth());
|
|
623
849
|
react.useEffect(() => {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
850
|
+
const props = createPickerProps(); // MonthPickerProps
|
|
851
|
+
const month = checkMonthPicker(props);
|
|
852
|
+
month ? setMonthValue(month) : setMonths(createMonthPicker(props));
|
|
853
|
+
}, [date, year, value, minDate, maxDate]);
|
|
854
|
+
react.useEffect(() => {
|
|
855
|
+
const month = checkMonthPicker(createPickerProps());
|
|
856
|
+
helpersAdvanced.itIsDefined(month)
|
|
857
|
+
? formControl?.setState(month)
|
|
858
|
+
: setValue(formControl?.state || currentDate.getMonth());
|
|
859
|
+
}, [formControl?.state]);
|
|
860
|
+
function createPickerProps() {
|
|
861
|
+
return {
|
|
862
|
+
date: currentDate,
|
|
863
|
+
month: helpersAdvanced.itIsDefined(formControl?.state) ? formControl?.state : value,
|
|
864
|
+
year: year || currentDate.getFullYear(),
|
|
627
865
|
minDate,
|
|
628
866
|
maxDate
|
|
629
|
-
}
|
|
630
|
-
}
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
function setMonthValue(value) {
|
|
870
|
+
formControl ? formControl.setState(value) : setValue(value);
|
|
871
|
+
}
|
|
631
872
|
function onChange(value) {
|
|
632
|
-
|
|
633
|
-
setValue(value);
|
|
873
|
+
setMonthValue(value);
|
|
634
874
|
if (onValue) {
|
|
635
875
|
onValue(value);
|
|
636
876
|
}
|
|
637
877
|
}
|
|
638
|
-
return (jsxRuntime.jsx("div", { className: "rls-month-picker", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-month-picker__component', {
|
|
639
|
-
disabled: disabled || disabledPicker
|
|
878
|
+
return (jsxRuntime.jsx("div", { className: "rls-month-picker", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, focused, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-month-picker__component', {
|
|
879
|
+
disabled: disabled || disabledPicker,
|
|
880
|
+
focused,
|
|
640
881
|
selected
|
|
641
|
-
}), onClick: () => {
|
|
642
|
-
if (!disabled) {
|
|
643
|
-
onChange(value);
|
|
644
|
-
}
|
|
645
|
-
}, children: jsxRuntime.jsx("span", { className: "rls-month-picker__span", children: label }) }, index))) }));
|
|
882
|
+
}), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-month-picker__span", children: label }) }, index))) }));
|
|
646
883
|
}
|
|
647
884
|
|
|
648
|
-
function RlsMonthTitlePicker({
|
|
649
|
-
const {
|
|
650
|
-
|
|
651
|
-
|
|
885
|
+
function RlsMonthTitlePicker({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
|
|
886
|
+
const { limitNext, limitPrevious } = monthLimitTemplate({
|
|
887
|
+
date,
|
|
888
|
+
maxDate,
|
|
889
|
+
minDate,
|
|
890
|
+
month: monthControl.state
|
|
891
|
+
});
|
|
892
|
+
const monthName = helpersDate.MONTH_NAMES()[monthControl.state || 0];
|
|
652
893
|
function onPreviousMonth() {
|
|
653
|
-
if (
|
|
654
|
-
if (
|
|
655
|
-
monthControl.setState(
|
|
894
|
+
if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
895
|
+
if (monthControl.state > helpersDate.Month.January) {
|
|
896
|
+
monthControl.setState(monthControl.state - 1);
|
|
656
897
|
}
|
|
657
898
|
else {
|
|
658
|
-
monthControl.setState(
|
|
659
|
-
yearControl.setState(
|
|
899
|
+
monthControl.setState(helpersDate.Month.December);
|
|
900
|
+
yearControl.setState(yearControl.state - 1);
|
|
660
901
|
}
|
|
661
902
|
}
|
|
662
903
|
}
|
|
663
904
|
function onPreviousYear() {
|
|
664
|
-
if (
|
|
665
|
-
yearControl.setState(
|
|
905
|
+
if (helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
906
|
+
yearControl.setState(yearControl.state - 1);
|
|
666
907
|
}
|
|
667
908
|
}
|
|
668
909
|
function onPrevious() {
|
|
669
910
|
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
670
911
|
}
|
|
671
912
|
function onNextMonth() {
|
|
672
|
-
if (
|
|
673
|
-
if (
|
|
674
|
-
monthControl.setState(
|
|
913
|
+
if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
914
|
+
if (monthControl.state < helpersDate.Month.December) {
|
|
915
|
+
monthControl.setState(monthControl.state + 1);
|
|
675
916
|
}
|
|
676
917
|
else {
|
|
677
|
-
monthControl.setState(
|
|
678
|
-
yearControl.setState(
|
|
918
|
+
monthControl.setState(helpersDate.Month.January);
|
|
919
|
+
yearControl.setState(yearControl.state + 1);
|
|
679
920
|
}
|
|
680
921
|
}
|
|
681
922
|
}
|
|
682
923
|
function onNextYear() {
|
|
683
|
-
if (
|
|
684
|
-
yearControl.setState(
|
|
924
|
+
if (helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
925
|
+
yearControl.setState(yearControl.state + 1);
|
|
685
926
|
}
|
|
686
927
|
}
|
|
687
928
|
function onNext() {
|
|
688
929
|
type === 'month' ? onNextMonth() : onNextYear();
|
|
689
930
|
}
|
|
690
|
-
return (jsxRuntime.jsxs("div", { className: "rls-month-title-picker", children: [jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled:
|
|
931
|
+
return (jsxRuntime.jsxs("div", { className: "rls-month-title-picker", children: [jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntime.jsx("span", { onClick: onClick, children: monthName }), jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
|
|
691
932
|
}
|
|
692
933
|
|
|
693
934
|
function RlsNumberField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
@@ -967,108 +1208,36 @@ function RlsToolbar({ actions, children, subtitle }) {
|
|
|
967
1208
|
return (jsxRuntime.jsxs("div", { className: "rls-toolbar", children: [jsxRuntime.jsxs("div", { className: "rls-toolbar__description", children: [children && jsxRuntime.jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsxRuntime.jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsxRuntime.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntime.jsx("div", { children: action }, index))) }))] }));
|
|
968
1209
|
}
|
|
969
1210
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
year = factory.minYear;
|
|
983
|
-
}
|
|
984
|
-
else if (factory.maxOverflowYear(year)) {
|
|
985
|
-
year = factory.maxYear;
|
|
986
|
-
}
|
|
987
|
-
const years = factory.createYears(year);
|
|
988
|
-
return {
|
|
989
|
-
hasNext: factory.hasNext,
|
|
990
|
-
hasPrevious: factory.hasPrevious,
|
|
991
|
-
maxRange: factory.maxYearRange,
|
|
992
|
-
minRange: factory.minYearRange,
|
|
993
|
-
years
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
createYears(year) {
|
|
997
|
-
const prevYears = [];
|
|
998
|
-
const nextYears = [];
|
|
999
|
-
this.minYearRange = year;
|
|
1000
|
-
this.maxYearRange = year;
|
|
1001
|
-
for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
|
|
1002
|
-
const yearPrev = year - COUNT_YEAR_RANGE + index;
|
|
1003
|
-
const yearNext = year + index + 1;
|
|
1004
|
-
const valuePrev = yearPrev >= this.minYear ? yearPrev : undefined;
|
|
1005
|
-
const valueNext = yearNext <= this.maxYear ? yearNext : undefined;
|
|
1006
|
-
const prevState = this.createYear(valuePrev);
|
|
1007
|
-
const nextState = this.createYear(valueNext);
|
|
1008
|
-
prevYears.push(prevState);
|
|
1009
|
-
nextYears.push(nextState);
|
|
1010
|
-
this.recalculateRange(prevState, nextState);
|
|
1011
|
-
}
|
|
1012
|
-
const yearCenter = this.createYear(year);
|
|
1013
|
-
return [...prevYears, yearCenter, ...nextYears];
|
|
1014
|
-
}
|
|
1015
|
-
minOverflowYear(year) {
|
|
1016
|
-
return year < this.minYear;
|
|
1017
|
-
}
|
|
1018
|
-
maxOverflowYear(year) {
|
|
1019
|
-
return year > this.maxYear;
|
|
1020
|
-
}
|
|
1021
|
-
get minYear() {
|
|
1022
|
-
return this.minDate?.getFullYear() || 0;
|
|
1023
|
-
}
|
|
1024
|
-
get maxYear() {
|
|
1025
|
-
return this.maxDate?.getFullYear() || 10000;
|
|
1026
|
-
}
|
|
1027
|
-
get hasPrevious() {
|
|
1028
|
-
return this.minYear < this.minYearRange;
|
|
1029
|
-
}
|
|
1030
|
-
get hasNext() {
|
|
1031
|
-
return this.maxYear > this.maxYearRange;
|
|
1032
|
-
}
|
|
1033
|
-
createYear(value) {
|
|
1034
|
-
return {
|
|
1035
|
-
value,
|
|
1036
|
-
disabled: !value,
|
|
1037
|
-
selected: value === this.value
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
recalculateRange(prev, next) {
|
|
1041
|
-
if (!!prev.value && this.minYearRange > prev.value) {
|
|
1042
|
-
this.minYearRange = prev.value;
|
|
1043
|
-
}
|
|
1044
|
-
if (!!next.value && this.maxYearRange < next.value) {
|
|
1045
|
-
this.maxYearRange = next.value;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
function createYearPicker(props) {
|
|
1050
|
-
return YearPickerFactory.execute(props);
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
function RlsYearPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme, onValue }) {
|
|
1054
|
-
const initialDate = date || new Date();
|
|
1055
|
-
const initialYear = formControl?.state || initialDate.getFullYear();
|
|
1056
|
-
const [value, setValue] = react.useState(initialYear);
|
|
1057
|
-
const [year, setYear] = react.useState(initialYear);
|
|
1058
|
-
const [template, setTemplate] = react.useState(createYearPicker({
|
|
1059
|
-
value: formControl?.state || value,
|
|
1060
|
-
year: initialYear,
|
|
1061
|
-
minDate,
|
|
1062
|
-
maxDate
|
|
1063
|
-
}));
|
|
1211
|
+
function RlsYearPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme }) {
|
|
1212
|
+
const currentDate = date || new Date();
|
|
1213
|
+
const [value, setValue] = react.useState(formControl?.state || currentDate.getFullYear());
|
|
1214
|
+
const [year, setYear] = react.useState(formControl?.state || currentDate.getFullYear());
|
|
1215
|
+
const [template, setTemplate] = react.useState(createYearPicker(createPickerProps()));
|
|
1216
|
+
react.useEffect(() => {
|
|
1217
|
+
const props = createPickerProps(); // YearPickerProps
|
|
1218
|
+
const year = checkYearPicker(props);
|
|
1219
|
+
year
|
|
1220
|
+
? setYearValue(year)
|
|
1221
|
+
: setTemplate(createYearPicker(createPickerProps()));
|
|
1222
|
+
}, [date, year, value, minDate, maxDate]);
|
|
1064
1223
|
react.useEffect(() => {
|
|
1065
|
-
|
|
1066
|
-
|
|
1224
|
+
const year = checkYearPicker(createPickerProps());
|
|
1225
|
+
helpersAdvanced.itIsDefined(year)
|
|
1226
|
+
? formControl?.setState(year)
|
|
1227
|
+
: setValue(formControl?.state || currentDate.getFullYear());
|
|
1228
|
+
}, [formControl?.state]);
|
|
1229
|
+
function createPickerProps() {
|
|
1230
|
+
return {
|
|
1231
|
+
date: currentDate,
|
|
1067
1232
|
year,
|
|
1068
1233
|
minDate,
|
|
1069
1234
|
maxDate
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function setYearValue(value) {
|
|
1238
|
+
formControl ? formControl.setState(value) : setValue(value);
|
|
1239
|
+
setYear(value);
|
|
1240
|
+
}
|
|
1072
1241
|
function onClickPrev() {
|
|
1073
1242
|
setYear(year - 8);
|
|
1074
1243
|
}
|
|
@@ -1076,21 +1245,16 @@ function RlsYearPicker({ formControl, date, disabled: disabledPicker, maxDate, m
|
|
|
1076
1245
|
setYear(year + 8);
|
|
1077
1246
|
}
|
|
1078
1247
|
function onChange(value) {
|
|
1079
|
-
|
|
1080
|
-
setYear(value);
|
|
1081
|
-
setValue(value);
|
|
1248
|
+
setYearValue(value);
|
|
1082
1249
|
if (onValue) {
|
|
1083
1250
|
onValue(value);
|
|
1084
1251
|
}
|
|
1085
1252
|
}
|
|
1086
|
-
return (jsxRuntime.jsxs("div", { className: "rls-year-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-year-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--prev", children: jsxRuntime.jsx(
|
|
1253
|
+
return (jsxRuntime.jsxs("div", { className: "rls-year-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-year-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--prev", children: jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabledPicker }) }), jsxRuntime.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntime.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--next", children: jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsxRuntime.jsx("div", { className: "rls-year-picker__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-year-picker__year', {
|
|
1087
1254
|
disabled: disabled || disabledPicker,
|
|
1255
|
+
focused,
|
|
1088
1256
|
selected
|
|
1089
|
-
}), onClick: () => {
|
|
1090
|
-
if (value && !disabled) {
|
|
1091
|
-
onChange(value);
|
|
1092
|
-
}
|
|
1093
|
-
}, children: jsxRuntime.jsx("span", { className: "rls-year-picker__year__span body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1257
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-year-picker__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1094
1258
|
}
|
|
1095
1259
|
|
|
1096
1260
|
const reactI18n = i18n.i18n({
|
|
@@ -1132,23 +1296,7 @@ function useDatatable() {
|
|
|
1132
1296
|
return { bodyRef, scrolleable };
|
|
1133
1297
|
}
|
|
1134
1298
|
|
|
1135
|
-
|
|
1136
|
-
constructor(value) {
|
|
1137
|
-
this.value = value;
|
|
1138
|
-
}
|
|
1139
|
-
find(element) {
|
|
1140
|
-
return this.value.find((current) => current.compareTo(element));
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
const classElement = '.rls-list-field__element';
|
|
1145
|
-
const MAX_POSITION_VISIBLE = 4;
|
|
1146
|
-
const LIST_SIZE_REM = 16;
|
|
1147
|
-
const ELEMENT_SIZE_REM = 4;
|
|
1148
|
-
const BASE_SIZE_PX = 16;
|
|
1149
|
-
const ELEMENT_SIZE_PX = BASE_SIZE_PX * ELEMENT_SIZE_REM;
|
|
1150
|
-
const MAZ_LIST_SIZE_PX = BASE_SIZE_PX * LIST_SIZE_REM;
|
|
1151
|
-
function useListControl({ suggestions, formControl, higher: withHigher = false }) {
|
|
1299
|
+
function useListControl({ suggestions, formControl }) {
|
|
1152
1300
|
const boxContentRef = react.useRef(null);
|
|
1153
1301
|
const listRef = react.useRef(null);
|
|
1154
1302
|
const inputRef = react.useRef(null);
|
|
@@ -1158,11 +1306,10 @@ function useListControl({ suggestions, formControl, higher: withHigher = false }
|
|
|
1158
1306
|
const [visible, setVisible] = react.useState(false);
|
|
1159
1307
|
const [higher, setHigher] = react.useState(false);
|
|
1160
1308
|
const [focused, setFocused] = react.useState(false);
|
|
1161
|
-
const
|
|
1162
|
-
const [listElements, setListElements] = react.useState(undefined);
|
|
1309
|
+
const position = react.useRef(0);
|
|
1163
1310
|
react.useEffect(() => {
|
|
1164
|
-
function onCloseSuggestions(
|
|
1165
|
-
if (!boxContentRef?.current?.contains(
|
|
1311
|
+
function onCloseSuggestions({ target }) {
|
|
1312
|
+
if (!boxContentRef?.current?.contains(target)) {
|
|
1166
1313
|
setVisible(false);
|
|
1167
1314
|
}
|
|
1168
1315
|
}
|
|
@@ -1175,95 +1322,32 @@ function useListControl({ suggestions, formControl, higher: withHigher = false }
|
|
|
1175
1322
|
if (visible && !opened) {
|
|
1176
1323
|
setOpened(true);
|
|
1177
1324
|
}
|
|
1178
|
-
if (!visible && opened && formControl
|
|
1325
|
+
if (!visible && opened && !!formControl?.touched) {
|
|
1179
1326
|
formControl.touch();
|
|
1180
1327
|
}
|
|
1181
|
-
|
|
1328
|
+
setHigher(!locationListIsBottom(boxContentRef.current, listRef.current));
|
|
1182
1329
|
}, [visible]);
|
|
1183
1330
|
react.useEffect(() => {
|
|
1184
1331
|
setCollection(new ListCollection(suggestions));
|
|
1185
1332
|
}, [suggestions]);
|
|
1186
|
-
function setLocationList() {
|
|
1187
|
-
if (boxContentRef?.current) {
|
|
1188
|
-
const { top, height } = boxContentRef.current.getBoundingClientRect();
|
|
1189
|
-
const overflow = BASE_SIZE_PX / 2;
|
|
1190
|
-
const positionEnd = top + height + MAZ_LIST_SIZE_PX + overflow;
|
|
1191
|
-
setHigher(positionEnd > window.innerHeight);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
1333
|
function navigationInput(event) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
if (visible && (withHigher || !higher)) {
|
|
1203
|
-
navigationInputDown();
|
|
1204
|
-
}
|
|
1205
|
-
break;
|
|
1334
|
+
if (visible) {
|
|
1335
|
+
const newPosition = listNavigationInput({
|
|
1336
|
+
contentElement: boxContentRef.current,
|
|
1337
|
+
event: event,
|
|
1338
|
+
listElement: listRef.current
|
|
1339
|
+
});
|
|
1340
|
+
position.current = helpersAdvanced.itIsDefined(newPosition) ? newPosition : 0;
|
|
1206
1341
|
}
|
|
1207
1342
|
}
|
|
1208
1343
|
function navigationElement(event) {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
function navigationInputUp() {
|
|
1219
|
-
const elements = listRef?.current?.querySelectorAll(classElement);
|
|
1220
|
-
if (elements?.length) {
|
|
1221
|
-
const newPosition = elements.length - 1;
|
|
1222
|
-
setListElements(elements);
|
|
1223
|
-
setPositionElement(newPosition);
|
|
1224
|
-
elements.item(newPosition).focus();
|
|
1225
|
-
if (positionElement > MAX_POSITION_VISIBLE) {
|
|
1226
|
-
const elementPosition = elements.length - MAX_POSITION_VISIBLE;
|
|
1227
|
-
setTimeout(() => {
|
|
1228
|
-
listRef?.current?.scroll({
|
|
1229
|
-
top: ELEMENT_SIZE_PX * elementPosition,
|
|
1230
|
-
behavior: 'smooth'
|
|
1231
|
-
});
|
|
1232
|
-
}, 100);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
function navigationInputDown() {
|
|
1237
|
-
const elements = listRef?.current?.querySelectorAll(classElement);
|
|
1238
|
-
if (elements?.length) {
|
|
1239
|
-
setListElements(elements);
|
|
1240
|
-
setPositionElement(0);
|
|
1241
|
-
elements.item(0).focus();
|
|
1242
|
-
setTimeout(() => {
|
|
1243
|
-
listRef?.current?.scroll({ top: 0, behavior: 'smooth' });
|
|
1244
|
-
}, 100);
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
function navigationElementUp() {
|
|
1248
|
-
if (positionElement > 0) {
|
|
1249
|
-
const newPosition = positionElement - 1;
|
|
1250
|
-
setPositionElement(newPosition);
|
|
1251
|
-
listElements?.item(newPosition).focus();
|
|
1252
|
-
}
|
|
1253
|
-
else if (withHigher || !higher) {
|
|
1254
|
-
inputRef?.current?.focus();
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
function navigationElementDown() {
|
|
1258
|
-
const newPosition = positionElement + 1;
|
|
1259
|
-
const length = listElements?.length || 0;
|
|
1260
|
-
if (newPosition < length) {
|
|
1261
|
-
setPositionElement(newPosition);
|
|
1262
|
-
listElements?.item(newPosition).focus();
|
|
1263
|
-
}
|
|
1264
|
-
else if (higher && !withHigher) {
|
|
1265
|
-
inputRef?.current?.focus();
|
|
1266
|
-
}
|
|
1344
|
+
position.current = listNavigationElement({
|
|
1345
|
+
contentElement: boxContentRef.current,
|
|
1346
|
+
event: event,
|
|
1347
|
+
inputElement: inputRef.current,
|
|
1348
|
+
listElement: listRef.current,
|
|
1349
|
+
position: position.current
|
|
1350
|
+
});
|
|
1267
1351
|
}
|
|
1268
1352
|
return {
|
|
1269
1353
|
boxContentRef,
|
|
@@ -1292,39 +1376,31 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1292
1376
|
coincidences: [],
|
|
1293
1377
|
previous: null
|
|
1294
1378
|
});
|
|
1295
|
-
const listControl = useListControl({
|
|
1296
|
-
suggestions,
|
|
1297
|
-
formControl,
|
|
1298
|
-
higher: true
|
|
1299
|
-
});
|
|
1379
|
+
const listControl = useListControl({ suggestions, formControl });
|
|
1300
1380
|
const { collection, inputRef, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
|
|
1301
|
-
const
|
|
1381
|
+
const changeInternal = react.useRef(false);
|
|
1302
1382
|
react.useEffect(() => filterSuggestions(pattern, true), [suggestions]);
|
|
1303
1383
|
react.useEffect(() => filterSuggestions(pattern), [pattern]);
|
|
1304
1384
|
react.useEffect(() => {
|
|
1305
|
-
|
|
1385
|
+
if (changeInternal.current) {
|
|
1386
|
+
changeInternal.current = false;
|
|
1387
|
+
}
|
|
1388
|
+
else {
|
|
1389
|
+
resetState(formControl?.state);
|
|
1390
|
+
}
|
|
1306
1391
|
}, [formControl?.state]);
|
|
1307
1392
|
react.useEffect(() => resetCollection(collection, formControl?.state), [collection]);
|
|
1308
1393
|
function setFormState(value) {
|
|
1309
|
-
|
|
1310
|
-
|
|
1394
|
+
if (formControl) {
|
|
1395
|
+
changeInternal.current = true;
|
|
1396
|
+
formControl.setState(value);
|
|
1397
|
+
}
|
|
1311
1398
|
}
|
|
1312
1399
|
function resetCollection(collection, state) {
|
|
1313
|
-
|
|
1314
|
-
const element = collection.find(state);
|
|
1315
|
-
if (element) {
|
|
1316
|
-
setValue(element.description);
|
|
1317
|
-
}
|
|
1318
|
-
else {
|
|
1319
|
-
setValue('');
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
else {
|
|
1323
|
-
setValue('');
|
|
1324
|
-
}
|
|
1400
|
+
setValue(state ? collection.find(state)?.description || '' : '');
|
|
1325
1401
|
}
|
|
1326
1402
|
function resetState(state) {
|
|
1327
|
-
|
|
1403
|
+
resetCollection(collection, state);
|
|
1328
1404
|
}
|
|
1329
1405
|
function onClickControl() {
|
|
1330
1406
|
if (!disabled) {
|
|
@@ -1341,8 +1417,6 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1341
1417
|
function onKeydownInput(event) {
|
|
1342
1418
|
switch (event.code) {
|
|
1343
1419
|
case 'Escape':
|
|
1344
|
-
setVisible(false);
|
|
1345
|
-
break;
|
|
1346
1420
|
case 'Tab':
|
|
1347
1421
|
setVisible(false);
|
|
1348
1422
|
break;
|
|
@@ -1354,9 +1428,7 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1354
1428
|
function onClickAction() {
|
|
1355
1429
|
setVisible(false);
|
|
1356
1430
|
setValue('');
|
|
1357
|
-
|
|
1358
|
-
setFormState(undefined);
|
|
1359
|
-
}
|
|
1431
|
+
setFormState(undefined);
|
|
1360
1432
|
if (onValue) {
|
|
1361
1433
|
onValue(undefined);
|
|
1362
1434
|
}
|
|
@@ -1371,14 +1443,7 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1371
1443
|
}
|
|
1372
1444
|
function onKeydownElement(element) {
|
|
1373
1445
|
return (event) => {
|
|
1374
|
-
|
|
1375
|
-
case 'Enter':
|
|
1376
|
-
onChange(element);
|
|
1377
|
-
break;
|
|
1378
|
-
default:
|
|
1379
|
-
navigationElement(event);
|
|
1380
|
-
break;
|
|
1381
|
-
}
|
|
1446
|
+
event.code === 'Enter' ? onChange(element) : navigationElement(event);
|
|
1382
1447
|
};
|
|
1383
1448
|
}
|
|
1384
1449
|
function onChange({ description, value }) {
|
|
@@ -1387,9 +1452,7 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1387
1452
|
onSelect(value);
|
|
1388
1453
|
}
|
|
1389
1454
|
else {
|
|
1390
|
-
|
|
1391
|
-
setFormState(value);
|
|
1392
|
-
}
|
|
1455
|
+
setFormState(value);
|
|
1393
1456
|
setValue(description);
|
|
1394
1457
|
}
|
|
1395
1458
|
if (onValue) {
|
|
@@ -1397,47 +1460,14 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1397
1460
|
}
|
|
1398
1461
|
}
|
|
1399
1462
|
function filterSuggestions(pattern, reboot = false) {
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
previous: store
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
else {
|
|
1412
|
-
setCoincidences(suggestions.slice(0, MAX_ELEMENTS));
|
|
1413
|
-
rebootStore();
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
function searchForPattern(value) {
|
|
1417
|
-
if (!store.pattern) {
|
|
1418
|
-
return null;
|
|
1419
|
-
}
|
|
1420
|
-
let newStore = store;
|
|
1421
|
-
let search = false;
|
|
1422
|
-
while (!search && newStore) {
|
|
1423
|
-
search = helpersString.hasPattern(value, newStore.pattern, true);
|
|
1424
|
-
if (!search) {
|
|
1425
|
-
newStore = newStore.previous;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
return newStore || rebootStore();
|
|
1429
|
-
}
|
|
1430
|
-
function rebootStore() {
|
|
1431
|
-
const store = createStoreEmpty();
|
|
1432
|
-
setStore(store);
|
|
1433
|
-
return store;
|
|
1434
|
-
}
|
|
1435
|
-
function createStoreEmpty() {
|
|
1436
|
-
return {
|
|
1437
|
-
coincidences: undefined,
|
|
1438
|
-
pattern: '',
|
|
1439
|
-
previous: null
|
|
1440
|
-
};
|
|
1463
|
+
const result = createStoreAutocomplete({
|
|
1464
|
+
pattern,
|
|
1465
|
+
suggestions,
|
|
1466
|
+
reboot,
|
|
1467
|
+
store
|
|
1468
|
+
});
|
|
1469
|
+
setCoincidences(result.collection.slice(0, MAX_ELEMENTS));
|
|
1470
|
+
setStore(result.store);
|
|
1441
1471
|
}
|
|
1442
1472
|
return {
|
|
1443
1473
|
coincidences,
|
|
@@ -1475,7 +1505,7 @@ function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formCon
|
|
|
1475
1505
|
setPattern(value);
|
|
1476
1506
|
}, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntime.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
1477
1507
|
onSearch(pattern);
|
|
1478
|
-
}, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !coincidences.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntime.jsx("label", { className: "label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
|
|
1508
|
+
}, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !coincidences.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntime.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
|
|
1479
1509
|
}
|
|
1480
1510
|
function RlsAutocompleteField(props) {
|
|
1481
1511
|
return (jsxRuntime.jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
@@ -1566,6 +1596,12 @@ function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }
|
|
|
1566
1596
|
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("table", { children: [header && jsxRuntime.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntime.jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), summary && jsxRuntime.jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsxRuntime.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
|
|
1567
1597
|
}
|
|
1568
1598
|
|
|
1599
|
+
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
1600
|
+
const minFormat = helpersDate.dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
1601
|
+
const maxFormat = helpersDate.dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
1602
|
+
return `${minFormat} - ${maxFormat}`;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1569
1605
|
const controlIsValid = (props) => {
|
|
1570
1606
|
const { state, validators } = props;
|
|
1571
1607
|
return validators.reduce((errors, validator) => {
|
|
@@ -1662,74 +1698,47 @@ function useReactControl(controlProps, controlValidators) {
|
|
|
1662
1698
|
return useControl(controlProps, controlValidators);
|
|
1663
1699
|
}
|
|
1664
1700
|
|
|
1665
|
-
var PickerListenerType;
|
|
1666
|
-
(function (PickerListenerType) {
|
|
1667
|
-
PickerListenerType["Select"] = "PickerSelect";
|
|
1668
|
-
PickerListenerType["Now"] = "PickerNow";
|
|
1669
|
-
PickerListenerType["Cancel"] = "PickerCancel";
|
|
1670
|
-
})(PickerListenerType || (PickerListenerType = {}));
|
|
1671
|
-
|
|
1672
|
-
function verifyDateRange(date, min, max) {
|
|
1673
|
-
return min && helpersDate.before(min, date) ? min : max && helpersDate.after(max, date) ? max : date;
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
1701
|
const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
year: false
|
|
1681
|
-
};
|
|
1682
|
-
const VISIBILITY$1 = {
|
|
1683
|
-
DAY: {
|
|
1684
|
-
...VISIBILITY_STATE$1,
|
|
1685
|
-
day: true
|
|
1686
|
-
},
|
|
1687
|
-
MONTH: {
|
|
1688
|
-
...VISIBILITY_STATE$1,
|
|
1689
|
-
month: true
|
|
1690
|
-
},
|
|
1691
|
-
YEAR: {
|
|
1692
|
-
...VISIBILITY_STATE$1,
|
|
1693
|
-
year: true
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDate, rlsTheme, onListener }) {
|
|
1697
|
-
const dateInitial = formControl?.state || date || new Date();
|
|
1702
|
+
function RlsDatePicker({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
1703
|
+
const today = new Date(); // Initial current date in component
|
|
1704
|
+
const dateInitial = formControl?.state || date || today;
|
|
1698
1705
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
1699
1706
|
const dayControl = useReactControl(dateInitial.getDate());
|
|
1700
1707
|
const monthControl = useReactControl(dateInitial.getMonth());
|
|
1701
1708
|
const [value, setValue] = react.useState(dateInitial);
|
|
1702
|
-
const [
|
|
1703
|
-
const title = helpersDate.formatDate(value, FORMAT_DESCRIPTION);
|
|
1709
|
+
const [visibility, setVisibility] = react.useState('DAY');
|
|
1704
1710
|
react.useEffect(() => {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1711
|
+
const dateCheck = checkDateRange({
|
|
1712
|
+
date: formControl?.state || date || today,
|
|
1713
|
+
minDate,
|
|
1714
|
+
maxDate
|
|
1709
1715
|
});
|
|
1716
|
+
setValue(dateCheck);
|
|
1717
|
+
formControl?.setState(dateCheck);
|
|
1718
|
+
}, []);
|
|
1719
|
+
react.useEffect(() => {
|
|
1720
|
+
setValue((prevValue) => helpersAdvanced.itIsDefined(yearControl.state)
|
|
1721
|
+
? helpersDate.assignYearInDate(prevValue, yearControl.state)
|
|
1722
|
+
: prevValue);
|
|
1710
1723
|
}, [yearControl.state]);
|
|
1711
1724
|
react.useEffect(() => {
|
|
1712
|
-
setValue((prevValue) =>
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
: prevValue;
|
|
1716
|
-
});
|
|
1725
|
+
setValue((prevValue) => helpersAdvanced.itIsDefined(monthControl.state)
|
|
1726
|
+
? helpersDate.assignMonthInDate(prevValue, monthControl.state)
|
|
1727
|
+
: prevValue);
|
|
1717
1728
|
}, [monthControl.state]);
|
|
1718
1729
|
react.useEffect(() => {
|
|
1719
|
-
setValue((prevValue) =>
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
: prevValue;
|
|
1723
|
-
});
|
|
1730
|
+
setValue((prevValue) => helpersAdvanced.itIsDefined(dayControl.state)
|
|
1731
|
+
? helpersDate.assignDayInDate(prevValue, dayControl.state)
|
|
1732
|
+
: prevValue);
|
|
1724
1733
|
}, [dayControl.state]);
|
|
1725
1734
|
function onVisibilityDay() {
|
|
1726
|
-
setVisibility(
|
|
1735
|
+
setVisibility('DAY');
|
|
1727
1736
|
}
|
|
1728
1737
|
function onVisibilityMonth() {
|
|
1729
|
-
setVisibility(
|
|
1738
|
+
setVisibility('MONTH');
|
|
1730
1739
|
}
|
|
1731
1740
|
function onVisibilityYear() {
|
|
1732
|
-
setVisibility(
|
|
1741
|
+
setVisibility('YEAR');
|
|
1733
1742
|
}
|
|
1734
1743
|
function onCancel() {
|
|
1735
1744
|
if (onListener) {
|
|
@@ -1737,14 +1746,12 @@ function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDat
|
|
|
1737
1746
|
}
|
|
1738
1747
|
}
|
|
1739
1748
|
function onToday() {
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
dayControl.setState(value.getDate());
|
|
1745
|
-
monthControl.setState(value.getMonth());
|
|
1749
|
+
yearControl.setState(today.getFullYear());
|
|
1750
|
+
dayControl.setState(today.getDate());
|
|
1751
|
+
monthControl.setState(today.getMonth());
|
|
1752
|
+
formControl?.setState(today);
|
|
1746
1753
|
if (onListener) {
|
|
1747
|
-
onListener({ type: PickerListenerType.Now, value });
|
|
1754
|
+
onListener({ type: PickerListenerType.Now, value: today });
|
|
1748
1755
|
}
|
|
1749
1756
|
}
|
|
1750
1757
|
function onSelect() {
|
|
@@ -1753,27 +1760,38 @@ function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDat
|
|
|
1753
1760
|
onListener({ type: PickerListenerType.Select, value });
|
|
1754
1761
|
}
|
|
1755
1762
|
}
|
|
1756
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-date-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children:
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
}), children: [jsxRuntime.jsx(RlsDayPicker, { formControl: dayControl, date:
|
|
1763
|
+
return (jsxRuntime.jsxs("div", { className: "rls-date-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-date-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children: helpersDate.dateFormatTemplate(dateInitial, FORMAT_DESCRIPTION) }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--year", children: jsxRuntime.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntime.jsx(RlsMonthTitlePicker, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-date-picker__component', {
|
|
1764
|
+
day: visibility === 'DAY',
|
|
1765
|
+
month: visibility === 'MONTH',
|
|
1766
|
+
year: visibility === 'YEAR'
|
|
1767
|
+
}), children: [jsxRuntime.jsx(RlsDayPicker, { formControl: dayControl, date: dateInitial, month: monthControl.state, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, date: dateInitial, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, date: dateInitial, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-picker__footer', { automatic }), children: jsxRuntime.jsxs("div", { className: "rls-date-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--today", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onToday, disabled: dateOutRange({ date: today, maxDate, minDate }), children: reactI18n('dateActionToday') }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1761
1768
|
}
|
|
1762
1769
|
|
|
1763
1770
|
function RlsModal({ children, visible, rlsTheme }) {
|
|
1764
1771
|
return ReactDOM.createPortal(jsxRuntime.jsxs("div", { className: renderClassStatus('rls-modal', { visible }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntime.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
|
|
1765
1772
|
}
|
|
1766
1773
|
|
|
1767
|
-
function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, placeholder, rlsTheme
|
|
1768
|
-
const
|
|
1769
|
-
const [value, setValue] = react.useState(
|
|
1770
|
-
const [
|
|
1771
|
-
const
|
|
1774
|
+
function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, onValue, placeholder, rlsTheme }) {
|
|
1775
|
+
const today = new Date(); // Initial current date in component
|
|
1776
|
+
const [value, setValue] = react.useState();
|
|
1777
|
+
const [modalIsVisible, setModalIsVisible] = react.useState(false);
|
|
1778
|
+
const description = react.useRef('');
|
|
1779
|
+
react.useEffect(() => {
|
|
1780
|
+
const dateCheck = checkDateRange({
|
|
1781
|
+
date: formControl?.state || date || today,
|
|
1782
|
+
minDate,
|
|
1783
|
+
maxDate
|
|
1784
|
+
});
|
|
1785
|
+
setValue(dateCheck);
|
|
1786
|
+
formControl?.setState(dateCheck);
|
|
1787
|
+
}, []);
|
|
1772
1788
|
react.useEffect(() => {
|
|
1773
|
-
|
|
1789
|
+
description.current = value
|
|
1790
|
+
? helpersDate.dateFormatTemplate(value, DATE_RANGE_FORMAT)
|
|
1791
|
+
: '';
|
|
1774
1792
|
}, [value]);
|
|
1775
1793
|
function onClickInput() {
|
|
1776
|
-
|
|
1794
|
+
setModalIsVisible(true);
|
|
1777
1795
|
}
|
|
1778
1796
|
function onChange(value, ignoreControl = false) {
|
|
1779
1797
|
if (!ignoreControl) {
|
|
@@ -1792,40 +1810,21 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1792
1810
|
}
|
|
1793
1811
|
}
|
|
1794
1812
|
else {
|
|
1795
|
-
|
|
1813
|
+
setModalIsVisible(true);
|
|
1796
1814
|
}
|
|
1797
1815
|
}
|
|
1798
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: description, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClean, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }), jsxRuntime.jsx(RlsModal, { visible:
|
|
1816
|
+
return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: description.current, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClean, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }), jsxRuntime.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
1799
1817
|
if (type !== PickerListenerType.Cancel) {
|
|
1800
1818
|
onChange(value, true);
|
|
1801
1819
|
}
|
|
1802
|
-
|
|
1803
|
-
if (
|
|
1804
|
-
formControl
|
|
1820
|
+
setModalIsVisible(false);
|
|
1821
|
+
if (!formControl?.touched) {
|
|
1822
|
+
formControl?.touch();
|
|
1805
1823
|
}
|
|
1806
1824
|
} }) })] }));
|
|
1807
1825
|
}
|
|
1808
1826
|
|
|
1809
|
-
|
|
1810
|
-
month: false,
|
|
1811
|
-
day: false,
|
|
1812
|
-
year: false
|
|
1813
|
-
};
|
|
1814
|
-
const VISIBILITY = {
|
|
1815
|
-
DAY: {
|
|
1816
|
-
...VISIBILITY_STATE,
|
|
1817
|
-
day: true
|
|
1818
|
-
},
|
|
1819
|
-
MONTH: {
|
|
1820
|
-
...VISIBILITY_STATE,
|
|
1821
|
-
month: true
|
|
1822
|
-
},
|
|
1823
|
-
YEAR: {
|
|
1824
|
-
...VISIBILITY_STATE,
|
|
1825
|
-
year: true
|
|
1826
|
-
}
|
|
1827
|
-
};
|
|
1828
|
-
function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, rlsTheme, onListener }) {
|
|
1827
|
+
function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
1829
1828
|
const dateInitial = helpersDate.normalizeMinTime(datePicker || new Date());
|
|
1830
1829
|
const rangeInitial = formControl?.state || helpersDate.DateRange.now();
|
|
1831
1830
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
@@ -1833,18 +1832,18 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
|
|
|
1833
1832
|
const dayControl = useReactControl(rangeInitial);
|
|
1834
1833
|
const [value, setValue] = react.useState(rangeInitial);
|
|
1835
1834
|
const [date, setDate] = react.useState(dateInitial);
|
|
1836
|
-
const [
|
|
1835
|
+
const [visibility, setVisibility] = react.useState('DAY');
|
|
1837
1836
|
react.useEffect(() => {
|
|
1838
1837
|
setDate((prevValue) => {
|
|
1839
1838
|
return typeof yearControl.state === 'number'
|
|
1840
|
-
? helpersDate.
|
|
1839
|
+
? helpersDate.assignYearInDate(prevValue, yearControl.state)
|
|
1841
1840
|
: prevValue;
|
|
1842
1841
|
});
|
|
1843
1842
|
}, [yearControl.state]);
|
|
1844
1843
|
react.useEffect(() => {
|
|
1845
1844
|
setDate((prevValue) => {
|
|
1846
1845
|
return typeof monthControl.state === 'number'
|
|
1847
|
-
? helpersDate.
|
|
1846
|
+
? helpersDate.assignMonthInDate(prevValue, monthControl.state)
|
|
1848
1847
|
: prevValue;
|
|
1849
1848
|
});
|
|
1850
1849
|
}, [monthControl.state]);
|
|
@@ -1852,16 +1851,16 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
|
|
|
1852
1851
|
if (dayControl.state) {
|
|
1853
1852
|
setValue(dayControl.state);
|
|
1854
1853
|
}
|
|
1855
|
-
setVisibility(
|
|
1854
|
+
setVisibility('DAY');
|
|
1856
1855
|
}, [dayControl.state]);
|
|
1857
1856
|
function onVisibilityDay() {
|
|
1858
|
-
setVisibility(
|
|
1857
|
+
setVisibility('DAY');
|
|
1859
1858
|
}
|
|
1860
1859
|
function onVisibilityMonth() {
|
|
1861
|
-
setVisibility(
|
|
1860
|
+
setVisibility('MONTH');
|
|
1862
1861
|
}
|
|
1863
1862
|
function onVisibilityYear() {
|
|
1864
|
-
setVisibility(
|
|
1863
|
+
setVisibility('YEAR');
|
|
1865
1864
|
}
|
|
1866
1865
|
function onCancel() {
|
|
1867
1866
|
if (onListener) {
|
|
@@ -1874,11 +1873,11 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
|
|
|
1874
1873
|
onListener({ type: PickerListenerType.Select, value });
|
|
1875
1874
|
}
|
|
1876
1875
|
}
|
|
1877
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-range-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-date-range-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children:
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
}), children: [jsxRuntime.jsx(RlsDayRangePicker, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl,
|
|
1876
|
+
return (jsxRuntime.jsxs("div", { className: "rls-date-range-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-date-range-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsxRuntime.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--year", children: jsxRuntime.jsx("span", { onClick: onVisibilityYear, children: yearControl.state }) }), jsxRuntime.jsx(RlsMonthTitlePicker, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityMonth })] }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-date-range-picker__component', {
|
|
1877
|
+
day: visibility === 'DAY',
|
|
1878
|
+
month: visibility === 'MONTH',
|
|
1879
|
+
year: visibility === 'YEAR'
|
|
1880
|
+
}), children: [jsxRuntime.jsx(RlsDayRangePicker, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-range-picker__footer', {
|
|
1882
1881
|
automatic
|
|
1883
1882
|
}), children: jsxRuntime.jsxs("div", { className: "rls-date-range-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1884
1883
|
}
|
|
@@ -1889,9 +1888,9 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
|
|
|
1889
1888
|
const [value, setValue] = react.useState(rangeInitial);
|
|
1890
1889
|
const [date] = react.useState(dateInitial);
|
|
1891
1890
|
const [show, setShow] = react.useState(false);
|
|
1892
|
-
const
|
|
1891
|
+
const description = react.useRef('');
|
|
1893
1892
|
react.useEffect(() => {
|
|
1894
|
-
|
|
1893
|
+
description.current = value ? rangeFormatTemplate(value) : '';
|
|
1895
1894
|
}, [value]);
|
|
1896
1895
|
function onClickInput() {
|
|
1897
1896
|
setShow(true);
|
|
@@ -1905,7 +1904,7 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
|
|
|
1905
1904
|
setShow(true);
|
|
1906
1905
|
}
|
|
1907
1906
|
}
|
|
1908
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-box-field", children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: description, readOnly: true, placeholder: placeholder, onClick: onClickInput }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) })] }), jsxRuntime.jsx(RlsModal, { visible: show, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsDateRangePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
1907
|
+
return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-box-field", children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: description.current, readOnly: true, placeholder: placeholder, onClick: onClickInput }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) })] }), jsxRuntime.jsx(RlsModal, { visible: show, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsDateRangePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
1909
1908
|
if (value) {
|
|
1910
1909
|
setValue(value);
|
|
1911
1910
|
}
|
|
@@ -1920,31 +1919,27 @@ function RlsFormNavigation({ children, visible, rlsTheme }) {
|
|
|
1920
1919
|
function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
1921
1920
|
const listControl = useListControl({ suggestions, formControl });
|
|
1922
1921
|
const { collection, inputRef, visible, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
|
|
1923
|
-
const
|
|
1922
|
+
const changeInternal = react.useRef(false);
|
|
1924
1923
|
react.useEffect(() => {
|
|
1925
|
-
|
|
1924
|
+
if (changeInternal.current) {
|
|
1925
|
+
changeInternal.current = false;
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
resetState(formControl?.state);
|
|
1929
|
+
}
|
|
1926
1930
|
}, [formControl?.state]);
|
|
1927
1931
|
react.useEffect(() => resetCollection(collection, formControl?.state), [collection]);
|
|
1928
1932
|
function setFormState(value) {
|
|
1929
|
-
|
|
1930
|
-
|
|
1933
|
+
if (formControl) {
|
|
1934
|
+
changeInternal.current = true;
|
|
1935
|
+
formControl.setState(value);
|
|
1936
|
+
}
|
|
1931
1937
|
}
|
|
1932
1938
|
function resetCollection(collection, state) {
|
|
1933
|
-
|
|
1934
|
-
const element = collection.find(state);
|
|
1935
|
-
if (element) {
|
|
1936
|
-
setValue(element.description);
|
|
1937
|
-
}
|
|
1938
|
-
else {
|
|
1939
|
-
setValue('');
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
else {
|
|
1943
|
-
setValue('');
|
|
1944
|
-
}
|
|
1939
|
+
setValue(state ? collection.find(state)?.description || '' : '');
|
|
1945
1940
|
}
|
|
1946
1941
|
function resetState(state) {
|
|
1947
|
-
|
|
1942
|
+
resetCollection(collection, state);
|
|
1948
1943
|
}
|
|
1949
1944
|
function onFocusInput() {
|
|
1950
1945
|
setFocused(true);
|
|
@@ -1952,20 +1947,16 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
|
1952
1947
|
function onBlurInput() {
|
|
1953
1948
|
setFocused(false);
|
|
1954
1949
|
}
|
|
1955
|
-
function
|
|
1950
|
+
function onClickInput() {
|
|
1956
1951
|
setVisible(true);
|
|
1957
1952
|
}
|
|
1958
1953
|
function onKeydownInput(event) {
|
|
1959
1954
|
switch (event.code) {
|
|
1960
1955
|
case 'Space':
|
|
1961
|
-
setVisible(true);
|
|
1962
|
-
break;
|
|
1963
1956
|
case 'Enter':
|
|
1964
1957
|
setVisible(true);
|
|
1965
1958
|
break;
|
|
1966
1959
|
case 'Escape':
|
|
1967
|
-
setVisible(false);
|
|
1968
|
-
break;
|
|
1969
1960
|
case 'Tab':
|
|
1970
1961
|
setVisible(false);
|
|
1971
1962
|
break;
|
|
@@ -1991,14 +1982,7 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
|
1991
1982
|
}
|
|
1992
1983
|
function onKeydownElement(element) {
|
|
1993
1984
|
return (event) => {
|
|
1994
|
-
|
|
1995
|
-
case 'Enter':
|
|
1996
|
-
onChange(element);
|
|
1997
|
-
break;
|
|
1998
|
-
default:
|
|
1999
|
-
navigationElement(event);
|
|
2000
|
-
break;
|
|
2001
|
-
}
|
|
1985
|
+
event.code === 'Enter' ? onChange(element) : navigationElement(event);
|
|
2002
1986
|
};
|
|
2003
1987
|
}
|
|
2004
1988
|
function onChange({ description, value }) {
|
|
@@ -2008,9 +1992,7 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2008
1992
|
onSelect(value);
|
|
2009
1993
|
}
|
|
2010
1994
|
else {
|
|
2011
|
-
|
|
2012
|
-
setFormState(value);
|
|
2013
|
-
}
|
|
1995
|
+
setFormState(value);
|
|
2014
1996
|
setValue(description);
|
|
2015
1997
|
}
|
|
2016
1998
|
if (onValue) {
|
|
@@ -2022,7 +2004,7 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2022
2004
|
onBlurInput,
|
|
2023
2005
|
onClickAction,
|
|
2024
2006
|
onClickBackdrop,
|
|
2025
|
-
onClickInput
|
|
2007
|
+
onClickInput,
|
|
2026
2008
|
onClickElement,
|
|
2027
2009
|
onFocusInput,
|
|
2028
2010
|
onKeydownElement,
|
|
@@ -2044,7 +2026,7 @@ function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl,
|
|
|
2044
2026
|
visible: listControl.visible,
|
|
2045
2027
|
hide: !listControl.visible,
|
|
2046
2028
|
higher: listControl.higher
|
|
2047
|
-
}), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntime.jsx("label", { className: "label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
|
|
2029
|
+
}), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntime.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
|
|
2048
2030
|
}
|
|
2049
2031
|
function RlsSelectField(props) {
|
|
2050
2032
|
return (jsxRuntime.jsx(RlsSelectFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
@@ -2112,7 +2094,6 @@ function RlsApplication({ children }) {
|
|
|
2112
2094
|
}
|
|
2113
2095
|
|
|
2114
2096
|
exports.ConfirmationResult = ConfirmationResult;
|
|
2115
|
-
exports.ListCollection = ListCollection;
|
|
2116
2097
|
exports.RlsAmount = RlsAmount;
|
|
2117
2098
|
exports.RlsApplication = RlsApplication;
|
|
2118
2099
|
exports.RlsAutocompleteField = RlsAutocompleteField;
|
|
@@ -2123,6 +2104,7 @@ exports.RlsBallot = RlsBallot;
|
|
|
2123
2104
|
exports.RlsBreadcrumb = RlsBreadcrumb;
|
|
2124
2105
|
exports.RlsButton = RlsButton;
|
|
2125
2106
|
exports.RlsButtonAction = RlsButtonAction;
|
|
2107
|
+
exports.RlsButtonProgress = RlsButtonProgress;
|
|
2126
2108
|
exports.RlsButtonToggle = RlsButtonToggle;
|
|
2127
2109
|
exports.RlsCard = RlsCard;
|
|
2128
2110
|
exports.RlsCheckBox = RlsCheckBox;
|
|
@@ -2161,6 +2143,7 @@ exports.RlsPagination = RlsPagination;
|
|
|
2161
2143
|
exports.RlsPasswordField = RlsPasswordField;
|
|
2162
2144
|
exports.RlsPoster = RlsPoster;
|
|
2163
2145
|
exports.RlsProgressBar = RlsProgressBar;
|
|
2146
|
+
exports.RlsProgressCircular = RlsProgressCircular;
|
|
2164
2147
|
exports.RlsRadioButton = RlsRadioButton;
|
|
2165
2148
|
exports.RlsRadioButtonLabel = RlsRadioButtonLabel;
|
|
2166
2149
|
exports.RlsSearchInput = RlsSearchInput;
|
|
@@ -2176,6 +2159,7 @@ exports.RlsTabularText = RlsTabularText;
|
|
|
2176
2159
|
exports.RlsTextField = RlsTextField;
|
|
2177
2160
|
exports.RlsToolbar = RlsToolbar;
|
|
2178
2161
|
exports.RlsYearPicker = RlsYearPicker;
|
|
2162
|
+
exports.rangeFormatTemplate = rangeFormatTemplate;
|
|
2179
2163
|
exports.renderClassStatus = renderClassStatus;
|
|
2180
2164
|
exports.useConfirmationService = useConfirmationService;
|
|
2181
2165
|
exports.useDatatable = useDatatable;
|