@lazar-ui/kit 0.4.0 → 0.5.0
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/CHANGELOG.md +19 -0
- package/dist/Button-BYnrV9av.mjs +52 -0
- package/dist/Chip-DLfYGIQG.mjs +51 -0
- package/dist/Chip.css +1 -0
- package/dist/button.js +2 -50
- package/dist/chip.d.ts +37 -0
- package/dist/chip.js +4 -0
- package/dist/dialog.js +2 -2
- package/dist/drawer.js +21 -21
- package/dist/input.d.ts +16 -0
- package/dist/input.js +162 -71
- package/dist/lazar-ui-provider.d.ts +29 -9
- package/dist/lazar-ui-provider.js +2 -2
- package/dist/pagination.js +19 -19
- package/dist/select.js +28 -28
- package/dist/table.css +1 -1
- package/dist/table.d.ts +59 -9
- package/dist/table.js +71 -32
- package/dist/useLocale-CJh-krrY.mjs +106 -0
- package/package.json +3 -5
- package/dist/useLocale-DdHNhmvT.mjs +0 -70
- /package/dist/{button.css → Button.css} +0 -0
package/dist/table.d.ts
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Table.ActiveFilters — displays active filter chips with individual remove buttons
|
|
5
|
+
* and an optional "Clear all" button.
|
|
6
|
+
*
|
|
7
|
+
* Returns `null` when there are no active filters.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Table.ActiveFilters
|
|
12
|
+
* filters={[
|
|
13
|
+
* { key: 'status', label: 'Status', value: 'Active' },
|
|
14
|
+
* { key: 'role', label: 'Role', value: 'Admin' },
|
|
15
|
+
* ]}
|
|
16
|
+
* onRemove={(key) => console.log('remove', key)}
|
|
17
|
+
* onClearAll={() => console.log('clear all')}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const ActiveFilters: default_2.FC<IProps>;
|
|
22
|
+
|
|
3
23
|
/**
|
|
4
24
|
* Table cell. Must be used as a child of `<Table.Row>`.
|
|
5
25
|
* Supports text alignment and header styling via `as="th"`.
|
|
6
26
|
*/
|
|
7
|
-
declare const Cell: default_2.FC<
|
|
27
|
+
declare const Cell: default_2.FC<IProps_2>;
|
|
28
|
+
|
|
29
|
+
export declare interface IFilterItem {
|
|
30
|
+
key: string;
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
8
34
|
|
|
9
|
-
declare interface IProps
|
|
35
|
+
declare interface IProps {
|
|
36
|
+
filters: IFilterItem[];
|
|
37
|
+
onRemove: (key: string) => void;
|
|
38
|
+
onClearAll?: () => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare interface IProps_2 extends default_2.PropsWithChildren {
|
|
10
42
|
/** Text alignment. */
|
|
11
43
|
align?: 'left' | 'center' | 'right';
|
|
12
44
|
/** HTML tag: `'td'` (default) or `'th'`. */
|
|
@@ -17,7 +49,10 @@ declare interface IProps extends default_2.PropsWithChildren {
|
|
|
17
49
|
width?: string;
|
|
18
50
|
}
|
|
19
51
|
|
|
20
|
-
declare interface
|
|
52
|
+
declare interface IProps_3 extends default_2.PropsWithChildren {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare interface IProps_4 extends default_2.PropsWithChildren {
|
|
21
56
|
}
|
|
22
57
|
|
|
23
58
|
export declare interface ITableProps extends default_2.PropsWithChildren {
|
|
@@ -27,34 +62,49 @@ export declare interface ITableProps extends default_2.PropsWithChildren {
|
|
|
27
62
|
* Table row. Must be used as a child of `<Table>`.
|
|
28
63
|
* Accepts `<Table.Cell>` children.
|
|
29
64
|
*/
|
|
30
|
-
declare const Row: default_2.FC<
|
|
65
|
+
declare const Row: default_2.FC<IProps_3>;
|
|
31
66
|
|
|
32
67
|
export declare const Table: TTableCompoundComponent;
|
|
33
68
|
|
|
34
69
|
/**
|
|
35
70
|
* Table container. Renders an HTML `<table>` with striped rows and hover effects.
|
|
36
71
|
*
|
|
72
|
+
* Supports an optional `<Table.Toolbar>` child rendered above the table.
|
|
37
73
|
* Uses compound component pattern via `<Table.Row>` and `<Table.Cell>`.
|
|
38
74
|
*
|
|
39
75
|
* @example
|
|
40
76
|
* ```tsx
|
|
41
77
|
* <Table>
|
|
78
|
+
* <Table.Toolbar>
|
|
79
|
+
* <Input placeholder="Search..." />
|
|
80
|
+
* </Table.Toolbar>
|
|
42
81
|
* <Table.Row>
|
|
43
82
|
* <Table.Cell as="th">Name</Table.Cell>
|
|
44
|
-
* <Table.Cell as="th">Role</Table.Cell>
|
|
45
|
-
* </Table.Row>
|
|
46
|
-
* <Table.Row>
|
|
47
|
-
* <Table.Cell>John</Table.Cell>
|
|
48
|
-
* <Table.Cell>Developer</Table.Cell>
|
|
49
83
|
* </Table.Row>
|
|
50
84
|
* </Table>
|
|
51
85
|
* ```
|
|
52
86
|
*/
|
|
53
87
|
declare const Table_2: default_2.FC<ITableProps>;
|
|
54
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Table.Toolbar — a simple flex-wrapper that sits above the Table
|
|
91
|
+
* and contains arbitrary controls (inputs, buttons, filters, etc.).
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <Table.Toolbar>
|
|
96
|
+
* <Input placeholder="Search..." />
|
|
97
|
+
* <Button>Export</Button>
|
|
98
|
+
* </Table.Toolbar>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare const Toolbar: default_2.FC<IProps_4>;
|
|
102
|
+
|
|
55
103
|
declare type TTableCompoundComponent = typeof Table_2 & {
|
|
104
|
+
ActiveFilters: typeof ActiveFilters;
|
|
56
105
|
Cell: typeof Cell;
|
|
57
106
|
Row: typeof Row;
|
|
107
|
+
Toolbar: typeof Toolbar;
|
|
58
108
|
};
|
|
59
109
|
|
|
60
110
|
export { }
|
package/dist/table.js
CHANGED
|
@@ -1,40 +1,79 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import p from "
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { jsxs as h, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import T, { useCallback as p } from "react";
|
|
3
|
+
import { B as u } from "./Button-BYnrV9av.mjs";
|
|
4
|
+
import { C as L } from "./Chip-DLfYGIQG.mjs";
|
|
5
|
+
import { u as y } from "./useLocale-CJh-krrY.mjs";
|
|
6
|
+
import R from "clsx";
|
|
7
|
+
import { g as w } from "./getVariantClassName-D7Nhpuec.mjs";
|
|
5
8
|
import { i } from "./isValidReactNode-CmYwTWCE.mjs";
|
|
6
9
|
import "./camelCase-PtIYufW8.mjs";
|
|
7
|
-
import './table.css';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
import './table.css';const $ = "Table.ActiveFilters", v = "_root_4qb7d_5", x = {
|
|
11
|
+
root: v
|
|
12
|
+
}, b = (t) => {
|
|
13
|
+
const { filters: e, onClearAll: o, onRemove: r } = t, c = y(), l = p(
|
|
14
|
+
(a) => () => {
|
|
15
|
+
r(a);
|
|
16
|
+
},
|
|
17
|
+
[r]
|
|
18
|
+
), m = p(() => {
|
|
19
|
+
o?.();
|
|
20
|
+
}, [o]);
|
|
21
|
+
return e.length === 0 ? null : /* @__PURE__ */ h("div", { className: x.root, children: [
|
|
22
|
+
e.map((a) => /* @__PURE__ */ h(L, { onDelete: l(a.key), children: [
|
|
23
|
+
a.label,
|
|
24
|
+
": ",
|
|
25
|
+
a.value
|
|
26
|
+
] }, a.key)),
|
|
27
|
+
o && /* @__PURE__ */ n(u, { mode: "text", size: "sm", onClick: m, children: c.Table.ActiveFilters.clearAll })
|
|
28
|
+
] });
|
|
29
|
+
};
|
|
30
|
+
b.displayName = $;
|
|
31
|
+
var s = /* @__PURE__ */ ((t) => (t.CELL = "Table.Cell", t.ROW = "Table.Row", t.TOOLBAR = "Table.Toolbar", t))(s || {});
|
|
32
|
+
const O = "_root_lmxwt_8", k = "_header_lmxwt_17", B = "_alignLeft_lmxwt_21", F = "_alignRight_lmxwt_24", D = "_alignCenter_lmxwt_27", _ = {
|
|
33
|
+
root: O,
|
|
34
|
+
header: k,
|
|
35
|
+
alignLeft: B,
|
|
36
|
+
alignRight: F,
|
|
37
|
+
alignCenter: D
|
|
38
|
+
}, g = (t) => {
|
|
39
|
+
const { align: e = "left", as: o = "td", children: r, title: c, width: l } = t, m = R(_.root, w("align", e, _), {
|
|
40
|
+
[_.header]: o === "th"
|
|
17
41
|
});
|
|
18
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ n(o, { className: m, title: c, width: l, children: r });
|
|
43
|
+
};
|
|
44
|
+
g.displayName = s.CELL;
|
|
45
|
+
const E = "_root_t4731_5", I = {
|
|
46
|
+
root: E
|
|
47
|
+
}, A = (t) => {
|
|
48
|
+
const { children: e } = t, o = (r) => i(s.CELL, r) ? r : null;
|
|
49
|
+
return /* @__PURE__ */ n("tr", { className: I.root, children: T.Children.map(e, o) });
|
|
19
50
|
};
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
root:
|
|
23
|
-
},
|
|
24
|
-
const { children:
|
|
25
|
-
return /* @__PURE__ */
|
|
51
|
+
A.displayName = s.ROW;
|
|
52
|
+
const M = "Table.Toolbar", P = "_root_d4szt_6", W = {
|
|
53
|
+
root: P
|
|
54
|
+
}, f = (t) => {
|
|
55
|
+
const { children: e } = t;
|
|
56
|
+
return /* @__PURE__ */ n("div", { className: W.root, children: e });
|
|
26
57
|
};
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
58
|
+
f.displayName = M;
|
|
59
|
+
const Y = "Table", j = "_wrapper_17sd8_5", z = "_root_17sd8_11", C = {
|
|
60
|
+
wrapper: j,
|
|
61
|
+
root: z
|
|
62
|
+
}, N = (t) => {
|
|
63
|
+
const { children: e } = t, o = T.Children.toArray(e), r = o.find(
|
|
64
|
+
(l) => i(s.TOOLBAR, l, !1)
|
|
65
|
+
), c = o.filter((l) => !i(s.TOOLBAR, l, !1)).filter((l) => i(s.ROW, l, !0));
|
|
66
|
+
return /* @__PURE__ */ h("div", { className: C.wrapper, children: [
|
|
67
|
+
r,
|
|
68
|
+
/* @__PURE__ */ n("table", { className: C.root, children: /* @__PURE__ */ n("tbody", { children: c }) })
|
|
69
|
+
] });
|
|
33
70
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
71
|
+
N.displayName = Y;
|
|
72
|
+
const d = N;
|
|
73
|
+
d.ActiveFilters = b;
|
|
74
|
+
d.Cell = g;
|
|
75
|
+
d.Row = A;
|
|
76
|
+
d.Toolbar = f;
|
|
38
77
|
export {
|
|
39
|
-
|
|
78
|
+
d as Table
|
|
40
79
|
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as u, useMemo as l, useEffect as g, useContext as f } from "react";
|
|
3
|
+
const c = u(null), a = {
|
|
4
|
+
Chip: {
|
|
5
|
+
remove: "Remove"
|
|
6
|
+
},
|
|
7
|
+
Dialog: {
|
|
8
|
+
close: "Close"
|
|
9
|
+
},
|
|
10
|
+
Drawer: {
|
|
11
|
+
Header: {
|
|
12
|
+
close: "Close"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
Input: {
|
|
16
|
+
Password: {
|
|
17
|
+
passwordHide: "Hide password",
|
|
18
|
+
passwordShow: "Show password"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
Pagination: {
|
|
22
|
+
Item: {
|
|
23
|
+
page: "Page {page}"
|
|
24
|
+
},
|
|
25
|
+
items: "items",
|
|
26
|
+
label: "Pagination",
|
|
27
|
+
next: "Next page",
|
|
28
|
+
of: "of",
|
|
29
|
+
prev: "Previous page"
|
|
30
|
+
},
|
|
31
|
+
Select: {
|
|
32
|
+
clear: "Clear",
|
|
33
|
+
noOptions: "No options",
|
|
34
|
+
placeholder: "Select..."
|
|
35
|
+
},
|
|
36
|
+
Table: {
|
|
37
|
+
ActiveFilters: {
|
|
38
|
+
clearAll: "Clear all",
|
|
39
|
+
remove: "Remove filter:"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, v = {
|
|
43
|
+
Chip: {
|
|
44
|
+
remove: "Удалить"
|
|
45
|
+
},
|
|
46
|
+
Dialog: {
|
|
47
|
+
close: "Закрыть"
|
|
48
|
+
},
|
|
49
|
+
Drawer: {
|
|
50
|
+
Header: {
|
|
51
|
+
close: "Закрыть"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
Input: {
|
|
55
|
+
Password: {
|
|
56
|
+
passwordHide: "Скрыть пароль",
|
|
57
|
+
passwordShow: "Показать пароль"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
Pagination: {
|
|
61
|
+
Item: {
|
|
62
|
+
page: "Страница {page}"
|
|
63
|
+
},
|
|
64
|
+
items: "элементов",
|
|
65
|
+
label: "Пагинация",
|
|
66
|
+
next: "Следующая страница",
|
|
67
|
+
of: "из",
|
|
68
|
+
prev: "Предыдущая страница"
|
|
69
|
+
},
|
|
70
|
+
Select: {
|
|
71
|
+
clear: "Очистить",
|
|
72
|
+
noOptions: "Нет вариантов",
|
|
73
|
+
placeholder: "Выберите..."
|
|
74
|
+
},
|
|
75
|
+
Table: {
|
|
76
|
+
ActiveFilters: {
|
|
77
|
+
clearAll: "Очистить всё",
|
|
78
|
+
remove: "Удалить фильтр:"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, w = { en: a, ru: v }, i = (e, n) => {
|
|
82
|
+
const t = { ...e };
|
|
83
|
+
for (const s of Object.keys(n)) {
|
|
84
|
+
const o = n[s], r = e[s];
|
|
85
|
+
o && typeof o == "object" && !Array.isArray(o) && r && typeof r == "object" && !Array.isArray(r) ? t[s] = i(
|
|
86
|
+
r,
|
|
87
|
+
o
|
|
88
|
+
) : o !== void 0 && (t[s] = o);
|
|
89
|
+
}
|
|
90
|
+
return t;
|
|
91
|
+
}, h = (e) => l(() => e ? typeof e == "string" ? w[e] ?? a : i(a, e) : a, [e]), C = (e) => {
|
|
92
|
+
const { children: n, theme: t = "light", locale: s, themeTarget: o } = e, r = h(s);
|
|
93
|
+
g(() => {
|
|
94
|
+
const d = o ?? document.documentElement;
|
|
95
|
+
d.dataset.theme = t;
|
|
96
|
+
}, [t, o]);
|
|
97
|
+
const p = l(() => ({ locale: r, theme: t }), [t, r]);
|
|
98
|
+
return /* @__PURE__ */ m(c.Provider, { value: p, children: n });
|
|
99
|
+
};
|
|
100
|
+
C.displayName = "LazarUiProvider";
|
|
101
|
+
const y = () => f(c)?.locale ?? a;
|
|
102
|
+
export {
|
|
103
|
+
c as C,
|
|
104
|
+
C as L,
|
|
105
|
+
y as u
|
|
106
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazar-ui/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A component library for building admin panels, dashboards, and internal tools.",
|
|
6
6
|
"homepage": "https://lazar-ui.github.io/docs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build": "vite build",
|
|
39
39
|
"check-types": "tsc --noEmit",
|
|
40
40
|
"clean": "rm -rf node_modules",
|
|
41
|
-
"dev": "
|
|
41
|
+
"dev": "",
|
|
42
42
|
"lint": "eslint src --max-warnings 100 || true",
|
|
43
43
|
"lint:styles": "stylelint \"src/components/**/*.scss\"",
|
|
44
44
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
@@ -48,9 +48,7 @@
|
|
|
48
48
|
"gen:component:ai": "node scripts/generate-component.mjs",
|
|
49
49
|
"test": "vitest run",
|
|
50
50
|
"test:coverage": "vitest run --coverage",
|
|
51
|
-
"test:watch": "vitest"
|
|
52
|
-
"tsm": "typed-scss-modules src",
|
|
53
|
-
"watch:tsm": "typed-scss-modules src --watch"
|
|
51
|
+
"test:watch": "vitest"
|
|
54
52
|
},
|
|
55
53
|
"devDependencies": {
|
|
56
54
|
"@repo/eslint-config": "*",
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as g, useMemo as i, useEffect as u, useContext as m } from "react";
|
|
3
|
-
const c = g(null), n = {
|
|
4
|
-
dialog: {
|
|
5
|
-
close: "Close"
|
|
6
|
-
},
|
|
7
|
-
input: {
|
|
8
|
-
passwordHide: "Hide password",
|
|
9
|
-
passwordShow: "Show password"
|
|
10
|
-
},
|
|
11
|
-
pagination: {
|
|
12
|
-
next: "Next page",
|
|
13
|
-
page: "Page {page}",
|
|
14
|
-
pagination: "Pagination",
|
|
15
|
-
prev: "Previous page"
|
|
16
|
-
},
|
|
17
|
-
select: {
|
|
18
|
-
clear: "Clear",
|
|
19
|
-
noOptions: "No options",
|
|
20
|
-
placeholder: "Select..."
|
|
21
|
-
}
|
|
22
|
-
}, f = {
|
|
23
|
-
dialog: {
|
|
24
|
-
close: "Закрыть"
|
|
25
|
-
},
|
|
26
|
-
input: {
|
|
27
|
-
passwordHide: "Скрыть пароль",
|
|
28
|
-
passwordShow: "Показать пароль"
|
|
29
|
-
},
|
|
30
|
-
pagination: {
|
|
31
|
-
next: "Следующая страница",
|
|
32
|
-
page: "Страница {page}",
|
|
33
|
-
pagination: "Пагинация",
|
|
34
|
-
prev: "Предыдущая страница"
|
|
35
|
-
},
|
|
36
|
-
select: {
|
|
37
|
-
clear: "Очистить",
|
|
38
|
-
noOptions: "Нет вариантов",
|
|
39
|
-
placeholder: "Выберите..."
|
|
40
|
-
}
|
|
41
|
-
}, h = { en: n, ru: f }, x = (e) => i(() => {
|
|
42
|
-
if (!e)
|
|
43
|
-
return n;
|
|
44
|
-
if (typeof e == "string")
|
|
45
|
-
return h[e] ?? n;
|
|
46
|
-
const r = { ...n };
|
|
47
|
-
for (const t of Object.keys(e)) {
|
|
48
|
-
const o = e[t];
|
|
49
|
-
o && typeof o == "object" && !Array.isArray(o) && (r[t] = {
|
|
50
|
-
...r[t],
|
|
51
|
-
...o
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return r;
|
|
55
|
-
}, [e]), w = (e) => {
|
|
56
|
-
const { children: r, theme: t = "light", locale: o, themeTarget: s } = e, a = x(o);
|
|
57
|
-
u(() => {
|
|
58
|
-
const d = s ?? document.documentElement;
|
|
59
|
-
d.dataset.theme = t;
|
|
60
|
-
}, [t, s]);
|
|
61
|
-
const p = i(() => ({ locale: a, theme: t }), [t, a]);
|
|
62
|
-
return /* @__PURE__ */ l(c.Provider, { value: p, children: r });
|
|
63
|
-
};
|
|
64
|
-
w.displayName = "LazarUiProvider";
|
|
65
|
-
const y = () => m(c)?.locale ?? n;
|
|
66
|
-
export {
|
|
67
|
-
c as C,
|
|
68
|
-
w as L,
|
|
69
|
-
y as u
|
|
70
|
-
};
|
|
File without changes
|