@cronocode/react-box 1.3.3 → 1.3.5

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,15 +1,15 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as i } from "react";
3
- import p from "../box.mjs";
4
- import { O as e } from "../utils/utils.mjs";
2
+ import { forwardRef as p } from "react";
3
+ import i from "../box.mjs";
4
+ import { O as m } from "../utils/utils.mjs";
5
5
  import "../box.module.css.mjs";
6
6
  import "../theme.mjs";
7
7
  const s = ["type", "onClick", "disabled"];
8
- function m(o, t) {
9
- const r = e.buildProps(o, s);
10
- return /* @__PURE__ */ n(p, { ref: t, tag: "button", inline: !0, cursor: "pointer", component: "button", ...r });
8
+ function e(o, t) {
9
+ const r = m.buildProps(o, s);
10
+ return /* @__PURE__ */ n(i, { ref: t, tag: "button", component: "button", ...r });
11
11
  }
12
- const d = i(m);
12
+ const l = p(e);
13
13
  export {
14
- d as default
14
+ l as default
15
15
  };
@@ -20,7 +20,7 @@ const p = [
20
20
  function m(o, r) {
21
21
  const { native: n } = o, i = a.buildProps(o, p, { type: "checkbox" });
22
22
  return /* @__PURE__ */ c(l, { inline: !0, position: "relative", children: [
23
- /* @__PURE__ */ e(t, { ref: r, tag: "input", inline: !0, b: 1, p: 2, component: "checkbox", ...i, appearance: n ? void 0 : "none" }),
23
+ /* @__PURE__ */ e(t, { ref: r, tag: "input", component: "checkbox", ...i, appearance: n ? void 0 : "none" }),
24
24
  !n && /* @__PURE__ */ e(t, { position: "absolute", pointerEvents: "none", className: d._checkedIcon, children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100%", viewBox: "0 0 20 20", children: /* @__PURE__ */ e("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ e("path", { stroke: "#000", strokeLinecap: "round", strokeLinejoin: "round", d: "M6 10.15L8.5 13 14 7" }) }) }) })
25
25
  ] });
26
26
  }
@@ -1,17 +1,4 @@
1
1
  import Box from '../box';
2
- import { Activated, Focused, Hovered } from '../types';
3
2
  type BoxProps = React.ComponentProps<typeof Box>;
4
- interface FlexStylesShortCuts {
5
- wrap?: BoxProps['flexWrap'];
6
- jc?: BoxProps['justifyContent'];
7
- ai?: BoxProps['alignItems'];
8
- ac?: BoxProps['alignContent'];
9
- d?: BoxProps['flexDirection'];
10
- grow?: BoxProps['flexGrow'];
11
- shrink?: BoxProps['flexShrink'];
12
- as?: BoxProps['alignSelf'];
13
- js?: BoxProps['justifySelf'];
14
- }
15
- type Props = BoxProps & FlexStylesShortCuts & Hovered<FlexStylesShortCuts> & Focused<FlexStylesShortCuts> & Activated<FlexStylesShortCuts>;
16
- export default function Flex(props: Props): JSX.Element;
3
+ export default function Flex(props: BoxProps): JSX.Element;
17
4
  export {};
@@ -16,7 +16,6 @@ interface Props extends Omit<BoxProps, 'props'> {
16
16
  required?: boolean;
17
17
  checked?: boolean;
18
18
  defaultChecked?: boolean;
19
- native?: boolean;
20
19
  }
21
20
  declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
22
21
  export default _default;
@@ -1,10 +1,10 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as a } from "react";
3
- import i from "../box.mjs";
4
- import { O as d } from "../utils/utils.mjs";
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { forwardRef as n } from "react";
3
+ import a from "../box.mjs";
4
+ import { O as i } from "../utils/utils.mjs";
5
5
  import "../box.module.css.mjs";
6
6
  import "../theme.mjs";
7
- const p = [
7
+ const d = [
8
8
  "name",
9
9
  "onInput",
10
10
  "onChange",
@@ -16,11 +16,11 @@ const p = [
16
16
  "checked",
17
17
  "defaultChecked"
18
18
  ];
19
- function u(o, t) {
20
- const { native: e } = o, n = d.buildProps(o, p, { type: "radio" });
21
- return /* @__PURE__ */ r(i, { ref: t, tag: "input", inline: !0, b: 1, p: 2, component: "radioButton", ...n, appearance: e ? void 0 : "none" });
19
+ function p(o, t) {
20
+ const r = i.buildProps(o, d, { type: "radio" });
21
+ return /* @__PURE__ */ e(a, { ref: t, tag: "input", component: "radioButton", ...r });
22
22
  }
23
- const B = a(u);
23
+ const B = n(p);
24
24
  export {
25
25
  B as default
26
26
  };
@@ -1,10 +1,10 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { forwardRef as a } from "react";
3
3
  import n from "../box.mjs";
4
- import { O as i } from "../utils/utils.mjs";
4
+ import { O as m } from "../utils/utils.mjs";
5
5
  import "../box.module.css.mjs";
6
6
  import "../theme.mjs";
7
- const m = [
7
+ const s = [
8
8
  "name",
9
9
  "onInput",
10
10
  "onChange",
@@ -20,11 +20,11 @@ const m = [
20
20
  "readOnly",
21
21
  "required"
22
22
  ];
23
- function s(t, e) {
24
- const o = i.buildProps(t, m);
25
- return /* @__PURE__ */ r(n, { ref: e, tag: "textarea", component: "textarea", inline: !0, ...o });
23
+ function p(t, o) {
24
+ const e = m.buildProps(t, s);
25
+ return /* @__PURE__ */ r(n, { ref: o, tag: "textarea", component: "textarea", ...e });
26
26
  }
27
- const x = a(s);
27
+ const x = a(p);
28
28
  export {
29
29
  x as default
30
30
  };
@@ -18,11 +18,11 @@ const i = [
18
18
  "value",
19
19
  "pattern"
20
20
  ];
21
- function u(t, o) {
22
- const e = p.buildProps(t, i);
23
- return /* @__PURE__ */ r(a, { ref: o, tag: "input", inline: !0, component: "textbox", ...e });
21
+ function m(o, t) {
22
+ const e = p.buildProps(o, i);
23
+ return /* @__PURE__ */ r(a, { ref: t, tag: "input", component: "textbox", ...e });
24
24
  }
25
- const c = n(u);
25
+ const c = n(m);
26
26
  export {
27
27
  c as default
28
28
  };
@@ -1,49 +1,57 @@
1
1
  import { jsxs as x, Fragment as b, jsx as a } from "react/jsx-runtime";
2
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";
3
+ import f from "../box.mjs";
4
+ import { useRef as L, useState as z, useCallback as c, useLayoutEffect as g } from "react";
5
5
  import { u as C } from "../utils/utils.mjs";
6
6
  import "../box.module.css.mjs";
7
7
  import "../theme.mjs";
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
- };
13
- return document.addEventListener("scroll", o, { capture: !0 }), () => {
14
- document.removeEventListener("scroll", o, { capture: !0 });
15
- };
16
- }, []), v = l((r, t) => {
17
- const o = (u) => {
18
- t();
19
- };
20
- return window.addEventListener("resize", o, { capture: !0 }), () => {
21
- window.removeEventListener("resize", o, { capture: !0 });
22
- };
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
- }, []);
8
+ function P(i) {
9
+ const { children: p, onPositionChange: s } = i, n = L(null), [t, d] = z(), m = C(), w = c(
10
+ (e, r) => {
11
+ const o = (u) => {
12
+ u.target.contains(e) && r();
13
+ };
14
+ return document.addEventListener("scroll", o, { capture: !0 }), () => {
15
+ document.removeEventListener("scroll", o, { capture: !0 });
16
+ };
17
+ },
18
+ [t]
19
+ ), v = c(
20
+ (e, r) => {
21
+ const o = (u) => {
22
+ r();
23
+ };
24
+ return window.addEventListener("resize", o, { capture: !0 }), () => {
25
+ window.removeEventListener("resize", o, { capture: !0 });
26
+ };
27
+ },
28
+ [t]
29
+ ), l = c(() => {
30
+ if (n.current) {
31
+ const e = n.current.getBoundingClientRect(), r = e.top + window.scrollY, o = e.left + window.scrollX;
32
+ ((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== o) && (s == null || s({ top: r, left: o }), d({ top: e.top + window.scrollY, left: e.left + window.scrollX }));
33
+ }
34
+ }, [t]);
27
35
  return g(() => {
28
- if (e.current) {
29
- i(e.current)();
30
- const r = w(e.current, i(e.current)), t = v(e.current, i(e.current));
36
+ if (n.current) {
37
+ l();
38
+ const e = w(n.current, l), r = v(n.current, l);
31
39
  return () => {
32
- r(), t();
40
+ e(), r();
33
41
  };
34
42
  }
35
- }, []), /* @__PURE__ */ x(b, { children: [
36
- /* @__PURE__ */ a(p, { ref: e, position: "absolute", top: 0, left: 0, ...c, children: void 0 }),
37
- s && E(
43
+ }, [t]), /* @__PURE__ */ x(b, { children: [
44
+ /* @__PURE__ */ a(f, { ref: n, position: "absolute", top: 0, left: 0, ...i, children: void 0 }),
45
+ t && E(
38
46
  /* @__PURE__ */ a(
39
- p,
47
+ f,
40
48
  {
41
49
  position: "absolute",
42
50
  top: 0,
43
51
  left: 0,
44
52
  transition: "none",
45
- style: { transform: `translate(${s.left}px,${s.top}px)` },
46
- children: d
53
+ style: { transform: `translate(${t.left}px,${t.top}px)` },
54
+ children: p
47
55
  }
48
56
  ),
49
57
  m
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "main": "./box.mjs",
5
5
  "module": "./box.mjs",
6
6
  "types": "./box.d.ts",