envoc-form 4.0.1-5 → 4.0.1-6
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/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +3 -1
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +2 -2
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +2 -1
- package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +3 -1
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +2 -2
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +2 -1
- package/package.json +2 -2
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +7 -2
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.tsx.snap +2 -2
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +8 -1
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.tsx.snap +1 -1
@@ -5,6 +5,8 @@ export interface ConfirmBaseFormProps {
|
|
5
5
|
request: useAxiosRequestProps;
|
6
6
|
style?: React.CSSProperties;
|
7
7
|
title?: string;
|
8
|
+
confirmButtonText?: string;
|
9
|
+
confirmButtonClass?: string;
|
8
10
|
children?: React.ReactNode;
|
9
11
|
}
|
10
|
-
export default function ConfirmBaseForm({ handleCancel, request, style, title, children, ...props }: ConfirmBaseFormProps): JSX.Element;
|
12
|
+
export default function ConfirmBaseForm({ handleCancel, request, style, title, confirmButtonText, confirmButtonClass, children, ...props }: ConfirmBaseFormProps): JSX.Element;
|
@@ -26,10 +26,10 @@ import { useAxiosRequest } from 'envoc-request';
|
|
26
26
|
import { FormDefaults } from '../FormDefaults';
|
27
27
|
// TODO: ask about how we should use 'children'
|
28
28
|
export default function ConfirmBaseForm(_a) {
|
29
|
-
var handleCancel = _a.handleCancel, request = _a.request, style = _a.style, title = _a.title, children = _a.children, props = __rest(_a, ["handleCancel", "request", "style", "title", "children"]);
|
29
|
+
var handleCancel = _a.handleCancel, request = _a.request, style = _a.style, title = _a.title, confirmButtonText = _a.confirmButtonText, confirmButtonClass = _a.confirmButtonClass, children = _a.children, props = __rest(_a, ["handleCancel", "request", "style", "title", "confirmButtonText", "confirmButtonClass", "children"]);
|
30
30
|
var webRequest = useAxiosRequest(Object.assign({}, request, { autoExecute: false }));
|
31
31
|
var onCancel = handleCancel !== null && handleCancel !== void 0 ? handleCancel : goBack;
|
32
|
-
return (_jsxs("div", __assign({ style: __assign({ textAlign: 'center' }, style) }, props, { children: [_jsx("h3", { children: title }), children, _jsx("button", __assign({ className: classNames(FormDefaults.cssClassPrefix + 'confirm-base-form-
|
32
|
+
return (_jsxs("div", __assign({ style: __assign({ textAlign: 'center' }, style) }, props, { children: [_jsx("h3", { children: title }), children, _jsx("button", __assign({ className: classNames(confirmButtonClass !== null && confirmButtonClass !== void 0 ? confirmButtonClass : FormDefaults.cssClassPrefix + 'confirm-base-form-confirm-button'), type: "button", onClick: webRequest.submitRequest }, { children: confirmButtonText !== null && confirmButtonText !== void 0 ? confirmButtonText : 'Confirm' })), _jsx("button", __assign({ className: classNames(FormDefaults.cssClassPrefix + 'confirm-base-form-cancel-button'), type: "button", onClick: onCancel }, { children: "Cancel" }))] })));
|
33
33
|
function goBack() {
|
34
34
|
window.history.back();
|
35
35
|
}
|
@@ -24,6 +24,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import { useNavigate, useParams } from 'react-router-dom';
|
25
25
|
import { toast } from 'react-toastify';
|
26
26
|
import ConfirmBaseForm from '../ConfirmBaseForm/ConfirmBaseForm';
|
27
|
+
import { FormDefaults } from '../FormDefaults';
|
27
28
|
export default function ConfirmDeleteForm(_a) {
|
28
29
|
var successUrl = _a.successUrl, form = _a.form, title = _a.title, handleComplete = _a.handleComplete, handleError = _a.handleError, children = _a.children, props = __rest(_a, ["successUrl", "form", "title", "handleComplete", "handleError", "children"]);
|
29
30
|
var navigate = useNavigate();
|
@@ -42,7 +43,7 @@ export default function ConfirmDeleteForm(_a) {
|
|
42
43
|
onComplete: onComplete,
|
43
44
|
onError: onError,
|
44
45
|
};
|
45
|
-
return (_jsx(ConfirmBaseForm, __assign({ request: request, handleCancel: goBack, title: title !== null && title !== void 0 ? title : 'Are you sure you want to delete this?' }, props, { children: children })));
|
46
|
+
return (_jsx(ConfirmBaseForm, __assign({ request: request, handleCancel: goBack, title: title !== null && title !== void 0 ? title : 'Are you sure you want to delete this?', confirmButtonText: "Yes", confirmButtonClass: FormDefaults.cssClassPrefix + 'confirm-delete-form-yes-button' }, props, { children: children })));
|
46
47
|
function goBack() {
|
47
48
|
if (successUrl) {
|
48
49
|
navigate(successUrl);
|
@@ -5,6 +5,8 @@ export interface ConfirmBaseFormProps {
|
|
5
5
|
request: useAxiosRequestProps;
|
6
6
|
style?: React.CSSProperties;
|
7
7
|
title?: string;
|
8
|
+
confirmButtonText?: string;
|
9
|
+
confirmButtonClass?: string;
|
8
10
|
children?: React.ReactNode;
|
9
11
|
}
|
10
|
-
export default function ConfirmBaseForm({ handleCancel, request, style, title, children, ...props }: ConfirmBaseFormProps): JSX.Element;
|
12
|
+
export default function ConfirmBaseForm({ handleCancel, request, style, title, confirmButtonText, confirmButtonClass, children, ...props }: ConfirmBaseFormProps): JSX.Element;
|
@@ -31,10 +31,10 @@ var envoc_request_1 = require("envoc-request");
|
|
31
31
|
var FormDefaults_1 = require("../FormDefaults");
|
32
32
|
// TODO: ask about how we should use 'children'
|
33
33
|
function ConfirmBaseForm(_a) {
|
34
|
-
var handleCancel = _a.handleCancel, request = _a.request, style = _a.style, title = _a.title, children = _a.children, props = __rest(_a, ["handleCancel", "request", "style", "title", "children"]);
|
34
|
+
var handleCancel = _a.handleCancel, request = _a.request, style = _a.style, title = _a.title, confirmButtonText = _a.confirmButtonText, confirmButtonClass = _a.confirmButtonClass, children = _a.children, props = __rest(_a, ["handleCancel", "request", "style", "title", "confirmButtonText", "confirmButtonClass", "children"]);
|
35
35
|
var webRequest = (0, envoc_request_1.useAxiosRequest)(Object.assign({}, request, { autoExecute: false }));
|
36
36
|
var onCancel = handleCancel !== null && handleCancel !== void 0 ? handleCancel : goBack;
|
37
|
-
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: __assign({ textAlign: 'center' }, style) }, props, { children: [(0, jsx_runtime_1.jsx)("h3", { children: title }), children, (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-base-form-
|
37
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: __assign({ textAlign: 'center' }, style) }, props, { children: [(0, jsx_runtime_1.jsx)("h3", { children: title }), children, (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(confirmButtonClass !== null && confirmButtonClass !== void 0 ? confirmButtonClass : FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-base-form-confirm-button'), type: "button", onClick: webRequest.submitRequest }, { children: confirmButtonText !== null && confirmButtonText !== void 0 ? confirmButtonText : 'Confirm' })), (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-base-form-cancel-button'), type: "button", onClick: onCancel }, { children: "Cancel" }))] })));
|
38
38
|
function goBack() {
|
39
39
|
window.history.back();
|
40
40
|
}
|
@@ -29,6 +29,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
29
29
|
var react_router_dom_1 = require("react-router-dom");
|
30
30
|
var react_toastify_1 = require("react-toastify");
|
31
31
|
var ConfirmBaseForm_1 = __importDefault(require("../ConfirmBaseForm/ConfirmBaseForm"));
|
32
|
+
var FormDefaults_1 = require("../FormDefaults");
|
32
33
|
function ConfirmDeleteForm(_a) {
|
33
34
|
var successUrl = _a.successUrl, form = _a.form, title = _a.title, handleComplete = _a.handleComplete, handleError = _a.handleError, children = _a.children, props = __rest(_a, ["successUrl", "form", "title", "handleComplete", "handleError", "children"]);
|
34
35
|
var navigate = (0, react_router_dom_1.useNavigate)();
|
@@ -47,7 +48,7 @@ function ConfirmDeleteForm(_a) {
|
|
47
48
|
onComplete: onComplete,
|
48
49
|
onError: onError,
|
49
50
|
};
|
50
|
-
return ((0, jsx_runtime_1.jsx)(ConfirmBaseForm_1.default, __assign({ request: request, handleCancel: goBack, title: title !== null && title !== void 0 ? title : 'Are you sure you want to delete this?' }, props, { children: children })));
|
51
|
+
return ((0, jsx_runtime_1.jsx)(ConfirmBaseForm_1.default, __assign({ request: request, handleCancel: goBack, title: title !== null && title !== void 0 ? title : 'Are you sure you want to delete this?', confirmButtonText: "Yes", confirmButtonClass: FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-delete-form-yes-button' }, props, { children: children })));
|
51
52
|
function goBack() {
|
52
53
|
if (successUrl) {
|
53
54
|
navigate(successUrl);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "envoc-form",
|
3
|
-
"version": "4.0.1-
|
3
|
+
"version": "4.0.1-6",
|
4
4
|
"description": "Envoc form components",
|
5
5
|
"keywords": [
|
6
6
|
"react-component",
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"axios": "^0.21.1",
|
38
38
|
"classnames": "^2.3.1",
|
39
39
|
"date-fns": "^2.22.1",
|
40
|
-
"envoc-request": "^4.0.1-
|
40
|
+
"envoc-request": "^4.0.1-6",
|
41
41
|
"lru-cache": "^6.0.0",
|
42
42
|
"prop-types": "^15.7.2",
|
43
43
|
"react-date-picker": "^8.2.0",
|
@@ -10,6 +10,8 @@ export interface ConfirmBaseFormProps {
|
|
10
10
|
request: useAxiosRequestProps;
|
11
11
|
style?: React.CSSProperties;
|
12
12
|
title?: string;
|
13
|
+
confirmButtonText?: string;
|
14
|
+
confirmButtonClass?: string;
|
13
15
|
children?: React.ReactNode;
|
14
16
|
}
|
15
17
|
|
@@ -19,6 +21,8 @@ export default function ConfirmBaseForm({
|
|
19
21
|
request,
|
20
22
|
style,
|
21
23
|
title,
|
24
|
+
confirmButtonText,
|
25
|
+
confirmButtonClass,
|
22
26
|
children,
|
23
27
|
...props
|
24
28
|
}: ConfirmBaseFormProps) {
|
@@ -33,11 +37,12 @@ export default function ConfirmBaseForm({
|
|
33
37
|
{children}
|
34
38
|
<button
|
35
39
|
className={classNames(
|
36
|
-
|
40
|
+
confirmButtonClass ??
|
41
|
+
FormDefaults.cssClassPrefix + 'confirm-base-form-confirm-button'
|
37
42
|
)}
|
38
43
|
type="button"
|
39
44
|
onClick={webRequest.submitRequest}>
|
40
|
-
|
45
|
+
{confirmButtonText ?? 'Confirm'}
|
41
46
|
</button>
|
42
47
|
<button
|
43
48
|
className={classNames(
|
@@ -7,10 +7,10 @@ exports[`ConfirmBaseForm has matching snapshot 1`] = `
|
|
7
7
|
>
|
8
8
|
<h3 />
|
9
9
|
<button
|
10
|
-
class="envoc-form-confirm-base-form-
|
10
|
+
class="envoc-form-confirm-base-form-confirm-button"
|
11
11
|
type="button"
|
12
12
|
>
|
13
|
-
|
13
|
+
Confirm
|
14
14
|
</button>
|
15
15
|
<button
|
16
16
|
class="envoc-form-confirm-base-form-cancel-button"
|
@@ -2,7 +2,10 @@ import React from 'react';
|
|
2
2
|
import { useNavigate, useParams } from 'react-router-dom';
|
3
3
|
import { toast } from 'react-toastify';
|
4
4
|
import { useAxiosRequestProps } from 'envoc-request';
|
5
|
-
import ConfirmBaseForm, {
|
5
|
+
import ConfirmBaseForm, {
|
6
|
+
ConfirmBaseFormProps,
|
7
|
+
} from '../ConfirmBaseForm/ConfirmBaseForm';
|
8
|
+
import { FormDefaults } from '../FormDefaults';
|
6
9
|
|
7
10
|
export interface ConfirmDeleteFormProps
|
8
11
|
extends Pick<ConfirmBaseFormProps, 'style'> {
|
@@ -52,6 +55,10 @@ export default function ConfirmDeleteForm({
|
|
52
55
|
request={request}
|
53
56
|
handleCancel={goBack}
|
54
57
|
title={title ?? 'Are you sure you want to delete this?'}
|
58
|
+
confirmButtonText="Yes"
|
59
|
+
confirmButtonClass={
|
60
|
+
FormDefaults.cssClassPrefix + 'confirm-delete-form-yes-button'
|
61
|
+
}
|
55
62
|
{...props}>
|
56
63
|
{children}
|
57
64
|
</ConfirmBaseForm>
|