时间日期组件添加失去焦点关闭事件

This commit is contained in:
KeiferJu 2020-03-24 09:45:37 +08:00
parent 63bb497eb0
commit 813b4f9738
2 changed files with 18 additions and 7 deletions

View File

@ -138,6 +138,10 @@
date = e.detail.timeStamp
dispatch('dateChecked', e.detail)
}
function windowClick(){
visible = false;
}
</script>
<style>
@ -202,13 +206,14 @@
box-shadow: none !important;
} */
</style>
<svelte:window on:click={windowClick}></svelte:window>
<div style="width: {width};position: relative">
{#if !calendar}
{#if pickerRule === 'rangeChoice'}
<div
style="position: relative;margin: 5px 0 0 0;"
on:click={() => {
on:click={(e) => {
e.stopPropagation()
visible = !visible
}}>
<Input type="text" class={inputClass} bind:value={rangePickerResult} readonly iconPack="fa" icon="{icon? 'calendar': ''}" />
@ -216,7 +221,8 @@
{:else}
<div
style="position: relative;margin: 5px 0 0 0;"
on:click={() => {
on:click={(e) => {
e.stopPropagation()
visible = !visible
}}>
<Input type="text" class={inputClass} bind:value={pickerResult} readonly iconPack="fa" icon="{icon? 'calendar': ''}" />
@ -225,7 +231,7 @@
{/if}
{/if}
{#if visible || calendar}
<div class={'calendar_' + theme} style="left: {left}">
<div class={'calendar_' + theme} style="left: {left}" on:click={(e)=>e.stopPropagation()}>
<Selector />
{#if $view === 'y'}
<YearView />

View File

@ -132,6 +132,10 @@
}
dispatch('timeChecked', data)
}
function windowClick(){
visible = false;
}
</script>
<style>
@ -199,9 +203,10 @@
line-height: 40px;
} */
</style>
<svelte:window on:click={windowClick}></svelte:window>
<div style="width: {width};position: relative">
<div style="position: relative" on:click={() => {
<div style="position: relative" on:click={(e) => {
e.stopPropagation()
visible = !visible
}} >
<!-- <input
@ -216,7 +221,7 @@
<Input type="text" class={inputClass} bind:value={_time} readonly iconPack="fa" icon="{icon? 'clock': ''}" />
</div>
{#if visible}
<div class="touch-time-wrapper" style="left: {left}">
<div class="touch-time-wrapper" style="left: {left}" on:click={(e)=>e.stopPropagation()}>
<div class="touch-time">{_time}</div>
<div class="touch-time-picker">
<Switcher type="hours" data={HOURS} selected={selectedHour} on:timeChange={timeChanged} } {hour12} />