fix: type

This commit is contained in:
07akioni 2022-05-17 22:01:03 +08:00
parent 0fafdb24c6
commit 720f135260
7 changed files with 58 additions and 28 deletions

View File

@ -2,10 +2,12 @@
## NEXT_VERSION
### Breaking Changes
- Since `n-pagination` supports `size` prop, some theme variables of `n-pagination` are changed.
### Fixes
- `quickJump` in `n-pagination` will be formatted as Int, close [#2928](https://github.com/TuSimple/naive-ui/issues/2928)
- `quickJump` in `n-pagination` will jump to the first page/last page when its value out of range, close [#2928](https://github.com/TuSimple/naive-ui/issues/2928)
- Fix `n-menu` use `render-icon` function render incorrect when returns `true`.
- Fix `n-tabs`'s `tabFontWeightActive` theme varialbe applies to all tabs, closes [#2926](https://github.com/TuSimple/naive-ui/issues/2926).
- Fix `n-tree-select`'s `default-expand-all` not working.
@ -16,6 +18,9 @@
- `n-notification-provider`'s `placement` prop supports `'top'` and `'bottom'`, closes [#2930](https://github.com/TuSimple/naive-ui/issues/2930).
- `n-pagination` add `size` prop, closes [#2888](https://github.com/TuSimple/naive-ui/issues/2888).
- `n-config-provider` adds `preflight-style-disabled` prop.
- `n-pagination`'s quick jumper only allow integer input, closes [#2928](https://github.com/TuSimple/naive-ui/issues/2928).
- `n-pagination` will jump to the first / last page when its value is out of range, closes [#2928](https://github.com/TuSimple/naive-ui/issues/2928).
### i18n

View File

@ -2,10 +2,12 @@
## NEXT_VERSION
### Breaking Changes
- 由于 `n-pagination` 支持了 `size` 属性,因此 `n-pagination` 的部分主题变量名称进行了调整
### Fixes
- 过滤 `n-pagination` 中快速跳转的输入字符为纯数字, 关闭 [#2928](https://github.com/TuSimple/naive-ui/issues/2928)
- `n-pagination` 快速跳转的页码超出范围时曲最大值/最小值, 关闭 [#2928](https://github.com/TuSimple/naive-ui/issues/2928)
- 修复 `n-menu` 使用 `render-icon` 函数返回值为 true 时渲染不正确
- 修复 `n-tabs``tabFontWeightActive` 主题变量应用在全部 tab 上了,关闭 [#2926](https://github.com/TuSimple/naive-ui/issues/2926)
- 修复 `n-tree-select``default-expand-all` 不生效
@ -17,10 +19,12 @@
- `n-notification-provider``placement` 属性支持 `'top'``'bottom'`,关闭 [#2930](https://github.com/TuSimple/naive-ui/issues/2930)
- `n-pagination` 新增 `size` 属性,关闭 [#2888](https://github.com/TuSimple/naive-ui/issues/2888)
- `n-config-provider` 新增 `preflight-style-disabled` 属性
- `n-pagination` 快速跳转的页码超出范围时取最大值、最小值,关闭 [#2928](https://github.com/TuSimple/naive-ui/issues/2928)
- `n-pagination` 中快速跳转的输入字符只允许纯数字,关闭 [#2928](https://github.com/TuSimple/naive-ui/issues/2928)
### i18n
- Add nlNL locale.
- 新增 nlNL locale
## 2.28.4

View File

@ -13,17 +13,30 @@ export function largerSize (
}
}
export function smallerSize (
size: 'small' | 'medium' | 'large' | 'huge'
): 'tiny' | 'small' | 'medium' | 'large' {
switch (size) {
case 'small':
return 'tiny'
case 'medium':
return 'small'
case 'large':
return 'medium'
case 'huge':
return 'large'
}
interface SmallerSizeMap {
tiny: 'mini'
small: 'tiny'
medium: 'small'
large: 'medium'
huge: 'large'
}
type SmallerSize<T extends keyof SmallerSizeMap> = SmallerSizeMap[T]
export function smallerSize<T extends keyof SmallerSizeMap> (
size: T
): SmallerSize<T> {
switch (size) {
case 'tiny':
return 'mini' as any
case 'small':
return 'tiny' as any
case 'medium':
return 'small' as any
case 'large':
return 'medium' as any
case 'huge':
return 'large' as any
}
throw Error(`${size} has no smaller size.`)
}

View File

@ -42,6 +42,10 @@ import style from './styles/index.cssr'
const dynamicTagsProps = {
...(useTheme.props as ThemeProps<DynamicTagsTheme>),
...commonProps,
size: {
type: String as PropType<'small' | 'medium' | 'large'>,
default: 'medium'
},
closable: {
type: Boolean,
default: true

View File

@ -23,20 +23,24 @@ const tagDark: TagTheme = {
closeColorHover,
closeColorPressed,
borderRadiusSmall: borderRadius,
fontSizeMini,
fontSizeTiny,
fontSizeSmall,
fontSizeMedium,
heightMini,
heightTiny,
heightSmall,
heightMedium
} = vars
return {
...commonVariables,
heightTiny: heightMini,
heightSmall: heightTiny,
heightMedium: heightSmall,
heightLarge: heightMedium,
borderRadius,
opacityDisabled,
fontSizeTiny: fontSizeMini,
fontSizeSmall: fontSizeTiny,
fontSizeMedium: fontSizeSmall,
fontSizeLarge: fontSizeMedium,

View File

@ -413,13 +413,13 @@ export const themeOverridesDark: GlobalThemeOverrides = {
},
Pagination: {
itemSizeMedium: '32px',
itemPadding: '0',
itemPaddingMedium: '0',
// buttonFontSize: '24px',
itemFontSizeMedium: '16px',
inputWidth: '80px',
selectWidth: '100px',
inputMargin: '0 20px',
itemMargin: '0 0 0 20px',
inputWidthMedium: '80px',
selectWidthMedium: '100px',
inputMarginMedium: '0 20px',
itemMarginMedium: '0 0 0 20px',
itemBorder: '0 solid #0000',
itemBorderActive: '0 solid #0000',
itemBorderDisabled: '0 solid #0000',

View File

@ -320,13 +320,13 @@ export const themeOverridesLight: GlobalThemeOverrides = {
},
Pagination: {
itemSizeMedium: '32px',
itemPadding: '0',
itemPaddingMedium: '0',
// buttonFontSize: '24px',
itemFontSizeMedium: '16px',
inputWidth: '80px',
selectWidth: '100px',
inputMargin: '0 20px',
itemMargin: '0 0 0 20px',
inputWidthMedium: '80px',
selectWidthMedium: '100px',
inputMarginMedium: '0 20px',
itemMarginMedium: '0 0 0 20px',
itemBorder: '0 solid #0000',
itemBorderHover: '0 solid #0000',
itemBorderActive: '0 solid #0000',