Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import React from 'react';
interface AmPmInputProps extends Omit<React.ComponentPropsWithoutRef<'select'>, 'value' | 'onChange'> {
labels: {
am: string;
pm: string;
};
value: string | null;
inputType: 'select' | 'input';
onChange: (value: string | null) => void;
readOnly?: boolean;
onPreviousInput?: () => void;
}
export declare const AmPmInput: React.ForwardRefExoticComponent<AmPmInputProps & React.RefAttributes<HTMLSelectElement>>;
export {};

View File

@@ -0,0 +1,13 @@
interface AmPmControlsListProps {
value: string | null;
onSelect: (value: string) => void;
labels: {
am: string;
pm: string;
};
}
export declare function AmPmControlsList({ labels, value, onSelect }: AmPmControlsListProps): import("react/jsx-runtime").JSX.Element;
export declare namespace AmPmControlsList {
var displayName: string;
}
export {};

View File

@@ -0,0 +1,10 @@
interface TimeControlProps {
value: number | string;
active: boolean;
onSelect: (value: any) => void;
}
export declare function TimeControl({ value, active, onSelect }: TimeControlProps): import("react/jsx-runtime").JSX.Element;
export declare namespace TimeControl {
var displayName: string;
}
export {};

View File

@@ -0,0 +1,13 @@
interface TimeControlsListProps {
min: number;
max: number;
step: number;
value: number | null;
onSelect: (value: number) => void;
reversed: boolean | undefined;
}
export declare function TimeControlsList({ min, max, step, value, onSelect, reversed, }: TimeControlsListProps): import("react/jsx-runtime").JSX.Element;
export declare namespace TimeControlsList {
var displayName: string;
}
export {};

View File

@@ -0,0 +1,12 @@
import { GetStylesApi, ScrollAreaProps } from '@mantine/core';
import type { TimePickerFactory } from './TimePicker';
interface TimePickerContext {
getStyles: GetStylesApi<TimePickerFactory>;
maxDropdownContentHeight: number;
scrollAreaProps: ScrollAreaProps | undefined;
}
export declare const TimePickerProvider: ({ children, value }: {
value: TimePickerContext;
children: React.ReactNode;
}) => import("react/jsx-runtime").JSX.Element, useTimePickerContext: () => TimePickerContext;
export {};

View File

@@ -0,0 +1,106 @@
import { __BaseInputProps, __InputStylesNames, BoxProps, CloseButtonProps, DataAttributes, ElementProps, Factory, InputVariant, PopoverProps, ScrollAreaProps, StylesApiProps } from '@mantine/core';
import { TimePickerAmPmLabels, TimePickerFormat, TimePickerPasteSplit, TimePickerPresets } from './TimePicker.types';
export type TimePickerStylesNames = 'fieldsRoot' | 'fieldsGroup' | 'field' | 'controlsList' | 'controlsListGroup' | 'control' | 'dropdown' | 'presetsRoot' | 'presetsGroup' | 'presetsGroupLabel' | 'presetControl' | 'scrollarea' | __InputStylesNames;
export type TimePickerCssVariables = {
dropdown: '--control-font-size';
};
export interface TimePickerProps extends BoxProps, __BaseInputProps, StylesApiProps<TimePickerFactory>, ElementProps<'div', 'onChange' | 'defaultValue'> {
/** Controlled component value */
value?: string;
/** Uncontrolled component default value */
defaultValue?: string;
/** Called when the value changes */
onChange?: (value: string) => void;
/** Determines whether the clear button should be displayed @default `false` */
clearable?: boolean;
/** `name` prop passed down to the hidden input */
name?: string;
/** `form` prop passed down to the hidden input */
form?: string;
/** Min possible time value in `hh:mm:ss` format */
min?: string;
/** Max possible time value in `hh:mm:ss` format */
max?: string;
/** Time format, `'24h'` by default */
format?: TimePickerFormat;
/** Number by which hours are incremented/decremented @default `1` */
hoursStep?: number;
/** Number by which minutes are incremented/decremented @default `1` */
minutesStep?: number;
/** Number by which seconds are incremented/decremented @default `1` */
secondsStep?: number;
/** Determines whether the seconds input should be displayed @default `false` */
withSeconds?: boolean;
/** `aria-label` of hours input */
hoursInputLabel?: string;
/** `aria-label` of minutes input */
minutesInputLabel?: string;
/** `aria-label` of seconds input */
secondsInputLabel?: string;
/** `aria-label` of am/pm input */
amPmInputLabel?: string;
/** Labels used for am/pm values @default `{ am: 'AM', pm: 'PM' }` */
amPmLabels?: TimePickerAmPmLabels;
/** Determines whether the dropdown with time controls list should be visible when the input has focus @default `false` */
withDropdown?: boolean;
/** Props passed down to `Popover` component */
popoverProps?: PopoverProps;
/** Called once when one of the inputs is focused, not called when focused is shifted between hours, minutes, seconds and am/pm inputs */
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
/** Called once when the focus is no longer on any of the inputs */
onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
/** Props passed down to clear button */
clearButtonProps?: CloseButtonProps & ElementProps<'button'> & DataAttributes;
/** Props passed down to hours input */
hoursInputProps?: React.ComponentPropsWithoutRef<'input'> & DataAttributes;
/** Props passed down to minutes input */
minutesInputProps?: React.ComponentPropsWithoutRef<'input'> & DataAttributes;
/** Props passed down to seconds input */
secondsInputProps?: React.ComponentPropsWithoutRef<'input'> & DataAttributes;
/** Props passed down to am/pm select */
amPmSelectProps?: React.ComponentPropsWithoutRef<'select'> & DataAttributes;
/** If set, the value cannot be updated */
readOnly?: boolean;
/** If set, the component becomes disabled */
disabled?: boolean;
/** Props passed down to the hidden input */
hiddenInputProps?: React.ComponentPropsWithoutRef<'input'> & DataAttributes;
/** A function to transform paste values, by default time in 24h format can be parsed on paste for example `23:34:22` */
pasteSplit?: TimePickerPasteSplit;
/** A ref object to get node reference of the hours input */
hoursRef?: React.Ref<HTMLInputElement>;
/** A ref object to get node reference of the minutes input */
minutesRef?: React.Ref<HTMLInputElement>;
/** A ref object to get node reference of the seconds input */
secondsRef?: React.Ref<HTMLInputElement>;
/** A ref object to get node reference of the am/pm select */
amPmRef?: React.Ref<HTMLSelectElement>;
/** Time presets to display in the dropdown */
presets?: TimePickerPresets;
/** Maximum height of the content displayed in the dropdown in px @default `200` */
maxDropdownContentHeight?: number;
/** Props passed down to all underlying `ScrollArea` components */
scrollAreaProps?: ScrollAreaProps;
/** If set, the time controls list are reversed, @default `false` */
reverseTimeControlsList?: boolean;
/** Hours input placeholder, @default `--` */
hoursPlaceholder?: string;
/** Minutes input placeholder, @default `--` */
minutesPlaceholder?: string;
/** Seconds input placeholder, @default `--` */
secondsPlaceholder?: string;
}
export type TimePickerFactory = Factory<{
props: TimePickerProps;
ref: HTMLDivElement;
stylesNames: TimePickerStylesNames;
vars: TimePickerCssVariables;
variant: InputVariant;
}>;
export declare const TimePicker: import("@mantine/core").MantineComponent<{
props: TimePickerProps;
ref: HTMLDivElement;
stylesNames: TimePickerStylesNames;
vars: TimePickerCssVariables;
variant: InputVariant;
}>;

View File

@@ -0,0 +1,22 @@
export type TimePickerFormat = '12h' | '24h';
export interface TimePickerAmPmLabels {
am: string;
pm: string;
}
export interface TimePickerPasteSplitInput {
time: string;
format: TimePickerFormat;
amPmLabels: TimePickerAmPmLabels;
}
export interface TimePickerPasteSplitReturnType {
hours: number | null;
minutes: number | null;
seconds: number | null;
amPm: string | null;
}
export type TimePickerPasteSplit = (input: TimePickerPasteSplitInput) => TimePickerPasteSplitReturnType;
export interface TimePickerPresetGroup {
label: React.ReactNode;
values: string[];
}
export type TimePickerPresets = string[] | TimePickerPresetGroup[];

View File

@@ -0,0 +1,14 @@
import { TimePickerAmPmLabels, TimePickerFormat } from '../TimePicker.types';
interface TimePresetControlProps {
value: string;
active: boolean;
onChange: (value: string) => void;
format: TimePickerFormat;
amPmLabels: TimePickerAmPmLabels;
withSeconds: boolean;
}
export declare function TimePresetControl({ value, active, onChange, format, amPmLabels, withSeconds, }: TimePresetControlProps): import("react/jsx-runtime").JSX.Element;
export declare namespace TimePresetControl {
var displayName: string;
}
export {};

View File

@@ -0,0 +1,14 @@
import { TimePickerAmPmLabels, TimePickerFormat, TimePickerPresetGroup } from '../TimePicker.types';
interface TimePresetGroupProps {
value: string;
data: TimePickerPresetGroup;
onChange: (value: string) => void;
format: TimePickerFormat;
amPmLabels: TimePickerAmPmLabels;
withSeconds: boolean;
}
export declare function TimePresetGroup({ value, data, onChange, format, amPmLabels, withSeconds, }: TimePresetGroupProps): import("react/jsx-runtime").JSX.Element;
export declare namespace TimePresetGroup {
var displayName: string;
}
export {};

View File

@@ -0,0 +1,14 @@
import { TimePickerAmPmLabels, TimePickerFormat, TimePickerPresets } from '../TimePicker.types';
interface TimePresetsProps {
presets: TimePickerPresets;
format: TimePickerFormat;
amPmLabels: TimePickerAmPmLabels;
value: string;
withSeconds: boolean;
onChange: (value: string) => void;
}
export declare function TimePresets({ presets, format, amPmLabels, withSeconds, value, onChange, }: TimePresetsProps): import("react/jsx-runtime").JSX.Element | null;
export declare namespace TimePresets {
var displayName: string;
}
export {};

View File

@@ -0,0 +1,4 @@
export { TimePicker } from './TimePicker';
export { getTimeRange } from './utils/get-time-range/get-time-range';
export type { TimePickerCssVariables, TimePickerFactory, TimePickerProps, TimePickerStylesNames, } from './TimePicker';
export type { TimePickerAmPmLabels, TimePickerFormat, TimePickerPasteSplit, TimePickerPresets, } from './TimePicker.types';

View File

@@ -0,0 +1,40 @@
import type { TimePickerAmPmLabels, TimePickerFormat, TimePickerPasteSplit } from './TimePicker.types';
interface UseTimePickerInput {
value: string | undefined;
defaultValue: string | undefined;
onChange: ((value: string) => void) | undefined;
format: TimePickerFormat;
amPmLabels: TimePickerAmPmLabels;
withSeconds: boolean | undefined;
min: string | undefined;
max: string | undefined;
readOnly: boolean | undefined;
disabled: boolean | undefined;
clearable: boolean | undefined;
pasteSplit: TimePickerPasteSplit | undefined;
}
export declare function useTimePicker({ value, defaultValue, onChange, format, amPmLabels, withSeconds, min, max, clearable, readOnly, disabled, pasteSplit, }: UseTimePickerInput): {
refs: {
hours: import("react").RefObject<HTMLInputElement | null>;
minutes: import("react").RefObject<HTMLInputElement | null>;
seconds: import("react").RefObject<HTMLInputElement | null>;
amPm: import("react").RefObject<HTMLSelectElement | null>;
};
values: {
hours: number | null;
minutes: number | null;
seconds: number | null;
amPm: string | null;
};
setHours: (value: number | null) => void;
setMinutes: (value: number | null) => void;
setSeconds: (value: number | null) => void;
setAmPm: (value: string | null) => void;
focus: (field: "hours" | "minutes" | "seconds" | "amPm") => void;
clear: () => void;
onPaste: (event: React.ClipboardEvent<any>) => void;
setTimeString: (timeString: string) => void;
isClearable: boolean | undefined;
hiddenInputValue: string;
};
export {};

View File

@@ -0,0 +1,6 @@
export declare function clampTime(time: string, min: string | undefined, max: string | undefined): {
timeString: string;
hours: number;
minutes: number;
seconds: number;
};

View File

@@ -0,0 +1,35 @@
import { TimePickerAmPmLabels, TimePickerFormat } from '../../TimePicker.types';
interface GetParsedTimeInput {
time: string;
format: TimePickerFormat;
amPmLabels: TimePickerAmPmLabels;
}
interface ConvertTimeTo12HourFormatInput {
hours: number | null;
minutes: number | null;
seconds: number | null;
amPmLabels: TimePickerAmPmLabels;
}
export declare function convertTimeTo12HourFormat({ hours, minutes, seconds, amPmLabels, }: ConvertTimeTo12HourFormatInput): {
hours: null;
minutes: null;
seconds: null;
amPm: null;
} | {
hours: number;
minutes: number | null;
seconds: number | null;
amPm: string;
};
export declare function getParsedTime({ time, format, amPmLabels }: GetParsedTimeInput): {
hours: number;
minutes: number | null;
seconds: number | null;
amPm: string;
} | {
amPm: null;
hours: number | null;
minutes: number | null;
seconds: number | null;
};
export {};

View File

@@ -0,0 +1,7 @@
interface GetTimeRangeInput {
startTime: string;
endTime: string;
interval: string;
}
export declare function getTimeRange({ startTime, endTime, interval }: GetTimeRangeInput): string[];
export {};

View File

@@ -0,0 +1,15 @@
import { TimePickerAmPmLabels, TimePickerFormat } from '../../TimePicker.types';
interface GetTimeStringInput {
hours: number | null;
minutes: number | null;
seconds: number | null;
format: TimePickerFormat;
withSeconds: boolean;
amPm: string | null;
amPmLabels: TimePickerAmPmLabels;
}
export declare function getTimeString({ hours, minutes, seconds, format, withSeconds, amPm, amPmLabels, }: GetTimeStringInput): {
valid: boolean;
value: string;
};
export {};

View File

@@ -0,0 +1,7 @@
interface IsSameTimeInput {
time: string;
compare: string;
withSeconds: boolean;
}
export declare function isSameTime({ time, compare, withSeconds }: IsSameTimeInput): boolean;
export {};

View File

@@ -0,0 +1 @@
export declare function padTime(value: number): string;

View File

@@ -0,0 +1,5 @@
export declare function splitTimeString(timeString: string): {
hours: number | null;
minutes: number | null;
seconds: number | null;
};

View File

@@ -0,0 +1,7 @@
export declare function timeToSeconds(timeStr: string): number;
export declare function secondsToTime(seconds: number): {
timeString: string;
hours: number;
minutes: number;
seconds: number;
};