@lumx/core 4.14.0-next.1 → 4.14.0-next.3

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,57 @@
1
+ import type { SetupStoriesOptions } from '@lumx/core/stories/types';
2
+ /**
3
+ * Setup TimePickerField stories for a specific framework (React or Vue).
4
+ *
5
+ * The framework wrapper (`TimePickerField`) is fully self-contained — it builds
6
+ * its option list from `step`/`minTime`/`maxTime`/`locale` internally — so each
7
+ * story is just an args object with optional render override.
8
+ */
9
+ export declare function setup({ component: TimePickerField, decorators: { withValueOnChange, withCombinations }, }: SetupStoriesOptions<{
10
+ decorators: 'withValueOnChange' | 'withCombinations';
11
+ }>): {
12
+ meta: {
13
+ component: any;
14
+ args: {
15
+ label: string;
16
+ locale: string;
17
+ translations: {
18
+ clearLabel: string;
19
+ showSuggestionsLabel: string;
20
+ };
21
+ };
22
+ decorators: ((story: any, context: any) => any)[];
23
+ };
24
+ Default: {};
25
+ WithValue: {
26
+ args: {
27
+ value: Date;
28
+ };
29
+ };
30
+ Step15: {
31
+ args: {
32
+ step: number;
33
+ };
34
+ };
35
+ WithMinTime: {
36
+ args: {
37
+ minTime: Date;
38
+ };
39
+ };
40
+ WithMaxTime: {
41
+ args: {
42
+ maxTime: Date;
43
+ };
44
+ };
45
+ French: {
46
+ args: {
47
+ locale: string;
48
+ value: Date;
49
+ };
50
+ };
51
+ Disabled: {
52
+ args: {
53
+ value: Date;
54
+ };
55
+ decorators: ((story: any, context: any) => any)[];
56
+ };
57
+ };
@@ -0,0 +1,29 @@
1
+ export declare const TRANSLATIONS: {
2
+ clearLabel: string;
3
+ showSuggestionsLabel: string;
4
+ };
5
+ type RenderResult = {
6
+ unmount: () => void;
7
+ container: HTMLElement;
8
+ };
9
+ /**
10
+ * Options to set up the TimePickerField test suite.
11
+ * Injected by the framework-specific test file (React or Vue).
12
+ */
13
+ export interface TimePickerFieldTestSetup {
14
+ components: {
15
+ TimePickerField: any;
16
+ };
17
+ /**
18
+ * Render a TimePickerField template with controlled state management.
19
+ *
20
+ * @param template JSX render function receiving `{ value, onChange, ... }`.
21
+ * @param initialArgs Initial props (value, spies, etc.).
22
+ */
23
+ renderWithState: (template: (props: any) => any, initialArgs?: Record<string, any>) => RenderResult;
24
+ }
25
+ export declare function createTemplates(TimePickerField: any): {
26
+ defaultTemplate: (props: any) => import("react").JSX.Element;
27
+ };
28
+ export default function timePickerFieldTests({ components, renderWithState }: TimePickerFieldTestSetup): void;
29
+ export {};
@@ -0,0 +1,64 @@
1
+ import type { GenericProps, HasClassName, HasTheme, LumxClassName } from '../../types';
2
+ import type { TimeOfDay } from '../../utils/time';
3
+ import type { SelectTextFieldTranslations } from '../../utils/select/types';
4
+ /**
5
+ * Component display name.
6
+ */
7
+ export declare const COMPONENT_NAME = "TimePickerField";
8
+ /**
9
+ * Component default class name (BEM root).
10
+ */
11
+ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
12
+ /**
13
+ * Translations consumed by `TimePickerField` (forwarded as-is to the underlying
14
+ * `SelectTextField`).
15
+ */
16
+ export type TimePickerFieldTranslations = Pick<SelectTextFieldTranslations, 'clearLabel' | 'showSuggestionsLabel'>;
17
+ /**
18
+ * Core props for the `TimePickerField` template.
19
+ */
20
+ export interface TimePickerFieldProps extends HasTheme, HasClassName, GenericProps {
21
+ /**
22
+ * Currently selected option. Resolve from the consumer's `Date` value via
23
+ * `value && timeList.find((e) => e.hour === value.getHours() && e.minute === value.getMinutes())`.
24
+ */
25
+ value?: TimeOfDay;
26
+ /** Time options (one entry per `step`-minute slot). */
27
+ options: TimeOfDay[];
28
+ /** Translation labels (clear button, show-suggestions toggle). */
29
+ translations: TimePickerFieldTranslations;
30
+ /** Called when the user picks (or clears) an option. */
31
+ handleChange(next: TimeOfDay | undefined): void;
32
+ /** Called as the user types — wrappers track this to resolve on blur. */
33
+ handleSearch(typed: string): void;
34
+ /** Called when the input loses focus — wrappers commit the typed value. */
35
+ handleBlur(): void;
36
+ }
37
+ /**
38
+ * Injected framework-specific components for TimePickerField rendering.
39
+ */
40
+ export interface TimePickerFieldComponents {
41
+ /** Framework-specific `SelectTextField` wrapper. */
42
+ SelectTextField: any;
43
+ /** Framework-specific `SelectTextField.Option` sub-component (used to render disabled out-of-range entries). */
44
+ Option: any;
45
+ }
46
+ /**
47
+ * `TimePickerField` core template.
48
+ *
49
+ * Renders a `SelectTextField<TimeOfDay>` with an option list built from
50
+ * `buildTimeList`. Out-of-range options (strictly before `minTime` / after
51
+ * `maxTime`) remain visible in the dropdown but are rendered as disabled.
52
+ *
53
+ * Framework-specific components are passed as a second argument by the
54
+ * React/Vue wrappers.
55
+ *
56
+ * @param props Component props.
57
+ * @param components Injected framework-specific components.
58
+ * @return JSX element.
59
+ */
60
+ export declare const TimePickerField: {
61
+ (props: TimePickerFieldProps, { SelectTextField, Option }: TimePickerFieldComponents): import("react").JSX.Element;
62
+ displayName: string;
63
+ className: "lumx-time-picker-field";
64
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get current browser locale (BCP-47 string).
3
+ *
4
+ * Reads `navigator.languages[0]` (the user's preferred language) with a
5
+ * fallback to `navigator.language`.
6
+ */
7
+ export declare const getCurrentLocale: () => string;
@@ -0,0 +1 @@
1
+ export { getCurrentLocale } from './getCurrentLocale';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A time-of-day (24h), independent of any date or time zone. Canonical
3
+ * exchange shape for the time utilities and `TimePickerField`.
4
+ */
5
+ export interface TimeOfDay {
6
+ /** 0–23 */
7
+ hour: number;
8
+ /** 0–59 */
9
+ minute: number;
10
+ /** Locale-aware short display string. Populated by `buildTimeList` when `locale` is set. */
11
+ name?: string;
12
+ /**
13
+ * `true` when strictly outside `[minTime, maxTime]`. Set by `buildTimeList`;
14
+ * consumers typically forward this as `isDisabled` on the rendered option.
15
+ */
16
+ outOfRange?: boolean;
17
+ }
18
+ /** Options for `buildTimeList`. */
19
+ export interface BuildTimeListOptions {
20
+ /** Positive integer minute interval between entries. @default 30 */
21
+ step?: number;
22
+ /** Lower bound (date part ignored). Entries before are kept but marked `outOfRange`. */
23
+ minTime?: Date;
24
+ /** Upper bound (date part ignored). Entries after are kept but marked `outOfRange`. */
25
+ maxTime?: Date;
26
+ /** BCP-47 locale used to populate `name` on each entry. */
27
+ locale?: string;
28
+ }
29
+ /**
30
+ * Build a full-day list of `TimeOfDay` entries spaced `step` minutes apart.
31
+ * Out-of-bounds entries are kept (with `outOfRange: true`) so consumers can
32
+ * render them as visible-but-unselectable. Returns `[]` for invalid `step`.
33
+ */
34
+ export declare function buildTimeList(options?: BuildTimeListOptions): TimeOfDay[];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Format a time-of-day as a locale-aware short time (e.g. `'10:30 AM'`,
3
+ * `'10:30'`). Hour is `numeric` (not `'2-digit'`); some locales insert a
4
+ * narrow no-break space (U+202F) before AM/PM.
5
+ */
6
+ export declare function formatTime(date: Date, locale: string): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Build a new `Date` with the given time-of-day, inheriting the date part of
3
+ * `reference` (or today). Seconds/ms zeroed; `reference` is not mutated.
4
+ */
5
+ export declare function getDateAtTime({ hour, minute }: {
6
+ hour: number;
7
+ minute: number;
8
+ }, reference?: Date): Date;
@@ -0,0 +1,8 @@
1
+ /** Time of day utilities */
2
+ export { buildTimeList, type BuildTimeListOptions, type TimeOfDay } from './buildTimeList';
3
+ export { formatTime } from './formatTime';
4
+ export { parseTimeInput } from './parseTimeInput';
5
+ export { getDateAtTime } from './getDateAtTime';
6
+ export { timeOfDayMinutes } from './timeOfDayMinutes';
7
+ export { snapTimeToBounds } from './snapTimeToBounds';
8
+ export { isDateOnTime } from './isDateOnTime';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns `true` when the time-of-day of `date` matches `time` (hour and
3
+ * minute). Seconds and milliseconds are ignored.
4
+ */
5
+ export declare function isDateOnTime(date: Date, time: {
6
+ hour: number;
7
+ minute: number;
8
+ }): boolean;
@@ -0,0 +1,16 @@
1
+ import type { TimeOfDay } from './buildTimeList';
2
+ /**
3
+ * Parse a free-form user time input into a 24h `TimeOfDay`. Accepts a wide
4
+ * range of formats:
5
+ *
6
+ * - 12h AM/PM: `'2pm'`, `'2 PM'`, `'2:30pm'`, `'3.45 PM'`, `'3:45 p.m.'`
7
+ * - 24h colon: `'10:30'`, `'15:45'`
8
+ * - 24h dot (DE/FR/IT): `'15.45'`
9
+ * - 24h French: `'15h45'`
10
+ * - Military / no separator: `'1545'`, `'1030pm'`
11
+ * - With seconds (ignored): `'15:45:00'`
12
+ * - ISO 8601: `'T15:45'`, `'15:45Z'`
13
+ *
14
+ * Whitespace is trimmed. Returns `undefined` if no format matches.
15
+ */
16
+ export declare function parseTimeInput(raw: string): TimeOfDay | undefined;
@@ -0,0 +1,7 @@
1
+ import type { TimeOfDay } from './buildTimeList';
2
+ /**
3
+ * Clamp `time` to `[minTime, maxTime]`. Inputs strictly before `minTime` snap
4
+ * up; inputs strictly after `maxTime` snap down; otherwise returned unchanged.
5
+ * Only the time-of-day of `minTime`/`maxTime` is used.
6
+ */
7
+ export declare function snapTimeToBounds(time: TimeOfDay, minTime?: Date, maxTime?: Date): TimeOfDay;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Return the time-of-day of `date` in minutes since 00:00 (date part ignored).
3
+ */
4
+ export declare function timeOfDayMinutes(date: Date): number;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@floating-ui/dom": "^1.7.5",
10
- "@lumx/icons": "^4.14.0-next.1",
10
+ "@lumx/icons": "^4.14.0-next.3",
11
11
  "classnames": "^2.3.2",
12
12
  "focus-visible": "^5.0.2",
13
13
  "lodash": "4.18.1",
@@ -69,7 +69,7 @@
69
69
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
70
70
  },
71
71
  "sideEffects": false,
72
- "version": "4.14.0-next.1",
72
+ "version": "4.14.0-next.3",
73
73
  "devDependencies": {
74
74
  "@rollup/plugin-typescript": "^12.3.0",
75
75
  "@testing-library/dom": "^10.4.1",