diff --git a/demo/documentation/components/layout/enUS/collapse.md b/demo/documentation/components/layout/enUS/collapse.md index 1733af2f4..1c6e11436 100644 --- a/demo/documentation/components/layout/enUS/collapse.md +++ b/demo/documentation/components/layout/enUS/collapse.md @@ -13,62 +13,62 @@ Use `collapsed-width` and `width` to set sider's width. - - + + - + - + - + - + - + - - + + - + - - - + + + @@ -110,11 +110,11 @@ Use `collapsed-width` and `width` to set sider's width. ``` ```js -import iosAirplane from 'naive-ui/lib/icons/ios-airplane' +import mdNotificationsOutline from 'naive-ui/lib/icons/md-notifications-outline' export default { components: { - iosAirplane + mdNotificationsOutline }, data () { return { diff --git a/packages/base/SelectMenu/src/SelectMenu.vue b/packages/base/SelectMenu/src/SelectMenu.vue index 46bf2a5a7..7d510b695 100644 --- a/packages/base/SelectMenu/src/SelectMenu.vue +++ b/packages/base/SelectMenu/src/SelectMenu.vue @@ -19,7 +19,7 @@ @scroll="handleMenuScroll" >
- +
import { getDefaultSlotOf, - getComponentNameOf, - getOptionPropsDataOf + getOptionPropsDataOf, + isSelectOptionLikeComponent } from '../../../utils/component' -import { - VALID_COMPONENT -} from './config' - export default { name: 'NBaseSelectOptionCollector', provide () { @@ -76,7 +72,7 @@ export default { * If component name is valid, * there must be data */ - if (VALID_COMPONENT.includes(getComponentNameOf(child))) { + if (isSelectOptionLikeComponent(child)) { const propsData = getOptionPropsDataOf(child) this.options.push({ ...propsData, children: child.children }) } diff --git a/packages/base/SelectMenu/src/SelectRenderOptions.vue b/packages/base/SelectMenu/src/SelectRenderOptions.vue index 88f233aa4..b4df6791d 100644 --- a/packages/base/SelectMenu/src/SelectRenderOptions.vue +++ b/packages/base/SelectMenu/src/SelectRenderOptions.vue @@ -7,36 +7,28 @@ export default { inject: { NBaseSelectMenu: { default: null - }, - mirror: { - type: Boolean, - default: true } }, render (h, context) { - if (context.props.mirror) { - return context.children - } else { - const selectMenu = context.injections.NBaseSelectMenu - const options = selectMenu && selectMenu.linkedOptions - const isSelected = selectMenu.isSelected - return options.map(option => { - return h(SelectOption, { - props: { - label: option.label, - value: option.value, - disabled: option.disabled, - isSelected: isSelected({ value: option.value }), - mirror: false - }, - scopedSlots: { - default () { - return option.children - } + const selectMenu = context.injections.NBaseSelectMenu + const options = selectMenu && selectMenu.linkedOptions + const isSelected = selectMenu.isSelected + return options.map(option => { + return h(SelectOption, { + props: { + label: option.label, + value: option.value, + disabled: option.disabled, + isSelected: isSelected({ value: option.value }), + mirror: false + }, + scopedSlots: { + default () { + return option.children } - }) + } }) - } + }) } } diff --git a/packages/base/SelectMenu/src/config.js b/packages/base/SelectMenu/src/config.js deleted file mode 100644 index 325f93696..000000000 --- a/packages/base/SelectMenu/src/config.js +++ /dev/null @@ -1,5 +0,0 @@ -const VALID_COMPONENT = ['NBaseSelectOption', 'NDropdownItem', 'NDropdownSubmenu'] - -export { - VALID_COMPONENT -} diff --git a/packages/common/Dropdown/src/Dropdown.vue b/packages/common/Dropdown/src/Dropdown.vue index 64fc4295f..8b4278ad3 100644 --- a/packages/common/Dropdown/src/Dropdown.vue +++ b/packages/common/Dropdown/src/Dropdown.vue @@ -69,6 +69,14 @@ export default { focusable: { type: Boolean, default: true + }, + disabled: { + type: Boolean, + default: false + }, + type: { + type: String, + default: 'dropdown' } }, render (h, context) { @@ -91,6 +99,7 @@ export default { arrow: false, raw: true, shadow: false, + disabled: context.props.disabled, controller }, scopedSlots: { @@ -103,6 +112,7 @@ export default { tabindex: context.props.focusable ? '0' : '-1' }, props: { + type: context.props.type, autoFocus: context.props.autoFocus, size: context.props.size, controller, diff --git a/packages/common/Dropdown/src/DropdownItem.vue b/packages/common/Dropdown/src/DropdownItem.vue index bd316d6b3..0376beed7 100644 --- a/packages/common/Dropdown/src/DropdownItem.vue +++ b/packages/common/Dropdown/src/DropdownItem.vue @@ -18,6 +18,10 @@ export default { value: { type: Number, required: true + }, + selected: { + type: Boolean, + default: false } }, inject: { @@ -29,7 +33,12 @@ export default { return h(NBaseSelectOption, { props: { label: this.$scopedSlots.default ? '' : (this.label || this.name), - value: this.value + value: this.value, + isSelected: this.selected + }, + class: { + 'n-dropdown-item': true, + 'n-dropdown-item--as-submenu': this.asSubmenu }, scopedSlots: { ...this.$scopedSlots }, on: { diff --git a/packages/common/Dropdown/src/DropdownMenu.vue b/packages/common/Dropdown/src/DropdownMenu.vue index 636054420..d21ebcb16 100644 --- a/packages/common/Dropdown/src/DropdownMenu.vue +++ b/packages/common/Dropdown/src/DropdownMenu.vue @@ -25,6 +25,10 @@ export default { } }, props: { + type: { + type: String, + default: 'dropdown' + }, autoFocus: { type: Boolean, default: true @@ -63,6 +67,12 @@ export default { } }, computed: { + showAsMenuPopover () { + if (this.NDropdownMenu) { + return this.NDropdownMenu.showAsMenuPopover + } + return this.type === 'menu' + }, inheritedSubmenuWidth () { if (this.NDropdownMenu) { return this.NDropdownMenu.inheritedSubmenuWidth @@ -95,6 +105,7 @@ export default { }, methods: { handleSelectItem (name) { + console.log('handleSelectItem') /** * Can only be called at root level menu */ @@ -177,6 +188,9 @@ export default { }) return h('div', { staticClass: 'n-dropdown-menu', + class: { + 'n-dropdown-menu--as-menu-popover': this.showAsMenuPopover + }, on: { keydown: this.handleKeyDown, mouseenter: this.handleMouseEnter, @@ -194,15 +208,21 @@ export default { h(NBaseSelectMenu, { ref: 'selectMenu', props: { + withoutLightBar: this.showAsMenuPopover, withoutScrollbar: true, useSlot: !!this.$scopedSlots.default, - isSelected: () => false, options: this.options, size: this.size, + isSelected: () => false, theme: this.synthesizedTheme, mirror: true + }, + scopedSlots: { + default () { + return options + } } - }, options) + }) ]) } } diff --git a/packages/common/Dropdown/src/DropdownSubmenu.vue b/packages/common/Dropdown/src/DropdownSubmenu.vue index 6fd55dcf2..58b905a97 100644 --- a/packages/common/Dropdown/src/DropdownSubmenu.vue +++ b/packages/common/Dropdown/src/DropdownSubmenu.vue @@ -2,8 +2,9 @@ { diff --git a/packages/common/Menu/src/Menu.vue b/packages/common/Menu/src/Menu.vue index ed252103a..56e82b6ca 100644 --- a/packages/common/Menu/src/Menu.vue +++ b/packages/common/Menu/src/Menu.vue @@ -65,6 +65,7 @@ export default { }, data () { return { + activeNames: [], internalOpenNames: this.openNames || this.defaultOpenNames || [] } }, diff --git a/packages/common/Menu/src/MenuItem.vue b/packages/common/Menu/src/MenuItem.vue index 7d1bfed8e..231ac68f6 100644 --- a/packages/common/Menu/src/MenuItem.vue +++ b/packages/common/Menu/src/MenuItem.vue @@ -1,13 +1,48 @@ + diff --git a/packages/common/Menu/src/MenuUl.vue b/packages/common/Menu/src/MenuUl.vue new file mode 100644 index 000000000..49fe9ed6d --- /dev/null +++ b/packages/common/Menu/src/MenuUl.vue @@ -0,0 +1,16 @@ + + + diff --git a/packages/common/Menu/src/SubMenu.vue b/packages/common/Menu/src/SubMenu.vue index d7232b4e3..9a686be06 100644 --- a/packages/common/Menu/src/SubMenu.vue +++ b/packages/common/Menu/src/SubMenu.vue @@ -1,10 +1,62 @@ +