master-components-react-ts 2.1.2 → 2.1.3

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 (85) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +8 -0
  2. package/dist/_virtual/customParseFormat.js +4 -0
  3. package/dist/_virtual/jsx-runtime.js +4 -0
  4. package/dist/_virtual/react-jsx-runtime.production.js +4 -0
  5. package/dist/assets/Icons/IconArrowUp.js +13 -0
  6. package/dist/assets/Icons/IconCalendar.js +32 -0
  7. package/dist/assets/Icons/IconCheck.js +15 -0
  8. package/dist/assets/Icons/IconCheckCircle.js +16 -0
  9. package/dist/assets/Icons/IconCheckmark.js +15 -0
  10. package/dist/assets/Icons/IconCircularLoading.js +36 -0
  11. package/dist/assets/Icons/IconClose.js +31 -0
  12. package/dist/assets/Icons/IconCloseBackground.js +15 -0
  13. package/dist/assets/Icons/IconCloseCircle.js +15 -0
  14. package/dist/assets/Icons/IconErrorDash.js +15 -0
  15. package/dist/assets/Icons/IconExclamation.js +15 -0
  16. package/dist/assets/Icons/IconLeft.js +13 -0
  17. package/dist/assets/Icons/IconLoading.js +22 -0
  18. package/dist/assets/Icons/IconMinus.js +7 -0
  19. package/dist/assets/Icons/IconRadioChecked.js +19 -0
  20. package/dist/assets/Icons/IconRadioCheckedDisabled.js +19 -0
  21. package/dist/assets/Icons/IconRadioUnchecked.js +16 -0
  22. package/dist/assets/Icons/IconRadioUncheckedDisabled.js +16 -0
  23. package/dist/assets/Icons/IconRight.js +13 -0
  24. package/dist/assets/Icons/IconSave.js +16 -0
  25. package/dist/assets/Icons/IconSearch.js +26 -0
  26. package/dist/assets/Icons/IconSuccess.js +15 -0
  27. package/dist/assets/Icons/IconTrash.js +16 -0
  28. package/dist/assets/components/ActionDropdown/ActionDropdown.module-CJpBa8kB.css +85 -0
  29. package/dist/assets/components/Checkbox/Checkbox.module-_XqqEodq.css +82 -0
  30. package/dist/assets/components/DatePicker/Calendar.module-D3fcZWFD.css +316 -0
  31. package/dist/assets/components/DatePicker/Datepicker.module-BxWRyQpP.css +39 -0
  32. package/dist/assets/components/Dropdown/Dropdown.module-DgjqziBo.css +242 -0
  33. package/dist/assets/components/FormInput/FormInput.module-DvfUbgbC.css +240 -0
  34. package/dist/assets/components/InlineLoading/InlineLoading.module-iVTVTMU0.css +40 -0
  35. package/dist/assets/components/MainButton/MainButton.module-8Us8t8Lb.css +306 -0
  36. package/dist/assets/components/NotificationToast/NotificationToast.module-mSanXElM.css +179 -0
  37. package/dist/assets/components/Popup/Popup.module-C1XFPW6u.css +152 -0
  38. package/dist/assets/components/Radio/Radio.module-BvqKw6WX.css +21 -0
  39. package/dist/assets/components/Skeleton/Skeleton.module-BxbVrXDg.css +57 -0
  40. package/dist/assets/components/Textarea/Textarea.module-BxaBUjlU.css +167 -0
  41. package/dist/assets/components/TimePicker/TimePicker.module-DfRiUaeb.css +150 -0
  42. package/dist/assets/components/Toggle/Toggle.module-DBfTR8Br.css +75 -0
  43. package/dist/assets/components/Tooltip/Tooltip.module-DEYqvQtd.css +113 -0
  44. package/dist/components/ActionDropdown/ActionDropdown.js +74 -0
  45. package/dist/components/ActionDropdown/ActionDropdown.module.scss.js +29 -0
  46. package/dist/components/Checkbox/Checkbox.js +54 -0
  47. package/dist/components/Checkbox/Checkbox.module.scss.js +26 -0
  48. package/dist/components/DatePicker/Calendar.js +437 -0
  49. package/dist/components/DatePicker/Calendar.module.scss.js +83 -0
  50. package/dist/components/DatePicker/DatePicker.js +211 -0
  51. package/dist/components/DatePicker/Datepicker.module.scss.js +17 -0
  52. package/dist/components/Dropdown/Dropdown.js +337 -0
  53. package/dist/components/Dropdown/Dropdown.module.scss.js +74 -0
  54. package/dist/components/FormInput/FormInput.js +151 -0
  55. package/dist/components/FormInput/FormInput.module.scss.js +62 -0
  56. package/dist/components/InlineLoading/InlineLoading.js +24 -0
  57. package/dist/components/InlineLoading/InlineLoading.module.scss.js +11 -0
  58. package/dist/components/MainButton/MainButton.js +72 -0
  59. package/dist/components/MainButton/MainButton.module.scss.js +56 -0
  60. package/dist/components/NotificationToast/NotificationContext.js +57 -0
  61. package/dist/components/NotificationToast/NotificationToast.js +66 -0
  62. package/dist/components/NotificationToast/NotificationToast.module.scss.js +59 -0
  63. package/dist/components/NotificationToast/createNotificationToast.js +10 -0
  64. package/dist/components/Popup/Popup.js +116 -0
  65. package/dist/components/Popup/Popup.module.scss.js +41 -0
  66. package/dist/components/Radio/Radio.js +46 -0
  67. package/dist/components/Radio/Radio.module.scss.js +8 -0
  68. package/dist/components/Skeleton/Skeleton.js +8 -0
  69. package/dist/components/Skeleton/Skeleton.module.scss.js +20 -0
  70. package/dist/components/Textarea/Textarea.js +149 -0
  71. package/dist/components/Textarea/Textarea.module.scss.js +41 -0
  72. package/dist/components/TimePicker/TimePicker.js +172 -0
  73. package/dist/components/TimePicker/TimePicker.module.scss.js +50 -0
  74. package/dist/components/Toggle/Toggle.js +20 -0
  75. package/dist/components/Toggle/Toggle.module.scss.js +29 -0
  76. package/dist/components/Tooltip/Tooltip.js +153 -0
  77. package/dist/components/Tooltip/Tooltip.module.scss.js +35 -0
  78. package/dist/context/NamespaceContext.js +7 -0
  79. package/dist/index.js +32 -5154
  80. package/dist/node_modules/dayjs/plugin/customParseFormat.js +129 -0
  81. package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +35 -0
  82. package/dist/node_modules/react/jsx-runtime.js +10 -0
  83. package/dist/utils/Helpers.js +15 -0
  84. package/package.json +10 -15
  85. package/dist/types/css-modules.d.ts +0 -9
@@ -0,0 +1,151 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./FormInput.module.scss.js";
3
+ import { useRef, useState, useEffect } from "react";
4
+ import { IconSearch } from "../../assets/Icons/IconSearch.js";
5
+ import { IconCloseCircle } from "../../assets/Icons/IconCloseCircle.js";
6
+ const FormInput = ({
7
+ label,
8
+ placeholder,
9
+ helperText,
10
+ required = false,
11
+ disabled = false,
12
+ readOnly = false,
13
+ withFocus = true,
14
+ withActive = true,
15
+ searchComponent = false,
16
+ size = "md",
17
+ toggleFocus = false,
18
+ rightSlot,
19
+ leftSlot,
20
+ helperSlot,
21
+ type = "text",
22
+ value,
23
+ maxLength,
24
+ forDropdown = false,
25
+ customFocus = null,
26
+ focus = false,
27
+ inputState = { error: false, success: false, loading: false },
28
+ inputSlot,
29
+ onChange,
30
+ onFocus,
31
+ onBlur,
32
+ onEnter,
33
+ onFocusChange,
34
+ formInputWrapperStyle,
35
+ inputWrapperStyle,
36
+ formInputStyle,
37
+ helperTextStyle,
38
+ labelStyle,
39
+ inputSlotStyle
40
+ }) => {
41
+ const InputRef = useRef(null);
42
+ const [SearchValue, setSearchValue] = useState(value ?? "");
43
+ const [Focused, setFocused] = useState(false);
44
+ const [Active, setActive] = useState(false);
45
+ const Change = (event) => {
46
+ if (searchComponent) {
47
+ setSearchValue(event.target.value);
48
+ }
49
+ onChange?.(event.target.value);
50
+ };
51
+ const Focus = () => {
52
+ onFocus?.();
53
+ if (forDropdown) return;
54
+ setFocused(true);
55
+ };
56
+ const Blur = () => {
57
+ if (!toggleFocus) {
58
+ setFocused(false);
59
+ } else {
60
+ setFocused(customFocus ?? false);
61
+ }
62
+ onBlur?.();
63
+ };
64
+ const handleKeyDown = (event) => {
65
+ const input = event.currentTarget.value;
66
+ const isFirstCharacter = input.length === 0;
67
+ if (type === "number") {
68
+ if (event.keyCode === 69 || !isFirstCharacter && (event.keyCode === 187 || event.keyCode === 107 || event.keyCode === 189 || event.keyCode === 109)) {
69
+ event.preventDefault();
70
+ }
71
+ }
72
+ if (event.key === "Enter" && input && input.length > 0) {
73
+ onEnter?.();
74
+ }
75
+ };
76
+ const getSlot = (slot) => {
77
+ return slot;
78
+ };
79
+ const HandleSearch = () => {
80
+ if (!searchComponent) return;
81
+ setSearchValue("");
82
+ onChange?.("");
83
+ };
84
+ useEffect(() => {
85
+ onFocusChange?.(Focused);
86
+ }, [Focused]);
87
+ useEffect(() => {
88
+ if (customFocus !== void 0 && customFocus !== null) {
89
+ setFocused(customFocus);
90
+ }
91
+ }, [customFocus]);
92
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.inputWrapper} ${disabled ? style.disabled : ""} ${style[size]}`, style: inputWrapperStyle ?? {}, children: [
93
+ label && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.formInputLabelWrapper, children: [
94
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { style: labelStyle ?? {}, className: style.formInputLabel, children: [
95
+ label,
96
+ " ",
97
+ typeof label === "string" && required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: style.formInputRequired, children: "*" })
98
+ ] }),
99
+ helperSlot && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.formInputHelperSlot, children: getSlot(helperSlot) })
100
+ ] }),
101
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
102
+ "div",
103
+ {
104
+ className: `${style.formInputWrapper} ${inputState.error ? style.errorState : ""} ${withFocus && Focused ? !inputState.error ? style.focused : style.errorFocused : ""} ${withActive && Active ? !inputState.error ? style.active : style.errorActive : ""} ${inputState.error ? style.error : ""} ${inputState.success ? style.success : ""}`,
105
+ style: formInputWrapperStyle ?? {},
106
+ onClick: () => toggleFocus && setFocused((state) => !state),
107
+ children: [
108
+ leftSlot && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.formInputSlot, children: getSlot(leftSlot) }),
109
+ searchComponent && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.formInputSlot, children: getSlot(/* @__PURE__ */ jsxRuntimeExports.jsx(IconSearch, {})) }),
110
+ inputSlot ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.formInputSlot, style: inputSlotStyle ?? {}, children: getSlot(inputSlot) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
111
+ "input",
112
+ {
113
+ className: style.formInput,
114
+ ref: InputRef,
115
+ style: formInputStyle ?? {},
116
+ type: type ?? "text",
117
+ value: searchComponent ? SearchValue : value,
118
+ onChange: (event) => Change(event),
119
+ onMouseDown: () => !forDropdown && setActive(true),
120
+ onMouseUp: () => !forDropdown && setActive(false),
121
+ onMouseLeave: () => !forDropdown && setActive(false),
122
+ onFocus: Focus,
123
+ onBlur: Blur,
124
+ disabled,
125
+ required,
126
+ onKeyDown: handleKeyDown,
127
+ readOnly,
128
+ spellCheck: false,
129
+ placeholder: placeholder ?? "",
130
+ autoComplete: "off",
131
+ maxLength
132
+ }
133
+ ),
134
+ rightSlot && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: searchComponent ? { cursor: "pointer" } : {}, className: style.formInputSlot, children: getSlot(rightSlot) }),
135
+ searchComponent && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.formInputSlot, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { onClick: HandleSearch, style: searchComponent ? { cursor: "pointer" } : {}, className: style.formInputSlot, children: SearchValue?.length > 0 ? getSlot(/* @__PURE__ */ jsxRuntimeExports.jsx(IconCloseCircle, {})) : null }) })
136
+ ]
137
+ }
138
+ ),
139
+ helperText && /* @__PURE__ */ jsxRuntimeExports.jsx(
140
+ "p",
141
+ {
142
+ style: helperTextStyle ?? {},
143
+ className: `${style.formInputHelperText} ${inputState.error ? style.errorHelperText : inputState.success ? style.successHelperText : ""}`,
144
+ children: helperText
145
+ }
146
+ )
147
+ ] });
148
+ };
149
+ export {
150
+ FormInput as default
151
+ };
@@ -0,0 +1,62 @@
1
+ const inputWrapper = "FormInput-module__inputWrapper";
2
+ const sm = "FormInput-module__sm";
3
+ const formInputWrapper = "FormInput-module__formInputWrapper";
4
+ const md = "FormInput-module__md";
5
+ const disabled = "FormInput-module__disabled";
6
+ const formInputLabel = "FormInput-module__formInputLabel";
7
+ const formInput = "FormInput-module__formInput";
8
+ const formInputHelperText = "FormInput-module__formInputHelperText";
9
+ const formInputLabelWrapper = "FormInput-module__formInputLabelWrapper";
10
+ const formInputRequired = "FormInput-module__formInputRequired";
11
+ const formInputHelperSlot = "FormInput-module__formInputHelperSlot";
12
+ const errorState = "FormInput-module__errorState";
13
+ const focused = "FormInput-module__focused";
14
+ const active = "FormInput-module__active";
15
+ const errorFocused = "FormInput-module__errorFocused";
16
+ const errorActive = "FormInput-module__errorActive";
17
+ const formInputSlot = "FormInput-module__formInputSlot";
18
+ const errorHelperText = "FormInput-module__errorHelperText";
19
+ const successHelperText = "FormInput-module__successHelperText";
20
+ const style = {
21
+ inputWrapper,
22
+ sm,
23
+ formInputWrapper,
24
+ md,
25
+ disabled,
26
+ formInputLabel,
27
+ formInput,
28
+ formInputHelperText,
29
+ formInputLabelWrapper,
30
+ formInputRequired,
31
+ formInputHelperSlot,
32
+ errorState,
33
+ focused,
34
+ active,
35
+ errorFocused,
36
+ errorActive,
37
+ formInputSlot,
38
+ errorHelperText,
39
+ successHelperText
40
+ };
41
+ export {
42
+ active,
43
+ style as default,
44
+ disabled,
45
+ errorActive,
46
+ errorFocused,
47
+ errorHelperText,
48
+ errorState,
49
+ focused,
50
+ formInput,
51
+ formInputHelperSlot,
52
+ formInputHelperText,
53
+ formInputLabel,
54
+ formInputLabelWrapper,
55
+ formInputRequired,
56
+ formInputSlot,
57
+ formInputWrapper,
58
+ inputWrapper,
59
+ md,
60
+ sm,
61
+ successHelperText
62
+ };
@@ -0,0 +1,24 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./InlineLoading.module.scss.js";
3
+ import { IconErrorDash } from "../../assets/Icons/IconErrorDash.js";
4
+ import { IconLoading } from "../../assets/Icons/IconLoading.js";
5
+ import { IconSuccess } from "../../assets/Icons/IconSuccess.js";
6
+ const InlineLoading = ({ loading, success, error, msg }) => {
7
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.inlineLoadingWrapper}`, children: [
8
+ loading?.state && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.loading, children: [
9
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconLoading, { color1: loading?.color1 ?? "#BCC1C2", color2: loading?.color2, size: loading?.size }),
10
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: msg?.style ?? {}, children: msg?.text ?? "" })
11
+ ] }),
12
+ !loading?.state && success?.state && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
13
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconSuccess, { size: success?.size, color: success?.color }),
14
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: msg?.style ?? {}, children: msg?.text ?? "" })
15
+ ] }),
16
+ !loading?.state && error?.state && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
17
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconErrorDash, { size: error?.size, color: error?.color }),
18
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: msg?.style ?? {}, children: msg?.text ?? "" })
19
+ ] })
20
+ ] });
21
+ };
22
+ export {
23
+ InlineLoading as default
24
+ };
@@ -0,0 +1,11 @@
1
+ const inlineLoadingWrapper = "InlineLoading-module__inlineLoadingWrapper";
2
+ const loading = "InlineLoading-module__loading";
3
+ const style = {
4
+ inlineLoadingWrapper,
5
+ loading
6
+ };
7
+ export {
8
+ style as default,
9
+ inlineLoadingWrapper,
10
+ loading
11
+ };
@@ -0,0 +1,72 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./MainButton.module.scss.js";
3
+ import { useState, useRef, useEffect } from "react";
4
+ import IconCircularLoading from "../../assets/Icons/IconCircularLoading.js";
5
+ const MainButton = ({
6
+ label,
7
+ size = "md",
8
+ leftSlot,
9
+ rightSlot,
10
+ buttonSlot,
11
+ type = "button",
12
+ colorType = "neutral",
13
+ buttonType = "primary",
14
+ withFocus = false,
15
+ customFocus,
16
+ disabled,
17
+ loading = false,
18
+ spaceBetween = false,
19
+ buttonStyle,
20
+ mainButtonContentStyle,
21
+ mainButtonLabelStyle,
22
+ leftSlotStyle,
23
+ rightSlotStyle,
24
+ onClick
25
+ }) => {
26
+ const [Focused, setFocused] = useState(customFocus || false);
27
+ const ButtonRef = useRef(null);
28
+ const Click = (e) => {
29
+ if (disabled || loading) return;
30
+ if (withFocus) {
31
+ setFocused((state) => !state);
32
+ }
33
+ onClick?.(e);
34
+ };
35
+ const getLoadingColor = () => {
36
+ let color = "#ffffff";
37
+ if (colorType === "neutral" && buttonType !== "primary") color = "#0058FF";
38
+ if (colorType === "positive" && buttonType !== "primary") color = "#328707";
39
+ if (colorType === "negative" && buttonType !== "primary") color = "#E3292F";
40
+ return color;
41
+ };
42
+ useEffect(() => {
43
+ const ClickHandler = (event) => {
44
+ if (!ButtonRef.current || disabled) return;
45
+ if (event.composedPath().includes(ButtonRef.current)) return;
46
+ setFocused(false);
47
+ };
48
+ document.addEventListener("click", ClickHandler);
49
+ return () => {
50
+ document.removeEventListener("click", ClickHandler);
51
+ };
52
+ }, []);
53
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
54
+ "button",
55
+ {
56
+ ref: ButtonRef,
57
+ style: buttonStyle,
58
+ type,
59
+ disabled,
60
+ className: `${style.mainButton} ${style[size]} ${loading ? style.loading : ""} ${Focused ? style.focused : ""} ${style[buttonType]} ${style[colorType]} ${disabled ? style.disabled : ""}`,
61
+ onClick: Click,
62
+ children: loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconCircularLoading, { size: 20, stroke: getLoadingColor() }) : buttonSlot || /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.mainButtonContent, style: { ...mainButtonContentStyle, justifyContent: spaceBetween ? "space-between" : "center" }, children: [
63
+ leftSlot && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.leftSlot, style: leftSlotStyle, children: leftSlot }),
64
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: style.mainButtonLabel, style: mainButtonLabelStyle, children: label }),
65
+ rightSlot && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.rightSlot, style: rightSlotStyle, children: rightSlot })
66
+ ] })
67
+ }
68
+ );
69
+ };
70
+ export {
71
+ MainButton as default
72
+ };
@@ -0,0 +1,56 @@
1
+ const mainButton = "MainButton-module__mainButton";
2
+ const sm = "MainButton-module__sm";
3
+ const md = "MainButton-module__md";
4
+ const lg = "MainButton-module__lg";
5
+ const mainButtonContent = "MainButton-module__mainButtonContent";
6
+ const mainButtonLabel = "MainButton-module__mainButtonLabel";
7
+ const primary = "MainButton-module__primary";
8
+ const neutral = "MainButton-module__neutral";
9
+ const loading = "MainButton-module__loading";
10
+ const disabled = "MainButton-module__disabled";
11
+ const focused = "MainButton-module__focused";
12
+ const positive = "MainButton-module__positive";
13
+ const negative = "MainButton-module__negative";
14
+ const secondary = "MainButton-module__secondary";
15
+ const tertiary = "MainButton-module__tertiary";
16
+ const tertiaryV2 = "MainButton-module__tertiaryV2";
17
+ const tertiaryV3 = "MainButton-module__tertiaryV3";
18
+ const style = {
19
+ mainButton,
20
+ sm,
21
+ md,
22
+ lg,
23
+ mainButtonContent,
24
+ mainButtonLabel,
25
+ primary,
26
+ neutral,
27
+ loading,
28
+ disabled,
29
+ focused,
30
+ positive,
31
+ negative,
32
+ secondary,
33
+ tertiary,
34
+ tertiaryV2,
35
+ tertiaryV3
36
+ };
37
+ export {
38
+ style as default,
39
+ disabled,
40
+ focused,
41
+ lg,
42
+ loading,
43
+ mainButton,
44
+ mainButtonContent,
45
+ mainButtonLabel,
46
+ md,
47
+ negative,
48
+ neutral,
49
+ positive,
50
+ primary,
51
+ secondary,
52
+ sm,
53
+ tertiary,
54
+ tertiaryV2,
55
+ tertiaryV3
56
+ };
@@ -0,0 +1,57 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import { createContext, useState, useCallback } from "react";
3
+ import NotificationToast from "./NotificationToast.js";
4
+ import style from "./NotificationToast.module.scss.js";
5
+ const ToastContext = createContext(null);
6
+ let idCounter = 0;
7
+ const ToastProvider = ({ children }) => {
8
+ const [toasts, setToasts] = useState([]);
9
+ const showToast = (props) => {
10
+ setToasts((prev) => {
11
+ const max = props.max ?? Infinity;
12
+ if (prev.length >= max) return prev;
13
+ const id = idCounter++;
14
+ setTimeout(() => {
15
+ setToasts((prev2) => prev2.filter((t) => t.id !== id));
16
+ }, props.timeout || 4e3);
17
+ return [...prev, { id, props }];
18
+ });
19
+ };
20
+ const getPosition = useCallback(() => {
21
+ if (toasts.length > 0) {
22
+ switch (toasts[0]?.props?.position) {
23
+ case "top-left":
24
+ return { top: "20px", left: "20px" };
25
+ case "top-right":
26
+ return { top: "20px", right: "20px" };
27
+ case "bottom-left":
28
+ return { bottom: "20px", left: "20px" };
29
+ case "bottom-right":
30
+ return { bottom: "20px", right: "20px" };
31
+ case "top-center":
32
+ return { top: "20px", left: "50%", transform: "translateX(-50%)" };
33
+ case "bottom-center":
34
+ return { bottom: "20px", left: "50%", transform: "translateX(-50%)" };
35
+ default:
36
+ return {};
37
+ }
38
+ }
39
+ }, [toasts.length]);
40
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(ToastContext.Provider, { value: { showToast }, children: [
41
+ children,
42
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.toastContainer, style: getPosition(), children: toasts.map(({ id, props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
43
+ NotificationToast,
44
+ {
45
+ ...props,
46
+ onClose: () => {
47
+ setToasts((prev) => prev.filter((t) => t.id !== id));
48
+ }
49
+ },
50
+ id
51
+ )) })
52
+ ] });
53
+ };
54
+ export {
55
+ ToastContext,
56
+ ToastProvider as default
57
+ };
@@ -0,0 +1,66 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import { IconCloseBlack } from "../../assets/Icons/IconClose.js";
3
+ import style from "./NotificationToast.module.scss.js";
4
+ import { useState, useEffect } from "react";
5
+ import { IconExclamation } from "../../assets/Icons/IconExclamation.js";
6
+ import { IconCheck } from "../../assets/Icons/IconCheck.js";
7
+ const NotificationToast = ({
8
+ title,
9
+ colorType = "neutral",
10
+ filled = false,
11
+ withClose = false,
12
+ withUndo = false,
13
+ withInfoIcon = true,
14
+ description,
15
+ customAction,
16
+ timeout = 4e3,
17
+ children,
18
+ onUndo,
19
+ onClose
20
+ }) => {
21
+ const [animationClass, setAnimationClass] = useState("fadeIn");
22
+ useEffect(() => {
23
+ const duration = timeout;
24
+ const fadeDuration = 300;
25
+ const hideTimeout = setTimeout(() => {
26
+ setAnimationClass("fadeOut");
27
+ setTimeout(() => {
28
+ onClose?.();
29
+ }, fadeDuration);
30
+ }, duration);
31
+ return () => {
32
+ clearTimeout(hideTimeout);
33
+ };
34
+ }, [onClose]);
35
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
36
+ "div",
37
+ {
38
+ className: `${style.notificationToast} ${style[colorType]} ${filled ? style.filled : ""} ${style[animationClass]}`,
39
+ style: description ? { padding: "12px" } : {},
40
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.notificationToastContent, style: description ? { alignItems: "flex-start" } : {}, children: [
41
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.notificationToastContentLeft, style: description ? { alignItems: "flex-start" } : {}, children: [
42
+ withInfoIcon && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.notificationToastContentInfoIcon, children: colorType === "success" ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconCheck, { color: filled ? "#328707" : "#fff" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconExclamation, { color: filled ? colorType === "neutral" ? "#131314" : colorType === "error" ? "#E3292F" : "#0058FF" : "#fff" }) }),
43
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.notificationToastContentLeftText, children: [
44
+ title && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: style.notificationToastContentLeftTextTitle, children: title }),
45
+ description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: style.notificationToastContentLeftTextDescription, children: description }),
46
+ children && children
47
+ ] })
48
+ ] }),
49
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.notificationToastContentDescription }),
50
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.notificationToastContentRight, children: [
51
+ customAction && customAction,
52
+ !description && withUndo && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: style.notificationToastContentRightUndoText, onClick: () => onUndo?.(), children: "Undo" }),
53
+ withClose && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.notificationToastContentRightClose, style: description || !withUndo ? { border: "none" } : {}, onClick: () => onClose?.(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
54
+ IconCloseBlack,
55
+ {
56
+ color: filled ? colorType === "neutral" ? "#131314" : colorType === "error" ? "#E3292F" : colorType === "info" ? "#0058FF" : "#328707" : "#fff"
57
+ }
58
+ ) })
59
+ ] })
60
+ ] })
61
+ }
62
+ );
63
+ };
64
+ export {
65
+ NotificationToast as default
66
+ };
@@ -0,0 +1,59 @@
1
+ const toastContainer = "NotificationToast-module__toastContainer";
2
+ const notificationToast = "NotificationToast-module__notificationToast";
3
+ const fadeIn = "NotificationToast-module__fadeIn";
4
+ const fadeOut = "NotificationToast-module__fadeOut";
5
+ const neutral = "NotificationToast-module__neutral";
6
+ const filled = "NotificationToast-module__filled";
7
+ const notificationToastContentLeftTextTitle = "NotificationToast-module__notificationToastContentLeftTextTitle";
8
+ const notificationToastContentRightUndoText = "NotificationToast-module__notificationToastContentRightUndoText";
9
+ const notificationToastContentLeftTextDescription = "NotificationToast-module__notificationToastContentLeftTextDescription";
10
+ const info = "NotificationToast-module__info";
11
+ const error = "NotificationToast-module__error";
12
+ const success = "NotificationToast-module__success";
13
+ const notificationToastContent = "NotificationToast-module__notificationToastContent";
14
+ const notificationToastContentLeft = "NotificationToast-module__notificationToastContentLeft";
15
+ const notificationToastContentInfoIcon = "NotificationToast-module__notificationToastContentInfoIcon";
16
+ const notificationToastContentLeftText = "NotificationToast-module__notificationToastContentLeftText";
17
+ const notificationToastContentRight = "NotificationToast-module__notificationToastContentRight";
18
+ const notificationToastContentRightClose = "NotificationToast-module__notificationToastContentRightClose";
19
+ const style = {
20
+ toastContainer,
21
+ notificationToast,
22
+ fadeIn,
23
+ fadeOut,
24
+ neutral,
25
+ filled,
26
+ notificationToastContentLeftTextTitle,
27
+ notificationToastContentRightUndoText,
28
+ notificationToastContentLeftTextDescription,
29
+ info,
30
+ error,
31
+ success,
32
+ notificationToastContent,
33
+ notificationToastContentLeft,
34
+ notificationToastContentInfoIcon,
35
+ notificationToastContentLeftText,
36
+ notificationToastContentRight,
37
+ notificationToastContentRightClose
38
+ };
39
+ export {
40
+ style as default,
41
+ error,
42
+ fadeIn,
43
+ fadeOut,
44
+ filled,
45
+ info,
46
+ neutral,
47
+ notificationToast,
48
+ notificationToastContent,
49
+ notificationToastContentInfoIcon,
50
+ notificationToastContentLeft,
51
+ notificationToastContentLeftText,
52
+ notificationToastContentLeftTextDescription,
53
+ notificationToastContentLeftTextTitle,
54
+ notificationToastContentRight,
55
+ notificationToastContentRightClose,
56
+ notificationToastContentRightUndoText,
57
+ success,
58
+ toastContainer
59
+ };
@@ -0,0 +1,10 @@
1
+ import { ToastContext } from "./NotificationContext.js";
2
+ import { useContext } from "react";
3
+ const createNotificationToast = () => {
4
+ const context = useContext(ToastContext);
5
+ if (!context) throw new Error("createNotificationToast must be used within ToastProvider");
6
+ return context.showToast;
7
+ };
8
+ export {
9
+ createNotificationToast as default
10
+ };