@lobehub/ui 4.17.1 → 4.18.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/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 +8 -0
- package/es/CodeDiff/CodeDiff.mjs +122 -0
- package/es/CodeDiff/CodeDiff.mjs.map +1 -0
- package/es/CodeDiff/PatchDiff.d.mts +8 -0
- package/es/CodeDiff/PatchDiff.mjs +101 -0
- package/es/CodeDiff/PatchDiff.mjs.map +1 -0
- package/es/CodeDiff/index.d.mts +4 -0
- package/es/CodeDiff/index.d.ts +1 -0
- package/es/CodeDiff/index.js +1 -0
- package/es/CodeDiff/index.mjs +4 -0
- package/es/CodeDiff/style.mjs +122 -0
- package/es/CodeDiff/style.mjs.map +1 -0
- package/es/CodeDiff/type.d.mts +123 -0
- 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/DraggablePanel/components/DraggablePanelBody.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/DropdownMenu.mjs +13 -42
- package/es/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/es/DropdownMenu/atoms.d.mts +145 -0
- package/es/DropdownMenu/atoms.mjs +163 -0
- package/es/DropdownMenu/atoms.mjs.map +1 -0
- package/es/DropdownMenu/index.d.mts +3 -1
- package/es/DropdownMenu/index.mjs +3 -1
- package/es/DropdownMenu/renderItems.d.mts +10 -0
- package/es/DropdownMenu/renderItems.mjs +22 -47
- package/es/DropdownMenu/renderItems.mjs.map +1 -1
- package/es/EditableText/EditableText.d.mts +2 -2
- 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/components/IconProvider.d.mts +3 -3
- package/es/Image/PreviewGroup.d.mts +2 -2
- package/es/ImageSelect/ImageSelect.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/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/Markdown/type.d.mts +1 -2
- package/es/Menu/Menu.d.mts +2 -2
- package/es/Menu/sharedStyle.mjs +1 -1
- 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/Mermaid/type.d.mts +1 -1
- 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 +7 -0
- package/es/Popover/PopoverGroup.mjs +14 -15
- package/es/Popover/PopoverGroup.mjs.map +1 -1
- package/es/Popover/PopoverPortal.d.mts +6 -0
- package/es/Popover/PopoverPortal.mjs +1 -1
- package/es/Popover/PopoverStandalone.mjs +20 -49
- package/es/Popover/PopoverStandalone.mjs.map +1 -1
- package/es/Popover/atoms.d.mts +77 -0
- package/es/Popover/atoms.mjs +104 -0
- package/es/Popover/atoms.mjs.map +1 -0
- package/es/Popover/context.d.mts +2 -2
- package/es/Popover/groupContext.d.mts +1 -0
- package/es/Popover/groupContext.mjs.map +1 -1
- package/es/Popover/index.d.mts +5 -2
- package/es/Popover/index.mjs +4 -1
- 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/Tooltip/groupContext.mjs.map +1 -1
- 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/Giscus/type.d.mts +4 -4
- 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/hooks/useMermaid.mjs.map +1 -1
- package/es/hooks/useStreamMermaid.mjs.map +1 -1
- package/es/i18n/context.d.mts +2 -2
- package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
- package/es/icons/lucideExtra/CreateBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/DiscordIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GlobeOffIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotIcon.d.mts +3 -3
- 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 -2
- package/es/index.mjs +6 -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/es/utils/placement.d.mts +7 -1
- package/es/utils/placement.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AccordionProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react41 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Accordion/Accordion.d.ts
|
|
5
|
-
declare const Accordion:
|
|
5
|
+
declare const Accordion: react41.NamedExoticComponent<AccordionProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Accordion };
|
|
8
8
|
//# sourceMappingURL=Accordion.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AccordionItemProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react42 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Accordion/AccordionItem.d.ts
|
|
5
|
-
declare const AccordionItem:
|
|
5
|
+
declare const AccordionItem: react42.NamedExoticComponent<AccordionItemProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { AccordionItem };
|
|
8
8
|
//# sourceMappingURL=AccordionItem.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ActionIconProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react40 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/ActionIcon/ActionIcon.d.ts
|
|
5
|
-
declare const ActionIcon:
|
|
5
|
+
declare const ActionIcon: react40.NamedExoticComponent<ActionIconProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ActionIcon };
|
|
8
8
|
//# sourceMappingURL=ActionIcon.d.mts.map
|
package/es/Alert/Alert.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AlertProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react18 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Alert/Alert.d.ts
|
|
5
|
-
declare const Alert:
|
|
5
|
+
declare const Alert: react18.NamedExoticComponent<AlertProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Alert };
|
|
8
8
|
//# sourceMappingURL=Alert.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AutoCompleteProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react55 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/AutoComplete/Select.d.ts
|
|
5
|
-
declare const AutoComplete:
|
|
5
|
+
declare const AutoComplete: react55.NamedExoticComponent<AutoCompleteProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { AutoComplete };
|
|
8
8
|
//# sourceMappingURL=Select.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AvatarGroupProps } from "../type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react54 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Avatar/AvatarGroup/index.d.ts
|
|
5
|
-
declare const AvatarGroup:
|
|
5
|
+
declare const AvatarGroup: react54.NamedExoticComponent<AvatarGroupProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { AvatarGroup };
|
|
8
8
|
//# sourceMappingURL=index.d.mts.map
|
package/es/Burger/Burger.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BurgerProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react31 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Burger/Burger.d.ts
|
|
5
|
-
declare const Burger:
|
|
5
|
+
declare const Burger: react31.NamedExoticComponent<BurgerProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Burger };
|
|
8
8
|
//# sourceMappingURL=Burger.d.mts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CodeDiffProps } from "./type.mjs";
|
|
2
|
+
import * as react29 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/CodeDiff/CodeDiff.d.ts
|
|
5
|
+
declare const CodeDiff: react29.NamedExoticComponent<CodeDiffProps>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { CodeDiff };
|
|
8
|
+
//# sourceMappingURL=CodeDiff.d.mts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import FlexBasic_default from "../Flex/FlexBasic.mjs";
|
|
4
|
+
import MaterialFileTypeIcon_default from "../MaterialFileTypeIcon/MaterialFileTypeIcon.mjs";
|
|
5
|
+
import { headerVariants, prefix, styles, variants } from "./style.mjs";
|
|
6
|
+
import { memo, useMemo } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { cx } from "antd-style";
|
|
9
|
+
import { MultiFileDiff } from "@pierre/diffs/react";
|
|
10
|
+
|
|
11
|
+
//#region src/CodeDiff/CodeDiff.tsx
|
|
12
|
+
const countContentChanges = (oldContent, newContent) => {
|
|
13
|
+
const oldLines = oldContent.split("\n");
|
|
14
|
+
const newLines = newContent.split("\n");
|
|
15
|
+
const oldSet = new Set(oldLines);
|
|
16
|
+
const newSet = new Set(newLines);
|
|
17
|
+
let deletions = 0;
|
|
18
|
+
let additions = 0;
|
|
19
|
+
for (const line of oldLines) if (!newSet.has(line)) deletions++;
|
|
20
|
+
for (const line of newLines) if (!oldSet.has(line)) additions++;
|
|
21
|
+
return {
|
|
22
|
+
additions,
|
|
23
|
+
deletions
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const CodeDiff = memo(({ oldContent, newContent, language, fileName, viewMode = "split", showHeader = true, variant = "filled", className, classNames, styles: customStyles, actionsRender, diffOptions, ...rest }) => {
|
|
27
|
+
const displayName = useMemo(() => {
|
|
28
|
+
if (fileName) return fileName;
|
|
29
|
+
if (language) return language;
|
|
30
|
+
return "diff";
|
|
31
|
+
}, [fileName, language]);
|
|
32
|
+
const { additions, deletions } = useMemo(() => countContentChanges(oldContent, newContent), [oldContent, newContent]);
|
|
33
|
+
const actions = useMemo(() => {
|
|
34
|
+
if (!actionsRender) return null;
|
|
35
|
+
return actionsRender({
|
|
36
|
+
newContent,
|
|
37
|
+
oldContent,
|
|
38
|
+
originalNode: null
|
|
39
|
+
});
|
|
40
|
+
}, [
|
|
41
|
+
actionsRender,
|
|
42
|
+
oldContent,
|
|
43
|
+
newContent
|
|
44
|
+
]);
|
|
45
|
+
const oldFile = useMemo(() => ({
|
|
46
|
+
contents: oldContent,
|
|
47
|
+
lang: language,
|
|
48
|
+
name: fileName || "file"
|
|
49
|
+
}), [
|
|
50
|
+
oldContent,
|
|
51
|
+
language,
|
|
52
|
+
fileName
|
|
53
|
+
]);
|
|
54
|
+
const newFile = useMemo(() => ({
|
|
55
|
+
contents: newContent,
|
|
56
|
+
lang: language,
|
|
57
|
+
name: fileName || "file"
|
|
58
|
+
}), [
|
|
59
|
+
newContent,
|
|
60
|
+
language,
|
|
61
|
+
fileName
|
|
62
|
+
]);
|
|
63
|
+
const options = useMemo(() => ({
|
|
64
|
+
diffStyle: viewMode,
|
|
65
|
+
disableFileHeader: true,
|
|
66
|
+
...diffOptions
|
|
67
|
+
}), [viewMode, diffOptions]);
|
|
68
|
+
return /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
69
|
+
className: cx(variants({ variant }), className),
|
|
70
|
+
"data-code-type": "code-diff",
|
|
71
|
+
...rest,
|
|
72
|
+
children: [showHeader && /* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: cx(headerVariants({ variant }), classNames?.header),
|
|
74
|
+
style: customStyles?.header,
|
|
75
|
+
children: [/* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
76
|
+
align: "center",
|
|
77
|
+
gap: 8,
|
|
78
|
+
horizontal: true,
|
|
79
|
+
children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon_default, {
|
|
80
|
+
filename: fileName || displayName,
|
|
81
|
+
size: 18,
|
|
82
|
+
type: "file"
|
|
83
|
+
}), /* @__PURE__ */ jsx("span", { children: displayName })]
|
|
84
|
+
}), /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
85
|
+
align: "center",
|
|
86
|
+
gap: 8,
|
|
87
|
+
horizontal: true,
|
|
88
|
+
children: [(deletions > 0 || additions > 0) && /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
89
|
+
className: styles.stats,
|
|
90
|
+
gap: 8,
|
|
91
|
+
horizontal: true,
|
|
92
|
+
children: [deletions > 0 && /* @__PURE__ */ jsxs("span", {
|
|
93
|
+
className: styles.deletions,
|
|
94
|
+
children: ["-", deletions]
|
|
95
|
+
}), additions > 0 && /* @__PURE__ */ jsxs("span", {
|
|
96
|
+
className: styles.additions,
|
|
97
|
+
children: ["+", additions]
|
|
98
|
+
})]
|
|
99
|
+
}), actions && /* @__PURE__ */ jsx(FlexBasic_default, {
|
|
100
|
+
align: "center",
|
|
101
|
+
className: cx(`${prefix}-actions`, styles.actions),
|
|
102
|
+
gap: 4,
|
|
103
|
+
children: actions
|
|
104
|
+
})]
|
|
105
|
+
})]
|
|
106
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: cx(styles.body, classNames?.body),
|
|
108
|
+
style: customStyles?.body,
|
|
109
|
+
children: /* @__PURE__ */ jsx(MultiFileDiff, {
|
|
110
|
+
newFile,
|
|
111
|
+
oldFile,
|
|
112
|
+
options
|
|
113
|
+
})
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
CodeDiff.displayName = "CodeDiff";
|
|
118
|
+
var CodeDiff_default = CodeDiff;
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { CodeDiff_default as default };
|
|
122
|
+
//# sourceMappingURL=CodeDiff.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeDiff.mjs","names":["Flexbox","MaterialFileTypeIcon"],"sources":["../../src/CodeDiff/CodeDiff.tsx"],"sourcesContent":["'use client';\n\nimport type { FileDiffOptions } from '@pierre/diffs';\nimport { MultiFileDiff } from '@pierre/diffs/react';\nimport { cx } from 'antd-style';\nimport { memo, useMemo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport MaterialFileTypeIcon from '@/MaterialFileTypeIcon';\n\nimport { headerVariants, prefix, styles, variants } from './style';\nimport type { CodeDiffProps } from './type';\n\nconst countContentChanges = (\n oldContent: string,\n newContent: string,\n): { additions: number; deletions: number } => {\n const oldLines = oldContent.split('\\n');\n const newLines = newContent.split('\\n');\n\n const oldSet = new Set(oldLines);\n const newSet = new Set(newLines);\n\n let deletions = 0;\n let additions = 0;\n\n for (const line of oldLines) {\n if (!newSet.has(line)) {\n deletions++;\n }\n }\n\n for (const line of newLines) {\n if (!oldSet.has(line)) {\n additions++;\n }\n }\n\n return { additions, deletions };\n};\n\nexport const CodeDiff = memo<CodeDiffProps>(\n ({\n oldContent,\n newContent,\n language,\n fileName,\n viewMode = 'split',\n showHeader = true,\n variant = 'filled',\n className,\n classNames,\n styles: customStyles,\n actionsRender,\n diffOptions,\n ...rest\n }) => {\n const displayName = useMemo(() => {\n if (fileName) return fileName;\n if (language) return language;\n return 'diff';\n }, [fileName, language]);\n\n const { additions, deletions } = useMemo(\n () => countContentChanges(oldContent, newContent),\n [oldContent, newContent],\n );\n\n const actions = useMemo(() => {\n if (!actionsRender) return null;\n return actionsRender({\n newContent,\n oldContent,\n originalNode: null,\n });\n }, [actionsRender, oldContent, newContent]);\n\n const oldFile = useMemo(\n () => ({\n contents: oldContent,\n lang: language as any,\n name: fileName || 'file',\n }),\n [oldContent, language, fileName],\n );\n\n const newFile = useMemo(\n () => ({\n contents: newContent,\n lang: language as any,\n name: fileName || 'file',\n }),\n [newContent, language, fileName],\n );\n\n const options = useMemo<FileDiffOptions<string>>(\n () => ({\n diffStyle: viewMode,\n disableFileHeader: true,\n ...diffOptions,\n }),\n [viewMode, diffOptions],\n );\n\n return (\n <Flexbox\n className={cx(variants({ variant }), className)}\n data-code-type=\"code-diff\"\n {...rest}\n >\n {showHeader && (\n <div\n className={cx(headerVariants({ variant }), classNames?.header)}\n style={customStyles?.header}\n >\n <Flexbox align=\"center\" gap={8} horizontal>\n <MaterialFileTypeIcon filename={fileName || displayName} size={18} type=\"file\" />\n <span>{displayName}</span>\n </Flexbox>\n <Flexbox align=\"center\" gap={8} horizontal>\n {(deletions > 0 || additions > 0) && (\n <Flexbox className={styles.stats} gap={8} horizontal>\n {deletions > 0 && <span className={styles.deletions}>-{deletions}</span>}\n {additions > 0 && <span className={styles.additions}>+{additions}</span>}\n </Flexbox>\n )}\n {actions && (\n <Flexbox align=\"center\" className={cx(`${prefix}-actions`, styles.actions)} gap={4}>\n {actions}\n </Flexbox>\n )}\n </Flexbox>\n </div>\n )}\n <div className={cx(styles.body, classNames?.body)} style={customStyles?.body}>\n <MultiFileDiff newFile={newFile} oldFile={oldFile} options={options} />\n </div>\n </Flexbox>\n );\n },\n);\n\nCodeDiff.displayName = 'CodeDiff';\n\nexport default CodeDiff;\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,uBACJ,YACA,eAC6C;CAC7C,MAAM,WAAW,WAAW,MAAM,KAAK;CACvC,MAAM,WAAW,WAAW,MAAM,KAAK;CAEvC,MAAM,SAAS,IAAI,IAAI,SAAS;CAChC,MAAM,SAAS,IAAI,IAAI,SAAS;CAEhC,IAAI,YAAY;CAChB,IAAI,YAAY;AAEhB,MAAK,MAAM,QAAQ,SACjB,KAAI,CAAC,OAAO,IAAI,KAAK,CACnB;AAIJ,MAAK,MAAM,QAAQ,SACjB,KAAI,CAAC,OAAO,IAAI,KAAK,CACnB;AAIJ,QAAO;EAAE;EAAW;EAAW;;AAGjC,MAAa,WAAW,MACrB,EACC,YACA,YACA,UACA,UACA,WAAW,SACX,aAAa,MACb,UAAU,UACV,WACA,YACA,QAAQ,cACR,eACA,aACA,GAAG,WACC;CACJ,MAAM,cAAc,cAAc;AAChC,MAAI,SAAU,QAAO;AACrB,MAAI,SAAU,QAAO;AACrB,SAAO;IACN,CAAC,UAAU,SAAS,CAAC;CAExB,MAAM,EAAE,WAAW,cAAc,cACzB,oBAAoB,YAAY,WAAW,EACjD,CAAC,YAAY,WAAW,CACzB;CAED,MAAM,UAAU,cAAc;AAC5B,MAAI,CAAC,cAAe,QAAO;AAC3B,SAAO,cAAc;GACnB;GACA;GACA,cAAc;GACf,CAAC;IACD;EAAC;EAAe;EAAY;EAAW,CAAC;CAE3C,MAAM,UAAU,eACP;EACL,UAAU;EACV,MAAM;EACN,MAAM,YAAY;EACnB,GACD;EAAC;EAAY;EAAU;EAAS,CACjC;CAED,MAAM,UAAU,eACP;EACL,UAAU;EACV,MAAM;EACN,MAAM,YAAY;EACnB,GACD;EAAC;EAAY;EAAU;EAAS,CACjC;CAED,MAAM,UAAU,eACP;EACL,WAAW;EACX,mBAAmB;EACnB,GAAG;EACJ,GACD,CAAC,UAAU,YAAY,CACxB;AAED,QACE,qBAACA;EACC,WAAW,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,UAAU;EAC/C,kBAAe;EACf,GAAI;aAEH,cACC,qBAAC;GACC,WAAW,GAAG,eAAe,EAAE,SAAS,CAAC,EAAE,YAAY,OAAO;GAC9D,OAAO,cAAc;cAErB,qBAACA;IAAQ,OAAM;IAAS,KAAK;IAAG;eAC9B,oBAACC;KAAqB,UAAU,YAAY;KAAa,MAAM;KAAI,MAAK;MAAS,EACjF,oBAAC,oBAAM,cAAmB;KAClB,EACV,qBAACD;IAAQ,OAAM;IAAS,KAAK;IAAG;gBAC5B,YAAY,KAAK,YAAY,MAC7B,qBAACA;KAAQ,WAAW,OAAO;KAAO,KAAK;KAAG;gBACvC,YAAY,KAAK,qBAAC;MAAK,WAAW,OAAO;iBAAW,KAAE;OAAiB,EACvE,YAAY,KAAK,qBAAC;MAAK,WAAW,OAAO;iBAAW,KAAE;OAAiB;MAChE,EAEX,WACC,oBAACA;KAAQ,OAAM;KAAS,WAAW,GAAG,GAAG,OAAO,WAAW,OAAO,QAAQ;KAAE,KAAK;eAC9E;MACO;KAEJ;IACN,EAER,oBAAC;GAAI,WAAW,GAAG,OAAO,MAAM,YAAY,KAAK;GAAE,OAAO,cAAc;aACtE,oBAAC;IAAuB;IAAkB;IAAkB;KAAW;IACnE;GACE;EAGf;AAED,SAAS,cAAc;AAEvB,uBAAe"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PatchDiffProps } from "./type.mjs";
|
|
2
|
+
import * as react30 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/CodeDiff/PatchDiff.d.ts
|
|
5
|
+
declare const PatchDiff: react30.NamedExoticComponent<PatchDiffProps>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { PatchDiff };
|
|
8
|
+
//# sourceMappingURL=PatchDiff.d.mts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import FlexBasic_default from "../Flex/FlexBasic.mjs";
|
|
4
|
+
import MaterialFileTypeIcon_default from "../MaterialFileTypeIcon/MaterialFileTypeIcon.mjs";
|
|
5
|
+
import { headerVariants, prefix, styles, variants } from "./style.mjs";
|
|
6
|
+
import { memo, useMemo } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { cx } from "antd-style";
|
|
9
|
+
import { PatchDiff } from "@pierre/diffs/react";
|
|
10
|
+
|
|
11
|
+
//#region src/CodeDiff/PatchDiff.tsx
|
|
12
|
+
const countPatchChanges = (patch) => {
|
|
13
|
+
const lines = patch.split("\n");
|
|
14
|
+
let additions = 0;
|
|
15
|
+
let deletions = 0;
|
|
16
|
+
for (const line of lines) if (line.startsWith("+") && !line.startsWith("+++")) additions++;
|
|
17
|
+
else if (line.startsWith("-") && !line.startsWith("---")) deletions++;
|
|
18
|
+
return {
|
|
19
|
+
additions,
|
|
20
|
+
deletions
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const PatchDiff$1 = memo(({ patch, language, fileName, viewMode = "split", showHeader = true, variant = "filled", className, classNames, styles: customStyles, actionsRender, diffOptions, ...rest }) => {
|
|
24
|
+
const displayName = useMemo(() => {
|
|
25
|
+
if (fileName) return fileName;
|
|
26
|
+
const match = patch.match(/^(?:-{3}|\+{3})\s+(?:a\/|b\/)?(.+?)(?:\t|$)/m);
|
|
27
|
+
if (match?.[1]) return match[1];
|
|
28
|
+
if (language) return language;
|
|
29
|
+
return "patch";
|
|
30
|
+
}, [
|
|
31
|
+
fileName,
|
|
32
|
+
patch,
|
|
33
|
+
language
|
|
34
|
+
]);
|
|
35
|
+
const { additions, deletions } = useMemo(() => countPatchChanges(patch), [patch]);
|
|
36
|
+
const actions = useMemo(() => {
|
|
37
|
+
if (!actionsRender) return null;
|
|
38
|
+
return actionsRender({
|
|
39
|
+
originalNode: null,
|
|
40
|
+
patch
|
|
41
|
+
});
|
|
42
|
+
}, [actionsRender, patch]);
|
|
43
|
+
const options = useMemo(() => ({
|
|
44
|
+
diffStyle: viewMode,
|
|
45
|
+
disableFileHeader: true,
|
|
46
|
+
...diffOptions
|
|
47
|
+
}), [viewMode, diffOptions]);
|
|
48
|
+
return /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
49
|
+
className: cx(variants({ variant }), className),
|
|
50
|
+
"data-code-type": "patch-diff",
|
|
51
|
+
...rest,
|
|
52
|
+
children: [showHeader && /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: cx(headerVariants({ variant }), classNames?.header),
|
|
54
|
+
style: customStyles?.header,
|
|
55
|
+
children: [/* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
56
|
+
align: "center",
|
|
57
|
+
gap: 8,
|
|
58
|
+
horizontal: true,
|
|
59
|
+
children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon_default, {
|
|
60
|
+
filename: fileName || displayName,
|
|
61
|
+
size: 18,
|
|
62
|
+
type: "file"
|
|
63
|
+
}), /* @__PURE__ */ jsx("span", { children: displayName })]
|
|
64
|
+
}), /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
65
|
+
align: "center",
|
|
66
|
+
gap: 8,
|
|
67
|
+
horizontal: true,
|
|
68
|
+
children: [(deletions > 0 || additions > 0) && /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
69
|
+
className: styles.stats,
|
|
70
|
+
gap: 8,
|
|
71
|
+
horizontal: true,
|
|
72
|
+
children: [deletions > 0 && /* @__PURE__ */ jsxs("span", {
|
|
73
|
+
className: styles.deletions,
|
|
74
|
+
children: ["-", deletions]
|
|
75
|
+
}), additions > 0 && /* @__PURE__ */ jsxs("span", {
|
|
76
|
+
className: styles.additions,
|
|
77
|
+
children: ["+", additions]
|
|
78
|
+
})]
|
|
79
|
+
}), actions && /* @__PURE__ */ jsx(FlexBasic_default, {
|
|
80
|
+
align: "center",
|
|
81
|
+
className: cx(`${prefix}-actions`, styles.actions),
|
|
82
|
+
gap: 4,
|
|
83
|
+
children: actions
|
|
84
|
+
})]
|
|
85
|
+
})]
|
|
86
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
87
|
+
className: cx(styles.body, classNames?.body),
|
|
88
|
+
style: customStyles?.body,
|
|
89
|
+
children: /* @__PURE__ */ jsx(PatchDiff, {
|
|
90
|
+
options,
|
|
91
|
+
patch
|
|
92
|
+
})
|
|
93
|
+
})]
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
PatchDiff$1.displayName = "PatchDiff";
|
|
97
|
+
var PatchDiff_default = PatchDiff$1;
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { PatchDiff_default as default };
|
|
101
|
+
//# sourceMappingURL=PatchDiff.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatchDiff.mjs","names":["PatchDiff","Flexbox","MaterialFileTypeIcon","PierrePatchDiff"],"sources":["../../src/CodeDiff/PatchDiff.tsx"],"sourcesContent":["'use client';\n\nimport type { FileDiffOptions } from '@pierre/diffs';\nimport { PatchDiff as PierrePatchDiff } from '@pierre/diffs/react';\nimport { cx } from 'antd-style';\nimport { memo, useMemo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport MaterialFileTypeIcon from '@/MaterialFileTypeIcon';\n\nimport { headerVariants, prefix, styles, variants } from './style';\nimport type { PatchDiffProps } from './type';\n\nconst countPatchChanges = (patch: string): { additions: number; deletions: number } => {\n const lines = patch.split('\\n');\n let additions = 0;\n let deletions = 0;\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n additions++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n deletions++;\n }\n }\n\n return { additions, deletions };\n};\n\nexport const PatchDiff = memo<PatchDiffProps>(\n ({\n patch,\n language,\n fileName,\n viewMode = 'split',\n showHeader = true,\n variant = 'filled',\n className,\n classNames,\n styles: customStyles,\n actionsRender,\n diffOptions,\n ...rest\n }) => {\n const displayName = useMemo(() => {\n if (fileName) return fileName;\n // Try to extract filename from patch header\n const match = patch.match(/^(?:-{3}|\\+{3})\\s+(?:a\\/|b\\/)?(.+?)(?:\\t|$)/m);\n if (match?.[1]) return match[1];\n if (language) return language;\n return 'patch';\n }, [fileName, patch, language]);\n\n const { additions, deletions } = useMemo(() => countPatchChanges(patch), [patch]);\n\n const actions = useMemo(() => {\n if (!actionsRender) return null;\n return actionsRender({\n originalNode: null,\n patch,\n });\n }, [actionsRender, patch]);\n\n const options = useMemo<FileDiffOptions<string>>(\n () => ({\n diffStyle: viewMode,\n disableFileHeader: true,\n ...diffOptions,\n }),\n [viewMode, diffOptions],\n );\n\n return (\n <Flexbox\n className={cx(variants({ variant }), className)}\n data-code-type=\"patch-diff\"\n {...rest}\n >\n {showHeader && (\n <div\n className={cx(headerVariants({ variant }), classNames?.header)}\n style={customStyles?.header}\n >\n <Flexbox align=\"center\" gap={8} horizontal>\n <MaterialFileTypeIcon filename={fileName || displayName} size={18} type=\"file\" />\n <span>{displayName}</span>\n </Flexbox>\n <Flexbox align=\"center\" gap={8} horizontal>\n {(deletions > 0 || additions > 0) && (\n <Flexbox className={styles.stats} gap={8} horizontal>\n {deletions > 0 && <span className={styles.deletions}>-{deletions}</span>}\n {additions > 0 && <span className={styles.additions}>+{additions}</span>}\n </Flexbox>\n )}\n {actions && (\n <Flexbox align=\"center\" className={cx(`${prefix}-actions`, styles.actions)} gap={4}>\n {actions}\n </Flexbox>\n )}\n </Flexbox>\n </div>\n )}\n <div className={cx(styles.body, classNames?.body)} style={customStyles?.body}>\n <PierrePatchDiff options={options} patch={patch} />\n </div>\n </Flexbox>\n );\n },\n);\n\nPatchDiff.displayName = 'PatchDiff';\n\nexport default PatchDiff;\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,qBAAqB,UAA4D;CACrF,MAAM,QAAQ,MAAM,MAAM,KAAK;CAC/B,IAAI,YAAY;CAChB,IAAI,YAAY;AAEhB,MAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,WAAW,MAAM,CACjD;UACS,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,WAAW,MAAM,CACxD;AAIJ,QAAO;EAAE;EAAW;EAAW;;AAGjC,MAAaA,cAAY,MACtB,EACC,OACA,UACA,UACA,WAAW,SACX,aAAa,MACb,UAAU,UACV,WACA,YACA,QAAQ,cACR,eACA,aACA,GAAG,WACC;CACJ,MAAM,cAAc,cAAc;AAChC,MAAI,SAAU,QAAO;EAErB,MAAM,QAAQ,MAAM,MAAM,+CAA+C;AACzE,MAAI,QAAQ,GAAI,QAAO,MAAM;AAC7B,MAAI,SAAU,QAAO;AACrB,SAAO;IACN;EAAC;EAAU;EAAO;EAAS,CAAC;CAE/B,MAAM,EAAE,WAAW,cAAc,cAAc,kBAAkB,MAAM,EAAE,CAAC,MAAM,CAAC;CAEjF,MAAM,UAAU,cAAc;AAC5B,MAAI,CAAC,cAAe,QAAO;AAC3B,SAAO,cAAc;GACnB,cAAc;GACd;GACD,CAAC;IACD,CAAC,eAAe,MAAM,CAAC;CAE1B,MAAM,UAAU,eACP;EACL,WAAW;EACX,mBAAmB;EACnB,GAAG;EACJ,GACD,CAAC,UAAU,YAAY,CACxB;AAED,QACE,qBAACC;EACC,WAAW,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,UAAU;EAC/C,kBAAe;EACf,GAAI;aAEH,cACC,qBAAC;GACC,WAAW,GAAG,eAAe,EAAE,SAAS,CAAC,EAAE,YAAY,OAAO;GAC9D,OAAO,cAAc;cAErB,qBAACA;IAAQ,OAAM;IAAS,KAAK;IAAG;eAC9B,oBAACC;KAAqB,UAAU,YAAY;KAAa,MAAM;KAAI,MAAK;MAAS,EACjF,oBAAC,oBAAM,cAAmB;KAClB,EACV,qBAACD;IAAQ,OAAM;IAAS,KAAK;IAAG;gBAC5B,YAAY,KAAK,YAAY,MAC7B,qBAACA;KAAQ,WAAW,OAAO;KAAO,KAAK;KAAG;gBACvC,YAAY,KAAK,qBAAC;MAAK,WAAW,OAAO;iBAAW,KAAE;OAAiB,EACvE,YAAY,KAAK,qBAAC;MAAK,WAAW,OAAO;iBAAW,KAAE;OAAiB;MAChE,EAEX,WACC,oBAACA;KAAQ,OAAM;KAAS,WAAW,GAAG,GAAG,OAAO,WAAW,OAAO,QAAQ;KAAE,KAAK;eAC9E;MACO;KAEJ;IACN,EAER,oBAAC;GAAI,WAAW,GAAG,OAAO,MAAM,YAAY,KAAK;GAAE,OAAO,cAAc;aACtE,oBAACE;IAAyB;IAAgB;KAAS;IAC/C;GACE;EAGf;AAED,YAAU,cAAc;AAExB,wBAAeH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.d.mts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.mjs';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { staticStylish } from "../styles/theme/customStylishStatic.mjs";
|
|
2
|
+
import { createStaticStyles, cx } from "antd-style";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
//#region src/CodeDiff/style.ts
|
|
6
|
+
const prefix = "lobe-code-diff";
|
|
7
|
+
const styles = createStaticStyles(({ css: css$1, cssVar: cssVar$1 }) => {
|
|
8
|
+
return {
|
|
9
|
+
actions: css$1`
|
|
10
|
+
position: absolute;
|
|
11
|
+
z-index: 2;
|
|
12
|
+
inset-block-start: 8px;
|
|
13
|
+
inset-inline-end: 8px;
|
|
14
|
+
|
|
15
|
+
opacity: 0;
|
|
16
|
+
transition: opacity 0.2s ${cssVar$1.motionEaseInOut};
|
|
17
|
+
`,
|
|
18
|
+
additions: css$1`
|
|
19
|
+
color: ${cssVar$1.colorSuccess};
|
|
20
|
+
font-family: ${cssVar$1.fontFamilyCode};
|
|
21
|
+
font-size: 12px;
|
|
22
|
+
`,
|
|
23
|
+
body: css$1`
|
|
24
|
+
overflow: auto;
|
|
25
|
+
|
|
26
|
+
width: 100%;
|
|
27
|
+
|
|
28
|
+
font-family: ${cssVar$1.fontFamilyCode};
|
|
29
|
+
font-size: 13px;
|
|
30
|
+
line-height: 1.6;
|
|
31
|
+
|
|
32
|
+
/* Override @pierre/diffs shadow DOM CSS variables */
|
|
33
|
+
--pdiff-font-family: ${cssVar$1.fontFamilyCode};
|
|
34
|
+
--pdiff-font-size: 13px;
|
|
35
|
+
--pdiff-line-height: 1.6;
|
|
36
|
+
--pdiff-bg-color: transparent;
|
|
37
|
+
--pdiff-border-color: ${cssVar$1.colorBorderSecondary};
|
|
38
|
+
--pdiff-gutter-bg: ${cssVar$1.colorFillQuaternary};
|
|
39
|
+
--pdiff-gutter-color: ${cssVar$1.colorTextQuaternary};
|
|
40
|
+
--pdiff-added-bg: ${cssVar$1.colorSuccessBgHover};
|
|
41
|
+
--pdiff-added-highlight-bg: ${cssVar$1.colorSuccessBg};
|
|
42
|
+
--pdiff-removed-bg: ${cssVar$1.colorErrorBgHover};
|
|
43
|
+
--pdiff-removed-highlight-bg: ${cssVar$1.colorErrorBg};
|
|
44
|
+
--pdiff-info-bg: ${cssVar$1.colorInfoBg};
|
|
45
|
+
`,
|
|
46
|
+
borderless: staticStylish.variantBorderlessWithoutHover,
|
|
47
|
+
deletions: css$1`
|
|
48
|
+
color: ${cssVar$1.colorError};
|
|
49
|
+
font-family: ${cssVar$1.fontFamilyCode};
|
|
50
|
+
font-size: 12px;
|
|
51
|
+
`,
|
|
52
|
+
filled: cx(staticStylish.variantFilledWithoutHover, css$1`
|
|
53
|
+
background: ${cssVar$1.colorFillQuaternary};
|
|
54
|
+
`),
|
|
55
|
+
header: css$1`
|
|
56
|
+
display: flex;
|
|
57
|
+
gap: 8px;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
|
|
61
|
+
padding: 8px 12px;
|
|
62
|
+
|
|
63
|
+
font-family: ${cssVar$1.fontFamilyCode};
|
|
64
|
+
font-size: 13px;
|
|
65
|
+
color: ${cssVar$1.colorTextSecondary};
|
|
66
|
+
|
|
67
|
+
border-block-end: 1px solid ${cssVar$1.colorBorderSecondary};
|
|
68
|
+
`,
|
|
69
|
+
headerBorderless: css$1`
|
|
70
|
+
padding-inline: 0;
|
|
71
|
+
border-block-end: none;
|
|
72
|
+
`,
|
|
73
|
+
headerFilled: css$1`
|
|
74
|
+
background: transparent;
|
|
75
|
+
`,
|
|
76
|
+
headerOutlined: css$1`
|
|
77
|
+
background: ${cssVar$1.colorFillQuaternary};
|
|
78
|
+
`,
|
|
79
|
+
outlined: staticStylish.variantOutlinedWithoutHover,
|
|
80
|
+
root: cx(prefix, css$1`
|
|
81
|
+
position: relative;
|
|
82
|
+
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
|
|
85
|
+
width: 100%;
|
|
86
|
+
border-radius: ${cssVar$1.borderRadius};
|
|
87
|
+
|
|
88
|
+
transition: background-color 100ms ${cssVar$1.motionEaseOut};
|
|
89
|
+
|
|
90
|
+
&:hover {
|
|
91
|
+
.${prefix}-actions {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`),
|
|
96
|
+
stats: css$1`
|
|
97
|
+
display: flex;
|
|
98
|
+
gap: 8px;
|
|
99
|
+
align-items: center;
|
|
100
|
+
`
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
const variants = cva(styles.root, {
|
|
104
|
+
defaultVariants: { variant: "filled" },
|
|
105
|
+
variants: { variant: {
|
|
106
|
+
filled: styles.filled,
|
|
107
|
+
outlined: styles.outlined,
|
|
108
|
+
borderless: styles.borderless
|
|
109
|
+
} }
|
|
110
|
+
});
|
|
111
|
+
const headerVariants = cva(styles.header, {
|
|
112
|
+
defaultVariants: { variant: "filled" },
|
|
113
|
+
variants: { variant: {
|
|
114
|
+
filled: styles.headerFilled,
|
|
115
|
+
outlined: styles.headerOutlined,
|
|
116
|
+
borderless: styles.headerBorderless
|
|
117
|
+
} }
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { headerVariants, prefix, styles, variants };
|
|
122
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["cssVar","lobeStaticStylish"],"sources":["../../src/CodeDiff/style.ts"],"sourcesContent":["import { createStaticStyles, cx } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { lobeStaticStylish } from '@/styles';\n\nexport const prefix = 'lobe-code-diff';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => {\n return {\n actions: css`\n position: absolute;\n z-index: 2;\n inset-block-start: 8px;\n inset-inline-end: 8px;\n\n opacity: 0;\n transition: opacity 0.2s ${cssVar.motionEaseInOut};\n `,\n additions: css`\n color: ${cssVar.colorSuccess};\n font-family: ${cssVar.fontFamilyCode};\n font-size: 12px;\n `,\n body: css`\n overflow: auto;\n\n width: 100%;\n\n font-family: ${cssVar.fontFamilyCode};\n font-size: 13px;\n line-height: 1.6;\n\n /* Override @pierre/diffs shadow DOM CSS variables */\n --pdiff-font-family: ${cssVar.fontFamilyCode};\n --pdiff-font-size: 13px;\n --pdiff-line-height: 1.6;\n --pdiff-bg-color: transparent;\n --pdiff-border-color: ${cssVar.colorBorderSecondary};\n --pdiff-gutter-bg: ${cssVar.colorFillQuaternary};\n --pdiff-gutter-color: ${cssVar.colorTextQuaternary};\n --pdiff-added-bg: ${cssVar.colorSuccessBgHover};\n --pdiff-added-highlight-bg: ${cssVar.colorSuccessBg};\n --pdiff-removed-bg: ${cssVar.colorErrorBgHover};\n --pdiff-removed-highlight-bg: ${cssVar.colorErrorBg};\n --pdiff-info-bg: ${cssVar.colorInfoBg};\n `,\n borderless: lobeStaticStylish.variantBorderlessWithoutHover,\n deletions: css`\n color: ${cssVar.colorError};\n font-family: ${cssVar.fontFamilyCode};\n font-size: 12px;\n `,\n filled: cx(\n lobeStaticStylish.variantFilledWithoutHover,\n css`\n background: ${cssVar.colorFillQuaternary};\n `,\n ),\n header: css`\n display: flex;\n gap: 8px;\n align-items: center;\n justify-content: space-between;\n\n padding: 8px 12px;\n\n font-family: ${cssVar.fontFamilyCode};\n font-size: 13px;\n color: ${cssVar.colorTextSecondary};\n\n border-block-end: 1px solid ${cssVar.colorBorderSecondary};\n `,\n headerBorderless: css`\n padding-inline: 0;\n border-block-end: none;\n `,\n headerFilled: css`\n background: transparent;\n `,\n headerOutlined: css`\n background: ${cssVar.colorFillQuaternary};\n `,\n outlined: lobeStaticStylish.variantOutlinedWithoutHover,\n root: cx(\n prefix,\n css`\n position: relative;\n\n overflow: hidden;\n\n width: 100%;\n border-radius: ${cssVar.borderRadius};\n\n transition: background-color 100ms ${cssVar.motionEaseOut};\n\n &:hover {\n .${prefix}-actions {\n opacity: 1;\n }\n }\n `,\n ),\n stats: css`\n display: flex;\n gap: 8px;\n align-items: center;\n `,\n };\n});\n\nexport const variants = cva(styles.root, {\n defaultVariants: {\n variant: 'filled',\n },\n /* eslint-disable sort-keys-fix/sort-keys-fix */\n variants: {\n variant: {\n filled: styles.filled,\n outlined: styles.outlined,\n borderless: styles.borderless,\n },\n },\n /* eslint-enable sort-keys-fix/sort-keys-fix */\n});\n\nexport const headerVariants = cva(styles.header, {\n defaultVariants: {\n variant: 'filled',\n },\n /* eslint-disable sort-keys-fix/sort-keys-fix */\n variants: {\n variant: {\n filled: styles.headerFilled,\n outlined: styles.headerOutlined,\n borderless: styles.headerBorderless,\n },\n },\n /* eslint-enable sort-keys-fix/sort-keys-fix */\n});\n"],"mappings":";;;;;AAKA,MAAa,SAAS;AAEtB,MAAa,SAAS,oBAAoB,EAAE,YAAK,uBAAa;AAC5D,QAAO;EACL,SAAS,KAAG;;;;;;;iCAOiBA,SAAO,gBAAgB;;EAEpD,WAAW,KAAG;eACHA,SAAO,aAAa;qBACdA,SAAO,eAAe;;;EAGvC,MAAM,KAAG;;;;;qBAKQA,SAAO,eAAe;;;;;6BAKdA,SAAO,eAAe;;;;8BAIrBA,SAAO,qBAAqB;2BAC/BA,SAAO,oBAAoB;8BACxBA,SAAO,oBAAoB;0BAC/BA,SAAO,oBAAoB;oCACjBA,SAAO,eAAe;4BAC9BA,SAAO,kBAAkB;sCACfA,SAAO,aAAa;yBACjCA,SAAO,YAAY;;EAExC,YAAYC,cAAkB;EAC9B,WAAW,KAAG;eACHD,SAAO,WAAW;qBACZA,SAAO,eAAe;;;EAGvC,QAAQ,GACNC,cAAkB,2BAClB,KAAG;sBACaD,SAAO,oBAAoB;QAE5C;EACD,QAAQ,KAAG;;;;;;;;qBAQMA,SAAO,eAAe;;eAE5BA,SAAO,mBAAmB;;oCAELA,SAAO,qBAAqB;;EAE5D,kBAAkB,KAAG;;;;EAIrB,cAAc,KAAG;;;EAGjB,gBAAgB,KAAG;oBACHA,SAAO,oBAAoB;;EAE3C,UAAUC,cAAkB;EAC5B,MAAM,GACJ,QACA,KAAG;;;;;;yBAMgBD,SAAO,aAAa;;6CAEAA,SAAO,cAAc;;;aAGrD,OAAO;;;;QAKf;EACD,OAAO,KAAG;;;;;EAKX;EACD;AAEF,MAAa,WAAW,IAAI,OAAO,MAAM;CACvC,iBAAiB,EACf,SAAS,UACV;CAED,UAAU,EACR,SAAS;EACP,QAAQ,OAAO;EACf,UAAU,OAAO;EACjB,YAAY,OAAO;EACpB,EACF;CAEF,CAAC;AAEF,MAAa,iBAAiB,IAAI,OAAO,QAAQ;CAC/C,iBAAiB,EACf,SAAS,UACV;CAED,UAAU,EACR,SAAS;EACP,QAAQ,OAAO;EACf,UAAU,OAAO;EACjB,YAAY,OAAO;EACpB,EACF;CAEF,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { FlexboxProps } from "../Flex/type.mjs";
|
|
2
|
+
import "../Flex/index.mjs";
|
|
3
|
+
import { CSSProperties, ReactNode } from "react";
|
|
4
|
+
import { FileDiffOptions } from "@pierre/diffs";
|
|
5
|
+
|
|
6
|
+
//#region src/CodeDiff/type.d.ts
|
|
7
|
+
type DiffViewMode = 'split' | 'unified';
|
|
8
|
+
interface CodeDiffProps extends Omit<FlexboxProps, 'children'> {
|
|
9
|
+
/**
|
|
10
|
+
* Actions to render in the header
|
|
11
|
+
*/
|
|
12
|
+
actionsRender?: (props: {
|
|
13
|
+
newContent: string;
|
|
14
|
+
oldContent: string;
|
|
15
|
+
originalNode: ReactNode;
|
|
16
|
+
}) => ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Custom class names for different parts
|
|
19
|
+
*/
|
|
20
|
+
classNames?: {
|
|
21
|
+
body?: string;
|
|
22
|
+
header?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Options for the diff component
|
|
26
|
+
*/
|
|
27
|
+
diffOptions?: FileDiffOptions<string>;
|
|
28
|
+
/**
|
|
29
|
+
* File name to display
|
|
30
|
+
*/
|
|
31
|
+
fileName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Programming language for syntax highlighting
|
|
34
|
+
*/
|
|
35
|
+
language?: string;
|
|
36
|
+
/**
|
|
37
|
+
* New content (after changes)
|
|
38
|
+
*/
|
|
39
|
+
newContent: string;
|
|
40
|
+
/**
|
|
41
|
+
* Old content (before changes)
|
|
42
|
+
*/
|
|
43
|
+
oldContent: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to show file header
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
showHeader?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Custom styles for different parts
|
|
51
|
+
*/
|
|
52
|
+
styles?: {
|
|
53
|
+
body?: CSSProperties;
|
|
54
|
+
header?: CSSProperties;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Visual variant
|
|
58
|
+
* @default 'filled'
|
|
59
|
+
*/
|
|
60
|
+
variant?: 'filled' | 'outlined' | 'borderless';
|
|
61
|
+
/**
|
|
62
|
+
* View mode for diff display
|
|
63
|
+
* @default 'split'
|
|
64
|
+
*/
|
|
65
|
+
viewMode?: DiffViewMode;
|
|
66
|
+
}
|
|
67
|
+
interface PatchDiffProps extends Omit<FlexboxProps, 'children'> {
|
|
68
|
+
/**
|
|
69
|
+
* Actions to render in the header
|
|
70
|
+
*/
|
|
71
|
+
actionsRender?: (props: {
|
|
72
|
+
originalNode: ReactNode;
|
|
73
|
+
patch: string;
|
|
74
|
+
}) => ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Custom class names for different parts
|
|
77
|
+
*/
|
|
78
|
+
classNames?: {
|
|
79
|
+
body?: string;
|
|
80
|
+
header?: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Options for the diff component
|
|
84
|
+
*/
|
|
85
|
+
diffOptions?: FileDiffOptions<string>;
|
|
86
|
+
/**
|
|
87
|
+
* File name to display (optional, extracted from patch if not provided)
|
|
88
|
+
*/
|
|
89
|
+
fileName?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Programming language for syntax highlighting
|
|
92
|
+
*/
|
|
93
|
+
language?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Unified diff patch string
|
|
96
|
+
*/
|
|
97
|
+
patch: string;
|
|
98
|
+
/**
|
|
99
|
+
* Whether to show file header
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
showHeader?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Custom styles for different parts
|
|
105
|
+
*/
|
|
106
|
+
styles?: {
|
|
107
|
+
body?: CSSProperties;
|
|
108
|
+
header?: CSSProperties;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Visual variant
|
|
112
|
+
* @default 'filled'
|
|
113
|
+
*/
|
|
114
|
+
variant?: 'filled' | 'outlined' | 'borderless';
|
|
115
|
+
/**
|
|
116
|
+
* View mode for diff display
|
|
117
|
+
* @default 'split'
|
|
118
|
+
*/
|
|
119
|
+
viewMode?: DiffViewMode;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { CodeDiffProps, DiffViewMode, PatchDiffProps };
|
|
123
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CodeEditorProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react27 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/CodeEditor/CodeEditor.d.ts
|
|
5
|
-
declare const CodeEditor:
|
|
5
|
+
declare const CodeEditor: react27.NamedExoticComponent<CodeEditorProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { CodeEditor };
|
|
8
8
|
//# sourceMappingURL=CodeEditor.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CollapseProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react28 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Collapse/Collapse.d.ts
|
|
5
|
-
declare const Collapse:
|
|
5
|
+
declare const Collapse: react28.NamedExoticComponent<CollapseProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Collapse };
|
|
8
8
|
//# sourceMappingURL=Collapse.d.mts.map
|