@gamecrafters/base-ui 0.0.38 → 0.0.39

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,4 @@
1
+ import * as React from "react";
2
+ import type { DateInputProps } from "./DateInput.types";
3
+ declare const _default: (props: DateInputProps & React.RefAttributes<any>) => React.ReactNode;
4
+ export default _default;
@@ -0,0 +1,137 @@
1
+ import type * as React from "react";
2
+ import type { CalendarDateInput, CalendarDateMatcher, CalendarMode, CalendarRange, CalendarRangeInput } from "../calendar/Calendar.types";
3
+ import type { TextInputSize } from "../text-input/TextInput.types";
4
+ export type DateInputGranularity = "day" | "hour" | "minute" | "second";
5
+ export type DateInputHourCycle = 12 | 24;
6
+ export type DateInputEditableSegmentType = "year" | "month" | "day" | "hour" | "minute" | "second" | "dayPeriod";
7
+ export type DateInputSegmentType = DateInputEditableSegmentType | "literal";
8
+ export type DateInputSegmentDetails = {
9
+ type: DateInputSegmentType;
10
+ text: string;
11
+ value?: number;
12
+ minValue?: number;
13
+ maxValue?: number;
14
+ placeholder: string;
15
+ placeholderShown: boolean;
16
+ entered: boolean;
17
+ filled: boolean;
18
+ editable: boolean;
19
+ };
20
+ export type DateInputIds = {
21
+ root?: string;
22
+ label?: string;
23
+ control?: string;
24
+ segmentGroup?: (index: number) => string;
25
+ hiddenInput?: (index: number) => string;
26
+ };
27
+ export type DateInputSegmentLabels = Partial<Record<DateInputEditableSegmentType, string>>;
28
+ export type DateInputPropsForOneDay = {
29
+ mode?: "single";
30
+ value?: CalendarDateInput | null;
31
+ defaultValue?: CalendarDateInput | null;
32
+ onChange?: (date: Date | null) => void;
33
+ };
34
+ export type DateInputPropsForARange = {
35
+ mode: "range";
36
+ value?: CalendarRangeInput | null;
37
+ defaultValue?: CalendarRangeInput | null;
38
+ onChange?: (range: CalendarRange) => void;
39
+ };
40
+ export type DateInputSelectionConfig = DateInputPropsForOneDay | DateInputPropsForARange;
41
+ type DateInputStoreProps = {
42
+ locale?: string;
43
+ granularity?: DateInputGranularity;
44
+ hourCycle?: DateInputHourCycle;
45
+ leadingZeros?: boolean;
46
+ placeholderValue?: CalendarDateInput;
47
+ min?: CalendarDateInput;
48
+ max?: CalendarDateInput;
49
+ isDateUnavailable?: CalendarDateMatcher;
50
+ format?: string;
51
+ segmentLabels?: DateInputSegmentLabels;
52
+ disabled?: boolean;
53
+ readOnly?: boolean;
54
+ required?: boolean;
55
+ invalid?: boolean;
56
+ name?: string;
57
+ form?: string;
58
+ id?: string;
59
+ ids?: DateInputIds;
60
+ onFocusChange?: (focused: boolean) => void;
61
+ };
62
+ export type UseDateInputProps = DateInputStoreProps & DateInputSelectionConfig;
63
+ export type UseDateInputElementProps = DateInputStoreProps & {
64
+ mode?: CalendarMode;
65
+ value?: CalendarDateInput | CalendarRangeInput | null;
66
+ defaultValue?: CalendarDateInput | CalendarRangeInput | null;
67
+ onChange?: ((date: Date | null) => void) | ((range: CalendarRange) => void);
68
+ };
69
+ export type UseDateInputReturn = {
70
+ mode: CalendarMode;
71
+ locale: string;
72
+ value: (Date | null)[];
73
+ valueAsString: string[];
74
+ placeholderValue: Date;
75
+ focused: boolean;
76
+ activeIndex: number;
77
+ disabled: boolean;
78
+ readOnly: boolean;
79
+ required: boolean;
80
+ invalid: boolean;
81
+ name?: string;
82
+ form?: string;
83
+ ids: Required<DateInputIds>;
84
+ describedBy?: string;
85
+ segmentLabels: Record<DateInputEditableSegmentType, string>;
86
+ focus: (index?: number) => void;
87
+ setValue: (value: (CalendarDateInput | null)[]) => void;
88
+ clearValue: () => void;
89
+ getSegments: (index?: number) => DateInputSegmentDetails[];
90
+ rootRef: React.RefObject<HTMLDivElement | null>;
91
+ handleSegmentFocus: (index: number, event: React.FocusEvent<HTMLElement>) => void;
92
+ handleSegmentPointerDown: () => void;
93
+ handleSegmentBlur: (event: React.FocusEvent<HTMLElement>) => void;
94
+ handleSegmentKeyDown: (index: number, event: React.KeyboardEvent<HTMLElement>) => void;
95
+ handleSegmentInput: (index: number, event: React.InputEvent<HTMLElement>) => void;
96
+ handleSegmentPaste: (index: number, event: React.ClipboardEvent<HTMLElement>) => void;
97
+ };
98
+ type DateInputFieldProps = {
99
+ size?: TextInputSize;
100
+ block?: boolean;
101
+ contrast?: boolean;
102
+ className?: string;
103
+ };
104
+ export type DateInputProps = Omit<React.ComponentPropsWithoutRef<"div">, keyof UseDateInputElementProps> & UseDateInputProps & DateInputFieldProps;
105
+ export type DateInputElementProps = Omit<React.ComponentPropsWithoutRef<"div">, keyof UseDateInputElementProps> & UseDateInputElementProps & DateInputFieldProps;
106
+ export type DateInputRootProviderProps = Omit<React.ComponentPropsWithoutRef<"div">, "onChange" | "defaultValue"> & DateInputFieldProps & {
107
+ value: UseDateInputReturn;
108
+ };
109
+ export type DateInputLabelProps = React.ComponentPropsWithoutRef<"label"> & {
110
+ className?: string;
111
+ };
112
+ export type DateInputControlProps = React.ComponentPropsWithoutRef<"div"> & {
113
+ className?: string;
114
+ };
115
+ export type DateInputSegmentGroupChildren = React.ReactNode | ((segments: DateInputSegmentDetails[]) => React.ReactNode);
116
+ export type DateInputSegmentGroupProps = Omit<React.ComponentPropsWithoutRef<"div">, "children"> & {
117
+ index?: number;
118
+ children?: DateInputSegmentGroupChildren;
119
+ className?: string;
120
+ };
121
+ export type DateInputSegmentProps = Omit<React.ComponentPropsWithoutRef<"span">, "children"> & {
122
+ segment: DateInputSegmentDetails;
123
+ className?: string;
124
+ };
125
+ export type DateInputHiddenInputProps = Omit<React.ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue"> & {
126
+ index?: number;
127
+ name?: string;
128
+ className?: string;
129
+ };
130
+ export type DateInputContextValue = Partial<UseDateInputReturn> & Omit<DateInputFieldProps, "className"> & {
131
+ ariaLabel?: string;
132
+ ariaLabelledBy?: string;
133
+ };
134
+ export type DateInputSegmentGroupContextValue = {
135
+ index: number;
136
+ };
137
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { DateInputContextValue, DateInputSegmentGroupContextValue } from "./DateInput.types";
2
+ export declare const DateInputContext: import("react").Context<DateInputContextValue>;
3
+ export declare const useDateInputContext: () => DateInputContextValue;
4
+ export declare const DateInputSegmentGroupContext: import("react").Context<DateInputSegmentGroupContextValue>;
5
+ export declare const useDateInputSegmentGroupContext: () => DateInputSegmentGroupContextValue;
6
+ export declare const getStateAttributes: ({ disabled, readOnly, required, invalid, }: DateInputContextValue) => {
7
+ "data-disabled": true | undefined;
8
+ "data-readonly": true | undefined;
9
+ "data-required": true | undefined;
10
+ "data-invalid": true | undefined;
11
+ };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ className?: string;
4
+ } & React.RefAttributes<any>) => React.ReactNode;
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "value" | "defaultValue" | "type"> & {
3
+ index?: number;
4
+ name?: string;
5
+ className?: string;
6
+ } & React.RefAttributes<any>) => React.ReactNode;
7
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
3
+ className?: string;
4
+ } & React.RefAttributes<any>) => React.ReactNode;
5
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onChange" | "defaultValue"> & {
3
+ size?: import("..").TextInputSize;
4
+ block?: boolean;
5
+ contrast?: boolean;
6
+ className?: string;
7
+ } & {
8
+ value: import("./DateInput.types").UseDateInputReturn;
9
+ } & React.RefAttributes<any>) => React.ReactNode;
10
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "children"> & {
3
+ segment: import("./DateInput.types").DateInputSegmentDetails;
4
+ className?: string;
5
+ } & React.RefAttributes<any>) => React.ReactNode;
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
3
+ index?: number;
4
+ children?: import("./DateInput.types").DateInputSegmentGroupChildren;
5
+ className?: string;
6
+ } & React.RefAttributes<any>) => React.ReactNode;
7
+ export default _default;
@@ -0,0 +1,49 @@
1
+ import type { Dayjs } from "dayjs";
2
+ import type { DateInputEditableSegmentType, DateInputSegmentDetails, DateInputSegmentType } from "./DateInput.types";
3
+ export type DateInputHourCycleId = "h11" | "h12" | "h23" | "h24";
4
+ export type DateInputFields = {
5
+ year: number | null;
6
+ month: number | null;
7
+ day: number | null;
8
+ hour: number | null;
9
+ minute: number | null;
10
+ second: number | null;
11
+ dayPeriod: number | null;
12
+ };
13
+ export type DateInputFieldLimits = {
14
+ minValue: number;
15
+ maxValue: number;
16
+ };
17
+ export declare const createFields: () => DateInputFields;
18
+ export declare const toHourCycle: (hour: number, hourCycle: DateInputHourCycleId) => [dayPeriod: number | null, hour: number];
19
+ export declare const fromHourCycle: (hour: number, dayPeriod: number, hourCycle: DateInputHourCycleId) => number;
20
+ export declare const getFieldLimits: (type: DateInputEditableSegmentType, hourCycle: DateInputHourCycleId) => DateInputFieldLimits;
21
+ export declare const fieldsFromDate: (date: Dayjs, hourCycle: DateInputHourCycleId) => DateInputFields;
22
+ export declare const fieldsToDate: (fields: DateInputFields, base: Dayjs, hourCycle: DateInputHourCycleId) => Dayjs;
23
+ export declare const withHourCycle: (fields: DateInputFields, from: DateInputHourCycleId, to: DateInputHourCycleId) => DateInputFields;
24
+ export declare const isComplete: (fields: DateInputFields, types: DateInputEditableSegmentType[]) => boolean;
25
+ export declare const isCleared: (fields: DateInputFields, types: DateInputEditableSegmentType[]) => boolean;
26
+ export declare const setField: (fields: DateInputFields, type: DateInputEditableSegmentType, value: number, base: Dayjs, hourCycle: DateInputHourCycleId) => DateInputFields;
27
+ export declare const clearField: (fields: DateInputFields, type: DateInputEditableSegmentType) => DateInputFields;
28
+ export declare const cycleValue: (value: number, amount: number, min: number, max: number, round?: boolean) => number;
29
+ export declare const cycleField: (fields: DateInputFields, type: DateInputEditableSegmentType, amount: number, base: Dayjs, hourCycle: DateInputHourCycleId) => DateInputFields;
30
+ export declare const constrainDate: (date: Dayjs, min: Dayjs | null, max: Dayjs | null) => Dayjs;
31
+ export type TypedInputOptions = {
32
+ fields: DateInputFields;
33
+ segment: DateInputSegmentDetails;
34
+ input: string;
35
+ enteredKeys: string;
36
+ base: Dayjs;
37
+ hourCycle: DateInputHourCycleId;
38
+ hour12: boolean;
39
+ dayPeriodNames: [am: string, pm: string];
40
+ };
41
+ export type TypedInputResult = {
42
+ fields: DateInputFields | null;
43
+ enteredKeys: string;
44
+ advance: boolean;
45
+ };
46
+ export declare const readTypedInput: ({ fields, segment, input, enteredKeys, base, hourCycle, hour12, dayPeriodNames, }: TypedInputOptions) => TypedInputResult | null;
47
+ export declare const parsePastedDate: (text: string, formats: string[]) => Dayjs | null;
48
+ export declare const isFocusableSegment: (segment: DateInputSegmentDetails) => boolean;
49
+ export declare const isEditableType: (type: DateInputSegmentType) => type is DateInputEditableSegmentType;
@@ -0,0 +1,26 @@
1
+ import type { Dayjs } from "dayjs";
2
+ import type { DateInputFields, DateInputHourCycleId } from "./dateInputFields";
3
+ import type { DateInputEditableSegmentType, DateInputGranularity, DateInputHourCycle, DateInputSegmentDetails } from "./DateInput.types";
4
+ export declare const DEFAULT_SEGMENT_LABELS: Record<DateInputEditableSegmentType, string>;
5
+ export declare const PAGE_STEPS: Partial<Record<DateInputEditableSegmentType, number>>;
6
+ export declare const DEFAULT_FORMATS: Record<DateInputGranularity, string>;
7
+ export declare const getPastedFormats: (format: string) => string[];
8
+ export declare const getPlaceholders: (locale: string) => Record<DateInputEditableSegmentType, string>;
9
+ export type SegmentFormatterOptions = {
10
+ granularity: DateInputGranularity;
11
+ leadingZeros: boolean;
12
+ hourCycle?: DateInputHourCycle;
13
+ };
14
+ export declare const createSegmentFormatter: (locale: string, options: SegmentFormatterOptions) => Intl.DateTimeFormat;
15
+ export declare const resolveHourCycle: (formatter: Intl.DateTimeFormat) => DateInputHourCycleId;
16
+ export declare const getDayPeriodNames: (locale: string) => [am: string, pm: string];
17
+ export declare const getSegmentTypes: (formatter: Intl.DateTimeFormat) => DateInputEditableSegmentType[];
18
+ export type BuildSegmentsOptions = {
19
+ fields: DateInputFields;
20
+ date: Dayjs;
21
+ formatter: Intl.DateTimeFormat;
22
+ placeholders: Record<DateInputEditableSegmentType, string>;
23
+ granularity: DateInputGranularity;
24
+ hourCycle: DateInputHourCycleId;
25
+ };
26
+ export declare const buildSegments: ({ fields, date, formatter, placeholders, granularity, hourCycle, }: BuildSegmentsOptions) => DateInputSegmentDetails[];
@@ -0,0 +1,41 @@
1
+ import DateInputControl from "./DateInputControl";
2
+ import DateInputHiddenInput from "./DateInputHiddenInput";
3
+ import DateInputLabel from "./DateInputLabel";
4
+ import DateInputRootProvider from "./DateInputRootProvider";
5
+ import DateInputSegment from "./DateInputSegment";
6
+ import DateInputSegmentGroup from "./DateInputSegmentGroup";
7
+ export declare const DateInput: ((props: import("./DateInput.types").DateInputProps & import("react").RefAttributes<any>) => React.ReactNode) & {
8
+ Root: (props: import("./DateInput.types").DateInputProps & import("react").RefAttributes<any>) => React.ReactNode;
9
+ RootProvider: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onChange" | "defaultValue"> & {
10
+ size?: import("..").TextInputSize;
11
+ block?: boolean;
12
+ contrast?: boolean;
13
+ className?: string;
14
+ } & {
15
+ value: import("./DateInput.types").UseDateInputReturn;
16
+ } & import("react").RefAttributes<any>) => React.ReactNode;
17
+ Label: (props: Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
18
+ className?: string;
19
+ } & import("react").RefAttributes<any>) => React.ReactNode;
20
+ Control: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
21
+ className?: string;
22
+ } & import("react").RefAttributes<any>) => React.ReactNode;
23
+ SegmentGroup: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
24
+ index?: number;
25
+ children?: import("./DateInput.types").DateInputSegmentGroupChildren;
26
+ className?: string;
27
+ } & import("react").RefAttributes<any>) => React.ReactNode;
28
+ Segment: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "children"> & {
29
+ segment: import("./DateInput.types").DateInputSegmentDetails;
30
+ className?: string;
31
+ } & import("react").RefAttributes<any>) => React.ReactNode;
32
+ HiddenInput: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "value" | "defaultValue" | "type"> & {
33
+ index?: number;
34
+ name?: string;
35
+ className?: string;
36
+ } & import("react").RefAttributes<any>) => React.ReactNode;
37
+ };
38
+ export { DateInputRootProvider, DateInputLabel, DateInputControl, DateInputSegmentGroup, DateInputSegment, DateInputHiddenInput, };
39
+ export { DateInputContext, DateInputSegmentGroupContext, useDateInputContext, useDateInputSegmentGroupContext, } from "./DateInputContext";
40
+ export { useDateInput } from "./useDateInput";
41
+ export * from "./DateInput.types";
@@ -0,0 +1,2 @@
1
+ import type { UseDateInputProps, UseDateInputReturn } from "./DateInput.types";
2
+ export declare const useDateInput: (props?: UseDateInputProps) => UseDateInputReturn;
@@ -36,6 +36,7 @@ export * from "./confirmation-dialog";
36
36
  export * from "./context-menu";
37
37
  export * from "./counter-label";
38
38
  export * from "./data-table";
39
+ export * from "./date-input";
39
40
  export * from "./date-picker";
40
41
  export * from "./details";
41
42
  export * from "./dialog";