@box/metadata-editor 2.0.1 → 2.2.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.
Files changed (34) hide show
  1. package/dist/chunks/combobox-with-api-pagination.js +2 -2
  2. package/dist/chunks/metadata-instance-form-autofill-button.js +1 -1
  3. package/dist/chunks/update-mode-field-wrapper.js +1 -1
  4. package/dist/chunks/utils.js +12 -5
  5. package/dist/esm/lib/components/combobox-with-api-pagination/use-async-list.js +48 -51
  6. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +1 -1
  7. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +1 -1
  8. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +1 -1
  9. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +1 -1
  10. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +1 -1
  11. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/legacy-metadata-taxonomy-field.js +67 -0
  12. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +15 -66
  13. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.js +53 -0
  14. package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/value-mapping.js +30 -0
  15. package/dist/esm/lib/components/metadata-editor-fields/editor-field-types.js +5 -5
  16. package/dist/esm/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.js +122 -118
  17. package/dist/esm/lib/components/metadata-editor-fields/metadata-editor-fields.js +1 -1
  18. package/dist/esm/lib/components/metadata-editor-fields/utils.js +2 -2
  19. package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +67 -63
  20. package/dist/esm/lib/utils/analytics/analytics-context.js +1 -1
  21. package/dist/esm/lib/utils/autofill-context.js +1 -1
  22. package/dist/esm/lib/utils/convertDate.js +1 -1
  23. package/dist/types/index.d.ts +1 -0
  24. package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/legacy-metadata-taxonomy-field.d.ts +9 -0
  25. package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.d.ts +7 -0
  26. package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.d.ts +15 -0
  27. package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/value-mapping.d.ts +28 -0
  28. package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/types.d.ts +12 -0
  29. package/dist/types/lib/components/metadata-editor-fields/types.d.ts +9 -1
  30. package/dist/types/lib/components/metadata-editor-fields/utils.d.ts +8 -0
  31. package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +5 -1
  32. package/dist/types/lib/test-utils/index.d.ts +1 -0
  33. package/dist/types/lib/test-utils/taxonomy-items-service.mock.d.ts +7 -0
  34. package/package.json +13 -11
@@ -4,182 +4,186 @@ import { checkIfHasBoundingBoxes as n } from "../../utils/check-if-has-bounding-
4
4
  import { isConfidenceScoreNeedingReview as r } from "../../utils/confidence-score/is-confidence-score-needing-review.js";
5
5
  import { isInteractiveFormElement as i } from "../../utils/is-interactive-form-element.js";
6
6
  import { t as a } from "../../../../chunks/shared-field-styles.module.js";
7
- import { t as ee } from "../../../../chunks/ai-suggestion-field.js";
8
- import { LowConfidenceSuggestionField as te } from "./components/low-confidence-suggestion-field/low-confidence-suggestion-field.js";
9
- import { t as o } from "../../../../chunks/update-mode-field-wrapper.js";
10
- import { r as s } from "../../../../chunks/utils.js";
11
- import { editorFieldTypes as c } from "./editor-field-types.js";
12
- import { useViewReferenceTooltip as ne } from "./hooks/use-view-reference-tooltip.js";
13
- import { Tooltip as l } from "@box/blueprint-web";
14
- import { forwardRef as u, memo as d, useCallback as f, useEffect as p, useMemo as re } from "react";
15
- import { useIntl as ie } from "react-intl";
16
- import { jsx as m, jsxs as ae } from "react/jsx-runtime";
17
- import h from "clsx";
18
- import { useFormikContext as g } from "formik";
19
- import oe from "lodash/isEqual";
20
- import se from "lodash/isUndefined";
21
- var _ = /* @__PURE__ */ d(/* @__PURE__ */ u(({ disableForm: u, portalElement: d, field: _, index: ce, taxonomyOptionsFetcher: v, isExternallyOwned: y, isMultilevelTaxonomyFieldEnabled: b, isConfidenceScoreReviewEnabled: x = !1, isBoundingBoxEnabled: S = !1, onSelectMetadataField: C, selectedMetadataFieldId: le }, w) => {
22
- let { setFieldValue: T } = g(), { formatMessage: E } = ie(), D = _.aiSuggestionState || t.Initial, O = D === t.Pending, k = D === t.Applied, A = D === t.Initial, j = c[_.type], { aiSuggestion: M, aiSuggestionConfidenceScore: N, aiSuggestionTargetLocation: P, type: F, value: I } = _, L = j && !_.hidden, R = !se(_.updateMode), z = `metadata.fields[${ce}]`, B = _.type === "taxonomy" && _.optionsRules?.multiSelect, V = S || x, H = x && !!_.confidenceScore, U = H && r(_.confidenceScore), ue = H && !O && !r(_.confidenceScore), W = le === _.id, de = n(_.targetLocation), G = V && de && !!C, { isTooltipOpen: K, handleMouseOver: fe, handleMouseLeave: pe, handleFocus: me, handleBlur: he } = ne(G), ge = h({
23
- [s.aiApproved]: k || ue || _.isExtracted,
7
+ import { t as o } from "../../../../chunks/ai-suggestion-field.js";
8
+ import { LowConfidenceSuggestionField as ee } from "./components/low-confidence-suggestion-field/low-confidence-suggestion-field.js";
9
+ import { t as te } from "../../../../chunks/update-mode-field-wrapper.js";
10
+ import { i as s } from "../../../../chunks/utils.js";
11
+ import { editorFieldTypes as ne } from "./editor-field-types.js";
12
+ import { useViewReferenceTooltip as re } from "./hooks/use-view-reference-tooltip.js";
13
+ import { Tooltip as c } from "@box/blueprint-web";
14
+ import { forwardRef as l, memo as u, useCallback as d, useEffect as f, useMemo as ie } from "react";
15
+ import { useIntl as ae } from "react-intl";
16
+ import { jsx as p, jsxs as oe } from "react/jsx-runtime";
17
+ import m from "clsx";
18
+ import { useFormikContext as h } from "formik";
19
+ import se from "lodash/isEqual";
20
+ import ce from "lodash/isUndefined";
21
+ var g = /*#__PURE__*/ u(/*#__PURE__*/ l(({ disableForm: l, portalElement: u, field: g, index: le, taxonomyOptionsFetcher: _, isExternallyOwned: v, isMultilevelTaxonomyFieldEnabled: y, isTaxonomyPickerEnabled: b, createTaxonomyItemsService: x, isConfidenceScoreReviewEnabled: S = !1, isBoundingBoxEnabled: ue = !1, onSelectMetadataField: C, selectedMetadataFieldId: de }, w) => {
22
+ let { setFieldValue: T } = h(), { formatMessage: E } = ae(), D = g.aiSuggestionState || t.Initial, O = D === t.Pending, k = D === t.Applied, A = D === t.Initial, j = ne[g.type], { aiSuggestion: M, aiSuggestionConfidenceScore: N, aiSuggestionTargetLocation: P, type: F, value: I } = g, fe = j && !g.hidden, L = !ce(g.updateMode), R = `metadata.fields[${le}]`, z = g.type === "taxonomy" && g.optionsRules?.multiSelect, B = ue || S, V = S && !!g.confidenceScore, H = V && r(g.confidenceScore), pe = V && !O && !r(g.confidenceScore), U = de === g.id, me = n(g.targetLocation), W = B && me && !!C, { isTooltipOpen: G, handleMouseOver: he, handleMouseLeave: ge, handleFocus: _e, handleBlur: ve } = re(W), ye = m({
23
+ [s.aiApproved]: k || pe || g.isExtracted,
24
24
  [s.hasSuggestion]: O,
25
- [s.hasConfidenceReview]: !O && U,
25
+ [s.hasConfidenceReview]: !O && H,
26
26
  [s.dateField]: F === "date"
27
- }), q = f((e, t) => {
28
- T(`${z}.${e}`, t);
29
- }, [z, T]), J = f((e) => {
30
- q("aiSuggestionState", e);
31
- }, [q]), Y = f((e, n = !1) => {
32
- q("value", e), J(t.Applied), q("isExtracted", !0), V && P && (q("targetLocation", P), q("aiSuggestionTargetLocation", void 0)), x && N && (q("confidenceScore", n ? {
27
+ }), K = d((e, t) => {
28
+ T(`${R}.${e}`, t);
29
+ }, [R, T]), q = d((e) => {
30
+ K("aiSuggestionState", e);
31
+ }, [K]), J = d((e, n = !1) => {
32
+ K("value", e), q(t.Applied), K("isExtracted", !0), B && P && (K("targetLocation", P), K("aiSuggestionTargetLocation", void 0)), S && N && (K("confidenceScore", n ? {
33
33
  ...N,
34
34
  isAccepted: !0
35
- } : N), q("aiSuggestionConfidenceScore", void 0));
35
+ } : N), K("aiSuggestionConfidenceScore", void 0));
36
36
  }, [
37
+ K,
37
38
  q,
38
- J,
39
39
  N,
40
40
  P,
41
- x,
42
- V
43
- ]), X = f(() => {
44
- J(t.Initial), q("aiSuggestion", void 0), V && q("aiSuggestionTargetLocation", void 0), x && q("aiSuggestionConfidenceScore", void 0);
41
+ S,
42
+ B
43
+ ]), Y = d(() => {
44
+ q(t.Initial), K("aiSuggestion", void 0), B && K("aiSuggestionTargetLocation", void 0), S && K("aiSuggestionConfidenceScore", void 0);
45
45
  }, [
46
- J,
47
46
  q,
48
- x,
49
- V
50
- ]), _e = f(() => {
51
- _.confidenceScore && q("confidenceScore", {
52
- ..._.confidenceScore,
47
+ K,
48
+ S,
49
+ B
50
+ ]), X = d(() => {
51
+ g.confidenceScore && K("confidenceScore", {
52
+ ...g.confidenceScore,
53
53
  isAccepted: !0
54
54
  }), C?.(null);
55
55
  }, [
56
- q,
57
- _.confidenceScore,
56
+ K,
57
+ g.confidenceScore,
58
58
  C
59
- ]), ve = f(() => {
60
- J(t.Initial), q("aiSuggestion", void 0), q("isExtracted", !1), q("value", F === "multiSelect" || F === "taxonomy" ? [] : ""), q("confidenceScore", void 0), q("targetLocation", void 0), C?.(null);
59
+ ]), be = d(() => {
60
+ q(t.Initial), K("aiSuggestion", void 0), K("isExtracted", !1), K("value", F === "multiSelect" || F === "taxonomy" ? [] : ""), K("confidenceScore", void 0), K("targetLocation", void 0), C?.(null);
61
61
  }, [
62
- q,
62
+ K,
63
63
  F,
64
64
  C,
65
- J
66
- ]), Z = f(() => {
67
- X(), _.isExtracted && q("isExtracted", !1), V && _.targetLocation && (q("targetLocation", void 0), C?.(null)), x && _.confidenceScore && (q("confidenceScore", void 0), C?.(null));
65
+ q
66
+ ]), Z = d(() => {
67
+ Y(), g.isExtracted && K("isExtracted", !1), B && g.targetLocation && (K("targetLocation", void 0), C?.(null)), S && g.confidenceScore && (K("confidenceScore", void 0), C?.(null));
68
68
  }, [
69
- X,
70
- x,
71
- _.confidenceScore,
72
- _.isExtracted,
73
- _.targetLocation,
74
- q,
69
+ Y,
70
+ S,
71
+ g.confidenceScore,
72
+ g.isExtracted,
73
+ g.targetLocation,
74
+ K,
75
75
  C,
76
- V
77
- ]), ye = f((e) => {
78
- C && (i(e.target) || C(_));
79
- }, [_, C]), be = f((e) => {
76
+ B
77
+ ]), xe = d((e) => {
78
+ C && (i(e.target) || C(g));
79
+ }, [g, C]), Se = d((e) => {
80
80
  if (e.key === "Enter") {
81
81
  if (!C || i(e.target)) return;
82
- e.preventDefault(), e.stopPropagation(), C(_);
82
+ e.preventDefault(), e.stopPropagation(), C(g);
83
83
  }
84
- }, [_, C]);
85
- p(() => {
86
- O && (!I || Array.isArray(I) && I.length === 0) && Y(M);
84
+ }, [g, C]);
85
+ f(() => {
86
+ O && (!I || Array.isArray(I) && I.length === 0) && J(M);
87
87
  }, [
88
88
  M,
89
89
  O,
90
- Y
91
- ]), p(() => {
92
- A && M && J(t.Pending);
90
+ J
91
+ ]), f(() => {
92
+ A && M && q(t.Pending);
93
93
  }, [
94
94
  A,
95
95
  M,
96
- J
96
+ q
97
97
  ]);
98
- let xe = re(() => M ? oe(I, M) : !1, [M, I]);
99
- if (!L) return null;
98
+ let Ce = ie(() => M ? se(I, M) : !1, [M, I]);
99
+ if (!fe) return null;
100
100
  let Q = {
101
101
  "data-metadata-field": !0,
102
102
  "data-target-id": "Button-metadataEditorFieldEditClick",
103
103
  "data-testid": "metadata-field",
104
- onClick: ye,
105
- onKeyDown: be,
106
- onMouseOver: fe,
107
- onMouseLeave: pe,
108
- onFocus: me,
109
- onBlur: he,
104
+ onClick: xe,
105
+ onKeyDown: Se,
106
+ onMouseOver: he,
107
+ onMouseLeave: ge,
108
+ onFocus: _e,
109
+ onBlur: ve,
110
110
  role: "button",
111
111
  tabIndex: 0
112
112
  };
113
- if (R) {
114
- let t = /* @__PURE__ */ m(o, {
115
- fieldNamePrefix: z,
116
- fieldType: _.type,
117
- isTaxonomyMultiSelect: B,
118
- children: /* @__PURE__ */ m(j, {
113
+ if (L) {
114
+ let t = /* @__PURE__ */ p(te, {
115
+ fieldNamePrefix: R,
116
+ fieldType: g.type,
117
+ isTaxonomyMultiSelect: z,
118
+ children: /* @__PURE__ */ p(j, {
119
119
  ref: w,
120
- description: _.description,
121
- disableForm: u,
122
- fieldNamePrefix: z,
120
+ description: g.description,
121
+ disableForm: l,
122
+ fieldNamePrefix: R,
123
123
  isAiSuggestionApplied: !1,
124
- isExternallyOwned: y,
125
- isMultilevelTaxonomyFieldEnabled: b,
126
- label: _.displayName,
127
- levels: _.levels,
124
+ isExternallyOwned: v,
125
+ isMultilevelTaxonomyFieldEnabled: y,
126
+ isTaxonomyPickerEnabled: b,
127
+ createTaxonomyItemsService: x,
128
+ label: g.displayName,
129
+ levels: g.levels,
128
130
  onValueEdited: Z,
129
- portalElement: d,
130
- taxonomyOptionsFetcher: v
131
+ portalElement: u,
132
+ taxonomyOptionsFetcher: _
131
133
  })
132
- }, _.key);
133
- return G ? /* @__PURE__ */ m(l, {
134
+ }, g.key);
135
+ return W ? /* @__PURE__ */ p(c, {
134
136
  content: E(e.viewOnDocument),
135
- open: K,
136
- children: /* @__PURE__ */ m("div", {
137
- className: h(a.spacious, a.clickableField, W && a.selectedField),
137
+ open: G,
138
+ children: /* @__PURE__ */ p("div", {
139
+ className: m(a.spacious, a.clickableField, U && a.selectedField),
138
140
  ...Q,
139
141
  children: t
140
142
  })
141
143
  }) : t;
142
144
  }
143
- let $ = /* @__PURE__ */ ae("div", {
144
- className: h(s.fieldWrapper, V && a.spacious, G && a.clickableField, G && W && a.selectedField),
145
- ...G && Q,
145
+ let $ = /* @__PURE__ */ oe("div", {
146
+ className: m(s.fieldWrapper, B && a.spacious, W && a.clickableField, W && U && a.selectedField),
147
+ ...W && Q,
146
148
  children: [
147
- /* @__PURE__ */ m(j, {
149
+ /* @__PURE__ */ p(j, {
148
150
  ref: w,
149
- className: ge,
150
- description: _.description,
151
- disableForm: u,
152
- fieldNamePrefix: z,
153
- isAiSuggestionApplied: k || _.isExtracted,
154
- isExternallyOwned: y,
155
- confidenceScore: x ? _.confidenceScore : void 0,
156
- isMultilevelTaxonomyFieldEnabled: b,
157
- label: _.displayName,
151
+ className: ye,
152
+ description: g.description,
153
+ disableForm: l,
154
+ fieldNamePrefix: R,
155
+ isAiSuggestionApplied: k || g.isExtracted,
156
+ isExternallyOwned: v,
157
+ confidenceScore: S ? g.confidenceScore : void 0,
158
+ isMultilevelTaxonomyFieldEnabled: y,
159
+ isTaxonomyPickerEnabled: b,
160
+ createTaxonomyItemsService: x,
161
+ label: g.displayName,
158
162
  onValueEdited: Z,
159
- portalElement: d,
160
- taxonomyOptionsFetcher: v
163
+ portalElement: u,
164
+ taxonomyOptionsFetcher: _
161
165
  }),
162
- O && /* @__PURE__ */ m(ee, {
166
+ O && /* @__PURE__ */ p(o, {
163
167
  aiSuggestion: M,
164
- confidenceLevel: x ? N?.level : void 0,
165
- isSameValue: xe,
168
+ confidenceLevel: S ? N?.level : void 0,
169
+ isSameValue: Ce,
166
170
  onAiSuggestionAppend: () => {
167
- Y([...new Set([I, M].flat().filter(Boolean))], !0);
171
+ J([...new Set([I, M].flat().filter(Boolean))], !0);
168
172
  },
169
- onAiSuggestionIgnore: X,
170
- onAiSuggestionReplace: () => Y(M, !0),
173
+ onAiSuggestionIgnore: Y,
174
+ onAiSuggestionReplace: () => J(M, !0),
171
175
  type: F
172
176
  }),
173
- !O && U && /* @__PURE__ */ m(te, {
174
- onAccept: _e,
175
- onClear: ve
177
+ !O && H && /* @__PURE__ */ p(ee, {
178
+ onAccept: X,
179
+ onClear: be
176
180
  })
177
181
  ]
178
- }, _.key);
179
- return G ? /* @__PURE__ */ m(l, {
182
+ }, g.key);
183
+ return W ? /* @__PURE__ */ p(c, {
180
184
  content: E(e.viewOnDocument),
181
- open: K,
185
+ open: G,
182
186
  children: $
183
187
  }) : $;
184
188
  }));
185
- export { _ as MetadataEditorFieldWrapper };
189
+ export { g as MetadataEditorFieldWrapper };
@@ -1,5 +1,5 @@
1
1
  import e from "../../messages.js";
2
- import { r as t } from "../../../../chunks/utils.js";
2
+ import { i as t } from "../../../../chunks/utils.js";
3
3
  import { MetadataEditorFieldWrapper as n } from "./metadata-editor-field-wrapper.js";
4
4
  import { useReviewFieldFilter as r } from "./hooks/use-review-field-filter.js";
5
5
  import { Text as i } from "@box/blueprint-web";
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "../../../../chunks/utils.js";
2
- export { t as getFieldLabel, e as tryParseDateSuggestion };
1
+ import { n as e, r as t, t as n } from "../../../../chunks/utils.js";
2
+ export { n as getFieldLabel, e as getFieldLabelContent, t as tryParseDateSuggestion };
@@ -6,59 +6,61 @@ import { TemplateInstance as i } from "../../../metadata-editor-fields/metadata-
6
6
  import { UnsavedChangesModal as a } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
7
7
  import { t as o } from "../../../../../../chunks/autofill-overlay.js";
8
8
  import { t as ee } from "../../../../../../chunks/custom-instance.js";
9
- import { t as s } from "../../../../../../chunks/delete-confirmation-modal.js";
10
- import { t as c } from "../../../../../../chunks/utils2.js";
11
- import { n as l, t as u } from "../../../../../../chunks/metadata-instance-form-card-wrapper.js";
12
- import { useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
13
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
14
- import _ from "clsx";
15
- import { Form as v, Formik as y } from "formik";
16
- import b from "lodash/isEqual";
17
- var x = ({ dirty: e, onChange: t, values: n }) => {
18
- let r = p(n);
19
- return e && !b(r.current.metadata.fields, n.metadata.fields) && (r.current = n, t(n)), null;
20
- }, S = (b) => {
21
- let { areAiSuggestionsAvailable: S, customRef: C, isLargeFile: w, errorCode: T, isAiSuggestionsFeatureEnabled: E, isAdvancedExtractAgentEnabled: D = !1, isBetaLanguageEnabled: te, isDeleteButtonDisabled: ne, isDeleteConfirmationModalCheckboxEnabled: re, isMultilevelTaxonomyFieldEnabled: O, isUnsavedChangesModalOpen: k = !1, MetadataInstanceFormCustomWrapper: A, selectedTemplateInstance: j, onCancel: M, onChange: N, onDelete: P, onDiscardUnsavedChanges: F, onSubmit: I, onToggleReviewFilter: L, setIsUnsavedChangesModalOpen: R, shouldShowOnlyReviewFields: z = !1, taxonomyOptionsFetcher: B, isConfidenceScoreReviewEnabled: V = !1, isBoundingBoxEnabled: H = !1, onSelectMetadataField: U, selectedMetadataFieldId: W } = b, ie = A ?? u, [G, K] = m(!1), { isFetchingSuggestions: q, isLongLoading: J, getAiSuggestions: Y, clearState: X, suggestions: ae } = r(), { trackEvent: oe } = n();
22
- d(() => () => {
23
- X();
24
- }, [X, j?.id]);
25
- let Z = j?.templateKey === e, se = async (e) => {
26
- await I(e, c(e, j));
27
- }, ce = (e) => {
9
+ import { t as te } from "../../../../../../chunks/delete-confirmation-modal.js";
10
+ import { t as ne } from "../../../../../../chunks/utils2.js";
11
+ import { n as s, t as c } from "../../../../../../chunks/metadata-instance-form-card-wrapper.js";
12
+ import { useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
13
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
14
+ import h from "clsx";
15
+ import { Form as g, Formik as _ } from "formik";
16
+ import v from "lodash/isEqual";
17
+ var y = ({ dirty: e, onChange: t, values: n }) => {
18
+ let r = d(n);
19
+ return e && !v(r.current.metadata.fields, n.metadata.fields) && (r.current = n, t(n)), null;
20
+ }, b = (v) => {
21
+ let { areAiSuggestionsAvailable: b, customRef: x, isLargeFile: S, errorCode: C, isAiSuggestionsFeatureEnabled: w, isAdvancedExtractAgentEnabled: T = !1, isBetaLanguageEnabled: re, isDeleteButtonDisabled: ie, isDeleteConfirmationModalCheckboxEnabled: ae, isMultilevelTaxonomyFieldEnabled: E, isTaxonomyPickerEnabled: D, createTaxonomyItemsService: O, isUnsavedChangesModalOpen: k = !1, MetadataInstanceFormCustomWrapper: A, selectedTemplateInstance: j, onCancel: M, onChange: N, onDelete: P, onDiscardUnsavedChanges: F, onSubmit: I, onToggleReviewFilter: L, setIsUnsavedChangesModalOpen: R, shouldShowOnlyReviewFields: z = !1, taxonomyOptionsFetcher: B, isConfidenceScoreReviewEnabled: V = !1, isBoundingBoxEnabled: H = !1, onSelectMetadataField: U, selectedMetadataFieldId: W } = v, oe = A ?? c, [G, K] = f(!1), { isFetchingSuggestions: q, isLongLoading: J, getAiSuggestions: se, clearState: Y, suggestions: ce } = r(), { trackEvent: le } = n();
22
+ l(() => () => {
23
+ Y();
24
+ }, [Y, j?.id]);
25
+ let X = j?.templateKey === e, ue = async (e) => {
26
+ await I(e, ne(e, j));
27
+ }, de = (e) => {
28
28
  e ? R(!0) : M();
29
- }, le = () => {
29
+ }, Z = () => {
30
30
  K(!0);
31
- }, ue = { metadata: { ...j } }, Q = p(null), [$, de] = m(null);
32
- d(() => {
33
- de(C ?? Q.current);
31
+ }, fe = { metadata: { ...j } }, Q = d(null), [$, pe] = f(null);
32
+ l(() => {
33
+ pe(x ?? Q.current);
34
34
  }, [
35
- C,
35
+ x,
36
36
  j?.templateKey,
37
37
  j?.scope
38
38
  ]);
39
- let fe = f(() => {
39
+ let me = u(() => {
40
40
  let e = j?.fields.length === 0;
41
- if (Z) return /* @__PURE__ */ h(ee, { isLoading: q });
42
- if (e) return /* @__PURE__ */ h(t, {
43
- isBoxAiSuggestionsFeatureEnabled: E,
41
+ if (X) return /* @__PURE__ */ p(ee, { isLoading: q });
42
+ if (e) return /* @__PURE__ */ p(t, {
43
+ isBoxAiSuggestionsFeatureEnabled: w,
44
44
  level: "instance"
45
45
  });
46
- let n = !!(q || T);
47
- return /* @__PURE__ */ g("div", {
48
- className: _(l.metadataInstanceFormContent, n && l.showOverlay, V && l.metadataInstanceFormContentReducedGap),
49
- children: [/* @__PURE__ */ h(o, {
50
- errorCode: T,
46
+ let n = !!(q || C);
47
+ return /* @__PURE__ */ m("div", {
48
+ className: h(s.metadataInstanceFormContent, n && s.showOverlay, V && s.metadataInstanceFormContentReducedGap),
49
+ children: [/* @__PURE__ */ p(o, {
50
+ errorCode: C,
51
51
  isFetchingSuggestions: q,
52
52
  isLongLoading: J
53
- }), /* @__PURE__ */ h(i, {
53
+ }), /* @__PURE__ */ p(i, {
54
54
  disableForm: q,
55
55
  isConfidenceScoreReviewEnabled: V,
56
56
  isBoundingBoxEnabled: H,
57
57
  isExternallyOwned: j?.isExternallyOwned,
58
- isMultilevelTaxonomyFieldEnabled: O,
58
+ isMultilevelTaxonomyFieldEnabled: E,
59
+ isTaxonomyPickerEnabled: D,
60
+ createTaxonomyItemsService: O,
59
61
  onSelectMetadataField: U,
60
62
  selectedMetadataFieldId: W,
61
- portalElement: C ?? $,
63
+ portalElement: x ?? $,
62
64
  shouldShowOnlyReviewFields: z,
63
65
  taxonomyOptionsFetcher: B
64
66
  })]
@@ -66,60 +68,62 @@ var x = ({ dirty: e, onChange: t, values: n }) => {
66
68
  }, [
67
69
  j?.fields.length,
68
70
  j?.isExternallyOwned,
69
- Z,
71
+ X,
70
72
  q,
71
73
  J,
72
- C,
74
+ x,
73
75
  $,
74
76
  B,
75
- E,
77
+ w,
76
78
  V,
77
79
  H,
80
+ E,
81
+ D,
78
82
  O,
79
- T,
83
+ C,
80
84
  z,
81
85
  U,
82
86
  W
83
87
  ]);
84
- return /* @__PURE__ */ h(y, {
85
- initialValues: ue,
86
- onSubmit: se,
87
- children: ({ values: e, dirty: t }) => /* @__PURE__ */ g(v, { children: [
88
- /* @__PURE__ */ h(ie, {
89
- areAiSuggestionsAvailable: S,
90
- className: l.metadataInstanceForm,
88
+ return /* @__PURE__ */ p(_, {
89
+ initialValues: fe,
90
+ onSubmit: ue,
91
+ children: ({ values: e, dirty: t }) => /* @__PURE__ */ m(g, { children: [
92
+ /* @__PURE__ */ p(oe, {
93
+ areAiSuggestionsAvailable: b,
94
+ className: s.metadataInstanceForm,
91
95
  formRef: Q,
92
96
  formValues: e,
93
- getAiSuggestions: Y,
94
- handleCancel: ce,
95
- handleDelete: le,
96
- isAdvancedExtractAgentEnabled: D,
97
- isAiSuggestionsFeatureEnabled: E,
98
- isBetaLanguageEnabled: te,
97
+ getAiSuggestions: se,
98
+ handleCancel: de,
99
+ handleDelete: Z,
100
+ isAdvancedExtractAgentEnabled: T,
101
+ isAiSuggestionsFeatureEnabled: w,
102
+ isBetaLanguageEnabled: re,
99
103
  isConfidenceScoreReviewEnabled: V,
100
- isDeleteButtonDisabled: ne,
104
+ isDeleteButtonDisabled: ie,
101
105
  isFetchingSuggestions: q,
102
106
  isFormDirty: t,
103
- isLargeFile: w,
107
+ isLargeFile: S,
104
108
  onToggleReviewFilter: L,
105
109
  selectedTemplateInstance: j,
106
110
  shouldShowOnlyReviewFields: z,
107
- suggestions: ae,
108
- children: j && fe
111
+ suggestions: ce,
112
+ children: j && me
109
113
  }),
110
- N && /* @__PURE__ */ h(x, {
114
+ N && /* @__PURE__ */ p(y, {
111
115
  dirty: t,
112
116
  onChange: N,
113
117
  values: e
114
118
  }),
115
- /* @__PURE__ */ h(a, {
119
+ /* @__PURE__ */ p(a, {
116
120
  onBackToEdit: () => R(!1),
117
121
  onDiscardChanges: F,
118
122
  open: k,
119
- trackEvent: oe
123
+ trackEvent: le
120
124
  }),
121
- /* @__PURE__ */ h(s, {
122
- isCheckboxEnabled: re,
125
+ /* @__PURE__ */ p(te, {
126
+ isCheckboxEnabled: ae,
123
127
  onConfirm: () => P(j),
124
128
  onDismiss: () => K(!1),
125
129
  open: G,
@@ -128,4 +132,4 @@ var x = ({ dirty: e, onChange: t, values: n }) => {
128
132
  ] })
129
133
  }, `${j?.scope}.${j?.templateKey}`);
130
134
  };
131
- export { S as MetadataInstanceForm };
135
+ export { b as MetadataInstanceForm };
@@ -1,7 +1,7 @@
1
1
  import { createContext as e, useContext as t, useMemo as n } from "react";
2
2
  import { jsx as r } from "react/jsx-runtime";
3
3
  import i from "lodash/noop";
4
- var a = /* @__PURE__ */ e({ trackEvent: i }), o = ({ children: e, trackEvent: t }) => {
4
+ var a = /*#__PURE__*/ e({ trackEvent: i }), o = ({ children: e, trackEvent: t }) => {
5
5
  let o = n(() => ({ trackEvent: t ?? i }), [t]);
6
6
  return /* @__PURE__ */ r(a.Provider, {
7
7
  value: o,
@@ -1,7 +1,7 @@
1
1
  import "../constants.js";
2
2
  import e, { createContext as t, useCallback as n, useContext as r, useMemo as i, useState as a } from "react";
3
3
  import { jsx as o } from "react/jsx-runtime";
4
- var s = 1e4, c = /* @__PURE__ */ t(null), l = ({ children: t, isAiSuggestionsFeatureEnabled: r, fetchSuggestions: l }) => {
4
+ var s = 1e4, c = /*#__PURE__*/ t(null), l = ({ children: t, isAiSuggestionsFeatureEnabled: r, fetchSuggestions: l }) => {
5
5
  let [u, d] = a({}), [f, p] = a({}), [m, h] = a({}), [g, _] = a(!1), [v, y] = a(!1);
6
6
  e.useEffect(() => {
7
7
  let e;
@@ -1,5 +1,5 @@
1
1
  import { parseDate as e } from "@box/blueprint-web";
2
- var t = 60 * 1e3, n = RegExp("^(\\d{4}-\\d{2}-\\d{2})(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?)?((Z$)|(?:[+-](?:([0-2]\\d$)|([0-2]\\d(?:00|30)$)|([0-2]\\d:(?:00|30)$))))?$"), r = 1, i = 2, a = 3, o = 4, s = 5, c = 6, l = 7, u = 8;
2
+ var t = 60 * 1e3, n = /* @__PURE__ */ RegExp("^(\\d{4}-\\d{2}-\\d{2})(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?)?((Z$)|(?:[+-](?:([0-2]\\d$)|([0-2]\\d(?:00|30)$)|([0-2]\\d:(?:00|30)$))))?$"), r = 1, i = 2, a = 3, o = 4, s = 5, c = 6, l = 7, u = 8;
3
3
  function d(e) {
4
4
  if (!n.test(e)) return e;
5
5
  let t = e.split(n), d = t[r], f = t[i], p = t[a], m = t[o], h = d;
@@ -12,3 +12,4 @@ export * from './lib/metadata-editor';
12
12
  export * from './lib/types';
13
13
  export * from './lib/utils/api-wrapper';
14
14
  export * from './lib/utils/autofill-context';
15
+ export type { FetchParams, FetchResponse, SearchParams, TaxonomyAncestor, TaxonomyItemsService, TaxonomyNode, TaxonomySearchResult, } from '@box/metadata-taxonomy-picker';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Legacy taxonomy field backed by `@box/combobox-with-api`
3
+ * (`ComboboxWithApiTreeView` for multilevel, `ComboboxWithApiPagination` otherwise).
4
+ * Retained for consumers that have not migrated to the new `MetadataTaxonomyPicker`
5
+ * experience; slated for removal once the picker is fully rolled out.
6
+ */
7
+ export declare const LegacyMetadataTaxonomyField: import('react').ForwardRefExoticComponent<Omit<import('../../types').MetadataFieldProps, "portalElement"> & {
8
+ portalElement?: HTMLElement | (() => HTMLElement);
9
+ } & import('react').RefAttributes<HTMLInputElement>>;
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Dispatches between the two taxonomy experiences: the new `MetadataTaxonomyPicker`
3
+ * (when `isTaxonomyPickerEnabled` is set and a `createTaxonomyItemsService` factory is
4
+ * provided) and the legacy `@box/combobox-with-api` field otherwise. This branch is the
5
+ * single migration boundary; remove the legacy field and this dispatcher's fallback once
6
+ * the picker is fully rolled out.
7
+ */
1
8
  export declare const MetadataTaxonomyField: import('react').ForwardRefExoticComponent<Omit<import('../../types').MetadataFieldProps, "portalElement"> & {
2
9
  portalElement?: HTMLElement | (() => HTMLElement);
3
10
  } & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,15 @@
1
+ import { CreateTaxonomyItemsService, MetadataTaxonomyFieldProps } from '../types';
2
+ export type MetadataTaxonomyPickerFieldProps = MetadataTaxonomyFieldProps & {
3
+ createTaxonomyItemsService: CreateTaxonomyItemsService;
4
+ };
5
+ /**
6
+ * New taxonomy field backed by `@box/metadata-taxonomy-picker`. Adapts the per-field
7
+ * `createTaxonomyItemsService` factory, the canonical Formik `TreeOptionType[]` value,
8
+ * and the field's level config to the picker's API. Selected via the
9
+ * `isTaxonomyPickerEnabled` flag in `MetadataTaxonomyField`.
10
+ */
11
+ export declare const MetadataTaxonomyPickerField: import('react').ForwardRefExoticComponent<Omit<import('../../../types').MetadataFieldProps, "portalElement"> & {
12
+ portalElement?: HTMLElement | (() => HTMLElement);
13
+ } & {
14
+ createTaxonomyItemsService: CreateTaxonomyItemsService;
15
+ } & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,28 @@
1
+ import { Level, TreeOptionType } from '@box/combobox-with-api';
2
+ import { TaxonomyLevel, TaxonomyValue, TaxonomyPickerMode } from '@box/metadata-taxonomy-picker';
3
+ /**
4
+ * Maps the Formik-stored taxonomy value (`TreeOptionType[]`, the canonical shape kept
5
+ * for submit serialization and read-mode display) to the picker's `TaxonomyValue[]`.
6
+ *
7
+ * Non-array inputs (e.g. an empty `''` value) map to `[]`. The bulk-update "Multiple
8
+ * values" sentinel is rendered with its localized label, mirroring the legacy field.
9
+ */
10
+ export declare function mapFormValueToTaxonomyValues(value: unknown, multipleValuesLabel: string): TaxonomyValue[];
11
+ /**
12
+ * Maps the picker's `TaxonomyValue[]` back to the canonical Formik `TreeOptionType[]`.
13
+ * `selectable` is synthesized as `true` (a selected item is selectable by definition,
14
+ * and this field is only consumed by submit's `.value` and re-display).
15
+ */
16
+ export declare function mapTaxonomyValuesToFormValue(values: TaxonomyValue[]): TreeOptionType[];
17
+ /**
18
+ * Derives the picker mode from the number of user-selectable levels: more than one
19
+ * selectable level is a multi-level taxonomy; a single selectable level (flat or a
20
+ * single deep level) is single-level.
21
+ */
22
+ export declare function getTaxonomyPickerMode(selectableLevels: number[] | undefined): TaxonomyPickerMode;
23
+ /**
24
+ * Maps the field's taxonomy `levels` to the picker's `TaxonomyLevel[]`, marking each
25
+ * level selectable based on `selectableLevels`. Drives the picker's chevron cutoff and
26
+ * search scope in single-level mode and the level-filter dropdown in multi-level mode.
27
+ */
28
+ export declare function mapLevelsToTaxonomyLevels(levels: Level[] | undefined, selectableLevels: number[] | undefined): TaxonomyLevel[];