@turtleclub/ui 0.7.0-beta.3 → 0.7.0-beta.4
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/.turbo/turbo-build.log +119 -119
- package/CHANGELOG.md +4 -0
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3076 -3068
- package/dist/index.js.map +1 -1
- package/dist/types/components/ui/combobox.d.ts +10 -0
- package/dist/types/components/ui/combobox.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/ui/combobox.tsx +35 -6
|
@@ -77,6 +77,11 @@ interface ComboboxProps<T = string> extends Omit<React.ButtonHTMLAttributes<HTML
|
|
|
77
77
|
* Receives an array of the new selected values.
|
|
78
78
|
*/
|
|
79
79
|
onValueChange: (value: T) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Custom renderer for the selected value displayed in the input.
|
|
82
|
+
* @param option The currently selected option object.
|
|
83
|
+
*/
|
|
84
|
+
renderValue?: (option: ComboboxOption<T>) => React.ReactNode;
|
|
80
85
|
/** The default selected values when the component mounts. */
|
|
81
86
|
defaultValue?: T;
|
|
82
87
|
/**
|
|
@@ -111,6 +116,11 @@ interface ComboboxProps<T = string> extends Omit<React.ButtonHTMLAttributes<HTML
|
|
|
111
116
|
* Optional, defaults to true.
|
|
112
117
|
*/
|
|
113
118
|
searchable?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* If true, searching will also check the 'value' field in addition to 'label'.
|
|
121
|
+
* Optional, defaults to false.
|
|
122
|
+
*/
|
|
123
|
+
searchByValue?: boolean;
|
|
114
124
|
/**
|
|
115
125
|
* Custom empty state message when no options match search.
|
|
116
126
|
* Optional, defaults to "No results found."
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoB/B;;;;;;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E,OAAO,CAAC;SACvB,CAAC;QACF,mDAAmD;QACnD,OAAO,CAAC,EAAE;YACR,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,SAAS,CAAC,EAAE,OAAO,CAAC;YACpB,WAAW,CAAC,EAAE,OAAO,CAAC;SACvB,CAAC;KACH,CAAC;IAEN;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAueD,QAAA,MAAM,kBAAkB,EAA0C,CAAC,CAAC,GAAG,MAAM,EAC3E,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;CAAE,KACvD,KAAK,CAAC,YAAY,CAAC;AAKxB,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turtleclub/ui",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.4",
|
|
4
4
|
"description": "shadcn/ui and custom Turtle UI components library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"vite": "^7.1.6",
|
|
85
85
|
"vite-plugin-dts": "^4.5.4"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "64ab8549fe80c0901dc1fcb71289a183f957ae03"
|
|
88
88
|
}
|
|
@@ -97,12 +97,19 @@ interface ComboboxProps<T = string>
|
|
|
97
97
|
* An array of option objects or groups to be displayed in the multi-select component.
|
|
98
98
|
*/
|
|
99
99
|
options: ComboboxOption<T>[];
|
|
100
|
+
|
|
100
101
|
/**
|
|
101
102
|
* Callback function triggered when the selected values change.
|
|
102
103
|
* Receives an array of the new selected values.
|
|
103
104
|
*/
|
|
104
105
|
onValueChange: (value: T) => void;
|
|
105
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Custom renderer for the selected value displayed in the input.
|
|
109
|
+
* @param option The currently selected option object.
|
|
110
|
+
*/
|
|
111
|
+
renderValue?: (option: ComboboxOption<T>) => React.ReactNode;
|
|
112
|
+
|
|
106
113
|
/** The default selected values when the component mounts. */
|
|
107
114
|
defaultValue?: T;
|
|
108
115
|
|
|
@@ -144,6 +151,12 @@ interface ComboboxProps<T = string>
|
|
|
144
151
|
*/
|
|
145
152
|
searchable?: boolean;
|
|
146
153
|
|
|
154
|
+
/**
|
|
155
|
+
* If true, searching will also check the 'value' field in addition to 'label'.
|
|
156
|
+
* Optional, defaults to false.
|
|
157
|
+
*/
|
|
158
|
+
searchByValue?: boolean;
|
|
159
|
+
|
|
147
160
|
/**
|
|
148
161
|
* Custom empty state message when no options match search.
|
|
149
162
|
* Optional, defaults to "No results found."
|
|
@@ -258,6 +271,8 @@ const ComboboxComponent = <T = string,>(
|
|
|
258
271
|
minWidth,
|
|
259
272
|
maxWidth,
|
|
260
273
|
closeOnSelect = false,
|
|
274
|
+
renderValue,
|
|
275
|
+
searchByValue = false,
|
|
261
276
|
...restProps
|
|
262
277
|
} = props;
|
|
263
278
|
|
|
@@ -423,12 +438,21 @@ const ComboboxComponent = <T = string,>(
|
|
|
423
438
|
if (!searchable || !searchValue) return options;
|
|
424
439
|
if (options.length === 0) return [];
|
|
425
440
|
|
|
426
|
-
return options.filter(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
441
|
+
return options.filter((option) => {
|
|
442
|
+
const labelMatch = option.label
|
|
443
|
+
.toLowerCase()
|
|
444
|
+
.includes(searchValue.toLowerCase());
|
|
445
|
+
if (!searchByValue) return labelMatch;
|
|
446
|
+
|
|
447
|
+
const val = option.value;
|
|
448
|
+
const valueMatch =
|
|
449
|
+
typeof val === "string" || typeof val === "number"
|
|
450
|
+
? String(val).toLowerCase().includes(searchValue.toLowerCase())
|
|
451
|
+
: false;
|
|
452
|
+
|
|
453
|
+
return labelMatch || valueMatch;
|
|
454
|
+
});
|
|
455
|
+
}, [options, searchValue, searchable, searchByValue]);
|
|
432
456
|
|
|
433
457
|
// const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
434
458
|
// if (event.key === "Enter") {
|
|
@@ -555,6 +579,11 @@ const ComboboxComponent = <T = string,>(
|
|
|
555
579
|
const selectedOption = options.find(
|
|
556
580
|
(op) => op.value === selectedValue,
|
|
557
581
|
);
|
|
582
|
+
|
|
583
|
+
if (renderValue && selectedOption) {
|
|
584
|
+
return renderValue(selectedOption);
|
|
585
|
+
}
|
|
586
|
+
|
|
558
587
|
return (
|
|
559
588
|
<>
|
|
560
589
|
{selectedOption?.icon && (
|