@cronocode/react-box 3.0.10 → 3.0.11
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/components/dropdown.cjs +1 -1
- package/components/dropdown.d.ts +5 -2
- package/components/dropdown.mjs +116 -116
- package/core.cjs +1 -1
- package/core.mjs +6 -6
- package/package.json +1 -1
package/components/dropdown.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),n=require("react"),h=require("../box.cjs"),L=require("./textbox.cjs"),G=require("./flex.cjs"),Q=require("../core.cjs"),X=require("./baseSvg.cjs"),Z=require("./tooltip.cjs"),K=require("./button.cjs");function ee(i,m){const{name:p,defaultValue:g,value:y,multiple:u,isSearchable:w,searchPlaceholder:B,children:A,hideArrow:H,onChange:s,...Y}=i,[J,j]=n.useState(Array.isArray(g)?g:g?[g]:[]),c="value"in i?Array.isArray(y)?y:y?[y]:[]:J,[D,R]=n.useState(""),[a,U,I]=Q.useVisibility(),q=n.useRef(null),T=n.useRef(null),[V,W]=n.useState(0),b=n.useMemo(()=>V>window.innerHeight/2,[V]),$=n.useMemo(()=>{var e;return b?((e=I.current)==null?void 0:e.getBoundingClientRect().height)??0:0},[b,I]),l=n.useMemo(()=>(Array.isArray(A)?A:[A]).flatMap(e=>e),[A]),_=n.useMemo(()=>l.filter(e=>{var t;return((t=e.type)==null?void 0:t.displayName)==="DropdownItem"}),[l]),f=n.useMemo(()=>_.filter(e=>w&&D?P(e).toLowerCase().includes(D.toLowerCase()):!0),[w,D,l]),x=n.useMemo(()=>l.find(e=>{var t;return((t=e.type)==null?void 0:t.displayName)==="DropdownUnselect"}),[l]),O=n.useMemo(()=>l.find(e=>{var t;return((t=e.type)==null?void 0:t.displayName)==="DropdownSelectAll"}),[l]),N=n.useMemo(()=>l.find(e=>{var t;return((t=e.type)==null?void 0:t.displayName)==="DropdownEmptyItem"}),[l]),C=n.useMemo(()=>l.find(e=>{var t;return((t=e.type)==null?void 0:t.displayName)==="DropdownDisplay"}),[l]),z=n.useMemo(()=>{if(C)return C.props.children(c,a);const e=f.filter(o=>c.includes(o.props.value));if(u&&e.length>1)return e.map(o=>P(o)).join(", ");const t=e.at(0);return(t==null?void 0:t.props.children)??(t==null?void 0:t.props.value)??(u?null:x==null?void 0:x.props.children)},[u,f,c,x,a]),k=n.useCallback((e,...t)=>{if(t.length===0)j([]),s==null||s(void 0,[]);else if(u&&t.length>1){const o=t.map(d=>d.props.value);j(o),s==null||s(void 0,o)}else if(t.length===1){const o=t[0];if(u){const d=c.filter(M=>M!==o.props.value);d.length===c.length&&d.push(o.props.value),j(d),s==null||s(o.props.value,d)}else j([o.props.value]),s==null||s(o.props.value,[o.props.value])}u?(e.stopPropagation(),setTimeout(()=>{var o;return(o=q.current)==null?void 0:o.focus()},0)):(U(!1),setTimeout(()=>{var o;return(o=I.current)==null?void 0:o.focus()},0))},[u,c,j]);n.useEffect(()=>{a?setTimeout(()=>{var e,t,o;(e=q.current)==null||e.focus(),(o=(t=T.current)==null?void 0:t.querySelector('[aria-selected="true"]'))==null||o.scrollIntoView({block:"nearest"})},0):R("")},[a]);const E=O&&u&&f.length>c.length,F=x&&f.length>0&&!E;return r.jsxs(h,{width:"fit-content",children:[c.map(e=>r.jsx(L,{ref:m,name:p,type:"hidden",value:JSON.stringify(e)??""},JSON.stringify(e))),r.jsxs(K,{ref:I,component:"dropdown",onClick:()=>U(e=>!e),props:{tabIndex:0},...Y,children:[w&&r.jsx(L,{display:a&&w?"block":"none",clean:!0,flex1:!0,width:1,minHeight:5,placeholder:B,value:D,onChange:e=>R(e.target.value),ref:q,props:{onClick:e=>{a&&w&&e.stopPropagation()}}}),r.jsx(G,{component:"dropdown.display",display:a&&w?"none":"flex",children:z}),!H&&r.jsx(h,{children:r.jsx(X,{viewBox:"0 0 10 6",width:"0.6rem",rotate:a?180:0,children:r.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 4 4 4-4"})})})]}),a&&r.jsx(Z,{ref:T,top:b?void 0:0,bottom:b?2:void 0,style:{transform:`translateY(-${$}px)`},onPositionChange:e=>W(e.top-window.scrollY),children:(f.length>0||N)&&r.jsxs(h,{component:"dropdown.items",children:[F&&r.jsx(h,{component:"dropdown.unselect",selected:c.length===0,...x.props,props:{onClick:e=>k(e)}}),E&&r.jsx(h,{component:"dropdown.selectAll",...O.props,props:{onClick:e=>k(e,..._)}}),f.map(e=>{const{value:t,onClick:o,...d}=e.props;return r.jsx(h,{component:"dropdown.item",theme:u?"multiple":"single",selected:c.includes(t),...d,props:{onClick:M=>{o==null||o(M),k(M,e)}}},t)}),f.length===0&&N&&r.jsx(h,{component:"dropdown.emptyItem",...N.props})]})})]})}function S(i){const m=p=>null;return m.displayName=i,m}const v=n.forwardRef(ee);v.Item=S("DropdownItem");v.Unselect=S("DropdownUnselect");v.SelectAll=S("DropdownSelectAll");v.EmptyItem=S("DropdownEmptyItem");v.Display=S("DropdownDisplay");function P(i){var m;if(i==null)return"";if(typeof i=="object"){const p=(m=i.props)==null?void 0:m.children;return p==null?"":typeof p=="object"?(Array.isArray(p)?p:[p]).map(y=>P(y)).join(""):p.toString()}return i.toString()}module.exports=v;
|
package/components/dropdown.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { BoxProps } from '../box';
|
|
3
|
-
interface Props<TVal> extends BoxProps {
|
|
3
|
+
interface Props<TVal> extends BoxProps<'button'> {
|
|
4
4
|
name?: string;
|
|
5
5
|
defaultValue?: TVal | TVal[];
|
|
6
|
+
value?: TVal | TVal[];
|
|
6
7
|
multiple?: boolean;
|
|
7
8
|
isSearchable?: boolean;
|
|
8
9
|
searchPlaceholder?: string;
|
|
10
|
+
hideArrow?: boolean;
|
|
9
11
|
onChange?: (value: Maybe<TVal>, values: TVal[]) => void;
|
|
10
12
|
}
|
|
11
13
|
interface DropdownItemProps<TVal> extends BoxProps {
|
|
12
14
|
value: TVal;
|
|
15
|
+
onClick?(e: React.MouseEvent): void;
|
|
13
16
|
}
|
|
14
17
|
interface DropdownDisplayProps<TVal> extends Omit<BoxProps, 'children'> {
|
|
15
|
-
children: (selectedValues: TVal[]) => React.ReactNode;
|
|
18
|
+
children: (selectedValues: TVal[], isOpen: boolean) => React.ReactNode;
|
|
16
19
|
}
|
|
17
20
|
interface DropdownType {
|
|
18
21
|
<TVal>(props: Props<TVal>, ref: Ref<HTMLInputElement>): React.ReactNode;
|
package/components/dropdown.mjs
CHANGED
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as U, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Z, useState as B, useRef as M, useMemo as c, useCallback as K, useEffect as ee } from "react";
|
|
3
3
|
import h from "../box.mjs";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { b as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
function
|
|
11
|
-
const { name: p, defaultValue: g, multiple:
|
|
4
|
+
import q from "./textbox.mjs";
|
|
5
|
+
import te from "./flex.mjs";
|
|
6
|
+
import { b as oe } from "../core.mjs";
|
|
7
|
+
import re from "./baseSvg.mjs";
|
|
8
|
+
import ne from "./tooltip.mjs";
|
|
9
|
+
import le from "./button.mjs";
|
|
10
|
+
function se(s, m) {
|
|
11
|
+
const { name: p, defaultValue: g, value: y, multiple: a, isSearchable: w, searchPlaceholder: F, children: S, hideArrow: W, onChange: r, ..._ } = s, [$, x] = B(Array.isArray(g) ? g : g ? [g] : []), i = "value" in s ? Array.isArray(y) ? y : y ? [y] : [] : $, [I, O] = B(""), [d, R, b] = oe(), P = M(null), C = M(null), [E, z] = B(0), N = c(() => E > window.innerHeight / 2, [E]), G = c(() => {
|
|
12
12
|
var e;
|
|
13
|
-
return
|
|
14
|
-
}, [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
return ((
|
|
20
|
-
}), [
|
|
21
|
-
var
|
|
22
|
-
return ((
|
|
23
|
-
}), [
|
|
24
|
-
var
|
|
25
|
-
return ((
|
|
26
|
-
}), [
|
|
27
|
-
var
|
|
28
|
-
return ((
|
|
29
|
-
}), [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
13
|
+
return N ? ((e = b.current) == null ? void 0 : e.getBoundingClientRect().height) ?? 0 : 0;
|
|
14
|
+
}, [N, b]), n = c(
|
|
15
|
+
() => (Array.isArray(S) ? S : [S]).flatMap((e) => e),
|
|
16
|
+
[S]
|
|
17
|
+
), L = c(() => n.filter((e) => {
|
|
18
|
+
var t;
|
|
19
|
+
return ((t = e.type) == null ? void 0 : t.displayName) === "DropdownItem";
|
|
20
|
+
}), [n]), f = c(() => L.filter((e) => w && I ? V(e).toLowerCase().includes(I.toLowerCase()) : !0), [w, I, n]), v = c(() => n.find((e) => {
|
|
21
|
+
var t;
|
|
22
|
+
return ((t = e.type) == null ? void 0 : t.displayName) === "DropdownUnselect";
|
|
23
|
+
}), [n]), H = c(() => n.find((e) => {
|
|
24
|
+
var t;
|
|
25
|
+
return ((t = e.type) == null ? void 0 : t.displayName) === "DropdownSelectAll";
|
|
26
|
+
}), [n]), T = c(() => n.find((e) => {
|
|
27
|
+
var t;
|
|
28
|
+
return ((t = e.type) == null ? void 0 : t.displayName) === "DropdownEmptyItem";
|
|
29
|
+
}), [n]), Y = c(() => n.find((e) => {
|
|
30
|
+
var t;
|
|
31
|
+
return ((t = e.type) == null ? void 0 : t.displayName) === "DropdownDisplay";
|
|
32
|
+
}), [n]), Q = c(() => {
|
|
33
|
+
if (Y) return Y.props.children(i, d);
|
|
34
|
+
const e = f.filter((o) => i.includes(o.props.value));
|
|
35
|
+
if (a && e.length > 1)
|
|
36
|
+
return e.map((o) => V(o)).join(", ");
|
|
37
|
+
const t = e.at(0);
|
|
38
|
+
return (t == null ? void 0 : t.props.children) ?? (t == null ? void 0 : t.props.value) ?? (a ? null : v == null ? void 0 : v.props.children);
|
|
39
|
+
}, [a, f, i, v, d]), j = K(
|
|
40
|
+
(e, ...t) => {
|
|
41
|
+
if (t.length === 0)
|
|
42
|
+
x([]), r == null || r(void 0, []);
|
|
43
|
+
else if (a && t.length > 1) {
|
|
44
|
+
const o = t.map((u) => u.props.value);
|
|
45
|
+
x(o), r == null || r(void 0, o);
|
|
46
|
+
} else if (t.length === 1) {
|
|
47
|
+
const o = t[0];
|
|
48
|
+
if (a) {
|
|
49
|
+
const u = i.filter((k) => k !== o.props.value);
|
|
50
|
+
u.length === i.length && u.push(o.props.value), x(u), r == null || r(o.props.value, u);
|
|
48
51
|
} else
|
|
49
|
-
|
|
52
|
+
x([o.props.value]), r == null || r(o.props.value, [o.props.value]);
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
return (
|
|
54
|
-
}, 0)) : (
|
|
55
|
-
var
|
|
56
|
-
return (
|
|
54
|
+
a ? (e.stopPropagation(), setTimeout(() => {
|
|
55
|
+
var o;
|
|
56
|
+
return (o = P.current) == null ? void 0 : o.focus();
|
|
57
|
+
}, 0)) : (R(!1), setTimeout(() => {
|
|
58
|
+
var o;
|
|
59
|
+
return (o = b.current) == null ? void 0 : o.focus();
|
|
57
60
|
}, 0));
|
|
58
61
|
},
|
|
59
|
-
[
|
|
62
|
+
[a, i, x]
|
|
60
63
|
);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var e,
|
|
64
|
-
(e =
|
|
65
|
-
}, 0) :
|
|
66
|
-
}, [
|
|
67
|
-
const
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
i.map((e) => /* @__PURE__ */ l(
|
|
70
|
-
/* @__PURE__ */
|
|
64
|
+
ee(() => {
|
|
65
|
+
d ? setTimeout(() => {
|
|
66
|
+
var e, t, o;
|
|
67
|
+
(e = P.current) == null || e.focus(), (o = (t = C.current) == null ? void 0 : t.querySelector('[aria-selected="true"]')) == null || o.scrollIntoView({ block: "nearest" });
|
|
68
|
+
}, 0) : O("");
|
|
69
|
+
}, [d]);
|
|
70
|
+
const J = H && a && f.length > i.length, X = v && f.length > 0 && !J;
|
|
71
|
+
return /* @__PURE__ */ U(h, { width: "fit-content", children: [
|
|
72
|
+
i.map((e) => /* @__PURE__ */ l(q, { ref: m, name: p, type: "hidden", value: JSON.stringify(e) ?? "" }, JSON.stringify(e))),
|
|
73
|
+
/* @__PURE__ */ U(le, { ref: b, component: "dropdown", onClick: () => R((e) => !e), props: { tabIndex: 0 }, ..._, children: [
|
|
71
74
|
w && /* @__PURE__ */ l(
|
|
72
|
-
|
|
75
|
+
q,
|
|
73
76
|
{
|
|
74
|
-
display:
|
|
77
|
+
display: d && w ? "block" : "none",
|
|
75
78
|
clean: !0,
|
|
76
79
|
flex1: !0,
|
|
77
80
|
width: 1,
|
|
78
81
|
minHeight: 5,
|
|
79
|
-
placeholder:
|
|
80
|
-
value:
|
|
81
|
-
onChange: (e) =>
|
|
82
|
-
ref:
|
|
82
|
+
placeholder: F,
|
|
83
|
+
value: I,
|
|
84
|
+
onChange: (e) => O(e.target.value),
|
|
85
|
+
ref: P,
|
|
83
86
|
props: {
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
onClick: (e) => {
|
|
88
|
+
d && w && e.stopPropagation();
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
),
|
|
90
|
-
/* @__PURE__ */ l(
|
|
91
|
-
/* @__PURE__ */ l(h, { children: /* @__PURE__ */ l(
|
|
93
|
+
/* @__PURE__ */ l(te, { component: "dropdown.display", display: d && w ? "none" : "flex", children: Q }),
|
|
94
|
+
!W && /* @__PURE__ */ l(h, { children: /* @__PURE__ */ l(re, { viewBox: "0 0 10 6", width: "0.6rem", rotate: d ? 180 : 0, children: /* @__PURE__ */ l("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m1 1 4 4 4-4" }) }) })
|
|
92
95
|
] }),
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
d && /* @__PURE__ */ l(
|
|
97
|
+
ne,
|
|
95
98
|
{
|
|
96
|
-
ref:
|
|
97
|
-
top:
|
|
98
|
-
bottom:
|
|
99
|
-
style: { transform: `translateY(-${
|
|
100
|
-
onPositionChange: (e) =>
|
|
101
|
-
children: (f.length > 0 ||
|
|
102
|
-
|
|
99
|
+
ref: C,
|
|
100
|
+
top: N ? void 0 : 0,
|
|
101
|
+
bottom: N ? 2 : void 0,
|
|
102
|
+
style: { transform: `translateY(-${G}px)` },
|
|
103
|
+
onPositionChange: (e) => z(e.top - window.scrollY),
|
|
104
|
+
children: (f.length > 0 || T) && /* @__PURE__ */ U(h, { component: "dropdown.items", children: [
|
|
105
|
+
X && /* @__PURE__ */ l(
|
|
103
106
|
h,
|
|
104
107
|
{
|
|
105
108
|
component: "dropdown.unselect",
|
|
106
109
|
selected: i.length === 0,
|
|
107
|
-
...
|
|
108
|
-
props: {
|
|
109
|
-
}
|
|
110
|
-
),
|
|
111
|
-
L && /* @__PURE__ */ l(
|
|
112
|
-
h,
|
|
113
|
-
{
|
|
114
|
-
component: "dropdown.selectAll",
|
|
115
|
-
...E.props,
|
|
116
|
-
props: { onMouseDown: (e) => j(e, ...k) }
|
|
110
|
+
...v.props,
|
|
111
|
+
props: { onClick: (e) => j(e) }
|
|
117
112
|
}
|
|
118
113
|
),
|
|
114
|
+
J && /* @__PURE__ */ l(h, { component: "dropdown.selectAll", ...H.props, props: { onClick: (e) => j(e, ...L) } }),
|
|
119
115
|
f.map((e) => {
|
|
120
|
-
const { value: o, ...
|
|
116
|
+
const { value: t, onClick: o, ...u } = e.props;
|
|
121
117
|
return /* @__PURE__ */ l(
|
|
122
118
|
h,
|
|
123
119
|
{
|
|
124
120
|
component: "dropdown.item",
|
|
125
|
-
theme:
|
|
126
|
-
selected: i.includes(
|
|
127
|
-
...
|
|
128
|
-
props: {
|
|
121
|
+
theme: a ? "multiple" : "single",
|
|
122
|
+
selected: i.includes(t),
|
|
123
|
+
...u,
|
|
124
|
+
props: {
|
|
125
|
+
onClick: (k) => {
|
|
126
|
+
o == null || o(k), j(k, e);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
129
|
},
|
|
130
|
-
|
|
130
|
+
t
|
|
131
131
|
);
|
|
132
132
|
}),
|
|
133
|
-
f.length === 0 &&
|
|
133
|
+
f.length === 0 && T && /* @__PURE__ */ l(h, { component: "dropdown.emptyItem", ...T.props })
|
|
134
134
|
] })
|
|
135
135
|
}
|
|
136
136
|
)
|
|
137
137
|
] });
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
const
|
|
141
|
-
return
|
|
139
|
+
function A(s) {
|
|
140
|
+
const m = (p) => null;
|
|
141
|
+
return m.displayName = s, m;
|
|
142
142
|
}
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
function
|
|
150
|
-
var
|
|
151
|
-
if (
|
|
152
|
-
if (typeof
|
|
153
|
-
const p = (
|
|
154
|
-
return p == null ? "" : typeof p == "object" ? (Array.isArray(p) ? p : [p]).map((
|
|
143
|
+
const D = Z(se);
|
|
144
|
+
D.Item = A("DropdownItem");
|
|
145
|
+
D.Unselect = A("DropdownUnselect");
|
|
146
|
+
D.SelectAll = A("DropdownSelectAll");
|
|
147
|
+
D.EmptyItem = A("DropdownEmptyItem");
|
|
148
|
+
D.Display = A("DropdownDisplay");
|
|
149
|
+
function V(s) {
|
|
150
|
+
var m;
|
|
151
|
+
if (s == null) return "";
|
|
152
|
+
if (typeof s == "object") {
|
|
153
|
+
const p = (m = s.props) == null ? void 0 : m.children;
|
|
154
|
+
return p == null ? "" : typeof p == "object" ? (Array.isArray(p) ? p : [p]).map((y) => V(y)).join("") : p.toString();
|
|
155
155
|
}
|
|
156
|
-
return
|
|
156
|
+
return s.toString();
|
|
157
157
|
}
|
|
158
158
|
export {
|
|
159
|
-
|
|
159
|
+
D as default
|
|
160
160
|
};
|
package/core.cjs
CHANGED
|
@@ -4,4 +4,4 @@ body{margin: 0;line-height: var(--lineHeight);font-size: var(--fontSize);}
|
|
|
4
4
|
a,ul{all: unset;}
|
|
5
5
|
.${ue}{display: block;border: 0 solid var(--borderColor);outline: 0px solid var(--outlineColor);margin: 0;padding: 0;background-color: initial;transition: all var(--transitionTime);box-sizing: border-box;font-family: inherit;font-size: inherit;}
|
|
6
6
|
.${A}{display: block;border: 0 solid var(--borderColor);outline: 0px solid var(--outlineColor);margin: 0;padding: 0;transition: all var(--svgTransitionTime);}.${A} path,.${A} circle,.${A} rect,.${A} line {transition: all var(--svgTransitionTime);}
|
|
7
|
-
`,g=Object.entries(r);g.sort(([c],[m])=>(U[c]??0)-(U[m]??0));const b=g.reduce((c,[m,N])=>(m!=="normal"&&c.push(`@media(min-width: ${U[m]}px){`),Object.entries(N).forEach(([F,q])=>{const{__parents:ee,...de}=q,te=Object.entries(de);te.sort(([C],[R])=>l[C]-l[R]),te.forEach(([C,R])=>{R.forEach(E=>{var
|
|
7
|
+
`,g=Object.entries(r);g.sort(([c],[m])=>(U[c]??0)-(U[m]??0));const b=g.reduce((c,[m,N])=>(m!=="normal"&&c.push(`@media(min-width: ${U[m]}px){`),Object.entries(N).forEach(([F,q])=>{const{__parents:ee,...de}=q,te=Object.entries(de);te.sort(([C],[R])=>l[C]-l[R]),te.forEach(([C,R])=>{R.forEach(E=>{var I,H;const h=z[C].find(V=>Array.isArray(V.values)?V.values.includes(E):typeof E==typeof V.values);if(!h)return;const j=o(C,E,+F,m),D=K[+F].map(V=>Z[V]).join(""),x=((I=h.selector)==null?void 0:I.call(h,`.${j}`,D))??`.${j}${D}`,k=Array.isArray(h.styleName)?h.styleName:[h.styleName??C],S=((H=h.valueFormat)==null?void 0:H.call(h,E,w.getVariableValue))??E;c.push(`${x}{${k.map(V=>`${V}:${S}`).join(";")}}`)})}),ee&&Object.entries(ee).forEach(([C,R])=>{const E=Object.entries(R);E.sort(([O],[h])=>l[O]-l[h]),E.forEach(([O,h])=>{h.forEach(j=>{var re,oe;const x=z[O].find(_=>Array.isArray(_.values)?_.values.includes(j):typeof j==typeof _.values);if(!x)return;const k=o(O,j,+F,m,C),[S]=K[+F],I=((re=x.selector)==null?void 0:re.call(x,`.${S}-${C}:${S} .${k}`,""))??`.${S}-${C}:${S} .${k}`,H=Array.isArray(x.styleName)?x.styleName:[x.styleName??O],V=((oe=x.valueFormat)==null?void 0:oe.call(x,j,w.getVariableValue))??j;c.push(`${I}{${H.map(_=>`${_}:${V}`).join(";")}}`)})})})}),m!=="normal"&&c.push("}"),c),[v]);b.unshift(`:root{${w.generateVariables()}}`);const s=y();s.innerHTML=b.join(""),t=!1}e.flush=i;function n(){r={}}e.clear=n;function d(l,v,g,b,s="normal",c){if(v==null)return;const m=b.reduce((F,q)=>F+ie[q],0);r[s]?r[s][m]?r[s][m][l]||(r[s][m][l]=new Set):r[s][m]={[l]:new Set}:r[s]={[m]:{[l]:new Set}},c?(r[s][m].__parents?r[s][m].__parents[c]?r[s][m].__parents[c][l]||(r[s][m].__parents[c][l]=new Set):r[s][m].__parents[c]={[l]:new Set}:r[s][m].__parents={[c]:{[l]:new Set}},r[s][m].__parents[c][l].has(v)||(r[s][m].__parents[c][l].add(v),t=!0)):r[s][m][l].has(v)||(r[s][m][l].add(v),t=!0);const N=o(l,v,m,s,c);g.push(N)}function o(l,v,g,b,s){const c=K[g],m=`${b==="normal"?"":`${b}-`}${c.map(N=>`${N}-`).join("")}${s?`${s}-`:""}${l}-${v}`;return ne?m:be.getIdentity(m)}const f="crono-styles";function y(){let l=document.getElementById(f);return l||(l=document.createElement("style"),l.setAttribute("id",f),l.setAttribute("type","text/css"),document.head.insertBefore(l,document.head.firstChild)),l}})(T||(T={}));exports.StylesContext=void 0;(e=>{e.flush=T.flush,e.clear=T.clear})(exports.StylesContext||(exports.StylesContext={}));var Y;(e=>{function t(r,a,i){return w.setUserVariables(r),Object.entries(a).forEach(([n,d])=>{z[n]=d}),Object.entries(i).forEach(([n,d])=>{const o=z[n];z[n]=o?[...d,...o]:d}),{extendedProps:a,extendedPropTypes:i}}e.extend=t})(Y||(Y={}));const pe=Y;function L(e){const{children:t,theme:r}=e,[a,i]=p.useState(r),n=p.useMemo(()=>{var l;const d=(l=L.userThemes)==null?void 0:l[a];if(!d)return B;const{components:o,...f}=d,y=o??{};return Object.entries(f).forEach(([v,g])=>{y[v]=g}),Object.keys(y).forEach(v=>{y[v].clean&&v in B&&delete B[v]}),$.mergeDeep(B,y)},[a]);return ce.jsx(P.Provider,{value:{themeStyles:n,theme:a,setTheme:i},children:t})}(e=>{e.userThemes=void 0;function t(a){e.userThemes=a}e.setup=t;function r(){const{theme:a,setTheme:i}=p.useContext(P);return[a,i]}e.useTheme=r})(L||(L={}));const xe=L,we={selected:"aria-selected"};var J;(e=>{function t(r,a,i){r!==void 0&&r!=null&&(i[we[a]??a]=Array.isArray(r)?r[0]:r)}e.assignBooleanProp=t})(J||(J={}));const Ne=J;Array.prototype.removeBy||(Array.prototype.removeBy=function(e){return this.filter(e)});function Fe(e=null){const[t,r]=p.useState(!1),a=p.useRef(null);return p.useEffect(()=>{function i(d){const o=e??a.current;(o==null?void 0:o.contains(d.target))===!1&&r(!1)}function n(d){d.key==="Escape"&&r(!1)}return t&&(window.addEventListener("click",i),window.addEventListener("keydown",n)),()=>{window.removeEventListener("click",i),window.removeEventListener("keydown",n)}},[e,t]),[t,r,a]}function $e(){return p.useMemo(()=>{const e="crono-box";let t=document.getElementById(e);return t||(t=document.createElement("div"),t.id=e,document.body.appendChild(t)),t},[])}var Q;(e=>{function t(a){const i=Array.from(a.elements).reduce((n,d)=>{const o=d.name;return o&&(n[o]||(n[o]=[]),n[o].push(d)),n},{});return Object.entries(i).reduce((n,[d,o])=>{if(o.length===1){const f=o[0];r(n,d,f.type==="checkbox"||f.type==="radio"?f.checked:f.value)}else{const f=o.reduce((y,l)=>(l.type==="checkbox"||l.type==="radio"?l.checked&&y.push(l.value):y.push(l.value),y),[]);r(n,d,f)}return n},{})}e.getFormEntries=t;function r(a,i,n){if(i.includes(".")){const d=i.split(".");let o=a;d.forEach((f,y)=>{if(d.length>y+1){const l=f.match(/^(.+)\[(\d)\]$/);if(l){const[,v,g]=l;o[v]=o[v]||[],o[v][g]=o[v][g]||{},o=o[v][g]}else o[f]=o[f]||{},o=o[f]}else o[f]=n})}else a[i]=n}})(Q||(Q={}));const Ce=Q;exports.BoxExtends=pe;exports.BoxUtils=Ne;exports.FormUtils=Ce;exports.ObjectUtils=$;exports.Theme=xe;exports.Variables=w;exports.classNames=ae;exports.usePortalContainer=$e;exports.useStyles=he;exports.useVisibility=Fe;
|
package/core.mjs
CHANGED
|
@@ -1977,10 +1977,10 @@ a,ul{all: unset;}
|
|
|
1977
1977
|
const { __parents: ee, ...me } = D, te = Object.entries(me);
|
|
1978
1978
|
te.sort(([F], [T]) => a[F] - a[T]), te.forEach(([F, T]) => {
|
|
1979
1979
|
T.forEach((V) => {
|
|
1980
|
-
var
|
|
1980
|
+
var k, I;
|
|
1981
1981
|
const h = E[F].find(($) => Array.isArray($.values) ? $.values.includes(V) : typeof V == typeof $.values);
|
|
1982
1982
|
if (!h) return;
|
|
1983
|
-
const z = o(F, V, +x, m), K = W[+x].map(($) => Z[$]).join(""), p = ((
|
|
1983
|
+
const z = o(F, V, +x, m), K = W[+x].map(($) => Z[$]).join(""), p = ((k = h.selector) == null ? void 0 : k.call(h, `.${z}`, K)) ?? `.${z}${K}`, B = Array.isArray(h.styleName) ? h.styleName : [h.styleName ?? F], O = ((I = h.valueFormat) == null ? void 0 : I.call(h, V, N.getVariableValue)) ?? V;
|
|
1984
1984
|
c.push(`${p}{${B.map(($) => `${$}:${O}`).join(";")}}`);
|
|
1985
1985
|
});
|
|
1986
1986
|
}), ee && Object.entries(ee).forEach(([F, T]) => {
|
|
@@ -1990,8 +1990,8 @@ a,ul{all: unset;}
|
|
|
1990
1990
|
var re, oe;
|
|
1991
1991
|
const p = E[j].find((_) => Array.isArray(_.values) ? _.values.includes(z) : typeof z == typeof _.values);
|
|
1992
1992
|
if (!p) return;
|
|
1993
|
-
const B = o(j, z, +x, m, F), [O] = W[+x],
|
|
1994
|
-
c.push(`${
|
|
1993
|
+
const B = o(j, z, +x, m, F), [O] = W[+x], k = ((re = p.selector) == null ? void 0 : re.call(p, `.${O}-${F}:${O} .${B}`, "")) ?? `.${O}-${F}:${O} .${B}`, I = Array.isArray(p.styleName) ? p.styleName : [p.styleName ?? j], $ = ((oe = p.valueFormat) == null ? void 0 : oe.call(p, z, N.getVariableValue)) ?? z;
|
|
1994
|
+
c.push(`${k}{${I.map((_) => `${_}:${$}`).join(";")}}`);
|
|
1995
1995
|
});
|
|
1996
1996
|
});
|
|
1997
1997
|
});
|
|
@@ -2091,8 +2091,8 @@ function Se(e = null) {
|
|
|
2091
2091
|
function n(d) {
|
|
2092
2092
|
d.key === "Escape" && r(!1);
|
|
2093
2093
|
}
|
|
2094
|
-
return t && (window.addEventListener("
|
|
2095
|
-
window.removeEventListener("
|
|
2094
|
+
return t && (window.addEventListener("click", i), window.addEventListener("keydown", n)), () => {
|
|
2095
|
+
window.removeEventListener("click", i), window.removeEventListener("keydown", n);
|
|
2096
2096
|
};
|
|
2097
2097
|
}, [e, t]), [t, r, l];
|
|
2098
2098
|
}
|