Skip to content

Commit

Permalink
Fix #4080 by moving base64 encoder/decoder from @rjsf/utils to pl…
Browse files Browse the repository at this point in the history
…ayground (#4093)
  • Loading branch information
nickgros authored Feb 19, 2024
1 parent f724820 commit e2e37b7
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 71 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ should change the heading of the (upcoming) version to include a major version b

- Added support for `UiSchema` `"ui:rows"` option for `textarea` elements, fixing [#4070](https://github.com/rjsf-team/react-jsonschema-form/issues/4070).

# @rjsf/utils

- [#4080](https://github.com/rjsf-team/react-jsonschema-form/issues/4080) - BREAKING CHANGE: Removed the `base64` object from the `@rjsf/utils` package. Note that this is a breaking change if you relied on the `base64` object exported by `@rjsf/utils`. Since this change caused [#4080](https://github.com/rjsf-team/react-jsonschema-form/issues/4080), and was only internally used by playground code, we are shipping this change in a patch release.

## Dev / docs / playground

- [#4080](https://github.com/rjsf-team/react-jsonschema-form/issues/4080) - Moved the `base64` encoder/decoder object to the Playground package.
- Added test configuration and script to the Playground.


# 5.17.0

## @rjsf/core
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 0 additions & 31 deletions packages/docs/docs/api-reference/utility-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1181,34 +1181,3 @@ For more information about how to specify the path see the [eslint lodash plugin
#### Returns

- ErrorSchemaBuilder<T> - The instance of the `ErrorSchemaBuilder` class

## utility object

### base64

An object providing base64 encoding and decoding functions using the UTF-8 charset.
By default, the `btoa()` and `atob()` built-in functions are only support the Latin-1 character range that means that non Latin-1 characters are not supported(for example, Chinese characters).

#### encode()

Encodes the given `input` string into a base64 encoded string

##### Parameters

- input: string - The string to encode

##### Returns

- string: The base64 encoded string

#### decode()

Decodes the given `input` string from a base64 encoded string

##### Parameters

- input: string - The string to decode

##### Returns

- string: The decoded string
30 changes: 0 additions & 30 deletions packages/playground/.babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions packages/playground/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const defaultConfig = require('../../babel.config');

module.exports = defaultConfig;
6 changes: 6 additions & 0 deletions packages/playground/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
verbose: true,
testEnvironment: 'jsdom',
testMatch: ['**/test/**/*.test.[jt]s?(x)'],
transformIgnorePatterns: [`/node_modules/(?!nanoid)`],
};
9 changes: 7 additions & 2 deletions packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "5.17.0",
"description": "rjsf playground",
"private": true,
"type": "module",
"type": "commonjs",
"scripts": {
"cs-check": "prettier -l \"src/**/*.ts?(x)\"",
"cs-format": "prettier \"src/**/*.ts?(x)\" --write",
Expand All @@ -13,7 +13,8 @@
"publish-to-gh-pages": "npm run build && gh-pages --dist build/",
"publish-to-npm": "npm run build && npm publish",
"start": "vite --force",
"preview": "vite preview"
"preview": "vite preview",
"test": "jest"
},
"lint-staged": {
"src/**/*.ts?(x)": [
Expand Down Expand Up @@ -92,6 +93,8 @@
"@monaco-editor/react": "^4.6.0",
"@mui/icons-material": "5.15.2",
"@types/lodash": "^4.14.202",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.14",
"@types/react-frame-component": "^4.1.6",
"@vitejs/plugin-react": "^4.2.1",
"cross-env": "^7.0.3",
Expand All @@ -100,6 +103,8 @@
"gh-pages": "^3.2.3",
"html": "^1.0.0",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"loader-utils": "^3.2.1",
"mini-css-extract-plugin": "^2.8.0",
"prettier": "^2.8.8",
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCallback } from 'react';
import Form, { IChangeEvent } from '@rjsf/core';
import { base64, RJSFSchema, UiSchema, ValidatorType } from '@rjsf/utils';
import { RJSFSchema, UiSchema, ValidatorType } from '@rjsf/utils';
import localValidator from '@rjsf/validator-ajv8';
import base64 from '../utils/base64';

import CopyLink from './CopyLink';
import ThemeSelector, { ThemesType } from './ThemeSelector';
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/src/components/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentType, FormEvent, useCallback, useEffect, useRef, useState } from 'react';
import { FormProps, IChangeEvent, withTheme } from '@rjsf/core';
import { base64, ErrorSchema, RJSFSchema, RJSFValidationError, UiSchema, ValidatorType } from '@rjsf/utils';
import { ErrorSchema, RJSFSchema, RJSFValidationError, UiSchema, ValidatorType } from '@rjsf/utils';
import base64 from '../utils/base64';

import { samples } from '../samples';
import Header, { LiveSettings } from './Header';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { base64 } from '../src';
import base64 from '../../src/utils/base64';

describe('base64', () => {
it('should successfully encode a ascii character', () => {
Expand Down
7 changes: 4 additions & 3 deletions packages/playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"include": ["./"],
"compilerOptions": {
"rootDir": "./src",
"rootDir": "./",
"baseUrl": "./",
"target": "ESNext",
"useDefineForClassFields": true,
Expand All @@ -18,9 +19,9 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": ["vite/client"]
"types": ["vite/client", "jest", "node"]
},
"include": ["src"],
"include": ["src", "test"],
"references": [
{ "path": "../antd" },
{ "path": "../bootstrap-4" },
Expand Down
2 changes: 0 additions & 2 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import utcToLocal from './utcToLocal';
import validationDataMerge from './validationDataMerge';
import withIdRefPrefix from './withIdRefPrefix';
import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';
import base64 from './base64';

export * from './types';
export * from './enums';
Expand Down Expand Up @@ -121,5 +120,4 @@ export {
utcToLocal,
validationDataMerge,
withIdRefPrefix,
base64,
};

0 comments on commit e2e37b7

Please sign in to comment.