@kaspernj/api-maker 1.0.443 → 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 +2 -2
- package/src/inputs/attachment.jsx +4 -4
- package/src/inputs/checkbox.jsx +15 -3
- package/src/use-can-can.mjs +8 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaspernj/api-maker",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
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",
|
|
@@ -54,7 +54,7 @@ export default memo(shapeComponent(class ApiMakerInputsAttachment extends BaseCo
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
getContentType() {
|
|
57
|
-
const {attribute, model} =
|
|
57
|
+
const {attribute, model} = this.p
|
|
58
58
|
const attributeName = `${attribute}ContentType`
|
|
59
59
|
|
|
60
60
|
if (!(attributeName in model)) throw new Error(`No such method on ${model.modelClassData().name}: ${attributeName}`)
|
|
@@ -63,7 +63,7 @@ export default memo(shapeComponent(class ApiMakerInputsAttachment extends BaseCo
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
getPurgeInputId() {
|
|
66
|
-
const {inputProps} =
|
|
66
|
+
const {inputProps} = this.tt
|
|
67
67
|
|
|
68
68
|
return `${inputProps.id}_purge`
|
|
69
69
|
}
|
|
@@ -71,7 +71,7 @@ export default memo(shapeComponent(class ApiMakerInputsAttachment extends BaseCo
|
|
|
71
71
|
getPurgeInputName() {
|
|
72
72
|
if ("purgeName" in this.props) return this.props.purgeName
|
|
73
73
|
|
|
74
|
-
const {inputProps} =
|
|
74
|
+
const {inputProps} = this.tt
|
|
75
75
|
|
|
76
76
|
if (!inputProps.name) return null
|
|
77
77
|
|
|
@@ -82,7 +82,7 @@ export default memo(shapeComponent(class ApiMakerInputsAttachment extends BaseCo
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
getUrl() {
|
|
85
|
-
const {attribute, model} =
|
|
85
|
+
const {attribute, model} = this.p
|
|
86
86
|
const attributeName = `${attribute}Url`
|
|
87
87
|
|
|
88
88
|
if (!(attributeName in model)) throw new Error(`No such method on ${model.modelClassData().name}: ${attributeName}`)
|
package/src/inputs/checkbox.jsx
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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
|
|
package/src/use-can-can.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
24
|
+
s.set({canCan})
|
|
22
25
|
}, [])
|
|
23
26
|
|
|
24
27
|
const onResetAbilities = useCallback(() => {
|
|
25
|
-
|
|
28
|
+
s.set({canCan: null}, {silent: true})
|
|
26
29
|
loadAbilities()
|
|
27
30
|
}, [])
|
|
28
31
|
|
|
29
32
|
useMemo(() => {
|
|
30
|
-
|
|
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
|