@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/cjs/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var react = require('react');
|
|
|
5
5
|
var helpersAdvanced = require('@rolster/helpers-advanced');
|
|
6
6
|
var helpersDate = require('@rolster/helpers-date');
|
|
7
7
|
var helpersString = require('@rolster/helpers-string');
|
|
8
|
+
var i18n = require('@rolster/i18n');
|
|
8
9
|
var ReactDOM = require('react-dom');
|
|
9
10
|
require('uuid');
|
|
10
11
|
var rxjs = require('rxjs');
|
|
@@ -66,7 +67,7 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
|
66
67
|
}, rlsTheme: rlsTheme }));
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
function RlsInput({ children, disabled, formControl,
|
|
70
|
+
function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
|
|
70
71
|
const [focused, setFocused] = react.useState(false);
|
|
71
72
|
function onChange(event) {
|
|
72
73
|
switch (type) {
|
|
@@ -101,7 +102,7 @@ function RlsInput({ children, disabled, formControl, onValue, placeholder, type,
|
|
|
101
102
|
}), children: [jsxRuntime.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 || '' }), jsxRuntime.jsx("span", { className: "rls-input__value", children: children })] }));
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
function RlsInputMoney({ decimals, disabled, formControl,
|
|
105
|
+
function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value, onValue }) {
|
|
105
106
|
const [valueInput, setValueInput] = react.useState(value || 0);
|
|
106
107
|
function onMoney(value) {
|
|
107
108
|
if (!formControl) {
|
|
@@ -114,7 +115,7 @@ function RlsInputMoney({ decimals, disabled, formControl, onValue, placeholder,
|
|
|
114
115
|
return (jsxRuntime.jsx("div", { className: "rls-input-money", children: jsxRuntime.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onMoney, children: jsxRuntime.jsx(RlsAmount, { value: formControl?.state || value || valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
function RlsInputNumber({ disabled, formControl,
|
|
118
|
+
function RlsInputNumber({ disabled, formControl, placeholder, value, onValue }) {
|
|
118
119
|
const [valueInput, setValueInput] = react.useState(value || 0);
|
|
119
120
|
function onNumber(value) {
|
|
120
121
|
if (!formControl) {
|
|
@@ -127,7 +128,7 @@ function RlsInputNumber({ disabled, formControl, onValue, placeholder, value })
|
|
|
127
128
|
return (jsxRuntime.jsx("div", { className: "rls-input-number", children: jsxRuntime.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onNumber, children: formControl?.state || value || valueInput }) }));
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
function RlsInputPassword({ disabled, formControl,
|
|
131
|
+
function RlsInputPassword({ disabled, formControl, placeholder, type, onValue }) {
|
|
131
132
|
const [focused, setFocused] = react.useState(false);
|
|
132
133
|
function onChange(event) {
|
|
133
134
|
formControl?.setState(event.target.value);
|
|
@@ -152,7 +153,7 @@ function RlsInputPassword({ disabled, formControl, onValue, placeholder, type })
|
|
|
152
153
|
}), children: jsxRuntime.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
function RlsInputText({ disabled, formControl,
|
|
156
|
+
function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
156
157
|
const [valueInput, setValueInput] = react.useState(value || '');
|
|
157
158
|
function onText(value) {
|
|
158
159
|
if (!formControl) {
|
|
@@ -181,7 +182,7 @@ function RlsProgressBar({ indeterminate, percentage, rlsTheme }) {
|
|
|
181
182
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-progress-bar', { indeterminate }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
function RlsRadioButton({ checked, disabled,
|
|
185
|
+
function RlsRadioButton({ checked, disabled, rlsTheme, onClick }) {
|
|
185
186
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
186
187
|
}
|
|
187
188
|
|
|
@@ -197,7 +198,7 @@ function RlsSkeletonText({ active, children, rlsTheme }) {
|
|
|
197
198
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-skeleton-text', { active }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("span", { className: "rls-skeleton-text__value", children: children }) }));
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
function RlsSwitch({ checked, disabled,
|
|
201
|
+
function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
|
|
201
202
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntime.jsxs("div", { className: "rls-switch__component", children: [jsxRuntime.jsx("div", { className: "rls-switch__component__element" }), jsxRuntime.jsx("div", { className: "rls-switch__component__bar" })] }) }));
|
|
202
203
|
}
|
|
203
204
|
function RlsSwitchControl({ formControl, disabled, rlsTheme }) {
|
|
@@ -264,7 +265,7 @@ function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme
|
|
|
264
265
|
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-checkbox-label__component", onClick: onToggle, children: jsxRuntime.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-checkbox-label__text", children: children })] }));
|
|
265
266
|
}
|
|
266
267
|
|
|
267
|
-
|
|
268
|
+
class DayPickerFactory {
|
|
268
269
|
constructor(props) {
|
|
269
270
|
const { date, value, maxDate, minDate } = props;
|
|
270
271
|
this.value = value;
|
|
@@ -274,7 +275,7 @@ let Factory$2 = class Factory {
|
|
|
274
275
|
this.date.setDate(1);
|
|
275
276
|
}
|
|
276
277
|
static execute(props) {
|
|
277
|
-
const factory = new
|
|
278
|
+
const factory = new DayPickerFactory(props);
|
|
278
279
|
const firstWeek = factory.createFirstWeek();
|
|
279
280
|
const rightWeeks = factory.createRightWeeks();
|
|
280
281
|
return [firstWeek, ...rightWeeks];
|
|
@@ -342,12 +343,12 @@ let Factory$2 = class Factory {
|
|
|
342
343
|
? helpersDate.weight(helpersDate.refactorDay(this.date, day)) > helpersDate.weight(this.maxDate)
|
|
343
344
|
: false;
|
|
344
345
|
}
|
|
345
|
-
}
|
|
346
|
+
}
|
|
346
347
|
function createDayPicker(props) {
|
|
347
|
-
return
|
|
348
|
+
return DayPickerFactory.execute(props);
|
|
348
349
|
}
|
|
349
350
|
|
|
350
|
-
function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
351
|
+
function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme, onValue }) {
|
|
351
352
|
const initialDate = date || new Date();
|
|
352
353
|
const initialDay = formControl?.state || initialDate.getDate();
|
|
353
354
|
const [weeks, setWeeks] = react.useState([]);
|
|
@@ -368,6 +369,9 @@ function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, mi
|
|
|
368
369
|
function onChange(value) {
|
|
369
370
|
setValue(value);
|
|
370
371
|
formControl?.setState(value);
|
|
372
|
+
if (onValue) {
|
|
373
|
+
onValue(value);
|
|
374
|
+
}
|
|
371
375
|
}
|
|
372
376
|
return (jsxRuntime.jsxs("div", { className: "rls-day-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-picker__header", children: helpersDate.DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-day-picker__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-day-picker__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-day-picker__week", children: days.map(({ value, disabled, forbidden, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-day-picker__day', {
|
|
373
377
|
disabled: disabled || disabledPicker,
|
|
@@ -380,13 +384,13 @@ function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, mi
|
|
|
380
384
|
}, children: jsxRuntime.jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
381
385
|
}
|
|
382
386
|
|
|
383
|
-
const
|
|
384
|
-
class
|
|
387
|
+
const DATE_FORMAT = '{dd}/{mm}/{aa}';
|
|
388
|
+
class ListCollection {
|
|
385
389
|
constructor(value) {
|
|
386
390
|
this.value = value;
|
|
387
391
|
}
|
|
388
|
-
|
|
389
|
-
return this.value.find((
|
|
392
|
+
find(element) {
|
|
393
|
+
return this.value.find((current) => current.compareTo(element));
|
|
390
394
|
}
|
|
391
395
|
}
|
|
392
396
|
class DateRange {
|
|
@@ -398,8 +402,8 @@ class DateRange {
|
|
|
398
402
|
else {
|
|
399
403
|
this.maxDate = helpersDate.normalizeMinTime(minDate);
|
|
400
404
|
}
|
|
401
|
-
const minFormat = helpersDate.formatDate(this.minDate,
|
|
402
|
-
const maxFormat = helpersDate.formatDate(this.maxDate,
|
|
405
|
+
const minFormat = helpersDate.formatDate(this.minDate, DATE_FORMAT);
|
|
406
|
+
const maxFormat = helpersDate.formatDate(this.maxDate, DATE_FORMAT);
|
|
403
407
|
this.description = `${minFormat} - ${maxFormat}`;
|
|
404
408
|
}
|
|
405
409
|
recalculate(date) {
|
|
@@ -420,7 +424,7 @@ class DateRange {
|
|
|
420
424
|
}
|
|
421
425
|
}
|
|
422
426
|
|
|
423
|
-
|
|
427
|
+
class DateRangePickerFactory {
|
|
424
428
|
constructor(props) {
|
|
425
429
|
const { date, range, maxDate, minDate } = props;
|
|
426
430
|
this.date = new Date(date.getTime());
|
|
@@ -430,7 +434,7 @@ let Factory$1 = class Factory {
|
|
|
430
434
|
this.date.setDate(1);
|
|
431
435
|
}
|
|
432
436
|
static execute(props) {
|
|
433
|
-
const factory = new
|
|
437
|
+
const factory = new DateRangePickerFactory(props);
|
|
434
438
|
const firstWeek = factory.createFirstWeek();
|
|
435
439
|
const rightWeeks = factory.createRightWeeks();
|
|
436
440
|
return [firstWeek, ...rightWeeks];
|
|
@@ -511,9 +515,9 @@ let Factory$1 = class Factory {
|
|
|
511
515
|
? helpersDate.weight(helpersDate.refactorDay(this.date, day)) > helpersDate.weight(this.maxDate)
|
|
512
516
|
: false;
|
|
513
517
|
}
|
|
514
|
-
}
|
|
518
|
+
}
|
|
515
519
|
function createRangePicker(props) {
|
|
516
|
-
return
|
|
520
|
+
return DateRangePickerFactory.execute(props);
|
|
517
521
|
}
|
|
518
522
|
|
|
519
523
|
function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
@@ -546,7 +550,7 @@ function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDat
|
|
|
546
550
|
}, children: jsxRuntime.jsx("span", { className: "rls-day-range-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
547
551
|
}
|
|
548
552
|
|
|
549
|
-
function RlsMoneyField({ children, decimals, disabled, formControl,
|
|
553
|
+
function RlsMoneyField({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
|
|
550
554
|
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
551
555
|
focused: formControl?.focused,
|
|
552
556
|
error: formControl?.touched && !formControl?.valid,
|
|
@@ -556,7 +560,7 @@ function RlsMoneyField({ children, decimals, disabled, formControl, onValue, pla
|
|
|
556
560
|
|
|
557
561
|
const MONTH_MAX_VALUE = helpersDate.Month.January;
|
|
558
562
|
const MONTH_MIN_VALUE = helpersDate.Month.December;
|
|
559
|
-
class
|
|
563
|
+
class MonthPickerFactory {
|
|
560
564
|
constructor(props) {
|
|
561
565
|
const { date, value, maxDate, minDate } = props;
|
|
562
566
|
this.value = value;
|
|
@@ -565,20 +569,20 @@ class Factory {
|
|
|
565
569
|
this.minDate = minDate;
|
|
566
570
|
}
|
|
567
571
|
static execute(props) {
|
|
568
|
-
const factory = new
|
|
572
|
+
const factory = new MonthPickerFactory(props);
|
|
569
573
|
return [
|
|
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(
|
|
580
|
-
factory.createMonth(
|
|
581
|
-
factory.createMonth(
|
|
574
|
+
factory.createMonth(helpersDate.Month.January),
|
|
575
|
+
factory.createMonth(helpersDate.Month.February),
|
|
576
|
+
factory.createMonth(helpersDate.Month.March),
|
|
577
|
+
factory.createMonth(helpersDate.Month.April),
|
|
578
|
+
factory.createMonth(helpersDate.Month.May),
|
|
579
|
+
factory.createMonth(helpersDate.Month.June),
|
|
580
|
+
factory.createMonth(helpersDate.Month.July),
|
|
581
|
+
factory.createMonth(helpersDate.Month.August),
|
|
582
|
+
factory.createMonth(helpersDate.Month.September),
|
|
583
|
+
factory.createMonth(helpersDate.Month.October),
|
|
584
|
+
factory.createMonth(helpersDate.Month.November),
|
|
585
|
+
factory.createMonth(helpersDate.Month.December)
|
|
582
586
|
];
|
|
583
587
|
}
|
|
584
588
|
createMonth(value) {
|
|
@@ -622,10 +626,10 @@ function isMaxLimitMonth(month, date, maxDate) {
|
|
|
622
626
|
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
623
627
|
}
|
|
624
628
|
function createMonthPicker(props) {
|
|
625
|
-
return
|
|
629
|
+
return MonthPickerFactory.execute(props);
|
|
626
630
|
}
|
|
627
631
|
|
|
628
|
-
function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme }) {
|
|
632
|
+
function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme, onValue }) {
|
|
629
633
|
const initialDate = date || new Date();
|
|
630
634
|
const initialMonth = formControl?.state || initialDate.getMonth();
|
|
631
635
|
const [months, setMonths] = react.useState([]);
|
|
@@ -638,12 +642,20 @@ function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate,
|
|
|
638
642
|
maxDate
|
|
639
643
|
}));
|
|
640
644
|
}, [value, date, minDate, maxDate]);
|
|
645
|
+
function onChange(value) {
|
|
646
|
+
formControl?.setState(value);
|
|
647
|
+
setValue(value);
|
|
648
|
+
if (onValue) {
|
|
649
|
+
onValue(value);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
641
652
|
return (jsxRuntime.jsx("div", { className: "rls-month-picker", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-month-picker__component', {
|
|
642
653
|
disabled: disabled || disabledPicker || false,
|
|
643
654
|
selected
|
|
644
655
|
}), onClick: () => {
|
|
645
|
-
|
|
646
|
-
|
|
656
|
+
if (!disabled) {
|
|
657
|
+
onChange(value);
|
|
658
|
+
}
|
|
647
659
|
}, children: jsxRuntime.jsx("span", { className: "rls-month-picker__span", children: label }) }, index))) }));
|
|
648
660
|
}
|
|
649
661
|
|
|
@@ -684,7 +696,7 @@ function RlsMonthTitlePicker({ monthControl, yearControl, date, maxDate, minDate
|
|
|
684
696
|
return (jsxRuntime.jsxs("div", { className: "rls-month-title-picker", children: [jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPreviousMonth, disabled: limitMinMonth }), jsxRuntime.jsx("span", { onClick: onClick, children: monthName }), jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNextMonth, disabled: limitMaxMonth })] }));
|
|
685
697
|
}
|
|
686
698
|
|
|
687
|
-
function RlsNumberField({ children, disabled, formControl,
|
|
699
|
+
function RlsNumberField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
688
700
|
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
689
701
|
focused: formControl?.focused,
|
|
690
702
|
error: formControl?.touched && !formControl?.valid,
|
|
@@ -734,7 +746,7 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
734
746
|
pagination.active = true;
|
|
735
747
|
setIndex(value);
|
|
736
748
|
setCurrentPagination(pagination);
|
|
737
|
-
refreshFromChanged(
|
|
749
|
+
refreshFromChanged(clonePage({ index: value }));
|
|
738
750
|
}
|
|
739
751
|
function goPagination(pagination) {
|
|
740
752
|
if (currentPagination) {
|
|
@@ -752,14 +764,14 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
752
764
|
else {
|
|
753
765
|
const prevIndex = value - MIN_NUMBER_PAGE;
|
|
754
766
|
if (prevIndex >= FIRST_PAGE) {
|
|
755
|
-
refreshFromChanged(
|
|
767
|
+
refreshFromChanged(clonePageFromIndex(prevIndex));
|
|
756
768
|
}
|
|
757
769
|
}
|
|
758
770
|
}
|
|
759
771
|
}
|
|
760
772
|
function goFirstPagination() {
|
|
761
773
|
if (collection.length) {
|
|
762
|
-
refreshFromChanged(
|
|
774
|
+
refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
|
|
763
775
|
}
|
|
764
776
|
}
|
|
765
777
|
function goNextPagination() {
|
|
@@ -772,14 +784,14 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
772
784
|
else {
|
|
773
785
|
const nextIndex = value + 1;
|
|
774
786
|
if (nextIndex <= maxPage) {
|
|
775
|
-
refreshFromChanged(
|
|
787
|
+
refreshFromChanged(clonePageFromIndex(nextIndex));
|
|
776
788
|
}
|
|
777
789
|
}
|
|
778
790
|
}
|
|
779
791
|
}
|
|
780
792
|
function goLastPagination() {
|
|
781
793
|
if (collection.length) {
|
|
782
|
-
refreshFromChanged(
|
|
794
|
+
refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
|
|
783
795
|
}
|
|
784
796
|
}
|
|
785
797
|
function createPageCollection(props) {
|
|
@@ -793,17 +805,11 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
793
805
|
}
|
|
794
806
|
function refreshFromElements(elements) {
|
|
795
807
|
elements.length
|
|
796
|
-
? refreshFromChanged(
|
|
808
|
+
? refreshFromChanged(refreshPage(elements, filter))
|
|
797
809
|
: rebootPagination();
|
|
798
810
|
}
|
|
799
811
|
function refreshFromFilter(filter) {
|
|
800
|
-
refreshFromChanged(
|
|
801
|
-
}
|
|
802
|
-
function createRefreshProps(elements, filter) {
|
|
803
|
-
const collection = refreshCollection(elements, filter);
|
|
804
|
-
const maxPage = refreshMaxPage(collection, count);
|
|
805
|
-
const index = refreshIndex(collection, maxPage);
|
|
806
|
-
return createPageProps({ collection, index, maxPage });
|
|
812
|
+
refreshFromChanged(refreshPage(elements, filter));
|
|
807
813
|
}
|
|
808
814
|
function refreshFromChanged(page) {
|
|
809
815
|
refreshPaginations(page);
|
|
@@ -831,13 +837,6 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
831
837
|
setIndex(newIndex);
|
|
832
838
|
return newIndex;
|
|
833
839
|
}
|
|
834
|
-
function rebootPagination() {
|
|
835
|
-
setCollection([]);
|
|
836
|
-
setMaxPage(0);
|
|
837
|
-
setIndex(0);
|
|
838
|
-
setPaginations([]);
|
|
839
|
-
onChangeElements([]);
|
|
840
|
-
}
|
|
841
840
|
function refreshDescription(page) {
|
|
842
841
|
const { collection, count, index } = page;
|
|
843
842
|
const totalCount = elements.length;
|
|
@@ -873,6 +872,23 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
873
872
|
}
|
|
874
873
|
setPaginations(paginations);
|
|
875
874
|
}
|
|
875
|
+
function clonePage(pagePartial) {
|
|
876
|
+
return {
|
|
877
|
+
collection: pagePartial.collection || collection,
|
|
878
|
+
index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
|
|
879
|
+
count: pagePartial.count || count,
|
|
880
|
+
maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function clonePageFromIndex(index) {
|
|
884
|
+
return clonePage({ index });
|
|
885
|
+
}
|
|
886
|
+
function refreshPage(elements, filter) {
|
|
887
|
+
const collection = refreshCollection(elements, filter);
|
|
888
|
+
const maxPage = refreshMaxPage(collection, count);
|
|
889
|
+
const index = refreshIndex(collection, maxPage);
|
|
890
|
+
return clonePage({ collection, index, maxPage });
|
|
891
|
+
}
|
|
876
892
|
function createPagination(value, index) {
|
|
877
893
|
const active = value === index;
|
|
878
894
|
const pagination = {
|
|
@@ -885,16 +901,12 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
885
901
|
}
|
|
886
902
|
return pagination;
|
|
887
903
|
}
|
|
888
|
-
function
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
index: typeof props.index === 'number' ? props.index : index,
|
|
895
|
-
count: props.count || count,
|
|
896
|
-
maxPage: typeof props.maxPage === 'number' ? props.maxPage : maxPage
|
|
897
|
-
};
|
|
904
|
+
function rebootPagination() {
|
|
905
|
+
setCollection([]);
|
|
906
|
+
setMaxPage(0);
|
|
907
|
+
setIndex(0);
|
|
908
|
+
setPaginations([]);
|
|
909
|
+
onChangeElements([]);
|
|
898
910
|
}
|
|
899
911
|
return (jsxRuntime.jsxs("div", { className: "rls-pagination", children: [jsxRuntime.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntime.jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: firstPage, children: jsxRuntime.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntime.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: firstPage, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntime.jsx("div", { className: "rls-pagination__pages", children: paginations.map((page, index) => {
|
|
900
912
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-pagination__page', {
|
|
@@ -949,7 +961,7 @@ function RlsSwitchLabel({ children, disabled, extended, formControl, rlsTheme })
|
|
|
949
961
|
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-switch-label', { disabled, extended }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-switch-label__component", onClick: onToggle, children: jsxRuntime.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-switch-label__text", children: children })] }));
|
|
950
962
|
}
|
|
951
963
|
|
|
952
|
-
function RlsTextField({ children, disabled, formControl,
|
|
964
|
+
function RlsTextField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
953
965
|
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
954
966
|
focused: formControl?.focused,
|
|
955
967
|
error: formControl?.touched && !formControl?.valid,
|
|
@@ -962,7 +974,7 @@ function RlsToolbar({ actions, children, subtitle }) {
|
|
|
962
974
|
}
|
|
963
975
|
|
|
964
976
|
const COUNT_YEAR_RANGE = 4;
|
|
965
|
-
class
|
|
977
|
+
class YearPickerFactory {
|
|
966
978
|
constructor(props) {
|
|
967
979
|
const { value, maxDate, minDate } = props;
|
|
968
980
|
this.value = value;
|
|
@@ -970,7 +982,7 @@ class FactoryYearPicker {
|
|
|
970
982
|
this.minDate = minDate;
|
|
971
983
|
}
|
|
972
984
|
static execute(props) {
|
|
973
|
-
const factory = new
|
|
985
|
+
const factory = new YearPickerFactory(props);
|
|
974
986
|
let year = props.year;
|
|
975
987
|
if (factory.minOverflowYear(year)) {
|
|
976
988
|
year = factory.minYear;
|
|
@@ -1041,10 +1053,10 @@ class FactoryYearPicker {
|
|
|
1041
1053
|
}
|
|
1042
1054
|
}
|
|
1043
1055
|
function createYearPicker(props) {
|
|
1044
|
-
return
|
|
1056
|
+
return YearPickerFactory.execute(props);
|
|
1045
1057
|
}
|
|
1046
1058
|
|
|
1047
|
-
function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxDate, minDate, rlsTheme }) {
|
|
1059
|
+
function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxDate, minDate, rlsTheme, onValue }) {
|
|
1048
1060
|
const initialDate = date || new Date();
|
|
1049
1061
|
const initialYear = formControl?.state || initialDate.getFullYear();
|
|
1050
1062
|
const [value, setValue] = react.useState(initialYear);
|
|
@@ -1073,17 +1085,41 @@ function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxD
|
|
|
1073
1085
|
formControl?.setState(value);
|
|
1074
1086
|
setYear(value);
|
|
1075
1087
|
setValue(value);
|
|
1088
|
+
if (onValue) {
|
|
1089
|
+
onValue(value);
|
|
1090
|
+
}
|
|
1076
1091
|
}
|
|
1077
1092
|
return (jsxRuntime.jsxs("div", { className: "rls-year-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-year-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--prev", children: jsxRuntime.jsx("button", { disabled: !template.hasPrevious || disabledPicker, onClick: onClickPrev, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-left" }) }) }), jsxRuntime.jsx("div", { className: "rls-year-picker__title", children: jsxRuntime.jsxs("label", { className: "title1-bold", children: [template.minRange, " - ", template.maxRange] }) }), jsxRuntime.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--next", children: jsxRuntime.jsx("button", { disabled: !template.hasNext || disabledPicker, onClick: onClickNext, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-right" }) }) })] }), jsxRuntime.jsx("div", { className: "rls-year-picker__component", children: template.years.map(({ value, disabled, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-year-picker__year', {
|
|
1078
1093
|
disabled: disabled || disabledPicker,
|
|
1079
1094
|
selected
|
|
1080
1095
|
}), onClick: () => {
|
|
1081
|
-
if (value) {
|
|
1096
|
+
if (value && !disabled) {
|
|
1082
1097
|
onChange(value);
|
|
1083
1098
|
}
|
|
1084
1099
|
}, children: jsxRuntime.jsx("span", { className: "rls-year-picker__year__span body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1085
1100
|
}
|
|
1086
1101
|
|
|
1102
|
+
const reactI18n = i18n.i18n({
|
|
1103
|
+
es: {
|
|
1104
|
+
confirmationActionApproved: 'Aceptar',
|
|
1105
|
+
dateActionCancel: 'Cancelar',
|
|
1106
|
+
dateActionSelect: 'Establecer',
|
|
1107
|
+
dateActionToday: 'Hoy',
|
|
1108
|
+
listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
|
|
1109
|
+
listEmptyTitle: 'Selección no disponible',
|
|
1110
|
+
listInputPlaceholder: 'Buscar...'
|
|
1111
|
+
},
|
|
1112
|
+
en: {
|
|
1113
|
+
confirmationActionApproved: 'Approved',
|
|
1114
|
+
dateActionCancel: 'Cancel',
|
|
1115
|
+
dateActionSelect: 'Select',
|
|
1116
|
+
dateActionToday: 'Today',
|
|
1117
|
+
listEmptyDescription: 'Sorry, there are currently no items in the list',
|
|
1118
|
+
listEmptyTitle: 'Selection not available',
|
|
1119
|
+
listInputPlaceholder: 'Search...'
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1087
1123
|
const classElement = '.rls-list-field__element';
|
|
1088
1124
|
const MAX_POSITION_VISIBLE = 4;
|
|
1089
1125
|
const LIST_SIZE_REM = 16;
|
|
@@ -1091,16 +1127,16 @@ const ELEMENT_SIZE_REM = 4;
|
|
|
1091
1127
|
const BASE_SIZE_PX = 16;
|
|
1092
1128
|
const ELEMENT_SIZE_PX = BASE_SIZE_PX * ELEMENT_SIZE_REM;
|
|
1093
1129
|
const MAZ_LIST_SIZE_PX = BASE_SIZE_PX * LIST_SIZE_REM;
|
|
1094
|
-
function useListControl({ suggestions, formControl,
|
|
1130
|
+
function useListControl({ suggestions, formControl, withHigher = false }) {
|
|
1095
1131
|
const boxContentRef = react.useRef(null);
|
|
1096
1132
|
const listRef = react.useRef(null);
|
|
1097
1133
|
const inputRef = react.useRef(null);
|
|
1098
|
-
const [collection, setCollection] = react.useState(new
|
|
1099
|
-
const [active, setActive] = react.useState(false);
|
|
1100
|
-
const [visible, setVisible] = react.useState(false);
|
|
1101
|
-
const [opened, setOpened] = react.useState(false);
|
|
1134
|
+
const [collection, setCollection] = react.useState(new ListCollection([]));
|
|
1102
1135
|
const [value, setValue] = react.useState('');
|
|
1136
|
+
const [opened, setOpened] = react.useState(false);
|
|
1137
|
+
const [visible, setVisible] = react.useState(false);
|
|
1103
1138
|
const [higher, setHigher] = react.useState(false);
|
|
1139
|
+
const [focused, setFocused] = react.useState(false);
|
|
1104
1140
|
const [positionElement, setPositionElement] = react.useState(0);
|
|
1105
1141
|
const [listElements, setListElements] = react.useState(undefined);
|
|
1106
1142
|
react.useEffect(() => {
|
|
@@ -1124,7 +1160,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1124
1160
|
setLocationList();
|
|
1125
1161
|
}, [visible]);
|
|
1126
1162
|
react.useEffect(() => {
|
|
1127
|
-
setCollection(new
|
|
1163
|
+
setCollection(new ListCollection(suggestions));
|
|
1128
1164
|
}, [suggestions]);
|
|
1129
1165
|
function setLocationList() {
|
|
1130
1166
|
if (boxContentRef?.current) {
|
|
@@ -1142,7 +1178,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1142
1178
|
}
|
|
1143
1179
|
break;
|
|
1144
1180
|
case 'ArrowDown':
|
|
1145
|
-
if (visible && (
|
|
1181
|
+
if (visible && (withHigher || !higher)) {
|
|
1146
1182
|
navigationInputDown();
|
|
1147
1183
|
}
|
|
1148
1184
|
break;
|
|
@@ -1196,7 +1232,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1196
1232
|
setPositionElement(newPosition);
|
|
1197
1233
|
listElements?.item(newPosition).focus();
|
|
1198
1234
|
}
|
|
1199
|
-
else if (
|
|
1235
|
+
else if (withHigher || !higher) {
|
|
1200
1236
|
inputRef?.current?.focus();
|
|
1201
1237
|
}
|
|
1202
1238
|
}
|
|
@@ -1207,30 +1243,30 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
|
|
|
1207
1243
|
setPositionElement(newPosition);
|
|
1208
1244
|
listElements?.item(newPosition).focus();
|
|
1209
1245
|
}
|
|
1210
|
-
else if (higher && !
|
|
1246
|
+
else if (higher && !withHigher) {
|
|
1211
1247
|
inputRef?.current?.focus();
|
|
1212
1248
|
}
|
|
1213
1249
|
}
|
|
1214
1250
|
return {
|
|
1215
|
-
active,
|
|
1216
1251
|
boxContentRef,
|
|
1217
1252
|
collection,
|
|
1253
|
+
focused,
|
|
1218
1254
|
higher,
|
|
1219
1255
|
inputRef,
|
|
1220
1256
|
listRef,
|
|
1257
|
+
value,
|
|
1258
|
+
visible,
|
|
1221
1259
|
navigationElement,
|
|
1222
1260
|
navigationInput,
|
|
1223
|
-
|
|
1261
|
+
setFocused,
|
|
1224
1262
|
setValue,
|
|
1225
|
-
setVisible
|
|
1226
|
-
value,
|
|
1227
|
-
visible
|
|
1263
|
+
setVisible
|
|
1228
1264
|
};
|
|
1229
1265
|
}
|
|
1230
1266
|
|
|
1231
1267
|
const DURATION_ANIMATION$1 = 240;
|
|
1232
1268
|
const MAX_ELEMENTS = 6;
|
|
1233
|
-
function
|
|
1269
|
+
function useAutocompleteField({ suggestions, disabled, formControl, onSelect, onValue }) {
|
|
1234
1270
|
const [pattern, setPattern] = react.useState('');
|
|
1235
1271
|
const [coincidences, setCoincidences] = react.useState([]);
|
|
1236
1272
|
const [store, setStore] = react.useState({
|
|
@@ -1238,7 +1274,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1238
1274
|
coincidences: [],
|
|
1239
1275
|
previous: null
|
|
1240
1276
|
});
|
|
1241
|
-
const
|
|
1277
|
+
const listControl = useListControl({
|
|
1278
|
+
suggestions,
|
|
1279
|
+
formControl,
|
|
1280
|
+
withHigher: true
|
|
1281
|
+
});
|
|
1282
|
+
const { collection, inputRef, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
|
|
1242
1283
|
const [changeInternal, setChangeInternal] = react.useState(false);
|
|
1243
1284
|
react.useEffect(() => {
|
|
1244
1285
|
filterSuggestions(pattern, true);
|
|
@@ -1256,7 +1297,7 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1256
1297
|
redefineDescription();
|
|
1257
1298
|
}, [collection]);
|
|
1258
1299
|
function redefineDescription() {
|
|
1259
|
-
const element = formControl?.state && collection.
|
|
1300
|
+
const element = formControl?.state && collection.find(formControl?.state);
|
|
1260
1301
|
setValue(element?.description || '');
|
|
1261
1302
|
}
|
|
1262
1303
|
function onClickControl() {
|
|
@@ -1266,10 +1307,10 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1266
1307
|
}
|
|
1267
1308
|
}
|
|
1268
1309
|
function onFocusInput() {
|
|
1269
|
-
|
|
1310
|
+
setFocused(true);
|
|
1270
1311
|
}
|
|
1271
1312
|
function onBlurInput() {
|
|
1272
|
-
|
|
1313
|
+
setFocused(false);
|
|
1273
1314
|
}
|
|
1274
1315
|
function onKeydownInput(event) {
|
|
1275
1316
|
switch (event.code) {
|
|
@@ -1298,12 +1339,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1298
1339
|
function onClickBackdrop() {
|
|
1299
1340
|
setVisible(false);
|
|
1300
1341
|
}
|
|
1301
|
-
function
|
|
1342
|
+
function onClickElement(element) {
|
|
1302
1343
|
return () => {
|
|
1303
1344
|
onChange(element);
|
|
1304
1345
|
};
|
|
1305
1346
|
}
|
|
1306
|
-
function
|
|
1347
|
+
function onKeydownElement(element) {
|
|
1307
1348
|
return (event) => {
|
|
1308
1349
|
switch (event.code) {
|
|
1309
1350
|
case 'Enter':
|
|
@@ -1334,8 +1375,8 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1334
1375
|
function filterSuggestions(pattern, reboot = false) {
|
|
1335
1376
|
if (pattern) {
|
|
1336
1377
|
const store = reboot ? createStoreEmpty() : searchForPattern(pattern);
|
|
1337
|
-
const
|
|
1338
|
-
const coincidences =
|
|
1378
|
+
const elements = store?.coincidences || suggestions;
|
|
1379
|
+
const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
|
|
1339
1380
|
setCoincidences(coincidences.slice(0, MAX_ELEMENTS));
|
|
1340
1381
|
setStore({
|
|
1341
1382
|
coincidences,
|
|
@@ -1363,9 +1404,9 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1363
1404
|
return newStore || rebootStore();
|
|
1364
1405
|
}
|
|
1365
1406
|
function rebootStore() {
|
|
1366
|
-
const
|
|
1367
|
-
setStore(
|
|
1368
|
-
return
|
|
1407
|
+
const store = createStoreEmpty();
|
|
1408
|
+
setStore(store);
|
|
1409
|
+
return store;
|
|
1369
1410
|
}
|
|
1370
1411
|
function createStoreEmpty() {
|
|
1371
1412
|
return {
|
|
@@ -1374,19 +1415,46 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
|
|
|
1374
1415
|
previous: null
|
|
1375
1416
|
};
|
|
1376
1417
|
}
|
|
1377
|
-
return
|
|
1418
|
+
return {
|
|
1419
|
+
coincidences,
|
|
1420
|
+
listControl,
|
|
1421
|
+
pattern,
|
|
1422
|
+
onBlurInput,
|
|
1423
|
+
onClickAction,
|
|
1424
|
+
onClickBackdrop,
|
|
1425
|
+
onClickControl,
|
|
1426
|
+
onClickElement,
|
|
1427
|
+
onFocusInput,
|
|
1428
|
+
onKeydownElement,
|
|
1429
|
+
onKeydownInput,
|
|
1430
|
+
setPattern
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
|
|
1435
|
+
const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useAutocompleteField({
|
|
1436
|
+
suggestions,
|
|
1437
|
+
disabled,
|
|
1438
|
+
formControl,
|
|
1439
|
+
onSelect,
|
|
1440
|
+
onValue
|
|
1441
|
+
});
|
|
1442
|
+
return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', {
|
|
1378
1443
|
disabled,
|
|
1379
|
-
|
|
1380
|
-
selected: !!value
|
|
1381
|
-
}, 'rls-autocomplete-field rls-list-field'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("label", { className: "rls-list-field__control", onClick: onClickControl, children: value ? (jsxRuntime.jsx("span", { className: "rls-list-field__control__description", children: value })) : (jsxRuntime.jsx("span", { className: "rls-list-field__control__placeholder", children: placeholder })) }), !hiddenIcon && value && (jsxRuntime.jsx("button", { className: "rls-list-field__action", disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
|
|
1382
|
-
visible,
|
|
1383
|
-
hide: !visible,
|
|
1384
|
-
higher
|
|
1385
|
-
}), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listRef, className: "rls-list-field__ul", children: [jsxRuntime.jsxs("div", { className: "rls-list-field__ul__search", children: [jsxRuntime.jsx("input", { ref: inputRef, className: "rls-list-field__ul__control", type: "text", value: pattern, onChange: ({ target: { value } }) => {
|
|
1444
|
+
focused: listControl.focused,
|
|
1445
|
+
selected: !!listControl.value
|
|
1446
|
+
}, 'rls-autocomplete-field rls-list-field'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("label", { className: "rls-list-field__control", onClick: onClickControl, children: listControl.value ? (jsxRuntime.jsx("span", { className: "rls-list-field__control__description", children: listControl.value })) : (jsxRuntime.jsx("span", { className: "rls-list-field__control__placeholder", children: placeholder })) }), !hiddenIcon && listControl.value && (jsxRuntime.jsx("button", { className: "rls-list-field__action", disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
|
|
1447
|
+
visible: listControl.visible,
|
|
1448
|
+
hide: !listControl.visible,
|
|
1449
|
+
higher: listControl.higher
|
|
1450
|
+
}), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [jsxRuntime.jsxs("div", { className: "rls-list-field__ul__search", children: [jsxRuntime.jsx("input", { ref: listControl.inputRef, className: "rls-list-field__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: pattern, onChange: ({ target: { value } }) => {
|
|
1386
1451
|
setPattern(value);
|
|
1387
1452
|
}, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntime.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
1388
1453
|
onSearch(pattern);
|
|
1389
|
-
}, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick:
|
|
1454
|
+
}, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !coincidences.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntime.jsx("label", { className: "label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
|
|
1455
|
+
}
|
|
1456
|
+
function RlsAutocompleteField(props) {
|
|
1457
|
+
return (jsxRuntime.jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
1390
1458
|
}
|
|
1391
1459
|
|
|
1392
1460
|
function RlsCard({ children, outline, rlsTheme }) {
|
|
@@ -1425,7 +1493,7 @@ function useConfirmationService() {
|
|
|
1425
1493
|
subtitle,
|
|
1426
1494
|
title,
|
|
1427
1495
|
approved: {
|
|
1428
|
-
label: approved || '
|
|
1496
|
+
label: approved || reactI18n('confirmationActionApproved'),
|
|
1429
1497
|
onClick: () => {
|
|
1430
1498
|
setVisible(false);
|
|
1431
1499
|
resolve(ConfirmationResult.approved());
|
|
@@ -1592,7 +1660,7 @@ const VISIBILITY$1 = {
|
|
|
1592
1660
|
year: true
|
|
1593
1661
|
}
|
|
1594
1662
|
};
|
|
1595
|
-
function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDate,
|
|
1663
|
+
function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDate, rlsTheme, onListener }) {
|
|
1596
1664
|
const dateInitial = formControl?.state || date || new Date();
|
|
1597
1665
|
const yearControl = useReactControl({ state: dateInitial.getFullYear() });
|
|
1598
1666
|
const dayControl = useReactControl({ state: dateInitial.getDate() });
|
|
@@ -1658,14 +1726,14 @@ function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDat
|
|
|
1658
1726
|
year,
|
|
1659
1727
|
day,
|
|
1660
1728
|
month
|
|
1661
|
-
}), children: [jsxRuntime.jsx(RlsDayPicker, { formControl: dayControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-picker__footer', { automatic }), children: jsxRuntime.jsxs("div", { className: "rls-date-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children:
|
|
1729
|
+
}), children: [jsxRuntime.jsx(RlsDayPicker, { formControl: dayControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-picker__footer', { automatic }), children: jsxRuntime.jsxs("div", { className: "rls-date-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--today", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onToday, children: reactI18n('dateActionToday') }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1662
1730
|
}
|
|
1663
1731
|
|
|
1664
1732
|
function RlsModal({ children, visible, rlsTheme }) {
|
|
1665
1733
|
return ReactDOM.createPortal(jsxRuntime.jsxs("div", { className: renderClassStatus('rls-modal', { visible }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntime.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
|
|
1666
1734
|
}
|
|
1667
1735
|
|
|
1668
|
-
function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
1736
|
+
function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, placeholder, rlsTheme, onValue }) {
|
|
1669
1737
|
const dateInitial = formControl?.state || date || new Date();
|
|
1670
1738
|
const [value, setValue] = react.useState(dateInitial);
|
|
1671
1739
|
const [show, setShow] = react.useState(false);
|
|
@@ -1676,10 +1744,18 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1676
1744
|
function onClickInput() {
|
|
1677
1745
|
setShow(true);
|
|
1678
1746
|
}
|
|
1747
|
+
function onChange(value, ignoreControl = false) {
|
|
1748
|
+
if (!ignoreControl) {
|
|
1749
|
+
formControl?.setState(undefined);
|
|
1750
|
+
}
|
|
1751
|
+
setValue(undefined);
|
|
1752
|
+
if (onValue) {
|
|
1753
|
+
onValue(value);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1679
1756
|
function onClean() {
|
|
1680
1757
|
if (value) {
|
|
1681
|
-
|
|
1682
|
-
setValue(undefined);
|
|
1758
|
+
onChange(undefined);
|
|
1683
1759
|
if (formControl && !formControl.touched) {
|
|
1684
1760
|
formControl.touch();
|
|
1685
1761
|
}
|
|
@@ -1688,9 +1764,9 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1688
1764
|
setShow(true);
|
|
1689
1765
|
}
|
|
1690
1766
|
}
|
|
1691
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: description, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClean, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }), jsxRuntime.jsx(RlsModal, { visible: show, children: jsxRuntime.jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
1692
|
-
if (
|
|
1693
|
-
|
|
1767
|
+
return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: description, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClean, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }), jsxRuntime.jsx(RlsModal, { visible: show, children: jsxRuntime.jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
1768
|
+
if (type !== PickerListenerType.Cancel) {
|
|
1769
|
+
onChange(value, true);
|
|
1694
1770
|
}
|
|
1695
1771
|
setShow(false);
|
|
1696
1772
|
if (formControl && !formControl.touched) {
|
|
@@ -1775,7 +1851,7 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
|
|
|
1775
1851
|
month
|
|
1776
1852
|
}), children: [jsxRuntime.jsx(RlsDayRangePicker, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-range-picker__footer', {
|
|
1777
1853
|
automatic
|
|
1778
|
-
}), children: jsxRuntime.jsxs("div", { className: "rls-date-range-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children:
|
|
1854
|
+
}), children: jsxRuntime.jsxs("div", { className: "rls-date-range-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1779
1855
|
}
|
|
1780
1856
|
|
|
1781
1857
|
function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
@@ -1812,8 +1888,9 @@ function RlsFormNavigation({ children, visible, rlsTheme }) {
|
|
|
1812
1888
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
|
|
1813
1889
|
}
|
|
1814
1890
|
|
|
1815
|
-
function
|
|
1816
|
-
const
|
|
1891
|
+
function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
1892
|
+
const listControl = useListControl({ suggestions, formControl });
|
|
1893
|
+
const { collection, inputRef, visible, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
|
|
1817
1894
|
const [changeInternal, setChangeInternal] = react.useState(false);
|
|
1818
1895
|
react.useEffect(() => {
|
|
1819
1896
|
if (!changeInternal) {
|
|
@@ -1825,16 +1902,16 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
|
|
|
1825
1902
|
redefineDescription();
|
|
1826
1903
|
}, [collection]);
|
|
1827
1904
|
function redefineDescription() {
|
|
1828
|
-
const element = formControl?.state && collection.
|
|
1905
|
+
const element = formControl?.state && collection.find(formControl?.state);
|
|
1829
1906
|
setValue(element?.description || '');
|
|
1830
1907
|
}
|
|
1831
1908
|
function onFocusInput() {
|
|
1832
|
-
|
|
1909
|
+
setFocused(true);
|
|
1833
1910
|
}
|
|
1834
1911
|
function onBlurInput() {
|
|
1835
|
-
|
|
1912
|
+
setFocused(false);
|
|
1836
1913
|
}
|
|
1837
|
-
function
|
|
1914
|
+
function onClickControl() {
|
|
1838
1915
|
setVisible(true);
|
|
1839
1916
|
}
|
|
1840
1917
|
function onKeydownInput(event) {
|
|
@@ -1866,12 +1943,12 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
|
|
|
1866
1943
|
function onClickBackdrop() {
|
|
1867
1944
|
setVisible(false);
|
|
1868
1945
|
}
|
|
1869
|
-
function
|
|
1946
|
+
function onClickElement(element) {
|
|
1870
1947
|
return () => {
|
|
1871
1948
|
onChange(element);
|
|
1872
1949
|
};
|
|
1873
1950
|
}
|
|
1874
|
-
function
|
|
1951
|
+
function onKeydownElement(element) {
|
|
1875
1952
|
return (event) => {
|
|
1876
1953
|
switch (event.code) {
|
|
1877
1954
|
case 'Enter':
|
|
@@ -1900,11 +1977,37 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
|
|
|
1900
1977
|
onValue(value);
|
|
1901
1978
|
}
|
|
1902
1979
|
}
|
|
1903
|
-
return
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1980
|
+
return {
|
|
1981
|
+
listControl,
|
|
1982
|
+
onBlurInput,
|
|
1983
|
+
onClickAction,
|
|
1984
|
+
onClickBackdrop,
|
|
1985
|
+
onClickInput: onClickControl,
|
|
1986
|
+
onClickElement,
|
|
1987
|
+
onFocusInput,
|
|
1988
|
+
onKeydownElement,
|
|
1989
|
+
onKeydownInput
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
|
|
1994
|
+
const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useSelectField({
|
|
1995
|
+
suggestions,
|
|
1996
|
+
disabled,
|
|
1997
|
+
formControl,
|
|
1998
|
+
onSelect,
|
|
1999
|
+
onValue
|
|
2000
|
+
});
|
|
2001
|
+
return (jsxRuntime.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 && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { 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 }), jsxRuntime.jsx("button", { className: renderClassStatus('rls-list-field__action', {
|
|
2002
|
+
visible: listControl.visible
|
|
2003
|
+
}), disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
|
|
2004
|
+
visible: listControl.visible,
|
|
2005
|
+
hide: !listControl.visible,
|
|
2006
|
+
higher: listControl.higher
|
|
2007
|
+
}), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntime.jsx("label", { className: "label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
|
|
2008
|
+
}
|
|
2009
|
+
function RlsSelectField(props) {
|
|
2010
|
+
return (jsxRuntime.jsx(RlsSelectFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
1908
2011
|
}
|
|
1909
2012
|
|
|
1910
2013
|
const DURATION_ANIMATION = 240;
|
|
@@ -1970,10 +2073,11 @@ function RlsApplication({ children }) {
|
|
|
1970
2073
|
|
|
1971
2074
|
exports.ConfirmationResult = ConfirmationResult;
|
|
1972
2075
|
exports.DateRange = DateRange;
|
|
1973
|
-
exports.
|
|
2076
|
+
exports.ListCollection = ListCollection;
|
|
1974
2077
|
exports.RlsAmount = RlsAmount;
|
|
1975
2078
|
exports.RlsApplication = RlsApplication;
|
|
1976
2079
|
exports.RlsAutocompleteField = RlsAutocompleteField;
|
|
2080
|
+
exports.RlsAutocompleteFieldTemplate = RlsAutocompleteFieldTemplate;
|
|
1977
2081
|
exports.RlsAvatar = RlsAvatar;
|
|
1978
2082
|
exports.RlsBallot = RlsBallot;
|
|
1979
2083
|
exports.RlsBreadcrumb = RlsBreadcrumb;
|
|
@@ -2019,6 +2123,7 @@ exports.RlsRadioButton = RlsRadioButton;
|
|
|
2019
2123
|
exports.RlsRadioButtonLabel = RlsRadioButtonLabel;
|
|
2020
2124
|
exports.RlsSearchInput = RlsSearchInput;
|
|
2021
2125
|
exports.RlsSelectField = RlsSelectField;
|
|
2126
|
+
exports.RlsSelectFieldTemplate = RlsSelectFieldTemplate;
|
|
2022
2127
|
exports.RlsSkeleton = RlsSkeleton;
|
|
2023
2128
|
exports.RlsSkeletonText = RlsSkeletonText;
|
|
2024
2129
|
exports.RlsSnackbar = RlsSnackbar;
|