asterui 0.12.8 → 0.12.10

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.
@@ -2,8 +2,10 @@ import { default as React } from 'react';
2
2
  export interface HeroProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  children: React.ReactNode;
4
4
  overlay?: boolean;
5
- overlayClassName?: string;
6
5
  contentClassName?: string;
7
- wrapperClassName?: string;
8
6
  }
9
- export declare function Hero({ children, overlay, overlayClassName, contentClassName, wrapperClassName, className, style, ...rest }: HeroProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Hero({ children, overlay, contentClassName, className, ...rest }: HeroProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare namespace Hero {
9
+ var displayName: string;
10
+ }
11
+ export default Hero;
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  export interface JoinProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  children: React.ReactNode;
4
- vertical?: boolean;
4
+ direction?: 'horizontal' | 'vertical';
5
5
  }
6
- export declare function Join({ children, vertical, className, ...rest }: JoinProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function Join({ children, direction, className, ...rest }: JoinProps): import("react/jsx-runtime").JSX.Element;
@@ -46,7 +46,7 @@ declare namespace LayoutRoot {
46
46
  declare function LayoutHeader({ children, className, style }: LayoutHeaderProps): import("react/jsx-runtime").JSX.Element;
47
47
  declare function LayoutFooter({ children, className, style }: LayoutFooterProps): import("react/jsx-runtime").JSX.Element;
48
48
  declare function LayoutContent({ children, className, style }: LayoutContentProps): import("react/jsx-runtime").JSX.Element;
49
- declare function LayoutSider({ children, width, collapsedWidth, collapsed: controlledCollapsed, defaultCollapsed, collapsible, onCollapse, trigger, className, style, }: LayoutSiderProps): import("react/jsx-runtime").JSX.Element;
49
+ declare function LayoutSider({ children, width, collapsedWidth, collapsed: controlledCollapsed, defaultCollapsed, collapsible, onCollapse, trigger, breakpoint, onBreakpoint, className, style, }: LayoutSiderProps): import("react/jsx-runtime").JSX.Element;
50
50
  declare namespace LayoutSider {
51
51
  var displayName: string;
52
52
  }
@@ -9,7 +9,7 @@ export interface MasonryProps extends React.HTMLAttributes<HTMLDivElement> {
9
9
  xl?: number;
10
10
  '2xl'?: number;
11
11
  };
12
- gap?: number | string;
12
+ gap?: number;
13
13
  }
14
14
  export declare const Masonry: React.FC<MasonryProps>;
15
15
  export default Masonry;
package/dist/index35.js CHANGED
@@ -1,21 +1,20 @@
1
- import { jsxs as v, jsx as e } from "react/jsx-runtime";
2
- function h({
1
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
+ function c({
3
3
  children: o,
4
- overlay: n = !1,
5
- overlayClassName: l = "",
4
+ overlay: s = !1,
6
5
  contentClassName: a = "",
7
- wrapperClassName: s,
8
- className: i = "",
9
- style: r,
10
- ...t
6
+ className: r = "",
7
+ ...l
11
8
  }) {
12
- const c = ["hero", "min-h-screen", i].filter(Boolean).join(" "), f = ["hero-content", a].filter(Boolean).join(" "), m = ["hero-overlay", l].filter(Boolean).join(" ");
13
- return /* @__PURE__ */ v("div", { className: c, style: r, ...t, children: [
14
- n && /* @__PURE__ */ e("div", { className: m }),
15
- /* @__PURE__ */ e("div", { className: f, children: s ? /* @__PURE__ */ e("div", { className: s, children: o }) : o })
9
+ const n = ["hero", r].filter(Boolean).join(" "), t = ["hero-content", a].filter(Boolean).join(" ");
10
+ return /* @__PURE__ */ i("div", { className: n, ...l, children: [
11
+ s && /* @__PURE__ */ e("div", { className: "hero-overlay bg-opacity-60" }),
12
+ /* @__PURE__ */ e("div", { className: t, children: o })
16
13
  ] });
17
14
  }
15
+ c.displayName = "Hero";
18
16
  export {
19
- h as Hero
17
+ c as Hero,
18
+ c as default
20
19
  };
21
20
  //# sourceMappingURL=index35.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index35.js","sources":["../src/components/Hero.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface HeroProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n overlay?: boolean\n overlayClassName?: string\n contentClassName?: string\n wrapperClassName?: string\n}\n\nexport function Hero({\n children,\n overlay = false,\n overlayClassName = '',\n contentClassName = '',\n wrapperClassName,\n className = '',\n style,\n ...rest\n}: HeroProps) {\n const classes = ['hero', 'min-h-screen', className].filter(Boolean).join(' ')\n const contentClasses = ['hero-content', contentClassName].filter(Boolean).join(' ')\n const overlayClasses = ['hero-overlay', overlayClassName].filter(Boolean).join(' ')\n\n return (\n <div className={classes} style={style} {...rest}>\n {overlay && <div className={overlayClasses} />}\n <div className={contentClasses}>\n {wrapperClassName ? <div className={wrapperClassName}>{children}</div> : children}\n </div>\n </div>\n )\n}\n"],"names":["Hero","children","overlay","overlayClassName","contentClassName","wrapperClassName","className","style","rest","classes","contentClasses","overlayClasses","jsx"],"mappings":";AAUO,SAASA,EAAK;AAAA,EACnB,UAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,kBAAAC,IAAmB;AAAA,EACnB,kBAAAC,IAAmB;AAAA,EACnB,kBAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,GAAGC;AACL,GAAc;AACZ,QAAMC,IAAU,CAAC,QAAQ,gBAAgBH,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GACtEI,IAAiB,CAAC,gBAAgBN,CAAgB,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAC5EO,IAAiB,CAAC,gBAAgBR,CAAgB,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAElF,2BACG,OAAA,EAAI,WAAWM,GAAS,OAAAF,GAAe,GAAGC,GACxC,UAAA;AAAA,IAAAN,KAAW,gBAAAU,EAAC,OAAA,EAAI,WAAWD,EAAA,CAAgB;AAAA,IAC5C,gBAAAC,EAAC,OAAA,EAAI,WAAWF,GACb,UAAAL,IAAmB,gBAAAO,EAAC,OAAA,EAAI,WAAWP,GAAmB,UAAAJ,EAAA,CAAS,IAASA,EAAA,CAC3E;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"index35.js","sources":["../src/components/Hero.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface HeroProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n overlay?: boolean\n contentClassName?: string\n}\n\nexport function Hero({\n children,\n overlay = false,\n contentClassName = '',\n className = '',\n ...rest\n}: HeroProps) {\n const heroClasses = ['hero', className].filter(Boolean).join(' ')\n const contentClasses = ['hero-content', contentClassName].filter(Boolean).join(' ')\n\n return (\n <div className={heroClasses} {...rest}>\n {overlay && <div className=\"hero-overlay bg-opacity-60\" />}\n <div className={contentClasses}>{children}</div>\n </div>\n )\n}\n\nHero.displayName = 'Hero'\n\nexport default Hero\n"],"names":["Hero","children","overlay","contentClassName","className","rest","heroClasses","contentClasses","jsxs","jsx"],"mappings":";AAQO,SAASA,EAAK;AAAA,EACnB,UAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,kBAAAC,IAAmB;AAAA,EACnB,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,GAAc;AACZ,QAAMC,IAAc,CAAC,QAAQF,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAC1DG,IAAiB,CAAC,gBAAgBJ,CAAgB,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAElF,SACE,gBAAAK,EAAC,OAAA,EAAI,WAAWF,GAAc,GAAGD,GAC9B,UAAA;AAAA,IAAAH,KAAW,gBAAAO,EAAC,OAAA,EAAI,WAAU,6BAAA,CAA6B;AAAA,IACxD,gBAAAA,EAAC,OAAA,EAAI,WAAWF,GAAiB,UAAAN,EAAA,CAAS;AAAA,EAAA,GAC5C;AAEJ;AAEAD,EAAK,cAAc;"}
package/dist/index42.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import n from "react";
3
- function p({ children: i, vertical: o = !1, className: t = "", ...a }) {
4
- const r = ["join", o && "join-vertical", t].filter(Boolean).join(" "), m = n.Children.map(i, (e) => {
3
+ function f({ children: o, direction: t = "horizontal", className: s = "", ...r }) {
4
+ const a = ["join", t === "vertical" && "join-vertical", s].filter(Boolean).join(" "), l = n.Children.map(o, (e) => {
5
5
  if (n.isValidElement(e)) {
6
- const s = e.props.className || "", l = s ? `join-item ${s}` : "join-item";
6
+ const i = e.props.className || "", m = i ? `join-item ${i}` : "join-item";
7
7
  return n.cloneElement(e, {
8
- className: l
8
+ className: m
9
9
  });
10
10
  }
11
11
  return e;
12
12
  });
13
- return /* @__PURE__ */ c("div", { className: r, ...a, children: m });
13
+ return /* @__PURE__ */ c("div", { className: a, ...r, children: l });
14
14
  }
15
15
  export {
16
- p as Join
16
+ f as Join
17
17
  };
18
18
  //# sourceMappingURL=index42.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index42.js","sources":["../src/components/Join.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface JoinProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n vertical?: boolean\n}\n\nexport function Join({ children, vertical = false, className = '', ...rest }: JoinProps) {\n const classes = ['join', vertical && 'join-vertical', className].filter(Boolean).join(' ')\n\n // Automatically add join-item class to all children\n const childrenWithJoinItem = React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n const existingClassName = (child.props as any).className || ''\n const newClassName = existingClassName ? `join-item ${existingClassName}` : 'join-item'\n\n return React.cloneElement(child as React.ReactElement<any>, {\n className: newClassName,\n })\n }\n return child\n })\n\n return <div className={classes} {...rest}>{childrenWithJoinItem}</div>\n}\n"],"names":["Join","children","vertical","className","rest","classes","childrenWithJoinItem","React","child","existingClassName","newClassName"],"mappings":";;AAOO,SAASA,EAAK,EAAE,UAAAC,GAAU,UAAAC,IAAW,IAAO,WAAAC,IAAY,IAAI,GAAGC,KAAmB;AACvF,QAAMC,IAAU,CAAC,QAAQH,KAAY,iBAAiBC,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAGnFG,IAAuBC,EAAM,SAAS,IAAIN,GAAU,CAACO,MAAU;AACnE,QAAID,EAAM,eAAeC,CAAK,GAAG;AAC/B,YAAMC,IAAqBD,EAAM,MAAc,aAAa,IACtDE,IAAeD,IAAoB,aAAaA,CAAiB,KAAK;AAE5E,aAAOF,EAAM,aAAaC,GAAkC;AAAA,QAC1D,WAAWE;AAAA,MAAA,CACZ;AAAA,IACH;AACA,WAAOF;AAAA,EACT,CAAC;AAED,2BAAQ,OAAA,EAAI,WAAWH,GAAU,GAAGD,GAAO,UAAAE,GAAqB;AAClE;"}
1
+ {"version":3,"file":"index42.js","sources":["../src/components/Join.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface JoinProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n direction?: 'horizontal' | 'vertical'\n}\n\nexport function Join({ children, direction = 'horizontal', className = '', ...rest }: JoinProps) {\n const classes = ['join', direction === 'vertical' && 'join-vertical', className].filter(Boolean).join(' ')\n\n // Automatically add join-item class to all children\n const childrenWithJoinItem = React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n const existingClassName = (child.props as any).className || ''\n const newClassName = existingClassName ? `join-item ${existingClassName}` : 'join-item'\n\n return React.cloneElement(child as React.ReactElement<any>, {\n className: newClassName,\n })\n }\n return child\n })\n\n return <div className={classes} {...rest}>{childrenWithJoinItem}</div>\n}\n"],"names":["Join","children","direction","className","rest","classes","childrenWithJoinItem","React","child","existingClassName","newClassName"],"mappings":";;AAOO,SAASA,EAAK,EAAE,UAAAC,GAAU,WAAAC,IAAY,cAAc,WAAAC,IAAY,IAAI,GAAGC,KAAmB;AAC/F,QAAMC,IAAU,CAAC,QAAQH,MAAc,cAAc,iBAAiBC,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAGnGG,IAAuBC,EAAM,SAAS,IAAIN,GAAU,CAACO,MAAU;AACnE,QAAID,EAAM,eAAeC,CAAK,GAAG;AAC/B,YAAMC,IAAqBD,EAAM,MAAc,aAAa,IACtDE,IAAeD,IAAoB,aAAaA,CAAiB,KAAK;AAE5E,aAAOF,EAAM,aAAaC,GAAkC;AAAA,QAC1D,WAAWE;AAAA,MAAA,CACZ;AAAA,IACH;AACA,WAAOF;AAAA,EACT,CAAC;AAED,2BAAQ,OAAA,EAAI,WAAWH,GAAU,GAAGD,GAAO,UAAAE,GAAqB;AAClE;"}
package/dist/index45.js CHANGED
@@ -1,122 +1,140 @@
1
- import { jsx as a, jsxs as v } from "react/jsx-runtime";
2
- import u, { useContext as k, createContext as S, useState as w, useCallback as g } from "react";
3
- const p = S(null);
4
- function F() {
5
- return k(p);
1
+ import { jsx as o, jsxs as A } from "react/jsx-runtime";
2
+ import d, { useContext as M, createContext as P, useState as C, useEffect as $, useCallback as F } from "react";
3
+ const L = P(null);
4
+ function Q() {
5
+ return M(L);
6
6
  }
7
- function m({ children: o, className: n = "", style: s }) {
8
- const t = u.Children.toArray(o), l = t.some(
9
- (e) => u.isValidElement(e) && e.type.displayName === "LayoutSider"
10
- ), f = [
7
+ function h({ children: n, className: s = "", style: a }) {
8
+ const e = d.Children.toArray(n), f = e.some(
9
+ (t) => d.isValidElement(t) && t.type.displayName === "LayoutSider"
10
+ ), m = [
11
11
  "flex",
12
12
  "min-h-0",
13
- l ? "flex-row" : "flex-col",
14
- n
15
- ].filter(Boolean).join(" "), i = l ? t.map((e) => {
16
- if (u.isValidElement(e) && (e.type === m || e.type.displayName === "LayoutRoot") && e.type.displayName !== "LayoutSider") {
17
- const c = e.props.className || "";
18
- if (!c.includes("flex-1"))
19
- return u.cloneElement(e, {
20
- className: `flex-1 ${c}`.trim()
13
+ f ? "flex-row" : "flex-col",
14
+ s
15
+ ].filter(Boolean).join(" "), r = f ? e.map((t) => {
16
+ if (d.isValidElement(t) && (t.type === h || t.type.displayName === "LayoutRoot") && t.type.displayName !== "LayoutSider") {
17
+ const i = t.props.className || "";
18
+ if (!i.includes("flex-1"))
19
+ return d.cloneElement(t, {
20
+ className: `flex-1 ${i}`.trim()
21
21
  });
22
22
  }
23
- return e;
24
- }) : o;
25
- return /* @__PURE__ */ a("div", { className: f, style: s, children: i });
23
+ return t;
24
+ }) : n;
25
+ return /* @__PURE__ */ o("div", { className: m, style: a, children: r });
26
26
  }
27
- m.displayName = "LayoutRoot";
28
- function B({ children: o, className: n = "", style: s }) {
29
- const t = [
27
+ h.displayName = "LayoutRoot";
28
+ function H({ children: n, className: s = "", style: a }) {
29
+ const e = [
30
30
  "flex",
31
31
  "items-center",
32
32
  "px-6",
33
33
  "h-16",
34
34
  "bg-base-300",
35
35
  "flex-shrink-0",
36
- n
36
+ s
37
37
  ].filter(Boolean).join(" ");
38
- return /* @__PURE__ */ a("header", { className: t, style: s, children: o });
38
+ return /* @__PURE__ */ o("header", { className: e, style: a, children: n });
39
39
  }
40
- function E({ children: o, className: n = "", style: s }) {
41
- const t = [
40
+ function I({ children: n, className: s = "", style: a }) {
41
+ const e = [
42
42
  "px-6",
43
43
  "py-4",
44
44
  "text-center",
45
45
  "bg-base-300",
46
46
  "flex-shrink-0",
47
- n
47
+ s
48
48
  ].filter(Boolean).join(" ");
49
- return /* @__PURE__ */ a("footer", { className: t, style: s, children: o });
49
+ return /* @__PURE__ */ o("footer", { className: e, style: a, children: n });
50
50
  }
51
- function R({ children: o, className: n = "", style: s }) {
52
- const t = ["flex-1", "min-h-0", "overflow-auto", n].filter(Boolean).join(" ");
53
- return /* @__PURE__ */ a("main", { className: t, style: s, children: o });
51
+ function O({ children: n, className: s = "", style: a }) {
52
+ const e = ["flex-1", "min-h-0", "overflow-auto", s].filter(Boolean).join(" ");
53
+ return /* @__PURE__ */ o("main", { className: e, style: a, children: n });
54
54
  }
55
- function y({
56
- children: o,
57
- width: n = 200,
58
- collapsedWidth: s = 80,
59
- collapsed: t,
60
- defaultCollapsed: l = !1,
61
- collapsible: f = !1,
62
- onCollapse: i,
63
- trigger: e,
64
- className: c = "",
65
- style: C
55
+ const T = {
56
+ sm: "(max-width: 639px)",
57
+ md: "(max-width: 767px)",
58
+ lg: "(max-width: 1023px)",
59
+ xl: "(max-width: 1279px)",
60
+ "2xl": "(max-width: 1535px)"
61
+ };
62
+ function v({
63
+ children: n,
64
+ width: s = 200,
65
+ collapsedWidth: a = 80,
66
+ collapsed: e,
67
+ defaultCollapsed: f = !1,
68
+ collapsible: m = !1,
69
+ onCollapse: r,
70
+ trigger: t,
71
+ breakpoint: i,
72
+ onBreakpoint: p,
73
+ className: w = "",
74
+ style: g
66
75
  }) {
67
- const [b, N] = w(l), r = t ?? b, h = g(() => {
68
- const x = !r;
69
- t === void 0 && N(x), i?.(x);
70
- }, [r, t, i]), d = r ? s : n, L = [
76
+ const [j, N] = C(f), [b, k] = C(!1), l = e ?? j;
77
+ $(() => {
78
+ if (!i) return;
79
+ const c = window.matchMedia(T[i]), y = (R) => {
80
+ const u = R.matches;
81
+ k(u), p?.(u), e === void 0 && N(u), u !== b && r?.(u);
82
+ };
83
+ return y(c), c.addEventListener("change", y), () => c.removeEventListener("change", y);
84
+ }, [i, p, e, r, b]);
85
+ const S = F(() => {
86
+ const c = !l;
87
+ e === void 0 && N(c), r?.(c);
88
+ }, [l, e, r]), x = l ? a : s, B = [
71
89
  "flex",
72
90
  "flex-col",
73
91
  "bg-base-200",
74
92
  "flex-shrink-0",
75
93
  "transition-all",
76
94
  "duration-200",
77
- c
78
- ].filter(Boolean).join(" "), j = f && e !== null && /* @__PURE__ */ a(
95
+ w
96
+ ].filter(Boolean).join(" "), E = m && t !== null && /* @__PURE__ */ o(
79
97
  "button",
80
98
  {
81
- onClick: h,
99
+ onClick: S,
82
100
  className: "flex items-center justify-center h-10 w-full bg-base-300 hover:bg-base-content/10 transition-colors",
83
- "aria-label": r ? "Expand sidebar" : "Collapse sidebar",
84
- children: /* @__PURE__ */ a(
101
+ "aria-label": l ? "Expand sidebar" : "Collapse sidebar",
102
+ children: /* @__PURE__ */ o(
85
103
  "svg",
86
104
  {
87
- className: `w-4 h-4 transition-transform ${r ? "rotate-180" : ""}`,
105
+ className: `w-4 h-4 transition-transform ${l ? "rotate-180" : ""}`,
88
106
  fill: "none",
89
107
  viewBox: "0 0 24 24",
90
108
  stroke: "currentColor",
91
- children: /* @__PURE__ */ a("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" })
109
+ children: /* @__PURE__ */ o("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" })
92
110
  }
93
111
  )
94
112
  }
95
113
  );
96
- return /* @__PURE__ */ a(p.Provider, { value: { collapsed: r, collapsedWidth: s, width: n }, children: /* @__PURE__ */ v(
114
+ return /* @__PURE__ */ o(L.Provider, { value: { collapsed: l, collapsedWidth: a, width: s }, children: /* @__PURE__ */ A(
97
115
  "aside",
98
116
  {
99
- className: L,
117
+ className: B,
100
118
  style: {
101
- width: typeof d == "number" ? `${d}px` : d,
102
- ...C
119
+ width: typeof x == "number" ? `${x}px` : x,
120
+ ...g
103
121
  },
104
122
  children: [
105
- /* @__PURE__ */ a("div", { className: "flex-1 overflow-auto", children: o }),
106
- e !== null && (e ?? j)
123
+ /* @__PURE__ */ o("div", { className: "flex-1 overflow-auto", children: n }),
124
+ t !== null && (t ?? E)
107
125
  ]
108
126
  }
109
127
  ) });
110
128
  }
111
- y.displayName = "LayoutSider";
112
- const H = Object.assign(m, {
113
- Header: B,
114
- Footer: E,
115
- Content: R,
116
- Sider: y
129
+ v.displayName = "LayoutSider";
130
+ const W = Object.assign(h, {
131
+ Header: H,
132
+ Footer: I,
133
+ Content: O,
134
+ Sider: v
117
135
  });
118
136
  export {
119
- H as Layout,
120
- F as useSiderContext
137
+ W as Layout,
138
+ Q as useSiderContext
121
139
  };
122
140
  //# sourceMappingURL=index45.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index45.js","sources":["../src/components/Layout.tsx"],"sourcesContent":["import React, { createContext, useContext, useState, useCallback } from 'react'\n\nexport interface LayoutProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutHeaderProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutFooterProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutContentProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutSiderProps {\n children: React.ReactNode\n width?: number | string\n collapsedWidth?: number | string\n collapsed?: boolean\n defaultCollapsed?: boolean\n collapsible?: boolean\n onCollapse?: (collapsed: boolean) => void\n trigger?: React.ReactNode | null\n breakpoint?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n onBreakpoint?: (broken: boolean) => void\n className?: string\n style?: React.CSSProperties\n}\n\ninterface SiderContextValue {\n collapsed: boolean\n collapsedWidth: number | string\n width: number | string\n}\n\nconst SiderContext = createContext<SiderContextValue | null>(null)\n\nexport function useSiderContext() {\n return useContext(SiderContext)\n}\n\nfunction LayoutRoot({ children, className = '', style }: LayoutProps) {\n // Check if any child is a Sider to determine flex direction\n const childArray = React.Children.toArray(children)\n const hasSider = childArray.some(\n (child) => React.isValidElement(child) && (child.type as any).displayName === 'LayoutSider'\n )\n\n const layoutClasses = [\n 'flex',\n 'min-h-0',\n hasSider ? 'flex-row' : 'flex-col',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // If we have a Sider, auto-add flex-1 to non-Sider Layout children\n const processedChildren = hasSider\n ? childArray.map((child) => {\n if (\n React.isValidElement(child) &&\n (child.type === LayoutRoot || (child.type as any).displayName === 'LayoutRoot') &&\n (child.type as any).displayName !== 'LayoutSider'\n ) {\n // Clone the Layout child and add flex-1 if not already present\n const existingClassName = (child.props as any).className || ''\n if (!existingClassName.includes('flex-1')) {\n return React.cloneElement(child as React.ReactElement<any>, {\n className: `flex-1 ${existingClassName}`.trim(),\n })\n }\n }\n return child\n })\n : children\n\n return (\n <div className={layoutClasses} style={style}>\n {processedChildren}\n </div>\n )\n}\n\nLayoutRoot.displayName = 'LayoutRoot'\n\nfunction LayoutHeader({ children, className = '', style }: LayoutHeaderProps) {\n const headerClasses = [\n 'flex',\n 'items-center',\n 'px-6',\n 'h-16',\n 'bg-base-300',\n 'flex-shrink-0',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <header className={headerClasses} style={style}>\n {children}\n </header>\n )\n}\n\nfunction LayoutFooter({ children, className = '', style }: LayoutFooterProps) {\n const footerClasses = [\n 'px-6',\n 'py-4',\n 'text-center',\n 'bg-base-300',\n 'flex-shrink-0',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <footer className={footerClasses} style={style}>\n {children}\n </footer>\n )\n}\n\nfunction LayoutContent({ children, className = '', style }: LayoutContentProps) {\n // flex-1 by default so Content fills available space\n const contentClasses = ['flex-1', 'min-h-0', 'overflow-auto', className].filter(Boolean).join(' ')\n\n return (\n <main className={contentClasses} style={style}>\n {children}\n </main>\n )\n}\n\nfunction LayoutSider({\n children,\n width = 200,\n collapsedWidth = 80,\n collapsed: controlledCollapsed,\n defaultCollapsed = false,\n collapsible = false,\n onCollapse,\n trigger,\n className = '',\n style,\n}: LayoutSiderProps) {\n const [internalCollapsed, setInternalCollapsed] = useState(defaultCollapsed)\n\n const collapsed = controlledCollapsed ?? internalCollapsed\n\n const handleCollapse = useCallback(() => {\n const newCollapsed = !collapsed\n if (controlledCollapsed === undefined) {\n setInternalCollapsed(newCollapsed)\n }\n onCollapse?.(newCollapsed)\n }, [collapsed, controlledCollapsed, onCollapse])\n\n const currentWidth = collapsed ? collapsedWidth : width\n\n const siderClasses = [\n 'flex',\n 'flex-col',\n 'bg-base-200',\n 'flex-shrink-0',\n 'transition-all',\n 'duration-200',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const defaultTrigger = collapsible && trigger !== null && (\n <button\n onClick={handleCollapse}\n className=\"flex items-center justify-center h-10 w-full bg-base-300 hover:bg-base-content/10 transition-colors\"\n aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n >\n <svg\n className={`w-4 h-4 transition-transform ${collapsed ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M15 19l-7-7 7-7\" />\n </svg>\n </button>\n )\n\n return (\n <SiderContext.Provider value={{ collapsed, collapsedWidth, width }}>\n <aside\n className={siderClasses}\n style={{\n width: typeof currentWidth === 'number' ? `${currentWidth}px` : currentWidth,\n ...style,\n }}\n >\n <div className=\"flex-1 overflow-auto\">{children}</div>\n {trigger !== null && (trigger ?? defaultTrigger)}\n </aside>\n </SiderContext.Provider>\n )\n}\n\nLayoutSider.displayName = 'LayoutSider'\n\nexport const Layout = Object.assign(LayoutRoot, {\n Header: LayoutHeader,\n Footer: LayoutFooter,\n Content: LayoutContent,\n Sider: LayoutSider,\n})\n"],"names":["SiderContext","createContext","useSiderContext","useContext","LayoutRoot","children","className","style","childArray","React","hasSider","child","layoutClasses","processedChildren","existingClassName","jsx","LayoutHeader","headerClasses","LayoutFooter","footerClasses","LayoutContent","contentClasses","LayoutSider","width","collapsedWidth","controlledCollapsed","defaultCollapsed","collapsible","onCollapse","trigger","internalCollapsed","setInternalCollapsed","useState","collapsed","handleCollapse","useCallback","newCollapsed","currentWidth","siderClasses","defaultTrigger","jsxs","Layout"],"mappings":";;AA+CA,MAAMA,IAAeC,EAAwC,IAAI;AAE1D,SAASC,IAAkB;AAChC,SAAOC,EAAWH,CAAY;AAChC;AAEA,SAASI,EAAW,EAAE,UAAAC,GAAU,WAAAC,IAAY,IAAI,OAAAC,KAAsB;AAEpE,QAAMC,IAAaC,EAAM,SAAS,QAAQJ,CAAQ,GAC5CK,IAAWF,EAAW;AAAA,IAC1B,CAACG,MAAUF,EAAM,eAAeE,CAAK,KAAMA,EAAM,KAAa,gBAAgB;AAAA,EAAA,GAG1EC,IAAgB;AAAA,IACpB;AAAA,IACA;AAAA,IACAF,IAAW,aAAa;AAAA,IACxBJ;AAAA,EAAA,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AAA,IACzF;AAAA,EAAA;AAIJ,SACE,gBAAAA,EAACf,EAAa,UAAb,EAAsB,OAAO,EAAE,WAAAiC,GAAW,gBAAAT,GAAgB,OAAAD,KACzD,UAAA,gBAAAiB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWF;AAAA,MACX,OAAO;AAAA,QACL,OAAO,OAAOD,KAAiB,WAAW,GAAGA,CAAY,OAAOA;AAAA,QAChE,GAAG9B;AAAA,MAAA;AAAA,MAGL,UAAA;AAAA,QAAA,gBAAAQ,EAAC,OAAA,EAAI,WAAU,wBAAwB,UAAAV,EAAA,CAAS;AAAA,QAC/CwB,MAAY,SAASA,KAAWU;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAErC;AAEJ;AAEAjB,EAAY,cAAc;AAEnB,MAAMmB,IAAS,OAAO,OAAOrC,GAAY;AAAA,EAC9C,QAAQY;AAAA,EACR,QAAQE;AAAA,EACR,SAASE;AAAA,EACT,OAAOE;AACT,CAAC;"}
1
+ {"version":3,"file":"index45.js","sources":["../src/components/Layout.tsx"],"sourcesContent":["import React, { createContext, useContext, useState, useCallback, useEffect } from 'react'\n\nexport interface LayoutProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutHeaderProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutFooterProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutContentProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nexport interface LayoutSiderProps {\n children: React.ReactNode\n width?: number | string\n collapsedWidth?: number | string\n collapsed?: boolean\n defaultCollapsed?: boolean\n collapsible?: boolean\n onCollapse?: (collapsed: boolean) => void\n trigger?: React.ReactNode | null\n breakpoint?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n onBreakpoint?: (broken: boolean) => void\n className?: string\n style?: React.CSSProperties\n}\n\ninterface SiderContextValue {\n collapsed: boolean\n collapsedWidth: number | string\n width: number | string\n}\n\nconst SiderContext = createContext<SiderContextValue | null>(null)\n\nexport function useSiderContext() {\n return useContext(SiderContext)\n}\n\nfunction LayoutRoot({ children, className = '', style }: LayoutProps) {\n // Check if any child is a Sider to determine flex direction\n const childArray = React.Children.toArray(children)\n const hasSider = childArray.some(\n (child) => React.isValidElement(child) && (child.type as any).displayName === 'LayoutSider'\n )\n\n const layoutClasses = [\n 'flex',\n 'min-h-0',\n hasSider ? 'flex-row' : 'flex-col',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // If we have a Sider, auto-add flex-1 to non-Sider Layout children\n const processedChildren = hasSider\n ? childArray.map((child) => {\n if (\n React.isValidElement(child) &&\n (child.type === LayoutRoot || (child.type as any).displayName === 'LayoutRoot') &&\n (child.type as any).displayName !== 'LayoutSider'\n ) {\n // Clone the Layout child and add flex-1 if not already present\n const existingClassName = (child.props as any).className || ''\n if (!existingClassName.includes('flex-1')) {\n return React.cloneElement(child as React.ReactElement<any>, {\n className: `flex-1 ${existingClassName}`.trim(),\n })\n }\n }\n return child\n })\n : children\n\n return (\n <div className={layoutClasses} style={style}>\n {processedChildren}\n </div>\n )\n}\n\nLayoutRoot.displayName = 'LayoutRoot'\n\nfunction LayoutHeader({ children, className = '', style }: LayoutHeaderProps) {\n const headerClasses = [\n 'flex',\n 'items-center',\n 'px-6',\n 'h-16',\n 'bg-base-300',\n 'flex-shrink-0',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <header className={headerClasses} style={style}>\n {children}\n </header>\n )\n}\n\nfunction LayoutFooter({ children, className = '', style }: LayoutFooterProps) {\n const footerClasses = [\n 'px-6',\n 'py-4',\n 'text-center',\n 'bg-base-300',\n 'flex-shrink-0',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <footer className={footerClasses} style={style}>\n {children}\n </footer>\n )\n}\n\nfunction LayoutContent({ children, className = '', style }: LayoutContentProps) {\n // flex-1 by default so Content fills available space\n const contentClasses = ['flex-1', 'min-h-0', 'overflow-auto', className].filter(Boolean).join(' ')\n\n return (\n <main className={contentClasses} style={style}>\n {children}\n </main>\n )\n}\n\nconst BREAKPOINT_MAP: Record<string, string> = {\n sm: '(max-width: 639px)',\n md: '(max-width: 767px)',\n lg: '(max-width: 1023px)',\n xl: '(max-width: 1279px)',\n '2xl': '(max-width: 1535px)',\n}\n\nfunction LayoutSider({\n children,\n width = 200,\n collapsedWidth = 80,\n collapsed: controlledCollapsed,\n defaultCollapsed = false,\n collapsible = false,\n onCollapse,\n trigger,\n breakpoint,\n onBreakpoint,\n className = '',\n style,\n}: LayoutSiderProps) {\n const [internalCollapsed, setInternalCollapsed] = useState(defaultCollapsed)\n const [broken, setBroken] = useState(false)\n\n const collapsed = controlledCollapsed ?? internalCollapsed\n\n // Handle responsive breakpoint\n useEffect(() => {\n if (!breakpoint) return\n\n const mediaQuery = window.matchMedia(BREAKPOINT_MAP[breakpoint])\n\n const handleChange = (e: MediaQueryListEvent | MediaQueryList) => {\n const isBroken = e.matches\n setBroken(isBroken)\n onBreakpoint?.(isBroken)\n\n // Auto-collapse when breakpoint is crossed\n if (controlledCollapsed === undefined) {\n setInternalCollapsed(isBroken)\n }\n if (isBroken !== broken) {\n onCollapse?.(isBroken)\n }\n }\n\n // Check initial state\n handleChange(mediaQuery)\n\n // Listen for changes\n mediaQuery.addEventListener('change', handleChange)\n return () => mediaQuery.removeEventListener('change', handleChange)\n }, [breakpoint, onBreakpoint, controlledCollapsed, onCollapse, broken])\n\n const handleCollapse = useCallback(() => {\n const newCollapsed = !collapsed\n if (controlledCollapsed === undefined) {\n setInternalCollapsed(newCollapsed)\n }\n onCollapse?.(newCollapsed)\n }, [collapsed, controlledCollapsed, onCollapse])\n\n const currentWidth = collapsed ? collapsedWidth : width\n\n const siderClasses = [\n 'flex',\n 'flex-col',\n 'bg-base-200',\n 'flex-shrink-0',\n 'transition-all',\n 'duration-200',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const defaultTrigger = collapsible && trigger !== null && (\n <button\n onClick={handleCollapse}\n className=\"flex items-center justify-center h-10 w-full bg-base-300 hover:bg-base-content/10 transition-colors\"\n aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n >\n <svg\n className={`w-4 h-4 transition-transform ${collapsed ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M15 19l-7-7 7-7\" />\n </svg>\n </button>\n )\n\n return (\n <SiderContext.Provider value={{ collapsed, collapsedWidth, width }}>\n <aside\n className={siderClasses}\n style={{\n width: typeof currentWidth === 'number' ? `${currentWidth}px` : currentWidth,\n ...style,\n }}\n >\n <div className=\"flex-1 overflow-auto\">{children}</div>\n {trigger !== null && (trigger ?? defaultTrigger)}\n </aside>\n </SiderContext.Provider>\n )\n}\n\nLayoutSider.displayName = 'LayoutSider'\n\nexport const Layout = Object.assign(LayoutRoot, {\n Header: LayoutHeader,\n Footer: LayoutFooter,\n Content: LayoutContent,\n Sider: LayoutSider,\n})\n"],"names":["SiderContext","createContext","useSiderContext","useContext","LayoutRoot","children","className","style","childArray","React","hasSider","child","layoutClasses","processedChildren","existingClassName","jsx","LayoutHeader","headerClasses","LayoutFooter","footerClasses","LayoutContent","contentClasses","BREAKPOINT_MAP","LayoutSider","width","collapsedWidth","controlledCollapsed","defaultCollapsed","collapsible","onCollapse","trigger","breakpoint","onBreakpoint","internalCollapsed","setInternalCollapsed","useState","broken","setBroken","collapsed","useEffect","mediaQuery","handleChange","e","isBroken","handleCollapse","useCallback","newCollapsed","currentWidth","siderClasses","defaultTrigger","jsxs","Layout"],"mappings":";;AA+CA,MAAMA,IAAeC,EAAwC,IAAI;AAE1D,SAASC,IAAkB;AAChC,SAAOC,EAAWH,CAAY;AAChC;AAEA,SAASI,EAAW,EAAE,UAAAC,GAAU,WAAAC,IAAY,IAAI,OAAAC,KAAsB;AAEpE,QAAMC,I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gBAAAQ,EAAC,OAAA,EAAI,WAAU,wBAAwB,UAAAV,EAAA,CAAS;AAAA,QAC/CyB,MAAY,SAASA,KAAWmB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAErC;AAEJ;AAEA1B,EAAY,cAAc;AAEnB,MAAM4B,IAAS,OAAO,OAAO/C,GAAY;AAAA,EAC9C,QAAQY;AAAA,EACR,QAAQE;AAAA,EACR,SAASE;AAAA,EACT,OAAOG;AACT,CAAC;"}
package/dist/index49.js CHANGED
@@ -1,119 +1,84 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import C from "react";
3
- const h = ({
4
- children: u,
5
- columns: l = 3,
6
- gap: m = 4,
7
- className: c = "",
8
- ...a
1
+ import { jsx as H } from "react/jsx-runtime";
2
+ import I, { useRef as R, useState as b, useCallback as K, useLayoutEffect as A } from "react";
3
+ const d = {
4
+ sm: 640,
5
+ md: 768,
6
+ lg: 1024,
7
+ xl: 1280,
8
+ "2xl": 1536
9
+ };
10
+ function L(t, e) {
11
+ return typeof t == "number" ? t : t ? t["2xl"] !== void 0 && e >= d["2xl"] ? t["2xl"] : t.xl !== void 0 && e >= d.xl ? t.xl : t.lg !== void 0 && e >= d.lg ? t.lg : t.md !== void 0 && e >= d.md ? t.md : t.sm !== void 0 && e >= d.sm ? t.sm : t.xs !== void 0 ? t.xs : 3 : 3;
12
+ }
13
+ const O = ({
14
+ children: t,
15
+ columns: e = 3,
16
+ gap: r = 16,
17
+ className: z = "",
18
+ style: M,
19
+ ...P
9
20
  }) => {
10
- const p = () => typeof m == "string" ? m : {
11
- 0: "gap-0",
12
- 1: "gap-1",
13
- 2: "gap-2",
14
- 3: "gap-3",
15
- 4: "gap-4",
16
- 5: "gap-5",
17
- 6: "gap-6",
18
- 7: "gap-7",
19
- 8: "gap-8",
20
- 9: "gap-9",
21
- 10: "gap-10",
22
- 11: "gap-11",
23
- 12: "gap-12"
24
- }[m] || "gap-4", o = {
25
- 1: "columns-1",
26
- 2: "columns-2",
27
- 3: "columns-3",
28
- 4: "columns-4",
29
- 5: "columns-5",
30
- 6: "columns-6",
31
- 7: "columns-7",
32
- 8: "columns-8",
33
- 9: "columns-9",
34
- 10: "columns-10",
35
- 11: "columns-11",
36
- 12: "columns-12"
37
- }, x = {
38
- 1: "sm:columns-1",
39
- 2: "sm:columns-2",
40
- 3: "sm:columns-3",
41
- 4: "sm:columns-4",
42
- 5: "sm:columns-5",
43
- 6: "sm:columns-6",
44
- 7: "sm:columns-7",
45
- 8: "sm:columns-8",
46
- 9: "sm:columns-9",
47
- 10: "sm:columns-10",
48
- 11: "sm:columns-11",
49
- 12: "sm:columns-12"
50
- }, g = {
51
- 1: "md:columns-1",
52
- 2: "md:columns-2",
53
- 3: "md:columns-3",
54
- 4: "md:columns-4",
55
- 5: "md:columns-5",
56
- 6: "md:columns-6",
57
- 7: "md:columns-7",
58
- 8: "md:columns-8",
59
- 9: "md:columns-9",
60
- 10: "md:columns-10",
61
- 11: "md:columns-11",
62
- 12: "md:columns-12"
63
- }, d = {
64
- 1: "lg:columns-1",
65
- 2: "lg:columns-2",
66
- 3: "lg:columns-3",
67
- 4: "lg:columns-4",
68
- 5: "lg:columns-5",
69
- 6: "lg:columns-6",
70
- 7: "lg:columns-7",
71
- 8: "lg:columns-8",
72
- 9: "lg:columns-9",
73
- 10: "lg:columns-10",
74
- 11: "lg:columns-11",
75
- 12: "lg:columns-12"
76
- }, e = {
77
- 1: "xl:columns-1",
78
- 2: "xl:columns-2",
79
- 3: "xl:columns-3",
80
- 4: "xl:columns-4",
81
- 5: "xl:columns-5",
82
- 6: "xl:columns-6",
83
- 7: "xl:columns-7",
84
- 8: "xl:columns-8",
85
- 9: "xl:columns-9",
86
- 10: "xl:columns-10",
87
- 11: "xl:columns-11",
88
- 12: "xl:columns-12"
89
- }, i = {
90
- 1: "2xl:columns-1",
91
- 2: "2xl:columns-2",
92
- 3: "2xl:columns-3",
93
- 4: "2xl:columns-4",
94
- 5: "2xl:columns-5",
95
- 6: "2xl:columns-6",
96
- 7: "2xl:columns-7",
97
- 8: "2xl:columns-8",
98
- 9: "2xl:columns-9",
99
- 10: "2xl:columns-10",
100
- 11: "2xl:columns-11",
101
- 12: "2xl:columns-12"
102
- }, t = [
103
- (() => {
104
- if (typeof l == "number")
105
- return o[l] || "columns-3";
106
- const s = [];
107
- return l.xs !== void 0 && s.push(o[l.xs] || "columns-3"), l.sm !== void 0 && s.push(x[l.sm] || "sm:columns-3"), l.md !== void 0 && s.push(g[l.md] || "md:columns-3"), l.lg !== void 0 && s.push(d[l.lg] || "lg:columns-3"), l.xl !== void 0 && s.push(e[l.xl] || "xl:columns-3"), l["2xl"] !== void 0 && s.push(i[l["2xl"]] || "2xl:columns-3"), s.join(" ");
108
- })(),
109
- p(),
110
- c
111
- ].filter(Boolean).join(" "), r = C.Children.map(u, (s, f) => /* @__PURE__ */ n("div", { className: "break-inside-avoid mb-4", children: s }, f));
112
- return /* @__PURE__ */ n("div", { className: t, ...a, children: r });
21
+ const u = R(null), [l, T] = b([]), [y, N] = b(0), w = R([]), c = I.Children.toArray(t), s = K(() => {
22
+ const i = u.current;
23
+ if (!i || c.length === 0) return;
24
+ const n = i.offsetWidth, m = typeof window < "u" ? window.innerWidth : n, a = L(e, m), j = (n - r * (a - 1)) / a, o = new Array(a).fill(0), W = [];
25
+ c.forEach((_, x) => {
26
+ const C = w.current[x];
27
+ if (!C) return;
28
+ let h = 0, E = o[0];
29
+ for (let f = 1; f < a; f++)
30
+ o[f] < E && (E = o[f], h = f);
31
+ const k = h * (j + r), B = o[h];
32
+ W[x] = { left: k, top: B };
33
+ const F = C.offsetHeight;
34
+ o[h] += F + r;
35
+ }), T(W), N(Math.max(...o) - r);
36
+ }, [t, e, r, c.length]);
37
+ A(() => {
38
+ s();
39
+ const i = () => {
40
+ s();
41
+ };
42
+ return window.addEventListener("resize", i), () => window.removeEventListener("resize", i);
43
+ }, [s]), A(() => {
44
+ const i = setTimeout(s, 0);
45
+ return () => clearTimeout(i);
46
+ }, [t, s]);
47
+ const v = u.current?.offsetWidth ?? 0, S = typeof window < "u" ? window.innerWidth : v, g = L(e, S), p = v > 0 ? (v - r * (g - 1)) / g : 0;
48
+ return /* @__PURE__ */ H(
49
+ "div",
50
+ {
51
+ ref: u,
52
+ className: z,
53
+ style: {
54
+ position: "relative",
55
+ height: y > 0 ? y : void 0,
56
+ ...M
57
+ },
58
+ ...P,
59
+ children: c.map((i, n) => /* @__PURE__ */ H(
60
+ "div",
61
+ {
62
+ ref: (m) => {
63
+ w.current[n] = m;
64
+ },
65
+ style: {
66
+ position: l.length > 0 ? "absolute" : "relative",
67
+ left: l[n]?.left ?? 0,
68
+ top: l[n]?.top ?? 0,
69
+ width: p > 0 ? p : "100%",
70
+ visibility: l.length > 0 ? "visible" : "hidden"
71
+ },
72
+ children: i
73
+ },
74
+ n
75
+ ))
76
+ }
77
+ );
113
78
  };
114
- h.displayName = "Masonry";
79
+ O.displayName = "Masonry";
115
80
  export {
116
- h as Masonry,
117
- h as default
81
+ O as Masonry,
82
+ O as default
118
83
  };
119
84
  //# sourceMappingURL=index49.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index49.js","sources":["../src/components/Masonry.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface MasonryProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n columns?: number | {\n xs?: number\n sm?: number\n md?: number\n lg?: number\n xl?: number\n '2xl'?: number\n }\n gap?: number | string\n}\n\nexport const Masonry: React.FC<MasonryProps> = ({\n children,\n columns = 3,\n gap = 4,\n className = '',\n ...rest\n}) => {\n // Map gap values to Tailwind classes\n const getGapClass = () => {\n if (typeof gap === 'string') {\n return gap\n }\n\n const gapMap: Record<number, string> = {\n 0: 'gap-0',\n 1: 'gap-1',\n 2: 'gap-2',\n 3: 'gap-3',\n 4: 'gap-4',\n 5: 'gap-5',\n 6: 'gap-6',\n 7: 'gap-7',\n 8: 'gap-8',\n 9: 'gap-9',\n 10: 'gap-10',\n 11: 'gap-11',\n 12: 'gap-12',\n }\n return gapMap[gap] || 'gap-4'\n }\n\n // Static column class mappings for Tailwind JIT\n const baseColumnMap: Record<number, string> = {\n 1: 'columns-1',\n 2: 'columns-2',\n 3: 'columns-3',\n 4: 'columns-4',\n 5: 'columns-5',\n 6: 'columns-6',\n 7: 'columns-7',\n 8: 'columns-8',\n 9: 'columns-9',\n 10: 'columns-10',\n 11: 'columns-11',\n 12: 'columns-12',\n }\n\n const smColumnMap: Record<number, string> = {\n 1: 'sm:columns-1',\n 2: 'sm:columns-2',\n 3: 'sm:columns-3',\n 4: 'sm:columns-4',\n 5: 'sm:columns-5',\n 6: 'sm:columns-6',\n 7: 'sm:columns-7',\n 8: 'sm:columns-8',\n 9: 'sm:columns-9',\n 10: 'sm:columns-10',\n 11: 'sm:columns-11',\n 12: 'sm:columns-12',\n }\n\n const mdColumnMap: Record<number, string> = {\n 1: 'md:columns-1',\n 2: 'md:columns-2',\n 3: 'md:columns-3',\n 4: 'md:columns-4',\n 5: 'md:columns-5',\n 6: 'md:columns-6',\n 7: 'md:columns-7',\n 8: 'md:columns-8',\n 9: 'md:columns-9',\n 10: 'md:columns-10',\n 11: 'md:columns-11',\n 12: 'md:columns-12',\n }\n\n const lgColumnMap: Record<number, string> = {\n 1: 'lg:columns-1',\n 2: 'lg:columns-2',\n 3: 'lg:columns-3',\n 4: 'lg:columns-4',\n 5: 'lg:columns-5',\n 6: 'lg:columns-6',\n 7: 'lg:columns-7',\n 8: 'lg:columns-8',\n 9: 'lg:columns-9',\n 10: 'lg:columns-10',\n 11: 'lg:columns-11',\n 12: 'lg:columns-12',\n }\n\n const xlColumnMap: Record<number, string> = {\n 1: 'xl:columns-1',\n 2: 'xl:columns-2',\n 3: 'xl:columns-3',\n 4: 'xl:columns-4',\n 5: 'xl:columns-5',\n 6: 'xl:columns-6',\n 7: 'xl:columns-7',\n 8: 'xl:columns-8',\n 9: 'xl:columns-9',\n 10: 'xl:columns-10',\n 11: 'xl:columns-11',\n 12: 'xl:columns-12',\n }\n\n const xl2ColumnMap: Record<number, string> = {\n 1: '2xl:columns-1',\n 2: '2xl:columns-2',\n 3: '2xl:columns-3',\n 4: '2xl:columns-4',\n 5: '2xl:columns-5',\n 6: '2xl:columns-6',\n 7: '2xl:columns-7',\n 8: '2xl:columns-8',\n 9: '2xl:columns-9',\n 10: '2xl:columns-10',\n 11: '2xl:columns-11',\n 12: '2xl:columns-12',\n }\n\n // Convert columns to Tailwind classes\n const getColumnClasses = () => {\n if (typeof columns === 'number') {\n return baseColumnMap[columns] || 'columns-3'\n }\n\n // Handle responsive columns object\n const classes: string[] = []\n if (columns.xs !== undefined) classes.push(baseColumnMap[columns.xs] || 'columns-3')\n if (columns.sm !== undefined) classes.push(smColumnMap[columns.sm] || 'sm:columns-3')\n if (columns.md !== undefined) classes.push(mdColumnMap[columns.md] || 'md:columns-3')\n if (columns.lg !== undefined) classes.push(lgColumnMap[columns.lg] || 'lg:columns-3')\n if (columns.xl !== undefined) classes.push(xlColumnMap[columns.xl] || 'xl:columns-3')\n if (columns['2xl'] !== undefined) classes.push(xl2ColumnMap[columns['2xl']] || '2xl:columns-3')\n\n return classes.join(' ')\n }\n\n const containerClasses = [\n getColumnClasses(),\n getGapClass(),\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Wrap children in break-inside-avoid containers\n const wrappedChildren = React.Children.map(children, (child, index) => (\n <div key={index} className=\"break-inside-avoid mb-4\">\n {child}\n </div>\n ))\n\n return (\n <div className={containerClasses} {...rest}>\n {wrappedChildren}\n </div>\n )\n}\n\nMasonry.displayName = 'Masonry'\n\nexport default Masonry\n"],"names":["Masonry","children","columns","gap","className","rest","getGapClass","baseColumnMap","smColumnMap","mdColumnMap","lgColumnMap","xlColumnMap","xl2ColumnMap","containerClasses","classes","wrappedChildren","React","child","index","jsx"],"mappings":";;AAeO,MAAMA,IAAkC,CAAC;AAAA,EAC9C,UAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,KAAAC,IAAM;AAAA,EACN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G,GAGLW,IAAkBC,EAAM,SAAS,IAAIf,GAAU,CAACgB,GAAOC,MAC3D,gBAAAC,EAAC,OAAA,EAAgB,WAAU,2BACxB,UAAAF,EAAA,GADOC,CAEV,CACD;AAED,2BACG,OAAA,EAAI,WAAWL,GAAmB,GAAGR,GACnC,UAAAU,GACH;AAEJ;AAEAf,EAAQ,cAAc;"}
1
+ {"version":3,"file":"index49.js","sources":["../src/components/Masonry.tsx"],"sourcesContent":["import React, { useRef, useState, useLayoutEffect, useCallback } from 'react'\n\nexport interface MasonryProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n columns?:\n | number\n | {\n xs?: number\n sm?: number\n md?: number\n lg?: number\n xl?: number\n '2xl'?: number\n }\n gap?: number\n}\n\n// Tailwind breakpoints in pixels\nconst BREAKPOINTS = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536,\n}\n\nfunction getColumnsForWidth(\n columns: MasonryProps['columns'],\n width: number\n): number {\n if (typeof columns === 'number') {\n return columns\n }\n\n if (!columns) return 3\n\n // Find the appropriate column count for current width\n // Start from largest breakpoint and work down\n if (columns['2xl'] !== undefined && width >= BREAKPOINTS['2xl']) {\n return columns['2xl']\n }\n if (columns.xl !== undefined && width >= BREAKPOINTS.xl) {\n return columns.xl\n }\n if (columns.lg !== undefined && width >= BREAKPOINTS.lg) {\n return columns.lg\n }\n if (columns.md !== undefined && width >= BREAKPOINTS.md) {\n return columns.md\n }\n if (columns.sm !== undefined && width >= BREAKPOINTS.sm) {\n return columns.sm\n }\n if (columns.xs !== undefined) {\n return columns.xs\n }\n\n // Default fallback\n return 3\n}\n\nexport const Masonry: React.FC<MasonryProps> = ({\n children,\n columns = 3,\n gap = 16,\n className = '',\n style,\n ...rest\n}) => {\n const containerRef = useRef<HTMLDivElement>(null)\n const [positions, setPositions] = useState<\n Array<{ left: number; top: number }>\n >([])\n const [containerHeight, setContainerHeight] = useState(0)\n const itemRefs = useRef<(HTMLDivElement | null)[]>([])\n\n const childArray = React.Children.toArray(children)\n\n const calculateLayout = useCallback(() => {\n const container = containerRef.current\n if (!container || childArray.length === 0) return\n\n const containerWidth = container.offsetWidth\n // Use viewport width for responsive breakpoints (matches Tailwind behavior)\n const viewportWidth = typeof window !== 'undefined' ? window.innerWidth : containerWidth\n const numColumns = getColumnsForWidth(columns, viewportWidth)\n const columnWidth = (containerWidth - gap * (numColumns - 1)) / numColumns\n\n // Track height of each column\n const columnHeights = new Array(numColumns).fill(0)\n const newPositions: Array<{ left: number; top: number }> = []\n\n // Place each item in the shortest column\n childArray.forEach((_, index) => {\n const itemEl = itemRefs.current[index]\n if (!itemEl) return\n\n // Find shortest column\n let shortestColumn = 0\n let minHeight = columnHeights[0]\n for (let i = 1; i < numColumns; i++) {\n if (columnHeights[i] < minHeight) {\n minHeight = columnHeights[i]\n shortestColumn = i\n }\n }\n\n // Calculate position\n const left = shortestColumn * (columnWidth + gap)\n const top = columnHeights[shortestColumn]\n\n newPositions[index] = { left, top }\n\n // Update column height\n const itemHeight = itemEl.offsetHeight\n columnHeights[shortestColumn] += itemHeight + gap\n })\n\n setPositions(newPositions)\n setContainerHeight(Math.max(...columnHeights) - gap)\n }, [children, columns, gap, childArray.length])\n\n // Calculate layout after render and on resize\n useLayoutEffect(() => {\n calculateLayout()\n\n const handleResize = () => {\n calculateLayout()\n }\n\n window.addEventListener('resize', handleResize)\n return () => window.removeEventListener('resize', handleResize)\n }, [calculateLayout])\n\n // Recalculate when children change\n useLayoutEffect(() => {\n // Small delay to ensure refs are populated\n const timer = setTimeout(calculateLayout, 0)\n return () => clearTimeout(timer)\n }, [children, calculateLayout])\n\n const containerWidth = containerRef.current?.offsetWidth ?? 0\n const viewportWidth = typeof window !== 'undefined' ? window.innerWidth : containerWidth\n const numColumns = getColumnsForWidth(columns, viewportWidth)\n const columnWidth =\n containerWidth > 0\n ? (containerWidth - gap * (numColumns - 1)) / numColumns\n : 0\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={{\n position: 'relative',\n height: containerHeight > 0 ? containerHeight : undefined,\n ...style,\n }}\n {...rest}\n >\n {childArray.map((child, index) => (\n <div\n key={index}\n ref={(el) => {\n itemRefs.current[index] = el\n }}\n style={{\n position: positions.length > 0 ? 'absolute' : 'relative',\n left: positions[index]?.left ?? 0,\n top: positions[index]?.top ?? 0,\n width: columnWidth > 0 ? columnWidth : '100%',\n visibility: positions.length > 0 ? 'visible' : 'hidden',\n }}\n >\n {child}\n </div>\n ))}\n </div>\n )\n}\n\nMasonry.displayName = 'Masonry'\n\nexport default Masonry\n"],"names":["BREAKPOINTS","getColumnsForWidth","columns","width","Masonry","children","gap","className","style","rest","containerRef","useRef","positions","setPositions","useState","containerHeight","setContainerHeight","itemRefs","childArray","React","calculateLayout","useCallback","container","containerWidth","viewportWidth","numColumns","columnWidth","columnHeights","newPositions","index","itemEl","shortestColumn","minHeight","i","left","top","itemHeight","useLayoutEffect","handleResize","timer","jsx","child","el"],"mappings":";;AAkBA,MAAMA,IAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT;AAEA,SAASC,EACPC,GACAC,GACQ;AACR,SAAI,OAAOD,KAAY,WACdA,IAGJA,IAIDA,EAAQ,KAAK,MAAM,UAAaC,KAASH,EAAY,KAAK,IACrDE,EAAQ,KAAK,IAElBA,EAAQ,OAAO,UAAaC,KAASH,EAAY,KAC5CE,EAAQ,KAEbA,EAAQ,OAAO,UAAaC,KAASH,EAAY,KAC5CE,EAAQ,KAEbA,EAAQ,OAAO,UAAaC,KAASH,EAAY,KAC5CE,EAAQ,KAEbA,EAAQ,OAAO,UAAaC,KAASH,EAAY,KAC5CE,EAAQ,KAEbA,EAAQ,OAAO,SACVA,EAAQ,KAIV,IAxBc;AAyBvB;AAEO,MAAME,IAAkC,CAAC;AAAA,EAC9C,UAAAC;AAAA,EACA,SAAAH,IAAU;AAAA,EACV,KAAAI,IAAM;AAAA,E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;AAAA,MAAA,CAcR;AAAA,IAAA;AAAA,EAAA;AAGP;AAEAzB,EAAQ,cAAc;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asterui",
3
- "version": "0.12.8",
3
+ "version": "0.12.10",
4
4
  "description": "React UI component library with DaisyUI",
5
5
  "homepage": "https://asterui.com",
6
6
  "repository": {