@commonsku/styles 1.17.7 → 1.17.8
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/index.cjs +32 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -21
- package/dist/index.mjs +32 -31
- package/dist/index.mjs.map +1 -1
- package/dist/styles/tables/SelectionTable.d.ts +4 -3
- package/dist/styles/tables/SelectionTable.d.ts.map +1 -1
- package/dist/styles/tables/VirtualTable.d.ts +14 -18
- package/dist/styles/tables/VirtualTable.d.ts.map +1 -1
- package/dist/styles/tables/types.d.ts +7 -2
- package/dist/styles/tables/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2891,26 +2891,26 @@ interface BaseSortByHeaderGroup<D extends object = {}> extends HeaderGroup<D>, U
|
|
|
2891
2891
|
interface Row<D extends Record<string, unknown> = Record<string, unknown>> extends UseTableRowProps<D>, UseExpandedRowProps<D>, UseGroupByRowProps<D>, UseRowSelectRowProps<D>, UseRowStateRowProps<D> {
|
|
2892
2892
|
}
|
|
2893
2893
|
|
|
2894
|
-
type VirtualTableProps = {
|
|
2895
|
-
columns: Column$1<
|
|
2896
|
-
data:
|
|
2894
|
+
type VirtualTableProps<RowType extends Record<string, unknown>, TableProps, TableFooterProps> = {
|
|
2895
|
+
columns: readonly Column$1<RowType>[];
|
|
2896
|
+
data: RowType[];
|
|
2897
2897
|
itemSize?: (value: {
|
|
2898
2898
|
index: number;
|
|
2899
|
-
row: Row
|
|
2899
|
+
row: Row<RowType>;
|
|
2900
2900
|
}) => number;
|
|
2901
2901
|
height?: number;
|
|
2902
2902
|
minWidth?: number;
|
|
2903
2903
|
maxWidth?: number;
|
|
2904
2904
|
defaultSort?: SortingRule<string>;
|
|
2905
|
-
onClickRow?: (row?:
|
|
2905
|
+
onClickRow?: (row?: RowType, index?: number, data?: {
|
|
2906
2906
|
isScrolling?: boolean;
|
|
2907
|
-
cell: Cell<
|
|
2907
|
+
cell: Cell<RowType>;
|
|
2908
2908
|
resetList: (index?: number) => void;
|
|
2909
2909
|
toggleAllRowsExpanded: (value?: boolean | undefined) => void;
|
|
2910
2910
|
}) => void;
|
|
2911
2911
|
onScroll?: ((props: ListOnScrollProps) => any);
|
|
2912
2912
|
onUpdateData?: (...args: any) => void;
|
|
2913
|
-
useTableProps?:
|
|
2913
|
+
useTableProps?: TableProps;
|
|
2914
2914
|
tableHeaderProps?: {
|
|
2915
2915
|
className?: string;
|
|
2916
2916
|
style?: React__default.CSSProperties;
|
|
@@ -2919,34 +2919,30 @@ type VirtualTableProps = {
|
|
|
2919
2919
|
className?: string;
|
|
2920
2920
|
style?: React__default.CSSProperties;
|
|
2921
2921
|
};
|
|
2922
|
-
TableFooter?: (props: React__default.PropsWithChildren<
|
|
2923
|
-
|
|
2924
|
-
}>) => React__default.ReactElement;
|
|
2925
|
-
customTableFooterProps?: object;
|
|
2922
|
+
TableFooter?: (props: React__default.PropsWithChildren<TableFooterProps>) => React__default.ReactElement;
|
|
2923
|
+
customTableFooterProps?: TableFooterProps;
|
|
2926
2924
|
className?: string;
|
|
2927
2925
|
hideFooter?: boolean;
|
|
2928
2926
|
hideHeader?: boolean;
|
|
2929
2927
|
NoRowsFound?: (props: React__default.PropsWithChildren<{
|
|
2930
2928
|
[key: string]: any;
|
|
2931
2929
|
}>) => React__default.ReactElement;
|
|
2932
|
-
renderRowSubComponent?: (props: React__default.PropsWithChildren<
|
|
2933
|
-
[key: string]: any;
|
|
2934
|
-
}>) => React__default.ReactElement;
|
|
2930
|
+
renderRowSubComponent?: <P = unknown>(props: React__default.PropsWithChildren<P>) => React__default.ReactElement;
|
|
2935
2931
|
onSort?: (value: {
|
|
2936
|
-
column: BaseSortByHeaderGroup<
|
|
2932
|
+
column: BaseSortByHeaderGroup<RowType>;
|
|
2937
2933
|
}) => void;
|
|
2938
2934
|
onResize?: VoidFunction;
|
|
2939
2935
|
rowGroupStyles?: (value: {
|
|
2940
|
-
row: Row
|
|
2936
|
+
row: Row<RowType>;
|
|
2941
2937
|
style: React__default.CSSProperties;
|
|
2942
2938
|
}) => React__default.CSSProperties;
|
|
2943
2939
|
rowStyles?: (value: {
|
|
2944
|
-
row: Row
|
|
2940
|
+
row: Row<RowType>;
|
|
2945
2941
|
style: React__default.CSSProperties;
|
|
2946
2942
|
}) => React__default.CSSProperties;
|
|
2947
2943
|
gutterSize?: number;
|
|
2948
2944
|
};
|
|
2949
|
-
declare const VirtualTable: (props: VirtualTableProps) => React__default.JSX.Element;
|
|
2945
|
+
declare const VirtualTable: <RowType extends Record<string, unknown>, TableProps, TableFooterProps>(props: VirtualTableProps<RowType, TableProps, TableFooterProps>) => React__default.JSX.Element;
|
|
2950
2946
|
|
|
2951
2947
|
declare const VirtualTableStyles: styled_components.StyledComponent<"div", any, {
|
|
2952
2948
|
tableHeight?: string | number | undefined;
|
|
@@ -2959,10 +2955,11 @@ declare const VirtualTableStyles: styled_components.StyledComponent<"div", any,
|
|
|
2959
2955
|
}, never>;
|
|
2960
2956
|
//# sourceMappingURL=VirtualTableStyles.d.ts.map
|
|
2961
2957
|
|
|
2962
|
-
type SelectionTableProps = VirtualTableProps & {
|
|
2963
|
-
|
|
2958
|
+
type SelectionTableProps<RowType extends Record<string, unknown>, TableProps, TableFooterProps> = VirtualTableProps<RowType, TableProps, TableFooterProps> & {
|
|
2959
|
+
selectedRows?: RowType[];
|
|
2960
|
+
onSelectionChange?: (selectedRows: RowType[]) => void;
|
|
2964
2961
|
};
|
|
2965
|
-
declare const SelectionTable: (props: SelectionTableProps) => React__default.JSX.Element;
|
|
2962
|
+
declare const SelectionTable: <RowType extends Record<string, unknown>, TableProps, TableFooterProps>(props: SelectionTableProps<RowType, TableProps, TableFooterProps>) => React__default.JSX.Element;
|
|
2966
2963
|
|
|
2967
2964
|
type ResponsiveValue<T = string | number> = T | Array<T | null> | {
|
|
2968
2965
|
xs?: T;
|
package/dist/index.mjs
CHANGED
|
@@ -6769,50 +6769,51 @@ var VirtualTableStyles = styled.div(templateObject_1$a || (templateObject_1$a =
|
|
|
6769
6769
|
var templateObject_1$a;
|
|
6770
6770
|
|
|
6771
6771
|
var SelectionTable = function (props) {
|
|
6772
|
-
var columns = props.columns,
|
|
6773
|
-
var _a = useState(props.data.map(function (row) { return (__assign({ selected: false }, row)); })), data = _a[0], setData = _a[1];
|
|
6772
|
+
var columns = props.columns, data = props.data, selectedRows = props.selectedRows, onSelectionChange = props.onSelectionChange;
|
|
6774
6773
|
var selectionState = useMemo(function () {
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6774
|
+
if (selectedRows == null)
|
|
6775
|
+
return "none";
|
|
6776
|
+
switch (selectedRows.length) {
|
|
6777
|
+
case 0:
|
|
6778
|
+
return 'none';
|
|
6779
|
+
case data.length:
|
|
6780
|
+
return 'all';
|
|
6781
|
+
default:
|
|
6782
|
+
return 'some';
|
|
6783
|
+
}
|
|
6784
|
+
}, [data.length, selectedRows]);
|
|
6785
|
+
var handleSelectRows = useCallback(function (rows) {
|
|
6786
|
+
if (onSelectionChange == null)
|
|
6787
|
+
return;
|
|
6788
|
+
if (selectedRows == null) {
|
|
6789
|
+
onSelectionChange(rows);
|
|
6790
|
+
return;
|
|
6791
|
+
}
|
|
6792
|
+
var newSelection = selectedRows.filter(function (row) { return !rows.includes(row); });
|
|
6793
|
+
newSelection.push.apply(newSelection, rows.filter(function (row) { return !selectedRows.includes(row); }));
|
|
6794
|
+
onSelectionChange(newSelection);
|
|
6795
|
+
}, [selectedRows, onSelectionChange]);
|
|
6781
6796
|
var handleSelectHeader = useCallback(function () {
|
|
6797
|
+
if (onSelectionChange == null)
|
|
6798
|
+
return;
|
|
6782
6799
|
switch (selectionState) {
|
|
6783
6800
|
case 'none':
|
|
6784
|
-
|
|
6801
|
+
onSelectionChange(__spreadArray([], data, true));
|
|
6785
6802
|
break;
|
|
6786
6803
|
case 'all':
|
|
6787
|
-
case '
|
|
6788
|
-
|
|
6804
|
+
case 'some':
|
|
6805
|
+
onSelectionChange([]);
|
|
6789
6806
|
break;
|
|
6790
6807
|
}
|
|
6791
|
-
}, [data,
|
|
6792
|
-
var
|
|
6793
|
-
setData(function (prev) { return prev.map(function (row, index) {
|
|
6794
|
-
if (rowIndex !== index)
|
|
6795
|
-
return row;
|
|
6796
|
-
if (onSelectRow != null) {
|
|
6797
|
-
onSelectRow(row, rowIndex);
|
|
6798
|
-
}
|
|
6799
|
-
return __assign(__assign({}, row), { selected: rowIndex === index
|
|
6800
|
-
? !row.selected
|
|
6801
|
-
: row.selected });
|
|
6802
|
-
}); });
|
|
6803
|
-
}, [onSelectRow]);
|
|
6804
|
-
var selectionHeader = useMemo(function () { return (React.createElement(LabeledCheckbox, { label: "", checked: selectionState === 'all', indeterminate: selectionState === 'indeterminate', onChange: handleSelectHeader })); }, [selectionState, handleSelectHeader]);
|
|
6808
|
+
}, [selectionState, data, onSelectionChange]);
|
|
6809
|
+
var selectionHeader = useMemo(function () { return (React.createElement(LabeledCheckbox, { label: "", checked: selectionState === 'all', indeterminate: selectionState === 'some', onChange: handleSelectHeader })); }, [selectionState, handleSelectHeader]);
|
|
6805
6810
|
var selectionColumn = useMemo(function () { return ({
|
|
6806
6811
|
Header: selectionHeader,
|
|
6807
6812
|
accessor: 'selected',
|
|
6808
|
-
Cell: function (
|
|
6809
|
-
return (React.createElement(LabeledCheckbox, { label: "", checked: cellObj.row.original.selected, onChange: function () { return handleSelectRow(cellObj.row.index); } }));
|
|
6810
|
-
},
|
|
6811
|
-
sticky: 'left',
|
|
6812
|
-
noDrag: true,
|
|
6813
|
+
Cell: function (cell) { return (React.createElement(LabeledCheckbox, { label: "", checked: selectedRows != null && selectedRows.includes(cell.row.original), onChange: function () { return handleSelectRows([cell.row.original]); } })); },
|
|
6813
6814
|
width: 40,
|
|
6814
6815
|
disableSortBy: true,
|
|
6815
|
-
}); }, [
|
|
6816
|
+
}); }, [selectedRows, selectionHeader, handleSelectRows]);
|
|
6816
6817
|
return (React.createElement(VirtualTable, __assign({}, props, { columns: __spreadArray([selectionColumn], columns, true), data: data, minWidth: 40 })));
|
|
6817
6818
|
};
|
|
6818
6819
|
|