@astryxdesign/core 0.7.8-canary.ffd29c5 → 0.7.8
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/CHANGELOG.md +132 -0
- package/dist/BottomSheet/BottomSheetPanel.d.ts +1 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +30 -14
- package/dist/BottomSheet/bottomSheetStack.js +1 -1
- package/dist/BottomSheet/useSheetGestures.d.ts +3 -1
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +4 -0
- package/dist/CheckboxList/CheckboxList.d.ts +13 -2
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +10 -4
- package/dist/CheckboxList/CheckboxListContext.d.ts +7 -0
- package/dist/CheckboxList/CheckboxListContext.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListContext.js +2 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +14 -2
- package/dist/CheckboxList/requiredGroup.d.ts +22 -0
- package/dist/CheckboxList/requiredGroup.d.ts.map +1 -0
- package/dist/CheckboxList/requiredGroup.js +52 -0
- package/dist/DateInput/PickerWheel.d.ts +1 -1
- package/dist/DateInput/PickerWheel.d.ts.map +1 -1
- package/dist/DateInput/PickerWheel.js +27 -6
- package/dist/DateInput/Wheel.d.ts +2 -2
- package/dist/DateInput/Wheel.d.ts.map +1 -1
- package/dist/DateInput/Wheel.js +20 -6
- package/dist/DateInput/datePickerTouch.d.ts +13 -0
- package/dist/DateInput/datePickerTouch.d.ts.map +1 -0
- package/dist/DateInput/datePickerTouch.js +14 -0
- package/dist/DateInput/wheelOptions.d.ts +22 -2
- package/dist/DateInput/wheelOptions.d.ts.map +1 -1
- package/dist/DateInput/wheelOptions.js +14 -2
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +62 -119
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +6 -1
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +7 -2
- package/dist/PowerSearch/PowerSearch.d.ts +4 -2
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +24 -1
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchBottomSheet.js +172 -50
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +15 -15
- package/dist/Resizable/createResizable.d.ts +70 -16
- package/dist/Resizable/createResizable.d.ts.map +1 -1
- package/dist/Resizable/createResizable.js +180 -22
- package/dist/Resizable/separatorAttributes.d.ts +45 -0
- package/dist/Resizable/separatorAttributes.d.ts.map +1 -0
- package/dist/Resizable/separatorAttributes.js +35 -0
- package/dist/Resizable/useResizable.js +2 -2
- package/dist/TimeInput/TimeWheels.d.ts +32 -0
- package/dist/TimeInput/TimeWheels.d.ts.map +1 -0
- package/dist/TimeInput/TimeWheels.js +144 -0
- package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
- package/dist/TimeInput/TouchTimeField.js +63 -118
- package/dist/TimeInput/timeWheelRules.d.ts +124 -0
- package/dist/TimeInput/timeWheelRules.d.ts.map +1 -0
- package/dist/TimeInput/timeWheelRules.js +277 -0
- package/dist/Tokenizer/TokenizerBottomSheet.js +8 -12
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +6 -0
- package/dist/astryx.css +3 -1
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +3 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js +5 -2
- package/dist/i18n/generated-english/Resizable/createResizable.generated.d.ts +8 -0
- package/dist/i18n/generated-english/Resizable/createResizable.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/Resizable/createResizable.generated.js +13 -0
- package/dist/i18n/generated-english/TimeInput/TimeWheels.generated.d.ts +8 -0
- package/dist/i18n/generated-english/TimeInput/TimeWheels.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/TimeInput/TimeWheels.generated.js +17 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +5 -2
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +5 -2
- package/dist/keyboard/index.d.ts +17 -0
- package/dist/keyboard/index.d.ts.map +1 -0
- package/dist/keyboard/index.js +19 -0
- package/dist/keyboard/keyboardHeight.d.ts +149 -0
- package/dist/keyboard/keyboardHeight.d.ts.map +1 -0
- package/dist/keyboard/keyboardHeight.js +432 -0
- package/dist/keyboard/keyboardLayoutGuide.d.ts +59 -0
- package/dist/keyboard/keyboardLayoutGuide.d.ts.map +1 -0
- package/dist/keyboard/keyboardLayoutGuide.js +207 -0
- package/dist/keyboard/keyboardModel.d.ts +93 -0
- package/dist/keyboard/keyboardModel.d.ts.map +1 -0
- package/dist/keyboard/keyboardModel.js +220 -0
- package/dist/keyboard/rideKeyboard.d.ts +42 -0
- package/dist/keyboard/rideKeyboard.d.ts.map +1 -0
- package/dist/keyboard/rideKeyboard.js +77 -0
- package/dist/keyboard/useMobileKeyboard.d.ts +61 -0
- package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -0
- package/dist/keyboard/useMobileKeyboard.js +699 -0
- package/dist/motion/android/index.d.ts +16 -0
- package/dist/motion/android/index.d.ts.map +1 -0
- package/dist/motion/android/index.js +18 -0
- package/dist/motion/android/keyboard.d.ts +83 -0
- package/dist/motion/android/keyboard.d.ts.map +1 -0
- package/dist/motion/android/keyboard.js +96 -0
- package/dist/motion/uikit/datePicker.d.ts +58 -0
- package/dist/motion/uikit/datePicker.d.ts.map +1 -0
- package/dist/motion/uikit/datePicker.js +60 -0
- package/dist/motion/uikit/index.d.ts +4 -3
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +4 -3
- package/dist/utils/interactionOverlay.stylex.d.ts +3 -2
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +3 -2
- package/dist/utils/layoutViewport.d.ts +25 -0
- package/dist/utils/layoutViewport.d.ts.map +1 -0
- package/dist/utils/layoutViewport.js +102 -0
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +74 -9
- package/dist/utils/pressGesture.d.ts +4 -2
- package/dist/utils/pressGesture.d.ts.map +1 -1
- package/dist/utils/pressGesture.js +3 -1
- package/dist/utils/selectionLock.d.ts +10 -1
- package/dist/utils/selectionLock.d.ts.map +1 -1
- package/dist/utils/selectionLock.js +31 -5
- package/dist/utils/sharedMutationObserver.d.ts +2 -1
- package/dist/utils/sharedMutationObserver.d.ts.map +1 -1
- package/dist/utils/sharedMutationObserver.js +2 -1
- package/dist/utils/timeParser.d.ts +2 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +29 -3
- package/locales/en.json +21 -9
- package/locales/pseudo.json +15 -6
- package/package.json +5 -5
- package/src/BottomSheet/BottomSheet.doc.mjs +1 -1
- package/src/BottomSheet/BottomSheetPanel.tsx +41 -13
- package/src/BottomSheet/BottomSheetSwitcher.doc.mjs +5 -0
- package/src/BottomSheet/bottomSheetStack.ts +1 -1
- package/src/BottomSheet/useSheetGestures.ts +6 -0
- package/src/CheckboxList/CheckboxList.doc.mjs +7 -0
- package/src/CheckboxList/CheckboxList.tsx +34 -2
- package/src/CheckboxList/CheckboxListContext.tsx +9 -1
- package/src/CheckboxList/CheckboxListItem.tsx +23 -2
- package/src/CheckboxList/requiredGroup.ts +77 -0
- package/src/DateInput/PickerWheel.tsx +37 -4
- package/src/DateInput/Wheel.tsx +30 -3
- package/src/DateInput/datePickerTouch.ts +15 -0
- package/src/DateInput/wheelOptions.ts +31 -2
- package/src/DateTimeInput/TouchDateTimeField.tsx +94 -178
- package/src/HoverCard/useHoverCard.tsx +6 -1
- package/src/Overlay/Overlay.tsx +7 -2
- package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
- package/src/PowerSearch/PowerSearch.tsx +4 -2
- package/src/PowerSearch/PowerSearchBottomSheet.tsx +237 -62
- package/src/Resizable/ResizeHandle.tsx +18 -26
- package/src/Resizable/createResizable.ts +242 -27
- package/src/Resizable/separatorAttributes.ts +73 -0
- package/src/Resizable/useResizable.ts +2 -2
- package/src/TimeInput/TimeWheels.tsx +218 -0
- package/src/TimeInput/TouchTimeField.tsx +93 -157
- package/src/TimeInput/timeWheelRules.ts +352 -0
- package/src/Tokenizer/TokenizerBottomSheet.tsx +8 -12
- package/src/Tooltip/useTooltip.tsx +6 -0
- package/src/gestures/GestureHost.ts +5 -4
- package/src/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.ts +5 -2
- package/src/i18n/generated-english/Resizable/createResizable.generated.ts +14 -0
- package/src/i18n/generated-english/TimeInput/TimeWheels.generated.ts +18 -0
- package/src/i18n/generated-locales/en.generated.ts +6 -4
- package/src/i18n/generated-locales/pseudo.generated.ts +6 -4
- package/src/keyboard/README.md +197 -0
- package/src/keyboard/index.ts +48 -0
- package/src/keyboard/keyboardHeight.ts +543 -0
- package/src/keyboard/keyboardLayoutGuide.ts +266 -0
- package/src/keyboard/keyboardModel.ts +301 -0
- package/src/keyboard/rideKeyboard.ts +100 -0
- package/src/keyboard/useMobileKeyboard.ts +866 -0
- package/src/motion/MEASUREMENTS.md +10 -0
- package/src/motion/README.md +2 -0
- package/src/motion/android/index.ts +18 -0
- package/src/motion/android/keyboard.ts +96 -0
- package/src/motion/uikit/datePicker.ts +60 -0
- package/src/motion/uikit/index.ts +4 -3
- package/src/utils/interactionOverlay.stylex.ts +3 -2
- package/src/utils/layoutViewport.ts +104 -0
- package/src/utils/pressFeedback.ts +99 -21
- package/src/utils/pressGesture.ts +4 -2
- package/src/utils/selectionLock.ts +40 -6
- package/src/utils/sharedMutationObserver.ts +2 -1
- package/src/utils/timeParser.ts +40 -3
- package/dist/BottomSheet/useMobileKeyboard.d.ts +0 -21
- package/dist/BottomSheet/useMobileKeyboard.d.ts.map +0 -1
- package/dist/BottomSheet/useMobileKeyboard.js +0 -413
- package/src/BottomSheet/useMobileKeyboard.ts +0 -542
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The state of one box that decides which box carries `required`. */
|
|
2
|
+
export interface RequiredGroupBox {
|
|
3
|
+
isChecked: boolean;
|
|
4
|
+
/** False for a disabled or read-only box, which the user cannot check. */
|
|
5
|
+
isEnabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface RequiredGroup {
|
|
8
|
+
/**
|
|
9
|
+
* Adds a checkbox with its state and updates `required` on every box.
|
|
10
|
+
* Returns a function that removes the checkbox, clears its `required`, and
|
|
11
|
+
* updates the rest. An item registers again when its state changes.
|
|
12
|
+
*/
|
|
13
|
+
register: (input: HTMLInputElement, box: RequiredGroupBox) => () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Updates `required` when the group's options move, for example after a
|
|
16
|
+
* keyed reorder, which registers no box again. Returns a function that
|
|
17
|
+
* stops it.
|
|
18
|
+
*/
|
|
19
|
+
observe: (container: HTMLElement) => () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function createRequiredGroup(): RequiredGroup;
|
|
22
|
+
//# sourceMappingURL=requiredGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredGroup.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/requiredGroup.ts"],"names":[],"mappings":"AAkBA,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,KAAK,MAAM,IAAI,CAAC;IACzE;;;;OAIG;IACH,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,MAAM,IAAI,CAAC;CACjD;AAUD,wBAAgB,mBAAmB,IAAI,aAAa,CA4BnD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file requiredGroup.ts
|
|
5
|
+
* @input The checkbox inputs of a required CheckboxList and each box's state;
|
|
6
|
+
* Core's shared mutation observer
|
|
7
|
+
* @output Exports createRequiredGroup, RequiredGroup, and RequiredGroupBox
|
|
8
|
+
* @position Internal to CheckboxList; CheckboxList creates one for an
|
|
9
|
+
* `isRequired` group and CheckboxListItem registers its checkbox with it
|
|
10
|
+
*
|
|
11
|
+
* The browser has no required state for a group of checkboxes. While no box
|
|
12
|
+
* is checked, the first enabled box carries native `required`. The browser
|
|
13
|
+
* then blocks submit and moves focus to that box with its own message. Once
|
|
14
|
+
* any box is checked, no box carries `required`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { observeMutations } from "../utils/sharedMutationObserver.js";
|
|
18
|
+
|
|
19
|
+
/** The state of one box that decides which box carries `required`. */
|
|
20
|
+
|
|
21
|
+
const MOVE_OPTIONS = {
|
|
22
|
+
childList: true,
|
|
23
|
+
subtree: true
|
|
24
|
+
};
|
|
25
|
+
function byDocumentOrder(a, b) {
|
|
26
|
+
return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
27
|
+
}
|
|
28
|
+
export function createRequiredGroup() {
|
|
29
|
+
const boxes = new Map();
|
|
30
|
+
function update() {
|
|
31
|
+
const ordered = [...boxes.keys()].sort(byDocumentOrder);
|
|
32
|
+
const isEmpty = ![...boxes.values()].some(box => box.isChecked);
|
|
33
|
+
const target = isEmpty ? ordered.find(input => boxes.get(input)?.isEnabled === true) : undefined;
|
|
34
|
+
for (const input of ordered) {
|
|
35
|
+
input.required = input === target;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
register(input, box) {
|
|
40
|
+
boxes.set(input, box);
|
|
41
|
+
update();
|
|
42
|
+
return () => {
|
|
43
|
+
boxes.delete(input);
|
|
44
|
+
input.required = false;
|
|
45
|
+
update();
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
observe(container) {
|
|
49
|
+
return observeMutations(container, MOVE_OPTIONS, update);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -12,7 +12,7 @@ import { type WheelProps } from './wheelOptions.js';
|
|
|
12
12
|
* <PickerWheel label="Month" options={monthOptions} value={month} onChange={setMonth} />
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
export declare function PickerWheel({ label, options, value, onChange, isActive, }: WheelProps): import("react").JSX.Element;
|
|
15
|
+
export declare function PickerWheel({ label, options, value, onChange, isActive, ref, }: WheelProps): import("react").JSX.Element;
|
|
16
16
|
export declare namespace PickerWheel {
|
|
17
17
|
var displayName: string;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PickerWheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/PickerWheel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PickerWheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/PickerWheel.tsx"],"names":[],"mappings":"AA2DA,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AA2HxB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,EACf,GAAG,GACJ,EAAE,UAAU,+BAuiBZ;yBA9iBe,WAAW"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file PickerWheel.tsx
|
|
7
|
-
* @input Wheel's props (wheelOptions.ts): options, value and change callback
|
|
7
|
+
* @input Wheel's props (wheelOptions.ts): options, value and change callback;
|
|
8
|
+
* optionally a ref for programmatic turns
|
|
8
9
|
* @output PickerWheel: one picker column that moves like UIPickerView
|
|
9
10
|
* @position Internal component; the Wheel under a finger (Wheel.tsx picks it)
|
|
10
11
|
*
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
* SYNC: When modified, update PickerWheel.test.tsx, Wheel.tsx,
|
|
15
16
|
* DateInputTouch.test.tsx, DateInput.doc.mjs and TimeInput.doc.mjs.
|
|
16
17
|
*/
|
|
17
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
18
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
18
19
|
import * as stylex from '@stylexjs/stylex';
|
|
19
20
|
import { scrollTypeOf } from "../gestures/GestureHost.js";
|
|
20
21
|
import { PanGestureRecognizer } from "../gestures/PanGestureRecognizer.js";
|
|
@@ -36,7 +37,7 @@ import { useOwnScrollGesture } from "./useOwnScrollGesture.js";
|
|
|
36
37
|
import { useWheelListbox } from "./useWheelListbox.js";
|
|
37
38
|
import { createWheelStrip } from "./wheelStrip.js";
|
|
38
39
|
import { dragOffset, nearestIndex, offsetBounds, planRelease, spinCurve } from "./wheelPhysics.js";
|
|
39
|
-
import { endIndex, nearestEnabledIndex, steppedIndex, WHEEL_ROW_HEIGHT } from "./wheelOptions.js";
|
|
40
|
+
import { canSpinTo, endIndex, nearestEnabledIndex, steppedIndex, WHEEL_ROW_HEIGHT } from "./wheelOptions.js";
|
|
40
41
|
|
|
41
42
|
/** Row pitch, px: the touch column keeps the scrolling column's pitch. */
|
|
42
43
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -130,7 +131,8 @@ export function PickerWheel({
|
|
|
130
131
|
options,
|
|
131
132
|
value,
|
|
132
133
|
onChange,
|
|
133
|
-
isActive = true
|
|
134
|
+
isActive = true,
|
|
135
|
+
ref
|
|
134
136
|
}) {
|
|
135
137
|
const columnRef = useRef(null);
|
|
136
138
|
const rowsRef = useRef(null);
|
|
@@ -469,8 +471,27 @@ export function PickerWheel({
|
|
|
469
471
|
isPointerKept: true
|
|
470
472
|
});
|
|
471
473
|
|
|
472
|
-
// A
|
|
473
|
-
//
|
|
474
|
+
// A spin turns only onto an enabled row (canSpinTo). So its arrival commits
|
|
475
|
+
// that row, and nothing turns on past it. It reports the row it was asked
|
|
476
|
+
// for, as the scrolling column does.
|
|
477
|
+
const spinTo = useCallback(async index => new Promise(resolve => {
|
|
478
|
+
if (!canSpinTo(latestRef.current.options, index)) {
|
|
479
|
+
resolve(false);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const offset = motion.offset();
|
|
483
|
+
move(turnCurve(columnRef.current, offset, index * ROW_HEIGHT), {
|
|
484
|
+
onEnd: (outcome, end) => {
|
|
485
|
+
if (outcome === 'arrived') {
|
|
486
|
+
arrive(end);
|
|
487
|
+
}
|
|
488
|
+
resolve(outcome === 'arrived');
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}), [motion, move, arrive]);
|
|
492
|
+
useImperativeHandle(ref, () => ({
|
|
493
|
+
spinTo
|
|
494
|
+
}), [spinTo]);
|
|
474
495
|
const turnToPosition = useCallback((position, offset) => {
|
|
475
496
|
const current = latestRef.current;
|
|
476
497
|
const option = current.options[position];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type WheelProps } from './wheelOptions.js';
|
|
2
|
-
export { nearestEnabledIndex, type WheelOption, type WheelProps, } from './wheelOptions.js';
|
|
2
|
+
export { nearestEnabledIndex, type WheelHandle, type WheelOption, type WheelProps, } from './wheelOptions.js';
|
|
3
3
|
/**
|
|
4
4
|
* One picker column: UIPickerView's motion with flat rows under a finger, the
|
|
5
5
|
* snap-scrolling column under a fine pointer.
|
|
@@ -31,7 +31,7 @@ export declare namespace Wheel {
|
|
|
31
31
|
* />
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare function ScrollWheel({ label, options, value, onChange, isActive, }: WheelProps): import("react").JSX.Element;
|
|
34
|
+
export declare function ScrollWheel({ label, options, value, onChange, isActive, ref, }: WheelProps): import("react").JSX.Element;
|
|
35
35
|
export declare namespace ScrollWheel {
|
|
36
36
|
var displayName: string;
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/Wheel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Wheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/Wheel.tsx"],"names":[],"mappings":"AA2DA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAoMxB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAKtC;yBALe,KAAK;;;AASrB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,EACf,GAAG,GACJ,EAAE,UAAU,+BAqVZ;yBA5Ve,WAAW"}
|
package/dist/DateInput/Wheel.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file Wheel.tsx
|
|
7
|
-
* @input Option list, selected value and change callback
|
|
7
|
+
* @input Option list, selected value and change callback; a ref for
|
|
8
|
+
* programmatic turns
|
|
8
9
|
* @output Exports Wheel (one picker column), ScrollWheel (the scrolling
|
|
9
10
|
* column) and the shared types of wheelOptions.ts
|
|
10
11
|
* @position Internal component; consumed by MonthYearWheels.tsx,
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
* - /packages/core/src/DateInput/DateInput.doc.mjs
|
|
27
28
|
* - /packages/core/src/DateInput/DateInputTouch.test.tsx
|
|
28
29
|
*/
|
|
29
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
30
|
+
import { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
30
31
|
import * as stylex from '@stylexjs/stylex';
|
|
31
32
|
import "../theme/tokens.stylex.js";
|
|
32
33
|
import { colorVars, radiusVars, fontWeightVars, typeScaleVars, spacingVars, durationVars } from "../theme/tokens.stylex.js";
|
|
@@ -40,7 +41,7 @@ import { useOwnScrollGesture } from "./useOwnScrollGesture.js";
|
|
|
40
41
|
import { usePointerDragScroll } from "./usePointerDragScroll.js";
|
|
41
42
|
import { useScrollSettle } from "./useScrollSettle.js";
|
|
42
43
|
import { useWheelListbox } from "./useWheelListbox.js";
|
|
43
|
-
import { endIndex, nearestEnabledIndex, steppedIndex } from "./wheelOptions.js";
|
|
44
|
+
import { canSpinTo, endIndex, nearestEnabledIndex, steppedIndex } from "./wheelOptions.js";
|
|
44
45
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
45
46
|
export { nearestEnabledIndex } from "./wheelOptions.js";
|
|
46
47
|
const ITEM_BLOCK_SIZE = dateInputTouchSizes.wheelItemSize;
|
|
@@ -130,8 +131,23 @@ export function ScrollWheel({
|
|
|
130
131
|
options,
|
|
131
132
|
value,
|
|
132
133
|
onChange,
|
|
133
|
-
isActive = true
|
|
134
|
+
isActive = true,
|
|
135
|
+
ref
|
|
134
136
|
}) {
|
|
137
|
+
// A spin commits the row at once. The new value then scrolls the column
|
|
138
|
+
// there, as any new value does.
|
|
139
|
+
useImperativeHandle(ref, () => ({
|
|
140
|
+
spinTo: async index => {
|
|
141
|
+
if (!canSpinTo(options, index)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
const option = options[index];
|
|
145
|
+
if (option.value !== value) {
|
|
146
|
+
onChange(option.value);
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
}), [options, value, onChange]);
|
|
135
151
|
const scrollerRef = useRef(null);
|
|
136
152
|
const selectedIndex = Math.max(0, options.findIndex(option => option.value === value));
|
|
137
153
|
// Which row is under the band right now. Tracks the finger during a scroll;
|
|
@@ -351,8 +367,6 @@ export function ScrollWheel({
|
|
|
351
367
|
useOwnScrollGesture(scrollerRef, 'all', {
|
|
352
368
|
isEnabled: isActive
|
|
353
369
|
});
|
|
354
|
-
|
|
355
|
-
// A key commits the row it moves to and scrolls the column there.
|
|
356
370
|
const moveTo = useCallback(row => {
|
|
357
371
|
const option = row == null ? undefined : options[row];
|
|
358
372
|
if (row == null || option == null || option.isDisabled) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file datePickerTouch.ts
|
|
3
|
+
* @input The date and time pickers' touch-only pieces
|
|
4
|
+
* @output Re-exports what the date and time sheets use only under a finger:
|
|
5
|
+
* TimeWheels
|
|
6
|
+
* @position The pickers' touch layer. The sheets import touch behaviour from
|
|
7
|
+
* here only, so a desktop build can replace this one module.
|
|
8
|
+
*
|
|
9
|
+
* SYNC: When modified, update TouchTimeField.tsx and TouchDateTimeField.tsx.
|
|
10
|
+
*/
|
|
11
|
+
export { TimeWheels } from '../TimeInput/TimeWheels.js';
|
|
12
|
+
export type { TimeWheelsProps } from '../TimeInput/TimeWheels.js';
|
|
13
|
+
//# sourceMappingURL=datePickerTouch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datePickerTouch.d.ts","sourceRoot":"","sources":["../../src/DateInput/datePickerTouch.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AACnD,YAAY,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file datePickerTouch.ts
|
|
5
|
+
* @input The date and time pickers' touch-only pieces
|
|
6
|
+
* @output Re-exports what the date and time sheets use only under a finger:
|
|
7
|
+
* TimeWheels
|
|
8
|
+
* @position The pickers' touch layer. The sheets import touch behaviour from
|
|
9
|
+
* here only, so a desktop build can replace this one module.
|
|
10
|
+
*
|
|
11
|
+
* SYNC: When modified, update TouchTimeField.tsx and TouchDateTimeField.tsx.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export { TimeWheels } from "../TimeInput/TimeWheels.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file wheelOptions.ts
|
|
3
3
|
* @input Nothing; types, the row height and pure functions
|
|
4
|
-
* @output WheelOption, WheelProps, WHEEL_ROW_HEIGHT,
|
|
5
|
-
* steppedIndex and endIndex: what both wheels share
|
|
4
|
+
* @output WheelOption, WheelProps, WheelHandle, WHEEL_ROW_HEIGHT, canSpinTo,
|
|
5
|
+
* nearestEnabledIndex, steppedIndex and endIndex: what both wheels share
|
|
6
6
|
* @position Internal; read by Wheel.tsx (which re-exports all of it) and
|
|
7
7
|
* PickerWheel.tsx
|
|
8
8
|
*
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - /packages/core/src/DateInput/Wheel.tsx
|
|
11
11
|
* - /packages/core/src/DateInput/PickerWheel.tsx
|
|
12
12
|
*/
|
|
13
|
+
import type { Ref } from 'react';
|
|
13
14
|
/**
|
|
14
15
|
* The row height, px (`dateInputTouchSizes.wheelItemSize`): the pitch of both
|
|
15
16
|
* columns' rows, and the unit of the touch wheel's offset.
|
|
@@ -32,6 +33,18 @@ export interface WheelOption {
|
|
|
32
33
|
*/
|
|
33
34
|
order?: number;
|
|
34
35
|
}
|
|
36
|
+
/** What a Wheel's `ref` exposes. */
|
|
37
|
+
export interface WheelHandle {
|
|
38
|
+
/**
|
|
39
|
+
* Turn the wheel onto `index` (an index into `options`) on the tap spin, then
|
|
40
|
+
* commit it as a rest would. Resolves true once that row is the committed
|
|
41
|
+
* one, false if a finger or another turn interrupted it or the wheel went
|
|
42
|
+
* away first. An index outside `options` or a disabled row resolves false at
|
|
43
|
+
* once, and nothing turns. Under a fine pointer the row commits at once. The
|
|
44
|
+
* column then scrolls to it as for any new value, on the same rule.
|
|
45
|
+
*/
|
|
46
|
+
spinTo(index: number): Promise<boolean>;
|
|
47
|
+
}
|
|
35
48
|
export interface WheelProps {
|
|
36
49
|
/** Accessible name for the column, e.g. "Month". */
|
|
37
50
|
label: string;
|
|
@@ -48,7 +61,14 @@ export interface WheelProps {
|
|
|
48
61
|
* motion.
|
|
49
62
|
*/
|
|
50
63
|
isActive?: boolean;
|
|
64
|
+
/** Programmatic turns: `spinTo(index)`. */
|
|
65
|
+
ref?: Ref<WheelHandle>;
|
|
51
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether `spinTo(index)` may turn onto `index`: an enabled row of `options`.
|
|
69
|
+
* The touch wheel and the scrolling column answer a spin by the same rule.
|
|
70
|
+
*/
|
|
71
|
+
export declare function canSpinTo(options: ReadonlyArray<WheelOption>, index: number): boolean;
|
|
52
72
|
/**
|
|
53
73
|
* The enabled row nearest `index`: `index` itself when it is enabled,
|
|
54
74
|
* otherwise the closest enabled row on either side. A tie goes to the side of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wheelOptions.d.ts","sourceRoot":"","sources":["../../src/DateInput/wheelOptions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,KAAK,EAA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tE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,KAAK,EAAE,MAAM,GACZ,OAAO,CAGT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,MAAM,CAsBR;AAaD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAyBf;AAED,uFAAuF;AACvF,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,GAAG,EAAE,OAAO,GAAG,MAAM,GACpB,MAAM,GAAG,IAAI,CAKf"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file wheelOptions.ts
|
|
5
5
|
* @input Nothing; types, the row height and pure functions
|
|
6
|
-
* @output WheelOption, WheelProps, WHEEL_ROW_HEIGHT,
|
|
7
|
-
* steppedIndex and endIndex: what both wheels share
|
|
6
|
+
* @output WheelOption, WheelProps, WheelHandle, WHEEL_ROW_HEIGHT, canSpinTo,
|
|
7
|
+
* nearestEnabledIndex, steppedIndex and endIndex: what both wheels share
|
|
8
8
|
* @position Internal; read by Wheel.tsx (which re-exports all of it) and
|
|
9
9
|
* PickerWheel.tsx
|
|
10
10
|
*
|
|
@@ -18,6 +18,18 @@
|
|
|
18
18
|
* columns' rows, and the unit of the touch wheel's offset.
|
|
19
19
|
*/
|
|
20
20
|
export const WHEEL_ROW_HEIGHT = 28;
|
|
21
|
+
|
|
22
|
+
/** What a Wheel's `ref` exposes. */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether `spinTo(index)` may turn onto `index`: an enabled row of `options`.
|
|
26
|
+
* The touch wheel and the scrolling column answer a spin by the same rule.
|
|
27
|
+
*/
|
|
28
|
+
export function canSpinTo(options, index) {
|
|
29
|
+
const option = options[index];
|
|
30
|
+
return option != null && !option.isDisabled;
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
/**
|
|
22
34
|
* The enabled row nearest `index`: `index` itself when it is enabled,
|
|
23
35
|
* otherwise the closest enabled row on either side. A tie goes to the side of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchDateTimeField.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/TouchDateTimeField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TouchDateTimeField.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/TouchDateTimeField.tsx"],"names":[],"mappings":"AAuHA,OAAO,KAAK,EAAC,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AA6S3E,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,SAAiB,EACjB,GAAG,EACH,GAAG,EACH,eAAe,EACf,UAAkB,EAClB,UAAkB,EAElB,aAAa,EAAE,cAAc,EAC7B,kBAAkB,EAAE,mBAAmB,EACvC,QAAgB,EAChB,WAAW,EAAE,oBAAoB,EACjC,eAAe,EAAE,wBAAwB,EACzC,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,YAAY,EAEZ,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,gBAAoB,EAClC,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,GAAG,EACH,GAAG,SAAS,EACb,EAAE,kBAAkB,+BAk8BpB;yBAz+Be,kBAAkB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file TouchDateTimeField.tsx
|
|
7
|
-
* @input Uses React, Field, BottomSheet, SegmentedControl, DateInput month picker primitives, Wheel, StyleX intrinsic flex layout
|
|
7
|
+
* @input Uses React, Field, BottomSheet, SegmentedControl, DateInput month picker primitives, Wheel and the pickers' touch layer (TimeWheels), the touch presentation, StyleX intrinsic flex layout
|
|
8
8
|
* @output Exports TouchDateTimeField — the coarse-pointer surface behind DateTimeInput
|
|
9
9
|
* @position Internal component; consumed by DateTimeInput.tsx
|
|
10
10
|
*
|
|
@@ -46,7 +46,7 @@ import { themeProps } from "../utils/themeProps.js";
|
|
|
46
46
|
import { normalizeDayOfWeek } from "../utils/dateTypes.js";
|
|
47
47
|
import { formatLocaleTime } from "../utils/timeFormat.js";
|
|
48
48
|
import { getWeekdayHeaders } from "../Calendar/getWeekdayHeaderNames.js";
|
|
49
|
-
import { formatISOTime, isImeKeyEvent, isRenderable,
|
|
49
|
+
import { formatISOTime, isImeKeyEvent, isRenderable, clampTime, mergeProps, parseISOTime } from "../utils/index.js";
|
|
50
50
|
import { chainEventHandlers } from "../utils/chainEventHandlers.js";
|
|
51
51
|
import { joinAriaIDs } from "../utils/inputAria.js";
|
|
52
52
|
import { DATE_FORMAT_LONG, plainDateFormat, plainDateFromISO, plainDateToday } from "../utils/plainDate.js";
|
|
@@ -54,13 +54,16 @@ import { plainDateFormatStandaloneMonthYear } from "../utils/plainDate.js";
|
|
|
54
54
|
import { MonthScroller } from "../DateInput/MonthScroller.js";
|
|
55
55
|
import { MonthYearWheels } from "../DateInput/MonthYearWheels.js";
|
|
56
56
|
import { Wheel } from "../DateInput/Wheel.js";
|
|
57
|
+
import { TimeWheels } from "../DateInput/datePickerTouch.js";
|
|
58
|
+
import { hour12From24, hour24From12, hourRowsInHalf, meridiemRows, minuteRows, secondRows, wheelBounds } from "../TimeInput/timeWheelRules.js";
|
|
59
|
+
import { useTouchPresentation } from "../utils/touchPresentation.js";
|
|
57
60
|
import "../DateInput/tokens.stylex.js";
|
|
58
61
|
import { dateInputTouchGeometry, dateInputTouchSizes } from "../DateInput/tokens.stylex.js";
|
|
59
62
|
import { DEFAULT_MONTH_REACH, clampIndex, fromMonthIndex, monthIndexOf } from "../DateInput/monthGeometry.js";
|
|
60
63
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
61
64
|
import { InternationalizationContext } from "../i18n/InternationalizationContext.js";
|
|
62
65
|
import english from "../i18n/generated-english/DateTimeInput/TouchDateTimeField.generated.js";
|
|
63
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
66
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
64
67
|
registerEnglishFallback(english);
|
|
65
68
|
function splitDateTime(dt) {
|
|
66
69
|
if (!dt) {
|
|
@@ -201,30 +204,6 @@ function normalizeISOTime(time, hasSeconds) {
|
|
|
201
204
|
const parsed = parseISOTime(time);
|
|
202
205
|
return parsed ? formatISOTime(parsed, hasSeconds) : undefined;
|
|
203
206
|
}
|
|
204
|
-
function timeToSeconds(time) {
|
|
205
|
-
if (time === undefined) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
const parsed = parseISOTime(time);
|
|
209
|
-
return parsed == null ? null : parsed.hour * 3600 + parsed.minute * 60 + parsed.second;
|
|
210
|
-
}
|
|
211
|
-
function twoDigits(value) {
|
|
212
|
-
return String(value).padStart(2, '0');
|
|
213
|
-
}
|
|
214
|
-
function hour12From24(hour) {
|
|
215
|
-
return hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
|
|
216
|
-
}
|
|
217
|
-
function hour24From12(hour, meridiem) {
|
|
218
|
-
if (meridiem === 0) {
|
|
219
|
-
return hour === 12 ? 0 : hour;
|
|
220
|
-
}
|
|
221
|
-
return hour === 12 ? 12 : hour + 12;
|
|
222
|
-
}
|
|
223
|
-
function rangeOverlaps(startSecond, endSecond, min, max) {
|
|
224
|
-
const minSecond = timeToSeconds(min);
|
|
225
|
-
const maxSecond = timeToSeconds(max);
|
|
226
|
-
return (minSecond == null || endSecond >= minSecond) && (maxSecond == null || startSecond <= maxSecond);
|
|
227
|
-
}
|
|
228
207
|
export function TouchDateTimeField({
|
|
229
208
|
label,
|
|
230
209
|
isLabelHidden = false,
|
|
@@ -348,6 +327,9 @@ export function TouchDateTimeField({
|
|
|
348
327
|
useBusyAnnouncement(isBusy, t('@astryx.spinner.loading'), isSheetOpen ? sheetBodyRef : dateInputRef);
|
|
349
328
|
const [activePanel, setActivePanel] = useState('date');
|
|
350
329
|
const [isWheelOpen, setIsWheelOpen] = useState(false);
|
|
330
|
+
const {
|
|
331
|
+
isTouch
|
|
332
|
+
} = useTouchPresentation();
|
|
351
333
|
const [draftTime, setDraftTime] = useState(() => normalizeISOTime(splitDateTime(value).time, hasSeconds));
|
|
352
334
|
const today = useMemo(() => plainDateToday(), []);
|
|
353
335
|
const selectedDate = useMemo(() => parseValidISODate(valueParts.date), [valueParts.date]);
|
|
@@ -519,63 +501,14 @@ export function TouchDateTimeField({
|
|
|
519
501
|
}, hasSeconds);
|
|
520
502
|
}, [hasSeconds, hourFormat, parsedWheelTime]);
|
|
521
503
|
const timeBounds = timeBoundsForDate(valueParts.date);
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}));
|
|
531
|
-
}
|
|
532
|
-
const meridiem = parsedWheelTime.hour < 12 ? 0 : 1;
|
|
533
|
-
// In 12-hour mode the hour column is interpreted inside the active AM/PM
|
|
534
|
-
// half, so disabled rows describe reachability within that half only.
|
|
535
|
-
return Array.from({
|
|
536
|
-
length: 12
|
|
537
|
-
}, (_, index) => {
|
|
538
|
-
const hour = index + 1;
|
|
539
|
-
const hour24 = hour24From12(hour, meridiem);
|
|
540
|
-
return {
|
|
541
|
-
value: hour,
|
|
542
|
-
label: String(hour),
|
|
543
|
-
// Keys step in time order: 12 PM comes before 1 PM.
|
|
544
|
-
order: hour24,
|
|
545
|
-
isDisabled: !rangeOverlaps(hour24 * 3600, hour24 * 3600 + 3599, timeBounds.min, timeBounds.max)
|
|
546
|
-
};
|
|
547
|
-
});
|
|
548
|
-
}, [hourFormat, parsedWheelTime.hour, timeBounds.min, timeBounds.max]);
|
|
549
|
-
const minuteOptions = useMemo(() => Array.from({
|
|
550
|
-
length: 60
|
|
551
|
-
}, (_, minute) => {
|
|
552
|
-
const start = parsedWheelTime.hour * 3600 + minute * 60;
|
|
553
|
-
return {
|
|
554
|
-
value: minute,
|
|
555
|
-
label: twoDigits(minute),
|
|
556
|
-
isDisabled: !rangeOverlaps(start, start + (hasSeconds ? 59 : 0), timeBounds.min, timeBounds.max)
|
|
557
|
-
};
|
|
558
|
-
}), [hasSeconds, parsedWheelTime.hour, timeBounds.min, timeBounds.max]);
|
|
559
|
-
const secondOptions = useMemo(() => Array.from({
|
|
560
|
-
length: 60
|
|
561
|
-
}, (_, second) => ({
|
|
562
|
-
value: second,
|
|
563
|
-
label: twoDigits(second),
|
|
564
|
-
isDisabled: !isTimeInRange(formatISOTime({
|
|
565
|
-
hour: parsedWheelTime.hour,
|
|
566
|
-
minute: parsedWheelTime.minute,
|
|
567
|
-
second
|
|
568
|
-
}, true), timeBounds.min, timeBounds.max)
|
|
569
|
-
})), [parsedWheelTime.hour, parsedWheelTime.minute, timeBounds.min, timeBounds.max]);
|
|
570
|
-
const meridiemOptions = useMemo(() => [{
|
|
571
|
-
value: 0,
|
|
572
|
-
label: t('@astryx.dateTimeInput.meridiemAM'),
|
|
573
|
-
isDisabled: !rangeOverlaps(0, 11 * 3600 + 3599, timeBounds.min, timeBounds.max)
|
|
574
|
-
}, {
|
|
575
|
-
value: 1,
|
|
576
|
-
label: t('@astryx.dateTimeInput.meridiemPM'),
|
|
577
|
-
isDisabled: !rangeOverlaps(12 * 3600, 23 * 3600 + 3599, timeBounds.min, timeBounds.max)
|
|
578
|
-
}], [t, timeBounds.min, timeBounds.max]);
|
|
504
|
+
const bounds = useMemo(() => wheelBounds(timeBounds.min, timeBounds.max), [timeBounds.min, timeBounds.max]);
|
|
505
|
+
const hourOptions = useMemo(() => hourRowsInHalf(parsedWheelTime.hour, hourFormat, bounds), [bounds, hourFormat, parsedWheelTime.hour]);
|
|
506
|
+
const minuteOptions = useMemo(() => minuteRows(parsedWheelTime.hour, hasSeconds, bounds), [bounds, hasSeconds, parsedWheelTime.hour]);
|
|
507
|
+
const secondOptions = useMemo(() => secondRows(parsedWheelTime.hour, parsedWheelTime.minute, bounds), [bounds, parsedWheelTime.hour, parsedWheelTime.minute]);
|
|
508
|
+
const meridiemOptions = useMemo(() => meridiemRows({
|
|
509
|
+
am: t('@astryx.dateTimeInput.meridiemAM'),
|
|
510
|
+
pm: t('@astryx.dateTimeInput.meridiemPM')
|
|
511
|
+
}, bounds), [bounds, t]);
|
|
579
512
|
const handleVisibleMonthChange = useCallback(next => {
|
|
580
513
|
if (activePanel === 'date' && !isWheelOpen) {
|
|
581
514
|
setMonthIndex(next);
|
|
@@ -853,45 +786,55 @@ export function TouchDateTimeField({
|
|
|
853
786
|
className: "x15r89dc x78zum5 xh8yej3 xeuugli xdt5ytf x1txdalj xlshs6z xg01cxk x47corl"
|
|
854
787
|
}
|
|
855
788
|
}[!!(activePanel !== 'time') << 0],
|
|
856
|
-
children: [/*#__PURE__*/
|
|
789
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
857
790
|
...{
|
|
858
791
|
className: "x78zum5 xh8yej3 xeuugli xm8gem x1txdalj"
|
|
859
792
|
},
|
|
860
|
-
children:
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
hour24: hour
|
|
867
|
-
}) : composeWheelTime({
|
|
868
|
-
hour12: hour
|
|
869
|
-
}))
|
|
870
|
-
}), /*#__PURE__*/_jsx(Wheel, {
|
|
871
|
-
label: t('@astryx.dateTimeInput.minuteWheel'),
|
|
872
|
-
options: minuteOptions,
|
|
873
|
-
value: parsedWheelTime.minute,
|
|
793
|
+
children: isTouch ? /*#__PURE__*/_jsx(TimeWheels, {
|
|
794
|
+
time: parsedWheelTime,
|
|
795
|
+
hourFormat: hourFormat,
|
|
796
|
+
hasSeconds: hasSeconds,
|
|
797
|
+
min: timeBounds.min,
|
|
798
|
+
max: timeBounds.max,
|
|
874
799
|
isActive: activePanel === 'time',
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
800
|
+
onCommit: time => commitWheelTime(formatISOTime(time, hasSeconds))
|
|
801
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
802
|
+
children: [/*#__PURE__*/_jsx(Wheel, {
|
|
803
|
+
label: t('@astryx.dateTimeInput.hourWheel'),
|
|
804
|
+
options: hourOptions,
|
|
805
|
+
value: hourFormat === '24h' ? parsedWheelTime.hour : hour12From24(parsedWheelTime.hour),
|
|
806
|
+
isActive: activePanel === 'time',
|
|
807
|
+
onChange: hour => commitWheelTime(hourFormat === '24h' ? composeWheelTime({
|
|
808
|
+
hour24: hour
|
|
809
|
+
}) : composeWheelTime({
|
|
810
|
+
hour12: hour
|
|
811
|
+
}))
|
|
812
|
+
}), /*#__PURE__*/_jsx(Wheel, {
|
|
813
|
+
label: t('@astryx.dateTimeInput.minuteWheel'),
|
|
814
|
+
options: minuteOptions,
|
|
815
|
+
value: parsedWheelTime.minute,
|
|
816
|
+
isActive: activePanel === 'time',
|
|
817
|
+
onChange: minute => commitWheelTime(composeWheelTime({
|
|
818
|
+
minute
|
|
819
|
+
}))
|
|
820
|
+
}), hasSeconds && /*#__PURE__*/_jsx(Wheel, {
|
|
821
|
+
label: t('@astryx.dateTimeInput.secondWheel'),
|
|
822
|
+
options: secondOptions,
|
|
823
|
+
value: parsedWheelTime.second,
|
|
824
|
+
isActive: activePanel === 'time',
|
|
825
|
+
onChange: second => commitWheelTime(composeWheelTime({
|
|
826
|
+
second
|
|
827
|
+
}))
|
|
828
|
+
}), hourFormat === '12h' && /*#__PURE__*/_jsx(Wheel, {
|
|
829
|
+
label: t('@astryx.dateTimeInput.meridiemWheel'),
|
|
830
|
+
options: meridiemOptions,
|
|
831
|
+
value: parsedWheelTime.hour < 12 ? 0 : 1,
|
|
832
|
+
isActive: activePanel === 'time',
|
|
833
|
+
onChange: meridiem => commitWheelTime(composeWheelTime({
|
|
834
|
+
meridiem
|
|
835
|
+
}))
|
|
836
|
+
})]
|
|
837
|
+
})
|
|
895
838
|
}), /*#__PURE__*/_jsx("div", {
|
|
896
839
|
...{
|
|
897
840
|
className: "x78zum5 xr1yuqi xfsso4q"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHoverCard.d.ts","sourceRoot":"","sources":["../../src/HoverCard/useHoverCard.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AA8BlC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhE;;GAEG;AACH,MA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Aa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAE9B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEtC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEzC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;;;;OAOG;IACH,eAAe,EAAE,CACf,QAAQ,EAAE,SAAS,EACnB,KAAK,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,KAC5C,SAAS,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,YAAY,CAAC,OAAO,GAAE,gBAAqB,GAAG,eAAe,CAke5E"}
|
|
@@ -197,7 +197,12 @@ export function useHoverCard(options = {}) {
|
|
|
197
197
|
|
|
198
198
|
// Tap-to-open on touch; on a mouse this does nothing and hover still rules.
|
|
199
199
|
const handlePointerDown = useCallback(event => {
|
|
200
|
-
|
|
200
|
+
// A pen in range starts the hover show before it lands. Left pending,
|
|
201
|
+
// that show opens the card during the press. The tap then closes it.
|
|
202
|
+
if (handleTouchPointerDown(event) && showTimeoutRef.current) {
|
|
203
|
+
clearTimeout(showTimeoutRef.current);
|
|
204
|
+
showTimeoutRef.current = null;
|
|
205
|
+
}
|
|
201
206
|
}, [handleTouchPointerDown]);
|
|
202
207
|
|
|
203
208
|
// Under `auto`, whether focus counts is decided when it arrives, and a
|