• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 8536869866

03 Apr 2024 10:05AM CUT coverage: 21.234% (-0.3%) from 21.535%
8536869866

Pull #514

github

web-flow
Merge 91a25d710 into 45ee7ebb3
Pull Request #514: refactor: user and link selector

1394 of 2532 branches covered (55.06%)

27 of 1620 new or added lines in 60 files covered. (1.67%)

4 existing lines in 2 files now uncovered.

14588 of 68702 relevant lines covered (21.23%)

2.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/sdk/src/components/record-list/SocketRecordList.tsx
NEW
1
import type { ILinkCellValue } from '@teable/core';
×
NEW
2
import { Skeleton } from '@teable/ui-lib';
×
NEW
3
import { debounce } from 'lodash';
×
NEW
4
import { useEffect, useMemo, useState } from 'react';
×
NEW
5
import { useRowCount, useSearch } from '../../hooks';
×
NEW
6
import { useInfiniteRecords } from '../../hooks/use-infinite-records';
×
NEW
7
import { RecordItem } from './RecordItem';
×
NEW
8
import { RecordList } from './RecordList';
×
NEW
9
import { RecordSearch } from './RecordSearch';
×
NEW
10

×
NEW
11
interface ISocketRecordListProps {
×
NEW
12
  primaryFieldId: string;
×
NEW
13
  take?: number;
×
NEW
14
  selectedRecordIds?: string[];
×
NEW
15
  onSelected?: (record: ILinkCellValue) => void;
×
NEW
16
  onClick?: (record: ILinkCellValue) => void;
×
NEW
17
}
×
NEW
18

×
NEW
19
export const SocketRecordList = (props: ISocketRecordListProps) => {
×
NEW
20
  const { selectedRecordIds, primaryFieldId, onSelected, onClick } = props;
×
NEW
21
  const rowCount = useRowCount();
×
NEW
22
  const { setValue: setSearch, setFieldId } = useSearch();
×
NEW
23
  const [searchInput, setSearchInput] = useState('');
×
NEW
24

×
NEW
25
  useEffect(() => {
×
NEW
26
    setFieldId(primaryFieldId);
×
NEW
27
  }, [primaryFieldId, setFieldId]);
×
NEW
28

×
NEW
29
  const updateSearchParam = useMemo(() => {
×
NEW
30
    return debounce((search: string) => {
×
NEW
31
      return setSearch(search);
×
NEW
32
    }, 300);
×
NEW
33
  }, [setSearch]);
×
NEW
34

×
NEW
35
  const { onVisibleRegionChanged, recordMap } = useInfiniteRecords();
×
NEW
36

×
NEW
37
  useEffect(() => updateSearchParam(searchInput), [searchInput, updateSearchParam]);
×
NEW
38

×
NEW
39
  return (
×
NEW
40
    <RecordList
×
NEW
41
      className="h-full"
×
NEW
42
      onSelect={(index) => {
×
NEW
43
        const record = recordMap[index];
×
NEW
44
        if (!record) {
×
NEW
45
          return;
×
NEW
46
        }
×
NEW
47
        onClick?.(record);
×
NEW
48
        if (!selectedRecordIds?.includes(record.id)) {
×
NEW
49
          onSelected?.(record);
×
NEW
50
        }
×
NEW
51
      }}
×
NEW
52
      itemRender={(index) => {
×
NEW
53
        const record = recordMap[index];
×
NEW
54
        if (!record) {
×
NEW
55
          return <Skeleton className="size-full"></Skeleton>;
×
NEW
56
        }
×
NEW
57
        const isActive = selectedRecordIds?.includes(record.id);
×
NEW
58
        return <RecordItem title={record.name} active={isActive} />;
×
NEW
59
      }}
×
NEW
60
      rowCount={rowCount ?? 0}
×
NEW
61
      onVisibleChange={(range) => {
×
NEW
62
        const [startIndex, endIndex] = range;
×
NEW
63
        onVisibleRegionChanged({
×
NEW
64
          y: startIndex,
×
NEW
65
          height: endIndex - startIndex,
×
NEW
66
        });
×
NEW
67
      }}
×
NEW
68
    >
×
NEW
69
      <RecordSearch value={searchInput} onChange={(e) => setSearchInput(e.target.value)} />
×
NEW
70
    </RecordList>
×
NEW
71
  );
×
NEW
72
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc