@taiv/ui 1.0.1 → 1.0.2
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/components/Info/Modals/Modal.d.ts.map +1 -1
- package/dist/components/Info/Modals/Modal.js +1 -0
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -5
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/useConfirmationModal.d.ts +18 -0
- package/dist/hooks/useConfirmationModal.d.ts.map +1 -0
- package/dist/hooks/useConfirmationModal.js +76 -0
- package/dist/hooks/useCopy.d.ts +10 -0
- package/dist/hooks/useCopy.d.ts.map +1 -0
- package/dist/hooks/useCopy.js +18 -0
- package/dist/hooks/useInfoModal.d.ts +15 -0
- package/dist/hooks/useInfoModal.d.ts.map +1 -0
- package/dist/hooks/useInfoModal.js +70 -0
- package/dist/hooks/useMediaQuery.d.ts +3 -0
- package/dist/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/hooks/useMediaQuery.js +2 -0
- package/dist/hooks/useNotifications.d.ts +16 -0
- package/dist/hooks/useNotifications.d.ts.map +1 -0
- package/dist/hooks/useNotifications.js +41 -0
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Modals/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,UAAU,UAAU;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Modals/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,UAAU,UAAU;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAGD,eAAO,MAAM,KAAK,GAAI,6DAAuE,UAAU,4CAoEtG,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { neutral } from '../../../constants/colors';
|
|
|
4
4
|
import { Title } from '../../Typography/Title';
|
|
5
5
|
import { Stack } from '../../Layout/Stack';
|
|
6
6
|
import { Center } from '../../Layout/Center';
|
|
7
|
+
// Base modal is intended to be extended and customized - use InfoModal or ConfirmationModal for common use cases
|
|
7
8
|
export const Modal = ({ opened, onClose, icon, title, subtitle, children, width = '40rem' }) => {
|
|
8
9
|
return (_jsx(MantineModal, { opened: opened, onClose: onClose, centered: true, radius: '16px', overlayProps: {
|
|
9
10
|
opacity: 0,
|
|
@@ -2,10 +2,7 @@ export { CheckboxTable } from "./Data/CheckboxTable";
|
|
|
2
2
|
export { RemovableItemList } from "./Data/RemovableItemList";
|
|
3
3
|
export { ModalProvider } from "./Info/Modals/ModalProvider";
|
|
4
4
|
export { Modal } from "./Info/Modals/Modal";
|
|
5
|
-
export { useConfirmationModal } from "./Info/Modals/ConfirmationModal";
|
|
6
|
-
export { useInfoModal } from "./Info/Modals/InfoModal";
|
|
7
5
|
export { NotificationProvider } from "./Info/Notifications/NotificationProvider";
|
|
8
|
-
export { useNotifications } from "./Info/Notifications/Notifications";
|
|
9
6
|
export { InfoTooltip } from "./Info/Tooltips/InfoTooltip";
|
|
10
7
|
export { Tooltip } from "./Info/Tooltips/Tooltip";
|
|
11
8
|
export { AutoComplete } from "./Inputs/TextInputs/AutoComplete";
|
|
@@ -33,6 +30,4 @@ export { CollapsibleText } from "./Typography/CollapsibleText";
|
|
|
33
30
|
export { Text } from "./Typography/Text";
|
|
34
31
|
export { Title } from "./Typography/Title";
|
|
35
32
|
export { Transition } from "./Misc/Transition";
|
|
36
|
-
export { useCopy } from "./Misc/Copy";
|
|
37
|
-
export { useMediaQuery } from "./Misc/MediaQuery";
|
|
38
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -4,10 +4,7 @@ export { RemovableItemList } from "./Data/RemovableItemList";
|
|
|
4
4
|
//Info
|
|
5
5
|
export { ModalProvider } from "./Info/Modals/ModalProvider";
|
|
6
6
|
export { Modal } from "./Info/Modals/Modal";
|
|
7
|
-
export { useConfirmationModal } from "./Info/Modals/ConfirmationModal";
|
|
8
|
-
export { useInfoModal } from "./Info/Modals/InfoModal";
|
|
9
7
|
export { NotificationProvider } from "./Info/Notifications/NotificationProvider";
|
|
10
|
-
export { useNotifications } from "./Info/Notifications/Notifications";
|
|
11
8
|
export { InfoTooltip } from "./Info/Tooltips/InfoTooltip";
|
|
12
9
|
export { Tooltip } from "./Info/Tooltips/Tooltip";
|
|
13
10
|
//Inputs
|
|
@@ -39,5 +36,3 @@ export { Text } from "./Typography/Text";
|
|
|
39
36
|
export { Title } from "./Typography/Title";
|
|
40
37
|
//Misc
|
|
41
38
|
export { Transition } from "./Misc/Transition";
|
|
42
|
-
export { useCopy } from "./Misc/Copy";
|
|
43
|
-
export { useMediaQuery } from "./Misc/MediaQuery";
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { useCopy } from '
|
|
2
|
-
export { useMediaQuery } from '
|
|
3
|
-
export { useNotifications } from '
|
|
4
|
-
export { useConfirmationModal } from '
|
|
5
|
-
export { useInfoModal } from '
|
|
1
|
+
export { useCopy } from './useCopy';
|
|
2
|
+
export { useMediaQuery } from './useMediaQuery';
|
|
3
|
+
export { useNotifications } from './useNotifications';
|
|
4
|
+
export { useConfirmationModal } from './useConfirmationModal';
|
|
5
|
+
export { useInfoModal } from './useInfoModal';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useCopy } from '
|
|
2
|
-
export { useMediaQuery } from '
|
|
3
|
-
export { useNotifications } from '
|
|
4
|
-
export { useConfirmationModal } from '
|
|
5
|
-
export { useInfoModal } from '
|
|
1
|
+
export { useCopy } from './useCopy';
|
|
2
|
+
export { useMediaQuery } from './useMediaQuery';
|
|
3
|
+
export { useNotifications } from './useNotifications';
|
|
4
|
+
export { useConfirmationModal } from './useConfirmationModal';
|
|
5
|
+
export { useInfoModal } from './useInfoModal';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { modalVariants } from '../components/Info/Modals/variants';
|
|
3
|
+
export declare const useConfirmationModal: () => {
|
|
4
|
+
show: (options: {
|
|
5
|
+
variant?: Exclude<keyof typeof modalVariants, "error">;
|
|
6
|
+
title?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
cancelLabel?: string;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
onConfirm?: () => void;
|
|
12
|
+
onCancel?: () => void;
|
|
13
|
+
size?: string | number;
|
|
14
|
+
}) => void;
|
|
15
|
+
close: (modalId: string) => void;
|
|
16
|
+
closeAll: () => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useConfirmationModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConfirmationModal.d.ts","sourceRoot":"","sources":["../../src/hooks/useConfirmationModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAInE,eAAO,MAAM,oBAAoB;oBACR;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,OAAO,aAAa,EAAE,OAAO,CAAC,CAAC;QACvD,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB;qBAkGuB,MAAM;;CAa/B,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { modals } from '@mantine/modals';
|
|
3
|
+
import { neutral } from '../constants/colors';
|
|
4
|
+
import { Title } from '../components/Typography/Title';
|
|
5
|
+
import { Stack } from '../components/Layout/Stack';
|
|
6
|
+
import { Center } from '../components/Layout/Center';
|
|
7
|
+
import { modalVariants } from '../components/Info/Modals/variants';
|
|
8
|
+
import { Button } from '../components/Inputs/Buttons/Button';
|
|
9
|
+
import { Group } from '../components/Layout/Group';
|
|
10
|
+
export const useConfirmationModal = () => {
|
|
11
|
+
const show = (options) => {
|
|
12
|
+
const { variant = 'confirm', title, message, confirmLabel, cancelLabel, icon, onConfirm, onCancel, size = '40rem', } = options;
|
|
13
|
+
const handleConfirm = () => {
|
|
14
|
+
if (onConfirm)
|
|
15
|
+
onConfirm();
|
|
16
|
+
modals.closeAll();
|
|
17
|
+
};
|
|
18
|
+
const handleCancel = () => {
|
|
19
|
+
if (onCancel)
|
|
20
|
+
onCancel();
|
|
21
|
+
modals.closeAll();
|
|
22
|
+
};
|
|
23
|
+
const selectedVariant = modalVariants[variant];
|
|
24
|
+
const iconContainer = {
|
|
25
|
+
width: '4.2rem',
|
|
26
|
+
height: '4.2rem',
|
|
27
|
+
borderRadius: '50%',
|
|
28
|
+
backgroundColor: selectedVariant.iconBackgroundColor,
|
|
29
|
+
border: `2px solid ${selectedVariant.iconColor}`,
|
|
30
|
+
};
|
|
31
|
+
const modalIcon = icon || (_jsx("i", { className: selectedVariant.icon, style: { color: selectedVariant.iconColor, fontSize: '2rem' } }));
|
|
32
|
+
const ConfirmModalContent = () => {
|
|
33
|
+
return (_jsx(Center, { h: "100%", w: "100%", children: _jsxs(Stack, { gap: "2rem", h: "100%", w: "100%", align: "center", children: [_jsxs(Stack, { gap: "1.5rem", align: "center", children: [_jsx(Center, { style: iconContainer, children: modalIcon }), _jsxs(Stack, { gap: "0.25rem", align: "center", children: [_jsx(Title, { variant: "cardHeader", align: "center", children: title || selectedVariant.title }), _jsx(Title, { variant: "cardSubheader", align: "center", children: message || selectedVariant.message })] })] }), _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Group, { gap: "1rem", align: "center", children: [_jsx(Button, { onClick: handleCancel, variant: "secondary", children: cancelLabel || selectedVariant.cancelLabel }), _jsx(Button, { onClick: handleConfirm, variant: selectedVariant.buttonVariant, children: confirmLabel || selectedVariant.confirmLabel })] }) })] }) }));
|
|
34
|
+
};
|
|
35
|
+
modals.open({
|
|
36
|
+
children: _jsx(ConfirmModalContent, {}),
|
|
37
|
+
size,
|
|
38
|
+
styles: {
|
|
39
|
+
content: {
|
|
40
|
+
borderRadius: '8px',
|
|
41
|
+
border: `1px solid ${neutral[50]}`,
|
|
42
|
+
boxShadow: '0px 0px 19px 0px #00000040',
|
|
43
|
+
},
|
|
44
|
+
header: {
|
|
45
|
+
padding: '0.8rem',
|
|
46
|
+
},
|
|
47
|
+
close: {
|
|
48
|
+
borderRadius: '16px',
|
|
49
|
+
backgroundColor: neutral[50],
|
|
50
|
+
width: '1.8rem',
|
|
51
|
+
height: '1.8rem',
|
|
52
|
+
'&:hover': {
|
|
53
|
+
backgroundColor: neutral[50],
|
|
54
|
+
},
|
|
55
|
+
'&:active': {
|
|
56
|
+
transform: 'none',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
body: {
|
|
60
|
+
padding: '0 3.2rem 1.6rem 3.2rem',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const close = (modalId) => {
|
|
66
|
+
modals.close(modalId);
|
|
67
|
+
};
|
|
68
|
+
const closeAll = () => {
|
|
69
|
+
modals.closeAll();
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
show,
|
|
73
|
+
close,
|
|
74
|
+
closeAll,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopy.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO;oBAIK;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B;CAmBF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useClipboard } from '@mantine/hooks';
|
|
2
|
+
import { useNotifications } from './useNotifications';
|
|
3
|
+
export const useCopy = () => {
|
|
4
|
+
const clipboard = useClipboard();
|
|
5
|
+
const notifications = useNotifications();
|
|
6
|
+
const copy = (options) => {
|
|
7
|
+
const { onCopy, showNotification = true, notificationMessage = `${options.label ? `${options.label}: ` : ''}${options.value}`, } = options || {};
|
|
8
|
+
clipboard.copy(options.value);
|
|
9
|
+
onCopy === null || onCopy === void 0 ? void 0 : onCopy(options.value);
|
|
10
|
+
if (showNotification) {
|
|
11
|
+
notifications.show({
|
|
12
|
+
message: notificationMessage,
|
|
13
|
+
variant: 'copy',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return { copy };
|
|
18
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { modalVariants } from '../components/Info/Modals/variants';
|
|
3
|
+
export declare const useInfoModal: () => {
|
|
4
|
+
show: (options: {
|
|
5
|
+
variant?: keyof typeof modalVariants;
|
|
6
|
+
title?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
onConfirm?: () => void;
|
|
10
|
+
size?: string | number;
|
|
11
|
+
}) => void;
|
|
12
|
+
close: (modalId: string) => void;
|
|
13
|
+
closeAll: () => void;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useInfoModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfoModal.d.ts","sourceRoot":"","sources":["../../src/hooks/useInfoModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAGnE,eAAO,MAAM,YAAY;oBACA;QACrB,OAAO,CAAC,EAAE,MAAM,OAAO,aAAa,CAAC;QACrC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB;qBA8EuB,MAAM;;CAa/B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { modals } from '@mantine/modals';
|
|
3
|
+
import { neutral } from '../constants/colors';
|
|
4
|
+
import { Title } from '../components/Typography/Title';
|
|
5
|
+
import { Stack } from '../components/Layout/Stack';
|
|
6
|
+
import { Center } from '../components/Layout/Center';
|
|
7
|
+
import { modalVariants } from '../components/Info/Modals/variants';
|
|
8
|
+
import { Button } from '../components/Inputs/Buttons/Button';
|
|
9
|
+
export const useInfoModal = () => {
|
|
10
|
+
const show = (options) => {
|
|
11
|
+
const { variant = 'info', title, message, icon, onConfirm, size = '35rem' } = options;
|
|
12
|
+
const handleConfirm = () => {
|
|
13
|
+
if (onConfirm)
|
|
14
|
+
onConfirm();
|
|
15
|
+
modals.closeAll();
|
|
16
|
+
};
|
|
17
|
+
const selectedVariant = modalVariants[variant];
|
|
18
|
+
const iconContainer = {
|
|
19
|
+
width: '4.2rem',
|
|
20
|
+
height: '4.2rem',
|
|
21
|
+
borderRadius: '50%',
|
|
22
|
+
backgroundColor: selectedVariant.iconBackgroundColor,
|
|
23
|
+
border: `2px solid ${selectedVariant.iconColor}`,
|
|
24
|
+
};
|
|
25
|
+
const modalIcon = icon || (_jsx("i", { className: selectedVariant.icon, style: { color: selectedVariant.iconColor, fontSize: '2rem' } }));
|
|
26
|
+
const InfoModalContent = () => {
|
|
27
|
+
return (_jsx(Center, { h: "100%", w: "100%", children: _jsxs(Stack, { gap: "2rem", h: "100%", w: "100%", align: "center", children: [_jsxs(Stack, { gap: "1.5rem", align: "center", children: [_jsx(Center, { style: iconContainer, children: modalIcon }), _jsxs(Stack, { gap: "0.25rem", align: "center", children: [_jsx(Title, { variant: "cardHeader", align: "center", children: title || selectedVariant.title }), _jsx(Title, { variant: "cardSubheader", align: "center", children: message || selectedVariant.message })] })] }), _jsx(Center, { h: "100%", w: "100%", children: _jsx(Button, { onClick: handleConfirm, variant: selectedVariant.buttonVariant, children: "OK" }) })] }) }));
|
|
28
|
+
};
|
|
29
|
+
modals.open({
|
|
30
|
+
children: _jsx(InfoModalContent, {}),
|
|
31
|
+
size,
|
|
32
|
+
styles: {
|
|
33
|
+
content: {
|
|
34
|
+
borderRadius: '8px',
|
|
35
|
+
border: `1px solid ${neutral[50]}`,
|
|
36
|
+
boxShadow: '0px 0px 19px 0px #00000040',
|
|
37
|
+
},
|
|
38
|
+
header: {
|
|
39
|
+
padding: '0.8rem',
|
|
40
|
+
},
|
|
41
|
+
close: {
|
|
42
|
+
borderRadius: '16px',
|
|
43
|
+
backgroundColor: neutral[50],
|
|
44
|
+
width: '1.8rem',
|
|
45
|
+
height: '1.8rem',
|
|
46
|
+
'&:hover': {
|
|
47
|
+
backgroundColor: neutral[50],
|
|
48
|
+
},
|
|
49
|
+
'&:active': {
|
|
50
|
+
transform: 'none',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
body: {
|
|
54
|
+
padding: '0 3.2rem 1.6rem 3.2rem',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const close = (modalId) => {
|
|
60
|
+
modals.close(modalId);
|
|
61
|
+
};
|
|
62
|
+
const closeAll = () => {
|
|
63
|
+
modals.closeAll();
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
show,
|
|
67
|
+
close,
|
|
68
|
+
closeAll,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaQuery.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,eAAO,MAAM,aAAa,6BAAuB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { componentVariants } from '../components/Info/Notifications/variants';
|
|
2
|
+
export declare const useNotifications: () => {
|
|
3
|
+
show: (options: {
|
|
4
|
+
variant?: keyof typeof componentVariants;
|
|
5
|
+
message: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
}) => void;
|
|
9
|
+
showError: () => void;
|
|
10
|
+
showLoading: (options: {
|
|
11
|
+
message: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
}) => string;
|
|
14
|
+
hide: (id: string) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useNotifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotifications.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E,eAAO,MAAM,gBAAgB;oBAMJ;QACrB,OAAO,CAAC,EAAE,MAAM,OAAO,iBAAiB,CAAC;QACzC,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,EAAE,CAAC,EAAE,MAAM,CAAC;KACb;;2BAmB6B;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;eA7BzC,MAAM;CAiD/B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { notifications as mantineNotifications } from '@mantine/notifications';
|
|
2
|
+
import { componentVariants } from '../components/Info/Notifications/variants';
|
|
3
|
+
export const useNotifications = () => {
|
|
4
|
+
const hide = async (id) => {
|
|
5
|
+
mantineNotifications.hide(id);
|
|
6
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
7
|
+
};
|
|
8
|
+
const show = (options) => {
|
|
9
|
+
const { variant = 'info', message, title, id } = options;
|
|
10
|
+
const selectedVariant = componentVariants[variant];
|
|
11
|
+
mantineNotifications.show({
|
|
12
|
+
title: title || selectedVariant.defaultTitle,
|
|
13
|
+
message,
|
|
14
|
+
icon: selectedVariant.icon,
|
|
15
|
+
autoClose: selectedVariant.autoClose,
|
|
16
|
+
id,
|
|
17
|
+
styles: {
|
|
18
|
+
root: {
|
|
19
|
+
borderLeft: `4px solid ${selectedVariant.color}`,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const showLoading = (options) => {
|
|
25
|
+
const notificationId = `${Math.random()}-${Math.random()}`;
|
|
26
|
+
show({
|
|
27
|
+
id: notificationId,
|
|
28
|
+
message: options.message,
|
|
29
|
+
title: options.title,
|
|
30
|
+
variant: 'loading',
|
|
31
|
+
});
|
|
32
|
+
return notificationId;
|
|
33
|
+
};
|
|
34
|
+
const showError = () => {
|
|
35
|
+
show({
|
|
36
|
+
variant: 'error',
|
|
37
|
+
message: 'An error has occurred. Please try again. If the issue persists, please contact us at support@taiv.tv',
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return { show, showError, showLoading, hide };
|
|
41
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiv/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"author": "Taiv",
|
|
5
5
|
"description": "Taiv's web UI Toolkit built on Mantine v6",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"typescript": "^5.0.2"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
|
-
".": "./dist/index.js",
|
|
34
|
-
"./core": "./dist/components/index.js",
|
|
33
|
+
".": "./dist/components/index.js",
|
|
35
34
|
"./hooks": "./dist/hooks/index.js",
|
|
36
35
|
"./constants": "./dist/constants/index.js"
|
|
37
36
|
}
|