| @@ -94,8 +94,31 @@ | ||
| 94 | 94 | return n; |
| 95 | 95 | } |
| 96 | 96 | var clsx_default = clsx; |
| 97 | 97 | |
| 98 | +// node_modules/@base-ui/utils/createLogOnce.mjs | |
| 99 | +var loggedMessages; | |
| 100 | +if (true) { | |
| 101 | + loggedMessages = /* @__PURE__ */ new Set(); | |
| 102 | +} | |
| 103 | +function createLogOnce(severity, prefix) { | |
| 104 | + return function logOnce(...messages) { | |
| 105 | + if (true) { | |
| 106 | + const message = messages.join(" "); | |
| 107 | + const output = prefix ? `${prefix}: ${message}` : message; | |
| 108 | + const key = `${severity}:${output}`; | |
| 109 | + if (!loggedMessages.has(key)) { | |
| 110 | + loggedMessages.add(key); | |
| 111 | + if (severity === "warn") { | |
| 112 | + console.warn(output); | |
| 113 | + } else { | |
| 114 | + console.error(output); | |
| 115 | + } | |
| 116 | + } | |
| 117 | + } | |
| 118 | + }; | |
| 119 | +} | |
| 120 | + | |
| 98 | 121 | // node_modules/@base-ui/utils/useRefWithInit.mjs |
| 99 | 122 | var React = __toESM(require_react(), 1); |
| 100 | 123 | var UNINITIALIZED = {}; |
| 101 | 124 | function useRefWithInit(init, initArg) { |
| @@ -106,22 +129,14 @@ | ||
| 106 | 129 | return ref; |
| 107 | 130 | } |
| 108 | 131 | |
| 109 | 132 | // node_modules/@base-ui/utils/warn.mjs |
| 110 | -var set; | |
| 111 | -if (true) { | |
| 112 | - set = /* @__PURE__ */ new Set(); | |
| 113 | -} | |
| 114 | -function warn(...messages) { | |
| 115 | - if (true) { | |
| 116 | - const messageKey = messages.join(" "); | |
| 117 | - if (!set.has(messageKey)) { | |
| 118 | - set.add(messageKey); | |
| 119 | - console.warn(`Base UI: ${messageKey}`); | |
| 120 | - } | |
| 121 | - } | |
| 122 | -} | |
| 133 | +var warn = createLogOnce("warn", "Base UI"); | |
| 123 | 134 | |
| 135 | +// node_modules/@base-ui/utils/empty.mjs | |
| 136 | +var EMPTY_ARRAY = Object.freeze([]); | |
| 137 | +var EMPTY_OBJECT = Object.freeze({}); | |
| 138 | + | |
| 124 | 139 | // node_modules/@base-ui/react/internals/useRenderElement.mjs |
| 125 | 140 | var React4 = __toESM(require_react(), 1); |
| 126 | 141 | |
| 127 | 142 | // node_modules/@base-ui/utils/useMergedRefs.mjs |
| @@ -249,12 +264,8 @@ | ||
| 249 | 264 | } |
| 250 | 265 | return void 0; |
| 251 | 266 | } |
| 252 | 267 | |
| 253 | -// node_modules/@base-ui/utils/empty.mjs | |
| 254 | -var EMPTY_ARRAY = Object.freeze([]); | |
| 255 | -var EMPTY_OBJECT = Object.freeze({}); | |
| 256 | - | |
| 257 | 268 | // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs |
| 258 | 269 | function getStateAttributesProps(state, customMapping) { |
| 259 | 270 | const props = {}; |
| 260 | 271 | for (const key in state) { |
| @@ -442,10 +453,13 @@ | ||
| 442 | 453 | |
| 443 | 454 | // node_modules/@base-ui/react/internals/useRenderElement.mjs |
| 444 | 455 | var import_react = __toESM(require_react(), 1); |
| 445 | 456 | function useRenderElement(element, componentProps, params = {}) { |
| 446 | - const renderProp = componentProps.render; | |
| 447 | - const outProps = useRenderElementProps(componentProps, params); | |
| 457 | + let renderProp = componentProps.render; | |
| 458 | + if (params.enabled !== false) { | |
| 459 | + renderProp = unwrapLazyRenderProp(renderProp); | |
| 460 | + } | |
| 461 | + const outProps = useRenderElementProps(componentProps, params, renderProp); | |
| 448 | 462 | if (params.enabled === false) { |
| 449 | 463 | return null; |
| 450 | 464 | } |
| 451 | 465 | const state = params.state ?? EMPTY_OBJECT; |
| @@ -450,13 +464,12 @@ | ||
| 450 | 464 | } |
| 451 | 465 | const state = params.state ?? EMPTY_OBJECT; |
| 452 | 466 | return evaluateRenderProp(element, renderProp, outProps, state); |
| 453 | 467 | } |
| 454 | -function useRenderElementProps(componentProps, params = {}) { | |
| 468 | +function useRenderElementProps(componentProps, params, renderProp) { | |
| 455 | 469 | const { |
| 456 | 470 | className: classNameProp, |
| 457 | - style: styleProp, | |
| 458 | - render: renderProp | |
| 471 | + style: styleProp | |
| 459 | 472 | } = componentProps; |
| 460 | 473 | const { |
| 461 | 474 | state = EMPTY_OBJECT, |
| 462 | 475 | ref, |
| @@ -497,8 +510,15 @@ | ||
| 497 | 510 | } |
| 498 | 511 | var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); |
| 499 | 512 | var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; |
| 500 | 513 | var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; |
| 514 | +function unwrapLazyRenderProp(render) { | |
| 515 | + if (render?.$$typeof !== REACT_LAZY_TYPE) { | |
| 516 | + return render; | |
| 517 | + } | |
| 518 | + const unwrapped = React4.Children.toArray(render)[0]; | |
| 519 | + return /* @__PURE__ */ React4.isValidElement(unwrapped) ? unwrapped : render; | |
| 520 | +} | |
| 501 | 521 | function evaluateRenderProp(element, render, props, state) { |
| 502 | 522 | if (render) { |
| 503 | 523 | if (typeof render === "function") { |
| 504 | 524 | if (true) { |
| @@ -507,19 +527,14 @@ | ||
| 507 | 527 | return render(props, state); |
| 508 | 528 | } |
| 509 | 529 | const mergedProps = mergeProps(props, render.props); |
| 510 | 530 | mergedProps.ref = props.ref; |
| 511 | - let newElement = render; | |
| 512 | - if (newElement?.$$typeof === REACT_LAZY_TYPE) { | |
| 513 | - const children = React4.Children.toArray(render); | |
| 514 | - newElement = children[0]; | |
| 515 | - } | |
| 516 | 531 | if (true) { |
| 517 | - if (!/* @__PURE__ */ React4.isValidElement(newElement)) { | |
| 532 | + if (!/* @__PURE__ */ React4.isValidElement(render)) { | |
| 518 | 533 | throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n")); |
| 519 | 534 | } |
| 520 | 535 | } |
| 521 | - return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps); | |
| 536 | + return /* @__PURE__ */ React4.cloneElement(render, mergedProps); | |
| 522 | 537 | } |
| 523 | 538 | if (element) { |
| 524 | 539 | if (typeof element === "string") { |
| 525 | 540 | return renderTag(element, props); |
| @@ -927,9 +942,9 @@ | ||
| 927 | 942 | return element; |
| 928 | 943 | }); |
| 929 | 944 | |
| 930 | 945 | // widgets/site-health/render.tsx |
| 931 | -import { useWidgetHost } from "@wordpress/widget-primitives"; | |
| 946 | +import { HostLink } from "@wordpress/widget-primitives"; | |
| 932 | 947 | |
| 933 | 948 | // widgets/site-health/components/circle-progress/circle-progress.tsx |
| 934 | 949 | var import_primitives = __toESM(require_primitives()); |
| 935 | 950 | |
| @@ -1136,13 +1151,12 @@ | ||
| 1136 | 1151 | } |
| 1137 | 1152 | function SiteHealth() { |
| 1138 | 1153 | const [counts, setCounts] = (0, import_element4.useState)(null); |
| 1139 | 1154 | const [isLoading, setIsLoading] = (0, import_element4.useState)(true); |
| 1140 | - const { links } = useWidgetHost(); | |
| 1141 | 1155 | (0, import_element4.useEffect)(() => { |
| 1142 | 1156 | let ignore = false; |
| 1143 | 1157 | const requests = ASYNC_TEST_PATHS.map( |
| 1144 | - (path2) => (0, import_api_fetch.default)({ path: path2 }).catch(() => null) | |
| 1158 | + (path) => (0, import_api_fetch.default)({ path }).catch(() => null) | |
| 1145 | 1159 | ); |
| 1146 | 1160 | Promise.all(requests).then((results) => { |
| 1147 | 1161 | if (ignore) { |
| 1148 | 1162 | return; |
| @@ -1183,10 +1197,8 @@ | ||
| 1183 | 1197 | const percentage = total > 0 ? Math.round(counts.good / total * 100) : 0; |
| 1184 | 1198 | const issuesTotal = counts.recommended + counts.critical; |
| 1185 | 1199 | const tone = toneForPercentage(percentage); |
| 1186 | 1200 | const href = reviewHref(counts); |
| 1187 | - const path = links?.match(href) ?? null; | |
| 1188 | - const HostLink = links?.Link; | |
| 1189 | 1201 | const reviewLabel = (0, import_i18n2.sprintf)( |
| 1190 | 1202 | /* translators: %d: Number of issues to address. */ |
| 1191 | 1203 | (0, import_i18n2._n)("Review %d item", "Review %d items", issuesTotal), |
| 1192 | 1204 | issuesTotal |
| @@ -1201,9 +1213,9 @@ | ||
| 1201 | 1213 | gap: "lg", |
| 1202 | 1214 | children: [ |
| 1203 | 1215 | /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CircleProgress, { percentage, tone }), |
| 1204 | 1216 | /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { variant: "body-lg", children: statusMessage(counts) }), |
| 1205 | - issuesTotal > 0 && (path !== null && HostLink ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Link, { render: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HostLink, { path }), children: reviewLabel }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Link, { href, children: reviewLabel })) | |
| 1217 | + issuesTotal > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Link, { render: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HostLink, { href }), children: reviewLabel }) | |
| 1206 | 1218 | ] |
| 1207 | 1219 | } |
| 1208 | 1220 | ); |
| 1209 | 1221 | } |