feat: migrate public DatePicker with shared field and calendar owners
This commit is contained in:
@@ -105,6 +105,11 @@ export const componentItems: DocsItem[] = [
|
||||
url: "/components/date-field",
|
||||
category: "date-and-time",
|
||||
},
|
||||
{
|
||||
title: "DatePicker 日期选择器",
|
||||
url: "/components/date-picker",
|
||||
category: "date-and-time",
|
||||
},
|
||||
{
|
||||
title: "Description 描述",
|
||||
url: "/components/description",
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
---
|
||||
title: DatePicker 日期选择器
|
||||
description: 通过 DateField 与 Calendar 组合的可组合日期选择器
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```ts
|
||||
import { DatePicker, DateField, Calendar, Label } from "@heroui-vue/components";
|
||||
```
|
||||
|
||||
<ComponentPreview name="date-picker-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
`DatePicker` 采用组合优先 API。显式组合 `DateField` 与 `Calendar` 以控制结构与样式。
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker>
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="选择日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
```
|
||||
|
||||
> **DatePicker** 拥有唯一的接受日期值、字段校验和原生提交;内嵌的 Calendar 在没有显式绑定时继承该值、约束和状态。
|
||||
|
||||
## 示例
|
||||
|
||||
### 禁用
|
||||
|
||||
<ComponentPreview name="date-picker-disabled" />
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview name="date-picker-controlled" />
|
||||
|
||||
### 表单校验
|
||||
|
||||
<ComponentPreview name="date-picker-with-validation" />
|
||||
|
||||
### 格式选项
|
||||
|
||||
使用 `granularity`、`hourCycle`、`hideTimeZone`、`shouldForceLeadingZeros` 等 props 控制 DatePicker 值的显示方式。
|
||||
|
||||
<ComponentPreview name="date-picker-format-options" />
|
||||
|
||||
### 表单示例
|
||||
|
||||
<ComponentPreview name="date-picker-form-example" />
|
||||
|
||||
### 自定义指示器
|
||||
|
||||
未提供默认插槽内容时,`DatePickerTriggerIndicator` 渲染默认日历图标。传入子元素可替换。
|
||||
|
||||
<ComponentPreview name="date-picker-with-custom-indicator" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 版本使用 `as` 与原生属性替代 React `render`;以下示例在根、标签、字段组、分段和触发器上设置自定义元素与 `data-custom`。
|
||||
|
||||
<ComponentPreview name="date-picker-render-function" />
|
||||
|
||||
### 国际化日历
|
||||
|
||||
默认情况下,DatePicker 使用用户 locale 的日历系统显示日期。可用 `ConfigProvider` 包裹并设置 [Unicode 日历 locale 扩展](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar#adding_a_calendar_in_the_locale_string) 覆盖。
|
||||
|
||||
以下示例展示印度日历系统:
|
||||
|
||||
<ComponentPreview name="date-picker-international-calendar" />
|
||||
|
||||
**Note:** 无论显示的 locale 如何,`change` 事件始终返回与 `value` 或 `defaultValue` 相同日历系统的日期(未提供 value 时为 Gregorian)。这确保应用逻辑在单一日历系统下一致运行,同时仍可按用户偏好格式显示日期。
|
||||
|
||||
完整支持的日历系统及其标识符列表请参阅:
|
||||
|
||||
- [React Aria Calendar Implementations](https://react-aria.adobe.com/internationalized/date/Calendar#implementations)
|
||||
- [React Aria International Calendars](https://react-aria.adobe.com/Calendar#international-calendars)
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="date-picker-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
使用 `@layer components` 自定义 DatePicker 基础类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-date-picker {
|
||||
@apply inline-flex flex-col gap-1;
|
||||
}
|
||||
|
||||
.hv-date-picker__trigger {
|
||||
@apply inline-flex items-center justify-between;
|
||||
}
|
||||
|
||||
.hv-date-picker__trigger-indicator {
|
||||
@apply text-muted;
|
||||
}
|
||||
|
||||
.hv-date-picker__popover {
|
||||
@apply min-w-[var(--reka-popper-anchor-width)] p-0;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 命名以便复用自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
DatePicker 在 `packages/styles/components/date-picker.css` 中使用以下类:
|
||||
|
||||
- `.hv-date-picker` - 根包裹层
|
||||
- `.hv-date-picker__trigger` - 打开 popover 的触发器部分
|
||||
- `.hv-date-picker__trigger-indicator` - 默认/自定义指示器 slot
|
||||
- `.hv-date-picker__popover` - Popover 内容包裹层
|
||||
|
||||
### 交互状态
|
||||
|
||||
DatePicker 支持与真实 Vue/Reka 状态同步的 data 属性与伪状态:
|
||||
|
||||
- **Open**:触发器上 `[data-open="true"]`
|
||||
- **Disabled**:触发器上 `[data-disabled="true"]` 或 `[aria-disabled="true"]`
|
||||
- **Focus visible**:触发器上 `:focus-visible` 或 `[data-focus-visible="true"]`
|
||||
- **Hover**:触发器上 `:hover`
|
||||
- **Invalid**:根容器上 `[data-invalid="true"]` 或 `[aria-invalid="true"]`
|
||||
- **Read only**:根容器上 `[data-readonly="true"]`
|
||||
|
||||
## API 参考
|
||||
|
||||
### DatePicker
|
||||
|
||||
DatePicker 继承固定基线的日期字段与弹层能力,通过 Vue `v-model`、具名部件与作用域插槽表达。未列出的 React 专属类型、Context 与 PressEvent 不导出。
|
||||
|
||||
#### Value Props
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------------------------ | ------------------------------------ | -------- | -------------------------------------------------- |
|
||||
| `modelValue` / `value` | `DateValue \| null` | - | 受控接受值。显式 `null` 表示空值,优先于 `value`。 |
|
||||
| `defaultValue` | `DateValue \| null` | - | 非受控初始值。 |
|
||||
| `update:modelValue` / `change` | `(value: DateValue \| null) => void` | - | 日期接受值变化时调用;同一次编辑只触发一次。 |
|
||||
| `placeholderValue` | `DateValue \| null` | 本地今天 | 空值时影响分段占位、显示历法和时间模板。 |
|
||||
|
||||
#### Open Props
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------------------------------------------- | --------------------------- | ------- | ------------------------------------------------------ |
|
||||
| `open` / `isOpen` | `boolean` | - | 受控 popover 打开状态。`open` 优先。 |
|
||||
| `defaultOpen` | `boolean` | `false` | 非受控初始打开状态。 |
|
||||
| `update:open` / `update:isOpen` / `openChange` | `(isOpen: boolean) => void` | - | popover 打开状态变化时调用。 |
|
||||
| `shouldCloseOnSelect` | `boolean` | `true` | 日历选中日期后是否关闭 popover;时间编辑不会触发关闭。 |
|
||||
|
||||
#### Validation Props
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------------------- | ------------------------------------------------------------------------------- | ---------- | -------------------------------------- |
|
||||
| `isRequired` | `boolean` | `false` | 是否在提交表单前要求用户输入。 |
|
||||
| `isInvalid` | `boolean` | - | 标记字段为无效以显示校验状态。 |
|
||||
| `minValue` | `DateValue \| null` | - | 最小可选日期,同时约束日历与字段校验。 |
|
||||
| `maxValue` | `DateValue \| null` | - | 最大可选日期,同时约束日历与字段校验。 |
|
||||
| `isDateUnavailable` | `(date: DateValue) => boolean` | - | 标记不可用日期;不可用时阻止选择。 |
|
||||
| `validate` | `(value: DateValue \| null) => string \| string[] \| true \| null \| undefined` | - | 自定义校验函数。 |
|
||||
| `validationBehavior` | `'native' \| 'aria'` | `'native'` | 使用原生 HTML 表单校验还是 ARIA 属性。 |
|
||||
|
||||
#### Format Props
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------------------- | ------------------------------------------------------------- | ------------------------- | ----------------------------------------------- |
|
||||
| `granularity` | `'day' \| 'hour' \| 'minute' \| 'second'` | `'day'` | 显示的日期/时间粒度;只改变显示,不截断接受值。 |
|
||||
| `hourCycle` | `12 \| 24` | 由 locale 决定 | 以 12 或 24 小时制显示时间。 |
|
||||
| `hideTimeZone` | `boolean` | `false` | 是否隐藏时区名称。 |
|
||||
| `shouldForceLeadingZeros` | `boolean` | - | 是否始终为月、日、小时等显示前导零。 |
|
||||
| `locale` | `string` | ConfigProvider 或 `en-US` | 显示历法与格式。 |
|
||||
| `dir` | `'ltr' \| 'rtl'` | ConfigProvider 或 `ltr` | 排列与方向键方向。 |
|
||||
| `firstDayOfWeek` | `'sun' \| 'mon' \| 'tue' \| 'wed' \| 'thu' \| 'fri' \| 'sat'` | 由 locale 决定 | 覆盖内嵌 Calendar 的一周起始日。 |
|
||||
| `pageBehavior` | `'visible' \| 'single'` | `'visible'` | 内嵌 Calendar 翻页按可见范围或单步前进。 |
|
||||
|
||||
#### State & Form Props
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------------------- | --------- | ------- | ---------------------------------------------------- |
|
||||
| `isDisabled` / `disabled` | `boolean` | `false` | 禁用日期编辑、触发器与日历选择。 |
|
||||
| `isReadOnly` | `boolean` | `false` | 只读:可查看,不可编辑或选择;触发器同样禁用。 |
|
||||
| `name` | `string` | - | 原生表单提交使用;以 ISO 8601 字符串提交唯一日期值。 |
|
||||
| `form` | `string` | - | 关联到外部表单 id。 |
|
||||
| `autoFocus` | `boolean` | `false` | 挂载后聚焦第一个日期分段。 |
|
||||
| `autoComplete` | `string` | `'off'` | 传给隐藏 ISO 文本输入。 |
|
||||
| `as` | `string` | `'div'` | 根元素标签;属性、事件与引用归属该元素。 |
|
||||
|
||||
### Composition Parts
|
||||
|
||||
| 组件 | 描述 |
|
||||
| ------------------------------- | ------------------------------------------------------------------------ |
|
||||
| `DatePicker` / `DatePickerRoot` | 根日期选择器容器与唯一状态所有者。 |
|
||||
| `DatePickerTrigger` | 触发按钮,通常渲染在 `DateFieldSuffix` 内;可取消的 click 不会打开面板。 |
|
||||
| `DatePickerTriggerIndicator` | 带默认日历图标的指示器 slot。 |
|
||||
| `DatePickerPopover` | `Calendar` 内容的 Popover 包裹层;默认 `placement="bottom"`。 |
|
||||
|
||||
日期输入使用既有的 `DateFieldGroup`、`DateFieldInput`、`DateFieldSegment`、`DateFieldSuffix`;日历使用 `Calendar*` 与 `CalendarYearPicker*` 具名部件。没有另建一套同义部件。
|
||||
|
||||
### 默认插槽与 Render Props
|
||||
|
||||
默认插槽提供响应式状态和操作。`state.timeValue` 与 `state.setTimeValue` 供格式选项示例中的 TimeField 使用,并走同一个接受值协议。
|
||||
|
||||
| 字段 | 类型 | 描述 |
|
||||
| ----------------------------- | --------------------------------------------------- | --------------------------------------------------------------- |
|
||||
| `value` | `DateValue \| null` | 当前接受值。 |
|
||||
| `isOpen` | `boolean` | popover 是否打开。 |
|
||||
| `isDisabled` | `boolean` | 是否禁用。 |
|
||||
| `isReadOnly` | `boolean` | 是否只读。 |
|
||||
| `isRequired` | `boolean` | 是否必填。 |
|
||||
| `isInvalid` | `boolean` | 当前是否无效。 |
|
||||
| `isFocusWithin` / `isFocused` | `boolean` | 字段是否聚焦。 |
|
||||
| `isFocusVisible` | `boolean` | 键盘焦点是否可见。 |
|
||||
| `validationErrors` | `string[]` | 当前可显示的校验错误。 |
|
||||
| `timeValue` | `Time \| CalendarDateTime \| ZonedDateTime \| null` | 当前接受值的时间部分。 |
|
||||
| `state` | `DatePickerState` | `value`、`timeValue`、`setValue`、`setTimeValue` 的响应式视图。 |
|
||||
| `open` / `close` / `toggle` | `() => void` | 打开、关闭或切换 popover。 |
|
||||
|
||||
### DatePickerTrigger
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ----------------- | --------- | ---------- | ---------------------------------------- |
|
||||
| `as` | `string` | `'button'` | 触发元素标签;默认生成 `type="button"`。 |
|
||||
| `asChild` | `boolean` | `false` | 将行为合并到单个子元素。 |
|
||||
| `isDisabled` | `boolean` | - | 额外禁用触发器。 |
|
||||
| `class` / `style` | - | - | 与组件样式合并。 |
|
||||
|
||||
### DatePickerPopover
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------------------------- | --------------------------------------------------- | ---------- | ---------------------- |
|
||||
| `placement` | `'top' \| 'bottom' \| 'left' \| 'right'` 及逻辑变体 | `'bottom'` | 优先定位方向。 |
|
||||
| `offset` | `number` | `8` | 与锚点间距。 |
|
||||
| `crossOffset` | `number` | `0` | 交叉轴偏移。 |
|
||||
| `shouldFlip` | `boolean` | `true` | 空间不足时翻转。 |
|
||||
| `containerPadding` | `number` | `12` | 视口碰撞内边距。 |
|
||||
| `to` | `string \| HTMLElement` | body | Portal 目标。 |
|
||||
| `isDismissable` | `boolean` | `true` | 是否允许外部点击关闭。 |
|
||||
| `isKeyboardDismissDisabled` | `boolean` | `false` | 是否禁止 Escape 关闭。 |
|
||||
|
||||
### Related packages
|
||||
|
||||
- [`@internationalized/date`](https://react-aria.adobe.com/internationalized/date/) — 所有日期组件使用的日期类型(`CalendarDate`、`CalendarDateTime`、`ZonedDateTime`)与工具
|
||||
- 本库 `ConfigProvider` — 为子树覆盖 locale、书写方向与 Portal 目标
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Calendar 日历](./calendar) · [DateField 日期字段](./date-field) · [TimeField 时间字段](./time-field)
|
||||
|
||||
## Vue 公共契约与差异
|
||||
|
||||
- `DatePicker` 与 `DatePickerRoot` 是同一根组件;`DatePickerTrigger`、`DatePickerTriggerIndicator`、`DatePickerPopover` 为独立具名导出,没有 React 对象式成员、Context、`PressEvent` 或 RenderFunction 类型。
|
||||
- 主值使用 `v-model`(`modelValue` / `update:modelValue`),`value` 为兼容别名;显式 `modelValue="null"` 是受控空值,不能按未传处理。`open` / `isOpen` 与 `defaultOpen` 的优先级相同,`open` 优先。
|
||||
- 日期输入、日历选择和时间编辑共用一个接受值协议。受控父组件拒绝提案时恢复接受值;再次提出同一值仍会触发事件。完成日历选择只发一次 `change`,不会由内嵌 Calendar 或分段输入重复提交。
|
||||
- 未显式绑定 `v-model`/`value`/`defaultValue` 的内嵌 Calendar 继承 Picker 的值、min/max、禁用、只读、无效与不可用规则;显式值绑定覆盖值来源,显式 `minValue`/`maxValue`/`isDateUnavailable` 覆盖对应继承项。独立 Calendar 行为不变。
|
||||
- Calendar 修改日期时保留接受值的日期类、时间、时区与历法;TimeField 修改时间时保留日期。空值先改时间会保留为草稿,完成日期后组合为完整值。粒度、locale 与时区显示选项不会悄悄截断提交值。
|
||||
- Picker 负责 `name` 对应的唯一日期原生命名输入、required/错误关联和 reset。内嵌 Calendar 不创建提交值;格式选项示例中独立 `name="time"` 的 TimeField 仍是另一个命名字段。
|
||||
- 触发器为原生 `button`,`type="button"`;调用者取消其可取消 click 时不打开。触发器的可访问名称优先取显式 `aria-label`,其次由字段标签 id 组成;没有标签时提供 `日历` / `Calendar` 默认名。只读时触发器禁用。缺少 `DatePicker` 的部件会抛出明确错误。外部点击、Escape、触发器切换、Tab 与关闭后焦点恢复按现有 Popover/Reka 协议执行。
|
||||
- 默认日历图标移植固定源 SVG,保留 Apache-2.0 来源;示例中的自定义图标使用 `@tabler/icons-vue`。`render` 改为 `as`、class/style 与原生属性;作用域插槽替代 React 渲染函数。
|
||||
- 不支持 SSR/水合/Nuxt 服务端专项;逐像素自动对比、完整读屏与真机矩阵不作为本轮门槛。Reka 无 React Aria 的 `data-entering`/`data-exiting` 自动等价标记,本库在 Popover 生命周期上显式生成。
|
||||
@@ -0,0 +1,67 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker class="w-72" name="date">
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
today,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { shallowRef } from "vue";
|
||||
const value = shallowRef<DateValue | null>(today(getLocalTimeZone()));
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-72 flex-col gap-4">
|
||||
<DatePicker v-model="value" name="date">
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
<Description>当前值:{{ value ? value.toString() : "(空)" }}</Description>
|
||||
<div class="flex gap-2">
|
||||
<Button variant="tertiary" @click="value = today(getLocalTimeZone())">
|
||||
设为今天
|
||||
</Button>
|
||||
<Button variant="tertiary" @click="value = null">清空</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarHeading,
|
||||
CalendarNavButton,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker class="w-72" name="event-date">
|
||||
<Label>活动日期</Label>
|
||||
<DateFieldGroup
|
||||
full-width
|
||||
class="rounded-xl border border-border/80 bg-default shadow-sm"
|
||||
variant="secondary"
|
||||
>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger class="text-muted">
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover class="border border-border/80 shadow-sm">
|
||||
<Calendar aria-label="活动日期" class="rounded-2xl bg-surface p-2">
|
||||
<CalendarHeader>
|
||||
<CalendarHeading class="font-medium text-foreground" />
|
||||
<CalendarNavButton
|
||||
class="text-muted hover:bg-default"
|
||||
slot="previous"
|
||||
/>
|
||||
<CalendarNavButton class="text-muted hover:bg-default" slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell class="text-xs text-muted">
|
||||
{{ day }}
|
||||
</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell
|
||||
class="rounded-lg data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground"
|
||||
:date="date"
|
||||
/>
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
@@ -0,0 +1,71 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import { getLocalTimeZone, today } from "@internationalized/date";
|
||||
const value = today(getLocalTimeZone());
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker is-disabled class="w-72" name="date" :value="value">
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<Description>该日期选择器已禁用。</Description>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
@@ -0,0 +1,111 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
FieldError,
|
||||
Form,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
today,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { computed, onBeforeUnmount, shallowRef } from "vue";
|
||||
const value = shallowRef<DateValue | null>(null);
|
||||
const isSubmitting = shallowRef(false);
|
||||
const currentDate = today(getLocalTimeZone());
|
||||
const isInvalid = computed(
|
||||
() => value.value != null && value.value.compare(currentDate) < 0,
|
||||
);
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
function submit() {
|
||||
if (!value.value || isInvalid.value || isSubmitting.value) return;
|
||||
isSubmitting.value = true;
|
||||
timer = setTimeout(() => {
|
||||
value.value = null;
|
||||
isSubmitting.value = false;
|
||||
}, 1200);
|
||||
}
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
</script>
|
||||
<template>
|
||||
<Form class="flex w-72 flex-col gap-3" @submit.prevent="submit">
|
||||
<DatePicker
|
||||
v-model="value"
|
||||
is-required
|
||||
:is-invalid="isInvalid"
|
||||
:min-value="currentDate"
|
||||
name="appointmentDate"
|
||||
>
|
||||
<Label>预约日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<FieldError v-if="isInvalid">日期须为今天或将来。</FieldError>
|
||||
<Description v-else>请选择有效的预约日期。</Description>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
<Button
|
||||
class="w-full"
|
||||
:is-disabled="!value || isInvalid"
|
||||
:is-pending="isSubmitting"
|
||||
type="submit"
|
||||
>
|
||||
{{ isSubmitting ? "提交中…" : "提交" }}
|
||||
</Button>
|
||||
</Form>
|
||||
</template>
|
||||
@@ -0,0 +1,221 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Label,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
Select,
|
||||
SelectIndicator,
|
||||
SelectPopover,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
TimeField,
|
||||
TimeFieldGroup,
|
||||
TimeFieldInput,
|
||||
TimeFieldSegment,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
parseDate,
|
||||
parseZonedDateTime,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
type Granularity = "day" | "hour" | "minute" | "second";
|
||||
const granularity = ref<Granularity>("minute");
|
||||
const hourCycle = ref(12);
|
||||
const hideTimeZone = ref(false);
|
||||
const shouldForceLeadingZeros = ref(false);
|
||||
const cycle = computed(() => (hourCycle.value === 24 ? 24 : 12) as 12 | 24);
|
||||
const timeGranularity = computed(() =>
|
||||
granularity.value !== "day" ? granularity.value : undefined,
|
||||
);
|
||||
const showTimeField = computed(() => !!timeGranularity.value);
|
||||
const defaultValue = computed<DateValue>(() => {
|
||||
const localTimeZone = getLocalTimeZone();
|
||||
if (granularity.value === "day") return parseDate("2026-02-03");
|
||||
return parseZonedDateTime(`2026-02-03T08:45:00[${localTimeZone}]`);
|
||||
});
|
||||
const granularityOptions: { label: string; value: Granularity }[] = [
|
||||
{ label: "日", value: "day" },
|
||||
{ label: "时", value: "hour" },
|
||||
{ label: "分", value: "minute" },
|
||||
{ label: "秒", value: "second" },
|
||||
];
|
||||
const hourCycleOptions = [
|
||||
{ label: "12 小时制", value: 12 },
|
||||
{ label: "24 小时制", value: 24 },
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<DatePicker
|
||||
:key="granularity"
|
||||
class="w-fit min-w-72"
|
||||
:default-value="defaultValue"
|
||||
:granularity="granularity"
|
||||
:hide-time-zone="hideTimeZone"
|
||||
:hour-cycle="cycle"
|
||||
name="date"
|
||||
:should-force-leading-zeros="shouldForceLeadingZeros"
|
||||
>
|
||||
<template #default="{ state }">
|
||||
<Label>日期和时间</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover class="flex flex-col gap-3">
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
<div v-if="showTimeField" class="flex items-center justify-between">
|
||||
<Label>时间</Label>
|
||||
<TimeField
|
||||
aria-label="时间"
|
||||
:granularity="timeGranularity"
|
||||
:hide-time-zone="hideTimeZone"
|
||||
:hour-cycle="cycle"
|
||||
name="time"
|
||||
:should-force-leading-zeros="shouldForceLeadingZeros"
|
||||
:value="state.timeValue"
|
||||
@change="state.setTimeValue($event)"
|
||||
>
|
||||
<TimeFieldGroup variant="secondary">
|
||||
<TimeFieldInput v-slot="{ segment }">
|
||||
<TimeFieldSegment :segment="segment" />
|
||||
</TimeFieldInput>
|
||||
</TimeFieldGroup>
|
||||
</TimeField>
|
||||
</div>
|
||||
</DatePickerPopover>
|
||||
</template>
|
||||
</DatePicker>
|
||||
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<div class="flex flex-col gap-1">
|
||||
<Select
|
||||
class="w-[120px]"
|
||||
:model-value="granularity"
|
||||
variant="secondary"
|
||||
@update:model-value="granularity = $event as Granularity"
|
||||
>
|
||||
<Label>粒度</Label>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
<SelectIndicator />
|
||||
</SelectTrigger>
|
||||
<SelectPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="option in granularityOptions"
|
||||
:id="option.value"
|
||||
:key="option.value"
|
||||
:text-value="option.label"
|
||||
>
|
||||
{{ option.label }}
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</SelectPopover>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<Select
|
||||
class="w-[120px]"
|
||||
:model-value="hourCycle"
|
||||
variant="secondary"
|
||||
@update:model-value="hourCycle = Number($event)"
|
||||
>
|
||||
<Label>小时制</Label>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
<SelectIndicator />
|
||||
</SelectTrigger>
|
||||
<SelectPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="option in hourCycleOptions"
|
||||
:id="option.value"
|
||||
:key="option.value"
|
||||
:text-value="option.label"
|
||||
>
|
||||
{{ option.label }}
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</SelectPopover>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-w-80 flex-col gap-2">
|
||||
<Switch v-model:checked="hideTimeZone">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
隐藏时区
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch v-model:checked="shouldForceLeadingZeros">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
强制前导零
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,72 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
ConfigProvider,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import { getLocalTimeZone, today } from "@internationalized/date";
|
||||
const value = today(getLocalTimeZone());
|
||||
</script>
|
||||
<template>
|
||||
<ConfigProvider locale="hi-IN-u-ca-indian">
|
||||
<DatePicker class="w-72" :default-value="value" name="international-date">
|
||||
<Label>活动日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</ConfigProvider>
|
||||
</template>
|
||||
@@ -0,0 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker class="w-72" as="section" data-custom="date-picker" name="date">
|
||||
<Label data-custom="date-picker-label">日期</Label>
|
||||
<DateFieldGroup full-width as="div" data-custom="date-field-group">
|
||||
<DateFieldInput
|
||||
as="div"
|
||||
data-custom="date-field-input"
|
||||
v-slot="{ segment }"
|
||||
>
|
||||
<DateFieldSegment
|
||||
as="span"
|
||||
data-custom="date-field-segment"
|
||||
:segment="segment"
|
||||
/>
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger as="button" data-custom="date-picker-trigger">
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期" data-custom="date-picker-calendar">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
@@ -0,0 +1,72 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconChevronDown } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker class="w-72" name="date">
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator>
|
||||
<IconChevronDown class="size-4" aria-hidden="true" />
|
||||
</DatePickerTriggerIndicator>
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<Description>通过传入自定义子元素替换默认日历图标。</Description>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
FieldError,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
today,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { computed, shallowRef } from "vue";
|
||||
const value = shallowRef<DateValue | null>(null);
|
||||
const currentDate = today(getLocalTimeZone());
|
||||
const isInvalid = computed(
|
||||
() => value.value != null && value.value.compare(currentDate) < 0,
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<DatePicker
|
||||
v-model="value"
|
||||
is-required
|
||||
class="w-72"
|
||||
:is-invalid="isInvalid"
|
||||
:min-value="currentDate"
|
||||
name="date"
|
||||
>
|
||||
<Label>预约日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<FieldError>日期须为今天或将来。</FieldError>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</template>
|
||||
@@ -53,6 +53,11 @@ const labs = [
|
||||
title: "弹层动画",
|
||||
component: defineAsyncComponent(() => import("./OverlayAnimationLab.vue")),
|
||||
},
|
||||
{
|
||||
key: "date-picker-overlay",
|
||||
title: "DatePicker 嵌套弹层",
|
||||
component: defineAsyncComponent(() => import("./DatePickerLab.vue")),
|
||||
},
|
||||
{
|
||||
key: "overlay-components",
|
||||
title: "弹层公共组合",
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
Label,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
} from "@heroui-vue/components";
|
||||
import { CalendarDate } from "@internationalized/date";
|
||||
const initial = new CalendarDate(2024, 2, 10);
|
||||
</script>
|
||||
<template>
|
||||
<main class="p-8">
|
||||
<Modal>
|
||||
<Button>打开嵌套弹层</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[420px]">
|
||||
<ModalCloseTrigger />
|
||||
<ModalHeader>
|
||||
<ModalHeading>嵌套日期选择器</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<DatePicker :default-value="initial" name="nested-date">
|
||||
<Label>活动日期</Label>
|
||||
<DateFieldGroup full-width>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger>
|
||||
<DatePickerTriggerIndicator />
|
||||
</DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<Description>Escape 应先关闭日历,再关闭模态框。</Description>
|
||||
<DatePickerPopover>
|
||||
<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }">
|
||||
<CalendarHeaderCell>{{ day }}</CalendarHeaderCell>
|
||||
</CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }">
|
||||
<CalendarCell :date="date" />
|
||||
</CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }">
|
||||
<CalendarYearPickerCell :year="year" :date="date" />
|
||||
</CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>
|
||||
</DatePickerPopover>
|
||||
</DatePicker>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">关闭</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</main>
|
||||
</template>
|
||||
+90
-84
@@ -4,91 +4,91 @@
|
||||
|
||||
固定上游公共组件清单;状态、差异和验证范围逐组件记录,不以单项测试通过声明整库完整兼容。
|
||||
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
|
||||
| alert-dialog | 验证中(M33) | 11 部件;role=alertdialog;默认不误关;14/14 基线例;Reka Dialog 底座 |
|
||||
| autocomplete | 已迁移(有已知差异) | Autocomplete 七部件;24/24 基线例;触发器单一 Tab 入口 + 弹层内搜索框虚拟焦点、受控开关/文本、多选 Value 用作用域插槽;见 B02 报告 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 验证中(最小实现) | Badge/BadgeAnchor/BadgeLabel;四角定位、圆点、文本/数字自动包装;Anchor 非链接 |
|
||||
| breadcrumbs | 验证中(M17) | Breadcrumbs/BreadcrumbsItem;7/7 基线例;ol+aria-label、末项 current、禁用/无 href span、separator 插槽;onAction 未提供,class 同时落 li/link |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 验证中(M26) | ButtonGroup/ButtonGroupSeparator;9/9 基线例;直接子 Button 继承 size/variant/isDisabled/fullWidth;嵌套不继承;圆角与 outline 边框处理 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 验证中(基线实现) | 原生 label/input;checked/isSelected、半选、primary/secondary、Content/Control/Indicator;15 个基线预览 |
|
||||
| checkbox-group | 验证中(基线实现) | 数组模型、同名重复提交、required/readonly/disabled/reset、组标签与成员描述隔离;10 个基线预览 |
|
||||
| chip | 验证中(最小实现) | color/size/variant;纯文本/数字自动包装为 ChipLabel;显式部件不重复包装;组合内容可动态切换 |
|
||||
| color-area | 私有基建已验证(COLOR-01) | 接受值、二维键盘、18 轴组合、指针捕获与两个原生轴/reset 已验证;未公开部件或 7 个正式预览 |
|
||||
| color-field | 私有组合协议已验证 | Root/Input及InputGroup前后缀、校验/关联、locale/草稿/IME/reset已验证;未公开包根、variants或正式13例,见COLOR-06。 |
|
||||
| color-picker | 私有组合协议已验证 | Picker/Trigger/Popover共享owner、字段/轨道联动与单一提交/reset已验证;未公开包根、variants或正式6例,见COLOR-08。 |
|
||||
| color-slider | 私有轨道已验证 | 自定义轨道、指针捕获/取消、键盘/方向/渐变及共享owner已验证;未公开Slider家族及正式文档,见COLOR-04。 |
|
||||
| color-swatch | 已迁移(客户端) | ColorSwatch/ColorSwatchRoot、circle/square、xs–xl、透明棋盘;7/7 基线例;省略 color 继承最近共享 owner,显式值覆盖;公开 Color/parseColor 子集;render 映射 as/asChild,style 函数映射 styleFn;见 COLOR-SWATCH 结果 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 已迁移(有已知差异) | ComboBox 五部件;24/24 基线例;可编辑输入 + 过滤 + 虚拟焦点、form-value key/text、menu-trigger 三态、多选 Value;见 B02 报告 |
|
||||
| date-field | 已迁移(有已知差异) | DateField 七部件与 DateInputGroup 六部件、17 预览;完整 ISO、字段校验、reset、SSR/水合与浏览器重点检查,见 DATE-02 报告;本地化整日期粘贴、13 月/era 编辑等仍待专项。 |
|
||||
| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| drawer | 验证中(M34) | 11 部件;四方向拖动关闭(30%/0.5px/ms);9/9 基线例;Content/Dialog 职责分离 |
|
||||
| progress-bar | 验证中(M18) | ProgressBar/Output/Track/Fill;7/7 基线例;确定/未知进度、min/max/formatOptions/valueLabel;custom-value 的 NumberField/Select 为原生临时控件 |
|
||||
| progress-circle | 验证中(M19) | ProgressCircle/Track/TrackCircle/FillCircle;7/7 基线例;圆环几何可覆盖;与 ProgressBar 共用取值语义 |
|
||||
| time-field | 已迁移(客户端) | TimeField/Root及六个共享输入部件;15/15基线例;Time/CalendarDateTime/ZonedDateTime、完整精度、受控拒绝、键盘/Enter、校验/提交/reset;框架差异见 TIME-FIELD 结果。 |
|
||||
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
|
||||
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
|
||||
| error-message | 已迁移(有已知差异) | ErrorMessage 单部件;2/2 基线例;复用字段错误 id 与样式变量,`slot="errorMessage"` 仅为 DOM 标记,不做校验也不改 aria-invalid;见 B03 报告 |
|
||||
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
|
||||
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
|
||||
| popover | 验证中(OVERLAY-02) | Root/Trigger/Content/Dialog/Heading/Arrow;6/6 基线例;逻辑定位/碰撞/退出/标题;模态 closeAutoFocus 不支持取消恢复,见 OVERLAY-02 |
|
||||
| scroll-shadow | 验证中(M24) | 7/7 基线例;fade/方向/尺寸/偏移/受控可见性;VueUse 测量与公开 useScrollShadow,RTL/动态内容;CSS scroll timeline 保留 |
|
||||
| separator | 验证中(最小实现) | orientation/variant/decorative;默认 hr + role=separator;asChild 自定义根;Reka Separator |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 验证中(M35 + 保真返修) | Provider/Toast/Content/Indicator/Title/Description/Action/Close + 队列;11/11 例;role=alertdialog + 标题/描述关联 + content role=alert;indicator data-swapped;自有计时(无双倒计时);getQueue 不提供,见文档差异 |
|
||||
| toggle-button | 验证中(M27) | ToggleButton;7/7 基线例;v-model/isSelected/defaultSelected;data-selected/pressed/hover/focus;Enter/Space;组内 radio 语义 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 验证中(M25) | 七部件、10/10 基线例;primary/secondary、方向/对齐、受控/键盘/禁用/滚动/指示器;Vue 模型与 ID/集合差异见报告 |
|
||||
| tag | 已迁移(有已知差异) | Tag/TagRemoveButton;与 TagGroup 同页 12 例;textValue 决定文字与移除按钮名称 `Remove tag {文本}`;移除由行统一处理;见 B03 报告 |
|
||||
| tag-group | 已迁移(有已知差异) | TagGroup/TagGroupList 两部件;role=grid/row、single/multiple、disabledKeys、移除与焦点恢复、aria-labelledby/describedby;12/12 基线例;见 B03 报告 |
|
||||
| toggle-button-group | 验证中(M28) | ToggleButtonGroup/Separator;10/10 基线例;single/multiple、disallowEmptySelection、roving focus;Vue 数组模型替代 Set<Key> |
|
||||
| toolbar | 验证中(M29) | Toolbar;5/5 基线例;isAttached/orientation/dir;跨组单 Tab 入口与方向键;子组焦点让位;Separator 垂直继承 |
|
||||
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
|
||||
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
|
||||
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
|
||||
| textarea | 验证中(字段接入) | rows 默认 3;变体/fullWidth/受控/FormData/reset;独立页 7/7 示例;接入 useTextControl |
|
||||
| textfield | 验证中(字段接入) | 值/状态/约束/校验/ID;独立页 13/13 示例;render 自定义根类型未支持(data-* 透传) |
|
||||
| search-field | 验证中(FORM-02) | 五部件、15 基线例;共享文本内核、clear/submit/IME/reset/SSR,边界见 FORM-02 |
|
||||
| typography | 验证中(M15) | Typography/Heading/Paragraph/Code/Prose 具名导出;6/6 基线例;type/as/align/color/weight/truncate;render 映射为 as |
|
||||
| label | 验证中(通用字段) | 自动 for、Switch 内 span、状态继承;独立页 2/2 示例 |
|
||||
| description | 验证中(通用字段) | 动态 ID 清理、外部 describedby 合并;独立页 2/2 示例;SSR 包装限制见基础协议 |
|
||||
| empty-state | 验证中(M16) | 单根 EmptyState;4 个自编示例(基线无页面/示例);默认 fallback;空节点判断与上游 children 真值回退边界不同 |
|
||||
| field-error | 验证中(通用字段) | 作用域插槽 validationErrors;独立页 2/2 示例;无完整 validationDetails(见基础协议) |
|
||||
| fieldset | 验证中(FORM-02) | 四部件、3 基线例与禁用验证例;响应式禁用、首 Legend 例外,边界见 FORM-02 |
|
||||
| form | 验证中(基础设施) | native/aria 校验、FormData/reset、服务端错误;完整基线文档与生态集成未完成 |
|
||||
| header | 验证中(M31) | Header/HeaderRoot;原生 `<header>` 集合分组标题;基线无独立文档/演示,自编 3 例并标注;无 v-model |
|
||||
| radio | 验证中(基线实现) | 原生 radio + Content/Control/Indicator;须在 RadioGroup 内,成员禁用/只读、作用域状态 |
|
||||
| radio-group | 验证中(基线实现) | 标量模型、roving Tab/方向键/dir/loop、原生提交/校验/reset;12 个基线预览 |
|
||||
| input-otp | 验证中(M32) | Root/Group/Slot/Separator + 3 正则常量;Reka PinInput 底座;字符串+索引数组;reset/Fieldset/Form/ARIA/mask 已接入;11/11 例;自动填充/IME/读屏未真机验证 |
|
||||
| alert | 验证中(最小实现) | status 五态;默认图标随 status;自定义 Indicator 空内容回退;内部 Surface 重置为 default |
|
||||
| list-box | 验证中(LISTBOX-01) | 四部件、9/9 基线例;typed key/数组模型、none/single/multiple、键盘/范围/全选、1000 项固定行高虚拟化;差异见 LISTBOX-01 |
|
||||
| list-box-item | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| list-box-section | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| dropdown | 验证中(B01) | Root/Trigger/Popover/Menu/Section/Item/ItemIndicator/SubmenuIndicator/SubmenuTrigger;17/17 基线例;Reka DropdownMenu;数组选择模型 |
|
||||
| menu | 验证中(B01) | MenuRoot/Menu 列表与选择/动作上下文;无独立官方文档页,契约折叠于 Dropdown;见 B01 |
|
||||
| menu-item | 验证中(B01) | MenuItem/Indicator/SubmenuIndicator;variant default/danger、checkmark/dot;见 B01 |
|
||||
| menu-section | 验证中(B01) | MenuSection 分组与分组级选择;见 B01 |
|
||||
| modal | 验证中(OVERLAY-02) | Root/Trigger/Backdrop/Container/Dialog/Heading/Header/Body/Footer/Icon/Close/CloseTrigger;14/14 基线例;焦点/锁/滚动/退出动画;Vue close 部件替代 React slot |
|
||||
| pagination | 验证中(M30) | 组合式 nav 容器(无 total/page 状态机);11 具名部件;9/9 基线例;onPress→@click;显式 aria-current 可覆盖 |
|
||||
| number-field | 验证中(NUMBER-01) | 五部件与 17/17 基线例;Reka 数值内核;受控/只读/表单 reset、SSR/水合;差异见 NUMBER-01 报告 |
|
||||
| select | 验证中(SELECT-01) | 六部件、19/19 例、单/多选、清空、字段/原生提交/SSR/异步;复用 ListBox + Popover,重点浏览器已验,限制见 SELECT-01 |
|
||||
| meter | 验证中(M20) | Meter/Output/Track/Fill;6/6 基线例;role=meter progressbar;无 isIndeterminate;测量语义独立于 Progress |
|
||||
| slider | 验证中(SLIDER-01) | 六部件、9/9 基线例;原生 range/局部指针适配,单值/范围、受控/reset/SSR/水合;差异见 SLIDER-01 |
|
||||
| table | 验证中(M36 + 保真返修) | 15 部件;选择/排序/原生语义;13 演示;TableBody `#empty` 空状态;全选半选;defaultWidth 的 1fr 按原生 auto 弹性适配,不承诺 fr 比例;虚拟化固定 42px 窗口、TanStack 分页行模型;RAC TableLayout 不导出,见 M36 |
|
||||
| calendar | 已迁移(有已知差异) | 月/周/日、多选、焦点/翻页、国际历法、年份层与 19 预览;局部日期视图/键盘适配,默认历法边界等差异见 DATE-03。 |
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
|
||||
| alert-dialog | 验证中(M33) | 11 部件;role=alertdialog;默认不误关;14/14 基线例;Reka Dialog 底座 |
|
||||
| autocomplete | 已迁移(有已知差异) | Autocomplete 七部件;24/24 基线例;触发器单一 Tab 入口 + 弹层内搜索框虚拟焦点、受控开关/文本、多选 Value 用作用域插槽;见 B02 报告 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 验证中(最小实现) | Badge/BadgeAnchor/BadgeLabel;四角定位、圆点、文本/数字自动包装;Anchor 非链接 |
|
||||
| breadcrumbs | 验证中(M17) | Breadcrumbs/BreadcrumbsItem;7/7 基线例;ol+aria-label、末项 current、禁用/无 href span、separator 插槽;onAction 未提供,class 同时落 li/link |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 验证中(M26) | ButtonGroup/ButtonGroupSeparator;9/9 基线例;直接子 Button 继承 size/variant/isDisabled/fullWidth;嵌套不继承;圆角与 outline 边框处理 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 验证中(基线实现) | 原生 label/input;checked/isSelected、半选、primary/secondary、Content/Control/Indicator;15 个基线预览 |
|
||||
| checkbox-group | 验证中(基线实现) | 数组模型、同名重复提交、required/readonly/disabled/reset、组标签与成员描述隔离;10 个基线预览 |
|
||||
| chip | 验证中(最小实现) | color/size/variant;纯文本/数字自动包装为 ChipLabel;显式部件不重复包装;组合内容可动态切换 |
|
||||
| color-area | 私有基建已验证(COLOR-01) | 接受值、二维键盘、18 轴组合、指针捕获与两个原生轴/reset 已验证;未公开部件或 7 个正式预览 |
|
||||
| color-field | 私有组合协议已验证 | Root/Input及InputGroup前后缀、校验/关联、locale/草稿/IME/reset已验证;未公开包根、variants或正式13例,见COLOR-06。 |
|
||||
| color-picker | 私有组合协议已验证 | Picker/Trigger/Popover共享owner、字段/轨道联动与单一提交/reset已验证;未公开包根、variants或正式6例,见COLOR-08。 |
|
||||
| color-slider | 私有轨道已验证 | 自定义轨道、指针捕获/取消、键盘/方向/渐变及共享owner已验证;未公开Slider家族及正式文档,见COLOR-04。 |
|
||||
| color-swatch | 已迁移(客户端) | ColorSwatch/ColorSwatchRoot、circle/square、xs–xl、透明棋盘;7/7 基线例;省略 color 继承最近共享 owner,显式值覆盖;公开 Color/parseColor 子集;render 映射 as/asChild,style 函数映射 styleFn;见 COLOR-SWATCH 结果 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 已迁移(有已知差异) | ComboBox 五部件;24/24 基线例;可编辑输入 + 过滤 + 虚拟焦点、form-value key/text、menu-trigger 三态、多选 Value;见 B02 报告 |
|
||||
| date-field | 已迁移(有已知差异) | DateField 七部件与 DateInputGroup 六部件、17 预览;完整 ISO、字段校验、reset、SSR/水合与浏览器重点检查,见 DATE-02 报告;本地化整日期粘贴、13 月/era 编辑等仍待专项。 |
|
||||
| date-picker | 已迁移(客户端,有已知差异) | DatePicker/Root、Trigger、TriggerIndicator、Popover;10/10 基线例;复用 DateField 字段、Calendar 视图/年份层与 Popover;唯一日期提交、受控拒绝/重试、时间草稿、locale/RTL、嵌套 Modal Escape;见 DATE-PICKER 结果。 |
|
||||
| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| drawer | 验证中(M34) | 11 部件;四方向拖动关闭(30%/0.5px/ms);9/9 基线例;Content/Dialog 职责分离 |
|
||||
| progress-bar | 验证中(M18) | ProgressBar/Output/Track/Fill;7/7 基线例;确定/未知进度、min/max/formatOptions/valueLabel;custom-value 的 NumberField/Select 为原生临时控件 |
|
||||
| progress-circle | 验证中(M19) | ProgressCircle/Track/TrackCircle/FillCircle;7/7 基线例;圆环几何可覆盖;与 ProgressBar 共用取值语义 |
|
||||
| time-field | 已迁移(客户端) | TimeField/Root及六个共享输入部件;15/15基线例;Time/CalendarDateTime/ZonedDateTime、完整精度、受控拒绝、键盘/Enter、校验/提交/reset;框架差异见 TIME-FIELD 结果。 |
|
||||
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
|
||||
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
|
||||
| error-message | 已迁移(有已知差异) | ErrorMessage 单部件;2/2 基线例;复用字段错误 id 与样式变量,`slot="errorMessage"` 仅为 DOM 标记,不做校验也不改 aria-invalid;见 B03 报告 |
|
||||
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
|
||||
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
|
||||
| popover | 验证中(OVERLAY-02) | Root/Trigger/Content/Dialog/Heading/Arrow;6/6 基线例;逻辑定位/碰撞/退出/标题;模态 closeAutoFocus 不支持取消恢复,见 OVERLAY-02 |
|
||||
| scroll-shadow | 验证中(M24) | 7/7 基线例;fade/方向/尺寸/偏移/受控可见性;VueUse 测量与公开 useScrollShadow,RTL/动态内容;CSS scroll timeline 保留 |
|
||||
| separator | 验证中(最小实现) | orientation/variant/decorative;默认 hr + role=separator;asChild 自定义根;Reka Separator |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 验证中(M35 + 保真返修) | Provider/Toast/Content/Indicator/Title/Description/Action/Close + 队列;11/11 例;role=alertdialog + 标题/描述关联 + content role=alert;indicator data-swapped;自有计时(无双倒计时);getQueue 不提供,见文档差异 |
|
||||
| toggle-button | 验证中(M27) | ToggleButton;7/7 基线例;v-model/isSelected/defaultSelected;data-selected/pressed/hover/focus;Enter/Space;组内 radio 语义 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 验证中(M25) | 七部件、10/10 基线例;primary/secondary、方向/对齐、受控/键盘/禁用/滚动/指示器;Vue 模型与 ID/集合差异见报告 |
|
||||
| tag | 已迁移(有已知差异) | Tag/TagRemoveButton;与 TagGroup 同页 12 例;textValue 决定文字与移除按钮名称 `Remove tag {文本}`;移除由行统一处理;见 B03 报告 |
|
||||
| tag-group | 已迁移(有已知差异) | TagGroup/TagGroupList 两部件;role=grid/row、single/multiple、disabledKeys、移除与焦点恢复、aria-labelledby/describedby;12/12 基线例;见 B03 报告 |
|
||||
| toggle-button-group | 验证中(M28) | ToggleButtonGroup/Separator;10/10 基线例;single/multiple、disallowEmptySelection、roving focus;Vue 数组模型替代 Set<Key> |
|
||||
| toolbar | 验证中(M29) | Toolbar;5/5 基线例;isAttached/orientation/dir;跨组单 Tab 入口与方向键;子组焦点让位;Separator 垂直继承 |
|
||||
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
|
||||
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
|
||||
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
|
||||
| textarea | 验证中(字段接入) | rows 默认 3;变体/fullWidth/受控/FormData/reset;独立页 7/7 示例;接入 useTextControl |
|
||||
| textfield | 验证中(字段接入) | 值/状态/约束/校验/ID;独立页 13/13 示例;render 自定义根类型未支持(data-* 透传) |
|
||||
| search-field | 验证中(FORM-02) | 五部件、15 基线例;共享文本内核、clear/submit/IME/reset/SSR,边界见 FORM-02 |
|
||||
| typography | 验证中(M15) | Typography/Heading/Paragraph/Code/Prose 具名导出;6/6 基线例;type/as/align/color/weight/truncate;render 映射为 as |
|
||||
| label | 验证中(通用字段) | 自动 for、Switch 内 span、状态继承;独立页 2/2 示例 |
|
||||
| description | 验证中(通用字段) | 动态 ID 清理、外部 describedby 合并;独立页 2/2 示例;SSR 包装限制见基础协议 |
|
||||
| empty-state | 验证中(M16) | 单根 EmptyState;4 个自编示例(基线无页面/示例);默认 fallback;空节点判断与上游 children 真值回退边界不同 |
|
||||
| field-error | 验证中(通用字段) | 作用域插槽 validationErrors;独立页 2/2 示例;无完整 validationDetails(见基础协议) |
|
||||
| fieldset | 验证中(FORM-02) | 四部件、3 基线例与禁用验证例;响应式禁用、首 Legend 例外,边界见 FORM-02 |
|
||||
| form | 验证中(基础设施) | native/aria 校验、FormData/reset、服务端错误;完整基线文档与生态集成未完成 |
|
||||
| header | 验证中(M31) | Header/HeaderRoot;原生 `<header>` 集合分组标题;基线无独立文档/演示,自编 3 例并标注;无 v-model |
|
||||
| radio | 验证中(基线实现) | 原生 radio + Content/Control/Indicator;须在 RadioGroup 内,成员禁用/只读、作用域状态 |
|
||||
| radio-group | 验证中(基线实现) | 标量模型、roving Tab/方向键/dir/loop、原生提交/校验/reset;12 个基线预览 |
|
||||
| input-otp | 验证中(M32) | Root/Group/Slot/Separator + 3 正则常量;Reka PinInput 底座;字符串+索引数组;reset/Fieldset/Form/ARIA/mask 已接入;11/11 例;自动填充/IME/读屏未真机验证 |
|
||||
| alert | 验证中(最小实现) | status 五态;默认图标随 status;自定义 Indicator 空内容回退;内部 Surface 重置为 default |
|
||||
| list-box | 验证中(LISTBOX-01) | 四部件、9/9 基线例;typed key/数组模型、none/single/multiple、键盘/范围/全选、1000 项固定行高虚拟化;差异见 LISTBOX-01 |
|
||||
| list-box-item | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| list-box-section | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| dropdown | 验证中(B01) | Root/Trigger/Popover/Menu/Section/Item/ItemIndicator/SubmenuIndicator/SubmenuTrigger;17/17 基线例;Reka DropdownMenu;数组选择模型 |
|
||||
| menu | 验证中(B01) | MenuRoot/Menu 列表与选择/动作上下文;无独立官方文档页,契约折叠于 Dropdown;见 B01 |
|
||||
| menu-item | 验证中(B01) | MenuItem/Indicator/SubmenuIndicator;variant default/danger、checkmark/dot;见 B01 |
|
||||
| menu-section | 验证中(B01) | MenuSection 分组与分组级选择;见 B01 |
|
||||
| modal | 验证中(OVERLAY-02) | Root/Trigger/Backdrop/Container/Dialog/Heading/Header/Body/Footer/Icon/Close/CloseTrigger;14/14 基线例;焦点/锁/滚动/退出动画;Vue close 部件替代 React slot |
|
||||
| pagination | 验证中(M30) | 组合式 nav 容器(无 total/page 状态机);11 具名部件;9/9 基线例;onPress→@click;显式 aria-current 可覆盖 |
|
||||
| number-field | 验证中(NUMBER-01) | 五部件与 17/17 基线例;Reka 数值内核;受控/只读/表单 reset、SSR/水合;差异见 NUMBER-01 报告 |
|
||||
| select | 验证中(SELECT-01) | 六部件、19/19 例、单/多选、清空、字段/原生提交/SSR/异步;复用 ListBox + Popover,重点浏览器已验,限制见 SELECT-01 |
|
||||
| meter | 验证中(M20) | Meter/Output/Track/Fill;6/6 基线例;role=meter progressbar;无 isIndeterminate;测量语义独立于 Progress |
|
||||
| slider | 验证中(SLIDER-01) | 六部件、9/9 基线例;原生 range/局部指针适配,单值/范围、受控/reset/SSR/水合;差异见 SLIDER-01 |
|
||||
| table | 验证中(M36 + 保真返修) | 15 部件;选择/排序/原生语义;13 演示;TableBody `#empty` 空状态;全选半选;defaultWidth 的 1fr 按原生 auto 弹性适配,不承诺 fr 比例;虚拟化固定 42px 窗口、TanStack 分页行模型;RAC TableLayout 不导出,见 M36 |
|
||||
| calendar | 已迁移(有已知差异) | 月/周/日、多选、焦点/翻页、国际历法、年份层与 19 预览;局部日期视图/键盘适配,默认历法边界等差异见 DATE-03。 |
|
||||
| range-calendar | 已迁移(客户端,有已知差异) | RangeCalendar/Root、九个具名日历部件、共享六个 CalendarYearPicker 部件;20/20 基线例;点击/键盘/鼠标拖选、受控拒绝、跨月/RTL;触屏长按拖选未实现,见 RANGE-CALENDAR 结果。 |
|
||||
| calendar-year-picker | 已迁移(DATE-03) | 六个独立具名部件、三列年份、窗口/格式/era、覆盖测量、焦点与关闭;不导出 React 上下文。 |
|
||||
| calendar-year-picker | 已迁移(DATE-03) | 六个独立具名部件、三列年份、窗口/格式/era、覆盖测量、焦点与关闭;不导出 React 上下文。 |
|
||||
|
||||
## 公共导出差异
|
||||
|
||||
@@ -250,3 +250,9 @@ ComboBox/Autocomplete的正式组合、原30项返修和本轮定位/ref/ARIA/lo
|
||||
公开 Root/九个具名部件、RangeCalendarOptions/Props/CalendarDateRange/CalendarRangeModel、Cell 状态与实例类型、rangeCalendarVariants;六个年份部件复用既有 CalendarYearPicker 具名导出。固定源中文 20 个预览、API/插槽/状态表与导航已接入,内核沿用既有范围接受值/锚点/手势与共享 Calendar view。公开组合、定向回归、真实浏览器和最终 tarball 验证见 [任务结果](tasks/results/RANGE-CALENDAR.md)。
|
||||
|
||||
两次点击、键盘、鼠标拖选及端点拖动可用;触屏长按拖选尚未实现。DOM 采用 td/gridcell + 原生 button + 内层样式 span;框架专属 render/Context/PressEvent 不移植,默认历法边界、属性和事件差异见组件文档。独立日历没有字段提交/reset;不代表 DatePicker/DateRangePicker 完成。
|
||||
|
||||
## DATE-PICKER 公共日期选择器(2026-10-26)
|
||||
|
||||
公开 DatePicker/Root、DatePickerTrigger、DatePickerTriggerIndicator、DatePickerPopover、datePickerVariants 及 Props/RenderProps/state 类型;字段输入复用 DateFieldGroup/Input/Segment/Suffix,日历复用 Calendar 与 CalendarYearPicker 具名部件。固定源中文 10 个预览、API/插槽/状态表与导航已接入;Picker 拥有唯一接受值、字段校验和原生命名提交,未显式绑定的内嵌 Calendar 继承值、上下界、不可用、禁用/只读/无效与 locale/dir。
|
||||
|
||||
分段编辑、日历选择和时间草稿走同一接受值协议;受控拒绝后可重试,日历修改保留日期类、时间、时区与历法,空值时间草稿在完成日期前不提交。触发器可访问名称取字段标签或显式 aria-label,只读时禁用;Escape 在分段内也关闭日历,嵌套 Modal 中先关闭 Picker 再关闭 Modal。范围选择、DateRangePicker 与颜色家族不在本项范围;完整证据和限制见 [任务结果](tasks/results/DATE-PICKER.md)。
|
||||
|
||||
+4
-4
@@ -8,13 +8,13 @@
|
||||
|
||||
- 展示、按钮、导航、展开、反馈等主要家族已有公共组件与文档。
|
||||
- 字段/Form、Checkbox/Radio、数值/Slider/OTP、弹层/菜单、集合/ListBox/Select、ComboBox/Autocomplete、Tag、Toast/Table已集成。
|
||||
- DateField、TimeField、Calendar与CalendarYearPicker已有公共组件;RangeCalendar 已完成公共客户端迁移(20 个基线预览),范围选择与 Calendar 共用视图/焦点/年份设施。
|
||||
- DateField、TimeField、Calendar、CalendarYearPicker 与 DatePicker 已有公共组件;RangeCalendar 已完成公共客户端迁移(20 个基线预览),范围选择与 Calendar 共用视图/焦点/年份设施。DatePicker 复用 DateField 字段、Calendar 视图与 Popover 弹层,10 个基线预览已接入。
|
||||
- ColorSwatch/ColorSwatchRoot及Color/parseColor公共子集已公开;Area、Slider、Field/InputGroup、Picker组合协议仍有私有实现和回归夹具,尚未作为完整公共颜色家族发布。
|
||||
- 兼容矩阵目前83条(包含子部件与基础设施),文档有66个组件页面。矩阵中的“验证中”保留其原有限制,不升级为完整兼容。
|
||||
- 兼容矩阵目前84条(包含子部件与基础设施),文档有67个组件页面。矩阵中的“验证中”保留其原有限制,不升级为完整兼容。
|
||||
|
||||
## 尚未完成的公共家族
|
||||
|
||||
DatePicker、DateRangePicker,以及ColorArea、ColorField、ColorSlider、ColorSwatchPicker、ColorPicker,共7项;已有私有内核不等于公共迁移完成。ColorInputGroup仍为私有协议;Color/parseColor公共边界已随COLOR-SWATCH验收。
|
||||
DateRangePicker,以及ColorArea、ColorField、ColorSlider、ColorSwatchPicker、ColorPicker,共6项;已有私有内核不等于公共迁移完成。ColorInputGroup仍为私有协议;Color/parseColor公共边界已随COLOR-SWATCH验收。
|
||||
|
||||
TIME-FIELD 已完成公共迁移和客户端验收,见 [结果](tasks/results/TIME-FIELD.md);COLOR-SWATCH 见 [结果](tasks/results/COLOR-SWATCH.md)。RANGE-CALENDAR 结果见 [任务结果](tasks/results/RANGE-CALENDAR.md)。后续由用户选择一项,在实际前置具备后创建任务卡;不自动并行推进。
|
||||
|
||||
@@ -22,7 +22,7 @@ TIME-FIELD 已完成公共迁移和客户端验收,见 [结果](tasks/results/
|
||||
|
||||
唯一Vue工作目录heroui-vue,一任务一分支、会话串行。b01/b02/b03已删除并解除Git登记;core内容已整合,是否保留该目录不影响运行。开发默认文档5173,playground按实际脚本;服务只在任务需要时启动,结束按用户要求停止。
|
||||
|
||||
已完成的单目录整合见 [结果](tasks/results/WORKSPACE-CONSOLIDATION.md)。当前客户端全量回归93文件/1338项通过;本轮TimeField新增2文件/27项,日期相关定向验收134项通过,见任务结果;SSR历史用例已删除。逐像素自动对比、完整读屏矩阵、真机矩阵及Nuxt集成暂不投入。维护清理的实际结果见 [MAINTENANCE](tasks/results/MAINTENANCE.md)。
|
||||
已完成的单目录整合见 [结果](tasks/results/WORKSPACE-CONSOLIDATION.md)。当前客户端全量回归95文件/1357项通过;本轮DatePicker新增2文件/19项,日期相关定向验收152项通过,见任务结果;SSR历史用例已删除。逐像素自动对比、完整读屏矩阵、真机矩阵及Nuxt集成暂不投入。维护清理的实际结果见 [MAINTENANCE](tasks/results/MAINTENANCE.md)。
|
||||
|
||||
## 按需入口
|
||||
|
||||
|
||||
@@ -268,3 +268,11 @@ TimeField CSS/variants 仅加 hv- 前缀,保留 Apache-2.0 来源;DateInputG
|
||||
本批沿用此前已移植的 range-calendar.css(原生 button 所需 w-full、表格相邻单元格选择器已在私有阶段适配),新增源 variants 的 hv- 映射。Root/部件结构、中文标题/正文/示例次序、默认值与演示内容按源适配;年份部件/默认 chevron 复用既有 Calendar/YearPicker 及基线 SVG。许可证继续采用 `third-party/HEROUI-LICENSE`(Apache-2.0);本批无新增依赖。
|
||||
|
||||
Vue 模型、具名导出、原生事件/作用域插槽与共享日期 owner 取代 React Aria 框架机制。触屏长按拖选、近似历法边界等差异见 [组件文档](../apps/docs/components/range-calendar.md) 和 [结果](tasks/results/RANGE-CALENDAR.md),不声明完整 React Aria 契约兼容。
|
||||
|
||||
## DATE-PICKER(2026-10-26)
|
||||
|
||||
固定 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/date-picker/{index.ts,date-picker.tsx}`、`packages/styles/components/date-picker.css`、`packages/styles/src/components/date-picker/date-picker.styles.ts`、中文 `(date-and-time)/date-picker.mdx` 与 `apps/docs/src/demos/cn/date-picker/` 全 10 例(format-options-no-ssr 只包装客户端内容)。同时核对 React Aria Components 1.21.1 的发布日期源码 `DatePicker`/`useDatePicker` 以确认按钮、对话框、Calendar 继承与 `shouldCloseOnSelect` 语义,未安装或执行 React。
|
||||
|
||||
DatePicker CSS/variants 仅加 hv- 前缀,弹层 origin/placement 与进入退出状态映射到 Reka;默认日历图标取自上游 `icons.tsx` 的 IconCalendar,保留 Apache-2.0 来源,示例自定义图标改用 Tabler Vue。Vue 侧复用既有 DateField 接受值/字段校验/原生提交与 Calendar/RangeCalendar 视图、年份层、Popover 协议;从 DateField 抽取内部 owner,供独立 DateField 与 Picker 共用,未复制第二套字段状态。无新增依赖,构建不依赖相邻 React 仓库。
|
||||
|
||||
框架差异(`v-model`、`v-model:open`、具名导出、作用域插槽、默认 slot 的 `state.timeValue`/`setTimeValue`、`render` 映射到 `as`/原生 attrs)见 [组件文档](../apps/docs/components/date-picker.md) 与 [结果](tasks/results/DATE-PICKER.md)。
|
||||
|
||||
@@ -30,3 +30,11 @@
|
||||
公开范围日历及20个固定源预览;新增11项公共行为与5项文档组合测试。全量客户端回归93文件/1338项、定向6文件/68项、typecheck和文档生产构建通过;统一产物脚本验证最终tarball的ESM/CSS/variants、实例/插槽/事件与strict NodeNext/bundler正反类型。实际浏览器覆盖点击/键盘确认、拖选、受控拒绝/重试、跨月、RTL、年份焦点/几何、浅深主题及390px视口。详情和可复现步骤见 [任务结果](tasks/results/RANGE-CALENDAR.md)。
|
||||
|
||||
触摸pointer仅做单元模拟,不宣称浏览器触摸事件或真机长按验证。逐像素、完整读屏、真机矩阵及服务端专项不在范围。
|
||||
|
||||
## DATE-PICKER(2026-10-26,客户端)
|
||||
|
||||
公开 DatePicker/Root、Trigger、TriggerIndicator、Popover、variants、RenderProps/state 类型;复用 DateField 字段、Calendar 视图/年份层与 Popover,固定源中文10例全部迁移。新增15项公共行为测试与4项文档/示例测试;全量客户端回归95文件/1357项、任务定向14文件/152项、类型检查与文档生产构建通过。统一产物脚本验证最终tarball的 ESM/CSS/variants 与 strict NodeNext/bundler 正反类型;在独立生产构建消费者中实际打开、选择日期并提交。
|
||||
|
||||
真实文档5173验证:键盘打开/关闭、日期选中、焦点恢复、外部点击、受控开关拒绝、格式选项粒度/小时制/时区/前导零、国际化历法显示与 Gregorian 提交、表单校验关联与提交清零、浅深主题、800px 与 390px 窄视口、reduced-motion。嵌套 Modal 专项在 playground 真实浏览器验证:Escape 依次关闭年份层、Picker、Modal,焦点与滚动锁恢复。年度层 Escape、RTL 方向键和 locale 继承另有单元断言。详情见 [任务结果](tasks/results/DATE-PICKER.md)。
|
||||
|
||||
未开展 SSR/水合/Nuxt 服务端、逐像素自动对比、完整读屏/真机矩阵;触摸、IME 与完整本地化日期粘贴仍不在本项验收范围。
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/* Adapted from HeroUI ce90ea3 date-picker.css. Copyright 2025 NextUI Inc.
|
||||
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace, Vue/Reka states. */
|
||||
|
||||
.hv-date-picker {
|
||||
@apply inline-flex flex-col gap-1;
|
||||
|
||||
.hv-date-input-group__suffix,
|
||||
.hv-date-input-group__prefix {
|
||||
@apply pointer-events-auto;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-date-picker__trigger {
|
||||
@apply inline-flex w-full items-center rounded-field p-1 text-sm no-highlight;
|
||||
|
||||
cursor: var(--cursor-interactive);
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition: box-shadow 150ms var(--ease-out);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
&:focus-visible:not([data-focused]),
|
||||
&[data-focus-visible="true"] {
|
||||
@apply status-focused;
|
||||
}
|
||||
|
||||
&:disabled,
|
||||
&[data-disabled="true"],
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-date-picker__trigger-indicator {
|
||||
@apply inline-flex size-4 items-center justify-center text-field-placeholder;
|
||||
}
|
||||
|
||||
.hv-date-picker__popover {
|
||||
@apply w-fit origin-(--reka-popper-transform-origin) scrollbar-none overflow-y-auto overscroll-contain bg-overlay p-3;
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
box-shadow: var(--overlay-shadow);
|
||||
border-radius: min(32px, calc(var(--radius) * 2.5));
|
||||
|
||||
&:focus-visible:not([data-focused]),
|
||||
&[data-focus-visible="true"] {
|
||||
@apply outline-none;
|
||||
}
|
||||
|
||||
&[data-entering="true"] {
|
||||
@apply animate-in duration-150 ease-smooth fade-in-0 zoom-in-95;
|
||||
|
||||
&[data-side^="top"] {
|
||||
@apply slide-in-from-bottom-1;
|
||||
}
|
||||
|
||||
&[data-side^="bottom"] {
|
||||
@apply slide-in-from-top-1;
|
||||
}
|
||||
|
||||
&[data-side^="left"] {
|
||||
@apply slide-in-from-right-1;
|
||||
}
|
||||
|
||||
&[data-side^="right"] {
|
||||
@apply slide-in-from-left-1;
|
||||
}
|
||||
}
|
||||
|
||||
&[data-exiting="true"] {
|
||||
@apply animate-out duration-100 ease-smooth zoom-out-95 fade-out;
|
||||
/* Stays non-interactive while closing, even if the exit animation is interrupted. */
|
||||
@apply pointer-events-none;
|
||||
}
|
||||
|
||||
&[data-exiting="true"],
|
||||
&[data-entering="true"] {
|
||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||
}
|
||||
}
|
||||
|
||||
.hv-date-picker__popover .hv-calendar__nav-button-icon,
|
||||
.hv-date-picker__popover .hv-range-calendar__nav-button-icon {
|
||||
@apply rotate-0;
|
||||
}
|
||||
@@ -163,6 +163,7 @@
|
||||
|
||||
@import "./components/date-input-group.css" layer(components);
|
||||
@import "./components/date-field.css" layer(components);
|
||||
@import "./components/date-picker.css" layer(components);
|
||||
@import "./components/time-field.css" layer(components);
|
||||
|
||||
@import "./components/calendar.css" layer(components);
|
||||
|
||||
@@ -1460,6 +1460,15 @@ export const dateFieldVariants = tv({
|
||||
variants: { fullWidth: { true: "hv-date-field--full-width", false: "" } },
|
||||
});
|
||||
export type DateFieldVariants = VariantProps<typeof dateFieldVariants>;
|
||||
export const datePickerVariants = tv({
|
||||
slots: {
|
||||
base: "hv-date-picker",
|
||||
popover: "hv-date-picker__popover",
|
||||
trigger: "hv-date-picker__trigger",
|
||||
triggerIndicator: "hv-date-picker__trigger-indicator",
|
||||
},
|
||||
});
|
||||
export type DatePickerVariants = VariantProps<typeof datePickerVariants>;
|
||||
export const dateInputGroupVariants = tv({
|
||||
slots: {
|
||||
base: "hv-date-input-group",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
<script setup lang="ts" generic="M extends CalendarSelectionMode = 'single'">
|
||||
import { computed, getCurrentInstance, useAttrs } from "vue";
|
||||
import {
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
inject,
|
||||
nextTick,
|
||||
onMounted,
|
||||
useAttrs,
|
||||
watch,
|
||||
} from "vue";
|
||||
import {
|
||||
GregorianCalendar,
|
||||
toCalendar,
|
||||
@@ -10,6 +18,7 @@ import {
|
||||
import { useChoiceValue } from "../choice/shared";
|
||||
import { copyDateValue, copyDateValues } from "../date/value";
|
||||
import { calendarHeading } from "../date/calendar";
|
||||
import { datePickerKey } from "../date-picker/context";
|
||||
import { useCalendarView } from "./view";
|
||||
import type {
|
||||
CalendarModel,
|
||||
@@ -39,10 +48,19 @@ defineSlots<{
|
||||
}>();
|
||||
const attrs = useAttrs(),
|
||||
instance = getCurrentInstance()!;
|
||||
const picker = inject(datePickerKey, undefined);
|
||||
type Value = DateValue | DateValue[] | null;
|
||||
const copy = (value: Value | undefined): Value =>
|
||||
Array.isArray(value) ? copyDateValues(value) : copyDateValue(value ?? null);
|
||||
const has = (key: string) => Object.hasOwn(instance.vnode.props ?? {}, key);
|
||||
const inheritsValue = computed(
|
||||
() =>
|
||||
!!picker &&
|
||||
!has("modelValue") &&
|
||||
!has("model-value") &&
|
||||
!has("value") &&
|
||||
!has("defaultValue"),
|
||||
);
|
||||
const model = useChoiceValue<Value>(
|
||||
() =>
|
||||
copy(
|
||||
@@ -56,6 +74,10 @@ const model = useChoiceValue<Value>(
|
||||
},
|
||||
);
|
||||
const selectedValues = computed(() => {
|
||||
if (inheritsValue.value) {
|
||||
const value = picker!.value.value;
|
||||
return value ? [value] : [];
|
||||
}
|
||||
const value = model.value.value;
|
||||
return Array.isArray(value) ? value : value ? [value] : [];
|
||||
});
|
||||
@@ -67,10 +89,26 @@ const view = useCalendarView(
|
||||
dates: selectedValues,
|
||||
selected,
|
||||
request,
|
||||
unavailable: (date) => !!props.isDateUnavailable?.(date.copy()),
|
||||
unavailable: (date) =>
|
||||
!!(props.isDateUnavailable ?? picker?.isDateUnavailable)?.(date),
|
||||
multiple: () => props.selectionMode === "multiple",
|
||||
},
|
||||
emit,
|
||||
"calendar",
|
||||
picker
|
||||
? {
|
||||
minValue: () => picker.minValue.value,
|
||||
maxValue: () => picker.maxValue.value,
|
||||
defaultFocusedValue: () => picker.placeholder.value,
|
||||
locale: () => picker.locale.value,
|
||||
dir: () => picker.dir.value,
|
||||
firstDayOfWeek: () => picker.firstDayOfWeek,
|
||||
pageBehavior: () => picker.pageBehavior,
|
||||
isDisabled: () => picker.disabled.value,
|
||||
isReadOnly: () => picker.readOnly.value,
|
||||
isInvalid: () => picker.invalid.value,
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
const {
|
||||
root,
|
||||
@@ -89,6 +127,10 @@ const {
|
||||
function request(value: DateValue) {
|
||||
if (view.disabledDay(value) || view.unavailable(value) || view.readOnly.value)
|
||||
return;
|
||||
if (inheritsValue.value) {
|
||||
picker!.requestDate(value);
|
||||
return;
|
||||
}
|
||||
const fallback = Array.isArray(props.defaultValue)
|
||||
? props.defaultValue[0]
|
||||
: props.defaultValue;
|
||||
@@ -113,6 +155,19 @@ function request(value: DateValue) {
|
||||
);
|
||||
} else if (!selected(value)) model.request(next.copy());
|
||||
}
|
||||
function focusForPicker(open: boolean) {
|
||||
if (!picker || !open) return;
|
||||
void nextTick(() => {
|
||||
if (picker.state.isOpen.value && tabStop.value)
|
||||
focusDate(tabStop.value, true);
|
||||
});
|
||||
}
|
||||
onMounted(() => focusForPicker(!!picker?.state.isOpen.value));
|
||||
watch(
|
||||
() => picker?.state.isOpen.value,
|
||||
(open) => focusForPicker(!!open),
|
||||
{ flush: "post" },
|
||||
);
|
||||
defineExpose({
|
||||
get element() {
|
||||
return root.value;
|
||||
|
||||
@@ -43,6 +43,19 @@ export type CalendarViewProps = Omit<
|
||||
| "selectionMode"
|
||||
| "isDateUnavailable"
|
||||
>;
|
||||
/** Constraints a DatePicker owner passes to an otherwise unbound Calendar. */
|
||||
export interface CalendarInheritedConstraints {
|
||||
minValue?: () => DateValue | undefined;
|
||||
maxValue?: () => DateValue | undefined;
|
||||
defaultFocusedValue?: () => DateValue | undefined;
|
||||
locale?: () => string;
|
||||
dir?: () => "ltr" | "rtl";
|
||||
firstDayOfWeek?: () => import("../date/calendar").CalendarWeekday | undefined;
|
||||
pageBehavior?: () => "visible" | "single" | undefined;
|
||||
isDisabled?: () => boolean;
|
||||
isReadOnly?: () => boolean;
|
||||
isInvalid?: () => boolean;
|
||||
}
|
||||
export interface CalendarSelectionAdapter {
|
||||
dates: ComputedRef<DateValue[]>;
|
||||
selected: (date: DateValue) => boolean;
|
||||
@@ -70,6 +83,7 @@ export function useCalendarView(
|
||||
selection: CalendarSelectionAdapter,
|
||||
emit: ViewEmit,
|
||||
prefix: "calendar" | "range-calendar" = "calendar",
|
||||
inherited?: CalendarInheritedConstraints,
|
||||
) {
|
||||
const instance = getCurrentInstance()!,
|
||||
config = useConfig();
|
||||
@@ -78,25 +92,40 @@ export function useCalendarView(
|
||||
trigger = shallowRef<HTMLElement>();
|
||||
const headingId = `hv-calendar-${useId()}-heading`;
|
||||
const locale = computed(
|
||||
() => props.locale ?? config?.locale.value ?? "en-US",
|
||||
() =>
|
||||
props.locale ?? inherited?.locale?.() ?? config?.locale.value ?? "en-US",
|
||||
);
|
||||
const dir = computed(
|
||||
() => props.dir ?? inherited?.dir?.() ?? config?.dir.value ?? "ltr",
|
||||
);
|
||||
const dir = computed(() => props.dir ?? config?.dir.value ?? "ltr");
|
||||
const timeZone = computed(() => props.timeZone ?? getLocalTimeZone());
|
||||
const disabled = useInheritedDisabled(
|
||||
() => props.isDisabled || props.disabled,
|
||||
() =>
|
||||
props.isDisabled || props.disabled || Boolean(inherited?.isDisabled?.()),
|
||||
);
|
||||
const readOnly = computed(
|
||||
() => !!props.isReadOnly || Boolean(inherited?.isReadOnly?.()),
|
||||
);
|
||||
const readOnly = computed(() => !!props.isReadOnly);
|
||||
const multiple = computed(() => selection.multiple?.() ?? false);
|
||||
const invalid = computed(() => !!props.isInvalid || !!selection.invalid?.());
|
||||
const invalid = computed(
|
||||
() =>
|
||||
!!props.isInvalid ||
|
||||
Boolean(inherited?.isInvalid?.()) ||
|
||||
!!selection.invalid?.(),
|
||||
);
|
||||
const options = computed(() => ({
|
||||
locale: locale.value,
|
||||
firstDayOfWeek: props.firstDayOfWeek,
|
||||
firstDayOfWeek: props.firstDayOfWeek ?? inherited?.firstDayOfWeek?.(),
|
||||
visibleDuration: props.visibleDuration,
|
||||
weeksInMonth: props.weeksInMonth,
|
||||
}));
|
||||
const pageBehavior = computed(
|
||||
() => props.pageBehavior ?? inherited?.pageBehavior?.(),
|
||||
);
|
||||
const initial = copyDateValue(
|
||||
props.defaultFocusedValue ??
|
||||
selection.dates.value[0] ??
|
||||
inherited?.defaultFocusedValue?.() ??
|
||||
today(timeZone.value),
|
||||
);
|
||||
const focusModel = useChoiceValue<DateValue>(
|
||||
@@ -114,7 +143,9 @@ export function useCalendarView(
|
||||
const min = computed(() =>
|
||||
toCalendarDate(
|
||||
dateForLocale(
|
||||
props.minValue ?? new CalendarDate(1900, 1, 1),
|
||||
props.minValue ??
|
||||
inherited?.minValue?.() ??
|
||||
new CalendarDate(1900, 1, 1),
|
||||
locale.value,
|
||||
),
|
||||
),
|
||||
@@ -122,7 +153,9 @@ export function useCalendarView(
|
||||
const max = computed(() =>
|
||||
toCalendarDate(
|
||||
dateForLocale(
|
||||
props.maxValue ?? new CalendarDate(2099, 12, 31),
|
||||
props.maxValue ??
|
||||
inherited?.maxValue?.() ??
|
||||
new CalendarDate(2099, 12, 31),
|
||||
locale.value,
|
||||
),
|
||||
),
|
||||
@@ -226,7 +259,7 @@ export function useCalendarView(
|
||||
{ flush: "sync" },
|
||||
);
|
||||
watch(
|
||||
[locale, () => props.visibleDuration, () => props.firstDayOfWeek],
|
||||
[locale, () => props.visibleDuration, () => options.value.firstDayOfWeek],
|
||||
() => {
|
||||
anchor.value = aligned(focus.value);
|
||||
},
|
||||
@@ -247,7 +280,7 @@ export function useCalendarView(
|
||||
function pageStep(direction: -1 | 1) {
|
||||
const { unit, count } = calendarDuration(props.visibleDuration);
|
||||
return {
|
||||
[unit]: direction * (props.pageBehavior === "single" ? 1 : count),
|
||||
[unit]: direction * (pageBehavior.value === "single" ? 1 : count),
|
||||
};
|
||||
}
|
||||
function pageDisabled(direction: -1 | 1) {
|
||||
|
||||
@@ -1,47 +1,16 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
computed,
|
||||
defineComponent,
|
||||
getCurrentInstance,
|
||||
h,
|
||||
mergeProps,
|
||||
nextTick,
|
||||
onMounted,
|
||||
provide,
|
||||
ref,
|
||||
shallowRef,
|
||||
watch,
|
||||
watchEffect,
|
||||
type PropType,
|
||||
type SlotsType,
|
||||
type VNodeChild,
|
||||
} from "vue";
|
||||
import { DateFieldRoot } from "reka-ui";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
today,
|
||||
parseDate,
|
||||
parseDateTime,
|
||||
parseZonedDateTime,
|
||||
toCalendar,
|
||||
toCalendarDateTime,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { type DateValue } from "@internationalized/date";
|
||||
import { dateFieldVariants } from "@heroui-vue/styles";
|
||||
import { useConfig } from "../../providers/context";
|
||||
import { useAcceptedDateValue } from "../date/model";
|
||||
import { dateForLocale, serializeDateValue } from "../date/value";
|
||||
import EmptyDateBridge from "../date/EmptyDateBridge";
|
||||
import {
|
||||
useChoiceField,
|
||||
useChoiceForm,
|
||||
validationInput,
|
||||
} from "../choice/shared";
|
||||
import { disabledContextKey } from "../field/disabled";
|
||||
import type { ValidationBehavior, ValidateResult } from "../field/context";
|
||||
import { dateFieldKey, type DateSegment } from "./context";
|
||||
import PrimitiveNode from "./PrimitiveNode";
|
||||
import DateSegments from "./DateSegments";
|
||||
import { useDateFieldOwner } from "./owner";
|
||||
export default defineComponent({
|
||||
name: "DateField",
|
||||
inheritAttrs: false,
|
||||
@@ -98,160 +67,25 @@ export default defineComponent({
|
||||
change: (_value: DateValue | null) => true,
|
||||
},
|
||||
setup(props, { attrs, slots, emit, expose }) {
|
||||
const config = useConfig();
|
||||
const instance = getCurrentInstance()!;
|
||||
const accepted: ReturnType<typeof useAcceptedDateValue<DateValue>> =
|
||||
useAcceptedDateValue<DateValue>({
|
||||
value: () =>
|
||||
["modelValue", "model-value"].some((key) =>
|
||||
Object.hasOwn(instance.vnode.props ?? {}, key),
|
||||
)
|
||||
? props.modelValue
|
||||
: props.value,
|
||||
defaultValue: () => props.defaultValue,
|
||||
onChange: (value) => {
|
||||
field.edit();
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
},
|
||||
disabled: () => field.field.disabled.value,
|
||||
readOnly: () => field.field.readOnly.value,
|
||||
});
|
||||
const field = useChoiceField(props, attrs, {
|
||||
kind: "group",
|
||||
value: accepted.value,
|
||||
satisfied: () => accepted.value.value !== null,
|
||||
requiredMessage: "请填写此字段。",
|
||||
validate: (value) => {
|
||||
if (value && props.minValue && value.compare(props.minValue) < 0)
|
||||
return "日期不能早于最早日期。";
|
||||
if (value && props.maxValue && value.compare(props.maxValue) > 0)
|
||||
return "日期不能晚于最晚日期。";
|
||||
if (value && props.isDateUnavailable?.(value)) return "此日期不可用。";
|
||||
return props.validate?.(value);
|
||||
const owner = useDateFieldOwner(props, attrs, {
|
||||
onChange: (value) => {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
},
|
||||
});
|
||||
provide(disabledContextKey, field.field.disabled);
|
||||
provide(dateFieldKey, {
|
||||
value: accepted.value,
|
||||
disabled: field.field.disabled,
|
||||
readOnly: field.field.readOnly,
|
||||
required: field.field.required,
|
||||
invalid: field.field.invalid,
|
||||
leadingZeros: () => props.shouldForceLeadingZeros,
|
||||
labelledBy: field.labelledBy,
|
||||
describedBy: field.describedBy,
|
||||
ariaLabel: () => attrs["aria-label"],
|
||||
});
|
||||
const locale = computed(
|
||||
() => props.locale ?? config?.locale.value ?? "en-US",
|
||||
);
|
||||
// Capture a real local date only as the empty edit placeholder. DateValue
|
||||
// models never pass through JS Date or acquire the machine's time zone.
|
||||
const initialPlaceholder = (
|
||||
props.placeholderValue ??
|
||||
props.defaultValue ??
|
||||
accepted.value.value ??
|
||||
today(getLocalTimeZone())
|
||||
).copy();
|
||||
const lastPlaceholder = shallowRef(initialPlaceholder);
|
||||
watch(accepted.value, (value) => {
|
||||
if (value) lastPlaceholder.value = value.copy();
|
||||
});
|
||||
const placeholder = computed(() => {
|
||||
let value = dateForLocale(
|
||||
props.placeholderValue ?? accepted.value.value ?? lastPlaceholder.value,
|
||||
locale.value,
|
||||
);
|
||||
if (
|
||||
props.granularity &&
|
||||
props.granularity !== "day" &&
|
||||
!("hour" in value)
|
||||
)
|
||||
value = toCalendarDateTime(value);
|
||||
return value;
|
||||
});
|
||||
const wire = computed(() =>
|
||||
accepted.wire.value
|
||||
? dateForLocale(accepted.wire.value, locale.value)
|
||||
: null,
|
||||
);
|
||||
const root = ref<HTMLElement>(),
|
||||
native = ref<HTMLInputElement>(),
|
||||
proxy = ref<HTMLInputElement>();
|
||||
const focused = ref(false);
|
||||
const focusVisible = ref(false);
|
||||
const focus = () =>
|
||||
root.value
|
||||
?.querySelector<HTMLElement>(
|
||||
'[data-slot="date-input-group-segment"][tabindex="0"]',
|
||||
)
|
||||
?.focus();
|
||||
function request(value: DateValue | undefined) {
|
||||
const calendar =
|
||||
accepted.value.value?.calendar ??
|
||||
props.defaultValue?.calendar ??
|
||||
props.placeholderValue?.calendar ??
|
||||
initialPlaceholder.calendar;
|
||||
accepted.request(value ? toCalendar(value, calendar) : null);
|
||||
}
|
||||
function restoreNative() {
|
||||
if (native.value)
|
||||
native.value.value = serializeDateValue(accepted.value.value);
|
||||
}
|
||||
useChoiceForm(
|
||||
proxy,
|
||||
() => {
|
||||
accepted.reset();
|
||||
field.reset();
|
||||
},
|
||||
restoreNative,
|
||||
);
|
||||
watchEffect(() => field.validity(proxy.value), { flush: "post" });
|
||||
const signature = computed(
|
||||
() =>
|
||||
`${props.granularity ?? "auto"}|${props.hourCycle ?? "auto"}|${placeholder.value.calendar.identifier}|${"hour" in placeholder.value}`,
|
||||
);
|
||||
watch(signature, () => {
|
||||
const old = root.value?.ownerDocument.activeElement as HTMLElement | null;
|
||||
const part =
|
||||
old && root.value?.contains(old)
|
||||
? old.dataset.rekaDateFieldSegment
|
||||
: undefined;
|
||||
if (part)
|
||||
void nextTick(() => {
|
||||
const current = root.value?.ownerDocument.activeElement;
|
||||
if (current === old || current === root.value?.ownerDocument.body)
|
||||
root.value
|
||||
?.querySelector<HTMLElement>(
|
||||
`[data-reka-date-field-segment="${part}"]`,
|
||||
)
|
||||
?.focus();
|
||||
});
|
||||
});
|
||||
onMounted(() => {
|
||||
if (props.autoFocus) focus();
|
||||
if (props.autoFocus) owner.focus();
|
||||
});
|
||||
expose({ element: root, focus });
|
||||
expose({ element: owner.root, focus: owner.focus });
|
||||
return () => {
|
||||
const state = {
|
||||
value: accepted.value.value,
|
||||
isDisabled: field.field.disabled.value,
|
||||
isReadOnly: field.field.readOnly.value,
|
||||
isRequired: field.field.required.value,
|
||||
isInvalid: field.field.invalid.value,
|
||||
isFocusWithin: focused.value,
|
||||
isFocused: focused.value,
|
||||
isFocusVisible: focusVisible.value,
|
||||
validationErrors: field.field.errors.value,
|
||||
};
|
||||
const state = owner.state();
|
||||
const raw = slots.default?.(state);
|
||||
const children = field.prepare(
|
||||
const children = owner.field.prepare(
|
||||
Array.isArray(raw) ? raw : raw ? [raw] : [],
|
||||
true,
|
||||
);
|
||||
const overrides = {
|
||||
id: field.field.controlId.value,
|
||||
id: owner.field.field.controlId.value,
|
||||
role: "group",
|
||||
class: dateFieldVariants({ fullWidth: props.fullWidth }),
|
||||
"data-slot": "date-field",
|
||||
@@ -259,18 +93,18 @@ export default defineComponent({
|
||||
"data-readonly": state.isReadOnly || undefined,
|
||||
"data-invalid": state.isInvalid || undefined,
|
||||
"data-required": state.isRequired || undefined,
|
||||
"data-focus-within": focused.value || undefined,
|
||||
"data-focus-within": owner.focused.value || undefined,
|
||||
"aria-label": attrs["aria-label"],
|
||||
"aria-labelledby": field.labelledBy(),
|
||||
"aria-describedby": field.describedBy(),
|
||||
"aria-labelledby": owner.field.labelledBy(),
|
||||
"aria-describedby": owner.field.describedBy(),
|
||||
"aria-invalid": state.isInvalid || undefined,
|
||||
"aria-required": state.isRequired || undefined,
|
||||
ref: (element: unknown) => {
|
||||
root.value = element as HTMLElement;
|
||||
owner.root.value = element as HTMLElement;
|
||||
},
|
||||
onFocusin: (event: FocusEvent) => {
|
||||
focused.value = true;
|
||||
focusVisible.value = (event.target as HTMLElement).matches(
|
||||
owner.focused.value = true;
|
||||
owner.focusVisible.value = (event.target as HTMLElement).matches(
|
||||
":focus-visible",
|
||||
);
|
||||
},
|
||||
@@ -280,104 +114,16 @@ export default defineComponent({
|
||||
event.relatedTarget as Node | null,
|
||||
)
|
||||
) {
|
||||
focused.value = false;
|
||||
focusVisible.value = false;
|
||||
owner.focused.value = false;
|
||||
owner.focusVisible.value = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
return h(
|
||||
DateFieldRoot,
|
||||
{
|
||||
key: signature.value,
|
||||
asChild: true,
|
||||
modelValue: wire.value,
|
||||
placeholder: placeholder.value,
|
||||
granularity: props.granularity,
|
||||
hourCycle: props.hourCycle,
|
||||
hideTimeZone: props.hideTimeZone,
|
||||
locale: locale.value,
|
||||
dir: props.dir ?? config?.dir.value,
|
||||
disabled: state.isDisabled,
|
||||
readonly: state.isReadOnly,
|
||||
// The base is nameless and unconstrained: its native input truncates
|
||||
// time and cannot represent zones or non-Gregorian values faithfully.
|
||||
"onUpdate:modelValue": request,
|
||||
},
|
||||
{
|
||||
default: ({
|
||||
segments,
|
||||
}: {
|
||||
segments: Pick<DateSegment, "part" | "value">[];
|
||||
}) =>
|
||||
h(
|
||||
PrimitiveNode,
|
||||
{ as: props.as, consumer: attrs, overrides },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
DateSegments,
|
||||
{ segments },
|
||||
{
|
||||
default: () => [
|
||||
...children,
|
||||
h(EmptyDateBridge, {
|
||||
revision: accepted.emptyRevision.value,
|
||||
}),
|
||||
h("input", {
|
||||
ref: native,
|
||||
type: "text",
|
||||
class: "hv-choice-input",
|
||||
tabindex: -1,
|
||||
"aria-hidden": "true",
|
||||
autoComplete: props.autoComplete ?? "off",
|
||||
readonly: state.isReadOnly,
|
||||
onFocus: focus,
|
||||
onInput: (event: Event) => {
|
||||
if (
|
||||
event.defaultPrevented ||
|
||||
state.isDisabled ||
|
||||
state.isReadOnly
|
||||
) {
|
||||
restoreNative();
|
||||
return;
|
||||
}
|
||||
const text = (event.target as HTMLInputElement)
|
||||
.value;
|
||||
try {
|
||||
request(
|
||||
!text
|
||||
? undefined
|
||||
: text.includes("[")
|
||||
? parseZonedDateTime(text)
|
||||
: text.includes("T")
|
||||
? parseDateTime(text)
|
||||
: parseDate(text),
|
||||
);
|
||||
} catch {
|
||||
restoreNative();
|
||||
}
|
||||
void nextTick(restoreNative);
|
||||
},
|
||||
name: props.name,
|
||||
form: props.form,
|
||||
value: serializeDateValue(accepted.value.value),
|
||||
disabled: state.isDisabled,
|
||||
"data-slot": "date-field-value",
|
||||
}),
|
||||
validationInput(
|
||||
proxy,
|
||||
props,
|
||||
state.isDisabled || state.isReadOnly,
|
||||
field.behavior.value,
|
||||
(event) => field.invalidEvent(event, focus),
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
return owner.renderOwner([...children, ...owner.inputNodes()], {
|
||||
as: props.as,
|
||||
consumer: attrs,
|
||||
overrides,
|
||||
});
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
import {
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
h,
|
||||
nextTick,
|
||||
provide,
|
||||
ref,
|
||||
shallowRef,
|
||||
watch,
|
||||
watchEffect,
|
||||
type VNodeChild,
|
||||
} from "vue";
|
||||
import { DateFieldRoot } from "reka-ui";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
parseDate,
|
||||
parseDateTime,
|
||||
parseZonedDateTime,
|
||||
toCalendar,
|
||||
toCalendarDateTime,
|
||||
today,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { useConfig } from "../../providers/context";
|
||||
import {
|
||||
useChoiceField,
|
||||
useChoiceForm,
|
||||
validationInput,
|
||||
} from "../choice/shared";
|
||||
import type { ChoiceFieldProps } from "../choice/shared";
|
||||
import { disabledContextKey } from "../field/disabled";
|
||||
import type { ValidateResult } from "../field/context";
|
||||
import { useAcceptedDateValue } from "../date/model";
|
||||
import { dateForLocale, serializeDateValue } from "../date/value";
|
||||
import EmptyDateBridge from "../date/EmptyDateBridge";
|
||||
import PrimitiveNode from "./PrimitiveNode";
|
||||
import DateSegments from "./DateSegments";
|
||||
import { dateFieldKey, type DateSegment } from "./context";
|
||||
|
||||
/** The props shared by DateField and DatePicker's field owner. */
|
||||
export interface DateFieldOwnerProps extends ChoiceFieldProps {
|
||||
modelValue?: DateValue | null;
|
||||
value?: DateValue | null;
|
||||
defaultValue?: DateValue | null;
|
||||
placeholderValue?: DateValue | null;
|
||||
minValue?: DateValue | null;
|
||||
maxValue?: DateValue | null;
|
||||
isDateUnavailable?: (value: DateValue) => boolean;
|
||||
granularity?: "day" | "hour" | "minute" | "second";
|
||||
hourCycle?: 12 | 24;
|
||||
hideTimeZone?: boolean;
|
||||
shouldForceLeadingZeros?: boolean;
|
||||
locale?: string;
|
||||
dir?: "ltr" | "rtl";
|
||||
autoComplete?: string;
|
||||
validate?: (value: DateValue | null) => ValidateResult;
|
||||
}
|
||||
|
||||
export interface DateFieldOwnerRoot {
|
||||
as: string;
|
||||
consumer?: Record<string, unknown>;
|
||||
overrides: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* One accepted date model, field context and native submission layer for both
|
||||
* standalone DateField and a DatePicker-owned field. Components remain
|
||||
* responsible for their own root element and public render state.
|
||||
*/
|
||||
export function useDateFieldOwner(
|
||||
props: DateFieldOwnerProps,
|
||||
attrs: Record<string, unknown>,
|
||||
options: { onChange: (value: DateValue | null) => void },
|
||||
) {
|
||||
const config = useConfig();
|
||||
const instance = getCurrentInstance()!;
|
||||
const accepted: ReturnType<typeof useAcceptedDateValue<DateValue>> =
|
||||
useAcceptedDateValue<DateValue>({
|
||||
value: () =>
|
||||
["modelValue", "model-value"].some((key) =>
|
||||
Object.hasOwn(instance.vnode.props ?? {}, key),
|
||||
)
|
||||
? props.modelValue
|
||||
: props.value,
|
||||
defaultValue: () => props.defaultValue,
|
||||
onChange: (value) => {
|
||||
field.edit();
|
||||
options.onChange(value);
|
||||
},
|
||||
disabled: () => field.field.disabled.value,
|
||||
readOnly: () => field.field.readOnly.value,
|
||||
});
|
||||
const field = useChoiceField(props, attrs, {
|
||||
kind: "group",
|
||||
value: accepted.value,
|
||||
satisfied: () => accepted.value.value !== null,
|
||||
requiredMessage: "请填写此字段。",
|
||||
validate: (value) => {
|
||||
if (value && props.minValue && value.compare(props.minValue) < 0)
|
||||
return "日期不能早于最早日期。";
|
||||
if (value && props.maxValue && value.compare(props.maxValue) > 0)
|
||||
return "日期不能晚于最晚日期。";
|
||||
if (value && props.isDateUnavailable?.(value)) return "此日期不可用。";
|
||||
return props.validate?.(value);
|
||||
},
|
||||
});
|
||||
provide(disabledContextKey, field.field.disabled);
|
||||
provide(dateFieldKey, {
|
||||
value: accepted.value,
|
||||
disabled: field.field.disabled,
|
||||
readOnly: field.field.readOnly,
|
||||
required: field.field.required,
|
||||
invalid: field.field.invalid,
|
||||
leadingZeros: () => props.shouldForceLeadingZeros,
|
||||
labelledBy: field.labelledBy,
|
||||
describedBy: field.describedBy,
|
||||
ariaLabel: () => attrs["aria-label"],
|
||||
});
|
||||
const locale = computed(
|
||||
() => props.locale ?? config?.locale.value ?? "en-US",
|
||||
);
|
||||
// Capture a real local date only as the empty edit placeholder. DateValue
|
||||
// models never pass through JS Date or acquire the machine's time zone.
|
||||
const initialPlaceholder = (
|
||||
props.placeholderValue ??
|
||||
props.defaultValue ??
|
||||
accepted.value.value ??
|
||||
today(getLocalTimeZone())
|
||||
).copy();
|
||||
const lastPlaceholder = shallowRef(initialPlaceholder);
|
||||
watch(accepted.value, (value) => {
|
||||
if (value) lastPlaceholder.value = value.copy();
|
||||
});
|
||||
const placeholder = computed(() => {
|
||||
let value = dateForLocale(
|
||||
props.placeholderValue ?? accepted.value.value ?? lastPlaceholder.value,
|
||||
locale.value,
|
||||
);
|
||||
if (props.granularity && props.granularity !== "day" && !("hour" in value))
|
||||
value = toCalendarDateTime(value);
|
||||
return value;
|
||||
});
|
||||
const wire = computed(() =>
|
||||
accepted.wire.value
|
||||
? dateForLocale(accepted.wire.value, locale.value)
|
||||
: null,
|
||||
);
|
||||
const root = ref<HTMLElement>(),
|
||||
native = ref<HTMLInputElement>(),
|
||||
proxy = ref<HTMLInputElement>();
|
||||
const focused = ref(false);
|
||||
const focusVisible = ref(false);
|
||||
const focus = () =>
|
||||
root.value
|
||||
?.querySelector<HTMLElement>(
|
||||
'[data-slot="date-input-group-segment"][tabindex="0"]',
|
||||
)
|
||||
?.focus();
|
||||
function requestInput(value: DateValue | undefined) {
|
||||
const calendar =
|
||||
accepted.value.value?.calendar ??
|
||||
props.defaultValue?.calendar ??
|
||||
props.placeholderValue?.calendar ??
|
||||
initialPlaceholder.calendar;
|
||||
accepted.request(value ? toCalendar(value, calendar) : null);
|
||||
}
|
||||
function restoreNative() {
|
||||
if (native.value)
|
||||
native.value.value = serializeDateValue(accepted.value.value);
|
||||
}
|
||||
useChoiceForm(
|
||||
proxy,
|
||||
() => {
|
||||
accepted.reset();
|
||||
field.reset();
|
||||
},
|
||||
restoreNative,
|
||||
);
|
||||
watchEffect(() => field.validity(proxy.value), { flush: "post" });
|
||||
const signature = computed(
|
||||
() =>
|
||||
`${props.granularity ?? "auto"}|${props.hourCycle ?? "auto"}|${placeholder.value.calendar.identifier}|${"hour" in placeholder.value}`,
|
||||
);
|
||||
watch(signature, () => {
|
||||
const old = root.value?.ownerDocument.activeElement as HTMLElement | null;
|
||||
const part =
|
||||
old && root.value?.contains(old)
|
||||
? old.dataset.rekaDateFieldSegment
|
||||
: undefined;
|
||||
if (part)
|
||||
void nextTick(() => {
|
||||
const current = root.value?.ownerDocument.activeElement;
|
||||
if (current === old || current === root.value?.ownerDocument.body)
|
||||
root.value
|
||||
?.querySelector<HTMLElement>(
|
||||
`[data-reka-date-field-segment="${part}"]`,
|
||||
)
|
||||
?.focus();
|
||||
});
|
||||
});
|
||||
function state() {
|
||||
return {
|
||||
value: accepted.value.value,
|
||||
isDisabled: field.field.disabled.value,
|
||||
isReadOnly: field.field.readOnly.value,
|
||||
isRequired: field.field.required.value,
|
||||
isInvalid: field.field.invalid.value,
|
||||
isFocusWithin: focused.value,
|
||||
isFocused: focused.value,
|
||||
isFocusVisible: focusVisible.value,
|
||||
validationErrors: field.field.errors.value,
|
||||
};
|
||||
}
|
||||
function inputNodes(valueSlot = "date-field-value") {
|
||||
return [
|
||||
h(EmptyDateBridge, { revision: accepted.emptyRevision.value }),
|
||||
h("input", {
|
||||
ref: native,
|
||||
type: "text",
|
||||
class: "hv-choice-input",
|
||||
tabindex: -1,
|
||||
"aria-hidden": "true",
|
||||
autoComplete: props.autoComplete ?? "off",
|
||||
readonly: field.field.readOnly.value,
|
||||
onFocus: focus,
|
||||
onInput: (event: Event) => {
|
||||
if (
|
||||
event.defaultPrevented ||
|
||||
field.field.disabled.value ||
|
||||
field.field.readOnly.value
|
||||
) {
|
||||
restoreNative();
|
||||
return;
|
||||
}
|
||||
const text = (event.target as HTMLInputElement).value;
|
||||
try {
|
||||
requestInput(
|
||||
!text
|
||||
? undefined
|
||||
: text.includes("[")
|
||||
? parseZonedDateTime(text)
|
||||
: text.includes("T")
|
||||
? parseDateTime(text)
|
||||
: parseDate(text),
|
||||
);
|
||||
} catch {
|
||||
restoreNative();
|
||||
}
|
||||
void nextTick(restoreNative);
|
||||
},
|
||||
name: props.name,
|
||||
form: props.form,
|
||||
value: serializeDateValue(accepted.value.value),
|
||||
disabled: field.field.disabled.value,
|
||||
"data-slot": valueSlot,
|
||||
}),
|
||||
validationInput(
|
||||
proxy,
|
||||
props,
|
||||
field.field.disabled.value || field.field.readOnly.value,
|
||||
field.behavior.value,
|
||||
(event) => field.invalidEvent(event, focus),
|
||||
),
|
||||
];
|
||||
}
|
||||
function renderOwner(children: VNodeChild[], rootConfig: DateFieldOwnerRoot) {
|
||||
return h(
|
||||
DateFieldRoot,
|
||||
{
|
||||
key: signature.value,
|
||||
asChild: true,
|
||||
modelValue: wire.value,
|
||||
placeholder: placeholder.value,
|
||||
granularity: props.granularity,
|
||||
hourCycle: props.hourCycle,
|
||||
hideTimeZone: props.hideTimeZone,
|
||||
locale: locale.value,
|
||||
dir: props.dir ?? config?.dir?.value,
|
||||
disabled: field.field.disabled.value,
|
||||
readonly: field.field.readOnly.value,
|
||||
// The base is nameless and unconstrained: its native input truncates
|
||||
// time and cannot represent zones or non-Gregorian values faithfully.
|
||||
"onUpdate:modelValue": requestInput,
|
||||
},
|
||||
{
|
||||
default: ({
|
||||
segments,
|
||||
}: {
|
||||
segments: Pick<DateSegment, "part" | "value">[];
|
||||
}) =>
|
||||
h(
|
||||
PrimitiveNode,
|
||||
{
|
||||
as: rootConfig.as,
|
||||
consumer: rootConfig.consumer,
|
||||
overrides: rootConfig.overrides,
|
||||
},
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
DateSegments,
|
||||
{ segments },
|
||||
{
|
||||
default: () => children,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
return {
|
||||
accepted,
|
||||
field,
|
||||
locale,
|
||||
placeholder,
|
||||
wire,
|
||||
root,
|
||||
native,
|
||||
proxy,
|
||||
focused,
|
||||
focusVisible,
|
||||
focus,
|
||||
requestInput,
|
||||
restoreNative,
|
||||
signature,
|
||||
state,
|
||||
inputNodes,
|
||||
renderOwner,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
computed,
|
||||
defineComponent,
|
||||
h,
|
||||
nextTick,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
provide,
|
||||
shallowRef,
|
||||
watch,
|
||||
type PropType,
|
||||
type SlotsType,
|
||||
type VNodeChild,
|
||||
} from "vue";
|
||||
import { PopoverRoot } from "reka-ui";
|
||||
import {
|
||||
getLocalTimeZone,
|
||||
isSameDay,
|
||||
Time,
|
||||
toCalendar,
|
||||
toCalendarDate,
|
||||
toCalendarDateTime,
|
||||
today,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import { datePickerVariants } from "@heroui-vue/styles";
|
||||
import { useConfig } from "../../providers/context";
|
||||
import { useOverlayState } from "../../composables/useOverlayState";
|
||||
import { copyDateValue } from "../date/value";
|
||||
import { createPopoverContext, popoverKey } from "../popover/context";
|
||||
import { overlayNodes } from "../overlay/OverlayAction";
|
||||
import type { ValidationBehavior, ValidateResult } from "../field/context";
|
||||
import { useDateFieldOwner } from "../date-field/owner";
|
||||
import {
|
||||
datePickerKey,
|
||||
type DatePickerRenderProps,
|
||||
type DatePickerTimeValue,
|
||||
} from "./context";
|
||||
|
||||
export default defineComponent({
|
||||
name: "DatePicker",
|
||||
inheritAttrs: false,
|
||||
slots: Object as SlotsType<{
|
||||
default?: (state: DatePickerRenderProps) => VNodeChild;
|
||||
}>,
|
||||
props: {
|
||||
modelValue: {
|
||||
type: [Object, null] as PropType<DateValue | null>,
|
||||
default: undefined,
|
||||
},
|
||||
value: {
|
||||
type: [Object, null] as PropType<DateValue | null>,
|
||||
default: undefined,
|
||||
},
|
||||
defaultValue: [Object, null] as PropType<DateValue | null>,
|
||||
placeholderValue: [Object, null] as PropType<DateValue | null>,
|
||||
minValue: [Object, null] as PropType<DateValue | null>,
|
||||
maxValue: [Object, null] as PropType<DateValue | null>,
|
||||
isDateUnavailable: Function as PropType<(value: DateValue) => boolean>,
|
||||
granularity: String as PropType<"day" | "hour" | "minute" | "second">,
|
||||
hourCycle: Number as PropType<12 | 24>,
|
||||
hideTimeZone: Boolean,
|
||||
shouldForceLeadingZeros: { type: Boolean, default: undefined },
|
||||
locale: String,
|
||||
dir: String as PropType<"ltr" | "rtl">,
|
||||
firstDayOfWeek: String as PropType<
|
||||
import("../date/calendar").CalendarWeekday
|
||||
>,
|
||||
pageBehavior: String as PropType<"visible" | "single">,
|
||||
as: { type: String, default: "div" },
|
||||
id: String,
|
||||
name: String,
|
||||
form: String,
|
||||
isDisabled: Boolean,
|
||||
disabled: Boolean,
|
||||
isReadOnly: Boolean,
|
||||
isRequired: Boolean,
|
||||
isInvalid: Boolean,
|
||||
autoFocus: Boolean,
|
||||
autoComplete: String,
|
||||
validationBehavior: String as PropType<ValidationBehavior>,
|
||||
validate: Function as PropType<(value: DateValue | null) => ValidateResult>,
|
||||
open: { type: Boolean, default: undefined },
|
||||
isOpen: { type: Boolean, default: undefined },
|
||||
defaultOpen: Boolean,
|
||||
shouldCloseOnSelect: { type: Boolean, default: true },
|
||||
},
|
||||
emits: {
|
||||
"update:modelValue": (_value: DateValue | null) => true,
|
||||
change: (_value: DateValue | null) => true,
|
||||
"update:open": (_value: boolean) => true,
|
||||
"update:isOpen": (_value: boolean) => true,
|
||||
openChange: (_value: boolean) => true,
|
||||
},
|
||||
setup(props, { attrs, slots, emit, expose }) {
|
||||
const config = useConfig();
|
||||
const dir = computed<"ltr" | "rtl">(
|
||||
() => props.dir ?? config?.dir?.value ?? "ltr",
|
||||
);
|
||||
const state = useOverlayState({
|
||||
isOpen: () => props.open ?? props.isOpen,
|
||||
defaultOpen: props.defaultOpen,
|
||||
onOpenChange(value) {
|
||||
emit("update:open", value);
|
||||
emit("update:isOpen", value);
|
||||
emit("openChange", value);
|
||||
},
|
||||
});
|
||||
const owner = useDateFieldOwner(props, attrs, {
|
||||
onChange: (value) => {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
},
|
||||
});
|
||||
const pendingTime = shallowRef<Time | null>(null);
|
||||
watch(owner.accepted.value, (value) => {
|
||||
if (value) pendingTime.value = null;
|
||||
});
|
||||
const timeValue = computed<DatePickerTimeValue | null>(() => {
|
||||
const value = owner.accepted.value.value;
|
||||
if (value && "hour" in value)
|
||||
return new Time(
|
||||
value.hour,
|
||||
value.minute,
|
||||
value.second,
|
||||
value.millisecond,
|
||||
);
|
||||
return pendingTime.value;
|
||||
});
|
||||
function emptyTemplate(): DateValue {
|
||||
const sample =
|
||||
props.placeholderValue ??
|
||||
props.defaultValue ??
|
||||
today(getLocalTimeZone());
|
||||
if ((props.granularity ?? "day") === "day") return toCalendarDate(sample);
|
||||
let base: DateValue =
|
||||
"hour" in sample ? sample : toCalendarDateTime(sample);
|
||||
if (pendingTime.value)
|
||||
base = base.set({
|
||||
hour: pendingTime.value.hour,
|
||||
minute: pendingTime.value.minute,
|
||||
second: pendingTime.value.second,
|
||||
millisecond: pendingTime.value.millisecond,
|
||||
});
|
||||
return base;
|
||||
}
|
||||
function requestDate(value: DateValue) {
|
||||
if (owner.field.field.disabled.value || owner.field.field.readOnly.value)
|
||||
return;
|
||||
const template = owner.accepted.value.value ?? emptyTemplate();
|
||||
const day = toCalendar(value, template.calendar);
|
||||
const next = template.set({
|
||||
era: day.era,
|
||||
year: day.year,
|
||||
month: day.month,
|
||||
day: day.day,
|
||||
});
|
||||
owner.accepted.request(copyDateValue(next));
|
||||
if (props.shouldCloseOnSelect) state.close();
|
||||
}
|
||||
function setTimeValue(value: DatePickerTimeValue | null) {
|
||||
if (!value) {
|
||||
pendingTime.value = null;
|
||||
return;
|
||||
}
|
||||
const time = new Time(
|
||||
value.hour,
|
||||
value.minute,
|
||||
value.second,
|
||||
value.millisecond,
|
||||
);
|
||||
const current = owner.accepted.value.value;
|
||||
if (!current) {
|
||||
pendingTime.value = time;
|
||||
return;
|
||||
}
|
||||
let next: DateValue =
|
||||
"hour" in current ? current : toCalendarDateTime(current);
|
||||
next = next.set({
|
||||
hour: time.hour,
|
||||
minute: time.minute,
|
||||
second: time.second,
|
||||
millisecond: time.millisecond,
|
||||
});
|
||||
owner.accepted.request(copyDateValue(next));
|
||||
}
|
||||
function setValue(value: DateValue | null) {
|
||||
owner.accepted.request(copyDateValue(value));
|
||||
}
|
||||
const trigger = shallowRef<HTMLElement>();
|
||||
const popover = createPopoverContext(state);
|
||||
provide(popoverKey, popover);
|
||||
provide(datePickerKey, {
|
||||
state,
|
||||
trigger,
|
||||
value: owner.accepted.value,
|
||||
dates: computed(() => {
|
||||
const value = owner.accepted.value.value;
|
||||
return value ? [value] : [];
|
||||
}),
|
||||
selected: (value) =>
|
||||
!!owner.accepted.value.value &&
|
||||
isSameDay(owner.accepted.value.value, value),
|
||||
requestDate,
|
||||
minValue: computed(() => props.minValue ?? undefined),
|
||||
maxValue: computed(() => props.maxValue ?? undefined),
|
||||
isDateUnavailable: props.isDateUnavailable,
|
||||
disabled: owner.field.field.disabled,
|
||||
readOnly: owner.field.field.readOnly,
|
||||
invalid: owner.field.field.invalid,
|
||||
locale: owner.locale,
|
||||
dir,
|
||||
labelledBy: owner.field.labelledBy,
|
||||
describedBy: owner.field.describedBy,
|
||||
firstDayOfWeek: props.firstDayOfWeek,
|
||||
pageBehavior: props.pageBehavior,
|
||||
placeholder: owner.placeholder,
|
||||
timeValue,
|
||||
setTimeValue,
|
||||
shouldCloseOnSelect: () => props.shouldCloseOnSelect,
|
||||
});
|
||||
let restoreFocus = false;
|
||||
const doc = typeof document === "undefined" ? undefined : document;
|
||||
function trackKeyboard(event: KeyboardEvent) {
|
||||
if (!event.metaKey && !event.ctrlKey && !event.altKey)
|
||||
restoreFocus = true;
|
||||
}
|
||||
function closeFromPicker(event: KeyboardEvent) {
|
||||
if (
|
||||
event.key !== "Escape" ||
|
||||
event.isComposing ||
|
||||
event.defaultPrevented ||
|
||||
!state.isOpen.value
|
||||
)
|
||||
return;
|
||||
const target = event.target as HTMLElement | null;
|
||||
if (!target) return;
|
||||
const content = doc?.getElementById(popover.contentId.value) ?? null;
|
||||
const inField = !!owner.root.value?.contains(target);
|
||||
const inContent = !!content?.contains(target);
|
||||
if (!inField && !inContent) return;
|
||||
// An open year layer owns its own Escape and restores focus itself.
|
||||
if (
|
||||
content?.querySelector(
|
||||
'[data-slot="calendar-year-picker-grid"][data-open]',
|
||||
)
|
||||
)
|
||||
return;
|
||||
// The installed date/time segment base prevents every non-Tab key,
|
||||
// including Escape. Modal popovers can also out-rank the picker layer.
|
||||
// The picker owns this dismissal path explicitly.
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
state.close();
|
||||
}
|
||||
function onDocumentKeydown(event: KeyboardEvent) {
|
||||
trackKeyboard(event);
|
||||
closeFromPicker(event);
|
||||
}
|
||||
watch(
|
||||
state.isOpen,
|
||||
(open) => {
|
||||
if (open) doc?.addEventListener("keydown", onDocumentKeydown, true);
|
||||
else {
|
||||
doc?.removeEventListener("keydown", onDocumentKeydown, true);
|
||||
if (restoreFocus) {
|
||||
const run = () => trigger.value?.focus({ preventScroll: true });
|
||||
if (typeof requestAnimationFrame === "function")
|
||||
requestAnimationFrame(run);
|
||||
else void nextTick(run);
|
||||
}
|
||||
restoreFocus = false;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
onMounted(() => {
|
||||
if (props.autoFocus) owner.focus();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
doc?.removeEventListener("keydown", onDocumentKeydown, true);
|
||||
});
|
||||
expose({
|
||||
element: owner.root,
|
||||
focus: owner.focus,
|
||||
open: state.open,
|
||||
close: state.close,
|
||||
toggle: state.toggle,
|
||||
});
|
||||
return () => {
|
||||
const base = owner.state();
|
||||
const pickerState = {
|
||||
value: owner.accepted.value.value,
|
||||
timeValue: timeValue.value,
|
||||
setValue,
|
||||
setTimeValue,
|
||||
};
|
||||
const renderState: DatePickerRenderProps = {
|
||||
...base,
|
||||
isOpen: state.isOpen.value,
|
||||
timeValue: timeValue.value,
|
||||
state: pickerState,
|
||||
open: state.open,
|
||||
close: state.close,
|
||||
toggle: state.toggle,
|
||||
};
|
||||
const raw = slots.default?.(renderState);
|
||||
const children = owner.field.prepare(
|
||||
Array.isArray(raw) ? raw : raw ? [raw] : [],
|
||||
true,
|
||||
);
|
||||
const overrides = {
|
||||
id: owner.field.field.controlId.value,
|
||||
role: "group",
|
||||
class: datePickerVariants().base(),
|
||||
"data-slot": "date-picker",
|
||||
"data-disabled": base.isDisabled || undefined,
|
||||
"data-readonly": base.isReadOnly || undefined,
|
||||
"data-invalid": base.isInvalid || undefined,
|
||||
"data-required": base.isRequired || undefined,
|
||||
"data-focus-within": owner.focused.value || undefined,
|
||||
"aria-label": attrs["aria-label"],
|
||||
"aria-labelledby": owner.field.labelledBy(),
|
||||
"aria-describedby": owner.field.describedBy(),
|
||||
"aria-invalid": base.isInvalid || undefined,
|
||||
"aria-required": base.isRequired || undefined,
|
||||
dir: dir.value,
|
||||
ref: (element: unknown) => {
|
||||
owner.root.value = element as HTMLElement;
|
||||
},
|
||||
onFocusin: (event: FocusEvent) => {
|
||||
owner.focused.value = true;
|
||||
owner.focusVisible.value = (event.target as HTMLElement).matches(
|
||||
":focus-visible",
|
||||
);
|
||||
},
|
||||
onFocusout: (event: FocusEvent) => {
|
||||
if (
|
||||
!(event.currentTarget as HTMLElement).contains(
|
||||
event.relatedTarget as Node | null,
|
||||
)
|
||||
) {
|
||||
owner.focused.value = false;
|
||||
owner.focusVisible.value = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
return h(
|
||||
PopoverRoot,
|
||||
{
|
||||
open: state.isOpen.value,
|
||||
modal: true,
|
||||
"onUpdate:open": state.setOpen,
|
||||
},
|
||||
{
|
||||
default: () =>
|
||||
owner.renderOwner(
|
||||
[
|
||||
...overlayNodes(children),
|
||||
...owner.inputNodes("date-picker-value"),
|
||||
],
|
||||
{ as: props.as, consumer: attrs, overrides },
|
||||
),
|
||||
},
|
||||
);
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { useAttrs } from "vue";
|
||||
import { datePickerVariants } from "@heroui-vue/styles";
|
||||
import type { OverlayPlacement } from "../overlay/placement";
|
||||
import PopoverContent from "../popover/PopoverContent.vue";
|
||||
import { useDatePicker } from "./context";
|
||||
defineOptions({ name: "DatePickerPopover", inheritAttrs: false });
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
as?: string;
|
||||
placement?: OverlayPlacement;
|
||||
offset?: number;
|
||||
crossOffset?: number;
|
||||
shouldFlip?: boolean;
|
||||
containerPadding?: number;
|
||||
to?: string | HTMLElement;
|
||||
isNonModal?: boolean;
|
||||
isDismissable?: boolean;
|
||||
isKeyboardDismissDisabled?: boolean;
|
||||
}>(),
|
||||
{
|
||||
as: "div",
|
||||
placement: "bottom",
|
||||
offset: 8,
|
||||
crossOffset: 0,
|
||||
shouldFlip: true,
|
||||
containerPadding: 12,
|
||||
isNonModal: undefined,
|
||||
isDismissable: true,
|
||||
isKeyboardDismissDisabled: false,
|
||||
},
|
||||
);
|
||||
const picker = useDatePicker();
|
||||
const attrs = useAttrs();
|
||||
function openAutoFocus(event: Event) {
|
||||
// The calendar cell owns initial focus; the dialog surface must not steal it.
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<PopoverContent
|
||||
v-bind="$attrs"
|
||||
:as="as"
|
||||
:placement="placement"
|
||||
:offset="offset"
|
||||
:cross-offset="crossOffset"
|
||||
:should-flip="shouldFlip"
|
||||
:container-padding="containerPadding"
|
||||
:to="to"
|
||||
:is-non-modal="isNonModal"
|
||||
:is-dismissable="isDismissable"
|
||||
:is-keyboard-dismiss-disabled="isKeyboardDismissDisabled"
|
||||
:lang="(attrs.lang as string | undefined) ?? picker.locale.value"
|
||||
:class="datePickerVariants().popover()"
|
||||
data-slot="date-picker-popover"
|
||||
@open-auto-focus="openAutoFocus"
|
||||
>
|
||||
<slot />
|
||||
</PopoverContent>
|
||||
</template>
|
||||
@@ -0,0 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, useAttrs, watch } from "vue";
|
||||
import { PopoverAnchor, useForwardExpose } from "reka-ui";
|
||||
import { datePickerVariants } from "@heroui-vue/styles";
|
||||
import OverlayAction from "../overlay/OverlayAction";
|
||||
import { usePopover } from "../popover/context";
|
||||
import { useDatePicker } from "./context";
|
||||
defineOptions({ name: "DatePickerTrigger", inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{ as?: string; asChild?: boolean; isDisabled?: boolean }>(),
|
||||
{ as: "button" },
|
||||
);
|
||||
const popover = usePopover();
|
||||
const picker = useDatePicker();
|
||||
const attrs = useAttrs();
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
const focusVisible = ref(false);
|
||||
const disabled = computed(
|
||||
() => props.isDisabled || picker.disabled.value || picker.readOnly.value,
|
||||
);
|
||||
const defaultLabelledBy = computed(() => {
|
||||
if (attrs["aria-label"] || attrs["aria-labelledby"]) return undefined;
|
||||
const ids = [popover.triggerId, picker.labelledBy()].filter(Boolean);
|
||||
return ids.length ? ids.join(" ") : undefined;
|
||||
});
|
||||
const defaultLabel = computed(() => {
|
||||
if (attrs["aria-label"] || attrs["aria-labelledby"]) return undefined;
|
||||
if (defaultLabelledBy.value) return undefined;
|
||||
return picker.locale.value.toLowerCase().startsWith("zh")
|
||||
? "日历"
|
||||
: "Calendar";
|
||||
});
|
||||
watch(
|
||||
currentElement,
|
||||
(element) => {
|
||||
picker.trigger.value = element;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<PopoverAnchor as-child>
|
||||
<OverlayAction
|
||||
:ref="forwardRef"
|
||||
v-bind="$attrs"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:is-disabled="disabled"
|
||||
:activate="popover.state.toggle"
|
||||
:class="datePickerVariants().trigger()"
|
||||
data-slot="date-picker-trigger"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="popover.state.isOpen.value"
|
||||
:aria-controls="
|
||||
popover.state.isOpen.value ? popover.contentId.value : undefined
|
||||
"
|
||||
:aria-label="($attrs['aria-label'] as string | undefined) ?? defaultLabel"
|
||||
:aria-labelledby="
|
||||
($attrs['aria-labelledby'] as string | undefined) ?? defaultLabelledBy
|
||||
"
|
||||
:aria-describedby="
|
||||
($attrs['aria-describedby'] as string | undefined) ??
|
||||
picker.describedBy()
|
||||
"
|
||||
:data-open="popover.state.isOpen.value || undefined"
|
||||
:data-disabled="disabled || undefined"
|
||||
:data-focus-visible="focusVisible || undefined"
|
||||
@focus="focusVisible = true"
|
||||
@blur="focusVisible = false"
|
||||
>
|
||||
<slot />
|
||||
</OverlayAction>
|
||||
</PopoverAnchor>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { datePickerVariants } from "@heroui-vue/styles";
|
||||
defineOptions({ name: "DatePickerTriggerIndicator", inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "span" });
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
aria-hidden="true"
|
||||
:class="datePickerVariants().triggerIndicator()"
|
||||
data-slot="date-picker-trigger-indicator"
|
||||
>
|
||||
<slot>
|
||||
<!-- Adapted from HeroUI ce90ea3 IconCalendar; Apache-2.0. -->
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="none"
|
||||
height="1em"
|
||||
role="presentation"
|
||||
viewBox="0 0 13 14"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M3.75 4.5A.75.75 0 0 1 3 3.75v-.748a1.5 1.5 0 0 0-1.5 1.5v1h10v-1a1.5 1.5 0 0 0-1.5-1.5v.75a.75.75 0 1 1-1.5 0v-.75h-4v.747a.75.75 0 0 1-.75.75ZM8.5 1.501h-4V.75a.75.75 0 0 0-1.5 0v.752a3 3 0 0 0-3 3v6a3 3 0 0 0 3 3h7a3 3 0 0 0 3-3v-6a3 3 0 0 0-3-3v-.75a.75.75 0 0 0-1.5 0v.75Zm-7 5.5v3.5a1.5 1.5 0 0 0 1.5 1.5h7a1.5 1.5 0 0 0 1.5-1.5v-3.5h-10Z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</slot>
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,75 @@
|
||||
import {
|
||||
inject,
|
||||
type ComputedRef,
|
||||
type InjectionKey,
|
||||
type ShallowRef,
|
||||
} from "vue";
|
||||
import type {
|
||||
CalendarDateTime,
|
||||
DateValue,
|
||||
Time,
|
||||
ZonedDateTime,
|
||||
} from "@internationalized/date";
|
||||
import type { OverlayState } from "../../composables/useOverlayState";
|
||||
|
||||
export type DatePickerTimeValue = Time | CalendarDateTime | ZonedDateTime;
|
||||
|
||||
export interface DatePickerState {
|
||||
value: DateValue | null;
|
||||
timeValue: DatePickerTimeValue | null;
|
||||
setValue: (value: DateValue | null) => void;
|
||||
setTimeValue: (value: DatePickerTimeValue | null) => void;
|
||||
}
|
||||
|
||||
export interface DatePickerRenderProps {
|
||||
value: DateValue | null;
|
||||
isOpen: boolean;
|
||||
isDisabled: boolean;
|
||||
isReadOnly: boolean;
|
||||
isRequired: boolean;
|
||||
isInvalid: boolean;
|
||||
isFocusWithin: boolean;
|
||||
isFocused: boolean;
|
||||
isFocusVisible: boolean;
|
||||
validationErrors: string[];
|
||||
timeValue: DatePickerTimeValue | null;
|
||||
state: DatePickerState;
|
||||
open: () => void;
|
||||
close: () => void;
|
||||
toggle: () => void;
|
||||
}
|
||||
|
||||
/** Shared Picker owner consumed by the field parts and an unbound Calendar. */
|
||||
export interface DatePickerContext {
|
||||
state: OverlayState;
|
||||
trigger: ShallowRef<HTMLElement | undefined>;
|
||||
value: ComputedRef<DateValue | null>;
|
||||
dates: ComputedRef<DateValue[]>;
|
||||
selected: (value: DateValue) => boolean;
|
||||
requestDate: (value: DateValue) => void;
|
||||
minValue: ComputedRef<DateValue | undefined>;
|
||||
maxValue: ComputedRef<DateValue | undefined>;
|
||||
isDateUnavailable?: (value: DateValue) => boolean;
|
||||
disabled: ComputedRef<boolean>;
|
||||
readOnly: ComputedRef<boolean>;
|
||||
invalid: ComputedRef<boolean>;
|
||||
locale: ComputedRef<string>;
|
||||
dir: ComputedRef<"ltr" | "rtl">;
|
||||
labelledBy: () => string | undefined;
|
||||
describedBy: () => string | undefined;
|
||||
firstDayOfWeek?: import("../date/calendar").CalendarWeekday;
|
||||
pageBehavior?: "visible" | "single";
|
||||
placeholder: ComputedRef<DateValue>;
|
||||
timeValue: ComputedRef<DatePickerTimeValue | null>;
|
||||
setTimeValue: (value: DatePickerTimeValue | null) => void;
|
||||
shouldCloseOnSelect: () => boolean;
|
||||
}
|
||||
|
||||
export const datePickerKey: InjectionKey<DatePickerContext> =
|
||||
Symbol("hv-date-picker");
|
||||
|
||||
export function useDatePicker() {
|
||||
const value = inject(datePickerKey, undefined);
|
||||
if (!value) throw new Error("DatePicker parts require DatePicker.");
|
||||
return value;
|
||||
}
|
||||
@@ -780,6 +780,31 @@ export {
|
||||
} from "./components/date-field/DateInputGroupSuffix.vue";
|
||||
export type { DateSegment } from "./components/date-field/context";
|
||||
|
||||
export {
|
||||
default as DatePicker,
|
||||
default as DatePickerRoot,
|
||||
} from "./components/date-picker/DatePicker.vue";
|
||||
export { default as DatePickerTrigger } from "./components/date-picker/DatePickerTrigger.vue";
|
||||
export { default as DatePickerTriggerIndicator } from "./components/date-picker/DatePickerTriggerIndicator.vue";
|
||||
export { default as DatePickerPopover } from "./components/date-picker/DatePickerPopover.vue";
|
||||
export type {
|
||||
DatePickerRenderProps,
|
||||
DatePickerState,
|
||||
DatePickerTimeValue,
|
||||
} from "./components/date-picker/context";
|
||||
|
||||
export {
|
||||
datePickerVariants,
|
||||
type DatePickerVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
export type {
|
||||
DatePickerProps,
|
||||
DatePickerRootProps,
|
||||
DatePickerTriggerProps,
|
||||
DatePickerTriggerIndicatorProps,
|
||||
DatePickerPopoverProps,
|
||||
} from "./types";
|
||||
|
||||
export {
|
||||
dateFieldVariants,
|
||||
dateInputGroupVariants,
|
||||
|
||||
@@ -646,6 +646,22 @@ export type DateFieldInputContainerProps = DateInputGroupInputContainerProps;
|
||||
export type DateFieldPrefixProps = DateInputGroupPrefixProps;
|
||||
export type DateFieldSuffixProps = DateInputGroupSuffixProps;
|
||||
|
||||
import type DatePicker from "./components/date-picker/DatePicker.vue";
|
||||
import type DatePickerTrigger from "./components/date-picker/DatePickerTrigger.vue";
|
||||
import type DatePickerTriggerIndicator from "./components/date-picker/DatePickerTriggerIndicator.vue";
|
||||
import type DatePickerPopover from "./components/date-picker/DatePickerPopover.vue";
|
||||
export type DatePickerProps = InstanceType<typeof DatePicker>["$props"];
|
||||
export type DatePickerRootProps = DatePickerProps;
|
||||
export type DatePickerTriggerProps = InstanceType<
|
||||
typeof DatePickerTrigger
|
||||
>["$props"];
|
||||
export type DatePickerTriggerIndicatorProps = InstanceType<
|
||||
typeof DatePickerTriggerIndicator
|
||||
>["$props"];
|
||||
export type DatePickerPopoverProps = InstanceType<
|
||||
typeof DatePickerPopover
|
||||
>["$props"];
|
||||
|
||||
import type ToastProvider from "./components/toast/ToastProvider.vue";
|
||||
import type Toast from "./components/toast/Toast.vue";
|
||||
import type ToastContent from "./components/toast/ToastContent.vue";
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { readFileSync } from "node:fs";
|
||||
const demos = import.meta.glob("../apps/docs/demos/date-picker-*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
});
|
||||
const expected = [
|
||||
"basic",
|
||||
"disabled",
|
||||
"controlled",
|
||||
"with-validation",
|
||||
"format-options",
|
||||
"form-example",
|
||||
"with-custom-indicator",
|
||||
"render-function",
|
||||
"international-calendar",
|
||||
"custom-styles",
|
||||
];
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
class {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
},
|
||||
);
|
||||
});
|
||||
afterEach(async () => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
await flushPromises();
|
||||
vi.unstubAllGlobals();
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
describe("DatePicker documentation", () => {
|
||||
it("includes every pinned preview and uses the displayed SFC as its implementation", () => {
|
||||
const md = readFileSync("apps/docs/components/date-picker.md", "utf8");
|
||||
expect(
|
||||
[...md.matchAll(/<ComponentPreview name="date-picker-([^"]+)"/g)].map(
|
||||
(match) => match[1],
|
||||
),
|
||||
).toEqual(expected);
|
||||
expect(md).not.toContain("[!toc]");
|
||||
expect(Object.keys(demos)).toHaveLength(10);
|
||||
});
|
||||
it("mounts all ten examples without warnings or missing date controls", async () => {
|
||||
const warnings: string[] = [];
|
||||
for (const demo of Object.values(demos)) {
|
||||
const w = mount(demo as never, {
|
||||
global: {
|
||||
config: { warnHandler: (message) => warnings.push(message) },
|
||||
},
|
||||
});
|
||||
wrappers.push(w);
|
||||
await flushPromises();
|
||||
expect(w.find('[data-slot="date-picker"]').exists()).toBe(true);
|
||||
expect(w.find('[data-slot="date-input-group-segment"]').exists()).toBe(
|
||||
true,
|
||||
);
|
||||
expect(w.find('[data-slot="date-picker-trigger"]').exists()).toBe(true);
|
||||
expect(w.find('[data-slot="date-picker-value"]').exists()).toBe(true);
|
||||
}
|
||||
expect(warnings).toEqual([]);
|
||||
});
|
||||
it("the controlled example updates and clears the real date", async () => {
|
||||
const component = demos["../apps/docs/demos/date-picker-controlled.vue"];
|
||||
const w = mount(component as never);
|
||||
wrappers.push(w);
|
||||
const value = () =>
|
||||
(w.get('[data-slot="date-picker-value"]').element as HTMLInputElement)
|
||||
.value;
|
||||
expect(value()).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
||||
const buttons = w.findAll("button");
|
||||
await buttons.find((button) => button.text() === "清空")!.trigger("click");
|
||||
await flushPromises();
|
||||
expect(value()).toBe("");
|
||||
expect(w.get('[data-slot="description"]').text()).toContain("(空)");
|
||||
await w
|
||||
.findAll("button")
|
||||
.find((button) => button.text() === "设为今天")!
|
||||
.trigger("click");
|
||||
await flushPromises();
|
||||
expect(value()).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
||||
expect(w.get('[data-slot="description"]').text()).not.toContain("(空)");
|
||||
});
|
||||
it("format options keeps one picker value while TimeField edits its time", async () => {
|
||||
const component =
|
||||
demos["../apps/docs/demos/date-picker-format-options.vue"];
|
||||
const w = mount(component as never, { attachTo: document.body });
|
||||
wrappers.push(w);
|
||||
await flushPromises();
|
||||
expect(
|
||||
(w.get('[data-slot="date-picker-value"]').element as HTMLInputElement)
|
||||
.value,
|
||||
).toContain("T08:45:00");
|
||||
await w.get('[data-slot="date-picker-trigger"]').trigger("click");
|
||||
await flushPromises();
|
||||
const timeField = document.querySelector('[data-slot="time-field"]');
|
||||
expect(timeField).not.toBeNull();
|
||||
const hour = timeField!.querySelector<HTMLElement>('[data-type="hour"]')!;
|
||||
expect(hour.textContent?.trim()).toBe("8");
|
||||
hour.focus();
|
||||
hour.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "ArrowUp",
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
await flushPromises();
|
||||
expect(
|
||||
(w.get('[data-slot="date-picker-value"]').element as HTMLInputElement)
|
||||
.value,
|
||||
).toContain("T09:45:00");
|
||||
expect(document.querySelectorAll('[name="date"]')).toHaveLength(1);
|
||||
expect(document.querySelectorAll('[name="time"]')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,568 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, nextTick, ref } from "vue";
|
||||
import {
|
||||
CalendarDate,
|
||||
CalendarDateTime,
|
||||
getLocalTimeZone,
|
||||
parseZonedDateTime,
|
||||
Time,
|
||||
today,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
FieldError,
|
||||
Form,
|
||||
Label,
|
||||
TimeField,
|
||||
TimeFieldGroup,
|
||||
TimeFieldInput,
|
||||
TimeFieldSegment,
|
||||
} from "../packages/vue/src";
|
||||
|
||||
const components = {
|
||||
Calendar,
|
||||
CalendarCell,
|
||||
CalendarGrid,
|
||||
CalendarGridBody,
|
||||
CalendarGridHeader,
|
||||
CalendarHeader,
|
||||
CalendarHeaderCell,
|
||||
CalendarNavButton,
|
||||
CalendarYearPickerCell,
|
||||
CalendarYearPickerGrid,
|
||||
CalendarYearPickerGridBody,
|
||||
CalendarYearPickerTrigger,
|
||||
CalendarYearPickerTriggerHeading,
|
||||
CalendarYearPickerTriggerIndicator,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateFieldSuffix,
|
||||
DatePicker,
|
||||
DatePickerPopover,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
Description,
|
||||
FieldError,
|
||||
Form,
|
||||
Label,
|
||||
TimeField,
|
||||
TimeFieldGroup,
|
||||
TimeFieldInput,
|
||||
TimeFieldSegment,
|
||||
};
|
||||
|
||||
const calendar = `<Calendar aria-label="活动日期">
|
||||
<CalendarHeader>
|
||||
<CalendarYearPickerTrigger>
|
||||
<CalendarYearPickerTriggerHeading />
|
||||
<CalendarYearPickerTriggerIndicator />
|
||||
</CalendarYearPickerTrigger>
|
||||
<CalendarNavButton slot="previous" />
|
||||
<CalendarNavButton slot="next" />
|
||||
</CalendarHeader>
|
||||
<CalendarGrid>
|
||||
<CalendarGridHeader v-slot="{ day }"><CalendarHeaderCell>{{ day }}</CalendarHeaderCell></CalendarGridHeader>
|
||||
<CalendarGridBody v-slot="{ date }"><CalendarCell :date="date" /></CalendarGridBody>
|
||||
</CalendarGrid>
|
||||
<CalendarYearPickerGrid>
|
||||
<CalendarYearPickerGridBody v-slot="{ year, date }"><CalendarYearPickerCell :year="year" :date="date" /></CalendarYearPickerGridBody>
|
||||
</CalendarYearPickerGrid>
|
||||
</Calendar>`;
|
||||
|
||||
const content = `<Label>日期</Label>
|
||||
<DateFieldGroup>
|
||||
<DateFieldInput v-slot="{ segment }"><DateFieldSegment :segment="segment" /></DateFieldInput>
|
||||
<DateFieldSuffix>
|
||||
<DatePickerTrigger aria-label="打开日历"><DatePickerTriggerIndicator /></DatePickerTrigger>
|
||||
</DateFieldSuffix>
|
||||
</DateFieldGroup>
|
||||
<FieldError />
|
||||
<DatePickerPopover>${calendar}</DatePickerPopover>`;
|
||||
|
||||
const initial = new CalendarDate(2024, 2, 10);
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
class {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
},
|
||||
);
|
||||
});
|
||||
afterEach(async () => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
await flushPromises();
|
||||
vi.unstubAllGlobals();
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
function view(template: string, setup = () => ({})) {
|
||||
const w = mount(defineComponent({ components, template, setup }), {
|
||||
attachTo: document.body,
|
||||
});
|
||||
wrappers.push(w);
|
||||
return w;
|
||||
}
|
||||
const native = (w: ReturnType<typeof mount>) =>
|
||||
w.get('[data-slot="date-picker-value"]').element as HTMLInputElement;
|
||||
const trigger = '[data-slot="date-picker-trigger"]';
|
||||
async function open(w: ReturnType<typeof mount>) {
|
||||
await w.get(trigger).trigger("click");
|
||||
await flushPromises();
|
||||
}
|
||||
async function pick(w: ReturnType<typeof mount>, date: string) {
|
||||
const cell = document.querySelector<HTMLElement>(
|
||||
`[data-slot="calendar-cell"][data-date="${date}"]`,
|
||||
);
|
||||
expect(cell).not.toBeNull();
|
||||
cell!.click();
|
||||
await flushPromises();
|
||||
}
|
||||
|
||||
describe("DatePicker public composition", () => {
|
||||
it("renders the picker root, trigger and one named date submission", async () => {
|
||||
const w = view(
|
||||
`<form><DatePicker name="date" :default-value="initial">${content}</DatePicker></form>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
const root = w.get('[data-slot="date-picker"]');
|
||||
expect(root.classes()).toContain("hv-date-picker");
|
||||
expect(root.attributes("role")).toBe("group");
|
||||
expect(root.attributes("aria-labelledby")).toContain(
|
||||
w.get('[data-slot="label"]').attributes("id"),
|
||||
);
|
||||
expect(
|
||||
w.get('[data-slot="date-picker-trigger"]').attributes("aria-expanded"),
|
||||
).toBe("false");
|
||||
expect(native(w).value).toBe("2024-02-10");
|
||||
expect(
|
||||
new FormData(w.get("form").element as HTMLFormElement).getAll("date"),
|
||||
).toEqual(["2024-02-10"]);
|
||||
});
|
||||
|
||||
it("opens the real popover and selects a calendar date once", async () => {
|
||||
const w = view(
|
||||
`<form><DatePicker name="date" :default-value="initial">${content}</DatePicker></form>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
await w.get('[data-slot="date-picker-trigger"]').trigger("click");
|
||||
await flushPromises();
|
||||
expect(
|
||||
document.querySelector('[data-slot="date-picker-popover"]'),
|
||||
).not.toBeNull();
|
||||
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
|
||||
const cell = document.querySelector<HTMLElement>(
|
||||
'[data-slot="calendar-cell"][data-date="2024-02-15"]',
|
||||
)!;
|
||||
expect(cell).not.toBeNull();
|
||||
cell.click();
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("2024-02-15");
|
||||
expect(w.getComponent(DatePicker).emitted("change")).toHaveLength(1);
|
||||
expect(
|
||||
(
|
||||
w.getComponent(DatePicker).emitted("change")![0]![0] as CalendarDate
|
||||
).toString(),
|
||||
).toBe("2024-02-15");
|
||||
expect(
|
||||
document.querySelector('[data-slot="date-picker-popover"]'),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("toggles the popover through the controlled open model and ignores a cancelled click", async () => {
|
||||
const openModel = ref(false),
|
||||
updates: boolean[] = [];
|
||||
const w = view(
|
||||
`<DatePicker :open="openModel" :default-value="initial" @update:open="updates.push($event)">${content}</DatePicker>`,
|
||||
() => ({ openModel, initial, updates }),
|
||||
);
|
||||
await w.get(trigger).trigger("click");
|
||||
await flushPromises();
|
||||
expect(updates).toEqual([true]);
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
openModel.value = true;
|
||||
await nextTick();
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
|
||||
expect(w.get(trigger).attributes("aria-expanded")).toBe("true");
|
||||
window.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "Escape",
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
await flushPromises();
|
||||
expect(updates).toEqual([true, false]);
|
||||
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
|
||||
openModel.value = false;
|
||||
await nextTick();
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
|
||||
const cancel = ref(true);
|
||||
const cancelled = view(
|
||||
`<DatePicker :default-value="initial"><DateFieldGroup><DateFieldInput v-slot="{ segment }"><DateFieldSegment :segment="segment" /></DateFieldInput></DateFieldGroup><DatePickerTrigger @click="cancel && $event.preventDefault()">打开</DatePickerTrigger><DatePickerPopover>${calendar}</DatePickerPopover></DatePicker>`,
|
||||
() => ({ initial, cancel }),
|
||||
);
|
||||
await cancelled.get(trigger).trigger("click");
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
});
|
||||
|
||||
it("inherits picker locale and direction into an unbound calendar", async () => {
|
||||
const w = view(
|
||||
`<DatePicker :default-value="initial" locale="zh-CN" dir="rtl" first-day-of-week="wed" page-behavior="single">${content}</DatePicker>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
expect(w.get('[data-slot="date-picker"]').attributes("dir")).toBe("rtl");
|
||||
expect(
|
||||
w
|
||||
.findAll('[data-slot="date-input-group-segment"]')[0]
|
||||
.attributes("data-type"),
|
||||
).toBe("year");
|
||||
await open(w);
|
||||
const focused = document.activeElement!;
|
||||
const date = focused.getAttribute("data-date");
|
||||
expect(date).toBe("2024-02-10");
|
||||
expect(
|
||||
document.querySelector('[data-slot="calendar-header-cell"]')?.textContent,
|
||||
).toBe("周三");
|
||||
focused.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "ArrowRight",
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
await flushPromises();
|
||||
expect(document.activeElement?.getAttribute("data-date")).toBe(
|
||||
"2024-02-09",
|
||||
);
|
||||
});
|
||||
|
||||
it("closes from Escape inside a date segment even though the base cancels that key", async () => {
|
||||
const w = view(
|
||||
`<DatePicker :default-value="initial">${content}</DatePicker>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
await open(w);
|
||||
const segment = w.get('[data-type="day"]').element as HTMLElement;
|
||||
segment.focus();
|
||||
segment.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "Escape",
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
await flushPromises();
|
||||
expect(
|
||||
document.querySelector('[data-slot="date-picker-popover"]'),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects and retries the same controlled value without draft pollution", async () => {
|
||||
const value = ref<CalendarDate | null>(initial),
|
||||
accept = ref(false);
|
||||
const w = view(
|
||||
`<form><DatePicker :model-value="value" name="date" @update:model-value="accept && (value = $event)">${content}</DatePicker></form>`,
|
||||
() => ({ value, accept, initial }),
|
||||
);
|
||||
const day = w.get('[data-type="day"]');
|
||||
await day.trigger("keydown", { key: "ArrowUp" });
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("2024-02-10");
|
||||
expect(day.text()).toBe("10");
|
||||
await day.trigger("keydown", { key: "ArrowUp" });
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("2024-02-10");
|
||||
expect(
|
||||
w
|
||||
.getComponent(DatePicker)
|
||||
.emitted("update:modelValue")!
|
||||
.map((args) => (args[0] as CalendarDate).toString()),
|
||||
).toEqual(["2024-02-11", "2024-02-11"]);
|
||||
accept.value = true;
|
||||
await day.trigger("keydown", { key: "ArrowUp" });
|
||||
await flushPromises();
|
||||
expect(value.value?.toString()).toBe("2024-02-11");
|
||||
expect(native(w).value).toBe("2024-02-11");
|
||||
value.value = null;
|
||||
await nextTick();
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("");
|
||||
expect(w.findAll('[data-placeholder="true"]')).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("keeps the accepted value when a controlled calendar proposal is rejected", async () => {
|
||||
const value = ref<CalendarDate | null>(initial),
|
||||
accept = ref(false);
|
||||
const w = view(
|
||||
`<DatePicker :model-value="value" @update:model-value="accept && (value = $event)">${content}</DatePicker>`,
|
||||
() => ({ value, accept, initial }),
|
||||
);
|
||||
await open(w);
|
||||
await pick(w, "2024-02-15");
|
||||
expect(native(w).value).toBe("2024-02-10");
|
||||
expect(
|
||||
(
|
||||
w.getComponent(DatePicker).emitted("change")![0]![0] as DateValue
|
||||
).toString(),
|
||||
).toBe("2024-02-15");
|
||||
await open(w);
|
||||
expect(
|
||||
document
|
||||
.querySelector('[data-slot="calendar-cell"][data-date="2024-02-15"]')
|
||||
?.getAttribute("data-selected"),
|
||||
).toBeNull();
|
||||
accept.value = true;
|
||||
await pick(w, "2024-02-15");
|
||||
expect(value.value?.toString()).toBe("2024-02-15");
|
||||
expect(native(w).value).toBe("2024-02-15");
|
||||
});
|
||||
|
||||
it("honors shouldCloseOnSelect=false and keeps calendar and field in sync", async () => {
|
||||
const w = view(
|
||||
`<DatePicker :default-value="initial" :should-close-on-select="false">${content}</DatePicker>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
await open(w);
|
||||
await pick(w, "2024-02-15");
|
||||
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
|
||||
expect(native(w).value).toBe("2024-02-15");
|
||||
expect(
|
||||
document
|
||||
.querySelector('[data-slot="calendar-cell"][data-date="2024-02-15"]')
|
||||
?.getAttribute("data-selected"),
|
||||
).toBe("true");
|
||||
await w.get('[data-type="day"]').trigger("keydown", { key: "ArrowUp" });
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("2024-02-16");
|
||||
expect(
|
||||
document
|
||||
.querySelector('[data-slot="calendar-cell"][data-date="2024-02-16"]')
|
||||
?.getAttribute("data-selected"),
|
||||
).toBe("true");
|
||||
});
|
||||
|
||||
it("preserves date class, time, zone, seconds and calendar when picking a day", async () => {
|
||||
const zoned = parseZonedDateTime(
|
||||
"2024-03-10T01:30:45.123-08:00[America/Los_Angeles]",
|
||||
);
|
||||
const zonedView = view(
|
||||
`<DatePicker :default-value="zoned">${content}</DatePicker>`,
|
||||
() => ({ zoned }),
|
||||
);
|
||||
await open(zonedView);
|
||||
await pick(zonedView, "2024-03-12");
|
||||
const zonedValue = zonedView
|
||||
.getComponent(DatePicker)
|
||||
.emitted("change")![0]![0] as typeof zoned;
|
||||
expect(zonedValue.toString()).toBe(
|
||||
"2024-03-12T01:30:45.123-07:00[America/Los_Angeles]",
|
||||
);
|
||||
expect(zonedValue.timeZone).toBe("America/Los_Angeles");
|
||||
expect([
|
||||
zonedValue.hour,
|
||||
zonedValue.minute,
|
||||
zonedValue.second,
|
||||
zonedValue.millisecond,
|
||||
]).toEqual([1, 30, 45, 123]);
|
||||
expect(native(zonedView).value).toBe(zonedValue.toString());
|
||||
|
||||
const dateTime = new CalendarDateTime(2024, 2, 10, 18, 4, 5, 6);
|
||||
const dateTimeView = view(
|
||||
`<DatePicker :default-value="dateTime">${content}</DatePicker>`,
|
||||
() => ({ dateTime }),
|
||||
);
|
||||
await open(dateTimeView);
|
||||
await pick(dateTimeView, "2024-02-12");
|
||||
expect(
|
||||
(
|
||||
dateTimeView
|
||||
.getComponent(DatePicker)
|
||||
.emitted("change")![0]![0] as CalendarDateTime
|
||||
).toString(),
|
||||
).toBe("2024-02-12T18:04:05.006");
|
||||
});
|
||||
|
||||
it("routes slot time operations through the same accepted value", async () => {
|
||||
const initialDateTime = new CalendarDateTime(2024, 2, 10, 1, 2, 3);
|
||||
const w = view(
|
||||
`<DatePicker :default-value="initialDateTime" granularity="second" v-slot="{ state, timeValue }"><DateFieldGroup><DateFieldInput v-slot="{ segment }"><DateFieldSegment :segment="segment" /></DateFieldInput></DateFieldGroup><button type="button" data-test="set-time" @click="state.setTimeValue(new Time(9, 8, 7))">时间</button><span data-test="time">{{ timeValue?.toString() }}</span><DatePickerTrigger>打开</DatePickerTrigger><DatePickerPopover>${calendar}</DatePickerPopover></DatePicker>`,
|
||||
() => ({ initialDateTime, Time }),
|
||||
);
|
||||
expect(w.get('[data-test="time"]').text()).toBe("01:02:03");
|
||||
await w.get('[data-test="set-time"]').trigger("click");
|
||||
await flushPromises();
|
||||
expect(w.get('[data-test="time"]').text()).toBe("09:08:07");
|
||||
expect(native(w).value).toBe("2024-02-10T09:08:07");
|
||||
await open(w);
|
||||
await pick(w, "2024-02-12");
|
||||
expect(native(w).value).toBe("2024-02-12T09:08:07");
|
||||
expect(
|
||||
w
|
||||
.getComponent(DatePicker)
|
||||
.emitted("change")!
|
||||
.map((args) => (args[0] as DateValue).toString()),
|
||||
).toEqual(["2024-02-10T09:08:07", "2024-02-12T09:08:07"]);
|
||||
});
|
||||
|
||||
it("keeps an empty picker empty after a time draft and completes it only with a day", async () => {
|
||||
const placeholder = new CalendarDateTime(2024, 2, 10, 0, 0);
|
||||
const w = view(
|
||||
`<form><DatePicker name="date" :placeholder-value="placeholder" granularity="second" v-slot="{ state }"><DateFieldGroup><DateFieldInput v-slot="{ segment }"><DateFieldSegment :segment="segment" /></DateFieldInput></DateFieldGroup><button type="button" data-test="set-time" @click="state.setTimeValue(new Time(9, 8, 7))">时间</button><DatePickerTrigger>打开</DatePickerTrigger><DatePickerPopover>${calendar}</DatePickerPopover></DatePicker></form>`,
|
||||
() => ({ placeholder, Time }),
|
||||
);
|
||||
await w.get('[data-test="set-time"]').trigger("click");
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("");
|
||||
expect(
|
||||
new FormData(w.get("form").element as HTMLFormElement).getAll("date"),
|
||||
).toEqual([""]);
|
||||
await open(w);
|
||||
await pick(w, "2024-02-15");
|
||||
expect(native(w).value).toBe("2024-02-15T09:08:07");
|
||||
expect(
|
||||
(
|
||||
w.getComponent(DatePicker).emitted("change")![0]![0] as CalendarDateTime
|
||||
).toString(),
|
||||
).toBe("2024-02-15T09:08:07");
|
||||
});
|
||||
|
||||
it("submits one named date, validates required, accepts a day, and resets to empty", async () => {
|
||||
const w = view(
|
||||
`<form><DatePicker name="date" is-required :placeholder-value="initial">${content}</DatePicker></form>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
expect(w.findAll('form [name="date"]')).toHaveLength(1);
|
||||
await flushPromises();
|
||||
const validation = w.get(".hv-choice-validation")
|
||||
.element as HTMLInputElement;
|
||||
expect(validation.checkValidity()).toBe(false);
|
||||
await flushPromises();
|
||||
expect(w.get('[data-slot="field-error"]').text()).toContain("请填写");
|
||||
expect(w.get('[data-slot="date-picker"]').attributes("aria-invalid")).toBe(
|
||||
"true",
|
||||
);
|
||||
await open(w);
|
||||
await pick(w, "2024-02-15");
|
||||
expect(validation.checkValidity()).toBe(true);
|
||||
expect(
|
||||
new FormData(w.get("form").element as HTMLFormElement).getAll("date"),
|
||||
).toEqual(["2024-02-15"]);
|
||||
(w.get("form").element as HTMLFormElement).reset();
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("");
|
||||
expect(
|
||||
w.get('[data-slot="date-picker"]').attributes("aria-invalid"),
|
||||
).toBeUndefined();
|
||||
expect(w.findAll('[data-placeholder="true"]')).toHaveLength(3);
|
||||
await open(w);
|
||||
expect(
|
||||
document.querySelector(
|
||||
'[data-slot="calendar-cell"][data-selected="true"]',
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("applies min/max/unavailable rules to both segments and calendar", async () => {
|
||||
const w = view(
|
||||
`<DatePicker :default-value="initial" validation-behavior="aria" :min-value="initial.add({days:1})" :is-date-unavailable="(value) => value.day === 20">${content}</DatePicker>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
await flushPromises();
|
||||
expect(w.get('[data-slot="field-error"]').text()).toContain("不能早于");
|
||||
await open(w);
|
||||
expect(
|
||||
document
|
||||
.querySelector('[data-slot="calendar-cell"][data-date="2024-02-10"]')
|
||||
?.getAttribute("data-disabled"),
|
||||
).toBe("true");
|
||||
expect(
|
||||
document
|
||||
.querySelector('[data-slot="calendar-cell"][data-date="2024-02-20"]')
|
||||
?.getAttribute("data-unavailable"),
|
||||
).toBe("true");
|
||||
const unavailable = document.querySelector<HTMLElement>(
|
||||
'[data-slot="calendar-cell"][data-date="2024-02-20"]',
|
||||
)!;
|
||||
unavailable.click();
|
||||
await flushPromises();
|
||||
expect(native(w).value).toBe("2024-02-10");
|
||||
await pick(w, "2024-02-21");
|
||||
expect(native(w).value).toBe("2024-02-21");
|
||||
});
|
||||
|
||||
it("disables editing and opening, and keeps read-only submission non-editable", async () => {
|
||||
const disabled = view(
|
||||
`<form><DatePicker name="date" is-disabled :default-value="initial">${content}</DatePicker></form>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
expect(disabled.get(trigger).attributes("disabled")).toBeDefined();
|
||||
expect(native(disabled).disabled).toBe(true);
|
||||
expect(
|
||||
new FormData(disabled.get("form").element as HTMLFormElement).getAll(
|
||||
"date",
|
||||
),
|
||||
).toEqual([]);
|
||||
await disabled
|
||||
.get('[data-type="day"]')
|
||||
.trigger("keydown", { key: "ArrowUp" });
|
||||
expect(disabled.getComponent(DatePicker).emitted("change")).toBeUndefined();
|
||||
|
||||
const readOnly = view(
|
||||
`<form><DatePicker name="date" is-read-only :default-value="initial">${content}</DatePicker></form>`,
|
||||
() => ({ initial }),
|
||||
);
|
||||
expect(native(readOnly).value).toBe("2024-02-10");
|
||||
await readOnly
|
||||
.get('[data-type="day"]')
|
||||
.trigger("keydown", { key: "ArrowUp" });
|
||||
expect(readOnly.getComponent(DatePicker).emitted("change")).toBeUndefined();
|
||||
expect(readOnly.get(trigger).attributes("disabled")).toBeDefined();
|
||||
await readOnly.get(trigger).trigger("click");
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps an explicitly bound child calendar independent from the picker value", async () => {
|
||||
const calendarValue = ref<DateValue | null>(null);
|
||||
const w = view(
|
||||
`<DatePicker :default-value="initial"><DateFieldGroup><DateFieldInput v-slot="{ segment }"><DateFieldSegment :segment="segment" /></DateFieldInput></DateFieldGroup><DatePickerTrigger>打开</DatePickerTrigger><DatePickerPopover><Calendar v-model="calendarValue" aria-label="独立日历"><CalendarHeader><CalendarNavButton slot="previous" /><CalendarNavButton slot="next" /></CalendarHeader><CalendarGrid><CalendarGridHeader v-slot="{ day }"><CalendarHeaderCell>{{ day }}</CalendarHeaderCell></CalendarGridHeader><CalendarGridBody v-slot="{ date }"><CalendarCell :date="date" /></CalendarGridBody></CalendarGrid></Calendar></DatePickerPopover></DatePicker>`,
|
||||
() => ({ initial, calendarValue }),
|
||||
);
|
||||
await open(w);
|
||||
await pick(w, "2024-02-15");
|
||||
expect(calendarValue.value?.toString()).toBe("2024-02-15");
|
||||
expect(native(w).value).toBe("2024-02-10");
|
||||
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -54,6 +54,12 @@ for (const id of process.argv.slice(2)) {
|
||||
.includes("hv-time-field--full-width"),
|
||||
);
|
||||
}
|
||||
if (id === "date-picker") {
|
||||
assert(lib.DatePicker === lib.DatePickerRoot);
|
||||
assert(lib.datePickerVariants().base() === "hv-date-picker");
|
||||
assert(lib.datePickerVariants().trigger() === "hv-date-picker__trigger");
|
||||
assert(lib.datePickerVariants().popover() === "hv-date-picker__popover");
|
||||
}
|
||||
if (id === "slider")
|
||||
assert(lib.sliderVariants().thumb().includes("hv-slider__thumb"));
|
||||
if (id === "select")
|
||||
|
||||
@@ -198,6 +198,30 @@
|
||||
"hv-date-input-group--secondary"
|
||||
]
|
||||
},
|
||||
"date-picker": {
|
||||
"exports": [
|
||||
"DatePicker",
|
||||
"DatePickerRoot",
|
||||
"DatePickerTrigger",
|
||||
"DatePickerTriggerIndicator",
|
||||
"DatePickerPopover",
|
||||
"datePickerVariants",
|
||||
"DateFieldGroup",
|
||||
"DateFieldInput",
|
||||
"DateFieldSegment",
|
||||
"DateFieldSuffix",
|
||||
"Calendar",
|
||||
"CalendarCell"
|
||||
],
|
||||
"css": [
|
||||
".hv-date-picker",
|
||||
".hv-date-picker__trigger",
|
||||
".hv-date-picker__trigger-indicator",
|
||||
".hv-date-picker__popover",
|
||||
"--reka-popper-transform-origin",
|
||||
"data-exiting"
|
||||
]
|
||||
},
|
||||
"list-box": {
|
||||
"exports": [
|
||||
"ListBox",
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
import { h } from "vue";
|
||||
import {
|
||||
CalendarDate,
|
||||
CalendarDateTime,
|
||||
parseZonedDateTime,
|
||||
Time,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
import {
|
||||
DatePicker,
|
||||
DatePickerRoot,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
DatePickerPopover,
|
||||
datePickerVariants,
|
||||
type DatePickerProps,
|
||||
type DatePickerTriggerProps,
|
||||
type DatePickerPopoverProps,
|
||||
type DatePickerRenderProps,
|
||||
type DatePickerState,
|
||||
type DatePickerTimeValue,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const day = new CalendarDate(2024, 2, 10);
|
||||
const dateTime = new CalendarDateTime(2024, 2, 10, 9, 30);
|
||||
const zoned = parseZonedDateTime("2024-01-01T09:30+08:00[Asia/Shanghai]");
|
||||
const time: DatePickerTimeValue = new Time(9, 30);
|
||||
const values: DatePickerProps[] = [
|
||||
{
|
||||
modelValue: day,
|
||||
value: null,
|
||||
defaultValue: dateTime,
|
||||
placeholderValue: zoned,
|
||||
minValue: day,
|
||||
maxValue: day.add({ years: 1 }),
|
||||
isDateUnavailable: (value) => value.day === 20,
|
||||
granularity: "second",
|
||||
hourCycle: 24,
|
||||
hideTimeZone: true,
|
||||
shouldForceLeadingZeros: true,
|
||||
locale: "zh-CN",
|
||||
firstDayOfWeek: "mon",
|
||||
pageBehavior: "single",
|
||||
dir: "rtl",
|
||||
name: "date",
|
||||
form: "appointment",
|
||||
isDisabled: false,
|
||||
isReadOnly: false,
|
||||
isRequired: true,
|
||||
isInvalid: false,
|
||||
shouldCloseOnSelect: false,
|
||||
validate: (value) => (value ? null : "Missing"),
|
||||
"onUpdate:modelValue": (value) => {
|
||||
const accepted: DateValue | null = value;
|
||||
void accepted;
|
||||
},
|
||||
onChange: (value) => {
|
||||
const accepted: DateValue | null = value;
|
||||
void accepted;
|
||||
},
|
||||
"onUpdate:open": (value) => {
|
||||
const open: boolean = value;
|
||||
void open;
|
||||
},
|
||||
onOpenChange: (value) => {
|
||||
const open: boolean = value;
|
||||
void open;
|
||||
},
|
||||
},
|
||||
];
|
||||
const trigger: DatePickerTriggerProps = {
|
||||
as: "button",
|
||||
asChild: false,
|
||||
isDisabled: true,
|
||||
};
|
||||
const indicator = { as: "span" };
|
||||
const popover: DatePickerPopoverProps = {
|
||||
placement: "bottom",
|
||||
offset: 12,
|
||||
crossOffset: 4,
|
||||
shouldFlip: true,
|
||||
containerPadding: 16,
|
||||
isDismissable: false,
|
||||
isKeyboardDismissDisabled: true,
|
||||
};
|
||||
const state: DatePickerState = {
|
||||
value: day,
|
||||
timeValue: time,
|
||||
setValue: (value) => {
|
||||
const next: DateValue | null = value;
|
||||
void next;
|
||||
},
|
||||
setTimeValue: (value) => {
|
||||
const next: DatePickerTimeValue | null = value;
|
||||
void next;
|
||||
},
|
||||
};
|
||||
const rendered: DatePickerRenderProps = {
|
||||
value: day,
|
||||
isOpen: true,
|
||||
isDisabled: false,
|
||||
isReadOnly: false,
|
||||
isRequired: false,
|
||||
isInvalid: false,
|
||||
isFocusWithin: false,
|
||||
isFocused: false,
|
||||
isFocusVisible: false,
|
||||
validationErrors: [],
|
||||
timeValue: time,
|
||||
state,
|
||||
open: () => {},
|
||||
close: () => {},
|
||||
toggle: () => {},
|
||||
};
|
||||
// @ts-expect-error a date model is not a string
|
||||
const string: DatePickerProps = { modelValue: "2024-02-10" };
|
||||
// @ts-expect-error visible granularity has a fixed set
|
||||
const wrongGranularity: DatePickerProps = { granularity: "week" };
|
||||
// @ts-expect-error page behavior has a fixed set
|
||||
const wrongPage: DatePickerProps = { pageBehavior: "month" };
|
||||
// @ts-expect-error hour cycles are 12 or 24
|
||||
const wrongCycle: DatePickerProps = { hourCycle: 23 };
|
||||
// @ts-expect-error open state is boolean
|
||||
const wrongOpen: DatePickerProps = { open: "yes" };
|
||||
const wrongChange: DatePickerProps = {
|
||||
// @ts-expect-error no React PressEvent shape
|
||||
onChange: (event: { key: string }) => event,
|
||||
};
|
||||
// @ts-expect-error placement is a known logical value
|
||||
const wrongPlacement: DatePickerPopoverProps = { placement: "diagonal" };
|
||||
// @ts-expect-error a DatePicker is not a range model
|
||||
const range: DatePickerProps = { modelValue: [day] };
|
||||
type Slot = Parameters<
|
||||
NonNullable<InstanceType<typeof DatePicker>["$slots"]["default"]>
|
||||
>[0];
|
||||
const slot: Slot = rendered;
|
||||
const slotTime: DatePickerTimeValue | null = slot.state.timeValue;
|
||||
// @ts-expect-error slot time is not a number
|
||||
const wrongSlotTime: number = slot.timeValue;
|
||||
void [
|
||||
DatePicker,
|
||||
DatePickerRoot,
|
||||
DatePickerTrigger,
|
||||
DatePickerTriggerIndicator,
|
||||
DatePickerPopover,
|
||||
datePickerVariants().base(),
|
||||
datePickerVariants().trigger(),
|
||||
datePickerVariants().popover(),
|
||||
values,
|
||||
trigger,
|
||||
indicator,
|
||||
popover,
|
||||
state,
|
||||
rendered,
|
||||
string,
|
||||
wrongGranularity,
|
||||
wrongCycle,
|
||||
wrongPage,
|
||||
wrongOpen,
|
||||
wrongChange,
|
||||
wrongPlacement,
|
||||
range,
|
||||
slotTime,
|
||||
wrongSlotTime,
|
||||
];
|
||||
h(DatePickerPopover, popover);
|
||||
Reference in New Issue
Block a user