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,116 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./Popup.module.scss.js";
3
+ import { IconCheckCircle } from "../../assets/Icons/IconCheckCircle.js";
4
+ import { IconSave } from "../../assets/Icons/IconSave.js";
5
+ import { IconTrash } from "../../assets/Icons/IconTrash.js";
6
+ import { useRef, useEffect } from "react";
7
+ import { IconCloseBlack } from "../../assets/Icons/IconClose.js";
8
+ const Popup = ({
9
+ visible,
10
+ template,
11
+ options,
12
+ children,
13
+ onClickOutside,
14
+ onClose,
15
+ widthType,
16
+ // "horizontal"
17
+ modalOverlayStyle,
18
+ popupContainerStyle,
19
+ templateWrapperStyle,
20
+ popupHeaderStyle,
21
+ popupTitleStyle,
22
+ closeButtonStyle
23
+ }) => {
24
+ const _getType = () => {
25
+ if (!options || !options?.type) return;
26
+ switch (String(options?.type)) {
27
+ case "delete": {
28
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(IconTrash, {});
29
+ }
30
+ case "unsaved": {
31
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(IconSave, {});
32
+ }
33
+ case "success": {
34
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(IconCheckCircle, {});
35
+ }
36
+ }
37
+ };
38
+ const ClickClose = () => {
39
+ if (onClose && typeof onClose === "function") {
40
+ onClose();
41
+ }
42
+ };
43
+ const componentRef = useRef(null);
44
+ const handleClick = (event) => {
45
+ const clickedElement = event.target;
46
+ if (clickedElement === componentRef.current) {
47
+ if (onClickOutside && typeof onClickOutside === "function") {
48
+ onClickOutside();
49
+ }
50
+ }
51
+ };
52
+ useEffect(() => {
53
+ document.addEventListener("click", handleClick);
54
+ return () => {
55
+ document.removeEventListener("click", handleClick);
56
+ };
57
+ }, []);
58
+ return visible && /* @__PURE__ */ jsxRuntimeExports.jsx(
59
+ "div",
60
+ {
61
+ ref: componentRef,
62
+ style: modalOverlayStyle ?? {},
63
+ className: `
64
+ ${style.modalOverlay}
65
+ ${options && options?.mode === "drawer" ? style.popupDrawerMode : ""}
66
+ `,
67
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
68
+ "div",
69
+ {
70
+ style: popupContainerStyle ?? {},
71
+ className: `
72
+ mcPopup_global
73
+ ${style.popupContainer}
74
+ ${options?.type ? style.withOptions : ""}
75
+ ${widthType === "horizontal" ? style.horizontal : ""}
76
+ `,
77
+ children: [
78
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.closeButton, style: closeButtonStyle ?? {}, onClick: ClickClose, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
79
+ IconCloseBlack,
80
+ {
81
+ color: "#131314"
82
+ }
83
+ ) }),
84
+ (options?.title || options?.description || options?.type) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.popupHeader}`, style: popupHeaderStyle ?? {}, children: [
85
+ _getType() && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.typeIcon, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
86
+ "div",
87
+ {
88
+ style: { backgroundColor: options?.type === "success" ? "#DCFAE6" : options?.type === "unsaved" ? "#FEF0C7" : "#FEE4E2" },
89
+ className: style.icon,
90
+ children: _getType()
91
+ }
92
+ ) }),
93
+ options && options?.title && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.popupTitle, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { style: popupTitleStyle ?? {}, children: [
94
+ " ",
95
+ options?.title ?? "",
96
+ " "
97
+ ] }) }),
98
+ options && options?.description && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.popupDescription, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { children: [
99
+ " ",
100
+ options?.description ?? "",
101
+ " "
102
+ ] }) })
103
+ ] }),
104
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.templateWrapper, style: templateWrapperStyle ?? {}, children: [
105
+ template && template,
106
+ children && children
107
+ ] })
108
+ ]
109
+ }
110
+ )
111
+ }
112
+ );
113
+ };
114
+ export {
115
+ Popup as default
116
+ };
@@ -0,0 +1,41 @@
1
+ const modalOverlay = "Popup-module__modalOverlay";
2
+ const popupDrawerMode = "Popup-module__popupDrawerMode";
3
+ const popupContainer = "Popup-module__popupContainer";
4
+ const closeButton = "Popup-module__closeButton";
5
+ const withOptions = "Popup-module__withOptions";
6
+ const horizontal = "Popup-module__horizontal";
7
+ const popupHeader = "Popup-module__popupHeader";
8
+ const popupTitle = "Popup-module__popupTitle";
9
+ const popupDescription = "Popup-module__popupDescription";
10
+ const typeIcon = "Popup-module__typeIcon";
11
+ const icon = "Popup-module__icon";
12
+ const templateWrapper = "Popup-module__templateWrapper";
13
+ const style = {
14
+ modalOverlay,
15
+ popupDrawerMode,
16
+ popupContainer,
17
+ closeButton,
18
+ withOptions,
19
+ horizontal,
20
+ popupHeader,
21
+ popupTitle,
22
+ popupDescription,
23
+ typeIcon,
24
+ icon,
25
+ templateWrapper
26
+ };
27
+ export {
28
+ closeButton,
29
+ style as default,
30
+ horizontal,
31
+ icon,
32
+ modalOverlay,
33
+ popupContainer,
34
+ popupDescription,
35
+ popupDrawerMode,
36
+ popupHeader,
37
+ popupTitle,
38
+ templateWrapper,
39
+ typeIcon,
40
+ withOptions
41
+ };
@@ -0,0 +1,46 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./Radio.module.scss.js";
3
+ import { useState } from "react";
4
+ import { useNamespace } from "../../context/NamespaceContext.js";
5
+ import { IconRadioCheckedDisabled } from "../../assets/Icons/IconRadioCheckedDisabled.js";
6
+ import { IconRadioChecked } from "../../assets/Icons/IconRadioChecked.js";
7
+ import { IconRadioUncheckedDisabled } from "../../assets/Icons/IconRadioUncheckedDisabled.js";
8
+ import { IconRadioUnchecked } from "../../assets/Icons/IconRadioUnchecked.js";
9
+ const Radio = ({ checked, change, disabled, required, withUncheckState = false, radioType = "default" }) => {
10
+ useNamespace();
11
+ useState(false);
12
+ const onChange = () => {
13
+ if (!disabled) {
14
+ if (withUncheckState) {
15
+ change?.(!checked);
16
+ } else {
17
+ change?.(true);
18
+ }
19
+ }
20
+ };
21
+ const RadioIcon = () => {
22
+ let icon = null;
23
+ let color = disabled ? "#95969C" : radioType === "error" ? "#E3292F" : "#0058FF";
24
+ if (checked) {
25
+ if (disabled) {
26
+ icon = /* @__PURE__ */ jsxRuntimeExports.jsx(IconRadioCheckedDisabled, { color });
27
+ } else {
28
+ icon = /* @__PURE__ */ jsxRuntimeExports.jsx(IconRadioChecked, { color });
29
+ }
30
+ } else {
31
+ if (disabled) {
32
+ icon = /* @__PURE__ */ jsxRuntimeExports.jsx(IconRadioUncheckedDisabled, { color });
33
+ } else {
34
+ icon = /* @__PURE__ */ jsxRuntimeExports.jsx(IconRadioUnchecked, { color });
35
+ }
36
+ }
37
+ return icon;
38
+ };
39
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.radioWrapper, style: { cursor: disabled ? "not-allowed" : "pointer" }, onClick: onChange, children: [
40
+ /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "radio", checked: true, readOnly: true, hidden: true, disabled: disabled ?? false, required }),
41
+ RadioIcon()
42
+ ] });
43
+ };
44
+ export {
45
+ Radio as default
46
+ };
@@ -0,0 +1,8 @@
1
+ const radioWrapper = "Radio-module__radioWrapper";
2
+ const style = {
3
+ radioWrapper
4
+ };
5
+ export {
6
+ style as default,
7
+ radioWrapper
8
+ };
@@ -0,0 +1,8 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./Skeleton.module.scss.js";
3
+ const Skeleton = ({ type = "text", customStyle, children }) => {
4
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: customStyle ?? {}, className: ` ${style.skeleton} ${style[type] || ""}`, children });
5
+ };
6
+ export {
7
+ Skeleton as default
8
+ };
@@ -0,0 +1,20 @@
1
+ const skeleton = "Skeleton-module__skeleton";
2
+ const shimmer = "Skeleton-module__shimmer";
3
+ const text = "Skeleton-module__text";
4
+ const avatar = "Skeleton-module__avatar";
5
+ const dark = "Skeleton-module__dark";
6
+ const style = {
7
+ skeleton,
8
+ shimmer,
9
+ text,
10
+ avatar,
11
+ dark
12
+ };
13
+ export {
14
+ avatar,
15
+ dark,
16
+ style as default,
17
+ shimmer,
18
+ skeleton,
19
+ text
20
+ };
@@ -0,0 +1,149 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import { useRef, useState, useEffect } from "react";
3
+ import style from "./Textarea.module.scss.js";
4
+ import { IconCloseBackground } from "../../assets/Icons/IconCloseBackground.js";
5
+ const Textarea = ({
6
+ placeholder,
7
+ label,
8
+ cols = 30,
9
+ rows = 5,
10
+ value,
11
+ inputState = { error: false, success: true },
12
+ maxLength = 20,
13
+ withFocus = true,
14
+ withActive = true,
15
+ withResize = true,
16
+ withClose = true,
17
+ onChange,
18
+ onFocus,
19
+ onBlur,
20
+ disabled,
21
+ required,
22
+ textareaContainerStyle,
23
+ textareaLabelStyle,
24
+ requiredStyle,
25
+ labelSlot,
26
+ textareaFooterStyle
27
+ }) => {
28
+ const TextareaRef = useRef(null);
29
+ const [Focused, setFocused] = useState(false);
30
+ const [Active, setActive] = useState(false);
31
+ const Change = (e) => {
32
+ let value2 = e.target.value;
33
+ if (onChange && typeof onChange === "function") {
34
+ onChange(value2);
35
+ }
36
+ };
37
+ const iconSlot = (icon) => {
38
+ return icon;
39
+ };
40
+ const Focus = (e) => {
41
+ setFocused(true);
42
+ if (onFocus && typeof onFocus === "function") {
43
+ onFocus(e);
44
+ }
45
+ };
46
+ const Blur = (e) => {
47
+ setFocused(false);
48
+ if (onBlur && typeof onBlur === "function") {
49
+ onBlur(e);
50
+ }
51
+ };
52
+ let isManuallyResized = false;
53
+ useEffect(() => {
54
+ if (!TextareaRef.current) return;
55
+ const textarea = TextareaRef.current.querySelector("textarea");
56
+ if (!textarea) return;
57
+ let isUserResizing = false;
58
+ const onMouseDown = (e) => {
59
+ const bounds = textarea.getBoundingClientRect();
60
+ const isNearBottomRight = e.clientX > bounds.right - 20 && e.clientY > bounds.bottom - 20;
61
+ if (isNearBottomRight) {
62
+ isUserResizing = true;
63
+ }
64
+ };
65
+ const observer = new ResizeObserver(() => {
66
+ if (isUserResizing) {
67
+ isManuallyResized = true;
68
+ isUserResizing = false;
69
+ }
70
+ });
71
+ textarea.addEventListener("mousedown", onMouseDown);
72
+ observer.observe(textarea);
73
+ return () => {
74
+ textarea.removeEventListener("mousedown", onMouseDown);
75
+ observer.disconnect();
76
+ };
77
+ }, []);
78
+ const adjustHeight = () => {
79
+ if (!TextareaRef.current) return;
80
+ const el = TextareaRef.current.querySelector("textarea");
81
+ if (!el || isManuallyResized) return;
82
+ el.style.height = "auto";
83
+ el.style.height = `${el.scrollHeight}px`;
84
+ };
85
+ useEffect(() => {
86
+ if (!TextareaRef.current) return;
87
+ const textarea = TextareaRef.current.querySelector("textarea");
88
+ const observer = new ResizeObserver(() => {
89
+ const isShrunk = textarea.offsetHeight < textarea.scrollHeight;
90
+ isManuallyResized = isShrunk;
91
+ });
92
+ observer.observe(textarea);
93
+ return () => observer.disconnect();
94
+ }, []);
95
+ const handleInput = (e) => {
96
+ isManuallyResized = false;
97
+ onChange?.(e.target.value);
98
+ adjustHeight();
99
+ };
100
+ const HandleClose = () => {
101
+ if (onChange && typeof onChange === "function") {
102
+ onChange("");
103
+ }
104
+ };
105
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
106
+ "div",
107
+ {
108
+ style: textareaContainerStyle ?? {},
109
+ className: `${style.textareaContainer} ${inputState.error ? style.error : ""} ${disabled ? style.disabled : null}`,
110
+ children: [
111
+ label && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: textareaLabelStyle, className: style.textAreaLabel, children: [
112
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: label }),
113
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: requiredStyle ?? {}, className: style.required, children: required && "*" }),
114
+ labelSlot && iconSlot(labelSlot)
115
+ ] }),
116
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.wrap} ${withResize ? style.resize : ""}`, ref: TextareaRef, children: [
117
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
118
+ "textarea",
119
+ {
120
+ className: `${style.textarea} ${Focused ? style.focused : ""} ${disabled ? style.disabled : ""} ${withFocus && Focused ? !inputState.error ? style.focused : style.errorFocused : ""} ${withActive && Active ? !inputState.error ? style.active : style.errorActive : ""} ${inputState.error ? style.error : ""} ${inputState.success ? style.success : ""}`,
121
+ value,
122
+ placeholder: placeholder ?? "",
123
+ cols,
124
+ rows,
125
+ maxLength: maxLength ?? void 0,
126
+ onInput: handleInput,
127
+ onFocus: Focus,
128
+ disabled,
129
+ onBlur: Blur,
130
+ onChange: Change,
131
+ onMouseDown: () => setActive(true),
132
+ onMouseUp: () => setActive(false),
133
+ onMouseLeave: () => setActive(false)
134
+ }
135
+ ),
136
+ withClose && value && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.textareaIconClose, onClick: HandleClose, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCloseBackground, {}) })
137
+ ] }),
138
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: textareaFooterStyle ?? {}, className: style.textareaFooter, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { children: [
139
+ value?.length,
140
+ "/",
141
+ maxLength
142
+ ] }) })
143
+ ]
144
+ }
145
+ );
146
+ };
147
+ export {
148
+ Textarea as default
149
+ };
@@ -0,0 +1,41 @@
1
+ const textareaContainer = "Textarea-module__textareaContainer";
2
+ const textAreaLabel = "Textarea-module__textAreaLabel";
3
+ const required = "Textarea-module__required";
4
+ const wrap = "Textarea-module__wrap";
5
+ const resize = "Textarea-module__resize";
6
+ const textareaIconClose = "Textarea-module__textareaIconClose";
7
+ const textarea = "Textarea-module__textarea";
8
+ const focused = "Textarea-module__focused";
9
+ const active = "Textarea-module__active";
10
+ const errorFocused = "Textarea-module__errorFocused";
11
+ const errorActive = "Textarea-module__errorActive";
12
+ const textareaFooter = "Textarea-module__textareaFooter";
13
+ const style = {
14
+ textareaContainer,
15
+ textAreaLabel,
16
+ required,
17
+ wrap,
18
+ resize,
19
+ textareaIconClose,
20
+ textarea,
21
+ focused,
22
+ active,
23
+ errorFocused,
24
+ errorActive,
25
+ textareaFooter
26
+ };
27
+ export {
28
+ active,
29
+ style as default,
30
+ errorActive,
31
+ errorFocused,
32
+ focused,
33
+ required,
34
+ resize,
35
+ textAreaLabel,
36
+ textarea,
37
+ textareaContainer,
38
+ textareaFooter,
39
+ textareaIconClose,
40
+ wrap
41
+ };
@@ -0,0 +1,172 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import { useRef, useState, useEffect } from "react";
3
+ import style from "./TimePicker.module.scss.js";
4
+ import FormInput from "../FormInput/FormInput.js";
5
+ import { IconArrowUp } from "../../assets/Icons/IconArrowUp.js";
6
+ import { IconCloseCircle } from "../../assets/Icons/IconCloseCircle.js";
7
+ import customParseFormat from "../../node_modules/dayjs/plugin/customParseFormat.js";
8
+ import dayjs from "dayjs";
9
+ import MainButton from "../MainButton/MainButton.js";
10
+ dayjs.extend(customParseFormat);
11
+ const TimePicker = ({
12
+ value,
13
+ defaultTimeType = "24",
14
+ defaultAmPm = "AM",
15
+ withConfirm = true,
16
+ mode = "single",
17
+ onChange,
18
+ onFocus,
19
+ onBlur,
20
+ ...rest
21
+ }) => {
22
+ const ComponentRef = useRef(null);
23
+ const DropdownRef = useRef(null);
24
+ const [IsFocused, setIsFocused] = useState(false);
25
+ const [TimeType, setTimeType] = useState(defaultTimeType);
26
+ const hours12 = Array.from({ length: 12 }, (_, index) => index < 10 ? `0${index}` : `${index}`);
27
+ const hours24 = Array.from({ length: 24 }, (_, index) => index < 10 ? `0${index}` : `${index}`);
28
+ const minutes = Array.from({ length: 60 }, (_, index) => index < 10 ? `0${index}` : `${index}`);
29
+ const [Value, setValue] = useState("");
30
+ const [Minutes, setMinutes] = useState(null);
31
+ const [Hours, setHours] = useState(null);
32
+ const [AmPm, setAmPm] = useState(defaultAmPm);
33
+ const CalculatePos = () => {
34
+ const componentEl = ComponentRef.current;
35
+ const dropdownEl = DropdownRef.current;
36
+ if (!dropdownEl || !componentEl) return;
37
+ const componentRect = componentEl.getBoundingClientRect();
38
+ const windowHeight = window.innerHeight;
39
+ dropdownEl.style.position = "fixed";
40
+ dropdownEl.style.left = `${componentRect.left + window.pageXOffset}px`;
41
+ if (componentRect.bottom + dropdownEl.offsetHeight > windowHeight) {
42
+ dropdownEl.style.top = `${window.scrollY + componentRect.top - dropdownEl.offsetHeight + 18}px`;
43
+ dropdownEl.style.bottom = "unset";
44
+ } else {
45
+ dropdownEl.style.top = `${window.scrollY + componentRect.bottom + 8}px`;
46
+ dropdownEl.style.bottom = "unset";
47
+ }
48
+ };
49
+ const Focus = () => {
50
+ onFocus?.();
51
+ };
52
+ const Clear = () => {
53
+ setValue("");
54
+ setHours(null);
55
+ setMinutes(null);
56
+ setAmPm("AM");
57
+ };
58
+ useEffect(() => {
59
+ if (value && value.length > 0) {
60
+ setValue(value);
61
+ }
62
+ }, [value]);
63
+ useEffect(() => {
64
+ if (!Hours && !Minutes) return;
65
+ const hour = parseInt(Hours ?? "0", 10);
66
+ const minute = parseInt(Minutes ?? "0", 10);
67
+ const adjustedHour = TimeType === "12" ? AmPm === "PM" && hour < 12 ? hour + 12 : AmPm === "AM" && hour === 12 ? 0 : hour : hour;
68
+ const formattedTime = dayjs().hour(adjustedHour).minute(minute).format(TimeType === "12" ? "hh:mm A" : "HH:mm");
69
+ setValue(formattedTime);
70
+ if (!withConfirm) {
71
+ onChange?.(formattedTime);
72
+ }
73
+ }, [Hours, Minutes, AmPm, TimeType]);
74
+ const isInitialRender = useRef(true);
75
+ useEffect(() => {
76
+ if (isInitialRender.current) {
77
+ isInitialRender.current = false;
78
+ return;
79
+ }
80
+ if (!IsFocused) {
81
+ onBlur?.();
82
+ }
83
+ }, [IsFocused]);
84
+ useEffect(() => {
85
+ CalculatePos();
86
+ }, [ComponentRef, IsFocused]);
87
+ useEffect(() => {
88
+ const ClickHandler = (event) => {
89
+ if (!ComponentRef.current || !DropdownRef.current) return;
90
+ if (event.composedPath().includes(ComponentRef.current) || event.composedPath().includes(DropdownRef.current)) return;
91
+ setIsFocused(false);
92
+ };
93
+ const ScrollHandler = (event) => {
94
+ if (!ComponentRef.current || DropdownRef.current) return;
95
+ setIsFocused(false);
96
+ };
97
+ document.addEventListener("click", ClickHandler);
98
+ document.addEventListener("wheel", ScrollHandler);
99
+ return () => {
100
+ document.removeEventListener("click", ClickHandler);
101
+ document.removeEventListener("wheel", ScrollHandler);
102
+ };
103
+ }, []);
104
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.timepickerWrapper} ${IsFocused ? style.focused : ""}`, children: [
105
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: ComponentRef, className: style.timepickerInputWrapper, onClick: () => (setIsFocused((state) => !state), CalculatePos()), onFocus: Focus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
106
+ FormInput,
107
+ {
108
+ ...rest,
109
+ onFocusChange: (value2) => setIsFocused(value2),
110
+ customFocus: IsFocused,
111
+ withActive: false,
112
+ value: Value,
113
+ toggleFocus: true,
114
+ formInputStyle: { cursor: "pointer" },
115
+ rightSlot: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.dropdownRightIcon} ${IsFocused ? style.focused : ""}`, children: [
116
+ Value && /* @__PURE__ */ jsxRuntimeExports.jsx(
117
+ "div",
118
+ {
119
+ onClick: (e) => {
120
+ e.stopPropagation();
121
+ Clear();
122
+ },
123
+ className: style.dropdownRightIconClose,
124
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCloseCircle, {})
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.dropdownRightIconArrow, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconArrowUp, {}) })
128
+ ] }),
129
+ readOnly: true,
130
+ forDropdown: true
131
+ }
132
+ ) }),
133
+ IsFocused && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: DropdownRef, className: style.timepickerDropdownWrapper, children: [
134
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.timepickerDropdownHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.timepickerDropdownHeaderButtons, children: [
135
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
136
+ "p",
137
+ {
138
+ className: TimeType === "12" ? style.active : "",
139
+ onClick: () => {
140
+ Clear();
141
+ setTimeType("12");
142
+ },
143
+ children: "AM -PM"
144
+ }
145
+ ),
146
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
147
+ "p",
148
+ {
149
+ className: TimeType === "24" ? style.active : "",
150
+ onClick: () => {
151
+ Clear();
152
+ setTimeType("24");
153
+ },
154
+ children: "24 Hours"
155
+ }
156
+ )
157
+ ] }) }),
158
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.timepickerDropdownBody, children: [
159
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.timepickerDropdownBodyHours, children: (TimeType === "12" ? hours12 : hours24).map((hour) => /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: Hours === hour || Value?.split(":")[0] === hour ? style.active : "", onClick: () => setHours(hour), children: hour }, hour)) }),
160
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.timepickerDropdownBodyMinutes, children: minutes.map((minute) => /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: Minutes === minute || Value?.split(":")[1] === minute ? style.active : "", onClick: () => setMinutes(minute), children: minute }, minute)) }),
161
+ TimeType === "12" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.timepickerDropdownBodyAmPm, children: [
162
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: AmPm === "AM" ? style.active : "", onClick: () => setAmPm("AM"), children: "AM" }, "AM"),
163
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: AmPm === "PM" ? style.active : "", onClick: () => setAmPm("PM"), children: "PM" }, "PM")
164
+ ] })
165
+ ] }),
166
+ withConfirm && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.timepickerDropdownFooter, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MainButton, { label: "Confirm time", onClick: () => onChange?.(Value) }) })
167
+ ] })
168
+ ] });
169
+ };
170
+ export {
171
+ TimePicker as default
172
+ };
@@ -0,0 +1,50 @@
1
+ const timepickerWrapper = "TimePicker-module__timepickerWrapper";
2
+ const timepickerInputWrapper = "TimePicker-module__timepickerInputWrapper";
3
+ const dropdownRightIcon = "TimePicker-module__dropdownRightIcon";
4
+ const dropdownRightIconClose = "TimePicker-module__dropdownRightIconClose";
5
+ const dropdownRightIconArrow = "TimePicker-module__dropdownRightIconArrow";
6
+ const focused = "TimePicker-module__focused";
7
+ const timepickerDropdownWrapper = "TimePicker-module__timepickerDropdownWrapper";
8
+ const timepickerDropdownHeader = "TimePicker-module__timepickerDropdownHeader";
9
+ const timepickerDropdownHeaderButtons = "TimePicker-module__timepickerDropdownHeaderButtons";
10
+ const active = "TimePicker-module__active";
11
+ const timepickerDropdownBody = "TimePicker-module__timepickerDropdownBody";
12
+ const timepickerDropdownBodyHours = "TimePicker-module__timepickerDropdownBodyHours";
13
+ const timepickerDropdownBodyMinutes = "TimePicker-module__timepickerDropdownBodyMinutes";
14
+ const timepickerDropdownBodyAmPm = "TimePicker-module__timepickerDropdownBodyAmPm";
15
+ const timepickerDropdownFooter = "TimePicker-module__timepickerDropdownFooter";
16
+ const style = {
17
+ timepickerWrapper,
18
+ timepickerInputWrapper,
19
+ dropdownRightIcon,
20
+ dropdownRightIconClose,
21
+ dropdownRightIconArrow,
22
+ focused,
23
+ timepickerDropdownWrapper,
24
+ timepickerDropdownHeader,
25
+ timepickerDropdownHeaderButtons,
26
+ active,
27
+ timepickerDropdownBody,
28
+ timepickerDropdownBodyHours,
29
+ timepickerDropdownBodyMinutes,
30
+ timepickerDropdownBodyAmPm,
31
+ timepickerDropdownFooter
32
+ };
33
+ export {
34
+ active,
35
+ style as default,
36
+ dropdownRightIcon,
37
+ dropdownRightIconArrow,
38
+ dropdownRightIconClose,
39
+ focused,
40
+ timepickerDropdownBody,
41
+ timepickerDropdownBodyAmPm,
42
+ timepickerDropdownBodyHours,
43
+ timepickerDropdownBodyMinutes,
44
+ timepickerDropdownFooter,
45
+ timepickerDropdownHeader,
46
+ timepickerDropdownHeaderButtons,
47
+ timepickerDropdownWrapper,
48
+ timepickerInputWrapper,
49
+ timepickerWrapper
50
+ };
@@ -0,0 +1,20 @@
1
+ import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
2
+ import style from "./Toggle.module.scss.js";
3
+ const Toggle = ({ checked, change, disabled = false, size = "md", toggleType = "default", required = false }) => {
4
+ const onChange = () => {
5
+ if (!disabled) {
6
+ change?.(!checked);
7
+ }
8
+ };
9
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
10
+ "div",
11
+ {
12
+ onClick: onChange,
13
+ className: `${style.toggleWrapper} ${toggleType === "error" ? style.error : ""} ${style[size]} ${checked ? style.checked : ""} ${disabled ? style.disabled : ""}`,
14
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.toggleState, children: /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "checkbox", checked, readOnly: true, disabled: disabled ?? false, hidden: true, required }) })
15
+ }
16
+ );
17
+ };
18
+ export {
19
+ Toggle as default
20
+ };