@@ -27,22 +27,12 @@ const Wrapper = styled.div(({ theme }) => ({
27
27
'.rejt-tree' : {
28
28
marginLeft : '1rem' ,
29
29
fontSize : '13px' ,
30
+ listStyleType : 'none' ,
30
31
} ,
31
- '.rejt-value-node, .rejt-object-node > .rejt-collapsed, .rejt-array-node > .rejt-collapsed, .rejt-object-node > .rejt-not-collapsed, .rejt-array-node > .rejt-not-collapsed' :
32
- {
33
- '& > svg' : {
34
- opacity : 0 ,
35
- transition : 'opacity 0.2s' ,
36
- } ,
32
+ '.rejt-value-node:hover' : {
33
+ '& > button' : {
34
+ opacity : 1 ,
37
35
} ,
38
- '.rejt-value-node:hover, .rejt-object-node:hover > .rejt-collapsed, .rejt-array-node:hover > .rejt-collapsed, .rejt-object-node:hover > .rejt-not-collapsed, .rejt-array-node:hover > .rejt-not-collapsed' :
39
- {
40
- '& > svg' : {
41
- opacity : 1 ,
42
- } ,
43
- } ,
44
- '.rejt-edit-form button' : {
45
- display : 'none' ,
46
36
} ,
47
37
'.rejt-add-form' : {
48
38
marginLeft : 10 ,
@@ -57,62 +47,6 @@ const Wrapper = styled.div(({ theme }) => ({
57
47
'.rejt-not-collapsed-delimiter' : {
58
48
lineHeight : '22px' ,
59
49
} ,
60
- '.rejt-plus-menu' : {
61
- marginLeft : 5 ,
62
- } ,
63
- '.rejt-object-node > span > *, .rejt-array-node > span > *' : {
64
- position : 'relative' ,
65
- zIndex : 2 ,
66
- } ,
67
- '.rejt-object-node, .rejt-array-node' : {
68
- position : 'relative' ,
69
- } ,
70
- '.rejt-object-node > span:first-of-type::after, .rejt-array-node > span:first-of-type::after, .rejt-collapsed::before, .rejt-not-collapsed::before' :
71
- {
72
- content : '""' ,
73
- position : 'absolute' ,
74
- top : 0 ,
75
- display : 'block' ,
76
- width : '100%' ,
77
- marginLeft : '-1rem' ,
78
- padding : '0 4px 0 1rem' ,
79
- height : 22 ,
80
- } ,
81
- '.rejt-collapsed::before, .rejt-not-collapsed::before' : {
82
- zIndex : 1 ,
83
- background : 'transparent' ,
84
- borderRadius : 4 ,
85
- transition : 'background 0.2s' ,
86
- pointerEvents : 'none' ,
87
- opacity : 0.1 ,
88
- } ,
89
- '.rejt-object-node:hover, .rejt-array-node:hover' : {
90
- '& > .rejt-collapsed::before, & > .rejt-not-collapsed::before' : {
91
- background : theme . color . secondary ,
92
- } ,
93
- } ,
94
- '.rejt-collapsed::after, .rejt-not-collapsed::after' : {
95
- content : '""' ,
96
- position : 'absolute' ,
97
- display : 'inline-block' ,
98
- pointerEvents : 'none' ,
99
- width : 0 ,
100
- height : 0 ,
101
- } ,
102
- '.rejt-collapsed::after' : {
103
- left : - 8 ,
104
- top : 8 ,
105
- borderTop : '3px solid transparent' ,
106
- borderBottom : '3px solid transparent' ,
107
- borderLeft : '3px solid rgba(153,153,153,0.6)' ,
108
- } ,
109
- '.rejt-not-collapsed::after' : {
110
- left : - 10 ,
111
- top : 10 ,
112
- borderTop : '3px solid rgba(153,153,153,0.6)' ,
113
- borderLeft : '3px solid transparent' ,
114
- borderRight : '3px solid transparent' ,
115
- } ,
116
50
'.rejt-value' : {
117
51
display : 'inline-block' ,
118
52
border : '1px solid transparent' ,
@@ -137,36 +71,37 @@ const ButtonInline = styled.button<{ primary?: boolean }>(({ theme, primary }) =
137
71
color : primary ? theme . color . lightest : theme . color . dark ,
138
72
fontWeight : primary ? 'bold' : 'normal' ,
139
73
cursor : 'pointer' ,
140
- order : primary ? 'initial' : 9 ,
141
74
} ) ) ;
142
75
143
- const ActionAddIcon = styled ( AddIcon ) < { disabled ?: boolean } > ( ( { theme, disabled } ) => ( {
144
- display : 'inline-block' ,
76
+ const ActionButton = styled . button ( ( { theme } ) => ( {
77
+ background : 'none' ,
78
+ border : 0 ,
79
+ display : 'inline-flex' ,
145
80
verticalAlign : 'middle' ,
146
- width : 15 ,
147
- height : 15 ,
148
81
padding : 3 ,
149
82
marginLeft : 5 ,
150
- cursor : disabled ? 'not-allowed' : 'pointer' ,
151
83
color : theme . textMutedColor ,
152
- '&:hover' : disabled ? { } : { color : theme . color . ancillary } ,
153
- 'svg + &' : {
154
- marginLeft : 0 ,
84
+ opacity : 0 ,
85
+ transition : 'opacity 0.2s' ,
86
+ cursor : 'pointer' ,
87
+ position : 'relative' ,
88
+ svg : {
89
+ width : 9 ,
90
+ height : 9 ,
155
91
} ,
156
- } ) ) ;
157
-
158
- const ActionSubstractIcon = styled ( SubtractIcon ) < { disabled ?: boolean } > ( ( { theme, disabled } ) => ( {
159
- display : 'inline-block' ,
160
- verticalAlign : 'middle' ,
161
- width : 15 ,
162
- height : 15 ,
163
- padding : 3 ,
164
- marginLeft : 5 ,
165
- cursor : disabled ? 'not-allowed' : 'pointer' ,
166
- color : theme . textMutedColor ,
167
- '&:hover' : disabled ? { } : { color : theme . color . negative } ,
168
- 'svg + &' : {
169
- marginLeft : 0 ,
92
+ ':disabled' : {
93
+ cursor : 'not-allowed' ,
94
+ } ,
95
+ ':hover, :focus-visible' : {
96
+ opacity : 1 ,
97
+ } ,
98
+ '&:hover:not(:disabled), &:focus-visible:not(:disabled)' : {
99
+ '&.rejt-plus-menu' : {
100
+ color : theme . color . ancillary ,
101
+ } ,
102
+ '&.rejt-minus-menu' : {
103
+ color : theme . color . negative ,
104
+ } ,
170
105
} ,
171
106
} ) ) ;
172
107
@@ -220,7 +155,13 @@ const RawInput = styled(Form.Textarea)(({ theme }) => ({
220
155
} ,
221
156
} ) ) ;
222
157
223
- const ENTER_EVENT = { bubbles : true , cancelable : true , key : 'Enter' , code : 'Enter' , keyCode : 13 } ;
158
+ const ENTER_EVENT = {
159
+ bubbles : true ,
160
+ cancelable : true ,
161
+ key : 'Enter' ,
162
+ code : 'Enter' ,
163
+ keyCode : 13 ,
164
+ } ;
224
165
const dispatchEnterKey = ( event : SyntheticEvent < HTMLInputElement > ) => {
225
166
event . currentTarget . dispatchEvent ( new globalWindow . KeyboardEvent ( 'keydown' , ENTER_EVENT ) ) ;
226
167
} ;
@@ -311,9 +252,12 @@ export const ObjectControl: FC<ObjectProps> = ({ name, value, onChange, argType
311
252
< Wrapper aria-readonly = { readonly } >
312
253
{ isObjectOrArray && (
313
254
< RawButton
255
+ role = "switch"
256
+ aria-checked = { showRaw }
257
+ aria-label = { `Edit the ${ name } properties in text format` }
314
258
onClick = { ( e : SyntheticEvent ) => {
315
259
e . preventDefault ( ) ;
316
- setShowRaw ( ( v ) => ! v ) ;
260
+ setShowRaw ( ( isRaw ) => ! isRaw ) ;
317
261
} }
318
262
>
319
263
{ showRaw ? < EyeCloseIcon /> : < EyeIcon /> }
@@ -329,14 +273,21 @@ export const ObjectControl: FC<ObjectProps> = ({ name, value, onChange, argType
329
273
onFullyUpdate = { onChange }
330
274
getStyle = { getCustomStyleFunction ( theme ) }
331
275
cancelButtonElement = { < ButtonInline type = "button" > Cancel</ ButtonInline > }
332
- editButtonElement = { < ButtonInline type = "submit" > Save</ ButtonInline > }
333
276
addButtonElement = {
334
277
< ButtonInline type = "submit" primary >
335
278
Save
336
279
</ ButtonInline >
337
280
}
338
- plusMenuElement = { < ActionAddIcon /> }
339
- minusMenuElement = { < ActionSubstractIcon /> }
281
+ plusMenuElement = {
282
+ < ActionButton type = "button" >
283
+ < AddIcon />
284
+ </ ActionButton >
285
+ }
286
+ minusMenuElement = {
287
+ < ActionButton type = "button" >
288
+ < SubtractIcon />
289
+ </ ActionButton >
290
+ }
340
291
inputElement = { ( _ : any , __ : any , ___ : any , key : string ) =>
341
292
key ? < Input onFocus = { selectValue } onBlur = { dispatchEnterKey } /> : < Input />
342
293
}
0 commit comments