-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branches 'next' and 'next' of https://github.com/vueComponent/a…
…nt-design-vue into next
- Loading branch information
Showing
12 changed files
with
555 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { VNodeTypes, HTMLAttributes, FunctionalComponent } from 'vue'; | ||
|
||
function notEmpty(val: any) { | ||
return val !== undefined && val !== null; | ||
} | ||
|
||
interface CellProps extends HTMLAttributes { | ||
itemPrefixCls: string; | ||
span: number; | ||
component: string; | ||
bordered?: boolean; | ||
label?: VNodeTypes; | ||
content?: VNodeTypes; | ||
colon?: boolean; | ||
} | ||
|
||
const Cell: FunctionalComponent<CellProps> = props => { | ||
const { itemPrefixCls, component, span, bordered, label, content, colon } = props; | ||
const Component = component as any; | ||
if (bordered) { | ||
return ( | ||
<Component | ||
class={[ | ||
{ | ||
[`${itemPrefixCls}-item-label`]: notEmpty(label), | ||
[`${itemPrefixCls}-item-content`]: notEmpty(content), | ||
}, | ||
]} | ||
colSpan={span} | ||
> | ||
{notEmpty(label) ? label : content} | ||
</Component> | ||
); | ||
} | ||
|
||
return ( | ||
<Component class={[`${itemPrefixCls}-item`]} colSpan={span}> | ||
{label && ( | ||
<span | ||
class={[ | ||
`${itemPrefixCls}-item-label`, | ||
{ | ||
[`${itemPrefixCls}-item-no-colon`]: !colon, | ||
}, | ||
]} | ||
> | ||
{label} | ||
</span> | ||
)} | ||
{content && <span class={`${itemPrefixCls}-item-content`}>{content}</span>} | ||
</Component> | ||
); | ||
}; | ||
|
||
export default Cell; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import Cell from './Cell'; | ||
import { getOptionProps, getSlot, getClass, getStyle, getComponent } from '../_util/props-util'; | ||
import { FunctionalComponent } from 'vue'; | ||
|
||
interface CellConfig { | ||
component: string | [string, string]; | ||
type: string; | ||
showLabel?: boolean; | ||
showContent?: boolean; | ||
} | ||
|
||
export interface RowProps { | ||
prefixCls: string; | ||
vertical: boolean; | ||
row: any[]; | ||
bordered: boolean; | ||
colon: boolean; | ||
index: number; | ||
} | ||
|
||
const Row: FunctionalComponent<RowProps> = props => { | ||
const renderCells = ( | ||
items, | ||
{ colon, prefixCls, bordered }, | ||
{ component, type, showLabel, showContent }: CellConfig, | ||
) => { | ||
return items.map((item, index) => { | ||
const { prefixCls: itemPrefixCls = prefixCls, span = 1 } = getOptionProps(item); | ||
const label = getComponent(item, 'label'); | ||
|
||
const children = getSlot(item); | ||
const className = getClass(item); | ||
const style = getStyle(item); | ||
const { key } = item; | ||
|
||
if (typeof component === 'string') { | ||
return ( | ||
<Cell | ||
key={`${type}-${key || index}`} | ||
class={className} | ||
style={style} | ||
span={span} | ||
colon={colon} | ||
component={component} | ||
itemPrefixCls={itemPrefixCls} | ||
bordered={bordered} | ||
label={showLabel ? label : null} | ||
content={showContent ? children : null} | ||
/> | ||
); | ||
} | ||
|
||
return [ | ||
<Cell | ||
key={`label-${key || index}`} | ||
class={className} | ||
style={style} | ||
span={1} | ||
colon={colon} | ||
component={component[0]} | ||
itemPrefixCls={itemPrefixCls} | ||
bordered={bordered} | ||
label={label} | ||
/>, | ||
<Cell | ||
key={`content-${key || index}`} | ||
class={className} | ||
style={style} | ||
span={span * 2 - 1} | ||
component={component[1]} | ||
itemPrefixCls={itemPrefixCls} | ||
bordered={bordered} | ||
content={children} | ||
/>, | ||
]; | ||
}); | ||
}; | ||
|
||
const { prefixCls, vertical, row, index, bordered } = props; | ||
if (vertical) { | ||
return ( | ||
<> | ||
<tr key={`label-${index}`} class={`${prefixCls}-row`}> | ||
{renderCells(row, props, { component: 'th', type: 'label', showLabel: true })} | ||
</tr> | ||
<tr key={`content-${index}`} class={`${prefixCls}-row`}> | ||
{renderCells(row, props, { | ||
component: 'td', | ||
type: 'content', | ||
showContent: true, | ||
})} | ||
</tr> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<tr key={index} class={`${prefixCls}-row`}> | ||
{renderCells(row, props, { | ||
component: bordered ? ['th', 'td'] : 'td', | ||
type: 'item', | ||
showLabel: true, | ||
showContent: true, | ||
})} | ||
</tr> | ||
); | ||
}; | ||
|
||
export default Row; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.