Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev-server/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
</head>
<body>
<div id="app-container"></div>
<script type="text/javascript" src="./main.js"></script>
<script type="text/javascript" src="/main.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions dev-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import Moment from 'moment';
//import the react-json-view component (installed with npm)
import JsonViewer from './../../src/js/index';

const forcedCustomButtonProps = {
icon: <div>Custom Icon</div>,
onClick: keyAndValue => {
const { value, namespace } = keyAndValue;
console.log({ value, namespace });
},
title: 'Apply filter'
};

//render 2 different examples of the react-json-view component
ReactDom.render(
<div>
Expand All @@ -19,6 +28,7 @@ ReactDom.render(
src={getExampleJson1()}
quotesOnKeys={false}
collapseStringsAfterLength={12}
customButtonProps={forcedCustomButtonProps}
onEdit={e => {
console.log('edit callback', e);
if (e.new_value == 'error') {
Expand Down
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ export interface ReactJsonViewProps {
* Default: null
*/
defaultValue?: TypeDefaultValue | TypeDefaultValue[] | null;

customButtonProps?: {
/**
* When set to true, the custom button will be shown even if the field is not hovered.
*/
forceShow?: boolean;
icon: React.ReactNode;
/**
* @param data value is the field value, namespace is a list of the entire fields. Suppose the field is "example.parent.sibling1", then namespace is ["example", "parent", "sibling1"]
*/
onClick: (data: { value: any; namespace: Array<string | null> }) => void;
title: string;
};
}

export interface OnCopyProps {
Expand Down
Loading