pixelize-design-library 2.2.192 → 3.0.1-beta.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.
- package/.claude/settings.local.json +9 -0
- package/MIGRATION.md +562 -0
- package/coverage/clover.xml +638 -0
- package/coverage/coverage-final.json +20 -0
- package/coverage/lcov-report/Table/CompactSelect.tsx.html +379 -0
- package/coverage/lcov-report/Table/Components/ActiveFilters.tsx.html +514 -0
- package/coverage/lcov-report/Table/Components/HeaderActions.tsx.html +373 -0
- package/coverage/lcov-report/Table/Components/Pagination.tsx.html +574 -0
- package/coverage/lcov-report/Table/Components/TableActions.tsx.html +574 -0
- package/coverage/lcov-report/Table/Components/TableBody.tsx.html +1027 -0
- package/coverage/lcov-report/Table/Components/TableFilters.tsx.html +397 -0
- package/coverage/lcov-report/Table/Components/TableHeader.tsx.html +1060 -0
- package/coverage/lcov-report/Table/Components/TableLoading.tsx.html +361 -0
- package/coverage/lcov-report/Table/Components/TableSearch.tsx.html +337 -0
- package/coverage/lcov-report/Table/Components/index.html +266 -0
- package/coverage/lcov-report/Table/Components/useDebounce.ts.html +178 -0
- package/coverage/lcov-report/Table/Components/useTable.ts.html +778 -0
- package/coverage/lcov-report/Table/LeftFilterPane.tsx.html +1810 -0
- package/coverage/lcov-report/Table/SelectOperationControls.tsx.html +178 -0
- package/coverage/lcov-report/Table/Table.tsx.html +1567 -0
- package/coverage/lcov-report/Table/TableProps.tsx.html +658 -0
- package/coverage/lcov-report/Table/TableSettings/ManageColumns.tsx.html +619 -0
- package/coverage/lcov-report/Table/TableSettings/TableFilters.tsx.html +229 -0
- package/coverage/lcov-report/Table/TableSettings/TableSettings.tsx.html +532 -0
- package/coverage/lcov-report/Table/TableSettings/index.html +146 -0
- package/coverage/lcov-report/Table/TableToDo.tsx.html +973 -0
- package/coverage/lcov-report/Table/TextOperationControls.tsx.html +271 -0
- package/coverage/lcov-report/Table/filterTypes.ts.html +97 -0
- package/coverage/lcov-report/Table/index.html +176 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +1836 -0
- package/dist/Assets/defaultLogo.tsx +31 -0
- package/dist/Components/Table/Components/ActiveFilters.js +3 -3
- package/dist/Theme/Dark/palette.d.ts +370 -0
- package/dist/Theme/Dark/palette.js +372 -0
- package/dist/components-v2/AlertDialog/AlertDialog.d.ts +23 -0
- package/dist/components-v2/AlertDialog/AlertDialog.js +98 -0
- package/dist/components-v2/Breadcrumbs/Breadcrumbs.d.ts +14 -0
- package/dist/components-v2/Breadcrumbs/Breadcrumbs.js +66 -0
- package/dist/components-v2/Charts/AreaChart.d.ts +23 -0
- package/dist/components-v2/Charts/AreaChart.js +63 -0
- package/dist/components-v2/Charts/BarChart.d.ts +25 -0
- package/dist/components-v2/Charts/BarChart.js +57 -0
- package/dist/components-v2/Charts/LineChart.d.ts +23 -0
- package/dist/components-v2/Charts/LineChart.js +55 -0
- package/dist/components-v2/Charts/PieChart.d.ts +15 -0
- package/dist/components-v2/Charts/PieChart.js +54 -0
- package/dist/components-v2/Charts/PolarChart.d.ts +14 -0
- package/dist/components-v2/Charts/PolarChart.js +54 -0
- package/dist/components-v2/Charts/chartOptions.d.ts +7 -0
- package/dist/components-v2/Charts/chartOptions.js +41 -0
- package/dist/components-v2/Charts/useChartTheme.d.ts +22 -0
- package/dist/components-v2/Charts/useChartTheme.js +106 -0
- package/dist/components-v2/ContactForm/ContactForm.d.ts +25 -0
- package/dist/components-v2/ContactForm/ContactForm.js +116 -0
- package/dist/components-v2/DatePicker/Calendar.d.ts +19 -0
- package/dist/components-v2/DatePicker/Calendar.js +212 -0
- package/dist/components-v2/DatePicker/DatePicker.d.ts +46 -0
- package/dist/components-v2/DatePicker/DatePicker.js +189 -0
- package/dist/components-v2/DatePicker/TimePicker.d.ts +12 -0
- package/dist/components-v2/DatePicker/TimePicker.js +105 -0
- package/dist/components-v2/DatePicker/utils.d.ts +31 -0
- package/dist/components-v2/DatePicker/utils.js +109 -0
- package/dist/components-v2/Drawer/Drawer.d.ts +27 -0
- package/dist/components-v2/Drawer/Drawer.js +132 -0
- package/dist/components-v2/FeedbackForm/FeedbackForm.d.ts +26 -0
- package/dist/components-v2/FeedbackForm/FeedbackForm.js +112 -0
- package/dist/components-v2/FileUploader/FileUploader.d.ts +28 -0
- package/dist/components-v2/FileUploader/FileUploader.js +127 -0
- package/dist/components-v2/Input/TextInput.d.ts +41 -0
- package/dist/components-v2/Input/TextInput.js +169 -0
- package/dist/components-v2/KanbanBoard/KanbanBoard.d.ts +39 -0
- package/dist/components-v2/KanbanBoard/KanbanBoard.js +101 -0
- package/dist/components-v2/Layout/AppLayout.d.ts +22 -0
- package/dist/components-v2/Layout/AppLayout.js +53 -0
- package/dist/components-v2/Loading/Loading.d.ts +19 -0
- package/dist/components-v2/Loading/Loading.js +55 -0
- package/dist/components-v2/Modal/Modal.d.ts +30 -0
- package/dist/components-v2/Modal/Modal.js +82 -0
- package/dist/components-v2/NavigationBar/NavigationBar.d.ts +47 -0
- package/dist/components-v2/NavigationBar/NavigationBar.js +148 -0
- package/dist/components-v2/Notification/Notification.d.ts +22 -0
- package/dist/components-v2/Notification/Notification.js +113 -0
- package/dist/components-v2/NumberInput/NumberInput.d.ts +37 -0
- package/dist/components-v2/NumberInput/NumberInput.js +210 -0
- package/dist/components-v2/PinInput/PinInput.d.ts +26 -0
- package/dist/components-v2/PinInput/PinInput.js +138 -0
- package/dist/components-v2/ProfilePhotoViewer/ProfilePhotoViewer.d.ts +18 -0
- package/dist/components-v2/ProfilePhotoViewer/ProfilePhotoViewer.js +91 -0
- package/dist/components-v2/Select/Select.d.ts +41 -0
- package/dist/components-v2/Select/Select.js +284 -0
- package/dist/components-v2/Sidebar/Sidebar.d.ts +41 -0
- package/dist/components-v2/Sidebar/Sidebar.js +182 -0
- package/dist/components-v2/Slider/Slider.d.ts +18 -0
- package/dist/components-v2/Slider/Slider.js +101 -0
- package/dist/components-v2/Table/Table.d.ts +7 -0
- package/dist/components-v2/Table/Table.js +172 -0
- package/dist/components-v2/Table/TableProps.d.ts +139 -0
- package/dist/components-v2/Table/TableProps.js +9 -0
- package/dist/components-v2/Table/components/ActiveFilters.d.ts +10 -0
- package/dist/components-v2/Table/components/ActiveFilters.js +70 -0
- package/dist/components-v2/Table/components/BulkActionBar.d.ts +11 -0
- package/dist/components-v2/Table/components/BulkActionBar.js +92 -0
- package/dist/components-v2/Table/components/ColumnResizeHandle.d.ts +7 -0
- package/dist/components-v2/Table/components/ColumnResizeHandle.js +41 -0
- package/dist/components-v2/Table/components/Pagination.d.ts +11 -0
- package/dist/components-v2/Table/components/Pagination.js +92 -0
- package/dist/components-v2/Table/components/TableBody.d.ts +23 -0
- package/dist/components-v2/Table/components/TableBody.js +69 -0
- package/dist/components-v2/Table/components/TableCell.d.ts +14 -0
- package/dist/components-v2/Table/components/TableCell.js +63 -0
- package/dist/components-v2/Table/components/TableEmptyState.d.ts +12 -0
- package/dist/components-v2/Table/components/TableEmptyState.js +55 -0
- package/dist/components-v2/Table/components/TableErrorState.d.ts +6 -0
- package/dist/components-v2/Table/components/TableErrorState.js +52 -0
- package/dist/components-v2/Table/components/TableHeader.d.ts +21 -0
- package/dist/components-v2/Table/components/TableHeader.js +94 -0
- package/dist/components-v2/Table/components/TableRow.d.ts +20 -0
- package/dist/components-v2/Table/components/TableRow.js +64 -0
- package/dist/components-v2/Table/components/TableSearch.d.ts +8 -0
- package/dist/components-v2/Table/components/TableSearch.js +47 -0
- package/dist/components-v2/Table/filters/FilterChips.d.ts +6 -0
- package/dist/components-v2/Table/filters/FilterChips.js +9 -0
- package/dist/components-v2/Table/filters/LeftFilterPane.d.ts +17 -0
- package/dist/components-v2/Table/filters/LeftFilterPane.js +105 -0
- package/dist/components-v2/Table/filters/TableFilters.d.ts +12 -0
- package/dist/components-v2/Table/filters/TableFilters.js +127 -0
- package/dist/components-v2/Table/hooks/useColumnResize.d.ts +15 -0
- package/dist/components-v2/Table/hooks/useColumnResize.js +104 -0
- package/dist/components-v2/Table/hooks/useTable.d.ts +58 -0
- package/dist/components-v2/Table/hooks/useTable.js +254 -0
- package/dist/components-v2/Table/hooks/useTableKeyboard.d.ts +25 -0
- package/dist/components-v2/Table/hooks/useTableKeyboard.js +112 -0
- package/dist/components-v2/Table/hooks/useVirtualScroll.d.ts +29 -0
- package/dist/components-v2/Table/hooks/useVirtualScroll.js +83 -0
- package/dist/components-v2/Table/settings/ManageColumns.d.ts +12 -0
- package/dist/components-v2/Table/settings/ManageColumns.js +59 -0
- package/dist/components-v2/Table/settings/TableSettings.d.ts +12 -0
- package/dist/components-v2/Table/settings/TableSettings.js +57 -0
- package/dist/components-v2/Table/utils/filterUtils.d.ts +7 -0
- package/dist/components-v2/Table/utils/filterUtils.js +149 -0
- package/dist/components-v2/Table/utils/sortUtils.d.ts +6 -0
- package/dist/components-v2/Table/utils/sortUtils.js +65 -0
- package/dist/components-v2/Tag/Tag.d.ts +15 -0
- package/dist/components-v2/Tag/Tag.js +87 -0
- package/dist/components-v2/Timeline/Timeline.d.ts +18 -0
- package/dist/components-v2/Timeline/Timeline.js +76 -0
- package/dist/components-v2/Toaster/Toaster.d.ts +61 -0
- package/dist/components-v2/Toaster/Toaster.js +63 -0
- package/dist/components-v2/Toggle/Toggle.d.ts +28 -0
- package/dist/components-v2/Toggle/Toggle.js +90 -0
- package/dist/components-v2/ui/accordion.d.ts +12 -0
- package/dist/components-v2/ui/accordion.js +104 -0
- package/dist/components-v2/ui/alert.d.ts +18 -0
- package/dist/components-v2/ui/alert.js +99 -0
- package/dist/components-v2/ui/avatar.d.ts +12 -0
- package/dist/components-v2/ui/avatar.js +80 -0
- package/dist/components-v2/ui/badge.d.ts +10 -0
- package/dist/components-v2/ui/badge.js +76 -0
- package/dist/components-v2/ui/button.d.ts +18 -0
- package/dist/components-v2/ui/button.js +97 -0
- package/dist/components-v2/ui/checkbox.d.ts +15 -0
- package/dist/components-v2/ui/checkbox.js +86 -0
- package/dist/components-v2/ui/dialog.d.ts +30 -0
- package/dist/components-v2/ui/dialog.js +115 -0
- package/dist/components-v2/ui/dropdown-menu.d.ts +26 -0
- package/dist/components-v2/ui/dropdown-menu.js +121 -0
- package/dist/components-v2/ui/field.d.ts +32 -0
- package/dist/components-v2/ui/field.js +62 -0
- package/dist/components-v2/ui/form-field.d.ts +25 -0
- package/dist/components-v2/ui/form-field.js +96 -0
- package/dist/components-v2/ui/input.d.ts +9 -0
- package/dist/components-v2/ui/input.js +73 -0
- package/dist/components-v2/ui/label.d.ts +10 -0
- package/dist/components-v2/ui/label.js +70 -0
- package/dist/components-v2/ui/popover.d.ts +9 -0
- package/dist/components-v2/ui/popover.js +60 -0
- package/dist/components-v2/ui/progress.d.ts +12 -0
- package/dist/components-v2/ui/progress.js +75 -0
- package/dist/components-v2/ui/radio-group.d.ts +17 -0
- package/dist/components-v2/ui/radio-group.js +91 -0
- package/dist/components-v2/ui/select.d.ts +24 -0
- package/dist/components-v2/ui/select.js +122 -0
- package/dist/components-v2/ui/separator.d.ts +5 -0
- package/dist/components-v2/ui/separator.js +55 -0
- package/dist/components-v2/ui/skeleton.d.ts +9 -0
- package/dist/components-v2/ui/skeleton.js +68 -0
- package/dist/components-v2/ui/spinner.d.ts +16 -0
- package/dist/components-v2/ui/spinner.js +64 -0
- package/dist/components-v2/ui/switch.d.ts +10 -0
- package/dist/components-v2/ui/switch.js +81 -0
- package/dist/components-v2/ui/tabs.d.ts +13 -0
- package/dist/components-v2/ui/tabs.js +95 -0
- package/dist/components-v2/ui/textarea.d.ts +10 -0
- package/dist/components-v2/ui/textarea.js +96 -0
- package/dist/components-v2/ui/tooltip.d.ts +17 -0
- package/dist/components-v2/ui/tooltip.js +75 -0
- package/dist/index.d.ts +128 -64
- package/dist/index.js +246 -173
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/theme-v2/ThemeProvider.d.ts +19 -0
- package/dist/theme-v2/ThemeProvider.js +149 -0
- package/dist/theme-v2/dark.css +47 -0
- package/dist/theme-v2/tokens.css +72 -0
- package/package.json +41 -20
- package/tailwind.config.ts +91 -0
- package/vite.config.ts +49 -10
- package/index.html +0 -13
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.endOfMonth = exports.startOfMonth = exports.startOfDay = exports.isSameMonth = exports.isSameDay = exports.isBefore = exports.isAfter = exports.addYears = exports.addMonths = exports.addDays = exports.DEFAULT_TIME_FORMAT = exports.DEFAULT_DATETIME_FORMAT = exports.DEFAULT_DATE_FORMAT = void 0;
|
|
4
|
+
exports.formatDate = formatDate;
|
|
5
|
+
exports.tryParseDate = tryParseDate;
|
|
6
|
+
exports.buildMonthGrid = buildMonthGrid;
|
|
7
|
+
exports.getWeekdayHeaders = getWeekdayHeaders;
|
|
8
|
+
exports.isDateDisabled = isDateDisabled;
|
|
9
|
+
exports.inferTypeFromFormat = inferTypeFromFormat;
|
|
10
|
+
const date_fns_1 = require("date-fns");
|
|
11
|
+
Object.defineProperty(exports, "addDays", { enumerable: true, get: function () { return date_fns_1.addDays; } });
|
|
12
|
+
Object.defineProperty(exports, "addMonths", { enumerable: true, get: function () { return date_fns_1.addMonths; } });
|
|
13
|
+
Object.defineProperty(exports, "addYears", { enumerable: true, get: function () { return date_fns_1.addYears; } });
|
|
14
|
+
Object.defineProperty(exports, "endOfMonth", { enumerable: true, get: function () { return date_fns_1.endOfMonth; } });
|
|
15
|
+
Object.defineProperty(exports, "isAfter", { enumerable: true, get: function () { return date_fns_1.isAfter; } });
|
|
16
|
+
Object.defineProperty(exports, "isBefore", { enumerable: true, get: function () { return date_fns_1.isBefore; } });
|
|
17
|
+
Object.defineProperty(exports, "isSameDay", { enumerable: true, get: function () { return date_fns_1.isSameDay; } });
|
|
18
|
+
Object.defineProperty(exports, "isSameMonth", { enumerable: true, get: function () { return date_fns_1.isSameMonth; } });
|
|
19
|
+
Object.defineProperty(exports, "startOfDay", { enumerable: true, get: function () { return date_fns_1.startOfDay; } });
|
|
20
|
+
Object.defineProperty(exports, "startOfMonth", { enumerable: true, get: function () { return date_fns_1.startOfMonth; } });
|
|
21
|
+
exports.DEFAULT_DATE_FORMAT = "dd/MM/yyyy";
|
|
22
|
+
exports.DEFAULT_DATETIME_FORMAT = "dd/MM/yyyy HH:mm";
|
|
23
|
+
exports.DEFAULT_TIME_FORMAT = "HH:mm";
|
|
24
|
+
function formatDate(date, pattern) {
|
|
25
|
+
if (!date)
|
|
26
|
+
return "";
|
|
27
|
+
try {
|
|
28
|
+
return (0, date_fns_1.format)(date, pattern);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function tryParseDate(text, pattern, referenceDate = new Date()) {
|
|
35
|
+
if (!text)
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
const parsed = (0, date_fns_1.parse)(text, pattern, referenceDate);
|
|
39
|
+
if (Number.isNaN(parsed.getTime()))
|
|
40
|
+
return null;
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
catch (_a) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the 6×7 grid for a given month, filled with leading/trailing days
|
|
49
|
+
* from the adjacent months so the grid is always rectangular.
|
|
50
|
+
*/
|
|
51
|
+
function buildMonthGrid(referenceDate, weekStartsOn) {
|
|
52
|
+
const firstOfMonth = (0, date_fns_1.startOfMonth)(referenceDate);
|
|
53
|
+
const lastOfMonth = (0, date_fns_1.endOfMonth)(referenceDate);
|
|
54
|
+
const gridStart = (0, date_fns_1.startOfWeek)(firstOfMonth, { weekStartsOn });
|
|
55
|
+
const gridEnd = (0, date_fns_1.endOfWeek)(lastOfMonth, { weekStartsOn });
|
|
56
|
+
const today = (0, date_fns_1.startOfDay)(new Date());
|
|
57
|
+
const cells = [];
|
|
58
|
+
let cursor = gridStart;
|
|
59
|
+
while (!(0, date_fns_1.isAfter)(cursor, gridEnd)) {
|
|
60
|
+
cells.push({
|
|
61
|
+
date: cursor,
|
|
62
|
+
inCurrentMonth: (0, date_fns_1.isSameMonth)(cursor, referenceDate),
|
|
63
|
+
isToday: (0, date_fns_1.isSameDay)(cursor, today),
|
|
64
|
+
});
|
|
65
|
+
cursor = (0, date_fns_1.addDays)(cursor, 1);
|
|
66
|
+
}
|
|
67
|
+
while (cells.length < 42) {
|
|
68
|
+
cells.push({
|
|
69
|
+
date: cursor,
|
|
70
|
+
inCurrentMonth: false,
|
|
71
|
+
isToday: (0, date_fns_1.isSameDay)(cursor, today),
|
|
72
|
+
});
|
|
73
|
+
cursor = (0, date_fns_1.addDays)(cursor, 1);
|
|
74
|
+
}
|
|
75
|
+
return cells;
|
|
76
|
+
}
|
|
77
|
+
function getWeekdayHeaders(weekStartsOn, locale = undefined) {
|
|
78
|
+
const SUNDAY = new Date(Date.UTC(1970, 0, 4));
|
|
79
|
+
const labels = [];
|
|
80
|
+
for (let i = 0; i < 7; i++) {
|
|
81
|
+
const day = (0, date_fns_1.addDays)(SUNDAY, (i + weekStartsOn) % 7);
|
|
82
|
+
labels.push(new Intl.DateTimeFormat(locale, { weekday: "short" }).format(day));
|
|
83
|
+
}
|
|
84
|
+
return labels;
|
|
85
|
+
}
|
|
86
|
+
function isDateDisabled(date, constraints) {
|
|
87
|
+
const { minDate, maxDate, disabledDates, disabledDaysOfWeek } = constraints;
|
|
88
|
+
if (minDate && (0, date_fns_1.isBefore)(date, (0, date_fns_1.startOfDay)(minDate)))
|
|
89
|
+
return true;
|
|
90
|
+
if (maxDate && (0, date_fns_1.isAfter)(date, (0, date_fns_1.startOfDay)(maxDate)))
|
|
91
|
+
return true;
|
|
92
|
+
if (disabledDaysOfWeek &&
|
|
93
|
+
disabledDaysOfWeek.includes(date.getDay())) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (disabledDates && disabledDates.some((d) => (0, date_fns_1.isSameDay)(d, date))) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
function inferTypeFromFormat(pattern) {
|
|
102
|
+
const hasTime = /[hHm]/.test(pattern);
|
|
103
|
+
const hasDate = /[yMdD]/.test(pattern);
|
|
104
|
+
if (hasTime && hasDate)
|
|
105
|
+
return "datetime";
|
|
106
|
+
if (hasTime)
|
|
107
|
+
return "time";
|
|
108
|
+
return "date";
|
|
109
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
import { type VariantProps } from "class-variance-authority";
|
|
4
|
+
export declare const Drawer: React.FC<DialogPrimitive.DialogProps>;
|
|
5
|
+
export declare const DrawerTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
export declare const DrawerPortal: React.FC<DialogPrimitive.DialogPortalProps>;
|
|
7
|
+
export declare const DrawerClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
export declare const DrawerOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
declare const contentVariants: (props?: ({
|
|
10
|
+
side?: "top" | "right" | "bottom" | "left" | null | undefined;
|
|
11
|
+
size?: "sm" | "md" | "lg" | "full" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
13
|
+
export interface DrawerContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, VariantProps<typeof contentVariants> {
|
|
14
|
+
hideCloseButton?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const DrawerContent: React.ForwardRefExoticComponent<DrawerContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export declare function DrawerHeader({ className, ...rest }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
18
|
+
export declare namespace DrawerHeader {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function DrawerFooter({ className, ...rest }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
22
|
+
export declare namespace DrawerFooter {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const DrawerTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
26
|
+
export declare const DrawerDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.DrawerDescription = exports.DrawerTitle = exports.DrawerContent = exports.DrawerOverlay = exports.DrawerClose = exports.DrawerPortal = exports.DrawerTrigger = exports.Drawer = void 0;
|
|
48
|
+
exports.DrawerHeader = DrawerHeader;
|
|
49
|
+
exports.DrawerFooter = DrawerFooter;
|
|
50
|
+
const React = __importStar(require("react"));
|
|
51
|
+
const DialogPrimitive = __importStar(require("@radix-ui/react-dialog"));
|
|
52
|
+
const lucide_react_1 = require("lucide-react");
|
|
53
|
+
const class_variance_authority_1 = require("class-variance-authority");
|
|
54
|
+
const utils_1 = require("../../lib/utils");
|
|
55
|
+
exports.Drawer = DialogPrimitive.Root;
|
|
56
|
+
exports.DrawerTrigger = DialogPrimitive.Trigger;
|
|
57
|
+
exports.DrawerPortal = DialogPrimitive.Portal;
|
|
58
|
+
exports.DrawerClose = DialogPrimitive.Close;
|
|
59
|
+
exports.DrawerOverlay = React.forwardRef((_a, ref) => {
|
|
60
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
61
|
+
return (React.createElement(DialogPrimitive.Overlay, Object.assign({ ref: ref, className: (0, utils_1.cn)("fixed inset-0 z-50 bg-foreground/40 backdrop-blur-sm", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className) }, rest)));
|
|
62
|
+
});
|
|
63
|
+
exports.DrawerOverlay.displayName = "DrawerOverlay";
|
|
64
|
+
const contentVariants = (0, class_variance_authority_1.cva)((0, utils_1.cn)("fixed z-50 flex flex-col gap-4 border border-border bg-card text-card-foreground p-6 shadow-lg", "data-[state=open]:animate-in data-[state=closed]:animate-out"), {
|
|
65
|
+
variants: {
|
|
66
|
+
side: {
|
|
67
|
+
left: (0, utils_1.cn)("inset-y-0 left-0 h-full border-l-0 border-y-0", "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left"),
|
|
68
|
+
right: (0, utils_1.cn)("inset-y-0 right-0 h-full border-r-0 border-y-0", "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right"),
|
|
69
|
+
top: (0, utils_1.cn)("inset-x-0 top-0 w-full border-t-0 border-x-0", "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top"),
|
|
70
|
+
bottom: (0, utils_1.cn)("inset-x-0 bottom-0 w-full border-b-0 border-x-0", "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom"),
|
|
71
|
+
},
|
|
72
|
+
size: {
|
|
73
|
+
sm: "",
|
|
74
|
+
md: "",
|
|
75
|
+
lg: "",
|
|
76
|
+
full: "",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
compoundVariants: [
|
|
80
|
+
{ side: "left", size: "sm", className: "w-[20rem] max-w-[90vw]" },
|
|
81
|
+
{ side: "left", size: "md", className: "w-[30rem] max-w-[90vw]" },
|
|
82
|
+
{ side: "left", size: "lg", className: "w-[40rem] max-w-[90vw]" },
|
|
83
|
+
{ side: "left", size: "full", className: "w-screen" },
|
|
84
|
+
{ side: "right", size: "sm", className: "w-[20rem] max-w-[90vw]" },
|
|
85
|
+
{ side: "right", size: "md", className: "w-[30rem] max-w-[90vw]" },
|
|
86
|
+
{ side: "right", size: "lg", className: "w-[40rem] max-w-[90vw]" },
|
|
87
|
+
{ side: "right", size: "full", className: "w-screen" },
|
|
88
|
+
{ side: "top", size: "sm", className: "h-[20vh]" },
|
|
89
|
+
{ side: "top", size: "md", className: "h-[40vh]" },
|
|
90
|
+
{ side: "top", size: "lg", className: "h-[60vh]" },
|
|
91
|
+
{ side: "top", size: "full", className: "h-screen" },
|
|
92
|
+
{ side: "bottom", size: "sm", className: "h-[20vh]" },
|
|
93
|
+
{ side: "bottom", size: "md", className: "h-[40vh]" },
|
|
94
|
+
{ side: "bottom", size: "lg", className: "h-[60vh]" },
|
|
95
|
+
{ side: "bottom", size: "full", className: "h-screen" },
|
|
96
|
+
],
|
|
97
|
+
defaultVariants: {
|
|
98
|
+
side: "right",
|
|
99
|
+
size: "md",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
exports.DrawerContent = React.forwardRef((_a, ref) => {
|
|
103
|
+
var { className, side, size, hideCloseButton, children } = _a, rest = __rest(_a, ["className", "side", "size", "hideCloseButton", "children"]);
|
|
104
|
+
return (React.createElement(exports.DrawerPortal, null,
|
|
105
|
+
React.createElement(exports.DrawerOverlay, null),
|
|
106
|
+
React.createElement(DialogPrimitive.Content, Object.assign({ ref: ref, className: (0, utils_1.cn)(contentVariants({ side, size }), className) }, rest),
|
|
107
|
+
children,
|
|
108
|
+
!hideCloseButton && (React.createElement(DialogPrimitive.Close, { className: (0, utils_1.cn)("absolute right-4 top-4 rounded-sm text-muted-foreground opacity-70 transition-opacity hover:opacity-100", "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1") },
|
|
109
|
+
React.createElement(lucide_react_1.X, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
110
|
+
React.createElement("span", { className: "sr-only" }, "Close"))))));
|
|
111
|
+
});
|
|
112
|
+
exports.DrawerContent.displayName = "DrawerContent";
|
|
113
|
+
function DrawerHeader(_a) {
|
|
114
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
115
|
+
return (React.createElement("div", Object.assign({ className: (0, utils_1.cn)("flex flex-col gap-1.5 text-left", className) }, rest)));
|
|
116
|
+
}
|
|
117
|
+
DrawerHeader.displayName = "DrawerHeader";
|
|
118
|
+
function DrawerFooter(_a) {
|
|
119
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
120
|
+
return (React.createElement("div", Object.assign({ className: (0, utils_1.cn)("mt-auto flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className) }, rest)));
|
|
121
|
+
}
|
|
122
|
+
DrawerFooter.displayName = "DrawerFooter";
|
|
123
|
+
exports.DrawerTitle = React.forwardRef((_a, ref) => {
|
|
124
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
125
|
+
return (React.createElement(DialogPrimitive.Title, Object.assign({ ref: ref, className: (0, utils_1.cn)("text-lg font-semibold leading-none tracking-tight text-foreground", className) }, rest)));
|
|
126
|
+
});
|
|
127
|
+
exports.DrawerTitle.displayName = "DrawerTitle";
|
|
128
|
+
exports.DrawerDescription = React.forwardRef((_a, ref) => {
|
|
129
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
130
|
+
return (React.createElement(DialogPrimitive.Description, Object.assign({ ref: ref, className: (0, utils_1.cn)("text-sm text-muted-foreground", className) }, rest)));
|
|
131
|
+
});
|
|
132
|
+
exports.DrawerDescription.displayName = "DrawerDescription";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface FeedbackFormValues {
|
|
3
|
+
rating: number;
|
|
4
|
+
comment: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FeedbackFormLabels {
|
|
7
|
+
title?: React.ReactNode;
|
|
8
|
+
ratingLabel?: React.ReactNode;
|
|
9
|
+
commentLabel?: React.ReactNode;
|
|
10
|
+
commentPlaceholder?: string;
|
|
11
|
+
submitLabel?: string;
|
|
12
|
+
/** Per-star descriptive labels (length 5). */
|
|
13
|
+
ratingDescriptors?: [string, string, string, string, string];
|
|
14
|
+
}
|
|
15
|
+
export interface FeedbackFormProps {
|
|
16
|
+
onSubmit: (values: FeedbackFormValues) => void | Promise<void>;
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
isCommentRequired?: boolean;
|
|
19
|
+
minRating?: number;
|
|
20
|
+
labels?: FeedbackFormLabels;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function FeedbackForm({ onSubmit, isLoading, isCommentRequired, minRating, labels, className, }: FeedbackFormProps): React.ReactElement;
|
|
24
|
+
export declare namespace FeedbackForm {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FeedbackForm = FeedbackForm;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const lucide_react_1 = require("lucide-react");
|
|
39
|
+
const utils_1 = require("../../lib/utils");
|
|
40
|
+
const button_1 = require("../ui/button");
|
|
41
|
+
const field_1 = require("../ui/field");
|
|
42
|
+
const textarea_1 = require("../ui/textarea");
|
|
43
|
+
const DEFAULT_DESCRIPTORS = [
|
|
44
|
+
"Terrible",
|
|
45
|
+
"Poor",
|
|
46
|
+
"Okay",
|
|
47
|
+
"Good",
|
|
48
|
+
"Great",
|
|
49
|
+
];
|
|
50
|
+
function FeedbackForm({ onSubmit, isLoading = false, isCommentRequired = false, minRating = 1, labels, className, }) {
|
|
51
|
+
var _a, _b, _c, _d, _e;
|
|
52
|
+
const ratingLabel = (_a = labels === null || labels === void 0 ? void 0 : labels.ratingLabel) !== null && _a !== void 0 ? _a : "Your rating";
|
|
53
|
+
const commentLabel = (_b = labels === null || labels === void 0 ? void 0 : labels.commentLabel) !== null && _b !== void 0 ? _b : "Comments";
|
|
54
|
+
const commentPlaceholder = (_c = labels === null || labels === void 0 ? void 0 : labels.commentPlaceholder) !== null && _c !== void 0 ? _c : "Tell us more (optional)";
|
|
55
|
+
const submitLabel = (_d = labels === null || labels === void 0 ? void 0 : labels.submitLabel) !== null && _d !== void 0 ? _d : "Submit feedback";
|
|
56
|
+
const descriptors = (_e = labels === null || labels === void 0 ? void 0 : labels.ratingDescriptors) !== null && _e !== void 0 ? _e : DEFAULT_DESCRIPTORS;
|
|
57
|
+
const [rating, setRating] = React.useState(0);
|
|
58
|
+
const [hover, setHover] = React.useState(null);
|
|
59
|
+
const [comment, setComment] = React.useState("");
|
|
60
|
+
const [ratingError, setRatingError] = React.useState(null);
|
|
61
|
+
const [commentError, setCommentError] = React.useState(null);
|
|
62
|
+
const handleSubmit = async (event) => {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
let hasError = false;
|
|
65
|
+
if (rating < minRating) {
|
|
66
|
+
setRatingError(minRating === 1
|
|
67
|
+
? "Please pick a rating."
|
|
68
|
+
: `Please give at least ${minRating} stars.`);
|
|
69
|
+
hasError = true;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
setRatingError(null);
|
|
73
|
+
}
|
|
74
|
+
if (isCommentRequired && !comment.trim()) {
|
|
75
|
+
setCommentError("Please leave a comment.");
|
|
76
|
+
hasError = true;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
setCommentError(null);
|
|
80
|
+
}
|
|
81
|
+
if (hasError)
|
|
82
|
+
return;
|
|
83
|
+
await onSubmit({ rating, comment });
|
|
84
|
+
};
|
|
85
|
+
const displayRating = hover !== null && hover !== void 0 ? hover : rating;
|
|
86
|
+
const descriptor = displayRating > 0 ? descriptors[displayRating - 1] : null;
|
|
87
|
+
return (React.createElement("form", { onSubmit: handleSubmit, noValidate: true, className: (0, utils_1.cn)("space-y-4", className) },
|
|
88
|
+
(labels === null || labels === void 0 ? void 0 : labels.title) && (React.createElement("h2", { className: "text-base font-semibold text-foreground" }, labels.title)),
|
|
89
|
+
React.createElement(field_1.Field, { label: ratingLabel, isRequired: true, error: !!ratingError, errorMessage: ratingError !== null && ratingError !== void 0 ? ratingError : undefined },
|
|
90
|
+
React.createElement("div", { role: "radiogroup", "aria-label": typeof ratingLabel === "string" ? ratingLabel : "Rating", className: "flex items-center gap-1", onMouseLeave: () => setHover(null) },
|
|
91
|
+
Array.from({ length: 5 }).map((_, index) => {
|
|
92
|
+
const value = index + 1;
|
|
93
|
+
const active = displayRating >= value;
|
|
94
|
+
return (React.createElement("button", { key: value, type: "button", role: "radio", "aria-checked": rating === value, "aria-label": `${value} star${value === 1 ? "" : "s"} (${descriptors[index]})`, onMouseEnter: () => setHover(value), onFocus: () => setHover(value), onBlur: () => setHover(null), onClick: () => {
|
|
95
|
+
setRating(value);
|
|
96
|
+
setRatingError(null);
|
|
97
|
+
}, className: "rounded-md p-1 transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" },
|
|
98
|
+
React.createElement(lucide_react_1.Star, { "aria-hidden": "true", className: (0, utils_1.cn)("h-6 w-6 transition-colors", active
|
|
99
|
+
? "fill-warning text-warning"
|
|
100
|
+
: "text-muted-foreground") })));
|
|
101
|
+
}),
|
|
102
|
+
descriptor && (React.createElement("span", { className: "ml-2 text-sm text-muted-foreground" }, descriptor)))),
|
|
103
|
+
React.createElement(field_1.Field, { label: commentLabel, isRequired: isCommentRequired, error: !!commentError, errorMessage: commentError !== null && commentError !== void 0 ? commentError : undefined },
|
|
104
|
+
React.createElement(textarea_1.Textarea, { value: comment, onChange: (event) => {
|
|
105
|
+
setComment(event.target.value);
|
|
106
|
+
if (commentError)
|
|
107
|
+
setCommentError(null);
|
|
108
|
+
}, placeholder: commentPlaceholder, autoResize: true, minRows: 3, maxRows: 8 })),
|
|
109
|
+
React.createElement("div", { className: "flex justify-end" },
|
|
110
|
+
React.createElement(button_1.Button, { type: "submit", isLoading: isLoading, loadingText: "Sending\u2026" }, submitLabel))));
|
|
111
|
+
}
|
|
112
|
+
FeedbackForm.displayName = "FeedbackForm";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Accept } from "react-dropzone";
|
|
3
|
+
export interface FileUploaderFile {
|
|
4
|
+
file: File;
|
|
5
|
+
id: string;
|
|
6
|
+
/** Percent (0–100). When undefined the per-file bar is hidden. */
|
|
7
|
+
progress?: number;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FileUploaderProps {
|
|
11
|
+
accept?: Accept;
|
|
12
|
+
multiple?: boolean;
|
|
13
|
+
maxFiles?: number;
|
|
14
|
+
/** Bytes. */
|
|
15
|
+
maxSize?: number;
|
|
16
|
+
isDisabled?: boolean;
|
|
17
|
+
/** Controlled file list (mirrors what `useFileUploader` returns). */
|
|
18
|
+
files?: FileUploaderFile[];
|
|
19
|
+
onFilesChange?: (files: FileUploaderFile[]) => void;
|
|
20
|
+
/** Pre-filled label shown above the dropzone. */
|
|
21
|
+
label?: React.ReactNode;
|
|
22
|
+
/** Pre-filled hint shown below the icon. */
|
|
23
|
+
hint?: React.ReactNode;
|
|
24
|
+
/** Forces error styling and shows this message under the zone. */
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const FileUploader: React.ForwardRefExoticComponent<FileUploaderProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FileUploader = void 0;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const react_dropzone_1 = require("react-dropzone");
|
|
39
|
+
const lucide_react_1 = require("lucide-react");
|
|
40
|
+
const utils_1 = require("../../lib/utils");
|
|
41
|
+
const button_1 = require("../ui/button");
|
|
42
|
+
const progress_1 = require("../ui/progress");
|
|
43
|
+
function formatBytes(bytes) {
|
|
44
|
+
if (bytes < 1024)
|
|
45
|
+
return `${bytes} B`;
|
|
46
|
+
if (bytes < 1024 * 1024)
|
|
47
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
48
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
49
|
+
}
|
|
50
|
+
function makeId(file) {
|
|
51
|
+
return `${file.name}-${file.size}-${file.lastModified}`;
|
|
52
|
+
}
|
|
53
|
+
exports.FileUploader = React.forwardRef((props, ref) => {
|
|
54
|
+
const { accept, multiple = true, maxFiles, maxSize, isDisabled = false, files: controlledFiles, onFilesChange, label, hint, errorMessage, className, } = props;
|
|
55
|
+
const isControlled = controlledFiles !== undefined;
|
|
56
|
+
const [internalFiles, setInternalFiles] = React.useState([]);
|
|
57
|
+
const files = isControlled ? controlledFiles : internalFiles;
|
|
58
|
+
const setFiles = (next) => {
|
|
59
|
+
if (!isControlled)
|
|
60
|
+
setInternalFiles(next);
|
|
61
|
+
onFilesChange === null || onFilesChange === void 0 ? void 0 : onFilesChange(next);
|
|
62
|
+
};
|
|
63
|
+
const removeFile = (id) => {
|
|
64
|
+
setFiles(files.filter((entry) => entry.id !== id));
|
|
65
|
+
};
|
|
66
|
+
const { getRootProps, getInputProps, isDragActive, isDragReject, fileRejections, } = (0, react_dropzone_1.useDropzone)({
|
|
67
|
+
accept,
|
|
68
|
+
multiple,
|
|
69
|
+
maxFiles,
|
|
70
|
+
maxSize,
|
|
71
|
+
disabled: isDisabled,
|
|
72
|
+
onDrop: (accepted) => {
|
|
73
|
+
const additions = accepted.map((file) => ({
|
|
74
|
+
id: makeId(file),
|
|
75
|
+
file,
|
|
76
|
+
}));
|
|
77
|
+
const merged = multiple
|
|
78
|
+
? [
|
|
79
|
+
...files,
|
|
80
|
+
...additions.filter((entry) => !files.some((existing) => existing.id === entry.id)),
|
|
81
|
+
]
|
|
82
|
+
: additions.slice(0, 1);
|
|
83
|
+
if (maxFiles) {
|
|
84
|
+
setFiles(merged.slice(0, maxFiles));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
setFiles(merged);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
const hasRejections = fileRejections.length > 0;
|
|
92
|
+
const showError = !!errorMessage || hasRejections;
|
|
93
|
+
return (React.createElement("div", { ref: ref, className: (0, utils_1.cn)("space-y-3", className) },
|
|
94
|
+
label && (React.createElement("div", { className: "text-sm font-medium text-foreground" }, label)),
|
|
95
|
+
React.createElement("div", Object.assign({}, getRootProps({
|
|
96
|
+
className: (0, utils_1.cn)("flex cursor-pointer flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-border bg-muted/30 px-4 py-8 text-center transition-colors", "hover:border-primary/60 hover:bg-accent/40", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", isDragActive && "border-primary bg-primary/10", (isDragReject || showError) &&
|
|
97
|
+
"border-destructive bg-destructive/5", isDisabled && "cursor-not-allowed opacity-50"),
|
|
98
|
+
}), { role: "button", tabIndex: isDisabled ? -1 : 0, "aria-label": "Drop files or click to browse", "aria-disabled": isDisabled || undefined }),
|
|
99
|
+
React.createElement("input", Object.assign({}, getInputProps())),
|
|
100
|
+
React.createElement(lucide_react_1.UploadCloud, { "aria-hidden": "true", className: (0, utils_1.cn)("h-8 w-8 text-muted-foreground", isDragActive && "text-primary") }),
|
|
101
|
+
React.createElement("div", { className: "text-sm text-foreground" },
|
|
102
|
+
React.createElement("span", { className: "font-medium text-primary" }, "Click to upload"),
|
|
103
|
+
" ",
|
|
104
|
+
"or drag and drop"),
|
|
105
|
+
React.createElement("p", { className: "text-xs text-muted-foreground" }, hint !== null && hint !== void 0 ? hint : (maxSize
|
|
106
|
+
? `Up to ${formatBytes(maxSize)}${maxFiles ? `, max ${maxFiles} files` : ""}`
|
|
107
|
+
: "Any file type"))),
|
|
108
|
+
showError && (React.createElement("div", { className: "flex items-start gap-1.5 text-xs text-destructive" },
|
|
109
|
+
React.createElement(lucide_react_1.AlertCircle, { "aria-hidden": "true", className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
110
|
+
React.createElement("div", null,
|
|
111
|
+
errorMessage,
|
|
112
|
+
fileRejections.map(({ file, errors }) => (React.createElement("div", { key: file.name },
|
|
113
|
+
file.name,
|
|
114
|
+
": ",
|
|
115
|
+
errors.map((e) => e.message).join(", "))))))),
|
|
116
|
+
files.length > 0 && (React.createElement("ul", { role: "list", className: "space-y-2" }, files.map((entry) => (React.createElement("li", { key: entry.id, className: "flex items-center gap-3 rounded-md border border-border bg-card px-3 py-2 text-sm" },
|
|
117
|
+
React.createElement(lucide_react_1.File, { "aria-hidden": "true", className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
118
|
+
React.createElement("div", { className: "min-w-0 flex-1" },
|
|
119
|
+
React.createElement("p", { className: "truncate font-medium text-foreground" }, entry.file.name),
|
|
120
|
+
React.createElement("p", { className: "text-xs text-muted-foreground" },
|
|
121
|
+
formatBytes(entry.file.size),
|
|
122
|
+
entry.error && (React.createElement("span", { className: "ml-2 text-destructive" }, entry.error))),
|
|
123
|
+
typeof entry.progress === "number" && (React.createElement(progress_1.Progress, { size: "sm", value: entry.progress, className: "mt-1" }))),
|
|
124
|
+
React.createElement(button_1.Button, { variant: "ghost", size: "sm", "aria-label": `Remove ${entry.file.name}`, onClick: () => removeFile(entry.id), className: "h-7 w-7 p-0" },
|
|
125
|
+
React.createElement(lucide_react_1.X, { "aria-hidden": "true" })))))))));
|
|
126
|
+
});
|
|
127
|
+
exports.FileUploader.displayName = "FileUploader";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type InputProps } from "../ui/input";
|
|
3
|
+
export type TextInputType = "text" | "email" | "password" | "number" | "tel" | "url" | "search";
|
|
4
|
+
export type TextInputSize = "sm" | "md" | "lg";
|
|
5
|
+
export type TextInputVariant = "default" | "floating";
|
|
6
|
+
export interface TextInputProps {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
15
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
16
|
+
type?: TextInputType;
|
|
17
|
+
isDisabled?: boolean;
|
|
18
|
+
isReadOnly?: boolean;
|
|
19
|
+
isRequired?: boolean;
|
|
20
|
+
error?: boolean;
|
|
21
|
+
errorMessage?: React.ReactNode;
|
|
22
|
+
helperText?: React.ReactNode;
|
|
23
|
+
leftIcon?: React.ReactNode;
|
|
24
|
+
rightIcon?: React.ReactNode;
|
|
25
|
+
onLeftIconClick?: () => void;
|
|
26
|
+
onRightIconClick?: () => void;
|
|
27
|
+
isInformation?: boolean;
|
|
28
|
+
informationMessage?: React.ReactNode;
|
|
29
|
+
size?: TextInputSize;
|
|
30
|
+
width?: string;
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
showCount?: boolean;
|
|
33
|
+
variant?: TextInputVariant;
|
|
34
|
+
autoComplete?: string;
|
|
35
|
+
autoFocus?: boolean;
|
|
36
|
+
className?: string;
|
|
37
|
+
/** Hide the visual label but keep it for screen readers. */
|
|
38
|
+
hideLabel?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
41
|
+
export type { InputProps };
|