@bitrise/bitkit 10.35.2-alpha-chakra.1 → 10.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/src/Components/ButtonGroup/ButtonGroup.tsx +4 -4
  3. package/src/Components/Icons/16x16/BoxWithArrowDown.tsx +14 -0
  4. package/src/Components/Icons/16x16/BoxWithDot.tsx +14 -0
  5. package/src/Components/Icons/16x16/OverflowingLines.tsx +14 -0
  6. package/src/Components/Icons/16x16/StepstatusIncomplete.tsx +14 -0
  7. package/src/Components/Icons/16x16/WrappedLines.tsx +14 -0
  8. package/src/Components/Icons/16x16/index.ts +5 -0
  9. package/src/Components/Icons/24x24/BoxWithArrowDown.tsx +14 -0
  10. package/src/Components/Icons/24x24/BoxWithDot.tsx +14 -0
  11. package/src/Components/Icons/24x24/OverflowingLines.tsx +14 -0
  12. package/src/Components/Icons/24x24/StepstatusIncomplete.tsx +14 -0
  13. package/src/Components/Icons/24x24/WrappedLines.tsx +14 -0
  14. package/src/Components/Icons/24x24/index.ts +5 -0
  15. package/src/Components/Table/Tr.tsx +1 -0
  16. package/src/Foundations/Sizes/Sizes.ts +0 -2
  17. package/src/Old/Base/Base.css +337 -0
  18. package/src/Old/Base/Base.tsx +199 -0
  19. package/src/Old/Flex/Flex.css +105 -0
  20. package/src/Old/Flex/Flex.tsx +92 -0
  21. package/src/Old/Placement/Placement.css +100 -0
  22. package/src/Old/Placement/Placement.tsx +74 -0
  23. package/src/Old/Placement/PlacementArea.tsx +49 -0
  24. package/src/Old/Placement/PlacementArrow.tsx +20 -0
  25. package/src/Old/Placement/PlacementArrowPropsContext.ts +9 -0
  26. package/src/Old/Placement/PlacementManager.tsx +24 -0
  27. package/src/Old/Placement/PlacementManagerContext.ts +9 -0
  28. package/src/Old/Placement/PlacementPopper.tsx +173 -0
  29. package/src/Old/Placement/PlacementReference.tsx +19 -0
  30. package/src/Old/hooks/index.ts +2 -0
  31. package/src/Old/hooks/useEventListener.ts +45 -0
  32. package/src/Old/hooks/useSyncedStateAndProps.ts +14 -0
  33. package/src/Old/variables.css +210 -0
  34. package/src/Old/variables.ts +320 -0
  35. package/src/index.ts +2 -4
  36. package/src/old.ts +16 -0
  37. package/src/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,199 @@
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import './Base.css';
4
+
5
+ export type TypeBorderRadius = 'x1' | 'x2' | 'x4' | 'rounded';
6
+
7
+ export const newToOld = {
8
+ 'neutral.100': 'white',
9
+ 'neutral.10': 'black',
10
+ 'neutral.95': 'gray-1',
11
+ 'neutral.93': 'gray-2',
12
+ 'neutral.90': 'gray-3',
13
+ 'neutral.80': 'gray-4',
14
+ 'neutral.70': 'gray-5',
15
+ 'neutral.50': 'gray-6',
16
+ 'neutral.40': 'gray-7',
17
+ 'neutral.30': 'gray-8',
18
+ 'turquoise.95': 'aqua-1',
19
+ 'turquoise.80': 'aqua-2',
20
+ 'turquoise.70': 'aqua-3',
21
+ 'turquoise.60': 'aqua-4',
22
+ 'turquoise.50': 'aqua-5',
23
+ 'purple.95': 'grape-1',
24
+ 'purple.70': 'grape-2',
25
+ 'purple.50': 'grape-3',
26
+ 'purple.30': 'grape-4',
27
+ 'purple.10': 'grape-5',
28
+ 'purple.40': 'eggplant',
29
+ 'red.93': 'red-1',
30
+ 'red.70': 'red-2',
31
+ 'red.50': 'red-3',
32
+ 'red.40': 'red-4',
33
+ 'red.30': 'red-5',
34
+ 'yellow.95': 'yellow-1',
35
+ 'yellow.90': 'yellow-2',
36
+ 'yellow.80': 'yellow-3',
37
+ 'yellow.70': 'yellow-4',
38
+ 'yellow.40': 'yellow-5',
39
+ 'green.95': 'green-1',
40
+ 'green.80': 'green-2',
41
+ 'green.60': 'green-3',
42
+ 'green.50': 'green-4',
43
+ 'green.40': 'green-5',
44
+ 'blue.93': 'blue-1',
45
+ 'blue.95': 'blue-95',
46
+ 'blue.70': 'blue-2',
47
+ 'blue.50': 'blue-3',
48
+ 'blue.40': 'blue-4',
49
+ 'blue.30': 'blue-5',
50
+ 'blue.60': 'darkblue-2',
51
+ 'blue.20': 'darkblue-4',
52
+ 'blue.10': 'darkblue-5',
53
+ 'purple.20': 'violet-5',
54
+ 'red.95': 'red-95',
55
+ 'orange-3': 'orange-3',
56
+ 'turquoise.40': 'turquoise-40',
57
+ } as const;
58
+
59
+ export type TypeColors = keyof typeof newToOld;
60
+
61
+ export type TypeSizes = 'x0' | 'x1' | 'x2' | 'x3' | 'x4' | 'x5' | 'x6' | 'x8' | 'x10' | 'x12' | 'x16';
62
+
63
+ export interface Props {
64
+ /**
65
+ * Sets the type of component to be rendered. Can be a
66
+ * string for an HTML tag or a React component.
67
+ * */
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ Component?: string | React.ComponentType<any>;
70
+ /** Absolute positioning, useful for quick centering in a relative surrounding. */
71
+ absolute?: boolean | 'center';
72
+ /** Sets the background color of any of the valid swatch colors. */
73
+ backgroundColor?: TypeColors;
74
+ /** Sets the border color of any of the valid swatch colors. */
75
+ borderColor?: TypeColors;
76
+ /** Sets the border radius to a multiple value. E.g. 'x1'. */
77
+ borderRadius?: TypeBorderRadius;
78
+ /** Sets the border radius to a multiple value. E.g. 'x1'. */
79
+ borderWidth?: 'x1' | 'x2' | 'x3';
80
+ /** Standard class name property. */
81
+ className?: string;
82
+ /** Sets the border radius to a multiple value. E.g. x1 */
83
+ clickable?: boolean;
84
+ /** Sets relative positioning */
85
+ container?: boolean;
86
+ /** Sets an elevated style with box-shadow, with a multiple value. E.g. x1 */
87
+ elevation?: 'x1' | 'x2' | 'x3';
88
+ /** Sets inline height styling */
89
+ height?: number | string;
90
+ /** Similar to other libraries, an alias to pass a ref to the final React element. */
91
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ innerRef?: React.Ref<any>;
93
+ /** Sets the margin to a multiple value. E.g. 'x1'. */
94
+ margin?: TypeSizes;
95
+ /** Sets inline max-height styling */
96
+ maxHeight?: number | string;
97
+ /** Sets inline max-width styling */
98
+ maxWidth?: number | string;
99
+ /** Sets inline min-height styling */
100
+ minHeight?: number | string;
101
+ /** Sets inline min-width styling */
102
+ minWidth?: number | string;
103
+ /** Sets the vertical and horizontal padding to a multiple value. E.g. 'x1'. */
104
+ padding?: TypeSizes;
105
+ /** Sets the horizontal padding to a multiple value. E.g. 'x1'. */
106
+ paddingHorizontal?: TypeSizes;
107
+ /** Sets the vertical padding to a multiple value. E.g. 'x1'. */
108
+ paddingVertical?: TypeSizes;
109
+ /** Sets the overflow */
110
+ overflow?: 'hidden' | 'scroll' | 'auto';
111
+ /** Standard style property. */
112
+ style?: React.CSSProperties | { [key: string]: number | string };
113
+ /** @ignore */
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+ ref?: React.Ref<any>;
116
+ /** Sets the font color of any of the valid swatch colors. */
117
+ textColor?: TypeColors;
118
+ /** Sets inline width styling */
119
+ width?: number | string;
120
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
121
+ [key: string]: any;
122
+ }
123
+
124
+ /**
125
+ * The Base component is the end of the line for all components and
126
+ * provides general and utility like styling.
127
+ * */
128
+ const Base: React.FunctionComponent<Props> = (props: Props) => {
129
+ const {
130
+ Component,
131
+ absolute,
132
+ backgroundColor,
133
+ borderColor,
134
+ borderWidth = borderColor ? 'x1' : undefined,
135
+ borderRadius,
136
+ children,
137
+ className,
138
+ clickable,
139
+ container,
140
+ elevation,
141
+ height,
142
+ innerRef,
143
+ margin,
144
+ maxHeight,
145
+ maxWidth,
146
+ minHeight,
147
+ minWidth,
148
+ padding,
149
+ paddingHorizontal = padding,
150
+ paddingVertical = padding,
151
+ overflow,
152
+ style,
153
+ textColor,
154
+ width,
155
+ ...rest
156
+ } = props;
157
+
158
+ const FinalComponent = Component || 'div';
159
+ const classes = classnames(
160
+ 'Base',
161
+ {
162
+ 'Base--absolute': absolute === true,
163
+ [`Base--absolute-${absolute}`]: typeof absolute === 'string',
164
+ [`Base--background-color-${newToOld[backgroundColor!]}`]: backgroundColor,
165
+ [`Base--border-radius-${borderRadius}`]: borderRadius,
166
+ [`Base--border-color-${newToOld[borderColor!]}`]: borderColor,
167
+ [`Base--border-width-${borderWidth}`]: borderWidth,
168
+ 'Base--clickable': clickable,
169
+ 'Base--container': container,
170
+ [`Base--elevation-${elevation}`]: elevation,
171
+ [`Base--margin-${margin}`]: margin,
172
+ 'Base--max-width': maxWidth,
173
+ [`Base--overflow-${overflow}`]: overflow,
174
+ [`Base--padding-horizontal-${paddingHorizontal}`]: paddingHorizontal,
175
+ [`Base--padding-vertical-${paddingVertical}`]: paddingVertical,
176
+ [`Base--text-color-${newToOld[textColor!]}`]: textColor,
177
+ },
178
+ className,
179
+ );
180
+
181
+ // Work around for findDOMNode area causing constant renders. Forwards
182
+ // refs for component compositions.
183
+ if (typeof FinalComponent === 'string') {
184
+ rest.ref = innerRef;
185
+ delete rest.innerRef;
186
+ }
187
+
188
+ return (
189
+ <FinalComponent
190
+ {...rest}
191
+ className={classes}
192
+ style={{ ...style, height, maxHeight, maxWidth, minHeight, minWidth, width }}
193
+ >
194
+ {children}
195
+ </FinalComponent>
196
+ );
197
+ };
198
+
199
+ export default Base;
@@ -0,0 +1,105 @@
1
+ /* stylelint-disable selector-max-universal */
2
+
3
+ .Flex { flex: 0 0 auto; }
4
+
5
+ .Flex--grow,
6
+ .Flex--grow-x1 {
7
+ flex-grow: 1;
8
+ }
9
+
10
+ .Flex--grow-x2 { flex-grow: 2; }
11
+ .Flex--grow-x3 { flex-grow: 3; }
12
+ .Flex--grow-x4 { flex-grow: 4; }
13
+
14
+ .Flex--shrink,
15
+ .Flex--shrink-x1,
16
+ .Flex--shrink-x2,
17
+ .Flex--shrink-x3,
18
+ .Flex--shrink-x4 {
19
+ min-width: 0;
20
+ }
21
+
22
+ .Flex--shrink,
23
+ .Flex--shrink-x1 {
24
+ flex-shrink: 1;
25
+ }
26
+
27
+ .Flex--shrink-x2 { flex-shrink: 2; }
28
+ .Flex--shrink-x3 { flex-shrink: 3; }
29
+ .Flex--shrink-x4 { flex-shrink: 4; }
30
+
31
+ .Flex--initial-none { flex-basis: 0%; }
32
+ .Flex--initial-content { flex-basis: auto; }
33
+ .Flex--initial-container { flex-basis: 100%; }
34
+
35
+ .Flex--horizontal,
36
+ .Flex--vertical {
37
+ display: flex;
38
+ }
39
+
40
+ .Flex--wrap { flex-wrap: wrap; }
41
+
42
+ .Flex--horizontal > .Flex--initial-none { width: 0; }
43
+ .Flex--vertical > .Flex--initial-none { height: 0; }
44
+
45
+ .Flex--horizontal { flex-direction: row; }
46
+ .Flex--vertical { flex-direction: column; }
47
+ .Flex--horizontal.Flex--reverse { flex-direction: row-reverse; }
48
+ .Flex--vertical.Flex--reverse { flex-direction: column-reverse; }
49
+
50
+ .Flex--align-self-start { align-self: flex-start; }
51
+ .Flex--align-self-middle { align-self: center; }
52
+ .Flex--align-self-end { align-self: flex-end; }
53
+
54
+ .Flex--horizontal.Flex--align-horz-start { justify-content: flex-start; }
55
+ .Flex--horizontal.Flex--align-horz-middle { justify-content: center; }
56
+ .Flex--horizontal.Flex--align-horz-end { justify-content: flex-end; }
57
+ .Flex--horizontal.Flex--align-horz-around { justify-content: space-around; }
58
+ .Flex--horizontal.Flex--align-horz-between { justify-content: space-between; }
59
+
60
+ .Flex--horizontal.Flex--align-vert-start { align-items: flex-start; }
61
+ .Flex--horizontal.Flex--align-vert-middle { align-items: center; }
62
+ .Flex--horizontal.Flex--align-vert-end { align-items: flex-end; }
63
+ .Flex--horizontal.Flex--align-vert-baseline { align-items: baseline; }
64
+
65
+ .Flex--vertical.Flex--align-horz-start { align-items: flex-start; }
66
+ .Flex--vertical.Flex--align-horz-middle { align-items: center; }
67
+ .Flex--vertical.Flex--align-horz-end { align-items: flex-end; }
68
+
69
+ .Flex--vertical.Flex--align-vert-start { justify-content: flex-start; }
70
+ .Flex--vertical.Flex--align-vert-middle { justify-content: center; }
71
+ .Flex--vertical.Flex--align-vert-end { justify-content: flex-end; }
72
+ .Flex--vertical.Flex--align-vert-around { justify-content: space-around; }
73
+ .Flex--vertical.Flex--align-vert-between { justify-content: space-between; }
74
+
75
+ .Flex--vertical.Flex--gap-x1 > * { margin: calc(var(--size--x1) * 0.5) 0; }
76
+ .Flex--vertical.Flex--gap-x2 > * { margin: calc(var(--size--x2) * 0.5) 0; }
77
+ .Flex--vertical.Flex--gap-x3 > * { margin: calc(var(--size--x3) * 0.5) 0; }
78
+ .Flex--vertical.Flex--gap-x4 > * { margin: calc(var(--size--x4) * 0.5) 0; }
79
+ .Flex--vertical.Flex--gap-x5 > * { margin: calc(var(--size--x5) * 0.5) 0; }
80
+ .Flex--vertical.Flex--gap-x6 > * { margin: calc(var(--size--x6) * 0.5) 0; }
81
+ .Flex--vertical.Flex--gap-x8 > * { margin: calc(var(--size--x8) * 0.5) 0; }
82
+ .Flex--vertical.Flex--gap-x10 > * { margin: calc(var(--size--x10) * 0.5) 0; }
83
+ .Flex--vertical.Flex--gap-x12 > * { margin: calc(var(--size--x12) * 0.5) 0; }
84
+ .Flex--vertical.Flex--gap-x16 > * { margin: calc(var(--size--x16) * 0.5) 0; }
85
+
86
+ .Flex--horizontal.Flex--gap-x1 > * { margin: 0 calc(var(--size--x1) * 0.5); }
87
+ .Flex--horizontal.Flex--gap-x2 > * { margin: 0 calc(var(--size--x2) * 0.5); }
88
+ .Flex--horizontal.Flex--gap-x3 > * { margin: 0 calc(var(--size--x3) * 0.5); }
89
+ .Flex--horizontal.Flex--gap-x4 > * { margin: 0 calc(var(--size--x4) * 0.5); }
90
+ .Flex--horizontal.Flex--gap-x5 > * { margin: 0 calc(var(--size--x5) * 0.5); }
91
+ .Flex--horizontal.Flex--gap-x6 > * { margin: 0 calc(var(--size--x6) * 0.5); }
92
+ .Flex--horizontal.Flex--gap-x8 > * { margin: 0 calc(var(--size--x8) * 0.5); }
93
+ .Flex--horizontal.Flex--gap-x10 > * { margin: 0 calc(var(--size--x10) * 0.5); }
94
+ .Flex--horizontal.Flex--gap-x12 > * { margin: 0 calc(var(--size--x12) * 0.5); }
95
+ .Flex--horizontal.Flex--gap-x16 > * { margin: 0 calc(var(--size--x16) * 0.5); }
96
+
97
+ .Flex--gapped.Flex--vertical:not(.Flex--reverse) > *:first-child { margin-top: 0; }
98
+ .Flex--gapped.Flex--vertical:not(.Flex--reverse) > *:last-child { margin-bottom: 0; }
99
+ .Flex--gapped.Flex--vertical.Flex--reverse > *:first-child { margin-bottom: 0; }
100
+ .Flex--gapped.Flex--vertical.Flex--reverse > *:last-child { margin-top: 0; }
101
+
102
+ .Flex--gapped.Flex--horizontal:not(.Flex--reverse) > *:first-child { margin-left: 0; }
103
+ .Flex--gapped.Flex--horizontal:not(.Flex--reverse) > *:last-child { margin-right: 0; }
104
+ .Flex--gapped.Flex--horizontal.Flex--reverse > *:first-child { margin-right: 0; }
105
+ .Flex--gapped.Flex--horizontal.Flex--reverse > *:last-child { margin-left: 0; }
@@ -0,0 +1,92 @@
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import Base, { Props as BaseProps, TypeSizes } from '../Base/Base';
4
+ import './Flex.css';
5
+
6
+ export interface Props extends BaseProps {
7
+ /**
8
+ * Used on a parent, sets both the horizontal and vertical alignment of flex children.
9
+ * Must be used in conjuction with the 'direction' prop.
10
+ * */
11
+ alignChildren?: 'start' | 'middle' | 'end';
12
+ /**
13
+ * Used on a parent, sets both the horizontal alignment of flex children.
14
+ * Must be used in conjuction with the 'direction' prop.
15
+ * */
16
+ alignChildrenHorizontal?: 'start' | 'middle' | 'end' | 'around' | 'between';
17
+ /**
18
+ * Used on a parent, sets both the vertical alignment of flex children.
19
+ * Must be used in conjuction with the 'direction' prop.
20
+ * */
21
+ alignChildrenVertical?: 'start' | 'middle' | 'end' | 'around' | 'between' | 'baseline';
22
+ /**
23
+ * Set the alignment of a flex child. Must be used inside a parent
24
+ * using the 'direction' prop.
25
+ */
26
+ alignSelf?: 'start' | 'middle' | 'end';
27
+ /** @ignore */
28
+ className?: string;
29
+ /** Used on a parent, activates flex behaviour for children. */
30
+ direction?: 'horizontal' | 'vertical';
31
+ /** Used on a parent, reverses the layout direction */
32
+ reverse?: boolean;
33
+ /**
34
+ * Used on a parent, sets the distances between flex children to
35
+ * a multiple value. E.g. 'x1'.
36
+ */
37
+ gap?: TypeSizes;
38
+ /** Sets a child to grow from it's initial width. (flex-grow: 1;) */
39
+ grow?: boolean | 'x1' | 'x2' | 'x3' | 'x4';
40
+ /** Sets a childs initial width before flex calculations. (flex-basis) */
41
+ initial?: 'content' | 'container' | 'none';
42
+ /** Sets a child to shrink from it's initial width. (flex-shrink: 1;) */
43
+ shrink?: boolean | 'x1' | 'x2' | 'x3' | 'x4';
44
+ /** Used on a parent, allows it's children to wrap onto new rows.. */
45
+ wrap?: boolean;
46
+ }
47
+
48
+ /**
49
+ * A useful and quick Flex component for handling
50
+ * frequent and common layouts of all sizes.
51
+ */
52
+ const Flex: React.FunctionComponent<Props> = (props: Props) => {
53
+ const {
54
+ alignChildren,
55
+ alignChildrenHorizontal = alignChildren,
56
+ alignChildrenVertical = alignChildren,
57
+ alignSelf,
58
+ className,
59
+ direction,
60
+ reverse,
61
+ grow,
62
+ gap,
63
+ initial,
64
+ shrink,
65
+ wrap,
66
+ ...rest
67
+ } = props;
68
+
69
+ const classes = classnames(
70
+ 'Flex',
71
+ {
72
+ [`Flex--align-horz-${alignChildrenHorizontal}`]: alignChildrenHorizontal,
73
+ [`Flex--align-self-${alignSelf}`]: alignSelf,
74
+ [`Flex--align-vert-${alignChildrenVertical}`]: alignChildrenVertical,
75
+ [`Flex--${direction}`]: direction,
76
+ [`Flex--initial-${initial}`]: initial,
77
+ 'Flex--gapped': gap,
78
+ [`Flex--gap-${gap}`]: gap,
79
+ 'Flex--reverse': reverse,
80
+ 'Flex--grow': grow === true,
81
+ [`Flex--grow-${grow}`]: typeof grow === 'string',
82
+ 'Flex--shrink': shrink === true,
83
+ [`Flex--shrink-${shrink}`]: typeof shrink === 'string',
84
+ 'Flex--wrap': wrap,
85
+ },
86
+ className,
87
+ );
88
+
89
+ return <Base {...rest} className={classes} />;
90
+ };
91
+
92
+ export default Flex;
@@ -0,0 +1,100 @@
1
+
2
+ .Placement {
3
+ position: absolute;
4
+ z-index: var(--z-index-Placement--below-modal);
5
+ }
6
+
7
+ .Placement--above-modal {
8
+ z-index: var(--z-index-Placement--above-modal);
9
+ }
10
+
11
+ .Placement--top .Placement__content { transform: translateY(calc(var(--size--x4) * -1)); }
12
+ .Placement--bottom .Placement__content { transform: translateY(var(--size--x4)); }
13
+
14
+ .Placement .Placement__content-appear-active,
15
+ .Placement .Placement__content-appear-done,
16
+ .Placement .Placement__content-enter-active,
17
+ .Placement .Placement__content-enter-done,
18
+ .Placement .Placement__content-exit {
19
+ transform: translateY(0);
20
+ opacity: 1;
21
+ pointer-events: all;
22
+ }
23
+
24
+ .Placement--top .Placement__content-appear,
25
+ .Placement--top .Placement__content-enter,
26
+ .Placement--top .Placement__content-exit-active,
27
+ .Placement--top .Placement__content-exit-done {
28
+ transform: translateY(calc(var(--size--x4) * -1));
29
+ opacity: 0;
30
+ }
31
+
32
+ .Placement--bottom .Placement__content-appear,
33
+ .Placement--bottom .Placement__content-enter,
34
+ .Placement--bottom .Placement__content-exit-active,
35
+ .Placement--bottom .Placement__content-exit-done {
36
+ transform: translateY(var(--size--x4));
37
+ opacity: 0;
38
+ }
39
+
40
+ .Placement__shadow {
41
+ border-radius: var(--size--x2);
42
+ filter: drop-shadow(0 0.125rem 0.3125rem rgba(199, 205, 207, 0.7));
43
+ }
44
+
45
+ .Placement__area--horizontal .Placement__area:not(:last-child) {
46
+ border-right: 0.0625rem solid var(--color-gray--2);
47
+ }
48
+
49
+ .Placement__area--vertical .Placement__area:not(:last-child) {
50
+ border-top: 0.0625rem solid var(--color-gray--2);
51
+ }
52
+
53
+ .Placement__arrow,
54
+ .Placement__arrow::before {
55
+ position: absolute;
56
+ width: var(--size--x3);
57
+ height: var(--size--x3);
58
+ }
59
+
60
+ .Placement__arrow,
61
+ .Placement__arrow:first-child,
62
+ .Placement__arrow:last-child {
63
+ visibility: hidden;
64
+ }
65
+
66
+ .Placement__arrow::before {
67
+ content: '';
68
+ display: block;
69
+ transform: rotate(45deg);
70
+ background: inherit;
71
+ visibility: visible;
72
+ }
73
+
74
+ .Placement--top .Placement__arrow,
75
+ .Placement--top-start .Placement__arrow,
76
+ .Placement--top-end .Placement__arrow {
77
+ top: 100%;
78
+ margin-top: -0.375rem;
79
+ }
80
+
81
+ .Placement--right .Placement__arrow,
82
+ .Placement--right-start .Placement__arrow,
83
+ .Placement--right-end .Placement__arrow {
84
+ right: 100%;
85
+ margin-right: -0.375rem;
86
+ }
87
+
88
+ .Placement--bottom .Placement__arrow,
89
+ .Placement--bottom-start .Placement__arrow,
90
+ .Placement--bottom-end .Placement__arrow {
91
+ bottom: 100%;
92
+ margin-bottom: -0.375rem;
93
+ }
94
+
95
+ .Placement--left .Placement__arrow,
96
+ .Placement--left-start .Placement__arrow,
97
+ .Placement--left-end .Placement__arrow {
98
+ left: 100%;
99
+ margin-left: -0.375rem;
100
+ }
@@ -0,0 +1,74 @@
1
+ import * as React from 'react';
2
+ import { Placement as TypePlacement } from '@popperjs/core';
3
+ import { Props as BaseProps } from '../Base/Base';
4
+ import PlacementPopper from './PlacementPopper';
5
+ import './Placement.css';
6
+
7
+ export interface Props extends BaseProps {
8
+ /**
9
+ * Flag that enables CSS animations ont he top level
10
+ * transform positioning.
11
+ */
12
+ animatePosition?: boolean;
13
+ /**
14
+ * A render callback function that provides a
15
+ * update function to trigger a reposition,
16
+ * and the width of the target that is being positioned
17
+ * around.
18
+ */
19
+ children: (props: { update: () => void; width?: number }) => React.ReactNode;
20
+ /**
21
+ * Flag that disables repositioning on scroll and resize events.
22
+ */
23
+ disableReposition?: boolean;
24
+ /**
25
+ * Flag that enables flipping the positioned content to the
26
+ * other side when there is not enough room on the screen.
27
+ */
28
+ flip?: boolean;
29
+ /**
30
+ * A callback that is called when the component is
31
+ * in a visible state and the area around it has been clicked on.
32
+ */
33
+ onClose?: (event: MouseEvent) => void;
34
+ /**
35
+ * The desired placement of the positioned content, note that if there
36
+ * is not sufficient room and an a better alternative is available it
37
+ * might not be used.
38
+ */
39
+ placement?: TypePlacement;
40
+ /**
41
+ * An optional reference element to be used as the target.
42
+ */
43
+ referenceElement?: any;
44
+ sameWidth?: boolean;
45
+ /**
46
+ * The visibilty of the positioned content.
47
+ */
48
+ visible?: boolean;
49
+ /**
50
+ * The desired animation speed on milliseconds.
51
+ */
52
+ timeout?: number;
53
+ }
54
+
55
+ /**
56
+ * The Placement component is used to absolutely position content on the
57
+ * screen around another target. Under the hood it uses the positioning
58
+ * engine library called Popper.js.
59
+ *
60
+ * When the positioning target is another DOM element on the screen the
61
+ * Placement component should be used in conjunction with PlacementManager
62
+ * and PlacementReference. If the target is an existing reference element
63
+ * it can be used by iteself by using the referenceElement prop.
64
+ */
65
+ const Placement: React.FunctionComponent<Props> = (props: Props) => (
66
+ <PlacementPopper {...props} closeElement={null} isInsideModal={false} />
67
+ );
68
+
69
+ Placement.defaultProps = {
70
+ flip: true,
71
+ visible: true,
72
+ };
73
+
74
+ export default Placement;
@@ -0,0 +1,49 @@
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import Flex, { Props as FlexProps } from '../Flex/Flex';
4
+ import PlacementArrow from './PlacementArrow';
5
+
6
+ export interface Props extends FlexProps {
7
+ /**
8
+ * When used as a container for multiple PlacementAreas
9
+ * the direction can be set to split with a dividing line
10
+ * either horizontally or vertically.
11
+ */
12
+ direction?: 'horizontal' | 'vertical';
13
+ /**
14
+ * Inserts the dynamically positioned arrow/tip.
15
+ */
16
+ withArrow?: boolean;
17
+ }
18
+
19
+ /**
20
+ * The content area(s) of the placed element. This acts as the main
21
+ * container for the content as well as the optional arrow that is dynamically
22
+ * positioned. This component can also act as a parent to other PlacementAreas
23
+ * when the content should be divided (see direction prop).
24
+ */
25
+ const PlacementArea: React.FunctionComponent<Props> = (props: Props) => {
26
+ const { children, direction, padding, paddingHorizontal, paddingVertical, withArrow, ...rest } = props;
27
+
28
+ const classes = classnames('Placement__area', {
29
+ [`Placement__area--${direction}`]: direction,
30
+ });
31
+
32
+ return (
33
+ <Flex {...rest} className={classes}>
34
+ {withArrow && <PlacementArrow />}
35
+
36
+ <Flex
37
+ className="Placement__area-content"
38
+ direction={direction}
39
+ padding={padding}
40
+ paddingHorizontal={paddingHorizontal}
41
+ paddingVertical={paddingVertical}
42
+ >
43
+ {children}
44
+ </Flex>
45
+ </Flex>
46
+ );
47
+ };
48
+
49
+ export default PlacementArea;
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import Base, { Props as BaseProps } from '../Base/Base';
3
+ import { PlacementArrowPropsContext } from './PlacementArrowPropsContext';
4
+
5
+ export type Props = BaseProps;
6
+
7
+ /**
8
+ * The dynamically positioned arrow/tip.
9
+ */
10
+ const PlacementArrow: React.FunctionComponent<Props> = (props: Props) => {
11
+ return (
12
+ <PlacementArrowPropsContext.Consumer>
13
+ {({ backgroundColor, ref, style }) => (
14
+ <Base {...props} backgroundColor={backgroundColor} className="Placement__arrow" innerRef={ref} style={style} />
15
+ )}
16
+ </PlacementArrowPropsContext.Consumer>
17
+ );
18
+ };
19
+
20
+ export default PlacementArrow;
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+ import { PopperArrowProps } from 'react-popper';
3
+ import { TypeColors } from '../Base/Base';
4
+
5
+ export const PlacementArrowPropsContext = createContext<PopperArrowProps & { backgroundColor?: TypeColors }>({
6
+ backgroundColor: 'neutral.95',
7
+ ref: () => {},
8
+ style: {},
9
+ });
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { Manager, ManagerProps } from 'react-popper';
3
+ import { PlacementManagerContext } from './PlacementManagerContext';
4
+
5
+ const { useState } = React;
6
+
7
+ export type Props = ManagerProps;
8
+
9
+ /**
10
+ * The manager component handles the ref communication between
11
+ * the Placement and PlacementReference components.
12
+ */
13
+ const PlacementManager: React.FunctionComponent<Props> = (props: Props) => {
14
+ const [referenceNode, setReferenceNode] = useState<null | HTMLElement>(null);
15
+
16
+ return (
17
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
18
+ <PlacementManagerContext.Provider value={{ referenceNode, setReferenceNode }}>
19
+ <Manager {...props} />
20
+ </PlacementManagerContext.Provider>
21
+ );
22
+ };
23
+
24
+ export default PlacementManager;
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+
3
+ export const PlacementManagerContext = createContext<{
4
+ referenceNode: HTMLElement | null;
5
+ setReferenceNode(referenceNode: HTMLElement | null): void;
6
+ }>({
7
+ referenceNode: null,
8
+ setReferenceNode: () => {},
9
+ });