@cryptlex/web-components 5.2.0 → 5.3.0

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 (121) hide show
  1. package/dist/components/data-table/data-table-filter.d.ts +27 -0
  2. package/dist/components/data-table/data-table-filter.js +112 -0
  3. package/dist/components/data-table/data-table.d.ts +73 -0
  4. package/dist/components/data-table/data-table.js +265 -0
  5. package/dist/components/data-table/table-commons.d.ts +56 -0
  6. package/dist/components/data-table/table-commons.js +137 -0
  7. package/dist/components/inputs/checkbox.d.ts +8 -0
  8. package/dist/components/inputs/checkbox.js +25 -0
  9. package/dist/components/inputs/date-picker.d.ts +11 -0
  10. package/dist/components/inputs/date-picker.js +22 -0
  11. package/dist/components/inputs/datefield.d.ts +14 -0
  12. package/dist/components/inputs/datefield.js +25 -0
  13. package/dist/components/inputs/field.d.ts +21 -0
  14. package/dist/components/inputs/field.js +48 -0
  15. package/dist/components/inputs/id-search.d.ts +20 -0
  16. package/dist/components/inputs/id-search.js +40 -0
  17. package/dist/components/inputs/input-otp.d.ts +8 -0
  18. package/dist/components/inputs/input-otp.js +19 -0
  19. package/dist/components/inputs/multi-select.d.ts +17 -0
  20. package/dist/components/inputs/multi-select.js +18 -0
  21. package/dist/components/inputs/numberfield.d.ts +7 -0
  22. package/dist/components/inputs/numberfield.js +25 -0
  23. package/dist/components/inputs/searchfield.d.ts +5 -0
  24. package/dist/components/inputs/searchfield.js +24 -0
  25. package/dist/components/inputs/select-options.d.ts +8 -0
  26. package/dist/components/inputs/select-options.js +286 -0
  27. package/dist/components/inputs/select.d.ts +17 -0
  28. package/dist/components/inputs/select.js +34 -0
  29. package/dist/components/inputs/textfield.d.ts +7 -0
  30. package/dist/components/inputs/textfield.js +28 -0
  31. package/dist/components/key-value-card/key-value-card.d.ts +17 -0
  32. package/dist/components/key-value-card/key-value-card.js +40 -0
  33. package/dist/components/ui/alert.d.ts +8 -0
  34. package/dist/components/ui/alert.js +18 -0
  35. package/dist/components/ui/avatar.d.ts +8 -0
  36. package/dist/components/ui/avatar.js +5 -0
  37. package/dist/components/ui/badge.d.ts +2 -0
  38. package/dist/components/ui/badge.js +5 -0
  39. package/dist/components/ui/breadcrumbs.d.ts +10 -0
  40. package/dist/components/ui/breadcrumbs.js +28 -0
  41. package/dist/components/ui/button.d.ts +11 -0
  42. package/dist/components/ui/button.js +34 -0
  43. package/dist/components/ui/calendar.d.ts +17 -0
  44. package/dist/components/ui/calendar.js +63 -0
  45. package/dist/components/ui/card.d.ts +7 -0
  46. package/dist/components/ui/card.js +20 -0
  47. package/dist/components/ui/dialog.d.ts +19 -0
  48. package/dist/components/ui/dialog.js +42 -0
  49. package/dist/components/ui/disclosure.d.ts +19 -0
  50. package/dist/components/ui/disclosure.js +20 -0
  51. package/dist/components/ui/list-box.d.ts +5 -0
  52. package/dist/components/ui/list-box.js +24 -0
  53. package/dist/components/ui/loader.d.ts +5 -0
  54. package/dist/components/ui/loader.js +6 -0
  55. package/dist/components/ui/menu.d.ts +25 -0
  56. package/dist/components/ui/menu.js +38 -0
  57. package/dist/components/ui/popover.d.ts +4 -0
  58. package/dist/components/ui/popover.js +14 -0
  59. package/dist/components/ui/sidebar.d.ts +53 -0
  60. package/dist/components/ui/sidebar.js +177 -0
  61. package/dist/components/ui/skeleton.d.ts +1 -0
  62. package/dist/components/ui/skeleton.js +5 -0
  63. package/dist/components/ui/sonner.d.ts +4 -0
  64. package/dist/components/ui/sonner.js +14 -0
  65. package/dist/components/ui/table.d.ts +9 -0
  66. package/dist/components/ui/table.js +26 -0
  67. package/dist/components/ui/tabs.d.ts +5 -0
  68. package/dist/components/ui/tabs.js +25 -0
  69. package/dist/components/ui/timeline.d.ts +15 -0
  70. package/dist/components/ui/timeline.js +31 -0
  71. package/dist/components/ui/tooltip.d.ts +4 -0
  72. package/dist/components/ui/tooltip.js +12 -0
  73. package/dist/utils/form-context.d.ts +4 -0
  74. package/{lib/utils/form-context.tsx → dist/utils/form-context.js} +1 -3
  75. package/dist/utils/form-hook.d.ts +25 -0
  76. package/{lib/utils/form-hook.tsx → dist/utils/form-hook.js} +15 -18
  77. package/dist/utils/primitives.d.ts +30 -0
  78. package/{lib/utils/primitives.ts → dist/utils/primitives.js} +8 -37
  79. package/dist/utils/resource-names.d.ts +23 -0
  80. package/{lib/utils/resource-names.tsx → dist/utils/resource-names.js} +42 -75
  81. package/dist/utils/use-mobile.d.ts +1 -0
  82. package/dist/utils/use-mobile.js +15 -0
  83. package/package.json +10 -5
  84. package/lib/components/data-table/data-table-filter.tsx +0 -220
  85. package/lib/components/data-table/data-table.tsx +0 -593
  86. package/lib/components/data-table/table-commons.tsx +0 -233
  87. package/lib/components/inputs/checkbox.tsx +0 -72
  88. package/lib/components/inputs/date-picker.tsx +0 -130
  89. package/lib/components/inputs/datefield.tsx +0 -109
  90. package/lib/components/inputs/field.tsx +0 -106
  91. package/lib/components/inputs/id-search.tsx +0 -83
  92. package/lib/components/inputs/input-otp.tsx +0 -63
  93. package/lib/components/inputs/multi-select.tsx +0 -62
  94. package/lib/components/inputs/numberfield.tsx +0 -110
  95. package/lib/components/inputs/searchfield.tsx +0 -87
  96. package/lib/components/inputs/select-options.tsx +0 -303
  97. package/lib/components/inputs/select.tsx +0 -140
  98. package/lib/components/inputs/textfield.tsx +0 -96
  99. package/lib/components/key-value-card/key-value-card.tsx +0 -115
  100. package/lib/components/ui/alert.tsx +0 -32
  101. package/lib/components/ui/avatar.tsx +0 -22
  102. package/lib/components/ui/badge.tsx +0 -19
  103. package/lib/components/ui/breadcrumbs.tsx +0 -104
  104. package/lib/components/ui/button.tsx +0 -66
  105. package/lib/components/ui/calendar.tsx +0 -220
  106. package/lib/components/ui/card.tsx +0 -58
  107. package/lib/components/ui/dialog.tsx +0 -172
  108. package/lib/components/ui/disclosure.tsx +0 -113
  109. package/lib/components/ui/list-box.tsx +0 -86
  110. package/lib/components/ui/loader.tsx +0 -10
  111. package/lib/components/ui/menu.tsx +0 -168
  112. package/lib/components/ui/popover.tsx +0 -37
  113. package/lib/components/ui/sidebar.tsx +0 -552
  114. package/lib/components/ui/skeleton.tsx +0 -7
  115. package/lib/components/ui/sonner.tsx +0 -26
  116. package/lib/components/ui/table.tsx +0 -79
  117. package/lib/components/ui/tabs.tsx +0 -82
  118. package/lib/components/ui/timeline.tsx +0 -52
  119. package/lib/components/ui/tooltip.tsx +0 -30
  120. package/lib/tokens.scss +0 -89
  121. package/lib/utils/use-mobile.tsx +0 -21
@@ -1,140 +0,0 @@
1
- "use client"
2
- import {
3
- ListBox as AriaListBox,
4
- ListBoxProps as AriaListBoxProps,
5
- PopoverProps as AriaPopoverProps,
6
- Select as AriaSelect,
7
- SelectProps as AriaSelectProps,
8
- SelectValue as AriaSelectValue,
9
- SelectValueProps as AriaSelectValueProps,
10
- composeRenderProps
11
- } from "react-aria-components"
12
-
13
- import { FormField, type FormFieldProps } from "lib/components/inputs/field"
14
- import type { SelectOption } from "lib/components/inputs/select-options"
15
- import { Button } from "lib/components/ui/button"
16
- import { useFieldContext } from "lib/utils/form-context"
17
- import { getFieldErrorMessage } from "lib/utils/form-hook"
18
- import { cn } from "lib/utils/primitives"
19
- import { ChevronDown } from "lucide-react"
20
- import {
21
- ListBoxCollection,
22
- ListBoxHeader,
23
- ListBoxItem,
24
- } from "../ui/list-box"
25
- import { Popover } from "../ui/popover"
26
-
27
- const ASelect = AriaSelect
28
- export const SelectItem = ListBoxItem
29
- export const SelectHeader = ListBoxHeader
30
- export const SelectCollection = ListBoxCollection
31
-
32
- export const SelectValue = <T extends object>({
33
- className,
34
- ...props
35
- }: AriaSelectValueProps<T>) => (
36
- <AriaSelectValue
37
- className={composeRenderProps(className, (className) =>
38
- cn(
39
- "line-clamp-1 data-[placeholder]:text-muted-foreground",
40
- /* Description */
41
- "[&>[slot=description]]:hidden",
42
- className
43
- )
44
- )}
45
- {...props}
46
- />
47
- )
48
-
49
- function SelectTrigger({ className, children, ...props }: React.ComponentProps<typeof Button>) {
50
- return (
51
- <Button {...props}>
52
- {composeRenderProps(children, (children) => (
53
- <>
54
- {children}
55
- <ChevronDown aria-hidden="true" className="size-icon opacity-50" />
56
- </>
57
- ))}
58
- </Button>
59
- )
60
- }
61
-
62
- export function SelectPopover({ className, ...props }: AriaPopoverProps) {
63
- return (
64
- <Popover
65
- className={composeRenderProps(className, (className) =>
66
- cn("w-auto min-w-[--trigger-width]", className)
67
- )}
68
- {...props}
69
- />
70
- )
71
- }
72
-
73
- function SelectListBox<T extends object>({
74
- className,
75
- ...props
76
- }: AriaListBoxProps<T>) {
77
- return (
78
- <AriaListBox
79
- className={composeRenderProps(className, (className) =>
80
- cn(
81
- "overflow-auto p-1 outline-none [clip-path:inset(0_0_0_0_round_calc(var(--radius)-2px))]",
82
- className
83
- )
84
- )}
85
- {...props}
86
- />
87
- )
88
- }
89
-
90
- export interface SingleSelectProps<T extends SelectOption> extends Omit<AriaSelectProps<T>, "children">, FormFieldProps {
91
- items: Iterable<T>
92
- children: React.ReactNode | ((item: T) => React.ReactNode)
93
- }
94
-
95
- export function SingleSelect<T extends SelectOption>({
96
- label,
97
- description,
98
- errorMessage,
99
- children,
100
- className,
101
- items,
102
- ...props
103
- }: SingleSelectProps<T>) {
104
- return (
105
- <ASelect
106
- className={composeRenderProps(className, (className) =>
107
- cn("group form-field", className)
108
- )}
109
- {...props}
110
- >
111
- <FormField label={label} description={description} errorMessage={errorMessage}>
112
- <SelectTrigger>
113
- <SelectValue />
114
- </SelectTrigger>
115
- <SelectPopover>
116
- <SelectListBox items={items}>{children}</SelectListBox>
117
- </SelectPopover>
118
- </FormField>
119
- </ASelect>
120
- )
121
- }
122
-
123
-
124
- type TfSingleSelectProps<T extends SelectOption> = Omit<SingleSelectProps<T>, "value" | "setValue" | 'children'>;
125
-
126
- export function TfSingleSelect<T extends SelectOption>({ ...props }: TfSingleSelectProps<T>) {
127
- const field = useFieldContext<string>();
128
-
129
- return (
130
- <SingleSelect
131
- selectedKey={field.state.value}
132
- onSelectionChange={(e) => field.handleChange(e!.toString())}
133
- onBlur={field.handleBlur}
134
- errorMessage={getFieldErrorMessage(field)}
135
- {...props}
136
- >
137
- {(item) => <SelectItem id={item.id} key={item.id}>{item.label}</SelectItem>}
138
- </SingleSelect>
139
- );
140
- }
@@ -1,96 +0,0 @@
1
- import {
2
- Input as AriaInput,
3
- InputProps as AriaInputProps,
4
- TextArea as AriaTextArea,
5
- TextAreaProps as AriaTextAreaProps,
6
- TextField as AriaTextField,
7
- TextFieldProps as AriaTextFieldProps,
8
- composeRenderProps
9
- } from "react-aria-components"
10
-
11
-
12
- import { useFieldContext } from "lib/utils/form-context"
13
- import { getFieldErrorMessage } from "lib/utils/form-hook"
14
- import { cn } from "lib/utils/primitives"
15
- import { FormField, type FormFieldProps } from "./field"
16
-
17
- const ATextField = AriaTextField
18
-
19
- function Input({ className, ...props }: AriaInputProps) {
20
- return (
21
- <AriaInput
22
- className={composeRenderProps(className, (className) =>
23
- cn(
24
- "flex input-dim w-full border border-input bg-card ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground",
25
- /* Disabled */
26
- "disabled-muted",
27
- /* Focused */
28
- "focus-ring",
29
- className
30
- )
31
- )}
32
- {...props}
33
- />
34
- )
35
- }
36
-
37
- function TextArea({ className, ...props }: AriaTextAreaProps) {
38
- return (
39
- <AriaTextArea
40
- className={composeRenderProps(className, (className) =>
41
- cn(
42
- "flex min-h-32 w-full border border-input bg-card px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground",
43
- /* Focused */
44
- "focus-ring",
45
- /* Disabled */
46
- "disabled-muted",
47
- className
48
- )
49
- )}
50
- {...props}
51
- />
52
- )
53
- }
54
-
55
- export interface TextFieldProps extends AriaTextFieldProps, FormFieldProps {
56
- textArea?: boolean
57
- }
58
-
59
- export function TextField({
60
- label,
61
- description,
62
- errorMessage,
63
- textArea,
64
- className,
65
- ...props
66
- }: TextFieldProps) {
67
- return (
68
- <ATextField
69
- className={composeRenderProps(className, (className) =>
70
- cn("group form-field", className)
71
- )}
72
- {...props}
73
- >
74
- <FormField label={label} errorMessage={errorMessage} description={description}>
75
- {textArea ? <TextArea /> : <Input />}
76
- </FormField>
77
- </ATextField>
78
- )
79
- }
80
-
81
- export function TfTextField({ isDisabled, ...props }: React.ComponentProps<typeof TextField>) {
82
- const field = useFieldContext<string>();
83
-
84
- return (
85
- <TextField
86
- isDisabled={isDisabled || field.form.state.isSubmitting}
87
- value={field.state.value}
88
- id={field.name}
89
- name={field.name}
90
- onBlur={field.handleBlur}
91
- onChange={field.handleChange}
92
- errorMessage={getFieldErrorMessage(field)}
93
- {...props} />)
94
- }
95
-
96
-
@@ -1,115 +0,0 @@
1
- import { formatDate } from "lib/components/data-table/table-commons";
2
- import { Badge } from "lib/components/ui/badge";
3
- import { Card, CardContent, CardHeader, CardTitle } from "lib/components/ui/card";
4
- import { Skeleton } from "lib/components/ui/skeleton";
5
-
6
- // Utility type to handle nested keys (dot notation) in any object
7
- type NestedKeyOf<T> = T extends object
8
- ? {
9
- [K in keyof T]: K extends string | number
10
- ? `${K & string}` | `${K & string}.${NestedKeyOf<T[K]>}`
11
- : never;
12
- }[keyof T]
13
- : never;
14
-
15
- // DisplayField type that works with nested keys
16
- export type DisplayField<T> = {
17
- display: string;
18
- accessor: NestedKeyOf<T>;
19
- type?:
20
- | "text"
21
- | "badge"
22
- | "boolean"
23
- | "date"
24
- | "yesno"
25
- | "copyButton"
26
- | "link"; // Field types
27
- transform?: (value: any) => React.ReactNode;
28
- };
29
-
30
- export interface KeyValueCardProps<T> {
31
- data: T; // Ensure data is of type T
32
- label: string;
33
- fields: DisplayField<T>[];
34
- className?: string;
35
- }
36
-
37
- export const KeyValueCard = <T extends {}>({
38
- data,
39
- label,
40
- fields,
41
- }: KeyValueCardProps<T>) => {
42
- const renderValue = (field: DisplayField<T>, value: any) => {
43
- if (field.transform) {
44
- return field.transform(value);
45
- }
46
- if (value === undefined || value === null) {
47
- return "-";
48
- }
49
- switch (field.type) {
50
- case "date":
51
- return <span>{formatDate(value)}</span>;
52
- case "yesno":
53
- return <span>{value ? "Yes" : "No"}</span>;
54
- case "badge":
55
- return (
56
- <div className="flex flex-wrap gap-1">
57
- {Array.isArray(value)
58
- ? value.map((item, index) => (
59
- <Badge key={index}>
60
- {typeof item === "object" ? item?.name || item?.id : item}
61
- </Badge>
62
- ))
63
- : value}
64
- </div>
65
- );
66
-
67
- case "boolean":
68
- return <span>{value.toString()}</span>;
69
- default:
70
- return <span>{value}</span>;
71
- }
72
- };
73
-
74
- return (
75
- <Card>
76
- <CardHeader>
77
- <CardTitle>{label}</CardTitle>
78
- </CardHeader>
79
- <CardContent>
80
- <div className="flex flex-col gap-2">
81
- {data
82
- ? fields.map((field) => {
83
- // TODO: improve this
84
- const value = field.accessor
85
- ? field.accessor
86
- .split(".")
87
- .reduce(
88
- (obj, key) =>
89
- obj && key in obj ? obj[key] : undefined,
90
- data as Record<string, any>,
91
- )
92
- : null;
93
-
94
- return (
95
- <div
96
- key={field.display}
97
- className="flex w-full flex-col md:flex-row justify-between first:pt-0 last:pb-0"
98
- >
99
- <p className="text-sm flex w-full justify-start col-span-1">
100
- {field.display}
101
- </p>
102
- <div className="text-sm flex w-full justify-start text-wrap break-all">
103
- {renderValue(field, value)}
104
- </div>
105
- </div>
106
- );
107
- })
108
- : fields.map((_, index) => (
109
- <Skeleton key={index} className="h-12 w-full" />
110
- ))}
111
- </div>
112
- </CardContent>
113
- </Card>
114
- );
115
- };
@@ -1,32 +0,0 @@
1
- import { cva, type VariantProps } from "class-variance-authority";
2
- import { cn } from "lib/utils/primitives";
3
- import { type LucideIcon } from "lucide-react";
4
-
5
- export const alertVariants = cva(
6
- `transition-colors border border-dotted p-2 text-foreground text-sm inline-flex items-start gap-2`,
7
- {
8
- variants: {
9
- variant: {
10
- destructive: "bg-destructive-foreground/20 text-destructive border-destructive",
11
- success: "bg-success-foreground/20 text-success border-success",
12
- muted: "bg-muted-foreground/20 text-muted border-muted",
13
- },
14
- },
15
- defaultVariants: {
16
- variant: "muted",
17
- },
18
- },
19
- );
20
-
21
- export function Alert({ children, className, variant, icon: Icon, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants> & {
22
- icon?: LucideIcon
23
- }) {
24
-
25
- return (
26
- <div role="alert" className={cn(alertVariants({ variant }), className)} {...props}>
27
- {Icon && <Icon className="size-icon mt-1" />}
28
- <span className="w-full">
29
- {children}
30
- </span>
31
- </div>)
32
- }
@@ -1,22 +0,0 @@
1
- import { cn } from "lib/utils/primitives";
2
- import type * as React from "react";
3
-
4
- interface InitialString {
5
- initials: string[2];
6
- }
7
- export interface AvatarProps
8
- extends Omit<React.ComponentProps<"div">, "children">,
9
- InitialString { }
10
- export function Avatar({ className, initials, ...props }: AvatarProps) {
11
- return (
12
- <div
13
- className={cn(
14
- "relative text-xs font-mono font-bold flex items-center leading-none justify-center bg-accent text-accent-foreground select-none size-input shrink-0 overflow-hidden rounded-full",
15
- className,
16
- )}
17
- {...props}
18
- >
19
- {initials}
20
- </div>
21
- );
22
- }
@@ -1,19 +0,0 @@
1
- import { cn } from "lib/utils/primitives";
2
- import type * as React from "react";
3
-
4
- export function Badge({ className, children, ...props }: React.ComponentProps<"span">) {
5
- return (
6
- <span
7
- className={cn(
8
- "text-muted leading-none text-sm px-1 inline-flex items-center justify-center select-none bg-card border h-input focus:outline-hidden focus:ring-1 focus:ring-ring",
9
- className,
10
- )}
11
- {...props}
12
- >
13
- {/* Contents */}
14
- <span>
15
- {children}
16
- </span>
17
- </span>
18
- );
19
- }
@@ -1,104 +0,0 @@
1
- import {
2
- Breadcrumb as AriaBreadcrumb,
3
- BreadcrumbProps as AriaBreadcrumbProps,
4
- Breadcrumbs as AriaBreadcrumbs,
5
- BreadcrumbsProps as AriaBreadcrumbsProps,
6
- Link as AriaLink,
7
- LinkProps as AriaLinkProps,
8
- composeRenderProps,
9
- } from "react-aria-components"
10
-
11
- import { cn } from "lib/utils/primitives"
12
- import { ChevronRight, DotSquare } from "lucide-react"
13
-
14
- export function Breadcrumbs<T extends object>({
15
- className,
16
- ...props
17
- }: AriaBreadcrumbsProps<T>) {
18
- return (
19
- <AriaBreadcrumbs
20
- className={cn(
21
- "flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
22
- className
23
- )}
24
- {...props}
25
- />
26
- )
27
- }
28
-
29
- export function BreadcrumbItem({ className, ...props }: AriaBreadcrumbProps) {
30
- return (
31
- <AriaBreadcrumb
32
- className={cn("inline-flex items-center gap-1.5 sm:gap-2.5", className)}
33
- {...props}
34
- />
35
- )
36
- }
37
-
38
- export function BreadcrumbLink({ className, ...props }: AriaLinkProps) {
39
- return (
40
- <AriaLink
41
- className={composeRenderProps(className, (className) =>
42
- cn(
43
- "transition-colors",
44
- /* Hover */
45
- "data-[hovered]:text-foreground",
46
- /* Disabled */
47
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
48
- /* Current */
49
- "data-[current]:pointer-events-auto data-[current]:opacity-100",
50
- className
51
- )
52
- )}
53
- {...props}
54
- />
55
- )
56
- }
57
-
58
- export function BreadcrumbSeparator({
59
- children,
60
- className,
61
- ...props
62
- }: React.ComponentProps<"span">) {
63
- return (
64
- <span
65
- role="presentation"
66
- aria-hidden="true"
67
- className={cn("[&>svg]:size-3.5", className)}
68
- {...props}
69
- >
70
- {children || <ChevronRight />}
71
- </span>
72
- )
73
- }
74
-
75
- export function BreadcrumbEllipsis({
76
- className,
77
- ...props
78
- }: React.ComponentProps<"span">) {
79
- return (
80
- <span
81
- role="presentation"
82
- aria-hidden="true"
83
- className={cn("flex size-9 items-center justify-center", className)}
84
- {...props}
85
- >
86
- <DotSquare className="size-4" />
87
- <span className="sr-only">More</span>
88
- </span>
89
- )
90
- }
91
-
92
- interface BreadcrumbPageProps extends Omit<AriaLinkProps, "href"> { }
93
-
94
- export function BreadcrumbPage({ className, ...props }: BreadcrumbPageProps) {
95
- return (
96
- <AriaLink
97
- className={composeRenderProps(className, (className) =>
98
- cn("font-normal text-foreground", className)
99
- )}
100
- {...props}
101
- />
102
- )
103
- }
104
-
@@ -1,66 +0,0 @@
1
- "use client"
2
- import { cva, type VariantProps } from "class-variance-authority";
3
- import { cn } from "lib/utils/primitives";
4
- import {
5
- Button as AriaButton,
6
- composeRenderProps,
7
- type ButtonProps as AriaButtonProps,
8
- } from "react-aria-components";
9
- import { Loader } from "./loader";
10
-
11
- export const buttonVariants = cva(
12
- "btn inline-flex gap-1 text-ellipsis overflow-hidden items-center justify-center font-medium transition-colors",
13
- {
14
- variants: {
15
- variant: {
16
- primary: "btn-primary",
17
- secondary: "btn-secondary",
18
- destructive: "btn-destructive",
19
- neutral: "btn-neutral",
20
- ghost: "btn-ghost",
21
- link: "text-primary underline-offset-4 hover:underline",
22
- },
23
- size: {
24
- default: "input-dim",
25
- icon: "size-input",
26
- none: ""
27
- },
28
- },
29
- defaultVariants: {
30
- variant: "neutral",
31
- size: "default",
32
- },
33
- },
34
- );
35
-
36
- export type ButtonProps = AriaButtonProps & VariantProps<typeof buttonVariants> & {
37
- ref?: React.Ref<HTMLButtonElement>
38
- active?: boolean
39
- }
40
-
41
- export function Button({ className: additionalClasses, variant, size, children, isPending, active, ...props }: ButtonProps) {
42
- return (
43
- <AriaButton
44
- {...props}
45
- className={composeRenderProps(additionalClasses, (className) =>
46
- cn(
47
- buttonVariants({
48
- variant,
49
- size,
50
- className,
51
- }),
52
- additionalClasses
53
- )
54
- )}
55
- >
56
- {composeRenderProps(children, (children) => (<>
57
- {isPending && <Loader />}
58
- {!isPending && <>
59
- {children}
60
- {/* TODO active indication */}
61
- </>}
62
- </>))}
63
- </AriaButton>
64
- )
65
- }
66
-