@annatarhe/lake-ui 0.0.28 → 0.0.31

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.
@@ -0,0 +1,30 @@
1
+ import { useRef as f, useEffect as i, useCallback as l } from "react";
2
+ function d(r, e = {}) {
3
+ const s = f(r), t = f(null);
4
+ return i(() => {
5
+ s.current = r;
6
+ }, [r]), l(
7
+ (n) => {
8
+ if (t.current && (t.current = null), !n || typeof IntersectionObserver > "u") return;
9
+ t.current = n;
10
+ const u = new IntersectionObserver(
11
+ (o) => {
12
+ o.forEach((c) => {
13
+ c.isIntersecting && s.current();
14
+ });
15
+ },
16
+ {
17
+ rootMargin: e.rootMargin ?? "0px",
18
+ threshold: e.threshold ?? 0
19
+ }
20
+ );
21
+ return u.observe(n), () => {
22
+ u.disconnect();
23
+ };
24
+ },
25
+ [e.rootMargin, e.threshold]
26
+ );
27
+ }
28
+ export {
29
+ d as default
30
+ };
package/dist/index.js CHANGED
@@ -1,26 +1,34 @@
1
- import { default as a } from "./card/index.js";
1
+ import { default as t } from "./card/index.js";
2
2
  import { default as r } from "./contribution-wall/index.js";
3
3
  import { default as f } from "./form/input-field.js";
4
4
  import { default as u } from "./form/multi-select.js";
5
5
  import { default as m } from "./form/number-field.js";
6
6
  import { default as s } from "./form/select-field.js";
7
- import { default as n } from "./form/switch-field.js";
8
- import { default as b } from "./form/textarea-field.js";
9
- import { default as C } from "./modal/index.js";
10
- import { default as T } from "./navbar/container.js";
11
- import { default as N } from "./table/index.js";
12
- import { default as v } from "./tooltip/index.js";
7
+ import { default as b } from "./form/switch-field.js";
8
+ import { default as T } from "./form/textarea-field.js";
9
+ import { default as c } from "./modal/index.js";
10
+ import { default as M } from "./navbar/container.js";
11
+ import { default as E } from "./table/index.js";
12
+ import { default as N } from "./tooltip/index.js";
13
+ import { default as h } from "./table/table-empty.js";
14
+ import { default as w } from "./table/table-end.js";
15
+ import { default as I } from "./table/table-load-more.js";
16
+ import { default as j } from "./table/table-loading.js";
13
17
  export {
14
- a as Card,
18
+ t as Card,
15
19
  r as ContributionWall,
16
20
  f as InputField,
17
- C as Modal,
21
+ c as Modal,
18
22
  u as MultiSelect,
19
- T as NavbarContainer,
23
+ M as NavbarContainer,
20
24
  m as NumberField,
21
25
  s as SelectField,
22
- n as SwitchField,
23
- N as Table,
24
- b as TextareaField,
25
- v as Tooltip
26
+ b as SwitchField,
27
+ E as Table,
28
+ h as TableEmpty,
29
+ w as TableEnd,
30
+ I as TableLoadMore,
31
+ j as TableLoading,
32
+ T as TextareaField,
33
+ N as Tooltip
26
34
  };
@@ -0,0 +1,6 @@
1
+ interface UseInViewportOptions {
2
+ rootMargin?: string;
3
+ threshold?: number | number[];
4
+ }
5
+ declare function useInViewport(callback: () => void, options?: UseInViewportOptions): (node: HTMLDivElement | null) => (() => void) | undefined;
6
+ export default useInViewport;
@@ -3,6 +3,6 @@ import { default as ContributionWall } from './contribution-wall';
3
3
  import { InputField, MultiSelect, NumberField, SelectField, SwitchField, TextareaField } from './form';
4
4
  import { default as Modal } from './modal';
5
5
  import { NavbarContainer } from './navbar';
6
- import { default as Table } from './table';
6
+ import { default as Table, TableEmpty, TableEnd, TableLoadMore, TableLoading } from './table';
7
7
  import { default as Tooltip } from './tooltip';
8
- export { Card, ContributionWall, InputField, Modal, MultiSelect, NavbarContainer, NumberField, SelectField, SwitchField, Table, TextareaField, Tooltip, };
8
+ export { Card, ContributionWall, InputField, Modal, MultiSelect, NavbarContainer, NumberField, SelectField, SwitchField, Table, TableEmpty, TableEnd, TableLoadMore, TableLoading, TextareaField, Tooltip, };
@@ -1,22 +1,9 @@
1
- import { default as React } from 'react';
2
- interface Column<T> {
3
- key: keyof T | string;
4
- header: string | React.ReactNode;
5
- render?: (value: any, row: T) => React.ReactNode;
6
- sortable?: boolean;
7
- width?: string;
8
- align?: 'left' | 'center' | 'right';
9
- }
10
- interface TableProps<T> {
11
- data: T[];
12
- columns: Column<T>[];
13
- className?: string;
14
- onSort?: (key: string, direction: 'asc' | 'desc') => void;
15
- sortKey?: string;
16
- sortDirection?: 'asc' | 'desc';
17
- loading?: boolean;
18
- emptyMessage?: string;
19
- variant?: 'default' | 'bordered' | 'striped';
20
- }
21
- declare function Table<T extends Record<string, any>>({ data, columns, className, onSort, sortKey, sortDirection, loading, emptyMessage, variant }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
1
+ import { default as TableEmpty } from './table-empty';
2
+ import { default as TableEnd } from './table-end';
3
+ import { default as TableLoadMore } from './table-load-more';
4
+ import { default as TableLoading } from './table-loading';
5
+ import { TableProps } from './types';
6
+ declare function Table<T extends Record<string, any>>({ data, columns, className, onSort, sortKey, sortDirection, loading, emptyMessage, variant, total, hasMore, onLoadMore, loadingMore, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
22
7
  export default Table;
8
+ export { TableEmpty, TableEnd, TableLoadMore, TableLoading };
9
+ export type { Column, TableProps } from './types';
@@ -0,0 +1,21 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { default as Table } from './index';
3
+ interface User {
4
+ id: number;
5
+ name: string;
6
+ email: string;
7
+ role: string;
8
+ }
9
+ declare const meta: Meta<typeof Table<User>>;
10
+ export default meta;
11
+ type Story = StoryObj<typeof Table<User>>;
12
+ export declare const Default: Story;
13
+ export declare const Bordered: Story;
14
+ export declare const Striped: Story;
15
+ export declare const Glass: Story;
16
+ export declare const WithSorting: Story;
17
+ export declare const Loading: Story;
18
+ export declare const Empty: Story;
19
+ export declare const InfiniteScroll: Story;
20
+ export declare const InfiniteScrollEnd: Story;
21
+ export declare const DarkMode: Story;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { TableEmptyProps } from './types';
2
+ declare function TableEmpty({ message, className, colSpan, }: TableEmptyProps): import("react/jsx-runtime").JSX.Element;
3
+ export default TableEmpty;
@@ -0,0 +1,3 @@
1
+ import { TableEndProps } from './types';
2
+ declare function TableEnd({ message, className, total }: TableEndProps): import("react/jsx-runtime").JSX.Element;
3
+ export default TableEnd;
@@ -0,0 +1,3 @@
1
+ import { TableLoadMoreProps } from './types';
2
+ declare function TableLoadMore({ onLoadMore, loading, className }: TableLoadMoreProps): import("react/jsx-runtime").JSX.Element;
3
+ export default TableLoadMore;
@@ -0,0 +1,3 @@
1
+ import { TableLoadingProps } from './types';
2
+ declare function TableLoading({ className, colSpan }: TableLoadingProps): import("react/jsx-runtime").JSX.Element;
3
+ export default TableLoading;
@@ -0,0 +1,43 @@
1
+ import { default as React } from 'react';
2
+ export interface Column<T> {
3
+ key: keyof T | string;
4
+ header: string | React.ReactNode;
5
+ render?: (value: any, row: T) => React.ReactNode;
6
+ sortable?: boolean;
7
+ width?: string;
8
+ align?: 'left' | 'center' | 'right';
9
+ }
10
+ export interface TableProps<T> {
11
+ data: T[];
12
+ columns: Column<T>[];
13
+ className?: string;
14
+ onSort?: (key: string, direction: 'asc' | 'desc') => void;
15
+ sortKey?: string;
16
+ sortDirection?: 'asc' | 'desc';
17
+ loading?: boolean;
18
+ emptyMessage?: string | React.ReactNode;
19
+ variant?: 'default' | 'bordered' | 'striped' | 'glass';
20
+ total?: number;
21
+ hasMore?: boolean;
22
+ onLoadMore?: () => void;
23
+ loadingMore?: boolean;
24
+ }
25
+ export interface TableLoadingProps {
26
+ className?: string;
27
+ colSpan: number;
28
+ }
29
+ export interface TableEmptyProps {
30
+ message?: string | React.ReactNode;
31
+ className?: string;
32
+ colSpan: number;
33
+ }
34
+ export interface TableEndProps {
35
+ message?: string | React.ReactNode;
36
+ className?: string;
37
+ total?: number;
38
+ }
39
+ export interface TableLoadMoreProps {
40
+ onLoadMore: () => void;
41
+ loading?: boolean;
42
+ className?: string;
43
+ }
@@ -0,0 +1,10 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { default as Tooltip } from './index';
3
+ declare const meta: Meta<typeof Tooltip>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Tooltip>;
6
+ export declare const Default: Story;
7
+ export declare const AllSides: Story;
8
+ export declare const Disabled: Story;
9
+ export declare const NoWrap: Story;
10
+ export declare const WithCustomContent: Story;
@@ -1,112 +1,128 @@
1
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
1
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
2
  import { cn as t } from "../utils/cn.js";
3
- import { ChevronUp as p, ChevronDown as f } from "lucide-react";
4
- function C({
5
- data: h,
6
- columns: g,
7
- className: n,
3
+ import { ChevronUp as v, ChevronDown as N } from "lucide-react";
4
+ import T from "./table-empty.js";
5
+ import C from "./table-end.js";
6
+ import j from "./table-load-more.js";
7
+ import E from "./table-loading.js";
8
+ const S = {
9
+ default: {
10
+ table: "bg-white dark:bg-gray-900",
11
+ header: "bg-gray-50 dark:bg-gray-800",
12
+ row: "hover:bg-gray-50/50 dark:hover:bg-gray-800/50",
13
+ border: "border-gray-200 dark:border-gray-700"
14
+ },
15
+ bordered: {
16
+ table: "bg-white dark:bg-gray-900 border-2",
17
+ header: "bg-gray-100 dark:bg-gray-800",
18
+ row: "hover:bg-gray-50 dark:hover:bg-gray-800/50 border",
19
+ border: "border-gray-300 dark:border-gray-600"
20
+ },
21
+ striped: {
22
+ table: "bg-white dark:bg-gray-900",
23
+ header: "bg-gradient-to-r from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-850",
24
+ row: "odd:bg-gray-50/30 even:bg-white hover:bg-blue-50/30 dark:odd:bg-gray-800/30 dark:even:bg-gray-900 dark:hover:bg-gray-700/50",
25
+ border: "border-gray-200 dark:border-gray-700"
26
+ },
27
+ glass: {
28
+ table: "bg-white/60 dark:bg-gray-900/60 backdrop-blur-sm",
29
+ header: "bg-white/40 dark:bg-gray-800/40",
30
+ row: "hover:bg-white/30 dark:hover:bg-gray-700/30",
31
+ border: "border-white/20 dark:border-gray-700/50"
32
+ }
33
+ };
34
+ function F({
35
+ data: g,
36
+ columns: b,
37
+ className: p,
8
38
  onSort: y,
9
- sortKey: s,
10
- sortDirection: b,
11
- loading: c,
12
- emptyMessage: x = "No data available",
13
- variant: o = "default"
39
+ sortKey: o,
40
+ sortDirection: h,
41
+ loading: i,
42
+ emptyMessage: c = "No data available",
43
+ variant: n = "default",
44
+ total: m,
45
+ hasMore: k,
46
+ onLoadMore: x,
47
+ loadingMore: f
14
48
  }) {
15
- const k = (e) => {
16
- if (!e.sortable || !y) return;
17
- const l = e.key;
18
- y(l, s === l && b === "asc" ? "desc" : "asc");
19
- }, d = {
20
- default: {
21
- table: "bg-white dark:bg-gray-900",
22
- header: "bg-gray-50 dark:bg-gray-800",
23
- row: "hover:bg-gray-50/50 dark:hover:bg-gray-800/50",
24
- border: "border-gray-200 dark:border-gray-700"
25
- },
26
- bordered: {
27
- table: "bg-white dark:bg-gray-900 border-2",
28
- header: "bg-gray-100 dark:bg-gray-800",
29
- row: "hover:bg-gray-50 dark:hover:bg-gray-800/50 border",
30
- border: "border-gray-300 dark:border-gray-600"
31
- },
32
- striped: {
33
- table: "bg-white dark:bg-gray-900",
34
- header: "bg-gradient-to-r from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-850",
35
- row: "odd:bg-gray-50/30 even:bg-white hover:bg-blue-50/30 dark:odd:bg-gray-800/30 dark:even:bg-gray-900 dark:hover:bg-gray-700/50",
36
- border: "border-gray-200 dark:border-gray-700"
37
- }
38
- }[o];
39
- return /* @__PURE__ */ r("div", { className: t("w-full overflow-x-auto rounded-lg border", d.border, n), children: /* @__PURE__ */ i("table", { className: t("w-full", d.table), children: [
40
- /* @__PURE__ */ r("thead", { className: d.header, children: /* @__PURE__ */ r("tr", { children: g.map((e) => /* @__PURE__ */ r(
41
- "th",
42
- {
43
- className: t(
44
- "px-4 py-3 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",
45
- e.sortable && "cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",
46
- e.align === "center" && "text-center",
47
- e.align === "right" && "text-right",
48
- e.width
49
- ),
50
- style: { width: e.width },
51
- onClick: () => k(e),
52
- children: /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
53
- e.header,
54
- e.sortable && /* @__PURE__ */ i("span", { className: "ml-1 inline-flex flex-col", children: [
55
- /* @__PURE__ */ r(
56
- p,
57
- {
58
- className: t(
59
- "h-3 w-3 -mb-1",
60
- s === e.key && b === "asc" ? "text-blue-500" : "text-gray-400"
61
- )
62
- }
63
- ),
64
- /* @__PURE__ */ r(
65
- f,
66
- {
67
- className: t(
68
- "h-3 w-3",
69
- s === e.key && b === "desc" ? "text-blue-500" : "text-gray-400"
70
- )
71
- }
72
- )
49
+ const w = (r) => {
50
+ if (!r.sortable || !y) return;
51
+ const s = r.key;
52
+ y(s, o === s && h === "asc" ? "desc" : "asc");
53
+ }, d = S[n];
54
+ return /* @__PURE__ */ l("div", { className: t("w-full", p), children: [
55
+ /* @__PURE__ */ e("div", { className: t("overflow-x-auto rounded-lg border", d.border), children: /* @__PURE__ */ l("table", { className: t("w-full", d.table), children: [
56
+ /* @__PURE__ */ e("thead", { className: d.header, children: /* @__PURE__ */ e("tr", { children: b.map((r) => /* @__PURE__ */ e(
57
+ "th",
58
+ {
59
+ className: t(
60
+ "px-3 py-2 sm:px-4 sm:py-3 text-left text-xs sm:text-sm font-semibold text-gray-700 dark:text-gray-300",
61
+ r.sortable && "cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",
62
+ r.align === "center" && "text-center",
63
+ r.align === "right" && "text-right",
64
+ r.width
65
+ ),
66
+ style: { width: r.width },
67
+ onClick: () => w(r),
68
+ children: /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
69
+ r.header,
70
+ r.sortable && /* @__PURE__ */ l("span", { className: "ml-1 inline-flex flex-col", children: [
71
+ /* @__PURE__ */ e(
72
+ v,
73
+ {
74
+ className: t(
75
+ "h-3 w-3 -mb-1",
76
+ o === r.key && h === "asc" ? "text-blue-500" : "text-gray-400 dark:text-gray-600"
77
+ )
78
+ }
79
+ ),
80
+ /* @__PURE__ */ e(
81
+ N,
82
+ {
83
+ className: t(
84
+ "h-3 w-3",
85
+ o === r.key && h === "desc" ? "text-blue-500" : "text-gray-400 dark:text-gray-600"
86
+ )
87
+ }
88
+ )
89
+ ] })
73
90
  ] })
74
- ] })
75
- },
76
- e.key
77
- )) }) }),
78
- /* @__PURE__ */ r("tbody", { children: c ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: g.length, className: "px-4 py-8 text-center", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "h-6 w-6 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500" }) }) }) }) : h.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r(
79
- "td",
80
- {
81
- colSpan: g.length,
82
- className: "px-4 py-8 text-center text-gray-500 dark:text-gray-400",
83
- children: x
84
- }
85
- ) }) : h.map((e, l) => /* @__PURE__ */ r(
86
- "tr",
87
- {
88
- className: t(
89
- "transition-colors",
90
- d.row,
91
- o === "bordered" && d.border
92
- ),
93
- children: g.map((a) => /* @__PURE__ */ r(
94
- "td",
95
- {
96
- className: t(
97
- "px-4 py-3 text-sm text-gray-700 dark:text-gray-300",
98
- a.align === "center" && "text-center",
99
- a.align === "right" && "text-right"
100
- ),
101
- children: a.render ? a.render(e[a.key], e) : e[a.key]
102
- },
103
- a.key
104
- ))
105
- },
106
- l
107
- )) })
108
- ] }) });
91
+ },
92
+ r.key
93
+ )) }) }),
94
+ /* @__PURE__ */ e("tbody", { children: i ? /* @__PURE__ */ e(E, { colSpan: b.length }) : g.length === 0 ? /* @__PURE__ */ e(T, { colSpan: b.length, message: c }) : g.map((r, s) => /* @__PURE__ */ e(
95
+ "tr",
96
+ {
97
+ className: t(
98
+ "transition-colors",
99
+ d.row,
100
+ n === "bordered" && d.border
101
+ ),
102
+ children: b.map((a) => /* @__PURE__ */ e(
103
+ "td",
104
+ {
105
+ className: t(
106
+ "px-3 py-2 sm:px-4 sm:py-3 text-xs sm:text-sm text-gray-700 dark:text-gray-300",
107
+ a.align === "center" && "text-center",
108
+ a.align === "right" && "text-right"
109
+ ),
110
+ children: a.render ? a.render(r[a.key], r) : r[a.key]
111
+ },
112
+ a.key
113
+ ))
114
+ },
115
+ s
116
+ )) })
117
+ ] }) }),
118
+ !i && g.length > 0 && k && x && /* @__PURE__ */ e(j, { onLoadMore: x, loading: f }),
119
+ !i && g.length > 0 && k === !1 && /* @__PURE__ */ e(C, { total: m })
120
+ ] });
109
121
  }
110
122
  export {
111
- C as default
123
+ T as TableEmpty,
124
+ C as TableEnd,
125
+ j as TableLoadMore,
126
+ E as TableLoading,
127
+ F as default
112
128
  };
@@ -0,0 +1,22 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { cn as m } from "../utils/cn.js";
3
+ function n({
4
+ message: r = "No data available",
5
+ className: a,
6
+ colSpan: e
7
+ }) {
8
+ return /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t(
9
+ "td",
10
+ {
11
+ colSpan: e,
12
+ className: m(
13
+ "px-3 py-4 sm:px-4 sm:py-8 text-center text-gray-500 dark:text-gray-400",
14
+ a
15
+ ),
16
+ children: r
17
+ }
18
+ ) });
19
+ }
20
+ export {
21
+ n as default
22
+ };
@@ -0,0 +1,18 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { cn as m } from "../utils/cn.js";
3
+ function n({ message: t, className: r, total: e }) {
4
+ const a = e != null ? `All ${e} items loaded` : "No more data";
5
+ return /* @__PURE__ */ s(
6
+ "div",
7
+ {
8
+ className: m(
9
+ "py-3 sm:py-4 text-center text-xs sm:text-sm text-gray-400 dark:text-gray-500",
10
+ r
11
+ ),
12
+ children: t ?? a
13
+ }
14
+ );
15
+ }
16
+ export {
17
+ n as default
18
+ };
@@ -0,0 +1,17 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { cn as a } from "../utils/cn.js";
3
+ import i from "../hooks/useInViewport.js";
4
+ function l({ onLoadMore: e, loading: o, className: t }) {
5
+ const n = i(e, { rootMargin: "200px" });
6
+ return /* @__PURE__ */ r(
7
+ "div",
8
+ {
9
+ ref: n,
10
+ className: a("flex items-center justify-center py-4", t),
11
+ children: o && /* @__PURE__ */ r("div", { className: "h-5 w-5 animate-spin rounded-full border-2 border-gray-300 dark:border-gray-700 border-t-blue-500" })
12
+ }
13
+ );
14
+ }
15
+ export {
16
+ l as default
17
+ };
@@ -0,0 +1,8 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { cn as a } from "../utils/cn.js";
3
+ function i({ className: r, colSpan: t }) {
4
+ return /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: t, className: a("px-3 py-4 sm:px-4 sm:py-8 text-center", r), children: /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "h-6 w-6 animate-spin rounded-full border-2 border-gray-300 dark:border-gray-700 border-t-blue-500" }) }) }) });
5
+ }
6
+ export {
7
+ i as default
8
+ };
@@ -0,0 +1 @@
1
+