create-packer 1.11.11 → 1.11.12
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 +1 -1
- package/template/react/package.json +2 -0
- package/template/react/src/providers/index.ts +1 -0
- package/template/react/src/providers/useVisible.ts +26 -0
- package/template/vue/package.json +2 -0
- package/template/vue/src/providers/index.ts +1 -0
- package/template/vue/src/providers/useVisible.ts +26 -0
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"immer": "9.0.15",
|
|
24
|
+
"lodash-es": "^4.17.21",
|
|
24
25
|
"react": "18.2.0",
|
|
25
26
|
"react-dom": "18.2.0",
|
|
26
27
|
"react-router-dom": "6.3.0",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@testing-library/react": "13.3.0",
|
|
33
34
|
"@testing-library/user-event": "14.4.2",
|
|
34
35
|
"@types/jest": "28.1.6",
|
|
36
|
+
"@types/lodash-es": "^4.17.6",
|
|
35
37
|
"@types/react": "18.0.15",
|
|
36
38
|
"@types/react-dom": "18.0.6",
|
|
37
39
|
"@types/testing-library__jest-dom": "5.14.5",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { isFunction } from 'lodash-es'
|
|
3
|
+
|
|
4
|
+
export interface useVisibleConfigType {
|
|
5
|
+
onBeforeShow?: () => Promise<boolean | void>
|
|
6
|
+
onBeforeHide?: () => Promise<boolean | void>
|
|
7
|
+
}
|
|
8
|
+
export default function useVisible(config?: useVisibleConfigType) {
|
|
9
|
+
const [visible, setVisible] = useState(false)
|
|
10
|
+
const onShow = async () => {
|
|
11
|
+
let isShow: boolean | void = true
|
|
12
|
+
if (isFunction(config?.onBeforeShow)) {
|
|
13
|
+
isShow = await config?.onBeforeShow?.()
|
|
14
|
+
}
|
|
15
|
+
setVisible(isShow !== false)
|
|
16
|
+
}
|
|
17
|
+
const onClose = async () => {
|
|
18
|
+
let isHide: boolean | void = true
|
|
19
|
+
if (isFunction(config?.onBeforeHide)) {
|
|
20
|
+
isHide = await config?.onBeforeHide?.()
|
|
21
|
+
}
|
|
22
|
+
setVisible(isHide === false)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { visible, onShow, onClose }
|
|
26
|
+
}
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
"commit": "git add . && npm run cz"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"lodash-es": "^4.17.21",
|
|
19
20
|
"pinia": "2.0.18",
|
|
20
21
|
"vite-plugin-eslint": "1.8.1",
|
|
21
22
|
"vue": "3.2.37",
|
|
22
23
|
"vue-router": "4.1.3"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
26
|
+
"@types/lodash-es": "^4.17.6",
|
|
25
27
|
"@typescript-eslint/eslint-plugin": "5.33.0",
|
|
26
28
|
"@typescript-eslint/parser": "5.33.0",
|
|
27
29
|
"@vitejs/plugin-vue": "3.0.3",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useVisible } from './useVisible'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
import { isFunction } from 'lodash-es'
|
|
3
|
+
|
|
4
|
+
export interface useVisibleConfigType {
|
|
5
|
+
onBeforeShow?: () => Promise<boolean | void>
|
|
6
|
+
onBeforeHide?: () => Promise<boolean | void>
|
|
7
|
+
}
|
|
8
|
+
export default function useVisible(config?: useVisibleConfigType) {
|
|
9
|
+
const visible = ref(false)
|
|
10
|
+
const onShow = async () => {
|
|
11
|
+
let isShow: boolean | void = true
|
|
12
|
+
if (isFunction(config?.onBeforeShow)) {
|
|
13
|
+
isShow = await config?.onBeforeShow?.()
|
|
14
|
+
}
|
|
15
|
+
visible.value = isShow !== false
|
|
16
|
+
}
|
|
17
|
+
const onClose = async () => {
|
|
18
|
+
let isHide: boolean | void = true
|
|
19
|
+
if (isFunction(config?.onBeforeHide)) {
|
|
20
|
+
isHide = await config?.onBeforeHide?.()
|
|
21
|
+
}
|
|
22
|
+
visible.value = isHide === false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { visible, onShow, onClose }
|
|
26
|
+
}
|