@flytedan/flytebot-design-system 0.41.0 → 0.42.0

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
@@ -1013,54 +1013,17 @@ function Collapsible({
1013
1013
  }
1014
1014
 
1015
1015
  // src/components/surfaces/Drawer.tsx
1016
- var React5 = __toESM(require("react"), 1);
1016
+ var React6 = __toESM(require("react"), 1);
1017
1017
  var import_react_dom3 = require("react-dom");
1018
- var import_jsx_runtime8 = require("react/jsx-runtime");
1019
- function Drawer({ open = true, title, onClose, footer, children, className = "", ...rest }) {
1020
- const zIndex = useOverlayLayer(open);
1021
- const [closing, setClosing] = React5.useState(false);
1022
- const close = React5.useCallback(() => {
1023
- if (!onClose) return;
1024
- setClosing(true);
1025
- setTimeout(onClose, 210);
1026
- }, [onClose]);
1027
- React5.useEffect(() => {
1028
- if (!open || !onClose) return;
1029
- const h = (e) => {
1030
- if (e.key === "Escape") close();
1031
- };
1032
- document.addEventListener("keydown", h);
1033
- return () => document.removeEventListener("keydown", h);
1034
- }, [open, onClose, close]);
1035
- if (!open) return null;
1036
- return (0, import_react_dom3.createPortal)(
1037
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(LayerProvider, { zIndex, children: [
1038
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "fd-scrim" + (closing ? " is-closing" : ""), style: { display: "block", zIndex: zIndex - LAYER_STEP }, onClick: close }),
1039
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { className: ["fd-drawer", closing ? "is-closing" : "", className].filter(Boolean).join(" "), role: "dialog", "aria-modal": "true", ...rest, style: { zIndex }, children: [
1040
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "fd-card-head", style: { flex: "none" }, children: [
1041
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "fd-card-head-title", title: truncationTitle(title), children: title }),
1042
- onClose ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "fd-btn-icon", "aria-label": "Close", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { className: "ph ph-x" }) }) : null
1043
- ] }),
1044
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: "1 1 auto", minHeight: 0, overflow: "auto", padding: 20 }, children }),
1045
- footer ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "fd-card-foot", style: { flex: "none" }, children: typeof footer === "function" ? footer(close) : footer }) : null
1046
- ] })
1047
- ] }),
1048
- document.body
1049
- );
1050
- }
1051
-
1052
- // src/components/surfaces/Modal.tsx
1053
- var React7 = __toESM(require("react"), 1);
1054
- var import_react_dom4 = require("react-dom");
1055
1018
 
1056
1019
  // src/kits/useFocusTrap.ts
1057
- var React6 = __toESM(require("react"), 1);
1020
+ var React5 = __toESM(require("react"), 1);
1058
1021
  var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
1059
1022
  function getFocusable(container) {
1060
1023
  return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
1061
1024
  }
1062
1025
  function useFocusTrap(containerRef, active) {
1063
- React6.useEffect(() => {
1026
+ React5.useEffect(() => {
1064
1027
  if (!active) return;
1065
1028
  const container = containerRef.current;
1066
1029
  if (!container) return;
@@ -1096,7 +1059,46 @@ function useFocusTrap(containerRef, active) {
1096
1059
  }, [active, containerRef]);
1097
1060
  }
1098
1061
 
1062
+ // src/components/surfaces/Drawer.tsx
1063
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1064
+ function Drawer({ open = true, title, onClose, footer, children, className = "", ...rest }) {
1065
+ const zIndex = useOverlayLayer(open);
1066
+ const asideRef = React6.useRef(null);
1067
+ useFocusTrap(asideRef, !!open);
1068
+ const [closing, setClosing] = React6.useState(false);
1069
+ const close = React6.useCallback(() => {
1070
+ if (!onClose) return;
1071
+ setClosing(true);
1072
+ setTimeout(onClose, 210);
1073
+ }, [onClose]);
1074
+ React6.useEffect(() => {
1075
+ if (!open || !onClose) return;
1076
+ const h = (e) => {
1077
+ if (e.key === "Escape") close();
1078
+ };
1079
+ document.addEventListener("keydown", h);
1080
+ return () => document.removeEventListener("keydown", h);
1081
+ }, [open, onClose, close]);
1082
+ if (!open) return null;
1083
+ return (0, import_react_dom3.createPortal)(
1084
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(LayerProvider, { zIndex, children: [
1085
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "fd-scrim" + (closing ? " is-closing" : ""), style: { display: "block", zIndex: zIndex - LAYER_STEP }, onClick: close }),
1086
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { ref: asideRef, className: ["fd-drawer", closing ? "is-closing" : "", className].filter(Boolean).join(" "), role: "dialog", "aria-modal": "true", ...rest, style: { zIndex }, children: [
1087
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "fd-card-head", style: { flex: "none" }, children: [
1088
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "fd-card-head-title", title: truncationTitle(title), children: title }),
1089
+ onClose ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "fd-btn-icon", "aria-label": "Close", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("i", { className: "ph ph-x" }) }) : null
1090
+ ] }),
1091
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: "1 1 auto", minHeight: 0, overflow: "auto", padding: 20 }, children }),
1092
+ footer ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "fd-card-foot", style: { flex: "none" }, children: typeof footer === "function" ? footer(close) : footer }) : null
1093
+ ] })
1094
+ ] }),
1095
+ document.body
1096
+ );
1097
+ }
1098
+
1099
1099
  // src/components/surfaces/Modal.tsx
1100
+ var React7 = __toESM(require("react"), 1);
1101
+ var import_react_dom4 = require("react-dom");
1100
1102
  var import_jsx_runtime9 = require("react/jsx-runtime");
1101
1103
  function Modal({ open = true, title, description, onClose, footer, wide = false, children, className = "", ...rest }) {
1102
1104
  const [closing, setClosing] = React7.useState(false);
@@ -7301,14 +7303,14 @@ function AccountMenu({
7301
7303
  className = "",
7302
7304
  ...rest
7303
7305
  }) {
7304
- const { user, roles, can: can2, signOut: ctxSignOut, demo } = useSessionContext();
7306
+ const { user, roles, can: can2, signOut: ctxSignOut, demo, pending } = useSessionContext();
7305
7307
  const [open, setOpen] = React43.useState(false);
7306
7308
  const [switching, setSwitching] = React43.useState(false);
7307
7309
  const [signingOut, setSigningOut] = React43.useState(false);
7308
7310
  const [signOutError, setSignOutError] = React43.useState(null);
7309
7311
  const ref = React43.useRef(null);
7310
- const visibleLinks = links.filter((l) => !l.perm || can2(l.perm));
7311
- const visibleGroups = groups.map((g) => ({ label: g.label, links: g.links.filter((l) => !l.perm || can2(l.perm)) })).filter((g) => g.links.length);
7312
+ const visibleLinks = links.filter((l) => !l.perm || !pending && can2(l.perm));
7313
+ const visibleGroups = groups.map((g) => ({ label: g.label, links: g.links.filter((l) => !l.perm || !pending && can2(l.perm)) })).filter((g) => g.links.length);
7312
7314
  const closeMenu = () => {
7313
7315
  setOpen(false);
7314
7316
  setSignOutError(null);
@@ -10620,6 +10622,7 @@ function GatePending({ compact: compact3 = false, className = "" }) {
10620
10622
  "div",
10621
10623
  {
10622
10624
  className: ["fd-stack", className].filter(Boolean).join(" "),
10625
+ role: "status",
10623
10626
  style: {
10624
10627
  gap: 10,
10625
10628
  alignItems: "flex-start",
@@ -10669,14 +10672,14 @@ function FeatureGate({
10669
10672
  bypassPerm = "flags.manage"
10670
10673
  }) {
10671
10674
  SessionKit.useSession();
10672
- const { can: can2 } = useSessionContext();
10675
+ const { can: can2, pending } = useSessionContext();
10673
10676
  const rt = useFeatureStatus(flag);
10674
10677
  if (!SessionKit.isEnabled(flag)) return fallback;
10675
10678
  if (rt.complete || rt.mode === "test") return children;
10676
10679
  if (!preview) return fallback;
10677
10680
  const f = SessionKit.findFlag(flag) || {};
10678
10681
  const missing = rt.missing || [];
10679
- const canBypass = bypassPerm === null ? false : !bypassPerm || can2(bypassPerm);
10682
+ const canBypass = pending ? false : bypassPerm === null ? false : !bypassPerm || can2(bypassPerm);
10680
10683
  return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
10681
10684
  ComingSoon,
10682
10685
  {
@@ -10696,7 +10699,10 @@ function FeatureGate({
10696
10699
  );
10697
10700
  }
10698
10701
  function PermissionHint({ perm, children }) {
10699
- const { can: can2 } = useSessionContext();
10702
+ const { can: can2, pending } = useSessionContext();
10703
+ if (pending) {
10704
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { title: "Access can't be verified right now", style: { display: "inline-flex", opacity: 0.45, cursor: "not-allowed" }, "aria-disabled": "true", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { style: { pointerEvents: "none" }, children }) });
10705
+ }
10700
10706
  if (can2(perm)) return children;
10701
10707
  return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
10702
10708
  "span",