@cronocode/react-box 1.4.5 → 1.4.7
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.cjs +1 -1
- package/baseSvg.module.css.mjs +1 -1
- package/box.module.css.cjs +1 -1
- package/box.module.css.mjs +1 -1
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.d.ts +2 -4
- package/components/tooltip.mjs +37 -45
- package/package.json +1 -1
- package/plugins.cjs +11 -14
- package/plugins.mjs +14 -15
- package/style.css +1 -1
- package/types.d.ts +1 -1
package/components/tooltip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),v=require("react-dom"),d=require("../box.cjs"),s=require("react"),h=require("../utils/utils.cjs");require("../box.module.css.cjs");require("../theme.cjs");const u=2;function x(f){const{onPositionChange:l}=f,i=s.useRef(null),[e,p]=s.useState(),w=h.usePortalContainer(),b=s.useCallback((n,t)=>{const r=o=>{o.target.contains(n)&&t(n)};return document.addEventListener("scroll",r,{capture:!0}),()=>{document.removeEventListener("scroll",r,{capture:!0})}},[]),m=s.useCallback((n,t)=>{const r=o=>{t(n)};return window.addEventListener("resize",r,{capture:!0}),()=>{window.removeEventListener("resize",r,{capture:!0})}},[]),a=s.useCallback(n=>{const t=n.getBoundingClientRect(),r=Math.round((t.top+window.scrollY)*u)/u,o=Math.round((t.left+window.scrollX)*u)/u;((e==null?void 0:e.top)!==r||(e==null?void 0:e.left)!==o)&&(l==null||l({top:r,left:o}),p({top:r,left:o,width:t.width>0?t.width:void 0}))},[]);return s.useLayoutEffect(()=>{if(i.current){a(i.current);const n=b(i.current,a),t=m(i.current,a);return()=>{n(),t()}}},[]),c.jsxs(c.Fragment,{children:[c.jsx(d.default,{ref:i}),e&&v.createPortal(c.jsx(d.default,{position:"absolute",top:0,left:0,style:{transform:`translate(${e.left}px,${e.top}px)`,width:e.width},children:c.jsx(d.default,{position:"absolute",width:"fit",...f})}),w)]})}exports.default=x;
|
package/components/tooltip.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import Box from '../box';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
interface Props extends BoxPosition {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
style?: React.ComponentProps<'div'>['style'];
|
|
3
|
+
interface Props extends React.ComponentProps<typeof Box> {
|
|
6
4
|
onPositionChange?(position: {
|
|
7
5
|
top: number;
|
|
8
6
|
left: number;
|
package/components/tooltip.mjs
CHANGED
|
@@ -1,57 +1,49 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createPortal as
|
|
3
|
-
import
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { u as
|
|
1
|
+
import { jsxs as v, 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 d, useLayoutEffect as g } from "react";
|
|
5
|
+
import { u as z } from "../utils/utils.mjs";
|
|
6
6
|
import "../box.module.css.mjs";
|
|
7
7
|
import "../theme.mjs";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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]);
|
|
8
|
+
const i = 2;
|
|
9
|
+
function M(f) {
|
|
10
|
+
const { onPositionChange: c } = f, s = E(null), [t, p] = L(), m = z(), w = d((o, e) => {
|
|
11
|
+
const r = (n) => {
|
|
12
|
+
n.target.contains(o) && e(o);
|
|
13
|
+
};
|
|
14
|
+
return document.addEventListener("scroll", r, { capture: !0 }), () => {
|
|
15
|
+
document.removeEventListener("scroll", r, { capture: !0 });
|
|
16
|
+
};
|
|
17
|
+
}, []), h = d((o, e) => {
|
|
18
|
+
const r = (n) => {
|
|
19
|
+
e(o);
|
|
20
|
+
};
|
|
21
|
+
return window.addEventListener("resize", r, { capture: !0 }), () => {
|
|
22
|
+
window.removeEventListener("resize", r, { capture: !0 });
|
|
23
|
+
};
|
|
24
|
+
}, []), l = d((o) => {
|
|
25
|
+
const e = o.getBoundingClientRect(), r = Math.round((e.top + window.scrollY) * i) / i, n = Math.round((e.left + window.scrollX) * i) / i;
|
|
26
|
+
((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== n) && (c == null || c({ top: r, left: n }), p({ top: r, left: n, width: e.width > 0 ? e.width : void 0 }));
|
|
27
|
+
}, []);
|
|
35
28
|
return g(() => {
|
|
36
|
-
if (
|
|
37
|
-
l();
|
|
38
|
-
const
|
|
29
|
+
if (s.current) {
|
|
30
|
+
l(s.current);
|
|
31
|
+
const o = w(s.current, l), e = h(s.current, l);
|
|
39
32
|
return () => {
|
|
40
|
-
|
|
33
|
+
o(), e();
|
|
41
34
|
};
|
|
42
35
|
}
|
|
43
|
-
}, [
|
|
44
|
-
/* @__PURE__ */ a
|
|
45
|
-
t &&
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
|
|
36
|
+
}, []), /* @__PURE__ */ v(x, { children: [
|
|
37
|
+
/* @__PURE__ */ u(a, { ref: s }),
|
|
38
|
+
t && b(
|
|
39
|
+
/* @__PURE__ */ u(
|
|
40
|
+
a,
|
|
48
41
|
{
|
|
49
42
|
position: "absolute",
|
|
50
43
|
top: 0,
|
|
51
44
|
left: 0,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
children: p
|
|
45
|
+
style: { transform: `translate(${t.left}px,${t.top}px)`, width: t.width },
|
|
46
|
+
children: /* @__PURE__ */ u(a, { position: "absolute", width: "fit", ...f })
|
|
55
47
|
}
|
|
56
48
|
),
|
|
57
49
|
m
|
|
@@ -59,5 +51,5 @@ function P(i) {
|
|
|
59
51
|
] });
|
|
60
52
|
}
|
|
61
53
|
export {
|
|
62
|
-
|
|
54
|
+
M as default
|
|
63
55
|
};
|
package/package.json
CHANGED
package/plugins.cjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
2
|
-
`),
|
|
3
|
-
`),
|
|
4
|
-
`),
|
|
5
|
-
${l}
|
|
6
|
-
${_}
|
|
7
|
-
${t}
|
|
8
|
-
}`,n=Object.keys(r.colors).map(o=>`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(r){const _=Object.entries(r.colors).map(([o,l])=>`--color${o}: ${l};`).join(`
|
|
2
|
+
`),t=Object.entries(r.shadows).map(([o,l])=>`--shadow${o}: ${l};`).join(`
|
|
3
|
+
`),c=Object.entries(r.backgrounds).map(([o,l])=>`--background${o}: ${l};`).join(`
|
|
4
|
+
`),e=[":root {"];_&&e.push(` ${_}`),t&&e.push(` ${t}`),c&&e.push(` ${c}`),e.push("}");const n=Object.keys(r.colors).map(o=>`
|
|
9
5
|
.color_${o},
|
|
10
6
|
.color_h_${o}:hover,
|
|
11
7
|
._h:hover>.color_h_${o} {
|
|
@@ -138,7 +134,7 @@
|
|
|
138
134
|
|
|
139
135
|
.shadow_a_${o}:active {
|
|
140
136
|
box-shadow: var(--shadow${o});
|
|
141
|
-
}`)
|
|
137
|
+
}`),h=Object.keys(r.backgrounds).map(o=>`
|
|
142
138
|
.bg_${o},
|
|
143
139
|
.bg_h_${o}:hover,
|
|
144
140
|
._h:hover>.bg_h_${o} {
|
|
@@ -152,11 +148,11 @@
|
|
|
152
148
|
|
|
153
149
|
.bg_a_${o}:active {
|
|
154
150
|
background: var(--background${o});
|
|
155
|
-
}`),
|
|
151
|
+
}`),s=Object.keys(r.colors).map(o=>`'${o}'`).join(" | "),$=Object.keys(r.backgrounds).map(o=>`'${o}'`).join(" | "),b=Object.keys(r.shadows).map(o=>`'${o}'`).join(" | "),p=`import {ColorType} from '@cronocode/react-box';
|
|
156
152
|
|
|
157
153
|
declare module '@cronocode/react-box' {
|
|
158
|
-
type ColorType = ${
|
|
159
|
-
type BackgroundType = ${
|
|
154
|
+
type ColorType = ${s};
|
|
155
|
+
type BackgroundType = ${$};
|
|
160
156
|
type ShadowType = ${b};
|
|
161
157
|
|
|
162
158
|
namespace Augmented {
|
|
@@ -211,5 +207,6 @@ declare module '@cronocode/react-box/components/baseSvg' {
|
|
|
211
207
|
}
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
|
-
`;return{themeCss:[
|
|
215
|
-
`)
|
|
210
|
+
`;return{themeCss:[e.join(`
|
|
211
|
+
`),...n,...i,...h].join(`
|
|
212
|
+
`),boxDts:p}}exports.boxTheme=u;
|
package/plugins.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
`),
|
|
4
|
-
`),
|
|
5
|
-
`),
|
|
6
|
-
${
|
|
7
|
-
|
|
8
|
-
${t}
|
|
9
|
-
}`, n = Object.keys(r.colors).map((o) => `
|
|
1
|
+
function d(r) {
|
|
2
|
+
const _ = Object.entries(r.colors).map(([o, l]) => `--color${o}: ${l};`).join(`
|
|
3
|
+
`), t = Object.entries(r.shadows).map(([o, l]) => `--shadow${o}: ${l};`).join(`
|
|
4
|
+
`), c = Object.entries(r.backgrounds).map(([o, l]) => `--background${o}: ${l};`).join(`
|
|
5
|
+
`), e = [":root {"];
|
|
6
|
+
_ && e.push(` ${_}`), t && e.push(` ${t}`), c && e.push(` ${c}`), e.push("}");
|
|
7
|
+
const n = Object.keys(r.colors).map((o) => `
|
|
10
8
|
.color_${o},
|
|
11
9
|
.color_h_${o}:hover,
|
|
12
10
|
._h:hover>.color_h_${o} {
|
|
@@ -139,7 +137,7 @@ function p(r) {
|
|
|
139
137
|
|
|
140
138
|
.shadow_a_${o}:active {
|
|
141
139
|
box-shadow: var(--shadow${o});
|
|
142
|
-
}`),
|
|
140
|
+
}`), h = Object.keys(r.backgrounds).map((o) => `
|
|
143
141
|
.bg_${o},
|
|
144
142
|
.bg_h_${o}:hover,
|
|
145
143
|
._h:hover>.bg_h_${o} {
|
|
@@ -153,10 +151,10 @@ function p(r) {
|
|
|
153
151
|
|
|
154
152
|
.bg_a_${o}:active {
|
|
155
153
|
background: var(--background${o});
|
|
156
|
-
}`),
|
|
154
|
+
}`), $ = Object.keys(r.colors).map((o) => `'${o}'`).join(" | "), s = Object.keys(r.backgrounds).map((o) => `'${o}'`).join(" | "), b = Object.keys(r.shadows).map((o) => `'${o}'`).join(" | "), p = `import {ColorType} from '@cronocode/react-box';
|
|
157
155
|
|
|
158
156
|
declare module '@cronocode/react-box' {
|
|
159
|
-
type ColorType = ${
|
|
157
|
+
type ColorType = ${$};
|
|
160
158
|
type BackgroundType = ${s};
|
|
161
159
|
type ShadowType = ${b};
|
|
162
160
|
|
|
@@ -214,11 +212,12 @@ declare module '@cronocode/react-box/components/baseSvg' {
|
|
|
214
212
|
}
|
|
215
213
|
`;
|
|
216
214
|
return {
|
|
217
|
-
themeCss: [
|
|
215
|
+
themeCss: [e.join(`
|
|
216
|
+
`), ...n, ...i, ...h].join(`
|
|
218
217
|
`),
|
|
219
|
-
boxDts:
|
|
218
|
+
boxDts: p
|
|
220
219
|
};
|
|
221
220
|
}
|
|
222
221
|
export {
|
|
223
|
-
|
|
222
|
+
d as boxTheme
|
|
224
223
|
};
|