@appcorp/shadcn 1.1.93 → 1.1.95
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.
|
@@ -48,8 +48,6 @@ interface EnhancedComboboxProps {
|
|
|
48
48
|
info?: string;
|
|
49
49
|
/** Optional error text displayed below the component (error state). */
|
|
50
50
|
error?: string;
|
|
51
|
-
/** Optional key used for lookup within the original options object (defaults to 'id'). */
|
|
52
|
-
lookupKey?: string;
|
|
53
51
|
/** `data-testid` for the trigger button (e.g. `my-combobox-trigger`). */
|
|
54
52
|
testIdTrigger?: string;
|
|
55
53
|
/** `data-testid` for the search input inside the popover. */
|
|
@@ -71,7 +69,7 @@ interface EnhancedComboboxProps {
|
|
|
71
69
|
/** `data-testid` for the scroll-down button (when scroll indicators enabled). */
|
|
72
70
|
testIdScrollDown?: string;
|
|
73
71
|
}
|
|
74
|
-
export declare function EnhancedCombobox({ className, disabled, emptyText, error, id, info, label, loading,
|
|
72
|
+
export declare function EnhancedCombobox({ className, disabled, emptyText, error, id, info, label, loading, maxHeight, onSearchChange, onValueChange, options, placeholder, required, searchPlaceholder, showScrollIndicators, value, virtualizeThreshold, testIdTrigger, testIdSearchInput, testIdPopoverContent, testIdEmpty, testIdList, testIdOptionPrefix, testIdScrollUp, testIdScrollDown, }: EnhancedComboboxProps): React.JSX.Element;
|
|
75
73
|
interface CompanyComboboxProps {
|
|
76
74
|
companies: Array<{
|
|
77
75
|
id?: string;
|
|
@@ -129,17 +129,18 @@ function VirtualizedList(_a) {
|
|
|
129
129
|
bottomSpacer > 0 && react_1.default.createElement("div", { style: { height: bottomSpacer } })));
|
|
130
130
|
}
|
|
131
131
|
function EnhancedCombobox(_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,
|
|
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, testIdTrigger = _a.testIdTrigger, testIdSearchInput = _a.testIdSearchInput, testIdPopoverContent = _a.testIdPopoverContent, testIdEmpty = _a.testIdEmpty, testIdList = _a.testIdList, testIdOptionPrefix = _a.testIdOptionPrefix, testIdScrollUp = _a.testIdScrollUp, testIdScrollDown = _a.testIdScrollDown;
|
|
133
133
|
var _m = (0, react_1.useState)(false), open = _m[0], setOpen = _m[1];
|
|
134
134
|
var _o = (0, react_1.useState)(""), searchValue = _o[0], setSearchValue = _o[1];
|
|
135
135
|
var _p = (0, react_1.useState)(false), canScrollUp = _p[0], setCanScrollUp = _p[1];
|
|
136
136
|
var _q = (0, react_1.useState)(false), canScrollDown = _q[0], setCanScrollDown = _q[1];
|
|
137
137
|
var scrollContainerRef = (0, react_1.useRef)(null);
|
|
138
|
-
var selectedOption = options.find(function (option) {
|
|
139
|
-
return option.value === value ||
|
|
140
|
-
option[lookupKey] === value;
|
|
141
|
-
});
|
|
138
|
+
var selectedOption = options.find(function (option) { return option.value === value; });
|
|
142
139
|
var shouldVirtualize = options.length > virtualizeThreshold;
|
|
140
|
+
console.log("EnhancedCombobox render:", {
|
|
141
|
+
options: options,
|
|
142
|
+
selectedOption: selectedOption,
|
|
143
|
+
});
|
|
143
144
|
// Filter options based on search - always handle filtering at this level for virtualization
|
|
144
145
|
var filteredOptions = react_1.default.useMemo(function () {
|
|
145
146
|
if (!searchValue) {
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
interface UseEnhancedComboboxProps
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}> {
|
|
2
|
+
interface UseEnhancedComboboxProps {
|
|
6
3
|
emptyText?: string;
|
|
7
4
|
error?: string;
|
|
8
5
|
id: string;
|
|
9
6
|
info: string;
|
|
10
7
|
label: string;
|
|
11
|
-
lookupKey?: keyof T;
|
|
12
8
|
onValueChange: (value: string) => void;
|
|
13
|
-
options:
|
|
9
|
+
options: {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
14
13
|
placeholder: string;
|
|
15
14
|
required?: boolean;
|
|
16
15
|
searchEndpoint: string;
|
|
17
16
|
searchPlaceholder?: string;
|
|
18
17
|
value: string;
|
|
19
18
|
}
|
|
20
|
-
export declare const useEnhancedCombobox:
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
}>({ emptyText, error, id, info, label, lookupKey, onValueChange, options, placeholder, required, searchEndpoint, searchPlaceholder, value, }: UseEnhancedComboboxProps<T>) => {
|
|
19
|
+
export declare const useEnhancedCombobox: ({ emptyText, error, id, info, label, onValueChange, options, placeholder, required, searchEndpoint, searchPlaceholder, value, }: UseEnhancedComboboxProps) => {
|
|
24
20
|
enhancedComboboxElement: React.JSX.Element;
|
|
25
21
|
};
|
|
26
22
|
export {};
|
|
@@ -76,10 +76,10 @@ var api_methods_1 = require("@react-pakistan/util-functions/constants/api-method
|
|
|
76
76
|
var use_debounce_1 = require("@react-pakistan/util-functions/hooks/use-debounce");
|
|
77
77
|
var enhanced_combobox_1 = require("../components/enhanced-combobox");
|
|
78
78
|
var useEnhancedCombobox = function (_a) {
|
|
79
|
-
var emptyText = _a.emptyText, error = _a.error, id = _a.id, info = _a.info, label = _a.label,
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
79
|
+
var emptyText = _a.emptyText, error = _a.error, id = _a.id, info = _a.info, label = _a.label, onValueChange = _a.onValueChange, options = _a.options, placeholder = _a.placeholder, required = _a.required, searchEndpoint = _a.searchEndpoint, searchPlaceholder = _a.searchPlaceholder, value = _a.value;
|
|
80
|
+
var _b = (0, react_1.useState)(""), searchQuery = _b[0], setSearchQuery = _b[1];
|
|
81
|
+
var _c = (0, react_1.useState)([]), searchOptions = _c[0], setSearchOptions = _c[1];
|
|
82
|
+
var _d = (0, react_1.useState)(false), loading = _d[0], setLoading = _d[1];
|
|
83
83
|
var debouncedSearchQuery = (0, use_debounce_1.useDebounce)(searchQuery, 800);
|
|
84
84
|
(0, react_1.useEffect)(function () {
|
|
85
85
|
if (!debouncedSearchQuery) {
|
|
@@ -119,14 +119,14 @@ var useEnhancedCombobox = function (_a) {
|
|
|
119
119
|
var mappedOptions = (0, react_1.useMemo)(function () {
|
|
120
120
|
var opts = searchOptions.length > 0 ? searchOptions : options;
|
|
121
121
|
return ((opts === null || opts === void 0 ? void 0 : opts.map(function (category) { return ({
|
|
122
|
-
label: category.
|
|
123
|
-
value:
|
|
122
|
+
label: category.label,
|
|
123
|
+
value: category.value,
|
|
124
124
|
}); })) || []);
|
|
125
|
-
}, [searchOptions, options
|
|
125
|
+
}, [searchOptions, options]);
|
|
126
126
|
var handleSearchChange = (0, react_1.useCallback)(function (query) {
|
|
127
127
|
setSearchQuery(query);
|
|
128
128
|
}, []);
|
|
129
|
-
var enhancedComboboxElement = (0, react_1.useMemo)(function () { return (react_1.default.createElement(enhanced_combobox_1.EnhancedCombobox, { emptyText: emptyText, error: error, id: id, info: info, label: label, loading: loading,
|
|
129
|
+
var enhancedComboboxElement = (0, react_1.useMemo)(function () { return (react_1.default.createElement(enhanced_combobox_1.EnhancedCombobox, { emptyText: emptyText, error: error, id: id, info: info, label: label, loading: loading, onSearchChange: handleSearchChange, onValueChange: onValueChange, options: mappedOptions, placeholder: placeholder, required: required, searchPlaceholder: searchPlaceholder, value: value })); }, [
|
|
130
130
|
emptyText,
|
|
131
131
|
error,
|
|
132
132
|
handleSearchChange,
|
|
@@ -134,7 +134,6 @@ var useEnhancedCombobox = function (_a) {
|
|
|
134
134
|
info,
|
|
135
135
|
label,
|
|
136
136
|
loading,
|
|
137
|
-
lookupKey,
|
|
138
137
|
mappedOptions,
|
|
139
138
|
onValueChange,
|
|
140
139
|
placeholder,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appcorp/shadcn",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.95",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:next": "next build",
|
|
6
6
|
"build:storybook": "mv ../.pnp.cjs ../.pnp.cjs.bak 2>/dev/null || true && storybook build -c .storybook -o .out && mv ../.pnp.cjs.bak ../.pnp.cjs 2>/dev/null || true",
|