@box/metadata-template-browser 1.17.31 → 1.18.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.
|
@@ -13,7 +13,7 @@ var o = (e) => new Promise((t, n) => {
|
|
|
13
13
|
let t = e();
|
|
14
14
|
t instanceof Promise && t.catch(() => void 0);
|
|
15
15
|
} catch {}
|
|
16
|
-
}, c = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "An unknown error occurred",
|
|
16
|
+
}, c = (e) => e.trim().replaceAll(/\s+/g, " "), l = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "An unknown error occurred", u = async (e, t, n, r) => {
|
|
17
17
|
try {
|
|
18
18
|
let r = await t();
|
|
19
19
|
e.aborted || n(r);
|
|
@@ -21,139 +21,141 @@ var o = (e) => new Promise((t, n) => {
|
|
|
21
21
|
e.aborted || r(t);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
|
|
24
|
+
function d(d, f, p, m, h) {
|
|
25
|
+
let g = i(null), _ = i(null), v = i(a(async (t) => {
|
|
26
|
+
_.current?.abort();
|
|
27
27
|
let n = new AbortController();
|
|
28
|
-
|
|
28
|
+
_.current = n;
|
|
29
29
|
let { signal: r } = n;
|
|
30
|
-
s(() =>
|
|
30
|
+
s(() => f.current.onSearchChange?.(t)), s(() => f.current.onNewViewLoading?.(!0)), await u(r, () => T(t, r), (t) => m({
|
|
31
31
|
type: e.SearchLoaded,
|
|
32
32
|
results: t.entries,
|
|
33
33
|
nextMarker: t.next_marker
|
|
34
|
-
}), (t) =>
|
|
34
|
+
}), (t) => m({
|
|
35
35
|
type: e.SearchError,
|
|
36
|
-
error:
|
|
37
|
-
})), r.aborted || s(() =>
|
|
38
|
-
}, 500)),
|
|
39
|
-
h.current?.abort();
|
|
40
|
-
let e = new AbortController();
|
|
41
|
-
return h.current = e, e.signal;
|
|
42
|
-
}, y = () => {
|
|
43
|
-
h.current?.abort(), h.current = null;
|
|
44
|
-
}, b = () => {
|
|
36
|
+
error: l(t)
|
|
37
|
+
})), r.aborted || s(() => f.current.onNewViewLoading?.(!1));
|
|
38
|
+
}, 500)), y = () => {
|
|
45
39
|
g.current?.abort();
|
|
46
40
|
let e = new AbortController();
|
|
47
41
|
return g.current = e, e.signal;
|
|
48
|
-
},
|
|
42
|
+
}, b = () => {
|
|
49
43
|
g.current?.abort(), g.current = null;
|
|
50
|
-
},
|
|
51
|
-
|
|
44
|
+
}, x = () => {
|
|
45
|
+
_.current?.abort();
|
|
46
|
+
let e = new AbortController();
|
|
47
|
+
return _.current = e, e.signal;
|
|
48
|
+
}, S = () => {
|
|
49
|
+
_.current?.abort(), _.current = null;
|
|
50
|
+
}, C = (e, n, r) => {
|
|
51
|
+
let i = d.current.getNamespaces;
|
|
52
52
|
return i ? Promise.race([i(e, {
|
|
53
53
|
limit: 200,
|
|
54
54
|
marker: r,
|
|
55
55
|
signal: n
|
|
56
56
|
}), o(n)]) : Promise.resolve(t);
|
|
57
|
-
},
|
|
58
|
-
let i =
|
|
57
|
+
}, w = (e, t, r) => {
|
|
58
|
+
let i = d.current.getTemplates;
|
|
59
59
|
return i ? Promise.race([i(e, {
|
|
60
60
|
limit: 200,
|
|
61
61
|
marker: r,
|
|
62
62
|
signal: t
|
|
63
63
|
}), o(t)]) : Promise.resolve(n);
|
|
64
|
-
},
|
|
65
|
-
let i =
|
|
64
|
+
}, T = (e, t, r) => {
|
|
65
|
+
let i = d.current.getSearchResults;
|
|
66
66
|
return i ? Promise.race([i(e, {
|
|
67
67
|
limit: 200,
|
|
68
68
|
marker: r,
|
|
69
69
|
signal: t
|
|
70
70
|
}), o(t)]) : Promise.resolve(n);
|
|
71
|
-
},
|
|
72
|
-
|
|
71
|
+
}, E = (e, t) => {
|
|
72
|
+
m({
|
|
73
73
|
type: e,
|
|
74
|
-
error:
|
|
74
|
+
error: l(t)
|
|
75
75
|
});
|
|
76
|
-
},
|
|
76
|
+
}, D = async (t, r, i) => {
|
|
77
77
|
let a = !1;
|
|
78
|
-
return await
|
|
79
|
-
let e = await
|
|
80
|
-
return [e, e.next_marker ? n : await
|
|
78
|
+
return await u(r, async () => {
|
|
79
|
+
let e = await C(t, r);
|
|
80
|
+
return [e, e.next_marker ? n : await w(t, r)];
|
|
81
81
|
}, ([t, n]) => {
|
|
82
|
-
|
|
82
|
+
m({
|
|
83
83
|
type: e.BrowseLoaded,
|
|
84
84
|
namespaces: t.entries,
|
|
85
85
|
namespaceNextMarker: t.next_marker,
|
|
86
86
|
templates: n.entries,
|
|
87
87
|
templateNextMarker: n.next_marker
|
|
88
88
|
}), a = !0;
|
|
89
|
-
}, (e) =>
|
|
90
|
-
},
|
|
91
|
-
let t =
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
let n =
|
|
95
|
-
|
|
89
|
+
}, (e) => E(i, e)), a;
|
|
90
|
+
}, O = async () => {
|
|
91
|
+
let t = y(), { namespaceFQN: n } = p.current;
|
|
92
|
+
m({ type: e.BrowseFetchStart }), s(() => f.current.onNewViewLoading?.(!0)), await D(n, t, e.InitialLoadError), t.aborted || s(() => f.current.onNewViewLoading?.(!1));
|
|
93
|
+
}, k = async (t) => {
|
|
94
|
+
let n = y(), r = p.current;
|
|
95
|
+
h.current.set(r.namespaceFQN, {
|
|
96
96
|
namespaces: r.namespaces,
|
|
97
97
|
templates: r.templates,
|
|
98
98
|
namespaceNextMarker: r.namespaceNextMarker,
|
|
99
99
|
templateNextMarker: r.templateNextMarker,
|
|
100
100
|
isNamespacesExhausted: r.isNamespacesExhausted
|
|
101
|
-
}),
|
|
101
|
+
}), m({
|
|
102
102
|
type: e.NavigateTo,
|
|
103
103
|
namespace: t
|
|
104
|
-
}),
|
|
105
|
-
let i = await
|
|
106
|
-
n.aborted || (s(() =>
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
let n =
|
|
110
|
-
n && (
|
|
104
|
+
}), m({ type: e.BrowseFetchStart }), s(() => f.current.onNewViewLoading?.(!0));
|
|
105
|
+
let i = await D(t.id, n, e.BrowseError);
|
|
106
|
+
n.aborted || (s(() => f.current.onNewViewLoading?.(!1)), i && s(() => f.current.onNamespaceChange?.(t.id)));
|
|
107
|
+
}, A = (t) => {
|
|
108
|
+
b();
|
|
109
|
+
let n = h.current.get(t);
|
|
110
|
+
n && (m({
|
|
111
111
|
type: e.NavigateBack,
|
|
112
112
|
fqn: t,
|
|
113
113
|
cached: n
|
|
114
|
-
}), s(() =>
|
|
115
|
-
},
|
|
116
|
-
|
|
114
|
+
}), s(() => f.current.onNamespaceChange?.(t)));
|
|
115
|
+
}, j = (t) => {
|
|
116
|
+
m({
|
|
117
117
|
type: e.SearchValueChange,
|
|
118
118
|
value: t
|
|
119
|
-
})
|
|
120
|
-
|
|
119
|
+
});
|
|
120
|
+
let n = c(t);
|
|
121
|
+
if (n === "") {
|
|
122
|
+
v.current.cancel(), S(), m({ type: e.SearchClear }), s(() => f.current.onSearchChange?.("")), s(() => f.current.onNewViewLoading?.(!1));
|
|
121
123
|
return;
|
|
122
124
|
}
|
|
123
|
-
|
|
125
|
+
m({
|
|
124
126
|
type: e.SearchFetchStart,
|
|
125
|
-
query:
|
|
126
|
-
}),
|
|
127
|
-
},
|
|
128
|
-
let { namespaceFQN: t, searchQuery: r, searchNextMarker: i, namespaceNextMarker: a, templateNextMarker: o, isNamespacesExhausted: s } =
|
|
129
|
-
if (!(d ||
|
|
130
|
-
|
|
127
|
+
query: n
|
|
128
|
+
}), v.current(n);
|
|
129
|
+
}, M = async () => {
|
|
130
|
+
let { namespaceFQN: t, searchQuery: r, searchNextMarker: i, namespaceNextMarker: a, templateNextMarker: o, isNamespacesExhausted: s } = p.current, c = !!r, d = c && !!i, f = !c && !s && !!a, g = !c && !!o;
|
|
131
|
+
if (!(d || f || g)) return;
|
|
132
|
+
m({ type: e.LoadMoreStart });
|
|
131
133
|
let _ = (t) => {
|
|
132
|
-
|
|
134
|
+
m({
|
|
133
135
|
type: e.LoadMoreError,
|
|
134
|
-
error:
|
|
136
|
+
error: l(t)
|
|
135
137
|
});
|
|
136
|
-
},
|
|
137
|
-
let n =
|
|
138
|
+
}, v = (e) => {
|
|
139
|
+
let n = h.current.get(t);
|
|
138
140
|
n && e(n);
|
|
139
141
|
};
|
|
140
142
|
if (d) {
|
|
141
|
-
let t =
|
|
142
|
-
await
|
|
143
|
+
let t = x();
|
|
144
|
+
await u(t, () => T(r, t, i), (t) => m({
|
|
143
145
|
type: e.LoadMoreSearchLoaded,
|
|
144
146
|
entries: t.entries,
|
|
145
147
|
nextMarker: t.next_marker
|
|
146
148
|
}), _);
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
|
-
if (
|
|
150
|
-
let r =
|
|
151
|
-
await
|
|
152
|
-
let e = await
|
|
153
|
-
return [e, e.next_marker ? n : await
|
|
151
|
+
if (f) {
|
|
152
|
+
let r = y();
|
|
153
|
+
await u(r, async () => {
|
|
154
|
+
let e = await C(t, r, a);
|
|
155
|
+
return [e, e.next_marker ? n : await w(t, r)];
|
|
154
156
|
}, ([t, n]) => {
|
|
155
157
|
let r = !t.next_marker;
|
|
156
|
-
|
|
158
|
+
m({
|
|
157
159
|
type: e.LoadMoreNamespacesLoaded,
|
|
158
160
|
entries: t.entries,
|
|
159
161
|
nextMarker: t.next_marker,
|
|
@@ -161,66 +163,66 @@ function u(u, d, f, p, m) {
|
|
|
161
163
|
templates: n.entries,
|
|
162
164
|
templateNextMarker: n.next_marker
|
|
163
165
|
}
|
|
164
|
-
}),
|
|
166
|
+
}), v((e) => {
|
|
165
167
|
e.namespaces = [...e.namespaces, ...t.entries], e.namespaceNextMarker = t.next_marker, e.isNamespacesExhausted = r, r && (e.templates = n.entries, e.templateNextMarker = n.next_marker);
|
|
166
168
|
});
|
|
167
169
|
}, _);
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
170
172
|
if (g) {
|
|
171
|
-
let n =
|
|
172
|
-
await
|
|
173
|
-
|
|
173
|
+
let n = y();
|
|
174
|
+
await u(n, () => w(t, n, o), (t) => {
|
|
175
|
+
m({
|
|
174
176
|
type: e.LoadMoreTemplatesLoaded,
|
|
175
177
|
entries: t.entries,
|
|
176
178
|
nextMarker: t.next_marker
|
|
177
|
-
}),
|
|
179
|
+
}), v((e) => {
|
|
178
180
|
e.templates = [...e.templates, ...t.entries], e.templateNextMarker = t.next_marker;
|
|
179
181
|
});
|
|
180
182
|
}, _);
|
|
181
183
|
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
+
}, N = async (t) => {
|
|
185
|
+
p.current.selectedTemplateId !== t.id && (m({
|
|
184
186
|
type: e.TemplateSelect,
|
|
185
187
|
template: t
|
|
186
|
-
}), s(() =>
|
|
187
|
-
},
|
|
188
|
-
s(() =>
|
|
189
|
-
},
|
|
190
|
-
let { searchError: t, searchQuery: n, loadMoreError: r, initialLoadError: i, browseError: a, namespaceFQN: o } =
|
|
188
|
+
}), s(() => f.current.onTemplateSelect?.(t)));
|
|
189
|
+
}, P = (e) => {
|
|
190
|
+
s(() => f.current.onTemplateEdit?.(e));
|
|
191
|
+
}, F = async () => {
|
|
192
|
+
let { searchError: t, searchQuery: n, loadMoreError: r, initialLoadError: i, browseError: a, namespaceFQN: o } = p.current;
|
|
191
193
|
if (t) {
|
|
192
|
-
let t =
|
|
193
|
-
|
|
194
|
+
let t = x();
|
|
195
|
+
m({
|
|
194
196
|
type: e.SearchFetchStart,
|
|
195
197
|
query: n
|
|
196
|
-
}), s(() =>
|
|
198
|
+
}), s(() => f.current.onNewViewLoading?.(!0)), await u(t, () => T(n, t), (t) => m({
|
|
197
199
|
type: e.SearchLoaded,
|
|
198
200
|
results: t.entries,
|
|
199
201
|
nextMarker: t.next_marker
|
|
200
|
-
}), (t) =>
|
|
202
|
+
}), (t) => m({
|
|
201
203
|
type: e.SearchError,
|
|
202
|
-
error:
|
|
203
|
-
})), t.aborted || s(() =>
|
|
204
|
+
error: l(t)
|
|
205
|
+
})), t.aborted || s(() => f.current.onNewViewLoading?.(!1));
|
|
204
206
|
return;
|
|
205
207
|
}
|
|
206
208
|
if (r) {
|
|
207
|
-
await
|
|
209
|
+
await M();
|
|
208
210
|
return;
|
|
209
211
|
}
|
|
210
212
|
if (i || a) {
|
|
211
|
-
let t =
|
|
212
|
-
|
|
213
|
+
let t = y(), n = i ? e.InitialLoadError : e.BrowseError;
|
|
214
|
+
m({ type: e.BrowseFetchStart }), s(() => f.current.onNewViewLoading?.(!0)), await D(o, t, n), t.aborted || s(() => f.current.onNewViewLoading?.(!1));
|
|
213
215
|
}
|
|
214
216
|
};
|
|
215
217
|
return r(() => ({
|
|
216
|
-
initialLoad:
|
|
217
|
-
navigateTo:
|
|
218
|
-
navigateBack:
|
|
219
|
-
setSearchValue:
|
|
220
|
-
loadMore:
|
|
221
|
-
selectTemplate:
|
|
222
|
-
editTemplate:
|
|
223
|
-
retry:
|
|
218
|
+
initialLoad: O,
|
|
219
|
+
navigateTo: k,
|
|
220
|
+
navigateBack: A,
|
|
221
|
+
setSearchValue: j,
|
|
222
|
+
loadMore: M,
|
|
223
|
+
selectTemplate: N,
|
|
224
|
+
editTemplate: P,
|
|
225
|
+
retry: F
|
|
224
226
|
}), []);
|
|
225
227
|
}
|
|
226
|
-
export {
|
|
228
|
+
export { d as useTemplateBrowserActions };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-template-browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@box/blueprint-web": "^14.
|
|
7
|
-
"@box/blueprint-web-assets": "^4.
|
|
6
|
+
"@box/blueprint-web": "^14.16.0",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.115.0",
|
|
8
8
|
"lodash": "^4.17.15",
|
|
9
9
|
"react": "^18.0.0",
|
|
10
10
|
"react-aria-components": "1.16.0",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"react-intl": "^6.4.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@box/blueprint-web": "^14.
|
|
16
|
-
"@box/blueprint-web-assets": "^4.
|
|
15
|
+
"@box/blueprint-web": "^14.16.0",
|
|
16
|
+
"@box/blueprint-web-assets": "^4.115.0",
|
|
17
17
|
"@box/eslint-plugin-blueprint": "1.1.17",
|
|
18
|
-
"@box/storybook-utils": "0.
|
|
18
|
+
"@box/storybook-utils": "0.18.0",
|
|
19
19
|
"react-intl": "^6.4.2"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|