@box/metadata-editor 0.52.9 → 0.52.10

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,18 +1,18 @@
1
1
  import "../styles/metadata-editor-field-wrapper.css";
2
- import S from "clsx";
3
- import { useFormikContext as x } from "formik";
4
- import _ from "lodash/isUndefined";
5
- import { useState as h } from "react";
6
- import { AiSuggestionField as A } from "../esm/lib/components/metadata-editor-fields/components/ai-suggestion-field/ai-suggestion-field.js";
7
- import { UpdateModeFieldWrapper as v } from "../esm/lib/components/metadata-editor-fields/components/update-mode-field-wrapper/update-mode-field-wrapper.js";
8
- import { editorFieldTypes as k } from "../esm/lib/components/metadata-editor-fields/editor-field-types.js";
9
- import { jsx as o, jsxs as F } from "react/jsx-runtime";
10
- const W = "_noAttributesText_vykxc_1", M = "_fieldWrapper_vykxc_5", N = "_hasSuggestion_vykxc_5", T = "_error_vykxc_13", u = {
11
- noAttributesText: W,
12
- fieldWrapper: M,
13
- hasSuggestion: N,
14
- error: T
15
- }, E = ({
2
+ import x from "clsx";
3
+ import { useFormikContext as _ } from "formik";
4
+ import h from "lodash/isUndefined";
5
+ import { useState as A } from "react";
6
+ import { AiSuggestionField as v } from "../esm/lib/components/metadata-editor-fields/components/ai-suggestion-field/ai-suggestion-field.js";
7
+ import { UpdateModeFieldWrapper as k } from "../esm/lib/components/metadata-editor-fields/components/update-mode-field-wrapper/update-mode-field-wrapper.js";
8
+ import { editorFieldTypes as F } from "../esm/lib/components/metadata-editor-fields/editor-field-types.js";
9
+ import { jsx as o, jsxs as W } from "react/jsx-runtime";
10
+ const M = "_noAttributesText_vykxc_1", N = "_fieldWrapper_vykxc_5", T = "_hasSuggestion_vykxc_5", b = "_error_vykxc_13", u = {
11
+ noAttributesText: M,
12
+ fieldWrapper: N,
13
+ hasSuggestion: T,
14
+ error: b
15
+ }, R = ({
16
16
  disableForm: n,
17
17
  portalElement: a,
18
18
  field: e,
@@ -20,11 +20,11 @@ const W = "_noAttributesText_vykxc_1", M = "_fieldWrapper_vykxc_5", N = "_hasSug
20
20
  }) => {
21
21
  const {
22
22
  setFieldValue: d
23
- } = x(), [l, i] = h(!0), r = k[e.type], g = r && !e.hidden, m = !_(e.updateMode), s = `metadata.fields[${p}]`;
23
+ } = _(), [l, i] = A(!0), r = F[e.type], g = r && !e.hidden, m = !h(e.updateMode), s = `metadata.fields[${p}]`;
24
24
  if (!g)
25
25
  return null;
26
26
  if (m)
27
- return /* @__PURE__ */ o(v, {
27
+ return /* @__PURE__ */ o(k, {
28
28
  fieldNamePrefix: s,
29
29
  fieldType: e.type,
30
30
  children: /* @__PURE__ */ o(r, {
@@ -37,31 +37,33 @@ const W = "_noAttributesText_vykxc_1", M = "_fieldWrapper_vykxc_5", N = "_hasSug
37
37
  }, e.key);
38
38
  const {
39
39
  aiSuggestion: t,
40
- value: f
40
+ type: f,
41
+ value: y
41
42
  } = e, c = t && l;
42
- return /* @__PURE__ */ F("div", {
43
+ return /* @__PURE__ */ W("div", {
43
44
  className: u.fieldWrapper,
44
45
  children: [/* @__PURE__ */ o(r, {
45
- className: S(c && u.hasSuggestion),
46
+ className: x(c && u.hasSuggestion),
46
47
  description: e.description,
47
48
  disableForm: n,
48
49
  fieldNamePrefix: `metadata.fields[${p}]`,
49
50
  label: e.displayName,
50
51
  portalElement: a
51
- }), c && /* @__PURE__ */ o(A, {
52
+ }), c && /* @__PURE__ */ o(v, {
52
53
  aiSuggestion: t,
53
54
  onAiSuggestionAppend: () => {
54
- const y = e.type === "multiSelect" ? [f, t].flat() : t;
55
- d(`${s}.value`, y), i(!1);
55
+ const S = e.type === "multiSelect" ? [y, t].flat() : t;
56
+ d(`${s}.value`, S), i(!1);
56
57
  },
57
58
  onAiSuggestionIgnore: () => i(!1),
58
59
  onAiSuggestionReplace: () => {
59
60
  d(`${s}.value`, t), i(!1);
60
- }
61
+ },
62
+ type: f
61
63
  })]
62
64
  }, e.key);
63
65
  };
64
66
  export {
65
- E as M,
67
+ R as M,
66
68
  u as s
67
69
  };
@@ -1,23 +1,24 @@
1
1
  import "../../../../../../styles/ai-suggestion-field.css";
2
2
  import { Text as l, IconButton as c, DropdownMenu as r } from "@box/blueprint-web";
3
- import { Checkmark as d, Ellipsis as u } from "@box/blueprint-web-assets/icons/Fill";
4
- import { useIntl as h, FormattedMessage as n } from "react-intl";
3
+ import { Checkmark as u, Ellipsis as h } from "@box/blueprint-web-assets/icons/Fill";
4
+ import { useIntl as S, FormattedMessage as n } from "react-intl";
5
5
  import t from "./messages.js";
6
- import { formatSuggestionValue as S } from "./utils.js";
6
+ import { formatSuggestionValue as _ } from "./utils.js";
7
7
  import { jsx as e, jsxs as i } from "react/jsx-runtime";
8
- const _ = "_wrapperGradient_1izxt_1", f = "_wrapper_1izxt_1", x = "_buttons_1izxt_18", w = "_selectTrigger_1izxt_22", o = {
9
- wrapperGradient: _,
10
- wrapper: f,
11
- buttons: x,
12
- selectTrigger: w
8
+ const f = "_wrapperGradient_1izxt_1", x = "_wrapper_1izxt_1", w = "_buttons_1izxt_18", b = "_selectTrigger_1izxt_22", o = {
9
+ wrapperGradient: f,
10
+ wrapper: x,
11
+ buttons: w,
12
+ selectTrigger: b
13
13
  };
14
- function M({
14
+ function N({
15
15
  aiSuggestion: p,
16
- onAiSuggestionAppend: a,
16
+ onAiSuggestionAppend: s,
17
17
  onAiSuggestionReplace: g,
18
- onAiSuggestionIgnore: m
18
+ onAiSuggestionIgnore: m,
19
+ type: d
19
20
  }) {
20
- const s = h();
21
+ const a = S();
21
22
  return /* @__PURE__ */ e("div", {
22
23
  className: o.wrapperGradient,
23
24
  children: /* @__PURE__ */ i("div", {
@@ -32,25 +33,28 @@ function M({
32
33
  })
33
34
  }), /* @__PURE__ */ e(l, {
34
35
  as: "p",
35
- children: S(p)
36
+ children: _(p, {
37
+ type: d,
38
+ locale: a.locale
39
+ })
36
40
  })]
37
41
  }), /* @__PURE__ */ i("div", {
38
42
  className: o.buttons,
39
43
  children: [/* @__PURE__ */ e(c, {
40
- "aria-label": s.formatMessage(t.aiSuggestionAppend),
41
- icon: d,
42
- onClick: a,
44
+ "aria-label": a.formatMessage(t.aiSuggestionAppend),
45
+ icon: u,
46
+ onClick: s,
43
47
  size: "x-small"
44
48
  }), /* @__PURE__ */ i(r.Root, {
45
49
  children: [/* @__PURE__ */ e(r.Trigger, {
46
50
  className: o.selectTrigger,
47
51
  children: /* @__PURE__ */ e(c, {
48
- "aria-label": s.formatMessage(t.aiSuggestionOptions),
49
- icon: u
52
+ "aria-label": a.formatMessage(t.aiSuggestionOptions),
53
+ icon: h
50
54
  })
51
55
  }), /* @__PURE__ */ i(r.Content, {
52
56
  children: [/* @__PURE__ */ e(r.Item, {
53
- onSelect: a,
57
+ onSelect: s,
54
58
  children: /* @__PURE__ */ e(n, {
55
59
  ...t.aiSuggestionAppend
56
60
  })
@@ -72,5 +76,5 @@ function M({
72
76
  });
73
77
  }
74
78
  export {
75
- M as AiSuggestionField
79
+ N as AiSuggestionField
76
80
  };
@@ -1,13 +1,15 @@
1
- function n(t) {
2
- if (t == null)
3
- return null;
4
- if (typeof t == "number")
5
- return t.toString();
6
- if (Array.isArray(t))
7
- return t.join(", ");
8
- const r = new Date(t);
9
- return !isNaN(r.getTime()) && r.toISOString() === t ? r.toLocaleDateString() : t;
1
+ import { DateFormatter as i } from "@box/blueprint-web";
2
+ function f(r, {
3
+ type: n = "string",
4
+ locale: e = "en"
5
+ } = {}) {
6
+ if (n === "date" && typeof r == "string") {
7
+ const t = new Date(r);
8
+ if (!isNaN(t.getTime()))
9
+ return new i(e).format(t);
10
+ }
11
+ return r == null ? null : typeof r == "number" ? r.toString() : Array.isArray(r) ? r.join(", ") : r;
10
12
  }
11
13
  export {
12
- n as formatSuggestionValue
14
+ f as formatSuggestionValue
13
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.52.9",
3
+ "version": "0.52.10",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.5",
6
6
  "@box/blueprint-web": "^7.20.0",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@ariakit/react": "0.4.5",
16
- "@box/blueprint-web": "^7.29.1",
16
+ "@box/blueprint-web": "^7.29.2",
17
17
  "@box/blueprint-web-assets": "^4.25.0",
18
18
  "@box/storybook-utils": "^0.6.1",
19
19
  "@testing-library/react": "^15.0.6",
@@ -52,5 +52,5 @@
52
52
  "**/*.css"
53
53
  ],
54
54
  "license": "SEE LICENSE IN LICENSE",
55
- "gitHead": "ec3cefc9f1032f495dfb760af708381f609875d7"
55
+ "gitHead": "0d9819fc38a244c6102693de49d13f092b173e08"
56
56
  }
@@ -1,2 +1,2 @@
1
1
  import { type AiSuggestionFieldProps } from './types';
2
- export declare function AiSuggestionField({ aiSuggestion, onAiSuggestionAppend, onAiSuggestionReplace, onAiSuggestionIgnore, }: AiSuggestionFieldProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function AiSuggestionField({ aiSuggestion, onAiSuggestionAppend, onAiSuggestionReplace, onAiSuggestionIgnore, type, }: AiSuggestionFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { type MetadataFieldValue } from '../../../../types';
1
+ import { type MetadataFieldValue, type MetadataTemplateFieldType } from '../../../../types';
2
2
  export interface AiSuggestionFieldProps {
3
3
  /**
4
4
  * Represents the AI suggestion to be displayed or processed.
@@ -18,4 +18,8 @@ export interface AiSuggestionFieldProps {
18
18
  * This function does not accept any parameters and does not return any value.
19
19
  */
20
20
  onAiSuggestionIgnore: () => void;
21
+ /**
22
+ * Type of the metadata field to display the suggestion for.
23
+ */
24
+ type: MetadataTemplateFieldType;
21
25
  }
@@ -1,3 +1,6 @@
1
1
  import { type ReactElement } from 'react';
2
- import { type MetadataFieldValue } from '../../../../types';
3
- export declare function formatSuggestionValue(value: MetadataFieldValue): null | ReactElement | string;
2
+ import { type MetadataFieldValue, type MetadataTemplateFieldType } from '../../../../types';
3
+ export declare function formatSuggestionValue(value: MetadataFieldValue, { type, locale }?: {
4
+ type?: MetadataTemplateFieldType;
5
+ locale?: string;
6
+ }): null | ReactElement | string;