• 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/filter/condition/FieldSelect.tsx
NEW
1
import { useCallback, useContext, useMemo } from 'react';
×
NEW
2
import { useFieldStaticGetter } from '../../../hooks';
×
3

×
4
import { BaseSingleSelect } from '../component';
×
NEW
5
import { FilterContext } from '../context';
×
6

×
7
interface IFieldSelectProps {
×
8
  fieldId: string | null;
×
9
  onSelect: (type: string | null) => void;
×
10
}
×
11

×
12
function FieldSelect(props: IFieldSelectProps) {
×
13
  const { fieldId: value, onSelect } = props;
×
NEW
14
  const { fields } = useContext(FilterContext);
×
15
  const options = useMemo(() => {
×
16
    return fields.map((field) => ({
×
17
      value: field.id,
×
18
      label: field.name,
×
19
      ...field,
×
20
    }));
×
21
  }, [fields]);
×
22
  const fieldStaticGetter = useFieldStaticGetter();
×
23

×
24
  const optionRender = useCallback(
×
25
    (option: (typeof options)[number]) => {
×
26
      const { Icon } = fieldStaticGetter(option.type, option.isLookup);
×
27
      return (
×
28
        <>
×
29
          <Icon className="shrink-0"></Icon>
×
30
          <div className="truncate pl-1 text-[13px]">{option.label}</div>
×
31
        </>
×
32
      );
×
33
    },
×
34
    [fieldStaticGetter]
×
35
  );
×
36

×
37
  return (
×
38
    <BaseSingleSelect
×
39
      options={options}
×
40
      onSelect={onSelect}
×
41
      value={value}
×
42
      className="w-40 shrink-0"
×
43
      popoverClassName="w-fit"
×
44
      optionRender={optionRender}
×
45
    />
×
46
  );
×
47
}
×
48

×
49
export { FieldSelect };
×
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