Skip to content

Commit

Permalink
refactor: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed May 21, 2023
1 parent c49963a commit cc4425c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- `n-data-table`'s `render-expand-icon` add `expanded` param, closes [#4439](https://github.com/tusen-ai/naive-ui/issues/4439).
- `n-tabs` adds `pane-wrapper-class` `pane-wrapper-style` prop.
- `n-collapse` adds `titlePadding` theme variable, closes [#4728](https://github.com/tusen-ai/naive-ui/issues/4728).
- `n-tabs` adds `placement` prop.

### i18n

Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

### Fixes

- 修复 `n-notification``description` 有英文时没有自动换行, closes [#4609](https://github.com/tusen-ai/naive-ui/issues/4609)
- 修复 `n-notification``description` 有英文时没有自动换行,关闭 [#4609](https://github.com/tusen-ai/naive-ui/issues/4609)
- 修复 `n-dynamic-input``on-remove` 方法返回被删除的数据下标 `index``value[index]` 已经不存在
- 修复 `n-dynamic-input` 在点击添加按钮后 `on-create` 返回的 `index` 不正确
- 修复 `trTR` 国际化,关闭 [#4231](https://github.com/tusen-ai/naive-ui/issues/4231)
- 修复 `n-input` 同时使用 `password``disabled` 时,显示密码图标偏移的问题,关闭 [#4364](https://github.com/tusen-ai/naive-ui/issues/4364)
- 修复 `n-image` 设置 `fallback-src` 属性和懒加载无效,closes[#4480](https://github.com/tusen-ai/naive-ui/issues/4480)
- 修复 `n-upload` 内部使用 vue `TransitionGroup` 组件时, 传递了未声明的 prop 且未被自动继承导致警告, 关闭[#4447](https://github.com/tusen-ai/naive-ui/issues/4447)
- 修复 `n-image` 设置 `fallback-src` 属性和懒加载无效,关闭 [#4480](https://github.com/tusen-ai/naive-ui/issues/4480)
- 修复 `n-upload` 内部使用 vue `TransitionGroup` 组件时, 传递了未声明的 prop 且未被自动继承导致警告关闭[#4447](https://github.com/tusen-ai/naive-ui/issues/4447)
- 修复 `n-menu` `show` `default` 属性拼写问题,关闭 [#4750](https://github.com/tusen-ai/naive-ui/issues/4750)
- 修复 `n-icon-wrapper` 的主题异常,关闭 [#4768](https://github.com/tusen-ai/naive-ui/issues/4768)

Expand All @@ -25,6 +25,7 @@
- `n-data-table``render-expand-icon` 属性新增 `expanded` 参数,关闭 [#4439](https://github.com/tusen-ai/naive-ui/issues/4439)
- `n-tabs` 新增 `pane-wrapper-class` `pane-wrapper-style` 属性
- `n-collapse` 新增 `titlePadding` 主题变量,关闭 [#4728](https://github.com/tusen-ai/naive-ui/issues/4728)
- `n-tabs` 新增 `placement` 属性

### i18n

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { h, Transition, TransitionGroup, defineComponent, type PropType } from 'vue'
import {
h,
Transition,
TransitionGroup,
type TransitionProps,
defineComponent,
type PropType
} from 'vue'

export default defineComponent({
name: 'FadeInExpandTransition',
Expand Down Expand Up @@ -77,24 +84,23 @@ export default defineComponent({
props.onAfterEnter?.()
}
return () => {
const type = props.group ? TransitionGroup : Transition
const differentProps = props.group ? undefined : { mode: props.mode }
return h(
type as any,
{
name: props.width
? 'fade-in-width-expand-transition'
: 'fade-in-height-expand-transition',
appear: props.appear,
onEnter: handleEnter,
onAfterEnter: handleAfterEnter,
onBeforeLeave: handleBeforeLeave,
onLeave: handleLeave,
onAfterLeave: handleAfterLeave,
...differentProps
},
slots
)
const { group, width, appear, mode } = props
const type = group ? TransitionGroup : Transition
const resolvedProps = {
name: width
? 'fade-in-width-expand-transition'
: 'fade-in-height-expand-transition',
appear,
onEnter: handleEnter,
onAfterEnter: handleAfterEnter,
onBeforeLeave: handleBeforeLeave,
onLeave: handleLeave,
onAfterLeave: handleAfterLeave
}
if (!group) {
;(resolvedProps as unknown as TransitionProps).mode = mode
}
return h(type as any, resolvedProps, slots)
}
}
})
2 changes: 1 addition & 1 deletion src/_mixins/use-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function useTheme<N, T, R> (
style: CNode | undefined,
defaultTheme: Theme<N, T, R>,
props: UseThemeProps<Theme<N, T, R>>,
clsPrefixRef?: Ref<string | undefined>
clsPrefixRef: Ref<string | undefined> | undefined
): ComputedRef<MergedTheme<Theme<N, T, R>>> {
const ssrAdapter = useSsrAdapter()
const NConfigProvider = inject(configProviderInjectionKey, null)
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic-input/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ custom-action.vue
| --- | --- | --- | --- | --- |
| create-button-props | `ButtonProps` | `undefined` | Props of create item button. | 2.25.0 |
| default-value | `unknown[]` | `[]` | Default value. | |
| disabled | `boolean` | `false` | Whether to disable the dynamic-input. | NEXT_VERSION |
| disabled | `boolean` | `false` | Whether to disable the dynamic-input. It won't work for custom content. | NEXT_VERSION |
| item-style | `string \| Object` | `undefined` | The style of each item of the dynamic input. | |
| key-field | `string` | `undefined` | The key of each item that should be used in the rendering of the list. | |
| min | `number` | `0` | Minimum number of items. | |
Expand Down
6 changes: 3 additions & 3 deletions src/dynamic-input/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ create-debug.vue
| --- | --- | --- | --- | --- |
| create-button-props | `ButtonProps` | `undefined` | 新建项按钮的属性 | 2.25.0 |
| default-value | `unknown[]` | `[]` | 非受控模式下的默认值 | |
| disabled | `boolean` | `false` | 是否禁用 | NEXT_VERSION |
| disabled | `boolean` | `false` | 是否禁用,对自定义内容无效 | NEXT_VERSION |
| item-style | `string \| Object` | `undefined` | 动态录入中每项的样式 | |
| key-field | `string` | `undefined` | 每一项的 key 值,会被用于列表渲染中 | |
| min | `number` | `0` | 最少有几项内容 | |
| max | `number` | `undefined` | 最多有几项内容 | |
| preset | `'input' \| 'pair'` | `'input'` | 动态录入使用的预设,在不设定 `$slots.default` 的时候生效 | |
| preset | `'input' \| 'pair'` | `'input'` | 动态录入使用的预设,在不设定 `$slots.default` 的时候生效 | |
| show-sort-button | `boolean` | `false` | 是否显示排序按钮 | 2.25.0 |
| value | `unknown[]` | `undefined` | 受控模式下的值 | |
| on-create | `(index: number) => void` | `undefined` | 点击添加按钮时的回调,如果设定则返回值会被用作新添加的初始值。其中 `index` 是创建内容将要被放置到的位置对应的数组索引,从 1 (第二项)开始计算 | |
| on-create | `(index: number) => void` | `undefined` | 点击添加按钮时的回调,如果设定则返回值会被用作新添加的初始值。其中 `index` 是创建内容将要被放置到的位置对应的数组索引,从 1第二项开始计算 | |
| on-remove | `(index: number) => void` | `undefined` | 点击第 index 项删除按钮的回调 | |
| on-update:value | `(value: any) => void` | `undefined` | 组件值发生变化的回调 | |

Expand Down
6 changes: 4 additions & 2 deletions src/popselect/src/Popselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { PopoverInst, PopoverTrigger } from '../../popover'
import NPopselectPanel, { panelPropKeys, panelProps } from './PopselectPanel'
import { omit, keep, createRefSetter, mergeEventHandlers } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { useTheme } from '../../_mixins'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { popselectLight } from '../styles'
import type { PopselectTheme } from '../styles'
Expand Down Expand Up @@ -42,12 +42,14 @@ export default defineComponent({
inheritAttrs: false,
__popover__: true,
setup (props) {
const { mergedClsPrefixRef } = useConfig(props)
const themeRef = useTheme(
'Popselect',
'-popselect',
undefined,
popselectLight,
props
props,
mergedClsPrefixRef
)
const popoverInstRef = ref<PopoverInst | null>(null)
function syncPosition (): void {
Expand Down
6 changes: 4 additions & 2 deletions src/tooltip/src/Tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { h, defineComponent, ref, computed } from 'vue'
import { NPopover } from '../../popover'
import { popoverBaseProps } from '../../popover/src/Popover'
import type { PopoverInst } from '../../popover'
import { useTheme } from '../../_mixins'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { tooltipLight } from '../styles'
import type { TooltipTheme } from '../styles'
Expand All @@ -23,12 +23,14 @@ export default defineComponent({
props: tooltipProps,
__popover__: true,
setup (props) {
const { mergedClsPrefixRef } = useConfig(props)
const themeRef = useTheme(
'Tooltip',
'-tooltip',
undefined,
tooltipLight,
props
props,
mergedClsPrefixRef
)
const popoverRef = ref<PopoverInst | null>(null)
const tooltipExposedMethod: TooltipInst = {
Expand Down

0 comments on commit cc4425c

Please sign in to comment.