@servicetitan/confirm 19.1.0 → 20.0.0
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/dist/confirm.js +6 -10
- package/dist/confirm.js.map +1 -1
- package/dist/confirmation-messages/default-confirmation.js +4 -8
- package/dist/confirmation-messages/default-confirmation.js.map +1 -1
- package/dist/confirmation-messages/yes-no-confirmation.js +5 -31
- package/dist/confirmation-messages/yes-no-confirmation.js.map +1 -1
- package/dist/demo/basic.js +5 -9
- package/dist/demo/basic.js.map +1 -1
- package/dist/demo/configurable.js +5 -9
- package/dist/demo/configurable.js.map +1 -1
- package/dist/demo/custom.js +6 -10
- package/dist/demo/custom.js.map +1 -1
- package/dist/demo/hook.js +7 -11
- package/dist/demo/hook.js.map +1 -1
- package/dist/demo/index.js +6 -18
- package/dist/demo/index.js.map +1 -1
- package/dist/demo/toggleable.js +7 -11
- package/dist/demo/toggleable.js.map +1 -1
- package/dist/demo/yes-no.js +5 -9
- package/dist/demo/yes-no.js.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/dist/use-confirm.js +9 -13
- package/dist/use-confirm.js.map +1 -1
- package/package.json +6 -5
package/dist/confirm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,15 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const use_confirm_1 = require("./use-confirm");
|
|
18
|
-
const Confirm = (_a) => {
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment } from 'react';
|
|
14
|
+
import { useConfirm } from './use-confirm';
|
|
15
|
+
export const Confirm = (_a) => {
|
|
19
16
|
var { onConfirm, onDecline, children } = _a, props = __rest(_a, ["onConfirm", "onDecline", "children"]);
|
|
20
|
-
const [Confirm, handler] =
|
|
21
|
-
return ((
|
|
17
|
+
const [Confirm, handler] = useConfirm(onConfirm, onDecline);
|
|
18
|
+
return (_jsxs(Fragment, { children: [children(handler), _jsx(Confirm, Object.assign({}, props), void 0)] }, void 0));
|
|
22
19
|
};
|
|
23
|
-
exports.Confirm = Confirm;
|
|
24
20
|
//# sourceMappingURL=confirm.js.map
|
package/dist/confirm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../src/confirm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../src/confirm.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAwD,MAAM,eAAe,CAAC;AASjG,MAAM,CAAC,MAAM,OAAO,GAAG,CAGrB,EAKmB,EAAE,EAAE;QALvB,EACE,SAAS,EACT,SAAS,EACT,QAAQ,OAES,EADd,KAAK,cAJV,sCAKD,CADW;IAER,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAE5D,OAAO,CACH,MAAC,QAAQ,eACJ,QAAQ,CAAC,OAAO,CAAC,EAElB,KAAC,OAAO,oBAAM,KAAyC,UAAI,YACpD,CACd,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,13 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
17
|
-
const DefaultConfirmation = (_a) => {
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Dialog } from '@servicetitan/design-system';
|
|
14
|
+
export const DefaultConfirmation = (_a) => {
|
|
18
15
|
var { negative = true, title = 'Are you sure?', message = '', onConfirm, onCancel } = _a, props = __rest(_a, ["negative", "title", "message", "onConfirm", "onCancel"]);
|
|
19
|
-
return ((
|
|
16
|
+
return (_jsx(Dialog, Object.assign({ open: true, negative: negative, onClose: onCancel, title: title, onPrimaryActionClick: onConfirm, primaryActionName: "Confirm", onSecondaryActionClick: onCancel, secondaryActionName: "Cancel" }, props, { children: message }), void 0));
|
|
20
17
|
};
|
|
21
|
-
exports.DefaultConfirmation = DefaultConfirmation;
|
|
22
18
|
//# sourceMappingURL=default-confirmation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-confirmation.js","sourceRoot":"","sources":["../../src/confirmation-messages/default-confirmation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default-confirmation.js","sourceRoot":"","sources":["../../src/confirmation-messages/default-confirmation.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,MAAM,EAAe,MAAM,6BAA6B,CAAC;AAiBlE,MAAM,CAAC,MAAM,mBAAmB,GAAiC,CAAC,EAOjE,EAAE,EAAE;QAP6D,EAC9D,QAAQ,GAAG,IAAI,EACf,KAAK,GAAG,eAAe,EACvB,OAAO,GAAG,EAAE,EACZ,SAAS,EACT,QAAQ,OAEX,EADM,KAAK,cANsD,yDAOjE,CADW;IACN,OAAA,CACF,KAAC,MAAM,kBACH,IAAI,QACJ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,QAAQ,EACjB,KAAK,EAAE,KAAK,EACZ,oBAAoB,EAAE,SAAS,EAC/B,iBAAiB,EAAC,SAAS,EAC3B,sBAAsB,EAAE,QAAQ,EAChC,mBAAmB,EAAC,QAAQ,IACxB,KAAK,cAER,OAAO,YACH,CACZ,CAAA;CAAA,CAAC"}
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.YesNoConfirmation = void 0;
|
|
26
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
28
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
29
|
-
const Styles = __importStar(require("./yes-no-confirmation.module.css"));
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal, ButtonGroup, Button } from '@servicetitan/design-system';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import * as Styles from './yes-no-confirmation.module.css';
|
|
30
5
|
// TODO: think about suitable default title
|
|
31
|
-
const YesNoConfirmation = ({ title = '', message = '', onConfirm, onDecline, onCancel, }) => ((
|
|
32
|
-
exports.YesNoConfirmation = YesNoConfirmation;
|
|
6
|
+
export const YesNoConfirmation = ({ title = '', message = '', onConfirm, onDecline, onCancel, }) => (_jsx(Modal, Object.assign({ open: true, closable: true, onClose: onCancel, size: Modal.Sizes.S, title: title, footer: _jsxs(ButtonGroup, { children: [_jsx(Button, Object.assign({ onClick: onCancel }, { children: "Cancel" }), void 0), _jsx(Button, Object.assign({ negative: true, onClick: onDecline }, { children: "No" }), void 0), _jsx(Button, Object.assign({ primary: true, onClick: onConfirm }, { children: "Yes" }), void 0)] }, void 0), className: classNames(Styles.yesNoConfirmation, !message && Styles.withoutMessage) }, { children: message }), void 0));
|
|
33
7
|
//# sourceMappingURL=yes-no-confirmation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yes-no-confirmation.js","sourceRoot":"","sources":["../../src/confirmation-messages/yes-no-confirmation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"yes-no-confirmation.js","sourceRoot":"","sources":["../../src/confirmation-messages/yes-no-confirmation.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIzE,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,kCAAkC,CAAC;AAE3D,2CAA2C;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAA0B,CAAC,EACrD,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,EAAE,EACZ,SAAS,EACT,SAAS,EACT,QAAQ,GACX,EAAE,EAAE,CAAC,CACF,KAAC,KAAK,kBACF,IAAI,QACJ,QAAQ,QACR,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EACnB,KAAK,EAAE,KAAK,EACZ,MAAM,EACF,MAAC,WAAW,eACR,KAAC,MAAM,kBAAC,OAAO,EAAE,QAAQ,oCAAiB,EAC1C,KAAC,MAAM,kBAAC,QAAQ,QAAC,OAAO,EAAE,SAAS,gCAE1B,EACT,KAAC,MAAM,kBAAC,OAAO,QAAC,OAAO,EAAE,SAAS,iCAEzB,YACC,EAElB,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,OAAO,IAAI,MAAM,CAAC,cAAc,CAAC,gBAEjF,OAAO,YACJ,CACX,CAAC"}
|
package/dist/demo/basic.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
6
|
-
const __1 = require("..");
|
|
7
|
-
const BasicExample = () => {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@servicetitan/design-system';
|
|
3
|
+
import { Confirm } from '..';
|
|
4
|
+
export const BasicExample = () => {
|
|
8
5
|
const handleConfirm = () => alert('Confirmed');
|
|
9
|
-
return ((
|
|
6
|
+
return (_jsx(Confirm, Object.assign({ onConfirm: handleConfirm }, { children: onClick => _jsx(Button, Object.assign({ onClick: onClick }, { children: "Do Something" }), void 0) }), void 0));
|
|
10
7
|
};
|
|
11
|
-
exports.BasicExample = BasicExample;
|
|
12
8
|
//# sourceMappingURL=basic.js.map
|
package/dist/demo/basic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../src/demo/basic.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../src/demo/basic.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,CAAC,MAAM,YAAY,GAAO,GAAG,EAAE;IACjC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE/C,OAAO,CACH,KAAC,OAAO,kBAAC,SAAS,EAAE,aAAa,gBAC5B,OAAO,CAAC,EAAE,CAAC,KAAC,MAAM,kBAAC,OAAO,EAAE,OAAO,0CAAuB,YACrD,CACb,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
6
|
-
const __1 = require("..");
|
|
7
|
-
const ConfigurableExample = () => {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@servicetitan/design-system';
|
|
3
|
+
import { Confirm } from '..';
|
|
4
|
+
export const ConfigurableExample = () => {
|
|
8
5
|
const handleConfirm = () => alert('Confirmed');
|
|
9
|
-
return ((
|
|
6
|
+
return (_jsx(Confirm, Object.assign({ negative: false, title: "You have unsaved changes", message: "Leave anyways?", onConfirm: handleConfirm }, { children: onClick => _jsx(Button, Object.assign({ onClick: onClick }, { children: "Do Something" }), void 0) }), void 0));
|
|
10
7
|
};
|
|
11
|
-
exports.ConfigurableExample = ConfigurableExample;
|
|
12
8
|
//# sourceMappingURL=configurable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurable.js","sourceRoot":"","sources":["../../src/demo/configurable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configurable.js","sourceRoot":"","sources":["../../src/demo/configurable.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,CAAC,MAAM,mBAAmB,GAAO,GAAG,EAAE;IACxC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE/C,OAAO,CACH,KAAC,OAAO,kBACJ,QAAQ,EAAE,KAAK,EACf,KAAK,EAAC,0BAA0B,EAChC,OAAO,EAAC,gBAAgB,EACxB,SAAS,EAAE,aAAa,gBAEvB,OAAO,CAAC,EAAE,CAAC,KAAC,MAAM,kBAAC,OAAO,EAAE,OAAO,0CAAuB,YACrD,CACb,CAAC;AACN,CAAC,CAAC"}
|
package/dist/demo/custom.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
6
|
-
const __1 = require("..");
|
|
7
|
-
const CustomExample = () => {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal, ButtonGroup, Button, Text } from '@servicetitan/design-system';
|
|
3
|
+
import { Confirm } from '..';
|
|
4
|
+
export const CustomExample = () => {
|
|
8
5
|
const handleConfirm = () => alert('Confirmed');
|
|
9
6
|
const handleDecline = () => alert('Declined');
|
|
10
|
-
return ((
|
|
7
|
+
return (_jsx(Confirm, Object.assign({ title: "Builder will be closed", message: "Do you want to save your changes?", details: "(Your progress will be removed permanently)", onConfirm: handleConfirm, onDecline: handleDecline, confirmation: CustomConfirmation }, { children: onClick => _jsx(Button, Object.assign({ onClick: onClick }, { children: "Do Something" }), void 0) }), void 0));
|
|
11
8
|
};
|
|
12
|
-
|
|
13
|
-
const CustomConfirmation = ({ title, message, details, onConfirm, onDecline, onCancel, }) => ((0, jsx_runtime_1.jsxs)(design_system_1.Modal, Object.assign({ open: true, closable: true, onClose: onCancel, size: design_system_1.Modal.Sizes.S, title: title, footer: (0, jsx_runtime_1.jsxs)(design_system_1.ButtonGroup, { children: [(0, jsx_runtime_1.jsx)(design_system_1.Button, Object.assign({ outline: true, onClick: onCancel }, { children: "Continue working" }), void 0), (0, jsx_runtime_1.jsx)(design_system_1.Button, Object.assign({ outline: true, negative: true, onClick: onDecline }, { children: "No, thanks" }), void 0), (0, jsx_runtime_1.jsx)(design_system_1.Button, Object.assign({ outline: true, primary: true, onClick: onConfirm }, { children: "Sure, let's do it" }), void 0)] }, void 0) }, { children: [(0, jsx_runtime_1.jsx)(design_system_1.Text, Object.assign({ size: 3 }, { children: message }), void 0), (0, jsx_runtime_1.jsx)(design_system_1.Text, Object.assign({ size: 2, subdued: true }, { children: details }), void 0)] }), void 0));
|
|
9
|
+
const CustomConfirmation = ({ title, message, details, onConfirm, onDecline, onCancel, }) => (_jsxs(Modal, Object.assign({ open: true, closable: true, onClose: onCancel, size: Modal.Sizes.S, title: title, footer: _jsxs(ButtonGroup, { children: [_jsx(Button, Object.assign({ outline: true, onClick: onCancel }, { children: "Continue working" }), void 0), _jsx(Button, Object.assign({ outline: true, negative: true, onClick: onDecline }, { children: "No, thanks" }), void 0), _jsx(Button, Object.assign({ outline: true, primary: true, onClick: onConfirm }, { children: "Sure, let's do it" }), void 0)] }, void 0) }, { children: [_jsx(Text, Object.assign({ size: 3 }, { children: message }), void 0), _jsx(Text, Object.assign({ size: 2, subdued: true }, { children: details }), void 0)] }), void 0));
|
|
14
10
|
//# sourceMappingURL=custom.js.map
|
package/dist/demo/custom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/demo/custom.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/demo/custom.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAqB,MAAM,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAO,GAA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|
|
6
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
7
|
-
const __1 = require("..");
|
|
8
|
-
const HookExample = () => {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { Button } from '@servicetitan/design-system';
|
|
4
|
+
import { useConfirm } from '..';
|
|
5
|
+
export const HookExample = () => {
|
|
9
6
|
const handleConfirm = () => alert('Confirmed');
|
|
10
|
-
const [HookConfirm, hookHandler] =
|
|
11
|
-
return ((
|
|
7
|
+
const [HookConfirm, hookHandler] = useConfirm(handleConfirm);
|
|
8
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, Object.assign({ onClick: hookHandler }, { children: "Do Something" }), void 0), _jsx(HookConfirm, {}, void 0)] }, void 0));
|
|
12
9
|
};
|
|
13
|
-
exports.HookExample = HookExample;
|
|
14
10
|
//# sourceMappingURL=hook.js.map
|
package/dist/demo/hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/demo/hook.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/demo/hook.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAM,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAO,GAAG,EAAE;IAChC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE/C,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAE7D,OAAO,CACH,MAAC,QAAQ,eACL,KAAC,MAAM,kBAAC,OAAO,EAAE,WAAW,0CAAuB,EACnD,KAAC,WAAW,aAAG,YACR,CACd,CAAC;AACN,CAAC,CAAC"}
|
package/dist/demo/index.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./basic"), exports);
|
|
14
|
-
__exportStar(require("./configurable"), exports);
|
|
15
|
-
__exportStar(require("./custom"), exports);
|
|
16
|
-
__exportStar(require("./hook"), exports);
|
|
17
|
-
__exportStar(require("./toggleable"), exports);
|
|
18
|
-
__exportStar(require("./yes-no"), exports);
|
|
1
|
+
export * from './basic';
|
|
2
|
+
export * from './configurable';
|
|
3
|
+
export * from './custom';
|
|
4
|
+
export * from './hook';
|
|
5
|
+
export * from './toggleable';
|
|
6
|
+
export * from './yes-no';
|
|
19
7
|
//# sourceMappingURL=index.js.map
|
package/dist/demo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/demo/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/demo/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
package/dist/demo/toggleable.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const __1 = require("..");
|
|
8
|
-
const ToggleableExample = () => {
|
|
9
|
-
const [confirmEnabled, setConfirmEnabled] = (0, react_1.useState)(true);
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Stack, Button, Checkbox } from '@servicetitan/design-system';
|
|
4
|
+
import { Confirm } from '..';
|
|
5
|
+
export const ToggleableExample = () => {
|
|
6
|
+
const [confirmEnabled, setConfirmEnabled] = useState(true);
|
|
10
7
|
const handleConfirm = () => alert('Confirmed');
|
|
11
8
|
const handleChangeConfirmEnabled = (_0, checked) => {
|
|
12
9
|
setConfirmEnabled(checked);
|
|
13
10
|
};
|
|
14
|
-
return ((
|
|
11
|
+
return (_jsxs(Stack, Object.assign({ alignItems: "center" }, { children: [_jsx(Confirm, Object.assign({ when: confirmEnabled, onConfirm: handleConfirm }, { children: onClick => _jsx(Button, Object.assign({ onClick: onClick }, { children: "Do Something" }), void 0) }), void 0), _jsx(Checkbox, { label: "Enable confirmation?", checked: confirmEnabled, onChange: handleChangeConfirmEnabled, className: "m-l-4" }, void 0)] }), void 0));
|
|
15
12
|
};
|
|
16
|
-
exports.ToggleableExample = ToggleableExample;
|
|
17
13
|
//# sourceMappingURL=toggleable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggleable.js","sourceRoot":"","sources":["../../src/demo/toggleable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggleable.js","sourceRoot":"","sources":["../../src/demo/toggleable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAM,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,MAAM,CAAC,MAAM,iBAAiB,GAAO,GAAG,EAAE;IACtC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE3D,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE/C,MAAM,0BAA0B,GAAG,CAAC,EAAS,EAAE,OAAgB,EAAE,EAAE;QAC/D,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,OAAO,CACH,MAAC,KAAK,kBAAC,UAAU,EAAC,QAAQ,iBACtB,KAAC,OAAO,kBAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,gBAClD,OAAO,CAAC,EAAE,CAAC,KAAC,MAAM,kBAAC,OAAO,EAAE,OAAO,0CAAuB,YACrD,EAEV,KAAC,QAAQ,IACL,KAAK,EAAC,sBAAsB,EAC5B,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,0BAA0B,EACpC,SAAS,EAAC,OAAO,WACnB,aACE,CACX,CAAC;AACN,CAAC,CAAC"}
|
package/dist/demo/yes-no.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const design_system_1 = require("@servicetitan/design-system");
|
|
6
|
-
const __1 = require("..");
|
|
7
|
-
const YesNoExample = () => {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@servicetitan/design-system';
|
|
3
|
+
import { Confirm, YesNoConfirmation } from '..';
|
|
4
|
+
export const YesNoExample = () => {
|
|
8
5
|
const handleConfirm = () => alert('Confirmed');
|
|
9
6
|
const handleDecline = () => alert('Declined');
|
|
10
|
-
return ((
|
|
7
|
+
return (_jsx(Confirm, Object.assign({ title: "Save current progress?", onConfirm: handleConfirm, onDecline: handleDecline, confirmation: YesNoConfirmation }, { children: onClick => _jsx(Button, Object.assign({ onClick: onClick }, { children: "Do Something" }), void 0) }), void 0));
|
|
11
8
|
};
|
|
12
|
-
exports.YesNoExample = YesNoExample;
|
|
13
9
|
//# sourceMappingURL=yes-no.js.map
|
package/dist/demo/yes-no.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yes-no.js","sourceRoot":"","sources":["../../src/demo/yes-no.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"yes-no.js","sourceRoot":"","sources":["../../src/demo/yes-no.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAO,GAAG,EAAE;IACjC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAE9C,OAAO,CACH,KAAC,OAAO,kBACJ,KAAK,EAAC,wBAAwB,EAC9B,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,aAAa,EACxB,YAAY,EAAE,iBAAiB,gBAE9B,OAAO,CAAC,EAAE,CAAC,KAAC,MAAM,kBAAC,OAAO,EAAE,OAAO,0CAAuB,YACrD,CACb,CAAC;AACN,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var use_confirm_1 = require("./use-confirm");
|
|
5
|
-
Object.defineProperty(exports, "useConfirm", { enumerable: true, get: function () { return use_confirm_1.useConfirm; } });
|
|
6
|
-
var confirm_1 = require("./confirm");
|
|
7
|
-
Object.defineProperty(exports, "Confirm", { enumerable: true, get: function () { return confirm_1.Confirm; } });
|
|
8
|
-
var yes_no_confirmation_1 = require("./confirmation-messages/yes-no-confirmation");
|
|
9
|
-
Object.defineProperty(exports, "YesNoConfirmation", { enumerable: true, get: function () { return yes_no_confirmation_1.YesNoConfirmation; } });
|
|
1
|
+
export { useConfirm } from './use-confirm';
|
|
2
|
+
export { Confirm } from './confirm';
|
|
3
|
+
export { YesNoConfirmation } from './confirmation-messages/yes-no-confirmation';
|
|
10
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC"}
|
package/dist/use-confirm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,14 +18,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
18
|
}
|
|
20
19
|
return t;
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const [defer, setDefer] = (0, react_1.useState)(undefined);
|
|
29
|
-
const handler = (0, react_1.useCallback)((...args) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
23
|
+
import { DefaultConfirmation, } from './confirmation-messages/default-confirmation';
|
|
24
|
+
export function useConfirm(onConfirm, onDecline) {
|
|
25
|
+
const [defer, setDefer] = useState(undefined);
|
|
26
|
+
const handler = useCallback((...args) => __awaiter(this, void 0, void 0, function* () {
|
|
30
27
|
let isConfirmed;
|
|
31
28
|
try {
|
|
32
29
|
isConfirmed = yield new Promise((resolve, reject) => {
|
|
@@ -50,8 +47,8 @@ function useConfirm(onConfirm, onDecline) {
|
|
|
50
47
|
onDecline(...args);
|
|
51
48
|
}
|
|
52
49
|
}), [onConfirm, onDecline]);
|
|
53
|
-
const Confirm =
|
|
54
|
-
var { when = true, confirmation: Confirmation =
|
|
50
|
+
const Confirm = useMemo(() => (_a) => {
|
|
51
|
+
var { when = true, confirmation: Confirmation = DefaultConfirmation } = _a, props = __rest(_a, ["when", "confirmation"]);
|
|
55
52
|
if (!defer) {
|
|
56
53
|
return null;
|
|
57
54
|
}
|
|
@@ -59,9 +56,8 @@ function useConfirm(onConfirm, onDecline) {
|
|
|
59
56
|
defer.confirm();
|
|
60
57
|
return null;
|
|
61
58
|
}
|
|
62
|
-
return ((
|
|
59
|
+
return (_jsx(Confirmation, Object.assign({}, props, { onConfirm: defer.confirm, onDecline: defer.decline, onCancel: defer.cancel }), void 0));
|
|
63
60
|
}, [defer]);
|
|
64
61
|
return [Confirm, handler];
|
|
65
62
|
}
|
|
66
|
-
exports.useConfirm = useConfirm;
|
|
67
63
|
//# sourceMappingURL=use-confirm.js.map
|
package/dist/use-confirm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-confirm.js","sourceRoot":"","sources":["../src/use-confirm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-confirm.js","sourceRoot":"","sources":["../src/use-confirm.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAiB,MAAM,OAAO,CAAC;AAEtE,OAAO,EACH,mBAAmB,GAEtB,MAAM,8CAA8C,CAAC;AAqBtD,MAAM,UAAU,UAAU,CAAoC,SAAY,EAAE,SAAa;IACrF,MAAM,CAAC,KA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ACxB,CACL,CAAC;IACN,CAAC,EACL,CAAC,KAAK,CAAC,CACV,CAAC;IAEF,OAAO,CAAC,OAAO,EAAE,OAAO,CAAwB,CAAC;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/confirm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/confirm",
|
|
6
6
|
"repository": {
|
|
@@ -10,17 +10,18 @@
|
|
|
10
10
|
},
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
12
|
"typings": "./dist/index.d.ts",
|
|
13
|
+
"sideEffects": false,
|
|
13
14
|
"files": [
|
|
14
15
|
"dist",
|
|
15
16
|
"src"
|
|
16
17
|
],
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@servicetitan/design-system": "~
|
|
19
|
-
"@types/react": "~17.0.
|
|
19
|
+
"@servicetitan/design-system": "~11.1.0",
|
|
20
|
+
"@types/react": "~17.0.38",
|
|
20
21
|
"react": "~17.0.2"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
|
-
"@servicetitan/design-system": "~
|
|
24
|
+
"@servicetitan/design-system": "~11.1.0",
|
|
24
25
|
"react": "~17.0.2"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"cli": {
|
|
33
34
|
"webpack": false
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f4af5745b847bb20eeaffe74e5db6f3b8621ae55"
|
|
36
37
|
}
|