frame.select 1.2.3 → 1.2.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/dist/App.d.ts.map +1 -1
- package/dist/App.js +8 -6
- 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 +26 -47
- package/dist/components/ItemFilter.js +4 -4
- package/dist/components/ItemList.d.ts +1 -0
- package/dist/components/ItemList.d.ts.map +1 -1
- package/dist/components/ItemList.js +70 -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 +3 -3
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;AAGnB,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,iBAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAC;AAGnB,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,iBAAS,GAAG,sBAkNX;AAED,eAAe,GAAG,CAAC"}
|
package/dist/App.js
CHANGED
|
@@ -6,8 +6,6 @@ import { BrandList } from './components/BrandList';
|
|
|
6
6
|
import { FrameList } from './components/FrameList';
|
|
7
7
|
function App() {
|
|
8
8
|
const [brand, setBrand] = useState('');
|
|
9
|
-
const [filterWidth, setFilterWidth] = useState('');
|
|
10
|
-
const [filterHeight, setFilterHeight] = useState('');
|
|
11
9
|
const brands = [
|
|
12
10
|
{
|
|
13
11
|
name: 'Adidas',
|
|
@@ -80,7 +78,7 @@ function App() {
|
|
|
80
78
|
'AFF000000000000000TMA4750190010',
|
|
81
79
|
'AFF000000000000000TMA4750190011',
|
|
82
80
|
'AFF000000000000000TMA4750190012',
|
|
83
|
-
'
|
|
81
|
+
'ADI000000000000000TXDDC50190012',
|
|
84
82
|
];
|
|
85
83
|
const frameNike = [
|
|
86
84
|
'AFF000000000000000TMA4750190000',
|
|
@@ -168,8 +166,12 @@ function App() {
|
|
|
168
166
|
React.createElement("h2", null,
|
|
169
167
|
"Frame List for ",
|
|
170
168
|
brand),
|
|
171
|
-
React.createElement(FrameList, { frameList: convertFrames(brand, frames), onClick: onClickFrame,
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
React.createElement(FrameList, { frameList: convertFrames(brand, frames), onClick: onClickFrame, slSize: 120, slFormat: (value) => {
|
|
170
|
+
return React.createElement("div", null, value);
|
|
171
|
+
}, bwSize: 160, bwFormat: (value) => {
|
|
172
|
+
return React.createElement("span", { style: { fontWeight: 'bold' } }, value);
|
|
173
|
+
}, formSize: 320, formFormat: (value) => {
|
|
174
|
+
return React.createElement("div", { style: { color: 'red' } }, value);
|
|
175
|
+
} })));
|
|
174
176
|
}
|
|
175
177
|
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,CAiBd"}
|
|
@@ -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" }));
|
|
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,CAiHd"}
|
|
@@ -29,56 +29,35 @@ 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}
|
|
@@ -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;
|
|
@@ -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;CACxB,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,49 @@ export function ItemList(props) {
|
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
return filter;
|
|
127
|
-
}
|
|
126
|
+
}, [defaultHeader, itemFilter, extraCols]);
|
|
127
|
+
const renderItem = useCallback((cell) => {
|
|
128
|
+
const cll = cell.getValue();
|
|
129
|
+
return React.createElement("div", null, cll);
|
|
130
|
+
}, []);
|
|
131
|
+
const displayHeaderCell = useCallback((header, baseWidth) => {
|
|
132
|
+
return (React.createElement(TableCell, { "data-testid": `${defaultHeader}.th.cell.${header.id}`, key: header.id, sx: {
|
|
133
|
+
backgroundColor,
|
|
134
|
+
width: baseWidth,
|
|
135
|
+
borderRight: '1px solid #999',
|
|
136
|
+
paddingLeft: '16px',
|
|
137
|
+
paddingRight: 0,
|
|
138
|
+
paddingTop: 0,
|
|
139
|
+
paddingBottom: 0,
|
|
140
|
+
boxSizing: 'border-box',
|
|
141
|
+
} }, displayHeader(header)));
|
|
142
|
+
}, [backgroundColor, defaultHeader, displayHeader]);
|
|
143
|
+
const displayBodyCell = useCallback((cell, index, width, bgColor) => {
|
|
144
|
+
const cll = cell.getValue();
|
|
145
|
+
// Calculate width to match header cells exactly
|
|
146
|
+
let baseWidth;
|
|
147
|
+
if (cell.column.columnDef.header === defaultHeader) {
|
|
148
|
+
baseWidth = width;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// Check if this extra column has a filter
|
|
152
|
+
const extraCol = extraCols.find((col) => col && cell.column.columnDef.header === col.column.header);
|
|
153
|
+
baseWidth = cellWidth(extraCol);
|
|
154
|
+
}
|
|
155
|
+
return (React.createElement(TableCell, { "data-testid": `${defaultHeader}.tb.cell.${index}`, style: { backgroundColor: bgColor }, sx: {
|
|
156
|
+
borderRight: '1px solid #999',
|
|
157
|
+
paddingLeft: '16px',
|
|
158
|
+
paddingRight: 0,
|
|
159
|
+
paddingTop: 0,
|
|
160
|
+
paddingBottom: 0,
|
|
161
|
+
width: baseWidth,
|
|
162
|
+
// minWidth: baseWidth,
|
|
163
|
+
// maxWidth: baseWidth,
|
|
164
|
+
boxSizing: 'border-box',
|
|
165
|
+
}, key: cell.id }, cell.column.columnDef.header === defaultHeader ? (React.createElement(Button, { onClick: onClick(cell, cell.row.index) }, props.renderItem
|
|
166
|
+
? props.renderItem(cll)
|
|
167
|
+
: flexRender(cell.column.columnDef.cell, cell.getContext()))) : props.renderItem ? (props.renderItem(cll)) : (flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
168
|
+
}, [cellWidth, defaultHeader, extraCols, onClick, props]);
|
|
128
169
|
const table = useReactTable({
|
|
129
170
|
data: filteredItems,
|
|
130
171
|
columns,
|
|
@@ -138,75 +179,40 @@ export function ItemList(props) {
|
|
|
138
179
|
maxSize: 120,
|
|
139
180
|
},
|
|
140
181
|
});
|
|
141
|
-
const paginatedRows = table.getRowModel().rows;
|
|
142
182
|
// Calculate total table width for consistent alignment
|
|
143
183
|
const totalTableWidth = useMemo(() => {
|
|
144
184
|
let width = 130; // Default header width
|
|
145
185
|
extraCols.forEach((col) => {
|
|
146
|
-
if (col
|
|
147
|
-
width += 120;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
186
|
+
if (col) {
|
|
187
|
+
width += col.column.size || 120;
|
|
188
|
+
if (col.filter) {
|
|
189
|
+
// add extra width for filter clear button
|
|
190
|
+
width += 20;
|
|
191
|
+
}
|
|
151
192
|
}
|
|
152
193
|
});
|
|
153
194
|
return width;
|
|
154
195
|
}, [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
|
|
196
|
+
const renderHeader = React.useCallback((headerGroups, width) => {
|
|
197
|
+
return headerGroups.map((headerGroup) => (React.createElement(TableRow, { key: headerGroup.id }, headerGroup.headers.map((header) => {
|
|
198
|
+
// Calculate width accounting for ItemFilter with CancelPresentationIcon
|
|
164
199
|
let baseWidth;
|
|
165
|
-
if (
|
|
166
|
-
baseWidth =
|
|
200
|
+
if (header.id === defaultHeader) {
|
|
201
|
+
baseWidth = width;
|
|
167
202
|
}
|
|
168
203
|
else {
|
|
169
204
|
// Check if this extra column has a filter
|
|
170
|
-
const extraCol = extraCols.find((col) => col &&
|
|
205
|
+
const extraCol = extraCols.find((col) => col && header.id === col.column.header);
|
|
171
206
|
baseWidth = cellWidth(extraCol);
|
|
172
207
|
}
|
|
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
|
-
}
|
|
208
|
+
return displayHeaderCell(header, baseWidth);
|
|
209
|
+
}))));
|
|
210
|
+
}, [cellWidth, defaultHeader, displayHeaderCell, extraCols]);
|
|
211
|
+
const renderBody = React.useCallback((rows, width, bgColor = backgroundColor) => {
|
|
206
212
|
return rows.map((row, index) => (React.createElement(TableRow, { "data-testid": `${defaultHeader}.tb.row.${index}`, key: row.id }, row.getVisibleCells().map((cell) => {
|
|
207
|
-
return
|
|
213
|
+
return displayBodyCell(cell, index, width, bgColor);
|
|
208
214
|
}))));
|
|
209
|
-
}, [backgroundColor,
|
|
215
|
+
}, [backgroundColor, defaultHeader, displayBodyCell]);
|
|
210
216
|
return (React.createElement("div", { "data-testid": `${defaultHeader}.table`, style: {
|
|
211
217
|
height,
|
|
212
218
|
overflow: 'hidden',
|
|
@@ -232,32 +238,7 @@ export function ItemList(props) {
|
|
|
232
238
|
borderCollapse: 'separate',
|
|
233
239
|
borderSpacing: 0,
|
|
234
240
|
} },
|
|
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
|
-
}))))))),
|
|
241
|
+
React.createElement(TableHead, { "data-testid": `${defaultHeader}.tableHeader`, sx: { backgroundColor } }, renderHeader(table.getHeaderGroups(), mainColumnWidth)))),
|
|
261
242
|
React.createElement(Box, { sx: {
|
|
262
243
|
flex: 1,
|
|
263
244
|
overflow: 'auto',
|
|
@@ -271,5 +252,5 @@ export function ItemList(props) {
|
|
|
271
252
|
borderCollapse: 'separate',
|
|
272
253
|
borderSpacing: 0,
|
|
273
254
|
} },
|
|
274
|
-
React.createElement(TableBody, { "data-testid":
|
|
255
|
+
React.createElement(TableBody, { "data-testid": `${defaultHeader}.tableBody`, sx: { backgroundColor } }, renderBody(table.getRowModel().rows, mainColumnWidth, backgroundColor))))));
|
|
275
256
|
}
|
|
@@ -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.4",
|
|
4
4
|
"description": "A React component for selecting items from a list with a search bar.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"react": "^19.2.3",
|
|
52
52
|
"react-dom": "^19.2.3",
|
|
53
53
|
"typescript": "~5.9.3",
|
|
54
|
-
"typescript-eslint": "^8.
|
|
55
|
-
"vite": "^7.3.
|
|
54
|
+
"typescript-eslint": "^8.52.0",
|
|
55
|
+
"vite": "^7.3.1",
|
|
56
56
|
"vitest": "^4.0.16"
|
|
57
57
|
}
|
|
58
58
|
}
|