1- import type { ComponentProps , FC , FocusEvent , SyntheticEvent } from 'react' ;
1+ import type { FC , FocusEvent , SyntheticEvent } from 'react' ;
22import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
33
44import { Button , Form , ToggleButton } from 'storybook/internal/components' ;
55
66import { AddIcon , SubtractIcon } from '@storybook/icons' ;
77
88import { cloneDeep } from 'es-toolkit/object' ;
9- import { type Theme , styled , useTheme } from 'storybook/theming' ;
9+ import { styled , useTheme } from 'storybook/theming' ;
1010
1111import { getControlId , getControlSetterButtonId } from './helpers' ;
1212import { JsonTree } from './react-editable-json-tree' ;
1313import type { ControlProps , ObjectConfig , ObjectValue } from './types' ;
1414
1515const { window : globalWindow } = globalThis ;
1616
17- type JsonTreeProps = ComponentProps < typeof JsonTree > ;
18-
1917const Wrapper = styled . div ( ( { theme } ) => ( {
2018 position : 'relative' ,
2119 display : 'flex' ,
@@ -39,8 +37,14 @@ const Wrapper = styled.div(({ theme }) => ({
3937 alignItems : 'center' ,
4038 } ,
4139 '.rejt-name' : {
40+ color : theme . color . secondary ,
4241 lineHeight : '22px' ,
4342 } ,
43+ '.rejt-not-collapsed-list' : {
44+ listStyle : 'none' ,
45+ margin : '0 0 0 1rem' ,
46+ padding : 0 ,
47+ } ,
4448 '.rejt-not-collapsed-delimiter' : {
4549 lineHeight : '22px' ,
4650 } ,
@@ -57,6 +61,9 @@ const Wrapper = styled.div(({ theme }) => ({
5761 background : theme . base === 'light' ? theme . color . lighter : 'hsl(0 0 100 / 0.02)' ,
5862 borderColor : theme . appBorderColor ,
5963 } ,
64+ '.rejt-collapsed-value' : {
65+ color : theme . color . defaultText ,
66+ } ,
6067} ) ) ;
6168
6269const ButtonInline = styled . button < { primary ?: boolean } > ( ( { theme, primary } ) => ( {
@@ -155,23 +162,6 @@ const selectValue = (event: SyntheticEvent<HTMLInputElement>) => {
155162
156163export type ObjectProps = ControlProps < ObjectValue > & ObjectConfig ;
157164
158- const getCustomStyleFunction : ( theme : Theme ) => JsonTreeProps [ 'getStyle' ] = ( theme ) => ( ) => ( {
159- name : {
160- color : theme . color . secondary ,
161- } ,
162- collapsed : {
163- color : theme . color . dark ,
164- } ,
165- ul : {
166- listStyle : 'none' ,
167- margin : '0 0 0 1rem' ,
168- padding : 0 ,
169- } ,
170- li : {
171- outline : 0 ,
172- } ,
173- } ) ;
174-
175165export const ObjectControl : FC < ObjectProps > = ( { name, value, onChange, argType } ) => {
176166 const theme = useTheme ( ) ;
177167 const data = useMemo ( ( ) => value && cloneDeep ( value ) , [ value ] ) ;
@@ -266,7 +256,6 @@ export const ObjectControl: FC<ObjectProps> = ({ name, value, onChange, argType
266256 data = { data }
267257 rootName = { name }
268258 onFullyUpdate = { onChange }
269- getStyle = { getCustomStyleFunction ( theme ) }
270259 cancelButtonElement = { < ButtonInline type = "button" > Cancel</ ButtonInline > }
271260 addButtonElement = {
272261 < ButtonInline type = "submit" primary >
0 commit comments