Skip to content

Commit

Permalink
chore(package): use keyboard-key package (#2707)
Browse files Browse the repository at this point in the history
* chore(package): use keyboard-key package

* chore(package): use keyboard-key

* chore(lint): disable noisable eslint rule
  • Loading branch information
levithomason authored Apr 30, 2018
1 parent 94e5684 commit d57b054
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 572 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"jsx-quotes": [2, "prefer-single"],
"max-len": [2, 120, 4],
"no-console": 2,
"no-mixed-operators": 0,
"no-multi-spaces": [2, { "ignoreEOLComments": true }],
"no-return-assign": [2, "except-parens"],
"no-underscore-dangle": 0,
Expand Down
3 changes: 2 additions & 1 deletion docs/app/Components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import keyboardKey from 'keyboard-key'
import _ from 'lodash/fp'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
Expand All @@ -14,7 +15,7 @@ import CarbonAd from 'docs/app/Components/CarbonAd/CarbonAd'
import Logo from 'docs/app/Components/Logo/Logo'
import { typeOrder, parentComponents, repoURL } from 'docs/app/utils'
import pkg from 'package.json'
import { keyboardKey, META } from 'src/lib'
import { META } from 'src/lib'

const getRoute = _meta => `/${_meta.type}s/${_.kebabCase(_meta.name)}`

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"babel-runtime": "^6.25.0",
"classnames": "^2.2.5",
"fbjs": "^0.8.16",
"keyboard-key": "^1.0.1",
"lodash": "^4.17.4",
"prop-types": "^15.5.10"
},
Expand Down
16 changes: 3 additions & 13 deletions src/addons/Pagination/PaginationItem.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import keyboardKey from 'keyboard-key'
import _ from 'lodash'
import PropTypes from 'prop-types'
import { Component } from 'react'

import {
createShorthandFactory,
keyboardKey,
META,
} from '../../lib'
import { createShorthandFactory, META } from '../../lib'
import MenuItem from '../../collections/Menu/MenuItem'

/**
Expand Down Expand Up @@ -37,14 +34,7 @@ class PaginationItem extends Component {
onKeyDown: PropTypes.func,

/** A pagination should have a type. */
type: PropTypes.oneOf([
'ellipsisItem',
'firstItem',
'prevItem',
'pageItem',
'nextItem',
'lastItem',
]),
type: PropTypes.oneOf(['ellipsisItem', 'firstItem', 'prevItem', 'pageItem', 'nextItem', 'lastItem']),
}

static _meta = {
Expand Down
29 changes: 10 additions & 19 deletions src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import keyboardKey from 'keyboard-key'
import _ from 'lodash'
import PropTypes from 'prop-types'
import React, { Children, cloneElement } from 'react'
Expand All @@ -8,7 +9,6 @@ import {
doesNodeContainClick,
eventStack,
isBrowser,
keyboardKey,
makeDebugger,
META,
} from '../../lib'
Expand Down Expand Up @@ -134,9 +134,7 @@ class Portal extends Component {
openOnTriggerClick: true,
}

static autoControlledProps = [
'open',
]
static autoControlledProps = ['open']

static _meta = {
name: 'Portal',
Expand Down Expand Up @@ -179,11 +177,11 @@ class Portal extends Component {
const { closeOnDocumentClick, closeOnRootNodeClick } = this.props

if (
!this.rootNode // not mounted
|| !this.portalNode // no portal
|| doesNodeContainClick(this.triggerNode, e) // event happened in trigger (delegate to trigger handlers)
|| doesNodeContainClick(this.portalNode, e) // event happened in the portal
) return // ignore the click
!this.rootNode || // not mounted
!this.portalNode || // no portal
doesNodeContainClick(this.triggerNode, e) || // event happened in trigger (delegate to trigger handlers)
doesNodeContainClick(this.portalNode, e) // event happened in the portal
) { return } // ignore the click

const didClickInRootNode = doesNodeContainClick(this.rootNode, e)

Expand Down Expand Up @@ -359,11 +357,8 @@ class Portal extends Component {
eventStack.unsub('mouseenter', this.handlePortalMouseEnter, { pool: eventPool, target: this.portalNode })
}

ReactDOM.unstable_renderSubtreeIntoContainer(
this,
Children.only(children),
this.rootNode,
() => this.attachRenderSubTreeSubscribers(eventPool),
ReactDOM.unstable_renderSubtreeIntoContainer(this, Children.only(children), this.rootNode, () =>
this.attachRenderSubTreeSubscribers(eventPool),
)
}

Expand All @@ -383,11 +378,7 @@ class Portal extends Component {

debug('mountPortal()')

const {
eventPool,
mountNode = isBrowser() ? document.body : null,
prepend,
} = this.props
const { eventPool, mountNode = isBrowser() ? document.body : null, prepend } = this.props

this.rootNode = document.createElement('div')

Expand Down
1 change: 0 additions & 1 deletion src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export * as META from './META'
export createPaginationItems from './createPaginationItems'
export * as SUI from './SUI'

export { default as keyboardKey } from './keyboardKey'
export { numberToWordMap, numberToWord } from './numberToWord'
export normalizeOffset from './normalizeOffset'
export normalizeTransitionDuration from './normalizeTransitionDuration'
Expand Down
Loading

0 comments on commit d57b054

Please sign in to comment.