@cronocode/react-box 1.2.7 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/baseSvg.module.css.mjs +4 -0
- package/box.d.ts +2 -1
- package/box.mjs +18 -14
- package/box.module.css.mjs +1 -1
- package/components/baseSvg.mjs +14 -14
- package/components/{buttonCore.d.ts → button.d.ts} +3 -2
- package/components/button.mjs +15 -0
- package/components/{radioButtonCore.d.ts → checkbox.d.ts} +7 -5
- package/components/checkbox.mjs +30 -0
- package/components/dataGrid.d.ts +15 -0
- package/components/dataGrid.mjs +36 -0
- package/components/flex.mjs +1 -0
- package/components/form.d.ts +10 -0
- package/components/{formAsync.mjs → form.mjs} +6 -5
- package/components/{checkboxCore.d.ts → radioButton.d.ts} +7 -5
- package/components/radioButton.mjs +26 -0
- package/components/{textareaCore.d.ts → textarea.d.ts} +6 -4
- package/components/textarea.mjs +30 -0
- package/components/textbox.d.ts +3 -4
- package/components/textbox.mjs +11 -11
- package/components/tooltip.d.ts +8 -0
- package/components/tooltip.mjs +55 -0
- package/hooks/usePortalContainer.d.ts +1 -0
- package/package.json +5 -2
- package/style.css +1 -1
- package/theme.d.ts +30 -21
- package/theme.mjs +20 -20
- package/types.d.ts +12 -2
- package/utils/object/objectUtils.d.ts +1 -439
- package/utils/utils.mjs +60 -45
- package/components/buttonCore.mjs +0 -13
- package/components/checkboxCore.mjs +0 -25
- package/components/formAsync.d.ts +0 -10
- package/components/radioButtonCore.mjs +0 -25
- package/components/textareaCore.mjs +0 -29
- package/components/textboxCore.d.ts +0 -24
- package/components/textboxCore.mjs +0 -28
package/components/baseSvg.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { C as
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
const { children:
|
|
6
|
-
Object.entries(
|
|
7
|
-
const
|
|
8
|
-
|
|
1
|
+
import d, { useState as N } from "react";
|
|
2
|
+
import { C as x, t as m } from "../utils/utils.mjs";
|
|
3
|
+
import { c as a } from "../baseSvg.module.css.mjs";
|
|
4
|
+
function C(n) {
|
|
5
|
+
const { children: s, props: p, className: r, style: h, viewBox: u, width: v, height: g } = n, e = r ? x.classNames(r, a.base) : [a.base];
|
|
6
|
+
Object.entries(n).forEach(([o, l]) => {
|
|
7
|
+
const f = a[o + l];
|
|
8
|
+
f ? e.push(f) : o in m && e.push(`${m[o]}${l}`);
|
|
9
9
|
});
|
|
10
|
-
const
|
|
10
|
+
const t = {
|
|
11
11
|
...p,
|
|
12
|
-
style: { ...
|
|
12
|
+
style: { ...h, width: v, height: g },
|
|
13
13
|
className: e.join(" "),
|
|
14
|
-
viewBox:
|
|
14
|
+
viewBox: u || "0 0 24 24",
|
|
15
15
|
xmlns: "http://www.w3.org/2000/svg",
|
|
16
16
|
fill: "none"
|
|
17
|
-
}, [
|
|
18
|
-
return
|
|
17
|
+
}, [w, c] = N(!1), i = typeof s == "function";
|
|
18
|
+
return i && (t.onMouseEnter = () => c(!0), t.onMouseLeave = () => c(!1)), d.createElement("svg", t, i ? s({ isHover: w }) : s);
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
C as default
|
|
22
22
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import Box from '../box';
|
|
2
2
|
type BoxProps = Omit<React.ComponentProps<typeof Box<'button'>>, 'ref' | 'tag'>;
|
|
3
3
|
type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
-
|
|
4
|
+
declare const tagProps: readonly ["type", "onClick", "disabled"];
|
|
5
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
6
|
+
type ButtonTagProps = Omit<BoxTagProps, TagPropsType>;
|
|
5
7
|
type ButtonType = Required<React.ComponentProps<'button'>>['type'];
|
|
6
8
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
7
9
|
props?: ButtonTagProps;
|
|
8
10
|
type?: ButtonType;
|
|
9
11
|
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
10
|
-
disabled?: boolean;
|
|
11
12
|
}
|
|
12
13
|
declare const _default: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
14
|
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
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";
|
|
5
|
+
import "../box.module.css.mjs";
|
|
6
|
+
import "../theme.mjs";
|
|
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 });
|
|
11
|
+
}
|
|
12
|
+
const d = i(m);
|
|
13
|
+
export {
|
|
14
|
+
d as default
|
|
15
|
+
};
|
|
@@ -2,19 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import Box from '../box';
|
|
3
3
|
type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
|
|
4
4
|
type BoxTagProps = Required<BoxProps>['props'];
|
|
5
|
-
|
|
5
|
+
declare const tagProps: readonly ["name", "onInput", "onChange", "disabled", "autoFocus", "readOnly", "required", "value", "checked", "defaultChecked"];
|
|
6
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
7
|
+
type CheckboxTagProps = Omit<BoxTagProps, TagPropsType | 'type'>;
|
|
6
8
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
7
9
|
name?: string;
|
|
8
|
-
props?:
|
|
9
|
-
onInput?: (e: React.
|
|
10
|
-
onChange?: (e: React.
|
|
11
|
-
disabled?: boolean;
|
|
10
|
+
props?: CheckboxTagProps;
|
|
11
|
+
onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
13
|
value?: string | number;
|
|
13
14
|
autoFocus?: boolean;
|
|
14
15
|
readOnly?: boolean;
|
|
15
16
|
required?: boolean;
|
|
16
17
|
checked?: boolean;
|
|
17
18
|
defaultChecked?: boolean;
|
|
19
|
+
native?: boolean;
|
|
18
20
|
}
|
|
19
21
|
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
20
22
|
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as s } from "react";
|
|
3
|
+
import t from "../box.mjs";
|
|
4
|
+
import { O as a } from "../utils/utils.mjs";
|
|
5
|
+
import l from "./flex.mjs";
|
|
6
|
+
import { c as d } from "../box.module.css.mjs";
|
|
7
|
+
import "../theme.mjs";
|
|
8
|
+
const p = [
|
|
9
|
+
"name",
|
|
10
|
+
"onInput",
|
|
11
|
+
"onChange",
|
|
12
|
+
"disabled",
|
|
13
|
+
"autoFocus",
|
|
14
|
+
"readOnly",
|
|
15
|
+
"required",
|
|
16
|
+
"value",
|
|
17
|
+
"checked",
|
|
18
|
+
"defaultChecked"
|
|
19
|
+
];
|
|
20
|
+
function m(o, r) {
|
|
21
|
+
const { native: n } = o, i = a.buildProps(o, p, { type: "checkbox" });
|
|
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" }),
|
|
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
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
const w = s(m);
|
|
28
|
+
export {
|
|
29
|
+
w as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface GridCell<T> {
|
|
2
|
+
key: keyof T;
|
|
3
|
+
value: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export interface GridColumn<T extends {}> {
|
|
6
|
+
key: keyof T;
|
|
7
|
+
}
|
|
8
|
+
export interface GridRow<T extends {}> {
|
|
9
|
+
dataRow: T;
|
|
10
|
+
cells: GridCell<T>[];
|
|
11
|
+
}
|
|
12
|
+
export interface Grid<T extends {}> {
|
|
13
|
+
columns: GridColumn<T>[];
|
|
14
|
+
rows: GridRow<T>[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as s, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import t from "../box.mjs";
|
|
3
|
+
import "react";
|
|
4
|
+
import "../box.module.css.mjs";
|
|
5
|
+
import "../utils/utils.mjs";
|
|
6
|
+
import "../theme.mjs";
|
|
7
|
+
function p(i) {
|
|
8
|
+
if (!(i != null && i.length))
|
|
9
|
+
return {
|
|
10
|
+
rows: [],
|
|
11
|
+
columns: []
|
|
12
|
+
};
|
|
13
|
+
const e = Object.keys(i[0]);
|
|
14
|
+
return {
|
|
15
|
+
rows: i.map((r) => ({
|
|
16
|
+
dataRow: r,
|
|
17
|
+
cells: e.map((n) => ({
|
|
18
|
+
key: n,
|
|
19
|
+
value: r[n]
|
|
20
|
+
}))
|
|
21
|
+
})),
|
|
22
|
+
columns: e.map((r) => ({
|
|
23
|
+
key: r
|
|
24
|
+
}))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function h(i) {
|
|
28
|
+
const { data: e } = i, r = p(e);
|
|
29
|
+
return r.columns.length === 0 ? /* @__PURE__ */ s(t, { display: "grid", children: "empty grid" }) : /* @__PURE__ */ l(t, { display: "grid", children: [
|
|
30
|
+
r.columns.map((n, o) => /* @__PURE__ */ s(t, { style: { gridColumn: o + 1 }, children: n.key.toString() }, n.key.toString())),
|
|
31
|
+
r.rows.map((n, o) => n.cells.map((m) => /* @__PURE__ */ s(t, { children: m.value }, m.key.toString() + o)))
|
|
32
|
+
] });
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
h as default
|
|
36
|
+
};
|
package/components/flex.mjs
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Box from '../box';
|
|
2
|
+
type BoxProps = React.ComponentProps<typeof Box<'form'>>;
|
|
3
|
+
type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
+
type FormTagProps = Omit<BoxTagProps, 'onSubmit' | 'ref'>;
|
|
5
|
+
interface Props<T> extends Omit<BoxProps, 'props' | 'tag'> {
|
|
6
|
+
props?: FormTagProps;
|
|
7
|
+
onSubmit: (obj: T, e: React.ChangeEvent<HTMLFormElement>) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function Form<T>(props: Props<T>): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -3,14 +3,15 @@ import { useRef as p, useCallback as u } from "react";
|
|
|
3
3
|
import a from "../box.mjs";
|
|
4
4
|
import { F as c } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import "../theme.mjs";
|
|
7
|
+
function d(o) {
|
|
8
|
+
const { onSubmit: m, props: n } = o, r = p(null), e = u((t) => {
|
|
8
9
|
t.preventDefault();
|
|
9
10
|
const f = c.getFormEntries(r.current);
|
|
10
11
|
m(f, t);
|
|
11
|
-
}, []),
|
|
12
|
-
return /* @__PURE__ */ i(a, { tag: "form", ...o, props:
|
|
12
|
+
}, []), s = { ...n, onSubmit: e, ref: r };
|
|
13
|
+
return /* @__PURE__ */ i(a, { tag: "form", ...o, props: s });
|
|
13
14
|
}
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
d as default
|
|
16
17
|
};
|
|
@@ -2,19 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import Box from '../box';
|
|
3
3
|
type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
|
|
4
4
|
type BoxTagProps = Required<BoxProps>['props'];
|
|
5
|
-
|
|
5
|
+
declare const tagProps: readonly ["name", "onInput", "onChange", "disabled", "value", "autoFocus", "readOnly", "required", "checked", "defaultChecked"];
|
|
6
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
7
|
+
type RadioButtonTagProps = Omit<BoxTagProps, TagPropsType | 'type'>;
|
|
6
8
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
7
9
|
name?: string;
|
|
8
|
-
props?:
|
|
9
|
-
onInput?: (e: React.
|
|
10
|
-
onChange?: (e: React.
|
|
11
|
-
disabled?: boolean;
|
|
10
|
+
props?: RadioButtonTagProps;
|
|
11
|
+
onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
13
|
value?: string | number;
|
|
13
14
|
autoFocus?: boolean;
|
|
14
15
|
readOnly?: boolean;
|
|
15
16
|
required?: boolean;
|
|
16
17
|
checked?: boolean;
|
|
17
18
|
defaultChecked?: boolean;
|
|
19
|
+
native?: boolean;
|
|
18
20
|
}
|
|
19
21
|
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
20
22
|
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
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";
|
|
5
|
+
import "../box.module.css.mjs";
|
|
6
|
+
import "../theme.mjs";
|
|
7
|
+
const p = [
|
|
8
|
+
"name",
|
|
9
|
+
"onInput",
|
|
10
|
+
"onChange",
|
|
11
|
+
"disabled",
|
|
12
|
+
"value",
|
|
13
|
+
"autoFocus",
|
|
14
|
+
"readOnly",
|
|
15
|
+
"required",
|
|
16
|
+
"checked",
|
|
17
|
+
"defaultChecked"
|
|
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" });
|
|
22
|
+
}
|
|
23
|
+
const B = a(u);
|
|
24
|
+
export {
|
|
25
|
+
B as default
|
|
26
|
+
};
|
|
@@ -2,12 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import Box from '../box';
|
|
3
3
|
type BoxProps = Omit<React.ComponentProps<typeof Box<'textarea'>>, 'ref' | 'tag'>;
|
|
4
4
|
type BoxTagProps = Required<BoxProps>['props'];
|
|
5
|
-
|
|
5
|
+
declare const tagProps: readonly ["name", "onInput", "onChange", "placeholder", "disabled", "value", "defaultValue", "rows", "cols", "autoFocus", "maxLength", "minLength", "readOnly", "required"];
|
|
6
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
7
|
+
type TextareaTagProps = Omit<BoxTagProps, TagPropsType>;
|
|
6
8
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
7
9
|
name?: string;
|
|
8
|
-
props?:
|
|
9
|
-
onInput?: (e: React.
|
|
10
|
-
onChange?: (e: React.
|
|
10
|
+
props?: TextareaTagProps;
|
|
11
|
+
onInput?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
12
|
+
onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
11
13
|
placeholder?: string;
|
|
12
14
|
disabled?: boolean;
|
|
13
15
|
value?: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as a } from "react";
|
|
3
|
+
import n from "../box.mjs";
|
|
4
|
+
import { O as i } from "../utils/utils.mjs";
|
|
5
|
+
import "../box.module.css.mjs";
|
|
6
|
+
import "../theme.mjs";
|
|
7
|
+
const m = [
|
|
8
|
+
"name",
|
|
9
|
+
"onInput",
|
|
10
|
+
"onChange",
|
|
11
|
+
"placeholder",
|
|
12
|
+
"disabled",
|
|
13
|
+
"value",
|
|
14
|
+
"defaultValue",
|
|
15
|
+
"rows",
|
|
16
|
+
"cols",
|
|
17
|
+
"autoFocus",
|
|
18
|
+
"maxLength",
|
|
19
|
+
"minLength",
|
|
20
|
+
"readOnly",
|
|
21
|
+
"required"
|
|
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 });
|
|
26
|
+
}
|
|
27
|
+
const x = a(s);
|
|
28
|
+
export {
|
|
29
|
+
x as default
|
|
30
|
+
};
|
package/components/textbox.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Box from '../box';
|
|
3
|
-
import Theme from '../theme';
|
|
4
3
|
type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
|
|
5
4
|
type BoxTagProps = Required<BoxProps>['props'];
|
|
6
5
|
declare const tagProps: readonly ["name", "onInput", "onChange", "type", "placeholder", "disabled", "defaultValue", "autoFocus", "readOnly", "required", "value", "pattern"];
|
|
7
6
|
type TagPropsType = (typeof tagProps)[number];
|
|
8
7
|
type TextboxTagProps = Omit<BoxTagProps, TagPropsType>;
|
|
9
8
|
type TextboxType = 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
|
10
|
-
interface Props extends Omit<BoxProps, 'props'
|
|
9
|
+
interface Props extends Omit<BoxProps, 'props'> {
|
|
11
10
|
name?: string;
|
|
12
11
|
props?: TextboxTagProps;
|
|
13
|
-
onInput?: (e: React.
|
|
14
|
-
onChange?: (e: React.
|
|
12
|
+
onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
13
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
15
14
|
type?: TextboxType;
|
|
16
15
|
placeholder?: string;
|
|
17
16
|
value?: string | number;
|
package/components/textbox.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { O as
|
|
5
|
-
import { useTheme as s } from "../theme.mjs";
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as n } from "react";
|
|
3
|
+
import a from "../box.mjs";
|
|
4
|
+
import { O as p } from "../utils/utils.mjs";
|
|
6
5
|
import "../box.module.css.mjs";
|
|
7
|
-
|
|
6
|
+
import "../theme.mjs";
|
|
7
|
+
const i = [
|
|
8
8
|
"name",
|
|
9
9
|
"onInput",
|
|
10
10
|
"onChange",
|
|
@@ -18,11 +18,11 @@ const u = [
|
|
|
18
18
|
"value",
|
|
19
19
|
"pattern"
|
|
20
20
|
];
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */
|
|
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 });
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const c = n(u);
|
|
26
26
|
export {
|
|
27
|
-
|
|
27
|
+
c as default
|
|
28
28
|
};
|
|
@@ -0,0 +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";
|
|
6
|
+
import "../box.module.css.mjs";
|
|
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();
|
|
12
|
+
};
|
|
13
|
+
return document.addEventListener("scroll", o, { capture: !0 }), () => {
|
|
14
|
+
document.removeEventListener("scroll", o, { capture: !0 });
|
|
15
|
+
};
|
|
16
|
+
}, []), v = i((r, e) => {
|
|
17
|
+
const o = (l) => {
|
|
18
|
+
e();
|
|
19
|
+
};
|
|
20
|
+
return window.addEventListener("resize", o, { capture: !0 }), () => {
|
|
21
|
+
window.removeEventListener("resize", o, { capture: !0 });
|
|
22
|
+
};
|
|
23
|
+
}, []), s = i((r) => () => {
|
|
24
|
+
const e = r.getBoundingClientRect();
|
|
25
|
+
d({ top: e.top + window.scrollY, left: e.left + window.scrollX });
|
|
26
|
+
}, []);
|
|
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));
|
|
31
|
+
return () => {
|
|
32
|
+
r(), e();
|
|
33
|
+
};
|
|
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,
|
|
40
|
+
{
|
|
41
|
+
position: "absolute",
|
|
42
|
+
top: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
transition: "none",
|
|
45
|
+
style: { transform: `translate(${n.left}px,${n.top}px)` },
|
|
46
|
+
children: p
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
f
|
|
50
|
+
)
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
B as default
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function usePortalContainer(): HTMLElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronocode/react-box",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"main": "./box.mjs",
|
|
5
5
|
"module": "./box.mjs",
|
|
6
6
|
"types": "./box.d.ts",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"dev": "vite ./
|
|
26
|
+
"dev": "vite ./pages --config ./pages.vite.config.ts --mode dev",
|
|
27
|
+
"build:pages": "vite build ./pages --config ./pages.vite.config.ts --outDir ../dist --mode production",
|
|
28
|
+
"preview": "vite preview",
|
|
27
29
|
"build": "vite build",
|
|
28
30
|
"build:dev": "vite build --mode dev",
|
|
29
31
|
"postbuild": "cp package.json dist & cp LICENSE dist & rm ./dist/index.d.ts & rm ./dist/index.js",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
"prettier": "^2.8.7",
|
|
63
65
|
"react": "^18.1.0",
|
|
64
66
|
"react-dom": "^18.2.0",
|
|
67
|
+
"react-router-dom": "^6.16.0",
|
|
65
68
|
"typescript": "^5.0.2",
|
|
66
69
|
"vite": "^4.2.1",
|
|
67
70
|
"vite-plugin-dts": "^2.1.0"
|