react-hook-toolkit 3.0.2 → 3.0.4

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.
@@ -1,41 +1,41 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useState } from 'react';
3
- var DrawerContext = createContext({
3
+ const DrawerContext = createContext({
4
4
  drawerOpen: false,
5
- openDrawer: function () { },
6
- closeDrawer: function () { },
7
- openDrawerInButton: function () { },
8
- closeDrawerInButton: function () { },
5
+ openDrawer: () => { },
6
+ closeDrawer: () => { },
7
+ openDrawerInButton: () => { },
8
+ closeDrawerInButton: () => { },
9
9
  currentMainMenu: '',
10
- setCurrentMainMenu: function () { },
10
+ setCurrentMainMenu: () => { },
11
11
  });
12
- export var DrawerProvider = function (props) {
13
- var children = props.children;
14
- var _a = useState(true), drawerOpen = _a[0], setDrawer = _a[1];
15
- var _b = useState(''), currentMainMenu = _b[0], setCurrOpenMenu = _b[1];
16
- var openDrawer = function () {
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
- var closeDrawer = function () {
19
+ const closeDrawer = () => {
20
20
  setDrawer(false);
21
21
  };
22
- var openDrawerInButton = function () {
22
+ const openDrawerInButton = () => {
23
23
  setDrawer(false);
24
24
  };
25
- var closeDrawerInButton = function () {
25
+ const closeDrawerInButton = () => {
26
26
  setDrawer(true);
27
27
  };
28
- var setCurrentMainMenu = function (value) {
28
+ const setCurrentMainMenu = (value) => {
29
29
  setCurrOpenMenu(value);
30
30
  };
31
31
  return (_jsx(DrawerContext.Provider, { value: {
32
- drawerOpen: drawerOpen,
33
- openDrawer: openDrawer,
34
- closeDrawer: closeDrawer,
35
- openDrawerInButton: openDrawerInButton,
36
- closeDrawerInButton: closeDrawerInButton,
37
- currentMainMenu: currentMainMenu,
38
- setCurrentMainMenu: 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
- var HEXE = /** @class */ (function () {
9
- function HEXE() {
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
- HEXE.prototype.setHook = function (name, hookFunction) {
16
+ setHook(name, hookFunction) {
17
17
  [
18
18
  { value: name, id: 'name', type: 'string' },
19
19
  { value: hookFunction, id: 'hook', type: 'function' },
20
- ].forEach(function (_a) {
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("\"".concat(id, "\" expected to be of type ").concat(type));
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("\"".concat(id, "\" expected to be of type ").concat(type));
25
+ throw new TypeError(`"${id}" expected to be of type ${type}`);
27
26
  }
28
27
  });
29
28
  this.hs[name] = {
30
- name: name,
29
+ name,
31
30
  hook: hookFunction,
32
31
  };
33
32
  return this;
34
- };
35
- HEXE.prototype.putHooks = function (name, value) {
33
+ }
34
+ putHooks(name, value) {
36
35
  this.ss[name] = value;
37
- };
38
- HEXE.prototype.component = function () {
39
- var _this = this;
36
+ }
37
+ component() {
40
38
  /* Author: Shivaji & Shyamal */
41
- var Component = function () {
42
- Object.values(_this.hs).forEach(function (_a) {
43
- var name = _a.name, hook = _a.hook;
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
- HEXE.prototype.getHook = function (name) {
46
+ }
47
+ getHook(name) {
51
48
  return this.ss[name];
52
- };
53
- return HEXE;
54
- }());
55
- var o = new HEXE();
56
- var ReactHooksWrapper = o.component();
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 };
@@ -11,10 +11,30 @@ export declare function useIsMounted(): boolean;
11
11
  export declare function useCss(css: string): {
12
12
  error: Error | null;
13
13
  };
14
- export declare function useSpeak(text: string): {
15
- speak: () => void;
14
+ type VoiceStatus = 'idle' | 'playing' | 'paused' | 'ended' | 'error';
15
+ interface ISpeakOptions {
16
+ rate?: number;
17
+ pitch?: number;
18
+ volume?: number;
19
+ lang?: string;
20
+ voice?: SpeechSynthesisVoice | null;
21
+ onStart?: () => void;
22
+ onEnd?: () => void;
23
+ onPause?: () => void;
24
+ onError?: (error: Error) => void;
25
+ }
26
+ interface ISpeakResult {
27
+ speak: (text: string, options?: ISpeakOptions) => void;
28
+ stop: () => void;
29
+ pause: () => void;
30
+ resume: () => void;
31
+ isPlaying: boolean;
32
+ isPaused: boolean;
33
+ status: VoiceStatus;
34
+ isSupported: boolean;
16
35
  error: Error | null;
17
- };
36
+ }
37
+ export declare function useSpeak(): ISpeakResult;
18
38
  export declare function useCountUp(target: number, duration: number): {
19
39
  count: number;
20
40
  error: Error | null;