@cronocode/react-box 1.3.2 → 1.3.3

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.
@@ -1,8 +1,6 @@
1
- export interface GridCell<T> {
2
- key: keyof T;
3
- value: React.ReactNode;
4
- }
5
- export interface GridColumn<T extends {}> {
1
+ import { Grid } from './dataGridContract';
2
+ export default function useGrid<T extends {}>(data?: T[]): Grid<T>;
3
+ tends {}> {
6
4
  key: keyof T;
7
5
  }
8
6
  export interface GridRow<T extends {}> {
@@ -3,6 +3,10 @@ import { BoxPosition } from '../types';
3
3
  interface Props extends BoxPosition {
4
4
  children: React.ReactNode;
5
5
  style?: React.ComponentProps<'div'>['style'];
6
+ onPositionChange?(position: {
7
+ top: number;
8
+ left: number;
9
+ }): void;
6
10
  }
7
11
  export default function Tooltip(props: Props): JSX.Element;
8
12
  export {};
@@ -1,55 +1,55 @@
1
- import { jsxs as w, Fragment as x, jsx as u } from "react/jsx-runtime";
2
- import { createPortal as b } from "react-dom";
3
- import a from "../box.mjs";
4
- import { useRef as E, useState as L, useCallback as i, useLayoutEffect as g } from "react";
5
- import { u as z } from "../utils/utils.mjs";
1
+ import { jsxs as x, Fragment as b, jsx as a } from "react/jsx-runtime";
2
+ import { createPortal as E } from "react-dom";
3
+ import p from "../box.mjs";
4
+ import { useRef as L, useState as z, useCallback as l, useLayoutEffect as g } from "react";
5
+ import { u as C } from "../utils/utils.mjs";
6
6
  import "../box.module.css.mjs";
7
7
  import "../theme.mjs";
8
- function B(c) {
9
- const { children: p } = c, t = E(null), [n, d] = L(), f = z(), m = i((r, e) => {
10
- const o = (l) => {
11
- l.target.contains(r) && e();
8
+ function P(c) {
9
+ const { children: d, onPositionChange: n } = c, e = L(null), [s, f] = z(), m = C(), w = l((r, t) => {
10
+ const o = (u) => {
11
+ u.target.contains(r) && t();
12
12
  };
13
13
  return document.addEventListener("scroll", o, { capture: !0 }), () => {
14
14
  document.removeEventListener("scroll", o, { capture: !0 });
15
15
  };
16
- }, []), v = i((r, e) => {
17
- const o = (l) => {
18
- e();
16
+ }, []), v = l((r, t) => {
17
+ const o = (u) => {
18
+ t();
19
19
  };
20
20
  return window.addEventListener("resize", o, { capture: !0 }), () => {
21
21
  window.removeEventListener("resize", o, { capture: !0 });
22
22
  };
23
- }, []), s = i((r) => () => {
24
- const e = r.getBoundingClientRect();
25
- d({ top: e.top + window.scrollY, left: e.left + window.scrollX });
23
+ }, []), i = l((r) => () => {
24
+ const t = r.getBoundingClientRect();
25
+ f({ top: t.top + window.scrollY, left: t.left + window.scrollX }), n == null || n({ top: t.top + window.scrollY, left: t.left + window.scrollX });
26
26
  }, []);
27
27
  return g(() => {
28
- if (t.current) {
29
- s(t.current)();
30
- const r = m(t.current, s(t.current)), e = v(t.current, s(t.current));
28
+ if (e.current) {
29
+ i(e.current)();
30
+ const r = w(e.current, i(e.current)), t = v(e.current, i(e.current));
31
31
  return () => {
32
- r(), e();
32
+ r(), t();
33
33
  };
34
34
  }
35
- }, []), /* @__PURE__ */ w(x, { children: [
36
- /* @__PURE__ */ u(a, { ref: t, position: "absolute", top: 0, left: 0, ...c, children: void 0 }),
37
- n && b(
38
- /* @__PURE__ */ u(
39
- a,
35
+ }, []), /* @__PURE__ */ x(b, { children: [
36
+ /* @__PURE__ */ a(p, { ref: e, position: "absolute", top: 0, left: 0, ...c, children: void 0 }),
37
+ s && E(
38
+ /* @__PURE__ */ a(
39
+ p,
40
40
  {
41
41
  position: "absolute",
42
42
  top: 0,
43
43
  left: 0,
44
44
  transition: "none",
45
- style: { transform: `translate(${n.left}px,${n.top}px)` },
46
- children: p
45
+ style: { transform: `translate(${s.left}px,${s.top}px)` },
46
+ children: d
47
47
  }
48
48
  ),
49
- f
49
+ m
50
50
  )
51
51
  ] });
52
52
  }
53
53
  export {
54
- B as default
54
+ P as default
55
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "main": "./box.mjs",
5
5
  "module": "./box.mjs",
6
6
  "types": "./box.d.ts",