@done-coding/admin-core 0.22.2-alpha.0 → 0.22.3-alpha.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.
Files changed (30) hide show
  1. package/es/components/data-view/DataGridView.vue.mjs +7 -0
  2. package/es/components/data-view/DataGridView.vue2.mjs +448 -0
  3. package/es/components/data-view/DataListView.vue.mjs +1 -1
  4. package/es/components/data-view/DataListView.vue2.mjs +6 -62
  5. package/es/components/data-view/InfiniteListView.vue.mjs +7 -0
  6. package/es/components/data-view/InfiniteListView.vue2.mjs +205 -0
  7. package/es/components/data-view/use-data-view-field-map.mjs +70 -0
  8. package/es/components/data-view/use-pull-refresh.mjs +38 -0
  9. package/es/components/data-view/utils.mjs +21 -1
  10. package/es/components/list-layout/ListLayout.vue.mjs +1 -1
  11. package/es/components/list-layout/ListLayout.vue2.mjs +48 -8
  12. package/es/index.mjs +92 -82
  13. package/es/style.css +199 -97
  14. package/package.json +5 -2
  15. package/src/components/data-view/README.md +34 -8
  16. package/src/components/data-view/docs/README-DataGridView.md +139 -0
  17. package/src/components/data-view/docs/README-InfiniteListView.md +105 -0
  18. package/types/components/data-view/DataGridView.vue.d.ts +40 -0
  19. package/types/components/data-view/DataListView.vue.d.ts +1 -2
  20. package/types/components/data-view/InfiniteListView.vue.d.ts +30 -0
  21. package/types/components/data-view/index.d.ts +9 -3
  22. package/types/components/data-view/types.d.ts +125 -1
  23. package/types/components/data-view/use-data-view-field-map.d.ts +24 -0
  24. package/types/components/data-view/use-pull-refresh.d.ts +20 -0
  25. package/types/components/data-view/utils.d.ts +13 -1
  26. package/types/components/list-layout/ListLayout.vue.d.ts +4 -0
  27. package/types/components/list-layout/types.d.ts +16 -0
  28. package/types/components/table/index.d.ts +11 -1
  29. package/types/index.d.ts +2 -0
  30. package/types/injectInfo.json.d.ts +1 -1
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./DataGridView.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const DataGridView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d9e5439d"]]);
5
+ export {
6
+ DataGridView as default
7
+ };
@@ -0,0 +1,448 @@
1
+ import { defineComponent, useModel, shallowRef, ref, computed, onMounted, onActivated, watch, openBlock, createElementBlock, createBlock, unref, withCtx, createVNode, mergeProps, createCommentVNode, createElementVNode, toDisplayString, createTextVNode, normalizeStyle, Fragment, renderList, renderSlot, resolveDynamicComponent, mergeModels } from "vue";
2
+ import { ElButton } from "element-plus";
3
+ import TableToolbar from "../table/TableToolbar.vue.mjs";
4
+ import _sfc_main$2 from "../table/TableEmpty.vue.mjs";
5
+ import TableSkeleton from "../table/TableSkeleton.vue.mjs";
6
+ import _sfc_main$1 from "../display/WatchSize.vue.mjs";
7
+ import _cloneDeep from "lodash/cloneDeep";
8
+ import _set from "lodash/set";
9
+ import _get from "lodash/get";
10
+ import InfiniteListView from "./InfiniteListView.vue.mjs";
11
+ import { useDataViewFieldMap } from "./use-data-view-field-map.mjs";
12
+ import { resolveGridColumnsByBreakpoint, createDataListViewInstance } from "./utils.mjs";
13
+ import { useBreakpoint } from "../../hooks/use-breakpoint.mjs";
14
+ import { pickExportColumns } from "../../utils/export.mjs";
15
+ import { useChannelViewportHeight } from "../../hooks/use-channel-viewport-height.mjs";
16
+ import { APP_API_LIST_MODEL_KEY_CONFIG } from "../../config/list-model.mjs";
17
+ const _hoisted_1 = { class: "dc-data-grid-view data-grid-view" };
18
+ const _hoisted_2 = { class: "data-grid-view__card" };
19
+ const _hoisted_3 = { class: "data-grid-view__field-label" };
20
+ const _hoisted_4 = { class: "data-grid-view__field-value" };
21
+ const _hoisted_5 = {
22
+ key: 0,
23
+ class: "data-grid-view__empty-error"
24
+ };
25
+ const _sfc_main = /* @__PURE__ */ defineComponent({
26
+ __name: "DataGridView",
27
+ props: /* @__PURE__ */ mergeModels({
28
+ api: {},
29
+ columns: {},
30
+ rowKey: {},
31
+ query: {},
32
+ pageSizeInit: { default: 20 },
33
+ gridColumns: { default: 4 },
34
+ maxHeight: { default: "100vh" },
35
+ refine: { type: Boolean, default: true },
36
+ refineReduceHeight: { default: 0 },
37
+ viewportHeight: {},
38
+ parentChannel: {},
39
+ fillHeight: { type: Boolean },
40
+ dataViewMaxHeightMinValue: { default: 500 },
41
+ injectInfo: {},
42
+ skeleton: { type: Boolean, default: true },
43
+ skeletonRows: { default: 4 },
44
+ initialSearch: { type: Boolean, default: true },
45
+ showToolbar: { type: Boolean, default: true },
46
+ toolbar: {},
47
+ infiniteListProps: {}
48
+ }, {
49
+ "isAutoRefresh": { type: Boolean },
50
+ "isAutoRefreshModifiers": {},
51
+ "refreshInterval": {},
52
+ "refreshIntervalModifiers": {}
53
+ }),
54
+ emits: /* @__PURE__ */ mergeModels(["pageChange", "pageSizeChange", "dataChange", "selectionChange", "loadingChange", "pageInfoChange"], ["update:isAutoRefresh", "update:refreshInterval"]),
55
+ setup(__props, { expose: __expose, emit: __emit }) {
56
+ const props = __props;
57
+ const emits = __emit;
58
+ const isAutoRefresh = useModel(__props, "isAutoRefresh");
59
+ const refreshInterval = useModel(__props, "refreshInterval");
60
+ const store = shallowRef([]);
61
+ const total = ref(0);
62
+ const pageSize = ref(0);
63
+ const currentPage = ref(0);
64
+ const loading = ref(false);
65
+ const publicLoading = ref(false);
66
+ const loadingMore = ref(false);
67
+ const error = ref(null);
68
+ const hasRequested = ref(false);
69
+ const noMoreFromServer = ref(false);
70
+ const hasData = computed(() => store.value.length > 0);
71
+ const finished = computed(
72
+ () => hasData.value && (noMoreFromServer.value || store.value.length >= total.value)
73
+ );
74
+ const infiniteList = ref();
75
+ const infiniteListPropsFinal = computed(() => {
76
+ const p = props.infiniteListProps || {};
77
+ const picked = {};
78
+ [
79
+ "loadMoreDistance",
80
+ "endText",
81
+ "errorText",
82
+ "estimateSize",
83
+ "overscan",
84
+ "pullRefresh"
85
+ ].forEach((k) => {
86
+ if (p[k] !== void 0) picked[k] = p[k];
87
+ });
88
+ return picked;
89
+ });
90
+ const errorText = computed(
91
+ () => {
92
+ var _a;
93
+ return ((_a = props.infiniteListProps) == null ? void 0 : _a.errorText) ?? "加载失败";
94
+ }
95
+ );
96
+ const buildParams = (page) => {
97
+ const merged = _cloneDeep(props.query || {});
98
+ _set(merged, APP_API_LIST_MODEL_KEY_CONFIG.PAGE_SIZE_KEY, pageSize.value);
99
+ _set(merged, APP_API_LIST_MODEL_KEY_CONFIG.CURRENT_PAGE_KEY, page);
100
+ return merged;
101
+ };
102
+ const canGoOnByParams = (p, tip = true) => {
103
+ const page = _get(
104
+ p,
105
+ APP_API_LIST_MODEL_KEY_CONFIG.CURRENT_PAGE_KEY
106
+ );
107
+ const res = JSON.stringify(p) === JSON.stringify(buildParams(page));
108
+ if (!res && tip) {
109
+ console.warn(`并发请求参数冰花,丢弃结果 ${JSON.stringify(p)}`);
110
+ }
111
+ return res;
112
+ };
113
+ const getList = (silent = false) => {
114
+ if (!pageSize.value) return;
115
+ hasRequested.value = true;
116
+ if (loading.value) {
117
+ console.warn(`请求并发`);
118
+ return;
119
+ }
120
+ loading.value = true;
121
+ if (!silent) publicLoading.value = true;
122
+ const p = buildParams(1);
123
+ return props.api(p).then((res) => {
124
+ if (!canGoOnByParams(p)) return;
125
+ const items = _get(res, APP_API_LIST_MODEL_KEY_CONFIG.LIST_KEY);
126
+ store.value = items;
127
+ total.value = _get(
128
+ res,
129
+ APP_API_LIST_MODEL_KEY_CONFIG.TOTAL_KEY
130
+ );
131
+ currentPage.value = 1;
132
+ error.value = null;
133
+ noMoreFromServer.value = false;
134
+ emits("pageInfoChange", {
135
+ pageSize: pageSize.value,
136
+ currentPage: 1,
137
+ total: total.value
138
+ });
139
+ }).catch((e) => {
140
+ if (!canGoOnByParams(p)) return;
141
+ error.value = (e == null ? void 0 : e.message) || String(e);
142
+ }).finally(() => {
143
+ if (!canGoOnByParams(p)) return;
144
+ loading.value = false;
145
+ publicLoading.value = false;
146
+ });
147
+ };
148
+ const fetchNextPage = () => {
149
+ if (loading.value || loadingMore.value || error.value || finished.value) {
150
+ return;
151
+ }
152
+ if (!hasData.value) return;
153
+ const nextPage = currentPage.value + 1;
154
+ loadingMore.value = true;
155
+ const p = buildParams(nextPage);
156
+ return props.api(p).then((res) => {
157
+ if (!canGoOnByParams(p)) return;
158
+ const items = _get(res, APP_API_LIST_MODEL_KEY_CONFIG.LIST_KEY);
159
+ if (!items.length) noMoreFromServer.value = true;
160
+ store.value = [...store.value, ...items];
161
+ total.value = _get(
162
+ res,
163
+ APP_API_LIST_MODEL_KEY_CONFIG.TOTAL_KEY
164
+ );
165
+ currentPage.value = nextPage;
166
+ error.value = null;
167
+ emits("pageChange", nextPage);
168
+ emits("pageInfoChange", {
169
+ pageSize: pageSize.value,
170
+ currentPage: nextPage,
171
+ total: total.value
172
+ });
173
+ }).catch((e) => {
174
+ if (!canGoOnByParams(p)) return;
175
+ error.value = (e == null ? void 0 : e.message) || String(e);
176
+ }).finally(() => {
177
+ if (!canGoOnByParams(p)) return;
178
+ loadingMore.value = false;
179
+ });
180
+ };
181
+ const onRetry = () => {
182
+ error.value = null;
183
+ if (hasData.value) fetchNextPage();
184
+ else getList();
185
+ };
186
+ const refresh = async (silent = false) => {
187
+ var _a;
188
+ return (_a = getList(silent)) == null ? void 0 : _a.catch(() => {
189
+ });
190
+ };
191
+ const reload = async (silent = false) => {
192
+ var _a;
193
+ return (_a = getList(silent)) == null ? void 0 : _a.catch(() => {
194
+ });
195
+ };
196
+ const { activeBreakpoint } = useBreakpoint();
197
+ const gridColumnsFinal = computed(
198
+ () => resolveGridColumnsByBreakpoint(props.gridColumns, activeBreakpoint.value)
199
+ );
200
+ const gridRows = computed(() => {
201
+ const rows = [];
202
+ const cols = gridColumnsFinal.value;
203
+ for (let i = 0; i < store.value.length; i += cols) {
204
+ rows.push(store.value.slice(i, i + cols));
205
+ }
206
+ return rows;
207
+ });
208
+ const keyOf = (row) => {
209
+ const rk = props.rowKey;
210
+ return typeof rk === "function" ? rk(row) : String(row[rk]);
211
+ };
212
+ const rowKeyOfRow = (row) => row.length ? keyOf(row[0]) : "empty-row";
213
+ const getRenderCtxParams = () => ({
214
+ injectInfo: props.injectInfo || {},
215
+ exposeInfo: expose
216
+ });
217
+ const { fieldComponentMap } = useDataViewFieldMap({
218
+ columns: () => props.columns,
219
+ getRenderCtxParams
220
+ });
221
+ const fieldKeyOf = (column) => column.type === "index" ? "$type_index" : column.type === "selection" ? "$type_selection" : column.prop ?? "";
222
+ const selectedKeys = ref(/* @__PURE__ */ new Set());
223
+ const hasSelectionColumn = computed(
224
+ () => props.columns.some((c) => c.type === "selection")
225
+ );
226
+ const selectedList = computed(
227
+ () => store.value.filter((r) => selectedKeys.value.has(keyOf(r)))
228
+ );
229
+ const isSelected = (row) => selectedKeys.value.has(keyOf(row));
230
+ const emitSelectionChange = () => {
231
+ emits("selectionChange", selectedList.value);
232
+ };
233
+ const clearSelection = () => {
234
+ selectedKeys.value = /* @__PURE__ */ new Set();
235
+ emitSelectionChange();
236
+ };
237
+ const toggleSelect = (row, selected) => {
238
+ const k = keyOf(row);
239
+ const next = new Set(selectedKeys.value);
240
+ const shouldSelect = selected ?? !next.has(k);
241
+ if (shouldSelect) next.add(k);
242
+ else next.delete(k);
243
+ selectedKeys.value = next;
244
+ emitSelectionChange();
245
+ };
246
+ const toggleAllSelection = () => {
247
+ if (!hasSelectionColumn.value) return;
248
+ const allSelected = selectedKeys.value.size === store.value.length && store.value.length > 0;
249
+ selectedKeys.value = allSelected ? /* @__PURE__ */ new Set() : new Set(store.value.map(keyOf));
250
+ emitSelectionChange();
251
+ };
252
+ const getSelectionRows = () => selectedList.value;
253
+ const gridInstance = createDataListViewInstance({
254
+ clearSelection,
255
+ getSelectionRows,
256
+ toggleRowSelection: toggleSelect,
257
+ toggleAllSelection,
258
+ columns: props.columns
259
+ });
260
+ const assertItemScope = (row, index) => ({
261
+ fieldComponentMap: fieldComponentMap.value,
262
+ row,
263
+ index,
264
+ selected: isSelected(row),
265
+ toggleSelect: () => toggleSelect(row)
266
+ });
267
+ const expose = {
268
+ refresh,
269
+ reload,
270
+ getTableInstance: () => gridInstance
271
+ };
272
+ __expose(expose);
273
+ const exportContext = computed(
274
+ () => ({
275
+ columns: pickExportColumns(props.columns),
276
+ selectedList: selectedList.value,
277
+ currentPageList: store.value,
278
+ api: props.api,
279
+ query: props.query,
280
+ total: total.value,
281
+ hasSelection: hasSelectionColumn.value
282
+ })
283
+ );
284
+ const toolbarHeight = ref(0);
285
+ const onToolbarHeightChange = (h) => {
286
+ toolbarHeight.value = h;
287
+ };
288
+ const { viewportHeightFinal } = useChannelViewportHeight(props);
289
+ const toolbarHeightAdjust = computed(
290
+ () => props.showToolbar ? toolbarHeight.value : 0
291
+ );
292
+ const rawAvailableHeight = computed(() => {
293
+ if (typeof props.maxHeight === "number") {
294
+ return props.maxHeight - toolbarHeightAdjust.value;
295
+ }
296
+ if (props.refine) {
297
+ return viewportHeightFinal.value - toolbarHeightAdjust.value - props.refineReduceHeight;
298
+ }
299
+ return props.maxHeight;
300
+ });
301
+ const tableMaxHeight = computed(() => {
302
+ const raw = rawAvailableHeight.value;
303
+ if (raw === void 0) return void 0;
304
+ return typeof raw === "number" ? Math.max(raw, props.dataViewMaxHeightMinValue) : raw;
305
+ });
306
+ const skeletonMaxHeight = computed(
307
+ () => typeof tableMaxHeight.value === "number" ? tableMaxHeight.value : void 0
308
+ );
309
+ const showSkeleton = computed(
310
+ () => props.skeleton && loading.value && !hasData.value
311
+ );
312
+ const skeletonRowsFinal = computed(() => props.skeletonRows);
313
+ let suppressAutoParams = !props.initialSearch;
314
+ onMounted(() => {
315
+ pageSize.value = props.pageSizeInit;
316
+ onActivated(() => {
317
+ if (hasRequested.value) {
318
+ expose.refresh();
319
+ }
320
+ });
321
+ });
322
+ watch(
323
+ () => props.query,
324
+ (n, o) => {
325
+ if (JSON.stringify(n) === JSON.stringify(o)) return;
326
+ suppressAutoParams = false;
327
+ reload();
328
+ }
329
+ );
330
+ watch(
331
+ pageSize,
332
+ () => {
333
+ if (suppressAutoParams) return;
334
+ getList();
335
+ },
336
+ { immediate: true }
337
+ );
338
+ watch(store, (n) => {
339
+ emits("dataChange", n);
340
+ });
341
+ watch(publicLoading, (n) => {
342
+ emits("loadingChange", n);
343
+ });
344
+ return (_ctx, _cache) => {
345
+ return openBlock(), createElementBlock("div", _hoisted_1, [
346
+ __props.showToolbar ? (openBlock(), createBlock(unref(_sfc_main$1), {
347
+ key: 0,
348
+ class: "dc-data-grid-view__toolbar",
349
+ onHeightChange: onToolbarHeightChange
350
+ }, {
351
+ default: withCtx(() => [
352
+ createVNode(unref(TableToolbar), mergeProps({
353
+ "is-auto-refresh": isAutoRefresh.value,
354
+ "onUpdate:isAutoRefresh": _cache[0] || (_cache[0] = ($event) => isAutoRefresh.value = $event),
355
+ "refresh-interval": refreshInterval.value,
356
+ "onUpdate:refreshInterval": _cache[1] || (_cache[1] = ($event) => refreshInterval.value = $event),
357
+ tableExpose: expose,
358
+ loading: loading.value,
359
+ exportContext: exportContext.value,
360
+ showSwitchView: false,
361
+ currentPage: currentPage.value,
362
+ pageSize: pageSize.value
363
+ }, __props.toolbar), null, 16, ["is-auto-refresh", "refresh-interval", "loading", "exportContext", "currentPage", "pageSize"])
364
+ ]),
365
+ _: 1
366
+ })) : createCommentVNode("", true),
367
+ showSkeleton.value ? (openBlock(), createBlock(unref(TableSkeleton), {
368
+ key: 1,
369
+ class: "data-grid-view-table",
370
+ mode: "grid",
371
+ rows: skeletonRowsFinal.value,
372
+ maxHeight: skeletonMaxHeight.value
373
+ }, null, 8, ["rows", "maxHeight"])) : (openBlock(), createBlock(InfiniteListView, mergeProps({
374
+ key: 2,
375
+ ref_key: "infiniteList",
376
+ ref: infiniteList,
377
+ data: gridRows.value,
378
+ "item-key": rowKeyOfRow,
379
+ loading: loading.value && !store.value.length,
380
+ "loading-more": loadingMore.value,
381
+ error: error.value && store.value.length ? error.value : null,
382
+ finished: finished.value,
383
+ "max-height": tableMaxHeight.value
384
+ }, infiniteListPropsFinal.value, {
385
+ onLoadMore: fetchNextPage,
386
+ onRetry
387
+ }), {
388
+ item: withCtx(({ item, index }) => [
389
+ createElementVNode("div", {
390
+ class: "data-grid-view__grid",
391
+ style: normalizeStyle({ gridTemplateColumns: `repeat(${gridColumnsFinal.value}, 1fr)` })
392
+ }, [
393
+ (openBlock(true), createElementBlock(Fragment, null, renderList(item, (row, colIndex) => {
394
+ return openBlock(), createElementBlock("div", {
395
+ key: keyOf(row),
396
+ class: "data-grid-view__cell"
397
+ }, [
398
+ renderSlot(_ctx.$slots, "custom-view-item", mergeProps({ ref_for: true }, assertItemScope(row, index * gridColumnsFinal.value + colIndex)), () => [
399
+ createElementVNode("div", _hoisted_2, [
400
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
401
+ return openBlock(), createElementBlock("div", {
402
+ key: column.prop ?? column.type,
403
+ class: "data-grid-view__field"
404
+ }, [
405
+ createElementVNode("span", _hoisted_3, toDisplayString(column.label ?? column.prop) + ":", 1),
406
+ createElementVNode("span", _hoisted_4, [
407
+ (openBlock(), createBlock(resolveDynamicComponent(unref(fieldComponentMap)[fieldKeyOf(column)]), {
408
+ row,
409
+ index: index * gridColumnsFinal.value + colIndex,
410
+ selected: isSelected(row),
411
+ "toggle-select": () => toggleSelect(row)
412
+ }, null, 8, ["row", "index", "selected", "toggle-select"]))
413
+ ])
414
+ ]);
415
+ }), 128))
416
+ ])
417
+ ], true)
418
+ ]);
419
+ }), 128))
420
+ ], 4)
421
+ ]),
422
+ empty: withCtx(() => [
423
+ error.value && !store.value.length ? (openBlock(), createElementBlock("div", _hoisted_5, [
424
+ createElementVNode("span", null, toDisplayString(errorText.value), 1),
425
+ createVNode(unref(ElButton), {
426
+ size: "small",
427
+ onClick: onRetry
428
+ }, {
429
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
430
+ createTextVNode("重试", -1)
431
+ ])]),
432
+ _: 1
433
+ })
434
+ ])) : (openBlock(), createBlock(unref(_sfc_main$2), {
435
+ key: 1,
436
+ loading: loading.value,
437
+ "has-requested": hasRequested.value
438
+ }, null, 8, ["loading", "has-requested"]))
439
+ ]),
440
+ _: 3
441
+ }, 16, ["data", "loading", "loading-more", "error", "finished", "max-height"]))
442
+ ]);
443
+ };
444
+ }
445
+ });
446
+ export {
447
+ _sfc_main as default
448
+ };
@@ -1,7 +1,7 @@
1
1
  import _sfc_main from "./DataListView.vue2.mjs";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
- const DataListView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-da082546"]]);
4
+ const DataListView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ce0bb05b"]]);
5
5
  export {
6
6
  DataListView as default
7
7
  };
@@ -1,7 +1,8 @@
1
- import { defineComponent, computed, ref, watch, openBlock, createElementBlock, normalizeStyle, Fragment, renderList, createBlock, withCtx, renderSlot, createVNode, unref, markRaw, h } from "vue";
1
+ import { defineComponent, computed, ref, watch, openBlock, createElementBlock, normalizeStyle, Fragment, renderList, createBlock, withCtx, renderSlot, unref, createVNode } from "vue";
2
2
  import { ElEmpty } from "element-plus";
3
3
  import DataListViewItem from "./DataListViewItem.vue.mjs";
4
4
  import { createDataListViewInstance } from "./utils.mjs";
5
+ import { useDataViewFieldMap } from "./use-data-view-field-map.mjs";
5
6
  const _hoisted_1 = {
6
7
  key: 1,
7
8
  class: "data-list-view-empty"
@@ -61,66 +62,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
61
62
  selectedKeys.value = next;
62
63
  emitChange();
63
64
  };
64
- const makeFieldComp = (column) => markRaw(
65
- defineComponent({
66
- name: "DataViewField",
67
- props: {
68
- row: { type: Object, required: true },
69
- index: { type: Number, required: true },
70
- selected: { type: Boolean, default: false },
71
- toggleSelect: { type: Function, default: void 0 }
72
- },
73
- setup(p) {
74
- return () => {
75
- const { type, render, prop } = column;
76
- if (type === "index") {
77
- return h("span", String(p.index + 1));
78
- }
79
- if (type === "selection") {
80
- return h("input", {
81
- type: "checkbox",
82
- checked: p.selected,
83
- onChange: () => {
84
- var _a;
85
- return (_a = p.toggleSelect) == null ? void 0 : _a.call(p);
86
- }
87
- });
88
- }
89
- if (typeof render === "function") {
90
- return render({
91
- ...props.getRenderCtxParams(),
92
- row: p.row,
93
- column,
94
- _index: p.index
95
- });
96
- }
97
- if (render) {
98
- return h(render);
99
- }
100
- const v = prop ? p.row[prop] : void 0;
101
- return h("span", v === void 0 || v === null ? "" : String(v));
102
- };
103
- }
104
- })
105
- );
106
- const fieldComponentMap = computed(() => {
107
- const map = {};
108
- for (const column of props.columns) {
109
- if (column.type === "expand") continue;
110
- const key = column.type === "index" ? "$type_index" : column.type === "selection" ? "$type_selection" : column.prop;
111
- if (!key) {
112
- console.warn(
113
- "[DataListView] 列缺少 prop 且非 index/selection,跳过",
114
- column
115
- );
116
- continue;
117
- }
118
- if (map[key]) {
119
- console.warn(`[DataListView] 列 key 重复 "${key}",后者覆盖前者`);
120
- }
121
- map[key] = makeFieldComp(column);
122
- }
123
- return map;
65
+ const { fieldComponentMap } = useDataViewFieldMap({
66
+ columns: () => props.columns,
67
+ getRenderCtxParams: () => props.getRenderCtxParams()
124
68
  });
125
69
  const expose = createDataListViewInstance({
126
70
  clearSelection,
@@ -148,7 +92,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
148
92
  }, {
149
93
  default: withCtx(() => [
150
94
  renderSlot(_ctx.$slots, "item", {
151
- fieldComponentMap: fieldComponentMap.value,
95
+ fieldComponentMap: unref(fieldComponentMap),
152
96
  row,
153
97
  index,
154
98
  selected: isSelected(row),
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./InfiniteListView.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const InfiniteListView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e597453f"]]);
5
+ export {
6
+ InfiniteListView as default
7
+ };