@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.
- package/dist/chunks/combobox-with-api-pagination.js +2 -2
- package/dist/chunks/metadata-instance-form-autofill-button.js +1 -1
- package/dist/chunks/update-mode-field-wrapper.js +1 -1
- package/dist/chunks/utils.js +12 -5
- package/dist/esm/lib/components/combobox-with-api-pagination/use-async-list.js +48 -51
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/legacy-metadata-taxonomy-field.js +67 -0
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +15 -66
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.js +53 -0
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/value-mapping.js +30 -0
- package/dist/esm/lib/components/metadata-editor-fields/editor-field-types.js +5 -5
- package/dist/esm/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.js +122 -118
- package/dist/esm/lib/components/metadata-editor-fields/metadata-editor-fields.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/utils.js +2 -2
- package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +67 -63
- package/dist/esm/lib/utils/analytics/analytics-context.js +1 -1
- package/dist/esm/lib/utils/autofill-context.js +1 -1
- package/dist/esm/lib/utils/convertDate.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/legacy-metadata-taxonomy-field.d.ts +9 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.d.ts +7 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.d.ts +15 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/value-mapping.d.ts +28 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/types.d.ts +12 -0
- package/dist/types/lib/components/metadata-editor-fields/types.d.ts +9 -1
- package/dist/types/lib/components/metadata-editor-fields/utils.d.ts +8 -0
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +5 -1
- package/dist/types/lib/test-utils/index.d.ts +1 -0
- package/dist/types/lib/test-utils/taxonomy-items-service.mock.d.ts +7 -0
- 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
|
|
8
|
-
import { LowConfidenceSuggestionField as
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import { editorFieldTypes as
|
|
12
|
-
import { useViewReferenceTooltip as
|
|
13
|
-
import { Tooltip as
|
|
14
|
-
import { forwardRef as
|
|
15
|
-
import { useIntl as
|
|
16
|
-
import { jsx as
|
|
17
|
-
import
|
|
18
|
-
import { useFormikContext as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
var
|
|
22
|
-
let { setFieldValue: T } =
|
|
23
|
-
[s.aiApproved]: k ||
|
|
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 &&
|
|
25
|
+
[s.hasConfidenceReview]: !O && H,
|
|
26
26
|
[s.dateField]: F === "date"
|
|
27
|
-
}),
|
|
28
|
-
T(`${
|
|
29
|
-
}, [
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
|
|
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),
|
|
35
|
+
} : N), K("aiSuggestionConfidenceScore", void 0));
|
|
36
36
|
}, [
|
|
37
|
+
K,
|
|
37
38
|
q,
|
|
38
|
-
J,
|
|
39
39
|
N,
|
|
40
40
|
P,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
]),
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
57
|
-
|
|
56
|
+
K,
|
|
57
|
+
g.confidenceScore,
|
|
58
58
|
C
|
|
59
|
-
]),
|
|
60
|
-
|
|
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
|
-
|
|
62
|
+
K,
|
|
63
63
|
F,
|
|
64
64
|
C,
|
|
65
|
-
|
|
66
|
-
]), Z =
|
|
67
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
Y,
|
|
70
|
+
S,
|
|
71
|
+
g.confidenceScore,
|
|
72
|
+
g.isExtracted,
|
|
73
|
+
g.targetLocation,
|
|
74
|
+
K,
|
|
75
75
|
C,
|
|
76
|
-
|
|
77
|
-
]),
|
|
78
|
-
C && (i(e.target) || C(
|
|
79
|
-
}, [
|
|
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
|
-
}, [
|
|
85
|
-
|
|
86
|
-
O && (!I || Array.isArray(I) && I.length === 0) &&
|
|
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
|
-
|
|
91
|
-
]),
|
|
92
|
-
A && M &&
|
|
90
|
+
J
|
|
91
|
+
]), f(() => {
|
|
92
|
+
A && M && q(t.Pending);
|
|
93
93
|
}, [
|
|
94
94
|
A,
|
|
95
95
|
M,
|
|
96
|
-
|
|
96
|
+
q
|
|
97
97
|
]);
|
|
98
|
-
let
|
|
99
|
-
if (!
|
|
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:
|
|
105
|
-
onKeyDown:
|
|
106
|
-
onMouseOver:
|
|
107
|
-
onMouseLeave:
|
|
108
|
-
onFocus:
|
|
109
|
-
onBlur:
|
|
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 (
|
|
114
|
-
let t = /* @__PURE__ */
|
|
115
|
-
fieldNamePrefix:
|
|
116
|
-
fieldType:
|
|
117
|
-
isTaxonomyMultiSelect:
|
|
118
|
-
children: /* @__PURE__ */
|
|
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:
|
|
121
|
-
disableForm:
|
|
122
|
-
fieldNamePrefix:
|
|
120
|
+
description: g.description,
|
|
121
|
+
disableForm: l,
|
|
122
|
+
fieldNamePrefix: R,
|
|
123
123
|
isAiSuggestionApplied: !1,
|
|
124
|
-
isExternallyOwned:
|
|
125
|
-
isMultilevelTaxonomyFieldEnabled:
|
|
126
|
-
|
|
127
|
-
|
|
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:
|
|
130
|
-
taxonomyOptionsFetcher:
|
|
131
|
+
portalElement: u,
|
|
132
|
+
taxonomyOptionsFetcher: _
|
|
131
133
|
})
|
|
132
|
-
},
|
|
133
|
-
return
|
|
134
|
+
}, g.key);
|
|
135
|
+
return W ? /* @__PURE__ */ p(c, {
|
|
134
136
|
content: E(e.viewOnDocument),
|
|
135
|
-
open:
|
|
136
|
-
children: /* @__PURE__ */
|
|
137
|
-
className:
|
|
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__ */
|
|
144
|
-
className:
|
|
145
|
-
...
|
|
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__ */
|
|
149
|
+
/* @__PURE__ */ p(j, {
|
|
148
150
|
ref: w,
|
|
149
|
-
className:
|
|
150
|
-
description:
|
|
151
|
-
disableForm:
|
|
152
|
-
fieldNamePrefix:
|
|
153
|
-
isAiSuggestionApplied: k ||
|
|
154
|
-
isExternallyOwned:
|
|
155
|
-
confidenceScore:
|
|
156
|
-
isMultilevelTaxonomyFieldEnabled:
|
|
157
|
-
|
|
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:
|
|
160
|
-
taxonomyOptionsFetcher:
|
|
163
|
+
portalElement: u,
|
|
164
|
+
taxonomyOptionsFetcher: _
|
|
161
165
|
}),
|
|
162
|
-
O && /* @__PURE__ */
|
|
166
|
+
O && /* @__PURE__ */ p(o, {
|
|
163
167
|
aiSuggestion: M,
|
|
164
|
-
confidenceLevel:
|
|
165
|
-
isSameValue:
|
|
168
|
+
confidenceLevel: S ? N?.level : void 0,
|
|
169
|
+
isSameValue: Ce,
|
|
166
170
|
onAiSuggestionAppend: () => {
|
|
167
|
-
|
|
171
|
+
J([...new Set([I, M].flat().filter(Boolean))], !0);
|
|
168
172
|
},
|
|
169
|
-
onAiSuggestionIgnore:
|
|
170
|
-
onAiSuggestionReplace: () =>
|
|
173
|
+
onAiSuggestionIgnore: Y,
|
|
174
|
+
onAiSuggestionReplace: () => J(M, !0),
|
|
171
175
|
type: F
|
|
172
176
|
}),
|
|
173
|
-
!O &&
|
|
174
|
-
onAccept:
|
|
175
|
-
onClear:
|
|
177
|
+
!O && H && /* @__PURE__ */ p(ee, {
|
|
178
|
+
onAccept: X,
|
|
179
|
+
onClear: be
|
|
176
180
|
})
|
|
177
181
|
]
|
|
178
|
-
},
|
|
179
|
-
return
|
|
182
|
+
}, g.key);
|
|
183
|
+
return W ? /* @__PURE__ */ p(c, {
|
|
180
184
|
content: E(e.viewOnDocument),
|
|
181
|
-
open:
|
|
185
|
+
open: G,
|
|
182
186
|
children: $
|
|
183
187
|
}) : $;
|
|
184
188
|
}));
|
|
185
|
-
export {
|
|
189
|
+
export { g as MetadataEditorFieldWrapper };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "../../messages.js";
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
|
10
|
-
import { t as
|
|
11
|
-
import { n as
|
|
12
|
-
import { useEffect as
|
|
13
|
-
import { jsx as
|
|
14
|
-
import
|
|
15
|
-
import { Form as
|
|
16
|
-
import
|
|
17
|
-
var
|
|
18
|
-
let r =
|
|
19
|
-
return e && !
|
|
20
|
-
},
|
|
21
|
-
let { areAiSuggestionsAvailable:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
let
|
|
26
|
-
await I(e,
|
|
27
|
-
},
|
|
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
|
-
},
|
|
29
|
+
}, Z = () => {
|
|
30
30
|
K(!0);
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}, fe = { metadata: { ...j } }, Q = d(null), [$, pe] = f(null);
|
|
32
|
+
l(() => {
|
|
33
|
+
pe(x ?? Q.current);
|
|
34
34
|
}, [
|
|
35
|
-
|
|
35
|
+
x,
|
|
36
36
|
j?.templateKey,
|
|
37
37
|
j?.scope
|
|
38
38
|
]);
|
|
39
|
-
let
|
|
39
|
+
let me = u(() => {
|
|
40
40
|
let e = j?.fields.length === 0;
|
|
41
|
-
if (
|
|
42
|
-
if (e) return /* @__PURE__ */
|
|
43
|
-
isBoxAiSuggestionsFeatureEnabled:
|
|
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 ||
|
|
47
|
-
return /* @__PURE__ */
|
|
48
|
-
className:
|
|
49
|
-
children: [/* @__PURE__ */
|
|
50
|
-
errorCode:
|
|
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__ */
|
|
53
|
+
}), /* @__PURE__ */ p(i, {
|
|
54
54
|
disableForm: q,
|
|
55
55
|
isConfidenceScoreReviewEnabled: V,
|
|
56
56
|
isBoundingBoxEnabled: H,
|
|
57
57
|
isExternallyOwned: j?.isExternallyOwned,
|
|
58
|
-
isMultilevelTaxonomyFieldEnabled:
|
|
58
|
+
isMultilevelTaxonomyFieldEnabled: E,
|
|
59
|
+
isTaxonomyPickerEnabled: D,
|
|
60
|
+
createTaxonomyItemsService: O,
|
|
59
61
|
onSelectMetadataField: U,
|
|
60
62
|
selectedMetadataFieldId: W,
|
|
61
|
-
portalElement:
|
|
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
|
-
|
|
71
|
+
X,
|
|
70
72
|
q,
|
|
71
73
|
J,
|
|
72
|
-
|
|
74
|
+
x,
|
|
73
75
|
$,
|
|
74
76
|
B,
|
|
75
|
-
|
|
77
|
+
w,
|
|
76
78
|
V,
|
|
77
79
|
H,
|
|
80
|
+
E,
|
|
81
|
+
D,
|
|
78
82
|
O,
|
|
79
|
-
|
|
83
|
+
C,
|
|
80
84
|
z,
|
|
81
85
|
U,
|
|
82
86
|
W
|
|
83
87
|
]);
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
-
initialValues:
|
|
86
|
-
onSubmit:
|
|
87
|
-
children: ({ values: e, dirty: t }) => /* @__PURE__ */ g
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
areAiSuggestionsAvailable:
|
|
90
|
-
className:
|
|
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:
|
|
94
|
-
handleCancel:
|
|
95
|
-
handleDelete:
|
|
96
|
-
isAdvancedExtractAgentEnabled:
|
|
97
|
-
isAiSuggestionsFeatureEnabled:
|
|
98
|
-
isBetaLanguageEnabled:
|
|
97
|
+
getAiSuggestions: se,
|
|
98
|
+
handleCancel: de,
|
|
99
|
+
handleDelete: Z,
|
|
100
|
+
isAdvancedExtractAgentEnabled: T,
|
|
101
|
+
isAiSuggestionsFeatureEnabled: w,
|
|
102
|
+
isBetaLanguageEnabled: re,
|
|
99
103
|
isConfidenceScoreReviewEnabled: V,
|
|
100
|
-
isDeleteButtonDisabled:
|
|
104
|
+
isDeleteButtonDisabled: ie,
|
|
101
105
|
isFetchingSuggestions: q,
|
|
102
106
|
isFormDirty: t,
|
|
103
|
-
isLargeFile:
|
|
107
|
+
isLargeFile: S,
|
|
104
108
|
onToggleReviewFilter: L,
|
|
105
109
|
selectedTemplateInstance: j,
|
|
106
110
|
shouldShowOnlyReviewFields: z,
|
|
107
|
-
suggestions:
|
|
108
|
-
children: j &&
|
|
111
|
+
suggestions: ce,
|
|
112
|
+
children: j && me
|
|
109
113
|
}),
|
|
110
|
-
N && /* @__PURE__ */
|
|
114
|
+
N && /* @__PURE__ */ p(y, {
|
|
111
115
|
dirty: t,
|
|
112
116
|
onChange: N,
|
|
113
117
|
values: e
|
|
114
118
|
}),
|
|
115
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ p(a, {
|
|
116
120
|
onBackToEdit: () => R(!1),
|
|
117
121
|
onDiscardChanges: F,
|
|
118
122
|
open: k,
|
|
119
|
-
trackEvent:
|
|
123
|
+
trackEvent: le
|
|
120
124
|
}),
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
isCheckboxEnabled:
|
|
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 {
|
|
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 =
|
|
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 =
|
|
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;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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[];
|