@kaspernj/api-maker 1.0.425 → 1.0.427
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 +1 -1
- package/src/modal.jsx +36 -0
- package/src/table/settings/index.jsx +10 -6
- package/src/use-model.mjs +7 -1
package/package.json
CHANGED
package/src/modal.jsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import BaseComponent from "./base-component"
|
|
2
|
+
import {memo} from "react"
|
|
3
|
+
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
4
|
+
import {Modal, Pressable, View} from "react-native"
|
|
5
|
+
|
|
6
|
+
export default memo(shapeComponent(class ApiMakerModal extends BaseComponent {
|
|
7
|
+
render() {
|
|
8
|
+
const {children, onRequestClose, ...restProps} = this.props
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<Modal onRequestClose={onRequestClose} {...restProps}>
|
|
12
|
+
<View
|
|
13
|
+
style={{
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
minWidth: "100%",
|
|
17
|
+
minHeight: "100%",
|
|
18
|
+
padding: 20,
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<Pressable
|
|
22
|
+
dataSet={{class: "modal-backdrop"}}
|
|
23
|
+
onPress={onRequestClose}
|
|
24
|
+
style={{
|
|
25
|
+
position: "absolute",
|
|
26
|
+
minWidth: "100%",
|
|
27
|
+
minHeight: "100%",
|
|
28
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
{children}
|
|
32
|
+
</View>
|
|
33
|
+
</Modal>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}))
|
|
@@ -3,10 +3,12 @@ import columnIdentifier from "../column-identifier.mjs"
|
|
|
3
3
|
import ColumnRow from "./column-row"
|
|
4
4
|
import DownloadAction from "./download-action"
|
|
5
5
|
import {memo, useRef} from "react"
|
|
6
|
+
import Modal from "../../modal"
|
|
6
7
|
import PropTypes from "prop-types"
|
|
7
8
|
import propTypesExact from "prop-types-exact"
|
|
8
9
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
9
|
-
import {
|
|
10
|
+
import {Text, View} from "react-native"
|
|
11
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
10
12
|
|
|
11
13
|
export default memo(shapeComponent(class ApiMakerTableSettings extends BaseComponent {
|
|
12
14
|
static propTypes = propTypesExact({
|
|
@@ -15,24 +17,26 @@ export default memo(shapeComponent(class ApiMakerTableSettings extends BaseCompo
|
|
|
15
17
|
})
|
|
16
18
|
|
|
17
19
|
setup() {
|
|
20
|
+
const {t} = useI18n({namespace: "js.api_maker.table.settings"})
|
|
21
|
+
|
|
18
22
|
this.rootRef = useRef()
|
|
23
|
+
this.t = t
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
tableSetting = () => this.p.table.s.tableSetting
|
|
22
27
|
|
|
23
28
|
render() {
|
|
29
|
+
const {t} = this.tt
|
|
24
30
|
const {table} = this.p
|
|
25
31
|
const {preparedColumns} = table.s
|
|
26
32
|
|
|
27
33
|
return (
|
|
28
|
-
<Modal onBackdropPress={this.p.onRequestClose} onRequestClose={this.p.onRequestClose} transparent>
|
|
34
|
+
<Modal onBackdropPress={this.p.onRequestClose} onRequestClose={this.p.onRequestClose} style={{backgroundColor: "#000"}} transparent>
|
|
29
35
|
<View
|
|
30
36
|
dataSet={{class: "api-maker--table--settings"}}
|
|
31
37
|
style={{
|
|
32
38
|
width: "100%",
|
|
33
39
|
maxWidth: 800,
|
|
34
|
-
marginHorizontal: "auto",
|
|
35
|
-
marginVertical: "auto",
|
|
36
40
|
padding: 20,
|
|
37
41
|
backgroundColor: "#fff",
|
|
38
42
|
border: "1px solid black"
|
|
@@ -40,13 +44,13 @@ export default memo(shapeComponent(class ApiMakerTableSettings extends BaseCompo
|
|
|
40
44
|
>
|
|
41
45
|
<View style={{marginBottom: 5}}>
|
|
42
46
|
<Text style={{fontSize: 16, fontWeight: "bold"}}>
|
|
43
|
-
Settings
|
|
47
|
+
{t(".settings", {defaultValue: "Settings"})}
|
|
44
48
|
</Text>
|
|
45
49
|
</View>
|
|
46
50
|
<DownloadAction table={table} />
|
|
47
51
|
<View style={{marginBottom: 5}}>
|
|
48
52
|
<Text style={{fontSize: 16, fontWeight: "bold"}}>
|
|
49
|
-
Columns
|
|
53
|
+
{t(".columns", {defaultValue: "Columns"})}
|
|
50
54
|
</Text>
|
|
51
55
|
</View>
|
|
52
56
|
{preparedColumns?.map(({column, tableSettingColumn}) =>
|
package/src/use-model.mjs
CHANGED
|
@@ -22,6 +22,12 @@ const useModel = (modelClassArg, argsArg = {}) => {
|
|
|
22
22
|
notFound: undefined
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
+
if ("active" in s.props && !s.props.active) {
|
|
26
|
+
s.meta.active = false
|
|
27
|
+
} else {
|
|
28
|
+
s.meta.active = true
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
if (typeof modelClassArg == "object") {
|
|
26
32
|
modelClass = modelClassArg.callback({queryParams})
|
|
27
33
|
} else {
|
|
@@ -83,7 +89,7 @@ const useModel = (modelClassArg, argsArg = {}) => {
|
|
|
83
89
|
}, [])
|
|
84
90
|
|
|
85
91
|
const loadModel = useCallback(async () => {
|
|
86
|
-
if (
|
|
92
|
+
if (!s.m.active) {
|
|
87
93
|
// Not active - don't do anything
|
|
88
94
|
} else if (s.props.newIfNoId && !s.m.modelId) {
|
|
89
95
|
return await loadNewModel()
|