@wordpress/commands 0.3.0 → 0.5.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 +4 -0
- package/README.md +16 -0
- package/build/components/command-menu.js +83 -57
- package/build/components/command-menu.js.map +1 -1
- package/build/hooks/use-command-context.js +45 -0
- package/build/hooks/use-command-context.js.map +1 -0
- package/build/hooks/use-command-loader.js +6 -11
- package/build/hooks/use-command-loader.js.map +1 -1
- package/build/hooks/use-command.js +5 -3
- package/build/hooks/use-command.js.map +1 -1
- package/build/index.js +18 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +61 -40
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +63 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +25 -17
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/command-menu.js +83 -57
- package/build-module/components/command-menu.js.map +1 -1
- package/build-module/hooks/use-command-context.js +35 -0
- package/build-module/hooks/use-command-context.js.map +1 -0
- package/build-module/hooks/use-command-loader.js +6 -11
- package/build-module/hooks/use-command-loader.js.map +1 -1
- package/build-module/hooks/use-command.js +5 -3
- package/build-module/hooks/use-command.js.map +1 -1
- package/build-module/index.js +2 -0
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +4 -4
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +55 -40
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +63 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +19 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +9 -1
- package/build-style/style.css +9 -1
- package/package.json +9 -9
- package/src/components/command-menu.js +57 -43
- package/src/components/style.scss +11 -1
- package/src/hooks/use-command-context.js +32 -0
- package/src/hooks/use-command-loader.js +12 -6
- package/src/hooks/use-command.js +7 -3
- package/src/index.js +2 -0
- package/src/private-apis.js +4 -4
- package/src/store/actions.js +53 -26
- package/src/store/reducer.js +53 -27
- package/src/store/selectors.js +22 -19
package/src/store/selectors.js
CHANGED
|
@@ -3,27 +3,30 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import createSelector from 'rememo';
|
|
5
5
|
|
|
6
|
-
function unique( array ) {
|
|
7
|
-
return array.filter(
|
|
8
|
-
( value, index, current ) => current.indexOf( value ) === index
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const getGroups = createSelector(
|
|
13
|
-
( state ) =>
|
|
14
|
-
unique(
|
|
15
|
-
Object.keys( state.commands ).concat(
|
|
16
|
-
Object.keys( state.commandLoaders )
|
|
17
|
-
)
|
|
18
|
-
),
|
|
19
|
-
( state ) => [ state.commands, state.commandLoaders ]
|
|
20
|
-
);
|
|
21
6
|
export const getCommands = createSelector(
|
|
22
|
-
( state,
|
|
23
|
-
|
|
7
|
+
( state, contextual = false ) =>
|
|
8
|
+
Object.values( state.commands ).filter( ( command ) => {
|
|
9
|
+
const isContextual =
|
|
10
|
+
command.context && command.context === state.context;
|
|
11
|
+
return contextual ? isContextual : ! isContextual;
|
|
12
|
+
} ),
|
|
13
|
+
( state ) => [ state.commands, state.context ]
|
|
24
14
|
);
|
|
25
15
|
|
|
26
16
|
export const getCommandLoaders = createSelector(
|
|
27
|
-
( state,
|
|
28
|
-
|
|
17
|
+
( state, contextual = false ) =>
|
|
18
|
+
Object.values( state.commandLoaders ).filter( ( loader ) => {
|
|
19
|
+
const isContextual =
|
|
20
|
+
loader.context && loader.context === state.context;
|
|
21
|
+
return contextual ? isContextual : ! isContextual;
|
|
22
|
+
} ),
|
|
23
|
+
( state ) => [ state.commandLoaders, state.context ]
|
|
29
24
|
);
|
|
25
|
+
|
|
26
|
+
export function isOpen( state ) {
|
|
27
|
+
return state.isOpen;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getContext( state ) {
|
|
31
|
+
return state.context;
|
|
32
|
+
}
|