@mantine/spotlight 4.0.1 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/ActionsList/ActionsList.js +4 -2
- package/cjs/ActionsList/ActionsList.js.map +1 -1
- package/cjs/DefaultAction/DefaultAction.js +5 -3
- package/cjs/DefaultAction/DefaultAction.js.map +1 -1
- package/cjs/DefaultAction/DefaultAction.styles.js +2 -2
- package/cjs/DefaultAction/DefaultAction.styles.js.map +1 -1
- package/cjs/Spotlight/Spotlight.js +15 -9
- package/cjs/Spotlight/Spotlight.js.map +1 -1
- package/cjs/Spotlight/Spotlight.styles.js +2 -2
- package/cjs/Spotlight/Spotlight.styles.js.map +1 -1
- package/esm/ActionsList/ActionsList.js +5 -3
- package/esm/ActionsList/ActionsList.js.map +1 -1
- package/esm/DefaultAction/DefaultAction.js +5 -3
- package/esm/DefaultAction/DefaultAction.js.map +1 -1
- package/esm/DefaultAction/DefaultAction.styles.js +2 -2
- package/esm/DefaultAction/DefaultAction.styles.js.map +1 -1
- package/esm/Spotlight/Spotlight.js +16 -10
- package/esm/Spotlight/Spotlight.js.map +1 -1
- package/esm/Spotlight/Spotlight.styles.js +2 -2
- package/esm/Spotlight/Spotlight.styles.js.map +1 -1
- package/lib/ActionsList/ActionsList.d.ts +14 -3
- package/lib/ActionsList/ActionsList.d.ts.map +1 -1
- package/lib/DefaultAction/DefaultAction.d.ts +3 -2
- package/lib/DefaultAction/DefaultAction.d.ts.map +1 -1
- package/lib/DefaultAction/DefaultAction.styles.d.ts +5 -1
- package/lib/DefaultAction/DefaultAction.styles.d.ts.map +1 -1
- package/lib/Spotlight/Spotlight.d.ts +4 -2
- package/lib/Spotlight/Spotlight.d.ts.map +1 -1
- package/lib/Spotlight/Spotlight.styles.d.ts +2 -0
- package/lib/Spotlight/Spotlight.styles.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -20,10 +20,11 @@ function ActionsList({
|
|
|
20
20
|
onActionTrigger,
|
|
21
21
|
query,
|
|
22
22
|
nothingFoundMessage,
|
|
23
|
-
highlightQuery
|
|
23
|
+
highlightQuery,
|
|
24
|
+
radius
|
|
24
25
|
}) {
|
|
25
26
|
const { classes } = ActionsList_styles['default'](null, { classNames, styles, name: "Spotlight" });
|
|
26
|
-
const items =
|
|
27
|
+
const items = actions.map((item) => {
|
|
27
28
|
if (item.type === "item") {
|
|
28
29
|
return /* @__PURE__ */ React__default.createElement(Action, {
|
|
29
30
|
query,
|
|
@@ -33,6 +34,7 @@ function ActionsList({
|
|
|
33
34
|
onMouseEnter: () => onActionHover(item.index),
|
|
34
35
|
classNames,
|
|
35
36
|
styles,
|
|
37
|
+
radius,
|
|
36
38
|
onTrigger: () => onActionTrigger(item.item),
|
|
37
39
|
highlightQuery
|
|
38
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, ClassNames, Text,
|
|
1
|
+
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, ClassNames, Text, MantineNumberSize } 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;\ntype GetGroupOptionsItem<T extends any[]> = { type: 'item'; item: T[number]; index: number };\ntype GetGroupOptionsLabel = { type: 'label'; label: string };\n\nexport interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {\n actions: (GetGroupOptionsItem<SpotlightAction[]> | GetGroupOptionsLabel)[];\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 radius: MantineNumberSize;\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 radius,\n}: ActionsListProps) {\n const { classes } = useStyles(null, { classNames, styles, name: 'Spotlight' });\n\n const items = actions.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 radius={radius}\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/spotlight/ActionsList';\n"],"names":["useStyles","React","Text"],"mappings":";;;;;;;;;;;;AAGO,SAAS,WAAW,CAAC;AAC5B,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,UAAU;AACZ,EAAE,eAAe,EAAE,MAAM;AACzB,EAAE,OAAO;AACT,EAAE,aAAa;AACf,EAAE,eAAe;AACjB,EAAE,KAAK;AACP,EAAE,mBAAmB;AACrB,EAAE,cAAc;AAChB,EAAE,MAAM;AACR,CAAC,EAAE;AACH,EAAE,MAAM,EAAE,OAAO,EAAE,GAAGA,6BAAS,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AACjF,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IA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AAK,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;;;;"}
|
|
@@ -46,7 +46,8 @@ function DefaultAction(_a) {
|
|
|
46
46
|
hovered,
|
|
47
47
|
onTrigger,
|
|
48
48
|
highlightQuery,
|
|
49
|
-
query
|
|
49
|
+
query,
|
|
50
|
+
radius
|
|
50
51
|
} = _b, others = __objRest(_b, [
|
|
51
52
|
"action",
|
|
52
53
|
"styles",
|
|
@@ -54,9 +55,10 @@ function DefaultAction(_a) {
|
|
|
54
55
|
"hovered",
|
|
55
56
|
"onTrigger",
|
|
56
57
|
"highlightQuery",
|
|
57
|
-
"query"
|
|
58
|
+
"query",
|
|
59
|
+
"radius"
|
|
58
60
|
]);
|
|
59
|
-
const { classes, cx } = DefaultAction_styles['default'](
|
|
61
|
+
const { classes, cx } = DefaultAction_styles['default']({ radius }, { styles, classNames, name: "Spotlight" });
|
|
60
62
|
return /* @__PURE__ */ React__default.createElement(core.UnstyledButton, __spreadValues({
|
|
61
63
|
className: cx(classes.action, { [classes.actionHovered]: hovered }),
|
|
62
64
|
tabIndex: -1,
|
|
@@ -1 +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(
|
|
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 MantineNumberSize,\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 radius: MantineNumberSize;\n}\n\nexport function DefaultAction({\n action,\n styles,\n classNames,\n hovered,\n onTrigger,\n highlightQuery,\n query,\n radius,\n ...others\n}: DefaultActionProps) {\n const { classes, cx } = useStyles({ radius }, { 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":["useStyles","React","UnstyledButton","Group","Center","Highlight","Text"],"mappings":";;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;A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AAM,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,GAAG,OAAO,EAAE,CAAC;AACvE,IAAI,QAAQ,EAAE,CAAC,CAAC;AAChB,IAAI,WAAW,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,cAAc,EAAE;AAClD,IAAI,OAAO,EAAE,SAAS;AACtB,GAAG,EAAE,MAAM,CAAC,kBAAkBD,cAAK,CAAC,aAAa,CAACE,UAAK,EAAE;AACzD,IAAI,MAAM,EAAE,IAAI;AAChB,GAAG,EAAE,MAAM,CAAC,IAAI,oBAAoBF,cAAK,CAAC,aAAa,CAACG,WAAM,EAAE;AAChE,IAAI,SAAS,EAAE,OAAO,CAAC,UAAU;AACjC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkBH,cAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AAC9D,IAAI,SAAS,EAAE,OAAO,CAAC,UAAU;AACjC,GAAG,kBAAkBA,cAAK,CAAC,aAAa,CAACI,cAAS,EAAE;AACpD,IAAI,SAAS,EAAE,cAAc,GAAG,KAAK,GAAG,IAAI;AAC5C,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,oBAAoBJ,cAAK,CAAC,aAAa,CAACK,SAAI,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;;;;"}
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@mantine/core');
|
|
6
6
|
|
|
7
|
-
var useStyles = core.createStyles((theme) => ({
|
|
7
|
+
var useStyles = core.createStyles((theme, { radius }) => ({
|
|
8
8
|
action: {
|
|
9
9
|
position: "relative",
|
|
10
10
|
display: "block",
|
|
11
11
|
width: "100%",
|
|
12
12
|
padding: "10px 12px",
|
|
13
|
-
borderRadius: theme.radius
|
|
13
|
+
borderRadius: theme.fn.radius(radius)
|
|
14
14
|
},
|
|
15
15
|
actionHovered: {
|
|
16
16
|
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize } from '@mantine/core';\n\nexport interface DefaultActionStylesParams {\n radius: MantineNumberSize;\n}\n\nexport default createStyles((theme, { radius }: DefaultActionStylesParams) => ({\n action: {\n position: 'relative',\n display: 'block',\n width: '100%',\n padding: '10px 12px',\n borderRadius: theme.fn.radius(radius),\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":["createStyles"],"mappings":";;;;;;AACA,gBAAeA,iBAAY,CAAC,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM;AACpD,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,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AACzC,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;;;;"}
|
|
@@ -58,6 +58,7 @@ function Spotlight(_a) {
|
|
|
58
58
|
overlayOpacity = 0.25,
|
|
59
59
|
overlayBlur = 3,
|
|
60
60
|
shadow = "md",
|
|
61
|
+
radius = "sm",
|
|
61
62
|
centered = false,
|
|
62
63
|
closeOnActionTrigger = true,
|
|
63
64
|
highlightQuery = false,
|
|
@@ -87,6 +88,7 @@ function Spotlight(_a) {
|
|
|
87
88
|
"overlayOpacity",
|
|
88
89
|
"overlayBlur",
|
|
89
90
|
"shadow",
|
|
91
|
+
"radius",
|
|
90
92
|
"centered",
|
|
91
93
|
"closeOnActionTrigger",
|
|
92
94
|
"highlightQuery",
|
|
@@ -103,7 +105,7 @@ function Spotlight(_a) {
|
|
|
103
105
|
"zIndex"
|
|
104
106
|
]);
|
|
105
107
|
const [hovered, setHovered] = React.useState(-1);
|
|
106
|
-
const { classes, cx } = Spotlight_styles['default']({ centered, maxWidth, topOffset }, { classNames, styles, name: "Spotlight" });
|
|
108
|
+
const { classes, cx } = Spotlight_styles['default']({ centered, maxWidth, topOffset, radius }, { classNames, styles, name: "Spotlight" });
|
|
107
109
|
const [, lockScroll] = hooks.useScrollLock();
|
|
108
110
|
const focusTrapRef = hooks.useFocusTrap(opened);
|
|
109
111
|
const resetHovered = () => setHovered(-1);
|
|
@@ -113,27 +115,29 @@ function Spotlight(_a) {
|
|
|
113
115
|
};
|
|
114
116
|
hooks.useFocusReturn({ transitionDuration: 0, opened });
|
|
115
117
|
const filteredActions = filter(query, actions).slice(0, limit);
|
|
118
|
+
const groupedWithLabels = core.getGroupedOptions(filteredActions).items;
|
|
119
|
+
const groupedActions = groupedWithLabels.map((item) => item.type === "item" ? item.item : void 0).filter((item) => item);
|
|
116
120
|
hooks.useDidUpdate(() => {
|
|
117
|
-
if (
|
|
118
|
-
setHovered(
|
|
121
|
+
if (groupedActions.length - 1 < hovered) {
|
|
122
|
+
setHovered(groupedActions.length - 1);
|
|
119
123
|
}
|
|
120
|
-
}, [
|
|
124
|
+
}, [groupedActions.length]);
|
|
121
125
|
const handleInputKeyDown = (event) => {
|
|
122
126
|
var _a2;
|
|
123
127
|
switch (event.code) {
|
|
124
128
|
case "ArrowDown": {
|
|
125
129
|
event.preventDefault();
|
|
126
|
-
setHovered((current) => current <
|
|
130
|
+
setHovered((current) => current < groupedActions.length - 1 ? current + 1 : 0);
|
|
127
131
|
break;
|
|
128
132
|
}
|
|
129
133
|
case "ArrowUp": {
|
|
130
134
|
event.preventDefault();
|
|
131
|
-
setHovered((current) => current > 0 ? current - 1 :
|
|
135
|
+
setHovered((current) => current > 0 ? current - 1 : groupedActions.length - 1);
|
|
132
136
|
break;
|
|
133
137
|
}
|
|
134
138
|
case "Enter": {
|
|
135
139
|
event.preventDefault();
|
|
136
|
-
const action =
|
|
140
|
+
const action = groupedActions[hovered];
|
|
137
141
|
(_a2 = action == null ? void 0 : action.onTrigger) == null ? void 0 : _a2.call(action, action);
|
|
138
142
|
if (closeOnActionTrigger && (action == null ? void 0 : action.onTrigger)) {
|
|
139
143
|
handleClose();
|
|
@@ -180,6 +184,7 @@ function Spotlight(_a) {
|
|
|
180
184
|
style: transitionStyles.spotlight,
|
|
181
185
|
className: classes.spotlight,
|
|
182
186
|
shadow,
|
|
187
|
+
radius,
|
|
183
188
|
onMouseLeave: resetHovered
|
|
184
189
|
}, /* @__PURE__ */ React__default.createElement(core.TextInput, {
|
|
185
190
|
value: query,
|
|
@@ -192,7 +197,7 @@ function Spotlight(_a) {
|
|
|
192
197
|
onMouseEnter: resetHovered
|
|
193
198
|
}), /* @__PURE__ */ React__default.createElement(ActionsWrapper, null, /* @__PURE__ */ React__default.createElement(ActionsList.ActionsList, {
|
|
194
199
|
highlightQuery,
|
|
195
|
-
actions:
|
|
200
|
+
actions: groupedWithLabels,
|
|
196
201
|
actionComponent,
|
|
197
202
|
hovered,
|
|
198
203
|
query,
|
|
@@ -203,7 +208,8 @@ function Spotlight(_a) {
|
|
|
203
208
|
closeOnActionTrigger && handleClose();
|
|
204
209
|
},
|
|
205
210
|
styles,
|
|
206
|
-
classNames
|
|
211
|
+
classNames,
|
|
212
|
+
radius
|
|
207
213
|
}))), /* @__PURE__ */ React__default.createElement("div", {
|
|
208
214
|
style: transitionStyles.overlay
|
|
209
215
|
}, /* @__PURE__ */ React__default.createElement(core.Overlay, {
|
|
@@ -1 +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":["filterActions","DefaultAction","getDefaultZIndex","useState","useStyles","useScrollLock","useFocusTrap","useFocusReturn","useDidUpdate","React","OptionalPortal","GroupedTransition","Paper","TextInput","ActionsList","Overlay"],"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,E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ClD,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;;;;"}
|
|
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 getGroupedOptions,\n MantineNumberSize,\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 /** Radius from theme.radius, or number to set border-radius in px, defaults to theme.defaultRadius */\n radius?: MantineNumberSize;\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 radius = 'sm',\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, radius },\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 const groupedWithLabels = getGroupedOptions(filteredActions).items;\n const groupedActions = groupedWithLabels\n .map((item) => (item.type === 'item' ? item.item : undefined))\n .filter((item) => item);\n\n useDidUpdate(() => {\n if (groupedActions.length - 1 < hovered) {\n setHovered(groupedActions.length - 1);\n }\n }, [groupedActions.length]);\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n switch (event.code) {\n case 'ArrowDown': {\n event.preventDefault();\n setHovered((current) => (current < groupedActions.length - 1 ? current + 1 : 0));\n break;\n }\n\n case 'ArrowUp': {\n event.preventDefault();\n setHovered((current) => (current > 0 ? current - 1 : groupedActions.length - 1));\n break;\n }\n\n case 'Enter': {\n event.preventDefault();\n const action = groupedActions[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 radius={radius}\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={groupedWithLabels}\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 radius={radius}\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":["filterActions","DefaultAction","getDefaultZIndex","useState","useStyles","useScrollLock","useFocusTrap","useFocusReturn","getGroupedOptions","useDidUpdate","React","OptionalPortal","GroupedTransition","Paper","TextInput","ActionsList","Overlay"],"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,IA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,MAAM,oBAAoB,IAAI,WAAW,EAAE,CAAC;AAC5C,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,MAAM;AACV,GAAG,CAAC,CAAC,CAAC,kBAAkBL,cAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACnD,IAAI,KAAK,EAAE,gBAAgB,CAAC,OAAO;AACnC,GAAG,kBAAkBA,cAAK,CAAC,aAAa,CAACM,YAAO,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;;;;"}
|
|
@@ -23,7 +23,7 @@ var __spreadValues = (a, b) => {
|
|
|
23
23
|
return a;
|
|
24
24
|
};
|
|
25
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
var useStyles = core.createStyles((theme, { centered, maxWidth, topOffset }) => ({
|
|
26
|
+
var useStyles = core.createStyles((theme, { centered, maxWidth, topOffset, radius }) => ({
|
|
27
27
|
root: __spreadProps(__spreadValues({}, theme.fn.cover()), {
|
|
28
28
|
position: "fixed"
|
|
29
29
|
}),
|
|
@@ -31,7 +31,7 @@ var useStyles = core.createStyles((theme, { centered, maxWidth, topOffset }) =>
|
|
|
31
31
|
position: "relative",
|
|
32
32
|
zIndex: 2,
|
|
33
33
|
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.white,
|
|
34
|
-
borderRadius: theme.radius
|
|
34
|
+
borderRadius: theme.fn.radius(radius),
|
|
35
35
|
width: "100%",
|
|
36
36
|
maxWidth,
|
|
37
37
|
overflow: "hidden",
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"Spotlight.styles.js","sources":["../../src/Spotlight/Spotlight.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize } from '@mantine/core';\n\nexport interface SpotlightStylesParams {\n centered: boolean;\n maxWidth: number;\n topOffset: number;\n radius: MantineNumberSize;\n}\n\nexport default createStyles(\n (theme, { centered, maxWidth, topOffset, radius }: 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.fn.radius(radius),\n width: '100%',\n maxWidth,\n overflow: 'hidden',\n marginLeft: 'calc(var(--removed-scroll-width, 0px) * -1)',\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);\n"],"names":["createStyles"],"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,Y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K;AACtF,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Text } from '@mantine/core';
|
|
3
3
|
import useStyles from './ActionsList.styles.js';
|
|
4
4
|
|
|
5
5
|
function ActionsList({
|
|
@@ -12,10 +12,11 @@ function ActionsList({
|
|
|
12
12
|
onActionTrigger,
|
|
13
13
|
query,
|
|
14
14
|
nothingFoundMessage,
|
|
15
|
-
highlightQuery
|
|
15
|
+
highlightQuery,
|
|
16
|
+
radius
|
|
16
17
|
}) {
|
|
17
18
|
const { classes } = useStyles(null, { classNames, styles, name: "Spotlight" });
|
|
18
|
-
const items =
|
|
19
|
+
const items = actions.map((item) => {
|
|
19
20
|
if (item.type === "item") {
|
|
20
21
|
return /* @__PURE__ */ React.createElement(Action, {
|
|
21
22
|
query,
|
|
@@ -25,6 +26,7 @@ function ActionsList({
|
|
|
25
26
|
onMouseEnter: () => onActionHover(item.index),
|
|
26
27
|
classNames,
|
|
27
28
|
styles,
|
|
29
|
+
radius,
|
|
28
30
|
onTrigger: () => onActionTrigger(item.item),
|
|
29
31
|
highlightQuery
|
|
30
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, ClassNames, Text,
|
|
1
|
+
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, ClassNames, Text, MantineNumberSize } 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;\ntype GetGroupOptionsItem<T extends any[]> = { type: 'item'; item: T[number]; index: number };\ntype GetGroupOptionsLabel = { type: 'label'; label: string };\n\nexport interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {\n actions: (GetGroupOptionsItem<SpotlightAction[]> | GetGroupOptionsLabel)[];\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 radius: MantineNumberSize;\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 radius,\n}: ActionsListProps) {\n const { classes } = useStyles(null, { classNames, styles, name: 'Spotlight' });\n\n const items = actions.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 radius={radius}\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/spotlight/ActionsList';\n"],"names":[],"mappings":";;;;AAGO,SAAS,WAAW,CAAC;AAC5B,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,UAAU;AACZ,EAAE,eAAe,EAAE,MAAM;AACzB,EAAE,OAAO;AACT,EAAE,aAAa;AACf,EAAE,eAAe;AACjB,EAAE,KAAK;AACP,EAAE,mBAAmB;AACrB,EAAE,cAAc;AAChB,E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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;;;;"}
|
|
@@ -38,7 +38,8 @@ function DefaultAction(_a) {
|
|
|
38
38
|
hovered,
|
|
39
39
|
onTrigger,
|
|
40
40
|
highlightQuery,
|
|
41
|
-
query
|
|
41
|
+
query,
|
|
42
|
+
radius
|
|
42
43
|
} = _b, others = __objRest(_b, [
|
|
43
44
|
"action",
|
|
44
45
|
"styles",
|
|
@@ -46,9 +47,10 @@ function DefaultAction(_a) {
|
|
|
46
47
|
"hovered",
|
|
47
48
|
"onTrigger",
|
|
48
49
|
"highlightQuery",
|
|
49
|
-
"query"
|
|
50
|
+
"query",
|
|
51
|
+
"radius"
|
|
50
52
|
]);
|
|
51
|
-
const { classes, cx } = useStyles(
|
|
53
|
+
const { classes, cx } = useStyles({ radius }, { styles, classNames, name: "Spotlight" });
|
|
52
54
|
return /* @__PURE__ */ React.createElement(UnstyledButton, __spreadValues({
|
|
53
55
|
className: cx(classes.action, { [classes.actionHovered]: hovered }),
|
|
54
56
|
tabIndex: -1,
|
|
@@ -1 +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(
|
|
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 MantineNumberSize,\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 radius: MantineNumberSize;\n}\n\nexport function DefaultAction({\n action,\n styles,\n classNames,\n hovered,\n onTrigger,\n highlightQuery,\n query,\n radius,\n ...others\n}: DefaultActionProps) {\n const { classes, cx } = useStyles({ radius }, { 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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les((theme, { radius }) => ({
|
|
4
4
|
action: {
|
|
5
5
|
position: "relative",
|
|
6
6
|
display: "block",
|
|
7
7
|
width: "100%",
|
|
8
8
|
padding: "10px 12px",
|
|
9
|
-
borderRadius: theme.radius
|
|
9
|
+
borderRadius: theme.fn.radius(radius)
|
|
10
10
|
},
|
|
11
11
|
actionHovered: {
|
|
12
12
|
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize } from '@mantine/core';\n\nexport interface DefaultActionStylesParams {\n radius: MantineNumberSize;\n}\n\nexport default createStyles((theme, { radius }: DefaultActionStylesParams) => ({\n action: {\n position: 'relative',\n display: 'block',\n width: '100%',\n padding: '10px 12px',\n borderRadius: theme.fn.radius(radius),\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,EAAE,EAAE,MAAM,EAAE,MAAM;AACpD,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,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AACzC,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;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { getDefaultZIndex, OptionalPortal, GroupedTransition, Paper, TextInput, Overlay } from '@mantine/core';
|
|
2
|
+
import { getDefaultZIndex, getGroupedOptions, OptionalPortal, GroupedTransition, Paper, TextInput, Overlay } from '@mantine/core';
|
|
3
3
|
import { useScrollLock, useFocusTrap, useFocusReturn, useDidUpdate } from '@mantine/hooks';
|
|
4
4
|
import { DefaultAction } from '../DefaultAction/DefaultAction.js';
|
|
5
5
|
import { ActionsList } from '../ActionsList/ActionsList.js';
|
|
@@ -50,6 +50,7 @@ function Spotlight(_a) {
|
|
|
50
50
|
overlayOpacity = 0.25,
|
|
51
51
|
overlayBlur = 3,
|
|
52
52
|
shadow = "md",
|
|
53
|
+
radius = "sm",
|
|
53
54
|
centered = false,
|
|
54
55
|
closeOnActionTrigger = true,
|
|
55
56
|
highlightQuery = false,
|
|
@@ -79,6 +80,7 @@ function Spotlight(_a) {
|
|
|
79
80
|
"overlayOpacity",
|
|
80
81
|
"overlayBlur",
|
|
81
82
|
"shadow",
|
|
83
|
+
"radius",
|
|
82
84
|
"centered",
|
|
83
85
|
"closeOnActionTrigger",
|
|
84
86
|
"highlightQuery",
|
|
@@ -95,7 +97,7 @@ function Spotlight(_a) {
|
|
|
95
97
|
"zIndex"
|
|
96
98
|
]);
|
|
97
99
|
const [hovered, setHovered] = useState(-1);
|
|
98
|
-
const { classes, cx } = useStyles({ centered, maxWidth, topOffset }, { classNames, styles, name: "Spotlight" });
|
|
100
|
+
const { classes, cx } = useStyles({ centered, maxWidth, topOffset, radius }, { classNames, styles, name: "Spotlight" });
|
|
99
101
|
const [, lockScroll] = useScrollLock();
|
|
100
102
|
const focusTrapRef = useFocusTrap(opened);
|
|
101
103
|
const resetHovered = () => setHovered(-1);
|
|
@@ -105,27 +107,29 @@ function Spotlight(_a) {
|
|
|
105
107
|
};
|
|
106
108
|
useFocusReturn({ transitionDuration: 0, opened });
|
|
107
109
|
const filteredActions = filter(query, actions).slice(0, limit);
|
|
110
|
+
const groupedWithLabels = getGroupedOptions(filteredActions).items;
|
|
111
|
+
const groupedActions = groupedWithLabels.map((item) => item.type === "item" ? item.item : void 0).filter((item) => item);
|
|
108
112
|
useDidUpdate(() => {
|
|
109
|
-
if (
|
|
110
|
-
setHovered(
|
|
113
|
+
if (groupedActions.length - 1 < hovered) {
|
|
114
|
+
setHovered(groupedActions.length - 1);
|
|
111
115
|
}
|
|
112
|
-
}, [
|
|
116
|
+
}, [groupedActions.length]);
|
|
113
117
|
const handleInputKeyDown = (event) => {
|
|
114
118
|
var _a2;
|
|
115
119
|
switch (event.code) {
|
|
116
120
|
case "ArrowDown": {
|
|
117
121
|
event.preventDefault();
|
|
118
|
-
setHovered((current) => current <
|
|
122
|
+
setHovered((current) => current < groupedActions.length - 1 ? current + 1 : 0);
|
|
119
123
|
break;
|
|
120
124
|
}
|
|
121
125
|
case "ArrowUp": {
|
|
122
126
|
event.preventDefault();
|
|
123
|
-
setHovered((current) => current > 0 ? current - 1 :
|
|
127
|
+
setHovered((current) => current > 0 ? current - 1 : groupedActions.length - 1);
|
|
124
128
|
break;
|
|
125
129
|
}
|
|
126
130
|
case "Enter": {
|
|
127
131
|
event.preventDefault();
|
|
128
|
-
const action =
|
|
132
|
+
const action = groupedActions[hovered];
|
|
129
133
|
(_a2 = action == null ? void 0 : action.onTrigger) == null ? void 0 : _a2.call(action, action);
|
|
130
134
|
if (closeOnActionTrigger && (action == null ? void 0 : action.onTrigger)) {
|
|
131
135
|
handleClose();
|
|
@@ -172,6 +176,7 @@ function Spotlight(_a) {
|
|
|
172
176
|
style: transitionStyles.spotlight,
|
|
173
177
|
className: classes.spotlight,
|
|
174
178
|
shadow,
|
|
179
|
+
radius,
|
|
175
180
|
onMouseLeave: resetHovered
|
|
176
181
|
}, /* @__PURE__ */ React.createElement(TextInput, {
|
|
177
182
|
value: query,
|
|
@@ -184,7 +189,7 @@ function Spotlight(_a) {
|
|
|
184
189
|
onMouseEnter: resetHovered
|
|
185
190
|
}), /* @__PURE__ */ React.createElement(ActionsWrapper, null, /* @__PURE__ */ React.createElement(ActionsList, {
|
|
186
191
|
highlightQuery,
|
|
187
|
-
actions:
|
|
192
|
+
actions: groupedWithLabels,
|
|
188
193
|
actionComponent,
|
|
189
194
|
hovered,
|
|
190
195
|
query,
|
|
@@ -195,7 +200,8 @@ function Spotlight(_a) {
|
|
|
195
200
|
closeOnActionTrigger && handleClose();
|
|
196
201
|
},
|
|
197
202
|
styles,
|
|
198
|
-
classNames
|
|
203
|
+
classNames,
|
|
204
|
+
radius
|
|
199
205
|
}))), /* @__PURE__ */ React.createElement("div", {
|
|
200
206
|
style: transitionStyles.overlay
|
|
201
207
|
}, /* @__PURE__ */ React.createElement(Overlay, {
|
|
@@ -1 +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,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS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AC5C,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;;;;"}
|
|
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 getGroupedOptions,\n MantineNumberSize,\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 /** Radius from theme.radius, or number to set border-radius in px, defaults to theme.defaultRadius */\n radius?: MantineNumberSize;\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 radius = 'sm',\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, radius },\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 const groupedWithLabels = getGroupedOptions(filteredActions).items;\n const groupedActions = groupedWithLabels\n .map((item) => (item.type === 'item' ? item.item : undefined))\n .filter((item) => item);\n\n useDidUpdate(() => {\n if (groupedActions.length - 1 < hovered) {\n setHovered(groupedActions.length - 1);\n }\n }, [groupedActions.length]);\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n switch (event.code) {\n case 'ArrowDown': {\n event.preventDefault();\n setHovered((current) => (current < groupedActions.length - 1 ? current + 1 : 0));\n break;\n }\n\n case 'ArrowUp': {\n event.preventDefault();\n setHovered((current) => (current > 0 ? current - 1 : groupedActions.length - 1));\n break;\n }\n\n case 'Enter': {\n event.preventDefault();\n const action = groupedActions[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 radius={radius}\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={groupedWithLabels}\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 radius={radius}\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,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,IAA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,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,oBAAoB,IAAI,WAAW,EAAE,CAAC;AAC5C,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,MAAM;AACV,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;;;;"}
|
|
@@ -19,7 +19,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var useStyles = createStyles((theme, { centered, maxWidth, topOffset }) => ({
|
|
22
|
+
var useStyles = createStyles((theme, { centered, maxWidth, topOffset, radius }) => ({
|
|
23
23
|
root: __spreadProps(__spreadValues({}, theme.fn.cover()), {
|
|
24
24
|
position: "fixed"
|
|
25
25
|
}),
|
|
@@ -27,7 +27,7 @@ var useStyles = createStyles((theme, { centered, maxWidth, topOffset }) => ({
|
|
|
27
27
|
position: "relative",
|
|
28
28
|
zIndex: 2,
|
|
29
29
|
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.white,
|
|
30
|
-
borderRadius: theme.radius
|
|
30
|
+
borderRadius: theme.fn.radius(radius),
|
|
31
31
|
width: "100%",
|
|
32
32
|
maxWidth,
|
|
33
33
|
overflow: "hidden",
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"Spotlight.styles.js","sources":["../../src/Spotlight/Spotlight.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize } from '@mantine/core';\n\nexport interface SpotlightStylesParams {\n centered: boolean;\n maxWidth: number;\n topOffset: number;\n radius: MantineNumberSize;\n}\n\nexport default createStyles(\n (theme, { centered, maxWidth, topOffset, radius }: 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.fn.radius(radius),\n width: '100%',\n maxWidth,\n overflow: 'hidden',\n marginLeft: 'calc(var(--removed-scroll-width, 0px) * -1)',\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);\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,CAA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CAAC,GAAG,KAAK,CAAC,KAAK;AACtF,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DefaultProps, ClassNames } from '@mantine/core';
|
|
2
|
+
import { DefaultProps, ClassNames, MantineNumberSize } from '@mantine/core';
|
|
3
3
|
import type { SpotlightAction } from '../types';
|
|
4
4
|
import type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';
|
|
5
5
|
import useStyles from './ActionsList.styles';
|
|
6
6
|
export declare type ActionsListStylesNames = ClassNames<typeof useStyles> | DefaultActionStylesNames;
|
|
7
|
+
declare type GetGroupOptionsItem<T extends any[]> = {
|
|
8
|
+
type: 'item';
|
|
9
|
+
item: T[number];
|
|
10
|
+
index: number;
|
|
11
|
+
};
|
|
12
|
+
declare type GetGroupOptionsLabel = {
|
|
13
|
+
type: 'label';
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
7
16
|
export interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {
|
|
8
|
-
actions: SpotlightAction[];
|
|
17
|
+
actions: (GetGroupOptionsItem<SpotlightAction[]> | GetGroupOptionsLabel)[];
|
|
9
18
|
actionComponent?: React.FC<DefaultActionProps>;
|
|
10
19
|
hovered: number;
|
|
11
20
|
query: string;
|
|
@@ -13,9 +22,11 @@ export interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {
|
|
|
13
22
|
onActionHover(index: number): void;
|
|
14
23
|
onActionTrigger(action: SpotlightAction): void;
|
|
15
24
|
highlightQuery: boolean;
|
|
25
|
+
radius: MantineNumberSize;
|
|
16
26
|
}
|
|
17
|
-
export declare function ActionsList({ actions, styles, classNames, actionComponent: Action, hovered, onActionHover, onActionTrigger, query, nothingFoundMessage, highlightQuery, }: ActionsListProps): JSX.Element;
|
|
27
|
+
export declare function ActionsList({ actions, styles, classNames, actionComponent: Action, hovered, onActionHover, onActionTrigger, query, nothingFoundMessage, highlightQuery, radius, }: ActionsListProps): JSX.Element;
|
|
18
28
|
export declare namespace ActionsList {
|
|
19
29
|
var displayName: string;
|
|
20
30
|
}
|
|
31
|
+
export {};
|
|
21
32
|
//# sourceMappingURL=ActionsList.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAAQ,iBAAiB,EAAE,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;AAC7F,aAAK,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7F,aAAK,oBAAoB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,sBAAsB,CAAC;IAC5E,OAAO,EAAE,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC,GAAG,oBAAoB,CAAC,EAAE,CAAC;IAC3E,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;IACxB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;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,EACd,MAAM,GACP,EAAE,gBAAgB,eA8ClB;yBA1De,WAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DefaultProps, ClassNames } from '@mantine/core';
|
|
2
|
+
import { DefaultProps, ClassNames, MantineNumberSize } from '@mantine/core';
|
|
3
3
|
import type { SpotlightAction } from '../types';
|
|
4
4
|
import useStyles from './DefaultAction.styles';
|
|
5
5
|
export declare type DefaultActionStylesNames = ClassNames<typeof useStyles>;
|
|
@@ -9,8 +9,9 @@ export interface DefaultActionProps extends DefaultProps<DefaultActionStylesName
|
|
|
9
9
|
onTrigger(): void;
|
|
10
10
|
highlightQuery: boolean;
|
|
11
11
|
query: string;
|
|
12
|
+
radius: MantineNumberSize;
|
|
12
13
|
}
|
|
13
|
-
export declare function DefaultAction({ action, styles, classNames, hovered, onTrigger, highlightQuery, query, ...others }: DefaultActionProps): JSX.Element;
|
|
14
|
+
export declare function DefaultAction({ action, styles, classNames, hovered, onTrigger, highlightQuery, query, radius, ...others }: DefaultActionProps): JSX.Element;
|
|
14
15
|
export declare namespace DefaultAction {
|
|
15
16
|
var displayName: string;
|
|
16
17
|
}
|
|
@@ -1 +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,
|
|
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,EAMV,iBAAiB,EAClB,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;IACd,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,MAAM,EACN,GAAG,MAAM,EACV,EAAE,kBAAkB,eA0BpB;yBApCe,aAAa"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { MantineNumberSize } from '@mantine/core';
|
|
2
|
+
export interface DefaultActionStylesParams {
|
|
3
|
+
radius: MantineNumberSize;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: (params: DefaultActionStylesParams, options?: import("@mantine/core").UseStylesOptions<"action" | "actionHovered" | "actionIcon" | "actionBody">) => {
|
|
2
6
|
classes: Record<"action" | "actionHovered" | "actionIcon" | "actionBody", string>;
|
|
3
7
|
cx: (...args: any) => string;
|
|
4
8
|
theme: import("@mantine/core").MantineTheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.styles.d.ts","sourceRoot":"","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.d.ts","sourceRoot":"","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,iBAAiB,CAAC;CAC3B;;;;;;AAED,wBAoBI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MantineTransition, DefaultProps, ClassNames, MantineShadow } from '@mantine/core';
|
|
2
|
+
import { MantineTransition, DefaultProps, ClassNames, MantineShadow, MantineNumberSize } from '@mantine/core';
|
|
3
3
|
import { DefaultActionProps } from '../DefaultAction/DefaultAction';
|
|
4
4
|
import { ActionsListStylesNames } from '../ActionsList/ActionsList';
|
|
5
5
|
import type { SpotlightAction } from '../types';
|
|
@@ -20,6 +20,8 @@ export interface InnerSpotlightProps extends DefaultProps<SpotlightStylesNames>,
|
|
|
20
20
|
overlayBlur?: number;
|
|
21
21
|
/** Value from theme.shadows or any valid css box-shadow value */
|
|
22
22
|
shadow?: MantineShadow;
|
|
23
|
+
/** Radius from theme.radius, or number to set border-radius in px, defaults to theme.defaultRadius */
|
|
24
|
+
radius?: MantineNumberSize;
|
|
23
25
|
/** Should spotlight be rendered in the center of the screen */
|
|
24
26
|
centered?: boolean;
|
|
25
27
|
/** Max spotlight width */
|
|
@@ -56,7 +58,7 @@ interface SpotlightProps extends InnerSpotlightProps {
|
|
|
56
58
|
query: string;
|
|
57
59
|
onQueryChange(query: string): void;
|
|
58
60
|
}
|
|
59
|
-
export declare function Spotlight({ query, onQueryChange, actions, onClose, opened, withinPortal, transition, transitionDuration, classNames, styles, overlayColor, overlayOpacity, overlayBlur, shadow, centered, closeOnActionTrigger, highlightQuery, maxWidth, topOffset, className, searchPlaceholder, searchIcon, filter, nothingFoundMessage, limit, actionComponent, actionsWrapperComponent: ActionsWrapper, zIndex, ...others }: SpotlightProps): JSX.Element;
|
|
61
|
+
export declare function Spotlight({ query, onQueryChange, actions, onClose, opened, withinPortal, transition, transitionDuration, classNames, styles, overlayColor, overlayOpacity, overlayBlur, shadow, radius, centered, closeOnActionTrigger, highlightQuery, maxWidth, topOffset, className, searchPlaceholder, searchIcon, filter, nothingFoundMessage, limit, actionComponent, actionsWrapperComponent: ActionsWrapper, zIndex, ...others }: SpotlightProps): JSX.Element;
|
|
60
62
|
export declare namespace Spotlight {
|
|
61
63
|
var displayName: string;
|
|
62
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spotlight.d.ts","sourceRoot":"","sources":["../../src/Spotlight/Spotlight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAGL,iBAAiB,EAGjB,YAAY,EACZ,UAAU,EACV,aAAa,
|
|
1
|
+
{"version":3,"file":"Spotlight.d.ts","sourceRoot":"","sources":["../../src/Spotlight/Spotlight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAGL,iBAAiB,EAGjB,YAAY,EACZ,UAAU,EACV,aAAa,EAIb,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAiB,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAe,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,SAAS,MAAM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,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAE/C,kDAAkD;IAClD,uBAAuB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,GAAG,MAAM,CAAC;IAE3E,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wDAAwD;IACxD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,cAAe,SAAQ,mBAAmB;IAClD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,aAAa,EACb,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,UAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,YAAqB,EACrB,cAAqB,EACrB,WAAe,EACf,MAAa,EACb,MAAa,EACb,QAAgB,EAChB,oBAA2B,EAC3B,cAAsB,EACtB,QAAc,EACd,SAAe,EACf,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,MAAsB,EACtB,mBAAmB,EACnB,KAAU,EACV,eAA+B,EAC/B,uBAAuB,EAAE,cAAsB,EAC/C,MAAkC,EAClC,GAAG,MAAM,EACV,EAAE,cAAc,eA+IhB;yBA9Ke,SAAS"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { MantineNumberSize } from '@mantine/core';
|
|
1
2
|
export interface SpotlightStylesParams {
|
|
2
3
|
centered: boolean;
|
|
3
4
|
maxWidth: number;
|
|
4
5
|
topOffset: number;
|
|
6
|
+
radius: MantineNumberSize;
|
|
5
7
|
}
|
|
6
8
|
declare const _default: (params: SpotlightStylesParams, options?: import("@mantine/core").UseStylesOptions<"root" | "spotlight" | "overlay" | "inner" | "searchInput">) => {
|
|
7
9
|
classes: Record<"root" | "spotlight" | "overlay" | "inner" | "searchInput", string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spotlight.styles.d.ts","sourceRoot":"","sources":["../../src/Spotlight/Spotlight.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Spotlight.styles.d.ts","sourceRoot":"","sources":["../../src/Spotlight/Spotlight.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;;;;;;AAED,wBAuCE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine/spotlight",
|
|
3
3
|
"description": "Command center for your application",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.4",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"directory": "src/mantine-notifications"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@mantine/core": "4.0.
|
|
19
|
-
"@mantine/hooks": "4.0.
|
|
18
|
+
"@mantine/core": "4.0.4",
|
|
19
|
+
"@mantine/hooks": "4.0.4",
|
|
20
20
|
"react": ">=16.8.0",
|
|
21
21
|
"react-dom": ">=16.8.0"
|
|
22
22
|
},
|