@kaspernj/api-maker 1.0.444 → 1.0.445

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": "@kaspernj/api-maker",
3
- "version": "1.0.444",
3
+ "version": "1.0.445",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -37,7 +37,7 @@
37
37
  "qs": ">= 6.9.3",
38
38
  "react-native-vector-icons": "^10.2.0",
39
39
  "replaceall": ">= 0.1.6",
40
- "set-state-compare": ">= 1.0.51",
40
+ "set-state-compare": ">= 1.0.53",
41
41
  "spark-md5": "^3.0.2",
42
42
  "stacktrace-parser": "^0.1.10",
43
43
  "strftime": ">= 0.10.0",
@@ -7,6 +7,7 @@ import memo from "set-state-compare/src/memo"
7
7
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
8
8
  import useInput from "../use-input"
9
9
  import {useForm} from "../form"
10
+ import {useMemo} from "react"
10
11
 
11
12
  export default memo(shapeComponent(class ApiMakerInputsCheckbox extends BaseComponent {
12
13
  static defaultProps = {
@@ -88,11 +89,22 @@ export default memo(shapeComponent(class ApiMakerInputsCheckbox extends BaseComp
88
89
  }
89
90
 
90
91
  onChanged = (...args) => {
91
- const {form} = this.tt
92
- const {attribute, autoSubmit, model, name, onChange} = this.props
92
+ const {form, inputProps} = this.tt
93
+ const {attribute, autoSubmit, model, onChange} = this.props
94
+ const {name} = inputProps
93
95
 
94
96
  if (attribute && autoSubmit && model) new AutoSubmit({component: this}).autoSubmit()
95
- if (form && name) form.setValue(name, args[0].target.checked)
97
+
98
+ console.log("onChanged", {form, name})
99
+
100
+ if (form && name) {
101
+ const checked = args[0].target.checked
102
+
103
+ console.log("Checkbox onChanged", {checked})
104
+
105
+ form.setValue(name, checked)
106
+ }
107
+
96
108
  if (onChange) onChange(...args)
97
109
  }
98
110
 
@@ -6,7 +6,10 @@ import useShape from "set-state-compare/src/use-shape.js"
6
6
  const useCanCan = (abilitiesCallback, dependencies) => {
7
7
  const currentUser = useCurrentUser()
8
8
  const s = useShape({abilitiesCallback})
9
- const [canCan, setCanCan] = useState()
9
+
10
+ s.useStates({
11
+ canCan: null
12
+ })
10
13
 
11
14
  if (!dependencies) {
12
15
  dependencies = [currentUser?.id()]
@@ -18,16 +21,16 @@ const useCanCan = (abilitiesCallback, dependencies) => {
18
21
 
19
22
  await canCan.loadAbilities(abilities)
20
23
 
21
- setCanCan(canCan)
24
+ s.set({canCan})
22
25
  }, [])
23
26
 
24
27
  const onResetAbilities = useCallback(() => {
25
- setCanCan(undefined)
28
+ s.set({canCan: null}, {silent: true})
26
29
  loadAbilities()
27
30
  }, [])
28
31
 
29
32
  useMemo(() => {
30
- setCanCan(undefined)
33
+ s.set({canCan: null}, {silent: true})
31
34
  loadAbilities()
32
35
  }, dependencies)
33
36
 
@@ -39,7 +42,7 @@ const useCanCan = (abilitiesCallback, dependencies) => {
39
42
  }
40
43
  }, [])
41
44
 
42
- return canCan
45
+ return s.s.canCan
43
46
  }
44
47
 
45
48
  export default useCanCan