@gravitee/graphene-core 2.6.0-feat-copyable-text.8eebb46 → 2.6.0-feat-copyable-text.65776b6
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.
|
@@ -7,8 +7,10 @@ interface CopyableTextProps {
|
|
|
7
7
|
readonly copiedLabel?: string;
|
|
8
8
|
/** Milliseconds to keep the "copied" state. Defaults to 1500. */
|
|
9
9
|
readonly resetDelayMs?: number;
|
|
10
|
+
/** Called with the rejection when the clipboard write fails. */
|
|
11
|
+
readonly onCopyError?: (error: unknown) => void;
|
|
10
12
|
}
|
|
11
|
-
declare function CopyableText({ value, className, copyLabel, copiedLabel, resetDelayMs, }: CopyableTextProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function CopyableText({ value, className, copyLabel, copiedLabel, resetDelayMs, onCopyError, }: CopyableTextProps): import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
declare namespace CopyableText {
|
|
13
15
|
var displayName: string;
|
|
14
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyableText.d.ts","sourceRoot":"","sources":["../../../src/composed/CopyableText/CopyableText.tsx"],"names":[],"mappings":"AAMA,UAAU,iBAAiB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"CopyableText.d.ts","sourceRoot":"","sources":["../../../src/composed/CopyableText/CopyableText.tsx"],"names":[],"mappings":"AAMA,UAAU,iBAAiB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD;AAED,iBAAS,YAAY,CAAC,EACpB,KAAK,EACL,SAAS,EACT,SAA2B,EAC3B,WAAuB,EACvB,YAAmB,EACnB,WAAW,GACZ,EAAE,iBAAiB,2CAkDnB;kBAzDQ,YAAY;;;AA6DrB,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25729,25 +25729,39 @@ function hV({ className: e, breadcrumbs: t = [], leading: n, trailing: r }) {
|
|
|
25729
25729
|
hV.displayName = "ContentHeader";
|
|
25730
25730
|
//#endregion
|
|
25731
25731
|
//#region src/composed/CopyableText/CopyableText.tsx
|
|
25732
|
-
function gV({ value: e, className: t, copyLabel: n = "Click to copy", copiedLabel: r = "Copied!", resetDelayMs: i = 1500 }) {
|
|
25733
|
-
let [
|
|
25732
|
+
function gV({ value: e, className: t, copyLabel: n = "Click to copy", copiedLabel: r = "Copied!", resetDelayMs: i = 1500, onCopyError: a }) {
|
|
25733
|
+
let [o, s] = B(!1), c = z(null);
|
|
25734
|
+
L(() => () => {
|
|
25735
|
+
c.current !== null && clearTimeout(c.current);
|
|
25736
|
+
}, []);
|
|
25737
|
+
let l = P(() => {
|
|
25738
|
+
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
25739
|
+
a?.(/* @__PURE__ */ Error("Clipboard API is not available in this context"));
|
|
25740
|
+
return;
|
|
25741
|
+
}
|
|
25734
25742
|
navigator.clipboard.writeText(e).then(() => {
|
|
25735
|
-
|
|
25743
|
+
s(!0), c.current !== null && clearTimeout(c.current), c.current = setTimeout(() => s(!1), i);
|
|
25744
|
+
}).catch((e) => {
|
|
25745
|
+
a?.(e);
|
|
25736
25746
|
});
|
|
25737
|
-
}, [
|
|
25738
|
-
|
|
25747
|
+
}, [
|
|
25748
|
+
e,
|
|
25749
|
+
i,
|
|
25750
|
+
a
|
|
25751
|
+
]);
|
|
25752
|
+
return /* @__PURE__ */ W(vz, { children: [/* @__PURE__ */ U(yz, {
|
|
25739
25753
|
asChild: !0,
|
|
25740
25754
|
children: /* @__PURE__ */ W(Gv, {
|
|
25741
25755
|
"data-slot": "copyable-text",
|
|
25742
25756
|
variant: "ghost",
|
|
25743
25757
|
size: "sm",
|
|
25744
25758
|
className: q("text-muted-foreground inline-flex h-auto items-center gap-1 px-1", t),
|
|
25745
|
-
"aria-label":
|
|
25746
|
-
onClick:
|
|
25759
|
+
"aria-label": o ? r : `Copy ${e}`,
|
|
25760
|
+
onClick: l,
|
|
25747
25761
|
children: [/* @__PURE__ */ U("span", {
|
|
25748
25762
|
className: "font-mono text-xs",
|
|
25749
25763
|
children: e
|
|
25750
|
-
}),
|
|
25764
|
+
}), o ? /* @__PURE__ */ U(d, {
|
|
25751
25765
|
className: "size-3.5 text-primary",
|
|
25752
25766
|
"aria-hidden": "true"
|
|
25753
25767
|
}) : /* @__PURE__ */ U(p, {
|
|
@@ -25755,7 +25769,7 @@ function gV({ value: e, className: t, copyLabel: n = "Click to copy", copiedLabe
|
|
|
25755
25769
|
"aria-hidden": "true"
|
|
25756
25770
|
})]
|
|
25757
25771
|
})
|
|
25758
|
-
}), /* @__PURE__ */ U(bz, { children:
|
|
25772
|
+
}), /* @__PURE__ */ U(bz, { children: o ? r : n })] });
|
|
25759
25773
|
}
|
|
25760
25774
|
gV.displayName = "CopyableText";
|
|
25761
25775
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravitee/graphene-core",
|
|
3
|
-
"version": "2.6.0-feat-copyable-text.
|
|
3
|
+
"version": "2.6.0-feat-copyable-text.65776b6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Gravitee's Graphene design system: accessible React components, design tokens, icons, and shared ESLint/TypeScript configs. Built on shadcn/ui and Tailwind.",
|
|
6
6
|
"keywords": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@fontsource/dm-sans": ">=5.0.0",
|
|
91
|
-
"@gravitee/graphene-core": "2.6.0-feat-copyable-text.
|
|
91
|
+
"@gravitee/graphene-core": "2.6.0-feat-copyable-text.65776b6",
|
|
92
92
|
"@tanstack/react-table": "^8.0.0",
|
|
93
93
|
"@testing-library/dom": ">=10.0.0",
|
|
94
94
|
"@testing-library/react": ">=16.0.0",
|