Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(package): use keyboard-key package #2707

Merged
merged 5 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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