1 | // @flow
|
---|
2 | export const top: 'top' = 'top';
|
---|
3 | export const bottom: 'bottom' = 'bottom';
|
---|
4 | export const right: 'right' = 'right';
|
---|
5 | export const left: 'left' = 'left';
|
---|
6 | export const auto: 'auto' = 'auto';
|
---|
7 | export type BasePlacement =
|
---|
8 | | typeof top
|
---|
9 | | typeof bottom
|
---|
10 | | typeof right
|
---|
11 | | typeof left;
|
---|
12 | export const basePlacements: Array<BasePlacement> = [top, bottom, right, left];
|
---|
13 |
|
---|
14 | export const start: 'start' = 'start';
|
---|
15 | export const end: 'end' = 'end';
|
---|
16 | export type Variation = typeof start | typeof end;
|
---|
17 |
|
---|
18 | export const clippingParents: 'clippingParents' = 'clippingParents';
|
---|
19 | export const viewport: 'viewport' = 'viewport';
|
---|
20 | export type Boundary = Element | Array<Element> | typeof clippingParents;
|
---|
21 | export type RootBoundary = typeof viewport | 'document';
|
---|
22 |
|
---|
23 | export const popper: 'popper' = 'popper';
|
---|
24 | export const reference: 'reference' = 'reference';
|
---|
25 | export type Context = typeof popper | typeof reference;
|
---|
26 |
|
---|
27 | export type VariationPlacement =
|
---|
28 | | 'top-start'
|
---|
29 | | 'top-end'
|
---|
30 | | 'bottom-start'
|
---|
31 | | 'bottom-end'
|
---|
32 | | 'right-start'
|
---|
33 | | 'right-end'
|
---|
34 | | 'left-start'
|
---|
35 | | 'left-end';
|
---|
36 | export type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';
|
---|
37 | export type ComputedPlacement = VariationPlacement | BasePlacement;
|
---|
38 | export type Placement = AutoPlacement | BasePlacement | VariationPlacement;
|
---|
39 |
|
---|
40 | export const variationPlacements: Array<VariationPlacement> = basePlacements.reduce(
|
---|
41 | (acc: Array<VariationPlacement>, placement: BasePlacement) =>
|
---|
42 | acc.concat([(`${placement}-${start}`: any), (`${placement}-${end}`: any)]),
|
---|
43 | []
|
---|
44 | );
|
---|
45 | export const placements: Array<Placement> = [...basePlacements, auto].reduce(
|
---|
46 | (
|
---|
47 | acc: Array<Placement>,
|
---|
48 | placement: BasePlacement | typeof auto
|
---|
49 | ): Array<Placement> =>
|
---|
50 | acc.concat([
|
---|
51 | placement,
|
---|
52 | (`${placement}-${start}`: any),
|
---|
53 | (`${placement}-${end}`: any),
|
---|
54 | ]),
|
---|
55 | []
|
---|
56 | );
|
---|
57 |
|
---|
58 | // modifiers that need to read the DOM
|
---|
59 | export const beforeRead: 'beforeRead' = 'beforeRead';
|
---|
60 | export const read: 'read' = 'read';
|
---|
61 | export const afterRead: 'afterRead' = 'afterRead';
|
---|
62 | // pure-logic modifiers
|
---|
63 | export const beforeMain: 'beforeMain' = 'beforeMain';
|
---|
64 | export const main: 'main' = 'main';
|
---|
65 | export const afterMain: 'afterMain' = 'afterMain';
|
---|
66 | // modifier with the purpose to write to the DOM (or write into a framework state)
|
---|
67 | export const beforeWrite: 'beforeWrite' = 'beforeWrite';
|
---|
68 | export const write: 'write' = 'write';
|
---|
69 | export const afterWrite: 'afterWrite' = 'afterWrite';
|
---|
70 | export const modifierPhases: Array<ModifierPhases> = [
|
---|
71 | beforeRead,
|
---|
72 | read,
|
---|
73 | afterRead,
|
---|
74 | beforeMain,
|
---|
75 | main,
|
---|
76 | afterMain,
|
---|
77 | beforeWrite,
|
---|
78 | write,
|
---|
79 | afterWrite,
|
---|
80 | ];
|
---|
81 |
|
---|
82 | export type ModifierPhases =
|
---|
83 | | typeof beforeRead
|
---|
84 | | typeof read
|
---|
85 | | typeof afterRead
|
---|
86 | | typeof beforeMain
|
---|
87 | | typeof main
|
---|
88 | | typeof afterMain
|
---|
89 | | typeof beforeWrite
|
---|
90 | | typeof write
|
---|
91 | | typeof afterWrite;
|
---|