@mantine/spotlight 3.7.0-alpha.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 (76) hide show
  1. package/README.md +19 -0
  2. package/cjs/ActionsList/ActionsList.js +60 -0
  3. package/cjs/ActionsList/ActionsList.js.map +1 -0
  4. package/cjs/ActionsList/ActionsList.styles.js +24 -0
  5. package/cjs/ActionsList/ActionsList.styles.js.map +1 -0
  6. package/cjs/DefaultAction/DefaultAction.js +81 -0
  7. package/cjs/DefaultAction/DefaultAction.js.map +1 -0
  8. package/cjs/DefaultAction/DefaultAction.styles.js +27 -0
  9. package/cjs/DefaultAction/DefaultAction.styles.js.map +1 -0
  10. package/cjs/Spotlight/Spotlight.js +221 -0
  11. package/cjs/Spotlight/Spotlight.js.map +1 -0
  12. package/cjs/Spotlight/Spotlight.styles.js +59 -0
  13. package/cjs/Spotlight/Spotlight.styles.js.map +1 -0
  14. package/cjs/Spotlight/filter-actions/filter-actions.js +23 -0
  15. package/cjs/Spotlight/filter-actions/filter-actions.js.map +1 -0
  16. package/cjs/Spotlight.context.js +18 -0
  17. package/cjs/Spotlight.context.js.map +1 -0
  18. package/cjs/SpotlightProvider.js +110 -0
  19. package/cjs/SpotlightProvider.js.map +1 -0
  20. package/cjs/index.js +12 -0
  21. package/cjs/index.js.map +1 -0
  22. package/cjs/use-actions-state/use-actions-state.js +68 -0
  23. package/cjs/use-actions-state/use-actions-state.js.map +1 -0
  24. package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js +22 -0
  25. package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -0
  26. package/esm/ActionsList/ActionsList.js +52 -0
  27. package/esm/ActionsList/ActionsList.js.map +1 -0
  28. package/esm/ActionsList/ActionsList.styles.js +20 -0
  29. package/esm/ActionsList/ActionsList.styles.js.map +1 -0
  30. package/esm/DefaultAction/DefaultAction.js +73 -0
  31. package/esm/DefaultAction/DefaultAction.js.map +1 -0
  32. package/esm/DefaultAction/DefaultAction.styles.js +23 -0
  33. package/esm/DefaultAction/DefaultAction.styles.js.map +1 -0
  34. package/esm/Spotlight/Spotlight.js +213 -0
  35. package/esm/Spotlight/Spotlight.js.map +1 -0
  36. package/esm/Spotlight/Spotlight.styles.js +55 -0
  37. package/esm/Spotlight/Spotlight.styles.js.map +1 -0
  38. package/esm/Spotlight/filter-actions/filter-actions.js +19 -0
  39. package/esm/Spotlight/filter-actions/filter-actions.js.map +1 -0
  40. package/esm/Spotlight.context.js +13 -0
  41. package/esm/Spotlight.context.js.map +1 -0
  42. package/esm/SpotlightProvider.js +102 -0
  43. package/esm/SpotlightProvider.js.map +1 -0
  44. package/esm/index.js +3 -0
  45. package/esm/index.js.map +1 -0
  46. package/esm/use-actions-state/use-actions-state.js +64 -0
  47. package/esm/use-actions-state/use-actions-state.js.map +1 -0
  48. package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js +17 -0
  49. package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -0
  50. package/lib/ActionsList/ActionsList.d.ts +21 -0
  51. package/lib/ActionsList/ActionsList.d.ts.map +1 -0
  52. package/lib/ActionsList/ActionsList.styles.d.ts +7 -0
  53. package/lib/ActionsList/ActionsList.styles.d.ts.map +1 -0
  54. package/lib/DefaultAction/DefaultAction.d.ts +17 -0
  55. package/lib/DefaultAction/DefaultAction.d.ts.map +1 -0
  56. package/lib/DefaultAction/DefaultAction.styles.d.ts +7 -0
  57. package/lib/DefaultAction/DefaultAction.styles.d.ts.map +1 -0
  58. package/lib/Spotlight/Spotlight.d.ts +64 -0
  59. package/lib/Spotlight/Spotlight.d.ts.map +1 -0
  60. package/lib/Spotlight/Spotlight.styles.d.ts +12 -0
  61. package/lib/Spotlight/Spotlight.styles.d.ts.map +1 -0
  62. package/lib/Spotlight/filter-actions/filter-actions.d.ts +3 -0
  63. package/lib/Spotlight/filter-actions/filter-actions.d.ts.map +1 -0
  64. package/lib/Spotlight.context.d.ts +25 -0
  65. package/lib/Spotlight.context.d.ts.map +1 -0
  66. package/lib/SpotlightProvider.d.ts +24 -0
  67. package/lib/SpotlightProvider.d.ts.map +1 -0
  68. package/lib/index.d.ts +7 -0
  69. package/lib/index.d.ts.map +1 -0
  70. package/lib/types.d.ts +20 -0
  71. package/lib/types.d.ts.map +1 -0
  72. package/lib/use-actions-state/use-actions-state.d.ts +7 -0
  73. package/lib/use-actions-state/use-actions-state.d.ts.map +1 -0
  74. package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts +4 -0
  75. package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts.map +1 -0
  76. package/package.json +25 -0
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var hooks = require('@mantine/hooks');
7
+ var useActionsState = require('./use-actions-state/use-actions-state.js');
8
+ var useSpotlightShortcuts = require('./use-spotlight-shortcuts/use-spotlight-shortcuts.js');
9
+ var Spotlight = require('./Spotlight/Spotlight.js');
10
+ var Spotlight_context = require('./Spotlight.context.js');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
13
+
14
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
+
16
+ var __defProp = Object.defineProperty;
17
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
20
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21
+ var __spreadValues = (a, b) => {
22
+ for (var prop in b || (b = {}))
23
+ if (__hasOwnProp.call(b, prop))
24
+ __defNormalProp(a, prop, b[prop]);
25
+ if (__getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(b)) {
27
+ if (__propIsEnum.call(b, prop))
28
+ __defNormalProp(a, prop, b[prop]);
29
+ }
30
+ return a;
31
+ };
32
+ var __objRest = (source, exclude) => {
33
+ var target = {};
34
+ for (var prop in source)
35
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
36
+ target[prop] = source[prop];
37
+ if (source != null && __getOwnPropSymbols)
38
+ for (var prop of __getOwnPropSymbols(source)) {
39
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
40
+ target[prop] = source[prop];
41
+ }
42
+ return target;
43
+ };
44
+ function SpotlightProvider(_a) {
45
+ var _b = _a, {
46
+ actions: initialActions,
47
+ children,
48
+ shortcut = "mod + K",
49
+ onSpotlightClose,
50
+ onSpotlightOpen,
51
+ onQueryChange,
52
+ cleanQueryOnClose = true,
53
+ transitionDuration = 150
54
+ } = _b, others = __objRest(_b, [
55
+ "actions",
56
+ "children",
57
+ "shortcut",
58
+ "onSpotlightClose",
59
+ "onSpotlightOpen",
60
+ "onQueryChange",
61
+ "cleanQueryOnClose",
62
+ "transitionDuration"
63
+ ]);
64
+ const timeoutRef = React.useRef(-1);
65
+ const [query, setQuery] = React.useState("");
66
+ const [actions, { registerActions, removeActions, triggerAction }] = useActionsState.useActionsState(initialActions, query);
67
+ const handleQueryChange = (value) => {
68
+ setQuery(value);
69
+ onQueryChange == null ? void 0 : onQueryChange(value);
70
+ };
71
+ const [opened, { open, close, toggle }] = hooks.useDisclosure(false, {
72
+ onClose: () => {
73
+ onSpotlightClose == null ? void 0 : onSpotlightClose();
74
+ if (cleanQueryOnClose) {
75
+ timeoutRef.current = window.setTimeout(() => {
76
+ handleQueryChange("");
77
+ }, transitionDuration);
78
+ }
79
+ },
80
+ onOpen: () => {
81
+ onSpotlightOpen == null ? void 0 : onSpotlightOpen();
82
+ window.clearTimeout(timeoutRef.current);
83
+ }
84
+ });
85
+ useSpotlightShortcuts.useSpotlightShortcuts(shortcut, open);
86
+ return /* @__PURE__ */ React__default.createElement(Spotlight_context.SpotlightContext.Provider, {
87
+ value: {
88
+ openSpotlight: open,
89
+ closeSpotlight: close,
90
+ toggleSpotlight: toggle,
91
+ registerActions,
92
+ removeActions,
93
+ triggerAction,
94
+ opened,
95
+ actions,
96
+ query
97
+ }
98
+ }, /* @__PURE__ */ React__default.createElement(Spotlight.Spotlight, __spreadValues({
99
+ actions,
100
+ onClose: close,
101
+ opened,
102
+ query,
103
+ onQueryChange: handleQueryChange,
104
+ transitionDuration
105
+ }, others)), children);
106
+ }
107
+ SpotlightProvider.displayName = "@mantine/spotlight/SpotlightProvider";
108
+
109
+ exports.SpotlightProvider = SpotlightProvider;
110
+ //# sourceMappingURL=SpotlightProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpotlightProvider.js","sources":["../src/SpotlightProvider.tsx"],"sourcesContent":["import React, { useState, useRef } from 'react';\nimport { useDisclosure } from '@mantine/hooks';\nimport { useActionsState } from './use-actions-state/use-actions-state';\nimport { useSpotlightShortcuts } from './use-spotlight-shortcuts/use-spotlight-shortcuts';\nimport { Spotlight, InnerSpotlightProps } from './Spotlight/Spotlight';\nimport type { SpotlightAction } from './types';\nimport { SpotlightContext } from './Spotlight.context';\n\nexport interface SpotlightProviderProps extends InnerSpotlightProps {\n /** Actions list */\n actions: SpotlightAction[] | ((query: string) => SpotlightAction[]);\n\n /** Your application */\n children?: React.ReactNode;\n\n /** Called when spotlight opens */\n onSpotlightOpen?(): void;\n\n /** Called when spotlight closes */\n onSpotlightClose?(): void;\n\n /** Called when user enters text in search input */\n onQueryChange?(query: string): void;\n\n /** Keyboard shortcut or list of shortcuts to trigger spotlight */\n shortcut?: string | string[] | null;\n\n /** Should search be cleared when spotlight closes */\n cleanQueryOnClose?: boolean;\n}\n\nexport function SpotlightProvider({\n actions: initialActions,\n children,\n shortcut = 'mod + K',\n onSpotlightClose,\n onSpotlightOpen,\n onQueryChange,\n cleanQueryOnClose = true,\n transitionDuration = 150,\n ...others\n}: SpotlightProviderProps) {\n const timeoutRef = useRef<number>(-1);\n const [query, setQuery] = useState('');\n const [actions, { registerActions, removeActions, triggerAction }] = useActionsState(\n initialActions,\n query\n );\n\n const handleQueryChange = (value: string) => {\n setQuery(value);\n onQueryChange?.(value);\n };\n\n const [opened, { open, close, toggle }] = useDisclosure(false, {\n onClose: () => {\n onSpotlightClose?.();\n if (cleanQueryOnClose) {\n timeoutRef.current = window.setTimeout(() => {\n handleQueryChange('');\n }, transitionDuration);\n }\n },\n onOpen: () => {\n onSpotlightOpen?.();\n window.clearTimeout(timeoutRef.current);\n },\n });\n\n useSpotlightShortcuts(shortcut, open);\n\n return (\n <SpotlightContext.Provider\n value={{\n openSpotlight: open,\n closeSpotlight: close,\n toggleSpotlight: toggle,\n registerActions,\n removeActions,\n triggerAction,\n opened,\n actions,\n query,\n }}\n >\n <Spotlight\n actions={actions}\n onClose={close}\n opened={opened}\n query={query}\n onQueryChange={handleQueryChange}\n transitionDuration={transitionDuration}\n {...others}\n />\n {children}\n </SpotlightContext.Provider>\n );\n}\n\nSpotlightProvider.displayName = '@mantine/spotlight/SpotlightProvider';\n"],"names":["useRef","useState","useActionsState","useDisclosure","useSpotlightShortcuts","React","SpotlightContext","Spotlight"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,I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Module', { value: true });
4
+
5
+ var Spotlight_context = require('./Spotlight.context.js');
6
+ var SpotlightProvider = require('./SpotlightProvider.js');
7
+
8
+
9
+
10
+ exports.useSpotlight = Spotlight_context.useSpotlight;
11
+ exports.SpotlightProvider = SpotlightProvider.SpotlightProvider;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var hooks = require('@mantine/hooks');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __defProps = Object.defineProperties;
10
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ function prepareAction(action) {
28
+ return __spreadProps(__spreadValues({}, action), { id: action.id || hooks.randomId() });
29
+ }
30
+ function filterDuplicateActions(actions) {
31
+ const ids = [];
32
+ return actions.reduceRight((acc, action) => {
33
+ if (!ids.includes(action.id)) {
34
+ ids.push(action.id);
35
+ acc.push(action);
36
+ }
37
+ return acc;
38
+ }, []).reverse();
39
+ }
40
+ function prepareActions(initialActions) {
41
+ return filterDuplicateActions(initialActions.map((action) => prepareAction(action)));
42
+ }
43
+ function useActionsState(initialActions, query) {
44
+ const [actions, setActions] = React.useState(prepareActions(typeof initialActions === "function" ? initialActions(query) : initialActions));
45
+ React.useEffect(() => {
46
+ if (typeof initialActions === "function") {
47
+ setActions(prepareActions(initialActions(query)));
48
+ }
49
+ }, [query]);
50
+ const registerActions = (payload) => setActions((current) => prepareActions([...current, ...payload]));
51
+ const removeActions = (ids) => setActions((current) => current.filter((action) => !ids.includes(action.id)));
52
+ const triggerAction = (id) => {
53
+ var _a;
54
+ const action = actions.find((item) => item.id === id);
55
+ (_a = action == null ? void 0 : action.onTrigger) == null ? void 0 : _a.call(action, action);
56
+ };
57
+ return [
58
+ actions,
59
+ {
60
+ registerActions,
61
+ removeActions,
62
+ triggerAction
63
+ }
64
+ ];
65
+ }
66
+
67
+ exports.useActionsState = useActionsState;
68
+ //# sourceMappingURL=use-actions-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-actions-state.js","sources":["../../src/use-actions-state/use-actions-state.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { randomId } from '@mantine/hooks';\nimport type { SpotlightAction } from '../types';\n\nfunction prepareAction(action: SpotlightAction) {\n return { ...action, id: action.id || randomId() };\n}\n\nfunction filterDuplicateActions(actions: SpotlightAction[]) {\n const ids = [];\n\n return actions\n .reduceRight<SpotlightAction[]>((acc, action) => {\n if (!ids.includes(action.id)) {\n ids.push(action.id);\n acc.push(action);\n }\n\n return acc;\n }, [])\n .reverse();\n}\n\nfunction prepareActions(initialActions: SpotlightAction[]) {\n return filterDuplicateActions(initialActions.map((action) => prepareAction(action)));\n}\n\nexport function useActionsState(\n initialActions: SpotlightAction[] | ((query: string) => SpotlightAction[]),\n query: string\n) {\n const [actions, setActions] = useState(\n prepareActions(typeof initialActions === 'function' ? initialActions(query) : initialActions)\n );\n\n useEffect(() => {\n if (typeof initialActions === 'function') {\n setActions(prepareActions(initialActions(query)));\n }\n }, [query]);\n\n const registerActions = (payload: SpotlightAction[]) =>\n setActions((current) => prepareActions([...current, ...payload]));\n\n const removeActions = (ids: string[]) =>\n setActions((current) => current.filter((action) => !ids.includes(action.id)));\n\n const triggerAction = (id: string) => {\n const action = actions.find((item) => item.id === id);\n action?.onTrigger?.(action);\n };\n\n return [\n actions,\n {\n registerActions,\n removeActions,\n triggerAction,\n },\n ] as const;\n}\n"],"names":["randomId","useState","useEffect"],"mappings":";;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,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AG,CAAC;AACJ;;;;"}
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var hooks = require('@mantine/hooks');
6
+
7
+ function getHotkeysPayload(shortcuts, onToggle) {
8
+ if (shortcuts === null) {
9
+ return [];
10
+ }
11
+ if (Array.isArray(shortcuts)) {
12
+ return shortcuts.map((shortcut) => [shortcut, onToggle]);
13
+ }
14
+ return [[shortcuts, onToggle]];
15
+ }
16
+ function useSpotlightShortcuts(shortcuts, onToggle) {
17
+ hooks.useHotkeys(getHotkeysPayload(shortcuts, onToggle));
18
+ }
19
+
20
+ exports.getHotkeysPayload = getHotkeysPayload;
21
+ exports.useSpotlightShortcuts = useSpotlightShortcuts;
22
+ //# sourceMappingURL=use-spotlight-shortcuts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-spotlight-shortcuts.js","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"sourcesContent":["import { useHotkeys, HotkeyItem } from '@mantine/hooks';\n\nexport function getHotkeysPayload(\n shortcuts: string | string[],\n onToggle: () => void\n): HotkeyItem[] {\n if (shortcuts === null) {\n return [];\n }\n\n if (Array.isArray(shortcuts)) {\n return shortcuts.map((shortcut) => [shortcut, onToggle]);\n }\n\n return [[shortcuts, onToggle]];\n}\n\nexport function useSpotlightShortcuts(shortcuts: string | string[], onToggle: () => void) {\n useHotkeys(getHotkeysPayload(shortcuts, onToggle));\n}\n"],"names":["useHotkeys"],"mappings":";;;;;;AACO,SAAS,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE;AACvD,EAAE,IAAI,SAAS,KAAK,IAAI,EAAE;AAC1B,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AAChC,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7D,GAAG;AACH,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjC,CAAC;AACM,SAAS,qBAAqB,CAAC,SAAS,EAAE,QAAQ,EAAE;AAC3D,EAAEA,gBAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACrD;;;;;"}
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { getGroupedOptions, Text } from '@mantine/core';
3
+ import useStyles from './ActionsList.styles.js';
4
+
5
+ function ActionsList({
6
+ actions,
7
+ styles,
8
+ classNames,
9
+ actionComponent: Action,
10
+ hovered,
11
+ onActionHover,
12
+ onActionTrigger,
13
+ query,
14
+ nothingFoundMessage,
15
+ highlightQuery
16
+ }) {
17
+ const { classes } = useStyles(null, { classNames, styles, name: "Spotlight" });
18
+ const items = getGroupedOptions(actions).items.map((item) => {
19
+ if (item.type === "item") {
20
+ return /* @__PURE__ */ React.createElement(Action, {
21
+ query,
22
+ key: item.item.id,
23
+ action: item.item,
24
+ hovered: item.index === hovered,
25
+ onMouseEnter: () => onActionHover(item.index),
26
+ classNames,
27
+ styles,
28
+ onTrigger: () => onActionTrigger(item.item),
29
+ highlightQuery
30
+ });
31
+ }
32
+ return /* @__PURE__ */ React.createElement(Text, {
33
+ className: classes.actionsGroup,
34
+ color: "dimmed",
35
+ key: item.label
36
+ }, item.label);
37
+ });
38
+ const shouldRenderActions = items.length > 0 || !!nothingFoundMessage && query.trim().length > 0;
39
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldRenderActions && /* @__PURE__ */ React.createElement("div", {
40
+ className: classes.actions
41
+ }, items.length > 0 ? items : /* @__PURE__ */ React.createElement(Text, {
42
+ color: "dimmed",
43
+ className: classes.nothingFound,
44
+ align: "center",
45
+ size: "lg",
46
+ py: "md"
47
+ }, nothingFoundMessage)));
48
+ }
49
+ ActionsList.displayName = "@mantine/spotlight/ActionsList";
50
+
51
+ export { ActionsList };
52
+ //# sourceMappingURL=ActionsList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, ClassNames, Text, getGroupedOptions } from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';\nimport useStyles from './ActionsList.styles';\n\nexport type ActionsListStylesNames = ClassNames<typeof useStyles> | DefaultActionStylesNames;\n\nexport interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {\n actions: SpotlightAction[];\n actionComponent?: React.FC<DefaultActionProps>;\n hovered: number;\n query: string;\n nothingFoundMessage?: React.ReactNode;\n onActionHover(index: number): void;\n onActionTrigger(action: SpotlightAction): void;\n highlightQuery: boolean;\n}\n\nexport function ActionsList({\n actions,\n styles,\n classNames,\n actionComponent: Action,\n hovered,\n onActionHover,\n onActionTrigger,\n query,\n nothingFoundMessage,\n highlightQuery,\n}: ActionsListProps) {\n const { classes } = useStyles(null, { classNames, styles, name: 'Spotlight' });\n\n const items = getGroupedOptions(actions).items.map((item) => {\n if (item.type === 'item') {\n return (\n <Action\n query={query}\n key={item.item.id}\n action={item.item}\n hovered={item.index === hovered}\n onMouseEnter={() => onActionHover(item.index)}\n classNames={classNames}\n styles={styles}\n onTrigger={() => onActionTrigger(item.item)}\n highlightQuery={highlightQuery}\n />\n );\n }\n\n return (\n <Text className={classes.actionsGroup} color=\"dimmed\" key={item.label}>\n {item.label}\n </Text>\n );\n });\n\n const shouldRenderActions =\n items.length > 0 || (!!nothingFoundMessage && query.trim().length > 0);\n\n return (\n <>\n {shouldRenderActions && (\n <div className={classes.actions}>\n {items.length > 0 ? (\n items\n ) : (\n <Text color=\"dimmed\" className={classes.nothingFound} align=\"center\" size=\"lg\" py=\"md\">\n {nothingFoundMessage}\n </Text>\n )}\n </div>\n )}\n </>\n );\n}\n\nActionsList.displayName = '@mantine/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;AACnB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,mBAAmB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACnG,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,mBAAmB,oBAAoB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACrI,IAAI,SAAS,EAAE,OAAO,CAAC,OAAO;AAC9B,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,mBAAmB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE;AAC1E,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,SAAS,EAAE,OAAO,CAAC,YAAY;AACnC,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,IAAI,EAAE,IAAI;AACd,IAAI,EAAE,EAAE,IAAI;AACZ,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,gCAAgC;;;;"}
@@ -0,0 +1,20 @@
1
+ import { createStyles } from '@mantine/core';
2
+
3
+ var useStyles = createStyles((theme) => ({
4
+ nothingFound: {},
5
+ actions: {
6
+ padding: theme.spacing.xs / 2,
7
+ borderTop: `1px solid ${theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[2]}`
8
+ },
9
+ actionsGroup: {
10
+ textTransform: "uppercase",
11
+ fontSize: theme.spacing.xs,
12
+ fontWeight: 700,
13
+ padding: "10px 12px",
14
+ paddingBottom: 0,
15
+ paddingTop: 15
16
+ }
17
+ }));
18
+
19
+ export default useStyles;
20
+ //# sourceMappingURL=ActionsList.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionsList.styles.js","sources":["../../src/ActionsList/ActionsList.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\nexport default createStyles((theme) => ({\n nothingFound: {},\n\n actions: {\n padding: theme.spacing.xs / 2,\n borderTop: `1px solid ${\n theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2]\n }`,\n },\n\n actionsGroup: {\n textTransform: 'uppercase',\n fontSize: theme.spacing.xs,\n fontWeight: 700,\n padding: '10px 12px',\n paddingBottom: 0,\n paddingTop: 15,\n },\n}));\n"],"names":[],"mappings":";;AACA,gBAAe,YAAY,CAAC,CAAC,KAAK,MAAM;AACxC,EAAE,YAAY,EAAE,EAAE;AAClB,EAAE,OAAO,EAAE;AACX,IAAI,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;AACjC,IAAI,SAAS,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,aAAa,EAAE,WAAW;AAC9B,IAAI,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;AAC9B,IAAI,UAAU,EAAE,GAAG;AACnB,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,aAAa,EAAE,CAAC;AACpB,IAAI,UAAU,EAAE,EAAE;AAClB,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import { UnstyledButton, Group, Center, Highlight, Text } from '@mantine/core';
3
+ import useStyles from './DefaultAction.styles.js';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ function DefaultAction(_a) {
34
+ var _b = _a, {
35
+ action,
36
+ styles,
37
+ classNames,
38
+ hovered,
39
+ onTrigger,
40
+ highlightQuery,
41
+ query
42
+ } = _b, others = __objRest(_b, [
43
+ "action",
44
+ "styles",
45
+ "classNames",
46
+ "hovered",
47
+ "onTrigger",
48
+ "highlightQuery",
49
+ "query"
50
+ ]);
51
+ const { classes, cx } = useStyles(null, { styles, classNames, name: "Spotlight" });
52
+ return /* @__PURE__ */ React.createElement(UnstyledButton, __spreadValues({
53
+ className: cx(classes.action, { [classes.actionHovered]: hovered }),
54
+ tabIndex: -1,
55
+ onMouseDown: (event) => event.preventDefault(),
56
+ onClick: onTrigger
57
+ }, others), /* @__PURE__ */ React.createElement(Group, {
58
+ noWrap: true
59
+ }, action.icon && /* @__PURE__ */ React.createElement(Center, {
60
+ className: classes.actionIcon
61
+ }, action.icon), /* @__PURE__ */ React.createElement("div", {
62
+ className: classes.actionBody
63
+ }, /* @__PURE__ */ React.createElement(Highlight, {
64
+ highlight: highlightQuery ? query : null
65
+ }, action.title), action.description && /* @__PURE__ */ React.createElement(Text, {
66
+ color: "dimmed",
67
+ size: "xs"
68
+ }, action.description))));
69
+ }
70
+ DefaultAction.displayName = "@mantine/spotlight/DefaultAction";
71
+
72
+ export { DefaultAction };
73
+ //# sourceMappingURL=DefaultAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultAction.js","sources":["../../src/DefaultAction/DefaultAction.tsx"],"sourcesContent":["import React from 'react';\nimport {\n DefaultProps,\n ClassNames,\n Highlight,\n UnstyledButton,\n Group,\n Center,\n Text,\n} from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport useStyles from './DefaultAction.styles';\n\nexport type DefaultActionStylesNames = ClassNames<typeof useStyles>;\n\nexport interface DefaultActionProps\n extends DefaultProps<DefaultActionStylesNames>,\n React.ComponentPropsWithoutRef<'button'> {\n action: SpotlightAction;\n hovered: boolean;\n onTrigger(): void;\n highlightQuery: boolean;\n query: string;\n}\n\nexport function DefaultAction({\n action,\n styles,\n classNames,\n hovered,\n onTrigger,\n highlightQuery,\n query,\n ...others\n}: DefaultActionProps) {\n const { classes, cx } = useStyles(null, { styles, classNames, name: 'Spotlight' });\n\n return (\n <UnstyledButton\n className={cx(classes.action, { [classes.actionHovered]: hovered })}\n tabIndex={-1}\n onMouseDown={(event) => event.preventDefault()}\n onClick={onTrigger}\n {...others}\n >\n <Group noWrap>\n {action.icon && <Center className={classes.actionIcon}>{action.icon}</Center>}\n\n <div className={classes.actionBody}>\n <Highlight highlight={highlightQuery ? query : null}>{action.title}</Highlight>\n\n {action.description && (\n <Text color=\"dimmed\" size=\"xs\">\n {action.description}\n </Text>\n )}\n </div>\n </Group>\n </UnstyledButton>\n );\n}\n\nDefaultAction.displayName = '@mantine/spotlight/DefaultAction';\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD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ClD,IAAI,OAAO,EAAE,SAAS;AACtB,GAAG,EAAE,MAAM,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACzD,IAAI,MAAM,EAAE,IAAI;AAChB,GAAG,EAAE,MAAM,CAAC,IAAI,oBAAoB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE;AAChE,IAAI,SAAS,EAAE,OAAO,CAAC,UAAU;AACjC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AAC9D,IAAI,SAAS,EAAE,OAAO,CAAC,UAAU;AACjC,GAAG,kBAAkB,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;AACpD,IAAI,SAAS,EAAE,cAAc,GAAG,KAAK,GAAG,IAAI;AAC5C,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,oBAAoB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE;AACpF,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,IAAI,EAAE,IAAI;AACd,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,aAAa,CAAC,WAAW,GAAG,kCAAkC;;;;"}
@@ -0,0 +1,23 @@
1
+ import { createStyles } from '@mantine/core';
2
+
3
+ var useStyles = createStyles((theme) => ({
4
+ action: {
5
+ position: "relative",
6
+ display: "block",
7
+ width: "100%",
8
+ padding: "10px 12px",
9
+ borderRadius: theme.radius.sm
10
+ },
11
+ actionHovered: {
12
+ backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]
13
+ },
14
+ actionIcon: {
15
+ color: theme.colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6]
16
+ },
17
+ actionBody: {
18
+ flex: 1
19
+ }
20
+ }));
21
+
22
+ export default useStyles;
23
+ //# sourceMappingURL=DefaultAction.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\nexport default createStyles((theme) => ({\n action: {\n position: 'relative',\n display: 'block',\n width: '100%',\n padding: '10px 12px',\n borderRadius: theme.radius.sm,\n },\n\n actionHovered: {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[1],\n },\n\n actionIcon: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[2] : theme.colors.gray[6],\n },\n\n actionBody: {\n flex: 1,\n },\n}));\n"],"names":[],"mappings":";;AACA,gBAAe,YAAY,CAAC,CAAC,KAAK,MAAM;AACxC,EAAE,MAAM,EAAE;AACV,IAAI,QAAQ,EAAE,UAAU;AACxB,IAAI,OAAO,EAAE,OAAO;AACpB,IAAI,KAAK,EAAE,MAAM;AACjB,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE;AACjC,GAAG;AACH,EAAE,aAAa,EAAE;AACjB,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/F,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,KAAK,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACrF,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC;AACX,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}