@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,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { getFloatingTransformOrigin } from "@musecat/functionkit";
|
|
4
|
+
import { AnimatePresence } from "motion/react";
|
|
5
|
+
import { type ReactNode, useCallback, useEffect, useRef } from "react";
|
|
6
|
+
import { useScrollLock } from "@/packages/Frameworks/_shared/bodyScrollLock";
|
|
7
|
+
import { LAYER_Z_INDEX } from "@/packages/Frameworks/_shared/layer.constants";
|
|
8
|
+
import { Size } from "@/packages/Frameworks/_shared/sizing";
|
|
9
|
+
import DialogFooter from "@/packages/Frameworks/Dialog/contents/Dialog.footer";
|
|
10
|
+
import DialogHeader from "@/packages/Frameworks/Dialog/contents/Dialog.header";
|
|
11
|
+
import BackgroundWrapper from "@/packages/Frameworks/Dialog/Dialog.background";
|
|
12
|
+
import type {
|
|
13
|
+
DialogOutsideOptions,
|
|
14
|
+
PopoverConfig,
|
|
15
|
+
} from "@/packages/Frameworks/Dialog/Dialog.types";
|
|
16
|
+
import {
|
|
17
|
+
DialogPortal,
|
|
18
|
+
useEscapeClose,
|
|
19
|
+
} from "@/packages/Frameworks/Dialog/Dialog.utils";
|
|
20
|
+
import { useDialogPosition } from "@/packages/Frameworks/Dialog/hooks/useDialogPosition";
|
|
21
|
+
import { motionPresets } from "@/packages/Frameworks/Motion/Motion.presets";
|
|
22
|
+
import View from "@/packages/Frameworks/View/View";
|
|
23
|
+
|
|
24
|
+
interface RenderPopoverProps {
|
|
25
|
+
open: boolean;
|
|
26
|
+
onOpenChange: (open: boolean) => void;
|
|
27
|
+
config: PopoverConfig;
|
|
28
|
+
id?: string;
|
|
29
|
+
zIndex?: number;
|
|
30
|
+
width?: string | number;
|
|
31
|
+
height?: string | number;
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
role?: string;
|
|
34
|
+
"data-color-mode"?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function RenderPopover({
|
|
38
|
+
open,
|
|
39
|
+
onOpenChange,
|
|
40
|
+
config,
|
|
41
|
+
id,
|
|
42
|
+
zIndex,
|
|
43
|
+
width,
|
|
44
|
+
height,
|
|
45
|
+
children,
|
|
46
|
+
role = "dialog",
|
|
47
|
+
"data-color-mode": dataColorMode,
|
|
48
|
+
}: RenderPopoverProps) {
|
|
49
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
50
|
+
const overlayEnabled = config.exit?.overlay !== false;
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
topValue,
|
|
54
|
+
leftValue,
|
|
55
|
+
maxHeightValue,
|
|
56
|
+
resolvedPlacement,
|
|
57
|
+
computedWidth,
|
|
58
|
+
isPositionReady,
|
|
59
|
+
} = useDialogPosition({
|
|
60
|
+
open,
|
|
61
|
+
anchorRef: config.anchorRef,
|
|
62
|
+
contentRef,
|
|
63
|
+
placement: config.placement,
|
|
64
|
+
strategy: config.strategy,
|
|
65
|
+
selectedItemSelector: config.selectedItemSelector,
|
|
66
|
+
matchAnchorWidth: config.matchAnchorWidth,
|
|
67
|
+
coverAnchor: config.coverAnchor,
|
|
68
|
+
margin: config.margin,
|
|
69
|
+
recalcKey: config.recalcKey,
|
|
70
|
+
offset: config.offset,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const resolvedZIndex = zIndex ?? LAYER_Z_INDEX.popover;
|
|
74
|
+
|
|
75
|
+
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
76
|
+
|
|
77
|
+
const stopPropagation = useCallback((e: React.SyntheticEvent) => {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const propagationHandlers = config.stopInteractionPropagation
|
|
82
|
+
? {
|
|
83
|
+
onClick: stopPropagation,
|
|
84
|
+
onMouseDown: stopPropagation,
|
|
85
|
+
onMouseUp: stopPropagation,
|
|
86
|
+
onTouchStart: stopPropagation,
|
|
87
|
+
onTouchEnd: stopPropagation,
|
|
88
|
+
onPointerDown: stopPropagation,
|
|
89
|
+
onPointerUp: stopPropagation,
|
|
90
|
+
onKeyDown: stopPropagation,
|
|
91
|
+
onKeyUp: stopPropagation,
|
|
92
|
+
}
|
|
93
|
+
: {};
|
|
94
|
+
|
|
95
|
+
useEscapeClose(open && config.exit?.escape !== false, close);
|
|
96
|
+
|
|
97
|
+
const offsetWidth = config.offset?.width;
|
|
98
|
+
const resolvedWidth = (() => {
|
|
99
|
+
if (offsetWidth === undefined || offsetWidth === null) {
|
|
100
|
+
return computedWidth !== null ? `${computedWidth}px` : Size(width);
|
|
101
|
+
}
|
|
102
|
+
const add =
|
|
103
|
+
typeof offsetWidth === "number" ? `${offsetWidth}px` : offsetWidth;
|
|
104
|
+
if (computedWidth !== null) return `calc(${computedWidth}px + ${add})`;
|
|
105
|
+
const base = width != null ? Size(width) : "auto";
|
|
106
|
+
return `calc(${base} + ${add})`;
|
|
107
|
+
})();
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!open || !overlayEnabled) return;
|
|
111
|
+
|
|
112
|
+
const handlePointerDown = (e: PointerEvent) => {
|
|
113
|
+
const target = e.target as Node;
|
|
114
|
+
if (contentRef.current?.contains(target)) return;
|
|
115
|
+
if (config.anchorRef.current?.contains(target)) return;
|
|
116
|
+
|
|
117
|
+
const triggerLabel = config.anchorRef.current?.closest("label");
|
|
118
|
+
if (triggerLabel?.contains(target)) return;
|
|
119
|
+
close();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
123
|
+
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
124
|
+
}, [open, overlayEnabled, close, config.anchorRef]);
|
|
125
|
+
|
|
126
|
+
const isOutsideConfig =
|
|
127
|
+
config.outside !== undefined && config.outside !== false;
|
|
128
|
+
const outsideOptions: DialogOutsideOptions =
|
|
129
|
+
isOutsideConfig && typeof config.outside === "object" ? config.outside : {};
|
|
130
|
+
const lockScroll = outsideOptions.lockBodyScroll ?? false;
|
|
131
|
+
|
|
132
|
+
useScrollLock(open && lockScroll);
|
|
133
|
+
|
|
134
|
+
const popoverNode = (
|
|
135
|
+
<AnimatePresence>
|
|
136
|
+
{open ? (
|
|
137
|
+
<View
|
|
138
|
+
data-color-mode={dataColorMode}
|
|
139
|
+
style={{
|
|
140
|
+
position: "fixed",
|
|
141
|
+
inset: 0,
|
|
142
|
+
zIndex: resolvedZIndex,
|
|
143
|
+
pointerEvents: "none",
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
{isOutsideConfig && (
|
|
147
|
+
<BackgroundWrapper
|
|
148
|
+
open={open}
|
|
149
|
+
showBackdrop={isOutsideConfig}
|
|
150
|
+
background={outsideOptions.background}
|
|
151
|
+
backgroundBlur={outsideOptions.backgroundBlur}
|
|
152
|
+
className={outsideOptions.className}
|
|
153
|
+
style={outsideOptions.style}
|
|
154
|
+
zIndex={resolvedZIndex - 1}
|
|
155
|
+
onClick={overlayEnabled ? close : undefined}
|
|
156
|
+
/>
|
|
157
|
+
)}
|
|
158
|
+
<View
|
|
159
|
+
id={id}
|
|
160
|
+
ref={contentRef}
|
|
161
|
+
className={config.className}
|
|
162
|
+
role={role}
|
|
163
|
+
tabIndex={-1}
|
|
164
|
+
data-popover-owner={config.popoverOwnerId}
|
|
165
|
+
{...propagationHandlers}
|
|
166
|
+
motion={motionPresets.popover(isPositionReady)}
|
|
167
|
+
themePreset={config.themePreset}
|
|
168
|
+
background={config.background ?? "Base1TP1"}
|
|
169
|
+
color={config.color}
|
|
170
|
+
border={config.border}
|
|
171
|
+
radius={config.radius ?? "Light"}
|
|
172
|
+
shadow={config.shadow ?? "Regular"}
|
|
173
|
+
gap={config.gap ?? 0}
|
|
174
|
+
backgroundBlur={config.backgroundBlur ?? "Light"}
|
|
175
|
+
width={width}
|
|
176
|
+
height={height}
|
|
177
|
+
column
|
|
178
|
+
style={{
|
|
179
|
+
position: "absolute",
|
|
180
|
+
zIndex: resolvedZIndex,
|
|
181
|
+
top: topValue ?? 0,
|
|
182
|
+
left: leftValue ?? 0,
|
|
183
|
+
width: resolvedWidth,
|
|
184
|
+
height: Size(height),
|
|
185
|
+
maxHeight: config.maxHeight
|
|
186
|
+
? Size(config.maxHeight)
|
|
187
|
+
: `${maxHeightValue}px`,
|
|
188
|
+
visibility: isPositionReady ? "visible" : "hidden",
|
|
189
|
+
pointerEvents: isPositionReady ? "auto" : "none",
|
|
190
|
+
transformOrigin: getFloatingTransformOrigin(
|
|
191
|
+
resolvedPlacement as any,
|
|
192
|
+
),
|
|
193
|
+
overflow: "hidden",
|
|
194
|
+
willChange: "transform",
|
|
195
|
+
...config.style,
|
|
196
|
+
}}
|
|
197
|
+
>
|
|
198
|
+
<DialogHeader
|
|
199
|
+
config={config.header}
|
|
200
|
+
exitIcon={config.exit?.icon}
|
|
201
|
+
onExit={close}
|
|
202
|
+
/>
|
|
203
|
+
|
|
204
|
+
{children}
|
|
205
|
+
|
|
206
|
+
<View style={{ display: "contents" }}>
|
|
207
|
+
<DialogFooter
|
|
208
|
+
config={config.footer}
|
|
209
|
+
exitButton={config.exit?.footerButton}
|
|
210
|
+
onExit={close}
|
|
211
|
+
/>
|
|
212
|
+
</View>
|
|
213
|
+
</View>
|
|
214
|
+
</View>
|
|
215
|
+
) : null}
|
|
216
|
+
</AnimatePresence>
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
return <DialogPortal>{popoverNode}</DialogPortal>;
|
|
220
|
+
}
|