@box/metadata-editor 0.125.1 → 0.127.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,6 +1,9 @@
1
1
  let n = /* @__PURE__ */ function(e) {
2
2
  return e.ClearAndReplace = "clearAndReplace", e.RemoveEntered = "removeEntered", e.ReplaceEntered = "replaceEntered", e.Append = "append", e;
3
+ }({}), r = /* @__PURE__ */ function(e) {
4
+ return e.Initial = "INITIAL", e.Pending = "PENDING", e.Applied = "APPLIED", e;
3
5
  }({});
4
6
  export {
7
+ r as A,
5
8
  n as U
6
9
  };
package/dist/esm/index.js CHANGED
@@ -3,48 +3,49 @@ import { MULTI_VALUE_DEFAULT_OPTION as r, MULTI_VALUE_DEFAULT_TAXONOMY_OPTION as
3
3
  import { MetadataEmptyState as f } from "./lib/components/metadata-empty-state/metadata-empty-state.js";
4
4
  import { defaultInitialValues as x, defaultMetadataValueMap as i } from "./lib/defaults.js";
5
5
  import { MetadataEditor as M } from "./lib/metadata-editor.js";
6
- import { U as A } from "../chunks/types.js";
7
- import { withApiWrapper as U } from "./lib/utils/api-wrapper.js";
8
- import { AutofillContext as T, AutofillContextProvider as _, TIMEOUT_10_SECONDS as E, useAutofill as L } from "./lib/utils/autofill-context.js";
9
- import { AddMetadataTemplateDropdown as c } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
10
- import { ComboboxWithApiPagination as D } from "./lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js";
11
- import { FilterInstancesDropdown as N } from "./lib/components/filter-instances-dropdown/filter-instances-dropdown.js";
6
+ import { A, U as I } from "../chunks/types.js";
7
+ import { withApiWrapper as u } from "./lib/utils/api-wrapper.js";
8
+ import { AutofillContext as _, AutofillContextProvider as E, TIMEOUT_10_SECONDS as L, useAutofill as O } from "./lib/utils/autofill-context.js";
9
+ import { AddMetadataTemplateDropdown as F } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
10
+ import { ComboboxWithApiPagination as C } from "./lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js";
11
+ import { FilterInstancesDropdown as S } from "./lib/components/filter-instances-dropdown/filter-instances-dropdown.js";
12
12
  import { CustomInstanceNewField as w } from "./lib/components/metadata-instance-editor/subcomponents/custom-instance-new-field/custom-instance-new-field.js";
13
- import { DeleteConfirmationModal as h } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
13
+ import { DeleteConfirmationModal as g } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
14
14
  import { MetadataInstanceFormAutofillButton as b } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js";
15
- import { MetadataInstanceFormHeader as v } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
16
- import { MetadataInstanceForm as J } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
17
- import { J as y } from "../chunks/utils.js";
18
- import { MetadataInstanceList as X } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
19
- import { MetadataInstanceHeader as j } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
20
- import { MetadataInstance as q } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance/metadata-instance.js";
21
- import { UnsavedChangesModal as G } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
15
+ import { MetadataInstanceFormHeader as H } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
16
+ import { MetadataInstanceForm as W } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
17
+ import { J as B } from "../chunks/utils.js";
18
+ import { MetadataInstanceList as Y } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
19
+ import { MetadataInstanceHeader as k } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
20
+ import { MetadataInstance as z } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance/metadata-instance.js";
21
+ import { UnsavedChangesModal as K } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
22
22
  export {
23
- c as AddMetadataTemplateDropdown,
24
- T as AutofillContext,
25
- _ as AutofillContextProvider,
26
- D as ComboboxWithApiPagination,
23
+ F as AddMetadataTemplateDropdown,
24
+ A as AiSuggestionState,
25
+ _ as AutofillContext,
26
+ E as AutofillContextProvider,
27
+ C as ComboboxWithApiPagination,
27
28
  w as CustomInstanceNewField,
28
- h as DeleteConfirmationModal,
29
+ g as DeleteConfirmationModal,
29
30
  e as FilterDropdownMenu,
30
- N as FilterInstancesDropdown,
31
- y as JSONPatchOp,
31
+ S as FilterInstancesDropdown,
32
+ B as JSONPatchOp,
32
33
  r as MULTI_VALUE_DEFAULT_OPTION,
33
34
  p as MULTI_VALUE_DEFAULT_TAXONOMY_OPTION,
34
35
  n as MULTI_VALUE_DEFAULT_VALUE,
35
36
  M as MetadataEditor,
36
37
  f as MetadataEmptyState,
37
- q as MetadataInstance,
38
- J as MetadataInstanceForm,
38
+ z as MetadataInstance,
39
+ W as MetadataInstanceForm,
39
40
  b as MetadataInstanceFormAutofillButton,
40
- v as MetadataInstanceFormHeader,
41
- j as MetadataInstanceHeader,
42
- X as MetadataInstanceList,
43
- E as TIMEOUT_10_SECONDS,
44
- G as UnsavedChangesModal,
45
- A as UpdateMode,
41
+ H as MetadataInstanceFormHeader,
42
+ k as MetadataInstanceHeader,
43
+ Y as MetadataInstanceList,
44
+ L as TIMEOUT_10_SECONDS,
45
+ K as UnsavedChangesModal,
46
+ I as UpdateMode,
46
47
  x as defaultInitialValues,
47
48
  i as defaultMetadataValueMap,
48
- L as useAutofill,
49
- U as withApiWrapper
49
+ O as useAutofill,
50
+ u as withApiWrapper
50
51
  };
@@ -1,86 +1,86 @@
1
- import { IconButton as b, Radio as i } from "@box/blueprint-web";
2
- import { Settings as y, XMark as A } from "@box/blueprint-web-assets/icons/Fill";
3
- import E from "clsx";
4
- import { useFormikContext as R, getIn as _, Field as U } from "formik";
5
- import C, { useState as q } from "react";
6
- import { useIntl as w } from "react-intl";
1
+ import { IconButton as I, Radio as i } from "@box/blueprint-web";
2
+ import { Settings as b, XMark as y } from "@box/blueprint-web-assets/icons/Fill";
3
+ import A from "clsx";
4
+ import { useFormikContext as E, getIn as u, Field as U } from "formik";
5
+ import M from "react";
6
+ import { useIntl as $ } from "react-intl";
7
7
  import { U as r } from "../../../../../../chunks/types.js";
8
- import { messages as l } from "./messages.js";
9
- import { MULTI_VALUE_DEFAULT_OPTION as S } from "./mulitple-values-utils.js";
8
+ import { messages as d } from "./messages.js";
9
+ import { MULTI_VALUE_DEFAULT_OPTION as q } from "./mulitple-values-utils.js";
10
10
  import { jsxs as p, jsx as o } from "react/jsx-runtime";
11
- import '../../../../../../styles/update-mode-field-wrapper.css';const B = "_wrapperContianer_19nqy_1", N = "_fieldContainer_19nqy_6", $ = "_field_19nqy_6", L = "_collapseButton_19nqy_14", O = "_radioContainer_19nqy_20", V = "_additionalFieldContainer_19nqy_23", k = "_hidden_19nqy_27", t = {
12
- wrapperContianer: B,
13
- fieldContainer: N,
14
- field: $,
15
- collapseButton: L,
16
- radioContainer: O,
17
- additionalFieldContainer: V,
18
- hidden: k
19
- }, x = (e) => e === r.ReplaceEntered, G = (e, a) => e === "string" || e === "multiSelect" || a, j = ({
11
+ import '../../../../../../styles/update-mode-field-wrapper.css';const w = "_wrapperContianer_19nqy_1", O = "_fieldContainer_19nqy_6", R = "_field_19nqy_6", B = "_collapseButton_19nqy_14", S = "_radioContainer_19nqy_20", L = "_additionalFieldContainer_19nqy_23", N = "_hidden_19nqy_27", a = {
12
+ wrapperContianer: w,
13
+ fieldContainer: O,
14
+ field: R,
15
+ collapseButton: B,
16
+ radioContainer: S,
17
+ additionalFieldContainer: L,
18
+ hidden: N
19
+ }, V = (e) => e === r.ReplaceEntered, k = (e, t) => e === "string" || e === "multiSelect" || t, j = ({
20
20
  children: e,
21
- fieldNamePrefix: a,
22
- fieldType: f,
23
- isTaxonomyMultiSelect: g
21
+ fieldNamePrefix: t,
22
+ fieldType: g,
23
+ isTaxonomyMultiSelect: f
24
24
  }) => {
25
25
  const {
26
- setFieldValue: M,
27
- values: m
28
- } = R(), [c, h] = q(!0), n = w(), u = `${a}.updateMode.mode`, v = _(m, u), s = e && C.Children.only(e), I = _(m, `${a}.options`, []).filter((d) => d.id !== S.id).map(({
29
- key: d
30
- }) => d);
26
+ setFieldValue: _,
27
+ values: c
28
+ } = E(), n = $(), C = `${t}.updateMode.mode`, h = u(c, C), s = e && M.Children.only(e), v = u(c, `${t}.options`, []).filter((l) => l.id !== q.id).map(({
29
+ key: l
30
+ }) => l), m = u(c, `${t}.updateMode.isOpened`);
31
31
  return /* @__PURE__ */ p("div", {
32
- className: t.wrapperContianer,
32
+ className: a.wrapperContianer,
33
33
  children: [/* @__PURE__ */ p("div", {
34
- className: t.fieldContainer,
34
+ className: a.fieldContainer,
35
35
  children: [/* @__PURE__ */ o("span", {
36
- className: t.field,
36
+ className: a.field,
37
37
  children: e
38
- }), /* @__PURE__ */ o(b, {
39
- "aria-label": n.formatMessage(l.toggleUpdateModeSelectiorAriaLabel),
40
- className: t.collapseButton,
38
+ }), /* @__PURE__ */ o(I, {
39
+ "aria-label": n.formatMessage(d.toggleUpdateModeSelectiorAriaLabel),
40
+ className: a.collapseButton,
41
41
  "data-testid": `${s.props.label}-update-mode-toggle`,
42
- icon: c ? y : A,
42
+ icon: m ? y : b,
43
43
  onClick: () => {
44
- h(!c);
44
+ _(`${t}.updateMode.isOpened`, !m);
45
45
  },
46
46
  size: "small",
47
47
  "data-target-id": "IconButton-toggleUpdateModeSelectiorAriaLabel"
48
48
  })]
49
49
  }), /* @__PURE__ */ p("div", {
50
- className: E(t.radioContainer, {
51
- [t.hidden]: c
50
+ className: A(a.radioContainer, {
51
+ [a.hidden]: !m
52
52
  }),
53
53
  children: [/* @__PURE__ */ o(U, {
54
- name: `${a}.updateMode.mode`,
54
+ name: `${t}.updateMode.mode`,
55
55
  children: ({
56
- field: d
56
+ field: l
57
57
  }) => /* @__PURE__ */ p(i.Group, {
58
58
  "data-testid": `${s.props.label}-radio-group`,
59
59
  loop: !0,
60
- onValueChange: (F) => M(u, F),
60
+ onValueChange: (F) => _(C, F),
61
61
  orientation: "vertical",
62
- value: d.value,
63
- children: [G(f, g) && /* @__PURE__ */ o(i.Item, {
64
- label: n.formatMessage(l.append),
62
+ value: l.value,
63
+ children: [k(g, f) && /* @__PURE__ */ o(i.Item, {
64
+ label: n.formatMessage(d.append),
65
65
  value: r.Append
66
66
  }), /* @__PURE__ */ o(i.Item, {
67
- label: n.formatMessage(l.clearAndReplace),
67
+ label: n.formatMessage(d.clearAndReplace),
68
68
  value: r.ClearAndReplace
69
69
  }), /* @__PURE__ */ o(i.Item, {
70
- label: n.formatMessage(l.removeEntered),
70
+ label: n.formatMessage(d.removeEntered),
71
71
  value: r.RemoveEntered
72
72
  }), /* @__PURE__ */ o(i.Item, {
73
- label: n.formatMessage(l.replaceEntered),
73
+ label: n.formatMessage(d.replaceEntered),
74
74
  value: r.ReplaceEntered
75
75
  })]
76
76
  })
77
- }), x(v) && s && /* @__PURE__ */ o("div", {
78
- className: t.additionalFieldContainer,
79
- children: /* @__PURE__ */ C.cloneElement(s, {
77
+ }), V(h) && s && /* @__PURE__ */ o("div", {
78
+ className: a.additionalFieldContainer,
79
+ children: /* @__PURE__ */ M.cloneElement(s, {
80
80
  // This field edits ${fieldNamePrefix}.updateMode.value, the '.value' is added by the field component
81
- updateModePrefix: `${a}.updateMode`,
82
- options: I,
83
- label: n.formatMessage(l.with)
81
+ updateModePrefix: `${t}.updateMode`,
82
+ options: v,
83
+ label: n.formatMessage(d.with)
84
84
  })
85
85
  })]
86
86
  })]
@@ -1,86 +1,86 @@
1
- import w from "clsx";
2
- import { useFormikContext as C } from "formik";
3
- import T from "lodash/isUndefined";
4
- import { forwardRef as U, useState as $, useCallback as j, useEffect as x, useMemo as D } from "react";
5
- import { UpdateModeFieldWrapper as L } from "./components/update-mode-field-wrapper/update-mode-field-wrapper.js";
6
- import { editorFieldTypes as R } from "./editor-field-types.js";
7
- import { s as p } from "../../../../chunks/utils2.js";
8
- import { jsx as r, jsxs as b } from "react/jsx-runtime";
9
- import { AiSuggestionField as B } from "./components/ai-suggestion-field/ai-suggestion-field.js";
10
- var t = /* @__PURE__ */ function(o) {
11
- return o.Pending = "PENDING", o.Applied = "APPLIED", o.Initial = "INITIAL", o;
12
- }(t || {});
13
- const Z = /* @__PURE__ */ U(({
14
- disableForm: o,
15
- portalElement: S,
1
+ import C from "clsx";
2
+ import { useFormikContext as E } from "formik";
3
+ import U from "lodash/isUndefined";
4
+ import { forwardRef as j, useCallback as S, useEffect as I, useMemo as R } from "react";
5
+ import { A as o } from "../../../../chunks/types.js";
6
+ import { UpdateModeFieldWrapper as T } from "./components/update-mode-field-wrapper/update-mode-field-wrapper.js";
7
+ import { editorFieldTypes as b } from "./editor-field-types.js";
8
+ import { s as g } from "../../../../chunks/utils2.js";
9
+ import { jsx as l, jsxs as B } from "react/jsx-runtime";
10
+ import { AiSuggestionField as q } from "./components/ai-suggestion-field/ai-suggestion-field.js";
11
+ const Z = /* @__PURE__ */ j(({
12
+ disableForm: A,
13
+ portalElement: f,
16
14
  field: e,
17
- index: F,
18
- taxonomyOptionsFetcher: f,
19
- isMultilevelTaxonomyFieldEnabled: y
20
- }, I) => {
15
+ index: V,
16
+ taxonomyOptionsFetcher: y,
17
+ isMultilevelTaxonomyFieldEnabled: h
18
+ }, x) => {
21
19
  var v;
22
20
  const {
23
- setFieldValue: l
24
- } = C(), [d, u] = $(t.Initial), n = d === t.Pending, N = d === t.Applied, P = d === t.Initial, g = R[e.type], {
25
- aiSuggestion: i,
26
- type: h,
21
+ setFieldValue: s
22
+ } = E(), d = e.aiSuggestionState || o.Initial, a = d === o.Pending, F = d === o.Applied, M = d === o.Initial, u = b[e.type], {
23
+ aiSuggestion: t,
24
+ type: N,
27
25
  value: c
28
- } = e, M = g && !e.hidden, E = !T(e.updateMode), s = `metadata.fields[${F}]`, V = e.type === "taxonomy" && ((v = e.optionsRules) == null ? void 0 : v.multiSelect), W = w({
29
- [p.suggestionApplied]: N,
30
- [p.hasSuggestion]: n,
31
- [p.dateField]: h === "date"
32
- }), a = j((A) => {
33
- l(`${s}.value`, A), u(t.Applied);
34
- }, [s, l]), m = () => {
35
- u(t.Initial), l(`${s}.aiSuggestion`, void 0);
36
- };
37
- x(() => {
38
- n && !c && a(i);
39
- }, [i, n, a]), x(() => {
40
- P && i && u(t.Pending);
41
- }, [P, i]);
42
- const k = D(() => i && c === i, [n]);
43
- return M ? E ? /* @__PURE__ */ r(L, {
44
- fieldNamePrefix: s,
26
+ } = e, W = u && !e.hidden, k = !U(e.updateMode), i = `metadata.fields[${V}]`, w = e.type === "taxonomy" && ((v = e.optionsRules) == null ? void 0 : v.multiSelect), P = C({
27
+ [g.suggestionApplied]: F,
28
+ [g.hasSuggestion]: a,
29
+ [g.dateField]: N === "date"
30
+ }), n = S((p) => {
31
+ s(`${i}.aiSuggestionState`, p);
32
+ }, [i, s]), r = S((p) => {
33
+ s(`${i}.value`, p), n(o.Applied);
34
+ }, [i, s, n]), m = S(() => {
35
+ n(o.Initial), s(`${i}.aiSuggestion`, void 0);
36
+ }, [n, s, i]);
37
+ I(() => {
38
+ a && !c && r(t);
39
+ }, [t, a, r]), I(() => {
40
+ M && t && n(o.Pending);
41
+ }, [M, t, n]);
42
+ const $ = R(() => t && c === t, [a]);
43
+ return W ? k ? /* @__PURE__ */ l(T, {
44
+ fieldNamePrefix: i,
45
45
  fieldType: e.type,
46
- isTaxonomyMultiSelect: V,
47
- children: /* @__PURE__ */ r(g, {
48
- ref: I,
46
+ isTaxonomyMultiSelect: w,
47
+ children: /* @__PURE__ */ l(u, {
48
+ ref: x,
49
49
  description: e.description,
50
- disableForm: o,
51
- fieldNamePrefix: s,
50
+ disableForm: A,
51
+ fieldNamePrefix: i,
52
52
  isAiSuggestionApplied: !1,
53
- isMultilevelTaxonomyFieldEnabled: y,
53
+ isMultilevelTaxonomyFieldEnabled: h,
54
54
  label: e.displayName,
55
55
  levels: e.levels,
56
56
  onValueEdited: m,
57
- portalElement: S,
58
- taxonomyOptionsFetcher: f
57
+ portalElement: f,
58
+ taxonomyOptionsFetcher: y
59
59
  })
60
- }, e.key) : /* @__PURE__ */ b("div", {
61
- className: p.fieldWrapper,
62
- children: [/* @__PURE__ */ r(g, {
63
- ref: I,
64
- className: W,
60
+ }, e.key) : /* @__PURE__ */ B("div", {
61
+ className: g.fieldWrapper,
62
+ children: [/* @__PURE__ */ l(u, {
63
+ ref: x,
64
+ className: P,
65
65
  description: e.description,
66
- disableForm: o,
67
- fieldNamePrefix: s,
68
- isAiSuggestionApplied: N,
69
- isMultilevelTaxonomyFieldEnabled: y,
66
+ disableForm: A,
67
+ fieldNamePrefix: i,
68
+ isAiSuggestionApplied: F,
69
+ isMultilevelTaxonomyFieldEnabled: h,
70
70
  label: e.displayName,
71
71
  onValueEdited: m,
72
- portalElement: S,
73
- taxonomyOptionsFetcher: f
74
- }), n && /* @__PURE__ */ r(B, {
75
- aiSuggestion: i,
76
- isSameValue: k,
72
+ portalElement: f,
73
+ taxonomyOptionsFetcher: y
74
+ }), a && /* @__PURE__ */ l(q, {
75
+ aiSuggestion: t,
76
+ isSameValue: $,
77
77
  onAiSuggestionAppend: () => {
78
- const A = [...new Set([c, i].flat().filter(Boolean))];
79
- a(A);
78
+ const p = [...new Set([c, t].flat().filter(Boolean))];
79
+ r(p);
80
80
  },
81
81
  onAiSuggestionIgnore: m,
82
- onAiSuggestionReplace: () => a(i),
83
- type: h
82
+ onAiSuggestionReplace: () => r(t),
83
+ type: N
84
84
  })]
85
85
  }, e.key) : null;
86
86
  });
@@ -1,4 +1,4 @@
1
- import { defaultMetadataValueMap as p } from "./defaults.js";
1
+ import { defaultMetadataValueMap as o } from "./defaults.js";
2
2
  import { U as i } from "../../chunks/types.js";
3
3
  const m = (e, a = !1) => ({
4
4
  scope: e.scope,
@@ -8,12 +8,13 @@ const m = (e, a = !1) => ({
8
8
  hidden: e.hidden,
9
9
  fields: e.fields.map((d) => {
10
10
  const {
11
- type: o,
12
- value: s = p[o]
11
+ type: p,
12
+ value: s = o[p]
13
13
  } = d;
14
- return d.value = s, a && (d.updateMode = {
14
+ return d.value = s, a && !d.updateMode && (d.updateMode = {
15
15
  mode: i.ClearAndReplace,
16
- value: p[o]
16
+ value: o[p],
17
+ isOpened: !1
17
18
  }), d;
18
19
  })
19
20
  }), t = (e) => e.map((a) => ({