@confidencesystemsinc/sdk 1.2.2 → 1.2.4

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/dist/components/playbook/confidence-playbook.d.ts +13 -7
  2. package/dist/components/playbook/playbook-header.d.ts +2 -2
  3. package/dist/hooks/usePlaybookExpandedTasks.d.ts +3 -1
  4. package/dist/index.cjs +15 -15
  5. package/dist/index.js +1439 -1415
  6. package/package.json +2 -3
  7. package/src/components/badge.tsx +0 -116
  8. package/src/components/initiate-playbook-modal/InitiatePlaybookModal.tsx +0 -53
  9. package/src/components/playbook/confidence-playbook.tsx +0 -346
  10. package/src/components/playbook/playbook-header.tsx +0 -32
  11. package/src/components/playbook-button/ConfidencePlaybookButton.tsx +0 -79
  12. package/src/components/task/confidence-task.tsx +0 -297
  13. package/src/components/task/task-buttons.tsx +0 -35
  14. package/src/components/task/task-dropdown-badge.tsx +0 -118
  15. package/src/components/task/task-expanded-content.tsx +0 -46
  16. package/src/components/task/task-left-panel.tsx +0 -60
  17. package/src/components/task/task-status-badge.tsx +0 -23
  18. package/src/components/ui/button.tsx +0 -272
  19. package/src/components/ui/input.tsx +0 -39
  20. package/src/components/ui/modal.tsx +0 -88
  21. package/src/components/ui/ui-wrapper.tsx +0 -7
  22. package/src/constants/settings.constants.ts +0 -4
  23. package/src/context/confidence-context.tsx +0 -25
  24. package/src/hooks/task/useCompleteTask.ts +0 -32
  25. package/src/hooks/task/useStartTask.ts +0 -35
  26. package/src/hooks/task/useTaskDetails.ts +0 -42
  27. package/src/hooks/usePlaybook.ts +0 -54
  28. package/src/hooks/usePlaybookActions.ts +0 -69
  29. package/src/hooks/usePlaybookExpandedTasks.ts +0 -35
  30. package/src/hooks/useTaskButtons.ts +0 -47
  31. package/src/index.ts +0 -7
  32. package/src/services/complete-task.service.ts +0 -25
  33. package/src/services/initiate-playbook.service.ts +0 -26
  34. package/src/services/start-task.services.ts +0 -27
  35. package/src/services/task-details.service.ts +0 -17
  36. package/src/stories/confidence-playbook.stories.tsx +0 -124
  37. package/src/stories/confidence-task.stories.tsx +0 -63
  38. package/src/stories/initiate-playbook-modal.stories.tsx +0 -31
  39. package/src/stories/modal.stories.tsx +0 -50
  40. package/src/task-description.css +0 -629
  41. package/src/theme.css +0 -11
  42. package/src/types/playbook.types.ts +0 -22
  43. package/src/types/task.types.ts +0 -20
  44. package/src/utils/cn.ts +0 -6
  45. package/src/vite-env.d.ts +0 -1
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@confidencesystemsinc/sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
- "dist",
9
- "src"
8
+ "dist"
10
9
  ],
11
10
  "exports": {
12
11
  ".": {
@@ -1,116 +0,0 @@
1
- import { type ComponentPropsWithoutRef, useMemo } from "react";
2
- import { twMerge } from "tailwind-merge";
3
-
4
- export const BadgeSolid = {
5
- white: "bg-white text-dark-300 border border-gray-300",
6
- primary: "bg-primary-600",
7
- secondary: "bg-secondary-500",
8
- success: "bg-success-600",
9
- info: "bg-info-500",
10
- warning: "bg-warning-500 text-gray-800",
11
- danger: "bg-danger-500",
12
- steel: "bg-steel-500",
13
- orange: "bg-orange-500",
14
- purple: "bg-purple-500",
15
- grayDark: "bg-gray-900",
16
- grayLight: "bg-gray-100 text-gray-800",
17
- } as const;
18
-
19
- export const BadgeOutline = {
20
- white: "text-white border border-white",
21
- primary: "text-primary-600 border border-primary-600",
22
- secondary: "text-secondary-500 border border-secondary-500",
23
- success: "text-success-600 border border-success-600",
24
- info: "text-info-500 border border-info-500",
25
- warning: "text-warning-500 border border-warning-500",
26
- danger: "text-danger-500 border border-danger-500",
27
- steel: "text-steel-500 border border-steel-500",
28
- orange: "text-orange-500 border border-orange-500",
29
- purple: "text-purple-500 border border-purple-500",
30
- grayDark: "text-gray-700 border border-gray-700",
31
- grayLight: "text-gray-500 border border-gray-100",
32
- } as const;
33
-
34
- const BadgeFontColor = {
35
- white: "text-dark-300",
36
- primary: "text-white",
37
- secondary: "text-white",
38
- success: "text-white",
39
- info: "text-black",
40
- warning: "text-gray-800",
41
- danger: "text-white",
42
- steel: "text-white",
43
- orange: "text-black",
44
- purple: "text-white",
45
- grayDark: "text-white",
46
- grayLight: "text-gray-800",
47
- } as const;
48
-
49
- export const BadgeRoundness = {
50
- normal: "rounded",
51
- pill: "rounded-pill",
52
- } as const;
53
-
54
- const BadgeSize = {
55
- big: "h-[24px] leading-[24px] text-md px-1",
56
- medium: "h-[22px] leading-[22px] text-sm px-[2px]",
57
- small: "h-[18px] leading-[18px] text-xs px-[2px]",
58
- } as const;
59
-
60
- export interface BadgeProps extends ComponentPropsWithoutRef<"div"> {
61
- category?: "solid" | "outline";
62
- color?: keyof typeof BadgeSolid;
63
- roundness?: keyof typeof BadgeRoundness;
64
- size?: keyof typeof BadgeSize;
65
- textClassName?: string;
66
- children: React.ReactNode;
67
- onClose?: () => void;
68
- onArrowClick?: () => void;
69
- className?: string;
70
- onCustomIconClick?: () => void;
71
- arrowTitle?: string;
72
- closeTitle?: string;
73
- }
74
-
75
- export const Badge = ({
76
- category = "solid",
77
- color = "primary",
78
- roundness = "normal",
79
- size = "medium",
80
- textClassName = "uppercase",
81
- children,
82
- className,
83
- ...rest
84
- }: BadgeProps) => {
85
- const fontColor = useMemo(
86
- () => BadgeFontColor[color] ?? "text-white",
87
- [color],
88
- );
89
- const BadgeClasses = useMemo(
90
- () =>
91
- twMerge(
92
- fontColor,
93
- category === "outline" ? BadgeOutline[color] : BadgeSolid[color],
94
- BadgeRoundness[roundness],
95
- BadgeSize[size],
96
- ),
97
- [fontColor, category, color, size, roundness],
98
- );
99
-
100
- return (
101
- <div
102
- className={twMerge(
103
- "ui-badge flex items-center font-bold",
104
- BadgeClasses,
105
- className,
106
- )}
107
- style={rest?.style}
108
- data-testid={`badge`}
109
- data-category={category}
110
- data-color={color}
111
- {...rest}
112
- >
113
- <p className={twMerge("mx-1", textClassName)}>{children}</p>
114
- </div>
115
- );
116
- };
@@ -1,53 +0,0 @@
1
- import { useState } from "react";
2
- import { Modal } from "../ui/modal";
3
- import { InputField } from "../ui/input";
4
-
5
- export const InitiatePlaybookModal = ({
6
- onConfirm,
7
- onClose,
8
- isOpen,
9
- title,
10
- }: {
11
- onConfirm: (email: string) => void | Promise<void>;
12
- onClose: () => void;
13
- isOpen: boolean;
14
- title?: string;
15
- }) => {
16
- const [email, setEmail] = useState("");
17
- const [isConfirming, setIsConfirming] = useState(false);
18
- const handleConfirm = async () => {
19
- if (email) {
20
- try {
21
- setIsConfirming(true);
22
- await onConfirm(email);
23
- setEmail(""); // Reset email after confirmation
24
- } finally {
25
- setIsConfirming(false);
26
- }
27
- } else {
28
- alert("Please enter a valid email address.");
29
- }
30
- };
31
- return (
32
- <Modal
33
- title={title || "Initiate Confidence Playbook"}
34
- isOpen={isOpen}
35
- close={onClose}
36
- dismissOptions={{ label: "Cancel", onClick: onClose }}
37
- confirmOptions={{
38
- label: "Initiate",
39
- onClick: handleConfirm,
40
- disabled: isConfirming || !email,
41
- }}
42
- >
43
- <>
44
- <InputField
45
- label="Email"
46
- disabled={isConfirming}
47
- description="Enter the email address to initiate the playbook."
48
- onChange={(e) => setEmail(e.target.value)}
49
- />
50
- </>
51
- </Modal>
52
- );
53
- };
@@ -1,346 +0,0 @@
1
- import { useEffect, useMemo, useRef, useState } from "react";
2
- import { ConfidenceContext } from "../../context/confidence-context";
3
- import { usePlaybook } from "../../hooks/usePlaybook";
4
- import { TASK_BUTTONS, TaskButton } from "../../hooks/useTaskButtons";
5
- import { initiatePlaybook } from "../../services/initiate-playbook.service";
6
- import { Playbook } from "../../types/playbook.types";
7
- import { TASK_STATUS } from "../../types/task.types";
8
- import { cn } from "../../utils/cn";
9
- import { ConfidencePlaybookButton } from "../playbook-button/ConfidencePlaybookButton";
10
- import { ConfidenceTask } from "../task/confidence-task";
11
- import { PlaybookHeader } from "./playbook-header";
12
- import ConfidenceLogo from "../../../public/confidence_logo.png";
13
- import { usePlaybookExpandedTasks } from "../../hooks/usePlaybookExpandedTasks";
14
- export interface ConfidencePlaybookStyleConfiguration {
15
- overlay?: {
16
- position?: "left" | "right";
17
- width?: number | string; // Use string to allow 'calc()' or other CSS values
18
- height?: number | string;
19
- right?: number; // For right positioning
20
- left?: number; // For left positioning
21
- };
22
- whiteLabel?: {
23
- titleBackgroundColor?: string;
24
- titleTextColor?: string;
25
- primaryColor?: string;
26
- };
27
- }
28
-
29
- const ConfidencePlaybookInternal = ({
30
- playbookInstanceId,
31
- playbookMode,
32
- playbookStyle,
33
- }: {
34
- playbookInstanceId: string | number;
35
- playbookMode: "list" | "card";
36
- playbookStyle?: ConfidencePlaybookStyleConfiguration;
37
- }) => {
38
- const { playbook, actions: playbookActions } =
39
- usePlaybook(playbookInstanceId);
40
-
41
- if (!playbook) {
42
- return <div></div>;
43
- }
44
-
45
- const handleButtonClick = async (buttonType: TaskButton, taskId: number) => {
46
- if (buttonType === TASK_BUTTONS.COMPLETE) {
47
- const sequenceOrder = playbook.tasks.find(
48
- (task) => task.taskInstanceId === taskId,
49
- )?.sequenceOrder;
50
- if (sequenceOrder === undefined) {
51
- console.error("Task not found in playbook");
52
- return;
53
- }
54
-
55
- return playbookActions.completeTask(taskId, sequenceOrder);
56
- }
57
-
58
- if (buttonType === TASK_BUTTONS.START) {
59
- return playbookActions.startTask(taskId);
60
- }
61
- };
62
-
63
- return (
64
- <PlaybookView
65
- playbook={playbook}
66
- playbookMode={playbookMode}
67
- onTaskButtonClick={handleButtonClick}
68
- playbookStyle={playbookStyle}
69
- />
70
- );
71
- };
72
-
73
- const TasksContainer = ({
74
- className,
75
- children,
76
- numberOfTasks,
77
- playbookMode,
78
- }: {
79
- className?: string;
80
- children: React.ReactNode;
81
- numberOfTasks?: number; // Default to 3 if not provided
82
- playbookMode: "list" | "card";
83
- }) => {
84
- return (
85
- <div className={cn("w-full p-4", className)}>
86
- {numberOfTasks && (
87
- <div className={cn(playbookMode === "card" && "mb-4")}>
88
- <span className="font-medium">Tasks</span> (3)
89
- </div>
90
- )}
91
- <div className={cn(playbookMode === "card" && "space-y-4")}>
92
- {children}
93
- </div>
94
- </div>
95
- );
96
- };
97
-
98
- const PlaybookView = ({
99
- playbook,
100
- playbookMode,
101
- onTaskButtonClick,
102
- playbookStyle,
103
- }: {
104
- playbookMode: "list" | "card";
105
- playbook: Playbook;
106
- onTaskButtonClick: (btn: TaskButton, taskId: number) => Promise<void>;
107
- playbookStyle?: ConfidencePlaybookStyleConfiguration;
108
- }) => {
109
- const { playbookInstanceName, tasks } = playbook;
110
- const playbookHeaderRef = useRef<HTMLDivElement>(null);
111
- const [playbookHeaderHeight, setPlaybookHeaderHeight] = useState(0);
112
- const { isTaskExpanded, toggleTaskExpanded } = usePlaybookExpandedTasks(
113
- playbook.playbookInstanceId,
114
- );
115
-
116
- useEffect(() => {
117
- if (playbookHeaderRef.current) {
118
- /** Setup a resize observer */
119
- const resizeObserver = new ResizeObserver((entries) => {
120
- for (const entry of entries) {
121
- console.log("ResizeObserver entry:", entry);
122
- if (entry.contentRect) {
123
- setPlaybookHeaderHeight(
124
- playbookHeaderRef.current?.offsetHeight || 0,
125
- );
126
- }
127
- }
128
- });
129
- resizeObserver.observe(playbookHeaderRef.current);
130
- }
131
-
132
- return () => {
133
- if (playbookHeaderRef.current) {
134
- /** Cleanup the resize observer */
135
- const resizeObserver = new ResizeObserver(() => {});
136
- resizeObserver.unobserve(playbookHeaderRef.current);
137
- }
138
- };
139
- }, [playbookHeaderRef]);
140
- const sequenceOrderToStart = useMemo(() => {
141
- const lastCompletedTask = tasks.find(
142
- (task) => task.workflowStatus === TASK_STATUS.COMPLETED,
143
- );
144
- if (!lastCompletedTask) {
145
- return 0;
146
- }
147
-
148
- return lastCompletedTask.sequenceOrder + 1;
149
- }, [tasks]);
150
-
151
- return (
152
- <div
153
- className={cn(
154
- !playbookStyle?.overlay && "min-h-screen",
155
- playbookStyle?.overlay && "fixed bottom-0 z-[99999999999999] flex",
156
- )}
157
- {...(playbookStyle?.overlay && {
158
- style: {
159
- width: playbookStyle.overlay.width || 450,
160
- height: playbookStyle.overlay.height || "calc(100vh - 4rem)",
161
- maxHeight: "calc(100vh - 4rem)",
162
- right:
163
- playbookStyle.overlay.right !== undefined
164
- ? playbookStyle.overlay.right
165
- : playbookStyle.overlay.position === "right"
166
- ? 32
167
- : undefined,
168
- left:
169
- playbookStyle.overlay.left !== undefined
170
- ? playbookStyle.overlay.left
171
- : playbookStyle.overlay.position === "left"
172
- ? 32
173
- : undefined,
174
- },
175
- })}
176
- >
177
- {playbookStyle?.overlay && (
178
- <div
179
- className={cn(
180
- "size-9 relative p-1 top-3 z-[99999999999999] border-none rounded-l-sm ",
181
- )}
182
- style={{
183
- backgroundColor:
184
- playbookStyle?.whiteLabel?.primaryColor || "#007BFF",
185
- boxShadow: "0px 3px 3px 0px #00000040",
186
- }}
187
- >
188
- <img
189
- src={ConfidenceLogo}
190
- alt="Confidence Logo"
191
- className="w-full h-full object-contain"
192
- />
193
- </div>
194
- )}
195
- <div
196
- className={cn(
197
- "flex flex-col flex-1 bg-gray-50",
198
- playbookStyle?.overlay &&
199
- "border border-gray-200 shadow-2xl rounded-t-sm overflow-y-auto",
200
- )}
201
- >
202
- <PlaybookHeader
203
- title={playbookInstanceName}
204
- className={cn("top-0 sticky z-2")}
205
- playbookStyle={playbookStyle}
206
- ref={playbookHeaderRef}
207
- />
208
-
209
- <TasksContainer
210
- playbookMode={playbookMode}
211
- numberOfTasks={playbook.numberofTasks}
212
- >
213
- {tasks.map((task, index) => {
214
- return (
215
- <ConfidenceTask
216
- key={index}
217
- task={task}
218
- step={index + 1}
219
- viewMode={playbookMode}
220
- playbookId={playbook.playbookId}
221
- canStart={task.sequenceOrder === sequenceOrderToStart}
222
- onButtonClick={(btn) => {
223
- return onTaskButtonClick(btn, task.taskInstanceId);
224
- }}
225
- playbookType={"Non-Sequential"}
226
- taskStyle={{
227
- titleColor: playbookStyle?.whiteLabel?.primaryColor,
228
- }}
229
- isExpanded={isTaskExpanded(task.taskInstanceId)}
230
- toggleExpanded={() => toggleTaskExpanded(task.taskInstanceId)}
231
- listStickyTopBase={playbookHeaderHeight || 104} // Adjust this value based on your header height
232
- />
233
- );
234
- })}
235
- </TasksContainer>
236
- </div>
237
- </div>
238
- );
239
- };
240
-
241
- const AutoInstantiated = ({
242
- email,
243
- playbookId,
244
- playbookMode,
245
- }: {
246
- email: string;
247
- playbookId: string;
248
- playbookMode: "list" | "card";
249
- }) => {
250
- const [playbookInstanceId, setPlaybookInstanceId] = useState<number | null>(
251
- null,
252
- );
253
-
254
- useEffect(() => {
255
- (async () => {
256
- const { playbookInstanceId, errorCode, details, message } =
257
- (await initiatePlaybook({
258
- bank: "public-sdk",
259
- email,
260
- timezone:
261
- Intl.DateTimeFormat().resolvedOptions().timeZone ||
262
- "America/Los_Angeles",
263
- playbookUid: playbookId,
264
- })) || {};
265
-
266
- if (errorCode) {
267
- throw new Error(
268
- `Error initiating playbook: ${message} (Code: ${errorCode}) - Details: ${details}`,
269
- );
270
- }
271
-
272
- setPlaybookInstanceId(playbookInstanceId);
273
- })();
274
- }, []);
275
-
276
- if (!playbookInstanceId) {
277
- return <div>Loading...</div>;
278
- }
279
-
280
- return (
281
- <ConfidencePlaybook
282
- playbookInstanceId={playbookInstanceId}
283
- playbookMode={playbookMode}
284
- />
285
- );
286
- };
287
-
288
- const WithInstantiateButton = ({
289
- playbookId,
290
- playbookMode = "list",
291
- playbookStyle,
292
- btnLabel = "Start Playbook",
293
- }: {
294
- playbookId: string;
295
- playbookMode?: "list" | "card";
296
- playbookStyle?: ConfidencePlaybookStyleConfiguration;
297
- btnLabel?: string;
298
- }) => {
299
- const [playbookInstanceId, setPlaybookInstanceId] = useState<number | null>(
300
- null,
301
- );
302
-
303
- return (
304
- <>
305
- <ConfidencePlaybookButton
306
- playbookId={playbookId}
307
- disabled={!!playbookInstanceId}
308
- onInitiated={setPlaybookInstanceId}
309
- btnLabel={btnLabel}
310
- />
311
-
312
- {playbookInstanceId && (
313
- <ConfidencePlaybook
314
- playbookInstanceId={playbookInstanceId}
315
- playbookMode={playbookMode}
316
- playbookStyle={playbookStyle}
317
- />
318
- )}
319
- </>
320
- );
321
- };
322
-
323
- export const ConfidencePlaybook = ({
324
- playbookInstanceId,
325
- playbookMode,
326
- playbookStyle,
327
- }: {
328
- playbookInstanceId: string | number;
329
- playbookMode: "list" | "card";
330
- playbookStyle?: ConfidencePlaybookStyleConfiguration;
331
- }) => {
332
- return (
333
- <ConfidenceContext>
334
- <ConfidencePlaybookInternal
335
- playbookInstanceId={playbookInstanceId}
336
- playbookMode={playbookMode}
337
- playbookStyle={playbookStyle}
338
- />
339
- </ConfidenceContext>
340
- );
341
- };
342
-
343
- ConfidencePlaybook.Context = ConfidenceContext;
344
- ConfidencePlaybook.View = PlaybookView;
345
- ConfidencePlaybook.AutoInstantiated = AutoInstantiated;
346
- ConfidencePlaybook.WithInstantiateButton = WithInstantiateButton;
@@ -1,32 +0,0 @@
1
- import { cn } from "../../utils/cn";
2
- import { type ConfidencePlaybookStyleConfiguration } from "./confidence-playbook";
3
-
4
- export const PlaybookHeader = ({
5
- title,
6
- className,
7
- playbookStyle,
8
- ...props
9
- }: React.ComponentProps<"div"> & {
10
- title: string;
11
- playbookStyle?: ConfidencePlaybookStyleConfiguration;
12
- }) => {
13
- return (
14
- <div
15
- className={cn("border-b border-gray-200 flex items-center", className)}
16
- style={{
17
- backgroundColor:
18
- playbookStyle?.whiteLabel?.titleBackgroundColor || "#f8f9fa",
19
- }}
20
- {...props}
21
- >
22
- <div
23
- className="text-xl min-h-16 p-4"
24
- style={{
25
- color: playbookStyle?.whiteLabel?.titleTextColor,
26
- }}
27
- >
28
- {title}
29
- </div>
30
- </div>
31
- );
32
- };
@@ -1,79 +0,0 @@
1
- import { useState } from "react";
2
- import { initiatePlaybook } from "../../services/initiate-playbook.service";
3
- import { InitiatePlaybookModal } from "../initiate-playbook-modal/InitiatePlaybookModal";
4
- import Button, { ButtonSizeType } from "../ui/button";
5
-
6
- export const ConfidencePlaybookButton = ({
7
- btnClassName,
8
- buttonNode,
9
- size,
10
- playbookId,
11
- onInitiated,
12
- disabled,
13
- btnLabel = "Run Playbook",
14
- }: {
15
- btnClassName?: string;
16
- buttonNode?: React.ReactNode;
17
- size?: ButtonSizeType;
18
- playbookId: string;
19
- disabled?: boolean;
20
- btnLabel?: string;
21
- onInitiated: (playbookInstanceId: number) => void;
22
- }) => {
23
- const [isOpen, setIsOpen] = useState(false);
24
-
25
- function open() {
26
- setIsOpen(true);
27
- }
28
-
29
- function close() {
30
- setIsOpen(false);
31
- }
32
-
33
- const onInitiatePlaybook = async (email: string) => {
34
- const { playbookInstanceId, errorCode, details, message } =
35
- (await initiatePlaybook({
36
- bank: "public-sdk",
37
- email,
38
- timezone:
39
- Intl.DateTimeFormat().resolvedOptions().timeZone ||
40
- "America/Los_Angeles",
41
- playbookUid: playbookId,
42
- })) || {};
43
-
44
- if (errorCode) {
45
- throw new Error(
46
- `Error initiating playbook: ${message} (Code: ${errorCode}) - Details: ${details}`,
47
- );
48
- }
49
-
50
- onInitiated(playbookInstanceId);
51
- };
52
-
53
- return (
54
- <>
55
- {buttonNode ? (
56
- { buttonNode }
57
- ) : (
58
- <Button
59
- onClick={open}
60
- className={btnClassName}
61
- color="primary"
62
- size={size}
63
- disabled={disabled}
64
- >
65
- {btnLabel}
66
- </Button>
67
- )}
68
-
69
- <InitiatePlaybookModal
70
- isOpen={isOpen}
71
- onClose={close}
72
- onConfirm={async (email) => {
73
- await onInitiatePlaybook(email);
74
- close();
75
- }}
76
- />
77
- </>
78
- );
79
- };