@ringcentral/juno 2.31.0 → 2.32.0
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/components/Forms/Picker/TimePicker/TimePicker.d.ts +4 -1
- package/components/Forms/Picker/TimePicker/TimePicker.js +12 -5
- package/components/Forms/Picker/TimePicker/ToggleText.d.ts +16 -1
- package/components/Forms/Picker/TimePicker/ToggleText.js +2 -2
- package/components/Forms/Picker/TimePicker/types.d.ts +4 -0
- package/components/Forms/Picker/TimePicker/types.js +2 -0
- package/components/Forms/Picker/TimePicker/utils/TimePickerHelper.d.ts +5 -1
- package/components/Forms/Picker/TimePicker/utils/TimePickerHelper.js +2 -2
- package/components/VirtualizedMenu/VirtualizedMenu.js +14 -3
- package/components/VirtualizedMenu/useNextFrame.d.ts +1 -0
- package/components/VirtualizedMenu/useNextFrame.js +22 -0
- package/es6/components/Forms/Picker/TimePicker/TimePicker.js +12 -5
- package/es6/components/Forms/Picker/TimePicker/ToggleText.js +2 -2
- package/es6/components/Forms/Picker/TimePicker/types.js +0 -0
- package/es6/components/Forms/Picker/TimePicker/utils/TimePickerHelper.js +2 -2
- package/es6/components/VirtualizedMenu/VirtualizedMenu.js +14 -3
- package/es6/components/VirtualizedMenu/useNextFrame.js +20 -0
- package/es6/foundation/styles/focusRing.js +2 -2
- package/foundation/styles/focusRing.js +2 -2
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { CustomStyledComponentResult, RcBaseProps, RcBaseSize, RcClassesProps }
|
|
|
3
3
|
import { PickerTextFieldProps } from '../utils';
|
|
4
4
|
import { NumberPickerProps } from './NumberPicker';
|
|
5
5
|
import { ToggleTextProps } from './ToggleText';
|
|
6
|
+
import { PeriodTexts } from './types';
|
|
6
7
|
declare type RcTimePickerSize = RcBaseSize<'small' | 'medium'>;
|
|
7
8
|
declare type RcClickFiledStyleProps = {
|
|
8
9
|
/** Is 12 hours system */
|
|
@@ -13,6 +14,7 @@ declare type RcClickFiledStyleProps = {
|
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
};
|
|
15
16
|
declare type PickNumberPickerProps = RcBaseProps<Partial<NumberPickerProps>, 'size' | 'onUpdateValue' | 'onClose' | 'onClick' | 'onKeyDown' | 'value' | 'min' | 'max' | 'isTwelveHourSystem' | 'source' | 'step'>;
|
|
17
|
+
declare type RcTimePickerPeriodTexts = Record<'input' | 'toggle', PeriodTexts>;
|
|
16
18
|
declare type RcTimePickerProps<T = false> = {
|
|
17
19
|
/** with two size: 'small' | 'medium', default with medium. */
|
|
18
20
|
size?: RcTimePickerSize;
|
|
@@ -34,6 +36,7 @@ declare type RcTimePickerProps<T = false> = {
|
|
|
34
36
|
MinutePickerProps?: PickNumberPickerProps;
|
|
35
37
|
/** props for periodToggle component */
|
|
36
38
|
PeriodToggleProps?: RcBaseProps<Partial<ToggleTextProps>, 'disabled' | 'isTwelveHourSystem' | 'size' | 'value' | 'onUpdateValue' | 'children'>;
|
|
39
|
+
periodTexts?: RcTimePickerPeriodTexts;
|
|
37
40
|
/** picker will show default value when textfield is empty */
|
|
38
41
|
defaultPickerValue?: T extends true ? Date : number;
|
|
39
42
|
} & RcBaseProps<PickerTextFieldProps, 'onClick' | 'value' | 'children'> & RcClassesProps<'popover' | 'popoverPaper'>;
|
|
@@ -43,4 +46,4 @@ declare type RcTimePickerProps<T = false> = {
|
|
|
43
46
|
*/
|
|
44
47
|
declare const ExportType: <T extends boolean = false>(props: RcTimePickerProps<T>) => JSX.Element & CustomStyledComponentResult<RcTimePickerProps<T>>;
|
|
45
48
|
export { ExportType as RcTimePicker };
|
|
46
|
-
export type { RcClickFiledStyleProps, RcTimePickerProps, RcTimePickerSize };
|
|
49
|
+
export type { RcClickFiledStyleProps, RcTimePickerProps, RcTimePickerSize, RcTimePickerPeriodTexts, };
|
|
@@ -13,22 +13,26 @@ var SelectionView_1 = require("./SelectionView");
|
|
|
13
13
|
var styles_1 = require("./styles");
|
|
14
14
|
var ToggleText_1 = require("./ToggleText");
|
|
15
15
|
var utils_2 = require("./utils");
|
|
16
|
+
var defaultPeriodTexts = {
|
|
17
|
+
input: { AM: 'AM', PM: 'PM' },
|
|
18
|
+
toggle: { AM: 'AM', PM: 'PM' },
|
|
19
|
+
};
|
|
16
20
|
var _RcTimePicker = react_1.forwardRef(function (inProps, ref) {
|
|
17
21
|
var props = foundation_1.useThemeProps({ props: inProps, name: 'RcTimePicker' });
|
|
18
|
-
var isTwelveHourSystem = props.isTwelveHourSystem, value = props.value, onChange = props.onChange, disabled = props.disabled, dateMode = props.dateMode, min = props.min, max = props.max, size = props.size, onKeyDown = props.onKeyDown, onClear = props.onClear, HourPickerProps = props.HourPickerProps, MinutePickerProps = props.MinutePickerProps, PeriodToggleProps = props.PeriodToggleProps, PopoverPropsProp = props.PopoverProps, InputPropsProp = props.InputProps, classes = props.classes, defaultPickerValue = props.defaultPickerValue, rest = tslib_1.__rest(props, ["isTwelveHourSystem", "value", "onChange", "disabled", "dateMode", "min", "max", "size", "onKeyDown", "onClear", "HourPickerProps", "MinutePickerProps", "PeriodToggleProps", "PopoverProps", "InputProps", "classes", "defaultPickerValue"]);
|
|
22
|
+
var isTwelveHourSystem = props.isTwelveHourSystem, value = props.value, onChange = props.onChange, disabled = props.disabled, dateMode = props.dateMode, min = props.min, max = props.max, size = props.size, onKeyDown = props.onKeyDown, onClear = props.onClear, HourPickerProps = props.HourPickerProps, MinutePickerProps = props.MinutePickerProps, PeriodToggleProps = props.PeriodToggleProps, PopoverPropsProp = props.PopoverProps, InputPropsProp = props.InputProps, classes = props.classes, defaultPickerValue = props.defaultPickerValue, _a = props.periodTexts, periodTexts = _a === void 0 ? defaultPeriodTexts : _a, rest = tslib_1.__rest(props, ["isTwelveHourSystem", "value", "onChange", "disabled", "dateMode", "min", "max", "size", "onKeyDown", "onClear", "HourPickerProps", "MinutePickerProps", "PeriodToggleProps", "PopoverProps", "InputProps", "classes", "defaultPickerValue", "periodTexts"]);
|
|
19
23
|
var actionRef = react_1.useRef(null);
|
|
20
24
|
var hourRef = react_1.useRef(null);
|
|
21
25
|
var minuteRef = react_1.useRef(null);
|
|
22
26
|
var periodRef = react_1.useRef(null);
|
|
23
27
|
var textFiledValueRef = react_1.useRef('');
|
|
24
|
-
var
|
|
25
|
-
var
|
|
28
|
+
var _b = tslib_1.__read(react_1.useState('none'), 2), selectionShowType = _b[0], setSelectionType = _b[1];
|
|
29
|
+
var _c = (function () {
|
|
26
30
|
if (value !== null)
|
|
27
31
|
return { nowTime: value, isShowTextfieldValue: true };
|
|
28
32
|
if (defaultPickerValue)
|
|
29
33
|
return { nowTime: defaultPickerValue, isShowTextfieldValue: false };
|
|
30
34
|
return { nowTime: null, isShowTextfieldValue: false };
|
|
31
|
-
})(), nowTime =
|
|
35
|
+
})(), nowTime = _c.nowTime, isShowTextfieldValue = _c.isShowTextfieldValue;
|
|
32
36
|
var isHaveValue = nowTime !== null;
|
|
33
37
|
var isDateMode = nowTime instanceof Date || dateMode;
|
|
34
38
|
var currentTimestamp = utils_2.getTimestamp(nowTime);
|
|
@@ -195,6 +199,7 @@ var _RcTimePicker = react_1.forwardRef(function (inProps, ref) {
|
|
|
195
199
|
hour: hour,
|
|
196
200
|
minute: minute,
|
|
197
201
|
period: currentPeriod,
|
|
202
|
+
periodTexts: periodTexts.input,
|
|
198
203
|
}, isTwelveHourSystem);
|
|
199
204
|
textFiledValueRef.current = formattedTime;
|
|
200
205
|
}, [
|
|
@@ -203,6 +208,8 @@ var _RcTimePicker = react_1.forwardRef(function (inProps, ref) {
|
|
|
203
208
|
currentTimestamp,
|
|
204
209
|
isTwelveHourSystem,
|
|
205
210
|
currentPeriod,
|
|
211
|
+
periodTexts.input.AM,
|
|
212
|
+
periodTexts.input.PM,
|
|
206
213
|
]);
|
|
207
214
|
// * when no value, open menu use min as value
|
|
208
215
|
var originalHourValue = isHaveValue
|
|
@@ -244,7 +251,7 @@ var _RcTimePicker = react_1.forwardRef(function (inProps, ref) {
|
|
|
244
251
|
react_1.default.createElement(Box_1.RcBox, { textAlign: "center", width: "48px" }, ":"),
|
|
245
252
|
react_1.default.createElement(NumberPicker_1.NumberPicker, tslib_1.__assign({ ref: minuteRef, size: size }, boundary.minute, { onUpdateValue: handleMinuteChange, onClick: setMinuteSelectionShow, onClose: closeMenu, value: minuteValue, source: utils_2.minuteSource, step: utils_2.TIME_GAP, automationId: "time-picker-minute" }, MinutePickerProps)),
|
|
246
253
|
isTwelveHourSystem && (react_1.default.createElement("div", null,
|
|
247
|
-
react_1.default.createElement(ToggleText_1.ToggleText, tslib_1.__assign({ ref: periodRef, size: size, disabled: toggleTextDisabled, onUpdateValue: onTogglePeriod, onInnerChange: handlePeriodInnerChange, onClose: closeMenu, value: periodValue }, PeriodToggleProps)))))) : (react_1.default.createElement(SelectionView_1.SelectionView, tslib_1.__assign({ size: size }, (isHourView ? boundary.hour : boundary.minute), { source: isHourView
|
|
254
|
+
react_1.default.createElement(ToggleText_1.ToggleText, tslib_1.__assign({ periodTexts: periodTexts.toggle, ref: periodRef, size: size, disabled: toggleTextDisabled, onUpdateValue: onTogglePeriod, onInnerChange: handlePeriodInnerChange, onClose: closeMenu, value: periodValue }, PeriodToggleProps)))))) : (react_1.default.createElement(SelectionView_1.SelectionView, tslib_1.__assign({ size: size }, (isHourView ? boundary.hour : boundary.minute), { source: isHourView
|
|
248
255
|
? isTwelveHourSystem
|
|
249
256
|
? utils_2.twelveHourSystemSource
|
|
250
257
|
: utils_2.twentyFourHourSystemSource
|
|
@@ -12,6 +12,11 @@ declare type ToggleTextProps = {
|
|
|
12
12
|
getScreenReaderLabel?: (value: string) => string;
|
|
13
13
|
/** trigger when confirm value */
|
|
14
14
|
onClose: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
15
|
+
/** custom text for 'AM' and 'PM' */
|
|
16
|
+
periodTexts: {
|
|
17
|
+
AM: string;
|
|
18
|
+
PM: string;
|
|
19
|
+
};
|
|
15
20
|
} & RcClickFiledStyleProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'value'>;
|
|
16
21
|
declare type ToggleTextRef = {
|
|
17
22
|
value: TIME_SYSTEM_TEXT;
|
|
@@ -27,6 +32,11 @@ declare const ToggleText: import("styled-components").StyledComponentClass<{
|
|
|
27
32
|
getScreenReaderLabel?: ((value: string) => string) | undefined;
|
|
28
33
|
/** trigger when confirm value */
|
|
29
34
|
onClose: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
35
|
+
/** custom text for 'AM' and 'PM' */
|
|
36
|
+
periodTexts: {
|
|
37
|
+
AM: string;
|
|
38
|
+
PM: string;
|
|
39
|
+
};
|
|
30
40
|
} & RcClickFiledStyleProps & Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, "form" | "className" | "color" | "id" | "lang" | "name" | "style" | "type" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget"> & React.RefAttributes<ToggleTextRef>, import("../../../../foundation").RcTheme, Pick<{
|
|
31
41
|
/** when user click th display text to change */
|
|
32
42
|
onUpdateValue: (value: TIME_SYSTEM_TEXT) => void;
|
|
@@ -38,7 +48,12 @@ declare const ToggleText: import("styled-components").StyledComponentClass<{
|
|
|
38
48
|
getScreenReaderLabel?: ((value: string) => string) | undefined;
|
|
39
49
|
/** trigger when confirm value */
|
|
40
50
|
onClose: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
41
|
-
|
|
51
|
+
/** custom text for 'AM' and 'PM' */
|
|
52
|
+
periodTexts: {
|
|
53
|
+
AM: string;
|
|
54
|
+
PM: string;
|
|
55
|
+
};
|
|
56
|
+
} & RcClickFiledStyleProps & Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, "form" | "className" | "color" | "id" | "lang" | "name" | "style" | "type" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget"> & React.RefAttributes<ToggleTextRef>, "ref" | "key" | "form" | "className" | "color" | "id" | "lang" | "name" | "style" | "type" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "value" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "onClose" | "onUpdateValue" | "isTwelveHourSystem" | "onInnerChange" | "getScreenReaderLabel" | "periodTexts"> & {
|
|
42
57
|
theme?: import("../../../../foundation").RcTheme | undefined;
|
|
43
58
|
}>;
|
|
44
59
|
export { ToggleText };
|
|
@@ -9,7 +9,7 @@ var styles_1 = require("./styles");
|
|
|
9
9
|
var utils_1 = require("./utils");
|
|
10
10
|
var A11yUtils_1 = require("./utils/A11yUtils");
|
|
11
11
|
var _ToggleText = react_1.memo(react_1.forwardRef(function (_a, ref) {
|
|
12
|
-
var onUpdateValue = _a.onUpdateValue, onInnerChange = _a.onInnerChange, value = _a.value, size = _a.size, disabled = _a.disabled, getScreenReaderLabel = _a.getScreenReaderLabel, onClose = _a.onClose, rest = tslib_1.__rest(_a, ["onUpdateValue", "onInnerChange", "value", "size", "disabled", "getScreenReaderLabel", "onClose"]);
|
|
12
|
+
var onUpdateValue = _a.onUpdateValue, onInnerChange = _a.onInnerChange, value = _a.value, size = _a.size, disabled = _a.disabled, getScreenReaderLabel = _a.getScreenReaderLabel, onClose = _a.onClose, periodTexts = _a.periodTexts, rest = tslib_1.__rest(_a, ["onUpdateValue", "onInnerChange", "value", "size", "disabled", "getScreenReaderLabel", "onClose", "periodTexts"]);
|
|
13
13
|
var _b = tslib_1.__read(foundation_1.useRefState(value), 2), innerValueRef = _b[0], setInnerValue = _b[1];
|
|
14
14
|
foundation_1.useChange(function () {
|
|
15
15
|
if (innerValueRef.current !== value) {
|
|
@@ -50,7 +50,7 @@ var _ToggleText = react_1.memo(react_1.forwardRef(function (_a, ref) {
|
|
|
50
50
|
value: innerValue,
|
|
51
51
|
}); }, [innerValue]);
|
|
52
52
|
return (react_1.default.createElement(styles_1.StyledTimeIconButton, tslib_1.__assign({ wrapperSize: size, onClick: handleClick, onKeyDown: handleToggleKeyDown, disabled: disabled, color: "informative.f02", "aria-live": "assertive", "aria-label": label }, rest),
|
|
53
|
-
react_1.default.createElement(react_1.default.Fragment, null, innerValue)));
|
|
53
|
+
react_1.default.createElement(react_1.default.Fragment, null, periodTexts[innerValue])));
|
|
54
54
|
}));
|
|
55
55
|
var ToggleText = foundation_1.styled(_ToggleText)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n margin-left: ", ";\n"], ["\n margin-left: ", ";\n"])), function (_a) {
|
|
56
56
|
var size = _a.size;
|
|
@@ -7,6 +7,10 @@ declare type GetFormattedTimeOption = {
|
|
|
7
7
|
hour: number;
|
|
8
8
|
minute: number;
|
|
9
9
|
period: TIME_SYSTEM_TEXT;
|
|
10
|
+
periodTexts: {
|
|
11
|
+
AM: string;
|
|
12
|
+
PM: string;
|
|
13
|
+
};
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
12
16
|
* get formatted time hh:mm
|
|
@@ -14,7 +18,7 @@ declare type GetFormattedTimeOption = {
|
|
|
14
18
|
* @param isTwelveHourSystem boolean
|
|
15
19
|
* @returns `hh:mm AM` or `hh:mm PM` or `hh:mm`
|
|
16
20
|
*/
|
|
17
|
-
declare const getFormattedTime: ({ hour, minute, period }: GetFormattedTimeOption, isTwelveHourSystem?: boolean | undefined) => string;
|
|
21
|
+
declare const getFormattedTime: ({ hour, minute, period, periodTexts }: GetFormattedTimeOption, isTwelveHourSystem?: boolean | undefined) => string;
|
|
18
22
|
declare const HALF_DAY_HOURS = 12;
|
|
19
23
|
declare const HOUR_MINUTES = 60;
|
|
20
24
|
declare const TIME_GAP = 15;
|
|
@@ -30,10 +30,10 @@ exports.pad = pad;
|
|
|
30
30
|
* @returns `hh:mm AM` or `hh:mm PM` or `hh:mm`
|
|
31
31
|
*/
|
|
32
32
|
var getFormattedTime = function (_a, isTwelveHourSystem) {
|
|
33
|
-
var hour = _a.hour, minute = _a.minute, period = _a.period;
|
|
33
|
+
var hour = _a.hour, minute = _a.minute, period = _a.period, periodTexts = _a.periodTexts;
|
|
34
34
|
var formattedHour = parseNumberToString(hour, isTwelveHourSystem);
|
|
35
35
|
var formattedMinute = parseNumberToString(minute);
|
|
36
|
-
var periodText = isTwelveHourSystem ? " " + period : '';
|
|
36
|
+
var periodText = isTwelveHourSystem ? " " + periodTexts[period] : '';
|
|
37
37
|
return formattedHour + ":" + formattedMinute + periodText;
|
|
38
38
|
};
|
|
39
39
|
exports.getFormattedTime = getFormattedTime;
|
|
@@ -9,12 +9,15 @@ var Transitions_1 = require("../Transitions");
|
|
|
9
9
|
var styles_1 = require("./styles");
|
|
10
10
|
var utils_1 = require("./utils");
|
|
11
11
|
var VirtualizedMenuList_1 = require("./VirtualizedMenuList");
|
|
12
|
+
var useNextFrame_1 = require("./useNextFrame");
|
|
12
13
|
var _RcVirtualizedMenu = react_1.forwardRef(function (inProps, ref) {
|
|
13
14
|
var props = foundation_1.useThemeProps({ props: inProps, name: 'RcVirtualizedMenu' });
|
|
14
|
-
var _a = props.autoFocus, autoFocus = _a === void 0 ? true : _a, children = props.children, classesProp = props.classes, _b = props.disableAutoFocusItem, disableAutoFocusItem = _b === void 0 ? false : _b, _c = props.MenuListProps, _d = _c === void 0 ? {} : _c, _e = _d.maxHeight, maxHeight = _e === void 0 ? 416 : _e, onKeyDown = _d.onKeyDown, MenuListProps = tslib_1.__rest(_d, ["maxHeight", "onKeyDown"]), onClose = props.onClose, open = props.open, TransitionPropsProp = props.TransitionProps, _f = props.PaperProps, PaperPropsProp = _f === void 0 ? {} : _f, PopoverClasses = props.PopoverClasses, _g = props.transitionDuration, transitionDuration = _g === void 0 ? 'auto' : _g, _h = props.variant, variant = _h === void 0 ? 'selectedMenu' : _h, rest = tslib_1.__rest(props, ["autoFocus", "children", "classes", "disableAutoFocusItem", "MenuListProps", "onClose", "open", "TransitionProps", "PaperProps", "PopoverClasses", "transitionDuration", "variant"]);
|
|
15
|
+
var _a = props.autoFocus, autoFocus = _a === void 0 ? true : _a, children = props.children, classesProp = props.classes, _b = props.disableAutoFocusItem, disableAutoFocusItem = _b === void 0 ? false : _b, _c = props.MenuListProps, _d = _c === void 0 ? {} : _c, _e = _d.maxHeight, maxHeight = _e === void 0 ? 416 : _e, onKeyDown = _d.onKeyDown, VirtuosoProps = _d.VirtuosoProps, MenuListProps = tslib_1.__rest(_d, ["maxHeight", "onKeyDown", "VirtuosoProps"]), onClose = props.onClose, open = props.open, TransitionPropsProp = props.TransitionProps, _f = props.PaperProps, PaperPropsProp = _f === void 0 ? {} : _f, PopoverClasses = props.PopoverClasses, _g = props.transitionDuration, transitionDuration = _g === void 0 ? 'auto' : _g, _h = props.variant, variant = _h === void 0 ? 'selectedMenu' : _h, _j = props.action, popoverActionProp = _j === void 0 ? null : _j, rest = tslib_1.__rest(props, ["autoFocus", "children", "classes", "disableAutoFocusItem", "MenuListProps", "onClose", "open", "TransitionProps", "PaperProps", "PopoverClasses", "transitionDuration", "variant", "action"]);
|
|
15
16
|
var document = foundation_1.useRcPortalWindowContext().document;
|
|
16
17
|
var popoverRef = react_1.useRef(null);
|
|
17
18
|
var handleRef = foundation_1.useForkRef(ref, popoverRef);
|
|
19
|
+
var popoverAction = react_1.useRef(null);
|
|
20
|
+
var handlePopoverAction = foundation_1.useForkRef(popoverAction, popoverActionProp);
|
|
18
21
|
var menuListActionRef = react_1.useRef(null);
|
|
19
22
|
var classes = react_1.useMemo(function () { return foundation_1.combineClasses(utils_1.RcVirtualizedMenuClasses, classesProp); }, [classesProp]);
|
|
20
23
|
var autoFocusItem = autoFocus && !disableAutoFocusItem && open;
|
|
@@ -51,10 +54,18 @@ var _RcVirtualizedMenu = react_1.forwardRef(function (inProps, ref) {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
});
|
|
54
|
-
|
|
57
|
+
var runInNextFrame = useNextFrame_1.useNextFrame();
|
|
58
|
+
return (react_1.default.createElement(Popover_1.RcPopover, tslib_1.__assign({ ref: handleRef, action: handlePopoverAction, container: document.body, classes: PopoverClasses, onClose: onClose, open: open,
|
|
55
59
|
// FIXME: workaround for virtualized menu height incorrect issue
|
|
56
60
|
TransitionComponent: Transitions_1.RcFade, transitionDuration: transitionDuration, PaperProps: PaperProps, TransitionProps: TransitionProps }, rest),
|
|
57
|
-
react_1.default.createElement(VirtualizedMenuList_1.RcVirtualizedMenuList, tslib_1.__assign({ position: "unset", action: menuListActionRef, autoFocus: autoFocus, autoFocusItem: autoFocusItem, maxHeight: maxHeight, variant: variant, onKeyDown: handleListKeyDown },
|
|
61
|
+
react_1.default.createElement(VirtualizedMenuList_1.RcVirtualizedMenuList, tslib_1.__assign({ position: "unset", action: menuListActionRef, autoFocus: autoFocus, autoFocusItem: autoFocusItem, maxHeight: maxHeight, variant: variant, onKeyDown: handleListKeyDown, VirtuosoProps: tslib_1.__assign(tslib_1.__assign({}, VirtuosoProps), { totalListHeightChanged: function (height) {
|
|
62
|
+
var _a;
|
|
63
|
+
(_a = VirtuosoProps === null || VirtuosoProps === void 0 ? void 0 : VirtuosoProps.totalListHeightChanged) === null || _a === void 0 ? void 0 : _a.call(VirtuosoProps, height);
|
|
64
|
+
runInNextFrame(function () {
|
|
65
|
+
var _a;
|
|
66
|
+
(_a = popoverAction.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
|
|
67
|
+
});
|
|
68
|
+
} }) }, MenuListProps, { className: clsx_1.default(classes.list, MenuListProps.className) }), children)));
|
|
58
69
|
});
|
|
59
70
|
var RcVirtualizedMenu = foundation_1.styled(_RcVirtualizedMenu)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.VirtualizedMenuStyle);
|
|
60
71
|
exports.RcVirtualizedMenu = RcVirtualizedMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useNextFrame: () => (task: Function) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
exports.useNextFrame = function () {
|
|
5
|
+
var rafIdRef = react_1.useRef(null);
|
|
6
|
+
react_1.useLayoutEffect(function () {
|
|
7
|
+
if (rafIdRef.current !== null) {
|
|
8
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
9
|
+
}
|
|
10
|
+
}, []);
|
|
11
|
+
return function (task) {
|
|
12
|
+
if (rafIdRef.current !== null) {
|
|
13
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
14
|
+
}
|
|
15
|
+
rafIdRef.current = requestAnimationFrame(function () {
|
|
16
|
+
rafIdRef.current = requestAnimationFrame(function () {
|
|
17
|
+
rafIdRef.current = null;
|
|
18
|
+
task();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -11,22 +11,26 @@ import { SelectionView } from './SelectionView';
|
|
|
11
11
|
import { StyledPickerPopperWrap } from './styles';
|
|
12
12
|
import { ToggleText } from './ToggleText';
|
|
13
13
|
import { getFormattedTime, getHourAndMinute, getNumberPickerBoundary, getPeriod, getRangeBoundary, getRecoupHour, getTimestamp, getTimestampFromDate, HALF_DAY_HOURS, minuteSource, parseNumberToString, RcTimePickerClasses, TIME_GAP, twelveHourSystemSource, twentyFourHourSystemSource, } from './utils';
|
|
14
|
+
var defaultPeriodTexts = {
|
|
15
|
+
input: { AM: 'AM', PM: 'PM' },
|
|
16
|
+
toggle: { AM: 'AM', PM: 'PM' },
|
|
17
|
+
};
|
|
14
18
|
var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
15
19
|
var props = useThemeProps({ props: inProps, name: 'RcTimePicker' });
|
|
16
|
-
var isTwelveHourSystem = props.isTwelveHourSystem, value = props.value, onChange = props.onChange, disabled = props.disabled, dateMode = props.dateMode, min = props.min, max = props.max, size = props.size, onKeyDown = props.onKeyDown, onClear = props.onClear, HourPickerProps = props.HourPickerProps, MinutePickerProps = props.MinutePickerProps, PeriodToggleProps = props.PeriodToggleProps, PopoverPropsProp = props.PopoverProps, InputPropsProp = props.InputProps, classes = props.classes, defaultPickerValue = props.defaultPickerValue, rest = __rest(props, ["isTwelveHourSystem", "value", "onChange", "disabled", "dateMode", "min", "max", "size", "onKeyDown", "onClear", "HourPickerProps", "MinutePickerProps", "PeriodToggleProps", "PopoverProps", "InputProps", "classes", "defaultPickerValue"]);
|
|
20
|
+
var isTwelveHourSystem = props.isTwelveHourSystem, value = props.value, onChange = props.onChange, disabled = props.disabled, dateMode = props.dateMode, min = props.min, max = props.max, size = props.size, onKeyDown = props.onKeyDown, onClear = props.onClear, HourPickerProps = props.HourPickerProps, MinutePickerProps = props.MinutePickerProps, PeriodToggleProps = props.PeriodToggleProps, PopoverPropsProp = props.PopoverProps, InputPropsProp = props.InputProps, classes = props.classes, defaultPickerValue = props.defaultPickerValue, _a = props.periodTexts, periodTexts = _a === void 0 ? defaultPeriodTexts : _a, rest = __rest(props, ["isTwelveHourSystem", "value", "onChange", "disabled", "dateMode", "min", "max", "size", "onKeyDown", "onClear", "HourPickerProps", "MinutePickerProps", "PeriodToggleProps", "PopoverProps", "InputProps", "classes", "defaultPickerValue", "periodTexts"]);
|
|
17
21
|
var actionRef = useRef(null);
|
|
18
22
|
var hourRef = useRef(null);
|
|
19
23
|
var minuteRef = useRef(null);
|
|
20
24
|
var periodRef = useRef(null);
|
|
21
25
|
var textFiledValueRef = useRef('');
|
|
22
|
-
var
|
|
23
|
-
var
|
|
26
|
+
var _b = __read(useState('none'), 2), selectionShowType = _b[0], setSelectionType = _b[1];
|
|
27
|
+
var _c = (function () {
|
|
24
28
|
if (value !== null)
|
|
25
29
|
return { nowTime: value, isShowTextfieldValue: true };
|
|
26
30
|
if (defaultPickerValue)
|
|
27
31
|
return { nowTime: defaultPickerValue, isShowTextfieldValue: false };
|
|
28
32
|
return { nowTime: null, isShowTextfieldValue: false };
|
|
29
|
-
})(), nowTime =
|
|
33
|
+
})(), nowTime = _c.nowTime, isShowTextfieldValue = _c.isShowTextfieldValue;
|
|
30
34
|
var isHaveValue = nowTime !== null;
|
|
31
35
|
var isDateMode = nowTime instanceof Date || dateMode;
|
|
32
36
|
var currentTimestamp = getTimestamp(nowTime);
|
|
@@ -193,6 +197,7 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
193
197
|
hour: hour,
|
|
194
198
|
minute: minute,
|
|
195
199
|
period: currentPeriod,
|
|
200
|
+
periodTexts: periodTexts.input,
|
|
196
201
|
}, isTwelveHourSystem);
|
|
197
202
|
textFiledValueRef.current = formattedTime;
|
|
198
203
|
}, [
|
|
@@ -201,6 +206,8 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
201
206
|
currentTimestamp,
|
|
202
207
|
isTwelveHourSystem,
|
|
203
208
|
currentPeriod,
|
|
209
|
+
periodTexts.input.AM,
|
|
210
|
+
periodTexts.input.PM,
|
|
204
211
|
]);
|
|
205
212
|
// * when no value, open menu use min as value
|
|
206
213
|
var originalHourValue = isHaveValue
|
|
@@ -242,7 +249,7 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
242
249
|
React.createElement(RcBox, { textAlign: "center", width: "48px" }, ":"),
|
|
243
250
|
React.createElement(NumberPicker, __assign({ ref: minuteRef, size: size }, boundary.minute, { onUpdateValue: handleMinuteChange, onClick: setMinuteSelectionShow, onClose: closeMenu, value: minuteValue, source: minuteSource, step: TIME_GAP, automationId: "time-picker-minute" }, MinutePickerProps)),
|
|
244
251
|
isTwelveHourSystem && (React.createElement("div", null,
|
|
245
|
-
React.createElement(ToggleText, __assign({ ref: periodRef, size: size, disabled: toggleTextDisabled, onUpdateValue: onTogglePeriod, onInnerChange: handlePeriodInnerChange, onClose: closeMenu, value: periodValue }, PeriodToggleProps)))))) : (React.createElement(SelectionView, __assign({ size: size }, (isHourView ? boundary.hour : boundary.minute), { source: isHourView
|
|
252
|
+
React.createElement(ToggleText, __assign({ periodTexts: periodTexts.toggle, ref: periodRef, size: size, disabled: toggleTextDisabled, onUpdateValue: onTogglePeriod, onInnerChange: handlePeriodInnerChange, onClose: closeMenu, value: periodValue }, PeriodToggleProps)))))) : (React.createElement(SelectionView, __assign({ size: size }, (isHourView ? boundary.hour : boundary.minute), { source: isHourView
|
|
246
253
|
? isTwelveHourSystem
|
|
247
254
|
? twelveHourSystemSource
|
|
248
255
|
: twentyFourHourSystemSource
|
|
@@ -7,7 +7,7 @@ import { StyledTimeIconButton } from './styles';
|
|
|
7
7
|
import { RcTimePickerUtils } from './utils';
|
|
8
8
|
import { isClick } from './utils/A11yUtils';
|
|
9
9
|
var _ToggleText = memo(forwardRef(function (_a, ref) {
|
|
10
|
-
var onUpdateValue = _a.onUpdateValue, onInnerChange = _a.onInnerChange, value = _a.value, size = _a.size, disabled = _a.disabled, getScreenReaderLabel = _a.getScreenReaderLabel, onClose = _a.onClose, rest = __rest(_a, ["onUpdateValue", "onInnerChange", "value", "size", "disabled", "getScreenReaderLabel", "onClose"]);
|
|
10
|
+
var onUpdateValue = _a.onUpdateValue, onInnerChange = _a.onInnerChange, value = _a.value, size = _a.size, disabled = _a.disabled, getScreenReaderLabel = _a.getScreenReaderLabel, onClose = _a.onClose, periodTexts = _a.periodTexts, rest = __rest(_a, ["onUpdateValue", "onInnerChange", "value", "size", "disabled", "getScreenReaderLabel", "onClose", "periodTexts"]);
|
|
11
11
|
var _b = __read(useRefState(value), 2), innerValueRef = _b[0], setInnerValue = _b[1];
|
|
12
12
|
useChange(function () {
|
|
13
13
|
if (innerValueRef.current !== value) {
|
|
@@ -48,7 +48,7 @@ var _ToggleText = memo(forwardRef(function (_a, ref) {
|
|
|
48
48
|
value: innerValue,
|
|
49
49
|
}); }, [innerValue]);
|
|
50
50
|
return (React.createElement(StyledTimeIconButton, __assign({ wrapperSize: size, onClick: handleClick, onKeyDown: handleToggleKeyDown, disabled: disabled, color: "informative.f02", "aria-live": "assertive", "aria-label": label }, rest),
|
|
51
|
-
React.createElement(React.Fragment, null, innerValue)));
|
|
51
|
+
React.createElement(React.Fragment, null, periodTexts[innerValue])));
|
|
52
52
|
}));
|
|
53
53
|
var ToggleText = styled(_ToggleText)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-left: ", ";\n"], ["\n margin-left: ", ";\n"])), function (_a) {
|
|
54
54
|
var size = _a.size;
|
|
File without changes
|
|
@@ -25,10 +25,10 @@ var pad = function (num, size) {
|
|
|
25
25
|
* @returns `hh:mm AM` or `hh:mm PM` or `hh:mm`
|
|
26
26
|
*/
|
|
27
27
|
var getFormattedTime = function (_a, isTwelveHourSystem) {
|
|
28
|
-
var hour = _a.hour, minute = _a.minute, period = _a.period;
|
|
28
|
+
var hour = _a.hour, minute = _a.minute, period = _a.period, periodTexts = _a.periodTexts;
|
|
29
29
|
var formattedHour = parseNumberToString(hour, isTwelveHourSystem);
|
|
30
30
|
var formattedMinute = parseNumberToString(minute);
|
|
31
|
-
var periodText = isTwelveHourSystem ? " " + period : '';
|
|
31
|
+
var periodText = isTwelveHourSystem ? " " + periodTexts[period] : '';
|
|
32
32
|
return formattedHour + ":" + formattedMinute + periodText;
|
|
33
33
|
};
|
|
34
34
|
var HALF_DAY_HOURS = 12;
|
|
@@ -7,12 +7,15 @@ import { RcFade } from '../Transitions';
|
|
|
7
7
|
import { VirtualizedMenuStyle } from './styles';
|
|
8
8
|
import { RcVirtualizedMenuClasses } from './utils';
|
|
9
9
|
import { RcVirtualizedMenuList, } from './VirtualizedMenuList';
|
|
10
|
+
import { useNextFrame } from './useNextFrame';
|
|
10
11
|
var _RcVirtualizedMenu = forwardRef(function (inProps, ref) {
|
|
11
12
|
var props = useThemeProps({ props: inProps, name: 'RcVirtualizedMenu' });
|
|
12
|
-
var _a = props.autoFocus, autoFocus = _a === void 0 ? true : _a, children = props.children, classesProp = props.classes, _b = props.disableAutoFocusItem, disableAutoFocusItem = _b === void 0 ? false : _b, _c = props.MenuListProps, _d = _c === void 0 ? {} : _c, _e = _d.maxHeight, maxHeight = _e === void 0 ? 416 : _e, onKeyDown = _d.onKeyDown, MenuListProps = __rest(_d, ["maxHeight", "onKeyDown"]), onClose = props.onClose, open = props.open, TransitionPropsProp = props.TransitionProps, _f = props.PaperProps, PaperPropsProp = _f === void 0 ? {} : _f, PopoverClasses = props.PopoverClasses, _g = props.transitionDuration, transitionDuration = _g === void 0 ? 'auto' : _g, _h = props.variant, variant = _h === void 0 ? 'selectedMenu' : _h, rest = __rest(props, ["autoFocus", "children", "classes", "disableAutoFocusItem", "MenuListProps", "onClose", "open", "TransitionProps", "PaperProps", "PopoverClasses", "transitionDuration", "variant"]);
|
|
13
|
+
var _a = props.autoFocus, autoFocus = _a === void 0 ? true : _a, children = props.children, classesProp = props.classes, _b = props.disableAutoFocusItem, disableAutoFocusItem = _b === void 0 ? false : _b, _c = props.MenuListProps, _d = _c === void 0 ? {} : _c, _e = _d.maxHeight, maxHeight = _e === void 0 ? 416 : _e, onKeyDown = _d.onKeyDown, VirtuosoProps = _d.VirtuosoProps, MenuListProps = __rest(_d, ["maxHeight", "onKeyDown", "VirtuosoProps"]), onClose = props.onClose, open = props.open, TransitionPropsProp = props.TransitionProps, _f = props.PaperProps, PaperPropsProp = _f === void 0 ? {} : _f, PopoverClasses = props.PopoverClasses, _g = props.transitionDuration, transitionDuration = _g === void 0 ? 'auto' : _g, _h = props.variant, variant = _h === void 0 ? 'selectedMenu' : _h, _j = props.action, popoverActionProp = _j === void 0 ? null : _j, rest = __rest(props, ["autoFocus", "children", "classes", "disableAutoFocusItem", "MenuListProps", "onClose", "open", "TransitionProps", "PaperProps", "PopoverClasses", "transitionDuration", "variant", "action"]);
|
|
13
14
|
var document = useRcPortalWindowContext().document;
|
|
14
15
|
var popoverRef = useRef(null);
|
|
15
16
|
var handleRef = useForkRef(ref, popoverRef);
|
|
17
|
+
var popoverAction = useRef(null);
|
|
18
|
+
var handlePopoverAction = useForkRef(popoverAction, popoverActionProp);
|
|
16
19
|
var menuListActionRef = useRef(null);
|
|
17
20
|
var classes = useMemo(function () { return combineClasses(RcVirtualizedMenuClasses, classesProp); }, [classesProp]);
|
|
18
21
|
var autoFocusItem = autoFocus && !disableAutoFocusItem && open;
|
|
@@ -49,10 +52,18 @@ var _RcVirtualizedMenu = forwardRef(function (inProps, ref) {
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
|
-
|
|
55
|
+
var runInNextFrame = useNextFrame();
|
|
56
|
+
return (React.createElement(RcPopover, __assign({ ref: handleRef, action: handlePopoverAction, container: document.body, classes: PopoverClasses, onClose: onClose, open: open,
|
|
53
57
|
// FIXME: workaround for virtualized menu height incorrect issue
|
|
54
58
|
TransitionComponent: RcFade, transitionDuration: transitionDuration, PaperProps: PaperProps, TransitionProps: TransitionProps }, rest),
|
|
55
|
-
React.createElement(RcVirtualizedMenuList, __assign({ position: "unset", action: menuListActionRef, autoFocus: autoFocus, autoFocusItem: autoFocusItem, maxHeight: maxHeight, variant: variant, onKeyDown: handleListKeyDown },
|
|
59
|
+
React.createElement(RcVirtualizedMenuList, __assign({ position: "unset", action: menuListActionRef, autoFocus: autoFocus, autoFocusItem: autoFocusItem, maxHeight: maxHeight, variant: variant, onKeyDown: handleListKeyDown, VirtuosoProps: __assign(__assign({}, VirtuosoProps), { totalListHeightChanged: function (height) {
|
|
60
|
+
var _a;
|
|
61
|
+
(_a = VirtuosoProps === null || VirtuosoProps === void 0 ? void 0 : VirtuosoProps.totalListHeightChanged) === null || _a === void 0 ? void 0 : _a.call(VirtuosoProps, height);
|
|
62
|
+
runInNextFrame(function () {
|
|
63
|
+
var _a;
|
|
64
|
+
(_a = popoverAction.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
|
|
65
|
+
});
|
|
66
|
+
} }) }, MenuListProps, { className: clsx(classes.list, MenuListProps.className) }), children)));
|
|
56
67
|
});
|
|
57
68
|
var RcVirtualizedMenu = styled(_RcVirtualizedMenu)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), VirtualizedMenuStyle);
|
|
58
69
|
RcVirtualizedMenu.defaultProps = {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useRef, useLayoutEffect } from 'react';
|
|
2
|
+
export var useNextFrame = function () {
|
|
3
|
+
var rafIdRef = useRef(null);
|
|
4
|
+
useLayoutEffect(function () {
|
|
5
|
+
if (rafIdRef.current !== null) {
|
|
6
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
7
|
+
}
|
|
8
|
+
}, []);
|
|
9
|
+
return function (task) {
|
|
10
|
+
if (rafIdRef.current !== null) {
|
|
11
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
12
|
+
}
|
|
13
|
+
rafIdRef.current = requestAnimationFrame(function () {
|
|
14
|
+
rafIdRef.current = requestAnimationFrame(function () {
|
|
15
|
+
rafIdRef.current = null;
|
|
16
|
+
task();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -13,9 +13,9 @@ export var focusRing = function (variant, options) {
|
|
|
13
13
|
var _b = options.borderRadius, borderRadius = _b === void 0 ? 'zero' : _b, _c = options.borderWidth, borderWidth = _c === void 0 ? '0px' : _c;
|
|
14
14
|
var isInset = variant === 'inset';
|
|
15
15
|
var offset = focusRingOffsetMap[variant];
|
|
16
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "], ["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "])), offset, borderWidth, offset, radius(borderRadius), isInset ? 'inset' : '', palette2('interactive', '
|
|
16
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "], ["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "])), offset, borderWidth, offset, radius(borderRadius), isInset ? 'inset' : '', palette2('interactive', 'f01'));
|
|
17
17
|
}
|
|
18
18
|
var _d = options.gapColor, gapColor = _d === void 0 ? 'neutral.b01' : _d;
|
|
19
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "], ["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "])), getParsePaletteColor(gapColor), palette2('interactive', '
|
|
19
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "], ["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "])), getParsePaletteColor(gapColor), palette2('interactive', 'f01'));
|
|
20
20
|
};
|
|
21
21
|
var templateObject_1, templateObject_2;
|
|
@@ -15,9 +15,9 @@ exports.focusRing = function (variant, options) {
|
|
|
15
15
|
var _b = options.borderRadius, borderRadius = _b === void 0 ? 'zero' : _b, _c = options.borderWidth, borderWidth = _c === void 0 ? '0px' : _c;
|
|
16
16
|
var isInset = variant === 'inset';
|
|
17
17
|
var offset = focusRingOffsetMap[variant];
|
|
18
|
-
return styled_components_1.css(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "], ["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "])), offset, borderWidth, offset, radius_1.radius(borderRadius), isInset ? 'inset' : '', newPalette_1.palette2('interactive', '
|
|
18
|
+
return styled_components_1.css(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "], ["\n &:after {\n pointer-events: none;\n content: '';\n position: absolute;\n inset: 0;\n\n margin: calc(-", " - ", ");\n border-radius: calc(", " + ", ");\n box-shadow: ", " 0 0 0 2px\n ", ";\n }\n "])), offset, borderWidth, offset, radius_1.radius(borderRadius), isInset ? 'inset' : '', newPalette_1.palette2('interactive', 'f01'));
|
|
19
19
|
}
|
|
20
20
|
var _d = options.gapColor, gapColor = _d === void 0 ? 'neutral.b01' : _d;
|
|
21
|
-
return styled_components_1.css(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "], ["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "])), newPalette_1.getParsePaletteColor(gapColor), newPalette_1.palette2('interactive', '
|
|
21
|
+
return styled_components_1.css(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "], ["\n box-shadow: 0 0 0 2px ", ",\n 0 0 0 4px ", ";\n "])), newPalette_1.getParsePaletteColor(gapColor), newPalette_1.palette2('interactive', 'f01'));
|
|
22
22
|
};
|
|
23
23
|
var templateObject_1, templateObject_2;
|