jky-component-lib 0.0.56 → 0.0.61

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.
Files changed (79) hide show
  1. package/dist/es/add-input/AddInput.vue.d.ts +27 -0
  2. package/dist/es/add-input/AddInput.vue.js +151 -0
  3. package/dist/es/add-input/AddInput.vue3.js +5 -0
  4. package/dist/es/add-input/index.d.ts +4 -0
  5. package/dist/es/add-input/index.js +8 -0
  6. package/dist/es/add-input/style.css +35 -0
  7. package/dist/es/button-nav/ButtonNav.vue.d.ts +4 -4
  8. package/dist/es/code-mirror-editor/CodeMirrorEditor.vue.d.ts +4 -4
  9. package/dist/es/components.d.ts +3 -0
  10. package/dist/es/components.js +10 -1
  11. package/dist/es/form/Form.vue.d.ts +2 -2
  12. package/dist/es/form/FormItem.vue.js +12 -0
  13. package/dist/es/index.js +6 -0
  14. package/dist/es/node_modules/@element-plus/icons-vue/dist/index.js +32 -0
  15. package/dist/es/package.json.js +1 -1
  16. package/dist/es/page-header/PageHeader.vue.js +1 -1
  17. package/dist/es/page-header/PopoverMenu.vue.d.ts +1 -1
  18. package/dist/es/page-header/PopoverMenu.vue.js +1 -1
  19. package/dist/es/page-table/PageTable.vue.d.ts +6087 -0
  20. package/dist/es/page-table/PageTable.vue.js +374 -0
  21. package/dist/es/page-table/PageTable.vue3.js +5 -0
  22. package/dist/es/page-table/Toolbar.vue.d.ts +32 -0
  23. package/dist/es/page-table/Toolbar.vue.js +268 -0
  24. package/dist/es/page-table/Toolbar.vue3.js +5 -0
  25. package/dist/es/page-table/index.d.ts +4 -0
  26. package/dist/es/page-table/index.js +8 -0
  27. package/dist/es/page-table/style.css +4 -0
  28. package/dist/es/rich-editor/RichEditor.vue.d.ts +78 -0
  29. package/dist/es/rich-editor/RichEditor.vue.js +105 -0
  30. package/dist/es/rich-editor/RichEditor.vue3.js +5 -0
  31. package/dist/es/rich-editor/index.d.ts +4 -0
  32. package/dist/es/rich-editor/index.js +8 -0
  33. package/dist/es/rich-editor/style.css +34 -0
  34. package/dist/es/style.css +28 -0
  35. package/dist/es/styles.css +1 -1
  36. package/dist/es/utils/index.d.ts +1 -0
  37. package/dist/es/utils/responsive-toolbar.d.ts +78 -0
  38. package/dist/es/utils/responsive-toolbar.js +64 -0
  39. package/dist/lib/add-input/AddInput.vue.d.ts +27 -0
  40. package/dist/lib/add-input/AddInput.vue.js +151 -0
  41. package/dist/lib/add-input/AddInput.vue3.js +5 -0
  42. package/dist/lib/add-input/index.d.ts +4 -0
  43. package/dist/lib/add-input/index.js +8 -0
  44. package/dist/lib/add-input/style.css +35 -0
  45. package/dist/lib/button-nav/ButtonNav.vue.d.ts +4 -4
  46. package/dist/lib/code-mirror-editor/CodeMirrorEditor.vue.d.ts +4 -4
  47. package/dist/lib/components.d.ts +3 -0
  48. package/dist/lib/components.js +30 -21
  49. package/dist/lib/form/Form.vue.d.ts +2 -2
  50. package/dist/lib/form/FormItem.vue.js +20 -8
  51. package/dist/lib/index.js +20 -14
  52. package/dist/lib/node_modules/@element-plus/icons-vue/dist/index.js +32 -0
  53. package/dist/lib/package.json.js +1 -1
  54. package/dist/lib/page-header/PageHeader.vue.js +2 -2
  55. package/dist/lib/page-header/PopoverMenu.vue.d.ts +1 -1
  56. package/dist/lib/page-header/PopoverMenu.vue.js +1 -1
  57. package/dist/lib/page-table/PageTable.vue.d.ts +6087 -0
  58. package/dist/lib/page-table/PageTable.vue.js +374 -0
  59. package/dist/lib/page-table/PageTable.vue3.js +5 -0
  60. package/dist/lib/page-table/Toolbar.vue.d.ts +32 -0
  61. package/dist/lib/page-table/Toolbar.vue.js +268 -0
  62. package/dist/lib/page-table/Toolbar.vue3.js +5 -0
  63. package/dist/lib/page-table/index.d.ts +4 -0
  64. package/dist/lib/page-table/index.js +8 -0
  65. package/dist/lib/page-table/style.css +4 -0
  66. package/dist/lib/rich-editor/RichEditor.vue.d.ts +78 -0
  67. package/dist/lib/rich-editor/RichEditor.vue.js +105 -0
  68. package/dist/lib/rich-editor/RichEditor.vue3.js +5 -0
  69. package/dist/lib/rich-editor/index.d.ts +4 -0
  70. package/dist/lib/rich-editor/index.js +8 -0
  71. package/dist/lib/rich-editor/style.css +34 -0
  72. package/dist/lib/style.css +28 -0
  73. package/dist/lib/styles.css +1 -1
  74. package/dist/lib/utils/index.d.ts +1 -0
  75. package/dist/lib/utils/responsive-toolbar.d.ts +78 -0
  76. package/dist/lib/utils/responsive-toolbar.js +64 -0
  77. package/package.json +4 -1
  78. package/dist/umd/index.js +0 -3966
  79. package/dist/umd/styles.css +0 -1
@@ -0,0 +1,374 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import { defineComponent, ref, computed, watch, onMounted, resolveComponent, resolveDirective, openBlock, createElementBlock, normalizeClass, createBlock, unref, withCtx, createVNode, mergeProps, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, renderSlot, resolveDynamicComponent } from "vue";
41
+ import { ElCard, ElTable, ElTableColumn, ElPagination } from "element-plus";
42
+ import { JkyForm } from "../form/index.js";
43
+ import _sfc_main$1 from "./Toolbar.vue.js";
44
+ /* empty css */
45
+ const _hoisted_1 = { class: "jky-page-table__filter-actions" };
46
+ const _hoisted_2 = {
47
+ key: 0,
48
+ class: "flex flex-end mt-4 jky-page-table__pagination"
49
+ };
50
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
51
+ name: "JkyPageTable"
52
+ }), {
53
+ __name: "PageTable",
54
+ props: {
55
+ title: { default: "" },
56
+ filterItems: { default: () => [] },
57
+ filterModel: { default: () => ({}) },
58
+ columns: {},
59
+ dataSource: {},
60
+ showSearchButton: { type: Boolean, default: true },
61
+ searchText: { default: "查询" },
62
+ resetText: { default: "重置" },
63
+ selection: { type: Boolean, default: false },
64
+ selectedRows: { default: () => [] },
65
+ pagination: {},
66
+ border: { type: Boolean, default: true },
67
+ stripe: { type: Boolean, default: false },
68
+ height: {},
69
+ maxHeight: {},
70
+ emptyText: { default: "暂无数据" },
71
+ loading: { type: Boolean, default: false },
72
+ className: { default: "" },
73
+ formProps: { default: () => ({}) },
74
+ tableProps: { default: () => ({}) },
75
+ paginationProps: { default: () => ({}) },
76
+ toolbarButtonLimit: { default: 0 },
77
+ toolbarButtons: {}
78
+ },
79
+ emits: ["search", "reset", "rowClick", "rowDblclick", "selectionChange", "pageChange", "sortChange"],
80
+ setup(__props, { expose: __expose, emit: __emit }) {
81
+ var _a, _b, _c;
82
+ const props = __props;
83
+ const emit = __emit;
84
+ const internalFilterModel = ref(__spreadValues({}, props.filterModel));
85
+ const internalData = ref([]);
86
+ const internalPagination = ref({
87
+ currentPage: ((_a = props.pagination) == null ? void 0 : _a.currentPage) || 1,
88
+ pageSize: ((_b = props.pagination) == null ? void 0 : _b.pageSize) || 10,
89
+ total: ((_c = props.pagination) == null ? void 0 : _c.total) || 0
90
+ });
91
+ const tableRef = ref(null);
92
+ const formRef = ref(null);
93
+ const paginationRef = ref(null);
94
+ const isLoading = ref(props.loading);
95
+ const showPagination = computed(() => {
96
+ var _a2;
97
+ return !!((_a2 = props.dataSource) == null ? void 0 : _a2.api);
98
+ });
99
+ function getColumnProps(column) {
100
+ return __spreadValues({}, column);
101
+ }
102
+ watch(
103
+ () => props.pagination,
104
+ (newPagination) => {
105
+ if (newPagination) {
106
+ internalPagination.value.currentPage = newPagination.currentPage || 1;
107
+ internalPagination.value.pageSize = newPagination.pageSize || 10;
108
+ internalPagination.value.total = newPagination.total || 0;
109
+ }
110
+ },
111
+ { deep: true }
112
+ );
113
+ function loadData() {
114
+ return __async(this, null, function* () {
115
+ var _a2;
116
+ if (!((_a2 = props.dataSource) == null ? void 0 : _a2.api))
117
+ return;
118
+ isLoading.value = true;
119
+ try {
120
+ const result = yield props.dataSource.api(__spreadValues({
121
+ currentPage: internalPagination.value.currentPage,
122
+ pageSize: internalPagination.value.pageSize
123
+ }, internalFilterModel.value));
124
+ const responseProps = props.dataSource.responseProps || {};
125
+ const recordsField = responseProps.recordsField || "records";
126
+ const totalField = responseProps.totalField || "total";
127
+ internalData.value = result[recordsField] || [];
128
+ internalPagination.value.total = result[totalField] || 0;
129
+ emit("pageChange", {
130
+ currentPage: internalPagination.value.currentPage,
131
+ pageSize: internalPagination.value.pageSize
132
+ });
133
+ } catch (error) {
134
+ console.error("加载数据失败:", error);
135
+ internalData.value = [];
136
+ internalPagination.value.total = 0;
137
+ } finally {
138
+ isLoading.value = false;
139
+ }
140
+ });
141
+ }
142
+ function handleSearch() {
143
+ var _a2;
144
+ emit("search", __spreadValues({}, internalFilterModel.value));
145
+ if ((_a2 = props.dataSource) == null ? void 0 : _a2.api) {
146
+ internalPagination.value.currentPage = 1;
147
+ loadData();
148
+ }
149
+ }
150
+ function handleReset() {
151
+ var _a2;
152
+ internalFilterModel.value = {};
153
+ emit("reset");
154
+ if (formRef.value) {
155
+ formRef.value.resetFields();
156
+ }
157
+ if ((_a2 = props.dataSource) == null ? void 0 : _a2.api) {
158
+ internalPagination.value.currentPage = 1;
159
+ loadData();
160
+ }
161
+ }
162
+ function handlePageChange(page) {
163
+ var _a2, _b2;
164
+ internalPagination.value.currentPage = page;
165
+ if ((_a2 = props.dataSource) == null ? void 0 : _a2.api) {
166
+ loadData();
167
+ } else if ((_b2 = props.pagination) == null ? void 0 : _b2.onPageChange) {
168
+ props.pagination.onPageChange(page);
169
+ }
170
+ emit("pageChange", {
171
+ currentPage: internalPagination.value.currentPage,
172
+ pageSize: internalPagination.value.pageSize
173
+ });
174
+ }
175
+ function handlePageSizeChange(size) {
176
+ var _a2, _b2;
177
+ internalPagination.value.pageSize = size;
178
+ internalPagination.value.currentPage = 1;
179
+ if ((_a2 = props.dataSource) == null ? void 0 : _a2.api) {
180
+ loadData();
181
+ } else if ((_b2 = props.pagination) == null ? void 0 : _b2.onPageSizeChange) {
182
+ props.pagination.onPageSizeChange(size);
183
+ }
184
+ emit("pageChange", {
185
+ currentPage: internalPagination.value.currentPage,
186
+ pageSize: internalPagination.value.pageSize
187
+ });
188
+ }
189
+ const selectedCount = ref(0);
190
+ function handleSelectionChange(selection) {
191
+ selectedCount.value = selection.length;
192
+ emit("selectionChange", selection);
193
+ }
194
+ function handleRowClick(row, column) {
195
+ emit("rowClick", row, column);
196
+ }
197
+ function handleRowDblclick(row, column) {
198
+ emit("rowDblclick", row, column);
199
+ }
200
+ function handleSortChange({ column, prop, order }) {
201
+ emit("sortChange", { column, prop, order });
202
+ }
203
+ __expose({
204
+ refresh: loadData,
205
+ getFilterData: () => __spreadValues({}, internalFilterModel.value),
206
+ setFilterData: (data) => {
207
+ internalFilterModel.value = __spreadValues({}, data);
208
+ },
209
+ resetFilter: handleReset,
210
+ getSelectedRows: () => {
211
+ var _a2;
212
+ return ((_a2 = tableRef.value) == null ? void 0 : _a2.getSelectionRows()) || [];
213
+ },
214
+ clearSelection: () => {
215
+ var _a2;
216
+ (_a2 = tableRef.value) == null ? void 0 : _a2.clearSelection();
217
+ },
218
+ toggleRowSelection: (row, selected) => {
219
+ var _a2;
220
+ (_a2 = tableRef.value) == null ? void 0 : _a2.toggleRowSelection(row, selected);
221
+ },
222
+ sort: (prop, order) => {
223
+ var _a2;
224
+ (_a2 = tableRef.value) == null ? void 0 : _a2.sort(prop, order);
225
+ },
226
+ formRef,
227
+ tableRef,
228
+ paginationRef
229
+ });
230
+ onMounted(() => {
231
+ var _a2;
232
+ if ((_a2 = props.dataSource) == null ? void 0 : _a2.api) {
233
+ loadData();
234
+ }
235
+ });
236
+ return (_ctx, _cache) => {
237
+ const _component_ElButton = resolveComponent("ElButton");
238
+ const _directive_loading = resolveDirective("loading");
239
+ return openBlock(), createElementBlock("div", {
240
+ class: normalizeClass(["bg-transparent jky-page-table", [__props.className]])
241
+ }, [
242
+ __props.filterItems && __props.filterItems.length > 0 ? (openBlock(), createBlock(unref(ElCard), {
243
+ key: 0,
244
+ class: "mb-4 jky-page-table__filter-card"
245
+ }, {
246
+ default: withCtx(() => [
247
+ createVNode(unref(JkyForm), mergeProps({
248
+ ref_key: "formRef",
249
+ ref: formRef,
250
+ modelValue: internalFilterModel.value,
251
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => internalFilterModel.value = $event),
252
+ items: __props.filterItems,
253
+ inline: true,
254
+ disabled: isLoading.value
255
+ }, __props.formProps), null, 16, ["modelValue", "items", "disabled"]),
256
+ createElementVNode("div", _hoisted_1, [
257
+ createVNode(_component_ElButton, {
258
+ type: "primary",
259
+ loading: isLoading.value,
260
+ onClick: handleSearch
261
+ }, {
262
+ default: withCtx(() => [
263
+ createTextVNode(toDisplayString(__props.searchText), 1)
264
+ ]),
265
+ _: 1
266
+ }, 8, ["loading"]),
267
+ createVNode(_component_ElButton, { onClick: handleReset }, {
268
+ default: withCtx(() => [
269
+ createTextVNode(toDisplayString(__props.resetText), 1)
270
+ ]),
271
+ _: 1
272
+ })
273
+ ])
274
+ ]),
275
+ _: 1
276
+ })) : createCommentVNode("", true),
277
+ createVNode(unref(ElCard), { class: "jky-page-table__table-card" }, {
278
+ default: withCtx(() => {
279
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l;
280
+ return [
281
+ createVNode(_sfc_main$1, {
282
+ "left-buttons": ((_a2 = props.toolbarButtons) == null ? void 0 : _a2.left) || [],
283
+ "batch-buttons": ((_b2 = props.toolbarButtons) == null ? void 0 : _b2.batch) || [],
284
+ "right-buttons": ((_c2 = props.toolbarButtons) == null ? void 0 : _c2.right) || [],
285
+ "selected-count": selectedCount.value,
286
+ "toolbar-button-limit": __props.toolbarButtonLimit,
287
+ payload: {
288
+ currentPage: internalPagination.value.currentPage,
289
+ pageSize: internalPagination.value.pageSize,
290
+ total: internalPagination.value.total,
291
+ tableData: internalData.value,
292
+ selectedRows: ((_d = tableRef.value) == null ? void 0 : _d.getSelectionRows()) || [],
293
+ filterData: __spreadValues({}, internalFilterModel.value)
294
+ }
295
+ }, null, 8, ["left-buttons", "batch-buttons", "right-buttons", "selected-count", "toolbar-button-limit", "payload"]),
296
+ withDirectives((openBlock(), createBlock(unref(ElTable), mergeProps({
297
+ ref_key: "tableRef",
298
+ ref: tableRef,
299
+ data: internalData.value,
300
+ border: __props.border,
301
+ stripe: __props.stripe,
302
+ height: __props.height,
303
+ "max-height": __props.maxHeight,
304
+ "empty-text": __props.emptyText
305
+ }, __props.tableProps, {
306
+ onSelectionChange: handleSelectionChange,
307
+ onRowClick: handleRowClick,
308
+ onRowDblclick: handleRowDblclick,
309
+ onSortChange: handleSortChange
310
+ }), {
311
+ default: withCtx(() => [
312
+ __props.selection ? (openBlock(), createBlock(unref(ElTableColumn), {
313
+ key: 0,
314
+ type: "selection",
315
+ width: "55",
316
+ align: "center"
317
+ })) : createCommentVNode("", true),
318
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
319
+ return openBlock(), createBlock(unref(ElTableColumn), mergeProps({
320
+ key: column.prop
321
+ }, { ref_for: true }, getColumnProps(column)), {
322
+ default: withCtx((scope) => [
323
+ renderSlot(_ctx.$slots, `column-${column.prop}`, {
324
+ row: scope.row,
325
+ column: scope.column,
326
+ index: scope.$index
327
+ }, () => {
328
+ var _a3;
329
+ return [
330
+ column.render ? (openBlock(), createBlock(resolveDynamicComponent((_a3 = column.render) == null ? void 0 : _a3.call(column, scope)), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
331
+ createTextVNode(toDisplayString(column.formatter ? column.formatter(scope.row, scope.column, scope.row[column.prop], scope.$index) : scope.row[column.prop]), 1)
332
+ ], 64))
333
+ ];
334
+ })
335
+ ]),
336
+ _: 2
337
+ }, 1040);
338
+ }), 128)),
339
+ renderSlot(_ctx.$slots, "columns")
340
+ ]),
341
+ _: 3
342
+ }, 16, ["data", "border", "stripe", "height", "max-height", "empty-text"])), [
343
+ [_directive_loading, isLoading.value]
344
+ ]),
345
+ showPagination.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
346
+ createVNode(unref(ElPagination), mergeProps({
347
+ ref_key: "paginationRef",
348
+ ref: paginationRef,
349
+ "current-page": internalPagination.value.currentPage,
350
+ "onUpdate:currentPage": _cache[1] || (_cache[1] = ($event) => internalPagination.value.currentPage = $event),
351
+ "page-size": internalPagination.value.pageSize,
352
+ "onUpdate:pageSize": _cache[2] || (_cache[2] = ($event) => internalPagination.value.pageSize = $event),
353
+ total: internalPagination.value.total,
354
+ "page-sizes": ((_e = __props.pagination) == null ? void 0 : _e.pageSizes) || [10, 20, 50, 100],
355
+ layout: ((_f = __props.pagination) == null ? void 0 : _f.layout) || "total, sizes, prev, pager, next, jumper",
356
+ "show-size-picker": (_h = (_g = __props.pagination) == null ? void 0 : _g.showSizePicker) != null ? _h : true,
357
+ "show-total": (_j = (_i = __props.pagination) == null ? void 0 : _i.showTotal) != null ? _j : true,
358
+ "show-jumper": (_l = (_k = __props.pagination) == null ? void 0 : _k.showJumper) != null ? _l : true
359
+ }, __props.paginationProps, {
360
+ onSizeChange: handlePageSizeChange,
361
+ onCurrentChange: handlePageChange
362
+ }), null, 16, ["current-page", "page-size", "total", "page-sizes", "layout", "show-size-picker", "show-total", "show-jumper"])
363
+ ])) : createCommentVNode("", true)
364
+ ];
365
+ }),
366
+ _: 3
367
+ })
368
+ ], 2);
369
+ };
370
+ }
371
+ }));
372
+ export {
373
+ _sfc_main as default
374
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./PageTable.vue.js";
2
+ /* empty css */
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,32 @@
1
+ import { ToolbarButtonConfig, ToolbarProps } from './types';
2
+ declare function handleBatchCommand(index: number): void;
3
+ declare function handleRightCommand(index: number): void;
4
+ declare const _default: import('vue').DefineComponent<ToolbarProps, {
5
+ handleBatchCommand: typeof handleBatchCommand;
6
+ handleRightCommand: typeof handleRightCommand;
7
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
8
+ batchCommand: (index: number) => any;
9
+ buttonClick: (button: ToolbarButtonConfig) => any;
10
+ rightCommand: (index: number) => any;
11
+ }, string, import('vue').PublicProps, Readonly<ToolbarProps> & Readonly<{
12
+ onBatchCommand?: ((index: number) => any) | undefined;
13
+ onButtonClick?: ((button: ToolbarButtonConfig) => any) | undefined;
14
+ onRightCommand?: ((index: number) => any) | undefined;
15
+ }>, {
16
+ leftButtons: ToolbarButtonConfig[];
17
+ batchButtons: ToolbarButtonConfig[];
18
+ rightButtons: ToolbarButtonConfig[];
19
+ selectedCount: number;
20
+ toolbarButtonLimit: number;
21
+ payload: {
22
+ currentPage: number;
23
+ pageSize: number;
24
+ total: number;
25
+ tableData: any[];
26
+ selectedRows: any[];
27
+ filterData: Record<string, any>;
28
+ };
29
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
30
+ toolbarRightRef: HTMLDivElement;
31
+ }, HTMLDivElement>;
32
+ export default _default;
@@ -0,0 +1,268 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { defineComponent, ref, computed, resolveComponent, openBlock, createElementBlock, createElementVNode, createBlock, resolveDynamicComponent, unref, withCtx, createVNode, normalizeClass, createTextVNode, toDisplayString, createCommentVNode, h } from "vue";
21
+ import { ArrowDown as arrow_down_default } from "../node_modules/@element-plus/icons-vue/dist/index.js";
22
+ import { ElDropdown, ElButton, ElDropdownMenu, ElDropdownItem } from "element-plus";
23
+ import { useResponsiveToolbar } from "../utils/responsive-toolbar.js";
24
+ const _hoisted_1 = { class: "flex items-center justify-between mb-2 py-2 jky-page-table__toolbar" };
25
+ const _hoisted_2 = { class: "flex items-center" };
26
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
27
+ name: "JkyPageTableToolbar"
28
+ }), {
29
+ __name: "Toolbar",
30
+ props: {
31
+ leftButtons: { default: () => [] },
32
+ batchButtons: { default: () => [] },
33
+ rightButtons: { default: () => [] },
34
+ selectedCount: { default: 0 },
35
+ toolbarButtonLimit: { default: 0 },
36
+ payload: { default: () => ({
37
+ currentPage: 1,
38
+ pageSize: 10,
39
+ total: 0,
40
+ tableData: [],
41
+ selectedRows: [],
42
+ filterData: {}
43
+ }) }
44
+ },
45
+ emits: ["batchCommand", "rightCommand", "buttonClick"],
46
+ setup(__props, { expose: __expose, emit: __emit }) {
47
+ const props = __props;
48
+ const emit = __emit;
49
+ const toolbarRightRef = ref(null);
50
+ const {
51
+ visibleCount: visibleRightCount,
52
+ needCollapse: needCollapseRight
53
+ } = useResponsiveToolbar({
54
+ toolbarRef: toolbarRightRef,
55
+ buttonLimit: props.toolbarButtonLimit > 0 ? props.toolbarButtonLimit : void 0,
56
+ minVisibleButtons: 1,
57
+ widthPercentage: 0.5
58
+ // 右侧占 50%
59
+ });
60
+ const showBatchActions = computed(() => {
61
+ return props.batchButtons && props.batchButtons.length > 0 && props.selectedCount && props.selectedCount > 0;
62
+ });
63
+ function getButtonPayload() {
64
+ return props.payload || {
65
+ currentPage: 1,
66
+ pageSize: 10,
67
+ total: 0,
68
+ tableData: [],
69
+ selectedRows: [],
70
+ filterData: {}
71
+ };
72
+ }
73
+ function handleToolbarButtonClick(button) {
74
+ emit("buttonClick", button);
75
+ if (button.onClick) {
76
+ button.onClick(getButtonPayload());
77
+ }
78
+ }
79
+ function handleBatchCommand(index) {
80
+ var _a;
81
+ emit("batchCommand", index);
82
+ const button = (_a = props.batchButtons) == null ? void 0 : _a[index];
83
+ if (button && button.onClick) {
84
+ button.onClick(getButtonPayload());
85
+ }
86
+ }
87
+ function handleRightCommand(index) {
88
+ var _a;
89
+ emit("rightCommand", index);
90
+ const button = (_a = props.rightButtons) == null ? void 0 : _a[index];
91
+ if (button && button.onClick) {
92
+ button.onClick(getButtonPayload());
93
+ }
94
+ }
95
+ function renderLeftButtons() {
96
+ const buttons = [];
97
+ if (props.leftButtons) {
98
+ props.leftButtons.forEach((button, index) => {
99
+ buttons.push(
100
+ h(
101
+ ElButton,
102
+ {
103
+ key: index,
104
+ type: button.type,
105
+ size: button.size,
106
+ disabled: button.disabled,
107
+ plain: button.plain,
108
+ class: button.className,
109
+ onClick: () => handleToolbarButtonClick(button)
110
+ },
111
+ { default: () => button.label }
112
+ )
113
+ );
114
+ });
115
+ }
116
+ return buttons;
117
+ }
118
+ function renderBatchDropdownItems() {
119
+ const items = [];
120
+ if (props.batchButtons) {
121
+ props.batchButtons.forEach((button, index) => {
122
+ items.push(
123
+ h(
124
+ ElDropdownItem,
125
+ {
126
+ key: index,
127
+ type: button.type,
128
+ disabled: button.disabled,
129
+ class: button.className,
130
+ command: index
131
+ },
132
+ { default: () => button.label }
133
+ )
134
+ );
135
+ });
136
+ }
137
+ return items;
138
+ }
139
+ function renderRightButtons() {
140
+ const buttons = [];
141
+ if (props.rightButtons) {
142
+ props.rightButtons.forEach((button, index) => {
143
+ const isVisible = index < visibleRightCount.value || !needCollapseRight.value;
144
+ if (isVisible) {
145
+ buttons.push(
146
+ h(
147
+ ElButton,
148
+ {
149
+ key: index,
150
+ type: button.type,
151
+ size: button.size,
152
+ disabled: button.disabled,
153
+ plain: button.plain,
154
+ class: button.className,
155
+ onClick: () => handleToolbarButtonClick(button)
156
+ },
157
+ { default: () => button.label }
158
+ )
159
+ );
160
+ }
161
+ });
162
+ }
163
+ return buttons;
164
+ }
165
+ function renderRightDropdownItems() {
166
+ const items = [];
167
+ if (props.rightButtons) {
168
+ props.rightButtons.slice(visibleRightCount.value).forEach((button, index) => {
169
+ const originalIndex = visibleRightCount.value + index;
170
+ items.push(
171
+ h(
172
+ ElDropdownItem,
173
+ {
174
+ key: originalIndex,
175
+ command: originalIndex
176
+ },
177
+ { default: () => button.label }
178
+ )
179
+ );
180
+ });
181
+ }
182
+ return items;
183
+ }
184
+ __expose({
185
+ handleBatchCommand,
186
+ handleRightCommand
187
+ });
188
+ return (_ctx, _cache) => {
189
+ const _component_ElIcon = resolveComponent("ElIcon");
190
+ return openBlock(), createElementBlock("div", _hoisted_1, [
191
+ createElementVNode("div", _hoisted_2, [
192
+ (openBlock(), createBlock(resolveDynamicComponent(renderLeftButtons))),
193
+ showBatchActions.value ? (openBlock(), createBlock(unref(ElDropdown), {
194
+ key: 0,
195
+ onCommand: handleBatchCommand
196
+ }, {
197
+ dropdown: withCtx(() => [
198
+ createVNode(unref(ElDropdownMenu), null, {
199
+ default: withCtx(() => [
200
+ (openBlock(), createBlock(resolveDynamicComponent(renderBatchDropdownItems)))
201
+ ]),
202
+ _: 1
203
+ })
204
+ ]),
205
+ default: withCtx(() => {
206
+ var _a;
207
+ return [
208
+ createVNode(unref(ElButton), {
209
+ type: "primary",
210
+ class: normalizeClass([((_a = props.leftButtons) == null ? void 0 : _a.length) ? "ml-3" : ""])
211
+ }, {
212
+ suffix: withCtx(() => [
213
+ createVNode(_component_ElIcon, { class: "text-white" }, {
214
+ default: withCtx(() => [
215
+ createVNode(unref(arrow_down_default))
216
+ ]),
217
+ _: 1
218
+ })
219
+ ]),
220
+ default: withCtx(() => [
221
+ createTextVNode(" 批量操作 (" + toDisplayString(__props.selectedCount) + ") ", 1)
222
+ ]),
223
+ _: 1
224
+ }, 8, ["class"])
225
+ ];
226
+ }),
227
+ _: 1
228
+ })) : createCommentVNode("", true)
229
+ ]),
230
+ createElementVNode("div", {
231
+ ref_key: "toolbarRightRef",
232
+ ref: toolbarRightRef,
233
+ class: "flex items-center jky-page-table__toolbar-right"
234
+ }, [
235
+ (openBlock(), createBlock(resolveDynamicComponent(renderRightButtons))),
236
+ unref(needCollapseRight) && __props.rightButtons && __props.rightButtons.length > unref(visibleRightCount) ? (openBlock(), createBlock(unref(ElDropdown), {
237
+ key: 0,
238
+ onCommand: handleRightCommand
239
+ }, {
240
+ dropdown: withCtx(() => [
241
+ createVNode(unref(ElDropdownMenu), null, {
242
+ default: withCtx(() => [
243
+ (openBlock(), createBlock(resolveDynamicComponent(renderRightDropdownItems)))
244
+ ]),
245
+ _: 1
246
+ })
247
+ ]),
248
+ default: withCtx(() => [
249
+ createVNode(unref(ElButton), {
250
+ type: "primary",
251
+ class: "ml-3"
252
+ }, {
253
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
254
+ createTextVNode(" 更多 ", -1)
255
+ ])]),
256
+ _: 1
257
+ })
258
+ ]),
259
+ _: 1
260
+ })) : createCommentVNode("", true)
261
+ ], 512)
262
+ ]);
263
+ };
264
+ }
265
+ }));
266
+ export {
267
+ _sfc_main as default
268
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./Toolbar.vue.js";
2
+ /* empty css */
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,4 @@
1
+ import { InstallWithSFC } from '../utils/types';
2
+ import { default as PageTable } from './PageTable.vue';
3
+ export declare const JkyPageTable: InstallWithSFC<typeof PageTable>;
4
+ export default JkyPageTable;