fantasia-ui 0.1.29 → 0.1.31

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/README.en.md ADDED
@@ -0,0 +1,103 @@
1
+ # Fantasia UI Component Library
2
+
3
+ ### Upload Component
4
+
5
+ *For detailed API usage, refer to [Secondary encapsulation based on el-upload to achieve multi-functional upload - CSDN Blog](https://blog.csdn.net/weixin_60818087/article/details/148193542?spm=1001.2014.3001.5502)*
6
+
7
+ > Import styles in `main.ts`: `import 'fantasia-ui/dist/index.css'`
8
+ >
9
+ > Missing icons? You need to install **Element-plus** icons for them to display.
10
+
11
+ ```vue
12
+ <script lang="ts">
13
+ import { FUpload } from 'fantasia-ui';
14
+
15
+ export default {
16
+ components: {
17
+ FUpload
18
+ },
19
+ methods: {
20
+ handleUpload: (file, done, error) => {
21
+ try {
22
+ console.log(file);
23
+ done();
24
+ } catch (err) {
25
+ error(err);
26
+ }
27
+ }
28
+ }
29
+ }
30
+ </script>
31
+
32
+ <template>
33
+ <FUpload crop mosaic @upload="handleUpload" />
34
+ </template>
35
+ ```
36
+
37
+ ### Table Component
38
+
39
+ ```vue
40
+ <script lang="ts" setup>
41
+ import { FTable } from 'fantasia-ui';
42
+ import type { Actions, Columns } from 'fantasia-ui/dist';
43
+ import { reactive } from 'vue';
44
+
45
+ const data = [
46
+ {
47
+ id: 1,
48
+ nickname: 'Test User'
49
+ }
50
+ ]
51
+
52
+ const columns = reactive<Columns[]>([
53
+ {
54
+ prop: 'id',
55
+ label: 'ID'
56
+ },
57
+ {
58
+ prop: 'nickname',
59
+ label: 'Nickname'
60
+ }
61
+ ])
62
+
63
+ const actions = reactive<Actions[]>([
64
+ {
65
+ action: 'switch',
66
+ event: 'change',
67
+ prop: 'change',
68
+ config: {
69
+ activeText: 'Enable',
70
+ inactiveText: 'Disable',
71
+ activeValue: 0,
72
+ inactiveValue: 1
73
+ }
74
+ },
75
+ {
76
+ action: 'button',
77
+ event: 'delete',
78
+ label: 'Delete',
79
+ type: 'danger',
80
+ icon: 'delete'
81
+ }
82
+ ])
83
+
84
+ const handleAction = (row: any, event: string) => {
85
+ switch (event) {
86
+ case 'change':
87
+ console.log("Switched");
88
+ break;
89
+ case 'delete':
90
+ console.log("Deleted");
91
+ break;
92
+ }
93
+ }
94
+ </script>
95
+
96
+ <template>
97
+ <FTable :data="data" :columns="columns" :actions="actions" @action="handleAction">
98
+ <template #id="{ row }">
99
+ <h1>{{ row }}</h1>
100
+ </template>
101
+ </FTable>
102
+ </template>
103
+ ```
package/README.md CHANGED
@@ -37,96 +37,66 @@ export default {
37
37
  ### Table 组件
38
38
 
39
39
  ```vue
40
- <script lang="ts">
40
+ <script lang="ts" setup>
41
41
  import { FTable } from 'fantasia-ui';
42
- import type { Actions, Columns } from 'fantasia-ui';
43
- import { ElEmpty } from 'element-plus';
42
+ import type { Actions, Columns } from 'fantasia-ui/dist';
43
+ import { reactive } from 'vue';
44
44
 
45
- interface Data {
46
- id: number;
47
- nickname: string;
48
- }
45
+ const data = [
46
+ {
47
+ id: 1,
48
+ nickname: '测试用户'
49
+ }
50
+ ]
49
51
 
50
- export default {
51
- components: {
52
- FTable
53
- },
54
- data: {
55
- columns: [
56
- {
57
- prop: 'id',
58
- label: 'ID',
59
- sortable: true
60
- },
61
- {
62
- prop: 'nickname',
63
- label: '昵称',
64
- },
65
- {
66
- prop: 'username',
67
- label: '用户名',
68
- align: 'center',
69
- filters: [
70
- {
71
- text: '测试',
72
- value: '测试'
73
- }
74
- ]
75
- }
76
- ],
77
- actions: [
78
- {
79
- action: 'button',
80
- label: '删除',
81
- event: 'delete',
82
- type: 'danger'
83
- },
84
- {
85
- action: 'button',
86
- label: '删除',
87
- event: 'delete',
88
- type: 'danger'
89
- },
90
- {
91
- action: 'button',
92
- label: '删除',
93
- event: 'delete',
94
- type: 'danger'
95
- },
96
- ],
97
- data: [
98
- {
99
- id: 1,
100
- nickname: '测试'
101
- }
102
- ]
52
+ const columns = reactive<Columns[]>([
53
+ {
54
+ prop: 'id',
55
+ label: 'ID'
103
56
  },
104
- methods: {
105
- handleAction: (row: Data, event: string) => {
106
- switch (event) {
107
- case 'delete':
108
- ElMessageBox.confirm(
109
- '确认删除?',
110
- '警告',
111
- {
112
- confirmButtonText: '确定',
113
- cancelButtonText: '取消',
114
- type: 'warning',
115
- }
116
- )
117
- break;
118
- default:
119
- return
120
- }
57
+ {
58
+ prop: 'nickname',
59
+ label: '昵称'
60
+ }
61
+ ])
62
+
63
+ const actions = reactive<Actions[]>([
64
+ {
65
+ action: 'switch',
66
+ event: 'change',
67
+ prop: 'change',
68
+ config: {
69
+ activeText: '启用',
70
+ inactiveText: '禁用',
71
+ activeValue: 0,
72
+ inactiveValue: 1
121
73
  }
74
+ },
75
+ {
76
+ action: 'button',
77
+ event: 'delete',
78
+ label: '删除',
79
+ type: 'danger',
80
+ icon: 'delete'
81
+ }
82
+ ])
83
+
84
+ const handleAction = (row: any, event: string) => {
85
+ switch (event) {
86
+ case 'change':
87
+ console.log("切换了");
88
+ break;
89
+ case 'delete':
90
+ console.log("删除了");
91
+ break;
122
92
  }
123
93
  }
124
94
  </script>
125
95
 
126
96
  <template>
127
- <FTable :columns="columns" :data="data" :actions="actions" @action="handleAction" border>
128
- <template #empty>
129
- <ElEmpty description="暂无数据" />
97
+ <FTable :data="data" :columns="columns" :actions="actions" @action="handleAction">
98
+ <template #id="{ row }">
99
+ <h1>{{ row }}</h1>
130
100
  </template>
131
101
  </FTable>
132
102
  </template>
@@ -1,14 +1,35 @@
1
1
  import { PropType } from 'vue';
2
- import { Actions, Columns, Data } from '../../types';
2
+ import { Actions, Columns, Data, Pagination } from '../../types';
3
3
  declare function __VLS_template(): {
4
4
  attrs: Partial<{}>;
5
- slots: Partial<Record<string, (_: {
6
- row: any;
7
- }) => any>> & {
8
- actions?(_: {
5
+ slots: Readonly<{
6
+ [prop: string]: {
9
7
  row: any;
10
- }): any;
11
- empty?(_: {}): any;
8
+ };
9
+ /**
10
+ * 自定义空内容插槽
11
+ * @param props 插槽属性
12
+ */
13
+ empty: any;
14
+ /**
15
+ * 自定义操作列插槽
16
+ * @param props 插槽属性
17
+ */
18
+ actions: any;
19
+ }> & {
20
+ [prop: string]: {
21
+ row: any;
22
+ };
23
+ /**
24
+ * 自定义空内容插槽
25
+ * @param props 插槽属性
26
+ */
27
+ empty: any;
28
+ /**
29
+ * 自定义操作列插槽
30
+ * @param props 插槽属性
31
+ */
32
+ actions: any;
12
33
  };
13
34
  refs: {};
14
35
  rootEl: any;
@@ -44,7 +65,24 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
44
65
  children: string;
45
66
  };
46
67
  };
68
+ pagination: {
69
+ type: PropType<Pagination>;
70
+ default: () => {
71
+ enable: boolean;
72
+ options: {
73
+ currentPage: number;
74
+ pageSize: number;
75
+ total: number;
76
+ layout: string;
77
+ pageSizes: number[];
78
+ pagerCount: number;
79
+ justifyContent: string;
80
+ };
81
+ };
82
+ };
47
83
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
84
+ "update:pageSize": (...args: any[]) => void;
85
+ "update:currentPage": (...args: any[]) => void;
48
86
  action: (...args: any[]) => void;
49
87
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
50
88
  columns: {
@@ -76,7 +114,24 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
76
114
  children: string;
77
115
  };
78
116
  };
117
+ pagination: {
118
+ type: PropType<Pagination>;
119
+ default: () => {
120
+ enable: boolean;
121
+ options: {
122
+ currentPage: number;
123
+ pageSize: number;
124
+ total: number;
125
+ layout: string;
126
+ pageSizes: number[];
127
+ pagerCount: number;
128
+ justifyContent: string;
129
+ };
130
+ };
131
+ };
79
132
  }>> & Readonly<{
133
+ "onUpdate:pageSize"?: (...args: any[]) => any;
134
+ "onUpdate:currentPage"?: (...args: any[]) => any;
80
135
  onAction?: (...args: any[]) => any;
81
136
  }>, {
82
137
  data: Data[];
@@ -87,6 +142,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
87
142
  treeProps: {
88
143
  children: string;
89
144
  };
145
+ pagination: Pagination;
90
146
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
91
147
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
92
148
  export default _default;