@rolster/react-components 19.6.4 → 19.6.9

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 (139) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/index.cjs +851 -595
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/es/index.mjs +851 -597
  5. package/dist/es/index.mjs.map +1 -1
  6. package/dist/esm/components/atoms/AreaText/AreaText.js +6 -2
  7. package/dist/esm/components/atoms/AreaText/AreaText.js.map +1 -1
  8. package/dist/esm/components/atoms/ButtonAction/ButtonAction.d.ts +1 -1
  9. package/dist/esm/components/atoms/ButtonAction/ButtonAction.js +1 -1
  10. package/dist/esm/components/atoms/ButtonAction/ButtonAction.js.map +1 -1
  11. package/dist/esm/components/atoms/CheckBox/CheckBox.d.ts +1 -1
  12. package/dist/esm/components/atoms/Input/Input.js +6 -2
  13. package/dist/esm/components/atoms/Input/Input.js.map +1 -1
  14. package/dist/esm/components/atoms/InputCounter/InputCounter.js +5 -3
  15. package/dist/esm/components/atoms/InputCounter/InputCounter.js.map +1 -1
  16. package/dist/esm/components/atoms/InputDecimal/InputDecimal.js +6 -1
  17. package/dist/esm/components/atoms/InputDecimal/InputDecimal.js.map +1 -1
  18. package/dist/esm/components/atoms/InputMoney/InputMoney.js +3 -1
  19. package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
  20. package/dist/esm/components/atoms/InputNumber/InputNumber.js +3 -1
  21. package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
  22. package/dist/esm/components/atoms/InputPassword/InputPassword.js +3 -1
  23. package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
  24. package/dist/esm/components/atoms/InputPercentage/InputPercentage.js +3 -1
  25. package/dist/esm/components/atoms/InputPercentage/InputPercentage.js.map +1 -1
  26. package/dist/esm/components/atoms/InputSearch/InputSearch.d.ts +1 -1
  27. package/dist/esm/components/atoms/InputSearch/InputSearch.js +3 -1
  28. package/dist/esm/components/atoms/InputSearch/InputSearch.js.map +1 -1
  29. package/dist/esm/components/atoms/InputText/InputText.js +3 -1
  30. package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
  31. package/dist/esm/components/atoms/Led/Led.js.map +1 -1
  32. package/dist/esm/components/atoms/Spinner/Spinner.js.map +1 -1
  33. package/dist/esm/components/atoms/Switch/Switch.d.ts +1 -1
  34. package/dist/esm/components/molecules/Alert/Alert.d.ts +1 -1
  35. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js +12 -4
  36. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
  37. package/dist/esm/components/molecules/FieldArea/FieldArea.d.ts +1 -1
  38. package/dist/esm/components/molecules/FieldArea/FieldArea.js.map +1 -1
  39. package/dist/esm/components/molecules/FieldFile/FieldFile.d.ts +1 -1
  40. package/dist/esm/components/molecules/FieldFile/FieldFile.js +6 -4
  41. package/dist/esm/components/molecules/FieldFile/FieldFile.js.map +1 -1
  42. package/dist/esm/components/molecules/FieldListSuggestions/FieldListSuggestions.d.ts +1 -1
  43. package/dist/esm/components/molecules/FieldMoney/FieldMoney.js +3 -2
  44. package/dist/esm/components/molecules/FieldMoney/FieldMoney.js.map +1 -1
  45. package/dist/esm/components/molecules/FieldNumber/FieldNumber.js +3 -2
  46. package/dist/esm/components/molecules/FieldNumber/FieldNumber.js.map +1 -1
  47. package/dist/esm/components/molecules/FieldPercentage/FieldPercentage.js +3 -2
  48. package/dist/esm/components/molecules/FieldPercentage/FieldPercentage.js.map +1 -1
  49. package/dist/esm/components/molecules/FieldText/FieldText.js +3 -2
  50. package/dist/esm/components/molecules/FieldText/FieldText.js.map +1 -1
  51. package/dist/esm/components/molecules/MessageFormError/MessageFormError.js.map +1 -1
  52. package/dist/esm/components/molecules/Pagination/Pagination.js +2 -1
  53. package/dist/esm/components/molecules/Pagination/Pagination.js.map +1 -1
  54. package/dist/esm/components/molecules/PickerDay/PickerDay.d.ts +1 -1
  55. package/dist/esm/components/molecules/PickerDay/PickerDay.js +22 -7
  56. package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
  57. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +4 -2
  58. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
  59. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +20 -10
  60. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
  61. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js +17 -5
  62. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js.map +1 -1
  63. package/dist/esm/components/molecules/PickerYear/PickerYear.js +18 -4
  64. package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
  65. package/dist/esm/components/molecules/Slider/Slider.js.map +1 -1
  66. package/dist/esm/components/molecules/Tabs/Tabs.js +6 -2
  67. package/dist/esm/components/molecules/Tabs/Tabs.js.map +1 -1
  68. package/dist/esm/components/organisms/BottomSheet/BottomSheet.js +3 -1
  69. package/dist/esm/components/organisms/BottomSheet/BottomSheet.js.map +1 -1
  70. package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +1 -1
  71. package/dist/esm/components/organisms/Dropdown/Dropdown.js +2 -1
  72. package/dist/esm/components/organisms/Dropdown/Dropdown.js.map +1 -1
  73. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +3 -1
  74. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
  75. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +12 -5
  76. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
  77. package/dist/esm/components/organisms/FieldClock/FieldClock.d.ts +1 -1
  78. package/dist/esm/components/organisms/FieldClock/FieldClock.js +6 -2
  79. package/dist/esm/components/organisms/FieldClock/FieldClock.js.map +1 -1
  80. package/dist/esm/components/organisms/FieldColor/FieldColor.js +6 -2
  81. package/dist/esm/components/organisms/FieldColor/FieldColor.js.map +1 -1
  82. package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +1 -1
  83. package/dist/esm/components/organisms/FieldDate/FieldDate.js +6 -2
  84. package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
  85. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +6 -2
  86. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
  87. package/dist/esm/components/organisms/FieldList/FieldList.js +1 -1
  88. package/dist/esm/components/organisms/FieldList/FieldList.js.map +1 -1
  89. package/dist/esm/components/organisms/FieldList/FieldListController.d.ts +5 -5
  90. package/dist/esm/components/organisms/FieldList/FieldListController.js +5 -2
  91. package/dist/esm/components/organisms/FieldList/FieldListController.js.map +1 -1
  92. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +21 -8
  93. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
  94. package/dist/esm/components/organisms/ImageChooser/ImageChooser.js +3 -1
  95. package/dist/esm/components/organisms/ImageChooser/ImageChooser.js.map +1 -1
  96. package/dist/esm/components/organisms/ImageEditor/ImageEditor.d.ts +1 -1
  97. package/dist/esm/components/organisms/ImageEditorModal/ImageEditorModal.d.ts +1 -1
  98. package/dist/esm/components/organisms/Modal/Modal.js +3 -1
  99. package/dist/esm/components/organisms/Modal/Modal.js.map +1 -1
  100. package/dist/esm/components/organisms/ModalSheet/ModalSheet.js +3 -1
  101. package/dist/esm/components/organisms/ModalSheet/ModalSheet.js.map +1 -1
  102. package/dist/esm/components/organisms/Notifications/Notifications.d.ts +17 -0
  103. package/dist/esm/components/organisms/Notifications/Notifications.js +59 -0
  104. package/dist/esm/components/organisms/Notifications/Notifications.js.map +1 -0
  105. package/dist/esm/components/organisms/PickerClock/PickerClock.js +12 -2
  106. package/dist/esm/components/organisms/PickerClock/PickerClock.js.map +1 -1
  107. package/dist/esm/components/organisms/PickerColor/PickerColor.js +9 -3
  108. package/dist/esm/components/organisms/PickerColor/PickerColor.js.map +1 -1
  109. package/dist/esm/components/organisms/PickerDate/PickerDate.js +7 -2
  110. package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
  111. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +7 -2
  112. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
  113. package/dist/esm/components/organisms/Snackbar/Snackbar.js +3 -1
  114. package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
  115. package/dist/esm/components/types.d.ts +6 -1
  116. package/dist/esm/context.d.ts +5 -2
  117. package/dist/esm/context.js +14 -12
  118. package/dist/esm/context.js.map +1 -1
  119. package/dist/esm/controllers/DropdownController.js +3 -3
  120. package/dist/esm/controllers/DropdownController.js.map +1 -1
  121. package/dist/esm/controllers/FormToggleController.js +8 -3
  122. package/dist/esm/controllers/FormToggleController.js.map +1 -1
  123. package/dist/esm/controllers/ImageEditorController.js +6 -2
  124. package/dist/esm/controllers/ImageEditorController.js.map +1 -1
  125. package/dist/esm/controllers/ListController.d.ts +1 -1
  126. package/dist/esm/controllers/ListController.js +26 -11
  127. package/dist/esm/controllers/ListController.js.map +1 -1
  128. package/dist/esm/controllers/ResizeController.js +2 -1
  129. package/dist/esm/controllers/ResizeController.js.map +1 -1
  130. package/dist/esm/helpers/color.d.ts +4 -4
  131. package/dist/esm/helpers/css.js +6 -5
  132. package/dist/esm/helpers/css.js.map +1 -1
  133. package/dist/esm/helpers/date-range-picker.js.map +1 -1
  134. package/dist/esm/helpers/design-system.js.map +1 -1
  135. package/dist/esm/helpers/language.js.map +1 -1
  136. package/dist/esm/index.d.ts +8 -7
  137. package/dist/esm/index.js +7 -6
  138. package/dist/esm/index.js.map +1 -1
  139. package/package.json +83 -91
@@ -433,12 +433,13 @@ var jsxRuntimeExports = requireJsxRuntime();
433
433
  function renderClassStatus(base, status = {}, additionals) {
434
434
  const _classElement = [base];
435
435
  Object.entries(status).forEach(([key, state]) => {
436
- state &&
437
- (typeof state === 'string'
438
- ? _classElement.push(`${base}--${state}`)
439
- : _classElement.push(`${base}--${key}`));
436
+ if (state) {
437
+ _classElement.push(typeof state === 'string' ? `${base}--${state}` : `${base}--${key}`);
438
+ }
440
439
  });
441
- additionals && _classElement.push(additionals);
440
+ if (additionals) {
441
+ _classElement.push(additionals);
442
+ }
442
443
  return _classElement.join(' ').trim();
443
444
  }
444
445
 
@@ -494,7 +495,9 @@ function RlsAreaText({ autoComplete, disabled, formControl, identifier, onBlur,
494
495
  require$$0.useEffect(() => {
495
496
  if (!changeIsInternal.current) {
496
497
  const nextValue = String(formControl?.value ?? value ?? '');
497
- valueArea !== nextValue && setValueArea(nextValue);
498
+ if (valueArea !== nextValue) {
499
+ setValueArea(nextValue);
500
+ }
498
501
  }
499
502
  changeIsInternal.current = false;
500
503
  }, [formControl?.value, value, valueArea]);
@@ -512,7 +515,9 @@ function RlsAreaText({ autoComplete, disabled, formControl, identifier, onBlur,
512
515
  }, [formControl, onValue]);
513
516
  const onKeyDownArea = require$$0.useCallback((event) => {
514
517
  onKeyDown?.(event);
515
- event.key === 'Enter' && onEnter?.();
518
+ if (event.key === 'Enter') {
519
+ onEnter?.();
520
+ }
516
521
  }, [onKeyDown, onEnter]);
517
522
  const onKeyUpArea = require$$0.useCallback((event) => {
518
523
  onKeyUp?.(event);
@@ -675,7 +680,9 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
675
680
  require$$0.useEffect(() => {
676
681
  if (!changeIsInternal.current && formControl) {
677
682
  const valueControl = formControl.value ? String(formControl.value) : '';
678
- valueInput !== valueControl && setValueInput(valueControl);
683
+ if (valueInput !== valueControl) {
684
+ setValueInput(valueControl);
685
+ }
679
686
  }
680
687
  changeIsInternal.current = false;
681
688
  }, [formControl?.value]);
@@ -691,7 +698,9 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
691
698
  }, [formControl, onValue, type, decimals]);
692
699
  const onKeyDownInput = require$$0.useCallback((event) => {
693
700
  onKeyDown?.(event);
694
- event.key === 'Enter' && onEnter?.();
701
+ if (event.key === 'Enter') {
702
+ onEnter?.();
703
+ }
695
704
  }, [onKeyDown, onEnter]);
696
705
  const onKeyUpInput = require$$0.useCallback((event) => {
697
706
  onKeyUp?.(event);
@@ -730,9 +739,9 @@ function RlsInputCounter({ className, disabled, formControl, identifier, max, mi
730
739
  require$$0.useEffect(() => {
731
740
  if (!changeIsInternal.current && formControl) {
732
741
  const counterValue = formControl.value;
733
- counterValue !== undefined &&
734
- counterValue !== value &&
742
+ if (counterValue !== undefined && counterValue !== value) {
735
743
  setValue(counterValue);
744
+ }
736
745
  }
737
746
  changeIsInternal.current = false;
738
747
  }, [formControl?.value]);
@@ -753,7 +762,9 @@ function RlsInputCounter({ className, disabled, formControl, identifier, max, mi
753
762
  const incrementIsAllowed = require$$0.useMemo(() => max !== undefined && value >= max, [max, value]);
754
763
  const onChangeInput = require$$0.useCallback((event) => {
755
764
  const parsed = parseFloat(event.target.value);
756
- !isNaN(parsed) && onUpdate(parsed);
765
+ if (!isNaN(parsed)) {
766
+ onUpdate(parsed);
767
+ }
757
768
  }, [onUpdate]);
758
769
  const onFocusInput = require$$0.useCallback(() => {
759
770
  setFocused(true);
@@ -776,7 +787,12 @@ function RlsInputDecimal(props) {
776
787
  }, [formControl?.value, valueInput]);
777
788
  const onValueInput = require$$0.useCallback((value) => {
778
789
  const valueDecimal = commons.BigDecimal.create(value);
779
- formControl ? formControl.setValue(valueDecimal) : setValueInput(value);
790
+ if (formControl) {
791
+ formControl.setValue(valueDecimal);
792
+ }
793
+ else {
794
+ setValueInput(value);
795
+ }
780
796
  onValue?.(valueDecimal);
781
797
  }, [formControl, onValue]);
782
798
  const decimalProps = { ...props, formControl: undefined };
@@ -787,7 +803,9 @@ function RlsInputMoney(props) {
787
803
  const { decimals, formControl, identifier, onValue, symbol, value } = props;
788
804
  const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
789
805
  const onValueInput = require$$0.useCallback((value) => {
790
- !formControl && setValueInput(value);
806
+ if (!formControl) {
807
+ setValueInput(value);
808
+ }
791
809
  onValue?.(value);
792
810
  }, [formControl, onValue]);
793
811
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { ...props, type: "number", value: valueInput, onValue: onValueInput, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
@@ -797,7 +815,9 @@ function RlsInputNumber(props) {
797
815
  const { formControl, identifier, onValue, value } = props;
798
816
  const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
799
817
  const onValueInput = require$$0.useCallback((value) => {
800
- !formControl && setValueInput(value);
818
+ if (!formControl) {
819
+ setValueInput(value);
820
+ }
801
821
  onValue?.(value);
802
822
  }, [formControl, onValue]);
803
823
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { ...props, type: "number", value: valueInput, onValue: onValueInput, children: formControl?.value ?? valueInput }) }));
@@ -811,7 +831,9 @@ function RlsInputPassword({ disabled, formControl, identifier, onEnter, onKeyDow
811
831
  }, [formControl, onValue]);
812
832
  const _onKeyDown = require$$0.useCallback((event) => {
813
833
  onKeyDown?.(event);
814
- event.key === 'Enter' && onEnter?.();
834
+ if (event.key === 'Enter') {
835
+ onEnter?.();
836
+ }
815
837
  }, [onKeyDown, onEnter]);
816
838
  const _onKeyUp = require$$0.useCallback((event) => {
817
839
  onKeyUp?.(event);
@@ -837,7 +859,9 @@ function RlsInputPercentage(props) {
837
859
  const { formControl, identifier, onValue, value } = props;
838
860
  const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? 0);
839
861
  const onValueInput = require$$0.useCallback((value) => {
840
- !formControl && setValueInput(value);
862
+ if (!formControl) {
863
+ setValueInput(value);
864
+ }
841
865
  onValue?.(value);
842
866
  }, [formControl, onValue]);
843
867
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-percentage", children: jsxRuntimeExports.jsxs(RlsInput, { ...props, type: "number", value: valueInput, onValue: onValueInput, children: [formControl?.value ?? valueInput, "%"] }) }));
@@ -849,7 +873,9 @@ function RlsInputSearch({ formControl, disabled, identifier, onEnter, onSearch,
849
873
  return renderClassStatus('rls-input-search', { disabled });
850
874
  }, [disabled]);
851
875
  const onValue = require$$0.useCallback((value) => {
852
- !formControl && setValue(() => value);
876
+ if (!formControl) {
877
+ setValue(() => value);
878
+ }
853
879
  }, [formControl]);
854
880
  return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, placeholder: placeholder, onEnter: onEnter, onValue: onValue, disabled: disabled, children: formControl?.value ?? value }), onSearch && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: "search", onClick: onSearch, disabled: disabled }))] }));
855
881
  }
@@ -858,7 +884,9 @@ function RlsInputText(props) {
858
884
  const { formControl, identifier, onValue, value } = props;
859
885
  const [valueInput, setValueInput] = require$$0.useState(formControl?.value ?? value ?? '');
860
886
  const onValueInput = require$$0.useCallback((value) => {
861
- !formControl && setValueInput(value);
887
+ if (!formControl) {
888
+ setValueInput(value);
889
+ }
862
890
  onValue?.(value);
863
891
  }, [formControl, onValue]);
864
892
  return (jsxRuntimeExports.jsx("div", { id: identifier, className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { ...props, type: "text", value: valueInput, onValue: onValueInput, children: formControl?.value ?? valueInput }) }));
@@ -1381,7 +1409,9 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
1381
1409
  const [visible, setVisible] = require$$0.useState(false);
1382
1410
  require$$0.useEffect(() => {
1383
1411
  function onCloseMenu({ target }) {
1384
- !componentRef?.current?.contains(target) && setVisible(false);
1412
+ if (!componentRef?.current?.contains(target)) {
1413
+ setVisible(false);
1414
+ }
1385
1415
  }
1386
1416
  document.addEventListener('click', onCloseMenu);
1387
1417
  return () => {
@@ -1400,15 +1430,21 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
1400
1430
  const onSelectAction = require$$0.useCallback((action) => {
1401
1431
  setAction(() => action);
1402
1432
  setVisible(() => false);
1403
- automatic && onAction(action.value);
1433
+ if (automatic) {
1434
+ onAction(action.value);
1435
+ }
1404
1436
  }, [onAction, automatic]);
1405
1437
  const onClickAction = require$$0.useCallback(() => {
1406
- action && onAction(action.value);
1438
+ if (action) {
1439
+ onAction(action.value);
1440
+ }
1407
1441
  }, [action, onAction]);
1408
1442
  const onClickOption = require$$0.useCallback((event) => {
1409
1443
  const index = Number(event.currentTarget.dataset.index);
1410
1444
  const option = options[index];
1411
- option && onSelectAction(option);
1445
+ if (option) {
1446
+ onSelectAction(option);
1447
+ }
1412
1448
  }, [options, onSelectAction]);
1413
1449
  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: onClickAction, 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: classNameList, children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "rls-truncate", "data-index": index, onClick: onClickOption, children: action.label }, index))) }) })] }));
1414
1450
  }
@@ -1541,7 +1577,7 @@ function RlsMessageFormError({ className, formControl }) {
1541
1577
  return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: formControl?.wrong && (jsxRuntimeExports.jsx("div", { className: className, children: jsxRuntimeExports.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: msgError }) })) }));
1542
1578
  }
1543
1579
 
1544
- function RlsFieldDecimal(props) {
1580
+ function RlsFieldArea(props) {
1545
1581
  const { children, formControl, identifier, rlsTheme } = props;
1546
1582
  const disabled = require$$0.useMemo(() => {
1547
1583
  return formControl?.disabled || props.disabled;
@@ -1552,12 +1588,12 @@ function RlsFieldDecimal(props) {
1552
1588
  error: formControl?.wrong,
1553
1589
  focused: formControl?.focused && !disabled,
1554
1590
  readonly: props.readOnly
1555
- }, 'rls-field-decimal');
1591
+ }, 'rls-field-area');
1556
1592
  }, [formControl?.focused, formControl?.wrong, props.readOnly, disabled]);
1557
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputDecimal, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1593
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsAreaText, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1558
1594
  }
1559
1595
 
1560
- function RlsFieldArea(props) {
1596
+ function RlsFieldDecimal(props) {
1561
1597
  const { children, formControl, identifier, rlsTheme } = props;
1562
1598
  const disabled = require$$0.useMemo(() => {
1563
1599
  return formControl?.disabled || props.disabled;
@@ -1568,14 +1604,14 @@ function RlsFieldArea(props) {
1568
1604
  error: formControl?.wrong,
1569
1605
  focused: formControl?.focused && !disabled,
1570
1606
  readonly: props.readOnly
1571
- }, 'rls-field-area');
1607
+ }, 'rls-field-decimal');
1572
1608
  }, [formControl?.focused, formControl?.wrong, props.readOnly, disabled]);
1573
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsAreaText, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1609
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputDecimal, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1574
1610
  }
1575
1611
 
1576
- function RlsFieldFile({ accept, children, disabled: disabledProp, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value }) {
1612
+ function RlsFieldFile({ accept, children, disabled: _disabled, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value }) {
1577
1613
  const inputRef = require$$0.useRef(null);
1578
- const disabled = require$$0.useMemo(() => formControl?.disabled || disabledProp, [formControl?.disabled, disabledProp]);
1614
+ const disabled = require$$0.useMemo(() => formControl?.disabled || _disabled, [formControl?.disabled, _disabled]);
1579
1615
  const className = require$$0.useMemo(() => renderClassStatus('rls-field-box', {
1580
1616
  disabled,
1581
1617
  error: formControl?.wrong,
@@ -1605,9 +1641,11 @@ function RlsFieldFile({ accept, children, disabled: disabledProp, formControl, i
1605
1641
  event.target.value = '';
1606
1642
  }, [formControl, onValue]);
1607
1643
  const onClickControl = require$$0.useCallback(() => {
1608
- !readOnly && !disabled && inputRef.current?.click();
1644
+ if (!readOnly && !disabled) {
1645
+ inputRef.current?.click();
1646
+ }
1609
1647
  }, [readOnly, disabled]);
1610
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", onClick: onClickControl, children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-input__component", readOnly: true, type: "text", value: displayValue, placeholder: placeholder }), jsxRuntimeExports.jsx("input", { ref: inputRef, className: "rls-field-file__input", type: "file", accept: accept, disabled: disabled || readOnly, onChange: onChangeInput }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: currentFile ? 'close' : 'attach-2', disabled: disabled, onClick: onClickAction })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1648
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", onClick: onClickControl, children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-input__component", readOnly: true, type: "text", value: displayValue, placeholder: placeholder }), jsxRuntimeExports.jsx("input", { ref: inputRef, className: "rls-field-file__input", type: "file", accept: accept, disabled: disabled || readOnly, onChange: onChangeInput }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: currentFile ? 'close' : 'attach', disabled: disabled, onClick: onClickAction })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1611
1649
  }
1612
1650
 
1613
1651
  const reactI18n = i18n.i18n({
@@ -1680,7 +1718,7 @@ function RlsFieldListSuggestions({ elements, action, disabled, higher, render, r
1680
1718
  }
1681
1719
 
1682
1720
  function RlsFieldMoney(props) {
1683
- const { children, formControl, identifier, rlsTheme } = props;
1721
+ const { action, children, formControl, identifier, rlsTheme } = props;
1684
1722
  const disabled = require$$0.useMemo(() => {
1685
1723
  return formControl?.disabled || props.disabled;
1686
1724
  }, [formControl?.disabled, props.disabled]);
@@ -1692,11 +1730,11 @@ function RlsFieldMoney(props) {
1692
1730
  readonly: props.readOnly
1693
1731
  }, 'rls-field-money');
1694
1732
  }, [formControl?.focused, formControl?.wrong, props.readOnly, disabled]);
1695
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1733
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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(RlsInputMoney, { ...props }), action && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: action.icon, disabled: disabled, onClick: action.onClick }))] }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1696
1734
  }
1697
1735
 
1698
1736
  function RlsFieldNumber(props) {
1699
- const { children, formControl, identifier, rlsTheme } = props;
1737
+ const { action, children, formControl, identifier, rlsTheme } = props;
1700
1738
  const disabled = require$$0.useMemo(() => {
1701
1739
  return formControl?.disabled || props.disabled;
1702
1740
  }, [formControl?.disabled, props.disabled]);
@@ -1708,7 +1746,7 @@ function RlsFieldNumber(props) {
1708
1746
  readonly: props.readOnly
1709
1747
  }, 'rls-field-number');
1710
1748
  }, [formControl?.focused, formControl?.wrong, props.readOnly, disabled]);
1711
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1749
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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(RlsInputNumber, { ...props }), action && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: action.icon, disabled: disabled, onClick: action.onClick }))] }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1712
1750
  }
1713
1751
 
1714
1752
  function RlsFieldPassword(props) {
@@ -1732,7 +1770,7 @@ function RlsFieldPassword(props) {
1732
1770
  }
1733
1771
 
1734
1772
  function RlsFieldPercentage(props) {
1735
- const { children, formControl, identifier, rlsTheme } = props;
1773
+ const { action, children, formControl, identifier, rlsTheme } = props;
1736
1774
  const disabled = require$$0.useMemo(() => {
1737
1775
  return formControl?.disabled || props.disabled;
1738
1776
  }, [formControl?.disabled, props.disabled]);
@@ -1744,7 +1782,7 @@ function RlsFieldPercentage(props) {
1744
1782
  readonly: props.readOnly
1745
1783
  }, 'rls-field-percentage');
1746
1784
  }, [formControl?.focused, formControl?.wrong, props.readOnly, disabled]);
1747
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputPercentage, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1785
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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(RlsInputPercentage, { ...props }), action && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: action.icon, disabled: disabled, onClick: action.onClick }))] }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1748
1786
  }
1749
1787
 
1750
1788
  function RlsFieldReadonly({ children, identifier, rlsTheme, value }) {
@@ -1752,7 +1790,7 @@ function RlsFieldReadonly({ children, identifier, rlsTheme, value }) {
1752
1790
  }
1753
1791
 
1754
1792
  function RlsFieldText(props) {
1755
- const { children, formControl, identifier, rlsTheme } = props;
1793
+ const { action, children, formControl, identifier, rlsTheme } = props;
1756
1794
  const disabled = require$$0.useMemo(() => {
1757
1795
  return formControl?.disabled || props.disabled;
1758
1796
  }, [formControl?.disabled, props.disabled]);
@@ -1764,7 +1802,7 @@ function RlsFieldText(props) {
1764
1802
  readonly: props.readOnly
1765
1803
  }, 'rls-field-text');
1766
1804
  }, [formControl?.focused, formControl?.wrong, props.readOnly, disabled]);
1767
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputText, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1805
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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(RlsInputText, { ...props }), action && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: action.icon, disabled: disabled, onClick: action.onClick }))] }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1768
1806
  }
1769
1807
 
1770
1808
  function useFormToggleController({ disabled, formControl }) {
@@ -1774,9 +1812,14 @@ function useFormToggleController({ disabled, formControl }) {
1774
1812
  }, [formControl?.value]);
1775
1813
  const onToggle = require$$0.useCallback(() => {
1776
1814
  if (!disabled) {
1777
- formControl
1778
- ? formControl.enabled && formControl.setValue(!formControl.value)
1779
- : setChecked((checked) => !checked);
1815
+ if (formControl) {
1816
+ if (formControl.enabled) {
1817
+ formControl.setValue(!formControl.value);
1818
+ }
1819
+ }
1820
+ else {
1821
+ setChecked((checked) => !checked);
1822
+ }
1780
1823
  }
1781
1824
  }, [formControl, disabled]);
1782
1825
  return { checked, onToggle };
@@ -1878,8 +1921,9 @@ function RlsPagination({ suggestions, count, filter, onPagination }) {
1878
1921
  setTemplate(template);
1879
1922
  }, [onPagination]);
1880
1923
  const refreshPagination = require$$0.useCallback((pagination) => {
1881
- pagination &&
1924
+ if (pagination) {
1882
1925
  refreshTemplate(pagination.template, pagination.page.collection);
1926
+ }
1883
1927
  }, [refreshTemplate]);
1884
1928
  require$$0.useEffect(() => {
1885
1929
  const pagination = new components.PaginationController({
@@ -1925,7 +1969,9 @@ function RlsPickerDayElement({ day, onSelect, disabled }) {
1925
1969
  });
1926
1970
  }, [day, disabled]);
1927
1971
  const onClick = require$$0.useCallback(() => {
1928
- day.value && !day.disabled && !disabled && onSelect(day.value);
1972
+ if (day.value && !day.disabled && !disabled) {
1973
+ onSelect(day.value);
1974
+ }
1929
1975
  }, [day.value, day.disabled, disabled, onSelect]);
1930
1976
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day__element__span", children: day.value || '??' }) }));
1931
1977
  }
@@ -1935,7 +1981,12 @@ function RlsPickerDay({ date, disabled, formControl, maxDate, month, minDate, on
1935
1981
  const [value, setValue] = require$$0.useState(formControl?.value ?? dateDay.getDate());
1936
1982
  const [_, setI18nVersion] = require$$0.useState(0);
1937
1983
  const setDayValue = require$$0.useCallback((value) => {
1938
- formControl ? formControl.setValue(value) : setValue(value);
1984
+ if (formControl) {
1985
+ formControl.setValue(value);
1986
+ }
1987
+ else {
1988
+ setValue(value);
1989
+ }
1939
1990
  }, [formControl]);
1940
1991
  const onSelect = require$$0.useCallback((value) => {
1941
1992
  setDayValue(value);
@@ -1949,13 +2000,21 @@ function RlsPickerDay({ date, disabled, formControl, maxDate, month, minDate, on
1949
2000
  require$$0.useEffect(() => {
1950
2001
  const options = createPickerOptions();
1951
2002
  const day = components.verifyDayPicker(options);
1952
- day ? setDayValue(day) : setWeeks(components.createDayPicker(options));
2003
+ if (day) {
2004
+ setDayValue(day);
2005
+ }
2006
+ else {
2007
+ setWeeks(components.createDayPicker(options));
2008
+ }
1953
2009
  }, [dateDay, month, year, value, minDate, maxDate]);
1954
2010
  require$$0.useEffect(() => {
1955
2011
  const day = components.verifyDayPicker(createPickerOptions());
1956
- day
1957
- ? formControl?.setValue(day)
1958
- : setValue(formControl?.value || dateDay.getDate());
2012
+ if (day) {
2013
+ formControl?.setValue(day);
2014
+ }
2015
+ else {
2016
+ setValue(formControl?.value || dateDay.getDate());
2017
+ }
1959
2018
  }, [formControl?.value]);
1960
2019
  const createPickerOptions = require$$0.useCallback(() => {
1961
2020
  return {
@@ -1984,7 +2043,9 @@ function RlsPickerDayRangeElement({ day, onSelect, disabled }) {
1984
2043
  });
1985
2044
  }, [day.disabled, day.end, day.forbidden, day.ranged, day.source, disabled]);
1986
2045
  const onClick = require$$0.useCallback(() => {
1987
- day.value && !day.disabled && !disabled && onSelect(day.value);
2046
+ if (day.value && !day.disabled && !disabled) {
2047
+ onSelect(day.value);
2048
+ }
1988
2049
  }, [day.value, day.disabled, disabled, onSelect]);
1989
2050
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: day.value || '??' }) }));
1990
2051
  }
@@ -2040,10 +2101,9 @@ function RlsPickerMonthElement({ month, onSelect, disabled }) {
2040
2101
  });
2041
2102
  }, [month.disabled, month.focused, month.selected, disabled]);
2042
2103
  const onClick = require$$0.useCallback(() => {
2043
- commons.valueIsDefined(month.value) &&
2044
- !month.disabled &&
2045
- !disabled &&
2104
+ if (commons.valueIsDefined(month.value) && !month.disabled && !disabled) {
2046
2105
  onSelect(month.value);
2106
+ }
2047
2107
  }, [month.value, month.disabled, disabled, onSelect]);
2048
2108
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }));
2049
2109
  }
@@ -2052,7 +2112,12 @@ function RlsPickerMonth({ date, disabled, formControl, maxDate, minDate, onValue
2052
2112
  const [months, setMonths] = require$$0.useState([]);
2053
2113
  const [value, setValue] = require$$0.useState(formControl?.value ?? dateMonth.getMonth());
2054
2114
  const setMonthValue = require$$0.useCallback((value) => {
2055
- formControl ? formControl.setValue(value) : setValue(value);
2115
+ if (formControl) {
2116
+ formControl.setValue(value);
2117
+ }
2118
+ else {
2119
+ setValue(value);
2120
+ }
2056
2121
  }, [formControl]);
2057
2122
  const onSelect = require$$0.useCallback((value) => {
2058
2123
  setMonthValue(value);
@@ -2067,9 +2132,12 @@ function RlsPickerMonth({ date, disabled, formControl, maxDate, minDate, onValue
2067
2132
  maxDate
2068
2133
  };
2069
2134
  const month = components.verifyMonthPicker(options);
2070
- commons.valueIsDefined(month)
2071
- ? setMonthValue(month)
2072
- : setMonths(components.createMonthPicker(options));
2135
+ if (commons.valueIsDefined(month)) {
2136
+ setMonthValue(month);
2137
+ }
2138
+ else {
2139
+ setMonths(components.createMonthPicker(options));
2140
+ }
2073
2141
  }, [dateMonth, year, value, minDate, maxDate]);
2074
2142
  require$$0.useEffect(() => {
2075
2143
  const month = components.verifyMonthPicker({
@@ -2079,9 +2147,12 @@ function RlsPickerMonth({ date, disabled, formControl, maxDate, minDate, onValue
2079
2147
  minDate,
2080
2148
  maxDate
2081
2149
  });
2082
- commons.valueIsDefined(month)
2083
- ? formControl?.setValue(month)
2084
- : setValue(formControl?.value ?? dateMonth.getMonth());
2150
+ if (commons.valueIsDefined(month)) {
2151
+ formControl?.setValue(month);
2152
+ }
2153
+ else {
2154
+ setValue(formControl?.value ?? dateMonth.getMonth());
2155
+ }
2085
2156
  }, [formControl?.value]);
2086
2157
  return (jsxRuntimeExports.jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: months.map((month, index) => (jsxRuntimeExports.jsx(RlsPickerMonthElement, { month: month, onSelect: onSelect, disabled: disabled }, index))) }));
2087
2158
  }
@@ -2123,11 +2194,17 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
2123
2194
  onClick?.('year');
2124
2195
  }, [onClick]);
2125
2196
  const onPreviousYear = require$$0.useCallback(() => {
2126
- commons.valueIsDefined(yearControl.value) &&
2197
+ if (commons.valueIsDefined(yearControl.value)) {
2127
2198
  yearControl.setValue(yearControl.value - 1);
2199
+ }
2128
2200
  }, [yearControl.value]);
2129
2201
  const onPrevious = require$$0.useCallback(() => {
2130
- type === 'month' ? onPreviousMonth() : onPreviousYear();
2202
+ if (type === 'month') {
2203
+ onPreviousMonth();
2204
+ }
2205
+ else {
2206
+ onPreviousYear();
2207
+ }
2131
2208
  }, [type, onPreviousMonth, onPreviousYear]);
2132
2209
  const onNextMonth = require$$0.useCallback(() => {
2133
2210
  if (commons.valueIsDefined(monthControl.value) &&
@@ -2142,11 +2219,17 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
2142
2219
  }
2143
2220
  }, [monthControl.value, yearControl.value]);
2144
2221
  const onNextYear = require$$0.useCallback(() => {
2145
- commons.valueIsDefined(yearControl.value) &&
2222
+ if (commons.valueIsDefined(yearControl.value)) {
2146
2223
  yearControl.setValue(yearControl.value + 1);
2224
+ }
2147
2225
  }, [yearControl.value]);
2148
2226
  const onNext = require$$0.useCallback(() => {
2149
- type === 'month' ? onNextMonth() : onNextYear();
2227
+ if (type === 'month') {
2228
+ onNextMonth();
2229
+ }
2230
+ else {
2231
+ onNextYear();
2232
+ }
2150
2233
  }, [type, onNextMonth, onNextYear]);
2151
2234
  return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title", children: [jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title__label", children: [jsxRuntimeExports.jsxs("span", { onClick: onMonth, children: [label, ","] }), jsxRuntimeExports.jsx("span", { onClick: onYear, children: yearControl.value })] }), jsxRuntimeExports.jsx(RlsButtonIcon, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
2152
2235
  }
@@ -2160,7 +2243,9 @@ function RlsPickerYearElement({ onSelect, year, disabled }) {
2160
2243
  });
2161
2244
  }, [year.disabled, year.focused, year.selected, disabled]);
2162
2245
  const onClick = require$$0.useCallback(() => {
2163
- year.value && !year.disabled && !disabled && onSelect(year.value);
2246
+ if (year.value && !year.disabled && !disabled) {
2247
+ onSelect(year.value);
2248
+ }
2164
2249
  }, [year.value, year.disabled, disabled, onSelect]);
2165
2250
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__span", children: year.value || '????' }) }));
2166
2251
  }
@@ -2179,14 +2264,26 @@ function RlsPickerYear({ date, disabled, formControl, maxDate, minDate, onValue,
2179
2264
  require$$0.useEffect(() => {
2180
2265
  const options = createPickerOptions();
2181
2266
  const validYear = components.verifyYearPicker(options);
2182
- validYear ? setYear(validYear) : setTemplate(components.createYearPicker(options));
2267
+ if (validYear) {
2268
+ setYear(validYear);
2269
+ }
2270
+ else {
2271
+ setTemplate(components.createYearPicker(options));
2272
+ }
2183
2273
  }, [dateYear, year, minDate, maxDate]);
2184
2274
  require$$0.useEffect(() => {
2185
2275
  const yearValue = formControl?.value;
2186
- commons.valueIsDefined(yearValue) && yearValue !== year && setYear(yearValue);
2276
+ if (commons.valueIsDefined(yearValue) && yearValue !== year) {
2277
+ setYear(yearValue);
2278
+ }
2187
2279
  }, [formControl?.value]);
2188
2280
  const onSelect = require$$0.useCallback((value) => {
2189
- formControl ? formControl.setValue(value) : setYear(value);
2281
+ if (formControl) {
2282
+ formControl.setValue(value);
2283
+ }
2284
+ else {
2285
+ setYear(value);
2286
+ }
2190
2287
  onValue?.(value);
2191
2288
  }, [formControl, onValue]);
2192
2289
  const onClickPrev = require$$0.useCallback(() => {
@@ -2261,7 +2358,9 @@ function RlsTab({ onSelect, tab, value }) {
2261
2358
  });
2262
2359
  }, [tab, value]);
2263
2360
  const onClick = require$$0.useCallback(() => {
2264
- !tab.disabled && onSelect(tab.value);
2361
+ if (!tab.disabled) {
2362
+ onSelect(tab.value);
2363
+ }
2265
2364
  }, [tab.disabled]);
2266
2365
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
2267
2366
  }
@@ -2273,7 +2372,9 @@ function RlsTabs({ tabs, onValue, rlsTheme }) {
2273
2372
  }, [onValue]);
2274
2373
  require$$0.useEffect(() => {
2275
2374
  const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
2276
- initial && onSelect(initial.value);
2375
+ if (initial) {
2376
+ onSelect(initial.value);
2377
+ }
2277
2378
  }, []);
2278
2379
  return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
2279
2380
  return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, value: value, onSelect: onSelect }, index));
@@ -2289,7 +2390,9 @@ function RlsBottomSheet({ autoclose, children, className, controller, onBackdrop
2289
2390
  return renderClassStatus('rls-bottom-sheet', { visible: controller?.visible ?? visible }, className);
2290
2391
  }, [className, visible, controller?.visible]);
2291
2392
  const onClickBackdrop = require$$0.useCallback(() => {
2292
- autoclose && controller?.close();
2393
+ if (autoclose) {
2394
+ controller?.close();
2395
+ }
2293
2396
  onBackdrop?.();
2294
2397
  }, [autoclose, controller, onBackdrop]);
2295
2398
  return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameSheet, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-bottom-sheet__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-bottom-sheet__backdrop", onClick: onClickBackdrop })] }), document.body);
@@ -2445,8 +2548,9 @@ function RlsDropdown({ children, controller, rlsTheme }) {
2445
2548
  }, [controller.visible]);
2446
2549
  require$$0.useEffect(() => {
2447
2550
  function onCloseDropdown({ target }) {
2448
- !controller.component.current.contains(target) &&
2551
+ if (!controller.component.current.contains(target)) {
2449
2552
  controller.close();
2553
+ }
2450
2554
  }
2451
2555
  document.addEventListener('click', onCloseDropdown);
2452
2556
  return () => {
@@ -2500,8 +2604,9 @@ function useListController(props) {
2500
2604
  const valueProtected = require$$0.useRef(undefined);
2501
2605
  require$$0.useEffect(() => {
2502
2606
  function onCloseSuggestions({ target }) {
2503
- !refContent?.current?.contains(target) &&
2607
+ if (!refContent?.current?.contains(target)) {
2504
2608
  refreshState((state) => ({ ...state, listIsVisible: false }));
2609
+ }
2505
2610
  }
2506
2611
  document.addEventListener('click', onCloseSuggestions);
2507
2612
  return () => {
@@ -2525,9 +2630,12 @@ function useListController(props) {
2525
2630
  const element = collection.find(formControl.value);
2526
2631
  if (!element) {
2527
2632
  valueProtected.current = formControl.value;
2528
- automatic
2529
- ? setFormValue(collection.value[0], true)
2530
- : setFormValue(undefined);
2633
+ if (automatic) {
2634
+ setFormValue(collection.value[0], true);
2635
+ }
2636
+ else {
2637
+ setFormValue(undefined);
2638
+ }
2531
2639
  }
2532
2640
  else {
2533
2641
  refreshState((state) => ({ ...state, value: element.description }));
@@ -2535,12 +2643,20 @@ function useListController(props) {
2535
2643
  }
2536
2644
  else if (valueProtected.current) {
2537
2645
  const element = collection.find(valueProtected.current);
2538
- element ? setFormValue(element) : refreshState({ ...state, value: '' });
2646
+ if (element) {
2647
+ setFormValue(element);
2648
+ }
2649
+ else {
2650
+ refreshState({ ...state, value: '' });
2651
+ }
2539
2652
  }
2540
2653
  else {
2541
- automatic
2542
- ? setFormValue(collection.value[0], true)
2543
- : refreshState({ ...state, value: '' });
2654
+ if (automatic) {
2655
+ setFormValue(collection.value[0], true);
2656
+ }
2657
+ else {
2658
+ refreshState({ ...state, value: '' });
2659
+ }
2544
2660
  }
2545
2661
  }
2546
2662
  changeValueInternal.current = false;
@@ -2560,9 +2676,12 @@ function useListController(props) {
2560
2676
  value: element?.description || ''
2561
2677
  }));
2562
2678
  changeValueInternal.current = true;
2563
- valueIsDefault
2564
- ? formControl?.setDefaultValue(element?.value)
2565
- : formControl?.setValue(element?.value);
2679
+ if (valueIsDefault) {
2680
+ formControl?.setDefaultValue(element?.value);
2681
+ }
2682
+ else {
2683
+ formControl?.setValue(element?.value);
2684
+ }
2566
2685
  }, [formControl]);
2567
2686
  const navigationInput = require$$0.useCallback((event) => {
2568
2687
  if (state.listIsVisible) {
@@ -2595,7 +2714,7 @@ function useListController(props) {
2595
2714
  };
2596
2715
  }
2597
2716
 
2598
- const DURATION_ANIMATION$1 = 240;
2717
+ const DURATION_ANIMATION$2 = 240;
2599
2718
  const MAX_ELEMENTS = 6;
2600
2719
  function useFieldAutocomplete(props) {
2601
2720
  const controller = useListController(props);
@@ -2627,7 +2746,9 @@ function useFieldAutocomplete(props) {
2627
2746
  refreshCoincidences(props.suggestions, pattern, reboot);
2628
2747
  }, [props.suggestions, pattern]);
2629
2748
  require$$0.useEffect(() => {
2630
- props.disabled && controller.setState({ focused: false });
2749
+ if (props.disabled) {
2750
+ controller.setState({ focused: false });
2751
+ }
2631
2752
  }, [props.disabled, controller.setState]);
2632
2753
  const onFocusInput = require$$0.useCallback(() => {
2633
2754
  controller.setState({ focused: true });
@@ -2652,7 +2773,7 @@ function useFieldAutocomplete(props) {
2652
2773
  clearTimeout(focusTimeoutId.current);
2653
2774
  focusTimeoutId.current = setTimeout(() => {
2654
2775
  controller.refInput?.current?.focus();
2655
- }, DURATION_ANIMATION$1);
2776
+ }, DURATION_ANIMATION$2);
2656
2777
  }
2657
2778
  }, [controller.setState, props.readOnly]);
2658
2779
  require$$0.useEffect(() => {
@@ -2682,7 +2803,9 @@ function useFieldAutocomplete(props) {
2682
2803
  }, [controller.setState]);
2683
2804
  const onChange = require$$0.useCallback((element) => {
2684
2805
  if (props.onSelect) {
2685
- element.value && props.onSelect(element.value);
2806
+ if (element.value) {
2807
+ props.onSelect(element.value);
2808
+ }
2686
2809
  }
2687
2810
  else {
2688
2811
  controller.setFormValue(element);
@@ -2710,9 +2833,12 @@ function useFieldAutocomplete(props) {
2710
2833
  }, [onChange]);
2711
2834
  const onKeydownElement = require$$0.useCallback((element) => {
2712
2835
  return (event) => {
2713
- event.code === 'Enter'
2714
- ? onChange(element)
2715
- : controller.navigationElement(event);
2836
+ if (event.code === 'Enter') {
2837
+ onChange(element);
2838
+ }
2839
+ else {
2840
+ controller.navigationElement(event);
2841
+ }
2716
2842
  };
2717
2843
  }, [onChange, controller.navigationElement]);
2718
2844
  return {
@@ -2766,7 +2892,9 @@ function RlsFieldAutocompleteTemplate(props) {
2766
2892
  onSearch?.(autocomplete.pattern);
2767
2893
  }, [onSearch, autocomplete.pattern]);
2768
2894
  const onKeyDownPattern = require$$0.useCallback((event) => {
2769
- event.key === 'Enter' && onSearch?.(autocomplete.pattern);
2895
+ if (event.key === 'Enter') {
2896
+ onSearch?.(autocomplete.pattern);
2897
+ }
2770
2898
  autocomplete.onKeydownInput(event);
2771
2899
  }, [autocomplete.onKeydownInput, onSearch, autocomplete.pattern]);
2772
2900
  const searchControl = require$$0.useMemo(() => ({
@@ -2803,7 +2931,9 @@ function RlsModal({ autoclose, children, className, controller, onBackdrop, visi
2803
2931
  return renderClassStatus('rls-modal', { visible: controller?.visible ?? visible }, className);
2804
2932
  }, [className, visible, controller?.visible]);
2805
2933
  const onClickBackdrop = require$$0.useCallback(() => {
2806
- autoclose && controller?.close();
2934
+ if (autoclose) {
2935
+ controller?.close();
2936
+ }
2807
2937
  onBackdrop?.();
2808
2938
  }, [autoclose, controller, onBackdrop]);
2809
2939
  return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameModal, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop", onClick: onClickBackdrop })] }), document.body);
@@ -2904,7 +3034,12 @@ function RlsPickerClock({ formControl, onListener, rlsTheme, time }) {
2904
3034
  });
2905
3035
  }, []);
2906
3036
  require$$0.useEffect(() => {
2907
- selectionIsHours ? refreshClockHour() : refreshClockMinute();
3037
+ if (selectionIsHours) {
3038
+ refreshClockHour();
3039
+ }
3040
+ else {
3041
+ refreshClockMinute();
3042
+ }
2908
3043
  }, [selectionIsHours]);
2909
3044
  require$$0.useEffect(() => {
2910
3045
  if (!changeIsInternal.current && formControl?.value) {
@@ -2924,7 +3059,12 @@ function RlsPickerClock({ formControl, onListener, rlsTheme, time }) {
2924
3059
  const angle = Math.atan2(-positionX, positionY) + Math.PI;
2925
3060
  const value = Math.round(angle / radianUnit);
2926
3061
  refreshClock(value);
2927
- selectionIsHours ? setHour(value === 0 ? 12 : value) : setMinute(value);
3062
+ if (selectionIsHours) {
3063
+ setHour(value === 0 ? 12 : value);
3064
+ }
3065
+ else {
3066
+ setMinute(value);
3067
+ }
2928
3068
  }, [selectionIsHours, radianUnit]);
2929
3069
  const refreshClock = require$$0.useCallback((value) => {
2930
3070
  const angle = value * radianUnit;
@@ -3041,7 +3181,9 @@ function RlsFieldClock({ children, disabled: disabledProps, formControl, identif
3041
3181
  };
3042
3182
  }, [timeValue]);
3043
3183
  const onClickInput = require$$0.useCallback(() => {
3044
- !readOnly && setModalIsVisible(true);
3184
+ if (!readOnly) {
3185
+ setModalIsVisible(true);
3186
+ }
3045
3187
  }, [readOnly]);
3046
3188
  const onChange = require$$0.useCallback((value) => {
3047
3189
  setValue(value);
@@ -3058,452 +3200,82 @@ function RlsFieldClock({ children, disabled: disabledProps, formControl, identif
3058
3200
  }
3059
3201
  }, [timeValue, formControl, valueInitial, onChange]);
3060
3202
  const onListener = require$$0.useCallback(({ event, value }) => {
3061
- event !== components.PickerListenerEvent.Cancel && onChange(value);
3203
+ if (event !== components.PickerListenerEvent.Cancel) {
3204
+ onChange(value);
3205
+ }
3062
3206
  formControl?.touch();
3063
3207
  setModalIsVisible(false);
3064
3208
  }, [formControl, onChange]);
3065
3209
  return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-clock", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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-clock__control", type: "text", value: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-clock-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerClock, { formControl: formControl, time: time, disabled: disabled, onListener: onListener }) })] }));
3066
3210
  }
3067
3211
 
3068
- const DATE_FORMAT = '{dd}/{mx}/{yy}';
3069
- const DATE_FORMAT_TITLE = '{dw}, {mx} {dd} de {yy}';
3070
- const DATE_RANGE_FORMAT = '{dd}/{mx}/{yy}';
3071
-
3072
- function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
3073
- const today = require$$0.useRef(new Date()); // Initial current date in component
3074
- const _date = require$$0.useMemo(() => {
3075
- return formControl?.value ?? date ?? today.current;
3076
- }, [formControl?.value, date]);
3077
- const yearControl = reactForms.useReactControl(_date.getFullYear());
3078
- const dayControl = reactForms.useReactControl(_date.getDate());
3079
- const monthControl = reactForms.useReactControl(_date.getMonth());
3080
- const [visibility, setVisibility] = require$$0.useState('DAY');
3212
+ function RlsPickerColor({ color, formControl, onListener, rlsTheme }) {
3213
+ const initialColor = require$$0.useMemo(() => formControl?.value ?? color ?? DEFAULT_COLOR, []);
3214
+ const initialHsv = require$$0.useMemo(() => hexToHsv(initialColor) ?? { h: 258, s: 100, v: 100 }, []);
3215
+ const canvasRef = require$$0.useRef(null);
3216
+ const hueRef = require$$0.useRef(null);
3217
+ const alphaRef = require$$0.useRef(null);
3218
+ const selectionIsActive = require$$0.useRef(false);
3219
+ const activeSlider = require$$0.useRef(null);
3220
+ const hexEditing = require$$0.useRef(false);
3221
+ const [hsv, setHsv] = require$$0.useState(initialHsv);
3222
+ const [alpha, setAlpha] = require$$0.useState(1);
3223
+ const [hexInput, setHexInput] = require$$0.useState(initialColor);
3081
3224
  const [labels, setLabels] = require$$0.useState({
3082
- dateActionCancel: reactI18n('dateActionCancel'),
3083
- dateActionSelect: reactI18n('dateActionSelect'),
3084
- dateActionToday: reactI18n('dateActionToday')
3225
+ colorActionCancel: reactI18n('dateActionCancel'),
3226
+ colorActionSelect: reactI18n('dateActionSelect')
3085
3227
  });
3086
- const value = require$$0.useMemo(() => {
3087
- return new Date(yearControl.value, monthControl.value, dayControl.value);
3088
- }, [yearControl.value, monthControl.value, dayControl.value]);
3089
- const classNameComponent = require$$0.useMemo(() => {
3090
- return renderClassStatus('rls-picker-date__component', {
3091
- day: visibility === 'DAY',
3092
- month: visibility === 'MONTH',
3093
- year: visibility === 'YEAR'
3094
- });
3095
- }, [visibility]);
3096
- const title = require$$0.useMemo(() => {
3097
- return dates.dateFormatTemplate(value, DATE_FORMAT_TITLE);
3098
- }, [value]);
3099
- const itIsDisabledToday = require$$0.useMemo(() => components.dateOutRange({
3100
- date: today.current,
3101
- maxDate,
3102
- minDate
3103
- }), [maxDate, minDate]);
3228
+ const hexColor = require$$0.useMemo(() => hsvToHex(hsv), [hsv]);
3229
+ const hexValue = require$$0.useMemo(() => {
3230
+ return hexInput.replace('#', '');
3231
+ }, [hexInput]);
3232
+ const canvasStyle = require$$0.useMemo(() => {
3233
+ const { r, g, b } = hsvToRgb({ h: hsv.h, s: 100, v: 100 });
3234
+ return {
3235
+ background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), rgb(${r}, ${g}, ${b})`
3236
+ };
3237
+ }, [hsv.h]);
3238
+ const indicatorPosition = require$$0.useMemo(() => {
3239
+ return {
3240
+ left: `${(hsv.s / 100) * 100}%`,
3241
+ top: `${100 - (hsv.v / 100) * 100}%`
3242
+ };
3243
+ }, [hsv.s, hsv.v]);
3244
+ const hueSliderStyle = require$$0.useMemo(() => {
3245
+ return {
3246
+ background: 'linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)'
3247
+ };
3248
+ }, []);
3249
+ const hueIndicatorStyle = require$$0.useMemo(() => {
3250
+ return { left: `${(hsv.h / 360) * 100}%`, backgroundColor: hexColor };
3251
+ }, [hsv.h, hexColor]);
3252
+ const alphaSliderStyle = require$$0.useMemo(() => {
3253
+ return {
3254
+ background: `linear-gradient(to right, transparent, ${hexColor})`
3255
+ };
3256
+ }, [hexColor]);
3257
+ const alphaIndicatorStyle = require$$0.useMemo(() => {
3258
+ return { left: `${alpha * 100}%`, backgroundColor: hexColor };
3259
+ }, [alpha, hexColor]);
3260
+ require$$0.useEffect(() => {
3261
+ if (!hexEditing.current) {
3262
+ setHexInput(hexColor);
3263
+ }
3264
+ }, [hexColor]);
3104
3265
  require$$0.useEffect(() => {
3105
- const date = components.verifyDateRange({ date: _date, minDate, maxDate });
3106
- yearControl.setValue(date.getFullYear());
3107
- monthControl.setValue(date.getMonth());
3108
- dayControl.setValue(date.getDate());
3109
- formControl?.setValue(date);
3110
3266
  return i18n.i18nSubscribe(() => {
3111
3267
  setLabels({
3112
- dateActionCancel: reactI18n('dateActionCancel'),
3113
- dateActionSelect: reactI18n('dateActionSelect'),
3114
- dateActionToday: reactI18n('dateActionToday')
3268
+ colorActionCancel: reactI18n('dateActionCancel'),
3269
+ colorActionSelect: reactI18n('dateActionSelect')
3115
3270
  });
3116
3271
  });
3117
3272
  }, []);
3118
- const onVisibilityDay = require$$0.useCallback(() => {
3119
- setVisibility('DAY');
3120
- }, []);
3121
- const onVisibilityTitle = require$$0.useCallback((type) => {
3122
- type === 'month' ? setVisibility('MONTH') : setVisibility('YEAR');
3123
- }, []);
3124
- const onCancel = require$$0.useCallback(() => {
3125
- onListener?.({ event: components.PickerListenerEvent.Cancel });
3126
- }, [onListener]);
3127
- const onToday = require$$0.useCallback(() => {
3128
- yearControl.setValue(today.current.getFullYear());
3129
- dayControl.setValue(today.current.getDate());
3130
- monthControl.setValue(today.current.getMonth());
3131
- formControl?.setValue(today.current);
3132
- onListener?.({
3133
- event: components.PickerListenerEvent.Now,
3134
- value: today.current
3135
- });
3136
- }, [formControl, onListener]);
3137
- const onSelect = require$$0.useCallback(() => {
3138
- formControl?.setValue(value);
3139
- onListener?.({
3140
- event: components.PickerListenerEvent.Select,
3141
- value: value
3142
- });
3143
- }, [formControl, value, onListener]);
3144
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityTitle }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDay, { formControl: dayControl, date: value, month: monthControl.value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, date: value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), !automatic && (jsxRuntimeExports.jsx("div", { className: "rls-picker-date__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "calendar", onClick: onToday, disabled: itIsDisabledToday }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.dateActionSelect }) })] }) }))] }));
3145
- }
3146
-
3147
- function RlsFieldDate({ children, date, disabled: disabledProps, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
3148
- const today = require$$0.useRef(new Date()); // Initial current date in component
3149
- const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
3150
- const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
3151
- const disabled = require$$0.useMemo(() => {
3152
- return formControl?.disabled || disabledProps;
3153
- }, [formControl?.disabled, disabledProps]);
3154
- const className = require$$0.useMemo(() => {
3155
- return renderClassStatus('rls-field-box', {
3156
- disabled,
3157
- readonly: readOnly
3158
- });
3159
- }, [disabled, readOnly]);
3160
- const dateValue = require$$0.useMemo(() => {
3161
- return formControl ? formControl.value : value;
3162
- }, [formControl?.value, value]);
3163
- const status = require$$0.useMemo(() => {
3164
- return {
3165
- icon: dateValue ? 'trash-2' : 'calendar',
3166
- label: dateValue
3167
- ? dates.dateFormatTemplate(dateValue, format ?? DATE_FORMAT)
3168
- : ''
3169
- };
3170
- }, [dateValue, format]);
3171
- require$$0.useEffect(() => {
3172
- const dateSecure = components.verifyDateRange({
3173
- date: formControl?.value ?? date ?? today.current,
3174
- minDate,
3175
- maxDate
3176
- });
3177
- setValue(dateSecure);
3178
- formControl?.setValue(dateSecure);
3179
- }, []);
3180
- const onClickInput = require$$0.useCallback(() => {
3181
- !readOnly && setModalIsVisible(true);
3182
- }, [readOnly]);
3183
- const onChange = require$$0.useCallback((value) => {
3184
- setValue(value);
3185
- onValue?.(value);
3186
- }, [onValue]);
3187
- const onClickAction = require$$0.useCallback(() => {
3188
- if (dateValue) {
3189
- formControl?.setValue(valueInitial);
3190
- formControl?.touch();
3191
- onChange(valueInitial);
3192
- }
3193
- else {
3194
- setModalIsVisible(true);
3195
- }
3196
- }, [dateValue, formControl, valueInitial, onChange]);
3197
- const onListener = require$$0.useCallback(({ event, value }) => {
3198
- event !== components.PickerListenerEvent.Cancel && onChange(value);
3199
- formControl?.touch();
3200
- setModalIsVisible(false);
3201
- }, [formControl, onChange]);
3202
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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: status.label, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
3203
- }
3204
-
3205
- function rangeFormatTemplate({ maxDate, minDate }) {
3206
- const minFormat = dates.dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
3207
- const maxFormat = dates.dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
3208
- return `${minFormat} - ${maxFormat}`;
3209
- }
3210
-
3211
- function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
3212
- const _date = require$$0.useMemo(() => dates.normalizeMinTime(datePicker ?? new Date()), [datePicker]);
3213
- const _range = require$$0.useMemo(() => formControl?.value ?? dates.DateRange.now(), [formControl?.value]);
3214
- const yearControl = reactForms.useReactControl(_date.getFullYear());
3215
- const monthControl = reactForms.useReactControl(_date.getMonth());
3216
- const rangeControl = reactForms.useReactControl(_range);
3217
- const [visibility, setVisibility] = require$$0.useState('DAY');
3218
- const [labels, setLabels] = require$$0.useState({
3219
- dateActionCancel: reactI18n('dateActionCancel'),
3220
- dateActionSelect: reactI18n('dateActionSelect')
3221
- });
3222
- const value = require$$0.useMemo(() => {
3223
- return rangeControl.value ?? _range;
3224
- }, [rangeControl.value, _range]);
3225
- const date = require$$0.useMemo(() => {
3226
- let value = _date;
3227
- if (commons.valueIsDefined(yearControl.value)) {
3228
- value = dates.assignYearInDate(value, yearControl.value);
3229
- }
3230
- if (commons.valueIsDefined(monthControl.value)) {
3231
- value = dates.assignMonthInDate(value, monthControl.value);
3232
- }
3233
- return value;
3234
- }, [_date, yearControl.value, monthControl.value]);
3235
- const classNameComponent = require$$0.useMemo(() => {
3236
- return renderClassStatus('rls-picker-date-range__component', {
3237
- day: visibility === 'DAY',
3238
- month: visibility === 'MONTH',
3239
- year: visibility === 'YEAR'
3240
- });
3241
- }, [visibility]);
3242
- const classNameFooter = require$$0.useMemo(() => {
3243
- return renderClassStatus('rls-picker-date-range__footer', { automatic });
3244
- }, [automatic]);
3245
- const title = require$$0.useMemo(() => rangeFormatTemplate(value), [value]);
3246
- require$$0.useEffect(() => {
3247
- return i18n.i18nSubscribe(() => {
3248
- setLabels({
3249
- dateActionCancel: reactI18n('dateActionCancel'),
3250
- dateActionSelect: reactI18n('dateActionSelect')
3251
- });
3252
- });
3253
- }, []);
3254
- require$$0.useEffect(() => {
3255
- setVisibility('DAY');
3256
- }, [rangeControl.value]);
3257
- const onVisibilityDay = require$$0.useCallback(() => {
3258
- setVisibility('DAY');
3259
- }, []);
3260
- const onVisibilityTitle = require$$0.useCallback((type) => {
3261
- type === 'month' ? setVisibility('MONTH') : setVisibility('YEAR');
3262
- }, []);
3263
- const onCancel = require$$0.useCallback(() => {
3264
- onListener?.({ event: components.PickerListenerEvent.Cancel });
3265
- }, [onListener]);
3266
- const onSelect = require$$0.useCallback(() => {
3267
- formControl?.setValue(value);
3268
- onListener?.({ event: components.PickerListenerEvent.Select, value });
3269
- }, [formControl, value, onListener]);
3270
- 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(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityTitle }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDayRange, { formControl: rangeControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntimeExports.jsx("div", { className: classNameFooter, children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.dateActionSelect }) })] }) })] }));
3271
- }
3272
-
3273
- function RlsFieldDateRange({ children, date, disabled: disabledProps, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
3274
- const currentDate = require$$0.useMemo(() => date ?? new Date(), [date]);
3275
- const [value, setValue] = require$$0.useState(formControl?.value || valueInitial);
3276
- const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
3277
- const disabled = require$$0.useMemo(() => {
3278
- return formControl?.disabled || disabledProps;
3279
- }, [formControl?.disabled, disabledProps]);
3280
- const className = require$$0.useMemo(() => {
3281
- return renderClassStatus('rls-field-box', {
3282
- disabled,
3283
- readonly: readOnly
3284
- });
3285
- }, [disabled, readOnly]);
3286
- const dateRangeValue = require$$0.useMemo(() => {
3287
- return formControl ? formControl.value : value;
3288
- }, [formControl?.value, value]);
3289
- const status = require$$0.useMemo(() => {
3290
- return {
3291
- icon: dateRangeValue ? 'trash-2' : 'calendar',
3292
- valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
3293
- };
3294
- }, [dateRangeValue]);
3295
- const onClickInput = require$$0.useCallback(() => {
3296
- !readOnly && setModalIsVisible(true);
3297
- }, [readOnly]);
3298
- const onChange = require$$0.useCallback((value) => {
3299
- setValue(value);
3300
- onValue?.(value);
3301
- }, [onValue]);
3302
- const onClickAction = require$$0.useCallback(() => {
3303
- if (dateRangeValue) {
3304
- formControl?.setValue(valueInitial);
3305
- formControl?.touch();
3306
- onChange(valueInitial);
3307
- }
3308
- else {
3309
- setModalIsVisible(true);
3310
- }
3311
- }, [dateRangeValue, formControl, valueInitial, onChange]);
3312
- const onListener = require$$0.useCallback(({ event, value }) => {
3313
- event !== components.PickerListenerEvent.Cancel && onChange(value);
3314
- formControl?.touch();
3315
- setModalIsVisible(false);
3316
- }, [formControl, onChange]);
3317
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-range-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
3318
- }
3319
-
3320
- function useFieldSelect(props) {
3321
- const controller = useListController(props);
3322
- require$$0.useEffect(() => {
3323
- props.disabled && controller.setState({ focused: false });
3324
- }, [props.disabled]);
3325
- const onFocusInput = require$$0.useCallback(() => {
3326
- controller.setState({ focused: true });
3327
- }, [controller.setState]);
3328
- const onBlurInput = require$$0.useCallback(() => {
3329
- controller.setState({ focused: false });
3330
- }, [controller.setState]);
3331
- const onClickInput = require$$0.useCallback(() => {
3332
- !props.readOnly && controller.setState({ listIsVisible: true });
3333
- }, [controller.setState, props.readOnly]);
3334
- const onKeydownInput = require$$0.useCallback((event) => {
3335
- switch (event.code) {
3336
- case 'Space':
3337
- case 'Enter':
3338
- controller.setState({ listIsVisible: true });
3339
- break;
3340
- case 'Escape':
3341
- case 'Tab':
3342
- controller.setState({ listIsVisible: false });
3343
- break;
3344
- default:
3345
- controller.navigationInput(event);
3346
- break;
3347
- }
3348
- }, [controller.setState, controller.navigationInput]);
3349
- const onClickAction = require$$0.useCallback(() => {
3350
- const removable = !props.unremovable && !!controller.value;
3351
- if (removable) {
3352
- controller.setState({ listIsVisible: false });
3353
- controller.setFormValue(undefined);
3354
- props.onValue?.(props.value);
3355
- }
3356
- else {
3357
- const listIsVisible = !controller.listIsVisible;
3358
- controller.setState({ listIsVisible });
3359
- listIsVisible && controller.refInput?.current?.focus();
3360
- }
3361
- }, [
3362
- controller.listIsVisible,
3363
- controller.value,
3364
- controller.setState,
3365
- controller.setFormValue,
3366
- props.unremovable,
3367
- props.onValue
3368
- ]);
3369
- const onClickBackdrop = require$$0.useCallback(() => {
3370
- controller.setState({ listIsVisible: false });
3371
- }, [controller.setState]);
3372
- const onChange = require$$0.useCallback((element) => {
3373
- !props.disabled && controller.refInput?.current?.focus();
3374
- if (props.onSelect) {
3375
- controller.setState({ listIsVisible: false });
3376
- element.value && props.onSelect(element.value);
3377
- }
3378
- else {
3379
- controller.setFormValue(element);
3380
- controller.setState({ listIsVisible: false });
3381
- }
3382
- props.onValue?.(element.value);
3383
- }, [
3384
- controller.setState,
3385
- controller.setFormValue,
3386
- props.onSelect,
3387
- props.onValue,
3388
- props.disabled
3389
- ]);
3390
- const onClickElement = require$$0.useCallback((element) => {
3391
- return () => {
3392
- onChange(element);
3393
- };
3394
- }, [onChange]);
3395
- const onKeydownElement = require$$0.useCallback((element) => {
3396
- return (event) => {
3397
- event.code === 'Enter'
3398
- ? onChange(element)
3399
- : controller.navigationElement(event);
3400
- };
3401
- }, [onChange, controller.navigationElement]);
3402
- return {
3403
- ...controller,
3404
- onBlurInput,
3405
- onClickAction,
3406
- onClickBackdrop,
3407
- onClickInput,
3408
- onClickElement,
3409
- onFocusInput,
3410
- onKeydownElement,
3411
- onKeydownInput
3412
- };
3413
- }
3414
-
3415
- function RlsFieldSelectTemplate(props) {
3416
- const select = useFieldSelect(props);
3417
- const { render, suggestions, action, children, formControl, msgErrorDisabled, placeholder, rlsTheme, unremovable } = props;
3418
- const disabled = require$$0.useMemo(() => {
3419
- return formControl?.disabled || props.disabled;
3420
- }, [formControl?.disabled, props.disabled]);
3421
- const className = require$$0.useMemo(() => {
3422
- return renderClassStatus('rls-field-box', {
3423
- focused: select.focused && !disabled,
3424
- error: formControl?.wrong,
3425
- disabled: disabled,
3426
- readonly: props.readOnly
3427
- }, `rls-field-list rls-field-select ${props.className ?? ''}`);
3428
- }, [
3429
- formControl?.wrong,
3430
- select.focused,
3431
- props.className,
3432
- props.readOnly,
3433
- disabled
3434
- ]);
3435
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), !props.readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: !unremovable && !!select.value ? 'close' : 'arrow-ios-down', onClick: select.onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: select.listIsVisible, action: action, disabled: disabled, higher: select.higher, render: render, refList: select.refList, onClickElement: select.onClickElement, onKeydownElement: select.onKeydownElement, onClickBackdrop: select.onClickBackdrop })] }));
3436
- }
3437
- function RlsFieldSelect(props) {
3438
- const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
3439
- return jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: render });
3440
- }
3441
-
3442
- function RlsPickerColor({ color, formControl, onListener, rlsTheme }) {
3443
- const initialColor = require$$0.useMemo(() => formControl?.value ?? color ?? DEFAULT_COLOR, []);
3444
- const initialHsv = require$$0.useMemo(() => hexToHsv(initialColor) ?? { h: 258, s: 100, v: 100 }, []);
3445
- const canvasRef = require$$0.useRef(null);
3446
- const hueRef = require$$0.useRef(null);
3447
- const alphaRef = require$$0.useRef(null);
3448
- const selectionIsActive = require$$0.useRef(false);
3449
- const activeSlider = require$$0.useRef(null);
3450
- const hexEditing = require$$0.useRef(false);
3451
- const [hsv, setHsv] = require$$0.useState(initialHsv);
3452
- const [alpha, setAlpha] = require$$0.useState(1);
3453
- const [hexInput, setHexInput] = require$$0.useState(initialColor);
3454
- const [labels, setLabels] = require$$0.useState({
3455
- colorActionCancel: reactI18n('dateActionCancel'),
3456
- colorActionSelect: reactI18n('dateActionSelect')
3457
- });
3458
- const hexColor = require$$0.useMemo(() => hsvToHex(hsv), [hsv]);
3459
- const hexValue = require$$0.useMemo(() => {
3460
- return hexInput.replace('#', '');
3461
- }, [hexInput]);
3462
- const canvasStyle = require$$0.useMemo(() => {
3463
- const { r, g, b } = hsvToRgb({ h: hsv.h, s: 100, v: 100 });
3464
- return {
3465
- background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), rgb(${r}, ${g}, ${b})`
3466
- };
3467
- }, [hsv.h]);
3468
- const indicatorPosition = require$$0.useMemo(() => {
3469
- return {
3470
- left: `${(hsv.s / 100) * 100}%`,
3471
- top: `${100 - (hsv.v / 100) * 100}%`
3472
- };
3473
- }, [hsv.s, hsv.v]);
3474
- const hueSliderStyle = require$$0.useMemo(() => {
3475
- return {
3476
- background: 'linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)'
3477
- };
3478
- }, []);
3479
- const hueIndicatorStyle = require$$0.useMemo(() => {
3480
- return { left: `${(hsv.h / 360) * 100}%`, backgroundColor: hexColor };
3481
- }, [hsv.h, hexColor]);
3482
- const alphaSliderStyle = require$$0.useMemo(() => {
3483
- return {
3484
- background: `linear-gradient(to right, transparent, ${hexColor})`
3485
- };
3486
- }, [hexColor]);
3487
- const alphaIndicatorStyle = require$$0.useMemo(() => {
3488
- return { left: `${alpha * 100}%`, backgroundColor: hexColor };
3489
- }, [alpha, hexColor]);
3490
- require$$0.useEffect(() => {
3491
- !hexEditing.current && setHexInput(hexColor);
3492
- }, [hexColor]);
3493
- require$$0.useEffect(() => {
3494
- return i18n.i18nSubscribe(() => {
3495
- setLabels({
3496
- colorActionCancel: reactI18n('dateActionCancel'),
3497
- colorActionSelect: reactI18n('dateActionSelect')
3498
- });
3499
- });
3500
- }, []);
3501
- const getPositionInElement = require$$0.useCallback((element, clientX, clientY) => {
3502
- const rect = element.getBoundingClientRect();
3503
- return {
3504
- x: (clientX - rect.left) / rect.width,
3505
- y: (clientY - rect.top) / rect.height
3506
- };
3273
+ const getPositionInElement = require$$0.useCallback((element, clientX, clientY) => {
3274
+ const rect = element.getBoundingClientRect();
3275
+ return {
3276
+ x: (clientX - rect.left) / rect.width,
3277
+ y: (clientY - rect.top) / rect.height
3278
+ };
3507
3279
  }, []);
3508
3280
  const updateColorOnCanvas = require$$0.useEffectEvent((clientX, clientY) => {
3509
3281
  if (!canvasRef.current)
@@ -3601,55 +3373,324 @@ function RlsPickerColor({ color, formControl, onListener, rlsTheme }) {
3601
3373
  updateAlphaOnSlider(touch.clientX, touch.clientY);
3602
3374
  break;
3603
3375
  }
3604
- }, [updateColorOnCanvas, updateHueOnSlider, updateAlphaOnSlider]);
3605
- const onInactiveSelection = require$$0.useCallback(() => {
3606
- selectionIsActive.current = false;
3607
- activeSlider.current = null;
3608
- }, []);
3609
- const onHexChange = require$$0.useCallback((value) => {
3610
- setHexInput(value);
3611
- const normalized = normalizeHex(value);
3612
- if (normalized) {
3613
- const hsv = hexToHsv(normalized);
3614
- hsv && setHsv(hsv);
3376
+ }, [updateColorOnCanvas, updateHueOnSlider, updateAlphaOnSlider]);
3377
+ const onInactiveSelection = require$$0.useCallback(() => {
3378
+ selectionIsActive.current = false;
3379
+ activeSlider.current = null;
3380
+ }, []);
3381
+ const onHexChange = require$$0.useCallback((value) => {
3382
+ setHexInput(value);
3383
+ const normalized = normalizeHex(value);
3384
+ if (normalized) {
3385
+ const hsv = hexToHsv(normalized);
3386
+ if (hsv) {
3387
+ setHsv(hsv);
3388
+ }
3389
+ }
3390
+ }, []);
3391
+ const onHexFocus = require$$0.useCallback(() => {
3392
+ hexEditing.current = true;
3393
+ }, []);
3394
+ const onHexBlur = require$$0.useEffectEvent(() => {
3395
+ hexEditing.current = false;
3396
+ const normalized = normalizeHex(hexInput);
3397
+ if (normalized) {
3398
+ setHexInput(normalized);
3399
+ }
3400
+ else {
3401
+ setHexInput(hexColor);
3402
+ }
3403
+ });
3404
+ const onHexKeyDown = require$$0.useCallback((event) => {
3405
+ if (event.key === 'Enter') {
3406
+ onHexBlur();
3407
+ }
3408
+ }, [onHexBlur]);
3409
+ const onHexInputChange = require$$0.useCallback((event) => onHexChange(event.target.value ? `#${event.target.value}` : ''), [onHexChange]);
3410
+ const onCancel = require$$0.useCallback(() => {
3411
+ onListener?.({ event: components.PickerListenerEvent.Cancel });
3412
+ }, [onListener]);
3413
+ const onSelect = require$$0.useCallback(() => {
3414
+ formControl?.setValue(hexColor);
3415
+ onListener?.({ event: components.PickerListenerEvent.Select, value: hexColor });
3416
+ }, [formControl, hexColor, onListener]);
3417
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-color", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__preview", children: jsxRuntimeExports.jsx("div", { ref: canvasRef, className: "rls-picker-color__canvas", style: canvasStyle, "data-slider": "canvas", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__indicator", style: {
3418
+ left: indicatorPosition.left,
3419
+ top: indicatorPosition.top
3420
+ }, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__indicator__circle", style: { backgroundColor: hexColor } }) }) }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__controls", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider", children: jsxRuntimeExports.jsx("div", { ref: hueRef, className: "rls-picker-color__slider__track", style: hueSliderStyle, "data-slider": "hue", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider__thumb", style: hueIndicatorStyle }) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider", children: jsxRuntimeExports.jsx("div", { ref: alphaRef, className: "rls-picker-color__slider__track rls-picker-color__slider__track--alpha", style: alphaSliderStyle, "data-slider": "alpha", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider__thumb", style: alphaIndicatorStyle }) }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__hex", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__hex__swatch", style: { backgroundColor: hexColor } }), jsxRuntimeExports.jsx("span", { className: "rls-picker-color__hex__prefix", children: "#" }), jsxRuntimeExports.jsx("input", { className: "rls-picker-color__hex__input", type: "text", maxLength: 6, value: hexValue, onChange: onHexInputChange, onFocus: onHexFocus, onBlur: onHexBlur, onKeyDown: onHexKeyDown })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.colorActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.colorActionSelect }) })] })] }));
3421
+ }
3422
+
3423
+ function RlsFieldColor({ children, color, disabled: disabledProps, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
3424
+ const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
3425
+ const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
3426
+ const colorValue = require$$0.useMemo(() => {
3427
+ return formControl ? formControl.value : value;
3428
+ }, [formControl?.value, value]);
3429
+ const disabled = require$$0.useMemo(() => {
3430
+ return formControl?.disabled || disabledProps;
3431
+ }, [formControl?.disabled, disabledProps]);
3432
+ const className = require$$0.useMemo(() => {
3433
+ return renderClassStatus('rls-field-box', {
3434
+ disabled,
3435
+ readonly: readOnly
3436
+ });
3437
+ }, [disabled, readOnly]);
3438
+ const displayHex = require$$0.useMemo(() => {
3439
+ const hex = colorValue && hexIsValid(colorValue) ? colorValue : '';
3440
+ return normalizeHex(hex);
3441
+ }, [colorValue]);
3442
+ const onClickInput = require$$0.useCallback(() => {
3443
+ if (!readOnly) {
3444
+ setModalIsVisible(true);
3445
+ }
3446
+ }, [readOnly]);
3447
+ const onChange = require$$0.useCallback((value) => {
3448
+ setValue(value);
3449
+ onValue?.(value);
3450
+ }, [onValue]);
3451
+ const onClickAction = require$$0.useCallback(() => {
3452
+ if (colorValue) {
3453
+ formControl?.setValue(valueInitial);
3454
+ formControl?.touch();
3455
+ onChange(valueInitial);
3456
+ }
3457
+ else {
3458
+ setModalIsVisible(true);
3459
+ }
3460
+ }, [colorValue, formControl, valueInitial, onChange]);
3461
+ const onListener = require$$0.useCallback(({ event, value }) => {
3462
+ if (event !== components.PickerListenerEvent.Cancel) {
3463
+ onChange(value);
3464
+ }
3465
+ formControl?.touch();
3466
+ setModalIsVisible(false);
3467
+ }, [formControl, onChange]);
3468
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-color", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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: [displayHex && (jsxRuntimeExports.jsx("div", { className: "rls-field-color__swatch", style: { backgroundColor: displayHex } })), jsxRuntimeExports.jsx("input", { className: "rls-field-color__control", type: "text", value: displayHex, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: colorValue ? 'trash-2' : 'color-palette', onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-color-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerColor, { formControl: formControl, color: color, disabled: disabled, onListener: onListener }) })] }));
3469
+ }
3470
+
3471
+ const DATE_FORMAT = '{dd}/{mx}/{yy}';
3472
+ const DATE_FORMAT_TITLE = '{dw}, {mx} {dd} de {yy}';
3473
+ const DATE_RANGE_FORMAT = '{dd}/{mx}/{yy}';
3474
+
3475
+ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
3476
+ const today = require$$0.useRef(new Date()); // Initial current date in component
3477
+ const _date = require$$0.useMemo(() => {
3478
+ return formControl?.value ?? date ?? today.current;
3479
+ }, [formControl?.value, date]);
3480
+ const yearControl = reactForms.useReactControl(_date.getFullYear());
3481
+ const dayControl = reactForms.useReactControl(_date.getDate());
3482
+ const monthControl = reactForms.useReactControl(_date.getMonth());
3483
+ const [visibility, setVisibility] = require$$0.useState('DAY');
3484
+ const [labels, setLabels] = require$$0.useState({
3485
+ dateActionCancel: reactI18n('dateActionCancel'),
3486
+ dateActionSelect: reactI18n('dateActionSelect'),
3487
+ dateActionToday: reactI18n('dateActionToday')
3488
+ });
3489
+ const value = require$$0.useMemo(() => {
3490
+ return new Date(yearControl.value, monthControl.value, dayControl.value);
3491
+ }, [yearControl.value, monthControl.value, dayControl.value]);
3492
+ const classNameComponent = require$$0.useMemo(() => {
3493
+ return renderClassStatus('rls-picker-date__component', {
3494
+ day: visibility === 'DAY',
3495
+ month: visibility === 'MONTH',
3496
+ year: visibility === 'YEAR'
3497
+ });
3498
+ }, [visibility]);
3499
+ const title = require$$0.useMemo(() => {
3500
+ return dates.dateFormatTemplate(value, DATE_FORMAT_TITLE);
3501
+ }, [value]);
3502
+ const itIsDisabledToday = require$$0.useMemo(() => components.dateOutRange({
3503
+ date: today.current,
3504
+ maxDate,
3505
+ minDate
3506
+ }), [maxDate, minDate]);
3507
+ require$$0.useEffect(() => {
3508
+ const date = components.verifyDateRange({ date: _date, minDate, maxDate });
3509
+ yearControl.setValue(date.getFullYear());
3510
+ monthControl.setValue(date.getMonth());
3511
+ dayControl.setValue(date.getDate());
3512
+ formControl?.setValue(date);
3513
+ return i18n.i18nSubscribe(() => {
3514
+ setLabels({
3515
+ dateActionCancel: reactI18n('dateActionCancel'),
3516
+ dateActionSelect: reactI18n('dateActionSelect'),
3517
+ dateActionToday: reactI18n('dateActionToday')
3518
+ });
3519
+ });
3520
+ }, []);
3521
+ const onVisibilityDay = require$$0.useCallback(() => {
3522
+ setVisibility('DAY');
3523
+ }, []);
3524
+ const onVisibilityTitle = require$$0.useCallback((type) => {
3525
+ if (type === 'month') {
3526
+ setVisibility('MONTH');
3527
+ }
3528
+ else {
3529
+ setVisibility('YEAR');
3530
+ }
3531
+ }, []);
3532
+ const onCancel = require$$0.useCallback(() => {
3533
+ onListener?.({ event: components.PickerListenerEvent.Cancel });
3534
+ }, [onListener]);
3535
+ const onToday = require$$0.useCallback(() => {
3536
+ yearControl.setValue(today.current.getFullYear());
3537
+ dayControl.setValue(today.current.getDate());
3538
+ monthControl.setValue(today.current.getMonth());
3539
+ formControl?.setValue(today.current);
3540
+ onListener?.({
3541
+ event: components.PickerListenerEvent.Now,
3542
+ value: today.current
3543
+ });
3544
+ }, [formControl, onListener]);
3545
+ const onSelect = require$$0.useCallback(() => {
3546
+ formControl?.setValue(value);
3547
+ onListener?.({
3548
+ event: components.PickerListenerEvent.Select,
3549
+ value: value
3550
+ });
3551
+ }, [formControl, value, onListener]);
3552
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityTitle }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDay, { formControl: dayControl, date: value, month: monthControl.value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, date: value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), !automatic && (jsxRuntimeExports.jsx("div", { className: "rls-picker-date__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "calendar", onClick: onToday, disabled: itIsDisabledToday }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.dateActionSelect }) })] }) }))] }));
3553
+ }
3554
+
3555
+ function RlsFieldDate({ children, date, disabled: disabledProps, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
3556
+ const today = require$$0.useRef(new Date()); // Initial current date in component
3557
+ const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
3558
+ const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
3559
+ const disabled = require$$0.useMemo(() => {
3560
+ return formControl?.disabled || disabledProps;
3561
+ }, [formControl?.disabled, disabledProps]);
3562
+ const className = require$$0.useMemo(() => {
3563
+ return renderClassStatus('rls-field-box', {
3564
+ disabled,
3565
+ readonly: readOnly
3566
+ });
3567
+ }, [disabled, readOnly]);
3568
+ const dateValue = require$$0.useMemo(() => {
3569
+ return formControl ? formControl.value : value;
3570
+ }, [formControl?.value, value]);
3571
+ const status = require$$0.useMemo(() => {
3572
+ return {
3573
+ icon: dateValue ? 'trash-2' : 'calendar',
3574
+ label: dateValue
3575
+ ? dates.dateFormatTemplate(dateValue, format ?? DATE_FORMAT)
3576
+ : ''
3577
+ };
3578
+ }, [dateValue, format]);
3579
+ require$$0.useEffect(() => {
3580
+ const dateSecure = components.verifyDateRange({
3581
+ date: formControl?.value ?? date ?? today.current,
3582
+ minDate,
3583
+ maxDate
3584
+ });
3585
+ setValue(dateSecure);
3586
+ formControl?.setValue(dateSecure);
3587
+ }, []);
3588
+ const onClickInput = require$$0.useCallback(() => {
3589
+ if (!readOnly) {
3590
+ setModalIsVisible(true);
3591
+ }
3592
+ }, [readOnly]);
3593
+ const onChange = require$$0.useCallback((value) => {
3594
+ setValue(value);
3595
+ onValue?.(value);
3596
+ }, [onValue]);
3597
+ const onClickAction = require$$0.useCallback(() => {
3598
+ if (dateValue) {
3599
+ formControl?.setValue(valueInitial);
3600
+ formControl?.touch();
3601
+ onChange(valueInitial);
3602
+ }
3603
+ else {
3604
+ setModalIsVisible(true);
3605
+ }
3606
+ }, [dateValue, formControl, valueInitial, onChange]);
3607
+ const onListener = require$$0.useCallback(({ event, value }) => {
3608
+ if (event !== components.PickerListenerEvent.Cancel) {
3609
+ onChange(value);
3610
+ }
3611
+ formControl?.touch();
3612
+ setModalIsVisible(false);
3613
+ }, [formControl, onChange]);
3614
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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: status.label, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
3615
+ }
3616
+
3617
+ function rangeFormatTemplate({ maxDate, minDate }) {
3618
+ const minFormat = dates.dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
3619
+ const maxFormat = dates.dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
3620
+ return `${minFormat} - ${maxFormat}`;
3621
+ }
3622
+
3623
+ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
3624
+ const _date = require$$0.useMemo(() => dates.normalizeMinTime(datePicker ?? new Date()), [datePicker]);
3625
+ const _range = require$$0.useMemo(() => formControl?.value ?? dates.DateRange.now(), [formControl?.value]);
3626
+ const yearControl = reactForms.useReactControl(_date.getFullYear());
3627
+ const monthControl = reactForms.useReactControl(_date.getMonth());
3628
+ const rangeControl = reactForms.useReactControl(_range);
3629
+ const [visibility, setVisibility] = require$$0.useState('DAY');
3630
+ const [labels, setLabels] = require$$0.useState({
3631
+ dateActionCancel: reactI18n('dateActionCancel'),
3632
+ dateActionSelect: reactI18n('dateActionSelect')
3633
+ });
3634
+ const value = require$$0.useMemo(() => {
3635
+ return rangeControl.value ?? _range;
3636
+ }, [rangeControl.value, _range]);
3637
+ const date = require$$0.useMemo(() => {
3638
+ let value = _date;
3639
+ if (commons.valueIsDefined(yearControl.value)) {
3640
+ value = dates.assignYearInDate(value, yearControl.value);
3641
+ }
3642
+ if (commons.valueIsDefined(monthControl.value)) {
3643
+ value = dates.assignMonthInDate(value, monthControl.value);
3615
3644
  }
3645
+ return value;
3646
+ }, [_date, yearControl.value, monthControl.value]);
3647
+ const classNameComponent = require$$0.useMemo(() => {
3648
+ return renderClassStatus('rls-picker-date-range__component', {
3649
+ day: visibility === 'DAY',
3650
+ month: visibility === 'MONTH',
3651
+ year: visibility === 'YEAR'
3652
+ });
3653
+ }, [visibility]);
3654
+ const classNameFooter = require$$0.useMemo(() => {
3655
+ return renderClassStatus('rls-picker-date-range__footer', { automatic });
3656
+ }, [automatic]);
3657
+ const title = require$$0.useMemo(() => rangeFormatTemplate(value), [value]);
3658
+ require$$0.useEffect(() => {
3659
+ return i18n.i18nSubscribe(() => {
3660
+ setLabels({
3661
+ dateActionCancel: reactI18n('dateActionCancel'),
3662
+ dateActionSelect: reactI18n('dateActionSelect')
3663
+ });
3664
+ });
3616
3665
  }, []);
3617
- const onHexFocus = require$$0.useCallback(() => {
3618
- hexEditing.current = true;
3666
+ require$$0.useEffect(() => {
3667
+ setVisibility('DAY');
3668
+ }, [rangeControl.value]);
3669
+ const onVisibilityDay = require$$0.useCallback(() => {
3670
+ setVisibility('DAY');
3619
3671
  }, []);
3620
- const onHexBlur = require$$0.useEffectEvent(() => {
3621
- hexEditing.current = false;
3622
- const normalized = normalizeHex(hexInput);
3623
- if (normalized) {
3624
- setHexInput(normalized);
3672
+ const onVisibilityTitle = require$$0.useCallback((type) => {
3673
+ if (type === 'month') {
3674
+ setVisibility('MONTH');
3625
3675
  }
3626
3676
  else {
3627
- setHexInput(hexColor);
3677
+ setVisibility('YEAR');
3628
3678
  }
3629
- });
3630
- const onHexKeyDown = require$$0.useCallback((event) => {
3631
- event.key === 'Enter' && onHexBlur();
3632
- }, [onHexBlur]);
3633
- const onHexInputChange = require$$0.useCallback((event) => onHexChange(event.target.value ? `#${event.target.value}` : ''), [onHexChange]);
3679
+ }, []);
3634
3680
  const onCancel = require$$0.useCallback(() => {
3635
3681
  onListener?.({ event: components.PickerListenerEvent.Cancel });
3636
3682
  }, [onListener]);
3637
3683
  const onSelect = require$$0.useCallback(() => {
3638
- formControl?.setValue(hexColor);
3639
- onListener?.({ event: components.PickerListenerEvent.Select, value: hexColor });
3640
- }, [formControl, hexColor, onListener]);
3641
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-color", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__preview", children: jsxRuntimeExports.jsx("div", { ref: canvasRef, className: "rls-picker-color__canvas", style: canvasStyle, "data-slider": "canvas", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__indicator", style: {
3642
- left: indicatorPosition.left,
3643
- top: indicatorPosition.top
3644
- }, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__indicator__circle", style: { backgroundColor: hexColor } }) }) }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__controls", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider", children: jsxRuntimeExports.jsx("div", { ref: hueRef, className: "rls-picker-color__slider__track", style: hueSliderStyle, "data-slider": "hue", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider__thumb", style: hueIndicatorStyle }) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider", children: jsxRuntimeExports.jsx("div", { ref: alphaRef, className: "rls-picker-color__slider__track rls-picker-color__slider__track--alpha", style: alphaSliderStyle, "data-slider": "alpha", onMouseDown: onMouseDown, onMouseMove: onMouseMove, onMouseUp: onInactiveSelection, onMouseLeave: onInactiveSelection, onTouchStart: onTouchStart, onTouchMove: onTouchMove, onTouchEnd: onInactiveSelection, children: jsxRuntimeExports.jsx("div", { className: "rls-picker-color__slider__thumb", style: alphaIndicatorStyle }) }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__hex", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__hex__swatch", style: { backgroundColor: hexColor } }), jsxRuntimeExports.jsx("span", { className: "rls-picker-color__hex__prefix", children: "#" }), jsxRuntimeExports.jsx("input", { className: "rls-picker-color__hex__input", type: "text", maxLength: 6, value: hexValue, onChange: onHexInputChange, onFocus: onHexFocus, onBlur: onHexBlur, onKeyDown: onHexKeyDown })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-picker-color__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-color__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.colorActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-color__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.colorActionSelect }) })] })] }));
3684
+ formControl?.setValue(value);
3685
+ onListener?.({ event: components.PickerListenerEvent.Select, value });
3686
+ }, [formControl, value, onListener]);
3687
+ 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(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityTitle }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDayRange, { formControl: rangeControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntimeExports.jsx("div", { className: classNameFooter, children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "flat", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "gradient", onClick: onSelect, children: labels.dateActionSelect }) })] }) })] }));
3645
3688
  }
3646
3689
 
3647
- function RlsFieldColor({ children, color, disabled: disabledProps, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
3648
- const [value, setValue] = require$$0.useState(formControl?.value ?? valueInitial);
3690
+ function RlsFieldDateRange({ children, date, disabled: disabledProps, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value: valueInitial }) {
3691
+ const currentDate = require$$0.useMemo(() => date ?? new Date(), [date]);
3692
+ const [value, setValue] = require$$0.useState(formControl?.value || valueInitial);
3649
3693
  const [modalIsVisible, setModalIsVisible] = require$$0.useState(false);
3650
- const colorValue = require$$0.useMemo(() => {
3651
- return formControl ? formControl.value : value;
3652
- }, [formControl?.value, value]);
3653
3694
  const disabled = require$$0.useMemo(() => {
3654
3695
  return formControl?.disabled || disabledProps;
3655
3696
  }, [formControl?.disabled, disabledProps]);
@@ -3659,19 +3700,26 @@ function RlsFieldColor({ children, color, disabled: disabledProps, formControl,
3659
3700
  readonly: readOnly
3660
3701
  });
3661
3702
  }, [disabled, readOnly]);
3662
- const displayHex = require$$0.useMemo(() => {
3663
- const hex = colorValue && hexIsValid(colorValue) ? colorValue : '';
3664
- return normalizeHex(hex);
3665
- }, [colorValue]);
3703
+ const dateRangeValue = require$$0.useMemo(() => {
3704
+ return formControl ? formControl.value : value;
3705
+ }, [formControl?.value, value]);
3706
+ const status = require$$0.useMemo(() => {
3707
+ return {
3708
+ icon: dateRangeValue ? 'trash-2' : 'calendar',
3709
+ valueInput: dateRangeValue ? rangeFormatTemplate(dateRangeValue) : ''
3710
+ };
3711
+ }, [dateRangeValue]);
3666
3712
  const onClickInput = require$$0.useCallback(() => {
3667
- !readOnly && setModalIsVisible(true);
3713
+ if (!readOnly) {
3714
+ setModalIsVisible(true);
3715
+ }
3668
3716
  }, [readOnly]);
3669
3717
  const onChange = require$$0.useCallback((value) => {
3670
3718
  setValue(value);
3671
3719
  onValue?.(value);
3672
3720
  }, [onValue]);
3673
3721
  const onClickAction = require$$0.useCallback(() => {
3674
- if (colorValue) {
3722
+ if (dateRangeValue) {
3675
3723
  formControl?.setValue(valueInitial);
3676
3724
  formControl?.touch();
3677
3725
  onChange(valueInitial);
@@ -3679,13 +3727,15 @@ function RlsFieldColor({ children, color, disabled: disabledProps, formControl,
3679
3727
  else {
3680
3728
  setModalIsVisible(true);
3681
3729
  }
3682
- }, [colorValue, formControl, valueInitial, onChange]);
3730
+ }, [dateRangeValue, formControl, valueInitial, onChange]);
3683
3731
  const onListener = require$$0.useCallback(({ event, value }) => {
3684
- event !== components.PickerListenerEvent.Cancel && onChange(value);
3732
+ if (event !== components.PickerListenerEvent.Cancel) {
3733
+ onChange(value);
3734
+ }
3685
3735
  formControl?.touch();
3686
3736
  setModalIsVisible(false);
3687
3737
  }, [formControl, onChange]);
3688
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-color", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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: [displayHex && (jsxRuntimeExports.jsx("div", { className: "rls-field-color__swatch", style: { backgroundColor: displayHex } })), jsxRuntimeExports.jsx("input", { className: "rls-field-color__control", type: "text", value: displayHex, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: colorValue ? 'trash-2' : 'color-palette', onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-color-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerColor, { formControl: formControl, color: color, disabled: disabled, onListener: onListener }) })] }));
3738
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("span", { 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: status.valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), !readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: status.icon, onClick: onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { className: "rls-field-date-range-modal", visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
3689
3739
  }
3690
3740
 
3691
3741
  const MAX_LIST_HEIGHT_REM = 90;
@@ -3726,8 +3776,9 @@ function useFieldList(props) {
3726
3776
  const [selected, setSelected] = require$$0.useState([]);
3727
3777
  require$$0.useEffect(() => {
3728
3778
  function onCloseSuggestions({ target }) {
3729
- !refContent?.current?.contains(target) &&
3779
+ if (!refContent?.current?.contains(target)) {
3730
3780
  setState((state) => ({ ...state, listIsVisible: false }));
3781
+ }
3731
3782
  }
3732
3783
  document.addEventListener('click', onCloseSuggestions);
3733
3784
  return () => {
@@ -3802,7 +3853,9 @@ function useFieldList(props) {
3802
3853
  }, [selected, formControl, props.onValue]);
3803
3854
  const onKeydownElement = require$$0.useCallback((element) => {
3804
3855
  return (event) => {
3805
- event.code === 'Enter' && toggleElement(element);
3856
+ if (event.code === 'Enter') {
3857
+ toggleElement(element);
3858
+ }
3806
3859
  };
3807
3860
  }, [toggleElement]);
3808
3861
  return {
@@ -3851,6 +3904,141 @@ function RlsFieldList(props) {
3851
3904
  return jsxRuntimeExports.jsx(RlsFieldListInner, { ...props, render: render, fieldList: fieldList });
3852
3905
  }
3853
3906
 
3907
+ function useFieldSelect(props) {
3908
+ const controller = useListController(props);
3909
+ require$$0.useEffect(() => {
3910
+ if (props.disabled) {
3911
+ controller.setState({ focused: false });
3912
+ }
3913
+ }, [props.disabled]);
3914
+ const onFocusInput = require$$0.useCallback(() => {
3915
+ controller.setState({ focused: true });
3916
+ }, [controller.setState]);
3917
+ const onBlurInput = require$$0.useCallback(() => {
3918
+ controller.setState({ focused: false });
3919
+ }, [controller.setState]);
3920
+ const onClickInput = require$$0.useCallback(() => {
3921
+ if (!props.readOnly) {
3922
+ controller.setState({ listIsVisible: true });
3923
+ }
3924
+ }, [controller.setState, props.readOnly]);
3925
+ const onKeydownInput = require$$0.useCallback((event) => {
3926
+ switch (event.code) {
3927
+ case 'Space':
3928
+ case 'Enter':
3929
+ controller.setState({ listIsVisible: true });
3930
+ break;
3931
+ case 'Escape':
3932
+ case 'Tab':
3933
+ controller.setState({ listIsVisible: false });
3934
+ break;
3935
+ default:
3936
+ controller.navigationInput(event);
3937
+ break;
3938
+ }
3939
+ }, [controller.setState, controller.navigationInput]);
3940
+ const onClickAction = require$$0.useCallback(() => {
3941
+ const removable = !props.unremovable && !!controller.value;
3942
+ if (removable) {
3943
+ controller.setState({ listIsVisible: false });
3944
+ controller.setFormValue(undefined);
3945
+ props.onValue?.(props.value);
3946
+ }
3947
+ else {
3948
+ const listIsVisible = !controller.listIsVisible;
3949
+ controller.setState({ listIsVisible });
3950
+ if (listIsVisible) {
3951
+ controller.refInput?.current?.focus();
3952
+ }
3953
+ }
3954
+ }, [
3955
+ controller.listIsVisible,
3956
+ controller.value,
3957
+ controller.setState,
3958
+ controller.setFormValue,
3959
+ props.unremovable,
3960
+ props.onValue
3961
+ ]);
3962
+ const onClickBackdrop = require$$0.useCallback(() => {
3963
+ controller.setState({ listIsVisible: false });
3964
+ }, [controller.setState]);
3965
+ const onChange = require$$0.useCallback((element) => {
3966
+ if (!props.disabled) {
3967
+ controller.refInput?.current?.focus();
3968
+ }
3969
+ if (props.onSelect) {
3970
+ controller.setState({ listIsVisible: false });
3971
+ if (element.value) {
3972
+ props.onSelect(element.value);
3973
+ }
3974
+ }
3975
+ else {
3976
+ controller.setFormValue(element);
3977
+ controller.setState({ listIsVisible: false });
3978
+ }
3979
+ props.onValue?.(element.value);
3980
+ }, [
3981
+ controller.setState,
3982
+ controller.setFormValue,
3983
+ props.onSelect,
3984
+ props.onValue,
3985
+ props.disabled
3986
+ ]);
3987
+ const onClickElement = require$$0.useCallback((element) => {
3988
+ return () => {
3989
+ onChange(element);
3990
+ };
3991
+ }, [onChange]);
3992
+ const onKeydownElement = require$$0.useCallback((element) => {
3993
+ return (event) => {
3994
+ if (event.code === 'Enter') {
3995
+ onChange(element);
3996
+ }
3997
+ else {
3998
+ controller.navigationElement(event);
3999
+ }
4000
+ };
4001
+ }, [onChange, controller.navigationElement]);
4002
+ return {
4003
+ ...controller,
4004
+ onBlurInput,
4005
+ onClickAction,
4006
+ onClickBackdrop,
4007
+ onClickInput,
4008
+ onClickElement,
4009
+ onFocusInput,
4010
+ onKeydownElement,
4011
+ onKeydownInput
4012
+ };
4013
+ }
4014
+
4015
+ function RlsFieldSelectTemplate(props) {
4016
+ const select = useFieldSelect(props);
4017
+ const { render, suggestions, action, children, formControl, msgErrorDisabled, placeholder, rlsTheme, unremovable } = props;
4018
+ const disabled = require$$0.useMemo(() => {
4019
+ return formControl?.disabled || props.disabled;
4020
+ }, [formControl?.disabled, props.disabled]);
4021
+ const className = require$$0.useMemo(() => {
4022
+ return renderClassStatus('rls-field-box', {
4023
+ focused: select.focused && !disabled,
4024
+ error: formControl?.wrong,
4025
+ disabled: disabled,
4026
+ readonly: props.readOnly
4027
+ }, `rls-field-list rls-field-select ${props.className ?? ''}`);
4028
+ }, [
4029
+ formControl?.wrong,
4030
+ select.focused,
4031
+ props.className,
4032
+ props.readOnly,
4033
+ disabled
4034
+ ]);
4035
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.refContent, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { 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", { ref: select.refInput, className: "rls-field-list__control", readOnly: true, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput, disabled: disabled }), !props.readOnly && (jsxRuntimeExports.jsx(RlsButtonIcon, { icon: !unremovable && !!select.value ? 'close' : 'arrow-ios-down', onClick: select.onClickAction, disabled: disabled }))] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx(RlsFieldListSuggestions, { elements: suggestions, visible: select.listIsVisible, action: action, disabled: disabled, higher: select.higher, render: render, refList: select.refList, onClickElement: select.onClickElement, onKeydownElement: select.onKeydownElement, onClickBackdrop: select.onClickBackdrop })] }));
4036
+ }
4037
+ function RlsFieldSelect(props) {
4038
+ const render = require$$0.useCallback((element) => (jsxRuntimeExports.jsx(RlsBallot, { className: "rls-field-list__ballot", subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })), []);
4039
+ return jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: render });
4040
+ }
4041
+
3854
4042
  function RlsFormNavigation({ children, className, controller, visible, rlsTheme }) {
3855
4043
  const classNameForm = require$$0.useMemo(() => {
3856
4044
  return renderClassStatus('rls-form-navigation', { visible: controller?.visible ?? visible }, className);
@@ -3955,7 +4143,7 @@ function useResize(props) {
3955
4143
  const dimension = require$$0.useRef({ height: 0, width: 0 });
3956
4144
  const observer = require$$0.useCallback((entries) => {
3957
4145
  const { height, width } = entries[0].contentRect;
3958
- onResize &&
4146
+ if (onResize) {
3959
4147
  onResize({
3960
4148
  current: dimension.current,
3961
4149
  dimension: {
@@ -3963,6 +4151,7 @@ function useResize(props) {
3963
4151
  width
3964
4152
  }
3965
4153
  });
4154
+ }
3966
4155
  dimension.current = { height, width };
3967
4156
  }, []);
3968
4157
  require$$0.useEffect(() => {
@@ -4254,7 +4443,9 @@ function useImageEditorController(options) {
4254
4443
  }, []);
4255
4444
  const onEditorValue = require$$0.useCallback((image) => {
4256
4445
  setSrcEditor(undefined);
4257
- options.onValue && options.onValue(image);
4446
+ if (options.onValue) {
4447
+ options.onValue(image);
4448
+ }
4258
4449
  }, [options.onValue]);
4259
4450
  const onCancel = require$$0.useCallback(() => {
4260
4451
  setSrcEditor(undefined);
@@ -4273,7 +4464,9 @@ function useImageEditorController(options) {
4273
4464
  onCancel
4274
4465
  ]);
4275
4466
  const onImageChooser = require$$0.useCallback(() => {
4276
- !options.disabled && refInput.current.click();
4467
+ if (!options.disabled) {
4468
+ refInput.current.click();
4469
+ }
4277
4470
  }, [options.disabled]);
4278
4471
  return { onImageChooser, RlsImageEditorChooser };
4279
4472
  }
@@ -4286,7 +4479,9 @@ function RlsImageChooser(props) {
4286
4479
  }, [props.onValue]);
4287
4480
  const controller = useImageEditorController({ ...props, onValue });
4288
4481
  require$$0.useEffect(() => {
4289
- props.src && setSrc(props.src);
4482
+ if (props.src) {
4483
+ setSrc(props.src);
4484
+ }
4290
4485
  }, [props.src]);
4291
4486
  return (jsxRuntimeExports.jsxs("div", { className: "rls-image-chooser", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-chooser__avatar", onClick: controller.onImageChooser, children: src && jsxRuntimeExports.jsx("img", { src: src }) }), controller.RlsImageEditorChooser] }));
4292
4487
  }
@@ -4296,12 +4491,68 @@ function RlsModalSheet({ autoclose, children, className, controller, onAutoClose
4296
4491
  return renderClassStatus('rls-modal-sheet', { visible: controller?.visible ?? visible }, className);
4297
4492
  }, [className, visible, controller?.visible]);
4298
4493
  const onClickBackdrop = require$$0.useCallback(() => {
4299
- autoclose && controller?.close();
4494
+ if (autoclose) {
4495
+ controller?.close();
4496
+ }
4300
4497
  onAutoClose?.();
4301
4498
  }, [autoclose, controller, onAutoClose]);
4302
4499
  return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameModal, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal-sheet__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal-sheet__backdrop", onClick: onClickBackdrop })] }), document.body);
4303
4500
  }
4304
4501
 
4502
+ const DURATION_ANIMATION$1 = 240;
4503
+ const DURATION_DEFAULT = 4000;
4504
+ let _id = 0;
4505
+ function generateId() {
4506
+ return `rls-notification-${++_id}`;
4507
+ }
4508
+ function RlsNotification({ content, icon, onClose, rlsTheme, title, visible }) {
4509
+ const className = require$$0.useMemo(() => {
4510
+ return renderClassStatus('rls-notification', { visible });
4511
+ }, [visible]);
4512
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-notification__avatar", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsxs("div", { className: "rls-notification__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-notification__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-notification__title", children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-notification__content", children: content })] })] }));
4513
+ }
4514
+ function useNotifications() {
4515
+ const [notifications, setNotifications] = require$$0.useState([]);
4516
+ const timersRef = require$$0.useRef(new Map());
4517
+ require$$0.useEffect(() => {
4518
+ const timers = timersRef.current;
4519
+ return () => {
4520
+ timers.forEach((timer) => clearTimeout(timer));
4521
+ timers.clear();
4522
+ };
4523
+ }, []);
4524
+ const remove = require$$0.useCallback((id) => {
4525
+ const timer = timersRef.current.get(id);
4526
+ if (timer) {
4527
+ clearTimeout(timer);
4528
+ timersRef.current.delete(id);
4529
+ }
4530
+ setNotifications((notifications) => notifications.map((notification) => notification.id === id
4531
+ ? { ...notification, visible: false }
4532
+ : notification));
4533
+ setTimeout(() => {
4534
+ setNotifications((notifications) => notifications.filter((notification) => notification.id !== id));
4535
+ }, DURATION_ANIMATION$1);
4536
+ }, []);
4537
+ const notify = require$$0.useCallback((config) => {
4538
+ const id = generateId();
4539
+ const duration = config.duration ?? DURATION_DEFAULT;
4540
+ setNotifications((notifications) => [
4541
+ ...notifications,
4542
+ { id, config, visible: true }
4543
+ ]);
4544
+ const timer = setTimeout(() => {
4545
+ remove(id);
4546
+ }, duration);
4547
+ timersRef.current.set(id, timer);
4548
+ }, [remove]);
4549
+ const RlsNotifications = ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: "rls-notifications", children: notifications.map((notification) => (jsxRuntimeExports.jsx(RlsNotification, { ...notification.config, visible: notification.visible, onClose: () => remove(notification.id) }, notification.id))) }), document.body);
4550
+ return {
4551
+ RlsNotifications,
4552
+ notify
4553
+ };
4554
+ }
4555
+
4305
4556
  const DURATION_ANIMATION = 240;
4306
4557
  const DURATION_CHAR = 75;
4307
4558
  const DURATION_MAX = 9000;
@@ -4331,7 +4582,9 @@ function useSnackbar() {
4331
4582
  visible: false
4332
4583
  });
4333
4584
  const onClose = require$$0.useCallback(() => {
4334
- timeoutId.current && clearTimeout(timeoutId.current);
4585
+ if (timeoutId.current) {
4586
+ clearTimeout(timeoutId.current);
4587
+ }
4335
4588
  timeoutId.current = undefined;
4336
4589
  setState((state) => ({ ...state, visible: false }));
4337
4590
  }, []);
@@ -4365,17 +4618,17 @@ function useSnackbar() {
4365
4618
  };
4366
4619
  }
4367
4620
 
4368
- const RlsContext = require$$0.createContext({
4369
- confirmation: () => {
4370
- return Promise.resolve(ConfirmationResult.approved());
4371
- },
4372
- snackbar: () => { },
4373
- setIsMobile: () => { },
4374
- setNavbarInApp: () => { },
4375
- setNavbarIsCondense: () => { }
4376
- });
4621
+ const RlsContext = require$$0.createContext(null);
4622
+ function useRlsContext() {
4623
+ const state = require$$0.useContext(RlsContext);
4624
+ if (!state) {
4625
+ throw new Error('RlsApplication not wrapped in Project');
4626
+ }
4627
+ return state;
4628
+ }
4377
4629
  function RlsApplication({ children }) {
4378
4630
  const { RlsConfirmation, confirmation } = useConfirmation();
4631
+ const { RlsNotifications, notify } = useNotifications();
4379
4632
  const { RlsSnackbar, snackbar } = useSnackbar();
4380
4633
  const [navbarInApp, setNavbarInApp] = require$$0.useState(false);
4381
4634
  const [navbarIsCondense, setNavbarIsCondense] = require$$0.useState(false);
@@ -4389,11 +4642,12 @@ function RlsApplication({ children }) {
4389
4642
  }, [appIsMobile, navbarInApp, navbarIsCondense]);
4390
4643
  return (jsxRuntimeExports.jsxs(RlsContext, { value: {
4391
4644
  confirmation,
4645
+ notify,
4392
4646
  snackbar,
4393
4647
  setIsMobile,
4394
4648
  setNavbarInApp,
4395
4649
  setNavbarIsCondense
4396
- }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
4650
+ }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsNotifications, RlsConfirmation] }));
4397
4651
  }
4398
4652
 
4399
4653
  const DEFAULT_DESIGN_SYSTEM = 'bordered';
@@ -4445,9 +4699,9 @@ function useDropdownController(effect = '0% 0%') {
4445
4699
  const openWithEvent = require$$0.useCallback((event) => {
4446
4700
  const rectContent = component.current.getBoundingClientRect();
4447
4701
  const rectElement = event.target.getBoundingClientRect();
4448
- let positionX = 0;
4449
- let positionY = 0;
4450
- let effect = '0% 0%';
4702
+ let positionX;
4703
+ let positionY;
4704
+ let effect;
4451
4705
  let transform = 0;
4452
4706
  const elementX = rectElement.x + rectElement.width / 2;
4453
4707
  const elementY = rectElement.y + rectElement.height / 2;
@@ -4654,8 +4908,10 @@ exports.useFormSingleSelectionController = useFormSingleSelectionController;
4654
4908
  exports.useFormToggleController = useFormToggleController;
4655
4909
  exports.useImageEditorController = useImageEditorController;
4656
4910
  exports.useListController = useListController;
4911
+ exports.useNotifications = useNotifications;
4657
4912
  exports.usePortalController = usePortalController;
4658
4913
  exports.useRelocationOnComponent = useRelocationOnComponent;
4659
4914
  exports.useResize = useResize;
4915
+ exports.useRlsContext = useRlsContext;
4660
4916
  exports.useSnackbar = useSnackbar;
4661
4917
  //# sourceMappingURL=index.cjs.map