No Description

element.js 42KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370
  1. this["wp"] = this["wp"] || {}; this["wp"]["element"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "o/Ny");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "Vx3V":
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = window["wp"]["escapeHtml"]; }());
  92. /***/ }),
  93. /***/ "YLtl":
  94. /***/ (function(module, exports) {
  95. (function() { module.exports = window["lodash"]; }());
  96. /***/ }),
  97. /***/ "cDcd":
  98. /***/ (function(module, exports) {
  99. (function() { module.exports = window["React"]; }());
  100. /***/ }),
  101. /***/ "faye":
  102. /***/ (function(module, exports) {
  103. (function() { module.exports = window["ReactDOM"]; }());
  104. /***/ }),
  105. /***/ "o/Ny":
  106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107. "use strict";
  108. // ESM COMPAT FLAG
  109. __webpack_require__.r(__webpack_exports__);
  110. // EXPORTS
  111. __webpack_require__.d(__webpack_exports__, "createInterpolateElement", function() { return /* reexport */ create_interpolate_element; });
  112. __webpack_require__.d(__webpack_exports__, "Children", function() { return /* reexport */ external_React_["Children"]; });
  113. __webpack_require__.d(__webpack_exports__, "cloneElement", function() { return /* reexport */ external_React_["cloneElement"]; });
  114. __webpack_require__.d(__webpack_exports__, "Component", function() { return /* reexport */ external_React_["Component"]; });
  115. __webpack_require__.d(__webpack_exports__, "createContext", function() { return /* reexport */ external_React_["createContext"]; });
  116. __webpack_require__.d(__webpack_exports__, "createElement", function() { return /* reexport */ external_React_["createElement"]; });
  117. __webpack_require__.d(__webpack_exports__, "createRef", function() { return /* reexport */ external_React_["createRef"]; });
  118. __webpack_require__.d(__webpack_exports__, "forwardRef", function() { return /* reexport */ external_React_["forwardRef"]; });
  119. __webpack_require__.d(__webpack_exports__, "Fragment", function() { return /* reexport */ external_React_["Fragment"]; });
  120. __webpack_require__.d(__webpack_exports__, "isValidElement", function() { return /* reexport */ external_React_["isValidElement"]; });
  121. __webpack_require__.d(__webpack_exports__, "memo", function() { return /* reexport */ external_React_["memo"]; });
  122. __webpack_require__.d(__webpack_exports__, "StrictMode", function() { return /* reexport */ external_React_["StrictMode"]; });
  123. __webpack_require__.d(__webpack_exports__, "useCallback", function() { return /* reexport */ external_React_["useCallback"]; });
  124. __webpack_require__.d(__webpack_exports__, "useContext", function() { return /* reexport */ external_React_["useContext"]; });
  125. __webpack_require__.d(__webpack_exports__, "useDebugValue", function() { return /* reexport */ external_React_["useDebugValue"]; });
  126. __webpack_require__.d(__webpack_exports__, "useEffect", function() { return /* reexport */ external_React_["useEffect"]; });
  127. __webpack_require__.d(__webpack_exports__, "useImperativeHandle", function() { return /* reexport */ external_React_["useImperativeHandle"]; });
  128. __webpack_require__.d(__webpack_exports__, "useLayoutEffect", function() { return /* reexport */ external_React_["useLayoutEffect"]; });
  129. __webpack_require__.d(__webpack_exports__, "useMemo", function() { return /* reexport */ external_React_["useMemo"]; });
  130. __webpack_require__.d(__webpack_exports__, "useReducer", function() { return /* reexport */ external_React_["useReducer"]; });
  131. __webpack_require__.d(__webpack_exports__, "useRef", function() { return /* reexport */ external_React_["useRef"]; });
  132. __webpack_require__.d(__webpack_exports__, "useState", function() { return /* reexport */ external_React_["useState"]; });
  133. __webpack_require__.d(__webpack_exports__, "lazy", function() { return /* reexport */ external_React_["lazy"]; });
  134. __webpack_require__.d(__webpack_exports__, "Suspense", function() { return /* reexport */ external_React_["Suspense"]; });
  135. __webpack_require__.d(__webpack_exports__, "concatChildren", function() { return /* reexport */ concatChildren; });
  136. __webpack_require__.d(__webpack_exports__, "switchChildrenNodeName", function() { return /* reexport */ switchChildrenNodeName; });
  137. __webpack_require__.d(__webpack_exports__, "createPortal", function() { return /* reexport */ external_ReactDOM_["createPortal"]; });
  138. __webpack_require__.d(__webpack_exports__, "findDOMNode", function() { return /* reexport */ external_ReactDOM_["findDOMNode"]; });
  139. __webpack_require__.d(__webpack_exports__, "render", function() { return /* reexport */ external_ReactDOM_["render"]; });
  140. __webpack_require__.d(__webpack_exports__, "unmountComponentAtNode", function() { return /* reexport */ external_ReactDOM_["unmountComponentAtNode"]; });
  141. __webpack_require__.d(__webpack_exports__, "isEmptyElement", function() { return /* reexport */ isEmptyElement; });
  142. __webpack_require__.d(__webpack_exports__, "Platform", function() { return /* reexport */ platform; });
  143. __webpack_require__.d(__webpack_exports__, "renderToString", function() { return /* reexport */ serialize; });
  144. __webpack_require__.d(__webpack_exports__, "RawHTML", function() { return /* reexport */ RawHTML; });
  145. // EXTERNAL MODULE: external "React"
  146. var external_React_ = __webpack_require__("cDcd");
  147. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/create-interpolate-element.js
  148. /**
  149. * Internal dependencies
  150. */
  151. /** @typedef {import('./react').WPElement} WPElement */
  152. let indoc, offset, output, stack;
  153. /**
  154. * Matches tags in the localized string
  155. *
  156. * This is used for extracting the tag pattern groups for parsing the localized
  157. * string and along with the map converting it to a react element.
  158. *
  159. * There are four references extracted using this tokenizer:
  160. *
  161. * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)
  162. * isClosing: The closing slash, it it exists.
  163. * name: The name portion of the tag (strong, br) (if )
  164. * isSelfClosed: The slash on a self closing tag, if it exists.
  165. *
  166. * @type {RegExp}
  167. */
  168. const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
  169. /**
  170. * The stack frame tracking parse progress.
  171. *
  172. * @typedef Frame
  173. *
  174. * @property {WPElement} element A parent element which may still have
  175. * @property {number} tokenStart Offset at which parent element first
  176. * appears.
  177. * @property {number} tokenLength Length of string marking start of parent
  178. * element.
  179. * @property {number} [prevOffset] Running offset at which parsing should
  180. * continue.
  181. * @property {number} [leadingTextStart] Offset at which last closing element
  182. * finished, used for finding text between
  183. * elements.
  184. * @property {WPElement[]} children Children.
  185. */
  186. /**
  187. * Tracks recursive-descent parse state.
  188. *
  189. * This is a Stack frame holding parent elements until all children have been
  190. * parsed.
  191. *
  192. * @private
  193. * @param {WPElement} element A parent element which may still have
  194. * nested children not yet parsed.
  195. * @param {number} tokenStart Offset at which parent element first
  196. * appears.
  197. * @param {number} tokenLength Length of string marking start of parent
  198. * element.
  199. * @param {number} [prevOffset] Running offset at which parsing should
  200. * continue.
  201. * @param {number} [leadingTextStart] Offset at which last closing element
  202. * finished, used for finding text between
  203. * elements.
  204. *
  205. * @return {Frame} The stack frame tracking parse progress.
  206. */
  207. function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
  208. return {
  209. element,
  210. tokenStart,
  211. tokenLength,
  212. prevOffset,
  213. leadingTextStart,
  214. children: []
  215. };
  216. }
  217. /**
  218. * This function creates an interpolated element from a passed in string with
  219. * specific tags matching how the string should be converted to an element via
  220. * the conversion map value.
  221. *
  222. * @example
  223. * For example, for the given string:
  224. *
  225. * "This is a <span>string</span> with <a>a link</a> and a self-closing
  226. * <CustomComponentB/> tag"
  227. *
  228. * You would have something like this as the conversionMap value:
  229. *
  230. * ```js
  231. * {
  232. * span: <span />,
  233. * a: <a href={ 'https://github.com' } />,
  234. * CustomComponentB: <CustomComponent />,
  235. * }
  236. * ```
  237. *
  238. * @param {string} interpolatedString The interpolation string to be parsed.
  239. * @param {Object} conversionMap The map used to convert the string to
  240. * a react element.
  241. * @throws {TypeError}
  242. * @return {WPElement} A wp element.
  243. */
  244. const createInterpolateElement = (interpolatedString, conversionMap) => {
  245. indoc = interpolatedString;
  246. offset = 0;
  247. output = [];
  248. stack = [];
  249. tokenizer.lastIndex = 0;
  250. if (!isValidConversionMap(conversionMap)) {
  251. throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are WPElements');
  252. }
  253. do {// twiddle our thumbs
  254. } while (proceed(conversionMap));
  255. return Object(external_React_["createElement"])(external_React_["Fragment"], null, ...output);
  256. };
  257. /**
  258. * Validate conversion map.
  259. *
  260. * A map is considered valid if it's an object and every value in the object
  261. * is a WPElement
  262. *
  263. * @private
  264. *
  265. * @param {Object} conversionMap The map being validated.
  266. *
  267. * @return {boolean} True means the map is valid.
  268. */
  269. const isValidConversionMap = conversionMap => {
  270. const isObject = typeof conversionMap === 'object';
  271. const values = isObject && Object.values(conversionMap);
  272. return isObject && values.length && values.every(element => Object(external_React_["isValidElement"])(element));
  273. };
  274. /**
  275. * This is the iterator over the matches in the string.
  276. *
  277. * @private
  278. *
  279. * @param {Object} conversionMap The conversion map for the string.
  280. *
  281. * @return {boolean} true for continuing to iterate, false for finished.
  282. */
  283. function proceed(conversionMap) {
  284. const next = nextToken();
  285. const [tokenType, name, startOffset, tokenLength] = next;
  286. const stackDepth = stack.length;
  287. const leadingTextStart = startOffset > offset ? offset : null;
  288. if (!conversionMap[name]) {
  289. addText();
  290. return false;
  291. }
  292. switch (tokenType) {
  293. case 'no-more-tokens':
  294. if (stackDepth !== 0) {
  295. const {
  296. leadingTextStart: stackLeadingText,
  297. tokenStart
  298. } = stack.pop();
  299. output.push(indoc.substr(stackLeadingText, tokenStart));
  300. }
  301. addText();
  302. return false;
  303. case 'self-closed':
  304. if (0 === stackDepth) {
  305. if (null !== leadingTextStart) {
  306. output.push(indoc.substr(leadingTextStart, startOffset - leadingTextStart));
  307. }
  308. output.push(conversionMap[name]);
  309. offset = startOffset + tokenLength;
  310. return true;
  311. } // otherwise we found an inner element
  312. addChild(createFrame(conversionMap[name], startOffset, tokenLength));
  313. offset = startOffset + tokenLength;
  314. return true;
  315. case 'opener':
  316. stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
  317. offset = startOffset + tokenLength;
  318. return true;
  319. case 'closer':
  320. // if we're not nesting then this is easy - close the block
  321. if (1 === stackDepth) {
  322. closeOuterElement(startOffset);
  323. offset = startOffset + tokenLength;
  324. return true;
  325. } // otherwise we're nested and we have to close out the current
  326. // block and add it as a innerBlock to the parent
  327. const stackTop = stack.pop();
  328. const text = indoc.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
  329. stackTop.children.push(text);
  330. stackTop.prevOffset = startOffset + tokenLength;
  331. const frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
  332. frame.children = stackTop.children;
  333. addChild(frame);
  334. offset = startOffset + tokenLength;
  335. return true;
  336. default:
  337. addText();
  338. return false;
  339. }
  340. }
  341. /**
  342. * Grabs the next token match in the string and returns it's details.
  343. *
  344. * @private
  345. *
  346. * @return {Array} An array of details for the token matched.
  347. */
  348. function nextToken() {
  349. const matches = tokenizer.exec(indoc); // we have no more tokens
  350. if (null === matches) {
  351. return ['no-more-tokens'];
  352. }
  353. const startedAt = matches.index;
  354. const [match, isClosing, name, isSelfClosed] = matches;
  355. const length = match.length;
  356. if (isSelfClosed) {
  357. return ['self-closed', name, startedAt, length];
  358. }
  359. if (isClosing) {
  360. return ['closer', name, startedAt, length];
  361. }
  362. return ['opener', name, startedAt, length];
  363. }
  364. /**
  365. * Pushes text extracted from the indoc string to the output stack given the
  366. * current rawLength value and offset (if rawLength is provided ) or the
  367. * indoc.length and offset.
  368. *
  369. * @private
  370. */
  371. function addText() {
  372. const length = indoc.length - offset;
  373. if (0 === length) {
  374. return;
  375. }
  376. output.push(indoc.substr(offset, length));
  377. }
  378. /**
  379. * Pushes a child element to the associated parent element's children for the
  380. * parent currently active in the stack.
  381. *
  382. * @private
  383. *
  384. * @param {Frame} frame The Frame containing the child element and it's
  385. * token information.
  386. */
  387. function addChild(frame) {
  388. const {
  389. element,
  390. tokenStart,
  391. tokenLength,
  392. prevOffset,
  393. children
  394. } = frame;
  395. const parent = stack[stack.length - 1];
  396. const text = indoc.substr(parent.prevOffset, tokenStart - parent.prevOffset);
  397. if (text) {
  398. parent.children.push(text);
  399. }
  400. parent.children.push(Object(external_React_["cloneElement"])(element, null, ...children));
  401. parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
  402. }
  403. /**
  404. * This is called for closing tags. It creates the element currently active in
  405. * the stack.
  406. *
  407. * @private
  408. *
  409. * @param {number} endOffset Offset at which the closing tag for the element
  410. * begins in the string. If this is greater than the
  411. * prevOffset attached to the element, then this
  412. * helps capture any remaining nested text nodes in
  413. * the element.
  414. */
  415. function closeOuterElement(endOffset) {
  416. const {
  417. element,
  418. leadingTextStart,
  419. prevOffset,
  420. tokenStart,
  421. children
  422. } = stack.pop();
  423. const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
  424. if (text) {
  425. children.push(text);
  426. }
  427. if (null !== leadingTextStart) {
  428. output.push(indoc.substr(leadingTextStart, tokenStart - leadingTextStart));
  429. }
  430. output.push(Object(external_React_["cloneElement"])(element, null, ...children));
  431. }
  432. /* harmony default export */ var create_interpolate_element = (createInterpolateElement);
  433. // EXTERNAL MODULE: external "lodash"
  434. var external_lodash_ = __webpack_require__("YLtl");
  435. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/react.js
  436. /**
  437. * External dependencies
  438. */
  439. // eslint-disable-next-line no-restricted-imports
  440. /**
  441. * Object containing a React element.
  442. *
  443. * @typedef {import('react').ReactElement} WPElement
  444. */
  445. /**
  446. * Object containing a React component.
  447. *
  448. * @typedef {import('react').ComponentType} WPComponent
  449. */
  450. /**
  451. * Object containing a React synthetic event.
  452. *
  453. * @typedef {import('react').SyntheticEvent} WPSyntheticEvent
  454. */
  455. /**
  456. * Object that provides utilities for dealing with React children.
  457. */
  458. /**
  459. * Creates a copy of an element with extended props.
  460. *
  461. * @param {WPElement} element Element
  462. * @param {?Object} props Props to apply to cloned element
  463. *
  464. * @return {WPElement} Cloned element.
  465. */
  466. /**
  467. * A base class to create WordPress Components (Refs, state and lifecycle hooks)
  468. */
  469. /**
  470. * Creates a context object containing two components: a provider and consumer.
  471. *
  472. * @param {Object} defaultValue A default data stored in the context.
  473. *
  474. * @return {Object} Context object.
  475. */
  476. /**
  477. * Returns a new element of given type. Type can be either a string tag name or
  478. * another function which itself returns an element.
  479. *
  480. * @param {?(string|Function)} type Tag name or element creator
  481. * @param {Object} props Element properties, either attribute
  482. * set to apply to DOM node or values to
  483. * pass through to element creator
  484. * @param {...WPElement} children Descendant elements
  485. *
  486. * @return {WPElement} Element.
  487. */
  488. /**
  489. * Returns an object tracking a reference to a rendered element via its
  490. * `current` property as either a DOMElement or Element, dependent upon the
  491. * type of element rendered with the ref attribute.
  492. *
  493. * @return {Object} Ref object.
  494. */
  495. /**
  496. * Component enhancer used to enable passing a ref to its wrapped component.
  497. * Pass a function argument which receives `props` and `ref` as its arguments,
  498. * returning an element using the forwarded ref. The return value is a new
  499. * component which forwards its ref.
  500. *
  501. * @param {Function} forwarder Function passed `props` and `ref`, expected to
  502. * return an element.
  503. *
  504. * @return {WPComponent} Enhanced component.
  505. */
  506. /**
  507. * A component which renders its children without any wrapping element.
  508. */
  509. /**
  510. * Checks if an object is a valid WPElement.
  511. *
  512. * @param {Object} objectToCheck The object to be checked.
  513. *
  514. * @return {boolean} true if objectToTest is a valid WPElement and false otherwise.
  515. */
  516. /**
  517. * @see https://reactjs.org/docs/react-api.html#reactmemo
  518. */
  519. /**
  520. * Component that activates additional checks and warnings for its descendants.
  521. */
  522. /**
  523. * @see https://reactjs.org/docs/hooks-reference.html#usecallback
  524. */
  525. /**
  526. * @see https://reactjs.org/docs/hooks-reference.html#usecontext
  527. */
  528. /**
  529. * @see https://reactjs.org/docs/hooks-reference.html#usedebugvalue
  530. */
  531. /**
  532. * @see https://reactjs.org/docs/hooks-reference.html#useeffect
  533. */
  534. /**
  535. * @see https://reactjs.org/docs/hooks-reference.html#useimperativehandle
  536. */
  537. /**
  538. * @see https://reactjs.org/docs/hooks-reference.html#uselayouteffect
  539. */
  540. /**
  541. * @see https://reactjs.org/docs/hooks-reference.html#usememo
  542. */
  543. /**
  544. * @see https://reactjs.org/docs/hooks-reference.html#usereducer
  545. */
  546. /**
  547. * @see https://reactjs.org/docs/hooks-reference.html#useref
  548. */
  549. /**
  550. * @see https://reactjs.org/docs/hooks-reference.html#usestate
  551. */
  552. /**
  553. * @see https://reactjs.org/docs/react-api.html#reactlazy
  554. */
  555. /**
  556. * @see https://reactjs.org/docs/react-api.html#reactsuspense
  557. */
  558. /**
  559. * Concatenate two or more React children objects.
  560. *
  561. * @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.
  562. *
  563. * @return {Array} The concatenated value.
  564. */
  565. function concatChildren(...childrenArguments) {
  566. return childrenArguments.reduce((accumulator, children, i) => {
  567. external_React_["Children"].forEach(children, (child, j) => {
  568. if (child && 'string' !== typeof child) {
  569. child = Object(external_React_["cloneElement"])(child, {
  570. key: [i, j].join()
  571. });
  572. }
  573. accumulator.push(child);
  574. });
  575. return accumulator;
  576. }, []);
  577. }
  578. /**
  579. * Switches the nodeName of all the elements in the children object.
  580. *
  581. * @param {?Object} children Children object.
  582. * @param {string} nodeName Node name.
  583. *
  584. * @return {?Object} The updated children object.
  585. */
  586. function switchChildrenNodeName(children, nodeName) {
  587. return children && external_React_["Children"].map(children, (elt, index) => {
  588. if (Object(external_lodash_["isString"])(elt)) {
  589. return Object(external_React_["createElement"])(nodeName, {
  590. key: index
  591. }, elt);
  592. }
  593. const {
  594. children: childrenProp,
  595. ...props
  596. } = elt.props;
  597. return Object(external_React_["createElement"])(nodeName, {
  598. key: index,
  599. ...props
  600. }, childrenProp);
  601. });
  602. }
  603. // EXTERNAL MODULE: external "ReactDOM"
  604. var external_ReactDOM_ = __webpack_require__("faye");
  605. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/react-platform.js
  606. /**
  607. * External dependencies
  608. */
  609. /**
  610. * Creates a portal into which a component can be rendered.
  611. *
  612. * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235
  613. *
  614. * @param {import('./react').WPElement} child Any renderable child, such as an element,
  615. * string, or fragment.
  616. * @param {HTMLElement} container DOM node into which element should be rendered.
  617. */
  618. /**
  619. * Finds the dom node of a React component.
  620. *
  621. * @param {import('./react').WPComponent} component Component's instance.
  622. */
  623. /**
  624. * Renders a given element into the target DOM node.
  625. *
  626. * @param {import('./react').WPElement} element Element to render.
  627. * @param {HTMLElement} target DOM node into which element should be rendered.
  628. */
  629. /**
  630. * Removes any mounted element from the target DOM node.
  631. *
  632. * @param {Element} target DOM node in which element is to be removed
  633. */
  634. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/utils.js
  635. /**
  636. * External dependencies
  637. */
  638. /**
  639. * Checks if the provided WP element is empty.
  640. *
  641. * @param {*} element WP element to check.
  642. * @return {boolean} True when an element is considered empty.
  643. */
  644. const isEmptyElement = element => {
  645. if (Object(external_lodash_["isNumber"])(element)) {
  646. return false;
  647. }
  648. if (Object(external_lodash_["isString"])(element) || Object(external_lodash_["isArray"])(element)) {
  649. return !element.length;
  650. }
  651. return !element;
  652. };
  653. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/platform.js
  654. /**
  655. * Parts of this source were derived and modified from react-native-web,
  656. * released under the MIT license.
  657. *
  658. * Copyright (c) 2016-present, Nicolas Gallagher.
  659. * Copyright (c) 2015-present, Facebook, Inc.
  660. *
  661. */
  662. const Platform = {
  663. OS: 'web',
  664. select: spec => 'web' in spec ? spec.web : spec.default
  665. };
  666. /**
  667. * Component used to detect the current Platform being used.
  668. * Use Platform.OS === 'web' to detect if running on web enviroment.
  669. *
  670. * This is the same concept as the React Native implementation.
  671. *
  672. * @see https://facebook.github.io/react-native/docs/platform-specific-code#platform-module
  673. *
  674. * Here is an example of how to use the select method:
  675. * @example
  676. * ```js
  677. * import { Platform } from '@wordpress/element';
  678. *
  679. * const placeholderLabel = Platform.select( {
  680. * native: __( 'Add media' ),
  681. * web: __( 'Drag images, upload new ones or select files from your library.' ),
  682. * } );
  683. * ```
  684. */
  685. /* harmony default export */ var platform = (Platform);
  686. // EXTERNAL MODULE: external ["wp","escapeHtml"]
  687. var external_wp_escapeHtml_ = __webpack_require__("Vx3V");
  688. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/raw-html.js
  689. /**
  690. * Internal dependencies
  691. */
  692. // Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly.
  693. /** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
  694. /**
  695. * Component used as equivalent of Fragment with unescaped HTML, in cases where
  696. * it is desirable to render dangerous HTML without needing a wrapper element.
  697. * To preserve additional props, a `div` wrapper _will_ be created if any props
  698. * aside from `children` are passed.
  699. *
  700. * @param {RawHTMLProps} props Children should be a string of HTML. Other props
  701. * will be passed through to div wrapper.
  702. *
  703. * @return {JSX.Element} Dangerously-rendering component.
  704. */
  705. function RawHTML({
  706. children,
  707. ...props
  708. }) {
  709. // The DIV wrapper will be stripped by serializer, unless there are
  710. // non-children props present.
  711. return Object(external_React_["createElement"])('div', {
  712. dangerouslySetInnerHTML: {
  713. __html: children
  714. },
  715. ...props
  716. });
  717. }
  718. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/serialize.js
  719. /**
  720. * Parts of this source were derived and modified from fast-react-render,
  721. * released under the MIT license.
  722. *
  723. * https://github.com/alt-j/fast-react-render
  724. *
  725. * Copyright (c) 2016 Andrey Morozov
  726. *
  727. * Permission is hereby granted, free of charge, to any person obtaining a copy
  728. * of this software and associated documentation files (the "Software"), to deal
  729. * in the Software without restriction, including without limitation the rights
  730. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  731. * copies of the Software, and to permit persons to whom the Software is
  732. * furnished to do so, subject to the following conditions:
  733. *
  734. * The above copyright notice and this permission notice shall be included in
  735. * all copies or substantial portions of the Software.
  736. *
  737. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  738. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  739. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  740. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  741. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  742. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  743. * THE SOFTWARE.
  744. */
  745. /**
  746. * External dependencies
  747. */
  748. /**
  749. * WordPress dependencies
  750. */
  751. /**
  752. * Internal dependencies
  753. */
  754. /** @typedef {import('./react').WPElement} WPElement */
  755. const {
  756. Provider,
  757. Consumer
  758. } = Object(external_React_["createContext"])(undefined);
  759. const ForwardRef = Object(external_React_["forwardRef"])(() => {
  760. return null;
  761. });
  762. /**
  763. * Valid attribute types.
  764. *
  765. * @type {Set<string>}
  766. */
  767. const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
  768. /**
  769. * Element tags which can be self-closing.
  770. *
  771. * @type {Set<string>}
  772. */
  773. const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
  774. /**
  775. * Boolean attributes are attributes whose presence as being assigned is
  776. * meaningful, even if only empty.
  777. *
  778. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
  779. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  780. *
  781. * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
  782. * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
  783. * .reduce( ( result, tr ) => Object.assign( result, {
  784. * [ tr.firstChild.textContent.trim() ]: true
  785. * } ), {} ) ).sort();
  786. *
  787. * @type {Set<string>}
  788. */
  789. 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']);
  790. /**
  791. * Enumerated attributes are attributes which must be of a specific value form.
  792. * Like boolean attributes, these are meaningful if specified, even if not of a
  793. * valid enumerated value.
  794. *
  795. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
  796. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  797. *
  798. * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
  799. * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
  800. * .reduce( ( result, tr ) => Object.assign( result, {
  801. * [ tr.firstChild.textContent.trim() ]: true
  802. * } ), {} ) ).sort();
  803. *
  804. * Some notable omissions:
  805. *
  806. * - `alt`: https://blog.whatwg.org/omit-alt
  807. *
  808. * @type {Set<string>}
  809. */
  810. 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']);
  811. /**
  812. * Set of CSS style properties which support assignment of unitless numbers.
  813. * Used in rendering of style properties, where `px` unit is assumed unless
  814. * property is included in this set or value is zero.
  815. *
  816. * Generated via:
  817. *
  818. * Object.entries( document.createElement( 'div' ).style )
  819. * .filter( ( [ key ] ) => (
  820. * ! /^(webkit|ms|moz)/.test( key ) &&
  821. * ( e.style[ key ] = 10 ) &&
  822. * e.style[ key ] === '10'
  823. * ) )
  824. * .map( ( [ key ] ) => key )
  825. * .sort();
  826. *
  827. * @type {Set<string>}
  828. */
  829. 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']);
  830. /**
  831. * Returns true if the specified string is prefixed by one of an array of
  832. * possible prefixes.
  833. *
  834. * @param {string} string String to check.
  835. * @param {string[]} prefixes Possible prefixes.
  836. *
  837. * @return {boolean} Whether string has prefix.
  838. */
  839. function hasPrefix(string, prefixes) {
  840. return prefixes.some(prefix => string.indexOf(prefix) === 0);
  841. }
  842. /**
  843. * Returns true if the given prop name should be ignored in attributes
  844. * serialization, or false otherwise.
  845. *
  846. * @param {string} attribute Attribute to check.
  847. *
  848. * @return {boolean} Whether attribute should be ignored.
  849. */
  850. function isInternalAttribute(attribute) {
  851. return 'key' === attribute || 'children' === attribute;
  852. }
  853. /**
  854. * Returns the normal form of the element's attribute value for HTML.
  855. *
  856. * @param {string} attribute Attribute name.
  857. * @param {*} value Non-normalized attribute value.
  858. *
  859. * @return {*} Normalized attribute value.
  860. */
  861. function getNormalAttributeValue(attribute, value) {
  862. switch (attribute) {
  863. case 'style':
  864. return renderStyle(value);
  865. }
  866. return value;
  867. }
  868. /**
  869. * Returns the normal form of the element's attribute name for HTML.
  870. *
  871. * @param {string} attribute Non-normalized attribute name.
  872. *
  873. * @return {string} Normalized attribute name.
  874. */
  875. function getNormalAttributeName(attribute) {
  876. switch (attribute) {
  877. case 'htmlFor':
  878. return 'for';
  879. case 'className':
  880. return 'class';
  881. }
  882. return attribute.toLowerCase();
  883. }
  884. /**
  885. * Returns the normal form of the style property name for HTML.
  886. *
  887. * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'
  888. * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'
  889. * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'
  890. *
  891. * @param {string} property Property name.
  892. *
  893. * @return {string} Normalized property name.
  894. */
  895. function getNormalStylePropertyName(property) {
  896. if (Object(external_lodash_["startsWith"])(property, '--')) {
  897. return property;
  898. }
  899. if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
  900. return '-' + Object(external_lodash_["kebabCase"])(property);
  901. }
  902. return Object(external_lodash_["kebabCase"])(property);
  903. }
  904. /**
  905. * Returns the normal form of the style property value for HTML. Appends a
  906. * default pixel unit if numeric, not a unitless property, and not zero.
  907. *
  908. * @param {string} property Property name.
  909. * @param {*} value Non-normalized property value.
  910. *
  911. * @return {*} Normalized property value.
  912. */
  913. function getNormalStylePropertyValue(property, value) {
  914. if (typeof value === 'number' && 0 !== value && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
  915. return value + 'px';
  916. }
  917. return value;
  918. }
  919. /**
  920. * Serializes a React element to string.
  921. *
  922. * @param {import('react').ReactNode} element Element to serialize.
  923. * @param {Object} [context] Context object.
  924. * @param {Object} [legacyContext] Legacy context object.
  925. *
  926. * @return {string} Serialized element.
  927. */
  928. function renderElement(element, context, legacyContext = {}) {
  929. if (null === element || undefined === element || false === element) {
  930. return '';
  931. }
  932. if (Array.isArray(element)) {
  933. return renderChildren(element, context, legacyContext);
  934. }
  935. switch (typeof element) {
  936. case 'string':
  937. return Object(external_wp_escapeHtml_["escapeHTML"])(element);
  938. case 'number':
  939. return element.toString();
  940. }
  941. const {
  942. type,
  943. props
  944. } =
  945. /** @type {{type?: any, props?: any}} */
  946. element;
  947. switch (type) {
  948. case external_React_["StrictMode"]:
  949. case external_React_["Fragment"]:
  950. return renderChildren(props.children, context, legacyContext);
  951. case RawHTML:
  952. const {
  953. children,
  954. ...wrapperProps
  955. } = props;
  956. return renderNativeComponent(Object(external_lodash_["isEmpty"])(wrapperProps) ? null : 'div', { ...wrapperProps,
  957. dangerouslySetInnerHTML: {
  958. __html: children
  959. }
  960. }, context, legacyContext);
  961. }
  962. switch (typeof type) {
  963. case 'string':
  964. return renderNativeComponent(type, props, context, legacyContext);
  965. case 'function':
  966. if (type.prototype && typeof type.prototype.render === 'function') {
  967. return renderComponent(type, props, context, legacyContext);
  968. }
  969. return renderElement(type(props, legacyContext), context, legacyContext);
  970. }
  971. switch (type && type.$$typeof) {
  972. case Provider.$$typeof:
  973. return renderChildren(props.children, props.value, legacyContext);
  974. case Consumer.$$typeof:
  975. return renderElement(props.children(context || type._currentValue), context, legacyContext);
  976. case ForwardRef.$$typeof:
  977. return renderElement(type.render(props), context, legacyContext);
  978. }
  979. return '';
  980. }
  981. /**
  982. * Serializes a native component type to string.
  983. *
  984. * @param {?string} type Native component type to serialize, or null if
  985. * rendering as fragment of children content.
  986. * @param {Object} props Props object.
  987. * @param {Object} [context] Context object.
  988. * @param {Object} [legacyContext] Legacy context object.
  989. *
  990. * @return {string} Serialized element.
  991. */
  992. function renderNativeComponent(type, props, context, legacyContext = {}) {
  993. let content = '';
  994. if (type === 'textarea' && props.hasOwnProperty('value')) {
  995. // Textarea children can be assigned as value prop. If it is, render in
  996. // place of children. Ensure to omit so it is not assigned as attribute
  997. // as well.
  998. content = renderChildren(props.value, context, legacyContext);
  999. props = Object(external_lodash_["omit"])(props, 'value');
  1000. } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') {
  1001. // Dangerous content is left unescaped.
  1002. content = props.dangerouslySetInnerHTML.__html;
  1003. } else if (typeof props.children !== 'undefined') {
  1004. content = renderChildren(props.children, context, legacyContext);
  1005. }
  1006. if (!type) {
  1007. return content;
  1008. }
  1009. const attributes = renderAttributes(props);
  1010. if (SELF_CLOSING_TAGS.has(type)) {
  1011. return '<' + type + attributes + '/>';
  1012. }
  1013. return '<' + type + attributes + '>' + content + '</' + type + '>';
  1014. }
  1015. /** @typedef {import('./react').WPComponent} WPComponent */
  1016. /**
  1017. * Serializes a non-native component type to string.
  1018. *
  1019. * @param {WPComponent} Component Component type to serialize.
  1020. * @param {Object} props Props object.
  1021. * @param {Object} [context] Context object.
  1022. * @param {Object} [legacyContext] Legacy context object.
  1023. *
  1024. * @return {string} Serialized element
  1025. */
  1026. function renderComponent(Component, props, context, legacyContext = {}) {
  1027. const instance = new
  1028. /** @type {import('react').ComponentClass} */
  1029. Component(props, legacyContext);
  1030. if (typeof // Ignore reason: Current prettier reformats parens and mangles type assertion
  1031. // prettier-ignore
  1032. /** @type {{getChildContext?: () => unknown}} */
  1033. instance.getChildContext === 'function') {
  1034. Object.assign(legacyContext,
  1035. /** @type {{getChildContext?: () => unknown}} */
  1036. instance.getChildContext());
  1037. }
  1038. const html = renderElement(instance.render(), context, legacyContext);
  1039. return html;
  1040. }
  1041. /**
  1042. * Serializes an array of children to string.
  1043. *
  1044. * @param {import('react').ReactNodeArray} children Children to serialize.
  1045. * @param {Object} [context] Context object.
  1046. * @param {Object} [legacyContext] Legacy context object.
  1047. *
  1048. * @return {string} Serialized children.
  1049. */
  1050. function renderChildren(children, context, legacyContext = {}) {
  1051. let result = '';
  1052. children = Object(external_lodash_["castArray"])(children);
  1053. for (let i = 0; i < children.length; i++) {
  1054. const child = children[i];
  1055. result += renderElement(child, context, legacyContext);
  1056. }
  1057. return result;
  1058. }
  1059. /**
  1060. * Renders a props object as a string of HTML attributes.
  1061. *
  1062. * @param {Object} props Props object.
  1063. *
  1064. * @return {string} Attributes string.
  1065. */
  1066. function renderAttributes(props) {
  1067. let result = '';
  1068. for (const key in props) {
  1069. const attribute = getNormalAttributeName(key);
  1070. if (!Object(external_wp_escapeHtml_["isValidAttributeName"])(attribute)) {
  1071. continue;
  1072. }
  1073. let value = getNormalAttributeValue(key, props[key]); // If value is not of serializeable type, skip.
  1074. if (!ATTRIBUTES_TYPES.has(typeof value)) {
  1075. continue;
  1076. } // Don't render internal attribute names.
  1077. if (isInternalAttribute(key)) {
  1078. continue;
  1079. }
  1080. const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute); // Boolean attribute should be omitted outright if its value is false.
  1081. if (isBooleanAttribute && value === false) {
  1082. continue;
  1083. }
  1084. const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute); // Only write boolean value as attribute if meaningful.
  1085. if (typeof value === 'boolean' && !isMeaningfulAttribute) {
  1086. continue;
  1087. }
  1088. result += ' ' + attribute; // Boolean attributes should write attribute name, but without value.
  1089. // Mere presence of attribute name is effective truthiness.
  1090. if (isBooleanAttribute) {
  1091. continue;
  1092. }
  1093. if (typeof value === 'string') {
  1094. value = Object(external_wp_escapeHtml_["escapeAttribute"])(value);
  1095. }
  1096. result += '="' + value + '"';
  1097. }
  1098. return result;
  1099. }
  1100. /**
  1101. * Renders a style object as a string attribute value.
  1102. *
  1103. * @param {Object} style Style object.
  1104. *
  1105. * @return {string} Style attribute value.
  1106. */
  1107. function renderStyle(style) {
  1108. // Only generate from object, e.g. tolerate string value.
  1109. if (!Object(external_lodash_["isPlainObject"])(style)) {
  1110. return style;
  1111. }
  1112. let result;
  1113. for (const property in style) {
  1114. const value = style[property];
  1115. if (null === value || undefined === value) {
  1116. continue;
  1117. }
  1118. if (result) {
  1119. result += ';';
  1120. } else {
  1121. result = '';
  1122. }
  1123. const normalName = getNormalStylePropertyName(property);
  1124. const normalValue = getNormalStylePropertyValue(property, value);
  1125. result += normalName + ':' + normalValue;
  1126. }
  1127. return result;
  1128. }
  1129. /* harmony default export */ var serialize = (renderElement);
  1130. // CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/index.js
  1131. /***/ })
  1132. /******/ });