@box/metadata-editor 0.51.0 → 0.51.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,27 +1,24 @@
1
- import { createContext as w, useState as f, useCallback as C, useMemo as A, useContext as v } from "react";
1
+ import { createContext as C, useState as g, useCallback as p, useMemo as A, useContext as v } from "react";
2
2
  import { TEMPLATE_CUSTOM_PROPERTIES as x } from "../constants.js";
3
- import { jsx as y } from "react/jsx-runtime";
4
- import "@storybook/test";
5
- const E = async (o, s) => s.map((t) => ({
6
- ...t,
7
- aiSuggestion: `${t.key} suggestion`
8
- })), m = /* @__PURE__ */ w(null), I = ({
9
- children: o,
10
- isAiSuggestionsFeatureEnabled: s
3
+ import { fetchSuggestions as E } from "./utils.js";
4
+ import { jsx as P } from "react/jsx-runtime";
5
+ const m = /* @__PURE__ */ C(null), y = ({
6
+ children: e,
7
+ isAiSuggestionsFeatureEnabled: n
11
8
  }) => {
12
- const [t, S] = f({}), [i, u] = f(!1), a = C(async (n, c, p = !1) => {
13
- let r = [];
14
- if (!s)
9
+ const [t, h] = g({}), [i, u] = g(!1), a = p(async (r, l, w = !1) => {
10
+ let s = [];
11
+ if (!n)
15
12
  throw new Error("AI Suggestions feature not available.");
16
- if (n === x)
13
+ if (r === x)
17
14
  throw new Error("Can't fetch suggestions for Custom Metadata instance");
18
- if (!t[n] || p) {
15
+ if (!t[r] || w) {
19
16
  u(!0);
20
17
  try {
21
- r = await E(n, c), S({
18
+ s = await E(r, l), h({
22
19
  ...t,
23
- [n]: {
24
- ...Object.fromEntries(r.map((e) => [e.key, e.aiSuggestion]))
20
+ [r]: {
21
+ ...Object.fromEntries(s.map((o) => [o.key, o.aiSuggestion]))
25
22
  }
26
23
  });
27
24
  } catch {
@@ -29,35 +26,35 @@ const E = async (o, s) => s.map((t) => ({
29
26
  u(!1);
30
27
  }
31
28
  } else
32
- r = c.map((e) => {
33
- var g;
34
- const l = (g = t == null ? void 0 : t.templateKey) == null ? void 0 : g[e.key];
29
+ s = l.map((o) => {
30
+ var f;
31
+ const c = (f = t == null ? void 0 : t.templateKey) == null ? void 0 : f[o.key];
35
32
  return {
36
- ...e,
37
- ...l ? {
38
- aiSuggestion: l
33
+ ...o,
34
+ ...c ? {
35
+ aiSuggestion: c
39
36
  } : null
40
37
  };
41
38
  });
42
- return r;
43
- }, [t]), h = A(() => ({
39
+ return s;
40
+ }, [t]), S = A(() => ({
44
41
  getAiSuggestions: a,
45
- isAiSuggestionsFeatureEnabled: s,
42
+ isAiSuggestionsFeatureEnabled: n,
46
43
  isFetchingSuggestions: i,
47
44
  suggestions: t
48
- }), [a, s, i, t]);
49
- return /* @__PURE__ */ y(m.Provider, {
50
- value: h,
51
- children: o
45
+ }), [a, n, i, t]);
46
+ return /* @__PURE__ */ P(m.Provider, {
47
+ value: S,
48
+ children: e
52
49
  });
53
- }, O = () => {
54
- const o = v(m);
55
- if (!o)
50
+ }, I = () => {
51
+ const e = v(m);
52
+ if (!e)
56
53
  throw new Error("useAutofill should be wrapped inside AutofillProvider");
57
- return o;
54
+ return e;
58
55
  };
59
56
  export {
60
57
  m as AutofillContext,
61
- I as AutofillContextProvider,
62
- O as useAutofill
58
+ y as AutofillContextProvider,
59
+ I as useAutofill
63
60
  };
@@ -0,0 +1,7 @@
1
+ const g = async (s, t) => t.map((e) => ({
2
+ ...e,
3
+ aiSuggestion: `${e.key} suggestion`
4
+ }));
5
+ export {
6
+ g as fetchSuggestions
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.51.0",
3
+ "version": "0.51.1",
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": "9088f58268c90960efb20ef3c5c4f03d66af30b8"
55
+ "gitHead": "114a9fc84dfc0b21d45b6b647064e736ea022384"
56
56
  }
@@ -3,4 +3,3 @@ export declare const updateText: (el: any, text: any) => Promise<void>;
3
3
  export declare const blur: () => Promise<void>;
4
4
  export declare const updateTextAndBlur: (el: any, text: any) => Promise<void>;
5
5
  export declare const checkIfFormFieldsAreDisabled: (canvasElement: HTMLElement, fields: MetadataTemplateField[]) => Promise<void>;
6
- export declare const fetchSuggestions: (templateKey: string, fields: MetadataTemplateField[]) => Promise<MetadataTemplateField[]>;
@@ -0,0 +1,2 @@
1
+ import { type MetadataTemplateField } from '../types';
2
+ export declare const fetchSuggestions: (templateKey: string, fields: MetadataTemplateField[]) => Promise<MetadataTemplateField[]>;