@box/copy-input 1.37.1 → 1.39.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.
|
@@ -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
|
};
|
package/dist/i18n/en-x-pseudo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
"groupSharedFeatures.copyButton.copyButtonCopiedLabel": "⟦萬
|
|
3
|
-
"groupSharedFeatures.copyButton.copyButtonLabel": "⟦萬
|
|
2
|
+
"groupSharedFeatures.copyButton.copyButtonCopiedLabel": "⟦萬 ĊσΡĭéď 國⟧",
|
|
3
|
+
"groupSharedFeatures.copyButton.copyButtonLabel": "⟦萬 ČõΡý 國⟧"
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# Label for a call-to-action button in its active state. Button was clicked and text input's contents was copied the user's clipboard.
|
|
2
|
-
groupSharedFeatures.copyButton.copyButtonCopiedLabel = ⟦萬
|
|
2
|
+
groupSharedFeatures.copyButton.copyButtonCopiedLabel = ⟦萬 ĊσΡĭéď 國⟧
|
|
3
3
|
# Label for a call-to-action button in its default state. Clicking the button copies text input's contents to the user's clipboard.
|
|
4
|
-
groupSharedFeatures.copyButton.copyButtonLabel = ⟦萬
|
|
4
|
+
groupSharedFeatures.copyButton.copyButtonLabel = ⟦萬 ČõΡý 國⟧
|
|
@@ -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;
|