eai-frontend-components 2.0.5 → 2.0.6

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 (100) hide show
  1. package/package.json +3 -3
  2. package/src/components/ui/accordion.tsx +0 -48
  3. package/src/components/ui/alert-dialog.tsx +0 -138
  4. package/src/components/ui/alert.tsx +0 -36
  5. package/src/components/ui/avatar.tsx +0 -48
  6. package/src/components/ui/badge.tsx +0 -35
  7. package/src/components/ui/breadcrumb.tsx +0 -115
  8. package/src/components/ui/button.tsx +0 -43
  9. package/src/components/ui/calendar.tsx +0 -142
  10. package/src/components/ui/card.tsx +0 -35
  11. package/src/components/ui/carousel.tsx +0 -257
  12. package/src/components/ui/chart.tsx +0 -363
  13. package/src/components/ui/checkbox.tsx +0 -26
  14. package/src/components/ui/collapsible.tsx +0 -9
  15. package/src/components/ui/command.tsx +0 -145
  16. package/src/components/ui/context-menu.tsx +0 -198
  17. package/src/components/ui/custom/date-picker.tsx +0 -97
  18. package/src/components/ui/custom/form/checkbox.tsx +0 -53
  19. package/src/components/ui/custom/form/color.tsx +0 -140
  20. package/src/components/ui/custom/form/combobox.tsx +0 -259
  21. package/src/components/ui/custom/form/cpf-cnpj.tsx +0 -85
  22. package/src/components/ui/custom/form/currency.tsx +0 -51
  23. package/src/components/ui/custom/form/date-range.tsx +0 -110
  24. package/src/components/ui/custom/form/date.tsx +0 -109
  25. package/src/components/ui/custom/form/decimal.tsx +0 -50
  26. package/src/components/ui/custom/form/file.tsx +0 -65
  27. package/src/components/ui/custom/form/form-help-text.tsx +0 -20
  28. package/src/components/ui/custom/form/form-label.tsx +0 -24
  29. package/src/components/ui/custom/form/form-message.tsx +0 -10
  30. package/src/components/ui/custom/form/ghost.tsx +0 -28
  31. package/src/components/ui/custom/form/input.tsx +0 -69
  32. package/src/components/ui/custom/form/mask.tsx +0 -78
  33. package/src/components/ui/custom/form/multi-select.tsx +0 -209
  34. package/src/components/ui/custom/form/password.tsx +0 -70
  35. package/src/components/ui/custom/form/percent.tsx +0 -52
  36. package/src/components/ui/custom/form/phone.tsx +0 -79
  37. package/src/components/ui/custom/form/radio-group.tsx +0 -94
  38. package/src/components/ui/custom/form/select.tsx +0 -62
  39. package/src/components/ui/custom/form/step-new-form.tsx +0 -49
  40. package/src/components/ui/custom/form/switch.tsx +0 -51
  41. package/src/components/ui/custom/form/text.tsx +0 -71
  42. package/src/components/ui/custom/form/textarea.tsx +0 -71
  43. package/src/components/ui/custom/form/utils.ts +0 -100
  44. package/src/components/ui/custom/header.tsx +0 -128
  45. package/src/components/ui/custom/label.tsx +0 -79
  46. package/src/components/ui/custom/not-found.tsx +0 -30
  47. package/src/components/ui/custom/sidebar/module-switcher.tsx +0 -58
  48. package/src/components/ui/custom/sidebar/nav-footer.tsx +0 -35
  49. package/src/components/ui/custom/sidebar/nav-main.tsx +0 -64
  50. package/src/components/ui/custom/sidebar/nav-submenu-collapsible.tsx +0 -60
  51. package/src/components/ui/custom/sidebar/nav-submenu-dropdown.tsx +0 -56
  52. package/src/components/ui/custom/sidebar/nav-user.tsx +0 -77
  53. package/src/components/ui/custom/sidebar/sidebar-button.tsx +0 -30
  54. package/src/components/ui/custom/sidebar/sidebar-item-two-lines.tsx +0 -25
  55. package/src/components/ui/custom/sidebar/sidebar-item.tsx +0 -19
  56. package/src/components/ui/custom/sidebar/types/sidebar.ts +0 -31
  57. package/src/components/ui/custom/table/data-table-export.tsx +0 -126
  58. package/src/components/ui/custom/table/data-table-footer.tsx +0 -148
  59. package/src/components/ui/custom/table/data-table-header.tsx +0 -58
  60. package/src/components/ui/custom/table/data-table-rows.tsx +0 -94
  61. package/src/components/ui/custom/table/data-table.tsx +0 -285
  62. package/src/components/ui/custom/table/types/data-table.ts +0 -31
  63. package/src/components/ui/custom/theme-provider.tsx +0 -121
  64. package/src/components/ui/dateRangePicker.tsx +0 -63
  65. package/src/components/ui/dialog.tsx +0 -84
  66. package/src/components/ui/drawer.tsx +0 -116
  67. package/src/components/ui/dropdown-menu.tsx +0 -173
  68. package/src/components/ui/form.tsx +0 -114
  69. package/src/components/ui/hover-card.tsx +0 -27
  70. package/src/components/ui/input.tsx +0 -265
  71. package/src/components/ui/label.tsx +0 -15
  72. package/src/components/ui/masks.ts +0 -35
  73. package/src/components/ui/pagination.tsx +0 -78
  74. package/src/components/ui/popover.tsx +0 -32
  75. package/src/components/ui/progress.tsx +0 -22
  76. package/src/components/ui/radio-group.tsx +0 -36
  77. package/src/components/ui/scroll-area.tsx +0 -46
  78. package/src/components/ui/select.tsx +0 -130
  79. package/src/components/ui/separator.tsx +0 -29
  80. package/src/components/ui/sheet.tsx +0 -90
  81. package/src/components/ui/sidebar.tsx +0 -598
  82. package/src/components/ui/skeleton.tsx +0 -15
  83. package/src/components/ui/slider.tsx +0 -18
  84. package/src/components/ui/switch.tsx +0 -26
  85. package/src/components/ui/table.tsx +0 -53
  86. package/src/components/ui/tabs.tsx +0 -47
  87. package/src/components/ui/textarea.tsx +0 -27
  88. package/src/components/ui/toast.tsx +0 -88
  89. package/src/components/ui/toaster.tsx +0 -49
  90. package/src/components/ui/tooltip.tsx +0 -31
  91. package/src/components/ui/use-calendar.tsx +0 -61
  92. package/src/components/ui/use-toast.ts +0 -186
  93. package/src/hooks/use-mobile.tsx +0 -19
  94. package/src/index.ts +0 -299
  95. package/src/lib/help/date-utils.ts +0 -41
  96. package/src/lib/help/format.ts +0 -171
  97. package/src/lib/help/theme.ts +0 -346
  98. package/src/lib/help/uuid.ts +0 -4
  99. package/src/lib/utils.ts +0 -6
  100. package/src/styles/globals.css +0 -59
@@ -1,285 +0,0 @@
1
- import {
2
- ColumnDef,
3
- PaginationState,
4
- SortingState,
5
- getCoreRowModel,
6
- getFilteredRowModel,
7
- getPaginationRowModel,
8
- getSortedRowModel,
9
- useReactTable,
10
- } from '@tanstack/react-table';
11
- import { Filter, Search } from 'lucide-react';
12
- import { useEffect, useRef, useState } from 'react';
13
- import { cn } from '../../../../lib/utils';
14
- import { Button } from '../../button';
15
- import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from '../../sheet';
16
- import { Table, TableBody } from '../../table';
17
- import { DataTableFooter } from './data-table-footer';
18
- import { DataTableHeader } from './data-table-header';
19
- import { DataTableRows } from './data-table-rows';
20
- import { ActionRow, ActionTable, ExportDataTable, FiltersActions } from './types/data-table';
21
-
22
- export interface DataTableProps<TData> {
23
- columns: ColumnDef<TData>[];
24
- data: TData[];
25
- actions?: ActionTable[];
26
- actionsRow?: ActionRow[];
27
- customFilters?: JSX.Element;
28
- className?: string;
29
- title?: string;
30
- rowsPage?: number;
31
- setSearch?: (value?: string) => void;
32
- setSelectRows?: (ids: string[]) => void;
33
- pageChanged?: (pageNumber: number) => void;
34
- pageSizeChanged?: (pageSize: number) => void;
35
- totalRows?: number;
36
- filtersActions?: FiltersActions;
37
- exportData?: ExportDataTable;
38
- textNoRecords?: string;
39
- heightRemainingScroll?: number;
40
- hideFilterField?: boolean;
41
- multiRowSelection?: {
42
- callback: (selectedRows: any[]) => void;
43
- };
44
- hidePagination?: boolean;
45
- disablePagination?: boolean;
46
- isLoading?: boolean;
47
- fixedHeight?: number;
48
- }
49
-
50
- export interface OriginalDataTableData {
51
- id: string;
52
- checked?: boolean;
53
- }
54
-
55
- export function DataTable<TData>({
56
- columns,
57
- data,
58
- className,
59
- title,
60
- rowsPage,
61
- actions,
62
- actionsRow,
63
- customFilters,
64
- setSearch,
65
- pageChanged,
66
- pageSizeChanged,
67
- totalRows,
68
- filtersActions,
69
- exportData,
70
- textNoRecords,
71
- heightRemainingScroll,
72
- hideFilterField,
73
- multiRowSelection,
74
- hidePagination,
75
- disablePagination,
76
- isLoading,
77
- fixedHeight,
78
- }: DataTableProps<TData>) {
79
- const [sorting, setSorting] = useState<SortingState>([]);
80
- const [pagination, setPagination] = useState<PaginationState>({
81
- pageIndex: 0,
82
- pageSize: rowsPage ?? 25,
83
- });
84
- const enableMultiRowSelection = multiRowSelection !== undefined;
85
- const [rowSelection, setRowSelection] = useState(
86
- enableMultiRowSelection
87
- ? Object.fromEntries(
88
- (Array.isArray(data) ? data : []).map((row: any, idx: number) => {
89
- return [idx, row.checked];
90
- }),
91
- )
92
- : {},
93
- );
94
- const debounceTimeout = useRef<NodeJS.Timeout | null>(null);
95
- const tableContainerRef = useRef<HTMLDivElement>(null);
96
- const [tableHeight, setTableHeight] = useState('auto');
97
- totalRows = totalRows ?? data.length;
98
-
99
- const table = useReactTable({
100
- manualPagination: true,
101
- data: data,
102
- columns,
103
- getPaginationRowModel: getPaginationRowModel(),
104
- onPaginationChange: setPagination,
105
- getCoreRowModel: getCoreRowModel(),
106
- onSortingChange: setSorting,
107
- getSortedRowModel: getSortedRowModel(),
108
- getFilteredRowModel: getFilteredRowModel(),
109
- onRowSelectionChange: (rowSelection) => {
110
- setRowSelection(rowSelection);
111
- },
112
- enableMultiRowSelection: enableMultiRowSelection,
113
- state: { pagination, rowSelection, sorting },
114
- pageCount: Math.ceil(totalRows / pagination.pageSize),
115
- });
116
-
117
- const totalPages = table.getPageCount();
118
- const currentPage = table.getState().pagination.pageIndex;
119
- const selectedRows = table.getSelectedRowModel().rows;
120
- const selectedIds = selectedRows.map((row) => (row.original as OriginalDataTableData).id);
121
-
122
- useEffect(() => {
123
- if (data.length === 0 && pagination.pageIndex > 0) {
124
- setPagination({ ...pagination, pageIndex: 0 });
125
- }
126
- }, [data]);
127
-
128
- useEffect(() => {
129
- handleResize();
130
-
131
- window.addEventListener('resize', handleResize);
132
- return () => {
133
- window.removeEventListener('resize', handleResize);
134
- };
135
- }, []);
136
-
137
- useEffect(() => {
138
- if (pageChanged) pageChanged(pagination.pageIndex + 1);
139
- }, [pagination]);
140
-
141
- useEffect(() => {
142
- const selectedRowsChecked = selectedRows.map((row) => row.original);
143
- if (multiRowSelection && selectedRowsChecked.length > 0) {
144
- multiRowSelection.callback(selectedRowsChecked);
145
- }
146
- }, [rowSelection]);
147
-
148
- const handleResize = () => {
149
- if (tableContainerRef.current) {
150
- const newHeight = window.innerHeight - tableContainerRef.current.getBoundingClientRect().top - (hidePagination ? 30 : 74);
151
-
152
- setTableHeight(`${newHeight - (heightRemainingScroll ?? 0)}px`);
153
- }
154
- };
155
-
156
- const handleSearchChange = (event: React.KeyboardEvent<HTMLInputElement>) => {
157
- const value = event.currentTarget.value;
158
-
159
- if (debounceTimeout.current) {
160
- clearTimeout(debounceTimeout.current);
161
- }
162
-
163
- debounceTimeout.current = setTimeout(() => {
164
- setSearch?.(value);
165
- handlePage(0);
166
- }, 300);
167
- };
168
-
169
- const handlePageSize = (value: number) => {
170
- pageSizeChanged?.(value);
171
- setPagination({ pageIndex: 0, pageSize: value });
172
- };
173
-
174
- const handlePage = (index: number) => {
175
- if (index !== currentPage) {
176
- setPagination({ ...pagination, pageIndex: index });
177
- }
178
- };
179
-
180
- return (
181
- <div className='flex flex-col flex-1'>
182
- {(!hideFilterField || filtersActions || customFilters || actions) && (
183
- <div className='flex items-end justify-between mb-4 space-x-6'>
184
- <div className='flex items-center gap-x-4'>
185
- {!hideFilterField && (
186
- <div className='flex bg-background items-center border border-slate-300 rounded-sm w-[350px] overflow-hidden focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 group'>
187
- <div className='pl-3.5 transform transition-transform duration-300 group-hover:-translate-x-1'>
188
- <Search size={18} className='w-5 h-5 stroke-zinc-500 dark:stroke-default' />
189
- </div>
190
-
191
- <input
192
- placeholder='Buscar'
193
- onKeyUp={(event) => {
194
- handleSearchChange(event);
195
- }}
196
- className='w-full bg-background text-default border-none focus:ring-0 focus:outline-none px-3 py-2 transform transition-transform duration-300 group-hover:-translate-x-1 '
197
- />
198
- </div>
199
- )}
200
- {filtersActions && (
201
- <Sheet open={filtersActions.filterOpen} onOpenChange={filtersActions.setFilterOpen}>
202
- <SheetTrigger asChild>
203
- <Button variant='secondary' type='button'>
204
- <Filter size={20} className='h-4 w-4' /> Filtros
205
- {filtersActions.countFilters > 0 && (
206
- <div className='bg-background-primary text-white rounded-full h-5 w-5 flex items-center justify-center text-sm placeholder:text-muted-foreground'>
207
- {filtersActions.countFilters}
208
- </div>
209
- )}
210
- </Button>
211
- </SheetTrigger>
212
- <SheetContent>
213
- <SheetHeader>
214
- <SheetTitle>Filtros</SheetTitle>
215
- <SheetDescription />
216
- </SheetHeader>
217
- <div className='flex flex-col py-6'>{filtersActions.fields}</div>
218
- </SheetContent>
219
- </Sheet>
220
- )}
221
- </div>
222
- {customFilters}
223
- <div className='flex space-x-4 content-end'>
224
- {actions?.map((action, index) => (
225
- <div key={`action-table-${index}`}>
226
- <Button
227
- onClick={() => action.onClick?.(selectedIds, selectedRows)}
228
- className={cn(action.className, action.hideUnselectedRows && selectedRows.length === 0 ? 'hidden' : '')}
229
- variant={(action.variant as 'link' | 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost') || 'default'}
230
- disabled={action.disabled}
231
- >
232
- <div className='[&_svg]:size-5'>{action.icon}</div>
233
- {action.label}
234
- </Button>
235
- </div>
236
- ))}
237
- </div>
238
- </div>
239
- )}
240
-
241
- <div className={`flex-1 flex flex-col rounded-md border ${className}`}>
242
- <div className='flex items-center justify-between'>{title && <div className='text-h4 p-4'>{title}</div>}</div>
243
- <div
244
- id='data-table'
245
- ref={tableContainerRef}
246
- style={fixedHeight ? { height: fixedHeight } : { height: tableHeight }}
247
- className='flex flex-col justify-between rounded-md overflow-x-auto overflow-y-auto'
248
- >
249
- <Table>
250
- <DataTableHeader
251
- table={table}
252
- canActionsRow={actionsRow && actionsRow.length > 0}
253
- enableMultiRowSelection={enableMultiRowSelection}
254
- />
255
- <TableBody className='bg-background'>
256
- <DataTableRows
257
- table={table}
258
- columns={columns}
259
- isLoading={isLoading}
260
- actionsRow={actionsRow}
261
- textNoRecords={textNoRecords}
262
- enableMultiRowSelection={enableMultiRowSelection}
263
- />
264
- </TableBody>
265
- </Table>
266
- </div>
267
- </div>
268
-
269
- <DataTableFooter
270
- hidePagination={hidePagination}
271
- disablePagination={disablePagination}
272
- isLoading={isLoading}
273
- totalRows={totalRows}
274
- totalPages={totalPages}
275
- currentPage={currentPage}
276
- pagination={pagination}
277
- handlePageSize={handlePageSize}
278
- handlePage={handlePage}
279
- previousPage={{ action: () => table.previousPage(), disabled: !table.getCanPreviousPage() }}
280
- nextPage={{ action: () => table.nextPage(), disabled: !table.getCanNextPage() }}
281
- exportData={exportData}
282
- />
283
- </div>
284
- );
285
- }
@@ -1,31 +0,0 @@
1
- export type ActionTable = {
2
- label: string;
3
- icon?: JSX.Element;
4
- variant?: string;
5
- onClick?: (ids: any[], rows: any[]) => void;
6
- className?: string;
7
- hideUnselectedRows?: boolean;
8
- disabled?: boolean;
9
- };
10
-
11
- export type ActionRow = {
12
- label: string;
13
- icon?: JSX.Element;
14
- variant?: string;
15
- onClick?: (row: any) => void;
16
- className?: (row: any) => string;
17
- disabled?: (row: any) => boolean;
18
- };
19
-
20
- export interface ExportDataTable {
21
- type: 'xlsx' | 'dialog';
22
- url: string;
23
- params?: Record<string, string>;
24
- }
25
-
26
- export interface FiltersActions {
27
- fields: JSX.Element;
28
- countFilters: number;
29
- filterOpen: boolean;
30
- setFilterOpen: React.Dispatch<React.SetStateAction<boolean>>;
31
- }
@@ -1,121 +0,0 @@
1
- import { createContext, useContext, useEffect, useState } from 'react';
2
- import { replaceThemeTailwindColors } from '../../../lib/help/theme';
3
-
4
- type Theme = 'light' | 'dark' | 'dark-side';
5
-
6
- type PortalDefinitions = {
7
- faviconPath: string;
8
- fullLogoPath: string;
9
- bannerDesktopPath: string;
10
- mvnoPrimaryColor: string;
11
- mvnoMainTheme: Theme;
12
- title: string;
13
- hideModuleSwitcher: boolean;
14
- };
15
-
16
- type ThemeProviderProps = {
17
- children: React.ReactNode;
18
- defaultTheme?: PortalDefinitions;
19
- storageKey?: string;
20
- };
21
-
22
- type ThemeProviderState = {
23
- portalDefinitions: PortalDefinitions;
24
- setPortalDefinitions: (portalDefinitions: PortalDefinitions) => void;
25
- };
26
-
27
- export const DEFAULT_THEME_DATA: PortalDefinitions = {
28
- faviconPath: '/logos/logosEai/Eai_roxo_48x48px.png',
29
- fullLogoPath: '/logos/logosEai/Eai_Roxo_60x42px.png',
30
- bannerDesktopPath: '/imgs/background-auth.png',
31
- mvnoPrimaryColor: 'violet',
32
- mvnoMainTheme: 'light',
33
- title: 'Eaí',
34
- hideModuleSwitcher: false,
35
- };
36
-
37
- const initialState: ThemeProviderState = {
38
- portalDefinitions: DEFAULT_THEME_DATA,
39
- setPortalDefinitions: () => null,
40
- };
41
-
42
- const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
43
-
44
- export function ThemeProvider({ children, defaultTheme = DEFAULT_THEME_DATA, storageKey = 'vite-ui-theme', ...props }: ThemeProviderProps) {
45
- const [portalDefinitions, setPortalDefinitionsState] = useState<PortalDefinitions>({
46
- faviconPath: localStorage.getItem(`${storageKey}-faviconPath`) || defaultTheme.faviconPath,
47
- fullLogoPath: localStorage.getItem(`${storageKey}-fullLogoPath`) || defaultTheme.fullLogoPath,
48
- bannerDesktopPath: localStorage.getItem(`${storageKey}-bannerDesktopPath`) || defaultTheme.bannerDesktopPath,
49
- mvnoPrimaryColor: localStorage.getItem(`${storageKey}-mvnoPrimaryColor`) || defaultTheme.mvnoPrimaryColor,
50
- mvnoMainTheme: (localStorage.getItem(storageKey) as Theme) || defaultTheme.mvnoMainTheme,
51
- title: localStorage.getItem(`${storageKey}-title`) || defaultTheme.title,
52
- hideModuleSwitcher: localStorage.getItem(`${storageKey}-hideModuleSwitcher`) === 'true',
53
- });
54
-
55
- useEffect(() => {
56
- const theme = portalDefinitions?.mvnoMainTheme;
57
-
58
- const root = window.document.documentElement;
59
- root.classList.remove('light', 'dark', 'dark-side');
60
- root.classList.add(theme);
61
-
62
- document.title = portalDefinitions?.title;
63
- const meta = document.querySelector('meta[name="description"]');
64
- if (meta) {
65
- meta.setAttribute('content', portalDefinitions?.title);
66
- }
67
-
68
- let link = document.querySelector<HTMLLinkElement>("link[rel~='icon']");
69
- if (!link) {
70
- link = document.createElement('link');
71
- link.rel = 'icon';
72
- document.getElementsByTagName('head')[0].appendChild(link);
73
- }
74
- link.href = portalDefinitions?.faviconPath;
75
-
76
- const el = replaceThemeTailwindColors(theme, portalDefinitions?.mvnoPrimaryColor);
77
-
78
- document.getElementById('theme-variables') &&
79
- document.getElementsByTagName('head')[0].removeChild(document.getElementById('theme-variables')!);
80
- document.getElementsByTagName('head')[0].appendChild(el);
81
- }, [portalDefinitions]);
82
-
83
- const setPortalDefinitions = (portalDefinitions: PortalDefinitions) => {
84
- localStorage.setItem(`${storageKey}-faviconPath`, portalDefinitions.faviconPath);
85
- localStorage.setItem(`${storageKey}-fullLogoPath`, portalDefinitions.fullLogoPath);
86
- localStorage.setItem(`${storageKey}-bannerDesktopPath`, portalDefinitions.bannerDesktopPath);
87
- localStorage.setItem(`${storageKey}-mvnoPrimaryColor`, portalDefinitions.mvnoPrimaryColor);
88
- localStorage.setItem(`${storageKey}-mvnoMainTheme`, portalDefinitions.mvnoMainTheme);
89
- localStorage.setItem(`${storageKey}-title`, portalDefinitions.title);
90
- localStorage.setItem(`${storageKey}-hideModuleSwitcher`, String(portalDefinitions.hideModuleSwitcher));
91
-
92
- setPortalDefinitionsState({
93
- faviconPath: portalDefinitions.faviconPath || DEFAULT_THEME_DATA.faviconPath,
94
- fullLogoPath: portalDefinitions.fullLogoPath || DEFAULT_THEME_DATA.fullLogoPath,
95
- bannerDesktopPath: portalDefinitions.bannerDesktopPath || DEFAULT_THEME_DATA.bannerDesktopPath,
96
- mvnoPrimaryColor: portalDefinitions.mvnoPrimaryColor || DEFAULT_THEME_DATA.mvnoPrimaryColor,
97
- mvnoMainTheme: portalDefinitions.mvnoMainTheme ? (portalDefinitions.mvnoMainTheme as Theme) : DEFAULT_THEME_DATA.mvnoMainTheme,
98
- title: portalDefinitions.title || DEFAULT_THEME_DATA.title,
99
- hideModuleSwitcher: portalDefinitions.hideModuleSwitcher || DEFAULT_THEME_DATA.hideModuleSwitcher,
100
- });
101
- };
102
-
103
- const value: ThemeProviderState = {
104
- portalDefinitions,
105
- setPortalDefinitions: setPortalDefinitions,
106
- };
107
-
108
- return (
109
- <ThemeProviderContext.Provider {...props} value={value}>
110
- {children}
111
- </ThemeProviderContext.Provider>
112
- );
113
- }
114
-
115
- export const useTheme = () => {
116
- const context = useContext(ThemeProviderContext);
117
-
118
- if (context === undefined) throw new Error('useTheme must be used within a ThemeProvider');
119
-
120
- return context;
121
- };
@@ -1,63 +0,0 @@
1
- import { addDays, format } from "date-fns"
2
- import { CalendarIcon } from "lucide-react"
3
- import * as React from "react"
4
- import { DateRange } from "react-day-picker"
5
-
6
- import { cn } from "@/lib/utils"
7
- import { Button } from "./button"
8
- import { Calendar } from "./calendar"
9
- import {
10
- Popover,
11
- PopoverContent,
12
- PopoverTrigger,
13
- } from "./popover"
14
-
15
- export function DatePickerWithRange({
16
- className,
17
- }: React.HTMLAttributes<HTMLDivElement>) {
18
- const [date, setDate] = React.useState<DateRange | undefined>({
19
- from: new Date(2022, 0, 20),
20
- to: addDays(new Date(2022, 0, 20), 20),
21
- })
22
-
23
- return (
24
- <div className={cn("grid gap-2", className)}>
25
- <Popover>
26
- <PopoverTrigger asChild>
27
- <Button
28
- id="date"
29
- variant={"outline"}
30
- className={cn(
31
- "w-[300px] justify-start text-left font-normal",
32
- !date && "text-muted-foreground"
33
- )}
34
- >
35
- <CalendarIcon />
36
- {date?.from ? (
37
- date.to ? (
38
- <>
39
- {format(date.from, "LLL dd, y")} -{" "}
40
- {format(date.to, "LLL dd, y")}
41
- </>
42
- ) : (
43
- format(date.from, "LLL dd, y")
44
- )
45
- ) : (
46
- <span>Pick a date</span>
47
- )}
48
- </Button>
49
- </PopoverTrigger>
50
- <PopoverContent className="w-auto p-0" align="start">
51
- <Calendar
52
- initialFocus
53
- mode="range"
54
- defaultMonth={date?.from}
55
- selected={date}
56
- onSelect={setDate}
57
- numberOfMonths={2}
58
- />
59
- </PopoverContent>
60
- </Popover>
61
- </div>
62
- )
63
- }
@@ -1,84 +0,0 @@
1
- 'use client';
2
-
3
- import * as DialogPrimitive from '@radix-ui/react-dialog';
4
- import { X } from 'lucide-react';
5
- import * as React from 'react';
6
- import { cn } from '../../lib/utils';
7
-
8
- const Dialog = DialogPrimitive.Root;
9
-
10
- const DialogTrigger = DialogPrimitive.Trigger;
11
-
12
- const DialogPortal = DialogPrimitive.Portal;
13
-
14
- const DialogClose = DialogPrimitive.Close;
15
-
16
- const DialogOverlay = React.forwardRef<
17
- React.ElementRef<typeof DialogPrimitive.Overlay>,
18
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
19
- >(({ className, ...props }, ref) => (
20
- <DialogPrimitive.Overlay
21
- ref={ref}
22
- className={cn(
23
- 'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
24
- className,
25
- )}
26
- {...props}
27
- />
28
- ));
29
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
30
-
31
- interface DialogContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
32
- hideClose?: boolean;
33
- }
34
-
35
- const DialogContent = React.forwardRef<React.ElementRef<typeof DialogPrimitive.Content>, DialogContentProps>(
36
- ({ className, children, hideClose, ...props }, ref) => (
37
- <DialogPortal>
38
- <DialogOverlay />
39
- <DialogPrimitive.Content
40
- ref={ref}
41
- className={cn(
42
- 'fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
43
- className,
44
- )}
45
- {...props}
46
- >
47
- {children}
48
- {!hideClose && (
49
- <DialogPrimitive.Close className='absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground'>
50
- <X className='h-4 w-4' />
51
- <span className='sr-only'>Close</span>
52
- </DialogPrimitive.Close>
53
- )}
54
- </DialogPrimitive.Content>
55
- </DialogPortal>
56
- ),
57
- );
58
- DialogContent.displayName = DialogPrimitive.Content.displayName;
59
-
60
- const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
61
- <div className={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)} {...props} />
62
- );
63
- DialogHeader.displayName = 'DialogHeader';
64
-
65
- const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
66
- <div className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)} {...props} />
67
- );
68
- DialogFooter.displayName = 'DialogFooter';
69
-
70
- const DialogTitle = React.forwardRef<React.ElementRef<typeof DialogPrimitive.Title>, React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>>(
71
- ({ className, ...props }, ref) => (
72
- <DialogPrimitive.Title ref={ref} className={cn('text-lg font-semibold leading-none tracking-tight', className)} {...props} />
73
- ),
74
- );
75
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
76
-
77
- const DialogDescription = React.forwardRef<
78
- React.ElementRef<typeof DialogPrimitive.Description>,
79
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
80
- >(({ className, ...props }, ref) => <DialogPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />);
81
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
82
-
83
- export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger };
84
-
@@ -1,116 +0,0 @@
1
- import * as React from "react"
2
- import { Drawer as DrawerPrimitive } from "vaul"
3
-
4
- import { cn } from "@/lib/utils"
5
-
6
- const Drawer = ({
7
- shouldScaleBackground = true,
8
- ...props
9
- }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
10
- <DrawerPrimitive.Root
11
- shouldScaleBackground={shouldScaleBackground}
12
- {...props}
13
- />
14
- )
15
- Drawer.displayName = "Drawer"
16
-
17
- const DrawerTrigger = DrawerPrimitive.Trigger
18
-
19
- const DrawerPortal = DrawerPrimitive.Portal
20
-
21
- const DrawerClose = DrawerPrimitive.Close
22
-
23
- const DrawerOverlay = React.forwardRef<
24
- React.ElementRef<typeof DrawerPrimitive.Overlay>,
25
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
26
- >(({ className, ...props }, ref) => (
27
- <DrawerPrimitive.Overlay
28
- ref={ref}
29
- className={cn("fixed inset-0 z-50 bg-black/80", className)}
30
- {...props}
31
- />
32
- ))
33
- DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName
34
-
35
- const DrawerContent = React.forwardRef<
36
- React.ElementRef<typeof DrawerPrimitive.Content>,
37
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
38
- >(({ className, children, ...props }, ref) => (
39
- <DrawerPortal>
40
- <DrawerOverlay />
41
- <DrawerPrimitive.Content
42
- ref={ref}
43
- className={cn(
44
- "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
45
- className
46
- )}
47
- {...props}
48
- >
49
- <div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
50
- {children}
51
- </DrawerPrimitive.Content>
52
- </DrawerPortal>
53
- ))
54
- DrawerContent.displayName = "DrawerContent"
55
-
56
- const DrawerHeader = ({
57
- className,
58
- ...props
59
- }: React.HTMLAttributes<HTMLDivElement>) => (
60
- <div
61
- className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)}
62
- {...props}
63
- />
64
- )
65
- DrawerHeader.displayName = "DrawerHeader"
66
-
67
- const DrawerFooter = ({
68
- className,
69
- ...props
70
- }: React.HTMLAttributes<HTMLDivElement>) => (
71
- <div
72
- className={cn("mt-auto flex flex-col gap-2 p-4", className)}
73
- {...props}
74
- />
75
- )
76
- DrawerFooter.displayName = "DrawerFooter"
77
-
78
- const DrawerTitle = React.forwardRef<
79
- React.ElementRef<typeof DrawerPrimitive.Title>,
80
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
81
- >(({ className, ...props }, ref) => (
82
- <DrawerPrimitive.Title
83
- ref={ref}
84
- className={cn(
85
- "text-lg font-semibold leading-none tracking-tight",
86
- className
87
- )}
88
- {...props}
89
- />
90
- ))
91
- DrawerTitle.displayName = DrawerPrimitive.Title.displayName
92
-
93
- const DrawerDescription = React.forwardRef<
94
- React.ElementRef<typeof DrawerPrimitive.Description>,
95
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
96
- >(({ className, ...props }, ref) => (
97
- <DrawerPrimitive.Description
98
- ref={ref}
99
- className={cn("text-sm text-muted-foreground", className)}
100
- {...props}
101
- />
102
- ))
103
- DrawerDescription.displayName = DrawerPrimitive.Description.displayName
104
-
105
- export {
106
- Drawer,
107
- DrawerPortal,
108
- DrawerOverlay,
109
- DrawerTrigger,
110
- DrawerClose,
111
- DrawerContent,
112
- DrawerHeader,
113
- DrawerFooter,
114
- DrawerTitle,
115
- DrawerDescription,
116
- }