@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.
@@ -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
  };
@@ -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.38.0",
3
+ "version": "1.39.1",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
- "@box/blueprint-web": "^13.3.0",
7
- "@box/blueprint-web-assets": "^4.101.14",
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.0",
14
- "@box/blueprint-web-assets": "^4.101.14",
15
- "@box/storybook-utils": "0.16.51",
16
- "@box/eslint-plugin-blueprint": "1.0.5",
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": {