@box/metadata-editor 0.120.19 → 0.120.20
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/metadata-instance-form-card-wrapper.js +27 -28
- package/dist/chunks/utils.js +25 -30
- package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +50 -51
- package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.js +2 -4
- package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/metadata-instance-form-footer.js +17 -18
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.d.ts +0 -1
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/metadata-instance-form-footer.d.ts +1 -1
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/types.d.ts +0 -1
- package/package.json +1 -1
@@ -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",
|
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 = (
|
13
|
+
}, B = (n) => {
|
14
14
|
const {
|
15
|
-
areAiSuggestionsAvailable:
|
16
|
-
children:
|
17
|
-
className:
|
18
|
-
formRef:
|
19
|
-
isAdvancedExtractAgentEnabled:
|
20
|
-
isAiSuggestionsFeatureEnabled:
|
21
|
-
isBetaLanguageEnabled:
|
22
|
-
isLargeFile:
|
23
|
-
isDeleteButtonDisabled:
|
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:
|
26
|
+
isFormDirty: _ = !1,
|
27
27
|
selectedTemplateInstance: a,
|
28
28
|
getAiSuggestions: p,
|
29
29
|
handleCancel: h,
|
30
30
|
handleDelete: f
|
31
|
-
} =
|
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 &&
|
33
|
+
className: e && s.wrapperGradient,
|
34
34
|
children: /* @__PURE__ */ b(E, {
|
35
|
-
ref:
|
36
|
-
className: y(
|
37
|
-
[
|
35
|
+
ref: g,
|
36
|
+
className: y(i, {
|
37
|
+
[s.suggestionsFetching]: e
|
38
38
|
}),
|
39
39
|
children: [/* @__PURE__ */ t(M, {
|
40
|
-
areAiSuggestionsAvailable:
|
40
|
+
areAiSuggestionsAvailable: o,
|
41
41
|
hasSuggestions: C,
|
42
|
-
isAdvancedExtractAgentEnabled:
|
43
|
-
isAiSuggestionsFeatureEnabled:
|
44
|
-
isBetaLanguageEnabled:
|
45
|
-
isLargeFile:
|
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 &&
|
50
|
-
isDeleteButtonDisabled:
|
51
|
-
isFormDirty: s,
|
49
|
+
}), a && r, /* @__PURE__ */ t(w, {
|
50
|
+
isDeleteButtonDisabled: F,
|
52
51
|
isLoading: e,
|
53
|
-
onCancel: () => h(
|
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
|
-
|
60
|
+
s
|
62
61
|
};
|
package/dist/chunks/utils.js
CHANGED
@@ -1,47 +1,42 @@
|
|
1
1
|
import h from "lodash/isEmpty";
|
2
|
-
import
|
3
|
-
import { TEMPLATE_CUSTOM_PROPERTIES as
|
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
|
-
},
|
11
|
-
const
|
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
|
-
(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
})
|
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: `/${
|
29
|
-
value:
|
30
|
-
}), v = (
|
24
|
+
path: `/${e}`,
|
25
|
+
value: a
|
26
|
+
}), v = (e, a) => ({
|
31
27
|
op: n.ADD,
|
32
|
-
path: `/${
|
33
|
-
value:
|
34
|
-
}),
|
28
|
+
path: `/${e}`,
|
29
|
+
value: a
|
30
|
+
}), k = (e) => ({
|
35
31
|
op: n.REMOVE,
|
36
|
-
path: `/${
|
37
|
-
}),
|
32
|
+
path: `/${e}`
|
33
|
+
}), M = (e, a) => ({
|
38
34
|
op: n.REPLACE,
|
39
|
-
path: `/${
|
40
|
-
value:
|
35
|
+
path: `/${e}`,
|
36
|
+
value: a
|
41
37
|
});
|
42
38
|
export {
|
43
39
|
n as J,
|
44
|
-
|
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
|
14
|
-
import { CustomInstance as
|
15
|
-
import {
|
16
|
-
import { s as u, M as
|
17
|
-
import { jsx as
|
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
|
20
|
-
dirty:
|
19
|
+
const so = ({
|
20
|
+
dirty: s,
|
21
21
|
onChange: m,
|
22
22
|
values: r
|
23
23
|
}) => {
|
24
24
|
const n = O(r);
|
25
|
-
return
|
26
|
-
},
|
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:
|
48
|
-
} =
|
47
|
+
taxonomyOptionsFetcher: c
|
48
|
+
} = s, w = k ?? no, [K, h] = S(!1), {
|
49
49
|
isFetchingSuggestions: a,
|
50
|
-
isLongLoading:
|
51
|
-
getAiSuggestions:
|
52
|
-
clearState:
|
53
|
-
suggestions:
|
50
|
+
isLongLoading: C,
|
51
|
+
getAiSuggestions: V,
|
52
|
+
clearState: E,
|
53
|
+
suggestions: W
|
54
54
|
} = T();
|
55
55
|
y(() => () => {
|
56
|
-
|
57
|
-
}, [
|
58
|
-
const F = (o == null ? void 0 : o.templateKey) === I, j = async (
|
59
|
-
await B(
|
60
|
-
}, _ = (
|
61
|
-
|
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
|
-
|
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
|
73
|
+
const t = (o == null ? void 0 : o.fields.length) === 0;
|
75
74
|
if (F)
|
76
|
-
return /* @__PURE__ */
|
75
|
+
return /* @__PURE__ */ i(io, {
|
77
76
|
isLoading: a
|
78
77
|
});
|
79
|
-
if (
|
80
|
-
return /* @__PURE__ */
|
78
|
+
if (t)
|
79
|
+
return /* @__PURE__ */ i(ro, {
|
81
80
|
isBoxAiSuggestionsFeatureEnabled: f,
|
82
81
|
level: "instance"
|
83
82
|
});
|
84
|
-
const
|
83
|
+
const e = !!(a || l);
|
85
84
|
return /* @__PURE__ */ D("div", {
|
86
|
-
className: H(u.metadataInstanceFormContent,
|
87
|
-
children: [/* @__PURE__ */
|
85
|
+
className: H(u.metadataInstanceFormContent, e && u.showOverlay),
|
86
|
+
children: [/* @__PURE__ */ i(to, {
|
88
87
|
errorCode: l,
|
89
88
|
isFetchingSuggestions: a,
|
90
|
-
isLongLoading:
|
91
|
-
}), /* @__PURE__ */
|
89
|
+
isLongLoading: C
|
90
|
+
}), /* @__PURE__ */ i(oo, {
|
92
91
|
disableForm: a,
|
93
92
|
isMultilevelTaxonomyFieldEnabled: d,
|
94
93
|
portalElement: r ?? b,
|
95
|
-
taxonomyOptionsFetcher:
|
94
|
+
taxonomyOptionsFetcher: c
|
96
95
|
})]
|
97
96
|
});
|
98
|
-
}, [o == null ? void 0 : o.fields.length, F, a,
|
99
|
-
return /* @__PURE__ */
|
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:
|
104
|
-
dirty:
|
102
|
+
values: t,
|
103
|
+
dirty: e
|
105
104
|
}) => /* @__PURE__ */ D(X, {
|
106
|
-
children: [/* @__PURE__ */
|
105
|
+
children: [/* @__PURE__ */ i(w, {
|
107
106
|
areAiSuggestionsAvailable: m,
|
108
107
|
className: u.metadataInstanceForm,
|
109
108
|
formRef: M,
|
110
|
-
formValues:
|
111
|
-
getAiSuggestions:
|
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:
|
118
|
+
isFormDirty: e,
|
120
119
|
isLargeFile: n,
|
121
120
|
selectedTemplateInstance: o,
|
122
|
-
suggestions:
|
121
|
+
suggestions: W,
|
123
122
|
children: o && z
|
124
|
-
}), g && /* @__PURE__ */
|
125
|
-
dirty:
|
123
|
+
}), g && /* @__PURE__ */ i(so, {
|
124
|
+
dirty: e,
|
126
125
|
onChange: g,
|
127
|
-
values:
|
128
|
-
}), /* @__PURE__ */
|
126
|
+
values: t
|
127
|
+
}), /* @__PURE__ */ i(eo, {
|
129
128
|
onBackToEdit: () => p(!1),
|
130
129
|
onDiscardChanges: U,
|
131
130
|
open: R
|
132
|
-
}), /* @__PURE__ */
|
131
|
+
}), /* @__PURE__ */ i(G, {
|
133
132
|
isCheckboxEnabled: L,
|
134
133
|
onConfirm: () => P(o),
|
135
|
-
onDismiss: () =>
|
136
|
-
open:
|
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
|
-
|
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,
|
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
|
-
|
9
|
-
p as getFormatedFieldValue
|
7
|
+
i as getFormatedFieldValue
|
10
8
|
};
|
@@ -1,30 +1,29 @@
|
|
1
|
-
import { TextButton as
|
2
|
-
import { useFormikContext as
|
3
|
-
import { useIntl as
|
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
|
7
|
-
metadataInstanceFormFooter:
|
8
|
-
buttonsContainer:
|
9
|
-
buttons:
|
10
|
-
},
|
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:
|
14
|
+
onDelete: l
|
16
15
|
}) => {
|
17
|
-
const t =
|
16
|
+
const t = B(), {
|
18
17
|
isSubmitting: s,
|
19
|
-
submitForm:
|
20
|
-
} =
|
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(
|
24
|
+
children: [/* @__PURE__ */ e(b, {
|
26
25
|
disabled: a || d,
|
27
|
-
onClick:
|
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
|
39
|
+
disabled: a,
|
41
40
|
loading: s,
|
42
41
|
loadingAriaLabel: t.formatMessage(o.loadingAriaLabel),
|
43
|
-
onClick:
|
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
|
-
|
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,
|
2
|
+
export declare const MetadataInstanceFormFooter: ({ isDeleteButtonDisabled, isLoading, onCancel, onDelete, }: MetadataInstanceFormFooterProps) => import("react/jsx-runtime").JSX.Element;
|