[improvement] rename packages dir to src (#3659)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-contact-list {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
padding-bottom: 50px;
|
||||
|
||||
&__item {
|
||||
padding: @contact-list-item-padding;
|
||||
}
|
||||
|
||||
&__item-value {
|
||||
padding-right: 34px;
|
||||
}
|
||||
|
||||
&__group {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
&__edit {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 15px;
|
||||
font-size: @contact-list-edit-icon-size;
|
||||
transform: translate(0, -50%);
|
||||
}
|
||||
|
||||
&__add {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: @contact-list-add-button-z-index;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { createNamespace } from '../utils';
|
||||
import { RED } from '../utils/color';
|
||||
import { emit, inherit } from '../utils/functional';
|
||||
import Icon from '../icon';
|
||||
import Cell from '../cell';
|
||||
import Button from '../button';
|
||||
import Radio from '../radio';
|
||||
import RadioGroup from '../radio-group';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/types';
|
||||
|
||||
export type ContactListItem = {
|
||||
id: string | number;
|
||||
tel: string | number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type ContactListProps = {
|
||||
value?: any;
|
||||
list: ContactListItem[];
|
||||
addText?: string;
|
||||
};
|
||||
|
||||
const [createComponent, bem, t] = createNamespace('contact-list');
|
||||
|
||||
function ContactList(
|
||||
h: CreateElement,
|
||||
props: ContactListProps,
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext<ContactListProps>
|
||||
) {
|
||||
const List = props.list.map((item, index) => {
|
||||
const onClick = () => {
|
||||
emit(ctx, 'input', item.id);
|
||||
emit(ctx, 'select', item, index);
|
||||
};
|
||||
|
||||
return (
|
||||
<Cell
|
||||
key={item.id}
|
||||
isLink
|
||||
class={bem('item')}
|
||||
valueClass={bem('item-value')}
|
||||
scopedSlots={{
|
||||
default: () => (
|
||||
<Radio name={item.id} iconSize={16} checkedColor={RED} onClick={onClick}>
|
||||
<div class={bem('name')}>{`${item.name},${item.tel}`}</div>
|
||||
</Radio>
|
||||
),
|
||||
'right-icon': () => (
|
||||
<Icon
|
||||
name="edit"
|
||||
class={bem('edit')}
|
||||
onClick={event => {
|
||||
event.stopPropagation();
|
||||
emit(ctx, 'edit', item, index);
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
onClick={onClick}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<div class={bem()} {...inherit(ctx)}>
|
||||
<RadioGroup value={props.value} class={bem('group')}>
|
||||
{List}
|
||||
</RadioGroup>
|
||||
<Button
|
||||
square
|
||||
size="large"
|
||||
type="danger"
|
||||
class={bem('add')}
|
||||
text={props.addText || t('addText')}
|
||||
onClick={() => {
|
||||
emit(ctx, 'add');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
ContactList.props = {
|
||||
value: null as any,
|
||||
list: Array,
|
||||
addText: String
|
||||
};
|
||||
|
||||
export default createComponent(ContactList);
|
||||
Reference in New Issue
Block a user