UNPKG

clickable-json

Version:

Interactive JSON and JSON CRDT viewer and editor

21 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JsonValue = void 0; const React = require("react"); const JsonProperty_1 = require("./JsonProperty"); const ValueInput_1 = require("./ValueInput"); const JsonAtom_1 = require("../JsonAtom"); const JsonValue = (props) => { const { pointer, property, doc, parentCollapsed, comma, onChange } = props; const isBinary = doc instanceof Uint8Array; const handleChange = (newValue) => { if (onChange) onChange([{ op: 'replace', path: pointer, value: newValue }]); }; return (React.createElement(React.Fragment, null, typeof property === 'string' && (React.createElement(JsonProperty_1.JsonProperty, { key: 'k' + String(parentCollapsed), pointer: pointer, onChange: onChange })), !onChange || isBinary ? (React.createElement(JsonAtom_1.JsonAtom, { value: doc })) : (React.createElement(ValueInput_1.ValueInput, { key: String(parentCollapsed), value: doc, onChange: handleChange })), !!comma && ',')); }; exports.JsonValue = JsonValue; //# sourceMappingURL=JsonValue.js.map