@schemavaults/ui 0.65.0 → 0.67.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/dist/components/ui/callout/callout.d.ts +1 -1
- package/dist/components/ui/collapsible/collapsible-variants.d.ts +16 -0
- package/dist/components/ui/collapsible/collapsible-variants.js +74 -0
- package/dist/components/ui/collapsible/collapsible-variants.js.map +1 -0
- package/dist/components/ui/collapsible/collapsible.d.ts +40 -0
- package/dist/components/ui/collapsible/collapsible.js +71 -0
- package/dist/components/ui/collapsible/collapsible.js.map +1 -0
- package/dist/components/ui/collapsible/index.d.ts +2 -0
- package/dist/components/ui/collapsible/index.js +2 -0
- package/dist/components/ui/collapsible/index.js.map +1 -0
- package/dist/components/ui/diff-viewer/compute-line-diff.d.ts +37 -0
- package/dist/components/ui/diff-viewer/compute-line-diff.js +124 -0
- package/dist/components/ui/diff-viewer/compute-line-diff.js.map +1 -0
- package/dist/components/ui/diff-viewer/diff-viewer-variants.d.ts +6 -0
- package/dist/components/ui/diff-viewer/diff-viewer-variants.js +8 -0
- package/dist/components/ui/diff-viewer/diff-viewer-variants.js.map +1 -0
- package/dist/components/ui/diff-viewer/diff-viewer.d.ts +38 -0
- package/dist/components/ui/diff-viewer/diff-viewer.js +121 -0
- package/dist/components/ui/diff-viewer/diff-viewer.js.map +1 -0
- package/dist/components/ui/diff-viewer/index.d.ts +5 -0
- package/dist/components/ui/diff-viewer/index.js +3 -0
- package/dist/components/ui/diff-viewer/index.js.map +1 -0
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export declare const calloutAppearanceIds: readonly ["accent-bar", "subtle"];
|
|
|
6
6
|
export type CalloutAppearanceId = (typeof calloutAppearanceIds)[number];
|
|
7
7
|
declare const calloutVariants: (props?: ({
|
|
8
8
|
intent?: "note" | "warning" | "tip" | "important" | "caution" | null | undefined;
|
|
9
|
-
appearance?: "
|
|
9
|
+
appearance?: "subtle" | "accent-bar" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
export interface CalloutProps extends Omit<HTMLAttributes<HTMLDivElement>, "title">, VariantProps<typeof calloutVariants> {
|
|
12
12
|
/** Override the default icon for the intent. Pass `null` to hide. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const collapsibleVariantIds: readonly ["default", "outline", "ghost", "subtle", "primary"];
|
|
2
|
+
export type CollapsibleVariantId = (typeof collapsibleVariantIds)[number];
|
|
3
|
+
export declare const collapsibleSizeIds: readonly ["sm", "md", "lg"];
|
|
4
|
+
export type CollapsibleSizeId = (typeof collapsibleSizeIds)[number];
|
|
5
|
+
export declare const collapsibleRootVariants: (props?: ({
|
|
6
|
+
variant?: "default" | "primary" | "outline" | "ghost" | "subtle" | null | undefined;
|
|
7
|
+
size?: "sm" | "lg" | "md" | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
+
export declare const collapsibleTriggerVariants: (props?: ({
|
|
10
|
+
variant?: "default" | "primary" | "outline" | "ghost" | "subtle" | null | undefined;
|
|
11
|
+
size?: "sm" | "lg" | "md" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
|
+
export declare const collapsibleContentInnerVariants: (props?: ({
|
|
14
|
+
variant?: "default" | "primary" | "outline" | "ghost" | "subtle" | null | undefined;
|
|
15
|
+
size?: "sm" | "lg" | "md" | null | undefined;
|
|
16
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
export const collapsibleVariantIds = [
|
|
3
|
+
"default",
|
|
4
|
+
"outline",
|
|
5
|
+
"ghost",
|
|
6
|
+
"subtle",
|
|
7
|
+
"primary",
|
|
8
|
+
];
|
|
9
|
+
export const collapsibleSizeIds = [
|
|
10
|
+
"sm",
|
|
11
|
+
"md",
|
|
12
|
+
"lg",
|
|
13
|
+
];
|
|
14
|
+
export const collapsibleRootVariants = cva("w-full overflow-hidden transition-colors", {
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
default: "bg-background",
|
|
18
|
+
outline: "rounded-lg border border-border bg-background",
|
|
19
|
+
ghost: "bg-transparent",
|
|
20
|
+
subtle: "rounded-lg bg-muted/50",
|
|
21
|
+
primary: "rounded-lg border border-primary/30 bg-primary/5 text-foreground",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
sm: "text-xs",
|
|
25
|
+
md: "text-sm",
|
|
26
|
+
lg: "text-base",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: "default",
|
|
31
|
+
size: "md",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export const collapsibleTriggerVariants = cva("group/collapsible-trigger flex w-full items-center justify-between gap-2 font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&>svg]:shrink-0", {
|
|
35
|
+
variants: {
|
|
36
|
+
variant: {
|
|
37
|
+
default: "text-foreground hover:text-foreground/80",
|
|
38
|
+
outline: "rounded-t-lg text-foreground hover:bg-accent/40 data-[state=closed]:rounded-b-lg",
|
|
39
|
+
ghost: "text-foreground hover:text-foreground/80",
|
|
40
|
+
subtle: "rounded-t-lg text-foreground hover:bg-muted/80 data-[state=closed]:rounded-b-lg data-[state=closed]:rounded-lg",
|
|
41
|
+
primary: "rounded-t-lg text-primary hover:text-primary/90 data-[state=closed]:rounded-lg",
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
sm: "px-3 py-2 text-xs [&>svg]:size-3.5",
|
|
45
|
+
md: "px-4 py-3 text-sm [&>svg]:size-4",
|
|
46
|
+
lg: "px-5 py-4 text-base [&>svg]:size-5",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
variant: "default",
|
|
51
|
+
size: "md",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export const collapsibleContentInnerVariants = cva("text-foreground/90", {
|
|
55
|
+
variants: {
|
|
56
|
+
variant: {
|
|
57
|
+
default: "",
|
|
58
|
+
outline: "border-t border-border",
|
|
59
|
+
ghost: "",
|
|
60
|
+
subtle: "",
|
|
61
|
+
primary: "border-t border-primary/20",
|
|
62
|
+
},
|
|
63
|
+
size: {
|
|
64
|
+
sm: "px-3 py-2 text-xs",
|
|
65
|
+
md: "px-4 py-3 text-sm",
|
|
66
|
+
lg: "px-5 py-4 text-base",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
variant: "default",
|
|
71
|
+
size: "md",
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=collapsible-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapsible-variants.js","sourceRoot":"","sources":["../../../../src/components/ui/collapsible/collapsible-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE/C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS;IACT,SAAS;IACT,OAAO;IACP,QAAQ;IACR,SAAS;CAC2B,CAAC;AAGvC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI;IACJ,IAAI;IACJ,IAAI;CACgC,CAAC;AAGvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CACxC,0CAA0C,EAC1C;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,+CAA+C;YACxD,KAAK,EAAE,gBAAgB;YACvB,MAAM,EAAE,wBAAwB;YAChC,OAAO,EACL,kEAAkE;SACtB;QAChD,IAAI,EAAE;YACJ,EAAE,EAAE,SAAS;YACb,EAAE,EAAE,SAAS;YACb,EAAE,EAAE,WAAW;SAC4B;KAC9C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,IAAI;KACX;CACF,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAC3C,qSAAqS,EACrS;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,0CAA0C;YACnD,OAAO,EACL,kFAAkF;YACpF,KAAK,EAAE,0CAA0C;YACjD,MAAM,EACJ,gHAAgH;YAClH,OAAO,EACL,gFAAgF;SACpC;QAChD,IAAI,EAAE;YACJ,EAAE,EAAE,oCAAoC;YACxC,EAAE,EAAE,kCAAkC;YACtC,EAAE,EAAE,oCAAoC;SACG;KAC9C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,IAAI;KACX;CACF,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,CAAC,oBAAoB,EAAE;IACvE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,wBAAwB;YACjC,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,4BAA4B;SACS;QAChD,IAAI,EAAE;YACJ,EAAE,EAAE,mBAAmB;YACvB,EAAE,EAAE,mBAAmB;YACvB,EAAE,EAAE,qBAAqB;SACkB;KAC9C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,IAAI;KACX;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { VariantProps } from "class-variance-authority";
|
|
3
|
+
import { collapsibleContentInnerVariants, collapsibleRootVariants, collapsibleTriggerVariants } from "./collapsible-variants";
|
|
4
|
+
export interface CollapsibleProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange">, VariantProps<typeof collapsibleRootVariants> {
|
|
5
|
+
/** Controlled open state. */
|
|
6
|
+
open?: boolean;
|
|
7
|
+
/** Initial open state when uncontrolled. */
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
/** Called when the open state changes. */
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
/** Disable the trigger interaction. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
ref?: Ref<HTMLDivElement>;
|
|
14
|
+
}
|
|
15
|
+
declare function Collapsible({ className, variant, size, open: openProp, defaultOpen, onOpenChange, disabled, children, ref, ...props }: CollapsibleProps): ReactElement;
|
|
16
|
+
declare namespace Collapsible {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CollapsibleTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
20
|
+
/** Hide the chevron icon on the right. */
|
|
21
|
+
hideIcon?: boolean;
|
|
22
|
+
/** Replace the default chevron with a custom icon. */
|
|
23
|
+
icon?: ReactNode;
|
|
24
|
+
ref?: Ref<HTMLButtonElement>;
|
|
25
|
+
}
|
|
26
|
+
declare function CollapsibleTrigger({ className, children, hideIcon, icon, onClick, type, disabled: disabledProp, ref, ...props }: CollapsibleTriggerProps): ReactElement;
|
|
27
|
+
declare namespace CollapsibleTrigger {
|
|
28
|
+
var displayName: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CollapsibleContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
31
|
+
/** When true, content stays mounted while closed (useful for forms). */
|
|
32
|
+
forceMount?: boolean;
|
|
33
|
+
ref?: Ref<HTMLDivElement>;
|
|
34
|
+
}
|
|
35
|
+
declare function CollapsibleContent({ className, children, forceMount, ref, ...props }: CollapsibleContentProps): ReactElement;
|
|
36
|
+
declare namespace CollapsibleContent {
|
|
37
|
+
var displayName: string;
|
|
38
|
+
}
|
|
39
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent, collapsibleRootVariants, collapsibleTriggerVariants, collapsibleContentInnerVariants, };
|
|
40
|
+
export { collapsibleVariantIds, collapsibleSizeIds, type CollapsibleVariantId, type CollapsibleSizeId, } from "./collapsible-variants";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useContext, useId, useMemo, useState, } from "react";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
import { AnimatePresence, m } from "../../../framer-motion";
|
|
7
|
+
import { collapsibleContentInnerVariants, collapsibleRootVariants, collapsibleTriggerVariants, } from "./collapsible-variants";
|
|
8
|
+
const CollapsibleContext = createContext(null);
|
|
9
|
+
function useCollapsibleContext(componentName) {
|
|
10
|
+
const ctx = useContext(CollapsibleContext);
|
|
11
|
+
if (ctx === null) {
|
|
12
|
+
throw new Error(`<${componentName}> must be rendered inside a <Collapsible> root.`);
|
|
13
|
+
}
|
|
14
|
+
return ctx;
|
|
15
|
+
}
|
|
16
|
+
function Collapsible({ className, variant, size, open: openProp, defaultOpen = false, onOpenChange, disabled = false, children, ref, ...props }) {
|
|
17
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
18
|
+
const isControlled = openProp !== undefined;
|
|
19
|
+
const open = isControlled ? openProp : internalOpen;
|
|
20
|
+
const reactId = useId();
|
|
21
|
+
const triggerId = `collapsible-trigger-${reactId}`;
|
|
22
|
+
const contentId = `collapsible-content-${reactId}`;
|
|
23
|
+
const resolvedVariant = variant ?? "default";
|
|
24
|
+
const resolvedSize = size ?? "md";
|
|
25
|
+
const toggle = useCallback(() => {
|
|
26
|
+
if (disabled)
|
|
27
|
+
return;
|
|
28
|
+
const next = !open;
|
|
29
|
+
if (!isControlled) {
|
|
30
|
+
setInternalOpen(next);
|
|
31
|
+
}
|
|
32
|
+
onOpenChange?.(next);
|
|
33
|
+
}, [disabled, open, isControlled, onOpenChange]);
|
|
34
|
+
const ctx = useMemo(() => ({
|
|
35
|
+
open,
|
|
36
|
+
disabled,
|
|
37
|
+
contentId,
|
|
38
|
+
triggerId,
|
|
39
|
+
variant: resolvedVariant,
|
|
40
|
+
size: resolvedSize,
|
|
41
|
+
toggle,
|
|
42
|
+
}), [open, disabled, contentId, triggerId, resolvedVariant, resolvedSize, toggle]);
|
|
43
|
+
return (_jsx(CollapsibleContext.Provider, { value: ctx, children: _jsx("div", { ref: ref, "data-slot": "collapsible", "data-state": open ? "open" : "closed", "data-disabled": disabled ? "" : undefined, className: cn(collapsibleRootVariants({ variant: resolvedVariant, size: resolvedSize }), className), ...props, children: children }) }));
|
|
44
|
+
}
|
|
45
|
+
Collapsible.displayName = "Collapsible";
|
|
46
|
+
function CollapsibleTrigger({ className, children, hideIcon = false, icon, onClick, type, disabled: disabledProp, ref, ...props }) {
|
|
47
|
+
const { open, toggle, disabled, contentId, triggerId, variant, size } = useCollapsibleContext("CollapsibleTrigger");
|
|
48
|
+
const handleClick = useCallback((event) => {
|
|
49
|
+
onClick?.(event);
|
|
50
|
+
if (event.defaultPrevented)
|
|
51
|
+
return;
|
|
52
|
+
toggle();
|
|
53
|
+
}, [onClick, toggle]);
|
|
54
|
+
const isDisabled = Boolean(disabledProp) || disabled;
|
|
55
|
+
return (_jsxs("button", { ref: ref, id: triggerId, type: type ?? "button", "data-slot": "collapsible-trigger", "data-state": open ? "open" : "closed", "aria-expanded": open, "aria-controls": contentId, disabled: isDisabled, onClick: handleClick, className: cn(collapsibleTriggerVariants({ variant, size }), className), ...props, children: [_jsx("span", { className: "flex-1 text-left", children: children }), hideIcon ? null : (_jsx("span", { "aria-hidden": true, className: cn("inline-flex shrink-0 transition-transform duration-200", open ? "rotate-180" : "rotate-0"), children: icon ?? _jsx(ChevronDown, {}) }))] }));
|
|
56
|
+
}
|
|
57
|
+
CollapsibleTrigger.displayName = "CollapsibleTrigger";
|
|
58
|
+
function CollapsibleContent({ className, children, forceMount = false, ref, ...props }) {
|
|
59
|
+
const { open, contentId, triggerId, variant, size } = useCollapsibleContext("CollapsibleContent");
|
|
60
|
+
if (forceMount) {
|
|
61
|
+
return (_jsx("div", { ref: ref, id: contentId, role: "region", "aria-labelledby": triggerId, hidden: !open, "data-slot": "collapsible-content", "data-state": open ? "open" : "closed", className: cn("overflow-hidden", className), ...props, children: _jsx("div", { className: cn(collapsibleContentInnerVariants({ variant, size })), children: children }) }));
|
|
62
|
+
}
|
|
63
|
+
return (_jsx(AnimatePresence, { initial: false, children: open ? (_jsx(m.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: {
|
|
64
|
+
height: { duration: 0.22, ease: [0.4, 0, 0.2, 1] },
|
|
65
|
+
opacity: { duration: 0.18, ease: "easeOut" },
|
|
66
|
+
}, className: "overflow-hidden", children: _jsx("div", { ref: ref, id: contentId, role: "region", "aria-labelledby": triggerId, "data-slot": "collapsible-content", "data-state": "open", className: className, ...props, children: _jsx("div", { className: cn(collapsibleContentInnerVariants({ variant, size })), children: children }) }) }, "collapsible-content")) : null }));
|
|
67
|
+
}
|
|
68
|
+
CollapsibleContent.displayName = "CollapsibleContent";
|
|
69
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent, collapsibleRootVariants, collapsibleTriggerVariants, collapsibleContentInnerVariants, };
|
|
70
|
+
export { collapsibleVariantIds, collapsibleSizeIds, } from "./collapsible-variants";
|
|
71
|
+
//# sourceMappingURL=collapsible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapsible.js","sourceRoot":"","sources":["../../../../src/components/ui/collapsible/collapsible.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,KAAK,EACL,OAAO,EACP,Q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AC,QAAQ,qBACI,SAAS,eAChB,qBAAqB,gBACpB,MAAM,EACjB,SAAS,EAAE,SAAS,KAChB,KAAK,YAET,cAAK,SAAS,EAAE,EAAE,CAAC,+BAA+B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,YACnE,QAAQ,GACL,GACF,IAvBF,qBAAqB,CAwBnB,CACT,CAAC,CAAC,CAAC,IAAI,GACQ,CACnB,CAAC;AACJ,CAAC;AACD,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAC;AAEtD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,CAAC;AACF,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GAGnB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/collapsible/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const diffOpTypes: readonly ["equal", "insert", "delete"];
|
|
2
|
+
export type DiffOpType = (typeof diffOpTypes)[number];
|
|
3
|
+
export interface DiffOp {
|
|
4
|
+
type: DiffOpType;
|
|
5
|
+
/** The line text. For "equal" this is identical on both sides. */
|
|
6
|
+
text: string;
|
|
7
|
+
/** 1-based line number in the old source (undefined for inserts). */
|
|
8
|
+
oldLineNumber?: number;
|
|
9
|
+
/** 1-based line number in the new source (undefined for deletes). */
|
|
10
|
+
newLineNumber?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compute a line-by-line diff between two strings using the classic
|
|
14
|
+
* longest-common-subsequence dynamic-programming algorithm. Time and space
|
|
15
|
+
* complexity are O(m * n), which is acceptable for typical document-sized
|
|
16
|
+
* inputs (up to a few thousand lines).
|
|
17
|
+
*/
|
|
18
|
+
export declare function computeLineDiff(oldText: string, newText: string): DiffOp[];
|
|
19
|
+
export interface DiffStats {
|
|
20
|
+
additions: number;
|
|
21
|
+
deletions: number;
|
|
22
|
+
unchanged: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function summarizeDiff(ops: readonly DiffOp[]): DiffStats;
|
|
25
|
+
export interface SplitDiffRow {
|
|
26
|
+
/** The op for the left (old) side, if any. */
|
|
27
|
+
left?: DiffOp;
|
|
28
|
+
/** The op for the right (new) side, if any. */
|
|
29
|
+
right?: DiffOp;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert a flat sequence of diff ops into rows suitable for side-by-side
|
|
33
|
+
* display. Contiguous runs of delete/insert ops are zipped together so that
|
|
34
|
+
* a deleted line lines up horizontally with the corresponding inserted line
|
|
35
|
+
* when possible.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildSplitRows(ops: readonly DiffOp[]): SplitDiffRow[];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export const diffOpTypes = ["equal", "insert", "delete"];
|
|
2
|
+
/**
|
|
3
|
+
* Compute a line-by-line diff between two strings using the classic
|
|
4
|
+
* longest-common-subsequence dynamic-programming algorithm. Time and space
|
|
5
|
+
* complexity are O(m * n), which is acceptable for typical document-sized
|
|
6
|
+
* inputs (up to a few thousand lines).
|
|
7
|
+
*/
|
|
8
|
+
export function computeLineDiff(oldText, newText) {
|
|
9
|
+
const oldLines = oldText.split("\n");
|
|
10
|
+
const newLines = newText.split("\n");
|
|
11
|
+
const m = oldLines.length;
|
|
12
|
+
const n = newLines.length;
|
|
13
|
+
const dp = new Uint32Array((m + 1) * (n + 1));
|
|
14
|
+
const stride = n + 1;
|
|
15
|
+
for (let i = 1; i <= m; i++) {
|
|
16
|
+
for (let j = 1; j <= n; j++) {
|
|
17
|
+
if (oldLines[i - 1] === newLines[j - 1]) {
|
|
18
|
+
dp[i * stride + j] = dp[(i - 1) * stride + (j - 1)] + 1;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const up = dp[(i - 1) * stride + j];
|
|
22
|
+
const left = dp[i * stride + (j - 1)];
|
|
23
|
+
dp[i * stride + j] = up >= left ? up : left;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ops = [];
|
|
28
|
+
let i = m;
|
|
29
|
+
let j = n;
|
|
30
|
+
while (i > 0 && j > 0) {
|
|
31
|
+
if (oldLines[i - 1] === newLines[j - 1]) {
|
|
32
|
+
ops.push({
|
|
33
|
+
type: "equal",
|
|
34
|
+
text: oldLines[i - 1],
|
|
35
|
+
oldLineNumber: i,
|
|
36
|
+
newLineNumber: j,
|
|
37
|
+
});
|
|
38
|
+
i--;
|
|
39
|
+
j--;
|
|
40
|
+
}
|
|
41
|
+
else if (dp[(i - 1) * stride + j] >= dp[i * stride + (j - 1)]) {
|
|
42
|
+
ops.push({
|
|
43
|
+
type: "delete",
|
|
44
|
+
text: oldLines[i - 1],
|
|
45
|
+
oldLineNumber: i,
|
|
46
|
+
});
|
|
47
|
+
i--;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
ops.push({
|
|
51
|
+
type: "insert",
|
|
52
|
+
text: newLines[j - 1],
|
|
53
|
+
newLineNumber: j,
|
|
54
|
+
});
|
|
55
|
+
j--;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
while (i > 0) {
|
|
59
|
+
ops.push({
|
|
60
|
+
type: "delete",
|
|
61
|
+
text: oldLines[i - 1],
|
|
62
|
+
oldLineNumber: i,
|
|
63
|
+
});
|
|
64
|
+
i--;
|
|
65
|
+
}
|
|
66
|
+
while (j > 0) {
|
|
67
|
+
ops.push({
|
|
68
|
+
type: "insert",
|
|
69
|
+
text: newLines[j - 1],
|
|
70
|
+
newLineNumber: j,
|
|
71
|
+
});
|
|
72
|
+
j--;
|
|
73
|
+
}
|
|
74
|
+
ops.reverse();
|
|
75
|
+
return ops;
|
|
76
|
+
}
|
|
77
|
+
export function summarizeDiff(ops) {
|
|
78
|
+
let additions = 0;
|
|
79
|
+
let deletions = 0;
|
|
80
|
+
let unchanged = 0;
|
|
81
|
+
for (const op of ops) {
|
|
82
|
+
if (op.type === "insert")
|
|
83
|
+
additions++;
|
|
84
|
+
else if (op.type === "delete")
|
|
85
|
+
deletions++;
|
|
86
|
+
else
|
|
87
|
+
unchanged++;
|
|
88
|
+
}
|
|
89
|
+
return { additions, deletions, unchanged };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Convert a flat sequence of diff ops into rows suitable for side-by-side
|
|
93
|
+
* display. Contiguous runs of delete/insert ops are zipped together so that
|
|
94
|
+
* a deleted line lines up horizontally with the corresponding inserted line
|
|
95
|
+
* when possible.
|
|
96
|
+
*/
|
|
97
|
+
export function buildSplitRows(ops) {
|
|
98
|
+
const rows = [];
|
|
99
|
+
let cursor = 0;
|
|
100
|
+
while (cursor < ops.length) {
|
|
101
|
+
const op = ops[cursor];
|
|
102
|
+
if (op.type === "equal") {
|
|
103
|
+
rows.push({ left: op, right: op });
|
|
104
|
+
cursor++;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const deletes = [];
|
|
108
|
+
const inserts = [];
|
|
109
|
+
while (cursor < ops.length && ops[cursor].type !== "equal") {
|
|
110
|
+
const next = ops[cursor];
|
|
111
|
+
if (next.type === "delete")
|
|
112
|
+
deletes.push(next);
|
|
113
|
+
else
|
|
114
|
+
inserts.push(next);
|
|
115
|
+
cursor++;
|
|
116
|
+
}
|
|
117
|
+
const pairCount = Math.max(deletes.length, inserts.length);
|
|
118
|
+
for (let k = 0; k < pairCount; k++) {
|
|
119
|
+
rows.push({ left: deletes[k], right: inserts[k] });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return rows;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=compute-line-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute-line-diff.js","sourceRoot":"","sources":["../../../../src/components/ui/diff-viewer/compute-line-diff.ts"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AAC,MAAM,CAAC,CAAC;QAC/B,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;YACnC,MAAM,EAAE,CAAC;YACT,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,OAAO,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3D,MAAM,IAAI,GAAW,GAAG,CAAC,MAAM,CAAC,CAAC;YACjC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBAC1C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,MAAM,EAAE,CAAC;QACX,CAAC;QACD,MAAM,SAAS,GAAW,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACnE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const diffViewerVariantIds: readonly ["default", "subtle", "contrast"];
|
|
2
|
+
export type DiffViewerVariant = (typeof diffViewerVariantIds)[number];
|
|
3
|
+
export declare const diffViewerSizeIds: readonly ["sm", "md", "lg"];
|
|
4
|
+
export type DiffViewerSize = (typeof diffViewerSizeIds)[number];
|
|
5
|
+
export declare const diffViewerModeIds: readonly ["unified", "split"];
|
|
6
|
+
export type DiffViewerMode = (typeof diffViewerModeIds)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-viewer-variants.js","sourceRoot":"","sources":["../../../../src/components/ui/diff-viewer/diff-viewer-variants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS;IACT,QAAQ;IACR,UAAU;CAC0B,CAAC;AAGvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAsC,CAAC;AAGzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,OAAO,CAAsC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode, type Ref } from "react";
|
|
3
|
+
import { diffViewerModeIds, diffViewerSizeIds, diffViewerVariantIds, type DiffViewerMode, type DiffViewerSize, type DiffViewerVariant } from "./diff-viewer-variants";
|
|
4
|
+
declare const diffViewerVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "subtle" | "contrast" | null | undefined;
|
|
6
|
+
size?: "sm" | "lg" | "md" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
export interface DiffViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "title">, VariantProps<typeof diffViewerVariants> {
|
|
9
|
+
/** The original text (the "before" state). */
|
|
10
|
+
oldValue: string;
|
|
11
|
+
/** The updated text (the "after" state). */
|
|
12
|
+
newValue: string;
|
|
13
|
+
/** Display mode. `unified` (default) shows one column; `split` shows two. */
|
|
14
|
+
mode?: DiffViewerMode;
|
|
15
|
+
/** Optional title rendered in the header (e.g. a file path). */
|
|
16
|
+
title?: ReactNode;
|
|
17
|
+
/** Label shown above the old/left column. Defaults to "Before". */
|
|
18
|
+
oldLabel?: ReactNode;
|
|
19
|
+
/** Label shown above the new/right column. Defaults to "After". */
|
|
20
|
+
newLabel?: ReactNode;
|
|
21
|
+
/** When true, displays line numbers in the gutter. Defaults to true. */
|
|
22
|
+
showLineNumbers?: boolean;
|
|
23
|
+
/** When true, shows additions/deletions counts in the header. Defaults to true. */
|
|
24
|
+
showStats?: boolean;
|
|
25
|
+
/** When true, long lines wrap rather than scroll horizontally. Defaults to false. */
|
|
26
|
+
wrap?: boolean;
|
|
27
|
+
/** Optional max-height applied to the scroll container, e.g. "20rem". */
|
|
28
|
+
maxHeight?: string;
|
|
29
|
+
/** Optional ref to the outer wrapper element. */
|
|
30
|
+
ref?: Ref<HTMLDivElement>;
|
|
31
|
+
}
|
|
32
|
+
declare function DiffViewer({ oldValue, newValue, mode, title, oldLabel, newLabel, showLineNumbers, showStats, wrap, maxHeight, variant, size, className, ref, ...props }: DiffViewerProps): ReactElement;
|
|
33
|
+
declare namespace DiffViewer {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
export { DiffViewer, diffViewerVariants, diffViewerVariantIds, diffViewerSizeIds, diffViewerModeIds, };
|
|
37
|
+
export type { DiffViewerVariant, DiffViewerSize, DiffViewerMode };
|
|
38
|
+
export default DiffViewer;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { useMemo, } from "react";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
import { buildSplitRows, computeLineDiff, summarizeDiff, } from "./compute-line-diff";
|
|
7
|
+
import { diffViewerModeIds, diffViewerSizeIds, diffViewerVariantIds, } from "./diff-viewer-variants";
|
|
8
|
+
const diffViewerVariants = cva("relative overflow-hidden rounded-md border font-mono", {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "border-border bg-card text-foreground",
|
|
12
|
+
subtle: "border-transparent bg-muted/60 text-foreground",
|
|
13
|
+
contrast: "border-foreground/10 bg-foreground/[0.03] text-foreground",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
sm: "text-xs",
|
|
17
|
+
md: "text-sm",
|
|
18
|
+
lg: "text-base",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "default",
|
|
23
|
+
size: "md",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const diffViewerHeaderVariants = cva("flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2", {
|
|
27
|
+
variants: {
|
|
28
|
+
variant: {
|
|
29
|
+
default: "border-border/60 bg-background/40",
|
|
30
|
+
subtle: "border-border/40 bg-transparent",
|
|
31
|
+
contrast: "border-foreground/10 bg-foreground/[0.04]",
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
sm: "text-[11px]",
|
|
35
|
+
md: "text-xs",
|
|
36
|
+
lg: "text-sm",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
variant: "default",
|
|
41
|
+
size: "md",
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const diffViewerBodyPaddingVariants = cva("leading-6", {
|
|
45
|
+
variants: {
|
|
46
|
+
size: {
|
|
47
|
+
sm: "leading-5",
|
|
48
|
+
md: "leading-6",
|
|
49
|
+
lg: "leading-7",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
defaultVariants: { size: "md" },
|
|
53
|
+
});
|
|
54
|
+
const lineNumberClasses = "select-none px-2 py-0 text-right tabular-nums text-muted-foreground/70";
|
|
55
|
+
const equalRowClasses = "bg-transparent";
|
|
56
|
+
const insertRowClasses = "bg-emerald-500/10 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-300";
|
|
57
|
+
const deleteRowClasses = "bg-destructive/10 text-destructive dark:text-red-300";
|
|
58
|
+
const emptyRowClasses = "bg-muted/40";
|
|
59
|
+
const markerClasses = "select-none px-2 text-center font-semibold";
|
|
60
|
+
function DiffViewer({ oldValue, newValue, mode = "unified", title, oldLabel = "Before", newLabel = "After", showLineNumbers = true, showStats = true, wrap = false, maxHeight, variant, size, className, ref, ...props }) {
|
|
61
|
+
const ops = useMemo(() => computeLineDiff(oldValue, newValue), [oldValue, newValue]);
|
|
62
|
+
const stats = useMemo(() => summarizeDiff(ops), [ops]);
|
|
63
|
+
const splitRows = useMemo(() => (mode === "split" ? buildSplitRows(ops) : []), [ops, mode]);
|
|
64
|
+
const resolvedVariant = variant ?? "default";
|
|
65
|
+
const resolvedSize = size ?? "md";
|
|
66
|
+
return (_jsxs("div", { ref: ref, "data-slot": "diff-viewer", "data-mode": mode, "data-variant": resolvedVariant, className: cn(diffViewerVariants({ variant, size }), className), ...props, children: [_jsxs("div", { "data-slot": "diff-viewer-header", className: cn(diffViewerHeaderVariants({ variant, size })), children: [_jsx("div", { className: "flex min-w-0 items-center gap-2", children: title !== undefined && (_jsx("span", { "data-slot": "diff-viewer-title", className: "truncate font-sans font-medium opacity-90", children: title })) }), showStats && (_jsxs("div", { "data-slot": "diff-viewer-stats", className: "flex shrink-0 items-center gap-2 font-sans", "aria-label": `${stats.additions} additions, ${stats.deletions} deletions`, children: [_jsxs("span", { className: "inline-flex items-center gap-1 rounded bg-emerald-500/15 px-1.5 py-0.5 font-mono font-semibold text-emerald-700 dark:text-emerald-300", children: ["+", stats.additions] }), _jsxs("span", { className: "inline-flex items-center gap-1 rounded bg-destructive/15 px-1.5 py-0.5 font-mono font-semibold text-destructive dark:text-red-300", children: ["-", stats.deletions] })] }))] }), _jsx("div", { "data-slot": "diff-viewer-body", className: cn("overflow-auto", diffViewerBodyPaddingVariants({ size: resolvedSize })), style: maxHeight !== undefined ? { maxHeight } : undefined, children: mode === "split" ? (_jsx(SplitView, { rows: splitRows, showLineNumbers: showLineNumbers, wrap: wrap, oldLabel: oldLabel, newLabel: newLabel })) : (_jsx(UnifiedView, { ops: ops, showLineNumbers: showLineNumbers, wrap: wrap })) })] }));
|
|
67
|
+
}
|
|
68
|
+
DiffViewer.displayName = "DiffViewer";
|
|
69
|
+
function UnifiedView({ ops, showLineNumbers, wrap, }) {
|
|
70
|
+
const cellWhitespace = wrap
|
|
71
|
+
? "whitespace-pre-wrap break-words"
|
|
72
|
+
: "whitespace-pre";
|
|
73
|
+
const gridTemplate = showLineNumbers
|
|
74
|
+
? "grid-cols-[auto_auto_auto_1fr]"
|
|
75
|
+
: "grid-cols-[auto_1fr]";
|
|
76
|
+
return (_jsx("div", { role: "table", "aria-label": "Unified diff", "data-slot": "diff-viewer-unified", className: cn("grid min-w-full", gridTemplate), children: ops.map((op, idx) => {
|
|
77
|
+
const rowClasses = op.type === "insert"
|
|
78
|
+
? insertRowClasses
|
|
79
|
+
: op.type === "delete"
|
|
80
|
+
? deleteRowClasses
|
|
81
|
+
: equalRowClasses;
|
|
82
|
+
const marker = op.type === "insert" ? "+" : op.type === "delete" ? "-" : " ";
|
|
83
|
+
return (_jsxs("div", { role: "row", "data-op": op.type, className: cn("contents"), children: [showLineNumbers && (_jsx("span", { role: "cell", className: cn(lineNumberClasses, rowClasses), children: op.oldLineNumber ?? "" })), showLineNumbers && (_jsx("span", { role: "cell", className: cn(lineNumberClasses, rowClasses), children: op.newLineNumber ?? "" })), _jsx("span", { role: "cell", "aria-hidden": "true", className: cn(markerClasses, rowClasses), children: marker }), _jsx("span", { role: "cell", className: cn("pr-3", cellWhitespace, rowClasses), children: op.text.length === 0 ? "" : op.text })] }, idx));
|
|
84
|
+
}) }));
|
|
85
|
+
}
|
|
86
|
+
function SplitView({ rows, showLineNumbers, wrap, oldLabel, newLabel, }) {
|
|
87
|
+
const cellWhitespace = wrap
|
|
88
|
+
? "whitespace-pre-wrap break-words"
|
|
89
|
+
: "whitespace-pre";
|
|
90
|
+
const sidePattern = showLineNumbers ? "auto auto 1fr" : "auto 1fr";
|
|
91
|
+
const gridTemplateColumns = `${sidePattern} ${sidePattern}`;
|
|
92
|
+
const columnsPerSide = showLineNumbers ? 3 : 2;
|
|
93
|
+
return (_jsxs("div", { role: "table", "aria-label": "Side-by-side diff", "data-slot": "diff-viewer-split", className: cn("grid min-w-full"), style: { gridTemplateColumns }, children: [_jsx("div", { role: "columnheader", className: "border-b border-border/60 bg-muted/40 px-3 py-1 font-sans text-xs font-medium text-muted-foreground", style: { gridColumn: `span ${columnsPerSide}` }, children: oldLabel }), _jsx("div", { role: "columnheader", className: "border-b border-l border-border/60 bg-muted/40 px-3 py-1 font-sans text-xs font-medium text-muted-foreground", style: { gridColumn: `span ${columnsPerSide}` }, children: newLabel }), rows.map((row, idx) => {
|
|
94
|
+
const leftOp = row.left;
|
|
95
|
+
const rightOp = row.right;
|
|
96
|
+
const leftRowClasses = leftOp === undefined
|
|
97
|
+
? emptyRowClasses
|
|
98
|
+
: leftOp.type === "delete"
|
|
99
|
+
? deleteRowClasses
|
|
100
|
+
: equalRowClasses;
|
|
101
|
+
const rightRowClasses = rightOp === undefined
|
|
102
|
+
? emptyRowClasses
|
|
103
|
+
: rightOp.type === "insert"
|
|
104
|
+
? insertRowClasses
|
|
105
|
+
: equalRowClasses;
|
|
106
|
+
const leftMarker = leftOp?.type === "delete" ? "-" : " ";
|
|
107
|
+
const rightMarker = rightOp?.type === "insert" ? "+" : " ";
|
|
108
|
+
return (_jsxs("div", { role: "row", "data-row-index": idx, className: "contents", children: [showLineNumbers && (_jsx("span", { role: "cell", className: cn(lineNumberClasses, leftRowClasses), children: leftOp?.oldLineNumber ?? "" })), _jsx("span", { role: "cell", "aria-hidden": "true", className: cn(markerClasses, leftRowClasses), children: leftMarker }), _jsx("span", { role: "cell", className: cn("pr-3", cellWhitespace, leftRowClasses), children: leftOp === undefined
|
|
109
|
+
? ""
|
|
110
|
+
: leftOp.text.length === 0
|
|
111
|
+
? ""
|
|
112
|
+
: leftOp.text }), showLineNumbers && (_jsx("span", { role: "cell", className: cn(lineNumberClasses, rightRowClasses, "border-l border-border/40"), children: rightOp?.newLineNumber ?? "" })), _jsx("span", { role: "cell", "aria-hidden": "true", className: cn(markerClasses, rightRowClasses, !showLineNumbers && "border-l border-border/40"), children: rightMarker }), _jsx("span", { role: "cell", className: cn("pr-3", cellWhitespace, rightRowClasses), children: rightOp === undefined
|
|
113
|
+
? ""
|
|
114
|
+
: rightOp.text.length === 0
|
|
115
|
+
? ""
|
|
116
|
+
: rightOp.text })] }, idx));
|
|
117
|
+
})] }));
|
|
118
|
+
}
|
|
119
|
+
export { DiffViewer, diffViewerVariants, diffViewerVariantIds, diffViewerSizeIds, diffViewerModeIds, };
|
|
120
|
+
export default DiffViewer;
|
|
121
|
+
//# sourceMappingURL=diff-viewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-viewer.js","sourceRoot":"","sources":["../../../../src/components/ui/diff-viewer/diff-viewer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAKL,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,cAAc,EACd,eAAe,EACf,aAAa,GAId,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GAIrB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,kBAAkB,GAAG,GAAG,CAC5B,sDAAsD,EACtD;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,uCAAuC;YAChD,MAAM,EAAE,gDAAgD;YACxD,QAAQ,EAAE,2DAA2D;SAC1B;QAC7C,IAAI,EAAE;YACJ,EAAE,EAAE,SAAS;YACb,EAAE,EAAE,SAAS;YACb,EAAE,EAAE,WAAW;SACyB;KAC3C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,S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,OAAO,CAAC,IAAI,GACX,KA3DF,GAAG,CA4DJ,CACP,CAAC;YACJ,CAAC,CAAC,IACE,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAGF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DiffViewer, DiffViewer as default, diffViewerVariants, diffViewerVariantIds, diffViewerSizeIds, diffViewerModeIds, } from "./diff-viewer";
|
|
2
|
+
export type { DiffViewerProps, } from "./diff-viewer";
|
|
3
|
+
export type { DiffViewerVariant, DiffViewerSize, DiffViewerMode, } from "./diff-viewer-variants";
|
|
4
|
+
export { computeLineDiff, summarizeDiff, buildSplitRows, diffOpTypes, } from "./compute-line-diff";
|
|
5
|
+
export type { DiffOp, DiffOpType, DiffStats, SplitDiffRow, } from "./compute-line-diff";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DiffViewer, DiffViewer as default, diffViewerVariants, diffViewerVariantIds, diffViewerSizeIds, diffViewerModeIds, } from "./diff-viewer";
|
|
2
|
+
export { computeLineDiff, summarizeDiff, buildSplitRows, diffOpTypes, } from "./compute-line-diff";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/diff-viewer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,IAAI,OAAO,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AASvB,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
|
|
@@ -4,6 +4,8 @@ export * from "./agent-chat-messages";
|
|
|
4
4
|
export type * from "./agent-chat-messages";
|
|
5
5
|
export * from "./accordion";
|
|
6
6
|
export type * from "./accordion";
|
|
7
|
+
export * from "./collapsible";
|
|
8
|
+
export type * from "./collapsible";
|
|
7
9
|
export * from "./alert";
|
|
8
10
|
export type * from "./alert";
|
|
9
11
|
export * from "./callout";
|
|
@@ -142,6 +144,8 @@ export * from "./secret-reveal";
|
|
|
142
144
|
export type * from "./secret-reveal";
|
|
143
145
|
export * from "./json-viewer";
|
|
144
146
|
export type * from "./json-viewer";
|
|
147
|
+
export * from "./diff-viewer";
|
|
148
|
+
export type * from "./diff-viewer";
|
|
145
149
|
export * from "./segmented-control";
|
|
146
150
|
export type * from "./segmented-control";
|
|
147
151
|
export * from "./marquee";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./avatar";
|
|
2
2
|
export * from "./agent-chat-messages";
|
|
3
3
|
export * from "./accordion";
|
|
4
|
+
export * from "./collapsible";
|
|
4
5
|
export * from "./alert";
|
|
5
6
|
export * from "./callout";
|
|
6
7
|
export * from "./blockquote";
|
|
@@ -70,6 +71,7 @@ export * from "./number-input";
|
|
|
70
71
|
export * from "./code-block";
|
|
71
72
|
export * from "./secret-reveal";
|
|
72
73
|
export * from "./json-viewer";
|
|
74
|
+
export * from "./diff-viewer";
|
|
73
75
|
export * from "./segmented-control";
|
|
74
76
|
export * from "./marquee";
|
|
75
77
|
export * from "./toggle";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,cAAc,uBAAuB,CAAC;AAGtC,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,UAAU,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,kBAAkB,C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