@box/metadata-editor 0.68.0 → 0.69.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.
- package/esm/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.js +19 -19
- package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.js +18 -17
- package/esm/lib/components/metadata-instance-list/subcomponents/metadata-instance/metadata-instance.js +32 -32
- package/package.json +2 -2
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.d.ts +2 -1
- package/types/lib/test-utils/sample-data.d.ts +4 -1
@@ -1,6 +1,6 @@
|
|
1
|
-
import
|
2
|
-
import { useFormikContext as
|
3
|
-
import
|
1
|
+
import I from "clsx";
|
2
|
+
import { useFormikContext as V } from "formik";
|
3
|
+
import k from "lodash/isUndefined";
|
4
4
|
import { forwardRef as E, useState as y } from "react";
|
5
5
|
import { AiSuggestionField as P } from "./components/ai-suggestion-field/ai-suggestion-field.js";
|
6
6
|
import { UpdateModeFieldWrapper as R } from "./components/update-mode-field-wrapper/update-mode-field-wrapper.js";
|
@@ -8,8 +8,8 @@ import { editorFieldTypes as T } from "./editor-field-types.js";
|
|
8
8
|
import { s as i } from "../../../../chunks/utils.js";
|
9
9
|
import { jsx as o, jsxs as U } from "react/jsx-runtime";
|
10
10
|
const H = /* @__PURE__ */ E(({
|
11
|
-
disableForm:
|
12
|
-
portalElement:
|
11
|
+
disableForm: d,
|
12
|
+
portalElement: l,
|
13
13
|
field: e,
|
14
14
|
index: h,
|
15
15
|
taxonomyOptionsFetcher: u
|
@@ -17,11 +17,11 @@ const H = /* @__PURE__ */ E(({
|
|
17
17
|
var A;
|
18
18
|
const {
|
19
19
|
setFieldValue: m
|
20
|
-
} =
|
21
|
-
aiSuggestion:
|
20
|
+
} = V(), [x, n] = y(!0), [a, p] = y(!1), r = T[e.type], {
|
21
|
+
aiSuggestion: s,
|
22
22
|
type: c,
|
23
23
|
value: F
|
24
|
-
} = e, M = r && !e.hidden, N = !
|
24
|
+
} = e, M = r && !e.hidden, N = !k(e.updateMode), t = `metadata.fields[${h}]`, W = e.type === "taxonomy" && ((A = e.optionsRules) == null ? void 0 : A.multiSelect), S = s && x, v = I({
|
25
25
|
[i.suggestionApplied]: a,
|
26
26
|
[i.hasSuggestion]: S,
|
27
27
|
[i.dateField]: c === "date"
|
@@ -32,18 +32,18 @@ const H = /* @__PURE__ */ E(({
|
|
32
32
|
a && p(!1);
|
33
33
|
};
|
34
34
|
return N ? /* @__PURE__ */ o(R, {
|
35
|
-
fieldNamePrefix:
|
35
|
+
fieldNamePrefix: t,
|
36
36
|
fieldType: e.type,
|
37
37
|
isTaxonomyMultiSelect: W,
|
38
38
|
children: /* @__PURE__ */ o(r, {
|
39
39
|
ref: g,
|
40
40
|
description: e.description,
|
41
|
-
disableForm:
|
42
|
-
fieldNamePrefix:
|
41
|
+
disableForm: d,
|
42
|
+
fieldNamePrefix: t,
|
43
43
|
isAiSuggestionApplied: !1,
|
44
44
|
label: e.displayName,
|
45
45
|
onValueEdited: f,
|
46
|
-
portalElement:
|
46
|
+
portalElement: l,
|
47
47
|
taxonomyOptionsFetcher: u
|
48
48
|
})
|
49
49
|
}, e.key) : /* @__PURE__ */ U("div", {
|
@@ -52,22 +52,22 @@ const H = /* @__PURE__ */ E(({
|
|
52
52
|
ref: g,
|
53
53
|
className: v,
|
54
54
|
description: e.description,
|
55
|
-
disableForm:
|
56
|
-
fieldNamePrefix:
|
55
|
+
disableForm: d,
|
56
|
+
fieldNamePrefix: t,
|
57
57
|
isAiSuggestionApplied: a,
|
58
58
|
label: e.displayName,
|
59
59
|
onValueEdited: f,
|
60
|
-
portalElement:
|
60
|
+
portalElement: l,
|
61
61
|
taxonomyOptionsFetcher: u
|
62
62
|
}), S && /* @__PURE__ */ o(P, {
|
63
|
-
aiSuggestion:
|
63
|
+
aiSuggestion: s,
|
64
64
|
onAiSuggestionAppend: () => {
|
65
|
-
const
|
66
|
-
m(`${
|
65
|
+
const w = [...new Set([F, s].flat())];
|
66
|
+
m(`${t}.value`, w), n(!1), p(!0);
|
67
67
|
},
|
68
68
|
onAiSuggestionIgnore: () => n(!1),
|
69
69
|
onAiSuggestionReplace: () => {
|
70
|
-
m(`${
|
70
|
+
m(`${t}.value`, s), n(!1), p(!0);
|
71
71
|
},
|
72
72
|
type: c
|
73
73
|
})]
|
package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.js
CHANGED
@@ -6,35 +6,36 @@ const n = {
|
|
6
6
|
REMOVE: "remove",
|
7
7
|
REPLACE: "replace",
|
8
8
|
TEST: "test"
|
9
|
-
}, p = (e) => e.value === void 0 || e.value === null || e.value === "" || O(e.value) && h(e.value), S = (e,
|
10
|
-
const o = [], c = e.metadata.fields, r =
|
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]));
|
11
11
|
return c.forEach((t) => {
|
12
|
-
const
|
13
|
-
|
12
|
+
const s = E.get(t.key);
|
13
|
+
s ? JSON.stringify(t) === JSON.stringify(s) || (!r && p(s) && !p(t) ? o.push(v(t.key, u(t))) : (
|
14
14
|
// template instance
|
15
|
-
(!r && t.value !==
|
16
|
-
r && t.value !==
|
17
|
-
)) : o.push(
|
18
|
-
}),
|
19
|
-
const
|
20
|
-
(!
|
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
21
|
}), o;
|
22
|
-
}, u = (e) => e.type === "float" ? Number(e.value) : e.value,
|
22
|
+
}, u = (e) => e.type === "float" ? Number(e.value) : e.type === "taxonomy" ? e.value.map((a) => a.value) : e.value, y = (e, a) => ({
|
23
23
|
op: n.TEST,
|
24
24
|
path: `/${e}`,
|
25
|
-
value:
|
26
|
-
}),
|
25
|
+
value: a
|
26
|
+
}), v = (e, a) => ({
|
27
27
|
op: n.ADD,
|
28
28
|
path: `/${e}`,
|
29
|
-
value:
|
29
|
+
value: a
|
30
30
|
}), k = (e) => ({
|
31
31
|
op: n.REMOVE,
|
32
32
|
path: `/${e}`
|
33
|
-
}), M = (e,
|
33
|
+
}), M = (e, a) => ({
|
34
34
|
op: n.REPLACE,
|
35
35
|
path: `/${e}`,
|
36
|
-
value:
|
36
|
+
value: a
|
37
37
|
});
|
38
38
|
export {
|
39
|
-
S as createJSONPatch
|
39
|
+
S as createJSONPatch,
|
40
|
+
u as getFormatedFieldValue
|
40
41
|
};
|
@@ -1,50 +1,50 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance.css";
|
2
|
-
import { Card as
|
3
|
-
import { useState as
|
4
|
-
import { useAutofill as
|
5
|
-
import { MetadataEmptyState as
|
6
|
-
import { MetadataInstanceContent as
|
7
|
-
import { MetadataInstanceFooter as
|
2
|
+
import { Card as V, Divider as n } from "@box/blueprint-web";
|
3
|
+
import { useState as A } from "react";
|
4
|
+
import { useAutofill as D } from "../../../../utils/autofill-context.js";
|
5
|
+
import { MetadataEmptyState as S } from "../../../metadata-empty-state/metadata-empty-state.js";
|
6
|
+
import { MetadataInstanceContent as b } from "../metadata-instance-content/metadata-instance-content.js";
|
7
|
+
import { MetadataInstanceFooter as g } from "../metadata-instance-footer/metadata-instance-footer.js";
|
8
8
|
import { MetadataInstanceHeader as H } from "../metadata-instance-header/metadata-instance-header.js";
|
9
|
-
import { jsxs as
|
10
|
-
const _ = "_topDivider_tzhlb_1",
|
9
|
+
import { jsxs as a, jsx as t, Fragment as u } from "react/jsx-runtime";
|
10
|
+
const _ = "_topDivider_tzhlb_1", M = "_bottomDivider_tzhlb_5", y = {
|
11
11
|
topDivider: _,
|
12
|
-
bottomDivider:
|
13
|
-
},
|
12
|
+
bottomDivider: M
|
13
|
+
}, W = ({
|
14
14
|
areAiSuggestionsAvailable: p,
|
15
|
-
isAiSuggestionsFeatureEnabled:
|
15
|
+
isAiSuggestionsFeatureEnabled: d,
|
16
16
|
onEdit: m,
|
17
17
|
templateInstance: o
|
18
18
|
}) => {
|
19
|
-
const
|
20
|
-
getAiSuggestions:
|
21
|
-
} =
|
22
|
-
m(o),
|
19
|
+
const e = o.fields, l = (s) => !s.value || Array.isArray(s.value) && s.value.length === 0, c = e.every(l), h = e.some(l), v = e.length > 0, [i, r] = A(!0), {
|
20
|
+
getAiSuggestions: E
|
21
|
+
} = D(), f = () => {
|
22
|
+
m(o), E(o.templateKey, e);
|
23
23
|
};
|
24
|
-
return /* @__PURE__ */
|
24
|
+
return /* @__PURE__ */ a(V, {
|
25
25
|
children: [/* @__PURE__ */ t(H, {
|
26
26
|
areAiSuggestionsAvailable: p,
|
27
27
|
canEdit: o.canEdit,
|
28
|
-
isAiSuggestionsFeatureEnabled:
|
29
|
-
onAutofill:
|
28
|
+
isAiSuggestionsFeatureEnabled: d,
|
29
|
+
onAutofill: f,
|
30
30
|
onEdit: () => m(o),
|
31
31
|
templateName: o == null ? void 0 : o.displayName
|
32
|
-
}), /* @__PURE__ */ t(
|
33
|
-
className:
|
34
|
-
}),
|
35
|
-
isAnyEmptyValueHidden:
|
36
|
-
isBoxAiSuggestionsFeatureEnabled:
|
32
|
+
}), /* @__PURE__ */ t(n, {
|
33
|
+
className: y.topDivider
|
34
|
+
}), i && c ? /* @__PURE__ */ t(S, {
|
35
|
+
isAnyEmptyValueHidden: v,
|
36
|
+
isBoxAiSuggestionsFeatureEnabled: d,
|
37
37
|
level: "instance",
|
38
38
|
onShowEmptyValues: () => r(!1)
|
39
|
-
}) : /* @__PURE__ */
|
40
|
-
children: [/* @__PURE__ */ t(
|
41
|
-
shouldHideEmptyValues:
|
39
|
+
}) : /* @__PURE__ */ a(u, {
|
40
|
+
children: [/* @__PURE__ */ t(b, {
|
41
|
+
shouldHideEmptyValues: i,
|
42
42
|
templateInstance: o
|
43
|
-
}),
|
44
|
-
children: [/* @__PURE__ */ t(
|
45
|
-
className:
|
46
|
-
}), /* @__PURE__ */ t(
|
47
|
-
isAnyEmptyValueHidden:
|
43
|
+
}), h && /* @__PURE__ */ a(u, {
|
44
|
+
children: [/* @__PURE__ */ t(n, {
|
45
|
+
className: y.bottomDivider
|
46
|
+
}), /* @__PURE__ */ t(g, {
|
47
|
+
isAnyEmptyValueHidden: i,
|
48
48
|
onHideEmptyValues: () => r(!0),
|
49
49
|
onShowEmptyValues: () => r(!1)
|
50
50
|
})]
|
@@ -53,5 +53,5 @@ const _ = "_topDivider_tzhlb_1", g = "_bottomDivider_tzhlb_5", n = {
|
|
53
53
|
});
|
54
54
|
};
|
55
55
|
export {
|
56
|
-
|
56
|
+
W as MetadataInstance
|
57
57
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.69.0",
|
4
4
|
"peerDependencies": {
|
5
5
|
"@ariakit/react": "0.4.5",
|
6
6
|
"@box/blueprint-web": "^7.30.3",
|
@@ -53,5 +53,5 @@
|
|
53
53
|
"**/*.css"
|
54
54
|
],
|
55
55
|
"license": "SEE LICENSE IN LICENSE",
|
56
|
-
"gitHead": "
|
56
|
+
"gitHead": "cb2d8bc467948346206919d6efae781b79e70aaf"
|
57
57
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type MetadataTemplateInstance } from '../../../../types';
|
1
|
+
import { type MetadataFormFieldValue, type MetadataTemplateField, type MetadataTemplateInstance } from '../../../../types';
|
2
2
|
import { type FormValues } from '../../types';
|
3
3
|
import { type JSONPatchOperations } from './types';
|
4
4
|
/**
|
@@ -10,3 +10,4 @@ import { type JSONPatchOperations } from './types';
|
|
10
10
|
* @param originalData
|
11
11
|
*/
|
12
12
|
export declare const createJSONPatch: (formValues: FormValues, originalData: MetadataTemplateInstance) => JSONPatchOperations;
|
13
|
+
export declare const getFormatedFieldValue: (field: MetadataTemplateField) => MetadataFormFieldValue;
|
@@ -6,6 +6,8 @@ declare const floatField: MetadataTemplateField;
|
|
6
6
|
declare const multiSelectField: MetadataTemplateField;
|
7
7
|
declare const taxonomySingleSelectSingleLevelField: MetadataTemplateField;
|
8
8
|
declare const taxonomyMultiSelectSingleLevelField: MetadataTemplateField;
|
9
|
+
declare const taxonomySingleSelectSingleLevelFieldWithValue: MetadataTemplateField;
|
10
|
+
declare const taxonomyMultiSelectSingleLevelFieldWithValue: MetadataTemplateField;
|
9
11
|
declare const hiddenField: MetadataTemplateField;
|
10
12
|
declare const noValueField: MetadataTemplateField;
|
11
13
|
declare const allFieldsTemplate: MetadataTemplate;
|
@@ -16,6 +18,7 @@ declare const templates: MetadataTemplate[];
|
|
16
18
|
declare const customTemplate: MetadataTemplate;
|
17
19
|
declare const templateOptions: MetadataTemplateOption[];
|
18
20
|
declare const fields: MetadataTemplateField[];
|
21
|
+
declare const floatInstanceField: MetadataTemplateField;
|
19
22
|
declare const allFieldsTemplateInstance: MetadataTemplateInstance;
|
20
23
|
declare const templateInstanceWithoutEmptyValues: MetadataTemplateInstance;
|
21
24
|
declare const emptyTemplateInstance: MetadataTemplateInstance;
|
@@ -35,4 +38,4 @@ declare const firstTemplateInstanceFieldsWithSuggestions: MetadataTemplateField[
|
|
35
38
|
declare const secondTemplateInstance: MetadataTemplate;
|
36
39
|
declare const secondTemplateSuggestions: AutofillSuggestions;
|
37
40
|
declare const secondTemplateInstanceFieldsWithSuggestions: MetadataTemplateField[];
|
38
|
-
export { allFieldsSuggestions, allFieldsTemplate, allFieldsTemplateInstance, allFieldsWithAiSuggestions, customTemplate, customTemplateInstance, customTemplateInstanceWithAllFieldsEmpty, customTemplateInstanceWithoutEditPermissions, customTemplateInstanceWithoutEmptyValues, dateField, emptyCustomTemplateInstance, emptyTemplateInstance, enumField, fields, firstTemplateInstance, firstTemplateInstanceFieldsWithSuggestions, firstTemplateSuggestions, floatField, hiddenField, multiSelectField, noFieldsTemplate, nonHiddenFieldsTemplate, nonHiddenFieldsWithValuesTemplate, noValueField, secondTemplateInstance, secondTemplateInstanceFieldsWithSuggestions, secondTemplateSuggestions, stringField, taxonomyMultiSelectSingleLevelField, taxonomySingleSelectSingleLevelField, templateInstancesList, templateInstanceWithAllFieldsEmpty, templateInstanceWithoutEditPermissions, templateInstanceWithoutEmptyValues, templateOptions, templates, };
|
41
|
+
export { allFieldsSuggestions, allFieldsTemplate, allFieldsTemplateInstance, allFieldsWithAiSuggestions, customTemplate, customTemplateInstance, customTemplateInstanceWithAllFieldsEmpty, customTemplateInstanceWithoutEditPermissions, customTemplateInstanceWithoutEmptyValues, dateField, emptyCustomTemplateInstance, emptyTemplateInstance, enumField, fields, firstTemplateInstance, firstTemplateInstanceFieldsWithSuggestions, firstTemplateSuggestions, floatField, floatInstanceField, hiddenField, multiSelectField, noFieldsTemplate, nonHiddenFieldsTemplate, nonHiddenFieldsWithValuesTemplate, noValueField, secondTemplateInstance, secondTemplateInstanceFieldsWithSuggestions, secondTemplateSuggestions, stringField, taxonomyMultiSelectSingleLevelField, taxonomyMultiSelectSingleLevelFieldWithValue, taxonomySingleSelectSingleLevelField, taxonomySingleSelectSingleLevelFieldWithValue, templateInstancesList, templateInstanceWithAllFieldsEmpty, templateInstanceWithoutEditPermissions, templateInstanceWithoutEmptyValues, templateOptions, templates, };
|