API reference
Every export of @sigx/lynx-datetime-picker v0.4.9.
The package has a single import surface: the DateTimePicker object plus the mode, option, and result types.
import { DateTimePicker } from '@sigx/lynx-datetime-picker';
import type {
DateTimePickerMode,
DateTimePickerOptions,
DateTimePickerResult,
} from '@sigx/lynx-datetime-picker';
DateTimePicker
The single value export — a frozen (as const) object grouping all picker entry points. It presents a native date/time picker (UIDatePicker in a presented sheet on iOS, DatePickerDialog / TimePickerDialog on Android) and bridges to the native DateTimePicker module. The methods are closed-over and do not depend on this, so the object survives destructuring.
const DateTimePicker: {
pick(opts?: DateTimePickerOptions): Promise<DateTimePickerResult>;
pickDate(opts?: Omit<DateTimePickerOptions, 'mode'>): Promise<DateTimePickerResult>;
pickTime(opts?: Omit<DateTimePickerOptions, 'mode'>): Promise<DateTimePickerResult>;
pickDateTime(opts?: Omit<DateTimePickerOptions, 'mode'>): Promise<DateTimePickerResult>;
isModuleAvailable(): boolean;
};
Platform: iOS and Android.
Methods
DateTimePicker.pick
Presents the picker; opts.mode selects what to pick.
DateTimePicker.pick(opts?: DateTimePickerOptions): Promise<DateTimePickerResult>
opts— optionalDateTimePickerOptions. Defaults to{}.modedefaults to'date'.- Returns a
DateTimePickerResult. The promise always resolves — cancellation, swipe-to-dismiss, a missing native module, a missing host/activity, and any bridge error all come back as{ cancelled: true }rather than rejecting. A malformed or non-finite native value also resolves to cancelled.
Platform: iOS and Android.
DateTimePicker.pickDate
Convenience wrapper for pick({ ...opts, mode: 'date' }) — picks a calendar date.
DateTimePicker.pickDate(opts?: Omit<DateTimePickerOptions, 'mode'>): Promise<DateTimePickerResult>
opts— optional options withoutmode. Defaults to{}.- Returns a
DateTimePickerResult.
Platform: iOS and Android.
DateTimePicker.pickTime
Convenience wrapper for pick({ ...opts, mode: 'time' }) — picks a time of day.
DateTimePicker.pickTime(opts?: Omit<DateTimePickerOptions, 'mode'>): Promise<DateTimePickerResult>
opts— optional options withoutmode. Defaults to{}.- Returns a
DateTimePickerResult. The value is still a fullDateanchored to the initial value's day (or today); readresult.hour/result.minutefor the time-only answer. minimumDate/maximumDateare ignored in this mode.
Platform: iOS and Android. minuteInterval applies only on iOS.
DateTimePicker.pickDateTime
Convenience wrapper for pick({ ...opts, mode: 'datetime' }) — picks combined date and time.
DateTimePicker.pickDateTime(opts?: Omit<DateTimePickerOptions, 'mode'>): Promise<DateTimePickerResult>
opts— optional options withoutmode. Defaults to{}.- Returns a
DateTimePickerResult.
Platform: iOS shows a single combined wheel. Android chains a date dialog and then a time dialog — cancelling either step cancels the whole pick.
DateTimePicker.isModuleAvailable
Reports whether the native DateTimePicker module is wired into the current build.
DateTimePicker.isModuleAvailable(): boolean
- Returns
trueif the native module was linked (bysigx prebuild), otherwisefalse. Synchronous. Delegates to@sigx/lynx-core'sisModuleAvailable('DateTimePicker').
Platform: iOS and Android.
Types
DateTimePickerMode
What the picker selects. Used as the mode option.
type DateTimePickerMode = 'date' | 'time' | 'datetime';
'date'— calendar date only (the default).'time'— time of day only.'datetime'— combined date and time.
Platform: cross-platform.
DateTimePickerOptions
Options for presenting the picker.
interface DateTimePickerOptions {
mode?: DateTimePickerMode;
value?: Date;
minimumDate?: Date;
maximumDate?: Date;
minuteInterval?: number;
is24Hour?: boolean;
title?: string;
}
mode— what to pick. Defaults to'date'. SeeDateTimePickerMode.value— initial selection. Defaults to "now" (decided native-side). An invalid or absentDateis dropped before crossing the bridge.minimumDate— earliest selectable instant. Ignored in'time'mode.maximumDate— latest selectable instant. Ignored in'time'mode.minuteInterval— iOS-onlyUIDatePicker.minuteInterval. Must evenly divide 60 (native clamps to1-30with60 % n === 0, otherwise it is ignored). Android has no equivalent.is24Hour— use a 24-hour clock for time. Defaults to the device setting. On iOS this is emulated via the BCP-47hclocale extension; on Android it defaults toDateFormat.is24HourFormat.title— sheet/toolbar title. iOS only; unused on Android.
Platform: cross-platform (minuteInterval and title are iOS-only).
DateTimePickerResult
The result of a pick.
interface DateTimePickerResult {
cancelled: boolean;
value?: Date;
year?: number;
month?: number;
day?: number;
hour?: number;
minute?: number;
}
cancelled—truewhen dismissed without choosing, or on bridge failure / a malformed value.value— the selected instant as a JSDate. Absent when cancelled.year/month/day/hour/minute— convenience local components ofvalue.monthis1-12(unlikeDate#getMonth, which is0-11) andhouris0-23. All component fields are absent when cancelled.
Platform: cross-platform.
