Skip to content
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

Avoid importing the whole of react-icons (if treeshaking is broken) #3046

Merged
merged 15 commits into from
Sep 1, 2022
Merged
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ should change the heading of the (upcoming) version to include a major version b
- Upgraded from the `1.x` to `2.x` version of `semantic-ui-react`
- Added support for `schema.examples` in the material ui theme fixing (https://github.com/rjsf-team/react-jsonschema-form/issues/2368, https://github.com/rjsf-team/react-jsonschema-form/issues/2557)

## @rjsf/bootstrap-4
- Avoid importing the whole of `react-icons` (https://github.com/rjsf-team/react-jsonschema-form/pull/3046, https://github.com/react-icons/react-icons/issues/154)

## Dev / docs / playground
- Fixed missing `playground` import error by adding `source-map-loader`
- Fixed up the incorrectly formatted `5.x Migration Guide`
Expand Down
32 changes: 20 additions & 12 deletions packages/bootstrap-4/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/bootstrap-4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@
],
"license": "MIT",
"dependencies": {
"react-icons": "^4.4.0"
"@react-icons/all-files": "^4.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/bootstrap-4/src/AddButton/AddButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

import { IconButtonProps } from "@rjsf/utils";
import Button from "react-bootstrap/Button";
import { BsPlus } from "react-icons/bs";
import { BsPlus } from "@react-icons/all-files/bs/BsPlus";

const AddButton: React.ComponentType<IconButtonProps> = (props) => (
<Button
Expand Down
5 changes: 3 additions & 2 deletions packages/bootstrap-4/src/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { IconButtonProps } from "@rjsf/utils";
import Button, { ButtonProps } from "react-bootstrap/Button";
import { IoIosRemove } from "react-icons/io";
import { AiOutlineArrowUp, AiOutlineArrowDown } from "react-icons/ai";
import { IoIosRemove } from "@react-icons/all-files/io/IoIosRemove";
import { AiOutlineArrowUp } from "@react-icons/all-files/ai/AiOutlineArrowUp";
import { AiOutlineArrowDown } from "@react-icons/all-files/ai/AiOutlineArrowDown";

const IconButton = (props: IconButtonProps & ButtonProps) => {
const { icon, iconType, className, ...otherProps } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ exports[`AddButton simple 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"
clipRule="evenodd"
d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z"
fillRule="evenodd"
/>
<path
clipRule="evenodd"
d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z"
fillRule="evenodd"
/>
</svg>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,14 @@ exports[`AdditionalProperties tests show add button and fields if additionalProp
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"
clipRule="evenodd"
d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z"
fillRule="evenodd"
/>
<path
clipRule="evenodd"
d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z"
fillRule="evenodd"
/>
</svg>
</button>
Expand Down
18 changes: 16 additions & 2 deletions packages/bootstrap-4/test/__snapshots__/Array.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ exports[`array fields array 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"
clipRule="evenodd"
d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z"
fillRule="evenodd"
/>
<path
clipRule="evenodd"
d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z"
fillRule="evenodd"
/>
</svg>
</button>
Expand Down Expand Up @@ -473,7 +480,14 @@ exports[`array fields array icons 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"
clipRule="evenodd"
d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z"
fillRule="evenodd"
/>
<path
clipRule="evenodd"
d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z"
fillRule="evenodd"
/>
</svg>
</button>
Expand Down
68 changes: 68 additions & 0 deletions packages/bootstrap-4/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,74 @@ exports[`single fields radio field 1`] = `
</form>
`;

exports[`single fields schema examples 1`] = `
<div
className="rjsf"
noValidate={false}
onSubmit={[Function]}
>
<div
className="form-group field field-string"
>
<div
className="form-group"
>
<div
className="mb-0 form-group"
>
<label
className="form-label"
htmlFor="root"
/>
<input
autoFocus={false}
className="form-control"
disabled={false}
id="root"
list="examples_root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder=""
readOnly={false}
type="text"
value=""
/>
<datalist
id="examples_root"
>
<option
value="Firefox"
/>
<option
value="Chrome"
/>
<option
value="Opera"
/>
<option
value="Vivaldi"
/>
<option
value="Safari"
/>
</datalist>
</div>

</div>
</div>
<div>
<button
className="btn btn-primary"
disabled={false}
type="submit"
>
Submit
</button>
</div>
</div>
`;

exports[`single fields select field 1`] = `
<form
className="rjsf"
Expand Down
9 changes: 8 additions & 1 deletion packages/bootstrap-4/test/__snapshots__/Object.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,14 @@ exports[`object fields additionalProperties 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"
clipRule="evenodd"
d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z"
fillRule="evenodd"
/>
<path
clipRule="evenodd"
d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z"
fillRule="evenodd"
/>
</svg>
</button>
Expand Down