UNPKG

@uiw/react-json-view

Version:
101 lines 2.41 kB
import _extends from "@babel/runtime/helpers/extends"; import { createContext, useContext, useReducer } from 'react'; import { TriangleArrow } from "../arrow/TriangleArrow.js"; import { jsx as _jsx } from "react/jsx-runtime"; var initialState = { Arrow: { as: 'span', className: 'w-rjv-arrow', style: { transform: 'rotate(0deg)', transition: 'all 0.3s' }, children: /*#__PURE__*/_jsx(TriangleArrow, {}) }, Colon: { as: 'span', style: { color: 'var(--w-rjv-colon-color, var(--w-rjv-color))', marginLeft: 0, marginRight: 2 }, className: 'w-rjv-colon', children: ':' }, Quote: { as: 'span', style: { color: 'var(--w-rjv-quotes-color, #236a7c)' }, className: 'w-rjv-quotes', children: '"' }, ValueQuote: { as: 'span', style: { color: 'var(--w-rjv-quotes-string-color, #cb4b16)' }, className: 'w-rjv-quotes', children: '"' }, BracketsLeft: { as: 'span', style: { color: 'var(--w-rjv-brackets-color, #236a7c)' }, className: 'w-rjv-brackets-start', children: '[' }, BracketsRight: { as: 'span', style: { color: 'var(--w-rjv-brackets-color, #236a7c)' }, className: 'w-rjv-brackets-end', children: ']' }, BraceLeft: { as: 'span', style: { color: 'var(--w-rjv-curlybraces-color, #236a7c)' }, className: 'w-rjv-curlybraces-start', children: '{' }, BraceRight: { as: 'span', style: { color: 'var(--w-rjv-curlybraces-color, #236a7c)' }, className: 'w-rjv-curlybraces-end', children: '}' } }; var Context = /*#__PURE__*/createContext(initialState); var reducer = (state, action) => _extends({}, state, action); export var useSymbolsStore = () => { return useContext(Context); }; var DispatchSymbols = /*#__PURE__*/createContext(() => {}); DispatchSymbols.displayName = 'JVR.DispatchSymbols'; export function useSymbols() { return useReducer(reducer, initialState); } export function useSymbolsDispatch() { return useContext(DispatchSymbols); } export var Symbols = _ref => { var { initial, dispatch, children } = _ref; return /*#__PURE__*/_jsx(Context.Provider, { value: initial, children: /*#__PURE__*/_jsx(DispatchSymbols.Provider, { value: dispatch, children: children }) }); }; Symbols.displayName = 'JVR.Symbols';