@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 +6 -0
- package/box.cjs +1 -1
- package/box.d.ts +3 -1
- package/box.mjs +16 -14
- package/components/dataGrid.cjs +1 -1
- package/components/dataGrid.mjs +11 -11
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.d.ts +16 -16
- package/components/dropdown.mjs +123 -89
- package/core/boxStyles.d.ts +23 -0
- package/core/theme/defaultTheme.d.ts +3 -0
- package/core/theme/theme.d.ts +13 -0
- package/core/theme/themeContext.d.ts +9 -0
- package/core/{theme.d.ts → theme/themeContract.d.ts} +9 -10
- package/core/theme/useTheme.d.ts +2 -0
- package/core.cjs +3 -3
- package/core.mjs +594 -530
- package/package.json +1 -1
- package/core/useTheme.d.ts +0 -8
package/array.d.ts
ADDED
package/box.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
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
|
|
2
|
-
import { B as S, T as
|
|
3
|
-
function
|
|
4
|
-
const { tag:
|
|
5
|
-
const P =
|
|
6
|
-
...
|
|
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
|
|
10
|
-
}, [
|
|
11
|
-
return
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
+
s as default
|
|
19
21
|
};
|
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
|
|
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;
|
package/components/dropdown.d.ts
CHANGED
|
@@ -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
|
-
|
|
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<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;
|
package/components/dropdown.mjs
CHANGED
|
@@ -1,106 +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
|
-
(o
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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:
|
|
63
|
+
display: m && d ? "block" : "none",
|
|
44
64
|
clean: !0,
|
|
45
65
|
flex1: !0,
|
|
46
66
|
width: 1,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
minHeight: 5,
|
|
68
|
+
placeholder: C,
|
|
69
|
+
value: D,
|
|
70
|
+
onChange: (e) => M(e.target.value),
|
|
71
|
+
ref: N,
|
|
51
72
|
props: {
|
|
52
|
-
onMouseDown: (
|
|
53
|
-
|
|
73
|
+
onMouseDown: (e) => {
|
|
74
|
+
m && d && e.stopPropagation();
|
|
54
75
|
}
|
|
55
76
|
}
|
|
56
77
|
}
|
|
57
78
|
),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
80
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
function
|
|
96
|
-
var
|
|
97
|
-
if (
|
|
98
|
-
if (typeof
|
|
99
|
-
const
|
|
100
|
-
return
|
|
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
|
|
136
|
+
return s.toString();
|
|
103
137
|
}
|
|
104
138
|
export {
|
|
105
|
-
|
|
139
|
+
S as default
|
|
106
140
|
};
|
package/core/boxStyles.d.ts
CHANGED
|
@@ -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,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 '
|
|
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
|
-
|
|
24
|
-
|
|
23
|
+
export interface Themes {
|
|
24
|
+
[name: string]: ThemeSetup;
|
|
25
25
|
}
|
|
26
|
-
export default Theme;
|