Skip to content

Commit

Permalink
feat!: update packages (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
bocembocem authored Feb 19, 2024
1 parent f1997f1 commit 32a4547
Show file tree
Hide file tree
Showing 188 changed files with 4,104 additions and 2,619 deletions.
5,933 changes: 3,546 additions & 2,387 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
},
"dependencies": {
"@bem-react/classname": "^1.6.0",
"@gravity-ui/components": "^2.8.0",
"@gravity-ui/i18n": "^1.1.0",
"@gravity-ui/components": "^3.0.0",
"@gravity-ui/i18n": "^1.2.0",
"@gravity-ui/icons": "^2.8.1",
"lodash": "^4.17.20"
},
Expand All @@ -54,11 +54,11 @@
"@babel/preset-typescript": "^7.18.6",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@gravity-ui/eslint-config": "^2.2.0",
"@gravity-ui/eslint-config": "^3.1.1",
"@gravity-ui/prettier-config": "^1.1.0",
"@gravity-ui/stylelint-config": "^2.0.0",
"@gravity-ui/stylelint-config": "^4.0.1",
"@gravity-ui/tsconfig": "^1.0.0",
"@gravity-ui/uikit": "^5.19.1",
"@gravity-ui/uikit": "^6.0.0",
"@playwright/experimental-ct-react": "^1.40.0",
"@playwright/test": "^1.40.0",
"@storybook/addon-essentials": "^7.0.27",
Expand All @@ -76,7 +76,7 @@
"@types/uuid": "^9.0.4",
"@vitejs/plugin-react": "^4.2.0",
"css-loader": "^5.2.6",
"eslint": "^8.27.0",
"eslint": "^8.49.0",
"final-form": "^4.20.2",
"gulp": "^4.0.2",
"gulp-cli": "^2.3.0",
Expand All @@ -91,7 +91,7 @@
"monaco-editor-webpack-plugin": "^6.0.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.19",
"prettier": "^2.7.1",
"prettier": "^3.0.3",
"randexp": "^0.5.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -103,14 +103,14 @@
"sass-loader": "^10.1.1",
"storybook": "^7.0.27",
"style-loader": "^2.0.0",
"stylelint": "^14.15.0",
"stylelint-scss": "^4.2.0",
"stylelint": "^15.10.3",
"stylelint-scss": "^5.1.0",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5",
"uuid": "^9.0.1"
},
"peerDependencies": {
"@gravity-ui/uikit": "^5.0.0",
"@gravity-ui/uikit": "^6.0.0",
"final-form": "^4.20.2",
"react": "^16.0.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0",
Expand Down
26 changes: 16 additions & 10 deletions playwright/core/DynamicForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';

import _ from 'lodash';
import {Form} from 'react-final-form';

Expand All @@ -11,15 +13,19 @@ export const DynamicForm = ({spec}: {spec: Spec}) => {
const generateRandomValue = () => 'value';

return (
<Form initialValues={{}} onSubmit={_.noop}>
{() => (
<DynamicField
name="input"
spec={spec}
config={dynamicConfig}
generateRandomValue={generateRandomValue}
/>
)}
</Form>
<ThemeProvider>
<MobileProvider>
<Form initialValues={{}} onSubmit={_.noop}>
{() => (
<DynamicField
name="input"
spec={spec}
config={dynamicConfig}
generateRandomValue={generateRandomValue}
/>
)}
</Form>
</MobileProvider>
</ThemeProvider>
);
};
10 changes: 9 additions & 1 deletion playwright/core/DynamicView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import React from 'react';

import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';

import {DynamicView as DynamicViewBase} from '../../src/lib/core/components/View/DynamicView';
import {Spec} from '../../src/lib/core/types/specs';
import {FormValue} from '../../src/lib/core/types/value';
import {dynamicViewConfig} from '../../src/lib/kit/constants/config';

export const DynamicView = ({spec, value}: {spec: Spec; value: FormValue}) => {
return <DynamicViewBase spec={spec} value={value} config={dynamicViewConfig} />;
return (
<ThemeProvider>
<MobileProvider>
<DynamicViewBase spec={spec} value={value} config={dynamicViewConfig} />
</MobileProvider>
</ThemeProvider>
);
};
8 changes: 4 additions & 4 deletions playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {...devices['Desktop Chrome'], deviceScaleFactor: 2},
},
{
name: 'webkit',
use: {...devices['Desktop Safari'], deviceScaleFactor: 2},
},
// {
// name: 'webkit',
// use: {...devices['Desktop Safari'], deviceScaleFactor: 2},
// },
],
};

Expand Down
22 changes: 16 additions & 6 deletions src/lib/core/components/Form/Controller/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,26 @@ export interface GetComponentsParams<SpecType extends Spec> {
config: DynamicFormConfig;
}

export interface GetComponentsReturn<DirtyValue extends FieldValue, SpecType extends Spec> {
inputEntity?: InputEntity<DirtyValue, SpecType> | IndependentInputEntity<DirtyValue, SpecType>;
Layout?: LayoutType<DirtyValue, SpecType>;
export interface GetComponentsReturn<
DirtyValue extends FieldValue,
SpecType extends Spec<undefined, undefined, undefined>,
> {
inputEntity?:
| InputEntity<DirtyValue, undefined, undefined, SpecType>
| IndependentInputEntity<DirtyValue, undefined, undefined, SpecType>;
Layout?: LayoutType<DirtyValue, undefined, undefined, SpecType>;
}

export interface GetRenderParams<DirtyValue extends FieldValue, SpecType extends Spec> {
export interface GetRenderParams<
DirtyValue extends FieldValue,
SpecType extends Spec<undefined, undefined, undefined>,
> {
name: string;
spec: SpecType;
inputEntity?: InputEntity<DirtyValue, SpecType> | IndependentInputEntity<DirtyValue, SpecType>;
Layout?: LayoutType<DirtyValue, SpecType>;
inputEntity?:
| InputEntity<DirtyValue, undefined, undefined, SpecType>
| IndependentInputEntity<DirtyValue, undefined, undefined, SpecType>;
Layout?: LayoutType<DirtyValue, undefined, undefined, SpecType>;
}

export interface GetValidateParams<SpecType extends Spec> {
Expand Down
58 changes: 37 additions & 21 deletions src/lib/core/components/Form/__tests__/DynamicField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

import {ThemeProvider} from '@gravity-ui/uikit';
import {act, render} from '@testing-library/react';
import {FormApi} from 'final-form';
import _ from 'lodash';
Expand Down Expand Up @@ -139,32 +140,47 @@ const spec: ObjectSpec = {

jest.mock('lodash/debounce', () => (f: Function) => f);

beforeEach(() => {
window.matchMedia = () => ({
media: '',
matches: false,
onchange: () => {},
addListener: () => {},
removeListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: (_) => true,
});
});

test('Form/hooks/DynamicField', () => {
const mirror: WonderMirror = {field: {}, controller: {}};
let form = null as FormApi | null;

render(
<Form initialValues={{}} onSubmit={_.noop}>
{() => {
const Caller = () => {
form = useForm();

return null;
};

return (
<React.Fragment>
<DynamicField
name={name}
spec={spec}
config={dynamicConfig}
__mirror={mirror}
/>
<Caller />
</React.Fragment>
);
}}
</Form>,
<ThemeProvider>
<Form initialValues={{}} onSubmit={_.noop}>
{() => {
const Caller = () => {
form = useForm();

return null;
};

return (
<React.Fragment>
<DynamicField
name={name}
spec={spec}
config={dynamicConfig}
__mirror={mirror}
/>
<Caller />
</React.Fragment>
);
}}
</Form>
</ThemeProvider>,
);

const value = {
Expand Down
78 changes: 58 additions & 20 deletions src/lib/core/components/Form/types/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,83 @@ import {
ValidatorsMap,
} from './';

export type ArrayInputProps<InputComponentProps extends Record<string, any> = {}> = InputProps<
export type ArrayInputProps<
InputComponentProps extends Record<string, any> | undefined = undefined,
> = InputProps<
FieldArrayValue,
ArraySpec<undefined, InputComponentProps>
InputComponentProps,
undefined,
ArraySpec<undefined, InputComponentProps, undefined>
>;

export type ArrayIndependentInputProps<
InputComponentProps extends Record<string, any> = {},
LayoutComponentProps extends Record<string, any> = {},
InputComponentProps extends Record<string, any> | undefined = undefined,
LayoutComponentProps extends Record<string, any> | undefined = undefined,
> = IndependentInputProps<
FieldArrayValue,
InputComponentProps,
LayoutComponentProps,
ArraySpec<undefined, InputComponentProps, LayoutComponentProps>
>;

export type ArrayLayoutProps<LayoutComponentProps extends Record<string, any> = {}> = LayoutProps<
export type ArrayLayoutProps<
InputComponentProps extends Record<string, any> | undefined = undefined,
LayoutComponentProps extends Record<string, any> | undefined = undefined,
> = LayoutProps<
FieldArrayValue,
ArraySpec<undefined, any, LayoutComponentProps>
InputComponentProps,
LayoutComponentProps,
ArraySpec<undefined, InputComponentProps, LayoutComponentProps>
>;

export type ArrayInput<InputComponentProps extends Record<string, any> = {}> = InputType<
FieldArrayValue,
ArraySpec<undefined, InputComponentProps>
>;
export type ArrayInput<InputComponentProps extends Record<string, any> | undefined = undefined> =
InputType<
FieldArrayValue,
InputComponentProps,
undefined,
ArraySpec<undefined, InputComponentProps, undefined>
>;

export type ArrayIndependentInput<
InputComponentProps extends Record<string, any> = {},
LayoutComponentProps extends Record<string, any> = {},
InputComponentProps extends Record<string, any> | undefined = undefined,
LayoutComponentProps extends Record<string, any> | undefined = undefined,
> = IndependentInputType<
FieldArrayValue,
InputComponentProps,
LayoutComponentProps,
ArraySpec<undefined, InputComponentProps, LayoutComponentProps>
>;

export type ArrayLayout<LayoutComponentProps extends Record<string, any> = {}> = LayoutType<
export type ArrayLayout<
InputComponentProps extends Record<string, any> | undefined = undefined,
LayoutComponentProps extends Record<string, any> | undefined = undefined,
> = LayoutType<
FieldArrayValue,
ArraySpec<undefined, any, LayoutComponentProps>
InputComponentProps,
LayoutComponentProps,
ArraySpec<undefined, InputComponentProps, LayoutComponentProps>
>;

export type ArrayInputEntity = InputEntity<FieldArrayValue, ArraySpec>;
export type ArrayIndependentInputEntity = IndependentInputEntity<FieldArrayValue, ArraySpec>;
export type ArrayInputEntity<
InputComponentProps extends Record<string, any> | undefined = undefined,
> = InputEntity<
FieldArrayValue,
InputComponentProps,
undefined,
ArraySpec<undefined, InputComponentProps, undefined>
>;
export type ArrayIndependentInputEntity<
InputComponentProps extends Record<string, any> | undefined = undefined,
LayoutComponentProps extends Record<string, any> | undefined = undefined,
> = IndependentInputEntity<
FieldArrayValue,
InputComponentProps,
LayoutComponentProps,
ArraySpec<undefined, InputComponentProps, LayoutComponentProps>
>;

export type ArrayInputsMap = InputsMap<FieldArrayValue, ArraySpec>;
export type ArrayLayoutsMap = LayoutsMap<FieldArrayValue, ArraySpec>;
export type ArrayValidatorsMap = ValidatorsMap<ArrayValue, ArraySpec>;
export type ArrayInputsMap = InputsMap<FieldArrayValue, ArraySpec<undefined, any, any>>;
export type ArrayLayoutsMap = LayoutsMap<FieldArrayValue, ArraySpec<undefined, any, any>>;
export type ArrayValidatorsMap = ValidatorsMap<ArrayValue, ArraySpec<undefined, any, any>>;

export type ArrayConfig = TypeConfig<FieldArrayValue, ArrayValue, ArraySpec>;
export type ArrayConfig = TypeConfig<FieldArrayValue, ArrayValue, ArraySpec<undefined, any, any>>;
Loading

0 comments on commit 32a4547

Please sign in to comment.