@rolster/react-components 18.9.0 → 18.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +242 -137
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +240 -137
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Amount/Amount.d.ts +2 -2
- package/dist/esm/components/atoms/Amount/Amount.js.map +1 -1
- package/dist/esm/components/atoms/Avatar/Avatar.d.ts +2 -2
- package/dist/esm/components/atoms/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/esm/components/atoms/Button/Button.d.ts +2 -2
- package/dist/esm/components/atoms/Button/Button.js.map +1 -1
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.d.ts +2 -2
- package/dist/esm/components/atoms/ButtonAction/ButtonAction.js.map +1 -1
- package/dist/esm/components/atoms/CheckBox/CheckBox.d.ts +4 -4
- package/dist/esm/components/atoms/CheckBox/CheckBox.js.map +1 -1
- package/dist/esm/components/atoms/Icon/Icon.d.ts +2 -2
- package/dist/esm/components/atoms/Icon/Icon.js.map +1 -1
- package/dist/esm/components/atoms/Input/Input.d.ts +3 -3
- package/dist/esm/components/atoms/Input/Input.js +1 -1
- package/dist/esm/components/atoms/Input/Input.js.map +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.d.ts +3 -3
- package/dist/esm/components/atoms/InputMoney/InputMoney.js +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.d.ts +3 -3
- package/dist/esm/components/atoms/InputNumber/InputNumber.js +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.d.ts +3 -3
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
- package/dist/esm/components/atoms/InputText/InputText.d.ts +3 -3
- package/dist/esm/components/atoms/InputText/InputText.js +1 -1
- package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
- package/dist/esm/components/atoms/MessageIcon/MessageIcon.d.ts +2 -2
- package/dist/esm/components/atoms/MessageIcon/MessageIcon.js.map +1 -1
- package/dist/esm/components/atoms/ProgressBar/ProgressBar.d.ts +2 -2
- package/dist/esm/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/esm/components/atoms/RadioButton/RadioButton.d.ts +2 -2
- package/dist/esm/components/atoms/RadioButton/RadioButton.js +1 -1
- package/dist/esm/components/atoms/RadioButton/RadioButton.js.map +1 -1
- package/dist/esm/components/atoms/SearchInput/SearchInput.d.ts +2 -2
- package/dist/esm/components/atoms/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/atoms/SkeletonText/SkeletonText.d.ts +2 -2
- package/dist/esm/components/atoms/SkeletonText/SkeletonText.js.map +1 -1
- package/dist/esm/components/atoms/Switch/Switch.d.ts +4 -4
- package/dist/esm/components/atoms/Switch/Switch.js +1 -1
- package/dist/esm/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/esm/components/atoms/TabularText/TabularText.d.ts +2 -2
- package/dist/esm/components/atoms/TabularText/TabularText.js.map +1 -1
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.d.ts +2 -2
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
- package/dist/esm/components/molecules/CheckBoxLabel/CheckBoxLabel.d.ts +2 -2
- package/dist/esm/components/molecules/CheckBoxLabel/CheckBoxLabel.js.map +1 -1
- package/dist/esm/components/molecules/DayPicker/DayPicker.d.ts +3 -2
- package/dist/esm/components/molecules/DayPicker/DayPicker.js +4 -1
- package/dist/esm/components/molecules/DayPicker/DayPicker.js.map +1 -1
- package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.d.ts +2 -2
- package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.js.map +1 -1
- package/dist/esm/components/molecules/MoneyField/MoneyField.d.ts +3 -3
- package/dist/esm/components/molecules/MoneyField/MoneyField.js +1 -1
- package/dist/esm/components/molecules/MoneyField/MoneyField.js.map +1 -1
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.d.ts +3 -2
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.js +12 -4
- package/dist/esm/components/molecules/MonthPicker/MonthPicker.js.map +1 -1
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.d.ts +2 -2
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.js.map +1 -1
- package/dist/esm/components/molecules/NumberField/NumberField.d.ts +3 -3
- package/dist/esm/components/molecules/NumberField/NumberField.js +1 -1
- package/dist/esm/components/molecules/NumberField/NumberField.js.map +1 -1
- package/dist/esm/components/molecules/Pagination/Pagination.d.ts +2 -2
- package/dist/esm/components/molecules/Pagination/Pagination.js +30 -30
- package/dist/esm/components/molecules/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/molecules/RadioButtonLabel/RadioButtonLabel.d.ts +2 -2
- package/dist/esm/components/molecules/RadioButtonLabel/RadioButtonLabel.js.map +1 -1
- package/dist/esm/components/molecules/TextField/TextField.d.ts +3 -3
- package/dist/esm/components/molecules/TextField/TextField.js +1 -1
- package/dist/esm/components/molecules/TextField/TextField.js.map +1 -1
- package/dist/esm/components/molecules/Toolbar/Toolbar.d.ts +2 -2
- package/dist/esm/components/molecules/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/molecules/YearPicker/YearPicker.d.ts +3 -2
- package/dist/esm/components/molecules/YearPicker/YearPicker.js +5 -2
- package/dist/esm/components/molecules/YearPicker/YearPicker.js.map +1 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.d.ts +11 -6
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js +21 -157
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js.map +1 -1
- package/dist/esm/components/organisms/AutocompleteField/autocomplete-field.hook.d.ts +27 -0
- package/dist/esm/components/organisms/AutocompleteField/autocomplete-field.hook.js +170 -0
- package/dist/esm/components/organisms/AutocompleteField/autocomplete-field.hook.js.map +1 -0
- package/dist/esm/components/organisms/Card/Card.d.ts +2 -2
- package/dist/esm/components/organisms/Card/Card.js.map +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +5 -4
- package/dist/esm/components/organisms/Confirmation/Confirmation.js +2 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/Datatable/Datatable.d.ts +7 -7
- package/dist/esm/components/organisms/Datatable/Datatable.js.map +1 -1
- package/dist/esm/components/organisms/DateField/DateField.d.ts +3 -2
- package/dist/esm/components/organisms/DateField/DateField.js +15 -6
- package/dist/esm/components/organisms/DateField/DateField.js.map +1 -1
- package/dist/esm/components/organisms/DatePicker/DatePicker.d.ts +2 -2
- package/dist/esm/components/organisms/DatePicker/DatePicker.js +3 -2
- package/dist/esm/components/organisms/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.d.ts +2 -2
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.js.map +1 -1
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js +2 -1
- package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/esm/components/organisms/FormNavigation/FormNavigation.d.ts +2 -2
- package/dist/esm/components/organisms/FormNavigation/FormNavigation.js.map +1 -1
- package/dist/esm/components/organisms/Modal/Modal.d.ts +2 -2
- package/dist/esm/components/organisms/Modal/Modal.js.map +1 -1
- package/dist/esm/components/organisms/SelectField/SelectField.d.ts +11 -7
- package/dist/esm/components/organisms/SelectField/SelectField.js +20 -95
- package/dist/esm/components/organisms/SelectField/SelectField.js.map +1 -1
- package/dist/esm/components/organisms/SelectField/select-field.hook.d.ts +24 -0
- package/dist/esm/components/organisms/SelectField/select-field.hook.js +104 -0
- package/dist/esm/components/organisms/SelectField/select-field.hook.js.map +1 -0
- package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +4 -4
- package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
- package/dist/esm/context.d.ts +3 -3
- package/dist/esm/hooks/list-control.hook.d.ts +10 -10
- package/dist/esm/hooks/list-control.hook.js +15 -15
- package/dist/esm/hooks/list-control.hook.js.map +1 -1
- package/dist/esm/i18n.d.ts +18 -0
- package/dist/esm/i18n.js +23 -0
- package/dist/esm/i18n.js.map +1 -0
- package/dist/esm/models.d.ts +19 -8
- package/dist/esm/models.js +6 -6
- package/dist/esm/models.js.map +1 -1
- package/dist/esm/utils/date-range-picker.d.ts +2 -2
- package/dist/esm/utils/date-range-picker.js +3 -3
- package/dist/esm/utils/date-range-picker.js.map +1 -1
- package/dist/esm/utils/day-picker.d.ts +2 -2
- package/dist/esm/utils/day-picker.js +3 -3
- package/dist/esm/utils/day-picker.js.map +1 -1
- package/dist/esm/utils/month-picker.d.ts +2 -2
- package/dist/esm/utils/month-picker.js +15 -15
- package/dist/esm/utils/month-picker.js.map +1 -1
- package/dist/esm/utils/year-picker.d.ts +2 -2
- package/dist/esm/utils/year-picker.js +3 -3
- package/dist/esm/utils/year-picker.js.map +1 -1
- package/package.json +2 -1
package/dist/es/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useState, useRef, useEffect, createContext } from 'react';
|
|
|
3
3
|
import { currencyFormat, PartialSealed } from '@rolster/helpers-advanced';
|
|
4
4
|
import { daysFromMonth, weight, refactorDay, DAY_LABELS, normalizeMinTime, isBefore, formatDate, isAfter, timeDifference, isBetween, Month, MONTH_NAMES, refactorYear, refactorMonth } from '@rolster/helpers-date';
|
|
5
5
|
import { hasPattern } from '@rolster/helpers-string';
|
|
6
|
+
import { i18n } from '@rolster/i18n';
|
|
6
7
|
import ReactDOM from 'react-dom';
|
|
7
8
|
import 'uuid';
|
|
8
9
|
import { BehaviorSubject } from 'rxjs';
|
|
@@ -64,7 +65,7 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
|
64
65
|
}, rlsTheme: rlsTheme }));
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
function RlsInput({ children, disabled, formControl,
|
|
68
|
+
function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
|
|
68
69
|
const [focused, setFocused] = useState(false);
|
|
69
70
|
function onChange(event) {
|
|
70
71
|
switch (type) {
|
|
@@ -99,7 +100,7 @@ function RlsInput({ children, disabled, formControl, onValue, placeholder, type,
|
|
|
99
100
|
}), children: [jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type || 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.state || value || '' }), jsx("span", { className: "rls-input__value", children: children })] }));
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
function RlsInputMoney({ decimals, disabled, formControl,
|
|
103
|
+
function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value, onValue }) {
|
|
103
104
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
104
105
|
function onMoney(value) {
|
|
105
106
|
if (!formControl) {
|
|
@@ -112,7 +113,7 @@ function RlsInputMoney({ decimals, disabled, formControl, onValue, placeholder,
|
|
|
112
113
|
return (jsx("div", { className: "rls-input-money", children: jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onMoney, children: jsx(RlsAmount, { value: formControl?.state || value || valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
function RlsInputNumber({ disabled, formControl,
|
|
116
|
+
function RlsInputNumber({ disabled, formControl, placeholder, value, onValue }) {
|
|
116
117
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
117
118
|
function onNumber(value) {
|
|
118
119
|
if (!formControl) {
|
|
@@ -125,7 +126,7 @@ function RlsInputNumber({ disabled, formControl, onValue, placeholder, value })
|
|
|
125
126
|
return (jsx("div", { className: "rls-input-number", children: jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onNumber, children: formControl?.state || value || valueInput }) }));
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
function RlsInputPassword({ disabled, formControl,
|
|
129
|
+
function RlsInputPassword({ disabled, formControl, placeholder, type, onValue }) {
|
|
129
130
|
const [focused, setFocused] = useState(false);
|
|
130
131
|
function onChange(event) {
|
|
131
132
|
formControl?.setState(event.target.value);
|
|
@@ -150,7 +151,7 @@ function RlsInputPassword({ disabled, formControl, onValue, placeholder, type })
|
|
|
150
151
|
}), children: jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
function RlsInputText({ disabled, formControl,
|
|
154
|
+
function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
154
155
|
const [valueInput, setValueInput] = useState(value || '');
|
|
155
156
|
function onText(value) {
|
|
156
157
|
if (!formControl) {
|
|
@@ -179,7 +180,7 @@ function RlsProgressBar({ indeterminate, percentage, rlsTheme }) {
|
|
|
179
180
|
return (jsx("div", { className: renderClassStatus('rls-progress-bar', { indeterminate }), "rls-theme": rlsTheme, children: jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
function RlsRadioButton({ checked, disabled,
|
|
183
|
+
function RlsRadioButton({ checked, disabled, rlsTheme, onClick }) {
|
|
183
184
|
return (jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
184
185
|
}
|
|
185
186
|
|
|
@@ -195,7 +196,7 @@ function RlsSkeletonText({ active, children, rlsTheme }) {
|
|
|
195
196
|
return (jsx("div", { className: renderClassStatus('rls-skeleton-text', { active }), "rls-theme": rlsTheme, children: jsx("span", { className: "rls-skeleton-text__value", children: children }) }));
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
function RlsSwitch({ checked, disabled,
|
|
199
|
+
function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
|
|
199
200
|
return (jsx("div", { className: renderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxs("div", { className: "rls-switch__component", children: [jsx("div", { className: "rls-switch__component__element" }), jsx("div", { className: "rls-switch__component__bar" })] }) }));
|
|
200
201
|
}
|
|
201
202
|
function RlsSwitchControl({ formControl, disabled, rlsTheme }) {
|
|
@@ -262,7 +263,7 @@ function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme
|
|
|
262
263
|
}), "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 })] }));
|
|
263
264
|
}
|
|
264
265
|
|
|
265
|
-
|
|
266
|
+
class DayPickerFactory {
|
|
266
267
|
constructor(props) {
|
|
267
268
|
const { date, value, maxDate, minDate } = props;
|
|
268
269
|
this.value = value;
|
|
@@ -272,7 +273,7 @@ let Factory$2 = class Factory {
|
|
|
272
273
|
this.date.setDate(1);
|
|
273
274
|
}
|
|
274
275
|
static execute(props) {
|
|
275
|
-
const factory = new
|
|
276
|
+
const factory = new DayPickerFactory(props);
|
|
276
277
|
const firstWeek = factory.createFirstWeek();
|
|
277
278
|
const rightWeeks = factory.createRightWeeks();
|
|
278
279
|
return [firstWeek, ...rightWeeks];
|
|
@@ -340,12 +341,12 @@ let Factory$2 = class Factory {
|
|
|
340
341
|
? weight(refactorDay(this.date, day)) > weight(this.maxDate)
|
|
341
342
|
: false;
|
|
342
343
|
}
|
|
343
|
-
}
|
|
344
|
+
}
|
|
344
345
|
function createDayPicker(props) {
|
|
345
|
-
return
|
|
346
|
+
return DayPickerFactory.execute(props);
|
|
346
347
|
}
|
|
347
348
|
|
|
348
|
-
function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
349
|
+
function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme, onValue }) {
|
|
349
350
|
const initialDate = date || new Date();
|
|
350
351
|
const initialDay = formControl?.state || initialDate.getDate();
|
|
351
352
|
const [weeks, setWeeks] = useState([]);
|
|
@@ -366,6 +367,9 @@ function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, mi
|
|
|
366
367
|
function onChange(value) {
|
|
367
368
|
setValue(value);
|
|
368
369
|
formControl?.setState(value);
|
|
370
|
+
if (onValue) {
|
|
371
|
+
onValue(value);
|
|
372
|
+
}
|
|
369
373
|
}
|
|
370
374
|
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', {
|
|
371
375
|
disabled: disabled || disabledPicker,
|
|
@@ -378,13 +382,13 @@ function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, mi
|
|
|
378
382
|
}, children: jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
379
383
|
}
|
|
380
384
|
|
|
381
|
-
const
|
|
382
|
-
class
|
|
385
|
+
const DATE_FORMAT = '{dd}/{mm}/{aa}';
|
|
386
|
+
class ListCollection {
|
|
383
387
|
constructor(value) {
|
|
384
388
|
this.value = value;
|
|
385
389
|
}
|
|
386
|
-
|
|
387
|
-
return this.value.find((
|
|
390
|
+
find(element) {
|
|
391
|
+
return this.value.find((current) => current.compareTo(element));
|
|
388
392
|
}
|
|
389
393
|
}
|
|
390
394
|
class DateRange {
|
|
@@ -396,8 +400,8 @@ class DateRange {
|
|
|
396
400
|
else {
|
|
397
401
|
this.maxDate = normalizeMinTime(minDate);
|
|
398
402
|
}
|
|
399
|
-
const minFormat = formatDate(this.minDate,
|
|
400
|
-
const maxFormat = formatDate(this.maxDate,
|
|
403
|
+
const minFormat = formatDate(this.minDate, DATE_FORMAT);
|
|
404
|
+
const maxFormat = formatDate(this.maxDate, DATE_FORMAT);
|
|
401
405
|
this.description = `${minFormat} - ${maxFormat}`;
|
|
402
406
|
}
|
|
403
407
|
recalculate(date) {
|
|
@@ -418,7 +422,7 @@ class DateRange {
|
|
|
418
422
|
}
|
|
419
423
|
}
|
|
420
424
|
|
|
421
|
-
|
|
425
|
+
class DateRangePickerFactory {
|
|
422
426
|
constructor(props) {
|
|
423
427
|
const { date, range, maxDate, minDate } = props;
|
|
424
428
|
this.date = new Date(date.getTime());
|
|
@@ -428,7 +432,7 @@ let Factory$1 = class Factory {
|
|
|
428
432
|
this.date.setDate(1);
|
|
429
433
|
}
|
|
430
434
|
static execute(props) {
|
|
431
|
-
const factory = new
|
|
435
|
+
const factory = new DateRangePickerFactory(props);
|
|
432
436
|
const firstWeek = factory.createFirstWeek();
|
|
433
437
|
const rightWeeks = factory.createRightWeeks();
|
|
434
438
|
return [firstWeek, ...rightWeeks];
|
|
@@ -509,9 +513,9 @@ let Factory$1 = class Factory {
|
|
|
509
513
|
? weight(refactorDay(this.date, day)) > weight(this.maxDate)
|
|
510
514
|
: false;
|
|
511
515
|
}
|
|
512
|
-
}
|
|
516
|
+
}
|
|
513
517
|
function createRangePicker(props) {
|
|
514
|
-
return
|
|
518
|
+
return DateRangePickerFactory.execute(props);
|
|
515
519
|
}
|
|
516
520
|
|
|
517
521
|
function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
@@ -544,7 +548,7 @@ function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDat
|
|
|
544
548
|
}, children: jsx("span", { className: "rls-day-range-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
545
549
|
}
|
|
546
550
|
|
|
547
|
-
function RlsMoneyField({ children, decimals, disabled, formControl,
|
|
551
|
+
function RlsMoneyField({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
|
|
548
552
|
return (jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
549
553
|
focused: formControl?.focused,
|
|
550
554
|
error: formControl?.touched && !formControl?.valid,
|
|
@@ -554,7 +558,7 @@ function RlsMoneyField({ children, decimals, disabled, formControl, onValue, pla
|
|
|
554
558
|
|
|
555
559
|
const MONTH_MAX_VALUE = Month.January;
|
|
556
560
|
const MONTH_MIN_VALUE = Month.December;
|
|
557
|
-
class
|
|
561
|
+
class MonthPickerFactory {
|
|
558
562
|
constructor(props) {
|
|
559
563
|
const { date, value, maxDate, minDate } = props;
|
|
560
564
|
this.value = value;
|
|
@@ -563,20 +567,20 @@ class Factory {
|
|
|
563
567
|
this.minDate = minDate;
|
|
564
568
|
}
|
|
565
569
|
static execute(props) {
|
|
566
|
-
const factory = new
|
|
570
|
+
const factory = new MonthPickerFactory(props);
|
|
567
571
|
return [
|
|
568
|
-
factory.createMonth(
|
|
569
|
-
factory.createMonth(
|
|
570
|
-
factory.createMonth(
|
|
571
|
-
factory.createMonth(
|
|
572
|
-
factory.createMonth(
|
|
573
|
-
factory.createMonth(
|
|
574
|
-
factory.createMonth(
|
|
575
|
-
factory.createMonth(
|
|
576
|
-
factory.createMonth(
|
|
577
|
-
factory.createMonth(
|
|
578
|
-
factory.createMonth(
|
|
579
|
-
factory.createMonth(
|
|
572
|
+
factory.createMonth(Month.January),
|
|
573
|
+
factory.createMonth(Month.February),
|
|
574
|
+
factory.createMonth(Month.March),
|
|
575
|
+
factory.createMonth(Month.April),
|
|
576
|
+
factory.createMonth(Month.May),
|
|
577
|
+
factory.createMonth(Month.June),
|
|
578
|
+
factory.createMonth(Month.July),
|
|
579
|
+
factory.createMonth(Month.August),
|
|
580
|
+
factory.createMonth(Month.September),
|
|
581
|
+
factory.createMonth(Month.October),
|
|
582
|
+
factory.createMonth(Month.November),
|
|
583
|
+
factory.createMonth(Month.December)
|
|
580
584
|
];
|
|
581
585
|
}
|
|
582
586
|
createMonth(value) {
|
|
@@ -620,10 +624,10 @@ function isMaxLimitMonth(month, date, maxDate) {
|
|
|
620
624
|
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
621
625
|
}
|
|
622
626
|
function createMonthPicker(props) {
|
|
623
|
-
return
|
|
627
|
+
return MonthPickerFactory.execute(props);
|
|
624
628
|
}
|
|
625
629
|
|
|
626
|
-
function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme }) {
|
|
630
|
+
function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme, onValue }) {
|
|
627
631
|
const initialDate = date || new Date();
|
|
628
632
|
const initialMonth = formControl?.state || initialDate.getMonth();
|
|
629
633
|
const [months, setMonths] = useState([]);
|
|
@@ -636,12 +640,20 @@ function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate,
|
|
|
636
640
|
maxDate
|
|
637
641
|
}));
|
|
638
642
|
}, [value, date, minDate, maxDate]);
|
|
643
|
+
function onChange(value) {
|
|
644
|
+
formControl?.setState(value);
|
|
645
|
+
setValue(value);
|
|
646
|
+
if (onValue) {
|
|
647
|
+
onValue(value);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
639
650
|
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', {
|
|
640
651
|
disabled: disabled || disabledPicker || false,
|
|
641
652
|
selected
|
|
642
653
|
}), onClick: () => {
|
|
643
|
-
|
|
644
|
-
|
|
654
|
+
if (!disabled) {
|
|
655
|
+
onChange(value);
|
|
656
|
+
}
|
|
645
657
|
}, children: jsx("span", { className: "rls-month-picker__span", children: label }) }, index))) }));
|
|
646
658
|
}
|
|
647
659
|
|
|
@@ -682,7 +694,7 @@ function RlsMonthTitlePicker({ monthControl, yearControl, date, maxDate, minDate
|
|
|
682
694
|
return (jsxs("div", { className: "rls-month-title-picker", children: [jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPreviousMonth, disabled: limitMinMonth }), jsx("span", { onClick: onClick, children: monthName }), jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNextMonth, disabled: limitMaxMonth })] }));
|
|
683
695
|
}
|
|
684
696
|
|
|
685
|
-
function RlsNumberField({ children, disabled, formControl,
|
|
697
|
+
function RlsNumberField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
686
698
|
return (jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
687
699
|
focused: formControl?.focused,
|
|
688
700
|
error: formControl?.touched && !formControl?.valid,
|
|
@@ -732,7 +744,7 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
732
744
|
pagination.active = true;
|
|
733
745
|
setIndex(value);
|
|
734
746
|
setCurrentPagination(pagination);
|
|
735
|
-
refreshFromChanged(
|
|
747
|
+
refreshFromChanged(clonePage({ index: value }));
|
|
736
748
|
}
|
|
737
749
|
function goPagination(pagination) {
|
|
738
750
|
if (currentPagination) {
|
|
@@ -750,14 +762,14 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
750
762
|
else {
|
|
751
763
|
const prevIndex = value - MIN_NUMBER_PAGE;
|
|
752
764
|
if (prevIndex >= FIRST_PAGE) {
|
|
753
|
-
refreshFromChanged(
|
|
765
|
+
refreshFromChanged(clonePageFromIndex(prevIndex));
|
|
754
766
|
}
|
|
755
767
|
}
|
|
756
768
|
}
|
|
757
769
|
}
|
|
758
770
|
function goFirstPagination() {
|
|
759
771
|
if (collection.length) {
|
|
760
|
-
refreshFromChanged(
|
|
772
|
+
refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
|
|
761
773
|
}
|
|
762
774
|
}
|
|
763
775
|
function goNextPagination() {
|
|
@@ -770,14 +782,14 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
770
782
|
else {
|
|
771
783
|
const nextIndex = value + 1;
|
|
772
784
|
if (nextIndex <= maxPage) {
|
|
773
|
-
refreshFromChanged(
|
|
785
|
+
refreshFromChanged(clonePageFromIndex(nextIndex));
|
|
774
786
|
}
|
|
775
787
|
}
|
|
776
788
|
}
|
|
777
789
|
}
|
|
778
790
|
function goLastPagination() {
|
|
779
791
|
if (collection.length) {
|
|
780
|
-
refreshFromChanged(
|
|
792
|
+
refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
|
|
781
793
|
}
|
|
782
794
|
}
|
|
783
795
|
function createPageCollection(props) {
|
|
@@ -791,17 +803,11 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
791
803
|
}
|
|
792
804
|
function refreshFromElements(elements) {
|
|
793
805
|
elements.length
|
|
794
|
-
? refreshFromChanged(
|
|
806
|
+
? refreshFromChanged(refreshPage(elements, filter))
|
|
795
807
|
: rebootPagination();
|
|
796
808
|
}
|
|
797
809
|
function refreshFromFilter(filter) {
|
|
798
|
-
refreshFromChanged(
|
|
799
|
-
}
|
|
800
|
-
function createRefreshProps(elements, filter) {
|
|
801
|
-
const collection = refreshCollection(elements, filter);
|
|
802
|
-
const maxPage = refreshMaxPage(collection, count);
|
|
803
|
-
const index = refreshIndex(collection, maxPage);
|
|
804
|
-
return createPageProps({ collection, index, maxPage });
|
|
810
|
+
refreshFromChanged(refreshPage(elements, filter));
|
|
805
811
|
}
|
|
806
812
|
function refreshFromChanged(page) {
|
|
807
813
|
refreshPaginations(page);
|
|
@@ -829,13 +835,6 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
829
835
|
setIndex(newIndex);
|
|
830
836
|
return newIndex;
|
|
831
837
|
}
|
|
832
|
-
function rebootPagination() {
|
|
833
|
-
setCollection([]);
|
|
834
|
-
setMaxPage(0);
|
|
835
|
-
setIndex(0);
|
|
836
|
-
setPaginations([]);
|
|
837
|
-
onChangeElements([]);
|
|
838
|
-
}
|
|
839
838
|
function refreshDescription(page) {
|
|
840
839
|
const { collection, count, index } = page;
|
|
841
840
|
const totalCount = elements.length;
|
|
@@ -871,6 +870,23 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
871
870
|
}
|
|
872
871
|
setPaginations(paginations);
|
|
873
872
|
}
|
|
873
|
+
function clonePage(pagePartial) {
|
|
874
|
+
return {
|
|
875
|
+
collection: pagePartial.collection || collection,
|
|
876
|
+
index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
|
|
877
|
+
count: pagePartial.count || count,
|
|
878
|
+
maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
function clonePageFromIndex(index) {
|
|
882
|
+
return clonePage({ index });
|
|
883
|
+
}
|
|
884
|
+
function refreshPage(elements, filter) {
|
|
885
|
+
const collection = refreshCollection(elements, filter);
|
|
886
|
+
const maxPage = refreshMaxPage(collection, count);
|
|
887
|
+
const index = refreshIndex(collection, maxPage);
|
|
888
|
+
return clonePage({ collection, index, maxPage });
|
|
889
|
+
}
|
|
874
890
|
function createPagination(value, index) {
|
|
875
891
|
const active = value === index;
|
|
876
892
|
const pagination = {
|
|
@@ -883,16 +899,12 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
883
899
|
}
|
|
884
900
|
return pagination;
|
|
885
901
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
index: typeof props.index === 'number' ? props.index : index,
|
|
893
|
-
count: props.count || count,
|
|
894
|
-
maxPage: typeof props.maxPage === 'number' ? props.maxPage : maxPage
|
|
895
|
-
};
|
|
902
|
+
function rebootPagination() {
|
|
903
|
+
setCollection([]);
|
|
904
|
+
setMaxPage(0);
|
|
905
|
+
setIndex(0);
|
|
906
|
+
setPaginations([]);
|
|
907
|
+
onChangeElements([]);
|
|
896
908
|
}
|
|
897
909
|
return (jsxs("div", { className: "rls-pagination", children: [jsxs("div", { className: "rls-pagination__actions", children: [jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: firstPage, children: jsx(RlsIcon, { value: "arrowhead-left" }) }), jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: firstPage, children: jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsx("div", { className: "rls-pagination__pages", children: paginations.map((page, index) => {
|
|
898
910
|
return (jsx("div", { className: renderClassStatus('rls-pagination__page', {
|
|
@@ -947,7 +959,7 @@ function RlsSwitchLabel({ children, disabled, extended, formControl, rlsTheme })
|
|
|
947
959
|
return (jsxs("div", { className: renderClassStatus('rls-switch-label', { disabled, extended }), "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-switch-label__component", onClick: onToggle, children: jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsx("label", { className: "rls-switch-label__text", children: children })] }));
|
|
948
960
|
}
|
|
949
961
|
|
|
950
|
-
function RlsTextField({ children, disabled, formControl,
|
|
962
|
+
function RlsTextField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
951
963
|
return (jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
952
964
|
focused: formControl?.focused,
|
|
953
965
|
error: formControl?.touched && !formControl?.valid,
|
|
@@ -960,7 +972,7 @@ function RlsToolbar({ actions, children, subtitle }) {
|
|
|
960
972
|
}
|
|
961
973
|
|
|
962
974
|
const COUNT_YEAR_RANGE = 4;
|
|
963
|
-
class
|
|
975
|
+
class YearPickerFactory {
|
|
964
976
|
constructor(props) {
|
|
965
977
|
const { value, maxDate, minDate } = props;
|
|
966
978
|
this.value = value;
|
|
@@ -968,7 +980,7 @@ class FactoryYearPicker {
|
|
|
968
980
|
this.minDate = minDate;
|
|
969
981
|
}
|
|
970
982
|
static execute(props) {
|
|
971
|
-
const factory = new
|
|
983
|
+
const factory = new YearPickerFactory(props);
|
|
972
984
|
let year = props.year;
|
|
973
985
|
if (factory.minOverflowYear(year)) {
|
|
974
986
|
year = factory.minYear;
|
|
@@ -1039,10 +1051,10 @@ class FactoryYearPicker {
|
|
|
1039
1051
|
}
|
|
1040
1052
|
}
|
|
1041
1053
|
function createYearPicker(props) {
|
|
1042
|
-
return
|
|
1054
|
+
return YearPickerFactory.execute(props);
|
|
1043
1055
|
}
|
|
1044
1056
|
|
|
1045
|
-
function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxDate, minDate, rlsTheme }) {
|
|
1057
|
+
function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxDate, minDate, rlsTheme, onValue }) {
|
|
1046
1058
|
const initialDate = date || new Date();
|
|
1047
1059
|
const initialYear = formControl?.state || initialDate.getFullYear();
|
|
1048
1060
|
const [value, setValue] = useState(initialYear);
|
|
@@ -1071,17 +1083,41 @@ function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxD
|
|
|
1071
1083
|
formControl?.setState(value);
|
|
1072
1084
|
setYear(value);
|
|
1073
1085
|
setValue(value);
|
|
1086
|
+
if (onValue) {
|
|
1087
|
+
onValue(value);
|
|
1088
|
+
}
|
|
1074
1089
|
}
|
|
1075
1090
|
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("button", { disabled: !template.hasPrevious || disabledPicker, onClick: onClickPrev, children: jsx(RlsIcon, { value: "arrow-ios-left" }) }) }), jsx("div", { className: "rls-year-picker__title", children: jsxs("label", { className: "title1-bold", children: [template.minRange, " - ", template.maxRange] }) }), jsx("div", { className: "rls-year-picker__action rls-year-picker__action--next", children: jsx("button", { disabled: !template.hasNext || disabledPicker, onClick: onClickNext, children: jsx(RlsIcon, { value: "arrow-ios-right" }) }) })] }), jsx("div", { className: "rls-year-picker__component", children: template.years.map(({ value, disabled, selected }, index) => (jsx("div", { className: renderClassStatus('rls-year-picker__year', {
|
|
1076
1091
|
disabled: disabled || disabledPicker,
|
|
1077
1092
|
selected
|
|
1078
1093
|
}), onClick: () => {
|
|
1079
|
-
if (value) {
|
|
1094
|
+
if (value && !disabled) {
|
|
1080
1095
|
onChange(value);
|
|
1081
1096
|
}
|
|
1082
1097
|
}, children: jsx("span", { className: "rls-year-picker__year__span body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1083
1098
|
}
|
|
1084
1099
|
|
|
1100
|
+
const reactI18n = i18n({
|
|
1101
|
+
es: {
|
|
1102
|
+
confirmationActionApproved: 'Aceptar',
|
|
1103
|
+
dateActionCancel: 'Cancelar',
|
|
1104
|
+
dateActionSelect: 'Establecer',
|
|
1105
|
+
dateActionToday: 'Hoy',
|
|
1106
|
+
listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
|
|
1107
|
+
listEmptyTitle: 'Selección no disponible',
|
|
1108
|
+
listInputPlaceholder: 'Buscar...'
|
|
1109
|
+
},
|
|
1110
|
+
en: {
|
|
1111
|
+
confirmationActionApproved: 'Approved',
|
|
1112
|
+
dateActionCancel: 'Cancel',
|
|
1113
|
+
dateActionSelect: 'Select',
|
|
1114
|
+
dateActionToday: 'Today',
|
|
1115
|
+
listEmptyDescription: 'Sorry, there are currently no items in the list',
|
|
1116
|
+
listEmptyTitle: 'Selection not available',
|
|
1117
|
+
listInputPlaceholder: 'Search...'
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
|
|
1085
1121
|
const classElement = '.rls-list-field__element';
|
|
1086
1122
|
const MAX_POSITION_VISIBLE = 4;
|
|
1087
1123
|
const LIST_SIZE_REM = 16;
|
|
@@ -1089,16 +1125,16 @@ const ELEMENT_SIZE_REM = 4;
|
|
|
1089
1125
|
const BASE_SIZE_PX = 16;
|
|
1090
1126
|
const ELEMENT_SIZE_PX = BASE_SIZE_PX * ELEMENT_SIZE_REM;
|
|
1091
1127
|
const MAZ_LIST_SIZE_PX = BASE_SIZE_PX * LIST_SIZE_REM;
|
|
1092
|
-
function useListControl({ suggestions, formControl,
|
|
1128
|
+
function useListControl({ suggestions, formControl, withHigher = false }) {
|
|
1093
1129
|
const boxContentRef = useRef(null);
|
|
1094
1130
|
const listRef = useRef(null);
|
|
1095
1131
|
const inputRef = useRef(null);
|
|
1096
|
-
const [collection, setCollection] = useState(new
|
|
1097
|
-
const [active, setActive] = useState(false);
|
|
1098
|
-
const [visible, setVisible] = useState(false);
|
|
1099
|
-
const [opened, setOpened] = useState(false);
|
|
1132
|
+
const [collection, setCollection] = useState(new ListCollection([]));
|
|
1100
1133
|
const [value, setValue] = useState('');
|
|
1134
|
+
const [opened, setOpened] = useState(false);
|
|
1135
|
+
const [visible, setVisible] = useState(false);
|
|
1101
1136
|
const [higher, setHigher] = useState(false);
|
|
1137
|
+
const [focused, setFocused] = useState(false);
|
|
1102
1138
|
const [positionElement, setPositionElement] = useState(0);
|
|
1103
1139
|
const [listElements, setListElements] = useState(undefined);
|
|
1104
1140
|
useEffect(() => {
|
|
@@ -1122,7 +1158,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1122
1158
|
setLocationList();
|
|
1123
1159
|
}, [visible]);
|
|
1124
1160
|
useEffect(() => {
|
|
1125
|
-
setCollection(new
|
|
1161
|
+
setCollection(new ListCollection(suggestions));
|
|
1126
1162
|
}, [suggestions]);
|
|
1127
1163
|
function setLocationList() {
|
|
1128
1164
|
if (boxContentRef?.current) {
|
|
@@ -1140,7 +1176,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1140
1176
|
}
|
|
1141
1177
|
break;
|
|
1142
1178
|
case 'ArrowDown':
|
|
1143
|
-
if (visible && (
|
|
1179
|
+
if (visible && (withHigher || !higher)) {
|
|
1144
1180
|
navigationInputDown();
|
|
1145
1181
|
}
|
|
1146
1182
|
break;
|
|
@@ -1194,7 +1230,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1194
1230
|
setPositionElement(newPosition);
|
|
1195
1231
|
listElements?.item(newPosition).focus();
|
|
1196
1232
|
}
|
|
1197
|
-
else if (
|
|
1233
|
+
else if (withHigher || !higher) {
|
|
1198
1234
|
inputRef?.current?.focus();
|
|
1199
1235
|
}
|
|
1200
1236
|
}
|
|
@@ -1205,30 +1241,30 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1205
1241
|
setPositionElement(newPosition);
|
|
1206
1242
|
listElements?.item(newPosition).focus();
|
|
1207
1243
|
}
|
|
1208
|
-
else if (higher && !
|
|
1244
|
+
else if (higher && !withHigher) {
|
|
1209
1245
|
inputRef?.current?.focus();
|
|
1210
1246
|
}
|
|
1211
1247
|
}
|
|
1212
1248
|
return {
|
|
1213
|
-
active,
|
|
1214
1249
|
boxContentRef,
|
|
1215
1250
|
collection,
|
|
1251
|
+
focused,
|
|
1216
1252
|
higher,
|
|
1217
1253
|
inputRef,
|
|
1218
1254
|
listRef,
|
|
1255
|
+
value,
|
|
1256
|
+
visible,
|
|
1219
1257
|
navigationElement,
|
|
1220
1258
|
navigationInput,
|
|
1221
|
-
|
|
1259
|
+
setFocused,
|
|
1222
1260
|
setValue,
|
|
1223
|
-
setVisible
|
|
1224
|
-
value,
|
|
1225
|
-
visible
|
|
1261
|
+
setVisible
|
|
1226
1262
|
};
|
|
1227
1263
|
}
|
|
1228
1264
|
|
|
1229
1265
|
const DURATION_ANIMATION$1 = 240;
|
|
1230
1266
|
const MAX_ELEMENTS = 6;
|
|
1231
|
-
function
|
|
1267
|
+
function useAutocompleteField({ suggestions, disabled, formControl, onSelect, onValue }) {
|
|
1232
1268
|
const [pattern, setPattern] = useState('');
|
|
1233
1269
|
const [coincidences, setCoincidences] = useState([]);
|
|
1234
1270
|
const [store, setStore] = useState({
|
|
@@ -1236,7 +1272,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1236
1272
|
coincidences: [],
|
|
1237
1273
|
previous: null
|
|
1238
1274
|
});
|
|
1239
|
-
const
|
|
1275
|
+
const listControl = useListControl({
|
|
1276
|
+
suggestions,
|
|
1277
|
+
formControl,
|
|
1278
|
+
withHigher: true
|
|
1279
|
+
});
|
|
1280
|
+
const { collection, inputRef, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
|
|
1240
1281
|
const [changeInternal, setChangeInternal] = useState(false);
|
|
1241
1282
|
useEffect(() => {
|
|
1242
1283
|
filterSuggestions(pattern, true);
|
|
@@ -1254,7 +1295,7 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1254
1295
|
redefineDescription();
|
|
1255
1296
|
}, [collection]);
|
|
1256
1297
|
function redefineDescription() {
|
|
1257
|
-
const element = formControl?.state && collection.
|
|
1298
|
+
const element = formControl?.state && collection.find(formControl?.state);
|
|
1258
1299
|
setValue(element?.description || '');
|
|
1259
1300
|
}
|
|
1260
1301
|
function onClickControl() {
|
|
@@ -1264,10 +1305,10 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1264
1305
|
}
|
|
1265
1306
|
}
|
|
1266
1307
|
function onFocusInput() {
|
|
1267
|
-
|
|
1308
|
+
setFocused(true);
|
|
1268
1309
|
}
|
|
1269
1310
|
function onBlurInput() {
|
|
1270
|
-
|
|
1311
|
+
setFocused(false);
|
|
1271
1312
|
}
|
|
1272
1313
|
function onKeydownInput(event) {
|
|
1273
1314
|
switch (event.code) {
|
|
@@ -1296,12 +1337,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1296
1337
|
function onClickBackdrop() {
|
|
1297
1338
|
setVisible(false);
|
|
1298
1339
|
}
|
|
1299
|
-
function
|
|
1340
|
+
function onClickElement(element) {
|
|
1300
1341
|
return () => {
|
|
1301
1342
|
onChange(element);
|
|
1302
1343
|
};
|
|
1303
1344
|
}
|
|
1304
|
-
function
|
|
1345
|
+
function onKeydownElement(element) {
|
|
1305
1346
|
return (event) => {
|
|
1306
1347
|
switch (event.code) {
|
|
1307
1348
|
case 'Enter':
|
|
@@ -1332,8 +1373,8 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1332
1373
|
function filterSuggestions(pattern, reboot = false) {
|
|
1333
1374
|
if (pattern) {
|
|
1334
1375
|
const store = reboot ? createStoreEmpty() : searchForPattern(pattern);
|
|
1335
|
-
const
|
|
1336
|
-
const coincidences =
|
|
1376
|
+
const elements = store?.coincidences || suggestions;
|
|
1377
|
+
const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
|
|
1337
1378
|
setCoincidences(coincidences.slice(0, MAX_ELEMENTS));
|
|
1338
1379
|
setStore({
|
|
1339
1380
|
coincidences,
|
|
@@ -1361,9 +1402,9 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1361
1402
|
return newStore || rebootStore();
|
|
1362
1403
|
}
|
|
1363
1404
|
function rebootStore() {
|
|
1364
|
-
const
|
|
1365
|
-
setStore(
|
|
1366
|
-
return
|
|
1405
|
+
const store = createStoreEmpty();
|
|
1406
|
+
setStore(store);
|
|
1407
|
+
return store;
|
|
1367
1408
|
}
|
|
1368
1409
|
function createStoreEmpty() {
|
|
1369
1410
|
return {
|
|
@@ -1372,19 +1413,46 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1372
1413
|
previous: null
|
|
1373
1414
|
};
|
|
1374
1415
|
}
|
|
1375
|
-
return
|
|
1416
|
+
return {
|
|
1417
|
+
coincidences,
|
|
1418
|
+
listControl,
|
|
1419
|
+
pattern,
|
|
1420
|
+
onBlurInput,
|
|
1421
|
+
onClickAction,
|
|
1422
|
+
onClickBackdrop,
|
|
1423
|
+
onClickControl,
|
|
1424
|
+
onClickElement,
|
|
1425
|
+
onFocusInput,
|
|
1426
|
+
onKeydownElement,
|
|
1427
|
+
onKeydownInput,
|
|
1428
|
+
setPattern
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
|
|
1433
|
+
const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useAutocompleteField({
|
|
1434
|
+
suggestions,
|
|
1435
|
+
disabled,
|
|
1436
|
+
formControl,
|
|
1437
|
+
onSelect,
|
|
1438
|
+
onValue
|
|
1439
|
+
});
|
|
1440
|
+
return (jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', {
|
|
1376
1441
|
disabled,
|
|
1377
|
-
|
|
1378
|
-
selected: !!value
|
|
1379
|
-
}, 'rls-autocomplete-field rls-list-field'), "rls-theme": rlsTheme, 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("label", { className: "rls-list-field__control", onClick: onClickControl, children: value ? (jsx("span", { className: "rls-list-field__control__description", children: value })) : (jsx("span", { className: "rls-list-field__control__placeholder", children: placeholder })) }), !hiddenIcon && value && (jsx("button", { className: "rls-list-field__action", disabled: disabled, onClick: onClickAction, children: jsx(RlsIcon, { value: "trash-2" }) }))] }) }), formControl?.touched && formControl?.error && (jsx("div", { className: "rls-box-field__error", children: jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
|
|
1380
|
-
visible,
|
|
1381
|
-
hide: !visible,
|
|
1382
|
-
higher
|
|
1383
|
-
}), children: [jsx("div", { className: "rls-list-field__suggestions__body", children: jsxs("ul", { ref: listRef, className: "rls-list-field__ul", children: [jsxs("div", { className: "rls-list-field__ul__search", children: [jsx("input", { ref: inputRef, className: "rls-list-field__ul__control", type: "text", value: pattern, onChange: ({ target: { value } }) => {
|
|
1442
|
+
focused: listControl.focused,
|
|
1443
|
+
selected: !!listControl.value
|
|
1444
|
+
}, 'rls-autocomplete-field rls-list-field'), "rls-theme": rlsTheme, 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("label", { className: "rls-list-field__control", onClick: onClickControl, children: listControl.value ? (jsx("span", { className: "rls-list-field__control__description", children: listControl.value })) : (jsx("span", { className: "rls-list-field__control__placeholder", children: placeholder })) }), !hiddenIcon && listControl.value && (jsx("button", { className: "rls-list-field__action", disabled: disabled, onClick: onClickAction, children: jsx(RlsIcon, { value: "trash-2" }) }))] }) }), formControl?.touched && formControl?.error && (jsx("div", { className: "rls-box-field__error", children: jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
|
|
1445
|
+
visible: listControl.visible,
|
|
1446
|
+
hide: !listControl.visible,
|
|
1447
|
+
higher: listControl.higher
|
|
1448
|
+
}), children: [jsx("div", { className: "rls-list-field__suggestions__body", children: jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [jsxs("div", { className: "rls-list-field__ul__search", children: [jsx("input", { ref: listControl.inputRef, className: "rls-list-field__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: pattern, onChange: ({ target: { value } }) => {
|
|
1384
1449
|
setPattern(value);
|
|
1385
1450
|
}, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
1386
1451
|
onSearch(pattern);
|
|
1387
|
-
}, children: jsx(RlsIcon, { value: "search" }) }))] }), searching && jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick:
|
|
1452
|
+
}, 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 })] })] }));
|
|
1453
|
+
}
|
|
1454
|
+
function RlsAutocompleteField(props) {
|
|
1455
|
+
return (jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
1388
1456
|
}
|
|
1389
1457
|
|
|
1390
1458
|
function RlsCard({ children, outline, rlsTheme }) {
|
|
@@ -1423,7 +1491,7 @@ function useConfirmationService() {
|
|
|
1423
1491
|
subtitle,
|
|
1424
1492
|
title,
|
|
1425
1493
|
approved: {
|
|
1426
|
-
label: approved || '
|
|
1494
|
+
label: approved || reactI18n('confirmationActionApproved'),
|
|
1427
1495
|
onClick: () => {
|
|
1428
1496
|
setVisible(false);
|
|
1429
1497
|
resolve(ConfirmationResult.approved());
|
|
@@ -1590,7 +1658,7 @@ const VISIBILITY$1 = {
|
|
|
1590
1658
|
year: true
|
|
1591
1659
|
}
|
|
1592
1660
|
};
|
|
1593
|
-
function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDate,
|
|
1661
|
+
function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDate, rlsTheme, onListener }) {
|
|
1594
1662
|
const dateInitial = formControl?.state || date || new Date();
|
|
1595
1663
|
const yearControl = useReactControl({ state: dateInitial.getFullYear() });
|
|
1596
1664
|
const dayControl = useReactControl({ state: dateInitial.getDate() });
|
|
@@ -1656,14 +1724,14 @@ function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDat
|
|
|
1656
1724
|
year,
|
|
1657
1725
|
day,
|
|
1658
1726
|
month
|
|
1659
|
-
}), children: [jsx(RlsDayPicker, { formControl: dayControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsMonthPicker, { formControl: monthControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsYearPicker, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), 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:
|
|
1727
|
+
}), children: [jsx(RlsDayPicker, { formControl: dayControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsMonthPicker, { formControl: monthControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsYearPicker, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), 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, children: reactI18n('dateActionToday') }) }), jsx("div", { className: "rls-date-picker__actions--ok", children: jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1660
1728
|
}
|
|
1661
1729
|
|
|
1662
1730
|
function RlsModal({ children, visible, rlsTheme }) {
|
|
1663
1731
|
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);
|
|
1664
1732
|
}
|
|
1665
1733
|
|
|
1666
|
-
function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
1734
|
+
function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, placeholder, rlsTheme, onValue }) {
|
|
1667
1735
|
const dateInitial = formControl?.state || date || new Date();
|
|
1668
1736
|
const [value, setValue] = useState(dateInitial);
|
|
1669
1737
|
const [show, setShow] = useState(false);
|
|
@@ -1674,10 +1742,18 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1674
1742
|
function onClickInput() {
|
|
1675
1743
|
setShow(true);
|
|
1676
1744
|
}
|
|
1745
|
+
function onChange(value, ignoreControl = false) {
|
|
1746
|
+
if (!ignoreControl) {
|
|
1747
|
+
formControl?.setState(undefined);
|
|
1748
|
+
}
|
|
1749
|
+
setValue(undefined);
|
|
1750
|
+
if (onValue) {
|
|
1751
|
+
onValue(value);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1677
1754
|
function onClean() {
|
|
1678
1755
|
if (value) {
|
|
1679
|
-
|
|
1680
|
-
setValue(undefined);
|
|
1756
|
+
onChange(undefined);
|
|
1681
1757
|
if (formControl && !formControl.touched) {
|
|
1682
1758
|
formControl.touch();
|
|
1683
1759
|
}
|
|
@@ -1686,9 +1762,9 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1686
1762
|
setShow(true);
|
|
1687
1763
|
}
|
|
1688
1764
|
}
|
|
1689
|
-
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: show, children: jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
1690
|
-
if (
|
|
1691
|
-
|
|
1765
|
+
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: show, children: jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
1766
|
+
if (type !== PickerListenerType.Cancel) {
|
|
1767
|
+
onChange(value, true);
|
|
1692
1768
|
}
|
|
1693
1769
|
setShow(false);
|
|
1694
1770
|
if (formControl && !formControl.touched) {
|
|
@@ -1773,7 +1849,7 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
|
|
|
1773
1849
|
month
|
|
1774
1850
|
}), children: [jsx(RlsDayRangePicker, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsMonthPicker, { formControl: monthControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsYearPicker, { formControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), jsx("div", { className: renderClassStatus('rls-date-range-picker__footer', {
|
|
1775
1851
|
automatic
|
|
1776
|
-
}), 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:
|
|
1852
|
+
}), 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') }) })] }) })] }));
|
|
1777
1853
|
}
|
|
1778
1854
|
|
|
1779
1855
|
function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
@@ -1810,8 +1886,9 @@ function RlsFormNavigation({ children, visible, rlsTheme }) {
|
|
|
1810
1886
|
return (jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsx("div", { className: "rls-form-navigation__body", children: children }) }));
|
|
1811
1887
|
}
|
|
1812
1888
|
|
|
1813
|
-
function
|
|
1814
|
-
const
|
|
1889
|
+
function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
1890
|
+
const listControl = useListControl({ suggestions, formControl });
|
|
1891
|
+
const { collection, inputRef, visible, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
|
|
1815
1892
|
const [changeInternal, setChangeInternal] = useState(false);
|
|
1816
1893
|
useEffect(() => {
|
|
1817
1894
|
if (!changeInternal) {
|
|
@@ -1823,16 +1900,16 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
|
|
|
1823
1900
|
redefineDescription();
|
|
1824
1901
|
}, [collection]);
|
|
1825
1902
|
function redefineDescription() {
|
|
1826
|
-
const element = formControl?.state && collection.
|
|
1903
|
+
const element = formControl?.state && collection.find(formControl?.state);
|
|
1827
1904
|
setValue(element?.description || '');
|
|
1828
1905
|
}
|
|
1829
1906
|
function onFocusInput() {
|
|
1830
|
-
|
|
1907
|
+
setFocused(true);
|
|
1831
1908
|
}
|
|
1832
1909
|
function onBlurInput() {
|
|
1833
|
-
|
|
1910
|
+
setFocused(false);
|
|
1834
1911
|
}
|
|
1835
|
-
function
|
|
1912
|
+
function onClickControl() {
|
|
1836
1913
|
setVisible(true);
|
|
1837
1914
|
}
|
|
1838
1915
|
function onKeydownInput(event) {
|
|
@@ -1864,12 +1941,12 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
|
|
|
1864
1941
|
function onClickBackdrop() {
|
|
1865
1942
|
setVisible(false);
|
|
1866
1943
|
}
|
|
1867
|
-
function
|
|
1944
|
+
function onClickElement(element) {
|
|
1868
1945
|
return () => {
|
|
1869
1946
|
onChange(element);
|
|
1870
1947
|
};
|
|
1871
1948
|
}
|
|
1872
|
-
function
|
|
1949
|
+
function onKeydownElement(element) {
|
|
1873
1950
|
return (event) => {
|
|
1874
1951
|
switch (event.code) {
|
|
1875
1952
|
case 'Enter':
|
|
@@ -1898,11 +1975,37 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
|
|
|
1898
1975
|
onValue(value);
|
|
1899
1976
|
}
|
|
1900
1977
|
}
|
|
1901
|
-
return
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1978
|
+
return {
|
|
1979
|
+
listControl,
|
|
1980
|
+
onBlurInput,
|
|
1981
|
+
onClickAction,
|
|
1982
|
+
onClickBackdrop,
|
|
1983
|
+
onClickInput: onClickControl,
|
|
1984
|
+
onClickElement,
|
|
1985
|
+
onFocusInput,
|
|
1986
|
+
onKeydownElement,
|
|
1987
|
+
onKeydownInput
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
|
|
1992
|
+
const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useSelectField({
|
|
1993
|
+
suggestions,
|
|
1994
|
+
disabled,
|
|
1995
|
+
formControl,
|
|
1996
|
+
onSelect,
|
|
1997
|
+
onValue
|
|
1998
|
+
});
|
|
1999
|
+
return (jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', { focused: listControl.focused, disabled }, 'rls-select-field rls-list-field'), "rls-theme": rlsTheme, 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", { ref: listControl.inputRef, className: "rls-list-field__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: listControl.value, onFocus: onFocusInput, onBlur: onBlurInput, onClick: onClickInput, onKeyDown: onKeydownInput }), jsx("button", { className: renderClassStatus('rls-list-field__action', {
|
|
2000
|
+
visible: listControl.visible
|
|
2001
|
+
}), disabled: disabled, onClick: onClickAction, children: jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), formControl?.touched && formControl?.error && (jsx("div", { className: "rls-box-field__error", children: jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
|
|
2002
|
+
visible: listControl.visible,
|
|
2003
|
+
hide: !listControl.visible,
|
|
2004
|
+
higher: listControl.higher
|
|
2005
|
+
}), 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 })] })] }));
|
|
2006
|
+
}
|
|
2007
|
+
function RlsSelectField(props) {
|
|
2008
|
+
return (jsx(RlsSelectFieldTemplate, { ...props, render: (element) => (jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
1906
2009
|
}
|
|
1907
2010
|
|
|
1908
2011
|
const DURATION_ANIMATION = 240;
|
|
@@ -1966,5 +2069,5 @@ function RlsApplication({ children }) {
|
|
|
1966
2069
|
return (jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
|
|
1967
2070
|
}
|
|
1968
2071
|
|
|
1969
|
-
export { ConfirmationResult, DateRange,
|
|
2072
|
+
export { ConfirmationResult, DateRange, ListCollection, RlsAmount, RlsApplication, RlsAutocompleteField, RlsAutocompleteFieldTemplate, RlsAvatar, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsCheckBoxLabel, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableTitle, RlsDateField, RlsDatePicker, RlsDateRangeField, RlsDateRangePicker, RlsDayPicker, RlsDayRangePicker, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputText, RlsLabel, RlsMessageIcon, RlsModal, RlsMoneyField, RlsMonthPicker, RlsMonthTitlePicker, RlsNumberField, RlsPagination, RlsPasswordField, RlsPoster, RlsProgressBar, RlsRadioButton, RlsRadioButtonLabel, RlsSearchInput, RlsSelectField, RlsSelectFieldTemplate, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsSwitchLabel, RlsTabularText, RlsTextField, RlsToolbar, RlsYearPicker, renderClassStatus, useConfirmationService, useListControl, useSnackbarService };
|
|
1970
2073
|
//# sourceMappingURL=index.js.map
|