Blame view

天文台pc/tianwentai-ui/node_modules/date-fns/locale/_lib/buildMatchFn.d.ts 1.99 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  import type { Quarter, Era, Day, Month } from "../../types.js";
  import type {
    LocaleUnitValue,
    LocaleWidth,
    LocaleDayPeriod,
    MatchFn,
    MatchValueCallback,
  } from "../types.js";
  export interface BuildMatchFnArgs<
    Result extends LocaleUnitValue,
    DefaultMatchWidth extends LocaleWidth,
    DefaultParseWidth extends LocaleWidth,
  > {
    matchPatterns: BuildMatchFnMatchPatterns<DefaultMatchWidth>;
    defaultMatchWidth: DefaultMatchWidth;
    parsePatterns: BuildMatchFnParsePatterns<Result, DefaultParseWidth>;
    defaultParseWidth: DefaultParseWidth;
    valueCallback?: MatchValueCallback<
      Result extends LocaleDayPeriod ? string : number,
      Result
    >;
  }
  export type BuildMatchFnMatchPatterns<DefaultWidth extends LocaleWidth> = {
    [Width in LocaleWidth]?: RegExp;
  } & {
    [Width in DefaultWidth]: RegExp;
  };
  export type BuildMatchFnParsePatterns<
    Value extends LocaleUnitValue,
    DefaultWidth extends LocaleWidth,
  > = {
    [Width in LocaleWidth]?: ParsePattern<Value>;
  } & {
    [Width in DefaultWidth]: ParsePattern<Value>;
  };
  export type ParsePattern<Value extends LocaleUnitValue> =
    Value extends LocaleDayPeriod
      ? Record<LocaleDayPeriod, RegExp>
      : Value extends Quarter
        ? readonly [RegExp, RegExp, RegExp, RegExp]
        : Value extends Era
          ? readonly [RegExp, RegExp]
          : Value extends Day
            ? readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp]
            : Value extends Month
              ? readonly [
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                  RegExp,
                ]
              : never;
  export declare function buildMatchFn<
    Value extends LocaleUnitValue,
    DefaultMatchWidth extends LocaleWidth,
    DefaultParseWidth extends LocaleWidth,
  >(
    args: BuildMatchFnArgs<Value, DefaultMatchWidth, DefaultParseWidth>,
  ): MatchFn<Value>;