@mantine/spotlight 3.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/cjs/ActionsList/ActionsList.js +60 -0
- package/cjs/ActionsList/ActionsList.js.map +1 -0
- package/cjs/ActionsList/ActionsList.styles.js +24 -0
- package/cjs/ActionsList/ActionsList.styles.js.map +1 -0
- package/cjs/DefaultAction/DefaultAction.js +81 -0
- package/cjs/DefaultAction/DefaultAction.js.map +1 -0
- package/cjs/DefaultAction/DefaultAction.styles.js +27 -0
- package/cjs/DefaultAction/DefaultAction.styles.js.map +1 -0
- package/cjs/Spotlight/Spotlight.js +221 -0
- package/cjs/Spotlight/Spotlight.js.map +1 -0
- package/cjs/Spotlight/Spotlight.styles.js +59 -0
- package/cjs/Spotlight/Spotlight.styles.js.map +1 -0
- package/cjs/Spotlight/filter-actions/filter-actions.js +23 -0
- package/cjs/Spotlight/filter-actions/filter-actions.js.map +1 -0
- package/cjs/Spotlight.context.js +18 -0
- package/cjs/Spotlight.context.js.map +1 -0
- package/cjs/SpotlightProvider.js +110 -0
- package/cjs/SpotlightProvider.js.map +1 -0
- package/cjs/index.js +12 -0
- package/cjs/index.js.map +1 -0
- package/cjs/use-actions-state/use-actions-state.js +68 -0
- package/cjs/use-actions-state/use-actions-state.js.map +1 -0
- package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js +22 -0
- package/cjs/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -0
- package/esm/ActionsList/ActionsList.js +52 -0
- package/esm/ActionsList/ActionsList.js.map +1 -0
- package/esm/ActionsList/ActionsList.styles.js +20 -0
- package/esm/ActionsList/ActionsList.styles.js.map +1 -0
- package/esm/DefaultAction/DefaultAction.js +73 -0
- package/esm/DefaultAction/DefaultAction.js.map +1 -0
- package/esm/DefaultAction/DefaultAction.styles.js +23 -0
- package/esm/DefaultAction/DefaultAction.styles.js.map +1 -0
- package/esm/Spotlight/Spotlight.js +213 -0
- package/esm/Spotlight/Spotlight.js.map +1 -0
- package/esm/Spotlight/Spotlight.styles.js +55 -0
- package/esm/Spotlight/Spotlight.styles.js.map +1 -0
- package/esm/Spotlight/filter-actions/filter-actions.js +19 -0
- package/esm/Spotlight/filter-actions/filter-actions.js.map +1 -0
- package/esm/Spotlight.context.js +13 -0
- package/esm/Spotlight.context.js.map +1 -0
- package/esm/SpotlightProvider.js +102 -0
- package/esm/SpotlightProvider.js.map +1 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/use-actions-state/use-actions-state.js +64 -0
- package/esm/use-actions-state/use-actions-state.js.map +1 -0
- package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js +17 -0
- package/esm/use-spotlight-shortcuts/use-spotlight-shortcuts.js.map +1 -0
- package/lib/ActionsList/ActionsList.d.ts +21 -0
- package/lib/ActionsList/ActionsList.d.ts.map +1 -0
- package/lib/ActionsList/ActionsList.styles.d.ts +7 -0
- package/lib/ActionsList/ActionsList.styles.d.ts.map +1 -0
- package/lib/DefaultAction/DefaultAction.d.ts +17 -0
- package/lib/DefaultAction/DefaultAction.d.ts.map +1 -0
- package/lib/DefaultAction/DefaultAction.styles.d.ts +7 -0
- package/lib/DefaultAction/DefaultAction.styles.d.ts.map +1 -0
- package/lib/Spotlight/Spotlight.d.ts +64 -0
- package/lib/Spotlight/Spotlight.d.ts.map +1 -0
- package/lib/Spotlight/Spotlight.styles.d.ts +12 -0
- package/lib/Spotlight/Spotlight.styles.d.ts.map +1 -0
- package/lib/Spotlight/filter-actions/filter-actions.d.ts +3 -0
- package/lib/Spotlight/filter-actions/filter-actions.d.ts.map +1 -0
- package/lib/Spotlight.context.d.ts +25 -0
- package/lib/Spotlight.context.d.ts.map +1 -0
- package/lib/SpotlightProvider.d.ts +24 -0
- package/lib/SpotlightProvider.d.ts.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/types.d.ts +20 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/use-actions-state/use-actions-state.d.ts +7 -0
- package/lib/use-actions-state/use-actions-state.d.ts.map +1 -0
- package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts +4 -0
- package/lib/use-spotlight-shortcuts/use-spotlight-shortcuts.d.ts.map +1 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Mantine Spotlight
|
|
2
|
+
|
|
3
|
+
Overlay command center for your application
|
|
4
|
+
|
|
5
|
+
[Documentation](https://mantine.dev/)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
# With yarn
|
|
11
|
+
yarn add @mantine/spotlight @mantine/core @mantine/hooks
|
|
12
|
+
|
|
13
|
+
# With npm
|
|
14
|
+
npm install @mantine/spotlight @mantine/core @mantine/hooks
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var core = require('@mantine/core');
|
|
7
|
+
var ActionsList_styles = require('./ActionsList.styles.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
13
|
+
function ActionsList({
|
|
14
|
+
actions,
|
|
15
|
+
styles,
|
|
16
|
+
classNames,
|
|
17
|
+
actionComponent: Action,
|
|
18
|
+
hovered,
|
|
19
|
+
onActionHover,
|
|
20
|
+
onActionTrigger,
|
|
21
|
+
query,
|
|
22
|
+
nothingFoundMessage,
|
|
23
|
+
highlightQuery
|
|
24
|
+
}) {
|
|
25
|
+
const { classes } = ActionsList_styles['default'](null, { classNames, styles, name: "Spotlight" });
|
|
26
|
+
const items = core.getGroupedOptions(actions).items.map((item) => {
|
|
27
|
+
if (item.type === "item") {
|
|
28
|
+
return /* @__PURE__ */ React__default.createElement(Action, {
|
|
29
|
+
query,
|
|
30
|
+
key: item.item.id,
|
|
31
|
+
action: item.item,
|
|
32
|
+
hovered: item.index === hovered,
|
|
33
|
+
onMouseEnter: () => onActionHover(item.index),
|
|
34
|
+
classNames,
|
|
35
|
+
styles,
|
|
36
|
+
onTrigger: () => onActionTrigger(item.item),
|
|
37
|
+
highlightQuery
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ React__default.createElement(core.Text, {
|
|
41
|
+
className: classes.actionsGroup,
|
|
42
|
+
color: "dimmed",
|
|
43
|
+
key: item.label
|
|
44
|
+
}, item.label);
|
|
45
|
+
});
|
|
46
|
+
const shouldRenderActions = items.length > 0 || !!nothingFoundMessage && query.trim().length > 0;
|
|
47
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, shouldRenderActions && /* @__PURE__ */ React__default.createElement("div", {
|
|
48
|
+
className: classes.actions
|
|
49
|
+
}, items.length > 0 ? items : /* @__PURE__ */ React__default.createElement(core.Text, {
|
|
50
|
+
color: "dimmed",
|
|
51
|
+
className: classes.nothingFound,
|
|
52
|
+
align: "center",
|
|
53
|
+
size: "lg",
|
|
54
|
+
py: "md"
|
|
55
|
+
}, nothingFoundMessage)));
|
|
56
|
+
}
|
|
57
|
+
ActionsList.displayName = "@mantine/spotlight/ActionsList";
|
|
58
|
+
|
|
59
|
+
exports.ActionsList = ActionsList;
|
|
60
|
+
//# sourceMappingURL=ActionsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsList.js","sources":["../../src/ActionsList/ActionsList.tsx"],"sourcesContent":["import React from 'react';\nimport { DefaultProps, ClassNames, Text, getGroupedOptions } from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport type { DefaultActionProps, DefaultActionStylesNames } from '../DefaultAction/DefaultAction';\nimport useStyles from './ActionsList.styles';\n\nexport type ActionsListStylesNames = ClassNames<typeof useStyles> | DefaultActionStylesNames;\n\nexport interface ActionsListProps extends DefaultProps<ActionsListStylesNames> {\n actions: SpotlightAction[];\n actionComponent?: React.FC<DefaultActionProps>;\n hovered: number;\n query: string;\n nothingFoundMessage?: React.ReactNode;\n onActionHover(index: number): void;\n onActionTrigger(action: SpotlightAction): void;\n highlightQuery: boolean;\n}\n\nexport function ActionsList({\n actions,\n styles,\n classNames,\n actionComponent: Action,\n hovered,\n onActionHover,\n onActionTrigger,\n query,\n nothingFoundMessage,\n highlightQuery,\n}: ActionsListProps) {\n const { classes } = useStyles(null, { classNames, styles, name: 'Spotlight' });\n\n const items = getGroupedOptions(actions).items.map((item) => {\n if (item.type === 'item') {\n return (\n <Action\n query={query}\n key={item.item.id}\n action={item.item}\n hovered={item.index === hovered}\n onMouseEnter={() => onActionHover(item.index)}\n classNames={classNames}\n styles={styles}\n onTrigger={() => onActionTrigger(item.item)}\n highlightQuery={highlightQuery}\n />\n );\n }\n\n return (\n <Text className={classes.actionsGroup} color=\"dimmed\" key={item.label}>\n {item.label}\n </Text>\n );\n });\n\n const shouldRenderActions =\n items.length > 0 || (!!nothingFoundMessage && query.trim().length > 0);\n\n return (\n <>\n {shouldRenderActions && (\n <div className={classes.actions}>\n {items.length > 0 ? (\n items\n ) : (\n <Text color=\"dimmed\" className={classes.nothingFound} align=\"center\" size=\"lg\" py=\"md\">\n {nothingFoundMessage}\n </Text>\n )}\n </div>\n )}\n </>\n );\n}\n\nActionsList.displayName = '@mantine/spotlight/ActionsList';\n"],"names":["useStyles","getGroupedOptions","React","Text"],"mappings":";;;;;;;;;;;;AAGO,SAAS,WAAW,CAAC;AAC5B,EAAE,OAAO;AACT,EAAE,MAAM;AACR,EAAE,UAAU;AACZ,EAAE,eAAe,EAAE,MAAM;AACzB,EAAE,OAAO;AACT,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G,CAAC,CAAC;AACnG,EAAE,uBAAuBD,cAAK,CAAC,aAAa,CAACA,cAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,mBAAmB,oBAAoBA,cAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACrI,IAAI,SAAS,EAAE,OAAO,CAAC,OAAO;AAC9B,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,mBAAmBA,cAAK,CAAC,aAAa,CAACC,SAAI,EAAE;AAC1E,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,SAAS,EAAE,OAAO,CAAC,YAAY;AACnC,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,IAAI,EAAE,IAAI;AACd,IAAI,EAAE,EAAE,IAAI;AACZ,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,gCAAgC;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@mantine/core');
|
|
6
|
+
|
|
7
|
+
var useStyles = core.createStyles((theme) => ({
|
|
8
|
+
nothingFound: {},
|
|
9
|
+
actions: {
|
|
10
|
+
padding: theme.spacing.xs / 2,
|
|
11
|
+
borderTop: `1px solid ${theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[2]}`
|
|
12
|
+
},
|
|
13
|
+
actionsGroup: {
|
|
14
|
+
textTransform: "uppercase",
|
|
15
|
+
fontSize: theme.spacing.xs,
|
|
16
|
+
fontWeight: 700,
|
|
17
|
+
padding: "10px 12px",
|
|
18
|
+
paddingBottom: 0,
|
|
19
|
+
paddingTop: 15
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
exports.default = useStyles;
|
|
24
|
+
//# sourceMappingURL=ActionsList.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionsList.styles.js","sources":["../../src/ActionsList/ActionsList.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\nexport default createStyles((theme) => ({\n nothingFound: {},\n\n actions: {\n padding: theme.spacing.xs / 2,\n borderTop: `1px solid ${\n theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2]\n }`,\n },\n\n actionsGroup: {\n textTransform: 'uppercase',\n fontSize: theme.spacing.xs,\n fontWeight: 700,\n padding: '10px 12px',\n paddingBottom: 0,\n paddingTop: 15,\n },\n}));\n"],"names":["createStyles"],"mappings":";;;;;;AACA,gBAAeA,iBAAY,CAAC,CAAC,KAAK,MAAM;AACxC,EAAE,YAAY,EAAE,EAAE;AAClB,EAAE,OAAO,EAAE;AACX,IAAI,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;AACjC,IAAI,SAAS,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,aAAa,EAAE,WAAW;AAC9B,IAAI,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;AAC9B,IAAI,UAAU,EAAE,GAAG;AACnB,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,aAAa,EAAE,CAAC;AACpB,IAAI,UAAU,EAAE,EAAE;AAClB,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var core = require('@mantine/core');
|
|
7
|
+
var DefaultAction_styles = require('./DefaultAction.styles.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
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 DefaultAction(_a) {
|
|
42
|
+
var _b = _a, {
|
|
43
|
+
action,
|
|
44
|
+
styles,
|
|
45
|
+
classNames,
|
|
46
|
+
hovered,
|
|
47
|
+
onTrigger,
|
|
48
|
+
highlightQuery,
|
|
49
|
+
query
|
|
50
|
+
} = _b, others = __objRest(_b, [
|
|
51
|
+
"action",
|
|
52
|
+
"styles",
|
|
53
|
+
"classNames",
|
|
54
|
+
"hovered",
|
|
55
|
+
"onTrigger",
|
|
56
|
+
"highlightQuery",
|
|
57
|
+
"query"
|
|
58
|
+
]);
|
|
59
|
+
const { classes, cx } = DefaultAction_styles['default'](null, { styles, classNames, name: "Spotlight" });
|
|
60
|
+
return /* @__PURE__ */ React__default.createElement(core.UnstyledButton, __spreadValues({
|
|
61
|
+
className: cx(classes.action, { [classes.actionHovered]: hovered }),
|
|
62
|
+
tabIndex: -1,
|
|
63
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
64
|
+
onClick: onTrigger
|
|
65
|
+
}, others), /* @__PURE__ */ React__default.createElement(core.Group, {
|
|
66
|
+
noWrap: true
|
|
67
|
+
}, action.icon && /* @__PURE__ */ React__default.createElement(core.Center, {
|
|
68
|
+
className: classes.actionIcon
|
|
69
|
+
}, action.icon), /* @__PURE__ */ React__default.createElement("div", {
|
|
70
|
+
className: classes.actionBody
|
|
71
|
+
}, /* @__PURE__ */ React__default.createElement(core.Highlight, {
|
|
72
|
+
highlight: highlightQuery ? query : null
|
|
73
|
+
}, action.title), action.description && /* @__PURE__ */ React__default.createElement(core.Text, {
|
|
74
|
+
color: "dimmed",
|
|
75
|
+
size: "xs"
|
|
76
|
+
}, action.description))));
|
|
77
|
+
}
|
|
78
|
+
DefaultAction.displayName = "@mantine/spotlight/DefaultAction";
|
|
79
|
+
|
|
80
|
+
exports.DefaultAction = DefaultAction;
|
|
81
|
+
//# sourceMappingURL=DefaultAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultAction.js","sources":["../../src/DefaultAction/DefaultAction.tsx"],"sourcesContent":["import React from 'react';\nimport {\n DefaultProps,\n ClassNames,\n Highlight,\n UnstyledButton,\n Group,\n Center,\n Text,\n} from '@mantine/core';\nimport type { SpotlightAction } from '../types';\nimport useStyles from './DefaultAction.styles';\n\nexport type DefaultActionStylesNames = ClassNames<typeof useStyles>;\n\nexport interface DefaultActionProps\n extends DefaultProps<DefaultActionStylesNames>,\n React.ComponentPropsWithoutRef<'button'> {\n action: SpotlightAction;\n hovered: boolean;\n onTrigger(): void;\n highlightQuery: boolean;\n query: string;\n}\n\nexport function DefaultAction({\n action,\n styles,\n classNames,\n hovered,\n onTrigger,\n highlightQuery,\n query,\n ...others\n}: DefaultActionProps) {\n const { classes, cx } = useStyles(null, { styles, classNames, name: 'Spotlight' });\n\n return (\n <UnstyledButton\n className={cx(classes.action, { [classes.actionHovered]: hovered })}\n tabIndex={-1}\n onMouseDown={(event) => event.preventDefault()}\n onClick={onTrigger}\n {...others}\n >\n <Group noWrap>\n {action.icon && <Center className={classes.actionIcon}>{action.icon}</Center>}\n\n <div className={classes.actionBody}>\n <Highlight highlight={highlightQuery ? query : null}>{action.title}</Highlight>\n\n {action.description && (\n <Text color=\"dimmed\" size=\"xs\">\n {action.description}\n </Text>\n )}\n </div>\n </Group>\n </UnstyledButton>\n );\n}\n\nDefaultAction.displayName = '@mantine/spotlight/DefaultAction';\n"],"names":["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,C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AE,MAAM,CAAC,IAAI,CAAC,kBAAkBH,cAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AAC9D,IAAI,SAAS,EAAE,OAAO,CAAC,UAAU;AACjC,GAAG,kBAAkBA,cAAK,CAAC,aAAa,CAACI,cAAS,EAAE;AACpD,IAAI,SAAS,EAAE,cAAc,GAAG,KAAK,GAAG,IAAI;AAC5C,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,oBAAoBJ,cAAK,CAAC,aAAa,CAACK,SAAI,EAAE;AACpF,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,IAAI,EAAE,IAAI;AACd,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AACD,aAAa,CAAC,WAAW,GAAG,kCAAkC;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@mantine/core');
|
|
6
|
+
|
|
7
|
+
var useStyles = core.createStyles((theme) => ({
|
|
8
|
+
action: {
|
|
9
|
+
position: "relative",
|
|
10
|
+
display: "block",
|
|
11
|
+
width: "100%",
|
|
12
|
+
padding: "10px 12px",
|
|
13
|
+
borderRadius: theme.radius.sm
|
|
14
|
+
},
|
|
15
|
+
actionHovered: {
|
|
16
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]
|
|
17
|
+
},
|
|
18
|
+
actionIcon: {
|
|
19
|
+
color: theme.colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6]
|
|
20
|
+
},
|
|
21
|
+
actionBody: {
|
|
22
|
+
flex: 1
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
exports.default = useStyles;
|
|
27
|
+
//# sourceMappingURL=DefaultAction.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultAction.styles.js","sources":["../../src/DefaultAction/DefaultAction.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\nexport default createStyles((theme) => ({\n action: {\n position: 'relative',\n display: 'block',\n width: '100%',\n padding: '10px 12px',\n borderRadius: theme.radius.sm,\n },\n\n actionHovered: {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[1],\n },\n\n actionIcon: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[2] : theme.colors.gray[6],\n },\n\n actionBody: {\n flex: 1,\n },\n}));\n"],"names":["createStyles"],"mappings":";;;;;;AACA,gBAAeA,iBAAY,CAAC,CAAC,KAAK,MAAM;AACxC,EAAE,MAAM,EAAE;AACV,IAAI,QAAQ,EAAE,UAAU;AACxB,IAAI,OAAO,EAAE,OAAO;AACpB,IAAI,KAAK,EAAE,MAAM;AACjB,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE;AACjC,GAAG;AACH,EAAE,aAAa,EAAE;AACjB,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/F,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,KAAK,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACrF,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC;AACX,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var core = require('@mantine/core');
|
|
7
|
+
var hooks = require('@mantine/hooks');
|
|
8
|
+
var DefaultAction = require('../DefaultAction/DefaultAction.js');
|
|
9
|
+
var ActionsList = require('../ActionsList/ActionsList.js');
|
|
10
|
+
var filterActions = require('./filter-actions/filter-actions.js');
|
|
11
|
+
var Spotlight_styles = require('./Spotlight.styles.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
+
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
19
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
20
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
21
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
|
+
var __spreadValues = (a, b) => {
|
|
23
|
+
for (var prop in b || (b = {}))
|
|
24
|
+
if (__hasOwnProp.call(b, prop))
|
|
25
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
|
+
if (__getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
28
|
+
if (__propIsEnum.call(b, prop))
|
|
29
|
+
__defNormalProp(a, prop, b[prop]);
|
|
30
|
+
}
|
|
31
|
+
return a;
|
|
32
|
+
};
|
|
33
|
+
var __objRest = (source, exclude) => {
|
|
34
|
+
var target = {};
|
|
35
|
+
for (var prop in source)
|
|
36
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
37
|
+
target[prop] = source[prop];
|
|
38
|
+
if (source != null && __getOwnPropSymbols)
|
|
39
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
40
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
41
|
+
target[prop] = source[prop];
|
|
42
|
+
}
|
|
43
|
+
return target;
|
|
44
|
+
};
|
|
45
|
+
function Spotlight(_a) {
|
|
46
|
+
var _b = _a, {
|
|
47
|
+
query,
|
|
48
|
+
onQueryChange,
|
|
49
|
+
actions,
|
|
50
|
+
onClose,
|
|
51
|
+
opened,
|
|
52
|
+
withinPortal,
|
|
53
|
+
transition = "pop",
|
|
54
|
+
transitionDuration,
|
|
55
|
+
classNames,
|
|
56
|
+
styles,
|
|
57
|
+
overlayColor = "#000",
|
|
58
|
+
overlayOpacity = 0.25,
|
|
59
|
+
overlayBlur = 3,
|
|
60
|
+
shadow = "md",
|
|
61
|
+
centered = false,
|
|
62
|
+
closeOnActionTrigger = true,
|
|
63
|
+
highlightQuery = false,
|
|
64
|
+
maxWidth = 600,
|
|
65
|
+
topOffset = 120,
|
|
66
|
+
className,
|
|
67
|
+
searchPlaceholder,
|
|
68
|
+
searchIcon,
|
|
69
|
+
filter = filterActions.filterActions,
|
|
70
|
+
nothingFoundMessage,
|
|
71
|
+
limit = 10,
|
|
72
|
+
actionComponent = DefaultAction.DefaultAction,
|
|
73
|
+
actionsWrapperComponent: ActionsWrapper = "div",
|
|
74
|
+
zIndex = core.getDefaultZIndex("modal")
|
|
75
|
+
} = _b, others = __objRest(_b, [
|
|
76
|
+
"query",
|
|
77
|
+
"onQueryChange",
|
|
78
|
+
"actions",
|
|
79
|
+
"onClose",
|
|
80
|
+
"opened",
|
|
81
|
+
"withinPortal",
|
|
82
|
+
"transition",
|
|
83
|
+
"transitionDuration",
|
|
84
|
+
"classNames",
|
|
85
|
+
"styles",
|
|
86
|
+
"overlayColor",
|
|
87
|
+
"overlayOpacity",
|
|
88
|
+
"overlayBlur",
|
|
89
|
+
"shadow",
|
|
90
|
+
"centered",
|
|
91
|
+
"closeOnActionTrigger",
|
|
92
|
+
"highlightQuery",
|
|
93
|
+
"maxWidth",
|
|
94
|
+
"topOffset",
|
|
95
|
+
"className",
|
|
96
|
+
"searchPlaceholder",
|
|
97
|
+
"searchIcon",
|
|
98
|
+
"filter",
|
|
99
|
+
"nothingFoundMessage",
|
|
100
|
+
"limit",
|
|
101
|
+
"actionComponent",
|
|
102
|
+
"actionsWrapperComponent",
|
|
103
|
+
"zIndex"
|
|
104
|
+
]);
|
|
105
|
+
const [hovered, setHovered] = React.useState(-1);
|
|
106
|
+
const { classes, cx } = Spotlight_styles['default']({ centered, maxWidth, topOffset }, { classNames, styles, name: "Spotlight" });
|
|
107
|
+
const [, lockScroll] = hooks.useScrollLock();
|
|
108
|
+
const focusTrapRef = hooks.useFocusTrap(opened);
|
|
109
|
+
const resetHovered = () => setHovered(-1);
|
|
110
|
+
const handleClose = () => {
|
|
111
|
+
resetHovered();
|
|
112
|
+
onClose();
|
|
113
|
+
};
|
|
114
|
+
hooks.useFocusReturn({ transitionDuration: 0, opened });
|
|
115
|
+
const filteredActions = filter(query, actions).slice(0, limit);
|
|
116
|
+
hooks.useDidUpdate(() => {
|
|
117
|
+
if (filteredActions.length - 1 < hovered) {
|
|
118
|
+
setHovered(filteredActions.length - 1);
|
|
119
|
+
}
|
|
120
|
+
}, [filteredActions.length]);
|
|
121
|
+
const handleInputKeyDown = (event) => {
|
|
122
|
+
var _a2;
|
|
123
|
+
switch (event.code) {
|
|
124
|
+
case "ArrowDown": {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
setHovered((current) => current < filteredActions.length - 1 ? current + 1 : 0);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case "ArrowUp": {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
setHovered((current) => current > 0 ? current - 1 : filteredActions.length - 1);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case "Enter": {
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
const action = filteredActions[hovered];
|
|
137
|
+
(_a2 = action == null ? void 0 : action.onTrigger) == null ? void 0 : _a2.call(action, action);
|
|
138
|
+
if (closeOnActionTrigger && (action == null ? void 0 : action.onTrigger)) {
|
|
139
|
+
handleClose();
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "Escape": {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
handleClose();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const handleInputChange = (event) => {
|
|
150
|
+
onQueryChange(event.currentTarget.value);
|
|
151
|
+
if (hovered === -1) {
|
|
152
|
+
setHovered(0);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return /* @__PURE__ */ React__default.createElement(core.OptionalPortal, {
|
|
156
|
+
withinPortal,
|
|
157
|
+
zIndex
|
|
158
|
+
}, /* @__PURE__ */ React__default.createElement(core.GroupedTransition, {
|
|
159
|
+
onExited: () => lockScroll(false),
|
|
160
|
+
onEntered: () => lockScroll(true),
|
|
161
|
+
mounted: opened,
|
|
162
|
+
transitions: {
|
|
163
|
+
spotlight: {
|
|
164
|
+
duration: transitionDuration,
|
|
165
|
+
transition,
|
|
166
|
+
timingFunction: "ease"
|
|
167
|
+
},
|
|
168
|
+
overlay: {
|
|
169
|
+
duration: transitionDuration / 2,
|
|
170
|
+
transition: "fade",
|
|
171
|
+
timingFunction: "ease"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, (transitionStyles) => /* @__PURE__ */ React__default.createElement("div", __spreadValues({
|
|
175
|
+
className: cx(classes.root, className)
|
|
176
|
+
}, others), /* @__PURE__ */ React__default.createElement("div", {
|
|
177
|
+
className: classes.inner,
|
|
178
|
+
ref: focusTrapRef
|
|
179
|
+
}, /* @__PURE__ */ React__default.createElement(core.Paper, {
|
|
180
|
+
style: transitionStyles.spotlight,
|
|
181
|
+
className: classes.spotlight,
|
|
182
|
+
shadow,
|
|
183
|
+
onMouseLeave: resetHovered
|
|
184
|
+
}, /* @__PURE__ */ React__default.createElement(core.TextInput, {
|
|
185
|
+
value: query,
|
|
186
|
+
onChange: handleInputChange,
|
|
187
|
+
onKeyDown: handleInputKeyDown,
|
|
188
|
+
classNames: { input: classes.searchInput },
|
|
189
|
+
size: "lg",
|
|
190
|
+
placeholder: searchPlaceholder,
|
|
191
|
+
icon: searchIcon,
|
|
192
|
+
onMouseEnter: resetHovered
|
|
193
|
+
}), /* @__PURE__ */ React__default.createElement(ActionsWrapper, null, /* @__PURE__ */ React__default.createElement(ActionsList.ActionsList, {
|
|
194
|
+
highlightQuery,
|
|
195
|
+
actions: filteredActions,
|
|
196
|
+
actionComponent,
|
|
197
|
+
hovered,
|
|
198
|
+
query,
|
|
199
|
+
nothingFoundMessage,
|
|
200
|
+
onActionHover: setHovered,
|
|
201
|
+
onActionTrigger: (action) => {
|
|
202
|
+
action.onTrigger(action);
|
|
203
|
+
closeOnActionTrigger && handleClose();
|
|
204
|
+
},
|
|
205
|
+
styles,
|
|
206
|
+
classNames
|
|
207
|
+
}))), /* @__PURE__ */ React__default.createElement("div", {
|
|
208
|
+
style: transitionStyles.overlay
|
|
209
|
+
}, /* @__PURE__ */ React__default.createElement(core.Overlay, {
|
|
210
|
+
className: classes.overlay,
|
|
211
|
+
zIndex: 1,
|
|
212
|
+
onMouseDown: handleClose,
|
|
213
|
+
color: overlayColor,
|
|
214
|
+
opacity: overlayOpacity,
|
|
215
|
+
blur: overlayBlur
|
|
216
|
+
}))))));
|
|
217
|
+
}
|
|
218
|
+
Spotlight.displayName = "@mantine/spotlight/Spotlight";
|
|
219
|
+
|
|
220
|
+
exports.Spotlight = Spotlight;
|
|
221
|
+
//# sourceMappingURL=Spotlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spotlight.js","sources":["../../src/Spotlight/Spotlight.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n OptionalPortal,\n GroupedTransition,\n MantineTransition,\n Overlay,\n Paper,\n DefaultProps,\n ClassNames,\n MantineShadow,\n TextInput,\n getDefaultZIndex,\n} from '@mantine/core';\nimport { useScrollLock, useFocusTrap, useDidUpdate, useFocusReturn } from '@mantine/hooks';\nimport { DefaultAction, DefaultActionProps } from '../DefaultAction/DefaultAction';\nimport { ActionsList, ActionsListStylesNames } from '../ActionsList/ActionsList';\nimport type { SpotlightAction } from '../types';\nimport { filterActions } from './filter-actions/filter-actions';\nimport useStyles from './Spotlight.styles';\n\nexport type SpotlightStylesNames = ClassNames<typeof useStyles> | ActionsListStylesNames;\n\nexport interface InnerSpotlightProps\n extends DefaultProps<SpotlightStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Should spotlight be rendered within Portal */\n withinPortal?: boolean;\n\n /** Premade transition or transition object */\n transition?: MantineTransition;\n\n /** Transition duration in ms, set to 0 to disable all transitions */\n transitionDuration?: number;\n\n /** Backdrop overlay color, e.g. #000 */\n overlayColor?: string;\n\n /** Backdrop overlay opacity (0-1), e.g. 0.65 */\n overlayOpacity?: number;\n\n /** Backdrop overlay blur in px */\n overlayBlur?: number;\n\n /** Value from theme.shadows or any valid css box-shadow value */\n shadow?: MantineShadow;\n\n /** Should spotlight be rendered in the center of the screen */\n centered?: boolean;\n\n /** Max spotlight width */\n maxWidth?: number;\n\n /** Top offset when spotlight is not centered */\n topOffset?: number;\n\n /** Search input placeholder */\n searchPlaceholder?: string;\n\n /** Search input icon */\n searchIcon?: React.ReactNode;\n\n /** Function used to determine how actions will be filtered based on user input */\n filter?(query: string, actions: SpotlightAction[]): SpotlightAction[];\n\n /** Message displayed when actions were not found */\n nothingFoundMessage?: React.ReactNode;\n\n /** Number of actions displayed at a time */\n limit?: number;\n\n /** Should spotlight be closed when action is triggered */\n closeOnActionTrigger?: boolean;\n\n /** Component that is used to render actions */\n actionComponent?: React.FC<DefaultActionProps>;\n\n /** Component that is used to wrap actions list */\n actionsWrapperComponent?: React.FC<{ children: React.ReactNode }> | string;\n\n /** Spotlight z-index */\n zIndex?: number;\n\n /** Should user query be highlighted in actions title */\n highlightQuery?: boolean;\n}\n\ninterface SpotlightProps extends InnerSpotlightProps {\n actions: SpotlightAction[];\n onClose(): void;\n opened: boolean;\n query: string;\n onQueryChange(query: string): void;\n}\n\nexport function Spotlight({\n query,\n onQueryChange,\n actions,\n onClose,\n opened,\n withinPortal,\n transition = 'pop',\n transitionDuration,\n classNames,\n styles,\n overlayColor = '#000',\n overlayOpacity = 0.25,\n overlayBlur = 3,\n shadow = 'md',\n centered = false,\n closeOnActionTrigger = true,\n highlightQuery = false,\n maxWidth = 600,\n topOffset = 120,\n className,\n searchPlaceholder,\n searchIcon,\n filter = filterActions,\n nothingFoundMessage,\n limit = 10,\n actionComponent = DefaultAction,\n actionsWrapperComponent: ActionsWrapper = 'div',\n zIndex = getDefaultZIndex('modal'),\n ...others\n}: SpotlightProps) {\n const [hovered, setHovered] = useState(-1);\n const { classes, cx } = useStyles(\n { centered, maxWidth, topOffset },\n { classNames, styles, name: 'Spotlight' }\n );\n\n const [, lockScroll] = useScrollLock();\n const focusTrapRef = useFocusTrap(opened);\n\n const resetHovered = () => setHovered(-1);\n const handleClose = () => {\n resetHovered();\n onClose();\n };\n\n useFocusReturn({ transitionDuration: 0, opened });\n\n const filteredActions = filter(query, actions).slice(0, limit);\n\n useDidUpdate(() => {\n if (filteredActions.length - 1 < hovered) {\n setHovered(filteredActions.length - 1);\n }\n }, [filteredActions.length]);\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n switch (event.code) {\n case 'ArrowDown': {\n event.preventDefault();\n setHovered((current) => (current < filteredActions.length - 1 ? current + 1 : 0));\n break;\n }\n\n case 'ArrowUp': {\n event.preventDefault();\n setHovered((current) => (current > 0 ? current - 1 : filteredActions.length - 1));\n break;\n }\n\n case 'Enter': {\n event.preventDefault();\n const action = filteredActions[hovered];\n action?.onTrigger?.(action);\n if (closeOnActionTrigger && action?.onTrigger) {\n handleClose();\n }\n break;\n }\n\n case 'Escape': {\n event.preventDefault();\n handleClose();\n }\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onQueryChange(event.currentTarget.value);\n if (hovered === -1) {\n setHovered(0);\n }\n };\n\n return (\n <OptionalPortal withinPortal={withinPortal} zIndex={zIndex}>\n <GroupedTransition\n onExited={() => lockScroll(false)}\n onEntered={() => lockScroll(true)}\n mounted={opened}\n transitions={{\n spotlight: {\n duration: transitionDuration,\n transition,\n timingFunction: 'ease',\n },\n overlay: {\n duration: transitionDuration / 2,\n transition: 'fade',\n timingFunction: 'ease',\n },\n }}\n >\n {(transitionStyles) => (\n <div className={cx(classes.root, className)} {...others}>\n <div className={classes.inner} ref={focusTrapRef}>\n <Paper\n style={transitionStyles.spotlight}\n className={classes.spotlight}\n shadow={shadow}\n onMouseLeave={resetHovered}\n >\n <TextInput\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n classNames={{ input: classes.searchInput }}\n size=\"lg\"\n placeholder={searchPlaceholder}\n icon={searchIcon}\n onMouseEnter={resetHovered}\n />\n <ActionsWrapper>\n <ActionsList\n highlightQuery={highlightQuery}\n actions={filteredActions}\n actionComponent={actionComponent}\n hovered={hovered}\n query={query}\n nothingFoundMessage={nothingFoundMessage}\n onActionHover={setHovered}\n onActionTrigger={(action) => {\n action.onTrigger(action);\n closeOnActionTrigger && handleClose();\n }}\n styles={styles}\n classNames={classNames}\n />\n </ActionsWrapper>\n </Paper>\n\n <div style={transitionStyles.overlay}>\n <Overlay\n className={classes.overlay}\n zIndex={1}\n onMouseDown={handleClose}\n color={overlayColor}\n opacity={overlayOpacity}\n blur={overlayBlur}\n />\n </div>\n </div>\n </div>\n )}\n </GroupedTransition>\n </OptionalPortal>\n );\n}\n\nSpotlight.displayName = '@mantine/spotlight/Spotlight';\n"],"names":["filterActions","DefaultAction","getDefaultZIndex","useState","useStyles","useScrollLock","useFocusTrap","useFocusReturn","useDidUpdate","React","OptionalPortal","GroupedTransition","Paper","TextInput","ActionsList","Overlay"],"mappings":";;;;;;;;;;;;;;;;AAAA,IA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AI,aAAa,EAAE,UAAU;AAC7B,IAAI,eAAe,EAAE,CAAC,MAAM,KAAK;AACjC,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,oBAAoB,IAAI,WAAW,EAAE,CAAC;AAC5C,KAAK;AACL,IAAI,MAAM;AACV,IAAI,UAAU;AACd,GAAG,CAAC,CAAC,CAAC,kBAAkBL,cAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACnD,IAAI,KAAK,EAAE,gBAAgB,CAAC,OAAO;AACnC,GAAG,kBAAkBA,cAAK,CAAC,aAAa,CAACM,YAAO,EAAE;AAClD,IAAI,SAAS,EAAE,OAAO,CAAC,OAAO;AAC9B,IAAI,MAAM,EAAE,CAAC;AACb,IAAI,WAAW,EAAE,WAAW;AAC5B,IAAI,KAAK,EAAE,YAAY;AACvB,IAAI,OAAO,EAAE,cAAc;AAC3B,IAAI,IAAI,EAAE,WAAW;AACrB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACV,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@mantine/core');
|
|
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));
|
|
26
|
+
var useStyles = core.createStyles((theme, { centered, maxWidth, topOffset }) => ({
|
|
27
|
+
root: __spreadProps(__spreadValues({}, theme.fn.cover()), {
|
|
28
|
+
position: "fixed"
|
|
29
|
+
}),
|
|
30
|
+
spotlight: {
|
|
31
|
+
position: "relative",
|
|
32
|
+
zIndex: 2,
|
|
33
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.white,
|
|
34
|
+
borderRadius: theme.radius.sm,
|
|
35
|
+
width: "100%",
|
|
36
|
+
maxWidth,
|
|
37
|
+
overflow: "hidden"
|
|
38
|
+
},
|
|
39
|
+
overlay: __spreadProps(__spreadValues({}, theme.fn.cover()), {
|
|
40
|
+
position: "fixed"
|
|
41
|
+
}),
|
|
42
|
+
inner: {
|
|
43
|
+
height: "100vh",
|
|
44
|
+
display: "flex",
|
|
45
|
+
flexDirection: "column",
|
|
46
|
+
paddingTop: centered ? theme.spacing.md : topOffset,
|
|
47
|
+
justifyContent: centered ? "center" : "flex-start",
|
|
48
|
+
alignItems: "center"
|
|
49
|
+
},
|
|
50
|
+
searchInput: {
|
|
51
|
+
border: 0,
|
|
52
|
+
borderBottomRightRadius: 0,
|
|
53
|
+
borderBottomLeftRadius: 0,
|
|
54
|
+
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.white
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
exports.default = useStyles;
|
|
59
|
+
//# sourceMappingURL=Spotlight.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spotlight.styles.js","sources":["../../src/Spotlight/Spotlight.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\nexport interface SpotlightStylesParams {\n centered: boolean;\n maxWidth: number;\n topOffset: number;\n}\n\nexport default createStyles((theme, { centered, maxWidth, topOffset }: SpotlightStylesParams) => ({\n root: {\n ...theme.fn.cover(),\n position: 'fixed',\n },\n\n spotlight: {\n position: 'relative',\n zIndex: 2,\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.white,\n borderRadius: theme.radius.sm,\n width: '100%',\n maxWidth,\n overflow: 'hidden',\n },\n\n overlay: {\n ...theme.fn.cover(),\n position: 'fixed',\n },\n\n inner: {\n height: '100vh',\n display: 'flex',\n flexDirection: 'column',\n paddingTop: centered ? theme.spacing.md : topOffset,\n justifyContent: centered ? 'center' : 'flex-start',\n alignItems: 'center',\n },\n\n searchInput: {\n border: 0,\n borderBottomRightRadius: 0,\n borderBottomLeftRadius: 0,\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.white,\n },\n}));\n"],"names":["createStyles"],"mappings":";;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,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,IA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AAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK;AACtF,IAAI,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE;AACjC,IAAI,KAAK,EAAE,MAAM;AACjB,IAAI,QAAQ;AACZ,IAAI,QAAQ,EAAE,QAAQ;AACtB,GAAG;AACH,EAAE,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE;AAC/D,IAAI,QAAQ,EAAE,OAAO;AACrB,GAAG,CAAC;AACJ,EAAE,KAAK,EAAE;AACT,IAAI,MAAM,EAAE,OAAO;AACnB,IAAI,OAAO,EAAE,MAAM;AACnB,IAAI,aAAa,EAAE,QAAQ;AAC3B,IAAI,UAAU,EAAE,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS;AACvD,IAAI,cAAc,EAAE,QAAQ,GAAG,QAAQ,GAAG,YAAY;AACtD,IAAI,UAAU,EAAE,QAAQ;AACxB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,MAAM,EAAE,CAAC;AACb,IAAI,uBAAuB,EAAE,CAAC;AAC9B,IAAI,sBAAsB,EAAE,CAAC;AAC7B,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK;AACtF,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function getKeywords(keywords) {
|
|
6
|
+
if (Array.isArray(keywords)) {
|
|
7
|
+
return keywords.map((keyword) => keyword.trim()).join(",").toLowerCase().trim();
|
|
8
|
+
}
|
|
9
|
+
if (typeof keywords === "string") {
|
|
10
|
+
return keywords.toLowerCase().trim();
|
|
11
|
+
}
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
function filterActions(_query, actions) {
|
|
15
|
+
const query = _query.trim().toLowerCase();
|
|
16
|
+
return actions.filter((action) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return ((_a = action.title) == null ? void 0 : _a.toLowerCase().includes(query)) || ((_b = action.description) == null ? void 0 : _b.toLowerCase().includes(query)) || getKeywords(action.keywords).includes(query);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.filterActions = filterActions;
|
|
23
|
+
//# sourceMappingURL=filter-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-actions.js","sources":["../../../src/Spotlight/filter-actions/filter-actions.ts"],"sourcesContent":["import type { SpotlightAction } from '../../types';\n\nfunction getKeywords(keywords: string | string[]) {\n if (Array.isArray(keywords)) {\n return keywords\n .map((keyword) => keyword.trim())\n .join(',')\n .toLowerCase()\n .trim();\n }\n\n if (typeof keywords === 'string') {\n return keywords.toLowerCase().trim();\n }\n\n return '';\n}\n\nexport function filterActions(_query: string, actions: SpotlightAction[]) {\n const query = _query.trim().toLowerCase();\n return actions.filter(\n (action) =>\n action.title?.toLowerCase().includes(query) ||\n action.description?.toLowerCase().includes(query) ||\n getKeywords(action.keywords).includes(query)\n );\n}\n"],"names":[],"mappings":";;;;AAAA,SAAS,WAAW,CAAC,QAAQ,EAAE;AAC/B,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC/B,IAAI,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AACpF,GAAG;AACH,EAAE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AACpC,IAAI,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AACzC,GAAG;AACH,EAAE,OAAO,EAAE,CAAC;AACZ,CAAC;AACM,SAAS,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/C,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC5C,EAAE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK;AACpC,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,WAAW,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxN,GAAG,CAAC,CAAC;AACL;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const SpotlightContext = React.createContext(null);
|
|
8
|
+
function useSpotlight() {
|
|
9
|
+
const ctx = React.useContext(SpotlightContext);
|
|
10
|
+
if (!ctx) {
|
|
11
|
+
throw new Error("[@mantine/spotlight] SpotlightProvider was not found in tree");
|
|
12
|
+
}
|
|
13
|
+
return ctx;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.SpotlightContext = SpotlightContext;
|
|
17
|
+
exports.useSpotlight = useSpotlight;
|
|
18
|
+
//# sourceMappingURL=Spotlight.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spotlight.context.js","sources":["../src/Spotlight.context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { SpotlightAction } from './types';\n\nexport interface SpotlightContextProps {\n /** Opens spotlight */\n openSpotlight(): void;\n\n /** Closes spotlight */\n closeSpotlight(): void;\n\n /** Toggles spotlight opened state */\n toggleSpotlight(): void;\n\n /** Triggers action with given id */\n triggerAction(actionId: string): void;\n\n /** Registers additional actions */\n registerActions(action: SpotlightAction[]): void;\n\n /** Removes actions with given ids */\n removeActions(actionIds: string[]): void;\n\n /** Current opened state */\n opened: boolean;\n\n /** List of registered actions */\n actions: SpotlightAction[];\n\n /** Search query */\n query: string;\n}\n\nexport const SpotlightContext = createContext<SpotlightContextProps>(null);\n\nexport function useSpotlight() {\n const ctx = useContext(SpotlightContext);\n\n if (!ctx) {\n throw new Error('[@mantine/spotlight] SpotlightProvider was not found in tree');\n }\n\n return ctx;\n}\n"],"names":["createContext","useContext"],"mappings":";;;;;;AACY,MAAC,gBAAgB,GAAGA,mBAAa,CAAC,IAAI,EAAE;AAC7C,SAAS,YAAY,GAAG;AAC/B,EAAE,MAAM,GAAG,GAAGC,gBAAU,CAAC,gBAAgB,CAAC,CAAC;AAC3C,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ,IAAI,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;AACpF,GAAG;AACH,EAAE,OAAO,GAAG,CAAC;AACb;;;;;"}
|