@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/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');
@@ -380,13 +381,13 @@ function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, mi
380
381
  }, children: jsxRuntime.jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
381
382
  }
382
383
 
383
- const FORMAT_DESCRIPTION$1 = '{dd}/{mm}/{aa}';
384
- class ListFieldCollection {
384
+ const DATE_FORMAT = '{dd}/{mm}/{aa}';
385
+ class ListCollection {
385
386
  constructor(value) {
386
387
  this.value = value;
387
388
  }
388
- findElement(value) {
389
- return this.value.find((element) => element.compareTo(value));
389
+ find(element) {
390
+ return this.value.find((current) => current.compareTo(element));
390
391
  }
391
392
  }
392
393
  class DateRange {
@@ -398,8 +399,8 @@ class DateRange {
398
399
  else {
399
400
  this.maxDate = helpersDate.normalizeMinTime(minDate);
400
401
  }
401
- const minFormat = helpersDate.formatDate(this.minDate, FORMAT_DESCRIPTION$1);
402
- const maxFormat = helpersDate.formatDate(this.maxDate, FORMAT_DESCRIPTION$1);
402
+ const minFormat = helpersDate.formatDate(this.minDate, DATE_FORMAT);
403
+ const maxFormat = helpersDate.formatDate(this.maxDate, DATE_FORMAT);
403
404
  this.description = `${minFormat} - ${maxFormat}`;
404
405
  }
405
406
  recalculate(date) {
@@ -1084,6 +1085,27 @@ function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxD
1084
1085
  }, children: jsxRuntime.jsx("span", { className: "rls-year-picker__year__span body1-medium", children: value || '????' }) }, index))) })] }));
1085
1086
  }
1086
1087
 
1088
+ const reactI18n = i18n.i18n({
1089
+ es: {
1090
+ confirmationActionApproved: 'Aceptar',
1091
+ dateActionCancel: 'Cancelar',
1092
+ dateActionSelect: 'Establecer',
1093
+ dateActionToday: 'Hoy',
1094
+ listEmptyDescription: 'Lo sentimos, en el momento no hay elementos en el listado',
1095
+ listEmptyTitle: 'Selección no disponible',
1096
+ listInputPlaceholder: 'Buscar...'
1097
+ },
1098
+ en: {
1099
+ confirmationActionApproved: 'Approved',
1100
+ dateActionCancel: 'Cancel',
1101
+ dateActionSelect: 'Select',
1102
+ dateActionToday: 'Today',
1103
+ listEmptyDescription: 'Sorry, there are currently no items in the list',
1104
+ listEmptyTitle: 'Selection not available',
1105
+ listInputPlaceholder: 'Search...'
1106
+ }
1107
+ });
1108
+
1087
1109
  const classElement = '.rls-list-field__element';
1088
1110
  const MAX_POSITION_VISIBLE = 4;
1089
1111
  const LIST_SIZE_REM = 16;
@@ -1091,16 +1113,16 @@ const ELEMENT_SIZE_REM = 4;
1091
1113
  const BASE_SIZE_PX = 16;
1092
1114
  const ELEMENT_SIZE_PX = BASE_SIZE_PX * ELEMENT_SIZE_REM;
1093
1115
  const MAZ_LIST_SIZE_PX = BASE_SIZE_PX * LIST_SIZE_REM;
1094
- function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1116
+ function useListControl({ suggestions, formControl, withHigher = false }) {
1095
1117
  const boxContentRef = react.useRef(null);
1096
1118
  const listRef = react.useRef(null);
1097
1119
  const inputRef = react.useRef(null);
1098
- const [collection, setCollection] = react.useState(new ListFieldCollection([]));
1099
- const [active, setActive] = react.useState(false);
1100
- const [visible, setVisible] = react.useState(false);
1101
- const [opened, setOpened] = react.useState(false);
1120
+ const [collection, setCollection] = react.useState(new ListCollection([]));
1102
1121
  const [value, setValue] = react.useState('');
1122
+ const [opened, setOpened] = react.useState(false);
1123
+ const [visible, setVisible] = react.useState(false);
1103
1124
  const [higher, setHigher] = react.useState(false);
1125
+ const [focused, setFocused] = react.useState(false);
1104
1126
  const [positionElement, setPositionElement] = react.useState(0);
1105
1127
  const [listElements, setListElements] = react.useState(undefined);
1106
1128
  react.useEffect(() => {
@@ -1124,7 +1146,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1124
1146
  setLocationList();
1125
1147
  }, [visible]);
1126
1148
  react.useEffect(() => {
1127
- setCollection(new ListFieldCollection(suggestions));
1149
+ setCollection(new ListCollection(suggestions));
1128
1150
  }, [suggestions]);
1129
1151
  function setLocationList() {
1130
1152
  if (boxContentRef?.current) {
@@ -1142,7 +1164,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1142
1164
  }
1143
1165
  break;
1144
1166
  case 'ArrowDown':
1145
- if (visible && (ignoreHigher || !higher)) {
1167
+ if (visible && (withHigher || !higher)) {
1146
1168
  navigationInputDown();
1147
1169
  }
1148
1170
  break;
@@ -1196,7 +1218,7 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1196
1218
  setPositionElement(newPosition);
1197
1219
  listElements?.item(newPosition).focus();
1198
1220
  }
1199
- else if (ignoreHigher || !higher) {
1221
+ else if (withHigher || !higher) {
1200
1222
  inputRef?.current?.focus();
1201
1223
  }
1202
1224
  }
@@ -1207,30 +1229,30 @@ function useListControl({ suggestions, formControl, ignoreHigher = false }) {
1207
1229
  setPositionElement(newPosition);
1208
1230
  listElements?.item(newPosition).focus();
1209
1231
  }
1210
- else if (higher && !ignoreHigher) {
1232
+ else if (higher && !withHigher) {
1211
1233
  inputRef?.current?.focus();
1212
1234
  }
1213
1235
  }
1214
1236
  return {
1215
- active,
1216
1237
  boxContentRef,
1217
1238
  collection,
1239
+ focused,
1218
1240
  higher,
1219
1241
  inputRef,
1220
1242
  listRef,
1243
+ value,
1244
+ visible,
1221
1245
  navigationElement,
1222
1246
  navigationInput,
1223
- setActive,
1247
+ setFocused,
1224
1248
  setValue,
1225
- setVisible,
1226
- value,
1227
- visible
1249
+ setVisible
1228
1250
  };
1229
1251
  }
1230
1252
 
1231
1253
  const DURATION_ANIMATION$1 = 240;
1232
1254
  const MAX_ELEMENTS = 6;
1233
- function RlsAutocompleteField({ suggestions, children, disabled, formControl, hiddenIcon, onSearch, onSelect, onValue, placeholder, searching, rlsTheme }) {
1255
+ function useAutocompleteField({ suggestions, disabled, formControl, onSelect, onValue }) {
1234
1256
  const [pattern, setPattern] = react.useState('');
1235
1257
  const [coincidences, setCoincidences] = react.useState([]);
1236
1258
  const [store, setStore] = react.useState({
@@ -1238,7 +1260,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1238
1260
  coincidences: [],
1239
1261
  previous: null
1240
1262
  });
1241
- const { active, boxContentRef, higher, inputRef, listRef, collection, value, visible, setActive, setValue, setVisible, navigationElement, navigationInput } = useListControl({ suggestions, formControl, ignoreHigher: true });
1263
+ const listControl = useListControl({
1264
+ suggestions,
1265
+ formControl,
1266
+ withHigher: true
1267
+ });
1268
+ const { collection, inputRef, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
1242
1269
  const [changeInternal, setChangeInternal] = react.useState(false);
1243
1270
  react.useEffect(() => {
1244
1271
  filterSuggestions(pattern, true);
@@ -1256,7 +1283,7 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1256
1283
  redefineDescription();
1257
1284
  }, [collection]);
1258
1285
  function redefineDescription() {
1259
- const element = formControl?.state && collection.findElement(formControl?.state);
1286
+ const element = formControl?.state && collection.find(formControl?.state);
1260
1287
  setValue(element?.description || '');
1261
1288
  }
1262
1289
  function onClickControl() {
@@ -1266,10 +1293,10 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1266
1293
  }
1267
1294
  }
1268
1295
  function onFocusInput() {
1269
- setActive(true);
1296
+ setFocused(true);
1270
1297
  }
1271
1298
  function onBlurInput() {
1272
- setActive(false);
1299
+ setFocused(false);
1273
1300
  }
1274
1301
  function onKeydownInput(event) {
1275
1302
  switch (event.code) {
@@ -1298,12 +1325,12 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1298
1325
  function onClickBackdrop() {
1299
1326
  setVisible(false);
1300
1327
  }
1301
- function onClickItem(element) {
1328
+ function onClickElement(element) {
1302
1329
  return () => {
1303
1330
  onChange(element);
1304
1331
  };
1305
1332
  }
1306
- function onKeydownItem(element) {
1333
+ function onKeydownElement(element) {
1307
1334
  return (event) => {
1308
1335
  switch (event.code) {
1309
1336
  case 'Enter':
@@ -1334,8 +1361,8 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1334
1361
  function filterSuggestions(pattern, reboot = false) {
1335
1362
  if (pattern) {
1336
1363
  const store = reboot ? createStoreEmpty() : searchForPattern(pattern);
1337
- const filters = store?.coincidences || suggestions;
1338
- const coincidences = filters.filter((element) => element.hasCoincidence(pattern));
1364
+ const elements = store?.coincidences || suggestions;
1365
+ const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
1339
1366
  setCoincidences(coincidences.slice(0, MAX_ELEMENTS));
1340
1367
  setStore({
1341
1368
  coincidences,
@@ -1363,9 +1390,9 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1363
1390
  return newStore || rebootStore();
1364
1391
  }
1365
1392
  function rebootStore() {
1366
- const newStore = createStoreEmpty();
1367
- setStore(newStore);
1368
- return newStore;
1393
+ const store = createStoreEmpty();
1394
+ setStore(store);
1395
+ return store;
1369
1396
  }
1370
1397
  function createStoreEmpty() {
1371
1398
  return {
@@ -1374,19 +1401,46 @@ function RlsAutocompleteField({ suggestions, children, disabled, formControl, hi
1374
1401
  previous: null
1375
1402
  };
1376
1403
  }
1377
- return (jsxRuntime.jsxs("div", { ref: boxContentRef, className: renderClassStatus('rls-box-field', {
1404
+ return {
1405
+ coincidences,
1406
+ listControl,
1407
+ pattern,
1408
+ onBlurInput,
1409
+ onClickAction,
1410
+ onClickBackdrop,
1411
+ onClickControl,
1412
+ onClickElement,
1413
+ onFocusInput,
1414
+ onKeydownElement,
1415
+ onKeydownInput,
1416
+ setPattern
1417
+ };
1418
+ }
1419
+
1420
+ function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
1421
+ const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useAutocompleteField({
1422
+ suggestions,
1423
+ disabled,
1424
+ formControl,
1425
+ onSelect,
1426
+ onValue
1427
+ });
1428
+ return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', {
1378
1429
  disabled,
1379
- active,
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 } }) => {
1430
+ focused: listControl.focused,
1431
+ selected: !!listControl.value
1432
+ }, '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', {
1433
+ visible: listControl.visible,
1434
+ hide: !listControl.visible,
1435
+ higher: listControl.higher
1436
+ }), 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
1437
  setPattern(value);
1387
1438
  }, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntime.jsx("button", { disabled: disabled || searching, onClick: () => {
1388
1439
  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: onClickItem(element), onKeyDown: onKeydownItem(element), children: jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title }) }, 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: "Selecci\u00F3n no disponible" }), jsxRuntime.jsx("p", { className: "caption-regular", children: "Lo sentimos, en el momento no hay elementos en el listado" })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
1440
+ }, 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 })] })] }));
1441
+ }
1442
+ function RlsAutocompleteField(props) {
1443
+ return (jsxRuntime.jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1390
1444
  }
1391
1445
 
1392
1446
  function RlsCard({ children, outline, rlsTheme }) {
@@ -1425,7 +1479,7 @@ function useConfirmationService() {
1425
1479
  subtitle,
1426
1480
  title,
1427
1481
  approved: {
1428
- label: approved || 'Aceptar',
1482
+ label: approved || reactI18n('confirmationActionApproved'),
1429
1483
  onClick: () => {
1430
1484
  setVisible(false);
1431
1485
  resolve(ConfirmationResult.approved());
@@ -1658,7 +1712,7 @@ function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDat
1658
1712
  year,
1659
1713
  day,
1660
1714
  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: "Cancelar" }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--today", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onToday, children: "Hoy" }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: "Establecer" }) })] }) })] }));
1715
+ }), 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
1716
  }
1663
1717
 
1664
1718
  function RlsModal({ children, visible, rlsTheme }) {
@@ -1775,7 +1829,7 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
1775
1829
  month
1776
1830
  }), 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
1831
  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: "Cancelar" }) }), jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: "Establecer" }) })] }) })] }));
1832
+ }), 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
1833
  }
1780
1834
 
1781
1835
  function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
@@ -1812,8 +1866,9 @@ function RlsFormNavigation({ children, visible, rlsTheme }) {
1812
1866
  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
1867
  }
1814
1868
 
1815
- function RlsSelectField({ suggestions, children, disabled, formControl, onSelect, onValue, placeholder, rlsTheme }) {
1816
- const { active, boxContentRef, higher, inputRef, listRef, collection, value, visible, setActive, setValue, setVisible, navigationElement, navigationInput } = useListControl({ suggestions, formControl });
1869
+ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1870
+ const listControl = useListControl({ suggestions, formControl });
1871
+ const { collection, inputRef, visible, setFocused, setValue, setVisible, navigationElement, navigationInput } = listControl;
1817
1872
  const [changeInternal, setChangeInternal] = react.useState(false);
1818
1873
  react.useEffect(() => {
1819
1874
  if (!changeInternal) {
@@ -1825,16 +1880,16 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
1825
1880
  redefineDescription();
1826
1881
  }, [collection]);
1827
1882
  function redefineDescription() {
1828
- const element = formControl?.state && collection.findElement(formControl?.state);
1883
+ const element = formControl?.state && collection.find(formControl?.state);
1829
1884
  setValue(element?.description || '');
1830
1885
  }
1831
1886
  function onFocusInput() {
1832
- setActive(true);
1887
+ setFocused(true);
1833
1888
  }
1834
1889
  function onBlurInput() {
1835
- setActive(false);
1890
+ setFocused(false);
1836
1891
  }
1837
- function onClickInput() {
1892
+ function onClickControl() {
1838
1893
  setVisible(true);
1839
1894
  }
1840
1895
  function onKeydownInput(event) {
@@ -1866,12 +1921,12 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
1866
1921
  function onClickBackdrop() {
1867
1922
  setVisible(false);
1868
1923
  }
1869
- function onClickItem(element) {
1924
+ function onClickElement(element) {
1870
1925
  return () => {
1871
1926
  onChange(element);
1872
1927
  };
1873
1928
  }
1874
- function onKeydownItem(element) {
1929
+ function onKeydownElement(element) {
1875
1930
  return (event) => {
1876
1931
  switch (event.code) {
1877
1932
  case 'Enter':
@@ -1900,11 +1955,37 @@ function RlsSelectField({ suggestions, children, disabled, formControl, onSelect
1900
1955
  onValue(value);
1901
1956
  }
1902
1957
  }
1903
- return (jsxRuntime.jsxs("div", { ref: boxContentRef, className: renderClassStatus('rls-box-field', { active, 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: inputRef, className: "rls-list-field__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: value, onFocus: onFocusInput, onBlur: onBlurInput, onClick: onClickInput, onKeyDown: onKeydownInput }), jsxRuntime.jsx("button", { className: renderClassStatus('rls-list-field__action', { visible }), 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', {
1904
- visible,
1905
- hide: !visible,
1906
- higher
1907
- }), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickItem(element), onKeyDown: onKeydownItem(element), children: jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title }) }, 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: "Selecci\u00F3n no disponible" }), jsxRuntime.jsx("p", { className: "caption-regular", children: "Lo sentimos, en el momento no hay elementos en el listado" })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
1958
+ return {
1959
+ listControl,
1960
+ onBlurInput,
1961
+ onClickAction,
1962
+ onClickBackdrop,
1963
+ onClickInput: onClickControl,
1964
+ onClickElement,
1965
+ onFocusInput,
1966
+ onKeydownElement,
1967
+ onKeydownInput
1968
+ };
1969
+ }
1970
+
1971
+ function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
1972
+ const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useSelectField({
1973
+ suggestions,
1974
+ disabled,
1975
+ formControl,
1976
+ onSelect,
1977
+ onValue
1978
+ });
1979
+ 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', {
1980
+ visible: listControl.visible
1981
+ }), 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', {
1982
+ visible: listControl.visible,
1983
+ hide: !listControl.visible,
1984
+ higher: listControl.higher
1985
+ }), 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 })] })] }));
1986
+ }
1987
+ function RlsSelectField(props) {
1988
+ return (jsxRuntime.jsx(RlsSelectFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1908
1989
  }
1909
1990
 
1910
1991
  const DURATION_ANIMATION = 240;
@@ -1970,10 +2051,11 @@ function RlsApplication({ children }) {
1970
2051
 
1971
2052
  exports.ConfirmationResult = ConfirmationResult;
1972
2053
  exports.DateRange = DateRange;
1973
- exports.ListFieldCollection = ListFieldCollection;
2054
+ exports.ListCollection = ListCollection;
1974
2055
  exports.RlsAmount = RlsAmount;
1975
2056
  exports.RlsApplication = RlsApplication;
1976
2057
  exports.RlsAutocompleteField = RlsAutocompleteField;
2058
+ exports.RlsAutocompleteFieldTemplate = RlsAutocompleteFieldTemplate;
1977
2059
  exports.RlsAvatar = RlsAvatar;
1978
2060
  exports.RlsBallot = RlsBallot;
1979
2061
  exports.RlsBreadcrumb = RlsBreadcrumb;
@@ -2019,6 +2101,7 @@ exports.RlsRadioButton = RlsRadioButton;
2019
2101
  exports.RlsRadioButtonLabel = RlsRadioButtonLabel;
2020
2102
  exports.RlsSearchInput = RlsSearchInput;
2021
2103
  exports.RlsSelectField = RlsSelectField;
2104
+ exports.RlsSelectFieldTemplate = RlsSelectFieldTemplate;
2022
2105
  exports.RlsSkeleton = RlsSkeleton;
2023
2106
  exports.RlsSkeletonText = RlsSkeletonText;
2024
2107
  exports.RlsSnackbar = RlsSnackbar;