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,138 @@
|
|
|
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.PinInput = void 0;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const utils_1 = require("../../lib/utils");
|
|
39
|
+
const field_1 = require("../ui/field");
|
|
40
|
+
const SIZE_CLASS = {
|
|
41
|
+
sm: "h-9 w-9 text-sm",
|
|
42
|
+
md: "h-11 w-11 text-base",
|
|
43
|
+
lg: "h-12 w-12 text-lg",
|
|
44
|
+
};
|
|
45
|
+
function normalize(raw, type) {
|
|
46
|
+
if (type === "number")
|
|
47
|
+
return raw.replace(/[^0-9]/g, "");
|
|
48
|
+
return raw.replace(/[^A-Za-z0-9]/g, "");
|
|
49
|
+
}
|
|
50
|
+
exports.PinInput = React.forwardRef((props, ref) => {
|
|
51
|
+
const { id, label, helperText, error, errorMessage, isRequired, length = 6, type = "number", value, defaultValue, onChange, onComplete, autoFocus, mask = false, size = "md", name, isDisabled, className, } = props;
|
|
52
|
+
const isControlled = value !== undefined;
|
|
53
|
+
const [internalValue, setInternalValue] = React.useState((defaultValue !== null && defaultValue !== void 0 ? defaultValue : "").slice(0, length));
|
|
54
|
+
const current = (isControlled ? value : internalValue).slice(0, length);
|
|
55
|
+
const inputRefs = React.useRef([]);
|
|
56
|
+
const setValue = (next) => {
|
|
57
|
+
const normalized = normalize(next, type).slice(0, length);
|
|
58
|
+
if (!isControlled)
|
|
59
|
+
setInternalValue(normalized);
|
|
60
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(normalized);
|
|
61
|
+
if (normalized.length === length)
|
|
62
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete(normalized);
|
|
63
|
+
};
|
|
64
|
+
const focusIndex = (index) => {
|
|
65
|
+
const target = inputRefs.current[index];
|
|
66
|
+
if (target) {
|
|
67
|
+
target.focus();
|
|
68
|
+
target.select();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const handleInput = (index, event) => {
|
|
72
|
+
const raw = event.target.value;
|
|
73
|
+
if (raw.length > 1) {
|
|
74
|
+
const cleaned = normalize(raw, type).slice(0, length);
|
|
75
|
+
setValue(cleaned.padEnd(0, ""));
|
|
76
|
+
focusIndex(Math.min(cleaned.length, length - 1));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const char = normalize(raw, type).slice(-1);
|
|
80
|
+
const chars = current.split("");
|
|
81
|
+
chars[index] = char;
|
|
82
|
+
const joined = chars.join("").replace(/\s+$/, "");
|
|
83
|
+
setValue(joined);
|
|
84
|
+
if (char && index < length - 1)
|
|
85
|
+
focusIndex(index + 1);
|
|
86
|
+
};
|
|
87
|
+
const handleKeyDown = (index, event) => {
|
|
88
|
+
if (event.key === "Backspace") {
|
|
89
|
+
if (current[index]) {
|
|
90
|
+
const chars = current.split("");
|
|
91
|
+
chars[index] = "";
|
|
92
|
+
setValue(chars.join(""));
|
|
93
|
+
}
|
|
94
|
+
else if (index > 0) {
|
|
95
|
+
focusIndex(index - 1);
|
|
96
|
+
const chars = current.split("");
|
|
97
|
+
chars[index - 1] = "";
|
|
98
|
+
setValue(chars.join(""));
|
|
99
|
+
}
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (event.key === "ArrowLeft" && index > 0) {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
focusIndex(index - 1);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (event.key === "ArrowRight" && index < length - 1) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
focusIndex(index + 1);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const handlePaste = (event) => {
|
|
115
|
+
const pasted = event.clipboardData.getData("text");
|
|
116
|
+
if (!pasted)
|
|
117
|
+
return;
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
const cleaned = normalize(pasted, type).slice(0, length);
|
|
120
|
+
setValue(cleaned);
|
|
121
|
+
focusIndex(Math.min(cleaned.length, length - 1));
|
|
122
|
+
};
|
|
123
|
+
const boxes = (React.createElement("div", { ref: ref, role: "group", "aria-label": typeof label === "string" ? label : "Pin input", className: (0, utils_1.cn)("flex items-center gap-2", className) },
|
|
124
|
+
Array.from({ length }).map((_, index) => {
|
|
125
|
+
var _a;
|
|
126
|
+
const char = (_a = current[index]) !== null && _a !== void 0 ? _a : "";
|
|
127
|
+
return (React.createElement("input", { key: index, ref: (node) => {
|
|
128
|
+
inputRefs.current[index] = node;
|
|
129
|
+
}, type: mask ? "password" : "text", inputMode: type === "number" ? "numeric" : "text", autoComplete: index === 0 ? "one-time-code" : "off", autoFocus: autoFocus && index === 0, disabled: isDisabled, maxLength: 1, value: char, onChange: (event) => handleInput(index, event), onKeyDown: (event) => handleKeyDown(index, event), onPaste: handlePaste, onFocus: (event) => event.target.select(), "aria-label": `Digit ${index + 1} of ${length}`, "aria-invalid": error || undefined, className: (0, utils_1.cn)("shrink-0 rounded-md border border-input bg-background text-center font-medium tabular-nums shadow-sm transition-colors", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1", "disabled:cursor-not-allowed disabled:opacity-50", error &&
|
|
130
|
+
"border-destructive focus-visible:ring-destructive", SIZE_CLASS[size]) }));
|
|
131
|
+
}),
|
|
132
|
+
name && (React.createElement("input", { type: "hidden", name: name, value: current }))));
|
|
133
|
+
if (label || helperText || errorMessage) {
|
|
134
|
+
return (React.createElement(field_1.Field, { id: id, label: label, helperText: helperText, error: error, errorMessage: errorMessage, isRequired: isRequired }, boxes));
|
|
135
|
+
}
|
|
136
|
+
return boxes;
|
|
137
|
+
});
|
|
138
|
+
exports.PinInput.displayName = "PinInput";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ProfilePhotoSize = "sm" | "md" | "lg" | "xl";
|
|
3
|
+
export interface ProfilePhotoViewerProps {
|
|
4
|
+
src?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
initials?: string;
|
|
7
|
+
size?: ProfilePhotoSize;
|
|
8
|
+
/** When true, hover overlay shows a camera icon; click opens file picker. */
|
|
9
|
+
editable?: boolean;
|
|
10
|
+
onPhotoChange?: (file: File) => void;
|
|
11
|
+
/** Accept attribute for the hidden file input. */
|
|
12
|
+
accept?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function ProfilePhotoViewer({ src, name, initials, size, editable, onPhotoChange, accept, className, }: ProfilePhotoViewerProps): React.ReactElement;
|
|
16
|
+
export declare namespace ProfilePhotoViewer {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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.ProfilePhotoViewer = ProfilePhotoViewer;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const lucide_react_1 = require("lucide-react");
|
|
39
|
+
const utils_1 = require("../../lib/utils");
|
|
40
|
+
const avatar_1 = require("../ui/avatar");
|
|
41
|
+
const dialog_1 = require("../ui/dialog");
|
|
42
|
+
const SIZE_PX = {
|
|
43
|
+
sm: 32,
|
|
44
|
+
md: 48,
|
|
45
|
+
lg: 80,
|
|
46
|
+
xl: 128,
|
|
47
|
+
};
|
|
48
|
+
function ProfilePhotoViewer({ src, name, initials, size = "lg", editable = false, onPhotoChange, accept = "image/*", className, }) {
|
|
49
|
+
const [viewerOpen, setViewerOpen] = React.useState(false);
|
|
50
|
+
const fileInputRef = React.useRef(null);
|
|
51
|
+
const resolvedInitials = initials !== null && initials !== void 0 ? initials : (name
|
|
52
|
+
? name
|
|
53
|
+
.split(/\s+/)
|
|
54
|
+
.map((part) => part[0])
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.slice(0, 2)
|
|
57
|
+
.join("")
|
|
58
|
+
.toUpperCase()
|
|
59
|
+
: "?");
|
|
60
|
+
const px = SIZE_PX[size];
|
|
61
|
+
const handleEditClick = (event) => {
|
|
62
|
+
var _a;
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
(_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
65
|
+
};
|
|
66
|
+
const handleFile = (event) => {
|
|
67
|
+
var _a;
|
|
68
|
+
const file = (_a = event.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
69
|
+
if (file)
|
|
70
|
+
onPhotoChange === null || onPhotoChange === void 0 ? void 0 : onPhotoChange(file);
|
|
71
|
+
event.target.value = "";
|
|
72
|
+
};
|
|
73
|
+
return (React.createElement(React.Fragment, null,
|
|
74
|
+
React.createElement("div", { className: (0, utils_1.cn)("relative inline-flex shrink-0", className), style: { width: px, height: px } },
|
|
75
|
+
React.createElement("button", { type: "button", onClick: () => src && setViewerOpen(true), "aria-label": src
|
|
76
|
+
? `View photo of ${name !== null && name !== void 0 ? name : "user"}`
|
|
77
|
+
: `${name !== null && name !== void 0 ? name : "User"} profile photo`, className: (0, utils_1.cn)("h-full w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", !src && "cursor-default"), disabled: !src },
|
|
78
|
+
React.createElement(avatar_1.Avatar, { size: size === "sm" ? "sm" : size === "md" ? "md" : "lg", className: "h-full w-full" },
|
|
79
|
+
src && React.createElement(avatar_1.AvatarImage, { src: src, alt: name !== null && name !== void 0 ? name : "Profile" }),
|
|
80
|
+
React.createElement(avatar_1.AvatarFallback, null, resolvedInitials))),
|
|
81
|
+
editable && (React.createElement("button", { type: "button", onClick: handleEditClick, "aria-label": "Change profile photo", className: (0, utils_1.cn)("absolute inset-0 grid place-items-center rounded-full bg-foreground/60 text-background opacity-0 transition-opacity", "hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background") },
|
|
82
|
+
React.createElement(lucide_react_1.Camera, { "aria-hidden": "true", className: (0, utils_1.cn)(size === "sm" ? "h-3.5 w-3.5" : "h-5 w-5") }))),
|
|
83
|
+
editable && (React.createElement("input", { ref: fileInputRef, type: "file", accept: accept, className: "sr-only", onChange: handleFile }))),
|
|
84
|
+
React.createElement(dialog_1.Dialog, { open: viewerOpen, onOpenChange: setViewerOpen },
|
|
85
|
+
React.createElement(dialog_1.DialogContent, { size: "lg" },
|
|
86
|
+
React.createElement(dialog_1.DialogHeader, null,
|
|
87
|
+
React.createElement(dialog_1.DialogTitle, null, name !== null && name !== void 0 ? name : "Profile photo")),
|
|
88
|
+
src && (React.createElement("div", { className: "flex items-center justify-center" },
|
|
89
|
+
React.createElement("img", { src: src, alt: name !== null && name !== void 0 ? name : "Profile", className: "max-h-[60vh] w-auto rounded-md object-contain" })))))));
|
|
90
|
+
}
|
|
91
|
+
ProfilePhotoViewer.displayName = "ProfilePhotoViewer";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
group?: string;
|
|
9
|
+
}
|
|
10
|
+
export type SelectSize = "sm" | "md" | "lg";
|
|
11
|
+
export interface SelectProps {
|
|
12
|
+
options: SelectOption[];
|
|
13
|
+
value?: string | string[];
|
|
14
|
+
defaultValue?: string | string[];
|
|
15
|
+
onChange?: (value: string | string[]) => void;
|
|
16
|
+
multiple?: boolean;
|
|
17
|
+
searchable?: boolean;
|
|
18
|
+
clearable?: boolean;
|
|
19
|
+
creatable?: boolean;
|
|
20
|
+
onCreateOption?: (inputValue: string) => void;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
label?: React.ReactNode;
|
|
23
|
+
helperText?: React.ReactNode;
|
|
24
|
+
error?: boolean;
|
|
25
|
+
errorMessage?: React.ReactNode;
|
|
26
|
+
isInformation?: boolean;
|
|
27
|
+
informationMessage?: React.ReactNode;
|
|
28
|
+
isRequired?: boolean;
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
isLoading?: boolean;
|
|
31
|
+
size?: SelectSize;
|
|
32
|
+
width?: string;
|
|
33
|
+
maxDisplayed?: number;
|
|
34
|
+
onSearch?: (query: string) => void;
|
|
35
|
+
emptyMessage?: React.ReactNode;
|
|
36
|
+
loadingMessage?: React.ReactNode;
|
|
37
|
+
id?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,284 @@
|
|
|
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.Select = void 0;
|
|
48
|
+
const React = __importStar(require("react"));
|
|
49
|
+
const lucide_react_1 = require("lucide-react");
|
|
50
|
+
const cmdk_1 = require("cmdk");
|
|
51
|
+
const utils_1 = require("../../lib/utils");
|
|
52
|
+
const badge_1 = require("../ui/badge");
|
|
53
|
+
const field_1 = require("../ui/field");
|
|
54
|
+
const popover_1 = require("../ui/popover");
|
|
55
|
+
const select_1 = require("../ui/select");
|
|
56
|
+
const skeleton_1 = require("../ui/skeleton");
|
|
57
|
+
const spinner_1 = require("../ui/spinner");
|
|
58
|
+
const form_field_1 = require("../ui/form-field");
|
|
59
|
+
const TRIGGER_SIZE = {
|
|
60
|
+
sm: "min-h-8 text-xs px-2.5",
|
|
61
|
+
md: "min-h-9 text-sm px-3",
|
|
62
|
+
lg: "min-h-10 text-base px-3.5",
|
|
63
|
+
};
|
|
64
|
+
exports.Select = React.forwardRef((props, ref) => {
|
|
65
|
+
const { id, label, helperText, error, errorMessage, isInformation, informationMessage, isRequired, width, className } = props, controlProps = __rest(props, ["id", "label", "helperText", "error", "errorMessage", "isInformation", "informationMessage", "isRequired", "width", "className"]);
|
|
66
|
+
return (React.createElement(field_1.Field, { id: id, label: label, isRequired: isRequired, isInformation: isInformation, informationMessage: informationMessage, helperText: helperText, error: error, errorMessage: errorMessage, width: width },
|
|
67
|
+
React.createElement(SelectControl, Object.assign({ ref: ref, error: error, className: className }, controlProps))));
|
|
68
|
+
});
|
|
69
|
+
exports.Select.displayName = "Select";
|
|
70
|
+
const SelectControl = React.forwardRef((props, ref) => {
|
|
71
|
+
const { options, value, defaultValue, onChange, multiple = false, searchable = false, clearable = false, creatable = false, onCreateOption, placeholder = "Select…", isDisabled = false, isLoading = false, size = "md", maxDisplayed = 3, onSearch, emptyMessage = "No options found", loadingMessage = "Loading…", name, error, className, } = props;
|
|
72
|
+
if (!multiple && !searchable) {
|
|
73
|
+
return (React.createElement(SimpleRadixSelect, { ref: ref, options: options, value: value, defaultValue: defaultValue, onChange: (v) => onChange === null || onChange === void 0 ? void 0 : onChange(v), placeholder: placeholder, isDisabled: isDisabled || isLoading, size: size, name: name, error: error, className: className, loadingMessage: loadingMessage, isLoading: isLoading }));
|
|
74
|
+
}
|
|
75
|
+
return (React.createElement(ComboSelect, { ref: ref, options: options, value: value, defaultValue: defaultValue, onChange: onChange, multiple: multiple, clearable: clearable, creatable: creatable, onCreateOption: onCreateOption, placeholder: placeholder, isDisabled: isDisabled, isLoading: isLoading, size: size, maxDisplayed: maxDisplayed, onSearch: onSearch, emptyMessage: emptyMessage, loadingMessage: loadingMessage, error: error, className: className, name: name }));
|
|
76
|
+
});
|
|
77
|
+
SelectControl.displayName = "SelectControl";
|
|
78
|
+
const SimpleRadixSelect = React.forwardRef(({ options, value, defaultValue, onChange, placeholder, isDisabled, size, name, error, className, loadingMessage, isLoading, }, ref) => {
|
|
79
|
+
const field = (0, form_field_1.useFormField)();
|
|
80
|
+
const grouped = useGroupedOptions(options);
|
|
81
|
+
return (React.createElement(select_1.Select, { value: value, defaultValue: defaultValue, onValueChange: onChange, disabled: isDisabled, name: name },
|
|
82
|
+
React.createElement(select_1.SelectTrigger, { ref: ref, id: field.id || undefined, size: size, "aria-invalid": error || field.hasError || undefined, className: (0, utils_1.cn)(error &&
|
|
83
|
+
"border-destructive bg-destructive/5 focus:ring-destructive", className) },
|
|
84
|
+
React.createElement(select_1.SelectValue, { placeholder: placeholder }),
|
|
85
|
+
isLoading && (React.createElement(spinner_1.Spinner, { size: "sm", className: "ml-2", label: String(loadingMessage) }))),
|
|
86
|
+
React.createElement(select_1.SelectContent, null, grouped.map((group) => {
|
|
87
|
+
var _a;
|
|
88
|
+
return (React.createElement(select_1.SelectGroup, { key: (_a = group.label) !== null && _a !== void 0 ? _a : "__root" },
|
|
89
|
+
group.label && (React.createElement(select_1.SelectLabel, null, group.label)),
|
|
90
|
+
group.options.map((option) => (React.createElement(select_1.SelectItem, { key: option.value, value: option.value, disabled: option.disabled },
|
|
91
|
+
React.createElement("span", { className: "flex items-center gap-2" },
|
|
92
|
+
option.icon,
|
|
93
|
+
React.createElement("span", { className: "flex flex-col" },
|
|
94
|
+
React.createElement("span", null, option.label),
|
|
95
|
+
option.description && (React.createElement("span", { className: "text-xs text-muted-foreground" }, option.description)))))))));
|
|
96
|
+
}))));
|
|
97
|
+
});
|
|
98
|
+
SimpleRadixSelect.displayName = "SimpleRadixSelect";
|
|
99
|
+
const ComboSelect = React.forwardRef(({ options, value, defaultValue, onChange, multiple, clearable, creatable, onCreateOption, placeholder, isDisabled, isLoading, size, maxDisplayed, onSearch, emptyMessage, loadingMessage, error, className, name, }, ref) => {
|
|
100
|
+
var _a;
|
|
101
|
+
const field = (0, form_field_1.useFormField)();
|
|
102
|
+
const isControlled = value !== undefined;
|
|
103
|
+
const [internalValue, setInternalValue] = React.useState(() => {
|
|
104
|
+
if (defaultValue !== undefined)
|
|
105
|
+
return defaultValue;
|
|
106
|
+
return multiple ? [] : "";
|
|
107
|
+
});
|
|
108
|
+
const currentValue = isControlled ? value : internalValue;
|
|
109
|
+
const [open, setOpen] = React.useState(false);
|
|
110
|
+
const [query, setQuery] = React.useState("");
|
|
111
|
+
const debouncedQuery = useDebouncedValue(query, 150);
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
if (onSearch)
|
|
114
|
+
onSearch(query);
|
|
115
|
+
}, [query, onSearch]);
|
|
116
|
+
const filtered = React.useMemo(() => {
|
|
117
|
+
if (onSearch)
|
|
118
|
+
return options;
|
|
119
|
+
if (!debouncedQuery.trim())
|
|
120
|
+
return options;
|
|
121
|
+
const q = debouncedQuery.toLowerCase();
|
|
122
|
+
return options.filter((o) => {
|
|
123
|
+
var _a;
|
|
124
|
+
return o.label.toLowerCase().includes(q) ||
|
|
125
|
+
o.value.toLowerCase().includes(q) ||
|
|
126
|
+
((_a = o.description) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(q));
|
|
127
|
+
});
|
|
128
|
+
}, [options, debouncedQuery, onSearch]);
|
|
129
|
+
const grouped = useGroupedOptions(filtered);
|
|
130
|
+
const setValue = (next) => {
|
|
131
|
+
if (!isControlled)
|
|
132
|
+
setInternalValue(next);
|
|
133
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
134
|
+
};
|
|
135
|
+
const selectedValues = React.useMemo(() => {
|
|
136
|
+
if (multiple)
|
|
137
|
+
return new Set(Array.isArray(currentValue) ? currentValue : []);
|
|
138
|
+
return new Set(typeof currentValue === "string" && currentValue ? [currentValue] : []);
|
|
139
|
+
}, [currentValue, multiple]);
|
|
140
|
+
const selectedOptions = React.useMemo(() => {
|
|
141
|
+
return options.filter((o) => selectedValues.has(o.value));
|
|
142
|
+
}, [options, selectedValues]);
|
|
143
|
+
const handleSelect = (optionValue) => {
|
|
144
|
+
if (multiple) {
|
|
145
|
+
const arr = Array.isArray(currentValue) ? currentValue : [];
|
|
146
|
+
const next = arr.includes(optionValue)
|
|
147
|
+
? arr.filter((v) => v !== optionValue)
|
|
148
|
+
: [...arr, optionValue];
|
|
149
|
+
setValue(next);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
setValue(optionValue);
|
|
153
|
+
setOpen(false);
|
|
154
|
+
}
|
|
155
|
+
setQuery("");
|
|
156
|
+
};
|
|
157
|
+
const removeValue = (optionValue) => {
|
|
158
|
+
if (multiple) {
|
|
159
|
+
const arr = Array.isArray(currentValue) ? currentValue : [];
|
|
160
|
+
setValue(arr.filter((v) => v !== optionValue));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
setValue("");
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const clearAll = (event) => {
|
|
167
|
+
event.stopPropagation();
|
|
168
|
+
setValue(multiple ? [] : "");
|
|
169
|
+
};
|
|
170
|
+
const hasValue = multiple
|
|
171
|
+
? Array.isArray(currentValue) && currentValue.length > 0
|
|
172
|
+
: !!currentValue;
|
|
173
|
+
const showCreate = creatable &&
|
|
174
|
+
query.trim() !== "" &&
|
|
175
|
+
!filtered.some((o) => o.label.toLowerCase() === query.trim().toLowerCase());
|
|
176
|
+
return (React.createElement(React.Fragment, null,
|
|
177
|
+
React.createElement(popover_1.Popover, { open: open, onOpenChange: setOpen },
|
|
178
|
+
React.createElement(popover_1.PopoverTrigger, { asChild: true },
|
|
179
|
+
React.createElement("button", { ref: ref, type: "button", id: field.id || undefined, role: "combobox", "aria-expanded": open, "aria-haspopup": "listbox", "aria-autocomplete": "list", "aria-invalid": error || field.hasError || undefined, disabled: isDisabled || isLoading, className: (0, utils_1.cn)("group flex w-full items-center justify-between gap-2 rounded-md border border-input bg-background text-foreground shadow-sm transition-colors", "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 focus:ring-offset-background", "disabled:cursor-not-allowed disabled:opacity-50", "data-[state=open]:ring-2 data-[state=open]:ring-ring", TRIGGER_SIZE[size], error &&
|
|
180
|
+
"border-destructive bg-destructive/5 focus:ring-destructive", className) },
|
|
181
|
+
React.createElement(SelectedChips, { multiple: multiple, selectedOptions: selectedOptions, maxDisplayed: maxDisplayed, placeholder: placeholder, removeValue: removeValue, isDisabled: isDisabled }),
|
|
182
|
+
React.createElement("span", { className: "ml-auto flex items-center gap-1 text-muted-foreground" },
|
|
183
|
+
isLoading && React.createElement(spinner_1.Spinner, { size: "sm" }),
|
|
184
|
+
clearable && hasValue && !isDisabled && (React.createElement("button", { type: "button", "aria-label": "Clear selection", onClick: clearAll, className: "rounded-sm hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" },
|
|
185
|
+
React.createElement(lucide_react_1.X, { className: "h-4 w-4" }))),
|
|
186
|
+
React.createElement(lucide_react_1.ChevronDown, { className: "h-4 w-4 opacity-60 transition-transform group-data-[state=open]:rotate-180" })))),
|
|
187
|
+
React.createElement(popover_1.PopoverContent, { align: "start", className: "w-[var(--radix-popover-trigger-width)] p-0" },
|
|
188
|
+
React.createElement(cmdk_1.Command, { shouldFilter: false, className: "flex max-h-72 flex-col overflow-hidden" },
|
|
189
|
+
React.createElement("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-2" },
|
|
190
|
+
React.createElement(lucide_react_1.Search, { "aria-hidden": "true", className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
191
|
+
React.createElement(cmdk_1.CommandInput, { autoFocus: true, value: query, onValueChange: setQuery, placeholder: "Search\u2026", className: "flex-1 bg-transparent py-2 text-sm outline-none placeholder:text-muted-foreground" })),
|
|
192
|
+
React.createElement(cmdk_1.CommandList, { className: "max-h-[16rem] flex-1 overflow-y-auto py-1" }, isLoading ? (React.createElement("div", { className: "space-y-1.5 px-2 py-2" },
|
|
193
|
+
React.createElement(skeleton_1.Skeleton, { variant: "text", className: "w-full" }),
|
|
194
|
+
React.createElement(skeleton_1.Skeleton, { variant: "text", className: "w-3/4" }),
|
|
195
|
+
React.createElement(skeleton_1.Skeleton, { variant: "text", className: "w-1/2" }))) : grouped.length === 0 && !showCreate ? (React.createElement(cmdk_1.CommandEmpty, { className: "px-3 py-4 text-center text-sm text-muted-foreground" }, emptyMessage)) : (React.createElement(React.Fragment, null,
|
|
196
|
+
grouped.map((group, idx) => {
|
|
197
|
+
var _a;
|
|
198
|
+
return (React.createElement(React.Fragment, { key: (_a = group.label) !== null && _a !== void 0 ? _a : "__root" },
|
|
199
|
+
idx > 0 && (React.createElement(cmdk_1.CommandSeparator, { className: "my-1 h-px bg-border" })),
|
|
200
|
+
React.createElement(cmdk_1.CommandGroup, { heading: group.label, className: (0, utils_1.cn)("px-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5", "[&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:text-muted-foreground") }, group.options.map((option) => (React.createElement(ComboItem, { key: option.value, option: option, selected: selectedValues.has(option.value), onSelect: () => handleSelect(option.value) }))))));
|
|
201
|
+
}),
|
|
202
|
+
showCreate && (React.createElement(React.Fragment, null,
|
|
203
|
+
React.createElement(cmdk_1.CommandSeparator, { className: "my-1 h-px bg-border" }),
|
|
204
|
+
React.createElement(cmdk_1.CommandItem, { value: `__create__${query}`, onSelect: () => {
|
|
205
|
+
const newValue = query.trim();
|
|
206
|
+
onCreateOption === null || onCreateOption === void 0 ? void 0 : onCreateOption(newValue);
|
|
207
|
+
handleSelect(newValue);
|
|
208
|
+
}, className: "mx-1 flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground aria-selected:bg-accent aria-selected:text-accent-foreground" },
|
|
209
|
+
React.createElement("span", { className: "text-muted-foreground" }, "Create"),
|
|
210
|
+
React.createElement("span", { className: "font-medium" },
|
|
211
|
+
"\u201C",
|
|
212
|
+
query,
|
|
213
|
+
"\u201D")))))))))),
|
|
214
|
+
name && (React.createElement("input", { type: "hidden", name: name, value: multiple
|
|
215
|
+
? JSON.stringify(currentValue !== null && currentValue !== void 0 ? currentValue : [])
|
|
216
|
+
: (_a = currentValue) !== null && _a !== void 0 ? _a : "" }))));
|
|
217
|
+
});
|
|
218
|
+
ComboSelect.displayName = "ComboSelect";
|
|
219
|
+
function ComboItem({ option, selected, onSelect }) {
|
|
220
|
+
return (React.createElement(cmdk_1.CommandItem, { value: `${option.label} ${option.value}`, disabled: option.disabled, onSelect: onSelect, className: (0, utils_1.cn)("relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm", "aria-selected:bg-accent aria-selected:text-accent-foreground", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50") },
|
|
221
|
+
option.icon,
|
|
222
|
+
React.createElement("span", { className: "flex flex-col" },
|
|
223
|
+
React.createElement("span", null, option.label),
|
|
224
|
+
option.description && (React.createElement("span", { className: "text-xs text-muted-foreground" }, option.description))),
|
|
225
|
+
selected && (React.createElement(lucide_react_1.Check, { "aria-hidden": "true", className: "ml-auto h-4 w-4 shrink-0 text-primary" }))));
|
|
226
|
+
}
|
|
227
|
+
function SelectedChips({ multiple, selectedOptions, maxDisplayed, placeholder, removeValue, isDisabled, }) {
|
|
228
|
+
if (selectedOptions.length === 0) {
|
|
229
|
+
return (React.createElement("span", { className: "truncate text-muted-foreground" }, placeholder));
|
|
230
|
+
}
|
|
231
|
+
if (!multiple) {
|
|
232
|
+
const [first] = selectedOptions;
|
|
233
|
+
return (React.createElement("span", { className: "flex items-center gap-2 truncate text-foreground" },
|
|
234
|
+
first.icon,
|
|
235
|
+
React.createElement("span", { className: "truncate" }, first.label)));
|
|
236
|
+
}
|
|
237
|
+
const visible = selectedOptions.slice(0, maxDisplayed);
|
|
238
|
+
const overflow = selectedOptions.length - visible.length;
|
|
239
|
+
return (React.createElement("div", { className: "flex max-h-[5.5rem] flex-1 flex-wrap items-center gap-1 overflow-y-auto py-1" },
|
|
240
|
+
visible.map((option) => (React.createElement(badge_1.Badge, { key: option.value, variant: "secondary", size: "sm", className: "gap-1 pr-1" },
|
|
241
|
+
option.label,
|
|
242
|
+
!isDisabled && (React.createElement("button", { type: "button", "aria-label": `Remove ${option.label}`, onClick: (event) => {
|
|
243
|
+
event.stopPropagation();
|
|
244
|
+
removeValue(option.value);
|
|
245
|
+
}, className: "rounded-sm hover:bg-foreground/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" },
|
|
246
|
+
React.createElement(lucide_react_1.X, { className: "h-3 w-3" })))))),
|
|
247
|
+
overflow > 0 && (React.createElement(badge_1.Badge, { variant: "outline", size: "sm" },
|
|
248
|
+
"+",
|
|
249
|
+
overflow,
|
|
250
|
+
" more"))));
|
|
251
|
+
}
|
|
252
|
+
function useGroupedOptions(options) {
|
|
253
|
+
return React.useMemo(() => {
|
|
254
|
+
var _a;
|
|
255
|
+
const hasGroups = options.some((o) => !!o.group);
|
|
256
|
+
if (!hasGroups)
|
|
257
|
+
return [{ label: undefined, options }];
|
|
258
|
+
const map = new Map();
|
|
259
|
+
for (const option of options) {
|
|
260
|
+
const key = option.group;
|
|
261
|
+
const list = (_a = map.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
262
|
+
list.push(option);
|
|
263
|
+
map.set(key, list);
|
|
264
|
+
}
|
|
265
|
+
const groups = [];
|
|
266
|
+
const ungrouped = map.get(undefined);
|
|
267
|
+
if (ungrouped)
|
|
268
|
+
groups.push({ label: undefined, options: ungrouped });
|
|
269
|
+
for (const [key, opts] of map.entries()) {
|
|
270
|
+
if (key === undefined)
|
|
271
|
+
continue;
|
|
272
|
+
groups.push({ label: key, options: opts });
|
|
273
|
+
}
|
|
274
|
+
return groups;
|
|
275
|
+
}, [options]);
|
|
276
|
+
}
|
|
277
|
+
function useDebouncedValue(value, delay) {
|
|
278
|
+
const [debounced, setDebounced] = React.useState(value);
|
|
279
|
+
React.useEffect(() => {
|
|
280
|
+
const timer = setTimeout(() => setDebounced(value), delay);
|
|
281
|
+
return () => clearTimeout(timer);
|
|
282
|
+
}, [value, delay]);
|
|
283
|
+
return debounced;
|
|
284
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type LucideIcon } from "lucide-react";
|
|
3
|
+
type BadgeVariant = "default" | "destructive" | "success" | "warning";
|
|
4
|
+
export interface SidebarMenuItem {
|
|
5
|
+
id: string | number;
|
|
6
|
+
title: string;
|
|
7
|
+
icon?: LucideIcon;
|
|
8
|
+
url?: string;
|
|
9
|
+
badge?: {
|
|
10
|
+
count?: number;
|
|
11
|
+
label?: string;
|
|
12
|
+
variant?: BadgeVariant;
|
|
13
|
+
};
|
|
14
|
+
children?: SidebarMenuItem[];
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface SidebarOtherApp {
|
|
18
|
+
id: string | number;
|
|
19
|
+
name: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
icon?: LucideIcon;
|
|
22
|
+
iconUrl?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SidebarProps {
|
|
25
|
+
menus: SidebarMenuItem[];
|
|
26
|
+
activeItem?: string | number;
|
|
27
|
+
onItemClick?: (item: SidebarMenuItem) => void;
|
|
28
|
+
logo?: string;
|
|
29
|
+
companyName?: string;
|
|
30
|
+
collapsed?: boolean;
|
|
31
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
32
|
+
defaultCollapsed?: boolean;
|
|
33
|
+
mobileOpen?: boolean;
|
|
34
|
+
onMobileOpenChange?: (open: boolean) => void;
|
|
35
|
+
otherApps?: SidebarOtherApp[];
|
|
36
|
+
footer?: React.ReactNode;
|
|
37
|
+
isLoading?: boolean;
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function Sidebar({ menus, activeItem, onItemClick, logo, companyName, collapsed: collapsedProp, onCollapsedChange, defaultCollapsed, mobileOpen, onMobileOpenChange, otherApps, footer, isLoading, className, }: SidebarProps): React.ReactElement;
|
|
41
|
+
export {};
|