fix(demos): inherit ConfigProvider locale and restore the format-options popover width

HD-03 scope, all against heroui ce90ea3 cn sources:

- calendar-disabled/read-only: restore the today() default value and the
  baseline description lines (日历已禁用 / 日历为只读) inside the
  flex flex-col items-center wrapper
- calendar-controlled: restore the second button row (设为今天/设为圣诞节/
  清空) and the baseline feedback wording (已选日期:…(未选))
- locale inheritance: add a public useLocale() accessor (the components'
  ConfigProvider → en-US/ltr chain) and use it for startOfWeek in
  calendar-controlled, isWeekend in booking-calendar/unavailable-dates and
  the DateFormatter in date-range-picker-format-options instead of the
  hardcoded 'en-US' / 'zh-CN' literals
- date-range-picker-format-options: restore the pinned w-full popover class;
  the pinned source positions the popover against the initial containing
  block (full viewport width — verified on the reference docs at desktop and
  narrow), while Reka's shrink-to-fit positioning wrapper collapses the same
  class. A scoped adapter rule (.hv-date-range-picker__popover.w-full →
  100vw, layering-safe like the dropdown static-wrapper adapter) restores
  the baseline effect: viewport-wide popover, 252px calendar, stretched
  time rows, identical boundary clamping

- tests: locale dynamic-switching regressions covering zh-CN/en-US for week
  start, weekend rules (with ar-EG flipping the weekend for a observable
  rule change) and range formatting; full suite 110 files / 1627 tests,
  typecheck, build:docs and the date-range-picker / api-root-aliases /
  calendar tarball contracts pass
This commit is contained in:
maoyingjie
2026-10-28 16:35:26 +08:00
parent 0b89f02745
commit 2e3fdd4800
15 changed files with 382 additions and 147 deletions
@@ -91,3 +91,15 @@
.hv-date-range-picker__popover .hv-calendar__nav-button-icon {
@apply rotate-0;
}
/* Vue/Reka adapter: the pinned source positions the popover itself with
* `position: absolute` against the initial containing block, where a consumer's
* `w-full` (e.g. the cn format-options demo) resolves to the viewport width.
* Reka sizes its positioning wrapper to the content instead, so the same class
* would collapse; map it to the identical viewport width so the anchor
* placement, boundary clamping and content layout match the baseline.
* `!important` is required to out-rank the `w-full` utility layer (same
* layering constraint as the dropdown static-wrapper adapter). */
.hv-date-range-picker__popover.w-full {
width: 100vw !important;
}
+4 -9
View File
@@ -438,6 +438,7 @@ export {
type UseOverlayStateOptions,
} from "./composables/useOverlayState";
export { default as ConfigProvider } from "./providers/ConfigProvider.vue";
export { useLocale } from "./providers/context";
export type { ConfigProviderProps } from "./types";
export { default as Modal } from "./components/modal/Modal";
@@ -817,9 +818,7 @@ export {
default as DateInputGroup,
default as DateFieldGroup,
} from "./components/date-field/DateInputGroup.vue";
export {
default as DateInputGroupRoot,
} from "./components/date-field/DateInputGroup.vue";
export { default as DateInputGroupRoot } from "./components/date-field/DateInputGroup.vue";
export {
default as DateInputGroupInput,
default as DateFieldInput,
@@ -1437,12 +1436,8 @@ export {
default as ColorPicker,
default as ColorPickerRoot,
} from "./components/color-picker/ColorPicker.vue";
export {
default as ColorPickerTrigger,
} from "./components/color-picker/ColorPickerTrigger.vue";
export {
default as ColorPickerPopover,
} from "./components/color-picker/ColorPickerPopover.vue";
export { default as ColorPickerTrigger } from "./components/color-picker/ColorPickerTrigger.vue";
export { default as ColorPickerPopover } from "./components/color-picker/ColorPickerPopover.vue";
export type * from "./components/color-picker/types";
export { colorPickerVariants } from "@heroui-vue/styles";
export type { ColorPickerVariants } from "@heroui-vue/styles";
+15 -1
View File
@@ -1,4 +1,4 @@
import { inject, type ComputedRef, type InjectionKey } from "vue";
import { computed, inject, type ComputedRef, type InjectionKey } from "vue";
export interface ConfigContext {
dir: ComputedRef<"ltr" | "rtl">;
@@ -9,3 +9,17 @@ export const configContextKey: InjectionKey<ConfigContext> =
export function useConfig() {
return inject(configContextKey, undefined);
}
/**
* Locale/direction of the active `ConfigProvider`, mirroring the components'
* inheritance chain (`ConfigProvider` → `en-US` / `ltr`). Consumers use it for
* locale-dependent computations outside the components, such as
* `startOfWeek`/`isWeekend` or a `DateFormatter`, the way upstream demos use
* react-aria-components' `useLocale()`.
*/
export function useLocale() {
const config = useConfig();
return {
locale: computed(() => config?.locale.value ?? "en-US"),
dir: computed(() => config?.dir.value ?? "ltr"),
};
}