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

teableio / teable / 10281066376

07 Aug 2024 08:42AM UTC coverage: 17.548% (-0.2%) from 17.734%
10281066376

Pull #793

github

web-flow
Merge 425f5ab0e into 6131ee284
Pull Request #793: feat: record history

1387 of 2823 branches covered (49.13%)

6 of 1033 new or added lines in 43 files covered. (0.58%)

34 existing lines in 5 files now uncovered.

14088 of 80281 relevant lines covered (17.55%)

1.74 hits per line

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

0.0
/packages/sdk/src/components/expand-record/RecordEditor.tsx
1
import { Button } from '@teable/ui-lib';
×
2
import { useRef } from 'react';
×
3
import { useMeasure, useToggle } from 'react-use';
×
4
import type { IFieldInstance, Record } from '../../model';
×
5
import { RecordEditorItem } from './RecordEditorItem';
×
6

×
7
// eslint-disable-next-line @typescript-eslint/naming-convention
×
8
const EDITOR_VERTICAL_MIN = 570;
×
9

×
10
export const RecordEditor = (props: {
×
11
  fields: IFieldInstance[];
×
12
  record: Record | undefined;
×
13
  hiddenFields?: IFieldInstance[];
×
14
  onChange?: (newValue: unknown, fieldId: string) => void;
×
15
  readonly?: boolean | ((field: IFieldInstance) => boolean);
×
16
}) => {
×
17
  const [ref, { width }] = useMeasure<HTMLDivElement>();
×
18
  const wrapRef = useRef<HTMLDivElement>(null);
×
19
  const { fields, hiddenFields = [], record, onChange, readonly } = props;
×
20
  const vertical = width > EDITOR_VERTICAL_MIN;
×
21
  const [showHiddenFields, toggle] = useToggle(false);
×
22

×
23
  return (
×
NEW
24
    <div ref={ref} className="max-w-3xl">
×
25
      <div ref={wrapRef} className="mx-auto space-y-6">
×
26
        {fields.map((field) => (
×
27
          <RecordEditorItem
×
28
            key={field.id}
×
29
            vertical={vertical}
×
30
            field={field}
×
31
            record={record}
×
32
            onChange={onChange}
×
33
            readonly={typeof readonly === 'function' ? readonly(field) : readonly}
×
34
          />
×
35
        ))}
×
36
        {hiddenFields.length !== 0 && (
×
37
          <div className="flex items-center gap-2">
×
38
            <div className="border-top-width h-px flex-1 bg-border" />
×
39
            <Button variant={'outline'} size={'xs'} onClick={toggle}>
×
40
              {showHiddenFields ? 'Hide' : 'Show'} {hiddenFields.length} hidden field
×
41
            </Button>
×
42
            <div className="border-top-width h-px flex-1 bg-border" />
×
43
          </div>
×
44
        )}
×
45
        {showHiddenFields &&
×
46
          hiddenFields?.map((field) => (
×
47
            <RecordEditorItem
×
48
              key={field.id}
×
49
              vertical={vertical}
×
50
              field={field}
×
51
              record={record}
×
52
              onChange={onChange}
×
53
              readonly={typeof readonly === 'function' ? readonly(field) : readonly}
×
54
            />
×
55
          ))}
×
56
      </div>
×
57
    </div>
×
58
  );
×
59
};
×
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