@cronocode/react-box 3.0.5 → 3.0.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/array.d.ts +6 -0
- package/box.cjs +1 -1
- package/box.mjs +13 -13
- package/components/dataGrid.cjs +1 -1
- package/components/dataGrid.mjs +11 -11
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.d.ts +16 -12
- package/components/dropdown.mjs +123 -62
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.d.ts +2 -2
- package/components/tooltip.mjs +16 -14
- package/core/boxStyles.d.ts +12 -2
- package/core/variables.d.ts +1 -2
- package/core.cjs +3 -3
- package/core.mjs +240 -176
- package/package.json +1 -1
package/array.d.ts
ADDED
package/box.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const o=require("react"),e=require("./core.cjs");function h(a,l){const{tag:c="div",children:n,props:m,className:p,style:i,disabled:x,required:B,checked:g,selected:f}=a,v=e.useStyles(a,c==="svg"),r=o.useMemo(()=>{const b=e.classNames(v,p).join(" "),s={...m,className:b};return e.BoxUtils.assignBooleanProp(x,"disabled",s),e.BoxUtils.assignBooleanProp(B,"required",s),e.BoxUtils.assignBooleanProp(g,"checked",s),e.BoxUtils.assignBooleanProp(f,"selected",s),i&&(s.style=i),l&&(s.ref=l),s},[a]),[P,u]=o.useState(!1),d=typeof n=="function";return d&&(r.onMouseEnter=()=>u(!0),r.onMouseLeave=()=>u(!1)),o.createElement(c,r,d?n({isHover:P}):n)}const t=o.memo(o.forwardRef(h));t.extend=e.BoxExtends.extend;t.themeSetup=e.Theme.setup;t.getVariableValue=e.Variables.getVariableValue;module.exports=t;
|
package/box.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import V, { memo as b, forwardRef as h, useMemo as y, useState as
|
|
2
|
-
import { B as
|
|
3
|
-
function
|
|
4
|
-
const { tag: l = "div", children:
|
|
5
|
-
const
|
|
1
|
+
import V, { memo as b, forwardRef as h, useMemo as y, useState as N } from "react";
|
|
2
|
+
import { B as S, T as C, V as E, u as H, c as M, a as s } from "./core.mjs";
|
|
3
|
+
function T(a, r) {
|
|
4
|
+
const { tag: l = "div", children: o, props: d, className: m, style: c, disabled: p, required: f, checked: g, selected: B } = a, x = H(a, l === "svg"), t = y(() => {
|
|
5
|
+
const P = M(x, m).join(" "), e = {
|
|
6
6
|
...d,
|
|
7
|
-
className:
|
|
7
|
+
className: P
|
|
8
8
|
};
|
|
9
|
-
return
|
|
10
|
-
}, [
|
|
11
|
-
return u && (
|
|
9
|
+
return s.assignBooleanProp(p, "disabled", e), s.assignBooleanProp(f, "required", e), s.assignBooleanProp(g, "checked", e), s.assignBooleanProp(B, "selected", e), c && (e.style = c), r && (e.ref = r), e;
|
|
10
|
+
}, [a]), [v, i] = N(!1), u = typeof o == "function";
|
|
11
|
+
return u && (t.onMouseEnter = () => i(!0), t.onMouseLeave = () => i(!1)), V.createElement(l, t, u ? o({ isHover: v }) : o);
|
|
12
12
|
}
|
|
13
|
-
const n = b(h(
|
|
14
|
-
n.extend =
|
|
15
|
-
n.themeSetup =
|
|
16
|
-
n.getVariableValue =
|
|
13
|
+
const n = b(h(T));
|
|
14
|
+
n.extend = S.extend;
|
|
15
|
+
n.themeSetup = C.setup;
|
|
16
|
+
n.getVariableValue = E.getVariableValue;
|
|
17
17
|
export {
|
|
18
18
|
n as default
|
|
19
19
|
};
|
package/components/dataGrid.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime");require("react");const
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime");require("react");const o=require("../box.cjs"),c=require("./grid.cjs");function g(u){const{data:e,def:d}=u,{rowKey:r,columns:i}=d;return i.length===0?(console.error("Cannot render grid without column definitions"),null):n.jsx(o,{component:"dataGrid",children:n.jsxs(c,{b:1,borderRadius:1,children:[i.map((t,s)=>n.jsx(o,{style:{gridColumn:s+1},children:t.key.toString()},s)),((e==null?void 0:e.length)??0)===0&&n.jsx(o,{children:"Empty table"}),((e==null?void 0:e.length)??0)>0&&n.jsx(n.Fragment,{children:e==null?void 0:e.map((t,s)=>{const m=r?typeof r=="function"?r(t):t[r]:s;return n.jsx(c,{style:{gridTemplateRows:"subgrid"},children:i.map((h,l)=>n.jsxs(o,{style:{gridColumn:l+1},children:["tes ",l]},l))},m)})})]})})}module.exports=g;
|
package/components/dataGrid.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
1
|
+
import { jsx as n, jsxs as c, Fragment as h } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import
|
|
3
|
+
import i from "../box.mjs";
|
|
4
4
|
import s from "./grid.mjs";
|
|
5
|
-
function x(
|
|
6
|
-
const { data: r, def: u } =
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
((r == null ? void 0 : r.length) ?? 0) === 0 && /* @__PURE__ */ n(
|
|
10
|
-
((r == null ? void 0 : r.length) ?? 0) > 0 && /* @__PURE__ */ n(
|
|
11
|
-
const p =
|
|
12
|
-
return /* @__PURE__ */ n(s, { style: { gridTemplateRows: "subgrid" }, children:
|
|
5
|
+
function x(d) {
|
|
6
|
+
const { data: r, def: u } = d, { rowKey: e, columns: l } = u;
|
|
7
|
+
return l.length === 0 ? (console.error("Cannot render grid without column definitions"), null) : /* @__PURE__ */ n(i, { component: "dataGrid", children: /* @__PURE__ */ c(s, { b: 1, borderRadius: 1, children: [
|
|
8
|
+
l.map((o, t) => /* @__PURE__ */ n(i, { style: { gridColumn: t + 1 }, children: o.key.toString() }, t)),
|
|
9
|
+
((r == null ? void 0 : r.length) ?? 0) === 0 && /* @__PURE__ */ n(i, { children: "Empty table" }),
|
|
10
|
+
((r == null ? void 0 : r.length) ?? 0) > 0 && /* @__PURE__ */ n(h, { children: r == null ? void 0 : r.map((o, t) => {
|
|
11
|
+
const p = e ? typeof e == "function" ? e(o) : o[e] : t;
|
|
12
|
+
return /* @__PURE__ */ n(s, { style: { gridTemplateRows: "subgrid" }, children: l.map((f, m) => /* @__PURE__ */ c(i, { style: { gridColumn: m + 1 }, children: [
|
|
13
13
|
"tes ",
|
|
14
14
|
m
|
|
15
|
-
] })) }, p);
|
|
15
|
+
] }, m)) }, p);
|
|
16
16
|
}) })
|
|
17
17
|
] }) });
|
|
18
18
|
}
|
package/components/dropdown.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),n=require("react"),w=require("../box.cjs"),U=require("./textbox.cjs"),C=require("./flex.cjs"),J=require("../core.cjs"),Y=require("./baseSvg.cjs"),k=require("./tooltip.cjs"),W=require("./button.cjs");function $(p,a){const{name:s,defaultValue:y,multiple:l,isSearchable:d,searchPlaceholder:V,children:v,onChange:i,...E}=p,[c,g]=n.useState(Array.isArray(y)?y:y?[y]:[]),[j,P]=n.useState(""),[m,R,D]=J.useVisibility(),M=n.useRef(null),A=n.useRef(null),[_,H]=n.useState(0),I=n.useMemo(()=>_>window.innerHeight/2,[_]),L=n.useMemo(()=>{var e;return I?((e=D.current)==null?void 0:e.getBoundingClientRect().height)??0:0},[I,D]),u=n.useMemo(()=>Array.isArray(v)?v:[v],[v]),f=n.useMemo(()=>u.filter(e=>{var t;return((t=e.type)==null?void 0:t.componentName)!=="DropdownItem"?!1:d&&j?N(e).toLowerCase().includes(j.toLowerCase()):!0}),[d,j,u]),h=n.useMemo(()=>u.find(e=>{var t;return((t=e.type)==null?void 0:t.componentName)==="DropdownUnselectItem"}),[u]),S=n.useMemo(()=>u.find(e=>{var t;return((t=e.type)==null?void 0:t.componentName)==="DropdownEmptyItem"}),[u]),O=n.useMemo(()=>u.find(e=>{var t;return((t=e.type)==null?void 0:t.componentName)==="DropdownDisplay"}),[u]),B=n.useMemo(()=>{if(O)return O.props.children(c);const e=f.filter(o=>c.includes(o.props.value));if(l&&e.length>1)return e.map(o=>N(o)).join(", ");const t=e.at(0);return(t==null?void 0:t.props.children)??(t==null?void 0:t.props.value)??(h==null?void 0:h.props.children)},[l,f,h,c]),T=n.useCallback((e,t)=>{if(!t)g([]),i==null||i(void 0,[]);else if(l){const o=c.filter(q=>q!==t.props.value);o.length===c.length&&o.push(t.props.value),g(o),i==null||i(t.props.value,o)}else g([t.props.value]),i==null||i(t.props.value,[t.props.value]);l?(e.stopPropagation(),setTimeout(()=>{var o;return(o=M.current)==null?void 0:o.focus()},0)):(R(!1),setTimeout(()=>{var o;return(o=D.current)==null?void 0:o.focus()},0))},[l,c,g]);return n.useEffect(()=>{m?setTimeout(()=>{var e,t,o;(e=M.current)==null||e.focus(),(o=(t=A.current)==null?void 0:t.querySelector('[aria-selected="true"]'))==null||o.scrollIntoView({block:"nearest"})},0):P("")},[m]),r.jsxs(w,{width:"fit-content",children:[c.map(e=>r.jsx(U,{ref:a,name:s,type:"hidden",value:JSON.stringify(e)??""},JSON.stringify(e))),r.jsxs(W,{ref:D,component:"dropdown",...E,props:{onMouseDown:()=>R(e=>!e),tabIndex:0},children:[d&&r.jsx(U,{display:m&&d?"block":"none",clean:!0,flex1:!0,width:1,minHeight:5,placeholder:V,value:j,onChange:e=>P(e.target.value),ref:M,props:{onMouseDown:e=>{m&&d&&e.stopPropagation()}}}),r.jsx(C,{display:m&&d?"none":"flex",flex1:!0,minHeight:5,children:B}),r.jsx(w,{children:r.jsx(Y,{viewBox:"0 0 10 6",width:"0.6rem",rotate:m?180:0,children:r.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 4 4 4-4"})})})]}),m&&r.jsx(k,{ref:A,top:I?void 0:0,bottom:I?2:void 0,style:{transform:`translateY(-${L}px)`},onPositionChange:e=>H(e.top),children:(f.length>0||S)&&r.jsxs(w,{component:"dropdown.items",children:[h&&f.length>0&&r.jsx(w,{component:"dropdown.unselectItem",selected:c.length===0,...h.props,props:{onMouseDown:e=>T(e)}}),f.map(e=>{const{value:t,...o}=e.props;return r.jsx(w,{component:"dropdown.item",theme:l?"multiple":"single",selected:c.includes(t),...o,props:{onMouseDown:q=>T(q,e)}},t)}),f.length===0&&S&&r.jsx(w,{component:"dropdown.emptyItem",...S.props})]})})]})}function b(p){const a=s=>null;return a.componentName=p,a}const x=n.forwardRef($);x.Item=b("DropdownItem");x.UnselectItem=b("DropdownUnselectItem");x.EmptyItem=b("DropdownEmptyItem");x.Display=b("DropdownDisplay");function N(p){var a;if(p==null)return"";if(typeof p=="object"){const s=(a=p.props)==null?void 0:a.children;return s==null?"":typeof s=="object"?(Array.isArray(s)?s:[s]).map(l=>N(l)).join(""):s.toString()}return p.toString()}module.exports=x;
|
package/components/dropdown.d.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { BoxProps } from '../box';
|
|
3
|
-
interface DropdownItemProps<TVal> extends BoxProps {
|
|
4
|
-
value: TVal;
|
|
5
|
-
onClick?: () => void;
|
|
6
|
-
}
|
|
7
3
|
interface Props<TVal> extends BoxProps {
|
|
8
4
|
name?: string;
|
|
9
|
-
|
|
5
|
+
defaultValue?: TVal | TVal[];
|
|
6
|
+
multiple?: boolean;
|
|
10
7
|
isSearchable?: boolean;
|
|
11
8
|
searchPlaceholder?: string;
|
|
12
|
-
onChange?: (value: TVal) => void;
|
|
13
|
-
|
|
9
|
+
onChange?: (value: Maybe<TVal>, values: TVal[]) => void;
|
|
10
|
+
}
|
|
11
|
+
interface DropdownItemProps<TVal> extends BoxProps {
|
|
12
|
+
value: TVal;
|
|
13
|
+
}
|
|
14
|
+
interface DropdownDisplayProps<TVal> extends Omit<BoxProps, 'children'> {
|
|
15
|
+
children: (selectedValues: TVal[]) => React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
interface DropdownType {
|
|
18
|
+
<TVal>(props: Props<TVal>, ref: Ref<HTMLInputElement>): React.ReactNode;
|
|
19
|
+
Item: <TVal>(props: DropdownItemProps<TVal>) => React.ReactNode;
|
|
20
|
+
UnselectItem: (props: BoxProps) => React.ReactNode;
|
|
21
|
+
EmptyItem: (props: BoxProps) => React.ReactNode;
|
|
22
|
+
Display: <TVal>(props: DropdownDisplayProps<TVal>) => React.ReactNode;
|
|
14
23
|
}
|
|
15
|
-
declare function DropdownImpl<TVal>(props: Props<TVal>, ref: Ref<HTMLDivElement>): React.ReactNode;
|
|
16
|
-
declare function DropdownItem<TVal>(props: DropdownItemProps<TVal>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
type DropdownType = typeof DropdownImpl & {
|
|
18
|
-
Item: typeof DropdownItem;
|
|
19
|
-
};
|
|
20
24
|
declare const Dropdown: DropdownType;
|
|
21
25
|
export default Dropdown;
|
package/components/dropdown.mjs
CHANGED
|
@@ -1,79 +1,140 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { b as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
), [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { jsxs as T, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as F, useState as A, useRef as H, useMemo as a, useCallback as W, useEffect as _ } from "react";
|
|
3
|
+
import w from "../box.mjs";
|
|
4
|
+
import L from "./textbox.mjs";
|
|
5
|
+
import $ from "./flex.mjs";
|
|
6
|
+
import { b as z } from "../core.mjs";
|
|
7
|
+
import G from "./baseSvg.mjs";
|
|
8
|
+
import Q from "./tooltip.mjs";
|
|
9
|
+
import X from "./button.mjs";
|
|
10
|
+
function Z(s, u) {
|
|
11
|
+
const { name: r, defaultValue: y, multiple: l, isSearchable: d, searchPlaceholder: C, children: v, onChange: p, ...J } = s, [i, g] = A(Array.isArray(y) ? y : y ? [y] : []), [D, M] = A(""), [m, O, I] = z(), N = H(null), R = H(null), [U, Y] = A(0), x = a(() => U > window.innerHeight / 2, [U]), k = a(() => {
|
|
12
|
+
var e;
|
|
13
|
+
return x ? ((e = I.current) == null ? void 0 : e.getBoundingClientRect().height) ?? 0 : 0;
|
|
14
|
+
}, [x, I]), c = a(() => Array.isArray(v) ? v : [v], [v]), f = a(() => c.filter((e) => {
|
|
15
|
+
var o;
|
|
16
|
+
return ((o = e.type) == null ? void 0 : o.componentName) !== "DropdownItem" ? !1 : d && D ? B(e).toLowerCase().includes(D.toLowerCase()) : !0;
|
|
17
|
+
}), [d, D, c]), h = a(() => c.find((e) => {
|
|
18
|
+
var o;
|
|
19
|
+
return ((o = e.type) == null ? void 0 : o.componentName) === "DropdownUnselectItem";
|
|
20
|
+
}), [c]), P = a(() => c.find((e) => {
|
|
21
|
+
var o;
|
|
22
|
+
return ((o = e.type) == null ? void 0 : o.componentName) === "DropdownEmptyItem";
|
|
23
|
+
}), [c]), V = a(() => c.find((e) => {
|
|
24
|
+
var o;
|
|
25
|
+
return ((o = e.type) == null ? void 0 : o.componentName) === "DropdownDisplay";
|
|
26
|
+
}), [c]), q = a(() => {
|
|
27
|
+
if (V) return V.props.children(i);
|
|
28
|
+
const e = f.filter((t) => i.includes(t.props.value));
|
|
29
|
+
if (l && e.length > 1)
|
|
30
|
+
return e.map((t) => B(t)).join(", ");
|
|
31
|
+
const o = e.at(0);
|
|
32
|
+
return (o == null ? void 0 : o.props.children) ?? (o == null ? void 0 : o.props.value) ?? (h == null ? void 0 : h.props.children);
|
|
33
|
+
}, [l, f, h, i]), E = W(
|
|
34
|
+
(e, o) => {
|
|
35
|
+
if (!o)
|
|
36
|
+
g([]), p == null || p(void 0, []);
|
|
37
|
+
else if (l) {
|
|
38
|
+
const t = i.filter((j) => j !== o.props.value);
|
|
39
|
+
t.length === i.length && t.push(o.props.value), g(t), p == null || p(o.props.value, t);
|
|
40
|
+
} else
|
|
41
|
+
g([o.props.value]), p == null || p(o.props.value, [o.props.value]);
|
|
42
|
+
l ? (e.stopPropagation(), setTimeout(() => {
|
|
43
|
+
var t;
|
|
44
|
+
return (t = N.current) == null ? void 0 : t.focus();
|
|
45
|
+
}, 0)) : (O(!1), setTimeout(() => {
|
|
46
|
+
var t;
|
|
47
|
+
return (t = I.current) == null ? void 0 : t.focus();
|
|
48
|
+
}, 0));
|
|
49
|
+
},
|
|
50
|
+
[l, i, g]
|
|
51
|
+
);
|
|
52
|
+
return _(() => {
|
|
53
|
+
m ? setTimeout(() => {
|
|
54
|
+
var e, o, t;
|
|
55
|
+
(e = N.current) == null || e.focus(), (t = (o = R.current) == null ? void 0 : o.querySelector('[aria-selected="true"]')) == null || t.scrollIntoView({ block: "nearest" });
|
|
56
|
+
}, 0) : M("");
|
|
57
|
+
}, [m]), /* @__PURE__ */ T(w, { width: "fit-content", children: [
|
|
58
|
+
i.map((e) => /* @__PURE__ */ n(L, { ref: u, name: r, type: "hidden", value: JSON.stringify(e) ?? "" }, JSON.stringify(e))),
|
|
59
|
+
/* @__PURE__ */ T(X, { ref: I, component: "dropdown", ...J, props: { onMouseDown: () => O((e) => !e), tabIndex: 0 }, children: [
|
|
60
|
+
d && /* @__PURE__ */ n(
|
|
61
|
+
L,
|
|
36
62
|
{
|
|
63
|
+
display: m && d ? "block" : "none",
|
|
37
64
|
clean: !0,
|
|
38
65
|
flex1: !0,
|
|
39
66
|
width: 1,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
minHeight: 5,
|
|
68
|
+
placeholder: C,
|
|
69
|
+
value: D,
|
|
70
|
+
onChange: (e) => M(e.target.value),
|
|
71
|
+
ref: N,
|
|
44
72
|
props: {
|
|
45
|
-
onMouseDown: (
|
|
46
|
-
|
|
73
|
+
onMouseDown: (e) => {
|
|
74
|
+
m && d && e.stopPropagation();
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
}
|
|
50
|
-
)
|
|
51
|
-
/* @__PURE__ */ n(
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ n($, { display: m && d ? "none" : "flex", flex1: !0, minHeight: 5, children: q }),
|
|
80
|
+
/* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(G, { viewBox: "0 0 10 6", width: "0.6rem", rotate: m ? 180 : 0, children: /* @__PURE__ */ n("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m1 1 4 4 4-4" }) }) })
|
|
52
81
|
] }),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
m && /* @__PURE__ */ n(
|
|
83
|
+
Q,
|
|
84
|
+
{
|
|
85
|
+
ref: R,
|
|
86
|
+
top: x ? void 0 : 0,
|
|
87
|
+
bottom: x ? 2 : void 0,
|
|
88
|
+
style: { transform: `translateY(-${k}px)` },
|
|
89
|
+
onPositionChange: (e) => Y(e.top),
|
|
90
|
+
children: (f.length > 0 || P) && /* @__PURE__ */ T(w, { component: "dropdown.items", children: [
|
|
91
|
+
h && f.length > 0 && /* @__PURE__ */ n(
|
|
92
|
+
w,
|
|
93
|
+
{
|
|
94
|
+
component: "dropdown.unselectItem",
|
|
95
|
+
selected: i.length === 0,
|
|
96
|
+
...h.props,
|
|
97
|
+
props: { onMouseDown: (e) => E(e) }
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
f.map((e) => {
|
|
101
|
+
const { value: o, ...t } = e.props;
|
|
102
|
+
return /* @__PURE__ */ n(
|
|
103
|
+
w,
|
|
104
|
+
{
|
|
105
|
+
component: "dropdown.item",
|
|
106
|
+
theme: l ? "multiple" : "single",
|
|
107
|
+
selected: i.includes(o),
|
|
108
|
+
...t,
|
|
109
|
+
props: { onMouseDown: (j) => E(j, e) }
|
|
110
|
+
},
|
|
111
|
+
o
|
|
112
|
+
);
|
|
113
|
+
}),
|
|
114
|
+
f.length === 0 && P && /* @__PURE__ */ n(w, { component: "dropdown.emptyItem", ...P.props })
|
|
115
|
+
] })
|
|
116
|
+
}
|
|
117
|
+
)
|
|
60
118
|
] });
|
|
61
119
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
120
|
+
function b(s) {
|
|
121
|
+
const u = (r) => null;
|
|
122
|
+
return u.componentName = s, u;
|
|
64
123
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
124
|
+
const S = F(Z);
|
|
125
|
+
S.Item = b("DropdownItem");
|
|
126
|
+
S.UnselectItem = b("DropdownUnselectItem");
|
|
127
|
+
S.EmptyItem = b("DropdownEmptyItem");
|
|
128
|
+
S.Display = b("DropdownDisplay");
|
|
129
|
+
function B(s) {
|
|
69
130
|
var u;
|
|
70
|
-
if (
|
|
71
|
-
if (typeof
|
|
72
|
-
const r = (u =
|
|
73
|
-
return r == null ? "" : typeof r == "object" ? (Array.isArray(r) ? r : [r]).map((
|
|
131
|
+
if (s == null) return "";
|
|
132
|
+
if (typeof s == "object") {
|
|
133
|
+
const r = (u = s.props) == null ? void 0 : u.children;
|
|
134
|
+
return r == null ? "" : typeof r == "object" ? (Array.isArray(r) ? r : [r]).map((l) => B(l)).join("") : r.toString();
|
|
74
135
|
}
|
|
75
|
-
return
|
|
136
|
+
return s.toString();
|
|
76
137
|
}
|
|
77
138
|
export {
|
|
78
|
-
|
|
139
|
+
S as default
|
|
79
140
|
};
|
package/components/tooltip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),x=require("react-dom"),d=require("../box.cjs"),n=require("react"),b=require("../core.cjs"),l=2;function R(f,p){const{onPositionChange:u}=f,c=n.useRef(null),[t,w]=n.useState(),h=b.usePortalContainer(),m=n.useCallback((o,e)=>{const r=s=>{s.target.contains(o)&&e(o)};return document.addEventListener("scroll",r,{capture:!0}),()=>{document.removeEventListener("scroll",r,{capture:!0})}},[t]),v=n.useCallback((o,e)=>{const r=s=>{e(o)};return window.addEventListener("resize",r,{capture:!0}),()=>{window.removeEventListener("resize",r,{capture:!0})}},[t]),a=n.useCallback(o=>{const e=o.getBoundingClientRect(),r=Math.round((e.top+window.scrollY)*l)/l,s=Math.round((e.left+window.scrollX)*l)/l;((t==null?void 0:t.top)!==r||(t==null?void 0:t.left)!==s)&&(u==null||u({top:r,left:s}),w({top:r,left:s,width:e.width>0?e.width:void 0}))},[t]);return n.useLayoutEffect(()=>{if(c.current){a(c.current);const o=m(c.current,a),e=v(c.current,a);return()=>{o(),e()}}},[t]),i.jsxs(i.Fragment,{children:[i.jsx(d,{ref:c}),t&&x.createPortal(i.jsx(d,{ref:p,position:"absolute",top:0,left:0,transition:"none",style:{transform:`translate(${t.left}px,${t.top}px)`,width:t.width},children:i.jsx(d,{position:"absolute",width:"fit",...f})}),h)]})}const C=n.forwardRef(R);module.exports=C;
|
package/components/tooltip.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ interface Props extends BoxProps {
|
|
|
5
5
|
left: number;
|
|
6
6
|
}): void;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
export
|
|
8
|
+
declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export default _default;
|
package/components/tooltip.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as x, Fragment as b, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { createPortal as E } from "react-dom";
|
|
3
3
|
import u from "../box.mjs";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { d as
|
|
4
|
+
import { forwardRef as L, useRef as R, useState as g, useCallback as d, useLayoutEffect as z } from "react";
|
|
5
|
+
import { d as C } from "../core.mjs";
|
|
6
6
|
const i = 2;
|
|
7
|
-
function
|
|
8
|
-
const { onPositionChange: c } = f, s =
|
|
7
|
+
function D(f, p) {
|
|
8
|
+
const { onPositionChange: c } = f, s = R(null), [t, m] = g(), w = C(), h = d(
|
|
9
9
|
(o, e) => {
|
|
10
10
|
const r = (n) => {
|
|
11
11
|
n.target.contains(o) && e(o);
|
|
@@ -15,7 +15,7 @@ function y(f) {
|
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
17
|
[t]
|
|
18
|
-
),
|
|
18
|
+
), v = d(
|
|
19
19
|
(o, e) => {
|
|
20
20
|
const r = (n) => {
|
|
21
21
|
e(o);
|
|
@@ -28,24 +28,25 @@ function y(f) {
|
|
|
28
28
|
), l = d(
|
|
29
29
|
(o) => {
|
|
30
30
|
const e = o.getBoundingClientRect(), r = Math.round((e.top + window.scrollY) * i) / i, n = Math.round((e.left + window.scrollX) * i) / i;
|
|
31
|
-
((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== n) && (c == null || c({ top: r, left: n }),
|
|
31
|
+
((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== n) && (c == null || c({ top: r, left: n }), m({ top: r, left: n, width: e.width > 0 ? e.width : void 0 }));
|
|
32
32
|
},
|
|
33
33
|
[t]
|
|
34
34
|
);
|
|
35
|
-
return
|
|
35
|
+
return z(() => {
|
|
36
36
|
if (s.current) {
|
|
37
37
|
l(s.current);
|
|
38
|
-
const o =
|
|
38
|
+
const o = h(s.current, l), e = v(s.current, l);
|
|
39
39
|
return () => {
|
|
40
40
|
o(), e();
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
}, [t]), /* @__PURE__ */
|
|
43
|
+
}, [t]), /* @__PURE__ */ x(b, { children: [
|
|
44
44
|
/* @__PURE__ */ a(u, { ref: s }),
|
|
45
|
-
t &&
|
|
45
|
+
t && E(
|
|
46
46
|
/* @__PURE__ */ a(
|
|
47
47
|
u,
|
|
48
48
|
{
|
|
49
|
+
ref: p,
|
|
49
50
|
position: "absolute",
|
|
50
51
|
top: 0,
|
|
51
52
|
left: 0,
|
|
@@ -54,10 +55,11 @@ function y(f) {
|
|
|
54
55
|
children: /* @__PURE__ */ a(u, { position: "absolute", width: "fit", ...f })
|
|
55
56
|
}
|
|
56
57
|
),
|
|
57
|
-
|
|
58
|
+
w
|
|
58
59
|
)
|
|
59
60
|
] });
|
|
60
61
|
}
|
|
62
|
+
const M = L(D);
|
|
61
63
|
export {
|
|
62
|
-
|
|
64
|
+
M as default
|
|
63
65
|
};
|
package/core/boxStyles.d.ts
CHANGED
|
@@ -701,6 +701,14 @@ export declare const cssStyles: {
|
|
|
701
701
|
valueFormat: (value: string, getVariableValue: (name: string) => string) => string;
|
|
702
702
|
styleName: string;
|
|
703
703
|
}[];
|
|
704
|
+
fill: {
|
|
705
|
+
values: Variables.ColorType[];
|
|
706
|
+
valueFormat: (value: string, getVariableValue: (name: string) => string) => string;
|
|
707
|
+
}[];
|
|
708
|
+
stroke: {
|
|
709
|
+
values: Variables.ColorType[];
|
|
710
|
+
valueFormat: (value: string, getVariableValue: (name: string) => string) => string;
|
|
711
|
+
}[];
|
|
704
712
|
bgImage: {
|
|
705
713
|
values: readonly ["none", "bg-img-checked", "bg-img-indeterminate", "bg-img-radio"];
|
|
706
714
|
valueFormat: (value: string, getVariableValue: (name: string) => string) => string;
|
|
@@ -726,12 +734,14 @@ export declare const pseudo2: {
|
|
|
726
734
|
checked: string;
|
|
727
735
|
required: string;
|
|
728
736
|
disabled: string;
|
|
737
|
+
selected: string;
|
|
729
738
|
};
|
|
730
739
|
export declare const pseudoClasses: {
|
|
731
740
|
indeterminate: string;
|
|
732
741
|
checked: string;
|
|
733
742
|
required: string;
|
|
734
743
|
disabled: string;
|
|
744
|
+
selected: string;
|
|
735
745
|
hover: string;
|
|
736
746
|
focus: string;
|
|
737
747
|
hasFocus: string;
|
|
@@ -745,9 +755,9 @@ export declare const pseudoClasses: {
|
|
|
745
755
|
hasRequired: string;
|
|
746
756
|
hasDisabled: string;
|
|
747
757
|
};
|
|
748
|
-
export declare const pseudoClassesWeight: Record<"indeterminate" | "checked" | "required" | "disabled" | "hover" | "focus" | "hasFocus" | "active" | "valid" | "hasValid" | "invalid" | "hasInvalid" | "optional" | "hasChecked" | "hasRequired" | "hasDisabled", number>;
|
|
758
|
+
export declare const pseudoClassesWeight: Record<"indeterminate" | "checked" | "required" | "disabled" | "selected" | "hover" | "focus" | "hasFocus" | "active" | "valid" | "hasValid" | "invalid" | "hasInvalid" | "optional" | "hasChecked" | "hasRequired" | "hasDisabled", number>;
|
|
749
759
|
export declare const pseudoClassesByWeight: {
|
|
750
|
-
[key: number]: ("indeterminate" | "checked" | "required" | "disabled" | "hover" | "focus" | "hasFocus" | "active" | "valid" | "hasValid" | "invalid" | "hasInvalid" | "optional" | "hasChecked" | "hasRequired" | "hasDisabled")[];
|
|
760
|
+
[key: number]: ("indeterminate" | "checked" | "required" | "disabled" | "selected" | "hover" | "focus" | "hasFocus" | "active" | "valid" | "hasValid" | "invalid" | "hasInvalid" | "optional" | "hasChecked" | "hasRequired" | "hasDisabled")[];
|
|
751
761
|
};
|
|
752
762
|
export declare const pseudoGroupClasses: {
|
|
753
763
|
hoverGroup: "hover";
|
package/core/variables.d.ts
CHANGED
|
@@ -196,7 +196,6 @@ declare namespace Variables {
|
|
|
196
196
|
'indigo-900': string;
|
|
197
197
|
'indigo-950': string;
|
|
198
198
|
'violet-50': string;
|
|
199
|
-
'violet-XX': string;
|
|
200
199
|
'violet-100': string;
|
|
201
200
|
'violet-200': string;
|
|
202
201
|
'violet-300': string;
|
|
@@ -253,7 +252,7 @@ declare namespace Variables {
|
|
|
253
252
|
'rose-900': string;
|
|
254
253
|
'rose-950': string;
|
|
255
254
|
};
|
|
256
|
-
type ColorType = keyof typeof colors;
|
|
255
|
+
type ColorType = keyof typeof colors | 'none';
|
|
257
256
|
function getVariableValue(name: string): string;
|
|
258
257
|
function generateVariables(): string;
|
|
259
258
|
function setUserVariables(variables: Record<string, string>): void;
|