@kaspernj/api-maker 1.0.405 → 1.0.406
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/form.jsx +19 -4
- package/src/table/model-row.jsx +3 -1
package/package.json
CHANGED
package/src/form.jsx
CHANGED
|
@@ -7,8 +7,9 @@ import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
|
7
7
|
const FormContext = createContext(null)
|
|
8
8
|
|
|
9
9
|
class FormInputs {
|
|
10
|
-
constructor() {
|
|
10
|
+
constructor({onSubmit}) {
|
|
11
11
|
this.inputs = {}
|
|
12
|
+
this.onSubmit = onSubmit
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
asObject() {
|
|
@@ -37,12 +38,18 @@ class FormInputs {
|
|
|
37
38
|
return <input name={name} type="hidden" value={value !== null && value !== undefined ? value : ""} />
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
|
|
42
|
+
submit() {
|
|
43
|
+
if (this.onSubmit) {
|
|
44
|
+
this.onSubmit()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
const Form = memo(shapeComponent(class Form extends BaseComponent {
|
|
43
50
|
render() {
|
|
44
|
-
const {children, setForm, ...restProps} = this.props
|
|
45
|
-
const form = useMemo(() => new FormInputs(), [])
|
|
51
|
+
const {children, onSubmit, setForm, ...restProps} = this.props
|
|
52
|
+
const form = useMemo(() => new FormInputs({onSubmit}), [])
|
|
46
53
|
|
|
47
54
|
useMemo(() => {
|
|
48
55
|
if (setForm) {
|
|
@@ -53,7 +60,7 @@ const Form = memo(shapeComponent(class Form extends BaseComponent {
|
|
|
53
60
|
return (
|
|
54
61
|
<FormContext.Provider value={form}>
|
|
55
62
|
{Platform.OS == "web" &&
|
|
56
|
-
<form {...restProps}>
|
|
63
|
+
<form onSubmit={this.tt.onFormSubmit} {...restProps}>
|
|
57
64
|
{children}
|
|
58
65
|
</form>
|
|
59
66
|
}
|
|
@@ -61,6 +68,14 @@ const Form = memo(shapeComponent(class Form extends BaseComponent {
|
|
|
61
68
|
</FormContext.Provider>
|
|
62
69
|
)
|
|
63
70
|
}
|
|
71
|
+
|
|
72
|
+
onFormSubmit = (e) => {
|
|
73
|
+
e.preventDefault()
|
|
74
|
+
|
|
75
|
+
if (this.props.onSubmit) {
|
|
76
|
+
this.props.onSubmit()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
64
79
|
}))
|
|
65
80
|
|
|
66
81
|
const useForm = () => useContext(FormContext)
|
package/src/table/model-row.jsx
CHANGED
|
@@ -191,7 +191,9 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
|
|
|
191
191
|
} else if (MoneyFormatter.isMoney(value)) {
|
|
192
192
|
return <Text>{MoneyFormatter.format(value)}</Text>
|
|
193
193
|
} else if (typeof value == "boolean") {
|
|
194
|
-
if (value)
|
|
194
|
+
if (value) {
|
|
195
|
+
return <Text>{I18n.t("js.shared.yes", {defaultValue: "Yes"})}</Text>
|
|
196
|
+
}
|
|
195
197
|
|
|
196
198
|
return <Text>{I18n.t("js.shared.no", {defaultValue: "No"})}</Text>
|
|
197
199
|
} else if (Array.isArray(value)) {
|