build/scripts/element
index.js
27.3 KB
4 months ago
index.js.map
77.5 KB
4 months ago
index.min.asset.php
121 B
4 months ago
index.min.js
12.1 KB
4 months ago
index.min.js.map
79.7 KB
4 months ago
| 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 (1 === stackDepth) { |
| 234 | closeOuterElement(startOffset); |
| 235 | offset = startOffset + tokenLength; |
| 236 | return true; |
| 237 | } |
| 238 | const stackTop = stack.pop(); |
| 239 | const text = indoc.substr( |
| 240 | stackTop.prevOffset, |
| 241 | startOffset - stackTop.prevOffset |
| 242 | ); |
| 243 | stackTop.children.push(text); |
| 244 | stackTop.prevOffset = startOffset + tokenLength; |
| 245 | const frame = createFrame( |
| 246 | stackTop.element, |
| 247 | stackTop.tokenStart, |
| 248 | stackTop.tokenLength, |
| 249 | startOffset + tokenLength |
| 250 | ); |
| 251 | frame.children = stackTop.children; |
| 252 | addChild(frame); |
| 253 | offset = startOffset + tokenLength; |
| 254 | return true; |
| 255 | default: |
| 256 | addText(); |
| 257 | return false; |
| 258 | } |
| 259 | } |
| 260 | function nextToken() { |
| 261 | const matches = tokenizer.exec(indoc); |
| 262 | if (null === matches) { |
| 263 | return ["no-more-tokens"]; |
| 264 | } |
| 265 | const startedAt = matches.index; |
| 266 | const [match, isClosing, name, isSelfClosed] = matches; |
| 267 | const length = match.length; |
| 268 | if (isSelfClosed) { |
| 269 | return ["self-closed", name, startedAt, length]; |
| 270 | } |
| 271 | if (isClosing) { |
| 272 | return ["closer", name, startedAt, length]; |
| 273 | } |
| 274 | return ["opener", name, startedAt, length]; |
| 275 | } |
| 276 | function addText() { |
| 277 | const length = indoc.length - offset; |
| 278 | if (0 === length) { |
| 279 | return; |
| 280 | } |
| 281 | output.push(indoc.substr(offset, length)); |
| 282 | } |
| 283 | function addChild(frame) { |
| 284 | const { element, tokenStart, tokenLength, prevOffset, children } = frame; |
| 285 | const parent = stack[stack.length - 1]; |
| 286 | const text = indoc.substr( |
| 287 | parent.prevOffset, |
| 288 | tokenStart - parent.prevOffset |
| 289 | ); |
| 290 | if (text) { |
| 291 | parent.children.push(text); |
| 292 | } |
| 293 | parent.children.push((0, import_react.cloneElement)(element, null, ...children)); |
| 294 | parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength; |
| 295 | } |
| 296 | function closeOuterElement(endOffset) { |
| 297 | const { element, leadingTextStart, prevOffset, tokenStart, children } = stack.pop(); |
| 298 | const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset); |
| 299 | if (text) { |
| 300 | children.push(text); |
| 301 | } |
| 302 | if (null !== leadingTextStart) { |
| 303 | output.push( |
| 304 | indoc.substr(leadingTextStart, tokenStart - leadingTextStart) |
| 305 | ); |
| 306 | } |
| 307 | output.push((0, import_react.cloneElement)(element, null, ...children)); |
| 308 | } |
| 309 | var create_interpolate_element_default = createInterpolateElement; |
| 310 | |
| 311 | // packages/element/build-module/react-platform.mjs |
| 312 | var import_react_dom = __toESM(require_react_dom(), 1); |
| 313 | var import_client = __toESM(require_client(), 1); |
| 314 | |
| 315 | // packages/element/build-module/utils.mjs |
| 316 | var isEmptyElement = (element) => { |
| 317 | if (typeof element === "number") { |
| 318 | return false; |
| 319 | } |
| 320 | if (typeof element?.valueOf() === "string" || Array.isArray(element)) { |
| 321 | return !element.length; |
| 322 | } |
| 323 | return !element; |
| 324 | }; |
| 325 | |
| 326 | // packages/element/build-module/platform.mjs |
| 327 | var Platform = { |
| 328 | /** Platform identifier. Will always be `'web'` in this module. */ |
| 329 | OS: "web", |
| 330 | /** |
| 331 | * Select a value based on the platform. |
| 332 | * |
| 333 | * @template T |
| 334 | * @param spec - Object with optional platform-specific values. |
| 335 | * @return The selected value. |
| 336 | */ |
| 337 | select(spec) { |
| 338 | return "web" in spec ? spec.web : spec.default; |
| 339 | }, |
| 340 | /** Whether the platform is web */ |
| 341 | isWeb: true |
| 342 | }; |
| 343 | var platform_default = Platform; |
| 344 | |
| 345 | // node_modules/is-plain-object/dist/is-plain-object.mjs |
| 346 | function isObject(o) { |
| 347 | return Object.prototype.toString.call(o) === "[object Object]"; |
| 348 | } |
| 349 | function isPlainObject(o) { |
| 350 | var ctor, prot; |
| 351 | if (isObject(o) === false) return false; |
| 352 | ctor = o.constructor; |
| 353 | if (ctor === void 0) return true; |
| 354 | prot = ctor.prototype; |
| 355 | if (isObject(prot) === false) return false; |
| 356 | if (prot.hasOwnProperty("isPrototypeOf") === false) { |
| 357 | return false; |
| 358 | } |
| 359 | return true; |
| 360 | } |
| 361 | |
| 362 | // node_modules/tslib/tslib.es6.mjs |
| 363 | var __assign = function() { |
| 364 | __assign = Object.assign || function __assign2(t) { |
| 365 | for (var s, i = 1, n = arguments.length; i < n; i++) { |
| 366 | s = arguments[i]; |
| 367 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
| 368 | } |
| 369 | return t; |
| 370 | }; |
| 371 | return __assign.apply(this, arguments); |
| 372 | }; |
| 373 | |
| 374 | // node_modules/lower-case/dist.es2015/index.js |
| 375 | function lowerCase(str) { |
| 376 | return str.toLowerCase(); |
| 377 | } |
| 378 | |
| 379 | // node_modules/no-case/dist.es2015/index.js |
| 380 | var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
| 381 | var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
| 382 | function noCase(input, options) { |
| 383 | if (options === void 0) { |
| 384 | options = {}; |
| 385 | } |
| 386 | 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; |
| 387 | var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
| 388 | var start = 0; |
| 389 | var end = result.length; |
| 390 | while (result.charAt(start) === "\0") |
| 391 | start++; |
| 392 | while (result.charAt(end - 1) === "\0") |
| 393 | end--; |
| 394 | return result.slice(start, end).split("\0").map(transform).join(delimiter); |
| 395 | } |
| 396 | function replace(input, re, value) { |
| 397 | if (re instanceof RegExp) |
| 398 | return input.replace(re, value); |
| 399 | return re.reduce(function(input2, re2) { |
| 400 | return input2.replace(re2, value); |
| 401 | }, input); |
| 402 | } |
| 403 | |
| 404 | // node_modules/dot-case/dist.es2015/index.js |
| 405 | function dotCase(input, options) { |
| 406 | if (options === void 0) { |
| 407 | options = {}; |
| 408 | } |
| 409 | return noCase(input, __assign({ delimiter: "." }, options)); |
| 410 | } |
| 411 | |
| 412 | // node_modules/param-case/dist.es2015/index.js |
| 413 | function paramCase(input, options) { |
| 414 | if (options === void 0) { |
| 415 | options = {}; |
| 416 | } |
| 417 | return dotCase(input, __assign({ delimiter: "-" }, options)); |
| 418 | } |
| 419 | |
| 420 | // packages/element/build-module/serialize.mjs |
| 421 | var import_escape_html = __toESM(require_escape_html(), 1); |
| 422 | |
| 423 | // packages/element/build-module/raw-html.mjs |
| 424 | function RawHTML({ children, ...props }) { |
| 425 | let rawHtml = ""; |
| 426 | import_react.Children.toArray(children).forEach((child) => { |
| 427 | if (typeof child === "string" && child.trim() !== "") { |
| 428 | rawHtml += child; |
| 429 | } |
| 430 | }); |
| 431 | return (0, import_react.createElement)("div", { |
| 432 | dangerouslySetInnerHTML: { __html: rawHtml }, |
| 433 | ...props |
| 434 | }); |
| 435 | } |
| 436 | |
| 437 | // packages/element/build-module/serialize.mjs |
| 438 | var Context = (0, import_react.createContext)(void 0); |
| 439 | Context.displayName = "ElementContext"; |
| 440 | var { Provider, Consumer } = Context; |
| 441 | var ForwardRef = (0, import_react.forwardRef)(() => { |
| 442 | return null; |
| 443 | }); |
| 444 | var ATTRIBUTES_TYPES = /* @__PURE__ */ new Set(["string", "boolean", "number"]); |
| 445 | var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([ |
| 446 | "area", |
| 447 | "base", |
| 448 | "br", |
| 449 | "col", |
| 450 | "command", |
| 451 | "embed", |
| 452 | "hr", |
| 453 | "img", |
| 454 | "input", |
| 455 | "keygen", |
| 456 | "link", |
| 457 | "meta", |
| 458 | "param", |
| 459 | "source", |
| 460 | "track", |
| 461 | "wbr" |
| 462 | ]); |
| 463 | var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([ |
| 464 | "allowfullscreen", |
| 465 | "allowpaymentrequest", |
| 466 | "allowusermedia", |
| 467 | "async", |
| 468 | "autofocus", |
| 469 | "autoplay", |
| 470 | "checked", |
| 471 | "controls", |
| 472 | "default", |
| 473 | "defer", |
| 474 | "disabled", |
| 475 | "download", |
| 476 | "formnovalidate", |
| 477 | "hidden", |
| 478 | "ismap", |
| 479 | "itemscope", |
| 480 | "loop", |
| 481 | "multiple", |
| 482 | "muted", |
| 483 | "nomodule", |
| 484 | "novalidate", |
| 485 | "open", |
| 486 | "playsinline", |
| 487 | "readonly", |
| 488 | "required", |
| 489 | "reversed", |
| 490 | "selected", |
| 491 | "typemustmatch" |
| 492 | ]); |
| 493 | var ENUMERATED_ATTRIBUTES = /* @__PURE__ */ new Set([ |
| 494 | "autocapitalize", |
| 495 | "autocomplete", |
| 496 | "charset", |
| 497 | "contenteditable", |
| 498 | "crossorigin", |
| 499 | "decoding", |
| 500 | "dir", |
| 501 | "draggable", |
| 502 | "enctype", |
| 503 | "formenctype", |
| 504 | "formmethod", |
| 505 | "http-equiv", |
| 506 | "inputmode", |
| 507 | "kind", |
| 508 | "method", |
| 509 | "preload", |
| 510 | "scope", |
| 511 | "shape", |
| 512 | "spellcheck", |
| 513 | "translate", |
| 514 | "type", |
| 515 | "wrap" |
| 516 | ]); |
| 517 | var CSS_PROPERTIES_SUPPORTS_UNITLESS = /* @__PURE__ */ new Set([ |
| 518 | "animation", |
| 519 | "animationIterationCount", |
| 520 | "baselineShift", |
| 521 | "borderImageOutset", |
| 522 | "borderImageSlice", |
| 523 | "borderImageWidth", |
| 524 | "columnCount", |
| 525 | "cx", |
| 526 | "cy", |
| 527 | "fillOpacity", |
| 528 | "flexGrow", |
| 529 | "flexShrink", |
| 530 | "floodOpacity", |
| 531 | "fontWeight", |
| 532 | "gridColumnEnd", |
| 533 | "gridColumnStart", |
| 534 | "gridRowEnd", |
| 535 | "gridRowStart", |
| 536 | "lineHeight", |
| 537 | "opacity", |
| 538 | "order", |
| 539 | "orphans", |
| 540 | "r", |
| 541 | "rx", |
| 542 | "ry", |
| 543 | "shapeImageThreshold", |
| 544 | "stopOpacity", |
| 545 | "strokeDasharray", |
| 546 | "strokeDashoffset", |
| 547 | "strokeMiterlimit", |
| 548 | "strokeOpacity", |
| 549 | "strokeWidth", |
| 550 | "tabSize", |
| 551 | "widows", |
| 552 | "x", |
| 553 | "y", |
| 554 | "zIndex", |
| 555 | "zoom" |
| 556 | ]); |
| 557 | function hasPrefix(string, prefixes) { |
| 558 | return prefixes.some((prefix) => string.indexOf(prefix) === 0); |
| 559 | } |
| 560 | function isInternalAttribute(attribute) { |
| 561 | return "key" === attribute || "children" === attribute; |
| 562 | } |
| 563 | function getNormalAttributeValue(attribute, value) { |
| 564 | switch (attribute) { |
| 565 | case "style": |
| 566 | return renderStyle(value); |
| 567 | } |
| 568 | return value; |
| 569 | } |
| 570 | var SVG_ATTRIBUTE_WITH_DASHES_LIST = [ |
| 571 | "accentHeight", |
| 572 | "alignmentBaseline", |
| 573 | "arabicForm", |
| 574 | "baselineShift", |
| 575 | "capHeight", |
| 576 | "clipPath", |
| 577 | "clipRule", |
| 578 | "colorInterpolation", |
| 579 | "colorInterpolationFilters", |
| 580 | "colorProfile", |
| 581 | "colorRendering", |
| 582 | "dominantBaseline", |
| 583 | "enableBackground", |
| 584 | "fillOpacity", |
| 585 | "fillRule", |
| 586 | "floodColor", |
| 587 | "floodOpacity", |
| 588 | "fontFamily", |
| 589 | "fontSize", |
| 590 | "fontSizeAdjust", |
| 591 | "fontStretch", |
| 592 | "fontStyle", |
| 593 | "fontVariant", |
| 594 | "fontWeight", |
| 595 | "glyphName", |
| 596 | "glyphOrientationHorizontal", |
| 597 | "glyphOrientationVertical", |
| 598 | "horizAdvX", |
| 599 | "horizOriginX", |
| 600 | "imageRendering", |
| 601 | "letterSpacing", |
| 602 | "lightingColor", |
| 603 | "markerEnd", |
| 604 | "markerMid", |
| 605 | "markerStart", |
| 606 | "overlinePosition", |
| 607 | "overlineThickness", |
| 608 | "paintOrder", |
| 609 | "panose1", |
| 610 | "pointerEvents", |
| 611 | "renderingIntent", |
| 612 | "shapeRendering", |
| 613 | "stopColor", |
| 614 | "stopOpacity", |
| 615 | "strikethroughPosition", |
| 616 | "strikethroughThickness", |
| 617 | "strokeDasharray", |
| 618 | "strokeDashoffset", |
| 619 | "strokeLinecap", |
| 620 | "strokeLinejoin", |
| 621 | "strokeMiterlimit", |
| 622 | "strokeOpacity", |
| 623 | "strokeWidth", |
| 624 | "textAnchor", |
| 625 | "textDecoration", |
| 626 | "textRendering", |
| 627 | "underlinePosition", |
| 628 | "underlineThickness", |
| 629 | "unicodeBidi", |
| 630 | "unicodeRange", |
| 631 | "unitsPerEm", |
| 632 | "vAlphabetic", |
| 633 | "vHanging", |
| 634 | "vIdeographic", |
| 635 | "vMathematical", |
| 636 | "vectorEffect", |
| 637 | "vertAdvY", |
| 638 | "vertOriginX", |
| 639 | "vertOriginY", |
| 640 | "wordSpacing", |
| 641 | "writingMode", |
| 642 | "xmlnsXlink", |
| 643 | "xHeight" |
| 644 | ].reduce( |
| 645 | (map, attribute) => { |
| 646 | map[attribute.toLowerCase()] = attribute; |
| 647 | return map; |
| 648 | }, |
| 649 | {} |
| 650 | ); |
| 651 | var CASE_SENSITIVE_SVG_ATTRIBUTES = [ |
| 652 | "allowReorder", |
| 653 | "attributeName", |
| 654 | "attributeType", |
| 655 | "autoReverse", |
| 656 | "baseFrequency", |
| 657 | "baseProfile", |
| 658 | "calcMode", |
| 659 | "clipPathUnits", |
| 660 | "contentScriptType", |
| 661 | "contentStyleType", |
| 662 | "diffuseConstant", |
| 663 | "edgeMode", |
| 664 | "externalResourcesRequired", |
| 665 | "filterRes", |
| 666 | "filterUnits", |
| 667 | "glyphRef", |
| 668 | "gradientTransform", |
| 669 | "gradientUnits", |
| 670 | "kernelMatrix", |
| 671 | "kernelUnitLength", |
| 672 | "keyPoints", |
| 673 | "keySplines", |
| 674 | "keyTimes", |
| 675 | "lengthAdjust", |
| 676 | "limitingConeAngle", |
| 677 | "markerHeight", |
| 678 | "markerUnits", |
| 679 | "markerWidth", |
| 680 | "maskContentUnits", |
| 681 | "maskUnits", |
| 682 | "numOctaves", |
| 683 | "pathLength", |
| 684 | "patternContentUnits", |
| 685 | "patternTransform", |
| 686 | "patternUnits", |
| 687 | "pointsAtX", |
| 688 | "pointsAtY", |
| 689 | "pointsAtZ", |
| 690 | "preserveAlpha", |
| 691 | "preserveAspectRatio", |
| 692 | "primitiveUnits", |
| 693 | "refX", |
| 694 | "refY", |
| 695 | "repeatCount", |
| 696 | "repeatDur", |
| 697 | "requiredExtensions", |
| 698 | "requiredFeatures", |
| 699 | "specularConstant", |
| 700 | "specularExponent", |
| 701 | "spreadMethod", |
| 702 | "startOffset", |
| 703 | "stdDeviation", |
| 704 | "stitchTiles", |
| 705 | "suppressContentEditableWarning", |
| 706 | "suppressHydrationWarning", |
| 707 | "surfaceScale", |
| 708 | "systemLanguage", |
| 709 | "tableValues", |
| 710 | "targetX", |
| 711 | "targetY", |
| 712 | "textLength", |
| 713 | "viewBox", |
| 714 | "viewTarget", |
| 715 | "xChannelSelector", |
| 716 | "yChannelSelector" |
| 717 | ].reduce( |
| 718 | (map, attribute) => { |
| 719 | map[attribute.toLowerCase()] = attribute; |
| 720 | return map; |
| 721 | }, |
| 722 | {} |
| 723 | ); |
| 724 | var SVG_ATTRIBUTES_WITH_COLONS = [ |
| 725 | "xlink:actuate", |
| 726 | "xlink:arcrole", |
| 727 | "xlink:href", |
| 728 | "xlink:role", |
| 729 | "xlink:show", |
| 730 | "xlink:title", |
| 731 | "xlink:type", |
| 732 | "xml:base", |
| 733 | "xml:lang", |
| 734 | "xml:space", |
| 735 | "xmlns:xlink" |
| 736 | ].reduce( |
| 737 | (map, attribute) => { |
| 738 | map[attribute.replace(":", "").toLowerCase()] = attribute; |
| 739 | return map; |
| 740 | }, |
| 741 | {} |
| 742 | ); |
| 743 | function getNormalAttributeName(attribute) { |
| 744 | switch (attribute) { |
| 745 | case "htmlFor": |
| 746 | return "for"; |
| 747 | case "className": |
| 748 | return "class"; |
| 749 | } |
| 750 | const attributeLowerCase = attribute.toLowerCase(); |
| 751 | if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) { |
| 752 | return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]; |
| 753 | } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) { |
| 754 | return paramCase( |
| 755 | SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase] |
| 756 | ); |
| 757 | } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) { |
| 758 | return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]; |
| 759 | } |
| 760 | return attributeLowerCase; |
| 761 | } |
| 762 | function getNormalStylePropertyName(property) { |
| 763 | if (property.startsWith("--")) { |
| 764 | return property; |
| 765 | } |
| 766 | if (hasPrefix(property, ["ms", "O", "Moz", "Webkit"])) { |
| 767 | return "-" + paramCase(property); |
| 768 | } |
| 769 | return paramCase(property); |
| 770 | } |
| 771 | function getNormalStylePropertyValue(property, value) { |
| 772 | if (typeof value === "number" && 0 !== value && !hasPrefix(property, ["--"]) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) { |
| 773 | return value + "px"; |
| 774 | } |
| 775 | return value; |
| 776 | } |
| 777 | function renderElement(element, context, legacyContext = {}) { |
| 778 | if (null === element || void 0 === element || false === element) { |
| 779 | return ""; |
| 780 | } |
| 781 | if (Array.isArray(element)) { |
| 782 | return renderChildren(element, context, legacyContext); |
| 783 | } |
| 784 | switch (typeof element) { |
| 785 | case "string": |
| 786 | return (0, import_escape_html.escapeHTML)(element); |
| 787 | case "number": |
| 788 | return element.toString(); |
| 789 | } |
| 790 | const { type, props } = element; |
| 791 | switch (type) { |
| 792 | case import_react.StrictMode: |
| 793 | case import_react.Fragment: |
| 794 | return renderChildren(props.children, context, legacyContext); |
| 795 | case RawHTML: |
| 796 | const { children, ...wrapperProps } = props; |
| 797 | return renderNativeComponent( |
| 798 | !Object.keys(wrapperProps).length ? null : "div", |
| 799 | { |
| 800 | ...wrapperProps, |
| 801 | dangerouslySetInnerHTML: { __html: children } |
| 802 | }, |
| 803 | context, |
| 804 | legacyContext |
| 805 | ); |
| 806 | } |
| 807 | switch (typeof type) { |
| 808 | case "string": |
| 809 | return renderNativeComponent(type, props, context, legacyContext); |
| 810 | case "function": |
| 811 | if (type.prototype && typeof type.prototype.render === "function") { |
| 812 | return renderComponent(type, props, context, legacyContext); |
| 813 | } |
| 814 | return renderElement( |
| 815 | type(props, legacyContext), |
| 816 | context, |
| 817 | legacyContext |
| 818 | ); |
| 819 | } |
| 820 | switch (type && type.$$typeof) { |
| 821 | case Provider.$$typeof: |
| 822 | return renderChildren(props.children, props.value, legacyContext); |
| 823 | case Consumer.$$typeof: |
| 824 | return renderElement( |
| 825 | props.children(context || type._currentValue), |
| 826 | context, |
| 827 | legacyContext |
| 828 | ); |
| 829 | case ForwardRef.$$typeof: |
| 830 | return renderElement( |
| 831 | type.render(props), |
| 832 | context, |
| 833 | legacyContext |
| 834 | ); |
| 835 | } |
| 836 | return ""; |
| 837 | } |
| 838 | function renderNativeComponent(type, props, context, legacyContext = {}) { |
| 839 | let content = ""; |
| 840 | if (type === "textarea" && props.hasOwnProperty("value")) { |
| 841 | content = renderChildren(props.value, context, legacyContext); |
| 842 | const { value, ...restProps } = props; |
| 843 | props = restProps; |
| 844 | } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === "string") { |
| 845 | content = props.dangerouslySetInnerHTML.__html; |
| 846 | } else if (typeof props.children !== "undefined") { |
| 847 | content = renderChildren(props.children, context, legacyContext); |
| 848 | } |
| 849 | if (!type) { |
| 850 | return content; |
| 851 | } |
| 852 | const attributes = renderAttributes(props); |
| 853 | if (SELF_CLOSING_TAGS.has(type)) { |
| 854 | return "<" + type + attributes + "/>"; |
| 855 | } |
| 856 | return "<" + type + attributes + ">" + content + "</" + type + ">"; |
| 857 | } |
| 858 | function renderComponent(Component2, props, context, legacyContext = {}) { |
| 859 | const instance = new Component2(props, legacyContext); |
| 860 | if (typeof instance.getChildContext === "function") { |
| 861 | Object.assign(legacyContext, instance.getChildContext()); |
| 862 | } |
| 863 | const html = renderElement(instance.render(), context, legacyContext); |
| 864 | return html; |
| 865 | } |
| 866 | function renderChildren(children, context, legacyContext = {}) { |
| 867 | let result = ""; |
| 868 | const childrenArray = Array.isArray(children) ? children : [children]; |
| 869 | for (let i = 0; i < childrenArray.length; i++) { |
| 870 | const child = childrenArray[i]; |
| 871 | result += renderElement(child, context, legacyContext); |
| 872 | } |
| 873 | return result; |
| 874 | } |
| 875 | function renderAttributes(props) { |
| 876 | let result = ""; |
| 877 | for (const key in props) { |
| 878 | const attribute = getNormalAttributeName(key); |
| 879 | if (!(0, import_escape_html.isValidAttributeName)(attribute)) { |
| 880 | continue; |
| 881 | } |
| 882 | let value = getNormalAttributeValue(key, props[key]); |
| 883 | if (!ATTRIBUTES_TYPES.has(typeof value)) { |
| 884 | continue; |
| 885 | } |
| 886 | if (isInternalAttribute(key)) { |
| 887 | continue; |
| 888 | } |
| 889 | const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute); |
| 890 | if (isBooleanAttribute && value === false) { |
| 891 | continue; |
| 892 | } |
| 893 | const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ["data-", "aria-"]) || ENUMERATED_ATTRIBUTES.has(attribute); |
| 894 | if (typeof value === "boolean" && !isMeaningfulAttribute) { |
| 895 | continue; |
| 896 | } |
| 897 | result += " " + attribute; |
| 898 | if (isBooleanAttribute) { |
| 899 | continue; |
| 900 | } |
| 901 | if (typeof value === "string") { |
| 902 | value = (0, import_escape_html.escapeAttribute)(value); |
| 903 | } |
| 904 | result += '="' + value + '"'; |
| 905 | } |
| 906 | return result; |
| 907 | } |
| 908 | function renderStyle(style) { |
| 909 | if (!isPlainObject(style)) { |
| 910 | return style; |
| 911 | } |
| 912 | let result; |
| 913 | const styleObj = style; |
| 914 | for (const property in styleObj) { |
| 915 | const value = styleObj[property]; |
| 916 | if (null === value || void 0 === value) { |
| 917 | continue; |
| 918 | } |
| 919 | if (result) { |
| 920 | result += ";"; |
| 921 | } else { |
| 922 | result = ""; |
| 923 | } |
| 924 | const normalName = getNormalStylePropertyName(property); |
| 925 | const normalValue = getNormalStylePropertyValue(property, value); |
| 926 | result += normalName + ":" + normalValue; |
| 927 | } |
| 928 | return result; |
| 929 | } |
| 930 | var serialize_default = renderElement; |
| 931 | return __toCommonJS(index_exports); |
| 932 | })(); |
| 933 | /*! Bundled license information: |
| 934 | |
| 935 | is-plain-object/dist/is-plain-object.mjs: |
| 936 | (*! |
| 937 | * is-plain-object <https://github.com/jonschlinkert/is-plain-object> |
| 938 | * |
| 939 | * Copyright (c) 2014-2017, Jon Schlinkert. |
| 940 | * Released under the MIT License. |
| 941 | *) |
| 942 | */ |
| 943 | //# sourceMappingURL=index.js.map |
| 944 |