@wordpress/element 8.0.0 → 8.0.1
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 +3 -1
- package/README.md +2 -6
- package/build/platform.cjs.map +2 -2
- package/build-module/platform.mjs.map +2 -2
- package/build-types/find-dom-node.d.ts +10 -0
- package/build-types/find-dom-node.d.ts.map +1 -0
- package/build-types/platform.d.ts +1 -13
- package/build-types/platform.d.ts.map +1 -1
- package/package.json +10 -7
- package/src/platform.ts +1 -14
- package/src/test/platform.js +10 -2
- package/src/platform.android.js +0 -21
- package/src/platform.ios.js +0 -21
- package/src/react-platform.native.js +0 -14
- package/src/test/platform.native.js +0 -15
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -238,11 +238,7 @@ _Related_
|
|
|
238
238
|
|
|
239
239
|
Component used to detect the current Platform being used. Use Platform.OS === 'web' to detect if running on web environment.
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
_Related_
|
|
244
|
-
|
|
245
|
-
- <https://reactnative.dev/docs/platform-specific-code#platform-module> Here is an example of how to use the select method:
|
|
241
|
+
Here is an example of how to use the select method:
|
|
246
242
|
|
|
247
243
|
_Usage_
|
|
248
244
|
|
|
@@ -250,10 +246,10 @@ _Usage_
|
|
|
250
246
|
import { Platform } from '@wordpress/element';
|
|
251
247
|
|
|
252
248
|
const placeholderLabel = Platform.select( {
|
|
253
|
-
native: __( 'Add media' ),
|
|
254
249
|
web: __(
|
|
255
250
|
'Drag images, upload new ones or select files from your library.'
|
|
256
251
|
),
|
|
252
|
+
default: __( 'Add media' ),
|
|
257
253
|
} );
|
|
258
254
|
```
|
|
259
255
|
|
package/build/platform.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/platform.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Specification for platform-specific value selection.\n */\ntype PlatformSelectSpec< T > = {\n\tweb?: T;\n\tdefault?: T;\n};\n\n/**\n * Component used to detect the current Platform being used.\n * Use Platform.OS === 'web' to detect if running on web environment.\n *\n * Here is an example of how to use the select method:\n * @example\n * ```js\n * import { Platform } from '@wordpress/element';\n *\n * const placeholderLabel = Platform.select( {\n * web: __( 'Drag images, upload new ones or select files from your library.' ),\n * default: __( 'Add media' ),\n * } );\n * ```\n */\nconst Platform = {\n\t/** Platform identifier. Will always be `'web'` in this module. */\n\tOS: 'web' as const,\n\n\t/**\n\t * Select a value based on the platform.\n\t *\n\t * @template T\n\t * @param spec - Object with optional platform-specific values.\n\t * @return The selected value.\n\t */\n\tselect< T >( spec: PlatformSelectSpec< T > ): T | undefined {\n\t\treturn 'web' in spec ? spec.web : spec.default;\n\t},\n\n\t/** Whether the platform is web */\n\tisWeb: true,\n};\n\nexport default Platform;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,IAAM,WAAW;AAAA;AAAA,EAEhB,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASJ,OAAa,MAA+C;AAC3D,WAAO,SAAS,OAAO,KAAK,MAAM,KAAK;AAAA,EACxC;AAAA;AAAA,EAGA,OAAO;AACR;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/platform.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Specification for platform-specific value selection.\n */\ntype PlatformSelectSpec< T > = {\n\tweb?: T;\n\tdefault?: T;\n};\n\n/**\n * Component used to detect the current Platform being used.\n * Use Platform.OS === 'web' to detect if running on web environment.\n *\n * Here is an example of how to use the select method:\n * @example\n * ```js\n * import { Platform } from '@wordpress/element';\n *\n * const placeholderLabel = Platform.select( {\n * web: __( 'Drag images, upload new ones or select files from your library.' ),\n * default: __( 'Add media' ),\n * } );\n * ```\n */\nconst Platform = {\n\t/** Platform identifier. Will always be `'web'` in this module. */\n\tOS: 'web' as const,\n\n\t/**\n\t * Select a value based on the platform.\n\t *\n\t * @template T\n\t * @param spec - Object with optional platform-specific values.\n\t * @return The selected value.\n\t */\n\tselect< T >( spec: PlatformSelectSpec< T > ): T | undefined {\n\t\treturn 'web' in spec ? spec.web : spec.default;\n\t},\n\n\t/** Whether the platform is web */\n\tisWeb: true,\n};\n\nexport default Platform;\n"],
|
|
5
|
+
"mappings": ";AAuBA,IAAM,WAAW;AAAA;AAAA,EAEhB,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASJ,OAAa,MAA+C;AAC3D,WAAO,SAAS,OAAO,KAAK,MAAM,KAAK;AAAA,EACxC;AAAA;AAAA,EAGA,OAAO;AACR;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the DOM node of a React component instance.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated since WordPress 7.1.0. Use DOM refs instead.
|
|
5
|
+
* @see https://react.dev/reference/react-dom/findDOMNode
|
|
6
|
+
*
|
|
7
|
+
* @param instance Component's instance.
|
|
8
|
+
*/
|
|
9
|
+
export default function findDOMNode(instance: any): Element | Text | null;
|
|
10
|
+
//# sourceMappingURL=find-dom-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-dom-node.d.ts","sourceRoot":"","sources":["../src/find-dom-node.ts"],"names":[],"mappings":"AAuDA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,QAAQ,EAAE,GAAG,GAAI,OAAO,GAAG,IAAI,GAAG,IAAI,CA4B1E"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parts of this source were derived and modified from react-native-web,
|
|
3
|
-
* released under the MIT license.
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2016-present, Nicolas Gallagher.
|
|
6
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
1
|
/**
|
|
10
2
|
* Specification for platform-specific value selection.
|
|
11
3
|
*/
|
|
@@ -17,18 +9,14 @@ type PlatformSelectSpec<T> = {
|
|
|
17
9
|
* Component used to detect the current Platform being used.
|
|
18
10
|
* Use Platform.OS === 'web' to detect if running on web environment.
|
|
19
11
|
*
|
|
20
|
-
* This is the same concept as the React Native implementation.
|
|
21
|
-
*
|
|
22
|
-
* @see https://reactnative.dev/docs/platform-specific-code#platform-module
|
|
23
|
-
*
|
|
24
12
|
* Here is an example of how to use the select method:
|
|
25
13
|
* @example
|
|
26
14
|
* ```js
|
|
27
15
|
* import { Platform } from '@wordpress/element';
|
|
28
16
|
*
|
|
29
17
|
* const placeholderLabel = Platform.select( {
|
|
30
|
-
* native: __( 'Add media' ),
|
|
31
18
|
* web: __( 'Drag images, upload new ones or select files from your library.' ),
|
|
19
|
+
* default: __( 'Add media' ),
|
|
32
20
|
* } );
|
|
33
21
|
* ```
|
|
34
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,kBAAkB,CAAE,CAAC,IAAK;IAC9B,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,QAAQ;IACb,kEAAkE;IAClE,EAAE,EAAE,KAAK;IAET;;;;;;OAMG;IACH,MAAM,CAAE,CAAC,QAAU,kBAAkB,CAAE,CAAC,CAAE,GAAI,CAAC,GAAG,SAAS;IAI3D,kCAAkC;IAClC,KAAK;CACL,CAAC;eAEa,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/element",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Element React module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -41,22 +41,25 @@
|
|
|
41
41
|
"./react-polyfill": "./src/react-polyfill-base.ts",
|
|
42
42
|
"./package.json": "./package.json"
|
|
43
43
|
},
|
|
44
|
-
"react-native": "src/index",
|
|
45
44
|
"wpScript": true,
|
|
46
45
|
"types": "build-types",
|
|
47
46
|
"sideEffects": false,
|
|
48
47
|
"dependencies": {
|
|
49
48
|
"@types/react": "^18.3.27",
|
|
50
49
|
"@types/react-dom": "^18.3.1",
|
|
51
|
-
"@wordpress/deprecated": "^4.48.
|
|
52
|
-
"@wordpress/escape-html": "^3.48.
|
|
50
|
+
"@wordpress/deprecated": "^4.48.1",
|
|
51
|
+
"@wordpress/escape-html": "^3.48.1",
|
|
53
52
|
"change-case": "^4.1.2",
|
|
54
53
|
"is-plain-object": "^5.0.0",
|
|
55
|
-
"react": "^18.3.
|
|
56
|
-
"react-dom": "^18.3.
|
|
54
|
+
"react": "^18.3.1",
|
|
55
|
+
"react-dom": "^18.3.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@testing-library/dom": "^10.4.1",
|
|
59
|
+
"@testing-library/react": "^16.3.2"
|
|
57
60
|
},
|
|
58
61
|
"publishConfig": {
|
|
59
62
|
"access": "public"
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "99df7432c5c7cb83ba41146fd1f57f3c19004305"
|
|
62
65
|
}
|
package/src/platform.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parts of this source were derived and modified from react-native-web,
|
|
3
|
-
* released under the MIT license.
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2016-present, Nicolas Gallagher.
|
|
6
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
/**
|
|
11
2
|
* Specification for platform-specific value selection.
|
|
12
3
|
*/
|
|
@@ -19,18 +10,14 @@ type PlatformSelectSpec< T > = {
|
|
|
19
10
|
* Component used to detect the current Platform being used.
|
|
20
11
|
* Use Platform.OS === 'web' to detect if running on web environment.
|
|
21
12
|
*
|
|
22
|
-
* This is the same concept as the React Native implementation.
|
|
23
|
-
*
|
|
24
|
-
* @see https://reactnative.dev/docs/platform-specific-code#platform-module
|
|
25
|
-
*
|
|
26
13
|
* Here is an example of how to use the select method:
|
|
27
14
|
* @example
|
|
28
15
|
* ```js
|
|
29
16
|
* import { Platform } from '@wordpress/element';
|
|
30
17
|
*
|
|
31
18
|
* const placeholderLabel = Platform.select( {
|
|
32
|
-
* native: __( 'Add media' ),
|
|
33
19
|
* web: __( 'Drag images, upload new ones or select files from your library.' ),
|
|
20
|
+
* default: __( 'Add media' ),
|
|
34
21
|
* } );
|
|
35
22
|
* ```
|
|
36
23
|
*/
|
package/src/test/platform.js
CHANGED
|
@@ -4,12 +4,20 @@
|
|
|
4
4
|
import Platform from '../platform';
|
|
5
5
|
|
|
6
6
|
describe( 'Platform', () => {
|
|
7
|
-
it( '
|
|
7
|
+
it( 'selects the web value', () => {
|
|
8
8
|
const element = Platform.select( {
|
|
9
9
|
web: <div />,
|
|
10
|
-
|
|
10
|
+
default: <button />,
|
|
11
11
|
} );
|
|
12
12
|
|
|
13
13
|
expect( element ).toEqual( <div /> );
|
|
14
14
|
} );
|
|
15
|
+
|
|
16
|
+
it( 'falls back to the default value when no web value is provided', () => {
|
|
17
|
+
const element = Platform.select( {
|
|
18
|
+
default: <button />,
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
expect( element ).toEqual( <button /> );
|
|
22
|
+
} );
|
|
15
23
|
} );
|
package/src/platform.android.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Platform as OriginalPlatform } from 'react-native';
|
|
5
|
-
|
|
6
|
-
const Platform = {
|
|
7
|
-
...OriginalPlatform,
|
|
8
|
-
OS: 'native',
|
|
9
|
-
select: ( spec ) => {
|
|
10
|
-
if ( 'android' in spec ) {
|
|
11
|
-
return spec.android;
|
|
12
|
-
} else if ( 'native' in spec ) {
|
|
13
|
-
return spec.native;
|
|
14
|
-
}
|
|
15
|
-
return spec.default;
|
|
16
|
-
},
|
|
17
|
-
isNative: true,
|
|
18
|
-
isAndroid: true,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default Platform;
|
package/src/platform.ios.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Platform as OriginalPlatform } from 'react-native';
|
|
5
|
-
|
|
6
|
-
const Platform = {
|
|
7
|
-
...OriginalPlatform,
|
|
8
|
-
OS: 'native',
|
|
9
|
-
select: ( spec ) => {
|
|
10
|
-
if ( 'ios' in spec ) {
|
|
11
|
-
return spec.ios;
|
|
12
|
-
} else if ( 'native' in spec ) {
|
|
13
|
-
return spec.native;
|
|
14
|
-
}
|
|
15
|
-
return spec.default;
|
|
16
|
-
},
|
|
17
|
-
isNative: true,
|
|
18
|
-
isIOS: true,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default Platform;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { AppRegistry } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Registers an app root component allowing the native system to run the app.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} appKey Unique app name identifier.
|
|
10
|
-
* @param {Function} componentProvider Function returning the app root React component.
|
|
11
|
-
*/
|
|
12
|
-
export const registerComponent = ( appKey, componentProvider ) => {
|
|
13
|
-
AppRegistry.registerComponent( appKey, componentProvider );
|
|
14
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import Platform from '../platform';
|
|
5
|
-
|
|
6
|
-
describe( 'Platform', () => {
|
|
7
|
-
it( 'is chooses the right thing', () => {
|
|
8
|
-
const selection = Platform.select( {
|
|
9
|
-
web: 'web',
|
|
10
|
-
native: 'native',
|
|
11
|
-
} );
|
|
12
|
-
|
|
13
|
-
expect( selection ).toBe( 'native' );
|
|
14
|
-
} );
|
|
15
|
-
} );
|