Skip to content

Commit 646cd2a

Browse files
committed
feat(date/time field): change step to 10 if shift is pressed
closes formwerkjs#156
1 parent 8efb928 commit 646cd2a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

packages/core/src/useDateTime/useDateTimeSegment.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ export function useDateTimeSegment(_props: Reactivify<DateTimeSegmentProps>) {
174174
if (hasKeyCode(evt, 'ArrowUp')) {
175175
blockEvent(evt);
176176
if (!isNonEditable()) {
177-
increment();
177+
increment(evt.shiftKey ? 10 : 1);
178178
}
179179
return;
180180
}
181181

182182
if (hasKeyCode(evt, 'ArrowDown')) {
183183
blockEvent(evt);
184184
if (!isNonEditable()) {
185-
decrement();
185+
decrement(evt.shiftKey ? -10 : -1);
186186
}
187187
return;
188188
}

packages/core/src/useDateTime/useDateTimeSegmentGroup.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export interface DateTimeSegmentRegistration {
2525
export interface DateTimeSegmentGroupContext {
2626
useDateSegmentRegistration(segment: DateTimeSegmentRegistration): {
2727
parser: NumberParserContext;
28-
increment(): void;
29-
decrement(): void;
28+
increment(step: number): void;
29+
decrement(step: number): void;
3030
setValue(value: number): void;
3131
getMetadata(): { min: number | null; max: number | null; maxLength: number | null };
3232
onDone(): void;
@@ -150,16 +150,16 @@ export function useDateTimeSegmentGroup({
150150
renderedSegments.value = renderedSegments.value.filter(s => s.id !== segment.id);
151151
});
152152

153-
function increment() {
153+
function increment(step: number = 1) {
154154
const type = segment.getType();
155-
const date = addToPart(type, 1);
155+
const date = addToPart(type, step);
156156

157157
onValueChange(withAllPartsSet(date));
158158
}
159159

160-
function decrement() {
160+
function decrement(step: number = -1) {
161161
const type = segment.getType();
162-
const date = addToPart(type, -1);
162+
const date = addToPart(type, step);
163163

164164
onValueChange(withAllPartsSet(date));
165165
}

packages/playground/src/components/TimeField.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const { controlProps, isTouched, labelProps, errorMessageProps, errorMessage, se
2727
@reference "../style.css";
2828
2929
.InputDate {
30-
font-family: 'Monaspace Neon Var';
30+
font-family: 'Monaspace Neon Var', monospace;
3131
@apply relative w-max;
3232
margin-bottom: calc(1em * 1.5);
3333

0 commit comments

Comments
 (0)