@cratis/components 4.41.5 → 4.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/compat-manifest.json +11 -11
- package/dist/esm/Chat/Kit/AnchoredOverlay.d.ts +4 -3
- package/dist/esm/Chat/Kit/AnchoredOverlay.d.ts.map +1 -1
- package/dist/esm/Chat/Kit/AnchoredOverlay.js +15 -47
- package/dist/esm/Chat/Kit/AnchoredOverlay.js.map +1 -1
- package/dist/esm/Chat/Kit/OverlayPlacement.d.ts +7 -0
- package/dist/esm/Chat/Kit/OverlayPlacement.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/OverlayPlacement.js +4 -0
- package/dist/esm/Chat/Kit/OverlayPlacement.js.map +1 -0
- package/dist/esm/Chat/Kit/OverlayPlacementOptions.d.ts +3 -0
- package/dist/esm/Chat/Kit/OverlayPlacementOptions.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/OverlayPlacementOptions.js +4 -0
- package/dist/esm/Chat/Kit/OverlayPlacementOptions.js.map +1 -0
- package/dist/esm/Chat/Kit/overlayGeometry.d.ts +5 -0
- package/dist/esm/Chat/Kit/overlayGeometry.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/overlayGeometry.js +47 -0
- package/dist/esm/Chat/Kit/overlayGeometry.js.map +1 -0
- package/dist/esm/Chat/Kit/readAnchorTheme.d.ts +3 -0
- package/dist/esm/Chat/Kit/readAnchorTheme.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/readAnchorTheme.js +12 -0
- package/dist/esm/Chat/Kit/readAnchorTheme.js.map +1 -0
- package/dist/esm/Chat/Kit/useOverlayLayer.d.ts +2 -0
- package/dist/esm/Chat/Kit/useOverlayLayer.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/useOverlayLayer.js +12 -0
- package/dist/esm/Chat/Kit/useOverlayLayer.js.map +1 -0
- package/dist/esm/Chat/Kit/useOverlayPlacement.d.ts +4 -0
- package/dist/esm/Chat/Kit/useOverlayPlacement.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/useOverlayPlacement.js +44 -0
- package/dist/esm/Chat/Kit/useOverlayPlacement.js.map +1 -0
- package/dist/esm/Chat/Kit/useOverlayTarget.d.ts +2 -0
- package/dist/esm/Chat/Kit/useOverlayTarget.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/useOverlayTarget.js +12 -0
- package/dist/esm/Chat/Kit/useOverlayTarget.js.map +1 -0
- package/dist/esm/Chat/Kit/useReactionPickerFocus.d.ts.map +1 -1
- package/dist/esm/Chat/Kit/useReactionPickerFocus.js +15 -10
- package/dist/esm/Chat/Kit/useReactionPickerFocus.js.map +1 -1
- package/dist/esm/DataPage/DataPage.d.ts +13 -7
- package/dist/esm/DataPage/DataPage.d.ts.map +1 -1
- package/dist/esm/DataPage/DataPage.js +6 -12
- package/dist/esm/DataPage/DataPage.js.map +1 -1
- package/dist/esm/DataPage/DataPageSelection.d.ts +19 -0
- package/dist/esm/DataPage/DataPageSelection.d.ts.map +1 -0
- package/dist/esm/DataPage/DataPageSelection.js +4 -0
- package/dist/esm/DataPage/DataPageSelection.js.map +1 -0
- package/dist/esm/DataPage/adaptMenuItem.d.ts +5 -0
- package/dist/esm/DataPage/adaptMenuItem.d.ts.map +1 -0
- package/dist/esm/DataPage/adaptMenuItem.js +22 -0
- package/dist/esm/DataPage/adaptMenuItem.js.map +1 -0
- package/dist/esm/DataPage/index.d.ts +1 -0
- package/dist/esm/DataPage/index.d.ts.map +1 -1
- package/dist/esm/Filter/measurePanelPlacement.d.ts +2 -11
- package/dist/esm/Filter/measurePanelPlacement.d.ts.map +1 -1
- package/dist/esm/Filter/measurePanelPlacement.js +3 -17
- package/dist/esm/Filter/measurePanelPlacement.js.map +1 -1
- package/dist/esm/Filter/usePanelPosition.js +2 -1
- package/dist/esm/Filter/usePanelPosition.js.map +1 -1
- package/dist/esm/renderer/fixedProbe.d.ts +11 -0
- package/dist/esm/renderer/fixedProbe.d.ts.map +1 -0
- package/dist/esm/renderer/fixedProbe.js +19 -0
- package/dist/esm/renderer/fixedProbe.js.map +1 -0
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
{
|
|
69
69
|
"name": "@cratis/components",
|
|
70
70
|
"role": "core",
|
|
71
|
-
"version": "4.
|
|
71
|
+
"version": "4.42.0",
|
|
72
72
|
"releaseMajorRange": ">=4 <5",
|
|
73
73
|
"independentRelease": false,
|
|
74
74
|
"private": false,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
{
|
|
93
93
|
"name": "@cratis/eslint-plugin-components",
|
|
94
94
|
"role": "eslint",
|
|
95
|
-
"version": "4.
|
|
95
|
+
"version": "4.42.0",
|
|
96
96
|
"releaseMajorRange": ">=4 <5",
|
|
97
97
|
"independentRelease": false,
|
|
98
98
|
"private": false,
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
{
|
|
106
106
|
"name": "@cratis/components.migrator",
|
|
107
107
|
"role": "migrator",
|
|
108
|
-
"version": "4.
|
|
108
|
+
"version": "4.42.0",
|
|
109
109
|
"releaseMajorRange": ">=4 <5",
|
|
110
110
|
"independentRelease": false,
|
|
111
111
|
"private": false,
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
{
|
|
117
117
|
"name": "@cratis/components.conformance",
|
|
118
118
|
"role": "conformance",
|
|
119
|
-
"version": "4.
|
|
119
|
+
"version": "4.42.0",
|
|
120
120
|
"releaseMajorRange": ">=4 <5",
|
|
121
121
|
"independentRelease": false,
|
|
122
122
|
"private": false,
|
|
123
123
|
"packageAccess": "public",
|
|
124
124
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.
|
|
125
|
+
"@cratis/components": "4.42.0",
|
|
126
126
|
"react": "^19.0.0",
|
|
127
127
|
"react-dom": "^19.0.0"
|
|
128
128
|
},
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "@cratis/components.mui",
|
|
134
134
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.
|
|
135
|
+
"version": "4.42.0",
|
|
136
136
|
"releaseMajorRange": ">=4 <5",
|
|
137
137
|
"independentRelease": false,
|
|
138
138
|
"private": false,
|
|
139
139
|
"packageAccess": "public",
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.
|
|
141
|
+
"@cratis/components": "4.42.0",
|
|
142
142
|
"@emotion/react": ">=11.5 <12",
|
|
143
143
|
"@emotion/styled": ">=11.11 <12",
|
|
144
144
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +188,13 @@
|
|
|
188
188
|
{
|
|
189
189
|
"name": "@cratis/components.primereact",
|
|
190
190
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.
|
|
191
|
+
"version": "4.42.0",
|
|
192
192
|
"releaseMajorRange": ">=4 <5",
|
|
193
193
|
"independentRelease": false,
|
|
194
194
|
"private": false,
|
|
195
195
|
"packageAccess": "public",
|
|
196
196
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.
|
|
197
|
+
"@cratis/components": "4.42.0",
|
|
198
198
|
"@primereact/core": ">=11 <12",
|
|
199
199
|
"@primereact/ui": ">=11 <12",
|
|
200
200
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +256,13 @@
|
|
|
256
256
|
{
|
|
257
257
|
"name": "@cratis/components.primereact10",
|
|
258
258
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.
|
|
259
|
+
"version": "4.42.0",
|
|
260
260
|
"releaseMajorRange": ">=4 <5",
|
|
261
261
|
"independentRelease": false,
|
|
262
262
|
"private": false,
|
|
263
263
|
"packageAccess": "public",
|
|
264
264
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.
|
|
265
|
+
"@cratis/components": "4.42.0",
|
|
266
266
|
"primereact": ">=10.9.9 <11",
|
|
267
267
|
"react": "^19.0.0",
|
|
268
268
|
"react-dom": "^19.0.0"
|
|
@@ -24,11 +24,12 @@ export interface AnchoredOverlayProps {
|
|
|
24
24
|
children: ReactNode;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Renders its children
|
|
27
|
+
* Renders its children in a fixed-position portal, anchored to an element on the board.
|
|
28
|
+
* The portal target is the overlay container resolved for the anchor: the owner document's body,
|
|
29
|
+
* or a dialog/top-layer container when the anchor lives inside one, layered above the nearest dialog.
|
|
28
30
|
* Board overlays (menus, pickers, tooltips) must float above everything: the slice columns use
|
|
29
31
|
* content-visibility paint containment for virtualization, which clips any absolutely-positioned
|
|
30
|
-
* descendant to the column box — portaling is what lets an overlay escape
|
|
31
|
-
* Cratis Dropdown takes with appendTo=document.body).
|
|
32
|
+
* descendant to the column box — portaling is what lets an overlay escape.
|
|
32
33
|
*/
|
|
33
34
|
export declare const AnchoredOverlay: React.FC<AnchoredOverlayProps>;
|
|
34
35
|
//# sourceMappingURL=AnchoredOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/AnchoredOverlay.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/AnchoredOverlay.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMpD,6DAA6D;AAC7D,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACjC,0CAA0C;IAC1C,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAEzC,oCAAoC;IACpC,IAAI,EAAE,OAAO,CAAC;IAEd,6EAA6E;IAC7E,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAE3B,qDAAqD;IACrD,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAE7B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,2BAA2B;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA6B1D,CAAC"}
|
|
@@ -1,56 +1,24 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useLayoutEffect } from 'react';
|
|
3
2
|
import { createPortal } from 'react-dom';
|
|
3
|
+
import { useOverlayTarget } from './useOverlayTarget.js';
|
|
4
|
+
import { useOverlayPlacement } from './useOverlayPlacement.js';
|
|
5
|
+
import { useOverlayLayer } from './useOverlayLayer.js';
|
|
4
6
|
|
|
5
|
-
const FLIP_THRESHOLD = 260;
|
|
6
|
-
function computePlacement(anchor, side, align, gap) {
|
|
7
|
-
if (side === 'left' || side === 'right') {
|
|
8
|
-
return {
|
|
9
|
-
top: anchor.top + anchor.height / 2,
|
|
10
|
-
left: side === 'right' ? anchor.right + gap : anchor.left - gap,
|
|
11
|
-
transform: side === 'right' ? 'translateY(-50%)' : 'translate(-100%, -50%)',
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const spaceBelow = window.innerHeight - anchor.bottom - gap;
|
|
15
|
-
const spaceAbove = anchor.top - gap;
|
|
16
|
-
const resolved = side === 'below'
|
|
17
|
-
? spaceBelow < FLIP_THRESHOLD && spaceAbove > spaceBelow
|
|
18
|
-
? 'above'
|
|
19
|
-
: 'below'
|
|
20
|
-
: spaceAbove < FLIP_THRESHOLD && spaceBelow > spaceAbove
|
|
21
|
-
? 'below'
|
|
22
|
-
: 'above';
|
|
23
|
-
const horizontal = align === 'center'
|
|
24
|
-
? { left: anchor.left + anchor.width / 2, transform: 'translateX(-50%)' }
|
|
25
|
-
: align === 'right'
|
|
26
|
-
? { left: anchor.right, transform: 'translateX(-100%)' }
|
|
27
|
-
: { left: anchor.left, transform: undefined };
|
|
28
|
-
return resolved === 'below'
|
|
29
|
-
? { top: anchor.bottom + gap, ...horizontal }
|
|
30
|
-
: { bottom: window.innerHeight - anchor.top + gap, ...horizontal };
|
|
31
|
-
}
|
|
32
7
|
const AnchoredOverlay = ({ anchorRef, open, side = 'below', align = 'left', gap = 8, children, }) => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const anchor = anchorRef.current?.getBoundingClientRect();
|
|
40
|
-
if (!anchor)
|
|
41
|
-
return;
|
|
42
|
-
setPlacement(computePlacement(anchor, side, align, gap));
|
|
43
|
-
}, [open, side, align, gap, anchorRef]);
|
|
44
|
-
if (!open || !placement)
|
|
8
|
+
const container = useOverlayTarget(open);
|
|
9
|
+
const placement = useOverlayPlacement(container, anchorRef, { side, align, gap });
|
|
10
|
+
const zIndex = useOverlayLayer();
|
|
11
|
+
if (!open)
|
|
45
12
|
return null;
|
|
46
|
-
|
|
13
|
+
if (!container)
|
|
14
|
+
return null;
|
|
15
|
+
if (!placement)
|
|
16
|
+
return null;
|
|
17
|
+
return createPortal(jsx("div", { "data-react-aria-top-layer": 'true', style: {
|
|
18
|
+
...placement,
|
|
47
19
|
position: 'fixed',
|
|
48
|
-
zIndex
|
|
49
|
-
|
|
50
|
-
bottom: placement.bottom,
|
|
51
|
-
left: placement.left,
|
|
52
|
-
transform: placement.transform,
|
|
53
|
-
}, children: children }), document.body);
|
|
20
|
+
zIndex,
|
|
21
|
+
}, children: children }), container);
|
|
54
22
|
};
|
|
55
23
|
|
|
56
24
|
export { AnchoredOverlay };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchoredOverlay.js","sources":["../../../../Chat/Kit/AnchoredOverlay.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { ReactNode, RefObject
|
|
1
|
+
{"version":3,"file":"AnchoredOverlay.js","sources":["../../../../Chat/Kit/AnchoredOverlay.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { ReactNode, RefObject } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useOverlayTarget } from './useOverlayTarget';\nimport { useOverlayPlacement } from './useOverlayPlacement';\nimport { useOverlayLayer } from './useOverlayLayer';\n\n/** The side of the anchor the overlay prefers to open on. */\nexport type AnchoredOverlaySide = 'above' | 'below' | 'left' | 'right';\n\n/** Horizontal alignment relative to the anchor (for above/below overlays). */\nexport type AnchoredOverlayAlign = 'left' | 'right' | 'center';\n\n/**\n * Props for a fixed-position portalled overlay anchored to an element on the board. Board overlays\n * (menus, pickers, tooltips) must float above everything: the slice columns use content-visibility\n * paint containment for virtualization, which clips any absolutely-positioned descendant to the\n * column box — portaling is what lets an overlay escape.\n */\nexport interface AnchoredOverlayProps {\n /** The element the overlay anchors to. */\n anchorRef: RefObject<HTMLElement | null>;\n\n /** Whether the overlay is shown. */\n open: boolean;\n\n /** The preferred side; above/below flip when the viewport leaves no room. */\n side?: AnchoredOverlaySide;\n\n /** Horizontal alignment for above/below overlays. */\n align?: AnchoredOverlayAlign;\n\n /** Gap between the anchor and the overlay in pixels. */\n gap?: number;\n\n /** The overlay content. */\n children: ReactNode;\n}\n\n/**\n * Renders its children in a fixed-position portal, anchored to an element on the board.\n * The portal target is the overlay container resolved for the anchor: the owner document's body,\n * or a dialog/top-layer container when the anchor lives inside one, layered above the nearest dialog.\n * Board overlays (menus, pickers, tooltips) must float above everything: the slice columns use\n * content-visibility paint containment for virtualization, which clips any absolutely-positioned\n * descendant to the column box — portaling is what lets an overlay escape.\n */\nexport const AnchoredOverlay: React.FC<AnchoredOverlayProps> = ({\n anchorRef,\n open,\n side = 'below',\n align = 'left',\n gap = 8,\n children,\n}) => {\n const container = useOverlayTarget(open);\n const placement = useOverlayPlacement(container, anchorRef, { side, align, gap });\n const zIndex = useOverlayLayer();\n\n if (!open) return null;\n if (!container) return null;\n if (!placement) return null;\n\n return createPortal(\n <div\n data-react-aria-top-layer='true'\n style={{\n ...placement,\n position: 'fixed',\n zIndex,\n }}\n >\n {children}\n </div>,\n container,\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAiDO,MAAM,eAAe,GAAmC,CAAC,EAC5D,SAAS,EACT,IAAI,EACJ,IAAI,GAAG,OAAO,EACd,KAAK,GAAG,MAAM,EACd,GAAG,GAAG,CAAC,EACP,QAAQ,GACX,KAAI;AACD,IAAA,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC;AACxC,IAAA,MAAM,SAAS,GAAG,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACjF,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;AAEhC,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;AACtB,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAE3B,IAAA,OAAO,YAAY,CACfA,GAAA,CAAA,KAAA,EAAA,EAAA,2BAAA,EAC8B,MAAM,EAChC,KAAK,EAAE;AACH,YAAA,GAAG,SAAS;AACZ,YAAA,QAAQ,EAAE,OAAO;YACjB,MAAM;AACT,SAAA,EAAA,QAAA,EAEA,QAAQ,EAAA,CACP,EACN,SAAS,CACZ;AACL;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayPlacement.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/OverlayPlacement.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayPlacement.js","sourceRoot":"","sources":["../../../../Chat/Kit/OverlayPlacement.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport interface OverlayPlacement {\n top?: number;\n bottom?: number;\n left: number;\n transform?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayPlacementOptions.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/OverlayPlacementOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAmB,CAAC;AAE9D,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayPlacementOptions.js","sourceRoot":"","sources":["../../../../Chat/Kit/OverlayPlacementOptions.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { AnchoredOverlayProps } from './AnchoredOverlay';\n\nexport type OverlayPlacementOptions = Required<Pick<AnchoredOverlayProps, 'side' | 'align' | 'gap'>>;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OverlayPlacement } from './OverlayPlacement.js';
|
|
2
|
+
import type { OverlayPlacementOptions } from './OverlayPlacementOptions.js';
|
|
3
|
+
export declare function computePlacement(anchor: DOMRect, options: OverlayPlacementOptions, viewportHeight: number): OverlayPlacement;
|
|
4
|
+
export declare function placementInContainer(probe: HTMLDivElement, placement: OverlayPlacement, viewportHeight: number): OverlayPlacement;
|
|
5
|
+
//# sourceMappingURL=overlayGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlayGeometry.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/overlayGeometry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA2B,CAAC;AA4BzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,GAAG,gBAAgB,CAK5H;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,GAAG,gBAAgB,CAUjI"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { measureProbe } from '../../renderer/fixedProbe.js';
|
|
2
|
+
|
|
3
|
+
const FLIP_THRESHOLD = 260;
|
|
4
|
+
function horizontalPlacement(anchor, align) {
|
|
5
|
+
if (align === 'center')
|
|
6
|
+
return { left: anchor.left + anchor.width / 2, transform: 'translateX(-50%)' };
|
|
7
|
+
if (align === 'right')
|
|
8
|
+
return { left: anchor.right, transform: 'translateX(-100%)' };
|
|
9
|
+
return { left: anchor.left };
|
|
10
|
+
}
|
|
11
|
+
function shouldFlip(preferredSpace, otherSpace) {
|
|
12
|
+
return preferredSpace < FLIP_THRESHOLD && otherSpace > preferredSpace;
|
|
13
|
+
}
|
|
14
|
+
function resolveVerticalSide(side, spaceBelow, spaceAbove) {
|
|
15
|
+
if (side === 'below')
|
|
16
|
+
return shouldFlip(spaceBelow, spaceAbove) ? 'above' : 'below';
|
|
17
|
+
return shouldFlip(spaceAbove, spaceBelow) ? 'below' : 'above';
|
|
18
|
+
}
|
|
19
|
+
function verticalPlacement(anchor, { side, align, gap }, viewportHeight) {
|
|
20
|
+
const resolved = resolveVerticalSide(side, viewportHeight - anchor.bottom - gap, anchor.top - gap);
|
|
21
|
+
const horizontal = horizontalPlacement(anchor, align);
|
|
22
|
+
return resolved === 'below'
|
|
23
|
+
? { top: anchor.bottom + gap, ...horizontal }
|
|
24
|
+
: { bottom: viewportHeight - anchor.top + gap, ...horizontal };
|
|
25
|
+
}
|
|
26
|
+
function computePlacement(anchor, options, viewportHeight) {
|
|
27
|
+
const { side, gap } = options;
|
|
28
|
+
if (side === 'right')
|
|
29
|
+
return { left: anchor.right + gap, top: anchor.top + anchor.height / 2, transform: 'translateY(-50%)' };
|
|
30
|
+
if (side === 'left')
|
|
31
|
+
return { left: anchor.left - gap, top: anchor.top + anchor.height / 2, transform: 'translate(-100%, -50%)' };
|
|
32
|
+
return verticalPlacement(anchor, options, viewportHeight);
|
|
33
|
+
}
|
|
34
|
+
function placementInContainer(probe, placement, viewportHeight) {
|
|
35
|
+
const { origin, bottom } = measureProbe(probe);
|
|
36
|
+
const scaleX = origin.width || 1;
|
|
37
|
+
const scaleY = origin.height || 1;
|
|
38
|
+
return {
|
|
39
|
+
...placement,
|
|
40
|
+
left: (placement.left - origin.left) / scaleX,
|
|
41
|
+
top: placement.top === undefined ? undefined : (placement.top - origin.top) / scaleY,
|
|
42
|
+
bottom: placement.bottom === undefined ? undefined : (bottom - viewportHeight + placement.bottom) / scaleY,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { computePlacement, placementInContainer };
|
|
47
|
+
//# sourceMappingURL=overlayGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlayGeometry.js","sources":["../../../../Chat/Kit/overlayGeometry.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { measureProbe } from '../../renderer/fixedProbe';\nimport type { OverlayPlacement } from './OverlayPlacement';\nimport type { OverlayPlacementOptions } from './OverlayPlacementOptions';\n\n/** Space on the preferred side under which an above/below overlay flips to the other side. */\nconst FLIP_THRESHOLD = 260;\n\nfunction horizontalPlacement(anchor: DOMRect, align: OverlayPlacementOptions['align']): Pick<OverlayPlacement, 'left' | 'transform'> {\n if (align === 'center') return { left: anchor.left + anchor.width / 2, transform: 'translateX(-50%)' };\n if (align === 'right') return { left: anchor.right, transform: 'translateX(-100%)' };\n return { left: anchor.left };\n}\n\nfunction shouldFlip(preferredSpace: number, otherSpace: number) {\n return preferredSpace < FLIP_THRESHOLD && otherSpace > preferredSpace;\n}\n\nfunction resolveVerticalSide(side: OverlayPlacementOptions['side'], spaceBelow: number, spaceAbove: number) {\n if (side === 'below') return shouldFlip(spaceBelow, spaceAbove) ? 'above' : 'below';\n return shouldFlip(spaceAbove, spaceBelow) ? 'below' : 'above';\n}\n\nfunction verticalPlacement(anchor: DOMRect, { side, align, gap }: OverlayPlacementOptions, viewportHeight: number): OverlayPlacement {\n const resolved = resolveVerticalSide(side, viewportHeight - anchor.bottom - gap, anchor.top - gap);\n const horizontal = horizontalPlacement(anchor, align);\n return resolved === 'below'\n ? { top: anchor.bottom + gap, ...horizontal }\n : { bottom: viewportHeight - anchor.top + gap, ...horizontal };\n}\n\nexport function computePlacement(anchor: DOMRect, options: OverlayPlacementOptions, viewportHeight: number): OverlayPlacement {\n const { side, gap } = options;\n if (side === 'right') return { left: anchor.right + gap, top: anchor.top + anchor.height / 2, transform: 'translateY(-50%)' };\n if (side === 'left') return { left: anchor.left - gap, top: anchor.top + anchor.height / 2, transform: 'translate(-100%, -50%)' };\n return verticalPlacement(anchor, options, viewportHeight);\n}\n\nexport function placementInContainer(probe: HTMLDivElement, placement: OverlayPlacement, viewportHeight: number): OverlayPlacement {\n const { origin, bottom } = measureProbe(probe);\n const scaleX = origin.width || 1;\n const scaleY = origin.height || 1;\n return {\n ...placement,\n left: (placement.left - origin.left) / scaleX,\n top: placement.top === undefined ? undefined : (placement.top - origin.top) / scaleY,\n bottom: placement.bottom === undefined ? undefined : (bottom - viewportHeight + placement.bottom) / scaleY,\n };\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readAnchorTheme.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/readAnchorTheme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAOlE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function readAnchorTheme(anchor) {
|
|
2
|
+
const computed = anchor.ownerDocument.defaultView?.getComputedStyle(anchor);
|
|
3
|
+
if (!computed)
|
|
4
|
+
return {};
|
|
5
|
+
const tokens = Object.fromEntries(Array.from(computed)
|
|
6
|
+
.filter(property => property.startsWith('--'))
|
|
7
|
+
.map(property => [property, computed.getPropertyValue(property)]));
|
|
8
|
+
return { ...tokens, colorScheme: computed.colorScheme };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { readAnchorTheme };
|
|
12
|
+
//# sourceMappingURL=readAnchorTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readAnchorTheme.js","sources":["../../../../Chat/Kit/readAnchorTheme.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { CSSProperties } from 'react';\n\nexport function readAnchorTheme(anchor: HTMLElement): CSSProperties {\n const computed = anchor.ownerDocument.defaultView?.getComputedStyle(anchor);\n if (!computed) return {};\n const tokens = Object.fromEntries(Array.from(computed)\n .filter(property => property.startsWith('--'))\n .map(property => [property, computed.getPropertyValue(property)]));\n return { ...tokens, colorScheme: computed.colorScheme };\n}\n"],"names":[],"mappings":"AAKM,SAAU,eAAe,CAAC,MAAmB,EAAA;AAC/C,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC;AAC3E,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,EAAE;IACxB,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;SAChD,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;AAC5C,SAAA,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE;AAC3D;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlayLayer.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/useOverlayLayer.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,WAK9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useNearestDialogZIndex } from '../../renderer/DialogStackContext.js';
|
|
2
|
+
import { zIndexAboveDialog, OVERLAY_OFFSET } from '../../renderer/dialogStack.js';
|
|
3
|
+
|
|
4
|
+
function useOverlayLayer() {
|
|
5
|
+
const nearestDialogZIndex = useNearestDialogZIndex();
|
|
6
|
+
return nearestDialogZIndex === null
|
|
7
|
+
? 'var(--cratis-z-index-overlay, 1300)'
|
|
8
|
+
: zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { useOverlayLayer };
|
|
12
|
+
//# sourceMappingURL=useOverlayLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlayLayer.js","sources":["../../../../Chat/Kit/useOverlayLayer.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useNearestDialogZIndex } from '../../renderer/DialogStackContext';\nimport { OVERLAY_OFFSET, zIndexAboveDialog } from '../../renderer/dialogStack';\n\nexport function useOverlayLayer() {\n const nearestDialogZIndex = useNearestDialogZIndex();\n return nearestDialogZIndex === null\n ? 'var(--cratis-z-index-overlay, 1300)'\n : zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET);\n}\n"],"names":[],"mappings":";;;SAMgB,eAAe,GAAA;AAC3B,IAAA,MAAM,mBAAmB,GAAG,sBAAsB,EAAE;IACpD,OAAO,mBAAmB,KAAK;AAC3B,UAAE;AACF,UAAE,iBAAiB,CAAC,mBAAmB,EAAE,cAAc,CAAC;AAChE;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CSSProperties, type RefObject } from 'react';
|
|
2
|
+
import type { OverlayPlacementOptions } from './OverlayPlacementOptions.js';
|
|
3
|
+
export declare function useOverlayPlacement(container: HTMLElement | null, anchorRef: RefObject<HTMLElement | null>, { side, align, gap }: OverlayPlacementOptions): CSSProperties | undefined;
|
|
4
|
+
//# sourceMappingURL=useOverlayPlacement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlayPlacement.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/useOverlayPlacement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAA6B,MAAM,OAAO,CAAC;AAGtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA2B,CAAC;AA6BzE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,uBAAuB,6BAOzJ"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useState, useLayoutEffect } from 'react';
|
|
2
|
+
import { probeStyle } from '../../renderer/fixedProbe.js';
|
|
3
|
+
import { computePlacement, placementInContainer } from './overlayGeometry.js';
|
|
4
|
+
import { readAnchorTheme } from './readAnchorTheme.js';
|
|
5
|
+
|
|
6
|
+
function trackOverlayPosition(container, anchorRef, options, updatePosition) {
|
|
7
|
+
const ownerWindow = container.ownerDocument.defaultView;
|
|
8
|
+
if (!ownerWindow)
|
|
9
|
+
return;
|
|
10
|
+
const probe = container.ownerDocument.createElement('div');
|
|
11
|
+
probe.style.cssText = probeStyle;
|
|
12
|
+
container.append(probe);
|
|
13
|
+
const update = () => {
|
|
14
|
+
const anchor = anchorRef.current;
|
|
15
|
+
if (!anchor)
|
|
16
|
+
return;
|
|
17
|
+
const placement = computePlacement(anchor.getBoundingClientRect(), options, ownerWindow.innerHeight);
|
|
18
|
+
updatePosition({ ...readAnchorTheme(anchor), ...placementInContainer(probe, placement, ownerWindow.innerHeight) });
|
|
19
|
+
};
|
|
20
|
+
update();
|
|
21
|
+
ownerWindow.addEventListener('resize', update);
|
|
22
|
+
ownerWindow.addEventListener('scroll', update, true);
|
|
23
|
+
container.ownerDocument.addEventListener('animationend', update);
|
|
24
|
+
container.ownerDocument.addEventListener('transitionend', update);
|
|
25
|
+
return () => {
|
|
26
|
+
ownerWindow.removeEventListener('resize', update);
|
|
27
|
+
ownerWindow.removeEventListener('scroll', update, true);
|
|
28
|
+
container.ownerDocument.removeEventListener('animationend', update);
|
|
29
|
+
container.ownerDocument.removeEventListener('transitionend', update);
|
|
30
|
+
probe.remove();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useOverlayPlacement(container, anchorRef, { side, align, gap }) {
|
|
34
|
+
const [position, setPosition] = useState();
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
if (!container)
|
|
37
|
+
return;
|
|
38
|
+
return trackOverlayPosition(container, anchorRef, { side, align, gap }, style => setPosition({ container, style }));
|
|
39
|
+
}, [container, anchorRef, side, align, gap]);
|
|
40
|
+
return position?.container === container ? position.style : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { useOverlayPlacement };
|
|
44
|
+
//# sourceMappingURL=useOverlayPlacement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlayPlacement.js","sources":["../../../../Chat/Kit/useOverlayPlacement.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { type CSSProperties, type RefObject, useLayoutEffect, useState } from 'react';\nimport { probeStyle } from '../../renderer/fixedProbe';\nimport { computePlacement, placementInContainer } from './overlayGeometry';\nimport type { OverlayPlacementOptions } from './OverlayPlacementOptions';\nimport { readAnchorTheme } from './readAnchorTheme';\n\nfunction trackOverlayPosition(container: HTMLElement, anchorRef: RefObject<HTMLElement | null>, options: OverlayPlacementOptions, updatePosition: (style: CSSProperties) => void) {\n const ownerWindow = container.ownerDocument.defaultView;\n if (!ownerWindow) return;\n const probe = container.ownerDocument.createElement('div');\n probe.style.cssText = probeStyle;\n container.append(probe);\n const update = () => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const placement = computePlacement(anchor.getBoundingClientRect(), options, ownerWindow.innerHeight);\n updatePosition({ ...readAnchorTheme(anchor), ...placementInContainer(probe, placement, ownerWindow.innerHeight) });\n };\n update();\n ownerWindow.addEventListener('resize', update);\n ownerWindow.addEventListener('scroll', update, true);\n container.ownerDocument.addEventListener('animationend', update);\n container.ownerDocument.addEventListener('transitionend', update);\n return () => {\n ownerWindow.removeEventListener('resize', update);\n ownerWindow.removeEventListener('scroll', update, true);\n container.ownerDocument.removeEventListener('animationend', update);\n container.ownerDocument.removeEventListener('transitionend', update);\n probe.remove();\n };\n}\n\nexport function useOverlayPlacement(container: HTMLElement | null, anchorRef: RefObject<HTMLElement | null>, { side, align, gap }: OverlayPlacementOptions) {\n const [position, setPosition] = useState<{ container: HTMLElement; style: CSSProperties }>();\n useLayoutEffect(() => {\n if (!container) return;\n return trackOverlayPosition(container, anchorRef, { side, align, gap }, style => setPosition({ container, style }));\n }, [container, anchorRef, side, align, gap]);\n return position?.container === container ? position.style : undefined;\n}\n"],"names":[],"mappings":";;;;;AASA,SAAS,oBAAoB,CAAC,SAAsB,EAAE,SAAwC,EAAE,OAAgC,EAAE,cAA8C,EAAA;AAC5K,IAAA,MAAM,WAAW,GAAG,SAAS,CAAC,aAAa,CAAC,WAAW;AACvD,IAAA,IAAI,CAAC,WAAW;QAAE;IAClB,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC;AAC1D,IAAA,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU;AAChC,IAAA,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;IACvB,MAAM,MAAM,GAAG,MAAK;AAChB,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO;AAChC,QAAA,IAAI,CAAC,MAAM;YAAE;AACb,QAAA,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC;QACpG,cAAc,CAAC,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;AACtH,IAAA,CAAC;AACD,IAAA,MAAM,EAAE;AACR,IAAA,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC9C,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;IACpD,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM,CAAC;IAChE,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC;AACjE,IAAA,OAAO,MAAK;AACR,QAAA,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC;QACjD,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;QACvD,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,cAAc,EAAE,MAAM,CAAC;QACnE,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,eAAe,EAAE,MAAM,CAAC;QACpE,KAAK,CAAC,MAAM,EAAE;AAClB,IAAA,CAAC;AACL;AAEM,SAAU,mBAAmB,CAAC,SAA6B,EAAE,SAAwC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAA2B,EAAA;IACtJ,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,EAAoD;IAC5F,eAAe,CAAC,MAAK;AACjB,QAAA,IAAI,CAAC,SAAS;YAAE;QAChB,OAAO,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,KAAK,IAAI,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACvH,IAAA,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAC5C,IAAA,OAAO,QAAQ,EAAE,SAAS,KAAK,SAAS,GAAG,QAAQ,CAAC,KAAK,GAAG,SAAS;AACzE;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlayTarget.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/useOverlayTarget.ts"],"names":[],"mappings":"AAMA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,sBAM7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useState, useLayoutEffect } from 'react';
|
|
2
|
+
import { unstable_useOverlayEnvironment } from '../../renderer/RendererContext.js';
|
|
3
|
+
|
|
4
|
+
function useOverlayTarget(open) {
|
|
5
|
+
const environment = unstable_useOverlayEnvironment();
|
|
6
|
+
const [container, setContainer] = useState(null);
|
|
7
|
+
useLayoutEffect(() => { setContainer(open ? environment.getContainer() : null); });
|
|
8
|
+
return container;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { useOverlayTarget };
|
|
12
|
+
//# sourceMappingURL=useOverlayTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlayTarget.js","sources":["../../../../Chat/Kit/useOverlayTarget.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useLayoutEffect, useState } from 'react';\nimport { unstable_useOverlayEnvironment } from '../../renderer/RendererContext';\n\nexport function useOverlayTarget(open: boolean) {\n const environment = unstable_useOverlayEnvironment();\n const [container, setContainer] = useState<HTMLElement | null>(null);\n // Resolve only while open, including subsequent host renders after a deferred target appears.\n useLayoutEffect(() => { setContainer(open ? environment.getContainer() : null); });\n return container;\n}\n"],"names":[],"mappings":";;;AAMM,SAAU,gBAAgB,CAAC,IAAa,EAAA;AAC1C,IAAA,MAAM,WAAW,GAAG,8BAA8B,EAAE;IACpD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAqB,IAAI,CAAC;IAEpE,eAAe,CAAC,MAAK,EAAG,YAAY,CAAC,IAAI,GAAG,WAAW,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,IAAA,OAAO,SAAS;AACpB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactionPickerFocus.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/useReactionPickerFocus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useReactionPickerFocus.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/useReactionPickerFocus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAc9E,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,cAAe,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,SAAS,aAAa,MAAM,IAAI;;uBASpF,aAAa,CAAC,cAAc,CAAC;CAQ1D,CAAC"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
+
const dismissOnOutsidePointer = (root, anchorRef, onDismiss) => {
|
|
4
|
+
const ownerDocument = root.ownerDocument;
|
|
5
|
+
const handlePointerDown = (event) => {
|
|
6
|
+
const target = event.target;
|
|
7
|
+
if (root.contains(target) || anchorRef?.current?.contains(target))
|
|
8
|
+
return;
|
|
9
|
+
onDismiss();
|
|
10
|
+
};
|
|
11
|
+
ownerDocument.addEventListener('pointerdown', handlePointerDown, true);
|
|
12
|
+
return () => ownerDocument.removeEventListener('pointerdown', handlePointerDown, true);
|
|
13
|
+
};
|
|
3
14
|
const useReactionPickerFocus = (anchorRef, onDismiss) => {
|
|
4
15
|
const rootRef = useRef(null);
|
|
5
16
|
useEffect(() => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
onDismiss();
|
|
11
|
-
};
|
|
12
|
-
document.addEventListener('pointerdown', handlePointerDown, true);
|
|
13
|
-
return () => {
|
|
14
|
-
document.removeEventListener('pointerdown', handlePointerDown, true);
|
|
15
|
-
};
|
|
17
|
+
const root = rootRef.current;
|
|
18
|
+
if (!root)
|
|
19
|
+
return;
|
|
20
|
+
return dismissOnOutsidePointer(root, anchorRef, onDismiss);
|
|
16
21
|
}, [onDismiss, anchorRef]);
|
|
17
22
|
const onKeyDown = (event) => {
|
|
18
23
|
if (event.key !== 'Escape')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactionPickerFocus.js","sources":["../../../../Chat/Kit/useReactionPickerFocus.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { type KeyboardEvent, type RefObject, useEffect, useRef } from 'react';\n\
|
|
1
|
+
{"version":3,"file":"useReactionPickerFocus.js","sources":["../../../../Chat/Kit/useReactionPickerFocus.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { type KeyboardEvent, type RefObject, useEffect, useRef } from 'react';\n\nconst dismissOnOutsidePointer = (root: HTMLElement, anchorRef: RefObject<HTMLElement | null> | undefined, onDismiss: () => void) => {\n const ownerDocument = root.ownerDocument;\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n if (root.contains(target) || anchorRef?.current?.contains(target)) return;\n onDismiss();\n };\n // Capture phase, so items that stop pointerdown propagation still dismiss the picker.\n ownerDocument.addEventListener('pointerdown', handlePointerDown, true);\n return () => ownerDocument.removeEventListener('pointerdown', handlePointerDown, true);\n};\n\n/** Keeps picker dismissal local to its focus scope while respecting the opening button. */\nexport const useReactionPickerFocus = (anchorRef: RefObject<HTMLElement | null> | undefined, onDismiss: () => void) => {\n const rootRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n return dismissOnOutsidePointer(root, anchorRef, onDismiss);\n }, [onDismiss, anchorRef]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Escape') return;\n event.preventDefault();\n event.stopPropagation();\n onDismiss();\n };\n\n return { rootRef, onKeyDown };\n};\n"],"names":[],"mappings":";;AAKA,MAAM,uBAAuB,GAAG,CAAC,IAAiB,EAAE,SAAoD,EAAE,SAAqB,KAAI;AAC/H,IAAA,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa;AACxC,IAAA,MAAM,iBAAiB,GAAG,CAAC,KAAmB,KAAI;AAC9C,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAc;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;YAAE;AACnE,QAAA,SAAS,EAAE;AACf,IAAA,CAAC;IAED,aAAa,CAAC,gBAAgB,CAAC,aAAa,EAAE,iBAAiB,EAAE,IAAI,CAAC;AACtE,IAAA,OAAO,MAAM,aAAa,CAAC,mBAAmB,CAAC,aAAa,EAAE,iBAAiB,EAAE,IAAI,CAAC;AAC1F,CAAC;MAGY,sBAAsB,GAAG,CAAC,SAAoD,EAAE,SAAqB,KAAI;AAClH,IAAA,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC;IAE5C,SAAS,CAAC,MAAK;AACX,QAAA,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO;AAC5B,QAAA,IAAI,CAAC,IAAI;YAAE;QACX,OAAO,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC;AAC9D,IAAA,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAE1B,IAAA,MAAM,SAAS,GAAG,CAAC,KAAoC,KAAI;AACvD,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ;YAAE;QAC5B,KAAK,CAAC,cAAc,EAAE;QACtB,KAAK,CAAC,eAAe,EAAE;AACvB,QAAA,SAAS,EAAE;AACf,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;AACjC;;"}
|
|
@@ -8,21 +8,24 @@ import type { DataTableFilterMeta } from '../DataTables/DataTableFilterMeta.js';
|
|
|
8
8
|
import type { DataTableSelectionChangeEvent } from '../DataTables/DataTableSelectionChangeEvent.js';
|
|
9
9
|
import type { DataTableServerQuery } from '../DataTables/DataTableServerQuery.js';
|
|
10
10
|
import type { Constructor } from '@cratis/fundamentals';
|
|
11
|
+
import type { DataPageSelection } from './DataPageSelection.js';
|
|
11
12
|
/**
|
|
12
13
|
* Props for {@link MenuItem} — a single action in a {@link DataPage}'s
|
|
13
14
|
* action bar.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam TDataType - The surrounding page's row type. JSX does not infer it from the parent.
|
|
14
17
|
*/
|
|
15
|
-
export interface MenuItemProps {
|
|
18
|
+
export interface MenuItemProps<TDataType extends object = object> {
|
|
16
19
|
/** Icon component rendered before the label (e.g. a react-icons icon). */
|
|
17
20
|
icon?: React.ComponentType<{
|
|
18
21
|
className?: string;
|
|
19
22
|
}>;
|
|
20
23
|
/** The visible label. */
|
|
21
24
|
label?: string;
|
|
22
|
-
/** Invoked when the item is activated. */
|
|
23
|
-
command?: () => void;
|
|
24
|
-
/**
|
|
25
|
-
disabled?: boolean;
|
|
25
|
+
/** Invoked with the immutable, committed selection when the enabled item is activated. */
|
|
26
|
+
command?: (selection: DataPageSelection<TDataType>) => void;
|
|
27
|
+
/** A boolean or selection predicate; when true, the item cannot dispatch its command. */
|
|
28
|
+
disabled?: boolean | ((selection: DataPageSelection<TDataType>) => boolean);
|
|
26
29
|
/**
|
|
27
30
|
* When true, the menu item is disabled while no row is selected in the
|
|
28
31
|
* surrounding {@link DataPage}. Use it for context-sensitive actions like
|
|
@@ -33,9 +36,12 @@ export interface MenuItemProps {
|
|
|
33
36
|
/**
|
|
34
37
|
* Declarative menu item for use inside `<DataPage.MenuItems>`. Renders nothing
|
|
35
38
|
* directly; the surrounding {@link MenuItems} component reads its props and
|
|
36
|
-
* forwards them to the action menubar.
|
|
39
|
+
* forwards them to the action menubar. Supply the page's row type explicitly
|
|
40
|
+
* as `<DataPage.MenuItem<Person>>` for typed row access in callbacks.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam TDataType - The surrounding page's row type, not inferred from its JSX parent.
|
|
37
43
|
*/
|
|
38
|
-
export declare const MenuItem: (_props: MenuItemProps) => null;
|
|
44
|
+
export declare const MenuItem: <TDataType extends object = object>(_props: MenuItemProps<TDataType>) => null;
|
|
39
45
|
/**
|
|
40
46
|
* Props for {@link MenuItems}.
|
|
41
47
|
*/
|