@tipp/ui 2.3.2 → 2.3.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.
- package/dist/app/index.cjs +4 -2
- package/dist/app/index.cjs.map +1 -1
- package/dist/app/index.js +87 -87
- package/dist/app/platform/coach-question-list.cjs.map +1 -1
- package/dist/app/platform/coach-question-list.js +28 -28
- package/dist/app/platform/contents-card.cjs.map +1 -1
- package/dist/app/platform/contents-card.js +28 -28
- package/dist/app/platform/curriculum-card.js +6 -6
- package/dist/app/platform/edit-coaching-time.cjs +4 -2
- package/dist/app/platform/edit-coaching-time.cjs.map +1 -1
- package/dist/app/platform/edit-coaching-time.js +69 -69
- package/dist/app/platform/edit-service-type.cjs +4 -2
- package/dist/app/platform/edit-service-type.cjs.map +1 -1
- package/dist/app/platform/edit-service-type.js +70 -70
- package/dist/app/platform/goal-manage-card-edit.cjs.map +1 -1
- package/dist/app/platform/goal-manage-card-edit.js +69 -69
- package/dist/app/platform/goal-manage-card-read.cjs.map +1 -1
- package/dist/app/platform/goal-manage-card-read.js +28 -28
- package/dist/app/platform/on-offline-radio-card.cjs.map +1 -1
- package/dist/app/platform/on-offline-radio-card.js +69 -69
- package/dist/app/platform/report-card.cjs.map +1 -1
- package/dist/app/platform/report-card.js +28 -28
- package/dist/app/platform/reservation-card.cjs.map +1 -1
- package/dist/app/platform/reservation-card.js +70 -70
- package/dist/app/platform/session-card.cjs +4 -2
- package/dist/app/platform/session-card.cjs.map +1 -1
- package/dist/app/platform/session-card.js +72 -72
- package/dist/app/platform/session-review-simple-read.cjs.map +1 -1
- package/dist/app/platform/session-review-simple-read.js +28 -28
- package/dist/app/platform/userInfos/coaching-customer-info/index.cjs.map +1 -1
- package/dist/app/platform/userInfos/coaching-customer-info/index.js +33 -33
- package/dist/app/platform/userInfos/coaching-customer-info/large.cjs.map +1 -1
- package/dist/app/platform/userInfos/coaching-customer-info/large.js +28 -28
- package/dist/app/platform/userInfos/coaching-customer-info/medium.cjs.map +1 -1
- package/dist/app/platform/userInfos/coaching-customer-info/medium.js +28 -28
- package/dist/app/platform/userInfos/coaching-customer-info/small.cjs.map +1 -1
- package/dist/app/platform/userInfos/coaching-customer-info/small.js +28 -28
- package/dist/app/platform/userInfos/session-user-info-detail.cjs.map +1 -1
- package/dist/app/platform/userInfos/session-user-info-detail.js +28 -28
- package/dist/app/platform/userInfos/utils.cjs.map +1 -1
- package/dist/app/platform/userInfos/utils.js +27 -27
- package/dist/atoms/bullet-text.js +2 -2
- package/dist/atoms/dialog.cjs +4 -2
- package/dist/atoms/dialog.cjs.map +1 -1
- package/dist/atoms/dialog.d.cts +1 -0
- package/dist/atoms/dialog.d.ts +1 -0
- package/dist/atoms/dialog.js +2 -2
- package/dist/atoms/field-error-wrapper.js +2 -2
- package/dist/atoms/index.cjs +4 -2
- package/dist/atoms/index.cjs.map +1 -1
- package/dist/atoms/index.js +59 -59
- package/dist/atoms/list.js +2 -2
- package/dist/atoms/pagination.js +3 -3
- package/dist/chunk-2MYKSCKP.js +99 -0
- package/dist/chunk-2MYKSCKP.js.map +1 -0
- package/dist/chunk-36DXOR67.js +68 -0
- package/dist/chunk-36DXOR67.js.map +1 -0
- package/dist/chunk-3I3IHASZ.js +64 -0
- package/dist/chunk-3I3IHASZ.js.map +1 -0
- package/dist/chunk-4BRN5AXJ.js +64 -0
- package/dist/chunk-4BRN5AXJ.js.map +1 -0
- package/dist/chunk-4N23WOT7.js +144 -0
- package/dist/chunk-4N23WOT7.js.map +1 -0
- package/dist/chunk-4WJF7WXY.js +192 -0
- package/dist/chunk-4WJF7WXY.js.map +1 -0
- package/dist/chunk-65ZUDFPR.js +117 -0
- package/dist/chunk-65ZUDFPR.js.map +1 -0
- package/dist/chunk-6GAZ3JJT.js +144 -0
- package/dist/chunk-6GAZ3JJT.js.map +1 -0
- package/dist/chunk-6K4VIQTT.js +54 -0
- package/dist/chunk-6K4VIQTT.js.map +1 -0
- package/dist/chunk-7BLUAQBV.js +233 -0
- package/dist/chunk-7BLUAQBV.js.map +1 -0
- package/dist/chunk-7IBUQ5XL.js +363 -0
- package/dist/chunk-7IBUQ5XL.js.map +1 -0
- package/dist/chunk-7Y6S4473.js +69 -0
- package/dist/chunk-7Y6S4473.js.map +1 -0
- package/dist/chunk-AH4A53SZ.js +137 -0
- package/dist/chunk-AH4A53SZ.js.map +1 -0
- package/dist/chunk-B5CCM56M.js +135 -0
- package/dist/chunk-B5CCM56M.js.map +1 -0
- package/dist/chunk-B6A7IIYJ.js +70 -0
- package/dist/chunk-B6A7IIYJ.js.map +1 -0
- package/dist/chunk-CLFON5AH.js +87 -0
- package/dist/chunk-CLFON5AH.js.map +1 -0
- package/dist/chunk-CMBTJWVJ.js +69 -0
- package/dist/chunk-CMBTJWVJ.js.map +1 -0
- package/dist/chunk-CMQRNBLB.js +54 -0
- package/dist/chunk-CMQRNBLB.js.map +1 -0
- package/dist/chunk-CMSM5Z5E.js +137 -0
- package/dist/chunk-CMSM5Z5E.js.map +1 -0
- package/dist/chunk-CWHY67LR.js +174 -0
- package/dist/chunk-CWHY67LR.js.map +1 -0
- package/dist/chunk-D6BUWYJI.js +54 -0
- package/dist/chunk-D6BUWYJI.js.map +1 -0
- package/dist/chunk-DCAW5B6B.js +64 -0
- package/dist/chunk-DCAW5B6B.js.map +1 -0
- package/dist/chunk-DW25XNLO.js +174 -0
- package/dist/chunk-DW25XNLO.js.map +1 -0
- package/dist/chunk-E5A6QALE.js +196 -0
- package/dist/chunk-E5A6QALE.js.map +1 -0
- package/dist/chunk-FQFLQN6Y.js +63 -0
- package/dist/chunk-FQFLQN6Y.js.map +1 -0
- package/dist/chunk-G6RTTIKB.js +64 -0
- package/dist/chunk-G6RTTIKB.js.map +1 -0
- package/dist/chunk-GNB7DD7J.js +196 -0
- package/dist/chunk-GNB7DD7J.js.map +1 -0
- package/dist/chunk-GXEWC3QS.js +196 -0
- package/dist/chunk-GXEWC3QS.js.map +1 -0
- package/dist/chunk-HLLWOJOK.js +174 -0
- package/dist/chunk-HLLWOJOK.js.map +1 -0
- package/dist/chunk-JI3K6VKE.js +144 -0
- package/dist/chunk-JI3K6VKE.js.map +1 -0
- package/dist/chunk-K2ATYWTQ.js +54 -0
- package/dist/chunk-K2ATYWTQ.js.map +1 -0
- package/dist/chunk-KJBSLION.js +174 -0
- package/dist/chunk-KJBSLION.js.map +1 -0
- package/dist/chunk-L6ZQX7HU.js +64 -0
- package/dist/chunk-L6ZQX7HU.js.map +1 -0
- package/dist/chunk-LVICE2MV.js +228 -0
- package/dist/chunk-LVICE2MV.js.map +1 -0
- package/dist/chunk-N5WK2MYE.js +64 -0
- package/dist/chunk-N5WK2MYE.js.map +1 -0
- package/dist/chunk-NIOXLMGY.js +64 -0
- package/dist/chunk-NIOXLMGY.js.map +1 -0
- package/dist/chunk-NQ6NKF3F.js +165 -0
- package/dist/chunk-NQ6NKF3F.js.map +1 -0
- package/dist/chunk-O66FI27Q.js +63 -0
- package/dist/chunk-O66FI27Q.js.map +1 -0
- package/dist/chunk-OB3C3JOM.js +144 -0
- package/dist/chunk-OB3C3JOM.js.map +1 -0
- package/dist/chunk-OQDPY5RB.js +137 -0
- package/dist/chunk-OQDPY5RB.js.map +1 -0
- package/dist/chunk-PAM3ZEFI.js +144 -0
- package/dist/chunk-PAM3ZEFI.js.map +1 -0
- package/dist/chunk-PCW3YU6E.js +196 -0
- package/dist/chunk-PCW3YU6E.js.map +1 -0
- package/dist/chunk-Q5Z4EHPC.js +169 -0
- package/dist/chunk-Q5Z4EHPC.js.map +1 -0
- package/dist/chunk-QGGG4IDX.js +196 -0
- package/dist/chunk-QGGG4IDX.js.map +1 -0
- package/dist/chunk-QPRH6W7T.js +196 -0
- package/dist/chunk-QPRH6W7T.js.map +1 -0
- package/dist/chunk-QRQYMO45.js +196 -0
- package/dist/chunk-QRQYMO45.js.map +1 -0
- package/dist/chunk-RFZPKB5J.js +196 -0
- package/dist/chunk-RFZPKB5J.js.map +1 -0
- package/dist/chunk-RNDGWKZA.js +54 -0
- package/dist/chunk-RNDGWKZA.js.map +1 -0
- package/dist/chunk-SDYFRI7L.js +54 -0
- package/dist/chunk-SDYFRI7L.js.map +1 -0
- package/dist/chunk-TAYCJ2P3.js +145 -0
- package/dist/chunk-TAYCJ2P3.js.map +1 -0
- package/dist/chunk-UE5S4ECH.js +137 -0
- package/dist/chunk-UE5S4ECH.js.map +1 -0
- package/dist/chunk-UHLHNMKL.js +135 -0
- package/dist/chunk-UHLHNMKL.js.map +1 -0
- package/dist/chunk-VG2DMJ2U.js +125 -0
- package/dist/chunk-VG2DMJ2U.js.map +1 -0
- package/dist/chunk-VGNQAHMB.js +79 -0
- package/dist/chunk-VGNQAHMB.js.map +1 -0
- package/dist/chunk-VH2ZMFTB.js +64 -0
- package/dist/chunk-VH2ZMFTB.js.map +1 -0
- package/dist/chunk-VIPNTIPC.js +174 -0
- package/dist/chunk-VIPNTIPC.js.map +1 -0
- package/dist/chunk-WZRGAW43.js +100 -0
- package/dist/chunk-WZRGAW43.js.map +1 -0
- package/dist/chunk-XBNMZOEU.js +144 -0
- package/dist/chunk-XBNMZOEU.js.map +1 -0
- package/dist/chunk-XCYDDU5Y.js +174 -0
- package/dist/chunk-XCYDDU5Y.js.map +1 -0
- package/dist/chunk-XLTMDAE3.js +75 -0
- package/dist/chunk-XLTMDAE3.js.map +1 -0
- package/dist/chunk-XQXNWDM7.js +144 -0
- package/dist/chunk-XQXNWDM7.js.map +1 -0
- package/dist/chunk-Z7ZJWOOJ.js +89 -0
- package/dist/chunk-Z7ZJWOOJ.js.map +1 -0
- package/dist/chunk-ZJNWNMA4.js +54 -0
- package/dist/chunk-ZJNWNMA4.js.map +1 -0
- package/dist/chunk-ZLIUPGUQ.js +89 -0
- package/dist/chunk-ZLIUPGUQ.js.map +1 -0
- package/dist/chunk-ZOJRVTUA.js +174 -0
- package/dist/chunk-ZOJRVTUA.js.map +1 -0
- package/dist/context/index.js +5 -5
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -12
- package/dist/index.js +137 -137
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/index.js +15 -15
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-comp.js +4 -4
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-body.js +9 -9
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-footer.js +2 -2
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-header.js +3 -3
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-layout.js +2 -2
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-radio.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-satisfaction-option.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-satisfaction-text.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-text.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/complete-review.js +4 -4
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/index.js +19 -19
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/start-review.js +6 -6
- package/dist/molecules/curriculumV2/CurriculumContents/curriculum-ai-traning.js +3 -3
- package/dist/molecules/curriculumV2/CurriculumContents/curriculum-review.cjs +4 -2
- package/dist/molecules/curriculumV2/CurriculumContents/curriculum-review.cjs.map +1 -1
- package/dist/molecules/curriculumV2/CurriculumContents/curriculum-review.js +21 -21
- package/dist/molecules/curriculumV2/CurriculumContents/index.cjs +4 -2
- package/dist/molecules/curriculumV2/CurriculumContents/index.cjs.map +1 -1
- package/dist/molecules/curriculumV2/CurriculumContents/index.js +25 -25
- package/dist/molecules/curriculumV2/CurriculumSidebar/Items/curriculum-item-title.js +2 -2
- package/dist/molecules/curriculumV2/CurriculumSidebar/Items/section-item.js +4 -4
- package/dist/molecules/curriculumV2/CurriculumSidebar/index.js +8 -8
- package/dist/molecules/curriculumV2/CurriculumSidebar/sidebar-item.js +6 -6
- package/dist/molecules/curriculumV2/curriculum-sub-nav.js +4 -4
- package/dist/molecules/curriculumV2/curriculum-v2-layout.js +2 -2
- package/dist/molecules/curriculumV2/index.cjs +4 -2
- package/dist/molecules/curriculumV2/index.cjs.map +1 -1
- package/dist/molecules/curriculumV2/index.js +36 -36
- package/dist/molecules/date-picker/date-picker-button.js +6 -6
- package/dist/molecules/date-picker/index.js +5 -5
- package/dist/molecules/download-card.js +2 -2
- package/dist/molecules/dynamic-field.js +4 -4
- package/dist/molecules/dynamic-form.js +5 -5
- package/dist/molecules/expand-table/index.js +4 -4
- package/dist/molecules/force-refresh.js +2 -2
- package/dist/molecules/ghost-post.js +4 -4
- package/dist/molecules/index.cjs +4 -2
- package/dist/molecules/index.cjs.map +1 -1
- package/dist/molecules/index.js +65 -65
- package/dist/molecules/learning-post.js +5 -5
- package/dist/molecules/navigation.js +3 -3
- package/dist/molecules/one-on-one-guide-list.js +3 -3
- package/dist/molecules/stepper.js +4 -4
- package/dist/molecules/tag-selector.js +5 -5
- package/package.json +1 -1
- package/src/atoms/dialog.tsx +4 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OnOfflineRadioCard
|
|
3
|
+
} from "./chunk-M2PVHXOE.js";
|
|
4
|
+
import {
|
|
5
|
+
Dialog
|
|
6
|
+
} from "./chunk-CMSM5Z5E.js";
|
|
7
|
+
import {
|
|
8
|
+
Box
|
|
9
|
+
} from "./chunk-4Y5BEXVN.js";
|
|
10
|
+
import {
|
|
11
|
+
Typo
|
|
12
|
+
} from "./chunk-PMJIFLDT.js";
|
|
13
|
+
import {
|
|
14
|
+
Flex
|
|
15
|
+
} from "./chunk-25HMMI7R.js";
|
|
16
|
+
import {
|
|
17
|
+
Button
|
|
18
|
+
} from "./chunk-ZVDAEY5Q.js";
|
|
19
|
+
|
|
20
|
+
// src/app/platform/edit-service-type.tsx
|
|
21
|
+
import { useCallback, useState } from "react";
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
function EditServiceType(props) {
|
|
24
|
+
const { defaultServiceType, onClickCancel } = props;
|
|
25
|
+
const [sessionType, setSessionType] = useState(
|
|
26
|
+
defaultServiceType
|
|
27
|
+
);
|
|
28
|
+
const onClickSave = useCallback(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
(_a = props.onClickSave) == null ? void 0 : _a.call(props, sessionType);
|
|
31
|
+
}, [props, sessionType]);
|
|
32
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
Typo,
|
|
35
|
+
{
|
|
36
|
+
as: "p",
|
|
37
|
+
color: "gray",
|
|
38
|
+
mb: { initial: "5", xs: "3" },
|
|
39
|
+
variant: "caption",
|
|
40
|
+
children: "\uC138\uC158 \uC720\uD615\uC5D0 \uB530\uB77C \uCC45\uC815\uB418\uB294 \uCF54\uCE6D \uAE08\uC561\uC774 \uB2EC\uB77C\uC9C0\uBBC0\uB85C, \uC815\uD655\uD558\uAC8C \uC120\uD0DD\uD574\uC8FC\uC138\uC694"
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ jsx(OnOfflineRadioCard, { onValueChange: setSessionType, value: sessionType }),
|
|
44
|
+
/* @__PURE__ */ jsxs(Flex, { gap: "3", justify: "end", mt: { initial: "6", xs: "3" }, children: [
|
|
45
|
+
/* @__PURE__ */ jsx(Dialog.Close, { children: /* @__PURE__ */ jsx(Button, { color: "gray", onClick: onClickCancel, variant: "outline", children: "\uCDE8\uC18C\uD558\uAE30" }) }),
|
|
46
|
+
/* @__PURE__ */ jsx(Dialog.Close, { children: /* @__PURE__ */ jsx(Button, { onClick: onClickSave, children: "\uC800\uC7A5\uD558\uAE30" }) })
|
|
47
|
+
] })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
EditServiceType
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=chunk-6K4VIQTT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/app/platform/edit-service-type.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { Box, Button, Dialog, Flex, Typo } from '@/atoms';\nimport type { ServiceType } from '@/types/biz.type';\nimport { OnOfflineRadioCard } from './on-offline-radio-card';\n\nexport interface EditServiceTypeProps {\n defaultServiceType?: ServiceType;\n onClickSave?: (serviceType: ServiceType) => void;\n onClickCancel?: () => void;\n}\n\nexport function EditServiceType(\n props: EditServiceTypeProps\n): React.ReactNode {\n const { defaultServiceType, onClickCancel } = props;\n const [sessionType, setSessionType] = useState<string | undefined>(\n defaultServiceType\n );\n\n const onClickSave = useCallback(() => {\n props.onClickSave?.(sessionType as ServiceType);\n }, [props, sessionType]);\n\n return (\n <Box>\n <Typo\n as=\"p\"\n color=\"gray\"\n mb={{ initial: '5', xs: '3' }}\n variant=\"caption\"\n >\n 세션 유형에 따라 책정되는 코칭 금액이 달라지므로, 정확하게 선택해주세요\n </Typo>\n <OnOfflineRadioCard onValueChange={setSessionType} value={sessionType} />\n <Flex gap=\"3\" justify=\"end\" mt={{ initial: '6', xs: '3' }}>\n <Dialog.Close>\n <Button color=\"gray\" onClick={onClickCancel} variant=\"outline\">\n 취소하기\n </Button>\n </Dialog.Close>\n <Dialog.Close>\n <Button onClick={onClickSave}>저장하기</Button>\n </Dialog.Close>\n </Flex>\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,aAAa,gBAAgB;AAyBvC,cASA,YATA;AAdC,SAAS,gBACd,OACiB;AACjB,QAAM,EAAE,oBAAoB,cAAc,IAAI;AAC9C,QAAM,CAAC,aAAa,cAAc,IAAI;AAAA,IACpC;AAAA,EACF;AAEA,QAAM,cAAc,YAAY,MAAM;AAnBxC;AAoBI,gBAAM,gBAAN,+BAAoB;AAAA,EACtB,GAAG,CAAC,OAAO,WAAW,CAAC;AAEvB,SACE,qBAAC,OACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,OAAM;AAAA,QACN,IAAI,EAAE,SAAS,KAAK,IAAI,IAAI;AAAA,QAC5B,SAAQ;AAAA,QACT;AAAA;AAAA,IAED;AAAA,IACA,oBAAC,sBAAmB,eAAe,gBAAgB,OAAO,aAAa;AAAA,IACvE,qBAAC,QAAK,KAAI,KAAI,SAAQ,OAAM,IAAI,EAAE,SAAS,KAAK,IAAI,IAAI,GACtD;AAAA,0BAAC,OAAO,OAAP,EACC,8BAAC,UAAO,OAAM,QAAO,SAAS,eAAe,SAAQ,WAAU,sCAE/D,GACF;AAAA,MACA,oBAAC,OAAO,OAAP,EACC,8BAAC,UAAO,SAAS,aAAa,sCAAI,GACpC;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Popover
|
|
3
|
+
} from "./chunk-5AVBYDPB.js";
|
|
4
|
+
import {
|
|
5
|
+
Heading
|
|
6
|
+
} from "./chunk-BESTU2AY.js";
|
|
7
|
+
import {
|
|
8
|
+
IconButton
|
|
9
|
+
} from "./chunk-XK6VEVOK.js";
|
|
10
|
+
import {
|
|
11
|
+
Box
|
|
12
|
+
} from "./chunk-4Y5BEXVN.js";
|
|
13
|
+
import {
|
|
14
|
+
Typo
|
|
15
|
+
} from "./chunk-PMJIFLDT.js";
|
|
16
|
+
import {
|
|
17
|
+
Flex
|
|
18
|
+
} from "./chunk-25HMMI7R.js";
|
|
19
|
+
import {
|
|
20
|
+
Button
|
|
21
|
+
} from "./chunk-ZVDAEY5Q.js";
|
|
22
|
+
import {
|
|
23
|
+
ChevronLeftIcon,
|
|
24
|
+
ChevronRightIcon
|
|
25
|
+
} from "./chunk-R7IT4TCD.js";
|
|
26
|
+
import {
|
|
27
|
+
__objRest,
|
|
28
|
+
__spreadProps,
|
|
29
|
+
__spreadValues
|
|
30
|
+
} from "./chunk-CRTRMMJ7.js";
|
|
31
|
+
|
|
32
|
+
// src/molecules/date-picker/index.tsx
|
|
33
|
+
import { forwardRef, useMemo, useState, useEffect, useRef } from "react";
|
|
34
|
+
import ReactDatePicker from "react-datepicker";
|
|
35
|
+
import { ko } from "date-fns/locale";
|
|
36
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
37
|
+
var DatePicker = forwardRef(
|
|
38
|
+
(props, ref) => {
|
|
39
|
+
const _a = props, { fullWidth } = _a, rest = __objRest(_a, ["fullWidth"]);
|
|
40
|
+
const fullWidthClassName = fullWidth ? "full-width" : "";
|
|
41
|
+
const [isYearDropdownOpen, setIsYearDropdownOpen] = useState(false);
|
|
42
|
+
const [isMonthDropdownOpen, setIsMonthDropdownOpen] = useState(false);
|
|
43
|
+
const renderCustomHeader = useMemo(() => {
|
|
44
|
+
const getYears = () => {
|
|
45
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
46
|
+
return Array.from(
|
|
47
|
+
{ length: currentYear + 5 - 1920 },
|
|
48
|
+
(_, index) => 1920 + index
|
|
49
|
+
).filter((year) => {
|
|
50
|
+
if (props.minDate && year < props.minDate.getFullYear()) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (props.maxDate && year > props.maxDate.getFullYear()) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return getRenderCustomHeader(__spreadProps(__spreadValues({}, props), {
|
|
60
|
+
years: getYears(),
|
|
61
|
+
isYearDropdownOpen,
|
|
62
|
+
setIsYearDropdownOpen,
|
|
63
|
+
isMonthDropdownOpen,
|
|
64
|
+
setIsMonthDropdownOpen
|
|
65
|
+
}));
|
|
66
|
+
}, [isMonthDropdownOpen, isYearDropdownOpen, props]);
|
|
67
|
+
return /* @__PURE__ */ jsx(Flex, { p: "0", width: "100%", children: /* @__PURE__ */ jsx(
|
|
68
|
+
ReactDatePicker,
|
|
69
|
+
__spreadProps(__spreadValues({
|
|
70
|
+
dateFormat: "yyyy/MM/dd h:mm aa",
|
|
71
|
+
formatWeekDay: (nameOfDay) => {
|
|
72
|
+
return nameOfDay[0];
|
|
73
|
+
},
|
|
74
|
+
locale: ko,
|
|
75
|
+
nextMonthButtonLabel: "\uB2E4\uC74C \uB2EC",
|
|
76
|
+
placeholderText: "YYYY/MM/DD hh:mm AM/PM",
|
|
77
|
+
popperProps: { strategy: "fixed" },
|
|
78
|
+
previousMonthButtonLabel: "\uC774\uC804 \uB2EC",
|
|
79
|
+
ref,
|
|
80
|
+
renderCustomHeader,
|
|
81
|
+
showPopperArrow: false,
|
|
82
|
+
timeCaption: "\uC2DC\uAC04",
|
|
83
|
+
timeFormat: "aa h:mm",
|
|
84
|
+
timeIntervals: 10
|
|
85
|
+
}, rest), {
|
|
86
|
+
calendarClassName: `tipp_datePicker_calendar ${rest.calendarClassName || ""}`,
|
|
87
|
+
wrapperClassName: `tipp_datePicker ${fullWidthClassName} ${rest.wrapperClassName || ""}`
|
|
88
|
+
})
|
|
89
|
+
) });
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
DatePicker.displayName = "DatePicker";
|
|
93
|
+
function DropdownSelector({
|
|
94
|
+
isOpen,
|
|
95
|
+
onOpenChange,
|
|
96
|
+
onSelect,
|
|
97
|
+
options,
|
|
98
|
+
selectedValue,
|
|
99
|
+
suffix
|
|
100
|
+
}) {
|
|
101
|
+
const scrollContainerRef = useRef(null);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (isOpen) {
|
|
104
|
+
queueMicrotask(() => {
|
|
105
|
+
var _a;
|
|
106
|
+
const item = (_a = scrollContainerRef.current) == null ? void 0 : _a.querySelector(
|
|
107
|
+
`[data-year-month-dropdown-tiem="${selectedValue}"]`
|
|
108
|
+
);
|
|
109
|
+
if (item) {
|
|
110
|
+
item.scrollIntoView({ behavior: "instant" });
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, [isOpen]);
|
|
115
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { modal: true, onOpenChange, open: isOpen, children: [
|
|
116
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(Button, { className: "react-datepicker_dropdown_header", variant: "ghost", children: /* @__PURE__ */ jsxs(Heading, { variant: "heading4", weight: "regular", children: [
|
|
117
|
+
selectedValue,
|
|
118
|
+
suffix
|
|
119
|
+
] }) }) }),
|
|
120
|
+
/* @__PURE__ */ jsx(Popover.Content, { side: "bottom", children: /* @__PURE__ */ jsx(
|
|
121
|
+
Box,
|
|
122
|
+
{
|
|
123
|
+
maxHeight: "200px",
|
|
124
|
+
overflowY: "auto",
|
|
125
|
+
ref: scrollContainerRef,
|
|
126
|
+
style: { scrollbarWidth: "none" },
|
|
127
|
+
children: /* @__PURE__ */ jsx(Flex, { direction: "column", gap: "1", children: options.map((item) => /* @__PURE__ */ jsx(
|
|
128
|
+
Button,
|
|
129
|
+
{
|
|
130
|
+
className: "react-datepicker_dropdown_item",
|
|
131
|
+
color: "gray",
|
|
132
|
+
"data-year-month-dropdown-tiem": item,
|
|
133
|
+
onClick: () => {
|
|
134
|
+
onSelect(item);
|
|
135
|
+
},
|
|
136
|
+
onMouseDown: (e) => {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
},
|
|
140
|
+
variant: "transparent",
|
|
141
|
+
children: /* @__PURE__ */ jsxs(Typo, { weight: item === selectedValue ? "bold" : void 0, children: [
|
|
142
|
+
item,
|
|
143
|
+
suffix
|
|
144
|
+
] })
|
|
145
|
+
},
|
|
146
|
+
item
|
|
147
|
+
)) })
|
|
148
|
+
}
|
|
149
|
+
) })
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
var getRenderCustomHeader = (props) => {
|
|
153
|
+
const renderer = (renderCustomHeaderProps) => {
|
|
154
|
+
const {
|
|
155
|
+
date,
|
|
156
|
+
decreaseMonth,
|
|
157
|
+
increaseMonth,
|
|
158
|
+
prevMonthButtonDisabled,
|
|
159
|
+
nextMonthButtonDisabled,
|
|
160
|
+
changeYear,
|
|
161
|
+
changeMonth
|
|
162
|
+
} = renderCustomHeaderProps;
|
|
163
|
+
const {
|
|
164
|
+
years,
|
|
165
|
+
isYearDropdownOpen,
|
|
166
|
+
setIsYearDropdownOpen,
|
|
167
|
+
isMonthDropdownOpen,
|
|
168
|
+
setIsMonthDropdownOpen
|
|
169
|
+
} = props;
|
|
170
|
+
const year = date ? new Date(date).getFullYear() : "-";
|
|
171
|
+
const month = date ? new Date(date).getMonth() + 1 : "-";
|
|
172
|
+
return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", pl: "2", pr: "2", children: [
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
IconButton,
|
|
175
|
+
{
|
|
176
|
+
className: "react-datepicker_dropdown_header",
|
|
177
|
+
disabled: prevMonthButtonDisabled,
|
|
178
|
+
onClick: decreaseMonth,
|
|
179
|
+
type: "button",
|
|
180
|
+
variant: "ghost",
|
|
181
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsxs(Flex, { gap: "3", children: [
|
|
185
|
+
/* @__PURE__ */ jsx(
|
|
186
|
+
DropdownSelector,
|
|
187
|
+
{
|
|
188
|
+
isOpen: isYearDropdownOpen,
|
|
189
|
+
onOpenChange: setIsYearDropdownOpen,
|
|
190
|
+
onSelect: (value) => {
|
|
191
|
+
changeYear(value);
|
|
192
|
+
setIsYearDropdownOpen(false);
|
|
193
|
+
},
|
|
194
|
+
options: years,
|
|
195
|
+
selectedValue: year,
|
|
196
|
+
suffix: "\uB144"
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ jsx(
|
|
200
|
+
DropdownSelector,
|
|
201
|
+
{
|
|
202
|
+
isOpen: isMonthDropdownOpen,
|
|
203
|
+
onOpenChange: setIsMonthDropdownOpen,
|
|
204
|
+
onSelect: (value) => {
|
|
205
|
+
changeMonth(value - 1);
|
|
206
|
+
setIsMonthDropdownOpen(false);
|
|
207
|
+
},
|
|
208
|
+
options: Array.from({ length: 12 }, (_, index) => index + 1),
|
|
209
|
+
selectedValue: month,
|
|
210
|
+
suffix: "\uC6D4"
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ jsx(
|
|
215
|
+
IconButton,
|
|
216
|
+
{
|
|
217
|
+
className: "react-datepicker_dropdown_header",
|
|
218
|
+
disabled: nextMonthButtonDisabled,
|
|
219
|
+
onClick: increaseMonth,
|
|
220
|
+
type: "button",
|
|
221
|
+
variant: "ghost",
|
|
222
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] });
|
|
226
|
+
};
|
|
227
|
+
return renderer;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export {
|
|
231
|
+
DatePicker
|
|
232
|
+
};
|
|
233
|
+
//# sourceMappingURL=chunk-7BLUAQBV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/molecules/date-picker/index.tsx"],"sourcesContent":["import type { ElementRef } from 'react';\nimport React, { forwardRef, useMemo, useState, useEffect, useRef } from 'react';\nimport type { DatePickerProps as ReactDatePickerProps } from 'react-datepicker';\nimport ReactDatePicker from 'react-datepicker';\nimport { ko } from 'date-fns/locale';\nimport { Box } from '@/atoms/box';\nimport { Button } from '@/atoms/button';\nimport { Popover } from '@/atoms/popover';\nimport { Typo } from '@/atoms/typo';\nimport { IconButton } from '../../atoms/icon-button';\nimport { Flex } from '../../atoms/flex';\nimport { ChevronLeftIcon, ChevronRightIcon } from '../../icon';\nimport { Heading } from '../../atoms/heading';\n\nexport type DatePickerProps = ReactDatePickerProps & {\n fullWidth?: boolean;\n};\ntype DatePickerRef = ElementRef<typeof ReactDatePicker>;\n\nexport const DatePicker = forwardRef<DatePickerRef, DatePickerProps>(\n (props, ref): React.ReactNode => {\n const { fullWidth, ...rest } = props;\n const fullWidthClassName = fullWidth ? 'full-width' : '';\n const [isYearDropdownOpen, setIsYearDropdownOpen] = useState(false);\n const [isMonthDropdownOpen, setIsMonthDropdownOpen] = useState(false);\n\n const renderCustomHeader = useMemo(() => {\n const getYears = (): number[] => {\n const currentYear = new Date().getFullYear();\n return Array.from(\n { length: currentYear + 5 - 1920 },\n (_, index) => 1920 + index\n ).filter((year) => {\n if (props.minDate && year < props.minDate.getFullYear()) {\n return false;\n }\n if (props.maxDate && year > props.maxDate.getFullYear()) {\n return false;\n }\n return true;\n });\n };\n\n return getRenderCustomHeader({\n ...props,\n years: getYears(),\n isYearDropdownOpen,\n setIsYearDropdownOpen,\n isMonthDropdownOpen,\n setIsMonthDropdownOpen,\n });\n }, [isMonthDropdownOpen, isYearDropdownOpen, props]);\n\n return (\n <Flex p=\"0\" width=\"100%\">\n <ReactDatePicker\n dateFormat=\"yyyy/MM/dd h:mm aa\"\n formatWeekDay={(nameOfDay) => {\n return nameOfDay[0];\n }}\n locale={ko}\n nextMonthButtonLabel=\"다음 달\"\n placeholderText=\"YYYY/MM/DD hh:mm AM/PM\"\n popperProps={{ strategy: 'fixed' }}\n previousMonthButtonLabel=\"이전 달\"\n ref={ref}\n renderCustomHeader={renderCustomHeader}\n showPopperArrow={false}\n timeCaption=\"시간\"\n timeFormat=\"aa h:mm\"\n timeIntervals={10}\n {...rest}\n calendarClassName={`tipp_datePicker_calendar ${rest.calendarClassName || ''}`}\n wrapperClassName={`tipp_datePicker ${fullWidthClassName} ${rest.wrapperClassName || ''}`}\n />\n </Flex>\n );\n }\n);\n\nDatePicker.displayName = 'DatePicker';\n\ninterface DropdownSelectorProps {\n isOpen: boolean;\n onOpenChange: (open: boolean) => void;\n onSelect: (value: number) => void;\n options: number[];\n selectedValue: number | string;\n suffix: string;\n}\n\nfunction DropdownSelector({\n isOpen,\n onOpenChange,\n onSelect,\n options,\n selectedValue,\n suffix,\n}: DropdownSelectorProps): React.JSX.Element {\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (isOpen) {\n queueMicrotask(() => {\n const item = scrollContainerRef.current?.querySelector(\n `[data-year-month-dropdown-tiem=\"${selectedValue}\"]`\n );\n if (item) {\n item.scrollIntoView({ behavior: 'instant' });\n }\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- 트리거 최적화\n }, [isOpen]);\n\n return (\n <Popover.Root modal onOpenChange={onOpenChange} open={isOpen}>\n <Popover.Trigger>\n <Button className=\"react-datepicker_dropdown_header\" variant=\"ghost\">\n <Heading variant=\"heading4\" weight=\"regular\">\n {selectedValue}\n {suffix}\n </Heading>\n </Button>\n </Popover.Trigger>\n <Popover.Content side=\"bottom\">\n <Box\n maxHeight=\"200px\"\n overflowY=\"auto\"\n ref={scrollContainerRef}\n style={{ scrollbarWidth: 'none' }}\n >\n <Flex direction=\"column\" gap=\"1\">\n {options.map((item: number) => (\n <Button\n className=\"react-datepicker_dropdown_item\"\n color=\"gray\"\n data-year-month-dropdown-tiem={item}\n key={item}\n onClick={() => {\n onSelect(item);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n variant=\"transparent\"\n >\n <Typo weight={item === selectedValue ? 'bold' : undefined}>\n {item}\n {suffix}\n </Typo>\n </Button>\n ))}\n </Flex>\n </Box>\n </Popover.Content>\n </Popover.Root>\n );\n}\n\nconst getRenderCustomHeader: (\n props: ReactDatePickerProps & {\n years: number[];\n isYearDropdownOpen: boolean;\n setIsYearDropdownOpen: (show: boolean) => void;\n isMonthDropdownOpen: boolean;\n setIsMonthDropdownOpen: (show: boolean) => void;\n }\n) => ReactDatePickerProps['renderCustomHeader'] = (props) => {\n const renderer: ReactDatePickerProps['renderCustomHeader'] = (\n renderCustomHeaderProps\n ) => {\n const {\n date,\n decreaseMonth,\n increaseMonth,\n prevMonthButtonDisabled,\n nextMonthButtonDisabled,\n changeYear,\n changeMonth,\n } = renderCustomHeaderProps;\n const {\n years,\n isYearDropdownOpen,\n setIsYearDropdownOpen,\n isMonthDropdownOpen,\n setIsMonthDropdownOpen,\n } = props;\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- date가 undefined일 수 있음\n const year = date ? new Date(date).getFullYear() : '-';\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- date가 undefined일 수 있음\n const month = date ? new Date(date).getMonth() + 1 : '-';\n\n return (\n <Flex align=\"center\" justify=\"between\" pl=\"2\" pr=\"2\">\n <IconButton\n className=\"react-datepicker_dropdown_header\"\n disabled={prevMonthButtonDisabled}\n onClick={decreaseMonth}\n type=\"button\"\n variant=\"ghost\"\n >\n <ChevronLeftIcon />\n </IconButton>\n <Flex gap=\"3\">\n <DropdownSelector\n isOpen={isYearDropdownOpen}\n onOpenChange={setIsYearDropdownOpen}\n onSelect={(value) => {\n changeYear(value);\n setIsYearDropdownOpen(false);\n }}\n options={years}\n selectedValue={year}\n suffix=\"년\"\n />\n <DropdownSelector\n isOpen={isMonthDropdownOpen}\n onOpenChange={setIsMonthDropdownOpen}\n onSelect={(value) => {\n changeMonth(value - 1);\n setIsMonthDropdownOpen(false);\n }}\n options={Array.from({ length: 12 }, (_, index) => index + 1)}\n selectedValue={month}\n suffix=\"월\"\n />\n </Flex>\n\n <IconButton\n className=\"react-datepicker_dropdown_header\"\n disabled={nextMonthButtonDisabled}\n onClick={increaseMonth}\n type=\"button\"\n variant=\"ghost\"\n >\n <ChevronRightIcon />\n </IconButton>\n </Flex>\n );\n };\n return renderer;\n};\n\n// DatePicker.displayName =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;AAAA,UAAC;AAAA;AAAA,YACC,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,UAAU,CAAC,UAAU;AACnB,0BAAY,QAAQ,CAAC;AACrB,qCAAuB,KAAK;AAAA,YAC9B;AAAA,YACA,SAAS,MAAM,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAC,GAAG,UAAU,QAAQ,CAAC;AAAA,YAC3D,eAAe;AAAA,YACf,QAAO;AAAA;AAAA,QACT;AAAA,SACF;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,UAAU;AAAA,UACV,SAAS;AAAA,UACT,MAAK;AAAA,UACL,SAAQ;AAAA,UAER,8BAAC,oBAAiB;AAAA;AAAA,MACpB;AAAA,OACF;AAAA,EAEJ;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ScrollArea
|
|
3
|
+
} from "./chunk-MUPK4L3U.js";
|
|
4
|
+
import {
|
|
5
|
+
Popover
|
|
6
|
+
} from "./chunk-5AVBYDPB.js";
|
|
7
|
+
import {
|
|
8
|
+
Grid
|
|
9
|
+
} from "./chunk-EGEQY3KT.js";
|
|
10
|
+
import {
|
|
11
|
+
Typo
|
|
12
|
+
} from "./chunk-PMJIFLDT.js";
|
|
13
|
+
import {
|
|
14
|
+
Flex
|
|
15
|
+
} from "./chunk-25HMMI7R.js";
|
|
16
|
+
import {
|
|
17
|
+
Button
|
|
18
|
+
} from "./chunk-ZVDAEY5Q.js";
|
|
19
|
+
import {
|
|
20
|
+
CheckIcon
|
|
21
|
+
} from "./chunk-R7IT4TCD.js";
|
|
22
|
+
import {
|
|
23
|
+
AutoSizingInput
|
|
24
|
+
} from "./chunk-6SYFG6YY.js";
|
|
25
|
+
import {
|
|
26
|
+
Badge
|
|
27
|
+
} from "./chunk-U3BQT7ZO.js";
|
|
28
|
+
|
|
29
|
+
// src/molecules/tag-selector.tsx
|
|
30
|
+
import {
|
|
31
|
+
useCallback,
|
|
32
|
+
useEffect,
|
|
33
|
+
useMemo,
|
|
34
|
+
useRef,
|
|
35
|
+
useState
|
|
36
|
+
} from "react";
|
|
37
|
+
import {
|
|
38
|
+
ChevronRightIcon,
|
|
39
|
+
Cross1Icon,
|
|
40
|
+
MagnifyingGlassIcon
|
|
41
|
+
} from "@radix-ui/react-icons";
|
|
42
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
43
|
+
var OPTION_HEIGHT = 32;
|
|
44
|
+
var stopDefaultEvents = (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
};
|
|
48
|
+
var DefaultDropdownContainer = (props) => {
|
|
49
|
+
return props.children;
|
|
50
|
+
};
|
|
51
|
+
function TagSelector(props) {
|
|
52
|
+
const {
|
|
53
|
+
options = [],
|
|
54
|
+
tagRender,
|
|
55
|
+
placeholder,
|
|
56
|
+
maxCount = 0,
|
|
57
|
+
DropdownContainer = DefaultDropdownContainer,
|
|
58
|
+
size = "medium",
|
|
59
|
+
readOnly,
|
|
60
|
+
error,
|
|
61
|
+
open: propsOpen,
|
|
62
|
+
dropdownItemRender
|
|
63
|
+
} = props;
|
|
64
|
+
const [_selected, _setSelected] = useState(props.selected || []);
|
|
65
|
+
const selected = props.selected || _selected;
|
|
66
|
+
const setSelected = props.onChange || _setSelected;
|
|
67
|
+
const [value, setValue] = useState("");
|
|
68
|
+
const [focusIndex, setFocusIndex] = useState(null);
|
|
69
|
+
const [open, setOpen] = useState(false);
|
|
70
|
+
const [focus, setFocus] = useState(false);
|
|
71
|
+
const fieldRef = useRef(null);
|
|
72
|
+
const scrollRef = useRef(null);
|
|
73
|
+
const closeRef = useRef(null);
|
|
74
|
+
const onFocus = useCallback(() => {
|
|
75
|
+
if (closeRef.current) {
|
|
76
|
+
clearTimeout(closeRef.current);
|
|
77
|
+
}
|
|
78
|
+
setFocus(true);
|
|
79
|
+
setOpen(true);
|
|
80
|
+
}, []);
|
|
81
|
+
const onBlur = useCallback(() => {
|
|
82
|
+
closeRef.current = setTimeout(() => {
|
|
83
|
+
setFocus(false);
|
|
84
|
+
setOpen(false);
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
setValue("");
|
|
87
|
+
}, 100);
|
|
88
|
+
}, 300);
|
|
89
|
+
}, []);
|
|
90
|
+
const onChangeValue = useCallback(
|
|
91
|
+
(e) => {
|
|
92
|
+
setValue(e.target.value);
|
|
93
|
+
},
|
|
94
|
+
[]
|
|
95
|
+
);
|
|
96
|
+
const filteredOptions = useMemo(() => {
|
|
97
|
+
return options.filter((option) => {
|
|
98
|
+
return option.name.includes(value);
|
|
99
|
+
});
|
|
100
|
+
}, [options, value]);
|
|
101
|
+
const selectedItem = useMemo(() => {
|
|
102
|
+
const result = [];
|
|
103
|
+
selected.forEach((id) => {
|
|
104
|
+
const maybeItem = options.find((option) => option.id === id);
|
|
105
|
+
if (maybeItem) result.push(maybeItem);
|
|
106
|
+
});
|
|
107
|
+
return result;
|
|
108
|
+
}, [options, selected]);
|
|
109
|
+
const onDelete = useCallback(
|
|
110
|
+
(id) => {
|
|
111
|
+
setSelected(selected.filter((el) => el !== id));
|
|
112
|
+
},
|
|
113
|
+
[selected, setSelected]
|
|
114
|
+
);
|
|
115
|
+
const onSelect = useCallback(
|
|
116
|
+
(id) => {
|
|
117
|
+
if (maxCount && selected.length + 1 > maxCount) return;
|
|
118
|
+
setSelected([...selected, id]);
|
|
119
|
+
},
|
|
120
|
+
[maxCount, selected, setSelected]
|
|
121
|
+
);
|
|
122
|
+
const toggleItem = useCallback(
|
|
123
|
+
(id) => {
|
|
124
|
+
if (selected.includes(id)) {
|
|
125
|
+
onDelete(id);
|
|
126
|
+
} else {
|
|
127
|
+
onSelect(id);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
[onDelete, onSelect, selected]
|
|
131
|
+
);
|
|
132
|
+
const setScroll = useCallback((index) => {
|
|
133
|
+
if (scrollRef.current) {
|
|
134
|
+
const scrollTop = scrollRef.current.scrollTop;
|
|
135
|
+
const clientHeight = scrollRef.current.clientHeight;
|
|
136
|
+
const focusTop = index * OPTION_HEIGHT;
|
|
137
|
+
if (focusTop < scrollTop) {
|
|
138
|
+
scrollRef.current.scrollTop = focusTop;
|
|
139
|
+
} else if (focusTop + OPTION_HEIGHT > scrollTop + clientHeight) {
|
|
140
|
+
scrollRef.current.scrollTop = focusTop + OPTION_HEIGHT - clientHeight;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, []);
|
|
144
|
+
const handleKeyDown = useCallback(
|
|
145
|
+
(e) => {
|
|
146
|
+
var _a;
|
|
147
|
+
const key = e.key;
|
|
148
|
+
switch (key) {
|
|
149
|
+
case "ArrowDown": {
|
|
150
|
+
stopDefaultEvents(e);
|
|
151
|
+
let newFocus = 0;
|
|
152
|
+
if (typeof focusIndex === "number") {
|
|
153
|
+
newFocus = focusIndex + 1 >= options.length ? 0 : focusIndex + 1;
|
|
154
|
+
}
|
|
155
|
+
setFocusIndex(newFocus);
|
|
156
|
+
setScroll(newFocus);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "ArrowUp": {
|
|
160
|
+
stopDefaultEvents(e);
|
|
161
|
+
let newFocus = 0;
|
|
162
|
+
if (typeof focusIndex === "number") {
|
|
163
|
+
newFocus = focusIndex - 1 < 0 ? options.length - 1 : focusIndex - 1;
|
|
164
|
+
}
|
|
165
|
+
setFocusIndex(newFocus);
|
|
166
|
+
setScroll(newFocus);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case "Enter":
|
|
170
|
+
stopDefaultEvents(e);
|
|
171
|
+
setValue("");
|
|
172
|
+
if (focusIndex !== null) {
|
|
173
|
+
toggleItem((_a = filteredOptions[focusIndex]) == null ? void 0 : _a.id);
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case "Backspace":
|
|
177
|
+
if (value.length === 0) {
|
|
178
|
+
setSelected(selected.slice(0, -1));
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case "Escape":
|
|
182
|
+
stopDefaultEvents(e);
|
|
183
|
+
setOpen(false);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
[
|
|
188
|
+
focusIndex,
|
|
189
|
+
value.length,
|
|
190
|
+
setScroll,
|
|
191
|
+
options.length,
|
|
192
|
+
toggleItem,
|
|
193
|
+
filteredOptions,
|
|
194
|
+
setSelected,
|
|
195
|
+
selected
|
|
196
|
+
]
|
|
197
|
+
);
|
|
198
|
+
const placeholderVisible = useMemo(() => {
|
|
199
|
+
if (selectedItem.length) return false;
|
|
200
|
+
if (value) return false;
|
|
201
|
+
if (focus) return false;
|
|
202
|
+
return true;
|
|
203
|
+
}, [focus, selectedItem.length, value]);
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
setFocusIndex(null);
|
|
206
|
+
}, [open]);
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
setFocusIndex(0);
|
|
209
|
+
}, [filteredOptions]);
|
|
210
|
+
const badgeSize = useMemo(() => {
|
|
211
|
+
switch (size) {
|
|
212
|
+
case "large":
|
|
213
|
+
return "large";
|
|
214
|
+
case "medium":
|
|
215
|
+
case "small":
|
|
216
|
+
default:
|
|
217
|
+
return "small";
|
|
218
|
+
}
|
|
219
|
+
}, [size]);
|
|
220
|
+
const placeholderVariant = useMemo(() => {
|
|
221
|
+
switch (size) {
|
|
222
|
+
case "large":
|
|
223
|
+
return "subtitle";
|
|
224
|
+
case "medium":
|
|
225
|
+
default:
|
|
226
|
+
return "body";
|
|
227
|
+
}
|
|
228
|
+
}, [size]);
|
|
229
|
+
const focusClassName = focus ? " focused" : "";
|
|
230
|
+
const readOnlyClassName = readOnly ? " read-only" : "";
|
|
231
|
+
const errorClassName = error ? " error" : "";
|
|
232
|
+
const readonlyContent = /* @__PURE__ */ jsx(Flex, { gap: "1", children: selectedItem.map((item) => {
|
|
233
|
+
return tagRender ? tagRender(item) : /* @__PURE__ */ jsx(Badge, { size: badgeSize, children: item.name }, item.id);
|
|
234
|
+
}) });
|
|
235
|
+
const editContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
236
|
+
/* @__PURE__ */ jsxs(
|
|
237
|
+
Flex,
|
|
238
|
+
{
|
|
239
|
+
align: "center",
|
|
240
|
+
gap: "1",
|
|
241
|
+
maxWidth: "100%",
|
|
242
|
+
overflow: "hidden",
|
|
243
|
+
wrap: "wrap",
|
|
244
|
+
children: [
|
|
245
|
+
selectedItem.map((item) => {
|
|
246
|
+
return tagRender ? tagRender(item, () => {
|
|
247
|
+
onDelete(item.id);
|
|
248
|
+
}) : /* @__PURE__ */ jsxs(Badge, { size: badgeSize, children: [
|
|
249
|
+
item.name,
|
|
250
|
+
/* @__PURE__ */ jsx(
|
|
251
|
+
Button,
|
|
252
|
+
{
|
|
253
|
+
onClick: () => {
|
|
254
|
+
onDelete(item.id);
|
|
255
|
+
},
|
|
256
|
+
variant: "transparent",
|
|
257
|
+
children: /* @__PURE__ */ jsx(Cross1Icon, {})
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
] }, item.id);
|
|
261
|
+
}),
|
|
262
|
+
placeholderVisible ? /* @__PURE__ */ jsx(Typo, { color: "gray", variant: placeholderVariant, children: placeholder }) : null,
|
|
263
|
+
/* @__PURE__ */ jsx(
|
|
264
|
+
AutoSizingInput,
|
|
265
|
+
{
|
|
266
|
+
onBlur,
|
|
267
|
+
onChange: onChangeValue,
|
|
268
|
+
onFocus,
|
|
269
|
+
onKeyDown: handleKeyDown,
|
|
270
|
+
ref: fieldRef,
|
|
271
|
+
value
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
focus ? /* @__PURE__ */ jsx(MagnifyingGlassIcon, {}) : /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
278
|
+
] });
|
|
279
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { open: Boolean(filteredOptions.length) && propsOpen || open, children: [
|
|
280
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { style: { position: "relative" }, children: /* @__PURE__ */ jsx(
|
|
281
|
+
Grid,
|
|
282
|
+
{
|
|
283
|
+
align: "center",
|
|
284
|
+
className: `tag-selector ${size} ${focusClassName}${readOnlyClassName}${errorClassName}`,
|
|
285
|
+
columns: "1fr auto",
|
|
286
|
+
gap: "1",
|
|
287
|
+
onClick: () => {
|
|
288
|
+
var _a;
|
|
289
|
+
return !readOnly && ((_a = fieldRef.current) == null ? void 0 : _a.focus());
|
|
290
|
+
},
|
|
291
|
+
children: readOnly ? readonlyContent : editContent
|
|
292
|
+
}
|
|
293
|
+
) }),
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
Popover.Content,
|
|
296
|
+
{
|
|
297
|
+
onOpenAutoFocus: preventDefault,
|
|
298
|
+
onTouchMove: stopPropagationTouch,
|
|
299
|
+
onWheel: stopPropagationWheel,
|
|
300
|
+
sticky: "always",
|
|
301
|
+
style: {
|
|
302
|
+
pointerEvents: "fill"
|
|
303
|
+
},
|
|
304
|
+
children: /* @__PURE__ */ jsx(
|
|
305
|
+
DropdownContainer,
|
|
306
|
+
{
|
|
307
|
+
currentItem: filteredOptions[focusIndex || 0],
|
|
308
|
+
items: filteredOptions,
|
|
309
|
+
children: /* @__PURE__ */ jsx(
|
|
310
|
+
ScrollArea,
|
|
311
|
+
{
|
|
312
|
+
ref: scrollRef,
|
|
313
|
+
scrollbars: "vertical",
|
|
314
|
+
style: { height: OPTION_HEIGHT * 8 },
|
|
315
|
+
type: "auto",
|
|
316
|
+
children: /* @__PURE__ */ jsx(Flex, { direction: "column", children: filteredOptions.map((item, i) => {
|
|
317
|
+
const isSelected = Boolean(
|
|
318
|
+
selected.find((el) => el === item.id)
|
|
319
|
+
);
|
|
320
|
+
const isFocus = i === focusIndex;
|
|
321
|
+
return /* @__PURE__ */ jsx(
|
|
322
|
+
Button,
|
|
323
|
+
{
|
|
324
|
+
className: `tag-selector-button ${isFocus ? "focused" : ""}`,
|
|
325
|
+
onClick: () => {
|
|
326
|
+
var _a;
|
|
327
|
+
toggleItem(item.id);
|
|
328
|
+
(_a = fieldRef.current) == null ? void 0 : _a.focus();
|
|
329
|
+
},
|
|
330
|
+
onMouseEnter: () => {
|
|
331
|
+
setFocusIndex(i);
|
|
332
|
+
},
|
|
333
|
+
variant: isSelected ? "soft" : "outline",
|
|
334
|
+
children: /* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", children: [
|
|
335
|
+
dropdownItemRender ? dropdownItemRender(item) : item.name,
|
|
336
|
+
isSelected ? /* @__PURE__ */ jsx(CheckIcon, {}) : null
|
|
337
|
+
] })
|
|
338
|
+
},
|
|
339
|
+
item.id
|
|
340
|
+
);
|
|
341
|
+
}) })
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
] });
|
|
349
|
+
}
|
|
350
|
+
var stopPropagationTouch = (e) => {
|
|
351
|
+
e.stopPropagation();
|
|
352
|
+
};
|
|
353
|
+
var stopPropagationWheel = (e) => {
|
|
354
|
+
e.stopPropagation();
|
|
355
|
+
};
|
|
356
|
+
var preventDefault = (e) => {
|
|
357
|
+
e.preventDefault();
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
export {
|
|
361
|
+
TagSelector
|
|
362
|
+
};
|
|
363
|
+
//# sourceMappingURL=chunk-7IBUQ5XL.js.map
|