@flytedan/flytebot-design-system 0.12.2 → 0.12.3

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.cjs CHANGED
@@ -388,6 +388,16 @@ var portal = (node) => {
388
388
  if (typeof document !== "undefined") return (0, import_react_dom.createPortal)(node, document.body);
389
389
  return node;
390
390
  };
391
+ var ROOT_LAYER = 0;
392
+ var LAYER_STEP = 10;
393
+ var LayerContext = React.createContext(ROOT_LAYER);
394
+ var useLayer = () => React.useContext(LayerContext);
395
+ var useOverlayLayer = (base) => {
396
+ const parent = useLayer();
397
+ return parent === ROOT_LAYER ? base : parent + LAYER_STEP;
398
+ };
399
+ var LayerProvider = ({ zIndex, children }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LayerContext.Provider, { value: zIndex, children });
400
+ var POPOVER_BASE = 140;
391
401
  function Popover({
392
402
  open,
393
403
  anchorRef,
@@ -424,6 +434,7 @@ function Popover({
424
434
  layerRef: ref
425
435
  });
426
436
  const restore = React.useRef(null);
437
+ const zIndex = useOverlayLayer(POPOVER_BASE);
427
438
  React.useEffect(() => {
428
439
  if (!open) return;
429
440
  restore.current = typeof document !== "undefined" ? document.activeElement : null;
@@ -462,7 +473,7 @@ function Popover({
462
473
  }, [open, closeOnOutside, closeOnEscape, onClose, anchorRef, triggerRef]);
463
474
  if (!open || !pos) return null;
464
475
  return portal(
465
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
476
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LayerProvider, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
466
477
  "div",
467
478
  {
468
479
  ref,
@@ -492,8 +503,12 @@ function Popover({
492
503
  // ordinary content that simply happens to be taller than some fixed number.
493
504
  maxHeight: maxHeight != null ? Math.min(maxHeight, pos.maxH) : pos.maxH,
494
505
  transformOrigin: pos.side === "top" ? "bottom center" : "top center",
495
- zIndex: 140,
496
- ...style
506
+ // Last, and always: a caller's `style` (Select, DatePicker, TimePicker all pass
507
+ // one) must never be able to clobber the computed layer — that silent override
508
+ // via object-spread order is exactly how the Select listbox (130) ended up
509
+ // fixed below the Popover (140) it opens from. zIndex is never a caller concern.
510
+ ...style,
511
+ zIndex
497
512
  },
498
513
  children: [
499
514
  header != null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "fd-pop-header", children: header }) : null,
@@ -501,7 +516,7 @@ function Popover({
501
516
  footer != null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "fd-pop-footer", children: footer }) : null
502
517
  ]
503
518
  }
504
- )
519
+ ) })
505
520
  );
506
521
  }
507
522
  var isItem = (it) => !!it && it.kind !== "separator" && it.kind !== "section" && it.kind !== "custom" && !it.disabled;
@@ -820,7 +835,9 @@ function Collapsible({
820
835
  var React3 = __toESM(require("react"), 1);
821
836
  var import_react_dom2 = require("react-dom");
822
837
  var import_jsx_runtime7 = require("react/jsx-runtime");
838
+ var DRAWER_BASE = 90;
823
839
  function Drawer({ open = true, title, onClose, footer, children, className = "", ...rest }) {
840
+ const zIndex = useOverlayLayer(DRAWER_BASE);
824
841
  const [closing, setClosing] = React3.useState(false);
825
842
  const close = React3.useCallback(() => {
826
843
  if (!onClose) return;
@@ -837,9 +854,9 @@ function Drawer({ open = true, title, onClose, footer, children, className = "",
837
854
  }, [open, onClose, close]);
838
855
  if (!open) return null;
839
856
  return (0, import_react_dom2.createPortal)(
840
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
841
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "fd-scrim" + (closing ? " is-closing" : ""), style: { display: "block" }, onClick: close }),
842
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { className: ["fd-drawer", closing ? "is-closing" : "", className].filter(Boolean).join(" "), role: "dialog", "aria-modal": "true", ...rest, children: [
857
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(LayerProvider, { zIndex, children: [
858
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "fd-scrim" + (closing ? " is-closing" : ""), style: { display: "block", zIndex: zIndex - LAYER_STEP }, onClick: close }),
859
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { className: ["fd-drawer", closing ? "is-closing" : "", className].filter(Boolean).join(" "), role: "dialog", "aria-modal": "true", ...rest, style: { zIndex }, children: [
843
860
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "fd-card-head", style: { flex: "none" }, children: [
844
861
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "fd-card-head-title", children: title }),
845
862
  onClose ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "fd-btn-icon", "aria-label": "Close", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("i", { className: "ph ph-x" }) }) : null
@@ -1328,6 +1345,7 @@ function Toast({ title, children, tone = "success", onUndo, onDismiss, className
1328
1345
  // src/components/feedback/Tooltip.tsx
1329
1346
  var React6 = __toESM(require("react"), 1);
1330
1347
  var import_jsx_runtime24 = require("react/jsx-runtime");
1348
+ var TOOLTIP_BASE = 150;
1331
1349
  var CLOSE_DELAY_MS = 120;
1332
1350
  function Tooltip({ label, placement = "top", children, className = "" }) {
1333
1351
  const anchorRef = React6.useRef(null);
@@ -1371,6 +1389,7 @@ function Tooltip({ label, placement = "top", children, className = "" }) {
1371
1389
  layerRef: bubbleRef,
1372
1390
  onDetach: hide
1373
1391
  });
1392
+ const zIndex = useOverlayLayer(TOOLTIP_BASE);
1374
1393
  React6.useEffect(() => {
1375
1394
  if (!open) return;
1376
1395
  const key = (e) => {
@@ -1434,7 +1453,7 @@ function Tooltip({ label, placement = "top", children, className = "" }) {
1434
1453
  ref: bubbleRef,
1435
1454
  role: "tooltip",
1436
1455
  className: ["fd-tooltip", pos.side === "bottom" ? "is-below" : "", className].filter(Boolean).join(" "),
1437
- style: { left: pos.left, top: pos.top == null ? "auto" : pos.top, bottom: pos.bottom == null ? "auto" : pos.bottom },
1456
+ style: { left: pos.left, top: pos.top == null ? "auto" : pos.top, bottom: pos.bottom == null ? "auto" : pos.bottom, zIndex },
1438
1457
  onPointerEnter: (e) => {
1439
1458
  if (isMouse(e)) cancelClose();
1440
1459
  },
@@ -3847,7 +3866,7 @@ function Select({
3847
3866
  matchWidth: "min",
3848
3867
  minWidth: 260,
3849
3868
  role: "presentation",
3850
- style: { maxWidth: 380, zIndex: 130 },
3869
+ style: { maxWidth: 380 },
3851
3870
  header: hasSearch ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "fd-pop-search", children: [
3852
3871
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("i", { className: "ph ph-magnifying-glass", style: { color: "var(--text-muted)", fontSize: 14 } }),
3853
3872
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
@@ -4111,7 +4130,7 @@ function DatePicker({ label, help, error, required = false, disabled = false, ra
4111
4130
  placement: "bottom-start",
4112
4131
  offset: 6,
4113
4132
  role: "presentation",
4114
- style: { width: "max-content", zIndex: 130 },
4133
+ style: { width: "max-content" },
4115
4134
  children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4116
4135
  Calendar,
4117
4136
  {
@@ -4263,7 +4282,6 @@ function TimePicker({ label, help, error, required = false, disabled = false, va
4263
4282
  offset: 6,
4264
4283
  width: 262,
4265
4284
  role: "presentation",
4266
- style: { zIndex: 130 },
4267
4285
  footer: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(React24.Fragment, { children: [
4268
4286
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
4269
4287
  "button",