@box/content-field 1.42.27 → 1.42.28

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.
@@ -9,67 +9,69 @@ import g from "clsx";
9
9
  import { forwardRef as _, useRef as v } from "react";
10
10
  import { useIntl as y } from "react-intl";
11
11
  import { jsx as b, jsxs as x } from "react/jsx-runtime";
12
- var S = (e) => e?.type === "variable", C = ({ icon: a, variant: o, isVariableWithTitle: s }) => a ? /* @__PURE__ */ b(t, { icon: a }) : b(s ? o === "file" ? e : r : o === "file" ? n : i, {}), w = /* @__PURE__ */ _(({ icon: e, placeholder: t, onClick: n, onClear: r, title: i, error: _, disabled: w = !1, variant: T = "folder", ...E }, D) => {
13
- let O = y(), { enableModernizedComponents: k } = d(), { titleValue: A } = i ?? {}, j = v(null), M = A ?? t, { TooltipComponent: N, tooltipProps: P } = o(j, i), F = (e) => {
14
- j.current?.focus(), r(e);
15
- }, I = f("inline-error-"), L = S(i) && !!A, R = _ ? "error" : "standard";
12
+ var S = (e) => e?.type === "variable", C = ({ icon: a, variant: o, isVariableWithTitle: s }) => a ? /* @__PURE__ */ b(t, { icon: a }) : b(s ? o === "file" ? e : r : o === "file" ? n : i, {}), w = /* @__PURE__ */ _(({ icon: e, placeholder: t, onClick: n, onClear: r, title: i, error: _, clearButtonRef: w, disabled: T = !1, variant: E = "folder", triggerRef: D, ...O }, k) => {
13
+ let A = y(), { enableModernizedComponents: j } = d(), { titleValue: M } = i ?? {}, N = v(null), P = M ?? t, { TooltipComponent: F, tooltipProps: I } = o(N, i), L = (e) => {
14
+ N.current?.focus(), r(e);
15
+ }, R = f("inline-error-"), z = S(i) && !!M, B = _ ? "error" : "standard";
16
16
  return /* @__PURE__ */ x("div", {
17
- ref: D,
17
+ ref: k,
18
18
  className: a.contentFieldWrapper,
19
- "data-modern": k,
19
+ "data-modern": j,
20
20
  children: [/* @__PURE__ */ x("div", {
21
21
  className: a.contentField,
22
- children: [/* @__PURE__ */ b(N, {
23
- ...P,
24
- variant: R,
22
+ children: [/* @__PURE__ */ b(F, {
23
+ ...I,
24
+ variant: B,
25
25
  children: /* @__PURE__ */ x(c, {
26
- "aria-describedby": I,
26
+ ref: D,
27
+ "aria-describedby": R,
27
28
  className: g(a.contentButton, {
28
29
  [a.hasSelection]: i,
29
30
  [a.error]: !!_,
30
- [a.disabled]: w
31
+ [a.disabled]: T
31
32
  }),
32
- disabled: w,
33
+ disabled: T,
33
34
  onClick: n,
34
35
  type: "button",
35
- ...E,
36
+ ...O,
36
37
  children: [/* @__PURE__ */ b(C, {
37
38
  icon: e,
38
- isVariableWithTitle: L,
39
- variant: T
39
+ isVariableWithTitle: z,
40
+ variant: E
40
41
  }), /* @__PURE__ */ b("div", {
41
42
  className: a.labelWrapper,
42
43
  children: /* @__PURE__ */ b(u, {
43
- ref: j,
44
+ ref: N,
44
45
  as: "span",
45
46
  className: g(a.contentLabel, {
46
- [a.variable]: L,
47
- [a.variableError]: L && _
47
+ [a.variable]: z,
48
+ [a.variableError]: z && _
48
49
  }),
49
- variant: L ? "bodyDefaultBold" : "bodyDefault",
50
- children: M
50
+ variant: z ? "bodyDefaultBold" : "bodyDefault",
51
+ children: P
51
52
  })
52
53
  })]
53
54
  })
54
- }), A && /* @__PURE__ */ b(c, {
55
- "aria-label": O.formatMessage(s.clearButtonLabel),
55
+ }), M && /* @__PURE__ */ b(c, {
56
+ ref: w,
57
+ "aria-label": A.formatMessage(s.clearButtonLabel),
56
58
  className: g(a.clearButton, {
57
- [a.hasSelection]: A,
59
+ [a.hasSelection]: M,
58
60
  [a.error]: !!_,
59
- [a.disabled]: w
61
+ [a.disabled]: T
60
62
  }),
61
- disabled: w,
62
- onClick: F,
63
+ disabled: T,
64
+ onClick: L,
63
65
  type: "button",
64
66
  children: /* @__PURE__ */ b(p, {
65
- height: k ? h : m,
67
+ height: j ? h : m,
66
68
  role: "presentation",
67
- width: k ? h : m
69
+ width: j ? h : m
68
70
  })
69
71
  })]
70
72
  }), /* @__PURE__ */ b(l, {
71
73
  className: a.inlineError,
72
- id: I,
74
+ id: R,
73
75
  children: _
74
76
  })]
75
77
  });
@@ -1,4 +1,4 @@
1
- import { ReactNode, MouseEvent, SVGProps, ComponentType } from 'react';
1
+ import { ComponentType, MouseEvent, ReactNode, Ref, SVGProps } from 'react';
2
2
  /** Configuration for a content field with a fixed display title */
3
3
  export interface ContentFieldConstantTitle {
4
4
  /** The text to display as the title */
@@ -25,6 +25,8 @@ export interface ContentFieldProps {
25
25
  error?: ReactNode;
26
26
  onClear: (e: MouseEvent<HTMLButtonElement>) => void;
27
27
  onClick: (e: MouseEvent<HTMLButtonElement>) => void;
28
+ clearButtonRef?: Ref<HTMLButtonElement>;
28
29
  disabled?: boolean;
29
30
  variant?: 'folder' | 'file';
31
+ triggerRef?: Ref<HTMLButtonElement>;
30
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/content-field",
3
- "version": "1.42.27",
3
+ "version": "1.42.28",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@ariakit/react": "^0.4.21",