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

Update @wordpress/components #65576

Merged
merged 4 commits into from
Jul 18, 2022
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
2 changes: 1 addition & 1 deletion apps/editing-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@wordpress/base-styles": "^4.5.0",
"@wordpress/block-editor": "^9.1.0",
"@wordpress/blocks": "^11.8.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/data": "^6.9.0",
"@wordpress/data-controls": "^2.9.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/o2-blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@wordpress/base-styles": "^4.5.0",
"@wordpress/block-editor": "^9.1.0",
"@wordpress/blocks": "^11.8.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/data": "^6.9.0",
"@wordpress/editor": "^12.8.0",
"@wordpress/element": "^4.7.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/wpcom-block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@wordpress/base-styles": "^4.5.0",
"@wordpress/block-editor": "^9.1.0",
"@wordpress/blocks": "^11.8.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/data": "^6.9.0",
"@wordpress/dom-ready": "^3.9.0",
Expand Down
21 changes: 11 additions & 10 deletions client/lib/protect-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
import debugModule from 'debug';
import i18n from 'i18n-calypso';
import page from 'page';
import { useRef, useCallback, useEffect } from 'react';
import { useRef, useCallback, useEffect, ComponentType } from 'react';

/**
* Module variables
Expand Down Expand Up @@ -79,15 +79,16 @@ export interface ProtectedFormProps {
/*
* HOC that passes markChanged/markSaved props to the wrapped component instance
*/
export const protectForm = createHigherOrderComponent< ProtectedFormProps >( ( InnerComponent ) => {
return ( props ) => {
const { markChanged, markSaved } = useProtectForm();
const innerProps = { ...props, markChanged, markSaved } as React.ComponentProps<
typeof InnerComponent
>;
return <InnerComponent { ...innerProps } />;
};
}, 'protectForm' );
export const protectForm = createHigherOrderComponent(
< OuterProps, >( InnerComponent: ComponentType< OuterProps & ProtectedFormProps > ) => {
return ( props: OuterProps ) => {
const { markChanged, markSaved } = useProtectForm();
const innerProps = { ...props, markChanged, markSaved };
return <InnerComponent { ...innerProps } />;
};
},
'protectForm'
);

/*
* Declarative variant that takes a 'isChanged' prop.
Expand Down
18 changes: 10 additions & 8 deletions client/lib/route-modal/with-route-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { createHigherOrderComponent } from '@wordpress/compose';
import useRouteModal, { RouteModalData } from './use-route-modal';
import type { ComponentType } from 'react';

export default function withRouteModal( queryKey: string, defaultValue?: string ) {
return createHigherOrderComponent< { routeModalData: RouteModalData } >(
( InnerComponent ) => ( props ) => {
const routeModalData = useRouteModal( queryKey, defaultValue );
const innerProps = { ...props, routeModalData } as React.ComponentProps<
typeof InnerComponent
>;
return <InnerComponent { ...innerProps } />;
},
return createHigherOrderComponent(
< OuterProps, >(
InnerComponent: ComponentType< OuterProps & { routeModalData: RouteModalData } >
) =>
( props: OuterProps ) => {
const routeModalData = useRouteModal( queryKey, defaultValue );
const innerProps = { ...props, routeModalData };
return <InnerComponent { ...innerProps } />;
},
'WithRouteModal'
);
}
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@wordpress/base-styles": "^4.5.0",
"@wordpress/block-editor": "^9.1.0",
"@wordpress/blocks": "^11.8.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/data": "^6.9.0",
"@wordpress/data-controls": "^2.9.0",
Expand Down
8 changes: 4 additions & 4 deletions docs/dependency-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ yarn remove -w lodash
Run

```
yarn upgrade <package>
yarn up <package>

# Example
# yarn upgrade react-query
# yarn up react-query
```

Note that this won't change the required range of `react-query` (i.e. it won't modify `package.json`). Instead, it will try to update `react-query` and any of its dependencies to the highest version that satisfies the specified range.
Expand All @@ -91,10 +91,10 @@ For example, if we declare a dependency on `react-query@^2.24.0` it may update r
Run

```
yarn upgrade <package>@^<semver-range>
yarn up <package>@^<semver-range>

# Example
# yarn upgrade react-query@^3.0.0
# yarn up react-query@^3.0.0
```

As before, it will update `react-query` and all its dependencies. But in this case, it _will_ change the required range (i.e. it will modify `package.json`)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"@types/wordpress__data-controls": "^2.2.0",
"@types/wordpress__editor": "^10.0.1",
"@wordpress/base-styles": "^4.5.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/data": "^6.9.0",
"@wordpress/element": "^4.7.0",
"@wordpress/i18n": "^4.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/design-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@automattic/js-utils": "workspace:^",
"@automattic/onboarding": "workspace:^",
"@automattic/typography": "workspace:^",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/react-i18n": "^3.7.0",
"@wordpress/url": "^3.10.0",
"classnames": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/domain-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@automattic/onboarding": "workspace:^",
"@automattic/typography": "workspace:^",
"@wordpress/base-styles": "^4.5.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/icons": "^9.0.0",
"@wordpress/react-i18n": "^3.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/help-center/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@automattic/viewport-react": "workspace:^",
"@popperjs/core": "^2.10.2",
"@wordpress/base-styles": "^4.5.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/i18n": "^4.9.0",
"@wordpress/icons": "^9.0.0",
"@wordpress/primitives": "^3.7.0",
Expand Down
17 changes: 10 additions & 7 deletions packages/i18n-utils/src/locale-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,16 @@ export function useLocale(): string {
* }
* export default withLocale( MyComponent );
*/
export const withLocale = createHigherOrderComponent< { locale: string } >( ( InnerComponent ) => {
return ( props ) => {
const locale = useLocale();
const innerProps = { ...props, locale } as React.ComponentProps< typeof InnerComponent >;
return <InnerComponent { ...innerProps } />;
};
}, 'withLocale' );
export const withLocale = createHigherOrderComponent(
< OuterProps, >( InnerComponent: React.ComponentType< OuterProps & { locale: string } > ) => {
return ( props: OuterProps ) => {
const locale = useLocale();
const innerProps = { ...props, locale };
return <InnerComponent { ...innerProps } />;
};
},
'withLocale'
);

/**
* React hook providing whether the current locale slug belongs to English or not
Expand Down
25 changes: 15 additions & 10 deletions packages/i18n-utils/src/localize-url.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHigherOrderComponent } from '@wordpress/compose';
import { getLocaleSlug } from 'i18n-calypso';
import { useCallback } from 'react';
import { useCallback, ComponentType } from 'react';
import { useLocale } from './locale-context';
import {
localesWithBlog,
Expand Down Expand Up @@ -217,12 +217,17 @@ export function useLocalizeUrl() {
);
}

export const withLocalizeUrl = createHigherOrderComponent< {
localizeUrl: ReturnType< typeof useLocalizeUrl >;
} >( ( InnerComponent ) => {
return ( props ) => {
const localizeUrl = useLocalizeUrl();
const innerProps = { ...props, localizeUrl } as React.ComponentProps< typeof InnerComponent >;
return <InnerComponent { ...innerProps } />;
};
}, 'withLocalizeUrl' );
export const withLocalizeUrl = createHigherOrderComponent(
< OuterProps, >(
InnerComponent: ComponentType<
OuterProps & { localizeUrl: ReturnType< typeof useLocalizeUrl > }
>
) => {
return ( props: OuterProps ) => {
const localizeUrl = useLocalizeUrl();
const innerProps = { ...props, localizeUrl };
return <InnerComponent { ...innerProps } />;
};
},
'withLocalizeUrl'
);
2 changes: 1 addition & 1 deletion packages/language-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@automattic/search": "workspace:^",
"@babel/runtime": "^7.17.2",
"@wordpress/base-styles": "^4.5.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/i18n": "^4.9.0",
"@wordpress/react-i18n": "^3.7.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/launch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@automattic/onboarding": "workspace:^",
"@automattic/plans-grid": "workspace:^",
"@automattic/shopping-cart": "workspace:^",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/icons": "^9.0.0",
"@wordpress/react-i18n": "^3.7.0",
"@wordpress/url": "^3.10.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@automattic/components": "workspace:^",
"@automattic/data-stores": "workspace:^",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/data": "^6.9.0",
"@wordpress/icons": "^9.0.0",
"@wordpress/react-i18n": "^3.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/page-pattern-modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@automattic/onboarding": "workspace:^",
"@automattic/typography": "workspace:^",
"@wordpress/blocks": "^11.8.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/element": "^4.7.0",
"@wordpress/i18n": "^4.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface PagePatternModalProps {
areTipsEnabled?: boolean;
hideWelcomeGuide: () => void;
insertPattern: ( title: string | null, blocks: unknown[] ) => void;
instanceId: number;
instanceId: string | number;
isOpen: boolean;
isWelcomeGuideActive?: boolean;
locale?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { PatternDefinition } from '../pattern-definition';
const noop = () => undefined;

interface PatternSelectorControlProps {
instanceId: number;
instanceId: string | number;
label: string;
legendLabel?: string;
locale?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/plans-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@automattic/data-stores": "workspace:^",
"@automattic/i18n-utils": "workspace:^",
"@automattic/onboarding": "workspace:^",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/icons": "^9.0.0",
"@wordpress/primitives": "^3.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@automattic/typography": "workspace:^",
"@babel/runtime": "^7.17.2",
"@wordpress/base-styles": "^4.5.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/compose": "^5.7.0",
"@wordpress/icons": "^9.0.0",
"@wordpress/react-i18n": "^3.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/social-previews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"@emotion/react": "^11.4.1",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/i18n": "^4.9.0",
"classnames": "^2.3.1",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/tour-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@automattic/viewport-react": "workspace:^",
"@popperjs/core": "^2.10.2",
"@wordpress/base-styles": "^4.5.0",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/dom": "^3.9.0",
"@wordpress/element": "^4.7.0",
"@wordpress/i18n": "^4.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/whats-new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@automattic/components": "workspace:^",
"@automattic/i18n-utils": "workspace:^",
"@automattic/typography": "workspace:^",
"@wordpress/components": "^19.11.0",
"@wordpress/components": "^19.15.0",
"@wordpress/element": "^4.7.0",
"@wordpress/i18n": "^4.10.0",
"@wordpress/keycodes": "^3.10.0",
Expand Down
Loading