@flytedan/flytebot-design-system 0.45.0 → 0.46.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 +24 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -207,6 +207,7 @@ __export(index_exports, {
|
|
|
207
207
|
installFlytedeskFavicon: () => installFlytedeskFavicon,
|
|
208
208
|
isImage: () => isImage,
|
|
209
209
|
isSystemMessage: () => isSystemMessage,
|
|
210
|
+
isWithinLayerTree: () => isWithinLayerTree,
|
|
210
211
|
jobBucket: () => jobBucket,
|
|
211
212
|
languageLabel: () => languageLabel,
|
|
212
213
|
loadPrefs: () => loadPrefs,
|
|
@@ -342,11 +343,21 @@ var import_react_dom = require("react-dom");
|
|
|
342
343
|
// src/kits/layerStack.tsx
|
|
343
344
|
var React2 = __toESM(require("react"), 1);
|
|
344
345
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
345
|
-
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
346
|
+
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable]:not([contenteditable="false"])';
|
|
346
347
|
var LayerContext = React2.createContext(null);
|
|
347
348
|
var openLayers = /* @__PURE__ */ new Set();
|
|
348
349
|
var lastOrder = 0;
|
|
349
350
|
var pendingEscape = null;
|
|
351
|
+
var lastClosed = null;
|
|
352
|
+
function isOpener(el) {
|
|
353
|
+
return !!el && el !== document.body && el.isConnected;
|
|
354
|
+
}
|
|
355
|
+
function inheritedOpener() {
|
|
356
|
+
let l = lastClosed;
|
|
357
|
+
lastClosed = null;
|
|
358
|
+
for (; l; l = l.parent) if (isOpener(l.opener)) return l.opener;
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
350
361
|
function rank(layer) {
|
|
351
362
|
const path = [];
|
|
352
363
|
for (let l = layer; l; l = l.parent) if (l.order > 0) path.push(l.order);
|
|
@@ -432,11 +443,13 @@ function open(layer) {
|
|
|
432
443
|
}
|
|
433
444
|
openLayers.add(layer);
|
|
434
445
|
layer.order = ++lastOrder;
|
|
446
|
+
lastClosed = null;
|
|
435
447
|
if (layer.options.trap && !contains(scopeOf(layer), document.activeElement)) focusInto(layer);
|
|
436
448
|
}
|
|
437
449
|
function close(layer) {
|
|
438
450
|
openLayers.delete(layer);
|
|
439
451
|
layer.order = 0;
|
|
452
|
+
lastClosed = layer;
|
|
440
453
|
if (openLayers.size === 0) {
|
|
441
454
|
document.removeEventListener("keydown", onKeydownCapture, true);
|
|
442
455
|
document.removeEventListener("keydown", onKeydown);
|
|
@@ -454,7 +467,7 @@ function returnFocus(layer) {
|
|
|
454
467
|
focusInto(l);
|
|
455
468
|
return;
|
|
456
469
|
}
|
|
457
|
-
if (l.opener
|
|
470
|
+
if (isOpener(l.opener)) {
|
|
458
471
|
l.opener.focus({ preventScroll: true });
|
|
459
472
|
return;
|
|
460
473
|
}
|
|
@@ -465,7 +478,9 @@ function useStackedLayer(options) {
|
|
|
465
478
|
const [layer] = React2.useState(() => ({ parent, options, order: 0, opener: null }));
|
|
466
479
|
const { active } = options;
|
|
467
480
|
React2.useInsertionEffect(() => {
|
|
468
|
-
if (active)
|
|
481
|
+
if (!active) return;
|
|
482
|
+
const current2 = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
483
|
+
layer.opener = isOpener(current2) ? current2 : inheritedOpener();
|
|
469
484
|
}, [active, layer]);
|
|
470
485
|
React2.useLayoutEffect(() => {
|
|
471
486
|
layer.options = options;
|
|
@@ -484,6 +499,9 @@ function useStackedLayer(options) {
|
|
|
484
499
|
function StackedLayerProvider({ layer, children }) {
|
|
485
500
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LayerContext.Provider, { value: layer, children });
|
|
486
501
|
}
|
|
502
|
+
function isWithinLayerTree(layer, node) {
|
|
503
|
+
return contains(scopeOf(layer), node);
|
|
504
|
+
}
|
|
487
505
|
|
|
488
506
|
// src/components/actions/Popover.tsx
|
|
489
507
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -680,15 +698,14 @@ function Popover({
|
|
|
680
698
|
const away = (e) => {
|
|
681
699
|
if (!closeOnOutside) return;
|
|
682
700
|
const target = e.target;
|
|
683
|
-
if (
|
|
701
|
+
if (isWithinLayerTree(layer, target)) return;
|
|
684
702
|
const trigger = (triggerRef || anchorRef).current;
|
|
685
703
|
if (trigger && trigger.contains(target)) return;
|
|
686
|
-
if (e.target.closest && e.target.closest(".fd-pop")) return;
|
|
687
704
|
onClose && onClose();
|
|
688
705
|
};
|
|
689
706
|
document.addEventListener("pointerdown", away, true);
|
|
690
707
|
return () => document.removeEventListener("pointerdown", away, true);
|
|
691
|
-
}, [open2, closeOnOutside, onClose, anchorRef, triggerRef]);
|
|
708
|
+
}, [open2, closeOnOutside, onClose, anchorRef, triggerRef, layer]);
|
|
692
709
|
if (!open2 || !pos) return null;
|
|
693
710
|
return portal(
|
|
694
711
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LayerProvider, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StackedLayerProvider, { layer, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
@@ -14250,6 +14267,7 @@ function useDocumentTitle(routeTitle, appName) {
|
|
|
14250
14267
|
installFlytedeskFavicon,
|
|
14251
14268
|
isImage,
|
|
14252
14269
|
isSystemMessage,
|
|
14270
|
+
isWithinLayerTree,
|
|
14253
14271
|
jobBucket,
|
|
14254
14272
|
languageLabel,
|
|
14255
14273
|
loadPrefs,
|