@cronocode/react-box 3.0.6 → 3.0.8

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 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;
1
+ "use strict";const t=require("react"),e=require("./core.cjs");function P(a,l){const{tag:c="div",children:n,props:m,className:p,style:i,disabled:x,required:B,checked:g,selected:h}=a,f=e.useStyles(a,c==="svg"),r=t.useMemo(()=>{const v=e.classNames(f,p).join(" "),s={...m,className:v};return e.BoxUtils.assignBooleanProp(x,"disabled",s),e.BoxUtils.assignBooleanProp(B,"required",s),e.BoxUtils.assignBooleanProp(g,"checked",s),e.BoxUtils.assignBooleanProp(h,"selected",s),i&&(s.style=i),l&&(s.ref=l),s},[a]),[T,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:T}):n)}const o=t.memo(t.forwardRef(P));o.extend=e.BoxExtends.extend;o.themeSetup=e.Theme.setup;o.Theme=e.Theme;o.useTheme=e.Theme.useTheme;o.getVariableValue=e.Variables.getVariableValue;module.exports=o;
package/box.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ClassNameType } from './core/classNames';
3
3
  import { ExtractElementFromTag } from './core/coreTypes';
4
4
  import { BoxStyleProps } from './types';
5
5
  import { default as BoxExtends } from './core/boxExtends';
6
- import { default as Theme } from './core/theme';
6
+ import { default as Theme } from './core/theme/theme';
7
7
  import { default as Variables } from './core/variables';
8
8
  type AllProps<TTag extends keyof React.JSX.IntrinsicElements> = React.ComponentProps<TTag>;
9
9
  type TagPropsType<TTag extends keyof React.JSX.IntrinsicElements> = Omit<AllProps<TTag>, 'className' | 'style' | 'ref' | 'disabled' | 'required' | 'checked'>;
@@ -21,6 +21,8 @@ interface BoxType {
21
21
  <TTag extends keyof React.JSX.IntrinsicElements = 'div'>(props: Props<TTag> & RefAttributes<ExtractElementFromTag<TTag>>): React.ReactNode;
22
22
  extend: typeof BoxExtends.extend;
23
23
  themeSetup: typeof Theme.setup;
24
+ Theme: typeof Theme;
25
+ useTheme: typeof Theme.useTheme;
24
26
  getVariableValue: typeof Variables.getVariableValue;
25
27
  }
26
28
  declare const Box: BoxType;
package/box.mjs CHANGED
@@ -1,19 +1,21 @@
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
- ...d,
1
+ import T, { memo as V, forwardRef as b, useMemo as y, useState as N } from "react";
2
+ import { B as S, T as r, V as C, u as E, c as H, a } from "./core.mjs";
3
+ function M(o, l) {
4
+ const { tag: c = "div", children: t, props: m, className: p, style: i, disabled: f, required: g, checked: B, selected: h } = o, x = E(o, c === "svg"), n = y(() => {
5
+ const P = H(x, p).join(" "), e = {
6
+ ...m,
7
7
  className: P
8
8
  };
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);
9
+ return a.assignBooleanProp(f, "disabled", e), a.assignBooleanProp(g, "required", e), a.assignBooleanProp(B, "checked", e), a.assignBooleanProp(h, "selected", e), i && (e.style = i), l && (e.ref = l), e;
10
+ }, [o]), [v, u] = N(!1), d = typeof t == "function";
11
+ return d && (n.onMouseEnter = () => u(!0), n.onMouseLeave = () => u(!1)), T.createElement(c, n, d ? t({ isHover: v }) : t);
12
12
  }
13
- const n = b(h(T));
14
- n.extend = S.extend;
15
- n.themeSetup = C.setup;
16
- n.getVariableValue = E.getVariableValue;
13
+ const s = V(b(M));
14
+ s.extend = S.extend;
15
+ s.themeSetup = r.setup;
16
+ s.Theme = r;
17
+ s.useTheme = r.useTheme;
18
+ s.getVariableValue = C.getVariableValue;
17
19
  export {
18
- n as default
20
+ s as default
19
21
  };
@@ -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 t=require("react/jsx-runtime"),c=require("react"),h=require("../box.cjs"),O=require("./tooltip.cjs"),P=require("./baseSvg.cjs"),E=require("../core.cjs"),A=require("./textbox.cjs"),U=require("./flex.cjs"),y=require("./button.cjs");function W(n,m){var g;const{children:o,name:N,isSearchable:p,searchPlaceholder:L,onChange:x,selectedValue:T}=n,[a,b]=c.useState(""),f=c.useMemo(()=>(Array.isArray(o)?o:[o]).filter(s=>{var r;return((r=s.type)==null?void 0:r.componentName)!=="DropdownItem"?!1:p&&a?_(s).toLowerCase().includes(a.toLowerCase()):!0}),[p,a,o]),l=c.useMemo(()=>(Array.isArray(o)?o:[o]).find(s=>{var r;return((r=s.type)==null?void 0:r.componentName)==="DropdownNullItem"}),[p,a,o]),v=c.useMemo(()=>(Array.isArray(o)?o:[o]).find(s=>{var r;return((r=s.type)==null?void 0:r.componentName)==="DropdownNoItems"}),[p,a,o]),[u,B]=c.useState(f.find(e=>e.props.value===T)),[i,j,V]=E.useVisibility(),k=c.useRef(null),C=c.useRef(null),q=c.useRef(null),H=c.useCallback(()=>{j(e=>!e)},[j]),S=c.useCallback((e,s)=>{var r,d;B(s),j(!1),(d=(r=s.props).onClick)==null||d.call(r,e),x==null||x(s.props.value),setTimeout(()=>{var R;return(R=C.current)==null?void 0:R.focus()},0)},[]);return c.useEffect(()=>{i?setTimeout(()=>{var e,s,r;(e=k.current)==null||e.focus(),(r=(s=q.current)==null?void 0:s.querySelector('[aria-selected="true"]'))==null||r.scrollIntoView({block:"nearest"})},0):b("")},[i]),t.jsxs(h,{ref:V,width:"fit-content",children:[t.jsx(A,{ref:m,name:N,type:"hidden",value:((g=u==null?void 0:u.props)==null?void 0:g.value)??""}),t.jsxs(y,{ref:C,component:"dropdown",...n,props:{onMouseDown:H},children:[p&&t.jsx(A,{display:i&&p?"block":"none",clean:!0,flex1:!0,width:1,placeholder:L,value:a,onChange:e=>b(e.target.value),ref:k,props:{onMouseDown:e=>{i&&p&&e.stopPropagation()}}}),t.jsx(U,{display:i&&p?"none":"flex",children:(u==null?void 0:u.props.children)??(u==null?void 0:u.props.value)??(l==null?void 0:l.props.children)??t.jsx(h,{height:5})}),t.jsx(P,{viewBox:"0 0 10 6",width:"0.6rem",rotate:i?180:0,children:t.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 4 4 4-4"})})]}),i&&t.jsx(O,{ref:q,children:(f.length>0||l||v)&&t.jsxs(h,{component:"dropdown.items",children:[l&&t.jsx(D,{...l.props,selected:!u,onClick:e=>S(e,l)}),f.map((e,s)=>{var r;return t.jsx(I,{...e.props,selected:e===u,onClick:d=>S(d,e)},(r=e.props.value)==null?void 0:r.toString())}),f.length===0&&!l&&v]})})]})}function I(n){return t.jsx(y,{component:"dropdown.item",...n,props:{onMouseDown:n.onClick}})}I.componentName="DropdownItem";function D(n){return t.jsx(y,{component:"dropdown.nullItem",...n,props:{onMouseDown:n.onClick}})}D.componentName="DropdownNullItem";function M(n){return t.jsx(h,{component:"dropdown.noItems",...n})}M.componentName="DropdownNoItems";const w=c.forwardRef(W);w.Item=I;w.NullItem=D;w.NoItems=M;function _(n){var m;if(n==null)return"";if(typeof n=="object"){const o=(m=n.props)==null?void 0:m.children;return o==null?"":typeof o=="object"?(Array.isArray(o)?o:[o]).map(p=>_(p)).join(""):o.toString()}return n.toString()}module.exports=w;
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,{component:"dropdown.display",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,25 +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?: (e: React.MouseEvent) => 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<HTMLInputElement>): React.ReactNode;
16
- declare function DropdownItem<TVal>(props: DropdownItemProps<TVal>): import("react/jsx-runtime").JSX.Element;
17
- declare function DropdownNullItem<TVal>(props: Omit<DropdownItemProps<TVal>, 'value'>): import("react/jsx-runtime").JSX.Element;
18
- declare function DropdownNoItems<TVal>(props: Omit<DropdownItemProps<TVal>, 'value'>): import("react/jsx-runtime").JSX.Element;
19
- type DropdownType = typeof DropdownImpl & {
20
- Item: typeof DropdownItem;
21
- NullItem: typeof DropdownNullItem;
22
- NoItems: typeof DropdownNoItems;
23
- };
24
24
  declare const Dropdown: DropdownType;
25
25
  export default Dropdown;
@@ -1,106 +1,140 @@
1
- import { jsxs as y, jsx as s } from "react/jsx-runtime";
2
- import { forwardRef as W, useState as R, useMemo as I, useRef as D, useCallback as L, useEffect as z } from "react";
3
- import f from "../box.mjs";
4
- import G from "./tooltip.mjs";
5
- import J from "./baseSvg.mjs";
6
- import { b as Q } from "../core.mjs";
7
- import V from "./textbox.mjs";
8
- import X from "./flex.mjs";
9
- import x from "./button.mjs";
10
- function Y(n, m) {
11
- var T;
12
- const { children: e, name: C, isSearchable: c, searchPlaceholder: P, onChange: h, selectedValue: q } = n, [a, b] = R(""), d = I(() => (Array.isArray(e) ? e : [e]).filter((t) => {
13
- var r;
14
- return ((r = t.type) == null ? void 0 : r.componentName) !== "DropdownItem" ? !1 : c && a ? O(t).toLowerCase().includes(a.toLowerCase()) : !0;
15
- }), [c, a, e]), l = I(() => (Array.isArray(e) ? e : [e]).find((t) => {
16
- var r;
17
- return ((r = t.type) == null ? void 0 : r.componentName) === "DropdownNullItem";
18
- }), [c, a, e]), g = I(() => (Array.isArray(e) ? e : [e]).find((t) => {
19
- var r;
20
- return ((r = t.type) == null ? void 0 : r.componentName) === "DropdownNoItems";
21
- }), [c, a, e]), [p, E] = R(
22
- d.find((o) => o.props.value === q)
23
- ), [i, w, F] = Q(), S = D(null), A = D(null), j = D(null), U = L(() => {
24
- w((o) => !o);
25
- }, [w]), B = L((o, t) => {
26
- var r, u;
27
- E(t), w(!1), (u = (r = t.props).onClick) == null || u.call(r, o), h == null || h(t.props.value), setTimeout(() => {
28
- var M;
29
- return (M = A.current) == null ? void 0 : M.focus();
30
- }, 0);
31
- }, []);
32
- return z(() => {
33
- i ? setTimeout(() => {
34
- var o, t, r;
35
- (o = S.current) == null || o.focus(), (r = (t = j.current) == null ? void 0 : t.querySelector('[aria-selected="true"]')) == null || r.scrollIntoView({ block: "nearest" });
36
- }, 0) : b("");
37
- }, [i]), /* @__PURE__ */ y(f, { ref: F, width: "fit-content", children: [
38
- /* @__PURE__ */ s(V, { ref: m, name: C, type: "hidden", value: ((T = p == null ? void 0 : p.props) == null ? void 0 : T.value) ?? "" }),
39
- /* @__PURE__ */ y(x, { ref: A, component: "dropdown", ...n, props: { onMouseDown: U }, children: [
40
- c && /* @__PURE__ */ s(
41
- V,
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,
42
62
  {
43
- display: i && c ? "block" : "none",
63
+ display: m && d ? "block" : "none",
44
64
  clean: !0,
45
65
  flex1: !0,
46
66
  width: 1,
47
- placeholder: P,
48
- value: a,
49
- onChange: (o) => b(o.target.value),
50
- ref: S,
67
+ minHeight: 5,
68
+ placeholder: C,
69
+ value: D,
70
+ onChange: (e) => M(e.target.value),
71
+ ref: N,
51
72
  props: {
52
- onMouseDown: (o) => {
53
- i && c && o.stopPropagation();
73
+ onMouseDown: (e) => {
74
+ m && d && e.stopPropagation();
54
75
  }
55
76
  }
56
77
  }
57
78
  ),
58
- /* @__PURE__ */ s(X, { display: i && c ? "none" : "flex", children: (p == null ? void 0 : p.props.children) ?? (p == null ? void 0 : p.props.value) ?? (l == null ? void 0 : l.props.children) ?? /* @__PURE__ */ s(f, { height: 5 }) }),
59
- /* @__PURE__ */ s(J, { viewBox: "0 0 10 6", width: "0.6rem", rotate: i ? 180 : 0, children: /* @__PURE__ */ s("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m1 1 4 4 4-4" }) })
79
+ /* @__PURE__ */ n($, { component: "dropdown.display", 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" }) }) })
60
81
  ] }),
61
- i && /* @__PURE__ */ s(G, { ref: j, children: (d.length > 0 || l || g) && /* @__PURE__ */ y(f, { component: "dropdown.items", children: [
62
- l && /* @__PURE__ */ s(v, { ...l.props, selected: !p, onClick: (o) => B(o, l) }),
63
- d.map((o, t) => {
64
- var r;
65
- return /* @__PURE__ */ s(
66
- N,
67
- {
68
- ...o.props,
69
- selected: o === p,
70
- onClick: (u) => B(u, o)
71
- },
72
- (r = o.props.value) == null ? void 0 : r.toString()
73
- );
74
- }),
75
- d.length === 0 && !l && g
76
- ] }) })
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
+ )
77
118
  ] });
78
119
  }
79
- function N(n) {
80
- return /* @__PURE__ */ s(x, { component: "dropdown.item", ...n, props: { onMouseDown: n.onClick } });
81
- }
82
- N.componentName = "DropdownItem";
83
- function v(n) {
84
- return /* @__PURE__ */ s(x, { component: "dropdown.nullItem", ...n, props: { onMouseDown: n.onClick } });
85
- }
86
- v.componentName = "DropdownNullItem";
87
- function H(n) {
88
- return /* @__PURE__ */ s(f, { component: "dropdown.noItems", ...n });
120
+ function b(s) {
121
+ const u = (r) => null;
122
+ return u.componentName = s, u;
89
123
  }
90
- H.componentName = "DropdownNoItems";
91
- const k = W(Y);
92
- k.Item = N;
93
- k.NullItem = v;
94
- k.NoItems = H;
95
- function O(n) {
96
- var m;
97
- if (n == null) return "";
98
- if (typeof n == "object") {
99
- const e = (m = n.props) == null ? void 0 : m.children;
100
- return e == null ? "" : typeof e == "object" ? (Array.isArray(e) ? e : [e]).map((c) => O(c)).join("") : e.toString();
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) {
130
+ var u;
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();
101
135
  }
102
- return n.toString();
136
+ return s.toString();
103
137
  }
104
138
  export {
105
- k as default
139
+ S as default
106
140
  };
@@ -701,11 +701,29 @@ 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;
707
715
  styleName: string;
708
716
  }[];
717
+ shadow: {
718
+ values: readonly ["small-shadow", "medium-shadow", "large-shadow"];
719
+ valueFormat: (value: string, getVariableValue: (name: string) => string) => string;
720
+ styleName: string;
721
+ }[];
722
+ translateX: {
723
+ values: number;
724
+ valueFormat: (value: number) => string;
725
+ styleName: string;
726
+ }[];
709
727
  };
710
728
  export declare const pseudo1: {
711
729
  hover: string;
@@ -758,9 +776,14 @@ export declare const pseudoGroupClasses: {
758
776
  disabledGroup: "disabled";
759
777
  };
760
778
  export declare const breakpoints: {
779
+ /** Styles applied for small screens and larger. >= 640 */
761
780
  sm: number;
781
+ /** Styles applied for medium screens and larger. >= 768 */
762
782
  md: number;
783
+ /** Styles applied for large screens and larger. >= 1024 */
763
784
  lg: number;
785
+ /** Styles applied for extra-large screens and larger. >= 1280 */
764
786
  xl: number;
787
+ /** Styles applied for 2x extra-large screens and larger. >= 1536 */
765
788
  xxl: number;
766
789
  };
@@ -0,0 +1,3 @@
1
+ import { ThemeSetup } from './themeContract';
2
+ declare const defaultTheme: ThemeSetup;
3
+ export default defaultTheme;
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ import { Themes } from './themeContract';
3
+ interface ThemeProps {
4
+ children: React.ReactNode;
5
+ theme: string;
6
+ }
7
+ declare function Theme(props: ThemeProps): import("react/jsx-runtime").JSX.Element;
8
+ declare namespace Theme {
9
+ let userThemes: Maybe<Themes>;
10
+ function setup(themes: Themes): void;
11
+ function useTheme(): [string, (theme: string) => void];
12
+ }
13
+ export default Theme;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { ThemeType } from './themeContract';
3
+ interface IThemeContext {
4
+ themeStyles: ThemeType;
5
+ theme: string;
6
+ setTheme(theme: string): void;
7
+ }
8
+ declare const ThemeContext: React.Context<IThemeContext>;
9
+ export default ThemeContext;
@@ -1,17 +1,17 @@
1
- import { BoxThemeStyles } from '../types';
1
+ import { BoxThemeStyles } from '../../types';
2
2
  export interface ThemeComponentStyles {
3
+ clean?: boolean;
3
4
  styles: BoxThemeStyles;
4
5
  themes?: {
5
6
  [name: string]: BoxThemeStyles;
6
7
  };
7
- children?: {
8
- [name: string]: ThemeComponentStyles;
9
- };
8
+ children?: ThemeType;
10
9
  }
10
+ export type ThemeType = {
11
+ [componentName: string]: ThemeComponentStyles;
12
+ };
11
13
  export interface ThemeSetup {
12
- components?: {
13
- [name: string]: ThemeComponentStyles;
14
- };
14
+ components?: ThemeType;
15
15
  button?: ThemeComponentStyles;
16
16
  textbox?: ThemeComponentStyles;
17
17
  textarea?: ThemeComponentStyles;
@@ -20,7 +20,6 @@ export interface ThemeSetup {
20
20
  label?: ThemeComponentStyles;
21
21
  dropdown?: ThemeComponentStyles;
22
22
  }
23
- declare namespace Theme {
24
- function setup(styles: ThemeSetup): void;
23
+ export interface Themes {
24
+ [name: string]: ThemeSetup;
25
25
  }
26
- export default Theme;
@@ -0,0 +1,2 @@
1
+ import { BoxThemeStyles, ThemeProps } from '../../types';
2
+ export default function useTheme(props: ThemeProps): BoxThemeStyles | undefined;