react-hook-toolkit 3.0.2 → 3.0.3
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/dist/chunk1213/chunk158261.js +22 -22
- package/dist/chunk1415/chunk143.js +21 -25
- package/dist/chunk1516/chunk0021.js +263 -347
- package/dist/chunk1516/chunk0022.js +159 -277
- package/dist/chunk1516/chunk3312.d.ts +63 -0
- package/dist/chunk1516/chunk3312.js +462 -0
- package/dist/chunk1516/chunk726433.js +172 -206
- package/dist/chunk1516/chunk940514.js +284 -415
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/utils.js +42 -68
- package/package.json +1 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useState } from 'react';
|
|
3
|
-
|
|
3
|
+
const DrawerContext = createContext({
|
|
4
4
|
drawerOpen: false,
|
|
5
|
-
openDrawer:
|
|
6
|
-
closeDrawer:
|
|
7
|
-
openDrawerInButton:
|
|
8
|
-
closeDrawerInButton:
|
|
5
|
+
openDrawer: () => { },
|
|
6
|
+
closeDrawer: () => { },
|
|
7
|
+
openDrawerInButton: () => { },
|
|
8
|
+
closeDrawerInButton: () => { },
|
|
9
9
|
currentMainMenu: '',
|
|
10
|
-
setCurrentMainMenu:
|
|
10
|
+
setCurrentMainMenu: () => { },
|
|
11
11
|
});
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export const DrawerProvider = (props) => {
|
|
13
|
+
const { children } = props;
|
|
14
|
+
const [drawerOpen, setDrawer] = useState(true);
|
|
15
|
+
const [currentMainMenu, setCurrOpenMenu] = useState('');
|
|
16
|
+
const openDrawer = () => {
|
|
17
17
|
setDrawer(true);
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
const closeDrawer = () => {
|
|
20
20
|
setDrawer(false);
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
const openDrawerInButton = () => {
|
|
23
23
|
setDrawer(false);
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
const closeDrawerInButton = () => {
|
|
26
26
|
setDrawer(true);
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
const setCurrentMainMenu = (value) => {
|
|
29
29
|
setCurrOpenMenu(value);
|
|
30
30
|
};
|
|
31
31
|
return (_jsx(DrawerContext.Provider, { value: {
|
|
32
|
-
drawerOpen
|
|
33
|
-
openDrawer
|
|
34
|
-
closeDrawer
|
|
35
|
-
openDrawerInButton
|
|
36
|
-
closeDrawerInButton
|
|
37
|
-
currentMainMenu
|
|
38
|
-
setCurrentMainMenu
|
|
32
|
+
drawerOpen,
|
|
33
|
+
openDrawer,
|
|
34
|
+
closeDrawer,
|
|
35
|
+
openDrawerInButton,
|
|
36
|
+
closeDrawerInButton,
|
|
37
|
+
currentMainMenu,
|
|
38
|
+
setCurrentMainMenu,
|
|
39
39
|
}, children: children }));
|
|
40
40
|
};
|
|
41
41
|
export default DrawerContext;
|
|
@@ -5,54 +5,50 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
class HEXE {
|
|
9
|
+
constructor() {
|
|
10
10
|
this.hs = {};
|
|
11
11
|
this.ss = {};
|
|
12
12
|
this.setHook = this.setHook.bind(this);
|
|
13
13
|
this.getHook = this.getHook.bind(this);
|
|
14
14
|
this.putHooks = this.putHooks.bind(this);
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
setHook(name, hookFunction) {
|
|
17
17
|
[
|
|
18
18
|
{ value: name, id: 'name', type: 'string' },
|
|
19
19
|
{ value: hookFunction, id: 'hook', type: 'function' },
|
|
20
|
-
].forEach(
|
|
21
|
-
var value = _a.value, id = _a.id, type = _a.type;
|
|
20
|
+
].forEach(({ value, id, type }) => {
|
|
22
21
|
if (type === 'string' && typeof value !== 'string') {
|
|
23
|
-
throw new TypeError("
|
|
22
|
+
throw new TypeError(`"${id}" expected to be of type ${type}`);
|
|
24
23
|
}
|
|
25
24
|
if (type === 'function' && typeof value !== 'function') {
|
|
26
|
-
throw new TypeError("
|
|
25
|
+
throw new TypeError(`"${id}" expected to be of type ${type}`);
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
28
|
this.hs[name] = {
|
|
30
|
-
name
|
|
29
|
+
name,
|
|
31
30
|
hook: hookFunction,
|
|
32
31
|
};
|
|
33
32
|
return this;
|
|
34
|
-
}
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
putHooks(name, value) {
|
|
36
35
|
this.ss[name] = value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var _this = this;
|
|
36
|
+
}
|
|
37
|
+
component() {
|
|
40
38
|
/* Author: Shivaji & Shyamal */
|
|
41
|
-
|
|
42
|
-
Object.values(
|
|
43
|
-
|
|
44
|
-
_this.putHooks(name, hook());
|
|
39
|
+
const Component = () => {
|
|
40
|
+
Object.values(this.hs).forEach(({ name, hook }) => {
|
|
41
|
+
this.putHooks(name, hook());
|
|
45
42
|
});
|
|
46
43
|
return /*#__PURE__*/ React.createElement(React.Fragment, null);
|
|
47
44
|
};
|
|
48
45
|
return Component;
|
|
49
|
-
}
|
|
50
|
-
|
|
46
|
+
}
|
|
47
|
+
getHook(name) {
|
|
51
48
|
return this.ss[name];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var getHook = o.getHook, setHook = o.setHook;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const o = new HEXE();
|
|
52
|
+
const ReactHooksWrapper = o.component();
|
|
53
|
+
const { getHook, setHook } = o;
|
|
58
54
|
export { ReactHooksWrapper, getHook, setHook };
|