@nivaro/react 0.3.32 → 0.3.34
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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +89 -8
- package/dist/index.js +338 -328
- package/dist/shared/components/ForceReloadBanner.js +56 -46
- package/dist/shared/components/ItemEditForm.js +5637 -5442
- package/dist/shared/components/ProfileView.js +46 -44
- package/dist/shared/components/ReportView.js +208 -205
- package/dist/shared/components/SearchHighlight.js +30 -0
- package/dist/shared/components/TipLayer.js +39 -37
- package/dist/shared/components/item-edit/CatalogPickerField.js +1484 -1232
- package/dist/shared/components/item-edit/FieldAffordances.js +370 -203
- package/dist/shared/components/item-edit/FieldRow.js +396 -354
- package/dist/shared/components/item-edit/PersonalDefaultPill.js +50 -0
- package/dist/shared/components/item-edit/RelationCombobox.js +42 -41
- package/dist/shared/components/item-edit/catalog-search.js +34 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +34 -34
- package/dist/shared/components/item-edit/personal-default-checks.js +134 -0
- package/dist/shared/components/item-edit/usePersonalDefaults.js +358 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +130 -111
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +76 -75
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/profile/MyDefaultsCard.js +667 -0
- package/dist/shared/components/profile/PersonProfile.js +42 -40
- package/dist/shared/components/profile/my-defaults-labels.js +76 -0
- package/dist/shared/components/profile/primitives.js +72 -67
- package/dist/shared/lib/personal-defaults.js +76 -0
- package/dist/shared/lib/request-gate.js +78 -76
- package/dist/shared/lib/search-text.js +111 -0
- package/dist/shared/lib/unsaved-work.js +86 -38
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { noteOwnWriteFromCommand as
|
|
1
|
+
import { noteOwnWriteFromCommand as b } from "./own-writes.js";
|
|
2
2
|
import { noteCredentialChanged as z, isIdentityRead as M, claimIdentityCall as $, signedOutError as Z, noteSignedIn as H, isSignedOutError as U, noteUnauthorized as x } from "./signed-out.js";
|
|
3
|
-
function
|
|
3
|
+
function G(t) {
|
|
4
4
|
if (!t || typeof t != "object") return "";
|
|
5
|
-
const s = Object.entries(t).filter(([, o]) => o != null).map(([o,
|
|
5
|
+
const s = Object.entries(t).filter(([, o]) => o != null).map(([o, a]) => [o, String(a)]).sort(([o], [a]) => o < a ? -1 : o > a ? 1 : 0);
|
|
6
6
|
return s.length ? new URLSearchParams(s).toString() : "";
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function I(t) {
|
|
9
9
|
const s = (t._method ?? "GET").toUpperCase(), o = s === "GET" || t._body === void 0 ? "" : JSON.stringify(t._body);
|
|
10
|
-
return `${s} ${t._path ?? ""} ${
|
|
10
|
+
return `${s} ${t._path ?? ""} ${G(t._params)} ${o}`;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function S(t) {
|
|
13
13
|
return (t._method ?? "GET").toUpperCase() === "GET";
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const P = /^\/(widgets-internal\/[^/]+\/render|items\/[^/]+\/[^/]+\/child-summary|items\/[^/]+\/auto-id-preview|config-conformance\/record\/.+\/check|pipelines\/instance\/[^/]+\/owners\/batch|addendums\/summary|at-risk\/evaluate|record-views\/.+\/touch)$/;
|
|
16
16
|
function B(t) {
|
|
17
|
-
return
|
|
17
|
+
return S(t) ? !0 : (t._method ?? "GET").toUpperCase() !== "POST" ? !1 : P.test((t._path ?? "").split("?")[0]);
|
|
18
18
|
}
|
|
19
19
|
function T(t) {
|
|
20
20
|
if (t == null || typeof t != "object") return t;
|
|
@@ -28,7 +28,7 @@ const N = Symbol("nivaro.coalesced");
|
|
|
28
28
|
function F(t) {
|
|
29
29
|
return t[N] === !0;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const R = 20, W = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, K = /* @__PURE__ */ new Set(["aggregate", "export", "distinct", "resolve-paths", "batch-read"]), J = /* @__PURE__ */ new Set([
|
|
32
32
|
"fields",
|
|
33
33
|
"filter",
|
|
34
34
|
"sort",
|
|
@@ -46,7 +46,7 @@ function Y(t) {
|
|
|
46
46
|
if ((s._method ?? "GET").toUpperCase() !== "GET") return null;
|
|
47
47
|
const o = W.exec(s._path ?? "");
|
|
48
48
|
if (!o) return null;
|
|
49
|
-
const [,
|
|
49
|
+
const [, a, d] = o;
|
|
50
50
|
if (d !== void 0 && K.has(d)) return null;
|
|
51
51
|
const m = s._params ?? {}, c = {};
|
|
52
52
|
for (const [r, u] of Object.entries(m))
|
|
@@ -54,12 +54,12 @@ function Y(t) {
|
|
|
54
54
|
if (!J.has(r)) return null;
|
|
55
55
|
c[r] = u;
|
|
56
56
|
}
|
|
57
|
-
return d === void 0 ? { collection:
|
|
57
|
+
return d === void 0 ? { collection: a, query: c } : { collection: a, id: d, query: c };
|
|
58
58
|
}
|
|
59
59
|
function Q(t) {
|
|
60
60
|
let s = [], o;
|
|
61
|
-
const
|
|
62
|
-
if (c.length === 1) return
|
|
61
|
+
const a = (c) => t.request(c.command).then(c.resolve, c.reject), d = async (c) => {
|
|
62
|
+
if (c.length === 1) return a(c[0]);
|
|
63
63
|
let r;
|
|
64
64
|
try {
|
|
65
65
|
const u = await t.request({
|
|
@@ -81,7 +81,7 @@ function Q(t) {
|
|
|
81
81
|
c.forEach((u, n) => {
|
|
82
82
|
const e = r == null ? void 0 : r[n];
|
|
83
83
|
if ((e == null ? void 0 : e.status) !== 200 || e === void 0) {
|
|
84
|
-
|
|
84
|
+
a(u);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
u.resolve(u.read.id !== void 0 ? { data: e.data } : { data: e.data, ...e.meta ?? {} });
|
|
@@ -90,8 +90,8 @@ function Q(t) {
|
|
|
90
90
|
o = void 0;
|
|
91
91
|
const c = s;
|
|
92
92
|
s = [];
|
|
93
|
-
for (let r = 0; r < c.length; r +=
|
|
94
|
-
d(c.slice(r, r +
|
|
93
|
+
for (let r = 0; r < c.length; r += R)
|
|
94
|
+
d(c.slice(r, r + R));
|
|
95
95
|
};
|
|
96
96
|
return (c, r) => new Promise((u, n) => {
|
|
97
97
|
s.push({
|
|
@@ -102,10 +102,10 @@ function Q(t) {
|
|
|
102
102
|
}), o === void 0 && (o = setTimeout(m, 0));
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const k = 50, V = 10, X = /^\/collections\/([A-Za-z_][A-Za-z0-9_-]{0,127})$/;
|
|
106
106
|
function ee(t) {
|
|
107
107
|
const s = t;
|
|
108
|
-
if ((s._method ?? "GET").toUpperCase() !== "GET" ||
|
|
108
|
+
if ((s._method ?? "GET").toUpperCase() !== "GET" || G(s._params) !== "") return null;
|
|
109
109
|
const o = X.exec(s._path ?? "");
|
|
110
110
|
return o ? o[1] : null;
|
|
111
111
|
}
|
|
@@ -113,11 +113,11 @@ function te() {
|
|
|
113
113
|
return Object.assign(new Error("Not found"), { status: 404, response: { error: "Not found" } });
|
|
114
114
|
}
|
|
115
115
|
function ne(t) {
|
|
116
|
-
let s = !0, o = [],
|
|
116
|
+
let s = !0, o = [], a;
|
|
117
117
|
const d = (r) => t.request(r.command).then(r.resolve, r.reject), m = async (r) => {
|
|
118
|
-
const u = [...new Set(r.map((
|
|
118
|
+
const u = [...new Set(r.map((i) => i.name))];
|
|
119
119
|
if (u.length === 1 || !s) {
|
|
120
|
-
for (const
|
|
120
|
+
for (const i of r) d(i);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
let n;
|
|
@@ -127,11 +127,11 @@ function ne(t) {
|
|
|
127
127
|
_path: "/collections",
|
|
128
128
|
_params: { names: u.join(",") }
|
|
129
129
|
});
|
|
130
|
-
} catch (
|
|
131
|
-
const h =
|
|
130
|
+
} catch (i) {
|
|
131
|
+
const h = i == null ? void 0 : i.status;
|
|
132
132
|
if (h === 400 || h === 404 || h === 405) s = !1;
|
|
133
133
|
else if (h === 429 || h !== void 0 && h >= 500) {
|
|
134
|
-
for (const p of r) p.reject(
|
|
134
|
+
for (const p of r) p.reject(i);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
n = void 0;
|
|
@@ -139,22 +139,22 @@ function ne(t) {
|
|
|
139
139
|
const e = n == null ? void 0 : n.data;
|
|
140
140
|
if (!e || typeof e != "object" || Array.isArray(e)) {
|
|
141
141
|
Array.isArray(e) && (s = !1);
|
|
142
|
-
for (const
|
|
142
|
+
for (const i of r) d(i);
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
const l = e, f = new Set(Array.isArray(n == null ? void 0 : n.missing) ? n.missing : []);
|
|
146
|
-
for (const
|
|
147
|
-
Object.hasOwn(l,
|
|
146
|
+
for (const i of r)
|
|
147
|
+
Object.hasOwn(l, i.name) ? i.resolve({ data: T(l[i.name]) }) : f.has(i.name) ? i.reject(te()) : d(i);
|
|
148
148
|
}, c = () => {
|
|
149
|
-
|
|
149
|
+
a = void 0;
|
|
150
150
|
const r = o;
|
|
151
151
|
o = [];
|
|
152
152
|
const u = [], n = /* @__PURE__ */ new Map();
|
|
153
153
|
for (const e of r) {
|
|
154
154
|
let l = n.get(e.name);
|
|
155
155
|
if (!l) {
|
|
156
|
-
const f = u[u.length - 1],
|
|
157
|
-
l = f &&
|
|
156
|
+
const f = u[u.length - 1], i = f ? new Set(f.map((h) => h.name)).size : k;
|
|
157
|
+
l = f && i < k ? f : [], l !== f && u.push(l), n.set(e.name, l);
|
|
158
158
|
}
|
|
159
159
|
l.push(e);
|
|
160
160
|
}
|
|
@@ -166,17 +166,17 @@ function ne(t) {
|
|
|
166
166
|
command: r,
|
|
167
167
|
resolve: n,
|
|
168
168
|
reject: e
|
|
169
|
-
}),
|
|
169
|
+
}), a === void 0 && (a = setTimeout(c, V));
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const q = 3e3, se = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, oe = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade|project)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
|
|
173
173
|
function re(t) {
|
|
174
174
|
const s = (t._path ?? "").split("?")[0];
|
|
175
|
-
return (t._method ?? "GET").toUpperCase() === "POST" &&
|
|
175
|
+
return (t._method ?? "GET").toUpperCase() === "POST" && P.test(s) ? !0 : oe.test(s);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function ie(t) {
|
|
178
178
|
const s = t;
|
|
179
|
-
if (!
|
|
179
|
+
if (!S(s) || !se.test(s._path ?? "")) return !1;
|
|
180
180
|
const o = s._params;
|
|
181
181
|
return !(o && o.item != null && /^\/collection-layouts\/active$/.test(s._path ?? ""));
|
|
182
182
|
}
|
|
@@ -184,14 +184,14 @@ let y = 0;
|
|
|
184
184
|
function D() {
|
|
185
185
|
y++;
|
|
186
186
|
}
|
|
187
|
-
let
|
|
188
|
-
const
|
|
189
|
-
function ue(t, s, o,
|
|
190
|
-
if (s.epoch !==
|
|
187
|
+
let g = 0;
|
|
188
|
+
const ae = 50, ce = /^\/items\//;
|
|
189
|
+
function ue(t, s, o, a) {
|
|
190
|
+
if (s.epoch !== a) return !1;
|
|
191
191
|
const d = t._path ?? "";
|
|
192
|
-
return !ce.test(d) || o - s.at <
|
|
192
|
+
return !ce.test(d) || o - s.at < ae;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function w(t, s) {
|
|
195
195
|
return t.then(
|
|
196
196
|
(o) => (s && H(), o),
|
|
197
197
|
(o) => {
|
|
@@ -201,52 +201,54 @@ function G(t, s) {
|
|
|
201
201
|
}
|
|
202
202
|
function me(t, s = {}) {
|
|
203
203
|
if (F(t)) return t;
|
|
204
|
-
const o = /* @__PURE__ */ new Map(),
|
|
204
|
+
const o = /* @__PURE__ */ new Map(), a = s.batchReads ? Q(t) : null, d = s.batchCollections === !1 ? null : ne(t), m = /* @__PURE__ */ new Map();
|
|
205
205
|
let c = y;
|
|
206
206
|
const r = (n, e, l) => {
|
|
207
207
|
if (e !== y) return;
|
|
208
208
|
c !== y && (m.clear(), c = y);
|
|
209
209
|
const f = Date.now();
|
|
210
|
-
for (const [
|
|
210
|
+
for (const [i, h] of m) f - h.at >= q && m.delete(i);
|
|
211
211
|
m.set(n, { at: f, epoch: e, value: l });
|
|
212
212
|
}, u = (n) => {
|
|
213
213
|
const e = n;
|
|
214
|
-
if (!
|
|
215
|
-
|
|
214
|
+
if (!S(e)) {
|
|
215
|
+
b(e._method, e._path, e._body);
|
|
216
216
|
const _ = !re(e);
|
|
217
|
-
_ && D(),
|
|
218
|
-
const
|
|
219
|
-
|
|
217
|
+
_ && D(), g++;
|
|
218
|
+
const C = w(t.request(n), !1).finally(() => {
|
|
219
|
+
g++;
|
|
220
220
|
});
|
|
221
|
-
return (_ ?
|
|
221
|
+
return (_ ? C.finally(D) : C).then((O) => (b(e._method, e._path, e._body, O), O));
|
|
222
222
|
}
|
|
223
|
-
|
|
223
|
+
if (n._signal)
|
|
224
|
+
return w(t.request(n), !1);
|
|
225
|
+
const l = I(e), f = ie(e);
|
|
224
226
|
if (f) {
|
|
225
227
|
const _ = m.get(l);
|
|
226
|
-
if (_ && _.epoch === y && Date.now() - _.at <
|
|
228
|
+
if (_ && _.epoch === y && Date.now() - _.at < q)
|
|
227
229
|
return Promise.resolve(T(_.value));
|
|
228
230
|
}
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
231
|
-
return
|
|
231
|
+
const i = o.get(l);
|
|
232
|
+
if (i && ue(e, i, Date.now(), g))
|
|
233
|
+
return i.p.then(T);
|
|
232
234
|
const h = M(e._method, e._path, e._params);
|
|
233
235
|
if (h && !$()) return Promise.reject(Z());
|
|
234
|
-
const p =
|
|
235
|
-
p &&
|
|
236
|
+
const p = a ? Y(e) : null, E = !p && d ? ee(e) : null, j = w(
|
|
237
|
+
p && a ? a(n, p) : E && d ? d(n, E) : t.request(n),
|
|
236
238
|
h
|
|
237
|
-
), L = y,
|
|
239
|
+
), L = y, A = j.then((_) => (f && r(l, L, T(_)), _)).finally(() => {
|
|
238
240
|
var _;
|
|
239
|
-
((_ = o.get(l)) == null ? void 0 : _.p) ===
|
|
241
|
+
((_ = o.get(l)) == null ? void 0 : _.p) === A && o.delete(l);
|
|
240
242
|
});
|
|
241
|
-
return o.set(l, { p:
|
|
243
|
+
return o.set(l, { p: A, at: Date.now(), epoch: g }), A;
|
|
242
244
|
};
|
|
243
245
|
return new Proxy(t, {
|
|
244
246
|
get(n, e, l) {
|
|
245
247
|
if (e === "request") return u;
|
|
246
248
|
if (e === N) return !0;
|
|
247
249
|
if (e === "setToken" && typeof n.setToken == "function")
|
|
248
|
-
return (
|
|
249
|
-
n.setToken(
|
|
250
|
+
return (i) => {
|
|
251
|
+
n.setToken(i), z();
|
|
250
252
|
};
|
|
251
253
|
const f = Reflect.get(n, e, l);
|
|
252
254
|
return typeof f == "function" ? f.bind(n) : f;
|
|
@@ -263,7 +265,7 @@ function _e(t) {
|
|
|
263
265
|
});
|
|
264
266
|
}
|
|
265
267
|
function pe(t, s = {}) {
|
|
266
|
-
let o = s.open ?? !0,
|
|
268
|
+
let o = s.open ?? !0, a;
|
|
267
269
|
const d = /* @__PURE__ */ new Map(), m = () => {
|
|
268
270
|
const n = [...d.values()];
|
|
269
271
|
d.clear();
|
|
@@ -273,29 +275,29 @@ function pe(t, s = {}) {
|
|
|
273
275
|
}, r = (n) => {
|
|
274
276
|
const e = n;
|
|
275
277
|
if (o || !B(e) || le.test(e._path ?? "")) return t.request(n);
|
|
276
|
-
const l =
|
|
278
|
+
const l = I(e), f = d.get(l);
|
|
277
279
|
if (f) return f.promise.then(T);
|
|
278
|
-
let
|
|
280
|
+
let i = () => {
|
|
279
281
|
};
|
|
280
282
|
const p = new Promise((E) => {
|
|
281
|
-
|
|
283
|
+
i = E;
|
|
282
284
|
}).then(() => t.request(n));
|
|
283
|
-
return d.set(l, { promise: p, release:
|
|
285
|
+
return d.set(l, { promise: p, release: i }), v.add(c), p;
|
|
284
286
|
};
|
|
285
287
|
return new Proxy(t, {
|
|
286
288
|
get(n, e, l) {
|
|
287
289
|
if (e === "request") return r;
|
|
288
290
|
if (e === "open") return o;
|
|
289
291
|
if (e === "setOpen")
|
|
290
|
-
return (
|
|
291
|
-
|
|
292
|
+
return (i) => {
|
|
293
|
+
a !== void 0 && (clearTimeout(a), a = void 0);
|
|
292
294
|
const h = o;
|
|
293
|
-
o =
|
|
295
|
+
o = i, i && !h && (v.delete(c), m());
|
|
294
296
|
};
|
|
295
297
|
if (e === "dispose")
|
|
296
298
|
return () => {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
+
a === void 0 && (a = setTimeout(() => {
|
|
300
|
+
a = void 0, o = !0, v.delete(c), m();
|
|
299
301
|
}, 0));
|
|
300
302
|
};
|
|
301
303
|
const f = Reflect.get(n, e, l);
|
|
@@ -304,17 +306,17 @@ function pe(t, s = {}) {
|
|
|
304
306
|
});
|
|
305
307
|
}
|
|
306
308
|
export {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
+
R as BATCH_READ_LIMIT,
|
|
310
|
+
k as COLLECTION_BATCH_LIMIT,
|
|
309
311
|
V as COLLECTION_BATCH_WINDOW_MS,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
+
ae as RECORD_JOIN_MS,
|
|
313
|
+
q as SETTLED_READ_MS,
|
|
312
314
|
ee as batchableCollectionMeta,
|
|
313
315
|
Y as batchableRead,
|
|
314
316
|
pe as createGatedClient,
|
|
315
317
|
D as forgetSettledReads,
|
|
316
318
|
F as isCoalesced,
|
|
317
|
-
|
|
319
|
+
ie as isSettledRead,
|
|
318
320
|
ue as mayJoinInflight,
|
|
319
321
|
fe as releaseGatedReads,
|
|
320
322
|
_e as releaseGatedReadsOnSharedFetch,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function d(o) {
|
|
2
|
+
return o.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
3
|
+
}
|
|
4
|
+
function g(o) {
|
|
5
|
+
let n = "";
|
|
6
|
+
for (const e of o) n += d(e);
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
function k(o) {
|
|
10
|
+
let n = "";
|
|
11
|
+
const e = [];
|
|
12
|
+
let t = 0;
|
|
13
|
+
for (const s of o) {
|
|
14
|
+
const i = d(s);
|
|
15
|
+
for (let r = 0; r < i.length; r++) e.push(t);
|
|
16
|
+
n += i, t += s.length;
|
|
17
|
+
}
|
|
18
|
+
return e.push(t), { folded: n, map: e };
|
|
19
|
+
}
|
|
20
|
+
function S(o) {
|
|
21
|
+
const n = String(o ?? ""), e = [], t = /"([^"]*)"|(\S+)/g;
|
|
22
|
+
let s;
|
|
23
|
+
for (; s = t.exec(n); ) {
|
|
24
|
+
const i = s[1] !== void 0 ? s[1] : s[2], r = g(i).replace(/\s+/g, " ").trim().replace(/^"+|"+$/g, "");
|
|
25
|
+
r && !e.includes(r) && e.push(r);
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
28
|
+
}
|
|
29
|
+
function x(o, n) {
|
|
30
|
+
if (!(n != null && n.length)) return o.map((t) => [t]);
|
|
31
|
+
const e = n.map((t) => t.map((s) => g(String(s)).trim()).filter(Boolean));
|
|
32
|
+
return o.map((t) => {
|
|
33
|
+
const s = [t];
|
|
34
|
+
for (const i of e)
|
|
35
|
+
if (i.includes(t))
|
|
36
|
+
for (const r of i) s.includes(r) || s.push(r);
|
|
37
|
+
return s;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function L(o, n, e = {}) {
|
|
41
|
+
const t = S(n);
|
|
42
|
+
if (t.length === 0) return !0;
|
|
43
|
+
const s = g(String(o ?? ""));
|
|
44
|
+
return x(t, e.synonyms).every((i) => i.some((r) => s.includes(r)));
|
|
45
|
+
}
|
|
46
|
+
function $(o, n, e = {}) {
|
|
47
|
+
const t = String(o ?? ""), s = S(n);
|
|
48
|
+
if (!t || s.length === 0) return t ? [{ text: t, match: !1 }] : [];
|
|
49
|
+
const { folded: i, map: r } = k(t), a = [];
|
|
50
|
+
for (const f of x(s, e.synonyms))
|
|
51
|
+
for (const c of f) {
|
|
52
|
+
if (!c) continue;
|
|
53
|
+
let m = 0;
|
|
54
|
+
for (; ; ) {
|
|
55
|
+
const p = i.indexOf(c, m);
|
|
56
|
+
if (p === -1) break;
|
|
57
|
+
a.push([r[p], r[p + c.length]]), m = p + c.length;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (a.length === 0) return [{ text: t, match: !1 }];
|
|
61
|
+
a.sort((f, c) => f[0] - c[0] || c[1] - f[1]);
|
|
62
|
+
const l = [];
|
|
63
|
+
for (const f of a) {
|
|
64
|
+
const c = l[l.length - 1];
|
|
65
|
+
c && f[0] <= c[1] ? c[1] = Math.max(c[1], f[1]) : l.push([f[0], f[1]]);
|
|
66
|
+
}
|
|
67
|
+
const h = [];
|
|
68
|
+
let u = 0;
|
|
69
|
+
for (const [f, c] of l)
|
|
70
|
+
f > u && h.push({ text: t.slice(u, f), match: !1 }), c > f && h.push({ text: t.slice(f, c), match: !0 }), u = c;
|
|
71
|
+
return u < t.length && h.push({ text: t.slice(u), match: !1 }), h;
|
|
72
|
+
}
|
|
73
|
+
const w = 5;
|
|
74
|
+
function R(o) {
|
|
75
|
+
const n = [];
|
|
76
|
+
for (const e of String(o ?? "").toLowerCase().split(/\s+/))
|
|
77
|
+
if (e && !n.includes(e) && n.push(e), n.length === w) break;
|
|
78
|
+
return n;
|
|
79
|
+
}
|
|
80
|
+
function C(o) {
|
|
81
|
+
return String(o ?? "").replace(/\s+/g, " ").trim();
|
|
82
|
+
}
|
|
83
|
+
const W = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
84
|
+
function b(o, n) {
|
|
85
|
+
var i;
|
|
86
|
+
const e = C(n).toLowerCase();
|
|
87
|
+
if (!e) return 5;
|
|
88
|
+
const t = o.map(
|
|
89
|
+
(r) => r == null || typeof r == "object" ? "" : String(r).toLowerCase().trimEnd()
|
|
90
|
+
);
|
|
91
|
+
if (t[0] === e) return 0;
|
|
92
|
+
if (t.slice(1).some((r) => r === e)) return 1;
|
|
93
|
+
if ((i = t[0]) != null && i.startsWith(e)) return 2;
|
|
94
|
+
if (t.slice(1).some((r) => r.startsWith(e))) return 3;
|
|
95
|
+
const s = R(n);
|
|
96
|
+
return s.length > 0 && s.every((r) => {
|
|
97
|
+
const a = new RegExp(`(^|[^a-z0-9])${W(r)}`);
|
|
98
|
+
return t.some((l) => a.test(l));
|
|
99
|
+
}) ? 4 : 5;
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
w as SEARCH_RANK_MAX_WORDS,
|
|
103
|
+
x as expandTokens,
|
|
104
|
+
g as foldSearchText,
|
|
105
|
+
$ as highlightParts,
|
|
106
|
+
L as matchesSearch,
|
|
107
|
+
C as searchRankPhrase,
|
|
108
|
+
b as searchRankTier,
|
|
109
|
+
R as searchRankWords,
|
|
110
|
+
S as tokenize
|
|
111
|
+
};
|
|
@@ -1,62 +1,110 @@
|
|
|
1
|
-
import { useEffect as
|
|
2
|
-
import { subscribeRecordOutbox as
|
|
3
|
-
const
|
|
4
|
-
let
|
|
5
|
-
function
|
|
6
|
-
for (const
|
|
1
|
+
import { useRef as d, useEffect as v } from "react";
|
|
2
|
+
import { subscribeRecordOutbox as h, getRecordOutbox as p } from "./record-outbox.js";
|
|
3
|
+
const a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set();
|
|
4
|
+
let b = 0;
|
|
5
|
+
function c() {
|
|
6
|
+
for (const t of [...u])
|
|
7
7
|
try {
|
|
8
|
-
|
|
8
|
+
t();
|
|
9
9
|
} catch {
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
-
|
|
12
|
+
function g(t, n, r = {}) {
|
|
13
|
+
const e = ++b;
|
|
14
|
+
return a.set(e, { label: t, dirty: n, saveForReload: r.saveForReload }), c(), () => {
|
|
15
|
+
a.delete(e) && c();
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function l() {
|
|
19
19
|
try {
|
|
20
|
-
return
|
|
20
|
+
return p().length;
|
|
21
21
|
} catch {
|
|
22
22
|
return 0;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
let
|
|
25
|
+
function m() {
|
|
26
|
+
const t = [];
|
|
27
|
+
for (const r of a.values()) {
|
|
28
|
+
let e = !1;
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
e = r.dirty();
|
|
31
31
|
} catch {
|
|
32
|
-
|
|
32
|
+
e = !1;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
e && !t.includes(r.label) && t.push(r.label);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
return
|
|
36
|
+
const n = l();
|
|
37
|
+
return n && t.push(`${n} save${n === 1 ? "" : "s"} waiting to be sent`), t;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function w() {
|
|
40
|
+
return m().length > 0;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const t =
|
|
42
|
+
const y = 3e3;
|
|
43
|
+
async function F() {
|
|
44
|
+
const t = await Promise.all(
|
|
45
|
+
[...a.values()].map(async (e) => {
|
|
46
|
+
let o = !1;
|
|
47
|
+
try {
|
|
48
|
+
o = e.dirty();
|
|
49
|
+
} catch {
|
|
50
|
+
o = !1;
|
|
51
|
+
}
|
|
52
|
+
if (!o) return null;
|
|
53
|
+
let s = !1;
|
|
54
|
+
if (e.saveForReload)
|
|
55
|
+
try {
|
|
56
|
+
s = await Promise.race([
|
|
57
|
+
Promise.resolve(e.saveForReload()),
|
|
58
|
+
new Promise((f) => setTimeout(() => f(!1), y))
|
|
59
|
+
]);
|
|
60
|
+
} catch {
|
|
61
|
+
s = !1;
|
|
62
|
+
}
|
|
63
|
+
return s ? null : e.label;
|
|
64
|
+
})
|
|
65
|
+
), n = [...new Set(t.filter((e) => e != null))], r = l();
|
|
66
|
+
return r && n.push(`${r} save${r === 1 ? "" : "s"} waiting to be sent`), n;
|
|
67
|
+
}
|
|
68
|
+
let i = !1;
|
|
69
|
+
function k() {
|
|
70
|
+
i = !0, setTimeout(() => {
|
|
71
|
+
i = !1;
|
|
72
|
+
}, 5e3);
|
|
73
|
+
}
|
|
74
|
+
function O() {
|
|
75
|
+
return i;
|
|
76
|
+
}
|
|
77
|
+
function W(t) {
|
|
78
|
+
u.add(t);
|
|
79
|
+
const n = h(t);
|
|
45
80
|
return () => {
|
|
46
|
-
|
|
81
|
+
u.delete(t), n();
|
|
47
82
|
};
|
|
48
83
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
function x(t, n = "Unsaved changes", r) {
|
|
85
|
+
const e = d(r);
|
|
86
|
+
e.current = r;
|
|
87
|
+
const o = !!r;
|
|
88
|
+
v(() => {
|
|
89
|
+
if (t)
|
|
90
|
+
return g(
|
|
91
|
+
n,
|
|
92
|
+
() => !0,
|
|
93
|
+
o ? { saveForReload: () => {
|
|
94
|
+
var s;
|
|
95
|
+
return ((s = e.current) == null ? void 0 : s.call(e)) ?? !1;
|
|
96
|
+
} } : {}
|
|
97
|
+
);
|
|
98
|
+
}, [t, n, o]);
|
|
54
99
|
}
|
|
55
100
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
101
|
+
k as beginReloadForUpdate,
|
|
102
|
+
w as hasUnsavedWork,
|
|
103
|
+
O as isReloadingForUpdate,
|
|
104
|
+
c as notifyUnsavedWorkChanged,
|
|
105
|
+
F as prepareForReload,
|
|
106
|
+
g as registerUnsavedWork,
|
|
107
|
+
W as subscribeUnsavedWork,
|
|
108
|
+
m as unsavedWorkLabels,
|
|
109
|
+
x as useUnsavedWork
|
|
62
110
|
};
|