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

Packages: Add a new compose package #7948

Merged
merged 6 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions components/autocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import 'element-closest';
/**
* WordPress dependencies
*/
import { Component, compose, renderToString } from '@wordpress/element';
import { Component, renderToString } from '@wordpress/element';
import { ENTER, ESCAPE, UP, DOWN, LEFT, RIGHT, SPACE } from '@wordpress/keycodes';
import { __, _n, sprintf } from '@wordpress/i18n';
import { withInstanceId, compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -19,7 +20,6 @@ import './style.scss';
import withFocusOutside from '../higher-order/with-focus-outside';
import Button from '../button';
import Popover from '../popover';
import withInstanceId from '../higher-order/with-instance-id';
import withSpokenMessages from '../higher-order/with-spoken-messages';

/**
Expand Down
6 changes: 5 additions & 1 deletion components/checkbox-control/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* External dependencies
*/
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import BaseControl from '../base-control';
import withInstanceId from '../higher-order/with-instance-id';
import './style.scss';

function CheckboxControl( { label, className, heading, checked, help, instanceId, onChange, ...props } ) {
Expand Down
35 changes: 35 additions & 0 deletions components/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* External dependencies
*/
import { mapValues } from 'lodash';

/**
* WordPress dependencies
*/
import {
ifCondition,
withGlobalEvents,
withInstanceId,
withSafeTimeout,
withState,
} from '@wordpress/compose';
import deprecated from '@wordpress/deprecated';

const deprecatedFunctions = {
ifCondition,
withGlobalEvents,
withInstanceId,
withSafeTimeout,
withState,
};

export default mapValues( deprecatedFunctions, ( deprecatedFunction, key ) => {
return ( ...args ) => {
deprecated( 'wp.components.' + key, {
Copy link
Member

@aduth aduth Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically our deprecated ESLint rule has stumbled spectacularly on any sort of cleverness. Did we check to see how this works (re: the concatenation)?

Also, with "complications" like the need to remove exports from index.js which is not entirely obvious by this deprecation call alone, it would be good to have included a comment noting said needs to the future maintainer.

version: '3.5',
alternative: 'wp.compose.' + key,
} );

return deprecatedFunction( ...args );
};
} );
2 changes: 1 addition & 1 deletion components/draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import classnames from 'classnames';
* WordPress Dependencies
*/
import { Component } from '@wordpress/element';
import { withSafeTimeout } from '@wordpress/compose';

/**
* Internal Dependencies
*/
import withSafeTimeout from '../higher-order/with-safe-timeout';
import './style.scss';

const dragImageClass = 'components-draggable__invisible-drag-image';
Expand Down
6 changes: 1 addition & 5 deletions components/focusable-iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { omit } from 'lodash';
* WordPress dependencies
*/
import { Component, createRef } from '@wordpress/element';

/**
* Internal dependencies
*/
import withGlobalEvents from '../higher-order/with-global-events';
import { withGlobalEvents } from '@wordpress/compose';

/**
* Browser dependencies
Expand Down
2 changes: 1 addition & 1 deletion components/form-token-field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import classnames from 'classnames';
*/
import { __, _n, sprintf } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -17,7 +18,6 @@ import './style.scss';
import Token from './token';
import TokenInput from './token-input';
import SuggestionsList from './suggestions-list';
import withInstanceId from '../higher-order/with-instance-id';
import withSpokenMessages from '../higher-order/with-spoken-messages';

const initialState = {
Expand Down
2 changes: 1 addition & 1 deletion components/form-token-field/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { noop } from 'lodash';
/**
* WordPress dependencies
*/
import withInstanceId from '../higher-order/with-instance-id';
import { withInstanceId } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';

/**
Expand Down
16 changes: 11 additions & 5 deletions components/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Internal dependencies
*/
import deprecated from './deprecated';

// Components
export { default as APIProvider } from './higher-order/with-api-data/provider';
export { default as Autocomplete } from './autocomplete';
Expand Down Expand Up @@ -57,7 +62,6 @@ export { default as TreeSelect } from './tree-select';
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill';

// Higher-Order Components
export { default as ifCondition } from './higher-order/if-condition';
export { default as navigateRegions } from './higher-order/navigate-regions';
export { default as withAPIData } from './higher-order/with-api-data';
export { default as withContext } from './higher-order/with-context';
Expand All @@ -66,9 +70,11 @@ export { default as withFallbackStyles } from './higher-order/with-fallback-styl
export { default as withFilters } from './higher-order/with-filters';
export { default as withFocusOutside } from './higher-order/with-focus-outside';
export { default as withFocusReturn } from './higher-order/with-focus-return';
export { default as withGlobalEvents } from './higher-order/with-global-events';
export { default as withInstanceId } from './higher-order/with-instance-id';
export { default as withNotices } from './higher-order/with-notices';
export { default as withSafeTimeout } from './higher-order/with-safe-timeout';
export { default as withSpokenMessages } from './higher-order/with-spoken-messages';
export { default as withState } from './higher-order/with-state';

export const ifCondition = deprecated.ifCondition;
export const withGlobalEvents = deprecated.withGlobalEvents;
export const withInstanceId = deprecated.withInstanceId;
export const withSafeTimeout = deprecated.withSafeTimeout;
export const withState = deprecated.withState;
2 changes: 1 addition & 1 deletion components/menu-group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import classnames from 'classnames';
*/
import { Children } from '@wordpress/element';
import { applyFilters } from '@wordpress/hooks';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import './style.scss';
import { NavigableMenu } from '../navigable-container';
import withInstanceId from '../higher-order/with-instance-id';

export function MenuGroup( {
children,
Expand Down
4 changes: 2 additions & 2 deletions components/modal/frame.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* WordPress dependencies
*/
import { Component, compose, createRef } from '@wordpress/element';
import { Component, createRef } from '@wordpress/element';
import { ESCAPE } from '@wordpress/keycodes';
import { focus } from '@wordpress/dom';
import { withGlobalEvents, compose } from '@wordpress/compose';

/**
* External dependencies
Expand All @@ -16,7 +17,6 @@ import clickOutside from 'react-click-outside';
import './style.scss';
import withFocusReturn from '../higher-order/with-focus-return';
import withConstrainedTabbing from '../higher-order/with-constrained-tabbing';
import withGlobalEvents from '../higher-order/with-global-events';

class ModalFrame extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion components/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { noop } from 'lodash';
* WordPress dependencies
*/
import { Component, createPortal } from '@wordpress/element';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -16,7 +17,6 @@ import './style.scss';
import ModalFrame from './frame';
import ModalHeader from './header';
import * as ariaHelper from './aria-helper';
import withInstanceId from '../higher-order/with-instance-id';

// Used to count the number of open modals.
let parentElement,
Expand Down
6 changes: 5 additions & 1 deletion components/radio-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import { isEmpty } from 'lodash';
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import BaseControl from '../base-control';
import withInstanceId from '../higher-order/with-instance-id';
import './style.scss';

function RadioControl( { label, className, selected, help, instanceId, onChange, options = [] } ) {
Expand Down
2 changes: 1 addition & 1 deletion components/range-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import { BaseControl, Button, Dashicon } from '../';
import withInstanceId from '../higher-order/with-instance-id';
import './style.scss';

function RangeControl( {
Expand Down
4 changes: 2 additions & 2 deletions components/sandbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* WordPress dependencies
*/
import { Component, renderToString, createRef } from '@wordpress/element';
import { withGlobalEvents } from '@wordpress/compose';

/**
* Internal dependencies
*/
import FocusableIframe from '../focusable-iframe';
import withGlobalEvents from '../higher-order/with-global-events';

class Sandbox extends Component {
constructor() {
Expand Down Expand Up @@ -151,7 +151,7 @@ class Sandbox extends Component {
aspectRatio = potentialIframe.width / potentialIframe.height;
potentialIframe.width = '100%';
}
}
}

sendResize();

Expand Down
6 changes: 5 additions & 1 deletion components/select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
*/
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import BaseControl from '../base-control';
import withInstanceId from '../higher-order/with-instance-id';
import './style.scss';

function SelectControl( {
Expand Down
2 changes: 1 addition & 1 deletion components/tab-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { partial, noop, find } from 'lodash';
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import { default as withInstanceId } from '../higher-order/with-instance-id';
import { NavigableMenu } from '../navigable-container';

const TabButton = ( { tabId, onClick, children, selected, ...rest } ) => (
Expand Down
6 changes: 5 additions & 1 deletion components/text-control/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* WordPress dependencies
*/
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import BaseControl from '../base-control';
import withInstanceId from '../higher-order/with-instance-id';
import './style.scss';

function TextControl( { label, value, help, className, instanceId, onChange, type = 'text', ...props } ) {
Expand Down
6 changes: 5 additions & 1 deletion components/textarea-control/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* WordPress dependencies
*/
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import BaseControl from '../base-control';
import withInstanceId from '../higher-order/with-instance-id';
import './style.scss';

function TextareaControl( { label, value, help, instanceId, onChange, rows = 4, className, ...props } ) {
Expand Down
4 changes: 2 additions & 2 deletions components/toggle-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { isFunction } from 'lodash';
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import FormToggle from '../form-toggle';
import withInstanceId from '../higher-order/with-instance-id';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
*/
import FormToggle from '../form-toggle';
import BaseControl from './../base-control';
import './style.scss';

Expand Down
3 changes: 2 additions & 1 deletion core-blocks/block/edit-panel/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/**
* WordPress dependencies
*/
import { Button, withInstanceId } from '@wordpress/components';
import { Button } from '@wordpress/components';
import { Component, Fragment, createRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { ESCAPE } from '@wordpress/keycodes';
import { withInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down
3 changes: 2 additions & 1 deletion core-blocks/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { noop, partial } from 'lodash';
/**
* WordPress dependencies
*/
import { Component, Fragment, compose } from '@wordpress/element';
import { Component, Fragment } from '@wordpress/element';
import { Placeholder, Spinner, Disabled } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { BlockEdit } from '@wordpress/editor';
import { compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down
3 changes: 2 additions & 1 deletion core-blocks/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import {
withNotices,
} from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { Component, compose, Fragment } from '@wordpress/element';
import { Component, Fragment } from '@wordpress/element';
import {
MediaUpload,
MediaPlaceholder,
BlockControls,
RichText,
editorMediaUpload,
} from '@wordpress/editor';
import { compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down
3 changes: 2 additions & 1 deletion core-blocks/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*/
import { RawHTML } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { withState, Disabled, SandBox, CodeEditor } from '@wordpress/components';
import { Disabled, SandBox, CodeEditor } from '@wordpress/components';
import { getPhrasingContentSchema } from '@wordpress/blocks';
import { BlockControls } from '@wordpress/editor';
import { withState } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down
Loading