extra-react-hooks 0.1.5 → 0.1.9

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +33 -9
  3. package/dist/es2015/index.min.mjs +17 -3
  4. package/dist/es2015/index.min.mjs.map +1 -1
  5. package/dist/es2015/index.mjs +8407 -246
  6. package/dist/es2015/index.mjs.map +1 -1
  7. package/dist/es2015/index.umd.js +8410 -245
  8. package/dist/es2015/index.umd.js.map +1 -1
  9. package/dist/es2015/index.umd.min.js +17 -3
  10. package/dist/es2015/index.umd.min.js.map +1 -1
  11. package/dist/es2018/index.min.mjs +17 -3
  12. package/dist/es2018/index.min.mjs.map +1 -1
  13. package/dist/es2018/index.mjs +8407 -246
  14. package/dist/es2018/index.mjs.map +1 -1
  15. package/dist/es2018/index.umd.js +8410 -245
  16. package/dist/es2018/index.umd.js.map +1 -1
  17. package/dist/es2018/index.umd.min.js +17 -3
  18. package/dist/es2018/index.umd.min.js.map +1 -1
  19. package/lib/es2015/index.d.ts +4 -0
  20. package/lib/es2015/index.js +4 -0
  21. package/lib/es2015/index.js.map +1 -1
  22. package/lib/es2015/use-finite-state-machine.d.ts +3 -0
  23. package/lib/es2015/use-finite-state-machine.js +17 -0
  24. package/lib/es2015/use-finite-state-machine.js.map +1 -0
  25. package/lib/es2015/use-force-update.d.ts +1 -0
  26. package/lib/es2015/use-force-update.js +10 -0
  27. package/lib/es2015/use-force-update.js.map +1 -0
  28. package/lib/es2015/use-increment.js +6 -2
  29. package/lib/es2015/use-increment.js.map +1 -1
  30. package/lib/es2015/use-resize-observer.d.ts +2 -0
  31. package/lib/es2015/use-resize-observer.js +18 -0
  32. package/lib/es2015/use-resize-observer.js.map +1 -0
  33. package/lib/es2015/use-state-cycle.js +7 -4
  34. package/lib/es2015/use-state-cycle.js.map +1 -1
  35. package/lib/es2015/use-step.d.ts +1 -0
  36. package/lib/es2015/use-step.js +32 -0
  37. package/lib/es2015/use-step.js.map +1 -0
  38. package/lib/es2018/index.d.ts +4 -0
  39. package/lib/es2018/index.js +4 -0
  40. package/lib/es2018/index.js.map +1 -1
  41. package/lib/es2018/use-finite-state-machine.d.ts +3 -0
  42. package/lib/es2018/use-finite-state-machine.js +17 -0
  43. package/lib/es2018/use-finite-state-machine.js.map +1 -0
  44. package/lib/es2018/use-force-update.d.ts +1 -0
  45. package/lib/es2018/use-force-update.js +10 -0
  46. package/lib/es2018/use-force-update.js.map +1 -0
  47. package/lib/es2018/use-increment.js +6 -2
  48. package/lib/es2018/use-increment.js.map +1 -1
  49. package/lib/es2018/use-resize-observer.d.ts +2 -0
  50. package/lib/es2018/use-resize-observer.js +18 -0
  51. package/lib/es2018/use-resize-observer.js.map +1 -0
  52. package/lib/es2018/use-state-cycle.js +7 -4
  53. package/lib/es2018/use-state-cycle.js.map +1 -1
  54. package/lib/es2018/use-step.d.ts +1 -0
  55. package/lib/es2018/use-step.js +32 -0
  56. package/lib/es2018/use-step.js.map +1 -0
  57. package/package.json +30 -21
package/CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [0.1.9](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.8...v0.1.9) (2021-12-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * add useFiniteStateMachine ([e6e8962](https://github.com/BlackGlory/extra-react-hooks/commit/e6e8962724774a8b217a1fd5332c13ba4ee051f7))
11
+
12
+ ### [0.1.8](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.7...v0.1.8) (2021-12-13)
13
+
14
+
15
+ ### Features
16
+
17
+ * add useForceUpdate ([f747227](https://github.com/BlackGlory/extra-react-hooks/commit/f747227c02c5bb2f0a0f1889de1c022bc9ca1e4d))
18
+
19
+ ### [0.1.7](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.6...v0.1.7) (2021-12-10)
20
+
21
+
22
+ ### Features
23
+
24
+ * add useStep ([f404846](https://github.com/BlackGlory/extra-react-hooks/commit/f4048462cc254499d7fd06cd51e16e98acd978ca))
25
+
26
+ ### [0.1.6](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.5...v0.1.6) (2021-11-15)
27
+
28
+
29
+ ### Features
30
+
31
+ * add useResizeObserver ([8a4e317](https://github.com/BlackGlory/extra-react-hooks/commit/8a4e317921387fa26e768796e52c8fe44e9b347e))
32
+
33
+ ### [0.1.5](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.4...v0.1.5) (2021-10-04)
34
+
35
+
36
+ ### Features
37
+
38
+ * add useIncrement ([e5f1fc4](https://github.com/BlackGlory/extra-react-hooks/commit/e5f1fc442a2c69aa490fed873cc21fe4ad9ff76b))
39
+
40
+ ### [0.1.4](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.3...v0.1.4) (2021-08-18)
41
+
42
+
43
+ ### Features
44
+
45
+ * add useIsMounted ([32a1295](https://github.com/BlackGlory/extra-react-hooks/commit/32a12951aab92ae5734f4caddf45021e2bbed793))
46
+
47
+ ### [0.1.3](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.2...v0.1.3) (2021-08-18)
48
+
49
+
50
+ ### Features
51
+
52
+ * add useStateCycle ([a48da21](https://github.com/BlackGlory/extra-react-hooks/commit/a48da211f364688daa63a0bd5406fa2f2c61eba7))
53
+
54
+ ### [0.1.2](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.1...v0.1.2) (2021-07-03)
55
+
56
+ ### [0.1.1](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.0...v0.1.1) (2021-06-29)
57
+
58
+
59
+ ### Features
60
+
61
+ * add useMount ([070045a](https://github.com/BlackGlory/extra-react-hooks/commit/070045ac0f209712eadd0f4e79c1328d20745b04))
62
+
63
+ ## 0.1.0 (2021-06-04)
64
+
65
+
66
+ ### Features
67
+
68
+ * add useToggle, useSingleSelection ([0b9ee92](https://github.com/BlackGlory/extra-react-hooks/commit/0b9ee92597a230989b51b7242f529f0a36590d1f))
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # extra-react-hooks
2
-
3
2
  ## Install
4
-
5
3
  ```sh
6
4
  npm install --save extra-react-hooks
7
5
  # or
@@ -9,15 +7,12 @@ yarn add extra-react-hooks
9
7
  ```
10
8
 
11
9
  ## API
12
-
13
10
  ### useToggle
14
-
15
11
  ```ts
16
12
  function useToggle(initialState: boolean = false): [on: boolean, toggle: () => void]
17
13
  ```
18
14
 
19
15
  ### useSingleSelection
20
-
21
16
  ```ts
22
17
  interface IOption<T> {
23
18
  value: T
@@ -37,13 +32,11 @@ function useSingleSelection<T>(values: T[]): {
37
32
  ```
38
33
 
39
34
  ### useMount
40
-
41
35
  ```ts
42
36
  function useMount(effect: EffectCallback): void
43
37
  ```
44
38
 
45
39
  ### useStateCycle
46
-
47
40
  ```ts
48
41
  function useStateCycle<T>(
49
42
  stateList: [T, ...T[]]
@@ -52,15 +45,46 @@ function useStateCycle<T>(
52
45
  ```
53
46
 
54
47
  ### useIsMounted
55
-
56
48
  ```ts
57
49
  function useIsMounted(): () => boolean
58
50
  ```
59
51
 
60
52
  ### useIncrement
61
-
62
53
  ```ts
63
54
  function useIncrement(
64
55
  initialValue: number
65
56
  ): [value: number, increment: (step?: number) => void, reset: () => void]
66
57
  ```
58
+
59
+ ### useResizeObserver
60
+ ```ts
61
+ function useResizeObserver(
62
+ callback: ResizeObserverCallback
63
+ , refs: Array<RefObject<HTMLElement> | MutableRefObject<HTMLElement>>
64
+ ): void
65
+ ```
66
+
67
+ ### useStep
68
+ ```ts
69
+ function useStep<T>(
70
+ steps: [T, ...T[]]
71
+ , initialStepIndex: number = 0
72
+ ): [currentStep: T, next: () => void, previous: () => void]
73
+ ```
74
+
75
+ ### useForceUpdate
76
+ ```ts
77
+ function useForceUpdate(): () => void
78
+ ```
79
+
80
+ ### useFiniteStateMachine
81
+ ```ts
82
+ function useFiniteStateMachine<State extends string, Event extends string>(
83
+ schema: IFiniteStateMachineSchema<State, Event>
84
+ , initialState: State
85
+ ): ObservableFiniteStateMachine<State, Event>
86
+ ```
87
+
88
+ The `ObservableFiniteStateMachine` comes from [@blackglory/structures].
89
+
90
+ [@blackglory/structures]: https://www.npmjs.com/package/@blackglory/structures