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,148 @@
|
|
|
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.NavigationBar = NavigationBar;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const lucide_react_1 = require("lucide-react");
|
|
39
|
+
const utils_1 = require("../../lib/utils");
|
|
40
|
+
const ThemeProvider_1 = require("../../theme-v2/ThemeProvider");
|
|
41
|
+
const avatar_1 = require("../ui/avatar");
|
|
42
|
+
const button_1 = require("../ui/button");
|
|
43
|
+
const dialog_1 = require("../ui/dialog");
|
|
44
|
+
const dropdown_menu_1 = require("../ui/dropdown-menu");
|
|
45
|
+
const input_1 = require("../ui/input");
|
|
46
|
+
const Breadcrumbs_1 = require("../Breadcrumbs/Breadcrumbs");
|
|
47
|
+
function NavigationBar({ logo, appName, onSidebarToggle, sidebarOpen, breadcrumb, pageTitle, backAction, actions, user, userMenuItems = [], onLogout, logoutLabel = "Sign out", notificationCount, notificationIcon, onNotificationClick, globalSearch, showThemeSwitcher = false, className, }) {
|
|
48
|
+
var _a, _b, _c;
|
|
49
|
+
const [searchOpen, setSearchOpen] = React.useState(false);
|
|
50
|
+
const [searchQuery, setSearchQuery] = React.useState("");
|
|
51
|
+
const submitSearch = (event) => {
|
|
52
|
+
var _a;
|
|
53
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
54
|
+
(_a = globalSearch === null || globalSearch === void 0 ? void 0 : globalSearch.onSearch) === null || _a === void 0 ? void 0 : _a.call(globalSearch, searchQuery);
|
|
55
|
+
};
|
|
56
|
+
const NotificationIcon = notificationIcon !== null && notificationIcon !== void 0 ? notificationIcon : lucide_react_1.Bell;
|
|
57
|
+
const showNotification = onNotificationClick !== undefined ||
|
|
58
|
+
typeof notificationCount === "number";
|
|
59
|
+
return (React.createElement("header", { role: "banner", className: (0, utils_1.cn)("sticky top-0 z-40 flex h-14 shrink-0 items-center gap-2 border-b border-border bg-background px-3", className) },
|
|
60
|
+
onSidebarToggle && (React.createElement("button", { type: "button", "aria-label": sidebarOpen ? "Close sidebar" : "Open sidebar", "aria-expanded": sidebarOpen, onClick: onSidebarToggle, className: "inline-flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring md:hidden" },
|
|
61
|
+
React.createElement(lucide_react_1.Menu, { "aria-hidden": "true", className: "h-5 w-5" }))),
|
|
62
|
+
(logo || appName) && (React.createElement("div", { className: "flex items-center gap-2 md:hidden" },
|
|
63
|
+
logo ? (React.createElement("img", { src: logo, alt: "", className: "h-6 w-6 rounded-sm object-contain" })) : null,
|
|
64
|
+
appName && (React.createElement("span", { className: "text-sm font-semibold text-foreground" }, appName)))),
|
|
65
|
+
backAction && (React.createElement("button", { type: "button", onClick: backAction.onClick, "aria-label": (_a = backAction.label) !== null && _a !== void 0 ? _a : "Go back", className: "inline-flex items-center gap-1 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" },
|
|
66
|
+
React.createElement(lucide_react_1.ChevronLeft, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
67
|
+
backAction.label && (React.createElement("span", { className: "hidden sm:inline" }, backAction.label)))),
|
|
68
|
+
React.createElement("div", { className: "min-w-0 flex-1" }, breadcrumb && breadcrumb.length > 0 ? (React.createElement(Breadcrumbs_1.Breadcrumbs, { items: breadcrumb, maxItems: 4 })) : pageTitle ? (React.createElement("h1", { className: "truncate text-sm font-semibold text-foreground" }, pageTitle)) : null),
|
|
69
|
+
React.createElement("nav", { "aria-label": "Global", className: "flex items-center gap-1" },
|
|
70
|
+
globalSearch && (React.createElement("button", { type: "button", onClick: () => setSearchOpen(true), "aria-label": "Open search", className: "hidden h-9 items-center gap-2 rounded-md border border-input bg-background px-2.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:inline-flex" },
|
|
71
|
+
React.createElement(lucide_react_1.Search, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
72
|
+
React.createElement("span", { className: "hidden md:inline" }, (_b = globalSearch.placeholder) !== null && _b !== void 0 ? _b : "Search…"),
|
|
73
|
+
globalSearch.shortcut && (React.createElement("kbd", { className: "ml-1 rounded border border-border bg-muted px-1 text-[10px] font-medium text-muted-foreground" }, globalSearch.shortcut)))),
|
|
74
|
+
globalSearch && (React.createElement("button", { type: "button", onClick: () => setSearchOpen(true), "aria-label": "Open search", className: "inline-flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:hidden" },
|
|
75
|
+
React.createElement(lucide_react_1.Search, { "aria-hidden": "true", className: "h-5 w-5" }))),
|
|
76
|
+
actions,
|
|
77
|
+
showThemeSwitcher && React.createElement(ThemeSwitcher, null),
|
|
78
|
+
showNotification && (React.createElement("button", { type: "button", onClick: onNotificationClick, "aria-label": typeof notificationCount === "number" && notificationCount > 0
|
|
79
|
+
? `Notifications (${notificationCount} unread)`
|
|
80
|
+
: "Notifications", className: "relative inline-flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" },
|
|
81
|
+
React.createElement(NotificationIcon, { "aria-hidden": "true", className: "h-5 w-5" }),
|
|
82
|
+
typeof notificationCount === "number" && notificationCount > 0 && (React.createElement("span", { "aria-hidden": "true", className: "absolute right-1 top-1 inline-flex min-w-[16px] items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-semibold leading-none text-destructive-foreground" }, notificationCount > 99 ? "99+" : notificationCount)))),
|
|
83
|
+
user && (React.createElement(UserMenu, { user: user, items: userMenuItems, onLogout: onLogout, logoutLabel: logoutLabel }))),
|
|
84
|
+
globalSearch && (React.createElement(dialog_1.Dialog, { open: searchOpen, onOpenChange: setSearchOpen },
|
|
85
|
+
React.createElement(dialog_1.DialogContent, { size: "lg", className: "top-[25%] gap-3" },
|
|
86
|
+
React.createElement(dialog_1.DialogHeader, null,
|
|
87
|
+
React.createElement(dialog_1.DialogTitle, null, "Search")),
|
|
88
|
+
React.createElement("form", { onSubmit: submitSearch, className: "flex gap-2" },
|
|
89
|
+
React.createElement(input_1.Input, { autoFocus: true, value: searchQuery, onChange: (event) => setSearchQuery(event.target.value), placeholder: (_c = globalSearch.placeholder) !== null && _c !== void 0 ? _c : "Search…", size: "lg" }),
|
|
90
|
+
React.createElement(button_1.Button, { type: "submit", size: "lg" }, "Go")))))));
|
|
91
|
+
}
|
|
92
|
+
function UserMenu({ user, items, onLogout, logoutLabel, }) {
|
|
93
|
+
var _a;
|
|
94
|
+
const initials = (_a = user.initials) !== null && _a !== void 0 ? _a : user.name
|
|
95
|
+
.split(/\s+/)
|
|
96
|
+
.map((part) => part[0])
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.slice(0, 2)
|
|
99
|
+
.join("")
|
|
100
|
+
.toUpperCase();
|
|
101
|
+
return (React.createElement(dropdown_menu_1.DropdownMenu, null,
|
|
102
|
+
React.createElement(dropdown_menu_1.DropdownMenuTrigger, { asChild: true },
|
|
103
|
+
React.createElement("button", { type: "button", "aria-label": `Account menu for ${user.name}`, className: "ml-1 rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" },
|
|
104
|
+
React.createElement(avatar_1.Avatar, { size: "sm" },
|
|
105
|
+
user.avatarUrl && (React.createElement(avatar_1.AvatarImage, { src: user.avatarUrl, alt: user.name })),
|
|
106
|
+
React.createElement(avatar_1.AvatarFallback, null, initials || "?")))),
|
|
107
|
+
React.createElement(dropdown_menu_1.DropdownMenuContent, { align: "end", className: "w-56" },
|
|
108
|
+
React.createElement("div", { className: "px-2 py-1.5" },
|
|
109
|
+
React.createElement("p", { className: "truncate text-sm font-medium text-foreground" }, user.name),
|
|
110
|
+
user.email && (React.createElement("p", { className: "truncate text-xs text-muted-foreground" }, user.email))),
|
|
111
|
+
items.length > 0 && React.createElement(dropdown_menu_1.DropdownMenuSeparator, null),
|
|
112
|
+
items.map((item, index) => (React.createElement(React.Fragment, { key: `${item.label}-${index}` },
|
|
113
|
+
item.separator && React.createElement(dropdown_menu_1.DropdownMenuSeparator, null),
|
|
114
|
+
item.href ? (React.createElement(dropdown_menu_1.DropdownMenuItem, { asChild: true },
|
|
115
|
+
React.createElement("a", { href: item.href, className: (0, utils_1.cn)(item.variant === "destructive" &&
|
|
116
|
+
"text-destructive focus:text-destructive") },
|
|
117
|
+
item.icon,
|
|
118
|
+
item.label))) : (React.createElement(dropdown_menu_1.DropdownMenuItem, { onClick: item.onClick, className: (0, utils_1.cn)(item.variant === "destructive" &&
|
|
119
|
+
"text-destructive focus:text-destructive") },
|
|
120
|
+
item.icon,
|
|
121
|
+
item.label))))),
|
|
122
|
+
onLogout && (React.createElement(React.Fragment, null,
|
|
123
|
+
React.createElement(dropdown_menu_1.DropdownMenuSeparator, null),
|
|
124
|
+
React.createElement(dropdown_menu_1.DropdownMenuItem, { onClick: onLogout, className: "text-destructive focus:text-destructive" },
|
|
125
|
+
React.createElement(lucide_react_1.LogOut, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
126
|
+
logoutLabel))))));
|
|
127
|
+
}
|
|
128
|
+
function ThemeSwitcher() {
|
|
129
|
+
const { mode, setMode } = (0, ThemeProvider_1.useTheme)();
|
|
130
|
+
const Icon = mode === "dark" ? lucide_react_1.Moon : mode === "light" ? lucide_react_1.Sun : lucide_react_1.Monitor;
|
|
131
|
+
return (React.createElement(dropdown_menu_1.DropdownMenu, null,
|
|
132
|
+
React.createElement(dropdown_menu_1.DropdownMenuTrigger, { asChild: true },
|
|
133
|
+
React.createElement("button", { type: "button", "aria-label": "Change theme", className: "inline-flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" },
|
|
134
|
+
React.createElement(Icon, { "aria-hidden": "true", className: "h-5 w-5" }))),
|
|
135
|
+
React.createElement(dropdown_menu_1.DropdownMenuContent, { align: "end", className: "w-40" },
|
|
136
|
+
React.createElement(dropdown_menu_1.DropdownMenuLabel, null, "Theme"),
|
|
137
|
+
React.createElement(dropdown_menu_1.DropdownMenuSeparator, null),
|
|
138
|
+
React.createElement(dropdown_menu_1.DropdownMenuRadioGroup, { value: mode, onValueChange: (value) => setMode(value) },
|
|
139
|
+
React.createElement(dropdown_menu_1.DropdownMenuRadioItem, { value: "light" },
|
|
140
|
+
React.createElement(lucide_react_1.Sun, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
141
|
+
"Light"),
|
|
142
|
+
React.createElement(dropdown_menu_1.DropdownMenuRadioItem, { value: "dark" },
|
|
143
|
+
React.createElement(lucide_react_1.Moon, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
144
|
+
"Dark"),
|
|
145
|
+
React.createElement(dropdown_menu_1.DropdownMenuRadioItem, { value: "system" },
|
|
146
|
+
React.createElement(lucide_react_1.Monitor, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
147
|
+
"System")))));
|
|
148
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type NotificationType = "info" | "success" | "warning" | "error";
|
|
3
|
+
export interface NotificationProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
/** Absolute timestamp, ISO string, or pre-formatted string. */
|
|
7
|
+
timestamp?: Date | string;
|
|
8
|
+
/** When false, the item is rendered with the "unread" indicator. */
|
|
9
|
+
read?: boolean;
|
|
10
|
+
onRead?: () => void;
|
|
11
|
+
onDismiss?: () => void;
|
|
12
|
+
type?: NotificationType;
|
|
13
|
+
/** Inline avatar (URL or initials). */
|
|
14
|
+
avatar?: {
|
|
15
|
+
src?: string;
|
|
16
|
+
initials?: string;
|
|
17
|
+
alt?: string;
|
|
18
|
+
};
|
|
19
|
+
/** Action row below the description. */
|
|
20
|
+
actions?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare const Notification: React.ForwardRefExoticComponent<NotificationProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,113 @@
|
|
|
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.Notification = void 0;
|
|
48
|
+
const React = __importStar(require("react"));
|
|
49
|
+
const lucide_react_1 = require("lucide-react");
|
|
50
|
+
const utils_1 = require("../../lib/utils");
|
|
51
|
+
const avatar_1 = require("../ui/avatar");
|
|
52
|
+
const TYPE_STYLES = {
|
|
53
|
+
info: {
|
|
54
|
+
border: "border-l-primary",
|
|
55
|
+
bg: "bg-primary/5",
|
|
56
|
+
icon: React.createElement(lucide_react_1.Info, { "aria-hidden": "true", className: "h-4 w-4 text-primary" }),
|
|
57
|
+
},
|
|
58
|
+
success: {
|
|
59
|
+
border: "border-l-success",
|
|
60
|
+
bg: "bg-success/5",
|
|
61
|
+
icon: React.createElement(lucide_react_1.CheckCircle2, { "aria-hidden": "true", className: "h-4 w-4 text-success" }),
|
|
62
|
+
},
|
|
63
|
+
warning: {
|
|
64
|
+
border: "border-l-warning",
|
|
65
|
+
bg: "bg-warning/5",
|
|
66
|
+
icon: React.createElement(lucide_react_1.AlertTriangle, { "aria-hidden": "true", className: "h-4 w-4 text-warning" }),
|
|
67
|
+
},
|
|
68
|
+
error: {
|
|
69
|
+
border: "border-l-destructive",
|
|
70
|
+
bg: "bg-destructive/5",
|
|
71
|
+
icon: React.createElement(lucide_react_1.AlertCircle, { "aria-hidden": "true", className: "h-4 w-4 text-destructive" }),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
function formatTimestamp(value) {
|
|
75
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
76
|
+
if (Number.isNaN(date.getTime()))
|
|
77
|
+
return String(value);
|
|
78
|
+
return date.toLocaleString(undefined, {
|
|
79
|
+
month: "short",
|
|
80
|
+
day: "numeric",
|
|
81
|
+
hour: "numeric",
|
|
82
|
+
minute: "2-digit",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exports.Notification = React.forwardRef((_a, ref) => {
|
|
86
|
+
var _b, _c;
|
|
87
|
+
var { className, title, description, timestamp, read = false, onRead, onDismiss, type = "info", avatar, actions, onClick } = _a, rest = __rest(_a, ["className", "title", "description", "timestamp", "read", "onRead", "onDismiss", "type", "avatar", "actions", "onClick"]);
|
|
88
|
+
const styles = TYPE_STYLES[type];
|
|
89
|
+
const handleClick = (event) => {
|
|
90
|
+
if (!read)
|
|
91
|
+
onRead === null || onRead === void 0 ? void 0 : onRead();
|
|
92
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
93
|
+
};
|
|
94
|
+
return (React.createElement("div", Object.assign({ ref: ref, role: "article", "aria-live": !read ? "polite" : undefined, onClick: handleClick, className: (0, utils_1.cn)("relative flex gap-3 border-l-2 p-3 transition-colors", "hover:bg-accent/40", read ? "border-l-transparent" : (0, utils_1.cn)(styles.border, styles.bg), onClick && "cursor-pointer", className) }, rest),
|
|
95
|
+
avatar ? (React.createElement(avatar_1.Avatar, { size: "sm" },
|
|
96
|
+
avatar.src && (React.createElement(avatar_1.AvatarImage, { src: avatar.src, alt: (_b = avatar.alt) !== null && _b !== void 0 ? _b : "" })),
|
|
97
|
+
React.createElement(avatar_1.AvatarFallback, null, (_c = avatar.initials) !== null && _c !== void 0 ? _c : "?"))) : (React.createElement("span", { className: "mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-card" }, styles.icon)),
|
|
98
|
+
React.createElement("div", { className: "min-w-0 flex-1" },
|
|
99
|
+
React.createElement("div", { className: "flex items-start justify-between gap-2" },
|
|
100
|
+
React.createElement("p", { className: (0, utils_1.cn)("text-sm", read
|
|
101
|
+
? "font-medium text-muted-foreground"
|
|
102
|
+
: "font-semibold text-foreground") }, title),
|
|
103
|
+
timestamp && (React.createElement("time", { className: "shrink-0 text-[11px] text-muted-foreground" }, formatTimestamp(timestamp)))),
|
|
104
|
+
description && (React.createElement("p", { className: "mt-0.5 text-sm text-muted-foreground" }, description)),
|
|
105
|
+
actions && React.createElement("div", { className: "mt-2 flex gap-2" }, actions)),
|
|
106
|
+
!read && (React.createElement("span", { "aria-label": "Unread", className: "absolute right-3 top-3 h-2 w-2 rounded-full bg-primary" })),
|
|
107
|
+
onDismiss && (React.createElement("button", { type: "button", "aria-label": "Dismiss notification", onClick: (event) => {
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
onDismiss();
|
|
110
|
+
}, className: "absolute bottom-2 right-2 rounded-sm text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100" },
|
|
111
|
+
React.createElement(lucide_react_1.X, { "aria-hidden": "true", className: "h-3.5 w-3.5" })))));
|
|
112
|
+
});
|
|
113
|
+
exports.Notification.displayName = "Notification";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type NumberInputSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface NumberInputProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
value?: number | null;
|
|
9
|
+
defaultValue?: number | null;
|
|
10
|
+
onChange?: (value: number | null) => void;
|
|
11
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
12
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
/** Decimal places — applied on clamp/blur. */
|
|
17
|
+
precision?: number;
|
|
18
|
+
/** Custom display formatter (e.g. currency). Called when input isn't focused. */
|
|
19
|
+
format?: (value: number) => string;
|
|
20
|
+
/** Inverse of format. Receives the raw input string. Return NaN to reject. */
|
|
21
|
+
parse?: (raw: string) => number;
|
|
22
|
+
helperText?: React.ReactNode;
|
|
23
|
+
error?: boolean;
|
|
24
|
+
errorMessage?: React.ReactNode;
|
|
25
|
+
isInformation?: boolean;
|
|
26
|
+
informationMessage?: React.ReactNode;
|
|
27
|
+
isDisabled?: boolean;
|
|
28
|
+
isReadOnly?: boolean;
|
|
29
|
+
isRequired?: boolean;
|
|
30
|
+
size?: NumberInputSize;
|
|
31
|
+
width?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
/** Hide the +/- stepper buttons. */
|
|
35
|
+
hideSteppers?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,210 @@
|
|
|
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.NumberInput = void 0;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const lucide_react_1 = require("lucide-react");
|
|
39
|
+
const utils_1 = require("../../lib/utils");
|
|
40
|
+
const field_1 = require("../ui/field");
|
|
41
|
+
const input_1 = require("../ui/input");
|
|
42
|
+
const form_field_1 = require("../ui/form-field");
|
|
43
|
+
const STEPPER_SIZE = {
|
|
44
|
+
sm: "w-5",
|
|
45
|
+
md: "w-6",
|
|
46
|
+
lg: "w-7",
|
|
47
|
+
};
|
|
48
|
+
const STEPPER_ICON = {
|
|
49
|
+
sm: "h-2.5 w-2.5",
|
|
50
|
+
md: "h-3 w-3",
|
|
51
|
+
lg: "h-3.5 w-3.5",
|
|
52
|
+
};
|
|
53
|
+
function clamp(value, min, max) {
|
|
54
|
+
if (typeof min === "number" && value < min)
|
|
55
|
+
return min;
|
|
56
|
+
if (typeof max === "number" && value > max)
|
|
57
|
+
return max;
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
function roundTo(value, precision) {
|
|
61
|
+
const factor = 10 ** precision;
|
|
62
|
+
return Math.round(value * factor) / factor;
|
|
63
|
+
}
|
|
64
|
+
function defaultParse(raw) {
|
|
65
|
+
if (raw.trim() === "")
|
|
66
|
+
return NaN;
|
|
67
|
+
const cleaned = raw.replace(/[^\d.\-+eE]/g, "");
|
|
68
|
+
return parseFloat(cleaned);
|
|
69
|
+
}
|
|
70
|
+
function defaultFormat(value, precision) {
|
|
71
|
+
if (Number.isNaN(value))
|
|
72
|
+
return "";
|
|
73
|
+
if (typeof precision === "number")
|
|
74
|
+
return value.toFixed(precision);
|
|
75
|
+
return String(value);
|
|
76
|
+
}
|
|
77
|
+
exports.NumberInput = React.forwardRef((props, ref) => {
|
|
78
|
+
const { id, label, placeholder, value, defaultValue, onChange, onBlur, onFocus, min, max, step = 1, precision, format, parse = defaultParse, helperText, error = false, errorMessage, isInformation, informationMessage, isDisabled, isReadOnly, isRequired, size = "md", width, className, autoFocus, hideSteppers = false, name, } = props;
|
|
79
|
+
return (React.createElement(field_1.Field, { id: id, label: label, isRequired: isRequired, isInformation: isInformation, informationMessage: informationMessage, helperText: helperText, error: error, errorMessage: errorMessage, width: width },
|
|
80
|
+
React.createElement(NumberInputControl, { ref: ref, name: name, placeholder: placeholder, value: value, defaultValue: defaultValue, onChange: onChange, onBlur: onBlur, onFocus: onFocus, min: min, max: max, step: step, precision: precision, format: format, parse: parse, isDisabled: isDisabled, isReadOnly: isReadOnly, error: error, size: size, className: className, autoFocus: autoFocus, hideSteppers: hideSteppers })));
|
|
81
|
+
});
|
|
82
|
+
exports.NumberInput.displayName = "NumberInput";
|
|
83
|
+
const NumberInputControl = React.forwardRef(({ placeholder, value, defaultValue, onChange, onBlur, onFocus, min, max, step = 1, precision, format, parse = defaultParse, isDisabled, isReadOnly, error = false, size = "md", className, autoFocus, hideSteppers = false, name, }, ref) => {
|
|
84
|
+
const field = (0, form_field_1.useFormField)();
|
|
85
|
+
const [draft, setDraft] = React.useState(() => {
|
|
86
|
+
const initial = typeof value === "number"
|
|
87
|
+
? value
|
|
88
|
+
: typeof defaultValue === "number"
|
|
89
|
+
? defaultValue
|
|
90
|
+
: null;
|
|
91
|
+
return initial === null ? "" : (format
|
|
92
|
+
? format(initial)
|
|
93
|
+
: defaultFormat(initial, precision));
|
|
94
|
+
});
|
|
95
|
+
const [focused, setFocused] = React.useState(false);
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
if (focused)
|
|
98
|
+
return;
|
|
99
|
+
if (value === undefined)
|
|
100
|
+
return;
|
|
101
|
+
setDraft(value === null
|
|
102
|
+
? ""
|
|
103
|
+
: format
|
|
104
|
+
? format(value)
|
|
105
|
+
: defaultFormat(value, precision));
|
|
106
|
+
}, [value, focused, format, precision]);
|
|
107
|
+
const innerRef = React.useRef(null);
|
|
108
|
+
const setRefs = React.useCallback((node) => {
|
|
109
|
+
innerRef.current = node;
|
|
110
|
+
if (typeof ref === "function")
|
|
111
|
+
ref(node);
|
|
112
|
+
else if (ref)
|
|
113
|
+
ref.current =
|
|
114
|
+
node;
|
|
115
|
+
}, [ref]);
|
|
116
|
+
const commit = (next) => {
|
|
117
|
+
const formatted = next === null
|
|
118
|
+
? ""
|
|
119
|
+
: format
|
|
120
|
+
? format(next)
|
|
121
|
+
: defaultFormat(next, precision);
|
|
122
|
+
setDraft(formatted);
|
|
123
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
124
|
+
};
|
|
125
|
+
const adjustBy = (delta) => {
|
|
126
|
+
if (isDisabled || isReadOnly)
|
|
127
|
+
return;
|
|
128
|
+
const parsed = parse(draft);
|
|
129
|
+
const base = Number.isNaN(parsed) ? min !== null && min !== void 0 ? min : 0 : parsed;
|
|
130
|
+
let next = base + delta * step;
|
|
131
|
+
if (typeof precision === "number")
|
|
132
|
+
next = roundTo(next, precision);
|
|
133
|
+
next = clamp(next, min, max);
|
|
134
|
+
commit(next);
|
|
135
|
+
};
|
|
136
|
+
const handleChange = (event) => {
|
|
137
|
+
setDraft(event.target.value);
|
|
138
|
+
const parsed = parse(event.target.value);
|
|
139
|
+
if (Number.isNaN(parsed)) {
|
|
140
|
+
if (event.target.value === "")
|
|
141
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(parsed);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const handleBlur = (event) => {
|
|
148
|
+
setFocused(false);
|
|
149
|
+
const parsed = parse(draft);
|
|
150
|
+
if (Number.isNaN(parsed)) {
|
|
151
|
+
if (draft.trim() === "")
|
|
152
|
+
commit(null);
|
|
153
|
+
else
|
|
154
|
+
commit(value !== null && value !== void 0 ? value : null);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
let next = parsed;
|
|
158
|
+
if (typeof precision === "number")
|
|
159
|
+
next = roundTo(next, precision);
|
|
160
|
+
next = clamp(next, min, max);
|
|
161
|
+
commit(next);
|
|
162
|
+
}
|
|
163
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
164
|
+
};
|
|
165
|
+
const handleFocus = (event) => {
|
|
166
|
+
setFocused(true);
|
|
167
|
+
const parsed = parse(draft);
|
|
168
|
+
if (!Number.isNaN(parsed)) {
|
|
169
|
+
setDraft(defaultFormat(parsed, precision));
|
|
170
|
+
}
|
|
171
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
172
|
+
};
|
|
173
|
+
const handleKeyDown = (event) => {
|
|
174
|
+
if (event.key === "ArrowUp") {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
adjustBy(event.shiftKey ? 10 : 1);
|
|
177
|
+
}
|
|
178
|
+
else if (event.key === "ArrowDown") {
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
adjustBy(event.shiftKey ? -10 : -1);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const atMin = typeof min === "number" && parseSafe(draft) <= min;
|
|
184
|
+
const atMax = typeof max === "number" && parseSafe(draft) >= max;
|
|
185
|
+
return (React.createElement("div", { className: (0, utils_1.cn)("relative", className) },
|
|
186
|
+
React.createElement(input_1.Input, { ref: setRefs, name: name, type: "text", inputMode: "decimal", placeholder: placeholder, value: draft, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, disabled: isDisabled, readOnly: isReadOnly, autoFocus: autoFocus, size: size, "aria-invalid": error || field.hasError || undefined, role: "spinbutton", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": typeof value === "number" ? value : undefined, className: (0, utils_1.cn)(!hideSteppers && stepperPadding(size), "tabular-nums", error &&
|
|
187
|
+
"border-destructive bg-destructive/5 focus-visible:ring-destructive") }),
|
|
188
|
+
!hideSteppers && (React.createElement("div", { className: (0, utils_1.cn)("pointer-events-none absolute inset-y-0 right-0 flex flex-col border-l border-input", STEPPER_SIZE[size]), "aria-hidden": "true" },
|
|
189
|
+
React.createElement(StepperButton, { label: "Increment", disabled: isDisabled || isReadOnly || atMax, onClick: () => adjustBy(1), size: size, position: "top" },
|
|
190
|
+
React.createElement(lucide_react_1.ChevronUp, { className: STEPPER_ICON[size] })),
|
|
191
|
+
React.createElement(StepperButton, { label: "Decrement", disabled: isDisabled || isReadOnly || atMin, onClick: () => adjustBy(-1), size: size, position: "bottom" },
|
|
192
|
+
React.createElement(lucide_react_1.ChevronDown, { className: STEPPER_ICON[size] }))))));
|
|
193
|
+
});
|
|
194
|
+
NumberInputControl.displayName = "NumberInputControl";
|
|
195
|
+
function parseSafe(raw) {
|
|
196
|
+
const n = parseFloat(raw);
|
|
197
|
+
return Number.isNaN(n) ? -Infinity : n;
|
|
198
|
+
}
|
|
199
|
+
function stepperPadding(size) {
|
|
200
|
+
if (size === "sm")
|
|
201
|
+
return "pr-7";
|
|
202
|
+
if (size === "lg")
|
|
203
|
+
return "pr-9";
|
|
204
|
+
return "pr-8";
|
|
205
|
+
}
|
|
206
|
+
function StepperButton({ label, disabled, onClick, size, position, children, }) {
|
|
207
|
+
return (React.createElement("button", { type: "button", tabIndex: -1, "aria-label": label, disabled: disabled, onMouseDown: (event) => {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
}, onClick: onClick, className: (0, utils_1.cn)("pointer-events-auto flex flex-1 items-center justify-center text-muted-foreground transition-colors", "hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", position === "top" ? "rounded-tr-md" : "rounded-br-md", size === "sm" ? "min-h-0" : "min-h-0") }, children));
|
|
210
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type PinInputSize = "sm" | "md" | "lg";
|
|
3
|
+
export type PinInputType = "number" | "alphanumeric";
|
|
4
|
+
export interface PinInputProps {
|
|
5
|
+
length?: number;
|
|
6
|
+
type?: PinInputType;
|
|
7
|
+
value?: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
onChange?: (value: string) => void;
|
|
10
|
+
/** Fires when all boxes are filled. */
|
|
11
|
+
onComplete?: (value: string) => void;
|
|
12
|
+
autoFocus?: boolean;
|
|
13
|
+
/** Replace the visible character with • (e.g. for OTP secrets). */
|
|
14
|
+
mask?: boolean;
|
|
15
|
+
label?: React.ReactNode;
|
|
16
|
+
helperText?: React.ReactNode;
|
|
17
|
+
error?: boolean;
|
|
18
|
+
errorMessage?: React.ReactNode;
|
|
19
|
+
isRequired?: boolean;
|
|
20
|
+
size?: PinInputSize;
|
|
21
|
+
name?: string;
|
|
22
|
+
isDisabled?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const PinInput: React.ForwardRefExoticComponent<PinInputProps & React.RefAttributes<HTMLDivElement>>;
|