ixia-ui-react 1.4.3 → 1.4.5
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/index.d.ts +6 -3
- package/dist/index.js +17 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -731,7 +731,10 @@ interface CodeBlockValue {
|
|
|
731
731
|
id: string;
|
|
732
732
|
label: string;
|
|
733
733
|
name: string;
|
|
734
|
-
|
|
734
|
+
/** Original source used for copying, downloading, and the plain-code fallback. */
|
|
735
|
+
code?: string;
|
|
736
|
+
/** Custom presentation. Strings render as text; wrap trusted highlighter HTML explicitly. */
|
|
737
|
+
content?: React.ReactNode;
|
|
735
738
|
icon?: React.ReactNode;
|
|
736
739
|
}
|
|
737
740
|
type CodeBlockTabsProps = React.ComponentProps<typeof Tabs>;
|
|
@@ -750,10 +753,10 @@ declare function CodeBlock$1({ items, defaultValue, className, ref, ...props }:
|
|
|
750
753
|
export declare function CodeBlockActions({ className, ref, ...props }: CodeBlockActionsProps): import("react").JSX.Element;
|
|
751
754
|
//#endregion
|
|
752
755
|
//#region src/components/code-block/code-block-copy.d.ts
|
|
753
|
-
export declare function CodeBlockCopy({ className, children, ref, ...props }: CodeBlockCopyProps): React$1.JSX.Element
|
|
756
|
+
export declare function CodeBlockCopy({ className, children, disabled, ref, ...props }: CodeBlockCopyProps): React$1.JSX.Element;
|
|
754
757
|
//#endregion
|
|
755
758
|
//#region src/components/code-block/code-block-download.d.ts
|
|
756
|
-
export declare function CodeBlockDownload({ className, children, ref, ...props }: CodeBlockDownloadProps): React$1.JSX.Element
|
|
759
|
+
export declare function CodeBlockDownload({ className, children, disabled, ref, ...props }: CodeBlockDownloadProps): React$1.JSX.Element;
|
|
757
760
|
//#endregion
|
|
758
761
|
//#region src/components/code-block/code-block-header.d.ts
|
|
759
762
|
type CodeBlockHeaderProps = React.ComponentProps<'div'>;
|
package/dist/index.js
CHANGED
|
@@ -2349,7 +2349,7 @@ function useCodeBlock() {
|
|
|
2349
2349
|
//#region src/components/code-block/code-block-actions.tsx
|
|
2350
2350
|
function CodeBlockActions({ className, ref, ...props }) {
|
|
2351
2351
|
return /* @__PURE__ */ jsx("div", {
|
|
2352
|
-
className: cn("absolute top-
|
|
2352
|
+
className: cn("absolute top-2xs right-2xs flex items-center gap-3xs", className),
|
|
2353
2353
|
ref,
|
|
2354
2354
|
...props
|
|
2355
2355
|
});
|
|
@@ -2367,27 +2367,27 @@ const COPY_STATUS_ICON = {
|
|
|
2367
2367
|
className: "animate-in zoom-in"
|
|
2368
2368
|
})
|
|
2369
2369
|
};
|
|
2370
|
-
function CodeBlockCopy({ className, children, ref, ...props }) {
|
|
2371
|
-
const { currentValue } = useCodeBlock(), [copied, setCopied] = React.useState(false), handleClick = async () => {
|
|
2372
|
-
if (typeof currentValue.content !== "string") return;
|
|
2370
|
+
function CodeBlockCopy({ className, children, disabled, ref, ...props }) {
|
|
2371
|
+
const { currentValue } = useCodeBlock(), { code } = currentValue, [copied, setCopied] = React.useState(false), handleClick = async () => {
|
|
2373
2372
|
try {
|
|
2374
|
-
|
|
2373
|
+
if (code === void 0) throw new Error("No source code available to copy");
|
|
2374
|
+
await navigator.clipboard.writeText(code);
|
|
2375
2375
|
setCopied(true);
|
|
2376
2376
|
setTimeout(() => setCopied(false), COPY_TIMEOUT);
|
|
2377
2377
|
} catch (error) {
|
|
2378
2378
|
console.error("Failed to copy text:", error);
|
|
2379
2379
|
}
|
|
2380
2380
|
};
|
|
2381
|
-
if (React.isValidElement(currentValue.content)) return;
|
|
2382
2381
|
return /* @__PURE__ */ jsxs(Button, {
|
|
2383
2382
|
"aria-label": "Copy code",
|
|
2383
|
+
className: cn("", className),
|
|
2384
2384
|
onClick: handleClick,
|
|
2385
|
+
ref,
|
|
2385
2386
|
size: "medium",
|
|
2386
|
-
variant: "ghost",
|
|
2387
2387
|
tone: "neutral",
|
|
2388
|
-
|
|
2389
|
-
ref,
|
|
2388
|
+
variant: "ghost",
|
|
2390
2389
|
...props,
|
|
2390
|
+
disabled: disabled || code === void 0,
|
|
2391
2391
|
children: [children, COPY_STATUS_ICON[`${copied}`]]
|
|
2392
2392
|
});
|
|
2393
2393
|
}
|
|
@@ -2404,11 +2404,11 @@ const DOWNLOAD_STATUS_ICON = {
|
|
|
2404
2404
|
className: "animate-in zoom-in"
|
|
2405
2405
|
})
|
|
2406
2406
|
};
|
|
2407
|
-
function CodeBlockDownload({ className, children, ref, ...props }) {
|
|
2408
|
-
const { currentValue } = useCodeBlock(), [downloaded, setDownloaded] = React.useState(false), handleClick = async () => {
|
|
2409
|
-
if (typeof currentValue.content !== "string") return;
|
|
2407
|
+
function CodeBlockDownload({ className, children, disabled, ref, ...props }) {
|
|
2408
|
+
const { currentValue } = useCodeBlock(), { code } = currentValue, [downloaded, setDownloaded] = React.useState(false), handleClick = async () => {
|
|
2410
2409
|
try {
|
|
2411
|
-
|
|
2410
|
+
if (code === void 0) throw new Error("No source code available to download");
|
|
2411
|
+
const blob = new Blob([code], { type: "text/plain;charset=utf-8" }), url = URL.createObjectURL(blob), link = document.createElement("a");
|
|
2412
2412
|
link.href = url;
|
|
2413
2413
|
link.download = currentValue.name;
|
|
2414
2414
|
link.click();
|
|
@@ -2419,7 +2419,6 @@ function CodeBlockDownload({ className, children, ref, ...props }) {
|
|
|
2419
2419
|
console.error("Failed to download file:", error);
|
|
2420
2420
|
}
|
|
2421
2421
|
};
|
|
2422
|
-
if (React.isValidElement(currentValue.content)) return;
|
|
2423
2422
|
return /* @__PURE__ */ jsxs(Button, {
|
|
2424
2423
|
"aria-label": "Download file",
|
|
2425
2424
|
onClick: handleClick,
|
|
@@ -2429,6 +2428,7 @@ function CodeBlockDownload({ className, children, ref, ...props }) {
|
|
|
2429
2428
|
className: cn("", className),
|
|
2430
2429
|
ref,
|
|
2431
2430
|
...props,
|
|
2431
|
+
disabled: disabled || code === void 0,
|
|
2432
2432
|
children: [children, DOWNLOAD_STATUS_ICON[`${downloaded}`]]
|
|
2433
2433
|
});
|
|
2434
2434
|
}
|
|
@@ -2760,15 +2760,13 @@ function CodeBlockTabs({ className, children, ref, ...props }) {
|
|
|
2760
2760
|
//#region src/components/code-block/code-block-window.tsx
|
|
2761
2761
|
function CodeBlockWindow({ className, children, ref, ...props }) {
|
|
2762
2762
|
const { currentValue } = useCodeBlock();
|
|
2763
|
+
let { content } = currentValue;
|
|
2764
|
+
if (content === void 0 && currentValue.code !== void 0) content = /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: currentValue.code }) });
|
|
2763
2765
|
return /* @__PURE__ */ jsxs("div", {
|
|
2764
2766
|
className: cn("relative overflow-auto rounded-lg px-md py-sm", className),
|
|
2765
2767
|
ref,
|
|
2766
2768
|
...props,
|
|
2767
|
-
children: [
|
|
2768
|
-
children,
|
|
2769
|
-
typeof currentValue.content === "string" && /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: currentValue.content } }),
|
|
2770
|
-
typeof currentValue.content !== "string" && currentValue.content
|
|
2771
|
-
]
|
|
2769
|
+
children: [children, content]
|
|
2772
2770
|
});
|
|
2773
2771
|
}
|
|
2774
2772
|
//#endregion
|