@mercury-fx/core 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/cx.d.ts +3 -0
- package/dist/date.d.ts +7 -0
- package/dist/index.d.ts +32 -0
- package/dist/internal/arrays.d.ts +95 -0
- package/dist/internal/attrs.d.ts +33 -0
- package/dist/internal/clamp.d.ts +4 -0
- package/dist/internal/create-id.d.ts +8 -0
- package/dist/internal/css-escape.d.ts +7 -0
- package/dist/internal/date-time/calendar/use-calendar.d.ts +63 -0
- package/dist/internal/date-time/field/helpers.d.ts +86 -0
- package/dist/internal/date-time/field/parts.d.ts +8 -0
- package/dist/internal/date-time/field/segments.d.ts +60 -0
- package/dist/internal/date-time/field/time-helpers.d.ts +82 -0
- package/dist/internal/date-time/field/types.d.ts +25 -0
- package/dist/internal/date-time/field/use-date-field.d.ts +61 -0
- package/dist/internal/date-time/formatter.d.ts +114 -0
- package/dist/internal/date-time/placeholders.d.ts +8 -0
- package/dist/internal/date-time/time-value.d.ts +11 -0
- package/dist/internal/date-time/utils.d.ts +76 -0
- package/dist/internal/debounce.d.ts +4 -0
- package/dist/internal/dom.d.ts +7 -0
- package/dist/internal/elements.d.ts +2 -0
- package/dist/internal/focus.d.ts +5 -0
- package/dist/internal/get-directional-keys.d.ts +21 -0
- package/dist/internal/is.d.ts +25 -0
- package/dist/internal/kbd-constants.d.ts +42 -0
- package/dist/internal/kbd.d.ts +1 -0
- package/dist/internal/locale.d.ts +6 -0
- package/dist/internal/math.d.ts +1 -0
- package/dist/internal/noop.d.ts +4 -0
- package/dist/internal/should-enable-focus-trap.d.ts +4 -0
- package/dist/internal/types.d.ts +14 -0
- package/dist/internal/use-anchored-position.d.ts +45 -0
- package/dist/internal/use-arrow-navigation.d.ts +62 -0
- package/dist/internal/use-dismiss.d.ts +31 -0
- package/dist/internal/use-focus-trap.d.ts +31 -0
- package/dist/internal/use-id.d.ts +6 -0
- package/dist/internal/warn.d.ts +1 -0
- package/dist/mercury-core.js +865 -0
- package/dist/mercury-core.js.map +1 -0
- package/dist/shared/date/types.d.ts +100 -0
- package/dist/shared/index.d.ts +36 -0
- package/dist/shared/types.d.ts +13 -0
- package/dist/types.d.ts +31 -0
- package/dist/utils/after-sleep.d.ts +4 -0
- package/dist/utils/clsx.d.ts +7 -0
- package/dist/utils/dom.d.ts +14 -0
- package/dist/utils/event-list.d.ts +1 -0
- package/dist/utils/events.d.ts +13 -0
- package/dist/utils/execute-callbacks.d.ts +7 -0
- package/dist/utils/is.d.ts +4 -0
- package/dist/utils/merge-props.d.ts +22 -0
- package/dist/utils/strings.d.ts +3 -0
- package/dist/utils/style-to-css.d.ts +9 -0
- package/dist/utils/style.d.ts +2 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mercury-core.js","sources":["../src/cx.ts","../src/internal/date-time/utils.ts","../src/internal/date-time/time-value.ts","../src/internal/date-time/formatter.ts","../src/internal/date-time/placeholders.ts","../src/internal/date-time/field/parts.ts","../src/internal/is.ts","../src/internal/date-time/field/segments.ts","../src/internal/use-id.ts","../src/internal/date-time/field/helpers.ts","../src/internal/date-time/field/use-date-field.ts","../src/internal/date-time/calendar/use-calendar.ts","../src/internal/should-enable-focus-trap.ts","../src/internal/use-focus-trap.ts","../src/internal/dom.ts","../src/internal/use-dismiss.ts","../src/internal/use-anchored-position.ts","../src/internal/use-arrow-navigation.ts"],"sourcesContent":["export type ClassValue = string | false | null | undefined;\n\n/** Tiny classNames join — filters falsy, joins with spaces. */\nexport function cx(...parts: ClassValue[]): string {\n return parts.filter(Boolean).join(\" \");\n}\n","import {\n\tCalendarDate,\n\tCalendarDateTime,\n\ttype DateValue,\n\tTime,\n\tZonedDateTime,\n\tgetDayOfWeek,\n\tgetLocalTimeZone,\n\tparseDate,\n\tparseDateTime,\n\tparseZonedDateTime,\n\ttoCalendar,\n} from \"@internationalized/date\";\nimport type {\n\tDateMatcher,\n\tGranularity,\n\tTimeGranularity,\n\tTimeValue,\n} from \"#shared/date/types.js\";\n\ntype GetDefaultDateProps = {\n\tdefaultValue?: DateValue | DateValue[] | undefined;\n\tminValue?: DateValue;\n\tmaxValue?: DateValue;\n\tgranularity?: Granularity;\n};\n\ntype GetDefaultTimeProps = {\n\tdefaultValue?: TimeValue | undefined;\n\tgranularity?: TimeGranularity;\n};\n\nconst defaultDateDefaults = {\n\tdefaultValue: undefined,\n\tgranularity: \"day\",\n};\n\nconst defaultTimeDefaults = {\n\tdefaultValue: undefined,\n\tgranularity: \"minute\",\n};\n\n/**\n * A helper function used throughout the various date builders\n * to generate a default `DateValue` using the `defaultValue`,\n * `defaultPlaceholder`, `minValue`, `maxValue`, and `granularity` props.\n *\n * It's important to match the `DateValue` type being used\n * elsewhere in the builder, so they behave according to the\n * behavior the user expects based on the props they've provided.\n *\n */\nexport function getDefaultDate(opts: GetDefaultDateProps): DateValue {\n\tconst withDefaults = { ...defaultDateDefaults, ...opts };\n\tconst { defaultValue, granularity, minValue, maxValue } = withDefaults;\n\n\tif (Array.isArray(defaultValue) && defaultValue.length) {\n\t\treturn defaultValue[defaultValue.length - 1]!;\n\t}\n\n\tif (defaultValue && !Array.isArray(defaultValue)) {\n\t\treturn defaultValue;\n\t} else {\n\t\tlet date = new Date();\n\t\tif (minValue && date < minValue.toDate(getLocalTimeZone())) {\n\t\t\tdate = minValue.toDate(getLocalTimeZone());\n\t\t} else if (maxValue && date > maxValue.toDate(getLocalTimeZone())) {\n\t\t\tdate = maxValue.toDate(getLocalTimeZone());\n\t\t}\n\t\tconst year = date.getFullYear();\n\t\tconst month = date.getMonth() + 1;\n\t\tconst day = date.getDate();\n\t\tconst calendarDateTimeGranularities = [\"hour\", \"minute\", \"second\"];\n\n\t\tif (calendarDateTimeGranularities.includes(granularity ?? \"day\")) {\n\t\t\treturn new CalendarDateTime(year, month, day, 0, 0, 0);\n\t\t}\n\n\t\treturn new CalendarDate(year, month, day);\n\t}\n}\n\nexport function getDefaultTime(opts: GetDefaultTimeProps): TimeValue {\n\tconst withDefaults = { ...defaultTimeDefaults, ...opts };\n\tconst { defaultValue } = withDefaults;\n\n\tif (defaultValue) {\n\t\treturn defaultValue;\n\t} else {\n\t\treturn new Time(0, 0, 0);\n\t}\n}\n\n/**\n * Given a date string and a reference `DateValue` object, parse the\n * string to the same type as the reference object.\n *\n * Useful for parsing strings from data attributes, which are always\n * strings, to the same type being used by the date component.\n */\nexport function parseStringToDateValue(dateStr: string, referenceVal: DateValue): DateValue {\n\tlet dateValue: DateValue;\n\tif (referenceVal instanceof ZonedDateTime) {\n\t\tdateValue = parseZonedDateTime(dateStr);\n\t} else if (referenceVal instanceof CalendarDateTime) {\n\t\tdateValue = parseDateTime(dateStr);\n\t} else {\n\t\tdateValue = parseDate(dateStr);\n\t}\n\n\t// ensure the parsed date is in the same calendar as the reference date set by the user.\n\treturn dateValue.calendar !== referenceVal.calendar\n\t\t? toCalendar(dateValue, referenceVal.calendar)\n\t\t: dateValue;\n}\n\n/**\n * Given a `DateValue` object, convert it to a native `Date` object.\n * If a timezone is provided, the date will be converted to that timezone.\n * If no timezone is provided, the date will be converted to the local timezone.\n */\nexport function toDate(dateValue: DateValue, tz: string = getLocalTimeZone()) {\n\tif (dateValue instanceof ZonedDateTime) {\n\t\treturn dateValue.toDate();\n\t} else {\n\t\treturn dateValue.toDate(tz);\n\t}\n}\n\nexport function getDateValueType(date: DateValue): string {\n\tif (date instanceof CalendarDate) return \"date\";\n\tif (date instanceof CalendarDateTime) return \"datetime\";\n\tif (date instanceof ZonedDateTime) return \"zoneddatetime\";\n\tthrow new Error(\"Unknown date type\");\n}\n\nexport function parseAnyDateValue(value: string, type: string): DateValue {\n\tswitch (type) {\n\t\tcase \"date\":\n\t\t\treturn parseDate(value);\n\t\tcase \"datetime\":\n\t\t\treturn parseDateTime(value);\n\t\tcase \"zoneddatetime\":\n\t\t\treturn parseZonedDateTime(value);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown date type: ${type}`);\n\t}\n}\n\nfunction isCalendarDateTime(dateValue: DateValue): dateValue is CalendarDateTime {\n\treturn dateValue instanceof CalendarDateTime;\n}\n\nexport function isZonedDateTime(dateValue: DateValue | TimeValue): dateValue is ZonedDateTime {\n\treturn dateValue instanceof ZonedDateTime;\n}\n\nexport function hasTime(dateValue: DateValue): dateValue is CalendarDateTime | ZonedDateTime {\n\treturn isCalendarDateTime(dateValue) || isZonedDateTime(dateValue);\n}\n\n/**\n * Given a date, return the number of days in the month.\n */\nexport function getDaysInMonth(date: Date | DateValue) {\n\tif (date instanceof Date) {\n\t\tconst year = date.getFullYear();\n\t\tconst month = date.getMonth() + 1;\n\t\t/**\n\t\t * By using zero as the day, we get the\n\t\t * last day of the previous month, which\n\t\t * is the month we originally passed in.\n\t\t */\n\t\treturn new Date(year, month, 0).getDate();\n\t} else {\n\t\treturn date.set({ day: 100 }).day;\n\t}\n}\n\n/**\n * Determine if a date is before the reference date.\n * @param dateToCompare - is this date before the `referenceDate`\n * @param referenceDate - is the `dateToCompare` before this date\n *\n * @see {@link isBeforeOrSame} for inclusive\n */\nexport function isBefore(dateToCompare: DateValue, referenceDate: DateValue) {\n\treturn dateToCompare.compare(referenceDate) < 0;\n}\n\n/**\n * Determine if a date is after the reference date.\n * @param dateToCompare - is this date after the `referenceDate`\n * @param referenceDate - is the `dateToCompare` after this date\n *\n * @see {@link isAfterOrSame} for inclusive\n */\nexport function isAfter(dateToCompare: DateValue, referenceDate: DateValue) {\n\treturn dateToCompare.compare(referenceDate) > 0;\n}\n\n/**\n * Determine if a date is before or the same as the reference date.\n *\n * @param dateToCompare - the date to compare\n * @param referenceDate - the reference date to make the comparison against\n *\n * @see {@link isBefore} for non-inclusive\n */\nfunction isBeforeOrSame(dateToCompare: DateValue, referenceDate: DateValue) {\n\treturn dateToCompare.compare(referenceDate) <= 0;\n}\n\n/**\n * Determine if a date is after or the same as the reference date.\n *\n * @param dateToCompare - is this date after or the same as the `referenceDate`\n * @param referenceDate - is the `dateToCompare` after or the same as this date\n *\n * @see {@link isAfter} for non-inclusive\n */\nfunction isAfterOrSame(dateToCompare: DateValue, referenceDate: DateValue) {\n\treturn dateToCompare.compare(referenceDate) >= 0;\n}\n\n/**\n * Determine if a date is inclusively between a start and end reference date.\n *\n * @param date - is this date inclusively between the `start` and `end` dates\n * @param start - the start reference date to make the comparison against\n * @param end - the end reference date to make the comparison against\n *\n * @see {@link isBetween} for non-inclusive\n */\nexport function isBetweenInclusive(date: DateValue, start: DateValue, end: DateValue) {\n\treturn isAfterOrSame(date, start) && isBeforeOrSame(date, end);\n}\n\nexport function getLastFirstDayOfWeek<T extends DateValue = DateValue>(\n\tdate: T,\n\tfirstDayOfWeek: number,\n\tlocale: string\n): T {\n\tconst day = getDayOfWeek(date, locale);\n\n\tif (firstDayOfWeek > day) {\n\t\treturn date.subtract({ days: day + 7 - firstDayOfWeek }) as T;\n\t}\n\tif (firstDayOfWeek === day) {\n\t\treturn date as T;\n\t}\n\treturn date.subtract({ days: day - firstDayOfWeek }) as T;\n}\n\nexport function getNextLastDayOfWeek<T extends DateValue = DateValue>(\n\tdate: T,\n\tfirstDayOfWeek: number,\n\tlocale: string\n): T {\n\tconst day = getDayOfWeek(date, locale);\n\tconst lastDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1;\n\n\tif (day === lastDayOfWeek) {\n\t\treturn date as T;\n\t}\n\n\tif (day > lastDayOfWeek) {\n\t\treturn date.add({ days: 7 - day + lastDayOfWeek }) as T;\n\t}\n\n\treturn date.add({ days: lastDayOfWeek - day }) as T;\n}\n\nexport function areAllDaysBetweenValid(\n\tstart: DateValue,\n\tend: DateValue,\n\tisUnavailable: DateMatcher | undefined,\n\tisDisabled: DateMatcher | undefined\n) {\n\tif (isUnavailable === undefined && isDisabled === undefined) {\n\t\treturn true;\n\t}\n\tlet dCurrent = start.add({ days: 1 });\n\tif (isDisabled?.(dCurrent) || isUnavailable?.(dCurrent)) {\n\t\treturn false;\n\t}\n\tconst dEnd = end;\n\twhile (dCurrent.compare(dEnd) < 0) {\n\t\tdCurrent = dCurrent.add({ days: 1 });\n\t\tif (isDisabled?.(dCurrent) || isUnavailable?.(dCurrent)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import { CalendarDateTime, Time, ZonedDateTime } from \"@internationalized/date\";\nimport type { TimeValue } from \"#shared/date/types.js\";\n\n/**\n * Normalize a {@link TimeValue} to a date-bearing value the `Intl` formatters\n * can consume. A bare `Time` has no date, so it is anchored to a fixed sentinel\n * day (2020-01-01) — only the time parts are ever read back out.\n *\n * This lives as a standalone leaf (rather than in `field/time-helpers`) so the\n * formatter can depend on it without pulling in the whole date-field surface.\n */\nexport function convertTimeValueToDateValue(time: TimeValue): CalendarDateTime | ZonedDateTime {\n\tif (time instanceof Time) {\n\t\treturn new CalendarDateTime(2020, 1, 1, time.hour, time.minute, time.second, time.millisecond);\n\t}\n\treturn time;\n}\n","import { DateFormatter, type DateValue } from \"@internationalized/date\";\nimport { hasTime, isZonedDateTime, toDate } from \"./utils\";\nimport type { HourCycle, TimeValue } from \"#shared/date/types.js\";\nimport { convertTimeValueToDateValue } from \"./time-value\";\n\n/**\n * A read-only, *live* value source — anything that exposes its current value\n * behind a `current` getter. A Svelte `box`, a signal wrapper, or the Effector\n * adapter from `@mercury-fx/effector` (`createFormatterModel`) all satisfy it. The\n * formatter reads `.current` on every call, so changes to the source are picked\n * up immediately with no rebuild and no framework coupling in this package.\n */\nexport interface Readable<T> {\n\treadonly current: T;\n}\n\n/** A formatter input that may be a plain value or a live {@link Readable}. */\nexport type MaybeReadable<T> = T | Readable<T>;\n\n/**\n * How the month renders in {@link Formatter.fullMonthAndYear}: an `Intl` month\n * style (`\"long\"`, `\"short\"`, `\"narrow\"`, `\"numeric\"`, `\"2-digit\"`) or a custom\n * mapper from the 1-based month number to a string.\n */\nexport type MonthFormat =\n\t| NonNullable<Intl.DateTimeFormatOptions[\"month\"]>\n\t| ((month: number) => string);\n\n/**\n * How the year renders in {@link Formatter.fullMonthAndYear}: an `Intl` year\n * style (`\"numeric\"`, `\"2-digit\"`) or a custom mapper from the full year.\n */\nexport type YearFormat =\n\t| NonNullable<Intl.DateTimeFormatOptions[\"year\"]>\n\t| ((year: number) => string);\n\n/** The resolved day period. */\nexport type DayPeriodValue = \"AM\" | \"PM\";\n\n/** Options for {@link createFormatter}. Only `locale` is required. */\nexport interface FormatterOptions {\n\t/** BCP-47 locale tag. Static, or a live source to follow a locale store. */\n\tlocale: MaybeReadable<string>;\n\t/** Month rendering for `fullMonthAndYear`. Defaults to `\"long\"`. */\n\tmonthFormat?: MaybeReadable<MonthFormat>;\n\t/** Year rendering for `fullMonthAndYear`. Defaults to `\"numeric\"`. */\n\tyearFormat?: MaybeReadable<YearFormat>;\n}\n\n/**\n * The locale-aware date-formatting surface used across the date builders. Every\n * method goes through `Intl`'s {@link DateFormatter} at the *current* locale, so\n * output stays consistent and updates when a live `locale` source changes.\n */\nexport interface Formatter {\n\t/** Imperatively override the active locale (wins over a live `locale` source). */\n\tsetLocale(newLocale: string): void;\n\t/** The active locale — the override if one was set, else the (possibly live) source. */\n\tgetLocale(): string;\n\t/** Format a native `Date` with arbitrary `Intl` options. */\n\tcustom(date: Date, options: Intl.DateTimeFormatOptions): string;\n\t/** A human \"selected date\" string, with time included when the value carries one. */\n\tselectedDate(date: DateValue, includeTime?: boolean): string;\n\t/** The full month + year, honoring `monthFormat` / `yearFormat`. */\n\tfullMonthAndYear(date: Date): string;\n\t/** The full (\"long\") month name. */\n\tfullMonth(date: Date): string;\n\t/** The numeric year. */\n\tfullYear(date: Date): string;\n\t/** The `Intl` parts of a date value, timezone-aware for zoned values. */\n\ttoParts(date: DateValue, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormatPart[];\n\t/** A single weekday label at the given width (default `\"narrow\"`). */\n\tdayOfWeek(date: Date, length?: Intl.DateTimeFormatOptions[\"weekday\"]): string;\n\t/** \"AM\" / \"PM\" for the given instant under the (optional) hour cycle. */\n\tdayPeriod(date: Date, hourCycle?: HourCycle): DayPeriodValue;\n\t/** The string value of one `Intl` part of a date value (`\"\"` if absent). */\n\tpart(\n\t\tdateObj: DateValue,\n\t\ttype: Intl.DateTimeFormatPartTypes,\n\t\toptions?: Intl.DateTimeFormatOptions\n\t): string;\n}\n\n/** Options for {@link createTimeFormatter}. */\nexport interface TimeFormatterOptions {\n\t/** BCP-47 locale tag. Static, or a live source to follow a locale store. */\n\tlocale: MaybeReadable<string>;\n}\n\n/** The locale-aware time-formatting surface (the time-only counterpart to {@link Formatter}). */\nexport interface TimeFormatter {\n\t/** Imperatively override the active locale (wins over a live `locale` source). */\n\tsetLocale(newLocale: string): void;\n\t/** The active locale — the override if one was set, else the (possibly live) source. */\n\tgetLocale(): string;\n\t/** Format a native `Date` with arbitrary `Intl` options. */\n\tcustom(date: Date, options: Intl.DateTimeFormatOptions): string;\n\t/** A human \"selected time\" string (long time style). */\n\tselectedTime(date: TimeValue): string;\n\t/** The `Intl` parts of a time value, timezone-aware for zoned values. */\n\ttoParts(timeValue: TimeValue, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormatPart[];\n\t/** \"AM\" / \"PM\" for the given instant under the (optional) hour cycle. */\n\tdayPeriod(date: Date, hourCycle?: HourCycle): DayPeriodValue;\n\t/** The string value of one `Intl` part of a time value (`\"\"` if absent). */\n\tpart(\n\t\tdateObj: TimeValue,\n\t\ttype: Intl.DateTimeFormatPartTypes,\n\t\toptions?: Intl.DateTimeFormatOptions\n\t): string;\n}\n\nconst defaultPartOptions: Intl.DateTimeFormatOptions = {\n\tyear: \"numeric\",\n\tmonth: \"numeric\",\n\tday: \"numeric\",\n\thour: \"numeric\",\n\tminute: \"numeric\",\n\tsecond: \"numeric\",\n};\n\nfunction isReadable<T>(value: MaybeReadable<T>): value is Readable<T> {\n\treturn typeof value === \"object\" && value !== null && \"current\" in value;\n}\n\n/** Collapse a plain value or a live {@link Readable} into a getter read on every call. */\nfunction reader<T>(value: MaybeReadable<T>): () => T {\n\treturn isReadable(value) ? () => value.current : () => value;\n}\n\n/**\n * Creates a typed wrapper around `@internationalized/date`'s {@link DateFormatter}\n * — itself an improved {@link Intl.DateTimeFormat} — used by the date builders to\n * format dates consistently.\n *\n * The wrapper is framework-agnostic: pass plain values for a static formatter, or\n * {@link Readable} sources (Svelte boxes, signals, the `@mercury-fx/effector` store\n * adapter) for one that tracks live locale / format changes.\n *\n * @example Static\n * ```ts\n * const fmt = createFormatter({ locale: \"en-GB\" });\n * fmt.fullMonthAndYear(new Date()); // \"December 2025\"\n * ```\n * @example Live (Effector — see `@mercury-fx/effector` `createFormatterModel`)\n * ```ts\n * const fmt = createFormatter({ locale: { get current() { return $locale.getState(); } } });\n * ```\n *\n * @see [DateFormatter](https://react-spectrum.adobe.com/internationalized/date/DateFormatter.html)\n */\nexport function createFormatter(opts: FormatterOptions): Formatter {\n\tconst readLocale = reader(opts.locale);\n\tconst readMonthFormat = reader<MonthFormat>(opts.monthFormat ?? \"long\");\n\tconst readYearFormat = reader<YearFormat>(opts.yearFormat ?? \"numeric\");\n\n\tlet override: string | undefined;\n\tconst locale = (): string => override ?? readLocale();\n\n\tfunction setLocale(newLocale: string): void {\n\t\toverride = newLocale;\n\t}\n\n\tfunction getLocale(): string {\n\t\treturn locale();\n\t}\n\n\tfunction custom(date: Date, options: Intl.DateTimeFormatOptions): string {\n\t\treturn new DateFormatter(locale(), options).format(date);\n\t}\n\n\tfunction selectedDate(date: DateValue, includeTime = true): string {\n\t\tif (hasTime(date) && includeTime) {\n\t\t\treturn custom(toDate(date), { dateStyle: \"long\", timeStyle: \"long\" });\n\t\t}\n\t\treturn custom(toDate(date), { dateStyle: \"long\" });\n\t}\n\n\tfunction fullMonthAndYear(date: Date): string {\n\t\tconst month = readMonthFormat();\n\t\tconst year = readYearFormat();\n\n\t\t// Fast path: when both are `Intl` styles, a single formatter yields the\n\t\t// locale-correct order and spacing (e.g. \"décembre 2025\" / \"2025年12月\").\n\t\tif (typeof month !== \"function\" && typeof year !== \"function\") {\n\t\t\treturn new DateFormatter(locale(), { month, year }).format(date);\n\t\t}\n\n\t\tconst formattedMonth =\n\t\t\ttypeof month === \"function\"\n\t\t\t\t? month(date.getMonth() + 1)\n\t\t\t\t: new DateFormatter(locale(), { month }).format(date);\n\t\tconst formattedYear =\n\t\t\ttypeof year === \"function\"\n\t\t\t\t? year(date.getFullYear())\n\t\t\t\t: new DateFormatter(locale(), { year }).format(date);\n\n\t\treturn `${formattedMonth} ${formattedYear}`;\n\t}\n\n\tfunction fullMonth(date: Date): string {\n\t\treturn new DateFormatter(locale(), { month: \"long\" }).format(date);\n\t}\n\n\tfunction fullYear(date: Date): string {\n\t\treturn new DateFormatter(locale(), { year: \"numeric\" }).format(date);\n\t}\n\n\tfunction toParts(\n\t\tdate: DateValue,\n\t\toptions?: Intl.DateTimeFormatOptions\n\t): Intl.DateTimeFormatPart[] {\n\t\tif (isZonedDateTime(date)) {\n\t\t\treturn new DateFormatter(locale(), { ...options, timeZone: date.timeZone }).formatToParts(\n\t\t\t\ttoDate(date)\n\t\t\t);\n\t\t}\n\t\treturn new DateFormatter(locale(), options).formatToParts(toDate(date));\n\t}\n\n\tfunction dayOfWeek(\n\t\tdate: Date,\n\t\tlength: Intl.DateTimeFormatOptions[\"weekday\"] = \"narrow\"\n\t): string {\n\t\treturn new DateFormatter(locale(), { weekday: length }).format(date);\n\t}\n\n\tfunction dayPeriod(date: Date, hourCycle: HourCycle | undefined = undefined): DayPeriodValue {\n\t\tconst parts = new DateFormatter(locale(), {\n\t\t\thour: \"numeric\",\n\t\t\tminute: \"numeric\",\n\t\t\thourCycle: hourCycle === 24 ? \"h23\" : undefined,\n\t\t}).formatToParts(date);\n\t\tconst value = parts.find((p) => p.type === \"dayPeriod\")?.value;\n\t\treturn value === \"PM\" ? \"PM\" : \"AM\";\n\t}\n\n\tfunction part(\n\t\tdateObj: DateValue,\n\t\ttype: Intl.DateTimeFormatPartTypes,\n\t\toptions: Intl.DateTimeFormatOptions = {}\n\t): string {\n\t\tconst parts = toParts(dateObj, { ...defaultPartOptions, ...options });\n\t\treturn parts.find((p) => p.type === type)?.value ?? \"\";\n\t}\n\n\treturn {\n\t\tsetLocale,\n\t\tgetLocale,\n\t\tcustom,\n\t\tselectedDate,\n\t\tfullMonthAndYear,\n\t\tfullMonth,\n\t\tfullYear,\n\t\ttoParts,\n\t\tdayOfWeek,\n\t\tdayPeriod,\n\t\tpart,\n\t};\n}\n\n/**\n * The time-only counterpart to {@link createFormatter}. Accepts a plain locale\n * string or a live {@link Readable} source, the same way.\n */\nexport function createTimeFormatter(locale: MaybeReadable<string>): TimeFormatter {\n\tconst readLocale = reader(locale);\n\tlet override: string | undefined;\n\tconst activeLocale = (): string => override ?? readLocale();\n\n\tfunction setLocale(newLocale: string): void {\n\t\toverride = newLocale;\n\t}\n\n\tfunction getLocale(): string {\n\t\treturn activeLocale();\n\t}\n\n\tfunction custom(date: Date, options: Intl.DateTimeFormatOptions): string {\n\t\treturn new DateFormatter(activeLocale(), options).format(date);\n\t}\n\n\tfunction selectedTime(date: TimeValue): string {\n\t\treturn custom(toDate(convertTimeValueToDateValue(date)), { timeStyle: \"long\" });\n\t}\n\n\tfunction toParts(\n\t\ttimeValue: TimeValue,\n\t\toptions?: Intl.DateTimeFormatOptions\n\t): Intl.DateTimeFormatPart[] {\n\t\tconst dateValue = convertTimeValueToDateValue(timeValue);\n\t\tif (isZonedDateTime(dateValue)) {\n\t\t\treturn new DateFormatter(activeLocale(), {\n\t\t\t\t...options,\n\t\t\t\ttimeZone: dateValue.timeZone,\n\t\t\t}).formatToParts(toDate(dateValue));\n\t\t}\n\t\treturn new DateFormatter(activeLocale(), options).formatToParts(toDate(dateValue));\n\t}\n\n\tfunction dayPeriod(date: Date, hourCycle: HourCycle | undefined = undefined): DayPeriodValue {\n\t\tconst parts = new DateFormatter(activeLocale(), {\n\t\t\thour: \"numeric\",\n\t\t\tminute: \"numeric\",\n\t\t\thourCycle: hourCycle === 24 ? \"h23\" : undefined,\n\t\t}).formatToParts(date);\n\t\tconst value = parts.find((p) => p.type === \"dayPeriod\")?.value;\n\t\treturn value === \"PM\" ? \"PM\" : \"AM\";\n\t}\n\n\tfunction part(\n\t\tdateObj: TimeValue,\n\t\ttype: Intl.DateTimeFormatPartTypes,\n\t\toptions: Intl.DateTimeFormatOptions = {}\n\t): string {\n\t\tconst parts = toParts(dateObj, { ...defaultPartOptions, ...options });\n\t\treturn parts.find((p) => p.type === type)?.value ?? \"\";\n\t}\n\n\treturn {\n\t\tsetLocale,\n\t\tgetLocale,\n\t\tcustom,\n\t\tselectedTime,\n\t\ttoParts,\n\t\tdayPeriod,\n\t\tpart,\n\t};\n}\n","// prettier-ignore\nconst supportedLocales = [\n\t'ach','af','am','an','ar','ast','az','be','bg','bn','br','bs',\n\t'ca','cak','ckb','cs','cy','da','de','dsb','el','en','eo','es',\n\t'et','eu','fa','ff','fi','fr','fy','ga','gd','gl','he','hr',\n\t'hsb','hu','ia','id','it','ja','ka','kk','kn','ko','lb','lo',\n\t'lt','lv','meh','ml','ms','nl','nn','no','oc','pl','pt','rm',\n\t'ro','ru','sc','scn','sk','sl','sr','sv','szl','tg','th','tr',\n\t'uk','zh-CN','zh-TW',\n] as const;\n\nconst placeholderFields = [\"year\", \"month\", \"day\"] as const;\n\ntype SupportedLocale = (typeof supportedLocales)[number];\ntype PlaceholderField = (typeof placeholderFields)[number];\nexport type PlaceholderMap = Record<SupportedLocale, Record<PlaceholderField, string>>;\n\nconst placeholders: PlaceholderMap = {\n\tach: { year: \"mwaka\", month: \"dwe\", day: \"nino\" },\n\taf: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n\tam: { year: \"ዓዓዓዓ\", month: \"ሚሜ\", day: \"ቀቀ\" },\n\tan: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\tar: { year: \"سنة\", month: \"شهر\", day: \"يوم\" },\n\tast: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\taz: { year: \"iiii\", month: \"aa\", day: \"gg\" },\n\tbe: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n\tbg: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n\tbn: { year: \"yyyy\", month: \"মিমি\", day: \"dd\" },\n\tbr: { year: \"bbbb\", month: \"mm\", day: \"dd\" },\n\tbs: { year: \"gggg\", month: \"mm\", day: \"dd\" },\n\tca: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\tcak: { year: \"jjjj\", month: \"ii\", day: \"q'q'\" },\n\tckb: { year: \"ساڵ\", month: \"مانگ\", day: \"ڕۆژ\" },\n\tcs: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n\tcy: { year: \"bbbb\", month: \"mm\", day: \"dd\" },\n\tda: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n\tde: { year: \"jjjj\", month: \"mm\", day: \"tt\" },\n\tdsb: { year: \"llll\", month: \"mm\", day: \"źź\" },\n\tel: { year: \"εεεε\", month: \"μμ\", day: \"ηη\" },\n\ten: { year: \"yyyy\", month: \"mm\", day: \"dd\" },\n\teo: { year: \"jjjj\", month: \"mm\", day: \"tt\" },\n\tes: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\tet: { year: \"aaaa\", month: \"kk\", day: \"pp\" },\n\teu: { year: \"uuuu\", month: \"hh\", day: \"ee\" },\n\tfa: { year: \"سال\", month: \"ماه\", day: \"روز\" },\n\tff: { year: \"hhhh\", month: \"ll\", day: \"ññ\" },\n\tfi: { year: \"vvvv\", month: \"kk\", day: \"pp\" },\n\tfr: { year: \"aaaa\", month: \"mm\", day: \"jj\" },\n\tfy: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n\tga: { year: \"bbbb\", month: \"mm\", day: \"ll\" },\n\tgd: { year: \"bbbb\", month: \"mm\", day: \"ll\" },\n\tgl: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\the: { year: \"שנה\", month: \"חודש\", day: \"יום\" },\n\thr: { year: \"gggg\", month: \"mm\", day: \"dd\" },\n\thsb: { year: \"llll\", month: \"mm\", day: \"dd\" },\n\thu: { year: \"éééé\", month: \"hh\", day: \"nn\" },\n\tia: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\tid: { year: \"tttt\", month: \"bb\", day: \"hh\" },\n\tit: { year: \"aaaa\", month: \"mm\", day: \"gg\" },\n\tja: { year: \" 年 \", month: \"月\", day: \"日\" },\n\tka: { year: \"წწწწ\", month: \"თთ\", day: \"რრ\" },\n\tkk: { year: \"жжжж\", month: \"аа\", day: \"кк\" },\n\tkn: { year: \"ವವವವ\", month: \"ಮಿಮೀ\", day: \"ದಿದಿ\" },\n\tko: { year: \"연도\", month: \"월\", day: \"일\" },\n\tlb: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n\tlo: { year: \"ປປປປ\", month: \"ດດ\", day: \"ວວ\" },\n\tlt: { year: \"mmmm\", month: \"mm\", day: \"dd\" },\n\tlv: { year: \"gggg\", month: \"mm\", day: \"dd\" },\n\tmeh: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\tml: { year: \"വർഷം\", month: \"മാസം\", day: \"തീയതി\" },\n\tms: { year: \"tttt\", month: \"mm\", day: \"hh\" },\n\tnl: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n\tnn: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n\tno: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n\toc: { year: \"aaaa\", month: \"mm\", day: \"jj\" },\n\tpl: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n\tpt: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\trm: { year: \"oooo\", month: \"mm\", day: \"dd\" },\n\tro: { year: \"aaaa\", month: \"ll\", day: \"zz\" },\n\tru: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n\tsc: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n\tscn: { year: \"aaaa\", month: \"mm\", day: \"jj\" },\n\tsk: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n\tsl: { year: \"llll\", month: \"mm\", day: \"dd\" },\n\tsr: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n\tsv: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n\tszl: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n\ttg: { year: \"сссс\", month: \"мм\", day: \"рр\" },\n\tth: { year: \"ปปปป\", month: \"ดด\", day: \"วว\" },\n\ttr: { year: \"yyyy\", month: \"aa\", day: \"gg\" },\n\tuk: { year: \"рррр\", month: \"мм\", day: \"дд\" },\n\t\"zh-CN\": { year: \"年\", month: \"月\", day: \"日\" },\n\t\"zh-TW\": { year: \"年\", month: \"月\", day: \"日\" },\n};\n\nfunction getPlaceholderObj(locale: SupportedLocale | (string & {})) {\n\tif (!isSupportedLocale(locale)) {\n\t\tconst localeLanguage = getLocaleLanguage(locale);\n\t\tif (!isSupportedLocale(localeLanguage)) {\n\t\t\treturn placeholders.en;\n\t\t} else {\n\t\t\treturn placeholders[localeLanguage];\n\t\t}\n\t} else {\n\t\treturn placeholders[locale];\n\t}\n}\n\ntype Field = \"era\" | \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\" | \"second\" | \"dayPeriod\";\n\nexport function getPlaceholder(\n\tfield: Field,\n\tvalue: string,\n\tlocale: SupportedLocale | (string & {})\n) {\n\tif (isPlaceholderField(field)) return getPlaceholderObj(locale)[field];\n\tif (isDefaultField(field)) return value;\n\tif (isTimeField(field)) return \"––\";\n\treturn \"\";\n}\n\nfunction isSupportedLocale(locale: string): locale is SupportedLocale {\n\treturn supportedLocales.includes(locale as SupportedLocale);\n}\n\nfunction isPlaceholderField(field: unknown): field is PlaceholderField {\n\treturn placeholderFields.includes(field as PlaceholderField);\n}\n\nfunction isTimeField(field: unknown): field is \"hour\" | \"minute\" | \"second\" {\n\treturn field === \"hour\" || field === \"minute\" || field === \"second\";\n}\n\nfunction isDefaultField(field: unknown): field is \"era\" | \"dayPeriod\" {\n\treturn field === \"era\" || field === \"dayPeriod\";\n}\n\nfunction getLocaleLanguage(locale: string) {\n\tif (Intl.Locale) {\n\t\treturn new Intl.Locale(locale).language;\n\t}\n\treturn locale.split(\"-\")[0]!;\n}\n","export const DATE_SEGMENT_PARTS = [\"day\", \"month\", \"year\"] as const;\nexport const EDITABLE_TIME_SEGMENT_PARTS = [\"hour\", \"minute\", \"second\", \"dayPeriod\"] as const;\nexport const NON_EDITABLE_SEGMENT_PARTS = [\"literal\", \"timeZoneName\"] as const;\nexport const EDITABLE_SEGMENT_PARTS = [\n\t...DATE_SEGMENT_PARTS,\n\t...EDITABLE_TIME_SEGMENT_PARTS,\n] as const;\nexport const ALL_SEGMENT_PARTS = [\n\t...EDITABLE_SEGMENT_PARTS,\n\t...NON_EDITABLE_SEGMENT_PARTS,\n] as const;\nexport const ALL_TIME_SEGMENT_PARTS = [\n\t...EDITABLE_TIME_SEGMENT_PARTS,\n\t...NON_EDITABLE_SEGMENT_PARTS,\n] as const;\n\nexport const ALL_EXCEPT_LITERAL_PARTS = ALL_SEGMENT_PARTS.filter((part) => part !== \"literal\");\nexport const ALL_TIME_EXCEPT_LITERAL_PARTS = ALL_TIME_SEGMENT_PARTS.filter(\n\t(part) => part !== \"literal\"\n);\n","import type { FocusableTarget } from \"./focus.js\";\n\nexport const isBrowser = typeof document !== \"undefined\";\n\nexport const isIOS = getIsIOS();\n\nfunction getIsIOS() {\n\treturn (\n\t\tisBrowser &&\n\t\twindow?.navigator?.userAgent &&\n\t\t(/iP(ad|hone|od)/.test(window.navigator.userAgent) ||\n\t\t\t// The new iPad Pro Gen3 does not identify itself as iPad, but as Macintosh.\n\t\t\t(window?.navigator?.maxTouchPoints > 2 &&\n\t\t\t\t/iPad|Macintosh/.test(window?.navigator.userAgent)))\n\t);\n}\n\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n\treturn typeof value === \"function\";\n}\n\nexport function isHTMLElement(element: unknown): element is HTMLElement {\n\treturn element instanceof HTMLElement;\n}\n\nexport function isElement(element: unknown): element is Element {\n\treturn element instanceof Element;\n}\n\nexport function isElementOrSVGElement(element: unknown): element is Element | SVGElement {\n\treturn element instanceof Element || element instanceof SVGElement;\n}\n\nexport function isNumberString(value: string) {\n\treturn !Number.isNaN(Number(value)) && !Number.isNaN(Number.parseFloat(value));\n}\n\nexport function isNull(value: unknown): value is null {\n\treturn value === null;\n}\n\nexport function isTouch(e: PointerEvent) {\n\treturn e.pointerType === \"touch\";\n}\n\nexport function isFocusVisible(element: Element) {\n\treturn element.matches(\":focus-visible\");\n}\n\nexport function isNotNull<T>(value: T | null): value is T {\n\treturn value !== null;\n}\n\n/**\n * Determines if the provided object is a valid `HTMLInputElement` with\n * a `select` method available.\n */\nexport function isSelectableInput(\n\telement: unknown\n): element is FocusableTarget & { select: () => void } {\n\treturn element instanceof HTMLInputElement && \"select\" in element;\n}\n\n/**\n * Given a node, determine if it is hidden by walking up the\n * DOM tree until we hit the `stopAt` node (exclusive), if provided)\n * otherwise we stop at the document root.\n */\nexport function isElementHidden(node: HTMLElement, stopAt?: HTMLElement) {\n\tif (getComputedStyle(node).visibility === \"hidden\") return true;\n\twhile (node) {\n\t\t// we stop at `upTo` (excluding it)\n\t\tif (stopAt !== undefined && node === stopAt) return false;\n\t\tif (getComputedStyle(node).display === \"none\") return true;\n\t\tnode = node.parentElement as HTMLElement;\n\t}\n\treturn false;\n}\n","import { isAnySegmentPart } from \"./helpers.js\";\nimport { isHTMLElement } from \"#internal/is.js\";\nimport { kbd } from \"#internal/kbd.js\";\n\n/**\n * Handles segment navigation based on the provided keyboard event and field ID.\n *\n * @param e - The keyboard event\n * @param fieldNode - The ID of the field we're navigating within\n */\nexport function handleSegmentNavigation(e: KeyboardEvent, fieldNode: HTMLElement | null) {\n\tconst currentTarget = e.currentTarget;\n\tif (!isHTMLElement(currentTarget)) return;\n\n\tconst { prev, next } = getPrevNextSegments(currentTarget, fieldNode);\n\n\tif (e.key === kbd.ARROW_LEFT) {\n\t\tif (!prev) return;\n\t\tprev.focus();\n\t} else if (e.key === kbd.ARROW_RIGHT) {\n\t\tif (!next) return;\n\t\tnext.focus();\n\t}\n}\n\nexport function handleTimeSegmentNavigation(e: KeyboardEvent, fieldNode: HTMLElement | null) {\n\tconst currentTarget = e.currentTarget;\n\tif (!isHTMLElement(currentTarget)) return;\n\n\tconst { prev, next } = getPrevNextTimeSegments(currentTarget, fieldNode);\n\n\tif (e.key === kbd.ARROW_LEFT) {\n\t\tif (!prev) return;\n\t\tprev.focus();\n\t} else if (e.key === kbd.ARROW_RIGHT) {\n\t\tif (!next) return;\n\t\tnext.focus();\n\t}\n}\n\n/**\n * Retrieves the next segment in the list of segments relative to the provided node.\n *\n * @param node - The node we're starting from\n * @param segments - The list of candidate segments to navigate through\n */\nexport function getNextSegment(node: HTMLElement, segments: HTMLElement[]) {\n\tconst index = segments.indexOf(node);\n\tif (index === segments.length - 1 || index === -1) return null;\n\tconst nextIndex = index + 1;\n\tconst nextSegment = segments[nextIndex];\n\treturn nextSegment;\n}\n\n/**\n * Retrieves the previous segment in the list of segments relative to the provided node.\n *\n * @param node - The node we're starting from\n * @param segments - The list of candidate segments to navigate through\n */\nexport function getPrevSegment(node: HTMLElement, segments: HTMLElement[]) {\n\tconst index = segments.indexOf(node);\n\tif (index === 0 || index === -1) return null;\n\tconst prevIndex = index - 1;\n\tconst prevSegment = segments[prevIndex];\n\treturn prevSegment;\n}\n\n/**\n * Retrieves an object containing the next and previous segments relative to the current node.\n *\n * @param startingNode - The node we're starting from\n * @param fieldNode - The ID of the field we're navigating within\n */\nexport function getPrevNextSegments(startingNode: HTMLElement, fieldNode: HTMLElement | null) {\n\tconst segments = getSegments(fieldNode);\n\tif (!segments.length) {\n\t\treturn {\n\t\t\tnext: null,\n\t\t\tprev: null,\n\t\t};\n\t}\n\treturn {\n\t\tnext: getNextSegment(startingNode, segments),\n\t\tprev: getPrevSegment(startingNode, segments),\n\t};\n}\n\nexport function getPrevNextTimeSegments(startingNode: HTMLElement, fieldNode: HTMLElement | null) {\n\tconst segments = getTimeSegments(fieldNode);\n\tif (!segments.length) {\n\t\treturn {\n\t\t\tnext: null,\n\t\t\tprev: null,\n\t\t};\n\t}\n\treturn {\n\t\tnext: getNextSegment(startingNode, segments),\n\t\tprev: getPrevSegment(startingNode, segments),\n\t};\n}\n\n/**\n * Shifts the focus to the next segment in the list of segments\n * within the field identified by the provided ID.\n */\nexport function moveToNextSegment(e: KeyboardEvent, fieldNode: HTMLElement | null) {\n\tconst node = e.currentTarget;\n\tif (!isHTMLElement(node)) return;\n\tconst { next } = getPrevNextSegments(node, fieldNode);\n\tif (!next) return;\n\tnext.focus();\n}\n\nexport function moveToNextTimeSegment(e: KeyboardEvent, fieldNode: HTMLElement | null) {\n\tconst node = e.currentTarget;\n\tif (!isHTMLElement(node)) return;\n\tconst { next } = getPrevNextTimeSegments(node, fieldNode);\n\tif (!next) return;\n\tnext.focus();\n}\n\nexport function moveToPrevTimeSegment(e: KeyboardEvent, fieldNode: HTMLElement | null) {\n\tconst node = e.currentTarget;\n\tif (!isHTMLElement(node)) return;\n\tconst { prev } = getPrevNextTimeSegments(node, fieldNode);\n\tif (!prev) return;\n\tprev.focus();\n}\n\n/**\n * Shifts the focus to the previous segment in the list of segments\n * within the field identified by the provided ID. If this is the first\n * segment, focus will not be shifted.\n */\nexport function moveToPrevSegment(e: KeyboardEvent, fieldNode: HTMLElement | null) {\n\tconst node = e.currentTarget;\n\tif (!isHTMLElement(node)) return;\n\tconst { prev } = getPrevNextSegments(node, fieldNode);\n\tif (!prev) return;\n\tprev.focus();\n}\n\nexport function isSegmentNavigationKey(key: string) {\n\tif (key === kbd.ARROW_RIGHT || key === kbd.ARROW_LEFT) return true;\n\treturn false;\n}\n\n/**\n * Retrieves all the interactive segments within the field identified by the provided ID.\n */\nexport function getSegments(fieldNode: HTMLElement | null) {\n\tif (!fieldNode) return [];\n\tconst segments = Array.from(fieldNode.querySelectorAll(\"[data-segment]\")).filter(\n\t\t(el): el is HTMLElement => {\n\t\t\tif (!isHTMLElement(el)) return false;\n\t\t\tconst segment = el.dataset.segment;\n\t\t\tif (segment === \"trigger\") return true;\n\t\t\tif (!isAnySegmentPart(segment) || segment === \"literal\") return false;\n\t\t\treturn true;\n\t\t}\n\t);\n\treturn segments;\n}\n\nexport function getTimeSegments(fieldNode: HTMLElement | null) {\n\tif (!fieldNode) return [];\n\tconst segments = Array.from(fieldNode.querySelectorAll(\"[data-segment]\")).filter(\n\t\t(el): el is HTMLElement => {\n\t\t\tif (!isHTMLElement(el)) return false;\n\t\t\tconst segment = el.dataset.segment;\n\t\t\tif (segment === \"trigger\") return true;\n\t\t\tif (segment === \"literal\") return false;\n\t\t\treturn true;\n\t\t}\n\t);\n\treturn segments;\n}\n\nexport function getFirstTimeSegment(fieldNode: HTMLElement | null) {\n\treturn getTimeSegments(fieldNode)[0];\n}\n\n/**\n * Get the first interactive segment within the field identified by the provided ID.\n */\nexport function getFirstSegment(fieldNode: HTMLElement | null) {\n\treturn getSegments(fieldNode)[0];\n}\n","let counter = 0;\n\n/**\n * Generates a process-unique id with the given prefix. Despite the name this is\n * NOT a React hook — it's a plain monotonic counter (base36), safe to call from\n * anywhere a stable, collision-free id is needed.\n */\nexport function useId(prefix = \"mx\"): string {\n\tcounter += 1;\n\treturn `${prefix}-${counter.toString(36)}`;\n}\n","import type { DateValue } from \"@internationalized/date\";\nimport type { Formatter } from \"#internal/date-time/formatter.js\";\nimport { getPlaceholder } from \"#internal/date-time/placeholders.js\";\nimport { hasTime, isZonedDateTime } from \"#internal/date-time/utils.js\";\nimport type {\n\tDateAndTimeSegmentObj,\n\tDateSegmentPart,\n\tEditableSegmentPart,\n\tSegmentContentObj,\n\tSegmentPart,\n\tSegmentStateMap,\n\tSegmentValueObj,\n\tTimeSegmentPart,\n} from \"./types.js\";\nimport {\n\tALL_SEGMENT_PARTS,\n\tDATE_SEGMENT_PARTS,\n\tEDITABLE_SEGMENT_PARTS,\n\tEDITABLE_TIME_SEGMENT_PARTS,\n} from \"./parts.js\";\nimport { getSegments } from \"./segments.js\";\nimport { isBrowser, isNull, isNumberString } from \"#internal/is.js\";\nimport { useId } from \"#internal/use-id.js\";\nimport { kbd } from \"#internal/kbd.js\";\nimport type { Granularity, HourCycle } from \"#shared/date/types.js\";\n\nexport function initializeSegmentValues(granularity: Granularity) {\n\tconst calendarDateTimeGranularities = [\"hour\", \"minute\", \"second\"];\n\tconst initialParts = EDITABLE_SEGMENT_PARTS.map((part) => {\n\t\tif (part === \"dayPeriod\") {\n\t\t\treturn [part, \"AM\"];\n\t\t}\n\t\treturn [part, null];\n\t}).filter(([key]) => {\n\t\tif (key === \"literal\" || key === null) return false;\n\t\tif (granularity === \"day\") {\n\t\t\treturn !calendarDateTimeGranularities.includes(key!);\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t});\n\treturn Object.fromEntries(initialParts) as SegmentValueObj;\n}\n\ntype SharedContentProps = {\n\tgranularity: Granularity;\n\tdateRef: DateValue;\n\tformatter: Formatter;\n\thideTimeZone: boolean;\n\thourCycle: HourCycle | undefined;\n};\n\ntype CreateContentObjProps = SharedContentProps & {\n\tsegmentValues: SegmentValueObj;\n\tlocale: string;\n};\n\ntype CreateContentArrProps = SharedContentProps & {\n\tcontentObj: SegmentContentObj;\n};\n\nfunction createContentObj(props: CreateContentObjProps) {\n\tconst { segmentValues, formatter, locale, dateRef } = props;\n\n\tconst content = Object.keys(segmentValues).reduce((obj, part) => {\n\t\tif (!isSegmentPart(part)) return obj;\n\t\tif (\"hour\" in segmentValues && part === \"dayPeriod\") {\n\t\t\tconst value = segmentValues[part];\n\t\t\tif (!isNull(value)) {\n\t\t\t\tobj[part] = value;\n\t\t\t} else {\n\t\t\t\tobj[part] = getPlaceholder(part, \"AM\", locale);\n\t\t\t}\n\t\t} else {\n\t\t\tobj[part] = getPartContent(part);\n\t\t}\n\n\t\treturn obj;\n\t}, {} as SegmentContentObj);\n\n\tfunction getPartContent(part: DateSegmentPart | TimeSegmentPart) {\n\t\tif (\"hour\" in segmentValues) {\n\t\t\tconst value = segmentValues[part];\n\t\t\tconst leadingZero = typeof value === \"string\" && value?.startsWith(\"0\");\n\t\t\tconst intValue = value !== null ? Number.parseInt(value) : null;\n\n\t\t\tif (value === \"0\" && part !== \"year\") {\n\t\t\t\treturn \"0\";\n\t\t\t} else if (!isNull(value) && !isNull(intValue)) {\n\t\t\t\tconst formatted = formatter.part(dateRef.set({ [part]: value }), part, {\n\t\t\t\t\thourCycle: props.hourCycle === 24 ? \"h23\" : undefined,\n\t\t\t\t});\n\n\t\t\t\t/**\n\t\t\t\t * If we're operating in a 12 hour clock and the part is an hour, we handle\n\t\t\t\t * the conversion to 12 hour format with 2 digit hours and leading zeros here.\n\t\t\t\t */\n\t\t\t\tconst is12HourMode =\n\t\t\t\t\tprops.hourCycle === 12 ||\n\t\t\t\t\t(props.hourCycle === undefined && getDefaultHourCycle(locale) === 12);\n\t\t\t\tif (part === \"hour\" && is12HourMode) {\n\t\t\t\t\t/**\n\t\t\t\t\t * If the value is over 12, we convert to 12 hour format and add leading\n\t\t\t\t\t * zeroes if the value is less than 10.\n\t\t\t\t\t */\n\t\t\t\t\tif (intValue > 12) {\n\t\t\t\t\t\tconst hour = intValue - 12;\n\t\t\t\t\t\tif (hour === 0) {\n\t\t\t\t\t\t\treturn \"12\";\n\t\t\t\t\t\t} else if (hour < 10) {\n\t\t\t\t\t\t\treturn `0${hour}`;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn `${hour}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * If the value is 0, we convert to 12, since 0 is not a valid 12 hour time.\n\t\t\t\t\t */\n\t\t\t\t\tif (intValue === 0) {\n\t\t\t\t\t\treturn \"12\";\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * If the value is less than 10, we add a leading zero to the value.\n\t\t\t\t\t */\n\t\t\t\t\tif (intValue < 10) {\n\t\t\t\t\t\treturn `0${intValue}`;\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * Otherwise, we don't need to do anything to the value.\n\t\t\t\t\t */\n\t\t\t\t\treturn `${intValue}`;\n\t\t\t\t}\n\n\t\t\t\tif (part === \"year\") {\n\t\t\t\t\treturn `${value}`;\n\t\t\t\t}\n\n\t\t\t\tif (leadingZero && formatted.length === 1) {\n\t\t\t\t\treturn `0${formatted}`;\n\t\t\t\t}\n\t\t\t\treturn formatted;\n\t\t\t} else {\n\t\t\t\treturn getPlaceholder(part, \"\", locale);\n\t\t\t}\n\t\t} else {\n\t\t\tif (isDateSegmentPart(part)) {\n\t\t\t\tconst value = segmentValues[part];\n\t\t\t\tconst leadingZero = typeof value === \"string\" && value?.startsWith(\"0\");\n\t\t\t\tif (value === \"0\") {\n\t\t\t\t\treturn \"0\";\n\t\t\t\t} else if (!isNull(value)) {\n\t\t\t\t\tconst formatted = formatter.part(dateRef.set({ [part]: value }), part);\n\t\t\t\t\tif (part === \"year\") {\n\t\t\t\t\t\treturn `${value}`;\n\t\t\t\t\t}\n\t\t\t\t\tif (leadingZero && formatted.length === 1) {\n\t\t\t\t\t\treturn `0${formatted}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn formatted;\n\t\t\t\t} else {\n\t\t\t\t\treturn getPlaceholder(part, \"\", locale);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\treturn content;\n}\n\nfunction createContentArr(props: CreateContentArrProps) {\n\tconst { granularity, dateRef, formatter, contentObj, hideTimeZone, hourCycle } = props;\n\tconst parts = formatter.toParts(dateRef, getOptsByGranularity(granularity, hourCycle));\n\tconst segmentContentArr = parts\n\t\t.map((part) => {\n\t\t\tconst defaultParts = [\"literal\", \"dayPeriod\", \"timeZoneName\", null];\n\n\t\t\tif (defaultParts.includes(part.type) || !isSegmentPart(part.type)) {\n\t\t\t\treturn {\n\t\t\t\t\tpart: part.type,\n\t\t\t\t\tvalue: part.value,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpart: part.type,\n\t\t\t\tvalue: contentObj[part.type],\n\t\t\t};\n\t\t})\n\t\t.filter((segment): segment is { part: SegmentPart; value: string } => {\n\t\t\tif (isNull(segment.part) || isNull(segment.value)) return false;\n\t\t\tif (segment.part === \"timeZoneName\" && (!isZonedDateTime(dateRef) || hideTimeZone)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\treturn segmentContentArr;\n}\n\ntype CreateContentProps = CreateContentObjProps;\n\nexport function createContent(props: CreateContentProps) {\n\tconst contentObj = createContentObj(props);\n\tconst contentArr = createContentArr({\n\t\tcontentObj,\n\t\t...props,\n\t});\n\treturn {\n\t\tobj: contentObj,\n\t\tarr: contentArr,\n\t};\n}\n\nfunction getOptsByGranularity(granularity: Granularity, hourCycle: HourCycle | undefined) {\n\tconst opts: Intl.DateTimeFormatOptions = {\n\t\tyear: \"numeric\",\n\t\tmonth: \"2-digit\",\n\t\tday: \"2-digit\",\n\t\thour: \"2-digit\",\n\t\tminute: \"2-digit\",\n\t\tsecond: \"2-digit\",\n\t\ttimeZoneName: \"short\",\n\t\thourCycle: hourCycle === 24 ? \"h23\" : undefined,\n\t\thour12: hourCycle === 24 ? false : undefined,\n\t};\n\n\tif (granularity === \"day\") {\n\t\tdelete opts.second;\n\t\tdelete opts.hour;\n\t\tdelete opts.minute;\n\t\tdelete opts.timeZoneName;\n\t}\n\tif (granularity === \"hour\") {\n\t\tdelete opts.minute;\n\t}\n\tif (granularity === \"minute\") {\n\t\tdelete opts.second;\n\t}\n\n\treturn opts;\n}\n\nexport function initSegmentStates() {\n\treturn EDITABLE_SEGMENT_PARTS.reduce((acc, key) => {\n\t\tacc[key] = {\n\t\t\tlastKeyZero: false,\n\t\t\thasLeftFocus: true,\n\t\t\tupdating: null,\n\t\t};\n\t\treturn acc;\n\t}, {} as SegmentStateMap);\n}\n\nexport function initSegmentIds() {\n\treturn Object.fromEntries(\n\t\tALL_SEGMENT_PARTS.map((part) => {\n\t\t\treturn [part, useId()];\n\t\t}).filter(([key]) => key !== \"literal\")\n\t);\n}\n\nexport function isDateSegmentPart(part: unknown): part is DateSegmentPart {\n\treturn DATE_SEGMENT_PARTS.includes(part as DateSegmentPart);\n}\n\nexport function isSegmentPart(part: string): part is EditableSegmentPart {\n\treturn EDITABLE_SEGMENT_PARTS.includes(part as EditableSegmentPart);\n}\n\nexport function isAnySegmentPart(part: unknown): part is SegmentPart {\n\treturn ALL_SEGMENT_PARTS.includes(part as EditableSegmentPart);\n}\n\n/**\n * Get the segments being used/ are rendered in the DOM.\n * We're using this to determine when to set the value of\n * the date picker, which is when all the segments have\n * been filled.\n */\nfunction getUsedSegments(fieldNode: HTMLElement | null) {\n\tif (!isBrowser || !fieldNode) return [];\n\tconst usedSegments = getSegments(fieldNode)\n\t\t.map((el) => el.dataset.segment)\n\t\t.filter((part): part is EditableSegmentPart => {\n\t\t\treturn EDITABLE_SEGMENT_PARTS.includes(part as EditableSegmentPart);\n\t\t});\n\treturn usedSegments;\n}\n\ntype GetValueFromSegments = {\n\tsegmentObj: SegmentValueObj;\n\tfieldNode: HTMLElement | null;\n\tdateRef: DateValue;\n};\n\nexport function getValueFromSegments(props: GetValueFromSegments) {\n\tconst { segmentObj, fieldNode, dateRef } = props;\n\tconst usedSegments = getUsedSegments(fieldNode);\n\tlet date = dateRef;\n\n\tfor (const part of usedSegments) {\n\t\tif (\"hour\" in segmentObj) {\n\t\t\tconst value = segmentObj[part];\n\t\t\tif (isNull(value)) continue;\n\t\t\tdate = date.set({ [part]: segmentObj[part] });\n\t\t} else if (isDateSegmentPart(part)) {\n\t\t\tconst value = segmentObj[part];\n\t\t\tif (isNull(value)) continue;\n\t\t\tdate = date.set({ [part]: segmentObj[part] });\n\t\t}\n\t}\n\n\treturn date;\n}\n\n/**\n * Check if all the segments being used have been filled.\n * We use this to determine when we should set the value\n * store of the date field(s).\n *\n * @param segmentValues - The current `SegmentValueObj`\n * @param fieldNode - The id of the date field\n */\nexport function areAllSegmentsFilled(\n\tsegmentValues: SegmentValueObj,\n\tfieldNode: HTMLElement | null\n) {\n\tconst usedSegments = getUsedSegments(fieldNode);\n\tfor (const part of usedSegments) {\n\t\tif (\"hour\" in segmentValues) {\n\t\t\tif (segmentValues[part] === null) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (isDateSegmentPart(part)) {\n\t\t\tif (segmentValues[part] === null) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Determines if the provided object is a valid `DateAndTimeSegmentObj`\n * by checking if it has the correct keys and values for each key.\n */\nexport function isDateAndTimeSegmentObj(obj: unknown): obj is DateAndTimeSegmentObj {\n\tif (typeof obj !== \"object\" || obj === null) {\n\t\treturn false;\n\t}\n\treturn Object.entries(obj).every(([key, value]) => {\n\t\tconst validKey =\n\t\t\tEDITABLE_TIME_SEGMENT_PARTS.includes(key as TimeSegmentPart) ||\n\t\t\tDATE_SEGMENT_PARTS.includes(key as DateSegmentPart);\n\n\t\tconst validValue =\n\t\t\tkey === \"dayPeriod\"\n\t\t\t\t? value === \"AM\" || value === \"PM\" || value === null\n\t\t\t\t: typeof value === \"string\" || typeof value === \"number\" || value === null;\n\n\t\treturn validKey && validValue;\n\t});\n}\n\n/**\n * Infer the granularity to use based on the\n * value and granularity props.\n */\nexport function inferGranularity(\n\tvalue: DateValue,\n\tgranularity: Granularity | undefined\n): Granularity {\n\tif (granularity) return granularity;\n\tif (hasTime(value)) return \"minute\";\n\treturn \"day\";\n}\n\nexport function isAcceptableSegmentKey(key: string) {\n\tconst acceptableSegmentKeys = [\n\t\tkbd.ENTER,\n\t\tkbd.ARROW_UP,\n\t\tkbd.ARROW_DOWN,\n\t\tkbd.ARROW_LEFT,\n\t\tkbd.ARROW_RIGHT,\n\t\tkbd.BACKSPACE,\n\t\tkbd.SPACE,\n\t];\n\tif (acceptableSegmentKeys.includes(key)) return true;\n\tif (isNumberString(key)) return true;\n\treturn false;\n}\n\n/**\n * Determines if the element with the provided id is the first focusable\n * segment in the date field with the provided fieldId.\n *\n * @param id - The id of the element to check if it's the first segment\n * @param fieldNode - The id of the date field associated with the segment\n */\nexport function isFirstSegment(id: string, fieldNode: HTMLElement | null) {\n\tif (!isBrowser) return false;\n\tconst segments = getSegments(fieldNode);\n\treturn segments.length ? segments[0]!.id === id : false;\n}\n\ntype SetDescriptionProps = {\n\tid: string;\n\tformatter: Formatter;\n\tvalue: DateValue;\n\tdoc: Document;\n};\n/**\n * Creates or updates a description element for a date field\n * which enables screen readers to read the date field's value.\n *\n * This element is hidden from view, and is portalled to the body\n * so it can be associated via `aria-describedby` and read by\n * screen readers as the user interacts with the date field.\n */\nexport function setDescription(props: SetDescriptionProps) {\n\tconst { id, formatter, value, doc } = props;\n\tif (!isBrowser) return;\n\tconst valueString = formatter.selectedDate(value);\n\tconst el = doc.getElementById(id);\n\tif (!el) {\n\t\tconst div = doc.createElement(\"div\");\n\t\tdiv.style.display = \"none\";\n\t\tdiv.id = id;\n\t\tdiv.innerText = `Selected Date: ${valueString}`;\n\t\tdoc.body.appendChild(div);\n\t} else {\n\t\tel.innerText = `Selected Date: ${valueString}`;\n\t}\n}\n\n/**\n * Removes the description element for the date field with\n * the provided ID. This function should be called when the\n * date field is unmounted.\n */\nexport function removeDescriptionElement(id: string, doc: Document) {\n\tif (!isBrowser) return;\n\tconst el = doc.getElementById(id);\n\tif (!el) return;\n\tdoc.body.removeChild(el);\n}\n\nexport function getDefaultHourCycle(locale: string): 12 | 24 {\n\tconst formatter = new Intl.DateTimeFormat(locale, { hour: \"numeric\" });\n\tconst parts = formatter.formatToParts(new Date(\"2023-01-01T13:00:00\"));\n\tconst hourPart = parts.find((part) => part.type === \"hour\");\n\n\treturn hourPart?.value === \"1\" ? 12 : 24;\n}\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { KeyboardEvent, RefObject } from \"react\";\nimport { CalendarDate, type DateValue } from \"@internationalized/date\";\nimport { createFormatter } from \"#internal/date-time/formatter.js\";\nimport { getDaysInMonth } from \"#internal/date-time/utils.js\";\nimport {\n areAllSegmentsFilled,\n createContent,\n getValueFromSegments,\n initializeSegmentValues,\n isDateSegmentPart,\n} from \"./helpers.js\";\nimport { getNextSegment, getPrevSegment, getSegments } from \"./segments.js\";\nimport type { DateSegmentPart, SegmentValueObj } from \"./types.js\";\n\n/** Options for {@link useDateField}. */\nexport type UseDateFieldOptions = {\n /** Controlled value. When set, the hook reflects this value and reports edits via `onChange`. */\n value?: DateValue;\n /** Uncontrolled initial value — seeds the segments on first render. */\n defaultValue?: DateValue;\n /** Called with the reconstructed value when every editable segment is filled, or `undefined` otherwise. */\n onChange?: (v: DateValue | undefined) => void;\n /** BCP-47 locale that orders the segments and renders the literals. Defaults to `\"en\"`. */\n locale?: string;\n /** Granularity of the field. Date-only for this wave. */\n granularity?: \"day\";\n};\n\n/** One rendered slot of the date field — an editable part or a literal separator. */\nexport interface DateSegment {\n part: string;\n value: string;\n}\n\n/** Props for the field container element. */\nexport interface FieldProps {\n ref: RefObject<HTMLElement | null>;\n role: \"group\";\n}\n\n/** Props for an editable segment (spinbutton) — spread onto the part element. */\nexport interface EditableSegmentProps {\n \"data-segment\": string;\n role: \"spinbutton\";\n inputMode: \"numeric\";\n tabIndex: number;\n \"aria-label\": string;\n \"aria-valuenow\"?: number;\n \"aria-valuemin\": number;\n \"aria-valuemax\": number;\n onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;\n}\n\n/** Props for a literal (separator) segment. */\nexport interface LiteralSegmentProps {\n \"data-segment\": string;\n}\n\n/** The two segment shapes spread by {@link UseDateFieldReturn.segmentProps}. */\nexport type SegmentProps = EditableSegmentProps | LiteralSegmentProps;\n\n/** Return shape of {@link useDateField}. */\nexport interface UseDateFieldReturn {\n /** Ordered render list — editable parts and literal separators, in locale order. */\n segments: DateSegment[];\n /** Props for the field container (carries the ref the machinery queries). */\n fieldProps: FieldProps;\n /** Props builder for a single segment, keyed by its part name. */\n segmentProps: (part: string) => SegmentProps;\n /** The current value — controlled value when set, else the reconstruction when all parts are filled. */\n value: DateValue | undefined;\n}\n\nconst NEUTRAL_YEAR = 2024;\n\n/** Build a `SegmentValueObj` from a `DateValue`, seeding the date parts from its fields. */\nfunction segmentsFromValue(date: DateValue): SegmentValueObj {\n return {\n ...initializeSegmentValues(\"day\"),\n day: String(date.day),\n month: String(date.month),\n year: String(date.year),\n } as SegmentValueObj;\n}\n\n/** Days in the month implied by the current segment values (falls back to a neutral month). */\nfunction daysInCurrentMonth(segValues: SegmentValueObj): number {\n return getDaysInMonth(\n new CalendarDate(Number(segValues.year) || NEUTRAL_YEAR, Number(segValues.month) || 1, 1)\n );\n}\n\n/** The inclusive maximum for an editable date part. */\nfunction maxFor(part: DateSegmentPart, segValues: SegmentValueObj): number {\n if (part === \"month\") return 12;\n if (part === \"year\") return 9999;\n return daysInCurrentMonth(segValues);\n}\n\n/**\n * Headless date-field composable. Composes the owned `internal/date-time` machinery\n * (segment seeding, locale formatter, content layout, value reconstruction, caret\n * navigation) into a presentational-ready prop kit. The keyboard reducer is the only\n * new logic; no native date math is hand-rolled.\n */\nexport function useDateField(options: UseDateFieldOptions = {}): UseDateFieldReturn {\n const { value, defaultValue, onChange, locale = \"en\" } = options;\n const isControlled = value !== undefined;\n\n const fieldRef = useRef<HTMLElement | null>(null);\n\n const [internal, setInternal] = useState<SegmentValueObj>(() =>\n defaultValue !== undefined ? segmentsFromValue(defaultValue) : initializeSegmentValues(\"day\")\n );\n\n const segValues = useMemo<SegmentValueObj>(\n () => (value !== undefined ? segmentsFromValue(value) : internal),\n [value, internal]\n );\n\n const formatter = useMemo(() => createFormatter({ locale }), [locale]);\n const dateRef = useMemo(() => new CalendarDate(NEUTRAL_YEAR, 1, 1), []);\n\n const content = useMemo(\n () =>\n createContent({\n segmentValues: segValues,\n formatter,\n locale,\n dateRef,\n granularity: \"day\",\n hideTimeZone: false,\n hourCycle: undefined,\n }),\n [segValues, formatter, locale, dateRef]\n );\n\n const onSegKeyDown = useCallback(\n (part: DateSegmentPart) =>\n (e: KeyboardEvent<HTMLElement>): void => {\n const node = fieldRef.current;\n const segs = getSegments(node);\n const cur = segValues[part];\n const width = part === \"year\" ? 4 : 2;\n const max = maxFor(part, segValues);\n\n // Apply a new value for this part, mirror it to uncontrolled state, and\n // report through onChange when every used segment is filled.\n const commit = (nextVal: string | null): void => {\n const next = { ...segValues, [part]: nextVal } as SegmentValueObj;\n if (!isControlled) setInternal(next);\n if (node && areAllSegmentsFilled(next, node)) {\n onChange?.(getValueFromSegments({ segmentObj: next, fieldNode: node, dateRef }));\n } else {\n onChange?.(undefined);\n }\n };\n\n if (/^[0-9]$/.test(e.key)) {\n e.preventDefault();\n const prev = cur && cur.length < width ? cur : \"\";\n let candidate = prev + e.key;\n if (Number(candidate) > max) candidate = e.key;\n const complete = candidate.length >= width || Number(candidate) * 10 > max;\n const stored =\n complete && candidate.length < width ? candidate.padStart(width, \"0\") : candidate;\n commit(stored);\n if (complete) getNextSegment(e.currentTarget, segs)?.focus();\n return;\n }\n\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n e.preventDefault();\n const delta = e.key === \"ArrowUp\" ? 1 : -1;\n let n = Number(cur);\n if (!cur || Number.isNaN(n)) {\n n = delta > 0 ? 1 : max;\n } else {\n n += delta;\n if (n > max) n = 1;\n if (n < 1) n = max;\n }\n commit(part === \"year\" ? String(n) : String(n).padStart(2, \"0\"));\n return;\n }\n\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n getPrevSegment(e.currentTarget, segs)?.focus();\n return;\n }\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n getNextSegment(e.currentTarget, segs)?.focus();\n return;\n }\n\n if (e.key === \"Backspace\") {\n e.preventDefault();\n if (!cur) {\n commit(null);\n } else {\n const trimmed = cur.slice(0, -1);\n commit(trimmed.length ? trimmed : null);\n }\n }\n },\n [segValues, isControlled, onChange, dateRef]\n );\n\n const segmentProps = useCallback(\n (part: string): SegmentProps => {\n if (!isDateSegmentPart(part)) {\n return { \"data-segment\": part };\n }\n return {\n \"data-segment\": part,\n role: \"spinbutton\",\n inputMode: \"numeric\",\n tabIndex: 0,\n \"aria-label\": part,\n \"aria-valuenow\": Number(segValues[part]) || undefined,\n \"aria-valuemin\": 1,\n \"aria-valuemax\": maxFor(part, segValues),\n onKeyDown: onSegKeyDown(part),\n };\n },\n [segValues, onSegKeyDown]\n );\n\n const segments = useMemo<DateSegment[]>(\n () => content.arr.map((seg) => ({ part: seg.part, value: seg.value })),\n [content]\n );\n\n const resolvedValue = useMemo<DateValue | undefined>(() => {\n if (value !== undefined) return value;\n const node = fieldRef.current;\n if (node && areAllSegmentsFilled(segValues, node)) {\n return getValueFromSegments({ segmentObj: segValues, fieldNode: node, dateRef });\n }\n return undefined;\n }, [value, segValues, dateRef]);\n\n return {\n segments,\n fieldProps: { ref: fieldRef, role: \"group\" },\n segmentProps,\n value: resolvedValue,\n };\n}\n","import { useCallback, useMemo, useState } from \"react\";\nimport {\n type DateValue,\n getLocalTimeZone,\n isSameDay,\n today,\n} from \"@internationalized/date\";\nimport { createFormatter } from \"#internal/date-time/formatter.js\";\nimport { getLastFirstDayOfWeek, toDate } from \"#internal/date-time/utils.js\";\n\n/** Options for {@link useCalendar}. */\nexport type UseCalendarOptions = {\n /** Controlled selected day. */\n value?: DateValue;\n /** Uncontrolled initial selected day. */\n defaultValue?: DateValue;\n /** Fires when a day is chosen. */\n onChange?: (value: DateValue) => void;\n /** BCP-47 locale for the month/weekday labels + week ordering. Default \"en\". */\n locale?: string;\n /** First column of the week, 0=Sun .. 6=Sat. Default 0. */\n firstDayOfWeek?: number;\n};\n\n/** Props spread onto a single day cell. */\nexport interface CalendarCellProps {\n role: \"gridcell\";\n \"aria-selected\": boolean;\n \"aria-label\": string;\n tabIndex: number;\n onClick: () => void;\n}\n\n/** One rendered day in the month grid. */\nexport interface CalendarCell {\n date: DateValue;\n label: string;\n isSelected: boolean;\n isToday: boolean;\n isOutsideMonth: boolean;\n cellProps: CalendarCellProps;\n}\n\n/** Props for a prev/next month navigation control. */\nexport interface CalendarNavProps {\n onClick: () => void;\n \"aria-label\": string;\n}\n\n/** Return shape of {@link useCalendar}. */\nexport interface UseCalendarReturn {\n /** Localized \"month year\" header, e.g. \"March 2024\". */\n monthLabel: string;\n /** Seven localized weekday headers, in `firstDayOfWeek` order. */\n weekdays: string[];\n /** The 42 grid cells (6 weeks) for the visible month. */\n cells: CalendarCell[];\n /** Props for the grid container. */\n gridProps: { role: \"grid\"; \"aria-label\": string };\n /** The current selected value (controlled or uncontrolled). */\n selected: DateValue | undefined;\n /** Props for the previous-month control. */\n prevButtonProps: CalendarNavProps;\n /** Props for the next-month control. */\n nextButtonProps: CalendarNavProps;\n}\n\nconst GRID_CELLS = 42; // six weeks\n\n/**\n * Headless month-grid calendar composable. Composes the owned `internal/date-time`\n * machinery (locale formatter, week alignment, value conversion) over\n * `@internationalized/date` values; the only new logic is the grid assembly and\n * month paging. Presentational-ready: spread the cell/nav prop kits.\n */\nexport function useCalendar(options: UseCalendarOptions = {}): UseCalendarReturn {\n const { value, defaultValue, onChange, locale = \"en\", firstDayOfWeek = 0 } = options;\n const isControlled = value !== undefined;\n\n const [internalSelected, setInternalSelected] = useState<DateValue | undefined>(defaultValue);\n const selected = isControlled ? value : internalSelected;\n\n // The displayed month: first-of-month of the seed (selected / default / today).\n const [visibleMonth, setVisibleMonth] = useState<DateValue>(\n () => (value ?? defaultValue ?? today(getLocalTimeZone())).set({ day: 1 }),\n );\n\n const formatter = useMemo(() => createFormatter({ locale }), [locale]);\n const todayDate = useMemo(() => today(getLocalTimeZone()), []);\n\n const monthLabel = useMemo(\n () => formatter.fullMonthAndYear(toDate(visibleMonth)),\n [formatter, visibleMonth],\n );\n\n const gridStart = useMemo(\n () => getLastFirstDayOfWeek(visibleMonth.set({ day: 1 }), firstDayOfWeek, locale),\n [visibleMonth, firstDayOfWeek, locale],\n );\n\n const weekdays = useMemo<string[]>(\n () =>\n Array.from({ length: 7 }, (_, i) =>\n formatter.dayOfWeek(toDate(gridStart.add({ days: i })), \"short\"),\n ),\n [formatter, gridStart],\n );\n\n const select = useCallback(\n (date: DateValue) => {\n if (!isControlled) setInternalSelected(date);\n onChange?.(date);\n },\n [isControlled, onChange],\n );\n\n const cells = useMemo<CalendarCell[]>(\n () =>\n Array.from({ length: GRID_CELLS }, (_, i) => {\n const date = gridStart.add({ days: i });\n const isSelected = selected != null && isSameDay(date, selected);\n return {\n date,\n label: String(date.day),\n isSelected,\n isToday: isSameDay(date, todayDate),\n isOutsideMonth: date.month !== visibleMonth.month,\n cellProps: {\n role: \"gridcell\" as const,\n \"aria-selected\": isSelected,\n \"aria-label\": formatter.selectedDate(date, false),\n tabIndex: isSelected ? 0 : -1,\n onClick: () => select(date),\n },\n };\n }),\n [gridStart, selected, todayDate, visibleMonth, formatter, select],\n );\n\n return {\n monthLabel,\n weekdays,\n cells,\n gridProps: { role: \"grid\", \"aria-label\": monthLabel },\n selected,\n prevButtonProps: {\n onClick: () => setVisibleMonth((m) => m.subtract({ months: 1 })),\n \"aria-label\": \"Previous month\",\n },\n nextButtonProps: {\n onClick: () => setVisibleMonth((m) => m.add({ months: 1 })),\n \"aria-label\": \"Next month\",\n },\n };\n}\n","export function shouldEnableFocusTrap({\n\tforceMount,\n\topen,\n}: {\n\tforceMount: boolean;\n\topen: boolean;\n}): boolean {\n\tif (forceMount) return open;\n\treturn open;\n}\n","import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { FocusableTarget } from \"./focus.js\";\nimport { shouldEnableFocusTrap } from \"./should-enable-focus-trap.js\";\n\n/**\n * Options for {@link useFocusTrap}.\n */\nexport interface UseFocusTrapOptions {\n\t/** While `true`, `Tab`/`Shift+Tab` cycle within `ref`'s focusable descendants. */\n\tactive: boolean;\n\t/**\n\t * Where focus returns on deactivate — the trigger. Accepts a ref or a direct\n\t * element. When omitted, focus returns to whatever held it when the trap engaged.\n\t */\n\treturnFocusTo?: RefObject<FocusableTarget | null> | FocusableTarget | null;\n\t/**\n\t * The element to focus first on engage (e.g. an alert dialog's confirm action).\n\t * When omitted, focus moves to the first focusable descendant, else the container.\n\t */\n\tinitialFocus?: RefObject<FocusableTarget | null> | null;\n\t/** Composes `shouldEnableFocusTrap` — a portal that stays mounted while closed. */\n\tforceMount?: boolean;\n}\n\nconst FOCUSABLE_SELECTOR = [\n\t\"a[href]\",\n\t\"button:not([disabled])\",\n\t\"input:not([disabled])\",\n\t\"textarea:not([disabled])\",\n\t\"select:not([disabled])\",\n\t'[tabindex]:not([tabindex=\"-1\"])',\n].join(\",\");\n\nfunction isVisible(el: HTMLElement): boolean {\n\treturn !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);\n}\n\n/** The visible, tabbable descendants of `container`, in DOM order. */\nfunction getFocusableDescendants(container: HTMLElement): HTMLElement[] {\n\tconst nodes = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR));\n\treturn nodes.filter((el) => isVisible(el) && el.getAttribute(\"aria-hidden\") !== \"true\");\n}\n\nfunction resolveTarget(\n\tt: RefObject<FocusableTarget | null> | FocusableTarget | null | undefined,\n): FocusableTarget | null {\n\tif (!t) return null;\n\tif (\"current\" in t) return t.current;\n\treturn t;\n}\n\n/**\n * Headless focus trap + focus return. While `active`, keyboard focus is confined\n * to `ref`'s focusable descendants (Tab wraps last→first, Shift+Tab first→last,\n * and focus that escapes is pulled back); on deactivate, focus returns to\n * `returnFocusTo` (or the element that held focus when the trap engaged).\n *\n * JSX/portal-free — the `<Portal>` wrapper lives in `@mercury-fx/ui`. Guards the\n * React-19 nullable `ref.current`.\n */\nexport function useFocusTrap(\n\tref: RefObject<HTMLElement | null>,\n\t{ active, returnFocusTo, initialFocus, forceMount = false }: UseFocusTrapOptions,\n): void {\n\tconst previouslyFocused = useRef<FocusableTarget | null>(null);\n\n\tuseEffect(() => {\n\t\tconst enabled = shouldEnableFocusTrap({ forceMount, open: active });\n\t\tconst container = ref.current;\n\t\tif (!enabled || !container) return;\n\n\t\tpreviouslyFocused.current = (document.activeElement as FocusableTarget | null) ?? null;\n\n\t\tconst explicit = resolveTarget(initialFocus);\n\t\tconst firstFocusable = getFocusableDescendants(container).at(0) ?? null;\n\t\t(explicit ?? firstFocusable ?? container).focus?.();\n\n\t\tconst onKeyDown = (event: KeyboardEvent) => {\n\t\t\tif (event.key !== \"Tab\") return;\n\t\t\tconst focusables = getFocusableDescendants(container);\n\t\t\tif (focusables.length === 0) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcontainer.focus?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst first = focusables[0];\n\t\t\tconst last = focusables[focusables.length - 1];\n\t\t\tconst activeEl = document.activeElement as HTMLElement | null;\n\t\t\t// Focus has escaped the container — pull it back to an edge.\n\t\t\tif (!activeEl || !container.contains(activeEl)) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t(event.shiftKey ? last : first)?.focus?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.shiftKey && activeEl === first) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tlast?.focus?.();\n\t\t\t} else if (!event.shiftKey && activeEl === last) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tfirst?.focus?.();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener(\"keydown\", onKeyDown, true);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"keydown\", onKeyDown, true);\n\t\t\t(resolveTarget(returnFocusTo) ?? previouslyFocused.current)?.focus?.();\n\t\t};\n\t}, [active, forceMount, ref, returnFocusTo, initialFocus]);\n}\n","export function getFirstNonCommentChild(element: HTMLElement | null) {\n\tif (!element) return null;\n\tfor (const child of element.childNodes) {\n\t\tif (child.nodeType !== Node.COMMENT_NODE) {\n\t\t\treturn child;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Determines if the click event truly occurred outside the content node.\n * This was added to handle password managers and other elements that may be injected\n * into the DOM but visually appear inside the content.\n */\nexport function isClickTrulyOutside(event: PointerEvent, contentNode: HTMLElement): boolean {\n\tconst { clientX, clientY } = event;\n\tconst rect = contentNode.getBoundingClientRect();\n\n\treturn (\n\t\tclientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom\n\t);\n}\n","import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport { isClickTrulyOutside } from \"./dom.js\";\n\n/**\n * Options for {@link useDismiss}.\n */\nexport interface UseDismissOptions {\n\t/** Called when an outside press or `Escape` requests dismissal. */\n\tonDismiss: () => void;\n\t/** Dismiss on a press outside `ref`. Default `true`. `AlertDialog` opts out. */\n\toutsideClick?: boolean;\n\t/** Dismiss on `Escape`. Default `true`. */\n\tescapeKey?: boolean;\n\t/**\n\t * Elements whose presses do NOT count as outside — typically the trigger /\n\t * anchor, so re-pressing it toggles rather than double-firing dismiss + open.\n\t */\n\tignore?: ReadonlyArray<RefObject<HTMLElement | null> | null>;\n\t/** Gate the whole hook — a closed overlay ignores `Escape`/outside. Default `true`. */\n\tenabled?: boolean;\n}\n\n/**\n * The one true outside-press + `Escape` dismiss effect, replacing the overlays'\n * inline copies. Subscribes once while `enabled` and reads the latest options at\n * event time, so `outsideClick`/`escapeKey`/`onDismiss` may change without churn.\n *\n * Uses `pointerdown` (mouse + touch + pen, before `click`) and composes\n * `dom.isClickTrulyOutside`: a press dismisses only when it lands outside the\n * DOM subtree AND outside the content's box (the latter guards password-manager\n * overlays injected outside the tree but visually within). Guards the React-19\n * nullable `ref.current`.\n */\nexport function useDismiss(\n\tref: RefObject<HTMLElement | null>,\n\toptions: UseDismissOptions,\n): void {\n\tconst optsRef = useRef(options);\n\toptsRef.current = options;\n\tconst enabled = options.enabled ?? true;\n\n\tuseEffect(() => {\n\t\tif (!enabled) return;\n\n\t\tconst onPointerDown = (event: PointerEvent) => {\n\t\t\tconst o = optsRef.current;\n\t\t\tif (o.outsideClick === false) return;\n\t\t\tconst content = ref.current;\n\t\t\tif (!content) return;\n\t\t\tconst target = event.target as Node | null;\n\t\t\tif (target && content.contains(target)) return;\n\t\t\tif (o.ignore) {\n\t\t\t\tfor (const r of o.ignore) {\n\t\t\t\t\tconst el = r?.current;\n\t\t\t\t\tif (el && target && el.contains(target)) return;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!isClickTrulyOutside(event, content)) return;\n\t\t\to.onDismiss();\n\t\t};\n\n\t\tconst onKeyDown = (event: KeyboardEvent) => {\n\t\t\tconst o = optsRef.current;\n\t\t\tif (o.escapeKey === false) return;\n\t\t\tif (event.key === \"Escape\") o.onDismiss();\n\t\t};\n\n\t\tdocument.addEventListener(\"pointerdown\", onPointerDown, true);\n\t\tdocument.addEventListener(\"keydown\", onKeyDown, true);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"pointerdown\", onPointerDown, true);\n\t\t\tdocument.removeEventListener(\"keydown\", onKeyDown, true);\n\t\t};\n\t}, [enabled, ref]);\n}\n","import { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, RefObject } from \"react\";\n\n/** A side, optionally refined by a cross-axis alignment (`bottom-start` …). */\nexport type AnchoredPlacement =\n\t| \"top\"\n\t| \"bottom\"\n\t| \"left\"\n\t| \"right\"\n\t| \"top-start\"\n\t| \"top-end\"\n\t| \"bottom-start\"\n\t| \"bottom-end\"\n\t| \"left-start\"\n\t| \"left-end\"\n\t| \"right-start\"\n\t| \"right-end\";\n\n/** Cross-axis alignment for a bare side (`placement: \"bottom\"` + `align: \"end\"`). */\nexport type AnchoredAlign = \"start\" | \"center\" | \"end\";\n\n/** A pointer anchor (e.g. a context menu) — overrides the anchor element's rect. */\nexport interface AnchoredPoint {\n\tx: number;\n\ty: number;\n}\n\n/**\n * Options for {@link useAnchoredPosition}.\n */\nexport interface UseAnchoredPositionOptions {\n\t/** The placed side (+ optional compound alignment). Default `\"bottom-start\"`. */\n\tplacement?: AnchoredPlacement;\n\t/** Cross-axis alignment when `placement` is a bare side. Default `\"center\"`. */\n\talign?: AnchoredAlign;\n\t/** A fixed float width (px). When set, overrides the measured width. */\n\twidth?: number;\n\t/** Offset between the anchor and the float (px). Default `8`. */\n\tgap?: number;\n\t/** Viewport-edge clamp padding (px). Default `8`. */\n\tpadding?: number;\n\t/** Recompute while open and track scroll/resize. Default open when omitted. */\n\topen?: boolean;\n\t/** Pointer anchor — overrides the anchor rect (context-menu case). */\n\tpoint?: AnchoredPoint | null;\n}\n\n/** The return of {@link useAnchoredPosition}. */\nexport interface UseAnchoredPositionReturn {\n\t/** A `position: fixed` style to spread onto the float element. */\n\tstyle: CSSProperties;\n\t/** Force a recompute (e.g. after the float's content resizes). */\n\tupdate: () => void;\n}\n\ntype Side = \"top\" | \"bottom\" | \"left\" | \"right\";\n\ninterface RectLike {\n\ttop: number;\n\tbottom: number;\n\tleft: number;\n\tright: number;\n}\n\nfunction normalize(\n\tplacement: AnchoredPlacement,\n\talignOpt: AnchoredAlign | undefined,\n): { side: Side; align: AnchoredAlign } {\n\tconst dash = placement.indexOf(\"-\");\n\tconst side = (dash === -1 ? placement : placement.slice(0, dash)) as Side;\n\tconst compound = dash === -1 ? undefined : (placement.slice(dash + 1) as AnchoredAlign);\n\treturn { side, align: compound ?? alignOpt ?? \"center\" };\n}\n\n/** Position along one axis: align the float's start/center/end within [start,end]. */\nfunction alongAxis(start: number, end: number, size: number, align: AnchoredAlign): number {\n\tif (align === \"start\") return start;\n\tif (align === \"end\") return end - size;\n\treturn start + (end - start - size) / 2;\n}\n\nfunction computePosition(\n\trect: RectLike,\n\tfloatW: number,\n\tfloatH: number,\n\to: UseAnchoredPositionOptions,\n): { top: number; left: number } {\n\tconst { side, align } = normalize(o.placement ?? \"bottom-start\", o.align);\n\tconst gap = o.gap ?? 8;\n\tconst pad = o.padding ?? 8;\n\tlet top = 0;\n\tlet left = 0;\n\tswitch (side) {\n\t\tcase \"top\":\n\t\t\ttop = rect.top - floatH - gap;\n\t\t\tleft = alongAxis(rect.left, rect.right, floatW, align);\n\t\t\tbreak;\n\t\tcase \"bottom\":\n\t\t\ttop = rect.bottom + gap;\n\t\t\tleft = alongAxis(rect.left, rect.right, floatW, align);\n\t\t\tbreak;\n\t\tcase \"left\":\n\t\t\tleft = rect.left - floatW - gap;\n\t\t\ttop = alongAxis(rect.top, rect.bottom, floatH, align);\n\t\t\tbreak;\n\t\tcase \"right\":\n\t\t\tleft = rect.right + gap;\n\t\t\ttop = alongAxis(rect.top, rect.bottom, floatH, align);\n\t\t\tbreak;\n\t}\n\t// Clamp within the viewport so a panel never overflows an edge.\n\tconst maxLeft = Math.max(pad, window.innerWidth - floatW - pad);\n\tconst maxTop = Math.max(pad, window.innerHeight - floatH - pad);\n\treturn {\n\t\ttop: Math.min(Math.max(pad, top), maxTop),\n\t\tleft: Math.min(Math.max(pad, left), maxLeft),\n\t};\n}\n\n/**\n * Hand-rolled anchored positioning (no positioning dependency — §D). Places\n * `floatRef` relative to `anchorRef` (or a pointer `point`) using `position:\n * fixed` + `getBoundingClientRect`, so it escapes overflow/stacking contexts and\n * pairs with the `<Portal>`. Recomputes on scroll/resize while open and clamps to\n * the viewport. Supports every enum placement + the pointer case the overlay\n * family needs. Guards the React-19 nullable refs.\n */\nexport function useAnchoredPosition(\n\tanchorRef: RefObject<HTMLElement | null>,\n\tfloatRef: RefObject<HTMLElement | null>,\n\toptions: UseAnchoredPositionOptions = {},\n): UseAnchoredPositionReturn {\n\tconst optsRef = useRef(options);\n\toptsRef.current = options;\n\tconst [style, setStyle] = useState<CSSProperties>({\n\t\tposition: \"fixed\",\n\t\ttop: 0,\n\t\tleft: 0,\n\t\tvisibility: \"hidden\",\n\t});\n\n\tconst update = useCallback(() => {\n\t\tconst o = optsRef.current;\n\t\tif (o.open === false) return;\n\t\tconst float = floatRef.current;\n\t\tif (!float) return;\n\t\tconst fr = float.getBoundingClientRect();\n\t\tconst floatW = o.width ?? fr.width;\n\t\tconst floatH = fr.height;\n\n\t\tlet rect: RectLike | null = null;\n\t\tif (o.point) {\n\t\t\trect = { top: o.point.y, bottom: o.point.y, left: o.point.x, right: o.point.x };\n\t\t} else {\n\t\t\tconst anchor = anchorRef.current;\n\t\t\tif (anchor) {\n\t\t\t\tconst r = anchor.getBoundingClientRect();\n\t\t\t\trect = { top: r.top, bottom: r.bottom, left: r.left, right: r.right };\n\t\t\t}\n\t\t}\n\t\tif (!rect) return;\n\n\t\tconst { top, left } = computePosition(rect, floatW, floatH, o);\n\t\tsetStyle({\n\t\t\tposition: \"fixed\",\n\t\t\ttop,\n\t\t\tleft,\n\t\t\tvisibility: \"visible\",\n\t\t\t...(o.width != null ? { width: o.width } : {}),\n\t\t});\n\t}, [anchorRef, floatRef]);\n\n\tuseLayoutEffect(() => {\n\t\tif (options.open === false) return;\n\t\tupdate();\n\t\twindow.addEventListener(\"scroll\", update, true);\n\t\twindow.addEventListener(\"resize\", update);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"scroll\", update, true);\n\t\t\twindow.removeEventListener(\"resize\", update);\n\t\t};\n\t}, [\n\t\toptions.open,\n\t\toptions.placement,\n\t\toptions.align,\n\t\toptions.width,\n\t\toptions.gap,\n\t\toptions.point?.x,\n\t\toptions.point?.y,\n\t\tupdate,\n\t]);\n\n\treturn { style, update };\n}\n","import type { Direction } from \"#shared/index.js\";\n\ntype ArrowKeyOptions = \"horizontal\" | \"vertical\" | \"both\";\n\ninterface ArrowNavigationOptions {\n\t/**\n\t * The arrow key options to allow navigation\n\t *\n\t * @defaultValue \"both\"\n\t */\n\tarrowKeyOptions?: ArrowKeyOptions;\n\n\t/**\n\t * The selector to find the collection items in the parent element.\n\t */\n\tcandidateSelector: string;\n\n\t/**\n\t * The parent element where contains all the collection items, this will collect every item to be used when nav\n\t * It will be ignored if attributeName is provided\n\t *\n\t * @defaultValue []\n\t */\n\titemsArray?: HTMLElement[];\n\n\t/**\n\t * Allow loop navigation. If false, it will stop at the first and last element\n\t *\n\t * @defaultValue true\n\t */\n\tloop?: boolean;\n\n\t/**\n\t * The orientation of the collection\n\t *\n\t * @defaultValue \"ltr\"\n\t */\n\tdir?: Direction;\n\n\t/**\n\t * Prevent the scroll when navigating. This happens when the direction of the\n\t * key matches the scroll direction of any ancestor scrollable elements.\n\t *\n\t * @defaultValue true\n\t */\n\tpreventScroll?: boolean;\n\n\t/**\n\t * By default all currentElement would trigger navigation. If `true`, currentElement nodeName in the ignore list will return null\n\t *\n\t * @defaultValue false\n\t */\n\tenableIgnoredElement?: boolean;\n\n\t/**\n\t * Focus the element after navigation\n\t *\n\t * @defaultValue false\n\t */\n\tfocus?: boolean;\n}\n\nconst ignoredElement = [\"INPUT\", \"TEXTAREA\"];\n\n/**\n *\n * @param e Keyboard event\n * @param currentElement Event initiator element or any element that wants to handle the navigation\n * @param parentElement Parent element where contains all the collection items, this will collect every item to be used when nav\n * @param options further options\n * @returns the navigated html element or null if none\n */\nexport function useArrowNavigation(\n\te: KeyboardEvent,\n\tcurrentElement: HTMLElement,\n\tparentElement: HTMLElement | undefined,\n\toptions: ArrowNavigationOptions\n): HTMLElement | null {\n\tif (\n\t\t!currentElement ||\n\t\t(options.enableIgnoredElement && ignoredElement.includes(currentElement.nodeName))\n\t) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tarrowKeyOptions = \"both\",\n\t\tcandidateSelector: attributeName,\n\t\titemsArray = [],\n\t\tloop = true,\n\t\tdir = \"ltr\",\n\t\tpreventScroll = true,\n\t\tfocus = false,\n\t} = options;\n\n\tconst [right, left, up, down, home, end] = [\n\t\te.key === \"ArrowRight\",\n\t\te.key === \"ArrowLeft\",\n\t\te.key === \"ArrowUp\",\n\t\te.key === \"ArrowDown\",\n\t\te.key === \"Home\",\n\t\te.key === \"End\",\n\t];\n\tconst goingVertical = up || down;\n\tconst goingHorizontal = right || left;\n\tif (\n\t\t!home &&\n\t\t!end &&\n\t\t((!goingVertical && !goingHorizontal) ||\n\t\t\t(arrowKeyOptions === \"vertical\" && goingHorizontal) ||\n\t\t\t(arrowKeyOptions === \"horizontal\" && goingVertical))\n\t)\n\t\treturn null;\n\n\tconst allCollectionItems: HTMLElement[] = parentElement\n\t\t? Array.from(parentElement.querySelectorAll(attributeName))\n\t\t: itemsArray;\n\n\tif (!allCollectionItems.length) return null;\n\n\tif (preventScroll) e.preventDefault();\n\n\tlet item: HTMLElement | null = null;\n\n\tif (goingHorizontal || goingVertical) {\n\t\tconst goForward = goingVertical ? down : dir === \"ltr\" ? right : left;\n\t\titem = findNextFocusableElement(allCollectionItems, currentElement, {\n\t\t\tgoForward,\n\t\t\tloop,\n\t\t});\n\t} else if (home) {\n\t\titem = allCollectionItems.at(0) || null;\n\t} else if (end) {\n\t\titem = allCollectionItems.at(-1) || null;\n\t}\n\n\tif (focus) item?.focus();\n\n\treturn item;\n}\n\n/**\n * Recursive function to find the next focusable element to avoid disabled elements\n */\nfunction findNextFocusableElement(\n\telements: HTMLElement[],\n\tcurrentElement: HTMLElement,\n\t{ goForward, loop }: { goForward: boolean; loop?: boolean },\n\titerations = elements.length\n): HTMLElement | null {\n\tif (--iterations === 0) return null;\n\n\tconst index = elements.indexOf(currentElement);\n\tconst newIndex = goForward ? index + 1 : index - 1;\n\n\tif (!loop && (newIndex < 0 || newIndex >= elements.length)) return null;\n\n\tconst adjustedNewIndex = (newIndex + elements.length) % elements.length;\n\tconst candidate = elements[adjustedNewIndex];\n\tif (!candidate) return null;\n\n\tconst isDisabled =\n\t\tcandidate.hasAttribute(\"disabled\") && candidate.getAttribute(\"disabled\") !== \"false\";\n\tif (isDisabled) {\n\t\treturn findNextFocusableElement(elements, candidate, { goForward, loop }, iterations);\n\t}\n\treturn candidate;\n}\n"],"names":["cx","parts","toDate","dateValue","tz","getLocalTimeZone","ZonedDateTime","isCalendarDateTime","CalendarDateTime","isZonedDateTime","hasTime","getDaysInMonth","date","year","month","getLastFirstDayOfWeek","firstDayOfWeek","locale","day","getDayOfWeek","convertTimeValueToDateValue","time","Time","defaultPartOptions","isReadable","value","reader","createFormatter","opts","readLocale","readMonthFormat","readYearFormat","override","setLocale","newLocale","getLocale","custom","options","DateFormatter","selectedDate","includeTime","fullMonthAndYear","formattedMonth","formattedYear","fullMonth","fullYear","toParts","dayOfWeek","length","dayPeriod","hourCycle","p","part","dateObj","type","createTimeFormatter","activeLocale","selectedTime","timeValue","supportedLocales","placeholderFields","placeholders","getPlaceholderObj","isSupportedLocale","localeLanguage","getLocaleLanguage","getPlaceholder","field","isPlaceholderField","isDefaultField","isTimeField","DATE_SEGMENT_PARTS","EDITABLE_TIME_SEGMENT_PARTS","NON_EDITABLE_SEGMENT_PARTS","EDITABLE_SEGMENT_PARTS","ALL_SEGMENT_PARTS","isBrowser","isHTMLElement","element","isNull","getNextSegment","node","segments","index","nextIndex","getPrevSegment","prevIndex","getSegments","fieldNode","el","segment","isAnySegmentPart","counter","useId","prefix","initializeSegmentValues","granularity","calendarDateTimeGranularities","initialParts","key","createContentObj","props","segmentValues","formatter","dateRef","content","obj","isSegmentPart","getPartContent","leadingZero","intValue","formatted","is12HourMode","getDefaultHourCycle","hour","isDateSegmentPart","createContentArr","contentObj","hideTimeZone","getOptsByGranularity","createContent","contentArr","getUsedSegments","getValueFromSegments","segmentObj","usedSegments","areAllSegmentsFilled","NEUTRAL_YEAR","segmentsFromValue","daysInCurrentMonth","segValues","CalendarDate","maxFor","useDateField","defaultValue","onChange","isControlled","fieldRef","useRef","internal","setInternal","useState","useMemo","onSegKeyDown","useCallback","e","segs","cur","width","max","commit","nextVal","next","candidate","complete","stored","delta","n","trimmed","segmentProps","seg","resolvedValue","GRID_CELLS","useCalendar","internalSelected","setInternalSelected","selected","visibleMonth","setVisibleMonth","today","todayDate","monthLabel","gridStart","weekdays","_","i","select","cells","isSelected","isSameDay","m","shouldEnableFocusTrap","forceMount","open","FOCUSABLE_SELECTOR","isVisible","getFocusableDescendants","container","resolveTarget","t","useFocusTrap","ref","active","returnFocusTo","initialFocus","previouslyFocused","useEffect","enabled","explicit","firstFocusable","onKeyDown","event","focusables","first","last","activeEl","isClickTrulyOutside","contentNode","clientX","clientY","rect","useDismiss","optsRef","onPointerDown","target","r","normalize","placement","alignOpt","dash","side","compound","alongAxis","start","end","size","align","computePosition","floatW","floatH","o","gap","pad","top","left","maxLeft","maxTop","useAnchoredPosition","anchorRef","floatRef","style","setStyle","update","float","fr","anchor","useLayoutEffect","ignoredElement","useArrowNavigation","currentElement","parentElement","arrowKeyOptions","attributeName","itemsArray","loop","dir","preventScroll","focus","right","up","down","home","goingVertical","goingHorizontal","allCollectionItems","item","findNextFocusableElement","elements","goForward","iterations","newIndex","adjustedNewIndex"],"mappings":";;;AAGO,SAASA,MAAMC,GAA6B;AACjD,SAAOA,EAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;ACoHO,SAASC,EAAOC,GAAsBC,IAAaC,KAAoB;AAC7E,SAAIF,aAAqBG,KACjBH,EAAU,OAAA,IAEVA,EAAU,OAAOC,CAAE;AAE5B;AAsBA,SAASG,GAAmBJ,GAAqD;AAChF,SAAOA,aAAqBK;AAC7B;AAEO,SAASC,EAAgBN,GAA8D;AAC7F,SAAOA,aAAqBG;AAC7B;AAEO,SAASI,GAAQP,GAAqE;AAC5F,SAAOI,GAAmBJ,CAAS,KAAKM,EAAgBN,CAAS;AAClE;AAKO,SAASQ,GAAeC,GAAwB;AACtD,MAAIA,aAAgB,MAAM;AACzB,UAAMC,IAAOD,EAAK,YAAA,GACZE,IAAQF,EAAK,SAAA,IAAa;AAMhC,WAAO,IAAI,KAAKC,GAAMC,GAAO,CAAC,EAAE,QAAA;AAAA,EACjC;AACC,WAAOF,EAAK,IAAI,EAAE,KAAK,IAAA,CAAK,EAAE;AAEhC;AA6DO,SAASG,GACfH,GACAI,GACAC,GACI;AACJ,QAAMC,IAAMC,GAAaP,GAAMK,CAAM;AAErC,SAAID,IAAiBE,IACbN,EAAK,SAAS,EAAE,MAAMM,IAAM,IAAIF,GAAgB,IAEpDA,MAAmBE,IACfN,IAEDA,EAAK,SAAS,EAAE,MAAMM,IAAMF,GAAgB;AACpD;ACjPO,SAASI,EAA4BC,GAAmD;AAC9F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AK,OAGjCP,QAAa,MAAA,GAEVQ;AACR;AAKA,SAASC,GACRC,GACAlB,GACA,EAAE,WAAAmB,GAAW,MAAAd,KACbe,IAAaF,EAAS,QACD;AACrB,MAAI,EAAEE,MAAe,EAAG,QAAO;AAE/B,QAAM1L,IAAQwL,EAAS,QAAQlB,CAAc,GACvCqB,IAAWF,IAAYzL,IAAQ,IAAIA,IAAQ;AAEjD,MAAI,CAAC2K,MAASgB,IAAW,KAAKA,KAAYH,EAAS,QAAS,QAAO;AAEnE,QAAMI,KAAoBD,IAAWH,EAAS,UAAUA,EAAS,QAC3DlH,IAAYkH,EAASI,CAAgB;AAC3C,SAAKtH,IAGJA,EAAU,aAAa,UAAU,KAAKA,EAAU,aAAa,UAAU,MAAM,UAEtEiH,GAAyBC,GAAUlH,GAAW,EAAE,WAAAmH,GAAW,MAAAd,EAAA,GAAQe,CAAU,IAE9EpH,IAPgB;AAQxB;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { CalendarDateTime, DateValue, Time, ZonedDateTime } from '@internationalized/date';
|
|
2
|
+
import { DATE_SEGMENT_PARTS, EDITABLE_SEGMENT_PARTS, NON_EDITABLE_SEGMENT_PARTS, EDITABLE_TIME_SEGMENT_PARTS } from '../..internal/date-time/field/parts.js';
|
|
3
|
+
export type Granularity = "day" | "hour" | "minute" | "second";
|
|
4
|
+
export type TimeGranularity = "hour" | "minute" | "second";
|
|
5
|
+
export type HourCycle = 12 | 24;
|
|
6
|
+
export type WeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
|
+
export type DateMatcher = (date: DateValue) => boolean;
|
|
8
|
+
export type TimeValue = Time | CalendarDateTime | ZonedDateTime;
|
|
9
|
+
export type TimeValidator<T extends TimeValue> = (time: T) => string[] | string | void;
|
|
10
|
+
/**
|
|
11
|
+
* A function that returns a string or array of strings as validation errors if the date is
|
|
12
|
+
* invalid, or nothing if the date is valid
|
|
13
|
+
*/
|
|
14
|
+
export type DateValidator = (date: DateValue) => string[] | string | void;
|
|
15
|
+
/**
|
|
16
|
+
* A function that returns a string or array of strings as validation errors if the date range
|
|
17
|
+
* is invalid, or nothing if the date range is valid
|
|
18
|
+
*/
|
|
19
|
+
export type DateRangeValidator = (range: {
|
|
20
|
+
start: DateValue;
|
|
21
|
+
end: DateValue;
|
|
22
|
+
}) => string[] | string | void;
|
|
23
|
+
export type TimeRangeValidator<T extends TimeValue = Time> = (range: {
|
|
24
|
+
start: T;
|
|
25
|
+
end: T;
|
|
26
|
+
}) => string[] | string | void;
|
|
27
|
+
/**
|
|
28
|
+
* A callback fired when the date field's value is invalid. Use this to display an error
|
|
29
|
+
* message to the user.
|
|
30
|
+
*/
|
|
31
|
+
export type DateOnInvalid = (reason: "min" | "max" | "custom", msg?: string | string[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* A callback fired when the time field's value is invalid. Use this to display an error
|
|
34
|
+
* message to the user.
|
|
35
|
+
*/
|
|
36
|
+
export type TimeOnInvalid = (reason: "min" | "max" | "custom", msg?: string | string[]) => void;
|
|
37
|
+
export type DateRange = {
|
|
38
|
+
start: DateValue | undefined;
|
|
39
|
+
end: DateValue | undefined;
|
|
40
|
+
};
|
|
41
|
+
export type TimeRange<T extends TimeValue = Time> = {
|
|
42
|
+
start: T | undefined;
|
|
43
|
+
end: T | undefined;
|
|
44
|
+
};
|
|
45
|
+
export type Month<T> = {
|
|
46
|
+
/**
|
|
47
|
+
* A `DateValue` used to represent the month. Since days
|
|
48
|
+
* from the previous and next months may be included in the
|
|
49
|
+
* calendar grid, we need a source of truth for the value
|
|
50
|
+
* the grid is representing.
|
|
51
|
+
*/
|
|
52
|
+
value: DateValue;
|
|
53
|
+
/**
|
|
54
|
+
* An array of arrays representing the weeks in the calendar.
|
|
55
|
+
* Each sub-array represents a week, and contains the dates for each
|
|
56
|
+
* day in that week. This structure is useful for rendering the calendar
|
|
57
|
+
* grid using a table, where each row represents a week and each cell
|
|
58
|
+
* represents a day.
|
|
59
|
+
*/
|
|
60
|
+
weeks: T[][];
|
|
61
|
+
/**
|
|
62
|
+
* An array of all the dates in the current month, including dates from
|
|
63
|
+
* the previous and next months that are used to fill out the calendar grid.
|
|
64
|
+
* This array is useful for rendering the calendar grid in a customizable way,
|
|
65
|
+
* as it provides all the dates that should be displayed in the grid in a flat
|
|
66
|
+
* array.
|
|
67
|
+
*/
|
|
68
|
+
dates: T[];
|
|
69
|
+
};
|
|
70
|
+
export type DateSegmentPart = (typeof DATE_SEGMENT_PARTS)[number];
|
|
71
|
+
export type EditableTimeSegmentPart = (typeof EDITABLE_TIME_SEGMENT_PARTS)[number];
|
|
72
|
+
export type EditableSegmentPart = (typeof EDITABLE_SEGMENT_PARTS)[number];
|
|
73
|
+
export type NonEditableSegmentPart = (typeof NON_EDITABLE_SEGMENT_PARTS)[number];
|
|
74
|
+
export type SegmentPart = EditableSegmentPart | NonEditableSegmentPart;
|
|
75
|
+
export type TimeSegmentPart = EditableTimeSegmentPart | "literal" | "timeZoneName";
|
|
76
|
+
export type AnyTimeExceptLiteral = Exclude<TimeSegmentPart, "literal">;
|
|
77
|
+
export type AnyExceptLiteral = Exclude<SegmentPart, "literal">;
|
|
78
|
+
export type DayPeriod = "AM" | "PM" | null;
|
|
79
|
+
export type DateSegmentObj = {
|
|
80
|
+
[K in DateSegmentPart]: string | null;
|
|
81
|
+
};
|
|
82
|
+
export type TimeSegmentObj = {
|
|
83
|
+
[K in EditableTimeSegmentPart]: K extends "dayPeriod" ? DayPeriod : string | null;
|
|
84
|
+
};
|
|
85
|
+
export type DateAndTimeSegmentObj = DateSegmentObj & TimeSegmentObj;
|
|
86
|
+
export type SegmentValueObj = DateSegmentObj | DateAndTimeSegmentObj;
|
|
87
|
+
export type SegmentContentObj = Record<EditableSegmentPart, string>;
|
|
88
|
+
export type TimeSegmentValueObj = TimeSegmentObj;
|
|
89
|
+
export type TimeSegmentContentObj = Record<EditableTimeSegmentPart, string>;
|
|
90
|
+
export type SegmentState = {
|
|
91
|
+
lastKeyZero: boolean;
|
|
92
|
+
hasLeftFocus: boolean;
|
|
93
|
+
updating: string | null;
|
|
94
|
+
};
|
|
95
|
+
export type SegmentStateMap = {
|
|
96
|
+
[K in EditableSegmentPart]: SegmentState;
|
|
97
|
+
};
|
|
98
|
+
export type TimeSegmentStateMap = {
|
|
99
|
+
[K in EditableTimeSegmentPart]: SegmentState;
|
|
100
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as CSS from "csstype";
|
|
2
|
+
export type Selected<Value> = {
|
|
3
|
+
value: Value;
|
|
4
|
+
label?: string;
|
|
5
|
+
};
|
|
6
|
+
export type SegmentPart = "month" | "day" | "year" | "hour" | "minute" | "second" | "dayPeriod" | "timeZoneName" | "literal";
|
|
7
|
+
export type FocusTarget = string | HTMLElement | SVGElement | null;
|
|
8
|
+
export type FocusProp = FocusTarget | ((defaultEl?: HTMLElement | null) => FocusTarget);
|
|
9
|
+
export type StyleProperties = CSS.Properties & {
|
|
10
|
+
[str: `--${string}`]: any;
|
|
11
|
+
};
|
|
12
|
+
export type Orientation = "horizontal" | "vertical";
|
|
13
|
+
export type Direction = "ltr" | "rtl";
|
|
14
|
+
/**
|
|
15
|
+
* Controls positioning of the slider thumb.
|
|
16
|
+
*
|
|
17
|
+
* - `exact`: The thumb is centered exactly at the value of the slider.
|
|
18
|
+
* - `contain`: The thumb is centered exactly at the value of the slider, but will be contained within the slider track at the ends.
|
|
19
|
+
*/
|
|
20
|
+
export type SliderThumbPositioning = "exact" | "contain";
|
|
21
|
+
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
|
|
22
|
+
export type WithoutChildren<T> = T extends {
|
|
23
|
+
children?: any;
|
|
24
|
+
} ? Omit<T, "children"> : T;
|
|
25
|
+
export type WithoutChild<T> = T extends {
|
|
26
|
+
child?: any;
|
|
27
|
+
} ? Omit<T, "child"> : T;
|
|
28
|
+
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & {
|
|
29
|
+
ref?: U | null;
|
|
30
|
+
};
|
|
31
|
+
export type { EditableSegmentPart, EditableTimeSegmentPart } from './date/types.js';
|
|
32
|
+
export type { Month, DateMatcher, DateOnInvalid, DateRangeValidator, DateValidator, DateRange, TimeValue, TimeSegmentPart, TimeRange, TimeValidator, TimeRangeValidator, TimeOnInvalid, } from './date/types.js';
|
|
33
|
+
export type { WithChild, Without, WithChildren } from '..internal/types.js';
|
|
34
|
+
export { mergeProps } from '..utils/merge-props.js';
|
|
35
|
+
export { useId } from '..internal/use-id.js';
|
|
36
|
+
export * from './types.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type FloatingContentSnippetProps = {
|
|
2
|
+
/**
|
|
3
|
+
* Whether the content is open or closed. Used alongside the `forceMount` prop to
|
|
4
|
+
* conditionally render the content using Svelte transitions.
|
|
5
|
+
*/
|
|
6
|
+
open: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Attributes to spread onto a wrapper element around the content.
|
|
9
|
+
* Do not style the wrapper element, its styles are computed by Floating UI.
|
|
10
|
+
*/
|
|
11
|
+
wrapperProps: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export type StaticContentSnippetProps = Omit<FloatingContentSnippetProps, "wrapperProps">;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as CSS from "csstype";
|
|
2
|
+
export type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return;
|
|
3
|
+
export type Getter<T> = () => T;
|
|
4
|
+
export type Expand<T> = T extends infer U ? {
|
|
5
|
+
[K in keyof U]: U[K];
|
|
6
|
+
} : never;
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a new type by omitting properties from type
|
|
9
|
+
* 'T' that exist in type 'U'.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The base object type from which properties will be omitted.
|
|
12
|
+
* @template U - The object type whose properties will be omitted from 'T'.
|
|
13
|
+
* @example
|
|
14
|
+
* type Result = Without<{ a: number; b: string; }, { b: string; }>;
|
|
15
|
+
* // Result type will be { a: number; }
|
|
16
|
+
*/
|
|
17
|
+
export type Without<T extends object, U extends object> = Omit<T, keyof U>;
|
|
18
|
+
export type WithoutChild<T> = T extends {
|
|
19
|
+
child?: any;
|
|
20
|
+
} ? Omit<T, "child"> : T;
|
|
21
|
+
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
|
|
22
|
+
export type WithoutChildren<T> = T extends {
|
|
23
|
+
children?: any;
|
|
24
|
+
} ? Omit<T, "children"> : T;
|
|
25
|
+
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & {
|
|
26
|
+
ref?: U | null;
|
|
27
|
+
};
|
|
28
|
+
export type StyleProperties = CSS.Properties & {
|
|
29
|
+
[str: `--${string}`]: any;
|
|
30
|
+
};
|
|
31
|
+
export type AnyFn = (...args: any[]) => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A self-contained `clsx` — joins class values (strings, numbers, arrays, and
|
|
3
|
+
* `{ class: boolean }` dictionaries) into one className string, skipping falsy
|
|
4
|
+
* entries. Inlined (no dependency) for `mergeProps`'s rich `class` merging.
|
|
5
|
+
*/
|
|
6
|
+
export type ClassValue = ClassValue[] | Record<string, unknown> | string | number | bigint | null | boolean | undefined;
|
|
7
|
+
export declare function clsx(...inputs: ClassValue[]): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function isHTMLElement(node: unknown): node is HTMLElement;
|
|
2
|
+
export declare function isDocument(node: unknown): node is Document;
|
|
3
|
+
export declare function isWindow(node: unknown): node is Window;
|
|
4
|
+
export declare function getNodeName(node: Node | Window): string;
|
|
5
|
+
export declare function isNode(node: unknown): node is Node;
|
|
6
|
+
export declare function isShadowRoot(node: unknown): node is ShadowRoot;
|
|
7
|
+
type Target = HTMLElement | EventTarget | null | undefined;
|
|
8
|
+
export declare function contains(parent: Target, child: Target): boolean;
|
|
9
|
+
export declare function getDocument(node: Element | Window | Node | Document | null | undefined): Document;
|
|
10
|
+
export declare function getDocumentElement(node: Element | Node | Window | Document | null | undefined): HTMLElement;
|
|
11
|
+
export declare function getWindow(node: Node | ShadowRoot | Document | null | undefined): Window & typeof globalThis;
|
|
12
|
+
export declare function getActiveElement(rootNode: Document | ShadowRoot): HTMLElement | null;
|
|
13
|
+
export declare function getParentNode(node: Node): Node;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EVENT_LIST_SET: Set<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Arrayable<T> = T | T[];
|
|
2
|
+
export type EventCallback<E extends Event = Event> = (event: E) => void;
|
|
3
|
+
type GeneralEventListener<E = Event> = (evt: E) => unknown;
|
|
4
|
+
export declare function addEventListener<E extends keyof WindowEventMap>(target: Window, event: Arrayable<E>, handler: (this: Window, ev: WindowEventMap[E]) => unknown, options?: boolean | AddEventListenerOptions): VoidFunction;
|
|
5
|
+
export declare function addEventListener<E extends keyof DocumentEventMap>(target: Document, event: Arrayable<E>, handler: (this: Document, ev: DocumentEventMap[E]) => unknown, options?: boolean | AddEventListenerOptions): VoidFunction;
|
|
6
|
+
export declare function addEventListener<E extends keyof HTMLElementEventMap>(target: EventTarget, event: Arrayable<E>, handler: GeneralEventListener<HTMLElementEventMap[E]>, options?: boolean | AddEventListenerOptions): VoidFunction;
|
|
7
|
+
/**
|
|
8
|
+
* Compose multiple event handlers into one. Handlers run in order; if any of
|
|
9
|
+
* them calls `event.preventDefault()`, the remaining handlers are skipped. Used
|
|
10
|
+
* by {@link mergeProps} to chain a component's handler with a consumer's.
|
|
11
|
+
*/
|
|
12
|
+
export declare function composeHandlers<E extends Event>(...handlers: Array<EventCallback<E> | undefined>): (event: E) => void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes an array of callback functions with the same arguments.
|
|
3
|
+
* @template T The types of the arguments that the callback functions take.
|
|
4
|
+
* @param callbacks array of callback functions to execute.
|
|
5
|
+
* @returns A new function that executes all of the original callback functions with the same arguments.
|
|
6
|
+
*/
|
|
7
|
+
export declare function executeCallbacks<T extends unknown[]>(...callbacks: T): (...args: unknown[]) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ClassValue } from './clsx.js';
|
|
2
|
+
export declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
|
|
3
|
+
export declare function isObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
4
|
+
export declare function isClassValue(value: unknown): value is ClassValue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type Props = Record<string, unknown>;
|
|
2
|
+
type PropsArg = Props | null | undefined;
|
|
3
|
+
type TupleTypes<T> = {
|
|
4
|
+
[P in keyof T]: T[P];
|
|
5
|
+
} extends {
|
|
6
|
+
[key: number]: infer V;
|
|
7
|
+
} ? NullToObject<V> : never;
|
|
8
|
+
type NullToObject<T> = T extends null | undefined ? {} : T;
|
|
9
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
10
|
+
/**
|
|
11
|
+
* Given a list of prop objects, merges them into a single object.
|
|
12
|
+
* - Automatically composes event handlers (e.g. `onclick`, `oninput`, etc.)
|
|
13
|
+
* - Chains regular functions with the same name so they are called in order
|
|
14
|
+
* - Merges class strings with `clsx`
|
|
15
|
+
* - Merges style objects and converts them to strings
|
|
16
|
+
* - Handles a bug with Svelte where setting the `hidden` attribute to `false` doesn't remove it
|
|
17
|
+
* - Overrides other values with the last one
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeProps<T extends PropsArg[]>(...args: T): UnionToIntersection<TupleTypes<T>> & {
|
|
20
|
+
style?: string;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StyleProperties } from '..types.js';
|
|
2
|
+
export declare function styleToCSS(styleObj: object): string;
|
|
3
|
+
/**
|
|
4
|
+
* Parse a CSS declaration string (`"display: none; --x: 1"`) into a style
|
|
5
|
+
* object. Standard properties are camelCased; `--*` custom properties are kept
|
|
6
|
+
* verbatim. The inverse of {@link styleToCSS}; used by `mergeProps` to merge a
|
|
7
|
+
* string `style` with an object one.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cssToStyleObj(css: string | null | undefined): StyleProperties;
|