@trackunit/react-compound-components 0.0.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.
Files changed (45) hide show
  1. package/README.md +26 -0
  2. package/index.cjs.d.ts +1 -0
  3. package/index.cjs.js +172 -0
  4. package/index.esm.js +149 -0
  5. package/package.json +19 -0
  6. package/src/ConfirmationDialog/ConfirmationDialogContextProvider.d.ts +8 -0
  7. package/src/ConfirmationDialog/ConfirmationDialogModal.d.ts +13 -0
  8. package/src/ConfirmationDialog/useConfirmationDialog.demo.d.ts +41 -0
  9. package/src/ConfirmationDialog/useConfirmationDialog.stories.d.ts +8 -0
  10. package/src/index.d.ts +1 -0
  11. package/src/translation.d.ts +34 -0
  12. package/translation.cjs.js +7 -0
  13. package/translation.cjs10.js +7 -0
  14. package/translation.cjs11.js +7 -0
  15. package/translation.cjs12.js +7 -0
  16. package/translation.cjs13.js +7 -0
  17. package/translation.cjs14.js +7 -0
  18. package/translation.cjs15.js +7 -0
  19. package/translation.cjs16.js +7 -0
  20. package/translation.cjs17.js +7 -0
  21. package/translation.cjs2.js +7 -0
  22. package/translation.cjs3.js +7 -0
  23. package/translation.cjs4.js +7 -0
  24. package/translation.cjs5.js +7 -0
  25. package/translation.cjs6.js +7 -0
  26. package/translation.cjs7.js +7 -0
  27. package/translation.cjs8.js +7 -0
  28. package/translation.cjs9.js +7 -0
  29. package/translation.esm.js +5 -0
  30. package/translation.esm10.js +5 -0
  31. package/translation.esm11.js +5 -0
  32. package/translation.esm12.js +5 -0
  33. package/translation.esm13.js +5 -0
  34. package/translation.esm14.js +5 -0
  35. package/translation.esm15.js +5 -0
  36. package/translation.esm16.js +5 -0
  37. package/translation.esm17.js +5 -0
  38. package/translation.esm2.js +5 -0
  39. package/translation.esm3.js +5 -0
  40. package/translation.esm4.js +5 -0
  41. package/translation.esm5.js +5 -0
  42. package/translation.esm6.js +5 -0
  43. package/translation.esm7.js +5 -0
  44. package/translation.esm8.js +5 -0
  45. package/translation.esm9.js +5 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ > **⚠️ Beta**
2
+ >
3
+ > This is a beta version and subject to change without notice.
4
+
5
+ # Trackunit compound-components
6
+
7
+ The `@trackunit/compound-components` package is the home of Trackunit's public components that are a combination of other React components and often include some special concerns to make them fully functional in Iris Apps.
8
+ This could include components like Dialogs, Toasts, Modals, and more...
9
+
10
+ This library is exposed publicly for use in the the Trackunit [Iris App SDK](https://www.npmjs.com/package/@trackunit/iris-app).
11
+
12
+ To browse all avaliable components visit our [Public Storybook](https://apps.iris.trackunit.com/storybook/).
13
+
14
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
15
+
16
+ ## Development
17
+
18
+ At this point this library is only developed by Trackunit Employees.
19
+ For development related information see the [development readme](https://github.com/Trackunit/manager/blob/master/libs/react/components/DEVELOPMENT.md).
20
+
21
+ ## Trackunit
22
+
23
+ This package was developed by Trackunit ApS.
24
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
25
+
26
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,172 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
7
+ var reactCoreHooks = require('@trackunit/react-core-hooks');
8
+ var React = require('react');
9
+ var reactComponents = require('@trackunit/react-components');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n["default"] = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
30
+
31
+ var defaultTranslations = {
32
+ "confirmationDialog.default.message": "Are you certain that you wish to proceed with this course of action?",
33
+ "confirmationDialog.default.primarybutton": "Confirm",
34
+ "confirmationDialog.default.secondarybutton": "Cancel",
35
+ "confirmationDialog.default.title": "Please confirm this action"
36
+ };
37
+
38
+ /** The translation namespace for this library */
39
+ const namespace = "react.compound-components";
40
+ /**
41
+ * The TranslationResource for this Library.
42
+ * Holds lazy loaded imports for all languages supported by the library.
43
+ *
44
+ * This is used to register the translations for this library before initializing i18next.
45
+ */
46
+ const translations = {
47
+ ns: namespace,
48
+ default: defaultTranslations,
49
+ languages: {
50
+ de: () => Promise.resolve().then(function () { return require('./translation.cjs.js'); }),
51
+ da: () => Promise.resolve().then(function () { return require('./translation.cjs2.js'); }),
52
+ cs: () => Promise.resolve().then(function () { return require('./translation.cjs3.js'); }),
53
+ nl: () => Promise.resolve().then(function () { return require('./translation.cjs4.js'); }),
54
+ fr: () => Promise.resolve().then(function () { return require('./translation.cjs5.js'); }),
55
+ fi: () => Promise.resolve().then(function () { return require('./translation.cjs6.js'); }),
56
+ hu: () => Promise.resolve().then(function () { return require('./translation.cjs7.js'); }),
57
+ it: () => Promise.resolve().then(function () { return require('./translation.cjs8.js'); }),
58
+ nb: () => Promise.resolve().then(function () { return require('./translation.cjs9.js'); }),
59
+ pl: () => Promise.resolve().then(function () { return require('./translation.cjs10.js'); }),
60
+ pt: () => Promise.resolve().then(function () { return require('./translation.cjs11.js'); }),
61
+ ru: () => Promise.resolve().then(function () { return require('./translation.cjs12.js'); }),
62
+ ro: () => Promise.resolve().then(function () { return require('./translation.cjs13.js'); }),
63
+ es: () => Promise.resolve().then(function () { return require('./translation.cjs14.js'); }),
64
+ sv: () => Promise.resolve().then(function () { return require('./translation.cjs15.js'); }),
65
+ ja: () => Promise.resolve().then(function () { return require('./translation.cjs16.js'); }),
66
+ th: () => Promise.resolve().then(function () { return require('./translation.cjs17.js'); }),
67
+ },
68
+ };
69
+ /**
70
+ * Local useTranslation for this specific library
71
+ */
72
+ const useTranslation = () => i18nLibraryTranslation.useNamespaceTranslation(namespace);
73
+ /**
74
+ * Registers the translations for this library
75
+ */
76
+ const setupLibraryTranslations = () => {
77
+ i18nLibraryTranslation.registerTranslations(translations);
78
+ };
79
+
80
+ /******************************************************************************
81
+ Copyright (c) Microsoft Corporation.
82
+
83
+ Permission to use, copy, modify, and/or distribute this software for any
84
+ purpose with or without fee is hereby granted.
85
+
86
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
87
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
88
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
89
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
90
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
91
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
92
+ PERFORMANCE OF THIS SOFTWARE.
93
+ ***************************************************************************** */
94
+
95
+ function __rest(s, e) {
96
+ var t = {};
97
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
98
+ t[p] = s[p];
99
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
100
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
101
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
102
+ t[p[i]] = s[p[i]];
103
+ }
104
+ return t;
105
+ }
106
+
107
+ function __awaiter(thisArg, _arguments, P, generator) {
108
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
109
+ return new (P || (P = Promise))(function (resolve, reject) {
110
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
111
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
112
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
113
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
114
+ });
115
+ }
116
+
117
+ /**
118
+ *
119
+ */
120
+ const ConfirmationDialogModal = (_a) => {
121
+ var { isOpen, title, handleDismiss, message, handlePrimaryActionClick, handleSecondaryActionClick, secondaryActionLabel, primaryActionType, primaryActionLabel } = _a, rest = __rest(_a, ["isOpen", "title", "handleDismiss", "message", "handlePrimaryActionClick", "handleSecondaryActionClick", "secondaryActionLabel", "primaryActionType", "primaryActionLabel"]);
122
+ return (jsxRuntime.jsx(reactComponents.Modal, Object.assign({ className: "max-w-xl", isOpen: isOpen, onDismissClick: handleDismiss }, rest, { children: jsxRuntime.jsxs(reactComponents.Card, { role: "dialog", "aria-labelledby": "dialogTitle", "aria-describedby": "dialogDesc", children: [jsxRuntime.jsx(reactComponents.CardHeader, { id: "dialogTitle", heading: title, headingVariant: "secondary", onClose: handleDismiss }), jsxRuntime.jsx(reactComponents.CardBody, { className: "bg-secondary-50", id: "dialogDesc", children: message }), jsxRuntime.jsxs(reactComponents.CardFooter, { hideSeparator: true, className: "bg-secondary-50", children: [jsxRuntime.jsx(reactComponents.Button, { variant: "secondary", onClick: handleSecondaryActionClick, dataTestId: "secondaryAction", children: secondaryActionLabel }), jsxRuntime.jsx(reactComponents.Button, { variant: primaryActionType, onClick: handlePrimaryActionClick, dataTestId: "primaryAction", children: primaryActionLabel })] })] }) })));
123
+ };
124
+
125
+ /**
126
+ *
127
+ */
128
+ const ConfirmationDialogContextProvider = ({ children }) => {
129
+ const [isOpen, setIsOpen] = React.useState(false);
130
+ const [t] = useTranslation();
131
+ const [resolveAction, setResolveAction] = React.useState(null);
132
+ const [confirmationDialogProps, setConfirmationDialogProps] = React.useState({
133
+ title: t("confirmationDialog.default.title"),
134
+ primaryActionType: "primary",
135
+ primaryActionLabel: t("confirmationDialog.default.primarybutton"),
136
+ secondaryActionLabel: t("confirmationDialog.default.secondarybutton"),
137
+ message: t("confirmationDialog.default.message"),
138
+ });
139
+ const closeModal = React__namespace.useCallback(() => {
140
+ setIsOpen(false);
141
+ }, []);
142
+ const confirmationDialogModalProps = React__namespace.useMemo(() => (Object.assign(Object.assign({}, confirmationDialogProps), { isOpen, handleDismiss: () => {
143
+ resolveAction === null || resolveAction === void 0 ? void 0 : resolveAction("CLOSE");
144
+ closeModal();
145
+ }, handlePrimaryActionClick: () => {
146
+ resolveAction === null || resolveAction === void 0 ? void 0 : resolveAction("PRIMARY");
147
+ closeModal();
148
+ }, handleSecondaryActionClick: () => {
149
+ resolveAction === null || resolveAction === void 0 ? void 0 : resolveAction("SECONDARY");
150
+ closeModal();
151
+ } })), [confirmationDialogProps, isOpen, resolveAction, closeModal]);
152
+ const confirm = React__namespace.useCallback((props) => __awaiter(void 0, void 0, void 0, function* () {
153
+ setConfirmationDialogProps(props);
154
+ setIsOpen(true);
155
+ return new Promise(resolve => {
156
+ setResolveAction(() => resolve);
157
+ });
158
+ }), []);
159
+ const value = React__namespace.useMemo(() => ({ confirm }), [confirm]);
160
+ return (jsxRuntime.jsxs(reactCoreHooks.ConfirmationDialogProvider, { value: value, children: [children, resolveAction ? jsxRuntime.jsx(ConfirmationDialogModal, Object.assign({}, confirmationDialogModalProps)) : null] }));
161
+ };
162
+
163
+ /*
164
+ * ----------------------------
165
+ * | SETUP TRANSLATIONS START |
166
+ * ----------------------------
167
+ * This import and function call is needed to register translations for this library.
168
+ * Do not remove this if this library has translations.
169
+ */
170
+ setupLibraryTranslations();
171
+
172
+ exports.ConfirmationDialogContextProvider = ConfirmationDialogContextProvider;
package/index.esm.js ADDED
@@ -0,0 +1,149 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
+ import { ConfirmationDialogProvider } from '@trackunit/react-core-hooks';
4
+ import * as React from 'react';
5
+ import { useState } from 'react';
6
+ import { Modal, Card, CardHeader, CardBody, CardFooter, Button } from '@trackunit/react-components';
7
+
8
+ var defaultTranslations = {
9
+ "confirmationDialog.default.message": "Are you certain that you wish to proceed with this course of action?",
10
+ "confirmationDialog.default.primarybutton": "Confirm",
11
+ "confirmationDialog.default.secondarybutton": "Cancel",
12
+ "confirmationDialog.default.title": "Please confirm this action"
13
+ };
14
+
15
+ /** The translation namespace for this library */
16
+ const namespace = "react.compound-components";
17
+ /**
18
+ * The TranslationResource for this Library.
19
+ * Holds lazy loaded imports for all languages supported by the library.
20
+ *
21
+ * This is used to register the translations for this library before initializing i18next.
22
+ */
23
+ const translations = {
24
+ ns: namespace,
25
+ default: defaultTranslations,
26
+ languages: {
27
+ de: () => import('./translation.esm.js'),
28
+ da: () => import('./translation.esm2.js'),
29
+ cs: () => import('./translation.esm3.js'),
30
+ nl: () => import('./translation.esm4.js'),
31
+ fr: () => import('./translation.esm5.js'),
32
+ fi: () => import('./translation.esm6.js'),
33
+ hu: () => import('./translation.esm7.js'),
34
+ it: () => import('./translation.esm8.js'),
35
+ nb: () => import('./translation.esm9.js'),
36
+ pl: () => import('./translation.esm10.js'),
37
+ pt: () => import('./translation.esm11.js'),
38
+ ru: () => import('./translation.esm12.js'),
39
+ ro: () => import('./translation.esm13.js'),
40
+ es: () => import('./translation.esm14.js'),
41
+ sv: () => import('./translation.esm15.js'),
42
+ ja: () => import('./translation.esm16.js'),
43
+ th: () => import('./translation.esm17.js'),
44
+ },
45
+ };
46
+ /**
47
+ * Local useTranslation for this specific library
48
+ */
49
+ const useTranslation = () => useNamespaceTranslation(namespace);
50
+ /**
51
+ * Registers the translations for this library
52
+ */
53
+ const setupLibraryTranslations = () => {
54
+ registerTranslations(translations);
55
+ };
56
+
57
+ /******************************************************************************
58
+ Copyright (c) Microsoft Corporation.
59
+
60
+ Permission to use, copy, modify, and/or distribute this software for any
61
+ purpose with or without fee is hereby granted.
62
+
63
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
64
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
66
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
67
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
68
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
69
+ PERFORMANCE OF THIS SOFTWARE.
70
+ ***************************************************************************** */
71
+
72
+ function __rest(s, e) {
73
+ var t = {};
74
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
+ t[p] = s[p];
76
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
+ t[p[i]] = s[p[i]];
80
+ }
81
+ return t;
82
+ }
83
+
84
+ function __awaiter(thisArg, _arguments, P, generator) {
85
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
86
+ return new (P || (P = Promise))(function (resolve, reject) {
87
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
88
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
89
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
90
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
91
+ });
92
+ }
93
+
94
+ /**
95
+ *
96
+ */
97
+ const ConfirmationDialogModal = (_a) => {
98
+ var { isOpen, title, handleDismiss, message, handlePrimaryActionClick, handleSecondaryActionClick, secondaryActionLabel, primaryActionType, primaryActionLabel } = _a, rest = __rest(_a, ["isOpen", "title", "handleDismiss", "message", "handlePrimaryActionClick", "handleSecondaryActionClick", "secondaryActionLabel", "primaryActionType", "primaryActionLabel"]);
99
+ return (jsx(Modal, Object.assign({ className: "max-w-xl", isOpen: isOpen, onDismissClick: handleDismiss }, rest, { children: jsxs(Card, { role: "dialog", "aria-labelledby": "dialogTitle", "aria-describedby": "dialogDesc", children: [jsx(CardHeader, { id: "dialogTitle", heading: title, headingVariant: "secondary", onClose: handleDismiss }), jsx(CardBody, { className: "bg-secondary-50", id: "dialogDesc", children: message }), jsxs(CardFooter, { hideSeparator: true, className: "bg-secondary-50", children: [jsx(Button, { variant: "secondary", onClick: handleSecondaryActionClick, dataTestId: "secondaryAction", children: secondaryActionLabel }), jsx(Button, { variant: primaryActionType, onClick: handlePrimaryActionClick, dataTestId: "primaryAction", children: primaryActionLabel })] })] }) })));
100
+ };
101
+
102
+ /**
103
+ *
104
+ */
105
+ const ConfirmationDialogContextProvider = ({ children }) => {
106
+ const [isOpen, setIsOpen] = useState(false);
107
+ const [t] = useTranslation();
108
+ const [resolveAction, setResolveAction] = useState(null);
109
+ const [confirmationDialogProps, setConfirmationDialogProps] = useState({
110
+ title: t("confirmationDialog.default.title"),
111
+ primaryActionType: "primary",
112
+ primaryActionLabel: t("confirmationDialog.default.primarybutton"),
113
+ secondaryActionLabel: t("confirmationDialog.default.secondarybutton"),
114
+ message: t("confirmationDialog.default.message"),
115
+ });
116
+ const closeModal = React.useCallback(() => {
117
+ setIsOpen(false);
118
+ }, []);
119
+ const confirmationDialogModalProps = React.useMemo(() => (Object.assign(Object.assign({}, confirmationDialogProps), { isOpen, handleDismiss: () => {
120
+ resolveAction === null || resolveAction === void 0 ? void 0 : resolveAction("CLOSE");
121
+ closeModal();
122
+ }, handlePrimaryActionClick: () => {
123
+ resolveAction === null || resolveAction === void 0 ? void 0 : resolveAction("PRIMARY");
124
+ closeModal();
125
+ }, handleSecondaryActionClick: () => {
126
+ resolveAction === null || resolveAction === void 0 ? void 0 : resolveAction("SECONDARY");
127
+ closeModal();
128
+ } })), [confirmationDialogProps, isOpen, resolveAction, closeModal]);
129
+ const confirm = React.useCallback((props) => __awaiter(void 0, void 0, void 0, function* () {
130
+ setConfirmationDialogProps(props);
131
+ setIsOpen(true);
132
+ return new Promise(resolve => {
133
+ setResolveAction(() => resolve);
134
+ });
135
+ }), []);
136
+ const value = React.useMemo(() => ({ confirm }), [confirm]);
137
+ return (jsxs(ConfirmationDialogProvider, { value: value, children: [children, resolveAction ? jsx(ConfirmationDialogModal, Object.assign({}, confirmationDialogModalProps)) : null] }));
138
+ };
139
+
140
+ /*
141
+ * ----------------------------
142
+ * | SETUP TRANSLATIONS START |
143
+ * ----------------------------
144
+ * This import and function call is needed to register translations for this library.
145
+ * Do not remove this if this library has translations.
146
+ */
147
+ setupLibraryTranslations();
148
+
149
+ export { ConfirmationDialogContextProvider };
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@trackunit/react-compound-components",
3
+ "version": "0.0.1",
4
+ "repository": "https://github.com/Trackunit/manager",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "dependencies": {
7
+ "@trackunit/react-core-contexts-api": "*",
8
+ "@trackunit/react-core-hooks": "*",
9
+ "react": "^18.2.0",
10
+ "@trackunit/react-components": "*",
11
+ "@trackunit/i18n-library-translation": "*"
12
+ },
13
+ "engines": {
14
+ "node": ">=18.x",
15
+ "yarn": "3.7.0"
16
+ },
17
+ "module": "./index.esm.js",
18
+ "main": "./index.cjs.js"
19
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ export interface ConfirmationDialogProviderProps {
3
+ children: React.ReactNode;
4
+ }
5
+ /**
6
+ *
7
+ */
8
+ export declare const ConfirmationDialogContextProvider: ({ children }: ConfirmationDialogProviderProps) => JSX.Element;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "@trackunit/react-components";
3
+ import { ConfirmationDialogProps } from "./useConfirmationDialog.demo";
4
+ export interface ConfirmationDialogModalProps extends Pick<ConfirmationDialogProps, "title" | "message" | "primaryActionLabel" | "secondaryActionLabel" | "primaryActionType">, CommonProps {
5
+ isOpen: boolean;
6
+ handleDismiss: () => void;
7
+ handlePrimaryActionClick: () => void;
8
+ handleSecondaryActionClick: () => void;
9
+ }
10
+ /**
11
+ *
12
+ */
13
+ export declare const ConfirmationDialogModal: ({ isOpen, title, handleDismiss, message, handlePrimaryActionClick, handleSecondaryActionClick, secondaryActionLabel, primaryActionType, primaryActionLabel, ...rest }: ConfirmationDialogModalProps) => JSX.Element;
@@ -0,0 +1,41 @@
1
+ /// <reference types="react" />
2
+ import { ConfirmationDialogProps as ConfirmationDialogPropsActual } from "@trackunit/react-core-contexts-api";
3
+ export interface ConfirmationDialogProps extends ConfirmationDialogPropsActual {
4
+ /**
5
+ * The heading of the modal.
6
+ */
7
+ title: string;
8
+ /**
9
+ * The content to show in the modal.
10
+ */
11
+ message: string;
12
+ /**
13
+ * The type of the primary action button.
14
+ * For actions like delete, the primary action button should be primary-danger.
15
+ */
16
+ primaryActionType: "primary" | "primary-danger";
17
+ /**
18
+ * The label of the primary action button.
19
+ * For example, "Delete user".
20
+ */
21
+ primaryActionLabel: string;
22
+ /**
23
+ * The label of the secondary action button.
24
+ * For example, "Cancel".
25
+ */
26
+ secondaryActionLabel: string;
27
+ }
28
+ /**
29
+ * The useConfirmationDialog hook is used to show a confirmation dialog in the _**Manager**_ or _**Iris Apps**_.
30
+ *
31
+ * It returns a function that can be called with a ConfirmationDialogProps object.
32
+ *
33
+ * The function returns a promise that resolves to a UserInteractionType.
34
+ *
35
+ * The UserInteractionType is either "PRIMARY", "SECONDARY" or "CLOSE".
36
+ *
37
+ * The promise resolves when the user clicks the primary, secondary, or close button. (CLOSE is also triggered when the modal is dismissed in other ways.)
38
+ *
39
+ * **ATTENTION:** In the Manager and Iris Apps, this hook will "just work". If you are using the hook in a custom setup, you need to wrap your app in the ConfirmationDialogContextProvider.
40
+ */
41
+ export declare const UseTableSelectionDemoComponent: (props: ConfirmationDialogProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { useConfirmationDialog } from "@trackunit/react-core-hooks";
3
+ import { UseTableSelectionDemoComponent } from "./useConfirmationDialog.demo";
4
+ type Story = StoryObj<typeof UseTableSelectionDemoComponent>;
5
+ declare const meta: Meta<typeof useConfirmationDialog>;
6
+ export default meta;
7
+ export declare const packageName: () => JSX.Element;
8
+ export declare const Default: Story;
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./ConfirmationDialog/ConfirmationDialogContextProvider";
@@ -0,0 +1,34 @@
1
+ /// <reference types="react" />
2
+ import { NamespaceTransProps, TransForLibs, TranslationResource } from "@trackunit/i18n-library-translation";
3
+ import defaultTranslations from "./locales/en/translation.json";
4
+ /** A type for all available translation keys in this library */
5
+ export type TranslationKeys = keyof typeof defaultTranslations;
6
+ /** The translation namespace for this library */
7
+ export declare const namespace = "react.compound-components";
8
+ /**
9
+ * The TranslationResource for this Library.
10
+ * Holds lazy loaded imports for all languages supported by the library.
11
+ *
12
+ * This is used to register the translations for this library before initializing i18next.
13
+ */
14
+ export declare const translations: TranslationResource<TranslationKeys>;
15
+ /**
16
+ * Local useTranslation for this specific library
17
+ */
18
+ export declare const useTranslation: () => [TransForLibs<"confirmationDialog.default.message" | "confirmationDialog.default.primarybutton" | "confirmationDialog.default.secondarybutton" | "confirmationDialog.default.title">, import("i18next").i18n, boolean] & {
19
+ t: TransForLibs<"confirmationDialog.default.message" | "confirmationDialog.default.primarybutton" | "confirmationDialog.default.secondarybutton" | "confirmationDialog.default.title">;
20
+ i18n: import("i18next").i18n;
21
+ ready: boolean;
22
+ };
23
+ /**
24
+ * Type of the t function for the local useTranslation for this specific library
25
+ */
26
+ export type TranslationFunction = TransForLibs<TranslationKeys>;
27
+ /**
28
+ * Trans for this specific library.
29
+ */
30
+ export declare const Trans: (props: NamespaceTransProps<TranslationKeys>) => JSX.Element;
31
+ /**
32
+ * Registers the translations for this library
33
+ */
34
+ export declare const setupLibraryTranslations: () => void;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var translation = {
4
+
5
+ };
6
+
7
+ exports["default"] = translation;
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };
@@ -0,0 +1,5 @@
1
+ var translation = {
2
+
3
+ };
4
+
5
+ export { translation as default };