@musecat/uikit 0.1.1
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/LICENSE +9 -0
- package/README.md +51 -0
- package/index.ts +78 -0
- package/package.json +103 -0
- package/packages/Components/Box/Box.tsx +173 -0
- package/packages/Components/Box/Box.types.ts +48 -0
- package/packages/Components/Button/Button.tsx +275 -0
- package/packages/Components/Button/Button.types.ts +44 -0
- package/packages/Components/Card/Card.default.tsx +180 -0
- package/packages/Components/Card/Card.foldable.tsx +383 -0
- package/packages/Components/Card/Card.module.scss +23 -0
- package/packages/Components/Card/Card.tsx +8 -0
- package/packages/Components/Card/Card.types.ts +91 -0
- package/packages/Components/Card/Card.utils.ts +66 -0
- package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
- package/packages/Components/Checkbox/Checkbox.tsx +104 -0
- package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
- package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
- package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
- package/packages/Components/CodeBox/CodeBox.tsx +91 -0
- package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
- package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
- package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
- package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
- package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
- package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
- package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
- package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
- package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
- package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
- package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
- package/packages/Components/DatePicker/DatePicker.tsx +786 -0
- package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
- package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
- package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
- package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
- package/packages/Components/Divider/Divider.tsx +46 -0
- package/packages/Components/Divider/Divider.types.ts +12 -0
- package/packages/Components/Header/Header.module.scss +74 -0
- package/packages/Components/Header/Header.tsx +47 -0
- package/packages/Components/Header/Header.types.ts +8 -0
- package/packages/Components/Icon/Icon.group.tsx +122 -0
- package/packages/Components/Icon/Icon.group.types.ts +20 -0
- package/packages/Components/Icon/Icon.tsx +341 -0
- package/packages/Components/Icon/Icon.types.ts +59 -0
- package/packages/Components/Icon/SVG/data.tsx +232 -0
- package/packages/Components/Input/Input.module.scss +5 -0
- package/packages/Components/Input/Input.tsx +87 -0
- package/packages/Components/Input/Input.types.ts +14 -0
- package/packages/Components/Label/Label.module.scss +19 -0
- package/packages/Components/Label/Label.tsx +115 -0
- package/packages/Components/Label/Label.types.ts +28 -0
- package/packages/Components/Layout/Layout.docs.module.scss +42 -0
- package/packages/Components/Layout/Layout.docs.tsx +150 -0
- package/packages/Components/Layout/Layout.docs.types.ts +18 -0
- package/packages/Components/Layout/Layout.module.scss +91 -0
- package/packages/Components/Layout/Layout.tsx +306 -0
- package/packages/Components/Layout/Layout.types.ts +71 -0
- package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
- package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
- package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
- package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
- package/packages/Components/Nav/Nav.module.scss +137 -0
- package/packages/Components/Nav/Nav.tsx +304 -0
- package/packages/Components/Nav/Nav.types.ts +32 -0
- package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
- package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
- package/packages/Components/Pagination/Pagination.tsx +254 -0
- package/packages/Components/Pagination/Pagination.types.ts +18 -0
- package/packages/Components/Pill/Pill.tsx +127 -0
- package/packages/Components/Pill/Pill.types.ts +33 -0
- package/packages/Components/Profile/Profile.shared.ts +74 -0
- package/packages/Components/Profile/Profile.tsx +382 -0
- package/packages/Components/Profile/Profile.types.ts +55 -0
- package/packages/Components/Progress/Progress.module.scss +15 -0
- package/packages/Components/Progress/Progress.tsx +88 -0
- package/packages/Components/Progress/Progress.types.ts +22 -0
- package/packages/Components/Radio/Radio.module.scss +11 -0
- package/packages/Components/Radio/Radio.tsx +121 -0
- package/packages/Components/Radio/Radio.types.ts +20 -0
- package/packages/Components/Select/Select.keyboard.tsx +76 -0
- package/packages/Components/Select/Select.trigger.tsx +88 -0
- package/packages/Components/Select/Select.tsx +11 -0
- package/packages/Components/Select/Select.types.ts +38 -0
- package/packages/Components/Select/Select.utils.ts +84 -0
- package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
- package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
- package/packages/Components/Select/hooks/useSelectState.ts +314 -0
- package/packages/Components/Select/select.control.tsx +228 -0
- package/packages/Components/Select/select.inner.tsx +312 -0
- package/packages/Components/Skeleton/Skeleton.tsx +30 -0
- package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
- package/packages/Components/Spinner/Spinner.module.scss +78 -0
- package/packages/Components/Spinner/Spinner.tsx +125 -0
- package/packages/Components/Spinner/Spinner.types.ts +19 -0
- package/packages/Components/Text/Text.module.scss +7 -0
- package/packages/Components/Text/Text.tsx +49 -0
- package/packages/Components/Text/Text.types.ts +33 -0
- package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
- package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
- package/packages/Components/TimePicker/TimePicker.tsx +511 -0
- package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
- package/packages/Components/Timeline/Timeline.tsx +111 -0
- package/packages/Components/Timeline/Timeline.types.ts +23 -0
- package/packages/Components/Title/Title.tsx +305 -0
- package/packages/Components/Title/Title.types.ts +64 -0
- package/packages/Components/Toggle/Toggle.module.scss +32 -0
- package/packages/Components/Toggle/Toggle.tsx +272 -0
- package/packages/Components/Toggle/Toggle.types.ts +17 -0
- package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
- package/packages/Components/Tooltip/Tooltip.tsx +340 -0
- package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
- package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
- package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
- package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
- package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
- package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
- package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
- package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
- package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
- package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
- package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
- package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
- package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
- package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
- package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
- package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
- package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
- package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
- package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
- package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
- package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
- package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
- package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
- package/packages/Frameworks/Theme/Radius.types.ts +55 -0
- package/packages/Frameworks/Theme/Theme.types.ts +325 -0
- package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
- package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
- package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
- package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
- package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
- package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
- package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
- package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
- package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
- package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
- package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
- package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
- package/packages/Frameworks/View/View.module.scss +34 -0
- package/packages/Frameworks/View/View.tsx +200 -0
- package/packages/Frameworks/View/View.types.ts +36 -0
- package/packages/Frameworks/_shared/Padding.types.ts +52 -0
- package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
- package/packages/Frameworks/_shared/Wind.types.ts +17 -0
- package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
- package/packages/Frameworks/_shared/layer.constants.ts +8 -0
- package/packages/Frameworks/_shared/normalize.ts +39 -0
- package/packages/Frameworks/_shared/sizing.ts +55 -0
- package/packages/Frameworks/_shared/useControllableState.ts +29 -0
- package/packages/Styles/_animation.scss +42 -0
- package/packages/Styles/_color.scss +131 -0
- package/packages/Styles/_font.scss +30 -0
- package/packages/Styles/_icon.scss +782 -0
- package/packages/Styles/_importer.scss +9 -0
- package/packages/Styles/_system.scss +69 -0
- package/packages/Styles/_textstyle.scss +111 -0
- package/packages/Styles/_theme.scss +452 -0
- package/packages/Styles/_viewport-global.scss +99 -0
- package/packages/Styles/_viewport.scss +108 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import Button from "@/packages/Components/Button/Button";
|
|
5
|
+
import type { DialogFooterConfig } from "@/packages/Frameworks/Dialog/Dialog.types";
|
|
6
|
+
import Pressable from "@/packages/Frameworks/Pressable/Pressable";
|
|
7
|
+
import View from "@/packages/Frameworks/View/View";
|
|
8
|
+
|
|
9
|
+
interface DialogFooterProps {
|
|
10
|
+
config?: DialogFooterConfig;
|
|
11
|
+
exitButton?: ReactNode;
|
|
12
|
+
onExit?: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function DialogFooter({
|
|
16
|
+
config,
|
|
17
|
+
exitButton,
|
|
18
|
+
onExit,
|
|
19
|
+
}: DialogFooterProps) {
|
|
20
|
+
if (!config && !exitButton) return null;
|
|
21
|
+
|
|
22
|
+
const renderExitButton = () => {
|
|
23
|
+
if (!exitButton) return null;
|
|
24
|
+
if (exitButton === true) {
|
|
25
|
+
return (
|
|
26
|
+
<Button
|
|
27
|
+
text="닫기"
|
|
28
|
+
themePreset="UISecondary"
|
|
29
|
+
pressable={{ onClick: onExit }}
|
|
30
|
+
style={{ flex: config?.buttonCondensed ? "0 0 auto" : "1 1 0" }}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return (
|
|
35
|
+
<Pressable style={{ display: "contents" }} onClick={onExit}>
|
|
36
|
+
{exitButton}
|
|
37
|
+
</Pressable>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const isColumn = !!config?.columnLayout;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<View
|
|
45
|
+
row={!isColumn}
|
|
46
|
+
column={isColumn}
|
|
47
|
+
alignItems={isColumn ? "stretch" : "center"}
|
|
48
|
+
gap={12}
|
|
49
|
+
padding={4}
|
|
50
|
+
width="100%"
|
|
51
|
+
>
|
|
52
|
+
{config?.content && (
|
|
53
|
+
<View style={{ flex: "1 1 auto", minWidth: 0 }}>{config.content}</View>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
{(config?.buttons?.length || exitButton) && (
|
|
57
|
+
<View
|
|
58
|
+
row={!isColumn}
|
|
59
|
+
column={isColumn}
|
|
60
|
+
gap={8}
|
|
61
|
+
justifyContent="flex-end"
|
|
62
|
+
style={{ flex: "1 1 auto" }}
|
|
63
|
+
>
|
|
64
|
+
{renderExitButton()}
|
|
65
|
+
{config?.buttons?.map(({ key, ...button }) => (
|
|
66
|
+
<Button
|
|
67
|
+
key={key ?? String(button.text)}
|
|
68
|
+
{...button}
|
|
69
|
+
style={{
|
|
70
|
+
flex: config?.buttonCondensed ? "0 0 auto" : "1 1 0",
|
|
71
|
+
...button.style,
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
))}
|
|
75
|
+
</View>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import Button from "@/packages/Components/Button/Button";
|
|
5
|
+
import Icon from "@/packages/Components/Icon/Icon";
|
|
6
|
+
import Text from "@/packages/Components/Text/Text";
|
|
7
|
+
import type {
|
|
8
|
+
FunnelConfig,
|
|
9
|
+
FunnelHistory,
|
|
10
|
+
FunnelStepConfig,
|
|
11
|
+
} from "@/packages/Frameworks/Dialog/Dialog.types";
|
|
12
|
+
import Pressable from "@/packages/Frameworks/Pressable/Pressable";
|
|
13
|
+
import View from "@/packages/Frameworks/View/View";
|
|
14
|
+
|
|
15
|
+
interface DialogFunnelProps {
|
|
16
|
+
config: FunnelConfig;
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
isMobile: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function DialogFunnel({
|
|
22
|
+
config,
|
|
23
|
+
onClose,
|
|
24
|
+
isMobile,
|
|
25
|
+
}: DialogFunnelProps) {
|
|
26
|
+
const [stepIndex, setStepIndex] = useState(0);
|
|
27
|
+
const currentStep = config.steps[stepIndex] as FunnelStepConfig | undefined;
|
|
28
|
+
|
|
29
|
+
const history = useMemo<FunnelHistory>(() => {
|
|
30
|
+
return {
|
|
31
|
+
push: (step: string) => {
|
|
32
|
+
const nextIdx = config.steps.findIndex((s) => s.name === step);
|
|
33
|
+
if (nextIdx >= 0) setStepIndex(nextIdx);
|
|
34
|
+
},
|
|
35
|
+
replace: (step: string) => {
|
|
36
|
+
const nextIdx = config.steps.findIndex((s) => s.name === step);
|
|
37
|
+
if (nextIdx >= 0) setStepIndex(nextIdx);
|
|
38
|
+
},
|
|
39
|
+
back: () => {
|
|
40
|
+
if (stepIndex > 0) setStepIndex(stepIndex - 1);
|
|
41
|
+
},
|
|
42
|
+
go: (index: number) => {
|
|
43
|
+
if (index >= 0 && index < config.steps.length) setStepIndex(index);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}, [config.steps, stepIndex]);
|
|
47
|
+
|
|
48
|
+
useMemo(() => {
|
|
49
|
+
config.onMount?.(history);
|
|
50
|
+
}, [config.onMount, history]);
|
|
51
|
+
|
|
52
|
+
if (!currentStep) return null;
|
|
53
|
+
|
|
54
|
+
const isFirstStep = stepIndex === 0;
|
|
55
|
+
const isLastStep = stepIndex === config.steps.length - 1;
|
|
56
|
+
|
|
57
|
+
const navPreset = config.preset ?? "oobe";
|
|
58
|
+
|
|
59
|
+
const getButtonLocations = () => {
|
|
60
|
+
let backLoc: "header" | "footer" = "footer";
|
|
61
|
+
let nextLoc: "header" | "footer" = "footer";
|
|
62
|
+
let exitLoc: "header" | "footer" = "header";
|
|
63
|
+
|
|
64
|
+
if (navPreset === "oobe") {
|
|
65
|
+
if (isMobile) {
|
|
66
|
+
backLoc = "header";
|
|
67
|
+
} else {
|
|
68
|
+
backLoc = "footer";
|
|
69
|
+
nextLoc = "footer";
|
|
70
|
+
exitLoc = "footer";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const resolveLocation = (
|
|
75
|
+
key: "backLocation" | "nextLocation" | "exitLocation",
|
|
76
|
+
fallback: "header" | "footer",
|
|
77
|
+
) => {
|
|
78
|
+
const loc = config.navigation?.[key];
|
|
79
|
+
if (typeof loc === "object") {
|
|
80
|
+
return isMobile ? loc.mobile : loc.pc;
|
|
81
|
+
}
|
|
82
|
+
return loc ?? fallback;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
back: resolveLocation("backLocation", backLoc),
|
|
87
|
+
next: resolveLocation("nextLocation", nextLoc),
|
|
88
|
+
exit: resolveLocation("exitLocation", exitLoc),
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const locations = getButtonLocations();
|
|
93
|
+
|
|
94
|
+
const handleNext = async () => {
|
|
95
|
+
if (currentStep.onNext) {
|
|
96
|
+
const result = await currentStep.onNext();
|
|
97
|
+
if (result === false) return;
|
|
98
|
+
if (typeof result === "string") {
|
|
99
|
+
history.push(result);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!isLastStep) {
|
|
104
|
+
setStepIndex(stepIndex + 1);
|
|
105
|
+
} else {
|
|
106
|
+
config.onFinish?.();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const showBack = !isFirstStep && config.navigation?.back !== false;
|
|
111
|
+
const showNext = config.navigation?.next !== false;
|
|
112
|
+
const showExit = config.navigation?.exit !== false;
|
|
113
|
+
|
|
114
|
+
const renderBackButton = (sizeFull = false) => {
|
|
115
|
+
if (!showBack) return null;
|
|
116
|
+
return (
|
|
117
|
+
<Button
|
|
118
|
+
text="이전"
|
|
119
|
+
themePreset="UISecondary"
|
|
120
|
+
sizeFull={sizeFull}
|
|
121
|
+
pressable={{ onClick: () => history.back() }}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const renderNextButton = (sizeFull = false) => {
|
|
127
|
+
if (!showNext) return null;
|
|
128
|
+
const isSubmit = isLastStep;
|
|
129
|
+
return (
|
|
130
|
+
<Button
|
|
131
|
+
text={isSubmit ? (config.loading ? "제출 중.." : "제출") : "다음"}
|
|
132
|
+
disabled={currentStep.nextDisabled || config.loading}
|
|
133
|
+
sizeFull={sizeFull}
|
|
134
|
+
pressable={{ onClick: handleNext }}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const renderExitButton = (sizeFull = false) => {
|
|
140
|
+
if (!showExit) return null;
|
|
141
|
+
return (
|
|
142
|
+
<Button
|
|
143
|
+
text="닫기"
|
|
144
|
+
themePreset="UISecondary"
|
|
145
|
+
sizeFull={sizeFull}
|
|
146
|
+
pressable={{ onClick: onClose }}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const footerButtons = [];
|
|
152
|
+
if (locations.back === "footer") {
|
|
153
|
+
const btn = renderBackButton();
|
|
154
|
+
if (btn) footerButtons.push({ element: btn, order: 0 });
|
|
155
|
+
}
|
|
156
|
+
if (locations.exit === "footer") {
|
|
157
|
+
const btn = renderExitButton();
|
|
158
|
+
if (btn) footerButtons.push({ element: btn, order: 1 });
|
|
159
|
+
}
|
|
160
|
+
if (locations.next === "footer") {
|
|
161
|
+
const btn = renderNextButton();
|
|
162
|
+
if (btn) footerButtons.push({ element: btn, order: 2 });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const sortedButtons = [...footerButtons].sort((a, b) => {
|
|
166
|
+
return a.order - b.order;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const isFooterColumn = !!config.footer?.columnLayout;
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<View column width="100%" height="100%" style={{ overflow: "hidden" }}>
|
|
173
|
+
{}
|
|
174
|
+
<View
|
|
175
|
+
row
|
|
176
|
+
alignItems="center"
|
|
177
|
+
justifyContent="space-between"
|
|
178
|
+
paddingHorizontal={16}
|
|
179
|
+
paddingVertical={12}
|
|
180
|
+
width="100%"
|
|
181
|
+
>
|
|
182
|
+
<View row alignItems="center" gap={8}>
|
|
183
|
+
{locations.back === "header" && showBack && (
|
|
184
|
+
<Icon
|
|
185
|
+
icon="iArrowKeyLeft"
|
|
186
|
+
box
|
|
187
|
+
pressable={{ onClick: () => history.back() }}
|
|
188
|
+
/>
|
|
189
|
+
)}
|
|
190
|
+
{currentStep.icon && <Icon box size={20} {...currentStep.icon} />}
|
|
191
|
+
<View column gap={2}>
|
|
192
|
+
{currentStep.title && (
|
|
193
|
+
<Text type="Headline">{currentStep.title}</Text>
|
|
194
|
+
)}
|
|
195
|
+
{currentStep.caption && (
|
|
196
|
+
<Text type="Footnote" opacity={0.72}>
|
|
197
|
+
{currentStep.caption}
|
|
198
|
+
</Text>
|
|
199
|
+
)}
|
|
200
|
+
</View>
|
|
201
|
+
</View>
|
|
202
|
+
<View row alignItems="center">
|
|
203
|
+
{locations.exit === "header" && showExit && (
|
|
204
|
+
<Icon icon="iClose" box pressable={{ onClick: onClose }} />
|
|
205
|
+
)}
|
|
206
|
+
</View>
|
|
207
|
+
</View>
|
|
208
|
+
|
|
209
|
+
{}
|
|
210
|
+
<View
|
|
211
|
+
style={{
|
|
212
|
+
flex: "1 1 auto",
|
|
213
|
+
overflowY: "auto",
|
|
214
|
+
minHeight: 0,
|
|
215
|
+
padding: "1.6rem",
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
{currentStep.content}
|
|
219
|
+
</View>
|
|
220
|
+
|
|
221
|
+
{}
|
|
222
|
+
{(sortedButtons.length > 0 || config.footer?.content) && (
|
|
223
|
+
<View
|
|
224
|
+
row={!isFooterColumn}
|
|
225
|
+
column={isFooterColumn}
|
|
226
|
+
alignItems={isFooterColumn ? "stretch" : "center"}
|
|
227
|
+
gap={12}
|
|
228
|
+
paddingHorizontal={16}
|
|
229
|
+
paddingVertical={16}
|
|
230
|
+
width="100%"
|
|
231
|
+
>
|
|
232
|
+
{config.footer?.content && (
|
|
233
|
+
<View style={{ flex: "1 1 auto", minWidth: 0 }}>
|
|
234
|
+
{config.footer.content}
|
|
235
|
+
</View>
|
|
236
|
+
)}
|
|
237
|
+
<View
|
|
238
|
+
row={!isFooterColumn}
|
|
239
|
+
column={isFooterColumn}
|
|
240
|
+
gap={8}
|
|
241
|
+
justifyContent="flex-end"
|
|
242
|
+
style={{ flex: "1 1 auto" }}
|
|
243
|
+
>
|
|
244
|
+
{sortedButtons.map((btn) => (
|
|
245
|
+
<Pressable
|
|
246
|
+
key={btn.order}
|
|
247
|
+
style={{
|
|
248
|
+
display: "contents",
|
|
249
|
+
flex: config.footer?.buttonCondensed ? "0 0 auto" : "1 1 0",
|
|
250
|
+
}}
|
|
251
|
+
>
|
|
252
|
+
{btn.element}
|
|
253
|
+
</Pressable>
|
|
254
|
+
))}
|
|
255
|
+
</View>
|
|
256
|
+
</View>
|
|
257
|
+
)}
|
|
258
|
+
</View>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import Icon from "@/packages/Components/Icon/Icon";
|
|
5
|
+
import Text from "@/packages/Components/Text/Text";
|
|
6
|
+
import { useDialog } from "@/packages/Frameworks/Dialog/Dialog";
|
|
7
|
+
import type { DialogHeaderConfig } from "@/packages/Frameworks/Dialog/Dialog.types";
|
|
8
|
+
import Pressable from "@/packages/Frameworks/Pressable/Pressable";
|
|
9
|
+
import View from "@/packages/Frameworks/View/View";
|
|
10
|
+
|
|
11
|
+
interface DialogHeaderProps {
|
|
12
|
+
config?: DialogHeaderConfig & {
|
|
13
|
+
centered?: boolean;
|
|
14
|
+
iconReversed?: boolean;
|
|
15
|
+
};
|
|
16
|
+
exitIcon?: ReactNode;
|
|
17
|
+
onExit?: () => void;
|
|
18
|
+
backIcon?: ReactNode;
|
|
19
|
+
onBack?: () => void;
|
|
20
|
+
isSheet?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function DialogHeader({
|
|
24
|
+
config,
|
|
25
|
+
exitIcon,
|
|
26
|
+
onExit,
|
|
27
|
+
backIcon,
|
|
28
|
+
onBack,
|
|
29
|
+
isSheet: propIsSheet,
|
|
30
|
+
}: DialogHeaderProps) {
|
|
31
|
+
const dialogContext = useDialog();
|
|
32
|
+
const _isSheet = propIsSheet ?? dialogContext?.mode === "sheet";
|
|
33
|
+
|
|
34
|
+
const hasContent =
|
|
35
|
+
!!config?.title ||
|
|
36
|
+
!!config?.caption ||
|
|
37
|
+
!!config?.icon ||
|
|
38
|
+
!!config?.content ||
|
|
39
|
+
!!exitIcon ||
|
|
40
|
+
!!backIcon;
|
|
41
|
+
|
|
42
|
+
if (!hasContent) return null;
|
|
43
|
+
|
|
44
|
+
const isPlainCaption =
|
|
45
|
+
typeof config?.caption === "string" || typeof config?.caption === "number";
|
|
46
|
+
|
|
47
|
+
const renderBack = () => {
|
|
48
|
+
if (!backIcon) return null;
|
|
49
|
+
if (backIcon === true) {
|
|
50
|
+
return <Icon icon="iArrowKeyLeft" box pressable={{ onClick: onBack }} />;
|
|
51
|
+
}
|
|
52
|
+
return (
|
|
53
|
+
<Pressable style={{ display: "contents" }} onClick={onBack}>
|
|
54
|
+
{backIcon}
|
|
55
|
+
</Pressable>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const renderExit = () => {
|
|
60
|
+
if (!exitIcon) return null;
|
|
61
|
+
if (exitIcon === true) {
|
|
62
|
+
return <Icon icon="iClose" box pressable={{ onClick: onExit }} />;
|
|
63
|
+
}
|
|
64
|
+
return (
|
|
65
|
+
<Pressable style={{ display: "contents" }} onClick={onExit}>
|
|
66
|
+
{exitIcon}
|
|
67
|
+
</Pressable>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const renderIcon = () => {
|
|
72
|
+
if (!config?.icon) return null;
|
|
73
|
+
return <Icon box size={20} background="Base4" {...config.icon} />;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<View
|
|
78
|
+
row
|
|
79
|
+
alignItems="center"
|
|
80
|
+
justifyContent="space-between"
|
|
81
|
+
gap={12}
|
|
82
|
+
padding={4}
|
|
83
|
+
width="100%"
|
|
84
|
+
style={{
|
|
85
|
+
position: "sticky",
|
|
86
|
+
top: 0,
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{config?.icon && (
|
|
90
|
+
<View row alignItems="center" gap={8} order={0}>
|
|
91
|
+
{renderBack()}
|
|
92
|
+
{!config?.iconReversed && renderIcon()}
|
|
93
|
+
</View>
|
|
94
|
+
)}
|
|
95
|
+
|
|
96
|
+
{(config?.title || config?.caption) && (
|
|
97
|
+
<View
|
|
98
|
+
column
|
|
99
|
+
gap={2}
|
|
100
|
+
order={1}
|
|
101
|
+
alignItems={config?.centered ? "center" : "flex-start"}
|
|
102
|
+
style={{
|
|
103
|
+
flex: 1,
|
|
104
|
+
minWidth: 0,
|
|
105
|
+
textAlign: config?.centered ? "center" : "left",
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{config?.title && (
|
|
109
|
+
<Text type="Title3" lineHeight={1.45}>
|
|
110
|
+
{config.title}
|
|
111
|
+
</Text>
|
|
112
|
+
)}
|
|
113
|
+
{config?.caption && (
|
|
114
|
+
<View style={{ wordBreak: "break-all" }}>
|
|
115
|
+
{isPlainCaption ? (
|
|
116
|
+
<Text type="Subheadline" weight={300} opacity={0.72}>
|
|
117
|
+
{config.caption}
|
|
118
|
+
</Text>
|
|
119
|
+
) : (
|
|
120
|
+
config.caption
|
|
121
|
+
)}
|
|
122
|
+
</View>
|
|
123
|
+
)}
|
|
124
|
+
</View>
|
|
125
|
+
)}
|
|
126
|
+
|
|
127
|
+
{config?.content}
|
|
128
|
+
|
|
129
|
+
{exitIcon && (
|
|
130
|
+
<View row alignItems="center" gap={8} order={2}>
|
|
131
|
+
{config?.iconReversed && renderIcon()}
|
|
132
|
+
{renderExit()}
|
|
133
|
+
</View>
|
|
134
|
+
)}
|
|
135
|
+
</View>
|
|
136
|
+
);
|
|
137
|
+
}
|