@mantine/spotlight 6.0.0-alpha.3 → 6.0.0-alpha.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 +61 -21
- package/cjs/ActionsList/ActionsList.js.map +1 -1
- package/cjs/DefaultAction/DefaultAction.js +9 -20
- package/cjs/DefaultAction/DefaultAction.js.map +1 -1
- package/cjs/DefaultAction/DefaultAction.styles.js +40 -4
- package/cjs/DefaultAction/DefaultAction.styles.js.map +1 -1
- package/cjs/Spotlight/Spotlight.js +1 -14
- package/cjs/Spotlight/Spotlight.js.map +1 -1
- package/cjs/SpotlightProvider.js +5 -3
- package/cjs/SpotlightProvider.js.map +1 -1
- package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js +2 -2
- package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -1
- package/esm/ActionsList/ActionsList.js +61 -21
- package/esm/ActionsList/ActionsList.js.map +1 -1
- package/esm/DefaultAction/DefaultAction.js +10 -21
- package/esm/DefaultAction/DefaultAction.js.map +1 -1
- package/esm/DefaultAction/DefaultAction.styles.js +40 -4
- package/esm/DefaultAction/DefaultAction.styles.js.map +1 -1
- package/esm/Spotlight/Spotlight.js +1 -14
- package/esm/Spotlight/Spotlight.js.map +1 -1
- package/esm/SpotlightProvider.js +5 -3
- package/esm/SpotlightProvider.js.map +1 -1
- package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js +2 -2
- package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -1
- package/lib/ActionsList/ActionsList.d.ts +2 -3
- package/lib/ActionsList/ActionsList.d.ts.map +1 -1
- package/lib/DefaultAction/DefaultAction.d.ts +1 -1
- package/lib/DefaultAction/DefaultAction.d.ts.map +1 -1
- package/lib/DefaultAction/DefaultAction.styles.d.ts +1 -0
- package/lib/DefaultAction/DefaultAction.styles.d.ts.map +1 -1
- package/lib/Spotlight/Spotlight.d.ts.map +1 -1
- package/lib/SpotlightProvider.d.ts +3 -1
- package/lib/SpotlightProvider.d.ts.map +1 -1
- package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts +1 -1
- package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -10,21 +10,62 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
+
var __spreadValues = (a, b) => {
|
|
19
|
+
for (var prop in b || (b = {}))
|
|
20
|
+
if (__hasOwnProp.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
if (__getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
+
if (__propIsEnum.call(b, prop))
|
|
25
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
|
+
}
|
|
27
|
+
return a;
|
|
28
|
+
};
|
|
29
|
+
var __objRest = (source, exclude) => {
|
|
30
|
+
var target = {};
|
|
31
|
+
for (var prop in source)
|
|
32
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
if (source != null && __getOwnPropSymbols)
|
|
35
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
36
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
37
|
+
target[prop] = source[prop];
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
};
|
|
41
|
+
function ActionsList(_a) {
|
|
42
|
+
var _b = _a, {
|
|
43
|
+
actions,
|
|
44
|
+
styles,
|
|
45
|
+
classNames,
|
|
46
|
+
actionComponent: Action,
|
|
47
|
+
hovered,
|
|
48
|
+
onActionTrigger,
|
|
49
|
+
query,
|
|
50
|
+
nothingFoundMessage,
|
|
51
|
+
highlightQuery,
|
|
52
|
+
highlightColor,
|
|
53
|
+
radius,
|
|
54
|
+
variant
|
|
55
|
+
} = _b, others = __objRest(_b, [
|
|
56
|
+
"actions",
|
|
57
|
+
"styles",
|
|
58
|
+
"classNames",
|
|
59
|
+
"actionComponent",
|
|
60
|
+
"hovered",
|
|
61
|
+
"onActionTrigger",
|
|
62
|
+
"query",
|
|
63
|
+
"nothingFoundMessage",
|
|
64
|
+
"highlightQuery",
|
|
65
|
+
"highlightColor",
|
|
66
|
+
"radius",
|
|
67
|
+
"variant"
|
|
68
|
+
]);
|
|
28
69
|
const { classes } = ActionsList_styles['default'](null, { name: "Spotlight", classNames, styles, variant });
|
|
29
70
|
const items = actions.map((item) => {
|
|
30
71
|
if (item.type === "item") {
|
|
@@ -33,7 +74,6 @@ function ActionsList({
|
|
|
33
74
|
key: item.item.id,
|
|
34
75
|
action: item.item,
|
|
35
76
|
hovered: item.index === hovered,
|
|
36
|
-
onMouseEnter: onActionHover,
|
|
37
77
|
classNames,
|
|
38
78
|
styles,
|
|
39
79
|
radius,
|
|
@@ -49,13 +89,13 @@ function ActionsList({
|
|
|
49
89
|
}, item.label);
|
|
50
90
|
});
|
|
51
91
|
const shouldRenderActions = items.length > 0 || !!nothingFoundMessage && query.trim().length > 0;
|
|
52
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, shouldRenderActions && /* @__PURE__ */ React__default.createElement("div", {
|
|
92
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, shouldRenderActions && /* @__PURE__ */ React__default.createElement("div", __spreadValues({
|
|
53
93
|
className: classes.actions
|
|
54
|
-
}, items.length > 0 ? items : /* @__PURE__ */ React__default.createElement(core.Text, {
|
|
55
|
-
|
|
94
|
+
}, others), items.length > 0 ? items : /* @__PURE__ */ React__default.createElement(core.Text, {
|
|
95
|
+
c: "dimmed",
|
|
56
96
|
className: classes.nothingFound,
|
|
57
|
-
|
|
58
|
-
|
|
97
|
+
ta: "center",
|
|
98
|
+
fz: "lg",
|
|
59
99
|
py: "md"
|
|
60
100
|
}, nothingFoundMessage)));
|
|
61
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, Selectors, Text, MantineNumberSize, MantineColor } from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';\nimport useStyles from './ActionsList.styles';\n\nexport type ActionsListStylesNames = Selectors<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
|
|
1
|
+
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, Selectors, Text, MantineNumberSize, MantineColor } from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';\nimport useStyles from './ActionsList.styles';\n\nexport type ActionsListStylesNames = Selectors<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\n extends DefaultProps<ActionsListStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n actions: (GetGroupOptionsItem<SpotlightAction[]> | GetGroupOptionsLabel)[];\n actionComponent?: React.FC<DefaultActionProps>;\n hovered: number;\n query: string;\n nothingFoundMessage?: React.ReactNode;\n onActionTrigger(action: SpotlightAction): void;\n highlightQuery: boolean;\n highlightColor: MantineColor;\n radius: MantineNumberSize;\n variant: string;\n}\n\nexport function ActionsList({\n actions,\n styles,\n classNames,\n actionComponent: Action,\n hovered,\n onActionTrigger,\n query,\n nothingFoundMessage,\n highlightQuery,\n highlightColor,\n radius,\n variant,\n ...others\n}: ActionsListProps) {\n const { classes } = useStyles(null, { name: 'Spotlight', classNames, styles, variant });\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 classNames={classNames}\n styles={styles}\n radius={radius}\n onTrigger={() => onActionTrigger(item.item)}\n highlightQuery={highlightQuery}\n highlightColor={highlightColor}\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} {...others}>\n {items.length > 0 ? (\n items\n ) : (\n <Text c=\"dimmed\" className={classes.nothingFound} ta=\"center\" fz=\"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":";;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YA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ACnF,IAAI,CAAC,EAAE,QAAQ;AACf,IAAI,SAAS,EAAE,OAAO,CAAC,YAAY;AACnC,IAAI,EAAE,EAAE,QAAQ;AAChB,IAAI,EAAE,EAAE,IAAI;AACZ,IAAI,EAAE,EAAE,IAAI;AACZ,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,gCAAgC;;;;"}
|
|
@@ -48,8 +48,7 @@ function DefaultAction(_a) {
|
|
|
48
48
|
highlightQuery,
|
|
49
49
|
highlightColor,
|
|
50
50
|
query,
|
|
51
|
-
radius
|
|
52
|
-
onMouseEnter
|
|
51
|
+
radius
|
|
53
52
|
} = _b, others = __objRest(_b, [
|
|
54
53
|
"action",
|
|
55
54
|
"styles",
|
|
@@ -59,39 +58,29 @@ function DefaultAction(_a) {
|
|
|
59
58
|
"highlightQuery",
|
|
60
59
|
"highlightColor",
|
|
61
60
|
"query",
|
|
62
|
-
"radius"
|
|
63
|
-
"onMouseEnter"
|
|
61
|
+
"radius"
|
|
64
62
|
]);
|
|
65
63
|
const { classes } = DefaultAction_styles['default']({ radius }, { styles, classNames, name: "Spotlight" });
|
|
66
|
-
const [shouldBeHovered, setShouldBeHovered] = React.useState(false);
|
|
67
|
-
const [isMouseOver, setIsMouseOver] = React.useState(false);
|
|
68
|
-
React.useEffect(() => {
|
|
69
|
-
const timeout = window.setTimeout(() => setShouldBeHovered(true), 300);
|
|
70
|
-
return () => window.clearTimeout(timeout);
|
|
71
|
-
}, []);
|
|
72
64
|
return /* @__PURE__ */ React__default.createElement(core.UnstyledButton, __spreadValues({
|
|
73
65
|
className: classes.action,
|
|
74
|
-
"data-hovered": hovered ||
|
|
66
|
+
"data-hovered": hovered || void 0,
|
|
75
67
|
tabIndex: -1,
|
|
76
68
|
onMouseDown: (event) => event.preventDefault(),
|
|
77
|
-
onClick: onTrigger
|
|
78
|
-
onMouseEnter: (event) => {
|
|
79
|
-
onMouseEnter == null ? void 0 : onMouseEnter(event);
|
|
80
|
-
shouldBeHovered && setIsMouseOver(true);
|
|
81
|
-
},
|
|
82
|
-
onMouseLeave: () => setIsMouseOver(false)
|
|
69
|
+
onClick: onTrigger
|
|
83
70
|
}, others), /* @__PURE__ */ React__default.createElement(core.Group, {
|
|
84
71
|
noWrap: true
|
|
85
72
|
}, action.icon && /* @__PURE__ */ React__default.createElement(core.Center, {
|
|
86
|
-
className: classes.actionIcon
|
|
73
|
+
className: classes.actionIcon,
|
|
74
|
+
"data-hovered": hovered || void 0
|
|
87
75
|
}, action.icon), /* @__PURE__ */ React__default.createElement("div", {
|
|
88
76
|
className: classes.actionBody
|
|
89
77
|
}, /* @__PURE__ */ React__default.createElement(core.Highlight, {
|
|
90
78
|
highlightColor,
|
|
91
79
|
highlight: highlightQuery ? query : null
|
|
92
80
|
}, action.title), action.description && /* @__PURE__ */ React__default.createElement(core.Text, {
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
size: "xs",
|
|
82
|
+
className: classes.actionDescription,
|
|
83
|
+
"data-hovered": hovered || void 0
|
|
95
84
|
}, action.description))));
|
|
96
85
|
}
|
|
97
86
|
DefaultAction.displayName = "@mantine/spotlight/DefaultAction";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.js","sources":["../../src/DefaultAction/DefaultAction.tsx"],"sourcesContent":["import React
|
|
1
|
+
{"version":3,"file":"DefaultAction.js","sources":["../../src/DefaultAction/DefaultAction.tsx"],"sourcesContent":["import React from 'react';\nimport {\n DefaultProps,\n Selectors,\n Highlight,\n UnstyledButton,\n Group,\n Center,\n Text,\n MantineNumberSize,\n MantineColor,\n} from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport useStyles from './DefaultAction.styles';\n\nexport type DefaultActionStylesNames = Selectors<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 highlightColor: MantineColor;\n query: string;\n radius: MantineNumberSize;\n}\n\nexport function DefaultAction({\n action,\n styles,\n classNames,\n hovered,\n onTrigger,\n highlightQuery,\n highlightColor,\n query,\n radius,\n ...others\n}: DefaultActionProps) {\n const { classes } = useStyles({ radius }, { styles, classNames, name: 'Spotlight' });\n\n return (\n <UnstyledButton\n className={classes.action}\n data-hovered={hovered || undefined}\n tabIndex={-1}\n onMouseDown={(event) => event.preventDefault()}\n onClick={onTrigger}\n {...others}\n >\n <Group noWrap>\n {action.icon && (\n <Center className={classes.actionIcon} data-hovered={hovered || undefined}>\n {action.icon}\n </Center>\n )}\n\n <div className={classes.actionBody}>\n <Highlight highlightColor={highlightColor} highlight={highlightQuery ? query : null}>\n {action.title}\n </Highlight>\n\n {action.description && (\n <Text\n size=\"xs\"\n className={classes.actionDescription}\n data-hovered={hovered || undefined}\n >\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;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,IAAI,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O,IAAI,KAAK,CAAC;AACrC,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,cAAc;AAClB,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,IAAI,EAAE,IAAI;AACd,IAAI,SAAS,EAAE,OAAO,CAAC,iBAAiB;AACxC,IAAI,cAAc,EAAE,OAAO,IAAI,KAAK,CAAC;AACrC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,aAAa,CAAC,WAAW,GAAG,kCAAkC;;;;"}
|
|
@@ -4,19 +4,55 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@mantine/core');
|
|
6
6
|
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
26
|
var useStyles = core.createStyles((theme, { radius }) => ({
|
|
8
|
-
action: {
|
|
27
|
+
action: __spreadProps(__spreadValues({
|
|
9
28
|
position: "relative",
|
|
10
29
|
display: "block",
|
|
11
30
|
width: "100%",
|
|
12
31
|
padding: `${core.rem(10)} ${core.rem(12)}`,
|
|
13
|
-
borderRadius: theme.fn.radius(radius)
|
|
32
|
+
borderRadius: theme.fn.radius(radius)
|
|
33
|
+
}, theme.fn.hover({
|
|
34
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]
|
|
35
|
+
})), {
|
|
36
|
+
"&[data-hovered]": __spreadValues({
|
|
37
|
+
backgroundColor: theme.fn.primaryColor(),
|
|
38
|
+
color: theme.white
|
|
39
|
+
}, theme.fn.hover({
|
|
40
|
+
backgroundColor: theme.fn.primaryColor()
|
|
41
|
+
}))
|
|
42
|
+
}),
|
|
43
|
+
actionDescription: {
|
|
44
|
+
color: theme.fn.dimmed(),
|
|
14
45
|
"&[data-hovered]": {
|
|
15
|
-
|
|
46
|
+
color: theme.white,
|
|
47
|
+
opacity: 0.7
|
|
16
48
|
}
|
|
17
49
|
},
|
|
18
50
|
actionIcon: {
|
|
19
|
-
color: theme.colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6]
|
|
51
|
+
color: theme.colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6],
|
|
52
|
+
"&[data-hovered]": {
|
|
53
|
+
color: theme.white,
|
|
54
|
+
opacity: 0.7
|
|
55
|
+
}
|
|
20
56
|
},
|
|
21
57
|
actionBody: {}
|
|
22
58
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize, rem } 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: `${rem(10)} ${rem(12)}`,\n borderRadius: theme.fn.radius(radius),\n
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize, rem } 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: `${rem(10)} ${rem(12)}`,\n borderRadius: theme.fn.radius(radius),\n ...theme.fn.hover({\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[1],\n }),\n\n '&[data-hovered]': {\n backgroundColor: theme.fn.primaryColor(),\n color: theme.white,\n ...theme.fn.hover({\n backgroundColor: theme.fn.primaryColor(),\n }),\n },\n },\n\n actionDescription: {\n color: theme.fn.dimmed(),\n\n '&[data-hovered]': {\n color: theme.white,\n opacity: 0.7,\n },\n },\n\n actionIcon: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[2] : theme.colors.gray[6],\n\n '&[data-hovered]': {\n color: theme.white,\n opacity: 0.7,\n },\n },\n\n actionBody: {},\n}));\n"],"names":["createStyles","rem"],"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,C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BAAiB,EAAE;AACvB,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK;AACxB,MAAM,OAAO,EAAE,GAAG;AAClB,KAAK;AACL,GAAG;AACH,EAAE,UAAU,EAAE,EAAE;AAChB,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -114,11 +114,10 @@ function Spotlight(props) {
|
|
|
114
114
|
"target",
|
|
115
115
|
"radius"
|
|
116
116
|
]);
|
|
117
|
-
const [shouldReset, setShouldReset] = React.useState(false);
|
|
118
117
|
const [hovered, setHovered] = React.useState(-1);
|
|
119
118
|
const [IMEOpen, setIMEOpen] = React.useState(false);
|
|
120
119
|
const { classes, cx } = Spotlight_styles['default'](null, { name: "Spotlight", classNames, styles, variant });
|
|
121
|
-
const resetHovered = () =>
|
|
120
|
+
const resetHovered = () => setHovered(-1);
|
|
122
121
|
const handleClose = () => {
|
|
123
122
|
resetHovered();
|
|
124
123
|
onClose();
|
|
@@ -131,17 +130,6 @@ function Spotlight(props) {
|
|
|
131
130
|
setHovered(groupedActions.length - 1);
|
|
132
131
|
}
|
|
133
132
|
}, [groupedActions.length]);
|
|
134
|
-
hooks.useDidUpdate(() => {
|
|
135
|
-
let timeout = -1;
|
|
136
|
-
if (opened) {
|
|
137
|
-
timeout = window.setTimeout(() => setShouldReset(true), 300);
|
|
138
|
-
return () => {
|
|
139
|
-
window.clearTimeout(timeout);
|
|
140
|
-
setShouldReset(false);
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return () => setShouldReset(false);
|
|
144
|
-
}, [opened]);
|
|
145
133
|
const handleInputKeyDown = (event) => {
|
|
146
134
|
var _a2, _b;
|
|
147
135
|
if (IMEOpen) {
|
|
@@ -210,7 +198,6 @@ function Spotlight(props) {
|
|
|
210
198
|
hovered,
|
|
211
199
|
query,
|
|
212
200
|
nothingFoundMessage,
|
|
213
|
-
onActionHover: () => setHovered(-1),
|
|
214
201
|
onActionTrigger: (action) => {
|
|
215
202
|
var _a2;
|
|
216
203
|
action.onTrigger(action);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spotlight.js","sources":["../../src/Spotlight/Spotlight.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n DefaultProps,\n Selectors,\n TextInput,\n getDefaultZIndex,\n MantineColor,\n TextInputProps,\n Modal,\n ModalProps,\n ModalStylesNames,\n useComponentDefaultProps,\n ScrollArea,\n ScrollAreaAutosizeProps,\n} from '@mantine/core';\nimport { getGroupedOptions } from '@mantine/utils';\nimport { useDidUpdate } 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\nfunction SpotlightScrollArea(props: ScrollAreaAutosizeProps) {\n return <ScrollArea.Autosize mah=\"calc(100vh - 18rem)\" {...props} />;\n}\n\nexport type SpotlightStylesNames =\n | Selectors<typeof useStyles>\n | Exclude<ModalStylesNames, 'close' | 'header' | 'title'>\n | ActionsListStylesNames;\n\nexport interface InnerSpotlightProps\n extends Omit<\n ModalProps,\n 'styles' | 'classNames' | 'title' | 'withCloseButton' | 'opened' | 'onClose'\n >,\n DefaultProps<SpotlightStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n variant?: string;\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 /** Should user query be highlighted in actions title */\n highlightQuery?: boolean;\n\n /** The highlight color */\n highlightColor?: MantineColor;\n\n /** Props spread to search input */\n searchInputProps?: TextInputProps;\n\n /** Component used as scrollable container for actions list, defaults to ScrollArea.Autosize */\n scrollAreaComponent?: React.FC<{ children: React.ReactNode }>;\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\nconst defaultProps: Partial<SpotlightProps> = {\n closeOnActionTrigger: true,\n highlightQuery: false,\n size: 600,\n yOffset: 120,\n filter: filterActions,\n limit: 10,\n actionComponent: DefaultAction,\n scrollAreaComponent: SpotlightScrollArea,\n actionsWrapperComponent: 'div',\n zIndex: getDefaultZIndex('max'),\n overlayProps: { opacity: 0.2, blur: 7 },\n};\n\nexport function Spotlight(props: SpotlightProps) {\n const {\n query,\n onQueryChange,\n actions,\n onClose,\n opened,\n classNames,\n styles,\n closeOnActionTrigger,\n highlightQuery,\n highlightColor,\n className,\n searchPlaceholder,\n searchIcon,\n filter,\n nothingFoundMessage,\n limit,\n actionComponent,\n actionsWrapperComponent: ActionsWrapper,\n scrollAreaComponent: ScrollAreaComponent,\n searchInputProps,\n variant,\n target,\n radius,\n ...others\n } = useComponentDefaultProps('Spotlight', defaultProps, props);\n\n const [shouldReset, setShouldReset] = useState(false);\n const [hovered, setHovered] = useState(-1);\n const [IMEOpen, setIMEOpen] = useState(false);\n const { classes, cx } = useStyles(null, { name: 'Spotlight', classNames, styles, variant });\n\n const resetHovered = () => shouldReset && setHovered(-1);\n const handleClose = () => {\n resetHovered();\n onClose();\n };\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 useDidUpdate(() => {\n let timeout = -1;\n if (opened) {\n timeout = window.setTimeout(() => setShouldReset(true), 300);\n return () => {\n window.clearTimeout(timeout);\n setShouldReset(false);\n };\n }\n\n return () => setShouldReset(false);\n }, [opened]);\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (IMEOpen) {\n return;\n }\n\n switch (event.key) {\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 ((action?.closeOnTrigger ?? 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 <Modal\n opened={opened}\n onClose={handleClose}\n padding={0}\n radius={radius}\n scrollAreaComponent={Modal.NativeScrollArea}\n classNames={{\n ...classNames,\n content: cx(classes.content, classNames?.content),\n }}\n styles={styles}\n withCloseButton={false}\n {...others}\n >\n <TextInput\n size=\"lg\"\n {...searchInputProps}\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n onCompositionStart={() => setIMEOpen(true)}\n onCompositionEnd={() => setIMEOpen(false)}\n classNames={{ input: classes.searchInput }}\n placeholder={searchPlaceholder}\n icon={searchIcon}\n onMouseEnter={resetHovered}\n />\n <ActionsWrapper>\n <ScrollAreaComponent>\n <ActionsList\n highlightQuery={highlightQuery}\n highlightColor={highlightColor}\n actions={groupedWithLabels}\n actionComponent={actionComponent}\n hovered={hovered}\n query={query}\n nothingFoundMessage={nothingFoundMessage}\n onActionHover={() => setHovered(-1)}\n onActionTrigger={(action) => {\n action.onTrigger(action);\n (action.closeOnTrigger ?? closeOnActionTrigger) && handleClose();\n }}\n styles={styles}\n classNames={classNames}\n radius={radius}\n variant={variant}\n />\n </ScrollAreaComponent>\n </ActionsWrapper>\n </Modal>\n );\n}\n\nSpotlight.displayName = '@mantine/spotlight/Spotlight';\n"],"names":["React","ScrollArea","filterActions","DefaultAction","getDefaultZIndex","useComponentDefaultProps","useState","useStyles","getGroupedOptions","useDidUpdate","Modal","TextInput","ActionsList"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE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,mBAAmB,EAAE,IAAI,kBAAkBA,cAAK,CAAC,aAAa,CAACY,uBAAW,EAAE;AACjL,IAAI,cAAc;AAClB,IAAI,cAAc;AAClB,IAAI,OAAO,EAAE,iBAAiB;AAC9B,IAAI,eAAe;AACnB,IAAI,OAAO;AACX,IAAI,KAAK;AACT,IAAI,mBAAmB;AACvB,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC;AACvC,IAAI,eAAe,EAAE,CAAC,MAAM,KAAK;AACjC,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,cAAc,KAAK,IAAI,GAAG,GAAG,GAAG,oBAAoB,KAAK,WAAW,EAAE,CAAC;AAC5F,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,MAAM;AACV,IAAI,OAAO;AACX,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACR,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 DefaultProps,\n Selectors,\n TextInput,\n getDefaultZIndex,\n MantineColor,\n TextInputProps,\n Modal,\n ModalProps,\n ModalStylesNames,\n useComponentDefaultProps,\n ScrollArea,\n ScrollAreaAutosizeProps,\n} from '@mantine/core';\nimport { getGroupedOptions } from '@mantine/utils';\nimport { useDidUpdate } 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\nfunction SpotlightScrollArea(props: ScrollAreaAutosizeProps) {\n return <ScrollArea.Autosize mah=\"calc(100vh - 18rem)\" {...props} />;\n}\n\nexport type SpotlightStylesNames =\n | Selectors<typeof useStyles>\n | Exclude<ModalStylesNames, 'close' | 'header' | 'title'>\n | ActionsListStylesNames;\n\nexport interface InnerSpotlightProps\n extends Omit<\n ModalProps,\n 'styles' | 'classNames' | 'title' | 'withCloseButton' | 'opened' | 'onClose'\n >,\n DefaultProps<SpotlightStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n variant?: string;\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 /** Should user query be highlighted in actions title */\n highlightQuery?: boolean;\n\n /** The highlight color */\n highlightColor?: MantineColor;\n\n /** Props spread to search input */\n searchInputProps?: TextInputProps;\n\n /** Component used as scrollable container for actions list, defaults to ScrollArea.Autosize */\n scrollAreaComponent?: React.FC<{ children: React.ReactNode }>;\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\nconst defaultProps: Partial<SpotlightProps> = {\n closeOnActionTrigger: true,\n highlightQuery: false,\n size: 600,\n yOffset: 120,\n filter: filterActions,\n limit: 10,\n actionComponent: DefaultAction,\n scrollAreaComponent: SpotlightScrollArea,\n actionsWrapperComponent: 'div',\n zIndex: getDefaultZIndex('max'),\n overlayProps: { opacity: 0.2, blur: 7 },\n};\n\nexport function Spotlight(props: SpotlightProps) {\n const {\n query,\n onQueryChange,\n actions,\n onClose,\n opened,\n classNames,\n styles,\n closeOnActionTrigger,\n highlightQuery,\n highlightColor,\n className,\n searchPlaceholder,\n searchIcon,\n filter,\n nothingFoundMessage,\n limit,\n actionComponent,\n actionsWrapperComponent: ActionsWrapper,\n scrollAreaComponent: ScrollAreaComponent,\n searchInputProps,\n variant,\n target,\n radius,\n ...others\n } = useComponentDefaultProps('Spotlight', defaultProps, props);\n\n const [hovered, setHovered] = useState(-1);\n const [IMEOpen, setIMEOpen] = useState(false);\n const { classes, cx } = useStyles(null, { name: 'Spotlight', classNames, styles, variant });\n\n const resetHovered = () => setHovered(-1);\n const handleClose = () => {\n resetHovered();\n onClose();\n };\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 if (IMEOpen) {\n return;\n }\n\n switch (event.key) {\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 ((action?.closeOnTrigger ?? 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 <Modal\n opened={opened}\n onClose={handleClose}\n padding={0}\n radius={radius}\n scrollAreaComponent={Modal.NativeScrollArea}\n classNames={{\n ...classNames,\n content: cx(classes.content, classNames?.content),\n }}\n styles={styles}\n withCloseButton={false}\n {...others}\n >\n <TextInput\n size=\"lg\"\n {...searchInputProps}\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n onCompositionStart={() => setIMEOpen(true)}\n onCompositionEnd={() => setIMEOpen(false)}\n classNames={{ input: classes.searchInput }}\n placeholder={searchPlaceholder}\n icon={searchIcon}\n onMouseEnter={resetHovered}\n />\n <ActionsWrapper>\n <ScrollAreaComponent>\n <ActionsList\n highlightQuery={highlightQuery}\n highlightColor={highlightColor}\n actions={groupedWithLabels}\n actionComponent={actionComponent}\n hovered={hovered}\n query={query}\n nothingFoundMessage={nothingFoundMessage}\n onActionTrigger={(action) => {\n action.onTrigger(action);\n (action.closeOnTrigger ?? closeOnActionTrigger) && handleClose();\n }}\n styles={styles}\n classNames={classNames}\n radius={radius}\n variant={variant}\n />\n </ScrollAreaComponent>\n </ActionsWrapper>\n </Modal>\n );\n}\n\nSpotlight.displayName = '@mantine/spotlight/Spotlight';\n"],"names":["React","ScrollArea","filterActions","DefaultAction","getDefaultZIndex","useComponentDefaultProps","useState","useStyles","getGroupedOptions","useDidUpdate","Modal","TextInput","ActionsList"],"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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AAClB,IAAI,OAAO,EAAE,iBAAiB;AAC9B,IAAI,eAAe;AACnB,IAAI,OAAO;AACX,IAAI,KAAK;AACT,IAAI,mBAAmB;AACvB,IAAI,eAAe,EAAE,CAAC,MAAM,KAAK;AACjC,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,cAAc,KAAK,IAAI,GAAG,GAAG,GAAG,oBAAoB,KAAK,WAAW,EAAE,CAAC;AAC5F,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,MAAM;AACV,IAAI,OAAO;AACX,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACR,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
package/cjs/SpotlightProvider.js
CHANGED
|
@@ -55,7 +55,8 @@ function SpotlightProvider(_a) {
|
|
|
55
55
|
cleanQueryOnClose = true,
|
|
56
56
|
transitionDuration = 150,
|
|
57
57
|
disabled = false,
|
|
58
|
-
tagsToIgnore = ["INPUT", "TEXTAREA", "SELECT"]
|
|
58
|
+
tagsToIgnore = ["INPUT", "TEXTAREA", "SELECT"],
|
|
59
|
+
triggerOnContentEditable = false
|
|
59
60
|
} = _b, others = __objRest(_b, [
|
|
60
61
|
"actions",
|
|
61
62
|
"children",
|
|
@@ -68,7 +69,8 @@ function SpotlightProvider(_a) {
|
|
|
68
69
|
"cleanQueryOnClose",
|
|
69
70
|
"transitionDuration",
|
|
70
71
|
"disabled",
|
|
71
|
-
"tagsToIgnore"
|
|
72
|
+
"tagsToIgnore",
|
|
73
|
+
"triggerOnContentEditable"
|
|
72
74
|
]);
|
|
73
75
|
const timeoutRef = React.useRef(-1);
|
|
74
76
|
const [_query, setQuery] = hooks.useUncontrolled({
|
|
@@ -110,7 +112,7 @@ function SpotlightProvider(_a) {
|
|
|
110
112
|
actions: _actions,
|
|
111
113
|
query: _query
|
|
112
114
|
};
|
|
113
|
-
useSpotlightShortcuts.useSpotlightShortcuts(shortcut, open, tagsToIgnore);
|
|
115
|
+
useSpotlightShortcuts.useSpotlightShortcuts(shortcut, open, tagsToIgnore, triggerOnContentEditable);
|
|
114
116
|
events.useSpotlightEvents({ open, close, toggle, registerActions, removeActions, triggerAction });
|
|
115
117
|
return /* @__PURE__ */ React__default.createElement(Spotlight_context.SpotlightContext.Provider, {
|
|
116
118
|
value: ctx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpotlightProvider.js","sources":["../src/SpotlightProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { useDisclosure, useUncontrolled } from '@mantine/hooks';\nimport { useSpotlightEvents } from './events';\nimport { SpotlightContext } from './Spotlight.context';\nimport { InnerSpotlightProps, Spotlight } from './Spotlight/Spotlight';\nimport type { SpotlightAction } from './types';\nimport { useActionsState } from './use-actions-state/use-actions-state';\nimport { useSpotlightShortcuts } from './use-spotlight-shortcuts/use-spotlight-shortcuts';\n\nexport interface SpotlightProviderProps extends InnerSpotlightProps {\n /** Actions list */\n actions: SpotlightAction[];\n\n /** Called when actions change (registered or removed) */\n onActionsChange?(actions: SpotlightAction[]): void;\n\n /** Controlled search query */\n query?: string;\n\n /** Called when user enters text in search input */\n onQueryChange?(query: string): void;\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 /** 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 /** Spotlight will not render if disabled is set to true */\n disabled?: boolean;\n\n /** Tags to ignore shortcut hotkeys on. */\n tagsToIgnore?: string[];\n}\n\nexport function SpotlightProvider({\n actions,\n children,\n shortcut = 'mod + K',\n query,\n onSpotlightClose,\n onSpotlightOpen,\n onQueryChange,\n onActionsChange,\n cleanQueryOnClose = true,\n transitionDuration = 150,\n disabled = false,\n tagsToIgnore = ['INPUT', 'TEXTAREA', 'SELECT'],\n ...others\n}: SpotlightProviderProps) {\n const timeoutRef = useRef<number>(-1);\n\n const [_query, setQuery] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onQueryChange,\n });\n\n const [_actions, { registerActions, removeActions, triggerAction }] = useActionsState({\n actions,\n onActionsChange,\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 const ctx = {\n openSpotlight: open,\n closeSpotlight: close,\n toggleSpotlight: toggle,\n registerActions,\n removeActions,\n triggerAction,\n opened,\n actions: _actions,\n query: _query,\n };\n\n useSpotlightShortcuts(shortcut, open, tagsToIgnore);\n useSpotlightEvents({ open, close, toggle, registerActions, removeActions, triggerAction });\n\n return (\n <SpotlightContext.Provider value={ctx}>\n {!disabled && (\n <Spotlight\n actions={_actions}\n onClose={close}\n opened={opened}\n query={_query}\n onQueryChange={handleQueryChange}\n transitionDuration={transitionDuration}\n {...others}\n />\n )}\n {children}\n </SpotlightContext.Provider>\n );\n}\n\nSpotlightProvider.displayName = '@mantine/spotlight/SpotlightProvider';\n"],"names":["useRef","useUncontrolled","useActionsState","useDisclosure","useSpotlightShortcuts","useSpotlightEvents","React","SpotlightContext","Spotlight"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI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;AACzB,IAAI,eAAe,EAAE,MAAM;AAC3B,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,MAAM;AACV,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,KAAK,EAAE,MAAM;AACjB,GAAG,CAAC;AACJ,EAAEC,2CAAqB,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SpotlightProvider.js","sources":["../src/SpotlightProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { useDisclosure, useUncontrolled } from '@mantine/hooks';\nimport { useSpotlightEvents } from './events';\nimport { SpotlightContext } from './Spotlight.context';\nimport { InnerSpotlightProps, Spotlight } from './Spotlight/Spotlight';\nimport type { SpotlightAction } from './types';\nimport { useActionsState } from './use-actions-state/use-actions-state';\nimport { useSpotlightShortcuts } from './use-spotlight-shortcuts/use-spotlight-shortcuts';\n\nexport interface SpotlightProviderProps extends InnerSpotlightProps {\n /** Actions list */\n actions: SpotlightAction[];\n\n /** Called when actions change (registered or removed) */\n onActionsChange?(actions: SpotlightAction[]): void;\n\n /** Controlled search query */\n query?: string;\n\n /** Called when user enters text in search input */\n onQueryChange?(query: string): void;\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 /** 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 /** Spotlight will not render if disabled is set to true */\n disabled?: boolean;\n\n /** Tags to ignore shortcut hotkeys on. */\n tagsToIgnore?: string[];\n\n /** Whether shortcuts should trigger based on contentEditable. */\n triggerOnContentEditable?: boolean;\n}\n\nexport function SpotlightProvider({\n actions,\n children,\n shortcut = 'mod + K',\n query,\n onSpotlightClose,\n onSpotlightOpen,\n onQueryChange,\n onActionsChange,\n cleanQueryOnClose = true,\n transitionDuration = 150,\n disabled = false,\n tagsToIgnore = ['INPUT', 'TEXTAREA', 'SELECT'],\n triggerOnContentEditable = false,\n ...others\n}: SpotlightProviderProps) {\n const timeoutRef = useRef<number>(-1);\n\n const [_query, setQuery] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onQueryChange,\n });\n\n const [_actions, { registerActions, removeActions, triggerAction }] = useActionsState({\n actions,\n onActionsChange,\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 const ctx = {\n openSpotlight: open,\n closeSpotlight: close,\n toggleSpotlight: toggle,\n registerActions,\n removeActions,\n triggerAction,\n opened,\n actions: _actions,\n query: _query,\n };\n\n useSpotlightShortcuts(shortcut, open, tagsToIgnore, triggerOnContentEditable);\n useSpotlightEvents({ open, close, toggle, registerActions, removeActions, triggerAction });\n\n return (\n <SpotlightContext.Provider value={ctx}>\n {!disabled && (\n <Spotlight\n actions={_actions}\n onClose={close}\n opened={opened}\n query={_query}\n onQueryChange={handleQueryChange}\n transitionDuration={transitionDuration}\n {...others}\n />\n )}\n {children}\n </SpotlightContext.Provider>\n );\n}\n\nSpotlightProvider.displayName = '@mantine/spotlight/SpotlightProvider';\n"],"names":["useRef","useUncontrolled","useActionsState","useDisclosure","useSpotlightShortcuts","useSpotlightEvents","React","SpotlightContext","Spotlight"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,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,MAAM,GAAG,GAAG;AACd,IAAI,aAAa,EAAE,IAAI;AACvB,IAAI,cAAc,EAAE,KAAK;AACzB,IAAI,eAAe,EAAE,MAAM;AAC3B,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,MAAM;AACV,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,KAAK,EAAE,MAAM;AACjB,GAAG,CAAC;AACJ,EAAEC,2CAAqB,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;AAChF,EAAEC,yBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC;AAC7F,EAAE,uBAAuBC,cAAK,CAAC,aAAa,CAACC,kCAAgB,CAAC,QAAQ,EAAE;AACxE,IAAI,KAAK,EAAE,GAAG;AACd,GAAG,EAAE,CAAC,QAAQ,oBAAoBD,cAAK,CAAC,aAAa,CAACE,mBAAS,EAAE,cAAc,CAAC;AAChF,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,MAAM;AACV,IAAI,KAAK,EAAE,MAAM;AACjB,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;;;;"}
|
|
@@ -13,8 +13,8 @@ function getHotkeysPayload(shortcuts, onToggle) {
|
|
|
13
13
|
}
|
|
14
14
|
return [[shortcuts, onToggle]];
|
|
15
15
|
}
|
|
16
|
-
function useSpotlightShortcuts(shortcuts, onToggle, tagsToIgnore) {
|
|
17
|
-
hooks.useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore);
|
|
16
|
+
function useSpotlightShortcuts(shortcuts, onToggle, tagsToIgnore, triggerOnContentEditable) {
|
|
17
|
+
hooks.useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore, triggerOnContentEditable);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.getHotkeysPayload = getHotkeysPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-spotlight-shortcuts.js","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"sourcesContent":["import { HotkeyItem, useHotkeys } 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(\n shortcuts: string | string[],\n onToggle: () => void,\n tagsToIgnore?: string[]\n) {\n useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore);\n}\n"],"names":["useHotkeys"],"mappings":";;;;;;AACO,SAAS,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE;AACvD,EAAE,IAAI,SAAS,KAAK,IAAI,EAAE;AAC1B,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AAChC,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7D,GAAG;AACH,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjC,CAAC;AACM,SAAS,qBAAqB,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"use-spotlight-shortcuts.js","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"sourcesContent":["import { HotkeyItem, useHotkeys } 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(\n shortcuts: string | string[],\n onToggle: () => void,\n tagsToIgnore?: string[],\n triggerOnContentEditable?: boolean\n) {\n useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore, triggerOnContentEditable);\n}\n"],"names":["useHotkeys"],"mappings":";;;;;;AACO,SAAS,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE;AACvD,EAAE,IAAI,SAAS,KAAK,IAAI,EAAE;AAC1B,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AAChC,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7D,GAAG;AACH,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjC,CAAC;AACM,SAAS,qBAAqB,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE;AACnG,EAAEA,gBAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;AAC7F;;;;;"}
|
|
@@ -2,21 +2,62 @@ import React from 'react';
|
|
|
2
2
|
import { Text } from '@mantine/core';
|
|
3
3
|
import useStyles from './ActionsList.styles.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
function ActionsList(_a) {
|
|
34
|
+
var _b = _a, {
|
|
35
|
+
actions,
|
|
36
|
+
styles,
|
|
37
|
+
classNames,
|
|
38
|
+
actionComponent: Action,
|
|
39
|
+
hovered,
|
|
40
|
+
onActionTrigger,
|
|
41
|
+
query,
|
|
42
|
+
nothingFoundMessage,
|
|
43
|
+
highlightQuery,
|
|
44
|
+
highlightColor,
|
|
45
|
+
radius,
|
|
46
|
+
variant
|
|
47
|
+
} = _b, others = __objRest(_b, [
|
|
48
|
+
"actions",
|
|
49
|
+
"styles",
|
|
50
|
+
"classNames",
|
|
51
|
+
"actionComponent",
|
|
52
|
+
"hovered",
|
|
53
|
+
"onActionTrigger",
|
|
54
|
+
"query",
|
|
55
|
+
"nothingFoundMessage",
|
|
56
|
+
"highlightQuery",
|
|
57
|
+
"highlightColor",
|
|
58
|
+
"radius",
|
|
59
|
+
"variant"
|
|
60
|
+
]);
|
|
20
61
|
const { classes } = useStyles(null, { name: "Spotlight", classNames, styles, variant });
|
|
21
62
|
const items = actions.map((item) => {
|
|
22
63
|
if (item.type === "item") {
|
|
@@ -25,7 +66,6 @@ function ActionsList({
|
|
|
25
66
|
key: item.item.id,
|
|
26
67
|
action: item.item,
|
|
27
68
|
hovered: item.index === hovered,
|
|
28
|
-
onMouseEnter: onActionHover,
|
|
29
69
|
classNames,
|
|
30
70
|
styles,
|
|
31
71
|
radius,
|
|
@@ -41,13 +81,13 @@ function ActionsList({
|
|
|
41
81
|
}, item.label);
|
|
42
82
|
});
|
|
43
83
|
const shouldRenderActions = items.length > 0 || !!nothingFoundMessage && query.trim().length > 0;
|
|
44
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldRenderActions && /* @__PURE__ */ React.createElement("div", {
|
|
84
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldRenderActions && /* @__PURE__ */ React.createElement("div", __spreadValues({
|
|
45
85
|
className: classes.actions
|
|
46
|
-
}, items.length > 0 ? items : /* @__PURE__ */ React.createElement(Text, {
|
|
47
|
-
|
|
86
|
+
}, others), items.length > 0 ? items : /* @__PURE__ */ React.createElement(Text, {
|
|
87
|
+
c: "dimmed",
|
|
48
88
|
className: classes.nothingFound,
|
|
49
|
-
|
|
50
|
-
|
|
89
|
+
ta: "center",
|
|
90
|
+
fz: "lg",
|
|
51
91
|
py: "md"
|
|
52
92
|
}, nothingFoundMessage)));
|
|
53
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, Selectors, Text, MantineNumberSize, MantineColor } from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';\nimport useStyles from './ActionsList.styles';\n\nexport type ActionsListStylesNames = Selectors<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
|
|
1
|
+
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, Selectors, Text, MantineNumberSize, MantineColor } from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';\nimport useStyles from './ActionsList.styles';\n\nexport type ActionsListStylesNames = Selectors<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\n extends DefaultProps<ActionsListStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n actions: (GetGroupOptionsItem<SpotlightAction[]> | GetGroupOptionsLabel)[];\n actionComponent?: React.FC<DefaultActionProps>;\n hovered: number;\n query: string;\n nothingFoundMessage?: React.ReactNode;\n onActionTrigger(action: SpotlightAction): void;\n highlightQuery: boolean;\n highlightColor: MantineColor;\n radius: MantineNumberSize;\n variant: string;\n}\n\nexport function ActionsList({\n actions,\n styles,\n classNames,\n actionComponent: Action,\n hovered,\n onActionTrigger,\n query,\n nothingFoundMessage,\n highlightQuery,\n highlightColor,\n radius,\n variant,\n ...others\n}: ActionsListProps) {\n const { classes } = useStyles(null, { name: 'Spotlight', classNames, styles, variant });\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 classNames={classNames}\n styles={styles}\n radius={radius}\n onTrigger={() => onActionTrigger(item.item)}\n highlightQuery={highlightQuery}\n highlightColor={highlightColor}\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} {...others}>\n {items.length > 0 ? (\n items\n ) : (\n <Text c=\"dimmed\" className={classes.nothingFound} ta=\"center\" fz=\"lg\" py=\"md\">\n {nothingFoundMessage}\n </Text>\n )}\n </div>\n )}\n </>\n );\n}\n\nActionsList.displayName = '@mantine/spotlight/ActionsList';\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,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,C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AC,aAAa,CAAC,IAAI,EAAE;AACrD,MAAM,SAAS,EAAE,OAAO,CAAC,YAAY;AACrC,MAAM,KAAK,EAAE,QAAQ;AACrB,MAAM,GAAG,EAAE,IAAI,CAAC,KAAK;AACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;AACnB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,mBAAmB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACnG,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,mBAAmB,oBAAoB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC;AACpJ,IAAI,SAAS,EAAE,OAAO,CAAC,OAAO;AAC9B,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,mBAAmB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE;AACnF,IAAI,CAAC,EAAE,QAAQ;AACf,IAAI,SAAS,EAAE,OAAO,CAAC,YAAY;AACnC,IAAI,EAAE,EAAE,QAAQ;AAChB,IAAI,EAAE,EAAE,IAAI;AACZ,IAAI,EAAE,EAAE,IAAI;AACZ,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,gCAAgC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { UnstyledButton, Group, Center, Highlight, Text } from '@mantine/core';
|
|
3
3
|
import useStyles from './DefaultAction.styles.js';
|
|
4
4
|
|
|
@@ -40,8 +40,7 @@ function DefaultAction(_a) {
|
|
|
40
40
|
highlightQuery,
|
|
41
41
|
highlightColor,
|
|
42
42
|
query,
|
|
43
|
-
radius
|
|
44
|
-
onMouseEnter
|
|
43
|
+
radius
|
|
45
44
|
} = _b, others = __objRest(_b, [
|
|
46
45
|
"action",
|
|
47
46
|
"styles",
|
|
@@ -51,39 +50,29 @@ function DefaultAction(_a) {
|
|
|
51
50
|
"highlightQuery",
|
|
52
51
|
"highlightColor",
|
|
53
52
|
"query",
|
|
54
|
-
"radius"
|
|
55
|
-
"onMouseEnter"
|
|
53
|
+
"radius"
|
|
56
54
|
]);
|
|
57
55
|
const { classes } = useStyles({ radius }, { styles, classNames, name: "Spotlight" });
|
|
58
|
-
const [shouldBeHovered, setShouldBeHovered] = useState(false);
|
|
59
|
-
const [isMouseOver, setIsMouseOver] = useState(false);
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
const timeout = window.setTimeout(() => setShouldBeHovered(true), 300);
|
|
62
|
-
return () => window.clearTimeout(timeout);
|
|
63
|
-
}, []);
|
|
64
56
|
return /* @__PURE__ */ React.createElement(UnstyledButton, __spreadValues({
|
|
65
57
|
className: classes.action,
|
|
66
|
-
"data-hovered": hovered ||
|
|
58
|
+
"data-hovered": hovered || void 0,
|
|
67
59
|
tabIndex: -1,
|
|
68
60
|
onMouseDown: (event) => event.preventDefault(),
|
|
69
|
-
onClick: onTrigger
|
|
70
|
-
onMouseEnter: (event) => {
|
|
71
|
-
onMouseEnter == null ? void 0 : onMouseEnter(event);
|
|
72
|
-
shouldBeHovered && setIsMouseOver(true);
|
|
73
|
-
},
|
|
74
|
-
onMouseLeave: () => setIsMouseOver(false)
|
|
61
|
+
onClick: onTrigger
|
|
75
62
|
}, others), /* @__PURE__ */ React.createElement(Group, {
|
|
76
63
|
noWrap: true
|
|
77
64
|
}, action.icon && /* @__PURE__ */ React.createElement(Center, {
|
|
78
|
-
className: classes.actionIcon
|
|
65
|
+
className: classes.actionIcon,
|
|
66
|
+
"data-hovered": hovered || void 0
|
|
79
67
|
}, action.icon), /* @__PURE__ */ React.createElement("div", {
|
|
80
68
|
className: classes.actionBody
|
|
81
69
|
}, /* @__PURE__ */ React.createElement(Highlight, {
|
|
82
70
|
highlightColor,
|
|
83
71
|
highlight: highlightQuery ? query : null
|
|
84
72
|
}, action.title), action.description && /* @__PURE__ */ React.createElement(Text, {
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
size: "xs",
|
|
74
|
+
className: classes.actionDescription,
|
|
75
|
+
"data-hovered": hovered || void 0
|
|
87
76
|
}, action.description))));
|
|
88
77
|
}
|
|
89
78
|
DefaultAction.displayName = "@mantine/spotlight/DefaultAction";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.js","sources":["../../src/DefaultAction/DefaultAction.tsx"],"sourcesContent":["import React
|
|
1
|
+
{"version":3,"file":"DefaultAction.js","sources":["../../src/DefaultAction/DefaultAction.tsx"],"sourcesContent":["import React from 'react';\nimport {\n DefaultProps,\n Selectors,\n Highlight,\n UnstyledButton,\n Group,\n Center,\n Text,\n MantineNumberSize,\n MantineColor,\n} from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport useStyles from './DefaultAction.styles';\n\nexport type DefaultActionStylesNames = Selectors<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 highlightColor: MantineColor;\n query: string;\n radius: MantineNumberSize;\n}\n\nexport function DefaultAction({\n action,\n styles,\n classNames,\n hovered,\n onTrigger,\n highlightQuery,\n highlightColor,\n query,\n radius,\n ...others\n}: DefaultActionProps) {\n const { classes } = useStyles({ radius }, { styles, classNames, name: 'Spotlight' });\n\n return (\n <UnstyledButton\n className={classes.action}\n data-hovered={hovered || undefined}\n tabIndex={-1}\n onMouseDown={(event) => event.preventDefault()}\n onClick={onTrigger}\n {...others}\n >\n <Group noWrap>\n {action.icon && (\n <Center className={classes.actionIcon} data-hovered={hovered || undefined}>\n {action.icon}\n </Center>\n )}\n\n <div className={classes.actionBody}>\n <Highlight highlightColor={highlightColor} highlight={highlightQuery ? query : null}>\n {action.title}\n </Highlight>\n\n {action.description && (\n <Text\n size=\"xs\"\n className={classes.actionDescription}\n data-hovered={hovered || undefined}\n >\n {action.description}\n </Text>\n )}\n </div>\n </Group>\n </UnstyledButton>\n );\n}\n\nDefaultAction.displayName = '@mantine/spotlight/DefaultAction';\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE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AAE,OAAO,IAAI,KAAK,CAAC;AACrC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,aAAa,CAAC,WAAW,GAAG,kCAAkC;;;;"}
|
|
@@ -1,18 +1,54 @@
|
|
|
1
1
|
import { createStyles, rem } from '@mantine/core';
|
|
2
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));
|
|
3
22
|
var useStyles = createStyles((theme, { radius }) => ({
|
|
4
|
-
action: {
|
|
23
|
+
action: __spreadProps(__spreadValues({
|
|
5
24
|
position: "relative",
|
|
6
25
|
display: "block",
|
|
7
26
|
width: "100%",
|
|
8
27
|
padding: `${rem(10)} ${rem(12)}`,
|
|
9
|
-
borderRadius: theme.fn.radius(radius)
|
|
28
|
+
borderRadius: theme.fn.radius(radius)
|
|
29
|
+
}, theme.fn.hover({
|
|
30
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]
|
|
31
|
+
})), {
|
|
32
|
+
"&[data-hovered]": __spreadValues({
|
|
33
|
+
backgroundColor: theme.fn.primaryColor(),
|
|
34
|
+
color: theme.white
|
|
35
|
+
}, theme.fn.hover({
|
|
36
|
+
backgroundColor: theme.fn.primaryColor()
|
|
37
|
+
}))
|
|
38
|
+
}),
|
|
39
|
+
actionDescription: {
|
|
40
|
+
color: theme.fn.dimmed(),
|
|
10
41
|
"&[data-hovered]": {
|
|
11
|
-
|
|
42
|
+
color: theme.white,
|
|
43
|
+
opacity: 0.7
|
|
12
44
|
}
|
|
13
45
|
},
|
|
14
46
|
actionIcon: {
|
|
15
|
-
color: theme.colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6]
|
|
47
|
+
color: theme.colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6],
|
|
48
|
+
"&[data-hovered]": {
|
|
49
|
+
color: theme.white,
|
|
50
|
+
opacity: 0.7
|
|
51
|
+
}
|
|
16
52
|
},
|
|
17
53
|
actionBody: {}
|
|
18
54
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize, rem } 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: `${rem(10)} ${rem(12)}`,\n borderRadius: theme.fn.radius(radius),\n
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize, rem } 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: `${rem(10)} ${rem(12)}`,\n borderRadius: theme.fn.radius(radius),\n ...theme.fn.hover({\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[1],\n }),\n\n '&[data-hovered]': {\n backgroundColor: theme.fn.primaryColor(),\n color: theme.white,\n ...theme.fn.hover({\n backgroundColor: theme.fn.primaryColor(),\n }),\n },\n },\n\n actionDescription: {\n color: theme.fn.dimmed(),\n\n '&[data-hovered]': {\n color: theme.white,\n opacity: 0.7,\n },\n },\n\n actionIcon: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[2] : theme.colors.gray[6],\n\n '&[data-hovered]': {\n color: theme.white,\n opacity: 0.7,\n },\n },\n\n actionBody: {},\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,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;A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EAAE,cAAc,CAAC;AACtC,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE;AAC9C,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK;AACxB,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;AACtB,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE;AAC9C,KAAK,CAAC,CAAC;AACP,GAAG,CAAC;AACJ,EAAE,iBAAiB,EAAE;AACrB,IAAI,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE;AAC5B,IAAI,iBAAiB,EAAE;AACvB,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK;AACxB,MAAM,OAAO,EAAE,GAAG;AAClB,KAAK;AACL,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,IAAI,iBAAiB,EAAE;AACvB,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK;AACxB,MAAM,OAAO,EAAE,GAAG;AAClB,KAAK;AACL,GAAG;AACH,EAAE,UAAU,EAAE,EAAE;AAChB,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -106,11 +106,10 @@ function Spotlight(props) {
|
|
|
106
106
|
"target",
|
|
107
107
|
"radius"
|
|
108
108
|
]);
|
|
109
|
-
const [shouldReset, setShouldReset] = useState(false);
|
|
110
109
|
const [hovered, setHovered] = useState(-1);
|
|
111
110
|
const [IMEOpen, setIMEOpen] = useState(false);
|
|
112
111
|
const { classes, cx } = useStyles(null, { name: "Spotlight", classNames, styles, variant });
|
|
113
|
-
const resetHovered = () =>
|
|
112
|
+
const resetHovered = () => setHovered(-1);
|
|
114
113
|
const handleClose = () => {
|
|
115
114
|
resetHovered();
|
|
116
115
|
onClose();
|
|
@@ -123,17 +122,6 @@ function Spotlight(props) {
|
|
|
123
122
|
setHovered(groupedActions.length - 1);
|
|
124
123
|
}
|
|
125
124
|
}, [groupedActions.length]);
|
|
126
|
-
useDidUpdate(() => {
|
|
127
|
-
let timeout = -1;
|
|
128
|
-
if (opened) {
|
|
129
|
-
timeout = window.setTimeout(() => setShouldReset(true), 300);
|
|
130
|
-
return () => {
|
|
131
|
-
window.clearTimeout(timeout);
|
|
132
|
-
setShouldReset(false);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
return () => setShouldReset(false);
|
|
136
|
-
}, [opened]);
|
|
137
125
|
const handleInputKeyDown = (event) => {
|
|
138
126
|
var _a2, _b;
|
|
139
127
|
if (IMEOpen) {
|
|
@@ -202,7 +190,6 @@ function Spotlight(props) {
|
|
|
202
190
|
hovered,
|
|
203
191
|
query,
|
|
204
192
|
nothingFoundMessage,
|
|
205
|
-
onActionHover: () => setHovered(-1),
|
|
206
193
|
onActionTrigger: (action) => {
|
|
207
194
|
var _a2;
|
|
208
195
|
action.onTrigger(action);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spotlight.js","sources":["../../src/Spotlight/Spotlight.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n DefaultProps,\n Selectors,\n TextInput,\n getDefaultZIndex,\n MantineColor,\n TextInputProps,\n Modal,\n ModalProps,\n ModalStylesNames,\n useComponentDefaultProps,\n ScrollArea,\n ScrollAreaAutosizeProps,\n} from '@mantine/core';\nimport { getGroupedOptions } from '@mantine/utils';\nimport { useDidUpdate } 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\nfunction SpotlightScrollArea(props: ScrollAreaAutosizeProps) {\n return <ScrollArea.Autosize mah=\"calc(100vh - 18rem)\" {...props} />;\n}\n\nexport type SpotlightStylesNames =\n | Selectors<typeof useStyles>\n | Exclude<ModalStylesNames, 'close' | 'header' | 'title'>\n | ActionsListStylesNames;\n\nexport interface InnerSpotlightProps\n extends Omit<\n ModalProps,\n 'styles' | 'classNames' | 'title' | 'withCloseButton' | 'opened' | 'onClose'\n >,\n DefaultProps<SpotlightStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n variant?: string;\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 /** Should user query be highlighted in actions title */\n highlightQuery?: boolean;\n\n /** The highlight color */\n highlightColor?: MantineColor;\n\n /** Props spread to search input */\n searchInputProps?: TextInputProps;\n\n /** Component used as scrollable container for actions list, defaults to ScrollArea.Autosize */\n scrollAreaComponent?: React.FC<{ children: React.ReactNode }>;\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\nconst defaultProps: Partial<SpotlightProps> = {\n closeOnActionTrigger: true,\n highlightQuery: false,\n size: 600,\n yOffset: 120,\n filter: filterActions,\n limit: 10,\n actionComponent: DefaultAction,\n scrollAreaComponent: SpotlightScrollArea,\n actionsWrapperComponent: 'div',\n zIndex: getDefaultZIndex('max'),\n overlayProps: { opacity: 0.2, blur: 7 },\n};\n\nexport function Spotlight(props: SpotlightProps) {\n const {\n query,\n onQueryChange,\n actions,\n onClose,\n opened,\n classNames,\n styles,\n closeOnActionTrigger,\n highlightQuery,\n highlightColor,\n className,\n searchPlaceholder,\n searchIcon,\n filter,\n nothingFoundMessage,\n limit,\n actionComponent,\n actionsWrapperComponent: ActionsWrapper,\n scrollAreaComponent: ScrollAreaComponent,\n searchInputProps,\n variant,\n target,\n radius,\n ...others\n } = useComponentDefaultProps('Spotlight', defaultProps, props);\n\n const [shouldReset, setShouldReset] = useState(false);\n const [hovered, setHovered] = useState(-1);\n const [IMEOpen, setIMEOpen] = useState(false);\n const { classes, cx } = useStyles(null, { name: 'Spotlight', classNames, styles, variant });\n\n const resetHovered = () => shouldReset && setHovered(-1);\n const handleClose = () => {\n resetHovered();\n onClose();\n };\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 useDidUpdate(() => {\n let timeout = -1;\n if (opened) {\n timeout = window.setTimeout(() => setShouldReset(true), 300);\n return () => {\n window.clearTimeout(timeout);\n setShouldReset(false);\n };\n }\n\n return () => setShouldReset(false);\n }, [opened]);\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (IMEOpen) {\n return;\n }\n\n switch (event.key) {\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 ((action?.closeOnTrigger ?? 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 <Modal\n opened={opened}\n onClose={handleClose}\n padding={0}\n radius={radius}\n scrollAreaComponent={Modal.NativeScrollArea}\n classNames={{\n ...classNames,\n content: cx(classes.content, classNames?.content),\n }}\n styles={styles}\n withCloseButton={false}\n {...others}\n >\n <TextInput\n size=\"lg\"\n {...searchInputProps}\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n onCompositionStart={() => setIMEOpen(true)}\n onCompositionEnd={() => setIMEOpen(false)}\n classNames={{ input: classes.searchInput }}\n placeholder={searchPlaceholder}\n icon={searchIcon}\n onMouseEnter={resetHovered}\n />\n <ActionsWrapper>\n <ScrollAreaComponent>\n <ActionsList\n highlightQuery={highlightQuery}\n highlightColor={highlightColor}\n actions={groupedWithLabels}\n actionComponent={actionComponent}\n hovered={hovered}\n query={query}\n nothingFoundMessage={nothingFoundMessage}\n onActionHover={() => setHovered(-1)}\n onActionTrigger={(action) => {\n action.onTrigger(action);\n (action.closeOnTrigger ?? closeOnActionTrigger) && handleClose();\n }}\n styles={styles}\n classNames={classNames}\n radius={radius}\n variant={variant}\n />\n </ScrollAreaComponent>\n </ActionsWrapper>\n </Modal>\n );\n}\n\nSpotlight.displayName = '@mantine/spotlight/Spotlight';\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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version":3,"file":"Spotlight.js","sources":["../../src/Spotlight/Spotlight.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n DefaultProps,\n Selectors,\n TextInput,\n getDefaultZIndex,\n MantineColor,\n TextInputProps,\n Modal,\n ModalProps,\n ModalStylesNames,\n useComponentDefaultProps,\n ScrollArea,\n ScrollAreaAutosizeProps,\n} from '@mantine/core';\nimport { getGroupedOptions } from '@mantine/utils';\nimport { useDidUpdate } 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\nfunction SpotlightScrollArea(props: ScrollAreaAutosizeProps) {\n return <ScrollArea.Autosize mah=\"calc(100vh - 18rem)\" {...props} />;\n}\n\nexport type SpotlightStylesNames =\n | Selectors<typeof useStyles>\n | Exclude<ModalStylesNames, 'close' | 'header' | 'title'>\n | ActionsListStylesNames;\n\nexport interface InnerSpotlightProps\n extends Omit<\n ModalProps,\n 'styles' | 'classNames' | 'title' | 'withCloseButton' | 'opened' | 'onClose'\n >,\n DefaultProps<SpotlightStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n variant?: string;\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 /** Should user query be highlighted in actions title */\n highlightQuery?: boolean;\n\n /** The highlight color */\n highlightColor?: MantineColor;\n\n /** Props spread to search input */\n searchInputProps?: TextInputProps;\n\n /** Component used as scrollable container for actions list, defaults to ScrollArea.Autosize */\n scrollAreaComponent?: React.FC<{ children: React.ReactNode }>;\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\nconst defaultProps: Partial<SpotlightProps> = {\n closeOnActionTrigger: true,\n highlightQuery: false,\n size: 600,\n yOffset: 120,\n filter: filterActions,\n limit: 10,\n actionComponent: DefaultAction,\n scrollAreaComponent: SpotlightScrollArea,\n actionsWrapperComponent: 'div',\n zIndex: getDefaultZIndex('max'),\n overlayProps: { opacity: 0.2, blur: 7 },\n};\n\nexport function Spotlight(props: SpotlightProps) {\n const {\n query,\n onQueryChange,\n actions,\n onClose,\n opened,\n classNames,\n styles,\n closeOnActionTrigger,\n highlightQuery,\n highlightColor,\n className,\n searchPlaceholder,\n searchIcon,\n filter,\n nothingFoundMessage,\n limit,\n actionComponent,\n actionsWrapperComponent: ActionsWrapper,\n scrollAreaComponent: ScrollAreaComponent,\n searchInputProps,\n variant,\n target,\n radius,\n ...others\n } = useComponentDefaultProps('Spotlight', defaultProps, props);\n\n const [hovered, setHovered] = useState(-1);\n const [IMEOpen, setIMEOpen] = useState(false);\n const { classes, cx } = useStyles(null, { name: 'Spotlight', classNames, styles, variant });\n\n const resetHovered = () => setHovered(-1);\n const handleClose = () => {\n resetHovered();\n onClose();\n };\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 if (IMEOpen) {\n return;\n }\n\n switch (event.key) {\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 ((action?.closeOnTrigger ?? 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 <Modal\n opened={opened}\n onClose={handleClose}\n padding={0}\n radius={radius}\n scrollAreaComponent={Modal.NativeScrollArea}\n classNames={{\n ...classNames,\n content: cx(classes.content, classNames?.content),\n }}\n styles={styles}\n withCloseButton={false}\n {...others}\n >\n <TextInput\n size=\"lg\"\n {...searchInputProps}\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n onCompositionStart={() => setIMEOpen(true)}\n onCompositionEnd={() => setIMEOpen(false)}\n classNames={{ input: classes.searchInput }}\n placeholder={searchPlaceholder}\n icon={searchIcon}\n onMouseEnter={resetHovered}\n />\n <ActionsWrapper>\n <ScrollAreaComponent>\n <ActionsList\n highlightQuery={highlightQuery}\n highlightColor={highlightColor}\n actions={groupedWithLabels}\n actionComponent={actionComponent}\n hovered={hovered}\n query={query}\n nothingFoundMessage={nothingFoundMessage}\n onActionTrigger={(action) => {\n action.onTrigger(action);\n (action.closeOnTrigger ?? closeOnActionTrigger) && handleClose();\n }}\n styles={styles}\n classNames={classNames}\n radius={radius}\n variant={variant}\n />\n </ScrollAreaComponent>\n </ActionsWrapper>\n </Modal>\n );\n}\n\nSpotlight.displayName = '@mantine/spotlight/Spotlight';\n"],"names":[],"mappings":";;;;;;;;;AAAA,IAA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AAU,CAAC,KAAK,CAAC;AAC7C,IAAI,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;AAC9C,IAAI,WAAW,EAAE,iBAAiB;AAClC,IAAI,IAAI,EAAE,UAAU;AACpB,IAAI,YAAY,EAAE,YAAY;AAC9B,GAAG,CAAC,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,kBAAkB,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,IAAI,kBAAkB,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE;AACjL,IAAI,cAAc;AAClB,IAAI,cAAc;AAClB,IAAI,OAAO,EAAE,iBAAiB;AAC9B,IAAI,eAAe;AACnB,IAAI,OAAO;AACX,IAAI,KAAK;AACT,IAAI,mBAAmB;AACvB,IAAI,eAAe,EAAE,CAAC,MAAM,KAAK;AACjC,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,cAAc,KAAK,IAAI,GAAG,GAAG,GAAG,oBAAoB,KAAK,WAAW,EAAE,CAAC;AAC5F,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,MAAM;AACV,IAAI,OAAO;AACX,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACR,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
package/esm/SpotlightProvider.js
CHANGED
|
@@ -47,7 +47,8 @@ function SpotlightProvider(_a) {
|
|
|
47
47
|
cleanQueryOnClose = true,
|
|
48
48
|
transitionDuration = 150,
|
|
49
49
|
disabled = false,
|
|
50
|
-
tagsToIgnore = ["INPUT", "TEXTAREA", "SELECT"]
|
|
50
|
+
tagsToIgnore = ["INPUT", "TEXTAREA", "SELECT"],
|
|
51
|
+
triggerOnContentEditable = false
|
|
51
52
|
} = _b, others = __objRest(_b, [
|
|
52
53
|
"actions",
|
|
53
54
|
"children",
|
|
@@ -60,7 +61,8 @@ function SpotlightProvider(_a) {
|
|
|
60
61
|
"cleanQueryOnClose",
|
|
61
62
|
"transitionDuration",
|
|
62
63
|
"disabled",
|
|
63
|
-
"tagsToIgnore"
|
|
64
|
+
"tagsToIgnore",
|
|
65
|
+
"triggerOnContentEditable"
|
|
64
66
|
]);
|
|
65
67
|
const timeoutRef = useRef(-1);
|
|
66
68
|
const [_query, setQuery] = useUncontrolled({
|
|
@@ -102,7 +104,7 @@ function SpotlightProvider(_a) {
|
|
|
102
104
|
actions: _actions,
|
|
103
105
|
query: _query
|
|
104
106
|
};
|
|
105
|
-
useSpotlightShortcuts(shortcut, open, tagsToIgnore);
|
|
107
|
+
useSpotlightShortcuts(shortcut, open, tagsToIgnore, triggerOnContentEditable);
|
|
106
108
|
useSpotlightEvents({ open, close, toggle, registerActions, removeActions, triggerAction });
|
|
107
109
|
return /* @__PURE__ */ React.createElement(SpotlightContext.Provider, {
|
|
108
110
|
value: ctx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpotlightProvider.js","sources":["../src/SpotlightProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { useDisclosure, useUncontrolled } from '@mantine/hooks';\nimport { useSpotlightEvents } from './events';\nimport { SpotlightContext } from './Spotlight.context';\nimport { InnerSpotlightProps, Spotlight } from './Spotlight/Spotlight';\nimport type { SpotlightAction } from './types';\nimport { useActionsState } from './use-actions-state/use-actions-state';\nimport { useSpotlightShortcuts } from './use-spotlight-shortcuts/use-spotlight-shortcuts';\n\nexport interface SpotlightProviderProps extends InnerSpotlightProps {\n /** Actions list */\n actions: SpotlightAction[];\n\n /** Called when actions change (registered or removed) */\n onActionsChange?(actions: SpotlightAction[]): void;\n\n /** Controlled search query */\n query?: string;\n\n /** Called when user enters text in search input */\n onQueryChange?(query: string): void;\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 /** 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 /** Spotlight will not render if disabled is set to true */\n disabled?: boolean;\n\n /** Tags to ignore shortcut hotkeys on. */\n tagsToIgnore?: string[];\n}\n\nexport function SpotlightProvider({\n actions,\n children,\n shortcut = 'mod + K',\n query,\n onSpotlightClose,\n onSpotlightOpen,\n onQueryChange,\n onActionsChange,\n cleanQueryOnClose = true,\n transitionDuration = 150,\n disabled = false,\n tagsToIgnore = ['INPUT', 'TEXTAREA', 'SELECT'],\n ...others\n}: SpotlightProviderProps) {\n const timeoutRef = useRef<number>(-1);\n\n const [_query, setQuery] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onQueryChange,\n });\n\n const [_actions, { registerActions, removeActions, triggerAction }] = useActionsState({\n actions,\n onActionsChange,\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 const ctx = {\n openSpotlight: open,\n closeSpotlight: close,\n toggleSpotlight: toggle,\n registerActions,\n removeActions,\n triggerAction,\n opened,\n actions: _actions,\n query: _query,\n };\n\n useSpotlightShortcuts(shortcut, open, tagsToIgnore);\n useSpotlightEvents({ open, close, toggle, registerActions, removeActions, triggerAction });\n\n return (\n <SpotlightContext.Provider value={ctx}>\n {!disabled && (\n <Spotlight\n actions={_actions}\n onClose={close}\n opened={opened}\n query={_query}\n onQueryChange={handleQueryChange}\n transitionDuration={transitionDuration}\n {...others}\n />\n )}\n {children}\n </SpotlightContext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Ae,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,eAAe,EAAE,CAAC;AAC3D,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,GAAG,GAAG;AACd,IAAI,aAAa,EAAE,IAAI;AACvB,IAAI,cAAc,EAAE,KAAK;AACzB,IAAI,eAAe,EAAE,MAAM;AAC3B,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,MAAM;AACV,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,KAAK,EAAE,MAAM;AACjB,GAAG,CAAC;AACJ,EAAE,qBAAqB,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SpotlightProvider.js","sources":["../src/SpotlightProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { useDisclosure, useUncontrolled } from '@mantine/hooks';\nimport { useSpotlightEvents } from './events';\nimport { SpotlightContext } from './Spotlight.context';\nimport { InnerSpotlightProps, Spotlight } from './Spotlight/Spotlight';\nimport type { SpotlightAction } from './types';\nimport { useActionsState } from './use-actions-state/use-actions-state';\nimport { useSpotlightShortcuts } from './use-spotlight-shortcuts/use-spotlight-shortcuts';\n\nexport interface SpotlightProviderProps extends InnerSpotlightProps {\n /** Actions list */\n actions: SpotlightAction[];\n\n /** Called when actions change (registered or removed) */\n onActionsChange?(actions: SpotlightAction[]): void;\n\n /** Controlled search query */\n query?: string;\n\n /** Called when user enters text in search input */\n onQueryChange?(query: string): void;\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 /** 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 /** Spotlight will not render if disabled is set to true */\n disabled?: boolean;\n\n /** Tags to ignore shortcut hotkeys on. */\n tagsToIgnore?: string[];\n\n /** Whether shortcuts should trigger based on contentEditable. */\n triggerOnContentEditable?: boolean;\n}\n\nexport function SpotlightProvider({\n actions,\n children,\n shortcut = 'mod + K',\n query,\n onSpotlightClose,\n onSpotlightOpen,\n onQueryChange,\n onActionsChange,\n cleanQueryOnClose = true,\n transitionDuration = 150,\n disabled = false,\n tagsToIgnore = ['INPUT', 'TEXTAREA', 'SELECT'],\n triggerOnContentEditable = false,\n ...others\n}: SpotlightProviderProps) {\n const timeoutRef = useRef<number>(-1);\n\n const [_query, setQuery] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onQueryChange,\n });\n\n const [_actions, { registerActions, removeActions, triggerAction }] = useActionsState({\n actions,\n onActionsChange,\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 const ctx = {\n openSpotlight: open,\n closeSpotlight: close,\n toggleSpotlight: toggle,\n registerActions,\n removeActions,\n triggerAction,\n opened,\n actions: _actions,\n query: _query,\n };\n\n useSpotlightShortcuts(shortcut, open, tagsToIgnore, triggerOnContentEditable);\n useSpotlightEvents({ open, close, toggle, registerActions, removeActions, triggerAction });\n\n return (\n <SpotlightContext.Provider value={ctx}>\n {!disabled && (\n <Spotlight\n actions={_actions}\n onClose={close}\n opened={opened}\n query={_query}\n onQueryChange={handleQueryChange}\n transitionDuration={transitionDuration}\n {...others}\n />\n )}\n {children}\n </SpotlightContext.Provider>\n );\n}\n\nSpotlightProvider.displayName = '@mantine/spotlight/SpotlightProvider';\n"],"names":[],"mapp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uts, onToggle, tagsToIgnore) {
|
|
13
|
-
useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore);
|
|
12
|
+
function useSpotlightShortcuts(shortcuts, onToggle, tagsToIgnore, triggerOnContentEditable) {
|
|
13
|
+
useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore, triggerOnContentEditable);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export { getHotkeysPayload, useSpotlightShortcuts };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-spotlight-shortcuts.js","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"sourcesContent":["import { HotkeyItem, useHotkeys } 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(\n shortcuts: string | string[],\n onToggle: () => void,\n tagsToIgnore?: string[]\n) {\n useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore);\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,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"use-spotlight-shortcuts.js","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"sourcesContent":["import { HotkeyItem, useHotkeys } 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(\n shortcuts: string | string[],\n onToggle: () => void,\n tagsToIgnore?: string[],\n triggerOnContentEditable?: boolean\n) {\n useHotkeys(getHotkeysPayload(shortcuts, onToggle), tagsToIgnore, triggerOnContentEditable);\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,YAAY,EAAE,wBAAwB,EAAE;AACnG,EAAE,UAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;AAC7F;;;;"}
|
|
@@ -13,20 +13,19 @@ type GetGroupOptionsLabel = {
|
|
|
13
13
|
type: 'label';
|
|
14
14
|
label: string;
|
|
15
15
|
};
|
|
16
|
-
export interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {
|
|
16
|
+
export interface ActionsListProps extends DefaultProps<ActionsListStylesNames>, React.ComponentPropsWithoutRef<'div'> {
|
|
17
17
|
actions: (GetGroupOptionsItem<SpotlightAction[]> | GetGroupOptionsLabel)[];
|
|
18
18
|
actionComponent?: React.FC<DefaultActionProps>;
|
|
19
19
|
hovered: number;
|
|
20
20
|
query: string;
|
|
21
21
|
nothingFoundMessage?: React.ReactNode;
|
|
22
|
-
onActionHover(): void;
|
|
23
22
|
onActionTrigger(action: SpotlightAction): void;
|
|
24
23
|
highlightQuery: boolean;
|
|
25
24
|
highlightColor: MantineColor;
|
|
26
25
|
radius: MantineNumberSize;
|
|
27
26
|
variant: string;
|
|
28
27
|
}
|
|
29
|
-
export declare function ActionsList({ actions, styles, classNames, actionComponent: Action, hovered,
|
|
28
|
+
export declare function ActionsList({ actions, styles, classNames, actionComponent: Action, hovered, onActionTrigger, query, nothingFoundMessage, highlightQuery, highlightColor, radius, variant, ...others }: ActionsListProps): JSX.Element;
|
|
30
29
|
export declare namespace ActionsList {
|
|
31
30
|
var displayName: string;
|
|
32
31
|
}
|
|
@@ -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,SAAS,EAAQ,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/F,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,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,SAAS,CAAC,GAAG,wBAAwB,CAAC;AAC5F,KAAK,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;I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EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,YAAY,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,MAAM,EACN,UAAU,EACV,eAAe,EAAE,MAAM,EACvB,OAAO,EACP,eAAe,EACf,KAAK,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,MAAM,EACN,OAAO,EACP,GAAG,MAAM,EACV,EAAE,gBAAgB,eA8ClB;yBA5De,WAAW"}
|
|
@@ -12,7 +12,7 @@ export interface DefaultActionProps extends DefaultProps<DefaultActionStylesName
|
|
|
12
12
|
query: string;
|
|
13
13
|
radius: MantineNumberSize;
|
|
14
14
|
}
|
|
15
|
-
export declare function DefaultAction({ action, styles, classNames, hovered, onTrigger, highlightQuery, highlightColor, query, radius,
|
|
15
|
+
export declare function DefaultAction({ action, styles, classNames, hovered, onTrigger, highlightQuery, highlightColor, query, radius, ...others }: DefaultActionProps): JSX.Element;
|
|
16
16
|
export declare namespace DefaultAction {
|
|
17
17
|
var displayName: string;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.d.ts","sourceRoot":"","sources":["../../src/DefaultAction/DefaultAction.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,SAAS,EAMT,iBAAiB,EACjB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;AAEnE,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,cAAc,EAAE,YAAY,CAAC;IAC7B,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,cAAc,EACd,KAAK,EACL,MAAM,EACN,GAAG,MAAM,EACV,EAAE,kBAAkB,eAqCpB;yBAhDe,aAAa"}
|
|
@@ -5,6 +5,7 @@ export interface DefaultActionStylesParams {
|
|
|
5
5
|
declare const _default: (params: DefaultActionStylesParams, options?: import("@mantine/core").UseStylesOptions<string>) => {
|
|
6
6
|
classes: {
|
|
7
7
|
action: string;
|
|
8
|
+
actionDescription: string;
|
|
8
9
|
actionIcon: string;
|
|
9
10
|
actionBody: string;
|
|
10
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAction.styles.d.ts","sourceRoot":"","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAO,MAAM,eAAe,CAAC;AAErE,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,iBAAiB,CAAC;CAC3B
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.d.ts","sourceRoot":"","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"names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xD,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,0BAA0B;IAC1B,cAAc,CAAC,EAAE,YAAY,CAAC;IAE9B,mCAAmC;IACnC,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAElC,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;CAC/D;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;AAgBD,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eA+I9C;yBA/Ie,SAAS"}
|
|
@@ -24,8 +24,10 @@ export interface SpotlightProviderProps extends InnerSpotlightProps {
|
|
|
24
24
|
disabled?: boolean;
|
|
25
25
|
/** Tags to ignore shortcut hotkeys on. */
|
|
26
26
|
tagsToIgnore?: string[];
|
|
27
|
+
/** Whether shortcuts should trigger based on contentEditable. */
|
|
28
|
+
triggerOnContentEditable?: boolean;
|
|
27
29
|
}
|
|
28
|
-
export declare function SpotlightProvider({ actions, children, shortcut, query, onSpotlightClose, onSpotlightOpen, onQueryChange, onActionsChange, cleanQueryOnClose, transitionDuration, disabled, tagsToIgnore, ...others }: SpotlightProviderProps): JSX.Element;
|
|
30
|
+
export declare function SpotlightProvider({ actions, children, shortcut, query, onSpotlightClose, onSpotlightOpen, onQueryChange, onActionsChange, cleanQueryOnClose, transitionDuration, disabled, tagsToIgnore, triggerOnContentEditable, ...others }: SpotlightProviderProps): JSX.Element;
|
|
29
31
|
export declare namespace SpotlightProvider {
|
|
30
32
|
var displayName: string;
|
|
31
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpotlightProvider.d.ts","sourceRoot":"","sources":["../src/SpotlightProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAItC,OAAO,EAAE,mBAAmB,EAAa,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI/C,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,mBAAmB;IACnB,OAAO,EAAE,eAAe,EAAE,CAAC;IAE3B,yDAAyD;IACzD,eAAe,CAAC,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IAEnD,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC,uBAAuB;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,kCAAkC;IAClC,eAAe,CAAC,IAAI,IAAI,CAAC;IAEzB,mCAAmC;IACnC,gBAAgB,CAAC,IAAI,IAAI,CAAC;IAE1B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAEpC,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"SpotlightProvider.d.ts","sourceRoot":"","sources":["../src/SpotlightProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAItC,OAAO,EAAE,mBAAmB,EAAa,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI/C,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,mBAAmB;IACnB,OAAO,EAAE,eAAe,EAAE,CAAC;IAE3B,yDAAyD;IACzD,eAAe,CAAC,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IAEnD,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC,uBAAuB;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,kCAAkC;IAClC,eAAe,CAAC,IAAI,IAAI,CAAC;IAEzB,mCAAmC;IACnC,gBAAgB,CAAC,IAAI,IAAI,CAAC;IAE1B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAEpC,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,iEAAiE;IACjE,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,QAAQ,EACR,QAAoB,EACpB,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,iBAAwB,EACxB,kBAAwB,EACxB,QAAgB,EAChB,YAA8C,EAC9C,wBAAgC,EAChC,GAAG,MAAM,EACV,EAAE,sBAAsB,eAkExB;yBAjFe,iBAAiB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HotkeyItem } from '@mantine/hooks';
|
|
2
2
|
export declare function getHotkeysPayload(shortcuts: string | string[], onToggle: () => void): HotkeyItem[];
|
|
3
|
-
export declare function useSpotlightShortcuts(shortcuts: string | string[], onToggle: () => void, tagsToIgnore?: string[]): void;
|
|
3
|
+
export declare function useSpotlightShortcuts(shortcuts: string | string[], onToggle: () => void, tagsToIgnore?: string[], triggerOnContentEditable?: boolean): void;
|
|
4
4
|
//# sourceMappingURL=use-spotlight-shortcuts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-spotlight-shortcuts.d.ts","sourceRoot":"","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAQ,EAAE,MAAM,IAAI,GACnB,UAAU,EAAE,CAUd;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAQ,EAAE,MAAM,IAAI,EACpB,YAAY,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"use-spotlight-shortcuts.d.ts","sourceRoot":"","sources":["../../src/use-spotlight-shortcuts/use-spotlight-shortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAQ,EAAE,MAAM,IAAI,GACnB,UAAU,EAAE,CAUd;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAQ,EAAE,MAAM,IAAI,EACpB,YAAY,CAAC,EAAE,MAAM,EAAE,EACvB,wBAAwB,CAAC,EAAE,OAAO,QAGnC"}
|
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": "6.0.0-alpha.
|
|
4
|
+
"version": "6.0.0-alpha.4",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"directory": "src/mantine-spotlight"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@mantine/core": "6.0.0-alpha.
|
|
19
|
-
"@mantine/hooks": "6.0.0-alpha.
|
|
18
|
+
"@mantine/core": "6.0.0-alpha.4",
|
|
19
|
+
"@mantine/hooks": "6.0.0-alpha.4",
|
|
20
20
|
"react": ">=16.8.0",
|
|
21
21
|
"react-dom": ">=16.8.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@mantine/utils": "6.0.0-alpha.
|
|
24
|
+
"@mantine/utils": "6.0.0-alpha.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {}
|
|
27
27
|
}
|