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

Perf: Optimize datepicker panel sidebar slots #22842

Closed
Closed
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
1 change: 1 addition & 0 deletions examples/docs/en-US/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,4 @@ When picking a date range, you can assign the time part for start date and end d
| Name | Description |
|---------|-------------|
| range-separator | custom range separator content |
| sidebar | Date panel side slot |
1 change: 1 addition & 0 deletions examples/docs/es/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,4 @@ Al seleccionar un intervalo de fechas, puede asignar la hora para la fecha de in
| Nombre | Descripción |
| --------------- | ------------------------------------- |
| range-separator | Separador de los rangos personalizado |
| sidebar | Ranura lateral del panel de fecha |
1 change: 1 addition & 0 deletions examples/docs/fr-FR/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,4 @@ Lorsque vous choisissez une plage de dates, vous pouvez assigner l'horaire de d
| Nom | Description |
|---------|-------------|
| range-separator | Séparateur d'intervalle personnalisé. |
| sidebar | Fentes latérales du panneau de date |
6 changes: 6 additions & 0 deletions examples/docs/zh-CN/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,9 @@
| 方法名 | 说明 | 参数 |
| ---- | ---- | ---- |
| focus | 使 input 获取焦点 | — |

### Slot
| name | 说明 |
|------|--------|
| range-separator | 区间分隔符插槽 |
| sidebar | 日期面板侧边插槽 |
20 changes: 12 additions & 8 deletions packages/date-picker/src/panel/date-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
'has-time': showTime
}, popperClass]">
<div class="el-picker-panel__body-wrapper">
<slot name="sidebar" class="el-picker-panel__sidebar"></slot>
<div class="el-picker-panel__sidebar" v-if="shortcuts">
<button
type="button"
class="el-picker-panel__shortcut"
v-for="(shortcut, key) in shortcuts"
:key="key"
@click="handleShortcutClick(shortcut)">{{shortcut.text}}</button>
<div class="el-picker-panel__sidebar">
<template v-if="shortcuts">
<button
type="button"
class="el-picker-panel__shortcut"
v-for="(shortcut, key) in shortcuts"
:key="key"
@click="handleShortcutClick(shortcut)">{{shortcut.text}}</button>
</template>
<template v-if="$slots.sidebar">
<slot name="sidebar"></slot>
</template>
</div>
<div class="el-picker-panel__body">
<div class="el-date-range-picker__time-header" v-if="showTime">
Expand Down
20 changes: 12 additions & 8 deletions packages/date-picker/src/panel/date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
'has-time': showTime
}, popperClass]">
<div class="el-picker-panel__body-wrapper">
<slot name="sidebar" class="el-picker-panel__sidebar"></slot>
<div class="el-picker-panel__sidebar" v-if="shortcuts">
<button
type="button"
class="el-picker-panel__shortcut"
v-for="(shortcut, key) in shortcuts"
:key="key"
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</button>
<div class="el-picker-panel__sidebar">
<template v-if="shortcuts">
<button
type="button"
class="el-picker-panel__shortcut"
v-for="(shortcut, key) in shortcuts"
:key="key"
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</button>
</template>
<template v-if="$slots.sidebar">
<slot name="sidebar"></slot>
</template>
</div>
<div class="el-picker-panel__body">
<div class="el-date-picker__time-header" v-if="showTime">
Expand Down
20 changes: 12 additions & 8 deletions packages/date-picker/src/panel/month-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
'has-sidebar': $slots.sidebar || shortcuts
}, popperClass]">
<div class="el-picker-panel__body-wrapper">
<slot name="sidebar" class="el-picker-panel__sidebar"></slot>
<div class="el-picker-panel__sidebar" v-if="shortcuts">
<button
type="button"
class="el-picker-panel__shortcut"
v-for="(shortcut, key) in shortcuts"
:key="key"
@click="handleShortcutClick(shortcut)">{{shortcut.text}}</button>
<div class="el-picker-panel__sidebar">
<template v-if="shortcuts">
<button
type="button"
class="el-picker-panel__shortcut"
v-for="(shortcut, key) in shortcuts"
:key="key"
@click="handleShortcutClick(shortcut)">{{shortcut.text}}</button>
</template>
<template v-if="$slots.sidebar">
<slot name="sidebar"></slot>
</template>
</div>
<div class="el-picker-panel__body">
<div class="el-picker-panel__content el-date-range-picker__content is-left">
Expand Down
Loading