webcake-ui-kit 1.1.27 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -404,14 +404,41 @@ export default {
|
|
|
404
404
|
// Vue 3: $slots.default is a function; Vue 2: it's an array
|
|
405
405
|
return typeof this.$slots.default === 'function' ? this.$slots.default() : this.$slots.default || []
|
|
406
406
|
},
|
|
407
|
+
_slotText(vnode) {
|
|
408
|
+
// Vue 2: text lives in componentOptions.children as text-vnodes
|
|
409
|
+
if (vnode.componentOptions && Array.isArray(vnode.componentOptions.children)) {
|
|
410
|
+
return vnode.componentOptions.children
|
|
411
|
+
.map(function (c) {
|
|
412
|
+
return c.text || ''
|
|
413
|
+
})
|
|
414
|
+
.join('')
|
|
415
|
+
.trim()
|
|
416
|
+
}
|
|
417
|
+
// Vue 3: text lives in children.default() as vnodes with string .children
|
|
418
|
+
if (vnode.children && typeof vnode.children.default === 'function') {
|
|
419
|
+
try {
|
|
420
|
+
return vnode.children
|
|
421
|
+
.default()
|
|
422
|
+
.map(function (c) {
|
|
423
|
+
return typeof c.children === 'string' ? c.children : ''
|
|
424
|
+
})
|
|
425
|
+
.join('')
|
|
426
|
+
.trim()
|
|
427
|
+
} catch (e) {
|
|
428
|
+
return ''
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return ''
|
|
432
|
+
},
|
|
407
433
|
_syncSlotLabels() {
|
|
408
434
|
const collect = nodes => {
|
|
409
435
|
if (!Array.isArray(nodes)) return
|
|
410
436
|
nodes.forEach(vnode => {
|
|
411
437
|
if (!vnode) return
|
|
412
438
|
const props = vnode.props || (vnode.componentOptions && vnode.componentOptions.propsData)
|
|
413
|
-
if (props && props.value != null
|
|
414
|
-
|
|
439
|
+
if (props && props.value != null) {
|
|
440
|
+
const label = props.label || this._slotText(vnode)
|
|
441
|
+
if (label) this.registerOption(String(props.value), String(label))
|
|
415
442
|
}
|
|
416
443
|
if (Array.isArray(vnode.children)) collect(vnode.children)
|
|
417
444
|
})
|
|
@@ -424,8 +451,9 @@ export default {
|
|
|
424
451
|
for (const vnode of nodes) {
|
|
425
452
|
if (!vnode) continue
|
|
426
453
|
const props = vnode.props || (vnode.componentOptions && vnode.componentOptions.propsData)
|
|
427
|
-
if (props && String(props.value) === String(value)
|
|
428
|
-
|
|
454
|
+
if (props && String(props.value) === String(value)) {
|
|
455
|
+
const label = props.label || this._slotText(vnode)
|
|
456
|
+
if (label) return String(label)
|
|
429
457
|
}
|
|
430
458
|
if (Array.isArray(vnode.children)) {
|
|
431
459
|
const found = scan(vnode.children)
|