UNPKG

@uiw/react-json-view

Version:
77 lines 1.8 kB
import _extends from "@babel/runtime/helpers/extends"; import React, { createContext, useContext, useReducer } from 'react'; import { jsx as _jsx } from "react/jsx-runtime"; var initialState = { Copied: { className: 'w-rjv-copied', style: { height: '1em', width: '1em', cursor: 'pointer', verticalAlign: 'middle', marginLeft: 5 } }, CountInfo: { as: 'span', className: 'w-rjv-object-size', style: { color: 'var(--w-rjv-info-color, #0000004d)', paddingLeft: 8, fontStyle: 'italic' } }, CountInfoExtra: { as: 'span', className: 'w-rjv-object-extra', style: { paddingLeft: 8 } }, Ellipsis: { as: 'span', style: { cursor: 'pointer', color: 'var(--w-rjv-ellipsis-color, #cb4b16)', userSelect: 'none' }, className: 'w-rjv-ellipsis', children: '...' }, Row: { as: 'div', className: 'w-rjv-line' }, KeyName: { as: 'span', className: 'w-rjv-object-key' } }; var Context = /*#__PURE__*/createContext(initialState); var reducer = (state, action) => _extends({}, state, action); export var useSectionStore = () => { return useContext(Context); }; var DispatchSection = /*#__PURE__*/createContext(() => {}); DispatchSection.displayName = 'JVR.DispatchSection'; export function useSection() { return useReducer(reducer, initialState); } export function useSectionDispatch() { return useContext(DispatchSection); } export var Section = _ref => { var { initial, dispatch, children } = _ref; return /*#__PURE__*/_jsx(Context.Provider, { value: initial, children: /*#__PURE__*/_jsx(DispatchSection.Provider, { value: dispatch, children: children }) }); }; Section.displayName = 'JVR.Section';