mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
fix(ellipsis): fix ellipsis word (#337)
This commit is contained in:
parent
846c339d9b
commit
ba36861413
@ -1,6 +1,6 @@
|
||||
# Ellipsis with Tooltip
|
||||
|
||||
Set `column.ellipsis.tooltip` to make ellipsis have tooltip. `column.ellipsis` accepts the same props as `n-ellpisis`.
|
||||
Set `column.ellipsis.tooltip` to make ellipsis have tooltip. `column.ellipsis` accepts the same props as `n-ellipsis`.
|
||||
|
||||
```html
|
||||
<n-data-table
|
||||
|
@ -64,7 +64,7 @@ tree
|
||||
| single-line | `boolean` | `true` | Whether to display as a line (when true, each row has border-bottom). |
|
||||
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Table size. |
|
||||
| summary | `CreateSummary` | `undefined` | Data of table summary row. For types, see <n-a href="#CreateSummary-Type">CreateSummary Type</n-a>. |
|
||||
| table-layout | `'auto' \| 'fixed'` | `'auto'` | Style `table-layout` of the table. When `ellpisis` or `max-height` are set, it will always be `'fixed'` regardless of what you set. |
|
||||
| table-layout | `'auto' \| 'fixed'` | `'auto'` | Style `table-layout` of the table. When `ellipsis` or `max-height` are set, it will always be `'fixed'` regardless of what you set. |
|
||||
| virtual-scroll | `boolean` | `false` | Whether to use virtual scroll to deal with large data. Make sure `max-height` is set before using it. |
|
||||
| on-update:checked-row-keys | `(keys: Array<string \| number>) => void` | `undefined` | The callback function triggered when the checked-row-keys value changes. |
|
||||
| on-update:filters | `(filters: { [string \| number]: Array<string \| number> \| string \| number }, initiatorColumn: DataTableColumn)` | `undefined` | The callback function triggered when the filters data changes. |
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 带提示的省略
|
||||
|
||||
通过设定 `column.ellipsis.tooltip` 使得省略内容有弹出提示。`column.ellipsis` 接受的属性和 `n-ellpisis` 相同。
|
||||
通过设定 `column.ellipsis.tooltip` 使得省略内容有弹出提示。`column.ellipsis` 接受的属性和 `n-ellipsis` 相同。
|
||||
|
||||
```html
|
||||
<n-data-table
|
||||
|
@ -64,7 +64,7 @@ tree
|
||||
| single-line | `boolean` | `true` | 是否展示为一行(true 时每一行都有 border-bottom) |
|
||||
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | 表格的尺寸 |
|
||||
| summary | `CreateSummary` | `undefined` | 表格总结栏的数据,类型见 <n-a href="#CreateSummary-Type">CreateSummary Type</n-a> |
|
||||
| table-layout | `'auto' \| 'fixed'` | `'auto'` | 表格的 `table-layout` 样式属性,在设定 `ellpisis` 或 `max-height` 的情况下固定为 `'fixed'` |
|
||||
| table-layout | `'auto' \| 'fixed'` | `'auto'` | 表格的 `table-layout` 样式属性,在设定 `ellipsis` 或 `max-height` 的情况下固定为 `'fixed'` |
|
||||
| virtual-scroll | `boolean` | `false` | 是否开启虚拟滚动,应对大规模数据,开启前请设定好 `max-height` |
|
||||
| on-update:checked-row-keys | `(keys: Array<string \| number>) => void` | `undefined` | checked-row-keys 值改变时触发的回调函数 |
|
||||
| on-update:filters | `(filters: { [string \| number]: Array<string \| number> \| string \| number }, initiatorColumn: DataTableColumn)` | `undefined` | filters 数据改变时触发的回调函数 |
|
||||
|
@ -460,7 +460,7 @@ export default defineComponent({
|
||||
{
|
||||
[`${mergedClsPrefix}-data-table-td--ellipsis`]:
|
||||
ellipsis === true ||
|
||||
// don't add ellpisis class if tooltip exists
|
||||
// don't add ellipsis class if tooltip exists
|
||||
(ellipsis && !ellipsis.tooltip),
|
||||
[`${mergedClsPrefix}-data-table-td--selection`]:
|
||||
column.type === 'selection',
|
||||
|
@ -10,10 +10,10 @@ import type { EllipsisTheme } from '../styles'
|
||||
import style from './styles/index.cssr'
|
||||
|
||||
function createLineClampClass (clsPrefix: string): string {
|
||||
return `${clsPrefix}-ellpisis--line-clamp`
|
||||
return `${clsPrefix}-ellipsis--line-clamp`
|
||||
}
|
||||
|
||||
const ellpisisProps = {
|
||||
const ellipsisProps = {
|
||||
...(useTheme.props as ThemeProps<EllipsisTheme>),
|
||||
expandTrigger: String as PropType<'click'>,
|
||||
lineClamp: [Number, String] as PropType<string | number>,
|
||||
@ -23,12 +23,12 @@ const ellpisisProps = {
|
||||
}
|
||||
} as const
|
||||
|
||||
export type EllipsisProps = ExtractPublicPropTypes<typeof ellpisisProps>
|
||||
export type EllipsisProps = ExtractPublicPropTypes<typeof ellipsisProps>
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Ellipsis',
|
||||
inheritAttrs: false,
|
||||
props: ellpisisProps,
|
||||
props: ellipsisProps,
|
||||
setup (props, { slots, attrs }) {
|
||||
const { mergedClsPrefixRef } = useConfig(props)
|
||||
const mergedTheme = useTheme(
|
||||
@ -42,7 +42,7 @@ export default defineComponent({
|
||||
const triggerRef = ref<HTMLElement | null>(null)
|
||||
const tooltipRef = ref<TooltipInst | null>(null)
|
||||
const expandedRef = ref(false)
|
||||
const ellpisisStyleRef = computed(() => {
|
||||
const ellipsisStyleRef = computed(() => {
|
||||
const { lineClamp } = props
|
||||
const { value: expanded } = expandedRef
|
||||
const cursor = props.expandTrigger === 'click' ? 'pointer' : ''
|
||||
@ -91,12 +91,12 @@ export default defineComponent({
|
||||
<span
|
||||
{...mergeProps(attrs, {
|
||||
class: [
|
||||
`${mergedClsPrefixRef.value}-ellpisis`,
|
||||
`${mergedClsPrefixRef.value}-ellipsis`,
|
||||
props.lineClamp !== undefined
|
||||
? createLineClampClass(mergedClsPrefixRef.value)
|
||||
: undefined
|
||||
],
|
||||
style: ellpisisStyleRef.value
|
||||
style: ellipsisStyleRef.value
|
||||
})}
|
||||
ref="triggerRef"
|
||||
onClick={handleClickRef.value}
|
||||
@ -106,7 +106,7 @@ export default defineComponent({
|
||||
)
|
||||
function syncEllipsisStyle (trigger: HTMLElement): void {
|
||||
if (!trigger) return
|
||||
const latestStyle = ellpisisStyleRef.value
|
||||
const latestStyle = ellipsisStyleRef.value
|
||||
const lineClampClass = createLineClampClass(mergedClsPrefixRef.value)
|
||||
if (props.lineClamp !== undefined) {
|
||||
if (!trigger.classList.contains(lineClampClass)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { cB, cNotM, cM } from '../../../_utils/cssr'
|
||||
|
||||
export default cB('ellpisis', {
|
||||
export default cB('ellipsis', {
|
||||
overflow: 'hidden'
|
||||
}, [
|
||||
cNotM('line-clamp', `
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Long Label
|
||||
|
||||
Set `label` to render function that renders `n-ellpisis`.
|
||||
Set `label` to render function that renders `n-ellipsis`.
|
||||
|
||||
```html
|
||||
<n-menu :options="options" style="width: 180px;" default-value="1" />
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 菜单内容很长
|
||||
|
||||
将 `label` 设为渲染函数,结合 `n-ellpisis`。
|
||||
将 `label` 设为渲染函数,结合 `n-ellipsis`。
|
||||
|
||||
```html
|
||||
<n-menu :options="options" style="width: 180px;" default-value="1" />
|
||||
|
Loading…
Reference in New Issue
Block a user