@wordpress/commands 0.2.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/CHANGELOG.md +7 -0
- package/LICENSE.md +788 -0
- package/README.md +35 -0
- package/build/components/command-menu.js +213 -0
- package/build/components/command-menu.js.map +1 -0
- package/build/hooks/use-command-loader.js +48 -0
- package/build/hooks/use-command-loader.js.map +1 -0
- package/build/hooks/use-command.js +48 -0
- package/build/hooks/use-command.js.map +1 -0
- package/build/index.js +22 -0
- package/build/index.js.map +1 -0
- package/build/private-apis.js +35 -0
- package/build/private-apis.js.map +1 -0
- package/build/store/actions.js +116 -0
- package/build/store/actions.js.map +1 -0
- package/build/store/index.js +45 -0
- package/build/store/index.js.map +1 -0
- package/build/store/reducer.js +99 -0
- package/build/store/reducer.js.map +1 -0
- package/build/store/selectors.js +33 -0
- package/build/store/selectors.js.map +1 -0
- package/build-module/components/command-menu.js +198 -0
- package/build-module/components/command-menu.js.map +1 -0
- package/build-module/hooks/use-command-loader.js +38 -0
- package/build-module/hooks/use-command-loader.js.map +1 -0
- package/build-module/hooks/use-command.js +38 -0
- package/build-module/hooks/use-command.js.map +1 -0
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +1 -0
- package/build-module/private-apis.js +20 -0
- package/build-module/private-apis.js.map +1 -0
- package/build-module/store/actions.js +103 -0
- package/build-module/store/actions.js.map +1 -0
- package/build-module/store/index.js +27 -0
- package/build-module/store/index.js.map +1 -0
- package/build-module/store/reducer.js +90 -0
- package/build-module/store/reducer.js.map +1 -0
- package/build-module/store/selectors.js +21 -0
- package/build-module/store/selectors.js.map +1 -0
- package/build-style/style-rtl.css +264 -0
- package/build-style/style.css +264 -0
- package/package.json +47 -0
- package/src/components/command-menu.js +216 -0
- package/src/components/style.scss +179 -0
- package/src/hooks/use-command-loader.js +30 -0
- package/src/hooks/use-command.js +41 -0
- package/src/index.js +2 -0
- package/src/private-apis.js +22 -0
- package/src/store/actions.js +91 -0
- package/src/store/index.js +28 -0
- package/src/store/reducer.js +81 -0
- package/src/store/selectors.js +29 -0
- package/src/style.scss +1 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { combineReducers } from '@wordpress/data';
|
|
5
|
+
/**
|
|
6
|
+
* Reducer returning the registered commands
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} state Current state.
|
|
9
|
+
* @param {Object} action Dispatched action.
|
|
10
|
+
*
|
|
11
|
+
* @return {Object} Updated state.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function commands() {
|
|
15
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
17
|
+
|
|
18
|
+
switch (action.type) {
|
|
19
|
+
case 'REGISTER_COMMAND':
|
|
20
|
+
return { ...state,
|
|
21
|
+
[action.group]: { ...state[action.group],
|
|
22
|
+
[action.name]: {
|
|
23
|
+
name: action.name,
|
|
24
|
+
label: action.label,
|
|
25
|
+
group: action.group,
|
|
26
|
+
callback: action.callback
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
case 'UNREGISTER_COMMAND':
|
|
32
|
+
{
|
|
33
|
+
const {
|
|
34
|
+
[action.name]: _,
|
|
35
|
+
...remainingState
|
|
36
|
+
} = state === null || state === void 0 ? void 0 : state[action.group];
|
|
37
|
+
return { ...state,
|
|
38
|
+
[action.group]: remainingState
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return state;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reducer returning the command loaders
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} state Current state.
|
|
49
|
+
* @param {Object} action Dispatched action.
|
|
50
|
+
*
|
|
51
|
+
* @return {Object} Updated state.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function commandLoaders() {
|
|
56
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
57
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
58
|
+
|
|
59
|
+
switch (action.type) {
|
|
60
|
+
case 'REGISTER_COMMAND_LOADER':
|
|
61
|
+
return { ...state,
|
|
62
|
+
[action.group]: { ...state[action.group],
|
|
63
|
+
[action.name]: {
|
|
64
|
+
name: action.name,
|
|
65
|
+
hook: action.hook
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
case 'UNREGISTER_COMMAND_LOADER':
|
|
71
|
+
{
|
|
72
|
+
const {
|
|
73
|
+
[action.name]: _,
|
|
74
|
+
...remainingState
|
|
75
|
+
} = state === null || state === void 0 ? void 0 : state[action.group];
|
|
76
|
+
return { ...state,
|
|
77
|
+
[action.group]: remainingState
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return state;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const reducer = combineReducers({
|
|
86
|
+
commands,
|
|
87
|
+
commandLoaders
|
|
88
|
+
});
|
|
89
|
+
export default reducer;
|
|
90
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/store/reducer.js"],"names":["combineReducers","commands","state","action","type","group","name","label","callback","_","remainingState","commandLoaders","hook","reducer"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,QAAT,GAAwC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AACvC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,KAAT,GAAkB,EACjB,GAAGH,KAAK,CAAEC,MAAM,CAACE,KAAT,CADS;AAEjB,WAAEF,MAAM,CAACG,IAAT,GAAiB;AAChBA,YAAAA,IAAI,EAAEH,MAAM,CAACG,IADG;AAEhBC,YAAAA,KAAK,EAAEJ,MAAM,CAACI,KAFE;AAGhBF,YAAAA,KAAK,EAAEF,MAAM,CAACE,KAHE;AAIhBG,YAAAA,QAAQ,EAAEL,MAAM,CAACK;AAJD;AAFA;AAFZ,OAAP;;AAYD,SAAK,oBAAL;AAA2B;AAC1B,cAAM;AAAE,WAAEL,MAAM,CAACG,IAAT,GAAiBG,CAAnB;AAAsB,aAAGC;AAAzB,YACLR,KADK,aACLA,KADK,uBACLA,KAAK,CAAIC,MAAM,CAACE,KAAX,CADN;AAEA,eAAO,EACN,GAAGH,KADG;AAEN,WAAEC,MAAM,CAACE,KAAT,GAAkBK;AAFZ,SAAP;AAIA;AArBF;;AAwBA,SAAOR,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASS,cAAT,GAA8C;AAAA,MAArBT,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC7C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,KAAT,GAAkB,EACjB,GAAGH,KAAK,CAAEC,MAAM,CAACE,KAAT,CADS;AAEjB,WAAEF,MAAM,CAACG,IAAT,GAAiB;AAChBA,YAAAA,IAAI,EAAEH,MAAM,CAACG,IADG;AAEhBM,YAAAA,IAAI,EAAET,MAAM,CAACS;AAFG;AAFA;AAFZ,OAAP;;AAUD,SAAK,2BAAL;AAAkC;AACjC,cAAM;AAAE,WAAET,MAAM,CAACG,IAAT,GAAiBG,CAAnB;AAAsB,aAAGC;AAAzB,YACLR,KADK,aACLA,KADK,uBACLA,KAAK,CAAIC,MAAM,CAACE,KAAX,CADN;AAEA,eAAO,EACN,GAAGH,KADG;AAEN,WAAEC,MAAM,CAACE,KAAT,GAAkBK;AAFZ,SAAP;AAIA;AAnBF;;AAsBA,SAAOR,KAAP;AACA;;AAED,MAAMW,OAAO,GAAGb,eAAe,CAAE;AAChCC,EAAAA,QADgC;AAEhCU,EAAAA;AAFgC,CAAF,CAA/B;AAKA,eAAeE,OAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the registered commands\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commands( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.group ]: {\n\t\t\t\t\t...state[ action.group ],\n\t\t\t\t\t[ action.name ]: {\n\t\t\t\t\t\tname: action.name,\n\t\t\t\t\t\tlabel: action.label,\n\t\t\t\t\t\tgroup: action.group,\n\t\t\t\t\t\tcallback: action.callback,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } =\n\t\t\t\tstate?.[ action.group ];\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.group ]: remainingState,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the command loaders\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction commandLoaders( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_COMMAND_LOADER':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.group ]: {\n\t\t\t\t\t...state[ action.group ],\n\t\t\t\t\t[ action.name ]: {\n\t\t\t\t\t\tname: action.name,\n\t\t\t\t\t\thook: action.hook,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_COMMAND_LOADER': {\n\t\t\tconst { [ action.name ]: _, ...remainingState } =\n\t\t\t\tstate?.[ action.group ];\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.group ]: remainingState,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n\nconst reducer = combineReducers( {\n\tcommands,\n\tcommandLoaders,\n} );\n\nexport default reducer;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import createSelector from 'rememo';
|
|
5
|
+
|
|
6
|
+
function unique(array) {
|
|
7
|
+
return array.filter((value, index, current) => current.indexOf(value) === index);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getGroups = createSelector(state => unique(Object.keys(state.commands).concat(Object.keys(state.commandLoaders))), state => [state.commands, state.commandLoaders]);
|
|
11
|
+
export const getCommands = createSelector((state, group) => {
|
|
12
|
+
var _state$commands$group;
|
|
13
|
+
|
|
14
|
+
return Object.values((_state$commands$group = state.commands[group]) !== null && _state$commands$group !== void 0 ? _state$commands$group : {});
|
|
15
|
+
}, (state, group) => [state.commands[group]]);
|
|
16
|
+
export const getCommandLoaders = createSelector((state, group) => {
|
|
17
|
+
var _state$commandLoaders;
|
|
18
|
+
|
|
19
|
+
return Object.values((_state$commandLoaders = state.commandLoaders[group]) !== null && _state$commandLoaders !== void 0 ? _state$commandLoaders : {});
|
|
20
|
+
}, (state, group) => [state.commandLoaders[group]]);
|
|
21
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/commands/src/store/selectors.js"],"names":["createSelector","unique","array","filter","value","index","current","indexOf","getGroups","state","Object","keys","commands","concat","commandLoaders","getCommands","group","values","getCommandLoaders"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;;AAEA,SAASC,MAAT,CAAiBC,KAAjB,EAAyB;AACxB,SAAOA,KAAK,CAACC,MAAN,CACN,CAAEC,KAAF,EAASC,KAAT,EAAgBC,OAAhB,KAA6BA,OAAO,CAACC,OAAR,CAAiBH,KAAjB,MAA6BC,KADpD,CAAP;AAGA;;AAED,OAAO,MAAMG,SAAS,GAAGR,cAAc,CACpCS,KAAF,IACCR,MAAM,CACLS,MAAM,CAACC,IAAP,CAAaF,KAAK,CAACG,QAAnB,EAA8BC,MAA9B,CACCH,MAAM,CAACC,IAAP,CAAaF,KAAK,CAACK,cAAnB,CADD,CADK,CAF+B,EAOpCL,KAAF,IAAa,CAAEA,KAAK,CAACG,QAAR,EAAkBH,KAAK,CAACK,cAAxB,CAPyB,CAAhC;AASP,OAAO,MAAMC,WAAW,GAAGf,cAAc,CACxC,CAAES,KAAF,EAASO,KAAT;AAAA;;AAAA,SAAoBN,MAAM,CAACO,MAAP,0BAAeR,KAAK,CAACG,QAAN,CAAgBI,KAAhB,CAAf,yEAA0C,EAA1C,CAApB;AAAA,CADwC,EAExC,CAAEP,KAAF,EAASO,KAAT,KAAoB,CAAEP,KAAK,CAACG,QAAN,CAAgBI,KAAhB,CAAF,CAFoB,CAAlC;AAKP,OAAO,MAAME,iBAAiB,GAAGlB,cAAc,CAC9C,CAAES,KAAF,EAASO,KAAT;AAAA;;AAAA,SAAoBN,MAAM,CAACO,MAAP,0BAAeR,KAAK,CAACK,cAAN,CAAsBE,KAAtB,CAAf,yEAAgD,EAAhD,CAApB;AAAA,CAD8C,EAE9C,CAAEP,KAAF,EAASO,KAAT,KAAoB,CAAEP,KAAK,CAACK,cAAN,CAAsBE,KAAtB,CAAF,CAF0B,CAAxC","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\nfunction unique( array ) {\n\treturn array.filter(\n\t\t( value, index, current ) => current.indexOf( value ) === index\n\t);\n}\n\nexport const getGroups = createSelector(\n\t( state ) =>\n\t\tunique(\n\t\t\tObject.keys( state.commands ).concat(\n\t\t\t\tObject.keys( state.commandLoaders )\n\t\t\t)\n\t\t),\n\t( state ) => [ state.commands, state.commandLoaders ]\n);\nexport const getCommands = createSelector(\n\t( state, group ) => Object.values( state.commands[ group ] ?? {} ),\n\t( state, group ) => [ state.commands[ group ] ]\n);\n\nexport const getCommandLoaders = createSelector(\n\t( state, group ) => Object.values( state.commandLoaders[ group ] ?? {} ),\n\t( state, group ) => [ state.commandLoaders[ group ] ]\n);\n"]}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex value into the rgb equivalent.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
5
|
+
* @return {string} comma separated rgb values
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Colors
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Breakpoints & Media Queries
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* SCSS Variables.
|
|
15
|
+
*
|
|
16
|
+
* Please use variables from this sheet to ensure consistency across the UI.
|
|
17
|
+
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
|
|
18
|
+
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Converts a hex value into the rgb equivalent.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
24
|
+
* @return {string} comma separated rgb values
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Colors
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Fonts & basic variables.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Grid System.
|
|
34
|
+
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Dimensions.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Shadows.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Editor widths.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Block & Editor UI.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Block paddings.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* React Native specific.
|
|
53
|
+
* These variables do not appear to be used anywhere else.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* Converts a hex value into the rgb equivalent.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
59
|
+
* @return {string} comma separated rgb values
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Long content fade mixin
|
|
63
|
+
*
|
|
64
|
+
* Creates a fading overlay to signify that the content is longer
|
|
65
|
+
* than the space allows.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Breakpoint mixins
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Focus styles.
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Applies editor left position to the selector passed as argument
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Styles that are reused verbatim in a few places
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Allows users to opt-out of animations via OS-level preferences.
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* Reset default styles for JavaScript UI based pages.
|
|
84
|
+
* This is a WP-admin agnostic reset
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Reset the WP Admin page styles for Gutenberg-like pages.
|
|
88
|
+
*/
|
|
89
|
+
:root {
|
|
90
|
+
--wp-admin-theme-color: #007cba;
|
|
91
|
+
--wp-admin-theme-color--rgb: 0, 124, 186;
|
|
92
|
+
--wp-admin-theme-color-darker-10: #006ba1;
|
|
93
|
+
--wp-admin-theme-color-darker-10--rgb: 0, 107, 161;
|
|
94
|
+
--wp-admin-theme-color-darker-20: #005a87;
|
|
95
|
+
--wp-admin-theme-color-darker-20--rgb: 0, 90, 135;
|
|
96
|
+
--wp-admin-border-width-focus: 2px;
|
|
97
|
+
--wp-block-synced-color: #7a00df;
|
|
98
|
+
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
99
|
+
}
|
|
100
|
+
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
|
|
101
|
+
:root {
|
|
102
|
+
--wp-admin-border-width-focus: 1.5px;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.commands-command-menu {
|
|
107
|
+
padding: 0;
|
|
108
|
+
width: 100%;
|
|
109
|
+
max-width: 680px;
|
|
110
|
+
position: relative;
|
|
111
|
+
top: 15%;
|
|
112
|
+
}
|
|
113
|
+
.commands-command-menu .components-modal__content {
|
|
114
|
+
margin: 0;
|
|
115
|
+
padding: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.commands-command-menu__overlay {
|
|
119
|
+
display: block;
|
|
120
|
+
align-items: start;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.commands-command-menu__header {
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
margin: 12px 12px 0 12px;
|
|
127
|
+
}
|
|
128
|
+
.commands-command-menu__header .components-button {
|
|
129
|
+
height: 56px;
|
|
130
|
+
width: 56px;
|
|
131
|
+
border: 1px solid #949494;
|
|
132
|
+
border-left: 0;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
border-radius: 0 2px 2px 0;
|
|
135
|
+
}
|
|
136
|
+
.commands-command-menu__header .components-button + [cmdk-input] {
|
|
137
|
+
border-top-right-radius: 0;
|
|
138
|
+
border-bottom-right-radius: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.commands-command-menu__container [cmdk-linear-badge] {
|
|
142
|
+
height: 24px;
|
|
143
|
+
padding: 0 8px;
|
|
144
|
+
font-size: 12px;
|
|
145
|
+
color: #2f2f2f;
|
|
146
|
+
background: #ddd;
|
|
147
|
+
border-radius: 4px;
|
|
148
|
+
width: -moz-fit-content;
|
|
149
|
+
width: fit-content;
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
margin: 16px 16px 0;
|
|
153
|
+
}
|
|
154
|
+
.commands-command-menu__container [cmdk-linear-shortcuts] {
|
|
155
|
+
display: flex;
|
|
156
|
+
margin-right: auto;
|
|
157
|
+
gap: 8px;
|
|
158
|
+
}
|
|
159
|
+
.commands-command-menu__container [cmdk-linear-shortcuts] kbd {
|
|
160
|
+
color: #2f2f2f;
|
|
161
|
+
}
|
|
162
|
+
.commands-command-menu__container [cmdk-input] {
|
|
163
|
+
border: 1px solid #949494;
|
|
164
|
+
width: 100%;
|
|
165
|
+
padding: 12px 16px;
|
|
166
|
+
min-height: 56px;
|
|
167
|
+
outline: none;
|
|
168
|
+
color: #1e1e1e;
|
|
169
|
+
margin: 0;
|
|
170
|
+
border-radius: 2px;
|
|
171
|
+
}
|
|
172
|
+
.commands-command-menu__container [cmdk-input]::placeholder {
|
|
173
|
+
color: #949494;
|
|
174
|
+
}
|
|
175
|
+
.commands-command-menu__container [cmdk-input]:focus {
|
|
176
|
+
outline: 2px solid transparent;
|
|
177
|
+
border-color: var(--wp-admin-theme-color);
|
|
178
|
+
box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
|
|
179
|
+
}
|
|
180
|
+
.commands-command-menu__container [cmdk-item] {
|
|
181
|
+
content-visibility: auto;
|
|
182
|
+
border-radius: 2px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
height: 40px;
|
|
185
|
+
display: flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
gap: 12px;
|
|
188
|
+
padding: 0 16px;
|
|
189
|
+
color: #1e1e1e;
|
|
190
|
+
-webkit-user-select: none;
|
|
191
|
+
user-select: none;
|
|
192
|
+
will-change: background, color;
|
|
193
|
+
transition: all 150ms ease;
|
|
194
|
+
transition-property: none;
|
|
195
|
+
position: relative;
|
|
196
|
+
}
|
|
197
|
+
.commands-command-menu__container [cmdk-item][aria-selected=true] {
|
|
198
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
199
|
+
color: var(--wp-admin-theme-color);
|
|
200
|
+
}
|
|
201
|
+
.commands-command-menu__container [cmdk-item][aria-selected=true] svg {
|
|
202
|
+
color: var(--wp-admin-theme-color);
|
|
203
|
+
}
|
|
204
|
+
.commands-command-menu__container [cmdk-item][aria-disabled=true] {
|
|
205
|
+
color: #949494;
|
|
206
|
+
cursor: not-allowed;
|
|
207
|
+
}
|
|
208
|
+
.commands-command-menu__container [cmdk-item]:active {
|
|
209
|
+
transition-property: background;
|
|
210
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
211
|
+
}
|
|
212
|
+
.commands-command-menu__container [cmdk-item] + [cmdk-item] {
|
|
213
|
+
margin-top: 4px;
|
|
214
|
+
}
|
|
215
|
+
.commands-command-menu__container [cmdk-item] svg,
|
|
216
|
+
.commands-command-menu__container [cmdk-item] .dashicon {
|
|
217
|
+
width: 16px;
|
|
218
|
+
height: 16px;
|
|
219
|
+
color: #2f2f2f;
|
|
220
|
+
}
|
|
221
|
+
.commands-command-menu__container [cmdk-root] > [cmdk-list] {
|
|
222
|
+
min-height: 300px;
|
|
223
|
+
max-height: 400px;
|
|
224
|
+
overflow: auto;
|
|
225
|
+
overscroll-behavior: contain;
|
|
226
|
+
transition: 100ms ease;
|
|
227
|
+
transition-property: height;
|
|
228
|
+
margin: 12px;
|
|
229
|
+
}
|
|
230
|
+
.commands-command-menu__container [cmdk-group-heading] {
|
|
231
|
+
-webkit-user-select: none;
|
|
232
|
+
user-select: none;
|
|
233
|
+
color: #757575;
|
|
234
|
+
padding: 24px 16px 16px;
|
|
235
|
+
display: flex;
|
|
236
|
+
align-items: center;
|
|
237
|
+
font-size: 11px;
|
|
238
|
+
text-transform: uppercase;
|
|
239
|
+
font-weight: 500;
|
|
240
|
+
position: sticky;
|
|
241
|
+
top: 0;
|
|
242
|
+
background: #fff;
|
|
243
|
+
z-index: 1;
|
|
244
|
+
}
|
|
245
|
+
.commands-command-menu__container [cmdk-empty] {
|
|
246
|
+
display: flex;
|
|
247
|
+
align-items: center;
|
|
248
|
+
justify-content: center;
|
|
249
|
+
height: 64px;
|
|
250
|
+
white-space: pre-wrap;
|
|
251
|
+
color: #2f2f2f;
|
|
252
|
+
}
|
|
253
|
+
.commands-command-menu__container [cmdk-loading] {
|
|
254
|
+
padding: 16px;
|
|
255
|
+
}
|
|
256
|
+
.commands-command-menu__container [cmdk-list-sizer] {
|
|
257
|
+
position: relative;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.commands-command-menu__item mark {
|
|
261
|
+
color: inherit;
|
|
262
|
+
background: unset;
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex value into the rgb equivalent.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
5
|
+
* @return {string} comma separated rgb values
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Colors
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Breakpoints & Media Queries
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* SCSS Variables.
|
|
15
|
+
*
|
|
16
|
+
* Please use variables from this sheet to ensure consistency across the UI.
|
|
17
|
+
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
|
|
18
|
+
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Converts a hex value into the rgb equivalent.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
24
|
+
* @return {string} comma separated rgb values
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Colors
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Fonts & basic variables.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Grid System.
|
|
34
|
+
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Dimensions.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Shadows.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Editor widths.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Block & Editor UI.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Block paddings.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* React Native specific.
|
|
53
|
+
* These variables do not appear to be used anywhere else.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* Converts a hex value into the rgb equivalent.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} hex - the hexadecimal value to convert
|
|
59
|
+
* @return {string} comma separated rgb values
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Long content fade mixin
|
|
63
|
+
*
|
|
64
|
+
* Creates a fading overlay to signify that the content is longer
|
|
65
|
+
* than the space allows.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Breakpoint mixins
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Focus styles.
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Applies editor left position to the selector passed as argument
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Styles that are reused verbatim in a few places
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Allows users to opt-out of animations via OS-level preferences.
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* Reset default styles for JavaScript UI based pages.
|
|
84
|
+
* This is a WP-admin agnostic reset
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Reset the WP Admin page styles for Gutenberg-like pages.
|
|
88
|
+
*/
|
|
89
|
+
:root {
|
|
90
|
+
--wp-admin-theme-color: #007cba;
|
|
91
|
+
--wp-admin-theme-color--rgb: 0, 124, 186;
|
|
92
|
+
--wp-admin-theme-color-darker-10: #006ba1;
|
|
93
|
+
--wp-admin-theme-color-darker-10--rgb: 0, 107, 161;
|
|
94
|
+
--wp-admin-theme-color-darker-20: #005a87;
|
|
95
|
+
--wp-admin-theme-color-darker-20--rgb: 0, 90, 135;
|
|
96
|
+
--wp-admin-border-width-focus: 2px;
|
|
97
|
+
--wp-block-synced-color: #7a00df;
|
|
98
|
+
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
99
|
+
}
|
|
100
|
+
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
|
|
101
|
+
:root {
|
|
102
|
+
--wp-admin-border-width-focus: 1.5px;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.commands-command-menu {
|
|
107
|
+
padding: 0;
|
|
108
|
+
width: 100%;
|
|
109
|
+
max-width: 680px;
|
|
110
|
+
position: relative;
|
|
111
|
+
top: 15%;
|
|
112
|
+
}
|
|
113
|
+
.commands-command-menu .components-modal__content {
|
|
114
|
+
margin: 0;
|
|
115
|
+
padding: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.commands-command-menu__overlay {
|
|
119
|
+
display: block;
|
|
120
|
+
align-items: start;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.commands-command-menu__header {
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
margin: 12px 12px 0 12px;
|
|
127
|
+
}
|
|
128
|
+
.commands-command-menu__header .components-button {
|
|
129
|
+
height: 56px;
|
|
130
|
+
width: 56px;
|
|
131
|
+
border: 1px solid #949494;
|
|
132
|
+
border-right: 0;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
border-radius: 2px 0 0 2px;
|
|
135
|
+
}
|
|
136
|
+
.commands-command-menu__header .components-button + [cmdk-input] {
|
|
137
|
+
border-top-left-radius: 0;
|
|
138
|
+
border-bottom-left-radius: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.commands-command-menu__container [cmdk-linear-badge] {
|
|
142
|
+
height: 24px;
|
|
143
|
+
padding: 0 8px;
|
|
144
|
+
font-size: 12px;
|
|
145
|
+
color: #2f2f2f;
|
|
146
|
+
background: #ddd;
|
|
147
|
+
border-radius: 4px;
|
|
148
|
+
width: -moz-fit-content;
|
|
149
|
+
width: fit-content;
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
margin: 16px 16px 0;
|
|
153
|
+
}
|
|
154
|
+
.commands-command-menu__container [cmdk-linear-shortcuts] {
|
|
155
|
+
display: flex;
|
|
156
|
+
margin-left: auto;
|
|
157
|
+
gap: 8px;
|
|
158
|
+
}
|
|
159
|
+
.commands-command-menu__container [cmdk-linear-shortcuts] kbd {
|
|
160
|
+
color: #2f2f2f;
|
|
161
|
+
}
|
|
162
|
+
.commands-command-menu__container [cmdk-input] {
|
|
163
|
+
border: 1px solid #949494;
|
|
164
|
+
width: 100%;
|
|
165
|
+
padding: 12px 16px;
|
|
166
|
+
min-height: 56px;
|
|
167
|
+
outline: none;
|
|
168
|
+
color: #1e1e1e;
|
|
169
|
+
margin: 0;
|
|
170
|
+
border-radius: 2px;
|
|
171
|
+
}
|
|
172
|
+
.commands-command-menu__container [cmdk-input]::placeholder {
|
|
173
|
+
color: #949494;
|
|
174
|
+
}
|
|
175
|
+
.commands-command-menu__container [cmdk-input]:focus {
|
|
176
|
+
outline: 2px solid transparent;
|
|
177
|
+
border-color: var(--wp-admin-theme-color);
|
|
178
|
+
box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
|
|
179
|
+
}
|
|
180
|
+
.commands-command-menu__container [cmdk-item] {
|
|
181
|
+
content-visibility: auto;
|
|
182
|
+
border-radius: 2px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
height: 40px;
|
|
185
|
+
display: flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
gap: 12px;
|
|
188
|
+
padding: 0 16px;
|
|
189
|
+
color: #1e1e1e;
|
|
190
|
+
-webkit-user-select: none;
|
|
191
|
+
user-select: none;
|
|
192
|
+
will-change: background, color;
|
|
193
|
+
transition: all 150ms ease;
|
|
194
|
+
transition-property: none;
|
|
195
|
+
position: relative;
|
|
196
|
+
}
|
|
197
|
+
.commands-command-menu__container [cmdk-item][aria-selected=true] {
|
|
198
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
199
|
+
color: var(--wp-admin-theme-color);
|
|
200
|
+
}
|
|
201
|
+
.commands-command-menu__container [cmdk-item][aria-selected=true] svg {
|
|
202
|
+
color: var(--wp-admin-theme-color);
|
|
203
|
+
}
|
|
204
|
+
.commands-command-menu__container [cmdk-item][aria-disabled=true] {
|
|
205
|
+
color: #949494;
|
|
206
|
+
cursor: not-allowed;
|
|
207
|
+
}
|
|
208
|
+
.commands-command-menu__container [cmdk-item]:active {
|
|
209
|
+
transition-property: background;
|
|
210
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
211
|
+
}
|
|
212
|
+
.commands-command-menu__container [cmdk-item] + [cmdk-item] {
|
|
213
|
+
margin-top: 4px;
|
|
214
|
+
}
|
|
215
|
+
.commands-command-menu__container [cmdk-item] svg,
|
|
216
|
+
.commands-command-menu__container [cmdk-item] .dashicon {
|
|
217
|
+
width: 16px;
|
|
218
|
+
height: 16px;
|
|
219
|
+
color: #2f2f2f;
|
|
220
|
+
}
|
|
221
|
+
.commands-command-menu__container [cmdk-root] > [cmdk-list] {
|
|
222
|
+
min-height: 300px;
|
|
223
|
+
max-height: 400px;
|
|
224
|
+
overflow: auto;
|
|
225
|
+
overscroll-behavior: contain;
|
|
226
|
+
transition: 100ms ease;
|
|
227
|
+
transition-property: height;
|
|
228
|
+
margin: 12px;
|
|
229
|
+
}
|
|
230
|
+
.commands-command-menu__container [cmdk-group-heading] {
|
|
231
|
+
-webkit-user-select: none;
|
|
232
|
+
user-select: none;
|
|
233
|
+
color: #757575;
|
|
234
|
+
padding: 24px 16px 16px;
|
|
235
|
+
display: flex;
|
|
236
|
+
align-items: center;
|
|
237
|
+
font-size: 11px;
|
|
238
|
+
text-transform: uppercase;
|
|
239
|
+
font-weight: 500;
|
|
240
|
+
position: sticky;
|
|
241
|
+
top: 0;
|
|
242
|
+
background: #fff;
|
|
243
|
+
z-index: 1;
|
|
244
|
+
}
|
|
245
|
+
.commands-command-menu__container [cmdk-empty] {
|
|
246
|
+
display: flex;
|
|
247
|
+
align-items: center;
|
|
248
|
+
justify-content: center;
|
|
249
|
+
height: 64px;
|
|
250
|
+
white-space: pre-wrap;
|
|
251
|
+
color: #2f2f2f;
|
|
252
|
+
}
|
|
253
|
+
.commands-command-menu__container [cmdk-loading] {
|
|
254
|
+
padding: 16px;
|
|
255
|
+
}
|
|
256
|
+
.commands-command-menu__container [cmdk-list-sizer] {
|
|
257
|
+
position: relative;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.commands-command-menu__item mark {
|
|
261
|
+
color: inherit;
|
|
262
|
+
background: unset;
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wordpress/commands",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Handles the commands menu.",
|
|
5
|
+
"author": "The WordPress Contributors",
|
|
6
|
+
"license": "GPL-2.0-or-later",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"wordpress",
|
|
9
|
+
"gutenberg",
|
|
10
|
+
"commands",
|
|
11
|
+
"k"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/commands/README.md",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/WordPress/gutenberg.git",
|
|
17
|
+
"directory": "packages/commands"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=12"
|
|
24
|
+
},
|
|
25
|
+
"main": "build/index.js",
|
|
26
|
+
"module": "build-module/index.js",
|
|
27
|
+
"react-native": "src/index",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@babel/runtime": "^7.16.0",
|
|
30
|
+
"@wordpress/components": "^23.8.0",
|
|
31
|
+
"@wordpress/data": "^9.1.0",
|
|
32
|
+
"@wordpress/element": "^5.8.0",
|
|
33
|
+
"@wordpress/i18n": "^4.31.0",
|
|
34
|
+
"@wordpress/icons": "^9.22.0",
|
|
35
|
+
"@wordpress/keyboard-shortcuts": "^4.8.0",
|
|
36
|
+
"@wordpress/private-apis": "^0.13.0",
|
|
37
|
+
"cmdk": "^0.2.0",
|
|
38
|
+
"rememo": "^4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "d61700b9f1c72ba0b030fc815ef1685b4f4031ec"
|
|
47
|
+
}
|