frame.select 1.2.3 → 1.2.5
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/dist/App.d.ts.map +1 -1
- package/dist/App.js +21 -20
- package/dist/components/BrandList.d.ts.map +1 -1
- package/dist/components/BrandList.js +2 -1
- package/dist/components/FrameList.d.ts +6 -0
- package/dist/components/FrameList.d.ts.map +1 -1
- package/dist/components/FrameList.js +27 -48
- package/dist/components/ItemFilter.js +4 -4
- package/dist/components/ItemList.d.ts +2 -0
- package/dist/components/ItemList.d.ts.map +1 -1
- package/dist/components/ItemList.js +66 -89
- package/dist/components/itemTypes.d.ts +2 -2
- package/dist/components/itemTypes.d.ts.map +1 -1
- package/dist/components/types.d.ts +4 -0
- package/dist/components/types.d.ts.map +1 -1
- package/package.json +13 -15
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAC;AAEnB,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,iBAAS,GAAG,sBAkNX;AAED,eAAe,GAAG,CAAC"}
|
package/dist/App.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createColumnHelper } from '@tanstack/react-table';
|
|
2
1
|
import './App.css';
|
|
3
2
|
import { useState } from 'react';
|
|
4
3
|
import React from 'react';
|
|
@@ -6,8 +5,6 @@ import { BrandList } from './components/BrandList';
|
|
|
6
5
|
import { FrameList } from './components/FrameList';
|
|
7
6
|
function App() {
|
|
8
7
|
const [brand, setBrand] = useState('');
|
|
9
|
-
const [filterWidth, setFilterWidth] = useState('');
|
|
10
|
-
const [filterHeight, setFilterHeight] = useState('');
|
|
11
8
|
const brands = [
|
|
12
9
|
{
|
|
13
10
|
name: 'Adidas',
|
|
@@ -80,7 +77,7 @@ function App() {
|
|
|
80
77
|
'AFF000000000000000TMA4750190010',
|
|
81
78
|
'AFF000000000000000TMA4750190011',
|
|
82
79
|
'AFF000000000000000TMA4750190012',
|
|
83
|
-
'
|
|
80
|
+
'ADI000000000000000TXDDC50190012',
|
|
84
81
|
];
|
|
85
82
|
const frameNike = [
|
|
86
83
|
'AFF000000000000000TMA4750190000',
|
|
@@ -140,19 +137,19 @@ function App() {
|
|
|
140
137
|
rest: stripLeadingZeros(frame.substring(28, 33)),
|
|
141
138
|
}));
|
|
142
139
|
}
|
|
143
|
-
const brandColumnHelper = createColumnHelper();
|
|
144
|
-
const brandColumns = [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
];
|
|
151
|
-
const _extraBrandColumns = [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
];
|
|
140
|
+
// const brandColumnHelper = createColumnHelper<TBrandObj>();
|
|
141
|
+
// const brandColumns = [
|
|
142
|
+
// brandColumnHelper.accessor((row) => row.description ?? '', {
|
|
143
|
+
// header: 'description',
|
|
144
|
+
// size: 300,
|
|
145
|
+
// cell: (info) => <div>{info.getValue()}</div>,
|
|
146
|
+
// }),
|
|
147
|
+
// ];
|
|
148
|
+
// const _extraBrandColumns: TColumn<TBrandObj>[] = [
|
|
149
|
+
// {
|
|
150
|
+
// column: brandColumns[0],
|
|
151
|
+
// },
|
|
152
|
+
// ];
|
|
156
153
|
const onClickBrand = (cell) => {
|
|
157
154
|
const brand = brands.find((b) => b.name === cell.row.original.name);
|
|
158
155
|
if (brand) {
|
|
@@ -168,8 +165,12 @@ function App() {
|
|
|
168
165
|
React.createElement("h2", null,
|
|
169
166
|
"Frame List for ",
|
|
170
167
|
brand),
|
|
171
|
-
React.createElement(FrameList, { frameList: convertFrames(brand, frames), onClick: onClickFrame,
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
React.createElement(FrameList, { frameList: convertFrames(brand, frames), onClick: onClickFrame, slSize: 120, slFormat: (value) => {
|
|
169
|
+
return React.createElement("div", null, value);
|
|
170
|
+
}, bwSize: 160, bwFormat: (value) => {
|
|
171
|
+
return React.createElement("span", { style: { fontWeight: 'bold' } }, value);
|
|
172
|
+
}, formSize: 320, formFormat: (value) => {
|
|
173
|
+
return React.createElement("div", { style: { color: 'red' } }, value);
|
|
174
|
+
} })));
|
|
174
175
|
}
|
|
175
176
|
export default App;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrandList.d.ts","sourceRoot":"","sources":["../../src/components/BrandList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"BrandList.d.ts","sourceRoot":"","sources":["../../src/components/BrandList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,GAAG,CAAC,OAAO,CAkBd"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ItemList } from './ItemList';
|
|
3
3
|
export function BrandList(props) {
|
|
4
|
-
|
|
4
|
+
const extraBrandColumns = [];
|
|
5
|
+
return (React.createElement(ItemList, { itemList: props.brandList, onClick: props.onClick, renderItem: props.renderItem, extraColumns: props.extraColumns ? props.extraColumns : extraBrandColumns, style: props.style, backgroundColor: props.backgroundColor, scrollbarWidth: 50, height: 300, placeholder: "Brands", defaultHeader: "Brand", testId: "name" }));
|
|
5
6
|
}
|
|
@@ -7,6 +7,12 @@ export declare function FrameList(props: {
|
|
|
7
7
|
frameList: TFrameObj[];
|
|
8
8
|
onClick?: (cell: Cell<TFrameObj, unknown>, index: number) => void;
|
|
9
9
|
renderItem?: (item: string) => React.ReactNode;
|
|
10
|
+
slSize?: number;
|
|
11
|
+
slFormat?: (value: string) => React.ReactNode;
|
|
12
|
+
bwSize?: number;
|
|
13
|
+
bwFormat?: (value: string) => React.ReactNode;
|
|
14
|
+
formSize?: number;
|
|
15
|
+
formFormat?: (value: string) => React.ReactNode;
|
|
10
16
|
extraColumns?: TColumn<TFrameObj>[];
|
|
11
17
|
style?: React.CSSProperties;
|
|
12
18
|
}): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameList.d.ts","sourceRoot":"","sources":["../../src/components/FrameList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAsB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAY,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"FrameList.d.ts","sourceRoot":"","sources":["../../src/components/FrameList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAsB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAY,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKL,SAAS,EACV,MAAM,SAAS,CAAC;AAGjB,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAChD,YAAY,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,GAAG,CAAC,OAAO,CAkHd"}
|
|
@@ -29,58 +29,37 @@ export function FrameList(props) {
|
|
|
29
29
|
return filterMatches(item, scheibenFormKey, filter);
|
|
30
30
|
}
|
|
31
31
|
const frameColumnHelper = createColumnHelper();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}),
|
|
43
|
-
frameColumnHelper.accessor((row) => row[scheibenFormKey].toString(), {
|
|
44
|
-
header: scheibenFormKey,
|
|
45
|
-
size: 120,
|
|
46
|
-
cell: (info) => React.createElement("div", null, info.getValue()),
|
|
47
|
-
}),
|
|
48
|
-
];
|
|
49
|
-
const extraFrameColumns = [
|
|
50
|
-
{
|
|
51
|
-
column: frameColumns[0],
|
|
52
|
-
filter: {
|
|
53
|
-
property: scheibenLaengeKey,
|
|
54
|
-
filter: filterHeight,
|
|
55
|
-
setFilter: setFilterHeight,
|
|
56
|
-
filterMatches: filterHeightMatches,
|
|
57
|
-
placeholder: 'Scheibenlänge',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
column: frameColumns[1],
|
|
32
|
+
function createColumn(key, filterHook, filterMatches, placeholder, colSize = 120, colFormat) {
|
|
33
|
+
return {
|
|
34
|
+
column: frameColumnHelper.accessor((row) => row[key].toString(), {
|
|
35
|
+
header: key,
|
|
36
|
+
size: colSize,
|
|
37
|
+
cell: (info) => {
|
|
38
|
+
const value = info.getValue();
|
|
39
|
+
return colFormat ? colFormat(value) : React.createElement("div", null, value); // Handle undefined case
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
62
42
|
filter: {
|
|
63
|
-
property:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
placeholder: 'Brückenweite',
|
|
43
|
+
property: key,
|
|
44
|
+
filterHook: filterHook,
|
|
45
|
+
filterMatches,
|
|
46
|
+
placeholder,
|
|
68
47
|
},
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const scheibenLaenge = createColumn(scheibenLaengeKey, { value: filterHeight, setValue: setFilterHeight }, filterHeightMatches, 'Scheibenlänge', props.slSize, props.slFormat);
|
|
51
|
+
const brueckenWeite = createColumn(brueckenWeiteKey, { value: filterWidth, setValue: setFilterWidth }, filterWidthMatches, 'Brückenweite', props.bwSize, props.bwFormat);
|
|
52
|
+
const scheibenForm = createColumn(scheibenFormKey, { value: filterForm, setValue: setFilterForm }, filterFormMatches, 'Scheibenform', props.formSize, props.formFormat);
|
|
53
|
+
const extraFrameColumns = [
|
|
54
|
+
scheibenLaenge,
|
|
55
|
+
brueckenWeite,
|
|
56
|
+
scheibenForm,
|
|
80
57
|
];
|
|
81
|
-
return (React.createElement(ItemList, { itemList: props.frameList, onClick: props.onClick, renderItem: props.renderItem, extraColumns: props.extraColumns
|
|
58
|
+
return (React.createElement(ItemList, { itemList: props.frameList, onClick: props.onClick, renderItem: props.renderItem, extraColumns: props.extraColumns && props.extraColumns.length > 0
|
|
59
|
+
? props.extraColumns
|
|
60
|
+
: extraFrameColumns, style: props.style,
|
|
82
61
|
// backgroundColor="lightgreen"
|
|
83
62
|
// scrollbarWidth={100}
|
|
84
63
|
// height={400}
|
|
85
|
-
placeholder: "Modellnummer", defaultHeader: "Frame" }));
|
|
64
|
+
placeholder: "Modellnummer", defaultHeader: "Frame", testId: "frame" }));
|
|
86
65
|
}
|
|
@@ -26,14 +26,14 @@ import React from 'react';
|
|
|
26
26
|
*/
|
|
27
27
|
const ItemFilter = (props) => {
|
|
28
28
|
function handleInputChange(e) {
|
|
29
|
-
props.itemFilter.
|
|
29
|
+
props.itemFilter.filterHook.setValue(e.target.value);
|
|
30
30
|
}
|
|
31
31
|
function clearFilter() {
|
|
32
|
-
props.itemFilter.
|
|
32
|
+
props.itemFilter.filterHook.setValue('');
|
|
33
33
|
}
|
|
34
34
|
return (React.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
|
|
35
|
-
React.createElement("input", { id: props.id, "data-testid": `input.filter.${props.id}`, type: "text", placeholder: props.itemFilter.placeholder ?? 'Items', value: props.itemFilter.
|
|
36
|
-
props.itemFilter.
|
|
35
|
+
React.createElement("input", { id: props.id, "data-testid": `input.filter.${props.id}`, type: "text", placeholder: props.itemFilter.placeholder ?? 'Items', value: props.itemFilter.filterHook.value || '', onChange: handleInputChange, style: { width: '80%' } }),
|
|
36
|
+
props.itemFilter.filterHook.value !== '' ? (React.createElement(Button, { "data-testid": `${props.tableId}.button.clearFilter.${props.id}`, style: { minWidth: 'unset', padding: '1px' }, onClick: clearFilter },
|
|
37
37
|
React.createElement(CancelPresentationIcon, null))) : (React.createElement("div", null))));
|
|
38
38
|
};
|
|
39
39
|
export default ItemFilter;
|
|
@@ -10,8 +10,10 @@ export declare function ItemList<T extends TItem>(props: {
|
|
|
10
10
|
style?: React.CSSProperties;
|
|
11
11
|
backgroundColor?: string;
|
|
12
12
|
scrollbarWidth?: number;
|
|
13
|
+
mainColumnWidth?: number;
|
|
13
14
|
height?: number | string;
|
|
14
15
|
placeholder?: string;
|
|
15
16
|
defaultHeader?: string;
|
|
17
|
+
testId: string;
|
|
16
18
|
}): JSX.Element;
|
|
17
19
|
//# sourceMappingURL=ItemList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemList.d.ts","sourceRoot":"","sources":["../../src/components/ItemList.tsx"],"names":[],"mappings":"AAUA,OAAO,EAIL,IAAI,
|
|
1
|
+
{"version":3,"file":"ItemList.d.ts","sourceRoot":"","sources":["../../src/components/ItemList.tsx"],"names":[],"mappings":"AAUA,OAAO,EAIL,IAAI,EAML,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAe,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,GAAG,EAA6C,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE;IAC/C,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,GAAG,CAAC,OAAO,CAsZd"}
|
|
@@ -5,7 +5,7 @@ import { useMemo, useState, useCallback } from 'react';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
export function ItemList(props) {
|
|
7
7
|
'use no memo'; // For React Compiler compatibility with TanStack Table
|
|
8
|
-
const { itemList, backgroundColor = 'lightgrey', scrollbarWidth = 50, height = 300, placeholder = 'Items', defaultHeader = 'Name', } = props;
|
|
8
|
+
const { itemList, backgroundColor = 'lightgrey', scrollbarWidth = 50, mainColumnWidth = 160, height = 300, placeholder = 'Items', defaultHeader = 'Name', } = props;
|
|
9
9
|
const scrollbarStyles = {
|
|
10
10
|
'&::-webkit-scrollbar': {
|
|
11
11
|
width: `${scrollbarWidth}px`,
|
|
@@ -35,14 +35,13 @@ export function ItemList(props) {
|
|
|
35
35
|
}, []);
|
|
36
36
|
const itemFilter = useMemo(() => ({
|
|
37
37
|
property: 'name',
|
|
38
|
-
filter,
|
|
39
|
-
|
|
40
|
-
filterMatches,
|
|
38
|
+
filterHook: { value: filter, setValue: setFilter },
|
|
39
|
+
filterMatches: filterMatches,
|
|
41
40
|
placeholder,
|
|
42
41
|
}), [filter, filterMatches, placeholder]);
|
|
43
42
|
const serializedExtraColumns = useMemo(() => JSON.stringify(props.extraColumns), [props.extraColumns]);
|
|
44
43
|
const extraCols = useMemo(() => {
|
|
45
|
-
if (props.extraColumns) {
|
|
44
|
+
if (props.extraColumns && props.extraColumns.length > 0) {
|
|
46
45
|
return props.extraColumns.filter((col) => col !== undefined);
|
|
47
46
|
}
|
|
48
47
|
else {
|
|
@@ -57,11 +56,11 @@ export function ItemList(props) {
|
|
|
57
56
|
}
|
|
58
57
|
let filteredList = itemList;
|
|
59
58
|
if (itemFilter.filterMatches) {
|
|
60
|
-
filteredList = itemList.filter((item) => itemFilter.filterMatches(item, itemFilter.
|
|
59
|
+
filteredList = itemList.filter((item) => itemFilter.filterMatches(item, itemFilter.filterHook.value));
|
|
61
60
|
}
|
|
62
61
|
extraCols.forEach((col) => {
|
|
63
62
|
if (col?.filter) {
|
|
64
|
-
filteredList = filteredList.filter((item) => col.filter?.filterMatches(item, col.filter.
|
|
63
|
+
filteredList = filteredList.filter((item) => col.filter?.filterMatches(item, col.filter.filterHook.value));
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
66
|
return filteredList;
|
|
@@ -97,7 +96,7 @@ export function ItemList(props) {
|
|
|
97
96
|
const baseWidth = (extraCol?.column.size || 100) + clearButtonWidth;
|
|
98
97
|
return baseWidth;
|
|
99
98
|
}, []);
|
|
100
|
-
|
|
99
|
+
const displayHeader = useCallback((header) => {
|
|
101
100
|
let filter = React.createElement("div", null);
|
|
102
101
|
if (header.id === defaultHeader) {
|
|
103
102
|
if (itemFilter) {
|
|
@@ -124,7 +123,45 @@ export function ItemList(props) {
|
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
return filter;
|
|
127
|
-
}
|
|
126
|
+
}, [defaultHeader, itemFilter, extraCols]);
|
|
127
|
+
const displayHeaderCell = useCallback((header, baseWidth) => {
|
|
128
|
+
return (React.createElement(TableCell, { "data-testid": `${defaultHeader}.th.cell.${header.id}`, key: header.id, sx: {
|
|
129
|
+
backgroundColor,
|
|
130
|
+
width: baseWidth,
|
|
131
|
+
borderRight: '1px solid #999',
|
|
132
|
+
paddingLeft: '16px',
|
|
133
|
+
paddingRight: 0,
|
|
134
|
+
paddingTop: 0,
|
|
135
|
+
paddingBottom: 0,
|
|
136
|
+
boxSizing: 'border-box',
|
|
137
|
+
} }, displayHeader(header)));
|
|
138
|
+
}, [backgroundColor, defaultHeader, displayHeader]);
|
|
139
|
+
const displayBodyCell = useCallback((cell, index, width, bgColor) => {
|
|
140
|
+
const cll = cell.getValue();
|
|
141
|
+
// Calculate width to match header cells exactly
|
|
142
|
+
let baseWidth;
|
|
143
|
+
if (cell.column.columnDef.header === defaultHeader) {
|
|
144
|
+
baseWidth = width;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// Check if this extra column has a filter
|
|
148
|
+
const extraCol = extraCols.find((col) => col && cell.column.columnDef.header === col.column.header);
|
|
149
|
+
baseWidth = cellWidth(extraCol);
|
|
150
|
+
}
|
|
151
|
+
return (React.createElement(TableCell, { "data-testid": `${defaultHeader}.tb.cell.${index}`, style: { backgroundColor: bgColor }, sx: {
|
|
152
|
+
borderRight: '1px solid #999',
|
|
153
|
+
paddingLeft: '16px',
|
|
154
|
+
paddingRight: 0,
|
|
155
|
+
paddingTop: 0,
|
|
156
|
+
paddingBottom: 0,
|
|
157
|
+
width: baseWidth,
|
|
158
|
+
// minWidth: baseWidth,
|
|
159
|
+
// maxWidth: baseWidth,
|
|
160
|
+
boxSizing: 'border-box',
|
|
161
|
+
}, key: cell.id }, cell.column.columnDef.header === defaultHeader ? (React.createElement(Button, { "data-testid": `${defaultHeader}.tb.cell.${cell.row.original[props.testId]}.button`, onClick: onClick(cell, cell.row.index) }, props.renderItem
|
|
162
|
+
? props.renderItem(cll)
|
|
163
|
+
: flexRender(cell.column.columnDef.cell, cell.getContext()))) : props.renderItem ? (props.renderItem(cll)) : (flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
164
|
+
}, [cellWidth, defaultHeader, extraCols, onClick, props]);
|
|
128
165
|
const table = useReactTable({
|
|
129
166
|
data: filteredItems,
|
|
130
167
|
columns,
|
|
@@ -138,75 +175,40 @@ export function ItemList(props) {
|
|
|
138
175
|
maxSize: 120,
|
|
139
176
|
},
|
|
140
177
|
});
|
|
141
|
-
const paginatedRows = table.getRowModel().rows;
|
|
142
178
|
// Calculate total table width for consistent alignment
|
|
143
179
|
const totalTableWidth = useMemo(() => {
|
|
144
180
|
let width = 130; // Default header width
|
|
145
181
|
extraCols.forEach((col) => {
|
|
146
|
-
if (col
|
|
147
|
-
width += 120;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
182
|
+
if (col) {
|
|
183
|
+
width += col.column.size || 120;
|
|
184
|
+
if (col.filter) {
|
|
185
|
+
// add extra width for filter clear button
|
|
186
|
+
width += 20;
|
|
187
|
+
}
|
|
151
188
|
}
|
|
152
189
|
});
|
|
153
190
|
return width;
|
|
154
191
|
}, [extraCols]);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return React.createElement("div", null, cll);
|
|
159
|
-
}
|
|
160
|
-
function displayBody(cell, index) {
|
|
161
|
-
let cellContent = React.createElement("div", null);
|
|
162
|
-
const cll = cell.getValue();
|
|
163
|
-
// Calculate width to match header cells exactly
|
|
192
|
+
const renderHeader = React.useCallback((headerGroups, width) => {
|
|
193
|
+
return headerGroups.map((headerGroup) => (React.createElement(TableRow, { key: headerGroup.id }, headerGroup.headers.map((header) => {
|
|
194
|
+
// Calculate width accounting for ItemFilter with CancelPresentationIcon
|
|
164
195
|
let baseWidth;
|
|
165
|
-
if (
|
|
166
|
-
baseWidth =
|
|
196
|
+
if (header.id === defaultHeader) {
|
|
197
|
+
baseWidth = width;
|
|
167
198
|
}
|
|
168
199
|
else {
|
|
169
200
|
// Check if this extra column has a filter
|
|
170
|
-
const extraCol = extraCols.find((col) => col &&
|
|
201
|
+
const extraCol = extraCols.find((col) => col && header.id === col.column.header);
|
|
171
202
|
baseWidth = cellWidth(extraCol);
|
|
172
203
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
borderRight: '1px solid #999',
|
|
178
|
-
paddingLeft: '16px',
|
|
179
|
-
paddingRight: 0,
|
|
180
|
-
paddingTop: 0,
|
|
181
|
-
paddingBottom: 0,
|
|
182
|
-
width: baseWidth,
|
|
183
|
-
minWidth: minWidth,
|
|
184
|
-
maxWidth: maxWidth,
|
|
185
|
-
boxSizing: 'border-box',
|
|
186
|
-
}, key: cell.id },
|
|
187
|
-
React.createElement(Button, { onClick: onClick(cell, cell.row.index) }, props.renderItem
|
|
188
|
-
? props.renderItem(cll)
|
|
189
|
-
: flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
cellContent = (React.createElement(TableCell, { "data-testid": `${defaultHeader}.tb.${index}`, style: { backgroundColor: bgColor }, sx: {
|
|
193
|
-
borderRight: '1px solid #999',
|
|
194
|
-
paddingLeft: '16px',
|
|
195
|
-
paddingRight: 0,
|
|
196
|
-
paddingTop: 0,
|
|
197
|
-
paddingBottom: 0,
|
|
198
|
-
width: baseWidth,
|
|
199
|
-
minWidth: minWidth,
|
|
200
|
-
maxWidth: maxWidth,
|
|
201
|
-
boxSizing: 'border-box',
|
|
202
|
-
}, key: cell.id }, props.renderItem ? props.renderItem(cll) : renderItem(cell)));
|
|
203
|
-
}
|
|
204
|
-
return cellContent;
|
|
205
|
-
}
|
|
204
|
+
return displayHeaderCell(header, baseWidth);
|
|
205
|
+
}))));
|
|
206
|
+
}, [cellWidth, defaultHeader, displayHeaderCell, extraCols]);
|
|
207
|
+
const renderBody = React.useCallback((rows, width, bgColor = backgroundColor) => {
|
|
206
208
|
return rows.map((row, index) => (React.createElement(TableRow, { "data-testid": `${defaultHeader}.tb.row.${index}`, key: row.id }, row.getVisibleCells().map((cell) => {
|
|
207
|
-
return
|
|
209
|
+
return displayBodyCell(cell, index, width, bgColor);
|
|
208
210
|
}))));
|
|
209
|
-
}, [backgroundColor,
|
|
211
|
+
}, [backgroundColor, defaultHeader, displayBodyCell]);
|
|
210
212
|
return (React.createElement("div", { "data-testid": `${defaultHeader}.table`, style: {
|
|
211
213
|
height,
|
|
212
214
|
overflow: 'hidden',
|
|
@@ -232,32 +234,7 @@ export function ItemList(props) {
|
|
|
232
234
|
borderCollapse: 'separate',
|
|
233
235
|
borderSpacing: 0,
|
|
234
236
|
} },
|
|
235
|
-
React.createElement(TableHead, { "data-testid": `${defaultHeader}.tableHeader`, sx: { backgroundColor } }, table.getHeaderGroups()
|
|
236
|
-
// Calculate width accounting for ItemFilter with CancelPresentationIcon
|
|
237
|
-
let baseWidth;
|
|
238
|
-
if (header.id === defaultHeader) {
|
|
239
|
-
baseWidth = 150;
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
// Check if this extra column has a filter
|
|
243
|
-
const extraCol = extraCols.find((col) => col && header.id === col.column.header);
|
|
244
|
-
baseWidth = cellWidth(extraCol);
|
|
245
|
-
}
|
|
246
|
-
const minWidth = baseWidth;
|
|
247
|
-
const maxWidth = baseWidth;
|
|
248
|
-
return (React.createElement(TableCell, { "data-testid": `${defaultHeader}.th.cell.${header.id}`, key: header.id, sx: {
|
|
249
|
-
backgroundColor,
|
|
250
|
-
width: baseWidth,
|
|
251
|
-
minWidth: minWidth,
|
|
252
|
-
maxWidth: maxWidth,
|
|
253
|
-
borderRight: '1px solid #999',
|
|
254
|
-
paddingLeft: '16px',
|
|
255
|
-
paddingRight: 0,
|
|
256
|
-
paddingTop: 0,
|
|
257
|
-
paddingBottom: 0,
|
|
258
|
-
boxSizing: 'border-box',
|
|
259
|
-
} }, displayHeader(header)));
|
|
260
|
-
}))))))),
|
|
237
|
+
React.createElement(TableHead, { "data-testid": `${defaultHeader}.tableHeader`, sx: { backgroundColor } }, renderHeader(table.getHeaderGroups(), mainColumnWidth)))),
|
|
261
238
|
React.createElement(Box, { sx: {
|
|
262
239
|
flex: 1,
|
|
263
240
|
overflow: 'auto',
|
|
@@ -271,5 +248,5 @@ export function ItemList(props) {
|
|
|
271
248
|
borderCollapse: 'separate',
|
|
272
249
|
borderSpacing: 0,
|
|
273
250
|
} },
|
|
274
|
-
React.createElement(TableBody, { "data-testid":
|
|
251
|
+
React.createElement(TableBody, { "data-testid": `${defaultHeader}.tableBody`, sx: { backgroundColor } }, renderBody(table.getRowModel().rows, mainColumnWidth, backgroundColor))))));
|
|
275
252
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AccessorFnColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { TFilterHook } from './types';
|
|
2
3
|
export type TItem = {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
5
6
|
export type TItemFilter<T> = {
|
|
6
7
|
property: keyof T;
|
|
7
|
-
|
|
8
|
-
setFilter: (filter: string) => void;
|
|
8
|
+
filterHook: TFilterHook;
|
|
9
9
|
filterMatches: (item: T, filter: string) => boolean;
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemTypes.d.ts","sourceRoot":"","sources":["../../src/components/itemTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"itemTypes.d.ts","sourceRoot":"","sources":["../../src/components/itemTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClB,UAAU,EAAE,WAAW,CAAC;IACxB,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACvB,MAAM,EAAE,mBAAmB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CACzB,CAAC"}
|
|
@@ -10,6 +10,10 @@ export type TFrameObj = {
|
|
|
10
10
|
sl: string;
|
|
11
11
|
rest: string;
|
|
12
12
|
};
|
|
13
|
+
export type TFilterHook = {
|
|
14
|
+
value: string;
|
|
15
|
+
setValue: React.Dispatch<React.SetStateAction<string>>;
|
|
16
|
+
};
|
|
13
17
|
export declare const brueckenWeiteKey = "bw";
|
|
14
18
|
export declare const scheibenLaengeKey = "sl";
|
|
15
19
|
export declare const scheibenFormKey = "rest";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,eAAe,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frame.select",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "A React component for selecting items from a list with a search bar.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,16 +21,14 @@
|
|
|
21
21
|
"test:e2e:debug": "playwright test --debug",
|
|
22
22
|
"preview": "vite preview"
|
|
23
23
|
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"@emotion/react": "^11.14.0",
|
|
26
|
-
"@emotion/styled": "^11.14.1",
|
|
27
|
-
"@mui/icons-material": "^7.3.6",
|
|
28
|
-
"@mui/material": "^7.3.6",
|
|
29
|
-
"@tanstack/react-table": "^8.21.3"
|
|
30
|
-
},
|
|
31
24
|
"peerDependencies": {
|
|
32
|
-
"react": "^
|
|
33
|
-
"
|
|
25
|
+
"@emotion/react": "^11.0.0",
|
|
26
|
+
"@emotion/styled": "^11.0.0",
|
|
27
|
+
"@mui/icons-material": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
28
|
+
"@mui/material": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
29
|
+
"@tanstack/react-table": "^8.0.0",
|
|
30
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
31
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
|
36
34
|
"@eslint/js": "^9.39.2",
|
|
@@ -38,8 +36,8 @@
|
|
|
38
36
|
"@testing-library/dom": "^10.4.1",
|
|
39
37
|
"@testing-library/jest-dom": "^6.9.1",
|
|
40
38
|
"@testing-library/react": "^16.3.1",
|
|
41
|
-
"@types/node": "^25.0.
|
|
42
|
-
"@types/react": "^19.2.
|
|
39
|
+
"@types/node": "^25.0.9",
|
|
40
|
+
"@types/react": "^19.2.8",
|
|
43
41
|
"@types/react-dom": "^19.2.3",
|
|
44
42
|
"@vitejs/plugin-react": "^5.1.2",
|
|
45
43
|
"eslint": "^9.39.2",
|
|
@@ -51,8 +49,8 @@
|
|
|
51
49
|
"react": "^19.2.3",
|
|
52
50
|
"react-dom": "^19.2.3",
|
|
53
51
|
"typescript": "~5.9.3",
|
|
54
|
-
"typescript-eslint": "^8.
|
|
55
|
-
"vite": "^7.3.
|
|
56
|
-
"vitest": "^4.0.
|
|
52
|
+
"typescript-eslint": "^8.53.0",
|
|
53
|
+
"vite": "^7.3.1",
|
|
54
|
+
"vitest": "^4.0.17"
|
|
57
55
|
}
|
|
58
56
|
}
|