@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,24 @@
|
|
|
1
|
+
import type { TextProps } from "@/packages/Components/Text/Text.types";
|
|
2
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
3
|
+
import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
|
|
4
|
+
import type {
|
|
5
|
+
BorderProps,
|
|
6
|
+
ThemeSystemProps,
|
|
7
|
+
} from "@/packages/Frameworks/Theme/Theme.types";
|
|
8
|
+
|
|
9
|
+
export interface CheckboxProps
|
|
10
|
+
extends Omit<
|
|
11
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
12
|
+
"size" | "title" | "color"
|
|
13
|
+
>,
|
|
14
|
+
BorderProps,
|
|
15
|
+
RadiusProps,
|
|
16
|
+
ThemeSystemProps {
|
|
17
|
+
"data-color-mode"?: string;
|
|
18
|
+
title?: React.ReactNode;
|
|
19
|
+
titleType?: TextProps["type"];
|
|
20
|
+
titleSpaceBetween?: boolean;
|
|
21
|
+
reversed?: boolean;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
size?: UIKitSizeValue;
|
|
24
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { NavigatorClipboard } from "@musecat/functionkit";
|
|
4
|
+
import Icon from "@/packages/Components/Icon/Icon";
|
|
5
|
+
import Text from "@/packages/Components/Text/Text";
|
|
6
|
+
import View from "@/packages/Frameworks/View/View";
|
|
7
|
+
|
|
8
|
+
export default function CodeBox_Copy({
|
|
9
|
+
language,
|
|
10
|
+
code,
|
|
11
|
+
}: {
|
|
12
|
+
language: string;
|
|
13
|
+
code: string;
|
|
14
|
+
}) {
|
|
15
|
+
return (
|
|
16
|
+
<View
|
|
17
|
+
alignItems="center"
|
|
18
|
+
justifyContent="space-between"
|
|
19
|
+
gap={12}
|
|
20
|
+
padding={[12, 12, 0, 12]}
|
|
21
|
+
>
|
|
22
|
+
<View
|
|
23
|
+
padding={[6, 10]}
|
|
24
|
+
themePreset="UISecondary"
|
|
25
|
+
radius="Circle"
|
|
26
|
+
border="Regular"
|
|
27
|
+
>
|
|
28
|
+
<Text type="Footnote">{language}</Text>
|
|
29
|
+
</View>
|
|
30
|
+
|
|
31
|
+
<Icon
|
|
32
|
+
icon="iContentCopy"
|
|
33
|
+
radius="Circle"
|
|
34
|
+
themePreset="UISecondary"
|
|
35
|
+
border="Regular"
|
|
36
|
+
size={18}
|
|
37
|
+
box
|
|
38
|
+
boxOptions={{ padding: 6 }}
|
|
39
|
+
pressable={{ onClick: () => NavigatorClipboard({ text: code }) }}
|
|
40
|
+
/>
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.CodeBox {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.Pre {
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 1.2rem 1.6rem 1.6rem;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
|
|
11
|
+
.Code {
|
|
12
|
+
display: block;
|
|
13
|
+
word-break: break-all;
|
|
14
|
+
font-size: var(--font-caption1-size);
|
|
15
|
+
line-height: 1.6;
|
|
16
|
+
letter-spacing: -0.02rem;
|
|
17
|
+
white-space: pre-wrap;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Prism token - 컬러 스킴 변수 기준 */
|
|
22
|
+
.CodeBox :global(.token.comment),
|
|
23
|
+
.CodeBox :global(.token.prolog),
|
|
24
|
+
.CodeBox :global(.token.doctype),
|
|
25
|
+
.CodeBox :global(.token.cdata) {
|
|
26
|
+
color: var(--color-text-base-light);
|
|
27
|
+
opacity: 0.8;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.CodeBox :global(.token.punctuation),
|
|
31
|
+
.CodeBox :global(.token.operator) {
|
|
32
|
+
color: var(--color-text-base-light);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.CodeBox :global(.token.keyword),
|
|
36
|
+
.CodeBox :global(.token.atrule) {
|
|
37
|
+
color: var(--color-purple-3);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.CodeBox :global(.token.function),
|
|
41
|
+
.CodeBox :global(.token.class-name) {
|
|
42
|
+
color: var(--color-blue-3);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.CodeBox :global(.token.string),
|
|
46
|
+
.CodeBox :global(.token.char),
|
|
47
|
+
.CodeBox :global(.token.attr-value) {
|
|
48
|
+
color: var(--color-green-3);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.CodeBox :global(.token.number),
|
|
52
|
+
.CodeBox :global(.token.boolean),
|
|
53
|
+
.CodeBox :global(.token.constant) {
|
|
54
|
+
color: var(--color-orange-3);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.CodeBox :global(.token.property),
|
|
58
|
+
.CodeBox :global(.token.selector),
|
|
59
|
+
.CodeBox :global(.token.tag),
|
|
60
|
+
.CodeBox :global(.token.builtin) {
|
|
61
|
+
color: var(--color-blue-3);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.CodeBox :global(.token.variable),
|
|
65
|
+
.CodeBox :global(.token.parameter) {
|
|
66
|
+
color: var(--color-yellow-3);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.CodeBox :global(.token.regex),
|
|
70
|
+
.CodeBox :global(.token.important) {
|
|
71
|
+
color: var(--color-red-3);
|
|
72
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import Prism from "prismjs";
|
|
2
|
+
import CodeBox_Copy from "@/packages/Components/CodeBox/CodeBox.copy";
|
|
3
|
+
import styles from "@/packages/Components/CodeBox/CodeBox.module.scss";
|
|
4
|
+
import type { CodeBoxProps } from "@/packages/Components/CodeBox/CodeBox.types";
|
|
5
|
+
import { normalizeLang } from "@/packages/Frameworks/_shared/normalize";
|
|
6
|
+
import View from "@/packages/Frameworks/View/View";
|
|
7
|
+
import "prismjs/components/prism-bash";
|
|
8
|
+
import "prismjs/components/prism-css";
|
|
9
|
+
import "prismjs/components/prism-javascript";
|
|
10
|
+
import "prismjs/components/prism-json";
|
|
11
|
+
import "prismjs/components/prism-jsx";
|
|
12
|
+
import "prismjs/components/prism-markdown";
|
|
13
|
+
import "prismjs/components/prism-markup";
|
|
14
|
+
import "prismjs/components/prism-scss";
|
|
15
|
+
import "prismjs/components/prism-tsx";
|
|
16
|
+
import "prismjs/components/prism-typescript";
|
|
17
|
+
|
|
18
|
+
export default function CodeBox({
|
|
19
|
+
code,
|
|
20
|
+
language,
|
|
21
|
+
border,
|
|
22
|
+
"data-color-mode": dataTheme,
|
|
23
|
+
themePreset,
|
|
24
|
+
background,
|
|
25
|
+
color,
|
|
26
|
+
shadow,
|
|
27
|
+
radius,
|
|
28
|
+
themeInteractive,
|
|
29
|
+
selected,
|
|
30
|
+
disabled,
|
|
31
|
+
readOnly,
|
|
32
|
+
backgroundBlur,
|
|
33
|
+
className,
|
|
34
|
+
style,
|
|
35
|
+
}: CodeBoxProps) {
|
|
36
|
+
const lang = normalizeLang(language);
|
|
37
|
+
const grammar = Prism.languages[lang] ?? Prism.languages.markup;
|
|
38
|
+
const source = code.trim();
|
|
39
|
+
const html = Prism.highlight(source, grammar, lang);
|
|
40
|
+
const substitutedLanguage =
|
|
41
|
+
language === "tsx"
|
|
42
|
+
? "TSX"
|
|
43
|
+
: language === "jsx"
|
|
44
|
+
? "JSX"
|
|
45
|
+
: language === "json"
|
|
46
|
+
? "JSON"
|
|
47
|
+
: language === "python"
|
|
48
|
+
? "Py"
|
|
49
|
+
: language;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View
|
|
53
|
+
column
|
|
54
|
+
gap={0}
|
|
55
|
+
className={`${styles.CodeBox}${className ? ` ${className}` : ""}`}
|
|
56
|
+
style={style}
|
|
57
|
+
data-color-mode={dataTheme}
|
|
58
|
+
border={border}
|
|
59
|
+
background={background}
|
|
60
|
+
themePreset={themePreset ?? "UIPrimary"}
|
|
61
|
+
color={color}
|
|
62
|
+
shadow={shadow}
|
|
63
|
+
radius={radius ?? "Regular"}
|
|
64
|
+
themeInteractive={themeInteractive}
|
|
65
|
+
selected={selected}
|
|
66
|
+
disabled={disabled}
|
|
67
|
+
readOnly={readOnly}
|
|
68
|
+
backgroundBlur={backgroundBlur}
|
|
69
|
+
>
|
|
70
|
+
{substitutedLanguage && (
|
|
71
|
+
<CodeBox_Copy
|
|
72
|
+
language={substitutedLanguage}
|
|
73
|
+
code={source}
|
|
74
|
+
data-color-mode={dataTheme}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
{}
|
|
78
|
+
{}
|
|
79
|
+
<pre
|
|
80
|
+
className={`${styles.Pre} language-${lang}`}
|
|
81
|
+
data-color-mode={dataTheme}
|
|
82
|
+
>
|
|
83
|
+
<code
|
|
84
|
+
className={`${styles.Code} language-${lang}`}
|
|
85
|
+
data-color-mode={dataTheme}
|
|
86
|
+
dangerouslySetInnerHTML={{ __html: html }}
|
|
87
|
+
/>
|
|
88
|
+
</pre>
|
|
89
|
+
</View>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
|
|
2
|
+
import type {
|
|
3
|
+
BorderProps,
|
|
4
|
+
ThemeSystemProps,
|
|
5
|
+
} from "@/packages/Frameworks/Theme/Theme.types";
|
|
6
|
+
|
|
7
|
+
export interface CodeBoxProps
|
|
8
|
+
extends ThemeSystemProps,
|
|
9
|
+
RadiusProps,
|
|
10
|
+
BorderProps {
|
|
11
|
+
"data-color-mode"?: string;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
code: string;
|
|
16
|
+
language?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type KeyboardEvent,
|
|
5
|
+
type MouseEvent,
|
|
6
|
+
memo,
|
|
7
|
+
type ReactElement,
|
|
8
|
+
} from "react";
|
|
9
|
+
import styles from "@/packages/Components/ContextMenu/ContextMenu.module.scss";
|
|
10
|
+
import type { ContentItem } from "@/packages/Components/ContextMenu/ContextMenu.types";
|
|
11
|
+
import Icon from "@/packages/Components/Icon/Icon";
|
|
12
|
+
import Text from "@/packages/Components/Text/Text";
|
|
13
|
+
import Pressable from "@/packages/Frameworks/Pressable/Pressable";
|
|
14
|
+
import View from "@/packages/Frameworks/View/View";
|
|
15
|
+
|
|
16
|
+
export interface ContextMenuOptionProps {
|
|
17
|
+
item: ContentItem;
|
|
18
|
+
index: number;
|
|
19
|
+
listId: string;
|
|
20
|
+
openSource: "mouse" | "keyboard";
|
|
21
|
+
activeIndex: number;
|
|
22
|
+
isInteractionDisabled: boolean;
|
|
23
|
+
isOptionDisabled: (option: ContentItem) => boolean;
|
|
24
|
+
setOpenSource: (source: "mouse" | "keyboard") => void;
|
|
25
|
+
setActiveIndex: (index: number) => void;
|
|
26
|
+
selectOption: () => void;
|
|
27
|
+
isSheetMode?: boolean;
|
|
28
|
+
showCheck?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ContextMenuOption = memo(function ContextMenuOption(
|
|
32
|
+
props: ContextMenuOptionProps,
|
|
33
|
+
): ReactElement {
|
|
34
|
+
const {
|
|
35
|
+
item,
|
|
36
|
+
index,
|
|
37
|
+
listId,
|
|
38
|
+
openSource,
|
|
39
|
+
activeIndex,
|
|
40
|
+
isInteractionDisabled,
|
|
41
|
+
isOptionDisabled,
|
|
42
|
+
setOpenSource,
|
|
43
|
+
setActiveIndex,
|
|
44
|
+
selectOption,
|
|
45
|
+
showCheck,
|
|
46
|
+
isSheetMode,
|
|
47
|
+
} = props;
|
|
48
|
+
const isSelected = !!item.selected;
|
|
49
|
+
const isActive = openSource === "keyboard" && index === activeIndex;
|
|
50
|
+
const isDisabled = isInteractionDisabled || isOptionDisabled(item);
|
|
51
|
+
|
|
52
|
+
const onMouseEnter = () => {
|
|
53
|
+
if (isDisabled) return;
|
|
54
|
+
setOpenSource("mouse");
|
|
55
|
+
setActiveIndex(index);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onMouseDown = (e: MouseEvent) => {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onClick = (e: MouseEvent) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
if (isDisabled) return;
|
|
67
|
+
selectOption();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
71
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
if (isDisabled) return;
|
|
75
|
+
selectOption();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Pressable
|
|
81
|
+
id={`${listId}-${index}`}
|
|
82
|
+
className={styles.OptionItem}
|
|
83
|
+
role="option"
|
|
84
|
+
aria-selected={isSelected}
|
|
85
|
+
data-selected={isSelected ? "true" : "false"}
|
|
86
|
+
data-active={isActive ? "true" : "false"}
|
|
87
|
+
data-disabled={isDisabled ? "true" : "false"}
|
|
88
|
+
themeInteractive={!isDisabled}
|
|
89
|
+
disabled={isDisabled}
|
|
90
|
+
radius={isSheetMode ? "Light" : "ExtraLight"}
|
|
91
|
+
onMouseEnter={onMouseEnter}
|
|
92
|
+
onMouseDown={onMouseDown}
|
|
93
|
+
onClick={onClick}
|
|
94
|
+
onKeyDown={onKeyDown}
|
|
95
|
+
alignItems="center"
|
|
96
|
+
gap={8}
|
|
97
|
+
width="100%"
|
|
98
|
+
padding={isSheetMode ? [12, 16] : [6, 12]}
|
|
99
|
+
>
|
|
100
|
+
{showCheck && (
|
|
101
|
+
<Icon
|
|
102
|
+
icon="iCheck"
|
|
103
|
+
size={16}
|
|
104
|
+
style={{ flex: "none" }}
|
|
105
|
+
opacity={isSelected ? 1 : 0}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
<View gap={6} alignItems="center">
|
|
109
|
+
{item.icon && <Icon icon={item.icon} size={16} />}
|
|
110
|
+
<View column gap={2}>
|
|
111
|
+
<Text type="Subheadline">{item.label}</Text>
|
|
112
|
+
{item.description && (
|
|
113
|
+
<Text
|
|
114
|
+
type="Caption2"
|
|
115
|
+
style={{ color: "var(--ds-gray-700, currentColor)" }}
|
|
116
|
+
>
|
|
117
|
+
{item.description}
|
|
118
|
+
</Text>
|
|
119
|
+
)}
|
|
120
|
+
</View>
|
|
121
|
+
</View>
|
|
122
|
+
</Pressable>
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export default ContextMenuOption;
|