master-components-react-ts 2.1.9 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +1 -8
- package/dist/_virtual/customParseFormat.js +1 -4
- package/dist/assets/Icons/IconArrowUp.js +1 -13
- package/dist/assets/Icons/IconCalendar.js +1 -32
- package/dist/assets/Icons/IconCheck.js +1 -15
- package/dist/assets/Icons/IconCheckCircle.js +1 -16
- package/dist/assets/Icons/IconCheckmark.js +1 -15
- package/dist/assets/Icons/IconCircularLoading.js +1 -36
- package/dist/assets/Icons/IconClose.js +1 -31
- package/dist/assets/Icons/IconCloseBackground.js +1 -15
- package/dist/assets/Icons/IconCloseCircle.js +1 -15
- package/dist/assets/Icons/IconErrorDash.js +1 -15
- package/dist/assets/Icons/IconExclamation.js +1 -15
- package/dist/assets/Icons/IconLeft.js +1 -13
- package/dist/assets/Icons/IconLoading.js +1 -22
- package/dist/assets/Icons/IconMinus.js +1 -7
- package/dist/assets/Icons/IconRadioChecked.js +1 -19
- package/dist/assets/Icons/IconRadioCheckedDisabled.js +1 -19
- package/dist/assets/Icons/IconRadioUnchecked.js +1 -16
- package/dist/assets/Icons/IconRadioUncheckedDisabled.js +1 -16
- package/dist/assets/Icons/IconRight.js +1 -13
- package/dist/assets/Icons/IconSave.js +1 -16
- package/dist/assets/Icons/IconSearch.js +1 -26
- package/dist/assets/Icons/IconSuccess.js +1 -15
- package/dist/assets/Icons/IconTrash.js +1 -16
- package/dist/components/ActionDropdown/ActionDropdown.js +1 -74
- package/dist/components/ActionDropdown/ActionDropdown.module.scss.js +1 -29
- package/dist/components/Checkbox/Checkbox.js +1 -54
- package/dist/components/Checkbox/Checkbox.module.scss.js +1 -26
- package/dist/components/DatePicker/Calendar.js +15 -437
- package/dist/components/DatePicker/Calendar.module.scss.js +1 -83
- package/dist/components/DatePicker/DatePicker.js +1 -211
- package/dist/components/DatePicker/Datepicker.module.scss.js +1 -17
- package/dist/components/Dropdown/Dropdown.js +1 -337
- package/dist/components/Dropdown/Dropdown.module.scss.js +1 -74
- package/dist/components/FormInput/FormInput.js +1 -151
- package/dist/components/FormInput/FormInput.module.scss.js +1 -62
- package/dist/components/InlineLoading/InlineLoading.js +1 -24
- package/dist/components/InlineLoading/InlineLoading.module.scss.js +1 -11
- package/dist/components/MainButton/MainButton.js +1 -72
- package/dist/components/MainButton/MainButton.module.scss.js +1 -56
- package/dist/components/NotificationToast/NotificationContext.js +1 -57
- package/dist/components/NotificationToast/NotificationToast.js +1 -66
- package/dist/components/NotificationToast/NotificationToast.module.scss.js +1 -59
- package/dist/components/NotificationToast/createNotificationToast.js +1 -10
- package/dist/components/Popup/Popup.js +8 -115
- package/dist/components/Popup/Popup.module.scss.js +1 -41
- package/dist/components/Radio/Radio.js +1 -46
- package/dist/components/Radio/Radio.module.scss.js +1 -8
- package/dist/components/Skeleton/Skeleton.js +1 -8
- package/dist/components/Skeleton/Skeleton.module.scss.js +1 -20
- package/dist/components/Textarea/Textarea.js +1 -149
- package/dist/components/Textarea/Textarea.module.scss.js +1 -41
- package/dist/components/TimePicker/TimePicker.js +1 -172
- package/dist/components/TimePicker/TimePicker.module.scss.js +1 -50
- package/dist/components/Toggle/Toggle.js +1 -20
- package/dist/components/Toggle/Toggle.module.scss.js +1 -29
- package/dist/components/Tooltip/Tooltip.js +1 -153
- package/dist/components/Tooltip/Tooltip.module.scss.js +1 -35
- package/dist/context/NamespaceContext.js +1 -7
- package/dist/index.js +2 -2294
- package/dist/node_modules/dayjs/plugin/customParseFormat.js +1 -129
- package/dist/utils/Helpers.js +1 -15
- package/package.json +2 -2
- package/dist/assets/Inter_24pt-Medium-C1cYvkz2.woff2 +0 -0
- package/dist/assets/Inter_24pt-Regular-C7SEt4-L.woff2 +0 -0
- package/dist/assets/Inter_24pt-SemiBold-DIQUEucn.woff2 +0 -0
|
@@ -1,116 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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__ */ jsx(IconTrash, {});
|
|
29
|
-
}
|
|
30
|
-
case "unsaved": {
|
|
31
|
-
return /* @__PURE__ */ jsx(IconSave, {});
|
|
32
|
-
}
|
|
33
|
-
case "success": {
|
|
34
|
-
return /* @__PURE__ */ 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__ */ 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__ */ jsxs(
|
|
68
|
-
"div",
|
|
69
|
-
{
|
|
70
|
-
style: popupContainerStyle ?? {},
|
|
71
|
-
className: `
|
|
1
|
+
import{jsx as r,jsxs as t}from"react/jsx-runtime";import c from"./Popup.module.scss.js";import{IconCheckCircle as C}from"../../assets/Icons/IconCheckCircle.js";import{IconSave as $}from"../../assets/Icons/IconSave.js";import{IconTrash as g}from"../../assets/Icons/IconTrash.js";import{useRef as I,useEffect as w}from"react";import{IconCloseBlack as F}from"../../assets/Icons/IconClose.js";const P=({visible:p,template:i,options:e,children:s,onClickOutside:l,onClose:a,widthType:o,modalOverlayStyle:u,popupContainerStyle:f,templateWrapperStyle:y,popupHeaderStyle:h,popupTitleStyle:v,closeButtonStyle:E})=>{const n=()=>{if(!(!e||!e?.type))switch(String(e?.type)){case"delete":return r(g,{});case"unsaved":return r($,{});case"success":return r(C,{})}},N=()=>{a&&typeof a=="function"&&a()},d=I(null),m=k=>{k.target===d.current&&l&&typeof l=="function"&&l()};return w(()=>(document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}),[]),p&&r("div",{ref:d,style:u??{},className:`
|
|
2
|
+
${c.modalOverlay}
|
|
3
|
+
${e&&e?.mode==="drawer"?c.popupDrawerMode:""}
|
|
4
|
+
`,children:t("div",{style:f??{},className:`
|
|
72
5
|
mcPopup_global
|
|
73
|
-
${
|
|
74
|
-
${
|
|
75
|
-
${
|
|
76
|
-
`,
|
|
77
|
-
children: [
|
|
78
|
-
/* @__PURE__ */ jsx("div", { className: style.closeButton, style: closeButtonStyle ?? {}, onClick: ClickClose, children: /* @__PURE__ */ jsx(
|
|
79
|
-
IconCloseBlack,
|
|
80
|
-
{
|
|
81
|
-
color: "#131314"
|
|
82
|
-
}
|
|
83
|
-
) }),
|
|
84
|
-
(options?.title || options?.description || options?.type) && /* @__PURE__ */ jsxs("div", { className: `${style.popupHeader}`, style: popupHeaderStyle ?? {}, children: [
|
|
85
|
-
_getType() && /* @__PURE__ */ jsx("div", { className: style.typeIcon, children: /* @__PURE__ */ 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__ */ jsx("div", { className: style.popupTitle, children: /* @__PURE__ */ jsxs("h2", { style: popupTitleStyle ?? {}, children: [
|
|
94
|
-
" ",
|
|
95
|
-
options?.title ?? "",
|
|
96
|
-
" "
|
|
97
|
-
] }) }),
|
|
98
|
-
options && options?.description && /* @__PURE__ */ jsx("div", { className: style.popupDescription, children: /* @__PURE__ */ jsxs("p", { children: [
|
|
99
|
-
" ",
|
|
100
|
-
options?.description ?? "",
|
|
101
|
-
" "
|
|
102
|
-
] }) })
|
|
103
|
-
] }),
|
|
104
|
-
/* @__PURE__ */ 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
|
-
};
|
|
6
|
+
${c.popupContainer}
|
|
7
|
+
${e?.type?c.withOptions:""}
|
|
8
|
+
${o==="horizontal"?c.horizontal:""}
|
|
9
|
+
`,children:[r("div",{className:c.closeButton,style:E??{},onClick:N,children:r(F,{color:"#131314"})}),(e?.title||e?.description||e?.type)&&t("div",{className:`${c.popupHeader}`,style:h??{},children:[n()&&r("div",{className:c.typeIcon,children:r("div",{style:{backgroundColor:e?.type==="success"?"#DCFAE6":e?.type==="unsaved"?"#FEF0C7":"#FEE4E2"},className:c.icon,children:n()})}),e&&e?.title&&r("div",{className:c.popupTitle,children:t("h2",{style:v??{},children:[" ",e?.title??""," "]})}),e&&e?.description&&r("div",{className:c.popupDescription,children:t("p",{children:[" ",e?.description??""," "]})})]}),t("div",{className:c.templateWrapper,style:y??{},children:[i&&i,s&&s]})]})})};export{P as default};
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
const
|
|
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
|
-
};
|
|
1
|
+
const p="Popup-module__modalOverlay",o="Popup-module__popupDrawerMode",e="Popup-module__popupContainer",t="Popup-module__closeButton",u="Popup-module__withOptions",n="Popup-module__horizontal",l="Popup-module__popupHeader",r="Popup-module__popupTitle",a="Popup-module__popupDescription",c="Popup-module__typeIcon",i="Popup-module__icon",s="Popup-module__templateWrapper",_={modalOverlay:p,popupDrawerMode:o,popupContainer:e,closeButton:t,withOptions:u,horizontal:n,popupHeader:l,popupTitle:r,popupDescription:a,typeIcon:c,icon:i,templateWrapper:s};export{t as closeButton,_ as default,n as horizontal,i as icon,p as modalOverlay,e as popupContainer,a as popupDescription,o as popupDrawerMode,l as popupHeader,r as popupTitle,s as templateWrapper,c as typeIcon,u as withOptions};
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
import
|
|
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__ */ jsx(IconRadioCheckedDisabled, { color });
|
|
27
|
-
} else {
|
|
28
|
-
icon = /* @__PURE__ */ jsx(IconRadioChecked, { color });
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
if (disabled) {
|
|
32
|
-
icon = /* @__PURE__ */ jsx(IconRadioUncheckedDisabled, { color });
|
|
33
|
-
} else {
|
|
34
|
-
icon = /* @__PURE__ */ jsx(IconRadioUnchecked, { color });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return icon;
|
|
38
|
-
};
|
|
39
|
-
return /* @__PURE__ */ jsxs("div", { className: style.radioWrapper, style: { cursor: disabled ? "not-allowed" : "pointer" }, onClick: onChange, children: [
|
|
40
|
-
/* @__PURE__ */ 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
|
-
};
|
|
1
|
+
import{jsxs as m,jsx as r}from"react/jsx-runtime";import p from"./Radio.module.scss.js";import{useState as d}from"react";import{useNamespace as u}from"../../context/NamespaceContext.js";import{IconRadioCheckedDisabled as h}from"../../assets/Icons/IconRadioCheckedDisabled.js";import{IconRadioChecked as R}from"../../assets/Icons/IconRadioChecked.js";import{IconRadioUncheckedDisabled as k}from"../../assets/Icons/IconRadioUncheckedDisabled.js";import{IconRadioUnchecked as C}from"../../assets/Icons/IconRadioUnchecked.js";const v=({checked:i,change:n,disabled:e,required:a,withUncheckState:c=!1,radioType:l="default"})=>{u(),d(!1);const s=()=>{e||n?.(c?!i:!0)},f=()=>{let o=null,t=e?"#95969C":l==="error"?"#E3292F":"#0058FF";return i?e?o=r(h,{color:t}):o=r(R,{color:t}):e?o=r(k,{color:t}):o=r(C,{color:t}),o};return m("div",{className:p.radioWrapper,style:{cursor:e?"not-allowed":"pointer"},onClick:s,children:[r("input",{type:"radio",checked:!0,readOnly:!0,hidden:!0,disabled:e??!1,required:a}),f()]})};export{v as default};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import style from "./Skeleton.module.scss.js";
|
|
3
|
-
const Skeleton = ({ type = "text", customStyle, children }) => {
|
|
4
|
-
return /* @__PURE__ */ jsx("div", { style: customStyle ?? {}, className: ` ${style.skeleton} ${style[type] || ""}`, children });
|
|
5
|
-
};
|
|
6
|
-
export {
|
|
7
|
-
Skeleton as default
|
|
8
|
-
};
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import t from"./Skeleton.module.scss.js";const a=({type:e="text",customStyle:o,children:s})=>r("div",{style:o??{},className:` ${t.skeleton} ${t[e]||""}`,children:s});export{a as default};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
const
|
|
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
|
-
};
|
|
1
|
+
const e="Skeleton-module__skeleton",t="Skeleton-module__shimmer",o="Skeleton-module__text",l="Skeleton-module__avatar",a="Skeleton-module__dark",n={skeleton:e,shimmer:t,text:o,avatar:l,dark:a};export{l as avatar,a as dark,n as default,t as shimmer,e as skeleton,o as text};
|
|
@@ -1,149 +1 @@
|
|
|
1
|
-
import
|
|
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__ */ jsxs(
|
|
106
|
-
"div",
|
|
107
|
-
{
|
|
108
|
-
style: textareaContainerStyle ?? {},
|
|
109
|
-
className: `${style.textareaContainer} ${inputState.error ? style.error : ""} ${disabled ? style.disabled : null}`,
|
|
110
|
-
children: [
|
|
111
|
-
label && /* @__PURE__ */ jsxs("div", { style: textareaLabelStyle, className: style.textAreaLabel, children: [
|
|
112
|
-
/* @__PURE__ */ jsx("p", { children: label }),
|
|
113
|
-
/* @__PURE__ */ jsx("span", { style: requiredStyle ?? {}, className: style.required, children: required && "*" }),
|
|
114
|
-
labelSlot && iconSlot(labelSlot)
|
|
115
|
-
] }),
|
|
116
|
-
/* @__PURE__ */ jsxs("div", { className: `${style.wrap} ${withResize ? style.resize : ""}`, ref: TextareaRef, children: [
|
|
117
|
-
/* @__PURE__ */ 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__ */ jsx("div", { className: style.textareaIconClose, onClick: HandleClose, children: /* @__PURE__ */ jsx(IconCloseBackground, {}) })
|
|
137
|
-
] }),
|
|
138
|
-
/* @__PURE__ */ jsx("div", { style: textareaFooterStyle ?? {}, className: style.textareaFooter, children: /* @__PURE__ */ jsxs("p", { children: [
|
|
139
|
-
value?.length,
|
|
140
|
-
"/",
|
|
141
|
-
maxLength
|
|
142
|
-
] }) })
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
export {
|
|
148
|
-
Textarea as default
|
|
149
|
-
};
|
|
1
|
+
import{jsxs as a,jsx as n}from"react/jsx-runtime";import{useRef as G,useState as b,useEffect as w}from"react";import r from"./Textarea.module.scss.js";import{IconCloseBackground as J}from"../../assets/Icons/IconCloseBackground.js";const Z=({placeholder:z,label:h,cols:H=30,rows:M=5,value:l,inputState:c={error:!1,success:!0},maxLength:x=20,withFocus:k=!0,withActive:q=!0,withResize:A=!0,withClose:B=!0,onChange:s,onFocus:u,onBlur:f,disabled:d,required:F,textareaContainerStyle:I,textareaLabelStyle:L,requiredStyle:j,labelSlot:y,textareaFooterStyle:E})=>{const o=G(null),[p,$]=b(!1),[C,m]=b(!1),D=e=>{let t=e.target.value;s&&typeof s=="function"&&s(t)},O=e=>e,S=e=>{$(!0),u&&typeof u=="function"&&u(e)},T=e=>{$(!1),f&&typeof f=="function"&&f(e)};let i=!1;w(()=>{if(!o.current)return;const e=o.current.querySelector("textarea");if(!e)return;let t=!1;const v=N=>{const R=e.getBoundingClientRect();N.clientX>R.right-20&&N.clientY>R.bottom-20&&(t=!0)},g=new ResizeObserver(()=>{t&&(i=!0,t=!1)});return e.addEventListener("mousedown",v),g.observe(e),()=>{e.removeEventListener("mousedown",v),g.disconnect()}},[]);const U=()=>{if(!o.current)return;const e=o.current.querySelector("textarea");!e||i||(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)};w(()=>{if(!o.current)return;const e=o.current.querySelector("textarea"),t=new ResizeObserver(()=>{i=e.offsetHeight<e.scrollHeight});return t.observe(e),()=>t.disconnect()},[]);const X=e=>{i=!1,s?.(e.target.value),U()},Y=()=>{s&&typeof s=="function"&&s("")};return a("div",{style:I??{},className:`${r.textareaContainer} ${c.error?r.error:""} ${d?r.disabled:null}`,children:[h&&a("div",{style:L,className:r.textAreaLabel,children:[n("p",{children:h}),n("span",{style:j??{},className:r.required,children:F&&"*"}),y&&O(y)]}),a("div",{className:`${r.wrap} ${A?r.resize:""}`,ref:o,children:[n("textarea",{className:`${r.textarea} ${p?r.focused:""} ${d?r.disabled:""} ${k&&p?c.error?r.errorFocused:r.focused:""} ${q&&C?c.error?r.errorActive:r.active:""} ${c.error?r.error:""} ${c.success?r.success:""}`,value:l,placeholder:z??"",cols:H,rows:M,maxLength:x??void 0,onInput:X,onFocus:S,disabled:d,onBlur:T,onChange:D,onMouseDown:()=>m(!0),onMouseUp:()=>m(!1),onMouseLeave:()=>m(!1)}),B&&l&&n("div",{className:r.textareaIconClose,onClick:Y,children:n(J,{})})]}),n("div",{style:E??{},className:r.textareaFooter,children:a("p",{children:[l?.length,"/",x]})})]})};export{Z as default};
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
const
|
|
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
|
-
};
|
|
1
|
+
const e="Textarea-module__textareaContainer",t="Textarea-module__textAreaLabel",a="Textarea-module__required",r="Textarea-module__wrap",o="Textarea-module__resize",c="Textarea-module__textareaIconClose",x="Textarea-module__textarea",s="Textarea-module__focused",_="Textarea-module__active",d="Textarea-module__errorFocused",n="Textarea-module__errorActive",u="Textarea-module__textareaFooter",l={textareaContainer:e,textAreaLabel:t,required:a,wrap:r,resize:o,textareaIconClose:c,textarea:x,focused:s,active:_,errorFocused:d,errorActive:n,textareaFooter:u};export{_ as active,l as default,n as errorActive,d as errorFocused,s as focused,a as required,o as resize,t as textAreaLabel,x as textarea,e as textareaContainer,u as textareaFooter,c as textareaIconClose,r as wrap};
|
|
@@ -1,172 +1 @@
|
|
|
1
|
-
import
|
|
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__ */ jsxs("div", { className: `${style.timepickerWrapper} ${IsFocused ? style.focused : ""}`, children: [
|
|
105
|
-
/* @__PURE__ */ jsx("div", { ref: ComponentRef, className: style.timepickerInputWrapper, onClick: () => (setIsFocused((state) => !state), CalculatePos()), onFocus: Focus, children: /* @__PURE__ */ 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__ */ jsxs("div", { className: `${style.dropdownRightIcon} ${IsFocused ? style.focused : ""}`, children: [
|
|
116
|
-
Value && /* @__PURE__ */ jsx(
|
|
117
|
-
"div",
|
|
118
|
-
{
|
|
119
|
-
onClick: (e) => {
|
|
120
|
-
e.stopPropagation();
|
|
121
|
-
Clear();
|
|
122
|
-
},
|
|
123
|
-
className: style.dropdownRightIconClose,
|
|
124
|
-
children: /* @__PURE__ */ jsx(IconCloseCircle, {})
|
|
125
|
-
}
|
|
126
|
-
),
|
|
127
|
-
/* @__PURE__ */ jsx("div", { className: style.dropdownRightIconArrow, children: /* @__PURE__ */ jsx(IconArrowUp, {}) })
|
|
128
|
-
] }),
|
|
129
|
-
readOnly: true,
|
|
130
|
-
forDropdown: true
|
|
131
|
-
}
|
|
132
|
-
) }),
|
|
133
|
-
IsFocused && /* @__PURE__ */ jsxs("div", { ref: DropdownRef, className: style.timepickerDropdownWrapper, children: [
|
|
134
|
-
/* @__PURE__ */ jsx("div", { className: style.timepickerDropdownHeader, children: /* @__PURE__ */ jsxs("div", { className: style.timepickerDropdownHeaderButtons, children: [
|
|
135
|
-
/* @__PURE__ */ 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__ */ 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__ */ jsxs("div", { className: style.timepickerDropdownBody, children: [
|
|
159
|
-
/* @__PURE__ */ jsx("div", { className: style.timepickerDropdownBodyHours, children: (TimeType === "12" ? hours12 : hours24).map((hour) => /* @__PURE__ */ jsx("p", { className: Hours === hour || Value?.split(":")[0] === hour ? style.active : "", onClick: () => setHours(hour), children: hour }, hour)) }),
|
|
160
|
-
/* @__PURE__ */ jsx("div", { className: style.timepickerDropdownBodyMinutes, children: minutes.map((minute) => /* @__PURE__ */ jsx("p", { className: Minutes === minute || Value?.split(":")[1] === minute ? style.active : "", onClick: () => setMinutes(minute), children: minute }, minute)) }),
|
|
161
|
-
TimeType === "12" && /* @__PURE__ */ jsxs("div", { className: style.timepickerDropdownBodyAmPm, children: [
|
|
162
|
-
/* @__PURE__ */ jsx("p", { className: AmPm === "AM" ? style.active : "", onClick: () => setAmPm("AM"), children: "AM" }, "AM"),
|
|
163
|
-
/* @__PURE__ */ jsx("p", { className: AmPm === "PM" ? style.active : "", onClick: () => setAmPm("PM"), children: "PM" }, "PM")
|
|
164
|
-
] })
|
|
165
|
-
] }),
|
|
166
|
-
withConfirm && /* @__PURE__ */ jsx("div", { className: style.timepickerDropdownFooter, children: /* @__PURE__ */ jsx(MainButton, { label: "Confirm time", onClick: () => onChange?.(Value) }) })
|
|
167
|
-
] })
|
|
168
|
-
] });
|
|
169
|
-
};
|
|
170
|
-
export {
|
|
171
|
-
TimePicker as default
|
|
172
|
-
};
|
|
1
|
+
import{jsxs as l,jsx as r}from"react/jsx-runtime";import{useRef as A,useState as m,useEffect as u}from"react";import o from"./TimePicker.module.scss.js";import _ from"../FormInput/FormInput.js";import{IconArrowUp as x}from"../../assets/Icons/IconArrowUp.js";import{IconCloseCircle as O}from"../../assets/Icons/IconCloseCircle.js";import V from"../../node_modules/dayjs/plugin/customParseFormat.js";import F from"dayjs";import Y from"../MainButton/MainButton.js";F.extend(V);const te=({value:f,defaultTimeType:R="24",defaultAmPm:B="AM",withConfirm:M=!0,mode:U="single",onChange:C,onFocus:E,onBlur:T,...b})=>{const i=A(null),a=A(null),[s,h]=m(!1),[c,H]=m(R),j=Array.from({length:12},(e,t)=>t<10?`0${t}`:`${t}`),L=Array.from({length:24},(e,t)=>t<10?`0${t}`:`${t}`),S=Array.from({length:60},(e,t)=>t<10?`0${t}`:`${t}`),[d,g]=m(""),[w,P]=m(null),[v,I]=m(null),[p,y]=m(B),$=()=>{const e=i.current,t=a.current;if(!t||!e)return;const n=e.getBoundingClientRect(),k=window.innerHeight;t.style.position="fixed",t.style.left=`${n.left+window.pageXOffset}px`,n.bottom+t.offsetHeight>k?(t.style.top=`${window.scrollY+n.top-t.offsetHeight+18}px`,t.style.bottom="unset"):(t.style.top=`${window.scrollY+n.bottom+8}px`,t.style.bottom="unset")},W=()=>{E?.()},N=()=>{g(""),I(null),P(null),y("AM")};u(()=>{f&&f.length>0&&g(f)},[f]),u(()=>{if(!v&&!w)return;const e=parseInt(v??"0",10),t=parseInt(w??"0",10),n=c==="12"?p==="PM"&&e<12?e+12:p==="AM"&&e===12?0:e:e,k=F().hour(n).minute(t).format(c==="12"?"hh:mm A":"HH:mm");g(k),M||C?.(k)},[v,w,p,c]);const D=A(!0);return u(()=>{if(D.current){D.current=!1;return}s||T?.()},[s]),u(()=>{$()},[i,s]),u(()=>{const e=n=>{!i.current||!a.current||n.composedPath().includes(i.current)||n.composedPath().includes(a.current)||h(!1)},t=n=>{!i.current||a.current||h(!1)};return document.addEventListener("click",e),document.addEventListener("wheel",t),()=>{document.removeEventListener("click",e),document.removeEventListener("wheel",t)}},[]),l("div",{className:`${o.timepickerWrapper} ${s?o.focused:""}`,children:[r("div",{ref:i,className:o.timepickerInputWrapper,onClick:()=>(h(e=>!e),$()),onFocus:W,children:r(_,{...b,onFocusChange:e=>h(e),customFocus:s,withActive:!1,value:d,toggleFocus:!0,formInputStyle:{cursor:"pointer"},rightSlot:l("div",{className:`${o.dropdownRightIcon} ${s?o.focused:""}`,children:[d&&r("div",{onClick:e=>{e.stopPropagation(),N()},className:o.dropdownRightIconClose,children:r(O,{})}),r("div",{className:o.dropdownRightIconArrow,children:r(x,{})})]}),readOnly:!0,forDropdown:!0})}),s&&l("div",{ref:a,className:o.timepickerDropdownWrapper,children:[r("div",{className:o.timepickerDropdownHeader,children:l("div",{className:o.timepickerDropdownHeaderButtons,children:[r("p",{className:c==="12"?o.active:"",onClick:()=>{N(),H("12")},children:"AM -PM"}),r("p",{className:c==="24"?o.active:"",onClick:()=>{N(),H("24")},children:"24 Hours"})]})}),l("div",{className:o.timepickerDropdownBody,children:[r("div",{className:o.timepickerDropdownBodyHours,children:(c==="12"?j:L).map(e=>r("p",{className:v===e||d?.split(":")[0]===e?o.active:"",onClick:()=>I(e),children:e},e))}),r("div",{className:o.timepickerDropdownBodyMinutes,children:S.map(e=>r("p",{className:w===e||d?.split(":")[1]===e?o.active:"",onClick:()=>P(e),children:e},e))}),c==="12"&&l("div",{className:o.timepickerDropdownBodyAmPm,children:[r("p",{className:p==="AM"?o.active:"",onClick:()=>y("AM"),children:"AM"},"AM"),r("p",{className:p==="PM"?o.active:"",onClick:()=>y("PM"),children:"PM"},"PM")]})]}),M&&r("div",{className:o.timepickerDropdownFooter,children:r(Y,{label:"Confirm time",onClick:()=>C?.(d)})})]})]})};export{te as default};
|