@trackunit/react-compound-components 1.7.159 → 1.7.166

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/index.cjs.js +38 -85
  2. package/index.esm.js +42 -89
  3. package/package.json +7 -10
  4. package/src/PreferenceCard/PreferenceCard.d.ts +10 -1
  5. package/src/PreferenceCard/PreferenceCard.stories.d.ts +1 -1
  6. package/src/PreferenceCard/PreferenceCardGroup.d.ts +3 -1
  7. package/src/index.d.ts +1 -1
  8. package/translation.cjs.js +1 -4
  9. package/translation.cjs10.js +1 -4
  10. package/translation.cjs11.js +1 -4
  11. package/translation.cjs12.js +1 -4
  12. package/translation.cjs13.js +1 -4
  13. package/translation.cjs14.js +1 -4
  14. package/translation.cjs15.js +1 -4
  15. package/translation.cjs16.js +1 -4
  16. package/translation.cjs17.js +1 -4
  17. package/translation.cjs2.js +1 -4
  18. package/translation.cjs3.js +1 -4
  19. package/translation.cjs4.js +1 -4
  20. package/translation.cjs5.js +1 -4
  21. package/translation.cjs6.js +1 -4
  22. package/translation.cjs7.js +1 -4
  23. package/translation.cjs8.js +1 -4
  24. package/translation.cjs9.js +1 -4
  25. package/translation.esm.js +1 -4
  26. package/translation.esm10.js +1 -4
  27. package/translation.esm11.js +1 -4
  28. package/translation.esm12.js +1 -4
  29. package/translation.esm13.js +1 -4
  30. package/translation.esm14.js +1 -4
  31. package/translation.esm15.js +1 -4
  32. package/translation.esm16.js +1 -4
  33. package/translation.esm17.js +1 -4
  34. package/translation.esm2.js +1 -4
  35. package/translation.esm3.js +1 -4
  36. package/translation.esm4.js +1 -4
  37. package/translation.esm5.js +1 -4
  38. package/translation.esm6.js +1 -4
  39. package/translation.esm7.js +1 -4
  40. package/translation.esm8.js +1 -4
  41. package/translation.esm9.js +1 -4
  42. package/src/ConfirmationDialog/ConfirmationDialogContextProvider.d.ts +0 -10
  43. package/src/ConfirmationDialog/ConfirmationDialogModal.d.ts +0 -12
  44. package/src/ConfirmationDialog/useConfirmationDialog.demo.d.ts +0 -41
  45. package/src/ConfirmationDialog/useConfirmationDialog.stories.d.ts +0 -18
package/index.cjs.js CHANGED
@@ -2,19 +2,14 @@
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
5
- var reactCoreHooks = require('@trackunit/react-core-hooks');
6
- var reactModal = require('@trackunit/react-modal');
7
- var react = require('react');
8
5
  var reactComponents = require('@trackunit/react-components');
9
6
  var reactFormComponents = require('@trackunit/react-form-components');
7
+ var react = require('react');
10
8
  var tailwindMerge = require('tailwind-merge');
11
9
  var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
12
10
 
13
11
  var defaultTranslations = {
14
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
15
- "confirmationDialog.default.primarybutton": "Confirm",
16
- "confirmationDialog.default.secondarybutton": "Cancel",
17
- "confirmationDialog.default.title": "Please confirm this action"
12
+
18
13
  };
19
14
 
20
15
  /** The translation namespace for this library */
@@ -48,10 +43,6 @@ const translations = {
48
43
  th: () => Promise.resolve().then(function () { return require('./translation.cjs17.js'); }),
49
44
  },
50
45
  };
51
- /**
52
- * Local useTranslation for this specific library
53
- */
54
- const useTranslation = () => i18nLibraryTranslation.useNamespaceTranslation(namespace);
55
46
  /**
56
47
  * Registers the translations for this library
57
48
  */
@@ -59,66 +50,6 @@ const setupLibraryTranslations = () => {
59
50
  i18nLibraryTranslation.registerTranslations(translations);
60
51
  };
61
52
 
62
- /**
63
- *
64
- */
65
- const ConfirmationDialogModal = ({ title, message, handlePrimaryActionClick, handleSecondaryActionClick, secondaryActionLabel, primaryActionType, primaryActionLabel, ...modalProps }) => {
66
- return (jsxRuntime.jsxs(reactModal.Modal, { ...modalProps, className: "max-w-xl", children: [jsxRuntime.jsx(reactModal.ModalHeader, { heading: title, id: "dialogTitle", onClose: modalProps.close }), jsxRuntime.jsx(reactModal.ModalBody, { id: "dialogDesc", children: message }), jsxRuntime.jsxs(reactModal.ModalFooter, { children: [jsxRuntime.jsx(reactComponents.Button, { "data-testid": "secondaryAction", onClick: handleSecondaryActionClick, variant: "ghost-neutral", children: secondaryActionLabel }), jsxRuntime.jsx(reactComponents.Button, { "data-testid": "primaryAction", onClick: handlePrimaryActionClick, variant: primaryActionType, children: primaryActionLabel })] })] }));
67
- };
68
-
69
- /**
70
- * Helper that resolves the promise with the given action and immediately clears the resolver to prevent double resolution
71
- *
72
- * Prevents scenarios where both a button click and modal auto-close would resolve the same promise
73
- */
74
- const resolveAndClear = (resolveAction, setResolveAction, action) => {
75
- if (resolveAction) {
76
- resolveAction(action);
77
- setResolveAction(null);
78
- }
79
- };
80
- /**
81
- * ConfirmationDialogContextProvider
82
- *
83
- * Provides confirmation dialog context and manages modal state with Promise-based resolution
84
- */
85
- const ConfirmationDialogContextProvider = ({ children }) => {
86
- const [t] = useTranslation();
87
- const modal = reactModal.useModal({
88
- onClose: () => {
89
- resolveAndClear(resolveAction, setResolveAction, "CLOSE");
90
- },
91
- });
92
- const [resolveAction, setResolveAction] = react.useState(null);
93
- const [confirmationDialogProps, setConfirmationDialogProps] = react.useState({
94
- title: t("confirmationDialog.default.title"),
95
- primaryActionType: "primary",
96
- primaryActionLabel: t("confirmationDialog.default.primarybutton"),
97
- secondaryActionLabel: t("confirmationDialog.default.secondarybutton"),
98
- message: t("confirmationDialog.default.message"),
99
- });
100
- const confirmationDialogModalProps = react.useMemo(() => ({
101
- ...confirmationDialogProps,
102
- handlePrimaryActionClick: () => {
103
- resolveAndClear(resolveAction, setResolveAction, "PRIMARY");
104
- modal.close();
105
- },
106
- handleSecondaryActionClick: () => {
107
- resolveAndClear(resolveAction, setResolveAction, "SECONDARY");
108
- modal.close();
109
- },
110
- }), [confirmationDialogProps, resolveAction, setResolveAction, modal]);
111
- const confirm = react.useCallback(async (props) => {
112
- setConfirmationDialogProps(prev => ({ ...prev, ...props }));
113
- modal.open();
114
- return new Promise(resolve => {
115
- setResolveAction(() => resolve);
116
- });
117
- }, [modal]);
118
- const value = react.useMemo(() => ({ confirm }), [confirm]);
119
- return (jsxRuntime.jsxs(reactCoreHooks.ConfirmationDialogProvider, { value: value, children: [children, resolveAction ? jsxRuntime.jsx(ConfirmationDialogModal, { ...modal, ...confirmationDialogModalProps }) : null] }));
120
- };
121
-
122
53
  const cvaPreferenceCard = cssClassVarianceUtilities.cvaMerge(["rounded-lg", "border", "border-neutral-200", "bg-white", "w-full"], {
123
54
  variants: {
124
55
  disabled: {
@@ -136,18 +67,13 @@ const cvaPreferenceCard = cssClassVarianceUtilities.cvaMerge(["rounded-lg", "bor
136
67
  clickable: true,
137
68
  class: "cursor-not-allowed",
138
69
  },
139
- {
140
- disabled: false,
141
- clickable: true,
142
- class: "focus:ring-primary-600 focus:border-primary-600 focus:outline-none focus:ring-1",
143
- },
144
70
  ],
145
71
  defaultVariants: {
146
72
  disabled: false,
147
73
  clickable: false,
148
74
  },
149
75
  });
150
- const cvaInputCard = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "p-4"], {
76
+ const cvaInputCard = cssClassVarianceUtilities.cvaMerge(["flex", "items-start", "px-4", "py-[21px]", "rounded-l-lg", "border", "border-transparent"], {
151
77
  variants: {
152
78
  disabled: {
153
79
  true: "bg-neutral-50",
@@ -162,12 +88,12 @@ const cvaInputCard = cssClassVarianceUtilities.cvaMerge(["flex", "items-center",
162
88
  {
163
89
  disabled: false,
164
90
  checked: true,
165
- class: "bg-primary-50",
91
+ class: "bg-primary-50 focus:border focus:border-blue-500 focus:outline-2 focus:outline-offset-2 focus:outline-blue-500",
166
92
  },
167
93
  {
168
94
  disabled: false,
169
95
  checked: false,
170
- class: "bg-neutral-50",
96
+ class: "bg-neutral-50 focus:border focus:border-blue-500 focus:outline-2 focus:outline-offset-2 focus:outline-blue-500",
171
97
  },
172
98
  ],
173
99
  defaultVariants: {
@@ -214,8 +140,8 @@ const cvaIconBackground = cssClassVarianceUtilities.cvaMerge(["flex", "h-8", "w-
214
140
  * with various states and visual treatments.
215
141
  * It is recommended to be primarily used as an input component, as it supports checkboxes, radio buttons and toggles.
216
142
  */
217
- const PreferenceCard = ({ title, description, icon, input, firstTag, secondTag, disabled = false, loading = false, className, "data-testid": dataTestId, children, onClick, }) => {
218
- const handleCardClick = react.useCallback(() => {
143
+ const PreferenceCard = ({ title, description, icon, image, input, firstTag, secondTag, disabled = false, loading = false, className, "data-testid": dataTestId, children, onClick, }) => {
144
+ const handleInputContainerClick = react.useCallback(() => {
219
145
  if (!disabled && !loading) {
220
146
  if (onClick) {
221
147
  onClick();
@@ -228,11 +154,38 @@ const PreferenceCard = ({ title, description, icon, input, firstTag, secondTag,
228
154
  const handleInputClick = react.useCallback((event) => {
229
155
  event.stopPropagation();
230
156
  }, []);
231
- return (jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge(cvaPreferenceCard({
157
+ return (jsxRuntime.jsx("div", { className: tailwindMerge.twMerge(cvaPreferenceCard({
232
158
  className,
233
159
  disabled,
234
- clickable: !!(onClick || input),
235
- }), "overflow-hidden"), "data-testid": dataTestId, onClick: handleCardClick, tabIndex: onClick || input ? (disabled ? -1 : 0) : undefined, children: [jsxRuntime.jsxs("div", { className: "flex items-stretch divide-x divide-neutral-200", children: [input ? (jsxRuntime.jsx("div", { className: cvaInputCard({ disabled, checked: input.checked }), onClick: handleInputClick, children: jsxRuntime.jsxs(reactComponents.Tooltip, { disabled: !input.tooltipText, label: input.tooltipText, placement: "top", children: [input.type === "checkbox" ? (jsxRuntime.jsx(reactFormComponents.Checkbox, { checked: input.checked, disabled: disabled, onChange: event => input.handleInputChange(event.target.checked) })) : null, input.type === "radio" ? jsxRuntime.jsx(reactFormComponents.RadioItem, { disabled: disabled, value: title }) : null, input.type === "toggle" ? (jsxRuntime.jsx(reactFormComponents.ToggleSwitch, { disabled: disabled, onChange: toggled => input.handleInputChange(toggled), toggled: input.checked })) : null] }) })) : null, jsxRuntime.jsxs("div", { className: "flex grow px-4 py-3", children: [loading ? (jsxRuntime.jsxs("div", { className: "flex grow items-center gap-3", children: [jsxRuntime.jsx("div", { className: "flex-shrink-0", children: jsxRuntime.jsx(reactComponents.SkeletonLines, { className: "rounded-md", height: 32, lines: 1, width: 32 }) }), jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: jsxRuntime.jsx(reactComponents.SkeletonLines, { gap: 4, height: [11, 12], lines: 2, width: [128, 152] }) })] })) : (jsxRuntime.jsxs("div", { className: "flex grow items-center gap-3", children: [icon ? (jsxRuntime.jsx("div", { className: "flex-shrink-0", children: jsxRuntime.jsx("div", { className: tailwindMerge.twMerge(cvaIconBackground({ disabled }), disabled ? "" : icon.backgroundColor), children: jsxRuntime.jsx(reactComponents.Icon, { color: "white", name: icon.name, size: "small", type: "solid" }) }) })) : null, jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntime.jsx("div", { className: "grid min-w-0 grid-cols-[1fr_auto] items-center gap-2", children: jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [jsxRuntime.jsx(reactComponents.Text, { className: cvaTitleCard({ disabled }), size: "medium", weight: "bold", children: title }), firstTag ? (jsxRuntime.jsx(reactComponents.Tag, { className: "shrink-0", color: disabled ? "unknown" : firstTag.color, size: "small", children: firstTag.title })) : null] }) }), jsxRuntime.jsx(reactComponents.Text, { className: cvaDescriptionCard({ disabled }), size: "small", type: "p", children: description })] })] })), secondTag ? (jsxRuntime.jsx(reactComponents.Tag, { className: "shrink-0", color: disabled ? "unknown" : secondTag.color, size: "medium", children: secondTag.title })) : null] })] }), children] }));
160
+ }), "overflow-hidden"), "data-testid": dataTestId, children: jsxRuntime.jsxs("div", { className: "flex items-stretch divide-x divide-neutral-200", children: [input ? (jsxRuntime.jsx("button", { "aria-label": `input-${title.toLowerCase().replace(/ /g, "-")}`, "aria-pressed": input.checked, className: cvaInputCard({ disabled, checked: input.checked }), onClick: handleInputContainerClick, tabIndex: disabled ? -1 : 0, type: "button", children: jsxRuntime.jsxs(reactComponents.Tooltip, { disabled: !input.tooltipText, label: input.tooltipText, placement: "top", children: [input.type === "checkbox" ? (jsxRuntime.jsx(reactFormComponents.Checkbox, { checked: input.checked, disabled: disabled, onChange: event => input.handleInputChange(event.target.checked), stopPropagation: true })) : null, input.type === "radio" ? (jsxRuntime.jsx(reactFormComponents.RadioItem, { checked: input.checked, disabled: disabled, onClick: handleInputClick, value: input.value })) : null, input.type === "toggle" ? (jsxRuntime.jsx(reactFormComponents.ToggleSwitch, { disabled: disabled, onChange: toggled => input.handleInputChange(toggled), onClick: handleInputClick, toggled: input.checked })) : null] }) })) : null, jsxRuntime.jsxs("div", { className: "flex flex-1 px-4 py-3", children: [loading ? (jsxRuntime.jsxs("div", { className: "flex grow items-center gap-3", children: [jsxRuntime.jsx("div", { className: "flex-shrink-0", children: jsxRuntime.jsx(reactComponents.SkeletonLines, { className: "rounded-md", height: 32, lines: 1, width: 32 }) }), jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: jsxRuntime.jsx(reactComponents.SkeletonLines, { gap: 4, height: [11, 12], lines: 2, width: [128, 152] }) })] })) : (jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col", children: [jsxRuntime.jsxs("div", { className: "flex flex-shrink-0 items-center gap-2", children: [icon ? (jsxRuntime.jsx("div", { className: "flex-shrink-0", children: jsxRuntime.jsx("div", { className: tailwindMerge.twMerge(cvaIconBackground({ disabled }), disabled ? "" : icon.backgroundColor), children: jsxRuntime.jsx(reactComponents.Icon, { color: "white", name: icon.name, size: "small", type: "solid" }) }) })) : null, image ? (jsxRuntime.jsx("div", { className: "flex-shrink-0", children: jsxRuntime.jsx("div", { className: tailwindMerge.twMerge(cvaIconBackground({ disabled }), disabled ? "" : image.backgroundColor || "bg-gray-100"), children: jsxRuntime.jsx("img", { alt: image.alt, className: "aspect-square h-8 w-8 rounded-md border border-neutral-200 object-contain", src: image.src }) }) })) : null, jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntime.jsx("div", { className: "grid min-w-0 grid-cols-[1fr_auto] items-center gap-2", children: jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [jsxRuntime.jsx(reactComponents.Text, { className: cvaTitleCard({ disabled }), size: "medium", weight: "bold", children: title }), firstTag ? (jsxRuntime.jsx(reactComponents.Tag, { className: "shrink-0", color: disabled ? "unknown" : firstTag.color, size: "small", children: firstTag.title })) : null] }) }), jsxRuntime.jsx(reactComponents.Text, { className: cvaDescriptionCard({ disabled }), size: "small", type: "p", children: description })] })] }), children] })), secondTag ? (jsxRuntime.jsx(reactComponents.Tag, { className: "shrink-0", color: disabled ? "unknown" : secondTag.color, size: "medium", children: secondTag.title })) : null] })] }) }));
161
+ };
162
+
163
+ /**
164
+ * PreferenceCardGroup allows multiple PreferenceCards to work together as a group.
165
+ */
166
+ const PreferenceCardGroup = ({ cards, selectedValue, onSelectionChange, groupId, isRadioMode = false, disabled = false, loading = false, "data-testid": dataTestId, }) => {
167
+ if (isRadioMode) {
168
+ return (jsxRuntime.jsx(reactFormComponents.RadioGroup, { "data-testid": dataTestId, disabled: disabled, id: groupId, onChange: event => onSelectionChange(event.target.value), value: typeof selectedValue === "string" ? selectedValue : "", children: cards.map(card => (jsxRuntime.jsx(PreferenceCard, { disabled: disabled, ...card, input: {
169
+ type: "radio",
170
+ checked: selectedValue === card.id,
171
+ value: card.id,
172
+ }, loading: loading, onClick: () => {
173
+ if (!disabled && !loading) {
174
+ onSelectionChange(card.id);
175
+ }
176
+ } }, card.id))) }));
177
+ }
178
+ return (jsxRuntime.jsx("div", { className: "flex flex-col gap-2", "data-testid": dataTestId, id: groupId, children: cards.map(card => (jsxRuntime.jsx(PreferenceCard, { ...card, disabled: disabled, input: {
179
+ type: card.input?.type === "toggle" ? "toggle" : "checkbox",
180
+ checked: Array.isArray(selectedValue) ? selectedValue.includes(card.id) : false,
181
+ handleInputChange: () => {
182
+ const currentValues = Array.isArray(selectedValue) ? selectedValue : [];
183
+ const newValues = currentValues.includes(card.id)
184
+ ? currentValues.filter(v => v !== card.id)
185
+ : [...currentValues, card.id];
186
+ onSelectionChange(newValues);
187
+ },
188
+ }, loading: loading }, card.id))) }));
236
189
  };
237
190
 
238
191
  /*
@@ -244,5 +197,5 @@ const PreferenceCard = ({ title, description, icon, input, firstTag, secondTag,
244
197
  */
245
198
  setupLibraryTranslations();
246
199
 
247
- exports.ConfirmationDialogContextProvider = ConfirmationDialogContextProvider;
248
200
  exports.PreferenceCard = PreferenceCard;
201
+ exports.PreferenceCardGroup = PreferenceCardGroup;
package/index.esm.js CHANGED
@@ -1,18 +1,13 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
- import { ConfirmationDialogProvider } from '@trackunit/react-core-hooks';
4
- import { Modal, ModalHeader, ModalBody, ModalFooter, useModal } from '@trackunit/react-modal';
5
- import { useState, useMemo, useCallback } from 'react';
6
- import { Button, Tooltip, SkeletonLines, Icon, Text, Tag } from '@trackunit/react-components';
7
- import { Checkbox, RadioItem, ToggleSwitch } from '@trackunit/react-form-components';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { registerTranslations } from '@trackunit/i18n-library-translation';
3
+ import { Tooltip, SkeletonLines, Icon, Text, Tag } from '@trackunit/react-components';
4
+ import { Checkbox, RadioItem, ToggleSwitch, RadioGroup } from '@trackunit/react-form-components';
5
+ import { useCallback } from 'react';
8
6
  import { twMerge } from 'tailwind-merge';
9
7
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
10
8
 
11
9
  var defaultTranslations = {
12
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
13
- "confirmationDialog.default.primarybutton": "Confirm",
14
- "confirmationDialog.default.secondarybutton": "Cancel",
15
- "confirmationDialog.default.title": "Please confirm this action"
10
+
16
11
  };
17
12
 
18
13
  /** The translation namespace for this library */
@@ -46,10 +41,6 @@ const translations = {
46
41
  th: () => import('./translation.esm17.js'),
47
42
  },
48
43
  };
49
- /**
50
- * Local useTranslation for this specific library
51
- */
52
- const useTranslation = () => useNamespaceTranslation(namespace);
53
44
  /**
54
45
  * Registers the translations for this library
55
46
  */
@@ -57,66 +48,6 @@ const setupLibraryTranslations = () => {
57
48
  registerTranslations(translations);
58
49
  };
59
50
 
60
- /**
61
- *
62
- */
63
- const ConfirmationDialogModal = ({ title, message, handlePrimaryActionClick, handleSecondaryActionClick, secondaryActionLabel, primaryActionType, primaryActionLabel, ...modalProps }) => {
64
- return (jsxs(Modal, { ...modalProps, className: "max-w-xl", children: [jsx(ModalHeader, { heading: title, id: "dialogTitle", onClose: modalProps.close }), jsx(ModalBody, { id: "dialogDesc", children: message }), jsxs(ModalFooter, { children: [jsx(Button, { "data-testid": "secondaryAction", onClick: handleSecondaryActionClick, variant: "ghost-neutral", children: secondaryActionLabel }), jsx(Button, { "data-testid": "primaryAction", onClick: handlePrimaryActionClick, variant: primaryActionType, children: primaryActionLabel })] })] }));
65
- };
66
-
67
- /**
68
- * Helper that resolves the promise with the given action and immediately clears the resolver to prevent double resolution
69
- *
70
- * Prevents scenarios where both a button click and modal auto-close would resolve the same promise
71
- */
72
- const resolveAndClear = (resolveAction, setResolveAction, action) => {
73
- if (resolveAction) {
74
- resolveAction(action);
75
- setResolveAction(null);
76
- }
77
- };
78
- /**
79
- * ConfirmationDialogContextProvider
80
- *
81
- * Provides confirmation dialog context and manages modal state with Promise-based resolution
82
- */
83
- const ConfirmationDialogContextProvider = ({ children }) => {
84
- const [t] = useTranslation();
85
- const modal = useModal({
86
- onClose: () => {
87
- resolveAndClear(resolveAction, setResolveAction, "CLOSE");
88
- },
89
- });
90
- const [resolveAction, setResolveAction] = useState(null);
91
- const [confirmationDialogProps, setConfirmationDialogProps] = useState({
92
- title: t("confirmationDialog.default.title"),
93
- primaryActionType: "primary",
94
- primaryActionLabel: t("confirmationDialog.default.primarybutton"),
95
- secondaryActionLabel: t("confirmationDialog.default.secondarybutton"),
96
- message: t("confirmationDialog.default.message"),
97
- });
98
- const confirmationDialogModalProps = useMemo(() => ({
99
- ...confirmationDialogProps,
100
- handlePrimaryActionClick: () => {
101
- resolveAndClear(resolveAction, setResolveAction, "PRIMARY");
102
- modal.close();
103
- },
104
- handleSecondaryActionClick: () => {
105
- resolveAndClear(resolveAction, setResolveAction, "SECONDARY");
106
- modal.close();
107
- },
108
- }), [confirmationDialogProps, resolveAction, setResolveAction, modal]);
109
- const confirm = useCallback(async (props) => {
110
- setConfirmationDialogProps(prev => ({ ...prev, ...props }));
111
- modal.open();
112
- return new Promise(resolve => {
113
- setResolveAction(() => resolve);
114
- });
115
- }, [modal]);
116
- const value = useMemo(() => ({ confirm }), [confirm]);
117
- return (jsxs(ConfirmationDialogProvider, { value: value, children: [children, resolveAction ? jsx(ConfirmationDialogModal, { ...modal, ...confirmationDialogModalProps }) : null] }));
118
- };
119
-
120
51
  const cvaPreferenceCard = cvaMerge(["rounded-lg", "border", "border-neutral-200", "bg-white", "w-full"], {
121
52
  variants: {
122
53
  disabled: {
@@ -134,18 +65,13 @@ const cvaPreferenceCard = cvaMerge(["rounded-lg", "border", "border-neutral-200"
134
65
  clickable: true,
135
66
  class: "cursor-not-allowed",
136
67
  },
137
- {
138
- disabled: false,
139
- clickable: true,
140
- class: "focus:ring-primary-600 focus:border-primary-600 focus:outline-none focus:ring-1",
141
- },
142
68
  ],
143
69
  defaultVariants: {
144
70
  disabled: false,
145
71
  clickable: false,
146
72
  },
147
73
  });
148
- const cvaInputCard = cvaMerge(["flex", "items-center", "p-4"], {
74
+ const cvaInputCard = cvaMerge(["flex", "items-start", "px-4", "py-[21px]", "rounded-l-lg", "border", "border-transparent"], {
149
75
  variants: {
150
76
  disabled: {
151
77
  true: "bg-neutral-50",
@@ -160,12 +86,12 @@ const cvaInputCard = cvaMerge(["flex", "items-center", "p-4"], {
160
86
  {
161
87
  disabled: false,
162
88
  checked: true,
163
- class: "bg-primary-50",
89
+ class: "bg-primary-50 focus:border focus:border-blue-500 focus:outline-2 focus:outline-offset-2 focus:outline-blue-500",
164
90
  },
165
91
  {
166
92
  disabled: false,
167
93
  checked: false,
168
- class: "bg-neutral-50",
94
+ class: "bg-neutral-50 focus:border focus:border-blue-500 focus:outline-2 focus:outline-offset-2 focus:outline-blue-500",
169
95
  },
170
96
  ],
171
97
  defaultVariants: {
@@ -212,8 +138,8 @@ const cvaIconBackground = cvaMerge(["flex", "h-8", "w-8", "items-center", "justi
212
138
  * with various states and visual treatments.
213
139
  * It is recommended to be primarily used as an input component, as it supports checkboxes, radio buttons and toggles.
214
140
  */
215
- const PreferenceCard = ({ title, description, icon, input, firstTag, secondTag, disabled = false, loading = false, className, "data-testid": dataTestId, children, onClick, }) => {
216
- const handleCardClick = useCallback(() => {
141
+ const PreferenceCard = ({ title, description, icon, image, input, firstTag, secondTag, disabled = false, loading = false, className, "data-testid": dataTestId, children, onClick, }) => {
142
+ const handleInputContainerClick = useCallback(() => {
217
143
  if (!disabled && !loading) {
218
144
  if (onClick) {
219
145
  onClick();
@@ -226,11 +152,38 @@ const PreferenceCard = ({ title, description, icon, input, firstTag, secondTag,
226
152
  const handleInputClick = useCallback((event) => {
227
153
  event.stopPropagation();
228
154
  }, []);
229
- return (jsxs("div", { className: twMerge(cvaPreferenceCard({
155
+ return (jsx("div", { className: twMerge(cvaPreferenceCard({
230
156
  className,
231
157
  disabled,
232
- clickable: !!(onClick || input),
233
- }), "overflow-hidden"), "data-testid": dataTestId, onClick: handleCardClick, tabIndex: onClick || input ? (disabled ? -1 : 0) : undefined, children: [jsxs("div", { className: "flex items-stretch divide-x divide-neutral-200", children: [input ? (jsx("div", { className: cvaInputCard({ disabled, checked: input.checked }), onClick: handleInputClick, children: jsxs(Tooltip, { disabled: !input.tooltipText, label: input.tooltipText, placement: "top", children: [input.type === "checkbox" ? (jsx(Checkbox, { checked: input.checked, disabled: disabled, onChange: event => input.handleInputChange(event.target.checked) })) : null, input.type === "radio" ? jsx(RadioItem, { disabled: disabled, value: title }) : null, input.type === "toggle" ? (jsx(ToggleSwitch, { disabled: disabled, onChange: toggled => input.handleInputChange(toggled), toggled: input.checked })) : null] }) })) : null, jsxs("div", { className: "flex grow px-4 py-3", children: [loading ? (jsxs("div", { className: "flex grow items-center gap-3", children: [jsx("div", { className: "flex-shrink-0", children: jsx(SkeletonLines, { className: "rounded-md", height: 32, lines: 1, width: 32 }) }), jsx("div", { className: "min-w-0 flex-1", children: jsx(SkeletonLines, { gap: 4, height: [11, 12], lines: 2, width: [128, 152] }) })] })) : (jsxs("div", { className: "flex grow items-center gap-3", children: [icon ? (jsx("div", { className: "flex-shrink-0", children: jsx("div", { className: twMerge(cvaIconBackground({ disabled }), disabled ? "" : icon.backgroundColor), children: jsx(Icon, { color: "white", name: icon.name, size: "small", type: "solid" }) }) })) : null, jsxs("div", { className: "min-w-0 flex-1", children: [jsx("div", { className: "grid min-w-0 grid-cols-[1fr_auto] items-center gap-2", children: jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [jsx(Text, { className: cvaTitleCard({ disabled }), size: "medium", weight: "bold", children: title }), firstTag ? (jsx(Tag, { className: "shrink-0", color: disabled ? "unknown" : firstTag.color, size: "small", children: firstTag.title })) : null] }) }), jsx(Text, { className: cvaDescriptionCard({ disabled }), size: "small", type: "p", children: description })] })] })), secondTag ? (jsx(Tag, { className: "shrink-0", color: disabled ? "unknown" : secondTag.color, size: "medium", children: secondTag.title })) : null] })] }), children] }));
158
+ }), "overflow-hidden"), "data-testid": dataTestId, children: jsxs("div", { className: "flex items-stretch divide-x divide-neutral-200", children: [input ? (jsx("button", { "aria-label": `input-${title.toLowerCase().replace(/ /g, "-")}`, "aria-pressed": input.checked, className: cvaInputCard({ disabled, checked: input.checked }), onClick: handleInputContainerClick, tabIndex: disabled ? -1 : 0, type: "button", children: jsxs(Tooltip, { disabled: !input.tooltipText, label: input.tooltipText, placement: "top", children: [input.type === "checkbox" ? (jsx(Checkbox, { checked: input.checked, disabled: disabled, onChange: event => input.handleInputChange(event.target.checked), stopPropagation: true })) : null, input.type === "radio" ? (jsx(RadioItem, { checked: input.checked, disabled: disabled, onClick: handleInputClick, value: input.value })) : null, input.type === "toggle" ? (jsx(ToggleSwitch, { disabled: disabled, onChange: toggled => input.handleInputChange(toggled), onClick: handleInputClick, toggled: input.checked })) : null] }) })) : null, jsxs("div", { className: "flex flex-1 px-4 py-3", children: [loading ? (jsxs("div", { className: "flex grow items-center gap-3", children: [jsx("div", { className: "flex-shrink-0", children: jsx(SkeletonLines, { className: "rounded-md", height: 32, lines: 1, width: 32 }) }), jsx("div", { className: "min-w-0 flex-1", children: jsx(SkeletonLines, { gap: 4, height: [11, 12], lines: 2, width: [128, 152] }) })] })) : (jsxs("div", { className: "flex flex-1 flex-col", children: [jsxs("div", { className: "flex flex-shrink-0 items-center gap-2", children: [icon ? (jsx("div", { className: "flex-shrink-0", children: jsx("div", { className: twMerge(cvaIconBackground({ disabled }), disabled ? "" : icon.backgroundColor), children: jsx(Icon, { color: "white", name: icon.name, size: "small", type: "solid" }) }) })) : null, image ? (jsx("div", { className: "flex-shrink-0", children: jsx("div", { className: twMerge(cvaIconBackground({ disabled }), disabled ? "" : image.backgroundColor || "bg-gray-100"), children: jsx("img", { alt: image.alt, className: "aspect-square h-8 w-8 rounded-md border border-neutral-200 object-contain", src: image.src }) }) })) : null, jsxs("div", { className: "min-w-0 flex-1", children: [jsx("div", { className: "grid min-w-0 grid-cols-[1fr_auto] items-center gap-2", children: jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [jsx(Text, { className: cvaTitleCard({ disabled }), size: "medium", weight: "bold", children: title }), firstTag ? (jsx(Tag, { className: "shrink-0", color: disabled ? "unknown" : firstTag.color, size: "small", children: firstTag.title })) : null] }) }), jsx(Text, { className: cvaDescriptionCard({ disabled }), size: "small", type: "p", children: description })] })] }), children] })), secondTag ? (jsx(Tag, { className: "shrink-0", color: disabled ? "unknown" : secondTag.color, size: "medium", children: secondTag.title })) : null] })] }) }));
159
+ };
160
+
161
+ /**
162
+ * PreferenceCardGroup allows multiple PreferenceCards to work together as a group.
163
+ */
164
+ const PreferenceCardGroup = ({ cards, selectedValue, onSelectionChange, groupId, isRadioMode = false, disabled = false, loading = false, "data-testid": dataTestId, }) => {
165
+ if (isRadioMode) {
166
+ return (jsx(RadioGroup, { "data-testid": dataTestId, disabled: disabled, id: groupId, onChange: event => onSelectionChange(event.target.value), value: typeof selectedValue === "string" ? selectedValue : "", children: cards.map(card => (jsx(PreferenceCard, { disabled: disabled, ...card, input: {
167
+ type: "radio",
168
+ checked: selectedValue === card.id,
169
+ value: card.id,
170
+ }, loading: loading, onClick: () => {
171
+ if (!disabled && !loading) {
172
+ onSelectionChange(card.id);
173
+ }
174
+ } }, card.id))) }));
175
+ }
176
+ return (jsx("div", { className: "flex flex-col gap-2", "data-testid": dataTestId, id: groupId, children: cards.map(card => (jsx(PreferenceCard, { ...card, disabled: disabled, input: {
177
+ type: card.input?.type === "toggle" ? "toggle" : "checkbox",
178
+ checked: Array.isArray(selectedValue) ? selectedValue.includes(card.id) : false,
179
+ handleInputChange: () => {
180
+ const currentValues = Array.isArray(selectedValue) ? selectedValue : [];
181
+ const newValues = currentValues.includes(card.id)
182
+ ? currentValues.filter(v => v !== card.id)
183
+ : [...currentValues, card.id];
184
+ onSelectionChange(newValues);
185
+ },
186
+ }, loading: loading }, card.id))) }));
234
187
  };
235
188
 
236
189
  /*
@@ -242,4 +195,4 @@ const PreferenceCard = ({ title, description, icon, input, firstTag, secondTag,
242
195
  */
243
196
  setupLibraryTranslations();
244
197
 
245
- export { ConfirmationDialogContextProvider, PreferenceCard };
198
+ export { PreferenceCard, PreferenceCardGroup };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-compound-components",
3
- "version": "1.7.159",
3
+ "version": "1.7.166",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -9,15 +9,12 @@
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
11
  "tailwind-merge": "^2.0.0",
12
- "@trackunit/react-core-hooks": "1.7.121",
13
- "@trackunit/react-components": "1.10.83",
14
- "@trackunit/react-modal": "1.8.147",
15
- "@trackunit/css-class-variance-utilities": "1.7.107",
16
- "@trackunit/react-form-components": "1.8.158",
17
- "@trackunit/i18n-library-translation": "1.7.128",
18
- "@trackunit/shared-utils": "1.9.107",
19
- "@trackunit/ui-icons": "1.7.108",
20
- "@trackunit/iris-app-runtime-core-api": "1.7.117"
12
+ "@trackunit/css-class-variance-utilities": "1.7.113",
13
+ "@trackunit/react-form-components": "1.8.164",
14
+ "@trackunit/i18n-library-translation": "1.7.134",
15
+ "@trackunit/shared-utils": "1.9.113",
16
+ "@trackunit/ui-icons": "1.7.114",
17
+ "@trackunit/react-components": "1.10.89"
21
18
  },
22
19
  "module": "./index.esm.js",
23
20
  "main": "./index.cjs.js",
@@ -20,6 +20,14 @@ export interface PreferenceCardProps extends CommonProps, MappedOmit<VariantProp
20
20
  name: IconName;
21
21
  backgroundColor: string;
22
22
  };
23
+ /**
24
+ * Custom image to display instead of an icon
25
+ */
26
+ image?: {
27
+ src: string;
28
+ alt: string;
29
+ backgroundColor?: string;
30
+ };
23
31
  /**
24
32
  * Input component to display in the card
25
33
  */
@@ -31,6 +39,7 @@ export interface PreferenceCardProps extends CommonProps, MappedOmit<VariantProp
31
39
  } | {
32
40
  type: "radio";
33
41
  checked: boolean;
42
+ value: string;
34
43
  tooltipText?: string;
35
44
  };
36
45
  /**
@@ -69,4 +78,4 @@ export interface PreferenceCardProps extends CommonProps, MappedOmit<VariantProp
69
78
  * with various states and visual treatments.
70
79
  * It is recommended to be primarily used as an input component, as it supports checkboxes, radio buttons and toggles.
71
80
  */
72
- export declare const PreferenceCard: ({ title, description, icon, input, firstTag, secondTag, disabled, loading, className, "data-testid": dataTestId, children, onClick, }: PreferenceCardProps) => ReactNode;
81
+ export declare const PreferenceCard: ({ title, description, icon, image, input, firstTag, secondTag, disabled, loading, className, "data-testid": dataTestId, children, onClick, }: PreferenceCardProps) => ReactNode;
@@ -3,7 +3,7 @@ import { ReactElement } from "react";
3
3
  import { PreferenceCardProps } from "./PreferenceCard";
4
4
  declare const meta: {
5
5
  title: string;
6
- component: ({ title, description, icon, input, firstTag, secondTag, disabled, loading, className, "data-testid": dataTestId, children, onClick, }: PreferenceCardProps) => import("react").ReactNode;
6
+ component: ({ title, description, icon, image, input, firstTag, secondTag, disabled, loading, className, "data-testid": dataTestId, children, onClick, }: PreferenceCardProps) => import("react").ReactNode;
7
7
  args: {};
8
8
  tags: string[];
9
9
  parameters: {
@@ -9,7 +9,9 @@ export interface PreferenceCardGroupProps extends CommonProps {
9
9
  /**
10
10
  * Include your card data here to showcase multiple PreferenceCard components
11
11
  */
12
- cards: Array<PreferenceCardProps>;
12
+ cards: Array<PreferenceCardProps & {
13
+ id: string;
14
+ }>;
13
15
  /**
14
16
  * The currently selected value(s)
15
17
  */
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./ConfirmationDialog/ConfirmationDialogContextProvider";
2
1
  export * from "./PreferenceCard";
2
+ export * from "./PreferenceCard/PreferenceCardGroup";
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var translation = {
4
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
5
- "confirmationDialog.default.primarybutton": "Confirm",
6
- "confirmationDialog.default.secondarybutton": "Cancel",
7
- "confirmationDialog.default.title": "Please confirm this action"
4
+
8
5
  };
9
6
 
10
7
  exports.default = translation;
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,8 +1,5 @@
1
1
  var translation = {
2
- "confirmationDialog.default.message": "Are you certain that you wish to proceed with this action?",
3
- "confirmationDialog.default.primarybutton": "Confirm",
4
- "confirmationDialog.default.secondarybutton": "Cancel",
5
- "confirmationDialog.default.title": "Please confirm this action"
2
+
6
3
  };
7
4
 
8
5
  export { translation as default };
@@ -1,10 +0,0 @@
1
- import { ReactElement, ReactNode } from "react";
2
- export interface ConfirmationDialogProviderProps {
3
- children: ReactNode;
4
- }
5
- /**
6
- * ConfirmationDialogContextProvider
7
- *
8
- * Provides confirmation dialog context and manages modal state with Promise-based resolution
9
- */
10
- export declare const ConfirmationDialogContextProvider: ({ children }: ConfirmationDialogProviderProps) => ReactElement;
@@ -1,12 +0,0 @@
1
- import { CommonProps } from "@trackunit/react-components";
2
- import { UseModalReturnValue } from "@trackunit/react-modal";
3
- import { ReactElement } from "react";
4
- import { ConfirmationDialogProps } from "./useConfirmationDialog.demo";
5
- export interface ConfirmationDialogModalProps extends Pick<ConfirmationDialogProps, "title" | "message" | "primaryActionLabel" | "secondaryActionLabel" | "primaryActionType">, UseModalReturnValue, CommonProps {
6
- handlePrimaryActionClick: () => void;
7
- handleSecondaryActionClick: () => void;
8
- }
9
- /**
10
- *
11
- */
12
- export declare const ConfirmationDialogModal: ({ title, message, handlePrimaryActionClick, handleSecondaryActionClick, secondaryActionLabel, primaryActionType, primaryActionLabel, ...modalProps }: ConfirmationDialogModalProps) => ReactElement;
@@ -1,41 +0,0 @@
1
- import { ConfirmationDialogProps as ConfirmationDialogPropsActual } from "@trackunit/iris-app-runtime-core-api";
2
- import { ReactElement, ReactNode } from "react";
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 | ReactNode;
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 UseConfirmationDialogDemoComponent: (props: ConfirmationDialogProps) => ReactElement;
@@ -1,18 +0,0 @@
1
- import { StoryObj } from "@storybook/react-webpack5";
2
- import { ReactElement } from "react";
3
- type Story = StoryObj<typeof meta>;
4
- declare const meta: {
5
- title: string;
6
- component: (props: import("./useConfirmationDialog.demo").ConfirmationDialogProps) => ReactElement;
7
- parameters: {
8
- docs: {
9
- source: {
10
- type: string;
11
- excludeDecorators: boolean;
12
- };
13
- };
14
- };
15
- };
16
- export default meta;
17
- export declare const PackageName: () => ReactElement;
18
- export declare const Default: Story;