@appcorp/stellar-solutions-modules 0.1.35 → 0.1.37

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.
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface CustomThemeProviderProps {
3
+ children: React.ReactNode;
4
+ defaultTheme?: string;
5
+ storageKey?: string;
6
+ enableSystem?: boolean;
7
+ }
8
+ export declare function ThemeProvider({ children, defaultTheme, storageKey, enableSystem, ...props }: CustomThemeProviderProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ "use strict";
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
47
+ var __rest = (this && this.__rest) || function (s, e) {
48
+ var t = {};
49
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
+ t[p] = s[p];
51
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
53
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
54
+ t[p[i]] = s[p[i]];
55
+ }
56
+ return t;
57
+ };
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.ThemeProvider = ThemeProvider;
60
+ var react_1 = __importStar(require("react"));
61
+ var next_themes_1 = require("next-themes");
62
+ var themes_1 = require("@/lib/themes");
63
+ // Component that applies theme variables when theme changes
64
+ function ThemeApplier(_a) {
65
+ var children = _a.children;
66
+ var _b = (0, next_themes_1.useTheme)(), theme = _b.theme, resolvedTheme = _b.resolvedTheme;
67
+ (0, react_1.useEffect)(function () {
68
+ var applyTheme = function (themeName) {
69
+ var themeConfig = themes_1.themes[themeName];
70
+ if (!themeConfig) {
71
+ console.warn("Theme \"".concat(themeName, "\" not found, falling back to light theme"));
72
+ // Fallback to light theme
73
+ var lightTheme = themes_1.themes.light;
74
+ if (lightTheme) {
75
+ var root_1 = document.documentElement;
76
+ Object.entries(lightTheme.colors).forEach(function (_a) {
77
+ var key = _a[0], value = _a[1];
78
+ root_1.style.setProperty("--".concat(key), value);
79
+ });
80
+ }
81
+ return;
82
+ }
83
+ var root = document.documentElement;
84
+ // Apply theme colors as CSS variables
85
+ Object.entries(themeConfig.colors).forEach(function (_a) {
86
+ var key = _a[0], value = _a[1];
87
+ root.style.setProperty("--".concat(key), value);
88
+ });
89
+ // Add theme class to root element for CSS selectors
90
+ root.className = root.className.replace(/theme-\w+/g, "");
91
+ root.classList.add("theme-".concat(themeName));
92
+ // Also set data-theme attribute for CSS selectors
93
+ root.setAttribute("data-theme", themeName);
94
+ };
95
+ // Apply theme on mount and when theme changes
96
+ var activeTheme = resolvedTheme || theme || "light";
97
+ // Always apply theme, even if it's "system" - fallback to light
98
+ var themeToApply = activeTheme === "system" ? "light" : activeTheme;
99
+ applyTheme(themeToApply);
100
+ }, [theme, resolvedTheme]);
101
+ // Apply default theme on mount
102
+ (0, react_1.useEffect)(function () {
103
+ // Apply light theme as default on first mount
104
+ var applyDefaultTheme = function () {
105
+ var lightTheme = themes_1.themes.light;
106
+ if (lightTheme) {
107
+ var root_2 = document.documentElement;
108
+ Object.entries(lightTheme.colors).forEach(function (_a) {
109
+ var key = _a[0], value = _a[1];
110
+ root_2.style.setProperty("--".concat(key), value);
111
+ });
112
+ }
113
+ };
114
+ applyDefaultTheme();
115
+ }, []); // Run only once on mount
116
+ return react_1.default.createElement(react_1.default.Fragment, null, children);
117
+ }
118
+ function ThemeProvider(_a) {
119
+ var children = _a.children, _b = _a.defaultTheme, defaultTheme = _b === void 0 ? "light" : _b, _c = _a.storageKey, storageKey = _c === void 0 ? "ui-theme" : _c, _d = _a.enableSystem, enableSystem = _d === void 0 ? false : _d, props = __rest(_a, ["children", "defaultTheme", "storageKey", "enableSystem"]);
120
+ return (react_1.default.createElement(next_themes_1.ThemeProvider, __assign({ attribute: "data-theme", defaultTheme: defaultTheme, storageKey: storageKey, enableSystem: enableSystem, themes: Object.keys(themes_1.themes) }, props),
121
+ react_1.default.createElement(ThemeApplier, null, children)));
122
+ }
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ declare function Card({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
3
+ declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
4
+ declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
5
+ declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
6
+ declare function CardAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
7
+ declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
8
+ declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
9
+ export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, };
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.Card = Card;
59
+ exports.CardHeader = CardHeader;
60
+ exports.CardFooter = CardFooter;
61
+ exports.CardTitle = CardTitle;
62
+ exports.CardAction = CardAction;
63
+ exports.CardDescription = CardDescription;
64
+ exports.CardContent = CardContent;
65
+ var React = __importStar(require("react"));
66
+ var utils_1 = require("@/lib/utils");
67
+ function Card(_a) {
68
+ var className = _a.className, props = __rest(_a, ["className"]);
69
+ return (React.createElement("div", __assign({ "data-slot": "card", className: (0, utils_1.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", className) }, props)));
70
+ }
71
+ function CardHeader(_a) {
72
+ var className = _a.className, props = __rest(_a, ["className"]);
73
+ return (React.createElement("div", __assign({ "data-slot": "card-header", className: (0, utils_1.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", className) }, props)));
74
+ }
75
+ function CardTitle(_a) {
76
+ var className = _a.className, props = __rest(_a, ["className"]);
77
+ return (React.createElement("div", __assign({ "data-slot": "card-title", className: (0, utils_1.cn)("leading-none font-semibold", className) }, props)));
78
+ }
79
+ function CardDescription(_a) {
80
+ var className = _a.className, props = __rest(_a, ["className"]);
81
+ return (React.createElement("div", __assign({ "data-slot": "card-description", className: (0, utils_1.cn)("text-muted-foreground text-sm", className) }, props)));
82
+ }
83
+ function CardAction(_a) {
84
+ var className = _a.className, props = __rest(_a, ["className"]);
85
+ return (React.createElement("div", __assign({ "data-slot": "card-action", className: (0, utils_1.cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className) }, props)));
86
+ }
87
+ function CardContent(_a) {
88
+ var className = _a.className, props = __rest(_a, ["className"]);
89
+ return (React.createElement("div", __assign({ "data-slot": "card-content", className: (0, utils_1.cn)("px-6", className) }, props)));
90
+ }
91
+ function CardFooter(_a) {
92
+ var className = _a.className, props = __rest(_a, ["className"]);
93
+ return (React.createElement("div", __assign({ "data-slot": "card-footer", className: (0, utils_1.cn)("flex items-center px-6 [.border-t]:pt-6", className) }, props)));
94
+ }
@@ -0,0 +1,70 @@
1
+ import React from "react";
2
+ export interface ComboboxOption {
3
+ value: string;
4
+ label: string;
5
+ id?: string;
6
+ }
7
+ interface ComboboxProps {
8
+ options: ComboboxOption[];
9
+ value?: string;
10
+ onValueChange: (value: string) => void;
11
+ onSearchChange?: (search: string) => void;
12
+ placeholder?: string;
13
+ searchPlaceholder?: string;
14
+ emptyText?: string;
15
+ loading?: boolean;
16
+ disabled?: boolean;
17
+ className?: string;
18
+ maxHeight?: number;
19
+ showScrollIndicators?: boolean;
20
+ virtualizeThreshold?: number;
21
+ label?: string;
22
+ required?: boolean;
23
+ id?: string;
24
+ info?: string;
25
+ error?: string;
26
+ }
27
+ export declare function Combobox({ className, disabled, emptyText, error, id, info, label, loading, maxHeight, onSearchChange, onValueChange, options, placeholder, required, searchPlaceholder, showScrollIndicators, value, virtualizeThreshold, }: ComboboxProps): React.JSX.Element;
28
+ interface CompanyComboboxProps {
29
+ companies: Array<{
30
+ id?: string;
31
+ name: string;
32
+ }>;
33
+ value?: string;
34
+ onValueChange: (value: string) => void;
35
+ onSearchChange: (search: string) => void;
36
+ loading?: boolean;
37
+ placeholder?: string;
38
+ className?: string;
39
+ maxHeight?: number;
40
+ showScrollIndicators?: boolean;
41
+ label?: string;
42
+ required?: boolean;
43
+ id?: string;
44
+ info?: string;
45
+ error?: string;
46
+ }
47
+ export declare function CompanyCombobox({ companies, value, onValueChange, onSearchChange, loading, placeholder, className, maxHeight, showScrollIndicators, label, required, id, info, error, }: CompanyComboboxProps): React.JSX.Element;
48
+ interface CountryComboboxProps {
49
+ countries?: Array<{
50
+ name: string;
51
+ code?: string;
52
+ }> | Array<{
53
+ name: string;
54
+ }>;
55
+ value?: string;
56
+ onValueChange: (value: string) => void;
57
+ onSearchChange?: (search: string) => void;
58
+ loading?: boolean;
59
+ placeholder?: string;
60
+ className?: string;
61
+ maxHeight?: number;
62
+ showScrollIndicators?: boolean;
63
+ label?: string;
64
+ required?: boolean;
65
+ id?: string;
66
+ info?: string;
67
+ error?: string;
68
+ }
69
+ export declare function CountryCombobox({ countries, value, onValueChange, onSearchChange, loading, placeholder, className, maxHeight, showScrollIndicators, label, required, id, info, error, }: CountryComboboxProps): React.JSX.Element;
70
+ export {};
@@ -0,0 +1,315 @@
1
+ "use client";
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.Combobox = Combobox;
38
+ exports.CompanyCombobox = CompanyCombobox;
39
+ exports.CountryCombobox = CountryCombobox;
40
+ var react_1 = __importStar(require("react"));
41
+ var lucide_react_1 = require("lucide-react");
42
+ var utils_1 = require("@/lib/utils");
43
+ var button_1 = require("@/components/ui/button");
44
+ var label_1 = require("@/components/ui/label");
45
+ var command_1 = require("@/components/ui/command");
46
+ var popover_1 = require("@/components/ui/popover");
47
+ function VirtualizedList(_a) {
48
+ var options = _a.options, selectedValue = _a.selectedValue, onSelect = _a.onSelect, scrollContainer = _a.scrollContainer;
49
+ var _b = (0, react_1.useState)({
50
+ start: 0,
51
+ end: Math.min(options.length, 25), // Increased initial visible items
52
+ }), visibleRange = _b[0], setVisibleRange = _b[1];
53
+ var handleScroll = (0, react_1.useCallback)(function () {
54
+ if (!scrollContainer.current)
55
+ return;
56
+ var _a = scrollContainer.current, scrollTop = _a.scrollTop, clientHeight = _a.clientHeight;
57
+ var itemHeight = 32; // Approximate item height
58
+ var containerHeight = clientHeight;
59
+ // Calculate visible range with proper bounds checking
60
+ var start = Math.max(0, Math.floor(scrollTop / itemHeight));
61
+ var visibleCount = Math.ceil(containerHeight / itemHeight);
62
+ var bufferSize = Math.min(10, Math.ceil(visibleCount * 0.5)); // Dynamic buffer
63
+ var end = Math.min(options.length, start + visibleCount + bufferSize);
64
+ var newRange = {
65
+ start: Math.max(0, start - bufferSize),
66
+ end: end,
67
+ };
68
+ // Only update if the range actually changed to prevent unnecessary re-renders
69
+ setVisibleRange(function (prevRange) {
70
+ if (prevRange.start !== newRange.start ||
71
+ prevRange.end !== newRange.end) {
72
+ return newRange;
73
+ }
74
+ return prevRange;
75
+ });
76
+ }, [options.length, scrollContainer]);
77
+ (0, react_1.useEffect)(function () {
78
+ var container = scrollContainer.current;
79
+ if (container) {
80
+ // Add scroll listener with passive option for better performance
81
+ container.addEventListener("scroll", handleScroll, { passive: true });
82
+ // Also listen to parent containers that might interfere (like drawer)
83
+ var parentContainer_1 = container.parentElement;
84
+ var parentScrollHandler_1 = function () { return handleScroll(); };
85
+ while (parentContainer_1) {
86
+ var hasOverflow = getComputedStyle(parentContainer_1).overflowY;
87
+ if (hasOverflow === "auto" || hasOverflow === "scroll") {
88
+ parentContainer_1.addEventListener("scroll", parentScrollHandler_1, {
89
+ passive: true,
90
+ });
91
+ break;
92
+ }
93
+ parentContainer_1 = parentContainer_1.parentElement;
94
+ }
95
+ return function () {
96
+ container.removeEventListener("scroll", handleScroll);
97
+ if (parentContainer_1) {
98
+ parentContainer_1.removeEventListener("scroll", parentScrollHandler_1);
99
+ }
100
+ };
101
+ }
102
+ }, [handleScroll, scrollContainer]);
103
+ // Reset visible range when options change (e.g., due to search filtering)
104
+ (0, react_1.useEffect)(function () {
105
+ var newEnd = Math.min(options.length, 25);
106
+ setVisibleRange(function () {
107
+ // Force update if options changed
108
+ return {
109
+ start: 0,
110
+ end: newEnd,
111
+ };
112
+ });
113
+ // Reset scroll position when options change
114
+ if (scrollContainer.current) {
115
+ scrollContainer.current.scrollTop = 0;
116
+ }
117
+ }, [options.length, options, scrollContainer]); // Watch both length and options array
118
+ // Ensure we always have valid visible range
119
+ var safeStart = Math.max(0, Math.min(visibleRange.start, options.length - 1));
120
+ var safeEnd = Math.max(safeStart + 1, Math.min(visibleRange.end, options.length));
121
+ var visibleOptions = options.slice(safeStart, safeEnd);
122
+ var topSpacer = safeStart * 32; // Approximate item height
123
+ var bottomSpacer = Math.max(0, (options.length - safeEnd) * 32);
124
+ return (react_1.default.createElement(react_1.default.Fragment, null,
125
+ topSpacer > 0 && react_1.default.createElement("div", { style: { height: topSpacer } }),
126
+ visibleOptions.map(function (option, index) { return (react_1.default.createElement(command_1.CommandItem, { key: "".concat(option.value, "-").concat(safeStart + index), value: option.label, onSelect: function () { return onSelect(option.value); }, className: "cursor-pointer hover:bg-accent hover:text-accent-foreground transition-colors h-8 flex items-center" },
127
+ react_1.default.createElement(lucide_react_1.Check, { className: (0, utils_1.cn)("mr-2 h-4 w-4", selectedValue === option.value ? "opacity-100" : "opacity-0") }),
128
+ react_1.default.createElement("span", { className: "truncate" }, option.label))); }),
129
+ bottomSpacer > 0 && react_1.default.createElement("div", { style: { height: bottomSpacer } })));
130
+ }
131
+ function Combobox(_a) {
132
+ var className = _a.className, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.emptyText, emptyText = _c === void 0 ? "No options found." : _c, error = _a.error, id = _a.id, info = _a.info, label = _a.label, _d = _a.loading, loading = _d === void 0 ? false : _d, _e = _a.maxHeight, maxHeight = _e === void 0 ? 256 : _e, onSearchChange = _a.onSearchChange, onValueChange = _a.onValueChange, _f = _a.options, options = _f === void 0 ? [] : _f, _g = _a.placeholder, placeholder = _g === void 0 ? "Select option..." : _g, _h = _a.required, required = _h === void 0 ? false : _h, _j = _a.searchPlaceholder, searchPlaceholder = _j === void 0 ? "Search..." : _j, _k = _a.showScrollIndicators, showScrollIndicators = _k === void 0 ? true : _k, value = _a.value, _l = _a.virtualizeThreshold, virtualizeThreshold = _l === void 0 ? 50 : _l;
133
+ var _m = (0, react_1.useState)(false), open = _m[0], setOpen = _m[1];
134
+ var _o = (0, react_1.useState)(""), searchValue = _o[0], setSearchValue = _o[1];
135
+ var _p = (0, react_1.useState)(false), canScrollUp = _p[0], setCanScrollUp = _p[1];
136
+ var _q = (0, react_1.useState)(false), canScrollDown = _q[0], setCanScrollDown = _q[1];
137
+ var scrollContainerRef = (0, react_1.useRef)(null);
138
+ var selectedOption = options.find(function (option) { return option.value === value; });
139
+ var shouldVirtualize = options.length > virtualizeThreshold;
140
+ // Filter options based on search - always handle filtering at this level for virtualization
141
+ var filteredOptions = react_1.default.useMemo(function () {
142
+ if (!searchValue) {
143
+ // No search query, return all options
144
+ return options;
145
+ }
146
+ if (onSearchChange && shouldVirtualize) {
147
+ // For virtualized lists with external search, let external handler manage it
148
+ // but still return all current options as they're already filtered externally
149
+ return options;
150
+ }
151
+ if (onSearchChange && !shouldVirtualize) {
152
+ // Non-virtualized with external search - let external handler manage
153
+ return options;
154
+ }
155
+ // Local filtering for non-external search or as fallback
156
+ return options.filter(function (option) {
157
+ return option.label.toLowerCase().includes(searchValue.toLowerCase());
158
+ });
159
+ }, [options, searchValue, onSearchChange, shouldVirtualize]);
160
+ var handleSearchChange = function (search) {
161
+ setSearchValue(search);
162
+ onSearchChange === null || onSearchChange === void 0 ? void 0 : onSearchChange(search);
163
+ };
164
+ var handleSelect = function (selectedValue) {
165
+ if (selectedValue === value) {
166
+ onValueChange("");
167
+ }
168
+ else {
169
+ onValueChange(selectedValue);
170
+ }
171
+ setOpen(false);
172
+ setSearchValue("");
173
+ };
174
+ // Handle scroll indicators
175
+ var updateScrollIndicators = function () {
176
+ if (!scrollContainerRef.current)
177
+ return;
178
+ var _a = scrollContainerRef.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
179
+ setCanScrollUp(scrollTop > 0);
180
+ setCanScrollDown(scrollTop < scrollHeight - clientHeight - 1);
181
+ };
182
+ // Update scroll indicators when options change or component opens
183
+ (0, react_1.useEffect)(function () {
184
+ if (open) {
185
+ // Small delay to ensure DOM is updated
186
+ setTimeout(updateScrollIndicators, 10);
187
+ }
188
+ }, [open, options]);
189
+ var scrollToTop = function () {
190
+ var _a;
191
+ (_a = scrollContainerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ top: 0, behavior: "smooth" });
192
+ };
193
+ var scrollToBottom = function () {
194
+ if (!scrollContainerRef.current)
195
+ return;
196
+ var scrollHeight = scrollContainerRef.current.scrollHeight;
197
+ scrollContainerRef.current.scrollTo({
198
+ top: scrollHeight,
199
+ behavior: "smooth",
200
+ });
201
+ };
202
+ var comboboxElement = (react_1.default.createElement(popover_1.Popover, { open: open, onOpenChange: setOpen, modal: true },
203
+ react_1.default.createElement(popover_1.PopoverTrigger, { asChild: true },
204
+ react_1.default.createElement(button_1.Button, { id: id, variant: "outline", role: "combobox", "aria-expanded": open, disabled: disabled, className: (0, utils_1.cn)("w-full justify-between", !selectedOption && "text-muted-foreground", className) },
205
+ (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || placeholder,
206
+ react_1.default.createElement(lucide_react_1.ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" }))),
207
+ react_1.default.createElement(popover_1.PopoverContent, { className: "w-[var(--radix-popover-trigger-width)] p-0", side: "bottom", align: "start", avoidCollisions: true, collisionPadding: 8, style: { zIndex: 1000 }, onOpenAutoFocus: function (e) { return e.preventDefault(); } },
208
+ react_1.default.createElement(command_1.Command, { shouldFilter: false },
209
+ react_1.default.createElement(command_1.CommandInput, { placeholder: searchPlaceholder, value: searchValue, onValueChange: handleSearchChange }),
210
+ react_1.default.createElement(command_1.CommandEmpty, null, loading ? (react_1.default.createElement("div", { className: "flex items-center justify-center py-6" },
211
+ react_1.default.createElement("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-primary" }),
212
+ react_1.default.createElement("span", { className: "ml-2 text-sm" }, "Searching..."))) : (emptyText)),
213
+ react_1.default.createElement("div", { className: "relative" },
214
+ showScrollIndicators && canScrollUp && (react_1.default.createElement("div", { className: "absolute top-0 left-0 right-0 z-10 h-8 bg-gradient-to-b from-background to-transparent pointer-events-none" },
215
+ react_1.default.createElement("button", { onClick: scrollToTop, className: "absolute top-1 left-1/2 transform -translate-x-1/2 p-1 rounded-full bg-background shadow-sm border pointer-events-auto hover:bg-muted transition-colors", "aria-label": "Scroll to top" },
216
+ react_1.default.createElement(lucide_react_1.ChevronUp, { className: "h-3 w-3" })))),
217
+ react_1.default.createElement(command_1.CommandGroup, { ref: scrollContainerRef, className: (0, utils_1.cn)("overflow-y-auto smooth-scroll", "scrollbar-thin scrollbar-thumb-muted-foreground/20 scrollbar-track-transparent hover:scrollbar-thumb-muted-foreground/40", "scroll-smooth", filteredOptions.length > 10 && "pb-2" // Extra padding for many options
218
+ ), style: { maxHeight: "".concat(maxHeight, "px") }, onScroll: updateScrollIndicators }, shouldVirtualize &&
219
+ filteredOptions.length > virtualizeThreshold ? (
220
+ // Virtualized rendering for large lists
221
+ react_1.default.createElement(VirtualizedList, { options: filteredOptions, selectedValue: value, onSelect: handleSelect, scrollContainer: scrollContainerRef })) : (
222
+ // Regular rendering for smaller lists or filtered results
223
+ filteredOptions.map(function (option) { return (react_1.default.createElement(command_1.CommandItem, { key: option.value, value: option.label, onSelect: function () { return handleSelect(option.value); }, className: "cursor-pointer hover:bg-accent hover:text-accent-foreground transition-colors" },
224
+ react_1.default.createElement(lucide_react_1.Check, { className: (0, utils_1.cn)("mr-2 h-4 w-4", value === option.value ? "opacity-100" : "opacity-0") }),
225
+ react_1.default.createElement("span", { className: "truncate" }, option.label))); }))),
226
+ showScrollIndicators && canScrollDown && (react_1.default.createElement("div", { className: "absolute bottom-0 left-0 right-0 z-10 h-8 bg-gradient-to-t from-background to-transparent pointer-events-none" },
227
+ react_1.default.createElement("button", { onClick: scrollToBottom, className: "absolute bottom-1 left-1/2 transform -translate-x-1/2 p-1 rounded-full bg-background shadow-sm border pointer-events-auto hover:bg-muted transition-colors", "aria-label": "Scroll to bottom" },
228
+ react_1.default.createElement(lucide_react_1.ChevronDown, { className: "h-3 w-3" })))))))));
229
+ // If label is provided, render the complete combobox with label structure
230
+ if (label) {
231
+ return (react_1.default.createElement("div", { className: "w-full space-y-2" },
232
+ react_1.default.createElement(label_1.Label, { htmlFor: id, required: required }, label),
233
+ comboboxElement,
234
+ error && (react_1.default.createElement("p", { className: "text-xs text-destructive dark:text-red-400" }, error)),
235
+ info && !error && (react_1.default.createElement("p", { className: "text-xs text-blue-600 dark:text-blue-400" }, info))));
236
+ }
237
+ // If no label, render just the combobox (backward compatibility)
238
+ return comboboxElement;
239
+ }
240
+ function CompanyCombobox(_a) {
241
+ var _b = _a.companies, companies = _b === void 0 ? [] : _b, value = _a.value, onValueChange = _a.onValueChange, onSearchChange = _a.onSearchChange, _c = _a.loading, loading = _c === void 0 ? false : _c, _d = _a.placeholder, placeholder = _d === void 0 ? "Select company..." : _d, className = _a.className, _e = _a.maxHeight, maxHeight = _e === void 0 ? 320 : _e, _f = _a.showScrollIndicators, showScrollIndicators = _f === void 0 ? true : _f, label = _a.label, _g = _a.required, required = _g === void 0 ? false : _g, id = _a.id, info = _a.info, error = _a.error;
242
+ var options = companies.map(function (company) {
243
+ var _a, _b;
244
+ return ({
245
+ value: ((_a = company.id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
246
+ label: company.name,
247
+ id: (_b = company.id) === null || _b === void 0 ? void 0 : _b.toString(),
248
+ });
249
+ });
250
+ return (react_1.default.createElement(Combobox, { options: options, value: value, onValueChange: onValueChange, onSearchChange: onSearchChange, placeholder: placeholder, searchPlaceholder: "Search companies...", emptyText: "No companies found.", loading: loading, className: className, maxHeight: maxHeight, showScrollIndicators: showScrollIndicators, virtualizeThreshold: 100, label: label, required: required, id: id, info: info, error: error }));
251
+ }
252
+ function CountryCombobox(_a) {
253
+ var _b = _a.countries, countries = _b === void 0 ? [] : _b, value = _a.value, onValueChange = _a.onValueChange, onSearchChange = _a.onSearchChange, _c = _a.loading, loading = _c === void 0 ? false : _c, _d = _a.placeholder, placeholder = _d === void 0 ? "Select country..." : _d, className = _a.className, _e = _a.maxHeight, maxHeight = _e === void 0 ? 280 : _e, _f = _a.showScrollIndicators, showScrollIndicators = _f === void 0 ? true : _f, label = _a.label, _g = _a.required, required = _g === void 0 ? false : _g, id = _a.id, info = _a.info, error = _a.error;
254
+ // Default countries if none provided or if provided list is empty
255
+ var defaultCountries = [
256
+ { name: "Afghanistan", code: "AF" },
257
+ { name: "Albania", code: "AL" },
258
+ { name: "Algeria", code: "DZ" },
259
+ { name: "Argentina", code: "AR" },
260
+ { name: "Australia", code: "AU" },
261
+ { name: "Austria", code: "AT" },
262
+ { name: "Bangladesh", code: "BD" },
263
+ { name: "Belgium", code: "BE" },
264
+ { name: "Brazil", code: "BR" },
265
+ { name: "Canada", code: "CA" },
266
+ { name: "China", code: "CN" },
267
+ { name: "Denmark", code: "DK" },
268
+ { name: "Egypt", code: "EG" },
269
+ { name: "Finland", code: "FI" },
270
+ { name: "France", code: "FR" },
271
+ { name: "Germany", code: "DE" },
272
+ { name: "Greece", code: "GR" },
273
+ { name: "India", code: "IN" },
274
+ { name: "Indonesia", code: "ID" },
275
+ { name: "Iran", code: "IR" },
276
+ { name: "Iraq", code: "IQ" },
277
+ { name: "Ireland", code: "IE" },
278
+ { name: "Israel", code: "IL" },
279
+ { name: "Italy", code: "IT" },
280
+ { name: "Japan", code: "JP" },
281
+ { name: "Jordan", code: "JO" },
282
+ { name: "Kenya", code: "KE" },
283
+ { name: "Malaysia", code: "MY" },
284
+ { name: "Mexico", code: "MX" },
285
+ { name: "Netherlands", code: "NL" },
286
+ { name: "New Zealand", code: "NZ" },
287
+ { name: "Nigeria", code: "NG" },
288
+ { name: "Norway", code: "NO" },
289
+ { name: "Pakistan", code: "PK" },
290
+ { name: "Philippines", code: "PH" },
291
+ { name: "Poland", code: "PL" },
292
+ { name: "Portugal", code: "PT" },
293
+ { name: "Russia", code: "RU" },
294
+ { name: "Saudi Arabia", code: "SA" },
295
+ { name: "Singapore", code: "SG" },
296
+ { name: "South Africa", code: "ZA" },
297
+ { name: "South Korea", code: "KR" },
298
+ { name: "Spain", code: "ES" },
299
+ { name: "Sweden", code: "SE" },
300
+ { name: "Switzerland", code: "CH" },
301
+ { name: "Thailand", code: "TH" },
302
+ { name: "Turkey", code: "TR" },
303
+ { name: "Ukraine", code: "UA" },
304
+ { name: "United Arab Emirates", code: "AE" },
305
+ { name: "United Kingdom", code: "GB" },
306
+ { name: "United States", code: "US" },
307
+ { name: "Vietnam", code: "VN" },
308
+ ];
309
+ var countryList = countries.length > 0 ? countries : defaultCountries;
310
+ var options = countryList.map(function (country) { return ({
311
+ value: country.name,
312
+ label: country.name,
313
+ }); });
314
+ return (react_1.default.createElement(Combobox, { options: options, value: value, onValueChange: onValueChange, onSearchChange: onSearchChange, placeholder: placeholder, searchPlaceholder: "Search countries...", emptyText: "No countries found.", loading: loading, className: className, maxHeight: maxHeight, showScrollIndicators: showScrollIndicators, virtualizeThreshold: 30, label: label, required: required, id: id, info: info, error: error }));
315
+ }
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { Command as CommandPrimitive } from "cmdk";
3
+ import { Dialog } from "@/components/ui/dialog";
4
+ declare function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>): React.JSX.Element;
5
+ declare function CommandDialog({ title, description, children, className, showCloseButton, ...props }: React.ComponentProps<typeof Dialog> & {
6
+ title?: string;
7
+ description?: string;
8
+ className?: string;
9
+ showCloseButton?: boolean;
10
+ }): React.JSX.Element;
11
+ declare function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>): React.JSX.Element;
12
+ declare function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>): React.JSX.Element;
13
+ declare function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element;
14
+ declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>): React.JSX.Element;
15
+ declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>): React.JSX.Element;
16
+ declare function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>): React.JSX.Element;
17
+ declare function CommandShortcut({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
18
+ export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator, };