@wordpress/element 4.0.2 → 4.1.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 +12 -0
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/build/index.js +8 -8
- package/build/raw-html.js +19 -9
- package/build/raw-html.js.map +1 -1
- package/build/react-platform.native.js +8 -40
- package/build/react-platform.native.js.map +1 -1
- package/build/react.js +50 -46
- package/build/react.js.map +1 -1
- package/build/serialize.js +12 -7
- package/build/serialize.js.map +1 -1
- package/build-module/raw-html.js +19 -10
- package/build-module/raw-html.js.map +1 -1
- package/build-module/react-platform.native.js +6 -38
- package/build-module/react-platform.native.js.map +1 -1
- package/build-module/react.js +6 -2
- package/build-module/react.js.map +1 -1
- package/build-module/serialize.js +9 -4
- package/build-module/serialize.js.map +1 -1
- package/build-types/raw-html.d.ts +3 -2
- package/build-types/raw-html.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/raw-html.js +16 -6
- package/src/react-platform.native.js +6 -42
- package/src/react.js +1 -1
- package/src/test/platform.native.js +4 -8
- package/src/test/raw-html.js +46 -11
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 4.1.0 (2022-01-27)
|
|
6
|
+
|
|
7
|
+
### Bug Fix
|
|
8
|
+
|
|
9
|
+
- Ensure that the package uses the latest version of React types ([#37365](https://github.com/WordPress/gutenberg/pull/37365)).
|
|
10
|
+
|
|
11
|
+
## 4.0.3 (2021-10-22)
|
|
12
|
+
|
|
13
|
+
### Bug Fix
|
|
14
|
+
|
|
15
|
+
- Update `rawHtml` to correctly concatenate multiple strings passed as children (see [35532](https://github.com/WordPress/gutenberg/pull/35532))
|
|
16
|
+
|
|
5
17
|
## 4.0.0 (2021-07-29)
|
|
6
18
|
|
|
7
19
|
### Breaking Change
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -294,7 +294,7 @@ aside from `children` are passed.
|
|
|
294
294
|
|
|
295
295
|
_Parameters_
|
|
296
296
|
|
|
297
|
-
- _props_ `RawHTMLProps`: Children should be a string of HTML. Other props will be passed through to div wrapper.
|
|
297
|
+
- _props_ `RawHTMLProps`: Children should be a string of HTML or an array of strings. Other props will be passed through to the div wrapper.
|
|
298
298
|
|
|
299
299
|
_Returns_
|
|
300
300
|
|
package/build/index.js
CHANGED
|
@@ -11,28 +11,28 @@ var _exportNames = {
|
|
|
11
11
|
renderToString: true,
|
|
12
12
|
RawHTML: true
|
|
13
13
|
};
|
|
14
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "Platform", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function () {
|
|
17
|
-
return
|
|
17
|
+
return _platform.default;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
Object.defineProperty(exports, "
|
|
20
|
+
Object.defineProperty(exports, "RawHTML", {
|
|
21
21
|
enumerable: true,
|
|
22
22
|
get: function () {
|
|
23
|
-
return
|
|
23
|
+
return _rawHtml.default;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
Object.defineProperty(exports, "
|
|
26
|
+
Object.defineProperty(exports, "createInterpolateElement", {
|
|
27
27
|
enumerable: true,
|
|
28
28
|
get: function () {
|
|
29
|
-
return
|
|
29
|
+
return _createInterpolateElement.default;
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
Object.defineProperty(exports, "
|
|
32
|
+
Object.defineProperty(exports, "renderToString", {
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function () {
|
|
35
|
-
return
|
|
35
|
+
return _serialize.default;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
|
package/build/raw-html.js
CHANGED
|
@@ -20,20 +20,30 @@ var _react = require("./react");
|
|
|
20
20
|
* To preserve additional props, a `div` wrapper _will_ be created if any props
|
|
21
21
|
* aside from `children` are passed.
|
|
22
22
|
*
|
|
23
|
-
* @param {RawHTMLProps} props Children should be a string of HTML
|
|
24
|
-
* will be passed through
|
|
23
|
+
* @param {RawHTMLProps} props Children should be a string of HTML or an array
|
|
24
|
+
* of strings. Other props will be passed through
|
|
25
|
+
* to the div wrapper.
|
|
25
26
|
*
|
|
26
27
|
* @return {JSX.Element} Dangerously-rendering component.
|
|
27
28
|
*/
|
|
28
|
-
function RawHTML({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
29
|
+
function RawHTML(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
children,
|
|
32
|
+
...props
|
|
33
|
+
} = _ref;
|
|
34
|
+
let rawHtml = ''; // Cast children as an array, and concatenate each element if it is a string.
|
|
35
|
+
|
|
36
|
+
_react.Children.toArray(children).forEach(child => {
|
|
37
|
+
if (typeof child === 'string' && child.trim() !== '') {
|
|
38
|
+
rawHtml += child;
|
|
39
|
+
}
|
|
40
|
+
}); // The `div` wrapper will be stripped by the `renderElement` serializer in
|
|
41
|
+
// `./serialize.js` unless there are non-children props present.
|
|
42
|
+
|
|
43
|
+
|
|
34
44
|
return (0, _react.createElement)('div', {
|
|
35
45
|
dangerouslySetInnerHTML: {
|
|
36
|
-
__html:
|
|
46
|
+
__html: rawHtml
|
|
37
47
|
},
|
|
38
48
|
...props
|
|
39
49
|
});
|
package/build/raw-html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/raw-html.js"],"names":["RawHTML","children","props","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,OAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/raw-html.js"],"names":["RawHTML","children","props","rawHtml","Children","toArray","forEach","child","trim","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,OAAT,OAA2C;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAAyB;AACzD,MAAIC,OAAO,GAAG,EAAd,CADyD,CAGzD;;AACAC,kBAASC,OAAT,CAAkBJ,QAAlB,EAA6BK,OAA7B,CAAwCC,KAAF,IAAa;AAClD,QAAK,OAAOA,KAAP,KAAiB,QAAjB,IAA6BA,KAAK,CAACC,IAAN,OAAiB,EAAnD,EAAwD;AACvDL,MAAAA,OAAO,IAAII,KAAX;AACA;AACD,GAJD,EAJyD,CAUzD;AACA;;;AACA,SAAO,0BAAe,KAAf,EAAsB;AAC5BE,IAAAA,uBAAuB,EAAE;AAAEC,MAAAA,MAAM,EAAEP;AAAV,KADG;AAE5B,OAAGD;AAFyB,GAAtB,CAAP;AAIA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { Children, createElement } from './react';\n\n// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly.\n/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */\n\n/**\n * Component used as equivalent of Fragment with unescaped HTML, in cases where\n * it is desirable to render dangerous HTML without needing a wrapper element.\n * To preserve additional props, a `div` wrapper _will_ be created if any props\n * aside from `children` are passed.\n *\n * @param {RawHTMLProps} props Children should be a string of HTML or an array\n * of strings. Other props will be passed through\n * to the div wrapper.\n *\n * @return {JSX.Element} Dangerously-rendering component.\n */\nexport default function RawHTML( { children, ...props } ) {\n\tlet rawHtml = '';\n\n\t// Cast children as an array, and concatenate each element if it is a string.\n\tChildren.toArray( children ).forEach( ( child ) => {\n\t\tif ( typeof child === 'string' && child.trim() !== '' ) {\n\t\t\trawHtml += child;\n\t\t}\n\t} );\n\n\t// The `div` wrapper will be stripped by the `renderElement` serializer in\n\t// `./serialize.js` unless there are non-children props present.\n\treturn createElement( 'div', {\n\t\tdangerouslySetInnerHTML: { __html: rawHtml },\n\t\t...props,\n\t} );\n}\n"]}
|
|
@@ -3,55 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.registerComponent = void 0;
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
|
-
var _hooks = require("@wordpress/hooks");
|
|
13
|
-
|
|
14
|
-
var _react = require("./react");
|
|
15
|
-
|
|
16
10
|
/**
|
|
17
11
|
* External dependencies
|
|
18
12
|
*/
|
|
19
13
|
|
|
20
14
|
/**
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
const render = (element, id) => {
|
|
28
|
-
class App extends _react.Component {
|
|
29
|
-
constructor() {
|
|
30
|
-
super(...arguments);
|
|
31
|
-
const parentProps = (0, _lodash.omit)(this.props || {}, ['rootTag']);
|
|
32
|
-
(0, _hooks.doAction)('native.pre-render', parentProps);
|
|
33
|
-
this.filteredProps = (0, _hooks.applyFilters)('native.block_editor_props', parentProps);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
componentDidMount() {
|
|
37
|
-
(0, _hooks.doAction)('native.render', this.filteredProps);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
render() {
|
|
41
|
-
return (0, _react.cloneElement)(element, this.filteredProps);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
_reactNative.AppRegistry.registerComponent(id, () => App);
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Render a given element on Native.
|
|
50
|
-
* This actually returns a componentProvider that can be registered with `AppRegistry.registerComponent`
|
|
15
|
+
* Registers an app root component allowing the native system to run the app.
|
|
51
16
|
*
|
|
52
|
-
* @param {
|
|
17
|
+
* @param {string} appKey Unique app name identifier.
|
|
18
|
+
* @param {Function} componentProvider Function returning the app root React component.
|
|
53
19
|
*/
|
|
20
|
+
const registerComponent = (appKey, componentProvider) => {
|
|
21
|
+
_reactNative.AppRegistry.registerComponent(appKey, componentProvider);
|
|
22
|
+
};
|
|
54
23
|
|
|
55
|
-
|
|
56
|
-
exports.render = render;
|
|
24
|
+
exports.registerComponent = registerComponent;
|
|
57
25
|
//# sourceMappingURL=react-platform.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/react-platform.native.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/react-platform.native.js"],"names":["registerComponent","appKey","componentProvider","AppRegistry"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,GAAG,CAAEC,MAAF,EAAUC,iBAAV,KAAiC;AACjEC,2BAAYH,iBAAZ,CAA+BC,MAA/B,EAAuCC,iBAAvC;AACA,CAFM","sourcesContent":["/**\n * External dependencies\n */\nimport { AppRegistry } from 'react-native';\n\n/**\n * Registers an app root component allowing the native system to run the app.\n *\n * @param {string} appKey Unique app name identifier.\n * @param {Function} componentProvider Function returning the app root React component.\n */\nexport const registerComponent = ( appKey, componentProvider ) => {\n\tAppRegistry.registerComponent( appKey, componentProvider );\n};\n"]}
|
package/build/react.js
CHANGED
|
@@ -3,114 +3,108 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.concatChildren = concatChildren;
|
|
7
|
-
exports.switchChildrenNodeName = switchChildrenNodeName;
|
|
8
6
|
Object.defineProperty(exports, "Children", {
|
|
9
7
|
enumerable: true,
|
|
10
8
|
get: function () {
|
|
11
9
|
return _react.Children;
|
|
12
10
|
}
|
|
13
11
|
});
|
|
14
|
-
Object.defineProperty(exports, "cloneElement", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return _react.cloneElement;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
12
|
Object.defineProperty(exports, "Component", {
|
|
21
13
|
enumerable: true,
|
|
22
14
|
get: function () {
|
|
23
15
|
return _react.Component;
|
|
24
16
|
}
|
|
25
17
|
});
|
|
26
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "Fragment", {
|
|
27
19
|
enumerable: true,
|
|
28
20
|
get: function () {
|
|
29
|
-
return _react.
|
|
21
|
+
return _react.Fragment;
|
|
30
22
|
}
|
|
31
23
|
});
|
|
32
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "StrictMode", {
|
|
33
25
|
enumerable: true,
|
|
34
26
|
get: function () {
|
|
35
|
-
return _react.
|
|
27
|
+
return _react.StrictMode;
|
|
36
28
|
}
|
|
37
29
|
});
|
|
38
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "Suspense", {
|
|
39
31
|
enumerable: true,
|
|
40
32
|
get: function () {
|
|
41
|
-
return _react.
|
|
33
|
+
return _react.Suspense;
|
|
42
34
|
}
|
|
43
35
|
});
|
|
44
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "cloneElement", {
|
|
45
37
|
enumerable: true,
|
|
46
38
|
get: function () {
|
|
47
|
-
return _react.
|
|
39
|
+
return _react.cloneElement;
|
|
48
40
|
}
|
|
49
41
|
});
|
|
50
|
-
|
|
42
|
+
exports.concatChildren = concatChildren;
|
|
43
|
+
Object.defineProperty(exports, "createContext", {
|
|
51
44
|
enumerable: true,
|
|
52
45
|
get: function () {
|
|
53
|
-
return _react.
|
|
46
|
+
return _react.createContext;
|
|
54
47
|
}
|
|
55
48
|
});
|
|
56
|
-
Object.defineProperty(exports, "
|
|
49
|
+
Object.defineProperty(exports, "createElement", {
|
|
57
50
|
enumerable: true,
|
|
58
51
|
get: function () {
|
|
59
|
-
return _react.
|
|
52
|
+
return _react.createElement;
|
|
60
53
|
}
|
|
61
54
|
});
|
|
62
|
-
Object.defineProperty(exports, "
|
|
55
|
+
Object.defineProperty(exports, "createRef", {
|
|
63
56
|
enumerable: true,
|
|
64
57
|
get: function () {
|
|
65
|
-
return _react.
|
|
58
|
+
return _react.createRef;
|
|
66
59
|
}
|
|
67
60
|
});
|
|
68
|
-
Object.defineProperty(exports, "
|
|
61
|
+
Object.defineProperty(exports, "forwardRef", {
|
|
69
62
|
enumerable: true,
|
|
70
63
|
get: function () {
|
|
71
|
-
return _react.
|
|
64
|
+
return _react.forwardRef;
|
|
72
65
|
}
|
|
73
66
|
});
|
|
74
|
-
Object.defineProperty(exports, "
|
|
67
|
+
Object.defineProperty(exports, "isValidElement", {
|
|
75
68
|
enumerable: true,
|
|
76
69
|
get: function () {
|
|
77
|
-
return _react.
|
|
70
|
+
return _react.isValidElement;
|
|
78
71
|
}
|
|
79
72
|
});
|
|
80
|
-
Object.defineProperty(exports, "
|
|
73
|
+
Object.defineProperty(exports, "lazy", {
|
|
81
74
|
enumerable: true,
|
|
82
75
|
get: function () {
|
|
83
|
-
return _react.
|
|
76
|
+
return _react.lazy;
|
|
84
77
|
}
|
|
85
78
|
});
|
|
86
|
-
Object.defineProperty(exports, "
|
|
79
|
+
Object.defineProperty(exports, "memo", {
|
|
87
80
|
enumerable: true,
|
|
88
81
|
get: function () {
|
|
89
|
-
return _react.
|
|
82
|
+
return _react.memo;
|
|
90
83
|
}
|
|
91
84
|
});
|
|
92
|
-
|
|
85
|
+
exports.switchChildrenNodeName = switchChildrenNodeName;
|
|
86
|
+
Object.defineProperty(exports, "useCallback", {
|
|
93
87
|
enumerable: true,
|
|
94
88
|
get: function () {
|
|
95
|
-
return _react.
|
|
89
|
+
return _react.useCallback;
|
|
96
90
|
}
|
|
97
91
|
});
|
|
98
|
-
Object.defineProperty(exports, "
|
|
92
|
+
Object.defineProperty(exports, "useContext", {
|
|
99
93
|
enumerable: true,
|
|
100
94
|
get: function () {
|
|
101
|
-
return _react.
|
|
95
|
+
return _react.useContext;
|
|
102
96
|
}
|
|
103
97
|
});
|
|
104
|
-
Object.defineProperty(exports, "
|
|
98
|
+
Object.defineProperty(exports, "useDebugValue", {
|
|
105
99
|
enumerable: true,
|
|
106
100
|
get: function () {
|
|
107
|
-
return _react.
|
|
101
|
+
return _react.useDebugValue;
|
|
108
102
|
}
|
|
109
103
|
});
|
|
110
|
-
Object.defineProperty(exports, "
|
|
104
|
+
Object.defineProperty(exports, "useEffect", {
|
|
111
105
|
enumerable: true,
|
|
112
106
|
get: function () {
|
|
113
|
-
return _react.
|
|
107
|
+
return _react.useEffect;
|
|
114
108
|
}
|
|
115
109
|
});
|
|
116
110
|
Object.defineProperty(exports, "useImperativeHandle", {
|
|
@@ -125,22 +119,28 @@ Object.defineProperty(exports, "useLayoutEffect", {
|
|
|
125
119
|
return _react.useLayoutEffect;
|
|
126
120
|
}
|
|
127
121
|
});
|
|
128
|
-
Object.defineProperty(exports, "
|
|
122
|
+
Object.defineProperty(exports, "useMemo", {
|
|
129
123
|
enumerable: true,
|
|
130
124
|
get: function () {
|
|
131
|
-
return _react.
|
|
125
|
+
return _react.useMemo;
|
|
132
126
|
}
|
|
133
127
|
});
|
|
134
|
-
Object.defineProperty(exports, "
|
|
128
|
+
Object.defineProperty(exports, "useReducer", {
|
|
135
129
|
enumerable: true,
|
|
136
130
|
get: function () {
|
|
137
|
-
return _react.
|
|
131
|
+
return _react.useReducer;
|
|
138
132
|
}
|
|
139
133
|
});
|
|
140
|
-
Object.defineProperty(exports, "
|
|
134
|
+
Object.defineProperty(exports, "useRef", {
|
|
141
135
|
enumerable: true,
|
|
142
136
|
get: function () {
|
|
143
|
-
return _react.
|
|
137
|
+
return _react.useRef;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "useState", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function () {
|
|
143
|
+
return _react.useState;
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
|
|
@@ -151,7 +151,7 @@ var _lodash = require("lodash");
|
|
|
151
151
|
/**
|
|
152
152
|
* External dependencies
|
|
153
153
|
*/
|
|
154
|
-
// eslint-disable-next-line no-restricted-imports
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Object containing a React element.
|
|
@@ -304,7 +304,11 @@ var _lodash = require("lodash");
|
|
|
304
304
|
*
|
|
305
305
|
* @return {Array} The concatenated value.
|
|
306
306
|
*/
|
|
307
|
-
function concatChildren(
|
|
307
|
+
function concatChildren() {
|
|
308
|
+
for (var _len = arguments.length, childrenArguments = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
309
|
+
childrenArguments[_key] = arguments[_key];
|
|
310
|
+
}
|
|
311
|
+
|
|
308
312
|
return childrenArguments.reduce((accumulator, children, i) => {
|
|
309
313
|
_react.Children.forEach(children, (child, j) => {
|
|
310
314
|
if (child && 'string' !== typeof child) {
|
package/build/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/react.js"],"names":["concatChildren","childrenArguments","reduce","accumulator","children","i","Children","forEach","child","j","key","join","push","switchChildrenNodeName","nodeName","map","elt","index","childrenProp","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAyBA;;AA7BA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/react.js"],"names":["concatChildren","childrenArguments","reduce","accumulator","children","i","Children","forEach","child","j","key","join","push","switchChildrenNodeName","nodeName","map","elt","index","childrenProp","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAyBA;;AA7BA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,GAAgD;AAAA,oCAApBC,iBAAoB;AAApBA,IAAAA,iBAAoB;AAAA;;AACtD,SAAOA,iBAAiB,CAACC,MAAlB,CAA0B,CAAEC,WAAF,EAAeC,QAAf,EAAyBC,CAAzB,KAAgC;AAChEC,oBAASC,OAAT,CAAkBH,QAAlB,EAA4B,CAAEI,KAAF,EAASC,CAAT,KAAgB;AAC3C,UAAKD,KAAK,IAAI,aAAa,OAAOA,KAAlC,EAA0C;AACzCA,QAAAA,KAAK,GAAG,yBAAcA,KAAd,EAAqB;AAC5BE,UAAAA,GAAG,EAAE,CAAEL,CAAF,EAAKI,CAAL,EAASE,IAAT;AADuB,SAArB,CAAR;AAGA;;AAEDR,MAAAA,WAAW,CAACS,IAAZ,CAAkBJ,KAAlB;AACA,KARD;;AAUA,WAAOL,WAAP;AACA,GAZM,EAYJ,EAZI,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASU,sBAAT,CAAiCT,QAAjC,EAA2CU,QAA3C,EAAsD;AAC5D,SACCV,QAAQ,IACRE,gBAASS,GAAT,CAAcX,QAAd,EAAwB,CAAEY,GAAF,EAAOC,KAAP,KAAkB;AACzC,QAAK,sBAAUD,GAAV,CAAL,EAAuB;AACtB,aAAO,0BAAeF,QAAf,EAAyB;AAAEJ,QAAAA,GAAG,EAAEO;AAAP,OAAzB,EAAyCD,GAAzC,CAAP;AACA;;AACD,UAAM;AAAEZ,MAAAA,QAAQ,EAAEc,YAAZ;AAA0B,SAAGC;AAA7B,QAAuCH,GAAG,CAACG,KAAjD;AACA,WAAO,0BACNL,QADM,EAEN;AAAEJ,MAAAA,GAAG,EAAEO,KAAP;AAAc,SAAGE;AAAjB,KAFM,EAGND,YAHM,CAAP;AAKA,GAVD,CAFD;AAcA","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport {\n\tChildren,\n\tcloneElement,\n\tComponent,\n\tcreateContext,\n\tcreateElement,\n\tcreateRef,\n\tforwardRef,\n\tFragment,\n\tisValidElement,\n\tmemo,\n\tStrictMode,\n\tuseState,\n\tuseEffect,\n\tuseContext,\n\tuseReducer,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseImperativeHandle,\n\tuseLayoutEffect,\n\tuseDebugValue,\n\tlazy,\n\tSuspense,\n} from 'react';\nimport { isString } from 'lodash';\n\n/**\n * Object containing a React element.\n *\n * @typedef {import('react').ReactElement} WPElement\n */\n\n/**\n * Object containing a React component.\n *\n * @typedef {import('react').ComponentType} WPComponent\n */\n\n/**\n * Object containing a React synthetic event.\n *\n * @typedef {import('react').SyntheticEvent} WPSyntheticEvent\n */\n\n/**\n * Object that provides utilities for dealing with React children.\n */\nexport { Children };\n\n/**\n * Creates a copy of an element with extended props.\n *\n * @param {WPElement} element Element\n * @param {?Object} props Props to apply to cloned element\n *\n * @return {WPElement} Cloned element.\n */\nexport { cloneElement };\n\n/**\n * A base class to create WordPress Components (Refs, state and lifecycle hooks)\n */\nexport { Component };\n\n/**\n * Creates a context object containing two components: a provider and consumer.\n *\n * @param {Object} defaultValue A default data stored in the context.\n *\n * @return {Object} Context object.\n */\nexport { createContext };\n\n/**\n * Returns a new element of given type. Type can be either a string tag name or\n * another function which itself returns an element.\n *\n * @param {?(string|Function)} type Tag name or element creator\n * @param {Object} props Element properties, either attribute\n * set to apply to DOM node or values to\n * pass through to element creator\n * @param {...WPElement} children Descendant elements\n *\n * @return {WPElement} Element.\n */\nexport { createElement };\n\n/**\n * Returns an object tracking a reference to a rendered element via its\n * `current` property as either a DOMElement or Element, dependent upon the\n * type of element rendered with the ref attribute.\n *\n * @return {Object} Ref object.\n */\nexport { createRef };\n\n/**\n * Component enhancer used to enable passing a ref to its wrapped component.\n * Pass a function argument which receives `props` and `ref` as its arguments,\n * returning an element using the forwarded ref. The return value is a new\n * component which forwards its ref.\n *\n * @param {Function} forwarder Function passed `props` and `ref`, expected to\n * return an element.\n *\n * @return {WPComponent} Enhanced component.\n */\nexport { forwardRef };\n\n/**\n * A component which renders its children without any wrapping element.\n */\nexport { Fragment };\n\n/**\n * Checks if an object is a valid WPElement.\n *\n * @param {Object} objectToCheck The object to be checked.\n *\n * @return {boolean} true if objectToTest is a valid WPElement and false otherwise.\n */\nexport { isValidElement };\n\n/**\n * @see https://reactjs.org/docs/react-api.html#reactmemo\n */\nexport { memo };\n\n/**\n * Component that activates additional checks and warnings for its descendants.\n */\nexport { StrictMode };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#usecallback\n */\nexport { useCallback };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#usecontext\n */\nexport { useContext };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#usedebugvalue\n */\nexport { useDebugValue };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#useeffect\n */\nexport { useEffect };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#useimperativehandle\n */\nexport { useImperativeHandle };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#uselayouteffect\n */\nexport { useLayoutEffect };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#usememo\n */\nexport { useMemo };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#usereducer\n */\nexport { useReducer };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#useref\n */\nexport { useRef };\n\n/**\n * @see https://reactjs.org/docs/hooks-reference.html#usestate\n */\nexport { useState };\n\n/**\n * @see https://reactjs.org/docs/react-api.html#reactlazy\n */\nexport { lazy };\n\n/**\n * @see https://reactjs.org/docs/react-api.html#reactsuspense\n */\nexport { Suspense };\n\n/**\n * Concatenate two or more React children objects.\n *\n * @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.\n *\n * @return {Array} The concatenated value.\n */\nexport function concatChildren( ...childrenArguments ) {\n\treturn childrenArguments.reduce( ( accumulator, children, i ) => {\n\t\tChildren.forEach( children, ( child, j ) => {\n\t\t\tif ( child && 'string' !== typeof child ) {\n\t\t\t\tchild = cloneElement( child, {\n\t\t\t\t\tkey: [ i, j ].join(),\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\taccumulator.push( child );\n\t\t} );\n\n\t\treturn accumulator;\n\t}, [] );\n}\n\n/**\n * Switches the nodeName of all the elements in the children object.\n *\n * @param {?Object} children Children object.\n * @param {string} nodeName Node name.\n *\n * @return {?Object} The updated children object.\n */\nexport function switchChildrenNodeName( children, nodeName ) {\n\treturn (\n\t\tchildren &&\n\t\tChildren.map( children, ( elt, index ) => {\n\t\t\tif ( isString( elt ) ) {\n\t\t\t\treturn createElement( nodeName, { key: index }, elt );\n\t\t\t}\n\t\t\tconst { children: childrenProp, ...props } = elt.props;\n\t\t\treturn createElement(\n\t\t\t\tnodeName,\n\t\t\t\t{ key: index, ...props },\n\t\t\t\tchildrenProp\n\t\t\t);\n\t\t} )\n\t);\n}\n"]}
|
package/build/serialize.js
CHANGED
|
@@ -5,13 +5,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.default = void 0;
|
|
8
9
|
exports.hasPrefix = hasPrefix;
|
|
10
|
+
exports.renderAttributes = renderAttributes;
|
|
11
|
+
exports.renderComponent = renderComponent;
|
|
9
12
|
exports.renderElement = renderElement;
|
|
10
13
|
exports.renderNativeComponent = renderNativeComponent;
|
|
11
|
-
exports.renderComponent = renderComponent;
|
|
12
|
-
exports.renderAttributes = renderAttributes;
|
|
13
14
|
exports.renderStyle = renderStyle;
|
|
14
|
-
exports.default = void 0;
|
|
15
15
|
|
|
16
16
|
var _lodash = require("lodash");
|
|
17
17
|
|
|
@@ -258,7 +258,9 @@ function getNormalStylePropertyValue(property, value) {
|
|
|
258
258
|
*/
|
|
259
259
|
|
|
260
260
|
|
|
261
|
-
function renderElement(element, context
|
|
261
|
+
function renderElement(element, context) {
|
|
262
|
+
let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
263
|
+
|
|
262
264
|
if (null === element || undefined === element || false === element) {
|
|
263
265
|
return '';
|
|
264
266
|
}
|
|
@@ -337,7 +339,8 @@ function renderElement(element, context, legacyContext = {}) {
|
|
|
337
339
|
*/
|
|
338
340
|
|
|
339
341
|
|
|
340
|
-
function renderNativeComponent(type, props, context
|
|
342
|
+
function renderNativeComponent(type, props, context) {
|
|
343
|
+
let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
341
344
|
let content = '';
|
|
342
345
|
|
|
343
346
|
if (type === 'textarea' && props.hasOwnProperty('value')) {
|
|
@@ -379,7 +382,8 @@ function renderNativeComponent(type, props, context, legacyContext = {}) {
|
|
|
379
382
|
*/
|
|
380
383
|
|
|
381
384
|
|
|
382
|
-
function renderComponent(Component, props, context
|
|
385
|
+
function renderComponent(Component, props, context) {
|
|
386
|
+
let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
383
387
|
const instance = new
|
|
384
388
|
/** @type {import('react').ComponentClass} */
|
|
385
389
|
Component(props, legacyContext);
|
|
@@ -408,7 +412,8 @@ function renderComponent(Component, props, context, legacyContext = {}) {
|
|
|
408
412
|
*/
|
|
409
413
|
|
|
410
414
|
|
|
411
|
-
function renderChildren(children, context
|
|
415
|
+
function renderChildren(children, context) {
|
|
416
|
+
let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
412
417
|
let result = '';
|
|
413
418
|
children = (0, _lodash.castArray)(children);
|
|
414
419
|
|