@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 k, Button as F, InlineError as O, Text as q } from "@box/blueprint-web";
2
- import i from "clsx";
3
- import { forwardRef as w, useCallback as f } from "react";
4
- import { useIntl as z } from "react-intl";
5
- import { messages as h } from "./messages.js";
6
- import { useClipboardCopy as H } from "./utils.js";
7
- import { jsxs as I, jsx as n } from "react/jsx-runtime";
8
- import '../../styles/copy-input.css';const U = "_formWrapper_241a0_2", A = "_hasError_241a0_7", G = "_copyInputWrapper_241a0_17", J = "_copied_241a0_21", K = "_copyButton_241a0_38", P = "_copyInput_241a0_17", Q = "_subtext_241a0_70", V = "_inlineError_241a0_71", e = {
9
- formWrapper: U,
10
- hasError: A,
11
- copyInputWrapper: G,
12
- copied: J,
13
- copyButton: K,
14
- copyInput: P,
15
- subtext: Q,
16
- inlineError: V
17
- }, X = /* @__PURE__ */ w((x, E) => {
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
- id: Y,
20
- value: g,
21
- subtext: p,
22
- error: o,
23
- disabled: a,
24
- ariaLive: B,
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
- hideLabel: W,
27
+ subtext: p,
28
+ successStateDuration: W,
29
+ value: N,
29
30
  ...l
30
- } = x, d = z(), N = d.formatMessage(h.copyButtonLabel), S = d.formatMessage(h.copyButtonCopiedLabel), u = _("inline-error-"), y = _("subtext-"), {
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: T
34
- } = H(a, L, C), D = f((t) => {
35
- t.target.select();
36
- }, []), M = f((t) => {
37
- t.target instanceof HTMLInputElement && t.target.setSelectionRange(0, t.target.value.length);
38
- }, []), r = !!o && !a, s = !o && !!p, R = r || s;
39
- let c = "";
40
- r ? c = u : s && (c = y);
41
- const j = i(l["aria-describedby"], {
42
- [c]: R
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__ */ I("div", {
45
- className: i(e.formWrapper, {
46
- [e.hasError]: o
45
+ return /* @__PURE__ */ h("div", {
46
+ className: c(e.formWrapper, {
47
+ [e.hasError]: a
47
48
  }),
48
- children: [/* @__PURE__ */ I("div", {
49
- className: i(e.copyInputWrapper, {
49
+ children: [/* @__PURE__ */ h("div", {
50
+ className: c(e.copyInputWrapper, {
50
51
  [e.copied]: m
51
52
  }),
52
- children: [/* @__PURE__ */ n(k, {
53
+ children: [/* @__PURE__ */ n(F, {
53
54
  ...l,
54
- ref: T,
55
- "aria-describedby": j || void 0,
56
- "aria-invalid": r,
55
+ ref: D,
56
+ "aria-describedby": k || void 0,
57
+ "aria-invalid": t,
57
58
  className: e.copyInput,
58
- disabled: a,
59
- hideLabel: W,
60
- invalid: r,
59
+ disabled: o,
60
+ hideLabel: C,
61
+ invalid: t,
61
62
  label: v,
62
63
  onCopy: b,
63
- onFocus: D,
64
- onSelect: M,
64
+ onFocus: M,
65
+ onSelect: R,
65
66
  readOnly: !0,
66
- value: g
67
- }), /* @__PURE__ */ n(F, {
68
- ref: E,
69
- "aria-live": B,
67
+ value: N
68
+ }), /* @__PURE__ */ n(O, {
69
+ ref: g,
70
+ "aria-live": E,
70
71
  className: e.copyButton,
71
- disabled: a,
72
+ "data-target-id": B,
73
+ disabled: o,
72
74
  onClick: b,
73
75
  size: "large",
74
76
  variant: "secondary",
75
- children: m ? S : N
77
+ children: m ? T : S
76
78
  })]
77
- }), r ? /* @__PURE__ */ n(O, {
79
+ }), t ? /* @__PURE__ */ n(q, {
78
80
  className: e.inlineError,
79
81
  id: u,
80
- children: o
81
- }) : s && /* @__PURE__ */ n(q, {
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
- X.displayName = "CopyInput";
93
+ Y.displayName = "CopyInput";
92
94
  export {
93
- X as CopyInput
95
+ Y as CopyInput
94
96
  };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/copy-input",
3
- "version": "1.37.1",
3
+ "version": "1.39.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^13.3.0",