@rolster/react-components 19.1.12 → 19.1.13

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 (34) hide show
  1. package/dist/cjs/assets/{index-BamXLzHk.css → index-Dvak5slE.css} +36 -0
  2. package/dist/cjs/index.js +122 -25
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-BamXLzHk.css → index-Dvak5slE.css} +36 -0
  5. package/dist/es/index.js +121 -26
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/atoms/Button/Button.css +1 -0
  8. package/dist/esm/components/atoms/Button/Button.css.map +1 -1
  9. package/dist/esm/components/atoms/ButtonAction/ButtonAction.css +3 -0
  10. package/dist/esm/components/atoms/ButtonAction/ButtonAction.css.map +1 -1
  11. package/dist/esm/components/atoms/Input/Input.js +12 -12
  12. package/dist/esm/components/atoms/Input/Input.js.map +1 -1
  13. package/dist/esm/components/definitions.d.ts +5 -2
  14. package/dist/esm/components/organisms/BottomSheet/BottomSheet.d.ts +5 -2
  15. package/dist/esm/components/organisms/BottomSheet/BottomSheet.js +6 -5
  16. package/dist/esm/components/organisms/BottomSheet/BottomSheet.js.map +1 -1
  17. package/dist/esm/components/organisms/Dropdown/Dropdown.css +31 -0
  18. package/dist/esm/components/organisms/Dropdown/Dropdown.css.map +1 -0
  19. package/dist/esm/components/organisms/Dropdown/Dropdown.d.ts +8 -0
  20. package/dist/esm/components/organisms/Dropdown/Dropdown.js +23 -0
  21. package/dist/esm/components/organisms/Dropdown/Dropdown.js.map +1 -0
  22. package/dist/esm/components/organisms/FormNavigation/FormNavigation.d.ts +3 -1
  23. package/dist/esm/components/organisms/FormNavigation/FormNavigation.js +3 -3
  24. package/dist/esm/components/organisms/FormNavigation/FormNavigation.js.map +1 -1
  25. package/dist/esm/components/organisms/Modal/Modal.d.ts +5 -2
  26. package/dist/esm/components/organisms/Modal/Modal.js +6 -5
  27. package/dist/esm/components/organisms/Modal/Modal.js.map +1 -1
  28. package/dist/esm/controllers/DropdownController.d.ts +9 -0
  29. package/dist/esm/controllers/DropdownController.js +75 -0
  30. package/dist/esm/controllers/DropdownController.js.map +1 -0
  31. package/dist/esm/index.d.ts +3 -1
  32. package/dist/esm/index.js +2 -0
  33. package/dist/esm/index.js.map +1 -1
  34. package/package.json +1 -1
@@ -425,6 +425,7 @@
425
425
  color: var(--pvt-button-content-font-color);
426
426
  border: var(--pvt-button-content-border);
427
427
  background: var(--pvt-button-content-background);
428
+ pointer-events: none;
428
429
  }
429
430
  .rls-button__content::before {
430
431
  position: absolute;
@@ -592,6 +593,9 @@
592
593
  opacity: 0.5;
593
594
  pointer-events: none;
594
595
  }
596
+ .rls-button-action__content {
597
+ pointer-events: none;
598
+ }
595
599
  .rls-button-action__tooltip {
596
600
  position: absolute;
597
601
  top: calc(100% + var(--rls-sizing-x6));
@@ -2546,6 +2550,38 @@
2546
2550
  }
2547
2551
  } /*# sourceMappingURL=Confirmation.css.map */
2548
2552
 
2553
+ .rls-dropdown {
2554
+ --pvt-content-opacity: 0;
2555
+ --pvt-content-transform: scale(0, 0);
2556
+ position: var(--rlc-dropdown-position, absolute);
2557
+ display: block;
2558
+ opacity: 0;
2559
+ width: auto;
2560
+ z-index: -16;
2561
+ transition: opacity 240ms 0ms var(--rls-standard-curve);
2562
+ }
2563
+ .rls-dropdown--visible {
2564
+ --pvt-content-opacity: 1;
2565
+ --pvt-content-transform: scale(1, 1);
2566
+ opacity: 1;
2567
+ z-index: var(--rlc-dropdown-z-index, var(--rls-z-index-4));
2568
+ }
2569
+ .rls-dropdown__content {
2570
+ display: block;
2571
+ width: auto;
2572
+ max-width: var(--rlc-dropdown-max-width, 150rem);
2573
+ border-radius: var(--rlc-dropdown-radius, var(--rls-sizing-x6));
2574
+ padding: var(--rlc-dropdown-padding, var(--rls-sizing-x6));
2575
+ box-sizing: border-box;
2576
+ border: var(--rlc-dropdown-border, var(--rls-app-border-1-200));
2577
+ background: var(--rlc-dropdown-background, var(--rls-app-color-050));
2578
+ opacity: var(--pvt-content-opacity);
2579
+ transform: var(--pvt-content-transform);
2580
+ transition:
2581
+ transform 240ms 0ms var(--rls-standard-curve),
2582
+ opacity 240ms 0ms var(--rls-standard-curve);
2583
+ } /*# sourceMappingURL=Dropdown.css.map */
2584
+
2549
2585
  .rls-field-autocomplete {
2550
2586
  --pvt-control-width: 100%;
2551
2587
  --pvt-control-opacity: 1;
package/dist/es/index.js CHANGED
@@ -582,7 +582,7 @@ function RlsImage({ src, rlsTheme }) {
582
582
  }
583
583
 
584
584
  function RlsInput({ children, decimals, disabled, formControl, identifier, onBlur, onEnter, onFocus, onKeyDown, onKeyUp, onValue, placeholder, readOnly, type, value }) {
585
- const valueInitial = formControl?.value ?? value ? String(value) : '';
585
+ const valueInitial = (formControl?.value ?? value) ? String(value) : '';
586
586
  const [valueInput, setValueInput] = useState(valueInitial);
587
587
  const [focused, setFocused] = useState(false);
588
588
  const changeIsInternal = useRef(false);
@@ -593,7 +593,7 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
593
593
  }
594
594
  changeIsInternal.current = false;
595
595
  }, [formControl?.value]);
596
- const _onChange = useCallback((event) => {
596
+ const onChangeInput = useCallback((event) => {
597
597
  const valueInput = event.target.value;
598
598
  const value = type === 'number'
599
599
  ? parseFloat((+valueInput).toFixed(decimals))
@@ -603,22 +603,22 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
603
603
  setValueInput(valueInput);
604
604
  formControl?.setValue(value);
605
605
  }, [formControl, onValue, type, decimals]);
606
- const _onKeyDown = useCallback((event) => {
607
- onKeyDown && onKeyDown(event);
608
- event.key === 'Enter' && onEnter && onEnter();
606
+ const onKeyDownInput = useCallback((event) => {
607
+ onKeyDown?.(event);
608
+ event.key === 'Enter' && onEnter?.();
609
609
  }, [onKeyDown, onEnter]);
610
- const _onKeyUp = useCallback((event) => {
611
- onKeyUp && onKeyUp(event);
610
+ const onKeyUpInput = useCallback((event) => {
611
+ onKeyUp?.(event);
612
612
  }, [onKeyUp]);
613
- const _onFocus = useCallback(() => {
613
+ const onFocusInput = useCallback(() => {
614
614
  formControl?.focus();
615
615
  setFocused(() => true);
616
- onFocus && onFocus();
616
+ onFocus?.();
617
617
  }, [formControl, onFocus]);
618
- const _onBlur = useCallback(() => {
618
+ const onBlurInput = useCallback(() => {
619
619
  formControl?.blur();
620
620
  setFocused(() => false);
621
- onBlur && onBlur();
621
+ onBlur?.();
622
622
  }, [formControl, onBlur]);
623
623
  const className = useMemo(() => {
624
624
  return renderClassStatus('rls-input', {
@@ -626,7 +626,7 @@ function RlsInput({ children, decimals, disabled, formControl, identifier, onBlu
626
626
  focused: formControl?.focused ?? focused
627
627
  });
628
628
  }, [formControl?.focused, formControl?.disabled, focused, disabled]);
629
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, readOnly: readOnly, onFocus: _onFocus, onBlur: _onBlur, onChange: _onChange, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, value: valueInput }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
629
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, readOnly: readOnly, onFocus: onFocusInput, onBlur: onBlurInput, onChange: onChangeInput, onKeyDown: onKeyDownInput, onKeyUp: onKeyUpInput, value: valueInput }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
630
630
  }
631
631
 
632
632
  function RlsInputDecimal(props) {
@@ -1572,13 +1572,14 @@ function RlsToolbar({ actions, children, subtitle }) {
1572
1572
  return (jsxRuntimeExports.jsxs("div", { className: "rls-toolbar", children: [jsxRuntimeExports.jsxs("div", { className: "rls-toolbar__description", children: [children && jsxRuntimeExports.jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsxRuntimeExports.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntimeExports.jsx("div", { children: action }, index))) }))] }));
1573
1573
  }
1574
1574
 
1575
- function RlsBottomSheet({ children, className, onAutoClose, visible, rlsTheme }) {
1575
+ function RlsBottomSheet({ autoclose, children, className, controller, onBackdrop, visible, rlsTheme }) {
1576
1576
  const classNameSheet = useMemo(() => {
1577
- return renderClassStatus('rls-bottom-sheet', { visible }, className);
1578
- }, [className, visible]);
1577
+ return renderClassStatus('rls-bottom-sheet', { visible: controller?.visible ?? visible }, className);
1578
+ }, [className, visible, controller?.visible]);
1579
1579
  const onClickBackdrop = useCallback(() => {
1580
- onAutoClose && onAutoClose();
1581
- }, [onAutoClose]);
1580
+ autoclose && controller?.close();
1581
+ onBackdrop?.();
1582
+ }, [autoclose, controller, onBackdrop]);
1582
1583
  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);
1583
1584
  }
1584
1585
 
@@ -1751,6 +1752,25 @@ function RlsDatatableFloating({ children, className, identifier, invested, rlsTh
1751
1752
  return (jsxRuntimeExports.jsx("td", { id: identifier, className: classNameFloating, "rls-theme": rlsTheme, children: children }));
1752
1753
  }
1753
1754
 
1755
+ function RlsDropdown({ children, controller, rlsTheme }) {
1756
+ const className = useMemo(() => {
1757
+ return renderClassStatus('rls-dropdown', {
1758
+ visible: controller.visible
1759
+ });
1760
+ }, [controller.visible]);
1761
+ useEffect(() => {
1762
+ function onCloseDropdown({ target }) {
1763
+ !controller.component.current.contains(target) &&
1764
+ controller.close();
1765
+ }
1766
+ document.addEventListener('click', onCloseDropdown);
1767
+ return () => {
1768
+ document.removeEventListener('click', onCloseDropdown);
1769
+ };
1770
+ }, []);
1771
+ return (jsxRuntimeExports.jsx("div", { ref: controller.component, className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-dropdown__content", children: children }) }));
1772
+ }
1773
+
1754
1774
  function calculateMinHeightList(count, height) {
1755
1775
  return count <= 0 ? 160 : (count < 6 ? count : 6) * height;
1756
1776
  }
@@ -2058,13 +2078,14 @@ function RlsFieldAutocomplete(props) {
2058
2078
  return jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: render });
2059
2079
  }
2060
2080
 
2061
- function RlsModal({ children, className, onAutoClose, visible, rlsTheme }) {
2081
+ function RlsModal({ autoclose, children, className, controller, onBackdrop, visible, rlsTheme }) {
2062
2082
  const classNameModal = useMemo(() => {
2063
- return renderClassStatus('rls-modal', { visible }, className);
2064
- }, [className, visible]);
2083
+ return renderClassStatus('rls-modal', { visible: controller?.visible ?? visible }, className);
2084
+ }, [className, visible, controller?.visible]);
2065
2085
  const onClickBackdrop = useCallback(() => {
2066
- onAutoClose && onAutoClose();
2067
- }, [onAutoClose]);
2086
+ autoclose && controller?.close();
2087
+ onBackdrop?.();
2088
+ }, [autoclose, controller, onBackdrop]);
2068
2089
  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);
2069
2090
  }
2070
2091
 
@@ -2727,10 +2748,10 @@ function RlsFieldSelect(props) {
2727
2748
  return jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: render });
2728
2749
  }
2729
2750
 
2730
- function RlsFormNavigation({ children, className, visible, rlsTheme }) {
2751
+ function RlsFormNavigation({ children, className, controller, visible, rlsTheme }) {
2731
2752
  const classNameForm = useMemo(() => {
2732
- return renderClassStatus('rls-form-navigation', { visible }, className);
2733
- }, [visible, className]);
2753
+ return renderClassStatus('rls-form-navigation', { visible: controller?.visible ?? visible }, className);
2754
+ }, [className, visible, controller?.visible]);
2734
2755
  return ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: classNameForm, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-form-navigation__component", children: children }) }), document.body);
2735
2756
  }
2736
2757
 
@@ -3263,6 +3284,80 @@ function RlsApplication({ children }) {
3263
3284
  }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
3264
3285
  }
3265
3286
 
3287
+ function useDropdownController() {
3288
+ const [visible, setVisible] = useState(false);
3289
+ const component = useRef(null);
3290
+ const open = useCallback((positionX, positionY) => {
3291
+ component.current.style.transformOrigin = '0% 0%';
3292
+ component.current.style.top = `${positionY}px`;
3293
+ component.current.style.left = `${positionX}px`;
3294
+ setVisible(true);
3295
+ }, []);
3296
+ const openWithEvent = useCallback((event) => {
3297
+ const rectContent = component.current.getBoundingClientRect();
3298
+ const rectElement = event.target.getBoundingClientRect();
3299
+ let positionX = 0;
3300
+ let positionY = 0;
3301
+ let effect = '0% 0%';
3302
+ let transform = 0;
3303
+ const elementX = rectElement.x + rectElement.width / 2;
3304
+ const elementY = rectElement.y + rectElement.height / 2;
3305
+ if (elementX + rectContent.width <= window.innerWidth) {
3306
+ positionX = elementX;
3307
+ transform += 1;
3308
+ }
3309
+ else if (elementX + rectElement.width - rectContent.width > 0) {
3310
+ positionX = elementX + rectElement.width - rectContent.width;
3311
+ transform += 3;
3312
+ }
3313
+ else {
3314
+ positionX = window.innerWidth - rectContent.width;
3315
+ transform += 1;
3316
+ }
3317
+ if (elementY + rectContent.height <= window.innerHeight) {
3318
+ positionY = elementY;
3319
+ transform += 4;
3320
+ }
3321
+ else if (elementY + rectElement.height - rectContent.height > 0) {
3322
+ positionY = elementY + rectElement.height - rectContent.height;
3323
+ transform += 7;
3324
+ }
3325
+ else {
3326
+ positionY = window.innerHeight - rectContent.height;
3327
+ transform += 4;
3328
+ }
3329
+ switch (transform) {
3330
+ case 7:
3331
+ effect = '100% 0%';
3332
+ break;
3333
+ case 8:
3334
+ effect = '0% 100%';
3335
+ break;
3336
+ case 10:
3337
+ effect = '100% 100%';
3338
+ break;
3339
+ default:
3340
+ effect = '0% 0%';
3341
+ break;
3342
+ }
3343
+ component.current.style.transformOrigin = effect;
3344
+ component.current.style.top = `${positionY}px`;
3345
+ component.current.style.left = `${positionX}px`;
3346
+ setVisible(true);
3347
+ event.stopPropagation();
3348
+ }, []);
3349
+ const close = useCallback(() => {
3350
+ setVisible(false);
3351
+ }, []);
3352
+ return {
3353
+ close,
3354
+ component,
3355
+ open,
3356
+ openWithEvent,
3357
+ visible
3358
+ };
3359
+ }
3360
+
3266
3361
  function usePortalController() {
3267
3362
  const [visible, setVisible] = useState(false);
3268
3363
  const open = useCallback(() => {
@@ -3274,5 +3369,5 @@ function usePortalController() {
3274
3369
  return { close, open, visible };
3275
3370
  }
3276
3371
 
3277
- export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonOption, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalSheet, RlsNavbar, RlsPagination, RlsPickerClock, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useFieldAutocomplete, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, usePortalController, useRelocationOnComponent, useResize, useSnackbar };
3372
+ export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBottomSheet, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonOption, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContent, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableFloating, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsDropdown, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldClock, RlsFieldDate, RlsFieldDateRange, RlsFieldDecimal, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldPercentage, RlsFieldReadonly, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsImage, RlsImageChooser, RlsImageEditor, RlsInput, RlsInputDecimal, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputPercentage, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsModalSheet, RlsNavbar, RlsPagination, RlsPickerClock, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSlider, RlsSnackbar, RlsSpinner, RlsSwitch, RlsSwitchControl, RlsTabs, RlsTabularText, RlsToolbar, calculateImgDimension, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useDropdownController, useFieldAutocomplete, useFieldSelect, useFormSingleSelectionController, useFormToggleController, useImageEditorController, useListController, usePortalController, useRelocationOnComponent, useResize, useSnackbar };
3278
3373
  //# sourceMappingURL=index.js.map