@rolster/react-components 18.9.0 → 18.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cjs/index.js +141 -58
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/index.js +139 -58
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.d.ts +11 -6
  6. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js +21 -157
  7. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js.map +1 -1
  8. package/dist/esm/components/organisms/AutocompleteField/autocomplete-field.hook.d.ts +27 -0
  9. package/dist/esm/components/organisms/AutocompleteField/autocomplete-field.hook.js +170 -0
  10. package/dist/esm/components/organisms/AutocompleteField/autocomplete-field.hook.js.map +1 -0
  11. package/dist/esm/components/organisms/Confirmation/Confirmation.js +2 -1
  12. package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
  13. package/dist/esm/components/organisms/DatePicker/DatePicker.js +2 -1
  14. package/dist/esm/components/organisms/DatePicker/DatePicker.js.map +1 -1
  15. package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js +2 -1
  16. package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js.map +1 -1
  17. package/dist/esm/components/organisms/SelectField/SelectField.d.ts +11 -7
  18. package/dist/esm/components/organisms/SelectField/SelectField.js +20 -95
  19. package/dist/esm/components/organisms/SelectField/SelectField.js.map +1 -1
  20. package/dist/esm/components/organisms/SelectField/select-field.hook.d.ts +24 -0
  21. package/dist/esm/components/organisms/SelectField/select-field.hook.js +104 -0
  22. package/dist/esm/components/organisms/SelectField/select-field.hook.js.map +1 -0
  23. package/dist/esm/hooks/list-control.hook.d.ts +10 -10
  24. package/dist/esm/hooks/list-control.hook.js +15 -15
  25. package/dist/esm/hooks/list-control.hook.js.map +1 -1
  26. package/dist/esm/i18n.d.ts +18 -0
  27. package/dist/esm/i18n.js +23 -0
  28. package/dist/esm/i18n.js.map +1 -0
  29. package/dist/esm/models.d.ts +19 -8
  30. package/dist/esm/models.js +6 -6
  31. package/dist/esm/models.js.map +1 -1
  32. 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';
@@ -378,13 +379,13 @@ function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, mi
378
379
  }, children: jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
379
380
  }
380
381
 
381
- const FORMAT_DESCRIPTION$1 = '{dd}/{mm}/{aa}';
382
- class ListFieldCollection {
382
+ const DATE_FORMAT = '{dd}/{mm}/{aa}';
383
+ class ListCollection {
383
384
  constructor(value) {
384
385
  this.value = value;
385
386
  }
386
- findElement(value) {
387
- return this.value.find((element) => element.compareTo(value));
387
+ find(element) {
388
+ return this.value.find((current) => current.compareTo(element));
388
389
  }
389
390
  }
390
391
  class DateRange {
@@ -396,8 +397,8 @@ class DateRange {
396
397
  else {
397
398
  this.maxDate = normalizeMinTime(minDate);
398
399
  }
399
- const minFormat = formatDate(this.minDate, FORMAT_DESCRIPTION$1);
400
- const maxFormat = formatDate(this.maxDate, FORMAT_DESCRIPTION$1);
400
+ const minFormat = formatDate(this.minDate, DATE_FORMAT);
401
+ const maxFormat = formatDate(this.maxDate, DATE_FORMAT);
401
402
  this.description = `${minFormat} - ${maxFormat}`;
402
403
  }
403
404
  recalculate(date) {
@@ -1082,6 +1083,27 @@ function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxD
1082
1083
  }, children: jsx("span", { className: "rls-year-picker__year__span body1-medium", children: value || '????' }) }, index))) })] }));
1083
1084
  }
1084
1085
 
1086
+ const reactI18n = i18n({
1087
+ es: {
1088
+ confirmationActionApproved: 'Aceptar',
1089
+ dateActionCancel: 'Cancelar',
1090
+ dateActionSelect: 'Establecer',
1091
+ dateActionToday: 'Hoy',
1092
+ listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
1093
+ listEmptyTitle: 'Selección no disponible',
1094
+ listInputPlaceholder: 'Buscar...'
1095
+ },
1096
+ en: {
1097
+ confirmationActionApproved: 'Approved',
1098
+ dateActionCancel: 'Cancel',
1099
+ dateActionSelect: 'Select',
1100
+ dateActionToday: 'Today',
1101
+ listEmptyDescription: 'Sorry, there are currently no items in the list',
1102
+ listEmptyTitle: 'Selection not available',
1103
+ listInputPlaceholder: 'Search...'
1104
+ }
1105
+ });
1106
+
1085
1107
  const classElement = '.rls-list-field__element';
1086
1108
  const MAX_POSITION_VISIBLE = 4;
1087
1109
  const LIST_SIZE_REM = 16;
@@ -1089,16 +1111,16 @@ const ELEMENT_SIZE_REM = 4;
1089
1111
  const BASE_SIZE_PX = 16;
1090
1112
  const ELEMENT_SIZE_PX = BASE_SIZE_PX * ELEMENT_SIZE_REM;
1091
1113
  const MAZ_LIST_SIZE_PX = BASE_SIZE_PX * LIST_SIZE_REM;
1092
- function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1114
+ function useListControl({ suggestions, formControl, withHigher = false }) {
1093
1115
  const boxContentRef = useRef(null);
1094
1116
  const listRef = useRef(null);
1095
1117
  const inputRef = useRef(null);
1096
- const [collection, setCollection] = useState(new ListFieldCollection([]));
1097
- const [active, setActive] = useState(false);
1098
- const [visible, setVisible] = useState(false);
1099
- const [opened, setOpened] = useState(false);
1118
+ const [collection, setCollection] = useState(new ListCollection([]));
1100
1119
  const [value, setValue] = useState('');
1120
+ const [opened, setOpened] = useState(false);
1121
+ const [visible, setVisible] = useState(false);
1101
1122
  const [higher, setHigher] = useState(false);
1123
+ const [focused, setFocused] = useState(false);
1102
1124
  const [positionElement, setPositionElement] = useState(0);
1103
1125
  const [listElements, setListElements] = useState(undefined);
1104
1126
  useEffect(() => {
@@ -1122,7 +1144,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1122
1144
  setLocationList();
1123
1145
  }, [visible]);
1124
1146
  useEffect(() => {
1125
- setCollection(new ListFieldCollection(suggestions));
1147
+ setCollection(new ListCollection(suggestions));
1126
1148
  }, [suggestions]);
1127
1149
  function setLocationList() {
1128
1150
  if (boxContentRef?.current) {
@@ -1140,7 +1162,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1140
1162
  }
1141
1163
  break;
1142
1164
  case 'ArrowDown':
1143
- if (visible && (ignoreHigher || !higher)) {
1165
+ if (visible && (withHigher || !higher)) {
1144
1166
  navigationInputDown();
1145
1167
  }
1146
1168
  break;
@@ -1194,7 +1216,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1194
1216
  setPositionElement(newPosition);
1195
1217
  listElements?.item(newPosition).focus();
1196
1218
  }
1197
- else if (ignoreHigher || !higher) {
1219
+ else if (withHigher || !higher) {
1198
1220
  inputRef?.current?.focus();
1199
1221
  }
1200
1222
  }
@@ -1205,30 +1227,30 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1205
1227
  setPositionElement(newPosition);
1206
1228
  listElements?.item(newPosition).focus();
1207
1229
  }
1208
- else if (higher && !ignoreHigher) {
1230
+ else if (higher && !withHigher) {
1209
1231
  inputRef?.current?.focus();
1210
1232
  }
1211
1233
  }
1212
1234
  return {
1213
- active,
1214
1235
  boxContentRef,
1215
1236
  collection,
1237
+ focused,
1216
1238
  higher,
1217
1239
  inputRef,
1218
1240
  listRef,
1241
+ value,
1242
+ visible,
1219
1243
  navigationElement,
1220
1244
  navigationInput,
1221
- setActive,
1245
+ setFocused,
1222
1246
  setValue,
1223
- setVisible,
1224
- value,
1225
- visible
1247
+ setVisible
1226
1248
  };
1227
1249
  }
1228
1250
 
1229
1251
  const DURATION_ANIMATION$1 = 240;
1230
1252
  const MAX_ELEMENTS = 6;
1231
- function RlsAutocompleteField({ suggestions, children, disabled, formControl, hiddenIcon, onSearch, onSelect, onValue, placeholder, searching, rlsTheme }) {
1253
+ function useAutocompleteField({ suggestions, disabled, formControl, onSelect, onValue }) {
1232
1254
  const [pattern, setPattern] = useState('');
1233
1255
  const [coincidences, setCoincidences] = useState([]);
1234
1256
  const [store, setStore] = useState({
@@ -1236,7 +1258,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1236
1258
  coincidences: [],
1237
1259
  previous: null
1238
1260
  });
1239
- const { active, boxContentRef, higher, inputRef, listRef, collection, value, visible, setActive, setValue, setVisible, navigationElement, navigationInput } = useListControl({ suggestions, formControl, ignoreHigher: true });
1261
+ const listControl = useListControl({
1262
+ suggestions,
1263
+ formControl,
1264
+ withHigher: true
1265
+ });
1266
+ const { collection, inputRef, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
1240
1267
  const [changeInternal, setChangeInternal] = useState(false);
1241
1268
  useEffect(() => {
1242
1269
  filterSuggestions(pattern, true);
@@ -1254,7 +1281,7 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1254
1281
  redefineDescription();
1255
1282
  }, [collection]);
1256
1283
  function redefineDescription() {
1257
- const element = formControl?.state && collection.findElement(formControl?.state);
1284
+ const element = formControl?.state && collection.find(formControl?.state);
1258
1285
  setValue(element?.description || '');
1259
1286
  }
1260
1287
  function onClickControl() {
@@ -1264,10 +1291,10 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1264
1291
  }
1265
1292
  }
1266
1293
  function onFocusInput() {
1267
- setActive(true);
1294
+ setFocused(true);
1268
1295
  }
1269
1296
  function onBlurInput() {
1270
- setActive(false);
1297
+ setFocused(false);
1271
1298
  }
1272
1299
  function onKeydownInput(event) {
1273
1300
  switch (event.code) {
@@ -1296,12 +1323,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1296
1323
  function onClickBackdrop() {
1297
1324
  setVisible(false);
1298
1325
  }
1299
- function onClickItem(element) {
1326
+ function onClickElement(element) {
1300
1327
  return () => {
1301
1328
  onChange(element);
1302
1329
  };
1303
1330
  }
1304
- function onKeydownItem(element) {
1331
+ function onKeydownElement(element) {
1305
1332
  return (event) => {
1306
1333
  switch (event.code) {
1307
1334
  case 'Enter':
@@ -1332,8 +1359,8 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1332
1359
  function filterSuggestions(pattern, reboot = false) {
1333
1360
  if (pattern) {
1334
1361
  const store = reboot ? createStoreEmpty() : searchForPattern(pattern);
1335
- const filters = store?.coincidences || suggestions;
1336
- const coincidences = filters.filter((element) => element.hasCoincidence(pattern));
1362
+ const elements = store?.coincidences || suggestions;
1363
+ const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
1337
1364
  setCoincidences(coincidences.slice(0, MAX_ELEMENTS));
1338
1365
  setStore({
1339
1366
  coincidences,
@@ -1361,9 +1388,9 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1361
1388
  return newStore || rebootStore();
1362
1389
  }
1363
1390
  function rebootStore() {
1364
- const newStore = createStoreEmpty();
1365
- setStore(newStore);
1366
- return newStore;
1391
+ const store = createStoreEmpty();
1392
+ setStore(store);
1393
+ return store;
1367
1394
  }
1368
1395
  function createStoreEmpty() {
1369
1396
  return {
@@ -1372,19 +1399,46 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1372
1399
  previous: null
1373
1400
  };
1374
1401
  }
1375
- return (jsxs("div", { ref: boxContentRef, className: renderClassStatus('rls-box-field', {
1402
+ return {
1403
+ coincidences,
1404
+ listControl,
1405
+ pattern,
1406
+ onBlurInput,
1407
+ onClickAction,
1408
+ onClickBackdrop,
1409
+ onClickControl,
1410
+ onClickElement,
1411
+ onFocusInput,
1412
+ onKeydownElement,
1413
+ onKeydownInput,
1414
+ setPattern
1415
+ };
1416
+ }
1417
+
1418
+ function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
1419
+ const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useAutocompleteField({
1420
+ suggestions,
1421
+ disabled,
1422
+ formControl,
1423
+ onSelect,
1424
+ onValue
1425
+ });
1426
+ return (jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', {
1376
1427
  disabled,
1377
- active,
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 } }) => {
1428
+ focused: listControl.focused,
1429
+ selected: !!listControl.value
1430
+ }, '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', {
1431
+ visible: listControl.visible,
1432
+ hide: !listControl.visible,
1433
+ higher: listControl.higher
1434
+ }), 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
1435
  setPattern(value);
1385
1436
  }, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsx("button", { disabled: disabled || searching, onClick: () => {
1386
1437
  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: onClickItem(element), onKeyDown: onKeydownItem(element), children: jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title }) }, 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: "Selecci\u00F3n no disponible" }), jsx("p", { className: "caption-regular", children: "Lo sentimos, en el momento no hay elementos en el listado" })] }) }))] }) }), jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
1438
+ }, 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 })] })] }));
1439
+ }
1440
+ function RlsAutocompleteField(props) {
1441
+ return (jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1388
1442
  }
1389
1443
 
1390
1444
  function RlsCard({ children, outline, rlsTheme }) {
@@ -1423,7 +1477,7 @@ function useConfirmationService() {
1423
1477
  subtitle,
1424
1478
  title,
1425
1479
  approved: {
1426
- label: approved || 'Aceptar',
1480
+ label: approved || reactI18n('confirmationActionApproved'),
1427
1481
  onClick: () => {
1428
1482
  setVisible(false);
1429
1483
  resolve(ConfirmationResult.approved());
@@ -1656,7 +1710,7 @@ function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDat
1656
1710
  year,
1657
1711
  day,
1658
1712
  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: "Cancelar" }) }), jsx("div", { className: "rls-date-picker__actions--today", children: jsx(RlsButton, { type: "ghost", onClick: onToday, children: "Hoy" }) }), jsx("div", { className: "rls-date-picker__actions--ok", children: jsx(RlsButton, { type: "raised", onClick: onSelect, children: "Establecer" }) })] }) })] }));
1713
+ }), 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
1714
  }
1661
1715
 
1662
1716
  function RlsModal({ children, visible, rlsTheme }) {
@@ -1773,7 +1827,7 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
1773
1827
  month
1774
1828
  }), 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
1829
  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: "Cancelar" }) }), jsx("div", { className: "rls-date-range-picker__actions--ok", children: jsx(RlsButton, { type: "raised", onClick: onSelect, children: "Establecer" }) })] }) })] }));
1830
+ }), 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
1831
  }
1778
1832
 
1779
1833
  function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
@@ -1810,8 +1864,9 @@ function RlsFormNavigation({ children, visible, rlsTheme }) {
1810
1864
  return (jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsx("div", { className: "rls-form-navigation__body", children: children }) }));
1811
1865
  }
1812
1866
 
1813
- function RlsSelectField({ suggestions, children, disabled, formControl, onSelect, onValue, placeholder, rlsTheme }) {
1814
- const { active, boxContentRef, higher, inputRef, listRef, collection, value, visible, setActive, setValue, setVisible, navigationElement, navigationInput } = useListControl({ suggestions, formControl });
1867
+ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1868
+ const listControl = useListControl({ suggestions, formControl });
1869
+ const { collection, inputRef, visible, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
1815
1870
  const [changeInternal, setChangeInternal] = useState(false);
1816
1871
  useEffect(() => {
1817
1872
  if (!changeInternal) {
@@ -1823,16 +1878,16 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
1823
1878
  redefineDescription();
1824
1879
  }, [collection]);
1825
1880
  function redefineDescription() {
1826
- const element = formControl?.state && collection.findElement(formControl?.state);
1881
+ const element = formControl?.state && collection.find(formControl?.state);
1827
1882
  setValue(element?.description || '');
1828
1883
  }
1829
1884
  function onFocusInput() {
1830
- setActive(true);
1885
+ setFocused(true);
1831
1886
  }
1832
1887
  function onBlurInput() {
1833
- setActive(false);
1888
+ setFocused(false);
1834
1889
  }
1835
- function onClickInput() {
1890
+ function onClickControl() {
1836
1891
  setVisible(true);
1837
1892
  }
1838
1893
  function onKeydownInput(event) {
@@ -1864,12 +1919,12 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
1864
1919
  function onClickBackdrop() {
1865
1920
  setVisible(false);
1866
1921
  }
1867
- function onClickItem(element) {
1922
+ function onClickElement(element) {
1868
1923
  return () => {
1869
1924
  onChange(element);
1870
1925
  };
1871
1926
  }
1872
- function onKeydownItem(element) {
1927
+ function onKeydownElement(element) {
1873
1928
  return (event) => {
1874
1929
  switch (event.code) {
1875
1930
  case 'Enter':
@@ -1898,11 +1953,37 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
1898
1953
  onValue(value);
1899
1954
  }
1900
1955
  }
1901
- return (jsxs("div", { ref: boxContentRef, className: renderClassStatus('rls-box-field', { active, 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: inputRef, className: "rls-list-field__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: value, onFocus: onFocusInput, onBlur: onBlurInput, onClick: onClickInput, onKeyDown: onKeydownInput }), jsx("button", { className: renderClassStatus('rls-list-field__action', { visible }), 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', {
1902
- visible,
1903
- hide: !visible,
1904
- higher
1905
- }), children: [jsx("div", { className: "rls-list-field__suggestions__body", children: jsxs("ul", { ref: listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickItem(element), onKeyDown: onKeydownItem(element), children: jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title }) }, 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: "Selecci\u00F3n no disponible" }), jsx("p", { className: "caption-regular", children: "Lo sentimos, en el momento no hay elementos en el listado" })] }) }))] }) }), jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
1956
+ return {
1957
+ listControl,
1958
+ onBlurInput,
1959
+ onClickAction,
1960
+ onClickBackdrop,
1961
+ onClickInput: onClickControl,
1962
+ onClickElement,
1963
+ onFocusInput,
1964
+ onKeydownElement,
1965
+ onKeydownInput
1966
+ };
1967
+ }
1968
+
1969
+ function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
1970
+ const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useSelectField({
1971
+ suggestions,
1972
+ disabled,
1973
+ formControl,
1974
+ onSelect,
1975
+ onValue
1976
+ });
1977
+ 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', {
1978
+ visible: listControl.visible
1979
+ }), 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', {
1980
+ visible: listControl.visible,
1981
+ hide: !listControl.visible,
1982
+ higher: listControl.higher
1983
+ }), 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 })] })] }));
1984
+ }
1985
+ function RlsSelectField(props) {
1986
+ return (jsx(RlsSelectFieldTemplate, { ...props, render: (element) => (jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1906
1987
  }
1907
1988
 
1908
1989
  const DURATION_ANIMATION = 240;
@@ -1966,5 +2047,5 @@ function RlsApplication({ children }) {
1966
2047
  return (jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
1967
2048
  }
1968
2049
 
1969
- export { ConfirmationResult, DateRange, ListFieldCollection, RlsAmount, RlsApplication, RlsAutocompleteField, 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, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsSwitchLabel, RlsTabularText, RlsTextField, RlsToolbar, RlsYearPicker, renderClassStatus, useConfirmationService, useListControl, useSnackbarService };
2050
+ 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
2051
  //# sourceMappingURL=index.js.map