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