-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Updated fluent-ui theme to use new @rjsf/utils and @rjsf/validator #2918
Closed
heath-freenome
wants to merge
16
commits into
rjsf-team:master
from
heath-freenome:fluent-ui-conversion
Closed
Updated fluent-ui theme to use new @rjsf/utils and @rjsf/validator #2918
heath-freenome
wants to merge
16
commits into
rjsf-team:master
from
heath-freenome:fluent-ui-conversion
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Implemented the utils package - Refactored the `packages/core/src/utils.js` file into separate typescript files in the new `packages/utils/src` * - More changes * - Added all of the non-validation-based utilities and many of the tests * - removed schema related files temporarily * - Added missing tests to get test coverage up to 100% for all but `getWidget()` - Also did some cleanup in the `src` files, moving types into `types.ts`, and exporting all the types * - Fixed getWidget tests * - Update README.md * - update the target to for typescript in * - revert `package-lock.json` for antd, core and playground * - fix build issues * - Added the `rjsf-v5` branch to the `ci.yml` - Added a new `RJSFSchema` as a redefine of `JSONSchema7` to make changing schemas everywhere else easier - Updated all the utils and tests to change `JSONSchema7` to `RJSFSchema` - Fixed test breaks by casting e to Error * - changed tabs to spaces in package.json, fixed bug in deepEquals * - Add `tsdx` to `package.json` to enable running `npm run test` inside of the `packages/utils` directory - Bumped `@types/jest` to match the version in use by `tsdx` - Fixed the `utcToLocal()` test by mocking the `getDate()` and `getHours()` functions to be UTC + 2 hours to avoid server vs local timezone issues * - Began adding documentation to the utility functions - Reordered the logic in `asNumber` to avoid converting to number until we have to - Updated `findSchemaDefinition()` to handle the case where a `$ref` in a schema also contains additional props - Updated `getSubmitButtonOptions()` to export its `DEFAULT_OPTIONS` for testing purposes - Updated `getUiOptions()` to no longer support `ui:widget` objects as it has been deprecated for years - Made some other test fixes * - Finished adding documentation to all of the remaining utils methods * - Minor documentation changes, and allow `findSchemaDefinition()` to support undefined ref name * - Responded to self-review comments
* Implemented the utils package - Refactored the `packages/core/src/utils.js` file into separate typescript files in the new `packages/utils/src` * - More changes * - Added all of the non-validation-based utilities and many of the tests * - removed schema related files temporarily * - revert `package-lock.json` for antd, core and playground * - The schema utilities that require validation * - More changes * - completed conversion to Typescript with some changes that were needed * - Updated various files to make some parameters optional, to add generics typing where missed - Created an `index.ts` in the `schema` subdirectory that exports all of the schema related functions - Updated `types.ts` to add the new `SchemaUtilsType` interface - Implemented a `createSchemaUtils()` function that returns a `SchemaUtilsType` interface given a `ValidatorType` and a `rootSchema` * - Implemented createSchemaUtils - Began testing the schema-based utils * - More fixes and adding missing generics * - Converted all the schema based tests over still missing 100% coverage * - Completed 100% unit testing * - Added documentation for most of the files and cleaned up some optionality on some arguments * - Completed all of the documentation of the schema-based utils * - Changed the `_NAME` constants to `_KEY` * - Added missing generics on a few types * - Added `ERRORS_KEY` constant for use in validation * - Fixed types based on implementation of validator * - Added missing generic to the `ValidationData` type for `ErrorSchema` * - Fixed tests for the missing generic type * - Incorporated rjsf-team#2876 by making props for UISchemaSubmitButtonOptions optional * - Added generic `<T>` to the return value of `toIdSchema()` and `toPathSchema()`
…rjsf-team#2899) * Refactored schema to support runnings from other packages - Fixed the import of `types` in `mergeSchemas.ts` - Renamed all of the `xxx.test.ts` to `xxxTest.ts` and wrapped them in an outer `xxxTest()` function that takes a `TestValidatorType` - Added a `types.ts` file in the `schema` directory to provide the `TestValidatorType` and `TestValidatorParams` interfaces - Added an `index.ts` file in the `schema` directory to export all of the `xxxTest` functions - Updated `getTestValidator()` to import the types from the `schema/types` - Added a `test/schema.test.ts` to create a `TestValidator` and run all of the `xxxTest()` functions from `schema` * - Fixed the tests based on using the real validator * - Removed the use of `xxx.hasOwnProperty('y')` in favor `'y' in xxx` to eliminate lint warnings - Fixed bug in `stubExistingAdditionalProperties()` related to the `additionalProperties: true` case, adding new test to verify fix * - Removed console.log statement * - Moved `stubExistingAdditionalProperties()` into the `retrieveSchema.ts` file to eliminate a circular dependency - Did the same for the `stubExistingAdditionalPropertiesTest()` function - Updated the `index.ts` files to remove the `stubExistingAdditionalProperties[Test]()` functions - Updated `SchemaUtilsType` and `createSchemaUtils` to remove the `stubExistingAdditionalProperties()` function
* Added new package for validator-ajv6 - Refactored `packages/core/src/validate.js` into this new package * - Switched to the new `@rjsf/utils` library and types * - Finished types conversion to @rjsf/utils - Began adding tests * - Completed conversion for validator class-based tests. Just need to get to 100% 1 * - Finished 100% test coverage and documentation of the `AJV6Validator` * - Completed the documentation of the remaining methods and types for the library * - Responded to self-review feedback and also fixed tests to hopefully get it to pass * - Fixed the build (this time hopefully) * - Switched to just passing `stack` instead of the whole empty object * - Added hacky run of tests from within the utils directory * - Fixed a few little things * - Fixed bug in custom validation, including adding a test to detect it * - Removed schema utils test for `stubExistingAdditionalPropertiesTest()` as it no longer exists * - Fixed self-review feedback and the import in the `test/createAjvInstance.test.ts` - Also bumped all the packages that made sense
…am#2903) * Update utils based on core refactor and update package.jsons - Updated the main `package.json` to bump typescript - Updated the utils `package.json` to bump everything but react - Updated `SchemaUtilsType` to add the `getValidator()` and `doesSchemaUtilsDiffer()` functions - Updated `createSchemaUtils()` to implement the new functions and the tests to validate them - Also updated other types to deal with issues found during core refactor - Changed `FormValidation` to `ErrorSchema` as needed - Updated the `Registry` type to remove `definitions` as it is never used and added the `xxxTemplate` props - Updated many interfaces to make previously required props to be optional - Switched to using the `React.ComponentType` which incorporates the `FunctionComponent` and `ClassComponent` both - Fixed a bug in `getDefaultFormState()` by making the `array` defaults use effectively the same logic as it did in `core` but refactored to a function for type safety - Updated the tests to add one that verifies the bug is fixed * - rollback typescript to previous version due to `fluent-ui` issue * - Fixed bug in `getSchemaType()` related to incorrectly defaulting to `string` when no type exists * - Made `uiSchema` optional in `canExpand()`, `getSubmitButtonOptions()` and `getUiOptions()` - Updated the required-ness of a smattering of props in interfaces * - Made all callbacks be required again * - Made label required again * - More updates to make `uiSchema` optional * - Added new `processSelectValue()` utility, refactored from core's `SelectWidget`, with full tests - Also updated the `UIOptionsType` to add optional `title` and `description` props, typed to `string` to eliminate the need to type cast them * - Added documentation for the `[key: string]` prop * - Responded to reviewer feedback
- Removed the `index.d.ts` file since all the types are now exported in `@rjsf/utils` - Updated `package*.json` to make changes consistent with pulling utils and validator-ajv6 libraries - Removed `core-js-pure`, `json-schema-merge-allof`, `jsonpointer` and `react-is` from `dependencies` in favor of `@rjsf/utils` - Moved `ajv` and `@types/json-schema` into the `devDependencies` - Added `@rjsf/validator-ajv6`, `@types/lodash` and `tsdx` - Also, removed all mentions of `index.d.ts` - Converted `ErrorList` to typescript, pulling types from `@rjsf/utils` - Converted `Form` to typescript - Built `FormProps` and `FormState` props which are exported - Pulled in all the types from `@rjsf/utils` functions - Removed the `additionalMetaSchemas` and `customFormats` props in favor of the new, required `validator: ValidatorType` prop - Updated `getStateFromProps()` to create a `SchemaUtilsType` object and put it into both the state and the registry as `schemaUtils` - Switched to using the `schemaUtils.getValidator()` to access the `validateFormData()` and `toErrorList()` calls - Switched to using `schemaUtils` to access `getDefaultFormState()`, `toIdSchema()`, `toPathSchema()` and `retrieveSchema()` - Updated `ArrayField` to use the `@rjsf/utils` functions - Also, switched to the `includes` function from `lodash` - Pull the `schemaUtils` from the `registry` and used it for `getDefaultFormState()`, `isMultiSelect()`, `isFilesArray()`, `retrieveSchema()` and `toIdSchema()` - Switched from `xxx.hadOwnProperty('y')` to `'y' in xxx` to remove an eslint warning - Updated `BooleanField`, `NumberField`, `CheckboxWidget`, `DateTimeWidget`, `FileWidget`, `RangeWidget`, `SelectWidget` and `UpDownWidget` to pull utility functions from `@rjsf/utils` - Updated `MultiSchemaField` to use the `@rjsf/utils` functions - Pulled the `schemaUtils` from the `registry` and used it for `getDefaultFormState()` and `getMatchingOption()` - Switched from `xxx.hadOwnProperty('y')` to `'y' in xxx` to remove an eslint warning - Updated `ObjectField` to use the `@rjsf/utils` functions - Pulled the `schemaUtils` from the `registry` and used it for `retrieveSchema()` - Switched from `xxx.hadOwnProperty('y')` to `'y' in xxx` to remove an eslint warning - Updated `SchemaField` to use the `@rjsf/utils` functions - Pulled the `schemaUtils` from the `registry` and used it for `getDisplayLabel()`, `isSelect()`, `retrieveSchema()` and `toIdSchema()` - Switched from `xxx.hadOwnProperty('y')` to `'y' in xxx` to remove an eslint warning - Updated `StringField` to use the `@rjsf/utils` functions - Pulled the `schemaUtils` from the `registry` and used it for `isSelect()` - Updated `AltDateWidget` to use the `@rjsf/utils` functions - Removed `prevState` from `componentDidUpdate()` because it is not used, removing lint error - Updated `TextWidget` to add `bool` as a type for the value to avoid a React error that failed tests - Converted `SubmitButton` to typescript, pulling types from `@rjsf/utils` and exporting it's props type - Converted `getDefaultRegistry()` to typescript, pulling types from `@rjsf/utils` - Changed the export to be `default` - Temporarily needing to cast `fields` and `widgets` to the proper type until they are converted - Converted `withTheme()` to typescript, pulling types from `@rjsf/utils` and the typescript `Form` - Converted the `src/index.js` file to Typescript, exporting both the `Form` and its types along with `withTheme()`, `getDefaultRegistry()` - Updated the `types.js` file to remove `definitions` and add in `schemaUtils` ffor the `registry` type. - Deleted the `src/utils.js`, `src/validate.js` files since they have been replaced with `@rjsf/utils/` and `@rjsf/validator-ajv6` - Removed the `utils_test.js` file entirely and only kept the `Form` integration part of the `validate_test.js` - Updated the tests as follows to make things work with `@rjsf/utils` and `@rjsf/validator-ajv6` - Updated `test_utils.js` to import the default `validator` from `@rjsf/validator-ajv6` and add it to the props for `createFormComponent()` - Updated the `Form_test.js` to import the default `validator` and the `customizeValidator()` function and passed `validator` into props for `<Form>...</Form>` - Updated the checking of `onChangeProp` to add `schemaValidationErrors`, `schemaValidationErrorSchema` and `schemaUtils` to the `calledWith()` check - Updated the checking of `onError` to add `schemaValidationErrors`, `schemaValidationErrorSchema` to the match - Deleted any tests that dealt with the now removed deprecated features - Replaced tests the used the `customFormats` or `additionalMetaSchemas` props with a customized validator with those values set on it - In one place, removed a piece of a test that was reverting the old props since they don't exist anymore - Updated the `SchemaField_test.js` file to check the `registry` in the received props to have `schemaUtils` instead of `definitions` - Fixed the import of `getDefaultRegistry()` - Also removed the test related to `empty definitions` since that isn't in the registry anymore - Updated the `StringField_test.js` to import the utility functions from `@rjsf/utils` - Updated the `uiSchema_test.js` file to deal with the removal of deprecated `ui:widget: {component, options}` feature in `@rjsf/utils` - Switched from `warn` to `error` for spying - Removed the deprecated `ui:widget` configurations in the tests, moving the options into the `ui:options` block instead` - Verified the proper error (instead of warning) is returned
- Switched `SubmitButton` to use `WidgetProps` - Removed `schemaUtils` as a param for `getDefaultRegistry()` - Set generic defaults on `WithThemeProps` - Fixed cast of `SubmitButton` in `Form`
…rocessSelectValue()` method in utils
- Updated `package*.json` to add `@rjsf/utils` and `@rjsf/validator` to dev and peer dependencies - Also, Removed a bunch of packages that were never used since the conversion to `tsdx` - Finally, bumped most of the dev dependencies that made sense to the latest version, except for those that cause breaking tests - Removed the `webpack.config.*.js` files since they are no longer needed since the conversion to `tsdx` - Updated all uses of non-schema utilities methods to `@rjsf/utils` and switched to using `registry.schemaUtils.XXX()` for those schema-based utilities - Updated the import of `getDefaultRegistry()` to be directly from `@rjsf/core` - Modified `SelectWidget` to use the new `processSelectValue()` function from `@rjsf/utils` - Updated the tests to import the `validator` from `@rjsf/validator` to pass to the `Form` - Also updated the snapshots via the `test:update` script to deal with the little differences from the conversion
- Updated `package*.json` to add `@rjsf/utils` to dev and peer dependencies and `@rjsf/validator-ajv6` to dev dependencies - Also, Removed a bunch of packages that were never used since the conversion to `tsdx` - Finally, bumped most of the dev dependencies that made sense to the latest version, except for those that cause breaking tests - Updated all uses of non-schema utilities methods to `@rjsf/utils` and switched to using `registry.schemaUtils.XXX()` for those schema-based utilities - Updated the import of `getDefaultRegistry()` to be directly from `@rjsf/core` - Updated components that used the `uiSchema['ui:xxx']` notation to get the `uiOptions` using `getUiOptions(uiSchema)` then doing `uiOptions.xxx` instead - Updated the use of `React.FC` with `React.ComponentType` in `AddButton` and `SubmitButton` - Updated `ArrayFieldTitleProps` and `ArrayFieldDescriptionProps` to make `title`, `required` and `description` optional in the `ArrayFieldTemplate.tsx` file - Also fixed the indentation of components - Updated `WrapIfAdditionalProps` to pick props from `FieldTemplateProps` joining it with `children` to fix type issues - Updated `Form` to use `React.ComponentType` - Modified `SelectWidget` to use the new `processSelectValue()` function from `@rjsf/utils` - Updated the tests to change to using `RJSFSchema` rather than `JSON7Schema` and import the `validator` from `@rjsf/validator` to pass to the `Form` - Also updated the snapshots via the `test:update` script to deal with the little differences from the conversion
- Updated `package*.json` to add `@rjsf/utils` to dev and peer dependencies and `@rjsf/validator-ajv6` to dev dependencies - Also, Removed a bunch of packages that were never used since the conversion to `tsdx` - Finally, bumped most of the dev dependencies that made sense to the latest version, except for those that cause breaking tests - Updated all uses of non-schema utilities methods to `@rjsf/utils` and switched to using `registry.schemaUtils.XXX()` for those schema-based utilities - Updated the import of `getDefaultRegistry()` to be directly from `@rjsf/core` - Updated components that used the `uiSchema['ui:xxx']` notation to get the `uiOptions` using `getUiOptions(uiSchema)` then doing `uiOptions.xxx` instead - Updated the use of `React.FC` with `React.ComponentType` in `AddButton` and `SubmitButton` - Updated `AltDateWidget` to extend the `AltDateStateType` object from the `DateObject` - Updated `ArrayFieldTitleProps` and `ArrayFieldDescriptionProps` to make `title`, `required` and `description` optional in the `ArrayFieldTemplate.tsx` file - Also fixed the indentation of components - Updated `WrapIfAdditionalProps` to pick props from `FieldTemplateProps` joining it with `children` to fix type issues - Updated `Form` to use `React.ComponentType` - Modified `SelectWidget` to use the new `processSelectValue()` function from `@rjsf/utils` - Updated `utils.js` to remove the custom `ThemeProps` in favor of the new `WithThemeProps` from `@rjsf/core` - Updated the tests to change to using `RJSFSchema` rather than `JSON7Schema` and import the `validator` from `@rjsf/validator` to pass to the `Form` - Also updated the snapshots via the `test:update` script to deal with the little differences from the conversion
- Updated `package*.json` to add `@rjsf/utils` to dev and peer dependencies and `@rjsf/validator-ajv6` to dev dependencies - Also, Removed a bunch of packages that were never used since the conversion to `tsdx` - Finally, bumped most of the dev dependencies that made sense to the latest version, except for those that cause breaking tests - Updated all uses of non-schema utilities methods to `@rjsf/utils` and switched to using `registry.schemaUtils.XXX()` for those schema-based utilities - Updated the import of `getDefaultRegistry()` to be directly from `@rjsf/core` - Updated `ArrayFieldTitleProps` and `ArrayFieldDescriptionProps` to make `title`, `required` and `description` optional in the `ArrayFieldTemplate.tsx` file - Also fixed the indentation of components - Updated `WrapIfAdditionalProps` to pick props from `FieldTemplateProps` joining it with `children` to fix type issues - Updated `FuiForm` to use `React.ComponentType` - Modified `SelectWidget` to use the new `processSelectValue()` function from `@rjsf/utils` - Updated the tests to change to using `RJSFSchema` rather than `JSON7Schema` and import the `validator` from `@rjsf/validator` to pass to the `Form` - Also updated the snapshots via the `test:update` script to deal with the little differences from the conversion
8 tasks
Closing because these changes were merged as part of #2920 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reasons for making this change
Partially fixes #2693 by updating the
fluent-ui
theme to use the new@rjsf/utils
and@rjsf/validator-ajv6
(for tests)package*.json
to add@rjsf/utils
to dev and peer dependencies and@rjsf/validator-ajv6
to dev dependenciestsdx
@rjsf/utils
and switched to usingregistry.schemaUtils.XXX()
for those schema-based utilitiesgetDefaultRegistry()
to be directly from@rjsf/core
ArrayFieldTitleProps
andArrayFieldDescriptionProps
to maketitle
,required
anddescription
optional in theArrayFieldTemplate.tsx
fileWrapIfAdditionalProps
to pick props fromFieldTemplateProps
joining it withchildren
to fix type issuesFuiForm
to useReact.ComponentType
SelectWidget
to use the newprocessSelectValue()
function from@rjsf/utils
RJSFSchema
rather thanJSON7Schema
and import thevalidator
from@rjsf/validator
to pass to theForm
test:update
script to deal with the little differences from the conversionNOTE: This PR is stacked on top of the branch for #2917 so you only need to review the
fluent-ui
directory... This PR will not pass tests because not all of the themes have yet to be convertedChecklist
npm run test:update
to update snapshots, if needed.