@firecms/ui 3.0.0-tw4.17 → 3.0.0-tw4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import { c } from "react-compiler-runtime";
4
4
  import * as React from "react";
5
- import React__default, { useEffect, useState, createContext, useContext, useRef, Children, forwardRef, useLayoutEffect, useDeferredValue } from "react";
5
+ import React__default, { createContext, useContext, useEffect, useState, useRef, Children, forwardRef, useLayoutEffect, useDeferredValue } from "react";
6
6
  import * as Collapsible from "@radix-ui/react-collapsible";
7
7
  import { clsx } from "clsx";
8
8
  import { twMerge } from "tailwind-merge";
@@ -247,31 +247,69 @@ function keyToIconComponent(key) {
247
247
  }).join("") + "Icon";
248
248
  return componentName;
249
249
  }
250
+ const PortalContainerContext = createContext(void 0);
251
+ function PortalContainerProvider(t0) {
252
+ const $ = c(5);
253
+ const {
254
+ container,
255
+ children
256
+ } = t0;
257
+ let t1;
258
+ if ($[0] !== container) {
259
+ t1 = {
260
+ container
261
+ };
262
+ $[0] = container;
263
+ $[1] = t1;
264
+ } else {
265
+ t1 = $[1];
266
+ }
267
+ let t2;
268
+ if ($[2] !== children || $[3] !== t1) {
269
+ t2 = /* @__PURE__ */ jsx(PortalContainerContext.Provider, { value: t1, children });
270
+ $[2] = children;
271
+ $[3] = t1;
272
+ $[4] = t2;
273
+ } else {
274
+ t2 = $[4];
275
+ }
276
+ return t2;
277
+ }
278
+ function usePortalContainer() {
279
+ const context = useContext(PortalContainerContext);
280
+ return context?.container ?? null;
281
+ }
250
282
  function useInjectStyles(key, styles2) {
251
- const $ = c(4);
283
+ const $ = c(5);
284
+ const portalContainer = usePortalContainer();
252
285
  let t0;
253
- if ($[0] !== key || $[1] !== styles2) {
286
+ if ($[0] !== key || $[1] !== portalContainer || $[2] !== styles2) {
254
287
  t0 = () => {
255
- const styleElement = document.getElementById(key);
256
- if (!styleElement) {
288
+ if (typeof document === "undefined") {
289
+ return;
290
+ }
291
+ const targetContainer = portalContainer ?? document.head;
292
+ const existingStyle = targetContainer.querySelector?.(`#${key}`);
293
+ if (!existingStyle) {
257
294
  const style = document.createElement("style");
258
295
  style.id = key;
259
296
  style.innerHTML = styles2;
260
- document.head.appendChild(style);
297
+ (targetContainer || document.head).appendChild(style);
261
298
  }
262
299
  };
263
300
  $[0] = key;
264
- $[1] = styles2;
265
- $[2] = t0;
301
+ $[1] = portalContainer;
302
+ $[2] = styles2;
303
+ $[3] = t0;
266
304
  } else {
267
- t0 = $[2];
305
+ t0 = $[3];
268
306
  }
269
307
  let t1;
270
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
308
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
271
309
  t1 = [];
272
- $[3] = t1;
310
+ $[4] = t1;
273
311
  } else {
274
- t1 = $[3];
312
+ t1 = $[4];
275
313
  }
276
314
  useEffect(t0, t1);
277
315
  }
@@ -360,38 +398,6 @@ function useIconStyles(t0) {
360
398
  font-variation-settings: 'FILL' ${fill ? 1 : 0}, 'wght' ${weight}, 'GRAD' ${grad}, 'opsz' ${opticalSize};
361
399
  }`);
362
400
  }
363
- const PortalContainerContext = createContext(void 0);
364
- function PortalContainerProvider(t0) {
365
- const $ = c(5);
366
- const {
367
- container,
368
- children
369
- } = t0;
370
- let t1;
371
- if ($[0] !== container) {
372
- t1 = {
373
- container
374
- };
375
- $[0] = container;
376
- $[1] = t1;
377
- } else {
378
- t1 = $[1];
379
- }
380
- let t2;
381
- if ($[2] !== children || $[3] !== t1) {
382
- t2 = /* @__PURE__ */ jsx(PortalContainerContext.Provider, { value: t1, children });
383
- $[2] = children;
384
- $[3] = t1;
385
- $[4] = t2;
386
- } else {
387
- t2 = $[4];
388
- }
389
- return t2;
390
- }
391
- function usePortalContainer() {
392
- const context = useContext(PortalContainerContext);
393
- return context?.container ?? null;
394
- }
395
401
  const Collapse = React__default.memo((t0) => {
396
402
  const $ = c(9);
397
403
  const {