@refraktor/dates 0.0.3 → 0.0.4

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.
Files changed (30) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/build/components/date-range-picker/date-range-picker.d.ts +4 -0
  3. package/build/components/date-range-picker/date-range-picker.d.ts.map +1 -0
  4. package/build/components/date-range-picker/date-range-picker.js +379 -0
  5. package/build/components/date-range-picker/date-range-picker.types.d.ts +100 -0
  6. package/build/components/date-range-picker/date-range-picker.types.d.ts.map +1 -0
  7. package/build/components/date-range-picker/date-range-picker.types.js +1 -0
  8. package/build/components/date-range-picker/index.d.ts +3 -0
  9. package/build/components/date-range-picker/index.d.ts.map +1 -0
  10. package/build/components/date-range-picker/index.js +1 -0
  11. package/build/components/time-input/index.d.ts +1 -1
  12. package/build/components/time-input/index.d.ts.map +1 -1
  13. package/build/components/time-input/time-input.d.ts.map +1 -1
  14. package/build/components/time-input/time-input.js +7 -196
  15. package/build/components/time-input/time-input.types.d.ts +5 -83
  16. package/build/components/time-input/time-input.types.d.ts.map +1 -1
  17. package/build/components/time-picker/index.d.ts +1 -1
  18. package/build/components/time-picker/index.d.ts.map +1 -1
  19. package/build/components/time-picker/time-picker.d.ts.map +1 -1
  20. package/build/components/time-picker/time-picker.js +498 -350
  21. package/build/components/time-picker/time-picker.types.d.ts +96 -61
  22. package/build/components/time-picker/time-picker.types.d.ts.map +1 -1
  23. package/build/style.css +1 -1
  24. package/package.json +3 -3
  25. package/src/components/time-input/index.ts +6 -23
  26. package/src/components/time-input/time-input.tsx +48 -453
  27. package/src/components/time-input/time-input.types.ts +30 -163
  28. package/src/components/time-picker/index.ts +10 -19
  29. package/src/components/time-picker/time-picker.tsx +1088 -737
  30. package/src/components/time-picker/time-picker.types.ts +166 -135
@@ -1,135 +1,166 @@
1
- import { ComponentPropsWithoutRef, ReactNode } from "react";
2
- import {
3
- RefraktorRadius,
4
- RefraktorSize,
5
- createClassNamesConfig,
6
- createComponentConfig,
7
- FactoryPayload
8
- } from "@refraktor/core";
9
-
10
- export type TimePickerValue = string;
11
- export type TimePickerMode = "12h" | "24h";
12
- export type TimePickerPeriod = "am" | "pm";
13
- export type TimePickerSize = RefraktorSize;
14
- export type TimePickerRadius = RefraktorRadius;
15
-
16
- export type TimePickerOnChange = (value: TimePickerValue) => void;
17
-
18
- export type TimePickerGetHourLabel = (
19
- hour: number,
20
- mode: TimePickerMode
21
- ) => ReactNode;
22
-
23
- export type TimePickerGetMinuteLabel = (minute: number) => ReactNode;
24
-
25
- export type TimePickerGetSecondLabel = (second: number) => ReactNode;
26
-
27
- export type TimePickerGetPeriodLabel = (period: TimePickerPeriod) => ReactNode;
28
-
29
- export type TimePickerGetHourAriaLabel = (
30
- hour: number,
31
- mode: TimePickerMode,
32
- selected: boolean
33
- ) => string;
34
-
35
- export type TimePickerGetMinuteAriaLabel = (
36
- minute: number,
37
- selected: boolean
38
- ) => string;
39
-
40
- export type TimePickerGetSecondAriaLabel = (
41
- second: number,
42
- selected: boolean
43
- ) => string;
44
-
45
- export type TimePickerGetPeriodAriaLabel = (
46
- period: TimePickerPeriod,
47
- selected: boolean
48
- ) => string;
49
-
50
- export type TimePickerClassNames = {
51
- root?: string;
52
- grid?: string;
53
- section?: string;
54
- sectionLabel?: string;
55
- list?: string;
56
- option?: string;
57
- optionActive?: string;
58
- optionDisabled?: string;
59
- hourSection?: string;
60
- minuteSection?: string;
61
- secondSection?: string;
62
- periodSection?: string;
63
- };
64
-
65
- export interface TimePickerProps
66
- extends Omit<
67
- ComponentPropsWithoutRef<"div">,
68
- "onChange" | "value" | "defaultValue"
69
- > {
70
- /** Active time (controlled), accepts `H:mm:ss` or `HH:mm:ss` (24h). */
71
- value?: TimePickerValue;
72
-
73
- /** Initial active time (uncontrolled), accepts `H:mm:ss` or `HH:mm:ss` (24h). */
74
- defaultValue?: TimePickerValue;
75
-
76
- /** Callback called when active time changes in normalized `HH:mm:ss` format (24h). */
77
- onChange?: TimePickerOnChange;
78
-
79
- /** Lower selectable bound for time-of-day, accepts `H:mm:ss` or `HH:mm:ss` (24h). */
80
- minTime?: TimePickerValue;
81
-
82
- /** Upper selectable bound for time-of-day, accepts `H:mm:ss` or `HH:mm:ss` (24h). */
83
- maxTime?: TimePickerValue;
84
-
85
- /** Time display mode @default `24h` */
86
- mode?: TimePickerMode;
87
-
88
- /** Whether all controls are disabled @default `false` */
89
- disabled?: boolean;
90
-
91
- /** Component size @default `md` */
92
- size?: TimePickerSize;
93
-
94
- /** Border radius @default `default` */
95
- radius?: TimePickerRadius;
96
-
97
- /** Custom hour label renderer. */
98
- getHourLabel?: TimePickerGetHourLabel;
99
-
100
- /** Custom minute label renderer. */
101
- getMinuteLabel?: TimePickerGetMinuteLabel;
102
-
103
- /** Custom second label renderer. */
104
- getSecondLabel?: TimePickerGetSecondLabel;
105
-
106
- /** Custom AM/PM label renderer in 12h mode. */
107
- getPeriodLabel?: TimePickerGetPeriodLabel;
108
-
109
- /** Custom aria-label generator for hour options. */
110
- getHourAriaLabel?: TimePickerGetHourAriaLabel;
111
-
112
- /** Custom aria-label generator for minute options. */
113
- getMinuteAriaLabel?: TimePickerGetMinuteAriaLabel;
114
-
115
- /** Custom aria-label generator for second options. */
116
- getSecondAriaLabel?: TimePickerGetSecondAriaLabel;
117
-
118
- /** Custom aria-label generator for period options. */
119
- getPeriodAriaLabel?: TimePickerGetPeriodAriaLabel;
120
-
121
- /** Used for editing root class name. */
122
- className?: string;
123
-
124
- /** Used for styling different parts of the component. */
125
- classNames?: TimePickerClassNames;
126
- }
127
-
128
- export interface TimePickerFactoryPayload extends FactoryPayload {
129
- props: TimePickerProps;
130
- ref: HTMLDivElement;
131
- compound: {
132
- configure: ReturnType<typeof createComponentConfig<TimePickerProps>>;
133
- classNames: ReturnType<typeof createClassNamesConfig<TimePickerClassNames>>;
134
- };
135
- }
1
+ import type { Placement } from "@floating-ui/react";
2
+ import { ComponentPropsWithoutRef, ReactNode, Ref } from "react";
3
+ import {
4
+ RefraktorRadius,
5
+ RefraktorSize,
6
+ InputVariant,
7
+ createClassNamesConfig,
8
+ createComponentConfig,
9
+ FactoryPayload
10
+ } from "@refraktor/core";
11
+
12
+ export type TimePickerValue = string;
13
+ export type TimePickerFormat = "12h" | "24h";
14
+ export type TimePickerAmPmLabels = { am: string; pm: string };
15
+
16
+ export type TimePickerClassNames = {
17
+ root?: string;
18
+ fieldsWrapper?: string;
19
+ field?: string;
20
+ separator?: string;
21
+ amPmInput?: string;
22
+ dropdown?: string;
23
+ dropdownColumn?: string;
24
+ dropdownColumnLabel?: string;
25
+ dropdownOption?: string;
26
+ dropdownOptionActive?: string;
27
+ };
28
+
29
+ export type TimePickerPopoverProps = {
30
+ /** Dropdown placement relative to the input @default `bottom-start` */
31
+ placement?: Placement;
32
+ /** Offset distance from the input in pixels @default `4` */
33
+ offset?: number;
34
+ };
35
+
36
+ interface _TimePickerProps {
37
+ /** Controlled time value in 24h format (`HH:mm` or `HH:mm:ss`). Empty string for no value. */
38
+ value?: TimePickerValue;
39
+
40
+ /** Uncontrolled initial time value in 24h format (`HH:mm` or `HH:mm:ss`). */
41
+ defaultValue?: TimePickerValue;
42
+
43
+ /** Called when the time value changes. Fires when all visible fields are filled, or all are cleared. */
44
+ onChange?: (value: TimePickerValue) => void;
45
+
46
+ /** Time display format @default `"24h"` */
47
+ format?: TimePickerFormat;
48
+
49
+ /** Show seconds field @default `false` */
50
+ withSeconds?: boolean;
51
+
52
+ /** Show scrollable dropdown with time options @default `false` */
53
+ withDropdown?: boolean;
54
+
55
+ /** Show clear button in the right section @default `false` */
56
+ clearable?: boolean;
57
+
58
+ /** Minimum selectable time in 24h format (`HH:mm` or `HH:mm:ss`) */
59
+ min?: TimePickerValue;
60
+
61
+ /** Maximum selectable time in 24h format (`HH:mm` or `HH:mm:ss`) */
62
+ max?: TimePickerValue;
63
+
64
+ /** Step for hour increment/decrement and dropdown generation @default `1` */
65
+ hoursStep?: number;
66
+
67
+ /** Step for minute increment/decrement and dropdown generation @default `1` */
68
+ minutesStep?: number;
69
+
70
+ /** Step for second increment/decrement and dropdown generation @default `1` */
71
+ secondsStep?: number;
72
+
73
+ /** Custom AM/PM labels @default `{ am: "AM", pm: "PM" }` */
74
+ amPmLabels?: TimePickerAmPmLabels;
75
+
76
+ /** Whether the input is disabled @default `false` */
77
+ disabled?: boolean;
78
+
79
+ /** Whether the input is read-only @default `false` */
80
+ readOnly?: boolean;
81
+
82
+ /** Input variant @default `"default"` */
83
+ variant?: InputVariant;
84
+
85
+ /** Component size @default `"md"` */
86
+ size?: RefraktorSize;
87
+
88
+ /** Border radius @default `"default"` */
89
+ radius?: RefraktorRadius;
90
+
91
+ /** Label text */
92
+ label?: ReactNode;
93
+
94
+ /** Description text displayed below the label */
95
+ description?: ReactNode;
96
+
97
+ /** Error message */
98
+ error?: ReactNode;
99
+
100
+ /** Whether the field is required */
101
+ required?: boolean;
102
+
103
+ /** Display an asterisk next to the label */
104
+ withAsterisk?: boolean;
105
+
106
+ /** Left section content */
107
+ leftSection?: ReactNode;
108
+
109
+ /** Right section content (overridden by clearable when value is set) */
110
+ rightSection?: ReactNode;
111
+
112
+ /** Ref for the hours input element */
113
+ hoursRef?: Ref<HTMLInputElement>;
114
+
115
+ /** Ref for the minutes input element */
116
+ minutesRef?: Ref<HTMLInputElement>;
117
+
118
+ /** Ref for the seconds input element */
119
+ secondsRef?: Ref<HTMLInputElement>;
120
+
121
+ /** Ref for the AM/PM select element */
122
+ amPmRef?: Ref<HTMLInputElement>;
123
+
124
+ /** Aria label for hours input */
125
+ hoursInputLabel?: string;
126
+
127
+ /** Aria label for minutes input */
128
+ minutesInputLabel?: string;
129
+
130
+ /** Aria label for seconds input */
131
+ secondsInputLabel?: string;
132
+
133
+ /** Aria label for AM/PM input */
134
+ amPmInputLabel?: string;
135
+
136
+ /** Popover props for the dropdown */
137
+ popoverProps?: TimePickerPopoverProps;
138
+
139
+ /** Called when any field gains focus */
140
+ onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;
141
+
142
+ /** Called when all fields lose focus */
143
+ onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
144
+
145
+ /** Used for styling different parts of the component */
146
+ classNames?: TimePickerClassNames;
147
+ }
148
+
149
+ export type TimePickerProps = _TimePickerProps &
150
+ Omit<
151
+ ComponentPropsWithoutRef<"div">,
152
+ | "onChange"
153
+ | "value"
154
+ | "defaultValue"
155
+ | "onFocus"
156
+ | "onBlur"
157
+ >;
158
+
159
+ export interface TimePickerFactoryPayload extends FactoryPayload {
160
+ props: TimePickerProps;
161
+ ref: HTMLDivElement;
162
+ compound: {
163
+ configure: ReturnType<typeof createComponentConfig<TimePickerProps>>;
164
+ classNames: ReturnType<typeof createClassNamesConfig<TimePickerClassNames>>;
165
+ };
166
+ }