torch-glare 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +207 -0
  3. package/cli/bin/addComponent.js +278 -0
  4. package/cli/bin/addHooks.js +75 -0
  5. package/cli/bin/addLayout.js +71 -0
  6. package/cli/bin/addProvider.js +71 -0
  7. package/cli/bin/addUtils.js +74 -0
  8. package/cli/bin/cli.js +73 -0
  9. package/cli/bin/init/init.js +15 -0
  10. package/cli/bin/init/tailwindInit.js +174 -0
  11. package/cli/bin/update.js +147 -0
  12. package/lib/components/ActionButton.tsx +63 -0
  13. package/lib/components/ActionsGroup.tsx +34 -0
  14. package/lib/components/AlertDialog.tsx +211 -0
  15. package/lib/components/Badge.tsx +116 -0
  16. package/lib/components/BadgeField.tsx +192 -0
  17. package/lib/components/Button.tsx +277 -0
  18. package/lib/components/Card.tsx +63 -0
  19. package/lib/components/Checkbox.tsx +122 -0
  20. package/lib/components/CountBadge.tsx +54 -0
  21. package/lib/components/DatePicker.tsx +464 -0
  22. package/lib/components/Drawer.tsx +118 -0
  23. package/lib/components/DropdownMenu.tsx +399 -0
  24. package/lib/components/FieldHint.tsx +76 -0
  25. package/lib/components/ImageAttachment.tsx +180 -0
  26. package/lib/components/InnerLabelField.tsx +155 -0
  27. package/lib/components/Input.tsx +179 -0
  28. package/lib/components/InputField.tsx +147 -0
  29. package/lib/components/Label.tsx +107 -0
  30. package/lib/components/LabelField.tsx +75 -0
  31. package/lib/components/LabeledCheckBox.tsx +65 -0
  32. package/lib/components/LabeledRadio.tsx +45 -0
  33. package/lib/components/LinkButton.tsx +94 -0
  34. package/lib/components/LoginButton.tsx +56 -0
  35. package/lib/components/PasswordLevel.tsx +58 -0
  36. package/lib/components/Popover.tsx +274 -0
  37. package/lib/components/ProfileMenu.tsx +90 -0
  38. package/lib/components/Radio.tsx +77 -0
  39. package/lib/components/RadioCard.tsx +72 -0
  40. package/lib/components/RingLoading.tsx +190 -0
  41. package/lib/components/SearchField.tsx +49 -0
  42. package/lib/components/Select.tsx +417 -0
  43. package/lib/components/SlideDatePicker.tsx +120 -0
  44. package/lib/components/SpinLoading.tsx +190 -0
  45. package/lib/components/Switcher.tsx +56 -0
  46. package/lib/components/TabFormItem.tsx +158 -0
  47. package/lib/components/Table.tsx +395 -0
  48. package/lib/components/Textarea.tsx +108 -0
  49. package/lib/components/Tooltip.tsx +111 -0
  50. package/lib/components/TransparentLabel.tsx +72 -0
  51. package/lib/components/TreeDropDown.tsx +69 -0
  52. package/lib/hooks/MobileSlidePicker/components/Picker.tsx +218 -0
  53. package/lib/hooks/MobileSlidePicker/components/PickerColumn.tsx +238 -0
  54. package/lib/hooks/MobileSlidePicker/components/PickerItem.tsx +64 -0
  55. package/lib/hooks/MobileSlidePicker/index.ts +10 -0
  56. package/lib/hooks/useActiveTreeItem.tsx +61 -0
  57. package/lib/hooks/useClickOutside.tsx +20 -0
  58. package/lib/hooks/useResize.tsx +78 -0
  59. package/lib/layouts/CLayout.tsx +326 -0
  60. package/lib/layouts/FieldSection.tsx +64 -0
  61. package/lib/layouts/TreeSubLayout.tsx +187 -0
  62. package/lib/providers/ThemeProvider.tsx +99 -0
  63. package/lib/utils/cn.ts +6 -0
  64. package/lib/utils/convertImageFileToDataUrl.ts +17 -0
  65. package/lib/utils/resize.ts +35 -0
  66. package/lib/utils/types.ts +12 -0
  67. package/package.json +28 -0
  68. package/torch-glare.js +24 -0
@@ -0,0 +1,395 @@
1
+ 'use client'
2
+ import * as React from "react";
3
+ import { cn } from "../utils/cn";
4
+ import { cva, VariantProps } from "class-variance-authority";
5
+ import { useRef } from "react";
6
+ import { Button } from "./Button";
7
+ import { Checkbox } from "./Checkbox";
8
+ import { useResize } from "../hooks/useResize";
9
+
10
+ const tableHeadVariants = cva(
11
+ [
12
+ "text-content-presentation-global-primary",
13
+ "px-[8px]",
14
+ "w-full",
15
+ "flex",
16
+ "items-center",
17
+ "justify-center",
18
+ "text-start",
19
+ "bg-transparent",
20
+ "hover:bg-background-presentation-action-hover",
21
+ "hover:text-content-presentation-action-hover",
22
+ "transition-[background-color,color]",
23
+ "duration-200",
24
+ "rounded-[3px]",
25
+ ],
26
+ {
27
+ variants: {
28
+ size: {
29
+ S: "h-[20px] min-w-[20px] typography-body-small-semibold",
30
+ M: "h-[32px] min-w-[32px] typography-body-medium-semibold",
31
+ },
32
+ disabled: {
33
+ true: [
34
+ "bg-background-presentation-table-row-disabled",
35
+ "cursor-not-allowed",
36
+ "hover:bg-background-presentation-table-row-disabled",
37
+ "hover:text-content-presentation-global-primary",
38
+ ],
39
+ },
40
+ isDummy: {
41
+ true: [
42
+ "hover:bg-transparent",
43
+ "hover:text-content-presentation-global-primary",
44
+ ],
45
+ },
46
+ defaultVariants: {
47
+ size: "M",
48
+ },
49
+ },
50
+ }
51
+ );
52
+
53
+ type TableHeadVariantsProps = VariantProps<typeof tableHeadVariants>;
54
+
55
+ const Table = React.forwardRef<
56
+ HTMLTableElement,
57
+ React.HTMLAttributes<HTMLTableElement> & {
58
+ theme?: "dark" | "light" | "default";
59
+ }
60
+ >(({ className, theme, ...props }, ref) => (
61
+ <table
62
+ data-theme={theme}
63
+ ref={ref}
64
+ className={cn("overflow-hidden w-auto [border-collapse:separate] border-spacing-0", className)}
65
+ {...props}
66
+
67
+ >
68
+ {props.children}
69
+ </table>
70
+ ));
71
+ Table.displayName = "Table";
72
+
73
+ const TableHeader = React.forwardRef<
74
+ HTMLTableSectionElement,
75
+ React.HTMLAttributes<HTMLTableSectionElement>
76
+ >(({ className, ...props }, ref) => (
77
+ <thead
78
+ ref={ref}
79
+ className={cn(
80
+ "shadow-[0px_4px_8px_0px_rgba(0,0,0,0.15)]",
81
+ className
82
+ )}
83
+ {...props}
84
+ />
85
+ ));
86
+ TableHeader.displayName = "TableHeader";
87
+
88
+ const TableBody = React.forwardRef<
89
+ HTMLTableSectionElement,
90
+ React.HTMLAttributes<HTMLTableSectionElement>
91
+ >(({ className, ...props }, ref) => (
92
+ <tbody ref={ref} className={className} {...props}>
93
+ {props.children}
94
+ </tbody>
95
+ ));
96
+ TableBody.displayName = "TableBody";
97
+
98
+ const TableFooter = React.forwardRef<
99
+ HTMLTableSectionElement,
100
+ React.HTMLAttributes<HTMLTableSectionElement>
101
+ >(({ className, ...props }, ref) => (
102
+ <tfoot ref={ref} className={cn(className)} {...props} />
103
+ ));
104
+ TableFooter.displayName = "TableFooter";
105
+
106
+ const TableRow = React.forwardRef<
107
+ HTMLTableRowElement,
108
+ React.HTMLAttributes<HTMLTableRowElement> & {
109
+ state?: "delete" | "update" | "add" | "selected" | "open";
110
+ }
111
+ >(({ className, state = "", ...props }, ref) => (
112
+ <tr
113
+ ref={ref}
114
+ className={cn([
115
+ "[&_button]:hover:opacity-100 hover:bg-background-presentation-table-row-hover transition-colors",
116
+ {
117
+ "bg-background-presentation-table-row-negative border-border-presentation-badge-red":
118
+ state === "delete",
119
+ },
120
+ {
121
+ "bg-background-presentation-table-row-information border-border-presentation-badge-navy":
122
+ state === "update",
123
+ },
124
+ {
125
+ "bg-background-presentation-table-row-success border-border-presentation-badge-green":
126
+ state === "add",
127
+ },
128
+ {
129
+ "bg-background-presentation-table-row-selected border-t border-[2px] border-border-presentation-table-selected":
130
+ state === "selected",
131
+ },
132
+ {
133
+ "bg-background-presentation-table-row-hover border-t border-[2px] border-border-presentation-table-dropdown":
134
+ state === "open",
135
+ },
136
+ ], className)}
137
+ {...props}
138
+ >
139
+ {props.children}
140
+ </tr>
141
+ ));
142
+ TableRow.displayName = "TableRow";
143
+
144
+ const TableHead = React.forwardRef<
145
+ HTMLTableCellElement,
146
+ React.ThHTMLAttributes<HTMLTableCellElement> &
147
+ TableHeadVariantsProps &
148
+ React.ButtonHTMLAttributes<HTMLButtonElement> & {
149
+ sortType?: "asc" | "desc" | undefined;
150
+ onSort?: () => void;
151
+ isDummy?: boolean;
152
+ }
153
+ >(
154
+ (
155
+ { className, size = "M", disabled, sortType, onSort, isDummy, ...props },
156
+ forwardedRef
157
+ ) => {
158
+ const headRef = useRef<any>(null);
159
+ const { width, handleStartResize } = useResize(headRef);
160
+
161
+ // Combine refs using useEffect
162
+ React.useEffect(() => {
163
+ if (!forwardedRef) return;
164
+ if (typeof forwardedRef === "function") forwardedRef(headRef.current);
165
+ else forwardedRef.current = headRef.current;
166
+ }, [forwardedRef]);
167
+
168
+ return (
169
+ <th
170
+ ref={headRef}
171
+ className={cn(
172
+ "relative py-[2px] px-[2px] border-b-[2px] border-border-presentation-table-header",
173
+ )}
174
+ >
175
+ <div
176
+ {...props}
177
+ className={cn(
178
+ tableHeadVariants({ size, disabled, isDummy }),
179
+ { "min-w-[200px]": !isDummy },
180
+ className
181
+ )}
182
+ >
183
+ <div
184
+ style={{ width: `${width}px` }}
185
+ className={cn("flex items-center justify-between flex-1", {
186
+ "justify-center": isDummy,
187
+ })}
188
+ >
189
+ {props.children}
190
+ {isDummy || !onSort ? null : <SortButton onSort={onSort} sortType={sortType} />}
191
+ </div>
192
+ </div>
193
+ {!isDummy && (
194
+ <button className="absolute top-[50%] translate-y-[-50%] right-[-1px] rtl:left-[-1px] rtl:right-[unset] h-[20px] w-[2px] rounded-full bg-border-presentation-action-primary">
195
+ <ResizeIcon
196
+ onMouseDown={handleStartResize}
197
+ onTouchStart={handleStartResize}
198
+ />
199
+ </button>
200
+ )}
201
+
202
+ </th>
203
+ );
204
+ }
205
+ );
206
+ TableHead.displayName = "TableHead";
207
+
208
+ const TableCell = React.forwardRef<
209
+ HTMLTableCellElement,
210
+ React.TdHTMLAttributes<HTMLTableCellElement> & {
211
+ isDummy?: boolean;
212
+ childrenClassName?: string;
213
+ className?: string;
214
+ }
215
+ >(({ className, childrenClassName, isDummy, ...props }, ref) => (
216
+ <td
217
+ ref={ref}
218
+ className={cn(
219
+ [
220
+ "h-[40px] text-content-presentation-action-light-primary",
221
+ "typography-body-small-regular relative",
222
+ "border-r border-b border-border-presentation-table-header px-1 rtl:border-l rtl:border-r-0",
223
+ "break-all",
224
+ ],
225
+ { "border-x-0": isDummy },
226
+ className
227
+ )}
228
+ {...props}
229
+ >
230
+ <div
231
+ className={cn(
232
+ "flex justify-start items-center gap-1 w-[200px] min-w-full overflow-hidden",
233
+ "[mask-image:linear-gradient(to_right,black_0%,black_0%,black_75%,transparent_100%)]",
234
+ "rtl:[mask-image:linear-gradient(to_left,black_0%,black_0%,black_75%,transparent_100%)]",
235
+ { "w-auto justify-center": isDummy }, childrenClassName)}
236
+ >
237
+ {props.children}
238
+ </div>
239
+ </td>
240
+ ));
241
+ TableCell.displayName = "TableCell";
242
+
243
+ const TableCheckbox = React.forwardRef<
244
+ HTMLInputElement,
245
+ React.InputHTMLAttributes<HTMLInputElement> & {
246
+ id: string;
247
+ }
248
+ >(({ className, id, ...props }, ref) => {
249
+ return (
250
+ <div className={cn(["flex items-center justify-center"], className)}>
251
+ <Checkbox {...props} ref={ref} size="S" />
252
+ </div>
253
+ );
254
+ });
255
+ TableCheckbox.displayName = "TableCheckbox";
256
+
257
+ const TableCaption = React.forwardRef<
258
+ HTMLTableCaptionElement,
259
+ React.HTMLAttributes<HTMLTableCaptionElement>
260
+ >(({ className, ...props }, ref) => (
261
+ <caption
262
+ ref={ref}
263
+ className={cn("mt-4 text-sm text-muted-foreground", className)}
264
+ {...props}
265
+ />
266
+ ));
267
+ TableCaption.displayName = "TableCaption";
268
+
269
+ const TableFooterButton = React.forwardRef<
270
+ HTMLButtonElement,
271
+ React.PropsWithChildren<{
272
+ className?: string;
273
+ }>
274
+ >(({ children, className, ...props }, ref) => {
275
+ return (
276
+ <TableRow
277
+ className={cn(
278
+ "h-[40px] overflow-hidden",
279
+ className
280
+ )}
281
+ >
282
+ <TableCell
283
+ className={
284
+ "border-t-2 border-b-2 border-transparent hover:border-border-presentation-table-action-hover hover:bg-background-presentation-table-acton-hover"}
285
+ colSpan={100}
286
+ >
287
+ <button
288
+ ref={ref}
289
+ {...props}
290
+ className={cn(
291
+ "overflow-hidden w-full flex items-center justify-start gap-2 typography-body-medium-semibold [&_i]:text-[20px]",
292
+ className
293
+ )}
294
+ >{children}</button>
295
+ </TableCell>
296
+ </TableRow>
297
+ );
298
+ });
299
+ TableFooterButton.displayName = "TableFooterButton";
300
+
301
+
302
+ const SubTableButton = ({
303
+ isActive,
304
+ className,
305
+ dummy,
306
+ }: {
307
+ isActive?: boolean;
308
+ className?: string;
309
+ dummy?: boolean;
310
+ }) => {
311
+ return (
312
+ <Button
313
+ className={cn(
314
+ "transition-opacity duration-200 opacity-0 border-none bg-transparent focus:bg-background-presentation-state-information-primary active:bg-background-presentation-state-information-primary",
315
+ {
316
+ "hover:bg-transparent hover:text-black focus:bg-transparent focus:text-black active:bg-transparent active:text-black":
317
+ dummy,
318
+ },
319
+ className
320
+ )}
321
+ variant={"PrimeStyle"}
322
+ buttonType={"icon"}
323
+ >
324
+ <i
325
+ className={cn(
326
+ "ri-arrow-right-s-line",
327
+ "rtl:rotate-180",
328
+ "transition-transform duration-200",
329
+ { "rotate-90": isActive }
330
+ )}
331
+ ></i>
332
+ </Button>
333
+ );
334
+ };
335
+
336
+ export {
337
+ Table,
338
+ TableHeader,
339
+ TableBody,
340
+ TableFooter,
341
+ TableHead,
342
+ TableRow,
343
+ TableCell,
344
+ TableCaption,
345
+ TableCheckbox,
346
+ SubTableButton,
347
+ TableFooterButton,
348
+ };
349
+
350
+ const ResizeIcon = (props: any) => {
351
+ return (
352
+ <svg
353
+ {...props}
354
+ className="z-50 cursor-col-resize absolute top-[50%] right-[50%] translate-x-[50%] translate-y-[-50%] opacity-0 hover:opacity-100 transition-opacity duration-200"
355
+ width="8"
356
+ height="32"
357
+ viewBox="0 0 8 40"
358
+ fill="none"
359
+ xmlns="http://www.w3.org/2000/svg"
360
+ >
361
+ <rect {...props} y="5" width="8" height="30" rx="3" fill="#3391FF" />
362
+ <circle {...props} cx="2.75" cy="15.5" r="0.75" fill="#F9F9F9" />
363
+ <circle {...props} cx="5.25" cy="15.5" r="0.75" fill="#F9F9F9" />
364
+ <circle {...props} cx="2.75" cy="18.5" r="0.75" fill="#F9F9F9" />
365
+ <circle {...props} cx="5.25" cy="18.5" r="0.75" fill="#F9F9F9" />
366
+ <circle {...props} cx="2.75" cy="21.5" r="0.75" fill="#F9F9F9" />
367
+ <circle {...props} cx="5.25" cy="21.5" r="0.75" fill="#F9F9F9" />
368
+ <circle {...props} cx="2.75" cy="24.5" r="0.75" fill="#F9F9F9" />
369
+ <circle {...props} cx="5.25" cy="24.5" r="0.75" fill="#F9F9F9" />
370
+ </svg>
371
+ );
372
+ };
373
+
374
+ const SortButton = ({
375
+ onSort,
376
+ sortType,
377
+ }: {
378
+ onSort?: () => void;
379
+ sortType?: "asc" | "desc" | undefined;
380
+ }) => {
381
+ return (
382
+ <button
383
+ className={cn("cursor-pointer text-[16px] z-10")}
384
+ onPointerDown={onSort}
385
+ >
386
+ {sortType === "asc" ? (
387
+ <i className="ri-arrow-up-line text-border-presentation-state-focus" />
388
+ ) : sortType === "desc" ? (
389
+ <i className="ri-arrow-down-line text-border-presentation-state-focus" />
390
+ ) : (
391
+ <i className="ri-arrow-up-down-line text-content-presentation-global-secondary" />
392
+ )}
393
+ </button>
394
+ );
395
+ };
@@ -0,0 +1,108 @@
1
+ import * as React from "react";
2
+ import { cn } from "../utils/cn";
3
+ import { Label } from "./Label";
4
+ import { cva, VariantProps } from "class-variance-authority";
5
+
6
+ // Define the styles for the textarea using cva
7
+ const textareaStyles = cva(
8
+ [
9
+ "w-full",
10
+ "border",
11
+ "rounded-[4px]",
12
+ "px-[8px]",
13
+ "py-[12px]",
14
+ "outline-none",
15
+ "typography-body-small-regular",
16
+ "!min-h-[36px]",
17
+ "transition-[border,background-color,color,caret-color,box-shadow]",
18
+ "ease-in-out",
19
+ "duration-150",
20
+ "text-content-presentation-action-light-primary",
21
+ "caret-border-presentation-state-focus",
22
+ "border-border-presentation-action-primary",
23
+ "bg-background-presentation-form-field-primary",
24
+ "hover:border-border-presentation-action-hover",
25
+ "hover:bg-background-presentation-form-field-hover",
26
+ "focus:border-border-presentation-state-focus",
27
+ "hover:shadow-[0px_1px_6px_0px_rgba(0,0,0,0.30)]",
28
+ "disabled:border-border-presentation-action-disabled",
29
+ "disabled:bg-background-presentation-action-disabled",
30
+ "disabled:text-border-presentation-action-disabled",
31
+ "disabled:cursor-not-allowed",
32
+ "disabled:placeholder-border-presentation-action-disabled",
33
+ ],
34
+ {
35
+ variants: {
36
+ state: {
37
+ negative: [
38
+ "border-border-presentation-state-negative",
39
+ "caret-border-presentation-state-negative",
40
+ "hover:border-border-presentation-state-negative",
41
+ "focus:border-border-presentation-state-negative",
42
+ ],
43
+ },
44
+ },
45
+ defaultVariants: {},
46
+ }
47
+ );
48
+
49
+ // Define the prop types for the Textarea component
50
+ interface TextareaProps
51
+ extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
52
+ VariantProps<typeof textareaStyles> {
53
+ label?: string; // Optional label text
54
+ requiredLabel?: string; // Text for required field indicator
55
+ secondaryLabel?: string; // Additional label text
56
+ direction?: "row" | "column";
57
+ theme?: "dark" | "light" | "default";
58
+ }
59
+
60
+ // Textarea component definition
61
+ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
62
+ (
63
+ {
64
+ className,
65
+ state, // Default state for textarea
66
+ label,
67
+ requiredLabel,
68
+ secondaryLabel,
69
+ direction = "row",
70
+ theme,
71
+ ...props
72
+ },
73
+ ref
74
+ ) => {
75
+ return (
76
+ <div
77
+ data-theme={theme}
78
+ className={cn(
79
+ "flex gap-[4px]",
80
+ {
81
+ "flex-col": direction === "column",
82
+ "flex-row items-start gap-[10px]": direction === "row",
83
+ },
84
+ className
85
+ )}
86
+ >
87
+ <Label
88
+ label={label}
89
+ requiredLabel={requiredLabel}
90
+ secondaryLabel={secondaryLabel}
91
+ directions={direction === "row" ? "vertical" : "horizontal"}
92
+ className={cn({
93
+ "pt-[9px]": direction === "row",
94
+ })}
95
+ size={"M"}
96
+ />
97
+ <textarea
98
+ className={cn(textareaStyles({ state }), className)}
99
+ ref={ref}
100
+ {...props}
101
+ />
102
+ </div>
103
+ );
104
+ }
105
+ );
106
+ Textarea.displayName = "Textarea";
107
+
108
+ export { Textarea };
@@ -0,0 +1,111 @@
1
+ import { cva, VariantProps } from "class-variance-authority";
2
+ import { ReactNode } from "react";
3
+ import { cn } from "../utils/cn";
4
+ import { Themes } from "../utils/types";
5
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
6
+ import React from "react";
7
+
8
+
9
+ const TooltipProvider = TooltipPrimitive.Provider
10
+
11
+ const ToolTipRoot = TooltipPrimitive.Root
12
+
13
+ const TooltipTrigger = TooltipPrimitive.Trigger
14
+
15
+ const TooltipContent = React.forwardRef<
16
+ React.ElementRef<typeof TooltipPrimitive.Content>,
17
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
18
+ >(({ className, sideOffset = 4, ...props }, ref) => (
19
+ <TooltipPrimitive.Portal>
20
+ <TooltipPrimitive.Content
21
+ ref={ref}
22
+ sideOffset={sideOffset}
23
+ className={cn(
24
+ "z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
25
+ className
26
+ )}
27
+ {...props}
28
+ />
29
+ </TooltipPrimitive.Portal>
30
+ ))
31
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName
32
+
33
+ const TooltipArrow = TooltipPrimitive.Arrow
34
+ export type ToolTipSide = "top" | "right" | "bottom" | "left";
35
+
36
+ export enum ContentAlign {
37
+ START = "start",
38
+ CENTER = "center",
39
+ END = "end",
40
+ }
41
+
42
+ const tooltipStyles = cva("typography-body-medium-regular rounded-[4px] p-1", {
43
+ variants: {
44
+ variant: {
45
+ primary: "bg-background-system-body-tertiary text-content-system-global-primary",
46
+ highlight: "bg-gradient-to-r from-wavy-navy-900 to-wavy-navy-800 text-white"
47
+ },
48
+ },
49
+ defaultVariants: {
50
+ variant: "primary",
51
+ },
52
+ });
53
+
54
+ interface TooltipProps
55
+ extends React.HTMLAttributes<HTMLSpanElement>,
56
+ VariantProps<typeof tooltipStyles> {
57
+ onOpenChange?: (open: boolean) => void;
58
+ open?: boolean;
59
+ toolTipSide?: ToolTipSide;
60
+ contentAlign?: ContentAlign;
61
+ avoidCollisions?: boolean;
62
+ tip?: boolean;
63
+ delay?: number;
64
+ disabled?: boolean;
65
+ text: ReactNode;
66
+ theme?: Themes
67
+ }
68
+
69
+ const Tooltip: React.FC<TooltipProps> = ({
70
+ children,
71
+ open,
72
+ text,
73
+ theme = "dark",
74
+ onOpenChange,
75
+ toolTipSide,
76
+ contentAlign = ContentAlign.CENTER,
77
+ avoidCollisions = true,
78
+ delay = 400,
79
+ tip = true,
80
+ variant,
81
+ className,
82
+ ...props
83
+ }) => {
84
+ return (
85
+ <TooltipProvider>
86
+ <ToolTipRoot delayDuration={delay} {...(typeof open !== "undefined" && { open })} {...(onOpenChange && { onOpenChange })}>
87
+ <TooltipTrigger aria-label="Open tooltip" asChild>
88
+ {children}
89
+ </TooltipTrigger>
90
+
91
+ <TooltipContent
92
+ data-theme={theme}
93
+ sideOffset={2}
94
+ side={toolTipSide}
95
+ align={contentAlign}
96
+ avoidCollisions={avoidCollisions}
97
+ className={cn(tooltipStyles({ variant, className }))}
98
+ {...props}
99
+ >
100
+ {text}
101
+ {tip && <TooltipArrow className={cn("fill-background-system-body-tertiary", {
102
+ "fill-wavy-navy-900": variant === "highlight"
103
+ })} />}
104
+ </TooltipContent>
105
+ </ToolTipRoot>
106
+ </TooltipProvider>
107
+ );
108
+ };
109
+
110
+
111
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, TooltipArrow, ToolTipRoot }
@@ -0,0 +1,72 @@
1
+ import { cn } from "../utils/cn";
2
+ import { cva, type VariantProps } from "class-variance-authority";
3
+ import { HTMLAttributes } from "react";
4
+
5
+ export const TransparentLabelStyles = cva(
6
+ "[mask-image:linear-gradient(to_right,black_0%,black_0%,black_85%,transparent_100%)] rtl:[mask-image:linear-gradient(to_left,black_0%,black_0%,black_85%,transparent_100%)]",
7
+ {
8
+ variants: {
9
+ size: {
10
+ "display-large-bold": "typography-display-large-bold",
11
+ "display-large-semibold": "typography-display-large-semibold",
12
+ "display-large-medium": "typography-display-large-medium",
13
+ "display-large-regular": "typography-display-large-regular",
14
+ "display-medium-bold": "typography-display-medium-bold",
15
+ "display-medium-semibold": "typography-display-medium-semibold",
16
+ "display-medium-medium": "typography-display-medium-medium",
17
+ "display-medium-regular": "typography-display-medium-regular",
18
+ "display-small-bold": "typography-display-small-bold",
19
+ "display-small-semibold": "typography-display-small-semibold",
20
+ "display-small-medium": "typography-display-small-medium",
21
+ "display-small-regular": "typography-display-small-regular",
22
+ "headers-large-bold": "typography-headers-large-bold",
23
+ "headers-large-semibold": "typography-headers-large-semibold",
24
+ "headers-large-medium": "typography-headers-large-medium",
25
+ "headers-large-regular": "typography-headers-large-regular",
26
+ "headers-medium-bold": "typography-headers-medium-bold",
27
+ "headers-medium-semibold": "typography-headers-medium-semibold",
28
+ "headers-medium-medium": "typography-headers-medium-medium",
29
+ "headers-medium-regular": "typography-headers-medium-regular",
30
+ "headers-small-bold": "typography-headers-small-bold",
31
+ "headers-small-semibold": "typography-headers-small-semibold",
32
+ "headers-small-medium": "typography-headers-small-medium",
33
+ "headers-small-regular": "typography-headers-small-regular",
34
+ "body-large-bold": "typography-body-large-bold",
35
+ "body-large-semibold": "typography-body-large-semibold",
36
+ "body-large-medium": "typography-body-large-medium",
37
+ "body-large-regular": "typography-body-large-regular",
38
+ "body-medium-bold": "typography-body-medium-bold",
39
+ "body-medium-semibold": "typography-body-medium-semibold",
40
+ "body-medium-medium": "typography-body-medium-medium",
41
+ "body-medium-regular": "typography-body-medium-regular",
42
+ "body-small-bold": "typography-body-small-bold",
43
+ "body-small-semibold": "typography-body-small-semibold",
44
+ "body-small-medium": "typography-body-small-medium",
45
+ "body-small-regular": "typography-body-small-regular",
46
+ "labels-large-bold": "typography-labels-large-bold",
47
+ "labels-large-semibold": "typography-labels-large-semibold",
48
+ "labels-large-medium": "typography-labels-large-medium",
49
+ "labels-large-regular": "typography-labels-large-regular",
50
+ "labels-medium-bold": "typography-labels-medium-bold",
51
+ "labels-medium-semibold": "typography-labels-medium-semibold",
52
+ "labels-medium-medium": "typography-labels-medium-medium",
53
+ "labels-medium-regular": "typography-labels-medium-regular",
54
+ "labels-small-bold": "typography-labels-small-bold",
55
+ "labels-small-semibold": "typography-labels-small-semibold",
56
+ "labels-small-medium": "typography-labels-small-medium",
57
+ "labels-small-regular": "typography-labels-small-regular",
58
+ },
59
+ },
60
+ defaultVariants: {
61
+ size: "body-medium-regular",
62
+ }
63
+ }
64
+ );
65
+
66
+ interface Props extends HTMLAttributes<HTMLParagraphElement>, VariantProps<typeof TransparentLabelStyles> { }
67
+
68
+ export const TransparentLabel = ({ size, className, ...props }: Props) => {
69
+ return (
70
+ <p {...props} className={cn(TransparentLabelStyles({ size }), className)}></p>
71
+ );
72
+ };