- ); - }, - }, - body: { - wrapper: (props) => { - return ( - | {
+ // field.setValidator((value) => {
+ // if (requiredValidator) {
+ // return Array.isArray(value) && value.length > 0 ? null : 'The field value is required';
+ // }
+ // return;
+ // });
+ // }, [requiredValidator]);
+
+ useEffect(() => {
+ if (treeTable !== false) {
+ const keys = getIdsWithChildren(field.value?.slice?.());
+ setAllIncludesChildren(keys);
+ }
+ }, [field.value]);
+ useEffect(() => {
+ if (expandFlag) {
+ setExpandesKeys(allIncludesChildren);
+ } else {
+ setExpandesKeys([]);
+ }
+ }, [expandFlag, allIncludesChildren]);
+
+ const components = useMemo(() => {
+ return {
+ header: {
+ wrapper: (props) => {
+ return (
+ | - ), + ); }, - }; - }, [field, onRowDragEnd, dragSort]); + }, + body: { + wrapper: (props) => { + return ( + | + ), + }, }; + }, [field, onRowDragEnd, dragSort]); - const getRowKey = (record: any) => { - if (typeof rowKey === 'string') { - return record[rowKey]?.toString(); - } else { - return (rowKey ?? defaultRowKey)(record)?.toString(); - } - }; + const defaultRowKey = (record: any) => { + return field.value?.indexOf?.(record); + }; - const restProps = { - rowSelection: rowSelection - ? { + const getRowKey = (record: any) => { + if (typeof rowKey === 'string') { + return record[rowKey]?.toString(); + } else { + return (rowKey ?? defaultRowKey)(record)?.toString(); + } + }; + + const restProps = { + rowSelection: rowSelection + ? { type: 'checkbox', selectedRowKeys: selectedRowKeys, onChange(selectedRowKeys: any[], selectedRows: any[]) { @@ -349,20 +380,23 @@ export const Table: any = observer( className={classNames( checked ? 'checked' : null, css` - position: relative; - display: flex; - float: left; - align-items: center; - justify-content: space-evenly; - padding-right: 8px; + position: relative; + display: flex; + float: left; + align-items: center; + justify-content: space-evenly; + padding-right: 8px; + .nb-table-index { + opacity: 0; + } + &:not(.checked) { .nb-table-index { - opacity: 0; - } - &:not(.checked) { - .nb-table-index { - opacity: 1; - } + opacity: 1; } + } + `, + { + [css` &:hover { .nb-table-index { opacity: 0; @@ -371,28 +405,30 @@ export const Table: any = observer( display: block; } } - `, + `]: isRowSelect, + }, )} > |
---|
-
-
-
- |
- - |
---|---|
- - | -
-
-
- |
-
- - | -
-
-
- |
-
- - | -
-
-
- |
-