@wordpress/element 6.32.0 → 6.32.1-next.b8c8708f3.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.
Files changed (45) hide show
  1. package/build/create-interpolate-element.js +79 -183
  2. package/build/create-interpolate-element.js.map +7 -1
  3. package/build/index.js +52 -74
  4. package/build/index.js.map +7 -1
  5. package/build/platform.android.js +29 -16
  6. package/build/platform.android.js.map +7 -1
  7. package/build/platform.ios.js +29 -16
  8. package/build/platform.ios.js.map +7 -1
  9. package/build/platform.js +25 -40
  10. package/build/platform.js.map +7 -1
  11. package/build/raw-html.js +28 -47
  12. package/build/raw-html.js.map +7 -1
  13. package/build/react-platform.js +43 -55
  14. package/build/react-platform.js.map +7 -1
  15. package/build/react.js +114 -411
  16. package/build/react.js.map +7 -1
  17. package/build/serialize.js +418 -325
  18. package/build/serialize.js.map +7 -1
  19. package/build/utils.js +29 -15
  20. package/build/utils.js.map +7 -1
  21. package/build-module/create-interpolate-element.js +63 -175
  22. package/build-module/create-interpolate-element.js.map +7 -1
  23. package/build-module/index.js +14 -8
  24. package/build-module/index.js.map +7 -1
  25. package/build-module/platform.android.js +10 -10
  26. package/build-module/platform.android.js.map +7 -1
  27. package/build-module/platform.ios.js +10 -10
  28. package/build-module/platform.ios.js.map +7 -1
  29. package/build-module/platform.js +7 -36
  30. package/build-module/platform.js.map +7 -1
  31. package/build-module/raw-html.js +11 -44
  32. package/build-module/raw-html.js.map +7 -1
  33. package/build-module/react-platform.js +20 -71
  34. package/build-module/react-platform.js.map +7 -1
  35. package/build-module/react.js +91 -255
  36. package/build-module/react.js.map +7 -1
  37. package/build-module/serialize.js +382 -311
  38. package/build-module/serialize.js.map +7 -1
  39. package/build-module/utils.js +7 -10
  40. package/build-module/utils.js.map +7 -1
  41. package/package.json +11 -4
  42. package/build/react-platform.native.js +0 -22
  43. package/build/react-platform.native.js.map +0 -1
  44. package/build-module/react-platform.native.js +0 -15
  45. package/build-module/react-platform.native.js.map +0 -1
@@ -1,335 +1,456 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var serialize_exports = {};
30
+ __export(serialize_exports, {
31
+ default: () => serialize_default,
32
+ hasPrefix: () => hasPrefix,
33
+ renderAttributes: () => renderAttributes,
34
+ renderComponent: () => renderComponent,
35
+ renderElement: () => renderElement,
36
+ renderNativeComponent: () => renderNativeComponent,
37
+ renderStyle: () => renderStyle
6
38
  });
7
- exports.default = void 0;
8
- exports.hasPrefix = hasPrefix;
9
- exports.renderAttributes = renderAttributes;
10
- exports.renderComponent = renderComponent;
11
- exports.renderElement = renderElement;
12
- exports.renderNativeComponent = renderNativeComponent;
13
- exports.renderStyle = renderStyle;
14
- var _isPlainObject = require("is-plain-object");
15
- var _changeCase = require("change-case");
16
- var _escapeHtml = require("@wordpress/escape-html");
17
- var _react = require("./react");
18
- var _rawHtml = _interopRequireDefault(require("./raw-html"));
19
- /**
20
- * Parts of this source were derived and modified from fast-react-render,
21
- * released under the MIT license.
22
- *
23
- * https://github.com/alt-j/fast-react-render
24
- *
25
- * Copyright (c) 2016 Andrey Morozov
26
- *
27
- * Permission is hereby granted, free of charge, to any person obtaining a copy
28
- * of this software and associated documentation files (the "Software"), to deal
29
- * in the Software without restriction, including without limitation the rights
30
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
- * copies of the Software, and to permit persons to whom the Software is
32
- * furnished to do so, subject to the following conditions:
33
- *
34
- * The above copyright notice and this permission notice shall be included in
35
- * all copies or substantial portions of the Software.
36
- *
37
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
43
- * THE SOFTWARE.
44
- */
45
-
46
- /**
47
- * External dependencies
48
- */
49
-
50
- /**
51
- * WordPress dependencies
52
- */
53
-
54
- /**
55
- * Internal dependencies
56
- */
57
-
58
- /** @typedef {import('react').ReactElement} ReactElement */
59
-
60
- const Context = (0, _react.createContext)(undefined);
61
- Context.displayName = 'ElementContext';
62
- const {
63
- Provider,
64
- Consumer
65
- } = Context;
66
- const ForwardRef = (0, _react.forwardRef)(() => {
39
+ module.exports = __toCommonJS(serialize_exports);
40
+ var import_is_plain_object = require("is-plain-object");
41
+ var import_change_case = require("change-case");
42
+ var import_escape_html = require("@wordpress/escape-html");
43
+ var import_react = require("./react");
44
+ var import_raw_html = __toESM(require("./raw-html"));
45
+ const Context = (0, import_react.createContext)(void 0);
46
+ Context.displayName = "ElementContext";
47
+ const { Provider, Consumer } = Context;
48
+ const ForwardRef = (0, import_react.forwardRef)(() => {
67
49
  return null;
68
50
  });
69
-
70
- /**
71
- * Valid attribute types.
72
- */
73
- const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
74
-
75
- /**
76
- * Element tags which can be self-closing.
77
- */
78
- const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
79
-
80
- /**
81
- * Boolean attributes are attributes whose presence as being assigned is
82
- * meaningful, even if only empty.
83
- *
84
- * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
85
- * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
86
- *
87
- * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
88
- * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
89
- * .reduce( ( result, tr ) => Object.assign( result, {
90
- * [ tr.firstChild.textContent.trim() ]: true
91
- * } ), {} ) ).sort();
92
- */
93
- const BOOLEAN_ATTRIBUTES = new Set(['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']);
94
-
95
- /**
96
- * Enumerated attributes are attributes which must be of a specific value form.
97
- * Like boolean attributes, these are meaningful if specified, even if not of a
98
- * valid enumerated value.
99
- *
100
- * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
101
- * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
102
- *
103
- * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
104
- * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
105
- * .reduce( ( result, tr ) => Object.assign( result, {
106
- * [ tr.firstChild.textContent.trim() ]: true
107
- * } ), {} ) ).sort();
108
- *
109
- * Some notable omissions:
110
- *
111
- * - `alt`: https://blog.whatwg.org/omit-alt
112
- */
113
- const ENUMERATED_ATTRIBUTES = new Set(['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']);
114
-
115
- /**
116
- * Set of CSS style properties which support assignment of unitless numbers.
117
- * Used in rendering of style properties, where `px` unit is assumed unless
118
- * property is included in this set or value is zero.
119
- *
120
- * Generated via:
121
- *
122
- * Object.entries( document.createElement( 'div' ).style )
123
- * .filter( ( [ key ] ) => (
124
- * ! /^(webkit|ms|moz)/.test( key ) &&
125
- * ( e.style[ key ] = 10 ) &&
126
- * e.style[ key ] === '10'
127
- * ) )
128
- * .map( ( [ key ] ) => key )
129
- * .sort();
130
- */
131
- const CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set(['animation', 'animationIterationCount', 'baselineShift', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'columnCount', 'cx', 'cy', 'fillOpacity', 'flexGrow', 'flexShrink', 'floodOpacity', 'fontWeight', 'gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart', 'lineHeight', 'opacity', 'order', 'orphans', 'r', 'rx', 'ry', 'shapeImageThreshold', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'tabSize', 'widows', 'x', 'y', 'zIndex', 'zoom']);
132
-
133
- /**
134
- * Returns true if the specified string is prefixed by one of an array of
135
- * possible prefixes.
136
- * @param string
137
- * @param prefixes
138
- */
51
+ const ATTRIBUTES_TYPES = /* @__PURE__ */ new Set(["string", "boolean", "number"]);
52
+ const SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
53
+ "area",
54
+ "base",
55
+ "br",
56
+ "col",
57
+ "command",
58
+ "embed",
59
+ "hr",
60
+ "img",
61
+ "input",
62
+ "keygen",
63
+ "link",
64
+ "meta",
65
+ "param",
66
+ "source",
67
+ "track",
68
+ "wbr"
69
+ ]);
70
+ const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
71
+ "allowfullscreen",
72
+ "allowpaymentrequest",
73
+ "allowusermedia",
74
+ "async",
75
+ "autofocus",
76
+ "autoplay",
77
+ "checked",
78
+ "controls",
79
+ "default",
80
+ "defer",
81
+ "disabled",
82
+ "download",
83
+ "formnovalidate",
84
+ "hidden",
85
+ "ismap",
86
+ "itemscope",
87
+ "loop",
88
+ "multiple",
89
+ "muted",
90
+ "nomodule",
91
+ "novalidate",
92
+ "open",
93
+ "playsinline",
94
+ "readonly",
95
+ "required",
96
+ "reversed",
97
+ "selected",
98
+ "typemustmatch"
99
+ ]);
100
+ const ENUMERATED_ATTRIBUTES = /* @__PURE__ */ new Set([
101
+ "autocapitalize",
102
+ "autocomplete",
103
+ "charset",
104
+ "contenteditable",
105
+ "crossorigin",
106
+ "decoding",
107
+ "dir",
108
+ "draggable",
109
+ "enctype",
110
+ "formenctype",
111
+ "formmethod",
112
+ "http-equiv",
113
+ "inputmode",
114
+ "kind",
115
+ "method",
116
+ "preload",
117
+ "scope",
118
+ "shape",
119
+ "spellcheck",
120
+ "translate",
121
+ "type",
122
+ "wrap"
123
+ ]);
124
+ const CSS_PROPERTIES_SUPPORTS_UNITLESS = /* @__PURE__ */ new Set([
125
+ "animation",
126
+ "animationIterationCount",
127
+ "baselineShift",
128
+ "borderImageOutset",
129
+ "borderImageSlice",
130
+ "borderImageWidth",
131
+ "columnCount",
132
+ "cx",
133
+ "cy",
134
+ "fillOpacity",
135
+ "flexGrow",
136
+ "flexShrink",
137
+ "floodOpacity",
138
+ "fontWeight",
139
+ "gridColumnEnd",
140
+ "gridColumnStart",
141
+ "gridRowEnd",
142
+ "gridRowStart",
143
+ "lineHeight",
144
+ "opacity",
145
+ "order",
146
+ "orphans",
147
+ "r",
148
+ "rx",
149
+ "ry",
150
+ "shapeImageThreshold",
151
+ "stopOpacity",
152
+ "strokeDasharray",
153
+ "strokeDashoffset",
154
+ "strokeMiterlimit",
155
+ "strokeOpacity",
156
+ "strokeWidth",
157
+ "tabSize",
158
+ "widows",
159
+ "x",
160
+ "y",
161
+ "zIndex",
162
+ "zoom"
163
+ ]);
139
164
  function hasPrefix(string, prefixes) {
140
- return prefixes.some(prefix => string.indexOf(prefix) === 0);
165
+ return prefixes.some((prefix) => string.indexOf(prefix) === 0);
141
166
  }
142
-
143
- /**
144
- * Returns true if the given prop name should be ignored in attributes
145
- * serialization, or false otherwise.
146
- * @param attribute
147
- */
148
167
  function isInternalAttribute(attribute) {
149
- return 'key' === attribute || 'children' === attribute;
168
+ return "key" === attribute || "children" === attribute;
150
169
  }
151
-
152
- /**
153
- * Returns the normal form of the element's attribute value for HTML.
154
- * @param attribute
155
- * @param value
156
- */
157
170
  function getNormalAttributeValue(attribute, value) {
158
171
  switch (attribute) {
159
- case 'style':
172
+ case "style":
160
173
  return renderStyle(value);
161
174
  }
162
175
  return value;
163
176
  }
164
-
165
- /**
166
- * This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
167
- * We need this to render e.g strokeWidth as stroke-width.
168
- *
169
- * List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
170
- */
171
- const SVG_ATTRIBUTE_WITH_DASHES_LIST = ['accentHeight', 'alignmentBaseline', 'arabicForm', 'baselineShift', 'capHeight', 'clipPath', 'clipRule', 'colorInterpolation', 'colorInterpolationFilters', 'colorProfile', 'colorRendering', 'dominantBaseline', 'enableBackground', 'fillOpacity', 'fillRule', 'floodColor', 'floodOpacity', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'glyphName', 'glyphOrientationHorizontal', 'glyphOrientationVertical', 'horizAdvX', 'horizOriginX', 'imageRendering', 'letterSpacing', 'lightingColor', 'markerEnd', 'markerMid', 'markerStart', 'overlinePosition', 'overlineThickness', 'paintOrder', 'panose1', 'pointerEvents', 'renderingIntent', 'shapeRendering', 'stopColor', 'stopOpacity', 'strikethroughPosition', 'strikethroughThickness', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'textAnchor', 'textDecoration', 'textRendering', 'underlinePosition', 'underlineThickness', 'unicodeBidi', 'unicodeRange', 'unitsPerEm', 'vAlphabetic', 'vHanging', 'vIdeographic', 'vMathematical', 'vectorEffect', 'vertAdvY', 'vertOriginX', 'vertOriginY', 'wordSpacing', 'writingMode', 'xmlnsXlink', 'xHeight'].reduce((map, attribute) => {
172
- // The keys are lower-cased for more robust lookup.
173
- map[attribute.toLowerCase()] = attribute;
174
- return map;
175
- }, {});
176
-
177
- /**
178
- * This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
179
- * The keys are lower-cased for more robust lookup.
180
- * Note that this list only contains attributes that contain at least one capital letter.
181
- * Lowercase attributes don't need mapping, since we lowercase all attributes by default.
182
- */
183
- const CASE_SENSITIVE_SVG_ATTRIBUTES = ['allowReorder', 'attributeName', 'attributeType', 'autoReverse', 'baseFrequency', 'baseProfile', 'calcMode', 'clipPathUnits', 'contentScriptType', 'contentStyleType', 'diffuseConstant', 'edgeMode', 'externalResourcesRequired', 'filterRes', 'filterUnits', 'glyphRef', 'gradientTransform', 'gradientUnits', 'kernelMatrix', 'kernelUnitLength', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'limitingConeAngle', 'markerHeight', 'markerUnits', 'markerWidth', 'maskContentUnits', 'maskUnits', 'numOctaves', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'refX', 'refY', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'specularConstant', 'specularExponent', 'spreadMethod', 'startOffset', 'stdDeviation', 'stitchTiles', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textLength', 'viewBox', 'viewTarget', 'xChannelSelector', 'yChannelSelector'].reduce((map, attribute) => {
184
- // The keys are lower-cased for more robust lookup.
185
- map[attribute.toLowerCase()] = attribute;
186
- return map;
187
- }, {});
188
-
189
- /**
190
- * This is a map of all SVG attributes that have colons.
191
- * Keys are lower-cased and stripped of their colons for more robust lookup.
192
- */
193
- const SVG_ATTRIBUTES_WITH_COLONS = ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'xmlns:xlink'].reduce((map, attribute) => {
194
- map[attribute.replace(':', '').toLowerCase()] = attribute;
195
- return map;
196
- }, {});
197
-
198
- /**
199
- * Returns the normal form of the element's attribute name for HTML.
200
- * @param attribute
201
- */
177
+ const SVG_ATTRIBUTE_WITH_DASHES_LIST = [
178
+ "accentHeight",
179
+ "alignmentBaseline",
180
+ "arabicForm",
181
+ "baselineShift",
182
+ "capHeight",
183
+ "clipPath",
184
+ "clipRule",
185
+ "colorInterpolation",
186
+ "colorInterpolationFilters",
187
+ "colorProfile",
188
+ "colorRendering",
189
+ "dominantBaseline",
190
+ "enableBackground",
191
+ "fillOpacity",
192
+ "fillRule",
193
+ "floodColor",
194
+ "floodOpacity",
195
+ "fontFamily",
196
+ "fontSize",
197
+ "fontSizeAdjust",
198
+ "fontStretch",
199
+ "fontStyle",
200
+ "fontVariant",
201
+ "fontWeight",
202
+ "glyphName",
203
+ "glyphOrientationHorizontal",
204
+ "glyphOrientationVertical",
205
+ "horizAdvX",
206
+ "horizOriginX",
207
+ "imageRendering",
208
+ "letterSpacing",
209
+ "lightingColor",
210
+ "markerEnd",
211
+ "markerMid",
212
+ "markerStart",
213
+ "overlinePosition",
214
+ "overlineThickness",
215
+ "paintOrder",
216
+ "panose1",
217
+ "pointerEvents",
218
+ "renderingIntent",
219
+ "shapeRendering",
220
+ "stopColor",
221
+ "stopOpacity",
222
+ "strikethroughPosition",
223
+ "strikethroughThickness",
224
+ "strokeDasharray",
225
+ "strokeDashoffset",
226
+ "strokeLinecap",
227
+ "strokeLinejoin",
228
+ "strokeMiterlimit",
229
+ "strokeOpacity",
230
+ "strokeWidth",
231
+ "textAnchor",
232
+ "textDecoration",
233
+ "textRendering",
234
+ "underlinePosition",
235
+ "underlineThickness",
236
+ "unicodeBidi",
237
+ "unicodeRange",
238
+ "unitsPerEm",
239
+ "vAlphabetic",
240
+ "vHanging",
241
+ "vIdeographic",
242
+ "vMathematical",
243
+ "vectorEffect",
244
+ "vertAdvY",
245
+ "vertOriginX",
246
+ "vertOriginY",
247
+ "wordSpacing",
248
+ "writingMode",
249
+ "xmlnsXlink",
250
+ "xHeight"
251
+ ].reduce(
252
+ (map, attribute) => {
253
+ map[attribute.toLowerCase()] = attribute;
254
+ return map;
255
+ },
256
+ {}
257
+ );
258
+ const CASE_SENSITIVE_SVG_ATTRIBUTES = [
259
+ "allowReorder",
260
+ "attributeName",
261
+ "attributeType",
262
+ "autoReverse",
263
+ "baseFrequency",
264
+ "baseProfile",
265
+ "calcMode",
266
+ "clipPathUnits",
267
+ "contentScriptType",
268
+ "contentStyleType",
269
+ "diffuseConstant",
270
+ "edgeMode",
271
+ "externalResourcesRequired",
272
+ "filterRes",
273
+ "filterUnits",
274
+ "glyphRef",
275
+ "gradientTransform",
276
+ "gradientUnits",
277
+ "kernelMatrix",
278
+ "kernelUnitLength",
279
+ "keyPoints",
280
+ "keySplines",
281
+ "keyTimes",
282
+ "lengthAdjust",
283
+ "limitingConeAngle",
284
+ "markerHeight",
285
+ "markerUnits",
286
+ "markerWidth",
287
+ "maskContentUnits",
288
+ "maskUnits",
289
+ "numOctaves",
290
+ "pathLength",
291
+ "patternContentUnits",
292
+ "patternTransform",
293
+ "patternUnits",
294
+ "pointsAtX",
295
+ "pointsAtY",
296
+ "pointsAtZ",
297
+ "preserveAlpha",
298
+ "preserveAspectRatio",
299
+ "primitiveUnits",
300
+ "refX",
301
+ "refY",
302
+ "repeatCount",
303
+ "repeatDur",
304
+ "requiredExtensions",
305
+ "requiredFeatures",
306
+ "specularConstant",
307
+ "specularExponent",
308
+ "spreadMethod",
309
+ "startOffset",
310
+ "stdDeviation",
311
+ "stitchTiles",
312
+ "suppressContentEditableWarning",
313
+ "suppressHydrationWarning",
314
+ "surfaceScale",
315
+ "systemLanguage",
316
+ "tableValues",
317
+ "targetX",
318
+ "targetY",
319
+ "textLength",
320
+ "viewBox",
321
+ "viewTarget",
322
+ "xChannelSelector",
323
+ "yChannelSelector"
324
+ ].reduce(
325
+ (map, attribute) => {
326
+ map[attribute.toLowerCase()] = attribute;
327
+ return map;
328
+ },
329
+ {}
330
+ );
331
+ const SVG_ATTRIBUTES_WITH_COLONS = [
332
+ "xlink:actuate",
333
+ "xlink:arcrole",
334
+ "xlink:href",
335
+ "xlink:role",
336
+ "xlink:show",
337
+ "xlink:title",
338
+ "xlink:type",
339
+ "xml:base",
340
+ "xml:lang",
341
+ "xml:space",
342
+ "xmlns:xlink"
343
+ ].reduce(
344
+ (map, attribute) => {
345
+ map[attribute.replace(":", "").toLowerCase()] = attribute;
346
+ return map;
347
+ },
348
+ {}
349
+ );
202
350
  function getNormalAttributeName(attribute) {
203
351
  switch (attribute) {
204
- case 'htmlFor':
205
- return 'for';
206
- case 'className':
207
- return 'class';
352
+ case "htmlFor":
353
+ return "for";
354
+ case "className":
355
+ return "class";
208
356
  }
209
357
  const attributeLowerCase = attribute.toLowerCase();
210
358
  if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
211
359
  return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
212
360
  } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
213
- return (0, _changeCase.paramCase)(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
361
+ return (0, import_change_case.paramCase)(
362
+ SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]
363
+ );
214
364
  } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
215
365
  return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
216
366
  }
217
367
  return attributeLowerCase;
218
368
  }
219
-
220
- /**
221
- * Returns the normal form of the style property name for HTML.
222
- *
223
- * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'
224
- * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'
225
- * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'
226
- * @param property
227
- */
228
369
  function getNormalStylePropertyName(property) {
229
- if (property.startsWith('--')) {
370
+ if (property.startsWith("--")) {
230
371
  return property;
231
372
  }
232
- if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
233
- return '-' + (0, _changeCase.paramCase)(property);
373
+ if (hasPrefix(property, ["ms", "O", "Moz", "Webkit"])) {
374
+ return "-" + (0, import_change_case.paramCase)(property);
234
375
  }
235
- return (0, _changeCase.paramCase)(property);
376
+ return (0, import_change_case.paramCase)(property);
236
377
  }
237
-
238
- /**
239
- * Returns the normal form of the style property value for HTML. Appends a
240
- * default pixel unit if numeric, not a unitless property, and not zero.
241
- * @param property
242
- * @param value
243
- */
244
378
  function getNormalStylePropertyValue(property, value) {
245
- if (typeof value === 'number' && 0 !== value && !hasPrefix(property, ['--']) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
246
- return value + 'px';
379
+ if (typeof value === "number" && 0 !== value && !hasPrefix(property, ["--"]) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
380
+ return value + "px";
247
381
  }
248
382
  return value;
249
383
  }
250
-
251
- /**
252
- * Serializes a React element to string.
253
- * @param element
254
- * @param context
255
- * @param legacyContext
256
- */
257
384
  function renderElement(element, context, legacyContext = {}) {
258
- if (null === element || undefined === element || false === element) {
259
- return '';
385
+ if (null === element || void 0 === element || false === element) {
386
+ return "";
260
387
  }
261
388
  if (Array.isArray(element)) {
262
389
  return renderChildren(element, context, legacyContext);
263
390
  }
264
391
  switch (typeof element) {
265
- case 'string':
266
- return (0, _escapeHtml.escapeHTML)(element);
267
- case 'number':
392
+ case "string":
393
+ return (0, import_escape_html.escapeHTML)(element);
394
+ case "number":
268
395
  return element.toString();
269
396
  }
270
- const {
271
- type,
272
- props
273
- } = element;
397
+ const { type, props } = element;
274
398
  switch (type) {
275
- case _react.StrictMode:
276
- case _react.Fragment:
399
+ case import_react.StrictMode:
400
+ case import_react.Fragment:
277
401
  return renderChildren(props.children, context, legacyContext);
278
- case _rawHtml.default:
279
- const {
280
- children,
281
- ...wrapperProps
282
- } = props;
283
- return renderNativeComponent(!Object.keys(wrapperProps).length ? null : 'div', {
284
- ...wrapperProps,
285
- dangerouslySetInnerHTML: {
286
- __html: children
287
- }
288
- }, context, legacyContext);
402
+ case import_raw_html.default:
403
+ const { children, ...wrapperProps } = props;
404
+ return renderNativeComponent(
405
+ !Object.keys(wrapperProps).length ? null : "div",
406
+ {
407
+ ...wrapperProps,
408
+ dangerouslySetInnerHTML: { __html: children }
409
+ },
410
+ context,
411
+ legacyContext
412
+ );
289
413
  }
290
414
  switch (typeof type) {
291
- case 'string':
415
+ case "string":
292
416
  return renderNativeComponent(type, props, context, legacyContext);
293
- case 'function':
294
- if (type.prototype && typeof type.prototype.render === 'function') {
417
+ case "function":
418
+ if (type.prototype && typeof type.prototype.render === "function") {
295
419
  return renderComponent(type, props, context, legacyContext);
296
420
  }
297
- return renderElement(type(props, legacyContext), context, legacyContext);
421
+ return renderElement(
422
+ type(props, legacyContext),
423
+ context,
424
+ legacyContext
425
+ );
298
426
  }
299
427
  switch (type && type.$$typeof) {
300
428
  case Provider.$$typeof:
301
429
  return renderChildren(props.children, props.value, legacyContext);
302
430
  case Consumer.$$typeof:
303
- return renderElement(props.children(context || type._currentValue), context, legacyContext);
431
+ return renderElement(
432
+ props.children(context || type._currentValue),
433
+ context,
434
+ legacyContext
435
+ );
304
436
  case ForwardRef.$$typeof:
305
- return renderElement(type.render(props), context, legacyContext);
437
+ return renderElement(
438
+ type.render(props),
439
+ context,
440
+ legacyContext
441
+ );
306
442
  }
307
- return '';
443
+ return "";
308
444
  }
309
-
310
- /**
311
- * Serializes a native component type to string.
312
- * @param type
313
- * @param props
314
- * @param context
315
- * @param legacyContext
316
- */
317
445
  function renderNativeComponent(type, props, context, legacyContext = {}) {
318
- let content = '';
319
- if (type === 'textarea' && props.hasOwnProperty('value')) {
320
- // Textarea children can be assigned as value prop. If it is, render in
321
- // place of children. Ensure to omit so it is not assigned as attribute
322
- // as well.
446
+ let content = "";
447
+ if (type === "textarea" && props.hasOwnProperty("value")) {
323
448
  content = renderChildren(props.value, context, legacyContext);
324
- const {
325
- value,
326
- ...restProps
327
- } = props;
449
+ const { value, ...restProps } = props;
328
450
  props = restProps;
329
- } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') {
330
- // Dangerous content is left unescaped.
451
+ } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === "string") {
331
452
  content = props.dangerouslySetInnerHTML.__html;
332
- } else if (typeof props.children !== 'undefined') {
453
+ } else if (typeof props.children !== "undefined") {
333
454
  content = renderChildren(props.children, context, legacyContext);
334
455
  }
335
456
  if (!type) {
@@ -337,35 +458,20 @@ function renderNativeComponent(type, props, context, legacyContext = {}) {
337
458
  }
338
459
  const attributes = renderAttributes(props);
339
460
  if (SELF_CLOSING_TAGS.has(type)) {
340
- return '<' + type + attributes + '/>';
461
+ return "<" + type + attributes + "/>";
341
462
  }
342
- return '<' + type + attributes + '>' + content + '</' + type + '>';
463
+ return "<" + type + attributes + ">" + content + "</" + type + ">";
343
464
  }
344
-
345
- /**
346
- * Serializes a non-native component type to string.
347
- * @param Component
348
- * @param props
349
- * @param context
350
- * @param legacyContext
351
- */
352
465
  function renderComponent(Component, props, context, legacyContext = {}) {
353
466
  const instance = new Component(props, legacyContext);
354
- if (typeof instance.getChildContext === 'function') {
467
+ if (typeof instance.getChildContext === "function") {
355
468
  Object.assign(legacyContext, instance.getChildContext());
356
469
  }
357
470
  const html = renderElement(instance.render(), context, legacyContext);
358
471
  return html;
359
472
  }
360
-
361
- /**
362
- * Serializes an array of children to string.
363
- * @param children
364
- * @param context
365
- * @param legacyContext
366
- */
367
473
  function renderChildren(children, context, legacyContext = {}) {
368
- let result = '';
474
+ let result = "";
369
475
  const childrenArray = Array.isArray(children) ? children : [children];
370
476
  for (let i = 0; i < childrenArray.length; i++) {
371
477
  const child = childrenArray[i];
@@ -373,82 +479,69 @@ function renderChildren(children, context, legacyContext = {}) {
373
479
  }
374
480
  return result;
375
481
  }
376
-
377
- /**
378
- * Renders a props object as a string of HTML attributes.
379
- * @param props
380
- */
381
482
  function renderAttributes(props) {
382
- let result = '';
483
+ let result = "";
383
484
  for (const key in props) {
384
485
  const attribute = getNormalAttributeName(key);
385
- if (!(0, _escapeHtml.isValidAttributeName)(attribute)) {
486
+ if (!(0, import_escape_html.isValidAttributeName)(attribute)) {
386
487
  continue;
387
488
  }
388
489
  let value = getNormalAttributeValue(key, props[key]);
389
-
390
- // If value is not of serializable type, skip.
391
490
  if (!ATTRIBUTES_TYPES.has(typeof value)) {
392
491
  continue;
393
492
  }
394
-
395
- // Don't render internal attribute names.
396
493
  if (isInternalAttribute(key)) {
397
494
  continue;
398
495
  }
399
496
  const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
400
-
401
- // Boolean attribute should be omitted outright if its value is false.
402
497
  if (isBooleanAttribute && value === false) {
403
498
  continue;
404
499
  }
405
- const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute);
406
-
407
- // Only write boolean value as attribute if meaningful.
408
- if (typeof value === 'boolean' && !isMeaningfulAttribute) {
500
+ const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ["data-", "aria-"]) || ENUMERATED_ATTRIBUTES.has(attribute);
501
+ if (typeof value === "boolean" && !isMeaningfulAttribute) {
409
502
  continue;
410
503
  }
411
- result += ' ' + attribute;
412
-
413
- // Boolean attributes should write attribute name, but without value.
414
- // Mere presence of attribute name is effective truthiness.
504
+ result += " " + attribute;
415
505
  if (isBooleanAttribute) {
416
506
  continue;
417
507
  }
418
- if (typeof value === 'string') {
419
- value = (0, _escapeHtml.escapeAttribute)(value);
508
+ if (typeof value === "string") {
509
+ value = (0, import_escape_html.escapeAttribute)(value);
420
510
  }
421
511
  result += '="' + value + '"';
422
512
  }
423
513
  return result;
424
514
  }
425
-
426
- /**
427
- * Renders a style object as a string attribute value.
428
- * @param style
429
- */
430
515
  function renderStyle(style) {
431
- // Only generate from object, e.g. tolerate string value.
432
- if (!(0, _isPlainObject.isPlainObject)(style)) {
516
+ if (!(0, import_is_plain_object.isPlainObject)(style)) {
433
517
  return style;
434
518
  }
435
519
  let result;
436
520
  const styleObj = style;
437
521
  for (const property in styleObj) {
438
522
  const value = styleObj[property];
439
- if (null === value || undefined === value) {
523
+ if (null === value || void 0 === value) {
440
524
  continue;
441
525
  }
442
526
  if (result) {
443
- result += ';';
527
+ result += ";";
444
528
  } else {
445
- result = '';
529
+ result = "";
446
530
  }
447
531
  const normalName = getNormalStylePropertyName(property);
448
532
  const normalValue = getNormalStylePropertyValue(property, value);
449
- result += normalName + ':' + normalValue;
533
+ result += normalName + ":" + normalValue;
450
534
  }
451
535
  return result;
452
536
  }
453
- var _default = exports.default = renderElement;
454
- //# sourceMappingURL=serialize.js.map
537
+ var serialize_default = renderElement;
538
+ // Annotate the CommonJS export names for ESM import in node:
539
+ 0 && (module.exports = {
540
+ hasPrefix,
541
+ renderAttributes,
542
+ renderComponent,
543
+ renderElement,
544
+ renderNativeComponent,
545
+ renderStyle
546
+ });
547
+ //# sourceMappingURL=serialize.js.map