@box/metadata-editor 0.61.1 → 0.61.2

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,9 +1,9 @@
1
- import { useReducer as I } from "react";
1
+ import { useReducer as i } from "react";
2
2
  import { RequestStates as u } from "./request.js";
3
3
  var s = /* @__PURE__ */ function(r) {
4
4
  return r.LOAD_MORE = "LOAD_MORE", r.RELOAD = "RELOAD", r.SEARCH = "SEARCH", r.SET_ERROR = "SET_ERROR", r.SET_LOADING = "SET_LOADING", r;
5
5
  }(s || {});
6
- function i(r, e) {
6
+ function I(r, e) {
7
7
  switch (e.type) {
8
8
  case s.LOAD_MORE:
9
9
  return {
@@ -52,50 +52,64 @@ function i(r, e) {
52
52
  throw new Error(`Invalid action type "${e.type}"`);
53
53
  }
54
54
  }
55
- function C(r) {
56
- const {
57
- load: e
58
- } = r, [t, l] = I(i, {
59
- error: null,
60
- items: [],
61
- requestInitiator: null,
62
- requestState: u.NOT_STARTED,
63
- searchInput: ""
64
- }), a = async (o, S) => {
65
- var E;
66
- const R = new AbortController();
55
+ function E(r, e) {
56
+ return r.type === s.SEARCH && e.requestState === u.IN_PROGRESS;
57
+ }
58
+ function S(r, e) {
59
+ return e.requestInitiator === s.LOAD_MORE && e.requestState === u.IN_PROGRESS && r.type === s.LOAD_MORE;
60
+ }
61
+ function a(r, e) {
62
+ return E(r, e) || S(r, e);
63
+ }
64
+ function m(r, e) {
65
+ var t;
66
+ E(r, e) && e.abortController.abort(), S(r, e) && ((t = r.abortController) == null || t.abort());
67
+ }
68
+ function p(r, e) {
69
+ return S(r, e);
70
+ }
71
+ async function R(r, e, t, n) {
72
+ const l = new AbortController();
73
+ if (a(r, t) && m(r, t), !p(r, t)) {
74
+ n({
75
+ type: s.SET_LOADING,
76
+ requestInitiator: r.type,
77
+ abortController: l
78
+ });
67
79
  try {
68
- if (o.type === s.SEARCH && t.requestState === u.IN_PROGRESS && t.abortController.abort(), t.requestInitiator === s.LOAD_MORE && t.requestState === u.IN_PROGRESS && o.type === s.LOAD_MORE) {
69
- (E = o.abortController) == null || E.abort();
70
- return;
71
- }
72
- l({
73
- type: s.SET_LOADING,
74
- requestInitiator: o.type,
75
- abortController: R
76
- });
77
- const n = await S({
80
+ const o = await e({
78
81
  items: t.items.slice(),
79
- signal: R.signal,
80
- marker: o.type === s.LOAD_MORE ? t.marker : null,
81
- searchInput: o.searchInput ?? t.searchInput
82
- }), O = n.searchInput ?? o.searchInput ?? t.searchInput;
83
- l({
84
- type: o.type,
85
- ...n,
82
+ signal: l.signal,
83
+ marker: r.type === s.LOAD_MORE ? t.marker : null,
84
+ searchInput: r.searchInput ?? t.searchInput
85
+ }), O = o.searchInput ?? r.searchInput ?? t.searchInput;
86
+ n({
87
+ type: r.type,
88
+ ...o,
86
89
  searchInput: O,
87
- abortController: R
90
+ abortController: l
88
91
  });
89
- } catch (n) {
90
- if ((n == null ? void 0 : n.name) === "AbortError")
92
+ } catch (o) {
93
+ if ((o == null ? void 0 : o.name) === "AbortError")
91
94
  return;
92
- l({
95
+ n({
93
96
  type: s.SET_ERROR,
94
- error: n,
95
- abortController: R
97
+ error: o,
98
+ abortController: l
96
99
  });
97
100
  }
98
- };
101
+ }
102
+ }
103
+ function C(r) {
104
+ const {
105
+ load: e
106
+ } = r, [t, n] = i(I, {
107
+ error: null,
108
+ items: [],
109
+ requestInitiator: null,
110
+ requestState: u.NOT_STARTED,
111
+ searchInput: ""
112
+ });
99
113
  return {
100
114
  hasError: t.requestState === u.ERROR,
101
115
  hasNextPage: t.requestState === u.ERROR ? !1 : t.marker != null,
@@ -103,20 +117,18 @@ function C(r) {
103
117
  isLoading: t.requestState === u.IN_PROGRESS,
104
118
  isReloading: t.requestState === u.IN_PROGRESS && (t.requestInitiator === s.RELOAD || t.requestInitiator === s.SEARCH),
105
119
  items: t.items,
106
- loadMore: () => a({
120
+ loadMore: () => R({
107
121
  type: s.LOAD_MORE
108
- }, e),
109
- reload: () => {
110
- a({
111
- type: s.RELOAD
112
- }, e);
113
- },
122
+ }, e, t, n),
123
+ reload: () => R({
124
+ type: s.RELOAD
125
+ }, e, t, n),
114
126
  requestInitiator: t.requestInitiator,
115
127
  searchInput: t.searchInput,
116
- search: (o) => a({
128
+ search: (l) => R({
117
129
  type: s.SEARCH,
118
- searchInput: o
119
- }, e)
130
+ searchInput: l
131
+ }, e, t, n)
120
132
  };
121
133
  }
122
134
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.61.1",
3
+ "version": "0.61.2",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.5",
6
6
  "@box/blueprint-web": "^7.30.3",
@@ -53,5 +53,5 @@
53
53
  "**/*.css"
54
54
  ],
55
55
  "license": "SEE LICENSE IN LICENSE",
56
- "gitHead": "e2f69a163f18e91fd7f4c4afc4778636657815a0"
56
+ "gitHead": "1a9265fe9212f894e9e9a8d86c1969ef1d602004"
57
57
  }