@sqlrooms/ui 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +6 -11
  3. package/.turbo/turbo-build.log +0 -8
  4. package/.turbo/turbo-lint.log +0 -10
  5. package/dist/components/DefaultErrorBoundary.d.ts +0 -2
  6. package/dist/components/DefaultErrorBoundary.d.ts.map +0 -1
  7. package/dist/components/DefaultErrorBoundary.js +0 -1
  8. package/dist/components/ProgressModal.d.ts +0 -10
  9. package/dist/components/ProgressModal.d.ts.map +0 -1
  10. package/dist/components/ProgressModal.js +0 -7
  11. package/dist/components/index.d.ts +0 -2
  12. package/dist/components/index.d.ts.map +0 -1
  13. package/dist/components/index.js +0 -1
  14. package/dist/tsconfig.tsbuildinfo +0 -1
  15. package/eslint.config.js +0 -4
  16. package/src/components/accordion.tsx +0 -55
  17. package/src/components/alert.tsx +0 -59
  18. package/src/components/badge.tsx +0 -34
  19. package/src/components/breadcrumb.tsx +0 -115
  20. package/src/components/button.tsx +0 -55
  21. package/src/components/card.tsx +0 -76
  22. package/src/components/checkbox.tsx +0 -28
  23. package/src/components/dialog.tsx +0 -120
  24. package/src/components/dropdown-menu.tsx +0 -199
  25. package/src/components/editable-text.tsx +0 -199
  26. package/src/components/error-boundary.tsx +0 -48
  27. package/src/components/error-pane.tsx +0 -81
  28. package/src/components/form.tsx +0 -176
  29. package/src/components/input.tsx +0 -22
  30. package/src/components/label.tsx +0 -24
  31. package/src/components/popover.tsx +0 -31
  32. package/src/components/progress-modal.tsx +0 -33
  33. package/src/components/progress.tsx +0 -26
  34. package/src/components/resizable.tsx +0 -43
  35. package/src/components/select.tsx +0 -157
  36. package/src/components/skeleton-pane.tsx +0 -45
  37. package/src/components/skeleton.tsx +0 -12
  38. package/src/components/spinner-pane.tsx +0 -44
  39. package/src/components/spinner.tsx +0 -16
  40. package/src/components/switch.tsx +0 -27
  41. package/src/components/table.tsx +0 -136
  42. package/src/components/tabs.tsx +0 -53
  43. package/src/components/textarea.tsx +0 -21
  44. package/src/components/toast.tsx +0 -127
  45. package/src/components/toaster.tsx +0 -33
  46. package/src/components/tooltip.tsx +0 -29
  47. package/src/hooks/use-toast.ts +0 -191
  48. package/src/hooks/useDisclosure.ts +0 -26
  49. package/src/index.ts +0 -35
  50. package/src/lib/utils.ts +0 -6
  51. package/src/tailwind-preset.css +0 -68
  52. package/src/tailwind-preset.ts +0 -55
  53. package/tsconfig.json +0 -12
@@ -1,176 +0,0 @@
1
- import * as React from 'react';
2
- import * as LabelPrimitive from '@radix-ui/react-label';
3
- import {Slot} from '@radix-ui/react-slot';
4
- import {
5
- Controller,
6
- ControllerProps,
7
- FieldPath,
8
- FieldValues,
9
- FormProvider,
10
- useFormContext,
11
- } from 'react-hook-form';
12
-
13
- import {cn} from '../lib/utils';
14
- import {Label} from './label';
15
-
16
- const Form = FormProvider;
17
-
18
- type FormFieldContextValue<
19
- TFieldValues extends FieldValues = FieldValues,
20
- TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
21
- > = {
22
- name: TName;
23
- };
24
-
25
- const FormFieldContext = React.createContext<FormFieldContextValue>(
26
- {} as FormFieldContextValue,
27
- );
28
-
29
- const FormField = <
30
- TFieldValues extends FieldValues = FieldValues,
31
- TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
32
- >({
33
- ...props
34
- }: ControllerProps<TFieldValues, TName>) => {
35
- return (
36
- <FormFieldContext.Provider value={{name: props.name}}>
37
- <Controller {...props} />
38
- </FormFieldContext.Provider>
39
- );
40
- };
41
-
42
- const useFormField = () => {
43
- const fieldContext = React.useContext(FormFieldContext);
44
- const itemContext = React.useContext(FormItemContext);
45
- const {getFieldState, formState} = useFormContext();
46
-
47
- const fieldState = getFieldState(fieldContext.name, formState);
48
-
49
- if (!fieldContext) {
50
- throw new Error('useFormField should be used within <FormField>');
51
- }
52
-
53
- const {id} = itemContext;
54
-
55
- return {
56
- id,
57
- name: fieldContext.name,
58
- formItemId: `${id}-form-item`,
59
- formDescriptionId: `${id}-form-item-description`,
60
- formMessageId: `${id}-form-item-message`,
61
- ...fieldState,
62
- };
63
- };
64
-
65
- type FormItemContextValue = {
66
- id: string;
67
- };
68
-
69
- const FormItemContext = React.createContext<FormItemContextValue>(
70
- {} as FormItemContextValue,
71
- );
72
-
73
- const FormItem = React.forwardRef<
74
- HTMLDivElement,
75
- React.HTMLAttributes<HTMLDivElement>
76
- >(({className, ...props}, ref) => {
77
- const id = React.useId();
78
-
79
- return (
80
- <FormItemContext.Provider value={{id}}>
81
- <div ref={ref} className={cn('space-y-2', className)} {...props} />
82
- </FormItemContext.Provider>
83
- );
84
- });
85
- FormItem.displayName = 'FormItem';
86
-
87
- const FormLabel = React.forwardRef<
88
- React.ElementRef<typeof LabelPrimitive.Root>,
89
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
90
- >(({className, ...props}, ref) => {
91
- const {error, formItemId} = useFormField();
92
-
93
- return (
94
- <Label
95
- ref={ref}
96
- className={cn(error && 'text-destructive', className)}
97
- htmlFor={formItemId}
98
- {...props}
99
- />
100
- );
101
- });
102
- FormLabel.displayName = 'FormLabel';
103
-
104
- const FormControl = React.forwardRef<
105
- React.ElementRef<typeof Slot>,
106
- React.ComponentPropsWithoutRef<typeof Slot>
107
- >(({...props}, ref) => {
108
- const {error, formItemId, formDescriptionId, formMessageId} = useFormField();
109
-
110
- return (
111
- <Slot
112
- ref={ref}
113
- id={formItemId}
114
- aria-describedby={
115
- !error
116
- ? `${formDescriptionId}`
117
- : `${formDescriptionId} ${formMessageId}`
118
- }
119
- aria-invalid={!!error}
120
- {...props}
121
- />
122
- );
123
- });
124
- FormControl.displayName = 'FormControl';
125
-
126
- const FormDescription = React.forwardRef<
127
- HTMLParagraphElement,
128
- React.HTMLAttributes<HTMLParagraphElement>
129
- >(({className, ...props}, ref) => {
130
- const {formDescriptionId} = useFormField();
131
-
132
- return (
133
- <p
134
- ref={ref}
135
- id={formDescriptionId}
136
- className={cn('text-[0.8rem] text-muted-foreground', className)}
137
- {...props}
138
- />
139
- );
140
- });
141
- FormDescription.displayName = 'FormDescription';
142
-
143
- const FormMessage = React.forwardRef<
144
- HTMLParagraphElement,
145
- React.HTMLAttributes<HTMLParagraphElement>
146
- >(({className, children, ...props}, ref) => {
147
- const {error, formMessageId} = useFormField();
148
- const body = error ? String(error?.message) : children;
149
-
150
- if (!body) {
151
- return null;
152
- }
153
-
154
- return (
155
- <p
156
- ref={ref}
157
- id={formMessageId}
158
- className={cn('text-[0.8rem] font-medium text-destructive', className)}
159
- {...props}
160
- >
161
- {body}
162
- </p>
163
- );
164
- });
165
- FormMessage.displayName = 'FormMessage';
166
-
167
- export {
168
- useFormField,
169
- Form,
170
- FormItem,
171
- FormLabel,
172
- FormControl,
173
- FormDescription,
174
- FormMessage,
175
- FormField,
176
- };
@@ -1,22 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import {cn} from '../lib/utils';
4
-
5
- const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
6
- ({className, type, ...props}, ref) => {
7
- return (
8
- <input
9
- type={type}
10
- className={cn(
11
- 'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
12
- className,
13
- )}
14
- ref={ref}
15
- {...props}
16
- />
17
- );
18
- },
19
- );
20
- Input.displayName = 'Input';
21
-
22
- export {Input};
@@ -1,24 +0,0 @@
1
- import * as React from 'react';
2
- import * as LabelPrimitive from '@radix-ui/react-label';
3
- import {cva, type VariantProps} from 'class-variance-authority';
4
-
5
- import {cn} from '../lib/utils';
6
-
7
- const labelVariants = cva(
8
- 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
9
- );
10
-
11
- const Label = React.forwardRef<
12
- React.ElementRef<typeof LabelPrimitive.Root>,
13
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
14
- VariantProps<typeof labelVariants>
15
- >(({className, ...props}, ref) => (
16
- <LabelPrimitive.Root
17
- ref={ref}
18
- className={cn(labelVariants(), className)}
19
- {...props}
20
- />
21
- ));
22
- Label.displayName = LabelPrimitive.Root.displayName;
23
-
24
- export {Label};
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import * as PopoverPrimitive from '@radix-ui/react-popover';
3
-
4
- import {cn} from '../lib/utils';
5
-
6
- const Popover = PopoverPrimitive.Root;
7
-
8
- const PopoverTrigger = PopoverPrimitive.Trigger;
9
-
10
- const PopoverAnchor = PopoverPrimitive.Anchor;
11
-
12
- const PopoverContent = React.forwardRef<
13
- React.ElementRef<typeof PopoverPrimitive.Content>,
14
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
15
- >(({className, align = 'center', sideOffset = 4, ...props}, ref) => (
16
- <PopoverPrimitive.Portal>
17
- <PopoverPrimitive.Content
18
- ref={ref}
19
- align={align}
20
- sideOffset={sideOffset}
21
- className={cn(
22
- 'z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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',
23
- className,
24
- )}
25
- {...props}
26
- />
27
- </PopoverPrimitive.Portal>
28
- ));
29
- PopoverContent.displayName = PopoverPrimitive.Content.displayName;
30
-
31
- export {Popover, PopoverTrigger, PopoverContent, PopoverAnchor};
@@ -1,33 +0,0 @@
1
- import {FC} from 'react';
2
- import {Dialog, DialogContent, DialogHeader, DialogTitle} from './dialog';
3
- import {Progress} from './progress';
4
-
5
- type Props = {
6
- isOpen: boolean;
7
- title?: string;
8
- loadingStage?: string;
9
- progress?: number;
10
- };
11
-
12
- const ProgressModal: FC<Props> = (props) => {
13
- const {isOpen, title, loadingStage, progress} = props;
14
-
15
- return (
16
- <Dialog open={isOpen} onOpenChange={() => {}}>
17
- <DialogContent className="sm:max-w-[425px]">
18
- <DialogHeader>
19
- <DialogTitle>{title ?? ''}</DialogTitle>
20
- </DialogHeader>
21
- <div className="flex flex-col gap-2">
22
- <Progress value={progress} className="w-full" />
23
- <div className="flex justify-between text-sm text-muted-foreground">
24
- <span>{loadingStage ?? ''}</span>
25
- {progress ? <span>{progress}%</span> : null}
26
- </div>
27
- </div>
28
- </DialogContent>
29
- </Dialog>
30
- );
31
- };
32
-
33
- export {ProgressModal};
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- import * as ProgressPrimitive from '@radix-ui/react-progress';
3
-
4
- import {cn} from '../lib/utils';
5
-
6
- const Progress = React.forwardRef<
7
- React.ElementRef<typeof ProgressPrimitive.Root>,
8
- React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
9
- >(({className, value, ...props}, ref) => (
10
- <ProgressPrimitive.Root
11
- ref={ref}
12
- className={cn(
13
- 'relative h-2 w-full overflow-hidden rounded-full bg-primary/20',
14
- className,
15
- )}
16
- {...props}
17
- >
18
- <ProgressPrimitive.Indicator
19
- className="h-full w-full flex-1 bg-primary transition-all"
20
- style={{transform: `translateX(-${100 - (value || 0)}%)`}}
21
- />
22
- </ProgressPrimitive.Root>
23
- ));
24
- Progress.displayName = ProgressPrimitive.Root.displayName;
25
-
26
- export {Progress};
@@ -1,43 +0,0 @@
1
- import {GripVertical} from 'lucide-react';
2
- import * as ResizablePrimitive from 'react-resizable-panels';
3
-
4
- import {cn} from '../lib/utils';
5
-
6
- const ResizablePanelGroup = ({
7
- className,
8
- ...props
9
- }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
10
- <ResizablePrimitive.PanelGroup
11
- className={cn(
12
- 'flex h-full w-full data-[panel-group-direction=vertical]:flex-col',
13
- className,
14
- )}
15
- {...props}
16
- />
17
- );
18
-
19
- const ResizablePanel = ResizablePrimitive.Panel;
20
-
21
- const ResizableHandle = ({
22
- withHandle,
23
- className,
24
- ...props
25
- }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
26
- withHandle?: boolean;
27
- }) => (
28
- <ResizablePrimitive.PanelResizeHandle
29
- className={cn(
30
- 'relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90',
31
- className,
32
- )}
33
- {...props}
34
- >
35
- {withHandle && (
36
- <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
37
- <GripVertical className="h-2.5 w-2.5" />
38
- </div>
39
- )}
40
- </ResizablePrimitive.PanelResizeHandle>
41
- );
42
-
43
- export {ResizablePanelGroup, ResizablePanel, ResizableHandle};
@@ -1,157 +0,0 @@
1
- import * as React from 'react';
2
- import * as SelectPrimitive from '@radix-ui/react-select';
3
- import {Check, ChevronDown, ChevronUp} from 'lucide-react';
4
-
5
- import {cn} from '../lib/utils';
6
-
7
- const Select = SelectPrimitive.Root;
8
-
9
- const SelectGroup = SelectPrimitive.Group;
10
-
11
- const SelectValue = SelectPrimitive.Value;
12
-
13
- const SelectTrigger = React.forwardRef<
14
- React.ElementRef<typeof SelectPrimitive.Trigger>,
15
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
16
- >(({className, children, ...props}, ref) => (
17
- <SelectPrimitive.Trigger
18
- ref={ref}
19
- className={cn(
20
- 'flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
21
- className,
22
- )}
23
- {...props}
24
- >
25
- {children}
26
- <SelectPrimitive.Icon asChild>
27
- <ChevronDown className="h-4 w-4 opacity-50" />
28
- </SelectPrimitive.Icon>
29
- </SelectPrimitive.Trigger>
30
- ));
31
- SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
32
-
33
- const SelectScrollUpButton = React.forwardRef<
34
- React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
35
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
36
- >(({className, ...props}, ref) => (
37
- <SelectPrimitive.ScrollUpButton
38
- ref={ref}
39
- className={cn(
40
- 'flex cursor-default items-center justify-center py-1',
41
- className,
42
- )}
43
- {...props}
44
- >
45
- <ChevronUp className="h-4 w-4" />
46
- </SelectPrimitive.ScrollUpButton>
47
- ));
48
- SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
49
-
50
- const SelectScrollDownButton = React.forwardRef<
51
- React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
52
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
53
- >(({className, ...props}, ref) => (
54
- <SelectPrimitive.ScrollDownButton
55
- ref={ref}
56
- className={cn(
57
- 'flex cursor-default items-center justify-center py-1',
58
- className,
59
- )}
60
- {...props}
61
- >
62
- <ChevronDown className="h-4 w-4" />
63
- </SelectPrimitive.ScrollDownButton>
64
- ));
65
- SelectScrollDownButton.displayName =
66
- SelectPrimitive.ScrollDownButton.displayName;
67
-
68
- const SelectContent = React.forwardRef<
69
- React.ElementRef<typeof SelectPrimitive.Content>,
70
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
71
- >(({className, children, position = 'popper', ...props}, ref) => (
72
- <SelectPrimitive.Portal>
73
- <SelectPrimitive.Content
74
- ref={ref}
75
- className={cn(
76
- 'relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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',
77
- position === 'popper' &&
78
- 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
79
- className,
80
- )}
81
- position={position}
82
- {...props}
83
- >
84
- <SelectScrollUpButton />
85
- <SelectPrimitive.Viewport
86
- className={cn(
87
- 'p-1',
88
- position === 'popper' &&
89
- 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',
90
- )}
91
- >
92
- {children}
93
- </SelectPrimitive.Viewport>
94
- <SelectScrollDownButton />
95
- </SelectPrimitive.Content>
96
- </SelectPrimitive.Portal>
97
- ));
98
- SelectContent.displayName = SelectPrimitive.Content.displayName;
99
-
100
- const SelectLabel = React.forwardRef<
101
- React.ElementRef<typeof SelectPrimitive.Label>,
102
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
103
- >(({className, ...props}, ref) => (
104
- <SelectPrimitive.Label
105
- ref={ref}
106
- className={cn('px-2 py-1.5 text-sm font-semibold', className)}
107
- {...props}
108
- />
109
- ));
110
- SelectLabel.displayName = SelectPrimitive.Label.displayName;
111
-
112
- const SelectItem = React.forwardRef<
113
- React.ElementRef<typeof SelectPrimitive.Item>,
114
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
115
- >(({className, children, ...props}, ref) => (
116
- <SelectPrimitive.Item
117
- ref={ref}
118
- className={cn(
119
- 'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
120
- className,
121
- )}
122
- {...props}
123
- >
124
- <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
125
- <SelectPrimitive.ItemIndicator>
126
- <Check className="h-4 w-4" />
127
- </SelectPrimitive.ItemIndicator>
128
- </span>
129
- <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
130
- </SelectPrimitive.Item>
131
- ));
132
- SelectItem.displayName = SelectPrimitive.Item.displayName;
133
-
134
- const SelectSeparator = React.forwardRef<
135
- React.ElementRef<typeof SelectPrimitive.Separator>,
136
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
137
- >(({className, ...props}, ref) => (
138
- <SelectPrimitive.Separator
139
- ref={ref}
140
- className={cn('-mx-1 my-1 h-px bg-muted', className)}
141
- {...props}
142
- />
143
- ));
144
- SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
145
-
146
- export {
147
- Select,
148
- SelectGroup,
149
- SelectValue,
150
- SelectTrigger,
151
- SelectContent,
152
- SelectLabel,
153
- SelectItem,
154
- SelectSeparator,
155
- SelectScrollUpButton,
156
- SelectScrollDownButton,
157
- };
@@ -1,45 +0,0 @@
1
- import * as React from 'react';
2
- import {cn} from '../lib/utils';
3
- import {Skeleton} from './skeleton';
4
-
5
- export type Props = {
6
- n?: number;
7
- staggeringDelay?: number;
8
- rowHeight?: number | string;
9
- className?: string;
10
- };
11
-
12
- const SkeletonPane: React.FC<Props> = ({
13
- n = 3,
14
- staggeringDelay = 200,
15
- rowHeight = '20px',
16
- className,
17
- }) => {
18
- const [count, setCount] = React.useState(0);
19
-
20
- React.useEffect(() => {
21
- if (count >= n) return;
22
-
23
- const timer = setTimeout(() => {
24
- setCount(count + 1);
25
- }, staggeringDelay);
26
-
27
- return () => clearTimeout(timer);
28
- }, [count, n, staggeringDelay]);
29
-
30
- return (
31
- <div className={cn('flex w-full flex-col justify-center', className)}>
32
- <div className="flex flex-col gap-2">
33
- {Array.from({length: n}).map((_, i) =>
34
- i < count ? (
35
- <Skeleton key={i} className="w-full" style={{height: rowHeight}} />
36
- ) : (
37
- <div key={i} style={{height: rowHeight}} />
38
- ),
39
- )}
40
- </div>
41
- </div>
42
- );
43
- };
44
-
45
- export {SkeletonPane};
@@ -1,12 +0,0 @@
1
- import {cn} from '../lib/utils';
2
-
3
- function Skeleton({className, ...props}: React.HTMLAttributes<HTMLDivElement>) {
4
- return (
5
- <div
6
- className={cn('animate-pulse rounded-md bg-primary/10', className)}
7
- {...props}
8
- />
9
- );
10
- }
11
-
12
- export {Skeleton};
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import {cn} from '../lib/utils';
3
- import {Spinner} from './spinner';
4
-
5
- export type SpinnerPaneProps = {
6
- h?: number | string;
7
- delayed?: boolean;
8
- className?: string;
9
- children?: React.ReactNode;
10
- };
11
-
12
- const DELAY = 500;
13
-
14
- const SpinnerPane: React.FC<SpinnerPaneProps> = (props) => {
15
- const {h, delayed, children, className, ...rest} = props;
16
- const [isPlaying, setPlaying] = React.useState(!delayed);
17
-
18
- React.useEffect(() => {
19
- if (!isPlaying && delayed) {
20
- const timer = setTimeout(() => setPlaying(true), DELAY);
21
- return () => clearTimeout(timer);
22
- }
23
- }, [isPlaying, delayed]);
24
-
25
- return (
26
- <div
27
- className={cn(
28
- 'mx-auto flex min-h-[inherit] items-center justify-center',
29
- className,
30
- )}
31
- style={{minHeight: h}}
32
- {...rest}
33
- >
34
- {isPlaying ? (
35
- <div className="flex flex-col items-center gap-2">
36
- {children}
37
- <Spinner className="text-muted-foreground" />
38
- </div>
39
- ) : null}
40
- </div>
41
- );
42
- };
43
-
44
- export {SpinnerPane};
@@ -1,16 +0,0 @@
1
- import {FC} from 'react';
2
-
3
- import {LoaderCircleIcon} from 'lucide-react';
4
- import {cn} from '../lib/utils';
5
-
6
- /**
7
- * Loading spinner component
8
- */
9
- export const Spinner: FC<{className?: string}> = ({className}) => {
10
- return (
11
- <LoaderCircleIcon
12
- className={cn('animate-spin text-brand-primary', className)}
13
- size={17}
14
- />
15
- );
16
- };
@@ -1,27 +0,0 @@
1
- import * as React from 'react';
2
- import * as SwitchPrimitives from '@radix-ui/react-switch';
3
-
4
- import {cn} from '../lib/utils';
5
-
6
- const Switch = React.forwardRef<
7
- React.ElementRef<typeof SwitchPrimitives.Root>,
8
- React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
9
- >(({className, ...props}, ref) => (
10
- <SwitchPrimitives.Root
11
- className={cn(
12
- 'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
13
- className,
14
- )}
15
- {...props}
16
- ref={ref}
17
- >
18
- <SwitchPrimitives.Thumb
19
- className={cn(
20
- 'pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
21
- )}
22
- />
23
- </SwitchPrimitives.Root>
24
- ));
25
- Switch.displayName = SwitchPrimitives.Root.displayName;
26
-
27
- export {Switch};