mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-05 13:00:47 +08:00
fix(split): fulfill it
This commit is contained in:
parent
e53a66c7cd
commit
4ddb36e612
@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"start": "pnpm run dev",
|
||||
"dev": "pnpm run clean && pnpm run gen-version && pnpm run gen-volar-dts && NODE_ENV=development vite",
|
||||
"build:package": "pnpm run gen-version && pnpm run clean && pnpm run gen-volar-dts && tsc -b --force tsconfig.esm.json && node scripts/pre-build/pre-cjs-build.js && tsc -b --force tsconfig.cjs.json && rollup -c && pnpm run test:umd && node scripts/post-build && rimraf {es,lib}/*.tsbuildinfo",
|
||||
"build:package": "pnpm run gen-version && pnpm run clean && pnpm run gen-volar-dts && tsc -b --force tsconfig.esm.json && node scripts/pre-build/pre-cjs-build.js && tsc -b --force tsconfig.cjs.json && rollup -c && pnpm run test:umd && pnpm run test:esm && node scripts/post-build && rimraf {es,lib}/*.tsbuildinfo",
|
||||
"build:site": "bash ./scripts/pre-build-site/pre-build-site.sh && NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 vite build && bash ./scripts/post-build-site/post-build-site.sh",
|
||||
"clean": "rimraf site lib es dist node_modules/naive-ui themes/tusimple/es themes/tusimple/lib",
|
||||
"release:package": "pnpm run test && pnpm run build:package && pnpm publish --no-git-checks",
|
||||
|
20
src/float-button-group/tests/NFloatButtonGroup.spec.tsx
Normal file
20
src/float-button-group/tests/NFloatButtonGroup.spec.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { h } from 'vue'
|
||||
import { NFloatButtonGroup } from '../index'
|
||||
|
||||
describe('n-flex', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NFloatButtonGroup)
|
||||
})
|
||||
|
||||
it('render empty children', () => {
|
||||
const wrapper = mount({
|
||||
render () {
|
||||
return <NFloatButtonGroup />
|
||||
}
|
||||
})
|
||||
expect(wrapper.find('.n-flex')).not.toBe(null)
|
||||
expect(wrapper.html()).toMatchSnapshot()
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
19
src/float-button-group/tests/server.spec.tsx
Normal file
19
src/float-button-group/tests/server.spec.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @jest-environment node
|
||||
*/
|
||||
import { h, createSSRApp } from 'vue'
|
||||
import { renderToString } from '@vue/server-renderer'
|
||||
import { setup } from '@css-render/vue3-ssr'
|
||||
import { NFloatButtonGroup } from '../..'
|
||||
|
||||
describe('SSR', () => {
|
||||
it('works', async () => {
|
||||
const app = createSSRApp(() => <NFloatButtonGroup />)
|
||||
setup(app)
|
||||
try {
|
||||
await renderToString(app)
|
||||
} catch (e) {
|
||||
expect(e).not.toBeTruthy()
|
||||
}
|
||||
})
|
||||
})
|
20
src/float-button/tests/FloatButton.spec.tsx
Normal file
20
src/float-button/tests/FloatButton.spec.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { h } from 'vue'
|
||||
import { NFloatButton } from '../index'
|
||||
|
||||
describe('n-flex', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NFloatButton)
|
||||
})
|
||||
|
||||
it('render empty children', () => {
|
||||
const wrapper = mount({
|
||||
render () {
|
||||
return <NFloatButton />
|
||||
}
|
||||
})
|
||||
expect(wrapper.find('.n-flex')).not.toBe(null)
|
||||
expect(wrapper.html()).toMatchSnapshot()
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
19
src/float-button/tests/server.spec.tsx
Normal file
19
src/float-button/tests/server.spec.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @jest-environment node
|
||||
*/
|
||||
import { h, createSSRApp } from 'vue'
|
||||
import { renderToString } from '@vue/server-renderer'
|
||||
import { setup } from '@css-render/vue3-ssr'
|
||||
import { NFloatButton } from '../..'
|
||||
|
||||
describe('SSR', () => {
|
||||
it('works', async () => {
|
||||
const app = createSSRApp(() => <NFloatButton />)
|
||||
setup(app)
|
||||
try {
|
||||
await renderToString(app)
|
||||
} catch (e) {
|
||||
expect(e).not.toBeTruthy()
|
||||
}
|
||||
})
|
||||
})
|
@ -1,20 +1,24 @@
|
||||
<markdown>
|
||||
# controlledPropertyValues
|
||||
# Controlled manner
|
||||
</markdown>
|
||||
|
||||
<template>
|
||||
<n-input-number v-model:value="split" :step="0.1" clearable />
|
||||
<NSplit v-model:size="split" style="height: 200px">
|
||||
<template #1>
|
||||
<div style="width: 100%; background-color: black" />
|
||||
</template>
|
||||
<template #2>
|
||||
<div style="width: 100%; background-color: red" />
|
||||
</template>
|
||||
</NSplit>
|
||||
<n-flex vertical>
|
||||
<n-input-number v-model:value="split" :step="0.1" clearable />
|
||||
<NSplit v-model:size="split" style="height: 200px">
|
||||
<template #1>
|
||||
<div style="width: 100%; background-color: black" />
|
||||
</template>
|
||||
<template #2>
|
||||
<div style="width: 100%; background-color: red" />
|
||||
</template>
|
||||
</NSplit>
|
||||
</n-flex>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { NSplit, NInputNumber } from 'naive-ui'
|
||||
|
||||
const split = ref<number>(0.8)
|
||||
</script>
|
||||
|
@ -12,6 +12,7 @@ vertical.vue
|
||||
nest.vue
|
||||
event.vue
|
||||
slot.vue
|
||||
controlled.vue
|
||||
```
|
||||
|
||||
## API
|
||||
@ -20,12 +21,12 @@ slot.vue
|
||||
|
||||
| Name | Type | Default | Description | Version |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| default-size | `number` | `0.5` | Default split size, 0-1 is a percentage. | 2.36.0 |
|
||||
| size | `number` | `undefined` | Split is the controlled split size, with 0-1 representing the percentage | NEXT_VERSION |
|
||||
| default-size | `number` | `0.5` | Default split size, 0~1 is a percentage. | 2.36.0 |
|
||||
| size | `number` | `undefined` | Split is the controlled split size, with 0~1 representing the percentage. | NEXT_VERSION |
|
||||
| disabled | `boolean` | `false` | Whether to disable the split. | 2.36.0 |
|
||||
| direction | `'horizontal' \| 'vertical'` | `'horizontal'` | The direction of the split. | 2.36.0 |
|
||||
| min | `number` | `0` | The minimum threshold for splitting, 0-1 is a percentage. | 2.36.0 |
|
||||
| max | `number` | `1` | The maximum split threshold, 0-1 is a percentage. | 2.36.0 |
|
||||
| min | `number` | `0` | The minimum threshold for splitting, 0~1 is a percentage. | 2.36.0 |
|
||||
| max | `number` | `1` | The maximum split threshold, 0~1 is a percentage. | 2.36.0 |
|
||||
| resize-trigger-size | `number` | `3` | Size of the resize trigger. | 2.36.0 |
|
||||
| watch-props | `Array<'defaultSize'>` | `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. | NEXT_VERSION |
|
||||
| on-update:size | `(value: number) => void` | `undefined` | Callback fired on size changes. | NEXT_VERSION |
|
||||
|
@ -3,18 +3,22 @@
|
||||
</markdown>
|
||||
|
||||
<template>
|
||||
<n-input-number v-model:value="split" :step="0.1" clearable />
|
||||
<NSplit v-model:size="split" style="height: 200px">
|
||||
<template #1>
|
||||
<div style="width: 100%; background-color: black" />
|
||||
</template>
|
||||
<template #2>
|
||||
<div style="width: 100%; background-color: red" />
|
||||
</template>
|
||||
</NSplit>
|
||||
<n-flex vertical>
|
||||
<n-input-number v-model:value="split" :step="0.1" clearable />
|
||||
<NSplit v-model:size="split" style="height: 200px">
|
||||
<template #1>
|
||||
<div style="width: 100%; background-color: black" />
|
||||
</template>
|
||||
<template #2>
|
||||
<div style="width: 100%; background-color: red" />
|
||||
</template>
|
||||
</NSplit>
|
||||
</n-flex>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { NSplit, NInputNumber } from 'naive-ui'
|
||||
|
||||
const split = ref<number>(0.8)
|
||||
</script>
|
||||
|
@ -21,12 +21,12 @@ controlled.vue
|
||||
|
||||
| 名称 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| default-size | `number` | `0.5` | Split 的默认分割大小,0-1 代表百分比 | 2.36.0 |
|
||||
| size | `number` | `undefined` | Split 的受控分割大小,0-1 代表百分比 | NEXT_VERSION |
|
||||
| default-size | `number` | `0.5` | Split 的默认分割大小,0~1 代表百分比 | 2.36.0 |
|
||||
| size | `number` | `undefined` | Split 的受控分割大小,0~1 代表百分比 | NEXT_VERSION |
|
||||
| disabled | `boolean` | `false` | 是否禁用 | 2.36.0 |
|
||||
| direction | `'horizontal' \| 'vertical'` | `'horizontal'` | Split 的分割方向 | 2.36.0 |
|
||||
| min | `number` | `0` | Split 的分割最小阈值,0-1 代表百分比 | 2.36.0 |
|
||||
| max | `number` | `1` | Split 的分割最大阈值,0-1 代表百分比 | 2.36.0 |
|
||||
| min | `number` | `0` | Split 的分割最小阈值,0~1 代表百分比 | 2.36.0 |
|
||||
| max | `number` | `1` | Split 的分割最大阈值,0~1 代表百分比 | 2.36.0 |
|
||||
| resize-trigger-size | `number` | `3` | Split 的分隔条大小 | 2.36.0 |
|
||||
| watch-props | `Array<'defaultSize'>` | `undefined` | 需要检测变更的默认属性,检测后组件状态会更新。注意:`watch-props` 本身不是响应式的 | NEXT_VERSION |
|
||||
| on-update:size | `(value: number) => void` | `undefined` | 组件 size 属性变化时触发的回调 | NEXT_VERSION |
|
||||
|
Loading…
Reference in New Issue
Block a user