Skip to content

Commit

Permalink
feat(n-tree-select): add watch-props prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jahnli committed Aug 29, 2023
1 parent 2167367 commit e65dbda
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- `n-tree` adds node information for `render-switcher-icon` props, closes [#4815](https://github.com/tusen-ai/naive-ui/issues/4815).
- `n-input-number` export the `select` method.
- `n-data-table` adds `n-data-table-tr--expanded` class to expanded rows, and `n-data-table-tr n-data-table-tr--expand` class to the additional row, closes [#4420](https://github.com/tusen-ai/naive-ui/issues/4420).
- `n-tree-select` adds `watch-props` prop.

### i18n

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- `n-tree``render-switcher-icon` 属性添加节点信息,关闭 [#4815](https://github.com/tusen-ai/naive-ui/issues/4815)
- `n-input-number` 导出 `select` 方法
- `n-data-table` 新增 `n-data-table-tr--expanded` class 到展开行,新增 `n-data-table-tr n-data-table-tr--expand` class 到附加行,关闭 [#4420](https://github.com/tusen-ai/naive-ui/issues/4420).
- `n-tree-select` 新增 `watch-props` 属性

### i18n

Expand Down
1 change: 1 addition & 0 deletions src/tree-select/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ debug.vue
| to | `string \| HTMLElement \| false` | `body` | Container node of the menu. `false` will keep it not detached. | |
| value | `string \| number \| Array<string \| number> \| null>` | `undefined` | Selected key (or keys when multiple). | |
| virtual-scroll | `boolean` | `true` | Whether to enable virtual scrolling. | |
| watch-props | `Array<'defaultCheckedKeys' \| 'defaultSelectedKeys' \|'defaultExpandedKeys'>` | `undefined` | Default prop names that needed to be watched. Components will be updated after the prop is changed. Note: the `watch-props` itself is not reactive. | |
| on-blur | `(e: FocusEvent) => void` | `undefined` | Callback on blur. | |
| on-focus | `(e: FocusEvent) => void` | `undefined` | Callback on focus. | |
| on-load | `(node: TreeSelectOption) => Promise<void>` | `undefined` | Callback function for asynchronously loading data. | 2.27.0 |
Expand Down
1 change: 1 addition & 0 deletions src/tree-select/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ render-debug.vue
| to | `string \| HTMLElement \| false` | `body` | 菜单的容器节点,`false` 会待在原地 | |
| value | `string \| number \| Array<string \| number> \| null>` | `undefined` | 选中的 key | |
| virtual-scroll | `boolean` | `true` | 是否开启虚拟滚动 | |
| watch-props | `Array<'defaultCheckedKeys' \| 'defaultSelectedKeys' \|'defaultExpandedKeys'>` | `undefined` | 需要检测变更的默认属性,检测后组件状态会更新。注意:`watch-props` 本身不是响应式的 | |
| on-blur | `(e: FocusEvent) => void` | `undefined` | Blur 时的回调 | |
| on-focus | `(e: FocusEvent) => void` | `undefined` | Focus 时的回调 | |
| on-load | `(node: TreeSelectOption) => Promise<void>` | `undefined` | 异步加载数据的回调函数 | 2.27.0 |
Expand Down
4 changes: 4 additions & 0 deletions src/tree-select/src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export const treeSelectProps = {
renderPrefix: Function as PropType<TreeSelectRenderPrefix>,
renderSuffix: Function as PropType<TreeSelectRenderSuffix>,
nodeProps: Function as PropType<TreeSelectNodeProps>,
watchProps: Array as PropType<
Array<'defaultCheckedKeys' | 'defaultSelectedKeys' | 'defaultExpandedKeys'>
>,
onBlur: Function as PropType<(e: FocusEvent) => void>,
onFocus: Function as PropType<(e: FocusEvent) => void>,
onLoad: Function as PropType<OnLoad>,
Expand Down Expand Up @@ -948,6 +951,7 @@ export default defineComponent({
renderSuffix={this.renderSuffix}
renderSwitcherIcon={this.renderSwitcherIcon}
nodeProps={this.nodeProps}
watchProps={this.watchProps}
virtualScroll={
this.consistentMenuWidth && this.virtualScroll
}
Expand Down

0 comments on commit e65dbda

Please sign in to comment.