@appcorp/shadcn 1.1.96 → 1.1.98

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.
@@ -137,11 +137,6 @@ function EnhancedCombobox(_a) {
137
137
  var scrollContainerRef = (0, react_1.useRef)(null);
138
138
  var selectedOption = options.find(function (option) { return option.value === value; });
139
139
  var shouldVirtualize = options.length > virtualizeThreshold;
140
- console.log("EnhancedCombobox render:", {
141
- options: options,
142
- selectedOption: selectedOption,
143
- value: value,
144
- });
145
140
  // Filter options based on search - always handle filtering at this level for virtualization
146
141
  var filteredOptions = react_1.default.useMemo(function () {
147
142
  if (!searchValue) {
@@ -15,8 +15,12 @@ interface UseEnhancedComboboxProps {
15
15
  searchEndpoint: string;
16
16
  searchPlaceholder?: string;
17
17
  value: string;
18
+ formatSearchResult?: (item: Record<string, unknown>) => {
19
+ label: string;
20
+ value: string;
21
+ };
18
22
  }
19
- export declare const useEnhancedCombobox: ({ emptyText, error, id, info, label, onValueChange, options, placeholder, required, searchEndpoint, searchPlaceholder, value, }: UseEnhancedComboboxProps) => {
23
+ export declare const useEnhancedCombobox: ({ emptyText, error, formatSearchResult, id, info, label, onValueChange, options, placeholder, required, searchEndpoint, searchPlaceholder, value, }: UseEnhancedComboboxProps) => {
20
24
  enhancedComboboxElement: React.JSX.Element;
21
25
  };
22
26
  export {};
@@ -76,7 +76,7 @@ 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, onValueChange = _a.onValueChange, options = _a.options, placeholder = _a.placeholder, required = _a.required, searchEndpoint = _a.searchEndpoint, searchPlaceholder = _a.searchPlaceholder, value = _a.value;
79
+ var emptyText = _a.emptyText, error = _a.error, formatSearchResult = _a.formatSearchResult, 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
80
  var _b = (0, react_1.useState)(""), searchQuery = _b[0], setSearchQuery = _b[1];
81
81
  var _c = (0, react_1.useState)([]), searchOptions = _c[0], setSearchOptions = _c[1];
82
82
  var _d = (0, react_1.useState)(false), loading = _d[0], setLoading = _d[1];
@@ -89,7 +89,7 @@ var useEnhancedCombobox = function (_a) {
89
89
  }
90
90
  setLoading(true);
91
91
  (function () { return __awaiter(void 0, void 0, void 0, function () {
92
- var data, error_1;
92
+ var data, formatter, error_1;
93
93
  return __generator(this, function (_a) {
94
94
  switch (_a.label) {
95
95
  case 0:
@@ -101,7 +101,15 @@ var useEnhancedCombobox = function (_a) {
101
101
  })];
102
102
  case 1:
103
103
  data = (_a.sent()).data;
104
- setSearchOptions(data.items || []);
104
+ formatter = formatSearchResult ||
105
+ (function (item) {
106
+ var _a, _b;
107
+ return ({
108
+ label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
109
+ value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
110
+ });
111
+ });
112
+ setSearchOptions((data.items || []).map(formatter));
105
113
  return [3 /*break*/, 4];
106
114
  case 2:
107
115
  error_1 = _a.sent();
@@ -115,13 +123,9 @@ var useEnhancedCombobox = function (_a) {
115
123
  }
116
124
  });
117
125
  }); })();
118
- }, [debouncedSearchQuery, searchEndpoint]);
126
+ }, [debouncedSearchQuery, formatSearchResult, searchEndpoint]);
119
127
  var mappedOptions = (0, react_1.useMemo)(function () {
120
- var opts = searchOptions.length > 0 ? searchOptions : options;
121
- return ((opts === null || opts === void 0 ? void 0 : opts.map(function (category) { return ({
122
- label: category.label,
123
- value: category.value,
124
- }); })) || []);
128
+ return searchOptions.length > 0 ? searchOptions : options;
125
129
  }, [searchOptions, options]);
126
130
  var handleSearchChange = (0, react_1.useCallback)(function (query) {
127
131
  setSearchQuery(query);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/shadcn",
3
- "version": "1.1.96",
3
+ "version": "1.1.98",
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",