Skip to content

Commit

Permalink
chore(lib): update Timepicker
Browse files Browse the repository at this point in the history
- `Timepicker` migrates to Vue 3. Changes sufficient to render the
  documentation page of `Timepicker` are made.
- In `src/components/timepicker/Timepicker.vue`,
    - The condition to determine if a footer should be rendered is
      fixed. Because `$slots.default.length` test does not work on Vue 3.
    - `disabled` is replaced with a computed value `disabledOrUndefined`
      that takes `true` or `undefined`. This is introduced because
      setting a boolean attribute `false` does not remove it on Vue 3.
      `null` or `undefined` has to be given to remove it.
    - `value` binding of `b-input` is replaced with `model-value`.
    - Automatic ESLint fix is applied. The following minor errors are
      manually fixed,
        - `.native` is removed.
  • Loading branch information
kikuomax committed Jul 7, 2023
1 parent 8f4b353 commit f5026d6
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/components/timepicker/Timepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-if="!isMobile || inline"
ref="dropdown"
:position="position"
:disabled="disabled"
:disabled="disabledOrUndefined"
:inline="inline"
:mobile-modal="mobileModal"
:append-to-body="appendToBody"
Expand All @@ -16,14 +16,14 @@
<b-input
ref="input"
autocomplete="off"
:value="formatValue(computedValue)"
:model-value="formatValue(computedValue)"
:placeholder="placeholder"
:size="size"
:icon="icon"
:icon-pack="iconPack"
:loading="loading"
:disabled="disabled"
:readonly="!editable"
:disabled="disabledOrUndefined"
:readonly="!editable || undefined"
:rounded="rounded"
v-bind="$attrs"
:use-html5-validation="useHtml5Validation"
Expand All @@ -35,22 +35,22 @@
</template>

<b-dropdown-item
:disabled="disabled"
:disabled="disabledOrUndefined"
:focusable="focusable"
custom
>
<b-field grouped position="is-centered">
<b-select
v-model="hoursSelected"
@change="onHoursChange($event.target.value)"
:disabled="disabled"
:disabled="disabledOrUndefined"
placeholder="00"
>
<option
v-for="hour in hours"
:value="hour.value"
:key="hour.value"
:disabled="isHourDisabled(hour.value)"
:disabled="isHourDisabled(hour.value) || undefined"
>
{{ hour.label }}
</option>
Expand All @@ -59,14 +59,14 @@
<b-select
v-model="minutesSelected"
@change="onMinutesChange($event.target.value)"
:disabled="disabled"
:disabled="disabledOrUndefined"
placeholder="00"
>
<option
v-for="minute in minutes"
:value="minute.value"
:key="minute.value"
:disabled="isMinuteDisabled(minute.value)"
:disabled="isMinuteDisabled(minute.value) || undefined"
>
{{ minute.label }}
</option>
Expand All @@ -76,14 +76,14 @@
<b-select
v-model="secondsSelected"
@change="onSecondsChange($event.target.value)"
:disabled="disabled"
:disabled="disabledOrUndefined"
placeholder="00"
>
<option
v-for="second in seconds"
:value="second.value"
:key="second.value"
:disabled="isSecondDisabled(second.value)"
:disabled="isSecondDisabled(second.value) || undefined"
>
{{ second.label }}
</option>
Expand All @@ -94,7 +94,7 @@
v-model="meridienSelected"
@change="onMeridienChange($event.target.value)"
v-if="!isHourFormat24"
:disabled="disabled"
:disabled="disabledOrUndefined"
>
<option
v-for="meridien in meridiens"
Expand All @@ -107,7 +107,7 @@
</b-field>

<footer
v-if="$slots.default !== undefined && $slots.default.length"
v-if="$slots.default !== undefined"
class="timepicker-footer"
>
<slot />
Expand All @@ -121,7 +121,7 @@
type="time"
:step="nativeStep"
autocomplete="off"
:value="formatHHMMSS(computedValue)"
:model-value="formatHHMMSS(computedValue)"
:placeholder="placeholder"
:size="size"
:icon="icon"
Expand All @@ -130,7 +130,7 @@
:loading="loading"
:max="formatHHMMSS(maxTime)"
:min="formatHHMMSS(minTime)"
:disabled="disabled"
:disabled="disabledOrUndefined"
:readonly="false"
v-bind="$attrs"
:use-html5-validation="useHtml5Validation"
Expand Down

0 comments on commit f5026d6

Please sign in to comment.