@@ -22,7 +22,7 @@ const CMenuItemOption = {
22
22
type : String ,
23
23
isDisabled : Boolean ,
24
24
isChecked : Boolean ,
25
- value : [ String , Number ]
25
+ value : [ String , Number , Array ]
26
26
} ,
27
27
computed : {
28
28
context ( ) {
@@ -102,55 +102,63 @@ const CMenuItemOption = {
102
102
}
103
103
} ,
104
104
render ( h ) {
105
- return h ( CPseudoBox , {
106
- props : {
107
- as : 'button'
108
- } ,
109
- attrs : {
110
- ...this . menuItemStyles ,
111
- display : 'flex' ,
112
- minHeight : '32px' ,
113
- alignItems : 'center' ,
114
- ...this . $attrs ,
115
- role : this . role ,
116
- tabindex : - 1 ,
117
- 'aria-checked' : this . isChecked ,
118
- disabled : this . isDisabled ,
119
- 'aria-disabled' : this . isDisabled ,
120
- 'data-chakra-component' : 'CMenuItemOption'
121
- } ,
122
- nativeOn : {
123
- click : this . handleClick ,
124
- mouseenter : this . handleMouseEnter ,
125
- mouseleave : this . handleMouseLeave ,
126
- keydown : this . handleKeyDown
127
- }
128
- } , [
129
- h ( CIcon , {
105
+ return h (
106
+ CPseudoBox ,
107
+ {
130
108
props : {
131
- name : 'check '
109
+ as : 'button '
132
110
} ,
133
111
attrs : {
134
- opacity : this . isChecked ? 1 : 0 ,
135
- color : 'currentColor' ,
136
- size : '1em' ,
137
- ml : '1rem' ,
138
- mr : '-4px' ,
139
- 'aria-hidden' : true ,
140
- 'data-menuitem-icon' : ''
141
- }
142
- } ) ,
143
- h ( CBox , {
144
- props : {
145
- as : 'span'
112
+ ...this . menuItemStyles ,
113
+ display : 'flex' ,
114
+ minHeight : '32px' ,
115
+ alignItems : 'center' ,
116
+ ...this . $attrs ,
117
+ role : this . role ,
118
+ tabindex : - 1 ,
119
+ 'aria-checked' : this . isChecked ,
120
+ disabled : this . isDisabled ,
121
+ 'aria-disabled' : this . isDisabled ,
122
+ 'data-chakra-component' : 'CMenuItemOption'
146
123
} ,
147
- attrs : {
148
- textAlign : 'left' ,
149
- flex : '1' ,
150
- mx : '1rem'
124
+ nativeOn : {
125
+ click : this . handleClick ,
126
+ mouseenter : this . handleMouseEnter ,
127
+ mouseleave : this . handleMouseLeave ,
128
+ keydown : this . handleKeyDown
151
129
}
152
- } , this . $slots . default )
153
- ] )
130
+ } ,
131
+ [
132
+ h ( CIcon , {
133
+ props : {
134
+ name : 'check'
135
+ } ,
136
+ attrs : {
137
+ opacity : this . isChecked ? 1 : 0 ,
138
+ color : 'currentColor' ,
139
+ size : '1em' ,
140
+ ml : '1rem' ,
141
+ mr : '-4px' ,
142
+ 'aria-hidden' : true ,
143
+ 'data-menuitem-icon' : ''
144
+ }
145
+ } ) ,
146
+ h (
147
+ CBox ,
148
+ {
149
+ props : {
150
+ as : 'span'
151
+ } ,
152
+ attrs : {
153
+ textAlign : 'left' ,
154
+ flex : '1' ,
155
+ mx : '1rem'
156
+ }
157
+ } ,
158
+ this . $slots . default
159
+ )
160
+ ]
161
+ )
154
162
}
155
163
}
156
164
@@ -173,7 +181,7 @@ const CMenuOptionGroup = {
173
181
name : String ,
174
182
title : String ,
175
183
value : {
176
- type : [ String , Number ] ,
184
+ type : [ String , Number , Array ] ,
177
185
default : null
178
186
} ,
179
187
defaultValue : [ String , Number , Array ]
@@ -229,87 +237,104 @@ const CMenuOptionGroup = {
229
237
if ( ! this . $slots || ! this . $slots . default ) {
230
238
return h ( null )
231
239
} else if ( ! this . $slots . default . length ) {
232
- return console . error ( '[Chakra-ui]: <CMenuOptionGroup /> component expects at least one child node.' )
240
+ return console . error (
241
+ '[Chakra-ui]: <CMenuOptionGroup /> component expects at least one child node.'
242
+ )
233
243
}
234
244
235
245
const children = this . $slots . default . filter ( e => e . tag )
236
246
237
247
const clonedChildNodes = children . map ( ( vnode ) => {
238
248
let result
239
249
const cloned = cloneVNode ( vnode , h )
240
- if ( ! cloned . componentOptions ) return console . error ( 'Chakra-ui: <CMenuOptionGroup /> component expects valid component as children' )
250
+ if ( ! cloned . componentOptions )
251
+ return console . error (
252
+ 'Chakra-ui: <CMenuOptionGroup /> component expects valid component as children'
253
+ )
241
254
242
255
if ( this . type === 'radio' ) {
243
- result = h ( cloned . componentOptions . Ctor , {
244
- ...cloned . data ,
245
- props : {
246
- ...( cloned . data . props || { } ) ,
247
- ...cloned . componentOptions . propsData ,
248
- type : this . type ,
249
- name : this . name || this . fallbackName ,
250
- isChecked : cloned . componentOptions . propsData . value === this . computedValue
251
- } ,
252
- attrs : {
253
- ...( cloned . data . attrs || { } )
254
- } ,
255
- key : cloned . componentOptions . propsData . value ,
256
- nativeOn : {
257
- click : ( event ) => {
258
- this . handleChange ( cloned . componentOptions . propsData . value )
256
+ result = h (
257
+ cloned . componentOptions . Ctor ,
258
+ {
259
+ ...cloned . data ,
260
+ props : {
261
+ ...( cloned . data . props || { } ) ,
262
+ ...cloned . componentOptions . propsData ,
263
+ type : this . type ,
264
+ name : this . name || this . fallbackName ,
265
+ isChecked :
266
+ cloned . componentOptions . propsData . value === this . computedValue
267
+ } ,
268
+ attrs : {
269
+ ...( cloned . data . attrs || { } )
259
270
} ,
260
- keydown : ( event ) => {
261
- if ( [ 'Enter' , ' ' ] . includes ( event . key ) ) {
262
- event . preventDefault ( )
271
+ key : cloned . componentOptions . propsData . value ,
272
+ nativeOn : {
273
+ click : ( event ) => {
263
274
this . handleChange ( cloned . componentOptions . propsData . value )
275
+ } ,
276
+ keydown : ( event ) => {
277
+ if ( [ 'Enter' , ' ' ] . includes ( event . key ) ) {
278
+ event . preventDefault ( )
279
+ this . handleChange ( cloned . componentOptions . propsData . value )
280
+ }
264
281
}
265
282
}
266
- }
267
- } , cloned . componentOptions . children )
283
+ } ,
284
+ cloned . componentOptions . children
285
+ )
268
286
}
269
287
270
288
if ( this . type === 'checkbox' ) {
271
- result = h ( cloned . componentOptions . Ctor , {
272
- ...cloned . data ,
273
- props : {
274
- ...( cloned . data . props || { } ) ,
275
- ...cloned . componentOptions . propsData ,
276
- type : this . type ,
277
- isChecked : this . computedValue . includes ( cloned . componentOptions . propsData . value )
278
- } ,
279
- attrs : {
280
- ...( cloned . data . attrs || { } )
281
- } ,
282
- key : cloned . componentOptions . propsData . value ,
283
- nativeOn : {
284
- click : ( event ) => {
285
- this . handleChange ( cloned . componentOptions . propsData . value )
289
+ result = h (
290
+ cloned . componentOptions . Ctor ,
291
+ {
292
+ ...cloned . data ,
293
+ props : {
294
+ ...( cloned . data . props || { } ) ,
295
+ ...cloned . componentOptions . propsData ,
296
+ type : this . type ,
297
+ isChecked : this . computedValue . includes (
298
+ cloned . componentOptions . propsData . value
299
+ )
300
+ } ,
301
+ attrs : {
302
+ ...( cloned . data . attrs || { } )
286
303
} ,
287
- keydown : ( event ) => {
288
- if ( [ 'Enter' , ' ' ] . includes ( event . key ) ) {
289
- event . preventDefault ( )
304
+ key : cloned . componentOptions . propsData . value ,
305
+ nativeOn : {
306
+ click : ( event ) => {
290
307
this . handleChange ( cloned . componentOptions . propsData . value )
308
+ } ,
309
+ keydown : ( event ) => {
310
+ if ( [ 'Enter' , ' ' ] . includes ( event . key ) ) {
311
+ event . preventDefault ( )
312
+ this . handleChange ( cloned . componentOptions . propsData . value )
313
+ }
291
314
}
292
315
}
293
- }
294
- } , cloned . componentOptions . children )
316
+ } ,
317
+ cloned . componentOptions . children
318
+ )
295
319
}
296
320
297
321
return result
298
322
} )
299
323
300
- return h ( CMenuGroup , {
301
- props : {
302
- title : this . title
324
+ return h (
325
+ CMenuGroup ,
326
+ {
327
+ props : {
328
+ title : this . title
329
+ } ,
330
+ attrs : {
331
+ ...this . $attrs ,
332
+ 'data-chakra-component' : 'CMenuOptionGroup'
333
+ }
303
334
} ,
304
- attrs : {
305
- ...this . $attrs ,
306
- 'data-chakra-component' : 'CMenuOptionGroup'
307
- }
308
- } , clonedChildNodes )
335
+ clonedChildNodes
336
+ )
309
337
}
310
338
}
311
339
312
- export {
313
- CMenuItemOption ,
314
- CMenuOptionGroup
315
- }
340
+ export { CMenuItemOption , CMenuOptionGroup }
0 commit comments