@peng_kai/kit 0.0.12 → 0.0.14

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.
@@ -0,0 +1,31 @@
1
+ import type { App } from 'vue'
2
+
3
+ export function formLabelAlign(app: App) {
4
+ const directiveName = 'antd-form-label-align'
5
+ const resizeObserverKey = `${directiveName}@resizeObserver`
6
+
7
+ app.directive(directiveName, {
8
+ mounted(el: HTMLElement) {
9
+ const labels = el.querySelectorAll('.ant-form-item .ant-form-item-label')
10
+ const resizeObserver = new ResizeObserver((entries) => {
11
+ const widths = entries.map(e => e.borderBoxSize?.[0]?.inlineSize ?? 0)
12
+ const maxWidth = Math.max(...widths)
13
+
14
+ if (maxWidth <= 0)
15
+ return
16
+
17
+ el.style.setProperty('--max-label-width', `${maxWidth}px`)
18
+ entries.forEach((e) => {
19
+ const target = e.target as HTMLElement
20
+ target.style.setProperty('width', 'var(--max-label-width)')
21
+ })
22
+ })
23
+
24
+ Array.from(labels).forEach(label => resizeObserver.observe(label));
25
+ (el as any)[resizeObserverKey] = resizeObserver
26
+ },
27
+ beforeUnmount(el) {
28
+ el[resizeObserverKey]?.disconnect()
29
+ },
30
+ })
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,7 +27,7 @@ export function popupMessage(popup: (type: 'error' | 'success', message: string)
27
27
  const errorMessageConfig = error?.config?.errorMessage
28
28
 
29
29
  if (errorMessageConfig === false)
30
- return error
30
+ throw error
31
31
 
32
32
  let errorMsg: boolean | string = errorMessageConfig
33
33
 
@@ -45,7 +45,7 @@ export function popupMessage(popup: (type: 'error' | 'success', message: string)
45
45
  if (typeof errorMsg === 'string')
46
46
  popup('error', errorMsg)
47
47
 
48
- return error
48
+ throw error
49
49
  },
50
50
  ]
51
51
  }
@@ -15,9 +15,9 @@ export function unitizeAxiosError(): Parameters<AxiosInterceptorManager<any>['us
15
15
  throw new axios.AxiosError(`${error.message}[AppError01]`)
16
16
 
17
17
  if (typeof error === 'object')
18
- throw new axios.AxiosError(`${JSON.stringify(error)}[AppError01]`)
18
+ throw new axios.AxiosError(`${JSON.stringify(error)}[AppError02]`)
19
19
 
20
- throw new axios.AxiosError(`${String(error)}[AppError01]`)
20
+ throw new axios.AxiosError(`${String(error)}[AppError03]`)
21
21
  },
22
22
  ]
23
23
  }