@wordpress/plugins 7.10.0 → 7.12.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 +2 -0
- package/build/components/plugin-context/index.js +8 -0
- package/build/components/plugin-context/index.js.map +1 -1
- package/build-module/components/plugin-context/index.js +7 -0
- package/build-module/components/plugin-context/index.js.map +1 -1
- package/build-types/components/plugin-context/index.d.ts +2 -0
- package/build-types/components/plugin-context/index.d.ts.map +1 -1
- package/package.json +10 -8
- package/src/components/plugin-context/index.tsx +7 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -8,6 +9,7 @@ exports.usePluginContext = usePluginContext;
|
|
|
8
9
|
exports.withPluginContext = void 0;
|
|
9
10
|
var _element = require("@wordpress/element");
|
|
10
11
|
var _compose = require("@wordpress/compose");
|
|
12
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
11
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
14
|
/**
|
|
13
15
|
* WordPress dependencies
|
|
@@ -36,6 +38,8 @@ function usePluginContext() {
|
|
|
36
38
|
* A Higher Order Component used to inject Plugin context to the
|
|
37
39
|
* wrapped component.
|
|
38
40
|
*
|
|
41
|
+
* @deprecated 6.8.0 Use `usePluginContext` hook instead.
|
|
42
|
+
*
|
|
39
43
|
* @param mapContextToProps Function called on every context change,
|
|
40
44
|
* expected to return object of props to
|
|
41
45
|
* merge with the component's own props.
|
|
@@ -43,6 +47,10 @@ function usePluginContext() {
|
|
|
43
47
|
* @return {Component} Enhanced component with injected context as props.
|
|
44
48
|
*/
|
|
45
49
|
const withPluginContext = mapContextToProps => (0, _compose.createHigherOrderComponent)(OriginalComponent => {
|
|
50
|
+
(0, _deprecated.default)('wp.plugins.withPluginContext', {
|
|
51
|
+
since: '6.8.0',
|
|
52
|
+
alternative: 'wp.plugins.usePluginContext'
|
|
53
|
+
});
|
|
46
54
|
return props => /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Consumer, {
|
|
47
55
|
children: context => /*#__PURE__*/(0, _jsxRuntime.jsx)(OriginalComponent, {
|
|
48
56
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_jsxRuntime","Context","createContext","name","icon","PluginContextProvider","exports","Provider","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","props","jsx","Consumer","children","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_deprecated","_interopRequireDefault","_jsxRuntime","Context","createContext","name","icon","PluginContextProvider","exports","Provider","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","deprecated","since","alternative","props","jsx","Consumer","children","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @deprecated 6.8.0 Use `usePluginContext` hook instead.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\tdeprecated( 'wp.plugins.withPluginContext', {\n\t\t\tsince: '6.8.0',\n\t\t\talternative: 'wp.plugins.usePluginContext',\n\t\t} );\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA+C,IAAAI,WAAA,GAAAJ,OAAA;AAL/C;AACA;AACA;;AAKA;AACA;AACA;;AAQA,MAAMK,OAAO,GAAG,IAAAC,sBAAa,EAAmB;EAC/CC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEI,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAGJ,OAAO,CAACM,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAO,IAAAC,mBAAU,EAAER,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,iBAAiB,GAC7BC,iBAGsB,IAEtB,IAAAC,mCAA0B,EAAIC,iBAAiB,IAAM;EACpD,IAAAC,mBAAU,EAAE,8BAA8B,EAAE;IAC3CC,KAAK,EAAE,OAAO;IACdC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAASC,KAAK,iBACb,IAAAjB,WAAA,CAAAkB,GAAA,EAACjB,OAAO,CAACkB,QAAQ;IAAAC,QAAA,EACZC,OAAO,iBACV,IAAArB,WAAA,CAAAkB,GAAA,EAACL,iBAAiB;MAAA,GACZI,KAAK;MAAA,GACLN,iBAAiB,CAAEU,OAAO,EAAEJ,KAAM;IAAC,CACxC;EACD,CACgB,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC;AAACX,OAAA,CAAAI,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createContext, useContext } from '@wordpress/element';
|
|
5
5
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
|
+
import deprecated from '@wordpress/deprecated';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -27,6 +28,8 @@ export function usePluginContext() {
|
|
|
27
28
|
* A Higher Order Component used to inject Plugin context to the
|
|
28
29
|
* wrapped component.
|
|
29
30
|
*
|
|
31
|
+
* @deprecated 6.8.0 Use `usePluginContext` hook instead.
|
|
32
|
+
*
|
|
30
33
|
* @param mapContextToProps Function called on every context change,
|
|
31
34
|
* expected to return object of props to
|
|
32
35
|
* merge with the component's own props.
|
|
@@ -34,6 +37,10 @@ export function usePluginContext() {
|
|
|
34
37
|
* @return {Component} Enhanced component with injected context as props.
|
|
35
38
|
*/
|
|
36
39
|
export const withPluginContext = mapContextToProps => createHigherOrderComponent(OriginalComponent => {
|
|
40
|
+
deprecated('wp.plugins.withPluginContext', {
|
|
41
|
+
since: '6.8.0',
|
|
42
|
+
alternative: 'wp.plugins.usePluginContext'
|
|
43
|
+
});
|
|
37
44
|
return props => /*#__PURE__*/_jsx(Context.Consumer, {
|
|
38
45
|
children: context => /*#__PURE__*/_jsx(OriginalComponent, {
|
|
39
46
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","createHigherOrderComponent","jsx","_jsx","Context","name","icon","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","props","Consumer","children","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB
|
|
1
|
+
{"version":3,"names":["createContext","useContext","createHigherOrderComponent","deprecated","jsx","_jsx","Context","name","icon","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","since","alternative","props","Consumer","children","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @deprecated 6.8.0 Use `usePluginContext` hook instead.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\tdeprecated( 'wp.plugins.withPluginContext', {\n\t\t\tsince: '6.8.0',\n\t\t\talternative: 'wp.plugins.usePluginContext',\n\t\t} );\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAUA,MAAMC,OAAO,GAAGN,aAAa,CAAmB;EAC/CO,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEH,OAAO,MAAMC,qBAAqB,GAAGH,OAAO,CAACI,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAOV,UAAU,CAAEK,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,iBAAiB,GAC7BC,iBAGsB,IAEtBX,0BAA0B,CAAIY,iBAAiB,IAAM;EACpDX,UAAU,CAAE,8BAA8B,EAAE;IAC3CY,KAAK,EAAE,OAAO;IACdC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAASC,KAAK,iBACbZ,IAAA,CAACC,OAAO,CAACY,QAAQ;IAAAC,QAAA,EACZC,OAAO,iBACVf,IAAA,CAACS,iBAAiB;MAAA,GACZG,KAAK;MAAA,GACLJ,iBAAiB,CAAEO,OAAO,EAAEH,KAAM;IAAC,CACxC;EACD,CACgB,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC","ignoreList":[]}
|
|
@@ -17,6 +17,8 @@ export declare function usePluginContext(): PluginContext;
|
|
|
17
17
|
* A Higher Order Component used to inject Plugin context to the
|
|
18
18
|
* wrapped component.
|
|
19
19
|
*
|
|
20
|
+
* @deprecated 6.8.0 Use `usePluginContext` hook instead.
|
|
21
|
+
*
|
|
20
22
|
* @param mapContextToProps Function called on every context change,
|
|
21
23
|
* expected to return object of props to
|
|
22
24
|
* merge with the component's own props.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-context/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-context/index.tsx"],"names":[],"mappings":"AAOA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAC;IAChC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAC;CAChC;AAOD,eAAO,MAAM,qBAAqB,yCAAmB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,gBAAgB,kBAE/B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,sBACV,CAAE,CAAC,EACrB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,CAAC,KACJ,CAAC,GAAG,aAAa,+FAiBE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/plugins",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.12.0",
|
|
4
4
|
"description": "Plugins module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,15 +25,17 @@
|
|
|
25
25
|
"main": "build/index.js",
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
27
|
"react-native": "src/index",
|
|
28
|
+
"wpScript": true,
|
|
28
29
|
"types": "build-types",
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@babel/runtime": "7.25.7",
|
|
31
|
-
"@wordpress/components": "
|
|
32
|
-
"@wordpress/compose": "
|
|
33
|
-
"@wordpress/
|
|
34
|
-
"@wordpress/
|
|
35
|
-
"@wordpress/
|
|
36
|
-
"@wordpress/
|
|
32
|
+
"@wordpress/components": "*",
|
|
33
|
+
"@wordpress/compose": "*",
|
|
34
|
+
"@wordpress/deprecated": "*",
|
|
35
|
+
"@wordpress/element": "*",
|
|
36
|
+
"@wordpress/hooks": "*",
|
|
37
|
+
"@wordpress/icons": "*",
|
|
38
|
+
"@wordpress/is-shallow-equal": "*",
|
|
37
39
|
"memize": "^2.0.1"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
@@ -43,5 +45,5 @@
|
|
|
43
45
|
"publishConfig": {
|
|
44
46
|
"access": "public"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "510540d99f3d222a96f08d3d7b66c9e7a726f705"
|
|
47
49
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createContext, useContext } from '@wordpress/element';
|
|
5
5
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
|
+
import deprecated from '@wordpress/deprecated';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -34,6 +35,8 @@ export function usePluginContext() {
|
|
|
34
35
|
* A Higher Order Component used to inject Plugin context to the
|
|
35
36
|
* wrapped component.
|
|
36
37
|
*
|
|
38
|
+
* @deprecated 6.8.0 Use `usePluginContext` hook instead.
|
|
39
|
+
*
|
|
37
40
|
* @param mapContextToProps Function called on every context change,
|
|
38
41
|
* expected to return object of props to
|
|
39
42
|
* merge with the component's own props.
|
|
@@ -47,6 +50,10 @@ export const withPluginContext = (
|
|
|
47
50
|
) => T & PluginContext
|
|
48
51
|
) =>
|
|
49
52
|
createHigherOrderComponent( ( OriginalComponent ) => {
|
|
53
|
+
deprecated( 'wp.plugins.withPluginContext', {
|
|
54
|
+
since: '6.8.0',
|
|
55
|
+
alternative: 'wp.plugins.usePluginContext',
|
|
56
|
+
} );
|
|
50
57
|
return ( props ) => (
|
|
51
58
|
<Context.Consumer>
|
|
52
59
|
{ ( context ) => (
|