Skip to content

Commit

Permalink
Merge branch 'main' into 1499
Browse files Browse the repository at this point in the history
  • Loading branch information
Volankey authored Nov 8, 2021
2 parents 3977ac0 + d969580 commit ee3c81c
Show file tree
Hide file tree
Showing 24 changed files with 534 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -30,7 +30,7 @@ jobs:
- run: pnpm install
- run: pnpm run lint
- run: pnpm run test:cov
- uses: codecov/codecov-action@v1.5.2
- uses: codecov/codecov-action@v2.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}

10 changes: 9 additions & 1 deletion CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CHANGELOG

## Pending
## 2.20.2 (2021-11-05)

### Feats

Expand All @@ -11,6 +11,14 @@

- Fix `n-alert` `contentTextColor` and `titleTextColor` type theme variable not working, closes [#1495](https://github.com/TuSimple/naive-ui/issues/1495).
- Fix `n-time-picker` not trigger blur event when the panel is closed by ok button, closes [#1499](https://github.com/TuSimple/naive-ui/issues/1499).
- Fix `n-upload` `UploadFileInfo`'s `thumbnailUrl` field not working, closes [#1495](https://github.com/TuSimple/naive-ui/issues/1245).
- Fix `n-button` `keyboard` prop does not work, closes [#1508](https://github.com/TuSimple/naive-ui/issues/1508).
- Fix `n-upload` instance misses `openOpenFileDialog` method.

### i18n

- Add deDE locale.
- Add nbNO locale.

## 2.20.1 (2021-11-01)

Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CHANGELOG

## Pending
## 2.20.2 (2021-11-05)

### Feats

Expand All @@ -11,6 +11,14 @@

- 修复 `n-alert` `contentTextColor``titleTextColor` 的类型主题变量不起作用,关闭 [#1495](https://github.com/TuSimple/naive-ui/issues/1495)
- 修复 `n-time-picker` 当选择面板通过确认按钮关闭时不会触发 blur 事件, closes [#1499](https://github.com/TuSimple/naive-ui/issues/1499)
- 修复 `n-upload` `UploadFileInfo``thumbnailUrl` 字段不起作用,关闭 [#1495](https://github.com/TuSimple/naive-ui/issues/1245)
- 修复 `n-button` `keyboard` 属性不起作用,关闭 [#1508](https://github.com/TuSimple/naive-ui/issues/1508)
- 修复 `n-upload` 实例缺少 `openOpenFileDialog` 方法

### i18n

- 新增 deDE locale
- 新增 nbNO locale

## 2.20.1 (2021-11-01)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "naive-ui",
"version": "2.20.1",
"version": "2.20.2",
"description": "A Vue 3 Component Library. Fairly Complete, Customizable Themes, Uses TypeScript, Not Too Slow",
"main": "lib/index.js",
"module": "es/index.js",
Expand All @@ -20,7 +20,7 @@
"format:code": "prettier --write \"(src|demo)/**/*.(vue|js)\"",
"format:md": "prettier --write --parser markdown --prose-wrap never \"(src|demo)/**/*.md\"",
"test": "cross-env NODE_ENV=test jest --collectCoverage=false",
"test:cov": "cross-env NODE_ENV=test jest",
"test:cov": "cross-env NODE_ENV=test NODE_OPTIONS=--unhandled-rejections=warn jest",
"test:watch": "cross-env NODE_ENV=test jest ---watch --verbose --coverage",
"gen-version": "node scripts/gen-version",
"release-changelog": "node scripts/release-changelog",
Expand Down
6 changes: 4 additions & 2 deletions src/button/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ const Button = defineComponent({
switch (e.code) {
case 'Enter':
case 'NumpadEnter':
if (!props.keyboard) return
e.preventDefault()
if (!props.keyboard) {
e.preventDefault()
return
}
enterPressedRef.value = true
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/button/tests/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ describe('n-button', () => {
await inst.trigger('click')
expect(onClick).toHaveBeenCalled()
})
it('keyboard', async () => {
const onClick = jest.fn()
const inst = mount(NButton, {
props: {
keyboard: false,
onClick
}
})
await inst.trigger('click')
expect(onClick).toBeCalledTimes(1)
await inst.trigger('keydown.space')
expect(onClick).toBeCalledTimes(1)
await inst.trigger('keydown.enter')
expect(onClick).toBeCalledTimes(1)
})
it('disabled', async () => {
const onClick = jest.fn()
const inst = mount(NButton, {
Expand Down
12 changes: 12 additions & 0 deletions src/image/tests/Image.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ describe('n-image', () => {
)
})

it('should work with `previewSrc` prop', async () => {
const wrapper = mount(NImage)

await wrapper.setProps({
previewSrc: 'https://www.naiveui.com/assets/naivelogo.93278402.svg'
})

expect(wrapper.find('img').attributes('data-preview-src')).toBe(
'https://www.naiveui.com/assets/naivelogo.93278402.svg'
)
})

it('should work with `showToolbar` prop', async () => {
const wrapper = mount(NImage)

Expand Down
34 changes: 34 additions & 0 deletions src/input/tests/Input.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { mount } from '@vue/test-utils'
import { h } from 'vue'
import { NInput } from '../index'
import InputGroup from '../src/InputGroup'
import InputGroupLabel from '../src/InputGroupLabel'
import WordCount from '../src/WordCount'

describe('n-input', () => {
Expand Down Expand Up @@ -225,4 +228,35 @@ describe('n-input', () => {
expect(wrapper.find('.n-input__separator').text()).toBe('-')
wrapper.unmount()
})

it('should work with `InputGroup` `InputGroupLabel` slot', async () => {
const wrapper = mount(InputGroup, {
slots: {
default: () => [
h(InputGroupLabel, null, { default: () => 'test1' }),
h(NInput),
h(InputGroupLabel, null, { default: () => 'test2' })
]
}
})

expect(wrapper.find('.n-input-group').exists()).toBe(true)
expect(wrapper.find('.n-input-group').element.children.length).toBe(3)
expect(
wrapper.find('.n-input-group').element.children[0].getAttribute('class')
).toContain('n-input-group-label')
expect(wrapper.find('.n-input-group').element.children[0].textContent).toBe(
'test1'
)
expect(
wrapper.find('.n-input-group').element.children[1].getAttribute('class')
).toContain('n-input')
expect(
wrapper.find('.n-input-group').element.children[2].getAttribute('class')
).toContain('n-input-group-label')
expect(wrapper.find('.n-input-group').element.children[2].textContent).toBe(
'test2'
)
wrapper.unmount()
})
})
40 changes: 40 additions & 0 deletions src/locales/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,43 @@ exports[`locale works 6`] = `
</div>
</div>"
`;
exports[`locale works 7`] = `
"<div class=\\"n-config-provider\\">
<div class=\\"n-input n-input--resizable n-input--stateful\\" style=\\"--bezier: cubic-bezier(.4, 0, .2, 1); --count-text-color: rgb(158, 164, 170); --color: rgba(255, 255, 255, 1); --font-size: 14px; --border-radius: 3px; --height: 34px; --padding-left: 12px; --padding-right: 12px; --text-color: rgb(51, 54, 57); --caret-color: #18a058; --text-decoration-color: rgb(51, 54, 57); --border: 1px solid rgb(224, 224, 230); --border-disabled: 1px solid rgb(224, 224, 230); --border-hover: 1px solid #36ad6a; --border-focus: 1px solid #36ad6a; --placeholder-color: rgba(194, 194, 194, 1); --placeholder-color-disabled: rgba(209, 209, 209, 1); --icon-size: 16px; --line-height-textarea: 1.6; --color-disabled: rgb(250, 250, 252); --color-focus: rgba(255, 255, 255, 1); --text-color-disabled: rgba(194, 194, 194, 1); --box-shadow-focus: 0 0 0 2px rgba(24, 160, 88, 0.2); --loading-color: #18a058; --caret-color-warning: #f0a020; --color-focus-warning: rgba(255, 255, 255, 1); --box-shadow-focus-warning: 0 0 0 2px rgba(240, 160, 32, 0.2); --border-warning: 1px solid #f0a020; --border-focus-warning: 1px solid #fcb040; --border-hover-warning: 1px solid #fcb040; --loading-color-warning: #f0a020; --caret-color-error: #d03050; --color-focus-error: rgba(255, 255, 255, 1); --box-shadow-focus-error: 0 0 0 2px rgba(208, 48, 80, 0.2); --border-error: 1px solid #d03050; --border-focus-error: 1px solid #de576d; --border-hover-error: 1px solid #de576d; --loading-color-error: #d03050; --clear-color: rgba(194, 194, 194, 1); --clear-size: 16px; --clear-color-hover: rgba(146, 146, 146, 1); --clear-color-pressed: rgba(175, 175, 175, 1); --icon-color: rgba(194, 194, 194, 1); --icon-color-hover: rgba(146, 146, 146, 1); --icon-color-pressed: rgba(175, 175, 175, 1); --icon-color-disabled: rgba(209, 209, 209, 1); --suffix-text-color: rgb(51, 54, 57);\\">
<div class=\\"n-input-wrapper\\">
<!---->
<div class=\\"n-input__input\\"><input type=\\"text\\" class=\\"n-input__input-el\\" placeholder=\\"Bitte ausfüllen\\" size=\\"20\\" style=\\"\\">
<div class=\\"n-input__placeholder\\"><span>Bitte ausfüllen</span></div>
<!---->
</div>
<!---->
</div>
<!---->
<!---->
<div class=\\"n-input__border\\"></div>
<div class=\\"n-input__state-border\\"></div>
<!---->
</div>
</div>"
`;
exports[`locale works 8`] = `
"<div class=\\"n-config-provider\\">
<div class=\\"n-input n-input--resizable n-input--stateful\\" style=\\"--bezier: cubic-bezier(.4, 0, .2, 1); --count-text-color: rgb(158, 164, 170); --color: rgba(255, 255, 255, 1); --font-size: 14px; --border-radius: 3px; --height: 34px; --padding-left: 12px; --padding-right: 12px; --text-color: rgb(51, 54, 57); --caret-color: #18a058; --text-decoration-color: rgb(51, 54, 57); --border: 1px solid rgb(224, 224, 230); --border-disabled: 1px solid rgb(224, 224, 230); --border-hover: 1px solid #36ad6a; --border-focus: 1px solid #36ad6a; --placeholder-color: rgba(194, 194, 194, 1); --placeholder-color-disabled: rgba(209, 209, 209, 1); --icon-size: 16px; --line-height-textarea: 1.6; --color-disabled: rgb(250, 250, 252); --color-focus: rgba(255, 255, 255, 1); --text-color-disabled: rgba(194, 194, 194, 1); --box-shadow-focus: 0 0 0 2px rgba(24, 160, 88, 0.2); --loading-color: #18a058; --caret-color-warning: #f0a020; --color-focus-warning: rgba(255, 255, 255, 1); --box-shadow-focus-warning: 0 0 0 2px rgba(240, 160, 32, 0.2); --border-warning: 1px solid #f0a020; --border-focus-warning: 1px solid #fcb040; --border-hover-warning: 1px solid #fcb040; --loading-color-warning: #f0a020; --caret-color-error: #d03050; --color-focus-error: rgba(255, 255, 255, 1); --box-shadow-focus-error: 0 0 0 2px rgba(208, 48, 80, 0.2); --border-error: 1px solid #d03050; --border-focus-error: 1px solid #de576d; --border-hover-error: 1px solid #de576d; --loading-color-error: #d03050; --clear-color: rgba(194, 194, 194, 1); --clear-size: 16px; --clear-color-hover: rgba(146, 146, 146, 1); --clear-color-pressed: rgba(175, 175, 175, 1); --icon-color: rgba(194, 194, 194, 1); --icon-color-hover: rgba(146, 146, 146, 1); --icon-color-pressed: rgba(175, 175, 175, 1); --icon-color-disabled: rgba(209, 209, 209, 1); --suffix-text-color: rgb(51, 54, 57);\\">
<div class=\\"n-input-wrapper\\">
<!---->
<div class=\\"n-input__input\\"><input type=\\"text\\" class=\\"n-input__input-el\\" placeholder=\\"Vennligst fyll ut\\" size=\\"20\\" style=\\"\\">
<div class=\\"n-input__placeholder\\"><span>Vennligst fyll ut</span></div>
<!---->
</div>
<!---->
</div>
<!---->
<!---->
<div class=\\"n-input__border\\"></div>
<div class=\\"n-input__state-border\\"></div>
<!---->
</div>
</div>"
`;
97 changes: 97 additions & 0 deletions src/locales/common/deDE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import type { NLocale } from './enUS'

const deDE: NLocale = {
name: 'de-DE',
global: {
undo: 'Rückgängig',
redo: 'Wiederholen',
confirm: 'Bestätigen'
},
Popconfirm: {
positiveText: 'Bestätigen',
negativeText: 'Abbrechen'
},
Cascader: {
placeholder: 'Bitte auswählen',
loading: 'Wird geladen',
loadingRequiredMessage: (label: string): string =>
`Bitte laden Sie alle Unterpunkte von ${label}, bevor Sie es auswählen.`
},
Time: {
dateFormat: 'dd-MM-yyyy',
dateTimeFormat: 'dd-MM-yyyy HH:mm:ss'
},
DatePicker: {
yearFormat: 'yyyy',
monthFormat: 'MMM',
dayFormat: 'eeeeee',
clear: 'Löschen',
now: 'Jetzt',
confirm: 'Bestätigen',
selectTime: 'Uhrzeit auswählen',
selectDate: 'Datum auswählen',
datePlaceholder: 'Datum auswählen',
datetimePlaceholder: 'Datum und Uhrzeit auswählen',
monthPlaceholder: 'Monat auswählen',
startDatePlaceholder: 'Anfangsdatum',
endDatePlaceholder: 'Enddatum',
startDatetimePlaceholder: 'Anfangsdatum und Uhrzeit',
endDatetimePlaceholder: 'Enddatum und Uhrzeit',
monthBeforeYear: true,
firstDayOfWeek: 0 as 0 | 1 | 2 | 3 | 4 | 5 | 6,
today: 'Heute'
},
DataTable: {
checkTableAll: 'Alles auswählen',
uncheckTableAll: 'Auswahl aufheben',
confirm: 'Bestätigen',
clear: 'Löschen'
},
Transfer: {
sourceTitle: 'Quelle',
targetTitle: 'Ziel'
},
Empty: {
description: 'Keine Daten'
},
Select: {
placeholder: 'Bitte auswählen'
},
TimePicker: {
placeholder: 'Uhrzeit auswählen',
positiveText: 'OK',
negativeText: 'Abbrechen',
now: 'Jetzt'
},
Pagination: {
goto: 'Gehe zu',
selectionSuffix: 'Seite'
},
DynamicTags: {
add: 'Hinzufügen'
},
Log: {
loading: 'Wird geladen'
},
Input: {
placeholder: 'Bitte ausfüllen'
},
InputNumber: {
placeholder: 'Bitte ausfüllen'
},
DynamicInput: {
create: 'Erstellen'
},
ThemeEditor: {
title: 'Theme Editor',
clearAllVars: 'Alle Variablen löschen',
clearSearch: 'Suche löschen',
filterCompName: 'Filter Komponentenname',
filterVarName: 'Filter Variablenname',
import: 'Importieren',
export: 'Exportieren',
restore: 'Auf Standard zurücksetzen'
}
}

export default deDE
Loading

0 comments on commit ee3c81c

Please sign in to comment.