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