@wq/form-web 3.0.0-alpha.1 → 3.0.0-alpha.3
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/AutoForm.js +10 -22
- package/FormProvider.js +22 -0
- package/components/DeleteForm.js +25 -18
- package/components/FormContainer.js +31 -0
- package/components/FormRoot.js +1 -30
- package/components/index.js +2 -0
- package/index.js +2 -1
- package/package.json +2 -2
- package/src/AutoForm.js +8 -14
- package/src/FormProvider.js +18 -0
- package/src/components/DeleteForm.js +23 -14
- package/src/components/FormContainer.js +26 -0
- package/src/components/FormRoot.js +1 -24
- package/src/components/index.js +2 -0
- package/src/index.js +2 -1
package/AutoForm.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
function AutoForm(props) {
|
|
15
|
-
if (!props.action && !props.onSubmit && !props.form) {
|
|
16
|
-
return props.children || null;
|
|
17
|
-
}
|
|
18
|
-
return /*#__PURE__*/ React.createElement(AutoFormBase, {
|
|
19
|
-
...props,
|
|
20
|
-
});
|
|
2
|
+
import { AutoFormBase } from "@wq/form-common";
|
|
3
|
+
import FormProvider from "./FormProvider.js";
|
|
4
|
+
export default function AutoForm(props) {
|
|
5
|
+
return /*#__PURE__*/ React.createElement(
|
|
6
|
+
FormProvider,
|
|
7
|
+
null,
|
|
8
|
+
/*#__PURE__*/ React.createElement(AutoFormBase, {
|
|
9
|
+
...props,
|
|
10
|
+
}),
|
|
11
|
+
);
|
|
21
12
|
}
|
|
22
|
-
export default withWQ(AutoForm, {
|
|
23
|
-
defaults: AutoFormDefaults,
|
|
24
|
-
});
|
package/FormProvider.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fragment } from "react";
|
|
2
|
+
import { withWQ } from "@wq/react";
|
|
3
|
+
import {
|
|
4
|
+
AutoFormBase as AutoForm,
|
|
5
|
+
AutoInput,
|
|
6
|
+
Form,
|
|
7
|
+
CancelButton,
|
|
8
|
+
} from "@wq/form-common";
|
|
9
|
+
import * as components from "./components/index.js";
|
|
10
|
+
const FormProviderDefaults = {
|
|
11
|
+
components: {
|
|
12
|
+
...components,
|
|
13
|
+
AutoForm,
|
|
14
|
+
AutoInput,
|
|
15
|
+
Form,
|
|
16
|
+
CancelButton,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export default withWQ(Fragment, {
|
|
20
|
+
name: "FormProvider",
|
|
21
|
+
defaults: FormProviderDefaults,
|
|
22
|
+
});
|
package/components/DeleteForm.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
createFallbackComponents,
|
|
7
7
|
} from "@wq/react";
|
|
8
8
|
import { Form } from "@wq/form-common";
|
|
9
|
+
import FormContainer from "./FormContainer.js";
|
|
9
10
|
import SubmitButton from "./SubmitButton.js";
|
|
10
11
|
import PropTypes from "prop-types";
|
|
11
12
|
const DeleteFormFallback = {
|
|
@@ -13,13 +14,15 @@ const DeleteFormFallback = {
|
|
|
13
14
|
CONFIRM_DELETE: "Are you sure you want to delete this record?",
|
|
14
15
|
},
|
|
15
16
|
components: {
|
|
17
|
+
FormContainer,
|
|
16
18
|
Form,
|
|
17
19
|
SubmitButton,
|
|
18
20
|
...createFallbackComponents(["View", "HorizontalView"], "@wq/material"),
|
|
19
21
|
},
|
|
20
22
|
};
|
|
21
23
|
function DeleteForm({ action, onSubmit, submitOptions }) {
|
|
22
|
-
const { Form, SubmitButton, View, HorizontalView } =
|
|
24
|
+
const { FormContainer, Form, SubmitButton, View, HorizontalView } =
|
|
25
|
+
useComponents(),
|
|
23
26
|
message = useMessage("CONFIRM_DELETE");
|
|
24
27
|
function confirmSubmit(options) {
|
|
25
28
|
if (window.confirm(message)) {
|
|
@@ -31,25 +34,29 @@ function DeleteForm({ action, onSubmit, submitOptions }) {
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
return /*#__PURE__*/ React.createElement(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
action: action,
|
|
37
|
-
method: "DELETE",
|
|
38
|
-
onSubmit: confirmSubmit,
|
|
39
|
-
submitOptions: submitOptions,
|
|
40
|
-
},
|
|
37
|
+
FormContainer,
|
|
38
|
+
null,
|
|
41
39
|
/*#__PURE__*/ React.createElement(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
Form,
|
|
41
|
+
{
|
|
42
|
+
action: action,
|
|
43
|
+
method: "DELETE",
|
|
44
|
+
onSubmit: confirmSubmit,
|
|
45
|
+
submitOptions: submitOptions,
|
|
46
|
+
},
|
|
45
47
|
/*#__PURE__*/ React.createElement(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
HorizontalView,
|
|
49
|
+
null,
|
|
50
|
+
/*#__PURE__*/ React.createElement(View, null),
|
|
51
|
+
/*#__PURE__*/ React.createElement(
|
|
52
|
+
SubmitButton,
|
|
53
|
+
{
|
|
54
|
+
icon: "delete",
|
|
55
|
+
variant: "text",
|
|
56
|
+
color: "secondary",
|
|
57
|
+
},
|
|
58
|
+
"Delete",
|
|
59
|
+
),
|
|
53
60
|
),
|
|
54
61
|
),
|
|
55
62
|
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { withWQ } from "@wq/react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
function FormContainer({ children }) {
|
|
5
|
+
return /*#__PURE__*/ React.createElement(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
style: {
|
|
9
|
+
flex: 1,
|
|
10
|
+
display: "flex",
|
|
11
|
+
justifyContent: "center",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
/*#__PURE__*/ React.createElement(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
style: {
|
|
18
|
+
width: "100%",
|
|
19
|
+
maxWidth: "70em",
|
|
20
|
+
padding: "1em",
|
|
21
|
+
boxSizing: "border-box",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
children,
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
FormContainer.propTypes = {
|
|
29
|
+
children: PropTypes.node,
|
|
30
|
+
};
|
|
31
|
+
export default withWQ(FormContainer);
|
package/components/FormRoot.js
CHANGED
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { withWQ } from "@wq/react";
|
|
3
2
|
import { Form } from "formik";
|
|
4
|
-
|
|
5
|
-
function FormRoot({ children }) {
|
|
6
|
-
return /*#__PURE__*/ React.createElement(
|
|
7
|
-
"div",
|
|
8
|
-
{
|
|
9
|
-
style: {
|
|
10
|
-
flex: 1,
|
|
11
|
-
display: "flex",
|
|
12
|
-
justifyContent: "center",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
/*#__PURE__*/ React.createElement(
|
|
16
|
-
Form,
|
|
17
|
-
{
|
|
18
|
-
style: {
|
|
19
|
-
width: "100%",
|
|
20
|
-
maxWidth: "70em",
|
|
21
|
-
padding: "1em",
|
|
22
|
-
boxSizing: "border-box",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
children,
|
|
26
|
-
),
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
FormRoot.propTypes = {
|
|
30
|
-
children: PropTypes.node,
|
|
31
|
-
};
|
|
32
|
-
export default withWQ(FormRoot);
|
|
3
|
+
export default withWQ(Form, "FormRoot");
|
package/components/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import FormContainer from "./FormContainer.js";
|
|
1
2
|
import FormRoot from "./FormRoot.js";
|
|
2
3
|
import FormError from "./FormError.js";
|
|
3
4
|
import Input from "./Input.js";
|
|
@@ -23,6 +24,7 @@ const Date = DateTime;
|
|
|
23
24
|
const Time = DateTime;
|
|
24
25
|
const dateTime = DateTime;
|
|
25
26
|
export {
|
|
27
|
+
FormContainer,
|
|
26
28
|
FormRoot,
|
|
27
29
|
FormError,
|
|
28
30
|
Input,
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wq/form-web",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"description": "Web bindings for @wq/form",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://form.wq.io/@wq/form-web",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@wq/form-common": "^3.0.0-alpha.
|
|
32
|
+
"@wq/form-common": "^3.0.0-alpha.4",
|
|
33
33
|
"@wq/react": "^3.0.0-alpha.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
package/src/AutoForm.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import * as components from "./components/index.js";
|
|
2
|
+
import { AutoFormBase } from "@wq/form-common";
|
|
3
|
+
import FormProvider from "./FormProvider.js";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return props.children || null;
|
|
13
|
-
}
|
|
14
|
-
return <AutoFormBase {...props} />;
|
|
5
|
+
export default function AutoForm(props) {
|
|
6
|
+
return (
|
|
7
|
+
<FormProvider>
|
|
8
|
+
<AutoFormBase {...props} />
|
|
9
|
+
</FormProvider>
|
|
10
|
+
);
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
export default withWQ(AutoForm, { defaults: AutoFormDefaults });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment } from "react";
|
|
2
|
+
import { withWQ } from "@wq/react";
|
|
3
|
+
import {
|
|
4
|
+
AutoFormBase as AutoForm,
|
|
5
|
+
AutoInput,
|
|
6
|
+
Form,
|
|
7
|
+
CancelButton,
|
|
8
|
+
} from "@wq/form-common";
|
|
9
|
+
import * as components from "./components/index.js";
|
|
10
|
+
|
|
11
|
+
const FormProviderDefaults = {
|
|
12
|
+
components: { ...components, AutoForm, AutoInput, Form, CancelButton },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default withWQ(Fragment, {
|
|
16
|
+
name: "FormProvider",
|
|
17
|
+
defaults: FormProviderDefaults,
|
|
18
|
+
});
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
createFallbackComponents,
|
|
7
7
|
} from "@wq/react";
|
|
8
8
|
import { Form } from "@wq/form-common";
|
|
9
|
+
import FormContainer from "./FormContainer.js";
|
|
9
10
|
import SubmitButton from "./SubmitButton.js";
|
|
10
11
|
import PropTypes from "prop-types";
|
|
11
12
|
|
|
@@ -14,6 +15,7 @@ const DeleteFormFallback = {
|
|
|
14
15
|
CONFIRM_DELETE: "Are you sure you want to delete this record?",
|
|
15
16
|
},
|
|
16
17
|
components: {
|
|
18
|
+
FormContainer,
|
|
17
19
|
Form,
|
|
18
20
|
SubmitButton,
|
|
19
21
|
...createFallbackComponents(["View", "HorizontalView"], "@wq/material"),
|
|
@@ -21,7 +23,8 @@ const DeleteFormFallback = {
|
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
function DeleteForm({ action, onSubmit, submitOptions }) {
|
|
24
|
-
const { Form, SubmitButton, View, HorizontalView } =
|
|
26
|
+
const { FormContainer, Form, SubmitButton, View, HorizontalView } =
|
|
27
|
+
useComponents(),
|
|
25
28
|
message = useMessage("CONFIRM_DELETE");
|
|
26
29
|
|
|
27
30
|
function confirmSubmit(options) {
|
|
@@ -35,19 +38,25 @@ function DeleteForm({ action, onSubmit, submitOptions }) {
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
<FormContainer>
|
|
42
|
+
<Form
|
|
43
|
+
action={action}
|
|
44
|
+
method="DELETE"
|
|
45
|
+
onSubmit={confirmSubmit}
|
|
46
|
+
submitOptions={submitOptions}
|
|
47
|
+
>
|
|
48
|
+
<HorizontalView>
|
|
49
|
+
<View />
|
|
50
|
+
<SubmitButton
|
|
51
|
+
icon="delete"
|
|
52
|
+
variant="text"
|
|
53
|
+
color="secondary"
|
|
54
|
+
>
|
|
55
|
+
Delete
|
|
56
|
+
</SubmitButton>
|
|
57
|
+
</HorizontalView>
|
|
58
|
+
</Form>
|
|
59
|
+
</FormContainer>
|
|
51
60
|
);
|
|
52
61
|
}
|
|
53
62
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { withWQ } from "@wq/react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
|
|
5
|
+
function FormContainer({ children }) {
|
|
6
|
+
return (
|
|
7
|
+
<div style={{ flex: 1, display: "flex", justifyContent: "center" }}>
|
|
8
|
+
<div
|
|
9
|
+
style={{
|
|
10
|
+
width: "100%",
|
|
11
|
+
maxWidth: "70em",
|
|
12
|
+
padding: "1em",
|
|
13
|
+
boxSizing: "border-box",
|
|
14
|
+
}}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
FormContainer.propTypes = {
|
|
23
|
+
children: PropTypes.node,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default withWQ(FormContainer);
|
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { withWQ } from "@wq/react";
|
|
3
2
|
import { Form } from "formik";
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<div style={{ flex: 1, display: "flex", justifyContent: "center" }}>
|
|
9
|
-
<Form
|
|
10
|
-
style={{
|
|
11
|
-
width: "100%",
|
|
12
|
-
maxWidth: "70em",
|
|
13
|
-
padding: "1em",
|
|
14
|
-
boxSizing: "border-box",
|
|
15
|
-
}}
|
|
16
|
-
>
|
|
17
|
-
{children}
|
|
18
|
-
</Form>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
FormRoot.propTypes = {
|
|
24
|
-
children: PropTypes.node,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default withWQ(FormRoot);
|
|
4
|
+
export default withWQ(Form, "FormRoot");
|
package/src/components/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import FormContainer from "./FormContainer.js";
|
|
1
2
|
import FormRoot from "./FormRoot.js";
|
|
2
3
|
import FormError from "./FormError.js";
|
|
3
4
|
import Input from "./Input.js";
|
|
@@ -25,6 +26,7 @@ const Time = DateTime;
|
|
|
25
26
|
const dateTime = DateTime;
|
|
26
27
|
|
|
27
28
|
export {
|
|
29
|
+
FormContainer,
|
|
28
30
|
FormRoot,
|
|
29
31
|
FormError,
|
|
30
32
|
Input,
|
package/src/index.js
CHANGED