@tmagic/table 1.5.0-beta.4 → 1.5.0-beta.6

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,8 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, withCtx, createElementBlock, Fragment, renderList, withDirectives, createVNode, createElementVNode, vShow, createTextVNode, resolveDynamicComponent, mergeProps, toHandlers, createCommentVNode, normalizeProps, toDisplayString, resolveComponent, ref, computed, resolveDirective } from 'vue';
2
2
  import { cloneDeep } from 'lodash-es';
3
- import { TMagicTableColumn, TMagicTooltip, TMagicButton, tMagicMessage, TMagicPopover, TMagicForm, TMagicTag, getConfig, TMagicTable } from '@tmagic/design';
4
- import { MForm } from '@tmagic/form';
5
- import { datetimeFormatter } from '@tmagic/utils';
3
+ import { TMagicTableColumn, TMagicTooltip, TMagicButton, tMagicMessage, TMagicPopover, TMagicForm, TMagicTag, getDesignConfig, TMagicTable } from '@tmagic/design';
4
+ import { MForm, datetimeFormatter } from '@tmagic/form';
6
5
 
7
6
  const _hoisted_1$2 = ["innerHTML"];
8
7
  const _sfc_main$5 = /* @__PURE__ */ defineComponent({
@@ -194,7 +193,11 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
194
193
  return props.config.props || {};
195
194
  };
196
195
  return (_ctx, _cache) => {
197
- return openBlock(), createBlock(unref(TMagicTableColumn), { type: "expand" }, {
196
+ return openBlock(), createBlock(unref(TMagicTableColumn), {
197
+ type: "expand",
198
+ width: _ctx.config.width,
199
+ fixed: _ctx.config.fixed
200
+ }, {
198
201
  default: withCtx((scope) => [
199
202
  _ctx.config.table ? (openBlock(), createBlock(_sfc_main, {
200
203
  key: 0,
@@ -214,7 +217,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
214
217
  _ctx.config.component ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.component), normalizeProps(mergeProps({ key: 3 }, componentProps(scope.row))), null, 16)) : createCommentVNode("", true)
215
218
  ]),
216
219
  _: 1
217
- });
220
+ }, 8, ["width", "fixed"]);
218
221
  };
219
222
  }
220
223
  });
@@ -234,6 +237,7 @@ const formatter = (item, row) => {
234
237
  return row[item.prop];
235
238
  }
236
239
  };
240
+ const createColumns = (columns) => columns;
237
241
 
238
242
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
239
243
  ...{
@@ -424,7 +428,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
424
428
  const emit = __emit;
425
429
  const tMagicTable = ref();
426
430
  const editState = ref([]);
427
- const tableColumnComponent = getConfig("components")?.tableColumn;
431
+ const tableColumnComponent = getDesignConfig("components")?.tableColumn;
428
432
  const selectionColumn = computed(() => {
429
433
  const column = props.columns.filter((item) => item.selection);
430
434
  return column.length ? column[0] : null;
@@ -552,4 +556,4 @@ const index = {
552
556
  }
553
557
  };
554
558
 
555
- export { _sfc_main as MagicTable, index as default, formatter };
559
+ export { _sfc_main as MagicTable, createColumns, index as default, formatter };
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('lodash-es'), require('@tmagic/design'), require('@tmagic/form'), require('@tmagic/utils')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'lodash-es', '@tmagic/design', '@tmagic/form', '@tmagic/utils'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicTable = {}, global.Vue, global.lodashEs, global.design, global.form, global.utils));
5
- })(this, (function (exports, vue, lodashEs, design, form, utils) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('lodash-es'), require('@tmagic/design'), require('@tmagic/form')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'lodash-es', '@tmagic/design', '@tmagic/form'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicTable = {}, global.Vue, global.lodashEs, global.design, global.form));
5
+ })(this, (function (exports, vue, lodashEs, design, form) { 'use strict';
6
6
 
7
7
  const _hoisted_1$2 = ["innerHTML"];
8
8
  const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
@@ -194,7 +194,11 @@
194
194
  return props.config.props || {};
195
195
  };
196
196
  return (_ctx, _cache) => {
197
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), { type: "expand" }, {
197
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
198
+ type: "expand",
199
+ width: _ctx.config.width,
200
+ fixed: _ctx.config.fixed
201
+ }, {
198
202
  default: vue.withCtx((scope) => [
199
203
  _ctx.config.table ? (vue.openBlock(), vue.createBlock(_sfc_main, {
200
204
  key: 0,
@@ -214,7 +218,7 @@
214
218
  _ctx.config.component ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.component), vue.normalizeProps(vue.mergeProps({ key: 3 }, componentProps(scope.row))), null, 16)) : vue.createCommentVNode("", true)
215
219
  ]),
216
220
  _: 1
217
- });
221
+ }, 8, ["width", "fixed"]);
218
222
  };
219
223
  }
220
224
  });
@@ -223,7 +227,7 @@
223
227
  if (!item.prop) return "";
224
228
  if (item.formatter) {
225
229
  if (item.formatter === "datetime") {
226
- item.formatter = (value) => utils.datetimeFormatter(value);
230
+ item.formatter = (value) => form.datetimeFormatter(value);
227
231
  }
228
232
  try {
229
233
  return item.formatter(row[item.prop], row);
@@ -234,6 +238,7 @@
234
238
  return row[item.prop];
235
239
  }
236
240
  };
241
+ const createColumns = (columns) => columns;
237
242
 
238
243
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
239
244
  ...{
@@ -424,7 +429,7 @@
424
429
  const emit = __emit;
425
430
  const tMagicTable = vue.ref();
426
431
  const editState = vue.ref([]);
427
- const tableColumnComponent = design.getConfig("components")?.tableColumn;
432
+ const tableColumnComponent = design.getDesignConfig("components")?.tableColumn;
428
433
  const selectionColumn = vue.computed(() => {
429
434
  const column = props.columns.filter((item) => item.selection);
430
435
  return column.length ? column[0] : null;
@@ -553,6 +558,7 @@
553
558
  };
554
559
 
555
560
  exports.MagicTable = _sfc_main;
561
+ exports.createColumns = createColumns;
556
562
  exports.default = index;
557
563
  exports.formatter = formatter;
558
564
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0-beta.4",
2
+ "version": "1.5.0-beta.6",
3
3
  "name": "@tmagic/table",
4
4
  "type": "module",
5
5
  "main": "dist/tmagic-table.umd.cjs",
@@ -46,9 +46,8 @@
46
46
  "peerDependencies": {
47
47
  "vue": "^3.4.35",
48
48
  "typescript": "*",
49
- "@tmagic/design": "1.5.0-beta.4",
50
- "@tmagic/utils": "1.5.0-beta.4",
51
- "@tmagic/form": "1.5.0-beta.4"
49
+ "@tmagic/design": "1.5.0-beta.6",
50
+ "@tmagic/form": "1.5.0-beta.6"
52
51
  },
53
52
  "peerDependenciesMeta": {
54
53
  "typescript": {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <TMagicTableColumn type="expand">
2
+ <TMagicTableColumn type="expand" :width="config.width" :fixed="config.fixed">
3
3
  <template #default="scope">
4
4
  <MTable
5
5
  v-if="config.table"
package/src/Table.vue CHANGED
@@ -66,7 +66,7 @@
66
66
  import { computed, ref } from 'vue';
67
67
  import { cloneDeep } from 'lodash-es';
68
68
 
69
- import { getConfig, TMagicTable } from '@tmagic/design';
69
+ import { getDesignConfig, TMagicTable } from '@tmagic/design';
70
70
 
71
71
  import ActionsColumn from './ActionsColumn.vue';
72
72
  import ComponentColumn from './ComponentColumn.vue';
@@ -121,7 +121,7 @@ const tMagicTable = ref<InstanceType<typeof TMagicTable>>();
121
121
 
122
122
  const editState = ref([]);
123
123
 
124
- const tableColumnComponent = getConfig('components')?.tableColumn;
124
+ const tableColumnComponent = getDesignConfig('components')?.tableColumn;
125
125
  const selectionColumn = computed(() => {
126
126
  const column = props.columns.filter((item) => item.selection);
127
127
  return column.length ? column[0] : null;
@@ -198,21 +198,3 @@ defineExpose({
198
198
  clearSelection,
199
199
  });
200
200
  </script>
201
-
202
- <style lang="scss">
203
- .m-table {
204
- .el-button.action-btn + .el-button.action-btn {
205
- margin-left: 0;
206
- }
207
- .keep-all {
208
- word-break: keep-all;
209
- }
210
- .el-table .cell > div {
211
- display: inline-block;
212
- vertical-align: middle;
213
- }
214
- .el-table__row.el-table__row--level-1 {
215
- color: #999;
216
- }
217
- }
218
- </style>
package/src/index.ts CHANGED
@@ -20,6 +20,8 @@ import { App } from 'vue';
20
20
 
21
21
  import Table from './Table.vue';
22
22
 
23
+ import './theme/index.scss';
24
+
23
25
  export { default as MagicTable } from './Table.vue';
24
26
  export * from './schema';
25
27
  export * from './utils';
package/src/schema.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  import { FormConfig, FormValue } from '@tmagic/form';
20
20
 
21
21
  export interface ColumnActionConfig {
22
- type?: 'delete' | 'copy' | 'edit';
22
+ type?: 'delete' | 'copy' | 'edit' | string;
23
23
  buttonType?: string;
24
24
  display?: (row: any) => boolean;
25
25
  text?: string | ((row: any) => string);
@@ -46,6 +46,7 @@ export interface ColumnConfig<T = any> {
46
46
  type?: 'popover' | 'expand' | 'component' | string | ((value: any, row: T) => string);
47
47
  text?: string;
48
48
  prop?: string;
49
+ name?: string;
49
50
  showHeader?: boolean;
50
51
  table?: ColumnConfig[];
51
52
  formatter?: 'datetime' | ((item: any, row: T) => any);
@@ -0,0 +1,15 @@
1
+ .m-table {
2
+ .el-button.action-btn + .el-button.action-btn {
3
+ margin-left: 0;
4
+ }
5
+ .keep-all {
6
+ word-break: keep-all;
7
+ }
8
+ .el-table .cell > div {
9
+ display: inline-block;
10
+ vertical-align: middle;
11
+ }
12
+ .el-table__row.el-table__row--level-1 {
13
+ color: #999;
14
+ }
15
+ }
package/src/utils.ts CHANGED
@@ -16,9 +16,9 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { datetimeFormatter } from '@tmagic/utils';
19
+ import { datetimeFormatter } from '@tmagic/form';
20
20
 
21
- import { ColumnConfig } from './schema';
21
+ import type { ColumnConfig } from './schema';
22
22
 
23
23
  export const formatter = (item: ColumnConfig, row: any) => {
24
24
  if (!item.prop) return '';
@@ -37,3 +37,5 @@ export const formatter = (item: ColumnConfig, row: any) => {
37
37
  return row[item.prop];
38
38
  }
39
39
  };
40
+
41
+ export const createColumns = (columns: ColumnConfig[]) => columns;
package/types/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { App } from 'vue';
3
3
  import { FormConfig, FormValue } from '@tmagic/form';
4
4
 
5
5
  interface ColumnActionConfig {
6
- type?: 'delete' | 'copy' | 'edit';
6
+ type?: 'delete' | 'copy' | 'edit' | string;
7
7
  buttonType?: string;
8
8
  display?: (row: any) => boolean;
9
9
  text?: string | ((row: any) => string);
@@ -31,6 +31,7 @@ interface ColumnConfig<T = any> {
31
31
  type?: 'popover' | 'expand' | 'component' | string | ((value: any, row: T) => string);
32
32
  text?: string;
33
33
  prop?: string;
34
+ name?: string;
34
35
  showHeader?: boolean;
35
36
  table?: ColumnConfig[];
36
37
  formatter?: 'datetime' | ((item: any, row: T) => any);
@@ -159,9 +160,10 @@ type __VLS_TypePropsToOption<T> = {
159
160
  };
160
161
 
161
162
  declare const formatter: (item: ColumnConfig, row: any) => any;
163
+ declare const createColumns: (columns: ColumnConfig[]) => ColumnConfig<any>[];
162
164
 
163
165
  declare const _default: {
164
166
  install(app: App): void;
165
167
  };
166
168
 
167
- export { type ColumnActionConfig, type ColumnConfig, _default$1 as MagicTable, _default as default, formatter };
169
+ export { type ColumnActionConfig, type ColumnConfig, _default$1 as MagicTable, createColumns, _default as default, formatter };