@box/metadata-editor 1.31.0 → 1.32.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,143 +1,148 @@
1
1
  import "../custom-instance-new-field/custom-instance-new-field.js";
2
- import { DeleteConfirmationModal as J } from "../delete-confirmation-modal/delete-confirmation-modal.js";
2
+ import { DeleteConfirmationModal as z } from "../delete-confirmation-modal/delete-confirmation-modal.js";
3
3
  import "../metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js";
4
4
  import "../metadata-instance-form-header/metadata-instance-form-header.js";
5
- import z from "clsx";
6
- import { Formik as G, Form as H } from "formik";
7
- import Q from "lodash/isEqual";
8
- import { useState as S, useEffect as y, useRef as O, useMemo as X } from "react";
9
- import { TEMPLATE_CUSTOM_PROPERTIES as Y } from "../../../../constants.js";
10
- import { useAutofill as Z } from "../../../../utils/autofill-context.js";
11
- import { TemplateInstance as ee } from "../../../metadata-editor-fields/metadata-editor-fields.js";
12
- import { MetadataEmptyState as te } from "../../../metadata-empty-state/metadata-empty-state.js";
13
- import { AutofillOverlay as ae } from "../autofill-overlay/autofill-overlay.js";
14
- import { CustomInstance as oe } from "../custom-instance/custom-instance.js";
15
- import { c as ne } from "../../../../../../chunks/utils.js";
16
- import { s as d, M as se } from "../../../../../../chunks/metadata-instance-form-card-wrapper.js";
17
- import { jsx as o, jsxs as D } from "react/jsx-runtime";
18
- import { UnsavedChangesModal as re } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
19
- const ie = ({
5
+ import G from "clsx";
6
+ import { Formik as H, Form as Q } from "formik";
7
+ import X from "lodash/isEqual";
8
+ import { useState as S, useEffect as y, useRef as O, useMemo as Y } from "react";
9
+ import { TEMPLATE_CUSTOM_PROPERTIES as Z } from "../../../../constants.js";
10
+ import { useAutofill as ee } from "../../../../utils/autofill-context.js";
11
+ import { ConfidenceScoreContextProvider as te } from "../../../../utils/confidence-score-context.js";
12
+ import { TemplateInstance as oe } from "../../../metadata-editor-fields/metadata-editor-fields.js";
13
+ import { MetadataEmptyState as ae } from "../../../metadata-empty-state/metadata-empty-state.js";
14
+ import { AutofillOverlay as ne } from "../autofill-overlay/autofill-overlay.js";
15
+ import { CustomInstance as se } from "../custom-instance/custom-instance.js";
16
+ import { c as re } from "../../../../../../chunks/utils.js";
17
+ import { s as d, M as ie } from "../../../../../../chunks/metadata-instance-form-card-wrapper.js";
18
+ import { jsx as t, jsxs as D } from "react/jsx-runtime";
19
+ import { UnsavedChangesModal as le } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
20
+ const me = ({
20
21
  dirty: i,
21
22
  onChange: l,
22
- values: t
23
+ values: o
23
24
  }) => {
24
- const s = O(t);
25
- return i && !Q(s.current.metadata.fields, t.metadata.fields) && (s.current = t, l(t)), null;
26
- }, Ie = (i) => {
25
+ const s = O(o);
26
+ return i && !X(s.current.metadata.fields, o.metadata.fields) && (s.current = o, l(o)), null;
27
+ }, Ae = (i) => {
27
28
  const {
28
29
  areAiSuggestionsAvailable: l,
29
- customRef: t,
30
+ customRef: o,
30
31
  isLargeFile: s,
31
32
  errorCode: m,
32
33
  isAiSuggestionsFeatureEnabled: c,
33
- isAdvancedExtractAgentEnabled: I = !1,
34
+ isAdvancedExtractAgentEnabled: v = !1,
34
35
  isBetaLanguageEnabled: x,
35
- isDeleteButtonDisabled: A,
36
- isDeleteConfirmationModalCheckboxEnabled: v,
37
- isMultilevelTaxonomyFieldEnabled: p,
36
+ isDeleteButtonDisabled: I,
37
+ isDeleteConfirmationModalCheckboxEnabled: A,
38
+ isMultilevelTaxonomyFieldEnabled: f,
38
39
  isUnsavedChangesModalOpen: T = !1,
39
- MetadataInstanceFormCustomWrapper: L,
40
+ MetadataInstanceFormCustomWrapper: R,
40
41
  selectedTemplateInstance: e,
41
- onCancel: R,
42
- onChange: f,
43
- onDelete: k,
44
- onDiscardUnsavedChanges: N,
45
- onSubmit: P,
42
+ onCancel: L,
43
+ onChange: p,
44
+ onDelete: P,
45
+ onDiscardUnsavedChanges: k,
46
+ onSubmit: N,
46
47
  setIsUnsavedChangesModalOpen: u,
47
- taxonomyOptionsFetcher: g
48
- } = i, U = L ?? se, [B, h] = S(!1), {
48
+ taxonomyOptionsFetcher: g,
49
+ isConfidenceScoreReviewEnabled: U = !1
50
+ } = i, w = R ?? ie, [B, C] = S(!1), {
49
51
  isFetchingSuggestions: n,
50
- isLongLoading: C,
51
- getAiSuggestions: w,
52
+ isLongLoading: h,
53
+ getAiSuggestions: K,
52
54
  clearState: E,
53
- suggestions: K
54
- } = Z();
55
+ suggestions: V
56
+ } = ee();
55
57
  y(() => () => {
56
58
  E();
57
59
  }, [E, e?.id]);
58
- const F = e?.templateKey === Y, V = async (a) => {
59
- await P(a, ne(a, e));
60
- }, W = (a) => {
61
- a ? u(!0) : R();
62
- }, j = () => {
63
- h(!0);
64
- }, _ = {
60
+ const b = e?.templateKey === Z, W = async (a) => {
61
+ await N(a, re(a, e));
62
+ }, j = (a) => {
63
+ a ? u(!0) : L();
64
+ }, _ = () => {
65
+ C(!0);
66
+ }, $ = {
65
67
  metadata: {
66
68
  ...e
67
69
  }
68
- }, M = O(null), [b, $] = S(null);
70
+ }, F = O(null), [M, q] = S(null);
69
71
  y(() => {
70
- $(t ?? M.current);
71
- }, [t, e?.templateKey, e?.scope]);
72
- const q = X(() => {
72
+ q(o ?? F.current);
73
+ }, [o, e?.templateKey, e?.scope]);
74
+ const J = Y(() => {
73
75
  const a = e?.fields.length === 0;
74
- if (F)
75
- return /* @__PURE__ */ o(oe, {
76
+ if (b)
77
+ return /* @__PURE__ */ t(se, {
76
78
  isLoading: n
77
79
  });
78
80
  if (a)
79
- return /* @__PURE__ */ o(te, {
81
+ return /* @__PURE__ */ t(ae, {
80
82
  isBoxAiSuggestionsFeatureEnabled: c,
81
83
  level: "instance"
82
84
  });
83
85
  const r = !!(n || m);
84
86
  return /* @__PURE__ */ D("div", {
85
- className: z(d.metadataInstanceFormContent, r && d.showOverlay),
86
- children: [/* @__PURE__ */ o(ae, {
87
+ className: G(d.metadataInstanceFormContent, r && d.showOverlay),
88
+ children: [/* @__PURE__ */ t(ne, {
87
89
  errorCode: m,
88
90
  isFetchingSuggestions: n,
89
- isLongLoading: C
90
- }), /* @__PURE__ */ o(ee, {
91
+ isLongLoading: h
92
+ }), /* @__PURE__ */ t(oe, {
91
93
  disableForm: n,
92
- isMultilevelTaxonomyFieldEnabled: p,
93
- portalElement: t ?? b,
94
+ isMultilevelTaxonomyFieldEnabled: f,
95
+ portalElement: o ?? M,
94
96
  taxonomyOptionsFetcher: g
95
97
  })]
96
98
  });
97
- }, [e?.fields.length, F, n, C, t, b, g, c, p, m]);
98
- return /* @__PURE__ */ o(G, {
99
- initialValues: _,
100
- onSubmit: V,
101
- children: ({
102
- values: a,
103
- dirty: r
104
- }) => /* @__PURE__ */ D(H, {
105
- children: [/* @__PURE__ */ o(U, {
106
- areAiSuggestionsAvailable: l,
107
- className: d.metadataInstanceForm,
108
- formRef: M,
109
- formValues: a,
110
- getAiSuggestions: w,
111
- handleCancel: W,
112
- handleDelete: j,
113
- isAdvancedExtractAgentEnabled: I,
114
- isAiSuggestionsFeatureEnabled: c,
115
- isBetaLanguageEnabled: x,
116
- isDeleteButtonDisabled: A,
117
- isFetchingSuggestions: n,
118
- isFormDirty: r,
119
- isLargeFile: s,
120
- selectedTemplateInstance: e,
121
- suggestions: K,
122
- children: e && q
123
- }), f && /* @__PURE__ */ o(ie, {
124
- dirty: r,
125
- onChange: f,
126
- values: a
127
- }), /* @__PURE__ */ o(re, {
128
- onBackToEdit: () => u(!1),
129
- onDiscardChanges: N,
130
- open: T
131
- }), /* @__PURE__ */ o(J, {
132
- isCheckboxEnabled: v,
133
- onConfirm: () => k(e),
134
- onDismiss: () => h(!1),
135
- open: B,
136
- templateName: e?.displayName
137
- })]
138
- })
139
- }, `${e?.scope}.${e?.templateKey}`);
99
+ }, [e?.fields.length, b, n, h, o, M, g, c, f, m]);
100
+ return /* @__PURE__ */ t(te, {
101
+ isConfidenceScoreReviewEnabled: U,
102
+ children: /* @__PURE__ */ t(H, {
103
+ initialValues: $,
104
+ onSubmit: W,
105
+ children: ({
106
+ values: a,
107
+ dirty: r
108
+ }) => /* @__PURE__ */ D(Q, {
109
+ children: [/* @__PURE__ */ t(w, {
110
+ areAiSuggestionsAvailable: l,
111
+ className: d.metadataInstanceForm,
112
+ formRef: F,
113
+ formValues: a,
114
+ getAiSuggestions: K,
115
+ handleCancel: j,
116
+ handleDelete: _,
117
+ isAdvancedExtractAgentEnabled: v,
118
+ isAiSuggestionsFeatureEnabled: c,
119
+ isBetaLanguageEnabled: x,
120
+ isDeleteButtonDisabled: I,
121
+ isFetchingSuggestions: n,
122
+ isFormDirty: r,
123
+ isLargeFile: s,
124
+ selectedTemplateInstance: e,
125
+ suggestions: V,
126
+ children: e && J
127
+ }), p && /* @__PURE__ */ t(me, {
128
+ dirty: r,
129
+ onChange: p,
130
+ values: a
131
+ }), /* @__PURE__ */ t(le, {
132
+ onBackToEdit: () => u(!1),
133
+ onDiscardChanges: k,
134
+ open: T
135
+ }), /* @__PURE__ */ t(z, {
136
+ isCheckboxEnabled: A,
137
+ onConfirm: () => P(e),
138
+ onDismiss: () => C(!1),
139
+ open: B,
140
+ templateName: e?.displayName
141
+ })]
142
+ })
143
+ }, `${e?.scope}.${e?.templateKey}`)
144
+ });
140
145
  };
141
146
  export {
142
- Ie as MetadataInstanceForm
147
+ Ae as MetadataInstanceForm
143
148
  };
@@ -1,29 +1,34 @@
1
- import { getVisibleTemplates as c } from "../../utils/utils.js";
2
- import { MetadataInstance as d } from "./subcomponents/metadata-instance/metadata-instance.js";
3
- import { jsx as a } from "react/jsx-runtime";
1
+ import { ConfidenceScoreContextProvider as d } from "../../utils/confidence-score-context.js";
2
+ import { getVisibleTemplates as f } from "../../utils/utils.js";
3
+ import { MetadataInstance as l } from "./subcomponents/metadata-instance/metadata-instance.js";
4
+ import { jsx as t } from "react/jsx-runtime";
4
5
  import "./subcomponents/metadata-instance-header/metadata-instance-header.js";
5
- import '../../../../styles/metadata-instance-list.css';const p = "_metadataInstanceList_bd83w_1", l = {
6
+ import '../../../../styles/metadata-instance-list.css';const p = "_metadataInstanceList_bd83w_1", I = {
6
7
  metadataInstanceList: p
7
- }, b = ({
8
- areAiSuggestionsAvailable: s,
9
- isAiSuggestionsFeatureEnabled: e,
8
+ }, v = ({
9
+ areAiSuggestionsAvailable: e,
10
+ isAiSuggestionsFeatureEnabled: s,
10
11
  isBetaLanguageEnabled: n,
11
12
  onEdit: i,
12
- templateInstances: m,
13
- taxonomyNodeFetcher: o,
14
- isAdvancedExtractAgentEnabled: r = !1
15
- }) => /* @__PURE__ */ a("div", {
16
- className: l.metadataInstanceList,
17
- children: c(m).map((t) => /* @__PURE__ */ a(d, {
18
- areAiSuggestionsAvailable: s,
19
- isAdvancedExtractAgentEnabled: r,
20
- isAiSuggestionsFeatureEnabled: e,
21
- isBetaLanguageEnabled: n,
22
- onEdit: i,
23
- taxonomyNodeFetcher: o,
24
- templateInstance: t
25
- }, t.id))
13
+ templateInstances: o,
14
+ taxonomyNodeFetcher: r,
15
+ isAdvancedExtractAgentEnabled: m = !1,
16
+ isConfidenceScoreReviewEnabled: c = !1
17
+ }) => /* @__PURE__ */ t(d, {
18
+ isConfidenceScoreReviewEnabled: c,
19
+ children: /* @__PURE__ */ t("div", {
20
+ className: I.metadataInstanceList,
21
+ children: f(o).map((a) => /* @__PURE__ */ t(l, {
22
+ areAiSuggestionsAvailable: e,
23
+ isAdvancedExtractAgentEnabled: m,
24
+ isAiSuggestionsFeatureEnabled: s,
25
+ isBetaLanguageEnabled: n,
26
+ onEdit: i,
27
+ taxonomyNodeFetcher: r,
28
+ templateInstance: a
29
+ }, a.id))
30
+ })
26
31
  });
27
32
  export {
28
- b as MetadataInstanceList
33
+ v as MetadataInstanceList
29
34
  };
@@ -0,0 +1,24 @@
1
+ import { createContext as t, useMemo as c, useContext as s } from "react";
2
+ import { jsx as i } from "react/jsx-runtime";
3
+ const r = /* @__PURE__ */ t(null), C = ({
4
+ children: e,
5
+ isConfidenceScoreReviewEnabled: o
6
+ }) => {
7
+ const n = c(() => ({
8
+ isConfidenceScoreReviewEnabled: o
9
+ }), [o]);
10
+ return /* @__PURE__ */ i(r.Provider, {
11
+ value: n,
12
+ children: e
13
+ });
14
+ }, f = () => {
15
+ const e = s(r);
16
+ if (!e)
17
+ throw new Error("useConfidenceScore should be wrapped inside ConfidenceScoreContextProvider");
18
+ return e;
19
+ };
20
+ export {
21
+ r as ConfidenceScoreContext,
22
+ C as ConfidenceScoreContextProvider,
23
+ f as useIsConfidenceScoreReviewEnabled
24
+ };
@@ -26,6 +26,7 @@ export type MetadataInstanceFormProps = {
26
26
  customRef?: HTMLDivElement | null;
27
27
  MetadataInstanceFormCustomWrapper?: React.ComponentType<MetadataInstanceFormWrapperProps<null>>;
28
28
  isAdvancedExtractAgentEnabled?: boolean;
29
+ isConfidenceScoreReviewEnabled?: boolean;
29
30
  };
30
31
  export type MetadataInstanceFormWrapperProps<T> = {
31
32
  areAiSuggestionsAvailable: boolean;
@@ -1,2 +1,2 @@
1
1
  import { MetadataInstanceListProps } from './types';
2
- export declare const MetadataInstanceList: ({ areAiSuggestionsAvailable, isAiSuggestionsFeatureEnabled, isBetaLanguageEnabled, onEdit, templateInstances, taxonomyNodeFetcher, isAdvancedExtractAgentEnabled, }: MetadataInstanceListProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MetadataInstanceList: ({ areAiSuggestionsAvailable, isAiSuggestionsFeatureEnabled, isBetaLanguageEnabled, onEdit, templateInstances, taxonomyNodeFetcher, isAdvancedExtractAgentEnabled, isConfidenceScoreReviewEnabled, }: MetadataInstanceListProps) => import("react/jsx-runtime").JSX.Element;
@@ -5,6 +5,7 @@ export type MetadataInstanceListProps = {
5
5
  isAiSuggestionsFeatureEnabled: boolean;
6
6
  isBetaLanguageEnabled: boolean;
7
7
  isAdvancedExtractAgentEnabled?: boolean;
8
+ isConfidenceScoreReviewEnabled?: boolean;
8
9
  onEdit: (templateInstacne: MetadataTemplateInstance) => void;
9
10
  templateInstances: MetadataTemplateInstance[];
10
11
  taxonomyNodeFetcher: TaxonomyNodeFetcher;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export interface ConfidenceScoreContextType {
3
+ isConfidenceScoreReviewEnabled: boolean;
4
+ }
5
+ export interface ConfidenceScoreContextProviderProps {
6
+ children: React.ReactNode;
7
+ isConfidenceScoreReviewEnabled: boolean;
8
+ }
9
+ export declare const ConfidenceScoreContext: React.Context<ConfidenceScoreContextType>;
10
+ export declare const ConfidenceScoreContextProvider: ({ children, isConfidenceScoreReviewEnabled, }: ConfidenceScoreContextProviderProps) => React.ReactElement;
11
+ export declare const useIsConfidenceScoreReviewEnabled: () => ConfidenceScoreContextType;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
- "@box/box-ai-agent-selector": "^1.28.0",
7
- "@box/blueprint-web": "^12.133.0",
8
- "@box/blueprint-web-assets": "^4.99.7",
9
- "@box/combobox-with-api": "^1.29.0",
6
+ "@box/box-ai-agent-selector": "^1.28.1",
7
+ "@box/blueprint-web": "^12.133.1",
8
+ "@box/blueprint-web-assets": "^4.99.8",
9
+ "@box/combobox-with-api": "^1.29.1",
10
10
  "formik": "^2.0.3",
11
11
  "lodash": "^4.17.15",
12
12
  "react": "^17.0.0 || ^18.0.0",
@@ -15,11 +15,11 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@ariakit/react": "0.4.15",
18
- "@box/box-ai-agent-selector": "^1.28.0",
18
+ "@box/box-ai-agent-selector": "^1.28.1",
19
19
  "@box/babel-plugin-target-attributes": "1.4.0",
20
- "@box/blueprint-web": "^12.133.0",
21
- "@box/blueprint-web-assets": "^4.99.7",
22
- "@box/storybook-utils": "^0.16.33",
20
+ "@box/blueprint-web": "^12.133.1",
21
+ "@box/blueprint-web-assets": "^4.99.8",
22
+ "@box/storybook-utils": "^0.16.34",
23
23
  "@testing-library/react": "^15.0.6",
24
24
  "react": "^18.3.0",
25
25
  "react-dom": "^18.3.0",