@cratis/components 4.41.4 → 4.41.6

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 (50) hide show
  1. package/compat-manifest.json +11 -11
  2. package/dist/esm/Chat/Kit/AnchoredOverlay.d.ts +4 -3
  3. package/dist/esm/Chat/Kit/AnchoredOverlay.d.ts.map +1 -1
  4. package/dist/esm/Chat/Kit/AnchoredOverlay.js +15 -47
  5. package/dist/esm/Chat/Kit/AnchoredOverlay.js.map +1 -1
  6. package/dist/esm/Chat/Kit/OverlayPlacement.d.ts +7 -0
  7. package/dist/esm/Chat/Kit/OverlayPlacement.d.ts.map +1 -0
  8. package/dist/esm/Chat/Kit/OverlayPlacement.js +4 -0
  9. package/dist/esm/Chat/Kit/OverlayPlacement.js.map +1 -0
  10. package/dist/esm/Chat/Kit/OverlayPlacementOptions.d.ts +3 -0
  11. package/dist/esm/Chat/Kit/OverlayPlacementOptions.d.ts.map +1 -0
  12. package/dist/esm/Chat/Kit/OverlayPlacementOptions.js +4 -0
  13. package/dist/esm/Chat/Kit/OverlayPlacementOptions.js.map +1 -0
  14. package/dist/esm/Chat/Kit/overlayGeometry.d.ts +5 -0
  15. package/dist/esm/Chat/Kit/overlayGeometry.d.ts.map +1 -0
  16. package/dist/esm/Chat/Kit/overlayGeometry.js +47 -0
  17. package/dist/esm/Chat/Kit/overlayGeometry.js.map +1 -0
  18. package/dist/esm/Chat/Kit/readAnchorTheme.d.ts +3 -0
  19. package/dist/esm/Chat/Kit/readAnchorTheme.d.ts.map +1 -0
  20. package/dist/esm/Chat/Kit/readAnchorTheme.js +12 -0
  21. package/dist/esm/Chat/Kit/readAnchorTheme.js.map +1 -0
  22. package/dist/esm/Chat/Kit/useOverlayLayer.d.ts +2 -0
  23. package/dist/esm/Chat/Kit/useOverlayLayer.d.ts.map +1 -0
  24. package/dist/esm/Chat/Kit/useOverlayLayer.js +12 -0
  25. package/dist/esm/Chat/Kit/useOverlayLayer.js.map +1 -0
  26. package/dist/esm/Chat/Kit/useOverlayPlacement.d.ts +4 -0
  27. package/dist/esm/Chat/Kit/useOverlayPlacement.d.ts.map +1 -0
  28. package/dist/esm/Chat/Kit/useOverlayPlacement.js +44 -0
  29. package/dist/esm/Chat/Kit/useOverlayPlacement.js.map +1 -0
  30. package/dist/esm/Chat/Kit/useOverlayTarget.d.ts +2 -0
  31. package/dist/esm/Chat/Kit/useOverlayTarget.d.ts.map +1 -0
  32. package/dist/esm/Chat/Kit/useOverlayTarget.js +12 -0
  33. package/dist/esm/Chat/Kit/useOverlayTarget.js.map +1 -0
  34. package/dist/esm/Chat/Kit/useReactionPickerFocus.d.ts.map +1 -1
  35. package/dist/esm/Chat/Kit/useReactionPickerFocus.js +15 -10
  36. package/dist/esm/Chat/Kit/useReactionPickerFocus.js.map +1 -1
  37. package/dist/esm/ComponentPicker/PresentationPropertyEditor.d.ts.map +1 -1
  38. package/dist/esm/ComponentPicker/PresentationPropertyEditor.js +10 -5
  39. package/dist/esm/ComponentPicker/PresentationPropertyEditor.js.map +1 -1
  40. package/dist/esm/Filter/measurePanelPlacement.d.ts +2 -11
  41. package/dist/esm/Filter/measurePanelPlacement.d.ts.map +1 -1
  42. package/dist/esm/Filter/measurePanelPlacement.js +3 -17
  43. package/dist/esm/Filter/measurePanelPlacement.js.map +1 -1
  44. package/dist/esm/Filter/usePanelPosition.js +2 -1
  45. package/dist/esm/Filter/usePanelPosition.js.map +1 -1
  46. package/dist/esm/renderer/fixedProbe.d.ts +11 -0
  47. package/dist/esm/renderer/fixedProbe.d.ts.map +1 -0
  48. package/dist/esm/renderer/fixedProbe.js +19 -0
  49. package/dist/esm/renderer/fixedProbe.js.map +1 -0
  50. package/package.json +1 -1
@@ -68,7 +68,7 @@
68
68
  {
69
69
  "name": "@cratis/components",
70
70
  "role": "core",
71
- "version": "4.41.4",
71
+ "version": "4.41.6",
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.41.4",
95
+ "version": "4.41.6",
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.41.4",
108
+ "version": "4.41.6",
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.41.4",
119
+ "version": "4.41.6",
120
120
  "releaseMajorRange": ">=4 <5",
121
121
  "independentRelease": false,
122
122
  "private": false,
123
123
  "packageAccess": "public",
124
124
  "peerDependencies": {
125
- "@cratis/components": "4.41.4",
125
+ "@cratis/components": "4.41.6",
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.41.4",
135
+ "version": "4.41.6",
136
136
  "releaseMajorRange": ">=4 <5",
137
137
  "independentRelease": false,
138
138
  "private": false,
139
139
  "packageAccess": "public",
140
140
  "peerDependencies": {
141
- "@cratis/components": "4.41.4",
141
+ "@cratis/components": "4.41.6",
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.41.4",
191
+ "version": "4.41.6",
192
192
  "releaseMajorRange": ">=4 <5",
193
193
  "independentRelease": false,
194
194
  "private": false,
195
195
  "packageAccess": "public",
196
196
  "peerDependencies": {
197
- "@cratis/components": "4.41.4",
197
+ "@cratis/components": "4.41.6",
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.41.4",
259
+ "version": "4.41.6",
260
260
  "releaseMajorRange": ">=4 <5",
261
261
  "independentRelease": false,
262
262
  "private": false,
263
263
  "packageAccess": "public",
264
264
  "peerDependencies": {
265
- "@cratis/components": "4.41.4",
265
+ "@cratis/components": "4.41.6",
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 into a fixed-position portal on <body>, anchored to an element on the board.
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 (the same approach the
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,EAA6B,MAAM,OAAO,CAAC;AAG/E,6DAA6D;AAC7D,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,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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 [placement, setPlacement] = useState();
34
- useLayoutEffect(() => {
35
- if (!open) {
36
- setPlacement(undefined);
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
- return createPortal(jsx("div", { style: {
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: 1300,
49
- top: placement.top,
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, useLayoutEffect, useState } from 'react';\nimport { createPortal } from 'react-dom';\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/** Space on the preferred side under which an above/below overlay flips to the other side. */\nconst FLIP_THRESHOLD = 260;\n\ninterface Placement {\n top?: number;\n bottom?: number;\n left: number;\n transform?: string;\n}\n\nfunction computePlacement(\n anchor: DOMRect,\n side: AnchoredOverlaySide,\n align: AnchoredOverlayAlign,\n gap: number,\n): Placement {\n if (side === 'left' || side === 'right') {\n return {\n top: anchor.top + anchor.height / 2,\n left: side === 'right' ? anchor.right + gap : anchor.left - gap,\n transform: side === 'right' ? 'translateY(-50%)' : 'translate(-100%, -50%)',\n };\n }\n\n const spaceBelow = window.innerHeight - anchor.bottom - gap;\n const spaceAbove = anchor.top - gap;\n const resolved =\n side === 'below'\n ? spaceBelow < FLIP_THRESHOLD && spaceAbove > spaceBelow\n ? 'above'\n : 'below'\n : spaceAbove < FLIP_THRESHOLD && spaceBelow > spaceAbove\n ? 'below'\n : 'above';\n\n const horizontal =\n align === 'center'\n ? { left: anchor.left + anchor.width / 2, transform: 'translateX(-50%)' }\n : align === 'right'\n ? { left: anchor.right, transform: 'translateX(-100%)' }\n : { left: anchor.left, transform: undefined };\n\n return resolved === 'below'\n ? { top: anchor.bottom + gap, ...horizontal }\n : { bottom: window.innerHeight - anchor.top + gap, ...horizontal };\n}\n\n/**\n * Renders its children into a fixed-position portal on <body>, anchored to an element on the board.\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 (the same approach the\n * Cratis Dropdown takes with appendTo=document.body).\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 [placement, setPlacement] = useState<Placement | undefined>();\n\n useLayoutEffect(() => {\n if (!open) {\n setPlacement(undefined);\n return;\n }\n const anchor = anchorRef.current?.getBoundingClientRect();\n if (!anchor) return;\n setPlacement(computePlacement(anchor, side, align, gap));\n }, [open, side, align, gap, anchorRef]);\n\n if (!open || !placement) return null;\n\n return createPortal(\n <div\n style={{\n position: 'fixed',\n zIndex: 1300,\n top: placement.top,\n bottom: placement.bottom,\n left: placement.left,\n transform: placement.transform,\n }}\n >\n {children}\n </div>,\n document.body,\n );\n};\n"],"names":["_jsx"],"mappings":";;;;AAuCA,MAAM,cAAc,GAAG,GAAG;AAS1B,SAAS,gBAAgB,CACrB,MAAe,EACf,IAAyB,EACzB,KAA2B,EAC3B,GAAW,EAAA;IAEX,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,EAAE;QACrC,OAAO;YACH,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;AACnC,YAAA,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,MAAM,CAAC,KAAK,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG;YAC/D,SAAS,EAAE,IAAI,KAAK,OAAO,GAAG,kBAAkB,GAAG,wBAAwB;SAC9E;IACL;IAEA,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,GAAG,GAAG;AAC3D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG;AACnC,IAAA,MAAM,QAAQ,GACV,IAAI,KAAK;AACL,UAAE,UAAU,GAAG,cAAc,IAAI,UAAU,GAAG;AAC1C,cAAE;AACF,cAAE;AACN,UAAE,UAAU,GAAG,cAAc,IAAI,UAAU,GAAG;AAC5C,cAAE;cACA,OAAO;AAEnB,IAAA,MAAM,UAAU,GACZ,KAAK,KAAK;AACN,UAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB;UACrE,KAAK,KAAK;cACR,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB;AACtD,cAAE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jC,SAAA,EAAA,QAAA,EAEA,QAAQ,EAAA,CACP,EACN,QAAQ,CAAC,IAAI,CAChB;AACL;;"}
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,7 @@
1
+ export interface OverlayPlacement {
2
+ top?: number;
3
+ bottom?: number;
4
+ left: number;
5
+ transform?: string;
6
+ }
7
+ //# sourceMappingURL=OverlayPlacement.d.ts.map
@@ -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,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=OverlayPlacement.js.map
@@ -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,3 @@
1
+ import type { AnchoredOverlayProps } from './AnchoredOverlay.js';
2
+ export type OverlayPlacementOptions = Required<Pick<AnchoredOverlayProps, 'side' | 'align' | 'gap'>>;
3
+ //# sourceMappingURL=OverlayPlacementOptions.d.ts.map
@@ -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,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=OverlayPlacementOptions.js.map
@@ -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":";;AAQA,MAAM,cAAc,GAAG,GAAG;AAE1B,SAAS,mBAAmB,CAAC,MAAe,EAAE,KAAuC,EAAA;IACjF,IAAI,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE;IACtG,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE;AACpF,IAAA,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;AAChC;AAEA,SAAS,UAAU,CAAC,cAAsB,EAAE,UAAkB,EAAA;AAC1D,IAAA,OAAO,cAAc,GAAG,cAAc,IAAI,UAAU,GAAG,cAAc;AACzE;AAEA,SAAS,mBAAmB,CAAC,IAAqC,EAAE,UAAkB,EAAE,UAAkB,EAAA;IACtG,IAAI,IAAI,KAAK,OAAO;AAAE,QAAA,OAAO,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,OAAO,GAAG,OAAO;AACnF,IAAA,OAAO,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,OAAO,GAAG,OAAO;AACjE;AAEA,SAAS,iBAAiB,CAAC,MAAe,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAA2B,EAAE,cAAsB,EAAA;IAC7G,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,GAAG,GAAG,EA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AAM,CAAC,IAAI,IAAI,MAAM;QAC7C,GAAG,EAAE,SAAS,CAAC,GAAG,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM;QACpF,MAAM,EAAE,SAAS,CAAC,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC,MAAM,IAAI,MAAM;KAC7G;AACL;;"}
@@ -0,0 +1,3 @@
1
+ import type { CSSProperties } from 'react';
2
+ export declare function readAnchorTheme(anchor: HTMLElement): CSSProperties;
3
+ //# sourceMappingURL=readAnchorTheme.d.ts.map
@@ -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,2 @@
1
+ export declare function useOverlayLayer(): string;
2
+ //# sourceMappingURL=useOverlayLayer.d.ts.map
@@ -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,SA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AM,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,2 @@
1
+ export declare function useOverlayTarget(open: boolean): HTMLElement | null;
2
+ //# sourceMappingURL=useOverlayTarget.d.ts.map
@@ -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;AAE9E,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,cAAe,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,SAAS,aAAa,MAAM,IAAI;;uBAiBpF,aAAa,CAAC,cAAc,CAAC;CAQ1D,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 handlePointerDown = (event) => {
7
- const target = event.target;
8
- if (rootRef.current?.contains(target) || anchorRef?.current?.contains(target))
9
- return;
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\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 handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n if (rootRef.current?.contains(target) || anchorRef?.current?.contains(target))\n return;\n onDismiss();\n };\n // Capture phase, so items that stop pointerdown propagation still dismiss the picker.\n document.addEventListener('pointerdown', handlePointerDown, true);\n return () => {\n document.removeEventListener('pointerdown', handlePointerDown, true);\n };\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":";;MAMa,sBAAsB,GAAG,CAAC,SAAoD,EAAE,SAAqB,KAAI;AAClH,IAAA,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC;IAE5C,SAAS,CAAC,MAAK;AACX,QAAA,MAAM,iBAAiB,GAAG,CAAC,KAAmB,KAAI;AAC9C,YAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAc;AACnC,YAAA,IAAI,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACzE;AACJ,YAAA,SAAS,EAAE;AACf,QAAA,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,iBAAiB,EAAE,IAAI,CAAC;AACjE,QAAA,OAAO,MAAK;YACR,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,iBAAiB,EAAE,IAAI,CAAC;AACxE,QAAA,CAAC;AACL,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;;"}
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,CA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AAI,CAAC;IAClD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAmED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6CAAsD,+BAA+B,gCA+C3H,CAAC"}
1
+ {"version":3,"file":"PresentationPropertyEditor.d.ts","sourceRoot":"","sources":["../../../ComponentPicker/PresentationPropertyEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAA8C,CAAC;AAEvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAIzD,oDAAoD;AACpD,MAAM,WAAW,+BAA+B;IAC5C,qEAAqE;IACrE,MAAM,EAAE,eAAe,CAAC;IACxB,mHAAmH;IACnH,QAAQ,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAoED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6CAAsD,+BAA+B,gCAmD3H,CAAC"}
@@ -4,6 +4,7 @@ import { previewPresentationChanges } from '../configuration/identity/componentI
4
4
  import { proposedChanges } from './proposedChanges.js';
5
5
 
6
6
  const unsetValue = '';
7
+ const emptyDraft = Object.freeze({});
7
8
  const field = (property, id, value, set) => {
8
9
  const common = { id, disabled: !property.editable, 'data-cratis-part': 'input' };
9
10
  switch (property.type) {
@@ -22,12 +23,13 @@ const field = (property, id, value, set) => {
22
23
  };
23
24
  const PresentationPropertyEditor = ({ picked, onChange, preview = false, className }) => {
24
25
  const prefix = useId();
25
- const [draft, setDraft] = useState({});
26
- const changes = useMemo(() => proposedChanges(picked, draft), [picked, draft]);
26
+ const [draft, setDraft] = useState({ picked, values: emptyDraft });
27
+ const values = draft.picked === picked ? draft.values : emptyDraft;
28
+ const changes = useMemo(() => proposedChanges(picked, values), [picked, values]);
27
29
  const reportChange = useRef(onChange);
28
30
  reportChange.current = onChange;
29
31
  useEffect(() => {
30
- setDraft({});
32
+ setDraft({ picked, values: emptyDraft });
31
33
  }, [picked]);
32
34
  useEffect(() => {
33
35
  reportChange.current(changes);
@@ -42,8 +44,11 @@ const PresentationPropertyEditor = ({ picked, onChange, preview = false, classNa
42
44
  }
43
45
  return (jsx("div", { "data-cratis-part": 'root', "data-cratis-component": 'PresentationPropertyEditor', className: className, children: picked.presentationProperties.map((property) => {
44
46
  const id = `${prefix}-${property.name}`;
45
- const value = property.name in draft ? draft[property.name] : property.value;
46
- return (jsxs("div", { "data-cratis-part": 'property', children: [jsx("label", { htmlFor: id, "data-cratis-part": 'label', children: property.label }), field(property, id, value, (next) => setDraft((current) => ({ ...current, [property.name]: next }))), property.description && jsx("small", { "data-cratis-part": 'description', children: property.description })] }, property.name));
47
+ const value = property.name in values ? values[property.name] : property.value;
48
+ return (jsxs("div", { "data-cratis-part": 'property', children: [jsx("label", { htmlFor: id, "data-cratis-part": 'label', children: property.label }), field(property, id, value, (next) => setDraft((current) => ({
49
+ picked,
50
+ values: { ...(current.picked === picked ? current.values : emptyDraft), [property.name]: next },
51
+ }))), property.description && jsx("small", { "data-cratis-part": 'description', children: property.description })] }, property.name));
47
52
  }) }));
48
53
  };
49
54
 
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationPropertyEditor.js","sources":["../../../ComponentPicker/PresentationPropertyEditor.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 { useEffect, useId, useMemo, useRef, useState } from 'react';\nimport { previewPresentationChanges } from '../configuration/identity/componentInstances';\nimport type { PresentationChange } from '../configuration/identity/PresentationChange';\nimport type { PresentationPropertyValue } from '../configuration/identity/PresentationPropertyValue';\nimport type { PickedComponent } from './PickedComponent';\nimport type { PickedPresentationProperty } from './PickedPresentationProperty';\nimport { proposedChanges } from './proposedChanges';\n\n/** Props for {@link PresentationPropertyEditor}. */\nexport interface PresentationPropertyEditorProps {\n /** The picked component whose presentation properties are edited. */\n picked: PickedComponent;\n /** Called every time the proposed changes change, including with `[]` when nothing differs. Nothing is applied. */\n onChange: (changes: PresentationChange[]) => void;\n /**\n * Applies the proposed changes to the rendered component while editing, through the same\n * registry the picker reads. The component returns to how it was when the editor unmounts,\n * when this turns off, and when a change is edited back to its original value.\n */\n preview?: boolean;\n /** Extra class name for the editor root. */\n className?: string;\n}\n\nconst unsetValue = '';\n\nconst field = (\n property: PickedPresentationProperty,\n id: string,\n value: PresentationPropertyValue,\n set: (next: PresentationPropertyValue) => void,\n) => {\n const common = { id, disabled: !property.editable, 'data-cratis-part': 'input' } as const;\n switch (property.type) {\n case 'boolean':\n return (\n <input\n {...common}\n type='checkbox'\n checked={value === true}\n onChange={(event) => set(event.currentTarget.checked)}\n />\n );\n case 'number':\n return (\n <input\n {...common}\n className='cratis-text-input'\n type='number'\n value={typeof value === 'number' ? value : ''}\n onChange={(event) =>\n set(event.currentTarget.value === '' ? undefined : Number(event.currentTarget.value))\n }\n />\n );\n case 'enum':\n return (\n <select\n {...common}\n className='cratis-text-input'\n value={value === undefined ? unsetValue : String(value)}\n onChange={(event) => {\n const chosen = event.currentTarget.value;\n set(chosen === unsetValue ? undefined : property.values?.find((v) => String(v) === chosen));\n }}\n >\n <option value={unsetValue}>\n {property.defaultValue === undefined ? '(not set)' : `(default: ${String(property.defaultValue)})`}\n </option>\n {property.values?.map((option) => (\n <option key={String(option)} value={String(option)}>\n {String(option)}\n </option>\n ))}\n </select>\n );\n default:\n return (\n <input\n {...common}\n className='cratis-text-input'\n type='text'\n value={typeof value === 'string' ? value : ''}\n onChange={(event) => set(event.currentTarget.value)}\n />\n );\n }\n};\n\n/**\n * A form for the presentation properties of a {@link PickedComponent}: a text, toggle, select or\n * number input per property, built from the component's descriptor. It reports the proposed changes\n * as `{ property, from, to }` and never applies them to the app, except for the optional live\n * `preview`.\n */\nexport const PresentationPropertyEditor = ({ picked, onChange, preview = false, className }: PresentationPropertyEditorProps) => {\n const prefix = useId();\n const [draft, setDraft] = useState<Record<string, PresentationPropertyValue>>({});\n const changes = useMemo(() => proposedChanges(picked, draft), [picked, draft]);\n const reportChange = useRef(onChange);\n reportChange.current = onChange;\n\n useEffect(() => {\n setDraft({});\n }, [picked]);\n\n useEffect(() => {\n reportChange.current(changes);\n }, [changes]);\n\n useEffect(() => {\n if (!preview || changes.length === 0) return;\n return previewPresentationChanges(picked.element, changes);\n }, [preview, changes, picked.element]);\n\n if (picked.presentationProperties.length === 0) {\n return (\n <p data-cratis-part='empty' className={className}>\n {picked.component} has no properties that can be changed here.\n </p>\n );\n }\n\n return (\n <div data-cratis-part='root' data-cratis-component='PresentationPropertyEditor' className={className}>\n {picked.presentationProperties.map((property) => {\n const id = `${prefix}-${property.name}`;\n const value = property.name in draft ? draft[property.name] : property.value;\n return (\n <div key={property.name} data-cratis-part='property'>\n <label htmlFor={id} data-cratis-part='label'>\n {property.label}\n </label>\n {field(property, id, value, (next) =>\n setDraft((current) => ({ ...current, [property.name]: next })),\n )}\n {property.description && <small data-cratis-part='description'>{property.description}</small>}\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;AA2BA,MAAM,UAAU,GAAG,EAAE;AAErB,MAAM,KAAK,GAAG,CACV,QAAoC,EACpC,EAAU,EACV,KAAgC,EAChC,GAA8C,KAC9C;AACA,IAAA,MAAM,MAAM,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAW;AACzF,IAAA,QAAQ,QAAQ,CAAC,IAAI;AACjB,QAAA,KAAK,SAAS;AACV,YAAA,QACIA,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,MAAM,EACV,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,KAAK,KAAK,IAAI,EACvB,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EAAA,CAAS,KAPvF,QAAQ,CAAC,IAAI,CAQjB;QAEd,CAAC,CAAC,EAAA,CACA;AAEd;;"}
1
+ {"version":3,"file":"PresentationPropertyEditor.js","sources":["../../../ComponentPicker/PresentationPropertyEditor.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 { useEffect, useId, useMemo, useRef, useState } from 'react';\nimport { previewPresentationChanges } from '../configuration/identity/componentInstances';\nimport type { PresentationChange } from '../configuration/identity/PresentationChange';\nimport type { PresentationPropertyValue } from '../configuration/identity/PresentationPropertyValue';\nimport type { PickedComponent } from './PickedComponent';\nimport type { PickedPresentationProperty } from './PickedPresentationProperty';\nimport { proposedChanges } from './proposedChanges';\n\n/** Props for {@link PresentationPropertyEditor}. */\nexport interface PresentationPropertyEditorProps {\n /** The picked component whose presentation properties are edited. */\n picked: PickedComponent;\n /** Called every time the proposed changes change, including with `[]` when nothing differs. Nothing is applied. */\n onChange: (changes: PresentationChange[]) => void;\n /**\n * Applies the proposed changes to the rendered component while editing, through the same\n * registry the picker reads. The component returns to how it was when the editor unmounts,\n * when this turns off, and when a change is edited back to its original value.\n */\n preview?: boolean;\n /** Extra class name for the editor root. */\n className?: string;\n}\n\nconst unsetValue = '';\nconst emptyDraft: Readonly<Record<string, PresentationPropertyValue>> = Object.freeze({});\n\nconst field = (\n property: PickedPresentationProperty,\n id: string,\n value: PresentationPropertyValue,\n set: (next: PresentationPropertyValue) => void,\n) => {\n const common = { id, disabled: !property.editable, 'data-cratis-part': 'input' } as const;\n switch (property.type) {\n case 'boolean':\n return (\n <input\n {...common}\n type='checkbox'\n checked={value === true}\n onChange={(event) => set(event.currentTarget.checked)}\n />\n );\n case 'number':\n return (\n <input\n {...common}\n className='cratis-text-input'\n type='number'\n value={typeof value === 'number' ? value : ''}\n onChange={(event) =>\n set(event.currentTarget.value === '' ? undefined : Number(event.currentTarget.value))\n }\n />\n );\n case 'enum':\n return (\n <select\n {...common}\n className='cratis-text-input'\n value={value === undefined ? unsetValue : String(value)}\n onChange={(event) => {\n const chosen = event.currentTarget.value;\n set(chosen === unsetValue ? undefined : property.values?.find((v) => String(v) === chosen));\n }}\n >\n <option value={unsetValue}>\n {property.defaultValue === undefined ? '(not set)' : `(default: ${String(property.defaultValue)})`}\n </option>\n {property.values?.map((option) => (\n <option key={String(option)} value={String(option)}>\n {String(option)}\n </option>\n ))}\n </select>\n );\n default:\n return (\n <input\n {...common}\n className='cratis-text-input'\n type='text'\n value={typeof value === 'string' ? value : ''}\n onChange={(event) => set(event.currentTarget.value)}\n />\n );\n }\n};\n\n/**\n * A form for the presentation properties of a {@link PickedComponent}: a text, toggle, select or\n * number input per property, built from the component's descriptor. It reports the proposed changes\n * as `{ property, from, to }` and never applies them to the app, except for the optional live\n * `preview`.\n */\nexport const PresentationPropertyEditor = ({ picked, onChange, preview = false, className }: PresentationPropertyEditorProps) => {\n const prefix = useId();\n const [draft, setDraft] = useState({ picked, values: emptyDraft });\n const values = draft.picked === picked ? draft.values : emptyDraft;\n const changes = useMemo(() => proposedChanges(picked, values), [picked, values]);\n const reportChange = useRef(onChange);\n reportChange.current = onChange;\n\n useEffect(() => {\n setDraft({ picked, values: emptyDraft });\n }, [picked]);\n\n useEffect(() => {\n reportChange.current(changes);\n }, [changes]);\n\n useEffect(() => {\n if (!preview || changes.length === 0) return;\n return previewPresentationChanges(picked.element, changes);\n }, [preview, changes, picked.element]);\n\n if (picked.presentationProperties.length === 0) {\n return (\n <p data-cratis-part='empty' className={className}>\n {picked.component} has no properties that can be changed here.\n </p>\n );\n }\n\n return (\n <div data-cratis-part='root' data-cratis-component='PresentationPropertyEditor' className={className}>\n {picked.presentationProperties.map((property) => {\n const id = `${prefix}-${property.name}`;\n const value = property.name in values ? values[property.name] : property.value;\n return (\n <div key={property.name} data-cratis-part='property'>\n <label htmlFor={id} data-cratis-part='label'>\n {property.label}\n </label>\n {field(property, id, value, (next) =>\n setDraft((current) => ({\n picked,\n values: { ...(current.picked === picked ? current.values : emptyDraft), [property.name]: next },\n })),\n )}\n {property.description && <small data-cratis-part='description'>{property.description}</small>}\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;AA2BA,MAAM,UAAU,GAAG,EAAE;AACrB,MAAM,UAAU,GAAwD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAEzF,MAAM,KAAK,GAAG,CACV,QAAoC,EACpC,EAAU,EACV,KAAgC,EAChC,GAA8C,KAC9C;AACA,IAAA,MAAM,MAAM,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAW;AACzF,IAAA,QAAQ,QAAQ,CAAC,IAAI;AACjB,QAAA,KAAK,SAAS;AACV,YAAA,QACIA,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,MAAM,EACV,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,KAAK,KAAK,IAAI,EACvB,QAAQ,EAAE,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,EAAA,CACvD;AAEV,QAAA,KAAK,QAAQ;AACT,YAAA,QACIA,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,MAAM,EACV,SAAS,EAAC,mBAAmB,EAC7B,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,EAAE,EAC7C,QAAQ,EAAE,CAAC,KAAK,KACZ,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,KAAK,EAAE,GAAG,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAA,CAE3F;AAEV,QAAA,KAAK,MAAM;AACP,YAAA,QACIC,IAAA,CAAA,QAAA,EAAA,EAAA,GACQ,MAAM,EACV,SAAS,EAAC,mBAAmB,EAC7B,KAAK,EAAE,K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AM,2BAAuB,4BAA4B,EAAC,SAAS,EAAE,SAAS,YAC/F,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAI;YAC5C,MAAM,EAAE,GAAG,CAAA,EAAG,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAA,CAAE;YACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK;AAC9E,YAAA,QACIC,IAAA,CAAA,KAAA,EAAA,EAAA,kBAAA,EAA0C,UAAU,EAAA,QAAA,EAAA,CAChDD,GAAA,CAAA,OAAA,EAAA,EAAO,OAAO,EAAE,EAAE,EAAA,kBAAA,EAAmB,OAAO,YACvC,QAAQ,CAAC,KAAK,EAAA,CACX,EACP,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,KAC7B,QAAQ,CAAC,CAAC,OAAO,MAAM;wBACnB,MAAM;AACN,wBAAA,MAAM,EAAE,EAAE,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,EAAE;qBAClG,CAAC,CAAC,CACN,EACA,QAAQ,CAAC,WAAW,IAAIA,mCAAwB,aAAa,EAAA,QAAA,EAAE,QAAQ,CAAC,WAAW,GAAS,CAAA,EAAA,EAVvF,QAAQ,CAAC,IAAI,CAWjB;QAEd,CAAC,CAAC,EAAA,CACA;AAEd;;"}
@@ -1,14 +1,10 @@
1
+ import { measureProbe, probeStyle } from '../renderer/fixedProbe.js';
1
2
  import { type DropdownPosition } from './utils.js';
3
+ export { measureProbe, probeStyle };
2
4
  /** Fixed-position panel placement, optionally with a clamped CSS width. */
3
5
  export type PanelPosition = DropdownPosition & {
4
6
  width?: number;
5
7
  };
6
- /** Edges of a fixed-position probe's containing block. */
7
- interface ProbeEdges {
8
- origin: DOMRect;
9
- bottom: number;
10
- right: number;
11
- }
12
8
  /** The probes (and the elements they sit in) the panel placement is measured against. */
13
9
  export interface PlacementTargets {
14
10
  probe: HTMLDivElement;
@@ -18,14 +14,9 @@ export interface PlacementTargets {
18
14
  panel: HTMLDivElement;
19
15
  anchor: HTMLButtonElement;
20
16
  }
21
- /** Inline style that makes an element a fixed, invisible, 1px probe. */
22
- export declare const probeStyle = "position:fixed;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none";
23
- /** Measures the origin, bottom and right edges of a fixed probe's containing block. */
24
- export declare function measureProbe(element: HTMLDivElement): ProbeEdges;
25
17
  /**
26
18
  * Computes where the fixed-position panel belongs so it stays attached to its anchor
27
19
  * and clamped inside the viewport (or the modal that clips it).
28
20
  */
29
21
  export declare function measurePanelPlacement(targets: PlacementTargets): PanelPosition;
30
- export {};
31
22
  //# sourceMappingURL=measurePanelPlacement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measurePanelPlacement.d.ts","sourceRoot":"","sources":["../../../Filter/measurePanelPlacement.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,YAAS,CAAC;AAEzE,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,0DAA0D;AAC1D,UAAU,UAAU;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,eAAe,EAAE,WAAW,CAAC;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;CAC7B;AAED,wEAAwE;AACxE,eAAO,MAAM,UAAU,uHAAuH,CAAC;AAK/I,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,CAchE;AAkHD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAoC9E"}
1
+ {"version":3,"file":"measurePanelPlacement.d.ts","sourceRoot":"","sources":["../../../Filter/measurePanelPlacement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,2BAAwB,CAAC;AACnF,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,YAAS,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AAEpC,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,eAAe,EAAE,WAAW,CAAC;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;CAC7B;AAqHD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAoC9E"}
@@ -1,23 +1,9 @@
1
+ import { measureProbe } from '../renderer/fixedProbe.js';
2
+ export { probeStyle } from '../renderer/fixedProbe.js';
1
3
  import { resolveDropdownPosition } from './utils.js';
2
4
 
3
- const probeStyle = 'position:fixed;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none';
4
5
  const edgeTolerance = 0.5;
5
6
  const viewportGutter = 32;
6
- function measureProbe(element) {
7
- element.style.top = '0';
8
- element.style.bottom = 'auto';
9
- const origin = element.getBoundingClientRect();
10
- element.style.top = 'auto';
11
- element.style.bottom = '0';
12
- const bottom = element.getBoundingClientRect().bottom;
13
- element.style.bottom = 'auto';
14
- element.style.left = 'auto';
15
- element.style.right = '0';
16
- const right = element.getBoundingClientRect().right;
17
- element.style.left = '0';
18
- element.style.right = 'auto';
19
- return { origin, bottom, right };
20
- }
21
7
  function readViewport() {
22
8
  const viewportElement = document.compatMode === 'BackCompat' ? document.body : document.documentElement;
23
9
  return {
@@ -128,5 +114,5 @@ function measurePanelPlacement(targets) {
128
114
  };
129
115
  }
130
116
 
131
- export { measurePanelPlacement, measureProbe, probeStyle };
117
+ export { measurePanelPlacement, measureProbe };
132
118
  //# sourceMappingURL=measurePanelPlacement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"measurePanelPlacement.js","sources":["../../../Filter/measurePanelPlacement.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 { resolveDropdownPosition, type DropdownPosition } from './utils';\n\n/** Fixed-position panel placement, optionally with a clamped CSS width. */\nexport type PanelPosition = DropdownPosition & { width?: number };\n\n/** Edges of a fixed-position probe's containing block. */\ninterface ProbeEdges {\n origin: DOMRect;\n bottom: number;\n right: number;\n}\n\n/** The probes (and the elements they sit in) the panel placement is measured against. */\nexport interface PlacementTargets {\n probe: HTMLDivElement;\n rootProbe: HTMLDivElement | null;\n modalRoot: HTMLElement | null | undefined;\n portalContainer: HTMLElement;\n panel: HTMLDivElement;\n anchor: HTMLButtonElement;\n}\n\n/** Inline style that makes an element a fixed, invisible, 1px probe. */\nexport const probeStyle = 'position:fixed;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none';\n\nconst edgeTolerance = 0.5;\nconst viewportGutter = 32;\n\n/** Measures the origin, bottom and right edges of a fixed probe's containing block. */\nexport function measureProbe(element: HTMLDivElement): ProbeEdges {\n element.style.top = '0';\n element.style.bottom = 'auto';\n const origin = element.getBoundingClientRect();\n element.style.top = 'auto';\n element.style.bottom = '0';\n const bottom = element.getBoundingClientRect().bottom;\n element.style.bottom = 'auto';\n element.style.left = 'auto';\n element.style.right = '0';\n const right = element.getBoundingClientRect().right;\n element.style.left = '0';\n element.style.right = 'auto';\n return { origin, bottom, right };\n}\n\n/** Layoutless renderers report zero; browser layout uses the scrollbar-free viewport. */\nfunction readViewport(): { width: number; height: number } {\n // In quirks mode the viewport's client size is reported on the body, not the root.\n const viewportElement = document.compatMode === 'BackCompat' ? document.body : document.documentElement;\n return {\n width: viewportElement.clientWidth || window.innerWidth,\n height: viewportElement.clientHeight || window.innerHeight,\n };\n}\n\n/** Properties whose non-\"none\" value makes an element the containing block of fixed descendants. */\nconst fixedContainingProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'] as const;\n\nconst containLayoutPattern = /\\b(?:layout|paint|strict|content)\\b/u;\nconst containerTypePattern = /^(?:size|inline-size)$/u;\nconst willChangePattern = /\\b(?:transform|translate|scale|rotate|perspective|filter|backdrop-filter|contain|container-type)\\b/u;\n\nfunction hasBackdropFilter(rootStyle: CSSStyleDeclaration): boolean {\n return rootStyle.getPropertyValue('backdrop-filter') !== 'none' &&\n rootStyle.getPropertyValue('backdrop-filter') !== '';\n}\n\nfunction hasFixedContainingStyle(rootStyle: CSSStyleDeclaration): boolean {\n if (fixedContainingProperties.some(property => rootStyle[property] !== 'none')) return true;\n if (hasBackdropFilter(rootStyle)) return true;\n return containLayoutPattern.test(rootStyle.contain) ||\n containerTypePattern.test(rootStyle.getPropertyValue('container-type')) ||\n willChangePattern.test(rootStyle.willChange);\n}\n\n/**\n * A fixed probe spans its containing block, not the Dialog's overflow box.\n * Compare all four edges to the root's padding box: a side dialog can share\n * the positioner's top-left origin without sharing its containing block.\n * Comparing to innerWidth/innerHeight instead would mistake classic scrollbars\n * (excluded from the layout viewport) for a transformed containing block.\n */\nfunction edgesMatchPaddingBox(\n rootEdges: ProbeEdges,\n rootRect: DOMRect,\n rootStyle: CSSStyleDeclaration,\n scaleX: number,\n scaleY: number,\n): boolean {\n // Lazy checks: each edge is read only when the previous edges matched.\n const edgeChecks: Array<() => boolean> = [\n () => Math.abs(rootEdges.origin.left - (rootRect.left + parseFloat(rootStyle.borderLeftWidth) * scaleX)) <= edgeTolerance,\n () => Math.abs(rootEdges.origin.top - (rootRect.top + parseFloat(rootStyle.borderTopWidth) * scaleY)) <= edgeTolerance,\n () => Math.abs(rootEdges.right - (rootRect.right - parseFloat(rootStyle.borderRightWidth) * scaleX)) <= edgeTolerance,\n () => Math.abs(rootEdges.bottom - (rootRect.bottom - parseFloat(rootStyle.borderBottomWidth) * scaleY)) <= edgeTolerance,\n ];\n return edgeChecks.every(check => check());\n}\n\nfunction edgesDiffer(probeEdges: ProbeEdges, rootEdges: ProbeEdges): boolean {\n // Lazy checks: each edge is read only when the previous edges did not differ.\n const edgeChecks: Array<() => boolean> = [\n () => Math.abs(probeEdges.origin.left - rootEdges.origin.left) > edgeTolerance,\n () => Math.abs(probeEdges.origin.top - rootEdges.origin.top) > edgeTolerance,\n () => Math.abs(probeEdges.right - rootEdges.right) > edgeTolerance,\n () => Math.abs(probeEdges.bottom - rootEdges.bottom) > edgeTolerance,\n ];\n return edgeChecks.some(check => check());\n}\n\n/** Layoutless environments cannot supply a modal clip rect. */\nfunction hasLayout(rect: DOMRect): boolean {\n return rect.right > rect.left && rect.bottom > rect.top;\n}\n\n/** The modal's rect when the modal or the portal's descendant block owns the fixed containing block. */\nfunction resolveModalClip(\n targets: PlacementTargets,\n edges: ProbeEdges,\n): DOMRect | null {\n const { modalRoot, portalContainer, rootProbe } = targets;\n if (!modalRoot || !modalRoot.contains(portalContainer)) return null;\n const rootRect = modalRoot.getBoundingClientRect();\n const rootEdges = rootProbe ? measureProbe(rootProbe) : edges;\n const rootStyle = getComputedStyle(modalRoot);\n const rootScaleX = rootEdges.origin.width;\n const rootScaleY = rootEdges.origin.height;\n // Axis-aligned bounding rects lose the padding origin under rotation/skew.\n // The root's own containing-block properties cover those cases; the probe\n // comparison below still handles nested portal containers geometrically.\n const rootOwnsBlock = hasFixedContainingStyle(rootStyle) ||\n edgesMatchPaddingBox(rootEdges, rootRect, rootStyle, rootScaleX, rootScaleY);\n // Evaluated even when the root owns the block, as the probe edges are always compared.\n const descendantOwnsBlock = rootProbe !== null && edgesDiffer(edges, rootEdges);\n const ownsBlock = rootOwnsBlock || descendantOwnsBlock;\n return ownsBlock && hasLayout(rootRect) ? rootRect : null;\n}\n\n/** The viewport rectangle, narrowed to the modal clip when there is one. */\nfunction resolveBounds(viewport: { width: number; height: number }, clip: DOMRect | null) {\n return {\n left: Math.max(0, clip?.left ?? 0),\n top: Math.max(0, clip?.top ?? 0),\n right: Math.min(viewport.width, clip?.right ?? viewport.width),\n bottom: Math.min(viewport.height, clip?.bottom ?? viewport.height),\n };\n}\n\n/** Measures the CSS width without a previous resize's inline clamp applied. */\nfunction measureCssWidth(panel: HTMLDivElement): number {\n const previousWidth = panel.style.width;\n if (previousWidth) panel.style.width = '';\n const cssWidth = panel.offsetWidth;\n if (previousWidth) panel.style.width = previousWidth;\n return cssWidth;\n}\n\n/**\n * Computes where the fixed-position panel belongs so it stays attached to its anchor\n * and clamped inside the viewport (or the modal that clips it).\n */\nexport function measurePanelPlacement(targets: PlacementTargets): PanelPosition {\n const { probe, panel, anchor: anchorElement } = targets;\n // The probe stays mounted while open, but its origin must be read on every\n // update: scrolling a transformed ancestor changes its viewport coordinates.\n const edges = measureProbe(probe);\n const { origin, bottom: containingBlockBottom } = edges;\n\n // offsetWidth is in local CSS pixels; the probe's rect supplies the viewport scale.\n // Preserve the viewport gutter even when a containing block scales the dropdown.\n const scaleX = origin.width || 1;\n const scaleY = origin.height || 1;\n const viewport = readViewport();\n const clip = resolveModalClip(targets, edges);\n const bounds = resolveBounds(viewport, clip);\n const visible = {\n width: Math.max(0, bounds.right - bounds.left),\n height: Math.max(0, bounds.bottom - bounds.top),\n };\n const cssWidth = measureCssWidth(panel);\n const width = cssWidth * scaleX > visible.width - viewportGutter\n ? Math.max(0, (visible.width - viewportGutter) / scaleX)\n : undefined;\n const anchor = anchorElement.getBoundingClientRect();\n const viewportPosition = resolveDropdownPosition({\n left: anchor.left - bounds.left,\n top: anchor.top - bounds.top,\n bottom: anchor.bottom - bounds.top,\n }, visible, (width ?? cssWidth) * scaleX);\n return {\n left: (bounds.left + viewportPosition.left - origin.left) / scaleX,\n top: viewportPosition.top === undefined ? undefined : (bounds.top + viewportPosition.top - origin.top) / scaleY,\n bottom: viewportPosition.bottom === undefined ? undefined\n : (containingBlockBottom - (bounds.bottom - viewportPosition.bottom)) / scaleY,\n maxHeight: viewportPosition.maxHeight / scaleY,\n width,\n };\n}\n"],"names":[],"mappings":";;AA0BO,MAAM,UAAU,GAAG;AAE1B,MAAM,aAAa,GAAG,GAAG;AACzB,MAAM,cAAc,GAAG,EAAE;AAGnB,SAAU,YAAY,CAAC,OAAuB,EAAA;AAChD,IAAA,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG;AACvB,IAAA,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM;AAC7B,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE;AAC9C,IAAA,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM;AAC1B,IAAA,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,MAAM;AACrD,IAAA,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM;AAC7B,IAAA,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM;AAC3B,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG;IACzB,MAAM,KAAK,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK;AACnD,IAAA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BAAgB,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM;QAClE,GAAG,EAAE,gBAAgB,CAAC,GAAG,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,gBAAgB,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM;QAC/G,MAAM,EAAE,gBAAgB,CAAC,MAAM,KAAK,SAAS,GAAG;AAC5C,cAAE,CAAC,qBAAqB,IAAI,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM;AAClF,QAAA,SAAS,EAAE,gBAAgB,CAAC,SAAS,GAAG,MAAM;QAC9C,KAAK;KACR;AACL;;"}
1
+ {"version":3,"file":"measurePanelPlacement.js","sources":["../../../Filter/measurePanelPlacement.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, probeStyle, type ProbeEdges } from '../renderer/fixedProbe';\nimport { resolveDropdownPosition, type DropdownPosition } from './utils';\n\nexport { measureProbe, probeStyle };\n\n/** Fixed-position panel placement, optionally with a clamped CSS width. */\nexport type PanelPosition = DropdownPosition & { width?: number };\n\n/** The probes (and the elements they sit in) the panel placement is measured against. */\nexport interface PlacementTargets {\n probe: HTMLDivElement;\n rootProbe: HTMLDivElement | null;\n modalRoot: HTMLElement | null | undefined;\n portalContainer: HTMLElement;\n panel: HTMLDivElement;\n anchor: HTMLButtonElement;\n}\n\nconst edgeTolerance = 0.5;\nconst viewportGutter = 32;\n\n/** Layoutless renderers report zero; browser layout uses the scrollbar-free viewport. */\nfunction readViewport(): { width: number; height: number } {\n // In quirks mode the viewport's client size is reported on the body, not the root.\n const viewportElement = document.compatMode === 'BackCompat' ? document.body : document.documentElement;\n return {\n width: viewportElement.clientWidth || window.innerWidth,\n height: viewportElement.clientHeight || window.innerHeight,\n };\n}\n\n/** Properties whose non-\"none\" value makes an element the containing block of fixed descendants. */\nconst fixedContainingProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'] as const;\n\nconst containLayoutPattern = /\\b(?:layout|paint|strict|content)\\b/u;\nconst containerTypePattern = /^(?:size|inline-size)$/u;\nconst willChangePattern = /\\b(?:transform|translate|scale|rotate|perspective|filter|backdrop-filter|contain|container-type)\\b/u;\n\nfunction hasBackdropFilter(rootStyle: CSSStyleDeclaration): boolean {\n return rootStyle.getPropertyValue('backdrop-filter') !== 'none' &&\n rootStyle.getPropertyValue('backdrop-filter') !== '';\n}\n\nfunction hasFixedContainingStyle(rootStyle: CSSStyleDeclaration): boolean {\n if (fixedContainingProperties.some(property => rootStyle[property] !== 'none')) return true;\n if (hasBackdropFilter(rootStyle)) return true;\n return containLayoutPattern.test(rootStyle.contain) ||\n containerTypePattern.test(rootStyle.getPropertyValue('container-type')) ||\n willChangePattern.test(rootStyle.willChange);\n}\n\n/**\n * A fixed probe spans its containing block, not the Dialog's overflow box.\n * Compare all four edges to the root's padding box: a side dialog can share\n * the positioner's top-left origin without sharing its containing block.\n * Comparing to innerWidth/innerHeight instead would mistake classic scrollbars\n * (excluded from the layout viewport) for a transformed containing block.\n */\nfunction edgesMatchPaddingBox(\n rootEdges: ProbeEdges,\n rootRect: DOMRect,\n rootStyle: CSSStyleDeclaration,\n scaleX: number,\n scaleY: number,\n): boolean {\n // Lazy checks: each edge is read only when the previous edges matched.\n const edgeChecks: Array<() => boolean> = [\n () => Math.abs(rootEdges.origin.left - (rootRect.left + parseFloat(rootStyle.borderLeftWidth) * scaleX)) <= edgeTolerance,\n () => Math.abs(rootEdges.origin.top - (rootRect.top + parseFloat(rootStyle.borderTopWidth) * scaleY)) <= edgeTolerance,\n () => Math.abs(rootEdges.right - (rootRect.right - parseFloat(rootStyle.borderRightWidth) * scaleX)) <= edgeTolerance,\n () => Math.abs(rootEdges.bottom - (rootRect.bottom - parseFloat(rootStyle.borderBottomWidth) * scaleY)) <= edgeTolerance,\n ];\n return edgeChecks.every(check => check());\n}\n\nfunction edgesDiffer(probeEdges: ProbeEdges, rootEdges: ProbeEdges): boolean {\n // Lazy checks: each edge is read only when the previous edges did not differ.\n const edgeChecks: Array<() => boolean> = [\n () => Math.abs(probeEdges.origin.left - rootEdges.origin.left) > edgeTolerance,\n () => Math.abs(probeEdges.origin.top - rootEdges.origin.top) > edgeTolerance,\n () => Math.abs(probeEdges.right - rootEdges.right) > edgeTolerance,\n () => Math.abs(probeEdges.bottom - rootEdges.bottom) > edgeTolerance,\n ];\n return edgeChecks.some(check => check());\n}\n\n/** Layoutless environments cannot supply a modal clip rect. */\nfunction hasLayout(rect: DOMRect): boolean {\n return rect.right > rect.left && rect.bottom > rect.top;\n}\n\n/** The modal's rect when the modal or the portal's descendant block owns the fixed containing block. */\nfunction resolveModalClip(\n targets: PlacementTargets,\n edges: ProbeEdges,\n): DOMRect | null {\n const { modalRoot, portalContainer, rootProbe } = targets;\n if (!modalRoot || !modalRoot.contains(portalContainer)) return null;\n const rootRect = modalRoot.getBoundingClientRect();\n const rootEdges = rootProbe ? measureProbe(rootProbe) : edges;\n const rootStyle = getComputedStyle(modalRoot);\n const rootScaleX = rootEdges.origin.width;\n const rootScaleY = rootEdges.origin.height;\n // Axis-aligned bounding rects lose the padding origin under rotation/skew.\n // The root's own containing-block properties cover those cases; the probe\n // comparison below still handles nested portal containers geometrically.\n const rootOwnsBlock = hasFixedContainingStyle(rootStyle) ||\n edgesMatchPaddingBox(rootEdges, rootRect, rootStyle, rootScaleX, rootScaleY);\n // Evaluated even when the root owns the block, as the probe edges are always compared.\n const descendantOwnsBlock = rootProbe !== null && edgesDiffer(edges, rootEdges);\n const ownsBlock = rootOwnsBlock || descendantOwnsBlock;\n return ownsBlock && hasLayout(rootRect) ? rootRect : null;\n}\n\n/** The viewport rectangle, narrowed to the modal clip when there is one. */\nfunction resolveBounds(viewport: { width: number; height: number }, clip: DOMRect | null) {\n return {\n left: Math.max(0, clip?.left ?? 0),\n top: Math.max(0, clip?.top ?? 0),\n right: Math.min(viewport.width, clip?.right ?? viewport.width),\n bottom: Math.min(viewport.height, clip?.bottom ?? viewport.height),\n };\n}\n\n/** Measures the CSS width without a previous resize's inline clamp applied. */\nfunction measureCssWidth(panel: HTMLDivElement): number {\n const previousWidth = panel.style.width;\n if (previousWidth) panel.style.width = '';\n const cssWidth = panel.offsetWidth;\n if (previousWidth) panel.style.width = previousWidth;\n return cssWidth;\n}\n\n/**\n * Computes where the fixed-position panel belongs so it stays attached to its anchor\n * and clamped inside the viewport (or the modal that clips it).\n */\nexport function measurePanelPlacement(targets: PlacementTargets): PanelPosition {\n const { probe, panel, anchor: anchorElement } = targets;\n // The probe stays mounted while open, but its origin must be read on every\n // update: scrolling a transformed ancestor changes its viewport coordinates.\n const edges = measureProbe(probe);\n const { origin, bottom: containingBlockBottom } = edges;\n\n // offsetWidth is in local CSS pixels; the probe's rect supplies the viewport scale.\n // Preserve the viewport gutter even when a containing block scales the dropdown.\n const scaleX = origin.width || 1;\n const scaleY = origin.height || 1;\n const viewport = readViewport();\n const clip = resolveModalClip(targets, edges);\n const bounds = resolveBounds(viewport, clip);\n const visible = {\n width: Math.max(0, bounds.right - bounds.left),\n height: Math.max(0, bounds.bottom - bounds.top),\n };\n const cssWidth = measureCssWidth(panel);\n const width = cssWidth * scaleX > visible.width - viewportGutter\n ? Math.max(0, (visible.width - viewportGutter) / scaleX)\n : undefined;\n const anchor = anchorElement.getBoundingClientRect();\n const viewportPosition = resolveDropdownPosition({\n left: anchor.left - bounds.left,\n top: anchor.top - bounds.top,\n bottom: anchor.bottom - bounds.top,\n }, visible, (width ?? cssWidth) * scaleX);\n return {\n left: (bounds.left + viewportPosition.left - origin.left) / scaleX,\n top: viewportPosition.top === undefined ? undefined : (bounds.top + viewportPosition.top - origin.top) / scaleY,\n bottom: viewportPosition.bottom === undefined ? undefined\n : (containingBlockBottom - (bounds.bottom - viewportPosition.bottom)) / scaleY,\n maxHeight: viewportPosition.maxHeight / scaleY,\n width,\n };\n}\n"],"names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GAAG,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,gBAAgB,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM;QAC/G,MAAM,EAAE,gBAAgB,CAAC,MAAM,KAAK,SAAS,GAAG;AAC5C,cAAE,CAAC,qBAAqB,IAAI,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM;AAClF,QAAA,SAAS,EAAE,gBAAgB,CAAC,SAAS,GAAG,MAAM;QAC9C,KAAK;KACR;AACL;;"}
@@ -1,5 +1,6 @@
1
1
  import { useState, useLayoutEffect } from 'react';
2
- import { probeStyle, measurePanelPlacement } from './measurePanelPlacement.js';
2
+ import { measurePanelPlacement } from './measurePanelPlacement.js';
3
+ import { probeStyle } from '../renderer/fixedProbe.js';
3
4
 
4
5
  const motionEvents = ['animationend', 'animationcancel', 'transitionend'];
5
6
  function usePanelPosition({ isOpen, portalContainer, modalRoot, anchorRef, panelRef, resolvedAnchor, }) {
@@ -1 +1 @@
1
- {"version":3,"file":"usePanelPosition.js","sources":["../../../Filter/usePanelPosition.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 type { RefObject } from 'react';\nimport {\n measurePanelPlacement,\n probeStyle,\n type PanelPosition,\n} from './measurePanelPlacement';\n\nconst motionEvents = ['animationend', 'animationcancel', 'transitionend'] as const;\n\n/** What the panel position tracks. */\nexport interface UsePanelPositionOptions {\n isOpen: boolean;\n portalContainer: HTMLElement | null;\n modalRoot: HTMLElement | null | undefined;\n anchorRef: RefObject<HTMLButtonElement | null>;\n panelRef: RefObject<HTMLDivElement | null>;\n /** The resolved anchor element; re-runs the effect when the anchor changes. */\n resolvedAnchor: HTMLButtonElement | null | undefined;\n}\n\n/**\n * Keeps the fixed-position portal attached to its anchor and clamped inside the viewport.\n * A transform (or other fixed containing-block property) on the portal container OR any\n * ancestor changes the meaning of CSS left/top/bottom. A fixed probe in the portal sees\n * exactly the same containing block as the panel, without guessing which ancestor owns it.\n * Capture-phase scroll observation also covers nested scrolling containers.\n *\n * @param options - What the position tracks.\n * @returns The current fixed-position placement of the panel.\n */\nexport function usePanelPosition({\n isOpen,\n portalContainer,\n modalRoot,\n anchorRef,\n panelRef,\n resolvedAnchor,\n}: UsePanelPositionOptions): PanelPosition {\n const [position, setPosition] = useState<PanelPosition>({\n top: 0,\n left: 0,\n maxHeight: 0,\n });\n\n useLayoutEffect(() => {\n if (!isOpen || !portalContainer) return;\n\n const probe = document.createElement('div');\n probe.style.cssText = probeStyle;\n portalContainer.appendChild(probe);\n // A portal inside (rather than directly on) the root can have a different fixed\n // containing block. A second probe distinguishes that descendant block from one\n // owned by the positioner outside the root.\n const rootProbe = modalRoot && modalRoot.contains(portalContainer) && portalContainer !== modalRoot\n ? document.createElement('div') : null;\n if (rootProbe && modalRoot) {\n rootProbe.style.cssText = probeStyle;\n modalRoot.appendChild(rootProbe);\n }\n\n const updatePosition = () => {\n const anchor = anchorRef.current;\n const panel = panelRef.current;\n if (!anchor || !panel) return;\n\n const nextPosition = measurePanelPlacement({\n probe,\n rootProbe,\n modalRoot,\n portalContainer,\n panel,\n anchor,\n });\n setPosition((previous) => previous.left === nextPosition.left &&\n previous.top === nextPosition.top && previous.bottom === nextPosition.bottom &&\n previous.maxHeight === nextPosition.maxHeight && previous.width === nextPosition.width\n ? previous : nextPosition);\n };\n\n // A Dialog's entry motion may change the fixed-position containing block.\n // Measure again when its root or positioner stops moving.\n let animationFrame: number | undefined;\n const schedulePosition = () => {\n if (animationFrame !== undefined) return;\n animationFrame = requestAnimationFrame(() => {\n animationFrame = undefined;\n updatePosition();\n });\n };\n const handleScroll = (event: Event) => {\n if (event.target instanceof Node && panelRef.current?.contains(event.target)) return;\n schedulePosition();\n };\n // Consumers may replace the Dialog's entry animation or animate its positioner.\n // Ignore events bubbling from controls inside the dialog; one frame is enough for\n // any number of animations or transitions ending in the same rendering frame.\n const positioner = modalRoot?.parentElement?.matches('[data-cratis-part=\"positioner\"]')\n ? modalRoot.parentElement : null;\n const handleModalMotionEnd = (event: Event) => {\n if (event.target === modalRoot || event.target === positioner) schedulePosition();\n };\n\n updatePosition();\n window.addEventListener('resize', schedulePosition);\n window.addEventListener('scroll', handleScroll, true);\n for (const eventName of motionEvents) {\n modalRoot?.addEventListener(eventName, handleModalMotionEnd);\n positioner?.addEventListener(eventName, handleModalMotionEnd);\n }\n\n return () => {\n if (animationFrame !== undefined) cancelAnimationFrame(animationFrame);\n window.removeEventListener('resize', schedulePosition);\n window.removeEventListener('scroll', handleScroll, true);\n for (const eventName of motionEvents) {\n modalRoot?.removeEventListener(eventName, handleModalMotionEnd);\n positioner?.removeEventListener(eventName, handleModalMotionEnd);\n }\n probe.remove();\n rootProbe?.remove();\n };\n }, [anchorRef, panelRef, isOpen, modalRoot, portalContainer, resolvedAnchor]);\n\n return position;\n}\n"],"names":[],"mappings":";;;AAWA,MAAM,YAAY,GAAG,CAAC,cAAc,EAAE,iBAAiB,EAAE,eAAe,CAAU;AAuB5E,SAAU,gBAAgB,CAAC,EAC7B,MAAM,EACN,eAAe,EACf,SAAS,EACT,SAAS,EACT,QAAQ,EACR,cAAc,GACQ,EAAA;AACtB,IAAA,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAgB;AACpD,QAAA,GAAG,EAAE,CAAC;AACN,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,SAAS,EAAE,CAAC;AACf,KAAA,CAAC;IAEF,eAAe,CAAC,MAAK;AACjB,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe;YAAE;QAEjC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AAC3C,QAAA,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU;AAChC,QAAA,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC;AAI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MAAM,EAAE;YACd,SAAS,EAAE,MAAM,EAAE;AACvB,QAAA,CAAC;AACL,IAAA,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;AAE7E,IAAA,OAAO,QAAQ;AACnB;;"}
1
+ {"version":3,"file":"usePanelPosition.js","sources":["../../../Filter/usePanelPosition.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 type { RefObject } from 'react';\nimport {\n measurePanelPlacement,\n probeStyle,\n type PanelPosition,\n} from './measurePanelPlacement';\n\nconst motionEvents = ['animationend', 'animationcancel', 'transitionend'] as const;\n\n/** What the panel position tracks. */\nexport interface UsePanelPositionOptions {\n isOpen: boolean;\n portalContainer: HTMLElement | null;\n modalRoot: HTMLElement | null | undefined;\n anchorRef: RefObject<HTMLButtonElement | null>;\n panelRef: RefObject<HTMLDivElement | null>;\n /** The resolved anchor element; re-runs the effect when the anchor changes. */\n resolvedAnchor: HTMLButtonElement | null | undefined;\n}\n\n/**\n * Keeps the fixed-position portal attached to its anchor and clamped inside the viewport.\n * A transform (or other fixed containing-block property) on the portal container OR any\n * ancestor changes the meaning of CSS left/top/bottom. A fixed probe in the portal sees\n * exactly the same containing block as the panel, without guessing which ancestor owns it.\n * Capture-phase scroll observation also covers nested scrolling containers.\n *\n * @param options - What the position tracks.\n * @returns The current fixed-position placement of the panel.\n */\nexport function usePanelPosition({\n isOpen,\n portalContainer,\n modalRoot,\n anchorRef,\n panelRef,\n resolvedAnchor,\n}: UsePanelPositionOptions): PanelPosition {\n const [position, setPosition] = useState<PanelPosition>({\n top: 0,\n left: 0,\n maxHeight: 0,\n });\n\n useLayoutEffect(() => {\n if (!isOpen || !portalContainer) return;\n\n const probe = document.createElement('div');\n probe.style.cssText = probeStyle;\n portalContainer.appendChild(probe);\n // A portal inside (rather than directly on) the root can have a different fixed\n // containing block. A second probe distinguishes that descendant block from one\n // owned by the positioner outside the root.\n const rootProbe = modalRoot && modalRoot.contains(portalContainer) && portalContainer !== modalRoot\n ? document.createElement('div') : null;\n if (rootProbe && modalRoot) {\n rootProbe.style.cssText = probeStyle;\n modalRoot.appendChild(rootProbe);\n }\n\n const updatePosition = () => {\n const anchor = anchorRef.current;\n const panel = panelRef.current;\n if (!anchor || !panel) return;\n\n const nextPosition = measurePanelPlacement({\n probe,\n rootProbe,\n modalRoot,\n portalContainer,\n panel,\n anchor,\n });\n setPosition((previous) => previous.left === nextPosition.left &&\n previous.top === nextPosition.top && previous.bottom === nextPosition.bottom &&\n previous.maxHeight === nextPosition.maxHeight && previous.width === nextPosition.width\n ? previous : nextPosition);\n };\n\n // A Dialog's entry motion may change the fixed-position containing block.\n // Measure again when its root or positioner stops moving.\n let animationFrame: number | undefined;\n const schedulePosition = () => {\n if (animationFrame !== undefined) return;\n animationFrame = requestAnimationFrame(() => {\n animationFrame = undefined;\n updatePosition();\n });\n };\n const handleScroll = (event: Event) => {\n if (event.target instanceof Node && panelRef.current?.contains(event.target)) return;\n schedulePosition();\n };\n // Consumers may replace the Dialog's entry animation or animate its positioner.\n // Ignore events bubbling from controls inside the dialog; one frame is enough for\n // any number of animations or transitions ending in the same rendering frame.\n const positioner = modalRoot?.parentElement?.matches('[data-cratis-part=\"positioner\"]')\n ? modalRoot.parentElement : null;\n const handleModalMotionEnd = (event: Event) => {\n if (event.target === modalRoot || event.target === positioner) schedulePosition();\n };\n\n updatePosition();\n window.addEventListener('resize', schedulePosition);\n window.addEventListener('scroll', handleScroll, true);\n for (const eventName of motionEvents) {\n modalRoot?.addEventListener(eventName, handleModalMotionEnd);\n positioner?.addEventListener(eventName, handleModalMotionEnd);\n }\n\n return () => {\n if (animationFrame !== undefined) cancelAnimationFrame(animationFrame);\n window.removeEventListener('resize', schedulePosition);\n window.removeEventListener('scroll', handleScroll, true);\n for (const eventName of motionEvents) {\n modalRoot?.removeEventListener(eventName, handleModalMotionEnd);\n positioner?.removeEventListener(eventName, handleModalMotionEnd);\n }\n probe.remove();\n rootProbe?.remove();\n };\n }, [anchorRef, panelRef, isOpen, modalRoot, portalContainer, resolvedAnchor]);\n\n return position;\n}\n"],"names":[],"mappings":";;;;AAWA,MAAM,YAAY,GAAG,CAAC,cAAc,EAAE,iBAAiB,EAAE,eAAe,CAAU;AAuB5E,SAAU,gBAAgB,CAAC,EAC7B,MAAM,EACN,eAAe,EACf,SAAS,EACT,SAAS,EACT,QAAQ,EACR,cAAc,GACQ,EAAA;AACtB,IAAA,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAgB;AACpD,QAAA,GAAG,EAAE,CAAC;AACN,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,SAAS,EAAE,CAAC;AACf,KAAA,CAAC;IAEF,eAAe,CAAC,MAAK;AACjB,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe;YAAE;QAEjC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AAC3C,QAAA,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU;AAChC,QAAA,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC;AAIlC,QAAA,MAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,eAAe,KAAK;cACpF,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI;AAC1C,QAAA,IAAI,SAAS,IAAI,SAAS,EAAE;AACxB,YAAA,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU;AACpC,YAAA,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC;QACpC;QAEA,MAAM,cAAc,GAAG,MAAK;AACxB,YAAA,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO;AAChC,YAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO;AAC9B,YAAA,IAAI,C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AAA,CAAC;AAED,QAAA,cAAc,EAAE;AAChB,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;QACnD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC;AACrD,QAAA,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE;AAClC,YAAA,SAAS,EAAE,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,CAAC;AAC5D,YAAA,UAAU,EAAE,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,CAAC;QACjE;AAEA,QAAA,OAAO,MAAK;YACR,IAAI,cAAc,KAAK,SAAS;gBAAE,oBAAoB,CAAC,cAAc,CAAC;AACtE,YAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;YACtD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC;AACxD,YAAA,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE;AAClC,gBAAA,SAAS,EAAE,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,CAAC;AAC/D,gBAAA,UAAU,EAAE,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,CAAC;YACpE;YACA,KAAK,CAAC,MAAM,EAAE;YACd,SAAS,EAAE,MAAM,EAAE;AACvB,QAAA,CAAC;AACL,IAAA,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;AAE7E,IAAA,OAAO,QAAQ;AACnB;;"}
@@ -0,0 +1,11 @@
1
+ /** Edges of a fixed-position probe's containing block. */
2
+ export interface ProbeEdges {
3
+ origin: DOMRect;
4
+ bottom: number;
5
+ right: number;
6
+ }
7
+ /** Inline style that makes an element a fixed, invisible, 1px probe. */
8
+ export declare const probeStyle = "position:fixed;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none";
9
+ /** Measures the origin, bottom and right edges of a fixed probe's containing block. */
10
+ export declare function measureProbe(element: HTMLDivElement): ProbeEdges;
11
+ //# sourceMappingURL=fixedProbe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixedProbe.d.ts","sourceRoot":"","sources":["../../../renderer/fixedProbe.ts"],"names":[],"mappings":"AAGA,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wEAAwE;AACxE,eAAO,MAAM,UAAU,uHAAuH,CAAC;AAE/I,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,CAchE"}
@@ -0,0 +1,19 @@
1
+ const probeStyle = 'position:fixed;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none';
2
+ function measureProbe(element) {
3
+ element.style.top = '0';
4
+ element.style.bottom = 'auto';
5
+ const origin = element.getBoundingClientRect();
6
+ element.style.top = 'auto';
7
+ element.style.bottom = '0';
8
+ const bottom = element.getBoundingClientRect().bottom;
9
+ element.style.bottom = 'auto';
10
+ element.style.left = 'auto';
11
+ element.style.right = '0';
12
+ const right = element.getBoundingClientRect().right;
13
+ element.style.left = '0';
14
+ element.style.right = 'auto';
15
+ return { origin, bottom, right };
16
+ }
17
+
18
+ export { measureProbe, probeStyle };
19
+ //# sourceMappingURL=fixedProbe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixedProbe.js","sources":["../../../renderer/fixedProbe.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\n/** Edges of a fixed-position probe's containing block. */\nexport interface ProbeEdges {\n origin: DOMRect;\n bottom: number;\n right: number;\n}\n\n/** Inline style that makes an element a fixed, invisible, 1px probe. */\nexport const probeStyle = 'position:fixed;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none';\n\n/** Measures the origin, bottom and right edges of a fixed probe's containing block. */\nexport function measureProbe(element: HTMLDivElement): ProbeEdges {\n element.style.top = '0';\n element.style.bottom = 'auto';\n const origin = element.getBoundingClientRect();\n element.style.top = 'auto';\n element.style.bottom = '0';\n const bottom = element.getBoundingClientRect().bottom;\n element.style.bottom = 'auto';\n element.style.left = 'auto';\n element.style.right = '0';\n const right = element.getBoundingClientRect().right;\n element.style.left = '0';\n element.style.right = 'auto';\n return { origin, bottom, right };\n}\n"],"names":[],"mappings":"AAWO,MAAM,UAAU,GAAG;AAGpB,SAAU,YAAY,CAAC,OAAuB,EAAA;AAChD,IAAA,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG;AACvB,IAAA,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM;AAC7B,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE;AAC9C,IAAA,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM;AAC1B,IAAA,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,MAAM;AACrD,IAAA,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM;AAC7B,IAAA,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM;AAC3B,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG;IACzB,MAAM,KAAK,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK;AACnD,IAAA,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG;AACxB,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM;AAC5B,IAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;AACpC;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/components",
3
- "version": "4.41.4",
3
+ "version": "4.41.6",
4
4
  "description": "React components for CQRS and event-sourced apps — command dialogs, typed forms, and query-backed data tables for Cratis Arc",
5
5
  "keywords": [
6
6
  "react",