@box/copy-input 1.38.0 → 1.39.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/dist/esm/lib/copy-input.js +63 -61
- package/dist/types/lib/types.d.ts +2 -0
- package/package.json +7 -7
|
@@ -1,84 +1,86 @@
|
|
|
1
|
-
import { useUniqueId as _, BaseTextInput as
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { messages as
|
|
6
|
-
import { useClipboardCopy as
|
|
7
|
-
import { jsxs as
|
|
8
|
-
import '../../styles/copy-input.css';const
|
|
9
|
-
formWrapper:
|
|
10
|
-
hasError:
|
|
11
|
-
copyInputWrapper:
|
|
12
|
-
copied:
|
|
13
|
-
copyButton:
|
|
14
|
-
copyInput:
|
|
15
|
-
subtext:
|
|
16
|
-
inlineError:
|
|
17
|
-
},
|
|
1
|
+
import { useUniqueId as _, BaseTextInput as F, Button as O, InlineError as q, Text as w } from "@box/blueprint-web";
|
|
2
|
+
import c from "clsx";
|
|
3
|
+
import { forwardRef as z, useCallback as f } from "react";
|
|
4
|
+
import { useIntl as H } from "react-intl";
|
|
5
|
+
import { messages as I } from "./messages.js";
|
|
6
|
+
import { useClipboardCopy as U } from "./utils.js";
|
|
7
|
+
import { jsxs as h, jsx as n } from "react/jsx-runtime";
|
|
8
|
+
import '../../styles/copy-input.css';const A = "_formWrapper_241a0_2", G = "_hasError_241a0_7", J = "_copyInputWrapper_241a0_17", K = "_copied_241a0_21", P = "_copyButton_241a0_38", Q = "_copyInput_241a0_17", V = "_subtext_241a0_70", X = "_inlineError_241a0_71", e = {
|
|
9
|
+
formWrapper: A,
|
|
10
|
+
hasError: G,
|
|
11
|
+
copyInputWrapper: J,
|
|
12
|
+
copied: K,
|
|
13
|
+
copyButton: P,
|
|
14
|
+
copyInput: Q,
|
|
15
|
+
subtext: V,
|
|
16
|
+
inlineError: X
|
|
17
|
+
}, Y = /* @__PURE__ */ z((x, g) => {
|
|
18
18
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
error:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
successStateDuration: C,
|
|
19
|
+
ariaLive: E,
|
|
20
|
+
"data-target-id": B,
|
|
21
|
+
disabled: o,
|
|
22
|
+
error: a,
|
|
23
|
+
hideLabel: C,
|
|
24
|
+
id: Z,
|
|
26
25
|
label: v,
|
|
27
26
|
onCopy: L,
|
|
28
|
-
|
|
27
|
+
subtext: p,
|
|
28
|
+
successStateDuration: W,
|
|
29
|
+
value: N,
|
|
29
30
|
...l
|
|
30
|
-
} = x, d =
|
|
31
|
+
} = x, d = H(), S = d.formatMessage(I.copyButtonLabel), T = d.formatMessage(I.copyButtonCopiedLabel), u = _("inline-error-"), y = _("subtext-"), {
|
|
31
32
|
copied: m,
|
|
32
33
|
handleCopy: b,
|
|
33
|
-
inputRef:
|
|
34
|
-
} =
|
|
35
|
-
|
|
36
|
-
}, []),
|
|
37
|
-
|
|
38
|
-
}, []),
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
[
|
|
34
|
+
inputRef: D
|
|
35
|
+
} = U(o, L, W), M = f((r) => {
|
|
36
|
+
r.target.select();
|
|
37
|
+
}, []), R = f((r) => {
|
|
38
|
+
r.target instanceof HTMLInputElement && r.target.setSelectionRange(0, r.target.value.length);
|
|
39
|
+
}, []), t = !!a && !o, s = !a && !!p, j = t || s;
|
|
40
|
+
let i = "";
|
|
41
|
+
t ? i = u : s && (i = y);
|
|
42
|
+
const k = c(l["aria-describedby"], {
|
|
43
|
+
[i]: j
|
|
43
44
|
});
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
className:
|
|
46
|
-
[e.hasError]:
|
|
45
|
+
return /* @__PURE__ */ h("div", {
|
|
46
|
+
className: c(e.formWrapper, {
|
|
47
|
+
[e.hasError]: a
|
|
47
48
|
}),
|
|
48
|
-
children: [/* @__PURE__ */
|
|
49
|
-
className:
|
|
49
|
+
children: [/* @__PURE__ */ h("div", {
|
|
50
|
+
className: c(e.copyInputWrapper, {
|
|
50
51
|
[e.copied]: m
|
|
51
52
|
}),
|
|
52
|
-
children: [/* @__PURE__ */ n(
|
|
53
|
+
children: [/* @__PURE__ */ n(F, {
|
|
53
54
|
...l,
|
|
54
|
-
ref:
|
|
55
|
-
"aria-describedby":
|
|
56
|
-
"aria-invalid":
|
|
55
|
+
ref: D,
|
|
56
|
+
"aria-describedby": k || void 0,
|
|
57
|
+
"aria-invalid": t,
|
|
57
58
|
className: e.copyInput,
|
|
58
|
-
disabled:
|
|
59
|
-
hideLabel:
|
|
60
|
-
invalid:
|
|
59
|
+
disabled: o,
|
|
60
|
+
hideLabel: C,
|
|
61
|
+
invalid: t,
|
|
61
62
|
label: v,
|
|
62
63
|
onCopy: b,
|
|
63
|
-
onFocus:
|
|
64
|
-
onSelect:
|
|
64
|
+
onFocus: M,
|
|
65
|
+
onSelect: R,
|
|
65
66
|
readOnly: !0,
|
|
66
|
-
value:
|
|
67
|
-
}), /* @__PURE__ */ n(
|
|
68
|
-
ref:
|
|
69
|
-
"aria-live":
|
|
67
|
+
value: N
|
|
68
|
+
}), /* @__PURE__ */ n(O, {
|
|
69
|
+
ref: g,
|
|
70
|
+
"aria-live": E,
|
|
70
71
|
className: e.copyButton,
|
|
71
|
-
|
|
72
|
+
"data-target-id": B,
|
|
73
|
+
disabled: o,
|
|
72
74
|
onClick: b,
|
|
73
75
|
size: "large",
|
|
74
76
|
variant: "secondary",
|
|
75
|
-
children: m ?
|
|
77
|
+
children: m ? T : S
|
|
76
78
|
})]
|
|
77
|
-
}),
|
|
79
|
+
}), t ? /* @__PURE__ */ n(q, {
|
|
78
80
|
className: e.inlineError,
|
|
79
81
|
id: u,
|
|
80
|
-
children:
|
|
81
|
-
}) : s && /* @__PURE__ */ n(
|
|
82
|
+
children: a
|
|
83
|
+
}) : s && /* @__PURE__ */ n(w, {
|
|
82
84
|
as: "p",
|
|
83
85
|
className: e.subtext,
|
|
84
86
|
color: "textOnLightSecondary",
|
|
@@ -88,7 +90,7 @@ import '../../styles/copy-input.css';const U = "_formWrapper_241a0_2", A = "_has
|
|
|
88
90
|
})]
|
|
89
91
|
});
|
|
90
92
|
});
|
|
91
|
-
|
|
93
|
+
Y.displayName = "CopyInput";
|
|
92
94
|
export {
|
|
93
|
-
|
|
95
|
+
Y as CopyInput
|
|
94
96
|
};
|
|
@@ -10,6 +10,8 @@ export type CopyInputProps = Omit<TextInputProps, 'onCopy'> & {
|
|
|
10
10
|
hideLabel?: boolean;
|
|
11
11
|
/** Aria-live for the button */
|
|
12
12
|
ariaLive?: 'off' | 'polite' | 'assertive';
|
|
13
|
+
/** Targeting id attribute for copy button */
|
|
14
|
+
'data-target-id'?: string;
|
|
13
15
|
/** Duration (milliseconds) in which to show the copy success state.
|
|
14
16
|
* @default 3000 [ms] */
|
|
15
17
|
successStateDuration?: number;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/copy-input",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@box/blueprint-web": "^13.3.
|
|
7
|
-
"@box/blueprint-web-assets": "^4.101.
|
|
6
|
+
"@box/blueprint-web": "^13.3.1",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.101.15",
|
|
8
8
|
"react": "^18.0.0",
|
|
9
9
|
"react-dom": "^18.0.0",
|
|
10
10
|
"react-intl": "^6.4.2"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@box/blueprint-web": "^13.3.
|
|
14
|
-
"@box/blueprint-web-assets": "^4.101.
|
|
15
|
-
"@box/storybook-utils": "0.16.
|
|
16
|
-
"@box/eslint-plugin-blueprint": "1.0
|
|
13
|
+
"@box/blueprint-web": "^13.3.1",
|
|
14
|
+
"@box/blueprint-web-assets": "^4.101.15",
|
|
15
|
+
"@box/storybook-utils": "0.16.52",
|
|
16
|
+
"@box/eslint-plugin-blueprint": "1.1.0",
|
|
17
17
|
"react-intl": "^6.4.2"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|