straplight 1.2.0 → 1.2.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.
- package/dist/_chunks/{Settings-BLDXIWWB.js → Settings-CTQDyLBP.js} +1 -1
- package/dist/_chunks/{Settings-CncfOILf.mjs → Settings-Chz6UwDr.mjs} +1 -1
- package/dist/_chunks/index-C5h4P4yg.mjs +569 -0
- package/dist/_chunks/index-Cii-JcUl.js +590 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/StraplightProvider.d.ts +1 -0
- package/package.json +1 -1
- package/dist/_chunks/StraplightOverlay-DLEpUqQM.mjs +0 -506
- package/dist/_chunks/StraplightOverlay-dGd1yRZj.js +0 -506
- package/dist/_chunks/index-B2B6CFFk.mjs +0 -82
- package/dist/_chunks/index-CuzgWWKQ.js +0 -103
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
const react = require("react");
|
|
25
|
+
const reactRouterDom = require("react-router-dom");
|
|
26
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
27
|
+
const designSystem = require("@strapi/design-system");
|
|
28
|
+
const admin = require("@strapi/strapi/admin");
|
|
29
|
+
const icons = require("@strapi/icons");
|
|
30
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
31
|
+
const v = glob[path];
|
|
32
|
+
if (v) {
|
|
33
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
34
|
+
}
|
|
35
|
+
return new Promise((_, reject) => {
|
|
36
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
37
|
+
reject.bind(
|
|
38
|
+
null,
|
|
39
|
+
new Error(
|
|
40
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const PLUGIN_ID = "straplight";
|
|
47
|
+
function NavigateCapture() {
|
|
48
|
+
const navigate = reactRouterDom.useNavigate();
|
|
49
|
+
react.useEffect(() => {
|
|
50
|
+
window.__straplight = window.__straplight || {};
|
|
51
|
+
window.__straplight.navigate = navigate;
|
|
52
|
+
}, [navigate]);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const DEFAULTS = {
|
|
56
|
+
debounceMs: 200,
|
|
57
|
+
minQueryLength: 1
|
|
58
|
+
};
|
|
59
|
+
function useStraplightSettings() {
|
|
60
|
+
const [settings, setSettings] = react.useState(DEFAULTS);
|
|
61
|
+
react.useEffect(() => {
|
|
62
|
+
const { get } = admin.getFetchClient();
|
|
63
|
+
get(`/${PLUGIN_ID}/settings`).then(({ data }) => {
|
|
64
|
+
setSettings({
|
|
65
|
+
debounceMs: data.settings?.debounceMs ?? DEFAULTS.debounceMs,
|
|
66
|
+
minQueryLength: data.settings?.minQueryLength ?? DEFAULTS.minQueryLength
|
|
67
|
+
});
|
|
68
|
+
}).catch(() => {
|
|
69
|
+
});
|
|
70
|
+
}, []);
|
|
71
|
+
return settings;
|
|
72
|
+
}
|
|
73
|
+
function useStraplight() {
|
|
74
|
+
const settings = useStraplightSettings();
|
|
75
|
+
const [isOpen, setIsOpen] = react.useState(false);
|
|
76
|
+
const [query, setQuery] = react.useState("");
|
|
77
|
+
const [results, setResults] = react.useState([]);
|
|
78
|
+
const [loading, setLoading] = react.useState(false);
|
|
79
|
+
const [selectedIndex, setSelectedIndex] = react.useState(0);
|
|
80
|
+
const debounceRef = react.useRef(null);
|
|
81
|
+
const requestIdRef = react.useRef(0);
|
|
82
|
+
react.useEffect(() => {
|
|
83
|
+
const handler = (e) => {
|
|
84
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
setIsOpen((prev) => !prev);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
document.addEventListener("keydown", handler);
|
|
90
|
+
return () => document.removeEventListener("keydown", handler);
|
|
91
|
+
}, []);
|
|
92
|
+
const close = react.useCallback(() => {
|
|
93
|
+
setIsOpen(false);
|
|
94
|
+
setQuery("");
|
|
95
|
+
setResults([]);
|
|
96
|
+
setSelectedIndex(0);
|
|
97
|
+
setLoading(false);
|
|
98
|
+
requestIdRef.current++;
|
|
99
|
+
}, []);
|
|
100
|
+
react.useEffect(() => {
|
|
101
|
+
if (!isOpen) return;
|
|
102
|
+
if (debounceRef.current) {
|
|
103
|
+
clearTimeout(debounceRef.current);
|
|
104
|
+
}
|
|
105
|
+
const trimmed = query.trim();
|
|
106
|
+
if (trimmed.length < settings.minQueryLength) {
|
|
107
|
+
setResults([]);
|
|
108
|
+
setSelectedIndex(0);
|
|
109
|
+
setLoading(false);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
debounceRef.current = setTimeout(async () => {
|
|
113
|
+
const id = ++requestIdRef.current;
|
|
114
|
+
setLoading(true);
|
|
115
|
+
try {
|
|
116
|
+
const { get } = admin.getFetchClient();
|
|
117
|
+
const { data } = await get(`/${PLUGIN_ID}/search`, {
|
|
118
|
+
params: { q: trimmed }
|
|
119
|
+
});
|
|
120
|
+
if (id !== requestIdRef.current) return;
|
|
121
|
+
setResults(data.results || []);
|
|
122
|
+
setSelectedIndex(0);
|
|
123
|
+
} catch {
|
|
124
|
+
if (id !== requestIdRef.current) return;
|
|
125
|
+
setResults([]);
|
|
126
|
+
} finally {
|
|
127
|
+
if (id === requestIdRef.current) {
|
|
128
|
+
setLoading(false);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, settings.debounceMs);
|
|
132
|
+
return () => {
|
|
133
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
134
|
+
};
|
|
135
|
+
}, [query, isOpen, settings.debounceMs, settings.minQueryLength]);
|
|
136
|
+
const navigateToResult = react.useCallback(
|
|
137
|
+
(result) => {
|
|
138
|
+
const path = `/content-manager/collection-types/${result.uid}/${result.documentId}`;
|
|
139
|
+
const nav = window.__straplight?.navigate;
|
|
140
|
+
if (nav) {
|
|
141
|
+
nav(path);
|
|
142
|
+
} else {
|
|
143
|
+
window.location.href = `/admin${path}`;
|
|
144
|
+
}
|
|
145
|
+
close();
|
|
146
|
+
},
|
|
147
|
+
[close]
|
|
148
|
+
);
|
|
149
|
+
const onKeyDown = react.useCallback(
|
|
150
|
+
(e) => {
|
|
151
|
+
if (e.key === "Escape") {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
close();
|
|
154
|
+
} else if (e.key === "ArrowDown") {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
setSelectedIndex((i) => i < results.length - 1 ? i + 1 : 0);
|
|
157
|
+
} else if (e.key === "ArrowUp") {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
setSelectedIndex((i) => i > 0 ? i - 1 : results.length - 1);
|
|
160
|
+
} else if (e.key === "Enter" && results.length > 0) {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
navigateToResult(results[selectedIndex]);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
[results, selectedIndex, navigateToResult, close]
|
|
166
|
+
);
|
|
167
|
+
return {
|
|
168
|
+
isOpen,
|
|
169
|
+
query,
|
|
170
|
+
setQuery,
|
|
171
|
+
results,
|
|
172
|
+
loading,
|
|
173
|
+
selectedIndex,
|
|
174
|
+
close,
|
|
175
|
+
onKeyDown,
|
|
176
|
+
navigateToResult
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const OVERLAY_STYLES = `
|
|
180
|
+
#straplight-portal input::placeholder {
|
|
181
|
+
color: inherit;
|
|
182
|
+
opacity: 0.6;
|
|
183
|
+
}
|
|
184
|
+
@keyframes straplight-fade-in {
|
|
185
|
+
from { opacity: 0; }
|
|
186
|
+
to { opacity: 1; }
|
|
187
|
+
}
|
|
188
|
+
@keyframes straplight-slide-in {
|
|
189
|
+
from { opacity: 0; transform: translateX(-50%) translateY(16px); }
|
|
190
|
+
to { opacity: 1; transform: translateX(-50%); }
|
|
191
|
+
}
|
|
192
|
+
@keyframes straplight-spin {
|
|
193
|
+
to { transform: rotate(360deg); }
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
196
|
+
function StraplightOverlay() {
|
|
197
|
+
const {
|
|
198
|
+
isOpen,
|
|
199
|
+
query,
|
|
200
|
+
setQuery,
|
|
201
|
+
results,
|
|
202
|
+
loading,
|
|
203
|
+
selectedIndex,
|
|
204
|
+
close,
|
|
205
|
+
onKeyDown,
|
|
206
|
+
navigateToResult
|
|
207
|
+
} = useStraplight();
|
|
208
|
+
const inputRef = react.useRef(null);
|
|
209
|
+
const listRef = react.useRef(null);
|
|
210
|
+
react.useEffect(() => {
|
|
211
|
+
if (isOpen && inputRef.current) {
|
|
212
|
+
inputRef.current.focus();
|
|
213
|
+
}
|
|
214
|
+
}, [isOpen]);
|
|
215
|
+
react.useEffect(() => {
|
|
216
|
+
if (!listRef.current) return;
|
|
217
|
+
const selected = listRef.current.children[selectedIndex];
|
|
218
|
+
if (selected) {
|
|
219
|
+
selected.scrollIntoView({ block: "nearest" });
|
|
220
|
+
}
|
|
221
|
+
}, [selectedIndex]);
|
|
222
|
+
if (!isOpen) return null;
|
|
223
|
+
const isMac = typeof navigator !== "undefined" && /mac/i.test(navigator.platform || navigator.userAgent);
|
|
224
|
+
const modKey = isMac ? "⌘" : "Ctrl";
|
|
225
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
226
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: OVERLAY_STYLES }),
|
|
227
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
228
|
+
designSystem.Box,
|
|
229
|
+
{
|
|
230
|
+
onClick: close,
|
|
231
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
232
|
+
position: "fixed",
|
|
233
|
+
zIndex: 99999,
|
|
234
|
+
animation: "straplight-fade-in 0.15s ease-out",
|
|
235
|
+
style: {
|
|
236
|
+
inset: 0,
|
|
237
|
+
backdropFilter: "blur(4px)"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
242
|
+
designSystem.Box,
|
|
243
|
+
{
|
|
244
|
+
onKeyDown,
|
|
245
|
+
background: "neutral0",
|
|
246
|
+
shadow: "filterShadow",
|
|
247
|
+
borderRadius: "12px",
|
|
248
|
+
maxHeight: "440px",
|
|
249
|
+
maxWidth: "calc(100vw - 32px)",
|
|
250
|
+
overflow: "hidden",
|
|
251
|
+
position: "fixed",
|
|
252
|
+
top: "calc(50% - 50px)",
|
|
253
|
+
left: "50%",
|
|
254
|
+
width: "580px",
|
|
255
|
+
zIndex: 1e5,
|
|
256
|
+
animation: "straplight-slide-in 0.2s ease-out 0.05s both",
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
259
|
+
designSystem.Box,
|
|
260
|
+
{
|
|
261
|
+
paddingLeft: 4,
|
|
262
|
+
paddingRight: 4,
|
|
263
|
+
paddingTop: 3,
|
|
264
|
+
paddingBottom: 3,
|
|
265
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
266
|
+
designSystem.Flex,
|
|
267
|
+
{
|
|
268
|
+
items: "center",
|
|
269
|
+
gap: "10px",
|
|
270
|
+
children: [
|
|
271
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
272
|
+
designSystem.Box,
|
|
273
|
+
{
|
|
274
|
+
display: "contents",
|
|
275
|
+
color: "neutral400",
|
|
276
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, { width: 20, height: 20 })
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
280
|
+
designSystem.Box,
|
|
281
|
+
{
|
|
282
|
+
color: "neutral700",
|
|
283
|
+
flex: "1",
|
|
284
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
285
|
+
"input",
|
|
286
|
+
{
|
|
287
|
+
ref: inputRef,
|
|
288
|
+
type: "text",
|
|
289
|
+
value: query,
|
|
290
|
+
onChange: (e) => setQuery(e.target.value),
|
|
291
|
+
placeholder: "Search content...",
|
|
292
|
+
style: {
|
|
293
|
+
border: "none",
|
|
294
|
+
outline: "none",
|
|
295
|
+
fontSize: "16px",
|
|
296
|
+
fontFamily: "inherit",
|
|
297
|
+
color: "inherit",
|
|
298
|
+
backgroundColor: "transparent"
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true })
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
)
|
|
308
|
+
}
|
|
309
|
+
),
|
|
310
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
|
|
311
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
312
|
+
designSystem.Box,
|
|
313
|
+
{
|
|
314
|
+
flex: "1",
|
|
315
|
+
overflow: "auto",
|
|
316
|
+
ref: listRef,
|
|
317
|
+
padding: results.length > 0 ? 2 : 0,
|
|
318
|
+
children: [
|
|
319
|
+
query.trim() && !loading && results.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
320
|
+
designSystem.Box,
|
|
321
|
+
{
|
|
322
|
+
color: "neutral600",
|
|
323
|
+
paddingLeft: 4,
|
|
324
|
+
paddingRight: 4,
|
|
325
|
+
paddingTop: 8,
|
|
326
|
+
paddingBottom: 8,
|
|
327
|
+
textAlign: "center",
|
|
328
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "No results found" })
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
results.map((result, index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
332
|
+
ResultItem,
|
|
333
|
+
{
|
|
334
|
+
result,
|
|
335
|
+
isSelected: index2 === selectedIndex,
|
|
336
|
+
onClick: () => navigateToResult(result)
|
|
337
|
+
},
|
|
338
|
+
`${result.uid}-${result.documentId}`
|
|
339
|
+
))
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
),
|
|
343
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
|
|
344
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
345
|
+
designSystem.Box,
|
|
346
|
+
{
|
|
347
|
+
paddingLeft: 4,
|
|
348
|
+
paddingRight: 4,
|
|
349
|
+
paddingTop: 3,
|
|
350
|
+
paddingBottom: 3,
|
|
351
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
352
|
+
designSystem.Flex,
|
|
353
|
+
{
|
|
354
|
+
color: "neutral600",
|
|
355
|
+
gap: "16px",
|
|
356
|
+
children: [
|
|
357
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontSize: "12px", children: [
|
|
358
|
+
/* @__PURE__ */ jsxRuntime.jsx(Kbd, { children: "↑↓" }),
|
|
359
|
+
" navigate"
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontSize: "12px", children: [
|
|
362
|
+
/* @__PURE__ */ jsxRuntime.jsx(Kbd, { children: "⏎" }),
|
|
363
|
+
" open"
|
|
364
|
+
] }),
|
|
365
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontSize: "12px", children: [
|
|
366
|
+
/* @__PURE__ */ jsxRuntime.jsx(Kbd, { children: "esc" }),
|
|
367
|
+
" close"
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontSize: "12px", style: { marginLeft: "auto" }, children: [
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Kbd, { children: [
|
|
371
|
+
modKey,
|
|
372
|
+
"+K"
|
|
373
|
+
] }),
|
|
374
|
+
" toggle"
|
|
375
|
+
] })
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
] });
|
|
385
|
+
}
|
|
386
|
+
function ResultItem({
|
|
387
|
+
result,
|
|
388
|
+
isSelected,
|
|
389
|
+
onClick
|
|
390
|
+
}) {
|
|
391
|
+
const [hovered, setHovered] = react.useState(false);
|
|
392
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
393
|
+
designSystem.Box,
|
|
394
|
+
{
|
|
395
|
+
paddingLeft: 3,
|
|
396
|
+
paddingRight: 3,
|
|
397
|
+
paddingTop: 2,
|
|
398
|
+
paddingBottom: 2,
|
|
399
|
+
borderRadius: "8px",
|
|
400
|
+
transition: "background-color 0.1s",
|
|
401
|
+
cursor: "pointer",
|
|
402
|
+
background: isSelected || hovered ? "neutral150" : "transparent",
|
|
403
|
+
onClick,
|
|
404
|
+
onMouseEnter: () => setHovered(true),
|
|
405
|
+
onMouseLeave: () => setHovered(false),
|
|
406
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
407
|
+
designSystem.Flex,
|
|
408
|
+
{
|
|
409
|
+
alignItems: "center",
|
|
410
|
+
justifyContent: "space-between",
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
413
|
+
designSystem.Box,
|
|
414
|
+
{
|
|
415
|
+
flex: "1",
|
|
416
|
+
overflow: "hidden",
|
|
417
|
+
marginRight: 3,
|
|
418
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
419
|
+
designSystem.Flex,
|
|
420
|
+
{
|
|
421
|
+
alignItems: "baseline",
|
|
422
|
+
gap: "8px",
|
|
423
|
+
children: [
|
|
424
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
425
|
+
designSystem.Box,
|
|
426
|
+
{
|
|
427
|
+
shrink: "0",
|
|
428
|
+
minWidth: 0,
|
|
429
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
430
|
+
designSystem.Typography,
|
|
431
|
+
{
|
|
432
|
+
fontWeight: isSelected ? 600 : 400,
|
|
433
|
+
style: {
|
|
434
|
+
overflow: "hidden",
|
|
435
|
+
textOverflow: "ellipsis",
|
|
436
|
+
whiteSpace: "nowrap"
|
|
437
|
+
},
|
|
438
|
+
children: result.label
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
}
|
|
442
|
+
),
|
|
443
|
+
result.fields && result.fields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
444
|
+
designSystem.Box,
|
|
445
|
+
{
|
|
446
|
+
shrink: "1",
|
|
447
|
+
minWidth: 0,
|
|
448
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
449
|
+
designSystem.Typography,
|
|
450
|
+
{
|
|
451
|
+
fontSize: "12px",
|
|
452
|
+
textColor: "neutral600",
|
|
453
|
+
style: {
|
|
454
|
+
overflow: "hidden",
|
|
455
|
+
textOverflow: "ellipsis",
|
|
456
|
+
whiteSpace: "nowrap"
|
|
457
|
+
},
|
|
458
|
+
children: result.fields.map((f) => f.value).join(" · ")
|
|
459
|
+
}
|
|
460
|
+
)
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
]
|
|
464
|
+
}
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
),
|
|
468
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
469
|
+
designSystem.Box,
|
|
470
|
+
{
|
|
471
|
+
color: "neutral600",
|
|
472
|
+
background: "neutral150",
|
|
473
|
+
paddingLeft: 2,
|
|
474
|
+
paddingRight: 2,
|
|
475
|
+
paddingTop: 1,
|
|
476
|
+
paddingBottom: 1,
|
|
477
|
+
borderRadius: "4px",
|
|
478
|
+
shrink: "0",
|
|
479
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontSize: "11px", children: result.contentType })
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
function Kbd({ children }) {
|
|
489
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
490
|
+
designSystem.Box,
|
|
491
|
+
{
|
|
492
|
+
display: "inline-block",
|
|
493
|
+
borderColor: "neutral200",
|
|
494
|
+
background: "neutral150",
|
|
495
|
+
borderRadius: "4px",
|
|
496
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
497
|
+
"kbd",
|
|
498
|
+
{
|
|
499
|
+
style: {
|
|
500
|
+
display: "inline-block",
|
|
501
|
+
padding: "1px 5px",
|
|
502
|
+
fontSize: "11px",
|
|
503
|
+
fontFamily: "inherit",
|
|
504
|
+
borderRadius: "4px"
|
|
505
|
+
},
|
|
506
|
+
children
|
|
507
|
+
}
|
|
508
|
+
)
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
function resolveIsDark() {
|
|
513
|
+
const stored = localStorage.getItem("STRAPI_THEME") || "system";
|
|
514
|
+
if (stored === "dark") return true;
|
|
515
|
+
if (stored === "light") return false;
|
|
516
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
517
|
+
}
|
|
518
|
+
function StraplightProvider() {
|
|
519
|
+
const [isDark, setIsDark] = react.useState(resolveIsDark);
|
|
520
|
+
react.useEffect(() => {
|
|
521
|
+
function update() {
|
|
522
|
+
setIsDark(resolveIsDark());
|
|
523
|
+
}
|
|
524
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
525
|
+
mq.addEventListener("change", update);
|
|
526
|
+
window.addEventListener("storage", update);
|
|
527
|
+
const originalSetItem = localStorage.setItem.bind(localStorage);
|
|
528
|
+
localStorage.setItem = function(key, value) {
|
|
529
|
+
originalSetItem(key, value);
|
|
530
|
+
if (key === "STRAPI_THEME") update();
|
|
531
|
+
};
|
|
532
|
+
return () => {
|
|
533
|
+
mq.removeEventListener("change", update);
|
|
534
|
+
window.removeEventListener("storage", update);
|
|
535
|
+
localStorage.setItem = originalSetItem;
|
|
536
|
+
};
|
|
537
|
+
}, []);
|
|
538
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.DesignSystemProvider, { theme: isDark ? designSystem.darkTheme : designSystem.lightTheme, children: /* @__PURE__ */ jsxRuntime.jsx(StraplightOverlay, {}) });
|
|
539
|
+
}
|
|
540
|
+
const index = {
|
|
541
|
+
register(app) {
|
|
542
|
+
app.registerPlugin({
|
|
543
|
+
id: PLUGIN_ID,
|
|
544
|
+
name: PLUGIN_ID
|
|
545
|
+
});
|
|
546
|
+
},
|
|
547
|
+
bootstrap(app) {
|
|
548
|
+
app.addSettingsLink("global", {
|
|
549
|
+
id: `${PLUGIN_ID}-settings`,
|
|
550
|
+
to: PLUGIN_ID,
|
|
551
|
+
intlLabel: {
|
|
552
|
+
id: `${PLUGIN_ID}.settings.link`,
|
|
553
|
+
defaultMessage: "Straplight"
|
|
554
|
+
},
|
|
555
|
+
permissions: [],
|
|
556
|
+
async Component() {
|
|
557
|
+
const { SettingsPage } = await Promise.resolve().then(() => require("./Settings-CTQDyLBP.js"));
|
|
558
|
+
return { default: SettingsPage };
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
const contentManager = app.getPlugin("content-manager");
|
|
562
|
+
contentManager.injectComponent("listView", "actions", {
|
|
563
|
+
name: "straplight-nav-capture",
|
|
564
|
+
Component: NavigateCapture
|
|
565
|
+
});
|
|
566
|
+
import("react-dom/client").then(({ createRoot }) => {
|
|
567
|
+
import("react/jsx-runtime").then(({ jsx }) => {
|
|
568
|
+
const el = document.createElement("div");
|
|
569
|
+
el.id = "straplight-portal";
|
|
570
|
+
document.body.appendChild(el);
|
|
571
|
+
const root = createRoot(el);
|
|
572
|
+
root.render(jsx(StraplightProvider, {}));
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
async registerTrads({ locales }) {
|
|
577
|
+
return Promise.all(
|
|
578
|
+
locales.map(async (locale) => {
|
|
579
|
+
try {
|
|
580
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-B4KWt_jN.js")) }), `./translations/${locale}.json`, 3);
|
|
581
|
+
return { data, locale };
|
|
582
|
+
} catch {
|
|
583
|
+
return { data: {}, locale };
|
|
584
|
+
}
|
|
585
|
+
})
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
exports.PLUGIN_ID = PLUGIN_ID;
|
|
590
|
+
exports.index = index;
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function StraplightProvider(): import("react/jsx-runtime").JSX.Element;
|