@redis-ui/components 41.4.1 → 41.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +330 -0
- package/dist/Button/TextButton/TextButton.cjs +2 -0
- package/dist/Button/TextButton/TextButton.js +2 -0
- package/dist/Button/TextButton/TextButton.style.cjs +9 -3
- package/dist/Button/TextButton/TextButton.style.d.ts +1 -1
- package/dist/Button/TextButton/TextButton.style.js +9 -3
- package/dist/Button/TextButton/TextButton.types.d.ts +2 -0
- package/dist/Button/ToggleButton/ToggleButton.style.cjs +1 -1
- package/dist/Button/ToggleButton/ToggleButton.style.js +1 -1
- package/dist/ChipList/Components/ExtraItem.cjs +8 -7
- package/dist/ChipList/Components/ExtraItem.js +8 -7
- package/dist/Filters/components/MultiSelectFilter/MultiSelectFilter.cjs +2 -2
- package/dist/Filters/components/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/dist/Filters/components/MultiTreeSelectFilter/MultiTreeSelectFilter.cjs +2 -2
- package/dist/Filters/components/MultiTreeSelectFilter/MultiTreeSelectFilter.js +2 -2
- package/dist/FormField/FormField.context.cjs +4 -0
- package/dist/FormField/FormField.context.d.ts +3 -0
- package/dist/FormField/FormField.context.js +4 -0
- package/dist/FormField/components/Nested/Nested.cjs +4 -2
- package/dist/FormField/components/Nested/Nested.js +5 -3
- package/dist/Helpers/css.utils.cjs +4 -0
- package/dist/Helpers/css.utils.js +4 -0
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +6 -2
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +7 -3
- package/dist/Inputs/components/Compose/CommonCompose.cjs +16 -14
- package/dist/Inputs/components/Compose/CommonCompose.js +17 -15
- package/dist/Inputs/components/Context/InputValue.context.cjs +13 -9
- package/dist/Inputs/components/Context/InputValue.context.d.ts +270 -4
- package/dist/Inputs/components/Context/InputValue.context.js +13 -9
- package/dist/Inputs/components/Context/InputValueProvider.cjs +7 -2
- package/dist/Inputs/components/Context/InputValueProvider.js +8 -3
- package/dist/Inputs/components/Context/NumericInputValueProvider.cjs +6 -1
- package/dist/Inputs/components/Context/NumericInputValueProvider.js +7 -2
- package/dist/Inputs/components/InputTag/InputTag.cjs +6 -3
- package/dist/Inputs/components/InputTag/InputTag.js +7 -4
- package/dist/Inputs/components/InputTag/InputTag.style.cjs +1 -1
- package/dist/Inputs/components/InputTag/InputTag.style.js +1 -1
- package/dist/Inputs/components/ResetButton/ResetButton.cjs +7 -4
- package/dist/Inputs/components/ResetButton/ResetButton.js +7 -4
- package/dist/Label/components/Required/Required.cjs +8 -8
- package/dist/Label/components/Required/Required.js +8 -8
- package/dist/Layouts/FlexDivider/FlexDivider.cjs +22 -0
- package/dist/Layouts/FlexDivider/FlexDivider.d.ts +2 -0
- package/dist/Layouts/FlexDivider/FlexDivider.js +22 -0
- package/dist/Layouts/FlexDivider/FlexDivider.style.cjs +46 -0
- package/dist/Layouts/FlexDivider/FlexDivider.style.d.ts +6 -0
- package/dist/Layouts/FlexDivider/FlexDivider.style.js +44 -0
- package/dist/Layouts/FlexDivider/FlexDivider.types.d.ts +15 -0
- package/dist/Layouts/FlexGroup/FlexGroup.cjs +20 -0
- package/dist/Layouts/FlexGroup/FlexGroup.d.ts +2 -0
- package/dist/Layouts/FlexGroup/FlexGroup.js +20 -0
- package/dist/Layouts/FlexGroup/FlexGroup.style.cjs +20 -0
- package/dist/Layouts/FlexGroup/FlexGroup.style.d.ts +9 -0
- package/dist/Layouts/FlexGroup/FlexGroup.style.js +18 -0
- package/dist/Layouts/FlexGroup/FlexGroup.types.d.ts +19 -0
- package/dist/Layouts/FlexItem/FlexItem.cjs +16 -0
- package/dist/Layouts/FlexItem/FlexItem.d.ts +2 -0
- package/dist/Layouts/FlexItem/FlexItem.js +16 -0
- package/dist/Layouts/FlexItem/FlexItem.style.cjs +14 -0
- package/dist/Layouts/FlexItem/FlexItem.style.d.ts +5 -0
- package/dist/Layouts/FlexItem/FlexItem.style.js +12 -0
- package/dist/Layouts/FlexItem/FlexItem.types.d.ts +14 -0
- package/dist/Layouts/FlexSplit/FlexSplit.cjs +10 -0
- package/dist/Layouts/FlexSplit/FlexSplit.d.ts +2 -0
- package/dist/Layouts/FlexSplit/FlexSplit.js +10 -0
- package/dist/Layouts/FlexSplit/FlexSplit.style.cjs +27 -0
- package/dist/Layouts/FlexSplit/FlexSplit.style.d.ts +8 -0
- package/dist/Layouts/FlexSplit/FlexSplit.style.js +25 -0
- package/dist/Layouts/FlexSplit/FlexSplit.types.d.ts +8 -0
- package/dist/Layouts/index.d.ts +8 -0
- package/dist/MidBar/MidBar.cjs +30 -0
- package/dist/MidBar/MidBar.d.ts +22 -0
- package/dist/MidBar/MidBar.js +30 -0
- package/dist/MidBar/MidBar.types.d.ts +6 -0
- package/dist/MidBar/components/Header/Header.cjs +32 -0
- package/dist/MidBar/components/Header/Header.d.ts +15 -0
- package/dist/MidBar/components/Header/Header.js +32 -0
- package/dist/MidBar/components/Header/Header.types.d.ts +13 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.cjs +8 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.d.ts +3 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.js +8 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.style.cjs +31 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.style.d.ts +1 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.style.js +29 -0
- package/dist/MidBar/components/Header/components/Compose/Compose.types.d.ts +2 -0
- package/dist/MidBar/components/Header/components/Group/Group.cjs +12 -0
- package/dist/MidBar/components/Header/components/Group/Group.d.ts +3 -0
- package/dist/MidBar/components/Header/components/Group/Group.js +12 -0
- package/dist/MidBar/components/Header/components/Group/Group.style.cjs +22 -0
- package/dist/MidBar/components/Header/components/Group/Group.style.d.ts +4 -0
- package/dist/MidBar/components/Header/components/Group/Group.style.js +20 -0
- package/dist/MidBar/components/Header/components/Group/Group.types.d.ts +5 -0
- package/dist/MidBar/index.d.ts +2 -0
- package/dist/MoreInfoIcon/MoreInfoIcon.style.cjs +1 -1
- package/dist/MoreInfoIcon/MoreInfoIcon.style.js +1 -1
- package/dist/SearchBar/components/SearchSection/components/Actions/components/ColumnSelector/ColumnSelector.cjs +5 -7
- package/dist/SearchBar/components/SearchSection/components/Actions/components/ColumnSelector/ColumnSelector.js +5 -7
- package/dist/SearchBar/components/SearchSection/components/Actions/components/FiltersToggle/FiltersToggle.cjs +11 -9
- package/dist/SearchBar/components/SearchSection/components/Actions/components/FiltersToggle/FiltersToggle.js +11 -9
- package/dist/Select/components/Context/Context.cjs +6 -4
- package/dist/Select/components/Context/Context.js +7 -5
- package/dist/Select/components/Trigger/components/Compose/Compose.cjs +5 -0
- package/dist/Select/components/Trigger/components/Compose/Compose.js +6 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.style.cjs +5 -0
- package/dist/Select/components/Trigger/components/Compose/Compose.style.js +5 -0
- package/dist/Stepper/Stepper.context.cjs +5 -10
- package/dist/Stepper/Stepper.context.d.ts +1 -2
- package/dist/Stepper/Stepper.context.js +5 -10
- package/dist/Stepper/Stepper.d.ts +4 -4
- package/dist/Stepper/components/Compose/Compose.cjs +6 -1
- package/dist/Stepper/components/Compose/Compose.d.ts +2 -2
- package/dist/Stepper/components/Compose/Compose.js +7 -2
- package/dist/Stepper/components/Step/Step.context.cjs +5 -10
- package/dist/Stepper/components/Step/Step.context.d.ts +1 -2
- package/dist/Stepper/components/Step/Step.context.js +5 -10
- package/dist/Stepper/components/Step/Step.d.ts +2 -3
- package/dist/Stepper/components/Step/components/Compose/Compose.cjs +1 -3
- package/dist/Stepper/components/Step/components/Compose/Compose.d.ts +1 -1
- package/dist/Stepper/components/Step/components/Compose/Compose.js +2 -4
- package/dist/Stepper/components/Step/components/Compose/Compose.style.cjs +2 -5
- package/dist/Stepper/components/Step/components/Compose/Compose.style.js +4 -7
- package/dist/Stepper/hooks/useStepperFocusing.cjs +31 -0
- package/dist/Stepper/hooks/useStepperFocusing.d.ts +16 -0
- package/dist/Stepper/hooks/useStepperFocusing.js +31 -0
- package/dist/Stepper/hooks/useStepperInteractive.cjs +30 -37
- package/dist/Stepper/hooks/useStepperInteractive.d.ts +2 -3
- package/dist/Stepper/hooks/useStepperInteractive.js +30 -37
- package/dist/ThemeModeSwitch/ThemeModeSwitch.cjs +64 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.d.ts +2 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.js +64 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.style.cjs +38 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.style.d.ts +4 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.style.js +36 -0
- package/dist/ThemeModeSwitch/ThemeModeSwitch.types.d.ts +7 -0
- package/dist/ThemeModeSwitch/index.d.ts +3 -0
- package/dist/ThemeModeSwitch/useThemeModeSwitch.cjs +37 -0
- package/dist/ThemeModeSwitch/useThemeModeSwitch.d.ts +8 -0
- package/dist/ThemeModeSwitch/useThemeModeSwitch.js +37 -0
- package/dist/Toast/Toaster.cjs +4 -6
- package/dist/Toast/Toaster.d.ts +2 -1
- package/dist/Toast/Toaster.js +4 -6
- package/dist/Toast/Toaster.style.cjs +2 -2
- package/dist/Toast/Toaster.style.d.ts +2 -2
- package/dist/Toast/Toaster.style.js +3 -3
- package/dist/Toast/core/core.d.ts +3 -3
- package/dist/Toast/core/mapping.helpers.cjs +18 -2
- package/dist/Toast/core/mapping.helpers.d.ts +4 -3
- package/dist/Toast/core/mapping.helpers.js +22 -6
- package/dist/Toast/core/mapping.types.d.ts +3 -2
- package/dist/index.cjs +1092 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1139 -48
- package/dist/node_modules/clsx/dist/clsx.cjs +17 -0
- package/dist/node_modules/clsx/dist/clsx.js +17 -0
- package/dist/packages/components/node_modules/react-toastify/dist/react-toastify.esm.cjs +320 -0
- package/dist/packages/components/node_modules/react-toastify/dist/react-toastify.esm.js +318 -0
- package/dist/packages/icons/dist/multicolor/LoaderLarge.cjs +2 -2
- package/dist/packages/icons/dist/multicolor/LoaderLarge.js +2 -2
- package/dist/packages/icons/dist/multicolor/dark/LoaderLarge.cjs +3 -8
- package/dist/packages/icons/dist/multicolor/dark/LoaderLarge.js +3 -8
- package/dist/packages/icons/dist/multicolor/light/LoaderLarge.cjs +3 -8
- package/dist/packages/icons/dist/multicolor/light/LoaderLarge.js +3 -8
- package/package.json +4 -4
- package/dist/node_modules/clsx/dist/clsx.m.cjs +0 -15
- package/dist/node_modules/clsx/dist/clsx.m.js +0 -15
- package/dist/node_modules/react-toastify/dist/react-toastify.esm.cjs +0 -300
- package/dist/node_modules/react-toastify/dist/react-toastify.esm.js +0 -298
|
@@ -16,15 +16,14 @@ export declare function useStepperInteractive({ onStepChange, onKeyDown, getIsSt
|
|
|
16
16
|
'aria-label': string;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
export declare function getInteractiveStepProps({ onClick,
|
|
19
|
+
export declare function getInteractiveStepProps({ onClick, onStepChange, getIsStepInteractive, stepIndex, state }: Pick<ComposeProps, 'onClick'> & Pick<StepperContextType, 'onStepChange' | 'getIsStepInteractive'> & {
|
|
20
20
|
stepIndex: number;
|
|
21
21
|
state: StepperStepStateType;
|
|
22
22
|
}): {
|
|
23
23
|
readonly onClick: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
24
|
-
readonly onKeyDown: import("react").KeyboardEventHandler<HTMLElement> | undefined;
|
|
25
24
|
readonly role: "listitem" | "tab";
|
|
26
25
|
readonly 'aria-selected': boolean | undefined;
|
|
27
26
|
readonly 'aria-current': "step" | undefined;
|
|
28
27
|
readonly 'aria-disabled': true | undefined;
|
|
29
|
-
readonly tabIndex:
|
|
28
|
+
readonly tabIndex: -1;
|
|
30
29
|
};
|
|
@@ -16,31 +16,36 @@ function useStepperInteractive({
|
|
|
16
16
|
}
|
|
17
17
|
return stepIndex !== currentStep;
|
|
18
18
|
}, [currentStep, getIsStepInteractive, isInteractive]);
|
|
19
|
-
const handleKeyDown =
|
|
19
|
+
const handleKeyDown = isInteractive ? (event) => {
|
|
20
|
+
const findNextInteractive = (from, to = totalSteps || 0) => {
|
|
21
|
+
for (let i = from; i < to; i += 1) {
|
|
22
|
+
if (isStepInteractive(i)) return i;
|
|
23
|
+
}
|
|
24
|
+
return void 0;
|
|
25
|
+
};
|
|
26
|
+
const findPrevInteractive = (from, to = 0) => {
|
|
27
|
+
for (let i = from; i >= to; i -= 1) {
|
|
28
|
+
if (isStepInteractive(i)) return i;
|
|
29
|
+
}
|
|
30
|
+
return void 0;
|
|
31
|
+
};
|
|
32
|
+
const handleChange = (next) => {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
if (next !== void 0) onStepChange(next);
|
|
35
|
+
};
|
|
20
36
|
const {
|
|
21
37
|
key
|
|
22
38
|
} = event;
|
|
23
|
-
if (key === "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
for (let i = newIndex; i >= 0; i -= 1) {
|
|
36
|
-
if (isStepInteractive(i)) {
|
|
37
|
-
onStepChange(i);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
39
|
+
if (key === "ArrowRight") {
|
|
40
|
+
handleChange(findNextInteractive(currentStep + 1));
|
|
41
|
+
} else if (key === "ArrowLeft") {
|
|
42
|
+
handleChange(findPrevInteractive(currentStep - 1));
|
|
43
|
+
} else if (key === "Home") {
|
|
44
|
+
handleChange(findNextInteractive(0, currentStep));
|
|
45
|
+
} else if (key === "End") {
|
|
46
|
+
handleChange(findPrevInteractive((totalSteps || 0) - 1, currentStep + 1));
|
|
42
47
|
}
|
|
43
|
-
} : void 0
|
|
48
|
+
} : void 0;
|
|
44
49
|
const role = isInteractive ? "tablist" : "list";
|
|
45
50
|
const label = isInteractive ? "Step navigation" : "Progress steps";
|
|
46
51
|
return {
|
|
@@ -49,7 +54,7 @@ function useStepperInteractive({
|
|
|
49
54
|
onStepChange
|
|
50
55
|
},
|
|
51
56
|
props: {
|
|
52
|
-
onKeyDown: handleKeyDown,
|
|
57
|
+
onKeyDown: combineHandlers(handleKeyDown, onKeyDown),
|
|
53
58
|
role,
|
|
54
59
|
"aria-label": label
|
|
55
60
|
}
|
|
@@ -57,7 +62,6 @@ function useStepperInteractive({
|
|
|
57
62
|
}
|
|
58
63
|
function getInteractiveStepProps({
|
|
59
64
|
onClick,
|
|
60
|
-
onKeyDown,
|
|
61
65
|
onStepChange,
|
|
62
66
|
getIsStepInteractive,
|
|
63
67
|
stepIndex,
|
|
@@ -65,29 +69,18 @@ function getInteractiveStepProps({
|
|
|
65
69
|
}) {
|
|
66
70
|
const isInteractive = !!onStepChange;
|
|
67
71
|
const isClickable = isInteractive && getIsStepInteractive(stepIndex);
|
|
68
|
-
const handleClick =
|
|
69
|
-
const handleKeyDown = combineHandlers(isClickable ? (e) => {
|
|
70
|
-
const {
|
|
71
|
-
key
|
|
72
|
-
} = e;
|
|
73
|
-
if (key === "Enter" || key === " ") {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
onStepChange(stepIndex);
|
|
76
|
-
}
|
|
77
|
-
} : void 0, onKeyDown);
|
|
72
|
+
const handleClick = isClickable ? () => onStepChange(stepIndex) : void 0;
|
|
78
73
|
const role = isInteractive ? "tab" : "listitem";
|
|
79
74
|
const ariaSelected = isInteractive ? state === StepperStepState.FOCUSED : void 0;
|
|
80
75
|
const ariaCurrent = !isInteractive && state === StepperStepState.FOCUSED ? "step" : void 0;
|
|
81
|
-
const tabIndex = isClickable ? 0 : -1;
|
|
82
76
|
const ariaDisabled = isInteractive && !isClickable ? true : void 0;
|
|
83
77
|
return {
|
|
84
|
-
onClick: handleClick,
|
|
85
|
-
onKeyDown: handleKeyDown,
|
|
78
|
+
onClick: combineHandlers(handleClick, onClick),
|
|
86
79
|
role,
|
|
87
80
|
"aria-selected": ariaSelected,
|
|
88
81
|
"aria-current": ariaCurrent,
|
|
89
82
|
"aria-disabled": ariaDisabled,
|
|
90
|
-
tabIndex
|
|
83
|
+
tabIndex: -1
|
|
91
84
|
};
|
|
92
85
|
}
|
|
93
86
|
export {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("../node_modules/react/jsx-runtime.cjs");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const ThemeModeSwitch_style = require("./ThemeModeSwitch.style.cjs");
|
|
6
|
+
const useThemeModeSwitch = require("./useThemeModeSwitch.cjs");
|
|
7
|
+
const Menu = require("../Menu/Menu.cjs");
|
|
8
|
+
const ThemeModeSwitch = ({
|
|
9
|
+
onThemeModeChange,
|
|
10
|
+
switchTimeoutMs = 300,
|
|
11
|
+
...restProps
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
allowSystemThemeMode,
|
|
15
|
+
themeMode,
|
|
16
|
+
setThemeMode,
|
|
17
|
+
toggleThemeMode
|
|
18
|
+
} = useThemeModeSwitch.useThemeModeSwitch({
|
|
19
|
+
onThemeModeChange,
|
|
20
|
+
switchTimeoutMs
|
|
21
|
+
});
|
|
22
|
+
const [ready, setReady] = React.useState(false);
|
|
23
|
+
React.useEffect(() => setReady(true), []);
|
|
24
|
+
const modeSwitch = jsxRuntime.jsxRuntimeExports.jsx(ThemeModeSwitch_style.ThemeModeSwitch, {
|
|
25
|
+
"data-theme-mode": themeMode,
|
|
26
|
+
"aria-label": `Theme mode switch. Current theme mode is ${themeMode || "unknown"}`,
|
|
27
|
+
...restProps,
|
|
28
|
+
onClick: toggleThemeMode,
|
|
29
|
+
"data-mounting": !ready ? "" : void 0,
|
|
30
|
+
"$durationMs": switchTimeoutMs,
|
|
31
|
+
onPointerDown: allowSystemThemeMode ? (e) => {
|
|
32
|
+
e.currentTarget.focus();
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
} : void 0,
|
|
35
|
+
children: jsxRuntime.jsxRuntimeExports.jsx(ThemeModeSwitch_style.Knob, {
|
|
36
|
+
"data-theme-mode": themeMode
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
if (allowSystemThemeMode) {
|
|
40
|
+
return jsxRuntime.jsxRuntimeExports.jsxs(Menu.default, {
|
|
41
|
+
children: [jsxRuntime.jsxRuntimeExports.jsx(Menu.default.Trigger, {
|
|
42
|
+
children: modeSwitch
|
|
43
|
+
}), jsxRuntime.jsxRuntimeExports.jsxs(Menu.default.Content, {
|
|
44
|
+
placement: "bottom",
|
|
45
|
+
align: "center",
|
|
46
|
+
children: [jsxRuntime.jsxRuntimeExports.jsx(Menu.default.Content.Item, {
|
|
47
|
+
text: "Light theme",
|
|
48
|
+
selected: themeMode === "light",
|
|
49
|
+
onClick: () => setThemeMode("light")
|
|
50
|
+
}), jsxRuntime.jsxRuntimeExports.jsx(Menu.default.Content.Item, {
|
|
51
|
+
text: "Dark theme",
|
|
52
|
+
selected: themeMode === "dark",
|
|
53
|
+
onClick: () => setThemeMode("dark")
|
|
54
|
+
}), jsxRuntime.jsxRuntimeExports.jsx(Menu.default.Content.Item, {
|
|
55
|
+
text: "Browser theme",
|
|
56
|
+
selected: themeMode === "system",
|
|
57
|
+
onClick: () => setThemeMode("system")
|
|
58
|
+
})]
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return modeSwitch;
|
|
63
|
+
};
|
|
64
|
+
exports.ThemeModeSwitch = ThemeModeSwitch;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { ThemeModeSwitch as ThemeModeSwitch$1, Knob } from "./ThemeModeSwitch.style.js";
|
|
4
|
+
import { useThemeModeSwitch } from "./useThemeModeSwitch.js";
|
|
5
|
+
import Menu from "../Menu/Menu.js";
|
|
6
|
+
const ThemeModeSwitch = ({
|
|
7
|
+
onThemeModeChange,
|
|
8
|
+
switchTimeoutMs = 300,
|
|
9
|
+
...restProps
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
allowSystemThemeMode,
|
|
13
|
+
themeMode,
|
|
14
|
+
setThemeMode,
|
|
15
|
+
toggleThemeMode
|
|
16
|
+
} = useThemeModeSwitch({
|
|
17
|
+
onThemeModeChange,
|
|
18
|
+
switchTimeoutMs
|
|
19
|
+
});
|
|
20
|
+
const [ready, setReady] = useState(false);
|
|
21
|
+
useEffect(() => setReady(true), []);
|
|
22
|
+
const modeSwitch = jsxRuntimeExports.jsx(ThemeModeSwitch$1, {
|
|
23
|
+
"data-theme-mode": themeMode,
|
|
24
|
+
"aria-label": `Theme mode switch. Current theme mode is ${themeMode || "unknown"}`,
|
|
25
|
+
...restProps,
|
|
26
|
+
onClick: toggleThemeMode,
|
|
27
|
+
"data-mounting": !ready ? "" : void 0,
|
|
28
|
+
"$durationMs": switchTimeoutMs,
|
|
29
|
+
onPointerDown: allowSystemThemeMode ? (e) => {
|
|
30
|
+
e.currentTarget.focus();
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
} : void 0,
|
|
33
|
+
children: jsxRuntimeExports.jsx(Knob, {
|
|
34
|
+
"data-theme-mode": themeMode
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
if (allowSystemThemeMode) {
|
|
38
|
+
return jsxRuntimeExports.jsxs(Menu, {
|
|
39
|
+
children: [jsxRuntimeExports.jsx(Menu.Trigger, {
|
|
40
|
+
children: modeSwitch
|
|
41
|
+
}), jsxRuntimeExports.jsxs(Menu.Content, {
|
|
42
|
+
placement: "bottom",
|
|
43
|
+
align: "center",
|
|
44
|
+
children: [jsxRuntimeExports.jsx(Menu.Content.Item, {
|
|
45
|
+
text: "Light theme",
|
|
46
|
+
selected: themeMode === "light",
|
|
47
|
+
onClick: () => setThemeMode("light")
|
|
48
|
+
}), jsxRuntimeExports.jsx(Menu.Content.Item, {
|
|
49
|
+
text: "Dark theme",
|
|
50
|
+
selected: themeMode === "dark",
|
|
51
|
+
onClick: () => setThemeMode("dark")
|
|
52
|
+
}), jsxRuntimeExports.jsx(Menu.Content.Item, {
|
|
53
|
+
text: "Browser theme",
|
|
54
|
+
selected: themeMode === "system",
|
|
55
|
+
onClick: () => setThemeMode("system")
|
|
56
|
+
})]
|
|
57
|
+
})]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return modeSwitch;
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
ThemeModeSwitch
|
|
64
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const _styled = require("styled-components");
|
|
4
|
+
const redisUiStyles = require("@redislabsdev/redis-ui-styles");
|
|
5
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
6
|
+
const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
|
|
7
|
+
const ThemeModeSwitch = _styled__default.default.button.withConfig({
|
|
8
|
+
displayName: "ThemeModeSwitchstyle__ThemeModeSwitch",
|
|
9
|
+
componentId: "RedisUI__sc-6b0pvc-0"
|
|
10
|
+
})(["all:unset;cursor:pointer;box-sizing:border-box;transition:all ", "ms ease,outline 0ms,outline-offset 0ms;&[data-mounting]{transition:none;}", " ", ""], ({
|
|
11
|
+
$durationMs
|
|
12
|
+
}) => $durationMs, () => {
|
|
13
|
+
const theme = redisUiStyles.useTheme().components.themeModeSwitch;
|
|
14
|
+
return _styled.css`
|
|
15
|
+
width: ${theme.width};
|
|
16
|
+
height: ${theme.height};
|
|
17
|
+
padding: ${theme.padding};
|
|
18
|
+
|
|
19
|
+
border-radius: ${theme.borderRadius};
|
|
20
|
+
|
|
21
|
+
border: ${theme.borderColor} solid ${theme.borderWidth};
|
|
22
|
+
background-color: ${theme.bgColor};
|
|
23
|
+
`;
|
|
24
|
+
}, redisUiStyles.getFocusStyle());
|
|
25
|
+
const Knob = _styled__default.default.div.withConfig({
|
|
26
|
+
displayName: "ThemeModeSwitchstyle__Knob",
|
|
27
|
+
componentId: "RedisUI__sc-6b0pvc-1"
|
|
28
|
+
})(["height:100%;width:100%;background:none;transition:inherit;&[data-theme-mode='dark']{transform:translateX(100%);:before{transform:translateX(-100%);}}&[data-theme-mode='system']{transform:translateX(50%);:before{transform:translateX(-50%);}}:before{content:'';display:block;transition:inherit;height:100%;background-size:contain;background-position:center;background-repeat:no-repeat;", "}"], () => {
|
|
29
|
+
const theme = redisUiStyles.useTheme().components.themeModeSwitch.thumb;
|
|
30
|
+
return _styled.css`
|
|
31
|
+
border-radius: ${theme.borderRadius};
|
|
32
|
+
background-color: ${theme.bgColor};
|
|
33
|
+
background-image: ${theme.icon};
|
|
34
|
+
aspect-ratio: ${theme.iconAspectRatio};
|
|
35
|
+
`;
|
|
36
|
+
});
|
|
37
|
+
exports.Knob = Knob;
|
|
38
|
+
exports.ThemeModeSwitch = ThemeModeSwitch;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _styled, { css } from "styled-components";
|
|
2
|
+
import { useTheme, getFocusStyle } from "@redislabsdev/redis-ui-styles";
|
|
3
|
+
const ThemeModeSwitch = _styled.button.withConfig({
|
|
4
|
+
displayName: "ThemeModeSwitchstyle__ThemeModeSwitch",
|
|
5
|
+
componentId: "RedisUI__sc-6b0pvc-0"
|
|
6
|
+
})(["all:unset;cursor:pointer;box-sizing:border-box;transition:all ", "ms ease,outline 0ms,outline-offset 0ms;&[data-mounting]{transition:none;}", " ", ""], ({
|
|
7
|
+
$durationMs
|
|
8
|
+
}) => $durationMs, () => {
|
|
9
|
+
const theme = useTheme().components.themeModeSwitch;
|
|
10
|
+
return css`
|
|
11
|
+
width: ${theme.width};
|
|
12
|
+
height: ${theme.height};
|
|
13
|
+
padding: ${theme.padding};
|
|
14
|
+
|
|
15
|
+
border-radius: ${theme.borderRadius};
|
|
16
|
+
|
|
17
|
+
border: ${theme.borderColor} solid ${theme.borderWidth};
|
|
18
|
+
background-color: ${theme.bgColor};
|
|
19
|
+
`;
|
|
20
|
+
}, getFocusStyle());
|
|
21
|
+
const Knob = _styled.div.withConfig({
|
|
22
|
+
displayName: "ThemeModeSwitchstyle__Knob",
|
|
23
|
+
componentId: "RedisUI__sc-6b0pvc-1"
|
|
24
|
+
})(["height:100%;width:100%;background:none;transition:inherit;&[data-theme-mode='dark']{transform:translateX(100%);:before{transform:translateX(-100%);}}&[data-theme-mode='system']{transform:translateX(50%);:before{transform:translateX(-50%);}}:before{content:'';display:block;transition:inherit;height:100%;background-size:contain;background-position:center;background-repeat:no-repeat;", "}"], () => {
|
|
25
|
+
const theme = useTheme().components.themeModeSwitch.thumb;
|
|
26
|
+
return css`
|
|
27
|
+
border-radius: ${theme.borderRadius};
|
|
28
|
+
background-color: ${theme.bgColor};
|
|
29
|
+
background-image: ${theme.icon};
|
|
30
|
+
aspect-ratio: ${theme.iconAspectRatio};
|
|
31
|
+
`;
|
|
32
|
+
});
|
|
33
|
+
export {
|
|
34
|
+
Knob,
|
|
35
|
+
ThemeModeSwitch
|
|
36
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserThemeMode } from '@redislabsdev/redis-ui-styles';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
export type UseThemeModeSwitchParams = {
|
|
4
|
+
onThemeModeChange?: (newThemeMode: UserThemeMode) => void;
|
|
5
|
+
switchTimeoutMs?: number;
|
|
6
|
+
};
|
|
7
|
+
export type ThemeModeSwitchProps = Omit<HTMLAttributes<HTMLElement>, 'onClick' | 'onChange'> & UseThemeModeSwitchParams;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const redisUiStyles = require("@redislabsdev/redis-ui-styles");
|
|
5
|
+
function useThemeModeSwitch({
|
|
6
|
+
onThemeModeChange,
|
|
7
|
+
switchTimeoutMs
|
|
8
|
+
}) {
|
|
9
|
+
const {
|
|
10
|
+
getNextThemeModeToToggle,
|
|
11
|
+
userThemeMode,
|
|
12
|
+
setUserThemeMode,
|
|
13
|
+
allowSystemThemeMode
|
|
14
|
+
} = redisUiStyles.useThemeModeSwitchingContext();
|
|
15
|
+
const [localThemeMode, setLocalThemeMode] = React.useState(userThemeMode);
|
|
16
|
+
React.useLayoutEffect(() => setLocalThemeMode(userThemeMode), [userThemeMode]);
|
|
17
|
+
const timerRef = React.useRef();
|
|
18
|
+
React.useEffect(() => () => clearTimeout(timerRef.current), []);
|
|
19
|
+
const applyThemeMode = (newThemeMode) => {
|
|
20
|
+
if (!newThemeMode) return;
|
|
21
|
+
clearTimeout(timerRef.current);
|
|
22
|
+
setLocalThemeMode(newThemeMode);
|
|
23
|
+
timerRef.current = setTimeout(() => {
|
|
24
|
+
if (setUserThemeMode(newThemeMode)) onThemeModeChange == null ? void 0 : onThemeModeChange(newThemeMode);
|
|
25
|
+
}, switchTimeoutMs);
|
|
26
|
+
};
|
|
27
|
+
const toggleThemeMode = () => {
|
|
28
|
+
applyThemeMode(getNextThemeModeToToggle(localThemeMode));
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
allowSystemThemeMode,
|
|
32
|
+
themeMode: localThemeMode,
|
|
33
|
+
setThemeMode: applyThemeMode,
|
|
34
|
+
toggleThemeMode
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.useThemeModeSwitch = useThemeModeSwitch;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UserThemeMode } from '@redislabsdev/redis-ui-styles';
|
|
2
|
+
import { UseThemeModeSwitchParams } from './ThemeModeSwitch.types';
|
|
3
|
+
export declare function useThemeModeSwitch({ onThemeModeChange, switchTimeoutMs }: UseThemeModeSwitchParams): {
|
|
4
|
+
allowSystemThemeMode: boolean | undefined;
|
|
5
|
+
themeMode: "light" | "dark" | "system" | undefined;
|
|
6
|
+
setThemeMode: (newThemeMode: UserThemeMode | undefined) => void;
|
|
7
|
+
toggleThemeMode: () => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useState, useLayoutEffect, useRef, useEffect } from "react";
|
|
2
|
+
import { useThemeModeSwitchingContext } from "@redislabsdev/redis-ui-styles";
|
|
3
|
+
function useThemeModeSwitch({
|
|
4
|
+
onThemeModeChange,
|
|
5
|
+
switchTimeoutMs
|
|
6
|
+
}) {
|
|
7
|
+
const {
|
|
8
|
+
getNextThemeModeToToggle,
|
|
9
|
+
userThemeMode,
|
|
10
|
+
setUserThemeMode,
|
|
11
|
+
allowSystemThemeMode
|
|
12
|
+
} = useThemeModeSwitchingContext();
|
|
13
|
+
const [localThemeMode, setLocalThemeMode] = useState(userThemeMode);
|
|
14
|
+
useLayoutEffect(() => setLocalThemeMode(userThemeMode), [userThemeMode]);
|
|
15
|
+
const timerRef = useRef();
|
|
16
|
+
useEffect(() => () => clearTimeout(timerRef.current), []);
|
|
17
|
+
const applyThemeMode = (newThemeMode) => {
|
|
18
|
+
if (!newThemeMode) return;
|
|
19
|
+
clearTimeout(timerRef.current);
|
|
20
|
+
setLocalThemeMode(newThemeMode);
|
|
21
|
+
timerRef.current = setTimeout(() => {
|
|
22
|
+
if (setUserThemeMode(newThemeMode)) onThemeModeChange == null ? void 0 : onThemeModeChange(newThemeMode);
|
|
23
|
+
}, switchTimeoutMs);
|
|
24
|
+
};
|
|
25
|
+
const toggleThemeMode = () => {
|
|
26
|
+
applyThemeMode(getNextThemeModeToToggle(localThemeMode));
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
allowSystemThemeMode,
|
|
30
|
+
themeMode: localThemeMode,
|
|
31
|
+
setThemeMode: applyThemeMode,
|
|
32
|
+
toggleThemeMode
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
useThemeModeSwitch
|
|
37
|
+
};
|
package/dist/Toast/Toaster.cjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const jsxRuntime = require("../node_modules/react/jsx-runtime.cjs");
|
|
4
|
+
const React = require("react");
|
|
4
5
|
const Toaster_style = require("./Toaster.style.cjs");
|
|
5
|
-
const Toaster = ({
|
|
6
|
+
const Toaster = React.forwardRef((props, ref) => jsxRuntime.jsxRuntimeExports.jsx(Toaster_style.ToasterContainer, {
|
|
6
7
|
ref,
|
|
7
8
|
...props
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
...props,
|
|
11
|
-
enableMultiContainer: !!props.containerId
|
|
12
|
-
});
|
|
9
|
+
}));
|
|
10
|
+
Toaster.displayName = "Toaster";
|
|
13
11
|
const Toaster$1 = Toaster;
|
|
14
12
|
exports.default = Toaster$1;
|
package/dist/Toast/Toaster.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ToasterProps } from './core/core.types';
|
|
2
|
-
declare const Toaster: (
|
|
3
|
+
declare const Toaster: import("react").ForwardRefExoticComponent<Omit<ToasterProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
4
|
export default Toaster;
|
package/dist/Toast/Toaster.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import { ToasterContainer } from "./Toaster.style.js";
|
|
3
|
-
const Toaster = ({
|
|
4
|
+
const Toaster = forwardRef((props, ref) => jsxRuntimeExports.jsx(ToasterContainer, {
|
|
4
5
|
ref,
|
|
5
6
|
...props
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
...props,
|
|
9
|
-
enableMultiContainer: !!props.containerId
|
|
10
|
-
});
|
|
7
|
+
}));
|
|
8
|
+
Toaster.displayName = "Toaster";
|
|
11
9
|
const Toaster$1 = Toaster;
|
|
12
10
|
export {
|
|
13
11
|
Toaster$1 as default
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const _styled = require("styled-components");
|
|
4
|
-
const reactToastify_esm = require("../node_modules/react-toastify/dist/react-toastify.esm.cjs");
|
|
5
|
-
;/* empty css
|
|
4
|
+
const reactToastify_esm = require("../packages/components/node_modules/react-toastify/dist/react-toastify.esm.cjs");
|
|
5
|
+
;/* empty css */
|
|
6
6
|
const redisUiStyles = require("@redislabsdev/redis-ui-styles");
|
|
7
7
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
8
|
const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { ToastContainer as RcToastContainer } from 'react-toastify';
|
|
2
2
|
import 'react-toastify/dist/ReactToastify.css';
|
|
3
3
|
/**
|
|
4
4
|
* Removes top level layout of toastify containers and allows using inner layout of the Toast component
|
|
5
5
|
*/
|
|
6
|
-
export declare const ToasterContainer: import("styled-components").StyledComponent<
|
|
6
|
+
export declare const ToasterContainer: import("styled-components").StyledComponent<typeof RcToastContainer, any, {}, never>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _styled from "styled-components";
|
|
2
|
-
import { ToastContainer as
|
|
3
|
-
/* empty css
|
|
2
|
+
import { ToastContainer as Q } from "../packages/components/node_modules/react-toastify/dist/react-toastify.esm.js";
|
|
3
|
+
/* empty css */
|
|
4
4
|
import { useTheme } from "@redislabsdev/redis-ui-styles";
|
|
5
|
-
const ToasterContainer = _styled(
|
|
5
|
+
const ToasterContainer = _styled(Q).withConfig({
|
|
6
6
|
displayName: "Toasterstyle__ToasterContainer",
|
|
7
7
|
componentId: "RedisUI__sc-zfvdgq-0"
|
|
8
8
|
})(["--toastify-toast-min-height:auto;--toastify-toast-width:auto;--toastify-font-family:inherit;& .Toastify__toast,& .Toastify__toast-body{padding:0;margin-bottom:", ";overflow:visible;background:none;color:black;box-shadow:none;}& .Toastify__toast-body{margin:0;}& .Toastify__progress-bar{visibility:hidden !important;}& .Toastify__close-button{display:none;}"], () => useTheme().components.toast.toaster.gap);
|
|
@@ -17,9 +17,9 @@ export declare const toast: {
|
|
|
17
17
|
readonly Danger: "danger";
|
|
18
18
|
};
|
|
19
19
|
update: (id: ToastId, content: ToastContent, options?: ToastOptions) => void;
|
|
20
|
-
dismiss: (id?: ToastId | undefined) => void;
|
|
21
|
-
isActive: (
|
|
22
|
-
addChangeListener:
|
|
20
|
+
dismiss: (id?: ToastId | undefined, containerId?: ToastId | undefined) => void;
|
|
21
|
+
isActive: typeof import("react-toastify/dist/core/store").isToastActive;
|
|
22
|
+
addChangeListener: typeof import("react-toastify/dist/core/store").onChange;
|
|
23
23
|
notice: (content: ToastContent, options?: Omit<ToastOptions, 'variant'>) => ToastId;
|
|
24
24
|
attention: (content: ToastContent, options?: Omit<ToastOptions, 'variant'>) => ToastId;
|
|
25
25
|
danger: (content: ToastContent, options?: Omit<ToastOptions, 'variant'>) => ToastId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const reactToastify_esm = require("../../node_modules/react-toastify/dist/react-toastify.esm.cjs");
|
|
3
|
+
const reactToastify_esm = require("../../packages/components/node_modules/react-toastify/dist/react-toastify.esm.cjs");
|
|
4
4
|
const extractContextProps = (props) => ({
|
|
5
5
|
variant: "informative",
|
|
6
6
|
liveRole: "alert",
|
|
@@ -25,8 +25,24 @@ const updateToast = (id, render, options) => reactToastify_esm.toast.update(id,
|
|
|
25
25
|
render: (props) => render(extractContextProps(props)),
|
|
26
26
|
...cleanupOptions(options)
|
|
27
27
|
});
|
|
28
|
+
const dismiss = (id, containerId) => {
|
|
29
|
+
if (containerId !== void 0) {
|
|
30
|
+
if (id !== void 0) {
|
|
31
|
+
return reactToastify_esm.toast.dismiss({
|
|
32
|
+
id,
|
|
33
|
+
containerId
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return reactToastify_esm.toast.dismiss({
|
|
37
|
+
containerId
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (id !== void 0) {
|
|
41
|
+
return reactToastify_esm.toast.dismiss(id);
|
|
42
|
+
}
|
|
43
|
+
return reactToastify_esm.toast.dismiss();
|
|
44
|
+
};
|
|
28
45
|
const {
|
|
29
|
-
dismiss,
|
|
30
46
|
isActive
|
|
31
47
|
} = reactToastify_esm.toast;
|
|
32
48
|
const addChangeListener = reactToastify_esm.toast.onChange;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This file maps toastify api to redis-ui api
|
|
3
3
|
*/
|
|
4
4
|
import { ReactElement } from 'react';
|
|
5
|
-
import { ToastContextProps, ToastId, ToastOptions, ToastUpdateOptions } from './mapping.types';
|
|
5
|
+
import { ToastContextProps, ToastId, ToastOptions, ToastUpdateOptions, ToastContainerId } from './mapping.types';
|
|
6
6
|
/**
|
|
7
7
|
* converts parameters to/from toastify and calls toastify toast
|
|
8
8
|
*/
|
|
@@ -11,5 +11,6 @@ export declare const createToast: (render: (contextProps: ToastContextProps) =>
|
|
|
11
11
|
* converts parameters to/from toastify and calls toastify update
|
|
12
12
|
*/
|
|
13
13
|
export declare const updateToast: (id: ToastId, render: (contextProps: ToastContextProps) => ReactElement, options?: ToastUpdateOptions) => void;
|
|
14
|
-
export declare const dismiss: (id?: ToastId
|
|
15
|
-
export declare const
|
|
14
|
+
export declare const dismiss: (id?: ToastId, containerId?: ToastContainerId) => void;
|
|
15
|
+
export declare const isActive: typeof import("react-toastify/dist/core/store").isToastActive;
|
|
16
|
+
export declare const addChangeListener: typeof import("react-toastify/dist/core/store").onChange;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toast as
|
|
1
|
+
import { toast as B } from "../../packages/components/node_modules/react-toastify/dist/react-toastify.esm.js";
|
|
2
2
|
const extractContextProps = (props) => ({
|
|
3
3
|
variant: "informative",
|
|
4
4
|
liveRole: "alert",
|
|
@@ -18,16 +18,32 @@ const cleanupOptions = (options) => ({
|
|
|
18
18
|
} : {}
|
|
19
19
|
// save real role for inner container, only if specified
|
|
20
20
|
});
|
|
21
|
-
const createToast = (render, options) =>
|
|
22
|
-
const updateToast = (id, render, options) =>
|
|
21
|
+
const createToast = (render, options) => B((props) => render(extractContextProps(props)), cleanupOptions(options));
|
|
22
|
+
const updateToast = (id, render, options) => B.update(id, {
|
|
23
23
|
render: (props) => render(extractContextProps(props)),
|
|
24
24
|
...cleanupOptions(options)
|
|
25
25
|
});
|
|
26
|
+
const dismiss = (id, containerId) => {
|
|
27
|
+
if (containerId !== void 0) {
|
|
28
|
+
if (id !== void 0) {
|
|
29
|
+
return B.dismiss({
|
|
30
|
+
id,
|
|
31
|
+
containerId
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return B.dismiss({
|
|
35
|
+
containerId
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (id !== void 0) {
|
|
39
|
+
return B.dismiss(id);
|
|
40
|
+
}
|
|
41
|
+
return B.dismiss();
|
|
42
|
+
};
|
|
26
43
|
const {
|
|
27
|
-
dismiss,
|
|
28
44
|
isActive
|
|
29
|
-
} =
|
|
30
|
-
const addChangeListener =
|
|
45
|
+
} = B;
|
|
46
|
+
const addChangeListener = B.onChange;
|
|
31
47
|
export {
|
|
32
48
|
addChangeListener,
|
|
33
49
|
createToast,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* This file maps toastify types to redis-ui types
|
|
3
3
|
*/
|
|
4
4
|
import { RefAttributes } from 'react';
|
|
5
|
-
import { ToastContainerProps as RcToastContainerProps, ToastContentProps as RcToastContentProps, ToastOptions as RcToastOptions, ToastPosition as RcToastPosition } from 'react-toastify';
|
|
5
|
+
import { Id, ToastContainerProps as RcToastContainerProps, ToastContentProps as RcToastContentProps, ToastOptions as RcToastOptions, ToastPosition as RcToastPosition, Id as ToastId } from 'react-toastify';
|
|
6
6
|
import { SemanticVariant } from '../../Banner/components/BannerSemanticComponents';
|
|
7
|
-
export type {
|
|
7
|
+
export type { ToastId };
|
|
8
8
|
type PickCommonOptions = 'pauseOnHover' | 'closeOnClick' | 'autoClose' | 'position' | 'role' | 'rtl' | 'containerId' | 'transition';
|
|
9
9
|
type PickToastOptions = PickCommonOptions | 'toastId' | 'delay' | 'onClose';
|
|
10
10
|
type PickToastProps = PickToastOptions | 'closeToast';
|
|
@@ -22,3 +22,4 @@ export type ToastContextProps = Partial<Pick<RcToastContentProps['toastProps'],
|
|
|
22
22
|
liveRole: string;
|
|
23
23
|
};
|
|
24
24
|
export type ToastPosition = RcToastPosition;
|
|
25
|
+
export type ToastContainerId = Id;
|