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