Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/area date time calendar placeholder #272

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/area/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ namespace nasl.ui {
}
})
disabled: nasl.core.Boolean = false;
@Prop({
group: '主要属性',
title: '占位提示',
description: '',
setter: {
concept: "InputSetter"
}
})
placeholder: nasl.core.String;
@Event({
title: '点击右上方完成按钮',
description: '点击右上方完成按钮'
Expand Down
5 changes: 5 additions & 0 deletions src/area/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
default: false
group: 状态属性
description: 置灰显示,且禁止任何交互(焦点、点击、选择、输入等)
- name: placeholder
title: 占位提示
type: string
group: 主要属性
description: ""
slots:
- concept: Slot
name: default
Expand Down
5 changes: 5 additions & 0 deletions src/area/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
</van-area>
</demo-block>

<demo-block card title="占位符">
<van-area placeholder="请选择">
<template #title>标题</template>
</van-area>
</demo-block>
</demo-section>
</template>

Expand Down
4 changes: 4 additions & 0 deletions src/area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export default createComponent({
type: String,
default: 'json',
},
placeholder: {
type: String,
},
labelField: {
type: String,
default: '',
Expand Down Expand Up @@ -615,6 +618,7 @@ export default createComponent({
scopedSlots={tempSlot}
readonly
disabled={this.disabled}
placeholder={this.placeholder}
isLink
input-align={this.inputAlign || 'right'}
onClick={this.inDesigner() ? this.designerOpen : this.onClickField}
Expand Down
10 changes: 10 additions & 0 deletions src/area/test/__snapshots__/demo.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,15 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
</div>
<div>
<div vusion-click-enabled="true" class="van-area__wrappparea">
<div label-layout="inline" noallow="" class="van-cellson van-cellson--center van-cellson--insel van-field">
<div vusion-slot-name="title" class="van-cellson__title van-field__label van-field__labelhasslots">标题</div>
<div class="van-cellson__value van-field__value">
<div class="van-field__body"><input type="text" readonly="readonly" placeholder="请选择" class="van-field__control van-field__control--right"></div>
</div>
</div>
</div>
</div>
</div>
`;
9 changes: 9 additions & 0 deletions src/calendar/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ namespace nasl.ui {
}
})
disabled: nasl.core.Boolean = false;
@Prop({
group: '主要属性',
title: '占位提示',
description: '',
setter: {
concept: "InputSetter"
}
})
placeholder: nasl.core.String;
@Event({
title: '确认',
description: '点击完成按钮时触发的事件'
Expand Down
5 changes: 5 additions & 0 deletions src/calendar/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
default: false
description: 置灰显示,且禁止任何交互(焦点、点击、选择、输入等)
group: 状态属性
- name: placeholder
title: 占位提示
type: string
group: 主要属性
description: ""
slots:
- concept: Slot
name: default
Expand Down
12 changes: 12 additions & 0 deletions src/calendar/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
></van-calendar>
</van-cell>
</demo-block>

<demo-block title="占位符">
<van-cell>
<template #title>
<span>日期选择</span>
</template>
<van-calendar
title="选择日期"
placeholder="请选择日期"
></van-calendar>
</van-cell>
</demo-block>
</demo-section>
</template>

Expand Down
16 changes: 13 additions & 3 deletions src/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export default createComponent({
rowHeight: [Number, String],
confirmText: String,
rangePrompt: String,
placeholder: {
type: String,
},
labelField: {
type: String,
default: '',
Expand Down Expand Up @@ -286,7 +289,9 @@ export default createComponent({
this.currentValue = val;

const date = dayjs(this.currentValue);
const value = date.isValid() ? date.format('YYYY-MM-DD') : this.currentValue;
const value = date.isValid()
? date.format('YYYY-MM-DD')
: this.currentValue;
this.$emit('update:value', value);
this.$emit('update:default-date', value);
},
Expand All @@ -307,7 +312,9 @@ export default createComponent({
this.currentValue = val;

const date = dayjs(this.currentValue);
const value = date.isValid() ? date.format('YYYY-MM-DD') : this.currentValue;
const value = date.isValid()
? date.format('YYYY-MM-DD')
: this.currentValue;
this.$emit('update:value', value);
this.$emit('update:default-date', value);
this.scrollIntoView();
Expand Down Expand Up @@ -455,7 +462,9 @@ export default createComponent({
this.currentValue = this.currentDate;

const date = dayjs(this.currentValue);
const value = date.isValid() ? date.format('YYYY-MM-DD') : this.currentValue;
const value = date.isValid()
? date.format('YYYY-MM-DD')
: this.currentValue;
this.$emit('update:value', value);
this.$emit('update:default-date', value);

Expand Down Expand Up @@ -634,6 +643,7 @@ export default createComponent({
scopedSlots={tempSlot}
readonly
disabled={this.disabled}
placeholder={this.placeholder}
isLink
input-align={this.inputAlign || 'right'}
onClick={this.inDesigner() ? this.designerOpen : this.togglePopup}
Expand Down
15 changes: 15 additions & 0 deletions src/calendar/test/__snapshots__/demo.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,20 @@ exports[`renders demo correctly 1`] = `
<van-icon name="arrow" class="van-cell__right-icon"></van-icon>
</div>
</div>
<div>
<div noallow="" role="button" tabindex="0" class="van-cell van-cell--clickable van-cell--center">
<div vusion-slot-name="title" vusion-slot-name-edit="title" class="van-cell__title"><span>日期选择</span></div>
<div class="van-cell__value">
<div vusion-click-enabled="true" class="van-calendar__wrapppcalendar">
<div label-layout="inline" noallow="" class="van-cellson van-cellson--center van-cellson--insel van-field">
<div class="van-cellson__value van-field__value">
<div class="van-field__body"><input type="text" readonly="readonly" placeholder="请选择日期" class="van-field__control van-field__control--right"></div>
</div>
</div>
</div>
</div>
<van-icon name="arrow" class="van-cell__right-icon"></van-icon>
</div>
</div>
</div>
`;
9 changes: 9 additions & 0 deletions src/datetime-picker/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ namespace nasl.ui {
}
})
disabled: nasl.core.Boolean = false;
@Prop({
group: '主要属性',
title: '占位提示',
description: '',
setter: {
concept: "InputSetter"
}
})
placeholder: nasl.core.String;
@Event({
title: '确认',
description: '点击完成按钮时触发的事件'
Expand Down
5 changes: 5 additions & 0 deletions src/datetime-picker/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@
default: false
description: 置灰显示,且禁止任何交互(焦点、点击、选择、输入等)
group: 状态属性
- name: placeholder
title: 占位提示
type: string
group: 主要属性
description: ""
slots:
- concept: Slot
name: default
Expand Down
4 changes: 2 additions & 2 deletions src/datetime-picker/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
<van-datetime-picker :value.sync="value.secondTime" type="time" unit="second" :title="t('timeType')" />
</demo-block>

<demo-block card title="临时测试">
<van-datetime-picker :close-on-click-overlay="true" type="date" />
<demo-block card title="占位符">
<van-datetime-picker :close-on-click-overlay="true" type="date" placeholder="请选择日期时间" />
</demo-block>
</demo-section>
</template>
Expand Down
4 changes: 3 additions & 1 deletion src/datetime-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default createComponent({
},
inputAlign: String,
closeOnClickOverlay: Boolean,
placeholder: String,
placeholder: {
type: String,
},
range: Boolean,
startValue: String,
endValue: String,
Expand Down
2 changes: 1 addition & 1 deletion src/datetime-picker/test/__snapshots__/demo.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ exports[`renders demo correctly 1`] = `
<div vusion-click-enabled="true" class="van-datetime-picker__wrapppdtpicker">
<div label-layout="inline" noallow="" class="van-cellson van-cellson--center van-cellson--insel van-field">
<div class="van-cellson__value van-field__value">
<div class="van-field__body"><input type="text" readonly="readonly" class="van-field__control van-field__control--right"></div>
<div class="van-field__body"><input type="text" readonly="readonly" placeholder="请选择日期时间" class="van-field__control van-field__control--right"></div>
</div>
</div>
</div>
Expand Down
Loading