@pnkx-lib/ui 1.9.556 → 1.9.557
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/es/ui/SelectTable.js
CHANGED
|
@@ -33,6 +33,8 @@ const SelectTable = ({
|
|
|
33
33
|
classNameLabel,
|
|
34
34
|
isShowLabel = false,
|
|
35
35
|
isShowCheckboxAll = false,
|
|
36
|
+
listIdDuplicate = [],
|
|
37
|
+
classNameRow = "",
|
|
36
38
|
...selectProps
|
|
37
39
|
}) => {
|
|
38
40
|
const [open, setOpen] = useState(false);
|
|
@@ -164,6 +166,29 @@ const SelectTable = ({
|
|
|
164
166
|
}
|
|
165
167
|
setOpen(visible);
|
|
166
168
|
};
|
|
169
|
+
const handleRowClick = (record) => {
|
|
170
|
+
{
|
|
171
|
+
const key = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
|
|
172
|
+
const isSelected = currentSelectedKeys.includes(key);
|
|
173
|
+
if (isSelected) {
|
|
174
|
+
const newSelectedKeys = currentSelectedKeys.filter((k) => k !== key);
|
|
175
|
+
const newSelectedRows = value?.filter((row) => {
|
|
176
|
+
const rowKeyValue = typeof rowKey === "function" ? rowKey(row) : row[rowKey];
|
|
177
|
+
return rowKeyValue !== key;
|
|
178
|
+
}) || [];
|
|
179
|
+
onSelectChange(newSelectedKeys, newSelectedRows);
|
|
180
|
+
} else {
|
|
181
|
+
const newSelectedKeys = [...currentSelectedKeys, key];
|
|
182
|
+
const newSelectedRows = [...value || [], record];
|
|
183
|
+
onSelectChange(newSelectedKeys, newSelectedRows);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const handleRowClassName = (record) => {
|
|
188
|
+
const key = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
|
|
189
|
+
const isValid = listIdDuplicate.includes(key);
|
|
190
|
+
return isValid ? classNameRow : "";
|
|
191
|
+
};
|
|
167
192
|
const dropdownRender = () => /* @__PURE__ */ jsx("div", { className: "select-table-dropdown", children: /* @__PURE__ */ jsx(
|
|
168
193
|
"div",
|
|
169
194
|
{
|
|
@@ -182,6 +207,10 @@ const SelectTable = ({
|
|
|
182
207
|
style: { overflowX: "hidden" },
|
|
183
208
|
loading: false,
|
|
184
209
|
onScroll: handleScroll,
|
|
210
|
+
onRow: (record) => ({
|
|
211
|
+
onClick: () => handleRowClick(record)
|
|
212
|
+
}),
|
|
213
|
+
rowClassName: handleRowClassName,
|
|
185
214
|
...tableProps
|
|
186
215
|
}
|
|
187
216
|
)
|
package/package.json
CHANGED
|
@@ -35,5 +35,7 @@ export interface SelectTableProps<T = Record<string, unknown>> extends Omit<Sele
|
|
|
35
35
|
classNameLabel?: string;
|
|
36
36
|
isShowLabel?: boolean;
|
|
37
37
|
isShowCheckboxAll?: boolean;
|
|
38
|
+
listIdDuplicate?: React.Key[];
|
|
39
|
+
classNameRow?: string;
|
|
38
40
|
}
|
|
39
|
-
export declare const SelectTable: <T>({ columns, dataSource, selectedKeys, onSelectionChange, onLoadMore, onSearch, hasMore, loading, rowKey, tableProps, infiniteScroll, loadMoreThreshold, searchPlaceholder, displayField, selectedRows, customeContentTable, customeContainerTable, field, formState, label, required, isDisabledCheckbox, classNameContainer, classNameLabel, isShowLabel, isShowCheckboxAll, ...selectProps }: SelectTableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare const SelectTable: <T>({ columns, dataSource, selectedKeys, onSelectionChange, onLoadMore, onSearch, hasMore, loading, rowKey, tableProps, infiniteScroll, loadMoreThreshold, searchPlaceholder, displayField, selectedRows, customeContentTable, customeContainerTable, field, formState, label, required, isDisabledCheckbox, classNameContainer, classNameLabel, isShowLabel, isShowCheckboxAll, listIdDuplicate, classNameRow, ...selectProps }: SelectTableProps<T>) => import("react/jsx-runtime").JSX.Element;
|