@chayns-components/core 5.5.40 → 5.5.42
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/AGENTS.md +6 -6
- package/lib/cjs/components/search-box/SearchBox.js +10 -9
- package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
- package/lib/cjs/components/truncation/Truncation.js +16 -4
- package/lib/cjs/components/truncation/Truncation.js.map +1 -1
- package/lib/cjs/components/truncation/Truncation.test.js +3 -0
- package/lib/cjs/components/truncation/Truncation.test.js.map +1 -1
- package/lib/cjs/utils/searchBox.test.js +20 -0
- package/lib/cjs/utils/searchBox.test.js.map +1 -1
- package/lib/esm/components/search-box/SearchBox.js +9 -9
- package/lib/esm/components/search-box/SearchBox.js.map +1 -1
- package/lib/esm/components/truncation/Truncation.js +16 -4
- package/lib/esm/components/truncation/Truncation.js.map +1 -1
- package/lib/esm/components/truncation/Truncation.test.js +3 -0
- package/lib/esm/components/truncation/Truncation.test.js.map +1 -1
- package/lib/esm/utils/searchBox.test.js +20 -0
- package/lib/esm/utils/searchBox.test.js.map +1 -1
- package/lib/types/components/search-box/SearchBox.d.ts +10 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchBox.test.js","names":["describe","expect","it","searchList","items","id","text","result","customSortFunction","a","b","localeCompare","searchString","map","toEqual"],"sources":["../../../src/utils/searchBox.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport type { ISearchBoxItem } from '../types/searchBox';\nimport { searchList } from './searchBox';\n\nconst items: ISearchBoxItem[] = [\n { id: '2', text: 'Zweite' },\n { id: '1', text: 'Erste' },\n];\n\ndescribe('searchList', () => {\n it('uses the custom sort function instead of the default sort', () => {\n const result = searchList({\n customSortFunction: (a, b) => b.id.localeCompare(a.id),\n items,\n searchString: '',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['2', '1']);\n });\n\n it('still filters before applying the custom sort function', () => {\n const result = searchList({\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'e',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['1', '2']);\n });\n});\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,UAAU,QAAQ,aAAa;AAExC,MAAMC,KAAuB,GAAG,CAC5B;EAAEC,EAAE,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAS,CAAC,EAC3B;EAAED,EAAE,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAQ,CAAC,CAC7B;
|
|
1
|
+
{"version":3,"file":"searchBox.test.js","names":["describe","expect","it","filterSearchBoxItems","searchList","items","id","text","result","customSortFunction","a","b","localeCompare","searchString","map","toEqual","values","customFilter","value","push","shouldUseCustomFilterOnly"],"sources":["../../../src/utils/searchBox.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport type { ISearchBoxItem } from '../types/searchBox';\nimport { filterSearchBoxItems } from '../components/search-box/SearchBox';\nimport { searchList } from './searchBox';\n\nconst items: ISearchBoxItem[] = [\n { id: '2', text: 'Zweite' },\n { id: '1', text: 'Erste' },\n];\n\ndescribe('searchList', () => {\n it('uses the custom sort function instead of the default sort', () => {\n const result = searchList({\n customSortFunction: (a, b) => b.id.localeCompare(a.id),\n items,\n searchString: '',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['2', '1']);\n });\n\n it('still filters before applying the custom sort function', () => {\n const result = searchList({\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'e',\n });\n\n expect(result.map(({ id }) => id)).toEqual(['1', '2']);\n });\n\n it('uses only the custom filter when shouldUseCustomFilterOnly is enabled', () => {\n const values: string[] = [];\n const result = filterSearchBoxItems({\n customFilter: ({ id }, value) => {\n values.push(value);\n return id === '2';\n },\n customSortFunction: (a, b) => a.id.localeCompare(b.id),\n items,\n searchString: 'does-not-match',\n shouldUseCustomFilterOnly: true,\n });\n\n expect(result.map(({ id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Fb,EAAE,CAAC,uEAAuE,EAAE,MAAM;IAC9E,MAAMc,MAAgB,GAAG,EAAE;IAC3B,MAAMR,MAAM,GAAGL,oBAAoB,CAAC;MAChCc,YAAY,EAAEA,CAAC;QAAEX;MAAG,CAAC,EAAEY,KAAK,KAAK;QAC7BF,MAAM,CAACG,IAAI,CAACD,KAAK,CAAC;QAClB,OAAOZ,EAAE,KAAK,GAAG;MACrB,CAAC;MACDG,kBAAkB,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACJ,EAAE,CAACM,aAAa,CAACD,CAAC,CAACL,EAAE,CAAC;MACtDD,KAAK;MACLQ,YAAY,EAAE,gBAAgB;MAC9BO,yBAAyB,EAAE;IAC/B,CAAC,CAAC;IAEFnB,MAAM,CAACO,MAAM,CAACM,GAAG,CAAC,CAAC;MAAER;IAAG,CAAC,KAAKA,EAAE,CAAC,CAAC,CAACS,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;IACjDd,MAAM,CAACe,MAAM,CAAC,CAACD,OAAO,CAAC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;EAChE,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -14,6 +14,13 @@ export interface TagInputSettings {
|
|
|
14
14
|
shouldAllowMultiple?: TagInputProps['shouldAllowMultiple'];
|
|
15
15
|
tags?: TagInputProps['tags'];
|
|
16
16
|
}
|
|
17
|
+
export declare const filterSearchBoxItems: ({ customFilter, customSortFunction, items, searchString, shouldUseCustomFilterOnly, }: {
|
|
18
|
+
customFilter?: (item: ISearchBoxItem, value: string) => boolean;
|
|
19
|
+
customSortFunction?: SearchBoxSortFunction;
|
|
20
|
+
items: ISearchBoxItem[];
|
|
21
|
+
searchString: string;
|
|
22
|
+
shouldUseCustomFilterOnly?: boolean;
|
|
23
|
+
}) => ISearchBoxItem[];
|
|
17
24
|
export type SearchBoxProps = {
|
|
18
25
|
/**
|
|
19
26
|
* The element where the content of the `ComboBox` should be rendered via React Portal.
|
|
@@ -21,8 +28,10 @@ export type SearchBoxProps = {
|
|
|
21
28
|
container?: Element;
|
|
22
29
|
/**
|
|
23
30
|
* An optional callback function to filter the elements to be displayed
|
|
31
|
+
* @param item The item to filter.
|
|
32
|
+
* @param value The current input value.
|
|
24
33
|
*/
|
|
25
|
-
customFilter?: (item: ISearchBoxItem) => boolean;
|
|
34
|
+
customFilter?: (item: ISearchBoxItem, value: string) => boolean;
|
|
26
35
|
/**
|
|
27
36
|
* An optional callback function to sort the filtered elements to be displayed
|
|
28
37
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.42",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "c319b7cea48a7f51172e657f756aa44580e81784"
|
|
97
97
|
}
|