@xmszm/core 0.0.2 → 0.0.3
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.md +10 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +1296 -1285
- package/dist/plugin/vite/initRouteMeta.cjs +1 -0
- package/dist/plugin/vite/initRouteMeta.mjs +13 -0
- package/dist/style.css +1 -1
- package/docs/.vitepress/config.mjs +10 -1
- package/docs/components/config-options.md +125 -0
- package/docs/components/dataform.md +175 -22
- package/docs/components/datatable.md +21 -39
- package/docs/components/dialog.md +155 -16
- package/docs/components/options.md +43 -14
- package/docs/components/query.md +20 -12
- package/docs/components/utils.md +118 -10
- package/docs/guide/changelog.md +81 -0
- package/docs/guide/config.md +241 -4
- package/docs/guide/quickstart.md +27 -2
- package/docs/index.md +1 -1
- package/docs/usage.md +16 -3
- package/examples/README.md +46 -0
- package/examples/index.html +14 -0
- package/examples/package.json +25 -0
- package/examples/pnpm-lock.yaml +1569 -0
- package/examples/pnpm-workspace.yaml +3 -0
- package/examples/src/AdminSystem.vue +870 -0
- package/examples/src/App.vue +330 -0
- package/examples/src/Introduction.vue +307 -0
- package/examples/src/main.js +22 -0
- package/examples/src/utils/permission.js +16 -0
- package/examples/src/utils/request.js +10 -0
- package/examples/vite.config.js +41 -0
- package/package.json +10 -4
- package/src/dialog/commonDialog.tsx +285 -0
- package/src/dialog/utils/{dialog.js → dialog.ts} +2 -0
- package/src/enum/sort.tsx +45 -0
- package/src/form/DataForm.vue +26 -52
- package/src/{index.js → index.ts} +7 -6
- package/src/list/{useList.jsx → useList.tsx} +49 -14
- package/src/options/{Options.jsx → Options.tsx} +37 -36
- package/src/options/defaultOptions.tsx +656 -0
- package/src/query/CommonQuery.vue +57 -89
- package/src/table/DataTable.vue +60 -94
- package/src/table/opr/{DataColumnCollet.jsx → DataColumnCollet.tsx} +18 -8
- package/src/table/opr/{useDataColumn.jsx → useDataColumn.tsx} +43 -48
- package/src/table/opr/{useDataColumnButton.jsx → useDataColumnButton.tsx} +13 -6
- package/src/table/opr/{useDataColumnPop.jsx → useDataColumnPop.tsx} +13 -5
- package/src/utils/{array.js → array.ts} +4 -6
- package/src/utils/{config.js → config.ts} +16 -2
- package/src/utils/{dialog.js → dialog.ts} +2 -2
- package/src/utils/{object.js → object.ts} +1 -0
- package/src/utils/{upload.js → upload.ts} +3 -3
- package/types/components.d.ts +402 -0
- package/types/index.d.ts +145 -7
- package/types/plugin/vite/initRouteMeta.d.ts +23 -0
- package/types/src.d.ts +55 -0
- package/types/vue-shim.d.ts +9 -0
- package/examples/demo.vue +0 -224
- package/src/dialog/commonDialog.jsx +0 -262
- package/src/enum/sort.jsx +0 -31
- package/src/options/defaultOptions.jsx +0 -580
- /package/src/dialog/{useCommonDialog.js → useCommonDialog.ts} +0 -0
- /package/src/directives/{auto-register.js → auto-register.ts} +0 -0
- /package/src/directives/{permission.js → permission.ts} +0 -0
- /package/src/enum/{options.js → options.ts} +0 -0
- /package/src/plugin/{index.js → index.ts} +0 -0
- /package/src/plugin/vite/{initRouteMeta.js → initRouteMeta.ts} +0 -0
- /package/src/store/utils/{index.js → index.ts} +0 -0
- /package/src/table/opr/{useQRCode.js → useQRCode.ts} +0 -0
- /package/src/table/utils/{ellipsis.js → ellipsis.ts} +0 -0
- /package/src/utils/{auth.js → auth.ts} +0 -0
- /package/src/utils/{time.js → time.ts} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ObjectToArray } from '
|
|
1
|
+
import { ObjectToArray } from '../utils/object'
|
|
2
|
+
import type { FormOption, OptionsProps } from '../../types/components'
|
|
2
3
|
|
|
3
4
|
import { NFormItem, NIcon, NSpace } from 'naive-ui'
|
|
4
5
|
import {
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
ref,
|
|
10
11
|
unref,
|
|
11
12
|
watch,
|
|
13
|
+
type VNode,
|
|
12
14
|
} from 'vue'
|
|
13
15
|
import {
|
|
14
16
|
labelField as globalLabelField,
|
|
@@ -20,7 +22,7 @@ import { registerDirectives, getGlobalApp } from '../directives/auto-register'
|
|
|
20
22
|
import { getCurrentInstance } from 'vue'
|
|
21
23
|
|
|
22
24
|
export default defineComponent(
|
|
23
|
-
(props, { emit }) => {
|
|
25
|
+
(props: OptionsProps, { emit }) => {
|
|
24
26
|
// 自动注册 corePermission 指令(如果尚未注册)
|
|
25
27
|
// 必须在组件渲染前注册,确保指令可用
|
|
26
28
|
const instance = getCurrentInstance()
|
|
@@ -33,21 +35,21 @@ export default defineComponent(
|
|
|
33
35
|
registerDirectives(globalApp)
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
const _value = ref(props.value)
|
|
38
|
+
const _value = ref(props.value || {})
|
|
37
39
|
const _isRead = computed(() => props.read || false)
|
|
38
40
|
|
|
39
|
-
let _formRef = props.formRef
|
|
41
|
+
let _formRef: any = props.formRef
|
|
40
42
|
|
|
41
43
|
watch(
|
|
42
44
|
() => props.formRef,
|
|
43
|
-
v => (_formRef = v),
|
|
45
|
+
(v) => (_formRef = v),
|
|
44
46
|
)
|
|
45
|
-
const _data = computed(() => props.option)
|
|
47
|
+
const _data = computed(() => props.option || [])
|
|
46
48
|
|
|
47
|
-
function cellcetWayKeys(op) {
|
|
48
|
-
return op.reduce((a, b) => {
|
|
49
|
+
function cellcetWayKeys(op: FormOption[]): string[] {
|
|
50
|
+
return op.reduce((a: string[], b: FormOption) => {
|
|
49
51
|
a.push(b?.way ?? 'input')
|
|
50
|
-
const arr = [b?.default, b?.suffix, b?.prefix].reduce((k, k1) => {
|
|
52
|
+
const arr = [b?.default, b?.suffix, b?.prefix].reduce((k: any[], k1: any) => {
|
|
51
53
|
if (Array.isArray(k1)) {
|
|
52
54
|
k = k.concat(k1)
|
|
53
55
|
}
|
|
@@ -60,13 +62,13 @@ export default defineComponent(
|
|
|
60
62
|
console.log(arr)
|
|
61
63
|
|
|
62
64
|
if (arr.length)
|
|
63
|
-
arr.forEach(v => a.push(v?.way ?? 'input'))
|
|
65
|
+
arr.forEach((v: any) => a.push(v?.way ?? 'input'))
|
|
64
66
|
return a
|
|
65
67
|
}, [])
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
const _optionsByWayKey = computed(() => [
|
|
69
|
-
...new Set(cellcetWayKeys(props.option)),
|
|
71
|
+
...new Set(cellcetWayKeys(props.option || [])),
|
|
70
72
|
])
|
|
71
73
|
const defaultOption = getOptions(_optionsByWayKey.value)
|
|
72
74
|
console.log(props.option)
|
|
@@ -75,15 +77,15 @@ export default defineComponent(
|
|
|
75
77
|
() => _value.value,
|
|
76
78
|
(v) => {
|
|
77
79
|
emit('update:value', v)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
+
},
|
|
81
|
+
{
|
|
80
82
|
immediate: true,
|
|
81
83
|
})
|
|
82
84
|
|
|
83
|
-
function initProps(cProp) {
|
|
84
|
-
let obj = {}
|
|
85
|
+
function initProps(cProp: any, typeHint?: string): any {
|
|
86
|
+
let obj: any = {}
|
|
85
87
|
const type = typeof cProp
|
|
86
|
-
let handleProps = null
|
|
88
|
+
let handleProps: any = null
|
|
87
89
|
try {
|
|
88
90
|
if (!cProp) {
|
|
89
91
|
handleProps = cProp
|
|
@@ -95,14 +97,13 @@ export default defineComponent(
|
|
|
95
97
|
handleProps = cProp(unref(_value), {
|
|
96
98
|
formRef: _formRef,
|
|
97
99
|
resetForm: () => _formRef?.value?.restoreValidation(),
|
|
98
|
-
close: () => props.cancel(),
|
|
100
|
+
close: () => (props as any).cancel?.(),
|
|
99
101
|
setValue,
|
|
100
102
|
})
|
|
101
103
|
}
|
|
102
104
|
if (typeof handleProps === 'object' && !Array.isArray(handleProps)) {
|
|
103
105
|
Object.keys(handleProps).forEach((v) => {
|
|
104
106
|
const item = handleProps[v]
|
|
105
|
-
// console.log(item)
|
|
106
107
|
if (isRef(item))
|
|
107
108
|
obj[v] = unref(item)
|
|
108
109
|
else obj[v] = item
|
|
@@ -124,18 +125,17 @@ export default defineComponent(
|
|
|
124
125
|
(v) => {
|
|
125
126
|
console.log(v)
|
|
126
127
|
|
|
127
|
-
_value.value = v
|
|
128
|
+
_value.value = v || {}
|
|
128
129
|
},
|
|
129
130
|
{
|
|
130
131
|
immediate: true,
|
|
131
132
|
},
|
|
132
133
|
)
|
|
133
134
|
|
|
134
|
-
function setValue(val) {
|
|
135
|
+
function setValue(val: any) {
|
|
135
136
|
_value.value = val
|
|
136
137
|
}
|
|
137
|
-
function main(item) {
|
|
138
|
-
// console.log('main---重绘?', item)
|
|
138
|
+
function main(item: FormOption): VNode {
|
|
139
139
|
return (
|
|
140
140
|
<NSpace
|
|
141
141
|
wrap-item={false}
|
|
@@ -153,7 +153,7 @@ export default defineComponent(
|
|
|
153
153
|
)
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
function initMain(dom) {
|
|
156
|
+
function initMain(dom: any): VNode | string | null | undefined {
|
|
157
157
|
if (!dom)
|
|
158
158
|
return
|
|
159
159
|
let domHandle = dom
|
|
@@ -175,11 +175,11 @@ export default defineComponent(
|
|
|
175
175
|
|
|
176
176
|
return (
|
|
177
177
|
<>
|
|
178
|
-
{domHandle.map((item, index) => (
|
|
178
|
+
{domHandle.map((item: any, index: number) => (
|
|
179
179
|
<CreateFormItem item={item} index={index} />
|
|
180
180
|
))}
|
|
181
181
|
</>
|
|
182
|
-
)
|
|
182
|
+
) as any
|
|
183
183
|
}
|
|
184
184
|
else if (typeof domHandle === 'object') {
|
|
185
185
|
console.log('??? object')
|
|
@@ -201,20 +201,21 @@ export default defineComponent(
|
|
|
201
201
|
),
|
|
202
202
|
)
|
|
203
203
|
}
|
|
204
|
+
return null
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
function handleOptions(option) {
|
|
207
|
+
function handleOptions(option: FormOption): FormOption {
|
|
207
208
|
if (unref(option.enum))
|
|
208
209
|
option.options = ObjectToArray(unref(option.enum))
|
|
209
210
|
return option
|
|
210
211
|
}
|
|
211
212
|
|
|
212
|
-
function CreateFormItem({ item, index }) {
|
|
213
|
+
function CreateFormItem({ item, index }: { item: FormOption; index: number }): VNode {
|
|
213
214
|
item.formItemProps = initProps(item?.formItemProps)
|
|
214
215
|
if (!item.formItemProps)
|
|
215
216
|
item.formItemProps = {}
|
|
216
|
-
if (!item
|
|
217
|
-
item.formItemProps.labelWidth = props.formProps?.labelWidth
|
|
217
|
+
if (!(item.formItemProps as any)?.labelWidth && (props.formProps as any)?.labelWidth) {
|
|
218
|
+
(item.formItemProps as any).labelWidth = (props.formProps as any)?.labelWidth
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
return (
|
|
@@ -223,13 +224,13 @@ export default defineComponent(
|
|
|
223
224
|
key={index}
|
|
224
225
|
showLabel={!item?.noLabel}
|
|
225
226
|
{...item?.formItemProps}
|
|
226
|
-
labelWidth={item?.formItemProps?.labelWidth || 'auto'}
|
|
227
|
-
feedback={initProps(item?.formItemProps?.feedback, 'string')}
|
|
227
|
+
labelWidth={(item?.formItemProps as any)?.labelWidth || 'auto'}
|
|
228
|
+
feedback={initProps((item?.formItemProps as any)?.feedback, 'string')}
|
|
228
229
|
style={{
|
|
229
230
|
padding: '0 15px',
|
|
230
231
|
boxSizing: 'border-box',
|
|
231
232
|
width: '100%',
|
|
232
|
-
...(item?.formItemProps?.style || {}),
|
|
233
|
+
...((item?.formItemProps as any)?.style || {}),
|
|
233
234
|
}}
|
|
234
235
|
path={String(item.key)}
|
|
235
236
|
>
|
|
@@ -264,9 +265,9 @@ export default defineComponent(
|
|
|
264
265
|
<></>
|
|
265
266
|
)}
|
|
266
267
|
{`${unref(
|
|
267
|
-
typeof item?.[props.labelField] === 'function'
|
|
268
|
-
? item?.[props.labelField]?.()
|
|
269
|
-
: item?.[props.labelField],
|
|
268
|
+
typeof item?.[props.labelField || 'label'] === 'function'
|
|
269
|
+
? item?.[props.labelField || 'label']?.()
|
|
270
|
+
: item?.[props.labelField || 'label'],
|
|
270
271
|
) || ''
|
|
271
272
|
} ${_isRead.value || item.read ? ' ' : ' '}
|
|
272
273
|
`}
|
|
@@ -288,7 +289,7 @@ export default defineComponent(
|
|
|
288
289
|
...props.style,
|
|
289
290
|
}}
|
|
290
291
|
>
|
|
291
|
-
{_data.value.map(({ isRender = true, ...item }, index) => {
|
|
292
|
+
{_data.value.map(({ isRender = true, ...item }: any, index: number) => {
|
|
292
293
|
return (
|
|
293
294
|
typeof unref(isRender) !== 'boolean'
|
|
294
295
|
? isRender?.(unref(_value))
|