From bca34e46b75792a2bc1865088f5470198bc3d632 Mon Sep 17 00:00:00 2001 From: plouc Date: Wed, 1 May 2024 13:41:45 +0900 Subject: [PATCH] feat(recompose): completely remove recompose from the project --- .eslintignore | 1 - examples/codesandbox/package.json | 1 - packages/core/package.json | 1 - packages/recompose/README.md | 7 --- packages/recompose/package.json | 40 ------------ packages/recompose/src/compose.ts | 14 ----- packages/recompose/src/defaultProps.ts | 18 ------ packages/recompose/src/getDisplayName.ts | 13 ---- packages/recompose/src/index.ts | 13 ---- packages/recompose/src/mapProps.ts | 18 ------ packages/recompose/src/pure.ts | 17 ----- packages/recompose/src/setDisplayName.ts | 6 -- packages/recompose/src/setPropTypes.ts | 6 -- packages/recompose/src/setStatic.ts | 11 ---- packages/recompose/src/shallowEqual.ts | 63 ------------------- packages/recompose/src/shouldUpdate.ts | 28 --------- packages/recompose/src/types.ts | 26 -------- packages/recompose/src/utils/index.ts | 1 - packages/recompose/src/utils/pick.ts | 11 ---- packages/recompose/src/withProps.ts | 19 ------ packages/recompose/src/withPropsOnChange.ts | 61 ------------------ packages/recompose/src/withState.ts | 52 --------------- packages/recompose/src/wrapDisplayName.ts | 5 -- packages/recompose/tests/compose.test.ts | 33 ---------- .../recompose/tests/defaultProps.test.tsx | 26 -------- .../recompose/tests/getDisplayName.test.tsx | 27 -------- .../recompose/tests/setDisplayName.test.tsx | 8 --- .../recompose/tests/setPropTypes.test.tsx | 12 ---- packages/recompose/tests/setStatic.test.tsx | 12 ---- packages/recompose/tests/withProps.test.tsx | 32 ---------- .../recompose/tests/wrapDisplayName.test.tsx | 12 ---- packages/recompose/tsconfig.json | 9 --- pnpm-lock.yaml | 31 --------- tsconfig.monorepo.json | 1 - 34 files changed, 635 deletions(-) delete mode 100644 packages/recompose/README.md delete mode 100644 packages/recompose/package.json delete mode 100644 packages/recompose/src/compose.ts delete mode 100644 packages/recompose/src/defaultProps.ts delete mode 100644 packages/recompose/src/getDisplayName.ts delete mode 100644 packages/recompose/src/index.ts delete mode 100644 packages/recompose/src/mapProps.ts delete mode 100644 packages/recompose/src/pure.ts delete mode 100644 packages/recompose/src/setDisplayName.ts delete mode 100644 packages/recompose/src/setPropTypes.ts delete mode 100644 packages/recompose/src/setStatic.ts delete mode 100644 packages/recompose/src/shallowEqual.ts delete mode 100644 packages/recompose/src/shouldUpdate.ts delete mode 100644 packages/recompose/src/types.ts delete mode 100644 packages/recompose/src/utils/index.ts delete mode 100644 packages/recompose/src/utils/pick.ts delete mode 100644 packages/recompose/src/withProps.ts delete mode 100644 packages/recompose/src/withPropsOnChange.ts delete mode 100644 packages/recompose/src/withState.ts delete mode 100644 packages/recompose/src/wrapDisplayName.ts delete mode 100644 packages/recompose/tests/compose.test.ts delete mode 100644 packages/recompose/tests/defaultProps.test.tsx delete mode 100644 packages/recompose/tests/getDisplayName.test.tsx delete mode 100644 packages/recompose/tests/setDisplayName.test.tsx delete mode 100644 packages/recompose/tests/setPropTypes.test.tsx delete mode 100644 packages/recompose/tests/setStatic.test.tsx delete mode 100644 packages/recompose/tests/withProps.test.tsx delete mode 100644 packages/recompose/tests/wrapDisplayName.test.tsx delete mode 100644 packages/recompose/tsconfig.json diff --git a/.eslintignore b/.eslintignore index aeb55eda2..198e9e523 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,3 @@ /stats/ /storybook-static/ node_modules/ -/packages/recompose/ \ No newline at end of file diff --git a/examples/codesandbox/package.json b/examples/codesandbox/package.json index ea8533134..0ffec2a6f 100644 --- a/examples/codesandbox/package.json +++ b/examples/codesandbox/package.json @@ -30,7 +30,6 @@ "@nivo/parallel-coordinates": "0.86.0", "@nivo/pie": "0.86.0", "@nivo/radar": "0.86.0", - "@nivo/recompose": "0.86.0", "@nivo/sankey": "0.86.0", "@nivo/scales": "0.86.0", "@nivo/scatterplot": "0.86.0", diff --git a/packages/core/package.json b/packages/core/package.json index 9b9b0c6a1..f514fd297 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -21,7 +21,6 @@ "dist/" ], "dependencies": { - "@nivo/recompose": "workspace:*", "@nivo/tooltip": "workspace:*", "@react-spring/web": "9.4.5 || ^9.7.2", "@types/d3-shape": "^2.0.0", diff --git a/packages/recompose/README.md b/packages/recompose/README.md deleted file mode 100644 index 50195381c..000000000 --- a/packages/recompose/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# `@nivo/recompose` - -[![version](https://img.shields.io/npm/v/@nivo/recompose.svg?style=flat-square)](https://www.npmjs.com/package/@nivo/recompose) - -## Recompose - -![Recompose](https://raw.githubusercontent.com/plouc/nivo/master/packages/recompose/doc/recompose.png) diff --git a/packages/recompose/package.json b/packages/recompose/package.json deleted file mode 100644 index 1b8c77fc9..000000000 --- a/packages/recompose/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@nivo/recompose", - "version": "0.86.0", - "keywords": [ - "nivo", - "react", - "recompose" - ], - "repository": { - "type": "git", - "url": "https://github.com/plouc/nivo.git", - "directory": "packages/recompose" - }, - "license": "MIT", - "author": { - "name": "Raphaƫl Benitte", - "url": "https://github.com/plouc" - }, - "main": "./dist/nivo-recompose.cjs.js", - "module": "./dist/nivo-recompose.es.js", - "types": "./dist/types/index.d.ts", - "files": [ - "README.md", - "LICENSE.md", - "dist/", - "!dist/tsconfig.tsbuildinfo" - ], - "dependencies": { - "@types/prop-types": "^15.7.2", - "@types/react-lifecycles-compat": "^3.0.1", - "prop-types": "^15.7.2", - "react-lifecycles-compat": "^3.0.4" - }, - "peerDependencies": { - "react": ">= 16.14.0 < 19.0.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/recompose/src/compose.ts b/packages/recompose/src/compose.ts deleted file mode 100644 index 8e48cb738..000000000 --- a/packages/recompose/src/compose.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ComponentClass, ComponentType } from 'react' - -interface ComponentEnhancer { - (component: ComponentType): ComponentClass -} - -// eslint-disable-next-line @typescript-eslint/ban-types -export const compose = (...funcs: Function[]): ComponentEnhancer => - funcs.reduce>( - (a, b) => - (...args) => - a(b(...args)), - arg => arg as any - ) as ComponentEnhancer diff --git a/packages/recompose/src/defaultProps.ts b/packages/recompose/src/defaultProps.ts deleted file mode 100644 index d15d2817a..000000000 --- a/packages/recompose/src/defaultProps.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createFactory } from 'react' -import { setDisplayName } from './setDisplayName' -import { DefaultingInferableComponentEnhancer } from './types' -import { wrapDisplayName } from './wrapDisplayName' - -// eslint-disable-next-line @typescript-eslint/ban-types -export const defaultProps = - (props: T): DefaultingInferableComponentEnhancer => - (BaseComponent: any): any => { - const factory = createFactory(BaseComponent) - const DefaultProps = (ownerProps: any) => factory(ownerProps) - DefaultProps.defaultProps = props - if (process.env.NODE_ENV !== 'production') { - // @ts-ignore - return setDisplayName(wrapDisplayName(BaseComponent, 'defaultProps'))(DefaultProps) - } - return DefaultProps - } diff --git a/packages/recompose/src/getDisplayName.ts b/packages/recompose/src/getDisplayName.ts deleted file mode 100644 index 9925c0464..000000000 --- a/packages/recompose/src/getDisplayName.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ComponentType } from 'react' - -export const getDisplayName = (component: ComponentType | string): string | undefined => { - if (typeof component === 'string') { - return component - } - - if (!component) { - return undefined - } - - return component.displayName || component.name || 'Component' -} diff --git a/packages/recompose/src/index.ts b/packages/recompose/src/index.ts deleted file mode 100644 index f1e17fdf8..000000000 --- a/packages/recompose/src/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -export * from './getDisplayName' -export * from './pure' -export * from './setDisplayName' -export * from './setStatic' -export * from './shallowEqual' -export * from './shouldUpdate' -export * from './wrapDisplayName' -export * from './compose' -export * from './withPropsOnChange' -export * from './defaultProps' -export * from './withProps' -export * from './setPropTypes' -export * from './withState' diff --git a/packages/recompose/src/mapProps.ts b/packages/recompose/src/mapProps.ts deleted file mode 100644 index d18ad4a6c..000000000 --- a/packages/recompose/src/mapProps.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createFactory } from 'react' -import { setDisplayName } from './setDisplayName' -import { InferableComponentEnhancerWithProps, Mapper } from './types' -import { wrapDisplayName } from './wrapDisplayName' - -export const mapProps = - ( - propsMapper: Mapper - ): InferableComponentEnhancerWithProps => - (BaseComponent: any): any => { - const factory = createFactory(BaseComponent) - // @ts-ignore - const MapProps = (props: any) => factory(propsMapper(props)) - if (process.env.NODE_ENV !== 'production') { - return setDisplayName(wrapDisplayName(BaseComponent, 'mapProps'))(MapProps) - } - return MapProps - } diff --git a/packages/recompose/src/pure.ts b/packages/recompose/src/pure.ts deleted file mode 100644 index 80b5d4b71..000000000 --- a/packages/recompose/src/pure.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ComponentType } from 'react' -import { setDisplayName } from './setDisplayName' -import { shallowEqual } from './shallowEqual' -import { shouldUpdate } from './shouldUpdate' -import { wrapDisplayName } from './wrapDisplayName' - -export const pure = (component: ComponentType): ComponentType => { - const hoc = shouldUpdate((props, nextProps) => !shallowEqual(props, nextProps)) - - if (process.env.NODE_ENV !== 'production') { - // @ts-ignore - return setDisplayName(wrapDisplayName(component, 'pure'))(hoc(component)) - } - - // @ts-ignore - return hoc(component) -} diff --git a/packages/recompose/src/setDisplayName.ts b/packages/recompose/src/setDisplayName.ts deleted file mode 100644 index d1c8b81e8..000000000 --- a/packages/recompose/src/setDisplayName.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ComponentType } from 'react' -import { setStatic } from './setStatic' - -export const setDisplayName = ( - displayName: string -): (>(component: T) => T) => setStatic('displayName', displayName) diff --git a/packages/recompose/src/setPropTypes.ts b/packages/recompose/src/setPropTypes.ts deleted file mode 100644 index a9f05166e..000000000 --- a/packages/recompose/src/setPropTypes.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ComponentType, ValidationMap } from 'react' -import { setStatic } from './setStatic' - -export const setPropTypes =

( - propTypes: ValidationMap

-): (>(component: T) => T) => setStatic('propTypes', propTypes) diff --git a/packages/recompose/src/setStatic.ts b/packages/recompose/src/setStatic.ts deleted file mode 100644 index 3a204ae80..000000000 --- a/packages/recompose/src/setStatic.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ComponentType } from 'react' - -export const setStatic = - (key: string, value: any): (>(component: T) => T) => - BaseComponent => { - /* eslint-disable no-param-reassign */ - // @ts-expect-error there's no way to type this - BaseComponent[key] = value - /* eslint-enable no-param-reassign */ - return BaseComponent - } diff --git a/packages/recompose/src/shallowEqual.ts b/packages/recompose/src/shallowEqual.ts deleted file mode 100644 index 414b70a4b..000000000 --- a/packages/recompose/src/shallowEqual.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule shallowEqual - * @typechecks - */ - -/* eslint-disable no-self-compare */ - -const hasOwnProperty = Object.prototype.hasOwnProperty - -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x: unknown, y: unknown): boolean { - // SameValue algorithm - if (x === y) { - // Steps 1-5, 7-10 - // Steps 6.b-6.e: +0 != -0 - // Added the nonzero y check to make Flow happy, but it is redundant - return x !== 0 || y !== 0 || 1 / x === 1 / y - } - // Step 6.a: NaN == NaN - return x !== x && y !== y -} - -/** - * Performs equality by iterating through keys on an object and returning false - * when any key has values which are not strictly equal between the arguments. - * Returns true when the values of all keys are strictly equal. - */ -export function shallowEqual( - objA: Record, - objB: Record -): boolean { - if (is(objA, objB)) { - return true - } - - if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { - return false - } - - const keysA = Object.keys(objA) - const keysB = Object.keys(objB) - - if (keysA.length !== keysB.length) { - return false - } - - // Test for A's keys different from B. - for (let i = 0; i < keysA.length; i++) { - if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { - return false - } - } - - return true -} diff --git a/packages/recompose/src/shouldUpdate.ts b/packages/recompose/src/shouldUpdate.ts deleted file mode 100644 index 37926eda4..000000000 --- a/packages/recompose/src/shouldUpdate.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Component, createFactory } from 'react' -import { setDisplayName } from './setDisplayName' -import { InferableComponentEnhancer, PredicateDiff } from './types' -import { wrapDisplayName } from './wrapDisplayName' - -export const shouldUpdate = - >( - test: PredicateDiff - // eslint-disable-next-line @typescript-eslint/ban-types - ): InferableComponentEnhancer<{}> => - (BaseComponent: any): any => { - const factory = createFactory(BaseComponent) - class ShouldUpdate extends Component { - shouldComponentUpdate(nextProps: any) { - // @ts-expect-error not type-able - return test(this.props, nextProps) - } - - render() { - return factory(this.props) - } - } - - if (process.env.NODE_ENV !== 'production') { - return setDisplayName(wrapDisplayName(BaseComponent, 'shouldUpdate'))(ShouldUpdate) - } - return ShouldUpdate - } diff --git a/packages/recompose/src/types.ts b/packages/recompose/src/types.ts deleted file mode 100644 index f52892ab9..000000000 --- a/packages/recompose/src/types.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ComponentClass, ComponentType } from 'react' - -export type Mapper = (input: TInner) => TOuter - -export type PredicateDiff = (current: T, next: T) => boolean - -// Injects props and removes them from the prop requirements. -// Will not pass through the injected props if they are passed in during -// render. Also adds new prop requirements from TNeedsProps. -export interface InferableComponentEnhancerWithProps { -

(component: ComponentType

): ComponentClass< - Omit & TNeedsProps - > -} - -// Injects props and removes them from the prop requirements. -// Will not pass through the injected props if they are passed in during -// render. -export type InferableComponentEnhancer = InferableComponentEnhancerWithProps< - TInjectedProps, - // eslint-disable-next-line @typescript-eslint/ban-types - {} -> - -export type DefaultingInferableComponentEnhancer = - InferableComponentEnhancerWithProps> diff --git a/packages/recompose/src/utils/index.ts b/packages/recompose/src/utils/index.ts deleted file mode 100644 index 87300e575..000000000 --- a/packages/recompose/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './pick' diff --git a/packages/recompose/src/utils/pick.ts b/packages/recompose/src/utils/pick.ts deleted file mode 100644 index ab6ffb66a..000000000 --- a/packages/recompose/src/utils/pick.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const pick = (obj: Record, keys: string[]) => { - const result: Record = {} - for (let i = 0; i < keys.length; i++) { - const key = keys[i] - // eslint-disable-next-line no-prototype-builtins - if (obj.hasOwnProperty(key)) { - result[key] = obj[key] - } - } - return result -} diff --git a/packages/recompose/src/withProps.ts b/packages/recompose/src/withProps.ts deleted file mode 100644 index bf7b2b591..000000000 --- a/packages/recompose/src/withProps.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { mapProps } from './mapProps' -import { setDisplayName } from './setDisplayName' -import { InferableComponentEnhancerWithProps, Mapper } from './types' -import { wrapDisplayName } from './wrapDisplayName' - -export const withProps = ( - createProps: TInner | Mapper -): InferableComponentEnhancerWithProps => { - const hoc = mapProps(props => ({ - ...(props as any), - // eslint-disable-next-line @typescript-eslint/ban-types - ...(typeof createProps === 'function' ? (createProps as Function)(props) : createProps), - })) - if (process.env.NODE_ENV !== 'production') { - return ((BaseComponent: any) => - setDisplayName(wrapDisplayName(BaseComponent, 'withProps'))(hoc(BaseComponent))) as any - } - return hoc as InferableComponentEnhancerWithProps -} diff --git a/packages/recompose/src/withPropsOnChange.ts b/packages/recompose/src/withPropsOnChange.ts deleted file mode 100644 index bf3d7a779..000000000 --- a/packages/recompose/src/withPropsOnChange.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Component, createFactory } from 'react' -import { polyfill } from 'react-lifecycles-compat' -import { setDisplayName } from './setDisplayName' -import { shallowEqual } from './shallowEqual' -import { InferableComponentEnhancerWithProps, Mapper, PredicateDiff } from './types' -import { pick } from './utils' -import { wrapDisplayName } from './wrapDisplayName' - -export const withPropsOnChange = - >( - shouldMapOrKeys: string[] | PredicateDiff, - propsMapper: Mapper - ): InferableComponentEnhancerWithProps => - (BaseComponent: any): any => { - const factory = createFactory(BaseComponent) - const shouldMap = - typeof shouldMapOrKeys === 'function' - ? shouldMapOrKeys - : (props: TOuter, nextProps: TOuter) => - !shallowEqual(pick(props, shouldMapOrKeys), pick(nextProps, shouldMapOrKeys)) - - class WithPropsOnChange extends Component { - state = { - computedProps: propsMapper(this.props), - prevProps: this.props, - } - - static getDerivedStateFromProps( - nextProps: TOuter, - prevState: WithPropsOnChange['state'] - ) { - if (shouldMap(prevState.prevProps, nextProps)) { - return { - computedProps: propsMapper(nextProps), - prevProps: nextProps, - } - } - - return { - prevProps: nextProps, - } - } - - render() { - return factory({ - ...this.props, - ...this.state.computedProps, - }) - } - } - - polyfill(WithPropsOnChange) - - if (process.env.NODE_ENV !== 'production') { - return setDisplayName(wrapDisplayName(BaseComponent, 'withPropsOnChange'))( - WithPropsOnChange - ) - } - - return WithPropsOnChange - } diff --git a/packages/recompose/src/withState.ts b/packages/recompose/src/withState.ts deleted file mode 100644 index 0c1b3b8dc..000000000 --- a/packages/recompose/src/withState.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { createFactory, Component } from 'react' -import { setDisplayName } from './setDisplayName' -import { InferableComponentEnhancerWithProps, Mapper } from './types' -import { wrapDisplayName } from './wrapDisplayName' - -type StateProps = { - [stateName in TStateName]: TState -} & { [stateUpdateName in TStateUpdaterName]: (state: TState) => TState } - -export const withState = - ( - stateName: TStateName, - stateUpdaterName: TStateUpdaterName, - initialState: TState | Mapper - ): InferableComponentEnhancerWithProps< - StateProps, - TOuter - > => - (BaseComponent: any): any => { - const factory = createFactory(BaseComponent) - class WithState extends Component { - state = { - stateValue: - typeof initialState === 'function' - ? // eslint-disable-next-line @typescript-eslint/ban-types - (initialState as Function)(this.props) - : initialState, - } - - updateStateValue = (updateFn: any, callback: any) => - this.setState( - ({ stateValue }: any) => ({ - stateValue: - typeof updateFn === 'function' ? updateFn(stateValue) : updateFn, - }), - callback - ) - - render() { - return factory({ - ...this.props, - [stateName]: this.state.stateValue, - [stateUpdaterName]: this.updateStateValue, - }) - } - } - - if (process.env.NODE_ENV !== 'production') { - return setDisplayName(wrapDisplayName(BaseComponent, 'withState'))(WithState) - } - return WithState - } diff --git a/packages/recompose/src/wrapDisplayName.ts b/packages/recompose/src/wrapDisplayName.ts deleted file mode 100644 index 8775e22dc..000000000 --- a/packages/recompose/src/wrapDisplayName.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ComponentType } from 'react' -import { getDisplayName } from './getDisplayName' - -export const wrapDisplayName = (BaseComponent: ComponentType, hocName: string): string => - `${hocName}(${getDisplayName(BaseComponent)})` diff --git a/packages/recompose/tests/compose.test.ts b/packages/recompose/tests/compose.test.ts deleted file mode 100644 index f1373cee6..000000000 --- a/packages/recompose/tests/compose.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { compose } from '../src' - -test('compose composes from right to left', () => { - const double = (x: number) => x * 2 - const square = (x: number) => x * x - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose(square)(5)).toBe(25) - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose(square, double)(5)).toBe(100) - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose(double, square, double)(5)).toBe(200) -}) - -test('compose can be seeded with multiple arguments', () => { - const square = (x: number) => x * x - const add = (x: number, y: number) => x + y - expect(compose(square, add)(1, 2)).toBe(9) -}) - -test('compose returns the identity function if given no arguments', () => { - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose()(1, 2)).toBe(1) - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose()(3)).toBe(3) - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose()()).toBe(undefined) -}) - -test('compose returns the first function if given only one', () => { - const fn = (x: number) => x * x - // @ts-expect-error not entirely sure why ts is complaining tbh - expect(compose(fn)(3)).toBe(fn(3)) -}) diff --git a/packages/recompose/tests/defaultProps.test.tsx b/packages/recompose/tests/defaultProps.test.tsx deleted file mode 100644 index d51d20766..000000000 --- a/packages/recompose/tests/defaultProps.test.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { shallow } from 'enzyme' -import { defaultProps } from '../src' - -test('defaultProps passes additional props to base component', () => { - const DoReMi = defaultProps({ 'data-so': 'do', 'data-la': 'fa' })('div') - expect(DoReMi.displayName).toBe('defaultProps(div)') - - const div = shallow().find('div') - expect(div.equals(

)).toBe(true) -}) - -test('defaultProps has lower precendence than props from owner', () => { - const DoReMi = defaultProps({ 'data-so': 'do', 'data-la': 'fa' })('div') - expect(DoReMi.displayName).toBe('defaultProps(div)') - - const div = shallow().find('div') - expect(div.equals(
)).toBe(true) -}) - -test('defaultProps overrides undefined owner props', () => { - const DoReMi = defaultProps({ 'data-so': 'do', 'data-la': 'fa' })('div') - expect(DoReMi.displayName).toBe('defaultProps(div)') - - const div = shallow().find('div') - expect(div.equals(
)).toBe(true) -}) diff --git a/packages/recompose/tests/getDisplayName.test.tsx b/packages/recompose/tests/getDisplayName.test.tsx deleted file mode 100644 index e038b5b4c..000000000 --- a/packages/recompose/tests/getDisplayName.test.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Component } from 'react' -import { getDisplayName } from '../src' - -test('getDisplayName gets the display name of a React component', () => { - class SomeComponent extends Component { - render() { - return
- } - } - - class SomeOtherComponent extends Component { - static displayName = 'CustomDisplayName' - render() { - return
- } - } - - function YetAnotherComponent() { - return
- } - - expect(getDisplayName(SomeComponent)).toBe('SomeComponent') - expect(getDisplayName(SomeOtherComponent)).toBe('CustomDisplayName') - expect(getDisplayName(YetAnotherComponent)).toBe('YetAnotherComponent') - expect(getDisplayName(() =>
)).toBe('Component') - expect(getDisplayName('div')).toBe('div') -}) diff --git a/packages/recompose/tests/setDisplayName.test.tsx b/packages/recompose/tests/setDisplayName.test.tsx deleted file mode 100644 index 792ec2b09..000000000 --- a/packages/recompose/tests/setDisplayName.test.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import * as React from 'react' -import { setDisplayName } from '../src' - -test('setDisplayName sets a static property on the base component', () => { - const BaseComponent: React.ComponentType = () =>
- const NewComponent = setDisplayName('Foo')(BaseComponent) - expect(NewComponent.displayName).toBe('Foo') -}) diff --git a/packages/recompose/tests/setPropTypes.test.tsx b/packages/recompose/tests/setPropTypes.test.tsx deleted file mode 100644 index e234d2003..000000000 --- a/packages/recompose/tests/setPropTypes.test.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import * as React from 'react' -import * as PropTypes from 'prop-types' -import { setPropTypes } from '../src' - -test('setPropTypes sets a static property on the base component', () => { - const BaseComponent: React.ComponentType = () =>
- const NewComponent = setPropTypes({ foo: PropTypes.object })(BaseComponent) - - expect(NewComponent.propTypes).toEqual({ - foo: PropTypes.object, - }) -}) diff --git a/packages/recompose/tests/setStatic.test.tsx b/packages/recompose/tests/setStatic.test.tsx deleted file mode 100644 index 2ef56463d..000000000 --- a/packages/recompose/tests/setStatic.test.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import * as React from 'react' -import * as PropTypes from 'prop-types' -import { setStatic } from '../src' - -test('setStatic sets a static property on the base component', () => { - const BaseComponent: React.ComponentType = () =>
- const NewComponent = setStatic('propTypes', { foo: PropTypes.object })(BaseComponent) - - expect(NewComponent.propTypes).toEqual({ - foo: PropTypes.object, - }) -}) diff --git a/packages/recompose/tests/withProps.test.tsx b/packages/recompose/tests/withProps.test.tsx deleted file mode 100644 index 7815171ac..000000000 --- a/packages/recompose/tests/withProps.test.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { shallow } from 'enzyme' -import { withProps } from '../src' - -test('withProps passes additional props to base component', () => { - // @ts-expect-error types need improving - const DoReMi = withProps({ 'data-so': 'do', 'data-la': 'fa' })('div') - expect(DoReMi.displayName).toBe('withProps(div)') - - const div = shallow().find('div') - expect(div.prop('data-so')).toBe('do') - expect(div.prop('data-la')).toBe('fa') -}) - -test('withProps takes precedent over owner props', () => { - // @ts-expect-error types need improving - const DoReMi = withProps({ 'data-so': 'do', 'data-la': 'fa' })('div') - - const div = shallow().find('div') - expect(div.prop('data-so')).toBe('do') - expect(div.prop('data-la')).toBe('fa') -}) - -test('withProps should accept function', () => { - const DoReMi = withProps(props => ({ - // @ts-expect-error types need improving - 'data-so': props['data-la'], - // @ts-expect-error types need improving - }))('div') - - const div = shallow().find('div') - expect(div.prop('data-so')).toBe('la') -}) diff --git a/packages/recompose/tests/wrapDisplayName.test.tsx b/packages/recompose/tests/wrapDisplayName.test.tsx deleted file mode 100644 index fc56b18aa..000000000 --- a/packages/recompose/tests/wrapDisplayName.test.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { Component } from 'react' -import { wrapDisplayName } from '../src' - -test('wrapDisplayName wraps the display name of a React component with the name of an HoC, Relay-style', () => { - class SomeComponent extends Component { - render() { - return
- } - } - - expect(wrapDisplayName(SomeComponent, 'someHoC')).toBe('someHoC(SomeComponent)') -}) diff --git a/packages/recompose/tsconfig.json b/packages/recompose/tsconfig.json deleted file mode 100644 index 7dddf9f17..000000000 --- a/packages/recompose/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.types.json", - "compilerOptions": { - "baseUrl": ".", - "outDir": "./dist/types", - "rootDir": "./src" - }, - "include": ["src/**/*"] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1043b2095..60d6a2df3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -706,9 +706,6 @@ importers: packages/core: dependencies: - '@nivo/recompose': - specifier: workspace:* - version: link:../recompose '@nivo/tooltip': specifier: workspace:* version: link:../tooltip @@ -1180,24 +1177,6 @@ importers: specifier: 18.2.0 version: 18.2.0 - packages/recompose: - dependencies: - '@types/prop-types': - specifier: ^15.7.2 - version: 15.7.4 - '@types/react-lifecycles-compat': - specifier: ^3.0.1 - version: 3.0.1 - prop-types: - specifier: ^15.7.2 - version: 15.8.1 - react: - specifier: 18.2.0 - version: 18.2.0 - react-lifecycles-compat: - specifier: ^3.0.4 - version: 3.0.4 - packages/sankey: dependencies: '@nivo/colors': @@ -7981,12 +7960,6 @@ packages: '@types/react': 18.2.0 dev: false - /@types/react-lifecycles-compat@3.0.1: - resolution: {integrity: sha512-4KiU5s1Go4xRbf7t6VxUUpBeN5PGjpjpBv9VvET4uiPHC500VNYBclU13f8ehHkHoZL39b2cfwHu6RzbV3b44A==} - dependencies: - '@types/react': 18.2.0 - dev: false - /@types/react-test-renderer@18.0.0: resolution: {integrity: sha512-C7/5FBJ3g3sqUahguGi03O79b8afNeSD6T8/GU50oQrJCU0bVCCGQHaGKUbg2Ce8VQEEqTw8/HiS6lXHHdgkdQ==} dependencies: @@ -21562,10 +21535,6 @@ packages: /react-is@18.2.0: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} - /react-lifecycles-compat@3.0.4: - resolution: {integrity: sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==} - dev: false - /react-markdown@8.0.7(@types/react@18.2.0)(react@18.2.0): resolution: {integrity: sha512-bvWbzG4MtOU62XqBx3Xx+zB2raaFFsq4mYiAzfjXJMEz2sixgeAfraA3tvzULF02ZdOMUOKTBFFaZJDDrq+BJQ==} peerDependencies: diff --git a/tsconfig.monorepo.json b/tsconfig.monorepo.json index be1953255..738a551ef 100644 --- a/tsconfig.monorepo.json +++ b/tsconfig.monorepo.json @@ -19,7 +19,6 @@ // Utility packages { "path": "./packages/generators" }, - { "path": "./packages/recompose" }, // Charts now { "path": "./packages/bar" },