@box/metadata-editor 0.78.9 → 0.79.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 (33) hide show
  1. package/chunks/utils.js +40 -41
  2. package/chunks/utils2.js +43 -0
  3. package/esm/index.js +34 -30
  4. package/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +1 -1
  5. package/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +1 -1
  6. package/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +1 -1
  7. package/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +1 -1
  8. package/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +1 -1
  9. package/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +1 -1
  10. package/esm/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.js +1 -1
  11. package/esm/lib/components/metadata-editor-fields/metadata-editor-fields.js +1 -1
  12. package/esm/lib/components/metadata-editor-fields/utils.js +1 -1
  13. package/esm/lib/components/metadata-instance-editor/index.js +12 -8
  14. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form-card-wrapper.js +40 -0
  15. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +85 -86
  16. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.js +6 -39
  17. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/messages.js +18 -0
  18. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js +68 -0
  19. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/messages.js +0 -12
  20. package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js +26 -61
  21. package/i18n/json/src/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/messages.json +1 -0
  22. package/i18n/json/src/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/messages.json +1 -1
  23. package/package.json +3 -3
  24. package/styles/metadata-instance-form-autofill-button.css +1 -0
  25. package/types/lib/components/metadata-instance-editor/index.d.ts +3 -1
  26. package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form-card-wrapper.d.ts +2 -0
  27. package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +20 -3
  28. package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/messages.d.ts +18 -0
  29. package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.d.ts +2 -0
  30. package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/types.d.ts +7 -0
  31. package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/messages.d.ts +0 -15
  32. package/types/lib/types.d.ts +0 -1
  33. package/types/lib/utils/autofill-context.d.ts +1 -1
package/chunks/utils.js CHANGED
@@ -1,43 +1,42 @@
1
- import "../styles/utils.css";
2
- import { BoxAiLogo as s } from "@box/blueprint-web-assets/icons/Logo";
3
- import g from "../esm/lib/components/interactive-text/interactive-text.js";
4
- import { convertISOStringToUTCDate as i } from "../esm/lib/utils/convertDate.js";
5
- import { jsxs as c, jsx as o } from "react/jsx-runtime";
6
- const _ = "_noAttributesText_1ggnw_1", p = "_fieldWrapper_1ggnw_5", b = "_hasSuggestion_1ggnw_10", x = "_error_1ggnw_18", d = "_dateField_1ggnw_30", m = "_suggestionApplied_1ggnw_34", u = "_comboboxContainer_1ggnw_34", T = "_labelWrapper_1ggnw_48", w = "_labelText_1ggnw_54", S = "_labelIcon_1ggnw_57", t = {
7
- noAttributesText: _,
8
- fieldWrapper: p,
9
- hasSuggestion: b,
10
- error: x,
11
- dateField: d,
12
- suggestionApplied: m,
13
- comboboxContainer: u,
14
- labelWrapper: T,
15
- labelText: w,
16
- labelIcon: S
17
- }, C = (e, n, l = !1, a = "label") => (r) => /* @__PURE__ */ c("div", {
18
- className: t.labelWrapper,
19
- children: [n ? /* @__PURE__ */ o(g, {
20
- as: a,
21
- className: t.labelText,
22
- tooltipText: n,
23
- ...r,
24
- children: e
25
- }) : /* @__PURE__ */ o("label", {
26
- className: t.labelText,
27
- ...r,
28
- children: e
29
- }), l && /* @__PURE__ */ o(s, {
30
- className: t.labelIcon
31
- })]
32
- }), F = (e) => {
33
- try {
34
- return i(e).toISOString();
35
- } catch {
36
- return null;
37
- }
38
- };
1
+ import h from "lodash/isEmpty";
2
+ import O from "lodash/isArray";
3
+ import { TEMPLATE_CUSTOM_PROPERTIES as f } from "../esm/lib/constants.js";
4
+ const n = {
5
+ ADD: "add",
6
+ REMOVE: "remove",
7
+ REPLACE: "replace",
8
+ TEST: "test"
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
+ return c.forEach((t) => {
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
+ // 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) => ({
23
+ op: n.TEST,
24
+ path: `/${e}`,
25
+ value: a
26
+ }), v = (e, a) => ({
27
+ op: n.ADD,
28
+ path: `/${e}`,
29
+ value: a
30
+ }), k = (e) => ({
31
+ op: n.REMOVE,
32
+ path: `/${e}`
33
+ }), M = (e, a) => ({
34
+ op: n.REPLACE,
35
+ path: `/${e}`,
36
+ value: a
37
+ });
39
38
  export {
40
- C as g,
41
- t as s,
42
- F as t
39
+ n as J,
40
+ S as c,
41
+ u as g
43
42
  };
@@ -0,0 +1,43 @@
1
+ import "../styles/utils.css";
2
+ import { BoxAiLogo as s } from "@box/blueprint-web-assets/icons/Logo";
3
+ import g from "../esm/lib/components/interactive-text/interactive-text.js";
4
+ import { convertISOStringToUTCDate as i } from "../esm/lib/utils/convertDate.js";
5
+ import { jsxs as c, jsx as o } from "react/jsx-runtime";
6
+ const _ = "_noAttributesText_1ggnw_1", p = "_fieldWrapper_1ggnw_5", b = "_hasSuggestion_1ggnw_10", x = "_error_1ggnw_18", d = "_dateField_1ggnw_30", m = "_suggestionApplied_1ggnw_34", u = "_comboboxContainer_1ggnw_34", T = "_labelWrapper_1ggnw_48", w = "_labelText_1ggnw_54", S = "_labelIcon_1ggnw_57", t = {
7
+ noAttributesText: _,
8
+ fieldWrapper: p,
9
+ hasSuggestion: b,
10
+ error: x,
11
+ dateField: d,
12
+ suggestionApplied: m,
13
+ comboboxContainer: u,
14
+ labelWrapper: T,
15
+ labelText: w,
16
+ labelIcon: S
17
+ }, C = (e, n, l = !1, a = "label") => (r) => /* @__PURE__ */ c("div", {
18
+ className: t.labelWrapper,
19
+ children: [n ? /* @__PURE__ */ o(g, {
20
+ as: a,
21
+ className: t.labelText,
22
+ tooltipText: n,
23
+ ...r,
24
+ children: e
25
+ }) : /* @__PURE__ */ o("label", {
26
+ className: t.labelText,
27
+ ...r,
28
+ children: e
29
+ }), l && /* @__PURE__ */ o(s, {
30
+ className: t.labelIcon
31
+ })]
32
+ }), F = (e) => {
33
+ try {
34
+ return i(e).toISOString();
35
+ } catch {
36
+ return null;
37
+ }
38
+ };
39
+ export {
40
+ C as g,
41
+ t as s,
42
+ F as t
43
+ };
package/esm/index.js CHANGED
@@ -1,39 +1,43 @@
1
- import { AddMetadataTemplateDropdown as o } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
1
+ import { AddMetadataTemplateDropdown as e } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
2
2
  import { ComboboxWithApiPagination as r } from "./lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js";
3
- import { FilterDropdownMenu as d } from "./lib/components/filter-dropdown-menu/index.js";
4
- import { FilterInstancesDropdown as m } from "./lib/components/filter-instances-dropdown/filter-instances-dropdown.js";
3
+ import { FilterDropdownMenu as n } from "./lib/components/filter-dropdown-menu/index.js";
4
+ import { FilterInstancesDropdown as d } from "./lib/components/filter-instances-dropdown/filter-instances-dropdown.js";
5
5
  import { MetadataEmptyState as x } from "./lib/components/metadata-empty-state/metadata-empty-state.js";
6
- import { DeleteConfirmationModal as l } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
7
- import { MetadataInstanceFormHeader as M } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
8
- import { CustomInstanceNewField as I } from "./lib/components/metadata-instance-editor/subcomponents/custom-instance-new-field/custom-instance-new-field.js";
9
- import { MetadataInstanceForm as A } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
10
- import { MetadataInstanceList as w } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
11
- import { MetadataInstanceHeader as D } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
12
- import { UnsavedChangesModal as U } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
13
- import { defaultInitialValues as g, defaultMetadataValueMap as v } from "./lib/defaults.js";
14
- import { MetadataEditor as H } from "./lib/metadata-editor.js";
6
+ import { CustomInstanceNewField as l } from "./lib/components/metadata-instance-editor/subcomponents/custom-instance-new-field/custom-instance-new-field.js";
7
+ import { DeleteConfirmationModal as M } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
8
+ import { MetadataInstanceFormAutofillButton as c } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js";
9
+ import { MetadataInstanceFormHeader as A } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
10
+ import { MetadataInstanceForm as F } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
11
+ import { J as h } from "../chunks/utils.js";
12
+ import { MetadataInstanceList as P } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
13
+ import { MetadataInstanceHeader as b } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
14
+ import { UnsavedChangesModal as v } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
15
+ import { defaultInitialValues as H, defaultMetadataValueMap as J } from "./lib/defaults.js";
16
+ import { MetadataEditor as O } from "./lib/metadata-editor.js";
15
17
  import { U as V } from "../chunks/types.js";
16
- import { AutofillContext as y, AutofillContextProvider as L, useAutofill as N } from "./lib/utils/autofill-context.js";
17
- import { withApiWrapper as T } from "./lib/utils/api-wrapper.js";
18
+ import { AutofillContext as y, AutofillContextProvider as B, useAutofill as L } from "./lib/utils/autofill-context.js";
19
+ import { withApiWrapper as j } from "./lib/utils/api-wrapper.js";
18
20
  export {
19
- o as AddMetadataTemplateDropdown,
21
+ e as AddMetadataTemplateDropdown,
20
22
  y as AutofillContext,
21
- L as AutofillContextProvider,
23
+ B as AutofillContextProvider,
22
24
  r as ComboboxWithApiPagination,
23
- I as CustomInstanceNewField,
24
- l as DeleteConfirmationModal,
25
- d as FilterDropdownMenu,
26
- m as FilterInstancesDropdown,
27
- H as MetadataEditor,
25
+ l as CustomInstanceNewField,
26
+ M as DeleteConfirmationModal,
27
+ n as FilterDropdownMenu,
28
+ d as FilterInstancesDropdown,
29
+ h as JSONPatchOp,
30
+ O as MetadataEditor,
28
31
  x as MetadataEmptyState,
29
- A as MetadataInstanceForm,
30
- M as MetadataInstanceFormHeader,
31
- D as MetadataInstanceHeader,
32
- w as MetadataInstanceList,
33
- U as UnsavedChangesModal,
32
+ F as MetadataInstanceForm,
33
+ c as MetadataInstanceFormAutofillButton,
34
+ A as MetadataInstanceFormHeader,
35
+ b as MetadataInstanceHeader,
36
+ P as MetadataInstanceList,
37
+ v as UnsavedChangesModal,
34
38
  V as UpdateMode,
35
- g as defaultInitialValues,
36
- v as defaultMetadataValueMap,
37
- N as useAutofill,
38
- T as withApiWrapper
39
+ H as defaultInitialValues,
40
+ J as defaultMetadataValueMap,
41
+ L as useAutofill,
42
+ j as withApiWrapper
39
43
  };
@@ -4,7 +4,7 @@ import { forwardRef as w, useMemo as S } from "react";
4
4
  import { useIntl as V } from "react-intl";
5
5
  import { convertIsoStringToCalendarDate as N, convertCalendarDateToISOString as O } from "../../../../utils/convertDate.js";
6
6
  import a from "../../../../messages.js";
7
- import { g as B } from "../../../../../../chunks/utils.js";
7
+ import { g as B } from "../../../../../../chunks/utils2.js";
8
8
  import { jsx as t } from "react/jsx-runtime";
9
9
  const H = /* @__PURE__ */ w(({
10
10
  className: i,
@@ -3,7 +3,7 @@ import { useFormikContext as C, getIn as L, Field as P } from "formik";
3
3
  import { forwardRef as $ } from "react";
4
4
  import { useIntl as b, FormattedMessage as j } from "react-intl";
5
5
  import d from "../../../../messages.js";
6
- import { g as w } from "../../../../../../chunks/utils.js";
6
+ import { g as w } from "../../../../../../chunks/utils2.js";
7
7
  import { jsx as t, jsxs as I } from "react/jsx-runtime";
8
8
  const U = /* @__PURE__ */ $(({
9
9
  className: i,
@@ -1,7 +1,7 @@
1
1
  import { TextInput as T } from "@box/blueprint-web";
2
2
  import { useFormikContext as V, getIn as $, Field as b } from "formik";
3
3
  import { forwardRef as B, useRef as I } from "react";
4
- import { g as M } from "../../../../../../chunks/utils.js";
4
+ import { g as M } from "../../../../../../chunks/utils2.js";
5
5
  import { fieldDefaultProps as O } from "../constants.js";
6
6
  import { useFloatValidation as j } from "./use-float-validation.js";
7
7
  import { jsx as r } from "react/jsx-runtime";
@@ -3,7 +3,7 @@ import { useFormikContext as x, getIn as M, Field as $ } from "formik";
3
3
  import { forwardRef as I } from "react";
4
4
  import { useIntl as j } from "react-intl";
5
5
  import k from "../../../../messages.js";
6
- import { g as D } from "../../../../../../chunks/utils.js";
6
+ import { g as D } from "../../../../../../chunks/utils2.js";
7
7
  import { fieldDefaultProps as O } from "../constants.js";
8
8
  import { jsx as t } from "react/jsx-runtime";
9
9
  const E = /* @__PURE__ */ I(({
@@ -3,7 +3,7 @@ import { Field as g } from "formik";
3
3
  import { forwardRef as h } from "react";
4
4
  import { useIntl as F } from "react-intl";
5
5
  import x from "../../../../messages.js";
6
- import { g as M } from "../../../../../../chunks/utils.js";
6
+ import { g as M } from "../../../../../../chunks/utils2.js";
7
7
  import { fieldDefaultProps as b } from "../constants.js";
8
8
  import { jsx as e } from "react/jsx-runtime";
9
9
  const v = /* @__PURE__ */ h(({
@@ -3,7 +3,7 @@ import { forwardRef as $ } from "react";
3
3
  import { useIntl as j } from "react-intl";
4
4
  import w from "../../../../messages.js";
5
5
  import { ComboboxWithApiPagination as A } from "../../../combobox-with-api-pagination/combobox-with-api-pagination.js";
6
- import { g as K } from "../../../../../../chunks/utils.js";
6
+ import { g as K } from "../../../../../../chunks/utils2.js";
7
7
  import { jsx as e } from "react/jsx-runtime";
8
8
  const E = /* @__PURE__ */ $(({
9
9
  description: l,
@@ -5,7 +5,7 @@ import { forwardRef as P, useState as N, useCallback as R, useEffect as T, useMe
5
5
  import { AiSuggestionField as b } from "./components/ai-suggestion-field/ai-suggestion-field.js";
6
6
  import { UpdateModeFieldWrapper as j } from "./components/update-mode-field-wrapper/update-mode-field-wrapper.js";
7
7
  import { editorFieldTypes as $ } from "./editor-field-types.js";
8
- import { s as n } from "../../../../chunks/utils.js";
8
+ import { s as n } from "../../../../chunks/utils2.js";
9
9
  import { jsx as a, jsxs as B } from "react/jsx-runtime";
10
10
  const X = /* @__PURE__ */ P(({
11
11
  disableForm: g,
@@ -4,7 +4,7 @@ import { useFormikContext as d, getIn as p, FieldArray as u } from "formik";
4
4
  import { FormattedMessage as x } from "react-intl";
5
5
  import g from "../../messages.js";
6
6
  import { MetadataEditorFieldWrapper as h } from "./metadata-editor-field-wrapper.js";
7
- import { s as F } from "../../../../chunks/utils.js";
7
+ import { s as F } from "../../../../chunks/utils2.js";
8
8
  import { jsx as t } from "react/jsx-runtime";
9
9
  const C = (m) => {
10
10
  const {
@@ -1,6 +1,6 @@
1
1
  import "@box/blueprint-web-assets/icons/Logo";
2
2
  import "../interactive-text/interactive-text.js";
3
- import { g as m, t as p } from "../../../../chunks/utils.js";
3
+ import { g as m, t as p } from "../../../../chunks/utils2.js";
4
4
  import "../../utils/convertDate.js";
5
5
  import "react/jsx-runtime";
6
6
  export {
@@ -1,10 +1,14 @@
1
- import { DeleteConfirmationModal as t } from "./subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
2
- import { MetadataInstanceFormHeader as r } from "./subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
3
- import { CustomInstanceNewField as n } from "./subcomponents/custom-instance-new-field/custom-instance-new-field.js";
4
- import { MetadataInstanceForm as f } from "./subcomponents/metadata-instance-form/metadata-instance-form.js";
1
+ import { CustomInstanceNewField as e } from "./subcomponents/custom-instance-new-field/custom-instance-new-field.js";
2
+ import { DeleteConfirmationModal as r } from "./subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
3
+ import { MetadataInstanceFormAutofillButton as n } from "./subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js";
4
+ import { MetadataInstanceFormHeader as p } from "./subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
5
+ import { MetadataInstanceForm as s } from "./subcomponents/metadata-instance-form/metadata-instance-form.js";
6
+ import { J as c } from "../../../../chunks/utils.js";
5
7
  export {
6
- n as CustomInstanceNewField,
7
- t as DeleteConfirmationModal,
8
- f as MetadataInstanceForm,
9
- r as MetadataInstanceFormHeader
8
+ e as CustomInstanceNewField,
9
+ r as DeleteConfirmationModal,
10
+ c as JSONPatchOp,
11
+ s as MetadataInstanceForm,
12
+ n as MetadataInstanceFormAutofillButton,
13
+ p as MetadataInstanceFormHeader
10
14
  };
@@ -0,0 +1,40 @@
1
+ import { Card as F } from "@box/blueprint-web";
2
+ import { TEMPLATE_CUSTOM_PROPERTIES as A } from "../../../../constants.js";
3
+ import { MetadataInstanceFormFooter as S } from "../metadata-instance-form-footer/metadata-instance-form-footer.js";
4
+ import { MetadataInstanceFormHeader as c } from "../metadata-instance-form-header/metadata-instance-form-header.js";
5
+ import { jsxs as C, jsx as o } from "react/jsx-runtime";
6
+ const x = (t) => {
7
+ const {
8
+ areAiSuggestionsAvailable: i,
9
+ children: r,
10
+ className: s,
11
+ formRef: n,
12
+ isAiSuggestionsFeatureEnabled: m,
13
+ isDeleteButtonDisabled: l,
14
+ isFetchingSuggestions: a,
15
+ isFormDirty: d = !1,
16
+ selectedTemplateInstance: e,
17
+ getAiSuggestions: g,
18
+ handleCancel: u,
19
+ handleDelete: f
20
+ } = t, p = (e == null ? void 0 : e.templateKey) === A;
21
+ return /* @__PURE__ */ C(F, {
22
+ ref: n,
23
+ className: s,
24
+ children: [/* @__PURE__ */ o(c, {
25
+ areAiSuggestionsAvailable: i,
26
+ isAiSuggestionsFeatureEnabled: m && !p,
27
+ isLoading: a,
28
+ onAutofill: g,
29
+ templateName: e == null ? void 0 : e.displayName
30
+ }), e && r, /* @__PURE__ */ o(S, {
31
+ isDeleteButtonDisabled: l,
32
+ isLoading: a,
33
+ onCancel: () => u(d),
34
+ onDelete: f
35
+ })]
36
+ });
37
+ };
38
+ export {
39
+ x as MetadataInstanceFormCardWrapper
40
+ };
@@ -1,101 +1,100 @@
1
1
  import "../../../../../../styles/metadata-instance-form.css";
2
- import { Card as P } from "@box/blueprint-web";
3
- import { Formik as U, Form as _ } from "formik";
4
- import { useState as d, useEffect as p, useRef as L, useMemo as R } from "react";
5
- import { TEMPLATE_CUSTOM_PROPERTIES as B } from "../../../../constants.js";
6
- import { useAutofill as K } from "../../../../utils/autofill-context.js";
7
- import { TemplateInstance as j } from "../../../metadata-editor-fields/metadata-editor-fields.js";
8
- import { MetadataEmptyState as k } from "../../../metadata-empty-state/metadata-empty-state.js";
9
- import { UnsavedChangesModal as $ } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
10
- import { CustomInstance as w } from "../custom-instance/custom-instance.js";
11
- import { DeleteConfirmationModal as H } from "../delete-confirmation-modal/delete-confirmation-modal.js";
12
- import { MetadataInstanceFormFooter as J } from "../metadata-instance-form-footer/metadata-instance-form-footer.js";
13
- import { MetadataInstanceFormHeader as V } from "../metadata-instance-form-header/metadata-instance-form-header.js";
14
- import { createJSONPatch as q } from "./utils.js";
15
- import { jsx as t, jsxs as u } from "react/jsx-runtime";
16
- const z = "_metadataInstanceForm_1hu4u_1", G = {
17
- metadataInstanceForm: z
18
- }, ce = (f) => {
2
+ import { Formik as B, Form as K } from "formik";
3
+ import { useState as d, useEffect as g, useRef as W, useMemo as j } from "react";
4
+ import { TEMPLATE_CUSTOM_PROPERTIES as k } from "../../../../constants.js";
5
+ import { useAutofill as L } from "../../../../utils/autofill-context.js";
6
+ import { TemplateInstance as V } from "../../../metadata-editor-fields/metadata-editor-fields.js";
7
+ import { MetadataEmptyState as $ } from "../../../metadata-empty-state/metadata-empty-state.js";
8
+ import { UnsavedChangesModal as w } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
9
+ import { CustomInstance as J } from "../custom-instance/custom-instance.js";
10
+ import { DeleteConfirmationModal as q } from "../delete-confirmation-modal/delete-confirmation-modal.js";
11
+ import { c as z } from "../../../../../../chunks/utils.js";
12
+ import { MetadataInstanceFormCardWrapper as G } from "./metadata-instance-form-card-wrapper.js";
13
+ import { jsx as r, jsxs as H } from "react/jsx-runtime";
14
+ const Q = "_metadataInstanceForm_1hu4u_1", X = {
15
+ metadataInstanceForm: Q
16
+ }, uo = (c) => {
19
17
  const {
20
- areAiSuggestionsAvailable: g,
21
- isAiSuggestionsFeatureEnabled: o,
22
- isDeleteButtonDisabled: h,
23
- isUnsavedChangesModalOpen: C = !1,
24
- onCancel: F,
25
- onDelete: S,
26
- onDiscardUnsavedChanges: M,
27
- onSubmit: E,
28
- selectedTemplateInstance: e,
29
- setIsUnsavedChangesModalOpen: i,
30
- taxonomyOptionsFetcher: I
31
- } = f, [D, r] = d(!1), {
18
+ areAiSuggestionsAvailable: h,
19
+ customRef: a,
20
+ isAiSuggestionsFeatureEnabled: i,
21
+ isDeleteButtonDisabled: C,
22
+ isUnsavedChangesModalOpen: F = !1,
23
+ MetadataInstanceFormCustomWrapper: M,
24
+ selectedTemplateInstance: o,
25
+ onCancel: S,
26
+ onDelete: E,
27
+ onDiscardUnsavedChanges: D,
28
+ onSubmit: y,
29
+ setIsUnsavedChangesModalOpen: s,
30
+ taxonomyOptionsFetcher: e
31
+ } = c, b = M ?? G, [O, m] = d(!1), {
32
32
  isFetchingSuggestions: n,
33
- getAiSuggestions: y,
34
- clearSuggestions: m
35
- } = K();
36
- p(() => m(), [m]);
37
- const s = e.templateKey === B, b = async (a) => {
38
- await E(a, q(a, e));
39
- }, A = (a) => {
40
- a ? i(!0) : F();
41
- }, O = () => {
42
- r(!0);
43
- }, T = {
33
+ getAiSuggestions: A,
34
+ clearSuggestions: u
35
+ } = L();
36
+ g(() => u(), [u]);
37
+ const f = (o == null ? void 0 : o.templateKey) === k, v = async (t) => {
38
+ await y(t, z(t, o));
39
+ }, x = (t) => {
40
+ t ? s(!0) : S();
41
+ }, P = () => {
42
+ m(!0);
43
+ }, R = {
44
44
  metadata: {
45
- ...e
45
+ ...o
46
46
  }
47
- }, l = L(null), [c, v] = d(null);
48
- p(() => {
49
- v(l.current);
50
- }, [e.templateKey, e.scope]);
51
- const N = R(() => {
52
- const a = e.fields.length === 0;
53
- return s ? /* @__PURE__ */ t(w, {
47
+ }, l = W(null), [p, U] = d(null);
48
+ g(() => {
49
+ U(a ?? l.current);
50
+ }, [a, o == null ? void 0 : o.templateKey, o == null ? void 0 : o.scope]);
51
+ const _ = j(() => {
52
+ const t = (o == null ? void 0 : o.fields.length) === 0;
53
+ return f ? /* @__PURE__ */ r(J, {
54
54
  isLoading: n
55
- }) : a ? /* @__PURE__ */ t(k, {
56
- isBoxAiSuggestionsFeatureEnabled: o,
55
+ }) : t ? /* @__PURE__ */ r($, {
56
+ isBoxAiSuggestionsFeatureEnabled: i,
57
57
  level: "instance"
58
- }) : /* @__PURE__ */ t(j, {
58
+ }) : /* @__PURE__ */ r(V, {
59
59
  disableForm: n,
60
- portalElement: c,
61
- taxonomyOptionsFetcher: I
60
+ portalElement: a ?? p,
61
+ taxonomyOptionsFetcher: e
62
62
  });
63
- }, [s, e.fields.length, n, o, c]);
64
- return /* @__PURE__ */ t(U, {
65
- initialValues: T,
66
- onSubmit: b,
63
+ }, [o == null ? void 0 : o.fields.length, f, n, a, p, e, i]);
64
+ return /* @__PURE__ */ r(B, {
65
+ initialValues: R,
66
+ onSubmit: v,
67
67
  children: ({
68
- values: a,
69
- dirty: x
70
- }) => /* @__PURE__ */ u(_, {
71
- children: [/* @__PURE__ */ u(P, {
72
- ref: l,
73
- className: G.metadataInstanceForm,
74
- children: [/* @__PURE__ */ t(V, {
75
- areAiSuggestionsAvailable: g,
76
- isAiSuggestionsFeatureEnabled: o && !s,
77
- isLoading: n,
78
- onAutofill: y,
79
- templateName: e.displayName
80
- }), N, /* @__PURE__ */ t(J, {
81
- isDeleteButtonDisabled: h,
82
- isLoading: n,
83
- onCancel: () => A(x),
84
- onDelete: O
85
- })]
86
- }), /* @__PURE__ */ t($, {
87
- onBackToEdit: () => i(!1),
88
- onDiscardChanges: M,
89
- open: C
90
- }), /* @__PURE__ */ t(H, {
91
- onConfirm: () => S(e),
92
- onDismiss: () => r(!1),
93
- open: D,
94
- templateName: e.displayName
68
+ values: t,
69
+ dirty: N
70
+ }) => /* @__PURE__ */ H(K, {
71
+ children: [/* @__PURE__ */ r(b, {
72
+ areAiSuggestionsAvailable: h,
73
+ className: X.metadataInstanceForm,
74
+ formRef: l,
75
+ formValues: t,
76
+ getAiSuggestions: A,
77
+ handleCancel: x,
78
+ handleDelete: P,
79
+ isAiSuggestionsFeatureEnabled: i,
80
+ isDeleteButtonDisabled: C,
81
+ isFetchingSuggestions: n,
82
+ isFormDirty: N,
83
+ selectedTemplateInstance: o,
84
+ children: o && _
85
+ }), /* @__PURE__ */ r(w, {
86
+ onBackToEdit: () => s(!1),
87
+ onDiscardChanges: D,
88
+ open: F
89
+ }), /* @__PURE__ */ r(q, {
90
+ onConfirm: () => E(o),
91
+ onDismiss: () => m(!1),
92
+ open: O,
93
+ templateName: o == null ? void 0 : o.displayName
95
94
  })]
96
95
  })
97
- }, `${e.scope}.${e.templateKey}`);
96
+ }, `${o == null ? void 0 : o.scope}.${o == null ? void 0 : o.templateKey}`);
98
97
  };
99
98
  export {
100
- ce as MetadataInstanceForm
99
+ uo as MetadataInstanceForm
101
100
  };
@@ -1,41 +1,8 @@
1
- import h from "lodash/isEmpty";
2
- import O from "lodash/isArray";
3
- import { TEMPLATE_CUSTOM_PROPERTIES as f } from "../../../../constants.js";
4
- const n = {
5
- ADD: "add",
6
- REMOVE: "remove",
7
- REPLACE: "replace",
8
- TEST: "test"
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
- return c.forEach((t) => {
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
- // 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) => ({
23
- op: n.TEST,
24
- path: `/${e}`,
25
- value: a
26
- }), v = (e, a) => ({
27
- op: n.ADD,
28
- path: `/${e}`,
29
- value: a
30
- }), k = (e) => ({
31
- op: n.REMOVE,
32
- path: `/${e}`
33
- }), M = (e, a) => ({
34
- op: n.REPLACE,
35
- path: `/${e}`,
36
- value: a
37
- });
1
+ import "lodash/isEmpty";
2
+ import "lodash/isArray";
3
+ import { c as m, g as i } from "../../../../../../chunks/utils.js";
4
+ import "../../../../constants.js";
38
5
  export {
39
- S as createJSONPatch,
40
- u as getFormatedFieldValue
6
+ m as createJSONPatch,
7
+ i as getFormatedFieldValue
41
8
  };
@@ -0,0 +1,18 @@
1
+ import { defineMessages as t } from "react-intl";
2
+ const e = t({
3
+ autofillButton: {
4
+ id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButton",
5
+ defaultMessage: "Autofill"
6
+ },
7
+ autofillButtonTooltip: {
8
+ id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButtonTooltip",
9
+ defaultMessage: "Autofill with Box AI"
10
+ },
11
+ loadingButtonAriaLabel: {
12
+ id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.loadingButtonAriaLabel",
13
+ defaultMessage: "Loading..."
14
+ }
15
+ });
16
+ export {
17
+ e as default
18
+ };
@@ -0,0 +1,68 @@
1
+ import "../../../../../../styles/metadata-instance-form-autofill-button.css";
2
+ import { LoadingIndicator as M, IconButton as v, Tooltip as L, Button as k } from "@box/blueprint-web";
3
+ import { BoxAiLogo as p } from "@box/blueprint-web-assets/icons/Logo";
4
+ import { useFormikContext as x, getIn as i } from "formik";
5
+ import { useEffect as K } from "react";
6
+ import { useIntl as h } from "react-intl";
7
+ import { useAutofill as C } from "../../../../utils/autofill-context.js";
8
+ import n from "./messages.js";
9
+ import { jsx as r } from "react/jsx-runtime";
10
+ const F = "_loadingIndicator_1vv9u_1", _ = {
11
+ loadingIndicator: F
12
+ }, z = ({
13
+ areAiSuggestionsAvailable: B,
14
+ isLoading: l,
15
+ variant: b = "secondary-button",
16
+ onAutofill: I
17
+ }) => {
18
+ const {
19
+ isSubmitting: y,
20
+ values: e,
21
+ setFieldValue: m
22
+ } = x(), t = h(), {
23
+ suggestions: o
24
+ } = C();
25
+ K(() => {
26
+ if (o) {
27
+ const a = i(e, "metadata.fields"), s = i(e, "metadata.templateKey");
28
+ m("metadata.fields", a == null ? void 0 : a.map((c) => {
29
+ var f;
30
+ const g = (f = o == null ? void 0 : o[s]) == null ? void 0 : f[c.key];
31
+ return g ? {
32
+ ...c,
33
+ aiSuggestion: g
34
+ } : c;
35
+ }));
36
+ }
37
+ }, [o, m]);
38
+ const d = () => {
39
+ const a = i(e, "metadata.templateKey"), s = i(e, "metadata.scope");
40
+ I(a, s);
41
+ }, u = !B || y || l, A = l ? /* @__PURE__ */ r(M, {
42
+ "aria-label": t.formatMessage(n.loadingButtonAriaLabel),
43
+ className: _.loadingIndicator
44
+ }) : /* @__PURE__ */ r(v, {
45
+ "aria-label": t.formatMessage(n.loadingButtonAriaLabel),
46
+ disabled: u,
47
+ icon: p,
48
+ onClick: d,
49
+ variant: "icon-logo",
50
+ "data-target-id": "IconButton-loadingButtonAriaLabel"
51
+ });
52
+ return /* @__PURE__ */ r(L, {
53
+ content: t.formatMessage(n.autofillButtonTooltip),
54
+ children: b === "secondary-button" ? /* @__PURE__ */ r(k, {
55
+ disabled: u,
56
+ icon: p,
57
+ loading: l,
58
+ loadingAriaLabel: t.formatMessage(n.loadingButtonAriaLabel),
59
+ onClick: d,
60
+ variant: "secondary",
61
+ "data-target-id": "Button-autofillButton",
62
+ children: t.formatMessage(n.autofillButton)
63
+ }) : A
64
+ });
65
+ };
66
+ export {
67
+ z as MetadataInstanceFormAutofillButton
68
+ };
@@ -1,20 +1,8 @@
1
1
  import { defineMessages as t } from "react-intl";
2
2
  const e = t({
3
- autofillButton: {
4
- id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButton",
5
- defaultMessage: "Autofill"
6
- },
7
- autofillButtonTooltip: {
8
- id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButtonTooltip",
9
- defaultMessage: "Autofill with Box AI"
10
- },
11
3
  customInstanceTitle: {
12
4
  id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.customInstanceTitle",
13
5
  defaultMessage: "Custom Metadata"
14
- },
15
- loadingButtonAriaLabel: {
16
- id: "metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.loadingButtonAriaLabel",
17
- defaultMessage: "Loading..."
18
6
  }
19
7
  });
20
8
  export {
@@ -1,67 +1,32 @@
1
1
  import "../../../../../../styles/metadata-instance-form-header.css";
2
- import { Tooltip as _, Button as b } from "@box/blueprint-web";
3
- import { BoxAiLogo as A } from "@box/blueprint-web-assets/icons/Logo";
4
- import { useFormikContext as M, getIn as o } from "formik";
5
- import { useEffect as h } from "react";
6
- import { useIntl as v } from "react-intl";
7
- import { useAutofill as K } from "../../../../utils/autofill-context.js";
8
- import T from "../../../interactive-header-text/interactive-header-text.js";
9
- import s from "./messages.js";
10
- import { jsxs as k, jsx as m } from "react/jsx-runtime";
11
- const j = "_metadataInstanceFormHeader_13lxr_1", C = "_title_13lxr_9", f = {
12
- metadataInstanceFormHeader: j,
13
- title: C
14
- }, J = ({
15
- areAiSuggestionsAvailable: p,
16
- isAiSuggestionsFeatureEnabled: g,
17
- isLoading: l,
18
- templateName: I,
19
- onAutofill: x
2
+ import { useIntl as l } from "react-intl";
3
+ import i from "../../../interactive-header-text/interactive-header-text.js";
4
+ import { MetadataInstanceFormAutofillButton as d } from "../metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js";
5
+ import I from "./messages.js";
6
+ import { jsxs as f, jsx as t } from "react/jsx-runtime";
7
+ const p = "_metadataInstanceFormHeader_13lxr_1", u = "_title_13lxr_9", e = {
8
+ metadataInstanceFormHeader: p,
9
+ title: u
10
+ }, j = ({
11
+ areAiSuggestionsAvailable: a,
12
+ isAiSuggestionsFeatureEnabled: r,
13
+ isLoading: s,
14
+ templateName: o,
15
+ onAutofill: n
20
16
  }) => {
21
- const {
22
- isSubmitting: B,
23
- values: e,
24
- setFieldValue: c
25
- } = M(), a = v(), {
26
- suggestions: t
27
- } = K();
28
- h(() => {
29
- if (t) {
30
- const n = o(e, "metadata.fields"), r = o(e, "metadata.templateKey");
31
- c("metadata.fields", n.map((i) => {
32
- var u;
33
- const d = (u = t == null ? void 0 : t[r]) == null ? void 0 : u[i.key];
34
- return d ? {
35
- ...i,
36
- aiSuggestion: d
37
- } : i;
38
- }));
39
- }
40
- }, [t, c]);
41
- const y = () => {
42
- const n = o(e, "metadata.templateKey"), r = o(e, "metadata.scope");
43
- x(n, r);
44
- }, F = I ?? a.formatMessage(s.customInstanceTitle), H = !p || B || l;
45
- return /* @__PURE__ */ k("div", {
46
- className: f.metadataInstanceFormHeader,
47
- children: [/* @__PURE__ */ m(T, {
48
- className: f.title,
49
- title: F
50
- }), g && /* @__PURE__ */ m(_, {
51
- content: a.formatMessage(s.autofillButtonTooltip),
52
- children: /* @__PURE__ */ m(b, {
53
- disabled: H,
54
- icon: A,
55
- loading: l,
56
- loadingAriaLabel: a.formatMessage(s.loadingButtonAriaLabel),
57
- onClick: y,
58
- variant: "secondary",
59
- "data-target-id": "Button-autofillButton",
60
- children: a.formatMessage(s.autofillButton)
61
- })
62
- })]
17
+ const m = l(), c = o ?? m.formatMessage(I.customInstanceTitle);
18
+ return /* @__PURE__ */ f("div", {
19
+ className: e.metadataInstanceFormHeader,
20
+ children: [/* @__PURE__ */ t(i, {
21
+ className: e.title,
22
+ title: c
23
+ }), r ? /* @__PURE__ */ t(d, {
24
+ areAiSuggestionsAvailable: a,
25
+ isLoading: s,
26
+ onAutofill: n
27
+ }) : null]
63
28
  });
64
29
  };
65
30
  export {
66
- J as MetadataInstanceFormHeader
31
+ j as MetadataInstanceFormHeader
67
32
  };
@@ -0,0 +1 @@
1
+ [{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButton","description":"Button with \"Autofill\" text. Call to action to automatically fill in form fields based on AI information","defaultMessage":"Autofill"},{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButtonTooltip","description":"Tooltip text explaining that by clicking button user can autofill template using Box AI","defaultMessage":"Autofill with Box AI"},{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.loadingButtonAriaLabel","description":"Aria label used to indicate that the button is currently loading.","defaultMessage":"Loading..."}]
@@ -1 +1 @@
1
- [{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButton","description":"Button with \"Autofill\" text. Call to action to automatically fill in form fields based on AI information","defaultMessage":"Autofill"},{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.autofillButtonTooltip","description":"Tooltip text explaining that by clicking button user can autofill template using Box AI","defaultMessage":"Autofill with Box AI"},{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.customInstanceTitle","description":"Header with Custom Metadata template name","defaultMessage":"Custom Metadata"},{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.loadingButtonAriaLabel","description":"Aria label used to indicate that the button is currently loading.","defaultMessage":"Loading..."}]
1
+ [{"id":"metadataEditor.metadataInstanceEditor.metadataInstanceFormHeader.customInstanceTitle","description":"Header with Custom Metadata template name","defaultMessage":"Custom Metadata"}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.78.9",
3
+ "version": "0.79.1",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.14",
6
6
  "@box/blueprint-web": "^7.30.3",
@@ -14,7 +14,7 @@
14
14
  "devDependencies": {
15
15
  "@ariakit/react": "0.4.14",
16
16
  "@box/babel-plugin-target-attributes": "1.3.0",
17
- "@box/blueprint-web": "^9.2.0",
17
+ "@box/blueprint-web": "^9.2.1",
18
18
  "@box/blueprint-web-assets": "^4.30.0",
19
19
  "@box/storybook-utils": "^0.7.0",
20
20
  "@testing-library/react": "^15.0.6",
@@ -53,5 +53,5 @@
53
53
  "**/*.css"
54
54
  ],
55
55
  "license": "SEE LICENSE IN LICENSE",
56
- "gitHead": "aea7aacd8bd8226934231748787d65edac379e02"
56
+ "gitHead": "94a36651838769cd08fd62a9ab1b41e0b4cb5280"
57
57
  }
@@ -0,0 +1 @@
1
+ ._loadingIndicator_1vv9u_1{position:relative;width:var(--size-8);height:var(--size-8);display:flex;align-items:center;justify-content:center;margin:unset}
@@ -1,4 +1,6 @@
1
+ export * from './subcomponents/custom-instance-new-field/custom-instance-new-field';
1
2
  export * from './subcomponents/delete-confirmation-modal/delete-confirmation-modal';
3
+ export * from './subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button';
2
4
  export * from './subcomponents/metadata-instance-form-header/metadata-instance-form-header';
3
- export * from './subcomponents/custom-instance-new-field/custom-instance-new-field';
4
5
  export * from './subcomponents/metadata-instance-form/metadata-instance-form';
6
+ export * from './subcomponents/metadata-instance-form/types';
@@ -0,0 +1,2 @@
1
+ import { type MetadataInstanceFormWrapperProps } from './types';
2
+ export declare const MetadataInstanceFormCardWrapper: (props: MetadataInstanceFormWrapperProps<null>) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,12 @@
1
- import { type MetadataFormFieldValue, type MetadataTemplateInstance } from '../../../../types';
2
- import { type FormValues } from '../../types';
1
+ import { type MetadataFormFieldValue, type MetadataTemplateField, type MetadataTemplateInstance } from '../../../../types';
3
2
  import { type TaxonomyOptionsFetcher } from '../../../metadata-editor-fields/components/metadata-taxonomy-field/types';
3
+ import { type FormValues } from '../../types';
4
4
  export type MetadataInstanceFormProps = {
5
5
  areAiSuggestionsAvailable: boolean;
6
6
  isAiSuggestionsFeatureEnabled: boolean;
7
7
  isDeleteButtonDisabled: boolean;
8
8
  isUnsavedChangesModalOpen: boolean;
9
- selectedTemplateInstance: MetadataTemplateInstance;
9
+ selectedTemplateInstance: MetadataTemplateInstance | null;
10
10
  onCancel: () => void;
11
11
  onDelete: (templateInstance: MetadataTemplateInstance) => void;
12
12
  /** Callback invoked when clicking Discard Changes button on the UnsavedChangesModal - can be used to reset form values */
@@ -14,7 +14,24 @@ export type MetadataInstanceFormProps = {
14
14
  onSubmit: (values: FormValues, operations: JSONPatchOperations) => Promise<void>;
15
15
  setIsUnsavedChangesModalOpen: (isUnsavedChangesModalOpen: boolean) => void;
16
16
  taxonomyOptionsFetcher: TaxonomyOptionsFetcher;
17
+ customRef?: HTMLDivElement | null;
18
+ MetadataInstanceFormCustomWrapper?: React.ComponentType<MetadataInstanceFormWrapperProps<null>>;
17
19
  };
20
+ export type MetadataInstanceFormWrapperProps<T> = {
21
+ areAiSuggestionsAvailable: boolean;
22
+ children: React.ReactNode;
23
+ formValues: FormValues;
24
+ isAiSuggestionsFeatureEnabled: boolean;
25
+ isDeleteButtonDisabled: boolean;
26
+ isFetchingSuggestions: boolean;
27
+ isFormDirty: boolean;
28
+ selectedTemplateInstance: MetadataTemplateInstance | null;
29
+ handleDelete: () => void;
30
+ handleCancel: (isDirty: boolean) => void;
31
+ getAiSuggestions: (templateKey: MetadataTemplateInstance['templateKey'], scope: MetadataTemplateInstance['scope']) => Promise<MetadataTemplateField[]>;
32
+ extraProps?: T;
33
+ formRef?: React.LegacyRef<HTMLDivElement | null>;
34
+ } & React.HTMLAttributes<HTMLDivElement>;
18
35
  export declare const JSONPatchOp: {
19
36
  readonly ADD: "add";
20
37
  readonly REMOVE: "remove";
@@ -0,0 +1,18 @@
1
+ declare const messages: {
2
+ autofillButton: {
3
+ defaultMessage: string;
4
+ description: string;
5
+ id: string;
6
+ };
7
+ autofillButtonTooltip: {
8
+ defaultMessage: string;
9
+ description: string;
10
+ id: string;
11
+ };
12
+ loadingButtonAriaLabel: {
13
+ defaultMessage: string;
14
+ description: string;
15
+ id: string;
16
+ };
17
+ };
18
+ export default messages;
@@ -0,0 +1,2 @@
1
+ import { type MetadataInstanceFormAutofillButtonProps } from './types';
2
+ export declare const MetadataInstanceFormAutofillButton: ({ areAiSuggestionsAvailable, isLoading, variant, onAutofill, }: MetadataInstanceFormAutofillButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { type MetadataTemplateField, type MetadataTemplateInstance } from '../../../../types';
2
+ export type MetadataInstanceFormAutofillButtonProps = {
3
+ areAiSuggestionsAvailable: boolean;
4
+ isLoading: boolean;
5
+ onAutofill?: (templateKey: MetadataTemplateInstance['templateKey'], scope: MetadataTemplateInstance['scope']) => Promise<MetadataTemplateField[]>;
6
+ variant?: 'secondary-button' | 'icon-button';
7
+ };
@@ -1,23 +1,8 @@
1
1
  declare const messages: {
2
- autofillButton: {
3
- defaultMessage: string;
4
- description: string;
5
- id: string;
6
- };
7
- autofillButtonTooltip: {
8
- defaultMessage: string;
9
- description: string;
10
- id: string;
11
- };
12
2
  customInstanceTitle: {
13
3
  defaultMessage: string;
14
4
  description: string;
15
5
  id: string;
16
6
  };
17
- loadingButtonAriaLabel: {
18
- defaultMessage: string;
19
- description: string;
20
- id: string;
21
- };
22
7
  };
23
8
  export default messages;
@@ -1,5 +1,4 @@
1
1
  import { type BaseOptionType } from './components/combobox-with-api-pagination/types';
2
- export type { JSONPatchOperations } from './components/metadata-instance-editor/subcomponents/metadata-instance-form/types';
3
2
  export type { FormValues } from './components/metadata-instance-editor/types';
4
3
  export type MetadataEmptyStateProps = {
5
4
  isBoxAiSuggestionsFeatureEnabled?: boolean;
@@ -10,7 +10,7 @@ export interface AutofillContextType {
10
10
  export interface AutofillContextProviderProps {
11
11
  children: React.ReactNode;
12
12
  isAiSuggestionsFeatureEnabled: boolean;
13
- fetchSuggestions: (templateKey: string, scope: string) => Promise<MetadataTemplateField[]>;
13
+ fetchSuggestions: (templateKey: MetadataTemplateInstance['templateKey'], scope: MetadataTemplateInstance['scope']) => Promise<MetadataTemplateField[]>;
14
14
  }
15
15
  export declare const AutofillContext: React.Context<AutofillContextType>;
16
16
  export declare const AutofillContextProvider: ({ children, isAiSuggestionsFeatureEnabled, fetchSuggestions, }: AutofillContextProviderProps) => React.ReactElement;