@24i/bigscreen-sdk 1.1.0 → 2.1.1-alpha.2133
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/README.md +1 -1
- package/package.json +34 -53
- package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
- package/packages/async-image/src/AsyncImage.tsx +10 -15
- package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
- package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +0 -11
- package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
- package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +0 -15
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +1 -2
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +3 -34
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +0 -4
- package/packages/developer-tools/src/TechnicalInfo/translations.ts +0 -4
- package/packages/device/src/getKeyDigit.ts +2 -2
- package/packages/device/src/resolver/resolver.ts +5 -18
- package/packages/digital-clock/src/DigitalClock.tsx +4 -15
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +9 -54
- package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +5 -29
- package/packages/driver-androidtv/src/keymap.ts +0 -18
- package/packages/driver-androidtv/src/types.ts +16 -102
- package/packages/driver-base/src/DeviceBase.ts +2 -61
- package/packages/driver-base/src/KeyMap/Key.ts +1 -8
- package/packages/driver-base/src/KeyMap/KeyMap.ts +0 -4
- package/packages/driver-base/src/KeyMap/interface.ts +0 -1
- package/packages/driver-base/src/KeyMap/overrideValues.ts +1 -2
- package/packages/driver-base/src/__mocks__/keyMap.ts +0 -1
- package/packages/driver-base/src/types/DeviceEvent.ts +0 -2
- package/packages/driver-base/src/types/KeycodeKeyMap.ts +0 -1
- package/packages/driver-browser/src/keymap.ts +0 -8
- package/packages/driver-entone/src/keymap.ts +0 -1
- package/packages/driver-tizen/src/TizenKeys.ts +0 -2
- package/packages/driver-vidaa/src/DeviceVidaa.ts +2 -3
- package/packages/driver-vidaa/src/__mocks__/vidaa.ts +1 -1
- package/packages/driver-vidaa/src/keymap.ts +0 -2
- package/packages/driver-webos/src/DeviceWebos.ts +0 -8
- package/packages/driver-webos/src/keymap.ts +1 -2
- package/packages/driver-xbox/src/keymap.ts +1 -1
- package/packages/epg/README.md +1 -3
- package/packages/epg/src/v2/Cell.tsx +2 -16
- package/packages/epg/src/v2/DataManager.ts +41 -112
- package/packages/epg/src/v2/DatePicker.tsx +3 -9
- package/packages/epg/src/v2/DateToast/DateToast.tsx +9 -12
- package/packages/epg/src/v2/Day.tsx +3 -6
- package/packages/epg/src/v2/Epg.tsx +5 -5
- package/packages/epg/src/v2/MockGenerator/generator.ts +2 -3
- package/packages/epg/src/v2/ProgramInfo/utils.ts +3 -4
- package/packages/epg/src/v2/Row.tsx +1 -3
- package/packages/epg/src/v2/TimelineSection.tsx +1 -4
- package/packages/epg/src/v2/basic/CellsManager.tsx +2 -7
- package/packages/epg/src/v2/basic/RowsManager.tsx +1 -3
- package/packages/epg/src/v2/interface.ts +0 -13
- package/packages/events-manager/src/EventsManager.ts +56 -1
- package/packages/focus/README.md +0 -33
- package/packages/focus/src/IFocusable.ts +0 -1
- package/packages/focus/src/Layout/Base.tsx +6 -41
- package/packages/focus/src/Layout/Matrix.tsx +19 -51
- package/packages/focus/src/Layout/__test__/Base.spec.ts +180 -0
- package/packages/focus/src/Layout/__test__/Horizontal.spec.ts +94 -0
- package/packages/focus/src/Layout/__test__/Matrix.spec.ts +261 -0
- package/packages/focus/src/Layout/__test__/Vertical.spec.ts +46 -0
- package/packages/focus/src/Layout/__test__/isRtl.spec.ts +23 -0
- package/packages/focus/src/Layout/__test__/shared.ts +19 -0
- package/packages/focus/src/focusFirstExisting.ts +1 -7
- package/packages/focus/src/index.ts +1 -2
- package/packages/gallup/src/Gallup.ts +3 -3
- package/packages/grid/src/Base/Base.tsx +10 -15
- package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +2 -4
- package/packages/icon/src/Icon.tsx +5 -27
- package/packages/input/README.md +1 -4
- package/packages/input/src/Input.tsx +29 -65
- package/packages/input/src/handleOverflow.ts +29 -0
- package/packages/interactable/README.md +1 -2
- package/packages/interactable/src/Interactable.tsx +3 -9
- package/packages/interactable/src/interface.ts +0 -1
- package/packages/jsx/src/index.ts +1 -1
- package/packages/jsx/src/test-utils/index.ts +0 -1
- package/packages/keyboard/src/Backdrop/Backdrop.scss +0 -2
- package/packages/keyboard/src/KeyboardBase.tsx +4 -16
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +0 -4
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +20 -28
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +0 -11
- package/packages/keyboard/src/WhitelabelKeyboard/types.ts +0 -1
- package/packages/l10n/README.md +0 -18
- package/packages/l10n/src/date/common.ts +6 -18
- package/packages/l10n/src/date/cs.ts +8 -2
- package/packages/l10n/src/date/en-001.ts +3 -3
- package/packages/l10n/src/date/en-common.ts +4 -5
- package/packages/l10n/src/date/en-us.ts +3 -3
- package/packages/l10n/src/date/iso.ts +13 -12
- package/packages/l10n/src/date/types.ts +0 -9
- package/packages/l10n/src/l10n.ts +3 -61
- package/packages/list/src/Base/Base.tsx +9 -19
- package/packages/list/src/Base/interface.ts +2 -2
- package/packages/list/src/CenteredList/controller.ts +1 -0
- package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +3 -3
- package/packages/list/src/UnifiedListController/UnifiedListController.ts +2 -6
- package/packages/logger/src/loggers/SentryLogger/Sentry.ts +0 -1
- package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +2 -2
- package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +3 -31
- package/packages/menu/src/MenuAndContentContainer/interface.ts +0 -8
- package/packages/modal-service/README.md +1 -4
- package/packages/modal-service/src/ModalService.tsx +5 -29
- package/packages/perf-utils/README.md +120 -1
- package/packages/perf-utils/src/array/filter.ts +54 -1
- package/packages/perf-utils/src/array/find.ts +43 -1
- package/packages/perf-utils/src/array/findIndex.ts +43 -1
- package/packages/perf-utils/src/array/forEach.ts +48 -1
- package/packages/perf-utils/src/array/includes.ts +41 -1
- package/packages/perf-utils/src/array/includesNaN.ts +32 -1
- package/packages/perf-utils/src/array/index.ts +7 -1
- package/packages/perf-utils/src/array/map.ts +52 -1
- package/packages/player-ui/README.md +1 -1
- package/packages/player-ui/src/CurrentTime.tsx +2 -2
- package/packages/player-ui/src/Duration.tsx +2 -2
- package/packages/player-ui/src/PauseButton.tsx +0 -8
- package/packages/player-ui/src/PlayerInteractable.tsx +0 -1
- package/packages/player-ui/src/PlayerTime.tsx +1 -3
- package/packages/player-ui/src/PlayerUI.tsx +35 -68
- package/packages/player-ui/src/RemainingTime.tsx +2 -2
- package/packages/player-ui/src/Seekbar.tsx +18 -110
- package/packages/player-ui/src/Seeking.ts +16 -57
- package/packages/player-ui/src/Subtitles.tsx +2 -2
- package/packages/player-ui/src/index.ts +0 -1
- package/packages/player-ui/src/mocks.ts +8 -32
- package/packages/player-ui/src/timeUtils.ts +3 -3
- package/packages/player-ui/src/types.ts +3 -9
- package/packages/router/src/Route.tsx +27 -61
- package/packages/router/src/Router.tsx +13 -59
- package/packages/router/src/history.ts +1 -8
- package/packages/router/src/index.ts +1 -1
- package/packages/router/src/utils.ts +4 -9
- package/packages/sass-utils/src/linear-gradient.scss +4 -9
- package/packages/sass-utils/src/scale.1080.scss +1 -3
- package/packages/sass-utils/src/scale.720.scss +1 -1
- package/packages/time/README.md +1 -4
- package/packages/time/src/Time.ts +13 -35
- package/packages/time/src/constants.ts +0 -1
- package/packages/toast/src/ToastService.tsx +5 -16
- package/packages/types-bigscreen-jsx/README.md +4 -5
- package/packages/types-bigscreen-jsx/index.d.ts +67 -72
- package/packages/utils/README.md +0 -27
- package/packages/utils/src/elementUtils.ts +0 -25
- package/packages/utils/src/index.ts +0 -8
- package/packages/utils/src/scaledImage.ts +3 -6
- package/packages/utils/src/textUtils.ts +14 -46
- package/packages/utils/src/wait.ts +1 -3
- package/packages/utils/src/xhr/xhrSend.ts +1 -3
- package/packages/utils/src/xhr/xhrSendRetry.ts +1 -3
- package/packages/zapping/src/ChannelZapping.ts +0 -9
- package/packages/zapping/src/Zapping.tsx +0 -10
- package/.vscode/settings.json +0 -6
- package/packages/analytics/README.md +0 -8
- package/packages/analytics/src/A.ts +0 -1
- package/packages/analytics/src/Analytics.ts +0 -1
- package/packages/analytics/src/analyticsOnScroll.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +0 -1
- package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +0 -200
- package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +0 -118
- package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +0 -17
- package/packages/analytics/src/clients/GoogleAnalytics/index.ts +0 -2
- package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +0 -77
- package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +0 -50
- package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +0 -14
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +0 -169
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +0 -102
- package/packages/analytics/src/clients/TealiumAnalytics/findIdForLanguage.ts +0 -9
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +0 -4
- package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +0 -33
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +0 -70
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +0 -36
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +0 -13
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +0 -156
- package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +0 -116
- package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +0 -99
- package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/index.ts +0 -2
- package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +0 -31
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdLoaded.ts +0 -13
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdSkipped.ts +0 -16
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +0 -21
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +0 -18
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +0 -17
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +0 -21
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +0 -32
- package/packages/analytics/src/clients/TwentyFourIQ/types.ts +0 -115
- package/packages/analytics/src/constants.ts +0 -1
- package/packages/analytics/src/index.ts +0 -3
- package/packages/analytics/src/interface.ts +0 -1
- package/packages/analytics/src/utils/generateSessionId.ts +0 -8
- package/packages/create-package/dist/createPackage.js +0 -66
- package/packages/create-package/dist/createPackage.js.map +0 -1
- package/packages/create-package/dist/index.js +0 -5
- package/packages/create-package/dist/index.js.map +0 -1
- package/packages/create-package/dist/questionnaire/questions.js +0 -35
- package/packages/create-package/dist/questionnaire/questions.js.map +0 -1
- package/packages/create-package/dist/settings/Settings.js +0 -10
- package/packages/create-package/dist/settings/Settings.js.map +0 -1
- package/packages/create-package/dist/types.js +0 -3
- package/packages/create-package/dist/types.js.map +0 -1
- package/packages/device/src/driver/index.firetv.ts +0 -1
- package/packages/device/src/driver/index.smartcast.tv.ts +0 -1
- package/packages/driver-firetv/src/DeviceFireTV.ts +0 -18
- package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +0 -36
- package/packages/driver-firetv/src/index.ts +0 -1
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +0 -317
- package/packages/driver-smartcast/src/__mocks__/api.ts +0 -49
- package/packages/driver-smartcast/src/index.ts +0 -1
- package/packages/driver-smartcast/src/keymap.ts +0 -9
- package/packages/driver-smartcast/src/types.ts +0 -65
- package/packages/focus/src/hasFocus.ts +0 -36
- package/packages/input/src/utils.ts +0 -71
- package/packages/jsx/src/test-utils/keyup.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/arabic.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/burmese.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/dari.ts +0 -28
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/pashto.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/persian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/ukrainian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +0 -26
- package/packages/l10n/src/date/de.ts +0 -97
- package/packages/l10n/src/date/es.ts +0 -71
- package/packages/l10n/src/date/fr.ts +0 -94
- package/packages/l10n/src/date/he.ts +0 -101
- package/packages/time/src/adapters/24iMediaTimeApi.ts +0 -47
- package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +0 -43
- package/packages/time/src/services/24iMediaTimeApi/index.ts +0 -6
- package/packages/utils/src/forceReflow.ts +0 -14
- package/packages/utils/src/keyPress/index.ts +0 -6
- package/packages/utils/src/keyPress/keyPressSimulator.ts +0 -74
- package/packages/utils/src/keyPress/simulateKeyPress.ts +0 -25
- package/utils/release/release.ts +0 -154
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRef, Component, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
1
|
+
import { createRef, Component, setText, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
2
|
import { Interactable } from '@24i/bigscreen-sdk/interactable';
|
|
3
3
|
import { IFocusable } from '@24i/bigscreen-sdk/focus';
|
|
4
4
|
import { isRtl } from '@24i/bigscreen-sdk/i18n';
|
|
@@ -9,7 +9,7 @@ import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
|
|
|
9
9
|
import { addClass } from '@24i/bigscreen-sdk/utils/addClass';
|
|
10
10
|
import { removeClass } from '@24i/bigscreen-sdk/utils/removeClass';
|
|
11
11
|
import { offsetPosition } from '@24i/bigscreen-sdk/utils/offsetPosition';
|
|
12
|
-
import {
|
|
12
|
+
import { handleOverflow } from './handleOverflow';
|
|
13
13
|
import './Input.scss';
|
|
14
14
|
|
|
15
15
|
type Props = {
|
|
@@ -19,11 +19,13 @@ type Props = {
|
|
|
19
19
|
passwordChar?: string,
|
|
20
20
|
/** Moves text to the left (with negative margin-left) when caret overflows */
|
|
21
21
|
shouldHandleOverflow?: boolean,
|
|
22
|
+
onChange?: (newValue: string) => void,
|
|
23
|
+
onFocus?: () => void,
|
|
24
|
+
onBlur?: () => void,
|
|
25
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
22
26
|
maxLength?: number,
|
|
23
|
-
|
|
24
|
-
onBlur?: (event: FocusEvent) => void,
|
|
27
|
+
// eslint-disable-next-line react/require-default-props
|
|
25
28
|
onFinish?: (wasCancelled?: boolean) => void,
|
|
26
|
-
onChange?: (newValue: string) => void,
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
const ACTIVE = 'active';
|
|
@@ -42,8 +44,6 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
42
44
|
|
|
43
45
|
caret = createRef<HTMLDivElement>();
|
|
44
46
|
|
|
45
|
-
caretPosition = 0;
|
|
46
|
-
|
|
47
47
|
isInputting = false;
|
|
48
48
|
|
|
49
49
|
lastValue: string;
|
|
@@ -70,11 +70,6 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
70
70
|
this.isPlaceholderVisible = value.length === 0;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
componentDidMount() {
|
|
74
|
-
const { value } = this.props;
|
|
75
|
-
if (value) this.setText(value);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
73
|
getType() {
|
|
79
74
|
return this.nativeInput.current?.type;
|
|
80
75
|
}
|
|
@@ -92,10 +87,13 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
92
87
|
|
|
93
88
|
onCaretPositionChange = (position: number | null) => {
|
|
94
89
|
if (position === null) return;
|
|
90
|
+
const { shouldHandleOverflow } = this.props;
|
|
95
91
|
const value = this.getValue();
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
|
|
92
|
+
setText(this.text, this.filterText(value));
|
|
93
|
+
this.setCaretPosition(position);
|
|
94
|
+
if (shouldHandleOverflow) {
|
|
95
|
+
handleOverflow(this.wrap.current, this.caret.current, this.text.current);
|
|
96
|
+
}
|
|
99
97
|
if (this.lastValue !== value) {
|
|
100
98
|
const { onChange } = this.props;
|
|
101
99
|
this.lastValue = value;
|
|
@@ -110,59 +108,31 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
110
108
|
|
|
111
109
|
setValue(value: string) {
|
|
112
110
|
this.nativeInput.current!.value = value;
|
|
113
|
-
this.setText(value);
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
setType(type: Props['type']) {
|
|
117
114
|
if (this.getType() === type) return;
|
|
118
115
|
const value = this.getValue();
|
|
119
116
|
this.nativeInput.current!.type = type;
|
|
120
|
-
this.
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
setText(text: string): void {
|
|
124
|
-
const filtered = this.filterText(text);
|
|
125
|
-
this.renderText(filtered);
|
|
117
|
+
setText(this.text, this.filterText(value));
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
|
|
120
|
+
setCaretPosition(position: number) {
|
|
129
121
|
const textNode = this.text.current!.firstChild;
|
|
130
|
-
if (!textNode
|
|
131
|
-
this.caretPosition = 0;
|
|
122
|
+
if (!textNode) {
|
|
132
123
|
offsetPosition(this.caret, { x: 0 });
|
|
133
124
|
return;
|
|
134
125
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (isRtl()) {
|
|
146
|
-
if (isCharMishmash) {
|
|
147
|
-
this.caretPosition = charDimensions.right - wholeTextDimensions.right;
|
|
148
|
-
} else {
|
|
149
|
-
this.caretPosition = charDimensions.left - wholeTextDimensions.right;
|
|
150
|
-
}
|
|
151
|
-
} else if (isCharMishmash) {
|
|
152
|
-
this.caretPosition = charDimensions.left - wholeTextDimensions.left;
|
|
153
|
-
} else {
|
|
154
|
-
this.caretPosition = charDimensions.right - wholeTextDimensions.left;
|
|
155
|
-
}
|
|
156
|
-
offsetPosition(this.caret, { x: this.caretPosition }, false);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
updateTextOverflow() {
|
|
160
|
-
const { shouldHandleOverflow } = this.props;
|
|
161
|
-
if (!shouldHandleOverflow) return;
|
|
162
|
-
const textMargin = handleOverflow(
|
|
163
|
-
this.wrap.current, this.caret.current, this.text.current,
|
|
164
|
-
);
|
|
165
|
-
offsetPosition(this.caret, { x: this.caretPosition - textMargin }, false);
|
|
126
|
+
const range = new Range();
|
|
127
|
+
range.selectNode(textNode);
|
|
128
|
+
const wholeText = range.getBoundingClientRect();
|
|
129
|
+
range.setStart(textNode, position);
|
|
130
|
+
range.setEnd(textNode, position);
|
|
131
|
+
const caretText = range.getBoundingClientRect();
|
|
132
|
+
const offset = isRtl()
|
|
133
|
+
? wholeText.left - caretText.left
|
|
134
|
+
: wholeText.left + wholeText.width - caretText.left;
|
|
135
|
+
offsetPosition(this.caret, { x: -offset }, false);
|
|
166
136
|
}
|
|
167
137
|
|
|
168
138
|
/**
|
|
@@ -226,14 +196,6 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
226
196
|
return text.replace(/ /g, NBSP);
|
|
227
197
|
}
|
|
228
198
|
|
|
229
|
-
renderText(text: string): void {
|
|
230
|
-
const chars: JSX.Element[] = [];
|
|
231
|
-
for (let i = 0; i < text.length; i++) {
|
|
232
|
-
chars.push(<span className="char">{text[i]}</span>);
|
|
233
|
-
}
|
|
234
|
-
this.clearMount(chars, this.text);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
199
|
render() {
|
|
238
200
|
const { value, type, placeholder, onFocus, onBlur } = this.props;
|
|
239
201
|
return (
|
|
@@ -258,7 +220,9 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
258
220
|
>
|
|
259
221
|
{placeholder}
|
|
260
222
|
</div>
|
|
261
|
-
<div ref={this.text} className="text"
|
|
223
|
+
<div ref={this.text} className="text" dir="auto">
|
|
224
|
+
{this.filterText(value)}
|
|
225
|
+
</div>
|
|
262
226
|
<div ref={this.caret} className="caret" />
|
|
263
227
|
</div>
|
|
264
228
|
</Interactable>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isRtl } from '@24i/bigscreen-sdk/i18n';
|
|
2
|
+
|
|
3
|
+
export const handleOverflow = (
|
|
4
|
+
wrap: HTMLDivElement | null,
|
|
5
|
+
caret: HTMLDivElement | null,
|
|
6
|
+
text: HTMLDivElement | null,
|
|
7
|
+
) => {
|
|
8
|
+
if (!wrap || !caret || !text) return;
|
|
9
|
+
const { width: wrapWidth, left: wrapLeft } = wrap.getBoundingClientRect();
|
|
10
|
+
const { width: caretWidth, left: caretLeft } = caret.getBoundingClientRect();
|
|
11
|
+
const textMargin = parseInt(text.dataset.margin!, 10) || 0;
|
|
12
|
+
const caretOffset = isRtl()
|
|
13
|
+
? caretLeft + textMargin - caretWidth
|
|
14
|
+
: caretLeft - textMargin + caretWidth;
|
|
15
|
+
if (!isRtl() && wrapWidth + wrapLeft < caretOffset) {
|
|
16
|
+
const margin = -(caretOffset - wrapWidth - wrapLeft);
|
|
17
|
+
text.style.marginLeft = `${margin}px`;
|
|
18
|
+
text.style.marginRight = '0px';
|
|
19
|
+
text.dataset.margin = margin.toString();
|
|
20
|
+
} else if (isRtl() && caretOffset < wrapLeft) {
|
|
21
|
+
const margin = -(wrapLeft - caretOffset);
|
|
22
|
+
text.style.marginLeft = '0px';
|
|
23
|
+
text.style.marginRight = `${margin}px`;
|
|
24
|
+
text.dataset.margin = margin.toString();
|
|
25
|
+
} else {
|
|
26
|
+
text.style.marginLeft = '0px';
|
|
27
|
+
text.style.marginRight = '0px';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -12,7 +12,6 @@ It provides common functionality for you.
|
|
|
12
12
|
## Props
|
|
13
13
|
- `onPress` - called for onClick and onKeyDown
|
|
14
14
|
- `ref` is forwarded to underlying `div`
|
|
15
|
-
- `blockRepeatedKeyDown` - interactable must suppress repeated onPress calls, until the key is released. This is because because keyDown event is repeatedly fired when user holds key on webTv and Adrodid Tv. This may lead to unpredictable behavior.
|
|
16
15
|
- other `div` props
|
|
17
16
|
|
|
18
17
|
## Provided functionality
|
|
@@ -35,4 +34,4 @@ renders
|
|
|
35
34
|
<div class="btn btn-primary" tabindex="0">
|
|
36
35
|
Play video
|
|
37
36
|
</div>
|
|
38
|
-
```
|
|
37
|
+
```
|
|
@@ -3,20 +3,14 @@ import { isClickOrEnter } from '@24i/bigscreen-sdk/device';
|
|
|
3
3
|
import { Props } from './interface';
|
|
4
4
|
|
|
5
5
|
export const Interactable = forwardRef<Props>(
|
|
6
|
-
({ children, onPress,
|
|
7
|
-
ref: Reference<HTMLDivElement> | null) => {
|
|
6
|
+
({ children, onPress, ...otherProps }, ref: Reference<HTMLDivElement> | null) => {
|
|
8
7
|
const domRef = ref || createRef<HTMLDivElement>();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (typeof onPress === 'function' && isClickOrEnter(e)) {
|
|
12
|
-
onPress(e);
|
|
13
|
-
}
|
|
8
|
+
const onPressProxy = (e: KeyboardEvent | MouseEvent) => {
|
|
9
|
+
if (typeof onPress === 'function' && isClickOrEnter(e)) onPress(e);
|
|
14
10
|
};
|
|
15
|
-
|
|
16
11
|
const onMouseEnter = () => {
|
|
17
12
|
domRef.current!.focus({ preventScroll: true });
|
|
18
13
|
};
|
|
19
|
-
|
|
20
14
|
return (
|
|
21
15
|
<div
|
|
22
16
|
{...otherProps}
|
|
@@ -27,5 +27,5 @@ export type {
|
|
|
27
27
|
ClassComponentInterface,
|
|
28
28
|
DeclareProps,
|
|
29
29
|
} from './types';
|
|
30
|
-
// eslint-disable-next-line import/no-default-export
|
|
30
|
+
// eslint-disable-next-line import/no-default-export
|
|
31
31
|
export { createElement as default } from './virtualDOM';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
.keyboard-backdrop {
|
|
2
2
|
position: fixed;
|
|
3
3
|
left: 0;
|
|
4
|
-
right: 0;
|
|
5
4
|
top: 0;
|
|
6
5
|
width: $backdrop-width;
|
|
7
6
|
height: $backdrop-height;
|
|
@@ -10,7 +9,6 @@
|
|
|
10
9
|
.keyboard-backdrop-disabled {
|
|
11
10
|
position: absolute;
|
|
12
11
|
left: 0;
|
|
13
|
-
right: 0;
|
|
14
12
|
top: 0;
|
|
15
13
|
width: 100%;
|
|
16
14
|
height: 100%;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Component, createRef, Reference } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { getKeyDigit
|
|
3
|
-
import { isRtl } from '@24i/bigscreen-sdk/i18n';
|
|
2
|
+
import { getKeyDigit } from '@24i/bigscreen-sdk/device';
|
|
4
3
|
import { EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
5
4
|
import {
|
|
6
5
|
Matrix,
|
|
@@ -121,15 +120,8 @@ export abstract class KeyboardBase<
|
|
|
121
120
|
*/
|
|
122
121
|
onKeyDown(event: KeyboardEvent) {
|
|
123
122
|
const { handleRemoteDigits, handleHWKeyboard } = this.props;
|
|
124
|
-
const preventBack = 'backAsBackspaceInSearch' in device && !!device.backAsBackspaceInSearch;
|
|
125
|
-
const inputLength = this.inputElement?.value?.length;
|
|
126
|
-
|
|
127
123
|
if (BACK.is(event)) {
|
|
128
|
-
|
|
129
|
-
this.onBackspace();
|
|
130
|
-
} else {
|
|
131
|
-
this.onCancel();
|
|
132
|
-
}
|
|
124
|
+
this.onCancel();
|
|
133
125
|
} else {
|
|
134
126
|
let char: string | null = null;
|
|
135
127
|
if (handleHWKeyboard) {
|
|
@@ -216,9 +208,7 @@ export abstract class KeyboardBase<
|
|
|
216
208
|
* Moves caret 1 position to the left.
|
|
217
209
|
*/
|
|
218
210
|
onLeft() {
|
|
219
|
-
const newPosition =
|
|
220
|
-
? caretLeft(this.inputElement)
|
|
221
|
-
: caretRight(this.inputElement);
|
|
211
|
+
const newPosition = caretLeft(this.inputElement);
|
|
222
212
|
if (typeof newPosition === 'number') {
|
|
223
213
|
this.updateCaretPosition(newPosition);
|
|
224
214
|
}
|
|
@@ -228,9 +218,7 @@ export abstract class KeyboardBase<
|
|
|
228
218
|
* Moves caret 1 position to the right.
|
|
229
219
|
*/
|
|
230
220
|
onRight() {
|
|
231
|
-
const newPosition =
|
|
232
|
-
? caretRight(this.inputElement)
|
|
233
|
-
: caretLeft(this.inputElement);
|
|
221
|
+
const newPosition = caretRight(this.inputElement);
|
|
234
222
|
if (typeof newPosition === 'number') {
|
|
235
223
|
this.updateCaretPosition(newPosition);
|
|
236
224
|
}
|
|
@@ -56,19 +56,14 @@ export class Keyboard extends KeyboardBase<Layouts, Props> {
|
|
|
56
56
|
createLanguageFocusMatrix() {
|
|
57
57
|
const { languageLayout } = this.props;
|
|
58
58
|
this.languageFocusMatrix = generateFocusMatrixFromStringMatrix(
|
|
59
|
-
this.keyRefs, languageLayout!.makeFocusStrings(languageLayout!.layout, true)
|
|
59
|
+
this.keyRefs, languageLayout!.makeFocusStrings(languageLayout!.layout, true)
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
show() {
|
|
64
64
|
super.show();
|
|
65
65
|
this.renderedLayout = 'normal';
|
|
66
|
-
|
|
67
|
-
if (this.isLanguageLayoutActive) {
|
|
68
|
-
this.renderLayout(this.languageFocusMatrix, languageLayout!.layout);
|
|
69
|
-
} else {
|
|
70
|
-
this.renderLayout(this.focusMatrices.normal, layouts.normal);
|
|
71
|
-
}
|
|
66
|
+
this.renderLayout(this.focusMatrices.normal, this.props.layouts.normal);
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
hide() {
|
|
@@ -208,7 +203,6 @@ export class Keyboard extends KeyboardBase<Layouts, Props> {
|
|
|
208
203
|
|
|
209
204
|
renderKeyboard(layout: JSX.Element[]) {
|
|
210
205
|
const { texts, shouldHideOnBackdropClick, languageLayout } = this.props;
|
|
211
|
-
const layoutClassName = languageLayout?.className || '';
|
|
212
206
|
const isSpecialLayout = this.renderedLayout === 'special';
|
|
213
207
|
const isNormalLayout = this.renderedLayout === 'normal';
|
|
214
208
|
return (
|
|
@@ -217,7 +211,7 @@ export class Keyboard extends KeyboardBase<Layouts, Props> {
|
|
|
217
211
|
onClick={() => this.onCancel()}
|
|
218
212
|
enableOnClick={shouldHideOnBackdropClick}
|
|
219
213
|
/>
|
|
220
|
-
<div className=
|
|
214
|
+
<div className="keyboard-wrapper">
|
|
221
215
|
<div className="keys-container side-bar layout-selector">
|
|
222
216
|
<div className="key-row first-row">
|
|
223
217
|
<div className="key key-wide key-empty"> </div>
|
|
@@ -258,25 +252,23 @@ export class Keyboard extends KeyboardBase<Layouts, Props> {
|
|
|
258
252
|
<div className="key-row">
|
|
259
253
|
<div className="key key-wide key-empty"> </div>
|
|
260
254
|
</div>
|
|
261
|
-
{languageLayout
|
|
262
|
-
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
>
|
|
269
|
-
<div className="key-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
</div>
|
|
279
|
-
)}
|
|
255
|
+
{!!languageLayout ?
|
|
256
|
+
<div className="key-row rounded-border-container">
|
|
257
|
+
<Interactable
|
|
258
|
+
ref={this.keyRefs.language}
|
|
259
|
+
className="key key-wide key-with-icon key-language"
|
|
260
|
+
onPress={() => this.onLanguage()}
|
|
261
|
+
>
|
|
262
|
+
<div className="key-background">
|
|
263
|
+
<div className="key-mask-icon" />
|
|
264
|
+
</div>
|
|
265
|
+
</Interactable>
|
|
266
|
+
</div>
|
|
267
|
+
:
|
|
268
|
+
<div className="key-row">
|
|
269
|
+
<div className="key key-wide key-empty"> </div>
|
|
270
|
+
</div>
|
|
271
|
+
}
|
|
280
272
|
</div>
|
|
281
273
|
<div className="keys-container key-layout">
|
|
282
274
|
{layout}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
export { arabic } from './arabic';
|
|
2
|
-
export { burmese } from './burmese';
|
|
3
|
-
export { dari } from './dari';
|
|
4
1
|
export { hebrew } from './hebrew';
|
|
5
|
-
export { korean } from './korean';
|
|
6
2
|
export { latin } from './latin';
|
|
7
|
-
export { pashto } from './pashto';
|
|
8
|
-
export { persian } from './persian';
|
|
9
|
-
export { russian } from './russian';
|
|
10
3
|
export { special } from './special';
|
|
11
|
-
export { tibetan } from './tibetan';
|
|
12
|
-
export { turkish } from './turkish';
|
|
13
|
-
export { ukrainian } from './ukrainian';
|
|
14
|
-
export { urdu } from './urdu';
|
package/packages/l10n/README.md
CHANGED
|
@@ -76,24 +76,6 @@ type DateTimeFormatOptions = {
|
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
#### date-fns DateTime format
|
|
80
|
-
It is also possible to use formatting provided by [date-fns](https://date-fns.org/v2.30.0/docs/format) library. First you need to globally configure the formats used (usually from backstage):
|
|
81
|
-
```ts
|
|
82
|
-
l10n.init({
|
|
83
|
-
dateFormatLong?: string | null, // e.g. 'eee, dd MMM' for "Wed, 09 Jul"
|
|
84
|
-
dateFormatNumeric?: string | null, // e.g. 'EEEE, MMMM d' for "Wednesday, July 9"
|
|
85
|
-
dateFormatShort?: string | null, // e.g. 'MM/dd/yyyy' for "07/09/2023"
|
|
86
|
-
timeFormat?: string | null, // e.g. 'h:mm a' for "9:05 PM"
|
|
87
|
-
});
|
|
88
|
-
```
|
|
89
|
-
After that, `timeFormat` and `dateFormatShort` are used automatically where appropriate, in case the format string is _falsy_ the [default formatting implementation](#datetime-format) will be used. You can also specify which format you want to use in `DateTimeFormatOptions`:
|
|
90
|
-
```ts
|
|
91
|
-
type DateTimeFormatOptions = {
|
|
92
|
-
...
|
|
93
|
-
formatType: 'dateFormatLong' | 'dateFormatNumeric' | 'dateFormatShort' | 'timeFormat',
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
79
|
You can use both `timestamp` in `ms` or `Date` object directly for formatting.
|
|
98
80
|
|
|
99
81
|
#### Examples
|
|
@@ -7,7 +7,7 @@ const NOON = 12;
|
|
|
7
7
|
|
|
8
8
|
export const SECOND_FROM_END = 2;
|
|
9
9
|
|
|
10
|
-
export const h24 = (date: Date) => date.
|
|
10
|
+
export const h24 = (date: Date) => date.getHours().toString();
|
|
11
11
|
|
|
12
12
|
export const hh24 = (date: Date) => {
|
|
13
13
|
const h = h24(date);
|
|
@@ -15,7 +15,7 @@ export const hh24 = (date: Date) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const h12 = (date: Date) => {
|
|
18
|
-
const h = date.
|
|
18
|
+
const h = date.getHours() % NOON;
|
|
19
19
|
return h === 0 ? '12' : h.toString();
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -24,14 +24,14 @@ export const hh12 = (date: Date) => {
|
|
|
24
24
|
return h.length === 1 ? `0${h}` : h;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export const m = (date: Date) => date.
|
|
27
|
+
export const m = (date: Date) => date.getMinutes().toString();
|
|
28
28
|
|
|
29
29
|
export const mm = (date: Date) => {
|
|
30
30
|
const min = m(date);
|
|
31
31
|
return min.length === 1 ? `0${min}` : min;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export const s = (date: Date) => date.
|
|
34
|
+
export const s = (date: Date) => date.getSeconds().toString();
|
|
35
35
|
|
|
36
36
|
export const ss = (date: Date) => {
|
|
37
37
|
const sec = s(date);
|
|
@@ -39,7 +39,7 @@ export const ss = (date: Date) => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export const amOrPm = (date: Date) => (
|
|
42
|
-
date.
|
|
42
|
+
date.getHours() < NOON ? 'AM' : 'PM'
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
export const h24Mm = (date: Date) => `${h24(date)}:${mm(date)}`;
|
|
@@ -107,7 +107,7 @@ export const collonSeparatedHour12MinuteSecond = (date: Date, options: DateTimeF
|
|
|
107
107
|
|
|
108
108
|
export const processYear = (dateStringParts: string[], year: Year | undefined, date: Date) => {
|
|
109
109
|
if (typeof year === 'undefined') return;
|
|
110
|
-
const fullYear = date.
|
|
110
|
+
const fullYear = date.getFullYear().toString();
|
|
111
111
|
dateStringParts.push(
|
|
112
112
|
year === '2-digit'
|
|
113
113
|
? fullYear.substring(fullYear.length - SECOND_FROM_END)
|
|
@@ -151,15 +151,3 @@ export const dateFormatter = (
|
|
|
151
151
|
)(date),
|
|
152
152
|
};
|
|
153
153
|
};
|
|
154
|
-
|
|
155
|
-
export const toTwoDigitLocaleTimeString = (date: Date) => (
|
|
156
|
-
options: DateTimeFormatOptions = {
|
|
157
|
-
hour: '2-digit', minute: '2-digit', second: '2-digit',
|
|
158
|
-
},
|
|
159
|
-
) => collonSeparatedHour24MinuteSecond(date, options);
|
|
160
|
-
|
|
161
|
-
export const toNumericLocaleTimeString = (date: Date) => (
|
|
162
|
-
options: DateTimeFormatOptions = {
|
|
163
|
-
hour: 'numeric', minute: '2-digit', second: '2-digit',
|
|
164
|
-
},
|
|
165
|
-
) => collonSeparatedHour24MinuteSecond(date, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dateFormatter, processYear
|
|
1
|
+
import { collonSeparatedHour24MinuteSecond, dateFormatter, processYear } from './common';
|
|
2
2
|
import type { DateTimeFormatOptions, Weekday, Day, Month, Year } from './types';
|
|
3
3
|
|
|
4
4
|
const WEEKDAYS = {
|
|
@@ -86,4 +86,10 @@ const toLocaleDateString = (date: Date) => (
|
|
|
86
86
|
return dateStringParts.join(' ');
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
const toLocaleTimeString = (date: Date) => (
|
|
90
|
+
options: DateTimeFormatOptions = {
|
|
91
|
+
hour: 'numeric', minute: '2-digit', second: '2-digit',
|
|
92
|
+
},
|
|
93
|
+
) => collonSeparatedHour24MinuteSecond(date, options);
|
|
94
|
+
|
|
95
|
+
export const csDateFormatter = dateFormatter(toLocaleTimeString, toLocaleDateString, ' ');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collonSeparatedHour12MinuteSecond, dateFormatter, processYear, SECOND_FROM_END,
|
|
3
3
|
} from './common';
|
|
4
|
-
import {
|
|
4
|
+
import { MONTHS, processWeekday, isDdMmYyyy } from './en-common';
|
|
5
5
|
import type { DateTimeFormatOptions, Day, Month, Year } from './types';
|
|
6
6
|
|
|
7
7
|
const processMonth = (
|
|
@@ -19,7 +19,7 @@ const processMonth = (
|
|
|
19
19
|
: numericMonth
|
|
20
20
|
}${typeof year !== 'undefined' ? ',' : ''}`);
|
|
21
21
|
} else {
|
|
22
|
-
dateStringParts.push(
|
|
22
|
+
dateStringParts.push(MONTHS[month][date.getMonth()]);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -49,7 +49,7 @@ const getDdMmYyyy = (dateStringParts: string[], year: Year | undefined, date: Da
|
|
|
49
49
|
dateStringParts.push(`${d}/${m}/${y}`);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const toLocaleDateString = (date: Date) => (
|
|
52
|
+
export const toLocaleDateString = (date: Date) => (
|
|
53
53
|
{ weekday, year, month, day }: DateTimeFormatOptions = {
|
|
54
54
|
year: 'numeric', month: '2-digit', day: '2-digit',
|
|
55
55
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Day, Month, Weekday,
|
|
1
|
+
import type { Day, Month, Weekday, Year } from './types';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const MONTHS = {
|
|
4
4
|
narrow: [
|
|
5
5
|
'J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D',
|
|
6
6
|
],
|
|
@@ -13,7 +13,7 @@ export const EN_MONTHS = {
|
|
|
13
13
|
],
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const WEEKDAYS = {
|
|
17
17
|
narrow: [
|
|
18
18
|
'S', 'M', 'T', 'W', 'T', 'F', 'S',
|
|
19
19
|
],
|
|
@@ -32,10 +32,9 @@ export const processWeekday = (
|
|
|
32
32
|
day: Day | undefined,
|
|
33
33
|
weekday: Weekday | undefined,
|
|
34
34
|
date: Date,
|
|
35
|
-
weekdaysLocaleData: LocaleData = EN_WEEKDAYS,
|
|
36
35
|
) => {
|
|
37
36
|
if (typeof weekday === 'undefined') return;
|
|
38
|
-
let weekdayString =
|
|
37
|
+
let weekdayString = WEEKDAYS[weekday][date.getDay()];
|
|
39
38
|
if (
|
|
40
39
|
typeof year !== 'undefined'
|
|
41
40
|
|| typeof month !== 'undefined'
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
processYear,
|
|
5
5
|
SECOND_FROM_END,
|
|
6
6
|
} from './common';
|
|
7
|
-
import {
|
|
7
|
+
import { MONTHS, processWeekday, isDdMmYyyy } from './en-common';
|
|
8
8
|
import type { DateTimeFormatOptions, Day, Month, Year } from './types';
|
|
9
9
|
|
|
10
10
|
const processMonth = (dateStringParts: string[], month: Month | undefined, date: Date) => {
|
|
@@ -16,7 +16,7 @@ const processMonth = (dateStringParts: string[], month: Month | undefined, date:
|
|
|
16
16
|
? `0${numericMonth}` : numericMonth,
|
|
17
17
|
);
|
|
18
18
|
} else {
|
|
19
|
-
dateStringParts.push(
|
|
19
|
+
dateStringParts.push(MONTHS[month][date.getMonth()]);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -56,7 +56,7 @@ const getDdMmYyyy = (
|
|
|
56
56
|
dateStringParts.push(`${m}/${d}/${y}`);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
const toLocaleDateString = (date: Date) => (
|
|
59
|
+
export const toLocaleDateString = (date: Date) => (
|
|
60
60
|
{ weekday, year, month, day }: DateTimeFormatOptions = {
|
|
61
61
|
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
62
62
|
},
|