@gnome-ui/react-native 1.12.0 → 1.13.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.
@@ -0,0 +1,36 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ import { TimeValue } from './timeUtils';
3
+ export interface TimeFieldsProps {
4
+ /** The time the columns show. Always concrete — callers supply the fallback. */
5
+ value: TimeValue;
6
+ /** Called with the whole time whenever any column moves. */
7
+ onChange: (value: TimeValue) => void;
8
+ /** 12- or 24-hour presentation. Defaults to `24`. */
9
+ hourCycle?: 12 | 24;
10
+ /** Minute increment for the spinner. Defaults to `1`. */
11
+ minuteStep?: number;
12
+ /**
13
+ * Prefix for each column's accessible label — `"Start"` gives
14
+ * "Start hours". Needed when a panel carries more than one set of columns.
15
+ */
16
+ labelPrefix?: string;
17
+ style?: StyleProp<ViewStyle>;
18
+ }
19
+ /**
20
+ * The hour/minute (and AM/PM) `SpinButton` columns — the panel half of
21
+ * `TimePicker`, split out so `DatePicker`'s `showTime` footer can reuse the
22
+ * same 12/24-hour bookkeeping without re-implementing it.
23
+ *
24
+ * Ported from `@gnome-ui/react`'s `TimePicker/TimeFields.tsx`: mirrors its
25
+ * prop API and `to12`/`to24` bookkeeping exactly, rebuilt on this package's
26
+ * own `SpinButton` (already shipped in Tier 5, with a matching `wrap`
27
+ * boolean and `format: (n: number) => string` callback — confirmed by
28
+ * reading `SpinButton.tsx` before wiring this up, no new prop needed for the
29
+ * AM/PM column's "numeric spinner whose `format` maps 0/1 to text" trick).
30
+ *
31
+ * **Not exported from the package**: `TimePicker` is this module's public
32
+ * face; `DatePicker`'s `showTime` footer imports it directly via
33
+ * `@/components/TimePicker/TimeFields`, the same cross-folder internal
34
+ * import `Calendar/calendarUtils.ts`'s `WeekStart` already established.
35
+ */
36
+ export declare const TimeFields: ({ value, onChange, hourCycle, minuteStep, labelPrefix, style, }: TimeFieldsProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,55 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ import { PopoverPlacement } from '../Popover';
3
+ import { TimeValue } from './timeUtils';
4
+ export type { TimeValue } from './timeUtils';
5
+ export interface TimePickerProps {
6
+ /** Controlled selected time. Pass `null` for "no selection". */
7
+ value?: TimeValue | null;
8
+ /** Initial selected time when uncontrolled. Defaults to `null`. */
9
+ defaultValue?: TimeValue | null;
10
+ /** Called when the user changes the time. */
11
+ onChange?: (value: TimeValue) => void;
12
+ /** 12- or 24-hour presentation. Defaults to `24`. */
13
+ hourCycle?: 12 | 24;
14
+ /** Minute increment for the spinner. Defaults to `1`. */
15
+ minuteStep?: number;
16
+ /** Text shown in the trigger while no time is selected. */
17
+ placeholder?: string;
18
+ /** Visible label rendered above the trigger. */
19
+ label?: string;
20
+ /** Accessible name for the trigger when no visible `label` is provided. */
21
+ accessibilityLabel?: string;
22
+ /** Disable the control. */
23
+ disabled?: boolean;
24
+ /** Preferred popover placement relative to the trigger. Defaults to `'bottom'`. */
25
+ placement?: PopoverPlacement;
26
+ style?: StyleProp<ViewStyle>;
27
+ testID?: string;
28
+ }
29
+ /**
30
+ * Hour/minute selection built from paired `SpinButton`s inside a `Popover`,
31
+ * behind an entry-styled trigger — mirrors the `GtkSpinButton` + `GtkPopover`
32
+ * composition GNOME apps use for time entry, with 12- and 24-hour support.
33
+ *
34
+ * Rebuilt on this package's own already-shipped `Popover` (Tier 5) rather
35
+ * than reinventing its trigger-rect + panel-size positioning, the same
36
+ * standing pitfall `DatePicker` already avoided. The panel is just
37
+ * `TimeFields` — no Done button, unlike `DatePicker`'s `showTime` footer:
38
+ * there is no calendar tap to disambiguate from a close here, so each
39
+ * column commits live and the popover only closes the same way `Dropdown`'s
40
+ * does, by tapping outside or the trigger again.
41
+ *
42
+ * **`TimeFields`/`timeUtils` moved here from `DatePicker`'s own folder**,
43
+ * where they first shipped as an internal dependency of its `showTime`
44
+ * footer — this is their intended public home (per the ROADMAP note left
45
+ * when `DatePicker` shipped), `DatePicker` now imports them from here
46
+ * instead of carrying its own copy.
47
+ *
48
+ * The web version's entire keyboard layer drops (no `ArrowDown`-opens focus
49
+ * management, no `Enter`/`Space` on the trigger) — the same touch-first
50
+ * convention `DatePicker` already follows. `locale` is dropped in favor of
51
+ * `GnomeProvider`'s app-wide `useDateTimeFormatter`, same as `DatePicker`.
52
+ *
53
+ * @see https://developer.gnome.org/hig/patterns/controls/spin-buttons.html
54
+ */
55
+ export declare const TimePicker: ({ value: controlledValue, defaultValue, onChange, hourCycle, minuteStep, placeholder, label, accessibilityLabel, disabled, placement, style, testID, }: TimePickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export type { TimePickerProps, TimeValue } from './TimePicker';
2
+ export { TimePicker } from './TimePicker';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Pure time helpers shared by `TimePicker` and `DatePicker`'s `showTime`
3
+ * footer. Ported verbatim from `@gnome-ui/react`'s `TimePicker/timeUtils.ts`
4
+ * — no DOM dependency there already, the same `calendarUtils.ts` precedent.
5
+ *
6
+ * Not exported from the package barrel — `DatePicker` imports it directly
7
+ * via `@/components/TimePicker/timeUtils`, the same cross-folder internal
8
+ * import `Calendar/calendarUtils.ts`'s `WeekStart` already established.
9
+ */
10
+ /** A wall-clock time, in 24-hour terms. */
11
+ export interface TimeValue {
12
+ /** Hours, `0`–`23`. */
13
+ hours: number;
14
+ /** Minutes, `0`–`59`. */
15
+ minutes: number;
16
+ }
17
+ /** Zero-padded two-digit rendering for a clock column. */
18
+ export declare const pad2: (n: number) => string;
19
+ /** Split a 0–23 hour into its 12-hour parts (`period`: 0 = AM, 1 = PM). */
20
+ export declare const to12: (hours24: number) => {
21
+ hour: number;
22
+ period: number;
23
+ };
24
+ /** Recombine a 12-hour clock reading into a 0–23 hour. */
25
+ export declare const to24: (hour12: number, period: number) => number;
26
+ /** The wall-clock time carried by a `Date`. */
27
+ export declare const timeOf: (date: Date) => TimeValue;
28
+ /**
29
+ * `date`'s calendar day at `time`'s wall clock.
30
+ *
31
+ * A local `Date` cannot represent an hour that a DST spring-forward skips, and
32
+ * the platform silently shifts it (02:30 → 03:30). That shift is kept — it is
33
+ * the only real instant for that reading — so callers should read the result
34
+ * back rather than assume the requested hour survived.
35
+ */
36
+ export declare const mergeDateAndTime: (date: Date, time: TimeValue) => Date;