@aoao-y33/ui 0.0.2 → 0.0.5

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 (120) hide show
  1. package/README.md +0 -11
  2. package/dist/button/components/button/props.d.ts +43 -0
  3. package/dist/button/components/button/props.d.ts.map +1 -1
  4. package/dist/button/utils/index.d.ts +20 -0
  5. package/dist/button/utils/index.d.ts.map +1 -1
  6. package/dist/common/utils/iconUtils.d.ts +16 -0
  7. package/dist/common/utils/iconUtils.d.ts.map +1 -1
  8. package/dist/form/components/fields/index.d.ts.map +1 -1
  9. package/dist/form/components/form/form.vue.d.ts.map +1 -1
  10. package/dist/form/components/form/props.d.ts +43 -0
  11. package/dist/form/components/form/props.d.ts.map +1 -1
  12. package/dist/form/components/form-item/props.d.ts +29 -0
  13. package/dist/form/components/form-item/props.d.ts.map +1 -1
  14. package/dist/form/hoc/useForm.d.ts +43 -0
  15. package/dist/form/hoc/useForm.d.ts.map +1 -1
  16. package/dist/form/utils/index.d.ts +65 -0
  17. package/dist/form/utils/index.d.ts.map +1 -1
  18. package/dist/index.d.ts +0 -5
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +22523 -12091
  21. package/dist/layout/utils/index.d.ts +20 -0
  22. package/dist/layout/utils/index.d.ts.map +1 -1
  23. package/dist/modal/components/form-modal/props.d.ts +36 -1
  24. package/dist/modal/components/form-modal/props.d.ts.map +1 -1
  25. package/dist/modal/components/modal/props.d.ts +43 -1
  26. package/dist/modal/components/modal/props.d.ts.map +1 -1
  27. package/dist/modal/hoc/useFormModal.d.ts +50 -0
  28. package/dist/modal/hoc/useFormModal.d.ts.map +1 -1
  29. package/dist/modal/hoc/useModal.d.ts +55 -0
  30. package/dist/modal/hoc/useModal.d.ts.map +1 -1
  31. package/dist/modal/hoc/useModalExpose.d.ts +24 -0
  32. package/dist/modal/hoc/useModalExpose.d.ts.map +1 -1
  33. package/dist/table/components/table/props.d.ts +75 -0
  34. package/dist/table/components/table/props.d.ts.map +1 -1
  35. package/dist/table/components/table-column/props.d.ts +19 -0
  36. package/dist/table/components/table-column/props.d.ts.map +1 -1
  37. package/dist/table/components/table-page/props.d.ts +31 -0
  38. package/dist/table/components/table-page/props.d.ts.map +1 -1
  39. package/dist/table/components/table-select/props.d.ts +49 -0
  40. package/dist/table/components/table-select/props.d.ts.map +1 -1
  41. package/dist/table/hoc/useTable.d.ts +41 -0
  42. package/dist/table/hoc/useTable.d.ts.map +1 -1
  43. package/dist/table/hoc/useTableExpose.d.ts +27 -0
  44. package/dist/table/hoc/useTableExpose.d.ts.map +1 -1
  45. package/dist/table/utils/index.d.ts +26 -0
  46. package/dist/table/utils/index.d.ts.map +1 -1
  47. package/package.json +13 -6
  48. package/dist/global.d.ts +0 -33
  49. package/dist/global.d.ts.map +0 -1
  50. package/src/button/components/button/button.vue +0 -64
  51. package/src/button/components/button/index.ts +0 -2
  52. package/src/button/components/button/props.ts +0 -75
  53. package/src/button/components/fields/index.ts +0 -6
  54. package/src/button/hoc/index.ts +0 -1
  55. package/src/button/hoc/useButton.ts +0 -27
  56. package/src/button/index.ts +0 -4
  57. package/src/button/utils/index.ts +0 -32
  58. package/src/common/index.ts +0 -1
  59. package/src/common/utils/iconUtils.ts +0 -21
  60. package/src/common/utils/index.ts +0 -1
  61. package/src/form/components/fields/index.ts +0 -35
  62. package/src/form/components/form/form.vue +0 -130
  63. package/src/form/components/form/index.ts +0 -6
  64. package/src/form/components/form/props.ts +0 -73
  65. package/src/form/components/form-item/form-item.vue +0 -90
  66. package/src/form/components/form-item/index.ts +0 -6
  67. package/src/form/components/form-item/props.ts +0 -50
  68. package/src/form/hoc/index.ts +0 -3
  69. package/src/form/hoc/useForm.ts +0 -106
  70. package/src/form/hoc/useFormExpose.ts +0 -97
  71. package/src/form/hoc/useFormFetch.ts +0 -103
  72. package/src/form/index.ts +0 -5
  73. package/src/form/utils/index.ts +0 -149
  74. package/src/global.ts +0 -40
  75. package/src/index.ts +0 -37
  76. package/src/layout/components/fields/basic/basic.vue +0 -18
  77. package/src/layout/components/fields/index.ts +0 -10
  78. package/src/layout/components/fields/side/side.vue +0 -26
  79. package/src/layout/components/fields/top/top.vue +0 -13
  80. package/src/layout/components/layout/index.ts +0 -6
  81. package/src/layout/components/layout/layout.vue +0 -19
  82. package/src/layout/components/layout/props.ts +0 -3
  83. package/src/layout/hoc/index.ts +0 -1
  84. package/src/layout/hoc/useLayout.ts +0 -32
  85. package/src/layout/index.ts +0 -4
  86. package/src/layout/utils/index.ts +0 -31
  87. package/src/modal/components/form-modal/form-modal.vue +0 -158
  88. package/src/modal/components/form-modal/index.ts +0 -5
  89. package/src/modal/components/form-modal/props.ts +0 -61
  90. package/src/modal/components/modal/index.ts +0 -6
  91. package/src/modal/components/modal/modal.vue +0 -127
  92. package/src/modal/components/modal/props.ts +0 -78
  93. package/src/modal/hoc/index.ts +0 -3
  94. package/src/modal/hoc/useFormModal.ts +0 -140
  95. package/src/modal/hoc/useModal.ts +0 -151
  96. package/src/modal/hoc/useModalExpose.ts +0 -52
  97. package/src/modal/index.ts +0 -3
  98. package/src/style/index.css +0 -21
  99. package/src/table/components/fields/action-column/action-column.vue +0 -34
  100. package/src/table/components/fields/action-column/props.ts +0 -8
  101. package/src/table/components/fields/index.ts +0 -6
  102. package/src/table/components/table/index.ts +0 -6
  103. package/src/table/components/table/props.ts +0 -148
  104. package/src/table/components/table/table.vue +0 -77
  105. package/src/table/components/table-column/index.ts +0 -6
  106. package/src/table/components/table-column/props.ts +0 -26
  107. package/src/table/components/table-column/table-column.vue +0 -31
  108. package/src/table/components/table-page/index.ts +0 -6
  109. package/src/table/components/table-page/props.ts +0 -48
  110. package/src/table/components/table-page/table-page.vue +0 -51
  111. package/src/table/components/table-select/index.ts +0 -6
  112. package/src/table/components/table-select/props.ts +0 -79
  113. package/src/table/components/table-select/table-select.vue +0 -70
  114. package/src/table/hoc/index.ts +0 -2
  115. package/src/table/hoc/useTable.ts +0 -206
  116. package/src/table/hoc/useTableExpose.ts +0 -46
  117. package/src/table/index.ts +0 -7
  118. package/src/table/utils/index.ts +0 -37
  119. package/tsconfig.json +0 -30
  120. package/vite.config.ts +0 -49
package/src/global.ts DELETED
@@ -1,40 +0,0 @@
1
- // global.ts
2
- // @ts-ignore
3
-
4
- import type { AxButton } from './button'
5
- import type { AxForm } from './form'
6
- import type { AxFormItem } from './form'
7
- import type { AxLayout } from './layout'
8
- import type { AxModal } from './modal'
9
- import type { AxTable, AxTablePage, AxTableSelect, AxTableColumn } from './table'
10
-
11
- declare module 'vue' {
12
- export interface GlobalComponents {
13
- AxButton: typeof AxButton
14
- AxForm: typeof AxForm
15
- AxFormItem: typeof AxFormItem
16
- AxLayout: typeof AxLayout
17
- AxModal: typeof AxModal
18
- AxTable: typeof AxTable
19
- AxTablePage: typeof AxTablePage
20
- AxTableSelect: typeof AxTableSelect
21
- AxTableColumn: typeof AxTableColumn
22
- }
23
- }
24
-
25
- // 添加组件名称的 kebab-case 版本支持
26
- declare module 'vue' {
27
- export interface GlobalComponents {
28
- 'ax-button': typeof AxButton
29
- 'ax-form': typeof AxForm
30
- 'ax-form-item': typeof AxFormItem
31
- 'ax-layout': typeof AxLayout
32
- 'ax-modal': typeof AxModal
33
- 'ax-table': typeof AxTable
34
- 'ax-table-page': typeof AxTablePage
35
- 'ax-table-select': typeof AxTableSelect
36
- 'ax-table-column': typeof AxTableColumn
37
- }
38
- }
39
-
40
- export {}
package/src/index.ts DELETED
@@ -1,37 +0,0 @@
1
- import './style/index.css';
2
- import type {App} from "vue";
3
- import './global';
4
- import {AxButton, initButtonFields} from "@/button";
5
- import {AxForm, AxFormItem, initFormFields} from "@/form";
6
- import {AxLayout, initLayoutFields} from "@/layout";
7
- import {AxTable, AxTableColumn, AxTablePage, AxTableSelect, initTableColumns} from "@/table";
8
- import {AxModal} from "@/modal";
9
-
10
- export * from './modal';
11
- export * from './button';
12
- export * from './form';
13
- export * from './layout';
14
- export * from './table';
15
- export * from './common';
16
- initButtonFields();
17
- initFormFields();
18
- initLayoutFields();
19
- initTableColumns();
20
-
21
- export default {
22
- install(app: App) {
23
- initFormFields();
24
- initLayoutFields();
25
- initTableColumns();
26
- initButtonFields();
27
- app.component("ax-button", AxButton);
28
- app.component("ax-form", AxForm);
29
- app.component("ax-form-item", AxFormItem);
30
- app.component("ax-layout", AxLayout);
31
- app.component("ax-modal", AxModal);
32
- app.component("ax-table", AxTable);
33
- app.component("ax-table-page", AxTablePage);
34
- app.component("ax-table-select", AxTableSelect);
35
- app.component("ax-table-column", AxTableColumn);
36
- }
37
- }
@@ -1,18 +0,0 @@
1
- <template>
2
- <div class="w-full h-full flex flex-col overflow-hidden">
3
- <header class="w-full">
4
- <slot name="header"></slot>
5
- </header>
6
- <main class="flex flex-1 overflow-hidden h-full">
7
- <aside class="h-full overflow-hidden">
8
- <slot name="aside"></slot>
9
- </aside>
10
- <main class="flex-1 flex overflow-hidden h-full">
11
- <slot name="main"></slot>
12
- </main>
13
- </main>
14
- <footer class="w-full">
15
- <slot name="footer"></slot>
16
- </footer>
17
- </div>
18
- </template>
@@ -1,10 +0,0 @@
1
- import basic from './basic/basic.vue';
2
- import side from './side/side.vue';
3
- import top from './top/top.vue';
4
- import {addLayoutField} from "@/layout";
5
-
6
- export const initLayoutFields = () => {
7
- addLayoutField('basic', basic);
8
- addLayoutField('side', side);
9
- addLayoutField('top', top);
10
- }
@@ -1,26 +0,0 @@
1
- <template>
2
- <div class="w-full h-full flex overflow-hidden">
3
- <aside class="h-full overflow-hidden">
4
- <slot name="aside"></slot>
5
- </aside>
6
- <main class="h-full flex-1 flex flex-col overflow-hidden">
7
- <header class="w-full">
8
- <slot name="header"></slot>
9
- </header>
10
- <main class="flex-1 w-full overflow-hidden">
11
- <slot name="main"></slot>
12
- </main>
13
- <footer class="w-full">
14
- <slot name="footer"></slot>
15
- </footer>
16
- </main>
17
- </div>
18
- </template>
19
-
20
- <script setup lang="ts">
21
-
22
- </script>
23
-
24
- <style scoped>
25
-
26
- </style>
@@ -1,13 +0,0 @@
1
- <template>
2
- <div class="flex flex-col w-full h-full">
3
- <header class="w-full">
4
- <slot name="header"></slot>
5
- </header>
6
- <main class="flex-1 w-full flex overflow-hidden">
7
- <slot name="main"></slot>
8
- </main>
9
- <footer class="w-full">
10
- <slot name="footer"></slot>
11
- </footer>
12
- </div>
13
- </template>
@@ -1,6 +0,0 @@
1
- import layout from './layout.vue';
2
-
3
- export * from './props';
4
- export const AxLayout = layout;
5
- export type AxLayoutInstance = InstanceType<typeof layout>;
6
- export default AxLayout;
@@ -1,19 +0,0 @@
1
- <template>
2
- <Layout>
3
- <template v-for="slot in Object.keys(slots)" #[slot]>
4
- <slot :name="slot"></slot>
5
- </template>
6
- </Layout>
7
- </template>
8
-
9
- <script setup lang="ts">
10
- import {type AxLayoutProps} from "./props";
11
- import {computed, useSlots} from "vue";
12
- import {layoutFields} from "@/layout";
13
-
14
- const {type = 'basic'} = defineProps<AxLayoutProps>();
15
- const slots = useSlots();
16
- const Layout = computed(()=>{
17
- return layoutFields[type]
18
- })
19
- </script>
@@ -1,3 +0,0 @@
1
- export interface AxLayoutProps {
2
- type?: string;
3
- }
@@ -1 +0,0 @@
1
- export * from './useLayout';
@@ -1,32 +0,0 @@
1
- import {type Component, defineComponent, h, shallowRef} from "vue";
2
- import {AxLayout} from "@/layout";
3
- import {mergeDeep} from "@aoao-y33/utils";
4
-
5
- export interface AxLayoutOptions {
6
- type?: string;
7
- header?:Component;
8
- footer?:Component ;
9
- main?:Component ;
10
- aside?:Component ;
11
- }
12
- export function useLayout(options:AxLayoutOptions={}){
13
- const props = shallowRef(options);
14
- const setLayout=(options:AxLayoutOptions)=>{
15
- props.value = mergeDeep(props.value,options);
16
- }
17
- const Layout = defineComponent({
18
- setup(){
19
- const slots:Record<string, Component> = {};
20
- const keys = ['header','footer','main','aside'];
21
-
22
- keys.forEach(key=>{
23
- if(props.value?.[key as keyof typeof props.value]){
24
- slots[key] = ()=>h(props.value[key as keyof typeof props.value] as Component)
25
- }
26
- })
27
- return ()=>h(AxLayout as any,{type:props.value?.type},slots);
28
- }
29
- })
30
-
31
- return [Layout,setLayout] as const;
32
- }
@@ -1,4 +0,0 @@
1
- export * from './components/layout';
2
- export * from './components/fields';
3
- export * from './hoc';
4
- export * from './utils';
@@ -1,31 +0,0 @@
1
- import type {Component} from "vue";
2
-
3
- /**
4
- * 布局组件注册表
5
- * 存储布局类型与对应 Vue 组件的映射关系
6
- * @example
7
- * // 注册自定义布局组件
8
- * addLayoutField('sidebar', SidebarLayoutComponent)
9
- */
10
- export const layoutFields:Record<string, Component> = {};
11
-
12
- /**
13
- * 注册新的布局类型组件
14
- * 将自定义布局组件添加到布局类型注册表中
15
- *
16
- * @param type - 布局类型标识符(唯一)
17
- * @param component - 对应的 Vue 组件
18
- *
19
- * @warning 如果类型已存在,会输出警告信息并阻止重复注册
20
- *
21
- * @example
22
- * import CustomLayout from './CustomLayout.vue'
23
- * addLayoutField('custom-layout', CustomLayout)
24
- */
25
- export const addLayoutField = (type: string, component: Component) => {
26
- if (type in layoutFields) {
27
- console.warn(`[AxLayout] Layout type ${type} already exists`)
28
- return;
29
- }
30
- layoutFields[type] = component;
31
- }
@@ -1,158 +0,0 @@
1
- <template>
2
- <Modal v-bind="{...modalProps,...attrs}" v-model="_open"
3
- :header-class="'ax-form-modal-header'+' '+headerClass"
4
- :footer-class="'ax-form-modal-footer'+' '+footerClass"
5
- :body-class="'ax-form-modal-body'+' '+bodyClass"
6
- :close-icon
7
- :class="['ax-form-modal',className]"
8
- ref="modalRef"
9
- :show-close="false">
10
- <template #header v-if="title||showClose">
11
- <div class="flex justify-between items-center overflow-hidden gap-1">
12
- <div :title="title" class="flex-1 whitespace-nowrap text-ellipsis overflow-hidden">{{ title }}</div>
13
- <ElIcon @click="close">
14
- <Close/>
15
- </ElIcon>
16
- </div>
17
- </template>
18
- <template #default>
19
- <AxForm v-loading="_loading" v-bind="{...modalProps,...attrs} as AxFormProps" :is-default="false" ref="formRef">
20
- <slot></slot>
21
- </AxForm>
22
- </template>
23
- <template #footer v-if="slots.button||isDefault">
24
- <template v-if="isDefault">
25
- <ax-button v-bind="_confirmButton" @click="onConfirm"></ax-button>
26
- <ax-button v-bind="_cancelButton" @click="close"></ax-button>
27
- </template>
28
- <slot name="button"></slot>
29
- </template>
30
- </Modal>
31
- </template>
32
-
33
- <script setup lang="ts">
34
- import type {AxFormModalProps, AxFormModalEmits} from "./props";
35
- import {useDefineProps, useFetch} from "@aoao-y33/hooks";
36
- import {computed, type Ref, ref, useAttrs, useSlots} from "vue";
37
- import {type DrawerInstance, ElDialog, ElDrawer, ElIcon,vLoading} from "element-plus";
38
- import {AxButton, type AxButtonProps} from "@/button";
39
- import {Close} from "@element-plus/icons-vue";
40
- import {AxForm, type AxFormInstance, type AxFormProps, useFormExpose} from "@/form";
41
-
42
- const {
43
- type = 'dialog',
44
- showClose = true,
45
- open = false,
46
- title = '',
47
- isDefault = true,
48
- confirmButton = {},
49
- cancelButton = {},
50
- className = "md:w-[30%]! w-[100%]!",
51
- api = null,
52
- apiConfig = {},
53
- loading=false,
54
- ...props
55
- } = defineProps<AxFormModalProps>();
56
-
57
- const emits = defineEmits<AxFormModalEmits>();
58
-
59
- const _confirmButton = useDefineProps<AxButtonProps>(confirmButton, {
60
- text: '确定',
61
- icon: 'CircleCheckFilled',
62
- componentProps: {
63
- type: 'primary',
64
- }
65
- })
66
-
67
- const _cancelButton = useDefineProps<AxButtonProps>(cancelButton, {
68
- text: '取消',
69
- icon: 'CircleCloseFilled',
70
- componentProps: {
71
- type: 'default',
72
- }
73
- })
74
-
75
- const slots = useSlots();
76
-
77
- const attrs = useAttrs();
78
-
79
- const [,requestApi] = useFetch(api, apiConfig);
80
-
81
- const modalProps = useDefineProps(props);
82
-
83
- const _open = computed({
84
- get() {
85
- return open;
86
- },
87
- set(value) {
88
- emits('update:open', value);
89
- }
90
- })
91
-
92
- const _loading = computed(()=>{
93
- return Boolean(loading||requestApi.getConfig().loading);
94
- })
95
-
96
-
97
- const modalRef = ref<DrawerInstance>();
98
-
99
- const formRef = ref<AxFormInstance>() as Ref<AxFormInstance>;
100
-
101
- const formApi = useFormExpose(formRef);
102
-
103
- const Modal = computed(() => {
104
- return type === 'dialog' ? ElDialog : ElDrawer;
105
- })
106
-
107
- const close = () => {
108
- modalRef.value?.handleClose();
109
- emits("cancel");
110
- }
111
-
112
- const onConfirm = () => {
113
- const data = formApi.getValues();
114
- formApi.getElForm().validate((res) => {
115
- if(res){
116
- if(requestApi.getReady()){
117
- requestApi.load(data);
118
- }
119
- emits("confirm",data);
120
- }
121
- })
122
-
123
- }
124
-
125
- const getModal = () => {
126
- return modalRef.value;
127
- }
128
-
129
- defineExpose({
130
- getModal,
131
- close,
132
- ...formApi,
133
- ...requestApi,
134
- })
135
- </script>
136
-
137
- <style lang="scss">
138
- .ax-form-modal {
139
- padding: 0 !important;
140
- }
141
-
142
- .ax-form-modal-header {
143
- padding: 8px 12px;
144
- border-bottom: 1px solid var(--el-border-color);
145
- }
146
-
147
- .ax-form-modal-body {
148
- flex: 1;
149
- width: 100%;
150
- height: 100%;
151
- padding: 8px 12px;
152
- }
153
-
154
- .ax-form-modal-footer {
155
- padding: 8px 12px;
156
- border-top: 1px solid var(--el-border-color);
157
- }
158
- </style>
@@ -1,5 +0,0 @@
1
- import formModal from './form-modal.vue';
2
- export * from './props';
3
- export const AxFormModal = formModal;
4
- export default AxFormModal;
5
- export type AxFormModalInstance = InstanceType<typeof formModal>;
@@ -1,61 +0,0 @@
1
- import type {AxModalProps} from "@/modal";
2
- import type {AxFormItemOptions, AxFormProps} from "@/form";
3
- import type {EmitsToEventProps} from "@aoao-y33/utils";
4
- import type {FieldsConfig} from "@aoao-y33/hooks";
5
- import type {AxButtonOptions} from "@/button";
6
- import type {EmitsToProps} from "vue";
7
- import type {DrawerEmits} from "element-plus";
8
-
9
- /**
10
- * AxFormModal 表单弹窗组件属性接口
11
- * 继承自 AxModalProps(弹窗属性)和 AxFormProps(表单属性),组合了弹窗和表单的双重功能
12
- * @template T - 表单数据类型,必须是对象类型
13
- */
14
- export interface AxFormModalProps<T extends Record<string, any> = any> extends AxModalProps, Omit<AxFormProps<T>, 'size'> {
15
- // 继承了弹窗的所有属性和表单的大部分属性(排除了 size,避免与弹窗尺寸冲突)
16
- }
17
-
18
- /**
19
- * AxFormModal 表单弹窗组件事件发射接口
20
- * @template T - 表单数据类型
21
- */
22
- export interface AxFormModalEmits<T extends Record<string, any> = any> {
23
- /**
24
- * 弹窗显示状态变化事件(用于 v-model:open 双向绑定)
25
- * @param data - 新的显示状态(true/false)
26
- */
27
- 'update:open': [data: boolean]
28
-
29
- /**
30
- * 确认按钮点击事件,触发表单验证和提交
31
- * @param data - 验证通过后的表单数据
32
- */
33
- 'confirm': [data: T]
34
-
35
- /** 取消按钮点击事件或关闭弹窗时触发 */
36
- 'cancel': []
37
- }
38
-
39
- /**
40
- * AxFormModal 表单弹窗配置选项接口
41
- * 整合了弹窗属性、表单属性、事件处理和字段配置
42
- * @template T - 表单数据类型
43
- */
44
- export interface AxFormModalOptions<T extends Record<string, any> = any>
45
- extends Omit<AxFormModalProps<T>, 'open'>, // 排除 open 属性(由内部状态管理)
46
- EmitsToProps<DrawerEmits>, // 合并 Element Plus Drawer 的事件属性
47
- EmitsToEventProps<AxFormModalEmits<T>> { // 合并自定义事件处理函数
48
- /**
49
- * 按钮配置映射表,用于配置弹窗中的操作按钮(确认、取消等)
50
- * @see FieldsConfig - 字段配置类型
51
- * @see AxButtonOptions - 按钮选项类型
52
- */
53
- buttonConfig?: FieldsConfig<AxButtonOptions>
54
-
55
- /**
56
- * 表单项配置映射表,用于配置弹窗内表单的各个字段
57
- * @see FieldsConfig - 字段配置类型
58
- * @see AxFormItemOptions - 表单项选项类型
59
- */
60
- fieldConfig?: FieldsConfig<AxFormItemOptions>
61
- }
@@ -1,6 +0,0 @@
1
- import modal from './modal.vue';
2
-
3
- export * from './props';
4
- export const AxModal = modal;
5
- export type AxModalInstance = InstanceType<typeof modal>;
6
- export default AxModal;
@@ -1,127 +0,0 @@
1
- <template>
2
- <Modal v-bind="{...modalProps,...attrs}" v-model="_open"
3
- :header-class="'ax-modal-header'+' '+headerClass"
4
- :footer-class="'ax-modal-footer'+' '+footerClass"
5
- :body-class="'ax-modal-body'+' '+bodyClass"
6
- :close-icon
7
- :class="['ax-modal',className]"
8
- ref="modalRef"
9
- :show-close="false" >
10
- <template #header v-if="title||showClose">
11
- <div class="flex justify-between items-center overflow-hidden gap-1">
12
- <div :title="title" class="flex-1 whitespace-nowrap text-ellipsis overflow-hidden">{{title}}</div>
13
- <ElIcon @click="close">
14
- <Close/>
15
- </ElIcon>
16
- </div>
17
- </template>
18
- <template #default>
19
- <slot></slot>
20
- </template>
21
- <template #footer v-if="slots.button||isDefault">
22
- <template v-if="isDefault">
23
- <ax-button v-bind="_confirmButton" @click="onConfirm"></ax-button>
24
- <ax-button v-bind="_cancelButton" @click="close"></ax-button>
25
- </template>
26
- <slot name="button"></slot>
27
- </template>
28
- </Modal>
29
- </template>
30
-
31
- <script setup lang="ts">
32
- import type {AxModalProps, AxModalEmits} from "./props";
33
- import {useDefineProps} from "@aoao-y33/hooks";
34
- import {computed, ref, useAttrs, useSlots} from "vue";
35
- import {type DrawerInstance, ElDialog, ElDrawer,ElIcon} from "element-plus";
36
- import {AxButton, type AxButtonProps} from "@/button";
37
- import {Close} from "@element-plus/icons-vue";
38
-
39
- const {
40
- type = 'dialog',
41
- showClose = true,
42
- open = false,
43
- title = '',
44
- isDefault = true,
45
- confirmButton = {},
46
- cancelButton = {},
47
- className = "md:w-[30%]! w-[100%]!",
48
- ...props
49
- } = defineProps<AxModalProps>();
50
-
51
- const emits = defineEmits<AxModalEmits>();
52
-
53
- const _confirmButton = useDefineProps<AxButtonProps>(confirmButton, {
54
- text: '确定',
55
- icon: 'CircleCheckFilled',
56
- componentProps: {
57
- type: 'primary',
58
- }
59
- })
60
-
61
- const _cancelButton = useDefineProps<AxButtonProps>(cancelButton, {
62
- text: '取消',
63
- icon: 'CircleCloseFilled',
64
- componentProps: {
65
- type: 'default',
66
- }
67
- })
68
-
69
- const slots = useSlots();
70
-
71
- const attrs = useAttrs();
72
-
73
- const modalProps = useDefineProps(props);
74
-
75
- const _open = computed({
76
- get() {
77
- return open;
78
- },
79
- set(value) {
80
- emits('update:open', value);
81
- }
82
- })
83
-
84
- const modalRef = ref<DrawerInstance>();
85
-
86
- const Modal = computed(() => {
87
- return type === 'dialog' ? ElDialog : ElDrawer;
88
- })
89
-
90
- const close = ()=>{
91
- modalRef.value?.handleClose();
92
- emits("cancel");
93
- }
94
-
95
- const onConfirm=()=>{
96
- emits("confirm");
97
- }
98
-
99
- const getModal =()=>{
100
- return modalRef.value;
101
- }
102
-
103
- defineExpose({
104
- getModal,
105
- close
106
- })
107
- </script>
108
-
109
- <style lang="scss">
110
- .ax-modal{
111
- padding: 0 !important;
112
- }
113
- .ax-modal-header{
114
- padding: 8px 12px;
115
- border-bottom: 1px solid var(--el-border-color);
116
- }
117
- .ax-modal-body{
118
- flex:1;
119
- width: 100%;
120
- height: 100%;
121
- padding: 8px 12px;
122
- }
123
- .ax-modal-footer{
124
- padding: 8px 12px;
125
- border-top: 1px solid var(--el-border-color);
126
- }
127
- </style>