@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.
- package/README.md +19 -0
- package/cjs/ActionsList/ActionsList.js +60 -0
- package/cjs/ActionsList/ActionsList.js.map +1 -0
- package/cjs/ActionsList/ActionsList.styles.js +24 -0
- package/cjs/ActionsList/ActionsList.styles.js.map +1 -0
- package/cjs/DefaultAction/DefaultAction.js +81 -0
- package/cjs/DefaultAction/DefaultAction.js.map +1 -0
- package/cjs/DefaultAction/DefaultAction.styles.js +27 -0
- package/cjs/DefaultAction/DefaultAction.styles.js.map +1 -0
- package/cjs/Spotlight/Spotlight.js +221 -0
- package/cjs/Spotlight/Spotlight.js.map +1 -0
- package/cjs/Spotlight/Spotlight.styles.js +59 -0
- package/cjs/Spotlight/Spotlight.styles.js.map +1 -0
- package/cjs/Spotlight/filter-actions/filter-actions.js +23 -0
- package/cjs/Spotlight/filter-actions/filter-actions.js.map +1 -0
- package/cjs/Spotlight.context.js +18 -0
- package/cjs/Spotlight.context.js.map +1 -0
- package/cjs/SpotlightProvider.js +110 -0
- package/cjs/SpotlightProvider.js.map +1 -0
- package/cjs/index.js +12 -0
- package/cjs/index.js.map +1 -0
- package/cjs/use-actions-state/use-actions-state.js +68 -0
- package/cjs/use-actions-state/use-actions-state.js.map +1 -0
- package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js +22 -0
- package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -0
- package/esm/ActionsList/ActionsList.js +52 -0
- package/esm/ActionsList/ActionsList.js.map +1 -0
- package/esm/ActionsList/ActionsList.styles.js +20 -0
- package/esm/ActionsList/ActionsList.styles.js.map +1 -0
- package/esm/DefaultAction/DefaultAction.js +73 -0
- package/esm/DefaultAction/DefaultAction.js.map +1 -0
- package/esm/DefaultAction/DefaultAction.styles.js +23 -0
- package/esm/DefaultAction/DefaultAction.styles.js.map +1 -0
- package/esm/Spotlight/Spotlight.js +213 -0
- package/esm/Spotlight/Spotlight.js.map +1 -0
- package/esm/Spotlight/Spotlight.styles.js +55 -0
- package/esm/Spotlight/Spotlight.styles.js.map +1 -0
- package/esm/Spotlight/filter-actions/filter-actions.js +19 -0
- package/esm/Spotlight/filter-actions/filter-actions.js.map +1 -0
- package/esm/Spotlight.context.js +13 -0
- package/esm/Spotlight.context.js.map +1 -0
- package/esm/SpotlightProvider.js +102 -0
- package/esm/SpotlightProvider.js.map +1 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/use-actions-state/use-actions-state.js +64 -0
- package/esm/use-actions-state/use-actions-state.js.map +1 -0
- package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js +17 -0
- package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -0
- package/lib/ActionsList/ActionsList.d.ts +21 -0
- package/lib/ActionsList/ActionsList.d.ts.map +1 -0
- package/lib/ActionsList/ActionsList.styles.d.ts +7 -0
- package/lib/ActionsList/ActionsList.styles.d.ts.map +1 -0
- package/lib/DefaultAction/DefaultAction.d.ts +17 -0
- package/lib/DefaultAction/DefaultAction.d.ts.map +1 -0
- package/lib/DefaultAction/DefaultAction.styles.d.ts +7 -0
- package/lib/DefaultAction/DefaultAction.styles.d.ts.map +1 -0
- package/lib/Spotlight/Spotlight.d.ts +64 -0
- package/lib/Spotlight/Spotlight.d.ts.map +1 -0
- package/lib/Spotlight/Spotlight.styles.d.ts +12 -0
- package/lib/Spotlight/Spotlight.styles.d.ts.map +1 -0
- package/lib/Spotlight/filter-actions/filter-actions.d.ts +3 -0
- package/lib/Spotlight/filter-actions/filter-actions.d.ts.map +1 -0
- package/lib/Spotlight.context.d.ts +25 -0
- package/lib/Spotlight.context.d.ts.map +1 -0
- package/lib/SpotlightProvider.d.ts +24 -0
- package/lib/SpotlightProvider.d.ts.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/types.d.ts +20 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/use-actions-state/use-actions-state.d.ts +7 -0
- package/lib/use-actions-state/use-actions-state.d.ts.map +1 -0
- package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts +4 -0
- package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts.map +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { getDefaultZIndex, OptionalPortal, GroupedTransition, Paper, TextInput, Overlay } from '@mantine/core';
|
|
3
|
+
import { useScrollLock, useFocusTrap, useFocusReturn, useDidUpdate } from '@mantine/hooks';
|
|
4
|
+
import { DefaultAction } from '../DefaultAction/DefaultAction.js';
|
|
5
|
+
import { ActionsList } from '../ActionsList/ActionsList.js';
|
|
6
|
+
import { filterActions } from './filter-actions/filter-actions.js';
|
|
7
|
+
import useStyles from './Spotlight.styles.js';
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
function Spotlight(_a) {
|
|
38
|
+
var _b = _a, {
|
|
39
|
+
query,
|
|
40
|
+
onQueryChange,
|
|
41
|
+
actions,
|
|
42
|
+
onClose,
|
|
43
|
+
opened,
|
|
44
|
+
withinPortal,
|
|
45
|
+
transition = "pop",
|
|
46
|
+
transitionDuration,
|
|
47
|
+
classNames,
|
|
48
|
+
styles,
|
|
49
|
+
overlayColor = "#000",
|
|
50
|
+
overlayOpacity = 0.25,
|
|
51
|
+
overlayBlur = 3,
|
|
52
|
+
shadow = "md",
|
|
53
|
+
centered = false,
|
|
54
|
+
closeOnActionTrigger = true,
|
|
55
|
+
highlightQuery = false,
|
|
56
|
+
maxWidth = 600,
|
|
57
|
+
topOffset = 120,
|
|
58
|
+
className,
|
|
59
|
+
searchPlaceholder,
|
|
60
|
+
searchIcon,
|
|
61
|
+
filter = filterActions,
|
|
62
|
+
nothingFoundMessage,
|
|
63
|
+
limit = 10,
|
|
64
|
+
actionComponent = DefaultAction,
|
|
65
|
+
actionsWrapperComponent: ActionsWrapper = "div",
|
|
66
|
+
zIndex = getDefaultZIndex("modal")
|
|
67
|
+
} = _b, others = __objRest(_b, [
|
|
68
|
+
"query",
|
|
69
|
+
"onQueryChange",
|
|
70
|
+
"actions",
|
|
71
|
+
"onClose",
|
|
72
|
+
"opened",
|
|
73
|
+
"withinPortal",
|
|
74
|
+
"transition",
|
|
75
|
+
"transitionDuration",
|
|
76
|
+
"classNames",
|
|
77
|
+
"styles",
|
|
78
|
+
"overlayColor",
|
|
79
|
+
"overlayOpacity",
|
|
80
|
+
"overlayBlur",
|
|
81
|
+
"shadow",
|
|
82
|
+
"centered",
|
|
83
|
+
"closeOnActionTrigger",
|
|
84
|
+
"highlightQuery",
|
|
85
|
+
"maxWidth",
|
|
86
|
+
"topOffset",
|
|
87
|
+
"className",
|
|
88
|
+
"searchPlaceholder",
|
|
89
|
+
"searchIcon",
|
|
90
|
+
"filter",
|
|
91
|
+
"nothingFoundMessage",
|
|
92
|
+
"limit",
|
|
93
|
+
"actionComponent",
|
|
94
|
+
"actionsWrapperComponent",
|
|
95
|
+
"zIndex"
|
|
96
|
+
]);
|
|
97
|
+
const [hovered, setHovered] = useState(-1);
|
|
98
|
+
const { classes, cx } = useStyles({ centered, maxWidth, topOffset }, { classNames, styles, name: "Spotlight" });
|
|
99
|
+
const [, lockScroll] = useScrollLock();
|
|
100
|
+
const focusTrapRef = useFocusTrap(opened);
|
|
101
|
+
const resetHovered = () => setHovered(-1);
|
|
102
|
+
const handleClose = () => {
|
|
103
|
+
resetHovered();
|
|
104
|
+
onClose();
|
|
105
|
+
};
|
|
106
|
+
useFocusReturn({ transitionDuration: 0, opened });
|
|
107
|
+
const filteredActions = filter(query, actions).slice(0, limit);
|
|
108
|
+
useDidUpdate(() => {
|
|
109
|
+
if (filteredActions.length - 1 < hovered) {
|
|
110
|
+
setHovered(filteredActions.length - 1);
|
|
111
|
+
}
|
|
112
|
+
}, [filteredActions.length]);
|
|
113
|
+
const handleInputKeyDown = (event) => {
|
|
114
|
+
var _a2;
|
|
115
|
+
switch (event.code) {
|
|
116
|
+
case "ArrowDown": {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
setHovered((current) => current < filteredActions.length - 1 ? current + 1 : 0);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "ArrowUp": {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
setHovered((current) => current > 0 ? current - 1 : filteredActions.length - 1);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case "Enter": {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
const action = filteredActions[hovered];
|
|
129
|
+
(_a2 = action == null ? void 0 : action.onTrigger) == null ? void 0 : _a2.call(action, action);
|
|
130
|
+
if (closeOnActionTrigger && (action == null ? void 0 : action.onTrigger)) {
|
|
131
|
+
handleClose();
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "Escape": {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
handleClose();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const handleInputChange = (event) => {
|
|
142
|
+
onQueryChange(event.currentTarget.value);
|
|
143
|
+
if (hovered === -1) {
|
|
144
|
+
setHovered(0);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return /* @__PURE__ */ React.createElement(OptionalPortal, {
|
|
148
|
+
withinPortal,
|
|
149
|
+
zIndex
|
|
150
|
+
}, /* @__PURE__ */ React.createElement(GroupedTransition, {
|
|
151
|
+
onExited: () => lockScroll(false),
|
|
152
|
+
onEntered: () => lockScroll(true),
|
|
153
|
+
mounted: opened,
|
|
154
|
+
transitions: {
|
|
155
|
+
spotlight: {
|
|
156
|
+
duration: transitionDuration,
|
|
157
|
+
transition,
|
|
158
|
+
timingFunction: "ease"
|
|
159
|
+
},
|
|
160
|
+
overlay: {
|
|
161
|
+
duration: transitionDuration / 2,
|
|
162
|
+
transition: "fade",
|
|
163
|
+
timingFunction: "ease"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, (transitionStyles) => /* @__PURE__ */ React.createElement("div", __spreadValues({
|
|
167
|
+
className: cx(classes.root, className)
|
|
168
|
+
}, others), /* @__PURE__ */ React.createElement("div", {
|
|
169
|
+
className: classes.inner,
|
|
170
|
+
ref: focusTrapRef
|
|
171
|
+
}, /* @__PURE__ */ React.createElement(Paper, {
|
|
172
|
+
style: transitionStyles.spotlight,
|
|
173
|
+
className: classes.spotlight,
|
|
174
|
+
shadow,
|
|
175
|
+
onMouseLeave: resetHovered
|
|
176
|
+
}, /* @__PURE__ */ React.createElement(TextInput, {
|
|
177
|
+
value: query,
|
|
178
|
+
onChange: handleInputChange,
|
|
179
|
+
onKeyDown: handleInputKeyDown,
|
|
180
|
+
classNames: { input: classes.searchInput },
|
|
181
|
+
size: "lg",
|
|
182
|
+
placeholder: searchPlaceholder,
|
|
183
|
+
icon: searchIcon,
|
|
184
|
+
onMouseEnter: resetHovered
|
|
185
|
+
}), /* @__PURE__ */ React.createElement(ActionsWrapper, null, /* @__PURE__ */ React.createElement(ActionsList, {
|
|
186
|
+
highlightQuery,
|
|
187
|
+
actions: filteredActions,
|
|
188
|
+
actionComponent,
|
|
189
|
+
hovered,
|
|
190
|
+
query,
|
|
191
|
+
nothingFoundMessage,
|
|
192
|
+
onActionHover: setHovered,
|
|
193
|
+
onActionTrigger: (action) => {
|
|
194
|
+
action.onTrigger(action);
|
|
195
|
+
closeOnActionTrigger && handleClose();
|
|
196
|
+
},
|
|
197
|
+
styles,
|
|
198
|
+
classNames
|
|
199
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
200
|
+
style: transitionStyles.overlay
|
|
201
|
+
}, /* @__PURE__ */ React.createElement(Overlay, {
|
|
202
|
+
className: classes.overlay,
|
|
203
|
+
zIndex: 1,
|
|
204
|
+
onMouseDown: handleClose,
|
|
205
|
+
color: overlayColor,
|
|
206
|
+
opacity: overlayOpacity,
|
|
207
|
+
blur: overlayBlur
|
|
208
|
+
}))))));
|
|
209
|
+
}
|
|
210
|
+
Spotlight.displayName = "@mantine/spotlight/Spotlight";
|
|
211
|
+
|
|
212
|
+
export { Spotlight };
|
|
213
|
+
//# sourceMappingURL=Spotlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spotlight.js","sources":["../../src/Spotlight/Spotlight.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n OptionalPortal,\n GroupedTransition,\n MantineTransition,\n Overlay,\n Paper,\n DefaultProps,\n ClassNames,\n MantineShadow,\n TextInput,\n getDefaultZIndex,\n} from '@mantine/core';\nimport { useScrollLock, useFocusTrap, useDidUpdate, useFocusReturn } from '@mantine/hooks';\nimport { DefaultAction, DefaultActionProps } from '../DefaultAction/DefaultAction';\nimport { ActionsList, ActionsListStylesNames } from '../ActionsList/ActionsList';\nimport type { SpotlightAction } from '../types';\nimport { filterActions } from './filter-actions/filter-actions';\nimport useStyles from './Spotlight.styles';\n\nexport type SpotlightStylesNames = ClassNames<typeof useStyles> | ActionsListStylesNames;\n\nexport interface InnerSpotlightProps\n extends DefaultProps<SpotlightStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Should spotlight be rendered within Portal */\n withinPortal?: boolean;\n\n /** Premade transition or transition object */\n transition?: MantineTransition;\n\n /** Transition duration in ms, set to 0 to disable all transitions */\n transitionDuration?: number;\n\n /** Backdrop overlay color, e.g. #000 */\n overlayColor?: string;\n\n /** Backdrop overlay opacity (0-1), e.g. 0.65 */\n overlayOpacity?: number;\n\n /** Backdrop overlay blur in px */\n overlayBlur?: number;\n\n /** Value from theme.shadows or any valid css box-shadow value */\n shadow?: MantineShadow;\n\n /** Should spotlight be rendered in the center of the screen */\n centered?: boolean;\n\n /** Max spotlight width */\n maxWidth?: number;\n\n /** Top offset when spotlight is not centered */\n topOffset?: number;\n\n /** Search input placeholder */\n searchPlaceholder?: string;\n\n /** Search input icon */\n searchIcon?: React.ReactNode;\n\n /** Function used to determine how actions will be filtered based on user input */\n filter?(query: string, actions: SpotlightAction[]): SpotlightAction[];\n\n /** Message displayed when actions were not found */\n nothingFoundMessage?: React.ReactNode;\n\n /** Number of actions displayed at a time */\n limit?: number;\n\n /** Should spotlight be closed when action is triggered */\n closeOnActionTrigger?: boolean;\n\n /** Component that is used to render actions */\n actionComponent?: React.FC<DefaultActionProps>;\n\n /** Component that is used to wrap actions list */\n actionsWrapperComponent?: React.FC<{ children: React.ReactNode }> | string;\n\n /** Spotlight z-index */\n zIndex?: number;\n\n /** Should user query be highlighted in actions title */\n highlightQuery?: boolean;\n}\n\ninterface SpotlightProps extends InnerSpotlightProps {\n actions: SpotlightAction[];\n onClose(): void;\n opened: boolean;\n query: string;\n onQueryChange(query: string): void;\n}\n\nexport function Spotlight({\n query,\n onQueryChange,\n actions,\n onClose,\n opened,\n withinPortal,\n transition = 'pop',\n transitionDuration,\n classNames,\n styles,\n overlayColor = '#000',\n overlayOpacity = 0.25,\n overlayBlur = 3,\n shadow = 'md',\n centered = false,\n closeOnActionTrigger = true,\n highlightQuery = false,\n maxWidth = 600,\n topOffset = 120,\n className,\n searchPlaceholder,\n searchIcon,\n filter = filterActions,\n nothingFoundMessage,\n limit = 10,\n actionComponent = DefaultAction,\n actionsWrapperComponent: ActionsWrapper = 'div',\n zIndex = getDefaultZIndex('modal'),\n ...others\n}: SpotlightProps) {\n const [hovered, setHovered] = useState(-1);\n const { classes, cx } = useStyles(\n { centered, maxWidth, topOffset },\n { classNames, styles, name: 'Spotlight' }\n );\n\n const [, lockScroll] = useScrollLock();\n const focusTrapRef = useFocusTrap(opened);\n\n const resetHovered = () => setHovered(-1);\n const handleClose = () => {\n resetHovered();\n onClose();\n };\n\n useFocusReturn({ transitionDuration: 0, opened });\n\n const filteredActions = filter(query, actions).slice(0, limit);\n\n useDidUpdate(() => {\n if (filteredActions.length - 1 < hovered) {\n setHovered(filteredActions.length - 1);\n }\n }, [filteredActions.length]);\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n switch (event.code) {\n case 'ArrowDown': {\n event.preventDefault();\n setHovered((current) => (current < filteredActions.length - 1 ? current + 1 : 0));\n break;\n }\n\n case 'ArrowUp': {\n event.preventDefault();\n setHovered((current) => (current > 0 ? current - 1 : filteredActions.length - 1));\n break;\n }\n\n case 'Enter': {\n event.preventDefault();\n const action = filteredActions[hovered];\n action?.onTrigger?.(action);\n if (closeOnActionTrigger && action?.onTrigger) {\n handleClose();\n }\n break;\n }\n\n case 'Escape': {\n event.preventDefault();\n handleClose();\n }\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onQueryChange(event.currentTarget.value);\n if (hovered === -1) {\n setHovered(0);\n }\n };\n\n return (\n <OptionalPortal withinPortal={withinPortal} zIndex={zIndex}>\n <GroupedTransition\n onExited={() => lockScroll(false)}\n onEntered={() => lockScroll(true)}\n mounted={opened}\n transitions={{\n spotlight: {\n duration: transitionDuration,\n transition,\n timingFunction: 'ease',\n },\n overlay: {\n duration: transitionDuration / 2,\n transition: 'fade',\n timingFunction: 'ease',\n },\n }}\n >\n {(transitionStyles) => (\n <div className={cx(classes.root, className)} {...others}>\n <div className={classes.inner} ref={focusTrapRef}>\n <Paper\n style={transitionStyles.spotlight}\n className={classes.spotlight}\n shadow={shadow}\n onMouseLeave={resetHovered}\n >\n <TextInput\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n classNames={{ input: classes.searchInput }}\n size=\"lg\"\n placeholder={searchPlaceholder}\n icon={searchIcon}\n onMouseEnter={resetHovered}\n />\n <ActionsWrapper>\n <ActionsList\n highlightQuery={highlightQuery}\n actions={filteredActions}\n actionComponent={actionComponent}\n hovered={hovered}\n query={query}\n nothingFoundMessage={nothingFoundMessage}\n onActionHover={setHovered}\n onActionTrigger={(action) => {\n action.onTrigger(action);\n closeOnActionTrigger && handleClose();\n }}\n styles={styles}\n classNames={classNames}\n />\n </ActionsWrapper>\n </Paper>\n\n <div style={transitionStyles.overlay}>\n <Overlay\n className={classes.overlay}\n zIndex={1}\n onMouseDown={handleClose}\n color={overlayColor}\n opacity={overlayOpacity}\n blur={overlayBlur}\n />\n </div>\n </div>\n </div>\n )}\n </GroupedTransition>\n </OptionalPortal>\n );\n}\n\nSpotlight.displayName = '@mantine/spotlight/Spotlight';\n"],"names":[],"mappings":";;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM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AM,CAAC,CAAC;AAC/B,MAAM,oBAAoB,IAAI,WAAW,EAAE,CAAC;AAC5C,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,GAAG,CAAC,CAAC,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACnD,IAAI,KAAK,EAAE,gBAAgB,CAAC,OAAO;AACnC,GAAG,kBAAkB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE;AAClD,IAAI,SAAS,EAAE,OAAO,CAAC,OAAO;AAC9B,IAAI,MAAM,EAAE,CAAC;AACb,IAAI,WAAW,EAAE,WAAW;AAC5B,IAAI,KAAK,EAAE,YAAY;AACvB,IAAI,OAAO,EAAE,cAAc;AAC3B,IAAI,IAAI,EAAE,WAAW;AACrB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACV,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createStyles } from '@mantine/core';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var useStyles = createStyles((theme, { centered, maxWidth, topOffset }) => ({
|
|
23
|
+
root: __spreadProps(__spreadValues({}, theme.fn.cover()), {
|
|
24
|
+
position: "fixed"
|
|
25
|
+
}),
|
|
26
|
+
spotlight: {
|
|
27
|
+
position: "relative",
|
|
28
|
+
zIndex: 2,
|
|
29
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.white,
|
|
30
|
+
borderRadius: theme.radius.sm,
|
|
31
|
+
width: "100%",
|
|
32
|
+
maxWidth,
|
|
33
|
+
overflow: "hidden"
|
|
34
|
+
},
|
|
35
|
+
overlay: __spreadProps(__spreadValues({}, theme.fn.cover()), {
|
|
36
|
+
position: "fixed"
|
|
37
|
+
}),
|
|
38
|
+
inner: {
|
|
39
|
+
height: "100vh",
|
|
40
|
+
display: "flex",
|
|
41
|
+
flexDirection: "column",
|
|
42
|
+
paddingTop: centered ? theme.spacing.md : topOffset,
|
|
43
|
+
justifyContent: centered ? "center" : "flex-start",
|
|
44
|
+
alignItems: "center"
|
|
45
|
+
},
|
|
46
|
+
searchInput: {
|
|
47
|
+
border: 0,
|
|
48
|
+
borderBottomRightRadius: 0,
|
|
49
|
+
borderBottomLeftRadius: 0,
|
|
50
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.white
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
export default useStyles;
|
|
55
|
+
//# sourceMappingURL=Spotlight.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spotlight.styles.js","sources":["../../src/Spotlight/Spotlight.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\nexport interface SpotlightStylesParams {\n centered: boolean;\n maxWidth: number;\n topOffset: number;\n}\n\nexport default createStyles((theme, { centered, maxWidth, topOffset }: SpotlightStylesParams) => ({\n root: {\n ...theme.fn.cover(),\n position: 'fixed',\n },\n\n spotlight: {\n position: 'relative',\n zIndex: 2,\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.white,\n borderRadius: theme.radius.sm,\n width: '100%',\n maxWidth,\n overflow: 'hidden',\n },\n\n overlay: {\n ...theme.fn.cover(),\n position: 'fixed',\n },\n\n inner: {\n height: '100vh',\n display: 'flex',\n flexDirection: 'column',\n paddingTop: centered ? theme.spacing.md : topOffset,\n justifyContent: centered ? 'center' : 'flex-start',\n alignItems: 'center',\n },\n\n searchInput: {\n border: 0,\n borderBottomRightRadius: 0,\n borderBottomLeftRadius: 0,\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.white,\n },\n}));\n"],"names":[],"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,IAA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B,GAAG;AACH,EAAE,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE;AAC/D,IAAI,QAAQ,EAAE,OAAO;AACrB,GAAG,CAAC;AACJ,EAAE,KAAK,EAAE;AACT,IAAI,MAAM,EAAE,OAAO;AACnB,IAAI,OAAO,EAAE,MAAM;AACnB,IAAI,aAAa,EAAE,QAAQ;AAC3B,IAAI,UAAU,EAAE,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS;AACvD,IAAI,cAAc,EAAE,QAAQ,GAAG,QAAQ,GAAG,YAAY;AACtD,IAAI,UAAU,EAAE,QAAQ;AACxB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,MAAM,EAAE,CAAC;AACb,IAAI,uBAAuB,EAAE,CAAC;AAC9B,IAAI,sBAAsB,EAAE,CAAC;AAC7B,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK;AACtF,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function getKeywords(keywords) {
|
|
2
|
+
if (Array.isArray(keywords)) {
|
|
3
|
+
return keywords.map((keyword) => keyword.trim()).join(",").toLowerCase().trim();
|
|
4
|
+
}
|
|
5
|
+
if (typeof keywords === "string") {
|
|
6
|
+
return keywords.toLowerCase().trim();
|
|
7
|
+
}
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
function filterActions(_query, actions) {
|
|
11
|
+
const query = _query.trim().toLowerCase();
|
|
12
|
+
return actions.filter((action) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return ((_a = action.title) == null ? void 0 : _a.toLowerCase().includes(query)) || ((_b = action.description) == null ? void 0 : _b.toLowerCase().includes(query)) || getKeywords(action.keywords).includes(query);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { filterActions };
|
|
19
|
+
//# sourceMappingURL=filter-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-actions.js","sources":["../../../src/Spotlight/filter-actions/filter-actions.ts"],"sourcesContent":["import type { SpotlightAction } from '../../types';\n\nfunction getKeywords(keywords: string | string[]) {\n if (Array.isArray(keywords)) {\n return keywords\n .map((keyword) => keyword.trim())\n .join(',')\n .toLowerCase()\n .trim();\n }\n\n if (typeof keywords === 'string') {\n return keywords.toLowerCase().trim();\n }\n\n return '';\n}\n\nexport function filterActions(_query: string, actions: SpotlightAction[]) {\n const query = _query.trim().toLowerCase();\n return actions.filter(\n (action) =>\n action.title?.toLowerCase().includes(query) ||\n action.description?.toLowerCase().includes(query) ||\n getKeywords(action.keywords).includes(query)\n );\n}\n"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,QAAQ,EAAE;AAC/B,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC/B,IAAI,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AACpF,GAAG;AACH,EAAE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AACpC,IAAI,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AACzC,GAAG;AACH,EAAE,OAAO,EAAE,CAAC;AACZ,CAAC;AACM,SAAS,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/C,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC5C,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK;AACpC,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,WAAW,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxN,GAAG,CAAC,CAAC;AACL;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const SpotlightContext = createContext(null);
|
|
4
|
+
function useSpotlight() {
|
|
5
|
+
const ctx = useContext(SpotlightContext);
|
|
6
|
+
if (!ctx) {
|
|
7
|
+
throw new Error("[@mantine/spotlight] SpotlightProvider was not found in tree");
|
|
8
|
+
}
|
|
9
|
+
return ctx;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { SpotlightContext, useSpotlight };
|
|
13
|
+
//# sourceMappingURL=Spotlight.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spotlight.context.js","sources":["../src/Spotlight.context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { SpotlightAction } from './types';\n\nexport interface SpotlightContextProps {\n /** Opens spotlight */\n openSpotlight(): void;\n\n /** Closes spotlight */\n closeSpotlight(): void;\n\n /** Toggles spotlight opened state */\n toggleSpotlight(): void;\n\n /** Triggers action with given id */\n triggerAction(actionId: string): void;\n\n /** Registers additional actions */\n registerActions(action: SpotlightAction[]): void;\n\n /** Removes actions with given ids */\n removeActions(actionIds: string[]): void;\n\n /** Current opened state */\n opened: boolean;\n\n /** List of registered actions */\n actions: SpotlightAction[];\n\n /** Search query */\n query: string;\n}\n\nexport const SpotlightContext = createContext<SpotlightContextProps>(null);\n\nexport function useSpotlight() {\n const ctx = useContext(SpotlightContext);\n\n if (!ctx) {\n throw new Error('[@mantine/spotlight] SpotlightProvider was not found in tree');\n }\n\n return ctx;\n}\n"],"names":[],"mappings":";;AACY,MAAC,gBAAgB,GAAG,aAAa,CAAC,IAAI,EAAE;AAC7C,SAAS,YAAY,GAAG;AAC/B,EAAE,MAAM,GAAG,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAC3C,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ,IAAI,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;AACpF,GAAG;AACH,EAAE,OAAO,GAAG,CAAC;AACb;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { useDisclosure } from '@mantine/hooks';
|
|
3
|
+
import { useActionsState } from './use-actions-state/use-actions-state.js';
|
|
4
|
+
import { useSpotlightShortcuts } from './use-spotlight-shortcuts/use-spotlight-shortcuts.js';
|
|
5
|
+
import { Spotlight } from './Spotlight/Spotlight.js';
|
|
6
|
+
import { SpotlightContext } from './Spotlight.context.js';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
function SpotlightProvider(_a) {
|
|
37
|
+
var _b = _a, {
|
|
38
|
+
actions: initialActions,
|
|
39
|
+
children,
|
|
40
|
+
shortcut = "mod + K",
|
|
41
|
+
onSpotlightClose,
|
|
42
|
+
onSpotlightOpen,
|
|
43
|
+
onQueryChange,
|
|
44
|
+
cleanQueryOnClose = true,
|
|
45
|
+
transitionDuration = 150
|
|
46
|
+
} = _b, others = __objRest(_b, [
|
|
47
|
+
"actions",
|
|
48
|
+
"children",
|
|
49
|
+
"shortcut",
|
|
50
|
+
"onSpotlightClose",
|
|
51
|
+
"onSpotlightOpen",
|
|
52
|
+
"onQueryChange",
|
|
53
|
+
"cleanQueryOnClose",
|
|
54
|
+
"transitionDuration"
|
|
55
|
+
]);
|
|
56
|
+
const timeoutRef = useRef(-1);
|
|
57
|
+
const [query, setQuery] = useState("");
|
|
58
|
+
const [actions, { registerActions, removeActions, triggerAction }] = useActionsState(initialActions, query);
|
|
59
|
+
const handleQueryChange = (value) => {
|
|
60
|
+
setQuery(value);
|
|
61
|
+
onQueryChange == null ? void 0 : onQueryChange(value);
|
|
62
|
+
};
|
|
63
|
+
const [opened, { open, close, toggle }] = useDisclosure(false, {
|
|
64
|
+
onClose: () => {
|
|
65
|
+
onSpotlightClose == null ? void 0 : onSpotlightClose();
|
|
66
|
+
if (cleanQueryOnClose) {
|
|
67
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
68
|
+
handleQueryChange("");
|
|
69
|
+
}, transitionDuration);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
onOpen: () => {
|
|
73
|
+
onSpotlightOpen == null ? void 0 : onSpotlightOpen();
|
|
74
|
+
window.clearTimeout(timeoutRef.current);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
useSpotlightShortcuts(shortcut, open);
|
|
78
|
+
return /* @__PURE__ */ React.createElement(SpotlightContext.Provider, {
|
|
79
|
+
value: {
|
|
80
|
+
openSpotlight: open,
|
|
81
|
+
closeSpotlight: close,
|
|
82
|
+
toggleSpotlight: toggle,
|
|
83
|
+
registerActions,
|
|
84
|
+
removeActions,
|
|
85
|
+
triggerAction,
|
|
86
|
+
opened,
|
|
87
|
+
actions,
|
|
88
|
+
query
|
|
89
|
+
}
|
|
90
|
+
}, /* @__PURE__ */ React.createElement(Spotlight, __spreadValues({
|
|
91
|
+
actions,
|
|
92
|
+
onClose: close,
|
|
93
|
+
opened,
|
|
94
|
+
query,
|
|
95
|
+
onQueryChange: handleQueryChange,
|
|
96
|
+
transitionDuration
|
|
97
|
+
}, others)), children);
|
|
98
|
+
}
|
|
99
|
+
SpotlightProvider.displayName = "@mantine/spotlight/SpotlightProvider";
|
|
100
|
+
|
|
101
|
+
export { SpotlightProvider };
|
|
102
|
+
//# 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/Spot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MAAM;AAC7B,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,KAAK;AACX,KAAK;AACL,GAAG,kBAAkB,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC;AACnE,IAAI,OAAO;AACX,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,MAAM;AACV,IAAI,KAAK;AACT,IAAI,aAAa,EAAE,iBAAiB;AACpC,IAAI,kBAAkB;AACtB,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AACzB,CAAC;AACD,iBAAiB,CAAC,WAAW,GAAG,sCAAsC;;;;"}
|
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { randomId } from '@mantine/hooks';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
function prepareAction(action) {
|
|
24
|
+
return __spreadProps(__spreadValues({}, action), { id: action.id || randomId() });
|
|
25
|
+
}
|
|
26
|
+
function filterDuplicateActions(actions) {
|
|
27
|
+
const ids = [];
|
|
28
|
+
return actions.reduceRight((acc, action) => {
|
|
29
|
+
if (!ids.includes(action.id)) {
|
|
30
|
+
ids.push(action.id);
|
|
31
|
+
acc.push(action);
|
|
32
|
+
}
|
|
33
|
+
return acc;
|
|
34
|
+
}, []).reverse();
|
|
35
|
+
}
|
|
36
|
+
function prepareActions(initialActions) {
|
|
37
|
+
return filterDuplicateActions(initialActions.map((action) => prepareAction(action)));
|
|
38
|
+
}
|
|
39
|
+
function useActionsState(initialActions, query) {
|
|
40
|
+
const [actions, setActions] = useState(prepareActions(typeof initialActions === "function" ? initialActions(query) : initialActions));
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (typeof initialActions === "function") {
|
|
43
|
+
setActions(prepareActions(initialActions(query)));
|
|
44
|
+
}
|
|
45
|
+
}, [query]);
|
|
46
|
+
const registerActions = (payload) => setActions((current) => prepareActions([...current, ...payload]));
|
|
47
|
+
const removeActions = (ids) => setActions((current) => current.filter((action) => !ids.includes(action.id)));
|
|
48
|
+
const triggerAction = (id) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const action = actions.find((item) => item.id === id);
|
|
51
|
+
(_a = action == null ? void 0 : action.onTrigger) == null ? void 0 : _a.call(action, action);
|
|
52
|
+
};
|
|
53
|
+
return [
|
|
54
|
+
actions,
|
|
55
|
+
{
|
|
56
|
+
registerActions,
|
|
57
|
+
removeActions,
|
|
58
|
+
triggerAction
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { useActionsState };
|
|
64
|
+
//# 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":[],"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,cA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GAAG,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/G,EAAE,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK;AAChC,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1D,IAAI,CAAC,EAAE,GAAG,MAAM,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACjG,GAAG,CAAC;AACJ,EAAE,OAAO;AACT,IAAI,OAAO;AACX,IAAI;AACJ,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useHotkeys } from '@mantine/hooks';
|
|
2
|
+
|
|
3
|
+
function getHotkeysPayload(shortcuts, onToggle) {
|
|
4
|
+
if (shortcuts === null) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
if (Array.isArray(shortcuts)) {
|
|
8
|
+
return shortcuts.map((shortcut) => [shortcut, onToggle]);
|
|
9
|
+
}
|
|
10
|
+
return [[shortcuts, onToggle]];
|
|
11
|
+
}
|
|
12
|
+
function useSpotlightShortcuts(shortcuts, onToggle) {
|
|
13
|
+
useHotkeys(getHotkeysPayload(shortcuts, onToggle));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { getHotkeysPayload, useSpotlightShortcuts };
|
|
17
|
+
//# 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":[],"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,EAAE,UAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACrD;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DefaultProps, ClassNames } from '@mantine/core';
|
|
3
|
+
import type { SpotlightAction } from '../types';
|
|
4
|
+
import type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';
|
|
5
|
+
import useStyles from './ActionsList.styles';
|
|
6
|
+
export declare type ActionsListStylesNames = ClassNames<typeof useStyles> | DefaultActionStylesNames;
|
|
7
|
+
export interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {
|
|
8
|
+
actions: SpotlightAction[];
|
|
9
|
+
actionComponent?: React.FC<DefaultActionProps>;
|
|
10
|
+
hovered: number;
|
|
11
|
+
query: string;
|
|
12
|
+
nothingFoundMessage?: React.ReactNode;
|
|
13
|
+
onActionHover(index: number): void;
|
|
14
|
+
onActionTrigger(action: SpotlightAction): void;
|
|
15
|
+
highlightQuery: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function ActionsList({ actions, styles, classNames, actionComponent: Action, hovered, onActionHover, onActionTrigger, query, nothingFoundMessage, highlightQuery, }: ActionsListProps): JSX.Element;
|
|
18
|
+
export declare namespace ActionsList {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ActionsList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsList.d.ts","sourceRoot":"","sources":["../../src/ActionsList/ActionsList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,UAAU,EAA2B,MAAM,eAAe,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACnG,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAE7C,oBAAY,sBAAsB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,GAAG,wBAAwB,CAAC;AAE7F,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,sBAAsB,CAAC;IAC5E,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/C,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,MAAM,EACN,UAAU,EACV,eAAe,EAAE,MAAM,EACvB,OAAO,EACP,aAAa,EACb,eAAe,EACf,KAAK,EACL,mBAAmB,EACnB,cAAc,GACf,EAAE,gBAAgB,eA6ClB;yBAxDe,WAAW"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const _default: (params: void, options?: import("@mantine/core").UseStylesOptions<"actions" | "nothingFound" | "actionsGroup">) => {
|
|
2
|
+
classes: Record<"actions" | "nothingFound" | "actionsGroup", string>;
|
|
3
|
+
cx: (...args: any) => string;
|
|
4
|
+
theme: import("@mantine/core").MantineTheme;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=ActionsList.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsList.styles.d.ts","sourceRoot":"","sources":["../../src/ActionsList/ActionsList.styles.ts"],"names":[],"mappings":";;;;;AAEA,wBAkBI"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DefaultProps, ClassNames } from '@mantine/core';
|
|
3
|
+
import type { SpotlightAction } from '../types';
|
|
4
|
+
import useStyles from './DefaultAction.styles';
|
|
5
|
+
export declare type DefaultActionStylesNames = ClassNames<typeof useStyles>;
|
|
6
|
+
export interface DefaultActionProps extends DefaultProps<DefaultActionStylesNames>, React.ComponentPropsWithoutRef<'button'> {
|
|
7
|
+
action: SpotlightAction;
|
|
8
|
+
hovered: boolean;
|
|
9
|
+
onTrigger(): void;
|
|
10
|
+
highlightQuery: boolean;
|
|
11
|
+
query: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function DefaultAction({ action, styles, classNames, hovered, onTrigger, highlightQuery, query, ...others }: DefaultActionProps): JSX.Element;
|
|
14
|
+
export declare namespace DefaultAction {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=DefaultAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultAction.d.ts","sourceRoot":"","sources":["../../src/DefaultAction/DefaultAction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,UAAU,EAMX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,oBAAY,wBAAwB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAEpE,MAAM,WAAW,kBACf,SAAQ,YAAY,CAAC,wBAAwB,CAAC,EAC5C,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC;IAC1C,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,IAAI,IAAI,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,GAAG,MAAM,EACV,EAAE,kBAAkB,eA0BpB;yBAnCe,aAAa"}
|