@box/metadata-editor 0.56.1 → 0.57.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.
@@ -1,56 +1,57 @@
1
1
  import "../../../../../../styles/metadata-instance-form.css";
2
2
  import { Card as N } from "@box/blueprint-web";
3
- import { Formik as T, Form as v } from "formik";
4
- import { useState as d, useRef as P, useEffect as U, useMemo as _ } from "react";
5
- import { TEMPLATE_CUSTOM_PROPERTIES as x } from "../../../../constants.js";
6
- import { useAutofill as L } from "../../../../utils/autofill-context.js";
7
- import { TemplateInstance as R } from "../../../metadata-editor-fields/metadata-editor-fields.js";
8
- import { MetadataEmptyState as j } from "../../../metadata-empty-state/metadata-empty-state.js";
9
- import { UnsavedChangesModal as B } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
10
- import { CustomInstance as k } from "../custom-instance/custom-instance.js";
11
- import { DeleteConfirmationModal as w } from "../delete-confirmation-modal/delete-confirmation-modal.js";
12
- import { MetadataInstanceFormFooter as H } from "../metadata-instance-form-footer/metadata-instance-form-footer.js";
13
- import { MetadataInstanceFormHeader as J } from "../metadata-instance-form-header/metadata-instance-form-header.js";
14
- import { createJSONPatch as K } from "./utils.js";
3
+ import { Formik as T, Form as P } from "formik";
4
+ import { useState as d, useRef as U, useEffect as _, useMemo as x } from "react";
5
+ import { TEMPLATE_CUSTOM_PROPERTIES as L } from "../../../../constants.js";
6
+ import { useAutofill as R } from "../../../../utils/autofill-context.js";
7
+ import { TemplateInstance as j } from "../../../metadata-editor-fields/metadata-editor-fields.js";
8
+ import { MetadataEmptyState as B } from "../../../metadata-empty-state/metadata-empty-state.js";
9
+ import { UnsavedChangesModal as k } 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 K } from "../metadata-instance-form-header/metadata-instance-form-header.js";
14
+ import { createJSONPatch as V } from "./utils.js";
15
15
  import { jsx as n, jsxs as f } from "react/jsx-runtime";
16
- const V = "_metadataInstanceForm_1hu4u_1", q = {
17
- metadataInstanceForm: V
18
- }, me = (u) => {
16
+ const q = "_metadataInstanceForm_1hu4u_1", z = {
17
+ metadataInstanceForm: q
18
+ }, re = (u) => {
19
19
  const {
20
+ areAiSuggestionsAvailable: p,
20
21
  isAiSuggestionsFeatureEnabled: o,
21
- isDeleteButtonDisabled: p,
22
- isUnsavedChangesModalOpen: g = !1,
23
- onCancel: C,
24
- onDelete: h,
25
- onSubmit: F,
22
+ isDeleteButtonDisabled: g,
23
+ isUnsavedChangesModalOpen: C = !1,
24
+ onCancel: h,
25
+ onDelete: F,
26
+ onSubmit: M,
26
27
  selectedTemplateInstance: e,
27
28
  setIsUnsavedChangesModalOpen: s,
28
- onUnsavedChangesModalCancel: M
29
- } = u, [S, m] = d(!1), {
29
+ onUnsavedChangesModalCancel: S
30
+ } = u, [I, m] = d(!1), {
30
31
  isFetchingSuggestions: a,
31
- getAiSuggestions: I
32
- } = L(), i = e.templateKey === x, r = async (t) => {
33
- await F(t, K(t, e)), s(!1);
34
- }, E = (t) => {
35
- t ? s(!0) : C();
32
+ getAiSuggestions: E
33
+ } = R(), i = e.templateKey === L, r = async (t) => {
34
+ await M(t, V(t, e)), s(!1);
35
+ }, A = (t) => {
36
+ t ? s(!0) : h();
36
37
  }, D = () => {
37
38
  m(!0);
38
39
  }, b = {
39
40
  metadata: {
40
41
  ...e
41
42
  }
42
- }, l = P(null), [c, A] = d(null);
43
- U(() => {
44
- A(l.current);
43
+ }, l = U(null), [c, y] = d(null);
44
+ _(() => {
45
+ y(l.current);
45
46
  }, []);
46
- const y = _(() => {
47
+ const O = x(() => {
47
48
  const t = e.fields.length === 0;
48
- return i ? /* @__PURE__ */ n(k, {
49
+ return i ? /* @__PURE__ */ n(w, {
49
50
  isLoading: a
50
- }) : t ? /* @__PURE__ */ n(j, {
51
+ }) : t ? /* @__PURE__ */ n(B, {
51
52
  isBoxAiSuggestionsFeatureEnabled: o,
52
53
  level: "instance"
53
- }) : /* @__PURE__ */ n(R, {
54
+ }) : /* @__PURE__ */ n(j, {
54
55
  disableForm: a,
55
56
  portalElement: c
56
57
  });
@@ -60,36 +61,37 @@ const V = "_metadataInstanceForm_1hu4u_1", q = {
60
61
  onSubmit: r,
61
62
  children: ({
62
63
  values: t,
63
- dirty: O
64
- }) => /* @__PURE__ */ f(v, {
64
+ dirty: v
65
+ }) => /* @__PURE__ */ f(P, {
65
66
  children: [/* @__PURE__ */ f(N, {
66
67
  ref: l,
67
- className: q.metadataInstanceForm,
68
- children: [/* @__PURE__ */ n(J, {
68
+ className: z.metadataInstanceForm,
69
+ children: [/* @__PURE__ */ n(K, {
70
+ areAiSuggestionsAvailable: p,
69
71
  isAiSuggestionsFeatureEnabled: o && !i,
70
72
  isLoading: a,
71
- onAutofill: I,
73
+ onAutofill: E,
72
74
  templateName: e.displayName
73
- }), y, /* @__PURE__ */ n(H, {
74
- isDeleteButtonDisabled: p,
75
+ }), O, /* @__PURE__ */ n(J, {
76
+ isDeleteButtonDisabled: g,
75
77
  isLoading: a,
76
- onCancel: () => E(O),
78
+ onCancel: () => A(v),
77
79
  onDelete: D
78
80
  })]
79
- }), /* @__PURE__ */ n(B, {
80
- onCancel: M,
81
+ }), /* @__PURE__ */ n(k, {
82
+ onCancel: S,
81
83
  onDismiss: () => s(!1),
82
84
  onSaveAndContinue: () => r(t),
83
- open: g
84
- }), /* @__PURE__ */ n(w, {
85
- onConfirm: () => h(e),
85
+ open: C
86
+ }), /* @__PURE__ */ n(H, {
87
+ onConfirm: () => F(e),
86
88
  onDismiss: () => m(!1),
87
- open: S,
89
+ open: I,
88
90
  templateName: e.displayName
89
91
  })]
90
92
  })
91
93
  });
92
94
  };
93
95
  export {
94
- me as MetadataInstanceForm
96
+ re as MetadataInstanceForm
95
97
  };
@@ -1,42 +1,43 @@
1
1
  import "../../../../../../styles/metadata-instance-form-header.css";
2
- import { Text as h, Tooltip as F, Button as x } from "@box/blueprint-web";
3
- import { BoxAiLogo as B } from "@box/blueprint-web-assets/icons/Logo";
4
- import { useFormikContext as M, getIn as n } from "formik";
5
- import { useIntl as _ } from "react-intl";
2
+ import { Text as F, Tooltip as x, Button as B } from "@box/blueprint-web";
3
+ import { BoxAiLogo as M } from "@box/blueprint-web-assets/icons/Logo";
4
+ import { useFormikContext as _, getIn as n } from "formik";
5
+ import { useIntl as y } from "react-intl";
6
6
  import e from "./messages.js";
7
- import { jsxs as y, jsx as a } from "react/jsx-runtime";
8
- const H = "_metadataInstanceFormHeader_1b2cc_1", v = "_title_1b2cc_8", i = {
9
- metadataInstanceFormHeader: H,
10
- title: v
11
- }, N = ({
12
- isAiSuggestionsFeatureEnabled: l,
7
+ import { jsxs as H, jsx as a } from "react/jsx-runtime";
8
+ const v = "_metadataInstanceFormHeader_1b2cc_1", A = "_title_1b2cc_8", i = {
9
+ metadataInstanceFormHeader: v,
10
+ title: A
11
+ }, S = ({
12
+ areAiSuggestionsAvailable: l,
13
+ isAiSuggestionsFeatureEnabled: r,
13
14
  isLoading: o,
14
- templateName: r,
15
- onAutofill: m
15
+ templateName: m,
16
+ onAutofill: c
16
17
  }) => {
17
18
  const {
18
- isSubmitting: c,
19
+ isSubmitting: d,
19
20
  values: s,
20
- setFieldValue: d
21
- } = M(), t = _(), f = async () => {
22
- const p = n(s, "metadata.fields"), I = n(s, "metadata.templateKey"), b = await m(I, p);
23
- d("metadata.fields", b);
24
- }, u = r ?? t.formatMessage(e.customInstanceTitle), g = c || o;
25
- return /* @__PURE__ */ y("div", {
21
+ setFieldValue: f
22
+ } = _(), t = y(), u = async () => {
23
+ const I = n(s, "metadata.fields"), b = n(s, "metadata.templateKey"), h = await c(b, I);
24
+ f("metadata.fields", h);
25
+ }, g = m ?? t.formatMessage(e.customInstanceTitle), p = !l || d || o;
26
+ return /* @__PURE__ */ H("div", {
26
27
  className: i.metadataInstanceFormHeader,
27
- children: [/* @__PURE__ */ a(h, {
28
+ children: [/* @__PURE__ */ a(F, {
28
29
  as: "h1",
29
30
  className: i.title,
30
31
  variant: "titleMedium",
31
- children: u
32
- }), l && /* @__PURE__ */ a(F, {
32
+ children: g
33
+ }), r && /* @__PURE__ */ a(x, {
33
34
  content: t.formatMessage(e.autofillButtonTooltip),
34
- children: /* @__PURE__ */ a(x, {
35
- disabled: g,
36
- icon: B,
35
+ children: /* @__PURE__ */ a(B, {
36
+ disabled: p,
37
+ icon: M,
37
38
  loading: o,
38
39
  loadingAriaLabel: t.formatMessage(e.loadingButtonAriaLabel),
39
- onClick: f,
40
+ onClick: u,
40
41
  variant: "secondary",
41
42
  children: t.formatMessage(e.autofillButton)
42
43
  })
@@ -44,5 +45,5 @@ const H = "_metadataInstanceFormHeader_1b2cc_1", v = "_title_1b2cc_8", i = {
44
45
  });
45
46
  };
46
47
  export {
47
- N as MetadataInstanceFormHeader
48
+ S as MetadataInstanceFormHeader
48
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.56.1",
3
+ "version": "0.57.0",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.5",
6
6
  "@box/blueprint-web": "^7.20.0",
@@ -52,5 +52,5 @@
52
52
  "**/*.css"
53
53
  ],
54
54
  "license": "SEE LICENSE IN LICENSE",
55
- "gitHead": "a0c0a5947c5f64b38582f24481ec3db29f9d8f4e"
55
+ "gitHead": "070e08d367f07146160cb5db9832001c9625d59e"
56
56
  }
@@ -1,6 +1,7 @@
1
1
  import { type MetadataFormFieldValue, type MetadataTemplateInstance } from '../../../../types';
2
2
  import { type FormValues } from '../../types';
3
3
  export type MetadataInstanceFormProps = {
4
+ areAiSuggestionsAvailable: boolean;
4
5
  isAiSuggestionsFeatureEnabled: boolean;
5
6
  isDeleteButtonDisabled: boolean;
6
7
  isUnsavedChangesModalOpen: boolean;
@@ -1,2 +1,2 @@
1
1
  import { type MetadataInstanceFormHeaderProps } from './types';
2
- export declare const MetadataInstanceFormHeader: ({ isAiSuggestionsFeatureEnabled, isLoading, templateName, onAutofill, }: MetadataInstanceFormHeaderProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MetadataInstanceFormHeader: ({ areAiSuggestionsAvailable, isAiSuggestionsFeatureEnabled, isLoading, templateName, onAutofill, }: MetadataInstanceFormHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { type MetadataTemplateField, type MetadataTemplateInstance } from '../../../../types';
2
2
  export type MetadataInstanceFormHeaderProps = {
3
+ areAiSuggestionsAvailable: boolean;
3
4
  isAiSuggestionsFeatureEnabled: boolean;
4
5
  isLoading: boolean;
5
6
  onAutofill?: (templateKey: MetadataTemplateInstance['templateKey'], fields: MetadataTemplateField[]) => Promise<MetadataTemplateField[]>;