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

teableio / teable / 8387093605

22 Mar 2024 07:48AM CUT coverage: 28.027% (-0.2%) from 28.222%
8387093605

Pull #484

github

web-flow
Merge 174ef76f7 into a06c6afb1
Pull Request #484: feat: support increment import

2099 of 3218 branches covered (65.23%)

24 of 703 new or added lines in 18 files covered. (3.41%)

49 existing lines in 6 files now uncovered.

25815 of 92109 relevant lines covered (28.03%)

5.52 hits per line

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

0.0
/packages/sdk/src/components/editor/date/Editor.tsx
1
import { TimeFormatting } from '@teable/core';
×
2
import { Calendar } from '@teable/icons';
×
3
import { Button, Popover, PopoverContent, PopoverTrigger } from '@teable/ui-lib';
×
4
import classNames from 'classnames';
×
5
import dayjs, { extend } from 'dayjs';
×
6
import timezone from 'dayjs/plugin/timezone';
×
7
import type { ForwardRefRenderFunction } from 'react';
×
8
import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
×
9
import { useTranslation } from '../../../context/app/i18n';
×
10
import type { IEditorRef } from '../type';
×
11
import type { IDateEditorMain } from './EditorMain';
×
12
import { DateEditorMain } from './EditorMain';
×
13

×
14
extend(timezone);
×
15

×
16
const DateEditorBase: ForwardRefRenderFunction<IEditorRef<string>, IDateEditorMain> = (
×
17
  props,
×
18
  ref
×
19
) => {
×
20
  const { value, onChange, className, readonly, options, disableTimePicker = false } = props;
×
21
  const {
×
22
    date,
×
23
    time,
×
24
    timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
×
25
  } = options?.formatting || {};
×
26
  const editorRef = useRef<IEditorRef<string>>(null);
×
27
  const { t } = useTranslation();
×
28

×
29
  useImperativeHandle(ref, () => ({
×
30
    setValue: (value?: string) => {
×
31
      editorRef.current?.setValue?.(value);
×
32
    },
×
33
  }));
×
34

×
35
  const valueComponent = useMemo(() => {
×
36
    if (!value) return <span>{t('editor.date.placeholder')}</span>;
×
37

×
38
    let format = 'YYYY-MM-DD HH:mm';
×
39
    if (date && time) {
×
40
      format = time === TimeFormatting.None ? date : `${date} ${time}`;
×
41
    }
×
42
    return dayjs(value).tz(timeZone).format(format);
×
43
  }, [value, t, date, time, timeZone]);
×
44

×
45
  return (
×
46
    <Popover>
×
47
      <PopoverTrigger asChild disabled={readonly}>
×
48
        <Button
×
49
          variant={'outline'}
×
50
          className={classNames(
×
51
            'w-full first-line:pl-3 text-left font-normal h-10 sm:h-9',
×
52
            !value && 'text-muted-foreground',
×
53
            className
×
54
          )}
×
55
        >
×
56
          {valueComponent}
×
57
          <Calendar />
×
58
        </Button>
×
59
      </PopoverTrigger>
×
60
      <PopoverContent className="w-auto p-0" align="start">
×
UNCOV
61
        <DateEditorMain
×
UNCOV
62
          ref={editorRef}
×
UNCOV
63
          value={value}
×
UNCOV
64
          options={options}
×
UNCOV
65
          disableTimePicker={disableTimePicker}
×
UNCOV
66
          onChange={onChange}
×
UNCOV
67
        />
×
UNCOV
68
      </PopoverContent>
×
UNCOV
69
    </Popover>
×
UNCOV
70
  );
×
UNCOV
71
};
×
UNCOV
72

×
UNCOV
73
export const DateEditor = forwardRef(DateEditorBase);
×
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