@rolster/react-components 19.7.5 → 19.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +90 -34
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +90 -34
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +2 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.js +13 -4
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +16 -3
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
- package/dist/esm/components/organisms/FieldList/FieldListController.js +13 -3
- package/dist/esm/components/organisms/FieldList/FieldListController.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +13 -3
- package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
- package/dist/esm/components/organisms/Notifications/Notifications.d.ts +2 -1
- package/dist/esm/components/organisms/Notifications/Notifications.js +11 -5
- package/dist/esm/components/organisms/Notifications/Notifications.js.map +1 -1
- package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +2 -1
- package/dist/esm/components/organisms/Snackbar/Snackbar.js +12 -6
- package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
- package/dist/esm/context.js +3 -3
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/controllers/DropdownController.js +2 -8
- package/dist/esm/controllers/DropdownController.js.map +1 -1
- package/dist/esm/controllers/ListController.js +3 -3
- package/dist/esm/controllers/ListController.js.map +1 -1
- package/dist/esm/controllers/PortalController.js +2 -2
- package/dist/esm/controllers/PortalController.js.map +1 -1
- package/dist/esm/controllers/TabsController.d.ts +5 -1
- package/dist/esm/controllers/TabsController.js +12 -4
- package/dist/esm/controllers/TabsController.js.map +1 -1
- package/package.json +1 -1
package/dist/es/index.mjs
CHANGED
|
@@ -2378,10 +2378,19 @@ function RlsConfirmationComponent({ approved, className, content, reject, rlsThe
|
|
|
2378
2378
|
return (jsxRuntimeExports.jsxs("div", { className: classConfirmation, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__content", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { identifier: approved.identifier, type: approved.type, onClick: approved.onClick, disabled: approved.disabled, rlsTheme: approved.rlsTheme, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { identifier: reject.identifier, type: reject.type, onClick: reject.onClick, disabled: reject.disabled, rlsTheme: reject.rlsTheme, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
2379
2379
|
}
|
|
2380
2380
|
const RlsConfirmation = memo(RlsConfirmationComponent);
|
|
2381
|
+
const RlsConfirmationBase = RlsConfirmation;
|
|
2381
2382
|
function useConfirmation() {
|
|
2382
2383
|
const [config, setConfig] = useState({});
|
|
2383
2384
|
const [visible, setVisible] = useState(false);
|
|
2384
|
-
const
|
|
2385
|
+
const configRef = useRef(config);
|
|
2386
|
+
configRef.current = config;
|
|
2387
|
+
const visibleRef = useRef(visible);
|
|
2388
|
+
visibleRef.current = visible;
|
|
2389
|
+
const RlsConfirmation = useMemo(() => {
|
|
2390
|
+
return function RlsConfirmation(props) {
|
|
2391
|
+
return ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmationBase, { ...props, ...configRef.current, visible: visibleRef.current }), document.body);
|
|
2392
|
+
};
|
|
2393
|
+
}, []);
|
|
2385
2394
|
const confirmation = useCallback((options) => {
|
|
2386
2395
|
return new Promise((resolve) => {
|
|
2387
2396
|
setConfig({
|
|
@@ -2415,8 +2424,8 @@ function useConfirmation() {
|
|
|
2415
2424
|
});
|
|
2416
2425
|
}, []);
|
|
2417
2426
|
return {
|
|
2418
|
-
|
|
2419
|
-
|
|
2427
|
+
confirmation,
|
|
2428
|
+
RlsConfirmation
|
|
2420
2429
|
};
|
|
2421
2430
|
}
|
|
2422
2431
|
|
|
@@ -2554,7 +2563,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2554
2563
|
const refInput = useRef(null);
|
|
2555
2564
|
const listIsOpen = useRef(false);
|
|
2556
2565
|
const stableSuggestions = useStableSuggestions(suggestions);
|
|
2557
|
-
const collection = useMemo(() => new ListCollection(stableSuggestions, reference), [stableSuggestions]);
|
|
2566
|
+
const collection = useMemo(() => new ListCollection(stableSuggestions, reference), [stableSuggestions, reference]);
|
|
2558
2567
|
const [state, refreshState] = useState({
|
|
2559
2568
|
focused: false,
|
|
2560
2569
|
higher: false,
|
|
@@ -2663,7 +2672,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2663
2672
|
position: position.current
|
|
2664
2673
|
});
|
|
2665
2674
|
}, [state.higher]);
|
|
2666
|
-
return {
|
|
2675
|
+
return useMemo(() => ({
|
|
2667
2676
|
...state,
|
|
2668
2677
|
navigationElement,
|
|
2669
2678
|
navigationInput,
|
|
@@ -2672,7 +2681,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
|
|
|
2672
2681
|
refList,
|
|
2673
2682
|
setFormValue,
|
|
2674
2683
|
setState
|
|
2675
|
-
};
|
|
2684
|
+
}), [state, navigationElement, navigationInput, setFormValue, setState]);
|
|
2676
2685
|
}
|
|
2677
2686
|
|
|
2678
2687
|
const DURATION_ANIMATION$2 = 240;
|
|
@@ -2802,7 +2811,7 @@ function useFieldAutocomplete(props) {
|
|
|
2802
2811
|
}
|
|
2803
2812
|
};
|
|
2804
2813
|
}, [onChange, controller.navigationElement]);
|
|
2805
|
-
return {
|
|
2814
|
+
return useMemo(() => ({
|
|
2806
2815
|
...controller,
|
|
2807
2816
|
coincidences,
|
|
2808
2817
|
onBlurInput,
|
|
@@ -2815,7 +2824,20 @@ function useFieldAutocomplete(props) {
|
|
|
2815
2824
|
onKeydownInput,
|
|
2816
2825
|
pattern,
|
|
2817
2826
|
setPattern
|
|
2818
|
-
}
|
|
2827
|
+
}), [
|
|
2828
|
+
controller,
|
|
2829
|
+
coincidences,
|
|
2830
|
+
onBlurInput,
|
|
2831
|
+
onClickAction,
|
|
2832
|
+
onClickBackdrop,
|
|
2833
|
+
onClickControl,
|
|
2834
|
+
onClickElement,
|
|
2835
|
+
onFocusInput,
|
|
2836
|
+
onKeydownElement,
|
|
2837
|
+
onKeydownInput,
|
|
2838
|
+
pattern,
|
|
2839
|
+
setPattern
|
|
2840
|
+
]);
|
|
2819
2841
|
}
|
|
2820
2842
|
|
|
2821
2843
|
function RlsFieldAutocompleteTemplateComponent(props) {
|
|
@@ -3825,7 +3847,7 @@ function useFieldList(props) {
|
|
|
3825
3847
|
}
|
|
3826
3848
|
};
|
|
3827
3849
|
}, [toggleElement]);
|
|
3828
|
-
return {
|
|
3850
|
+
return useMemo(() => ({
|
|
3829
3851
|
...state,
|
|
3830
3852
|
selected,
|
|
3831
3853
|
refContent,
|
|
@@ -3837,7 +3859,17 @@ function useFieldList(props) {
|
|
|
3837
3859
|
onClickInput,
|
|
3838
3860
|
onKeydownElement,
|
|
3839
3861
|
onRemoveElement
|
|
3840
|
-
}
|
|
3862
|
+
}), [
|
|
3863
|
+
state,
|
|
3864
|
+
selected,
|
|
3865
|
+
isSelected,
|
|
3866
|
+
onClickAction,
|
|
3867
|
+
onClickBackdrop,
|
|
3868
|
+
onClickElement,
|
|
3869
|
+
onClickInput,
|
|
3870
|
+
onKeydownElement,
|
|
3871
|
+
onRemoveElement
|
|
3872
|
+
]);
|
|
3841
3873
|
}
|
|
3842
3874
|
|
|
3843
3875
|
function RlsFieldListInner({ render, suggestions, action, children, formControl, fieldList, msgErrorDisabled, placeholder, rlsTheme, ...props }) {
|
|
@@ -3960,7 +3992,7 @@ function useFieldSelect(props) {
|
|
|
3960
3992
|
}
|
|
3961
3993
|
};
|
|
3962
3994
|
}, [onChange, controller.navigationElement]);
|
|
3963
|
-
return {
|
|
3995
|
+
return useMemo(() => ({
|
|
3964
3996
|
...controller,
|
|
3965
3997
|
onBlurInput,
|
|
3966
3998
|
onClickAction,
|
|
@@ -3970,7 +4002,17 @@ function useFieldSelect(props) {
|
|
|
3970
4002
|
onFocusInput,
|
|
3971
4003
|
onKeydownElement,
|
|
3972
4004
|
onKeydownInput
|
|
3973
|
-
}
|
|
4005
|
+
}), [
|
|
4006
|
+
controller,
|
|
4007
|
+
onBlurInput,
|
|
4008
|
+
onClickAction,
|
|
4009
|
+
onClickBackdrop,
|
|
4010
|
+
onClickInput,
|
|
4011
|
+
onClickElement,
|
|
4012
|
+
onFocusInput,
|
|
4013
|
+
onKeydownElement,
|
|
4014
|
+
onKeydownInput
|
|
4015
|
+
]);
|
|
3974
4016
|
}
|
|
3975
4017
|
|
|
3976
4018
|
function RlsFieldSelectTemplateComponent(props) {
|
|
@@ -4467,6 +4509,8 @@ function RlsNotification({ content, icon, onClose, rlsTheme, title, visible }) {
|
|
|
4467
4509
|
function useNotifications() {
|
|
4468
4510
|
const [notifications, setNotifications] = useState([]);
|
|
4469
4511
|
const timersRef = useRef(new Map());
|
|
4512
|
+
const notificationsRef = useRef(notifications);
|
|
4513
|
+
notificationsRef.current = notifications;
|
|
4470
4514
|
useEffect(() => {
|
|
4471
4515
|
const timers = timersRef.current;
|
|
4472
4516
|
return () => {
|
|
@@ -4487,6 +4531,14 @@ function useNotifications() {
|
|
|
4487
4531
|
setNotifications((notifications) => notifications.filter((notification) => notification.id !== id));
|
|
4488
4532
|
}, DURATION_ANIMATION$1);
|
|
4489
4533
|
}, []);
|
|
4534
|
+
const RlsNotifications = useMemo(() => {
|
|
4535
|
+
return function RlsNotifications(props) {
|
|
4536
|
+
const className = renderClassStatus('rls-notifications', {
|
|
4537
|
+
visible: notificationsRef.current.length > 0
|
|
4538
|
+
});
|
|
4539
|
+
return ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: className, ...props, children: notificationsRef.current.map((notification) => (jsxRuntimeExports.jsx(RlsNotification, { ...notification.config, visible: notification.visible, onClose: () => remove(notification.id) }, notification.id))) }), document.body);
|
|
4540
|
+
};
|
|
4541
|
+
}, [remove]);
|
|
4490
4542
|
const notify = useCallback((config) => {
|
|
4491
4543
|
const id = generateId();
|
|
4492
4544
|
const duration = config.duration ?? DURATION_DEFAULT;
|
|
@@ -4506,10 +4558,6 @@ function useNotifications() {
|
|
|
4506
4558
|
}, duration);
|
|
4507
4559
|
timersRef.current.set(id, timer);
|
|
4508
4560
|
}, [remove]);
|
|
4509
|
-
const className = renderClassStatus('rls-notifications', {
|
|
4510
|
-
visible: notifications.length > 0
|
|
4511
|
-
});
|
|
4512
|
-
const RlsNotifications = ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: className, children: notifications.map((notification) => (jsxRuntimeExports.jsx(RlsNotification, { ...notification.config, visible: notification.visible, onClose: () => remove(notification.id) }, notification.id))) }), document.body);
|
|
4513
4561
|
return {
|
|
4514
4562
|
RlsNotifications,
|
|
4515
4563
|
notify
|
|
@@ -4536,6 +4584,7 @@ function RlsSnackbarComponent({ content, onClose, icon, rlsTheme, title, visible
|
|
|
4536
4584
|
return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-snackbar__avatar", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsxs("div", { className: "rls-snackbar__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-snackbar__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-snackbar__title", children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-snackbar__content", children: content })] })] }));
|
|
4537
4585
|
}
|
|
4538
4586
|
const RlsSnackbar = memo(RlsSnackbarComponent);
|
|
4587
|
+
const RlsSnackbarNode = RlsSnackbar;
|
|
4539
4588
|
function useSnackbar() {
|
|
4540
4589
|
const timeoutId = useRef(undefined);
|
|
4541
4590
|
const duration = useRef(4000);
|
|
@@ -4543,6 +4592,8 @@ function useSnackbar() {
|
|
|
4543
4592
|
config: {},
|
|
4544
4593
|
visible: false
|
|
4545
4594
|
});
|
|
4595
|
+
const stateRef = useRef(state);
|
|
4596
|
+
stateRef.current = state;
|
|
4546
4597
|
const onClose = useCallback(() => {
|
|
4547
4598
|
if (timeoutId.current) {
|
|
4548
4599
|
clearTimeout(timeoutId.current);
|
|
@@ -4550,7 +4601,13 @@ function useSnackbar() {
|
|
|
4550
4601
|
timeoutId.current = undefined;
|
|
4551
4602
|
setState((state) => ({ ...state, visible: false }));
|
|
4552
4603
|
}, []);
|
|
4553
|
-
const
|
|
4604
|
+
const onCloseRef = useRef(onClose);
|
|
4605
|
+
onCloseRef.current = onClose;
|
|
4606
|
+
const RlsSnackbar = useMemo(() => {
|
|
4607
|
+
return function RlsSnackbar(props) {
|
|
4608
|
+
return (jsxRuntimeExports.jsx(RlsSnackbarNode, { ...props, ...stateRef.current.config, visible: stateRef.current.visible, onClose: onCloseRef.current }));
|
|
4609
|
+
};
|
|
4610
|
+
}, []);
|
|
4554
4611
|
useEffect(() => {
|
|
4555
4612
|
if (state.visible) {
|
|
4556
4613
|
timeoutId.current = setTimeout(() => {
|
|
@@ -4574,10 +4631,7 @@ function useSnackbar() {
|
|
|
4574
4631
|
visible: !state.visible
|
|
4575
4632
|
}));
|
|
4576
4633
|
}, []);
|
|
4577
|
-
return {
|
|
4578
|
-
RlsSnackbar: rlsSnackbar,
|
|
4579
|
-
snackbar
|
|
4580
|
-
};
|
|
4634
|
+
return { RlsSnackbar, snackbar };
|
|
4581
4635
|
}
|
|
4582
4636
|
|
|
4583
4637
|
const RlsContext = createContext(null);
|
|
@@ -4590,8 +4644,8 @@ function useRlsContext() {
|
|
|
4590
4644
|
}
|
|
4591
4645
|
function RlsApplication({ children }) {
|
|
4592
4646
|
const { RlsConfirmation, confirmation } = useConfirmation();
|
|
4593
|
-
const { RlsNotifications, notify } = useNotifications();
|
|
4594
4647
|
const { RlsSnackbar, snackbar } = useSnackbar();
|
|
4648
|
+
const { RlsNotifications, notify } = useNotifications();
|
|
4595
4649
|
const [navbarInApp, setNavbarInApp] = useState(false);
|
|
4596
4650
|
const [navbarIsCondense, setNavbarIsCondense] = useState(false);
|
|
4597
4651
|
const [appIsMobile, setIsMobile] = useState(false);
|
|
@@ -4608,7 +4662,7 @@ function RlsApplication({ children }) {
|
|
|
4608
4662
|
setNavbarIsCondense,
|
|
4609
4663
|
snackbar
|
|
4610
4664
|
}), [confirmation, notify, snackbar]);
|
|
4611
|
-
return (jsxRuntimeExports.jsxs(RlsContext, { value: state, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsNotifications,
|
|
4665
|
+
return (jsxRuntimeExports.jsxs(RlsContext, { value: state, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, jsxRuntimeExports.jsx(RlsSnackbar, {})] }), jsxRuntimeExports.jsx(RlsConfirmation, {}), jsxRuntimeExports.jsx(RlsNotifications, {})] }));
|
|
4612
4666
|
}
|
|
4613
4667
|
|
|
4614
4668
|
const DEFAULT_DESIGN_SYSTEM = 'bordered';
|
|
@@ -4714,13 +4768,7 @@ function useDropdownController(effect = '0% 0%') {
|
|
|
4714
4768
|
const close = useCallback(() => {
|
|
4715
4769
|
setVisible(false);
|
|
4716
4770
|
}, []);
|
|
4717
|
-
return {
|
|
4718
|
-
close,
|
|
4719
|
-
component,
|
|
4720
|
-
open,
|
|
4721
|
-
openWithEvent,
|
|
4722
|
-
visible
|
|
4723
|
-
};
|
|
4771
|
+
return useMemo(() => ({ close, component, open, openWithEvent, visible }), [close, open, openWithEvent, visible]);
|
|
4724
4772
|
}
|
|
4725
4773
|
|
|
4726
4774
|
function usePortalController() {
|
|
@@ -4731,15 +4779,23 @@ function usePortalController() {
|
|
|
4731
4779
|
const close = useCallback(() => {
|
|
4732
4780
|
setVisible(false);
|
|
4733
4781
|
}, []);
|
|
4734
|
-
return { close, open, visible };
|
|
4782
|
+
return useMemo(() => ({ close, open, visible }), [close, open, visible]);
|
|
4735
4783
|
}
|
|
4736
4784
|
|
|
4737
4785
|
function useTabsController(options) {
|
|
4738
4786
|
const formControl = useFormControl(options.value);
|
|
4787
|
+
const tabsRef = useRef(options.tabs);
|
|
4788
|
+
tabsRef.current = options.tabs;
|
|
4789
|
+
const onValueRef = useRef(options.onValue);
|
|
4790
|
+
onValueRef.current = options.onValue;
|
|
4791
|
+
const formControlRef = useRef(formControl);
|
|
4792
|
+
formControlRef.current = formControl;
|
|
4739
4793
|
const Tabs = useMemo(() => {
|
|
4740
|
-
return (
|
|
4741
|
-
|
|
4742
|
-
|
|
4794
|
+
return function Tabs(props) {
|
|
4795
|
+
return (jsxRuntimeExports.jsx(RlsTabs, { ...props, tabs: tabsRef.current, formControl: formControlRef.current, onValue: onValueRef.current }));
|
|
4796
|
+
};
|
|
4797
|
+
}, []);
|
|
4798
|
+
return useMemo(() => ({ Tabs, formControl }), [Tabs, formControl]);
|
|
4743
4799
|
}
|
|
4744
4800
|
|
|
4745
4801
|
const APP_THEME_ATTRIBUTE = 'app-theme';
|