feat: migrate DateField and shared date input group
This commit is contained in:
@@ -21,3 +21,5 @@ LISTBOX-01 增加 `consume-list-box.mjs` / `list-box-contract.ts`。同样复制
|
||||
M33–M34 使用 consume-m33-m34.mjs / m33-m34-contract.ts;同样复制到独立 tarball 消费工程,分别运行 node 与两种解析模式的 tsc。包括所有公开部件、真正 node SSR、CSS 关键帧与策略/尺寸/方向的正反类型检查。集成验证目录为 /private/tmp/heroui-m33-consumer,不复用其他并行任务的临时产物。
|
||||
|
||||
SELECT-01 增加 `consume-select.mjs` / `select-contract.ts`。新 tarball 安装后运行 ESM/SSR/CSS 脚本,两种模块解析模式都纳入类型正反例;数字/字符串/空 key、六部件、validate 与事件载荷推断不应退化。保留旧组件消费回归。
|
||||
|
||||
DATE-02 增加 `consume-date-field.mjs` / `date-field-contract.ts`。独立消费者显式安装 `@internationalized/date@3.12.4`,运行完整 ISO 时区提交/SSR/样式检查,分别用 NodeNext 与 bundler 验证 DateValue、粒度、变体、范围和 segment 的正反类型,不从源码 alias 取公共类型。
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { parseZonedDateTime } from "@internationalized/date";
|
||||
import * as c from "@heroui-vue/components";
|
||||
import { readFile } from "node:fs/promises";
|
||||
for (const key of [
|
||||
"DateField",
|
||||
"DateFieldRoot",
|
||||
"DateFieldGroup",
|
||||
"DateFieldInput",
|
||||
"DateFieldSegment",
|
||||
"DateFieldPrefix",
|
||||
"DateFieldSuffix",
|
||||
"DateFieldInputContainer",
|
||||
"DateInputGroup",
|
||||
"DateInputGroupInput",
|
||||
"DateInputGroupSegment",
|
||||
"DateInputGroupInputContainer",
|
||||
"DateInputGroupPrefix",
|
||||
"DateInputGroupSuffix",
|
||||
])
|
||||
assert.ok(c[key], key);
|
||||
const date = parseZonedDateTime(
|
||||
"2024-03-10T01:30:45-08:00[America/Los_Angeles]",
|
||||
);
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(
|
||||
c.DateField,
|
||||
{ defaultValue: date, granularity: "minute", name: "date" },
|
||||
() => [
|
||||
h(c.Label, () => "Date"),
|
||||
h(c.DateFieldGroup, () => h(c.DateFieldInput)),
|
||||
h(c.Description, () => "Help"),
|
||||
],
|
||||
),
|
||||
}),
|
||||
);
|
||||
assert.ok(
|
||||
html.includes('value="2024-03-10T01:30:45-08:00[America/Los_Angeles]"'),
|
||||
);
|
||||
assert.equal((html.match(/name="date"/g) || []).length, 1);
|
||||
assert.ok(html.includes("aria-labelledby="));
|
||||
assert.ok(html.includes("aria-describedby="));
|
||||
const css = await readFile(
|
||||
import.meta.resolve("@heroui-vue/styles/css").replace("file://", ""),
|
||||
"utf8",
|
||||
);
|
||||
for (const name of [
|
||||
"hv-date-field",
|
||||
"hv-date-input-group",
|
||||
"hv-date-input-group__segment",
|
||||
"hv-date-input-group--secondary",
|
||||
])
|
||||
assert.ok(css.includes(name), name);
|
||||
console.log("DateField tarball ESM/SSR/CSS: passed");
|
||||
@@ -0,0 +1,55 @@
|
||||
import {
|
||||
DateField,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateInputGroup,
|
||||
type DateFieldProps,
|
||||
type DateFieldGroupProps,
|
||||
type DateFieldSegmentProps,
|
||||
type DateSegment,
|
||||
} from "@heroui-vue/components";
|
||||
import { parseDate } from "@internationalized/date";
|
||||
const date = parseDate("2024-02-10");
|
||||
const props: DateFieldProps = {
|
||||
modelValue: date,
|
||||
granularity: "minute",
|
||||
hourCycle: 24,
|
||||
placeholderValue: date,
|
||||
validate: (value) => (value ? value.toString() : "Missing"),
|
||||
};
|
||||
const group: DateFieldGroupProps = { variant: "secondary", fullWidth: true };
|
||||
// @ts-expect-error DateValue is not a date string
|
||||
const wrongDate: DateFieldProps = { modelValue: "2024-02-10" };
|
||||
// @ts-expect-error no milliseconds granularity
|
||||
const wrongGranularity: DateFieldProps = { granularity: "millisecond" };
|
||||
// @ts-expect-error no arbitrary variants
|
||||
const wrongVariant: DateFieldGroupProps = { variant: "outline" };
|
||||
// @ts-expect-error a DateField is not a range
|
||||
const wrongRange: DateFieldProps = { modelValue: [date, date] };
|
||||
const segment: DateSegment = {
|
||||
part: "day",
|
||||
type: "day",
|
||||
text: "10",
|
||||
value: "10",
|
||||
isEditable: true,
|
||||
isPlaceholder: false,
|
||||
};
|
||||
const segmentProps: DateFieldSegmentProps = { segment };
|
||||
// @ts-expect-error DateSegment has real properties
|
||||
const wrongSegment: DateFieldSegmentProps = { segment: "day" };
|
||||
void [
|
||||
DateField,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
DateInputGroup,
|
||||
props,
|
||||
group,
|
||||
segmentProps,
|
||||
wrongDate,
|
||||
wrongGranularity,
|
||||
wrongVariant,
|
||||
wrongRange,
|
||||
wrongSegment,
|
||||
];
|
||||
Reference in New Issue
Block a user