@os-design/core 1.0.276 → 1.0.277

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.
@@ -12,7 +12,7 @@ export interface PopoverProps extends JsxDivProps, WithSize {
12
12
  * Where the popover will be rendered.
13
13
  * @default document.body
14
14
  */
15
- container?: Element | RefObject<Element>;
15
+ container?: RefObject<Element> | Element | null;
16
16
  /**
17
17
  * On which side of the element the popover will appear.
18
18
  * @default top
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Popover/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAW9D,OAAO,EAGL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAA2B,EACzB,KAAK,SAAS,EACd,KAAK,IAAI,EACV,MAAM,+BAA+B,CAAC;AAEvC,KAAK,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7D,MAAM,WAAW,YAAa,SAAQ,WAAW,EAAE,QAAQ;IACzD;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAuDD;;GAEG;AACH,QAAA,MAAM,OAAO,yGAyHZ,CAAC;AAIF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Popover/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAW9D,OAAO,EAGL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAA2B,EACzB,KAAK,SAAS,EACd,KAAK,IAAI,EACV,MAAM,+BAA+B,CAAC;AAEvC,KAAK,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7D,MAAM,WAAW,YAAa,SAAQ,WAAW,EAAE,QAAQ;IACzD;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAuDD;;GAEG;AACH,QAAA,MAAM,OAAO,yGAkIZ,CAAC;AAIF,eAAe,OAAO,CAAC"}
@@ -88,9 +88,17 @@ const Popover = /*#__PURE__*/forwardRef(({
88
88
  current
89
89
  } = trigger;
90
90
  if (!current) return;
91
- setTriggerRect(current.getBoundingClientRect());
91
+ const rect = current.getBoundingClientRect();
92
+ if (container) {
93
+ const containerElement = container instanceof Element ? container : container.current;
94
+ if (!containerElement) return;
95
+ const containerRect = containerElement.getBoundingClientRect();
96
+ rect.x -= containerRect.x;
97
+ rect.y -= containerRect.y;
98
+ }
99
+ setTriggerRect(rect);
92
100
  });
93
- }, [trigger]);
101
+ }, [container, trigger]);
94
102
  useBrowserLayoutEffect(() => {
95
103
  if (!visible) return;
96
104
  triggerResizeListener();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os-design/core",
3
- "version": "1.0.276",
3
+ "version": "1.0.277",
4
4
  "license": "UNLICENSED",
5
5
  "repository": "git@gitlab.com:os-team/libs/os-design.git",
6
6
  "type": "module",
@@ -58,5 +58,5 @@
58
58
  "react": "18",
59
59
  "react-dom": "18"
60
60
  },
61
- "gitHead": "59dea037dfe43e783a9e6f5e3d45788fdcc0ce97"
61
+ "gitHead": "73c07308561addb0b095734a9a9bd3e3a773fa61"
62
62
  }
@@ -37,7 +37,7 @@ export interface PopoverProps extends JsxDivProps, WithSize {
37
37
  * Where the popover will be rendered.
38
38
  * @default document.body
39
39
  */
40
- container?: Element | RefObject<Element>;
40
+ container?: RefObject<Element> | Element | null;
41
41
  /**
42
42
  * On which side of the element the popover will appear.
43
43
  * @default top
@@ -169,9 +169,18 @@ const Popover = forwardRef<HTMLDivElement, PopoverProps>(
169
169
  if (!trigger) return;
170
170
  const { current } = trigger as RefObject<Element>;
171
171
  if (!current) return;
172
- setTriggerRect(current.getBoundingClientRect());
172
+ const rect = current.getBoundingClientRect();
173
+ if (container) {
174
+ const containerElement =
175
+ container instanceof Element ? container : container.current;
176
+ if (!containerElement) return;
177
+ const containerRect = containerElement.getBoundingClientRect();
178
+ rect.x -= containerRect.x;
179
+ rect.y -= containerRect.y;
180
+ }
181
+ setTriggerRect(rect);
173
182
  });
174
- }, [trigger]);
183
+ }, [container, trigger]);
175
184
  useBrowserLayoutEffect(() => {
176
185
  if (!visible) return;
177
186
  triggerResizeListener();