@mantine-vue/spotlight 3.0.0 → 3.2.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.
- package/cjs/index.cjs +570 -624
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +571 -625
- package/esm/index.mjs.map +1 -1
- package/lib/components/Spotlight/Spotlight.types.d.ts +34 -0
- package/lib/components/Spotlight/Spotlight.vue.d.ts +15 -0
- package/lib/components/Spotlight/index.d.ts +224 -0
- package/lib/components/SpotlightAction/SpotlightAction.types.d.ts +34 -0
- package/lib/components/SpotlightAction/SpotlightAction.vue.d.ts +11 -0
- package/lib/components/SpotlightAction/index.d.ts +18 -0
- package/lib/components/SpotlightActionsGroup/SpotlightActionsGroup.types.d.ts +13 -0
- package/lib/components/SpotlightActionsGroup/SpotlightActionsGroup.vue.d.ts +13 -0
- package/lib/components/SpotlightActionsGroup/index.d.ts +20 -0
- package/lib/components/SpotlightActionsList/SpotlightActionsList.types.d.ts +13 -0
- package/lib/components/SpotlightActionsList/SpotlightActionsList.vue.d.ts +13 -0
- package/lib/components/SpotlightActionsList/index.d.ts +20 -0
- package/lib/components/SpotlightEmpty/SpotlightEmpty.types.d.ts +11 -0
- package/lib/components/SpotlightEmpty/SpotlightEmpty.vue.d.ts +13 -0
- package/lib/components/SpotlightEmpty/index.d.ts +20 -0
- package/lib/components/SpotlightFooter/SpotlightFooter.types.d.ts +11 -0
- package/lib/components/SpotlightFooter/SpotlightFooter.vue.d.ts +13 -0
- package/lib/components/SpotlightFooter/index.d.ts +20 -0
- package/lib/components/SpotlightRoot/SpotlightRoot.types.d.ts +53 -0
- package/lib/components/SpotlightRoot/SpotlightRoot.vue.d.ts +23 -0
- package/lib/components/SpotlightRoot/index.d.ts +48 -0
- package/lib/components/SpotlightSearch/SpotlightSearch.types.d.ts +25 -0
- package/lib/components/SpotlightSearch/SpotlightSearch.vue.d.ts +11 -0
- package/lib/components/SpotlightSearch/index.d.ts +36 -0
- package/lib/default-spotlight-filter.d.ts +1 -1
- package/lib/index.d.mts +16 -9
- package/lib/index.d.ts +16 -9
- package/lib/is-actions-group.d.ts +1 -1
- package/lib/limit-actions.d.ts +1 -1
- package/package.json +4 -4
- package/lib/Spotlight.d.ts +0 -934
- package/lib/SpotlightAction.d.ts +0 -134
- package/lib/SpotlightActionsGroup.d.ts +0 -50
- package/lib/SpotlightActionsList.d.ts +0 -50
- package/lib/SpotlightEmpty.d.ts +0 -40
- package/lib/SpotlightFooter.d.ts +0 -40
- package/lib/SpotlightRoot.d.ts +0 -192
- package/lib/SpotlightSearch.d.ts +0 -81
package/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createStore } from "@mantine-vue/store";
|
|
2
|
-
import { computed, defineComponent,
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useAttrs, useSlots, watch, withCtx } from "vue";
|
|
3
3
|
import { Box, Highlight, Input, Modal, ScrollAreaAutosize, UnstyledButton, getDefaultZIndex, hasNode, rem, resolveNode, useProps, useStyles } from "@mantine-vue/core";
|
|
4
4
|
import { useHotkeys, useId } from "@mantine-vue/hooks";
|
|
5
5
|
//#region src/spotlight.store.ts
|
|
@@ -140,73 +140,6 @@ function isActionsGroup(item) {
|
|
|
140
140
|
return group.group !== void 0 && Array.isArray(group.actions);
|
|
141
141
|
}
|
|
142
142
|
//#endregion
|
|
143
|
-
//#region src/default-spotlight-filter.ts
|
|
144
|
-
function getKeywords(keywords) {
|
|
145
|
-
if (Array.isArray(keywords)) return keywords.map((keyword) => keyword.trim()).join(",").toLowerCase().trim();
|
|
146
|
-
if (typeof keywords === "string") return keywords.toLowerCase().trim();
|
|
147
|
-
return "";
|
|
148
|
-
}
|
|
149
|
-
function getFlatActions(data) {
|
|
150
|
-
return data.reduce((acc, item) => {
|
|
151
|
-
if ("actions" in item) return [...acc, ...item.actions.map((action) => ({
|
|
152
|
-
...action,
|
|
153
|
-
group: item.group
|
|
154
|
-
}))];
|
|
155
|
-
return [...acc, item];
|
|
156
|
-
}, []);
|
|
157
|
-
}
|
|
158
|
-
function flatActionsToGroups(data) {
|
|
159
|
-
const groups = {};
|
|
160
|
-
const result = [];
|
|
161
|
-
data.forEach((action) => {
|
|
162
|
-
if (action.group) {
|
|
163
|
-
if (!groups[action.group]) groups[action.group] = {
|
|
164
|
-
pushed: false,
|
|
165
|
-
data: {
|
|
166
|
-
group: action.group,
|
|
167
|
-
actions: []
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
groups[action.group].data.actions.push(action);
|
|
171
|
-
if (!groups[action.group].pushed) {
|
|
172
|
-
groups[action.group].pushed = true;
|
|
173
|
-
result.push(groups[action.group].data);
|
|
174
|
-
}
|
|
175
|
-
} else result.push(action);
|
|
176
|
-
});
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
var defaultSpotlightFilter = (_query, data) => {
|
|
180
|
-
const query = _query.trim().toLowerCase();
|
|
181
|
-
const priorityMatrix = [[], []];
|
|
182
|
-
getFlatActions(data).forEach((item) => {
|
|
183
|
-
if (item.label?.toLowerCase().includes(query)) priorityMatrix[0].push(item);
|
|
184
|
-
else if (item.description?.toLowerCase().includes(query) || getKeywords(item.keywords).includes(query)) priorityMatrix[1].push(item);
|
|
185
|
-
});
|
|
186
|
-
return flatActionsToGroups(priorityMatrix.flat());
|
|
187
|
-
};
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region src/limit-actions.ts
|
|
190
|
-
function limitActions(actions, limit) {
|
|
191
|
-
if (!Array.isArray(actions)) return [];
|
|
192
|
-
let count = 0;
|
|
193
|
-
return actions.reduce((acc, item) => {
|
|
194
|
-
if (count >= limit) return acc;
|
|
195
|
-
if (isActionsGroup(item)) {
|
|
196
|
-
const groupActions = limitActions(item.actions, limit - count);
|
|
197
|
-
acc.push({
|
|
198
|
-
group: item.group,
|
|
199
|
-
actions: groupActions
|
|
200
|
-
});
|
|
201
|
-
count += groupActions.length;
|
|
202
|
-
} else {
|
|
203
|
-
acc.push(item);
|
|
204
|
-
count += 1;
|
|
205
|
-
}
|
|
206
|
-
return acc;
|
|
207
|
-
}, []);
|
|
208
|
-
}
|
|
209
|
-
//#endregion
|
|
210
143
|
//#region src/Spotlight.context.ts
|
|
211
144
|
var SpotlightContextKey = Symbol("SpotlightContext");
|
|
212
145
|
function provideSpotlightContext(value) {
|
|
@@ -217,294 +150,228 @@ function useSpotlightContext() {
|
|
|
217
150
|
if (ctx === null) throw new Error("Spotlight component was not found in tree");
|
|
218
151
|
return ctx;
|
|
219
152
|
}
|
|
220
|
-
var Spotlight_module_default = {
|
|
221
|
-
root: "_root_87n7g_1",
|
|
222
|
-
content: "_content_87n7g_7",
|
|
223
|
-
body: "_body_87n7g_13",
|
|
224
|
-
search: "_search_87n7g_19",
|
|
225
|
-
actionsList: "_actionsList_87n7g_24",
|
|
226
|
-
action: "_action_87n7g_24",
|
|
227
|
-
actionBody: "_actionBody_87n7g_73",
|
|
228
|
-
actionSection: "_actionSection_87n7g_77",
|
|
229
|
-
actionLabel: "_actionLabel_87n7g_99",
|
|
230
|
-
actionDescription: "_actionDescription_87n7g_103",
|
|
231
|
-
empty: "_empty_87n7g_110",
|
|
232
|
-
footer: "_footer_87n7g_116",
|
|
233
|
-
actionsGroup: "_actionsGroup_87n7g_129"
|
|
234
|
-
};
|
|
235
153
|
//#endregion
|
|
236
|
-
//#region src/SpotlightAction.
|
|
237
|
-
var
|
|
238
|
-
dimmedSections: true,
|
|
239
|
-
highlightQuery: false
|
|
240
|
-
};
|
|
241
|
-
var SpotlightAction = defineComponent({
|
|
154
|
+
//#region src/components/SpotlightAction/SpotlightAction.vue
|
|
155
|
+
var SpotlightAction_default = /* @__PURE__ */ defineComponent({
|
|
242
156
|
name: "SpotlightAction",
|
|
243
157
|
inheritAttrs: false,
|
|
244
|
-
|
|
158
|
+
__name: "SpotlightAction",
|
|
245
159
|
props: {
|
|
246
|
-
label: {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
description: {
|
|
251
|
-
type: String,
|
|
252
|
-
default: void 0
|
|
253
|
-
},
|
|
254
|
-
leftSection: {
|
|
255
|
-
type: null,
|
|
256
|
-
default: void 0
|
|
257
|
-
},
|
|
258
|
-
rightSection: {
|
|
259
|
-
type: null,
|
|
260
|
-
default: void 0
|
|
261
|
-
},
|
|
160
|
+
label: {},
|
|
161
|
+
description: {},
|
|
162
|
+
leftSection: {},
|
|
163
|
+
rightSection: {},
|
|
262
164
|
dimmedSections: {
|
|
263
165
|
type: Boolean,
|
|
264
|
-
default:
|
|
166
|
+
default: true
|
|
265
167
|
},
|
|
266
168
|
highlightQuery: {
|
|
267
169
|
type: Boolean,
|
|
268
|
-
default:
|
|
269
|
-
},
|
|
270
|
-
highlightColor: {
|
|
271
|
-
type: String,
|
|
272
|
-
default: void 0
|
|
170
|
+
default: false
|
|
273
171
|
},
|
|
172
|
+
highlightColor: {},
|
|
274
173
|
closeSpotlightOnTrigger: {
|
|
275
174
|
type: Boolean,
|
|
276
175
|
default: void 0
|
|
277
176
|
},
|
|
278
|
-
keywords: {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
classNames: {
|
|
283
|
-
type: [Object, Function],
|
|
284
|
-
default: void 0
|
|
285
|
-
},
|
|
286
|
-
styles: {
|
|
287
|
-
type: [Object, Function],
|
|
288
|
-
default: void 0
|
|
289
|
-
},
|
|
290
|
-
vars: {
|
|
291
|
-
type: [Object, Function],
|
|
292
|
-
default: void 0
|
|
293
|
-
}
|
|
177
|
+
keywords: {},
|
|
178
|
+
classNames: {},
|
|
179
|
+
styles: {},
|
|
180
|
+
vars: {}
|
|
294
181
|
},
|
|
295
|
-
setup(
|
|
296
|
-
const
|
|
182
|
+
setup(__props) {
|
|
183
|
+
const rawProps = __props;
|
|
184
|
+
const attrs = useAttrs();
|
|
185
|
+
const slots = useSlots();
|
|
186
|
+
const props = useProps("SpotlightAction", null, rawProps);
|
|
297
187
|
const ctx = useSpotlightContext();
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
attrs.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
188
|
+
const stylesApi = computed(() => ({
|
|
189
|
+
classNames: props.classNames,
|
|
190
|
+
styles: props.styles
|
|
191
|
+
}));
|
|
192
|
+
const leftSection = computed(() => resolveNode(props.leftSection, slots.leftSection));
|
|
193
|
+
const rightSection = computed(() => resolveNode(props.rightSection, slots.rightSection));
|
|
194
|
+
const renderLeftSection = () => leftSection.value;
|
|
195
|
+
const renderRightSection = () => rightSection.value;
|
|
196
|
+
const forwardedAttrs = computed(() => {
|
|
197
|
+
const value = { ...attrs };
|
|
198
|
+
delete value.onClick;
|
|
199
|
+
delete value.onMousedown;
|
|
200
|
+
return value;
|
|
201
|
+
});
|
|
202
|
+
function mousedown(event) {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
attrs.onMousedown?.(event);
|
|
205
|
+
}
|
|
206
|
+
function click(event) {
|
|
207
|
+
attrs.onClick?.(event);
|
|
208
|
+
if (props.closeSpotlightOnTrigger ?? ctx.closeOnActionTrigger) spotlightActions.close(ctx.store);
|
|
209
|
+
}
|
|
210
|
+
return (_ctx, _cache) => {
|
|
211
|
+
return openBlock(), createBlock(unref(UnstyledButton), mergeProps({
|
|
212
|
+
...forwardedAttrs.value,
|
|
213
|
+
...unref(ctx).getStyles("action", {
|
|
214
|
+
className: unref(attrs).class,
|
|
215
|
+
style: unref(attrs).style,
|
|
216
|
+
...stylesApi.value
|
|
217
|
+
})
|
|
218
|
+
}, {
|
|
219
|
+
"data-action": "",
|
|
220
|
+
tabindex: -1,
|
|
221
|
+
onMousedown: mousedown,
|
|
222
|
+
onClick: click
|
|
223
|
+
}), {
|
|
224
|
+
default: withCtx(() => [_ctx.$slots.default ? renderSlot(_ctx.$slots, "default", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
225
|
+
unref(hasNode)(leftSection.value) ? (openBlock(), createBlock(unref(Box), mergeProps({
|
|
226
|
+
key: 0,
|
|
227
|
+
component: "span",
|
|
228
|
+
mod: {
|
|
229
|
+
position: "left",
|
|
230
|
+
dimmed: unref(props).dimmedSections
|
|
231
|
+
}
|
|
232
|
+
}, unref(ctx).getStyles("actionSection", stylesApi.value)), {
|
|
233
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(renderLeftSection)))]),
|
|
234
|
+
_: 1
|
|
235
|
+
}, 16, ["mod"])) : createCommentVNode("", true),
|
|
236
|
+
createElementVNode("span", normalizeProps(guardReactiveProps(unref(ctx).getStyles("actionBody", stylesApi.value))), [unref(props).highlightQuery && typeof unref(props).label === "string" ? (openBlock(), createBlock(unref(Highlight), mergeProps({
|
|
237
|
+
key: 0,
|
|
238
|
+
component: "span",
|
|
239
|
+
highlight: unref(ctx).query,
|
|
240
|
+
color: unref(props).highlightColor
|
|
241
|
+
}, unref(ctx).getStyles("actionLabel", stylesApi.value)), {
|
|
242
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(props).label), 1)]),
|
|
243
|
+
_: 1
|
|
244
|
+
}, 16, ["highlight", "color"])) : (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 1 }, unref(ctx).getStyles("actionLabel", stylesApi.value))), toDisplayString(unref(props).label), 17)), createElementVNode("span", normalizeProps(guardReactiveProps(unref(ctx).getStyles("actionDescription", stylesApi.value))), toDisplayString(unref(props).description), 17)], 16),
|
|
245
|
+
unref(hasNode)(rightSection.value) ? (openBlock(), createBlock(unref(Box), mergeProps({
|
|
246
|
+
key: 1,
|
|
247
|
+
component: "span",
|
|
248
|
+
mod: {
|
|
249
|
+
position: "right",
|
|
250
|
+
dimmed: unref(props).dimmedSections
|
|
251
|
+
}
|
|
252
|
+
}, unref(ctx).getStyles("actionSection", stylesApi.value)), {
|
|
253
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(renderRightSection)))]),
|
|
254
|
+
_: 1
|
|
255
|
+
}, 16, ["mod"])) : createCommentVNode("", true)
|
|
256
|
+
], 64))]),
|
|
257
|
+
_: 3
|
|
258
|
+
}, 16);
|
|
347
259
|
};
|
|
348
260
|
}
|
|
349
261
|
});
|
|
350
|
-
Object.assign(SpotlightAction, { classes: Spotlight_module_default });
|
|
351
262
|
//#endregion
|
|
352
|
-
//#region src/SpotlightActionsGroup.
|
|
353
|
-
var
|
|
263
|
+
//#region src/components/SpotlightActionsGroup/SpotlightActionsGroup.vue
|
|
264
|
+
var SpotlightActionsGroup_default = /* @__PURE__ */ defineComponent({
|
|
354
265
|
name: "SpotlightActionsGroup",
|
|
355
266
|
inheritAttrs: false,
|
|
267
|
+
__name: "SpotlightActionsGroup",
|
|
356
268
|
props: {
|
|
357
|
-
label: {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
classNames: {
|
|
362
|
-
type: [Object, Function],
|
|
363
|
-
default: void 0
|
|
364
|
-
},
|
|
365
|
-
styles: {
|
|
366
|
-
type: [Object, Function],
|
|
367
|
-
default: void 0
|
|
368
|
-
},
|
|
369
|
-
vars: {
|
|
370
|
-
type: [Object, Function],
|
|
371
|
-
default: void 0
|
|
372
|
-
}
|
|
269
|
+
label: {},
|
|
270
|
+
classNames: {},
|
|
271
|
+
styles: {},
|
|
272
|
+
vars: {}
|
|
373
273
|
},
|
|
374
|
-
setup(
|
|
274
|
+
setup(__props) {
|
|
275
|
+
const rawProps = __props;
|
|
276
|
+
const attrs = useAttrs();
|
|
375
277
|
const props = useProps("SpotlightActionsGroup", null, rawProps);
|
|
376
278
|
const ctx = useSpotlightContext();
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
279
|
+
const groupStyles = computed(() => ctx.getStyles("actionsGroup", {
|
|
280
|
+
className: attrs.class,
|
|
281
|
+
style: attrs.style,
|
|
282
|
+
classNames: props.classNames,
|
|
283
|
+
styles: props.styles
|
|
284
|
+
}));
|
|
285
|
+
const labelVariable = computed(() => ({ "--spotlight-label": `'${props.label?.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'` }));
|
|
286
|
+
return (_ctx, _cache) => {
|
|
287
|
+
return openBlock(), createBlock(unref(Box), mergeProps({
|
|
288
|
+
...unref(attrs),
|
|
289
|
+
...groupStyles.value
|
|
290
|
+
}, { style: [
|
|
291
|
+
groupStyles.value.style,
|
|
292
|
+
unref(attrs).style,
|
|
293
|
+
labelVariable.value
|
|
294
|
+
] }), {
|
|
295
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
296
|
+
_: 3
|
|
297
|
+
}, 16, ["style"]);
|
|
298
|
+
};
|
|
391
299
|
}
|
|
392
300
|
});
|
|
393
|
-
Object.assign(SpotlightActionsGroup, { classes: Spotlight_module_default });
|
|
394
301
|
//#endregion
|
|
395
|
-
//#region src/SpotlightActionsList.
|
|
396
|
-
var
|
|
302
|
+
//#region src/components/SpotlightActionsList/SpotlightActionsList.vue
|
|
303
|
+
var SpotlightActionsList_default = /* @__PURE__ */ defineComponent({
|
|
397
304
|
name: "SpotlightActionsList",
|
|
398
305
|
inheritAttrs: false,
|
|
306
|
+
__name: "SpotlightActionsList",
|
|
399
307
|
props: {
|
|
400
|
-
id: {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
classNames: {
|
|
405
|
-
type: [Object, Function],
|
|
406
|
-
default: void 0
|
|
407
|
-
},
|
|
408
|
-
styles: {
|
|
409
|
-
type: [Object, Function],
|
|
410
|
-
default: void 0
|
|
411
|
-
},
|
|
412
|
-
vars: {
|
|
413
|
-
type: [Object, Function],
|
|
414
|
-
default: void 0
|
|
415
|
-
}
|
|
308
|
+
id: {},
|
|
309
|
+
classNames: {},
|
|
310
|
+
styles: {},
|
|
311
|
+
vars: {}
|
|
416
312
|
},
|
|
417
|
-
setup(
|
|
313
|
+
setup(__props) {
|
|
314
|
+
const rawProps = __props;
|
|
315
|
+
const attrs = useAttrs();
|
|
418
316
|
const props = useProps("SpotlightActionsList", null, rawProps);
|
|
419
317
|
const ctx = useSpotlightContext();
|
|
420
318
|
const generatedId = useId();
|
|
421
319
|
const listId = props.id || `mantine-${generatedId.value.replace(/:/g, "")}`;
|
|
422
320
|
onMounted(() => spotlightActions.setListId(listId, ctx.store));
|
|
423
321
|
onBeforeUnmount(() => spotlightActions.setListId("", ctx.store));
|
|
424
|
-
return () =>
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
322
|
+
return (_ctx, _cache) => {
|
|
323
|
+
return openBlock(), createBlock(unref(ScrollAreaAutosize), mergeProps({
|
|
324
|
+
...unref(attrs),
|
|
325
|
+
...unref(ctx).getStyles("actionsList", {
|
|
326
|
+
className: unref(attrs).class,
|
|
327
|
+
style: unref(attrs).style,
|
|
328
|
+
classNames: unref(props).classNames,
|
|
329
|
+
styles: unref(props).styles
|
|
330
|
+
})
|
|
331
|
+
}, {
|
|
332
|
+
type: "scroll",
|
|
333
|
+
"scrollbar-size": "var(--spotlight-actions-list-padding)",
|
|
334
|
+
"offset-scrollbars": "y",
|
|
335
|
+
id: unref(listId)
|
|
336
|
+
}), {
|
|
337
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
338
|
+
_: 3
|
|
339
|
+
}, 16, ["id"]);
|
|
340
|
+
};
|
|
437
341
|
}
|
|
438
342
|
});
|
|
439
|
-
Object.assign(SpotlightActionsList, { classes: Spotlight_module_default });
|
|
440
343
|
//#endregion
|
|
441
|
-
//#region src/SpotlightEmpty.
|
|
442
|
-
var
|
|
344
|
+
//#region src/components/SpotlightEmpty/SpotlightEmpty.vue
|
|
345
|
+
var SpotlightEmpty_default = /* @__PURE__ */ defineComponent({
|
|
443
346
|
name: "SpotlightEmpty",
|
|
444
347
|
inheritAttrs: false,
|
|
348
|
+
__name: "SpotlightEmpty",
|
|
445
349
|
props: {
|
|
446
|
-
classNames: {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
},
|
|
450
|
-
styles: {
|
|
451
|
-
type: [Object, Function],
|
|
452
|
-
default: void 0
|
|
453
|
-
},
|
|
454
|
-
vars: {
|
|
455
|
-
type: [Object, Function],
|
|
456
|
-
default: void 0
|
|
457
|
-
}
|
|
350
|
+
classNames: {},
|
|
351
|
+
styles: {},
|
|
352
|
+
vars: {}
|
|
458
353
|
},
|
|
459
|
-
setup(
|
|
354
|
+
setup(__props) {
|
|
355
|
+
const rawProps = __props;
|
|
356
|
+
const attrs = useAttrs();
|
|
460
357
|
const props = useProps("SpotlightEmpty", null, rawProps);
|
|
461
358
|
const ctx = useSpotlightContext();
|
|
462
|
-
return () =>
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
var SpotlightFooter = defineComponent({
|
|
477
|
-
name: "SpotlightFooter",
|
|
478
|
-
inheritAttrs: false,
|
|
479
|
-
props: {
|
|
480
|
-
classNames: {
|
|
481
|
-
type: [Object, Function],
|
|
482
|
-
default: void 0
|
|
483
|
-
},
|
|
484
|
-
styles: {
|
|
485
|
-
type: [Object, Function],
|
|
486
|
-
default: void 0
|
|
487
|
-
},
|
|
488
|
-
vars: {
|
|
489
|
-
type: [Object, Function],
|
|
490
|
-
default: void 0
|
|
491
|
-
}
|
|
492
|
-
},
|
|
493
|
-
setup(rawProps, { attrs, slots }) {
|
|
494
|
-
const props = useProps("SpotlightFooter", null, rawProps);
|
|
495
|
-
const ctx = useSpotlightContext();
|
|
496
|
-
return () => h(Box, {
|
|
497
|
-
...attrs,
|
|
498
|
-
...ctx.getStyles("footer", {
|
|
499
|
-
className: attrs.class,
|
|
500
|
-
style: attrs.style,
|
|
501
|
-
classNames: props.classNames,
|
|
502
|
-
styles: props.styles
|
|
503
|
-
})
|
|
504
|
-
}, () => slots.default?.());
|
|
359
|
+
return (_ctx, _cache) => {
|
|
360
|
+
return openBlock(), createBlock(unref(Box), normalizeProps(guardReactiveProps({
|
|
361
|
+
...unref(attrs),
|
|
362
|
+
...unref(ctx).getStyles("empty", {
|
|
363
|
+
className: unref(attrs).class,
|
|
364
|
+
style: unref(attrs).style,
|
|
365
|
+
classNames: unref(props).classNames,
|
|
366
|
+
styles: unref(props).styles
|
|
367
|
+
})
|
|
368
|
+
})), {
|
|
369
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
370
|
+
_: 3
|
|
371
|
+
}, 16);
|
|
372
|
+
};
|
|
505
373
|
}
|
|
506
374
|
});
|
|
507
|
-
Object.assign(SpotlightFooter, { classes: Spotlight_module_default });
|
|
508
375
|
//#endregion
|
|
509
376
|
//#region src/get-hotkeys.ts
|
|
510
377
|
function getHotkeys(hotkeys, store) {
|
|
@@ -533,116 +400,91 @@ function mergeStyles(...items) {
|
|
|
533
400
|
return acc;
|
|
534
401
|
}, {});
|
|
535
402
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
store: spotlightStore,
|
|
551
|
-
clearQueryOnClose: true,
|
|
552
|
-
closeOnActionTrigger: true,
|
|
553
|
-
shortcut: "mod + K",
|
|
554
|
-
maxHeight: 400
|
|
403
|
+
var Spotlight_module_default = {
|
|
404
|
+
root: "_root_87n7g_1",
|
|
405
|
+
content: "_content_87n7g_7",
|
|
406
|
+
body: "_body_87n7g_13",
|
|
407
|
+
search: "_search_87n7g_19",
|
|
408
|
+
actionsList: "_actionsList_87n7g_24",
|
|
409
|
+
action: "_action_87n7g_24",
|
|
410
|
+
actionBody: "_actionBody_87n7g_73",
|
|
411
|
+
actionSection: "_actionSection_87n7g_77",
|
|
412
|
+
actionLabel: "_actionLabel_87n7g_99",
|
|
413
|
+
actionDescription: "_actionDescription_87n7g_103",
|
|
414
|
+
empty: "_empty_87n7g_110",
|
|
415
|
+
footer: "_footer_87n7g_116",
|
|
416
|
+
actionsGroup: "_actionsGroup_87n7g_129"
|
|
555
417
|
};
|
|
556
|
-
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/components/SpotlightRoot/SpotlightRoot.vue
|
|
420
|
+
var SpotlightRoot_default = /* @__PURE__ */ defineComponent({
|
|
557
421
|
name: "SpotlightRoot",
|
|
558
422
|
inheritAttrs: false,
|
|
423
|
+
__name: "SpotlightRoot",
|
|
559
424
|
props: {
|
|
560
|
-
store: {
|
|
561
|
-
|
|
562
|
-
default: void 0
|
|
563
|
-
},
|
|
564
|
-
query: {
|
|
565
|
-
type: String,
|
|
566
|
-
default: void 0
|
|
567
|
-
},
|
|
568
|
-
onQueryChange: {
|
|
569
|
-
type: Function,
|
|
570
|
-
default: void 0
|
|
571
|
-
},
|
|
425
|
+
store: { default: () => spotlightStore },
|
|
426
|
+
query: {},
|
|
572
427
|
clearQueryOnClose: {
|
|
573
428
|
type: Boolean,
|
|
574
|
-
default:
|
|
575
|
-
},
|
|
576
|
-
shortcut: {
|
|
577
|
-
type: [
|
|
578
|
-
String,
|
|
579
|
-
Array,
|
|
580
|
-
null
|
|
581
|
-
],
|
|
582
|
-
default: void 0
|
|
583
|
-
},
|
|
584
|
-
tagsToIgnore: {
|
|
585
|
-
type: Array,
|
|
586
|
-
default: void 0
|
|
587
|
-
},
|
|
588
|
-
triggerOnContentEditable: {
|
|
589
|
-
type: Boolean,
|
|
590
|
-
default: void 0
|
|
429
|
+
default: true
|
|
591
430
|
},
|
|
431
|
+
shortcut: { default: "mod + K" },
|
|
432
|
+
tagsToIgnore: {},
|
|
433
|
+
triggerOnContentEditable: { type: Boolean },
|
|
592
434
|
disabled: {
|
|
593
435
|
type: Boolean,
|
|
594
436
|
default: false
|
|
595
437
|
},
|
|
596
|
-
onSpotlightOpen: {
|
|
597
|
-
type: Function,
|
|
598
|
-
default: void 0
|
|
599
|
-
},
|
|
600
|
-
onSpotlightClose: {
|
|
601
|
-
type: Function,
|
|
602
|
-
default: void 0
|
|
603
|
-
},
|
|
604
438
|
forceOpened: {
|
|
605
439
|
type: Boolean,
|
|
606
440
|
default: false
|
|
607
441
|
},
|
|
608
442
|
closeOnActionTrigger: {
|
|
609
443
|
type: Boolean,
|
|
610
|
-
default:
|
|
611
|
-
},
|
|
612
|
-
maxHeight: {
|
|
613
|
-
type: [String, Number],
|
|
614
|
-
default: void 0
|
|
444
|
+
default: true
|
|
615
445
|
},
|
|
446
|
+
maxHeight: { default: 400 },
|
|
616
447
|
scrollable: {
|
|
617
448
|
type: Boolean,
|
|
618
449
|
default: false
|
|
619
450
|
},
|
|
620
|
-
classNames: {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
styles: {
|
|
625
|
-
type: [Object, Function],
|
|
626
|
-
default: void 0
|
|
627
|
-
},
|
|
628
|
-
vars: {
|
|
629
|
-
type: [Object, Function],
|
|
630
|
-
default: void 0
|
|
631
|
-
},
|
|
632
|
-
unstyled: {
|
|
633
|
-
type: Boolean,
|
|
634
|
-
default: false
|
|
635
|
-
}
|
|
451
|
+
classNames: {},
|
|
452
|
+
styles: {},
|
|
453
|
+
vars: {},
|
|
454
|
+
unstyled: { type: Boolean }
|
|
636
455
|
},
|
|
637
|
-
|
|
638
|
-
|
|
456
|
+
emits: [
|
|
457
|
+
"update:query",
|
|
458
|
+
"query-change",
|
|
459
|
+
"spotlight-open",
|
|
460
|
+
"spotlight-close",
|
|
461
|
+
"exit-transition-end"
|
|
462
|
+
],
|
|
463
|
+
setup(__props, { emit: __emit }) {
|
|
464
|
+
const rawProps = __props;
|
|
465
|
+
const emit = __emit;
|
|
466
|
+
const attrs = useAttrs();
|
|
467
|
+
const props = useProps("SpotlightRoot", {
|
|
468
|
+
size: 600,
|
|
469
|
+
yOffset: 80,
|
|
470
|
+
zIndex: getDefaultZIndex("max"),
|
|
471
|
+
overlayProps: {
|
|
472
|
+
backgroundOpacity: .35,
|
|
473
|
+
blur: 7
|
|
474
|
+
},
|
|
475
|
+
transitionProps: {
|
|
476
|
+
duration: 200,
|
|
477
|
+
transition: "pop"
|
|
478
|
+
}
|
|
479
|
+
}, rawProps);
|
|
639
480
|
const state = useSpotlight(props.store);
|
|
640
481
|
const previousOpened = ref(state.value.opened);
|
|
641
482
|
const currentQuery = computed(() => typeof props.query === "string" ? props.query : state.value.query);
|
|
642
|
-
|
|
643
|
-
|
|
483
|
+
function setQuery(query) {
|
|
484
|
+
emit("update:query", query);
|
|
485
|
+
emit("query-change", query);
|
|
644
486
|
spotlightActions.setQuery(query, props.store);
|
|
645
|
-
}
|
|
487
|
+
}
|
|
646
488
|
const getStyles = useStyles({
|
|
647
489
|
name: "Spotlight",
|
|
648
490
|
classes: Spotlight_module_default,
|
|
@@ -668,88 +510,122 @@ var SpotlightRoot = defineComponent({
|
|
|
668
510
|
useHotkeys(() => getHotkeys(props.shortcut, props.store), () => props.tagsToIgnore, () => props.triggerOnContentEditable);
|
|
669
511
|
watch(() => state.value.opened, (opened) => {
|
|
670
512
|
if (opened === previousOpened.value) return;
|
|
671
|
-
if (opened)
|
|
672
|
-
else
|
|
513
|
+
if (opened) emit("spotlight-open");
|
|
514
|
+
else emit("spotlight-close");
|
|
673
515
|
previousOpened.value = opened;
|
|
674
516
|
});
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const { classNames: _classNames, styles: _styles, vars: _vars, unstyled: _unstyled, store: _store, query: _query, onQueryChange: _onQueryChange, clearQueryOnClose: _clearQueryOnClose, shortcut: _shortcut, tagsToIgnore: _tagsToIgnore, triggerOnContentEditable: _triggerOnContentEditable, disabled: _disabled, onSpotlightOpen: _onSpotlightOpen, onSpotlightClose: _onSpotlightClose, forceOpened: _forceOpened, closeOnActionTrigger: _closeOnActionTrigger, maxHeight: _maxHeight, scrollable: _scrollable, ...modalAttrs } = {
|
|
517
|
+
const rootStyles = computed(() => getStyles("root", {
|
|
518
|
+
className: attrs.class,
|
|
519
|
+
style: attrs.style
|
|
520
|
+
}));
|
|
521
|
+
const modalAttrs = computed(() => {
|
|
522
|
+
const value = {
|
|
682
523
|
...attrs,
|
|
683
524
|
...props
|
|
684
525
|
};
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
526
|
+
for (const key of [
|
|
527
|
+
"classNames",
|
|
528
|
+
"styles",
|
|
529
|
+
"vars",
|
|
530
|
+
"unstyled",
|
|
531
|
+
"store",
|
|
532
|
+
"query",
|
|
533
|
+
"clearQueryOnClose",
|
|
534
|
+
"shortcut",
|
|
535
|
+
"tagsToIgnore",
|
|
536
|
+
"triggerOnContentEditable",
|
|
537
|
+
"disabled",
|
|
538
|
+
"forceOpened",
|
|
539
|
+
"closeOnActionTrigger",
|
|
540
|
+
"maxHeight",
|
|
541
|
+
"scrollable",
|
|
542
|
+
"class",
|
|
543
|
+
"style"
|
|
544
|
+
]) delete value[key];
|
|
545
|
+
return value;
|
|
546
|
+
});
|
|
547
|
+
function close() {
|
|
548
|
+
spotlightActions.close(props.store);
|
|
549
|
+
}
|
|
550
|
+
function exitTransitionEnd() {
|
|
551
|
+
if (props.clearQueryOnClose) setQuery("");
|
|
552
|
+
spotlightActions.clearSpotlightState({ clearQuery: props.clearQueryOnClose }, props.store);
|
|
553
|
+
props.transitionProps?.onExited?.();
|
|
554
|
+
emit("exit-transition-end");
|
|
555
|
+
}
|
|
556
|
+
return (_ctx, _cache) => {
|
|
557
|
+
return !unref(props).disabled ? (openBlock(), createBlock(unref(Modal), mergeProps({ key: 0 }, modalAttrs.value, {
|
|
558
|
+
"with-close-button": false,
|
|
559
|
+
opened: unref(state).opened || unref(props).forceOpened,
|
|
689
560
|
padding: 0,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
"
|
|
706
|
-
|
|
561
|
+
class: rootStyles.value.class,
|
|
562
|
+
style: rootStyles.value.style,
|
|
563
|
+
"class-names": unref(mergeClassNames)({
|
|
564
|
+
body: unref(Spotlight_module_default).body,
|
|
565
|
+
content: unref(Spotlight_module_default).content
|
|
566
|
+
}, unref(props).classNames),
|
|
567
|
+
styles: unref(mergeStyles)(unref(props).styles),
|
|
568
|
+
vars: unref(mergeStyles)({ root: { "--spotlight-max-height": unref(props).scrollable ? unref(rem)(unref(props).maxHeight) : void 0 } }, unref(props).vars),
|
|
569
|
+
"data-scrollable": unref(props).scrollable || void 0,
|
|
570
|
+
onClose: close,
|
|
571
|
+
onExitTransitionEnd: exitTransitionEnd
|
|
572
|
+
}), {
|
|
573
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
574
|
+
_: 3
|
|
575
|
+
}, 16, [
|
|
576
|
+
"opened",
|
|
577
|
+
"class",
|
|
578
|
+
"style",
|
|
579
|
+
"class-names",
|
|
580
|
+
"styles",
|
|
581
|
+
"vars",
|
|
582
|
+
"data-scrollable"
|
|
583
|
+
])) : createCommentVNode("", true);
|
|
707
584
|
};
|
|
708
585
|
}
|
|
709
586
|
});
|
|
710
|
-
Object.assign(SpotlightRoot, { classes: Spotlight_module_default });
|
|
711
587
|
//#endregion
|
|
712
|
-
//#region src/SpotlightSearch.
|
|
713
|
-
var
|
|
714
|
-
var SpotlightSearch = defineComponent({
|
|
588
|
+
//#region src/components/SpotlightSearch/SpotlightSearch.vue
|
|
589
|
+
var SpotlightSearch_default = /* @__PURE__ */ defineComponent({
|
|
715
590
|
name: "SpotlightSearch",
|
|
716
591
|
inheritAttrs: false,
|
|
592
|
+
__name: "SpotlightSearch",
|
|
717
593
|
props: {
|
|
718
|
-
size: {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
},
|
|
722
|
-
|
|
723
|
-
type: String,
|
|
724
|
-
default: void 0
|
|
725
|
-
},
|
|
726
|
-
onChange: {
|
|
727
|
-
type: Function,
|
|
728
|
-
default: void 0
|
|
729
|
-
},
|
|
730
|
-
onKeydown: {
|
|
731
|
-
type: Function,
|
|
732
|
-
default: void 0
|
|
733
|
-
},
|
|
734
|
-
classNames: {
|
|
735
|
-
type: [Object, Function],
|
|
736
|
-
default: void 0
|
|
737
|
-
},
|
|
738
|
-
styles: {
|
|
739
|
-
type: [Object, Function],
|
|
740
|
-
default: void 0
|
|
741
|
-
},
|
|
742
|
-
vars: {
|
|
743
|
-
type: [Object, Function],
|
|
744
|
-
default: void 0
|
|
745
|
-
}
|
|
594
|
+
size: { default: "lg" },
|
|
595
|
+
modelValue: {},
|
|
596
|
+
classNames: {},
|
|
597
|
+
styles: {},
|
|
598
|
+
vars: {}
|
|
746
599
|
},
|
|
747
|
-
|
|
748
|
-
|
|
600
|
+
emits: [
|
|
601
|
+
"update:modelValue",
|
|
602
|
+
"change",
|
|
603
|
+
"keydown"
|
|
604
|
+
],
|
|
605
|
+
setup(__props, { emit: __emit }) {
|
|
606
|
+
const rawProps = __props;
|
|
607
|
+
const emit = __emit;
|
|
608
|
+
const attrs = useAttrs();
|
|
609
|
+
const props = useProps("SpotlightSearch", null, rawProps);
|
|
749
610
|
const ctx = useSpotlightContext();
|
|
750
611
|
const isComposing = ref(false);
|
|
751
|
-
const
|
|
752
|
-
|
|
612
|
+
const inputStyles = computed(() => ctx.getStyles("search"));
|
|
613
|
+
const forwardedAttrs = computed(() => {
|
|
614
|
+
const value = { ...attrs };
|
|
615
|
+
delete value.onInput;
|
|
616
|
+
delete value.onKeydown;
|
|
617
|
+
delete value.onCompositionstart;
|
|
618
|
+
delete value.onCompositionend;
|
|
619
|
+
return value;
|
|
620
|
+
});
|
|
621
|
+
function input(event) {
|
|
622
|
+
const value = event.currentTarget.value;
|
|
623
|
+
ctx.setQuery(value);
|
|
624
|
+
emit("update:modelValue", value);
|
|
625
|
+
emit("change", value);
|
|
626
|
+
}
|
|
627
|
+
function keydown(event) {
|
|
628
|
+
emit("keydown", event);
|
|
753
629
|
if (isComposing.value) return;
|
|
754
630
|
if (event.code === "ArrowDown") {
|
|
755
631
|
event.preventDefault();
|
|
@@ -763,206 +639,276 @@ var SpotlightSearch = defineComponent({
|
|
|
763
639
|
event.preventDefault();
|
|
764
640
|
spotlightActions.triggerSelectedAction(ctx.store);
|
|
765
641
|
}
|
|
766
|
-
}
|
|
767
|
-
return () => {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
isComposing.value = false;
|
|
786
|
-
}
|
|
787
|
-
});
|
|
642
|
+
}
|
|
643
|
+
return (_ctx, _cache) => {
|
|
644
|
+
return openBlock(), createBlock(unref(Input), mergeProps(forwardedAttrs.value, {
|
|
645
|
+
size: unref(props).size,
|
|
646
|
+
value: unref(props).modelValue ?? unref(ctx).query,
|
|
647
|
+
"class-names": unref(mergeClassNames)({ input: inputStyles.value.class }, unref(props).classNames),
|
|
648
|
+
styles: unref(mergeStyles)({ input: inputStyles.value.style }, unref(props).styles),
|
|
649
|
+
vars: unref(props).vars,
|
|
650
|
+
onInput: input,
|
|
651
|
+
onKeydown: keydown,
|
|
652
|
+
onCompositionstart: _cache[0] || (_cache[0] = ($event) => isComposing.value = true),
|
|
653
|
+
onCompositionend: _cache[1] || (_cache[1] = ($event) => isComposing.value = false)
|
|
654
|
+
}), null, 16, [
|
|
655
|
+
"size",
|
|
656
|
+
"value",
|
|
657
|
+
"class-names",
|
|
658
|
+
"styles",
|
|
659
|
+
"vars"
|
|
660
|
+
]);
|
|
788
661
|
};
|
|
789
662
|
}
|
|
790
663
|
});
|
|
791
|
-
Object.assign(SpotlightSearch, { classes: Spotlight_module_default });
|
|
792
664
|
//#endregion
|
|
793
|
-
//#region src/
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
},
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
665
|
+
//#region src/default-spotlight-filter.ts
|
|
666
|
+
function getKeywords(keywords) {
|
|
667
|
+
if (Array.isArray(keywords)) return keywords.map((keyword) => keyword.trim()).join(",").toLowerCase().trim();
|
|
668
|
+
if (typeof keywords === "string") return keywords.toLowerCase().trim();
|
|
669
|
+
return "";
|
|
670
|
+
}
|
|
671
|
+
function getFlatActions(data) {
|
|
672
|
+
return data.reduce((acc, item) => {
|
|
673
|
+
if ("actions" in item) return [...acc, ...item.actions.map((action) => ({
|
|
674
|
+
...action,
|
|
675
|
+
group: item.group
|
|
676
|
+
}))];
|
|
677
|
+
return [...acc, item];
|
|
678
|
+
}, []);
|
|
679
|
+
}
|
|
680
|
+
function flatActionsToGroups(data) {
|
|
681
|
+
const groups = {};
|
|
682
|
+
const result = [];
|
|
683
|
+
data.forEach((action) => {
|
|
684
|
+
if (action.group) {
|
|
685
|
+
if (!groups[action.group]) groups[action.group] = {
|
|
686
|
+
pushed: false,
|
|
687
|
+
data: {
|
|
688
|
+
group: action.group,
|
|
689
|
+
actions: []
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
groups[action.group].data.actions.push(action);
|
|
693
|
+
if (!groups[action.group].pushed) {
|
|
694
|
+
groups[action.group].pushed = true;
|
|
695
|
+
result.push(groups[action.group].data);
|
|
696
|
+
}
|
|
697
|
+
} else result.push(action);
|
|
698
|
+
});
|
|
699
|
+
return result;
|
|
700
|
+
}
|
|
701
|
+
var defaultSpotlightFilter = (_query, data) => {
|
|
702
|
+
const query = _query.trim().toLowerCase();
|
|
703
|
+
const priorityMatrix = [[], []];
|
|
704
|
+
getFlatActions(data).forEach((item) => {
|
|
705
|
+
if (item.label?.toLowerCase().includes(query)) priorityMatrix[0].push(item);
|
|
706
|
+
else if (item.description?.toLowerCase().includes(query) || getKeywords(item.keywords).includes(query)) priorityMatrix[1].push(item);
|
|
707
|
+
});
|
|
708
|
+
return flatActionsToGroups(priorityMatrix.flat());
|
|
812
709
|
};
|
|
813
|
-
|
|
814
|
-
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/limit-actions.ts
|
|
712
|
+
function limitActions(actions, limit) {
|
|
713
|
+
if (!Array.isArray(actions)) return [];
|
|
714
|
+
let count = 0;
|
|
715
|
+
return actions.reduce((acc, item) => {
|
|
716
|
+
if (count >= limit) return acc;
|
|
717
|
+
if (isActionsGroup(item)) {
|
|
718
|
+
const groupActions = limitActions(item.actions, limit - count);
|
|
719
|
+
acc.push({
|
|
720
|
+
group: item.group,
|
|
721
|
+
actions: groupActions
|
|
722
|
+
});
|
|
723
|
+
count += groupActions.length;
|
|
724
|
+
} else {
|
|
725
|
+
acc.push(item);
|
|
726
|
+
count += 1;
|
|
727
|
+
}
|
|
728
|
+
return acc;
|
|
729
|
+
}, []);
|
|
815
730
|
}
|
|
816
|
-
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region src/components/Spotlight/Spotlight.vue
|
|
733
|
+
var Spotlight_default = /* @__PURE__ */ defineComponent({
|
|
817
734
|
name: "Spotlight",
|
|
818
735
|
inheritAttrs: false,
|
|
736
|
+
__name: "Spotlight",
|
|
819
737
|
props: {
|
|
820
|
-
searchProps: {
|
|
821
|
-
|
|
822
|
-
default: void 0
|
|
823
|
-
},
|
|
824
|
-
actions: {
|
|
825
|
-
type: Array,
|
|
826
|
-
required: true
|
|
827
|
-
},
|
|
738
|
+
searchProps: {},
|
|
739
|
+
actions: {},
|
|
828
740
|
filter: {
|
|
829
741
|
type: Function,
|
|
830
|
-
default:
|
|
831
|
-
},
|
|
832
|
-
nothingFound: {
|
|
833
|
-
type: [
|
|
834
|
-
String,
|
|
835
|
-
Number,
|
|
836
|
-
Object,
|
|
837
|
-
Function
|
|
838
|
-
],
|
|
839
|
-
default: void 0
|
|
742
|
+
default: defaultSpotlightFilter
|
|
840
743
|
},
|
|
744
|
+
nothingFound: {},
|
|
841
745
|
highlightQuery: {
|
|
842
746
|
type: Boolean,
|
|
843
747
|
default: false
|
|
844
748
|
},
|
|
845
|
-
limit: {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
},
|
|
849
|
-
scrollAreaProps: {
|
|
850
|
-
type: Object,
|
|
851
|
-
default: void 0
|
|
852
|
-
},
|
|
853
|
-
query: {
|
|
854
|
-
type: String,
|
|
855
|
-
default: void 0
|
|
856
|
-
},
|
|
857
|
-
onQueryChange: {
|
|
858
|
-
type: Function,
|
|
859
|
-
default: void 0
|
|
860
|
-
},
|
|
861
|
-
store: {
|
|
862
|
-
type: Object,
|
|
863
|
-
default: void 0
|
|
864
|
-
},
|
|
749
|
+
limit: { default: Infinity },
|
|
750
|
+
scrollAreaProps: {},
|
|
751
|
+
store: { default: () => spotlightStore },
|
|
752
|
+
query: {},
|
|
865
753
|
clearQueryOnClose: {
|
|
866
754
|
type: Boolean,
|
|
867
|
-
default:
|
|
868
|
-
},
|
|
869
|
-
shortcut: {
|
|
870
|
-
type: [String, Array],
|
|
871
|
-
default: void 0
|
|
872
|
-
},
|
|
873
|
-
tagsToIgnore: {
|
|
874
|
-
type: Array,
|
|
875
|
-
default: void 0
|
|
876
|
-
},
|
|
877
|
-
triggerOnContentEditable: {
|
|
878
|
-
type: Boolean,
|
|
879
|
-
default: void 0
|
|
880
|
-
},
|
|
881
|
-
disabled: {
|
|
882
|
-
type: Boolean,
|
|
883
|
-
default: false
|
|
884
|
-
},
|
|
885
|
-
onSpotlightOpen: {
|
|
886
|
-
type: Function,
|
|
887
|
-
default: void 0
|
|
888
|
-
},
|
|
889
|
-
onSpotlightClose: {
|
|
890
|
-
type: Function,
|
|
891
|
-
default: void 0
|
|
892
|
-
},
|
|
893
|
-
forceOpened: {
|
|
894
|
-
type: Boolean,
|
|
895
|
-
default: false
|
|
755
|
+
default: true
|
|
896
756
|
},
|
|
757
|
+
shortcut: { default: "mod + K" },
|
|
758
|
+
tagsToIgnore: {},
|
|
759
|
+
triggerOnContentEditable: { type: Boolean },
|
|
760
|
+
disabled: { type: Boolean },
|
|
761
|
+
forceOpened: { type: Boolean },
|
|
897
762
|
closeOnActionTrigger: {
|
|
898
763
|
type: Boolean,
|
|
899
|
-
default:
|
|
900
|
-
},
|
|
901
|
-
maxHeight: {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
},
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
default: false
|
|
908
|
-
},
|
|
909
|
-
classNames: {
|
|
910
|
-
type: [Object, Function],
|
|
911
|
-
default: void 0
|
|
912
|
-
},
|
|
913
|
-
styles: {
|
|
914
|
-
type: [Object, Function],
|
|
915
|
-
default: void 0
|
|
916
|
-
},
|
|
917
|
-
vars: {
|
|
918
|
-
type: [Object, Function],
|
|
919
|
-
default: void 0
|
|
920
|
-
},
|
|
921
|
-
unstyled: {
|
|
922
|
-
type: Boolean,
|
|
923
|
-
default: false
|
|
924
|
-
}
|
|
764
|
+
default: true
|
|
765
|
+
},
|
|
766
|
+
maxHeight: {},
|
|
767
|
+
scrollable: { type: Boolean },
|
|
768
|
+
classNames: {},
|
|
769
|
+
styles: {},
|
|
770
|
+
vars: {},
|
|
771
|
+
unstyled: { type: Boolean }
|
|
925
772
|
},
|
|
926
|
-
|
|
927
|
-
|
|
773
|
+
emits: [
|
|
774
|
+
"update:query",
|
|
775
|
+
"query-change",
|
|
776
|
+
"spotlight-open",
|
|
777
|
+
"spotlight-close",
|
|
778
|
+
"exit-transition-end"
|
|
779
|
+
],
|
|
780
|
+
setup(__props, { emit: __emit }) {
|
|
781
|
+
const rawProps = __props;
|
|
782
|
+
const emit = __emit;
|
|
783
|
+
const attrs = useAttrs();
|
|
784
|
+
const props = useProps("Spotlight", {
|
|
785
|
+
size: 600,
|
|
786
|
+
yOffset: 80,
|
|
787
|
+
zIndex: getDefaultZIndex("max"),
|
|
788
|
+
overlayProps: {
|
|
789
|
+
backgroundOpacity: .35,
|
|
790
|
+
blur: 7
|
|
791
|
+
},
|
|
792
|
+
transitionProps: {
|
|
793
|
+
duration: 200,
|
|
794
|
+
transition: "pop"
|
|
795
|
+
}
|
|
796
|
+
}, rawProps);
|
|
928
797
|
const uncontrolledQuery = ref("");
|
|
929
798
|
const currentQuery = computed(() => typeof props.query === "string" ? props.query : uncontrolledQuery.value);
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
};
|
|
934
|
-
return () => {
|
|
935
|
-
const renderedActions = limitActions(props.filter(currentQuery.value, props.actions), props.limit).map((item) => {
|
|
936
|
-
if (isActionsGroup(item)) return h(SpotlightActionsGroup, {
|
|
937
|
-
key: item.group,
|
|
938
|
-
label: item.group
|
|
939
|
-
}, () => item.actions.map(({ id, ...actionData }) => h(SpotlightAction, {
|
|
940
|
-
key: id,
|
|
941
|
-
highlightQuery: props.highlightQuery,
|
|
942
|
-
...actionData
|
|
943
|
-
})));
|
|
944
|
-
const { id, ...actionData } = item;
|
|
945
|
-
return h(SpotlightAction, {
|
|
946
|
-
key: id,
|
|
947
|
-
highlightQuery: props.highlightQuery,
|
|
948
|
-
...actionData
|
|
949
|
-
});
|
|
950
|
-
});
|
|
951
|
-
const { searchProps: _searchProps, actions: _actions, filter: _filter, nothingFound: _nothingFound, highlightQuery: _highlightQuery, limit: _limit, scrollAreaProps: _scrollAreaProps, query: _query, onQueryChange: _onQueryChange, ...rootProps } = props;
|
|
952
|
-
return h(SpotlightRoot, {
|
|
799
|
+
const filteredActions = computed(() => limitActions(props.filter(currentQuery.value, props.actions), props.limit));
|
|
800
|
+
const rootProps = computed(() => {
|
|
801
|
+
const value = {
|
|
953
802
|
...attrs,
|
|
954
|
-
...
|
|
803
|
+
...props
|
|
804
|
+
};
|
|
805
|
+
for (const key of [
|
|
806
|
+
"searchProps",
|
|
807
|
+
"actions",
|
|
808
|
+
"filter",
|
|
809
|
+
"nothingFound",
|
|
810
|
+
"highlightQuery",
|
|
811
|
+
"limit",
|
|
812
|
+
"scrollAreaProps",
|
|
813
|
+
"query"
|
|
814
|
+
]) delete value[key];
|
|
815
|
+
return value;
|
|
816
|
+
});
|
|
817
|
+
function setQuery(query) {
|
|
818
|
+
if (typeof props.query !== "string") uncontrolledQuery.value = query;
|
|
819
|
+
emit("update:query", query);
|
|
820
|
+
emit("query-change", query);
|
|
821
|
+
}
|
|
822
|
+
function actionProps(action) {
|
|
823
|
+
const value = { ...action };
|
|
824
|
+
delete value.id;
|
|
825
|
+
delete value.group;
|
|
826
|
+
return value;
|
|
827
|
+
}
|
|
828
|
+
const renderNothingFound = () => typeof props.nothingFound === "function" ? props.nothingFound() : props.nothingFound;
|
|
829
|
+
return (_ctx, _cache) => {
|
|
830
|
+
return openBlock(), createBlock(SpotlightRoot_default, mergeProps(rootProps.value, {
|
|
955
831
|
query: currentQuery.value,
|
|
956
832
|
onQueryChange: setQuery
|
|
957
|
-
},
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
833
|
+
}), {
|
|
834
|
+
default: withCtx(() => [createVNode(SpotlightSearch_default, normalizeProps(guardReactiveProps(unref(props).searchProps)), null, 16), filteredActions.value.length ? (openBlock(), createBlock(SpotlightActionsList_default, normalizeProps(mergeProps({ key: 0 }, unref(props).scrollAreaProps)), {
|
|
835
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(filteredActions.value, (item) => {
|
|
836
|
+
return openBlock(), createElementBlock(Fragment, { key: unref(isActionsGroup)(item) ? item.group : item.id }, [unref(isActionsGroup)(item) ? (openBlock(), createBlock(SpotlightActionsGroup_default, {
|
|
837
|
+
key: 0,
|
|
838
|
+
label: item.group
|
|
839
|
+
}, {
|
|
840
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(item.actions, (action) => {
|
|
841
|
+
return openBlock(), createBlock(SpotlightAction_default, mergeProps({ key: action.id }, { ref_for: true }, actionProps(action), { "highlight-query": unref(props).highlightQuery }), null, 16, ["highlight-query"]);
|
|
842
|
+
}), 128))]),
|
|
843
|
+
_: 2
|
|
844
|
+
}, 1032, ["label"])) : (openBlock(), createBlock(SpotlightAction_default, mergeProps({
|
|
845
|
+
key: 1,
|
|
846
|
+
ref_for: true
|
|
847
|
+
}, actionProps(item), { "highlight-query": unref(props).highlightQuery }), null, 16, ["highlight-query"]))], 64);
|
|
848
|
+
}), 128))]),
|
|
849
|
+
_: 1
|
|
850
|
+
}, 16)) : unref(props).nothingFound ? (openBlock(), createBlock(SpotlightEmpty_default, { key: 1 }, {
|
|
851
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(renderNothingFound)))]),
|
|
852
|
+
_: 1
|
|
853
|
+
})) : createCommentVNode("", true)]),
|
|
854
|
+
_: 1
|
|
855
|
+
}, 16, ["query"]);
|
|
962
856
|
};
|
|
963
857
|
}
|
|
964
858
|
});
|
|
965
|
-
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/components/SpotlightAction/index.ts
|
|
861
|
+
var SpotlightAction = Object.assign(SpotlightAction_default, { classes: Spotlight_module_default });
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region src/components/SpotlightActionsGroup/index.ts
|
|
864
|
+
var SpotlightActionsGroup = Object.assign(SpotlightActionsGroup_default, { classes: Spotlight_module_default });
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/components/SpotlightActionsList/index.ts
|
|
867
|
+
var SpotlightActionsList = Object.assign(SpotlightActionsList_default, { classes: Spotlight_module_default });
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/components/SpotlightEmpty/index.ts
|
|
870
|
+
var SpotlightEmpty = Object.assign(SpotlightEmpty_default, { classes: Spotlight_module_default });
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/components/SpotlightFooter/index.ts
|
|
873
|
+
var SpotlightFooter = Object.assign(/* @__PURE__ */ defineComponent({
|
|
874
|
+
name: "SpotlightFooter",
|
|
875
|
+
inheritAttrs: false,
|
|
876
|
+
__name: "SpotlightFooter",
|
|
877
|
+
props: {
|
|
878
|
+
classNames: {},
|
|
879
|
+
styles: {},
|
|
880
|
+
vars: {}
|
|
881
|
+
},
|
|
882
|
+
setup(__props) {
|
|
883
|
+
const rawProps = __props;
|
|
884
|
+
const attrs = useAttrs();
|
|
885
|
+
const props = useProps("SpotlightFooter", null, rawProps);
|
|
886
|
+
const ctx = useSpotlightContext();
|
|
887
|
+
return (_ctx, _cache) => {
|
|
888
|
+
return openBlock(), createBlock(unref(Box), normalizeProps(guardReactiveProps({
|
|
889
|
+
...unref(attrs),
|
|
890
|
+
...unref(ctx).getStyles("footer", {
|
|
891
|
+
className: unref(attrs).class,
|
|
892
|
+
style: unref(attrs).style,
|
|
893
|
+
classNames: unref(props).classNames,
|
|
894
|
+
styles: unref(props).styles
|
|
895
|
+
})
|
|
896
|
+
})), {
|
|
897
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
898
|
+
_: 3
|
|
899
|
+
}, 16);
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
}), { classes: Spotlight_module_default });
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/components/SpotlightRoot/index.ts
|
|
905
|
+
var SpotlightRoot = Object.assign(SpotlightRoot_default, { classes: Spotlight_module_default });
|
|
906
|
+
//#endregion
|
|
907
|
+
//#region src/components/SpotlightSearch/index.ts
|
|
908
|
+
var SpotlightSearch = Object.assign(SpotlightSearch_default, { classes: Spotlight_module_default });
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region src/components/Spotlight/index.ts
|
|
911
|
+
var Spotlight = Object.assign(Spotlight_default, {
|
|
966
912
|
classes: Spotlight_module_default,
|
|
967
913
|
Search: SpotlightSearch,
|
|
968
914
|
ActionsList: SpotlightActionsList,
|