diff --git a/src/a11y/a11y.js.flow b/src/a11y/a11y.js.flow
deleted file mode 100644
index d434330073..0000000000
--- a/src/a11y/a11y.js.flow
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-/* global document cancelIdleCallback requestIdleCallback */
-
-import * as React from 'react';
-import axe from 'axe-core';
-
-import { Layer, TetherBehavior, TETHER_PLACEMENT } from '../layer/index.js';
-import { ParagraphSmall, ParagraphXSmall } from '../typography/index.js';
-import { styled } from '../styles/index.js';
-import { ThemeContext } from '../styles/theme-provider.js';
-
-import type { ViolationPropsT } from './types.js';
-
-function validateNode(node) {
- return new Promise((resolve, reject) => {
- axe.run(node, { reporter: 'v2' }, (error, results) => {
- if (error) reject(error);
- resolve(results.violations);
- });
- });
-}
-
-function segmentViolationsByNode(violations) {
- const nodes = violations.reduce((map, violation) => {
- violation.nodes.forEach((node) => {
- if (!map[node.target]) {
- map[node.target] = [violation];
- } else {
- map[node.target] = map[node.target].push(violation);
- }
- });
- return map;
- }, {});
- return Object.entries(nodes);
-}
-
-const ViolationContainer = styled<{ $top: string, $left: string }>(
- 'div',
- ({ $theme, $top, $left }) => {
- return {
- backgroundColor: $theme.colors.backgroundPrimary,
- boxShadow: $theme.lighting.shadow600,
- position: 'absolute',
- padding: $theme.sizing.scale400,
- top: $top,
- left: $left,
- };
- }
-);
-
-function Violation(props: ViolationPropsT) {
- const [offset, setOffset] = React.useState({ top: 0, left: 0 });
- const [anchor, setAnchor] = React.useState(null);
- const [popper, setPopper] = React.useState(null);
- const [isHovered, setIsHovered] = React.useState(false);
- const theme = React.useContext(ThemeContext);
-
- const handleMouseEnter = () => setIsHovered(true);
- const handleMouseLeave = () => setIsHovered(false);
-
- React.useEffect(() => {
- const node = document.querySelector(props.target);
- if (node) {
- setAnchor(node);
-
- node.setAttribute('style', `border: solid 1px ${theme.colors.borderNegative};`);
-
- node.addEventListener('mouseenter', handleMouseEnter);
- node.addEventListener('mouseleave', handleMouseLeave);
- }
-
- return () => {
- if (node) {
- node.removeEventListener('mouseenter', handleMouseEnter);
- node.removeEventListener('mouseleave', handleMouseLeave);
- }
- };
- }, [props.target]);
-
- if (!isHovered) return null;
-
- return (
-
- setOffset(update.popper)}
- placement={TETHER_PLACEMENT.bottom}
- >
-
- {props.target}
- {props.violations.map((violation, index) => (
- {violation.description}
- ))}
-
-
-
- );
-}
-
-export default function A11y(props: { children: React.Node }) {
- const [violations, setViolations] = React.useState([]);
- const [idleID, setIdleID] = React.useState(null);
- const child = React.useRef(null);
- React.useEffect(() => {
- if (child.current) {
- if (idleID) {
- cancelIdleCallback(idleID);
- setIdleID(null);
- }
-
- const id = requestIdleCallback(() => {
- validateNode(child.current).then(setViolations);
- });
- setIdleID(id);
- }
- }, [props.children]);
-
- const violationsByNode = segmentViolationsByNode(violations);
-
- return (
- <>
- {props.children}
-
- {violationsByNode.map(([node, violations], index) => (
- // flowlint-next-line unclear-type:off
-
- ))}
-
- >
- );
-}
diff --git a/src/a11y/index.js.flow b/src/a11y/index.js.flow
deleted file mode 100644
index bc20ff34e1..0000000000
--- a/src/a11y/index.js.flow
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { default as Unstable_A11y } from './a11y.js';
diff --git a/src/a11y/types.js.flow b/src/a11y/types.js.flow
deleted file mode 100644
index cbfb1d92de..0000000000
--- a/src/a11y/types.js.flow
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-type NodeT = { target: string };
-type ViolationT = { description: string, nodes: NodeT };
-
-export type ViolationPropsT = {
- target: string,
- violations: Array,
-};
diff --git a/src/accordion/accordion.js.flow b/src/accordion/accordion.js.flow
deleted file mode 100644
index 39c47f1f61..0000000000
--- a/src/accordion/accordion.js.flow
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { getOverrides } from '../helpers/overrides.js';
-import { Root as StyledRoot } from './styled-components.js';
-import { STATE_CHANGE_TYPE } from './constants.js';
-import type { AccordionPropsT, AccordionStateT, StateChangeTypeT } from './types.js';
-
-export default class Accordion extends React.Component {
- static defaultProps: $Shape = {
- accordion: true,
- disabled: false,
- initialState: {
- expanded: [],
- },
- onChange: () => {},
- overrides: {},
- renderAll: false,
- stateReducer: (type, newState) => newState,
- };
-
- state = {
- expanded: [],
- ...this.props.initialState,
- };
-
- itemRefs = [];
-
- //flowlint-next-line unclear-type:off
- onPanelChange(key: React.Key, onChange: () => {}, ...args: Array) {
- let activeKeys = this.state.expanded;
- const { accordion } = this.props;
- if (accordion) {
- activeKeys = activeKeys[0] === key ? [] : [key];
- } else {
- activeKeys = [...activeKeys];
- const index = activeKeys.indexOf(key);
- const wasExpanded = index > -1;
- if (wasExpanded) {
- // remove active state
- activeKeys.splice(index, 1);
- } else {
- activeKeys.push(key);
- }
- }
- const newState = { expanded: activeKeys };
- this.internalSetState(STATE_CHANGE_TYPE.expand, newState);
- // Call individual panel's onChange handler
- if (typeof onChange === 'function') onChange(...args);
- }
-
- internalSetState(type: StateChangeTypeT, changes: AccordionStateT) {
- const { stateReducer, onChange } = this.props;
- const newState = stateReducer(type, changes, this.state);
- this.setState(newState);
- typeof onChange === 'function' && onChange(newState);
- }
-
- handleKeyDown(e: KeyboardEvent) {
- if (this.props.disabled) {
- return;
- }
-
- const itemRefs = this.itemRefs;
-
- const HOME = 36;
- const END = 35;
- const ARROW_UP = 38;
- const ARROW_DOWN = 40;
-
- if (e.keyCode === HOME) {
- e.preventDefault();
- const firstItem = itemRefs[0];
- firstItem.current && firstItem.current.focus();
- }
- if (e.keyCode === END) {
- e.preventDefault();
- const lastItem = itemRefs[itemRefs.length - 1];
- lastItem.current && lastItem.current.focus();
- }
- if (e.keyCode === ARROW_UP) {
- e.preventDefault();
- const activeItemIdx = itemRefs.findIndex((item) => item.current === document.activeElement);
- if (activeItemIdx > 0) {
- const prevItem = itemRefs[activeItemIdx - 1];
- prevItem.current && prevItem.current.focus();
- }
- }
- if (e.keyCode === ARROW_DOWN) {
- e.preventDefault();
- const activeItemIdx = itemRefs.findIndex((item) => item.current === document.activeElement);
- if (activeItemIdx < itemRefs.length - 1) {
- const nextItem = itemRefs[activeItemIdx + 1];
- nextItem.current && nextItem.current.focus();
- }
- }
- }
-
- getItems() {
- const { expanded } = this.state;
- const { accordion, disabled, children, renderAll, overrides } = this.props;
- // flowlint-next-line unclear-type:off
- return React.Children.map(children, (child: any, index) => {
- if (!child) return;
-
- const itemRef = React.createRef();
- this.itemRefs.push(itemRef);
-
- // If there is no key provided use the panel order as a default key
- const key = child.key || String(index);
- let isExpanded = false;
- if (accordion) {
- isExpanded = expanded[0] === key;
- } else {
- isExpanded = expanded.includes(key);
- }
-
- const props = {
- key,
- ref: itemRef,
- expanded: isExpanded || child.props.expanded,
- accordion,
- renderAll,
- overrides: child.props.overrides || overrides,
- disabled: child.props.disabled || disabled,
- onChange: (...args) => this.onPanelChange(key, child.props.onChange, ...args),
- };
- return React.cloneElement(child, props);
- });
- }
-
- render() {
- const { overrides = {} } = this.props;
- const { Root: RootOverride } = overrides;
- const [Root, rootProps] = getOverrides(RootOverride, StyledRoot);
- return (
-
- {this.getItems()}
-
- );
- }
-}
diff --git a/src/accordion/constants.js.flow b/src/accordion/constants.js.flow
deleted file mode 100644
index d9c49a49f9..0000000000
--- a/src/accordion/constants.js.flow
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export const STATE_CHANGE_TYPE = {
- expand: 'expand',
-};
diff --git a/src/accordion/index.js.flow b/src/accordion/index.js.flow
deleted file mode 100644
index 9857ca1320..0000000000
--- a/src/accordion/index.js.flow
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-export { default as Accordion } from './accordion.js';
-export { default as Panel } from './panel.js';
-export { default as StatefulPanel } from './stateful-panel.js';
-export { default as StatefulPanelContainer } from './stateful-panel-container.js';
-export { default as StatelessAccordion } from './stateless-accordion.js';
-// Constants
-export { STATE_CHANGE_TYPE } from './constants.js';
-// Styled elements
-export {
- Root as StyledRoot,
- PanelContainer as StyledPanelContainer,
- Header as StyledHeader,
- Content as StyledContent,
- ContentAnimationContainer as StyledContentAnimationContainer,
- ToggleIcon as StyledToggleIcon,
- ToggleIconGroup as StyledToggleIconGroup,
-} from './styled-components.js';
-// Flow
-export type * from './types.js';
diff --git a/src/accordion/locale.js.flow b/src/accordion/locale.js.flow
deleted file mode 100644
index 60458bcec7..0000000000
--- a/src/accordion/locale.js.flow
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export type AccordionLocaleT = {|
- collapse: string,
- expand: string,
-|};
-
-const locale = {
- collapse: 'Collapse',
- expand: 'Expand',
-};
-
-export default locale;
diff --git a/src/accordion/panel.js.flow b/src/accordion/panel.js.flow
deleted file mode 100644
index 397e0892e6..0000000000
--- a/src/accordion/panel.js.flow
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import { LocaleContext } from '../locale/index.js';
-import { getOverrides } from '../helpers/overrides.js';
-import {
- PanelContainer as StyledPanelContainer,
- Header as StyledHeader,
- Content as StyledContent,
- ToggleIcon as StyledToggleIcon,
- ToggleIconGroup as StyledToggleIconGroup,
- ContentAnimationContainer as StyledContentAnimationContainer,
-} from './styled-components.js';
-import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
-
-import type { PanelPropsT } from './types.js';
-
-const Panel = (
- {
- 'aria-controls': ariaControls,
- children,
- disabled = false,
- expanded = false,
- onChange = () => {},
- onClick = () => {},
- onKeyDown = () => {},
- overrides = {},
- title = '',
- renderAll = false,
- }: PanelPropsT,
- ref
-) => {
- const [localState, setLocalState] = React.useState({
- expanded,
- isFocusVisible: false,
- elementHeight: 0,
- animationInProgress: false,
- });
- const handleFocus = React.useCallback(
- (event: SyntheticEvent<>) => {
- if (isFocusVisible(event)) {
- setLocalState({ ...localState, isFocusVisible: true });
- }
- },
- [localState]
- );
- const handleBlur = React.useCallback(
- (event: SyntheticEvent<>) => {
- if (localState.isFocusVisible) {
- setLocalState({ ...localState, isFocusVisible: false });
- }
- },
- [localState]
- );
- const handleClick = React.useCallback(
- (e: Event) => {
- if (disabled) {
- return;
- }
- typeof onChange === 'function' && onChange({ expanded: !expanded });
- typeof onClick === 'function' && onClick(e);
- },
- [expanded, disabled, onChange, onClick]
- );
- const handleKeyDown = React.useCallback(
- (e: KeyboardEvent) => {
- if (disabled) {
- return;
- }
-
- const ENTER = 13;
- const SPACE = 32;
-
- if (e.keyCode === ENTER || e.keyCode === SPACE) {
- typeof onChange === 'function' && onChange({ expanded: !expanded });
- if (e.keyCode === SPACE) {
- e.preventDefault(); // prevent jumping scroll when using Space
- }
- }
- typeof onKeyDown === 'function' && onKeyDown(e);
- },
- [expanded, disabled, onChange, onKeyDown]
- );
- // flowlint-next-line unclear-type:off
- const _animateRef = React.useRef(null);
-
- React.useEffect(() => {
- if (_animateRef.current) {
- const height = _animateRef.current.getBoundingClientRect().height;
- // After the first render, when everything is in the DOM, update the local
- //state to indicate an animation is in progress.
- if (expanded !== localState.expanded) {
- setLocalState({
- ...localState,
- expanded,
- animationInProgress: true,
- });
- } else if (parseInt(localState.elementHeight) !== height) {
- // After the second render (where child elements were added to the Content)
- //the Content height now reflects the true height. This kicks off the actual
- //animation.
- setLocalState({
- ...localState,
- elementHeight: height ? `${height}px` : 0,
- });
- }
- }
- }, [_animateRef.current, expanded, localState.elementHeight, localState.expanded, setLocalState]);
-
- const contentHeight = React.useMemo(() => {
- // When closing, the first render will re-query the content element for the new
- //height and set the height of the animation container from auto to a px value.
- if (!expanded && localState.expanded) {
- const height = _animateRef.current.getBoundingClientRect().height;
- setLocalState({
- ...localState,
- elementHeight: height ? `${height}px` : 0,
- });
- return localState.elementHeight;
- }
- if (!localState.expanded) {
- return 0;
- }
- // When no longer animating, set the height to auto to accommodate dynamic nested components.
- return localState.animationInProgress ? localState.elementHeight : 'auto';
- }, [expanded, localState.expanded, localState.animationInProgress, localState.elementHeight]);
-
- const sharedProps = {
- $disabled: disabled,
- $expanded: expanded,
- $isFocusVisible: localState.isFocusVisible,
- };
-
- const {
- PanelContainer: PanelContainerOverride,
- Header: HeaderOverride,
- Content: ContentOverride,
- ContentAnimationContainer: ContentAnimationContainerOverride,
- ToggleIcon: ToggleIconOverride,
- ToggleIconGroup: ToggleIconGroupOverride,
- } = overrides;
-
- const [PanelContainer, panelContainerProps] = getOverrides(
- PanelContainerOverride,
- StyledPanelContainer
- );
- const [Header, headerProps] = getOverrides(HeaderOverride, StyledHeader);
- const [Content, contentProps] = getOverrides(ContentOverride, StyledContent);
- const [ContentAnimationContainer, contentAnimationProps] = getOverrides(
- ContentAnimationContainerOverride,
- StyledContentAnimationContainer
- );
- const [ToggleIconGroup, toggleIconGroupProps] = getOverrides(
- ToggleIconGroupOverride,
- StyledToggleIconGroup
- );
-
- const [ToggleIcon, toggleIconProps] = getOverrides(ToggleIconOverride, StyledToggleIcon);
-
- return (
-
- {(locale) => (
-
-
- {
- if (localState.animationInProgress) {
- setLocalState({ ...localState, animationInProgress: false });
- }
- }}
- >
-
- {localState.expanded || renderAll || localState.animationInProgress ? children : null}
-
-
-
- )}
-
- );
-};
-
-const ForwardedPanel = React.forwardRef(Panel);
-ForwardedPanel.displayName = 'Panel';
-export default ForwardedPanel;
diff --git a/src/accordion/stateful-panel-container.js.flow b/src/accordion/stateful-panel-container.js.flow
deleted file mode 100644
index ab62a22548..0000000000
--- a/src/accordion/stateful-panel-container.js.flow
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import { STATE_CHANGE_TYPE } from './constants.js';
-import type {
- PanelStateT,
- StatefulPanelContainerPropsT,
- PanelStateReducerT,
- StateChangeTypeT,
- OnChangeHandlerT,
-} from './types.js';
-
-const defaultStateReducer: PanelStateReducerT = (type, nextState) => nextState;
-
-class StatefulPanelContainer extends React.Component {
- static defaultProps = {
- initialState: { expanded: false },
- stateReducer: defaultStateReducer,
- onChange: () => {},
- };
-
- state = {
- expanded: false,
- ...this.props.initialState,
- };
-
- onChange: OnChangeHandlerT = () => {
- if (typeof this.props.onChange === 'function') {
- this.props.onChange({ expanded: !this.state.expanded });
- }
- this.internalSetState(STATE_CHANGE_TYPE.expand, {
- expanded: !this.state.expanded,
- });
- };
-
- internalSetState(type: StateChangeTypeT, changes: PanelStateT) {
- const { stateReducer } = this.props;
- this.setState((prevState) => (stateReducer ? stateReducer(type, changes, prevState) : changes));
- }
-
- render() {
- const { children, initialState, stateReducer, ...restProps } = this.props;
-
- return this.props.children({
- ...restProps,
- ...this.state,
- onChange: this.onChange,
- });
- }
-}
-
-export default StatefulPanelContainer;
diff --git a/src/accordion/stateful-panel.js.flow b/src/accordion/stateful-panel.js.flow
deleted file mode 100644
index 721e968cda..0000000000
--- a/src/accordion/stateful-panel.js.flow
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import StatefulContainer from './stateful-panel-container.js';
-import Panel from './panel.js';
-import type { StatefulPanelPropsT } from './types.js';
-
-export default function StatefulPanel(props: StatefulPanelPropsT) {
- const { children, ...restProps } = props;
- return (
-
- {(componentProps) => {children}}
-
- );
-}
diff --git a/src/accordion/stateless-accordion.js.flow b/src/accordion/stateless-accordion.js.flow
deleted file mode 100644
index 41a69fac13..0000000000
--- a/src/accordion/stateless-accordion.js.flow
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import { getOverrides } from '../helpers/overrides.js';
-import { Root as StyledRoot } from './styled-components.js';
-import type { StatelessAccordionPropsT } from './types.js';
-
-function StatelessAccordion({
- accordion = true,
- children,
- disabled,
- expanded,
- onChange,
- overrides = {},
- renderAll,
-}: StatelessAccordionPropsT) {
- const { Root: RootOverrides, ...PanelOverrides } = overrides;
- const [Root, rootProps] = getOverrides(RootOverrides, StyledRoot);
- return (
-
- {React.Children.map(children, (child, index) => {
- const key = child.key || String(index);
- return React.cloneElement(child, {
- disabled: child.props.disabled || disabled,
- expanded: expanded.includes(key),
- key,
- onChange:
- // Don't bother constructing the wrapper function if no one is listening
- onChange && typeof onChange === 'function'
- ? () => {
- let next;
- if (accordion) {
- if (expanded.includes(key)) {
- next = [];
- } else {
- next = [key];
- }
- } else {
- if (expanded.includes(key)) {
- next = expanded.filter((k) => k !== key);
- } else {
- next = [...expanded, key];
- }
- }
- onChange({ key, expanded: next });
- }
- : onChange,
- overrides: child.props.overrides || PanelOverrides,
- renderAll,
- });
- })}
-
- );
-}
-
-export default StatelessAccordion;
diff --git a/src/accordion/styled-components.js.flow b/src/accordion/styled-components.js.flow
deleted file mode 100644
index 59b998ddcc..0000000000
--- a/src/accordion/styled-components.js.flow
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import { styled } from '../styles/index.js';
-import { getSvgStyles } from '../icon/styled-components.js';
-import type { SharedStylePropsArgT } from './types.js';
-
-/**
- * Main component container element
- */
-export const Root = styled('ul', {
- listStyleType: 'none',
- marginBottom: 0,
- marginTop: 0,
- paddingLeft: 0,
- paddingRight: 0,
- width: '100%',
-});
-
-export const PanelContainer = styled('li', (props) => {
- const {
- $expanded,
- $theme: { colors },
- } = props;
- return {
- listStyleType: 'none',
- width: '100%',
- borderBottomWidth: '1px',
- borderBottomStyle: 'solid',
- borderBottomColor: $expanded ? colors.borderOpaque : colors.borderOpaque,
- };
-});
-
-export const Header = styled('div', (props) => {
- const {
- $disabled,
- $isFocusVisible,
- $theme: { colors, sizing, typography },
- } = props;
- return {
- ...typography.font350,
- color: colors.contentPrimary,
- cursor: $disabled ? 'not-allowed' : 'pointer',
- backgroundColor: colors.listHeaderFill,
- paddingTop: sizing.scale600,
- paddingBottom: sizing.scale600,
- paddingLeft: sizing.scale700,
- paddingRight: sizing.scale700,
- marginTop: 0,
- marginBottom: 0,
- marginLeft: 0,
- marginRight: 0,
- display: 'flex',
- alignItems: 'center',
- outline: $isFocusVisible ? `3px solid ${colors.borderAccent}` : 'none',
- outlineOffset: '-3px',
- justifyContent: 'space-between',
- ':hover': {
- color: colors.contentPrimary,
- },
- };
-});
-
-export const ToggleIcon = styled('svg', (props) => {
- const { $theme, $disabled, $color } = props;
- return {
- ...getSvgStyles(props),
- flexShrink: 0,
- color: $color || $theme.colors.contentPrimary,
- cursor: $disabled ? 'not-allowed' : 'pointer',
- };
-});
-
-export const ToggleIconGroup = styled('g', (props) => {
- const { $theme, $expanded } = props;
- return {
- transform: $expanded ? 'rotate(0)' : 'rotate(-90deg)',
- transformOrigin: 'center',
- transitionProperty: 'transform',
- transitionDuration: $theme.animation.timing500,
- transitionTimingFunction: $theme.animation.easeOutQuinticCurve,
- };
-});
-
-export const Content = styled('div', (props) => {
- const {
- $theme: { animation, colors, sizing, typography },
- $expanded,
- } = props;
- return {
- ...typography.font200,
- backgroundColor: colors.listBodyFill,
- color: colors.contentPrimary,
- paddingTop: sizing.scale800,
- paddingBottom: sizing.scale1000,
- paddingLeft: sizing.scale800,
- paddingRight: sizing.scale800,
- marginTop: 0,
- marginBottom: 0,
- marginLeft: 0,
- marginRight: 0,
- boxSizing: 'border-box',
- overflow: 'hidden',
- opacity: $expanded ? 1 : 0,
- visibility: $expanded ? 'visible' : 'hidden',
- transitionProperty: 'opacity,visibility',
- transitionDuration: animation.timing500,
- transitionDelay: animation.timing200,
- transitionTimingFunction: animation.easeOutQuinticCurve,
- };
-});
-
-export const ContentAnimationContainer = styled<
- { $height: string | number } & SharedStylePropsArgT
->('div', (props) => {
- const {
- $height,
- $theme: { animation },
- } = props;
- return {
- height: `${$height}`,
- overflow: 'hidden',
- transitionProperty: 'height',
- transitionDuration: animation.timing500,
- transitionTimingFunction: animation.easeOutQuinticCurve,
- };
-});
diff --git a/src/accordion/types.js.flow b/src/accordion/types.js.flow
deleted file mode 100644
index 21fdb65a0b..0000000000
--- a/src/accordion/types.js.flow
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-/* eslint-disable flowtype/generic-spacing */
-import * as React from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-import { STATE_CHANGE_TYPE } from './constants.js';
-
-export type AccordionStateT = {
- expanded: Array,
-};
-
-export type PanelStateT = {
- expanded: boolean,
-};
-
-export type StateChangeTypeT = $Keys;
-
-export type StateReducerT = (
- stateChangeType: StateChangeTypeT,
- nextState: AccordionStateT,
- currentState: AccordionStateT
-) => AccordionStateT;
-
-export type PanelStateReducerT = (
- stateChangeType: StateChangeTypeT,
- nextState: PanelStateT,
- currentState: PanelStateT
-) => PanelStateT;
-
-export type AccordionOverridesT = {
- Content?: OverrideT,
- ContentAnimationContainer?: OverrideT,
- Header?: OverrideT,
- PanelContainer?: OverrideT,
- Root?: OverrideT,
- ToggleIcon?: OverrideT,
- ToggleIconGroup?: OverrideT,
-};
-
-export type PanelOverridesT = {
- PanelContainer?: OverrideT,
- Header?: OverrideT,
- ToggleIcon?: OverrideT,
- ToggleIconGroup?: OverrideT,
- Content?: OverrideT,
- ContentAnimationContainer?: OverrideT,
-};
-
-export type OnChangeHandlerT = ({ expanded: boolean }) => mixed;
-
-export type AccordionOnChangeHandlerT = ({
- expanded: Array,
-}) => mixed;
-
-//flowlint-next-line unclear-type:off
-type ChildrenT = React.ChildrenArray>;
-
-export type AccordionPropsT = {
- /** Determines how many panels may be expanded at a time. If set to
- * true it will collapse a current panel when a new panel is expanded.
- * If set to false more than one panel may be expanded at a time. */
- accordion?: boolean,
- /** Accordion expandable items. See Panel API below for reference. */
- children: ChildrenT,
- /** If set to true all its children panels will be disabled from toggling. */
- disabled?: boolean,
- initialState?: AccordionStateT,
- /** Handler called each time a panel is toggled. expanded prop is an array
- * of Panel keys that are currently expanded. */
- onChange?: AccordionOnChangeHandlerT,
- overrides?: AccordionOverridesT,
- /** Handler called each time the component state changes.
- * Used to override default state-change functionality. */
- stateReducer: StateReducerT,
- /**
- * Allows users to render all child content whether a panel is expanded or not
- * for SEO purposed
- */
- renderAll?: boolean,
-};
-
-export type StatelessAccordionOnChangeHandlerT = ({
- expanded: Array,
- key: React.Key,
-}) => mixed;
-
-export type StatelessAccordionPropsT = {
- /** Determines how many panels may be expanded at a time. If set to
- * true it will collapse a current panel when a new panel is expanded.
- * If set to false more than one panel may be expanded at a time. */
- accordion?: boolean,
- /** Accordion expandable items. See Panel API below for reference. */
- children: ChildrenT,
- /** If set to true all its children panels will be disabled from toggling. */
- disabled?: boolean,
- /** List of Panel keys which are expanded. */
- expanded: Array,
- /** Handler called each time a panel is toggled. */
- onChange?: StatelessAccordionOnChangeHandlerT,
- overrides?: AccordionOverridesT & PanelOverridesT,
- /**
- * Allows users to render all child content whether a panel is expanded or not
- * for SEO purposed
- */
- renderPanelContent?: boolean,
- /**
- * Allows users to render all child content whether a panel is expanded or not
- * for SEO purposed
- */
- renderAll?: boolean,
-};
-
-type SharedPanelPropsT = {
- /** The content visible when Panel is expanded. */
- children: React.Node,
- /** Defaults to the disabled value provided by the parent Accordion component. */
- disabled?: boolean,
- /** Id for a panel, when provided populates aria-controls
- * attribute for panel button and content
- * */
- 'aria-controls'?: string,
- /** The key of a Panel. Used to maintain list of expanded panels.
- * Must be unique across children of the Accordion. */
- key?: React.Key,
- /** Handler for individual Panel change events. */
- onChange?: OnChangeHandlerT,
- /** Handler for the Header's click events. */
- onClick?: (e: Event) => mixed,
- /** Handler for the Header's keyDown events. */
- onKeyDown?: (e: KeyboardEvent) => mixed,
- overrides?: PanelOverridesT,
- /** The title of an accordion panel. */
- title?: React.Node,
- /**
- * Allows users to render all child content whether a panel is expanded or not
- * for SEO purposed
- */
- renderPanelContent?: boolean,
- /**
- * Allows users to render all child content whether a panel is expanded or not
- * for SEO purposed
- */
- renderAll?: boolean,
-};
-
-export type PanelPropsT = SharedPanelPropsT & {
- /** Defines if the panel is expanded. If set to true the panel is rendered expanded. */
- expanded?: boolean,
-};
-
-// Props for panel stateful container
-type SharedStatefulPanelContainerPropsT = {
- /** Initial state of a stateful panel component.
- * The expanded prop indicates if the panel is initially expanded.
- * If set to true the panel will be expanded initially */
- initialState?: PanelStateT,
- onChange?: OnChangeHandlerT,
- stateReducer?: PanelStateReducerT,
-};
-export type StatefulPanelContainerPropsT = SharedStatefulPanelContainerPropsT & {
- children: (props: $Diff) => React.Node,
-};
-
-// Props for stateful panel
-export type StatefulPanelPropsT = SharedStatefulPanelContainerPropsT & SharedPanelPropsT;
-
-export type SharedStylePropsArgT = {
- $color?: string,
- $disabled: ?boolean,
- $expanded?: ?boolean,
- $size?: string | number,
- $isFocusVisible: boolean,
-};
diff --git a/src/app-nav-bar/app-nav-bar.js.flow b/src/app-nav-bar/app-nav-bar.js.flow
deleted file mode 100644
index 1046ee63d8..0000000000
--- a/src/app-nav-bar/app-nav-bar.js.flow
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { getOverrides } from '../helpers/overrides.js';
-import { useStyletron } from '../styles/index.js';
-import { isFocusVisible } from '../utils/focusVisible.js';
-
-import { KIND, POSITION } from './constants.js';
-import MobileNav from './mobile-menu.js';
-import UserMenu from './user-menu.js';
-import {
- StyledRoot,
- StyledSpacing,
- StyledPrimaryMenuContainer,
- StyledSecondaryMenuContainer,
- StyledAppName,
- StyledMainMenuItem,
- StyledDesktopMenuContainer,
- StyledDesktopMenu,
-} from './styled-components.js';
-import type { AppNavBarPropsT } from './types.js';
-import { defaultMapItemToNode, mapItemsActive } from './utils.js';
-
-function MainMenuItem(props) {
- const { item, kind = KIND.primary, mapItemToNode, onSelect, overrides = {} } = props;
- const [focusVisible, setFocusVisible] = React.useState(false);
-
- function handleFocus(event) {
- if (isFocusVisible(event)) {
- setFocusVisible(true);
- }
- }
-
- function handleBlur(event) {
- if (focusVisible) {
- setFocusVisible(false);
- }
- }
-
- function handleClick(event) {
- if (onSelect) {
- onSelect(item);
- }
- }
-
- function handleKeyDown(event) {
- if (event.key === 'Enter' && onSelect) {
- onSelect(item);
- }
- }
-
- const [MainMenuItemElement, mainMenuItemElementProps] = getOverrides(
- overrides.MainMenuItem,
- StyledMainMenuItem
- );
-
- return (
-
- {mapItemToNode(item)}
-
- );
-}
-
-function SecondaryMenu(props) {
- const { items = [], mapItemToNode, onSelect, overrides = {} } = props;
-
- const [SecondaryMenuContainer, secondaryMenuContainerProps] = getOverrides(
- overrides.SecondaryMenuContainer,
- StyledSecondaryMenuContainer
- );
-
- return (
-
- {items.map((item, index) => (
- // Replace with a menu item renderer
-
- ))}
-
- );
-}
-
-export default function AppNavBar(props: AppNavBarPropsT) {
- const [css, theme] = useStyletron();
- const {
- title,
- mapItemToNode = defaultMapItemToNode,
- onMainItemSelect = (item) => {},
- onUserItemSelect = (item) => {},
- overrides = {},
- userItems = [],
- username,
- usernameSubtitle,
- userImgUrl,
- } = props;
-
- const mainItems = React.useMemo(() => {
- if (props.isMainItemActive) {
- return mapItemsActive(props.mainItems || [], props.isMainItemActive);
- }
- return props.mainItems || [];
- }, [props.mainItems, props.isMainItemActive]);
-
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
- const [Spacing, spacingProps] = getOverrides(overrides.Spacing, StyledSpacing);
- const [AppName, appNameProps] = getOverrides(overrides.AppName, StyledAppName);
- const [PrimaryMenuContainer, primaryMenuContainerProps] = getOverrides(
- overrides.PrimaryMenuContainer,
- StyledPrimaryMenuContainer
- );
- const [DesktopMenuContainer, desktopMenuContainerProps] = getOverrides(
- overrides.DesktopMenuContainer,
- StyledDesktopMenuContainer
- );
- const [DesktopMenu, desktopMenuProps] = getOverrides(overrides.DesktopMenu, StyledDesktopMenu);
-
- let secondaryMenu;
- let desktopSubNavPosition = POSITION.horizontal;
- let mobileSubNavPosition = POSITION.vertical;
-
- return (
-
- {/* Mobile Nav Experience */}
-
-
- {mainItems.length || userItems.length ? : null}
- {title}
-
-
- {secondaryMenu && mobileSubNavPosition === POSITION.horizontal && (
-
- )}
-
-
- {/* Desktop Nav Experience */}
-
-
-
- {/* Replace with a Logo renderer */}
- {title}
-
-
- {mainItems.map((item, index) => {
- // For an active top level menu get the secondary navigation and its positioning
- if (item.active && item.children && item.children.length) {
- secondaryMenu = item.children;
- if (item.navPosition) {
- desktopSubNavPosition = item.navPosition.desktop || desktopSubNavPosition;
- mobileSubNavPosition = item.navPosition.mobile || mobileSubNavPosition;
- }
- }
- return (
-
- );
- })}
-
-
- {userItems.length ? (
-
- ) : null}
-
-
-
- {secondaryMenu && desktopSubNavPosition === POSITION.horizontal && (
-
- )}
-
-
- );
-}
diff --git a/src/app-nav-bar/constants.js.flow b/src/app-nav-bar/constants.js.flow
deleted file mode 100644
index 826440093a..0000000000
--- a/src/app-nav-bar/constants.js.flow
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export const POSITION = {
- horizontal: 'horizontal',
- vertical: 'vertical',
-};
-
-export const KIND = {
- primary: 'primary',
- secondary: 'secondary',
-};
diff --git a/src/app-nav-bar/index.js.flow b/src/app-nav-bar/index.js.flow
deleted file mode 100644
index 218421c71f..0000000000
--- a/src/app-nav-bar/index.js.flow
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { default as AppNavBar } from './app-nav-bar.js';
-export { POSITION } from './constants.js';
-export * from './styled-components.js';
-export * from './types.js';
-
-export { setItemActive } from './utils.js';
diff --git a/src/app-nav-bar/mobile-menu.js.flow b/src/app-nav-bar/mobile-menu.js.flow
deleted file mode 100644
index 008fe9bc71..0000000000
--- a/src/app-nav-bar/mobile-menu.js.flow
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { Button } from '../button/index.js';
-import { Drawer, ANCHOR } from '../drawer/index.js';
-import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
-import ArrowLeft from '../icon/arrow-left.js';
-import MenuIcon from '../icon/menu.js';
-import { MenuAdapter, ListItemLabel, ARTWORK_SIZES } from '../list/index.js';
-import { StatefulMenu } from '../menu/index.js';
-
-import { StyledSideMenuButton, StyledUserMenuProfileListItem } from './styled-components.js';
-import type { AppNavBarPropsT } from './types.js';
-import UserProfileTile from './user-profile-tile.js';
-import { defaultMapItemToNode } from './utils.js';
-
-const USER_TITLE_ITEM = 'USER_TITLE_ITEM';
-const USER_MENU_ITEM = 'USER_MENU_ITEM';
-const PARENT_MENU_ITEM = 'PARENT_MENU_ITEM';
-
-// eslint-disable-next-line react/display-name
-const MobileNavMenuItem = React.forwardRef((props, ref) => {
- const { item, mapItemToNode = defaultMapItemToNode, overrides = {}, ...restProps } = props;
-
- const [UserMenuProfileListItem, userMenuProfileListItemProps] = getOverrides(
- overrides.UserMenuProfileListItem,
- StyledUserMenuProfileListItem
- );
-
- if (item.PARENT_MENU_ITEM) {
- return (
-
- {item.label}
-
- );
- }
- if (item.USER_TITLE_ITEM) {
- // Replace with a user menu item renderer
- return (
-
-
-
- );
- }
- return (
- // Replace with a main menu item renderer
-
- {mapItemToNode(item)}
-
- );
-});
-
-export default function MobileMenu(props: AppNavBarPropsT) {
- const { mainItems = [], userItems = [], mapItemToNode, overrides = {}, ...rest } = props;
-
- const items = [
- ...(userItems.length
- ? [
- {
- item: { ...rest },
- label: props.username,
- [USER_TITLE_ITEM]: true,
- children: userItems.map((item) => {
- return {
- ...item,
- [USER_MENU_ITEM]: true,
- };
- }),
- },
- ]
- : []),
- ...mainItems,
- ];
-
- const [isOpen, setIsOpen] = React.useState(false);
- const [currentNavItems, setCurrentNavItems] = React.useState(items);
- const [ancestorNavItems, setAncestorNavItems] = React.useState([]);
-
- const toggleMenu = () => {
- setIsOpen(!isOpen);
- };
-
- const [SideMenuButton, sideMenuButtonProps] = getOverrides(overrides.SideMenuButton, Button);
- sideMenuButtonProps.overrides = mergeOverrides(
- { BaseButton: { component: StyledSideMenuButton } },
- sideMenuButtonProps.overrides
- );
-
- const [MobileDrawer, drawerProps] = getOverrides(overrides.MobileDrawer, Drawer);
- drawerProps.overrides = mergeOverrides(
- {
- DrawerBody: {
- style: ({ $theme }) => {
- return {
- marginTop: '0px',
- marginBottom: '0px',
- marginLeft: '0px',
- marginRight: '0px',
- };
- },
- },
- // Removes the close icon from the drawer
- Close: () => null,
- },
- drawerProps.overrides
- );
-
- const [MobileMenu, menuProps] = getOverrides(overrides.MobileMenu, StatefulMenu);
- menuProps.overrides = mergeOverrides(
- {
- List: {
- style: {
- paddingTop: '0',
- paddingBottom: '0',
- minHeight: '100vh',
- boxShadow: 'none',
- },
- },
- // eslint-disable-next-line react/display-name
- ListItem: React.forwardRef((listItemProps, ref) => {
- return (
-
- );
- }),
- },
- menuProps.overrides
- );
-
- return (
- <>
-
-
-
-
- {
- if (item.PARENT_MENU_ITEM) {
- // Remove current parent item selected to return to
- // from the ancestors list (`ancestorNavItems[ancestorArrLength - 1]`)
- const updatedAncestorNavItems = ancestorNavItems.slice(
- 0,
- ancestorNavItems.length - 1
- );
- const isTopLevel = !updatedAncestorNavItems.length;
- if (isTopLevel) {
- // Set to the initial `navItems` value
- setCurrentNavItems(items);
- } else {
- const newParentItem = {
- ...updatedAncestorNavItems[updatedAncestorNavItems.length - 1],
- [PARENT_MENU_ITEM]: true,
- };
- setCurrentNavItems([newParentItem, ...newParentItem.children]);
- }
- setAncestorNavItems(updatedAncestorNavItems);
- return;
- }
-
- if (item.USER_MENU_ITEM && props.onUserItemSelect) {
- props.onUserItemSelect(item);
- } else if (!item.USER_TITLE_ITEM && props.onMainItemSelect) {
- props.onMainItemSelect(item);
- }
-
- if (item.children && item.children.length) {
- const parentItem = { ...item, [PARENT_MENU_ITEM]: true };
- setAncestorNavItems([...ancestorNavItems, item]);
- setCurrentNavItems([parentItem, ...item.children]);
- return;
- }
- toggleMenu();
- }}
- {...menuProps}
- />
-
- >
- );
-}
diff --git a/src/app-nav-bar/styled-components.js.flow b/src/app-nav-bar/styled-components.js.flow
deleted file mode 100644
index f3a6c8ee5a..0000000000
--- a/src/app-nav-bar/styled-components.js.flow
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import { styled, withStyle } from '../styles/index.js';
-import { getMediaQueryPageMargins, getMinimumPageMargins } from '../helpers/responsive-helpers.js';
-import { StyledListItem } from '../menu/index.js';
-import { KIND } from './constants.js';
-import { type StyleObject } from 'styletron-react';
-
-const StyledButton = styled<{ $isFocusVisible: boolean }>(
- 'button',
- ({ $theme, $isFocusVisible }) => ({
- boxSizing: 'border-box',
- display: 'flex',
- flexDirection: 'row',
- flexWrap: 'nowrap',
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: 'transparent',
- color: $theme.colors.contentPrimary,
- borderLeftWidth: 0,
- borderTopWidth: 0,
- borderRightWidth: 0,
- borderBottomWidth: 0,
- paddingTop: '0',
- paddingBottom: '0',
- paddingLeft: '0',
- paddingRight: '0',
- marginLeft: 0,
- marginTop: 0,
- marginRight: 0,
- marginBottom: 0,
- outline: $isFocusVisible ? `3px solid ${$theme.colors.borderAccent}` : 'none',
- outlineOffset: '-3px',
- WebkitAppearance: 'none',
- cursor: 'pointer',
- })
-);
-
-export const StyledRoot = styled<{}>('div', (props): StyleObject => {
- const { $theme } = props;
- return {
- ...getMediaQueryPageMargins($theme),
- ...$theme.typography.font300,
- ...getMinimumPageMargins($theme.grid.margins),
- boxSizing: 'border-box',
- backgroundColor: $theme.colors.backgroundPrimary,
- borderBottomWidth: '1px',
- borderBottomStyle: 'solid',
- borderBottomColor: `${$theme.colors.borderOpaque}`,
- };
-});
-
-export const StyledSubnavContainer = styled('div', {});
-
-export const StyledSpacing = styled<{}>('div', (props) => {
- const { $theme } = props;
- return {
- boxSizing: 'border-box',
- height: '100%',
- display: 'flex',
- alignItems: 'center',
- paddingTop: $theme.sizing.scale400,
- paddingBottom: $theme.sizing.scale400,
- [$theme.mediaQuery.medium]: {
- paddingTop: $theme.sizing.scale700,
- paddingBottom: $theme.sizing.scale700,
- },
- };
-});
-
-export const StyledAppName = styled<{}>('div', ({ $theme }) => ({
- ...$theme.typography.font550,
- color: $theme.colors.contentPrimary,
- textDecoration: 'none',
- [$theme.mediaQuery.medium]: {
- ...$theme.typography.font650,
- },
-}));
-
-export const StyledSideMenuButton = withStyle(
- StyledButton,
- ({ $theme }) => ({
- ...($theme.direction === 'rtl'
- ? { marginLeft: $theme.sizing.scale600 }
- : { marginRight: $theme.sizing.scale600 }),
- paddingTop: $theme.sizing.scale100,
- paddingBottom: $theme.sizing.scale100,
- paddingLeft: $theme.sizing.scale100,
- paddingRight: $theme.sizing.scale100,
- })
-);
-
-export const StyledPrimaryMenuContainer = styled<{}>('div', ({ $theme }) => {
- return {
- boxSizing: 'border-box',
- height: '100%',
- display: 'flex',
- flexDirection: 'row',
- flexGrow: 1,
- flexWrap: 'nowrap',
- justifyContent: 'flex-end',
- alignItems: 'stretch',
- paddingInlineEnd: $theme.sizing.scale1000,
- };
-});
-
-export const StyledMainMenuItem = styled<{
- $active?: boolean,
- $isFocusVisible: boolean,
- $kind: $Values,
-}>('div', (props) => {
- const {
- $active,
- $isFocusVisible,
- $kind,
- $theme: { colors, sizing, direction },
- } = props;
- return {
- boxSizing: 'border-box',
- display: 'flex',
- alignItems: 'center',
- color: $active ? colors.contentPrimary : colors.contentTertiary,
- marginLeft: sizing.scale700,
- marginRight: sizing.scale700,
- paddingTop: $kind === KIND.secondary ? sizing.scale750 : '0',
- paddingBottom: $kind === KIND.secondary ? sizing.scale750 : '0',
- outline: $isFocusVisible ? `3px solid ${colors.borderAccent}` : 'none',
- outlineOffset: '-3px',
- borderBottomWidth: '2px',
- borderBottomStyle: 'solid',
- borderBottomColor: $active && !$isFocusVisible ? colors.borderSelected : 'transparent',
- cursor: $active ? 'default' : 'pointer',
- whiteSpace: $kind === KIND.secondary ? 'nowrap' : 'initial',
- ':first-child': {
- ...(direction === 'rtl' ? { marginRight: '0' } : { marginLeft: '0' }),
- },
- ':last-child': {
- ...(direction === 'rtl' ? { marginLeft: '0' } : { marginRight: '0' }),
- },
- ':hover': {
- color: colors.contentPrimary,
- },
- };
-});
-
-export const StyledSecondaryMenuContainer = styled<{}>('div', ({ $theme }) => {
- return {
- boxSizing: 'border-box',
- height: '100%',
- display: 'flex',
- flexDirection: 'row',
- flexWrap: 'nowrap',
- justifyContent: 'flex-start',
- margin: 'auto',
- maxWidth: `${$theme.grid.maxWidth}px`,
- alignItems: 'stretch',
- overflow: 'auto',
- };
-});
-
-export const StyledUserMenuButton = StyledButton;
-
-export const StyledUserMenuProfileListItem = withStyle(
- StyledListItem,
- ({ $theme }) => ({
- paddingTop: '0',
- paddingBottom: '0',
- ...($theme.direction === 'rtl' ? { paddingLeft: '0' } : { paddingRight: '0' }),
- })
-);
-
-export const StyledUserProfileTileContainer = styled<{}>('div', ({ $theme }) => {
- return {
- boxSizing: 'border-box',
- height: '100%',
- display: 'flex',
- flexDirection: 'row',
- flexWrap: 'nowrap',
- justifyContent: 'flex-start',
- paddingTop: $theme.sizing.scale650,
- paddingBottom: $theme.sizing.scale650,
- };
-});
-
-export const StyledUserProfilePictureContainer = styled<{}>('div', ({ $theme }) => {
- return {
- ...($theme.direction === 'rtl'
- ? { marginLeft: $theme.sizing.scale600 }
- : { marginRight: $theme.sizing.scale600 }),
- };
-});
-
-export const StyledUserProfileInfoContainer = styled<{}>('div', ({ $theme }) => {
- return {
- boxSizing: 'border-box',
- alignSelf: 'center',
- };
-});
-
-export const StyledDesktopMenuContainer = styled<{}>('div', ({ $theme }) => {
- return {};
-});
-
-export const StyledDesktopMenu = styled<{}>('div', ({ $theme }) => {
- return {
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'space-between',
- margin: 'auto',
- maxWidth: `${$theme.grid.maxWidth}px`,
- paddingBlockStart: '18px',
- paddingBlockEnd: '18px',
- };
-});
diff --git a/src/app-nav-bar/types.js.flow b/src/app-nav-bar/types.js.flow
deleted file mode 100644
index 846bff1e5e..0000000000
--- a/src/app-nav-bar/types.js.flow
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { POSITION } from './constants.js';
-
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type OverridesT = {
- Root?: OverrideT,
- AppName?: OverrideT,
- DesktopMenu?: OverrideT,
- DesktopMenuContainer?: OverrideT,
- MainMenuItem?: OverrideT,
- PrimaryMenuContainer?: OverrideT,
- ProfileTileContainer?: OverrideT,
- SecondaryMenuContainer?: OverrideT,
- Spacing?: OverrideT,
- SubnavContainer?: OverrideT,
- UserMenuProfileListItem?: OverrideT,
- UserProfileInfoContainer?: OverrideT,
- UserProfilePictureContainer?: OverrideT,
- UserProfileTileContainer?: OverrideT,
-
- // nested overrides
- MobileDrawer?: OverrideT,
- MobileMenu?: OverrideT,
- SideMenuButton?: OverrideT,
- UserMenuButton?: OverrideT,
- UserMenu?: OverrideT,
-};
-
-export type NavItemT = {|
- active?: boolean,
- // flowlint-next-line unclear-type:off
- icon?: React.AbstractComponent,
- // flowlint-next-line unclear-type:off
- info?: any,
- label: string,
- children?: NavItemT[],
- // flowlint-next-line unclear-type:off
- navExitIcon?: React.AbstractComponent,
- navPosition?: {
- desktop?: $Values,
- mobile?: $Values,
- },
-|};
-
-export type UserMenuPropsT = {|
- userItems?: NavItemT[],
- username?: string,
- usernameSubtitle?: React.Node,
- userImgUrl?: string,
- onUserItemSelect?: (NavItemT) => mixed,
-|};
-
-export type AppNavBarPropsT = {|
- ...UserMenuPropsT,
- isMainItemActive?: (NavItemT) => boolean,
- mainItems?: NavItemT[],
- mapItemToNode?: (NavItemT) => React.Node,
- onMainItemSelect?: (NavItemT) => mixed,
- overrides?: OverridesT,
- title?: React.Node,
-|};
diff --git a/src/app-nav-bar/user-menu.js.flow b/src/app-nav-bar/user-menu.js.flow
deleted file mode 100644
index 4af99bf959..0000000000
--- a/src/app-nav-bar/user-menu.js.flow
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { Avatar } from '../avatar/index.js';
-import { Button } from '../button/index.js';
-import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
-import ChevronDownSmallFilled from '../icon/chevron-down.js';
-import ChevronUpSmallFilled from '../icon/chevron-up.js';
-import { MenuAdapter, ListItemLabel, ARTWORK_SIZES } from '../list/index.js';
-import { StatefulMenu, StyledList } from '../menu/index.js';
-import { StatefulPopover, PLACEMENT, TRIGGER_TYPE } from '../popover/index.js';
-
-import { StyledUserMenuButton, StyledUserMenuProfileListItem } from './styled-components.js';
-import type { UserMenuPropsT, NavItemT, OverridesT } from './types.js';
-import UserProfileTile from './user-profile-tile.js';
-import { defaultMapItemToNode } from './utils.js';
-
-const MENU_ITEM_WIDTH = '275px';
-
-// eslint-disable-next-line react/display-name
-const UserMenuListItem = React.forwardRef((props, ref) => {
- const { item, mapItemToNode = defaultMapItemToNode } = props;
- // Replace with a user menu item renderer
- return (
-
- {mapItemToNode(item)}
-
- );
-});
-
-const svgStyleOverride = ({ $theme }) => ({ paddingLeft: $theme.sizing.scale200 });
-
-export default function UserMenuComponent(props: {|
- ...UserMenuPropsT,
- mapItemToNode: (NavItemT) => React.Node,
- onItemSelect: (NavItemT) => mixed,
- overrides: OverridesT,
-|}) {
- // isOpen is used for displaying different arrow icons in open or closed state
- const [isOpen, setIsOpen] = React.useState(false);
- const { userItems = [], username, userImgUrl, overrides = {} } = props;
-
- const [UserMenuProfileListItem, userMenuProfileListItemProps] = getOverrides(
- overrides.UserMenuProfileListItem,
- StyledUserMenuProfileListItem
- );
-
- const [UserMenuButton, userMenuButtonProps] = getOverrides(overrides.UserMenuButton, Button);
- userMenuButtonProps.overrides = mergeOverrides(
- { BaseButton: { component: StyledUserMenuButton } },
- userMenuButtonProps.overrides
- );
-
- const [UserMenu, userMenuProps] = getOverrides(overrides.UserMenu, StatefulMenu);
- userMenuProps.overrides = mergeOverrides(
- {
- List: {
- // eslint-disable-next-line react/display-name
- component: React.forwardRef(({ children, ...restProps }, ref) => (
-
-
- {/* Replace with a renderer: renderUserProfileTile() */}
-
-
- {children}
-
- )),
- style: { width: MENU_ITEM_WIDTH },
- },
- // eslint-disable-next-line react/display-name
- ListItem: React.forwardRef((listItemProps, ref) => {
- return (
-
- );
- }),
- },
- userMenuProps.overrides
- );
-
- return (
- (
- {
- props.onItemSelect(item);
- close();
- }}
- {...userMenuProps}
- />
- )}
- autoFocus={false}
- dismissOnEsc={true}
- dismissOnClickOutside={true}
- onOpen={() => setIsOpen(true)}
- onClose={() => setIsOpen(false)}
- placement={PLACEMENT.bottomRight}
- popperOptions={{ modifiers: { flip: { enabled: false } } }}
- triggerType={TRIGGER_TYPE.click}
- >
-
-
- {isOpen ? (
-
- ) : (
-
- )}
-
-
- );
-}
diff --git a/src/app-nav-bar/user-profile-tile.js.flow b/src/app-nav-bar/user-profile-tile.js.flow
deleted file mode 100644
index a7236b7a1e..0000000000
--- a/src/app-nav-bar/user-profile-tile.js.flow
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { Avatar } from '../avatar/index.js';
-import { getOverrides } from '../helpers/overrides.js';
-import { LabelMedium, ParagraphSmall } from '../typography/index.js';
-
-import {
- StyledUserProfileTileContainer,
- StyledUserProfilePictureContainer,
- StyledUserProfileInfoContainer,
-} from './styled-components.js';
-import type { OverridesT, UserMenuPropsT } from './types.js';
-
-export default function UserProfileTile(props: {| ...UserMenuPropsT, overrides: OverridesT |}) {
- const { overrides = {}, username, usernameSubtitle, userImgUrl } = props;
-
- const [UserProfileTileContainer, userProfileTileContainerProps] = getOverrides(
- overrides.UserProfileTileContainer,
- StyledUserProfileTileContainer
- );
-
- const [UserProfilePictureContainer, userProfilePictureContainerProps] = getOverrides(
- overrides.UserProfilePictureContainer,
- StyledUserProfilePictureContainer
- );
-
- const [UserProfileInfoContainer, userProfileInfoContainerProps] = getOverrides(
- overrides.UserProfileInfoContainer,
- StyledUserProfileInfoContainer
- );
-
- return (
- // Replace with a profile tile renderer: renderUserProfileTile()
-
-
-
-
-
- {username}
- {usernameSubtitle ? (
-
- {usernameSubtitle}
-
- ) : null}
-
-
- );
-}
diff --git a/src/app-nav-bar/utils.js.flow b/src/app-nav-bar/utils.js.flow
deleted file mode 100644
index 75d96d9096..0000000000
--- a/src/app-nav-bar/utils.js.flow
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import type { NavItemT } from './types.js';
-
-type GetUniqueIdentifierT = (NavItemT) => string | number;
-
-export function defaultMapItemToNode(item: NavItemT) {
- if (__DEV__) {
- if (!item.label) {
- throw Error(
- 'There needs to be an unique item.label. You can implement a custom mapping with the mapItemToNode prop.'
- );
- }
- }
- return item.label;
-}
-
-function defaultGetUniqueIdentifier(item: NavItemT) {
- if (__DEV__) {
- if (!item.label) {
- throw Error(
- 'There needs to be an unique item.label. You can implement a custom mapping with the getUniqueIdentifier argument to setItemActive.'
- );
- }
- }
- return item.label;
-}
-
-export function mapItemsActive(items: NavItemT[], predicate: (NavItemT) => boolean) {
- return items.map((current) => {
- if (predicate(current)) {
- current.active = true;
- } else {
- current.active = false;
- }
-
- if (current.children) {
- current.children = mapItemsActive(current.children, predicate);
- if (current.children.some((child) => child.active)) {
- current.active = true;
- }
- }
-
- return current;
- });
-}
-
-export function setItemActive(
- items: NavItemT[],
- item: NavItemT,
- getUniqueIdentifier?: GetUniqueIdentifierT = defaultGetUniqueIdentifier
-) {
- return mapItemsActive(
- items,
- (current) => getUniqueIdentifier(current) === getUniqueIdentifier(item)
- );
-}
diff --git a/src/aspect-ratio-box/aspect-ratio-box-body.js.flow b/src/aspect-ratio-box/aspect-ratio-box-body.js.flow
deleted file mode 100644
index 33d030e72e..0000000000
--- a/src/aspect-ratio-box/aspect-ratio-box-body.js.flow
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import Block from '../block/block.js';
-import type { BlockPropsT } from '../block/types.js';
-
-export const AspectRatioBoxBody = ({
- position,
- top,
- bottom,
- width,
- ...restProps
-}: $Exact): React.Node => (
-
-);
-
-export default AspectRatioBoxBody;
diff --git a/src/aspect-ratio-box/aspect-ratio-box.js.flow b/src/aspect-ratio-box/aspect-ratio-box.js.flow
deleted file mode 100644
index 7bdeefda48..0000000000
--- a/src/aspect-ratio-box/aspect-ratio-box.js.flow
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { Block } from '../block/index.js';
-import { mergeOverrides } from '../helpers/overrides.js';
-import type { AspectRatioBoxPropsT } from './types.js';
-
-const aspectRatioBoxStyle = ({ $aspectRatio }) => ({
- position: 'relative',
- '::before': {
- content: '""',
- width: '1px',
- marginLeft: '-1px',
- float: 'left',
- height: 0,
- paddingTop: `${100 / $aspectRatio}%`,
- pointerEvents: 'none',
- },
- '::after': {
- content: '""',
- display: 'table',
- clear: 'both',
- },
-});
-
-const AspectRatioBox = ({
- forwardedRef,
- aspectRatio = 1,
- overrides = {},
- ...restProps
-}: // flowlint-next-line unclear-type:off
-AspectRatioBoxPropsT & { forwardedRef: any }): React.Node => {
- const aspectRatioBoxOverrides = {
- Block: {
- style: aspectRatioBoxStyle,
- },
- };
- const blockOverrides = mergeOverrides(aspectRatioBoxOverrides, overrides);
- return (
-
- );
-};
-
-const AspectRatioBoxComponent = React.forwardRef(
- (props: AspectRatioBoxPropsT, ref) =>
-);
-AspectRatioBoxComponent.displayName = 'AspectRatioBox';
-export default AspectRatioBoxComponent;
diff --git a/src/aspect-ratio-box/index.js.flow b/src/aspect-ratio-box/index.js.flow
deleted file mode 100644
index 4917fab41c..0000000000
--- a/src/aspect-ratio-box/index.js.flow
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { default as AspectRatioBox } from './aspect-ratio-box.js';
-export { default as AspectRatioBoxBody } from './aspect-ratio-box-body.js';
-export type * from './types.js';
diff --git a/src/aspect-ratio-box/types.js.flow b/src/aspect-ratio-box/types.js.flow
deleted file mode 100644
index bd6008e3c1..0000000000
--- a/src/aspect-ratio-box/types.js.flow
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import type { BlockPropsT } from '../block/types.js';
-
-export type AspectRatioBoxPropsT = {
- /** Aspect ratio is width divided by height. */
- +aspectRatio?: number,
-} & BlockPropsT;
diff --git a/src/avatar/avatar.js.flow b/src/avatar/avatar.js.flow
deleted file mode 100644
index b543d4c56b..0000000000
--- a/src/avatar/avatar.js.flow
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { getOverrides } from '../helpers/overrides.js';
-
-import {
- Avatar as StyledAvatar,
- Initials as StyledInitials,
- Root as StyledRoot,
-} from './styled-components.js';
-import type { PropsT } from './types.js';
-
-function getInitials(name) {
- const words = name.split(' ');
- const initials = words.map((word) => word[0]);
- return initials.slice(0, 2).join('').toUpperCase();
-}
-
-export default function Avatar({
- initials,
- name = '',
- overrides = {},
- size = 'scale1000',
- src,
-}: PropsT) {
- // $FlowFixMe
- const imageRef = React.useRef(null);
- const [imageLoaded, setImageLoaded] = React.useState(false);
-
- function handleLoad() {
- setImageLoaded(true);
- }
-
- function handleError() {
- setImageLoaded(false);
- }
-
- React.useEffect(() => {
- setImageLoaded(false);
-
- if (imageRef.current) {
- if (typeof src === 'string') {
- imageRef.current.src = src;
- imageRef.current.onload = handleLoad;
- imageRef.current.onerror = handleError;
- }
- }
-
- return () => {
- if (imageRef.current) {
- imageRef.current.onload = null;
- imageRef.current.onerror = null;
- }
- };
- }, [src]);
-
- const [Avatar, avatarProps] = getOverrides(overrides.Avatar, StyledAvatar);
- const [Initials, initialsProps] = getOverrides(overrides.Initials, StyledInitials);
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
-
- return (
-
-
-
- {!imageLoaded && {initials || getInitials(name)}}
-
- );
-}
diff --git a/src/avatar/index.js.flow b/src/avatar/index.js.flow
deleted file mode 100644
index ec51f5cdc7..0000000000
--- a/src/avatar/index.js.flow
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { default as Avatar } from './avatar.js';
-
-// Styled elements
-export {
- Avatar as StyledAvatar,
- Initials as StyledInitials,
- Root as StyledRoot,
-} from './styled-components.js';
-
-// Flow
-export type * from './types.js';
diff --git a/src/avatar/styled-components.js.flow b/src/avatar/styled-components.js.flow
deleted file mode 100644
index 8d28d9ae26..0000000000
--- a/src/avatar/styled-components.js.flow
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import { styled } from '../styles/index.js';
-import type { AvatarStylePropsT, RootStylePropsT, InitialsStylePropsT } from './types.js';
-
-function getSize(props) {
- const { $size, $theme } = props;
-
- const defaultSize = $theme.sizing.scale1000;
- const size = $size || defaultSize;
- return $theme.sizing[size] || size;
-}
-
-export const Avatar = styled('img', (props) => {
- const themedSize = getSize(props);
-
- return {
- borderTopLeftRadius: '50%',
- borderTopRightRadius: '50%',
- borderBottomRightRadius: '50%',
- borderBottomLeftRadius: '50%',
- boxSizing: 'border-box',
- display: props.$imageLoaded ? 'block' : 'none',
- height: themedSize,
- width: themedSize,
- objectFit: 'cover',
- };
-});
-
-export const Initials = styled('div', (props) => ({
- ...props.$theme.typography.font300,
- color: props.$theme.colors.contentInversePrimary,
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- height: '100%',
-}));
-
-export const Root = styled('div', (props) => {
- const { $didImageFailToLoad } = props;
- const themedSize = getSize(props);
-
- return ({
- backgroundColor: $didImageFailToLoad ? props.$theme.colors.backgroundInversePrimary : null,
- borderTopLeftRadius: '50%',
- borderTopRightRadius: '50%',
- borderBottomRightRadius: '50%',
- borderBottomLeftRadius: '50%',
- boxSizing: 'border-box',
- display: 'inline-block',
-
- // image previously set the root height/width
- // since image is not rendered, set the height/width
- height: $didImageFailToLoad ? themedSize : null,
- width: $didImageFailToLoad ? themedSize : null,
- }: {});
-});
diff --git a/src/avatar/types.js.flow b/src/avatar/types.js.flow
deleted file mode 100644
index 5d4cf2fb14..0000000000
--- a/src/avatar/types.js.flow
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type InitialsStylePropsT = {};
-export type AvatarStylePropsT = {
- $didImageFailToLoad?: boolean,
- $imageLoaded?: boolean,
- $size?: string,
-};
-export type RootStylePropsT = {
- $didImageFailToLoad: boolean,
- $size?: string,
-};
-export type StylePropsT = RootStylePropsT;
-
-export type OverridesT = {
- Avatar?: OverrideT,
- Initials?: OverrideT,
- Root?: OverrideT,
-};
-
-export type PropsT = {|
- /** Bypasses initial generation from provided name with this value. */
- initials?: string,
- /** Defines an alternative text description of the image. */
- name?: string,
- overrides?: OverridesT,
- /** Defines the width/height of the image. Accepts labels from theme.sizing, or passes value to height/width. */
- size?: string,
- /** Image to display. */
- src?: string,
-|};
diff --git a/src/badge/badge.js.flow b/src/badge/badge.js.flow
deleted file mode 100644
index e536a20e1a..0000000000
--- a/src/badge/badge.js.flow
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { getOverrides } from '../helpers/overrides.js';
-import { StyledBadge, StyledRoot, StyledPositioner } from './styled-components.js';
-import type { BadgePropsT } from './types.js';
-import { PLACEMENT, ROLE, SHAPE, HIERARCHY } from './constants.js';
-import { getAnchorFromChildren } from './utils.js';
-
-const Badge = ({
- children,
- content,
- color,
- shape = SHAPE.rectangle,
- placement = PLACEMENT.topRight,
- hierarchy,
- horizontalOffset,
- verticalOffset,
- hidden,
- overrides = {},
-}: BadgePropsT) => {
- const [Badge, badgeProps] = getOverrides(overrides.Badge, StyledBadge);
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
- const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
-
- const anchor = getAnchorFromChildren(children);
-
- const VALID_RECT_PLACEMENTS = [
- PLACEMENT.topLeft,
- PLACEMENT.topRight,
- PLACEMENT.bottomRight,
- PLACEMENT.bottomLeft,
- ];
-
- if (__DEV__) {
- if (shape === SHAPE.rectangle && !VALID_RECT_PLACEMENTS.includes(placement)) {
- console.warn('Rectangle badges should only be placed in a corner or used inline');
- }
- if (shape === SHAPE.rectangle && hierarchy === HIERARCHY.secondary && anchor) {
- console.warn(
- 'Secondary badges should not be positioned. Use the inline version of this badge instead.'
- );
- }
- if (shape === SHAPE.pill && hierarchy === HIERARCHY.secondary) {
- console.warn('Pill badges should only be used with primary hierarchy');
- }
- }
-
- // If there's no anchor, render the badge inline
- if (!anchor) {
- return (
-
- {content}
-
- );
- }
-
- return (
-
- {anchor}
-
-
- {content}
-
-
-
- );
-};
-export default Badge;
diff --git a/src/badge/constants.js.flow b/src/badge/constants.js.flow
deleted file mode 100644
index 2e7abac2ee..0000000000
--- a/src/badge/constants.js.flow
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export const HIERARCHY = Object.freeze({
- primary: 'primary',
- secondary: 'secondary',
-});
-
-export const SHAPE = Object.freeze({
- pill: 'pill',
- rectangle: 'rectangle',
-});
-
-export const COLOR = Object.freeze({
- accent: 'accent',
- primary: 'primary',
- positive: 'positive',
- negative: 'negative',
- warning: 'warning',
-});
-
-export const PLACEMENT = Object.freeze({
- topLeft: 'topLeft',
- topRight: 'topRight',
- bottomRight: 'bottomRight',
- bottomLeft: 'bottomLeft',
- topLeftEdge: 'topLeftEdge',
- topEdge: 'topEdge',
- topRightEdge: 'topRightEdge',
- bottomRightEdge: 'bottomRightEdge',
- bottomEdge: 'bottomEdge',
- bottomLeftEdge: 'bottomLeftEdge',
- leftTopEdge: 'leftTopEdge',
- rightTopEdge: 'rightTopEdge',
- rightBottomEdge: 'rightBottomEdge',
- leftBottomEdge: 'leftBottomEdge',
-});
-
-export const ROLE = Object.freeze({
- badge: 'badge',
- notificationCircle: 'notificationCircle',
- hintDot: 'hintDot',
-});
diff --git a/src/badge/hint-dot.js.flow b/src/badge/hint-dot.js.flow
deleted file mode 100644
index 5e1b31ee16..0000000000
--- a/src/badge/hint-dot.js.flow
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { useStyletron } from '../styles/index.js';
-import { getOverrides } from '../helpers/overrides.js';
-import { StyledHintDot, StyledRoot, StyledPositioner } from './styled-components.js';
-import type { HintDotPropsT } from './types.js';
-import { PLACEMENT, ROLE } from './constants.js';
-import { getAnchorFromChildren } from './utils.js';
-
-const HintDot = ({
- children,
- color,
- horizontalOffset: horizontalOffsetProp,
- verticalOffset: verticalOffsetProp,
- hidden,
- overrides = {},
-}: HintDotPropsT) => {
- const [HintDot, hintDotProps] = getOverrides(overrides.Badge, StyledHintDot);
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
- const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
-
- const [, theme] = useStyletron();
-
- const anchor = getAnchorFromChildren(children);
-
- // if the anchor is a string, we supply default offsets
- let horizontalOffset = horizontalOffsetProp;
- let verticalOffset = verticalOffsetProp;
- if (typeof anchor === 'string') {
- if (!horizontalOffset) {
- horizontalOffset = '-14px';
- }
- if (!verticalOffset) {
- verticalOffset = '-4px';
- }
- }
- return (
-
- {anchor}
-
-
-
-
- );
-};
-export default HintDot;
diff --git a/src/badge/index.js.flow b/src/badge/index.js.flow
deleted file mode 100644
index 97fe09e117..0000000000
--- a/src/badge/index.js.flow
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-export { default as Badge } from './badge.js';
-export { default as NotificationCircle } from './notification-circle.js';
-export { default as HintDot } from './hint-dot.js';
-
-export { HIERARCHY, SHAPE, COLOR, PLACEMENT } from './constants.js';
-
-export * from './styled-components.js';
-
-export type * from './types.js';
diff --git a/src/badge/notification-circle.js.flow b/src/badge/notification-circle.js.flow
deleted file mode 100644
index f5b3a9deea..0000000000
--- a/src/badge/notification-circle.js.flow
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { getOverrides } from '../helpers/overrides.js';
-import { StyledNotificationCircle, StyledRoot, StyledPositioner } from './styled-components.js';
-import type { NotificationCirclePropsT } from './types.js';
-import { PLACEMENT, ROLE } from './constants.js';
-import { getAnchorFromChildren } from './utils.js';
-
-const NotificationCircle = ({
- children,
- content: contentProp,
- color,
- placement = PLACEMENT.topRight,
- horizontalOffset,
- verticalOffset,
- hidden,
- overrides = {},
-}: NotificationCirclePropsT) => {
- const [NotificationCircle, NotificationCircleProps] = getOverrides(
- overrides.Badge,
- StyledNotificationCircle
- );
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
- const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
-
- const anchor = getAnchorFromChildren(children);
-
- if (__DEV__) {
- if (typeof contentProp === 'string') {
- console.error(`[baseui] NotificationCircle child must be number or icon, found string`);
- }
- if (placement && placement !== PLACEMENT.topLeft && placement !== PLACEMENT.topRight) {
- console.error(
- `[baseui] NotificationCircle must be placed topLeft or topRight, found ${placement}`
- );
- }
- }
-
- let content = contentProp;
- if (typeof content === 'number' && content > 9) {
- content = '9+';
- }
-
- // If there's no anchor, render the badge inline
- if (!anchor) {
- return (
-
- {content}
-
- );
- }
-
- return (
-
- {anchor}
-
-
- {content}
-
-
-
- );
-};
-export default NotificationCircle;
diff --git a/src/badge/styled-components.js.flow b/src/badge/styled-components.js.flow
deleted file mode 100644
index a8b7f21691..0000000000
--- a/src/badge/styled-components.js.flow
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import { styled } from '../styles/index.js';
-import type { PlacementT, ColorT, ShapeT, RoleT, HierarchyT } from './types.js';
-import { COLOR, SHAPE, ROLE, PLACEMENT, HIERARCHY } from './constants.js';
-
-function getColorStyles({ $theme, $hierarchy, $color }): {|
- color: string,
- backgroundColor: string,
-|} {
- const COLOR_STYLES = {
- [HIERARCHY.primary]: {
- [COLOR.accent]: {
- color: $theme.colors.contentOnColor,
- backgroundColor: $theme.colors.backgroundAccent,
- },
- [COLOR.primary]: {
- color: $theme.colors.contentInversePrimary,
- backgroundColor: $theme.colors.backgroundInversePrimary,
- },
- [COLOR.positive]: {
- color: $theme.colors.contentOnColor,
- backgroundColor: $theme.colors.backgroundPositive,
- },
- [COLOR.negative]: {
- color: $theme.colors.contentOnColor,
- backgroundColor: $theme.colors.backgroundNegative,
- },
- [COLOR.warning]: {
- color: $theme.colors.contentOnColorInverse,
- backgroundColor: $theme.colors.backgroundWarning,
- },
- },
- [HIERARCHY.secondary]: {
- [COLOR.accent]: {
- color: $theme.colors.contentAccent,
- backgroundColor: $theme.colors.backgroundAccentLight,
- },
- [COLOR.primary]: {
- color: $theme.colors.contentPrimary,
- backgroundColor: $theme.colors.backgroundSecondary,
- },
- [COLOR.positive]: {
- color: $theme.colors.contentPositive,
- backgroundColor: $theme.colors.backgroundPositiveLight,
- },
- [COLOR.negative]: {
- color: $theme.colors.contentNegative,
- backgroundColor: $theme.colors.backgroundNegativeLight,
- },
- [COLOR.warning]: {
- color: $theme.colors.contentWarning,
- backgroundColor: $theme.colors.backgroundWarningLight,
- },
- },
- };
-
- return COLOR_STYLES[$hierarchy][$color];
-}
-
-const DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
- top: '-10px',
- right: '-10px',
-};
-
-const DEFAULT_HINT_DOT_PLACEMENT = {
- top: '-4px',
- right: '-4px',
-};
-
-const POSITION_STYLES = Object.freeze({
- [ROLE.badge]: {
- [PLACEMENT.topEdge]: {
- top: '-8px',
- left: '50%',
- transform: 'translateX(-50%)',
- },
- [PLACEMENT.bottomEdge]: {
- bottom: '-8px',
- left: '50%',
- transform: 'translateX(-50%)',
- },
- [PLACEMENT.topLeft]: {
- top: '16px',
- left: '16px',
- },
- [PLACEMENT.topRight]: {
- top: '16px',
- right: '16px',
- },
- [PLACEMENT.bottomRight]: {
- bottom: '16px',
- right: '16px',
- },
-
- [PLACEMENT.bottomLeft]: {
- bottom: '16px',
- left: '16px',
- },
- [PLACEMENT.topLeftEdge]: {
- top: '-8px',
- left: '16px',
- },
- [PLACEMENT.topRightEdge]: {
- top: '-8px',
- right: '16px',
- },
- [PLACEMENT.bottomRightEdge]: {
- bottom: '-8px',
- right: '16px',
- },
- [PLACEMENT.bottomLeftEdge]: {
- bottom: '-8px',
- left: '16px',
- },
- [PLACEMENT.leftTopEdge]: {
- top: '16px',
- left: '-8px',
- },
- [PLACEMENT.rightTopEdge]: {
- top: '16px',
- right: '-8px',
- },
- [PLACEMENT.rightBottomEdge]: {
- bottom: '16px',
- right: '-8px',
- },
- [PLACEMENT.leftBottomEdge]: {
- bottom: '16px',
- left: '-8px',
- },
- },
- [ROLE.notificationCircle]: {
- [PLACEMENT.topLeft]: {
- top: '-10px',
- left: '-10px',
- },
- [PLACEMENT.topRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- // NotificationCircle can only be placed topLeft or topRight, other values fall back to topRight
- [PLACEMENT.topEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.bottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.bottomRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.bottomLeft]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.topLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.topRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.bottomRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.bottomLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.leftTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.rightTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.rightBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- [PLACEMENT.leftBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
- },
- [ROLE.hintDot]: {
- [PLACEMENT.topLeft]: {
- top: '-4px',
- left: '-4px',
- },
- [PLACEMENT.topRight]: DEFAULT_HINT_DOT_PLACEMENT,
- // HintDot can only be placed topLeft or topRight, other values fall back to topRight
- [PLACEMENT.topEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.bottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.bottomRight]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.bottomLeft]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.topLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.topRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.bottomRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.bottomLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.leftTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.rightTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.rightBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- [PLACEMENT.leftBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
- },
-});
-
-export const StyledRoot = styled<{}>('div', () => {
- return {
- position: 'relative',
- display: 'inline-block',
- lineHeight: 'initial',
- };
-});
-StyledRoot.displayName = 'StyledRoot';
-
-const TOP_PLACEMENTS = [
- PLACEMENT.topLeft,
- PLACEMENT.topRight,
- PLACEMENT.topLeftEdge,
- PLACEMENT.topEdge,
- PLACEMENT.topRightEdge,
- PLACEMENT.leftTopEdge,
- PLACEMENT.rightTopEdge,
-];
-const BOTTOM_PLACEMENTS = [
- PLACEMENT.bottomLeft,
- PLACEMENT.bottomRight,
- PLACEMENT.bottomLeftEdge,
- PLACEMENT.bottomEdge,
- PLACEMENT.bottomRightEdge,
- PLACEMENT.leftBottomEdge,
- PLACEMENT.rightBottomEdge,
-];
-const LEFT_PLACEMENTS = [
- PLACEMENT.topLeft,
- PLACEMENT.topLeftEdge,
- PLACEMENT.topEdge,
- PLACEMENT.bottomLeft,
- PLACEMENT.bottomLeftEdge,
- PLACEMENT.bottomEdge,
- PLACEMENT.leftTopEdge,
- PLACEMENT.leftBottomEdge,
-];
-const RIGHT_PLACEMENTS = [
- PLACEMENT.topRight,
- PLACEMENT.topRightEdge,
- PLACEMENT.bottomRight,
- PLACEMENT.bottomRightEdge,
- PLACEMENT.rightTopEdge,
- PLACEMENT.rightBottomEdge,
-];
-
-export const StyledPositioner = styled<{
- $role: RoleT,
- $placement: PlacementT,
- $horizontalOffset?: ?string,
- $verticalOffset?: ?string,
-}>('div', ({ $theme, $role, $placement, $horizontalOffset, $verticalOffset }) => {
- let positionStyle = POSITION_STYLES[$role][$placement];
-
- if ($verticalOffset) {
- if (TOP_PLACEMENTS.includes($placement)) {
- positionStyle = { ...positionStyle, top: $verticalOffset };
- }
- if (BOTTOM_PLACEMENTS.includes($placement)) {
- positionStyle = { ...positionStyle, bottom: $verticalOffset };
- }
- }
-
- if ($horizontalOffset) {
- if (LEFT_PLACEMENTS.includes($placement)) {
- positionStyle = { ...positionStyle, left: $horizontalOffset };
- }
- if (RIGHT_PLACEMENTS.includes($placement)) {
- positionStyle = { ...positionStyle, right: $horizontalOffset };
- }
- }
-
- return {
- ...positionStyle,
- position: 'absolute',
- lineHeight: 'initial',
- };
-});
-StyledPositioner.displayName = 'StyledPositioner';
-
-export const StyledBadge = styled<{
- $shape?: ShapeT,
- $color?: ColorT,
- $hierarchy?: HierarchyT,
- $hidden?: boolean,
-}>(
- 'div',
- ({
- $theme,
- $shape = SHAPE.rectangle,
- $color = COLOR.accent,
- $hierarchy = HIERARCHY.primary,
- $hidden,
- }) => {
- return {
- visibility: $hidden ? 'hidden' : 'inherit',
- boxSizing: 'border-box',
- height: $theme.sizing.scale700,
- borderRadius:
- $shape === SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
- paddingRight: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
- paddingLeft: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
- display: 'inline-flex',
- alignItems: 'center',
- ...getColorStyles({ $theme, $hierarchy, $color }),
- ...($hierarchy === HIERARCHY.primary
- ? $theme.typography.LabelSmall
- : $theme.typography.ParagraphSmall),
- };
- }
-);
-StyledBadge.displayName = 'StyledBadge';
-
-export const StyledNotificationCircle = styled<{
- $color?: ColorT,
- $hidden?: boolean,
-}>('div', ({ $theme, $color = COLOR.accent, $hidden }) => {
- return {
- visibility: $hidden ? 'hidden' : 'inherit',
- height: $theme.sizing.scale700,
- width: $theme.sizing.scale700,
- borderRadius: '20px',
- display: 'inline-flex',
- alignItems: 'center',
- justifyContent: 'center',
- ...getColorStyles({ $theme, $hierarchy: HIERARCHY.primary, $color }),
- ...$theme.typography.LabelXSmall,
- };
-});
-StyledNotificationCircle.displayName = 'StyledNotificationCircle';
-
-export const StyledHintDot = styled<{ $color: ColorT, $hidden?: boolean }>(
- 'div',
- ({ $theme, $color = COLOR.accent, $hidden }) => {
- return {
- visibility: $hidden ? 'hidden' : 'inherit',
- backgroundColor: $theme.colors[$color],
- boxSizing: 'content-box',
- height: '8px',
- width: '8px',
- borderRadius: '50%',
- border: `4px solid ${$theme.colors.backgroundPrimary}`,
- ...getColorStyles({ $theme, $hierarchy: HIERARCHY.primary, $color }),
- };
- }
-);
-StyledHintDot.displayName = 'StyledHintDot';
diff --git a/src/badge/types.js.flow b/src/badge/types.js.flow
deleted file mode 100644
index 5c2b786f85..0000000000
--- a/src/badge/types.js.flow
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import { HIERARCHY, SHAPE, COLOR, PLACEMENT, ROLE } from './constants.js';
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type HierarchyT = $Values;
-export type ShapeT = $Values;
-export type ColorT = $Values;
-export type PlacementT = $Values;
-export type RoleT = $Values;
-
-export type BadgeOverridesT = {
- Root?: OverrideT,
- Positioner?: OverrideT,
- Badge?: OverrideT,
-};
-
-export type BadgePropsT = {
- content: React.Node,
- hierarchy?: HierarchyT,
- shape?: ShapeT,
- color?: ColorT,
- placement?: PlacementT,
- hidden?: boolean,
- horizontalOffset?: string,
- verticalOffset?: string,
- overrides?: BadgeOverridesT,
- children?: React.Node,
-};
-
-export type NotificationCirclePropsT = {
- content: React.Node,
- color?: ColorT,
- placement?: PlacementT,
- hidden?: boolean,
- horizontalOffset?: string,
- verticalOffset?: string,
- overrides?: BadgeOverridesT,
- children?: React.Node,
-};
-
-export type HintDotPropsT = {
- color?: ColorT,
- hidden?: boolean,
- horizontalOffset?: string,
- verticalOffset?: string,
- overrides?: BadgeOverridesT,
- children?: React.Node,
-};
diff --git a/src/badge/utils.js.flow b/src/badge/utils.js.flow
deleted file mode 100644
index 639a2aba53..0000000000
--- a/src/badge/utils.js.flow
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-
-export const getAnchorFromChildren = (children: ?React.Node) => {
- const childArray = React.Children.toArray(children);
- if (childArray.length !== 1) {
- // eslint-disable-next-line no-console
- console.error(
- `[baseui] No more than 1 child may be passed to Badge, found ${childArray.length} children`
- );
- }
- return childArray[0];
-};
diff --git a/src/banner/banner.js.flow b/src/banner/banner.js.flow
deleted file mode 100644
index 4a415a21f1..0000000000
--- a/src/banner/banner.js.flow
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import { Button, SIZE as BUTTON_SIZE, SHAPE as BUTTON_SHAPE } from '../button/index.js';
-import { getOverrides } from '../helpers/overrides.js';
-import { useStyletron } from '../styles/index.js';
-import { ACTION_POSITION, ARTWORK_TYPE, HIERARCHY, KIND } from './constants.js';
-import {
- StyledRoot,
- StyledLeadingContent,
- StyledMessageContent,
- StyledTitle,
- StyledMessage,
- StyledBelowContent,
- StyledTrailingContent,
- StyledTrailingButtonContainer,
- StyledTrailingIconButton,
-} from './styled-components.js';
-import type { PropsT } from './types.js';
-
-function low(theme, kind) {
- switch (kind) {
- case KIND.negative:
- return {
- actionBackgroundColor: theme.colors.bannerActionLowNegative,
- backgroundColor: theme.colors.backgroundNegativeLight,
- color: theme.colors.contentPrimary,
- };
-
- case KIND.positive:
- return {
- actionBackgroundColor: theme.colors.bannerActionLowPositive,
- backgroundColor: theme.colors.backgroundPositiveLight,
- color: theme.colors.contentPrimary,
- };
-
- case KIND.warning:
- return {
- actionBackgroundColor: theme.colors.bannerActionLowWarning,
- backgroundColor: theme.colors.backgroundWarningLight,
- color: theme.colors.contentPrimary,
- };
-
- case KIND.info:
- default:
- return {
- actionBackgroundColor: theme.colors.bannerActionLowInfo,
- backgroundColor: theme.colors.backgroundAccentLight,
- color: theme.colors.contentPrimary,
- };
- }
-}
-
-function high(theme, kind) {
- switch (kind) {
- case KIND.negative:
- return {
- actionBackgroundColor: theme.colors.bannerActionHighNegative,
- backgroundColor: theme.colors.backgroundNegative,
- color: theme.colors.contentOnColor,
- };
-
- case KIND.positive:
- return {
- actionBackgroundColor: theme.colors.bannerActionHighPositive,
- backgroundColor: theme.colors.backgroundPositive,
- color: theme.colors.contentOnColor,
- };
-
- case KIND.warning:
- return {
- actionBackgroundColor: theme.colors.bannerActionHighWarning,
- backgroundColor: theme.colors.backgroundWarning,
- color: theme.colors.contentPrimary,
- };
-
- case KIND.info:
- default:
- return {
- actionBackgroundColor: theme.colors.bannerActionHighInfo,
- backgroundColor: theme.colors.backgroundAccent,
- color: theme.colors.contentOnColor,
- };
- }
-}
-
-function Leading({ artwork }) {
- const [, theme] = useStyletron();
-
- if (!artwork) {
- return null;
- }
-
- const size = artwork.type === ARTWORK_TYPE.badge ? theme.sizing.scale1000 : theme.sizing.scale800;
- return artwork.icon({ size });
-}
-
-function Below({ action, backgroundColor, color }) {
- if (!action || action.position !== ACTION_POSITION.below) {
- return null;
- }
-
- if (__DEV__) {
- if (action.icon) {
- console.error('Banner ACTION_POSITION.below must not have an icon.');
- return null;
- }
- }
-
- if (action.label) {
- return (
-
- );
- }
-
- return null;
-}
-
-function Trailing({ action, backgroundColor, color, overrides, nested }) {
- const [, theme] = useStyletron();
-
- if (!action || (action.position && action.position !== ACTION_POSITION.trailing)) {
- return null;
- }
-
- const [TrailingIconButton, trailingIconButtonProps] = getOverrides(
- overrides.TrailingIconButton,
- StyledTrailingIconButton
- );
-
- if (action.icon) {
- return (
-
- {action.icon({ size: theme.sizing.scale650 })}
-
- );
- }
-
- const [TrailingButtonContainer, trailingButtonContainerProps] = getOverrides(
- overrides.TrailingButtonContainer,
- StyledTrailingButtonContainer
- );
-
- if (action.label) {
- return (
-
-
-
- );
- }
-
- return null;
-}
-
-export function Banner({
- action,
- artwork,
- children,
- hierarchy = HIERARCHY.low,
- kind = KIND.info,
- overrides = {},
- nested = false,
- title,
-}: PropsT) {
- const [, theme] = useStyletron();
- const styles = hierarchy === HIERARCHY.high ? high(theme, kind) : low(theme, kind);
- const actionPosition = action && action.position ? action.position : ACTION_POSITION.trailing;
-
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
- const [LeadingContent, leadingContentProps] = getOverrides(
- overrides.LeadingContent,
- StyledLeadingContent
- );
- const [MessageContent, messageContentProps] = getOverrides(
- overrides.MessageContent,
- StyledMessageContent
- );
- const [TrailingContent, trailingContentProps] = getOverrides(
- overrides.TrailingContent,
- StyledTrailingContent
- );
- const [BelowContent, belowContentProps] = getOverrides(
- overrides.BelowContent,
- StyledBelowContent
- );
- const [Title, titleProps] = getOverrides(overrides.Title, StyledTitle);
- const [Message, messageProps] = getOverrides(overrides.Message, StyledMessage);
- const ariaLabel = rootProps.hasOwnProperty('aria-label')
- ? rootProps['aria-label']
- : 'this is an announcement banner';
-
- return (
-
-
-
-
-
-
- {Boolean(title) && {title}}
- {Boolean(children) && {children}}
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/banner/constants.js.flow b/src/banner/constants.js.flow
deleted file mode 100644
index 7ed35ba87c..0000000000
--- a/src/banner/constants.js.flow
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export const ACTION_POSITION = Object.freeze({
- below: 'below',
- trailing: 'trailing',
-});
-
-export const ARTWORK_TYPE = Object.freeze({
- icon: 'icon',
- badge: 'badge',
-});
-
-export const HIERARCHY = Object.freeze({
- low: 'low',
- high: 'high',
-});
-
-export const KIND = Object.freeze({
- info: 'info',
- negative: 'negative',
- positive: 'positive',
- warning: 'warning',
-});
diff --git a/src/banner/index.js.flow b/src/banner/index.js.flow
deleted file mode 100644
index a9776bb265..0000000000
--- a/src/banner/index.js.flow
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { Banner } from './banner.js';
-export * from './constants.js';
-export * from './styled-components.js';
-export type * from './types.js';
diff --git a/src/banner/styled-components.js.flow b/src/banner/styled-components.js.flow
deleted file mode 100644
index 25a0a40ce6..0000000000
--- a/src/banner/styled-components.js.flow
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import { styled } from '../styles/index.js';
-import { ACTION_POSITION } from './constants.js';
-import type { ActionPositionT } from './types.js';
-
-export const StyledRoot = styled<{ $backgroundColor: string, $color: string, $nested: boolean }>(
- 'div',
- ({ $theme, $backgroundColor, $color, $nested }) => {
- const radius = $nested ? $theme.borders.radius300 : $theme.borders.radius400;
- return {
- backgroundColor: $backgroundColor,
- borderStartStartRadius: radius,
- borderStartEndRadius: radius,
- borderEndStartRadius: radius,
- borderEndEndRadius: radius,
- color: $color,
- display: 'grid',
- gridColumnGap: $theme.sizing.scale600,
- gridTemplateColumns: 'min-content auto min-content',
- gridTemplateRows: 'auto min-content',
- margin: $theme.sizing.scale600,
- };
- }
-);
-
-export const StyledLeadingContent = styled<{ $includesArtwork: boolean }>(
- 'div',
- ({ $theme, $includesArtwork }) => {
- return {
- alignItems: 'center',
- display: 'flex',
- paddingInlineStart: $includesArtwork ? $theme.sizing.scale600 : null,
- };
- }
-);
-
-export const StyledMessageContent = styled<{ $actionPosition: ActionPositionT }>(
- 'div',
- ({ $theme, $actionPosition }) => {
- return {
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- paddingBlockStart: $theme.sizing.scale600,
- paddingBlockEnd: $actionPosition === ACTION_POSITION.trailing ? $theme.sizing.scale600 : null,
- };
- }
-);
-
-export const StyledTrailingContent = styled<{}>('div', ({ $theme }) => {
- return {
- display: 'flex',
- gridRowEnd: 'span 2',
- marginInlineStart: 'auto',
- };
-});
-
-export const StyledBelowContent = styled<{ $actionPosition: ActionPositionT }>(
- 'div',
- ({ $theme, $actionPosition }) => {
- return {
- gridColumnStart: 2,
- paddingBlockStart: $actionPosition === ACTION_POSITION.below ? $theme.sizing.scale300 : null,
- paddingBlockEnd: $actionPosition === ACTION_POSITION.below ? $theme.sizing.scale600 : null,
- };
- }
-);
-
-export const StyledTitle = styled<{}>('div', ({ $theme }) => {
- return $theme.typography.LabelMedium;
-});
-
-export const StyledMessage = styled<{}>('div', ({ $theme }) => {
- return $theme.typography.ParagraphMedium;
-});
-
-export const StyledTrailingButtonContainer = styled<{}>('div', ({ $theme }) => {
- return {
- display: 'flex',
- alignItems: 'center',
- paddingInlineEnd: $theme.sizing.scale600,
- };
-});
-
-export const StyledTrailingIconButton = styled<{ $nested: boolean }>(
- 'button',
- ({ $theme, $nested }) => {
- const radius = $nested ? $theme.borders.radius300 : $theme.borders.radius400;
- return {
- alignItems: 'center',
- background: 'none',
- border: 'none',
- borderStartEndRadius: radius,
- borderEndEndRadius: radius,
- color: 'inherit',
- cursor: 'pointer',
- display: 'flex',
- paddingInlineStart: $theme.sizing.scale600,
- paddingInlineEnd: $theme.sizing.scale600,
- ':hover': {
- boxShadow: 'inset 999px 999px 0px rgba(0, 0, 0, 0.04)',
- },
- ':active': {
- boxShadow: 'inset 999px 999px 0px rgba(0, 0, 0, 0.08)',
- },
- };
- }
-);
diff --git a/src/banner/types.js.flow b/src/banner/types.js.flow
deleted file mode 100644
index e01522bdc5..0000000000
--- a/src/banner/types.js.flow
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-import { ACTION_POSITION, ARTWORK_TYPE, HIERARCHY, KIND } from './constants.js';
-
-export type ActionPositionT = $Values;
-export type ArtworkTypeT = $Values;
-export type HierarchyT = $Values;
-export type KindT = $Values;
-
-export type ActionContentT = {|
- // Text shown within action button or applied to aria label.
- label: string,
- // If provided renders this icon instead of the text label.
- icon?: ({ size: string }) => React.Node,
- // Called when action button is activated.
- onClick: (SyntheticEvent) => mixed,
- // Determines if action button is positioned trailing message or below.
- position?: ActionPositionT,
-|};
-
-export type ArtworkContentT = {|
- // Element displayed, usually an icon.
- icon: ({ size: string }) => React.Node,
- // Determines artwork size. Icon for graphics with a strong silhouette or badge for more nuance.
- type?: ArtworkTypeT,
-|};
-
-export type OverridesT = {|
- BelowContent?: OverrideT,
- LeadingContent?: OverrideT,
- Message?: OverrideT,
- MessageContent?: OverrideT,
- Root?: OverrideT,
- Title?: OverrideT,
- TrailingContent?: OverrideT,
- TrailingButtonContainer?: OverrideT,
- TrailingIconButton?: OverrideT,
-|};
-
-export type PropsT = {|
- // Provide a method to "accept", "dismiss", or otherwise interact with the message shown.
- action?: ActionContentT,
- // Visually convey the message text.
- artwork?: ArtworkContentT,
- // Message to display.
- children: React.Node,
- // Determines message priority by rendering in pale or saturated colors.
- hierarchy?: HierarchyT,
- // Determines color scheme and conveys message intent.
- kind?: KindT,
- overrides?: OverridesT,
- // Used to make the banner visually distinct from its container element.
- nested?: boolean,
- // Bold text displayed when message content should be separated to two lines.
- title?: React.Node,
-|};
diff --git a/src/block/block.js.flow b/src/block/block.js.flow
deleted file mode 100644
index 21f0b7536b..0000000000
--- a/src/block/block.js.flow
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import * as React from 'react';
-import type { BlockPropsT } from './types.js';
-import { StyledBlock } from './styled-components.js';
-import { getOverrides } from '../helpers/overrides.js';
-
-function Block({
- forwardedRef,
- children,
- as = 'div',
- overrides = {},
- color,
- backgroundAttachment,
- backgroundClip,
- backgroundColor,
- backgroundImage,
- backgroundOrigin,
- backgroundPosition,
- backgroundRepeat,
- backgroundSize,
- font,
- alignContent,
- alignItems,
- alignSelf,
- flexDirection,
- display,
- flex,
- grid,
- gridArea,
- gridAutoColumns,
- gridAutoFlow,
- gridAutoRows,
- gridColumn,
- gridColumnEnd,
- gridColumnGap,
- gridColumnStart,
- gridGap,
- gridRow,
- gridRowEnd,
- gridRowGap,
- gridRowStart,
- gridTemplate,
- gridTemplateAreas,
- gridTemplateColumns,
- gridTemplateRows,
- justifyContent,
- justifyItems,
- justifySelf,
- position,
- width,
- minWidth,
- maxWidth,
- height,
- minHeight,
- maxHeight,
- overflow,
- margin,
- marginTop,
- marginRight,
- marginBottom,
- marginLeft,
- padding,
- paddingTop,
- paddingRight,
- paddingBottom,
- paddingLeft,
- placeContent,
- placeItems,
- placeSelf,
- flexWrap,
- left,
- top,
- right,
- bottom,
- textOverflow,
- whiteSpace,
- ...restProps
-}) {
- const [BaseBlock, baseBlockProps] = getOverrides(overrides.Block, StyledBlock);
-
- return (
-
- {children}
-
- );
-}
-
-const BlockComponent = React.forwardRef((props: BlockPropsT, ref) => (
-
-));
-BlockComponent.displayName = 'Block';
-export default BlockComponent;
diff --git a/src/block/index.js.flow b/src/block/index.js.flow
deleted file mode 100644
index e68a780920..0000000000
--- a/src/block/index.js.flow
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-export { default as Block } from './block.js';
-export type * from './types.js';
diff --git a/src/block/styled-components.js.flow b/src/block/styled-components.js.flow
deleted file mode 100644
index 28082f59b3..0000000000
--- a/src/block/styled-components.js.flow
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import { getMediaQueries } from '../helpers/responsive-helpers.js';
-import { styled } from '../styles/index.js';
-import type { BreakpointsT } from '../styles/types.js';
-import type { StyledBlockPropsT } from './types.js';
-
-// styletron will throw when value is undefined. if so, replace with null
-function constrainToNull(value) {
- if (value === undefined) {
- return null;
- }
- return value;
-}
-
-type ApplyParams = {
- property: string,
- // flowlint-next-line unclear-type:off
- value?: any | Array,
- // flowlint-next-line unclear-type:off
- transform?: Function,
-};
-
-function build(breakpoints: BreakpointsT) {
- const styles = {};
- const mediaQueries = getMediaQueries(breakpoints);
-
- return {
- apply: ({ property, transform = (x) => x, value }: ApplyParams) => {
- if (value === null || value === undefined) {
- return;
- }
-
- if (Array.isArray(value)) {
- value.forEach((v, index) => {
- // Do not create a media query for the smallest breakpoint.
- if (index === 0) {
- styles[property] = constrainToNull(transform(v));
- return;
- }
-
- const mediaQuery = mediaQueries[index - 1];
- if (!styles[mediaQuery]) {
- styles[mediaQuery] = {};
- }
-
- styles[mediaQuery][property] = constrainToNull(transform(v));
- });
- } else {
- styles[property] = constrainToNull(transform(value));
- }
- },
- value: () => styles,
- };
-}
-
-function getFontValue(obj, key) {
- if (!obj) return;
- return obj[key];
-}
-
-export const StyledBlock = styled('div', (props) => {
- const { breakpoints, colors, typography, sizing } = props.$theme;
-
- const get = (obj, key) => obj[key];
- const getScale = (size) => sizing[size] || size;
-
- const styles = build(breakpoints);
- styles.apply({
- property: 'color',
- value: get(props, '$color'),
- transform: (color) => colors[color] || color,
- });
- styles.apply({
- property: 'backgroundAttachment',
- value: get(props, '$backgroundAttachment'),
- });
- styles.apply({
- property: 'backgroundClip',
- value: get(props, '$backgroundClip'),
- });
- styles.apply({
- property: 'backgroundColor',
- value: get(props, '$backgroundColor'),
- transform: (backgroundColor) => colors[backgroundColor] || backgroundColor,
- });
- styles.apply({
- property: 'backgroundImage',
- value: get(props, '$backgroundImage'),
- });
- styles.apply({
- property: 'backgroundOrigin',
- value: get(props, '$backgroundOrigin'),
- });
- styles.apply({
- property: 'backgroundPosition',
- value: get(props, '$backgroundPosition'),
- });
- styles.apply({
- property: 'backgroundRepeat',
- value: get(props, '$backgroundRepeat'),
- });
- styles.apply({
- property: 'backgroundSize',
- value: get(props, '$backgroundSize'),
- });
- styles.apply({
- property: 'fontFamily',
- value: get(props, '$font'),
- transform: (font) => getFontValue(typography[font], 'fontFamily'),
- });
- styles.apply({
- property: 'fontWeight',
- value: get(props, '$font'),
- transform: (font) => getFontValue(typography[font], 'fontWeight'),
- });
- styles.apply({
- property: 'fontSize',
- value: get(props, '$font'),
- transform: (font) => getFontValue(typography[font], 'fontSize'),
- });
- styles.apply({
- property: 'lineHeight',
- value: get(props, '$font'),
- transform: (font) => getFontValue(typography[font], 'lineHeight'),
- });
-
- styles.apply({
- property: 'alignContent',
- value: get(props, '$alignContent'),
- });
- styles.apply({ property: 'alignItems', value: get(props, '$alignItems') });
- styles.apply({ property: 'alignSelf', value: get(props, '$alignSelf') });
- styles.apply({ property: 'display', value: get(props, '$display') });
- styles.apply({ property: 'flex', value: get(props, '$flex') });
- styles.apply({
- property: 'flexDirection',
- value: get(props, '$flexDirection'),
- });
- styles.apply({ property: 'grid', value: get(props, '$grid') });
- styles.apply({ property: 'gridArea', value: get(props, '$gridArea') });
- styles.apply({
- property: 'gridAutoColumns',
- value: get(props, '$gridAutoColumns'),
- });
- styles.apply({
- property: 'gridAutoFlow',
- value: get(props, '$gridAutoFlow'),
- });
- styles.apply({
- property: 'gridAutoRows',
- value: get(props, '$gridAutoRows'),
- });
- styles.apply({ property: 'gridColumn', value: get(props, '$gridColumn') });
- styles.apply({
- property: 'gridColumnEnd',
- value: get(props, '$gridColumnEnd'),
- });
- styles.apply({
- property: 'gridColumnGap',
- value: get(props, '$gridColumnGap'),
- transform: getScale,
- });
- styles.apply({
- property: 'gridColumnStart',
- value: get(props, '$gridColumnStart'),
- });
- styles.apply({
- property: 'gridGap',
- value: get(props, '$gridGap'),
- transform: getScale,
- });
- styles.apply({ property: 'gridRow', value: get(props, '$gridRow') });
- styles.apply({ property: 'gridRowEnd', value: get(props, '$gridRowEnd') });
- styles.apply({
- property: 'gridRowGap',
- value: get(props, '$gridRowGap'),
- transform: getScale,
- });
- styles.apply({ property: 'gridRowStart', value: get(props, '$gridRowStart') });
- styles.apply({ property: 'gridTemplate', value: get(props, '$gridTemplate') });
- styles.apply({
- property: 'gridTemplateAreas',
- value: get(props, '$gridTemplateAreas'),
- });
- styles.apply({
- property: 'gridTemplateColumns',
- value: get(props, '$gridTemplateColumns'),
- });
- styles.apply({
- property: 'gridTemplateRows',
- value: get(props, '$gridTemplateRows'),
- });
- styles.apply({
- property: 'justifyContent',
- value: get(props, '$justifyContent'),
- });
- styles.apply({
- property: 'justifyItems',
- value: get(props, '$justifyItems'),
- });
- styles.apply({ property: 'justifySelf', value: get(props, '$justifySelf') });
- styles.apply({ property: 'position', value: get(props, '$position') });
- styles.apply({
- property: 'width',
- value: get(props, '$width'),
- transform: getScale,
- });
- styles.apply({
- property: 'minWidth',
- value: get(props, '$minWidth'),
- transform: getScale,
- });
- styles.apply({
- property: 'maxWidth',
- value: get(props, '$maxWidth'),
- transform: getScale,
- });
- styles.apply({
- property: 'height',
- value: get(props, '$height'),
- transform: getScale,
- });
- styles.apply({
- property: 'minHeight',
- value: get(props, '$minHeight'),
- transform: getScale,
- });
- styles.apply({
- property: 'maxHeight',
- value: get(props, '$maxHeight'),
- transform: getScale,
- });
- styles.apply({
- property: 'overflowX',
- value: get(props, '$overflow'),
- transform: (overflow) => {
- if (overflow === 'scrollX') {
- return 'scroll';
- }
- return null;
- },
- });
- styles.apply({
- property: 'overflowY',
- value: get(props, '$overflow'),
- transform: (overflow) => {
- if (overflow === 'scrollY') {
- return 'scroll';
- }
- return null;
- },
- });
- styles.apply({
- property: 'overflow',
- value: get(props, '$overflow'),
- transform: (overflow) => {
- if (overflow !== 'scrollX' && overflow !== 'scrollY') {
- return overflow;
- }
- return null;
- },
- });
-
- styles.apply({
- property: 'margin',
- value: get(props, '$margin'),
- transform: getScale,
- });
- styles.apply({
- property: 'marginTop',
- value: get(props, '$marginTop'),
- transform: getScale,
- });
- styles.apply({
- property: 'marginRight',
- value: get(props, '$marginRight'),
- transform: getScale,
- });
- styles.apply({
- property: 'marginBottom',
- value: get(props, '$marginBottom'),
- transform: getScale,
- });
- styles.apply({
- property: 'marginLeft',
- value: get(props, '$marginLeft'),
- transform: getScale,
- });
-
- styles.apply({
- property: 'padding',
- value: get(props, '$padding'),
- transform: getScale,
- });
- styles.apply({
- property: 'paddingTop',
- value: get(props, '$paddingTop'),
- transform: getScale,
- });
- styles.apply({
- property: 'paddingRight',
- value: get(props, '$paddingRight'),
- transform: getScale,
- });
- styles.apply({
- property: 'paddingBottom',
- value: get(props, '$paddingBottom'),
- transform: getScale,
- });
- styles.apply({
- property: 'paddingLeft',
- value: get(props, '$paddingLeft'),
- transform: getScale,
- });
-
- styles.apply({
- property: 'placeContent',
- value: get(props, '$placeContent'),
- });
- styles.apply({ property: 'placeItems', value: get(props, '$placeItems') });
- styles.apply({ property: 'placeSelf', value: get(props, '$placeSelf') });
- styles.apply({
- property: 'flexWrap',
- value: get(props, '$flexWrap'),
- transform: () => 'wrap',
- });
-
- styles.apply({
- property: 'top',
- value: get(props, '$top'),
- transform: getScale,
- });
- styles.apply({
- property: 'right',
- value: get(props, '$right'),
- transform: getScale,
- });
- styles.apply({
- property: 'left',
- value: get(props, '$left'),
- transform: getScale,
- });
- styles.apply({
- property: 'bottom',
- value: get(props, '$bottom'),
- transform: getScale,
- });
-
- styles.apply({ property: 'textOverflow', value: get(props, '$textOverflow') });
- styles.apply({ property: 'whiteSpace', value: get(props, '$whiteSpace') });
-
- return styles.value();
-});
diff --git a/src/block/types.js.flow b/src/block/types.js.flow
deleted file mode 100644
index 9a79a1ce80..0000000000
--- a/src/block/types.js.flow
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import type { Node, ElementType } from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type OverridesT = {
- Block?: OverrideT,
-};
-
-export type ResponsiveT = T | Array;
-
-type AlignContentT =
- | 'center'
- | 'start'
- | 'end'
- | 'flex-start'
- | 'flex-end'
- | 'normal'
- | 'baseline'
- | 'first baseline'
- | 'last baseline'
- | 'space-between'
- | 'space-around'
- | 'space-evenly'
- | 'stretch'
- | 'safe center'
- | 'unsafe center'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type AlignItemsT =
- | 'normal'
- | 'stretch'
- | 'center'
- | 'start'
- | 'end'
- | 'flex-start'
- | 'flex-end'
- | 'self-start'
- | 'self-end'
- | 'baseline'
- | 'first baseline'
- | 'last baseline'
- | 'safe center'
- | 'unsafe center'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type AlignSelfT =
- | 'auto'
- | 'normal'
- | 'center'
- | 'start'
- | 'end'
- | 'self-start'
- | 'self-end'
- | 'flex-start'
- | 'flex-end'
- | 'baseline'
- | 'first baseline'
- | 'last baseline'
- | 'stretch'
- | 'safe center'
- | 'unsafe center'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type FlexDirectionT =
- | 'row'
- | 'row-reverse'
- | 'column'
- | 'column-reverse'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type FlexT = number | string;
-
-type DisplayT =
- | 'block'
- | 'inline'
- | 'run-in'
- | 'flow'
- | 'flow-root'
- | 'table'
- | 'flex'
- | 'grid'
- | 'ruby'
- | 'block flow'
- | 'inline table'
- | 'flex run-in'
- | 'list-item'
- | 'list-item block'
- | 'list-item inline'
- | 'list-item flow'
- | 'list-item flow-root'
- | 'list-item block flow'
- | 'list-item block flow-root'
- | 'flow list-item block'
- | 'table-row-group'
- | 'table-header-group'
- | 'table-footer-group'
- | 'table-row'
- | 'table-cell'
- | 'table-column-group'
- | 'table-column'
- | 'table-caption'
- | 'ruby-base'
- | 'ruby-text'
- | 'ruby-base-container'
- | 'ruby-text-container'
- | 'contents'
- | 'none'
- | 'inline-block'
- | 'inline-table'
- | 'inline-flex'
- | 'inline-grid'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type GridAutoFlowT =
- | 'row'
- | 'column'
- | 'dense'
- | 'row dense'
- | 'column dense'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type JustifyContentT =
- | 'center'
- | 'start'
- | 'end'
- | 'flex-start'
- | 'flex-end'
- | 'left'
- | 'right'
- | 'space-between'
- | 'space-around'
- | 'space-evenly'
- | 'stretch'
- | 'safe center'
- | 'unsafe center'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type JustifyItemsT =
- /* Basic keywords */
- | 'auto'
- | 'normal'
- | 'stretch'
- | 'center'
- | 'start'
- | 'end'
- | 'flex-start'
- | 'flex-end'
- | 'self-start'
- | 'self-end'
- | 'left'
- | 'right'
- | 'baseline'
- | 'first baseline'
- | 'last baseline'
- | 'safe center'
- | 'unsafe center'
- | 'legacy right'
- | 'legacy left'
- | 'legacy center'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type JustifySelfT =
- | 'auto'
- | 'normal'
- | 'stretch'
- | 'center'
- | 'start'
- | 'end'
- | 'flex-start'
- | 'flex-end'
- | 'self-start'
- | 'self-end'
- | 'left'
- | 'right'
- | 'baseline'
- | 'first baseline'
- | 'last baseline'
- | 'safe center'
- | 'unsafe center'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-type PositionT = 'static' | 'absolute' | 'relative' | 'fixed' | 'sticky';
-
-type OverflowT =
- | 'visible'
- | 'hidden'
- | 'scroll'
- | 'scrollX'
- | 'scrollY'
- | 'auto'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-export type ScaleT = 0 | string;
-
-export type WhiteSpaceT =
- | 'normal'
- | 'nowrap'
- | 'pre'
- | 'pre-wrap'
- | 'pre-line'
- | 'break-spaces'
- | 'inherit'
- | 'initial'
- | 'unset';
-
-export type BlockPropsT = {
- children?: Node,
- /** Modifies the base element used to render the block. */
- as?: ElementType,
- overrides?: OverridesT,
- /** Accepts all themeable color properties (`primary200`, etc.). */
- color?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment */
- backgroundAttachment?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip */
- backgroundClip?: ResponsiveT,
- /** Accepts all themeable color properties (`primary200`, etc.). */
- backgroundColor?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-image */
- backgroundImage?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-origin */
- backgroundOrigin?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-position */
- backgroundPosition?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat */
- backgroundRepeat?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/background-size */
- backgroundSize?: ResponsiveT,
- /** Accepts all themeable font properties (`font200`, etc.). */
- font?: string | Array,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/align-content */
- alignContent?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/align-items */
- alignItems?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/align-self */
- alignSelf?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction */
- flexDirection?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/display */
- display?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/flex */
- flex?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid */
- grid?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area */
- gridArea?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns */
- gridAutoColumns?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow */
- gridAutoFlow?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows */
- gridAutoRows?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column */
- gridColumn?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end */
- gridColumnEnd?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-gap */
- gridColumnGap?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-start */
- gridColumnStart?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-gap */
- gridGap?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row */
- gridRow?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end */
- gridRowEnd?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-gap */
- gridRowGap?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-start */
- gridRowStart?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template */
- gridTemplate?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas */
- gridTemplateAreas?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns */
- gridTemplateColumns?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows */
- gridTemplateRows?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content */
- justifyContent?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items */
- justifyItems?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self */
- justifySelf?: ResponsiveT,
- position?: ResponsiveT,
- width?: ResponsiveT,
- minWidth?: ResponsiveT,
- maxWidth?: ResponsiveT,
- height?: ResponsiveT,
- minHeight?: ResponsiveT,
- maxHeight?: ResponsiveT,
- overflow?: ResponsiveT,
- margin?: ResponsiveT,
- marginTop?: ResponsiveT,
- marginRight?: ResponsiveT,
- marginBottom?: ResponsiveT,
- marginLeft?: ResponsiveT,
- padding?: ResponsiveT,
- paddingTop?: ResponsiveT,
- paddingRight?: ResponsiveT,
- paddingBottom?: ResponsiveT,
- paddingLeft?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/place-content */
- placeContent?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/place-items */
- placeItems?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/place-self */
- placeSelf?: ResponsiveT,
- flexWrap?: ResponsiveT,
- left?: ResponsiveT,
- top?: ResponsiveT,
- right?: ResponsiveT,
- bottom?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow */
- textOverflow?: ResponsiveT,
- /** available values: https://developer.mozilla.org/en-US/docs/Web/CSS/white-space */
- whiteSpace?: ResponsiveT,
- src?: string,
-};
-
-export type StyledBlockPropsT = {
- $as?: ElementType,
- $color?: ResponsiveT,
- $backgroundAttachment?: ResponsiveT,
- $backgroundClip?: ResponsiveT,
- $backgroundColor?: ResponsiveT,
- $backgroundImage?: ResponsiveT,
- $backgroundOrigin?: ResponsiveT,
- $backgroundPosition?: ResponsiveT,
- $backgroundRepeat?: ResponsiveT,
- $backgroundSize?: ResponsiveT,
- $font?: ResponsiveT,
- $alignContent?: ResponsiveT,
- $alignItems?: ResponsiveT,
- $alignSelf?: ResponsiveT,
- $flexDirection?: ResponsiveT,
- $display?: ResponsiveT,
- $flex?: ResponsiveT,
- $grid?: ResponsiveT,
- $gridArea?: ResponsiveT,
- $gridAutoColumns?: ResponsiveT,
- $gridAutoFlow?: ResponsiveT,
- $gridAutoRows?: ResponsiveT,
- $gridColumn?: ResponsiveT,
- $gridColumnEnd?: ResponsiveT,
- $gridColumnGap?: ResponsiveT,
- $gridColumnStart?: ResponsiveT,
- $gridGap?: ResponsiveT,
- $gridRow?: ResponsiveT,
- $gridRowEnd?: ResponsiveT,
- $gridRowGap?: ResponsiveT,
- $gridRowStart?: ResponsiveT,
- $gridTemplate?: ResponsiveT,
- $gridTemplateAreas?: ResponsiveT,
- $gridTemplateColumns?: ResponsiveT,
- $gridTemplateRows?: ResponsiveT,
- $justifyContent?: ResponsiveT,
- $justifyItems?: ResponsiveT,
- $justifySelf?: ResponsiveT,
- $position?: ResponsiveT,
- $width?: ResponsiveT,
- $minWidth?: ResponsiveT,
- $maxWidth?: ResponsiveT,
- $height?: ResponsiveT,
- $minHeight?: ResponsiveT,
- $maxHeight?: ResponsiveT,
- $overflow?: ResponsiveT,
- $margin?: ResponsiveT,
- $marginTop?: ResponsiveT,
- $marginRight?: ResponsiveT,
- $marginBottom?: ResponsiveT,
- $marginLeft?: ResponsiveT,
- $padding?: ResponsiveT,
- $paddingTop?: ResponsiveT,
- $paddingRight?: ResponsiveT,
- $paddingBottom?: ResponsiveT,
- $paddingLeft?: ResponsiveT,
- $placeContent?: ResponsiveT,
- $placeItems?: ResponsiveT,
- $placeSelf?: ResponsiveT,
- $flexWrap?: ResponsiveT,
- $left?: ResponsiveT,
- $top?: ResponsiveT,
- $right?: ResponsiveT,
- $bottom?: ResponsiveT,
- $textOverflow?: ResponsiveT,
- $whiteSpace?: ResponsiveT,
-};
diff --git a/src/bottom-navigation/index.js.flow b/src/bottom-navigation/index.js.flow
deleted file mode 100644
index 7efdf2883e..0000000000
--- a/src/bottom-navigation/index.js.flow
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-import { type StyletronComponent } from 'styletron-react';
-
-export type NavItemOverridesT = {
- Title?: OverrideT,
- Selector?: OverrideT,
- Panel?: OverrideT,
-};
-
-export type BottomNavigationOverridesT = {
- Root?: OverrideT,
- SelectorList?: OverrideT,
- OverflowPanel?: OverrideT,
- OverflowPanelList?: OverrideT,
- OverflowTitle?: OverrideT,
- OverflowSelector?: OverrideT,
-};
-
-export type IconT = React.AbstractComponent<{| size: number |}>;
-
-export type NavItemPropsT = {
- children?: React.Node,
- title: string,
- icon?: IconT,
- overrides?: NavItemOverridesT,
-};
-
-export type OnChangeT = (params: { activeKey: number }) => void;
-
-export type BottomNavigationPropsT = {
- children?: React.Node,
- activeKey?: number,
- onChange?: OnChangeT,
- overrides?: BottomNavigationOverridesT,
-};
-
-export type SelectorPropsT = {
- title: string,
- icon: IconT,
- isActive: boolean,
- onChange: OnChangeT,
- overrides: NavItemOverridesT,
-};
-
-export type PanelPropsT = {
- isActive: boolean,
- overrides: NavItemOverridesT,
- children: React.Node,
-};
-
-declare export var StyledRoot: StyletronComponent<'div', {}>;
-declare export var StyledTitle: StyletronComponent<'div', { $isActive: boolean }>;
-declare export var StyledSelectorList: StyletronComponent<'div', {}>;
-declare export var StyledSelector: StyletronComponent<'button', {}>;
-declare export var StyledPanel: StyletronComponent<'div', {}>;
-declare export var StyledOverflowPanel: StyletronComponent<'div', {}>;
-declare export var StyledOverflowPanelList: StyletronComponent<'div', {}>;
-
-declare export var NavItem: React.ComponentType;
-declare export var BottomNavigation: React.ComponentType;
diff --git a/src/breadcrumbs/breadcrumbs.js.flow b/src/breadcrumbs/breadcrumbs.js.flow
deleted file mode 100644
index 998e1c5faa..0000000000
--- a/src/breadcrumbs/breadcrumbs.js.flow
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import React, { Children } from 'react';
-
-import { LocaleContext } from '../locale/index.js';
-import { ThemeContext } from '../styles/theme-provider.js';
-import ChevronRight from '../icon/chevron-right.js';
-import ChevronLeft from '../icon/chevron-left.js';
-import type { BreadcrumbsPropsT } from './types.js';
-import { StyledList, StyledListItem, StyledRoot, StyledSeparator } from './styled-components.js';
-import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
-
-export function Breadcrumbs(props: BreadcrumbsPropsT) {
- const { overrides = {}, showTrailingSeparator = false } = props;
- const childrenArray = Children.toArray(props.children);
- const childrenWithSeparators = [];
-
- const [Root, baseRootProps] = getOverrides(overrides.Root, StyledRoot);
- const [Right, baseIconProps] = getOverrides(overrides.Icon, ChevronRight);
- const [Left] = getOverrides(overrides.Icon, ChevronLeft);
- const [List, baseListProps] = getOverrides(overrides.List, StyledList);
- const [ListItem, baseListItemProps] = getOverrides(overrides.ListItem, StyledListItem);
- const [Separator, baseSeparatorProps] = getOverrides(overrides.Separator, StyledSeparator);
-
- baseIconProps.overrides = mergeOverrides(
- { Svg: { style: { verticalAlign: 'text-bottom' } } },
- baseIconProps && baseIconProps.overrides
- );
-
- childrenArray.forEach((child, index) => {
- childrenWithSeparators.push(
-
- {child}
- {(showTrailingSeparator || index !== childrenArray.length - 1) && (
-
-
- {(theme) =>
- theme.direction === 'rtl' ? (
-
- ) : (
-
- )
- }
-
-
- )}
-
- );
- });
-
- return (
-
- {(locale) => (
-
- {childrenWithSeparators}
-
- )}
-
- );
-}
-
-Breadcrumbs.defaultProps = {
- overrides: {},
- showTrailingSeparator: false,
-};
-
-export default Breadcrumbs;
diff --git a/src/breadcrumbs/index.js.flow b/src/breadcrumbs/index.js.flow
deleted file mode 100644
index e7e397312c..0000000000
--- a/src/breadcrumbs/index.js.flow
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-export { default as Breadcrumbs } from './breadcrumbs.js';
-export * from './styled-components.js';
-export type * from './types.js';
diff --git a/src/breadcrumbs/locale.js.flow b/src/breadcrumbs/locale.js.flow
deleted file mode 100644
index 4282470b03..0000000000
--- a/src/breadcrumbs/locale.js.flow
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export type BreadcrumbLocaleT = {|
- ariaLabel: string,
-|};
-
-const locale = {
- ariaLabel: 'Breadcrumbs navigation',
-};
-
-export default locale;
diff --git a/src/breadcrumbs/styled-components.js.flow b/src/breadcrumbs/styled-components.js.flow
deleted file mode 100644
index 46671681f5..0000000000
--- a/src/breadcrumbs/styled-components.js.flow
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import { styled } from '../styles/index.js';
-
-export const StyledRoot = styled<{}>('nav', ({ $theme }) => {
- return {
- color: $theme.colors.breadcrumbsText,
- ...$theme.typography.font350,
- };
-});
-
-export const StyledList = styled<{}>('ol', ({ $theme }) => {
- return {
- listStyleType: 'none',
- margin: 0,
- padding: 0,
- ...$theme.typography.font350,
- };
-});
-
-export const StyledListItem = styled<{}>('li', ({ $theme }) => {
- return {
- display: 'inline-block',
- ...$theme.typography.font350,
- };
-});
-
-export const StyledSeparator = styled<{}>('div', ({ $theme }) => {
- return {
- display: 'inline-block',
- color: $theme.colors.breadcrumbsSeparatorFill,
- marginLeft: $theme.sizing.scale300,
- marginRight: $theme.sizing.scale300,
- verticalAlign: 'middle',
- };
-});
diff --git a/src/breadcrumbs/types.js.flow b/src/breadcrumbs/types.js.flow
deleted file mode 100644
index aa1e1e0abb..0000000000
--- a/src/breadcrumbs/types.js.flow
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-
-import type { Node } from 'react';
-
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type OverridesT = {
- Root?: OverrideT,
- Separator?: OverrideT,
- List?: OverrideT,
- ListItem?: OverrideT,
- Icon?: OverrideT,
-};
-
-export type BreadcrumbsPropsT = {|
- children?: Node,
- overrides?: OverridesT,
- ariaLabel?: string,
- 'aria-label'?: string,
- /** Whether to show a trailing separator after the last breadcrumb. */
- showTrailingSeparator?: boolean,
-|};
diff --git a/src/button-dock/index.js.flow b/src/button-dock/index.js.flow
deleted file mode 100644
index c53ae3f776..0000000000
--- a/src/button-dock/index.js.flow
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-import { type StyletronComponent } from 'styletron-react';
-
-export type ButtonDockOverridesT = {
- Root?: OverrideT,
- ActionContainer?: OverrideT,
- ActionSubContainer?: OverrideT,
-};
-
-export type ButtonDockPropsT = {
- primaryAction: React.Node,
- secondaryActions?: [React.Node] | [React.Node, React.Node],
- dismissiveAction?: React.Node,
- topAccessory?: React.Node,
- overrides?: ButtonDockOverridesT,
-};
-
-declare export var StyledRoot: StyletronComponent<'div', {}>;
-declare export var StyledActionContainer: StyletronComponent<'div', {}>;
-declare export var StyledActionSubContainer: StyletronComponent<
- 'div',
- { $reverseWhenWide: boolean }
->;
-
-declare export var ButtonDock: React.ComponentType;
diff --git a/src/button-docked/index.js.flow b/src/button-docked/index.js.flow
deleted file mode 100644
index 89c5a2deb8..0000000000
--- a/src/button-docked/index.js.flow
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-import { type StyletronComponent } from 'styletron-react';
-
-export type ButtonDockedOverridesT = {
- Root?: OverrideT,
- ActionContainer?: OverrideT,
- ActionSubContainer?: OverrideT,
-};
-
-export type ButtonDockedPropsT = {
- primaryAction: React.Node,
- secondaryActions?: [React.Node] | [React.Node, React.Node],
- dismissiveAction?: React.Node,
- topAccessory?: React.Node,
- overrides?: ButtonDockedOverridesT,
-};
-
-declare export var StyledRoot: StyletronComponent<'div', {}>;
-declare export var StyledActionContainer: StyletronComponent<'div', {}>;
-declare export var StyledActionSubContainer: StyletronComponent<
- 'div',
- { $reverseWhenWide: boolean }
->;
-
-declare export var ButtonDocked: React.ComponentType;
diff --git a/src/button-group/button-group.js.flow b/src/button-group/button-group.js.flow
deleted file mode 100644
index 5a1f4ba6fa..0000000000
--- a/src/button-group/button-group.js.flow
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { KIND, SIZE, SHAPE } from '../button/index.js';
-import { MODE } from './constants.js';
-import { getOverrides } from '../helpers/overrides.js';
-import { LocaleContext } from '../locale/index.js';
-
-import { StyledRoot } from './styled-components.js';
-import type { PropsT } from './types.js';
-
-function isIndexSelected(selected, index) {
- if (!Array.isArray(selected) && typeof selected !== 'number') {
- return false;
- }
-
- if (Array.isArray(selected)) {
- return selected.includes(index);
- }
-
- return selected === index;
-}
-
-export default class ButtonGroup extends React.Component {
- childRefs: // flowlint-next-line unclear-type:off
- { [key: number]: React.ElementRef } = {};
- static defaultProps = {
- disabled: false,
- onClick: () => {},
- shape: SHAPE.default,
- size: SIZE.default,
- kind: KIND.secondary,
- };
- render() {
- const {
- overrides = {},
- mode = MODE.checkbox,
- children,
- selected,
- disabled,
- onClick,
- kind,
- shape,
- size,
- } = this.props;
- const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
- const ariaLabel = this.props['aria-label'] || this.props.ariaLabel;
- const isRadio = mode === MODE.radio;
-
- const numItems = React.Children.count(children);
-
- return (
-
- {(locale) => (
-
- {React.Children.map(children, (child, index) => {
- if (!React.isValidElement(child)) {
- return null;
- }
-
- const isSelected = child.props.isSelected
- ? child.props.isSelected
- : isIndexSelected(selected, index);
-
- if (isRadio) {
- this.childRefs[index] = React.createRef();
- }
- return React.cloneElement(child, {
- disabled: disabled || child.props.disabled,
- isSelected,
- ref: isRadio ? this.childRefs[index] : undefined,
- tabIndex:
- !isRadio ||
- isSelected ||
- (isRadio && (!selected || selected === -1) && index === 0)
- ? 0
- : -1,
- onKeyDown: (e) => {
- if (!isRadio) return;
- const value = Number(selected) ? Number(selected) : 0;
- if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
- e.preventDefault && e.preventDefault();
- const prevIndex = value - 1 < 0 ? numItems - 1 : value - 1;
- onClick && onClick(e, prevIndex);
- this.childRefs[prevIndex].current && this.childRefs[prevIndex].current.focus();
- }
- if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
- e.preventDefault && e.preventDefault();
- const nextIndex = value + 1 > numItems - 1 ? 0 : value + 1;
- onClick && onClick(e, nextIndex);
- this.childRefs[nextIndex].current && this.childRefs[nextIndex].current.focus();
- }
- },
- kind,
- onClick: (event) => {
- if (disabled) {
- return;
- }
-
- if (child.props.onClick) {
- child.props.onClick(event);
- }
-
- if (onClick) {
- onClick(event, index);
- }
- },
- shape,
- size,
- overrides: {
- BaseButton: {
- style: ({ $theme }) => {
- // Even though baseui's buttons have square corners, some applications override to
- // rounded. Maintaining corner radius in this circumstance is ideal to avoid further
- // customization.
- if (children.length === 1) {
- return {};
- }
-
- if (shape !== SHAPE.default) {
- return {
- marginLeft: $theme.sizing.scale100,
- marginRight: $theme.sizing.scale100,
- };
- }
-
- return {
- marginLeft: '0.5px',
- marginRight: '0.5px',
- };
- },
- props: {
- 'aria-checked': isSelected,
- role: isRadio ? 'radio' : 'checkbox',
- },
- },
-
- ...child.props.overrides,
- },
- });
- })}
-
- )}
-
- );
- }
-}
diff --git a/src/button-group/constants.js.flow b/src/button-group/constants.js.flow
deleted file mode 100644
index 25b2e557d7..0000000000
--- a/src/button-group/constants.js.flow
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export const MODE = Object.freeze({
- radio: 'radio',
- checkbox: 'checkbox',
-});
-
-export const STATE_CHANGE_TYPE = Object.freeze({
- change: 'change',
-});
diff --git a/src/button-group/index.js.flow b/src/button-group/index.js.flow
deleted file mode 100644
index 2599349c8e..0000000000
--- a/src/button-group/index.js.flow
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { default as ButtonGroup } from './button-group.js';
-export { default as StatefulButtonGroup } from './stateful-button-group.js';
-export { default as StatefulContainer } from './stateful-container.js';
-
-// Constants
-export { SIZE, SHAPE } from '../button/constants.js';
-export { MODE, STATE_CHANGE_TYPE } from './constants.js';
-
-// Styled elements
-export { StyledRoot } from './styled-components.js';
-
-// Types
-export type * from './types.js';
diff --git a/src/button-group/locale.js.flow b/src/button-group/locale.js.flow
deleted file mode 100644
index 00e3f3a5f3..0000000000
--- a/src/button-group/locale.js.flow
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export type ButtonGroupLocaleT = {|
- ariaLabel: string,
-|};
-
-const locale = {
- ariaLabel: 'button group',
-};
-
-export default locale;
diff --git a/src/button-group/stateful-button-group.js.flow b/src/button-group/stateful-button-group.js.flow
deleted file mode 100644
index bbbb309e58..0000000000
--- a/src/button-group/stateful-button-group.js.flow
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import ButtonGroup from './button-group.js';
-import StatefulContainer from './stateful-container.js';
-import type { StatefulPropsT } from './types.js';
-
-export default function StatefulButtonGroup(props: StatefulPropsT) {
- const { children, initialState, ...restProps } = props;
- return (
-
- {({ ...containerProps }) => (
- //$FlowFixMe
- {props.children}
- )}
-
- );
-}
diff --git a/src/button-group/stateful-container.js.flow b/src/button-group/stateful-container.js.flow
deleted file mode 100644
index a43dc17f57..0000000000
--- a/src/button-group/stateful-container.js.flow
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { MODE, STATE_CHANGE_TYPE } from './constants.js';
-
-import type { StatefulContainerPropsT, StateT } from './types.js';
-
-// handles the case where selected = 0
-function isSelectedDefined(selected) {
- return Array.isArray(selected) || typeof selected === 'number';
-}
-
-function defaultStateReducer(
- type: $Values,
- nextState: StateT,
- currentState: StateT
-) {
- return nextState;
-}
-
-export default class StatefulContainer extends React.Component {
- static defaultProps = {
- initialState: { selected: [] },
- stateReducer: defaultStateReducer,
- };
-
- constructor(props: StatefulContainerPropsT) {
- super(props);
-
- const { initialState = {} } = props;
- const { selected = [] } = initialState;
-
- this.state = {
- selected: isSelectedDefined(selected) ? [].concat(selected) : [],
- };
- }
-
- changeState = (nextState: StateT) => {
- if (this.props.stateReducer) {
- this.setState(this.props.stateReducer(STATE_CHANGE_TYPE.change, nextState, this.state));
- } else {
- this.setState(nextState);
- }
- };
-
- onClick = (event: SyntheticEvent, index: number) => {
- if (this.props.mode === MODE.radio) {
- if (this.state.selected.length === 0 || this.state.selected[0] !== index) {
- this.changeState({ selected: [index] });
- } else {
- this.changeState({ selected: [] });
- }
- }
-
- if (this.props.mode === MODE.checkbox) {
- if (!this.state.selected.includes(index)) {
- this.changeState({ selected: [...this.state.selected, index] });
- } else {
- this.changeState({
- selected: this.state.selected.filter((value) => value !== index),
- });
- }
- }
-
- if (this.props.onClick) {
- this.props.onClick(event, index);
- }
- };
-
- render() {
- const { initialState, stateReducer, ...props } = this.props;
- return this.props.children({
- ...props,
- onClick: this.onClick,
- selected: this.state.selected,
- });
- }
-}
diff --git a/src/button-group/styled-components.js.flow b/src/button-group/styled-components.js.flow
deleted file mode 100644
index 8ab93ac8ae..0000000000
--- a/src/button-group/styled-components.js.flow
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import { styled } from '../styles/index.js';
-import { SHAPE } from '../button/index.js';
-
-export const StyledRoot = styled<{ $shape: string, $length: number }>(
- 'div',
- ({ $shape, $length, $theme }) => {
- const margin =
- $length === 1
- ? undefined
- : $shape !== SHAPE.default
- ? `-${$theme.sizing.scale100}`
- : '-0.5px';
- return {
- display: 'flex',
- marginLeft: margin,
- marginRight: margin,
- };
- }
-);
diff --git a/src/button-group/types.js.flow b/src/button-group/types.js.flow
deleted file mode 100644
index 5d090a02b4..0000000000
--- a/src/button-group/types.js.flow
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import * as React from 'react';
-
-import { SIZE, SHAPE, KIND } from '../button/index.js';
-import type { OverrideT } from '../helpers/overrides.js';
-import { MODE, STATE_CHANGE_TYPE } from './constants.js';
-
-// button-group
-export type PropsT = {|
- /** Accessible label. */
- ariaLabel?: string,
- 'aria-label'?: string,
- /** Set of more than one `Button` components */
- children: Array,
- /** Defines if the button group is disabled. */
- disabled?: boolean,
- /**
- * Use the `mode` prop to render toggleable Buttons:
- * the value `radio` will cause Buttons to behave like radio buttons,
- * the value `checkbox` will cause Buttons to behave like checkboxes.
- */
- mode?: $Values,
- /**
- * Called with click events from children. If a child button has its
- * own click handler, the local handler will be called first, then
- * this handler will trigger.
- */
- onClick?: ClickHandlerT,
- overrides?: OverridesT,
- /**
- * Index or array of indices of the selected Button(s).
- * Primarily for use with controlled components with a `mode` prop defined.
- */
- selected?: number | Array,
- /** Defines the shape of the buttons in the button group. */
- shape?: $Values,
- /** Defines the size of the buttons in the button group. */
- size?: $Values,
- /** Defines the `kind` of the buttons in the group */
- kind?: $Values,
-|};
-
-type OverridesT = {
- Root?: OverrideT,
-};
-
-// stateful-group
-// eslint-disable-next-line flowtype/generic-spacing
-export type StatefulPropsT = $Diff<
- {|
- ...PropsT,
- initialState?: { selected: number | Array },
- stateReducer?: StateReducerT,
- |},
- { selected: mixed } // excluded from type definition
->;
-
-// stateful-container
-export type StatefulContainerPropsT = {|
- ...StatefulPropsT,
- children: (props: {
- ...$Diff,
- onClick: ClickHandlerT,
- selected: number | Array,
- }) => React.Node,
-|};
-
-export type StateT = {
- selected: Array,
-};
-
-export type StateReducerT = (
- stateType: $Values,
- nextState: StateT,
- currentState: StateT
-) => StateT;
-
-// general
-type ClickHandlerT = (event: SyntheticEvent, index: number) => mixed;
diff --git a/src/button-timed/index.js.flow b/src/button-timed/index.js.flow
deleted file mode 100644
index 5433f84b0b..0000000000
--- a/src/button-timed/index.js.flow
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-import { type StyletronComponent } from 'styletron-react';
-import type { CustomColorsT } from '../button';
-
-export type OverridesT = {
- BaseButtonTimed?: OverrideT,
- TimerContainer?: OverrideT,
- Root?: OverrideT,
- StartEnhancer?: OverrideT,
- EndEnhancer?: OverrideT,
- LoadingSpinnerContainer?: OverrideT,
- LoadingSpinner?: OverrideT,
-};
-
-export type ButtonTimedPropsT = {
- initialTime: number,
- onClick: (a?: SyntheticEvent) => mixed,
- overrides?: OverridesT,
- paused?: boolean,
- children?: React$Node,
- colors?: CustomColorsT,
- disabled?: boolean,
- /** A helper rendered at the end of the button. */
- // flowlint-next-line unclear-type:off
- endEnhancer?: React.Node | React.AbstractComponent,
- /** Show loading button style and spinner. */
- isLoading?: boolean,
- /** Indicates that the button is selected */
- isSelected?: boolean,
- /** A helper rendered at the start of the button. */
- // flowlint-next-line unclear-type:off
- startEnhancer?: React.Node | React.AbstractComponent,
- type?: 'submit' | 'reset' | 'button',
-};
-
-export {
- StyledStartEnhancer,
- StyledEndEnhancer,
- StyledLoadingSpinner,
- StyledLoadingSpinnerContainer,
-} from '../button';
-declare export var StyledBaseButtonTimed: StyletronComponent<'div', {}>;
-declare export var StyledTimerContainer: StyletronComponent<'div', {}>;
-
-declare export var ButtonTimed: React.ComponentType;
diff --git a/src/button/button-internals.js.flow b/src/button/button-internals.js.flow
deleted file mode 100644
index 66ed0129f2..0000000000
--- a/src/button/button-internals.js.flow
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import * as ReactIs from 'react-is';
-import {
- StartEnhancer as StyledStartEnhancer,
- EndEnhancer as StyledEndEnhancer,
-} from './styled-components.js';
-import { getSharedProps } from './utils.js';
-import { getOverrides } from '../helpers/overrides.js';
-
-import type { ButtonPropsT } from './types.js';
-
-function RenderEnhancer(props) {
- const { Enhancer, ...restProps } = props;
- if (typeof Enhancer === 'string') {
- return Enhancer;
- }
- if (ReactIs.isValidElementType(Enhancer)) {
- // $FlowFixMe
- return ;
- }
- // $FlowFixMe
- return Enhancer;
-}
-
-export default function ButtonInternals(props: ButtonPropsT) {
- const { children, overrides = {}, startEnhancer, endEnhancer } = props;
- const [StartEnhancer, startEnhancerProps] = getOverrides(
- overrides.StartEnhancer,
- StyledStartEnhancer
- );
- const [EndEnhancer, endEnhancerProps] = getOverrides(overrides.EndEnhancer, StyledEndEnhancer);
- const sharedProps = getSharedProps(props);
- return (
-
- {startEnhancer !== null && startEnhancer !== undefined && (
-
-
-
- )}
- {children}
- {endEnhancer !== null && endEnhancer !== undefined && (
-
-
-
- )}
-
- );
-}
diff --git a/src/button/button.js.flow b/src/button/button.js.flow
deleted file mode 100644
index 05fd705bd1..0000000000
--- a/src/button/button.js.flow
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import {
- BaseButton as StyledBaseButton,
- LoadingSpinner as StyledLoadingSpinner,
- LoadingSpinnerContainer as StyledLoadingSpinnerContainer,
-} from './styled-components.js';
-import { getSharedProps } from './utils.js';
-import ButtonInternals from './button-internals.js';
-import { defaultProps } from './default-props.js';
-import { getOverrides } from '../helpers/overrides.js';
-import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
-
-import type { ButtonPropsT, SharedStylePropsT, ReactRefT } from './types.js';
-
-class Button extends React.Component<
- ButtonPropsT & { forwardedRef: ReactRefT },
- { isFocusVisible: boolean }
-> {
- static defaultProps = defaultProps;
- state = { isFocusVisible: false };
-
- internalOnClick = (...args) => {
- const { isLoading, onClick } = this.props;
- if (isLoading) {
- args[0].preventDefault();
- return;
- }
- onClick && onClick(...args);
- };
-
- handleFocus = (event: SyntheticEvent<>) => {
- if (isFocusVisible(event)) {
- this.setState({ isFocusVisible: true });
- }
- };
-
- handleBlur = (event: SyntheticEvent<>) => {
- if (this.state.isFocusVisible !== false) {
- this.setState({ isFocusVisible: false });
- }
- };
-
- render() {
- const {
- overrides = {},
- size,
- kind,
- shape,
- isLoading,
- isSelected,
- // Removing from restProps
- startEnhancer,
- endEnhancer,
- children,
- forwardedRef,
- colors,
- ...restProps
- } = this.props;
- // Get overrides
- const [BaseButton, baseButtonProps] = getOverrides(
- // adding both (1) BaseButton and (2) Root
- // (1) because it's a Button under the hood
- // (2) because we want consistency with the rest of the components
- overrides.BaseButton || overrides.Root,
- StyledBaseButton
- );
- const [LoadingSpinner, loadingSpinnerProps] = getOverrides(
- overrides.LoadingSpinner,
- StyledLoadingSpinner
- );
- const [LoadingSpinnerContainer, loadingSpinnerContainerProps] = getOverrides(
- overrides.LoadingSpinnerContainer,
- StyledLoadingSpinnerContainer
- );
- const sharedProps: SharedStylePropsT = {
- ...getSharedProps(this.props),
- $isFocusVisible: this.state.isFocusVisible,
- };
- return (
-
- {isLoading ? (
-
- {/* This is not meant to be overridable by users */}
-
-
-
-
-
-
-
- ) : (
-
- )}
-
- );
- }
-}
-
-const ForwardedButton = React.forwardRef(
- //$FlowFixMe
- (props: ButtonPropsT, ref) =>
-);
-ForwardedButton.displayName = 'Button';
-export default ForwardedButton;
diff --git a/src/button/constants.js.flow b/src/button/constants.js.flow
deleted file mode 100644
index d1c680f532..0000000000
--- a/src/button/constants.js.flow
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export const KIND = {
- primary: 'primary',
- secondary: 'secondary',
- tertiary: 'tertiary',
-};
-
-export const SHAPE = {
- default: 'default',
- pill: 'pill',
- round: 'round',
- circle: 'circle',
- square: 'square',
-};
-
-export const SIZE = {
- mini: 'mini',
- default: 'default',
- compact: 'compact',
- large: 'large',
-};
diff --git a/src/button/default-props.js.flow b/src/button/default-props.js.flow
deleted file mode 100644
index 8abbb132a8..0000000000
--- a/src/button/default-props.js.flow
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import { KIND, SHAPE, SIZE } from './constants.js';
-
-export const defaultProps = {
- disabled: false,
- isLoading: false,
- isSelected: false,
- kind: KIND.primary,
- overrides: {},
- shape: SHAPE.default,
- size: SIZE.default,
-};
diff --git a/src/button/index.js.flow b/src/button/index.js.flow
deleted file mode 100644
index a3562a42ab..0000000000
--- a/src/button/index.js.flow
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-export { default as Button } from './button.js';
-// Constants
-export { KIND, SIZE, SHAPE } from './constants.js';
-// Styled elements
-export {
- BaseButton as StyledBaseButton,
- StartEnhancer as StyledStartEnhancer,
- EndEnhancer as StyledEndEnhancer,
- LoadingSpinner as StyledLoadingSpinner,
- LoadingSpinnerContainer as StyledLoadingSpinnerContainer,
-} from './styled-components.js';
-// Types
-export type * from './types.js';
diff --git a/src/button/styled-components.js.flow b/src/button/styled-components.js.flow
deleted file mode 100644
index 67c307ff4f..0000000000
--- a/src/button/styled-components.js.flow
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import { styled } from '../styles/index.js';
-import { KIND, SIZE, SHAPE } from './constants.js';
-import type { SharedStylePropsT } from './types.js';
-import type { FontT } from '../themes/types.js';
-
-export const BaseButton = styled(
- 'button',
- ({
- $theme,
- $size,
- $colors,
- $kind,
- $shape,
- $isLoading,
- $isSelected,
- $disabled,
- $isFocusVisible,
- //$FlowFixMe
- }) => ({
- display: 'inline-flex',
- // need to maintain button width while showing loading spinner
- flexDirection: $isLoading ? 'column' : 'row',
- alignItems: 'center',
- justifyContent: 'center',
- borderLeftWidth: 0,
- borderTopWidth: 0,
- borderRightWidth: 0,
- borderBottomWidth: 0,
- borderLeftStyle: 'none',
- borderTopStyle: 'none',
- borderRightStyle: 'none',
- borderBottomStyle: 'none',
- outline: 'none',
- boxShadow: $isFocusVisible ? `inset 0 0 0 3px ${$theme.colors.borderAccent}` : 'none',
- textDecoration: 'none',
- WebkitAppearance: 'none',
- transitionProperty: 'background',
- transitionDuration: $theme.animation.timing200,
- transitionTimingFunction: $theme.animation.linearCurve,
- cursor: 'pointer',
- ':disabled': {
- cursor: 'not-allowed',
- ...getDisabledStyles({ $theme, $kind, $disabled, $isSelected }),
- },
- marginLeft: 0,
- marginTop: 0,
- marginRight: 0,
- marginBottom: 0,
- ...getFontStyles({ $theme, $size }),
- ...getBorderRadiiStyles({ $theme, $size, $shape }),
- ...getPaddingStyles({ $theme, $size, $shape }),
- ...getColorStyles({
- $theme,
- $colors,
- $kind,
- $isLoading,
- $isSelected,
- $disabled,
- }),
- ...getShapeStyles({ $shape, $size }),
- })
-);
-
-export const EndEnhancer = styled('div', ({ $theme }) => {
- const marginDirection: string = $theme.direction === 'rtl' ? 'marginRight' : 'marginLeft';
- return {
- display: 'flex',
- [marginDirection]: $theme.sizing.scale300,
- };
-});
-
-export const StartEnhancer = styled('div', ({ $theme }) => {
- const marginDirection: string = $theme.direction === 'rtl' ? 'marginLeft' : 'marginRight';
- return {
- display: 'flex',
- [marginDirection]: $theme.sizing.scale300,
- };
-});
-
-export const LoadingSpinnerContainer = styled('div', ({ $theme, $size }) => {
- // we don't have a theming value for this
- let margins = '3px';
- if ($size === SIZE.mini || $size === SIZE.compact) {
- margins = $theme.sizing.scale0;
- }
- if ($size === SIZE.large) {
- margins = $theme.sizing.scale100;
- }
-
- return {
- lineHeight: 0,
- position: 'static',
- marginBottom: margins,
- marginTop: margins,
- };
-});
-
-export const LoadingSpinner = styled(
- 'span',
- ({ $theme, $kind, $disabled, $size }) => {
- const { foreground, background } = getLoadingSpinnerColors({
- $theme,
- $kind,
- $disabled,
- });
-
- let dimension = $theme.sizing.scale550;
- if ($size === SIZE.mini || $size === SIZE.compact) {
- dimension = $theme.sizing.scale500;
- }
- if ($size === SIZE.large) {
- dimension = $theme.sizing.scale600;
- }
-
- return {
- height: dimension,
- width: dimension,
- borderTopLeftRadius: '50%',
- borderTopRightRadius: '50%',
- borderBottomRightRadius: '50%',
- borderBottomLeftRadius: '50%',
- borderLeftStyle: 'solid',
- borderTopStyle: 'solid',
- borderRightStyle: 'solid',
- borderBottomStyle: 'solid',
- borderLeftWidth: $theme.sizing.scale0,
- borderTopWidth: $theme.sizing.scale0,
- borderRightWidth: $theme.sizing.scale0,
- borderBottomWidth: $theme.sizing.scale0,
- borderTopColor: foreground,
- borderLeftColor: background,
- borderBottomColor: background,
- borderRightColor: background,
- boxSizing: 'border-box',
- display: 'inline-block',
- animationDuration: $theme.animation.timing700,
- animationTimingFunction: 'linear',
- animationIterationCount: 'infinite',
- animationName: {
- to: {
- transform: 'rotate(360deg)',
- },
- from: {
- transform: 'rotate(0deg)',
- },
- },
- };
- }
-);
-
-function getLoadingSpinnerColors({ $theme, $kind, $disabled }) {
- if ($disabled) {
- return {
- foreground: $theme.colors.buttonDisabledSpinnerForeground,
- background: $theme.colors.buttonDisabledSpinnerBackground,
- };
- }
- switch ($kind) {
- case KIND.secondary: {
- return {
- foreground: $theme.colors.buttonSecondarySpinnerForeground,
- background: $theme.colors.buttonSecondarySpinnerBackground,
- };
- }
- case KIND.tertiary: {
- return {
- foreground: $theme.colors.buttonTertiarySpinnerForeground,
- background: $theme.colors.buttonTertiarySpinnerBackground,
- };
- }
- case KIND.primary:
- default: {
- return {
- foreground: $theme.colors.buttonPrimarySpinnerForeground,
- background: $theme.colors.buttonPrimarySpinnerBackground,
- };
- }
- }
-}
-
-function getBorderRadiiStyles({ $theme, $size, $shape }) {
- let value = $theme.borders.buttonBorderRadius;
-
- if ($shape === SHAPE.pill) {
- if ($size === SIZE.compact) {
- value = '30px';
- } else if ($size === SIZE.large) {
- value = '42px';
- } else {
- value = '38px';
- }
- } else if ($shape === SHAPE.circle || $shape === SHAPE.round) {
- value = '50%';
- } else if ($size === SIZE.mini) {
- value = $theme.borders.buttonBorderRadiusMini;
- }
-
- return {
- borderTopRightRadius: value,
- borderBottomRightRadius: value,
- borderTopLeftRadius: value,
- borderBottomLeftRadius: value,
- };
-}
-
-function getFontStyles({ $theme, $size }): FontT {
- switch ($size) {
- case SIZE.mini:
- return $theme.typography.font150;
- case SIZE.compact:
- return $theme.typography.font250;
- case SIZE.large:
- return $theme.typography.font450;
- default:
- return $theme.typography.font350;
- }
-}
-
-function getDisabledStyles({ $theme, $kind, $isSelected, $disabled }) {
- if ($disabled && $isSelected) {
- if ($kind === KIND.primary || $kind === KIND.secondary) {
- return {
- color: $theme.colors.buttonDisabledActiveText,
- backgroundColor: $theme.colors.buttonDisabledActiveFill,
- };
- } else if ($kind === KIND.tertiary) {
- return {
- backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
- color: $theme.colors.buttonTertiaryDisabledActiveText,
- };
- }
- }
-
- return {
- backgroundColor: $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
- color: $theme.colors.buttonDisabledText,
- };
-}
-
-function getPaddingStyles({ $theme, $size, $shape }) {
- const iconShape = $shape === SHAPE.square || $shape === SHAPE.circle || $shape === SHAPE.round;
- switch ($size) {
- case SIZE.mini:
- return {
- paddingTop: $theme.sizing.scale200,
- paddingBottom: $theme.sizing.scale200,
- paddingLeft: iconShape ? $theme.sizing.scale200 : $theme.sizing.scale300,
- paddingRight: iconShape ? $theme.sizing.scale200 : $theme.sizing.scale300,
- };
- case SIZE.compact:
- return {
- paddingTop: $theme.sizing.scale400,
- paddingBottom: $theme.sizing.scale400,
- paddingLeft: iconShape ? $theme.sizing.scale400 : $theme.sizing.scale500,
- paddingRight: iconShape ? $theme.sizing.scale400 : $theme.sizing.scale500,
- };
- case SIZE.large:
- return {
- paddingTop: $theme.sizing.scale600,
- paddingBottom: $theme.sizing.scale600,
- paddingLeft: iconShape ? $theme.sizing.scale600 : $theme.sizing.scale700,
- paddingRight: iconShape ? $theme.sizing.scale600 : $theme.sizing.scale700,
- };
- default:
- return {
- paddingTop: $theme.sizing.scale550,
- paddingBottom: $theme.sizing.scale550,
- paddingLeft: iconShape ? $theme.sizing.scale550 : $theme.sizing.scale600,
- paddingRight: iconShape ? $theme.sizing.scale550 : $theme.sizing.scale600,
- };
- }
-}
-
-type ColorStylesT = {|
- color?: string,
- backgroundColor?: string,
- ':hover'?: {
- boxShadow?: string,
- backgroundColor?: string,
- },
- ':focus'?: {
- boxShadow?: string,
- backgroundColor?: string,
- },
- ':active'?: {
- boxShadow?: string,
- backgroundColor?: string,
- },
-|};
-function getColorStyles({
- $theme,
- $colors,
- $isLoading,
- $isSelected,
- $kind,
- $disabled,
-}): ColorStylesT {
- if ($colors) {
- return {
- color: $colors.color,
- backgroundColor: $colors.backgroundColor,
- ':hover': {
- boxShadow: 'inset 999px 999px 0px rgba(0, 0, 0, 0.04)',
- },
- ':active': {
- boxShadow: 'inset 999px 999px 0px rgba(0, 0, 0, 0.08)',
- },
- };
- }
-
- if ($disabled) {
- return Object.freeze({});
- }
- switch ($kind) {
- case KIND.primary:
- if ($isSelected) {
- return {
- color: $theme.colors.buttonPrimarySelectedText,
- backgroundColor: $theme.colors.buttonPrimarySelectedFill,
- };
- }
- return {
- color: $theme.colors.buttonPrimaryText,
- backgroundColor: $theme.colors.buttonPrimaryFill,
- ':hover': {
- backgroundColor: $isLoading
- ? $theme.colors.buttonPrimaryActive
- : $theme.colors.buttonPrimaryHover,
- },
- ':active': {
- backgroundColor: $theme.colors.buttonPrimaryActive,
- },
- };
- case KIND.secondary:
- if ($isSelected) {
- return {
- color: $theme.colors.buttonPrimaryText,
- backgroundColor: $theme.colors.buttonPrimaryFill,
- };
- }
- return {
- color: $theme.colors.buttonSecondaryText,
- backgroundColor: $theme.colors.buttonSecondaryFill,
- ':hover': {
- backgroundColor: $isLoading
- ? $theme.colors.buttonSecondaryActive
- : $theme.colors.buttonSecondaryHover,
- },
- ':active': {
- backgroundColor: $theme.colors.buttonSecondaryActive,
- },
- };
- case KIND.tertiary:
- if ($isSelected) {
- return {
- color: $theme.colors.buttonTertiarySelectedText,
- backgroundColor: $theme.colors.buttonTertiarySelectedFill,
- };
- }
- return {
- color: $theme.colors.buttonTertiaryText,
- backgroundColor: $theme.colors.buttonTertiaryFill,
- ':hover': {
- backgroundColor: $isLoading
- ? $theme.colors.buttonTertiaryActive
- : $theme.colors.buttonTertiaryHover,
- },
- ':active': {
- backgroundColor: $theme.colors.buttonTertiaryActive,
- },
- };
- default:
- return Object.freeze({});
- }
-}
-
-function getShapeStyles({ $shape, $size }): {
- height?: string,
- width?: string,
- paddingTop?: number,
- paddingBottom?: number,
- paddingLeft?: number,
- paddingRight?: number,
-} {
- if ($shape === SHAPE.circle || $shape === SHAPE.square) {
- let height, width;
- switch ($size) {
- case SIZE.mini:
- height = '28px';
- width = '28px';
- break;
- case SIZE.compact:
- height = '36px';
- width = '36px';
- break;
- case SIZE.large:
- height = '56px';
- width = '56px';
- break;
- case SIZE.default:
- default:
- height = '48px';
- width = '48px';
- break;
- }
- return {
- height,
- width,
- paddingTop: 0,
- paddingBottom: 0,
- paddingLeft: 0,
- paddingRight: 0,
- };
- } else {
- return {};
- }
-}
diff --git a/src/button/types.js.flow b/src/button/types.js.flow
deleted file mode 100644
index c1e0dfe2dd..0000000000
--- a/src/button/types.js.flow
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-
-import { KIND, SIZE, SHAPE } from './constants.js';
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type ReactRefT = { current: null | T } | {| current: null | T |};
-
-export type OverridesT = {
- Root?: OverrideT,
- BaseButton?: OverrideT,
- StartEnhancer?: OverrideT,
- EndEnhancer?: OverrideT,
- LoadingSpinnerContainer?: OverrideT,
- LoadingSpinner?: OverrideT,
-};
-
-export type CustomColorsT = {|
- backgroundColor: string,
- color: string,
-|};
-
-export type ButtonPropsT = {
- children?: React$Node,
- colors?: CustomColorsT,
- disabled?: boolean,
- /** A helper rendered at the end of the button. */
- // flowlint-next-line unclear-type:off
- endEnhancer?: React.Node | React.AbstractComponent,
- /** Show loading button style and spinner. */
- isLoading?: boolean,
- /** Indicates that the button is selected */
- isSelected?: boolean,
- /** Defines the kind (purpose) of a button */
- kind?: $Keys,
- onClick?: (SyntheticEvent) => mixed,
- overrides?: OverridesT,
- /** Defines the shape of the button */
- shape?: $Keys,
- /** Defines the size of the button */
- size?: $Keys,
- /** A helper rendered at the start of the button. */
- // flowlint-next-line unclear-type:off
- startEnhancer?: React.Node | React.AbstractComponent,
- type?: 'submit' | 'reset' | 'button',
-};
-
-export type SharedStylePropsT = {
- $colors?: CustomColorsT,
- $kind?: $Keys,
- $isSelected?: boolean,
- $shape?: $Keys,
- $size?: $Keys,
- $isLoading?: boolean,
- $disabled?: boolean,
- $isFocusVisible: boolean,
-};
diff --git a/src/button/utils.js.flow b/src/button/utils.js.flow
deleted file mode 100644
index 1bff2b0b49..0000000000
--- a/src/button/utils.js.flow
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import type { ButtonPropsT, SharedStylePropsT } from './types.js';
-
-export function getSharedProps({
- colors,
- disabled,
- isLoading,
- isSelected,
- kind,
- shape,
- size,
-}: ButtonPropsT): $Shape {
- return {
- $colors: colors,
- $disabled: disabled,
- $isLoading: isLoading,
- $isSelected: isSelected,
- $kind: kind,
- $shape: shape,
- $size: size,
- };
-}
diff --git a/src/card/card.js.flow b/src/card/card.js.flow
deleted file mode 100644
index 0a90519cd3..0000000000
--- a/src/card/card.js.flow
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-/* @flow */
-
-import * as React from 'react';
-import { getOverride, getOverrideProps } from '../helpers/overrides.js';
-import { LevelContext } from '../heading/index.js';
-import {
- Action as StyledAction,
- Body as StyledBody,
- Contents as StyledContents,
- HeaderImage as StyledHeaderImage,
- Root as StyledRoot,
- Thumbnail as StyledThumbnail,
- Title as StyledTitle,
-} from './styled-components.js';
-
-import type { CardsPropsT } from './types.js';
-
-export function hasThumbnail(props: { +thumbnail?: string }) {
- return !!props.thumbnail;
-}
-
-const SemanticTitle = ({ children, ...restProps }) => {
- const levels = ['', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
-
- return (
-
- {(level) => (
-
- {children}
-
- )}
-
- );
-};
-
-function Card(props: CardsPropsT) {
- const {
- action,
- children,
- hasThumbnail: hasThumbnailProp = hasThumbnail,
- headerImage,
- thumbnail: thumbnailSrc,
- title,
- overrides,
- ...restProps
- } = props;
-
- const {
- Action: ActionOverride,
- Body: BodyOverride,
- Contents: ContentsOverride,
- HeaderImage: HeaderImageOverride,
- Root: RootOverride,
- Thumbnail: ThumbnailOverride,
- Title: TitleOverride,
- } = overrides;
-
- const Action = getOverride(ActionOverride) || StyledAction;
- const Body = getOverride(BodyOverride) || StyledBody;
- const Contents = getOverride(ContentsOverride) || StyledContents;
- const HeaderImage = getOverride(HeaderImageOverride) || StyledHeaderImage;
- const Root = getOverride(RootOverride) || StyledRoot;
- const Thumbnail = getOverride(ThumbnailOverride) || StyledThumbnail;
- const Title = getOverride(TitleOverride) || SemanticTitle;
-
- const headerImageProps = typeof headerImage === 'string' ? { src: headerImage } : headerImage;
-
- const $hasThumbnail = hasThumbnail(props);
- return (
-
- {headerImage && (
-
- )}
-
- {thumbnailSrc && }
- {title && (
-
- {title}
-
- )}
- {children}
- {action && {action}}
-
-
- );
-}
-
-Card.defaultProps = {
- action: null,
- children: null,
- hasThumbnail,
- overrides: {},
-};
-
-export default Card;
diff --git a/src/card/index.js.flow b/src/card/index.js.flow
deleted file mode 100644
index 6f26c21cdb..0000000000
--- a/src/card/index.js.flow
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-/* @flow */
-
-export { default as Card, hasThumbnail } from './card.js';
-export {
- Action as StyledAction,
- Body as StyledBody,
- Contents as StyledContents,
- HeaderImage as StyledHeaderImage,
- Thumbnail as StyledThumbnail,
- Title as StyledTitle,
- Root as StyledRoot,
- Root as StyledWrapper,
-} from './styled-components.js';
-export type * from './types.js';
diff --git a/src/card/styled-components.js.flow b/src/card/styled-components.js.flow
deleted file mode 100644
index 0662043a9d..0000000000
--- a/src/card/styled-components.js.flow
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-/* @flow */
-
-import { styled, expandBorderStyles } from '../styles/index.js';
-
-export const Action = styled<{}>('div', ({ $theme }) => ({
- ...$theme.typography.LabelMedium,
-}));
-
-export const Body = styled<{}>('div', ({ $theme }) => ({
- marginBottom: $theme.sizing.scale600,
- color: $theme.colors.contentPrimary,
- ...$theme.typography.ParagraphMedium,
-}));
-
-export const Contents = styled<{}>('div', ({ $theme }) => ({
- marginLeft: $theme.sizing.scale600,
- marginTop: $theme.sizing.scale600,
- marginRight: $theme.sizing.scale600,
- marginBottom: $theme.sizing.scale600,
-}));
-
-export const HeaderImage = styled<{}>('img', ({ $theme }) => ({
- borderTopLeftRadius: $theme.borders.surfaceBorderRadius,
- borderTopRightRadius: $theme.borders.surfaceBorderRadius,
- objectFit: 'contain',
- maxWidth: '100%',
-}));
-
-// by using the section tag, we can keep the h1 for the title
-// https://html.spec.whatwg.org/multipage/sections.html#headings-and-sections
-export const Root = styled<{}>('section', ({ $theme }) => ({
- borderLeftWidth: '2px',
- borderTopWidth: '2px',
- borderRightWidth: '2px',
- borderBottomWidth: '2px',
- borderLeftStyle: 'solid',
- borderTopStyle: 'solid',
- borderRightStyle: 'solid',
- borderBottomStyle: 'solid',
- borderLeftColor: $theme.colors.borderOpaque,
- borderRightColor: $theme.colors.borderOpaque,
- borderTopColor: $theme.colors.borderOpaque,
- borderBottomColor: $theme.colors.borderOpaque,
- borderTopLeftRadius: $theme.borders.radius400,
- borderTopRightRadius: $theme.borders.radius400,
- borderBottomLeftRadius: $theme.borders.radius400,
- borderBottomRightRadius: $theme.borders.radius400,
- backgroundColor: $theme.colors.backgroundPrimary,
- overflow: 'hidden',
-}));
-
-export const Thumbnail = styled<{}>('img', ({ $theme }) => ({
- float: 'right',
- height: $theme.sizing.scale2400,
- width: $theme.sizing.scale2400,
- objectFit: 'cover',
- borderTopLeftRadius: $theme.borders.surfaceBorderRadius,
- borderTopRightRadius: $theme.borders.surfaceBorderRadius,
- borderBottomLeftRadius: $theme.borders.surfaceBorderRadius,
- borderBottomRightRadius: $theme.borders.surfaceBorderRadius,
- ...expandBorderStyles($theme.borders.border200),
- margin: `0 0 ${$theme.sizing.scale500} ${$theme.sizing.scale500}`,
-}));
-
-export const Title = styled<{}>('h1', ({ $theme }) => ({
- ...$theme.typography.HeadingSmall,
- color: $theme.colors.contentPrimary,
- marginLeft: 0,
- marginTop: 0,
- marginRight: 0,
- marginBottom: $theme.sizing.scale500,
- paddingLeft: 0,
- paddingTop: 0,
- paddingRight: 0,
- paddingBottom: 0,
-}));
diff --git a/src/card/types.js.flow b/src/card/types.js.flow
deleted file mode 100644
index 48f7b8356b..0000000000
--- a/src/card/types.js.flow
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import type { Node } from 'react';
-import type { OverrideT } from '../helpers/overrides.js';
-
-export type CardComponentsT = {
- Action?: OverrideT,
- Body?: OverrideT,
- Contents?: OverrideT,
- HeaderImage?: OverrideT,
- Root?: OverrideT,
- Thumbnail?: OverrideT,
- Title?: OverrideT,
-};
-
-export type ImagePropsT = {
- alt?: string,
- complete?: boolean,
- crossOrigin?: string,
- currentSrc?: string,
- height?: number,
- decode?: Promise,
- isMap?: boolean,
- naturalHeight?: number,
- naturalWidth?: number,
- sizes?: string,
- src?: string,
- srcset?: string,
- useMap?: string,
- width?: number,
-};
-
-export type CardsPropsT = {
- /** Contents to be rendered at the bottom of the Card. Used to organize UI which enables user action. */
- +action?: Node,
- /** Content to be rendered within the Card body. */
- +children?: Node,
- /** Function that takes Card props and returns a boolean that represents if a thumbnail will be rendered. */
- +hasThumbnail?: ({ +thumbnail?: string }) => boolean,
- /** Image to be positioned at the top of the Card. Can be a string representing the img src or an object with img attrs */
- +headerImage?: string | ImagePropsT,
- +overrides: CardComponentsT,
- /** Image src that by default is rendered to the side of children content. */
- +thumbnail?: string,
- /** Content to render above the body content. */
- +title?: Node,
-};
diff --git a/src/checkbox/checkbox.js.flow b/src/checkbox/checkbox.js.flow
deleted file mode 100644
index 03ce5d1a74..0000000000
--- a/src/checkbox/checkbox.js.flow
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import { getOverride, getOverrideProps } from '../helpers/overrides.js';
-import type { PropsT, DefaultPropsT, StatelessStateT } from './types.js';
-import {
- Checkmark as StyledCheckmark,
- Input as StyledInput,
- Label as StyledLabel,
- Root as StyledRoot,
- Toggle as StyledToggle,
- ToggleTrack as StyledToggleTrack,
-} from './styled-components.js';
-import { STYLE_TYPE } from './constants.js';
-import { isFocusVisible } from '../utils/focusVisible.js';
-
-const stopPropagation = (e) => e.stopPropagation();
-
-class StatelessCheckbox extends React.Component {
- static defaultProps: DefaultPropsT = {
- overrides: {},
- checked: false,
- containsInteractiveElement: false,
- disabled: false,
- autoFocus: false,
- isIndeterminate: false,
- inputRef: React.createRef(),
- error: false,
- checkmarkType: STYLE_TYPE.default,
- onChange: () => {},
- onMouseEnter: () => {},
- onMouseLeave: () => {},
- onMouseDown: () => {},
- onMouseUp: () => {},
- onFocus: () => {},
- onBlur: () => {},
- };
-
- state = {
- isFocused: this.props.autoFocus || false,
- isFocusVisible: false,
- isHovered: false,
- isActive: false,
- };
-
- componentDidMount() {
- const { autoFocus, inputRef } = this.props;
- if (autoFocus && inputRef.current) {
- inputRef.current.focus();
- }
- }
-
- onMouseEnter = (e: SyntheticInputEvent) => {
- this.setState({ isHovered: true });
- this.props.onMouseEnter(e);
- };
-
- onMouseLeave = (e: SyntheticInputEvent) => {
- this.setState({ isHovered: false, isActive: false });
- this.props.onMouseLeave(e);
- };
-
- onMouseDown = (e: SyntheticInputEvent) => {
- this.setState({ isActive: true });
- this.props.onMouseDown(e);
- };
-
- onMouseUp = (e: SyntheticInputEvent) => {
- this.setState({ isActive: false });
- this.props.onMouseUp(e);
- };
-
- onFocus = (e: SyntheticInputEvent) => {
- this.setState({ isFocused: true });
- this.props.onFocus(e);
- if (isFocusVisible(e)) {
- this.setState({ isFocusVisible: true });
- }
- };
-
- onBlur = (e: SyntheticInputEvent) => {
- this.setState({ isFocused: false });
- this.props.onBlur(e);
- if (this.state.isFocusVisible !== false) {
- this.setState({ isFocusVisible: false });
- }
- };
-
- render() {
- const {
- overrides = {},
- onChange,
- labelPlacement = this.props.checkmarkType === STYLE_TYPE.toggle ? 'left' : 'right',
- inputRef,
- isIndeterminate,
- error,
- disabled,
- value,
- name,
- checked,
- children,
- required,
- title,
- } = this.props;
-
- const {
- Root: RootOverride,
- Checkmark: CheckmarkOverride,
- Label: LabelOverride,
- Input: InputOverride,
- Toggle: ToggleOverride,
- ToggleTrack: ToggleTrackOverride,
- } = overrides;
-
- const Root = getOverride(RootOverride) || StyledRoot;
- const Checkmark = getOverride(CheckmarkOverride) || StyledCheckmark;
- const Label = getOverride(LabelOverride) || StyledLabel;
- const Input = getOverride(InputOverride) || StyledInput;
- const Toggle = getOverride(ToggleOverride) || StyledToggle;
- const ToggleTrack = getOverride(ToggleTrackOverride) || StyledToggleTrack;
-
- const inputEvents = {
- onChange,
- onFocus: this.onFocus,
- onBlur: this.onBlur,
- };
- const mouseEvents = {
- onMouseEnter: this.onMouseEnter,
- onMouseLeave: this.onMouseLeave,
- onMouseDown: this.onMouseDown,
- onMouseUp: this.onMouseUp,
- };
- const sharedProps = {
- $isFocused: this.state.isFocused,
- $isFocusVisible: this.state.isFocusVisible,
- $isHovered: this.state.isHovered,
- $isActive: this.state.isActive,
- $error: error,
- $checked: checked,
- $isIndeterminate: isIndeterminate,
- $required: required,
- $disabled: disabled,
- $value: value,
- };
-
- const labelComp = children && (
-
- );
-
- return (
-
- {(labelPlacement === 'top' || labelPlacement === 'left') && labelComp}
- {this.props.checkmarkType === STYLE_TYPE.toggle ? (
-
-
-
- ) : (
-
- )}
-
- {(labelPlacement === 'bottom' || labelPlacement === 'right') && labelComp}
-
- );
- }
-}
-
-export default StatelessCheckbox;
diff --git a/src/checkbox/constants.js.flow b/src/checkbox/constants.js.flow
deleted file mode 100644
index 708809949d..0000000000
--- a/src/checkbox/constants.js.flow
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-/* eslint-disable import/prefer-default-export */
-
-export const STATE_TYPE = {
- change: 'CHANGE',
-};
-
-export const STYLE_TYPE = Object.freeze({
- default: 'default',
- toggle: 'toggle',
- // maintaining key with aliased value to assist in transition to v11 but will be removed soon after release
- toggle_round: 'toggle',
-});
-
-export const LABEL_PLACEMENT = Object.freeze({
- top: 'top',
- right: 'right',
- bottom: 'bottom',
- left: 'left',
-});
-
-/* eslint-enable import/prefer-default-export */
diff --git a/src/checkbox/index.js.flow b/src/checkbox/index.js.flow
deleted file mode 100644
index 0361c9e795..0000000000
--- a/src/checkbox/index.js.flow
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-export { default as StatefulCheckbox } from './stateful-checkbox.js';
-export { default as StatefulContainer } from './stateful-checkbox-container.js';
-export { default as Checkbox } from './checkbox.js';
-// Styled elements
-export {
- Root as StyledRoot,
- Checkmark as StyledCheckmark,
- Label as StyledLabel,
- Input as StyledInput,
- Toggle as StyledToggle,
- ToggleTrack as StyledToggleTrack,
-} from './styled-components.js';
-
-export { STATE_TYPE, STYLE_TYPE, LABEL_PLACEMENT } from './constants.js';
-
-// Flow
-export type * from './types.js';
diff --git a/src/checkbox/stateful-checkbox-container.js.flow b/src/checkbox/stateful-checkbox-container.js.flow
deleted file mode 100644
index 8457ce3679..0000000000
--- a/src/checkbox/stateful-checkbox-container.js.flow
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-import { STATE_TYPE } from './constants.js';
-import type {
- StatefulContainerPropsT,
- StateReducerT,
- DefaultStatefulPropsT,
- StateT,
-} from './types.js';
-
-const defaultStateReducer: StateReducerT = (type, nextState) => nextState;
-
-class StatefulCheckboxContainer extends React.Component {
- static defaultProps: DefaultStatefulPropsT = {
- initialState: {
- checked: false,
- isIndeterminate: false,
- },
- stateReducer: defaultStateReducer,
- onChange: () => {},
- onMouseEnter: () => {},
- onMouseLeave: () => {},
- onFocus: () => {},
- onBlur: () => {},
- };
-
- constructor(props: StatefulContainerPropsT) {
- super(props);
- const { initialState } = this.props;
- this.state = {
- ...initialState,
- };
- }
-
- onChange = (e: SyntheticInputEvent) => {
- this.stateReducer(STATE_TYPE.change, e);
- const { onChange } = this.props;
- onChange && onChange(e);
- };
-
- onMouseEnter = (e: SyntheticInputEvent) => {
- const { onMouseEnter } = this.props;
- onMouseEnter && onMouseEnter(e);
- };
-
- onMouseLeave = (e: SyntheticInputEvent) => {
- const { onMouseLeave } = this.props;
- onMouseLeave && onMouseLeave(e);
- };
-
- onFocus = (e: SyntheticInputEvent) => {
- const { onFocus } = this.props;
- onFocus && onFocus(e);
- };
-
- onBlur = (e: SyntheticInputEvent) => {
- const { onBlur } = this.props;
- onBlur && onBlur(e);
- };
-
- stateReducer = (type: string, e: SyntheticInputEvent) => {
- let nextState = {};
- const { stateReducer } = this.props;
- switch (type) {
- case STATE_TYPE.change:
- nextState = { checked: e.target.checked };
- break;
- }
- const newState = stateReducer(type, nextState, this.state, e);
- this.setState(newState);
- };
-
- render() {
- const {
- children = (childProps: {}) => null,
- initialState,
- stateReducer,
- ...restProps
- } = this.props;
- const { onChange, onMouseEnter, onMouseLeave, onFocus, onBlur } = this;
- return children({
- ...restProps,
- checked: this.state.checked,
- isIndeterminate: this.state.isIndeterminate,
- onChange,
- onMouseEnter,
- onMouseLeave,
- onFocus,
- onBlur,
- });
- }
-}
-
-export default StatefulCheckboxContainer;
diff --git a/src/checkbox/stateful-checkbox.js.flow b/src/checkbox/stateful-checkbox.js.flow
deleted file mode 100644
index fe99b37abd..0000000000
--- a/src/checkbox/stateful-checkbox.js.flow
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-import * as React from 'react';
-// eslint-disable-next-line import/no-named-default
-import { default as StatefulContainer } from './stateful-checkbox-container.js';
-// eslint-disable-next-line import/no-named-default
-import { default as Checkbox } from './checkbox.js';
-import type { StatefulContainerChildPropsT, StatefulCheckboxPropsT } from './types.js';
-// Styled elements
-
-const StatefulCheckbox = function (props: StatefulCheckboxPropsT) {
- return (
-
- {(childrenProps: StatefulContainerChildPropsT) => (
- {props.children}
- )}
-
- );
-};
-StatefulCheckbox.displayName = 'StatefulCheckbox';
-export default StatefulCheckbox;
diff --git a/src/checkbox/styled-components.js.flow b/src/checkbox/styled-components.js.flow
deleted file mode 100644
index 17c4ee92e4..0000000000
--- a/src/checkbox/styled-components.js.flow
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-
-// @flow
-import { styled } from '../styles/index.js';
-
-import type { SharedStylePropsT } from './types.js';
-
-function getBorderColor(props) {
- const { $disabled, $checked, $error, $isIndeterminate, $theme, $isFocusVisible } = props;
- const { colors } = $theme;
- if ($disabled) {
- return colors.tickFillDisabled;
- } else if ($checked || $isIndeterminate) {
- return 'transparent';
- } else if ($error) {
- return colors.borderNegative;
- } else if ($isFocusVisible) {
- return colors.borderSelected;
- } else {
- return colors.tickBorder;
- }
-}
-
-function getLabelPadding(props) {
- const { $labelPlacement = '', $theme } = props;
- const { sizing } = $theme;
- const { scale300 } = sizing;
- let paddingDirection;
-
- switch ($labelPlacement) {
- case 'top':
- paddingDirection = 'Bottom';
- break;
- case 'bottom':
- paddingDirection = 'Top';
- break;
- case 'left':
- paddingDirection = 'Right';
- break;
- default:
- case 'right':
- paddingDirection = 'Left';
- break;
- }
-
- if ($theme.direction === 'rtl' && paddingDirection === 'Left') {
- paddingDirection = 'Right';
- } else if ($theme.direction === 'rtl' && paddingDirection === 'Right') {
- paddingDirection = 'Left';
- }
-
- return {
- [`padding${paddingDirection}`]: scale300,
- };
-}
-
-function getBackgroundColor(props) {
- const { $disabled, $checked, $isIndeterminate, $error, $isHovered, $isActive, $theme } = props;
- const { colors } = $theme;
- if ($disabled) {
- if ($checked || $isIndeterminate) {
- return colors.tickFillDisabled;
- } else {
- return colors.tickFill;
- }
- } else if ($error && ($isIndeterminate || $checked)) {
- if ($isActive) {
- return colors.tickFillErrorSelectedHoverActive;
- } else if ($isHovered) {
- return colors.tickFillErrorSelectedHover;
- } else {
- return colors.tickFillErrorSelected;
- }
- } else if ($error) {
- if ($isActive) {
- return colors.tickFillErrorHoverActive;
- } else if ($isHovered) {
- return colors.tickFillErrorHover;
- } else {
- return colors.tickFillError;
- }
- } else if ($isIndeterminate || $checked) {
- if ($isActive) {
- return colors.tickFillSelectedHoverActive;
- } else if ($isHovered) {
- return colors.tickFillSelectedHover;
- } else {
- return colors.tickFillSelected;
- }
- } else {
- if ($isActive) {
- return colors.tickFillActive;
- } else if ($isHovered) {
- return colors.tickFillHover;
- } else {
- return colors.tickFill;
- }
- }
-}
-
-function getLabelColor(props) {
- const { $disabled, $theme } = props;
- const { colors } = $theme;
- return $disabled ? colors.contentSecondary : colors.contentPrimary;
-}
-
-export const Root = styled('label', (props) => {
- const { $disabled, $labelPlacement } = props;
- return {
- flexDirection: $labelPlacement === 'top' || $labelPlacement === 'bottom' ? 'column' : 'row',
- display: 'flex',
- alignItems: $labelPlacement === 'top' || $labelPlacement === 'bottom' ? 'center' : 'flex-start',
- cursor: $disabled ? 'not-allowed' : 'pointer',
- userSelect: 'none',
- };
-});
-
-export const Checkmark = styled('span', (props) => {
- const { $checked, $disabled, $error, $isIndeterminate, $theme, $isFocusVisible } = props;
- const { sizing, animation } = $theme;
-
- const tickColor = $disabled
- ? $theme.colors.tickMarkFillDisabled
- : $error
- ? $theme.colors.tickMarkFillError
- : $theme.colors.tickMarkFill;
-
- const indeterminate = encodeURIComponent(`
-
- `);
-
- const check = encodeURIComponent(`
-
- `);
-
- const borderRadius = $theme.borders.checkboxBorderRadius;
- const borderColor = getBorderColor(props);
-
- return ({
- flex: '0 0 auto',
- transitionDuration: animation.timing200,
- transitionTimingFunction: animation.easeOutCurve,
- transitionProperty: 'background-image, border-color, background-color',
- width: sizing.scale700,
- height: sizing.scale700,
- left: '4px',
- top: '4px',
- boxSizing: 'border-box',
- borderLeftStyle: 'solid',
- borderRightStyle: 'solid',
- borderTopStyle: 'solid',
- borderBottomStyle: 'solid',
- borderLeftWidth: '3px',
- borderRightWidth: '3px',
- borderTopWidth: '3px',
- borderBottomWidth: '3px',
- borderLeftColor: borderColor,
- borderRightColor: borderColor,
- borderTopColor: borderColor,
- borderBottomColor: borderColor,
- borderTopLeftRadius: borderRadius,
- borderTopRightRadius: borderRadius,
- borderBottomRightRadius: borderRadius,
- borderBottomLeftRadius: borderRadius,
- outline: $isFocusVisible && $checked ? `3px solid ${$theme.colors.borderAccent}` : 'none',
- display: 'inline-block',
- verticalAlign: 'middle',
- backgroundImage: $isIndeterminate
- ? `url('data:image/svg+xml,${indeterminate}');`
- : $checked
- ? `url('data:image/svg+xml,${check}');`
- : null,
- backgroundColor: getBackgroundColor(props),
- backgroundRepeat: 'no-repeat',
- backgroundPosition: 'center',
- backgroundSize: 'contain',
- marginTop: $theme.sizing.scale0,
- marginBottom: $theme.sizing.scale0,
- marginLeft: $theme.sizing.scale0,
- marginRight: $theme.sizing.scale0,
- }: {});
-});
-
-export const Label = styled('div', (props) => {
- const { $theme } = props;
- const { typography } = $theme;
- return ({
- verticalAlign: 'middle',
- ...getLabelPadding(props),
- color: getLabelColor(props),
- ...typography.LabelMedium,
- lineHeight: '24px',
- }: {});
-});
-
-// tricky style for focus event cause display: none doesn't work
-export const Input = styled('input', {
- opacity: 0,
- width: 0,
- height: 0,
- overflow: 'hidden',
- margin: 0,
- padding: 0,
- position: 'absolute',
-});
-
-export const Toggle = styled('div', (props) => {
- let backgroundColor = props.$theme.colors.toggleFill;
- if (props.$disabled) {
- backgroundColor = props.$theme.colors.toggleFillDisabled;
- } else if (props.$checked && props.$error) {
- backgroundColor = props.$theme.colors.tickFillErrorSelected;
- } else if (props.$checked) {
- backgroundColor = props.$theme.colors.toggleFillChecked;
- }
-
- return {
- backgroundColor,
- borderTopLeftRadius: '50%',
- borderTopRightRadius: '50%',
- borderBottomRightRadius: '50%',
- borderBottomLeftRadius: '50%',
- boxShadow: props.$isFocusVisible
- ? `0 0 0 3px ${props.$theme.colors.borderAccent}`
- : props.$isHovered && !props.$disabled
- ? props.$theme.lighting.shadow500
- : props.$theme.lighting.shadow400,
- outline: 'none',
- height: props.$theme.sizing.scale700,
- width: props.$theme.sizing.scale700,
- transform: props.$checked
- ? `translateX(${props.$theme.direction === 'rtl' ? '-100%' : '100%'})`
- : null,
- transition: `transform ${props.$theme.animation.timing200}`,
- };
-});
-
-export const ToggleTrack = styled('div', (props) => {
- let backgroundColor = props.$theme.colors.toggleTrackFill;
- if (props.$disabled) {
- backgroundColor = props.$theme.colors.toggleTrackFillDisabled;
- } else if (props.$error && props.$checked) {
- backgroundColor = props.$theme.colors.tickFillError;
- }
- return {
- alignItems: 'center',
- backgroundColor,
- borderTopLeftRadius: '7px',
- borderTopRightRadius: '7px',
- borderBottomRightRadius: '7px',
- borderBottomLeftRadius: '7px',
- display: 'flex',
- height: props.$theme.sizing.scale550,
- marginTop: props.$theme.sizing.scale200,
- marginBottom: props.$theme.sizing.scale100,
- marginLeft: props.$theme.sizing.scale200,
- marginRight: props.$theme.sizing.scale100,
- width: props.$theme.sizing.scale1000,
- };
-});
diff --git a/src/checkbox/types.js.flow b/src/checkbox/types.js.flow
deleted file mode 100644
index da3dab8d2e..0000000000
--- a/src/checkbox/types.js.flow
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-Copyright (c) Uber Technologies, Inc.
-
-This source code is licensed under the MIT license found in the
-LICENSE file in the root directory of this source tree.
-*/
-// @flow
-
-import type { OverrideT } from '../helpers/overrides.js';
-import { STYLE_TYPE } from './constants.js';
-
-export type LabelPlacementT = 'top' | 'right' | 'bottom' | 'left';
-export type StyleTypeT = $Keys;
-export type ReactRefT = { current: null | T } | {| current: null | T |};
-
-export type OverridesT = {
- Checkmark?: OverrideT,
- Label?: OverrideT,
- Root?: OverrideT,
- Input?: OverrideT,
- Toggle?: OverrideT,
- ToggleInner?: OverrideT,
- ToggleTrack?: OverrideT,
-};
-
-export type DefaultPropsT = {
- children?: React$Node,
- checked: boolean,
- disabled: boolean,
- error: boolean,
- autoFocus: boolean,
- isIndeterminate: boolean,
- inputRef: ReactRefT,
- checkmarkType: StyleTypeT,
- onChange: (e: SyntheticInputEvent) => mixed,
- onMouseEnter: (e: SyntheticInputEvent) => mixed,
- onMouseLeave: (e: SyntheticInputEvent) => mixed,
- onMouseDown: (e: SyntheticInputEvent) => mixed,
- onMouseUp: (e: SyntheticInputEvent) => mixed,
- onFocus: (e: SyntheticInputEvent) => mixed,
- onBlur: (e: SyntheticInputEvent