@ztwoint/z-ui 0.1.115 → 0.1.117
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/dist/components/assets/icons/double-chevron-left.js +1 -2
- package/dist/components/assets/icons/double-chevron-right.js +1 -2
- package/dist/components/chart/chart.d.ts +4 -0
- package/dist/components/chart/chart.js +25 -0
- package/dist/components/chart/index.d.ts +2 -0
- package/dist/components/chart-card/builders/bar-chart-builder.d.ts +3 -0
- package/dist/components/chart-card/builders/bar-chart-builder.js +43 -0
- package/dist/components/chart-card/builders/chart-builder-factory.d.ts +5 -0
- package/dist/components/chart-card/builders/chart-builder-factory.js +23 -0
- package/dist/components/chart-card/builders/line-chart-builder.d.ts +3 -0
- package/dist/components/chart-card/builders/line-chart-builder.js +53 -0
- package/dist/components/chart-card/builders/pie-chart-builder.d.ts +3 -0
- package/dist/components/chart-card/builders/pie-chart-builder.js +71 -0
- package/dist/components/chart-card/chart-card-states.d.ts +10 -0
- package/dist/components/chart-card/chart-card-states.js +93 -0
- package/dist/components/chart-card/chart-card.config.types.d.ts +99 -0
- package/dist/components/chart-card/chart-card.d.ts +2 -0
- package/dist/components/chart-card/chart-card.js +72 -0
- package/dist/components/chart-card/chart-card.types.d.ts +12 -0
- package/dist/components/chart-card/config/colors.d.ts +29 -0
- package/dist/components/chart-card/config/colors.js +49 -0
- package/dist/components/chart-card/config/defaults.d.ts +164 -0
- package/dist/components/chart-card/config/defaults.js +156 -0
- package/dist/components/chart-card/index.d.ts +10 -0
- package/dist/components/chart-card/validators/config-validator.d.ts +7 -0
- package/dist/components/chart-card/validators/config-validator.js +40 -0
- package/dist/components/dynamic-table/z2-table-pagination.d.ts +2 -0
- package/dist/components/dynamic-table/z2-table-pagination.js +113 -64
- package/dist/components/dynamic-table/z2-table.js +162 -137
- package/dist/components/skeleton/skeleton.js +5 -5
- package/dist/components/table/components/cell/avatar-cell.js +5 -2
- package/dist/components/table/table-provider.js +3 -0
- package/dist/components/table-card/table-card.js +11 -8
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +153 -130
- package/dist/types/components/chart/chart.d.ts +4 -0
- package/dist/types/components/chart/index.d.ts +2 -0
- package/dist/types/components/chart-card/builders/bar-chart-builder.d.ts +3 -0
- package/dist/types/components/chart-card/builders/chart-builder-factory.d.ts +5 -0
- package/dist/types/components/chart-card/builders/line-chart-builder.d.ts +3 -0
- package/dist/types/components/chart-card/builders/pie-chart-builder.d.ts +3 -0
- package/dist/types/components/chart-card/chart-card-states.d.ts +10 -0
- package/dist/types/components/chart-card/chart-card.config.types.d.ts +99 -0
- package/dist/types/components/chart-card/chart-card.d.ts +2 -0
- package/dist/types/components/chart-card/chart-card.types.d.ts +12 -0
- package/dist/types/components/chart-card/config/colors.d.ts +29 -0
- package/dist/types/components/chart-card/config/defaults.d.ts +164 -0
- package/dist/types/components/chart-card/index.d.ts +10 -0
- package/dist/types/components/chart-card/validators/config-validator.d.ts +7 -0
- package/dist/types/components/dynamic-table/z2-table-pagination.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +3 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ChartOptions } from '../chart-card.config.types';
|
|
2
|
+
export declare const DEFAULT_CHART_HEIGHT = 400;
|
|
3
|
+
export declare const DEFAULT_CHART_WIDTH = "100%";
|
|
4
|
+
export declare const DEFAULT_FONT_FAMILY = "Inter Variable, sans-serif";
|
|
5
|
+
export declare const COMMON_TEXT_STYLE: {
|
|
6
|
+
fontFamily: string;
|
|
7
|
+
color: "#000000";
|
|
8
|
+
};
|
|
9
|
+
export declare function buildTitleConfig(title: string, options?: ChartOptions['title']): {
|
|
10
|
+
text: string;
|
|
11
|
+
textStyle: {
|
|
12
|
+
fontFamily: string;
|
|
13
|
+
fontSize: number;
|
|
14
|
+
fontWeight: number;
|
|
15
|
+
color: string;
|
|
16
|
+
};
|
|
17
|
+
left: "center" | "left" | "right";
|
|
18
|
+
top: number;
|
|
19
|
+
padding: number[];
|
|
20
|
+
} | undefined;
|
|
21
|
+
export declare function buildTooltipConfig(options?: ChartOptions['tooltip']): {
|
|
22
|
+
trigger: "axis" | "item";
|
|
23
|
+
backgroundColor: "#ffffff";
|
|
24
|
+
borderColor: "#d1d1d1";
|
|
25
|
+
borderWidth: number;
|
|
26
|
+
textStyle: {
|
|
27
|
+
fontFamily: string;
|
|
28
|
+
color: "#000000";
|
|
29
|
+
};
|
|
30
|
+
} | undefined;
|
|
31
|
+
export declare function buildLegendConfig(data: string[], hasTitle?: boolean, options?: ChartOptions['legend']): {
|
|
32
|
+
data: string[];
|
|
33
|
+
top: string | number;
|
|
34
|
+
bottom: string | number | undefined;
|
|
35
|
+
left: string | number;
|
|
36
|
+
right: string | number | undefined;
|
|
37
|
+
orient: "horizontal" | "vertical";
|
|
38
|
+
itemGap: number;
|
|
39
|
+
padding: number[];
|
|
40
|
+
textStyle: {
|
|
41
|
+
fontSize: number;
|
|
42
|
+
fontFamily: string;
|
|
43
|
+
color: "#000000";
|
|
44
|
+
};
|
|
45
|
+
itemWidth: number;
|
|
46
|
+
itemHeight: number;
|
|
47
|
+
} | undefined;
|
|
48
|
+
export declare function buildAxisLabelConfig(rotate?: number): {
|
|
49
|
+
rotate?: number | undefined;
|
|
50
|
+
color: "#5d5d5d";
|
|
51
|
+
fontFamily: string;
|
|
52
|
+
fontSize: number;
|
|
53
|
+
};
|
|
54
|
+
export declare function buildAxisLineConfig(show?: boolean): {
|
|
55
|
+
show: boolean;
|
|
56
|
+
lineStyle: {
|
|
57
|
+
color: "#d1d1d1";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare function buildSplitLineConfig(show?: boolean): {
|
|
61
|
+
show: boolean;
|
|
62
|
+
lineStyle: {
|
|
63
|
+
color: "#e7e7e7";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export declare function buildGridConfig(hasTitle: boolean, hasLegend?: boolean, legendPosition?: 'top' | 'bottom' | 'left' | 'right', customGrid?: ChartOptions['grid']): {
|
|
67
|
+
left: string | number;
|
|
68
|
+
right: string | number;
|
|
69
|
+
bottom: string | number;
|
|
70
|
+
top: string | number;
|
|
71
|
+
containLabel: boolean;
|
|
72
|
+
};
|
|
73
|
+
export declare function buildXAxisConfig(data: string[], boundaryGap?: boolean, options?: ChartOptions['xAxis']): {
|
|
74
|
+
show: boolean;
|
|
75
|
+
type?: undefined;
|
|
76
|
+
data?: undefined;
|
|
77
|
+
boundaryGap?: undefined;
|
|
78
|
+
name?: undefined;
|
|
79
|
+
nameLocation?: undefined;
|
|
80
|
+
nameGap?: undefined;
|
|
81
|
+
nameTextStyle?: undefined;
|
|
82
|
+
axisLine?: undefined;
|
|
83
|
+
axisLabel?: undefined;
|
|
84
|
+
splitLine?: undefined;
|
|
85
|
+
} | {
|
|
86
|
+
type: "category";
|
|
87
|
+
data: string[];
|
|
88
|
+
boundaryGap: boolean;
|
|
89
|
+
name: string | undefined;
|
|
90
|
+
nameLocation: "end" | "middle" | "start";
|
|
91
|
+
nameGap: number | undefined;
|
|
92
|
+
nameTextStyle: {
|
|
93
|
+
fontSize: number;
|
|
94
|
+
fontWeight: number;
|
|
95
|
+
fontFamily: string;
|
|
96
|
+
color: "#000000";
|
|
97
|
+
} | undefined;
|
|
98
|
+
axisLine: {
|
|
99
|
+
show: boolean;
|
|
100
|
+
lineStyle: {
|
|
101
|
+
color: "#d1d1d1";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
axisLabel: {
|
|
105
|
+
rotate?: number | undefined;
|
|
106
|
+
color: "#5d5d5d";
|
|
107
|
+
fontFamily: string;
|
|
108
|
+
fontSize: number;
|
|
109
|
+
};
|
|
110
|
+
splitLine: {
|
|
111
|
+
show: boolean;
|
|
112
|
+
lineStyle: {
|
|
113
|
+
color: "#e7e7e7";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
show?: undefined;
|
|
117
|
+
};
|
|
118
|
+
export declare function buildYAxisConfig(options?: ChartOptions['yAxis']): {
|
|
119
|
+
show: boolean;
|
|
120
|
+
type?: undefined;
|
|
121
|
+
name?: undefined;
|
|
122
|
+
nameLocation?: undefined;
|
|
123
|
+
nameGap?: undefined;
|
|
124
|
+
nameRotate?: undefined;
|
|
125
|
+
nameTextStyle?: undefined;
|
|
126
|
+
min?: undefined;
|
|
127
|
+
max?: undefined;
|
|
128
|
+
axisLine?: undefined;
|
|
129
|
+
axisLabel?: undefined;
|
|
130
|
+
splitLine?: undefined;
|
|
131
|
+
} | {
|
|
132
|
+
type: "value";
|
|
133
|
+
name: string | undefined;
|
|
134
|
+
nameLocation: "end" | "middle" | "start";
|
|
135
|
+
nameGap: number | undefined;
|
|
136
|
+
nameRotate: number;
|
|
137
|
+
nameTextStyle: {
|
|
138
|
+
fontSize: number;
|
|
139
|
+
fontWeight: number;
|
|
140
|
+
fontFamily: string;
|
|
141
|
+
color: "#000000";
|
|
142
|
+
} | undefined;
|
|
143
|
+
min: number | undefined;
|
|
144
|
+
max: number | undefined;
|
|
145
|
+
axisLine: {
|
|
146
|
+
show: boolean;
|
|
147
|
+
lineStyle: {
|
|
148
|
+
color: "#d1d1d1";
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
axisLabel: {
|
|
152
|
+
rotate?: number | undefined;
|
|
153
|
+
color: "#5d5d5d";
|
|
154
|
+
fontFamily: string;
|
|
155
|
+
fontSize: number;
|
|
156
|
+
};
|
|
157
|
+
splitLine: {
|
|
158
|
+
show: boolean;
|
|
159
|
+
lineStyle: {
|
|
160
|
+
color: "#e7e7e7";
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
show?: undefined;
|
|
164
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { UI_COLORS as m } from "./colors.js";
|
|
2
|
+
const g = "Inter Variable, sans-serif", c = {
|
|
3
|
+
fontFamily: g,
|
|
4
|
+
color: m.text.primary
|
|
5
|
+
};
|
|
6
|
+
function y(e, l) {
|
|
7
|
+
if ((l == null ? void 0 : l.show) === !1)
|
|
8
|
+
return;
|
|
9
|
+
const r = (l == null ? void 0 : l.position) ?? "left", a = (l == null ? void 0 : l.fontSize) ?? 16, f = (l == null ? void 0 : l.color) ?? m.text.primary;
|
|
10
|
+
return {
|
|
11
|
+
text: e,
|
|
12
|
+
textStyle: {
|
|
13
|
+
fontFamily: g,
|
|
14
|
+
fontSize: a,
|
|
15
|
+
fontWeight: 500,
|
|
16
|
+
color: f
|
|
17
|
+
},
|
|
18
|
+
left: r,
|
|
19
|
+
top: 12,
|
|
20
|
+
padding: [0, 0, 8, 0]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function C(e) {
|
|
24
|
+
return (e == null ? void 0 : e.show) === !1 ? void 0 : {
|
|
25
|
+
trigger: (e == null ? void 0 : e.trigger) ?? "axis",
|
|
26
|
+
backgroundColor: m.background.default,
|
|
27
|
+
borderColor: m.border.default,
|
|
28
|
+
borderWidth: 1,
|
|
29
|
+
textStyle: {
|
|
30
|
+
...c
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function v(e, l = !1, r) {
|
|
35
|
+
if ((r == null ? void 0 : r.show) === !1)
|
|
36
|
+
return;
|
|
37
|
+
const a = (r == null ? void 0 : r.position) ?? "top", f = (r == null ? void 0 : r.orient) ?? "horizontal";
|
|
38
|
+
let u = l ? 48 : 16, t, d = "center", b;
|
|
39
|
+
return a === "bottom" ? (u = "auto", t = 10) : a === "left" ? (u = "middle", d = 10) : a === "right" && (u = "middle", d = "auto", b = 10), {
|
|
40
|
+
data: e,
|
|
41
|
+
top: u,
|
|
42
|
+
bottom: t,
|
|
43
|
+
left: d,
|
|
44
|
+
right: b,
|
|
45
|
+
orient: f,
|
|
46
|
+
itemGap: 20,
|
|
47
|
+
padding: [8, 0, 12, 0],
|
|
48
|
+
textStyle: {
|
|
49
|
+
...c,
|
|
50
|
+
fontSize: 12
|
|
51
|
+
},
|
|
52
|
+
itemWidth: 25,
|
|
53
|
+
itemHeight: 14
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function x(e) {
|
|
57
|
+
return {
|
|
58
|
+
color: m.text.secondary,
|
|
59
|
+
fontFamily: g,
|
|
60
|
+
fontSize: 11,
|
|
61
|
+
...e && { rotate: e }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function S(e = !0) {
|
|
65
|
+
return {
|
|
66
|
+
show: e,
|
|
67
|
+
lineStyle: {
|
|
68
|
+
color: m.border.default
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function h(e = !0) {
|
|
73
|
+
return {
|
|
74
|
+
show: e,
|
|
75
|
+
lineStyle: {
|
|
76
|
+
color: m.border.light
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function T(e, l = !1, r = "top", a) {
|
|
81
|
+
if (a)
|
|
82
|
+
return {
|
|
83
|
+
left: a.left ?? "3%",
|
|
84
|
+
right: a.right ?? "4%",
|
|
85
|
+
bottom: a.bottom ?? "3%",
|
|
86
|
+
top: a.top ?? 20,
|
|
87
|
+
containLabel: !0
|
|
88
|
+
};
|
|
89
|
+
let f = 20;
|
|
90
|
+
e && (f += 48), l && r === "top" && (f += 40);
|
|
91
|
+
let u = "3%";
|
|
92
|
+
l && r === "bottom" && (u = 60);
|
|
93
|
+
let t = "3%";
|
|
94
|
+
l && r === "left" && (t = 100);
|
|
95
|
+
let d = "4%";
|
|
96
|
+
return l && r === "right" && (d = 100), {
|
|
97
|
+
left: t,
|
|
98
|
+
right: d,
|
|
99
|
+
bottom: u,
|
|
100
|
+
top: f,
|
|
101
|
+
containLabel: !0
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function w(e, l = !0, r) {
|
|
105
|
+
return (r == null ? void 0 : r.show) === !1 ? { show: !1 } : {
|
|
106
|
+
type: "category",
|
|
107
|
+
data: e,
|
|
108
|
+
boundaryGap: l,
|
|
109
|
+
name: r == null ? void 0 : r.name,
|
|
110
|
+
nameLocation: (r == null ? void 0 : r.nameLocation) ?? "middle",
|
|
111
|
+
nameGap: r != null && r.name ? 30 : void 0,
|
|
112
|
+
nameTextStyle: r != null && r.name ? {
|
|
113
|
+
...c,
|
|
114
|
+
fontSize: 12,
|
|
115
|
+
fontWeight: 500
|
|
116
|
+
} : void 0,
|
|
117
|
+
axisLine: S(),
|
|
118
|
+
axisLabel: x(r == null ? void 0 : r.labelRotate),
|
|
119
|
+
splitLine: h((r == null ? void 0 : r.gridLines) ?? !1)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function z(e) {
|
|
123
|
+
if ((e == null ? void 0 : e.show) === !1)
|
|
124
|
+
return { show: !1 };
|
|
125
|
+
const l = (e == null ? void 0 : e.min) === "auto" || e == null ? void 0 : e.min, r = (e == null ? void 0 : e.max) === "auto" || e == null ? void 0 : e.max;
|
|
126
|
+
return {
|
|
127
|
+
type: "value",
|
|
128
|
+
name: e == null ? void 0 : e.name,
|
|
129
|
+
nameLocation: (e == null ? void 0 : e.nameLocation) ?? "middle",
|
|
130
|
+
nameGap: e != null && e.name ? 50 : void 0,
|
|
131
|
+
nameRotate: 90,
|
|
132
|
+
nameTextStyle: e != null && e.name ? {
|
|
133
|
+
...c,
|
|
134
|
+
fontSize: 12,
|
|
135
|
+
fontWeight: 500
|
|
136
|
+
} : void 0,
|
|
137
|
+
min: l,
|
|
138
|
+
max: r,
|
|
139
|
+
axisLine: S(!1),
|
|
140
|
+
axisLabel: x(),
|
|
141
|
+
splitLine: h((e == null ? void 0 : e.gridLines) ?? !0)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
c as COMMON_TEXT_STYLE,
|
|
146
|
+
g as DEFAULT_FONT_FAMILY,
|
|
147
|
+
x as buildAxisLabelConfig,
|
|
148
|
+
S as buildAxisLineConfig,
|
|
149
|
+
T as buildGridConfig,
|
|
150
|
+
v as buildLegendConfig,
|
|
151
|
+
h as buildSplitLineConfig,
|
|
152
|
+
y as buildTitleConfig,
|
|
153
|
+
C as buildTooltipConfig,
|
|
154
|
+
w as buildXAxisConfig,
|
|
155
|
+
z as buildYAxisConfig
|
|
156
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ChartCard } from './chart-card';
|
|
2
|
+
export type { ChartCardProps } from './chart-card.types';
|
|
3
|
+
export { LoadingState, EmptyState, ErrorState } from './chart-card-states';
|
|
4
|
+
export type { ChartType, ChartTheme, LineChartTheme, BarChartTheme, ChartConfig, BarChartConfig, LineChartConfig, ChartSeries, ChartData, ChartOptions, SeriesStyleConfig, } from './chart-card.config.types';
|
|
5
|
+
export { UI_COLORS, COLOR_PALETTES, getThemePalette } from './config/colors';
|
|
6
|
+
export { validateChartConfig, validateChartData } from './validators/config-validator';
|
|
7
|
+
export type { ValidationResult } from './validators/config-validator';
|
|
8
|
+
export { buildBarChartOptions } from './builders/bar-chart-builder';
|
|
9
|
+
export { buildLineChartOptions } from './builders/line-chart-builder';
|
|
10
|
+
export { buildChartOptions, isChartTypeSupported, registeredChartTypes, } from './builders/chart-builder-factory';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChartConfig, ChartData } from '../chart-card.config.types';
|
|
2
|
+
export interface ValidationResult {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function validateChartConfig(config: ChartConfig): ValidationResult;
|
|
7
|
+
export declare function validateChartData(data: ChartData): ValidationResult;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const i = /* @__PURE__ */ new Set([
|
|
2
|
+
"basic",
|
|
3
|
+
"smooth"
|
|
4
|
+
]), s = /* @__PURE__ */ new Set([
|
|
5
|
+
"basic",
|
|
6
|
+
"stacked"
|
|
7
|
+
]);
|
|
8
|
+
function n(e) {
|
|
9
|
+
var r;
|
|
10
|
+
return e != null && e.type ? (r = e.name) != null && r.trim() ? (e.type === "line" ? i.has(e.theme) : s.has(e.theme)) ? { valid: !0 } : {
|
|
11
|
+
valid: !1,
|
|
12
|
+
error: `Theme "${e.theme}" is not supported for ${e.type} charts`
|
|
13
|
+
} : { valid: !1, error: "Chart name is required" } : { valid: !1, error: "Chart type is required" };
|
|
14
|
+
}
|
|
15
|
+
function u(e) {
|
|
16
|
+
if (!e)
|
|
17
|
+
return { valid: !1, error: "Chart data is required" };
|
|
18
|
+
if (!Array.isArray(e.labels) || e.labels.length === 0)
|
|
19
|
+
return { valid: !1, error: "At least one label is required" };
|
|
20
|
+
if (!Array.isArray(e.series) || e.series.length === 0)
|
|
21
|
+
return { valid: !1, error: "At least one data series is required" };
|
|
22
|
+
const a = e.labels.length;
|
|
23
|
+
for (const r of e.series) {
|
|
24
|
+
const t = l(r, a);
|
|
25
|
+
if (!t.valid)
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
return { valid: !0 };
|
|
29
|
+
}
|
|
30
|
+
function l(e, a) {
|
|
31
|
+
var r;
|
|
32
|
+
return (r = e.name) != null && r.trim() ? Array.isArray(e.values) ? e.values.length !== a ? {
|
|
33
|
+
valid: !1,
|
|
34
|
+
error: `Series "${e.name}" contains ${e.values.length} points, expected ${a}`
|
|
35
|
+
} : { valid: !0 } : { valid: !1, error: `Series "${e.name}" is missing values` } : { valid: !1, error: "Each series requires a name" };
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
n as validateChartConfig,
|
|
39
|
+
u as validateChartData
|
|
40
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
interface Z2TablePaginationProps {
|
|
3
|
+
showSizeToggle?: boolean;
|
|
3
4
|
sizes?: number[];
|
|
4
5
|
sizesInfo?: string;
|
|
5
6
|
sizesLabel?: string;
|
|
@@ -14,6 +15,7 @@ interface Z2TablePaginationProps {
|
|
|
14
15
|
previousPageLabel?: string;
|
|
15
16
|
nextPageLabel?: string;
|
|
16
17
|
ellipsisText?: string;
|
|
18
|
+
showGoToPage?: boolean;
|
|
17
19
|
}
|
|
18
20
|
declare function Z2TablePagination(props: Z2TablePaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
export { Z2TablePagination, type Z2TablePaginationProps };
|
|
@@ -1,59 +1,65 @@
|
|
|
1
|
-
import { jsx as t, jsxs as l, Fragment as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Button as r } from "../button/button.js";
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { useZ2Table as z } from "./z2-table-context.js";
|
|
3
|
+
import { Z2Skeleton as N } from "../skeleton/skeleton.js";
|
|
4
|
+
import { Button as s } from "../button/button.js";
|
|
6
5
|
import "react";
|
|
7
|
-
import { cn as
|
|
8
|
-
import { Z2Select as
|
|
9
|
-
|
|
6
|
+
import { cn as I } from "../../lib/utils.js";
|
|
7
|
+
import { Z2Select as L, Z2SelectTrigger as y, Z2SelectValue as T, Z2SelectContent as Z, Z2SelectItem as G } from "../select/z2-select.js";
|
|
8
|
+
import $ from "../assets/icons/double-chevron-left.js";
|
|
9
|
+
import j from "../assets/icons/double-chevron-right.js";
|
|
10
|
+
import B from "../assets/icons/chevron-left.js";
|
|
11
|
+
import M from "../assets/icons/chevron-right.js";
|
|
12
|
+
import { Input as D } from "../input/input.js";
|
|
13
|
+
function X(P) {
|
|
10
14
|
var b;
|
|
11
|
-
const { table:
|
|
12
|
-
|
|
15
|
+
const { table: a, recordCount: g, isLoading: h } = z(), e = { ...{
|
|
16
|
+
showSizeToggle: !1,
|
|
17
|
+
sizes: [25, 50, 100],
|
|
13
18
|
sizesLabel: "Show",
|
|
14
19
|
sizesDescription: "per page",
|
|
15
|
-
sizesSkeleton: /* @__PURE__ */ t(
|
|
20
|
+
sizesSkeleton: /* @__PURE__ */ t(N, { className: "h-6 w-44" }),
|
|
16
21
|
moreLimit: 5,
|
|
17
22
|
more: !1,
|
|
18
|
-
info: "{from} - {to} of {count}",
|
|
19
|
-
infoSkeleton: /* @__PURE__ */ t(
|
|
23
|
+
info: "Viewing {from} - {to} out of {count}",
|
|
24
|
+
infoSkeleton: /* @__PURE__ */ t(N, { className: "h-6 w-32" }),
|
|
20
25
|
rowsPerPageLabel: "Rows per page",
|
|
21
26
|
previousPageLabel: "Go to previous page",
|
|
22
27
|
nextPageLabel: "Go to next page",
|
|
23
|
-
ellipsisText: "..."
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
ellipsisText: "...",
|
|
29
|
+
showGoToPage: !1
|
|
30
|
+
}, ...P }, r = " rtl:transform rtl:rotate-180", i = a.getState().pagination.pageIndex, c = a.getState().pagination.pageSize, x = i * c + 1, v = Math.min((i + 1) * c, g), d = a.getPageCount(), w = e != null && e.info ? e.info.replace("{from}", x.toString()).replace("{to}", v.toString()).replace("{count}", g.toString()) : `${x} - ${v} of ${g}`, p = (e == null ? void 0 : e.moreLimit) || 5, m = Math.floor(i / p) * p, u = Math.min(m + p, d), S = () => {
|
|
31
|
+
const o = [];
|
|
32
|
+
for (let n = m; n < u; n++)
|
|
33
|
+
o.push(
|
|
28
34
|
/* @__PURE__ */ t(
|
|
29
|
-
|
|
35
|
+
s,
|
|
30
36
|
{
|
|
31
37
|
size: "small",
|
|
32
38
|
variant: "stroke",
|
|
33
|
-
disabled:
|
|
39
|
+
disabled: i === n,
|
|
34
40
|
onClick: () => {
|
|
35
|
-
|
|
41
|
+
i !== n && a.setPageIndex(n);
|
|
36
42
|
},
|
|
37
|
-
leftIcon:
|
|
43
|
+
leftIcon: n + 1
|
|
38
44
|
},
|
|
39
|
-
|
|
45
|
+
n
|
|
40
46
|
)
|
|
41
47
|
);
|
|
42
|
-
return
|
|
43
|
-
},
|
|
44
|
-
|
|
48
|
+
return o;
|
|
49
|
+
}, C = () => m > 0 ? /* @__PURE__ */ t(
|
|
50
|
+
s,
|
|
45
51
|
{
|
|
46
52
|
size: "small",
|
|
47
53
|
variant: "stroke",
|
|
48
|
-
onClick: () =>
|
|
54
|
+
onClick: () => a.setPageIndex(m - 1),
|
|
49
55
|
label: e.ellipsisText
|
|
50
56
|
}
|
|
51
|
-
) : null,
|
|
52
|
-
|
|
57
|
+
) : null, k = () => u < d ? /* @__PURE__ */ t(
|
|
58
|
+
s,
|
|
53
59
|
{
|
|
54
60
|
variant: "stroke",
|
|
55
61
|
size: "small",
|
|
56
|
-
onClick: () =>
|
|
62
|
+
onClick: () => a.setPageIndex(u),
|
|
57
63
|
label: e.ellipsisText
|
|
58
64
|
}
|
|
59
65
|
) : null;
|
|
@@ -61,55 +67,98 @@ function H(N) {
|
|
|
61
67
|
"div",
|
|
62
68
|
{
|
|
63
69
|
"data-slot": "data-grid-pagination",
|
|
64
|
-
className:
|
|
70
|
+
className: I(
|
|
65
71
|
"flex flex-wrap flex-col sm:flex-row justify-between items-center gap-2.5 py-2.5 sm:py-0 grow",
|
|
66
72
|
e == null ? void 0 : e.className
|
|
67
73
|
),
|
|
68
74
|
children: [
|
|
69
|
-
/* @__PURE__ */ t("div", { className: "flex flex-wrap items-center space-x-2.5 pb-2.5 sm:pb-0 order-2 sm:order-1", children:
|
|
70
|
-
|
|
71
|
-
/* @__PURE__ */ l(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
/* @__PURE__ */ t("div", { className: "flex flex-wrap items-center space-x-2.5 pb-2.5 sm:pb-0 order-2 sm:order-1", children: h ? e == null ? void 0 : e.infoSkeleton : /* @__PURE__ */ t(f, { children: /* @__PURE__ */ t("div", { className: "leading-none-medium-sm text-neutral-secondary text-nowrap", children: w }) }) }),
|
|
76
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col sm:flex-row justify-center sm:justify-end items-center gap-2.5 pt-2.5 sm:pt-0 order-1 sm:order-2", children: h ? e == null ? void 0 : e.sizesSkeleton : /* @__PURE__ */ l(f, { children: [
|
|
77
|
+
e.showSizeToggle && /* @__PURE__ */ l(f, { children: [
|
|
78
|
+
/* @__PURE__ */ t("div", { className: "leading-none-medium-sm text-neutral-secondary", children: e.rowsPerPageLabel }),
|
|
79
|
+
/* @__PURE__ */ l(
|
|
80
|
+
L,
|
|
81
|
+
{
|
|
82
|
+
value: `${c}`,
|
|
83
|
+
onValueChange: (o) => {
|
|
84
|
+
const n = Number(o);
|
|
85
|
+
a.setPageSize(n);
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ t(y, { className: "w-fit", size: "sm", children: /* @__PURE__ */ t(T, { placeholder: `${c}` }) }),
|
|
89
|
+
/* @__PURE__ */ t(Z, { side: "top", className: "min-w-[50px]", children: (b = e == null ? void 0 : e.sizes) == null ? void 0 : b.map((o) => /* @__PURE__ */ t(G, { value: `${o}`, children: o }, o)) })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] }),
|
|
94
|
+
e.showGoToPage && /* @__PURE__ */ l("div", { className: "leading-none-medium-sm text-neutral-secondary text-nowrap order-2 sm:order-1 flex items-center gap-1", children: [
|
|
95
|
+
"Go to page:",
|
|
96
|
+
" ",
|
|
97
|
+
/* @__PURE__ */ t(
|
|
98
|
+
D,
|
|
99
|
+
{
|
|
100
|
+
size: "small",
|
|
101
|
+
className: "w-10",
|
|
102
|
+
type: "number",
|
|
103
|
+
min: 1,
|
|
104
|
+
placeholder: `${a.getState().pagination.pageIndex + 1}`,
|
|
105
|
+
max: a.getPageCount(),
|
|
106
|
+
onBlur: (o) => {
|
|
107
|
+
let n = Number(o.target.value);
|
|
108
|
+
n = n - 1, n <= a.getPageCount() && a.setPageIndex(n);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }),
|
|
113
|
+
d > 1 && /* @__PURE__ */ l("div", { className: "flex items-center space-x-1 order-1 sm:order-2", children: [
|
|
89
114
|
/* @__PURE__ */ t(
|
|
90
|
-
|
|
115
|
+
s,
|
|
91
116
|
{
|
|
92
117
|
size: "small",
|
|
93
118
|
variant: "stroke",
|
|
94
|
-
className:
|
|
95
|
-
onClick: () =>
|
|
96
|
-
disabled: !
|
|
97
|
-
leftIcon: /* @__PURE__ */ t(
|
|
119
|
+
className: r,
|
|
120
|
+
onClick: () => a.firstPage(),
|
|
121
|
+
disabled: !a.getCanPreviousPage(),
|
|
122
|
+
leftIcon: /* @__PURE__ */ t($, {}),
|
|
123
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.previousPageLabel })
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ t(
|
|
127
|
+
s,
|
|
128
|
+
{
|
|
129
|
+
size: "small",
|
|
130
|
+
variant: "stroke",
|
|
131
|
+
className: r,
|
|
132
|
+
onClick: () => a.previousPage(),
|
|
133
|
+
disabled: !a.getCanPreviousPage(),
|
|
134
|
+
leftIcon: /* @__PURE__ */ t(B, {}),
|
|
98
135
|
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.previousPageLabel })
|
|
99
136
|
}
|
|
100
137
|
),
|
|
101
|
-
k(),
|
|
102
|
-
z(),
|
|
103
138
|
C(),
|
|
139
|
+
S(),
|
|
140
|
+
k(),
|
|
141
|
+
/* @__PURE__ */ t(
|
|
142
|
+
s,
|
|
143
|
+
{
|
|
144
|
+
size: "small",
|
|
145
|
+
variant: "stroke",
|
|
146
|
+
className: r,
|
|
147
|
+
onClick: () => a.nextPage(),
|
|
148
|
+
disabled: !a.getCanNextPage(),
|
|
149
|
+
leftIcon: /* @__PURE__ */ t(M, {}),
|
|
150
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.nextPageLabel })
|
|
151
|
+
}
|
|
152
|
+
),
|
|
104
153
|
/* @__PURE__ */ t(
|
|
105
|
-
|
|
154
|
+
s,
|
|
106
155
|
{
|
|
107
156
|
size: "small",
|
|
108
157
|
variant: "stroke",
|
|
109
|
-
className:
|
|
110
|
-
onClick: () =>
|
|
111
|
-
disabled: !
|
|
112
|
-
leftIcon: /* @__PURE__ */ t(
|
|
158
|
+
className: r,
|
|
159
|
+
onClick: () => a.lastPage(),
|
|
160
|
+
disabled: !a.getCanNextPage(),
|
|
161
|
+
leftIcon: /* @__PURE__ */ t(j, {}),
|
|
113
162
|
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.nextPageLabel })
|
|
114
163
|
}
|
|
115
164
|
)
|
|
@@ -120,5 +169,5 @@ function H(N) {
|
|
|
120
169
|
);
|
|
121
170
|
}
|
|
122
171
|
export {
|
|
123
|
-
|
|
172
|
+
X as Z2TablePagination
|
|
124
173
|
};
|