@zealakit/overlay-react 1.0.0 → 1.1.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.
Files changed (83) hide show
  1. package/README.md +1 -0
  2. package/dist/animation/presence.js +3 -2
  3. package/dist/components/arrow.js +2 -0
  4. package/dist/components/context-menu/content.js +1 -1
  5. package/dist/components/context-menu/context-menu.js +2 -12
  6. package/dist/components/context-menu/index.d.ts +4 -4
  7. package/dist/components/context-menu/index.js +2 -2
  8. package/dist/components/context-menu/items.js +3 -3
  9. package/dist/components/context-menu/menu-navigation.js +22 -6
  10. package/dist/components/context-menu/menu-surface.d.ts +4 -4
  11. package/dist/components/context-menu/menu-surface.js +10 -11
  12. package/dist/components/context-menu/sub.d.ts +1 -1
  13. package/dist/components/context-menu/sub.js +3 -13
  14. package/dist/components/context-menu/trigger.js +0 -1
  15. package/dist/components/dialog/content.d.ts +3 -3
  16. package/dist/components/dialog/content.js +13 -15
  17. package/dist/components/dialog/dialog.js +1 -1
  18. package/dist/components/dialog/helpers.js +1 -0
  19. package/dist/components/dialog/index.d.ts +1 -1
  20. package/dist/components/dialog/trigger.js +2 -0
  21. package/dist/components/popover/content.d.ts +24 -24
  22. package/dist/components/popover/content.js +13 -17
  23. package/dist/components/popover/helpers.js +1 -0
  24. package/dist/components/popover/index.d.ts +2 -2
  25. package/dist/components/popover/index.js +1 -1
  26. package/dist/components/popover/popover.js +3 -1
  27. package/dist/components/portal.d.ts +1 -1
  28. package/dist/components/slot.js +1 -4
  29. package/dist/components/tooltip/content.d.ts +2 -2
  30. package/dist/components/tooltip/content.js +1 -3
  31. package/dist/components/tooltip/index.d.ts +5 -5
  32. package/dist/components/tooltip/index.js +4 -4
  33. package/dist/components/tooltip/provider.js +2 -2
  34. package/dist/components/tooltip/tooltip.js +19 -28
  35. package/dist/hooks/use-layer.js +4 -4
  36. package/dist/hooks/use-overlay.js +4 -4
  37. package/dist/hooks/use-positioner.js +3 -12
  38. package/dist/index.d.ts +4 -4
  39. package/dist/index.js +4 -4
  40. package/dist/vendor/core/animation/keyframes.d.ts +12 -3
  41. package/dist/vendor/core/animation/keyframes.js +63 -25
  42. package/dist/vendor/core/animation/run-animation.d.ts +1 -1
  43. package/dist/vendor/core/animation/run-animation.js +5 -10
  44. package/dist/vendor/core/controller/animator.js +2 -2
  45. package/dist/vendor/core/controller/context-menu-behavior.js +48 -37
  46. package/dist/vendor/core/controller/overlay-controller.d.ts +1 -1
  47. package/dist/vendor/core/controller/overlay-controller.js +52 -72
  48. package/dist/vendor/core/controller/tooltip-behavior.js +1 -3
  49. package/dist/vendor/core/controller/types.d.ts +15 -1
  50. package/dist/vendor/core/events/outside.d.ts +6 -3
  51. package/dist/vendor/core/events/outside.js +12 -25
  52. package/dist/vendor/core/events/pointer.d.ts +7 -7
  53. package/dist/vendor/core/events/pointer.js +7 -9
  54. package/dist/vendor/core/focus/focus.js +45 -105
  55. package/dist/vendor/core/layer/create-layer-stack.d.ts +14 -12
  56. package/dist/vendor/core/layer/create-layer-stack.js +114 -158
  57. package/dist/vendor/core/layer/create-layer.js +1 -2
  58. package/dist/vendor/core/layer/index.d.ts +1 -2
  59. package/dist/vendor/core/layer/index.js +1 -2
  60. package/dist/vendor/core/menu/index.d.ts +1 -1
  61. package/dist/vendor/core/menu/index.js +1 -1
  62. package/dist/vendor/core/menu/navigation.d.ts +0 -12
  63. package/dist/vendor/core/menu/navigation.js +0 -42
  64. package/dist/vendor/core/modal/background.js +13 -5
  65. package/dist/vendor/core/portal/index.d.ts +1 -1
  66. package/dist/vendor/core/portal/index.js +1 -1
  67. package/dist/vendor/core/positioning/compute.js +3 -3
  68. package/dist/vendor/core/positioning/coordinates.js +1 -1
  69. package/dist/vendor/core/positioning/create-positioner.d.ts +6 -3
  70. package/dist/vendor/core/positioning/create-positioner.js +86 -76
  71. package/dist/vendor/core/positioning/placement.js +1 -3
  72. package/dist/vendor/core/scroll-lock/scroll-lock.d.ts +8 -6
  73. package/dist/vendor/core/scroll-lock/scroll-lock.js +14 -60
  74. package/dist/vendor/core/types/animation.d.ts +10 -18
  75. package/dist/vendor/core/types/animation.js +3 -5
  76. package/dist/vendor/core/types/dismissal.d.ts +15 -2
  77. package/dist/vendor/core/types/geometry.d.ts +14 -5
  78. package/dist/vendor/core/types/layer.d.ts +2 -0
  79. package/dist/vendor/core/types/positioner.d.ts +8 -1
  80. package/dist/vendor/core/utils/global-state.js +6 -0
  81. package/package.json +4 -13
  82. package/dist/vendor/core/layer/manager.d.ts +0 -9
  83. package/dist/vendor/core/layer/manager.js +0 -157
@@ -1,4 +1,4 @@
1
- import { arrow as arrowMiddleware, autoUpdate as createAutoUpdate, computePosition as computeEnginePosition, flip as flipMiddleware, offset as offsetMiddleware, shift as shiftMiddleware, } from "@floating-ui/dom";
1
+ import { autoUpdate as engineAutoUpdate, computePosition as engineComputePosition, } from "@zealakit/ui-engine/position";
2
2
  import { isConnected } from "../utils/element.js";
3
3
  import { isElement } from "../utils/dom.js";
4
4
  import { parsePlacement } from "./placement.js";
@@ -29,44 +29,35 @@ function resolveOptions(patch) {
29
29
  arrow: patch.arrow ?? DEFAULT_OPTIONS.arrow,
30
30
  };
31
31
  }
32
- /** Drop `undefined` entries so a partial update cannot reset unrelated options. */
33
- function definedOptions(patch) {
34
- const entries = Object.entries(patch).filter(([, value]) => value !== undefined);
35
- return Object.fromEntries(entries);
36
- }
37
- function toClientRect(rect) {
38
- return {
39
- x: rect.x,
40
- y: rect.y,
41
- width: rect.width,
42
- height: rect.height,
43
- top: rect.y,
44
- right: rect.x + rect.width,
45
- bottom: rect.y + rect.height,
46
- left: rect.x,
47
- };
32
+ function referenceRect(reference) {
33
+ if (isElement(reference)) {
34
+ const rect = reference.getBoundingClientRect();
35
+ return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
36
+ }
37
+ return reference.getBoundingClientRect();
48
38
  }
49
39
  /**
50
- * Adapt core's minimal `VirtualElement` contract to the engine's shape.
40
+ * Adapt core's minimal virtual element to the engine's shape.
51
41
  *
52
- * The engine is an implementation detail; core only promises `x/y/width/height`.
42
+ * The engine is an implementation detail; core only promises x/y/width/height.
53
43
  */
54
44
  function toEngineReference(reference) {
55
45
  if (isElement(reference)) {
56
46
  return reference;
57
47
  }
58
48
  return {
59
- getBoundingClientRect: () => toClientRect(reference.getBoundingClientRect()),
60
- ...(reference.contextElement
61
- ? { contextElement: reference.contextElement }
62
- : {}),
49
+ getBoundingClientRect: () => reference.getBoundingClientRect(),
50
+ ...(reference.contextElement ? { contextElement: reference.contextElement } : {}),
63
51
  };
64
52
  }
65
53
  /**
66
- * Create a collision-aware positioning session.
54
+ * Create a collision-aware positioning session backed by
55
+ * `@zealakit/ui-engine/position`.
67
56
  *
68
- * Collision handling (flip/shift) is delegated to Floating UI but never leaks
69
- * through this API; adapters only see coordinates, placement, and strategy.
57
+ * The engine owns the placement math, flip/shift, and auto-update. Core keeps
58
+ * the overlay-facing API, normalizes overlay placements (including `-center`
59
+ * aliases), resolves the CSS strategy, and computes the arrow offset from the
60
+ * engine's measured rects (the engine deliberately ships no arrow middleware).
70
61
  */
71
62
  export function createPositioner(initial = {}) {
72
63
  let reference = initial.reference ?? null;
@@ -75,8 +66,44 @@ export function createPositioner(initial = {}) {
75
66
  let disposed = false;
76
67
  let updateId = 0;
77
68
  let stopAutoUpdate = null;
69
+ let lastApplied = { x: 0, y: 0 };
78
70
  const listeners = new Set();
79
- const compute = async () => {
71
+ const computeArrow = (currentReference, currentFloating, x, y, placement) => {
72
+ const arrowElement = options.arrow?.element;
73
+ if (!arrowElement || !isConnected(arrowElement)) {
74
+ return null;
75
+ }
76
+ const referenceBox = referenceRect(currentReference);
77
+ const floatingBox = currentFloating.getBoundingClientRect();
78
+ // The engine returns coordinates in the offset-parent space; the arrow only
79
+ // needs the relative move, so translate the measured rect by the delta.
80
+ const targetX = floatingBox.x + (x - lastApplied.x);
81
+ const targetY = floatingBox.y + (y - lastApplied.y);
82
+ const side = parsePlacement(placement).side;
83
+ const isXAxis = side === "top" || side === "bottom";
84
+ const key = isXAxis ? "x" : "y";
85
+ const referenceLength = isXAxis ? referenceBox.width : referenceBox.height;
86
+ const floatingLength = isXAxis ? floatingBox.width : floatingBox.height;
87
+ const arrowRect = arrowElement.getBoundingClientRect();
88
+ const arrowLength = isXAxis ? arrowRect.width : arrowRect.height;
89
+ const referenceStart = isXAxis ? referenceBox.x : referenceBox.y;
90
+ const targetStart = isXAxis ? targetX : targetY;
91
+ const startDiff = targetStart - referenceStart;
92
+ const endDiff = referenceStart + referenceLength - targetStart - floatingLength;
93
+ const centerToReference = endDiff / 2 - startDiff / 2;
94
+ const clientSize = (isXAxis
95
+ ? currentFloating.clientWidth
96
+ : currentFloating.clientHeight) || floatingLength;
97
+ const padding = options.arrow?.padding ?? 0;
98
+ const min = padding;
99
+ const max = clientSize - arrowLength - padding;
100
+ const center = clientSize / 2 - arrowLength / 2 + centerToReference;
101
+ const offset = Math.max(min, Math.min(max, center));
102
+ return key === "x"
103
+ ? { x: offset, centerOffset: center - offset }
104
+ : { y: offset, centerOffset: center - offset };
105
+ };
106
+ const computeSync = () => {
80
107
  if (disposed) {
81
108
  return null;
82
109
  }
@@ -93,56 +120,24 @@ export function createPositioner(initial = {}) {
93
120
  }
94
121
  try {
95
122
  const placement = parsePlacement(options.placement).placement;
96
- const boundary = options.boundary === "viewport"
97
- ? "clippingAncestors"
98
- : options.boundary;
99
- const rootBoundary = "viewport";
100
- const middleware = [
101
- offsetMiddleware({
102
- mainAxis: options.offset,
103
- crossAxis: options.alignOffset,
104
- }),
105
- ];
106
- if (options.flip) {
107
- middleware.push(flipMiddleware({
108
- padding: options.padding,
109
- boundary,
110
- rootBoundary,
111
- }));
112
- }
113
- if (options.shift) {
114
- middleware.push(shiftMiddleware({
115
- padding: options.padding,
116
- boundary,
117
- rootBoundary,
118
- }));
119
- }
120
- if (options.arrow?.element && isConnected(options.arrow.element)) {
121
- middleware.push(arrowMiddleware({
122
- element: options.arrow.element,
123
- padding: options.arrow.padding ?? 0,
124
- }));
125
- }
126
- const result = await computeEnginePosition(toEngineReference(currentReference), currentFloating, {
123
+ const strategy = resolveStrategy(currentReference, options.strategy);
124
+ const result = engineComputePosition(toEngineReference(currentReference), currentFloating, {
127
125
  placement,
128
- strategy: resolveStrategy(currentReference, options.strategy),
129
- middleware,
126
+ strategy,
127
+ offset: { mainAxis: options.offset, crossAxis: options.alignOffset },
128
+ flip: options.flip ? { padding: options.padding } : false,
129
+ shift: options.shift ? { padding: options.padding } : false,
130
+ padding: options.padding,
131
+ ...(options.boundary !== undefined ? { boundary: options.boundary } : {}),
130
132
  });
131
- const arrow = result.middlewareData.arrow;
133
+ const arrow = computeArrow(currentReference, currentFloating, result.x, result.y, result.placement);
134
+ lastApplied = { x: result.x, y: result.y };
132
135
  return {
133
136
  x: result.x,
134
137
  y: result.y,
135
138
  placement: result.placement,
136
139
  strategy: result.strategy,
137
- ...(arrow
138
- ? {
139
- arrow: {
140
- ...(typeof arrow.x === "number" ? { x: arrow.x } : {}),
141
- ...(typeof arrow.y === "number" ? { y: arrow.y } : {}),
142
- centerOffset: arrow.centerOffset ?? 0,
143
- },
144
- }
145
- : {}),
140
+ ...(arrow ? { arrow } : {}),
146
141
  };
147
142
  }
148
143
  catch {
@@ -156,7 +151,13 @@ export function createPositioner(initial = {}) {
156
151
  const id = ++updateId;
157
152
  const currentReference = reference;
158
153
  const currentFloating = floating;
159
- const result = await compute();
154
+ // Let a newer `update()` or option change supersede this one, matching the
155
+ // old async platform's behaviour.
156
+ await Promise.resolve();
157
+ if (disposed || id !== updateId) {
158
+ return null;
159
+ }
160
+ const result = computeSync();
160
161
  if (disposed || id !== updateId) {
161
162
  return null;
162
163
  }
@@ -186,9 +187,18 @@ export function createPositioner(initial = {}) {
186
187
  if (isElement(reference) && !isConnected(reference)) {
187
188
  return;
188
189
  }
189
- stopAutoUpdate = createAutoUpdate(toEngineReference(reference), floating, () => {
190
+ // The engine calls `update` once immediately; `refresh` already does that,
191
+ // so skip the synchronous first call to keep a single notification.
192
+ let skipInitial = true;
193
+ const stop = engineAutoUpdate(toEngineReference(reference), floating, () => {
194
+ if (skipInitial) {
195
+ skipInitial = false;
196
+ return;
197
+ }
190
198
  void update();
191
199
  });
200
+ skipInitial = false;
201
+ stopAutoUpdate = stop;
192
202
  };
193
203
  const refresh = () => {
194
204
  if (disposed) {
@@ -214,16 +224,16 @@ export function createPositioner(initial = {}) {
214
224
  return;
215
225
  }
216
226
  floating = next;
227
+ lastApplied = { x: 0, y: 0 };
217
228
  refresh();
218
229
  },
219
230
  setOptions(patch) {
220
231
  if (disposed) {
221
232
  return;
222
233
  }
223
- options = resolveOptions({
224
- ...options,
225
- ...definedOptions(patch),
226
- });
234
+ // `resolveOptions` falls back with `?? DEFAULT` for every key, so an
235
+ // explicit undefined in the patch resets it and an omitted key keeps it.
236
+ options = resolveOptions({ ...options, ...patch });
227
237
  refresh();
228
238
  },
229
239
  update,
@@ -21,9 +21,7 @@ export function parsePlacement(placement = DEFAULT_PLACEMENT) {
21
21
  throw new Error(`[overlay-core] Unknown placement alignment: "${align}"`);
22
22
  }
23
23
  return {
24
- placement: align === "center"
25
- ? rawSide
26
- : `${rawSide}-${align}`,
24
+ placement: align === "center" ? rawSide : `${rawSide}-${align}`,
27
25
  side: rawSide,
28
26
  align,
29
27
  };
@@ -1,12 +1,14 @@
1
1
  import type { Cleanup } from "../types/lifecycle.js";
2
2
  /**
3
- * Reference-counted body scroll lock for modal overlays.
3
+ * Reference-counted page scroll lock (spec §6).
4
4
  *
5
- * The first lock saves the current inline overflow/padding styles and applies
6
- * `overflow: hidden` plus scrollbar-width compensation. Nested locks only
7
- * increment a counter; the final release restores the original styles.
5
+ * Thin compatibility wrapper over the engine's `createScrollLock()`:
6
+ * - the engine locks `documentElement` (not `body`) and restores its inline
7
+ * `overflow` and `padding-right` exactly;
8
+ * - the count is page-wide, so nested dialogs and every adapter share it;
9
+ * - `documentRef` is kept only for signature compatibility. The engine locks
10
+ * the main document; another document is ignored with a development warning.
8
11
  *
9
- * This intentionally does not attach global event listeners. Callers own the
10
- * lock lifetime and must call the returned cleanup on close/unmount.
12
+ * `@deprecated use createScrollLock from @zealakit/ui-engine`
11
13
  */
12
14
  export declare function lockBodyScroll(documentRef?: Document): Cleanup;
@@ -1,68 +1,22 @@
1
- import { getGlobalState } from "../utils/global-state.js";
2
- const states = getGlobalState("scroll-lock", () => new WeakMap());
3
- function resolveDocument(documentRef) {
4
- if (documentRef?.body) {
5
- return documentRef;
6
- }
7
- return typeof document !== "undefined" && document.body ? document : null;
8
- }
1
+ import { createScrollLock } from "@zealakit/ui-engine";
9
2
  /**
10
- * Reference-counted body scroll lock for modal overlays.
3
+ * Reference-counted page scroll lock (spec §6).
11
4
  *
12
- * The first lock saves the current inline overflow/padding styles and applies
13
- * `overflow: hidden` plus scrollbar-width compensation. Nested locks only
14
- * increment a counter; the final release restores the original styles.
5
+ * Thin compatibility wrapper over the engine's `createScrollLock()`:
6
+ * - the engine locks `documentElement` (not `body`) and restores its inline
7
+ * `overflow` and `padding-right` exactly;
8
+ * - the count is page-wide, so nested dialogs and every adapter share it;
9
+ * - `documentRef` is kept only for signature compatibility. The engine locks
10
+ * the main document; another document is ignored with a development warning.
15
11
  *
16
- * This intentionally does not attach global event listeners. Callers own the
17
- * lock lifetime and must call the returned cleanup on close/unmount.
12
+ * `@deprecated use createScrollLock from @zealakit/ui-engine`
18
13
  */
19
14
  export function lockBodyScroll(documentRef) {
20
- const document_ = resolveDocument(documentRef);
21
- if (!document_) {
22
- return () => { };
23
- }
24
- const body = document_.body;
25
- const root = document_.documentElement;
26
- const view = document_.defaultView;
27
- let state = states.get(document_);
28
- if (!state) {
29
- const scrollbarGap = view
30
- ? Math.max(0, view.innerWidth - root.clientWidth)
31
- : 0;
32
- const currentPadding = view
33
- ? Number.parseFloat(view.getComputedStyle(body).paddingRight) || 0
34
- : 0;
35
- state = {
36
- count: 0,
37
- bodyOverflow: body.style.overflow,
38
- bodyPaddingRight: body.style.paddingRight,
39
- htmlOverflow: root.style.overflow,
40
- };
41
- states.set(document_, state);
42
- root.style.overflow = "hidden";
43
- body.style.overflow = "hidden";
44
- if (scrollbarGap > 0) {
45
- body.style.paddingRight = `${currentPadding + scrollbarGap}px`;
15
+ if (documentRef !== undefined && typeof document !== "undefined" && documentRef !== document) {
16
+ if (typeof process === "undefined" ? false : process.env.NODE_ENV !== "production") {
17
+ console.warn("[@zealakit/overlay-core] lockBodyScroll() ignores a non-page document; " +
18
+ "the engine locks the main document (§6).");
46
19
  }
47
20
  }
48
- state.count += 1;
49
- let released = false;
50
- return () => {
51
- if (released) {
52
- return;
53
- }
54
- released = true;
55
- const current = states.get(document_);
56
- if (!current) {
57
- return;
58
- }
59
- current.count -= 1;
60
- if (current.count > 0) {
61
- return;
62
- }
63
- body.style.overflow = current.bodyOverflow;
64
- body.style.paddingRight = current.bodyPaddingRight;
65
- root.style.overflow = current.htmlOverflow;
66
- states.delete(document_);
67
- };
21
+ return createScrollLock();
68
22
  }
@@ -1,4 +1,6 @@
1
+ import type { AnimationEasing, AnimationTiming, ResolvedAnimationTiming } from "@zealakit/ui-engine/presence";
1
2
  import type { Align, Side } from "./geometry.js";
3
+ export type { AnimationEasing, AnimationTimingFunction } from "@zealakit/ui-engine/presence";
2
4
  /**
3
5
  * Direction of built-in movement. For `fade` it is the direction the popup
4
6
  * travels (exit reverses it); for `expand` it is the direction it grows.
@@ -6,10 +8,6 @@ import type { Align, Side } from "./geometry.js";
6
8
  export type AnimationDirection = "up" | "down" | "left" | "right";
7
9
  /** Auto resolves from the final placement; explicit values take precedence. */
8
10
  export type AnimationDirectionSetting = AnimationDirection | "auto";
9
- /** Built-in timing presets. */
10
- export type AnimationTimingFunction = "ease-in-out" | "linear";
11
- /** Presets plus any valid CSS timing function (for example `cubic-bezier(...)`). */
12
- export type AnimationEasing = AnimationTimingFunction | "ease" | "ease-in" | "ease-out" | (string & {});
13
11
  /** Built-in presets plus consumer-defined animation. */
14
12
  export type AnimationType = "fade" | "expand" | "custom";
15
13
  /** CSS classes added for the enter/exit phase; your CSS owns the animation. */
@@ -39,31 +37,25 @@ export type CustomAnimationKeyframes = {
39
37
  };
40
38
  export type CustomAnimation = CustomAnimationClasses | CustomAnimationKeyframes;
41
39
  export declare function isCustomClasses(custom: CustomAnimation): custom is CustomAnimationClasses;
42
- export type AnimationConfig = {
43
- /** Defaults to true when a config object is passed. */
44
- enabled?: boolean;
40
+ /**
41
+ * Overlay's animation option: the engine timing fields (E37) plus overlay's own.
42
+ *
43
+ * Defaults: duration 160 ms, delay 0, easing `ease-in-out`; enabled when a
44
+ * config object is passed.
45
+ */
46
+ export type AnimationConfig = AnimationTiming & {
45
47
  /** `fade` (default), `expand` (grow from the anchor edge), or `custom`. */
46
48
  type?: AnimationType;
47
49
  /** Explicit direction; defaults to "auto" based on resolved placement. */
48
50
  direction?: AnimationDirectionSetting;
49
- /** Milliseconds. Defaults to 160. */
50
- duration?: number;
51
- /** Milliseconds. Defaults to 0. */
52
- delay?: number;
53
- /** CSS timing function. Defaults to "ease-in-out". */
54
- easing?: AnimationEasing;
55
51
  /** Required when type is "custom": CSS classes or Web Animations keyframes. */
56
52
  custom?: CustomAnimation;
57
53
  };
58
54
  /** Animation is disabled unless `true` or a config object is passed. */
59
55
  export type AnimationSetting = boolean | AnimationConfig;
60
- export type ResolvedAnimationConfig = {
61
- enabled: boolean;
56
+ export type ResolvedAnimationConfig = ResolvedAnimationTiming & {
62
57
  type: AnimationType;
63
58
  direction: AnimationDirectionSetting;
64
- duration: number;
65
- delay: number;
66
- easing: AnimationEasing;
67
59
  custom: CustomAnimation | null;
68
60
  };
69
61
  export declare const DEFAULT_ANIMATION_DURATION = 160;
@@ -14,21 +14,19 @@ function nonEmptyString(value) {
14
14
  return typeof value === "string" && value.trim() !== "";
15
15
  }
16
16
  function validKeyframes(value) {
17
- return (typeof value === "function" || (Array.isArray(value) && value.length > 0));
17
+ return typeof value === "function" || (Array.isArray(value) && value.length > 0);
18
18
  }
19
19
  function validCustom(custom) {
20
20
  if (!custom) {
21
21
  return null;
22
22
  }
23
23
  if (typeof custom.enter === "string") {
24
- return nonEmptyString(custom.enter) &&
25
- nonEmptyString(custom.exit)
24
+ return nonEmptyString(custom.enter) && nonEmptyString(custom.exit)
26
25
  ? custom
27
26
  : null;
28
27
  }
29
28
  const exit = custom.exit;
30
- return validKeyframes(custom.enter) &&
31
- (exit === undefined || validKeyframes(exit))
29
+ return validKeyframes(custom.enter) && (exit === undefined || validKeyframes(exit))
32
30
  ? custom
33
31
  : null;
34
32
  }
@@ -1,2 +1,15 @@
1
- /** Why a layer was closed. */
2
- export type DismissReason = "escape-key" | "outside-press" | "reference-press" | "imperative";
1
+ /**
2
+ * Why a layer was closed.
3
+ *
4
+ * Overlay's union is wider than the engine's `DismissReason`; the mapping is:
5
+ * - `"escape-key"`, `"outside-press"`, `"focus-outside"`, `"parent-dismissed"`
6
+ * are the engine's reasons, passed through unchanged;
7
+ * - `"reference-press"` (the trigger was pressed) and `"imperative"` (an app
8
+ * called `close()`) are overlay product reasons and never come from the
9
+ * engine.
10
+ */
11
+ export type DismissReason = "escape-key" | "outside-press" | "reference-press" | "imperative"
12
+ /** Engine: focus moved outside a linked focus scope. */
13
+ | "focus-outside"
14
+ /** Engine: an ancestor layer was released. */
15
+ | "parent-dismissed";
@@ -1,14 +1,23 @@
1
+ import type { Placement as EnginePlacement } from "@zealakit/ui-engine/position";
1
2
  /**
2
3
  * Placement primitives shared by every adapter.
3
4
  *
4
- * A placement is a side plus an optional alignment. A bare side (`"top"`) is
5
- * equivalent to `"top-center"`.
5
+ * The engine owns `Placement` and `Side` (BRD §5 rule 5). Overlay keeps its
6
+ * legacy `-center` spelling as an additive alias until its next major, because
7
+ * `"top-center"` used to be a valid overlay placement and the engine's
8
+ * `"top"` means the same thing.
6
9
  */
7
- export type Side = "top" | "right" | "bottom" | "left";
10
+ export type { Side } from "@zealakit/ui-engine/position";
8
11
  export type Align = "start" | "center" | "end";
9
- export type Placement = Side | `${Side}-${Align}`;
12
+ /**
13
+ * An overlay placement: every engine placement plus the legacy `-center` forms.
14
+ *
15
+ * @deprecated Prefer `Placement` from `@zealakit/ui-engine/position`; the
16
+ * `-center` aliases disappear in overlay's next major.
17
+ */
18
+ export type Placement = EnginePlacement | `${EnginePlacement}-center`;
10
19
  /** A placement after normalization: center alignment collapses to the bare side. */
11
- export type NormalizedPlacement = Side | `${Side}-start` | `${Side}-end`;
20
+ export type NormalizedPlacement = "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
12
21
  export type Size = {
13
22
  width: number;
14
23
  height: number;
@@ -76,6 +76,8 @@ export type LayerStackRegistration = {
76
76
  boundaries?: LayerBoundarySource;
77
77
  dismissOnEscape?: boolean;
78
78
  dismissOnOutsidePress?: boolean;
79
+ /** Stops the engine's outside-press walk at this layer (dialogs). */
80
+ modal?: boolean;
79
81
  onDismiss?: (reason: DismissReason) => void;
80
82
  };
81
83
  export type LayerStackOptions = {
@@ -62,11 +62,18 @@ export type PositionerListener = (result: PositionerResult) => void;
62
62
  * The instance owns no DOM of its own; it measures the supplied elements and
63
63
  * reports results. `dispose()` stops observers and drops subscribers.
64
64
  */
65
+ /**
66
+ * A live-options patch for the positioner. An explicit `undefined` resets that
67
+ * option to its default; an omitted key keeps the current value.
68
+ */
69
+ export type PositionerOptionsPatch = {
70
+ [K in keyof PositionerOptions]?: PositionerOptions[K] | undefined;
71
+ };
65
72
  export type Positioner = {
66
73
  readonly isDisposed: boolean;
67
74
  setReference(reference: ReferenceElement | null): void;
68
75
  setFloating(floating: FloatingElement | null): void;
69
- setOptions(options: Partial<PositionerOptions>): void;
76
+ setOptions(options: PositionerOptionsPatch): void;
70
77
  /** Measure now. Resolves `null` when elements are missing or detached. */
71
78
  update(): Promise<PositionerResult | null>;
72
79
  subscribe(listener: PositionerListener): Cleanup;
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Process-wide state shared by every copy of Core loaded on a page.
3
3
  *
4
+ * **This file now serves exactly one key: `modal-background`** (X6). Overlay's
5
+ * inert state stays local until a second package needs a modal (D31: quill's
6
+ * media picker or dashboard-grid's maximize triggers the move into the engine).
7
+ * Do not add a key here without a decision code; 01-1 removed `overlay-id` and
8
+ * `shared-layer-stack`.
9
+ *
4
10
  * Each public adapter ships its own bundled copy of Core, so module-level
5
11
  * variables would split per adapter (a React and a Vue overlay on the same
6
12
  * page would get separate layer stacks, scroll locks, and id counters). State
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zealakit/overlay-react",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A lightweight foundation for building floating, layered, and interactive headless UI components for React.",
5
5
  "keywords": [
6
6
  "overlay",
@@ -44,20 +44,11 @@
44
44
  },
45
45
  "./package.json": "./package.json"
46
46
  },
47
- "dependencies": {
48
- "@floating-ui/dom": "^1.8.0"
49
- },
47
+ "dependencies": {},
50
48
  "peerDependencies": {
51
49
  "react": "^18.0.0 || ^19.0.0",
52
- "react-dom": "^18.0.0 || ^19.0.0"
53
- },
54
- "devDependencies": {
55
- "@testing-library/react": "^16.3.3",
56
- "@types/react": "^19.3.0",
57
- "@types/react-dom": "^19.3.0",
58
- "happy-dom": "^21.0.4",
59
- "react": "^19.3.1",
60
- "react-dom": "^19.3.1"
50
+ "react-dom": "^18.0.0 || ^19.0.0",
51
+ "@zealakit/ui-engine": "^1.0.0-beta.1"
61
52
  },
62
53
  "main": "./dist/index.js",
63
54
  "module": "./dist/index.js",
@@ -1,9 +0,0 @@
1
- import type { LayerManager } from "../types/layer.js";
2
- /**
3
- * Create a minimal layer stack.
4
- *
5
- * Layers are ordered by registration (bottom → top). A child layer belongs to
6
- * an existing parent; unregistering a parent also removes its descendants.
7
- * The manager does not open, close, focus, or render layers.
8
- */
9
- export declare function createLayerManager(): LayerManager;