PluginProbe
Gutenberg / 23.7.2
Gutenberg v23.7.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / element / index.js

index.js in Gutenberg 23.7.2, at build/scripts/element/index.js

953 lines 27.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).element = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // vendor-external:react
36 var require_react = __commonJS({
37 "vendor-external:react"(exports, module) {
38 module.exports = window.React;
39 }
40 });
41
42 // vendor-external:react-dom
43 var require_react_dom = __commonJS({
44 "vendor-external:react-dom"(exports, module) {
45 module.exports = window.ReactDOM;
46 }
47 });
48
49 // vendor-external:react-dom/client
50 var require_client = __commonJS({
51 "vendor-external:react-dom/client"(exports, module) {
52 module.exports = window.ReactDOM;
53 }
54 });
55
56 // package-external:@wordpress/escape-html
57 var require_escape_html = __commonJS({
58 "package-external:@wordpress/escape-html"(exports, module) {
59 module.exports = window.wp.escapeHtml;
60 }
61 });
62
63 // packages/element/build-module/index.mjs
64 var index_exports = {};
65 __export(index_exports, {
66 Children: () => import_react.Children,
67 Component: () => import_react.Component,
68 Fragment: () => import_react.Fragment,
69 Platform: () => platform_default,
70 PureComponent: () => import_react.PureComponent,
71 RawHTML: () => RawHTML,
72 StrictMode: () => import_react.StrictMode,
73 Suspense: () => import_react.Suspense,
74 cloneElement: () => import_react.cloneElement,
75 concatChildren: () => concatChildren,
76 createContext: () => import_react.createContext,
77 createElement: () => import_react.createElement,
78 createInterpolateElement: () => create_interpolate_element_default,
79 createPortal: () => import_react_dom.createPortal,
80 createRef: () => import_react.createRef,
81 createRoot: () => import_client.createRoot,
82 findDOMNode: () => import_react_dom.findDOMNode,
83 flushSync: () => import_react_dom.flushSync,
84 forwardRef: () => import_react.forwardRef,
85 hydrate: () => import_react_dom.hydrate,
86 hydrateRoot: () => import_client.hydrateRoot,
87 isEmptyElement: () => isEmptyElement,
88 isValidElement: () => import_react.isValidElement,
89 lazy: () => import_react.lazy,
90 memo: () => import_react.memo,
91 render: () => import_react_dom.render,
92 renderToString: () => serialize_default,
93 startTransition: () => import_react.startTransition,
94 switchChildrenNodeName: () => switchChildrenNodeName,
95 unmountComponentAtNode: () => import_react_dom.unmountComponentAtNode,
96 useCallback: () => import_react.useCallback,
97 useContext: () => import_react.useContext,
98 useDebugValue: () => import_react.useDebugValue,
99 useDeferredValue: () => import_react.useDeferredValue,
100 useEffect: () => import_react.useEffect,
101 useId: () => import_react.useId,
102 useImperativeHandle: () => import_react.useImperativeHandle,
103 useInsertionEffect: () => import_react.useInsertionEffect,
104 useLayoutEffect: () => import_react.useLayoutEffect,
105 useMemo: () => import_react.useMemo,
106 useReducer: () => import_react.useReducer,
107 useRef: () => import_react.useRef,
108 useState: () => import_react.useState,
109 useSyncExternalStore: () => import_react.useSyncExternalStore,
110 useTransition: () => import_react.useTransition
111 });
112
113 // packages/element/build-module/react.mjs
114 var import_react = __toESM(require_react(), 1);
115 function concatChildren(...childrenArguments) {
116 return childrenArguments.reduce(
117 (accumulator, children, i) => {
118 import_react.Children.forEach(children, (child, j) => {
119 if ((0, import_react.isValidElement)(child) && typeof child !== "string") {
120 child = (0, import_react.cloneElement)(child, {
121 key: [i, j].join()
122 });
123 }
124 accumulator.push(child);
125 });
126 return accumulator;
127 },
128 []
129 );
130 }
131 function switchChildrenNodeName(children, nodeName) {
132 return children && import_react.Children.map(children, (elt, index) => {
133 if (typeof elt?.valueOf() === "string") {
134 return (0, import_react.createElement)(nodeName, { key: index }, elt);
135 }
136 if (!(0, import_react.isValidElement)(elt)) {
137 return elt;
138 }
139 const { children: childrenProp, ...props } = elt.props;
140 return (0, import_react.createElement)(
141 nodeName,
142 { key: index, ...props },
143 childrenProp
144 );
145 });
146 }
147
148 // packages/element/build-module/create-interpolate-element.mjs
149 var indoc;
150 var offset;
151 var output;
152 var stack;
153 var tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
154 function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
155 return {
156 element,
157 tokenStart,
158 tokenLength,
159 prevOffset,
160 leadingTextStart,
161 children: []
162 };
163 }
164 function createInterpolateElement(interpolatedString, conversionMap) {
165 indoc = interpolatedString;
166 offset = 0;
167 output = [];
168 stack = [];
169 tokenizer.lastIndex = 0;
170 if (!isValidConversionMap(conversionMap)) {
171 throw new TypeError(
172 "The conversionMap provided is not valid. It must be an object with values that are React Elements"
173 );
174 }
175 do {
176 } while (proceed(conversionMap));
177 return (0, import_react.createElement)(import_react.Fragment, null, ...output);
178 }
179 var isValidConversionMap = (conversionMap) => {
180 const isObject2 = typeof conversionMap === "object" && conversionMap !== null;
181 const values = isObject2 && Object.values(conversionMap);
182 return isObject2 && values.length > 0 && values.every((element) => (0, import_react.isValidElement)(element));
183 };
184 function proceed(conversionMap) {
185 const next = nextToken();
186 const [tokenType, name, startOffset, tokenLength] = next;
187 const stackDepth = stack.length;
188 const leadingTextStart = startOffset > offset ? offset : null;
189 if (name && !conversionMap[name]) {
190 addText();
191 return false;
192 }
193 switch (tokenType) {
194 case "no-more-tokens":
195 if (stackDepth !== 0) {
196 const { leadingTextStart: stackLeadingText, tokenStart } = stack.pop();
197 output.push(indoc.substr(stackLeadingText, tokenStart));
198 }
199 addText();
200 return false;
201 case "self-closed":
202 if (0 === stackDepth) {
203 if (null !== leadingTextStart) {
204 output.push(
205 indoc.substr(
206 leadingTextStart,
207 startOffset - leadingTextStart
208 )
209 );
210 }
211 output.push(conversionMap[name]);
212 offset = startOffset + tokenLength;
213 return true;
214 }
215 addChild(
216 createFrame(conversionMap[name], startOffset, tokenLength)
217 );
218 offset = startOffset + tokenLength;
219 return true;
220 case "opener":
221 stack.push(
222 createFrame(
223 conversionMap[name],
224 startOffset,
225 tokenLength,
226 startOffset + tokenLength,
227 leadingTextStart
228 )
229 );
230 offset = startOffset + tokenLength;
231 return true;
232 case "closer":
233 if (0 === stackDepth) {
234 if (true) {
235 console.warn(
236 `Unmatched closing tag '</${name}>' in createInterpolateElement. The rest of the string was not interpolated.`
237 );
238 }
239 addText();
240 return false;
241 }
242 if (1 === stackDepth) {
243 closeOuterElement(startOffset);
244 offset = startOffset + tokenLength;
245 return true;
246 }
247 const stackTop = stack.pop();
248 const text = indoc.substr(
249 stackTop.prevOffset,
250 startOffset - stackTop.prevOffset
251 );
252 stackTop.children.push(text);
253 stackTop.prevOffset = startOffset + tokenLength;
254 const frame = createFrame(
255 stackTop.element,
256 stackTop.tokenStart,
257 stackTop.tokenLength,
258 startOffset + tokenLength
259 );
260 frame.children = stackTop.children;
261 addChild(frame);
262 offset = startOffset + tokenLength;
263 return true;
264 default:
265 addText();
266 return false;
267 }
268 }
269 function nextToken() {
270 const matches = tokenizer.exec(indoc);
271 if (null === matches) {
272 return ["no-more-tokens"];
273 }
274 const startedAt = matches.index;
275 const [match, isClosing, name, isSelfClosed] = matches;
276 const length = match.length;
277 if (isSelfClosed) {
278 return ["self-closed", name, startedAt, length];
279 }
280 if (isClosing) {
281 return ["closer", name, startedAt, length];
282 }
283 return ["opener", name, startedAt, length];
284 }
285 function addText() {
286 const length = indoc.length - offset;
287 if (0 === length) {
288 return;
289 }
290 output.push(indoc.substr(offset, length));
291 }
292 function addChild(frame) {
293 const { element, tokenStart, tokenLength, prevOffset, children } = frame;
294 const parent = stack[stack.length - 1];
295 const text = indoc.substr(
296 parent.prevOffset,
297 tokenStart - parent.prevOffset
298 );
299 if (text) {
300 parent.children.push(text);
301 }
302 parent.children.push((0, import_react.cloneElement)(element, null, ...children));
303 parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
304 }
305 function closeOuterElement(endOffset) {
306 const { element, leadingTextStart, prevOffset, tokenStart, children } = stack.pop();
307 const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
308 if (text) {
309 children.push(text);
310 }
311 if (null !== leadingTextStart) {
312 output.push(
313 indoc.substr(leadingTextStart, tokenStart - leadingTextStart)
314 );
315 }
316 output.push((0, import_react.cloneElement)(element, null, ...children));
317 }
318 var create_interpolate_element_default = createInterpolateElement;
319
320 // packages/element/build-module/react-platform.mjs
321 var import_react_dom = __toESM(require_react_dom(), 1);
322 var import_client = __toESM(require_client(), 1);
323
324 // packages/element/build-module/utils.mjs
325 var isEmptyElement = (element) => {
326 if (typeof element === "number") {
327 return false;
328 }
329 if (typeof element?.valueOf() === "string" || Array.isArray(element)) {
330 return !element.length;
331 }
332 return !element;
333 };
334
335 // packages/element/build-module/platform.mjs
336 var Platform = {
337 /** Platform identifier. Will always be `'web'` in this module. */
338 OS: "web",
339 /**
340 * Select a value based on the platform.
341 *
342 * @template T
343 * @param spec - Object with optional platform-specific values.
344 * @return The selected value.
345 */
346 select(spec) {
347 return "web" in spec ? spec.web : spec.default;
348 },
349 /** Whether the platform is web */
350 isWeb: true
351 };
352 var platform_default = Platform;
353
354 // node_modules/is-plain-object/dist/is-plain-object.mjs
355 function isObject(o) {
356 return Object.prototype.toString.call(o) === "[object Object]";
357 }
358 function isPlainObject(o) {
359 var ctor, prot;
360 if (isObject(o) === false) return false;
361 ctor = o.constructor;
362 if (ctor === void 0) return true;
363 prot = ctor.prototype;
364 if (isObject(prot) === false) return false;
365 if (prot.hasOwnProperty("isPrototypeOf") === false) {
366 return false;
367 }
368 return true;
369 }
370
371 // node_modules/tslib/tslib.es6.mjs
372 var __assign = function() {
373 __assign = Object.assign || function __assign2(t) {
374 for (var s, i = 1, n = arguments.length; i < n; i++) {
375 s = arguments[i];
376 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
377 }
378 return t;
379 };
380 return __assign.apply(this, arguments);
381 };
382
383 // node_modules/lower-case/dist.es2015/index.js
384 function lowerCase(str) {
385 return str.toLowerCase();
386 }
387
388 // node_modules/no-case/dist.es2015/index.js
389 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
390 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
391 function noCase(input, options) {
392 if (options === void 0) {
393 options = {};
394 }
395 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
396 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
397 var start = 0;
398 var end = result.length;
399 while (result.charAt(start) === "\0")
400 start++;
401 while (result.charAt(end - 1) === "\0")
402 end--;
403 return result.slice(start, end).split("\0").map(transform).join(delimiter);
404 }
405 function replace(input, re, value) {
406 if (re instanceof RegExp)
407 return input.replace(re, value);
408 return re.reduce(function(input2, re2) {
409 return input2.replace(re2, value);
410 }, input);
411 }
412
413 // node_modules/dot-case/dist.es2015/index.js
414 function dotCase(input, options) {
415 if (options === void 0) {
416 options = {};
417 }
418 return noCase(input, __assign({ delimiter: "." }, options));
419 }
420
421 // node_modules/param-case/dist.es2015/index.js
422 function paramCase(input, options) {
423 if (options === void 0) {
424 options = {};
425 }
426 return dotCase(input, __assign({ delimiter: "-" }, options));
427 }
428
429 // packages/element/build-module/serialize.mjs
430 var import_escape_html = __toESM(require_escape_html(), 1);
431
432 // packages/element/build-module/raw-html.mjs
433 function RawHTML({ children, ...props }) {
434 let rawHtml = "";
435 import_react.Children.toArray(children).forEach((child) => {
436 if (typeof child === "string" && child.trim() !== "") {
437 rawHtml += child;
438 }
439 });
440 return (0, import_react.createElement)("div", {
441 dangerouslySetInnerHTML: { __html: rawHtml },
442 ...props
443 });
444 }
445
446 // packages/element/build-module/serialize.mjs
447 var Context = (0, import_react.createContext)(void 0);
448 Context.displayName = "ElementContext";
449 var { Provider, Consumer } = Context;
450 var ForwardRef = (0, import_react.forwardRef)(() => {
451 return null;
452 });
453 var ATTRIBUTES_TYPES = /* @__PURE__ */ new Set(["string", "boolean", "number"]);
454 var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
455 "area",
456 "base",
457 "br",
458 "col",
459 "command",
460 "embed",
461 "hr",
462 "img",
463 "input",
464 "keygen",
465 "link",
466 "meta",
467 "param",
468 "source",
469 "track",
470 "wbr"
471 ]);
472 var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
473 "allowfullscreen",
474 "allowpaymentrequest",
475 "allowusermedia",
476 "async",
477 "autofocus",
478 "autoplay",
479 "checked",
480 "controls",
481 "default",
482 "defer",
483 "disabled",
484 "download",
485 "formnovalidate",
486 "hidden",
487 "ismap",
488 "itemscope",
489 "loop",
490 "multiple",
491 "muted",
492 "nomodule",
493 "novalidate",
494 "open",
495 "playsinline",
496 "readonly",
497 "required",
498 "reversed",
499 "selected",
500 "typemustmatch"
501 ]);
502 var ENUMERATED_ATTRIBUTES = /* @__PURE__ */ new Set([
503 "autocapitalize",
504 "autocomplete",
505 "charset",
506 "contenteditable",
507 "crossorigin",
508 "decoding",
509 "dir",
510 "draggable",
511 "enctype",
512 "formenctype",
513 "formmethod",
514 "http-equiv",
515 "inputmode",
516 "kind",
517 "method",
518 "preload",
519 "scope",
520 "shape",
521 "spellcheck",
522 "translate",
523 "type",
524 "wrap"
525 ]);
526 var CSS_PROPERTIES_SUPPORTS_UNITLESS = /* @__PURE__ */ new Set([
527 "animation",
528 "animationIterationCount",
529 "baselineShift",
530 "borderImageOutset",
531 "borderImageSlice",
532 "borderImageWidth",
533 "columnCount",
534 "cx",
535 "cy",
536 "fillOpacity",
537 "flexGrow",
538 "flexShrink",
539 "floodOpacity",
540 "fontWeight",
541 "gridColumnEnd",
542 "gridColumnStart",
543 "gridRowEnd",
544 "gridRowStart",
545 "lineHeight",
546 "opacity",
547 "order",
548 "orphans",
549 "r",
550 "rx",
551 "ry",
552 "shapeImageThreshold",
553 "stopOpacity",
554 "strokeDasharray",
555 "strokeDashoffset",
556 "strokeMiterlimit",
557 "strokeOpacity",
558 "strokeWidth",
559 "tabSize",
560 "widows",
561 "x",
562 "y",
563 "zIndex",
564 "zoom"
565 ]);
566 function hasPrefix(string, prefixes) {
567 return prefixes.some((prefix) => string.indexOf(prefix) === 0);
568 }
569 function isInternalAttribute(attribute) {
570 return "key" === attribute || "children" === attribute;
571 }
572 function getNormalAttributeValue(attribute, value) {
573 switch (attribute) {
574 case "style":
575 return renderStyle(value);
576 }
577 return value;
578 }
579 var SVG_ATTRIBUTE_WITH_DASHES_LIST = [
580 "accentHeight",
581 "alignmentBaseline",
582 "arabicForm",
583 "baselineShift",
584 "capHeight",
585 "clipPath",
586 "clipRule",
587 "colorInterpolation",
588 "colorInterpolationFilters",
589 "colorProfile",
590 "colorRendering",
591 "dominantBaseline",
592 "enableBackground",
593 "fillOpacity",
594 "fillRule",
595 "floodColor",
596 "floodOpacity",
597 "fontFamily",
598 "fontSize",
599 "fontSizeAdjust",
600 "fontStretch",
601 "fontStyle",
602 "fontVariant",
603 "fontWeight",
604 "glyphName",
605 "glyphOrientationHorizontal",
606 "glyphOrientationVertical",
607 "horizAdvX",
608 "horizOriginX",
609 "imageRendering",
610 "letterSpacing",
611 "lightingColor",
612 "markerEnd",
613 "markerMid",
614 "markerStart",
615 "overlinePosition",
616 "overlineThickness",
617 "paintOrder",
618 "panose1",
619 "pointerEvents",
620 "renderingIntent",
621 "shapeRendering",
622 "stopColor",
623 "stopOpacity",
624 "strikethroughPosition",
625 "strikethroughThickness",
626 "strokeDasharray",
627 "strokeDashoffset",
628 "strokeLinecap",
629 "strokeLinejoin",
630 "strokeMiterlimit",
631 "strokeOpacity",
632 "strokeWidth",
633 "textAnchor",
634 "textDecoration",
635 "textRendering",
636 "underlinePosition",
637 "underlineThickness",
638 "unicodeBidi",
639 "unicodeRange",
640 "unitsPerEm",
641 "vAlphabetic",
642 "vHanging",
643 "vIdeographic",
644 "vMathematical",
645 "vectorEffect",
646 "vertAdvY",
647 "vertOriginX",
648 "vertOriginY",
649 "wordSpacing",
650 "writingMode",
651 "xmlnsXlink",
652 "xHeight"
653 ].reduce(
654 (map, attribute) => {
655 map[attribute.toLowerCase()] = attribute;
656 return map;
657 },
658 {}
659 );
660 var CASE_SENSITIVE_SVG_ATTRIBUTES = [
661 "allowReorder",
662 "attributeName",
663 "attributeType",
664 "autoReverse",
665 "baseFrequency",
666 "baseProfile",
667 "calcMode",
668 "clipPathUnits",
669 "contentScriptType",
670 "contentStyleType",
671 "diffuseConstant",
672 "edgeMode",
673 "externalResourcesRequired",
674 "filterRes",
675 "filterUnits",
676 "glyphRef",
677 "gradientTransform",
678 "gradientUnits",
679 "kernelMatrix",
680 "kernelUnitLength",
681 "keyPoints",
682 "keySplines",
683 "keyTimes",
684 "lengthAdjust",
685 "limitingConeAngle",
686 "markerHeight",
687 "markerUnits",
688 "markerWidth",
689 "maskContentUnits",
690 "maskUnits",
691 "numOctaves",
692 "pathLength",
693 "patternContentUnits",
694 "patternTransform",
695 "patternUnits",
696 "pointsAtX",
697 "pointsAtY",
698 "pointsAtZ",
699 "preserveAlpha",
700 "preserveAspectRatio",
701 "primitiveUnits",
702 "refX",
703 "refY",
704 "repeatCount",
705 "repeatDur",
706 "requiredExtensions",
707 "requiredFeatures",
708 "specularConstant",
709 "specularExponent",
710 "spreadMethod",
711 "startOffset",
712 "stdDeviation",
713 "stitchTiles",
714 "suppressContentEditableWarning",
715 "suppressHydrationWarning",
716 "surfaceScale",
717 "systemLanguage",
718 "tableValues",
719 "targetX",
720 "targetY",
721 "textLength",
722 "viewBox",
723 "viewTarget",
724 "xChannelSelector",
725 "yChannelSelector"
726 ].reduce(
727 (map, attribute) => {
728 map[attribute.toLowerCase()] = attribute;
729 return map;
730 },
731 {}
732 );
733 var SVG_ATTRIBUTES_WITH_COLONS = [
734 "xlink:actuate",
735 "xlink:arcrole",
736 "xlink:href",
737 "xlink:role",
738 "xlink:show",
739 "xlink:title",
740 "xlink:type",
741 "xml:base",
742 "xml:lang",
743 "xml:space",
744 "xmlns:xlink"
745 ].reduce(
746 (map, attribute) => {
747 map[attribute.replace(":", "").toLowerCase()] = attribute;
748 return map;
749 },
750 {}
751 );
752 function getNormalAttributeName(attribute) {
753 switch (attribute) {
754 case "htmlFor":
755 return "for";
756 case "className":
757 return "class";
758 }
759 const attributeLowerCase = attribute.toLowerCase();
760 if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
761 return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
762 } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
763 return paramCase(
764 SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]
765 );
766 } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
767 return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
768 }
769 return attributeLowerCase;
770 }
771 function getNormalStylePropertyName(property) {
772 if (property.startsWith("--")) {
773 return property;
774 }
775 if (hasPrefix(property, ["ms", "O", "Moz", "Webkit"])) {
776 return "-" + paramCase(property);
777 }
778 return paramCase(property);
779 }
780 function getNormalStylePropertyValue(property, value) {
781 if (typeof value === "number" && 0 !== value && !hasPrefix(property, ["--"]) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
782 return value + "px";
783 }
784 return value;
785 }
786 function renderElement(element, context, legacyContext = {}) {
787 if (null === element || void 0 === element || false === element) {
788 return "";
789 }
790 if (Array.isArray(element)) {
791 return renderChildren(element, context, legacyContext);
792 }
793 switch (typeof element) {
794 case "string":
795 return (0, import_escape_html.escapeHTML)(element);
796 case "number":
797 return element.toString();
798 }
799 const { type, props } = element;
800 switch (type) {
801 case import_react.StrictMode:
802 case import_react.Fragment:
803 return renderChildren(props.children, context, legacyContext);
804 case RawHTML:
805 const { children, ...wrapperProps } = props;
806 return renderNativeComponent(
807 !Object.keys(wrapperProps).length ? null : "div",
808 {
809 ...wrapperProps,
810 dangerouslySetInnerHTML: { __html: children }
811 },
812 context,
813 legacyContext
814 );
815 }
816 switch (typeof type) {
817 case "string":
818 return renderNativeComponent(type, props, context, legacyContext);
819 case "function":
820 if (type.prototype && typeof type.prototype.render === "function") {
821 return renderComponent(type, props, context, legacyContext);
822 }
823 return renderElement(
824 type(props, legacyContext),
825 context,
826 legacyContext
827 );
828 }
829 switch (type && type.$$typeof) {
830 case Provider.$$typeof:
831 return renderChildren(props.children, props.value, legacyContext);
832 case Consumer.$$typeof:
833 return renderElement(
834 props.children(context || type._currentValue),
835 context,
836 legacyContext
837 );
838 case ForwardRef.$$typeof:
839 return renderElement(
840 type.render(props),
841 context,
842 legacyContext
843 );
844 }
845 return "";
846 }
847 function renderNativeComponent(type, props, context, legacyContext = {}) {
848 let content = "";
849 if (type === "textarea" && props.hasOwnProperty("value")) {
850 content = renderChildren(props.value, context, legacyContext);
851 const { value, ...restProps } = props;
852 props = restProps;
853 } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === "string") {
854 content = props.dangerouslySetInnerHTML.__html;
855 } else if (typeof props.children !== "undefined") {
856 content = renderChildren(props.children, context, legacyContext);
857 }
858 if (!type) {
859 return content;
860 }
861 const attributes = renderAttributes(props);
862 if (SELF_CLOSING_TAGS.has(type)) {
863 return "<" + type + attributes + "/>";
864 }
865 return "<" + type + attributes + ">" + content + "</" + type + ">";
866 }
867 function renderComponent(Component2, props, context, legacyContext = {}) {
868 const instance = new Component2(props, legacyContext);
869 if (typeof instance.getChildContext === "function") {
870 Object.assign(legacyContext, instance.getChildContext());
871 }
872 const html = renderElement(instance.render(), context, legacyContext);
873 return html;
874 }
875 function renderChildren(children, context, legacyContext = {}) {
876 let result = "";
877 const childrenArray = Array.isArray(children) ? children : [children];
878 for (let i = 0; i < childrenArray.length; i++) {
879 const child = childrenArray[i];
880 result += renderElement(child, context, legacyContext);
881 }
882 return result;
883 }
884 function renderAttributes(props) {
885 let result = "";
886 for (const key in props) {
887 const attribute = getNormalAttributeName(key);
888 if (!(0, import_escape_html.isValidAttributeName)(attribute)) {
889 continue;
890 }
891 let value = getNormalAttributeValue(key, props[key]);
892 if (!ATTRIBUTES_TYPES.has(typeof value)) {
893 continue;
894 }
895 if (isInternalAttribute(key)) {
896 continue;
897 }
898 const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
899 if (isBooleanAttribute && value === false) {
900 continue;
901 }
902 const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ["data-", "aria-"]) || ENUMERATED_ATTRIBUTES.has(attribute);
903 if (typeof value === "boolean" && !isMeaningfulAttribute) {
904 continue;
905 }
906 result += " " + attribute;
907 if (isBooleanAttribute) {
908 continue;
909 }
910 if (typeof value === "string") {
911 value = (0, import_escape_html.escapeAttribute)(value);
912 }
913 result += '="' + value + '"';
914 }
915 return result;
916 }
917 function renderStyle(style) {
918 if (!isPlainObject(style)) {
919 return style;
920 }
921 let result;
922 const styleObj = style;
923 for (const property in styleObj) {
924 const value = styleObj[property];
925 if (null === value || void 0 === value) {
926 continue;
927 }
928 if (result) {
929 result += ";";
930 } else {
931 result = "";
932 }
933 const normalName = getNormalStylePropertyName(property);
934 const normalValue = getNormalStylePropertyValue(property, value);
935 result += normalName + ":" + normalValue;
936 }
937 return result;
938 }
939 var serialize_default = renderElement;
940 return __toCommonJS(index_exports);
941 })();
942 /*! Bundled license information:
943
944 is-plain-object/dist/is-plain-object.mjs:
945 (*!
946 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
947 *
948 * Copyright (c) 2014-2017, Jon Schlinkert.
949 * Released under the MIT License.
950 *)
951 */
952 //# sourceMappingURL=index.js.map
953