customs-ui-kit 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customs-ui-kit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/customs-ui-kit.umd.js",
5
5
  "module": "dist/customs-ui-kit.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,8 @@
13
13
  "./style.css": "./dist/style.css"
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "src"
17
18
  ],
18
19
  "scripts": {
19
20
  "dev": "vite",
@@ -35,6 +36,8 @@
35
36
  "@storybook/addon-interactions": "^8.6.14",
36
37
  "@storybook/addon-links": "^8.6.18",
37
38
  "@storybook/blocks": "^8.6.14",
39
+ "@storybook/manager-api": "^8.6.14",
40
+ "@storybook/theming": "^8.6.14",
38
41
  "@storybook/vue3": "^8.6.18",
39
42
  "@storybook/vue3-vite": "^8.6.18",
40
43
  "@types/express": "^5.0.6",
@@ -0,0 +1,52 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+ import { MyButton } from './index';
3
+
4
+ const meta = {
5
+ title: 'Components/MyButton',
6
+ component: MyButton,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ highlight: { control: 'boolean' },
10
+ type: {
11
+ control: { type: 'select' },
12
+ options: ['primary', 'success', 'warning', 'danger', 'info', 'default'],
13
+ },
14
+ size: {
15
+ control: { type: 'select' },
16
+ options: ['large', 'default', 'small'],
17
+ },
18
+ },
19
+ } satisfies Meta<typeof MyButton>;
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ export const Default: Story = {
25
+ args: {
26
+ type: 'primary',
27
+ highlight: false,
28
+ default: 'Click Me',
29
+ },
30
+ render: (args) => ({
31
+ components: { MyButton },
32
+ setup() {
33
+ return { args };
34
+ },
35
+ template: '<my-button v-bind="args">{{ args.default }}</my-button>',
36
+ }),
37
+ };
38
+
39
+ export const Highlighted: Story = {
40
+ args: {
41
+ type: 'success',
42
+ highlight: true,
43
+ default: 'Highlighted Button',
44
+ },
45
+ render: (args) => ({
46
+ components: { MyButton },
47
+ setup() {
48
+ return { args };
49
+ },
50
+ template: '<my-button v-bind="args">{{ args.default }}</my-button>',
51
+ }),
52
+ };
@@ -0,0 +1,36 @@
1
+ <script setup lang="ts">
2
+ import { ElButton } from 'element-plus';
3
+ import type { ButtonProps as ElButtonProps } from 'element-plus';
4
+ import { useCssModule } from 'vue';
5
+
6
+ /**
7
+ * 自定义按钮组件属性 (继承并扩展 Element Plus)
8
+ */
9
+ export interface MyButtonProps extends /* @vue-ignore */ Partial<ElButtonProps> {
10
+ /**
11
+ * 自定义业务类型:是否为强调按钮
12
+ * @default false
13
+ */
14
+ highlight?: boolean;
15
+ }
16
+
17
+ defineProps<MyButtonProps>();
18
+ </script>
19
+
20
+ <template>
21
+ <el-button v-bind="$attrs" :class="[$style.myButton, { [$style.isHighlight]: highlight }]">
22
+ <slot />
23
+ </el-button>
24
+ </template>
25
+
26
+ <style module>
27
+ .myButton {
28
+ /* 在这里可以添加基础的自定义样式 */
29
+ }
30
+
31
+ .isHighlight {
32
+ box-shadow: 0 0 8px rgba(64, 158, 255, 0.8);
33
+ transform: scale(1.02);
34
+ transition: all 0.3s ease;
35
+ }
36
+ </style>
@@ -0,0 +1,4 @@
1
+ import MyButton from './Button.vue';
2
+
3
+ export { MyButton };
4
+ export type { MyButtonProps } from './Button.vue';
@@ -0,0 +1,49 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3';
2
+ import { MyTable } from './index';
3
+
4
+ const meta = {
5
+ title: 'Components/MyTable',
6
+ component: MyTable,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ border: { control: 'boolean' },
10
+ },
11
+ } satisfies Meta<typeof MyTable>;
12
+
13
+ export default meta;
14
+ type Story = StoryObj<typeof meta>;
15
+
16
+ export const Default: Story = {
17
+ args: {
18
+ border: true,
19
+ columns: [
20
+ { prop: 'date', label: 'Date', width: '180' },
21
+ { prop: 'name', label: 'Name', width: '180' },
22
+ { prop: 'address', label: 'Address' },
23
+ ],
24
+ data: [
25
+ {
26
+ date: '2026-05-03',
27
+ name: 'Tom',
28
+ address: 'No. 189, Grove St, Los Angeles',
29
+ },
30
+ {
31
+ date: '2026-05-02',
32
+ name: 'John',
33
+ address: 'No. 189, Grove St, Los Angeles',
34
+ },
35
+ {
36
+ date: '2026-05-04',
37
+ name: 'Morgan',
38
+ address: 'No. 189, Grove St, Los Angeles',
39
+ },
40
+ ],
41
+ },
42
+ render: (args) => ({
43
+ components: { MyTable },
44
+ setup() {
45
+ return { args };
46
+ },
47
+ template: '<my-table v-bind="args" />',
48
+ }),
49
+ };
@@ -0,0 +1,80 @@
1
+ <script setup lang="ts">
2
+ import { ElTable, ElTableColumn } from 'element-plus';
3
+ import type { TableProps as ElTableProps } from 'element-plus';
4
+
5
+ /**
6
+ * 表格列配置定义
7
+ */
8
+ export interface MyTableColumn {
9
+ /** 列的属性名 */
10
+ prop: string;
11
+ /** 列的显示标题 */
12
+ label: string;
13
+ /** 列宽 */
14
+ width?: string | number;
15
+ /** 是否支持排序 */
16
+ sortable?: boolean;
17
+ }
18
+
19
+ /**
20
+ * 自定义表格组件属性
21
+ */
22
+ export interface MyTableProps extends /* @vue-ignore */ Partial<ElTableProps<any>> {
23
+ /**
24
+ * 表格数据数组
25
+ * @default []
26
+ */
27
+ data: any[];
28
+ /**
29
+ * 表格列配置数组
30
+ * @default []
31
+ */
32
+ columns: MyTableColumn[];
33
+ /**
34
+ * 是否显示边框
35
+ * @default true
36
+ */
37
+ border?: boolean;
38
+ }
39
+
40
+ withDefaults(defineProps<MyTableProps>(), {
41
+ data: () => [],
42
+ columns: () => [],
43
+ border: true
44
+ });
45
+ </script>
46
+
47
+ <template>
48
+ <div :class="$style.myTableWrapper">
49
+ <el-table :data="data" :border="border" v-bind="$attrs" :class="$style.myTable">
50
+ <el-table-column
51
+ v-for="col in columns"
52
+ :key="col.prop"
53
+ :prop="col.prop"
54
+ :label="col.label"
55
+ :width="col.width"
56
+ :sortable="col.sortable"
57
+ >
58
+ <!-- 允许通过具名插槽自定义列内容,插槽名为列的 prop -->
59
+ <template #default="scope" v-if="$slots[col.prop]">
60
+ <slot :name="col.prop" v-bind="scope" />
61
+ </template>
62
+ </el-table-column>
63
+
64
+ <!-- 允许追加其他列,比如操作列 -->
65
+ <slot name="append" />
66
+ </el-table>
67
+ </div>
68
+ </template>
69
+
70
+ <style module>
71
+ .myTableWrapper {
72
+ width: 100%;
73
+ overflow: hidden;
74
+ }
75
+
76
+ .myTable {
77
+ /* 自定义表格样式 */
78
+ --el-table-header-bg-color: #f5f7fa;
79
+ }
80
+ </style>
@@ -0,0 +1,4 @@
1
+ import MyTable from './Table.vue';
2
+
3
+ export { MyTable };
4
+ export type { MyTableProps, MyTableColumn } from './Table.vue';
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components/Button';
2
+ export * from './components/Table';