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

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.
@@ -1,92 +0,0 @@
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;
@@ -1,100 +0,0 @@
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
- }
@@ -1,74 +0,0 @@
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;
@@ -1,49 +0,0 @@
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;
@@ -1,20 +0,0 @@
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;
@@ -1,9 +0,0 @@
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
- });
@@ -1,24 +0,0 @@
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;
@@ -1,9 +0,0 @@
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
- });
@@ -1,173 +0,0 @@
1
- /* eslint-disable react/default-props-match-prop-types */
2
- import * as React from 'react';
3
- import { createPortal } from 'react-dom';
4
- import { Placement as TypePlacement, VirtualElement } from '@popperjs/core';
5
- import { Popper, PopperProps } from 'react-popper';
6
- import classnames from 'classnames';
7
- import { useEventListener } from '../hooks';
8
- import Base, { Props as BaseProps } from '../Base/Base';
9
- import { PlacementArrowPropsContext } from './PlacementArrowPropsContext';
10
- import { PlacementManagerContext } from './PlacementManagerContext';
11
- import './Placement.css';
12
-
13
- const { useEffect, useRef, useState } = React;
14
-
15
- export interface Props extends BaseProps {
16
- animatePosition?: boolean;
17
- children: (props: { update: () => void; width?: number }) => React.ReactNode;
18
- closeElement?: null | HTMLElement;
19
- disableReposition?: boolean;
20
- flip?: boolean;
21
- isInsideModal?: boolean;
22
- onClose?: (event: MouseEvent) => void;
23
- placement?: TypePlacement;
24
- referenceElement?: any;
25
- visible?: boolean;
26
- timeout?: number;
27
- }
28
-
29
- const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
30
- const {
31
- animatePosition,
32
- backgroundColor,
33
- children,
34
- closeElement,
35
- disableReposition,
36
- flip,
37
- isInsideModal,
38
- onClose,
39
- placement: desiredPlacement,
40
- referenceElement,
41
- sameWidth,
42
- visible,
43
- ...rest
44
- } = props;
45
-
46
- const ref = useRef<HTMLElement | null>();
47
- const [render, setRender] = useState(visible);
48
-
49
- const [reference, setReference] = useState<Element | VirtualElement | undefined>(undefined);
50
-
51
- useEffect(() => {
52
- if (visible) {
53
- setRender(true);
54
- }
55
- }, [visible]);
56
-
57
- useEventListener(
58
- closeElement || document,
59
- 'click',
60
- (event) => {
61
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
62
- /* @ts-ignore */
63
- const isReferenceInPath = [...event.composedPath()].includes(reference);
64
- if (onClose && ref.current && !ref.current.contains(event.target as Node) && !isReferenceInPath) {
65
- onClose(event as MouseEvent);
66
- }
67
- },
68
- [onClose, reference],
69
- );
70
-
71
- useEventListener(
72
- ref.current || null,
73
- 'transitionend',
74
- () => {
75
- if (!visible) {
76
- setRender(false);
77
- }
78
- },
79
- [visible],
80
- );
81
-
82
- if (!render) {
83
- return null;
84
- }
85
-
86
- const modifiers: any[] = [
87
- {
88
- name: 'offset',
89
- options: {
90
- offset: [0, 12],
91
- },
92
- },
93
- ];
94
-
95
- if (sameWidth) {
96
- modifiers.push({
97
- enabled: true,
98
- name: 'sameWidth',
99
- phase: 'beforeWrite',
100
- requires: ['computeStyles'],
101
- fn: ({ state }: any) => {
102
- // eslint-disable-next-line no-param-reassign
103
- state.styles.popper.width = `${state.rects.reference.width}px`;
104
- },
105
- effect: ({ state }: any) => {
106
- // eslint-disable-next-line no-param-reassign
107
- state.elements.popper.style.width = `${state.elements.reference.getBoundingClientRect().width || 0}px`;
108
- },
109
- });
110
- }
111
-
112
- const popperProps: PopperProps<any> = {
113
- children: () => null,
114
- placement: desiredPlacement,
115
- modifiers,
116
- };
117
-
118
- if (referenceElement) {
119
- popperProps.referenceElement = referenceElement;
120
- }
121
-
122
- return createPortal(
123
- // eslint-disable-next-line no-return-assign
124
- <Popper
125
- {...popperProps}
126
- // eslint-disable-next-line no-return-assign
127
- innerRef={(el) => (ref.current = el || null)}
128
- onFirstUpdate={(state) => {
129
- setReference(state.elements?.reference);
130
- }}
131
- >
132
- {/* eslint-disable-next-line @typescript-eslint/no-shadow */}
133
- {({ arrowProps, placement, ref, update, style }) => {
134
- return (
135
- // eslint-disable-next-line react/jsx-no-constructed-context-values
136
- <PlacementArrowPropsContext.Provider value={{ ...arrowProps, backgroundColor }}>
137
- <div
138
- className={classnames('Placement', `Placement--${placement}`, {
139
- 'Placement--above-modal': isInsideModal,
140
- 'Placement--animate': animatePosition,
141
- })}
142
- ref={ref}
143
- style={style}
144
- >
145
- {visible && (
146
- <div className="Placement__content">
147
- <Base {...rest} backgroundColor={backgroundColor} className="Placement__shadow">
148
- <PlacementManagerContext.Consumer>
149
- {({ referenceNode }) =>
150
- children({
151
- update,
152
- width: (referenceNode && referenceNode.clientWidth) || undefined,
153
- })
154
- }
155
- </PlacementManagerContext.Consumer>
156
- </Base>
157
- </div>
158
- )}
159
- </div>
160
- </PlacementArrowPropsContext.Provider>
161
- );
162
- }}
163
- </Popper>,
164
- document.body,
165
- );
166
- };
167
-
168
- PlacementPopper.defaultProps = {
169
- backgroundColor: 'neutral.100',
170
- borderRadius: 'x2',
171
- };
172
-
173
- export default PlacementPopper;
@@ -1,19 +0,0 @@
1
- import * as React from 'react';
2
- import { Reference, ReferenceProps } from 'react-popper';
3
- import { PlacementManagerContext } from './PlacementManagerContext';
4
-
5
- export type Props = ReferenceProps;
6
-
7
- /**
8
- * The reference component handles setting the target element ref with the
9
- * PlacementManager.
10
- */
11
- const PlacementReference: React.FunctionComponent<Props> = (props: Props) => {
12
- return (
13
- <PlacementManagerContext.Consumer>
14
- {({ setReferenceNode }) => <Reference {...props} innerRef={setReferenceNode} />}
15
- </PlacementManagerContext.Consumer>
16
- );
17
- };
18
-
19
- export default PlacementReference;
@@ -1,2 +0,0 @@
1
- export { default as useEventListener } from './useEventListener';
2
- export { default as useSyncedStateAndProps } from './useSyncedStateAndProps';
@@ -1,45 +0,0 @@
1
- import { useEffect } from 'react';
2
-
3
- type HTMLElementOrDocumentOrWindow = HTMLElement | Document | Window;
4
- interface HTMLElementOrDocumentOrWindowEventMap extends HTMLElementEventMap, DocumentEventMap, WindowEventMap {}
5
-
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- function useEventListener<E extends Window, K extends keyof WindowEventMap>(
8
- el: E | null | undefined,
9
- type: K,
10
- handler: (evnt: WindowEventMap[K]) => void,
11
- watch?: any[],
12
- ): void;
13
- function useEventListener<E extends Document, K extends keyof DocumentEventMap>(
14
- el: E | null | undefined,
15
- type: K,
16
- handler: (evt: DocumentEventMap[K]) => void,
17
- watch?: any[],
18
- ): void;
19
- function useEventListener<E extends HTMLElement, K extends keyof HTMLElementEventMap>(
20
- el: E | null | undefined,
21
- type: K,
22
- handler: (evt: HTMLElementEventMap[K]) => void,
23
- watch?: any[],
24
- ): void;
25
- function useEventListener<K extends keyof HTMLElementOrDocumentOrWindowEventMap>(
26
- el: HTMLElementOrDocumentOrWindow,
27
- type: string,
28
- handler: (evt: HTMLElementOrDocumentOrWindowEventMap[K]) => void,
29
- watch?: any[],
30
- ): void;
31
- function useEventListener(el: any, type: string, handler: any, watch?: any[]) {
32
- useEffect(() => {
33
- if (el) {
34
- el.addEventListener(type, handler);
35
- }
36
-
37
- return () => {
38
- if (el) {
39
- el.removeEventListener(type, handler);
40
- }
41
- };
42
- }, watch || []);
43
- }
44
-
45
- export default useEventListener;
@@ -1,14 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- export default (prop: any) => {
5
- const [state, setState] = useState(prop);
6
-
7
- useEffect(() => {
8
- if (state !== prop) {
9
- setState(prop);
10
- }
11
- }, [prop]);
12
-
13
- return [state, setState];
14
- };