@lobehub/ui 4.23.0 → 4.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Accordion/Accordion.d.mts +2 -2
- package/es/Accordion/AccordionItem.d.mts +2 -2
- package/es/ActionIcon/ActionIcon.d.mts +2 -2
- package/es/Alert/Alert.d.mts +2 -2
- package/es/AutoComplete/Select.d.mts +2 -2
- package/es/Avatar/AvatarGroup/index.d.mts +2 -2
- package/es/Burger/Burger.d.mts +2 -2
- package/es/CodeDiff/CodeDiff.d.mts +2 -2
- package/es/CodeDiff/PatchDiff.d.mts +2 -2
- package/es/CodeEditor/CodeEditor.d.mts +2 -2
- package/es/Collapse/Collapse.d.mts +2 -2
- package/es/ConfigProvider/index.d.mts +2 -2
- package/es/ContextMenu/ContextMenuHost.d.mts +3 -3
- package/es/CopyButton/CopyButton.d.mts +2 -2
- package/es/DatePicker/DatePicker.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelBody.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelContainer.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelFooter.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelHeader.d.mts +2 -2
- package/es/DraggableSideNav/DraggableSideNav.d.mts +2 -2
- package/es/Drawer/Drawer.d.mts +2 -2
- package/es/Dropdown/Dropdown.d.mts +2 -2
- package/es/DropdownMenu/DropdownMenu.d.mts +2 -2
- package/es/DropdownMenu/atoms.d.mts +16 -16
- package/es/EditableText/EditableText.d.mts +2 -2
- package/es/EditorSlashMenu/atoms.d.mts +12 -12
- package/es/EmojiPicker/EmojiPicker.d.mts +2 -2
- package/es/Flex/FlexBasic.d.mts +2 -2
- package/es/FontLoader/index.d.mts +2 -2
- package/es/Footer/Footer.d.mts +2 -2
- package/es/Form/components/FormGroup.d.mts +2 -2
- package/es/Form/components/FormItem.d.mts +2 -2
- package/es/Form/components/FormSubmitFooter.d.mts +2 -2
- package/es/FormModal/FormModal.d.mts +2 -2
- package/es/GuideCard/GuideCard.d.mts +2 -2
- package/es/Header/Header.d.mts +2 -2
- package/es/Highlighter/Highlighter.d.mts +2 -2
- package/es/Highlighter/SyntaxHighlighter/index.d.mts +2 -2
- package/es/Hotkey/Hotkey.d.mts +2 -2
- package/es/HotkeyInput/HotkeyInput.d.mts +2 -2
- package/es/Icon/Icon.d.mts +2 -2
- package/es/Icon/components/IconProvider.d.mts +3 -3
- package/es/Image/PreviewGroup.d.mts +2 -2
- package/es/Input/Input.d.mts +2 -2
- package/es/Input/InputNumber.d.mts +2 -2
- package/es/Input/InputOPT.d.mts +2 -2
- package/es/Input/InputPassword.d.mts +2 -2
- package/es/Input/TextArea.d.mts +2 -2
- package/es/Layout/components/LayoutFooter.d.mts +2 -2
- package/es/Layout/components/LayoutHeader.d.mts +2 -2
- package/es/Layout/components/LayoutMain.d.mts +2 -2
- package/es/Layout/components/LayoutSidebar.d.mts +2 -2
- package/es/Layout/components/LayoutSidebarInner.d.mts +2 -2
- package/es/Layout/components/LayoutToc.d.mts +2 -2
- package/es/List/ListItem/index.d.mts +2 -2
- package/es/LobeSelect/LobeSelect.d.mts +2 -2
- package/es/LobeSelect/atoms.d.mts +19 -19
- package/es/LobeSelect/style.mjs +18 -5
- package/es/LobeSelect/style.mjs.map +1 -1
- package/es/LobeSwitch/LobeSwitch.d.mts +8 -0
- package/es/LobeSwitch/LobeSwitch.mjs +68 -0
- package/es/LobeSwitch/LobeSwitch.mjs.map +1 -0
- package/es/LobeSwitch/atoms.d.mts +56 -0
- package/es/LobeSwitch/atoms.mjs +132 -0
- package/es/LobeSwitch/atoms.mjs.map +1 -0
- package/es/LobeSwitch/index.d.mts +5 -0
- package/es/LobeSwitch/index.d.ts +1 -0
- package/es/LobeSwitch/index.js +1 -0
- package/es/LobeSwitch/index.mjs +5 -0
- package/es/LobeSwitch/style.d.mts +19 -0
- package/es/LobeSwitch/style.mjs +146 -0
- package/es/LobeSwitch/style.mjs.map +1 -0
- package/es/LobeSwitch/type.d.mts +131 -0
- package/es/Markdown/Markdown.d.mts +2 -2
- package/es/Markdown/Typography.d.mts +2 -2
- package/es/Markdown/components/SearchResultCards/index.d.mts +2 -2
- package/es/MaskShadow/MaskShadow.d.mts +2 -2
- package/es/Menu/Menu.d.mts +2 -2
- package/es/Menu/sharedStyle.d.mts +18 -0
- package/es/Menu/sharedStyle.mjs +30 -54
- package/es/Menu/sharedStyle.mjs.map +1 -1
- package/es/Mermaid/Mermaid.d.mts +2 -2
- package/es/Mermaid/SyntaxMermaid/index.d.mts +2 -2
- package/es/Modal/Modal.d.mts +2 -2
- package/es/Modal/ModalProvider.d.mts +2 -2
- package/es/Modal/imperative.d.mts +2 -2
- package/es/MotionProvider/index.d.mts +2 -2
- package/es/Popover/ArrowIcon.d.mts +2 -2
- package/es/Popover/atoms.d.mts +9 -9
- package/es/Popover/context.d.mts +2 -2
- package/es/SearchBar/SearchBar.d.mts +2 -2
- package/es/Segmented/Segmented.d.mts +2 -2
- package/es/Select/Select.d.mts +2 -2
- package/es/SideNav/SideNav.d.mts +2 -2
- package/es/SliderWithInput/SliderWithInput.d.mts +2 -2
- package/es/SortableList/components/DragHandle.d.mts +2 -2
- package/es/SortableList/components/SortableItem.d.mts +2 -2
- package/es/ThemeProvider/ThemeProvider.d.mts +2 -2
- package/es/Toc/Toc.d.mts +2 -2
- package/es/Video/index.d.mts +2 -2
- package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
- package/es/awesome/BottomGradientButton/BottomGradientButton.d.mts +2 -2
- package/es/awesome/Features/Features.d.mts +2 -2
- package/es/awesome/Giscus/Giscus.d.mts +2 -2
- package/es/awesome/GradientButton/GradientButton.d.mts +2 -2
- package/es/awesome/GridBackground/GridBackground.d.mts +2 -2
- package/es/awesome/GridBackground/GridShowcase.d.mts +2 -2
- package/es/awesome/Hero/Hero.d.mts +2 -2
- package/es/awesome/Spline/Spine.d.mts +2 -2
- package/es/awesome/Spotlight/Spotlight.d.mts +2 -2
- package/es/awesome/SpotlightCard/SpotlightCard.d.mts +2 -2
- package/es/awesome/TypewriterEffect/TypewriterEffect.d.mts +2 -2
- package/es/brand/LobeChat/index.d.mts +2 -2
- package/es/brand/LobeHub/index.d.mts +2 -2
- package/es/brand/LogoThree/LogoSpline.d.mts +2 -2
- package/es/brand/LogoThree/index.d.mts +2 -2
- package/es/chat/BackBottom/BackBottom.d.mts +2 -2
- package/es/chat/ChatInputArea/components/ChatInputAreaInner.d.mts +2 -2
- package/es/chat/ChatItem/ChatItem.d.mts +2 -2
- package/es/chat/ChatList/ChatList.d.mts +2 -2
- package/es/chat/EditableMessage/EditableMessage.d.mts +2 -2
- package/es/chat/EditableMessageList/EditableMessageList.d.mts +2 -2
- package/es/chat/MessageInput/MessageInput.d.mts +2 -2
- package/es/chat/MessageModal/MessageModal.d.mts +2 -2
- package/es/color/ColorScales/index.d.mts +2 -2
- package/es/color/CssVar/index.d.mts +2 -2
- package/es/i18n/context.d.mts +2 -2
- package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
- package/es/icons/lucideExtra/CreateBotIcon.d.mts +2 -2
- package/es/icons/lucideExtra/DiscordIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GlobeOffIcon.d.mts +2 -2
- package/es/icons/lucideExtra/GroupBotIcon.d.mts +2 -2
- package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +3 -3
- package/es/icons/lucideExtra/LeftClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/McpIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ProviderIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +3 -3
- package/es/index.d.mts +7 -1
- package/es/index.mjs +5 -1
- package/es/mdx/Mdx/index.d.mts +2 -2
- package/es/mobile/ChatHeader/ChatHeaderTitle.d.mts +2 -2
- package/es/mobile/ChatInputArea/components/ChatSendButton.d.mts +2 -2
- package/es/mobile/TabBar/TabBar.d.mts +2 -2
- package/es/storybook/StoryBook/index.d.mts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { LobeSwitchChangeEventHandler, LobeSwitchContextType, LobeSwitchIconProps, LobeSwitchRootProps, LobeSwitchThumbProps } from "./type.mjs";
|
|
2
|
+
import { styles } from "./style.mjs";
|
|
3
|
+
import * as react_jsx_runtime26 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/LobeSwitch/atoms.d.ts
|
|
6
|
+
declare const useLobeSwitchContext: () => LobeSwitchContextType;
|
|
7
|
+
type LobeSwitchRootInternalProps = Omit<LobeSwitchRootProps, 'onCheckedChange' | 'onClick'> & {
|
|
8
|
+
onCheckedChange?: LobeSwitchChangeEventHandler;
|
|
9
|
+
onClick?: LobeSwitchChangeEventHandler;
|
|
10
|
+
};
|
|
11
|
+
declare const LobeSwitchRoot: {
|
|
12
|
+
({
|
|
13
|
+
checked,
|
|
14
|
+
className,
|
|
15
|
+
defaultChecked,
|
|
16
|
+
onCheckedChange,
|
|
17
|
+
onClick,
|
|
18
|
+
size,
|
|
19
|
+
children,
|
|
20
|
+
disabled,
|
|
21
|
+
readOnly,
|
|
22
|
+
required,
|
|
23
|
+
inputRef,
|
|
24
|
+
id,
|
|
25
|
+
name,
|
|
26
|
+
...rest
|
|
27
|
+
}: LobeSwitchRootInternalProps): react_jsx_runtime26.JSX.Element;
|
|
28
|
+
displayName: string;
|
|
29
|
+
};
|
|
30
|
+
declare const LobeSwitchThumb: {
|
|
31
|
+
({
|
|
32
|
+
className,
|
|
33
|
+
pressedAnimation,
|
|
34
|
+
size,
|
|
35
|
+
transition,
|
|
36
|
+
children,
|
|
37
|
+
...rest
|
|
38
|
+
}: LobeSwitchThumbProps): react_jsx_runtime26.JSX.Element;
|
|
39
|
+
displayName: string;
|
|
40
|
+
};
|
|
41
|
+
declare const LobeSwitchIcon: {
|
|
42
|
+
({
|
|
43
|
+
children,
|
|
44
|
+
className,
|
|
45
|
+
position,
|
|
46
|
+
transition,
|
|
47
|
+
...rest
|
|
48
|
+
}: LobeSwitchIconProps & {
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
size?: "default" | "small";
|
|
51
|
+
}): react_jsx_runtime26.JSX.Element;
|
|
52
|
+
displayName: string;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { LobeSwitchIcon, LobeSwitchRoot, LobeSwitchThumb, useLobeSwitchContext };
|
|
56
|
+
//# sourceMappingURL=atoms.d.mts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMotionComponent } from "../MotionProvider/index.mjs";
|
|
4
|
+
import { rootVariants, styles, thumbVariants } from "./style.mjs";
|
|
5
|
+
import { createContext, useContext, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { cx } from "antd-style";
|
|
8
|
+
import useMergeState from "use-merge-value";
|
|
9
|
+
import { Switch } from "@base-ui/react/switch";
|
|
10
|
+
|
|
11
|
+
//#region src/LobeSwitch/atoms.tsx
|
|
12
|
+
const LobeSwitchContext = createContext(null);
|
|
13
|
+
const useLobeSwitchContext = () => {
|
|
14
|
+
const context = useContext(LobeSwitchContext);
|
|
15
|
+
if (!context) throw new Error("useLobeSwitchContext must be used within a LobeSwitchRoot");
|
|
16
|
+
return context;
|
|
17
|
+
};
|
|
18
|
+
const LobeSwitchRoot = ({ checked, className, defaultChecked, onCheckedChange, onClick, size = "default", children, disabled, readOnly, required, inputRef, id, name, ...rest }) => {
|
|
19
|
+
const Motion = useMotionComponent();
|
|
20
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
21
|
+
const lastEventRef = useRef(null);
|
|
22
|
+
const [isChecked, setIsChecked] = useMergeState(defaultChecked ?? false, {
|
|
23
|
+
defaultValue: defaultChecked,
|
|
24
|
+
onChange: (value) => {
|
|
25
|
+
if (lastEventRef.current) onCheckedChange?.(value, lastEventRef.current);
|
|
26
|
+
},
|
|
27
|
+
value: checked
|
|
28
|
+
});
|
|
29
|
+
const baseClassName = rootVariants({ size });
|
|
30
|
+
const contextValue = useMemo(() => ({
|
|
31
|
+
isChecked: Boolean(isChecked),
|
|
32
|
+
isPressed,
|
|
33
|
+
setIsChecked: (value) => setIsChecked(value),
|
|
34
|
+
setIsPressed
|
|
35
|
+
}), [
|
|
36
|
+
isChecked,
|
|
37
|
+
isPressed,
|
|
38
|
+
setIsChecked
|
|
39
|
+
]);
|
|
40
|
+
const handleClick = (event) => {
|
|
41
|
+
lastEventRef.current = event;
|
|
42
|
+
onClick?.(!isChecked, event);
|
|
43
|
+
};
|
|
44
|
+
const handleKeyDown = (event) => {
|
|
45
|
+
if (event.key === "Enter" || event.key === " ") lastEventRef.current = event;
|
|
46
|
+
rest.onKeyDown?.(event);
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ jsx(LobeSwitchContext.Provider, {
|
|
49
|
+
value: contextValue,
|
|
50
|
+
children: /* @__PURE__ */ jsx(Switch.Root, {
|
|
51
|
+
checked: isChecked,
|
|
52
|
+
defaultChecked,
|
|
53
|
+
disabled,
|
|
54
|
+
id,
|
|
55
|
+
inputRef,
|
|
56
|
+
name,
|
|
57
|
+
onCheckedChange: setIsChecked,
|
|
58
|
+
readOnly,
|
|
59
|
+
render: /* @__PURE__ */ jsx(Motion.button, {
|
|
60
|
+
...rest,
|
|
61
|
+
className: cx(baseClassName, className),
|
|
62
|
+
initial: false,
|
|
63
|
+
onClick: handleClick,
|
|
64
|
+
onKeyDown: handleKeyDown,
|
|
65
|
+
onTap: () => setIsPressed(false),
|
|
66
|
+
onTapCancel: () => setIsPressed(false),
|
|
67
|
+
onTapStart: () => setIsPressed(true),
|
|
68
|
+
whileTap: "tap"
|
|
69
|
+
}),
|
|
70
|
+
required,
|
|
71
|
+
children
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
LobeSwitchRoot.displayName = "LobeSwitchRoot";
|
|
76
|
+
const LobeSwitchThumb = ({ className, pressedAnimation, size = "default", transition = {
|
|
77
|
+
damping: 25,
|
|
78
|
+
stiffness: 300,
|
|
79
|
+
type: "spring"
|
|
80
|
+
}, children, ...rest }) => {
|
|
81
|
+
const Motion = useMotionComponent();
|
|
82
|
+
const { isPressed } = useLobeSwitchContext();
|
|
83
|
+
const baseClassName = thumbVariants({ size });
|
|
84
|
+
const defaultPressedAnimation = { width: size === "small" ? 16 : 22 };
|
|
85
|
+
return /* @__PURE__ */ jsx(Switch.Thumb, { render: /* @__PURE__ */ jsx(Motion.span, {
|
|
86
|
+
animate: isPressed ? pressedAnimation || defaultPressedAnimation : void 0,
|
|
87
|
+
className: cx(baseClassName, className),
|
|
88
|
+
layout: true,
|
|
89
|
+
transition,
|
|
90
|
+
...rest,
|
|
91
|
+
children
|
|
92
|
+
}) });
|
|
93
|
+
};
|
|
94
|
+
LobeSwitchThumb.displayName = "LobeSwitchThumb";
|
|
95
|
+
const getIconPositionClass = (position, size) => {
|
|
96
|
+
if (position === "thumb") return styles.iconThumb;
|
|
97
|
+
if (position === "left") return size === "small" ? styles.iconLeftSmall : styles.iconLeft;
|
|
98
|
+
return size === "small" ? styles.iconRightSmall : styles.iconRight;
|
|
99
|
+
};
|
|
100
|
+
const LobeSwitchIcon = ({ children, className, position, transition = {
|
|
101
|
+
bounce: 0,
|
|
102
|
+
type: "spring"
|
|
103
|
+
}, ...rest }) => {
|
|
104
|
+
const Motion = useMotionComponent();
|
|
105
|
+
const { isChecked } = useLobeSwitchContext();
|
|
106
|
+
const size = rest.size || "default";
|
|
107
|
+
const isAnimated = useMemo(() => {
|
|
108
|
+
if (position === "right") return !isChecked;
|
|
109
|
+
if (position === "left") return isChecked;
|
|
110
|
+
if (position === "thumb") return true;
|
|
111
|
+
return false;
|
|
112
|
+
}, [position, isChecked]);
|
|
113
|
+
const positionClass = getIconPositionClass(position, size);
|
|
114
|
+
return /* @__PURE__ */ jsx(Motion.span, {
|
|
115
|
+
animate: isAnimated ? {
|
|
116
|
+
opacity: 1,
|
|
117
|
+
scale: 1
|
|
118
|
+
} : {
|
|
119
|
+
opacity: 0,
|
|
120
|
+
scale: 0
|
|
121
|
+
},
|
|
122
|
+
className: cx(styles.icon, positionClass, className),
|
|
123
|
+
transition,
|
|
124
|
+
...rest,
|
|
125
|
+
children
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
LobeSwitchIcon.displayName = "LobeSwitchIcon";
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { LobeSwitchIcon, LobeSwitchRoot, LobeSwitchThumb, useLobeSwitchContext };
|
|
132
|
+
//# sourceMappingURL=atoms.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["useControlledState"],"sources":["../../src/LobeSwitch/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Switch } from '@base-ui/react/switch';\nimport { cx } from 'antd-style';\nimport type { KeyboardEvent, MouseEvent } from 'react';\nimport { createContext, useContext, useMemo, useRef, useState } from 'react';\nimport useControlledState from 'use-merge-value';\n\nimport { useMotionComponent } from '@/MotionProvider';\n\nimport { rootVariants, styles, thumbVariants } from './style';\nimport type {\n LobeSwitchChangeEventHandler,\n LobeSwitchContextType,\n LobeSwitchIconPosition,\n LobeSwitchIconProps,\n LobeSwitchRootProps,\n LobeSwitchThumbProps,\n} from './type';\n\nconst LobeSwitchContext = createContext<LobeSwitchContextType | null>(null);\n\nexport const useLobeSwitchContext = () => {\n const context = useContext(LobeSwitchContext);\n if (!context) {\n throw new Error('useLobeSwitchContext must be used within a LobeSwitchRoot');\n }\n return context;\n};\n\ntype LobeSwitchRootInternalProps = Omit<LobeSwitchRootProps, 'onCheckedChange' | 'onClick'> & {\n onCheckedChange?: LobeSwitchChangeEventHandler;\n onClick?: LobeSwitchChangeEventHandler;\n};\n\nexport const LobeSwitchRoot = ({\n checked,\n className,\n defaultChecked,\n onCheckedChange,\n onClick,\n size = 'default',\n children,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n name,\n ...rest\n}: LobeSwitchRootInternalProps) => {\n const Motion = useMotionComponent();\n const [isPressed, setIsPressed] = useState(false);\n const lastEventRef = useRef<MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>>(\n null,\n );\n\n const [isChecked, setIsChecked] = useControlledState(defaultChecked ?? false, {\n defaultValue: defaultChecked,\n onChange: (value: boolean) => {\n if (lastEventRef.current) {\n onCheckedChange?.(value, lastEventRef.current);\n }\n },\n value: checked,\n });\n\n const baseClassName = rootVariants({ size });\n\n const contextValue = useMemo(\n () => ({\n isChecked: Boolean(isChecked),\n isPressed,\n setIsChecked: (value: boolean) => setIsChecked(value),\n setIsPressed,\n }),\n [isChecked, isPressed, setIsChecked],\n );\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n lastEventRef.current = event;\n onClick?.(!isChecked, event);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n lastEventRef.current = event;\n }\n (rest as any).onKeyDown?.(event);\n };\n\n return (\n <LobeSwitchContext.Provider value={contextValue}>\n <Switch.Root\n checked={isChecked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n id={id}\n inputRef={inputRef}\n name={name}\n onCheckedChange={setIsChecked}\n readOnly={readOnly}\n render={\n <Motion.button\n {...rest}\n className={cx(baseClassName, className)}\n initial={false}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onTap={() => setIsPressed(false)}\n onTapCancel={() => setIsPressed(false)}\n onTapStart={() => setIsPressed(true)}\n whileTap=\"tap\"\n />\n }\n required={required}\n >\n {children}\n </Switch.Root>\n </LobeSwitchContext.Provider>\n );\n};\n\nLobeSwitchRoot.displayName = 'LobeSwitchRoot';\n\nexport const LobeSwitchThumb = ({\n className,\n pressedAnimation,\n size = 'default',\n transition = { damping: 25, stiffness: 300, type: 'spring' },\n children,\n ...rest\n}: LobeSwitchThumbProps) => {\n const Motion = useMotionComponent();\n const { isPressed } = useLobeSwitchContext();\n const baseClassName = thumbVariants({ size });\n\n const defaultPressedAnimation = {\n width: size === 'small' ? 16 : 22,\n };\n\n return (\n <Switch.Thumb\n render={\n <Motion.span\n animate={isPressed ? pressedAnimation || defaultPressedAnimation : undefined}\n className={cx(baseClassName, className)}\n layout\n transition={transition}\n {...rest}\n >\n {children}\n </Motion.span>\n }\n />\n );\n};\n\nLobeSwitchThumb.displayName = 'LobeSwitchThumb';\n\nconst getIconPositionClass = (position: LobeSwitchIconPosition, size: 'default' | 'small') => {\n if (position === 'thumb') return styles.iconThumb;\n if (position === 'left') return size === 'small' ? styles.iconLeftSmall : styles.iconLeft;\n return size === 'small' ? styles.iconRightSmall : styles.iconRight;\n};\n\nexport const LobeSwitchIcon = ({\n children,\n className,\n position,\n transition = { bounce: 0, type: 'spring' },\n ...rest\n}: LobeSwitchIconProps & { children?: React.ReactNode; size?: 'default' | 'small' }) => {\n const Motion = useMotionComponent();\n const { isChecked } = useLobeSwitchContext();\n const size = (rest as any).size || 'default';\n\n const isAnimated = useMemo(() => {\n if (position === 'right') return !isChecked;\n if (position === 'left') return isChecked;\n if (position === 'thumb') return true;\n return false;\n }, [position, isChecked]);\n\n const positionClass = getIconPositionClass(position, size);\n\n return (\n <Motion.span\n animate={isAnimated ? { opacity: 1, scale: 1 } : { opacity: 0, scale: 0 }}\n className={cx(styles.icon, positionClass, className)}\n transition={transition}\n {...rest}\n >\n {children}\n </Motion.span>\n );\n};\n\nLobeSwitchIcon.displayName = 'LobeSwitchIcon';\n\nexport { styles as lobeSwitchStyles } from './style';\n"],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LobeSwitchChangeEventHandler, LobeSwitchClassNames, LobeSwitchClickEventHandler, LobeSwitchContextType, LobeSwitchIconPosition, LobeSwitchIconProps, LobeSwitchProps, LobeSwitchRootProps, LobeSwitchSize, LobeSwitchStyles, LobeSwitchThumbProps } from "./type.mjs";
|
|
2
|
+
import { styles } from "./style.mjs";
|
|
3
|
+
import { LobeSwitchIcon, LobeSwitchRoot, LobeSwitchThumb, useLobeSwitchContext } from "./atoms.mjs";
|
|
4
|
+
import { LobeSwitch } from "./LobeSwitch.mjs";
|
|
5
|
+
export { type LobeSwitchChangeEventHandler, type LobeSwitchClassNames, type LobeSwitchClickEventHandler, type LobeSwitchContextType, LobeSwitchIcon, type LobeSwitchIconPosition, type LobeSwitchIconProps, type LobeSwitchProps, LobeSwitchRoot, type LobeSwitchRootProps, type LobeSwitchSize, type LobeSwitchStyles, LobeSwitchThumb, type LobeSwitchThumbProps, LobeSwitch as default, styles as lobeSwitchStyles, useLobeSwitchContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.d.mts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.mjs';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { styles } from "./style.mjs";
|
|
2
|
+
import { LobeSwitchIcon, LobeSwitchRoot, LobeSwitchThumb, useLobeSwitchContext } from "./atoms.mjs";
|
|
3
|
+
import LobeSwitch_default from "./LobeSwitch.mjs";
|
|
4
|
+
|
|
5
|
+
export { LobeSwitchIcon, LobeSwitchRoot, LobeSwitchThumb, LobeSwitch_default as default, styles as lobeSwitchStyles, useLobeSwitchContext };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/LobeSwitch/style.d.ts
|
|
2
|
+
declare const styles: {
|
|
3
|
+
icon: string;
|
|
4
|
+
iconLeft: string;
|
|
5
|
+
iconLeftSmall: string;
|
|
6
|
+
iconRight: string;
|
|
7
|
+
iconRightSmall: string;
|
|
8
|
+
iconThumb: string;
|
|
9
|
+
loading: string;
|
|
10
|
+
root: string;
|
|
11
|
+
rootDefault: string;
|
|
12
|
+
rootSmall: string;
|
|
13
|
+
thumb: string;
|
|
14
|
+
thumbDefault: string;
|
|
15
|
+
thumbSmall: string;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { styles };
|
|
19
|
+
//# sourceMappingURL=style.d.mts.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
//#region src/LobeSwitch/style.ts
|
|
5
|
+
const styles = createStaticStyles(({ css: css$1, cssVar: cssVar$1 }) => ({
|
|
6
|
+
icon: css$1`
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
|
|
9
|
+
position: absolute;
|
|
10
|
+
inset-block: 0 0;
|
|
11
|
+
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
|
|
16
|
+
color: ${cssVar$1.colorTextLightSolid};
|
|
17
|
+
`,
|
|
18
|
+
iconLeft: css$1`
|
|
19
|
+
inset-inline-start: 5px;
|
|
20
|
+
`,
|
|
21
|
+
iconLeftSmall: css$1`
|
|
22
|
+
inset-inline-start: 4px;
|
|
23
|
+
`,
|
|
24
|
+
iconRight: css$1`
|
|
25
|
+
inset-inline-end: 5px;
|
|
26
|
+
`,
|
|
27
|
+
iconRightSmall: css$1`
|
|
28
|
+
inset-inline-end: 4px;
|
|
29
|
+
`,
|
|
30
|
+
iconThumb: css$1`
|
|
31
|
+
position: relative;
|
|
32
|
+
inset: unset;
|
|
33
|
+
transform: none;
|
|
34
|
+
color: ${cssVar$1.colorPrimary};
|
|
35
|
+
`,
|
|
36
|
+
loading: css$1`
|
|
37
|
+
@keyframes lobe-switch-loading {
|
|
38
|
+
0% {
|
|
39
|
+
transform: rotate(0deg);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
100% {
|
|
43
|
+
transform: rotate(360deg);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
animation: lobe-switch-loading 1s linear infinite;
|
|
48
|
+
`,
|
|
49
|
+
root: css$1`
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
user-select: none;
|
|
52
|
+
|
|
53
|
+
position: relative;
|
|
54
|
+
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: flex-start;
|
|
59
|
+
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
padding: 2px;
|
|
62
|
+
border: 0;
|
|
63
|
+
border-radius: 100px;
|
|
64
|
+
|
|
65
|
+
background: ${cssVar$1.colorTextQuaternary};
|
|
66
|
+
outline: none;
|
|
67
|
+
|
|
68
|
+
transition: background 150ms ${cssVar$1.motionEaseOut};
|
|
69
|
+
|
|
70
|
+
&:focus-visible {
|
|
71
|
+
outline: 2px solid ${cssVar$1.colorPrimaryBorder};
|
|
72
|
+
outline-offset: 1px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:hover:not([data-disabled]) {
|
|
76
|
+
background: ${cssVar$1.colorTextTertiary};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&[data-checked] {
|
|
80
|
+
justify-content: flex-end;
|
|
81
|
+
background: ${cssVar$1.colorPrimary};
|
|
82
|
+
|
|
83
|
+
&:hover:not([data-disabled]) {
|
|
84
|
+
background: ${cssVar$1.colorPrimaryHover};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&[data-disabled] {
|
|
89
|
+
cursor: not-allowed;
|
|
90
|
+
opacity: 0.5;
|
|
91
|
+
}
|
|
92
|
+
`,
|
|
93
|
+
rootDefault: css$1`
|
|
94
|
+
width: 44px;
|
|
95
|
+
min-width: 44px;
|
|
96
|
+
height: 22px;
|
|
97
|
+
`,
|
|
98
|
+
rootSmall: css$1`
|
|
99
|
+
width: 28px;
|
|
100
|
+
min-width: 28px;
|
|
101
|
+
height: 16px;
|
|
102
|
+
`,
|
|
103
|
+
thumb: css$1`
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
|
|
111
|
+
background: ${cssVar$1.colorBgContainer};
|
|
112
|
+
box-shadow:
|
|
113
|
+
0 2px 4px 0 rgba(0, 35, 11, 20%),
|
|
114
|
+
0 1px 2px 0 rgba(0, 0, 0, 8%);
|
|
115
|
+
|
|
116
|
+
[data-disabled] > & {
|
|
117
|
+
box-shadow: none;
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
thumbDefault: css$1`
|
|
121
|
+
width: 18px;
|
|
122
|
+
height: 18px;
|
|
123
|
+
`,
|
|
124
|
+
thumbSmall: css$1`
|
|
125
|
+
width: 12px;
|
|
126
|
+
height: 12px;
|
|
127
|
+
`
|
|
128
|
+
}));
|
|
129
|
+
const rootVariants = cva(styles.root, {
|
|
130
|
+
defaultVariants: { size: "default" },
|
|
131
|
+
variants: { size: {
|
|
132
|
+
default: styles.rootDefault,
|
|
133
|
+
small: styles.rootSmall
|
|
134
|
+
} }
|
|
135
|
+
});
|
|
136
|
+
const thumbVariants = cva(styles.thumb, {
|
|
137
|
+
defaultVariants: { size: "default" },
|
|
138
|
+
variants: { size: {
|
|
139
|
+
default: styles.thumbDefault,
|
|
140
|
+
small: styles.thumbSmall
|
|
141
|
+
} }
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
export { rootVariants, styles, thumbVariants };
|
|
146
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["cssVar"],"sources":["../../src/LobeSwitch/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n icon: css`\n pointer-events: none;\n\n position: absolute;\n inset-block: 0 0;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n color: ${cssVar.colorTextLightSolid};\n `,\n iconLeft: css`\n inset-inline-start: 5px;\n `,\n iconLeftSmall: css`\n inset-inline-start: 4px;\n `,\n iconRight: css`\n inset-inline-end: 5px;\n `,\n iconRightSmall: css`\n inset-inline-end: 4px;\n `,\n iconThumb: css`\n position: relative;\n inset: unset;\n transform: none;\n color: ${cssVar.colorPrimary};\n `,\n loading: css`\n @keyframes lobe-switch-loading {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n }\n\n animation: lobe-switch-loading 1s linear infinite;\n `,\n root: css`\n cursor: pointer;\n user-select: none;\n\n position: relative;\n\n overflow: hidden;\n display: inline-flex;\n align-items: center;\n justify-content: flex-start;\n\n box-sizing: border-box;\n padding: 2px;\n border: 0;\n border-radius: 100px;\n\n background: ${cssVar.colorTextQuaternary};\n outline: none;\n\n transition: background 150ms ${cssVar.motionEaseOut};\n\n &:focus-visible {\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: 1px;\n }\n\n &:hover:not([data-disabled]) {\n background: ${cssVar.colorTextTertiary};\n }\n\n &[data-checked] {\n justify-content: flex-end;\n background: ${cssVar.colorPrimary};\n\n &:hover:not([data-disabled]) {\n background: ${cssVar.colorPrimaryHover};\n }\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n opacity: 0.5;\n }\n `,\n rootDefault: css`\n width: 44px;\n min-width: 44px;\n height: 22px;\n `,\n rootSmall: css`\n width: 28px;\n min-width: 28px;\n height: 16px;\n `,\n thumb: css`\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n\n border-radius: 50%;\n\n background: ${cssVar.colorBgContainer};\n box-shadow:\n 0 2px 4px 0 rgba(0, 35, 11, 20%),\n 0 1px 2px 0 rgba(0, 0, 0, 8%);\n\n [data-disabled] > & {\n box-shadow: none;\n }\n `,\n thumbDefault: css`\n width: 18px;\n height: 18px;\n `,\n thumbSmall: css`\n width: 12px;\n height: 12px;\n `,\n}));\n\nexport const rootVariants = cva(styles.root, {\n defaultVariants: {\n size: 'default',\n },\n variants: {\n size: {\n default: styles.rootDefault,\n small: styles.rootSmall,\n },\n },\n});\n\nexport const thumbVariants = cva(styles.thumb, {\n defaultVariants: {\n size: 'default',\n },\n variants: {\n size: {\n default: styles.thumbDefault,\n small: styles.thumbSmall,\n },\n },\n});\n"],"mappings":";;;;AAGA,MAAa,SAAS,oBAAoB,EAAE,YAAK,wBAAc;CAC7D,MAAM,KAAG;;;;;;;;;;aAUEA,SAAO,oBAAoB;;CAEtC,UAAU,KAAG;;;CAGb,eAAe,KAAG;;;CAGlB,WAAW,KAAG;;;CAGd,gBAAgB,KAAG;;;CAGnB,WAAW,KAAG;;;;aAIHA,SAAO,aAAa;;CAE/B,SAAS,KAAG;;;;;;;;;;;;;CAaZ,MAAM,KAAG;;;;;;;;;;;;;;;;kBAgBOA,SAAO,oBAAoB;;;mCAGVA,SAAO,cAAc;;;2BAG7BA,SAAO,mBAAmB;;;;;oBAKjCA,SAAO,kBAAkB;;;;;oBAKzBA,SAAO,aAAa;;;sBAGlBA,SAAO,kBAAkB;;;;;;;;;CAS7C,aAAa,KAAG;;;;;CAKhB,WAAW,KAAG;;;;;CAKd,OAAO,KAAG;;;;;;;;kBAQMA,SAAO,iBAAiB;;;;;;;;;CASxC,cAAc,KAAG;;;;CAIjB,YAAY,KAAG;;;;CAIhB,EAAE;AAEH,MAAa,eAAe,IAAI,OAAO,MAAM;CAC3C,iBAAiB,EACf,MAAM,WACP;CACD,UAAU,EACR,MAAM;EACJ,SAAS,OAAO;EAChB,OAAO,OAAO;EACf,EACF;CACF,CAAC;AAEF,MAAa,gBAAgB,IAAI,OAAO,OAAO;CAC7C,iBAAiB,EACf,MAAM,WACP;CACD,UAAU,EACR,MAAM;EACJ,SAAS,OAAO;EAChB,OAAO,OAAO;EACf,EACF;CACF,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CSSProperties, ComponentProps, KeyboardEvent, MouseEvent, ReactNode, Ref } from "react";
|
|
2
|
+
import { HTMLMotionProps, TargetAndTransition, Transition } from "motion/react";
|
|
3
|
+
import { Switch } from "@base-ui/react/switch";
|
|
4
|
+
|
|
5
|
+
//#region src/LobeSwitch/type.d.ts
|
|
6
|
+
type LobeSwitchSize = 'default' | 'small';
|
|
7
|
+
type LobeSwitchChangeEventHandler = (checked: boolean, event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
|
|
8
|
+
type LobeSwitchClickEventHandler = LobeSwitchChangeEventHandler;
|
|
9
|
+
interface LobeSwitchClassNames {
|
|
10
|
+
content?: string;
|
|
11
|
+
root?: string;
|
|
12
|
+
thumb?: string;
|
|
13
|
+
}
|
|
14
|
+
interface LobeSwitchStyles {
|
|
15
|
+
content?: CSSProperties;
|
|
16
|
+
root?: CSSProperties;
|
|
17
|
+
thumb?: CSSProperties;
|
|
18
|
+
}
|
|
19
|
+
interface LobeSwitchContextType {
|
|
20
|
+
isChecked: boolean;
|
|
21
|
+
isPressed: boolean;
|
|
22
|
+
setIsChecked: (checked: boolean) => void;
|
|
23
|
+
setIsPressed: (pressed: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
type LobeSwitchRootProps = Omit<ComponentProps<typeof Switch.Root>, 'render'> & HTMLMotionProps<'button'> & {
|
|
26
|
+
size?: LobeSwitchSize;
|
|
27
|
+
};
|
|
28
|
+
type LobeSwitchThumbProps = Omit<ComponentProps<typeof Switch.Thumb>, 'render'> & HTMLMotionProps<'span'> & {
|
|
29
|
+
pressedAnimation?: TargetAndTransition | boolean;
|
|
30
|
+
size?: LobeSwitchSize;
|
|
31
|
+
transition?: Transition;
|
|
32
|
+
};
|
|
33
|
+
type LobeSwitchIconPosition = 'left' | 'right' | 'thumb';
|
|
34
|
+
type LobeSwitchIconProps = HTMLMotionProps<'span'> & {
|
|
35
|
+
position: LobeSwitchIconPosition;
|
|
36
|
+
transition?: Transition;
|
|
37
|
+
};
|
|
38
|
+
interface LobeSwitchProps {
|
|
39
|
+
/**
|
|
40
|
+
* Whether to set focus automatically when mounted
|
|
41
|
+
*/
|
|
42
|
+
autoFocus?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the switch is checked
|
|
45
|
+
*/
|
|
46
|
+
checked?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Icon to show when checked (left position)
|
|
49
|
+
*/
|
|
50
|
+
checkedChildren?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Custom class name
|
|
53
|
+
*/
|
|
54
|
+
className?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Custom class names for each part
|
|
57
|
+
*/
|
|
58
|
+
classNames?: LobeSwitchClassNames;
|
|
59
|
+
/**
|
|
60
|
+
* Initial checked state (uncontrolled)
|
|
61
|
+
*/
|
|
62
|
+
defaultChecked?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Alias for `defaultChecked`
|
|
65
|
+
*/
|
|
66
|
+
defaultValue?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the switch is disabled
|
|
69
|
+
*/
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Element id
|
|
73
|
+
*/
|
|
74
|
+
id?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Show loading indicator
|
|
77
|
+
*/
|
|
78
|
+
loading?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Name attribute for form submission
|
|
81
|
+
*/
|
|
82
|
+
name?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Callback when the switch state changes
|
|
85
|
+
*/
|
|
86
|
+
onChange?: LobeSwitchChangeEventHandler;
|
|
87
|
+
/**
|
|
88
|
+
* Callback when clicking the switch
|
|
89
|
+
*/
|
|
90
|
+
onClick?: LobeSwitchClickEventHandler;
|
|
91
|
+
/**
|
|
92
|
+
* Reference to the root element
|
|
93
|
+
*/
|
|
94
|
+
ref?: Ref<HTMLButtonElement>;
|
|
95
|
+
/**
|
|
96
|
+
* Additional class name for root element
|
|
97
|
+
*/
|
|
98
|
+
rootClassName?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Size of the switch
|
|
101
|
+
* @default 'default'
|
|
102
|
+
*/
|
|
103
|
+
size?: LobeSwitchSize;
|
|
104
|
+
/**
|
|
105
|
+
* Custom inline style
|
|
106
|
+
*/
|
|
107
|
+
style?: CSSProperties;
|
|
108
|
+
/**
|
|
109
|
+
* Custom styles for each part
|
|
110
|
+
*/
|
|
111
|
+
styles?: LobeSwitchStyles;
|
|
112
|
+
/**
|
|
113
|
+
* Tab index for keyboard navigation
|
|
114
|
+
*/
|
|
115
|
+
tabIndex?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Native title attribute
|
|
118
|
+
*/
|
|
119
|
+
title?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Icon to show when unchecked (right position)
|
|
122
|
+
*/
|
|
123
|
+
unCheckedChildren?: ReactNode;
|
|
124
|
+
/**
|
|
125
|
+
* Alias for `checked`
|
|
126
|
+
*/
|
|
127
|
+
value?: boolean;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { LobeSwitchChangeEventHandler, LobeSwitchClassNames, LobeSwitchClickEventHandler, LobeSwitchContextType, LobeSwitchIconPosition, LobeSwitchIconProps, LobeSwitchProps, LobeSwitchRootProps, LobeSwitchSize, LobeSwitchStyles, LobeSwitchThumbProps };
|
|
131
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MarkdownProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react59 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Markdown/Markdown.d.ts
|
|
5
|
-
declare const Markdown:
|
|
5
|
+
declare const Markdown: react59.NamedExoticComponent<MarkdownProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Markdown };
|
|
8
8
|
//# sourceMappingURL=Markdown.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TypographyProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react54 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Markdown/Typography.d.ts
|
|
5
|
-
declare const Typography:
|
|
5
|
+
declare const Typography: react54.NamedExoticComponent<TypographyProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Typography };
|
|
8
8
|
//# sourceMappingURL=Typography.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlexboxProps } from "../../../Flex/type.mjs";
|
|
2
2
|
import "../../../Flex/index.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react43 from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/Markdown/components/SearchResultCards/index.d.ts
|
|
@@ -14,7 +14,7 @@ interface SearchResultCardsProps extends FlexboxProps {
|
|
|
14
14
|
dataSource: string[] | SearchResultItem[];
|
|
15
15
|
ref?: Ref<HTMLDivElement>;
|
|
16
16
|
}
|
|
17
|
-
declare const SearchResultCards:
|
|
17
|
+
declare const SearchResultCards: react43.NamedExoticComponent<SearchResultCardsProps>;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { SearchResultCards, SearchResultCardsProps };
|
|
20
20
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MaskShadowProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react22 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/MaskShadow/MaskShadow.d.ts
|
|
5
|
-
declare const MaskShadow:
|
|
5
|
+
declare const MaskShadow: react22.NamedExoticComponent<MaskShadowProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { MaskShadow };
|
|
8
8
|
//# sourceMappingURL=MaskShadow.d.mts.map
|
package/es/Menu/Menu.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MenuProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react21 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Menu/Menu.d.ts
|
|
5
|
-
declare const Menu:
|
|
5
|
+
declare const Menu: react21.NamedExoticComponent<MenuProps<unknown>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Menu };
|
|
8
8
|
//# sourceMappingURL=Menu.d.mts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/Menu/sharedStyle.d.ts
|
|
2
|
+
declare const styles: {
|
|
3
|
+
danger: string;
|
|
4
|
+
empty: string;
|
|
5
|
+
extra: string;
|
|
6
|
+
groupLabel: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
item: string;
|
|
9
|
+
itemContent: string;
|
|
10
|
+
label: string;
|
|
11
|
+
popup: string;
|
|
12
|
+
positioner: string;
|
|
13
|
+
separator: string;
|
|
14
|
+
submenuArrow: string;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { styles };
|
|
18
|
+
//# sourceMappingURL=sharedStyle.d.mts.map
|