@wq/form-native 3.0.0-alpha.0 → 3.0.0-alpha.1

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": "@wq/form-native",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "React Native and Expo bindings for @wq/material",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://form.wq.io/@wq/form-native",
30
30
  "dependencies": {
31
- "@wq/form-common": "^3.0.0-alpha.0",
31
+ "@wq/form-common": "^3.0.0-alpha.2",
32
32
  "@wq/react": "^3.0.0-alpha.0"
33
33
  },
34
34
  "peerDependencies": {
@@ -24,49 +24,53 @@ const DeleteFormFallback = {
24
24
  },
25
25
  };
26
26
 
27
- function DeleteForm({ action }) {
27
+ function DeleteForm({ action, onSubmit, submitOptions }) {
28
28
  const { Form, SubmitButton, View, HorizontalView } = useComponents(),
29
29
  confirmDelete = useMessage("CONFIRM_DELETE"),
30
30
  confirmDeleteTitle = useMessage("CONFIRM_DELETE_TITLE"),
31
31
  confirmDeleteOk = useMessage("CONFIRM_DELETE_OK"),
32
32
  confirmDeleteCancel = useMessage("CONFIRM_DELETE_CANCEL");
33
33
 
34
- async function confirmSubmit() {
35
- return new Promise((resolve) => {
36
- Alert.alert(
37
- confirmDeleteTitle,
38
- confirmDelete,
39
- [
40
- {
41
- text: confirmDeleteCancel,
42
- onPress() {
43
- resolve(false);
44
- },
45
- style: "cancel",
46
- },
47
- {
48
- text: confirmDeleteOk,
49
- onPress() {
50
- resolve(true);
51
- },
52
- style: "destructive",
34
+ async function confirmSubmit(options) {
35
+ Alert.alert(
36
+ confirmDeleteTitle,
37
+ confirmDelete,
38
+ [
39
+ {
40
+ text: confirmDeleteCancel,
41
+ onPress() {
42
+ // noop
53
43
  },
54
- ],
44
+ style: "cancel",
45
+ },
55
46
  {
56
- onDismiss() {
57
- resolve(false);
47
+ text: confirmDeleteOk,
48
+ onPress() {
49
+ if (onSubmit) {
50
+ onSubmit(options);
51
+ } else {
52
+ console.error(
53
+ "No onSubmit handler provided to DeleteForm",
54
+ );
55
+ }
58
56
  },
57
+ style: "destructive",
58
+ },
59
+ ],
60
+ {
61
+ onDismiss() {
62
+ // noop
59
63
  },
60
- );
61
- });
64
+ },
65
+ );
62
66
  }
63
67
 
64
68
  return (
65
69
  <Form
66
70
  action={action}
67
71
  method="DELETE"
68
- backgroundSync={false}
69
72
  onSubmit={confirmSubmit}
73
+ submitOptions={submitOptions}
70
74
  >
71
75
  <HorizontalView>
72
76
  <View />
@@ -80,6 +84,8 @@ function DeleteForm({ action }) {
80
84
 
81
85
  DeleteForm.propTypes = {
82
86
  action: PropTypes.string,
87
+ onSubmit: PropTypes.func.isRequired,
88
+ submitOptions: PropTypes.object,
83
89
  };
84
90
 
85
91
  export default withWQ(DeleteForm, { fallback: DeleteFormFallback });