v2.15.0

InputTime

Поле ввода для выбора времени.

Использование

Директива v-model управляет выбранным временем.

12
30
<script setup lang="ts">
import { Time } from '@internationalized/date'

const value = shallowRef(new Time(12, 30, 0))
</script>

<template>
  <B24InputTime v-model="value" />
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
import { Time } from '@internationalized/date'

const value = shallowRef(new Time(12, 30, 0))
</script>

<template>
  <B24InputTime v-model="value" />
</template>

Пропс default-value задаёт начальное значение, когда управлять состоянием не нужно.

09
45
<script setup lang="ts">
import { Time } from '@internationalized/date'

const defaultValue = shallowRef(new Time(9, 45, 0))
</script>

<template>
  <B24InputTime :default-value="defaultValue" />
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
import { Time } from '@internationalized/date'

const defaultValue = shallowRef(new Time(9, 45, 0))
</script>

<template>
  <B24InputTime :default-value="defaultValue" />
</template>
Компонент использует пакет @internationalized/date для форматирования с учётом локали. Формат времени определяется пропсом locale компонента App.
Компонент использует пакет @internationalized/date для форматирования с учётом локали. Формат времени определяется пропсом locale компонента App.

Диапазон

Пропс range включает выбор диапазона времени с началом и концом.

09
00
17
30
<script setup lang="ts">
import { Time } from '@internationalized/date'

const value = ref({ start: new Time(9, 0, 0), end: new Time(17, 30, 0) })
</script>

<template>
  <B24InputTime range v-model="value" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { Time } from '@internationalized/date'

const value = ref({ start: new Time(9, 0, 0), end: new Time(17, 30, 0) })
</script>

<template>
  <B24InputTime range v-model="value" />
</template>

Формат часов

Пропс hour-cycle меняет формат часов InputTime. По умолчанию 12.

16
30
<script setup lang="ts">
import { Time } from '@internationalized/date'

const defaultValue = shallowRef(new Time(16, 30, 0))
</script>

<template>
  <B24InputTime :hour-cycle="24" :default-value="defaultValue" />
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
import { Time } from '@internationalized/date'

const defaultValue = shallowRef(new Time(16, 30, 0))
</script>

<template>
  <B24InputTime :hour-cycle="24" :default-value="defaultValue" />
</template>

Цвет

Пропс color меняет цвет InputTime.

––
––
<template>
  <B24InputTime color="air-primary" highlight />
</template>
Пропс highlight здесь показывает состояние фокуса. Внутри компонента он включается при ошибке валидации.

Тег

Свойство tag показывает Badge поверх InputTime.

заметка
––
––
<template>
  <B24InputTime tag="заметка" color="air-primary" highlight />
</template>

Свойство tagColor задаёт цвет Badge.

заметка
––
––
<script setup lang="ts">
const value = ref(undefined)
</script>

<template>
  <B24InputTime tag="заметка" tag-color="air-secondary-alert" color="air-primary" highlight />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const value = ref(undefined)
</script>

<template>
  <B24InputTime tag="заметка" tag-color="air-secondary-alert" color="air-primary" highlight />
</template>

Размер

Пропс size меняет размер InputTime.

––
––
<template>
  <B24InputTime size="xl" />
</template>

Иконка

Пропс icon показывает иконку внутри InputTime.

––
––
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24InputTime :icon="RocketIcon" />
</template>

Иконка разделителя

Пропс separator-icon меняет иконку разделителя диапазона.

––
––
––
––
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24InputTime range :separator-icon="RocketIcon" />
</template>

Аватар

Пропс avatar показывает Avatar внутри InputTime.

––
––
<template>
  <B24InputTime
    :avatar="{
      src: '/b24ui/avatar/employee.png',
      loading: 'lazy'
    }"
    size="md"
  />
</template>

Загрузка

Пропс loading показывает иконку загрузки в InputTime.

––
––
<template>
  <B24InputTime loading />
</template>

Отключение

Пропс disabled отключает InputTime.

––
––
<template>
  <B24InputTime disabled />
</template>

Без отступов

Пропс noPadding убирает отступы у InputTime.

––
––
<template>
  <B24InputTime no-padding highlight />
</template>
Пропс highlight здесь показывает состояние фокуса.

Без границы

Пропс noBorder убирает у InputTime все границы (кольца).

––
––
<template>
  <B24InputTime no-border highlight />
</template>
Пропс highlight здесь показывает, что состояния фокуса нет.

Подчёркивание

Пропс underline убирает у InputTime все границы (кольца), кроме нижней.

––
––
<template>
  <B24InputTime underline highlight />
</template>
Пропс highlight здесь показывает состояние фокуса.

Скругление

Пропс rounded скругляет InputTime.

––
––
<template>
  <B24InputTime rounded highlight />
</template>
Пропс highlight здесь показывает состояние фокуса.

Примеры

Внутри FormField

InputTime можно использовать внутри компонента FormField, чтобы показывать подпись, справочный текст, признак обязательности и так далее.

12
30
Укажите время
<script setup lang="ts">
import { Time } from '@internationalized/date'

const time = shallowRef(new Time(12, 30, 0))
</script>

<template>
  <B24FormField label="Время" help="Укажите время" required>
    <B24InputTime v-model="time" />
  </B24FormField>
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
import { Time } from '@internationalized/date'

const time = shallowRef(new Time(12, 30, 0))
</script>

<template>
  <B24FormField label="Время" help="Укажите время" required>
    <B24InputTime v-model="time" />
  </B24FormField>
</template>

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

color'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot"
size'md' "xss" | "xs" | "sm" | "md" | "lg" | "xl"
noPaddingfalseboolean

Removes padding from input

noBorderfalseboolean

Removes all borders (rings)

underlinefalseboolean

Removes all borders (rings) except the bottom one

roundedfalseboolean

Rounds the corners of the input

tag string
tagColor'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-tertiary" | "air-selection"
highlightboolean

Highlight the ring color like a focus state.

fixedboolean

Keep the mobile text size on all breakpoints. (Left for backward compatibility.)

autofocusboolean
autofocusDelay0 number
separatorIconicons.minusIconComponent

The icon to use as a range separator.

rangefalse R

Enable time range selection.

defaultValueTime | CalendarDateTime | ZonedDateTime
modelValuenull | Time | CalendarDateTime | ZonedDateTime
iconIconComponent

Display an icon on the left side.

avatar AvatarProps

Display an avatar on the left side.

loadingboolean

When true, the loading icon will be displayed.

trailingboolean

When true, the icon will be displayed on the right side.

trailingIconIconComponent

Display an icon on the right side.

defaultPlaceholderTime | CalendarDateTime | ZonedDateTime
placeholderTime | CalendarDateTime | ZonedDateTime
hourCycle 12 | 24

The hour cycle used for formatting times. Defaults to the local preference

step DateStep

The stepping interval for the time fields. Defaults to 1.

stepSnappingboolean

Whether to enforce snapping the value to the nearest step increment after input. Defaults to false.

granularity "hour" | "minute" | "second"

The granularity to use for formatting times. Defaults to minute if a Time is provided, otherwise defaults to minute. The field will render segments for each part of the date up to and including the specified granularity

hideTimeZoneboolean

Whether or not to hide the time zone segment of the field

maxValueTime | CalendarDateTime | ZonedDateTime
minValueTime | CalendarDateTime | ZonedDateTime
locale string

The locale to use for formatting dates

disabledboolean

Whether or not the time field is disabled

readonlyboolean

Whether or not the time field is readonly

id string

Id of the element

name string

The name of the field. Submitted with its owning form as part of a name/value pair.

requiredboolean

When true, indicates that the user must set the value before the owning form can be submitted.

isTimeUnavailable (date: DateValue): boolean

A function that returns whether or not a time is unavailable

b24ui { base?: SlotClass; leading?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailing?: SlotClass; trailingIcon?: SlotClass; tag?: SlotClass; segment?: SlotClass; separatorIcon?: SlotClass; }

Слоты

Slot Type
leading{ b24ui: object; }
default{ b24ui: object; }
trailing{ b24ui: object; }
separator{ b24ui: object; }

События

Event Type
update:modelValue[value: InputTimeModelValue<R>]
update:placeholder[date: TimeValue] & [date: TimeValue]
change[event: Event]
blur[event: FocusEvent]
focus[event: FocusEvent]

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/input-time.ts
export default {
  slots: {
    base: 'group relative inline-flex items-center select-none transition-colors style-blurred-bg-input',
    leading: 'absolute inset-y-0 start-0 flex items-center',
    leadingIcon: 'shrink-0 text-(--b24ui-icon-color)',
    leadingAvatar: 'shrink-0',
    leadingAvatarSize: '',
    trailing: 'absolute inset-y-0 end-0 flex items-center',
    trailingIcon: 'shrink-0 text-(--b24ui-icon-color)',
    tag: 'pointer-events-none select-none absolute z-10 -top-[7px] right-[14px] flex flex-col justify-center items-center',
    segment: 'rounded-2xs text-center outline-hidden text-(--ui-color-base-1) data-placeholder:text-(--ui-color-design-plain-na-content-secondary) hover:text-(--ui-color-base-1) focus:text-(--ui-color-base-1) active:text-(--ui-color-base-1) font-[family-name:var(--ui-font-family-primary)] font-(--ui-font-weight-regular) align-middle data-[segment=literal]:text-(--ui-color-base-6) data-invalid:text-(--ui-color-accent-main-alert) data-disabled:cursor-not-allowed data-disabled:pointer-events-auto data-disabled:select-none data-disabled:opacity-30 data-disabled:resize-none transition-colors focus:bg-(--ui-color-bg-content-secondary)',
    separatorIcon: 'shrink-0 size-4 text-muted'
  },
  variants: {
    fieldGroup: {
      horizontal: 'focus-visible:outline-none ring ring-inset ring-0 focus-visible:ring-2 group-[.is-field-group]/items:not-only:first:rounded-e-none group-[.is-field-group]/items:not-only:last:rounded-s-none group-[.is-field-group]/items:not-last:not-first:rounded-none group-[.is-field-group]/items:not-only:first:border-e-0 group-[.is-field-group]/items:not-only:not-first:border-s-0 focus-visible:z-[1]',
      vertical: 'focus-visible:outline-none ring ring-inset ring-0 focus-visible:ring-2 not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]'
    },
    noSplit: {
      false: "group-[.is-field-group]/items:not-only:not-first:after:content-[''] group-[.is-field-group]/items:not-only:not-first:after:absolute group-[.is-field-group]/items:not-only:not-first:after:top-[7px] group-[.is-field-group]/items:not-only:not-first:after:bottom-[6px] group-[.is-field-group]/items:not-only:not-first:after:left-0 group-[.is-field-group]/items:not-only:not-first:after:w-px group-[.is-field-group]/items:not-only:not-first:after:bg-current/30"
    },
    size: {
      xss: {
        base: 'h-[20px] gap-1 text-(length:--ui-font-size-4xs)/[normal] gap-0.20 px-1',
        leading: 'px-1',
        trailing: 'px-1',
        leadingIcon: 'size-[12px]',
        leadingAvatarSize: '3xs',
        trailingIcon: 'size-[12px]',
        segment: 'not-data-[segment=literal]:w-8'
      },
      xs: {
        base: 'h-[24px] gap-1 text-(length:--ui-font-size-xs)/[normal] gap-0.25 px-2',
        leading: 'px-1',
        trailing: 'px-1',
        leadingIcon: 'size-[14px]',
        leadingAvatarSize: '3xs',
        trailingIcon: 'size-[14px]',
        segment: 'not-data-[segment=literal]:w-8'
      },
      sm: {
        base: 'h-[28px] gap-1.5 text-(length:--ui-font-size-sm)/[normal] gap-0.5 px-2',
        leading: 'px-1.5',
        trailing: 'px-1.5',
        leadingIcon: 'size-[16px]',
        leadingAvatar: 'size-[16px]',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-[16px]',
        segment: 'not-data-[segment=literal]:w-8'
      },
      md: {
        base: 'h-[34px] gap-1.5 text-(length:--ui-font-size-lg)/[normal] gap-0.5 px-3',
        leading: 'px-2',
        trailing: 'px-2',
        leadingIcon: 'size-4.5',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-4.5',
        segment: 'not-data-[segment=literal]:w-9'
      },
      lg: {
        base: 'h-[38px] gap-2 text-(length:--ui-font-size-lg)/[normal] gap-0.75 px-3',
        leading: 'px-2',
        trailing: 'px-2',
        leadingIcon: 'size-[22px]',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-[22px]',
        segment: 'not-data-[segment=literal]:w-9'
      },
      xl: {
        base: 'h-[46px] gap-2 text-(length:--ui-font-size-2xl)/[normal] gap-0.75 px-3',
        leading: 'px-2',
        trailing: 'px-2',
        leadingIcon: 'size-[22px]',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-[22px]',
        segment: 'not-data-[segment=literal]:w-10'
      }
    },
    color: {
      'air-primary': {
        base: 'style-filled'
      },
      'air-primary-success': {
        base: 'style-filled-success'
      },
      'air-primary-alert': {
        base: 'style-filled-alert'
      },
      'air-primary-copilot': {
        base: 'style-filled-copilot'
      },
      'air-primary-warning': {
        base: 'style-filled-warning'
      },
      default: {
        base: 'style-old-default'
      },
      danger: {
        base: 'style-old-danger'
      },
      success: {
        base: 'style-old-success'
      },
      warning: {
        base: 'style-old-warning'
      },
      primary: {
        base: 'style-old-primary'
      },
      secondary: {
        base: 'style-old-secondary'
      },
      collab: {
        base: 'style-old-collab'
      },
      ai: {
        base: 'style-old-ai'
      }
    },
    rounded: {
      true: 'rounded-(--ui-border-radius-3xl)',
      false: 'rounded-(--ui-border-radius-sm)'
    },
    noPadding: {
      true: {
        base: 'px-0'
      }
    },
    noBorder: {
      true: 'ring-0 focus-visible:ring-0 style-transparent-bg'
    },
    underline: {
      true: 'rounded-none ring-0 focus-visible:ring-0 style-transparent-bg border-b-1 border-b-(--ui-color-design-outline-stroke)'
    },
    leading: {
      true: ''
    },
    trailing: {
      true: ''
    },
    loading: {
      true: ''
    },
    highlight: {
      true: 'ring ring-inset ring-(--b24ui-border-color)'
    },
    fixed: {
      false: ''
    },
    type: {
      file: 'file:me-1.5 file:text-(--ui-color-design-plain-na-content-secondary) file:outline-none'
    }
  },
  compoundVariants: [
    {
      highlight: false,
      noBorder: false,
      underline: false,
      class: {
        base: 'ring ring-inset ring-(--ui-color-design-outline-stroke) focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-(--b24ui-border-color) hover:not-disabled:not-data-disabled:ring-1 hover:not-disabled:not-data-disabled:ring-inset hover:not-disabled:not-data-disabled:ring-(--b24ui-border-color) data-[state=open]:ring-1 data-[state=open]:ring-inset data-[state=open]:ring-(--b24ui-border-color)'
      }
    },
    {
      highlight: true,
      noBorder: false,
      underline: false,
      class: {
        base: 'ring ring-inset ring-(--b24ui-border-color) focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-(--b24ui-border-color) hover:ring-1 hover:ring-inset hover:ring-(--b24ui-border-color) data-[state=open]:ring-1 data-[state=open]:ring-inset data-[state=open]:ring-(--b24ui-border-color)'
      }
    },
    {
      noBorder: false,
      underline: true,
      class: {
        base: 'focus-visible:border-(--b24ui-border-color) hover:not-disabled:not-data-disabled:border-(--b24ui-border-color) data-[state=open]:border-(--b24ui-border-color)'
      }
    },
    {
      highlight: true,
      noBorder: false,
      underline: true,
      class: {
        base: 'ring-0 border-b-(--b24ui-border-color)'
      }
    },
    {
      highlight: true,
      noBorder: true,
      underline: false,
      class: {
        base: 'ring-0'
      }
    },
    {
      type: 'file',
      size: 'xss',
      class: 'py-[2px]'
    },
    {
      type: 'file',
      size: 'xs',
      class: 'py-[4px]'
    },
    {
      type: 'file',
      size: 'sm',
      class: 'py-[5px]'
    },
    {
      type: 'file',
      size: 'md',
      class: 'py-[7px]'
    },
    {
      type: 'file',
      size: 'lg',
      class: 'py-[9px]'
    },
    {
      type: 'file',
      size: 'xl',
      class: 'py-[11px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'xss',
      class: 'ps-[20px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'xs',
      class: 'ps-[22px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'sm',
      class: 'ps-[28px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'md',
      class: 'ps-[32px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'lg',
      class: 'ps-[32px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'xl',
      class: 'ps-[32px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'xss',
      class: 'pe-[20px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'xs',
      class: 'pe-[22px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'sm',
      class: 'pe-[28px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'md',
      class: 'pe-[34px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'lg',
      class: 'pe-[38px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'xl',
      class: 'pe-[38px]'
    },
    {
      loading: true,
      leading: true,
      class: {
        leadingIcon: 'size-[21px]'
      }
    },
    {
      loading: true,
      leading: false,
      trailing: true,
      class: {
        trailingIcon: 'size-[21px]'
      }
    },
    {
      loading: true,
      leading: true,
      noPadding: true,
      class: {
        base: 'ps-[34px]'
      }
    },
    {
      loading: true,
      leading: false,
      trailing: true,
      noPadding: true,
      class: {
        base: 'pe-[34px]'
      }
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: [
        'xl',
        'lg',
        'md'
      ],
      rounded: false,
      class: 'rounded-(--ui-border-radius-md)'
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: 'sm',
      rounded: false,
      class: 'rounded-(--ui-border-radius-sm)'
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: 'xs',
      rounded: false,
      class: 'rounded-(--ui-border-radius-xs)'
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: 'xss',
      rounded: false,
      class: 'rounded-[5px]'
    },
    {
      fixed: false,
      size: 'xss',
      class: 'md:text-(length:--ui-font-size-4xs)/[normal]'
    },
    {
      fixed: false,
      size: 'xs',
      class: 'md:text-(length:--ui-font-size-xs)/[normal]'
    },
    {
      fixed: false,
      size: 'sm',
      class: 'md:text-(length:--ui-font-size-sm)/[normal]'
    },
    {
      fixed: false,
      size: 'md',
      class: 'md:text-(length:--ui-font-size-lg)/[normal]'
    },
    {
      fixed: false,
      size: 'lg',
      class: 'md:text-(length:--ui-font-size-lg)/[normal]'
    }
  ],
  defaultVariants: {
    color: 'air-primary',
    size: 'md'
  }
}