@box/metadata-editor 0.120.19 → 0.120.21

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.
@@ -4,53 +4,52 @@ import { TEMPLATE_CUSTOM_PROPERTIES as S } from "../esm/lib/constants.js";
4
4
  import { MetadataInstanceFormFooter as w } from "../esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/metadata-instance-form-footer.js";
5
5
  import { MetadataInstanceFormHeader as M } from "../esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
6
6
  import { jsx as t, jsxs as b } from "react/jsx-runtime";
7
- import '../styles/metadata-instance-form-card-wrapper.css';const v = "_metadataInstanceForm_1e6l2_1", x = "_wrapperGradient_1e6l2_7", D = "_suggestionsFetching_1e6l2_12", I = "_metadataInstanceFormContent_1e6l2_18", L = "_showOverlay_1e6l2_25", n = {
7
+ import '../styles/metadata-instance-form-card-wrapper.css';const v = "_metadataInstanceForm_1e6l2_1", x = "_wrapperGradient_1e6l2_7", D = "_suggestionsFetching_1e6l2_12", I = "_metadataInstanceFormContent_1e6l2_18", L = "_showOverlay_1e6l2_25", s = {
8
8
  metadataInstanceForm: v,
9
9
  wrapperGradient: x,
10
10
  suggestionsFetching: D,
11
11
  metadataInstanceFormContent: I,
12
12
  showOverlay: L
13
- }, B = (o) => {
13
+ }, B = (n) => {
14
14
  const {
15
- areAiSuggestionsAvailable: r,
16
- children: i,
17
- className: g,
18
- formRef: m,
19
- isAdvancedExtractAgentEnabled: l = !1,
20
- isAiSuggestionsFeatureEnabled: d,
21
- isBetaLanguageEnabled: c,
22
- isLargeFile: F = !1,
23
- isDeleteButtonDisabled: u,
24
- suggestions: _,
15
+ areAiSuggestionsAvailable: o,
16
+ children: r,
17
+ className: i,
18
+ formRef: g,
19
+ isAdvancedExtractAgentEnabled: m = !1,
20
+ isAiSuggestionsFeatureEnabled: l,
21
+ isBetaLanguageEnabled: d,
22
+ isLargeFile: c = !1,
23
+ isDeleteButtonDisabled: F,
24
+ suggestions: u,
25
25
  isFetchingSuggestions: e,
26
- isFormDirty: s = !1,
26
+ isFormDirty: _ = !1,
27
27
  selectedTemplateInstance: a,
28
28
  getAiSuggestions: p,
29
29
  handleCancel: h,
30
30
  handleDelete: f
31
- } = o, A = (a == null ? void 0 : a.templateKey) === S, C = !!_[a == null ? void 0 : a.templateKey];
31
+ } = n, A = (a == null ? void 0 : a.templateKey) === S, C = !!u[a == null ? void 0 : a.templateKey];
32
32
  return /* @__PURE__ */ t("div", {
33
- className: e && n.wrapperGradient,
33
+ className: e && s.wrapperGradient,
34
34
  children: /* @__PURE__ */ b(E, {
35
- ref: m,
36
- className: y(g, {
37
- [n.suggestionsFetching]: e
35
+ ref: g,
36
+ className: y(i, {
37
+ [s.suggestionsFetching]: e
38
38
  }),
39
39
  children: [/* @__PURE__ */ t(M, {
40
- areAiSuggestionsAvailable: r,
40
+ areAiSuggestionsAvailable: o,
41
41
  hasSuggestions: C,
42
- isAdvancedExtractAgentEnabled: l,
43
- isAiSuggestionsFeatureEnabled: d && !A,
44
- isBetaLanguageEnabled: c,
45
- isLargeFile: F,
42
+ isAdvancedExtractAgentEnabled: m,
43
+ isAiSuggestionsFeatureEnabled: l && !A,
44
+ isBetaLanguageEnabled: d,
45
+ isLargeFile: c,
46
46
  isLoading: e,
47
47
  onAutofill: p,
48
48
  templateName: a == null ? void 0 : a.displayName
49
- }), a && i, /* @__PURE__ */ t(w, {
50
- isDeleteButtonDisabled: u,
51
- isFormDirty: s,
49
+ }), a && r, /* @__PURE__ */ t(w, {
50
+ isDeleteButtonDisabled: F,
52
51
  isLoading: e,
53
- onCancel: () => h(s),
52
+ onCancel: () => h(_),
54
53
  onDelete: f
55
54
  })]
56
55
  })
@@ -58,5 +57,5 @@ import '../styles/metadata-instance-form-card-wrapper.css';const v = "_metadataI
58
57
  };
59
58
  export {
60
59
  B as M,
61
- n as s
60
+ s
62
61
  };
@@ -1,47 +1,42 @@
1
1
  import h from "lodash/isEmpty";
2
- import l from "lodash/isArray";
3
- import { TEMPLATE_CUSTOM_PROPERTIES as O } from "../esm/lib/constants.js";
4
- import { defaultMetadataValueMap as M } from "../esm/lib/defaults.js";
2
+ import O from "lodash/isArray";
3
+ import { TEMPLATE_CUSTOM_PROPERTIES as f } from "../esm/lib/constants.js";
5
4
  const n = {
6
5
  ADD: "add",
7
6
  REMOVE: "remove",
8
7
  REPLACE: "replace",
9
8
  TEST: "test"
10
- }, o = (a) => a.value === void 0 || a.value === null || a.value === "" || l(a.value) && h(a.value), P = (a, e) => {
11
- const p = [], c = a.metadata.fields, r = e.templateKey === O, y = new Map(e.fields.map((t) => [t.key, t])), E = new Map(c.map((t) => [t.key, t]));
9
+ }, p = (e) => e.value === void 0 || e.value === null || e.value === "" || O(e.value) && h(e.value), S = (e, a) => {
10
+ const o = [], c = e.metadata.fields, r = a.templateKey === f, E = new Map(a.fields.map((t) => [t.key, t])), m = new Map(c.map((t) => [t.key, t]));
12
11
  return c.forEach((t) => {
13
- const s = y.get(t.key);
14
- s ? JSON.stringify(t) === JSON.stringify(s) || (!r && o(s) && !o(t) ? p.push(v(t.key, u(t))) : (
15
- // template instance
16
- (!r && t.value !== s.value && s.value !== null && !o(t) || // custom instance
17
- r && t.value !== s.value) && (p.push(m(s.key, u(s))), p.push(k(t.key, u(t))))
18
- )) : p.push(v(t.key, t.value));
19
- }), e.fields.forEach((t) => {
20
12
  const s = E.get(t.key);
21
- (!s || !r && o(s) && !o(t)) && (p.push(m(t.key, u(t))), p.push(f(t.key)));
22
- }), p;
23
- }, u = (a) => a.type === "float" ? Number(a.value) : a.type === "taxonomy" ? a.value.map((e) => e.value) : a.value, g = (a) => a.map((e) => ({
24
- ...e,
25
- value: e.value ?? M[e.type]
26
- })), m = (a, e) => ({
13
+ s ? JSON.stringify(t) === JSON.stringify(s) || (!r && p(s) && !p(t) ? o.push(v(t.key, u(t))) : (
14
+ // template instance
15
+ (!r && t.value !== s.value && s.value !== null && !p(t) || // custom instance
16
+ r && t.value !== s.value) && (o.push(y(s.key, u(s))), o.push(M(t.key, u(t))))
17
+ )) : o.push(v(t.key, t.value));
18
+ }), a.fields.forEach((t) => {
19
+ const s = m.get(t.key);
20
+ (!s || !r && p(s) && !p(t)) && (o.push(y(t.key, u(t))), o.push(k(t.key)));
21
+ }), o;
22
+ }, u = (e) => e.type === "float" ? Number(e.value) : e.type === "taxonomy" ? e.value.map((a) => a.value) : e.value, y = (e, a) => ({
27
23
  op: n.TEST,
28
- path: `/${a}`,
29
- value: e
30
- }), v = (a, e) => ({
24
+ path: `/${e}`,
25
+ value: a
26
+ }), v = (e, a) => ({
31
27
  op: n.ADD,
32
- path: `/${a}`,
33
- value: e
34
- }), f = (a) => ({
28
+ path: `/${e}`,
29
+ value: a
30
+ }), k = (e) => ({
35
31
  op: n.REMOVE,
36
- path: `/${a}`
37
- }), k = (a, e) => ({
32
+ path: `/${e}`
33
+ }), M = (e, a) => ({
38
34
  op: n.REPLACE,
39
- path: `/${a}`,
40
- value: e
35
+ path: `/${e}`,
36
+ value: a
41
37
  });
42
38
  export {
43
39
  n as J,
44
- P as c,
45
- g as e,
40
+ S as c,
46
41
  u as g
47
42
  };
@@ -10,20 +10,20 @@ import { TEMPLATE_CUSTOM_PROPERTIES as I } from "../../../../constants.js";
10
10
  import { useAutofill as T } from "../../../../utils/autofill-context.js";
11
11
  import { TemplateInstance as oo } from "../../../metadata-editor-fields/metadata-editor-fields.js";
12
12
  import { MetadataEmptyState as ro } from "../../../metadata-empty-state/metadata-empty-state.js";
13
- import { AutofillOverlay as io } from "../autofill-overlay/autofill-overlay.js";
14
- import { CustomInstance as to } from "../custom-instance/custom-instance.js";
15
- import { e as ao, c as no } from "../../../../../../chunks/utils.js";
16
- import { s as u, M as so } from "../../../../../../chunks/metadata-instance-form-card-wrapper.js";
17
- import { jsx as t, jsxs as D } from "react/jsx-runtime";
13
+ import { AutofillOverlay as to } from "../autofill-overlay/autofill-overlay.js";
14
+ import { CustomInstance as io } from "../custom-instance/custom-instance.js";
15
+ import { c as ao } from "../../../../../../chunks/utils.js";
16
+ import { s as u, M as no } from "../../../../../../chunks/metadata-instance-form-card-wrapper.js";
17
+ import { jsx as i, jsxs as D } from "react/jsx-runtime";
18
18
  import { UnsavedChangesModal as eo } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
19
- const mo = ({
20
- dirty: e,
19
+ const so = ({
20
+ dirty: s,
21
21
  onChange: m,
22
22
  values: r
23
23
  }) => {
24
24
  const n = O(r);
25
- return e && !Y(n.current.metadata.fields, r.metadata.fields) && (n.current = r, m(r)), null;
26
- }, vo = (e) => {
25
+ return s && !Y(n.current.metadata.fields, r.metadata.fields) && (n.current = r, m(r)), null;
26
+ }, Ao = (s) => {
27
27
  const {
28
28
  areAiSuggestionsAvailable: m,
29
29
  customRef: r,
@@ -44,71 +44,70 @@ const mo = ({
44
44
  onDiscardUnsavedChanges: U,
45
45
  onSubmit: B,
46
46
  setIsUnsavedChangesModalOpen: p,
47
- taxonomyOptionsFetcher: h
48
- } = e, V = k ?? so, [W, C] = S(!1), {
47
+ taxonomyOptionsFetcher: c
48
+ } = s, w = k ?? no, [K, h] = S(!1), {
49
49
  isFetchingSuggestions: a,
50
- isLongLoading: E,
51
- getAiSuggestions: w,
52
- clearState: c,
53
- suggestions: K
50
+ isLongLoading: C,
51
+ getAiSuggestions: V,
52
+ clearState: E,
53
+ suggestions: W
54
54
  } = T();
55
55
  y(() => () => {
56
- c();
57
- }, [c, o == null ? void 0 : o.id]);
58
- const F = (o == null ? void 0 : o.templateKey) === I, j = async (i) => {
59
- await B(i, no(i, o));
60
- }, _ = (i) => {
61
- i ? p(!0) : N();
56
+ E();
57
+ }, [E, o == null ? void 0 : o.id]);
58
+ const F = (o == null ? void 0 : o.templateKey) === I, j = async (t) => {
59
+ await B(t, ao(t, o));
60
+ }, _ = (t) => {
61
+ t ? p(!0) : N();
62
62
  }, $ = () => {
63
- C(!0);
63
+ h(!0);
64
64
  }, q = {
65
65
  metadata: {
66
- ...o,
67
- fields: ao((o == null ? void 0 : o.fields) ?? [])
66
+ ...o
68
67
  }
69
68
  }, M = O(null), [b, J] = S(null);
70
69
  y(() => {
71
70
  J(r ?? M.current);
72
71
  }, [r, o == null ? void 0 : o.templateKey, o == null ? void 0 : o.scope]);
73
72
  const z = Z(() => {
74
- const i = (o == null ? void 0 : o.fields.length) === 0;
73
+ const t = (o == null ? void 0 : o.fields.length) === 0;
75
74
  if (F)
76
- return /* @__PURE__ */ t(to, {
75
+ return /* @__PURE__ */ i(io, {
77
76
  isLoading: a
78
77
  });
79
- if (i)
80
- return /* @__PURE__ */ t(ro, {
78
+ if (t)
79
+ return /* @__PURE__ */ i(ro, {
81
80
  isBoxAiSuggestionsFeatureEnabled: f,
82
81
  level: "instance"
83
82
  });
84
- const s = !!(a || l);
83
+ const e = !!(a || l);
85
84
  return /* @__PURE__ */ D("div", {
86
- className: H(u.metadataInstanceFormContent, s && u.showOverlay),
87
- children: [/* @__PURE__ */ t(io, {
85
+ className: H(u.metadataInstanceFormContent, e && u.showOverlay),
86
+ children: [/* @__PURE__ */ i(to, {
88
87
  errorCode: l,
89
88
  isFetchingSuggestions: a,
90
- isLongLoading: E
91
- }), /* @__PURE__ */ t(oo, {
89
+ isLongLoading: C
90
+ }), /* @__PURE__ */ i(oo, {
92
91
  disableForm: a,
93
92
  isMultilevelTaxonomyFieldEnabled: d,
94
93
  portalElement: r ?? b,
95
- taxonomyOptionsFetcher: h
94
+ taxonomyOptionsFetcher: c
96
95
  })]
97
96
  });
98
- }, [o == null ? void 0 : o.fields.length, F, a, E, r, b, h, f, d, l]);
99
- return /* @__PURE__ */ t(Q, {
97
+ }, [o == null ? void 0 : o.fields.length, F, a, C, r, b, c, f, d, l]);
98
+ return /* @__PURE__ */ i(Q, {
100
99
  initialValues: q,
101
100
  onSubmit: j,
102
101
  children: ({
103
- values: i,
104
- dirty: s
102
+ values: t,
103
+ dirty: e
105
104
  }) => /* @__PURE__ */ D(X, {
106
- children: [/* @__PURE__ */ t(V, {
105
+ children: [/* @__PURE__ */ i(w, {
107
106
  areAiSuggestionsAvailable: m,
108
107
  className: u.metadataInstanceForm,
109
108
  formRef: M,
110
- formValues: i,
111
- getAiSuggestions: w,
109
+ formValues: t,
110
+ getAiSuggestions: V,
112
111
  handleCancel: _,
113
112
  handleDelete: $,
114
113
  isAdvancedExtractAgentEnabled: x,
@@ -116,29 +115,29 @@ const mo = ({
116
115
  isBetaLanguageEnabled: A,
117
116
  isDeleteButtonDisabled: v,
118
117
  isFetchingSuggestions: a,
119
- isFormDirty: s,
118
+ isFormDirty: e,
120
119
  isLargeFile: n,
121
120
  selectedTemplateInstance: o,
122
- suggestions: K,
121
+ suggestions: W,
123
122
  children: o && z
124
- }), g && /* @__PURE__ */ t(mo, {
125
- dirty: s,
123
+ }), g && /* @__PURE__ */ i(so, {
124
+ dirty: e,
126
125
  onChange: g,
127
- values: i
128
- }), /* @__PURE__ */ t(eo, {
126
+ values: t
127
+ }), /* @__PURE__ */ i(eo, {
129
128
  onBackToEdit: () => p(!1),
130
129
  onDiscardChanges: U,
131
130
  open: R
132
- }), /* @__PURE__ */ t(G, {
131
+ }), /* @__PURE__ */ i(G, {
133
132
  isCheckboxEnabled: L,
134
133
  onConfirm: () => P(o),
135
- onDismiss: () => C(!1),
136
- open: W,
134
+ onDismiss: () => h(!1),
135
+ open: K,
137
136
  templateName: o == null ? void 0 : o.displayName
138
137
  })]
139
138
  })
140
139
  }, `${o == null ? void 0 : o.scope}.${o == null ? void 0 : o.templateKey}`);
141
140
  };
142
141
  export {
143
- vo as MetadataInstanceForm
142
+ Ao as MetadataInstanceForm
144
143
  };
@@ -1,10 +1,8 @@
1
1
  import "lodash/isEmpty";
2
2
  import "lodash/isArray";
3
- import { c as m, e as l, g as p } from "../../../../../../chunks/utils.js";
3
+ import { c as m, g as i } from "../../../../../../chunks/utils.js";
4
4
  import "../../../../constants.js";
5
- import "../../../../defaults.js";
6
5
  export {
7
6
  m as createJSONPatch,
8
- l as enrichFieldsWithInitialValues,
9
- p as getFormatedFieldValue
7
+ i as getFormatedFieldValue
10
8
  };
@@ -1,30 +1,29 @@
1
- import { TextButton as g, Button as r } from "@box/blueprint-web";
2
- import { useFormikContext as B } from "formik";
3
- import { useIntl as F } from "react-intl";
1
+ import { TextButton as b, Button as r } from "@box/blueprint-web";
2
+ import { useFormikContext as g } from "formik";
3
+ import { useIntl as B } from "react-intl";
4
4
  import o from "./messages.js";
5
5
  import { jsx as e, jsxs as i } from "react/jsx-runtime";
6
- import '../../../../../../styles/metadata-instance-form-footer.css';const f = "_metadataInstanceFormFooter_sqpiw_1", p = "_buttonsContainer_sqpiw_7", _ = "_buttons_sqpiw_7", n = {
7
- metadataInstanceFormFooter: f,
8
- buttonsContainer: p,
9
- buttons: _
10
- }, M = ({
6
+ import '../../../../../../styles/metadata-instance-form-footer.css';const F = "_metadataInstanceFormFooter_sqpiw_1", f = "_buttonsContainer_sqpiw_7", p = "_buttons_sqpiw_7", n = {
7
+ metadataInstanceFormFooter: F,
8
+ buttonsContainer: f,
9
+ buttons: p
10
+ }, I = ({
11
11
  isDeleteButtonDisabled: d,
12
- isFormDirty: l = !1,
13
12
  isLoading: m,
14
13
  onCancel: c,
15
- onDelete: u
14
+ onDelete: l
16
15
  }) => {
17
- const t = F(), {
16
+ const t = B(), {
18
17
  isSubmitting: s,
19
- submitForm: b
20
- } = B(), a = m || s;
18
+ submitForm: u
19
+ } = g(), a = m || s;
21
20
  return /* @__PURE__ */ e("div", {
22
21
  className: n.metadataInstanceFormFooter,
23
22
  children: /* @__PURE__ */ i("div", {
24
23
  className: n.buttonsContainer,
25
- children: [/* @__PURE__ */ e(g, {
24
+ children: [/* @__PURE__ */ e(b, {
26
25
  disabled: a || d,
27
- onClick: u,
26
+ onClick: l,
28
27
  "data-target-id": "TextButton-deleteButton",
29
28
  children: t.formatMessage(o.deleteButton)
30
29
  }), /* @__PURE__ */ i("div", {
@@ -37,10 +36,10 @@ import '../../../../../../styles/metadata-instance-form-footer.css';const f = "_
37
36
  "data-target-id": "Button-cancelButton",
38
37
  children: t.formatMessage(o.cancelButton)
39
38
  }), /* @__PURE__ */ e(r, {
40
- disabled: a || !l,
39
+ disabled: a,
41
40
  loading: s,
42
41
  loadingAriaLabel: t.formatMessage(o.loadingAriaLabel),
43
- onClick: b,
42
+ onClick: u,
44
43
  size: "large",
45
44
  "data-target-id": "Button-saveButton",
46
45
  children: t.formatMessage(o.saveButton)
@@ -50,5 +49,5 @@ import '../../../../../../styles/metadata-instance-form-footer.css';const f = "_
50
49
  });
51
50
  };
52
51
  export {
53
- M as MetadataInstanceFormFooter
52
+ I as MetadataInstanceFormFooter
54
53
  };
@@ -11,4 +11,3 @@ import { JSONPatchOperations } from './types';
11
11
  */
12
12
  export declare const createJSONPatch: (formValues: FormValues, originalData: MetadataTemplateInstance) => JSONPatchOperations;
13
13
  export declare const getFormatedFieldValue: (field: MetadataTemplateField) => MetadataFormFieldValue;
14
- export declare const enrichFieldsWithInitialValues: (fields: MetadataTemplateField[]) => MetadataTemplateField[];
@@ -1,2 +1,2 @@
1
1
  import { MetadataInstanceFormFooterProps } from './types';
2
- export declare const MetadataInstanceFormFooter: ({ isDeleteButtonDisabled, isFormDirty, isLoading, onCancel, onDelete, }: MetadataInstanceFormFooterProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MetadataInstanceFormFooter: ({ isDeleteButtonDisabled, isLoading, onCancel, onDelete, }: MetadataInstanceFormFooterProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,5 @@
1
1
  export type MetadataInstanceFormFooterProps = {
2
2
  isDeleteButtonDisabled: boolean;
3
- isFormDirty?: boolean;
4
3
  isLoading: boolean;
5
4
  onCancel: () => void;
6
5
  onDelete: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.120.19",
3
+ "version": "0.120.21",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
6
  "@box/box-ai-agent-selector": "^0.41.7",
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@ariakit/react": "0.4.15",
18
- "@box/box-ai-agent-selector": "^0.48.3",
18
+ "@box/box-ai-agent-selector": "^0.48.4",
19
19
  "@box/babel-plugin-target-attributes": "1.3.0",
20
- "@box/blueprint-web": "^12.36.0",
20
+ "@box/blueprint-web": "^12.37.0",
21
21
  "@box/blueprint-web-assets": "^4.60.0",
22
22
  "@box/storybook-utils": "^0.13.14",
23
23
  "@testing-library/react": "^15.0.6",