@wordpress/element
Advanced tools
Comparing version 2.8.2 to 2.9.0
export * from './react'; | ||
export * from './react-platform'; | ||
export * from './utils'; | ||
export { default as Platform } from './platform'; | ||
export { default as renderToString } from './serialize'; | ||
export { default as RawHTML } from './raw-html'; | ||
//# sourceMappingURL=index.js.map |
@@ -18,3 +18,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread"; | ||
* | ||
* @return {WPElement} Dangerously-rendering element. | ||
* @return {WPComponent} Dangerously-rendering component. | ||
*/ | ||
@@ -21,0 +21,0 @@ |
@@ -10,4 +10,5 @@ /** | ||
* | ||
* @param {Component} component Component | ||
* @param {Element} target DOM node into which element should be rendered | ||
* @param {WPElement} child Any renderable child, such as an element, | ||
* string, or fragment. | ||
* @param {HTMLElement} container DOM node into which element should be rendered. | ||
*/ | ||
@@ -17,6 +18,5 @@ | ||
/** | ||
* Finds the dom node of a React component | ||
* Finds the dom node of a React component. | ||
* | ||
* @param {Component} component component's instance | ||
* @param {Element} target DOM node into which element should be rendered | ||
* @param {WPComponent} component Component's instance. | ||
*/ | ||
@@ -28,4 +28,4 @@ | ||
* | ||
* @param {WPElement} element Element to render | ||
* @param {Element} target DOM node into which element should be rendered | ||
* @param {WPElement} element Element to render. | ||
* @param {HTMLElement} target DOM node into which element should be rendered. | ||
*/ | ||
@@ -32,0 +32,0 @@ |
@@ -10,2 +10,20 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread"; | ||
/** | ||
* Object containing a React element. | ||
* | ||
* @typedef {react.ReactElement} WPElement | ||
*/ | ||
/** | ||
* Object containing a React component. | ||
* | ||
* @typedef {react.Component} WPComponent | ||
*/ | ||
/** | ||
* Object containing a React synthetic event. | ||
* | ||
* @typedef {react.SyntheticEvent} WPSyntheticEvent | ||
*/ | ||
/** | ||
* Object that provides utilities for dealing with React children. | ||
@@ -45,4 +63,4 @@ */ | ||
* @param {Object} props Element properties, either attribute | ||
* set to apply to DOM node or values to | ||
* pass through to element creator | ||
* set to apply to DOM node or values to | ||
* pass through to element creator | ||
* @param {...WPElement} children Descendant elements | ||
@@ -82,3 +100,3 @@ * | ||
/** | ||
* Checks if an object is a valid WPElement | ||
* Checks if an object is a valid WPElement. | ||
* | ||
@@ -174,3 +192,3 @@ * @param {Object} objectToCheck The object to be checked. | ||
return childrenArguments.reduce(function (result, children, i) { | ||
return childrenArguments.reduce(function (accumulator, children, i) { | ||
Children.forEach(children, function (child, j) { | ||
@@ -183,5 +201,5 @@ if (child && 'string' !== typeof child) { | ||
result.push(child); | ||
accumulator.push(child); | ||
}); | ||
return result; | ||
return accumulator; | ||
}, []); | ||
@@ -188,0 +206,0 @@ } |
@@ -9,5 +9,12 @@ "use strict"; | ||
var _exportNames = { | ||
Platform: true, | ||
renderToString: true, | ||
RawHTML: true | ||
}; | ||
Object.defineProperty(exports, "Platform", { | ||
enumerable: true, | ||
get: function get() { | ||
return _platform.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "renderToString", { | ||
@@ -65,2 +72,4 @@ enumerable: true, | ||
var _platform = _interopRequireDefault(require("./platform")); | ||
var _serialize = _interopRequireDefault(require("./serialize")); | ||
@@ -67,0 +76,0 @@ |
@@ -30,3 +30,3 @@ "use strict"; | ||
* | ||
* @return {WPElement} Dangerously-rendering element. | ||
* @return {WPComponent} Dangerously-rendering component. | ||
*/ | ||
@@ -33,0 +33,0 @@ function RawHTML(_ref) { |
@@ -162,2 +162,20 @@ "use strict"; | ||
/** | ||
* Object containing a React element. | ||
* | ||
* @typedef {react.ReactElement} WPElement | ||
*/ | ||
/** | ||
* Object containing a React component. | ||
* | ||
* @typedef {react.Component} WPComponent | ||
*/ | ||
/** | ||
* Object containing a React synthetic event. | ||
* | ||
* @typedef {react.SyntheticEvent} WPSyntheticEvent | ||
*/ | ||
/** | ||
* Object that provides utilities for dealing with React children. | ||
@@ -193,4 +211,4 @@ */ | ||
* @param {Object} props Element properties, either attribute | ||
* set to apply to DOM node or values to | ||
* pass through to element creator | ||
* set to apply to DOM node or values to | ||
* pass through to element creator | ||
* @param {...WPElement} children Descendant elements | ||
@@ -226,3 +244,3 @@ * | ||
/** | ||
* Checks if an object is a valid WPElement | ||
* Checks if an object is a valid WPElement. | ||
* | ||
@@ -302,3 +320,3 @@ * @param {Object} objectToCheck The object to be checked. | ||
return childrenArguments.reduce(function (result, children, i) { | ||
return childrenArguments.reduce(function (accumulator, children, i) { | ||
_react.Children.forEach(children, function (child, j) { | ||
@@ -311,6 +329,6 @@ if (child && 'string' !== typeof child) { | ||
result.push(child); | ||
accumulator.push(child); | ||
}); | ||
return result; | ||
return accumulator; | ||
}, []); | ||
@@ -317,0 +335,0 @@ } |
{ | ||
"name": "@wordpress/element", | ||
"version": "2.8.2", | ||
"version": "2.9.0", | ||
"description": "Element React module for WordPress.", | ||
@@ -27,3 +27,3 @@ "author": "The WordPress Contributors", | ||
"@babel/runtime": "^7.4.4", | ||
"@wordpress/escape-html": "^1.5.1", | ||
"@wordpress/escape-html": "^1.6.0", | ||
"lodash": "^4.17.15", | ||
@@ -36,3 +36,3 @@ "react": "^16.9.0", | ||
}, | ||
"gitHead": "707754784420a7089ae31ec4d6c756ce9af9c782" | ||
"gitHead": "52bfe7deb90fe2b6df7f1a0a92f89cc69462a491" | ||
} |
@@ -151,4 +151,4 @@ # Element | ||
- _component_ `Component`: Component | ||
- _target_ `Element`: DOM node into which element should be rendered | ||
- _child_ `WPElement`: Any renderable child, such as an element, string, or fragment. | ||
- _container_ `HTMLElement`: DOM node into which element should be rendered. | ||
@@ -167,8 +167,7 @@ <a name="createRef" href="#createRef">#</a> **createRef** | ||
Finds the dom node of a React component | ||
Finds the dom node of a React component. | ||
_Parameters_ | ||
- _component_ `Component`: component's instance | ||
- _target_ `Element`: DOM node into which element should be rendered | ||
- _component_ `WPComponent`: Component's instance. | ||
@@ -208,3 +207,3 @@ <a name="forwardRef" href="#forwardRef">#</a> **forwardRef** | ||
Checks if an object is a valid WPElement | ||
Checks if an object is a valid WPElement. | ||
@@ -231,2 +230,26 @@ _Parameters_ | ||
<a name="Platform" href="#Platform">#</a> **Platform** | ||
Component used to detect the current Platform being used. | ||
Use Platform.OS === 'web' to detect if running on web enviroment. | ||
This is the same concept as the React Native implementation. | ||
_Related_ | ||
- <https://facebook.github.io/react-native/docs/platform-specific-code#platform-module> | ||
Here is an example of how to use the select method: | ||
_Usage_ | ||
```js | ||
import { Platform } from '@wordpress/element'; | ||
const placeholderLabel = Platform.select( { | ||
native: __( 'Add media' ), | ||
web: __( 'Drag images, upload new ones or select files from your library.' ), | ||
} ); | ||
``` | ||
<a name="RawHTML" href="#RawHTML">#</a> **RawHTML** | ||
@@ -247,3 +270,3 @@ | ||
- `WPElement`: Dangerously-rendering element. | ||
- `WPComponent`: Dangerously-rendering component. | ||
@@ -256,4 +279,4 @@ <a name="render" href="#render">#</a> **render** | ||
- _element_ `WPElement`: Element to render | ||
- _target_ `Element`: DOM node into which element should be rendered | ||
- _element_ `WPElement`: Element to render. | ||
- _target_ `HTMLElement`: DOM node into which element should be rendered. | ||
@@ -260,0 +283,0 @@ <a name="renderToString" href="#renderToString">#</a> **renderToString** |
export * from './react'; | ||
export * from './react-platform'; | ||
export * from './utils'; | ||
export { default as Platform } from './platform'; | ||
export { default as renderToString } from './serialize'; | ||
export { default as RawHTML } from './raw-html'; |
@@ -16,3 +16,3 @@ /** | ||
* | ||
* @return {WPElement} Dangerously-rendering element. | ||
* @return {WPComponent} Dangerously-rendering component. | ||
*/ | ||
@@ -19,0 +19,0 @@ export default function RawHTML( { children, ...props } ) { |
@@ -16,4 +16,5 @@ /** | ||
* | ||
* @param {Component} component Component | ||
* @param {Element} target DOM node into which element should be rendered | ||
* @param {WPElement} child Any renderable child, such as an element, | ||
* string, or fragment. | ||
* @param {HTMLElement} container DOM node into which element should be rendered. | ||
*/ | ||
@@ -23,6 +24,5 @@ export { createPortal }; | ||
/** | ||
* Finds the dom node of a React component | ||
* Finds the dom node of a React component. | ||
* | ||
* @param {Component} component component's instance | ||
* @param {Element} target DOM node into which element should be rendered | ||
* @param {WPComponent} component Component's instance. | ||
*/ | ||
@@ -34,4 +34,4 @@ export { findDOMNode }; | ||
* | ||
* @param {WPElement} element Element to render | ||
* @param {Element} target DOM node into which element should be rendered | ||
* @param {WPElement} element Element to render. | ||
* @param {HTMLElement} target DOM node into which element should be rendered. | ||
*/ | ||
@@ -38,0 +38,0 @@ export { render }; |
@@ -32,2 +32,20 @@ /** | ||
/** | ||
* Object containing a React element. | ||
* | ||
* @typedef {react.ReactElement} WPElement | ||
*/ | ||
/** | ||
* Object containing a React component. | ||
* | ||
* @typedef {react.Component} WPComponent | ||
*/ | ||
/** | ||
* Object containing a React synthetic event. | ||
* | ||
* @typedef {react.SyntheticEvent} WPSyntheticEvent | ||
*/ | ||
/** | ||
* Object that provides utilities for dealing with React children. | ||
@@ -67,4 +85,4 @@ */ | ||
* @param {Object} props Element properties, either attribute | ||
* set to apply to DOM node or values to | ||
* pass through to element creator | ||
* set to apply to DOM node or values to | ||
* pass through to element creator | ||
* @param {...WPElement} children Descendant elements | ||
@@ -104,3 +122,3 @@ * | ||
/** | ||
* Checks if an object is a valid WPElement | ||
* Checks if an object is a valid WPElement. | ||
* | ||
@@ -191,3 +209,3 @@ * @param {Object} objectToCheck The object to be checked. | ||
export function concatChildren( ...childrenArguments ) { | ||
return childrenArguments.reduce( ( result, children, i ) => { | ||
return childrenArguments.reduce( ( accumulator, children, i ) => { | ||
Children.forEach( children, ( child, j ) => { | ||
@@ -200,6 +218,6 @@ if ( child && 'string' !== typeof child ) { | ||
result.push( child ); | ||
accumulator.push( child ); | ||
} ); | ||
return result; | ||
return accumulator; | ||
}, [] ); | ||
@@ -206,0 +224,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222049
60
3350
386