@pnkx-lib/ui 1.0.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.
@@ -0,0 +1,249 @@
1
+ import { j as a, I, _ as w, u as $, c as k } from "./AntdIcon-BppsuyXF.js";
2
+ import { Button as F, Cascader as M, Card as b, Empty as V, Table as _, Modal as L, Tooltip as D, Tabs as K, Space as S, Skeleton as f, Popover as H, Badge as R } from "antd";
3
+ import * as g from "react";
4
+ import y, { useEffect as G } from "react";
5
+ const C = (e) => /* @__PURE__ */ a.jsx(F, { ...e }), ne = (e) => {
6
+ const {
7
+ customStyleContainer: t,
8
+ customStyleCascader: s,
9
+ options: n = [],
10
+ ...r
11
+ } = e;
12
+ return /* @__PURE__ */ a.jsx("div", { className: t, children: /* @__PURE__ */ a.jsx(
13
+ M,
14
+ {
15
+ options: n,
16
+ className: s,
17
+ ...r
18
+ }
19
+ ) });
20
+ }, re = ({
21
+ data: e,
22
+ columns: t,
23
+ loading: s = !1,
24
+ totalItems: n,
25
+ filters: r,
26
+ onChangePage: d,
27
+ onChangePageSize: u,
28
+ onSort: c,
29
+ rowsSelected: m,
30
+ onSelect: o,
31
+ onRowClick: x,
32
+ ...l
33
+ }) => {
34
+ const j = {
35
+ current: r.PageIndex,
36
+ pageSize: r.PageSize,
37
+ total: n,
38
+ showSizeChanger: !0,
39
+ onChange: (i, h) => {
40
+ i !== r.PageIndex && d(i), h !== r.PageSize && u(h);
41
+ }
42
+ }, v = {
43
+ selectedRowKeys: m,
44
+ onChange: o
45
+ }, P = (i) => {
46
+ i && i.field && c && c({}, i.field);
47
+ };
48
+ function B(i, h) {
49
+ return (E) => {
50
+ const p = E.target;
51
+ p.closest("input") || // ⛔ Checkbox
52
+ p.closest("button") || // ⛔ Button trong row
53
+ p.closest("svg") || // ⛔ Icon
54
+ p.closest(".ant-checkbox") || // ⛔ AntD checkbox
55
+ p.closest("a") || h == null || h(i);
56
+ };
57
+ }
58
+ return /* @__PURE__ */ a.jsx(a.Fragment, { children: e.length === 0 ? /* @__PURE__ */ a.jsx(b, { children: /* @__PURE__ */ a.jsx(V, {}) }) : /* @__PURE__ */ a.jsx(
59
+ _,
60
+ {
61
+ dataSource: e,
62
+ columns: t,
63
+ pagination: j,
64
+ loading: s,
65
+ rowSelection: v,
66
+ onChange: P,
67
+ onRow: (i) => ({
68
+ onClick: B(i, x)
69
+ }),
70
+ ...l
71
+ }
72
+ ) });
73
+ }, oe = ({
74
+ children: e,
75
+ onOk: t,
76
+ onSubmit: s,
77
+ ...n
78
+ }) => /* @__PURE__ */ a.jsx(L, { onOk: s || t, ...n, children: /* @__PURE__ */ a.jsx("div", { className: "max-h-[20rem] overflow-y-auto", children: s ? /* @__PURE__ */ a.jsx("form", { onSubmit: s, children: e }) : e }) }), ce = ({ children: e, ...t }) => /* @__PURE__ */ a.jsx(D, { ...t, children: e }), T = (e) => {
79
+ let t;
80
+ const s = /* @__PURE__ */ new Set(), n = (o, x) => {
81
+ const l = typeof o == "function" ? o(t) : o;
82
+ if (!Object.is(l, t)) {
83
+ const j = t;
84
+ t = x ?? (typeof l != "object" || l === null) ? l : Object.assign({}, t, l), s.forEach((v) => v(t, j));
85
+ }
86
+ }, r = () => t, c = { setState: n, getState: r, getInitialState: () => m, subscribe: (o) => (s.add(o), () => s.delete(o)) }, m = t = e(n, r, c);
87
+ return c;
88
+ }, q = (e) => e ? T(e) : T, J = (e) => e;
89
+ function Q(e, t = J) {
90
+ const s = y.useSyncExternalStore(
91
+ e.subscribe,
92
+ () => t(e.getState()),
93
+ () => t(e.getInitialState())
94
+ );
95
+ return y.useDebugValue(s), s;
96
+ }
97
+ const N = (e) => {
98
+ const t = q(e), s = (n) => Q(t, n);
99
+ return Object.assign(s, t), s;
100
+ }, U = (e) => e ? N(e) : N, W = U((e) => ({
101
+ activeTabKey: void 0,
102
+ // giá trị mặc định
103
+ setActiveTabKey: (t) => e({ activeTabKey: t })
104
+ })), ie = ({
105
+ items: e,
106
+ lazyRender: t = !1,
107
+ defaultActiveKey: s,
108
+ ...n
109
+ }) => {
110
+ var c;
111
+ const { activeTabKey: r, setActiveTabKey: d } = W(), u = (s == null ? void 0 : s.toString()) || ((c = e[0]) == null ? void 0 : c.key);
112
+ return G(() => {
113
+ !r && u && d(u);
114
+ }, [r, u, d]), /* @__PURE__ */ a.jsx(
115
+ K,
116
+ {
117
+ items: e,
118
+ destroyInactiveTabPane: t,
119
+ activeKey: r,
120
+ defaultActiveKey: s,
121
+ onChange: (m) => d(m),
122
+ ...n
123
+ }
124
+ );
125
+ }, le = ({ type: e }) => /* @__PURE__ */ a.jsx(a.Fragment, { children: e === "table" ? /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
126
+ /* @__PURE__ */ a.jsx(S, { style: { width: "100%" }, children: /* @__PURE__ */ a.jsx(
127
+ f.Input,
128
+ {
129
+ size: "small",
130
+ block: !0,
131
+ active: !0,
132
+ style: { width: "15rem", marginBottom: "15px" }
133
+ }
134
+ ) }),
135
+ /* @__PURE__ */ a.jsx(b, { children: /* @__PURE__ */ a.jsx(S, { direction: "vertical", size: "middle", style: { width: "100%" }, children: Array.from({ length: 10 }).map((t, s) => /* @__PURE__ */ a.jsx(f.Input, { size: "small", block: !0, active: !0 }, s)) }) }),
136
+ /* @__PURE__ */ a.jsx(
137
+ "div",
138
+ {
139
+ style: {
140
+ width: "100%",
141
+ display: "flex",
142
+ justifyContent: "flex-end",
143
+ marginTop: "20px"
144
+ },
145
+ children: /* @__PURE__ */ a.jsx(
146
+ f.Input,
147
+ {
148
+ size: "small",
149
+ active: !0,
150
+ style: { width: "20rem" }
151
+ }
152
+ )
153
+ }
154
+ )
155
+ ] }) : /* @__PURE__ */ a.jsx(b, { children: /* @__PURE__ */ a.jsx("div", { style: { display: "grid", rowGap: 8 }, children: Array.from({ length: 3 }).map((t, s) => /* @__PURE__ */ a.jsx(f.Input, { size: "small", block: !0, active: !0 }, s)) }) }) }), de = (e) => {
156
+ const { customStyleContainer: t, customStylePopover: s, ...n } = e;
157
+ return /* @__PURE__ */ a.jsx("div", { className: t, children: /* @__PURE__ */ a.jsx(H, { className: s, ...n }) });
158
+ };
159
+ var X = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z" } }] }, name: "filter", theme: "outlined" }, Y = function(t, s) {
160
+ return /* @__PURE__ */ g.createElement(I, w({}, t, {
161
+ ref: s,
162
+ icon: X
163
+ }));
164
+ }, O = /* @__PURE__ */ g.forwardRef(Y);
165
+ process.env.NODE_ENV !== "production" && (O.displayName = "FilterOutlined");
166
+ var Z = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z" } }] }, name: "search", theme: "outlined" }, A = function(t, s) {
167
+ return /* @__PURE__ */ g.createElement(I, w({}, t, {
168
+ ref: s,
169
+ icon: Z
170
+ }));
171
+ }, z = /* @__PURE__ */ g.forwardRef(A);
172
+ process.env.NODE_ENV !== "production" && (z.displayName = "SearchOutlined");
173
+ const ue = ({
174
+ initialValues: e,
175
+ renderFilterFields: t,
176
+ onSubmit: s,
177
+ onReset: n,
178
+ classNamesContainer: r,
179
+ classNameWrapperForm: d,
180
+ hideDefaultSubmit: u,
181
+ hideResetButton: c
182
+ }) => {
183
+ const { control: m, handleSubmit: o, reset: x, setValue: l } = $({
184
+ defaultValues: e
185
+ });
186
+ return /* @__PURE__ */ a.jsxs("form", { className: d, onSubmit: o(s), children: [
187
+ /* @__PURE__ */ a.jsx("div", { className: r, children: t && t({
188
+ control: m,
189
+ setValue: l,
190
+ handleSubmit: o
191
+ }) }),
192
+ !u && /* @__PURE__ */ a.jsxs("div", { className: "flex justify-end gap-2 mb-3", children: [
193
+ /* @__PURE__ */ a.jsx(
194
+ C,
195
+ {
196
+ icon: /* @__PURE__ */ a.jsx(z, {}),
197
+ className: "px-3 py-1 ",
198
+ color: "blue",
199
+ variant: "solid",
200
+ htmlType: "submit",
201
+ children: "Tìm kiếm"
202
+ }
203
+ ),
204
+ !c && /* @__PURE__ */ a.jsx(
205
+ C,
206
+ {
207
+ icon: /* @__PURE__ */ a.jsx(O, {}),
208
+ className: "px-3 py-1",
209
+ onClick: () => {
210
+ x(), n == null || n();
211
+ },
212
+ children: "Đặt lại"
213
+ }
214
+ )
215
+ ] })
216
+ ] });
217
+ }, me = ({
218
+ children: e,
219
+ className: t,
220
+ size: s
221
+ }) => /* @__PURE__ */ a.jsx(
222
+ "div",
223
+ {
224
+ className: k(s, "mx-auto px-4 sm:px-6 lg:px-8", t),
225
+ children: e
226
+ }
227
+ ), ee = {
228
+ error: "red",
229
+ info: "blue",
230
+ success: "green",
231
+ warning: "yellow"
232
+ }, xe = ({ type: e, ...t }) => {
233
+ const s = e ? ee[e] : void 0;
234
+ return /* @__PURE__ */ a.jsx(R, { color: s, ...t });
235
+ };
236
+ export {
237
+ C as B,
238
+ ne as C,
239
+ oe as M,
240
+ de as P,
241
+ le as S,
242
+ re as T,
243
+ ce as a,
244
+ ie as b,
245
+ ue as c,
246
+ me as d,
247
+ xe as e,
248
+ ee as t
249
+ };