diff --git a/src/examples/data/components.js b/src/examples/data/components.js index edb4cabdba..f2f38663e5 100644 --- a/src/examples/data/components.js +++ b/src/examples/data/components.js @@ -1,39 +1,16 @@ -export { default as Accordion } from '../../legacy/Accordion/examples/KitchenSink'; -export { default as ActivityButton } from '../../legacy/ActivityButton/examples/KitchenSink'; -export { default as Alert } from '../../legacy/Alert/examples/KitchenSink'; export { default as AlertBanner } from '../../legacy/AlertBanner/examples/KitchenSink'; -export { default as AlertCall } from '../../legacy/AlertCall/examples/KitchenSink'; -export { default as AlertMeeting } from '../../legacy/AlertMeeting/examples/KitchenSink'; export { default as Avatar } from '../../legacy/Avatar/examples/KitchenSink'; export { default as Badge } from '../../legacy/Badge/examples/KitchenSink'; -export { default as Breadcrumbs } from '../../legacy/Breadcrumbs/examples/KitchenSink'; export { default as Button } from '../../legacy/Button/examples/KitchenSink'; export { default as ButtonGroup } from '../../legacy/ButtonGroup/examples/KitchenSink'; -export { default as CallControl } from '../../legacy/CallControl/examples/KitchenSink'; -export { default as Card } from '../../legacy/Card/examples/KitchenSink'; -export { default as CardSection } from '../../legacy/CardSection/examples/KitchenSink'; -export { default as Checkbox } from '../../legacy/Checkbox/examples/KitchenSink'; -export { default as Coachmark } from '../../legacy/Coachmark/examples/KitchenSink'; -export { default as CollapseButton } from '../../legacy/CollapseButton/examples/KitchenSink'; -export { default as ComboBox } from '../../legacy/ComboBox/examples/KitchenSink'; export { default as ContentItem } from '../../legacy/ContentItem/examples/KitchenSink'; -export { default as DatePicker } from '../../legacy/DatePicker/examples/KitchenSink'; -export { default as Dialog } from '../../legacy/Dialog/examples/KitchenSink'; -export { default as EditableTextfield } from '../../legacy/EditableTextfield/examples/KitchenSink'; -export { default as EventOverlay } from '../../legacy/EventOverlay/examples/KitchenSink'; -export { default as FormSection } from '../../legacy/FormSection/examples/KitchenSink'; -export { default as FormSubSection } from '../../legacy/FormSubSection/examples/KitchenSink'; export { default as Icon } from '../../legacy/Icon/examples/KitchenSink'; export { default as Input } from '../../legacy/Input/examples/KitchenSink'; -export { default as InputHelper } from '../../legacy/InputHelper/examples/KitchenSink'; -export { default as InputSearch } from '../../legacy/InputSearch/examples/KitchenSink'; -export { default as Label } from '../../legacy/Label/examples/KitchenSink'; export { default as Lightbox } from '../../legacy/Lightbox/examples/KitchenSink'; export { default as Link } from '../../legacy/Link/examples/KitchenSink'; export { default as List } from '../../legacy/List/examples/KitchenSink'; export { default as ListItem } from '../../legacy/ListItem/examples/KitchenSink'; export { default as ListItemHeader } from '../../legacy/ListItemHeader/examples/KitchenSink'; -export { default as ListItemMeeting } from '../../legacy/ListItemMeeting/examples/KitchenSink'; export { default as Loading } from '../../legacy/Loading/examples/KitchenSink'; export { default as Menu } from '../../legacy/Menu/examples/KitchenSink'; export { default as Modal } from '../../legacy/Modal/examples/KitchenSink'; @@ -41,15 +18,7 @@ export { default as ModalBody } from '../../legacy/ModalBody/examples/KitchenSin export { default as ModalFooter } from '../../legacy/ModalFooter/examples/KitchenSink'; export { default as Popover } from '../../legacy/Popover/examples/KitchenSink'; export { default as ProgressBar } from '../../legacy/ProgressBar/examples/KitchenSink'; -export { default as Radio } from '../../legacy/Radio/examples/KitchenSink'; export { default as Select } from '../../legacy/Select/examples/KitchenSink'; -export { default as Sidebar } from '../../legacy/Sidebar/examples/KitchenSink'; -export { default as Slider } from '../../legacy/Slider/examples/KitchenSink'; -export { default as SocialList } from '../../legacy/SocialList/examples/KitchenSink'; export { default as SpaceListItem } from '../../legacy/SpaceListItem/examples/KitchenSink'; export { default as Spinner } from '../../legacy/Spinner/examples/KitchenSink'; -export { default as Tabs } from '../../legacy/Tabs/examples/KitchenSink'; -export { default as TimePicker } from '../../legacy/TimePicker/examples/KitchenSink'; -export { default as Topbar } from '../../legacy/Topbar/examples/KitchenSink'; -export { default as ToggleSwitch } from '../../legacy/ToggleSwitch/examples/KitchenSink'; export { default as Tooltip } from '../../legacy/Tooltip/examples/KitchenSink'; diff --git a/src/index.js b/src/index.js index d9043cfde9..714e201eba 100644 --- a/src/index.js +++ b/src/index.js @@ -2,58 +2,22 @@ * Entry file for momentum-ui-react module. */ export { - Accordion, - AccordionGroup, - AccordionHeader, - AccordionContent, - ActivityButton, - Alert, AlertBanner, - AlertCall, - AlertCallContainer, AlertContainer, - AlertMeeting, Avatar, Badge, - Breadcrumbs, Button, ButtonGroup, - CallControl, - Card, - CardSection, - Checkbox, - CheckboxGroup, Chip, - CloseIcon, - CloseWrapper, - Coachmark, - ComboBox, - CompositeAvatar, - CollapseButton, ContentItem, - DatePicker, - EditableTextfield, - EventOverlay, - ErrorBoundary, - Footer, Form, - FormContent, - FormInfo, - FormSection, - FormSubSection, Icon, Input, - InputMessage, - InputHelper, - InputSearch, - InputSection, - Label, Lightbox, Link, List, ListItem, ListItemHeader, - ListItemMeeting, ListItemSection, ListSeparator, Loading, @@ -67,34 +31,11 @@ export { ModalHeader, Popover, ProgressBar, - Radio, - RadioGroup, Select, SelectOption, - Sidebar, - SidebarBody, - SidebarFooter, - SidebarHeader, - SidebarNav, - SidebarNavItem, - Slider, - SocialList, SpaceListItem, - SpaceListMeeting, Spinner, SubMenu, - Tab, - TabContent, - TabHeader, - TabList, - TabPane, - Tabs, - TimePicker, - ToggleSwitch, - Topbar, - TopbarMobile, - TopbarNav, - TopbarRight, Tooltip, } from './legacy'; diff --git a/src/legacy/Accordion/examples/Default.js b/src/legacy/Accordion/examples/Default.js deleted file mode 100644 index 034dafc807..0000000000 --- a/src/legacy/Accordion/examples/Default.js +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; -import { - Accordion, - AccordionContent, - AccordionGroup, - AccordionHeader, - ListItem, -} from '@momentum-ui/react-collaboration'; -export default class AccordionDefault extends React.Component { - render() { - return ( - - - -
Accordion 1
-
- - - -
- - -
Accordion 2
-
- - - -
-
- ); - } -} diff --git a/src/legacy/Accordion/examples/KitchenSink.js b/src/legacy/Accordion/examples/KitchenSink.js deleted file mode 100644 index a7e2e48a55..0000000000 --- a/src/legacy/Accordion/examples/KitchenSink.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { AccordionDefault, AccordionMultiOpen, AccordionPreSelectedOpen } from './index'; - -export default class AccordionKitchenSink extends React.Component { - render() { - return ( - - - - - - ); - } -} diff --git a/src/legacy/Accordion/examples/KitchenSink.stories.tsx b/src/legacy/Accordion/examples/KitchenSink.stories.tsx deleted file mode 100644 index b712bd930f..0000000000 --- a/src/legacy/Accordion/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/Accordion', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/Accordion/examples/MultiOpen.js b/src/legacy/Accordion/examples/MultiOpen.js deleted file mode 100644 index de0a4375c9..0000000000 --- a/src/legacy/Accordion/examples/MultiOpen.js +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; -import { - Accordion, - AccordionContent, - AccordionGroup, - AccordionHeader, - ListItem, -} from '@momentum-ui/react-collaboration'; -export default class AccordionMultiOpen extends React.Component { - render() { - return ( - - - -
Accordion 1
-
- - - -
- - -
Accordion 2
-
- - - -
-
- ); - } -} diff --git a/src/legacy/Accordion/examples/PreSelectedOpen.js b/src/legacy/Accordion/examples/PreSelectedOpen.js deleted file mode 100644 index e25939930b..0000000000 --- a/src/legacy/Accordion/examples/PreSelectedOpen.js +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; -import { - Accordion, - AccordionContent, - AccordionGroup, - AccordionHeader, - ListItem, -} from '@momentum-ui/react-collaboration'; -export default class AccordionPreSelectedOpen extends React.Component { - render() { - return ( - - - -
Accordion 1
-
- - - -
- - -
Accordion 2
-
- - - -
-
- ); - } -} diff --git a/src/legacy/Accordion/examples/index.js b/src/legacy/Accordion/examples/index.js deleted file mode 100644 index f72e504567..0000000000 --- a/src/legacy/Accordion/examples/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as AccordionDefault } from './Default'; -export { default as AccordionKitchenSink } from './KitchenSink'; -export { default as AccordionMultiOpen } from './MultiOpen'; -export { default as AccordionPreSelectedOpen } from './PreSelectedOpen'; diff --git a/src/legacy/Accordion/index.js b/src/legacy/Accordion/index.js deleted file mode 100644 index 7fdf550e14..0000000000 --- a/src/legacy/Accordion/index.js +++ /dev/null @@ -1,220 +0,0 @@ -/**@component accordion */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class Accordion extends React.Component { - static displayName = 'Accordion'; - - state = { - activeIndices: this.props.initialActive || [], - focus: false, - }; - - componentDidMount() { - if (!this.verifyChildren()) { - throw new Error('Accordion should contain one or more AccordionGroup as children.'); - } - - this.determineInitialFocus(); - } - - verifyChildren = () => { - const { children } = this.props; - const childrenArr = React.Children.toArray(children); - - const status = childrenArr.reduce((status, child) => { - return status && child.type.displayName === 'AccordionGroup'; - }, true); - - return children && childrenArr.length && status; - }; - - determineInitialFocus = () => { - const nonDisabledIndex = React.Children.toArray(this.props.children).reduceRight( - (agg, child, idx) => { - return !child.props.disabled ? idx : agg; - }, - null - ); - - this.setFocus(nonDisabledIndex); - }; - - handleClick = (index) => { - return this.props.multipleVisible ? this.setMultiple(index) : this.setSelected(index); - }; - - setMultiple = (index) => { - let newValues; - const { onSelect } = this.props; - const { activeIndices } = this.state; - const isActive = activeIndices.includes(index); - - if (isActive) { - newValues = activeIndices.filter((v) => v !== index); - } else { - newValues = activeIndices.concat(index); - } - - this.setFocus(index); - this.setState(() => { - onSelect && onSelect(newValues); - return { activeIndices: newValues }; - }); - }; - - setSelected = (index) => { - const { activeIndices } = this.state; - const { children, onSelect } = this.props; - // Don't do anything if index is the same or outside of the bounds - if (activeIndices.includes(index) || index < 0 || index >= children.length) return; - - // Keep reference to last index for event handler - const last = activeIndices[0]; - - // Update state with selected index - this.setState(() => ({ activeIndices: [index] })); - this.setFocus(index); - - onSelect && onSelect(index, last); - }; - - handleKeyPress = (e, idx, length, disabled) => { - if (disabled) { - e.preventDefault(); - e.stopPropagation(); - return; - } - - let newIndex, clickEvent; - const tgt = e.currentTarget; - let flag = false; - - const getNewIndex = (currentIndex, change) => { - const getPossibleIndex = () => { - if (currentIndex + change < 0) { - return length; - } else if (currentIndex + change > length) { - return 0; - } - - return currentIndex + change; - }; - const possibleIndex = getPossibleIndex(); - return React.Children.toArray(this.props.children)[possibleIndex].props.disabled - ? getNewIndex(possibleIndex, change) - : possibleIndex; - }; - - switch (e.which) { - case 32: - case 13: - try { - clickEvent = new MouseEvent('click', { - view: window, - bubbles: true, - cancelable: true, - }); - } catch (err) { - if (document.createEvent) { - // DOM Level 3 for IE 9+ - clickEvent = document.createEvent('MouseEvents'); - clickEvent.initEvent('click', true, true); - } - } - tgt.dispatchEvent(clickEvent); - - flag = true; - break; - - case 38: - case 37: - newIndex = getNewIndex(idx, -1); - this.setFocus(newIndex); - flag = true; - break; - - case 39: - case 40: - newIndex = getNewIndex(idx, 1); - this.setFocus(newIndex); - flag = true; - break; - - case 33: - case 36: - this.setFocus(0); - flag = true; - break; - - case 34: - case 35: - this.setFocus(length); - flag = true; - break; - default: - break; - } - - if (flag) { - e.stopPropagation(); - e.preventDefault(); - } - }; - - setFocus = (index) => { - this.setState({ focus: index }); - }; - - render() { - const { children, className, showSeparator } = this.props; - - const { activeIndices } = this.state; - - const setAccordionGroups = React.Children.map(children, (child, idx) => { - return React.cloneElement(child, { - isExpanded: !child.props.disabled && activeIndices.includes(idx), - onClick: () => this.handleClick(idx), - onKeyDown: (e) => this.handleKeyPress(e, idx, children.length - 1, child.props.disabled), - focus: this.state.focus === idx, - showSeparator, - }); - }); - - return ( -
- {setAccordionGroups} -
- ); - } -} - -Accordion.propTypes = { - /** @prop Children nodes to render inside Accordion | null */ - children: PropTypes.node, - /** @prop Set to allow expansion of multiple AccordionGroups | false */ - multipleVisible: PropTypes.bool, - /** @prop Handler to be called when the user selects Accordion | null */ - onSelect: PropTypes.func, - /** @prop An array of indexes that are preselected | [] */ - initialActive: PropTypes.array, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Optional underline under Accordion menu item | false */ - showSeparator: PropTypes.bool, -}; - -Accordion.defaultProps = { - children: null, - multipleVisible: false, - onSelect: null, - initialActive: [], - className: '', - showSeparator: false, -}; - -export default Accordion; diff --git a/src/legacy/Accordion/tests/index.spec.js b/src/legacy/Accordion/tests/index.spec.js deleted file mode 100644 index c95b03bb46..0000000000 --- a/src/legacy/Accordion/tests/index.spec.js +++ /dev/null @@ -1,202 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { - Accordion, - AccordionHeader, - AccordionGroup, - AccordionContent, -} from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount( - - - - Hi - - - Hello - - - - ); - expect(container).toMatchSnapshot(); - }); - - it('with multipleVisible as true, multiple AccordionGroups can be open', () => { - const onSelect = jest.fn(); - const container = mount( - - - - Hi - - - Hello - - - - - - Hi - - - Hello - - - - - - Hi - - - Hello - - - - ); - - const firstGroup = container.find('.md-accordion__header').at(0); - firstGroup.simulate('click'); - expect( - container.find('.md-accordion__group').at(0).hasClass('md-accordion__group--active') - ).toEqual(true); - expect(onSelect).toHaveBeenCalledWith([0]); - expect(container.find('AccordionHeader').at(0).props().focus).toEqual(true); - - const secondGroup = container.find('.md-accordion__header').at(1); - secondGroup.simulate('click'); - expect( - container.find('.md-accordion__group').at(1).hasClass('md-accordion__group--active') - ).toEqual(true); - expect(onSelect).toHaveBeenCalledWith([0, 1]); - - const thirdGroup = container.find('.md-accordion__header').at(2); - thirdGroup.simulate('click'); - expect( - container.find('.md-accordion__group').at(1).hasClass('md-accordion__group--active') - ).toEqual(true); - }); - - it('with multipleVisible prop as false, only one AccordionGroup can be open', () => { - const onSelect = jest.fn(); - const container = mount( - - - - Hi - - - Hello - - - - - - Hi - - - Hello - - - - ); - expect( - container.find('.md-accordion__group').at(0).hasClass('md-accordion__group--active') - ).toEqual(true); - - const secondGroup = container.find('.md-accordion__header').at(1); - secondGroup.simulate('click'); - expect( - container.find('.md-accordion__group').at(1).hasClass('md-accordion__group--active') - ).toEqual(true); - expect(onSelect).toHaveBeenCalledWith(1, 0); - expect( - container.find('.md-accordion__group').at(0).hasClass('md-accordion__group--active') - ).toEqual(false); - }); - - it('should clone children with props', () => { - const container = shallow( - - - - ); - - expect(container.children().props().isExpanded).toEqual(true); - expect(container.children().props().showSeparator).toEqual(false); - }); - - it('should add custom class', () => { - const container = shallow( - - - - ); - expect(container.find('.testClass').exists()).toEqual(true); - }); - - it('should throw error if child is not an AccordionGroup', () => { - try { - shallow( - -
- - ); - } catch (e) { - expect(e.message).toEqual('Accordion should contain one or more AccordionGroup as children.'); - } - }); - - it('should handle keyboard keys', () => { - const onSelect = jest.fn(); - const container = mount( - - - - Hi - - - Hello - - - - - - Hi - - - Hello - - - - - - Hi - - - Hello - - - - ); - - // second element is in focus, since first element is disabled - expect(container.find('AccordionHeader').at(1).props().focus).toEqual(true); - const secondHeader = container.find('.md-accordion__header').at(1); - const thirdHeader = container.find('.md-accordion__header').at(2); - - // press down and third element is in focus - secondHeader.simulate('keyDown', { which: 39, charCode: 39, key: 'Down' }); - expect(container.find('AccordionHeader').at(2).props().focus).toEqual(true); - - // press down and second element is in focus - thirdHeader.simulate('keyDown', { which: 39, charCode: 39, key: 'Down' }); - expect(container.find('AccordionHeader').at(1).props().focus).toEqual(true); - - // press up and third element is in focus - secondHeader.simulate('keyDown', { which: 38, charCode: 38, key: 'Up' }); - expect(container.find('AccordionHeader').at(2).props().focus).toEqual(true); - }); -}); diff --git a/src/legacy/Accordion/tests/index.spec.js.snap b/src/legacy/Accordion/tests/index.spec.js.snap deleted file mode 100644 index 54c02d518c..0000000000 --- a/src/legacy/Accordion/tests/index.spec.js.snap +++ /dev/null @@ -1,70 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
- -
- -
- - Hi - - -
-
- -
- - Hello - -
-
-
-
-
-
-`; diff --git a/src/legacy/AccordionContent/index.js b/src/legacy/AccordionContent/index.js deleted file mode 100644 index d620c68611..0000000000 --- a/src/legacy/AccordionContent/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** @component accordion */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const AccordionContent = (props) => { - const { children, className } = props; - return ( -
- {children} -
- ); -}; - -AccordionContent.displayName = 'AccordionContent'; - -AccordionContent.propTypes = { - /** @prop Children nodes to render inside AccordionContent | null */ - children: PropTypes.node, - /** @prop Optional css class string | '' */ - className: PropTypes.string, -}; - -AccordionContent.defaultProps = { - children: null, - className: '', -}; - -export default AccordionContent; diff --git a/src/legacy/AccordionContent/tests/index.spec.js b/src/legacy/AccordionContent/tests/index.spec.js deleted file mode 100644 index 0cdcb05a7d..0000000000 --- a/src/legacy/AccordionContent/tests/index.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { AccordionContent } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render one AccordionContent', () => { - const container = shallow(); - - expect(container.find('.md-accordion__content').length).toEqual(1); - }); - - it('should pass ClassName Prop', () => { - const container = shallow(); - - expect(container.find('.testClass').exists()).toEqual(true); - }); - - it('should render children', () => { - const container = shallow( - -
- - ); - - expect(container.find('.testingforTC').length).toEqual(1); - }); -}); diff --git a/src/legacy/AccordionContent/tests/index.spec.js.snap b/src/legacy/AccordionContent/tests/index.spec.js.snap deleted file mode 100644 index 43a39c49b1..0000000000 --- a/src/legacy/AccordionContent/tests/index.spec.js.snap +++ /dev/null @@ -1,11 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
- -`; diff --git a/src/legacy/AccordionGroup/index.js b/src/legacy/AccordionGroup/index.js deleted file mode 100644 index b1dda94392..0000000000 --- a/src/legacy/AccordionGroup/index.js +++ /dev/null @@ -1,101 +0,0 @@ -/** @component accordion */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class AccordionGroup extends React.Component { - static displayName = 'AccordionGroup'; - - static childContextTypes = { - onClick: PropTypes.func, - onKeyDown: PropTypes.func, - }; - - getChildContext = () => { - return { - onClick: this.props.onClick, - onKeyDown: this.props.onKeyDown, - }; - }; - - componentDidMount() { - if (!this.verifyChildren()) { - throw new Error( - 'AccordionGroup should contain 2 children ' + - 'AccordionHeader and AccordionContent respectively.' - ); - } - } - - verifyChildren = () => { - const { children } = this.props; - const childrenArr = React.Children.toArray(children); - return ( - children && - childrenArr.length === 2 && - childrenArr[0].type.displayName === 'AccordionHeader' && - childrenArr[1].type.displayName === 'AccordionContent' - ); - }; - - render() { - const { children, className, isExpanded, disabled, focus, showSeparator } = this.props; - - const setGroupContent = React.Children.map(children, (child) => { - return React.cloneElement(child, { - disabled, - focus, - showSeparator, - }); - }); - - return ( -
- {setGroupContent} -
- ); - } -} - -AccordionGroup.propTypes = { - /** @prop Children nodes to render inside Accordion | null */ - children: PropTypes.node, - /** @prop Set accordionGroup to be expanded | false */ - isExpanded: PropTypes.bool, - /** @prop Handler to be called when the user taps the AccordionGroup | null */ - onClick: PropTypes.func, - /** @prop Handler to be called when the user presses a key | null */ - onKeyDown: PropTypes.func, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Set the attribute disabled to the accordionGroup | false */ - disabled: PropTypes.bool, - /** @prop Specifies if AccordionGroup show automatically get focus when page loads | false */ - focus: PropTypes.bool, - /** @prop Optional underline under Accordion menu item | false */ - showSeparator: PropTypes.bool, -}; - -AccordionGroup.defaultProps = { - children: null, - isExpanded: false, - onClick: null, - onKeyDown: null, - className: '', - disabled: false, - focus: false, - showSeparator: false, -}; - -export default AccordionGroup; diff --git a/src/legacy/AccordionGroup/tests/index.spec.js b/src/legacy/AccordionGroup/tests/index.spec.js deleted file mode 100644 index 15e14c46f9..0000000000 --- a/src/legacy/AccordionGroup/tests/index.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { - AccordionGroup, - AccordionContent, - AccordionHeader, -} from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount( - - - - - ); - expect(container).toMatchSnapshot(); - }); - - it('should render children', () => { - const container = mount( - - - - - ); - const group = container.find('.md-accordion__group'); - - expect(group.length).toEqual(1); - expect(group.hasClass('md-accordion__group--active')).toEqual(true); - expect(group.find('.md-accordion__header').length).toEqual(1); - expect(group.find('.md-accordion__content').length).toEqual(1); - expect(container.instance().props.isExpanded).toEqual(true); - }); - - it('should pass disabled, focus and showSeparator props to children', () => { - const container = shallow( - - - - - ); - const group = container.find('.md-accordion__group'); - expect(group.hasClass('testClass')).toEqual(true); - expect(group.hasClass('md-accordion__group--disabled')).toEqual(true); - expect(container.find('AccordionHeader').props().disabled).toEqual(true); - expect(container.find('AccordionHeader').props().focus).toEqual(true); - expect(container.find('AccordionHeader').props().showSeparator).toEqual(false); - }); - - it('should throw error if header and content are not present', () => { - try { - shallow(); - } catch (e) { - expect(e.message).toEqual( - 'AccordionGroup should contain 2 children AccordionHeader and AccordionContent respectively.' - ); - } - }); -}); diff --git a/src/legacy/AccordionGroup/tests/index.spec.js.snap b/src/legacy/AccordionGroup/tests/index.spec.js.snap deleted file mode 100644 index 788936a1a1..0000000000 --- a/src/legacy/AccordionGroup/tests/index.spec.js.snap +++ /dev/null @@ -1,50 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
- -
- -
-
- -
- -
- -`; diff --git a/src/legacy/AccordionHeader/index.js b/src/legacy/AccordionHeader/index.js deleted file mode 100644 index 95c24ad01d..0000000000 --- a/src/legacy/AccordionHeader/index.js +++ /dev/null @@ -1,72 +0,0 @@ -/** @component accordion */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class AccordionHeader extends React.Component { - static displayName = 'AccordionHeader'; - - static contextTypes = { - onClick: PropTypes.func, - onKeyDown: PropTypes.func, - }; - - componentDidUpdate(prevProps) { - const { focus } = this.props; - !prevProps.focus && focus && this.headerRef.focus(); - } - - render() { - const { children, className, disabled, showSeparator, height } = this.props; - - const { onClick, onKeyDown } = this.context; - - return ( -
(this.headerRef = ref)} - onClick={onClick} - onKeyDown={onKeyDown} - tabIndex={!disabled ? 0 : -1} - className={ - 'md-accordion__header' + - `${(showSeparator && ` md-accordion__header--separator`) || ''}` + - `${(height && ` md-accordion__header--${height}`) || ''}` + - `${(className && ` ${className}`) || ''}` - } - > - {children} - -
- ); - } -} - -AccordionHeader.propTypes = { - /** @prop Children nodes to render inside AccordionHeader | null */ - children: PropTypes.node, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Set the attribute disabled to the AccordionHeader | false */ - disabled: PropTypes.bool, - /** @prop Specifies if AccordionHeader automatically gets focus when page loads | false */ - focus: PropTypes.bool, - /** @prop Optional underline under Accordion menu item | false */ - showSeparator: PropTypes.bool, - /** @prop Set the height of the AccordionHeader to either the default or 56px | '' */ - height: PropTypes.oneOf(['', 56]), -}; - -AccordionHeader.defaultProps = { - children: null, - className: '', - disabled: false, - focus: false, - showSeparator: true, - height: '', -}; - -export default AccordionHeader; diff --git a/src/legacy/AccordionHeader/tests/index.spec.js b/src/legacy/AccordionHeader/tests/index.spec.js deleted file mode 100644 index 99eb418468..0000000000 --- a/src/legacy/AccordionHeader/tests/index.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { AccordionHeader } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render children', () => { - const container = shallow( - -
- - ); - expect(container.find('.testingforTC').length).toEqual(1); - }); - - it('should pass ClassName Prop', () => { - const container = shallow(); - - expect(container.find('.testClass').exists()).toEqual(true); - expect(container.find('.md-accordion__header').props().tabIndex).toEqual(0); - }); - - it('when the header is disabled, should set tabIndex to -1', () => { - const container = shallow(); - expect(container.find('.md-accordion__header').props().tabIndex).toEqual(-1); - }); - - it('when the showSeparator prop is true, should display the separator', () => { - const container = shallow(); - expect( - container.find('.md-accordion__header').hasClass('md-accordion__header--separator') - ).toEqual(true); - }); - - it('when height prop is set, should apply height style to header', () => { - const container = shallow(); - expect(container.find('.md-accordion__header').hasClass('md-accordion__header--56')).toEqual( - true - ); - }); - - it('should call the context handler function on click and keyDown event', () => { - const onClickFn = jest.fn(); - const onKeyDownFn = jest.fn(); - const container = mount(, { - context: { - onClick: onClickFn, - onKeyDown: onKeyDownFn, - }, - }); - container.simulate('click'); - expect(onClickFn).toHaveBeenCalled(); - container.simulate('keyDown'); - expect(onKeyDownFn).toHaveBeenCalled(); - }); -}); diff --git a/src/legacy/AccordionHeader/tests/index.spec.js.snap b/src/legacy/AccordionHeader/tests/index.spec.js.snap deleted file mode 100644 index c0fa1b4855..0000000000 --- a/src/legacy/AccordionHeader/tests/index.spec.js.snap +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
- -
-
-`; diff --git a/src/legacy/ActivityButton/examples/Default.js b/src/legacy/ActivityButton/examples/Default.js deleted file mode 100644 index ca93939fad..0000000000 --- a/src/legacy/ActivityButton/examples/Default.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { ActivityButton } from '@momentum-ui/react-collaboration'; -export default function ActivityButtonDefault() { - return ( -
- {}} label="Chat" ariaLabel="Chats" /> - {}} label="Camera" ariaLabel="Camera" /> - {}} label="Meetings" ariaLabel="Meetings" /> - {}} - label="Whiteboard" - ariaLabel="Whiteboard" - /> - {}} label="Files" ariaLabel="Files" /> - {}} label="Share" ariaLabel="Share" /> - {}} label="Tasks" ariaLabel="Tasks" /> -
- ); -} diff --git a/src/legacy/ActivityButton/examples/KitchenSink.js b/src/legacy/ActivityButton/examples/KitchenSink.js deleted file mode 100644 index c5682e005d..0000000000 --- a/src/legacy/ActivityButton/examples/KitchenSink.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { ActivityButtonDefault, ActivityButtonLarge, ActivityButtonSize56 } from './index'; - -export default class ActivityButtonKitchenSink extends React.Component { - render() { - return ( - - - - - - ); - } -} diff --git a/src/legacy/ActivityButton/examples/KitchenSink.stories.tsx b/src/legacy/ActivityButton/examples/KitchenSink.stories.tsx deleted file mode 100644 index 7c5e4817b9..0000000000 --- a/src/legacy/ActivityButton/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/ActivityButton', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/ActivityButton/examples/Large.js b/src/legacy/ActivityButton/examples/Large.js deleted file mode 100644 index b90e16537c..0000000000 --- a/src/legacy/ActivityButton/examples/Large.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import { ActivityButton } from '@momentum-ui/react-collaboration'; -export default function ActivityButtonLarge() { - return ( -
- {}} label="Chat" ariaLabel="Chat" /> - {}} - label="Camera" - ariaLabel="Camera" - /> - {}} - label="Meetings" - ariaLabel="Meetings" - /> - {}} - label="Whiteboard" - ariaLabel="Whiteboard" - /> - {}} label="Files" ariaLabel="Files" /> - {}} - label="Share" - ariaLabel="Share" - /> - {}} - label="Tasks" - ariaLabel="Tasks" - title="tasks" - /> -
- ); -} diff --git a/src/legacy/ActivityButton/examples/Size56.js b/src/legacy/ActivityButton/examples/Size56.js deleted file mode 100644 index 14e3768e5f..0000000000 --- a/src/legacy/ActivityButton/examples/Size56.js +++ /dev/null @@ -1,53 +0,0 @@ -import React from 'react'; -import { ActivityButton } from '@momentum-ui/react-collaboration'; -export default function ActivityButtonSize56() { - return ( -
- {}} label="Chat" ariaLabel="Chat" /> - {}} - label="Camera" - ariaLabel="Camera" - /> - {}} - label="Contact Card" - ariaLabel="Contact Card" - /> - {}} - label="Meetings" - ariaLabel="Meetings" - /> - {}} - label="Whiteboard" - ariaLabel="Whiteboard" - /> - {}} label="Files" ariaLabel="Files" /> - {}} - label="Share" - ariaLabel="Share" - /> - {}} - label="Tasks" - ariaLabel="Tasks" - title="tasks" - /> -
- ); -} diff --git a/src/legacy/ActivityButton/examples/index.js b/src/legacy/ActivityButton/examples/index.js deleted file mode 100644 index 773c362d67..0000000000 --- a/src/legacy/ActivityButton/examples/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as ActivityButtonDefault } from './Default'; -export { default as ActivityButtonKitchenSink } from './KitchenSink'; -export { default as ActivityButtonLarge } from './Large'; -export { default as ActivityButtonSize56 } from './Size56'; diff --git a/src/legacy/ActivityButton/index.js b/src/legacy/ActivityButton/index.js deleted file mode 100644 index 62d62f52f0..0000000000 --- a/src/legacy/ActivityButton/index.js +++ /dev/null @@ -1,86 +0,0 @@ -/** @component activity-button */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import get from 'lodash/get'; -import { Button, Icon } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const ActivityButton = (props) => { - const { ariaLabel, className, disabled, onClick, size, type, ...otherHTMLProps } = props; - - let icon = type.icon; - if (!icon) { - const buttonToIconSizeMapping = { - 56: '24', - 68: '28', - 84: '36', - }; - icon = ; - } - - return ( - - ); -}; - -ActivityButton.displayName = 'ActivityButton'; - -ActivityButton.propTypes = { - /** @prop Text to display for blindness accessibility features | '' */ - ariaLabel: PropTypes.string, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Sets the attribute disabled to the button | false */ - disabled: PropTypes.bool, - /** @prop Handler to be called when the user taps the button | null */ - onClick: PropTypes.func, - /** @prop Sets the button's size | '' */ - size: PropTypes.oneOf([56, 68, 84]), - /** @prop Sets the button's activity type */ - type: PropTypes.oneOfType([ - PropTypes.oneOf([ - 'chat', - 'camera', - 'contact-card', - 'meetings', - 'whiteboard', - 'files', - 'share-screen', - 'tasks', - ]), - PropTypes.shape({ - color: PropTypes.string, - icon: PropTypes.element.isRequired, - }), - ]).isRequired, -}; - -ActivityButton.defaultProps = { - ariaLabel: '', - className: '', - disabled: false, - size: 68, - onClick: null, - type: '', -}; - -export default ActivityButton; diff --git a/src/legacy/ActivityButton/tests/index.spec.js b/src/legacy/ActivityButton/tests/index.spec.js deleted file mode 100644 index 2129380892..0000000000 --- a/src/legacy/ActivityButton/tests/index.spec.js +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import { ActivityButton } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render one ActivityButton button', () => { - const container = mount(); - - expect(container.find('Button').length).toEqual(1); - }); - - it('should handle onClick event', () => { - let count = 0; - const countUp = () => count++; - const container = mount(); - - container.find('Button').simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle keyDown as onClick event', () => { - let count = 0; - const countUp = () => count++; - const container = mount(); - - container.find('Button').simulate('click'); - container.find('Button').simulate('keyDown', { which: 13, charCode: 13, key: 'Space' }); - expect(count).toEqual(2); - }); - - it('should render meetings type', () => { - const container = mount(); - - expect(container.find('Button').hasClass('md-activity__meetings')).toEqual(true); - }); - - it('should render large meetings type', () => { - const container = mount(); - - expect(container.find('.md-button--84').exists()).toEqual(true); - }); - - it('should render custom activity', () => { - const container = mount( - }} - /> - ); - - expect( - container - .find('button') - .hasClass('md-button md-button--circle md-button--68 md-button--red md-activity') - ).toEqual(true); - }); -}); diff --git a/src/legacy/ActivityButton/tests/index.spec.js.snap b/src/legacy/ActivityButton/tests/index.spec.js.snap deleted file mode 100644 index c1aba366c9..0000000000 --- a/src/legacy/ActivityButton/tests/index.spec.js.snap +++ /dev/null @@ -1,124 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - - - - - - - - -`; diff --git a/src/legacy/Alert/examples/Default.js b/src/legacy/Alert/examples/Default.js deleted file mode 100644 index 9d37161020..0000000000 --- a/src/legacy/Alert/examples/Default.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { Alert, AlertContainer, Button } from '@momentum-ui/react-collaboration'; -export default class AlertDefault extends React.PureComponent { - state = { - show: false, - }; - render() { - return ( -
-
-
-
-
-
- - this.setState({ show: false }), - ariaLabel: 'Close Alert', - }} - show={this.state.show} - type="info" - /> - -
- ); - } -} diff --git a/src/legacy/Alert/examples/Error.js b/src/legacy/Alert/examples/Error.js deleted file mode 100644 index 618bddc4f4..0000000000 --- a/src/legacy/Alert/examples/Error.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { Alert, AlertContainer, Button } from '@momentum-ui/react-collaboration'; -export default class AlertDefault extends React.PureComponent { - state = { - show: false, - }; - render() { - return ( -
-
-
-
-
-
- - this.setState({ show: false }), - ariaLabel: 'Close Alert', - }} - show={this.state.show} - type="error" - /> - -
- ); - } -} diff --git a/src/legacy/Alert/examples/KitchenSink.js b/src/legacy/Alert/examples/KitchenSink.js deleted file mode 100644 index 73ab025831..0000000000 --- a/src/legacy/Alert/examples/KitchenSink.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import { Alert, AlertContainer } from '@momentum-ui/react-collaboration'; - -export default class AlertKitchenSink extends React.Component { - render() { - const types = ['success', 'warning', 'error', 'info']; - - return ( - - - {types.map((type) => ( - - ))} - - - ); - } -} diff --git a/src/legacy/Alert/examples/KitchenSink.stories.tsx b/src/legacy/Alert/examples/KitchenSink.stories.tsx deleted file mode 100644 index f0ae589b51..0000000000 --- a/src/legacy/Alert/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/Alert', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/Alert/examples/Success.js b/src/legacy/Alert/examples/Success.js deleted file mode 100644 index 9ac01b05a1..0000000000 --- a/src/legacy/Alert/examples/Success.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { Alert, AlertContainer, Button } from '@momentum-ui/react-collaboration'; -export default class AlertDefault extends React.PureComponent { - state = { - show: false, - }; - render() { - return ( -
-
-
-
-
-
- - this.setState({ show: false }), - ariaLabel: 'Close Alert', - }} - show={this.state.show} - type="success" - /> - -
- ); - } -} diff --git a/src/legacy/Alert/examples/Warning.js b/src/legacy/Alert/examples/Warning.js deleted file mode 100644 index f9fcd374dd..0000000000 --- a/src/legacy/Alert/examples/Warning.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { Alert, AlertContainer, Button } from '@momentum-ui/react-collaboration'; -export default class AlertDefault extends React.PureComponent { - state = { - show: false, - }; - render() { - return ( -
-
-
-
-
-
- - this.setState({ show: false }), - ariaLabel: 'Close Alert', - }} - show={this.state.show} - type="warning" - /> - -
- ); - } -} diff --git a/src/legacy/Alert/examples/index.js b/src/legacy/Alert/examples/index.js deleted file mode 100644 index 8ad0e66377..0000000000 --- a/src/legacy/Alert/examples/index.js +++ /dev/null @@ -1,5 +0,0 @@ -export { default as AlertDefault } from './Default'; -export { default as AlertError } from './Error'; -export { default as AlertKitchenSink } from './KitchenSink'; -export { default as AlertSuccess } from './Success'; -export { default as AlertWarning } from './Warning'; diff --git a/src/legacy/Alert/index.js b/src/legacy/Alert/index.js deleted file mode 100644 index 852a0d6808..0000000000 --- a/src/legacy/Alert/index.js +++ /dev/null @@ -1,66 +0,0 @@ -/** @component alert */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { Button, Icon } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class Alert extends React.PureComponent { - render() { - const { className, closable, dismissBtnProps, message, show, title, type, ...otherProps } = - this.props; - - return ( - show && ( -
-
-
-
{title}
-
{message}
-
- {closable && ( -
- -
- )} -
- ) - ); - } -} - -Alert.defaultProps = { - closable: true, - dismissBtnProps: null, - message: '', - title: '', - type: 'info', -}; - -Alert.propTypes = { - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop To show/hide Close button of the Alert | true */ - closable: PropTypes.bool, - /** @prop Props to be passed to dismiss button | null */ - dismissBtnProps: PropTypes.object, - /** @prop Optional Alert message | '' */ - message: PropTypes.string, - /** @prop Set Alert visibility */ - show: PropTypes.bool.isRequired, - /** @prop Optional Alert title | '' */ - title: PropTypes.string, - /** @prop Sets the type of the Alert | 'info' */ - type: PropTypes.oneOf(['info', 'success', 'warning', 'error']), -}; - -Alert.displayName = 'Alert'; - -export default Alert; diff --git a/src/legacy/Alert/tests/index.spec.js b/src/legacy/Alert/tests/index.spec.js deleted file mode 100644 index 36f0289453..0000000000 --- a/src/legacy/Alert/tests/index.spec.js +++ /dev/null @@ -1,89 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { Alert } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render one Alert', () => { - const container = mount(); - - expect(container.find('.md-alert').length).toEqual(1); - }); - - it('should pass otherProps to container', () => { - const container = mount(); - - expect(container.find('#testid').exists()).toEqual(true); - }); - - it('should pass className prop', () => { - const container = mount(); - - expect(container.find('.testing').exists()).toEqual(true); - expect(container.find('Alert').hasClass('testing')).toEqual(true); - }); - - it('should render title', () => { - const container = shallow(); - - expect(container.find('.md-alert__title').text()).toEqual('test'); - }); - - it('should render message', () => { - const container = shallow(); - - expect(container.find('.md-alert__message').text()).toEqual('test'); - }); - - it('should not display closable button if set to false', () => { - const container = mount(); - - expect(container.find('.md-button').exists()).toEqual(false); - }); - - it('should display closable button by default', () => { - const container = mount(); - - expect(container.find('.md-button').exists()).toEqual(true); - }); - - it('should pass type attribute props (success)', () => { - const container = mount(); - - expect(container.find('.md-alert').hasClass('md-alert--success')).toEqual(true); - }); - - it('should pass type attribute props (warning)', () => { - const container = mount(); - - expect(container.find('.md-alert').hasClass('md-alert--warning')).toEqual(true); - }); - - it('should pass type attribute props (error)', () => { - const container = mount(); - - expect(container.find('.md-alert').hasClass('md-alert--error')).toEqual(true); - }); - - it('should handle onHide event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - countUp(), ariaLabel: 'Close' }} /> - ); - - container.find('.md-button').simulate('click'); - expect(count).toEqual(1); - }); - - it('should pass dismissBtnProps prop', () => { - const container = mount(); - - expect(container.find('Button').props().ariaLabel).toEqual('test'); - }); -}); diff --git a/src/legacy/Alert/tests/index.spec.js.snap b/src/legacy/Alert/tests/index.spec.js.snap deleted file mode 100644 index e35337fadd..0000000000 --- a/src/legacy/Alert/tests/index.spec.js.snap +++ /dev/null @@ -1,140 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
-
-
-
-
-
-
- - - - - - -
-
- -`; diff --git a/src/legacy/AlertCall/examples/Default.js b/src/legacy/AlertCall/examples/Default.js deleted file mode 100644 index 06a432a446..0000000000 --- a/src/legacy/AlertCall/examples/Default.js +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react'; -import { AlertCall, AlertCallContainer, Button } from '@momentum-ui/react-collaboration'; -import uniqueId from 'lodash/uniqueId'; -import reject from 'lodash/reject'; -export default class AlertCallDefault extends React.PureComponent { - state = { - alertList: [], - caller: { title: 'Jefe Guadelupe', alt: '+ 1 972-555-1212' }, - devices: [ - { name: 'SJC21-Babelfish', value: '1010101', type: 'device' }, - { name: 'Use my computer', value: '2020202' }, - ], - }; - handleOnReject = (key) => { - alert(`onRejectCall ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVoice = (key) => { - alert(`onAnswerVoice ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVideo = (key) => { - alert(`onAnswerVideo ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - renderPersonCaller = () => { - const key = uniqueId('call_alert_'); - return ( - this.handleOnReject(key)} - onAnswerVoice={() => this.handleOnAnswerVoice(key)} - onAnswerVideo={() => this.handleOnAnswerVideo(key)} - onDeviceSelect={() => alert('onDeviceSelect')} - show - /> - ); - }; - render() { - return ( -
-
-
- {this.state.alertList} -
- ); - } -} diff --git a/src/legacy/AlertCall/examples/Device.js b/src/legacy/AlertCall/examples/Device.js deleted file mode 100644 index cb2ca31944..0000000000 --- a/src/legacy/AlertCall/examples/Device.js +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; -import { Button, AlertCall, AlertCallContainer } from '@momentum-ui/react-collaboration'; -import uniqueId from 'lodash/uniqueId'; -import reject from 'lodash/reject'; -export default class AlertCallDevice extends React.PureComponent { - state = { - alertList: [], - caller: { title: 'Jefe Guadelupe', alt: '+ 1 972-555-1212' }, - devices: [ - { name: 'SJC21-Babelfish', value: '1010101', type: 'device' }, - { name: 'Use my computer', value: '2020202' }, - ], - }; - handleOnReject = (key) => { - alert(`onRejectCall ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVoice = (key) => { - alert(`onAnswerVoice ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVideo = (key) => { - alert(`onAnswerVideo ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - renderDeviceCaller = () => { - const key = uniqueId('call_alert_'); - return ( - this.handleOnReject(key)} - onAnswerVoice={() => this.handleOnAnswerVoice(key)} - onAnswerVideo={() => this.handleOnAnswerVideo(key)} - onDeviceSelect={() => alert('onDeviceSelect')} - show - /> - ); - }; - render() { - return ( -
-
-
-
- {this.state.alertList} -
- ); - } -} diff --git a/src/legacy/AlertCall/examples/DeviceList.js b/src/legacy/AlertCall/examples/DeviceList.js deleted file mode 100644 index 0f320ea3e1..0000000000 --- a/src/legacy/AlertCall/examples/DeviceList.js +++ /dev/null @@ -1,68 +0,0 @@ -import React from 'react'; -import { Button, AlertCall, AlertCallContainer } from '@momentum-ui/react-collaboration'; -import uniqueId from 'lodash/uniqueId'; -import reject from 'lodash/reject'; -export default class AlertCallDeviceList extends React.PureComponent { - state = { - alertList: [], - caller: { title: 'Jefe Guadelupe', alt: '+ 1 972-555-1212' }, - devices: [ - { name: 'SJC21-Babelfish', value: '1010101', type: 'device' }, - { name: 'Use my computer', value: '2020202' }, - ], - }; - handleOnReject = (key) => { - alert(`onRejectCall ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVoice = (key) => { - alert(`onAnswerVoice ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVideo = (key) => { - alert(`onAnswerVideo ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - renderCallerWithDevices = () => { - const key = uniqueId('call_alert_'); - return ( - this.handleOnReject(key)} - onAnswerVoice={() => this.handleOnAnswerVoice(key)} - onAnswerVideo={() => this.handleOnAnswerVideo(key)} - onDeviceSelect={() => alert('onDeviceSelect')} - show - /> - ); - }; - render() { - return ( -
-
-
-
- {this.state.alertList} -
- ); - } -} diff --git a/src/legacy/AlertCall/examples/KitchenSink.js b/src/legacy/AlertCall/examples/KitchenSink.js deleted file mode 100644 index 8f74d06ac1..0000000000 --- a/src/legacy/AlertCall/examples/KitchenSink.js +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import { AlertCall, AlertCallContainer } from '@momentum-ui/react-collaboration'; - -export default class AlertCallKitchenSink extends React.Component { - state = { - devices: [ - { name: 'SJC21-Babelfish', value: '1010101', type: 'device' }, - { name: 'Use my computer', value: '2020202' }, - ], - }; - render() { - const types = ['call', 'device', 'devices', 'number']; - return ( - - - {types.map((type) => ( - {}} - onAnswerVoice={() => {}} - onAnswerVideo={() => {}} - onDeviceSelect={() => {}} - show - {...(type === 'devices' && { devices: this.state.devices })} - /> - ))} - - - ); - } -} diff --git a/src/legacy/AlertCall/examples/KitchenSink.stories.tsx b/src/legacy/AlertCall/examples/KitchenSink.stories.tsx deleted file mode 100644 index 04a214b615..0000000000 --- a/src/legacy/AlertCall/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/AlertCall', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/AlertCall/examples/Number.js b/src/legacy/AlertCall/examples/Number.js deleted file mode 100644 index 3e01b0ce0c..0000000000 --- a/src/legacy/AlertCall/examples/Number.js +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; -import { Button, AlertCall, AlertCallContainer } from '@momentum-ui/react-collaboration'; -import uniqueId from 'lodash/uniqueId'; -import reject from 'lodash/reject'; -export default class AlertCallNumber extends React.PureComponent { - state = { - alertList: [], - caller: { title: 'Jefe Guadelupe', alt: '+ 1 972-555-1212' }, - devices: [ - { name: 'SJC21-Babelfish', value: '1010101', type: 'device' }, - { name: 'Use my computer', value: '2020202' }, - ], - }; - handleOnReject = (key) => { - alert(`onRejectCall ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVoice = (key) => { - alert(`onAnswerVoice ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - handleOnAnswerVideo = (key) => { - alert(`onAnswerVideo ${key}`); - this.setState((state) => { - return { alertList: reject(state.alertList, { key }) }; - }); - }; - renderNumberOnlyCaller = () => { - const key = uniqueId('call_alert_'); - return ( - this.handleOnReject(key)} - onAnswerVoice={() => this.handleOnAnswerVoice(key)} - onAnswerVideo={() => this.handleOnAnswerVideo(key)} - onDeviceSelect={() => alert('onDeviceSelect')} - show - /> - ); - }; - render() { - return ( -
-
-
-
- {this.state.alertList} -
- ); - } -} diff --git a/src/legacy/AlertCall/examples/index.js b/src/legacy/AlertCall/examples/index.js deleted file mode 100644 index 7b86996653..0000000000 --- a/src/legacy/AlertCall/examples/index.js +++ /dev/null @@ -1,5 +0,0 @@ -export { default as AlertCallDefault } from './Default'; -export { default as AlertCallDevice } from './Device'; -export { default as AlertCallDeviceList } from './DeviceList'; -export { default as AlertCallKitchenSink } from './KitchenSink'; -export { default as AlertCallNumber } from './Number'; diff --git a/src/legacy/AlertCall/index.js b/src/legacy/AlertCall/index.js deleted file mode 100644 index 95ee0d27ec..0000000000 --- a/src/legacy/AlertCall/index.js +++ /dev/null @@ -1,216 +0,0 @@ -/** @component alert-call */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { UIDReset } from 'react-uid'; -import DeviceListCall from '../DeviceListCall'; -import { Avatar, Button, Icon } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const AlertCall = (props) => { - const { - avatar, - avatarProps, - caller, - defaultSelectedDevice, - deviceListHeader, - deviceListProps, - devices, - onAnswerShare, - onAnswerVideo, - onAnswerVoice, - onDeviceSelect, - onReject, - rejectAriaLabel, - rejectBtnProps, - shareAriaLabel, - shareBtnProps, - show, - title, - videoAriaLabel, - videoBtnProps, - voiceAriaLabel, - voiceBtnProps, - ...otherProps - } = props; - - const getAvatar = () => { - if (avatar) { - return avatar; - } else { - switch (caller.type) { - case 'number': - return ; - case 'device': - return ( - } - size="xlarge" - {...avatarProps} - /> - ); - default: - return ; - } - } - }; - - const getDeviceList = () => { - return ( - devices.length > 0 && ( - - ) - ); - }; - - return ( - show && ( -
-
{title}
-
- {getAvatar()} -
{caller.title}
-
{caller.alt}
-
- {getDeviceList()} -
- {onAnswerShare && ( - - )} - {onAnswerVideo && ( - - )} - {onAnswerVoice && ( - - )} - -
-
- ) - ); -}; - -AlertCall.defaultProps = { - avatar: null, - avatarProps: null, - caller: null, - defaultSelectedDevice: 0, - deviceListHeader: 'Device selection', - deviceListProps: null, - devices: [], - onAnswerShare: null, - onAnswerVideo: null, - onAnswerVoice: null, - onDeviceSelect: null, - onReject: null, - rejectAriaLabel: 'reject call', - rejectBtnProps: null, - shareAriaLabel: 'answer call with share', - shareBtnProps: null, - title: '', - videoAriaLabel: 'answer call with video', - videoBtnProps: null, - voiceAriaLabel: 'answer call with voice', - voiceBtnProps: null, -}; - -AlertCall.propTypes = { - /** @prop Optional avatar prop | null */ - avatar: PropTypes.node, - /** @prop Props to be passed to avatar | null */ - avatarProps: PropTypes.object, - /** @prop Required caller object */ - caller: PropTypes.shape({ - title: PropTypes.string.isRequired, - alt: PropTypes.string, - src: PropTypes.string, - type: PropTypes.oneOf(['', 'number', 'device']), - }).isRequired, - /** @prop Optional default selected device by index value or eventKey | 0 */ - defaultSelectedDevice: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - /** @prop Props to be passed to device button | null */ - deviceBtnProps: PropTypes.object, - /** @prop Optional header string for device selection list | 'Device selection' */ - deviceListHeader: PropTypes.string, - /** @prop Optional list of devices to answer call with | [] */ - devices: PropTypes.array, - /** @prop Callback function invoked when the share button is clicked | null */ - onAnswerShare: PropTypes.func, - /** @prop Callback function invoked when the video button is clicked | null */ - onAnswerVideo: PropTypes.func, - /** @prop Callback function invoked when the handset button is clicked | null */ - onAnswerVoice: PropTypes.func, - /** @prop Optional callback function when device is selected | null */ - onDeviceSelect: PropTypes.func, - /** @prop Callback function invoked when the reject button is clicked | null */ - onReject: PropTypes.func, - /** @prop Optional aria-label reject message | 'reject call' */ - rejectAriaLabel: PropTypes.string, - /** @prop Props to be passed to reject button | null */ - rejectBtnProps: PropTypes.object, - /** @prop Optional aria-label share | 'answer call with share' */ - shareAriaLabel: PropTypes.string, - /** @prop Props to be passed to share button | null */ - shareBtnProps: PropTypes.object, - /** @prop Required AlertCall visitibility setting */ - show: PropTypes.bool.isRequired, - /** @prop Optional title of AlertCall | '' */ - title: PropTypes.string, - /** @prop Optional aria-label video | 'answer call with video' */ - videoAriaLabel: PropTypes.string, - /** @prop Props to be passed to video button | null */ - videoBtnProps: PropTypes.object, - /** @prop Optional aria-label voice | 'answer call with voice only' */ - voiceAriaLabel: PropTypes.string, - /** @prop Props to be passed to voice button | null */ - voiceBtnProps: PropTypes.object, -}; - -AlertCall.displayName = 'AlertCall'; - -export default AlertCall; diff --git a/src/legacy/AlertCall/tests/index.spec.js b/src/legacy/AlertCall/tests/index.spec.js deleted file mode 100644 index f944f42ef5..0000000000 --- a/src/legacy/AlertCall/tests/index.spec.js +++ /dev/null @@ -1,285 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { AlertCall, Avatar } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - const alertTitle = 'Incoming call'; - const caller1 = { - title: 'Jefe Guadelupe', - alt: '+1 408-555-1212', - }; - - const caller2 = { - title: '+1 972-555-1212', - type: 'number', - }; - - const caller3 = { - title: 'SJC21-Babelfish', - alt: '+1 469-555-1212', - type: 'device', - }; - - const devices = [ - { name: 'SJC21-Babelfish', value: '1010101', type: 'device' }, - { name: 'Use my computer', value: '2020202' }, - ]; - - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should match SnapShot with devices', () => { - const container = mount( - - ); - - expect(container).toMatchSnapshot(); - }); - - it('should render one AlertCall', () => { - const container = mount(); - - expect(container.find('.md-alert.md-alert--call').length).toEqual(1); - }); - - it('should handle rejectAriaLabel', () => { - const container = mount( - - ); - - expect(container.find('button').last().props()['aria-label']).toEqual('rejectLabel'); - }); - - it('should handle shareAriaLabel', () => { - const container = mount( - {}} - /> - ); - - expect(container.find('button').first().props()['aria-label']).toEqual('shareAriaLabel'); - }); - - it('should handle videoAriaLabel', () => { - const container = mount( - {}} - /> - ); - - expect(container.find('button').first().props()['aria-label']).toEqual('videoAriaLabel'); - }); - - it('should handle voiceAriaLabel', () => { - const container = mount( - {}} - /> - ); - - expect(container.find('button').first().props()['aria-label']).toEqual('voiceLabel'); - }); - - it('should render meeting title', () => { - const container = shallow(); - - expect(container.find('.md-alert__title').text()).toEqual('Incoming call'); - }); - - it('should render an avatar', () => { - const container = mount(); - - expect(container.find(Avatar).length).toEqual(1); - }); - - it('should render an avatar prop', () => { - const container = mount( - } - /> - ); - - expect(container.find(Avatar).length).toEqual(1); - expect(container.find('#testid').exists()).toEqual(true); - }); - - it('should handle caller.title prop', () => { - const container = shallow(); - - expect(container.find('.md-alert__caller-title').text()).toEqual('Jefe Guadelupe'); - }); - - it('should handle caller.alt prop', () => { - const container = shallow(); - - expect(container.find('.md-alert__caller-subtitle').text()).toEqual('+1 408-555-1212'); - }); - - describe('should handle caller.type', () => { - it('should handle number', () => { - const container = mount(); - - expect(container.find('.md-avatar__letter').text()).toEqual('#'); - }); - - it('should handle device', () => { - const container = mount(); - - expect(container.find('.md-avatar__icon').length).toEqual(1); - }); - }); - - it('should render two action buttons when onAnswerVoice is passed in', () => { - const container = mount( - {}} /> - ); - - expect(container.find('.md-button').length).toEqual(2); - }); - - it('should render reject action button when nothing else is passed in', () => { - const container = mount(); - - expect(container.find('.md-button').length).toEqual(1); - }); - - it('should handle onReject event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('.md-button').last().simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle onAnswerShare event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('.md-button').first().simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle onAnswerVoice event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('.md-button').first().simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle onAnswerVideo event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('.md-button').first().simulate('click'); - expect(count).toEqual(1); - }); - - it('should pass rejectBtnProps prop', () => { - const container = mount( - - ); - - expect(container.find('Button').last().props().ariaLabel).toEqual('test'); - }); - - it('should pass shareBtnProps prop', () => { - const container = mount( - {}} - shareBtnProps={{ ariaLabel: 'test' }} - show - title={alertTitle} - /> - ); - - expect(container.find('Button').first().props().ariaLabel).toEqual('test'); - }); - - it('should pass videoBtnProps prop', () => { - const container = mount( - {}} - show - title={alertTitle} - videoBtnProps={{ ariaLabel: 'test' }} - /> - ); - - expect(container.find('Button').first().props().ariaLabel).toEqual('test'); - }); - - it('should pass voiceBtnProps prop', () => { - const container = mount( - {}} - show - title={alertTitle} - voiceBtnProps={{ ariaLabel: 'test' }} - /> - ); - - expect(container.find('Button').first().props().ariaLabel).toEqual('test'); - }); - - it('should pass avatarProps prop', () => { - const container = mount( - - ); - - expect(container.find('#testid').exists()).toEqual(true); - }); - - it('should pass deviceListProps prop', () => { - const container = mount( - - ); - - expect(container.find('#testid').exists()).toEqual(true); - }); - - it('should pass otherProps to container', () => { - const container = mount(); - - expect(container.find('#testid').exists()).toEqual(true); - }); -}); diff --git a/src/legacy/AlertCall/tests/index.spec.js.snap b/src/legacy/AlertCall/tests/index.spec.js.snap deleted file mode 100644 index f6827654ee..0000000000 --- a/src/legacy/AlertCall/tests/index.spec.js.snap +++ /dev/null @@ -1,905 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
-
- Incoming call -
-
- -
- - JG - -
-
-
- Jefe Guadelupe -
-
- +1 408-555-1212 -
-
- -
- - - - - - -
-
-
-`; - -exports[`tests for should match SnapShot with devices 1`] = ` - -
-
- Incoming call -
-
- -
- - JG - -
-
-
- Jefe Guadelupe -
-
- +1 408-555-1212 -
-
- - - -
- - - - - -
- -
-
- Device selection -
-
-
- -
- -
- - - - - - - - - - - -
- -
- - - -
-
- -
-
- SJC21-Babelfish -
-
-
- -
- - - -
-
-
-
-
-
-
-
-
- - - - - - -
- -
- - - -
-
- -
-
- Use my computer -
-
-
- -
- -
- - - - - - -
- - -
-
- - - - - - -
-
- -`; diff --git a/src/legacy/AlertCallContainer/index.js b/src/legacy/AlertCallContainer/index.js deleted file mode 100644 index 4eaecfe07c..0000000000 --- a/src/legacy/AlertCallContainer/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** @component alert-call */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const AlertCallContainer = (props) => { - const { children, ...otherProps } = props; - - return ( -
- {children} -
- ); -}; - -AlertCallContainer.defaultProps = { - children: null, -}; - -AlertCallContainer.propTypes = { - /** @prop Children Nodes to Render inside container | null */ - children: PropTypes.node, -}; - -AlertCallContainer.displayName = 'AlertCallContainer'; - -export default AlertCallContainer; diff --git a/src/legacy/AlertCallContainer/tests/index.spec.js b/src/legacy/AlertCallContainer/tests/index.spec.js deleted file mode 100644 index 666a62dacd..0000000000 --- a/src/legacy/AlertCallContainer/tests/index.spec.js +++ /dev/null @@ -1,83 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { AlertCall, AlertCallContainer } from '@momentum-ui/react-collaboration'; -import uniqueId from 'lodash/uniqueId'; - -describe('tests for ', () => { - const alertTitle = 'Incoming call'; - const caller1 = { - title: 'Jefe Guadelupe', - alt: '+1 408-555-1212', - }; - - const caller2 = { - title: '+1 972-555-1212', - type: 'number', - }; - - /* eslint-disable react/no-multi-comp */ - - function renderCaller1() { - const key = uniqueId('call_alert_'); - return ( - {}} - onAnswerVoice={() => {}} - onAnswerVideo={() => {}} - onDeviceSelect={() => {}} - show - /> - ); - } - - function renderCaller2() { - const key = uniqueId('call_alert_'); - return ( - {}} - onAnswerVoice={() => {}} - onAnswerVideo={() => {}} - onDeviceSelect={() => {}} - show - /> - ); - } - - /* eslint-enable react/no-multi-comp */ - - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render a div', () => { - const container = shallow(); - - expect(container.find('.md-alert__container--call').length).toEqual(1); - }); - - it('should not render any call alerts if the alertList is empty', () => { - const container = mount(); - expect(container.find(AlertCall).length).toEqual(0); - }); - - it('should render no more than two call alerts at the same time', () => { - const alertList = [renderCaller1(), renderCaller2()]; - const container = mount(); - - expect(container.find(AlertCall).length).toEqual(2); - }); - - it('should pass otherProps to container', () => { - const container = shallow(); - - expect(container.find('#testid').exists()).toEqual(true); - }); -}); diff --git a/src/legacy/AlertCallContainer/tests/index.spec.js.snap b/src/legacy/AlertCallContainer/tests/index.spec.js.snap deleted file mode 100644 index 61116102dc..0000000000 --- a/src/legacy/AlertCallContainer/tests/index.spec.js.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
- -`; diff --git a/src/legacy/AlertContainer/tests/index.spec.js b/src/legacy/AlertContainer/tests/index.spec.js index 85d86f0290..bb1bb6b6ba 100644 --- a/src/legacy/AlertContainer/tests/index.spec.js +++ b/src/legacy/AlertContainer/tests/index.spec.js @@ -1,6 +1,6 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Alert, AlertContainer } from '@momentum-ui/react-collaboration'; +import { AlertContainer } from '@momentum-ui/react-collaboration'; describe('tests for ', () => { const alertTitle = 'Now Hear This!'; @@ -76,64 +76,6 @@ describe('tests for ', () => { expect(container.find('.md-alert__container--bottom-right').length).toEqual(1); }); - it('should render an info Alert when info() is called', () => { - const container = mount( - - - - ); - container.update(); - expect(container.find('.md-alert--info').length).toEqual(1); - }); - - it('should render a success Alert when success() is called', () => { - const container = mount( - - - - ); - - container.update(); - expect(container.find('.md-alert--success').length).toEqual(1); - }); - - it('should render a warning Alert when warning() is called', () => { - const container = mount( - - - - ); - container.update(); - expect(container.find('.md-alert--warning').length).toEqual(1); - }); - - it('should render an error Alert when error() is called', () => { - const container = mount( - - - - ); - container.update(); - expect(container.find('.md-alert--error').length).toEqual(1); - }); - - it('should pass any other HTML props to Alert', () => { - const container = mount( - - {} }} - /> - - ); - - container.update(); - expect(container.find('button').props().id).toEqual('testProp'); - }); - it('should pass otherProps to container', () => { const container = shallow(); diff --git a/src/legacy/AlertMeeting/examples/Default.js b/src/legacy/AlertMeeting/examples/Default.js deleted file mode 100644 index e88bb728ac..0000000000 --- a/src/legacy/AlertMeeting/examples/Default.js +++ /dev/null @@ -1,47 +0,0 @@ -/** @component alert-meeting */ - -import React from 'react'; -import { Button, AlertMeeting, AlertContainer } from '@momentum-ui/react-collaboration'; - -export default class Default extends React.PureComponent { - state = { - show: false, - }; - - handleOnHide = () => { - this.setState({ show: false }); - }; - - handleOnSnooze = () => { - this.setState({ show: false }); - }; - - render() { - return ( -
-
-
-
-
- - - -
-
- ); - } -} diff --git a/src/legacy/AlertMeeting/examples/KitchenSink.js b/src/legacy/AlertMeeting/examples/KitchenSink.js deleted file mode 100644 index 3fe0371835..0000000000 --- a/src/legacy/AlertMeeting/examples/KitchenSink.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { AlertMeeting, AlertContainer } from '@momentum-ui/react-collaboration'; - -export default class AlertMeetingKitchenSink extends React.Component { - render() { - const types = ['single', 'multiple']; - return ( - - - {types.map((type) => ( - - ))} - - - ); - } -} diff --git a/src/legacy/AlertMeeting/examples/KitchenSink.stories.tsx b/src/legacy/AlertMeeting/examples/KitchenSink.stories.tsx deleted file mode 100644 index 72fc257610..0000000000 --- a/src/legacy/AlertMeeting/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/AlertMeeting', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/AlertMeeting/examples/Multiple.js b/src/legacy/AlertMeeting/examples/Multiple.js deleted file mode 100644 index 4e100e79c9..0000000000 --- a/src/legacy/AlertMeeting/examples/Multiple.js +++ /dev/null @@ -1,47 +0,0 @@ -/** @component alert-meeting */ - -import React from 'react'; -import { Button, AlertMeeting, AlertContainer } from '@momentum-ui/react-collaboration'; - -export default class Default extends React.PureComponent { - state = { - show: false, - }; - - handleOnHide = () => { - this.setState({ show: false }); - }; - - handleOnSnooze = () => { - this.setState({ show: false }); - }; - - render() { - return ( -
-
-
-
-
- - - -
-
- ); - } -} diff --git a/src/legacy/AlertMeeting/examples/index.js b/src/legacy/AlertMeeting/examples/index.js deleted file mode 100644 index f008662b14..0000000000 --- a/src/legacy/AlertMeeting/examples/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as AlertMeetingDefault } from './Default'; -export { default as AlertMeetingKitchenSink } from './KitchenSink'; -export { default as AlertMeetingMultiple } from './Multiple'; diff --git a/src/legacy/AlertMeeting/index.js b/src/legacy/AlertMeeting/index.js deleted file mode 100644 index ebcc167f52..0000000000 --- a/src/legacy/AlertMeeting/index.js +++ /dev/null @@ -1,177 +0,0 @@ -/** @component meeting-alert */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { Avatar, CompositeAvatar, Button, Icon } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const AlertMeeting = (props) => { - const { - attendees, - avatar, - className, - closeAriaLabel, - closeBtnProps, - message, - onClick, - onKeyDown, - onHide, - onSnooze, - remindAriaLabel, - show, - snoozeBtnProps, - status, - title, - ...otherProps - } = props; - - const renderAvatar = () => { - if (avatar) { - return avatar; - } else { - if (attendees.length >= 2) { - return ( - - - - - ); - } else if (attendees.length === 1) { - return ( - - ); - } else { - throw new Error('AlertMeeting needs at least one attendee to render an avatar.'); - } - } - }; - - const handleKeyDown = (e) => { - if (e.which === 32 || e.which === 13 || e.charCode === 32 || e.charCode === 13) { - onClick && onClick(e); - e.preventDefault(); - } - - onKeyDown && onKeyDown(e); - }; - - return ( - show && ( -
handleKeyDown(e), - role: 'button', - })} - {...otherProps} - > - {renderAvatar()} -
-
- {title} -
-
{status}
-
- {message} -
-
- {onSnooze && ( -
- -
- )} -
- -
-
- ) - ); -}; - -AlertMeeting.defaultProps = { - attendees: [], - avatar: null, - className: '', - closeAriaLabel: 'close', - closeBtnProps: null, - message: '', - onClick: null, - onKeyDown: null, - onHide: null, - onSnooze: null, - remindAriaLabel: 'snooze', - snoozeBtnProps: null, - status: '', - title: '', -}; - -AlertMeeting.propTypes = { - /** @prop Optional avatar prop | null */ - avatar: PropTypes.node, - /** @prop Optional attendee array. If more than one attendee, a Composite Avatar with only the first 2 attendees is created. | null */ - attendees: PropTypes.arrayOf( - PropTypes.shape({ - title: PropTypes.string.isRequired, - alt: PropTypes.string, - src: PropTypes.string, - }) - ), - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Optional aria label for the close button | 'close' */ - closeAriaLabel: PropTypes.string, - /** @prop Props to be passed to close button | null */ - closeBtnProps: PropTypes.object, - /** @prop Optional callback function invoked on click of alert | null */ - onClick: PropTypes.func, - /** @prop Optional callback function invoked on keydown on alert | null */ - onKeyDown: PropTypes.func, - /** @prop Mandatory handler invoked when the user presses on the Alert's close button or hit's the esc key | null */ - onHide: PropTypes.func, - /** @prop Optional callback function invoked when the snooze button is clicked | null */ - onSnooze: PropTypes.func, - /** @prop Optional AlertMeeting Message | '' */ - message: PropTypes.string, - /** @prop Optional aria label for snooze buton | 'snooze' */ - remindAriaLabel: PropTypes.string, - /** @prop Set AlertMeeting visibility */ - show: PropTypes.bool.isRequired, - /** @prop Props to be passed to snooze button | null */ - snoozeBtnProps: PropTypes.object, - /** @prop Optional AlertMeeting status | '' */ - status: PropTypes.string, - /** @prop Optional AlertMeeting title | '' */ - title: PropTypes.string, -}; - -AlertMeeting.displayName = 'AlertMeeting'; - -export default AlertMeeting; diff --git a/src/legacy/AlertMeeting/tests/index.spec.js b/src/legacy/AlertMeeting/tests/index.spec.js deleted file mode 100644 index 326783f7e0..0000000000 --- a/src/legacy/AlertMeeting/tests/index.spec.js +++ /dev/null @@ -1,233 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import AlertMeeting from '../index'; -import { Avatar, CompositeAvatar } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - const attendeeOne = { title: 'J $', props: { id: 'testid' } }; - const attendeeTwo = { title: 'Hee Haw', props: { id: 'testid2' } }; - const attendeeThree = { title: 'Hollywood Squarepants' }; - - const attendeeListOne = [attendeeOne]; - const attendeeListTwo = [attendeeOne, attendeeTwo]; - const attendeeListThree = [attendeeOne, attendeeTwo, attendeeThree]; - - it('should match SnapShot', () => { - const container = mount( {}} />); - - expect(container).toMatchSnapshot(); - }); - - it('should render one AlertMeeting', () => { - const container = mount(); - - expect(container.find('.md-alert.md-alert--meeting').length).toEqual(1); - }); - - it('should pass className prop', () => { - const container = mount(); - - expect(container.find('.testing').exists()).toEqual(true); - expect(container.find('AlertMeeting').hasClass('testing')).toEqual(true); - }); - - it('should render meeting title', () => { - const container = shallow( - - ); - - expect(container.find('.md-alert__title').text()).toEqual('Super Important Meeting'); - }); - - it('should render meeting status', () => { - const container = shallow(); - - expect(container.find('.md-alert__status').text()).toEqual('Now'); - }); - - it('should render meeting message', () => { - const container = shallow( - - ); - - expect(container.find('.md-alert__message').text()).toEqual('Attendance Required'); - }); - - it('should render an avatar', () => { - const container = mount(); - - expect(container.find(Avatar).length).toEqual(1); - }); - - it('should only render a close button when onSnooze is not passed in', () => { - const container = mount(); - - expect(container.find('.md-button').length).toEqual(1); - }); - - it('should render snooze button when onSnooze is passed in', () => { - const container = mount( {}} />); - - expect(container.find('.md-button').length).toEqual(2); - }); - - it('should handle snooze aria-label when remindAriaLabel is passed in', () => { - const container = mount( - {}} - remindAriaLabel="testSnooze" - /> - ); - - expect(container.find('button').first().props()['aria-label']).toEqual('testSnooze'); - }); - - it('should handle snooze aria-label when closeAriaLabel is passed in', () => { - const container = mount( - - ); - - expect(container.find('button').last().props()['aria-label']).toEqual('testClose'); - }); - - it('should use md-alert__content class when onSnooze is passed in', () => { - const container = mount( {}} />); - - expect(container.find('.md-alert__content').length).toEqual(1); - expect(container.find('.md-alert__content--wide').length).toEqual(0); - }); - - it('should use md-alert__content--wide class when onSnooze is not passed in', () => { - const container = mount(); - - expect(container.find('.md-alert__content').length).toEqual(1); - expect(container.find('.md-alert__content--wide').length).toEqual(1); - }); - - it('should render a composite avatar when attendee list is greater than 1', () => { - const container = mount(); - - expect(container.find(CompositeAvatar).length).toEqual(1); - expect(container.find(Avatar).length).toEqual(2); - }); - - it('should render a composite avatar with only 2 avatars when attendee list is greater than 2', () => { - const container = mount(); - - expect(container.find(CompositeAvatar).length).toEqual(1); - expect(container.find(Avatar).length).toEqual(2); - }); - - it('should handle onClick event', () => { - let count = 0; - const countUp = () => count++; - const container = mount(); - - container.find('.md-alert').first().simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle keyDown event with onClick (Enter)', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('.md-alert').first().simulate('keyDown', { which: 32 }); - expect(count).toEqual(1); - container.find('.md-alert').first().simulate('keyDown', { charCode: 32 }); - expect(count).toEqual(2); - }); - - it('should handle keyDown event with onClick (Space)', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('.md-alert').first().simulate('keyDown', { which: 13 }); - expect(count).toEqual(1); - container.find('.md-alert').first().simulate('keyDown', { charCode: 13 }); - expect(count).toEqual(2); - }); - - it('should handle onKeyDown event', () => { - let count = 0; - const countUp = () => count++; - const container = mount(); - - container.find('.md-alert').first().simulate('keyDown', { which: 100 }); - expect(count).toEqual(1); - }); - - it('should handle onSnooze event', () => { - let count = 0; - const countUp = () => count++; - const container = mount(); - - container.find('.md-button').first().simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle onHide event', () => { - let count = 0; - const countUp = () => count++; - const container = mount(); - - container.find('.md-button').last().simulate('click'); - expect(count).toEqual(1); - }); - - it('should pass snoozeBtnProps prop', () => { - const container = mount( - {}} - show - snoozeBtnProps={{ ariaLabel: 'test' }} - /> - ); - - expect(container.find('Button').first().props().ariaLabel).toEqual('test'); - }); - - it('should pass closeBtnProps prop', () => { - const container = mount( - - ); - - expect(container.find('Button').last().props().ariaLabel).toEqual('test'); - }); - - it('should pass avatar props when single attendee', () => { - const container = mount(); - - expect(container.find('#testid').exists()).toEqual(true); - }); - - it('should pass avatar props with multiple attendees', () => { - const container = mount(); - - expect(container.find('#testid').exists()).toEqual(true); - expect(container.find('#testid2').exists()).toEqual(true); - }); - - it('should render an avatar prop', () => { - const container = mount(} show />); - - expect(container.find(Avatar).length).toEqual(1); - expect(container.find('#testid').exists()).toEqual(true); - }); - - it('should throw error if no attendees or avatar prop', () => { - try { - shallow(); - } catch (e) { - expect(e.message).toEqual('AlertMeeting needs at least one attendee to render an avatar.'); - } - }); -}); diff --git a/src/legacy/AlertMeeting/tests/index.spec.js.snap b/src/legacy/AlertMeeting/tests/index.spec.js.snap deleted file mode 100644 index 4437f2fb6a..0000000000 --- a/src/legacy/AlertMeeting/tests/index.spec.js.snap +++ /dev/null @@ -1,314 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
- -
- - J$ - -
-
-
-
-
-
-
-
- - - - - - -
-
- - - - - - -
-
- -`; diff --git a/src/legacy/Avatar/examples/Composite.js b/src/legacy/Avatar/examples/Composite.js deleted file mode 100644 index bccb029c47..0000000000 --- a/src/legacy/Avatar/examples/Composite.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { Avatar, CompositeAvatar } from '@momentum-ui/react-collaboration'; -export default class AvatarComposite extends React.PureComponent { - render() { - return ( - - - - - ); - } -} diff --git a/src/legacy/Avatar/examples/index.js b/src/legacy/Avatar/examples/index.js index 585ed530e5..1d765cbc1d 100644 --- a/src/legacy/Avatar/examples/index.js +++ b/src/legacy/Avatar/examples/index.js @@ -1,6 +1,5 @@ export { default as AvatarActive } from './Active'; export { default as AvatarBot } from './Bot'; -export { default as AvatarComposite } from './Composite'; export { default as AvatarDefault } from './Default'; export { default as AvatarFailure } from './Failure'; export { default as AvatarGroup } from './Group'; diff --git a/src/legacy/Breadcrumbs/examples/Default.js b/src/legacy/Breadcrumbs/examples/Default.js deleted file mode 100644 index eb8473deb7..0000000000 --- a/src/legacy/Breadcrumbs/examples/Default.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { Breadcrumbs } from '@momentum-ui/react-collaboration'; - -export default function DefaultBreadCrumbs() { - return ( -
-
- -
  • Default
  • -
    -
    -
    - -
  • Default
  • -
  • Default2
  • -
    -
    -
    - -
  • Default
  • -
  • Default2
  • -
  • Default3
  • -
    -
    -
    - ); -} diff --git a/src/legacy/Breadcrumbs/examples/KitchenSink.js b/src/legacy/Breadcrumbs/examples/KitchenSink.js deleted file mode 100644 index 05406dd07d..0000000000 --- a/src/legacy/Breadcrumbs/examples/KitchenSink.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { BreadcrumbsDefault } from './index'; - -export default class BreadcrumbsKitchenSink extends React.Component { - render() { - return ( - - - - ); - } -} diff --git a/src/legacy/Breadcrumbs/examples/KitchenSink.stories.tsx b/src/legacy/Breadcrumbs/examples/KitchenSink.stories.tsx deleted file mode 100644 index a596279c72..0000000000 --- a/src/legacy/Breadcrumbs/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/Breadcrumbs', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/Breadcrumbs/examples/index.js b/src/legacy/Breadcrumbs/examples/index.js deleted file mode 100644 index b18d7fbea6..0000000000 --- a/src/legacy/Breadcrumbs/examples/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as BreadcrumbsDefault } from './Default'; -export { default as BreadcrumbsKitchenSink } from './KitchenSink'; diff --git a/src/legacy/Breadcrumbs/index.js b/src/legacy/Breadcrumbs/index.js deleted file mode 100644 index e2a8417efd..0000000000 --- a/src/legacy/Breadcrumbs/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** @component breadcrumbs */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class Breadcrumbs extends React.PureComponent { - static displayName = 'Breadcrumbs'; - - static propTypes = { - /** @prop Children nodes to render inside Breadcrumbs | null */ - children: PropTypes.node, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - }; - - static defaultProps = { - children: null, - className: '', - }; - - render() { - const { className, children } = this.props; - - const items = React.Children.map(children, (child, idx) => { - if (children.length - 1 === idx || !children.length) { - return React.cloneElement(child, { className: 'current' }); - } - - return child; - }); - - return
      {items}
    ; - } -} - -export default Breadcrumbs; diff --git a/src/legacy/Breadcrumbs/tests/index.spec.js b/src/legacy/Breadcrumbs/tests/index.spec.js deleted file mode 100644 index a42e54c707..0000000000 --- a/src/legacy/Breadcrumbs/tests/index.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { Breadcrumbs } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render one UL', () => { - const container = shallow(); - - expect(container.find('ul').length).toEqual(1); - }); - - it('should render one Child Div', () => { - const container = shallow( - -
    Test
    -
    - ); - - expect(container.find('ul').children().length).toEqual(1); - }); - - it('should assign conditional outlined class name', () => { - const container = shallow(); - - expect(container.find('ul').hasClass('test')).toEqual(true); - }); -}); diff --git a/src/legacy/Breadcrumbs/tests/index.spec.js.snap b/src/legacy/Breadcrumbs/tests/index.spec.js.snap deleted file mode 100644 index 9059250514..0000000000 --- a/src/legacy/Breadcrumbs/tests/index.spec.js.snap +++ /dev/null @@ -1,11 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
      - -`; diff --git a/src/legacy/CallControl/examples/Active.js b/src/legacy/CallControl/examples/Active.js deleted file mode 100644 index a77a40175c..0000000000 --- a/src/legacy/CallControl/examples/Active.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { CallControl } from '@momentum-ui/react-collaboration'; -export default function CallControlActive() { - return ( - {}} ariaLabel="Mute microphone" /> - ); -} diff --git a/src/legacy/CallControl/examples/Cancel.js b/src/legacy/CallControl/examples/Cancel.js deleted file mode 100644 index 8bfcf1543c..0000000000 --- a/src/legacy/CallControl/examples/Cancel.js +++ /dev/null @@ -1,5 +0,0 @@ -import React from 'react'; -import { CallControl } from '@momentum-ui/react-collaboration'; -export default function CallControlCancel() { - return {}} ariaLabel="Cancel" />; -} diff --git a/src/legacy/CallControl/examples/Default.js b/src/legacy/CallControl/examples/Default.js deleted file mode 100644 index 82adf8adb6..0000000000 --- a/src/legacy/CallControl/examples/Default.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { CallControl } from '@momentum-ui/react-collaboration'; -export default function CallControlDefault() { - return ( -
      -
      - -
      -
      - -
      -
      - -
      -
      - ); -} diff --git a/src/legacy/CallControl/examples/Disable.js b/src/legacy/CallControl/examples/Disable.js deleted file mode 100644 index c8455ecd94..0000000000 --- a/src/legacy/CallControl/examples/Disable.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { CallControl } from '@momentum-ui/react-collaboration'; -export default function CallControlDisabled() { - return ( - {}} ariaLabel="Mute microphone" /> - ); -} diff --git a/src/legacy/CallControl/examples/KitchenSink.js b/src/legacy/CallControl/examples/KitchenSink.js deleted file mode 100644 index 75b11fa287..0000000000 --- a/src/legacy/CallControl/examples/KitchenSink.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { - CallControlActive, - CallControlCancel, - CallControlDefault, - CallControlDisable, -} from './index'; - -export default class CallControlKitchenSink extends React.Component { - render() { - return ( - - - - - - - ); - } -} diff --git a/src/legacy/CallControl/examples/KitchenSink.stories.tsx b/src/legacy/CallControl/examples/KitchenSink.stories.tsx deleted file mode 100644 index 2f20ca1d92..0000000000 --- a/src/legacy/CallControl/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/CallControl', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/CallControl/examples/index.js b/src/legacy/CallControl/examples/index.js deleted file mode 100644 index 50092d0b91..0000000000 --- a/src/legacy/CallControl/examples/index.js +++ /dev/null @@ -1,5 +0,0 @@ -export { default as CallControlActive } from './Active'; -export { default as CallControlCancel } from './Cancel'; -export { default as CallControlDefault } from './Default'; -export { default as CallControlDisable } from './Disable'; -export { default as CallControlKitchenSink } from './KitchenSink'; diff --git a/src/legacy/CallControl/index.js b/src/legacy/CallControl/index.js deleted file mode 100644 index 005e5abb9e..0000000000 --- a/src/legacy/CallControl/index.js +++ /dev/null @@ -1,104 +0,0 @@ -/** @component call-control */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { Button, Icon } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class CallControl extends React.PureComponent { - render() { - const { - active, - ariaLabel, - className, - disabled, - iconColor, - iconSize, - onClick, - type, - ...otherHTMLProps - } = this.props; - - const activeRed = ['camera-muted', 'cancel', 'microphone-muted', 'speaker']; - - const activeBlue = ['camera', 'participant-list', 'share-screen']; - - const getActiveColor = () => { - switch (true) { - case activeRed.includes(type): - return 'red'; - case activeBlue.includes(type): - return 'blue'; - default: - return 'dark-gray'; - } - }; - - const getColor = () => (active ? getActiveColor() : 'dark-gray'); - - return ( - - ); - } -} - -CallControl.propTypes = { - /** @prop Sets active css styling | false */ - active: PropTypes.bool, - /** @prop Text to display for blindness accessibility features | '' */ - ariaLabel: PropTypes.string, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Sets the attribute disabled to the CallControl button | false */ - disabled: PropTypes.bool, - /** @prop Optional icon color prop | $md-white-100 */ - iconColor: PropTypes.string, - /** @prop Optional numeric icon size prop | 24 */ - iconSize: PropTypes.number, - /** @prop Handler to be called when the user taps the CallControl button | null */ - onClick: PropTypes.func, - /** @prop Optional numeric size prop for CallControl button | 56 */ - size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - /** @prop Optional predefined CallControl prop type | '' */ - type: PropTypes.oneOf([ - 'activities', - 'camera', - 'camera-muted', - 'cancel', - 'handset', - 'microphone-muted', - 'more', - 'participant-list', - 'share-screen', - 'speaker', - 'view-list', - ]), -}; - -CallControl.defaultProps = { - active: false, - ariaLabel: '', - className: '', - disabled: false, - iconColor: 'white-100', - iconSize: 24, - onClick: null, - size: 56, - type: '', -}; - -CallControl.displayName = 'CallControl'; - -export default CallControl; diff --git a/src/legacy/CallControl/tests/index.spec.js b/src/legacy/CallControl/tests/index.spec.js deleted file mode 100644 index 7d18cad0c7..0000000000 --- a/src/legacy/CallControl/tests/index.spec.js +++ /dev/null @@ -1,137 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { CallControl } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render one Call Control button', () => { - const container = mount(); - - expect(container.find('Button').length).toEqual(1); - }); - - it('should handle disabled state', () => { - const container = shallow(); - - expect(container.props().disabled).toEqual(true); - }); - - it('should handle onClick event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('Button').simulate('click'); - expect(count).toEqual(1); - }); - - it('should handle keyDown as onClick event', () => { - let count = 0; - const countUp = () => count++; - const container = mount( - - ); - - container.find('Button').simulate('click'); - container.find('Button').simulate('keyDown', { which: 13, charCode: 13, key: 'Space' }); - expect(count).toEqual(2); - }); - - describe('tests for type prop', () => { - it('should render activities type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('activities_24'); - }); - - it('should render camera type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('camera_24'); - }); - - it('should render camera-muted type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('camera-muted_24'); - }); - - it('should render cancel type', () => { - const container = mount(); - - expect(container.find('button').hasClass('md-button--red')).toEqual(true); - expect(container.find('Icon').props().name).toEqual('cancel_24'); - }); - - it('should render handset type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('handset_24'); - }); - - it('should render microphone-muted type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('microphone-muted_24'); - }); - - it('should render more type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('more_24'); - }); - - it('should render participant-list type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('participant-list_24'); - }); - - it('should render share-screen type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('share-screen_24'); - }); - - it('should render speaker type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('speaker_24'); - }); - - it('should render more type', () => { - const container = mount(); - - expect(container.find('Icon').props().name).toEqual('more_24'); - }); - }); - - it('should handle iconSize of 20', () => { - const container = mount(); - - const iEle = container.find('i'); - expect(iEle.getDOMNode().style.fontSize).toEqual('10px'); - }); - - it('should handle iconSize of 40', () => { - const container = mount(); - - const iEle = container.find('i'); - expect(iEle.getDOMNode().style.fontSize).toEqual('16px'); - }); - - it('should handle iconColor prop', () => { - const container = mount( - - ); - - expect(container.find('Icon').props().color).toEqual('green-50'); - }); -}); diff --git a/src/legacy/CallControl/tests/index.spec.js.snap b/src/legacy/CallControl/tests/index.spec.js.snap deleted file mode 100644 index 993d4342f2..0000000000 --- a/src/legacy/CallControl/tests/index.spec.js.snap +++ /dev/null @@ -1,128 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - - - - - - - - -`; diff --git a/src/legacy/Card/examples/Clickable.js b/src/legacy/Card/examples/Clickable.js deleted file mode 100644 index bd231c3198..0000000000 --- a/src/legacy/Card/examples/Clickable.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { Avatar, Button, Card, CardSection, Link } from '@momentum-ui/react-collaboration'; -export default function CardClickable() { - return ( - {}} style={{ width: '300px' }}> - - -
      -

      Clickable

      -
      Subtitle
      -
      -
      - - placeholder - - - Et netus et malesuada fames ac turpis egestas macecenas. Adipisccing at in tellus integer. - - - - {' '} - Link Text{' '} - - - - ); - } -} diff --git a/src/legacy/Coachmark/examples/Default.js b/src/legacy/Coachmark/examples/Default.js deleted file mode 100644 index ab8db8034c..0000000000 --- a/src/legacy/Coachmark/examples/Default.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import { Button, Coachmark } from '@momentum-ui/react-collaboration'; - -export default class CoachmarkDefault extends React.Component { - state = { - isOpen: true, - }; - - render() { - const { isOpen } = this.state; - - return ( - - - - ); - } -} diff --git a/src/legacy/Coachmark/examples/KitchenSink.js b/src/legacy/Coachmark/examples/KitchenSink.js deleted file mode 100644 index 0545000aef..0000000000 --- a/src/legacy/Coachmark/examples/KitchenSink.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { CoachmarkContent, CoachmarkDefault } from './index'; - -export default class CoachmarkKitchenSink extends React.Component { - render() { - return ( - -
      - -
      -
      - -
      -
      - ); - } -} diff --git a/src/legacy/Coachmark/examples/KitchenSink.stories.tsx b/src/legacy/Coachmark/examples/KitchenSink.stories.tsx deleted file mode 100644 index 34a8561c44..0000000000 --- a/src/legacy/Coachmark/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/Coachmark', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/Coachmark/examples/index.js b/src/legacy/Coachmark/examples/index.js deleted file mode 100644 index f79efc5e82..0000000000 --- a/src/legacy/Coachmark/examples/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as CoachmarkDefault } from './Default'; -export { default as CoachmarkContent } from './Content'; -export { default as CoachmarkKitchenSink } from './KitchenSink'; diff --git a/src/legacy/Coachmark/index.js b/src/legacy/Coachmark/index.js deleted file mode 100644 index 20439ab31e..0000000000 --- a/src/legacy/Coachmark/index.js +++ /dev/null @@ -1,213 +0,0 @@ -/** @component coachmark */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import omit from 'lodash/omit'; -import { EventOverlay, Button } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class Coachmark extends React.Component { - static displayName = 'Coachmark'; - - state = { - isOpen: this.props.isOpen || false, - }; - - componentDidMount() { - this.props.isOpen && this.forceUpdate(); - } - - componentDidUpdate(prevProps) { - if (prevProps.isOpen !== this.props.isOpen) { - return this.props.isOpen ? this.delayedShow() : this.delayedHide(); - } - } - - componentWillUnmount() { - this.hideTimerId && clearTimeout(this.hideTimerId); - this.showTimerId && clearTimeout(this.showTimerId); - } - - delayedHide = (e) => { - const { onClick, onClose } = this.props; - - if (this.showTimerId) { - clearTimeout(this.showTimerId); - this.showTimerId = null; - } - - const delay = this.props.hideDelay ? this.props.hideDelay : this.props.delay; - - this.hideTimerId = setTimeout(() => { - this.hideTimerId = null; - this.setState(() => { - onClick && onClick(e); - onClose && onClose(e); - return { isOpen: false }; - }); - }, delay); - }; - - delayedShow = () => { - if (this.hideTimerId) { - clearTimeout(this.hideTimerId); - this.hideTimerId = null; - } - - const delay = this.props.showDelay ? this.props.showDelay : this.props.delay; - - this.showTimerId = setTimeout(() => { - this.showTimerId = null; - this.setState({ isOpen: true }); - }, delay); - }; - - handleClose = () => { - this.setState( - () => ({ - isOpen: false, - }), - this.delayedHide() - ); - }; - - render() { - const { - allowClickAway, - buttonProps, - className, - children, - closeOnClick, - contentNode, - direction, - header, - maxWidth, - onClick, - subheader, - ...props - } = this.props; - const { isOpen } = this.state; - - const otherProps = omit({ ...props }, ['delay', 'hideDelay', 'isOpen', 'onClose', 'showDelay']); - - const anchorWithRef = () => - children && - React.cloneElement(children, { - ref: (ele) => (this.anchorRef = ele), - ...otherProps, - }); - - const content = ( -
      - {contentNode - ? contentNode - : [ - header && ( -
      - {header} -
      - ), - subheader && ( -
      - {subheader} -
      - ), - onClick &&
      - ); - - return ( - - {anchorWithRef()} - {isOpen && ( - (this.overlay = ref)} - allowClickAway={allowClickAway} - anchorNode={this.anchorRef} - isOpen={isOpen} - className={'md-coachmark' + `${(className && ` ${className}`) || ''}`} - showArrow - direction={direction} - close={this.handleClose} - closeOnClick={closeOnClick} - {...(maxWidth && { maxWidth: maxWidth })} - > - {content} - - )} - - ); - } -} - -Coachmark.defaultProps = { - allowClickAway: false, - buttonProps: {}, - children: null, - className: '', - closeOnClick: false, - contentNode: null, - delay: 0, - direction: 'top-center', - header: '', - hideDelay: 0, - isOpen: false, - maxWidth: null, - onClick: null, - onClose: null, - showDelay: 0, - subheader: '', -}; - -Coachmark.propTypes = { - /** @prop Allows user to click outside of element | false */ - allowClickAway: PropTypes.bool, - /** @prop Button props within Coachmark | {} */ - buttonProps: PropTypes.object, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Children nodes to render inside Coachmark | null */ - children: PropTypes.node.isRequired, - /** @prop Allows Coachmark to be closed by a click from the user | false */ - closeOnClick: PropTypes.bool, - /** @prop Node with content that populates the Coachmark | null */ - contentNode: PropTypes.node, - /** @prop Sets the time the timer is delayed | 0 */ - delay: PropTypes.number, - /** @prop Sets the direction the Coachmark opens up | 'top-center' */ - direction: PropTypes.oneOf([ - 'top-center', - 'top-left', - 'top-right', - 'left-center', - 'left-top', - 'left-bottom', - 'bottom-center', - 'bottom-left', - 'bottom-right', - 'right-center', - 'right-top', - 'right-bottom', - ]), - /** @prop Sets the header node of Coachmark | '' */ - header: PropTypes.node, - /** @prop Sets the time delay to hide the Coachmark | 0 */ - hideDelay: PropTypes.number, - /** @prop Sets the initial visibility of Coachmark | false */ - isOpen: PropTypes.bool, - /** @prop Sets the maximum width of Coachmark | null */ - maxWidth: PropTypes.number, - /** @prop Handler to be called when the user clicks the Coachmark | null */ - onClick: PropTypes.func, - /** @prop Handler to be called when Coachmark is closed, should be provided when allowClickAway is true | null */ - onClose: PropTypes.func, - /** @prop Shows visibility of the delay value | 0 */ - showDelay: PropTypes.number, - /** @prop Sets the subheader node of the Coachmark | '' */ - subheader: PropTypes.node, -}; - -export default Coachmark; diff --git a/src/legacy/Coachmark/tests/index.spec.js b/src/legacy/Coachmark/tests/index.spec.js deleted file mode 100644 index 9633af27bb..0000000000 --- a/src/legacy/Coachmark/tests/index.spec.js +++ /dev/null @@ -1,218 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { Coachmark } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - beforeAll(() => { - jest.clearAllTimers(); - jest.useFakeTimers(); - }); - - it('should match SnapShot', () => { - const content = Hello how are you doing; - const container = shallow( - - - - ); - - expect(container).toMatchSnapshot(); - }); - - it('should not render one Coachmark without isOpen', () => { - const content = ( - - Hello how are you doing - - ); - const container = mount( - - - - ); - - jest.runAllTimers(); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(0); - }); - - it('should render one Coachmark with isOpen', () => { - const content = ( - - Hello how are you doing - - ); - const container = mount( - - - - ); - - jest.runAllTimers(); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(1); - }); - - it('should handle contentNode prop', () => { - const content = ( - - Hello how are you doing - - ); - const container = mount( - - - - ); - - jest.runAllTimers(); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(1); - }); - - it('should handle header prop', () => { - const content = ( - - Hello how are you doing - - ); - const container = mount( - - - - ); - - jest.runAllTimers(); - container.update(); - expect(container.find('.md-coachmark__header').length).toEqual(1); - }); - - it('should handle subheader prop', () => { - const content = ( - - Hello how are you doing - - ); - const container = mount( - - - - ); - - jest.runAllTimers(); - container.update(); - expect(container.find('.md-coachmark__subheader').length).toEqual(1); - }); - - it('should handle onClick prop', () => { - const onClick = jest.fn(); - - const content = ( - - Hello how are you doing - - ); - - const container = mount( - -
      Hello
      -
      - ); - - jest.runAllTimers(); - container.update(); - expect(container.find('.md-button').length).toEqual(1); - container.find('button').simulate('click'); - jest.runAllTimers(); - container.update(); - expect(onClick).toHaveBeenCalled(); - }); - - it('should show and hide with delay and allowClickAway', () => { - class Container extends React.Component { - state = { - coachmarkOpen: false, - }; - render() { - const content = ( - - Hello how are you doing - - ); - - return ( - - - - ); - } - } - const container = mount(); - expect(container.find('.coachmark-content').length).toEqual(0); - - container.setState({ coachmarkOpen: true }); - - jest.advanceTimersByTime(300); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(1); - - // Dispatch click outside Event - const evt = document.createEvent('HTMLEvents'); - evt.initEvent('click', false, true); - document.dispatchEvent(evt); - - jest.advanceTimersByTime(200); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(0); - }); - - it('on click outside, should not close the overlay', () => { - /* eslint-disable react/no-multi-comp */ - class ContainerDefault extends React.Component { - state = { - coachmarkOpen: false, - }; - render() { - const content = ( - - Hello how are you doing - - ); - - return ( -
      - - - -
      - ); - } - } - /* eslint-enable react/no-multi-comp */ - const container = mount(); - container.setState({ coachmarkOpen: true }); - - jest.runAllTimers(); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(1); - - // Dispatch click outside Event - const evt = document.createEvent('HTMLEvents'); - evt.initEvent('click', false, true); - document.dispatchEvent(evt); - - jest.runAllTimers(); - container.update(); - expect(container.find('.coachmark-content').length).toEqual(1); - }); -}); diff --git a/src/legacy/Coachmark/tests/index.spec.js.snap b/src/legacy/Coachmark/tests/index.spec.js.snap deleted file mode 100644 index 977b5822f8..0000000000 --- a/src/legacy/Coachmark/tests/index.spec.js.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - - - -`; diff --git a/src/legacy/CollapseButton/examples/Collapsed.js b/src/legacy/CollapseButton/examples/Collapsed.js deleted file mode 100644 index ad43f62011..0000000000 --- a/src/legacy/CollapseButton/examples/Collapsed.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { CollapseButton } from '@momentum-ui/react-collaboration'; -export default class CollapseButtonCollapsed extends React.PureComponent { - render() { - return ; - } -} diff --git a/src/legacy/CollapseButton/examples/Expanded.js b/src/legacy/CollapseButton/examples/Expanded.js deleted file mode 100644 index 46e3e11f31..0000000000 --- a/src/legacy/CollapseButton/examples/Expanded.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { CollapseButton } from '@momentum-ui/react-collaboration'; -export default class CollapseButtonExpanded extends React.PureComponent { - render() { - return ; - } -} diff --git a/src/legacy/CollapseButton/examples/KitchenSink.js b/src/legacy/CollapseButton/examples/KitchenSink.js deleted file mode 100644 index 2a4e94c43d..0000000000 --- a/src/legacy/CollapseButton/examples/KitchenSink.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { CollapseButtonCollapsed, CollapseButtonExpanded } from './index'; - -export default class CollapseButtonKitchenSink extends React.Component { - render() { - return ( - - - - - ); - } -} diff --git a/src/legacy/CollapseButton/examples/KitchenSink.stories.tsx b/src/legacy/CollapseButton/examples/KitchenSink.stories.tsx deleted file mode 100644 index 6cac9f1114..0000000000 --- a/src/legacy/CollapseButton/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/CollapseButton', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/CollapseButton/examples/index.js b/src/legacy/CollapseButton/examples/index.js deleted file mode 100644 index d4f794a312..0000000000 --- a/src/legacy/CollapseButton/examples/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as CollapseButtonCollapsed } from './Collapsed'; -export { default as CollapseButtonExpanded } from './Expanded'; -export { default as CollapseButtonKitchenSink } from './KitchenSink'; diff --git a/src/legacy/CollapseButton/index.js b/src/legacy/CollapseButton/index.js deleted file mode 100644 index b718852696..0000000000 --- a/src/legacy/CollapseButton/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** @component collapse-button */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { Button, Icon } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const CollapseButton = (props) => { - const { alignment, className, collapse, onClick, ...otherProps } = props; - - const handleClick = () => { - onClick && onClick(); - }; - - const getIconName = () => { - return collapse ? 'panel-control-right_12' : 'panel-control-left_12'; - }; - - return ( - - - - - - -`; diff --git a/src/legacy/ComboBox/examples/Clear.js b/src/legacy/ComboBox/examples/Clear.js deleted file mode 100644 index d85342c539..0000000000 --- a/src/legacy/ComboBox/examples/Clear.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { ComboBox } from '@momentum-ui/react-collaboration'; -export default class ComboBoxClear extends React.PureComponent { - render() { - return ; - } -} diff --git a/src/legacy/ComboBox/examples/Default.js b/src/legacy/ComboBox/examples/Default.js deleted file mode 100644 index a3caa05142..0000000000 --- a/src/legacy/ComboBox/examples/Default.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { ComboBox } from '@momentum-ui/react-collaboration'; -export default class ComboBoxDefault extends React.PureComponent { - render() { - return ; - } -} diff --git a/src/legacy/ComboBox/examples/KitchenSink.js b/src/legacy/ComboBox/examples/KitchenSink.js deleted file mode 100644 index 4ccde6bd64..0000000000 --- a/src/legacy/ComboBox/examples/KitchenSink.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { ComboBoxClear, ComboBoxDefault } from './index'; - -export default class ComboBoxKitchenSink extends React.Component { - render() { - return ( - - - - - ); - } -} diff --git a/src/legacy/ComboBox/examples/KitchenSink.stories.tsx b/src/legacy/ComboBox/examples/KitchenSink.stories.tsx deleted file mode 100644 index 850aa48b23..0000000000 --- a/src/legacy/ComboBox/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/ComboBox', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/ComboBox/examples/index.js b/src/legacy/ComboBox/examples/index.js deleted file mode 100644 index d2d210e67e..0000000000 --- a/src/legacy/ComboBox/examples/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as ComboBoxClear } from './Clear'; -export { default as ComboBoxDefault } from './Default'; -export { default as ComboBoxKitchenSink } from './KitchenSink'; diff --git a/src/legacy/ComboBox/index.js b/src/legacy/ComboBox/index.js deleted file mode 100644 index 0a7360ba67..0000000000 --- a/src/legacy/ComboBox/index.js +++ /dev/null @@ -1,307 +0,0 @@ -/** @component combo-box */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { EventOverlay, Input, ListItem, InputSearch } from '@momentum-ui/react-collaboration'; -import omit from 'lodash/omit'; -import uniqueId from 'lodash/uniqueId'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class ComboBox extends React.Component { - static displayName = 'ComboBox'; - - state = { - filteredOptions: [], - focus: -1, - id: this.props.id || uniqueId('md-combo-box-'), - isOpen: false, - value: '', - }; - - componentDidMount() { - const { children } = this.props; - - this.options = (children && React.Children.toArray(children)) || this.mapOptionsToListItem(); - - this.setFilteredOptions(); - } - - componentDidUpdate(prevProps) { - const { options, children } = this.props; - const { value } = this.state; - - if (prevProps.options !== options || prevProps.children !== children) { - this.options = (children && React.Children.toArray(children)) || this.mapOptionsToListItem(); - - this.setFilteredOptions(value); - } - } - - mapOptionsToListItem = () => { - const { options } = this.props; - - return options.map((option, i) => ); - }; - - setFilteredOptions = (filter) => { - const { onChange } = this.props; - - const filteredOptions = !onChange ? this.applyFilter(filter) : this.options; - - this.setState({ - isOpen: !!filteredOptions.length, - filteredOptions, - }); - }; - - hidePopover = () => { - this.setState({ - isOpen: false, - }); - }; - - handleToggle = () => { - const { filteredOptions } = this.state; - - filteredOptions.length && this.setState({ isOpen: true }); - }; - - applyFilter = (value) => { - const { searchProp } = this.props; - const isSubString = (string) => value && string.toLowerCase().includes(value.toLowerCase()); - - return this.options.filter( - (option) => - (option.props[searchProp] && isSubString(option.props[searchProp])) || - ['ListItemHeader'].includes(option.type.displayName) - ); - }; - - handleChange = (e) => { - const { onChange } = this.props; - const { focus } = this.state; - - this.setFilteredOptions(e.target.value); - this.setState( - { - value: e.target.value, - focus: !onChange ? -1 : focus, - }, - () => onChange && onChange(e, e.target.value) - ); - }; - - handleClick = (e, selectedOption) => { - const { searchProp } = this.props; - const { onSelect } = this.props; - - this.setFilteredOptions(selectedOption.props[searchProp]); - this.setState( - { - value: selectedOption.props[searchProp], - isOpen: false, - focus: -1, - }, - () => onSelect && onSelect(e, selectedOption) - ); - }; - - setFocus = (index) => { - this.setState({ focus: index }); - }; - - handleKeyDown = (e) => { - let flag = false; - let newIndex; - const { filteredOptions, focus, isOpen } = this.state; - const length = filteredOptions && filteredOptions.length - 1; - - const getNewIndex = (currentIndex, change) => { - const getPossibleIndex = () => { - if (currentIndex + change < 0) { - return length; - } else if (currentIndex + change > length) { - return 0; - } - - return currentIndex + change; - }; - - const possibleIndex = getPossibleIndex(); - const potentialTarget = React.Children.toArray(filteredOptions)[possibleIndex]; - - return potentialTarget.props.disabled || potentialTarget.props.isReadOnly - ? getNewIndex(possibleIndex, change) - : possibleIndex; - }; - - switch (e.which) { - case 13: - isOpen && focus !== -1 && this.handleClick(e, filteredOptions[focus]); - flag = true; - break; - - case 38: - if (isOpen) { - newIndex = getNewIndex(focus, -1); - this.setFocus(newIndex); - } - flag = true; - break; - - case 40: - if (isOpen) { - newIndex = getNewIndex(focus, 1); - this.setFocus(newIndex); - } - flag = true; - break; - - default: - break; - } - if (flag) { - e.stopPropagation(); - e.preventDefault(); - } - }; - - render() { - const { className, clear, disabled, hasSearchIcon, inputProps, placeholder, ...props } = - this.props; - - const otherProps = omit({ ...props }, [ - 'children', - 'id', - 'onChange', - 'onSelect', - 'options', - 'searchProp', - ]); - - const { filteredOptions, focus, id, isOpen, value } = this.state; - - const activeDescendant = this.activeChild && this.activeChild.id; - const InputComp = hasSearchIcon ? InputSearch : Input; - - const input = ( - (this.anchorNode = ref)} - onChange={this.handleChange} - onClick={this.handleToggle} - onKeyDown={this.handleKeyDown} - placeholder={placeholder} - value={value} - {...(activeDescendant && { 'aria-activedescendant': activeDescendant })} - {...inputProps} - /> - ); - - const renderFilteredOption = - filteredOptions && - filteredOptions.map((option, i) => - React.cloneElement(option, { - active: i === focus, - key: i, - onClick: (e) => this.handleClick(e, option), - refName: 'option', - role: 'option', - ...(focus === i && { ref: (ref) => (this.activeChild = ref) }), - }) - ); - - const dropdownElement = this.anchorNode && isOpen && ( - -
      - {renderFilteredOption} -
      -
      - ); - - return ( -
      - {input} - {dropdownElement} -
      - ); - } -} - -ComboBox.propTypes = { - /** @prop Children nodes to render inside ComboBox | null */ - children: PropTypes.node, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Sets the initial input element as empty | false */ - clear: PropTypes.bool, - /** @prop Sets the attribute disabled to the ComboBox | false */ - disabled: PropTypes.bool, - /** @prop Sets the ComboBox to have a search icon | true */ - hasSearchIcon: PropTypes.bool, - /** @prop Sets the ID of the ComboBox */ - id: PropTypes.string, - /** @prop Collection of props unique for Input element | null */ - inputProps: PropTypes.shape({}), - /** @prop Handler invoked when the user presses any key | null */ - onChange: PropTypes.func, - /** @prop Handler invoked when the user selects the ComboBox | null */ - onSelect: PropTypes.func, - /** @prop Array of options for the ComboBox dropdown | [] */ - options: PropTypes.arrayOf(PropTypes.string), - /** @prop Text that initially populates the input field for guidence | '' */ - placeholder: PropTypes.string, - /** @prop Sets the search prop | 'label' */ - searchProp: PropTypes.string, - /** @prop Sets the target offset | { horizontal: 0, vertical: 4 } */ - targetOffset: PropTypes.shape({ - horizontal: PropTypes.number, - vertical: PropTypes.number, - }), -}; - -ComboBox.defaultProps = { - children: null, - className: '', - clear: false, - disabled: false, - hasSearchIcon: true, - id: null, - inputProps: null, - onChange: null, - onSelect: null, - options: [], - placeholder: '', - searchProp: 'label', - targetOffset: { - horizontal: 0, - vertical: 4, - }, -}; - -export default ComboBox; diff --git a/src/legacy/ComboBox/tests/index.spec.js b/src/legacy/ComboBox/tests/index.spec.js deleted file mode 100644 index 2d29597069..0000000000 --- a/src/legacy/ComboBox/tests/index.spec.js +++ /dev/null @@ -1,195 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import { ComboBox, ListItem, ListItemHeader } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - expect(container).toMatchSnapshot(); - }); - - it('should apply className to ComboBox', () => { - const container = mount(); - expect(container.find('.md-combo-box').hasClass('test')).toEqual(true); - expect(container.find('Input').length).toEqual(1); - }); - - it('should display search icon by default', () => { - const container = mount(); - expect(container.find('SearchInput').length).toEqual(1); - }); - - it('should not show searchIcon when hasSearchIcon is false', () => { - const container = mount(); - expect(container.find('Input').length).toEqual(1); - }); - - it('should show options when search string is does exists', () => { - const container = mount(); - container.find('.md-input').simulate('change', { target: { value: 'a' } }); - expect(container.find('ListItem').length).toEqual(3); - - container.find('.md-input').simulate('change', { target: { value: 'ab' } }); - expect(container.find('ListItem').length).toEqual(2); - - container.find('.md-input').simulate('change', { target: { value: 'abc' } }); - expect(container.find('ListItem').length).toEqual(1); - }); - - it('should not show any options when search string is does not exists', () => { - const container = mount(); - container.find('.md-input').simulate('change', { target: { value: 'xyz' } }); - expect(container.find('ListItem').length).toEqual(0); - }); - - it('should close the options list when an option is selected', () => { - const onSelectFn = jest.fn(); - const container = mount(); - container.find('.md-input').simulate('change', { target: { value: 'a' } }); - expect(container.find('ListItem').length).toEqual(3); - - // select 'ab' option - container.find('.md-list-item').at(1).simulate('click'); - expect(container.find('.md-input').props().value).toEqual('ab'); - expect(container.find('ListItem').length).toEqual(0); - expect(onSelectFn).toHaveBeenCalled(); - - // click back on input tag, should open the options list once again - container.find('.md-input').simulate('click'); - expect(container.find('ListItem').length).toEqual(2); - }); - - it('should handle keyBoard events', () => { - const onSelectFn = jest.fn(); - const container = mount(); - container.find('.md-input').simulate('change', { target: { value: 'a' } }); - expect(container.find('ListItem').length).toEqual(3); - - // focus first option using keyBoard - container.find('.md-input').simulate('keyDown', { which: 40 }); - expect(container.find('.md-list-item').at(0).hasClass('active')).toEqual(true); - - // focus second option using keyBoard - container.find('.md-input').simulate('keyDown', { which: 40 }); - expect(container.find('.md-list-item').at(1).hasClass('active')).toEqual(true); - - container.find('.md-input').simulate('keyDown', { which: 13 }); - expect(container.find('.md-input').props().value).toEqual('ab'); - expect(container.find('ListItem').length).toEqual(0); - expect(onSelectFn).toHaveBeenCalled(); - }); - - it('should handle keyBoard events with few items disabled', () => { - const onSelectFn = jest.fn(); - const container = mount( - - - - - - ); - container.find('.md-input').simulate('change', { target: { value: 'x' } }); - expect(container.find('ListItem').length).toEqual(3); - - // focus on the second option since first one is disabled, on down key - container.find('.md-input').simulate('keyDown', { which: 40 }); - expect(container.find('.md-list-item').at(1).hasClass('active')).toEqual(true); - - // focus third option on down key - container.find('.md-input').simulate('keyDown', { which: 40 }); - expect(container.find('.md-list-item').at(2).hasClass('active')).toEqual(true); - - // focus on first option on down key - container.find('.md-input').simulate('keyDown', { which: 40 }); - expect(container.find('.md-list-item').at(1).hasClass('active')).toEqual(true); - }); - - it('on click outside, should close the options list', () => { - const container = mount(); - - container.find('.md-input').simulate('change', { target: { value: 'a' } }); - expect(container.find('ListItem').length).toEqual(3); - - // Dispatch click outside Event - const evt = document.createEvent('HTMLEvents'); - evt.initEvent('click', false, true); - document.dispatchEvent(evt); - - container.update(); - expect(container.find('ListItem').length).toEqual(0); - }); - - it('ComboBox should not search when onChange listener is registered', () => { - const onSelectFn = jest.fn(); - class ContainerDefault extends React.Component { - state = { - options: [], - }; - - onChange = () => { - this.setState({ - options: ['a', 'ab'], - }); - }; - - render() { - return ( - - ); - } - } - - const container = mount(); - - container.find('.md-input').simulate('change', { target: { value: 'x' } }); - expect(container.find('ListItem').length).toEqual(2); - - container.find('.md-list-item').at(1).simulate('click'); - expect(container.find('.md-input').props().value).toEqual('ab'); - expect(container.find('ListItem').length).toEqual(0); - expect(onSelectFn).toHaveBeenCalled(); - }); - - it('should render ListItem nodes as options if passed as ComboBox children', () => { - const container = mount( - - -
      - - -
      - - - ); - container.find('.md-input').simulate('change', { target: { value: 'x' } }); - expect(container.find('ListItem').length).toEqual(2); - - expect(container.find('ListItem').at(0).find('.content-1').length).toEqual(1); - expect(container.find('ListItem').at(1).find('.content-2').length).toEqual(1); - - container.find('.md-list-item').at(1).simulate('click'); - expect(container.find('.md-input').props().value).toEqual('xy'); - - container.find('.md-input').simulate('change', { target: { value: 'a' } }); - expect(container.find('ListItem').length).toEqual(0); - }); - - it('should render ListItemHeader if passed as ComboBox children', () => { - const container = mount( - - - -
      - - - ); - - container.find('.md-input').simulate('change', { target: { value: 'z' } }); - - expect(container.find('ListItemHeader').exists()).toEqual(true); - expect(container.find('ListItem').at(0).find('.content-1').exists()).toEqual(false); - - container.find('ListItemHeader').simulate('click'); - expect(container.find('.md-input').props().value).toEqual('z'); - }); -}); diff --git a/src/legacy/ComboBox/tests/index.spec.js.snap b/src/legacy/ComboBox/tests/index.spec.js.snap deleted file mode 100644 index 52c0105805..0000000000 --- a/src/legacy/ComboBox/tests/index.spec.js.snap +++ /dev/null @@ -1,165 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
      - - - } - inputClassName="" - inputRef={[Function]} - inputSize="" - isFilled={false} - label="" - messageArr={Array []} - multiline={false} - name={null} - nestedLevel={0} - onChange={[Function]} - onClick={[Function]} - onDoneEditing={null} - onFocus={null} - onKeyDown={[Function]} - onMouseDown={null} - placeholder="" - readOnly={false} - secondaryLabel="" - shape="" - type="text" - value="" - > -
      -
      - - - - - - - - -
      -
      - -
      -
      -
      -`; diff --git a/src/legacy/CompositeAvatar/index.js b/src/legacy/CompositeAvatar/index.js deleted file mode 100644 index ed6899fc80..0000000000 --- a/src/legacy/CompositeAvatar/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** @component avatar */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -const CompositeAvatar = (props) => { - const { children, className, size } = props; - - return ( -
      - {children} -
      - ); -}; - -CompositeAvatar.displayName = 'CompositeAvatar'; - -CompositeAvatar.propTypes = { - /** @prop Children nodes to render inside CompositeAvatar | null */ - children: PropTypes.node, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Sets the size of the CompositeAvatar | 'medium' */ - size: PropTypes.oneOf(['small', 'medium', 'large', 28, 40, 84, 135]), -}; - -CompositeAvatar.defaultProps = { - className: '', - size: 'medium', - children: null, -}; - -export default CompositeAvatar; diff --git a/src/legacy/CompositeAvatar/tests/index.spec.js b/src/legacy/CompositeAvatar/tests/index.spec.js deleted file mode 100644 index cd0a4b0cad..0000000000 --- a/src/legacy/CompositeAvatar/tests/index.spec.js +++ /dev/null @@ -1,124 +0,0 @@ -import React from 'react'; -import { mount, shallow } from 'enzyme'; -import { Avatar, CompositeAvatar } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount( - - - - - ); - - expect(container).toMatchSnapshot(); - }); - - describe('composite avatars of different sizes ', () => { - it('when size is small/28', () => { - let container = mount( - - - - - ); - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--small')).toEqual( - true - ); - expect(container.find('.md-avatar').length).toEqual(2); - container = mount( - - - - - ); - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--28')).toEqual( - true - ); - }); - - it('when size is medium/40', () => { - let container = mount( - - - - - ); - expect( - container.find('.md-composite-avatar').hasClass('md-composite-avatar--medium') - ).toEqual(true); - expect(container.find('.md-avatar').length).toEqual(2); - container = mount( - - - - - ); - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--40')).toEqual( - true - ); - }); - - it('when size is 84', () => { - let container = mount( - - - - - ); - - expect(container.find('.md-avatar').length).toEqual(2); - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--84')).toEqual( - true - ); - }); - - it('when size is large/135', () => { - let container = mount( - - - - - ); - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--large')).toEqual( - true - ); - expect(container.find('.md-avatar').length).toEqual(2); - container = mount( - - - - - ); - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--135')).toEqual( - true - ); - }); - }); - - it('should not throw an error when 2 Avatar components are not present as children', () => { - const container = shallow( - - - - ); - - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--large')).toEqual( - true - ); - }); - - it('should allow Avatar components to be wrapped', () => { - const container = shallow( - -
      - -
      -
      - ); - - expect(container.find('.md-composite-avatar').hasClass('md-composite-avatar--large')).toEqual( - true - ); - }); -}); diff --git a/src/legacy/CompositeAvatar/tests/index.spec.js.snap b/src/legacy/CompositeAvatar/tests/index.spec.js.snap deleted file mode 100644 index a40927475d..0000000000 --- a/src/legacy/CompositeAvatar/tests/index.spec.js.snap +++ /dev/null @@ -1,89 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -
      - -
      - - t - -
      -
      - -
      - - t - -
      -
      -
      -
      -`; diff --git a/src/legacy/DatePicker/DatePickerCalendar/index.js b/src/legacy/DatePicker/DatePickerCalendar/index.js deleted file mode 100644 index c363e5e785..0000000000 --- a/src/legacy/DatePicker/DatePickerCalendar/index.js +++ /dev/null @@ -1,205 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePickerContext from '../../DatePickerContext'; -import DatePickerMonth from '../DatePickerMonth'; -import { Icon } from '@momentum-ui/react-collaboration'; -import { - addDays, - addMonths, - getLocaleData, - getStartOfWeek, - getWeekdayMinInLocale, - isSameDay, - localizeDate, - now, - shouldNextMonthDisable, - shouldPrevMonthDisable, - subtractMonths, -} from '../../utils/dateUtils'; -import mapContextToProps from '@restart/context/mapContextToProps'; -import moment from 'moment'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class DatePickerCalendar extends React.Component { - constructor(props) { - super(props); - this.state = { - date: null, - }; - this.nextMonthRef = React.createRef(); - this.prevMonthRef = React.createRef(); - } - - componentDidMount() { - const { focus, selected } = this.props; - this.setDate(focus || selected || now()); - } - - componentDidUpdate(prevProps) { - const { focus, monthNavFocus } = prevProps; - if (focus && !isSameDay(this.props.focus, focus)) { - this.setDate(focus); - } - if (monthNavFocus !== this.props.monthNavFocus) { - this.props.monthNavFocus === 'prev' && this.prevMonthRef.button.focus(); - this.props.monthNavFocus === 'next' && this.nextMonthRef.button.focus(); - } - } - - setDate = (date, cb) => { - this.setState( - { - date, - }, - cb - ); - }; - - increaseMonth = (event) => { - const { handleMonthChange } = this.props; - const { date } = this.state; - this.setDate( - addMonths(date.clone(), 1), - () => handleMonthChange && handleMonthChange(event, this.state.date) - ); - }; - - decreaseMonth = (event) => { - const { handleMonthChange } = this.props; - const { date } = this.state; - this.setDate( - subtractMonths(date.clone(), 1), - () => handleMonthChange && handleMonthChange(event, this.state.date) - ); - }; - - render() { - const { date } = this.state; - const { locale, monthFormat, nextArialLabel, previousArialLabel, ...otherProps } = this.props; - - const renderMonthName = () => { - return ( -
      - {localizeDate(date, locale).format(monthFormat)} -
      - ); - }; - - const renderPreviousMonthButton = () => { - const { minDate } = this.props; - const allPrevDaysDisabled = shouldPrevMonthDisable(date, minDate); - return ( - (this.prevMonthRef = ref) }} - tabIndex={-1} - /> - ); - }; - - const renderNextMonthButton = () => { - const { maxDate } = this.props; - const allNextDaysDisabled = shouldNextMonthDisable(date, maxDate); - return ( - (this.nextMonthRef = ref) }} - tabIndex={-1} - /> - ); - }; - - const header = () => { - const startOfWeek = getStartOfWeek(date.clone()); - const dayNames = []; - return dayNames.concat( - [0, 1, 2, 3, 4, 5, 6].map((offset) => { - const day = addDays(localizeDate(startOfWeek, locale), offset); - const localeData = getLocaleData(day); - const weekDayName = getWeekdayMinInLocale(localeData, day); - return ( -
      - {weekDayName} -
      - ); - }) - ); - }; - - const renderMonth = () => { - return ( -
      -
      -
      - {renderMonthName()} -
      - {renderPreviousMonthButton()} - {renderNextMonthButton()} -
      -
      -
      {header()}
      -
      - -
      - ); - }; - - return
      {date && renderMonth()}
      ; - } -} - -DatePickerCalendar.propTypes = { - // Internal Context Use Only - focus: PropTypes.instanceOf(moment), - // Internal Context Use Only - handleMonthChange: PropTypes.func, - /** Sets the language for the DatePickerCalendar | 'en' */ - locale: PropTypes.string, - /** Sets the last date in which the calendar does not disable | null */ - maxDate: PropTypes.instanceOf(Date), - /** Sets the first date in which the calendar does not disable | null */ - minDate: PropTypes.instanceOf(Date), - /** Sets the format in how the Month is displayed | null */ - monthFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), - /** Sets which arrow button for the month navigation should have focus */ - monthNavFocus: PropTypes.string, - /** Text to display for blindness accessibility features | 'next' */ - nextArialLabel: PropTypes.string, - /** Text to display for blindness accessibility features | 'previous' */ - previousArialLabel: PropTypes.string, - // Internal Context Use Only - selected: PropTypes.instanceOf(moment), -}; - -DatePickerCalendar.defaultProps = { - focus: null, - handleMonthChange: null, - locale: 'en', - maxDate: null, - minDate: null, - monthFormat: 'MMMM YYYY', - monthNavFocus: 'prev', - nextArialLabel: '', - previousArialLabel: '', - Selected: null, -}; - -DatePickerCalendar.displayName = 'DatePickerCalendar'; - -export default mapContextToProps(DatePickerContext, (context) => context, DatePickerCalendar); diff --git a/src/legacy/DatePicker/DatePickerCalendar/tests/index.spec.js b/src/legacy/DatePicker/DatePickerCalendar/tests/index.spec.js deleted file mode 100644 index 363f889184..0000000000 --- a/src/legacy/DatePicker/DatePickerCalendar/tests/index.spec.js +++ /dev/null @@ -1,105 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import DatePickerCalendar from '../index'; -import DatePickerContext from '../../../DatePickerContext'; -import { isSameDay, now } from '../../../utils/dateUtils'; -import moment from 'moment-timezone'; - -describe('tests for ', () => { - const monthFormat = 'MMMM YYYY'; - const TEST_DATE = '2018-04-01'; - let day; - - beforeAll(() => { - // setting timezone to CST - moment.tz.setDefault('Asia/Kolkata'); - day = moment(TEST_DATE); - }); - - afterAll(() => { - moment.tz.setDefault(); - }); - - it('should start with the current date in view if no date is passed in', () => { - const calendar = mount( - - - - ); - expect(isSameDay(calendar.find('DatePickerCalendar').state().date, now())).toEqual(true); - }); - - it('should start with the focus date if it is provided', () => { - const calendar = mount( - - - - ); - expect(isSameDay(calendar.find('DatePickerCalendar').state().date, day)).toEqual(true); - }); - - it('should start with the selected date in view if provided and focus date is not provided', () => { - const calendar = mount( - - - - ); - expect(isSameDay(calendar.find('DatePickerCalendar').state().date, day)).toEqual(true); - }); - - it('should display month, navigation buttons and month name', () => { - const calendar = mount( - - - - ); - expect(calendar.find('DatePickerDay')).toHaveLength(35); - expect(calendar.find('DatePickerWeek')).toHaveLength(5); - expect(calendar.find('DatePickerMonth')).toHaveLength(1); - - expect(calendar.find('.md-datepicker__navigation--current-month').text()).toEqual('April 2018'); - expect(calendar.find('.md-button.md-button--icon').at(1).props().disabled).toEqual(false); - expect(calendar.find('.md-button.md-button--icon').at(0).props().disabled).toEqual(false); - expect(calendar.find('.md-button.md-datepicker__day--selected').text()).toEqual('1'); - expect(calendar.find('.md-button.md-datepicker__day--focus').text()).toEqual('1'); - }); - - it('should next and previous buttons disabled when the other months are disabled', () => { - const calendar = mount( - - - - ); - expect(calendar.find('.md-button--icon').at(1).props().disabled).toEqual(true); - expect(calendar.find('.md-button--icon').at(0).props().disabled).toEqual(true); - }); - - it('when next is clicked should switch to next month vice-versa', () => { - const calendar = mount( - - - - ); - calendar.find('.md-button.md-button--icon').at(1).simulate('click'); - expect(calendar.find('.md-datepicker__navigation--current-month').text()).toEqual('May 2018'); - calendar.find('.md-button.md-button--icon').at(0).simulate('click'); - expect(calendar.find('.md-datepicker__navigation--current-month').text()).toEqual('April 2018'); - }); - - it('should disable dates that are filtered', () => { - const calendar = mount( - - day.day() == '0'} /> - - ); - calendar.find('DatePickerWeek').forEach((week) => { - expect(week.find('DatePickerDay').at(0).find('button.md-button').props().disabled).toEqual( - true - ); - }); - }); -}); diff --git a/src/legacy/DatePicker/DatePickerDay/index.js b/src/legacy/DatePicker/DatePickerDay/index.js deleted file mode 100644 index a9dc4358df..0000000000 --- a/src/legacy/DatePicker/DatePickerDay/index.js +++ /dev/null @@ -1,77 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { Button } from '@momentum-ui/react-collaboration'; -import DatePickerContext from '../../DatePickerContext'; -import { getDate, getMonth, isDayDisabled, isSameDay, now } from '../../utils/dateUtils'; -import mapContextToProps from '@restart/context/mapContextToProps'; -import moment from 'moment'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class DatePickerDay extends React.Component { - constructor(props) { - super(props); - this.dayButton = React.createRef(); - } - - componentDidUpdate = () => { - const { day, focus } = this.props; - - isSameDay(day, focus) && this.dayButton.current.button.focus(); - }; - - handleClick = (e) => { - const { handleDayClick, day } = this.props; - return handleDayClick && handleDayClick(e, day); - }; - - render() { - const { selected, focus, day, month } = this.props; - - const isOutsideMonth = month !== getMonth(day); - const isSelected = isSameDay(day, selected); - const isToday = isSameDay(day, now()); - const disabled = isDayDisabled(day, this.props); - const hasFocus = isSameDay(day, focus); - - return ( - - ); - } -} - -DatePickerDay.propTypes = { - /** Required day that the DatePickerDay displays */ - day: PropTypes.instanceOf(moment).isRequired, - // Internal Context Use Only - focus: PropTypes.instanceOf(moment), - // Internal Context Use Only - handleDayClick: PropTypes.func, - /** Required month that the DatePickerDay displays */ - month: PropTypes.number.isRequired, - // Internal Context Use Only - selected: PropTypes.instanceOf(moment), -}; - -DatePickerDay.displayName = 'DatePickerDay'; - -export default mapContextToProps(DatePickerContext, (context) => context, DatePickerDay); diff --git a/src/legacy/DatePicker/DatePickerDay/tests/index.spec.js b/src/legacy/DatePicker/DatePickerDay/tests/index.spec.js deleted file mode 100644 index a6b459f8ea..0000000000 --- a/src/legacy/DatePicker/DatePickerDay/tests/index.spec.js +++ /dev/null @@ -1,88 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import DatePickerContext from '../../../DatePickerContext'; -import DatePickerDay from '../index'; -import moment from 'moment-timezone'; - -const TEST_DATE = '2018-04-21'; - -describe.only('tests for ', () => { - let day; - - beforeAll(() => { - // setting timezone to CST - moment.tz.setDefault('Asia/Kolkata'); - day = moment(TEST_DATE); - }); - - afterAll(() => { - moment.tz.setDefault(); - }); - - it('should match selected day SnapShot', () => { - const selected = moment(TEST_DATE); - const container = shallow(); - expect(container).toMatchSnapshot(); - }); - - describe('should apply the right modifier classes', () => { - it('should apply a modifier, when the date does not belong to current month', () => { - const container = mount(); - expect(container.find('.md-button').hasClass('md-datepicker__day--outside-month')).toEqual( - true - ); - }); - - it('should apply a modifier when the date is selected', () => { - const container = mount( - - - - ); - expect(container.find('.md-button').hasClass('md-datepicker__day--selected')).toEqual(true); - }); - - it('should apply a modifier when the date is today`s date', () => { - const container = mount(); - expect(container.find('.md-button').hasClass('md-datepicker__day--today')).toEqual(true); - }); - - it('should apply a modifier when the date is in focus', () => { - const container = mount( - - - - ); - expect(container.find('.md-button').hasClass('md-datepicker__day--focus')).toEqual(true); - }); - }); - - it('when Day the disabled, should set disabled prop on button', () => { - const container = mount( true} />); - expect(container.find('.md-button').props().disabled).toEqual(true); - }); - - it('onclick of Day should call the callback in context', () => { - const onClickFn = jest.fn(); - const container = mount( - - - - ); - container.find('.md-button').simulate('click'); - expect(onClickFn).toHaveBeenCalled(); - }); - - it('on press of enter/space key on Day, should call the callback in context', () => { - const onClickFn = jest.fn(); - const container = mount( - - - - ); - container.find('.md-button').simulate('keyDown', { which: 13 }); - expect(onClickFn).toHaveBeenCalled(); - container.find('.md-button').simulate('keyDown', { which: 32 }); - expect(onClickFn).toHaveBeenCalledTimes(2); - }); -}); diff --git a/src/legacy/DatePicker/DatePickerDay/tests/index.spec.js.snap b/src/legacy/DatePicker/DatePickerDay/tests/index.spec.js.snap deleted file mode 100644 index 828e7a9e05..0000000000 --- a/src/legacy/DatePicker/DatePickerDay/tests/index.spec.js.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match selected day SnapShot 1`] = ` - - - -`; diff --git a/src/legacy/DatePicker/DatePickerMonth/index.js b/src/legacy/DatePicker/DatePickerMonth/index.js deleted file mode 100644 index 7de4993635..0000000000 --- a/src/legacy/DatePicker/DatePickerMonth/index.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePickerWeek from '../DatePickerWeek'; -import { - addWeeks, - getMonth, - getStartOfMonth, - getStartOfWeek, - isSameMonth, -} from '../../utils/dateUtils'; -import moment from 'moment'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class DatePickerMonth extends React.Component { - static displayName = 'DatePickerMonth'; - - renderWeeks = () => { - const { day, ...otherProps } = this.props; - - let i = 0; - let currentWeekStart = getStartOfWeek(getStartOfMonth(day.clone())); - - const weeks = []; - const month = getMonth(day); - - do { - weeks.push(); - currentWeekStart = addWeeks(currentWeekStart.clone(), 1); - } while (isSameMonth(currentWeekStart, day)); - - return weeks; - }; - - render() { - return
      {this.renderWeeks()}
      ; - } -} - -DatePickerMonth.propTypes = { - /** Required day for the DatePickerMonth */ - day: PropTypes.instanceOf(moment).isRequired, -}; - -export default DatePickerMonth; diff --git a/src/legacy/DatePicker/DatePickerMonth/tests/index.spec.js b/src/legacy/DatePicker/DatePickerMonth/tests/index.spec.js deleted file mode 100644 index a4ff941d0b..0000000000 --- a/src/legacy/DatePicker/DatePickerMonth/tests/index.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import DatePickerMonth from '../index'; -import moment from 'moment-timezone'; - -const TEST_DATE = '2018-04-01'; - -describe('tests for ', () => { - let day; - - beforeAll(() => { - // setting timezone to CST - moment.tz.setDefault('Asia/Kolkata'); - day = moment(TEST_DATE); - }); - - afterAll(() => { - moment.tz.setDefault(); - }); - - it('should match month SnapShot', () => { - const container = shallow(); - expect(container).toMatchSnapshot(); - }); - - it('should render all days of the month correctly', () => { - const container = mount(); - expect(container.find('DatePickerWeek')).toHaveLength(5); - expect(container.find('DatePickerDay')).toHaveLength(35); - }); -}); diff --git a/src/legacy/DatePicker/DatePickerMonth/tests/index.spec.js.snap b/src/legacy/DatePicker/DatePickerMonth/tests/index.spec.js.snap deleted file mode 100644 index 60cd09d43f..0000000000 --- a/src/legacy/DatePicker/DatePickerMonth/tests/index.spec.js.snap +++ /dev/null @@ -1,33 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match month SnapShot 1`] = ` -
      - - - - - -
      -`; diff --git a/src/legacy/DatePicker/DatePickerWeek/index.js b/src/legacy/DatePicker/DatePickerWeek/index.js deleted file mode 100644 index 7eeb7bd7f7..0000000000 --- a/src/legacy/DatePicker/DatePickerWeek/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePickerDay from '../DatePickerDay'; -import { addDays, getStartOfWeek } from '../../utils/dateUtils'; -import moment from 'moment'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class DatePickerWeek extends React.PureComponent { - static displayName = 'DatePickerWeek'; - - render() { - const { day, ...otherProps } = this.props; - - const renderDays = () => { - const startOfWeek = getStartOfWeek(day.clone()); - - const days = [0, 1, 2, 3, 4, 5, 6].map((offset) => { - const day = addDays(startOfWeek.clone(), offset); - return ; - }); - - return days; - }; - - return
      {renderDays()}
      ; - } -} - -DatePickerWeek.propTypes = { - /** Required day for the DatePickerWeek */ - day: PropTypes.instanceOf(moment).isRequired, -}; - -export default DatePickerWeek; diff --git a/src/legacy/DatePicker/DatePickerWeek/tests/index.spec.js b/src/legacy/DatePicker/DatePickerWeek/tests/index.spec.js deleted file mode 100644 index 2068860e75..0000000000 --- a/src/legacy/DatePicker/DatePickerWeek/tests/index.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { mount, shallow } from 'enzyme'; -import DatePickerWeek from '../index'; -import moment from 'moment-timezone'; - -const TEST_DATE = '2018-04-01'; - -describe('tests for ', () => { - let day; - - beforeAll(() => { - // setting timezone to CST - moment.tz.setDefault('Asia/Kolkata'); - day = moment(TEST_DATE); - }); - - afterAll(() => { - moment.tz.setDefault(); - }); - - it('should match week SnapShot', () => { - const container = shallow(); - expect(container).toMatchSnapshot(); - }); - - it('should render a div', () => { - const container = shallow(); - expect(container.find('.md-datepicker__week').length).toEqual(1); - }); - - it('should render 7 Day components', () => { - const container = mount(); - expect(container.find('DatePickerDay')).toHaveLength(7); - }); -}); diff --git a/src/legacy/DatePicker/DatePickerWeek/tests/index.spec.js.snap b/src/legacy/DatePicker/DatePickerWeek/tests/index.spec.js.snap deleted file mode 100644 index 2160e8dd7c..0000000000 --- a/src/legacy/DatePicker/DatePickerWeek/tests/index.spec.js.snap +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match week SnapShot 1`] = ` -
      - - - - - - - -
      -`; diff --git a/src/legacy/DatePicker/examples/Default.js b/src/legacy/DatePicker/examples/Default.js deleted file mode 100644 index b7cb323a18..0000000000 --- a/src/legacy/DatePicker/examples/Default.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { Button, DatePicker } from '@momentum-ui/react-collaboration'; -export default class DatePickerDefault extends React.PureComponent { - state = { - date: null, - }; - render() { - const { date } = this.state; - return ( - -

      Selected Date: {date && date.toDateString()}

      - this.setState({ date })}> -
      -
      - ); - } -} diff --git a/src/legacy/Dialog/examples/KitchenSink.js b/src/legacy/Dialog/examples/KitchenSink.js deleted file mode 100644 index 1ac59788d9..0000000000 --- a/src/legacy/Dialog/examples/KitchenSink.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { DialogDefault } from './index'; - -export default class DialogKitchenSink extends React.Component { - render() { - return ( - - - - ); - } -} diff --git a/src/legacy/Dialog/examples/KitchenSink.stories.tsx b/src/legacy/Dialog/examples/KitchenSink.stories.tsx deleted file mode 100644 index 3efad2ec90..0000000000 --- a/src/legacy/Dialog/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/Dialog', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/Dialog/examples/index.js b/src/legacy/Dialog/examples/index.js deleted file mode 100644 index 95213ea53d..0000000000 --- a/src/legacy/Dialog/examples/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as DialogDefault } from './Default'; -export { default as DialogKitchenSink } from './KitchenSink'; diff --git a/src/legacy/EditableTextfield/examples/Default.js b/src/legacy/EditableTextfield/examples/Default.js deleted file mode 100644 index 0cd7fa980a..0000000000 --- a/src/legacy/EditableTextfield/examples/Default.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { EditableTextfield } from '@momentum-ui/react-collaboration'; -export default class EditableTextFieldDefault extends React.Component { - render() { - return ( - alert(data)} inputText="Hello World" /> - ); - } -} diff --git a/src/legacy/EditableTextfield/examples/KitchenSink.js b/src/legacy/EditableTextfield/examples/KitchenSink.js deleted file mode 100644 index edb5e4f1e0..0000000000 --- a/src/legacy/EditableTextfield/examples/KitchenSink.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { EditableTextfieldDefault } from './index'; - -export default class EditableTextfieldKitchenSink extends React.Component { - render() { - return ( - - - - ); - } -} diff --git a/src/legacy/EditableTextfield/examples/KitchenSink.stories.tsx b/src/legacy/EditableTextfield/examples/KitchenSink.stories.tsx deleted file mode 100644 index 5db4a00089..0000000000 --- a/src/legacy/EditableTextfield/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/EditableTextfield', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/EditableTextfield/examples/index.js b/src/legacy/EditableTextfield/examples/index.js deleted file mode 100644 index 1ce42aea09..0000000000 --- a/src/legacy/EditableTextfield/examples/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as EditableTextfieldDefault } from './Default'; -export { default as EditableTextfieldKitchenSink } from './KitchenSink'; diff --git a/src/legacy/EditableTextfield/index.js b/src/legacy/EditableTextfield/index.js deleted file mode 100644 index 4b8ed1da41..0000000000 --- a/src/legacy/EditableTextfield/index.js +++ /dev/null @@ -1,194 +0,0 @@ -/** @component editable-textfield */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import omit from 'lodash/omit'; -import { Input } from '@momentum-ui/react-collaboration'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class EditableTextfield extends React.Component { - static displayName = 'EditableTextfield'; - - state = { - isEditing: false, - inputText: this.props.inputText, - }; - - componentDidUpdate = () => { - if (this.state.isEditing && this.editText) { - this.editText.focus(); - } - }; - - handleEnter = (e, value) => { - const { allowEmpty, handleDoneEditing } = this.props; - e.persist(); - - if (!allowEmpty && (!value || !value.replace(/\s/g, ''))) { - this.setState( - { - isEditing: false, - }, - () => handleDoneEditing && handleDoneEditing(e, { value }) - ); - } else { - this.setState( - { - isEditing: false, - inputText: value, - }, - () => handleDoneEditing && handleDoneEditing(e, { value }) - ); - } - - e.nativeEvent.stopImmediatePropagation(); - }; - - handleBlur = (e, value) => { - const { allowEmpty, handleDoneEditing } = this.props; - e.persist(); - - if (!allowEmpty && (!value || !value.replace(/\s/g, ''))) { - this.setState( - { - isEditing: false, - }, - () => handleDoneEditing && handleDoneEditing(e, { value }) - ); - } else { - this.setState( - { - isEditing: false, - inputText: value, - }, - () => handleDoneEditing && handleDoneEditing(e, { value }) - ); - } - }; - - handleEsc = (e) => { - const { value } = e.target; - const handleDoneEditing = this.props.handleDoneEditing; - this.setState( - { - isEditing: false, - }, - () => handleDoneEditing && handleDoneEditing(e, { value }) - ); - e.nativeEvent.stopImmediatePropagation(); - }; - - handleClick = () => { - const { disabled } = this.props; - - if (disabled) { - return; - } else { - this.setState({ - isEditing: true, - }); - } - }; - - handleKey = () => { - const { disabled } = this.props; - - if (disabled) { - return; - } else { - this.setState({ - isEditing: true, - }); - } - }; - - handleDoneKeyDown = (e) => { - if (e.keyCode === 27) { - this.handleEsc(e); - } else if (e.keyCode === 13) { - this.handleEnter(e, e.target.value); - } - }; - - render() { - const { alignment, buttonClassName, buttonProps, className, ...props } = this.props; - const { isEditing, inputText } = this.state; - - const inputProps = omit({ ...props }, [ - 'allowEmpty', - 'disabled', - 'handleDoneEditing', - 'inputText', - ]); - - return ( - - {isEditing && ( - { - this.editText = input; - }} - onDoneEditing={this.handleBlur} - onKeyDown={this.handleDoneKeyDown} - value={inputText} - {...inputProps} - /> - )} - {!isEditing && ( -
      - {inputText || '\u00a0'} -
      - )} -
      - ); - } -} - -EditableTextfield.propTypes = { - /** @prop Alignment css modifier | 'left' */ - alignment: PropTypes.oneOf(['center', 'left', 'right']), - /** @prop Optional prop that prevents input from having null value | true */ - allowEmpty: PropTypes.bool, - /** @prop Optional css class name for internal button | null */ - buttonClassName: PropTypes.string, - /** @prop Optional props for internal button | '' */ - buttonProps: PropTypes.shape({}), - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Sets the disable attribute for EditableTextField | false */ - disabled: PropTypes.bool, - /** @prop Optional function for blur | null */ - handleDoneEditing: PropTypes.func, - /** @prop Text to be shown within input field | null */ - inputText: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), -}; - -EditableTextfield.defaultProps = { - alignment: 'left', - allowEmpty: true, - buttonClassName: '', - buttonProps: null, - className: '', - disabled: false, - handleDoneEditing: null, - inputText: '', -}; - -export default EditableTextfield; diff --git a/src/legacy/EditableTextfield/tests/index.spec.js b/src/legacy/EditableTextfield/tests/index.spec.js deleted file mode 100644 index f348098892..0000000000 --- a/src/legacy/EditableTextfield/tests/index.spec.js +++ /dev/null @@ -1,180 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { EditableTextfield } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should render an Editable Textfield', () => { - const wrapper = shallow(); - - expect(wrapper).toMatchSnapshot(); - }); - - it('should render one Editable Textfield', () => { - const container = shallow(); - - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should click on Editable Textfield', () => { - const container = shallow(); - container.find('.md-editable-textfield__button').simulate('click'); - - expect(container.find('.md-editable-textfield__button').length).toEqual(0); - expect(container.find('Input').length).toEqual(1); - }); - - it('should pass buttonClassName to button', () => { - const container = shallow( - - ); - - expect(container.find('.inputClass').exists()).toEqual(false); - expect(container.find('.buttonClass').exists()).toEqual(true); - }); - - it('should pass className to Input', () => { - const container = shallow( - - ); - container.find('.md-editable-textfield__button').simulate('click'); - - expect(container.find('.buttonClass').exists()).toEqual(false); - expect(container.find('.inputClass').exists()).toEqual(true); - }); - - it('should pass props to Input', () => { - const container = shallow(); - container.find('.md-editable-textfield__button').simulate('click'); - - expect(container.find('Input').props().title).toEqual('testProp'); - }); - - it('should pass buttonProps to button', () => { - const container = shallow(); - - expect(container.find('.md-editable-textfield__button').props().title).toEqual('testProp'); - }); - - it('should pass alignment prop to container', () => { - const container = shallow(); - - expect(container.find('.md-editable-textfield--center').exists()).toEqual(true); - }); - - it('should click on Editable Textfield, edit and save', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: 'Hello World Tom' } }); - container.find('.md-input').simulate('keydown', { - keyCode: 13, - key: 'Enter', - nativeEvent: { stopImmediatePropagation: () => {} }, - }); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('Hello World Tom'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should click on Editable Textfield, edit and exit(escape)', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: 'Hello World Tom' } }); - container.find('.md-input').simulate('keydown', { - keyCode: 27, - key: 'Escape', - nativeEvent: { stopImmediatePropagation: () => {} }, - }); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('Hello World'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should click on Editable Textfield, edit and blur', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: 'Hello World Tom' } }); - container.find('.md-input').simulate('blur'); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('Hello World Tom'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should handle allowEmpty prop with enter key', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: '' } }); - container.find('.md-input').simulate('keydown', { - keyCode: 13, - key: 'Enter', - nativeEvent: { stopImmediatePropagation: () => {} }, - }); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('Hello World'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should handle allowEmpty prop with string of empty spaces', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: ' ' } }); - container.find('.md-input').simulate('keydown', { - keyCode: 13, - key: 'Enter', - nativeEvent: { stopImmediatePropagation: () => {} }, - }); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('Hello World'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should handle allowEmpty prop with blur', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: '' } }); - container.find('.md-input').simulate('blur'); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('Hello World'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should handle empty value with blur', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: '' } }); - container.find('.md-input').simulate('blur'); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('\u00a0'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); - - it('should handle empty value with enter', () => { - const container = mount(); - container.find('.md-editable-textfield__button').simulate('click'); - - container.find('.md-input').simulate('change', { target: { value: '' } }); - container.find('.md-input').simulate('keydown', { - keyCode: 13, - key: 'Enter', - nativeEvent: { stopImmediatePropagation: () => {} }, - }); - - expect(container.find('.md-editable-textfield__button').text()).toEqual('\u00a0'); - expect(container.find('.md-editable-textfield__button').length).toEqual(1); - expect(container.find('Input').length).toEqual(0); - }); -}); diff --git a/src/legacy/EditableTextfield/tests/index.spec.js.snap b/src/legacy/EditableTextfield/tests/index.spec.js.snap deleted file mode 100644 index 67f03a9671..0000000000 --- a/src/legacy/EditableTextfield/tests/index.spec.js.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should render an Editable Textfield 1`] = ` - -
      -   -
      -
      -`; diff --git a/src/legacy/ErrorBoundary/index.js b/src/legacy/ErrorBoundary/index.js deleted file mode 100644 index 7117e94b0b..0000000000 --- a/src/legacy/ErrorBoundary/index.js +++ /dev/null @@ -1,68 +0,0 @@ -/** @component error-boundary */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -/** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class ErrorBoundary extends React.Component { - state = { - error: null, - errorInfo: null, - }; - - componentDidCatch(error, errorInfo) { - this.setState({ - error: error, - errorInfo: errorInfo, - }); - - if (this.props.errorCallback) { - this.props.errorCallback(error, errorInfo); - } - } - - render() { - const { error, errorInfo } = this.state; - const { children, fallbackComponent } = this.props; - - const errorComponent = () => - fallbackComponent ? ( - React.cloneElement(fallbackComponent, { - error: error, - errorInfo: errorInfo, - }) - ) : ( -
      -

      Something went wrong.

      -
      - {error && error.toString()} -
      - {errorInfo.componentStack} -
      -
      - ); - - return errorInfo ? errorComponent() : children; - } -} - -ErrorBoundary.propTypes = { - /** @prop Children nodes to render inside the ErrorBoundary | null */ - children: PropTypes.node, - /** @prop Callback function invoked when an error has occured | null */ - errorCallback: PropTypes.func, - /** @prop Sets a backup Component in the case of a failure | null */ - fallbackComponent: PropTypes.node, -}; - -ErrorBoundary.defaultProps = { - children: null, - errorCallback: null, - fallbackComponent: null, -}; - -ErrorBoundary.displayName = 'ErrorBoundary'; - -export default ErrorBoundary; diff --git a/src/legacy/ErrorBoundary/tests/index.spec.js b/src/legacy/ErrorBoundary/tests/index.spec.js deleted file mode 100644 index 759eaf523c..0000000000 --- a/src/legacy/ErrorBoundary/tests/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { ErrorBoundary } from '@momentum-ui/react-collaboration'; - -describe('tests for ', () => { - it('should match SnapShot', () => { - const container = mount(); - - expect(container).toMatchSnapshot(); - }); - - it('should render one ErrorBoundary', () => { - const container = shallow(); - - expect(container.html()).toEqual(null); - }); - - it('should render children', () => { - const container = shallow( - -
      - - ); - - expect(container.find('.testingforTC').length).toEqual(1); - }); -}); diff --git a/src/legacy/ErrorBoundary/tests/index.spec.js.snap b/src/legacy/ErrorBoundary/tests/index.spec.js.snap deleted file mode 100644 index 54d612d40b..0000000000 --- a/src/legacy/ErrorBoundary/tests/index.spec.js.snap +++ /dev/null @@ -1,8 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tests for should match SnapShot 1`] = ` - -`; diff --git a/src/legacy/EventOverlay/examples/KitchenSink.js b/src/legacy/EventOverlay/examples/KitchenSink.js deleted file mode 100644 index 1bd41ef166..0000000000 --- a/src/legacy/EventOverlay/examples/KitchenSink.js +++ /dev/null @@ -1,808 +0,0 @@ -import React, { forwardRef } from 'react'; - -import { - Avatar, - Button, - Coachmark, - ComboBox, - DatePicker, - EditableTextfield, - Input, - Label, - List, - ListItem, - ListItemMeeting, - ListItemSection, - Menu, - MenuContent, - MenuItem, - MenuOverlay, - Popover, - Select, - SelectOption, - SubMenu, - ToggleSwitch, -} from '@momentum-ui/react-collaboration'; -import ButtonCircle from '../../../components/ButtonCircle'; -import IconNext from '../../../components/Icon'; -import { AutoSizer as CAutoSizer, List as Clist } from 'react-virtualized'; -import { FixedSizeList } from 'react-window'; -import AutoSizer from 'react-virtualized-auto-sizer'; - -class EventOverlayKitchenSink extends React.Component { - state = { - boundingParentID: '', - isCoachmarkOpen: false, - isContained: 'vertical', - checkOverflow: false, - direction: 'top-center', - loadingDiv: true, - portalNode: '', - scrollParentID: '', - showArrow: true, - showPopoverExamples: true, - targetOffset: { horizontal: 0, vertical: 0 }, - }; - - render() { - const { - boundingParentID, - isCoachmarkOpen, - isContained, - checkOverflow, - direction, - loadingDiv, - portalNode, - scrollParentID, - showArrow, - showPopoverExamples, - targetOffset, - } = this.state; - - const rowRenderer = ({ index, style }, ...args) => ( - - - - {getPopover(h1600w1900, index, ...args)} - - - ); - - const getListItem = (popover, label) => ( - - {getPopover(popover)} - {label} - - ); - - const getPopover = (node, buttonLabel, other) => ( - - {other?.isButtonCircle ? ( - - - - ) : ( - - )} - - ); - - const loadingExample = loadingDiv ? ( -
      Loading
      - ) : ( - - ); - - const simpleDiv = ( -
      - Robs poppity poppity Popover - {loadingExample} -
      - ); - - const h500 = ( -
      - Popover(height: 500px) - {loadingExample} -
      - ); - const h1800 = ( -
      - Popover(height: 1800px) - {loadingExample} -
      - ); - const h3000 = ( -
      - Popover(height: 3000px) - {loadingExample} -
      - ); - const h30w1600 = ( -
      - Popover(height: 30px, width: 1600px) - {loadingExample} -
      - ); - const h1600w1900 = ( -
      - Popover(height: 1900px, width: 1600px) - {loadingExample} -
      - ); - const w100 = ( -
      - Popover(width: 100px) - {loadingExample} -
      - ); - - const varyingContent = ( - - {getListItem(simpleDiv, 'Simple Div')} - {getListItem(h500, '500px Tall Popover')} - {getListItem(h1800, '1800px Tall Popover')} - {getListItem(h3000, '3000px Tall Popover')} - {getListItem(w100, '100px Wide Popover')} - {getListItem(h30w1600, '1600px Wide Popover')} - {getListItem(h1600w1900, '1600px Tall, 1900px Wide Popover')} - - ); - - const popoverExamples = ( - - {getPopover(simpleDiv, 'div')} - {getPopover(h500, 'h500')} - {getPopover(h1800, 'h1800')} - {getPopover(h3000, 'h3000')} - {getPopover(w100, 'w100')} - {getPopover(h30w1600, 'h30w1600')} - {getPopover(h1600w1900, 'h1600w1900')} - - ); - - return ( -
      -
      -

      Toggle Options

      - this.setState({ loadingDiv: !loadingDiv })} - /> - this.setState({ checkOverflow: !checkOverflow })} - /> - this.setState({ showArrow: !showArrow })} - /> - this.setState({ showPopoverExamples: !showPopoverExamples })} - /> - - this.setState((state) => ({ - ...state, - targetOffset: { - ...state.targetOffset.vertical, - horizontal: 20, - }, - })) - } - /> - - this.setState((state) => ({ - targetOffset: { - ...state.targetOffset.horizontal, - vertical: 20, - }, - })) - } - /> -
      - this.setState({ portalNode: e.target.value })} - clear - /> - this.setState({ boundingParentID: e.target.value })} - clear - /> - this.setState({ scrollParentID: e.target.value })} - clear - /> - - - - -
      -
      - -
      - - {showPopoverExamples && ( - -
      -
      Popover Examples
      - - {getPopover(simpleDiv, 'Hover', { - popoverTrigger: 'MouseEnter', - })} - {getPopover(simpleDiv, 'Delay', { - popoverTrigger: 'MouseEnter', - delay: 500, - })} - {getPopover(simpleDiv, 'Click')} - {getPopover(simpleDiv, 'No Toggle', { - doesAnchorToggle: false, - })} - {getPopover(simpleDiv, 'AlwaysOpen', { - popoverTrigger: 'None', - doesAnchorToggle: false, - startOpen: true, - allowClickAway: false, - })} - {getPopover(simpleDiv, 'Focus', { popoverTrigger: 'Focus' })} - {getPopover(simpleDiv, 'Click', { isButtonCircle: true })} - -
      -
      - - )} - -
      -
      Input with Popover
      - - - -
      - -
      - -
      -
      List with Popovers, Overflow Auto
      -
      {varyingContent}
      -
      - -
      - -
      -
      List using React Virtualized (checkOverflow should be false)
      -
      - - {({ width, height }) => ( - - )} - -
      -
      - -
      - -
      -
      List using React-Window (checkOverflow should be false)
      -
      - - {({ width, height }) => ( - ( -
      - ))} - /* eslint-enable react/display-name, react/no-multi-comp */ - > - {rowRenderer} - - )} - -
      -
      - -
      - -
      -
      Absolute Container, No Overflow
      -
      -
      - {popoverExamples} -
      -
      -
      - -
      - -
      -
      Absolute Container, Overflow
      -
      -
      - {popoverExamples} -
      -
      -
      - -
      - -
      -
      Various Popover Examples
      - {popoverExamples} -
      - -
      - -
      -
      Overflow Container
      -
      -
      - {popoverExamples} -
      -
      -
      - -
      - -
      -
      Coachmark
      - {}} - onClose={() => { - this.setState({ isCoachmarkOpen: false }); - }} - > - - -
      - -
      - -
      -
      ComboBox
      - -
      - -
      - -
      -
      DatePicker
      - -
      - -
      - -
      -
      ListItemMeeting
      - alert('anchor clicked')} - childrenRight={} - popoverContent={'test'} - /> -
      - -
      - -
      -
      MenuOverlay
      - Show Menu}> - - - - - - - - - - - - - - - - - -
      - -
      - -
      -
      -
      - Top Section -
      -
      - {popoverExamples} -
      -
      - Bottom Section -
      -
      -
      - -
      -
      -
      - WITH Transform -
      -
      -
      - {popoverExamples} -
      -
      -
      - Bottom Section -
      -
      -
      - -
      -
      -
      - No Overflow -
      -
      - {popoverExamples} -
      -
      - Bottom Section -
      -
      -
      -
      - ); - } -} - -EventOverlayKitchenSink.displayName = 'EventOverlayPlayground'; - -export default EventOverlayKitchenSink; diff --git a/src/legacy/EventOverlay/examples/KitchenSink.stories.tsx b/src/legacy/EventOverlay/examples/KitchenSink.stories.tsx deleted file mode 100644 index e70a118f10..0000000000 --- a/src/legacy/EventOverlay/examples/KitchenSink.stories.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import LegacyKitchenSink from './KitchenSink'; -import React from 'react'; - -export default { - title: 'Legacy/EventOverlay', - component: LegacyKitchenSink, -}; - -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -const Legacy = () => ; - -export { Legacy }; diff --git a/src/legacy/EventOverlay/examples/index.js b/src/legacy/EventOverlay/examples/index.js deleted file mode 100644 index 96df7c5ace..0000000000 --- a/src/legacy/EventOverlay/examples/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default as EventOverlayKitchenSink } from './KitchenSink'; diff --git a/src/legacy/EventOverlay/tests/index.spec.js b/src/legacy/EventOverlay/tests/index.spec.js index 4b3d90d0bf..837e813f94 100644 --- a/src/legacy/EventOverlay/tests/index.spec.js +++ b/src/legacy/EventOverlay/tests/index.spec.js @@ -1,6 +1,7 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Button, EventOverlay, Popover } from '@momentum-ui/react-collaboration'; +import { Button, Popover } from '@momentum-ui/react-collaboration'; +import EventOverlay from '..'; import { ButtonPill } from '../../../components'; describe('tests for ', () => { diff --git a/src/legacy/Footer/index.js b/src/legacy/Footer/index.js deleted file mode 100644 index 96f0bc21d3..0000000000 --- a/src/legacy/Footer/index.js +++ /dev/null @@ -1,58 +0,0 @@ -/** @component footer */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -export default /** - * @deprecated - Components in the legacy folder (/src/legacy) are deprecated. Please use a component from the components folder (/src/components) instead. Legacy components may not follow accessibility standards. - **/ -class Footer extends React.Component { - render() { - const { color, logo, copyright, social, className, children } = this.props; - const footerTopSection = children &&
      {children}
      ; - const footerBottomSection = (logo || copyright || social) && ( -
      - {(logo || copyright) && ( - - {logo} - {copyright} - - )} - {social && {social}} -
      - ); - - return ( -
      - {footerTopSection} - {footerBottomSection} -
      - ); - } -} - -Footer.propTypes = { - /** @prop Children nodes to render inside the Footer | null */ - children: PropTypes.node, - /** @prop Optional css class string | '' */ - className: PropTypes.string, - /** @prop Optional color css styling | 'dark' */ - color: PropTypes.string, - /** @prop Set the copyright within the Footer | '' */ - copyright: PropTypes.string, - /** @prop Set the logo within the Footer | null */ - logo: PropTypes.node, - /** @prop Node containing social media links | null */ - social: PropTypes.node, -}; - -Footer.defaultProps = { - children: null, - className: '', - color: 'dark', - copyright: '', - logo: null, - social: null, -}; - -Footer.displayName = 'Footer'; diff --git a/src/legacy/Footer/tests/index.spec.js b/src/legacy/Footer/tests/index.spec.js deleted file mode 100644 index 366ae3f798..0000000000 --- a/src/legacy/Footer/tests/index.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import { Footer } from '@momentum-ui/react-collaboration'; - -describe('tests for