@aplus-frontend/ui 0.2.14 → 0.2.16

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.
@@ -1,24 +1,24 @@
1
- import { defineComponent as ve, useSlots as Te, ref as P, computed as s, unref as r, createVNode as y, Fragment as U, watchEffect as Fe, watch as G, openBlock as p, createElementBlock as T, normalizeClass as f, normalizeStyle as M, mergeProps as w, createSlots as _, withCtx as F, renderList as J, createBlock as Q, resolveDynamicComponent as xe, renderSlot as h, createCommentVNode as X, createElementVNode as I, normalizeProps as Be, guardReactiveProps as ke } from "vue";
2
- import { Divider as ze, Table as Pe } from "@aplus-frontend/antdv";
3
- import { useToken as Ie } from "@aplus-frontend/antdv/es/theme/internal";
4
- import { ApForm as Ne } from "../ap-form/index.mjs";
1
+ import { defineComponent as Te, useSlots as Fe, ref as P, computed as s, unref as r, createVNode as y, Fragment as U, watchEffect as xe, watch as G, openBlock as p, createElementBlock as T, normalizeClass as f, normalizeStyle as M, mergeProps as w, createSlots as _, withCtx as F, renderList as J, createBlock as Q, resolveDynamicComponent as Be, renderSlot as h, createCommentVNode as X, createElementVNode as I, normalizeProps as ke, guardReactiveProps as ze } from "vue";
2
+ import { Divider as Pe, Table as Ie } from "@aplus-frontend/antdv";
3
+ import { useToken as Ne } from "@aplus-frontend/antdv/es/theme/internal";
4
+ import { ApForm as Ee } from "../ap-form/index.mjs";
5
5
  import { noRenderAsFormItemValueList as Y } from "./constants.mjs";
6
6
  import "../config-provider/index.mjs";
7
- import { useTablePaging as Ee } from "./hooks/use-table-paging.mjs";
8
- import { omit as Z, isUndefined as m, isBoolean as Ke } from "lodash-unified";
9
- import { apColumnToColumn as Le, getTableTitle as Oe, getTableRenderType as Ve, getTableRenderProps as De, getTableCellRenderNode as Ae, getColumnOrder as ee, updateFormProps as je, getFieldProps as $e, getSearchFormItemRenderNode as We, recursionApColumns as ae, objectToString as He } from "./utils.mjs";
10
- import qe from "./hooks/use-table-content-height.mjs";
11
- import { getRawDisplayValue as Ue } from "../editable-table/utils.mjs";
12
- import Ge from "./hooks/use-table-row-selection.mjs";
13
- import { isDef as Me } from "../utils/index.mjs";
7
+ import { useTablePaging as Ke } from "./hooks/use-table-paging.mjs";
8
+ import { isUndefined as m, omit as Z, isBoolean as Le } from "lodash-unified";
9
+ import { getColumnOrder as ee, updateFormProps as Oe, getFieldProps as Ve, getSearchFormItemRenderNode as De, recursionApColumns as ae, apColumnToColumn as Ae, getTableTitle as je, getTableRenderType as $e, getTableRenderProps as We, getTableCellRenderNode as He, objectToString as qe } from "./utils.mjs";
10
+ import Ue from "./hooks/use-table-content-height.mjs";
11
+ import { getRawDisplayValue as Ge } from "../editable-table/utils.mjs";
12
+ import Me from "./hooks/use-table-row-selection.mjs";
13
+ import { isDef as _e } from "../utils/index.mjs";
14
14
  import "./components/setting/modal/index.vue.mjs";
15
15
  import "./components/paragraph-ellipsis/index.vue.mjs";
16
- import { useProvideApTable as _e } from "./context.mjs";
17
- import { useNamespace as Je } from "../config-provider/hooks/use-namespace.mjs";
18
- import { useGlobalConfig as Qe } from "../config-provider/hooks/use-global-config.mjs";
19
- import Xe from "./components/paragraph-ellipsis/index.vue2.mjs";
20
- import Ye from "./components/setting/modal/index.vue2.mjs";
21
- const Sa = /* @__PURE__ */ ve({
16
+ import { useProvideApTable as Je } from "./context.mjs";
17
+ import { useNamespace as Qe } from "../config-provider/hooks/use-namespace.mjs";
18
+ import { useGlobalConfig as Xe } from "../config-provider/hooks/use-global-config.mjs";
19
+ import Ye from "./components/paragraph-ellipsis/index.vue2.mjs";
20
+ import Ze from "./components/setting/modal/index.vue2.mjs";
21
+ const ba = /* @__PURE__ */ Te({
22
22
  name: "ApTable",
23
23
  __name: "ap-table",
24
24
  props: {
@@ -147,15 +147,15 @@ const Sa = /* @__PURE__ */ ve({
147
147
  }) {
148
148
  const a = oe;
149
149
  let N = 0;
150
- const S = Te(), [, re] = Ie(), {
150
+ const S = Fe(), [, re] = Ne(), {
151
151
  e: x,
152
152
  b: i,
153
153
  be: E
154
- } = Je("ap-table"), K = Qe("valueTypeMap"), {
154
+ } = Qe("ap-table"), K = Xe("valueTypeMap"), {
155
155
  height: le,
156
156
  contentRef: ne
157
- } = qe(), B = P(a.size), d = P([]), L = P([]);
158
- _e({
157
+ } = Ue(), B = P(a.size), d = P([]), L = P([]);
158
+ Je({
159
159
  columns: s(() => d.value),
160
160
  columnsBackup: s(() => L.value),
161
161
  size: s(() => B.value),
@@ -166,58 +166,13 @@ const Sa = /* @__PURE__ */ ve({
166
166
  B.value = e;
167
167
  }
168
168
  });
169
- const se = () => {
170
- var t;
171
- let e = ((t = a.columns) == null ? void 0 : t.filter((l) => !l.hideInTable)) || [];
172
- function o(l, u) {
173
- return l.map((n) => ({
174
- resizable: Me(n.resizable) ? n.resizable : a.columnResizable,
175
- ...Z(Le(n), ["ellipsis"]),
176
- fixed: u ? u.fixed : n.fixed,
177
- title: Oe(n, E("table-header", "title"), S.headerCell, r(re).colorPrimary),
178
- customRender({
179
- value: c,
180
- ...g
181
- }) {
182
- var H, q;
183
- const $ = Ve(n), be = De({
184
- ...n,
185
- valueType: $
186
- }, {
187
- value: c,
188
- ...g
189
- }), Re = Ae($, be, g.record, r(K)), W = ((H = n.renderText) == null ? void 0 : H.call(n, {
190
- value: c,
191
- ...g
192
- })) || c, Ce = n.renderText ? y(U, null, [(q = n.renderText) == null ? void 0 : q.call(n, {
193
- value: c,
194
- ...g
195
- })]) : Re;
196
- let z = ye(n, W, Ce);
197
- return n.customRender && (z = n.customRender({
198
- value: c,
199
- ...g,
200
- column: n,
201
- originalNode: z,
202
- originalText: W
203
- })), z;
204
- },
205
- children: o(n.children || [], u || n)
206
- }));
207
- }
208
- return o(e);
209
- };
210
- Fe(() => {
211
- const e = se();
212
- d.value = e, L.value = e;
213
- });
214
169
  const O = s(() => {
215
170
  var e, o, t;
216
171
  return N++, ((t = (o = (e = a.columns) == null ? void 0 : e.filter((l) => !l.hideInSearch && l.dataIndex && (l.valueType || l.customRenderFormItem) && !Y.includes(l.valueType))) == null ? void 0 : o.sort((l, u) => {
217
172
  let n = ee(l.order);
218
173
  return ee(u.order) - n;
219
174
  })) == null ? void 0 : t.map((l) => {
220
- const u = je(l, $e(l.fieldProps, {})), n = {
175
+ const u = Oe(l, Ve(l.fieldProps, {})), n = {
221
176
  ...l,
222
177
  fieldProps: {
223
178
  label: l.title,
@@ -227,35 +182,36 @@ const Sa = /* @__PURE__ */ ve({
227
182
  },
228
183
  renderNode: void 0
229
184
  };
230
- return n.renderNode = We(n, r(K)), n;
185
+ return n.renderNode = De(n, r(K)), n;
231
186
  })) || [];
232
- }), de = s(() => ae(r(d), (e) => {
187
+ }), se = s(() => ae(r(d), (e) => {
233
188
  if (e.sorter === !0)
234
189
  return e.key || e.dataIndex;
235
- }).filter(Boolean)), ue = s(() => ae(r(d), (e) => {
190
+ }).filter(Boolean)), de = s(() => ae(r(d), (e) => {
236
191
  if (e.filters && !e.onFilter)
237
192
  return e.key || e.dataIndex;
238
- }).filter(Boolean)), ie = s(() => m(a.dataSource) ? v.value.records : a.dataSource), {
193
+ }).filter(Boolean)), ue = s(() => m(a.dataSource) ? v.value.records : a.dataSource), {
239
194
  rowSelection: b,
240
- selectedRows: R,
241
- ...C
242
- } = Ge({
195
+ selectedRows: C,
196
+ ...R
197
+ } = Me({
243
198
  fixed: !0,
244
199
  ...a.rowSelection === !0 ? {} : a.rowSelection,
245
200
  rowKey: a.rowKey,
246
- dataSource: ie
201
+ dataSource: ue
247
202
  }), {
248
203
  formRef: k,
249
204
  submit: V,
250
205
  reset: D,
251
206
  tableProps: A,
252
- refresh: ce,
207
+ refresh: ie,
253
208
  data: v,
254
- setDataSource: pe
255
- } = Ee({
209
+ setDataSource: ce,
210
+ getColumnSFConfig: pe
211
+ } = Ke({
256
212
  async request(e) {
257
213
  var t, l;
258
- if (!b.value.preserveSelectedRowKeys && m(a.dataSource) && C.clearAll(), !m(a.dataSource))
214
+ if (!b.value.preserveSelectedRowKeys && m(a.dataSource) && R.clearAll(), !m(a.dataSource))
259
215
  return {
260
216
  data: a.dataSource || [],
261
217
  total: a.dataSource.length || 0
@@ -266,8 +222,8 @@ const Sa = /* @__PURE__ */ ve({
266
222
  total: (o == null ? void 0 : o.total) || 0
267
223
  };
268
224
  },
269
- filterFields: ue,
270
- sortFields: de,
225
+ filterFields: de,
226
+ sortFields: se,
271
227
  defaultParams: a.params,
272
228
  defaultData: a.defaultData,
273
229
  manual: a.manual,
@@ -276,7 +232,53 @@ const Sa = /* @__PURE__ */ ve({
276
232
  formatParams: a.beforeSearchSubmit,
277
233
  showLessItems: a.pagination ? a.pagination.showLessItems : void 0,
278
234
  showTotal: a.pagination ? a.pagination.showTotal : void 0
279
- }), fe = s(() => {
235
+ }), fe = () => {
236
+ var t;
237
+ let e = ((t = a.columns) == null ? void 0 : t.filter((l) => !l.hideInTable)) || [];
238
+ function o(l, u) {
239
+ return l.map((n) => ({
240
+ resizable: _e(n.resizable) ? n.resizable : a.columnResizable,
241
+ ...Z(Ae(n), ["ellipsis"]),
242
+ ...pe(n),
243
+ fixed: u ? u.fixed : n.fixed,
244
+ title: je(n, E("table-header", "title"), S.headerCell, r(re).colorPrimary),
245
+ customRender({
246
+ value: c,
247
+ ...g
248
+ }) {
249
+ var H, q;
250
+ const $ = $e(n), Ce = We({
251
+ ...n,
252
+ valueType: $
253
+ }, {
254
+ value: c,
255
+ ...g
256
+ }), Re = He($, Ce, g.record, r(K)), W = ((H = n.renderText) == null ? void 0 : H.call(n, {
257
+ value: c,
258
+ ...g
259
+ })) || c, ve = n.renderText ? y(U, null, [(q = n.renderText) == null ? void 0 : q.call(n, {
260
+ value: c,
261
+ ...g
262
+ })]) : Re;
263
+ let z = we(n, W, ve);
264
+ return n.customRender && (z = n.customRender({
265
+ value: c,
266
+ ...g,
267
+ column: n,
268
+ originalNode: z,
269
+ originalText: W
270
+ })), z;
271
+ },
272
+ children: o(n.children || [], u || n)
273
+ }));
274
+ }
275
+ return o(e);
276
+ };
277
+ xe(() => {
278
+ const e = fe();
279
+ d.value = e, L.value = e;
280
+ });
281
+ const me = s(() => {
280
282
  var o, t;
281
283
  if (a.adaptive && (v.value.total > 0 || ((o = a.dataSource) == null ? void 0 : o.length)))
282
284
  return {
@@ -285,7 +287,7 @@ const Sa = /* @__PURE__ */ ve({
285
287
  };
286
288
  if (a.scroll)
287
289
  return a.scroll;
288
- }), me = s(() => {
290
+ }), ge = s(() => {
289
291
  var e;
290
292
  if (a.tableLayout)
291
293
  return a.tableLayout;
@@ -304,62 +306,62 @@ const Sa = /* @__PURE__ */ ve({
304
306
  } : a.rowSelection,
305
307
  loading: m(a.loading) ? e.loading : a.loading,
306
308
  pagination: a.pagination === !1 ? !1 : e.pagination,
307
- scroll: r(fe)
309
+ scroll: r(me)
308
310
  };
309
- }), ge = s(() => [i(), a.card ? null : i("wrapper"), a.adaptive ? i("adaptive") : null].filter(Boolean));
310
- function ye(e, o, t) {
311
+ }), ye = s(() => [i(), a.card ? null : i("wrapper"), a.adaptive ? i("adaptive") : null].filter(Boolean));
312
+ function we(e, o, t) {
311
313
  if (Y.includes(e.valueType))
312
314
  return t;
313
- const l = He(o);
314
- return e.copyable || e.ellipsis ? y(Xe, {
315
+ const l = qe(o);
316
+ return e.copyable || e.ellipsis ? y(Ye, {
315
317
  copyable: e.copyable,
316
- ellipsis: e.ellipsis ? Ke(e.ellipsis) ? {
318
+ ellipsis: e.ellipsis ? Le(e.ellipsis) ? {
317
319
  tooltip: l
318
320
  } : {
319
321
  ...e.ellipsis,
320
322
  tooltip: l
321
323
  } : !1,
322
- content: e.ellipsis ? Ue(e, o) : t
324
+ content: e.ellipsis ? Ge(e, o) : t
323
325
  }, null) : t;
324
326
  }
325
327
  G(() => r(v).loading, (e) => {
326
328
  var o;
327
329
  (o = a.onLoadingChange) == null || o.call(a, e);
328
330
  }), G(() => a.dataSource, (e) => {
329
- pe(e);
331
+ ce(e);
330
332
  }, {
331
333
  immediate: !0
332
334
  });
333
- function we(e) {
335
+ function he(e) {
334
336
  var o, t, l;
335
337
  (l = (t = (o = k.value) == null ? void 0 : o.apForm) == null ? void 0 : t.setFieldsValue) == null || l.call(t, e);
336
338
  }
337
- function he() {
339
+ function Se() {
338
340
  var e, o, t;
339
341
  return (t = (o = (e = k.value) == null ? void 0 : e.apForm) == null ? void 0 : o.getFieldsValue) == null ? void 0 : t.call(o, !0);
340
342
  }
341
- function Se() {
343
+ function be() {
342
344
  return r(d);
343
345
  }
344
346
  return te({
345
347
  submit: () => V(),
346
348
  reset: () => D(),
347
- refresh: () => ce(),
348
- setSearchFormValues: we,
349
- getSearchFormValues: he,
350
- getShownColumns: Se,
349
+ refresh: () => ie(),
350
+ setSearchFormValues: he,
351
+ getSearchFormValues: Se,
352
+ getShownColumns: be,
351
353
  dataSource: s(() => r(v).records),
352
354
  rowSelection: {
353
- selectedRows: s(() => r(R)),
354
- ...C
355
+ selectedRows: s(() => r(C)),
356
+ ...R
355
357
  }
356
358
  }), (e, o) => (p(), T("div", {
357
- class: f(ge.value)
359
+ class: f(ye.value)
358
360
  }, [r(m)(e.dataSource) && e.searchForm !== !1 && O.value.length > 0 ? (p(), T("div", {
359
361
  key: 0,
360
362
  class: f(e.card ? r(x)("search-wrapper") : null),
361
363
  style: M(e.searchFormWrapperStyle)
362
- }, [y(r(Ne).SearchForm, w(e.searchForm || {}, {
364
+ }, [y(r(Ee).SearchForm, w(e.searchForm || {}, {
363
365
  ref_key: "formRef",
364
366
  ref: k,
365
367
  "custom-reset": "",
@@ -367,7 +369,7 @@ const Sa = /* @__PURE__ */ ve({
367
369
  onReset: r(D),
368
370
  "submit-loading": r(A).loading
369
371
  }), _({
370
- default: F(() => [(p(!0), T(U, null, J(O.value, (t) => (p(), Q(xe(t.renderNode), w({
372
+ default: F(() => [(p(!0), T(U, null, J(O.value, (t) => (p(), Q(Be(t.renderNode), w({
371
373
  key: t.dataIndex,
372
374
  ref_for: !0
373
375
  }, t.fieldProps || {}, {
@@ -391,39 +393,39 @@ const Sa = /* @__PURE__ */ ve({
391
393
  }, [I("div", {
392
394
  class: f(r(E)("header", "title"))
393
395
  }, [h(e.$slots, "title", w({
394
- selectedRows: r(R),
396
+ selectedRows: r(C),
395
397
  selectedRowKeys: r(b).selectedRowKeys,
396
398
  shownColumns: d.value
397
- }, C))], 2), S.title ? (p(), Q(r(ze), {
399
+ }, R))], 2), S.title ? (p(), Q(r(Pe), {
398
400
  key: 0,
399
401
  type: "vertical"
400
- })) : X("", !0), y(Ye, {
402
+ })) : X("", !0), y(Ze, {
401
403
  config: e.settings === !0 ? {} : e.settings
402
404
  }, null, 8, ["config"])], 2)) : h(e.$slots, "title", w({
403
405
  key: 1,
404
- selectedRows: r(R),
406
+ selectedRows: r(C),
405
407
  selectedRowKeys: r(b).selectedRowKeys,
406
408
  shownColumns: d.value
407
- }, C))], 2), y(r(Pe), w({
409
+ }, R))], 2), y(r(Ie), w({
408
410
  class: r(i)("table")
409
411
  }, j.value, {
410
412
  size: B.value,
411
- "table-layout": me.value,
413
+ "table-layout": ge.value,
412
414
  columns: d.value,
413
415
  onResizeColumn: o[0] || (o[0] = (t, l) => l.width = t)
414
416
  }), _({
415
417
  summary: F(() => [h(e.$slots, "summary", {
416
418
  columns: d.value,
417
419
  records: j.value.dataSource,
418
- selectedRows: r(R)
420
+ selectedRows: r(C)
419
421
  })]),
420
422
  _: 2
421
423
  }, [J(r(Z)(S, ["title", "searchFormExtra", "headerCell", "summary"]), (t, l) => ({
422
424
  name: l,
423
- fn: F((u) => [h(e.$slots, l, Be(ke(u || {})))])
425
+ fn: F((u) => [h(e.$slots, l, ke(ze(u || {})))])
424
426
  }))]), 1040, ["class", "size", "table-layout", "columns"])], 6)], 2));
425
427
  }
426
428
  });
427
429
  export {
428
- Sa as default
430
+ ba as default
429
431
  };
@@ -0,0 +1,9 @@
1
+ import { ApColumnType } from '../interface';
2
+ import { Recordable } from '../../type';
3
+ export declare const useTableSortedAndFiltered: () => {
4
+ getColumnSFConfig: (column: ApColumnType) => Recordable;
5
+ setSF: (filters: any, sorter: any) => void;
6
+ clearSorter: () => void;
7
+ clearFilters: () => void;
8
+ clearAll: () => void;
9
+ };
@@ -0,0 +1,30 @@
1
+ import { ref as i, unref as s } from "vue";
2
+ const F = () => {
3
+ const r = i(), t = i();
4
+ function c(e) {
5
+ const n = s(t) || {}, u = s(r) || {}, l = {};
6
+ return e.filters && (l.filteredValue = n[e.key] || null), e.sorter && (l.sortOrder = u.columnKey === e.key ? u.order : null), l;
7
+ }
8
+ function d(e, n) {
9
+ t.value = e, r.value = n;
10
+ }
11
+ function o() {
12
+ r.value = null;
13
+ }
14
+ function f() {
15
+ t.value = null;
16
+ }
17
+ function a() {
18
+ o(), f();
19
+ }
20
+ return {
21
+ getColumnSFConfig: c,
22
+ setSF: d,
23
+ clearSorter: o,
24
+ clearFilters: f,
25
+ clearAll: a
26
+ };
27
+ };
28
+ export {
29
+ F as useTableSortedAndFiltered
30
+ };
@@ -4,6 +4,8 @@ import { ApFormSearchFormExpose } from '../../ap-form';
4
4
  import { DataIndex } from '@aplus-frontend/antdv/es/vc-table/interface';
5
5
  import { TablePaginationConfig } from '@aplus-frontend/antdv';
6
6
  import { FilterValue, SorterResult, TableCurrentDataSource } from '@aplus-frontend/antdv/es/table/interface';
7
+ import { ApColumnType } from '..';
8
+ import { Recordable } from '../../type';
7
9
  export type UseTablePagingParams<DataType, ParamsType> = {
8
10
  request: (params: any) => Promise<RequestData<DataType>>;
9
11
  /**
@@ -92,4 +94,5 @@ export declare const useTablePaging: <DataType = any, ParamsType = Record<string
92
94
  }>;
93
95
  dataSource: ComputedRef<DataType[]>;
94
96
  setDataSource: (dataSource?: DataType[]) => void;
97
+ getColumnSFConfig: (column: ApColumnType) => Recordable;
95
98
  };