@gfazioli/mantine-window 3.0.0 → 3.1.1

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.
@@ -5,6 +5,18 @@ export type SingleWindowLayout = 'snap-left' | 'snap-right' | 'snap-top' | 'snap
5
5
  export type GroupLayout = 'arrange-columns' | 'arrange-rows' | 'tile';
6
6
  /** All layout types */
7
7
  export type WindowLayout = SingleWindowLayout | GroupLayout;
8
+ /**
9
+ * Strategy for assigning z-index when a window is brought to front.
10
+ *
11
+ * - `'increment'` (legacy): monotonically increase a counter. Simple and preserves
12
+ * history of activation order across mounts, but the counter can grow unbounded
13
+ * and eventually exceed modal/menu z-indexes. A `maxZIndex` cap is recommended
14
+ * when using this strategy.
15
+ * - `'normalize'`: derive z-indexes from an ordered stack of window ids. The
16
+ * active window always gets the highest z-index and values stay compact
17
+ * (`initialZIndex .. initialZIndex + N - 1`). Recommended for long-running apps.
18
+ */
19
+ export type ZIndexStrategy = 'increment' | 'normalize';
8
20
  export interface WindowGroupWindowState {
9
21
  id: string;
10
22
  x: number;
@@ -50,6 +62,8 @@ export interface WindowGroupContextValue {
50
62
  expandAll: () => void;
51
63
  /** Get all registered window IDs */
52
64
  getWindowIds: () => string[];
65
+ /** Current stacking order (bottom to top). Read-only snapshot exposed for introspection. */
66
+ stackOrder: string[];
53
67
  /** Whether the tools button should be shown (true when inside a group) */
54
68
  showToolsButton: boolean;
55
69
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Factory, type BoxProps } from '@mantine/core';
3
- import { type WindowGroupContextValue, type WindowLayout } from './WindowGroup.context';
3
+ import { type WindowGroupContextValue, type WindowLayout, type ZIndexStrategy } from './WindowGroup.context';
4
4
  export interface WindowGroupProps extends BoxProps {
5
5
  /** Unique group identifier */
6
6
  id?: string;
@@ -10,6 +10,28 @@ export interface WindowGroupProps extends BoxProps {
10
10
  showToolsButton?: boolean;
11
11
  /** Initial layout to apply after windows have registered. Applied once on mount. */
12
12
  defaultLayout?: WindowLayout;
13
+ /**
14
+ * Starting z-index for the stacking context of this group. Defaults to 200 when
15
+ * `withinPortal` is true, 1 otherwise — matching the previous hardcoded values.
16
+ */
17
+ initialZIndex?: number;
18
+ /**
19
+ * Upper bound for z-index values. When the `'increment'` strategy would exceed this
20
+ * value, the counter wraps back to `initialZIndex`. Ignored when `'normalize'` is in
21
+ * use, since z-indexes are derived directly from the stacking order and already stay
22
+ * compact. Recommended when the group coexists with Mantine modals/menus.
23
+ */
24
+ maxZIndex?: number;
25
+ /**
26
+ * How z-indexes are assigned when a window is focused or registered.
27
+ *
28
+ * - `'increment'` (default): a counter monotonically increases. Preserves legacy
29
+ * behavior. Can exceed modal z-indexes unless `maxZIndex` is set.
30
+ * - `'normalize'`: z-indexes are derived from the stacking order. Values always
31
+ * stay within `initialZIndex .. initialZIndex + N - 1`. Recommended for
32
+ * long-running applications or when Mantine modals/menus are used alongside.
33
+ */
34
+ zIndexStrategy?: ZIndexStrategy;
13
35
  /** Ref to access group API imperatively (applyLayout, closeAll, etc.) */
14
36
  groupRef?: React.Ref<WindowGroupContextValue>;
15
37
  /** Called when a layout is applied */
@@ -1,4 +1,6 @@
1
1
  import type { WindowPosition, WindowSize } from '../Window';
2
+ /** @internal — test-only reset helper so counters don't leak across tests */
3
+ export declare function __resetStandaloneZIndexCounters(): void;
2
4
  export interface UseWindowStateOptions {
3
5
  id?: string;
4
6
  title?: string;
@@ -14,6 +16,8 @@ export interface UseWindowStateOptions {
14
16
  defaultY?: number | string;
15
17
  defaultWidth?: number | string;
16
18
  defaultHeight?: number | string;
19
+ initialZIndex?: number;
20
+ maxZIndex?: number;
17
21
  onClose?: () => void;
18
22
  onPositionChange?: (position: {
19
23
  x: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gfazioli/mantine-window",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "A Mantine extension component that renders draggable, resizable floating windows with persistent state, customizable boundaries, collapsible content, z-index management, and flexible control over position, size, and interaction modes. Includes a WindowGroup compound component for coordinated multi-window management with layout presets.",
5
5
  "homepage": "https://gfazioli.github.io/mantine-window/",
6
6
  "packageManager": "yarn@4.0.1",