@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 ADDED
@@ -0,0 +1,6 @@
1
+ export {};
2
+ declare global {
3
+ interface Array<T> {
4
+ removeBy(predicate: (value: T) => boolean): Array<T>;
5
+ }
6
+ }
package/box.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const t=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:f,checked:g}=a,B=e.useStyles(a,c==="svg"),r=t.useMemo(()=>{const b=e.classNames(B,p).join(" "),s={...m,className:b};return e.BoxUtils.assignBooleanProp(x,"disabled",s),e.BoxUtils.assignBooleanProp(f,"required",s),e.BoxUtils.assignBooleanProp(g,"checked",s),i&&(s.style=i),l&&(s.ref=l),s},[a]),[v,u]=t.useState(!1),d=typeof n=="function";return d&&(r.onMouseEnter=()=>u(!0),r.onMouseLeave=()=>u(!1)),t.createElement(c,r,d?n({isHover:v}):n)}const o=t.memo(t.forwardRef(h));o.extend=e.BoxExtends.extend;o.themeSetup=e.Theme.setup;o.getVariableValue=e.Variables.getVariableValue;module.exports=o;
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 P } from "react";
2
- import { B as N, T as S, V as C, u as E, c as H, a as t } from "./core.mjs";
3
- function M(s, r) {
4
- const { tag: l = "div", children: a, props: d, className: m, style: c, disabled: f, required: p, checked: g } = s, x = E(s, l === "svg"), o = y(() => {
5
- const v = H(x, m).join(" "), e = {
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: v
7
+ className: P
8
8
  };
9
- return t.assignBooleanProp(f, "disabled", e), t.assignBooleanProp(p, "required", e), t.assignBooleanProp(g, "checked", e), c && (e.style = c), r && (e.ref = r), e;
10
- }, [s]), [B, i] = P(!1), u = typeof a == "function";
11
- return u && (o.onMouseEnter = () => i(!0), o.onMouseLeave = () => i(!1)), V.createElement(l, o, u ? a({ isHover: B }) : a);
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(M));
14
- n.extend = N.extend;
15
- n.themeSetup = S.setup;
16
- n.getVariableValue = C.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
  };
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime");require("react");const i=require("../box.cjs"),c=require("./grid.cjs");function g(u){const{data:e,def:d}=u,{rowKey:t,columns:s}=d;return s.length===0?(console.error("Cannot render grid without column definitions"),null):n.jsx(i,{component:"dataGrid",children:n.jsxs(c,{b:1,borderRadius:1,children:[s.map((r,o)=>n.jsx(i,{style:{gridColumn:o+1},children:r.key.toString()},r.key.toString())),((e==null?void 0:e.length)??0)===0&&n.jsx(i,{children:"Empty table"}),((e==null?void 0:e.length)??0)>0&&n.jsx(n.Fragment,{children:e==null?void 0:e.map((r,o)=>{const m=t?typeof t=="function"?t(r):r[t]:o;return n.jsx(c,{style:{gridTemplateRows:"subgrid"},children:s.map((h,l)=>n.jsxs(i,{style:{gridColumn:l+1},children:["tes ",l]}))},m)})})]})})}module.exports=g;
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;
@@ -1,18 +1,18 @@
1
- import { jsx as n, jsxs as d, Fragment as g } from "react/jsx-runtime";
1
+ import { jsx as n, jsxs as c, Fragment as h } from "react/jsx-runtime";
2
2
  import "react";
3
- import o from "../box.mjs";
3
+ import i from "../box.mjs";
4
4
  import s from "./grid.mjs";
5
- function x(c) {
6
- const { data: r, def: u } = c, { rowKey: t, columns: i } = u;
7
- return i.length === 0 ? (console.error("Cannot render grid without column definitions"), null) : /* @__PURE__ */ n(o, { component: "dataGrid", children: /* @__PURE__ */ d(s, { b: 1, borderRadius: 1, children: [
8
- i.map((e, l) => /* @__PURE__ */ n(o, { style: { gridColumn: l + 1 }, children: e.key.toString() }, e.key.toString())),
9
- ((r == null ? void 0 : r.length) ?? 0) === 0 && /* @__PURE__ */ n(o, { children: "Empty table" }),
10
- ((r == null ? void 0 : r.length) ?? 0) > 0 && /* @__PURE__ */ n(g, { children: r == null ? void 0 : r.map((e, l) => {
11
- const p = t ? typeof t == "function" ? t(e) : e[t] : l;
12
- return /* @__PURE__ */ n(s, { style: { gridTemplateRows: "subgrid" }, children: i.map((h, m) => /* @__PURE__ */ d(o, { style: { gridColumn: m + 1 }, 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
  }
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),c=require("react"),w=require("../box.cjs"),A=require("./tooltip.cjs"),L=require("./baseSvg.cjs"),T=require("../core.cjs"),g=require("./textbox.cjs"),N=require("./flex.cjs"),y=require("./button.cjs");function P(n,d){var v;const{children:o,name:S,isSearchable:u,searchPlaceholder:C,onChange:f,selectedValue:I}=n,[l,b]=c.useState(""),i=c.useMemo(()=>(Array.isArray(o)?o:[o]).filter(a=>{var s;return((s=a.type)==null?void 0:s.componentName)!=="DropdownItem"?!1:u&&l?q(a).toLowerCase().includes(l.toLowerCase()):!0}),[u,l,o]),[t,k]=c.useState(i.find(e=>e.props.value===I)??(i==null?void 0:i[0])),[p,h,M]=T.useVisibility(),m=c.useRef(null),R=c.useCallback(()=>{h(e=>!e)},[h]),_=c.useCallback(e=>{var a,s;k(e),h(!1),(s=(a=e.props).onClick)==null||s.call(a),f==null||f(e.props.value),setTimeout(()=>{var x;return(x=m.current)==null?void 0:x.focus()},10)},[]);return c.useEffect(()=>{p?setTimeout(()=>{var e;return(e=m.current)==null?void 0:e.focus()},0):b("")},[p]),r.jsxs(w,{ref:M,width:"fit-content",userSelect:"none",children:[r.jsx(g,{name:S,type:"hidden",value:(v=t==null?void 0:t.props)==null?void 0:v.toString()}),r.jsxs(y,{component:"dropdown",...n,props:{onMouseDown:R,tabIndex:0},children:[p&&u?r.jsx(g,{clean:!0,flex1:!0,width:1,placeholder:C,value:l,onChange:e=>b(e.target.value),ref:m,props:{onMouseDown:e=>{p&&u&&e.stopPropagation()}}}):r.jsx(N,{children:(t==null?void 0:t.props.children)??(t==null?void 0:t.props.value)}),r.jsx(L,{viewBox:"0 0 10 6",width:"0.6rem",rotate:p?180:0,children:r.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 4 4 4-4"})})]}),p&&r.jsx(A,{children:r.jsxs(w,{component:"dropdown.items",children:[i.map((e,a)=>{var s;return r.jsx(j,{...e.props,onClick:()=>_(e)},(s=e.props.value)==null?void 0:s.toString())}),i.length===0&&r.jsx(w,{p:2,color:"gray-500",userSelect:"none",props:{onMouseDown:e=>e.stopPropagation()},children:"No options"})]})})]})}function j(n){return r.jsx(y,{component:"dropdown.item",...n,props:{onMouseDown:n.onClick}})}j.componentName="DropdownItem";const D=c.forwardRef(P);D.Item=j;function q(n){var d;if(n==null)return"";if(typeof n=="object"){const o=(d=n.props)==null?void 0:d.children;return o==null?"":typeof o=="object"?(Array.isArray(o)?o:[o]).map(u=>q(u)).join(""):o.toString()}return n.toString()}module.exports=D;
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;
@@ -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
- children: React.ReactElement<DropdownItemProps<TVal>> | Array<React.ReactElement<DropdownItemProps<TVal>>>;
5
+ defaultValue?: TVal | TVal[];
6
+ multiple?: boolean;
10
7
  isSearchable?: boolean;
11
8
  searchPlaceholder?: string;
12
- onChange?: (value: TVal) => void;
13
- selectedValue?: TVal;
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;
@@ -1,79 +1,140 @@
1
- import { jsxs as w, jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as N, useState as D, useMemo as P, useRef as R, useCallback as b, useEffect as H } from "react";
3
- import x from "../box.mjs";
4
- import O from "./tooltip.mjs";
5
- import V from "./baseSvg.mjs";
6
- import { b as E } from "../core.mjs";
7
- import C from "./textbox.mjs";
8
- import F from "./flex.mjs";
9
- import I from "./button.mjs";
10
- function U(e, u) {
11
- var y;
12
- const { children: r, name: S, isSearchable: p, searchPlaceholder: T, onChange: f, selectedValue: k } = e, [l, g] = D(""), i = P(() => (Array.isArray(r) ? r : [r]).filter((a) => {
13
- var s;
14
- return ((s = a.type) == null ? void 0 : s.componentName) !== "DropdownItem" ? !1 : p && l ? j(a).toLowerCase().includes(l.toLowerCase()) : !0;
15
- }), [p, l, r]), [t, B] = D(
16
- i.find((o) => o.props.value === k) ?? (i == null ? void 0 : i[0])
17
- ), [c, m, M] = E(), d = R(null), A = b(() => {
18
- m((o) => !o);
19
- }, [m]), L = b((o) => {
20
- var a, s;
21
- B(o), m(!1), (s = (a = o.props).onClick) == null || s.call(a), f == null || f(o.props.value), setTimeout(() => {
22
- var h;
23
- return (h = d.current) == null ? void 0 : h.focus();
24
- }, 10);
25
- }, []);
26
- return H(() => {
27
- c ? setTimeout(() => {
28
- var o;
29
- return (o = d.current) == null ? void 0 : o.focus();
30
- }, 0) : g("");
31
- }, [c]), /* @__PURE__ */ w(x, { ref: M, width: "fit-content", userSelect: "none", children: [
32
- /* @__PURE__ */ n(C, { name: S, type: "hidden", value: (y = t == null ? void 0 : t.props) == null ? void 0 : y.toString() }),
33
- /* @__PURE__ */ w(I, { component: "dropdown", ...e, props: { onMouseDown: A, tabIndex: 0 }, children: [
34
- c && p ? /* @__PURE__ */ n(
35
- C,
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
- placeholder: T,
41
- value: l,
42
- onChange: (o) => g(o.target.value),
43
- ref: d,
67
+ minHeight: 5,
68
+ placeholder: C,
69
+ value: D,
70
+ onChange: (e) => M(e.target.value),
71
+ ref: N,
44
72
  props: {
45
- onMouseDown: (o) => {
46
- c && p && o.stopPropagation();
73
+ onMouseDown: (e) => {
74
+ m && d && e.stopPropagation();
47
75
  }
48
76
  }
49
77
  }
50
- ) : /* @__PURE__ */ n(F, { children: (t == null ? void 0 : t.props.children) ?? (t == null ? void 0 : t.props.value) }),
51
- /* @__PURE__ */ n(V, { viewBox: "0 0 10 6", width: "0.6rem", rotate: c ? 180 : 0, children: /* @__PURE__ */ n("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m1 1 4 4 4-4" }) })
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
- c && /* @__PURE__ */ n(O, { children: /* @__PURE__ */ w(x, { component: "dropdown.items", children: [
54
- i.map((o, a) => {
55
- var s;
56
- return /* @__PURE__ */ n(v, { ...o.props, onClick: () => L(o) }, (s = o.props.value) == null ? void 0 : s.toString());
57
- }),
58
- i.length === 0 && /* @__PURE__ */ n(x, { p: 2, color: "gray-500", userSelect: "none", props: { onMouseDown: (o) => o.stopPropagation() }, children: "No options" })
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 v(e) {
63
- return /* @__PURE__ */ n(I, { component: "dropdown.item", ...e, props: { onMouseDown: e.onClick } });
120
+ function b(s) {
121
+ const u = (r) => null;
122
+ return u.componentName = s, u;
64
123
  }
65
- v.componentName = "DropdownItem";
66
- const W = N(U);
67
- W.Item = v;
68
- function j(e) {
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 (e == null) return "";
71
- if (typeof e == "object") {
72
- const r = (u = e.props) == null ? void 0 : u.children;
73
- return r == null ? "" : typeof r == "object" ? (Array.isArray(r) ? r : [r]).map((p) => j(p)).join("") : r.toString();
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 e.toString();
136
+ return s.toString();
76
137
  }
77
138
  export {
78
- W as default
139
+ S as default
79
140
  };
@@ -1 +1 @@
1
- "use strict";const i=require("react/jsx-runtime"),v=require("react-dom"),d=require("../box.cjs"),s=require("react"),x=require("../core.cjs"),l=2;function b(f){const{onPositionChange:u}=f,c=s.useRef(null),[t,p]=s.useState(),w=x.usePortalContainer(),h=s.useCallback((n,e)=>{const r=o=>{o.target.contains(n)&&e(n)};return document.addEventListener("scroll",r,{capture:!0}),()=>{document.removeEventListener("scroll",r,{capture:!0})}},[t]),m=s.useCallback((n,e)=>{const r=o=>{e(n)};return window.addEventListener("resize",r,{capture:!0}),()=>{window.removeEventListener("resize",r,{capture:!0})}},[t]),a=s.useCallback(n=>{const e=n.getBoundingClientRect(),r=Math.round((e.top+window.scrollY)*l)/l,o=Math.round((e.left+window.scrollX)*l)/l;((t==null?void 0:t.top)!==r||(t==null?void 0:t.left)!==o)&&(u==null||u({top:r,left:o}),p({top:r,left:o,width:e.width>0?e.width:void 0}))},[t]);return s.useLayoutEffect(()=>{if(c.current){a(c.current);const n=h(c.current,a),e=m(c.current,a);return()=>{n(),e()}}},[t]),i.jsxs(i.Fragment,{children:[i.jsx(d,{ref:c}),t&&v.createPortal(i.jsx(d,{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})}),w)]})}module.exports=b;
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;
@@ -5,5 +5,5 @@ interface Props extends BoxProps {
5
5
  left: number;
6
6
  }): void;
7
7
  }
8
- export default function Tooltip(props: Props): import("react/jsx-runtime").JSX.Element;
9
- export {};
8
+ declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLDivElement>>;
9
+ export default _default;
@@ -1,11 +1,11 @@
1
- import { jsxs as v, Fragment as x, jsx as a } from "react/jsx-runtime";
2
- import { createPortal as b } from "react-dom";
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 E, useState as L, useCallback as d, useLayoutEffect as g } from "react";
5
- import { d as z } from "../core.mjs";
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 y(f) {
8
- const { onPositionChange: c } = f, s = E(null), [t, p] = L(), m = z(), w = d(
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
- ), h = d(
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 }), p({ top: r, left: n, width: e.width > 0 ? e.width : void 0 }));
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 g(() => {
35
+ return z(() => {
36
36
  if (s.current) {
37
37
  l(s.current);
38
- const o = w(s.current, l), e = h(s.current, l);
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__ */ v(x, { children: [
43
+ }, [t]), /* @__PURE__ */ x(b, { children: [
44
44
  /* @__PURE__ */ a(u, { ref: s }),
45
- t && b(
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
- m
58
+ w
58
59
  )
59
60
  ] });
60
61
  }
62
+ const M = L(D);
61
63
  export {
62
- y as default
64
+ M as default
63
65
  };
@@ -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";
@@ -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;