create-packer 1.11.10 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.11.10",
3
+ "version": "1.11.12",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -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",
@@ -16,7 +16,7 @@ export function defineStore<S extends object, A extends object>(
16
16
  options: defineStoreOptionsType<S, A>
17
17
  ) {
18
18
  return create(
19
- combine({ state: options.state() }, (setState, getState) => {
19
+ combine({ state: options.state() }, (setState, getState, store) => {
20
20
  const _setState: setStateType<S> = updater => {
21
21
  setState(
22
22
  produce((store: { state: S }) => {
@@ -32,6 +32,8 @@ export function defineStore<S extends object, A extends object>(
32
32
  setState({ state: options.state() })
33
33
  },
34
34
  setState: _setState,
35
+ destroy: store.destroy,
36
+ subscribe: store.subscribe,
35
37
  ...options.actions(_setState, _getState, _getActions)
36
38
  }
37
39
  }
@@ -1 +1,2 @@
1
1
  export * from './defineStore'
2
+ export { default as useVisible } from './useVisible'
@@ -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
+ }