react-core-ts 1.3.79 → 1.4.0

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/docs/App.tsx CHANGED
@@ -151,6 +151,7 @@ export default function App() {
151
151
  singleSelect={true}
152
152
  expandable={true}
153
153
  isTreeDropdown={true}
154
+ filterCondition={{ filterKey: 'id', filterValue: 22 }}
154
155
  descId="id"
155
156
  data={treeDropData}
156
157
  paginationEnabled={false}
package/docs/store.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export const treeDropData = [
2
2
  {
3
- name: 'Port A - This is the main port in the northern region with significant traffic and operations',
3
+ name: 'Port 22 - This is the main port in the northern region with significant traffic and operations',
4
4
  id: 22,
5
5
  parentId: null,
6
6
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-core-ts",
3
- "version": "1.3.79",
3
+ "version": "1.4.0",
4
4
  "description": "React Components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -72,6 +72,7 @@ const AutoCompleteWithTreeStructure = forwardRef<
72
72
  hasDisableSelection,
73
73
  inputType = 'text',
74
74
  onFocusTreeDropdown,
75
+ filterCondition,
75
76
  },
76
77
  ref
77
78
  ) => {
@@ -470,18 +471,35 @@ const AutoCompleteWithTreeStructure = forwardRef<
470
471
 
471
472
  const searchRecursive = (port: any) => {
472
473
  if (port[desc].toLowerCase().includes(lowerQuery)) {
473
- result.push({
474
- [descId]: port[descId],
475
- [desc]: port[desc],
476
- parentId: port.parentId,
477
- });
474
+ if (
475
+ filterCondition &&
476
+ filterCondition.filterKey &&
477
+ filterCondition.filterValue
478
+ ) {
479
+ result.push({
480
+ [descId]: port[descId],
481
+ [desc]: port[desc],
482
+ parentId: port.parentId,
483
+ [filterCondition?.filterKey]: port[filterCondition.filterKey],
484
+ });
485
+ } else {
486
+ result.push({
487
+ [descId]: port[descId],
488
+ [desc]: port[desc],
489
+ parentId: port.parentId,
490
+ });
491
+ }
478
492
  }
479
493
  port.children?.forEach(searchRecursive);
480
494
  };
481
495
 
482
- dropDownData.forEach(searchRecursive);
483
- result;
484
- setFilteredData(result);
496
+ // Default behavior (filter entire array)
497
+ dropDownData?.forEach(searchRecursive);
498
+
499
+ const final = result.filter((item) => {
500
+ return item[filterCondition?.filterKey] === filterCondition.filterValue;
501
+ });
502
+ setFilteredData(final);
485
503
  };
486
504
 
487
505
  const handleSuggestionClick = useCallback((suggestion: ValueProps) => {
@@ -73,6 +73,10 @@ export interface AutoSuggestionInputProps {
73
73
  e: React.FocusEvent<HTMLTextAreaElement, Element>
74
74
  ) => void;
75
75
  inputType?: 'text' | 'textarea';
76
+ filterCondition?: {
77
+ filterKey?: any;
78
+ filterValue?: any;
79
+ };
76
80
  }
77
81
  export interface IconsProps {
78
82
  name: any;