@ithinkdt/page 4.0.22 → 4.1.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 +5 -5
- package/src/crud.js +3 -6
- package/src/data-source.js +1 -1
- package/src/description.js +4 -4
- package/src/form.d.ts +1 -0
- package/src/form.js +34 -37
- package/src/list.js +1 -1
- package/src/plugin.js +1 -1
- package/src/rules.js +2 -2
- package/src/table.js +5 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ithinkdt/page",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "iThinkDT Page",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"sideEffects": false,
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@vueuse/core": "^14.3.0",
|
|
43
|
-
"nanoid": "^5.1.
|
|
44
|
-
"@ithinkdt/common": "^4.
|
|
43
|
+
"nanoid": "^5.1.15",
|
|
44
|
+
"@ithinkdt/common": "^4.1.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"vue": ">=3.5",
|
|
48
|
-
"vue-router": ">=
|
|
48
|
+
"vue-router": ">=5.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "~6.0.3",
|
|
52
52
|
"vite": "^8.0.16",
|
|
53
|
-
"vue": "^3.5.
|
|
53
|
+
"vue": "^3.5.38",
|
|
54
54
|
"vue-router": "^5.1.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
package/src/crud.js
CHANGED
|
@@ -70,10 +70,7 @@ function _useSimpleCrudModal(crudType, getItems, request, options) {
|
|
|
70
70
|
const setModalType = (crudType) => {
|
|
71
71
|
let type = options.modalType
|
|
72
72
|
if (typeof type === 'function') {
|
|
73
|
-
type = type(
|
|
74
|
-
model: model.value,
|
|
75
|
-
type: crudType,
|
|
76
|
-
})
|
|
73
|
+
type = type(crudType)
|
|
77
74
|
} else if (isRef(type)) {
|
|
78
75
|
type = type.value
|
|
79
76
|
}
|
|
@@ -123,14 +120,14 @@ function _useSimpleCrudModal(crudType, getItems, request, options) {
|
|
|
123
120
|
initial
|
|
124
121
|
.then((res) => {
|
|
125
122
|
model.value = res
|
|
123
|
+
modal.reset(res)
|
|
126
124
|
}).finally(() => {
|
|
127
125
|
loading.value = false
|
|
128
126
|
})
|
|
129
127
|
}
|
|
130
128
|
setModalType(crudType)
|
|
131
129
|
const $open = modal.open(model.value, title)
|
|
132
|
-
if (crudType
|
|
133
|
-
return $open
|
|
130
|
+
if (crudType !== 'view') return $open
|
|
134
131
|
},
|
|
135
132
|
}
|
|
136
133
|
}
|
package/src/data-source.js
CHANGED
|
@@ -142,7 +142,7 @@ export function useDs(fetch, options = {}) {
|
|
|
142
142
|
if (
|
|
143
143
|
pagination === true
|
|
144
144
|
&& getOriData().length > 0
|
|
145
|
-
&&
|
|
145
|
+
&& ['filter', 'sortField', 'sortOrder'].every(it => !(it in params2))
|
|
146
146
|
) {
|
|
147
147
|
Object.assign(params, params2)
|
|
148
148
|
await nextTick()
|
package/src/description.js
CHANGED
|
@@ -56,10 +56,10 @@ export function useDescriptionsHelper(
|
|
|
56
56
|
|
|
57
57
|
const bindings = { }
|
|
58
58
|
for (const k of Object.keys(options ?? {})) {
|
|
59
|
-
if (k.length > render.length && k.startsWith(render))
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
if (!(k.length > render.length && k.startsWith(render))) continue
|
|
60
|
+
|
|
61
|
+
bindings[uncapitalize(k.slice(render.length))] = options[k]
|
|
62
|
+
delete options[k]
|
|
63
63
|
}
|
|
64
64
|
const bindings0 = computed(() => {
|
|
65
65
|
return Object.fromEntries(Object.entries(bindings)
|
package/src/form.d.ts
CHANGED
|
@@ -255,6 +255,7 @@ export type FormModalOptions<Model extends {}> = FormModalOptionsBase & FormHelp
|
|
|
255
255
|
export interface FormModal<Model extends {}> extends Omit<ModalReturns, 'open'> {
|
|
256
256
|
open(this: void, model: MaybePromise<Model>, title?: VNodeChild | (() => VNodeChild)): PromiseLike<Model>
|
|
257
257
|
reinit(this: void): void
|
|
258
|
+
reset(this: void, initial?: Partial<Model>, overwrite?: boolean, reinit?: boolean): Partial<Model>
|
|
258
259
|
}
|
|
259
260
|
export declare function useFormModal<Model extends {}>(options: FormModalOptions<Model>):
|
|
260
261
|
FormModal<Model>
|
package/src/form.js
CHANGED
|
@@ -61,10 +61,10 @@ export function useFormHelper(items, { initial: initial0, rules, onChange, inFil
|
|
|
61
61
|
}
|
|
62
62
|
const bindings = {}
|
|
63
63
|
for (const k of Object.keys(options)) {
|
|
64
|
-
if (k.length > render.length && k.startsWith(render))
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if (!(k.length > render.length && k.startsWith(render))) continue
|
|
65
|
+
|
|
66
|
+
bindings[uncapitalize(k.slice(render.length))] = options[k]
|
|
67
|
+
delete options[k]
|
|
68
68
|
}
|
|
69
69
|
const bindings0 = computed(() => {
|
|
70
70
|
return Object.fromEntries(Object.entries(bindings)
|
|
@@ -131,23 +131,22 @@ export function useFormHelper(items, { initial: initial0, rules, onChange, inFil
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
return [invalid.value, _mergeValidation(result, result2 ?? {})]
|
|
134
|
-
} else {
|
|
135
|
-
restoreValidation(prop)
|
|
136
|
-
const it = items0.value.find(it => it.name === prop && unref(it.hidden) != true)
|
|
137
|
-
const result = { errors: [], warnings: [] }
|
|
138
|
-
await Promise.allSettled(
|
|
139
|
-
rules[it.__key]
|
|
140
|
-
?.map(r => r.validator(r, model[prop])
|
|
141
|
-
.then((ret) => {
|
|
142
|
-
if (ret) {
|
|
143
|
-
result[r.level === 'warning' ? 'warnings' : 'errors'].push(ret)
|
|
144
|
-
}
|
|
145
|
-
}),
|
|
146
|
-
) ?? [],
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
return [_checkInvalid(result.errors), result]
|
|
150
134
|
}
|
|
135
|
+
restoreValidation(prop)
|
|
136
|
+
const it = items0.value.find(it => it.name === prop && unref(it.hidden) != true)
|
|
137
|
+
const result = { errors: [], warnings: [] }
|
|
138
|
+
await Promise.allSettled(
|
|
139
|
+
rules[it.__key]
|
|
140
|
+
?.map(r => r.validator(r, model[prop])
|
|
141
|
+
.then((ret) => {
|
|
142
|
+
if (ret) {
|
|
143
|
+
result[r.level === 'warning' ? 'warnings' : 'errors'].push(ret)
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
) ?? [],
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
return [_checkInvalid(result.errors), result]
|
|
151
150
|
}
|
|
152
151
|
const restoreValidation = (props) => {
|
|
153
152
|
if (!props) {
|
|
@@ -191,20 +190,19 @@ export function useFormHelper(items, { initial: initial0, rules, onChange, inFil
|
|
|
191
190
|
),
|
|
192
191
|
)
|
|
193
192
|
return [invalid.value, result]
|
|
194
|
-
} else {
|
|
195
|
-
const it = items0.value.find(it => it.name === prop && unref(it.hidden) != true)
|
|
196
|
-
const result = { errors: [], warnings: [] }
|
|
197
|
-
await Promise.resolve(
|
|
198
|
-
it.beforeSubmit?.(model[prop], model))
|
|
199
|
-
.then((ret) => {
|
|
200
|
-
if (typeof ret === 'string') {
|
|
201
|
-
validation[prop].errors.push(ret)
|
|
202
|
-
result.errors.push(ret)
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
return [_checkInvalid(result.errors), result]
|
|
207
193
|
}
|
|
194
|
+
const it = items0.value.find(it => it.name === prop && unref(it.hidden) != true)
|
|
195
|
+
const result = { errors: [], warnings: [] }
|
|
196
|
+
await Promise.resolve(
|
|
197
|
+
it.beforeSubmit?.(model[prop], model))
|
|
198
|
+
.then((ret) => {
|
|
199
|
+
if (typeof ret !== 'string') return
|
|
200
|
+
|
|
201
|
+
validation[prop].errors.push(ret)
|
|
202
|
+
result.errors.push(ret)
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
return [_checkInvalid(result.errors), result]
|
|
208
206
|
}
|
|
209
207
|
|
|
210
208
|
const returns = {
|
|
@@ -277,7 +275,7 @@ export function useFormHelper(items, { initial: initial0, rules, onChange, inFil
|
|
|
277
275
|
}
|
|
278
276
|
|
|
279
277
|
const rule = item.rule ? [item.rule].flat() : []
|
|
280
|
-
if (item.required &&
|
|
278
|
+
if (item.required && rule.every(r => !isRequiredRule(r))) {
|
|
281
279
|
rule.push(required(() => t('common.page.form.validate.requiredMessage'), { required: item.required }))
|
|
282
280
|
}
|
|
283
281
|
if (rule.length > 0) {
|
|
@@ -441,9 +439,7 @@ export function useFilterHelper(items, { customizable = false, cached, cacheVers
|
|
|
441
439
|
const raw = StorageSerializers.object.write([sort, hidden])
|
|
442
440
|
return storage.setItem(key, raw)
|
|
443
441
|
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (!customizable) {
|
|
442
|
+
} else {
|
|
447
443
|
reinit()
|
|
448
444
|
}
|
|
449
445
|
|
|
@@ -600,6 +596,7 @@ export function useFormModal({ initial, items, rules, onSubmit, submitText, canc
|
|
|
600
596
|
...modal,
|
|
601
597
|
open,
|
|
602
598
|
reinit: form.reinit,
|
|
599
|
+
reset: form.reset,
|
|
603
600
|
})
|
|
604
601
|
return returns
|
|
605
602
|
}
|
package/src/list.js
CHANGED
|
@@ -161,7 +161,7 @@ export function useListPageCustomization({
|
|
|
161
161
|
})
|
|
162
162
|
|
|
163
163
|
function removeProfile(key) {
|
|
164
|
-
const removeProfile = config.value.profiles.
|
|
164
|
+
const removeProfile = config.value.profiles.some(profile => profile.key === key)
|
|
165
165
|
|
|
166
166
|
let newProfiles = config.value.profiles
|
|
167
167
|
if (removeProfile) {
|
package/src/plugin.js
CHANGED
|
@@ -27,7 +27,7 @@ export function plugin(app, options) {
|
|
|
27
27
|
pageInjection = { keyField: 'key', ...options }
|
|
28
28
|
app.provide(PAGE_INJECTION, pageInjection)
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
addEventListener('unhandledrejection', (ev) => {
|
|
31
31
|
if (!ev?.reason) return
|
|
32
32
|
if (ev.reason instanceof IgnoreRejectionError) {
|
|
33
33
|
ev.preventDefault()
|
package/src/rules.js
CHANGED
|
@@ -61,8 +61,8 @@ export const plateNo = (message, options) =>
|
|
|
61
61
|
message,
|
|
62
62
|
options,
|
|
63
63
|
)
|
|
64
|
-
export const noChinese = (message, options) => pattern(/^[^\
|
|
65
|
-
export const chinese = (message, options) => pattern(/^[\
|
|
64
|
+
export const noChinese = (message, options) => pattern(/^[^\u{4E00}-\u{9FA5}]+$/u, message, options)
|
|
65
|
+
export const chinese = (message, options) => pattern(/^[\u{4E00}-\u{9FA5}]+$/u, message, options)
|
|
66
66
|
|
|
67
67
|
export const requiredRuleSymbol = Symbol('rule:required')
|
|
68
68
|
export function required(message, { required = true, trigger = ['input', 'blur', 'change'] } = {}) {
|
package/src/table.js
CHANGED
|
@@ -54,10 +54,10 @@ export function useTableHelper(columns, { customizable, actions, actionWidth, ac
|
|
|
54
54
|
}
|
|
55
55
|
const bindings = {}
|
|
56
56
|
for (const k of Object.keys(options)) {
|
|
57
|
-
if (k.length > render.length && k.startsWith(render))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
if (!(k.length > render.length && k.startsWith(render))) continue
|
|
58
|
+
|
|
59
|
+
bindings[uncapitalize(k.slice(render.length))] = options[k]
|
|
60
|
+
delete options[k]
|
|
61
61
|
}
|
|
62
62
|
const bindings0 = computed(() => {
|
|
63
63
|
return Object.fromEntries(Object.entries(bindings)
|
|
@@ -360,9 +360,7 @@ export function useTableHelper(columns, { customizable, actions, actionWidth, ac
|
|
|
360
360
|
const raw = StorageSerializers.object.write([sort, hidden, fixed, width])
|
|
361
361
|
return storage.setItem(key, raw)
|
|
362
362
|
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if (!customizable) {
|
|
363
|
+
} else {
|
|
366
364
|
reinit()
|
|
367
365
|
}
|
|
368
366
|
|