@teambit/command-bar 0.0.707 → 0.0.708

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.
Files changed (90) hide show
  1. package/command-bar.module.scss +11 -0
  2. package/command-bar.ui.runtime.tsx +48 -36
  3. package/dist/command-bar.module.scss +11 -0
  4. package/dist/command-bar.ui.runtime.d.ts +10 -11
  5. package/dist/command-bar.ui.runtime.js +81 -55
  6. package/dist/command-bar.ui.runtime.js.map +1 -1
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +0 -32
  9. package/dist/index.js.map +1 -1
  10. package/dist/searchers/command-searcher/command-result.d.ts +7 -0
  11. package/dist/searchers/command-searcher/command-result.js +93 -0
  12. package/dist/searchers/command-searcher/command-result.js.map +1 -0
  13. package/dist/searchers/command-searcher/command-result.module.scss +15 -0
  14. package/dist/searchers/command-searcher/command-searcher.d.ts +9 -0
  15. package/dist/searchers/command-searcher/command-searcher.js +74 -0
  16. package/dist/searchers/command-searcher/command-searcher.js.map +1 -0
  17. package/dist/searchers/command-searcher/command.d.ts +8 -0
  18. package/dist/searchers/command-searcher/command.js +3 -0
  19. package/dist/searchers/command-searcher/command.js.map +1 -0
  20. package/dist/{ui → searchers}/command-searcher/index.d.ts +0 -0
  21. package/dist/{ui → searchers}/command-searcher/index.js +0 -0
  22. package/dist/{ui → searchers}/command-searcher/index.js.map +0 -0
  23. package/dist/searchers/index.d.ts +2 -0
  24. package/dist/searchers/index.js +23 -0
  25. package/dist/{ui/command-bar-context → searchers}/index.js.map +1 -1
  26. package/dist/searchers/search-provider.d.ts +7 -0
  27. package/dist/searchers/search-provider.js +3 -0
  28. package/dist/searchers/search-provider.js.map +1 -0
  29. package/dist/types.d.ts +1 -15
  30. package/package-tar/teambit-command-bar-0.0.708.tgz +0 -0
  31. package/package.json +13 -13
  32. package/{preview-1649733938651.js → preview-1649820303295.js} +2 -2
  33. package/searchers/command-searcher/command-result.module.scss +15 -0
  34. package/searchers/command-searcher/command-result.tsx +25 -0
  35. package/searchers/command-searcher/command-searcher.tsx +31 -0
  36. package/searchers/command-searcher/command.ts +8 -0
  37. package/{ui → searchers}/command-searcher/index.ts +0 -0
  38. package/searchers/index.ts +2 -0
  39. package/searchers/search-provider.ts +8 -0
  40. package/types.tsx +2 -17
  41. package/dist/ui/autocomplete-input/autocomplete-input.d.ts +0 -11
  42. package/dist/ui/autocomplete-input/autocomplete-input.js +0 -112
  43. package/dist/ui/autocomplete-input/autocomplete-input.js.map +0 -1
  44. package/dist/ui/autocomplete-input/autocomplete-input.module.scss +0 -13
  45. package/dist/ui/autocomplete-input/index.d.ts +0 -1
  46. package/dist/ui/autocomplete-input/index.js +0 -20
  47. package/dist/ui/autocomplete-input/index.js.map +0 -1
  48. package/dist/ui/command-bar/command-bar.d.ts +0 -9
  49. package/dist/ui/command-bar/command-bar.js +0 -149
  50. package/dist/ui/command-bar/command-bar.js.map +0 -1
  51. package/dist/ui/command-bar/command-bar.module.scss +0 -44
  52. package/dist/ui/command-bar/index.d.ts +0 -1
  53. package/dist/ui/command-bar/index.js +0 -29
  54. package/dist/ui/command-bar/index.js.map +0 -1
  55. package/dist/ui/command-bar-context/command-bar-context.d.ts +0 -3
  56. package/dist/ui/command-bar-context/command-bar-context.js +0 -21
  57. package/dist/ui/command-bar-context/command-bar-context.js.map +0 -1
  58. package/dist/ui/command-bar-context/index.d.ts +0 -1
  59. package/dist/ui/command-bar-context/index.js +0 -23
  60. package/dist/ui/command-bar-item/command-bar-item.d.ts +0 -7
  61. package/dist/ui/command-bar-item/command-bar-item.js +0 -109
  62. package/dist/ui/command-bar-item/command-bar-item.js.map +0 -1
  63. package/dist/ui/command-bar-item/command-bar-item.module.scss +0 -38
  64. package/dist/ui/command-bar-item/index.d.ts +0 -1
  65. package/dist/ui/command-bar-item/index.js +0 -29
  66. package/dist/ui/command-bar-item/index.js.map +0 -1
  67. package/dist/ui/command-searcher/command-searcher.d.ts +0 -8
  68. package/dist/ui/command-searcher/command-searcher.js +0 -67
  69. package/dist/ui/command-searcher/command-searcher.js.map +0 -1
  70. package/dist/ui/component-searcher/component-searcher.d.ts +0 -14
  71. package/dist/ui/component-searcher/component-searcher.js +0 -89
  72. package/dist/ui/component-searcher/component-searcher.js.map +0 -1
  73. package/dist/ui/component-searcher/index.d.ts +0 -1
  74. package/dist/ui/component-searcher/index.js +0 -23
  75. package/dist/ui/component-searcher/index.js.map +0 -1
  76. package/package-tar/teambit-command-bar-0.0.707.tgz +0 -0
  77. package/ui/autocomplete-input/autocomplete-input.module.scss +0 -13
  78. package/ui/autocomplete-input/autocomplete-input.tsx +0 -62
  79. package/ui/autocomplete-input/index.ts +0 -1
  80. package/ui/command-bar/command-bar.module.scss +0 -44
  81. package/ui/command-bar/command-bar.tsx +0 -66
  82. package/ui/command-bar/index.ts +0 -1
  83. package/ui/command-bar-context/command-bar-context.tsx +0 -4
  84. package/ui/command-bar-context/index.ts +0 -1
  85. package/ui/command-bar-item/command-bar-item.module.scss +0 -38
  86. package/ui/command-bar-item/command-bar-item.tsx +0 -30
  87. package/ui/command-bar-item/index.ts +0 -1
  88. package/ui/command-searcher/command-searcher.ts +0 -31
  89. package/ui/component-searcher/component-searcher.ts +0 -44
  90. package/ui/component-searcher/index.ts +0 -1
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CommandResult = CommandResult;
9
+
10
+ function _react() {
11
+ const data = _interopRequireDefault(require("react"));
12
+
13
+ _react = function () {
14
+ return data;
15
+ };
16
+
17
+ return data;
18
+ }
19
+
20
+ function _classnames() {
21
+ const data = _interopRequireDefault(require("classnames"));
22
+
23
+ _classnames = function () {
24
+ return data;
25
+ };
26
+
27
+ return data;
28
+ }
29
+
30
+ function _designUiStyles() {
31
+ const data = require("@teambit/design.ui.styles.ellipsis");
32
+
33
+ _designUiStyles = function () {
34
+ return data;
35
+ };
36
+
37
+ return data;
38
+ }
39
+
40
+ function _uiFoundationUi() {
41
+ const data = require("@teambit/ui-foundation.ui.keycap");
42
+
43
+ _uiFoundationUi = function () {
44
+ return data;
45
+ };
46
+
47
+ return data;
48
+ }
49
+
50
+ function _baseUiText() {
51
+ const data = require("@teambit/base-ui.text.muted-text");
52
+
53
+ _baseUiText = function () {
54
+ return data;
55
+ };
56
+
57
+ return data;
58
+ }
59
+
60
+ function _commandResultModule() {
61
+ const data = _interopRequireDefault(require("./command-result.module.scss"));
62
+
63
+ _commandResultModule = function () {
64
+ return data;
65
+ };
66
+
67
+ return data;
68
+ }
69
+
70
+ function CommandResult({
71
+ command
72
+ }) {
73
+ const {
74
+ icon,
75
+ iconAlt,
76
+ displayName,
77
+ keybinding
78
+ } = command;
79
+
80
+ const _keybinding = Array.isArray(keybinding) ? keybinding[0] : keybinding;
81
+
82
+ return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, icon && /*#__PURE__*/_react().default.createElement("img", {
83
+ src: icon,
84
+ alt: iconAlt,
85
+ className: _commandResultModule().default.icon
86
+ }), /*#__PURE__*/_react().default.createElement("div", {
87
+ className: (0, _classnames().default)(_designUiStyles().ellipsis, _commandResultModule().default.name)
88
+ }, displayName), _keybinding && /*#__PURE__*/_react().default.createElement(_uiFoundationUi().KeySequence, {
89
+ className: (0, _classnames().default)(_commandResultModule().default.commandKeys, _baseUiText().mutedText)
90
+ }, _keybinding));
91
+ }
92
+
93
+ //# sourceMappingURL=command-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["command-result.tsx"],"names":["CommandResult","command","icon","iconAlt","displayName","keybinding","_keybinding","Array","isArray","styles","ellipsis","name","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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMO,SAASA,aAAT,CAAuB;AAAEC,EAAAA;AAAF,CAAvB,EAAwD;AAC7D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,OAAR;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA;AAA9B,MAA6CJ,OAAnD;;AACA,QAAMK,WAAW,GAAGC,KAAK,CAACC,OAAN,CAAcH,UAAd,IAA4BA,UAAU,CAAC,CAAD,CAAtC,GAA4CA,UAAhE;;AAEA,sBACE,gEACGH,IAAI,iBAAI;AAAK,IAAA,GAAG,EAAEA,IAAV;AAAgB,IAAA,GAAG,EAAEC,OAArB;AAA8B,IAAA,SAAS,EAAEM,+BAAOP;AAAhD,IADX,eAEE;AAAK,IAAA,SAAS,EAAE,2BAAWQ,0BAAX,EAAqBD,+BAAOE,IAA5B;AAAhB,KAAoDP,WAApD,CAFF,EAGGE,WAAW,iBAAI,+BAAC,6BAAD;AAAa,IAAA,SAAS,EAAE,2BAAWG,+BAAOG,WAAlB,EAA+BC,uBAA/B;AAAxB,KAAoEP,WAApE,CAHlB,CADF;AAOD","sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { ellipsis } from '@teambit/design.ui.styles.ellipsis';\nimport { KeySequence } from '@teambit/ui-foundation.ui.keycap';\nimport { mutedText } from '@teambit/base-ui.text.muted-text';\nimport { Command } from './command';\n\nimport styles from './command-result.module.scss';\n\ntype CommandResultProps = {\n command: Command;\n};\n\nexport function CommandResult({ command }: CommandResultProps) {\n const { icon, iconAlt, displayName, keybinding } = command;\n const _keybinding = Array.isArray(keybinding) ? keybinding[0] : keybinding;\n\n return (\n <>\n {icon && <img src={icon} alt={iconAlt} className={styles.icon} />}\n <div className={classnames(ellipsis, styles.name)}>{displayName}</div>\n {_keybinding && <KeySequence className={classnames(styles.commandKeys, mutedText)}>{_keybinding}</KeySequence>}\n </>\n );\n}\n"]}
@@ -0,0 +1,15 @@
1
+ .name {
2
+ flex: 1;
3
+ }
4
+
5
+ .commandKeys {
6
+ float: right;
7
+ font-size: 0.85em;
8
+ }
9
+
10
+ .icon {
11
+ font-size: 1.15em;
12
+ width: 1em;
13
+ height: 1em;
14
+ margin-right: 0.5em;
15
+ }
@@ -0,0 +1,9 @@
1
+ import { Searcher, SearchResult, FuzzySearchItem } from '@teambit/explorer.ui.command-bar';
2
+ import { SearchProvider } from '../search-provider';
3
+ import { Command } from './command';
4
+ export declare class CommandSearcher extends Searcher<Command, Command> implements SearchProvider {
5
+ constructor(commands: Command[]);
6
+ test(term: string): boolean;
7
+ protected toSearchableItem(item: Command): Command;
8
+ protected toSearchResult({ item }: FuzzySearchItem<Command>): SearchResult;
9
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CommandSearcher = void 0;
9
+
10
+ function _react() {
11
+ const data = _interopRequireDefault(require("react"));
12
+
13
+ _react = function () {
14
+ return data;
15
+ };
16
+
17
+ return data;
18
+ }
19
+
20
+ function _explorerUi() {
21
+ const data = require("@teambit/explorer.ui.command-bar");
22
+
23
+ _explorerUi = function () {
24
+ return data;
25
+ };
26
+
27
+ return data;
28
+ }
29
+
30
+ function _commandResult() {
31
+ const data = require("./command-result");
32
+
33
+ _commandResult = function () {
34
+ return data;
35
+ };
36
+
37
+ return data;
38
+ }
39
+
40
+ const searchKeys = ['displayName'];
41
+
42
+ class CommandSearcher extends _explorerUi().Searcher {
43
+ constructor(commands) {
44
+ super({
45
+ searchKeys
46
+ });
47
+ this.update(commands);
48
+ }
49
+
50
+ test(term) {
51
+ return term.startsWith('>');
52
+ }
53
+
54
+ toSearchableItem(item) {
55
+ return item;
56
+ }
57
+
58
+ toSearchResult({
59
+ item
60
+ }) {
61
+ return {
62
+ id: item.id,
63
+ action: item.action,
64
+ children: /*#__PURE__*/_react().default.createElement(_commandResult().CommandResult, {
65
+ command: item
66
+ })
67
+ };
68
+ }
69
+
70
+ }
71
+
72
+ exports.CommandSearcher = CommandSearcher;
73
+
74
+ //# sourceMappingURL=command-searcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["command-searcher.tsx"],"names":["searchKeys","CommandSearcher","Searcher","constructor","commands","update","test","term","startsWith","toSearchableItem","item","toSearchResult","id","action","children"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA,MAAMA,UAA6B,GAAG,CAAC,aAAD,CAAtC;;AAEO,MAAMC,eAAN,SAA8BC,sBAA9B,CAAmF;AACxFC,EAAAA,WAAW,CAACC,QAAD,EAAsB;AAC/B,UAAM;AAAEJ,MAAAA;AAAF,KAAN;AAEA,SAAKK,MAAL,CAAYD,QAAZ;AACD;;AAEQE,EAAAA,IAAI,CAACC,IAAD,EAAwB;AACnC,WAAOA,IAAI,CAACC,UAAL,CAAgB,GAAhB,CAAP;AACD;;AAEkBC,EAAAA,gBAAgB,CAACC,IAAD,EAAgB;AACjD,WAAOA,IAAP;AACD;;AAEkBC,EAAAA,cAAc,CAAC;AAAED,IAAAA;AAAF,GAAD,EAAmD;AAClF,WAAO;AACLE,MAAAA,EAAE,EAAEF,IAAI,CAACE,EADJ;AAELC,MAAAA,MAAM,EAAEH,IAAI,CAACG,MAFR;AAGLC,MAAAA,QAAQ,eAAE,+BAAC,8BAAD;AAAe,QAAA,OAAO,EAAEJ;AAAxB;AAHL,KAAP;AAKD;;AArBuF","sourcesContent":["import React from 'react';\nimport { Searcher, SearchResult, FuzzySearchItem } from '@teambit/explorer.ui.command-bar';\nimport { SearchProvider } from '../search-provider';\nimport { CommandResult } from './command-result';\nimport { Command } from './command';\n\nconst searchKeys: (keyof Command)[] = ['displayName'];\n\nexport class CommandSearcher extends Searcher<Command, Command> implements SearchProvider {\n constructor(commands: Command[]) {\n super({ searchKeys });\n\n this.update(commands);\n }\n\n override test(term: string): boolean {\n return term.startsWith('>');\n }\n\n protected override toSearchableItem(item: Command) {\n return item;\n }\n\n protected override toSearchResult({ item }: FuzzySearchItem<Command>): SearchResult {\n return {\n id: item.id,\n action: item.action,\n children: <CommandResult command={item} />,\n };\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare type Command = {
2
+ id: string;
3
+ displayName: string;
4
+ action: Function;
5
+ icon?: string;
6
+ iconAlt?: string;
7
+ keybinding?: string | string[];
8
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
File without changes
@@ -0,0 +1,2 @@
1
+ export { CommandSearcher } from './command-searcher';
2
+ export type { SearchProvider } from './search-provider';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CommandSearcher", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _commandSearcher().CommandSearcher;
10
+ }
11
+ });
12
+
13
+ function _commandSearcher() {
14
+ const data = require("./command-searcher");
15
+
16
+ _commandSearcher = function () {
17
+ return data;
18
+ };
19
+
20
+ return data;
21
+ }
22
+
23
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { CommandBarContext } from './command-bar-context';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { CommandSearcher } from './command-searcher';\nexport type { SearchProvider } from './search-provider';\n"]}
@@ -0,0 +1,7 @@
1
+ import { SearchResult } from '@teambit/explorer.ui.command-bar';
2
+ export interface SearchProvider {
3
+ /** provide completions for this search term */
4
+ search(term: string, limit: number): SearchResult[];
5
+ /** determines what terms are handled by this searcher. */
6
+ test(term: string): boolean;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ //# sourceMappingURL=search-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
package/dist/types.d.ts CHANGED
@@ -1,17 +1,3 @@
1
1
  export declare type CommandId = string;
2
- export declare type CommandHandler = (...arg: any[]) => any;
3
- export declare type CommanderSearchResult = {
4
- id: string;
5
- displayName: string;
6
- handler: CommandHandler;
7
- icon?: string;
8
- iconAlt?: string;
9
- keybinding?: Keybinding;
10
- };
11
- export interface SearchProvider {
12
- /** provide completions for this search term */
13
- search(term: string, limit: number): CommanderSearchResult[];
14
- /** determines what terms are handled by this searcher. */
15
- test(term: string): boolean;
16
- }
2
+ export declare type CommandHandler = Function;
17
3
  export declare type Keybinding = string | string[];
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
2
  "name": "@teambit/command-bar",
3
- "version": "0.0.707",
3
+ "version": "0.0.708",
4
4
  "homepage": "https://bit.dev/teambit/explorer/command-bar",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.explorer",
8
8
  "name": "command-bar",
9
- "version": "0.0.707"
9
+ "version": "0.0.708"
10
10
  },
11
11
  "dependencies": {
12
+ "lodash.flatten": "4.4.0",
12
13
  "mousetrap": "1.6.5",
13
14
  "is-primitive": "3.0.1",
14
15
  "classnames": "2.2.6",
15
- "fuse.js": "6.4.6",
16
- "memoize-one": "5.1.1",
17
16
  "@babel/runtime": "7.12.18",
18
17
  "core-js": "^3.0.0",
19
18
  "@teambit/harmony": "0.3.3",
20
- "@teambit/base-ui.surfaces.card": "1.0.1",
19
+ "@teambit/explorer.ui.command-bar": "1.0.0",
21
20
  "@teambit/base-ui.text.muted-text": "1.0.1",
22
- "@teambit/preview": "0.0.707",
23
- "@teambit/pubsub": "0.0.707",
21
+ "@teambit/preview": "0.0.708",
22
+ "@teambit/pubsub": "0.0.708",
23
+ "@teambit/react-router": "0.0.708",
24
24
  "@teambit/ui-foundation.ui.is-browser": "0.0.486",
25
- "@teambit/ui": "0.0.707",
25
+ "@teambit/ui": "0.0.708",
26
26
  "@teambit/bit-error": "0.0.394",
27
- "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487",
28
- "@teambit/ui-foundation.ui.keycap": "0.0.486",
29
- "@teambit/component": "0.0.707"
27
+ "@teambit/design.ui.styles.ellipsis": "0.0.347",
28
+ "@teambit/ui-foundation.ui.keycap": "0.0.486"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@types/react": "^17.0.8",
32
+ "@types/lodash.flatten": "4.4.6",
33
33
  "@types/mousetrap": "1.6.5",
34
34
  "@types/classnames": "2.2.11",
35
35
  "@types/mocha": "9.1.0",
@@ -39,7 +39,7 @@
39
39
  "@types/node": "12.20.4"
40
40
  },
41
41
  "peerDependencies": {
42
- "@teambit/legacy": "1.0.247",
42
+ "@teambit/legacy": "1.0.248",
43
43
  "react-dom": "^16.8.0 || ^17.0.0",
44
44
  "react": "^16.8.0 || ^17.0.0"
45
45
  },
@@ -67,7 +67,7 @@
67
67
  "react": "-"
68
68
  },
69
69
  "peerDependencies": {
70
- "@teambit/legacy": "1.0.247",
70
+ "@teambit/legacy": "1.0.248",
71
71
  "react-dom": "^16.8.0 || ^17.0.0",
72
72
  "react": "^16.8.0 || ^17.0.0"
73
73
  }
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_command-bar@0.0.707/dist/command-bar.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_command-bar@0.0.707/dist/command-bar.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_command-bar@0.0.708/dist/command-bar.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.explorer_command-bar@0.0.708/dist/command-bar.docs.mdx')]
@@ -0,0 +1,15 @@
1
+ .name {
2
+ flex: 1;
3
+ }
4
+
5
+ .commandKeys {
6
+ float: right;
7
+ font-size: 0.85em;
8
+ }
9
+
10
+ .icon {
11
+ font-size: 1.15em;
12
+ width: 1em;
13
+ height: 1em;
14
+ margin-right: 0.5em;
15
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import { ellipsis } from '@teambit/design.ui.styles.ellipsis';
4
+ import { KeySequence } from '@teambit/ui-foundation.ui.keycap';
5
+ import { mutedText } from '@teambit/base-ui.text.muted-text';
6
+ import { Command } from './command';
7
+
8
+ import styles from './command-result.module.scss';
9
+
10
+ type CommandResultProps = {
11
+ command: Command;
12
+ };
13
+
14
+ export function CommandResult({ command }: CommandResultProps) {
15
+ const { icon, iconAlt, displayName, keybinding } = command;
16
+ const _keybinding = Array.isArray(keybinding) ? keybinding[0] : keybinding;
17
+
18
+ return (
19
+ <>
20
+ {icon && <img src={icon} alt={iconAlt} className={styles.icon} />}
21
+ <div className={classnames(ellipsis, styles.name)}>{displayName}</div>
22
+ {_keybinding && <KeySequence className={classnames(styles.commandKeys, mutedText)}>{_keybinding}</KeySequence>}
23
+ </>
24
+ );
25
+ }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { Searcher, SearchResult, FuzzySearchItem } from '@teambit/explorer.ui.command-bar';
3
+ import { SearchProvider } from '../search-provider';
4
+ import { CommandResult } from './command-result';
5
+ import { Command } from './command';
6
+
7
+ const searchKeys: (keyof Command)[] = ['displayName'];
8
+
9
+ export class CommandSearcher extends Searcher<Command, Command> implements SearchProvider {
10
+ constructor(commands: Command[]) {
11
+ super({ searchKeys });
12
+
13
+ this.update(commands);
14
+ }
15
+
16
+ override test(term: string): boolean {
17
+ return term.startsWith('>');
18
+ }
19
+
20
+ protected override toSearchableItem(item: Command) {
21
+ return item;
22
+ }
23
+
24
+ protected override toSearchResult({ item }: FuzzySearchItem<Command>): SearchResult {
25
+ return {
26
+ id: item.id,
27
+ action: item.action,
28
+ children: <CommandResult command={item} />,
29
+ };
30
+ }
31
+ }
@@ -0,0 +1,8 @@
1
+ export type Command = {
2
+ id: string;
3
+ displayName: string;
4
+ action: Function;
5
+ icon?: string;
6
+ iconAlt?: string;
7
+ keybinding?: string | string[];
8
+ };
File without changes
@@ -0,0 +1,2 @@
1
+ export { CommandSearcher } from './command-searcher';
2
+ export type { SearchProvider } from './search-provider';
@@ -0,0 +1,8 @@
1
+ import { SearchResult } from '@teambit/explorer.ui.command-bar';
2
+
3
+ export interface SearchProvider {
4
+ /** provide completions for this search term */
5
+ search(term: string, limit: number): SearchResult[];
6
+ /** determines what terms are handled by this searcher. */
7
+ test(term: string): boolean;
8
+ }
package/types.tsx CHANGED
@@ -1,20 +1,5 @@
1
+ // export type { SearchResult };
1
2
  export type CommandId = string;
2
- export type CommandHandler = (...arg: any[]) => any;
3
-
4
- export type CommanderSearchResult = {
5
- id: string;
6
- displayName: string;
7
- handler: CommandHandler;
8
- icon?: string;
9
- iconAlt?: string;
10
- keybinding?: Keybinding;
11
- };
12
-
13
- export interface SearchProvider {
14
- /** provide completions for this search term */
15
- search(term: string, limit: number): CommanderSearchResult[];
16
- /** determines what terms are handled by this searcher. */
17
- test(term: string): boolean;
18
- }
3
+ export type CommandHandler = Function;
19
4
 
20
5
  export type Keybinding = string | string[];
@@ -1,11 +0,0 @@
1
- import React, { InputHTMLAttributes } from 'react';
2
- declare type AutoCompleteInputProps = InputHTMLAttributes<HTMLInputElement> & {
3
- onEscape?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
4
- onDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
5
- onUp?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
6
- onEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
7
- focus?: Truthy;
8
- };
9
- declare type Truthy = boolean | number | string | null | undefined;
10
- export declare function AutoCompleteInput({ className, onEscape, onDown, onUp, onEnter, onKeyDown, focus, ...rest }: AutoCompleteInputProps): JSX.Element;
11
- export {};
@@ -1,112 +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.AutoCompleteInput = AutoCompleteInput;
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 = _interopRequireWildcard(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 _autocompleteInputModule() {
51
- const data = _interopRequireDefault(require("./autocomplete-input.module.scss"));
52
-
53
- _autocompleteInputModule = function () {
54
- return data;
55
- };
56
-
57
- return data;
58
- }
59
-
60
- 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); }
61
-
62
- 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; }
63
-
64
- function AutoCompleteInput(_ref) {
65
- let {
66
- className,
67
- onEscape,
68
- onDown,
69
- onUp,
70
- onEnter,
71
- onKeyDown,
72
- focus
73
- } = _ref,
74
- rest = (0, _objectWithoutProperties2().default)(_ref, ["className", "onEscape", "onDown", "onUp", "onEnter", "onKeyDown", "focus"]);
75
- const inputRef = /*#__PURE__*/(0, _react().createRef)();
76
- (0, _react().useEffect)(() => {
77
- var _inputRef$current;
78
-
79
- if (focus) (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
80
- }, [focus]);
81
- const handleKeyDown = (0, _react().useCallback)(e => {
82
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
83
- if (e.defaultPrevented) return;
84
- const handlers = {
85
- Escape: () => {
86
- e.preventDefault();
87
- onEscape === null || onEscape === void 0 ? void 0 : onEscape(e);
88
- },
89
- ArrowDown: () => {
90
- e.preventDefault();
91
- onDown === null || onDown === void 0 ? void 0 : onDown(e);
92
- },
93
- ArrowUp: () => {
94
- e.preventDefault();
95
- onUp === null || onUp === void 0 ? void 0 : onUp(e);
96
- },
97
- Enter: () => {
98
- e.preventDefault();
99
- onEnter === null || onEnter === void 0 ? void 0 : onEnter(e);
100
- }
101
- };
102
- if (e.key in handlers) handlers[e.key]();
103
- }, [onEscape, onDown, onUp, onEnter]); // @ts-ignore (https://github.com/teambit/bit/issues/4908)
104
-
105
- return /*#__PURE__*/_react().default.createElement("input", (0, _extends2().default)({}, rest, {
106
- ref: inputRef,
107
- className: (0, _classnames().default)(_autocompleteInputModule().default.input, className),
108
- onKeyDown: handleKeyDown
109
- }));
110
- }
111
-
112
- //# sourceMappingURL=autocomplete-input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["autocomplete-input.tsx"],"names":["AutoCompleteInput","className","onEscape","onDown","onUp","onEnter","onKeyDown","focus","rest","inputRef","current","handleKeyDown","e","defaultPrevented","handlers","Escape","preventDefault","ArrowDown","ArrowUp","Enter","key","styles","input"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAYO,SAASA,iBAAT,OASoB;AAAA,MATO;AAChCC,IAAAA,SADgC;AAEhCC,IAAAA,QAFgC;AAGhCC,IAAAA,MAHgC;AAIhCC,IAAAA,IAJgC;AAKhCC,IAAAA,OALgC;AAMhCC,IAAAA,SANgC;AAOhCC,IAAAA;AAPgC,GASP;AAAA,MADtBC,IACsB;AACzB,QAAMC,QAAQ,gBAAG,yBAAjB;AAEA,0BAAU,MAAM;AAAA;;AACd,QAAIF,KAAJ,EAAW,qBAAAE,QAAQ,CAACC,OAAT,wEAAkBH,KAAlB;AACZ,GAFD,EAEG,CAACA,KAAD,CAFH;AAIA,QAAMI,aAAa,GAAG,0BACnBC,CAAD,IAA8C;AAC5CN,IAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAGM,CAAH,CAAT;AACA,QAAIA,CAAC,CAACC,gBAAN,EAAwB;AAExB,UAAMC,QAAQ,GAAG;AACfC,MAAAA,MAAM,EAAE,MAAM;AACZH,QAAAA,CAAC,CAACI,cAAF;AACAd,QAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAGU,CAAH,CAAR;AACD,OAJc;AAKfK,MAAAA,SAAS,EAAE,MAAM;AACfL,QAAAA,CAAC,CAACI,cAAF;AACAb,QAAAA,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAGS,CAAH,CAAN;AACD,OARc;AASfM,MAAAA,OAAO,EAAE,MAAM;AACbN,QAAAA,CAAC,CAACI,cAAF;AACAZ,QAAAA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAGQ,CAAH,CAAJ;AACD,OAZc;AAafO,MAAAA,KAAK,EAAE,MAAM;AACXP,QAAAA,CAAC,CAACI,cAAF;AACAX,QAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAGO,CAAH,CAAP;AACD;AAhBc,KAAjB;AAmBA,QAAIA,CAAC,CAACQ,GAAF,IAASN,QAAb,EAAuBA,QAAQ,CAACF,CAAC,CAACQ,GAAH,CAAR;AACxB,GAzBmB,EA0BpB,CAAClB,QAAD,EAAWC,MAAX,EAAmBC,IAAnB,EAAyBC,OAAzB,CA1BoB,CAAtB,CAPyB,CAoCzB;;AACA,sBAAO,qEAAWG,IAAX;AAAiB,IAAA,GAAG,EAAEC,QAAtB;AAAgC,IAAA,SAAS,EAAE,2BAAWY,mCAAOC,KAAlB,EAAyBrB,SAAzB,CAA3C;AAAgF,IAAA,SAAS,EAAEU;AAA3F,KAAP;AACD","sourcesContent":["import React, { useCallback, useEffect, createRef, InputHTMLAttributes } from 'react';\nimport classNames from 'classnames';\nimport styles from './autocomplete-input.module.scss';\n\ntype AutoCompleteInputProps = InputHTMLAttributes<HTMLInputElement> & {\n onEscape?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n onDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n onUp?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n onEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n focus?: Truthy;\n};\n\ntype Truthy = boolean | number | string | null | undefined;\n\nexport function AutoCompleteInput({\n className,\n onEscape,\n onDown,\n onUp,\n onEnter,\n onKeyDown,\n focus,\n ...rest\n}: AutoCompleteInputProps) {\n const inputRef = createRef<HTMLInputElement>();\n\n useEffect(() => {\n if (focus) inputRef.current?.focus();\n }, [focus]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const handlers = {\n Escape: () => {\n e.preventDefault();\n onEscape?.(e);\n },\n ArrowDown: () => {\n e.preventDefault();\n onDown?.(e);\n },\n ArrowUp: () => {\n e.preventDefault();\n onUp?.(e);\n },\n Enter: () => {\n e.preventDefault();\n onEnter?.(e);\n },\n };\n\n if (e.key in handlers) handlers[e.key]();\n },\n [onEscape, onDown, onUp, onEnter]\n );\n\n // @ts-ignore (https://github.com/teambit/bit/issues/4908)\n return <input {...rest} ref={inputRef} className={classNames(styles.input, className)} onKeyDown={handleKeyDown} />;\n}\n"]}
@@ -1,13 +0,0 @@
1
- .input {
2
- font-size: inherit;
3
- font-family: inherit;
4
- color: inherit;
5
- border: none;
6
-
7
- // command bar is open iff input is focused, so outline is not needed
8
- outline: none;
9
-
10
- &::placeholder {
11
- color: var(--bit-text-inactive, #babec9);
12
- }
13
- }
@@ -1 +0,0 @@
1
- export * from './autocomplete-input';