Skip to content

Commit

Permalink
Merge branch 'master' into deprecate-material-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
zendranm committed Jun 14, 2024
2 parents 0815bf0 + c047291 commit 946faf6
Show file tree
Hide file tree
Showing 90 changed files with 500 additions and 2,656 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"overrides": [
{
"files": ["**/__mocks__/**/*", "**/__tests__/**/*"],
"files": ["**/__tests__/**/*"],
"env": {
"jest": true
}
Expand Down Expand Up @@ -72,7 +72,6 @@
"valid-jsdoc": "off"
},
"settings": {
"import/core-modules": ["meteor/aldeed:simple-schema", "meteor/check"],
"import/resolver": {
"typescript": {}
},
Expand Down
36 changes: 36 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,42 @@ Our kanban board is public and available [here](https://github.com/orgs/vazco/pr
- Make sure you have added the necessary tests for your changes. Do not worry though, the Codecov bot will report it in the pull request.
- Make sure your code passes _all_ tests: `npm test`.

### Development

For the best local developer experience (DX) it is recommended to start `build` and `test` in `--watch` mode.

Run the commands below in the root directory.

#### Running the build in watch mode

```sh
npm run build -- --watch
```

#### Running the tests in watch mode

```sh
npm run test -- --watch
```

#### Fixing lint issues automatically

```sh
npm run lint:code -- --fix
```

#### Making changes to the documentation website (docusaurus)

The local version of docs will use the locally built version of uniforms, so make sure to run the build in watch mode for live changes.

Navigate to `/website` and run

```sh
npm start
```

It will start the docusaurus in development mode supporting hot reload so you should see the changes made to the website immediately.

## _Work in progress_ PRs are also welcome

If you can't or won't finish your PR, submit it anyway - maybe someone else will continue your work. If you don't know how to achieve your desired feature - file an issue for it - maybe someone else will implement it.
10 changes: 0 additions & 10 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
- any-glob-to-any-file:
- packages/uniforms-bridge-json-schema/**/*
- packages/uniforms-bridge-simple-schema-2/**/*
- packages/uniforms-bridge-simple-schema/**/*
- packages/uniforms-bridge-zod/**/*
'Area: Core':
- changed-files:
Expand Down Expand Up @@ -42,7 +41,6 @@
- changed-files:
- any-glob-to-any-file:
- packages/uniforms-antd/**/*
- packages/uniforms-bootstrap3/**/*
- packages/uniforms-bootstrap4/**/*
- packages/uniforms-bootstrap5/**/*
- packages/uniforms-mui/**/*
Expand All @@ -52,10 +50,6 @@
- changed-files:
- any-glob-to-any-file:
- packages/uniforms-bridge-json-schema/**/*
'Bridge: SimpleSchema':
- changed-files:
- any-glob-to-any-file:
- packages/uniforms-bridge-simple-schema/**/*
'Bridge: SimpleSchema (v2)':
- changed-files:
- any-glob-to-any-file:
Expand All @@ -68,10 +62,6 @@
- changed-files:
- any-glob-to-any-file:
- packages/uniforms-antd/**/*
'Theme: Bootstrap 3':
- changed-files:
- any-glob-to-any-file:
- packages/uniforms-bootstrap3/**/*
'Theme: Bootstrap 4':
- changed-files:
- any-glob-to-any-file:
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@
- **Inline and asynchronous form validation**
- **Integrations with various schemas:**
- **[JSON Schema](http://json-schema.org/)**
- **[SimpleSchema](https://github.com/aldeed/meteor-simple-schema)**
- **[SimpleSchema@2](https://github.com/aldeed/node-simple-schema)**
- **[Zod](https://github.com/colinhacks/zod)**
- **And any other - only [a small wrapper](https://vazco.github.io/uniforms/#/introduction) is needed!**
- **Wide range of themes:**
- **[AntD](https://ant.design/) theme**
- **[Bootstrap3](https://getbootstrap.com/docs/3.4/) theme**
- **[Bootstrap4](https://getbootstrap.com/docs/4.6) theme**
- **[Bootstrap5](https://getbootstrap.com/) theme**
- **[MUI](https://mui.com/) theme**
Expand Down
21 changes: 19 additions & 2 deletions docs/api-bridges.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Currently available bridges:

- `JSONSchemaBridge` in `uniforms-bridge-json-schema` ([schema documentation](https://json-schema.org/))
- `SimpleSchema2Bridge` in `uniforms-bridge-simple-schema-2` ([schema documentation](https://github.com/longshotlabs/simpl-schema#readme))
- `SimpleSchemaBridge` in `uniforms-bridge-simple-schema` ([schema documentation](https://github.com/Meteor-Community-Packages/meteor-simple-schema/blob/master/DOCS.md))
- `ZodBridge` in `uniforms-bridge-zod` ([schema documentation](https://zod.dev/))

Deprecated packages:
Deprecated bridges:

- `SimpleSchemaBridge` in `uniforms-bridge-simple-schema` ([schema documentation](https://github.com/Meteor-Community-Packages/meteor-simple-schema/blob/master/DOCS.md))
- `GraphQLBridge` in `uniforms-bridge-graphql` ([schema documentation](https://graphql.org/))

If you see a lot of [`Warning: Unknown props...`](https://fb.me/react-unknown-prop) logs, check if your schema or theme doesn't provide extra props. If so, consider [registering it with `filterDOMProps`](/docs/api-helpers#filterdomprops).
Expand Down Expand Up @@ -141,8 +141,25 @@ const schema = new SimpleSchema({
const bridge = new SimpleSchema2Bridge({ schema });
```

## `ZodBridge`

```tsx
import ZodBridge from 'uniforms-bridge-zod';
import z from 'zod';

const schema = z.object({ aboutMe: z.string() });

const bridge = new ZodBridge({ schema });
```

## `SimpleSchemaBridge`

:::caution

SimpleSchemaBridge is deprecated since uniforms v4.

:::

```tsx
import SimpleSchemaBridge from 'uniforms-bridge-simple-schema';
import { SimpleSchema } from 'aldeed:simple-schema';
Expand Down
1 change: 0 additions & 1 deletion docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Now the schema package.
tabs={[
{ name: 'Semantic' },
{ name: 'MUI' },
{ name: 'Bootstrap3' },
{ name: 'Bootstrap4' },
{ name: 'Bootstrap5' },
{ name: 'AntD' },
Expand Down
5 changes: 1 addition & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ module.exports = {
collectCoverageFrom: ['packages/*/src/*.{ts,tsx}'],
coverageReporters: ['html', 'lcovonly', 'text-summary'],
moduleNameMapper: {
'^meteor/([^:]*):(.*)$':
'<rootDir>/packages/uniforms/__mocks__/meteor/$1_$2.ts',
'^meteor/([^:]*)$': '<rootDir>/packages/uniforms/__mocks__/meteor/$1.ts',
'^simpl-schema$': '<rootDir>/node_modules/simpl-schema',
'^uniforms/__suites__$': '<rootDir>/packages/uniforms/__suites__',
'^uniforms([^/]*)(.*)$': '<rootDir>/packages/uniforms$1/src$2',
},
preset: 'ts-jest',
setupFiles: ['./scripts/setupEnzyme.ts'],
setupFiles: ['./scripts/setupEnzyme.ts', './scripts/setupFilterWarnings.ts'],
setupFilesAfterEnv: ['./scripts/setupMatchers.ts'],
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/', '/_[^/]*$', '\\.d\\.ts$'],
Expand Down
8 changes: 7 additions & 1 deletion packages/uniforms-antd/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ it('exports everything', () => {
});
});

describe('@RTL', () => {
describe('@RTL AntD', () => {
suites.testAutoField(theme.AutoField, {
getDateField: screen => screen.getByRole('textbox'),
getSelectField: screen => screen.getByRole('combobox'),
Expand Down Expand Up @@ -65,4 +65,10 @@ describe('@RTL', () => {
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
suites.testWrapField(theme.wrapField, {
helpPropsName: 'help',
withoutWrapClassName: true,
withoutHelpClassName: true,
withoutLabelClassName: true,
});
});
121 changes: 49 additions & 72 deletions packages/uniforms-antd/__tests__/wrapField.tsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,52 @@
import Form from 'antd/lib/form';
import Tooltip from 'antd/lib/tooltip';
import { screen } from '@testing-library/react';
import React from 'react';
import { wrapField } from 'uniforms-antd';

import mount from './_mount';

test('<wrapField> - renders wrapper with label', () => {
const element = wrapField({ label: 'Label' }, <div />);
const wrapper = mount(element);

// @ts-expect-error Correct label type.
expect(wrapper.find(Form.Item).prop('label').props.children[0]).toBe('Label');
});

test('<wrapField> - renders wrapper with label and info', () => {
const element = wrapField({ label: 'Label', info: 'Info' }, <div />);
const wrapper = mount(element);

expect(wrapper.find(Tooltip).prop('title')).toBe('Info');
});

test('<wrapField> - renders wrapper with an error message', () => {
const error = new Error();
const element = wrapField(
{ error, showInlineError: true, errorMessage: 'Error' },
<div />,
);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('help')).toBe('Error');
});

test('<wrapField> - renders wrapper with an error status', () => {
const element = wrapField({}, <div />);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('validateStatus')).toBe(undefined);
});

test('<wrapField> - renders wrapper with an error status (error)', () => {
const error = new Error();
const element = wrapField({ error }, <div />);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('validateStatus')).toBe('error');
});

test('<wrapField> - renders wrapper with help text', () => {
const element = wrapField({ help: 'Help' }, <div />);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('help')).toBe('Help');
});

test('<wrapField> - renders wrapper with extra text', () => {
const element = wrapField({ extra: 'Extra' }, <div />);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('extra')).toBe('Extra');
});

test('<wrapField> - renders wrapper with extra style', () => {
const element = wrapField({ wrapperStyle: {} }, <div />);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('style')).toEqual({});
});

test('<wrapField> - renders wrapper with a custom validateStatus', () => {
const element = wrapField({ validateStatus: 'success' }, <div />);
const wrapper = mount(element);

expect(wrapper.find(Form.Item).prop('validateStatus')).toBe('success');
import { renderWithZod } from 'uniforms/__suites__';
import { z } from 'zod';

describe('wrapField tests', () => {
test('<wrapField> - renders wrapper with extra style', () => {
const { container } = renderWithZod({
element: wrapField(
{ wrapperStyle: { backgroundColor: 'red' } },
<div data-testid="x" />,
),
schema: z.object({}),
});
const element = container.getElementsByClassName('ant-form-item')[0];
expect(element?.getAttribute('style')).toBe('background-color: red;');
});

test('<wrapField> - renders wrapper with label and info', () => {
renderWithZod({
element: wrapField({ label: 'Label', info: 'Info' }, <div />),
schema: z.object({}),
});
expect(screen.getByRole('img').getAttribute('aria-label')).toBe(
'question-circle',
);
});

test('<wrapField> - renders wrapper with extra text', () => {
renderWithZod({
element: wrapField({ extra: 'Extra' }, <div data-testid="x" />),
schema: z.object({}),
});
expect(screen.getByText('Extra')).toBeInTheDocument();
});

test('<wrapField> - renders wrapper with a custom validateStatus', () => {
renderWithZod({
element: wrapField(
{ validateStatus: 'success' },
<div data-testid="x" />,
),
schema: z.object({}),
});
expect(
screen
.getByTestId('x')
.closest('.ant-form-item-has-feedback.ant-form-item-has-success'),
).toBeInTheDocument();
});
});
11 changes: 0 additions & 11 deletions packages/uniforms-bootstrap3/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions packages/uniforms-bootstrap3/__tests__/_mount.tsx

This file was deleted.

42 changes: 0 additions & 42 deletions packages/uniforms-bootstrap3/__tests__/gridClassName.ts

This file was deleted.

Loading

0 comments on commit 946faf6

Please sign in to comment.