@ithinkdt/page 4.0.21 → 4.1.0

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": "@ithinkdt/page",
3
- "version": "4.0.21",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT Page",
@@ -41,17 +41,17 @@
41
41
  "dependencies": {
42
42
  "@vueuse/core": "^14.3.0",
43
43
  "nanoid": "^5.1.11",
44
- "@ithinkdt/common": "^4.0.9"
44
+ "@ithinkdt/common": "^4.1.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "vue": ">=3.5",
48
- "vue-router": ">=4.5"
48
+ "vue-router": ">=5.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "typescript": "~6.0.3",
52
- "vite": "^8.0.14",
53
- "vue": "^3.5.34",
54
- "vue-router": "^5.0.7"
52
+ "vite": "^8.0.16",
53
+ "vue": "^3.5.38",
54
+ "vue-router": "^5.1.0"
55
55
  },
56
56
  "scripts": {
57
57
  "release": "pnpm publish --no-git-checks"
package/src/crud.js CHANGED
@@ -129,8 +129,7 @@ function _useSimpleCrudModal(crudType, getItems, request, options) {
129
129
  }
130
130
  setModalType(crudType)
131
131
  const $open = modal.open(model.value, title)
132
- if (crudType == 'view') return
133
- return $open
132
+ if (crudType !== 'view') return $open
134
133
  },
135
134
  }
136
135
  }
@@ -142,7 +142,7 @@ export function useDs(fetch, options = {}) {
142
142
  if (
143
143
  pagination === true
144
144
  && getOriData().length > 0
145
- && !['filter', 'sortField', 'sortOrder'].some(it => it in params2)
145
+ && ['filter', 'sortField', 'sortOrder'].every(it => !(it in params2))
146
146
  ) {
147
147
  Object.assign(params, params2)
148
148
  await nextTick()
package/src/form.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StorageSerializers, toReactive, tryOnScopeDispose, useEventListener, useStorage } from '@vueuse/core'
2
2
  import { nanoid } from 'nanoid'
3
- import { computed, effectScope, h, hasInjectionContext, inject, reactive, readonly, ref, shallowReactive, shallowRef, toRaw, unref, watch } from 'vue'
3
+ import { computed, effectScope, h, hasInjectionContext, inject, reactive, readonly, ref, shallowReactive, shallowRef, toRaw, unref } from 'vue'
4
4
  import { useRoute } from 'vue-router'
5
5
 
6
6
  import { copy, isNone } from '@ithinkdt/common/object'
@@ -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 && !rule.some(r => isRequiredRule(r))) {
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) {
package/src/list.js CHANGED
@@ -91,8 +91,8 @@ export function useListPageCustomization({
91
91
  const filterStorage = new CustomStorage('filter-form', storage, key, 'default', { onSet })
92
92
  const tableStorage = new CustomStorage('table-column', storage, key, 'default', { onSet })
93
93
  tryOnScopeDispose(() => {
94
- filterStorage.$event.clear()
95
- tableStorage.$event.clear()
94
+ filterStorage.$change.clear()
95
+ tableStorage.$change.clear()
96
96
  })
97
97
 
98
98
  let laskKey = 'default'
@@ -161,7 +161,7 @@ export function useListPageCustomization({
161
161
  })
162
162
 
163
163
  function removeProfile(key) {
164
- const removeProfile = config.value.profiles.find(profile => profile.key === key)
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
- globalThis.addEventListener('unhandledrejection', (ev) => {
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(/^[^\u4E00-\u9FA5]+$/, message, options)
65
- export const chinese = (message, options) => pattern(/^[\u4E00-\u9FA5]+$/, message, options)
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'] } = {}) {