@ai-matrx/design-system 0.43.0 → 0.44.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.
@@ -2,7 +2,7 @@
2
2
  "use client";
3
3
 
4
4
  // src/data-table/DataRowWindow.tsx
5
- import { useEffect as useEffect5, useState as useState8 } from "react";
5
+ import { useEffect as useEffect6, useState as useState8 } from "react";
6
6
 
7
7
  // src/dialog.tsx
8
8
  import * as DialogPrimitive from "@radix-ui/react-dialog";
@@ -124,6 +124,15 @@ function useIsMobile() {
124
124
  return isMobile;
125
125
  }
126
126
 
127
+ // src/layer-front.ts
128
+ var LAYER_FRONT_EVENT = "matrx:layer-front";
129
+ function announceLayerFront(element) {
130
+ if (typeof document === "undefined") return;
131
+ document.dispatchEvent(
132
+ new CustomEvent(LAYER_FRONT_EVENT, { detail: { element } })
133
+ );
134
+ }
135
+
127
136
  // src/dialog.tsx
128
137
  import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
129
138
  var DialogWindowedByDefaultContext = React4.createContext(false);
@@ -194,6 +203,8 @@ var DialogContent = React4.forwardRef(
194
203
  dismissOnOutsideClick = false,
195
204
  onInteractOutside,
196
205
  onEscapeKeyDown,
206
+ onPointerDownCapture,
207
+ onFocusCapture,
197
208
  style,
198
209
  ...props
199
210
  }, ref) => {
@@ -206,6 +217,24 @@ var DialogContent = React4.forwardRef(
206
217
  const [containerEl, setContainerEl] = React4.useState(
207
218
  null
208
219
  );
220
+ const stacks = windowed && windowedByDefault;
221
+ const [behind, setBehind] = React4.useState(false);
222
+ React4.useEffect(() => {
223
+ if (!stacks || !containerEl) return;
224
+ const onFront = (event) => {
225
+ const element = event.detail?.element ?? null;
226
+ if (element && (element === containerEl || containerEl.contains(element))) return;
227
+ setBehind(true);
228
+ };
229
+ document.addEventListener(LAYER_FRONT_EVENT, onFront);
230
+ announceLayerFront(containerEl);
231
+ return () => document.removeEventListener(LAYER_FRONT_EVENT, onFront);
232
+ }, [stacks, containerEl]);
233
+ const bringToFront = () => {
234
+ if (!stacks || !containerEl) return;
235
+ setBehind(false);
236
+ announceLayerFront(containerEl);
237
+ };
209
238
  const [offset, setOffset] = React4.useState({ x: 0, y: 0 });
210
239
  const dragRef = React4.useRef(null);
211
240
  const handle = React4.useMemo(() => {
@@ -264,10 +293,20 @@ var DialogContent = React4.forwardRef(
264
293
  // z=1000); staying below that boundary makes a newly focused window
265
294
  // usable without coupling the two systems.
266
295
  !isModal && !windowedByDefault && "z-[900]",
296
+ // Another layer came to the front after this window (layer-front.ts).
297
+ stacks && behind && "z-[999]",
267
298
  // Without an overlay the card needs its own separation from the page.
268
299
  windowed && "shadow-2xl ring-1 ring-border/60"
269
300
  ),
270
301
  style: windowed && (offset.x !== 0 || offset.y !== 0) ? { ...style, translate: `${offset.x}px ${offset.y}px` } : style,
302
+ onPointerDownCapture: (event) => {
303
+ onPointerDownCapture?.(event);
304
+ if (behind) bringToFront();
305
+ },
306
+ onFocusCapture: (event) => {
307
+ onFocusCapture?.(event);
308
+ if (behind) bringToFront();
309
+ },
271
310
  onInteractOutside: (event) => {
272
311
  onInteractOutside?.(event);
273
312
  if (windowed && !dismissOnOutsideClick) event.preventDefault();
@@ -3100,7 +3139,7 @@ function CopyButtons(props) {
3100
3139
 
3101
3140
  // src/data-table/MatrxUuidCell.tsx
3102
3141
  import {
3103
- useEffect as useEffect4,
3142
+ useEffect as useEffect5,
3104
3143
  useRef as useRef5,
3105
3144
  useState as useState7
3106
3145
  } from "react";
@@ -3172,7 +3211,7 @@ function MatrxUuidCell({
3172
3211
  const [opening, setOpening] = useState7(false);
3173
3212
  const [peekOpen, setPeekOpen] = useState7(false);
3174
3213
  const timer = useRef5(null);
3175
- useEffect4(
3214
+ useEffect5(
3176
3215
  () => () => {
3177
3216
  if (timer.current) clearTimeout(timer.current);
3178
3217
  },
@@ -3500,7 +3539,7 @@ function DataRowWindow({
3500
3539
  const hasTabs = hasEdit && children == null;
3501
3540
  const initialTab = defaultTab ?? (hasEdit ? "edit" : "view");
3502
3541
  const [tab, setTab] = useState8(initialTab);
3503
- useEffect5(() => {
3542
+ useEffect6(() => {
3504
3543
  if (!isOpen) return;
3505
3544
  setTab(defaultTab ?? (hasEdit ? "edit" : "view"));
3506
3545
  }, [isOpen, windowId, hasEdit, defaultTab]);