You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Version 1.14.0** has a change which recommends you provide a `setData` prop and not use `onUpdate` for updating your data externally. See [Managing state](#managing-state).
29
+
> Breaking changes:
30
+
> -**Version 1.19.0** has a change to the `theme` input. Built-in themes must now
31
+
> be imported separately and passed in, rather than just naming the theme as a
32
+
> string. This is better for tree-shaking, so unused themes won't be bundled
33
+
> with your build. See [Themes & Styles](#themes--styles)
34
+
> -**Version 1.14.0** has a change which recommends you provide a `setData` prop
35
+
> and not use `onUpdate` for updating your data externally. See [Managing
36
+
> state](#managing-state).
30
37
31
38
## Contents <!-- omit in toc -->
32
39
-[Installation](#installation)
@@ -136,7 +143,7 @@ The only *required* value is `data` (although you will need to provide a `setDat
136
143
|`defaultValue`|`any\|DefaultValueFilterFunction`|`null`| When a new property is added, it is initialised with this value. A [function can be provided](#filter-functions) with the almost the same input as the `FilterFunction`s, but should output a value. This allows a different default value to be used depending on the data state (e.g. default for top level is an object, but a string elsewhere.) |
137
144
|`stringTruncate`|`number`|`250`| String values longer than this many characters will be displayed truncated (with `...`). The full string will always be visible when editing. |
138
145
|`translations`|`LocalisedStrings` object |`{ }`| UI strings (such as error messages) can be translated by passing an object containing localised string values (there are only a few). See [Localisation](#localisation)|
139
-
|`theme`|`string\|ThemeObject\|[string, ThemeObject]`|`"default"`| Either the name of one of the built-in themes, or an object specifying some or all theme properties. See [Themes](#themes--styles).|
146
+
|`theme`|`ThemeInput`|`default`| Either one of the built-in themes (imported separately), or an object specifying some or all theme properties. See [Themes](#themes--styles). |
140
147
|`className`|`string`|| Name of a CSS class to apply to the component. In most cases, specifying `theme` properties will be more straightforward. |
141
148
|`id`|`string`|| Name for the HTML `id` attribute on the main component container. |
142
149
|`icons`|`{[iconName]: JSX.Element, ... }`|`{ }`| Replace the built-in icons by specifying them here. See [Themes](#themes--styles). ||
@@ -414,14 +421,31 @@ An example custom search function can be seen in the [Demo](#https://carlosnz.gi
414
421
415
422
## Themes & Styles
416
423
417
-
There is a small selection of built-in themes (as seen in the [Demo app](https://carlosnz.github.io/json-edit-react/)). In order to use one of these, just pass the name into the `theme` prop (although realistically, these exist more to showcase the capabilities — I'm open to better built-in themes, so feel free to [create an issue](https://github.com/CarlosNZ/json-edit-react/issues) with suggestions). The available themes are:
418
-
- `default`
419
-
- `githubDark`
420
-
- `githubLight`
421
-
- `monoDark`
422
-
- `monoLight`
423
-
- `candyWrapper`
424
-
- `psychedelic`
424
+
There is a small selection of built-in themes (as seen in the [Demo app](https://carlosnz.github.io/json-edit-react/)). In order to use one of these, just import it from the package and pass it as the theme prop:
The following themes are available in the package (although realistically, these exist more to showcase the capabilities — I'm open to better built-in themes, so feel free to [create an issue](https://github.com/CarlosNZ/json-edit-react/issues) with suggestions):
443
+
- `githubDarkTheme`
444
+
- `githubLightTheme`
445
+
- `monoDarkTheme`
446
+
- `monoLightTheme`
447
+
- `candyWrapperTheme`
448
+
- `psychedelicTheme`
425
449
426
450
However, you can pass in your own theme object, or part thereof. The theme structure is as follows (this is the "default" theme definition):
427
451
@@ -471,7 +495,7 @@ For a simple example, if you want to use the "githubDark" theme, but just change
@@ -488,7 +512,7 @@ Or you could create your own theme from scratch and overwrite the whole theme ob
488
512
489
513
So, to summarise, the `theme` prop can take *either*:
490
514
491
-
- a theme name e.g.`"candyWrapper"`
515
+
- an imported theme, e.g `"candyWrapperTheme"`
492
516
- a theme object:
493
517
- can be structured as above with `fragments`, `styles`, `displayName` etc., or just the `styles` part (at the root level)
494
518
- a theme name *and* an override object in an array, i.e. `[ "<themeName>, {...overrides } ]`
@@ -751,6 +775,7 @@ This component is heavily inspired by [react-json-view](https://github.com/mac-s
751
775
752
776
## Changelog
753
777
778
+
- **1.19.0**: Built-in [themes](#themes--styles) must now be imported separately -- this improves tree-shaking to prevent unused themes being bundled with your build
754
779
- **1.18.0**:
755
780
- Ability to [customise keyboard controls](#keyboard-customisation)
0 commit comments