@weing-dev/ui-kit-primitive 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/eslint.config.js +29 -0
- package/index.html +13 -0
- package/package.json +75 -0
- package/public/static/icon/Add.svg +1 -0
- package/public/static/icon/ApprovalInactive.svg +1 -0
- package/public/static/icon/ArrowRight.svg +5 -0
- package/public/static/icon/Cancle Filled.svg +1 -0
- package/public/static/icon/Cancle.svg +1 -0
- package/public/static/icon/Cart Filled.svg +1 -0
- package/public/static/icon/Cart.svg +1 -0
- package/public/static/icon/Check.svg +1 -0
- package/public/static/icon/CheckBoxRound.svg +3 -0
- package/public/static/icon/Company.svg +1 -0
- package/public/static/icon/DragHandle.svg +1 -0
- package/public/static/icon/Eco.svg +1 -0
- package/public/static/icon/EditSquare.svg +1 -0
- package/public/static/icon/Error Filled.svg +1 -0
- package/public/static/icon/Error.svg +1 -0
- package/public/static/icon/File Upload.svg +1 -0
- package/public/static/icon/FilecheckInactive.svg +1 -0
- package/public/static/icon/Go Before.svg +1 -0
- package/public/static/icon/Go Next.svg +1 -0
- package/public/static/icon/Hamburger Menu.svg +1 -0
- package/public/static/icon/ImagecheckPlay.svg +4 -0
- package/public/static/icon/Kakao Talk.svg +1 -0
- package/public/static/icon/Minus.svg +1 -0
- package/public/static/icon/Naver Blog.svg +1 -0
- package/public/static/icon/Naver.svg +1 -0
- package/public/static/icon/OrderApprove.svg +1 -0
- package/public/static/icon/OrderInactive.svg +1 -0
- package/public/static/icon/OrderPlay.svg +1 -0
- package/public/static/icon/PayApprove.svg +1 -0
- package/public/static/icon/PayInactive.svg +1 -0
- package/public/static/icon/PrintInactive.svg +1 -0
- package/public/static/icon/PrintPlay.svg +1 -0
- package/public/static/icon/Search.svg +1 -0
- package/public/static/icon/ShippingDone.svg +1 -0
- package/public/static/icon/Support Agent.svg +1 -0
- package/public/static/icon/Task.svg +1 -0
- package/public/static/icon/User.svg +1 -0
- package/public/static/icon/Warning Filled.svg +1 -0
- package/public/static/icon/Warning.svg +1 -0
- package/public/static/icon/add_a_photo.svg +3 -0
- package/public/static/icon/attach_file.svg +1 -0
- package/public/static/icon/check_circle.svg +1 -0
- package/public/static/icon/close.svg +1 -0
- package/public/static/icon/download.svg +1 -0
- package/public/static/icon/expand all.svg +1 -0
- package/public/static/icon/expand_less.svg +1 -0
- package/public/static/icon/expand_more.svg +1 -0
- package/public/static/icon/factory.svg +1 -0
- package/public/static/icon/inventory.svg +1 -0
- package/public/static/icon/listAll.svg +1 -0
- package/public/static/icon/local_shipping.svg +1 -0
- package/public/static/icon/logout.svg +1 -0
- package/public/static/icon/menu.svg +1 -0
- package/public/static/icon/mode_edit.svg +4 -0
- package/public/static/icon/more.svg +1 -0
- package/public/static/icon/outward.svg +1 -0
- package/public/static/icon/personcard.svg +1 -0
- package/public/static/icon/product.svg +1 -0
- package/public/static/icon/settings.svg +1 -0
- package/public/static/icon/swap_vert.svg +3 -0
- package/public/static/icon/upload.svg +1 -0
- package/public/static/icon/warning_amber.svg +3 -0
- package/public/static/image/Thumbnail.png +0 -0
- package/public/vite.svg +1 -0
- package/public/weing_logo_final.png +0 -0
- package/scripts/icons/setIcon.cjs +151 -0
- package/scripts/icons/svg-template.cjs +18 -0
- package/scripts/icons/svgo-config.json +9 -0
- package/scripts/icons/svgr-config.json +16 -0
- package/src/@types/color.d.ts +51 -0
- package/src/@types/common.d.ts +6 -0
- package/src/@types/extends/react.extends.d.ts +7 -0
- package/src/@types/quill-image-resize-module-react/index.d.ts +1 -0
- package/src/App.css +0 -0
- package/src/App.tsx +84 -0
- package/src/assets/react.svg +1 -0
- package/src/components/Accordion/Accordion.context.tsx +62 -0
- package/src/components/Accordion/Accordion.module.scss +163 -0
- package/src/components/Accordion/Accordion.tsx +242 -0
- package/src/components/Accordion/README.md +408 -0
- package/src/components/Accordion/images/as_trigger.gif +0 -0
- package/src/components/Accordion/images/closed.png +0 -0
- package/src/components/Accordion/images/open.png +0 -0
- package/src/components/Accordion/images/thumbnail1.png +0 -0
- package/src/components/Accordion/images/thumbnail2.png +0 -0
- package/src/components/Accordion/images/thumbnail3.png +0 -0
- package/src/components/Avatar/Avatar.module.scss +47 -0
- package/src/components/Avatar/Avatar.tsx +230 -0
- package/src/components/Avatar/README.md +333 -0
- package/src/components/Badge/Badge.module.scss +49 -0
- package/src/components/Badge/Badge.tsx +87 -0
- package/src/components/Badge/README.md +223 -0
- package/src/components/BarCode/BarCode.module.scss +0 -0
- package/src/components/BarCode/BarCode.tsx +153 -0
- package/src/components/Breadcrumb/Breadcrumb.module.scss +36 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +114 -0
- package/src/components/Breadcrumb/README.md +339 -0
- package/src/components/Button/Button.colors.tsx +322 -0
- package/src/components/Button/Button.context.tsx +47 -0
- package/src/components/Button/Button.module.scss +156 -0
- package/src/components/Button/Button.tsx +190 -0
- package/src/components/Button/Button.type.ts +11 -0
- package/src/components/Calendar/Calendar.context.tsx +138 -0
- package/src/components/Calendar/Calendar.module.scss +116 -0
- package/src/components/Calendar/Calendar.tsx +440 -0
- package/src/components/Calendar/dayjs.util.ts +312 -0
- package/src/components/Cascader/Cacader.data.ts +1185 -0
- package/src/components/Cascader/Cascader.context.tsx +61 -0
- package/src/components/Cascader/Cascader.hook.ts +502 -0
- package/src/components/Cascader/Cascader.module.scss +143 -0
- package/src/components/Cascader/Cascader.tsx +281 -0
- package/src/components/Cascader/README.md +735 -0
- package/src/components/Chart/Chart.module.scss +0 -0
- package/src/components/Chart/Chart.tsx +230 -0
- package/src/components/Chart/README.md +85 -0
- package/src/components/Chart/images/barChart.png +0 -0
- package/src/components/Chips/Chips.colors.tsx +185 -0
- package/src/components/Chips/Chips.module.scss +49 -0
- package/src/components/Chips/Chips.tsx +78 -0
- package/src/components/Comment/Comment.module.scss +14 -0
- package/src/components/Comment/Comment.tsx +105 -0
- package/src/components/Dialog/Dialog.module.scss +0 -0
- package/src/components/Dialog/Dialog.tsx +12 -0
- package/src/components/Divider/Divider.module.scss +12 -0
- package/src/components/Divider/Divider.tsx +33 -0
- package/src/components/Editor/Editor.context.tsx +12 -0
- package/src/components/Editor/Editor.module.scss +40 -0
- package/src/components/Editor/Editor.tsx +174 -0
- package/src/components/Form/CheckBox/CheckBox.context.tsx +56 -0
- package/src/components/Form/CheckBox/CheckBox.module.scss +81 -0
- package/src/components/Form/CheckBox/CheckBox.tsx +196 -0
- package/src/components/Form/CheckBox/Checkbox.colors.tsx +42 -0
- package/src/components/Form/Dropdown/Dropdown.colors.tsx +125 -0
- package/src/components/Form/Dropdown/Dropdown.context.tsx +62 -0
- package/src/components/Form/Dropdown/Dropdown.module.scss +133 -0
- package/src/components/Form/Dropdown/Dropdown.tsx +404 -0
- package/src/components/Form/OTPInput/OTPInput.context.tsx +104 -0
- package/src/components/Form/OTPInput/OTPInput.module.scss +22 -0
- package/src/components/Form/OTPInput/OTPInput.tsx +67 -0
- package/src/components/Form/Radio/Radio.colors.tsx +42 -0
- package/src/components/Form/Radio/Radio.context.tsx +40 -0
- package/src/components/Form/Radio/Radio.module.scss +61 -0
- package/src/components/Form/Radio/Radio.tsx +174 -0
- package/src/components/Form/Switch/Switch.colors.tsx +42 -0
- package/src/components/Form/Switch/Switch.context.tsx +50 -0
- package/src/components/Form/Switch/Switch.module.scss +53 -0
- package/src/components/Form/Switch/Switch.tsx +151 -0
- package/src/components/Form/TextArea/TextArea.colors.tsx +76 -0
- package/src/components/Form/TextArea/TextArea.context.tsx +97 -0
- package/src/components/Form/TextArea/TextArea.module.scss +138 -0
- package/src/components/Form/TextArea/TextArea.tsx +246 -0
- package/src/components/Form/TextInput/TextInput.colors.tsx +76 -0
- package/src/components/Form/TextInput/TextInput.context.tsx +106 -0
- package/src/components/Form/TextInput/TextInput.module.scss +160 -0
- package/src/components/Form/TextInput/TextInput.tsx +225 -0
- package/src/components/GlobalStyle/GlobalStyle.tsx +20 -0
- package/src/components/HelperText/HelperText.module.scss +28 -0
- package/src/components/HelperText/HelperText.tsx +130 -0
- package/src/components/Icon/Icon.tsx +29 -0
- package/src/components/Icons/Add.tsx +20 -0
- package/src/components/Icons/AddAPhoto.tsx +21 -0
- package/src/components/Icons/ApprovalInactive.tsx +26 -0
- package/src/components/Icons/ArrowRight.tsx +24 -0
- package/src/components/Icons/AttachFile.tsx +20 -0
- package/src/components/Icons/Cancle.tsx +20 -0
- package/src/components/Icons/CancleFilled.tsx +20 -0
- package/src/components/Icons/Cart.tsx +20 -0
- package/src/components/Icons/CartFilled.tsx +20 -0
- package/src/components/Icons/Check.tsx +20 -0
- package/src/components/Icons/CheckBoxRound.tsx +21 -0
- package/src/components/Icons/CheckCircle.tsx +35 -0
- package/src/components/Icons/Close.tsx +20 -0
- package/src/components/Icons/Company.tsx +20 -0
- package/src/components/Icons/Download.tsx +20 -0
- package/src/components/Icons/DragHandle.tsx +20 -0
- package/src/components/Icons/Eco.tsx +20 -0
- package/src/components/Icons/EditSquare.tsx +20 -0
- package/src/components/Icons/Error.tsx +20 -0
- package/src/components/Icons/ErrorFilled.tsx +20 -0
- package/src/components/Icons/ExpandAll.tsx +20 -0
- package/src/components/Icons/ExpandLess.tsx +20 -0
- package/src/components/Icons/ExpandMore.tsx +20 -0
- package/src/components/Icons/Factory.tsx +20 -0
- package/src/components/Icons/FileUpload.tsx +20 -0
- package/src/components/Icons/FilecheckInactive.tsx +22 -0
- package/src/components/Icons/GoBefore.tsx +20 -0
- package/src/components/Icons/GoNext.tsx +20 -0
- package/src/components/Icons/HamburgerMenu.tsx +20 -0
- package/src/components/Icons/ImagecheckPlay.tsx +27 -0
- package/src/components/Icons/Inventory.tsx +20 -0
- package/src/components/Icons/KakaoTalk.tsx +22 -0
- package/src/components/Icons/ListAll.tsx +20 -0
- package/src/components/Icons/LocalShipping.tsx +20 -0
- package/src/components/Icons/Logout.tsx +20 -0
- package/src/components/Icons/Menu.tsx +20 -0
- package/src/components/Icons/Minus.tsx +18 -0
- package/src/components/Icons/ModeEdit.tsx +25 -0
- package/src/components/Icons/More.tsx +20 -0
- package/src/components/Icons/Naver.tsx +20 -0
- package/src/components/Icons/NaverBlog.tsx +22 -0
- package/src/components/Icons/OrderApprove.tsx +20 -0
- package/src/components/Icons/OrderInactive.tsx +20 -0
- package/src/components/Icons/OrderPlay.tsx +20 -0
- package/src/components/Icons/Outward.tsx +20 -0
- package/src/components/Icons/PayApprove.tsx +24 -0
- package/src/components/Icons/PayInactive.tsx +24 -0
- package/src/components/Icons/Personcard.tsx +20 -0
- package/src/components/Icons/PrintInactive.tsx +24 -0
- package/src/components/Icons/PrintPlay.tsx +24 -0
- package/src/components/Icons/Product.tsx +20 -0
- package/src/components/Icons/Search.tsx +20 -0
- package/src/components/Icons/Settings.tsx +20 -0
- package/src/components/Icons/ShippingDone.tsx +20 -0
- package/src/components/Icons/SupportAgent.tsx +20 -0
- package/src/components/Icons/SwapVert.tsx +21 -0
- package/src/components/Icons/Task.tsx +20 -0
- package/src/components/Icons/Upload.tsx +20 -0
- package/src/components/Icons/User.tsx +20 -0
- package/src/components/Icons/Warning.tsx +20 -0
- package/src/components/Icons/WarningAmber.tsx +21 -0
- package/src/components/Icons/WarningFilled.tsx +20 -0
- package/src/components/Icons/index.ts +62 -0
- package/src/components/LNB/LNB.context.tsx +32 -0
- package/src/components/LNB/LNB.module.scss +99 -0
- package/src/components/LNB/LNB.tsx +190 -0
- package/src/components/LNB/README.md +411 -0
- package/src/components/LNB/makeNavigation.ts +51 -0
- package/src/components/LNB/navigation.d.ts +15 -0
- package/src/components/LNB/navigation.json +211 -0
- package/src/components/Label/Label.colors.tsx +241 -0
- package/src/components/Label/Label.module.scss +31 -0
- package/src/components/Label/Label.tsx +54 -0
- package/src/components/LazyImage/LazyImage.module.scss +6 -0
- package/src/components/LazyImage/LazyImage.tsx +107 -0
- package/src/components/List/List.module.scss +81 -0
- package/src/components/List/List.tsx +91 -0
- package/src/components/List/README.md +87 -0
- package/src/components/MobilePicker/MobilePicker.context.tsx +22 -0
- package/src/components/MobilePicker/MobilePicker.module.scss +57 -0
- package/src/components/MobilePicker/MobilePicker.tsx +336 -0
- package/src/components/MobilePicker/README.md +159 -0
- package/src/components/Modal/Modal.tsx +77 -0
- package/src/components/Modal/README.md +130 -0
- package/src/components/Pagination/Pagination.colors.tsx +85 -0
- package/src/components/Pagination/Pagination.context.tsx +28 -0
- package/src/components/Pagination/Pagination.module.scss +60 -0
- package/src/components/Pagination/Pagination.tsx +234 -0
- package/src/components/Popup/Popup.context.tsx +15 -0
- package/src/components/Popup/Popup.module.scss +53 -0
- package/src/components/Popup/Popup.tsx +116 -0
- package/src/components/Popup/README.md +170 -0
- package/src/components/QRCode/QRCode.module.scss +2 -0
- package/src/components/QRCode/QRCode.tsx +61 -0
- package/src/components/ScrollCalendar/ScrollCalendar.context.tsx +26 -0
- package/src/components/ScrollCalendar/ScrollCalendar.module.scss +42 -0
- package/src/components/ScrollCalendar/ScrollCalendar.tsx +448 -0
- package/src/components/ScrollSpy/README.md +62 -0
- package/src/components/ScrollSpy/ScrollSpy.tsx +130 -0
- package/src/components/Sheet/README.md +92 -0
- package/src/components/Sheet/Sheet.context.tsx +23 -0
- package/src/components/Sheet/Sheet.module.scss +68 -0
- package/src/components/Sheet/Sheet.tsx +146 -0
- package/src/components/Slider/README.md +639 -0
- package/src/components/Slider/Slider.backup.tsx +477 -0
- package/src/components/Slider/Slider.context.tsx +67 -0
- package/src/components/Slider/Slider.module.scss +123 -0
- package/src/components/Slider/Slider.tsx +467 -0
- package/src/components/Stepper/README.md +320 -0
- package/src/components/Stepper/Stepper.context.tsx +49 -0
- package/src/components/Stepper/Stepper.module.scss +163 -0
- package/src/components/Stepper/Stepper.tsx +219 -0
- package/src/components/Tab/Tab.colors.tsx +54 -0
- package/src/components/Tab/Tab.context.tsx +64 -0
- package/src/components/Tab/Tab.module.scss +239 -0
- package/src/components/Tab/Tab.tsx +123 -0
- package/src/components/Tab/cx.ts +6 -0
- package/src/components/Table/README.md +162 -0
- package/src/components/Table/Table.context.tsx +23 -0
- package/src/components/Table/Table.hook.ts +51 -0
- package/src/components/Table/Table.module.scss +83 -0
- package/src/components/Table/Table.tsx +147 -0
- package/src/components/Thumbnail/README.md +302 -0
- package/src/components/Thumbnail/Thumbnail.context.tsx +42 -0
- package/src/components/Thumbnail/Thumbnail.module.scss +149 -0
- package/src/components/Thumbnail/Thumbnail.tsx +391 -0
- package/src/components/TimeInput/README.md +118 -0
- package/src/components/TimeInput/TimeInput.colors.tsx +76 -0
- package/src/components/TimeInput/TimeInput.context.tsx +58 -0
- package/src/components/TimeInput/TimeInput.module.scss +211 -0
- package/src/components/TimeInput/TimeInput.tsx +411 -0
- package/src/components/WeeklyCalendar/WeeklyCalendar.context.tsx +88 -0
- package/src/components/WeeklyCalendar/WeeklyCalendar.module.scss +225 -0
- package/src/components/WeeklyCalendar/WeeklyCalendar.tsx +772 -0
- package/src/components/WeeklyCalendar/dayjs.util.ts +336 -0
- package/src/components/WeeklyCalendar/weeklyCalendar.util.ts +583 -0
- package/src/components/WisywygEditor/Quill/Editor.tsx +148 -0
- package/src/constant/locale.constant.ts +6 -0
- package/src/globals.scss +80 -0
- package/src/hooks/useColorScheme.tsx +48 -0
- package/src/hooks/useElementRect.tsx +128 -0
- package/src/hooks/useIntersectionObserver.tsx +33 -0
- package/src/index.css +17 -0
- package/src/index.ts +187 -0
- package/src/main.tsx +10 -0
- package/src/styles/_fontSize.mixin.scss +57 -0
- package/src/styles/_fontWeight.mixin.scss +15 -0
- package/src/styles/_lineHeight.mixin.scss +57 -0
- package/src/styles/_scrollbar.mixin.scss +49 -0
- package/src/styles/baseColor.ts +297 -0
- package/src/styles/color.ts +272 -0
- package/src/styles/color2.ts +200 -0
- package/src/styles/scrollbar.README.md +72 -0
- package/src/styles/typography.scss +170 -0
- package/src/utils/aws.util.ts +180 -0
- package/src/utils/common.utill.ts +45 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +24 -0
- package/tsconfig.json +29 -0
- package/tsconfig.node.json +10 -0
- package/tsconfig.node.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.d.ts +2 -0
- package/vite.config.js +47 -0
- package/vite.config.ts +50 -0
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
"use client";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import styles from "./WeeklyCalendar.module.scss";
|
|
5
|
+
import cn from "classnames/bind";
|
|
6
|
+
import { DndContext, useDraggable, useDroppable } from "@dnd-kit/core";
|
|
7
|
+
import {
|
|
8
|
+
type EventItem as EventItemType,
|
|
9
|
+
initialState,
|
|
10
|
+
WeeklyCalendarContext,
|
|
11
|
+
WeeklyCalendarProviderProps,
|
|
12
|
+
} from "./WeeklyCalendar.context";
|
|
13
|
+
import { getDayText, getGmtString } from "./dayjs.util";
|
|
14
|
+
import dayjs from "dayjs";
|
|
15
|
+
import {
|
|
16
|
+
getNearestStepTime,
|
|
17
|
+
layoutEventsWithColumns,
|
|
18
|
+
splitEventsConsideringAllDay,
|
|
19
|
+
} from "./weeklyCalendar.util";
|
|
20
|
+
import minmax from "dayjs/plugin/minMax";
|
|
21
|
+
import { usePopper } from "react-popper";
|
|
22
|
+
|
|
23
|
+
dayjs.extend(minmax);
|
|
24
|
+
|
|
25
|
+
const cx = cn.bind(styles);
|
|
26
|
+
|
|
27
|
+
type DateColumnRowProps = {
|
|
28
|
+
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type EventItemProps = React.PropsWithChildren<{
|
|
32
|
+
startTime: string;
|
|
33
|
+
endTime?: string;
|
|
34
|
+
id: string;
|
|
35
|
+
height: string | number;
|
|
36
|
+
widthPercent: number;
|
|
37
|
+
leftPercent: number;
|
|
38
|
+
topPercent: number;
|
|
39
|
+
title: string;
|
|
40
|
+
realStartTime?: string;
|
|
41
|
+
realEndTime?: string;
|
|
42
|
+
}>;
|
|
43
|
+
|
|
44
|
+
const EventItem = (props: EventItemProps) => {
|
|
45
|
+
const {
|
|
46
|
+
id,
|
|
47
|
+
height,
|
|
48
|
+
widthPercent,
|
|
49
|
+
leftPercent,
|
|
50
|
+
topPercent,
|
|
51
|
+
title,
|
|
52
|
+
realStartTime,
|
|
53
|
+
realEndTime,
|
|
54
|
+
} = props;
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
currentDate,
|
|
58
|
+
columnCount,
|
|
59
|
+
enableMoveByDrag,
|
|
60
|
+
popperHideDelay,
|
|
61
|
+
popperOffset,
|
|
62
|
+
eventItemAs,
|
|
63
|
+
eventItemPopperAs,
|
|
64
|
+
} = React.useContext(WeeklyCalendarContext);
|
|
65
|
+
|
|
66
|
+
const {
|
|
67
|
+
setNodeRef,
|
|
68
|
+
listeners,
|
|
69
|
+
attributes: dragAttributes,
|
|
70
|
+
transform,
|
|
71
|
+
active,
|
|
72
|
+
} = useDraggable({
|
|
73
|
+
id,
|
|
74
|
+
data: {
|
|
75
|
+
supports: new Array(columnCount).fill(0).map((_, i) => {
|
|
76
|
+
return dayjs(currentDate).add(i, "day").format("YYYY-MM-DD");
|
|
77
|
+
}),
|
|
78
|
+
attributes: {
|
|
79
|
+
"data-id": id,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// (1) popper 참조 관리
|
|
85
|
+
const [referenceElement, setReferenceElement] =
|
|
86
|
+
React.useState<HTMLElement | null>(null);
|
|
87
|
+
const [popperElement, setPopperElement] =
|
|
88
|
+
React.useState<HTMLDivElement | null>(null);
|
|
89
|
+
const [arrowElement, setArrowElement] = React.useState<HTMLDivElement | null>(
|
|
90
|
+
null
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// (2) hover 상태 -> 툴팁 표시 여부 상태로 변경
|
|
94
|
+
const [showPopper, setShowPopper] = React.useState(false);
|
|
95
|
+
// 타이머 ID를 저장하기 위한 ref
|
|
96
|
+
const hidePopperTimeoutRef = React.useRef<number | null>(null);
|
|
97
|
+
|
|
98
|
+
// (3) Popper 설정
|
|
99
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
100
|
+
placement: "auto", // \`)
|
|
101
|
+
modifiers: [
|
|
102
|
+
{ name: "arrow", options: { element: arrowElement } },
|
|
103
|
+
{ name: "offset", options: { offset: popperOffset } }, // y축으로 8px 정도 띄움
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const isSame = active?.id === id;
|
|
108
|
+
|
|
109
|
+
// 툴팁을 보여주는 함수
|
|
110
|
+
const handleShowPopper = React.useCallback(() => {
|
|
111
|
+
if (hidePopperTimeoutRef.current) {
|
|
112
|
+
clearTimeout(hidePopperTimeoutRef.current);
|
|
113
|
+
hidePopperTimeoutRef.current = null;
|
|
114
|
+
}
|
|
115
|
+
setShowPopper(true);
|
|
116
|
+
}, []);
|
|
117
|
+
|
|
118
|
+
// 툴팁을 숨기는 함수 (지연 시간 적용)
|
|
119
|
+
const handleHidePopper = React.useCallback(() => {
|
|
120
|
+
hidePopperTimeoutRef.current = window.setTimeout(() => {
|
|
121
|
+
setShowPopper(false);
|
|
122
|
+
}, popperHideDelay); // 200ms 지연. 이 시간을 조절하여 반응성을 변경할 수 있습니다.
|
|
123
|
+
}, [popperHideDelay]);
|
|
124
|
+
|
|
125
|
+
const eventItemRender = () => {
|
|
126
|
+
if (eventItemAs) {
|
|
127
|
+
return React.createElement(eventItemAs, {
|
|
128
|
+
key: id,
|
|
129
|
+
...props,
|
|
130
|
+
onMouseEnter: handleShowPopper, // 마우스가 참조 요소 위로 올라가면 툴팁 보이기
|
|
131
|
+
onMouseLeave: handleHidePopper, // 마우스가 참조 요소에서 벗어나면 툴팁 숨기기 (지연)
|
|
132
|
+
ref: setReferenceElement,
|
|
133
|
+
style: {
|
|
134
|
+
top: `${topPercent}%`,
|
|
135
|
+
height,
|
|
136
|
+
width: `min(${widthPercent}%, 100%)`,
|
|
137
|
+
left: `${leftPercent}%`,
|
|
138
|
+
color: "black",
|
|
139
|
+
overflow: "hidden",
|
|
140
|
+
alignSelf: "flex-start",
|
|
141
|
+
position: "absolute",
|
|
142
|
+
borderRadius: 4,
|
|
143
|
+
cursor: enableMoveByDrag ? "move" : "default",
|
|
144
|
+
transform:
|
|
145
|
+
enableMoveByDrag && transform
|
|
146
|
+
? `translate(${transform.x}px, ${transform.y}px)`
|
|
147
|
+
: undefined,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return null;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const eventItemPopperRender = () => {
|
|
156
|
+
if (eventItemPopperAs) {
|
|
157
|
+
// 커스텀 Popper 컴포넌트를 사용할 때, 해당 컴포넌트가 onMouseEnter와 onMouseLeave를
|
|
158
|
+
// 내부적으로 자신의 최상위 요소에 바인딩해야 합니다.
|
|
159
|
+
// 또한, 커스텀 컴포넌트의 최상위 요소는 pointerEvents가 'none'이 아니어야 합니다.
|
|
160
|
+
return React.createElement(eventItemPopperAs, {
|
|
161
|
+
...props,
|
|
162
|
+
popperRef: setPopperElement,
|
|
163
|
+
onMouseEnter: handleShowPopper, // 마우스가 커스텀 Popper 위로 올라가면 툴팁 보이기 (숨김 타이머 취소)
|
|
164
|
+
onMouseLeave: handleHidePopper, // 마우스가 커스텀 Popper에서 벗어나면 툴팁 숨기기 (지연)
|
|
165
|
+
popperStyle: {
|
|
166
|
+
...styles.popper,
|
|
167
|
+
// pointerEvents: "none", // 툴팁 자체는 클릭 막기 (원한다면) -> 마우스 이벤트 유지를 위해 제거 또는 주석 해제 필요
|
|
168
|
+
zIndex: 9999,
|
|
169
|
+
background: "#333", // 기본 스타일 예시, 커스텀 컴포넌트에서 재정의 가능
|
|
170
|
+
color: "#fff",
|
|
171
|
+
padding: "6px 8px",
|
|
172
|
+
borderRadius: 4,
|
|
173
|
+
fontSize: 12,
|
|
174
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
|
|
175
|
+
},
|
|
176
|
+
popperAttributes: {
|
|
177
|
+
...attributes.popper,
|
|
178
|
+
},
|
|
179
|
+
title,
|
|
180
|
+
realStartTime,
|
|
181
|
+
realEndTime,
|
|
182
|
+
arrowRef: setArrowElement,
|
|
183
|
+
arrowStyle: {
|
|
184
|
+
...styles.arrow,
|
|
185
|
+
width: "8px",
|
|
186
|
+
height: "8px",
|
|
187
|
+
transform: "rotate(90deg)",
|
|
188
|
+
},
|
|
189
|
+
arrowAttributes: {
|
|
190
|
+
...attributes.arrow,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return null;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<div
|
|
200
|
+
{...(enableMoveByDrag ? dragAttributes : {})}
|
|
201
|
+
{...(enableMoveByDrag ? listeners : {})}
|
|
202
|
+
ref={setNodeRef}
|
|
203
|
+
>
|
|
204
|
+
{eventItemAs ? (
|
|
205
|
+
eventItemRender()
|
|
206
|
+
) : (
|
|
207
|
+
<div
|
|
208
|
+
key={id}
|
|
209
|
+
data-id={id}
|
|
210
|
+
className={cx("EventItem", {
|
|
211
|
+
dragging: isSame && enableMoveByDrag,
|
|
212
|
+
draggable: enableMoveByDrag,
|
|
213
|
+
})}
|
|
214
|
+
ref={setReferenceElement} // Popper 참조 요소로 등록
|
|
215
|
+
style={{
|
|
216
|
+
top: `${topPercent}%`,
|
|
217
|
+
height,
|
|
218
|
+
width: `min(${widthPercent}%, 100%)`,
|
|
219
|
+
left: `${leftPercent}%`,
|
|
220
|
+
color: "white",
|
|
221
|
+
overflow: "hidden",
|
|
222
|
+
alignSelf: "flex-start",
|
|
223
|
+
position: "absolute",
|
|
224
|
+
borderRadius: 4,
|
|
225
|
+
border: "1px solid #ccc",
|
|
226
|
+
cursor: enableMoveByDrag ? "move" : "default",
|
|
227
|
+
transform:
|
|
228
|
+
enableMoveByDrag && transform
|
|
229
|
+
? `translate(${transform.x}px, ${transform.y}px)`
|
|
230
|
+
: undefined,
|
|
231
|
+
}}
|
|
232
|
+
onMouseEnter={handleShowPopper} // 마우스가 참조 요소 위로 올라가면 툴팁 보이기
|
|
233
|
+
onMouseLeave={handleHidePopper} // 마우스가 참조 요소에서 벗어나면 툴팁 숨기기 (지연)
|
|
234
|
+
onMouseDown={(e) => {
|
|
235
|
+
if (!enableMoveByDrag) return;
|
|
236
|
+
e.stopPropagation();
|
|
237
|
+
}}
|
|
238
|
+
onClick={(e) => {
|
|
239
|
+
e.stopPropagation();
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
{title}
|
|
243
|
+
</div>
|
|
244
|
+
)}
|
|
245
|
+
|
|
246
|
+
{!isSame &&
|
|
247
|
+
showPopper && // isHover 대신 showPopper 사용 -> showPopper 상태에 따라 툴팁 렌더링
|
|
248
|
+
(eventItemPopperAs ? (
|
|
249
|
+
eventItemPopperRender()
|
|
250
|
+
) : (
|
|
251
|
+
// 기본 Popper 렌더링
|
|
252
|
+
<div
|
|
253
|
+
ref={setPopperElement}
|
|
254
|
+
onMouseEnter={handleShowPopper} // 마우스가 기본 Popper 위로 올라가면 툴팁 보이기 (숨김 타이머 취소)
|
|
255
|
+
onMouseLeave={handleHidePopper} // 마우스가 기본 Popper에서 벗어나면 툴팁 숨기기 (지연)
|
|
256
|
+
style={{
|
|
257
|
+
...styles.popper,
|
|
258
|
+
// pointerEvents: "none", // 툴팁 자체는 클릭 막기 (원한다면) -> 이 줄이 있으면 Popper 위에서 마우스 이벤트 감지 안됨. 제거 또는 주석 처리.
|
|
259
|
+
// 사용자가 원한 동작을 위해서는 제거되어야 합니다.
|
|
260
|
+
zIndex: 9999,
|
|
261
|
+
background: "#333",
|
|
262
|
+
color: "#fff",
|
|
263
|
+
padding: "6px 8px",
|
|
264
|
+
borderRadius: 4,
|
|
265
|
+
fontSize: 12,
|
|
266
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
|
|
267
|
+
}}
|
|
268
|
+
{...attributes.popper}
|
|
269
|
+
>
|
|
270
|
+
{/* 툴팁 콘텐츠 예시 */}
|
|
271
|
+
<div style={{ whiteSpace: "nowrap" }}>
|
|
272
|
+
<div>
|
|
273
|
+
<strong>{title}</strong>
|
|
274
|
+
</div>
|
|
275
|
+
<div>
|
|
276
|
+
{dayjs(realStartTime).format("MM.DD HH:mm")}
|
|
277
|
+
{realEndTime &&
|
|
278
|
+
` ~ ${dayjs(realEndTime).format("MM.DD HH:mm")}`}
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
{/* 화살표 (Arrow) */}
|
|
282
|
+
<div
|
|
283
|
+
ref={setArrowElement}
|
|
284
|
+
style={{
|
|
285
|
+
...styles.arrow,
|
|
286
|
+
width: "8px",
|
|
287
|
+
height: "8px",
|
|
288
|
+
// background: "#333",
|
|
289
|
+
transform: "rotate(90deg)",
|
|
290
|
+
}}
|
|
291
|
+
{...attributes.arrow}
|
|
292
|
+
/>
|
|
293
|
+
</div>
|
|
294
|
+
))}
|
|
295
|
+
</div>
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
type DateColumnProps = {
|
|
300
|
+
date: string;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const DateColumn = (props: DateColumnProps) => {
|
|
304
|
+
const { date } = props;
|
|
305
|
+
const {
|
|
306
|
+
minHour,
|
|
307
|
+
maxHour,
|
|
308
|
+
step,
|
|
309
|
+
events = [],
|
|
310
|
+
enableCreateByDrag,
|
|
311
|
+
itemHeight = 48,
|
|
312
|
+
type = "default",
|
|
313
|
+
} = React.useContext(WeeklyCalendarContext);
|
|
314
|
+
|
|
315
|
+
const [col, setCol] = React.useState<HTMLDivElement | null>(null);
|
|
316
|
+
const [topValue, setTopValue] = React.useState<number | null>(null);
|
|
317
|
+
const { setNodeRef } = useDroppable({
|
|
318
|
+
id: date,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const results = layoutEventsWithColumns({
|
|
322
|
+
events: events.filter((event) => {
|
|
323
|
+
return (
|
|
324
|
+
!event.isAllDay && dayjs(event.startTime).format("YYYY-MM-DD") === date
|
|
325
|
+
);
|
|
326
|
+
}),
|
|
327
|
+
minHour,
|
|
328
|
+
maxHour,
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const nowTs = dayjs().valueOf();
|
|
332
|
+
const startOfDay = dayjs(date)
|
|
333
|
+
.startOf("day")
|
|
334
|
+
.add(minHour, "hour")
|
|
335
|
+
.format("YYYY-MM-DD HH:mm");
|
|
336
|
+
const endOfDay = dayjs(date)
|
|
337
|
+
.startOf("day")
|
|
338
|
+
.add(maxHour, "hour")
|
|
339
|
+
.subtract(1, "millisecond")
|
|
340
|
+
.format("YYYY-MM-DD HH:mm");
|
|
341
|
+
|
|
342
|
+
const startTimestamp = dayjs(startOfDay).valueOf();
|
|
343
|
+
const endTimestamp = dayjs(endOfDay).valueOf();
|
|
344
|
+
|
|
345
|
+
const totalRange = endTimestamp - startTimestamp;
|
|
346
|
+
const elapsed = nowTs - startTimestamp;
|
|
347
|
+
|
|
348
|
+
const percentage = (elapsed / totalRange) * 100;
|
|
349
|
+
|
|
350
|
+
const value = percentage > 100 ? 100 : percentage <= 0 ? 0 : percentage;
|
|
351
|
+
|
|
352
|
+
React.useEffect(() => {
|
|
353
|
+
setTopValue(value);
|
|
354
|
+
}, []);
|
|
355
|
+
const isToday = dayjs().isSame(date, "day");
|
|
356
|
+
|
|
357
|
+
const handleClick = () =>
|
|
358
|
+
// e: React.MouseEvent<HTMLDivElement>
|
|
359
|
+
{
|
|
360
|
+
// const scrollY = e.nativeEvent.offsetY;
|
|
361
|
+
// const columnHeight = e.currentTarget.clientHeight;
|
|
362
|
+
// const nearestTime = getNearestStepTime({
|
|
363
|
+
// clickOffsetY: scrollY,
|
|
364
|
+
// columnHeight,
|
|
365
|
+
// date,
|
|
366
|
+
// minHour,
|
|
367
|
+
// maxHour,
|
|
368
|
+
// step,
|
|
369
|
+
// });
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const diff = maxHour - minHour;
|
|
373
|
+
|
|
374
|
+
const height = diff * itemHeight;
|
|
375
|
+
|
|
376
|
+
const todos = results.filter(
|
|
377
|
+
(result) =>
|
|
378
|
+
dayjs(result.startTime).format("YYYY-MM-DD") === date && !result.isAllDay
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
// (1) 드래그 상태를 저장할 state
|
|
382
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
383
|
+
const [dragStartY, setDragStartY] = React.useState<number | null>(null);
|
|
384
|
+
const [dragEndY, setDragEndY] = React.useState<number | null>(null);
|
|
385
|
+
|
|
386
|
+
// "실시간" 마우스 위치에 따른 임시 박스의 시간
|
|
387
|
+
const [tempStartTime, setTempStartTime] = React.useState<dayjs.Dayjs | null>(
|
|
388
|
+
null
|
|
389
|
+
);
|
|
390
|
+
const [tempEndTime, setTempEndTime] = React.useState<dayjs.Dayjs | null>(
|
|
391
|
+
null
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
const [dragStartTime, setDragStartTime] = React.useState<dayjs.Dayjs | null>(
|
|
395
|
+
null
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
// div 참조
|
|
399
|
+
const colRef = React.useRef<HTMLDivElement | null>(null);
|
|
400
|
+
|
|
401
|
+
// (2) onMouseDown: 드래그 시작
|
|
402
|
+
const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
403
|
+
if (!enableCreateByDrag) return;
|
|
404
|
+
if (e.button !== 0) return; // 왼클릭만
|
|
405
|
+
setIsDragging(true);
|
|
406
|
+
|
|
407
|
+
const offsetY = e.nativeEvent.offsetY;
|
|
408
|
+
setDragStartY(offsetY);
|
|
409
|
+
setDragEndY(offsetY);
|
|
410
|
+
|
|
411
|
+
// 최초 시작 시각 기록
|
|
412
|
+
if (colRef.current) {
|
|
413
|
+
const columnHeight = colRef.current.clientHeight;
|
|
414
|
+
const nearestTime = getNearestStepTime({
|
|
415
|
+
clickOffsetY: offsetY,
|
|
416
|
+
columnHeight,
|
|
417
|
+
date,
|
|
418
|
+
minHour,
|
|
419
|
+
maxHour,
|
|
420
|
+
step,
|
|
421
|
+
});
|
|
422
|
+
setDragStartTime(nearestTime);
|
|
423
|
+
// 초기엔 tempStart/End를 동일하게
|
|
424
|
+
setTempStartTime(nearestTime);
|
|
425
|
+
setTempEndTime(nearestTime);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
// (3) onMouseMove: 드래그 진행 중
|
|
430
|
+
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
431
|
+
if (!enableCreateByDrag || !isDragging) return;
|
|
432
|
+
if (!dragStartTime) return; // 아직 시작 시각이 없다면
|
|
433
|
+
|
|
434
|
+
const offsetY = e.nativeEvent.offsetY;
|
|
435
|
+
setDragEndY(offsetY);
|
|
436
|
+
|
|
437
|
+
if (!colRef.current) return;
|
|
438
|
+
const columnHeight = colRef.current.clientHeight;
|
|
439
|
+
const currentTime = getNearestStepTime({
|
|
440
|
+
clickOffsetY: offsetY,
|
|
441
|
+
columnHeight,
|
|
442
|
+
date,
|
|
443
|
+
minHour,
|
|
444
|
+
maxHour,
|
|
445
|
+
step,
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// **여기가 핵심**:
|
|
449
|
+
// 항상 dragStartTime과 currentTime 중 "더 이른 시간"을 tempStartTime,
|
|
450
|
+
// "더 늦은 시간"을 tempEndTime으로 설정
|
|
451
|
+
const lowerTime = dayjs.min(dragStartTime, currentTime);
|
|
452
|
+
const upperTime = dayjs.max(dragStartTime, currentTime);
|
|
453
|
+
|
|
454
|
+
setTempStartTime(lowerTime);
|
|
455
|
+
setTempEndTime(upperTime);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// (4) onMouseUp: 드래그 끝
|
|
459
|
+
const handleMouseUp = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
460
|
+
if (!enableCreateByDrag) return;
|
|
461
|
+
e.stopPropagation();
|
|
462
|
+
if (!isDragging) return;
|
|
463
|
+
setIsDragging(false);
|
|
464
|
+
|
|
465
|
+
if (tempStartTime && tempEndTime && !tempStartTime.isSame(tempEndTime)) {
|
|
466
|
+
// TODO: 일정 생성 (dispatch or setState)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// 초기화
|
|
470
|
+
setDragStartTime(null);
|
|
471
|
+
setDragStartY(null);
|
|
472
|
+
setDragEndY(null);
|
|
473
|
+
setTempStartTime(null);
|
|
474
|
+
setTempEndTime(null);
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// const handleMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
478
|
+
// e.stopPropagation();
|
|
479
|
+
// if (isDragging) {
|
|
480
|
+
// // 여기서 "드래그 중지" 로직
|
|
481
|
+
// setIsDragging(false);
|
|
482
|
+
// // pointer-events 돌려놓기(필요하다면)
|
|
483
|
+
// console.log("DateColumn 벗어남 → 드래그 취소");
|
|
484
|
+
// }
|
|
485
|
+
// };
|
|
486
|
+
|
|
487
|
+
// (5) "임시 박스" 렌더링용 계산
|
|
488
|
+
let selectionTop = 0;
|
|
489
|
+
let selectionHeight = 0;
|
|
490
|
+
if (dragStartY !== null && dragEndY !== null) {
|
|
491
|
+
const minY = Math.min(dragStartY, dragEndY);
|
|
492
|
+
const maxY = Math.max(dragStartY, dragEndY);
|
|
493
|
+
selectionTop = minY;
|
|
494
|
+
selectionHeight = maxY - minY;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const tempText = React.useMemo(() => {
|
|
498
|
+
const startText = tempStartTime?.format("HH:mm") ?? "";
|
|
499
|
+
const endText = tempEndTime?.format("HH:mm") ?? "";
|
|
500
|
+
|
|
501
|
+
return `(제목 없음)\n${startText} ~ ${endText}`;
|
|
502
|
+
}, [tempStartTime, tempEndTime]);
|
|
503
|
+
|
|
504
|
+
return (
|
|
505
|
+
<div
|
|
506
|
+
className={cx("DateColumn", type, {
|
|
507
|
+
dragging: isDragging && enableCreateByDrag,
|
|
508
|
+
allowCreate: enableCreateByDrag,
|
|
509
|
+
})}
|
|
510
|
+
ref={setNodeRef}
|
|
511
|
+
onClick={handleClick}
|
|
512
|
+
onMouseDown={enableCreateByDrag ? handleMouseDown : undefined}
|
|
513
|
+
onMouseMove={enableCreateByDrag ? handleMouseMove : undefined}
|
|
514
|
+
onMouseUp={enableCreateByDrag ? handleMouseUp : undefined}
|
|
515
|
+
style={
|
|
516
|
+
{
|
|
517
|
+
cursor: enableCreateByDrag ? "cell" : "default",
|
|
518
|
+
"--bg-start-white": itemHeight - 1 + "px",
|
|
519
|
+
"--bg-end-white": itemHeight - 1 + "px",
|
|
520
|
+
"--bg-line-white": itemHeight + "px",
|
|
521
|
+
} as React.CSSProperties
|
|
522
|
+
}
|
|
523
|
+
>
|
|
524
|
+
<div className={cx("DateColumnInner")} ref={colRef} style={{ height }}>
|
|
525
|
+
{isToday && topValue ? (
|
|
526
|
+
<div
|
|
527
|
+
className={cx("TodayIndicator")}
|
|
528
|
+
style={{ top: `${topValue}%` }}
|
|
529
|
+
/>
|
|
530
|
+
) : null}
|
|
531
|
+
|
|
532
|
+
{todos.map((todo) => {
|
|
533
|
+
const height = Math.max(
|
|
534
|
+
(col?.clientHeight || 0) * (todo.heightPercent / 100),
|
|
535
|
+
24
|
|
536
|
+
);
|
|
537
|
+
return (
|
|
538
|
+
<EventItem
|
|
539
|
+
key={todo.id}
|
|
540
|
+
{...todo}
|
|
541
|
+
endTime={todo.realEndTime}
|
|
542
|
+
height={height}
|
|
543
|
+
title={todo.title ?? ""}
|
|
544
|
+
/>
|
|
545
|
+
);
|
|
546
|
+
})}
|
|
547
|
+
|
|
548
|
+
{isDragging && (
|
|
549
|
+
<div
|
|
550
|
+
style={{
|
|
551
|
+
position: "absolute",
|
|
552
|
+
top: selectionTop,
|
|
553
|
+
left: 0,
|
|
554
|
+
width: "100%",
|
|
555
|
+
height: selectionHeight,
|
|
556
|
+
backgroundColor: "#F4511E",
|
|
557
|
+
pointerEvents: "none",
|
|
558
|
+
fontSize: 11,
|
|
559
|
+
borderRadius: 4,
|
|
560
|
+
padding: 4,
|
|
561
|
+
boxShadow: "0 0 4px rgba(0,0,0,0.2)",
|
|
562
|
+
whiteSpace: "pre-wrap",
|
|
563
|
+
color: "white",
|
|
564
|
+
zIndex: 100,
|
|
565
|
+
}}
|
|
566
|
+
>
|
|
567
|
+
{tempText}
|
|
568
|
+
</div>
|
|
569
|
+
)}
|
|
570
|
+
</div>
|
|
571
|
+
<div
|
|
572
|
+
ref={setCol}
|
|
573
|
+
style={{
|
|
574
|
+
// flex: 1,
|
|
575
|
+
width: 8,
|
|
576
|
+
// position: "absolute",
|
|
577
|
+
height: `${height}px`,
|
|
578
|
+
}}
|
|
579
|
+
></div>
|
|
580
|
+
</div>
|
|
581
|
+
);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
const DateColumnRow = (props: DateColumnRowProps) => {
|
|
585
|
+
const { onScroll } = props;
|
|
586
|
+
const {
|
|
587
|
+
currentDate = dayjs().format("YYYY-MM-DD"),
|
|
588
|
+
columnCount,
|
|
589
|
+
minHour,
|
|
590
|
+
maxHour,
|
|
591
|
+
} = React.useContext(WeeklyCalendarContext);
|
|
592
|
+
|
|
593
|
+
const dateCells = Array.from({ length: columnCount }, (_, i) => {
|
|
594
|
+
return {
|
|
595
|
+
date: dayjs(currentDate).add(i, "day").format("YYYY-MM-DD"),
|
|
596
|
+
dayText: getDayText(dayjs(currentDate).add(i, "day").get("day"), "ko"),
|
|
597
|
+
};
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
const diff = maxHour - minHour;
|
|
601
|
+
const timeline = Array.from({ length: diff }, (_, i) => {
|
|
602
|
+
return dayjs()
|
|
603
|
+
.startOf("day")
|
|
604
|
+
.add(minHour + i, "hour")
|
|
605
|
+
.format("HH:mm");
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
return (
|
|
609
|
+
<div className={cx("DateColumnRow")} onScroll={onScroll}>
|
|
610
|
+
<div className={cx("DateColumnRowInner")}>
|
|
611
|
+
<div className={cx("TimeCriteria")}>
|
|
612
|
+
{timeline.map((time) => {
|
|
613
|
+
return <div key={time} className={cx("TimeCriteriaCell")}></div>;
|
|
614
|
+
})}
|
|
615
|
+
</div>
|
|
616
|
+
{dateCells.map((dateCell) => {
|
|
617
|
+
return <DateColumn key={dateCell.date} date={dateCell.date} />;
|
|
618
|
+
})}
|
|
619
|
+
</div>
|
|
620
|
+
</div>
|
|
621
|
+
);
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
const DateCellRow = () => {
|
|
625
|
+
const { currentDate = dayjs().format("YYYY-MM-DD"), columnCount } =
|
|
626
|
+
React.useContext(WeeklyCalendarContext);
|
|
627
|
+
|
|
628
|
+
const dateCells = Array.from({ length: columnCount }, (_, i) => {
|
|
629
|
+
return {
|
|
630
|
+
realDate: dayjs(currentDate).add(i, "day"),
|
|
631
|
+
date: dayjs(currentDate).add(i, "day").format("DD"),
|
|
632
|
+
dayText: getDayText(dayjs(currentDate).add(i, "day").get("day"), "ko"),
|
|
633
|
+
};
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
return (
|
|
637
|
+
<div className={cx("DateCellRow")}>
|
|
638
|
+
{dateCells.map((dateCell) => {
|
|
639
|
+
return (
|
|
640
|
+
<div
|
|
641
|
+
key={dateCell.date}
|
|
642
|
+
className={cx("DateCell", {
|
|
643
|
+
today: dayjs().isSame(dateCell.realDate, "day"),
|
|
644
|
+
})}
|
|
645
|
+
>
|
|
646
|
+
<div className={cx("DayText")}>{dateCell.dayText}</div>
|
|
647
|
+
<div className={cx("Date")}>{dateCell.date}</div>
|
|
648
|
+
</div>
|
|
649
|
+
);
|
|
650
|
+
})}
|
|
651
|
+
</div>
|
|
652
|
+
);
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
const StandardTime = () => {
|
|
656
|
+
return (
|
|
657
|
+
<div className={cx("ShrinkedColumn", "StandardTime")}>{getGmtString()}</div>
|
|
658
|
+
);
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
interface TimelinesProps {
|
|
662
|
+
className?: string;
|
|
663
|
+
as?: (props: {
|
|
664
|
+
itemHeight: number;
|
|
665
|
+
minHour: number;
|
|
666
|
+
maxHour: number;
|
|
667
|
+
time: string;
|
|
668
|
+
}) => React.ReactNode;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const Timelines = (props: TimelinesProps) => {
|
|
672
|
+
const { className, as } = props;
|
|
673
|
+
const {
|
|
674
|
+
minHour,
|
|
675
|
+
maxHour,
|
|
676
|
+
itemHeight = 48,
|
|
677
|
+
type = "default",
|
|
678
|
+
} = React.useContext(WeeklyCalendarContext);
|
|
679
|
+
const diff = maxHour - minHour;
|
|
680
|
+
const timeline = Array.from({ length: diff + 1 }, (_, i) => {
|
|
681
|
+
return dayjs()
|
|
682
|
+
.startOf("day")
|
|
683
|
+
.add(minHour + i, "hour")
|
|
684
|
+
.format("HH:mm");
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
const renderTimeline = (time: string) => {
|
|
688
|
+
if (as) {
|
|
689
|
+
return React.createElement(as, {
|
|
690
|
+
key: time.toString(),
|
|
691
|
+
itemHeight,
|
|
692
|
+
minHour,
|
|
693
|
+
maxHour,
|
|
694
|
+
time,
|
|
695
|
+
});
|
|
696
|
+
} else {
|
|
697
|
+
return (
|
|
698
|
+
<div
|
|
699
|
+
key={time}
|
|
700
|
+
className={cx("Timeline")}
|
|
701
|
+
style={{
|
|
702
|
+
height: itemHeight,
|
|
703
|
+
}}
|
|
704
|
+
>
|
|
705
|
+
<span className={cx("TimeText")}>{time}</span>
|
|
706
|
+
</div>
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
return (
|
|
712
|
+
<div className={cx("TimelineWrapper", className, type)}>
|
|
713
|
+
{timeline.map((time) => {
|
|
714
|
+
return renderTimeline(time);
|
|
715
|
+
})}
|
|
716
|
+
</div>
|
|
717
|
+
);
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
type RootProps<T extends EventItemType> = WeeklyCalendarProviderProps<T> & {
|
|
721
|
+
className?: string;
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
const Root = <T extends EventItemType>(props: RootProps<T>) => {
|
|
725
|
+
const {
|
|
726
|
+
children,
|
|
727
|
+
enableCreateByDrag = true,
|
|
728
|
+
enableMoveByDrag = true,
|
|
729
|
+
type = "default",
|
|
730
|
+
className,
|
|
731
|
+
events,
|
|
732
|
+
...rest
|
|
733
|
+
} = props;
|
|
734
|
+
|
|
735
|
+
function handleDragEnd() {
|
|
736
|
+
if (!enableMoveByDrag) return;
|
|
737
|
+
// ... 드래그 앤 드롭 처리
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const contextValue = {
|
|
741
|
+
...initialState,
|
|
742
|
+
...rest,
|
|
743
|
+
events: splitEventsConsideringAllDay(events || []),
|
|
744
|
+
type,
|
|
745
|
+
enableCreateByDrag,
|
|
746
|
+
enableMoveByDrag,
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
return (
|
|
750
|
+
<DndContext onDragEnd={handleDragEnd}>
|
|
751
|
+
<WeeklyCalendarContext value={contextValue}>
|
|
752
|
+
<div className={cx("WeeklyCalendarRoot", className)}>{children}</div>
|
|
753
|
+
</WeeklyCalendarContext>
|
|
754
|
+
</DndContext>
|
|
755
|
+
);
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
interface IWeeklyCalendar {
|
|
759
|
+
Root: typeof Root;
|
|
760
|
+
Timelines: typeof Timelines;
|
|
761
|
+
StandardTime: typeof StandardTime;
|
|
762
|
+
DateCellRow: typeof DateCellRow;
|
|
763
|
+
DateColumnRow: typeof DateColumnRow;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export default {
|
|
767
|
+
Root,
|
|
768
|
+
Timelines,
|
|
769
|
+
StandardTime,
|
|
770
|
+
DateCellRow,
|
|
771
|
+
DateColumnRow,
|
|
772
|
+
} as IWeeklyCalendar;
|