ixia-ui-react 1.4.4 → 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 +16 -16
- 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
|
@@ -2367,11 +2367,11 @@ 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) {
|
|
@@ -2380,13 +2380,14 @@ function CodeBlockCopy({ className, children, ref, ...props }) {
|
|
|
2380
2380
|
};
|
|
2381
2381
|
return /* @__PURE__ */ jsxs(Button, {
|
|
2382
2382
|
"aria-label": "Copy code",
|
|
2383
|
+
className: cn("", className),
|
|
2383
2384
|
onClick: handleClick,
|
|
2385
|
+
ref,
|
|
2384
2386
|
size: "medium",
|
|
2385
|
-
variant: "ghost",
|
|
2386
2387
|
tone: "neutral",
|
|
2387
|
-
|
|
2388
|
-
ref,
|
|
2388
|
+
variant: "ghost",
|
|
2389
2389
|
...props,
|
|
2390
|
+
disabled: disabled || code === void 0,
|
|
2390
2391
|
children: [children, COPY_STATUS_ICON[`${copied}`]]
|
|
2391
2392
|
});
|
|
2392
2393
|
}
|
|
@@ -2403,11 +2404,11 @@ const DOWNLOAD_STATUS_ICON = {
|
|
|
2403
2404
|
className: "animate-in zoom-in"
|
|
2404
2405
|
})
|
|
2405
2406
|
};
|
|
2406
|
-
function CodeBlockDownload({ className, children, ref, ...props }) {
|
|
2407
|
-
const { currentValue } = useCodeBlock(), [downloaded, setDownloaded] = React.useState(false), handleClick = async () => {
|
|
2408
|
-
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 () => {
|
|
2409
2409
|
try {
|
|
2410
|
-
|
|
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");
|
|
2411
2412
|
link.href = url;
|
|
2412
2413
|
link.download = currentValue.name;
|
|
2413
2414
|
link.click();
|
|
@@ -2427,6 +2428,7 @@ function CodeBlockDownload({ className, children, ref, ...props }) {
|
|
|
2427
2428
|
className: cn("", className),
|
|
2428
2429
|
ref,
|
|
2429
2430
|
...props,
|
|
2431
|
+
disabled: disabled || code === void 0,
|
|
2430
2432
|
children: [children, DOWNLOAD_STATUS_ICON[`${downloaded}`]]
|
|
2431
2433
|
});
|
|
2432
2434
|
}
|
|
@@ -2758,15 +2760,13 @@ function CodeBlockTabs({ className, children, ref, ...props }) {
|
|
|
2758
2760
|
//#region src/components/code-block/code-block-window.tsx
|
|
2759
2761
|
function CodeBlockWindow({ className, children, ref, ...props }) {
|
|
2760
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 }) });
|
|
2761
2765
|
return /* @__PURE__ */ jsxs("div", {
|
|
2762
2766
|
className: cn("relative overflow-auto rounded-lg px-md py-sm", className),
|
|
2763
2767
|
ref,
|
|
2764
2768
|
...props,
|
|
2765
|
-
children: [
|
|
2766
|
-
children,
|
|
2767
|
-
typeof currentValue.content === "string" && /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: currentValue.content } }),
|
|
2768
|
-
typeof currentValue.content !== "string" && currentValue.content
|
|
2769
|
-
]
|
|
2769
|
+
children: [children, content]
|
|
2770
2770
|
});
|
|
2771
2771
|
}
|
|
2772
2772
|
//#endregion
|