@teambit/command-bar 0.0.707 → 0.0.710
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/command-bar.module.scss +11 -0
- package/command-bar.ui.runtime.tsx +48 -36
- package/dist/command-bar.module.scss +11 -0
- package/dist/command-bar.ui.runtime.d.ts +10 -11
- package/dist/command-bar.ui.runtime.js +81 -55
- package/dist/command-bar.ui.runtime.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +0 -32
- package/dist/index.js.map +1 -1
- package/dist/searchers/command-searcher/command-result.d.ts +7 -0
- package/dist/searchers/command-searcher/command-result.js +93 -0
- package/dist/searchers/command-searcher/command-result.js.map +1 -0
- package/dist/searchers/command-searcher/command-result.module.scss +15 -0
- package/dist/searchers/command-searcher/command-searcher.d.ts +9 -0
- package/dist/searchers/command-searcher/command-searcher.js +74 -0
- package/dist/searchers/command-searcher/command-searcher.js.map +1 -0
- package/dist/searchers/command-searcher/command.d.ts +8 -0
- package/dist/searchers/command-searcher/command.js +3 -0
- package/dist/searchers/command-searcher/command.js.map +1 -0
- package/dist/{ui → searchers}/command-searcher/index.d.ts +0 -0
- package/dist/{ui → searchers}/command-searcher/index.js +0 -0
- package/dist/{ui → searchers}/command-searcher/index.js.map +0 -0
- package/dist/searchers/index.d.ts +2 -0
- package/dist/searchers/index.js +23 -0
- package/dist/{ui/command-bar-context → searchers}/index.js.map +1 -1
- package/dist/searchers/search-provider.d.ts +7 -0
- package/dist/searchers/search-provider.js +3 -0
- package/dist/searchers/search-provider.js.map +1 -0
- package/dist/types.d.ts +1 -15
- package/package-tar/teambit-command-bar-0.0.710.tgz +0 -0
- package/package.json +14 -14
- package/{preview-1649733938651.js → preview-1650252279523.js} +2 -2
- package/searchers/command-searcher/command-result.module.scss +15 -0
- package/searchers/command-searcher/command-result.tsx +25 -0
- package/searchers/command-searcher/command-searcher.tsx +31 -0
- package/searchers/command-searcher/command.ts +8 -0
- package/{ui → searchers}/command-searcher/index.ts +0 -0
- package/searchers/index.ts +2 -0
- package/searchers/search-provider.ts +8 -0
- package/types.tsx +2 -17
- package/dist/ui/autocomplete-input/autocomplete-input.d.ts +0 -11
- package/dist/ui/autocomplete-input/autocomplete-input.js +0 -112
- package/dist/ui/autocomplete-input/autocomplete-input.js.map +0 -1
- package/dist/ui/autocomplete-input/autocomplete-input.module.scss +0 -13
- package/dist/ui/autocomplete-input/index.d.ts +0 -1
- package/dist/ui/autocomplete-input/index.js +0 -20
- package/dist/ui/autocomplete-input/index.js.map +0 -1
- package/dist/ui/command-bar/command-bar.d.ts +0 -9
- package/dist/ui/command-bar/command-bar.js +0 -149
- package/dist/ui/command-bar/command-bar.js.map +0 -1
- package/dist/ui/command-bar/command-bar.module.scss +0 -44
- package/dist/ui/command-bar/index.d.ts +0 -1
- package/dist/ui/command-bar/index.js +0 -29
- package/dist/ui/command-bar/index.js.map +0 -1
- package/dist/ui/command-bar-context/command-bar-context.d.ts +0 -3
- package/dist/ui/command-bar-context/command-bar-context.js +0 -21
- package/dist/ui/command-bar-context/command-bar-context.js.map +0 -1
- package/dist/ui/command-bar-context/index.d.ts +0 -1
- package/dist/ui/command-bar-context/index.js +0 -23
- package/dist/ui/command-bar-item/command-bar-item.d.ts +0 -7
- package/dist/ui/command-bar-item/command-bar-item.js +0 -109
- package/dist/ui/command-bar-item/command-bar-item.js.map +0 -1
- package/dist/ui/command-bar-item/command-bar-item.module.scss +0 -38
- package/dist/ui/command-bar-item/index.d.ts +0 -1
- package/dist/ui/command-bar-item/index.js +0 -29
- package/dist/ui/command-bar-item/index.js.map +0 -1
- package/dist/ui/command-searcher/command-searcher.d.ts +0 -8
- package/dist/ui/command-searcher/command-searcher.js +0 -67
- package/dist/ui/command-searcher/command-searcher.js.map +0 -1
- package/dist/ui/component-searcher/component-searcher.d.ts +0 -14
- package/dist/ui/component-searcher/component-searcher.js +0 -89
- package/dist/ui/component-searcher/component-searcher.js.map +0 -1
- package/dist/ui/component-searcher/index.d.ts +0 -1
- package/dist/ui/component-searcher/index.js +0 -23
- package/dist/ui/component-searcher/index.js.map +0 -1
- package/package-tar/teambit-command-bar-0.0.707.tgz +0 -0
- package/ui/autocomplete-input/autocomplete-input.module.scss +0 -13
- package/ui/autocomplete-input/autocomplete-input.tsx +0 -62
- package/ui/autocomplete-input/index.ts +0 -1
- package/ui/command-bar/command-bar.module.scss +0 -44
- package/ui/command-bar/command-bar.tsx +0 -66
- package/ui/command-bar/index.ts +0 -1
- package/ui/command-bar-context/command-bar-context.tsx +0 -4
- package/ui/command-bar-context/index.ts +0 -1
- package/ui/command-bar-item/command-bar-item.module.scss +0 -38
- package/ui/command-bar-item/command-bar-item.tsx +0 -30
- package/ui/command-bar-item/index.ts +0 -1
- package/ui/command-searcher/command-searcher.ts +0 -31
- package/ui/component-searcher/component-searcher.ts +0 -44
- package/ui/component-searcher/index.ts +0 -1
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _autocompleteInput = require("./autocomplete-input");
|
|
8
|
-
|
|
9
|
-
Object.keys(_autocompleteInput).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _autocompleteInput[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _autocompleteInput[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './autocomplete-input';\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CardProps } from '@teambit/base-ui.surfaces.card';
|
|
3
|
-
import type { CommandBarUI } from '../../command-bar.ui.runtime';
|
|
4
|
-
import { CommanderSearchResult } from '../../types';
|
|
5
|
-
export declare type CommandBarProps = {
|
|
6
|
-
search: (term: string, limit?: number) => CommanderSearchResult[];
|
|
7
|
-
commander: CommandBarUI;
|
|
8
|
-
} & CardProps;
|
|
9
|
-
export declare function CommandBar({ search, commander, elevation, className, ...rest }: CommandBarProps): JSX.Element;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
exports.CommandBar = CommandBar;
|
|
13
|
-
|
|
14
|
-
function _extends2() {
|
|
15
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
|
-
|
|
17
|
-
_extends2 = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _objectWithoutProperties2() {
|
|
25
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
26
|
-
|
|
27
|
-
_objectWithoutProperties2 = function () {
|
|
28
|
-
return data;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function _react() {
|
|
35
|
-
const data = _interopRequireWildcard(require("react"));
|
|
36
|
-
|
|
37
|
-
_react = function () {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return data;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _classnames() {
|
|
45
|
-
const data = _interopRequireDefault(require("classnames"));
|
|
46
|
-
|
|
47
|
-
_classnames = function () {
|
|
48
|
-
return data;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return data;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function _baseUiSurfaces() {
|
|
55
|
-
const data = require("@teambit/base-ui.surfaces.card");
|
|
56
|
-
|
|
57
|
-
_baseUiSurfaces = function () {
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return data;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function _autocompleteInput() {
|
|
65
|
-
const data = require("../autocomplete-input");
|
|
66
|
-
|
|
67
|
-
_autocompleteInput = function () {
|
|
68
|
-
return data;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return data;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function _commandBarItem() {
|
|
75
|
-
const data = require("../command-bar-item");
|
|
76
|
-
|
|
77
|
-
_commandBarItem = function () {
|
|
78
|
-
return data;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
return data;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function _commandBarModule() {
|
|
85
|
-
const data = _interopRequireDefault(require("./command-bar.module.scss"));
|
|
86
|
-
|
|
87
|
-
_commandBarModule = function () {
|
|
88
|
-
return data;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
95
|
-
|
|
96
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
97
|
-
|
|
98
|
-
const MIN_IDX = 0;
|
|
99
|
-
|
|
100
|
-
function CommandBar(_ref) {
|
|
101
|
-
let {
|
|
102
|
-
search,
|
|
103
|
-
commander,
|
|
104
|
-
elevation = 'high',
|
|
105
|
-
className
|
|
106
|
-
} = _ref,
|
|
107
|
-
rest = (0, _objectWithoutProperties2().default)(_ref, ["search", "commander", "elevation", "className"]);
|
|
108
|
-
const [term, setTerm] = (0, _react().useState)('');
|
|
109
|
-
const options = (0, _react().useMemo)(() => search(term), [term, search]);
|
|
110
|
-
const [activeIdx, setActive] = (0, _react().useState)(MIN_IDX);
|
|
111
|
-
const increment = (0, _react().useCallback)(() => setActive(x => Math.min(x + 1, options.length - 1)), [options.length]);
|
|
112
|
-
const decrement = (0, _react().useCallback)(() => setActive(x => Math.max(x - 1, MIN_IDX)), []);
|
|
113
|
-
const [visible, setVisibility] = (0, _react().useState)(false);
|
|
114
|
-
commander.setVisibility = setVisibility;
|
|
115
|
-
const handleEnter = (0, _react().useCallback)(() => {
|
|
116
|
-
var _options$activeIdx;
|
|
117
|
-
|
|
118
|
-
setVisibility(false);
|
|
119
|
-
(_options$activeIdx = options[activeIdx]) === null || _options$activeIdx === void 0 ? void 0 : _options$activeIdx.handler();
|
|
120
|
-
}, [options, activeIdx]);
|
|
121
|
-
(0, _react().useEffect)(() => setTerm(''), [visible]);
|
|
122
|
-
(0, _react().useEffect)(() => setActive(MIN_IDX), [options]);
|
|
123
|
-
return /*#__PURE__*/_react().default.createElement(_baseUiSurfaces().Card, (0, _extends2().default)({}, rest, {
|
|
124
|
-
elevation: elevation,
|
|
125
|
-
className: (0, _classnames().default)(className, _commandBarModule().default.commandBar, visible && _commandBarModule().default.visible)
|
|
126
|
-
}), /*#__PURE__*/_react().default.createElement(_autocompleteInput().AutoCompleteInput, {
|
|
127
|
-
value: term,
|
|
128
|
-
focus: visible,
|
|
129
|
-
className: _commandBarModule().default.input,
|
|
130
|
-
placeholder: "Search anything or type > to only search commands",
|
|
131
|
-
onChange: e => setTerm(e.target.value),
|
|
132
|
-
onDown: increment,
|
|
133
|
-
onUp: decrement,
|
|
134
|
-
onEnter: handleEnter,
|
|
135
|
-
onEscape: () => setVisibility(false),
|
|
136
|
-
onBlur: () => setVisibility(false)
|
|
137
|
-
}), /*#__PURE__*/_react().default.createElement("div", {
|
|
138
|
-
className: _commandBarModule().default.results
|
|
139
|
-
}, options.map((x, idx) => /*#__PURE__*/_react().default.createElement(_commandBarItem().CommandBarItem, {
|
|
140
|
-
key: idx // use index instead of id to avoid duplicate keys
|
|
141
|
-
,
|
|
142
|
-
entry: x,
|
|
143
|
-
active: idx === activeIdx // mouseDown happens before blur, which closes the command bar
|
|
144
|
-
,
|
|
145
|
-
onMouseDown: x.handler
|
|
146
|
-
}))));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
//# sourceMappingURL=command-bar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["command-bar.tsx"],"names":["MIN_IDX","CommandBar","search","commander","elevation","className","rest","term","setTerm","options","activeIdx","setActive","increment","x","Math","min","length","decrement","max","visible","setVisibility","handleEnter","handler","styles","commandBar","input","e","target","value","results","map","idx"],"mappings":"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","sourcesContent":["import React, { useCallback, useEffect, useState, useMemo } from 'react';\nimport classNames from 'classnames';\nimport { Card, CardProps } from '@teambit/base-ui.surfaces.card';\nimport type { CommandBarUI } from '../../command-bar.ui.runtime';\nimport { CommanderSearchResult } from '../../types';\nimport { AutoCompleteInput } from '../autocomplete-input';\nimport { CommandBarItem } from '../command-bar-item';\nimport styles from './command-bar.module.scss';\n\nexport type CommandBarProps = {\n search: (term: string, limit?: number) => CommanderSearchResult[];\n commander: CommandBarUI;\n} & CardProps;\n\nconst MIN_IDX = 0;\n\nexport function CommandBar({ search, commander, elevation = 'high', className, ...rest }: CommandBarProps) {\n const [term, setTerm] = useState('');\n const options = useMemo(() => search(term), [term, search]);\n const [activeIdx, setActive] = useState(MIN_IDX);\n const increment = useCallback(() => setActive((x) => Math.min(x + 1, options.length - 1)), [options.length]);\n const decrement = useCallback(() => setActive((x) => Math.max(x - 1, MIN_IDX)), []);\n const [visible, setVisibility] = useState(false);\n\n commander.setVisibility = setVisibility;\n\n const handleEnter = useCallback(() => {\n setVisibility(false);\n options[activeIdx]?.handler();\n }, [options, activeIdx]);\n\n useEffect(() => setTerm(''), [visible]);\n useEffect(() => setActive(MIN_IDX), [options]);\n\n return (\n <Card\n {...rest}\n elevation={elevation}\n className={classNames(className, styles.commandBar, visible && styles.visible)}\n >\n <AutoCompleteInput\n value={term}\n focus={visible}\n className={styles.input}\n placeholder=\"Search anything or type > to only search commands\"\n onChange={(e) => setTerm(e.target.value)}\n onDown={increment}\n onUp={decrement}\n onEnter={handleEnter}\n onEscape={() => setVisibility(false)}\n onBlur={() => setVisibility(false)}\n />\n <div className={styles.results}>\n {options.map((x, idx) => (\n <CommandBarItem\n key={idx} // use index instead of id to avoid duplicate keys\n entry={x}\n active={idx === activeIdx}\n // mouseDown happens before blur, which closes the command bar\n onMouseDown={x.handler}\n />\n ))}\n </div>\n </Card>\n );\n}\n"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
@import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
-
|
|
3
|
-
.commandBar {
|
|
4
|
-
display: none;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
|
|
7
|
-
position: fixed;
|
|
8
|
-
top: 130px;
|
|
9
|
-
left: 50%;
|
|
10
|
-
transform: translate(-50%, 0);
|
|
11
|
-
width: 643px;
|
|
12
|
-
border: 1px solid var(--bit-border-color, #babec9);
|
|
13
|
-
max-width: 90%;
|
|
14
|
-
|
|
15
|
-
overflow: hidden; // enforce border-radius
|
|
16
|
-
|
|
17
|
-
color: var(--bit-text-color-heavy, #2b2b2b);
|
|
18
|
-
box-shadow: 0 40px 60px 0 rgba(0, 0, 0, 0.32);
|
|
19
|
-
|
|
20
|
-
&.visible {
|
|
21
|
-
display: flex;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.commandBar {
|
|
26
|
-
padding: 0px;
|
|
27
|
-
z-index: $modal-z-index;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.input {
|
|
31
|
-
padding: 0 24px;
|
|
32
|
-
font-size: 20px;
|
|
33
|
-
height: 56px;
|
|
34
|
-
line-height: 56px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.results {
|
|
38
|
-
font-size: 14px;
|
|
39
|
-
|
|
40
|
-
&:not(:empty) {
|
|
41
|
-
margin-bottom: 8px;
|
|
42
|
-
border-top: solid 1px var(--bit-border-color, #babec9);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CommandBar, CommandBarProps } from './command-bar';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "CommandBar", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _commandBar().CommandBar;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "CommandBarProps", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _commandBar().CommandBarProps;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
function _commandBar() {
|
|
20
|
-
const data = require("./command-bar");
|
|
21
|
-
|
|
22
|
-
_commandBar = function () {
|
|
23
|
-
return data;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { CommandBar, CommandBarProps } from './command-bar';\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CommandBarContext = void 0;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = require("react");
|
|
10
|
-
|
|
11
|
-
_react = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const CommandBarContext = /*#__PURE__*/(0, _react().createContext)(undefined);
|
|
19
|
-
exports.CommandBarContext = CommandBarContext;
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=command-bar-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["command-bar-context.tsx"],"names":["CommandBarContext","undefined"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,iBAAiB,gBAAG,4BAAwCC,SAAxC,CAA1B","sourcesContent":["import { createContext } from 'react';\nimport { CommandBarUI } from '../../command-bar.ui.runtime';\n\nexport const CommandBarContext = createContext<CommandBarUI | undefined>(undefined);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CommandBarContext } from './command-bar-context';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "CommandBarContext", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _commandBarContext().CommandBarContext;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
function _commandBarContext() {
|
|
14
|
-
const data = require("./command-bar-context");
|
|
15
|
-
|
|
16
|
-
_commandBarContext = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CommanderSearchResult } from '../../types';
|
|
3
|
-
export declare type CommandItemProps = {
|
|
4
|
-
active?: boolean;
|
|
5
|
-
entry: CommanderSearchResult;
|
|
6
|
-
} & React.HTMLAttributes<HTMLDivElement>;
|
|
7
|
-
export declare function CommandBarItem({ entry, className, active, ...rest }: CommandItemProps): JSX.Element;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.CommandBarItem = CommandBarItem;
|
|
9
|
-
|
|
10
|
-
function _extends2() {
|
|
11
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
|
|
13
|
-
_extends2 = function () {
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _objectWithoutProperties2() {
|
|
21
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
22
|
-
|
|
23
|
-
_objectWithoutProperties2 = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _react() {
|
|
31
|
-
const data = _interopRequireDefault(require("react"));
|
|
32
|
-
|
|
33
|
-
_react = function () {
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _classnames() {
|
|
41
|
-
const data = _interopRequireDefault(require("classnames"));
|
|
42
|
-
|
|
43
|
-
_classnames = function () {
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _uiFoundationUi() {
|
|
51
|
-
const data = require("@teambit/ui-foundation.ui.keycap");
|
|
52
|
-
|
|
53
|
-
_uiFoundationUi = function () {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _baseUiText() {
|
|
61
|
-
const data = require("@teambit/base-ui.text.muted-text");
|
|
62
|
-
|
|
63
|
-
_baseUiText = function () {
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _commandBarItemModule() {
|
|
71
|
-
const data = _interopRequireDefault(require("./command-bar-item.module.scss"));
|
|
72
|
-
|
|
73
|
-
_commandBarItemModule = function () {
|
|
74
|
-
return data;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return data;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function CommandBarItem(_ref) {
|
|
81
|
-
let {
|
|
82
|
-
entry,
|
|
83
|
-
className,
|
|
84
|
-
active
|
|
85
|
-
} = _ref,
|
|
86
|
-
rest = (0, _objectWithoutProperties2().default)(_ref, ["entry", "className", "active"]);
|
|
87
|
-
const {
|
|
88
|
-
handler,
|
|
89
|
-
displayName: name,
|
|
90
|
-
icon,
|
|
91
|
-
iconAlt,
|
|
92
|
-
keybinding
|
|
93
|
-
} = entry;
|
|
94
|
-
const firstKeybinding = Array.isArray(keybinding) ? keybinding[0] : keybinding;
|
|
95
|
-
return /*#__PURE__*/_react().default.createElement("div", (0, _extends2().default)({}, rest, {
|
|
96
|
-
className: (0, _classnames().default)(className, _commandBarItemModule().default.commandBarOption, active && _commandBarItemModule().default.active),
|
|
97
|
-
onMouseDown: handler
|
|
98
|
-
}), icon && /*#__PURE__*/_react().default.createElement("img", {
|
|
99
|
-
src: icon,
|
|
100
|
-
alt: iconAlt,
|
|
101
|
-
className: _commandBarItemModule().default.icon
|
|
102
|
-
}), /*#__PURE__*/_react().default.createElement("div", {
|
|
103
|
-
className: _commandBarItemModule().default.name
|
|
104
|
-
}, name), firstKeybinding && /*#__PURE__*/_react().default.createElement(_uiFoundationUi().KeySequence, {
|
|
105
|
-
className: (0, _classnames().default)(_commandBarItemModule().default.commandKeys, _baseUiText().mutedText)
|
|
106
|
-
}, firstKeybinding));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
//# sourceMappingURL=command-bar-item.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["command-bar-item.tsx"],"names":["CommandBarItem","entry","className","active","rest","handler","displayName","name","icon","iconAlt","keybinding","firstKeybinding","Array","isArray","styles","commandBarOption","commandKeys","mutedText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAOO,SAASA,cAAT,OAAiF;AAAA,MAAzD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,SAAT;AAAoBC,IAAAA;AAApB,GAAyD;AAAA,MAA1BC,IAA0B;AACtF,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,WAAW,EAAEC,IAAxB;AAA8BC,IAAAA,IAA9B;AAAoCC,IAAAA,OAApC;AAA6CC,IAAAA;AAA7C,MAA4DT,KAAlE;AACA,QAAMU,eAAe,GAAGC,KAAK,CAACC,OAAN,CAAcH,UAAd,IAA4BA,UAAU,CAAC,CAAD,CAAtC,GAA4CA,UAApE;AAEA,sBACE,mEACMN,IADN;AAEE,IAAA,SAAS,EAAE,2BAAWF,SAAX,EAAsBY,gCAAOC,gBAA7B,EAA+CZ,MAAM,IAAIW,gCAAOX,MAAhE,CAFb;AAGE,IAAA,WAAW,EAAEE;AAHf,MAKGG,IAAI,iBAAI;AAAK,IAAA,GAAG,EAAEA,IAAV;AAAgB,IAAA,GAAG,EAAEC,OAArB;AAA8B,IAAA,SAAS,EAAEK,gCAAON;AAAhD,IALX,eAME;AAAK,IAAA,SAAS,EAAEM,gCAAOP;AAAvB,KAA8BA,IAA9B,CANF,EAOGI,eAAe,iBACd,+BAAC,6BAAD;AAAa,IAAA,SAAS,EAAE,2BAAWG,gCAAOE,WAAlB,EAA+BC,uBAA/B;AAAxB,KAAoEN,eAApE,CARJ,CADF;AAaD","sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { KeySequence } from '@teambit/ui-foundation.ui.keycap';\nimport { mutedText } from '@teambit/base-ui.text.muted-text';\nimport { CommanderSearchResult } from '../../types';\nimport styles from './command-bar-item.module.scss';\n\nexport type CommandItemProps = {\n active?: boolean;\n entry: CommanderSearchResult;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nexport function CommandBarItem({ entry, className, active, ...rest }: CommandItemProps) {\n const { handler, displayName: name, icon, iconAlt, keybinding } = entry;\n const firstKeybinding = Array.isArray(keybinding) ? keybinding[0] : keybinding;\n\n return (\n <div\n {...rest}\n className={classnames(className, styles.commandBarOption, active && styles.active)}\n onMouseDown={handler}\n >\n {icon && <img src={icon} alt={iconAlt} className={styles.icon} />}\n <div className={styles.name}>{name}</div>\n {firstKeybinding && (\n <KeySequence className={classnames(styles.commandKeys, mutedText)}>{firstKeybinding}</KeySequence>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
.commandBarOption {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
|
|
5
|
-
height: 40px;
|
|
6
|
-
padding: 0 24px;
|
|
7
|
-
transition: all 180ms;
|
|
8
|
-
|
|
9
|
-
user-select: none;
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
|
|
12
|
-
&:hover {
|
|
13
|
-
background-color: var(--bit-bg-heavy, #f6f6f6);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&.active,
|
|
17
|
-
&.active:hover {
|
|
18
|
-
background-color: var(--bit-accent-bg, #eceaff);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.name {
|
|
23
|
-
flex: 1 1;
|
|
24
|
-
text-overflow: ellipsis;
|
|
25
|
-
overflow: hidden;
|
|
26
|
-
white-space: nowrap;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.commandKeys {
|
|
30
|
-
float: right;
|
|
31
|
-
font-size: 15px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.icon {
|
|
35
|
-
width: 16px;
|
|
36
|
-
height: 16px;
|
|
37
|
-
margin-right: 8px;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CommandBarItem, CommandItemProps } from './command-bar-item';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "CommandBarItem", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _commandBarItem().CommandBarItem;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "CommandItemProps", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _commandBarItem().CommandItemProps;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
function _commandBarItem() {
|
|
20
|
-
const data = require("./command-bar-item");
|
|
21
|
-
|
|
22
|
-
_commandBarItem = function () {
|
|
23
|
-
return data;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { CommandBarItem, CommandItemProps } from './command-bar-item';\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CommanderSearchResult, SearchProvider } from '../../types';
|
|
2
|
-
export declare class CommandSearcher implements SearchProvider {
|
|
3
|
-
private fuseCommands;
|
|
4
|
-
constructor(commands: CommanderSearchResult[]);
|
|
5
|
-
update(commands: CommanderSearchResult[]): void;
|
|
6
|
-
search(term: string, limit: number): CommanderSearchResult[];
|
|
7
|
-
test(term: string): boolean;
|
|
8
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.string.replace.js");
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
exports.CommandSearcher = void 0;
|
|
13
|
-
|
|
14
|
-
function _defineProperty2() {
|
|
15
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
|
-
_defineProperty2 = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _fuse() {
|
|
25
|
-
const data = _interopRequireDefault(require("fuse.js"));
|
|
26
|
-
|
|
27
|
-
_fuse = function () {
|
|
28
|
-
return data;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const searchedKeys = ['displayName'];
|
|
35
|
-
|
|
36
|
-
class CommandSearcher {
|
|
37
|
-
constructor(commands) {
|
|
38
|
-
(0, _defineProperty2().default)(this, "fuseCommands", new (_fuse().default)([], {
|
|
39
|
-
// weight can be included here.
|
|
40
|
-
// fields loses weight the longer they get, so it seems ok for now.
|
|
41
|
-
keys: searchedKeys
|
|
42
|
-
}));
|
|
43
|
-
this.fuseCommands.setCollection(commands);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
update(commands) {
|
|
47
|
-
this.fuseCommands.setCollection(commands);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
search(term, limit) {
|
|
51
|
-
const unprefixedPattern = term.replace(/^>/, '');
|
|
52
|
-
const searchResults = this.fuseCommands.search(unprefixedPattern, {
|
|
53
|
-
limit
|
|
54
|
-
}); // @ts-ignore this shows error on Circle for some weird reason
|
|
55
|
-
|
|
56
|
-
return searchResults.map(x => x.item);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
test(term) {
|
|
60
|
-
return term.startsWith('>');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
exports.CommandSearcher = CommandSearcher;
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=command-searcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["command-searcher.ts"],"names":["searchedKeys","CommandSearcher","constructor","commands","Fuse","keys","fuseCommands","setCollection","update","search","term","limit","unprefixedPattern","replace","searchResults","map","x","item","test","startsWith"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA,MAAMA,YAA6C,GAAG,CAAC,aAAD,CAAtD;;AAEO,MAAMC,eAAN,CAAgD;AAOrDC,EAAAA,WAAW,CAACC,QAAD,EAAoC;AAAA,0DANxB,KAAIC,eAAJ,EAAgC,EAAhC,EAAoC;AACzD;AACA;AACAC,MAAAA,IAAI,EAAEL;AAHmD,KAApC,CAMwB;AAC7C,SAAKM,YAAL,CAAkBC,aAAlB,CAAgCJ,QAAhC;AACD;;AAEDK,EAAAA,MAAM,CAACL,QAAD,EAAoC;AACxC,SAAKG,YAAL,CAAkBC,aAAlB,CAAgCJ,QAAhC;AACD;;AAEDM,EAAAA,MAAM,CAACC,IAAD,EAAeC,KAAf,EAAuD;AAC3D,UAAMC,iBAAiB,GAAGF,IAAI,CAACG,OAAL,CAAa,IAAb,EAAmB,EAAnB,CAA1B;AACA,UAAMC,aAAa,GAAG,KAAKR,YAAL,CAAkBG,MAAlB,CAAyBG,iBAAzB,EAA4C;AAAED,MAAAA;AAAF,KAA5C,CAAtB,CAF2D,CAG3D;;AACA,WAAOG,aAAa,CAACC,GAAd,CAAmBC,CAAD,IAAOA,CAAC,CAACC,IAA3B,CAAP;AACD;;AAEDC,EAAAA,IAAI,CAACR,IAAD,EAAwB;AAC1B,WAAOA,IAAI,CAACS,UAAL,CAAgB,GAAhB,CAAP;AACD;;AAxBoD","sourcesContent":["import Fuse from 'fuse.js';\nimport { CommanderSearchResult, SearchProvider } from '../../types';\n\nconst searchedKeys: (keyof CommanderSearchResult)[] = ['displayName'];\n\nexport class CommandSearcher implements SearchProvider {\n private fuseCommands = new Fuse<CommanderSearchResult>([], {\n // weight can be included here.\n // fields loses weight the longer they get, so it seems ok for now.\n keys: searchedKeys,\n });\n\n constructor(commands: CommanderSearchResult[]) {\n this.fuseCommands.setCollection(commands);\n }\n\n update(commands: CommanderSearchResult[]) {\n this.fuseCommands.setCollection(commands);\n }\n\n search(term: string, limit: number): CommanderSearchResult[] {\n const unprefixedPattern = term.replace(/^>/, '');\n const searchResults = this.fuseCommands.search(unprefixedPattern, { limit });\n // @ts-ignore this shows error on Circle for some weird reason\n return searchResults.map((x) => x.item);\n }\n\n test(term: string): boolean {\n return term.startsWith('>');\n }\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ComponentModel } from '@teambit/component';
|
|
2
|
-
import { SearchProvider, CommanderSearchResult } from '../../types';
|
|
3
|
-
declare type ComponentSearchResult = CommanderSearchResult & {
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export declare class ComponentSearcher implements SearchProvider {
|
|
7
|
-
private navigate;
|
|
8
|
-
private fuseCommands;
|
|
9
|
-
constructor(navigate: (path: string) => void);
|
|
10
|
-
update: (components: ComponentModel[]) => void;
|
|
11
|
-
search(term: string, limit: number): ComponentSearchResult[];
|
|
12
|
-
test(term: string): boolean;
|
|
13
|
-
}
|
|
14
|
-
export {};
|