compote-ui
Version:
An opinionated UI component library for Svelte, built on top of [Ark UI](https://ark-ui.com) with additional components and features not available in the core Ark UI library.
27 lines (26 loc) • 1.55 kB
TypeScript
import { type DateValue } from '@internationalized/date';
export type { DateValue };
/**
* Anything the date components accept for a single value: an
* `@internationalized/date` value, an ISO/DB string, a native `Date`, or null.
*/
export type DateInputValue = DateValue | string | Date | null | undefined;
/** The runtime shape a bound value was provided in, used to round-trip on change. */
export type DateValueShape = 'string' | 'date' | 'date-value';
/** Report the runtime shape of a value so a change can be emitted in the same shape. */
export declare function dateValueShape(value: DateInputValue): DateValueShape | null;
/**
* Coerce a string / `Date` / `DateValue` into a `DateValue` for Ark UI.
*
* String auto-detection:
* - `"2024-01-15"` → {@link parseDate} (date-only)
* - `"2024-01-15T10:30:00"` → {@link parseDateTime} (local datetime)
* - `"2024-01-15T10:30:00Z"` / `"…+02:00"` → zoned (in `timeZone`, else local)
*/
export declare function toDateValue(value: DateInputValue, timeZone?: string): DateValue | null;
/** Serialize a `DateValue` to an ISO string (absolute `…Z` for zoned values). */
export declare function dateValueToString(value: DateValue): string;
/** Convert a `DateValue` to a native `Date`. */
export declare function dateValueToDate(value: DateValue, timeZone?: string): Date;
/** Emit a `DateValue` back in the original `shape` it was bound as. */
export declare function fromDateValue(value: DateValue | null, shape: DateValueShape, timeZone?: string): DateValue | string | Date | null;