@rolster/react-components 18.15.8 → 18.15.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/assets/{index-6EQEC0IJ.css → index-l02yDX9t.css} +1 -1
- package/dist/cjs/index.js +112 -193
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-6EQEC0IJ.css → index-l02yDX9t.css} +1 -1
- package/dist/es/index.js +112 -193
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Input/Input.js +7 -9
- package/dist/esm/components/atoms/Input/Input.js.map +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.js +3 -7
- package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js +4 -8
- package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +3 -5
- package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
- package/dist/esm/components/atoms/InputText/InputText.js +3 -7
- package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js +8 -8
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.d.ts +4 -4
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js +1 -3
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js.map +1 -1
- package/dist/esm/components/molecules/PickerDay/PickerDay.js +1 -3
- package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +5 -1
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +5 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +2 -4
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js.map +1 -1
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +6 -4
- package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.css +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.js +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.d.ts +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js +3 -45
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +1 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +2 -6
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +1 -3
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js +3 -46
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +1 -1
- package/dist/esm/components/organisms/PickerDate/PickerDate.js +7 -16
- package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +4 -10
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
- package/dist/esm/hooks/ListControlHook.d.ts +4 -4
- package/dist/esm/hooks/ListControlHook.js +46 -10
- package/dist/esm/hooks/ListControlHook.js.map +1 -1
- package/dist/esm/i18n.d.ts +1 -2
- package/dist/esm/i18n.js +1 -2
- package/dist/esm/i18n.js.map +1 -1
- package/package.json +1 -1
|
@@ -1700,7 +1700,7 @@
|
|
|
1700
1700
|
}
|
|
1701
1701
|
.rls-confirmation__subtitle {
|
|
1702
1702
|
text-align: center;
|
|
1703
|
-
color: var(--rls-theme-color-
|
|
1703
|
+
color: var(--rls-theme-color-400);
|
|
1704
1704
|
font-weight: var(--rls-font-weight-bold);
|
|
1705
1705
|
font-size: var(--pvt-subtitle-font-size);
|
|
1706
1706
|
line-height: var(--pvt-subtitle-line-height);
|
package/dist/es/index.js
CHANGED
|
@@ -1418,14 +1418,12 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
|
1418
1418
|
|
|
1419
1419
|
function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
|
|
1420
1420
|
const [focused, setFocused] = useState(false);
|
|
1421
|
-
function onChange(event) {
|
|
1422
|
-
setValue(type === 'number' ? +event.target.value : event.target.value);
|
|
1423
|
-
}
|
|
1424
1421
|
function setValue(value) {
|
|
1425
1422
|
formControl?.setValue(value);
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1423
|
+
onValue && onValue(value);
|
|
1424
|
+
}
|
|
1425
|
+
function onChange(event) {
|
|
1426
|
+
setValue(type === 'number' ? +event.target.value : event.target.value);
|
|
1429
1427
|
}
|
|
1430
1428
|
function onFocus() {
|
|
1431
1429
|
formControl?.focus();
|
|
@@ -1436,44 +1434,34 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
|
|
|
1436
1434
|
setFocused(false);
|
|
1437
1435
|
}
|
|
1438
1436
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-input', {
|
|
1439
|
-
focused: formControl?.focused
|
|
1440
|
-
disabled: formControl?.disabled
|
|
1441
|
-
}), children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type
|
|
1437
|
+
focused: formControl?.focused ?? focused,
|
|
1438
|
+
disabled: formControl?.disabled ?? disabled
|
|
1439
|
+
}), children: [jsxRuntimeExports.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?.value ?? value ?? '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
|
|
1442
1440
|
}
|
|
1443
1441
|
|
|
1444
1442
|
function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value, onValue }) {
|
|
1445
1443
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
1446
1444
|
function onChange(value) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
}
|
|
1450
|
-
if (onValue) {
|
|
1451
|
-
onValue(value);
|
|
1452
|
-
}
|
|
1445
|
+
!formControl && setValueInput(value);
|
|
1446
|
+
onValue && onValue(value);
|
|
1453
1447
|
}
|
|
1454
|
-
return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value
|
|
1448
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
1455
1449
|
}
|
|
1456
1450
|
|
|
1457
1451
|
function RlsInputNumber({ disabled, formControl, placeholder, value, onValue }) {
|
|
1458
|
-
const [valueInput, setValueInput] = useState(value
|
|
1452
|
+
const [valueInput, setValueInput] = useState(value ?? 0);
|
|
1459
1453
|
function onChange(value) {
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
}
|
|
1463
|
-
if (onValue) {
|
|
1464
|
-
onValue(value);
|
|
1465
|
-
}
|
|
1454
|
+
!formControl && setValueInput(value);
|
|
1455
|
+
onValue && onValue(value);
|
|
1466
1456
|
}
|
|
1467
|
-
return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value
|
|
1457
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value ?? value ?? valueInput }) }));
|
|
1468
1458
|
}
|
|
1469
1459
|
|
|
1470
1460
|
function RlsInputPassword({ disabled, formControl, placeholder, type, onValue }) {
|
|
1471
1461
|
const [focused, setFocused] = useState(false);
|
|
1472
1462
|
function onChange(event) {
|
|
1473
1463
|
formControl?.setValue(event.target.value);
|
|
1474
|
-
|
|
1475
|
-
onValue(event.target.value);
|
|
1476
|
-
}
|
|
1464
|
+
onValue && onValue(event.target.value);
|
|
1477
1465
|
}
|
|
1478
1466
|
function onFocus() {
|
|
1479
1467
|
formControl?.focus();
|
|
@@ -1484,9 +1472,9 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
1484
1472
|
setFocused(false);
|
|
1485
1473
|
}
|
|
1486
1474
|
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-input-password', {
|
|
1487
|
-
focused: formControl?.focused
|
|
1475
|
+
focused: formControl?.focused ?? focused,
|
|
1488
1476
|
disabled
|
|
1489
|
-
}), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type
|
|
1477
|
+
}), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type ?? 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
1490
1478
|
}
|
|
1491
1479
|
|
|
1492
1480
|
function RlsInputSearch({ formControl, placeholder, onSearch }) {
|
|
@@ -1496,14 +1484,10 @@ function RlsInputSearch({ formControl, placeholder, onSearch }) {
|
|
|
1496
1484
|
function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
1497
1485
|
const [valueInput, setValueInput] = useState(value || '');
|
|
1498
1486
|
function onChange(value) {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
if (onValue) {
|
|
1503
|
-
onValue(value);
|
|
1504
|
-
}
|
|
1487
|
+
!formControl && setValueInput(value);
|
|
1488
|
+
onValue && onValue(value);
|
|
1505
1489
|
}
|
|
1506
|
-
return (jsxRuntimeExports.jsx("div", { className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value
|
|
1490
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value ?? value ?? valueInput }) }));
|
|
1507
1491
|
}
|
|
1508
1492
|
|
|
1509
1493
|
function RlsLabel({ children, rlsTheme }) {
|
|
@@ -1562,9 +1546,7 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
|
|
|
1562
1546
|
const [visible, setVisible] = useState(false);
|
|
1563
1547
|
useEffect(() => {
|
|
1564
1548
|
function onCloseMenu({ target }) {
|
|
1565
|
-
|
|
1566
|
-
setVisible(false);
|
|
1567
|
-
}
|
|
1549
|
+
!componentRef?.current?.contains(target) && setVisible(false);
|
|
1568
1550
|
}
|
|
1569
1551
|
document.addEventListener('click', onCloseMenu);
|
|
1570
1552
|
return () => {
|
|
@@ -1577,14 +1559,16 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
|
|
|
1577
1559
|
function onSelectAction(action) {
|
|
1578
1560
|
setAction(action);
|
|
1579
1561
|
setVisible(false);
|
|
1580
|
-
|
|
1581
|
-
onAction(action.value);
|
|
1582
|
-
}
|
|
1562
|
+
automatic && onAction(action.value);
|
|
1583
1563
|
}
|
|
1584
|
-
return (jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle", ref: componentRef, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__action", children: jsxRuntimeExports.jsx(RlsButton, { disabled: disabled, type: type, onClick: () =>
|
|
1564
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle", ref: componentRef, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__action", children: jsxRuntimeExports.jsx(RlsButton, { disabled: disabled, type: type, onClick: () => {
|
|
1565
|
+
onAction(action.value);
|
|
1566
|
+
}, children: action.label }) })), jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__icon", children: jsxRuntimeExports.jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-button-toggle__list', {
|
|
1585
1567
|
visible,
|
|
1586
1568
|
hide: !visible
|
|
1587
|
-
}), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () =>
|
|
1569
|
+
}), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => {
|
|
1570
|
+
onSelectAction(action);
|
|
1571
|
+
}, children: action.label }, index))) }) })] }));
|
|
1588
1572
|
}
|
|
1589
1573
|
|
|
1590
1574
|
function RlsMessageFormError({ className, formControl }) {
|
|
@@ -1652,9 +1636,7 @@ function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsThe
|
|
|
1652
1636
|
setChecked(formControl?.value === value);
|
|
1653
1637
|
}, [formControl?.value]);
|
|
1654
1638
|
function onSelect() {
|
|
1655
|
-
|
|
1656
|
-
formControl?.setValue(value);
|
|
1657
|
-
}
|
|
1639
|
+
formControl && formControl?.setValue(value);
|
|
1658
1640
|
}
|
|
1659
1641
|
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
|
|
1660
1642
|
disabled,
|
|
@@ -1765,9 +1747,7 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1765
1747
|
}
|
|
1766
1748
|
function onChange(value) {
|
|
1767
1749
|
setDayValue(value);
|
|
1768
|
-
|
|
1769
|
-
onValue(value);
|
|
1770
|
-
}
|
|
1750
|
+
onValue && onValue(value);
|
|
1771
1751
|
}
|
|
1772
1752
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-day__element', {
|
|
1773
1753
|
disabled: disabled || disabledPicker,
|
|
@@ -1809,7 +1789,11 @@ function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDat
|
|
|
1809
1789
|
forbidden,
|
|
1810
1790
|
ranged,
|
|
1811
1791
|
source
|
|
1812
|
-
}), onClick: value && !disabledPicker
|
|
1792
|
+
}), onClick: value && !disabledPicker
|
|
1793
|
+
? () => {
|
|
1794
|
+
onChange(value);
|
|
1795
|
+
}
|
|
1796
|
+
: undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1813
1797
|
}
|
|
1814
1798
|
|
|
1815
1799
|
function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
|
|
@@ -1849,7 +1833,11 @@ function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate,
|
|
|
1849
1833
|
disabled: disabled || disabledPicker,
|
|
1850
1834
|
focused,
|
|
1851
1835
|
selected
|
|
1852
|
-
}), onClick: !(disabled || disabledPicker)
|
|
1836
|
+
}), onClick: !(disabled || disabledPicker)
|
|
1837
|
+
? () => {
|
|
1838
|
+
onChange(value);
|
|
1839
|
+
}
|
|
1840
|
+
: undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
|
|
1853
1841
|
}
|
|
1854
1842
|
|
|
1855
1843
|
function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
|
|
@@ -1872,9 +1860,8 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
|
|
|
1872
1860
|
}
|
|
1873
1861
|
}
|
|
1874
1862
|
function onPreviousYear() {
|
|
1875
|
-
|
|
1863
|
+
itIsDefined(yearControl.value) &&
|
|
1876
1864
|
yearControl.setValue(yearControl.value - 1);
|
|
1877
|
-
}
|
|
1878
1865
|
}
|
|
1879
1866
|
function onPrevious() {
|
|
1880
1867
|
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
@@ -1891,9 +1878,8 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
|
|
|
1891
1878
|
}
|
|
1892
1879
|
}
|
|
1893
1880
|
function onNextYear() {
|
|
1894
|
-
|
|
1881
|
+
itIsDefined(yearControl.value) &&
|
|
1895
1882
|
yearControl.setValue(yearControl.value + 1);
|
|
1896
|
-
}
|
|
1897
1883
|
}
|
|
1898
1884
|
function onNext() {
|
|
1899
1885
|
type === 'month' ? onNextMonth() : onNextYear();
|
|
@@ -1939,15 +1925,17 @@ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, m
|
|
|
1939
1925
|
}
|
|
1940
1926
|
function onChange(value) {
|
|
1941
1927
|
setYearValue(value);
|
|
1942
|
-
|
|
1943
|
-
onValue(value);
|
|
1944
|
-
}
|
|
1928
|
+
onValue && onValue(value);
|
|
1945
1929
|
}
|
|
1946
1930
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabledPicker }) }), jsxRuntimeExports.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-year__year', {
|
|
1947
1931
|
disabled: disabled || disabledPicker,
|
|
1948
1932
|
focused,
|
|
1949
1933
|
selected
|
|
1950
|
-
}), onClick: value && !disabledPicker
|
|
1934
|
+
}), onClick: value && !disabledPicker
|
|
1935
|
+
? () => {
|
|
1936
|
+
onChange(value);
|
|
1937
|
+
}
|
|
1938
|
+
: undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1951
1939
|
}
|
|
1952
1940
|
|
|
1953
1941
|
function RlsToolbar({ actions, children, subtitle }) {
|
|
@@ -2078,18 +2066,19 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2078
2066
|
const listRef = useRef(null);
|
|
2079
2067
|
const inputRef = useRef(null);
|
|
2080
2068
|
const [state, setState] = useState({
|
|
2081
|
-
collection: new ListCollection([]),
|
|
2082
2069
|
focused: false,
|
|
2083
2070
|
higher: false,
|
|
2084
2071
|
value: '',
|
|
2085
2072
|
visible: false
|
|
2086
2073
|
});
|
|
2074
|
+
const collection = useRef(new ListCollection([]));
|
|
2087
2075
|
const position = useRef(0);
|
|
2076
|
+
const changeInternal = useRef(false);
|
|
2077
|
+
const protectedValue = useRef();
|
|
2088
2078
|
useEffect(() => {
|
|
2089
2079
|
function onCloseSuggestions({ target }) {
|
|
2090
|
-
|
|
2080
|
+
!contentRef?.current?.contains(target) &&
|
|
2091
2081
|
setState((state) => ({ ...state, visible: false }));
|
|
2092
|
-
}
|
|
2093
2082
|
}
|
|
2094
2083
|
document.addEventListener('click', onCloseSuggestions);
|
|
2095
2084
|
return () => {
|
|
@@ -2097,26 +2086,60 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2097
2086
|
};
|
|
2098
2087
|
}, []);
|
|
2099
2088
|
useEffect(() => {
|
|
2100
|
-
const content = contentRef.current;
|
|
2101
|
-
const list = listRef.current;
|
|
2102
2089
|
formControl?.touch();
|
|
2103
2090
|
setState((state) => ({
|
|
2104
2091
|
...state,
|
|
2105
|
-
higher: locationListCanTop(
|
|
2092
|
+
higher: locationListCanTop(contentRef.current, listRef.current)
|
|
2106
2093
|
}));
|
|
2107
2094
|
}, [state.visible]);
|
|
2108
2095
|
useEffect(() => {
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
}
|
|
2096
|
+
if (!changeInternal.current) {
|
|
2097
|
+
changeInternal.current = false;
|
|
2098
|
+
return;
|
|
2099
|
+
}
|
|
2100
|
+
refresh(collection.current, formControl?.value);
|
|
2101
|
+
}, [formControl?.value]);
|
|
2102
|
+
useEffect(() => {
|
|
2103
|
+
collection.current = new ListCollection(suggestions);
|
|
2104
|
+
refresh(collection.current, formControl?.value);
|
|
2113
2105
|
}, [suggestions]);
|
|
2106
|
+
function refresh(collection, state) {
|
|
2107
|
+
if (!state) {
|
|
2108
|
+
return refreshProtected(collection) ? undefined : setValue('');
|
|
2109
|
+
}
|
|
2110
|
+
const element = collection.find(state);
|
|
2111
|
+
if (element) {
|
|
2112
|
+
return setValue(element.description);
|
|
2113
|
+
}
|
|
2114
|
+
if (!refreshProtected(collection)) {
|
|
2115
|
+
protectedValue.current = state;
|
|
2116
|
+
setValue('');
|
|
2117
|
+
setFormState(undefined);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
function refreshProtected(collection) {
|
|
2121
|
+
if (protectedValue.current) {
|
|
2122
|
+
const element = collection.find(protectedValue.current);
|
|
2123
|
+
if (element) {
|
|
2124
|
+
formControl?.setValue(protectedValue.current);
|
|
2125
|
+
protectedValue.current = undefined;
|
|
2126
|
+
return true;
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
return false;
|
|
2130
|
+
}
|
|
2114
2131
|
function setFocused(focused) {
|
|
2115
2132
|
setState((state) => ({ ...state, focused }));
|
|
2116
2133
|
}
|
|
2117
2134
|
function setValue(value) {
|
|
2118
2135
|
setState((state) => ({ ...state, value }));
|
|
2119
2136
|
}
|
|
2137
|
+
function setFormState(value) {
|
|
2138
|
+
if (formControl) {
|
|
2139
|
+
changeInternal.current = true;
|
|
2140
|
+
formControl.setValue(value);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2120
2143
|
function setVisible(visible) {
|
|
2121
2144
|
setState((state) => ({ ...state, visible }));
|
|
2122
2145
|
}
|
|
@@ -2147,6 +2170,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
2147
2170
|
navigationElement,
|
|
2148
2171
|
navigationInput,
|
|
2149
2172
|
setFocused,
|
|
2173
|
+
setFormState,
|
|
2150
2174
|
setValue,
|
|
2151
2175
|
setVisible
|
|
2152
2176
|
};
|
|
@@ -2163,51 +2187,13 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2163
2187
|
previous: null
|
|
2164
2188
|
});
|
|
2165
2189
|
const listControl = useListControl({ suggestions, formControl });
|
|
2166
|
-
const {
|
|
2167
|
-
const initializedState = useRef(false);
|
|
2168
|
-
const initializedCollection = useRef(false);
|
|
2169
|
-
const changeInternal = useRef(false);
|
|
2190
|
+
const { inputRef, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
|
|
2170
2191
|
useEffect(() => {
|
|
2171
2192
|
refreshCoincidences(pattern, true);
|
|
2172
2193
|
}, [suggestions]);
|
|
2173
2194
|
useEffect(() => {
|
|
2174
2195
|
refreshCoincidences(pattern);
|
|
2175
2196
|
}, [pattern]);
|
|
2176
|
-
useEffect(() => {
|
|
2177
|
-
if (!initializedState.current || !initializedCollection.current) {
|
|
2178
|
-
initializedState.current = true;
|
|
2179
|
-
return;
|
|
2180
|
-
}
|
|
2181
|
-
if (changeInternal.current) {
|
|
2182
|
-
changeInternal.current = false;
|
|
2183
|
-
return;
|
|
2184
|
-
}
|
|
2185
|
-
refresh(collection, formControl?.value);
|
|
2186
|
-
}, [formControl?.value]);
|
|
2187
|
-
useEffect(() => {
|
|
2188
|
-
if (!initializedCollection.current || !initializedState.current) {
|
|
2189
|
-
initializedCollection.current = true;
|
|
2190
|
-
return;
|
|
2191
|
-
}
|
|
2192
|
-
refresh(collection, formControl?.value);
|
|
2193
|
-
}, [collection]);
|
|
2194
|
-
function refresh(collection, state) {
|
|
2195
|
-
if (!state) {
|
|
2196
|
-
return setValue('');
|
|
2197
|
-
}
|
|
2198
|
-
const element = collection.find(state);
|
|
2199
|
-
if (element) {
|
|
2200
|
-
return setValue(element.description);
|
|
2201
|
-
}
|
|
2202
|
-
setValue('');
|
|
2203
|
-
setFormState(undefined);
|
|
2204
|
-
}
|
|
2205
|
-
function setFormState(value) {
|
|
2206
|
-
if (formControl) {
|
|
2207
|
-
changeInternal.current = true;
|
|
2208
|
-
formControl.setValue(value);
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
2197
|
function onClickControl() {
|
|
2212
2198
|
if (!disabled) {
|
|
2213
2199
|
setVisible(true);
|
|
@@ -2237,9 +2223,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2237
2223
|
setVisible(false);
|
|
2238
2224
|
setValue('');
|
|
2239
2225
|
setFormState(undefined);
|
|
2240
|
-
|
|
2241
|
-
onValue(undefined);
|
|
2242
|
-
}
|
|
2226
|
+
onValue && onValue(undefined);
|
|
2243
2227
|
}
|
|
2244
2228
|
function onClickBackdrop() {
|
|
2245
2229
|
setVisible(false);
|
|
@@ -2263,9 +2247,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2263
2247
|
setFormState(value);
|
|
2264
2248
|
setValue(description);
|
|
2265
2249
|
}
|
|
2266
|
-
|
|
2267
|
-
onValue(value);
|
|
2268
|
-
}
|
|
2250
|
+
onValue && onValue(value);
|
|
2269
2251
|
}
|
|
2270
2252
|
function refreshCoincidences(pattern, reboot = false) {
|
|
2271
2253
|
const { collection, store } = createAutocompleteStore({
|
|
@@ -2350,19 +2332,16 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2350
2332
|
formControl?.setValue(dateCheck);
|
|
2351
2333
|
}, []);
|
|
2352
2334
|
useEffect(() => {
|
|
2353
|
-
|
|
2335
|
+
itIsDefined(yearControl.value) &&
|
|
2354
2336
|
setValue(assignYearInDate(value, yearControl.value));
|
|
2355
|
-
}
|
|
2356
2337
|
}, [yearControl.value]);
|
|
2357
2338
|
useEffect(() => {
|
|
2358
|
-
|
|
2339
|
+
itIsDefined(monthControl.value) &&
|
|
2359
2340
|
setValue(assignMonthInDate(value, monthControl.value));
|
|
2360
|
-
}
|
|
2361
2341
|
}, [monthControl.value]);
|
|
2362
2342
|
useEffect(() => {
|
|
2363
|
-
|
|
2343
|
+
itIsDefined(dayControl.value) &&
|
|
2364
2344
|
setValue(assignDayInDate(value, dayControl.value));
|
|
2365
|
-
}
|
|
2366
2345
|
}, [dayControl.value]);
|
|
2367
2346
|
function onVisibilityDay() {
|
|
2368
2347
|
setVisibility('DAY');
|
|
@@ -2374,24 +2353,18 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2374
2353
|
setVisibility('YEAR');
|
|
2375
2354
|
}
|
|
2376
2355
|
function onCancel() {
|
|
2377
|
-
|
|
2378
|
-
onListener({ type: PickerListenerType.Cancel });
|
|
2379
|
-
}
|
|
2356
|
+
onListener && onListener({ type: PickerListenerType.Cancel });
|
|
2380
2357
|
}
|
|
2381
2358
|
function onToday() {
|
|
2382
2359
|
yearControl.setValue(today.getFullYear());
|
|
2383
2360
|
dayControl.setValue(today.getDate());
|
|
2384
2361
|
monthControl.setValue(today.getMonth());
|
|
2385
2362
|
formControl?.setValue(today);
|
|
2386
|
-
|
|
2387
|
-
onListener({ type: PickerListenerType.Now, value: today });
|
|
2388
|
-
}
|
|
2363
|
+
onListener && onListener({ type: PickerListenerType.Now, value: today });
|
|
2389
2364
|
}
|
|
2390
2365
|
function onSelect() {
|
|
2391
2366
|
formControl?.setValue(value);
|
|
2392
|
-
|
|
2393
|
-
onListener({ type: PickerListenerType.Select, value });
|
|
2394
|
-
}
|
|
2367
|
+
onListener && onListener({ type: PickerListenerType.Select, value });
|
|
2395
2368
|
}
|
|
2396
2369
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial, FORMAT_TITLE) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-picker-date__component', {
|
|
2397
2370
|
day: visibility === 'DAY',
|
|
@@ -2416,9 +2389,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
|
|
|
2416
2389
|
}, []);
|
|
2417
2390
|
function onChange(value) {
|
|
2418
2391
|
setValue(value);
|
|
2419
|
-
|
|
2420
|
-
onValue(value);
|
|
2421
|
-
}
|
|
2392
|
+
onValue && onValue(value);
|
|
2422
2393
|
}
|
|
2423
2394
|
function onClickInput() {
|
|
2424
2395
|
setModalIsVisible(true);
|
|
@@ -2437,9 +2408,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
|
|
|
2437
2408
|
? dateFormatTemplate(value, format || FORMAT_DATE)
|
|
2438
2409
|
: '';
|
|
2439
2410
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date__control", type: "text", value: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
2440
|
-
|
|
2441
|
-
onChange(value);
|
|
2442
|
-
}
|
|
2411
|
+
type !== PickerListenerType.Cancel && onChange(value);
|
|
2443
2412
|
formControl?.touch();
|
|
2444
2413
|
setModalIsVisible(false);
|
|
2445
2414
|
} }) })] }));
|
|
@@ -2469,9 +2438,7 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2469
2438
|
});
|
|
2470
2439
|
}, [monthControl.value]);
|
|
2471
2440
|
useEffect(() => {
|
|
2472
|
-
|
|
2473
|
-
setValue(dayControl.value);
|
|
2474
|
-
}
|
|
2441
|
+
dayControl.value && setValue(dayControl.value);
|
|
2475
2442
|
setVisibility('DAY');
|
|
2476
2443
|
}, [dayControl.value]);
|
|
2477
2444
|
function onVisibilityDay() {
|
|
@@ -2484,15 +2451,11 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2484
2451
|
setVisibility('YEAR');
|
|
2485
2452
|
}
|
|
2486
2453
|
function onCancel() {
|
|
2487
|
-
|
|
2488
|
-
onListener({ type: PickerListenerType.Cancel });
|
|
2489
|
-
}
|
|
2454
|
+
onListener && onListener({ type: PickerListenerType.Cancel });
|
|
2490
2455
|
}
|
|
2491
2456
|
function onSelect() {
|
|
2492
2457
|
formControl?.setValue(value);
|
|
2493
|
-
|
|
2494
|
-
onListener({ type: PickerListenerType.Select, value });
|
|
2495
|
-
}
|
|
2458
|
+
onListener && onListener({ type: PickerListenerType.Select, value });
|
|
2496
2459
|
}
|
|
2497
2460
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-picker-date-range__component', {
|
|
2498
2461
|
day: visibility === 'DAY',
|
|
@@ -2521,54 +2484,14 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2521
2484
|
}
|
|
2522
2485
|
}
|
|
2523
2486
|
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date-range__control", type: "text", value: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
2524
|
-
|
|
2525
|
-
setValue(value);
|
|
2526
|
-
}
|
|
2487
|
+
value && setValue(value);
|
|
2527
2488
|
setModalIsVisible(false);
|
|
2528
2489
|
} }) })] }));
|
|
2529
2490
|
}
|
|
2530
2491
|
|
|
2531
2492
|
function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
2532
2493
|
const listControl = useListControl({ suggestions, formControl });
|
|
2533
|
-
const {
|
|
2534
|
-
const initializedState = useRef(false);
|
|
2535
|
-
const initializedCollection = useRef(false);
|
|
2536
|
-
const changeInternal = useRef(false);
|
|
2537
|
-
useEffect(() => {
|
|
2538
|
-
if (!initializedState.current || !initializedCollection.current) {
|
|
2539
|
-
initializedState.current = true;
|
|
2540
|
-
return;
|
|
2541
|
-
}
|
|
2542
|
-
if (changeInternal.current) {
|
|
2543
|
-
changeInternal.current = false;
|
|
2544
|
-
return;
|
|
2545
|
-
}
|
|
2546
|
-
refresh(collection, formControl?.value);
|
|
2547
|
-
}, [formControl?.value]);
|
|
2548
|
-
useEffect(() => {
|
|
2549
|
-
if (!initializedCollection.current || !initializedState.current) {
|
|
2550
|
-
initializedCollection.current = true;
|
|
2551
|
-
return;
|
|
2552
|
-
}
|
|
2553
|
-
refresh(collection, formControl?.value);
|
|
2554
|
-
}, [collection]);
|
|
2555
|
-
function refresh(collection, state) {
|
|
2556
|
-
if (!state) {
|
|
2557
|
-
return setValue('');
|
|
2558
|
-
}
|
|
2559
|
-
const element = collection.find(state);
|
|
2560
|
-
if (element) {
|
|
2561
|
-
return setValue(element.description);
|
|
2562
|
-
}
|
|
2563
|
-
setValue('');
|
|
2564
|
-
setFormState(undefined);
|
|
2565
|
-
}
|
|
2566
|
-
function setFormState(value) {
|
|
2567
|
-
if (formControl) {
|
|
2568
|
-
changeInternal.current = true;
|
|
2569
|
-
formControl.setValue(value);
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2494
|
+
const { inputRef, visible, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
|
|
2572
2495
|
function onFocusInput() {
|
|
2573
2496
|
setFocused(true);
|
|
2574
2497
|
}
|
|
@@ -2595,9 +2518,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2595
2518
|
}
|
|
2596
2519
|
function onClickAction() {
|
|
2597
2520
|
setVisible(!visible);
|
|
2598
|
-
|
|
2599
|
-
inputRef?.current?.focus();
|
|
2600
|
-
}
|
|
2521
|
+
!visible && inputRef?.current?.focus();
|
|
2601
2522
|
}
|
|
2602
2523
|
function onClickBackdrop() {
|
|
2603
2524
|
setVisible(false);
|
|
@@ -2622,9 +2543,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2622
2543
|
setFormState(value);
|
|
2623
2544
|
setValue(description);
|
|
2624
2545
|
}
|
|
2625
|
-
|
|
2626
|
-
onValue(value);
|
|
2627
|
-
}
|
|
2546
|
+
onValue && onValue(value);
|
|
2628
2547
|
}
|
|
2629
2548
|
return {
|
|
2630
2549
|
listControl,
|