From 427e6767c37d52e11f3659a4b2e42f012a8831b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Po=C5=9Bpiech?= Date: Fri, 24 May 2024 15:48:08 +0200 Subject: [PATCH] removed bootstrap3 theme --- .github/labeler.yml | 5 - README.md | 1 - docs/installation.mdx | 1 - package-lock.json | 14 -- packages/uniforms-bootstrap3/README.md | 11 -- .../uniforms-bootstrap3/__tests__/_mount.tsx | 14 -- .../__tests__/gridClassName.ts | 42 ------ .../uniforms-bootstrap3/__tests__/index.ts | 66 ---------- .../__tests__/wrapField.tsx | 84 ------------ packages/uniforms-bootstrap3/package.json | 41 ------ .../uniforms-bootstrap3/src/AutoField.tsx | 43 ------ .../uniforms-bootstrap3/src/AutoFields.tsx | 37 ------ packages/uniforms-bootstrap3/src/AutoForm.tsx | 13 -- packages/uniforms-bootstrap3/src/BaseForm.tsx | 40 ------ .../uniforms-bootstrap3/src/BoolField.tsx | 59 --------- .../uniforms-bootstrap3/src/DateField.tsx | 72 ---------- .../uniforms-bootstrap3/src/ErrorField.tsx | 36 ----- .../uniforms-bootstrap3/src/ErrorsField.tsx | 26 ---- .../uniforms-bootstrap3/src/HiddenField.tsx | 35 ----- .../uniforms-bootstrap3/src/ListAddField.tsx | 70 ---------- .../uniforms-bootstrap3/src/ListDelField.tsx | 68 ---------- .../uniforms-bootstrap3/src/ListField.tsx | 75 ----------- .../uniforms-bootstrap3/src/ListItemField.tsx | 30 ----- .../uniforms-bootstrap3/src/LongTextField.tsx | 32 ----- .../uniforms-bootstrap3/src/NestField.tsx | 41 ------ packages/uniforms-bootstrap3/src/NumField.tsx | 44 ------- .../uniforms-bootstrap3/src/QuickForm.tsx | 28 ---- .../uniforms-bootstrap3/src/RadioField.tsx | 55 -------- .../uniforms-bootstrap3/src/SelectField.tsx | 124 ------------------ .../uniforms-bootstrap3/src/SubmitField.tsx | 78 ----------- .../uniforms-bootstrap3/src/TextField.tsx | 35 ----- .../uniforms-bootstrap3/src/ValidatedForm.tsx | 13 -- .../src/ValidatedQuickForm.tsx | 5 - .../uniforms-bootstrap3/src/gridClassName.ts | 38 ------ packages/uniforms-bootstrap3/src/index.ts | 25 ---- packages/uniforms-bootstrap3/src/types.ts | 7 - .../uniforms-bootstrap3/src/wrapField.tsx | 112 ---------------- .../uniforms-bootstrap3/tsconfig.cjs.json | 12 -- .../uniforms-bootstrap3/tsconfig.esm.json | 12 -- reproductions/App.tsx | 1 - reproductions/package.json | 1 - tsconfig.build.json | 2 - tsconfig.global.json | 2 - website/components/ExampleCustomizer.tsx | 1 - website/components/Playground.tsx | 2 +- website/components/TutorialForm.tsx | 1 - website/lib/styles.tsx | 4 - website/lib/universal.tsx | 2 - website/package.json | 1 - website/pages-parts/LandingPage/WhyUs.tsx | 1 - 50 files changed, 1 insertion(+), 1561 deletions(-) delete mode 100644 packages/uniforms-bootstrap3/README.md delete mode 100644 packages/uniforms-bootstrap3/__tests__/_mount.tsx delete mode 100644 packages/uniforms-bootstrap3/__tests__/gridClassName.ts delete mode 100644 packages/uniforms-bootstrap3/__tests__/index.ts delete mode 100644 packages/uniforms-bootstrap3/__tests__/wrapField.tsx delete mode 100644 packages/uniforms-bootstrap3/package.json delete mode 100644 packages/uniforms-bootstrap3/src/AutoField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/AutoFields.tsx delete mode 100644 packages/uniforms-bootstrap3/src/AutoForm.tsx delete mode 100644 packages/uniforms-bootstrap3/src/BaseForm.tsx delete mode 100644 packages/uniforms-bootstrap3/src/BoolField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/DateField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ErrorField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ErrorsField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/HiddenField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ListAddField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ListDelField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ListField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ListItemField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/LongTextField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/NestField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/NumField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/QuickForm.tsx delete mode 100644 packages/uniforms-bootstrap3/src/RadioField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/SelectField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/SubmitField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/TextField.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ValidatedForm.tsx delete mode 100644 packages/uniforms-bootstrap3/src/ValidatedQuickForm.tsx delete mode 100644 packages/uniforms-bootstrap3/src/gridClassName.ts delete mode 100644 packages/uniforms-bootstrap3/src/index.ts delete mode 100644 packages/uniforms-bootstrap3/src/types.ts delete mode 100644 packages/uniforms-bootstrap3/src/wrapField.tsx delete mode 100644 packages/uniforms-bootstrap3/tsconfig.cjs.json delete mode 100644 packages/uniforms-bootstrap3/tsconfig.esm.json diff --git a/.github/labeler.yml b/.github/labeler.yml index a643b0c42..5bc3b45e4 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -42,7 +42,6 @@ - changed-files: - any-glob-to-any-file: - packages/uniforms-antd/**/* - - packages/uniforms-bootstrap3/**/* - packages/uniforms-bootstrap4/**/* - packages/uniforms-bootstrap5/**/* - packages/uniforms-material/**/* @@ -69,10 +68,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: diff --git a/README.md b/README.md index a49b7ccb1..b09bbdfd9 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ - **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** - **[Material](https://v4.mui.com/) theme** diff --git a/docs/installation.mdx b/docs/installation.mdx index d6b973226..2ed1a9ccf 100644 --- a/docs/installation.mdx +++ b/docs/installation.mdx @@ -37,7 +37,6 @@ Now the schema package. { name: 'Semantic' }, { name: 'Material' }, { name: 'MUI' }, - { name: 'Bootstrap3' }, { name: 'Bootstrap4' }, { name: 'Bootstrap5' }, { name: 'AntD' }, diff --git a/package-lock.json b/package-lock.json index 17a3e4fac..1c76069dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,6 @@ "eslint-config-vazco": "6.2.0", "eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-typescript": "2.3.0", - "graphql": "^15.0.0", "husky": "8.0.1", "invariant": "^2.0.0", "jest": "27.0.6", @@ -15806,14 +15805,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, - "node_modules/graphql": { - "version": "15.5.3", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.5.3.tgz", - "integrity": "sha512-sM+jXaO5KinTui6lbK/7b7H/Knj9BpjGxZ+Ki35v7YbUJxxdBCUqNM0h3CRVU1ZF9t5lNiBzvBCSYPvIwxPOQA==", - "engines": { - "node": ">= 10.x" - } - }, "node_modules/gray-matter": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz", @@ -40359,11 +40350,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, - "graphql": { - "version": "15.5.3", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.5.3.tgz", - "integrity": "sha512-sM+jXaO5KinTui6lbK/7b7H/Knj9BpjGxZ+Ki35v7YbUJxxdBCUqNM0h3CRVU1ZF9t5lNiBzvBCSYPvIwxPOQA==" - }, "gray-matter": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz", diff --git a/packages/uniforms-bootstrap3/README.md b/packages/uniforms-bootstrap3/README.md deleted file mode 100644 index bf4963a4a..000000000 --- a/packages/uniforms-bootstrap3/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# uniforms-bootstrap3 - -> Bootstrap3 UI components for `uniforms`. - -## Install - -```sh -$ npm install uniforms-bootstrap3 -``` - -For more in depth documentation see [uniforms.tools](https://uniforms.tools). diff --git a/packages/uniforms-bootstrap3/__tests__/_mount.tsx b/packages/uniforms-bootstrap3/__tests__/_mount.tsx deleted file mode 100644 index d586e42dd..000000000 --- a/packages/uniforms-bootstrap3/__tests__/_mount.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { mount as enzyme } from 'enzyme'; -import { context } from 'uniforms'; - -function mount(node: any, options: any) { - if (options === undefined) { - return enzyme(node); - } - return enzyme(node, { - wrappingComponent: context.Provider, - wrappingComponentProps: { value: options.context }, - }); -} - -export default mount as typeof enzyme; diff --git a/packages/uniforms-bootstrap3/__tests__/gridClassName.ts b/packages/uniforms-bootstrap3/__tests__/gridClassName.ts deleted file mode 100644 index 1af0c5192..000000000 --- a/packages/uniforms-bootstrap3/__tests__/gridClassName.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { gridClassName } from 'uniforms-bootstrap3'; - -test('gridClassName - object', () => { - expect(gridClassName({ md: 3 }, 'input')).toBe('col-md-9'); - expect(gridClassName({ md: 5 }, 'input')).toBe('col-md-7'); - expect(gridClassName({ md: 7 }, 'input')).toBe('col-md-5'); - expect(gridClassName({ md: 9 }, 'input')).toBe('col-md-3'); - expect(gridClassName({ md: 3, xs: 2 }, 'input')).toBe('col-md-9 col-xs-10'); - expect(gridClassName({ md: 5, xs: 4 }, 'input')).toBe('col-md-7 col-xs-8'); - expect(gridClassName({ md: 7, xs: 6 }, 'input')).toBe('col-md-5 col-xs-6'); - expect(gridClassName({ md: 9, xs: 8 }, 'input')).toBe('col-md-3 col-xs-4'); - - expect(gridClassName({ md: 3 }, 'label')).toBe('col-md-3'); - expect(gridClassName({ md: 5 }, 'label')).toBe('col-md-5'); - expect(gridClassName({ md: 7 }, 'label')).toBe('col-md-7'); - expect(gridClassName({ md: 9 }, 'label')).toBe('col-md-9'); - expect(gridClassName({ md: 3, xs: 2 }, 'label')).toBe('col-md-3 col-xs-2'); - expect(gridClassName({ md: 5, xs: 4 }, 'label')).toBe('col-md-5 col-xs-4'); - expect(gridClassName({ md: 7, xs: 6 }, 'label')).toBe('col-md-7 col-xs-6'); - expect(gridClassName({ md: 9, xs: 8 }, 'label')).toBe('col-md-9 col-xs-8'); -}); - -test('gridClassName - number', () => { - expect(gridClassName(3, 'input')).toBe('col-sm-9'); - expect(gridClassName(3, 'label')).toBe('col-sm-3'); - expect(gridClassName(5, 'input')).toBe('col-sm-7'); - expect(gridClassName(5, 'label')).toBe('col-sm-5'); -}); - -test('gridClassName - number (string)', () => { - expect(gridClassName('3', 'input')).toBe('col-sm-9'); - expect(gridClassName('3', 'label')).toBe('col-sm-3'); - expect(gridClassName('5', 'input')).toBe('col-sm-7'); - expect(gridClassName('5', 'label')).toBe('col-sm-5'); -}); - -test('gridClassName - string', () => { - expect(gridClassName('col-md-9')).toBe('col-md-9'); - expect(gridClassName('col-md-3')).toBe('col-md-3'); - expect(gridClassName('col-md-7')).toBe('col-md-7'); - expect(gridClassName('col-md-5')).toBe('col-md-5'); -}); diff --git a/packages/uniforms-bootstrap3/__tests__/index.ts b/packages/uniforms-bootstrap3/__tests__/index.ts deleted file mode 100644 index 73501bc3f..000000000 --- a/packages/uniforms-bootstrap3/__tests__/index.ts +++ /dev/null @@ -1,66 +0,0 @@ -import * as theme from 'uniforms-bootstrap3'; -import * as suites from 'uniforms/__suites__'; - -it('exports everything', () => { - expect(theme).toEqual({ - AutoFields: expect.any(Function), - AutoField: expect.any(Function), - AutoForm: expect.any(Function), - BaseForm: expect.any(Function), - BoolField: expect.any(Function), - DateField: expect.any(Function), - ErrorField: expect.any(Function), - ErrorsField: expect.any(Function), - HiddenField: expect.any(Function), - ListAddField: expect.any(Function), - ListDelField: expect.any(Function), - ListField: expect.any(Function), - ListItemField: expect.any(Function), - LongTextField: expect.any(Function), - NestField: expect.any(Function), - NumField: expect.any(Function), - QuickForm: expect.any(Function), - RadioField: expect.any(Function), - SelectField: expect.any(Function), - SubmitField: expect.any(Function), - TextField: expect.any(Function), - ValidatedForm: expect.any(Function), - ValidatedQuickForm: expect.any(Function), - gridClassName: expect.any(Function), - wrapField: expect.any(Function), - }); -}); - -describe('@RTL', () => { - suites.testAutoField(theme.AutoField, { - getDateField: screen => screen.getByLabelText('X'), - getSelectField: screen => screen.getByRole('combobox'), - }); - suites.testAutoForm(theme.AutoForm); - suites.testBaseForm(theme.BaseForm); - suites.testBoolField(theme.BoolField, { testInline: true }); - suites.testDateField(theme.DateField); - suites.testErrorField(theme.ErrorField); - suites.testErrorsField(theme.ErrorsField); - suites.testHiddenField(theme.HiddenField); - suites.testListAddField(theme.ListAddField); - suites.testListDelField(theme.ListDelField); - suites.testListField(theme.ListField, { - getListAddField: screen => screen.getByRole('button'), - disableInlineError: true, - }); - suites.testListItemField(theme.ListItemField); - suites.testLongTextField(theme.LongTextField); - suites.testNestField(theme.NestField); - suites.testNumField(theme.NumField); - suites.testQuickForm(theme.QuickForm); - suites.testRadioField(theme.RadioField); - suites.testSelectField(theme.SelectField, { - getCheckboxInlineOption: screen => - screen.getByLabelText('a').closest('.checkbox-inline'), - }); - suites.testSubmitField(theme.SubmitField); - suites.testTextField(theme.TextField, { testWrapClassName: true }); - suites.testValidatedForm(theme.ValidatedForm); - suites.testValidatedQuickForm(theme.ValidatedQuickForm); -}); diff --git a/packages/uniforms-bootstrap3/__tests__/wrapField.tsx b/packages/uniforms-bootstrap3/__tests__/wrapField.tsx deleted file mode 100644 index 9089eec21..000000000 --- a/packages/uniforms-bootstrap3/__tests__/wrapField.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import React from 'react'; -import { wrapField } from 'uniforms-bootstrap3'; - -import mount from './_mount'; - -test(' - renders wrapper with correct class', () => { - const element = wrapField({ wrapClassName: 'container' },
); - const wrapper = mount(element); - - expect(wrapper.find('.container')).toHaveLength(1); -}); - -test(' - renders help block', () => { - const element = wrapField({ help: 'Hint' },
); - const wrapper = mount(element); - - expect(wrapper.find('.help-block').text()).toBe('Hint'); -}); - -test(' - renders help block with specified class', () => { - const element = wrapField( - { help: 'Hint', helpClassName: 'text-hint' }, -
, - ); - const wrapper = mount(element); - - expect(wrapper.find('.help-block.text-hint')).toHaveLength(1); -}); - -test(' - renders error block', () => { - const error = new Error(); - const element = wrapField( - { error, showInlineError: true, errorMessage: 'Error' }, -
, - ); - const wrapper = mount(element); - - expect(wrapper.find('.help-block').text()).toBe('Error'); -}); - -test(' - renders error block (feedbackable)', () => { - const error = new Error(); - const element = wrapField({ error, feedbackable: true },
); - const wrapper = mount(element); - - expect(wrapper.find('.form-control-feedback')).toHaveLength(1); -}); - -test(' - renders error block (showInlineError=false)', () => { - const error = new Error(); - const element = wrapField( - { error, showInlineError: false, errorMessage: 'Error' }, -
, - ); - const wrapper = mount(element); - - expect(wrapper.find('.help-block')).toHaveLength(0); -}); - -test(' - label has custom class (String)', () => { - const element = wrapField( - { - label: 'A field label', - labelClassName: 'custom-label-class', - }, -
, - ); - const wrapper = mount(element); - - expect(wrapper.find('label.custom-label-class')).toHaveLength(1); -}); - -test(' - label has custom class (Array[String])', () => { - const element = wrapField( - { - label: 'A field label', - labelClassName: ['custom-1', 'custom-2'], - }, -
, - ); - const wrapper = mount(element); - - expect(wrapper.find('label.custom-1.custom-2')).toHaveLength(1); -}); diff --git a/packages/uniforms-bootstrap3/package.json b/packages/uniforms-bootstrap3/package.json deleted file mode 100644 index 99c858e4a..000000000 --- a/packages/uniforms-bootstrap3/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "uniforms-bootstrap3", - "version": "4.0.0-alpha.5", - "license": "MIT", - "main": "./cjs/index.js", - "module": "./esm/index.js", - "sideEffects": false, - "description": "Bootstrap3 UI components for uniforms.", - "repository": "https://github.com/vazco/uniforms/tree/master/packages/uniforms-bootstrap3", - "bugs": "https://github.com/vazco/uniforms/issues", - "funding": "https://github.com/vazco/uniforms?sponsor=1", - "keywords": [ - "bootstrap", - "form", - "forms", - "meteor", - "react", - "react-component", - "schema", - "validation" - ], - "files": [ - "cjs/*.d.ts", - "cjs/*.js", - "esm/*.d.ts", - "esm/*.js", - "src/*.ts", - "src/*.tsx" - ], - "peerDependencies": { - "react": "^18.0.0 || ^17.0.0 || ^16.8.0" - }, - "dependencies": { - "classnames": "^2.0.0", - "invariant": "^2.0.0", - "lodash": "^4.0.0", - "tslib": "^2.2.0", - "uniforms": "^4.0.0-alpha.5", - "warning": "^4.0.0" - } -} diff --git a/packages/uniforms-bootstrap3/src/AutoField.tsx b/packages/uniforms-bootstrap3/src/AutoField.tsx deleted file mode 100644 index fe7a4693f..000000000 --- a/packages/uniforms-bootstrap3/src/AutoField.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import invariant from 'invariant'; -export { AutoFieldProps } from 'uniforms'; -import { createAutoField } from 'uniforms'; - -import BoolField from './BoolField'; -import DateField from './DateField'; -import ListField from './ListField'; -import NestField from './NestField'; -import NumField from './NumField'; -import RadioField from './RadioField'; -import SelectField from './SelectField'; -import TextField from './TextField'; - -const AutoField = createAutoField(props => { - if (props.component) { - return props.component; - } - - if (props.options) { - return props.checkboxes && props.fieldType !== Array - ? RadioField - : SelectField; - } - - switch (props.fieldType) { - case Array: - return ListField; - case Boolean: - return BoolField; - case Date: - return DateField; - case Number: - return NumField; - case Object: - return NestField; - case String: - return TextField; - } - - return invariant(false, 'Unsupported field type: %s', props.fieldType); -}); - -export default AutoField; diff --git a/packages/uniforms-bootstrap3/src/AutoFields.tsx b/packages/uniforms-bootstrap3/src/AutoFields.tsx deleted file mode 100644 index 1f70b06e0..000000000 --- a/packages/uniforms-bootstrap3/src/AutoFields.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { ComponentType, Fragment, createElement } from 'react'; -import { useForm } from 'uniforms'; - -import AutoField from './AutoField'; - -export type AutoFieldsProps = { - element?: ComponentType | string; - fields?: string[]; - omitFields?: string[]; - showInlineError?: boolean; -}; - -export default function AutoFields({ - element = Fragment, - fields, - omitFields = [], - showInlineError, - ...props -}: AutoFieldsProps) { - const { schema } = useForm(); - - return createElement( - element, - props, - (fields ?? schema.getSubfields()) - .filter(field => !omitFields.includes(field)) - .map(field => - createElement( - AutoField, - Object.assign( - { key: field, name: field }, - showInlineError === undefined ? null : { showInlineError }, - ), - ), - ), - ); -} diff --git a/packages/uniforms-bootstrap3/src/AutoForm.tsx b/packages/uniforms-bootstrap3/src/AutoForm.tsx deleted file mode 100644 index ea8321711..000000000 --- a/packages/uniforms-bootstrap3/src/AutoForm.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { AutoForm } from 'uniforms'; - -import ValidatedQuickForm from './ValidatedQuickForm'; - -function Auto(parent: any) { - class _ extends AutoForm.Auto(parent) { - static Auto = Auto; - } - - return _ as unknown as AutoForm; -} - -export default Auto(ValidatedQuickForm); diff --git a/packages/uniforms-bootstrap3/src/BaseForm.tsx b/packages/uniforms-bootstrap3/src/BaseForm.tsx deleted file mode 100644 index fc4e96cc2..000000000 --- a/packages/uniforms-bootstrap3/src/BaseForm.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import classnames from 'classnames'; -import { BaseForm } from 'uniforms'; - -function Bootstrap3(parent: any) { - class _ extends parent { - static Bootstrap3 = Bootstrap3; - - static displayName = `Bootstrap3${parent.displayName}`; - - getContextState() { - return { - ...super.getContextState(), - grid: this.props.grid, - }; - } - - getNativeFormProps() { - const error = this.getContextError(); - const { - className, - grid, - - ...props - } = super.getNativeFormProps(); - - return { - ...props, - className: classnames( - 'form', - { error, 'form-horizontal': grid }, - className, - ), - }; - } - } - - return _ as unknown as typeof BaseForm; -} - -export default Bootstrap3(BaseForm); diff --git a/packages/uniforms-bootstrap3/src/BoolField.tsx b/packages/uniforms-bootstrap3/src/BoolField.tsx deleted file mode 100644 index 80b1447f4..000000000 --- a/packages/uniforms-bootstrap3/src/BoolField.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import classnames from 'classnames'; -import React, { Ref } from 'react'; -import { connectField, HTMLFieldProps } from 'uniforms'; - -import wrapField from './wrapField'; - -export type BoolFieldProps = HTMLFieldProps< - boolean, - HTMLDivElement, - { - inline?: boolean; - inputClassName?: string; - inputRef?: Ref; - labelBefore?: string; - } ->; - -function Bool(props: BoolFieldProps) { - const { - disabled, - inline, - inputClassName, - label, - labelBefore, - name, - onChange, - readOnly, - value, - } = props; - return wrapField( - { ...props, label: labelBefore }, -
- -
, - ); -} - -export default connectField(Bool, { kind: 'leaf' }); diff --git a/packages/uniforms-bootstrap3/src/DateField.tsx b/packages/uniforms-bootstrap3/src/DateField.tsx deleted file mode 100644 index 63f69f72b..000000000 --- a/packages/uniforms-bootstrap3/src/DateField.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import classnames from 'classnames'; -import React, { Ref } from 'react'; -import { connectField, HTMLFieldProps } from 'uniforms'; - -import wrapField from './wrapField'; - -type DateFieldType = 'date' | 'datetime-local'; - -/* istanbul ignore next */ -const DateConstructor = (typeof global === 'object' ? global : window).Date; -const dateFormat = (value?: Date, type: DateFieldType = 'datetime-local') => - value?.toISOString().slice(0, type === 'datetime-local' ? -8 : -14); - -export type DateFieldProps = HTMLFieldProps< - Date, - HTMLDivElement, - { - error: unknown; - inputClassName?: string; - inputRef?: Ref; - max?: Date; - min?: Date; - wrapClassName?: string; - type?: DateFieldType; - } ->; - -function Date({ - disabled, - error, - id, - inputClassName, - inputRef, - max, - min, - name, - onChange, - placeholder, - readOnly, - value, - type = 'datetime-local', - ...props -}: DateFieldProps) { - return wrapField( - { ...props, id }, - { - const date = new DateConstructor(event.target.valueAsNumber); - if (date.getFullYear() < 10000) { - onChange(date); - } else if (isNaN(event.target.valueAsNumber)) { - onChange(undefined); - } - }} - placeholder={placeholder} - readOnly={readOnly} - ref={inputRef} - type={type} - value={dateFormat(value, type) ?? ''} - />, - ); -} - -export default connectField(Date, { kind: 'leaf' }); diff --git a/packages/uniforms-bootstrap3/src/ErrorField.tsx b/packages/uniforms-bootstrap3/src/ErrorField.tsx deleted file mode 100644 index 3ddcb803d..000000000 --- a/packages/uniforms-bootstrap3/src/ErrorField.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import classnames from 'classnames'; -import React, { HTMLProps } from 'react'; -import { connectField, filterDOMProps, Override } from 'uniforms'; - -export type ErrorFieldProps = Override< - Omit, 'onChange'>, - { error?: any; errorMessage?: string } ->; - -function Error({ - children, - className, - error, - errorMessage, - ...props -}: ErrorFieldProps) { - return !error ? null : ( -
-
- {children || ( -
-

{errorMessage}

-
- )} -
-
- ); -} - -export default connectField(Error, { - initialValue: false, - kind: 'leaf', -}); diff --git a/packages/uniforms-bootstrap3/src/ErrorsField.tsx b/packages/uniforms-bootstrap3/src/ErrorsField.tsx deleted file mode 100644 index 64b827da0..000000000 --- a/packages/uniforms-bootstrap3/src/ErrorsField.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import classnames from 'classnames'; -import React, { HTMLProps } from 'react'; -import { filterDOMProps, useForm } from 'uniforms'; - -export type ErrorsFieldProps = HTMLProps; - -function ErrorsField({ className, children, ...props }: ErrorsFieldProps) { - const { error, schema } = useForm(); - - return !error && !children ? null : ( -
-
- {children} - - {schema.getErrorMessages(error).map((message, index) => ( -
{message}
- ))} -
-
- ); -} - -export default ErrorsField; diff --git a/packages/uniforms-bootstrap3/src/HiddenField.tsx b/packages/uniforms-bootstrap3/src/HiddenField.tsx deleted file mode 100644 index 616f87f08..000000000 --- a/packages/uniforms-bootstrap3/src/HiddenField.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { HTMLProps, Ref, useEffect } from 'react'; -import { Override, filterDOMProps, useField } from 'uniforms'; - -export type HiddenFieldProps = Override< - HTMLProps, - { - inputRef?: Ref; - name: string; - noDOM?: boolean; - value?: unknown; - } ->; - -export default function HiddenField({ value, ...rawProps }: HiddenFieldProps) { - const props = useField(rawProps.name, rawProps, { initialValue: false })[0]; - - useEffect(() => { - if (value !== undefined && value !== props.value) { - props.onChange(value); - } - }); - - return props.noDOM ? null : ( - - ); -} diff --git a/packages/uniforms-bootstrap3/src/ListAddField.tsx b/packages/uniforms-bootstrap3/src/ListAddField.tsx deleted file mode 100644 index b48dac9af..000000000 --- a/packages/uniforms-bootstrap3/src/ListAddField.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import classnames from 'classnames'; -import cloneDeep from 'lodash/cloneDeep'; -import React, { ReactNode } from 'react'; -import { - HTMLFieldProps, - connectField, - filterDOMProps, - joinName, - useField, -} from 'uniforms'; - -export type ListAddFieldProps = HTMLFieldProps< - unknown, - HTMLDivElement, - { addIcon?: ReactNode } ->; - -function ListAdd({ - addIcon, - className, - disabled, - name, - readOnly, - value, - ...props -}: ListAddFieldProps) { - const nameParts = joinName(null, name); - const parentName = joinName(nameParts.slice(0, -1)); - const parent = useField< - { - maxCount?: number; - }, - unknown[] - >(parentName, {}, { absoluteName: true })[0]; - - const limitNotReached = - !disabled && !(parent.maxCount! <= parent.value!.length); - - function onAction(event: React.KeyboardEvent | React.MouseEvent) { - if ( - limitNotReached && - !readOnly && - (!('key' in event) || event.key === 'Enter') - ) { - parent.onChange(parent.value!.concat([cloneDeep(value)])); - } - } - - return ( -
- {addIcon} -
- ); -} - -ListAdd.defaultProps = { - addIcon: , -}; - -export default connectField(ListAdd, { - initialValue: false, - kind: 'leaf', -}); diff --git a/packages/uniforms-bootstrap3/src/ListDelField.tsx b/packages/uniforms-bootstrap3/src/ListDelField.tsx deleted file mode 100644 index 8c844a41b..000000000 --- a/packages/uniforms-bootstrap3/src/ListDelField.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import classnames from 'classnames'; -import React, { ReactNode } from 'react'; -import { - HTMLFieldProps, - connectField, - filterDOMProps, - joinName, - useField, -} from 'uniforms'; - -export type ListDelFieldProps = HTMLFieldProps< - unknown, - HTMLDivElement, - { removeIcon?: ReactNode } ->; - -function ListDel({ - className, - disabled, - name, - readOnly, - removeIcon, - ...props -}: ListDelFieldProps) { - const nameParts = joinName(null, name); - const nameIndex = +nameParts[nameParts.length - 1]; - const parentName = joinName(nameParts.slice(0, -1)); - const parent = useField<{ minCount?: number }, unknown[]>( - parentName, - {}, - { absoluteName: true }, - )[0]; - - disabled ||= readOnly || parent.minCount! >= parent.value!.length; - function onAction( - event: - | React.KeyboardEvent - | React.MouseEvent, - ) { - if (!disabled && (!('key' in event) || event.key === 'Enter')) { - const value = parent.value!.slice(); - value.splice(nameIndex, 1); - parent.onChange(value); - } - } - - return ( - - {removeIcon} - - ); -} - -ListDel.defaultProps = { - removeIcon: , -}; - -export default connectField(ListDel, { - initialValue: false, - kind: 'leaf', -}); diff --git a/packages/uniforms-bootstrap3/src/ListField.tsx b/packages/uniforms-bootstrap3/src/ListField.tsx deleted file mode 100644 index c2bb9c943..000000000 --- a/packages/uniforms-bootstrap3/src/ListField.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import classnames from 'classnames'; -import React, { - Children, - ReactNode, - cloneElement, - isValidElement, -} from 'react'; -import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms'; - -import ListAddField from './ListAddField'; -import ListItemField from './ListItemField'; - -export type ListFieldProps = HTMLFieldProps< - unknown[], - HTMLDivElement, - { - addIcon?: ReactNode; - itemProps?: object; - removeIcon?: ReactNode; - } ->; - -function List({ - addIcon, - children = , - className, - error, - errorMessage, - itemProps, - label, - removeIcon, - showInlineError, - value, - ...props -}: ListFieldProps) { - return ( -
-
- {label && ( -
- - - - - {!!(error && showInlineError) && ( - {errorMessage} - )} -
- )} - - {value?.map((item, itemIndex) => - Children.map(children, (child, childIndex) => - isValidElement(child) - ? cloneElement(child, { - key: `${itemIndex}-${childIndex}`, - name: child.props.name?.replace('$', '' + itemIndex), - ...itemProps, - removeIcon, - }) - : child, - ), - )} -
-
- ); -} - -export default connectField(List); diff --git a/packages/uniforms-bootstrap3/src/ListItemField.tsx b/packages/uniforms-bootstrap3/src/ListItemField.tsx deleted file mode 100644 index 06713d84d..000000000 --- a/packages/uniforms-bootstrap3/src/ListItemField.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React, { ReactNode } from 'react'; -import { connectField } from 'uniforms'; - -import AutoField from './AutoField'; -import ListDelField from './ListDelField'; - -export type ListItemFieldProps = { - children?: ReactNode; - name: string; - removeIcon?: ReactNode; - value?: unknown; -}; - -function ListItem({ - children = , - removeIcon, -}: ListItemFieldProps) { - return ( -
-
- -
- {children} -
- ); -} - -export default connectField(ListItem, { - initialValue: false, -}); diff --git a/packages/uniforms-bootstrap3/src/LongTextField.tsx b/packages/uniforms-bootstrap3/src/LongTextField.tsx deleted file mode 100644 index 2a2157a29..000000000 --- a/packages/uniforms-bootstrap3/src/LongTextField.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import classnames from 'classnames'; -import React, { Ref } from 'react'; -import { connectField, HTMLFieldProps } from 'uniforms'; - -import wrapField from './wrapField'; - -export type LongTextFieldProps = HTMLFieldProps< - string, - HTMLDivElement, - { inputClassName?: string; inputRef?: Ref } ->; - -function LongText(props: LongTextFieldProps) { - return wrapField( - props, -