@refraktor/dates 0.0.2 → 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.
- package/.turbo/turbo-build.log +1 -1
- package/build/components/date-input/date-input.d.ts.map +1 -1
- package/build/components/date-input/date-input.js +5 -3
- package/build/components/date-range-picker/date-range-picker.d.ts +4 -0
- package/build/components/date-range-picker/date-range-picker.d.ts.map +1 -0
- package/build/components/date-range-picker/date-range-picker.js +379 -0
- package/build/components/date-range-picker/date-range-picker.types.d.ts +100 -0
- package/build/components/date-range-picker/date-range-picker.types.d.ts.map +1 -0
- package/build/components/date-range-picker/date-range-picker.types.js +1 -0
- package/build/components/date-range-picker/index.d.ts +3 -0
- package/build/components/date-range-picker/index.d.ts.map +1 -0
- package/build/components/date-range-picker/index.js +1 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +2 -0
- package/build/components/month-input/month-input.d.ts.map +1 -1
- package/build/components/month-input/month-input.js +5 -3
- package/build/components/time-input/index.d.ts +3 -0
- package/build/components/time-input/index.d.ts.map +1 -0
- package/build/components/time-input/index.js +1 -0
- package/build/components/time-input/time-input.d.ts +4 -0
- package/build/components/time-input/time-input.d.ts.map +1 -0
- package/build/components/time-input/time-input.js +18 -0
- package/build/components/time-input/time-input.types.d.ts +21 -0
- package/build/components/time-input/time-input.types.d.ts.map +1 -0
- package/build/components/time-input/time-input.types.js +1 -0
- package/build/components/time-picker/index.d.ts +3 -0
- package/build/components/time-picker/index.d.ts.map +1 -0
- package/build/components/time-picker/index.js +1 -0
- package/build/components/time-picker/time-picker.d.ts +4 -0
- package/build/components/time-picker/time-picker.d.ts.map +1 -0
- package/build/components/time-picker/time-picker.js +553 -0
- package/build/components/time-picker/time-picker.types.d.ts +114 -0
- package/build/components/time-picker/time-picker.types.d.ts.map +1 -0
- package/build/components/time-picker/time-picker.types.js +1 -0
- package/build/components/year-input/year-input.d.ts.map +1 -1
- package/build/components/year-input/year-input.js +5 -3
- package/build/style.css +1 -1
- package/package.json +3 -3
- package/src/components/date-input/date-input.tsx +5 -2
- package/src/components/index.ts +2 -0
- package/src/components/month-input/month-input.tsx +5 -2
- package/src/components/time-input/index.ts +6 -0
- package/src/components/time-input/time-input.tsx +48 -0
- package/src/components/time-input/time-input.types.ts +30 -0
- package/src/components/time-picker/index.ts +10 -0
- package/src/components/time-picker/time-picker.tsx +1088 -0
- package/src/components/time-picker/time-picker.types.ts +166 -0
- package/src/components/year-input/year-input.tsx +5 -2
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
}
|
|
@@ -180,7 +180,8 @@ const YearInput = factory<YearInputFactoryPayload>((_props, ref) => {
|
|
|
180
180
|
open: isOpen,
|
|
181
181
|
onOpenChange: handleOpenChange,
|
|
182
182
|
middleware,
|
|
183
|
-
whileElementsMounted: autoUpdate
|
|
183
|
+
whileElementsMounted: autoUpdate,
|
|
184
|
+
strategy: "fixed"
|
|
184
185
|
});
|
|
185
186
|
|
|
186
187
|
const focus = useFocus(floating.context, {
|
|
@@ -267,13 +268,15 @@ const YearInput = factory<YearInputFactoryPayload>((_props, ref) => {
|
|
|
267
268
|
transition="fade"
|
|
268
269
|
duration={150}
|
|
269
270
|
mounted={isOpen}
|
|
271
|
+
style={{ position: "relative", zIndex: 1000 }}
|
|
270
272
|
{...transitionProps}
|
|
271
273
|
>
|
|
272
274
|
<div
|
|
273
275
|
ref={floating.refs.setFloating}
|
|
274
276
|
id={dropdownId}
|
|
275
277
|
style={{
|
|
276
|
-
...floating.floatingStyles
|
|
278
|
+
...floating.floatingStyles,
|
|
279
|
+
zIndex: 1000
|
|
277
280
|
}}
|
|
278
281
|
className={cx(
|
|
279
282
|
"w-60 z-50 border border-[var(--refraktor-border)] bg-[var(--refraktor-bg)] p-2 text-[var(--refraktor-text)] shadow-md",
|