@box/metadata-editor 0.126.0 → 0.127.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.
@@ -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 A } from "../chunks/types.js";
7
- import { withApiWrapper as U } from "./lib/utils/api-wrapper.js";
8
- import { AutofillContext as T, AutofillContextProvider as _, TIMEOUT_10_SECONDS as E, useAutofill as L } from "./lib/utils/autofill-context.js";
9
- import { AddMetadataTemplateDropdown as c } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
10
- import { ComboboxWithApiPagination as D } from "./lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js";
11
- import { FilterInstancesDropdown as N } from "./lib/components/filter-instances-dropdown/filter-instances-dropdown.js";
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 h } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
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 v } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
16
- import { MetadataInstanceForm as J } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
17
- import { J as y } from "../chunks/utils.js";
18
- import { MetadataInstanceList as X } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
19
- import { MetadataInstanceHeader as j } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
20
- import { MetadataInstance as q } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance/metadata-instance.js";
21
- import { UnsavedChangesModal as G } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
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
- c as AddMetadataTemplateDropdown,
24
- T as AutofillContext,
25
- _ as AutofillContextProvider,
26
- D as ComboboxWithApiPagination,
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
- h as DeleteConfirmationModal,
29
+ g as DeleteConfirmationModal,
29
30
  e as FilterDropdownMenu,
30
- N as FilterInstancesDropdown,
31
- y as JSONPatchOp,
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
- q as MetadataInstance,
38
- J as MetadataInstanceForm,
38
+ z as MetadataInstance,
39
+ W as MetadataInstanceForm,
39
40
  b as MetadataInstanceFormAutofillButton,
40
- v as MetadataInstanceFormHeader,
41
- j as MetadataInstanceHeader,
42
- X as MetadataInstanceList,
43
- E as TIMEOUT_10_SECONDS,
44
- G as UnsavedChangesModal,
45
- A as UpdateMode,
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
- L as useAutofill,
49
- U as withApiWrapper
49
+ O as useAutofill,
50
+ u as withApiWrapper
50
51
  };
@@ -1,86 +1,86 @@
1
- import w from "clsx";
2
- import { useFormikContext as C } from "formik";
3
- import T from "lodash/isUndefined";
4
- import { forwardRef as U, useState as $, useCallback as j, useEffect as x, useMemo as D } from "react";
5
- import { UpdateModeFieldWrapper as L } from "./components/update-mode-field-wrapper/update-mode-field-wrapper.js";
6
- import { editorFieldTypes as R } from "./editor-field-types.js";
7
- import { s as p } from "../../../../chunks/utils2.js";
8
- import { jsx as r, jsxs as b } from "react/jsx-runtime";
9
- import { AiSuggestionField as B } from "./components/ai-suggestion-field/ai-suggestion-field.js";
10
- var t = /* @__PURE__ */ function(o) {
11
- return o.Pending = "PENDING", o.Applied = "APPLIED", o.Initial = "INITIAL", o;
12
- }(t || {});
13
- const Z = /* @__PURE__ */ U(({
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: F,
18
- taxonomyOptionsFetcher: f,
19
- isMultilevelTaxonomyFieldEnabled: y
20
- }, I) => {
15
+ index: V,
16
+ taxonomyOptionsFetcher: y,
17
+ isMultilevelTaxonomyFieldEnabled: h
18
+ }, x) => {
21
19
  var v;
22
20
  const {
23
- setFieldValue: l
24
- } = C(), [d, u] = $(t.Initial), n = d === t.Pending, N = d === t.Applied, P = d === t.Initial, g = R[e.type], {
25
- aiSuggestion: i,
26
- type: h,
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, M = g && !e.hidden, E = !T(e.updateMode), s = `metadata.fields[${F}]`, V = e.type === "taxonomy" && ((v = e.optionsRules) == null ? void 0 : v.multiSelect), W = w({
29
- [p.suggestionApplied]: N,
30
- [p.hasSuggestion]: n,
31
- [p.dateField]: h === "date"
32
- }), a = j((A) => {
33
- l(`${s}.value`, A), u(t.Applied);
34
- }, [s, l]), m = () => {
35
- u(t.Initial), l(`${s}.aiSuggestion`, void 0);
36
- };
37
- x(() => {
38
- n && !c && a(i);
39
- }, [i, n, a]), x(() => {
40
- P && i && u(t.Pending);
41
- }, [P, i]);
42
- const k = D(() => i && c === i, [n]);
43
- return M ? E ? /* @__PURE__ */ r(L, {
44
- fieldNamePrefix: s,
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: V,
47
- children: /* @__PURE__ */ r(g, {
48
- ref: I,
46
+ isTaxonomyMultiSelect: w,
47
+ children: /* @__PURE__ */ l(u, {
48
+ ref: x,
49
49
  description: e.description,
50
- disableForm: o,
51
- fieldNamePrefix: s,
50
+ disableForm: A,
51
+ fieldNamePrefix: i,
52
52
  isAiSuggestionApplied: !1,
53
- isMultilevelTaxonomyFieldEnabled: y,
53
+ isMultilevelTaxonomyFieldEnabled: h,
54
54
  label: e.displayName,
55
55
  levels: e.levels,
56
56
  onValueEdited: m,
57
- portalElement: S,
58
- taxonomyOptionsFetcher: f
57
+ portalElement: f,
58
+ taxonomyOptionsFetcher: y
59
59
  })
60
- }, e.key) : /* @__PURE__ */ b("div", {
61
- className: p.fieldWrapper,
62
- children: [/* @__PURE__ */ r(g, {
63
- ref: I,
64
- className: W,
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: o,
67
- fieldNamePrefix: s,
68
- isAiSuggestionApplied: N,
69
- isMultilevelTaxonomyFieldEnabled: y,
66
+ disableForm: A,
67
+ fieldNamePrefix: i,
68
+ isAiSuggestionApplied: F,
69
+ isMultilevelTaxonomyFieldEnabled: h,
70
70
  label: e.displayName,
71
71
  onValueEdited: m,
72
- portalElement: S,
73
- taxonomyOptionsFetcher: f
74
- }), n && /* @__PURE__ */ r(B, {
75
- aiSuggestion: i,
76
- isSameValue: k,
72
+ portalElement: f,
73
+ taxonomyOptionsFetcher: y
74
+ }), a && /* @__PURE__ */ l(q, {
75
+ aiSuggestion: t,
76
+ isSameValue: $,
77
77
  onAiSuggestionAppend: () => {
78
- const A = [...new Set([c, i].flat().filter(Boolean))];
79
- a(A);
78
+ const p = [...new Set([c, t].flat().filter(Boolean))];
79
+ r(p);
80
80
  },
81
81
  onAiSuggestionIgnore: m,
82
- onAiSuggestionReplace: () => a(i),
83
- type: h
82
+ onAiSuggestionReplace: () => r(t),
83
+ type: N
84
84
  })]
85
85
  }, e.key) : null;
86
86
  });
@@ -39,9 +39,15 @@ export type TaxonomyOptionsRules = {
39
39
  multiSelect: boolean;
40
40
  selectableLevels: number[];
41
41
  };
42
+ export declare enum AiSuggestionState {
43
+ Initial = "INITIAL",
44
+ Pending = "PENDING",
45
+ Applied = "APPLIED"
46
+ }
42
47
  export type MetadataTemplateField = {
43
48
  description?: string;
44
49
  aiSuggestion?: MetadataFieldValue;
50
+ aiSuggestionState?: AiSuggestionState;
45
51
  displayName?: string;
46
52
  hidden: boolean;
47
53
  id?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.126.0",
3
+ "version": "0.127.1",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
6
  "@box/box-ai-agent-selector": "^0.41.7",
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@ariakit/react": "0.4.15",
18
- "@box/box-ai-agent-selector": "^0.55.0",
18
+ "@box/box-ai-agent-selector": "^0.55.1",
19
19
  "@box/babel-plugin-target-attributes": "1.3.0",
20
- "@box/blueprint-web": "^12.60.0",
20
+ "@box/blueprint-web": "^12.60.1",
21
21
  "@box/blueprint-web-assets": "^4.64.0",
22
22
  "@box/storybook-utils": "^0.13.19",
23
23
  "@testing-library/react": "^15.0.6",