@nectary/components 0.39.0 → 0.41.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/accordion/index.js +47 -84
- package/accordion-item/index.js +30 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +177 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +52 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +46 -92
- package/button/types.d.ts +1 -1
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +59 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +140 -0
- package/chip/types.d.ts +37 -0
- package/color-menu/index.d.ts +14 -0
- package/color-menu/index.js +450 -0
- package/color-menu/types.d.ts +36 -0
- package/color-menu/utils.d.ts +1 -0
- package/color-menu/utils.js +15 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +60 -0
- package/color-swatch/types.d.ts +11 -0
- package/colors.json +61 -49
- package/date-picker/index.js +162 -293
- package/dialog/index.js +70 -142
- package/field/index.js +44 -65
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +11 -28
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.d.ts +1 -0
- package/icon-button/index.js +51 -85
- package/icon-button/types.d.ts +16 -2
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +117 -222
- package/link/index.js +51 -97
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +113 -163
- package/pop/index.d.ts +11 -0
- package/pop/index.js +391 -0
- package/pop/types.d.ts +35 -0
- package/pop/utils.d.ts +7 -0
- package/pop/utils.js +18 -0
- package/popover/index.d.ts +1 -0
- package/popover/index.js +105 -314
- package/popover/types.d.ts +8 -1
- package/popover/utils.d.ts +5 -0
- package/popover/utils.js +17 -1
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +28 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +28 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +45 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +42 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +158 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +345 -0
- package/select-menu/types.d.ts +29 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +24 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +35 -38
- package/tag/types.d.ts +12 -7
- package/textarea/index.js +96 -167
- package/theme.css +146 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +45 -87
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +59 -107
- package/tooltip/index.d.ts +2 -0
- package/tooltip/index.js +160 -17
- package/tooltip/types.d.ts +13 -0
- package/tooltip/utils.d.ts +5 -0
- package/tooltip/utils.js +25 -1
- package/utils/animation.d.ts +17 -0
- package/utils/animation.js +142 -0
- package/utils/colors.d.ts +5 -0
- package/utils/colors.js +5 -0
- package/utils/context.d.ts +15 -0
- package/utils/context.js +57 -0
- package/{utils.d.ts → utils/index.d.ts} +15 -11
- package/{utils.js → utils/index.js} +104 -48
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-checkbox-option/index.d.ts +0 -11
- package/dropdown-checkbox-option/index.js +0 -88
- package/dropdown-checkbox-option/types.d.ts +0 -15
- package/dropdown-radio-option/index.d.ts +0 -11
- package/dropdown-radio-option/index.js +0 -88
- package/dropdown-radio-option/types.d.ts +0 -15
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-checkbox-option → chip}/types.js +0 -0
- /package/{dropdown-radio-option → color-menu}/types.js +0 -0
- /package/{dropdown-text-option → color-swatch}/types.js +0 -0
- /package/{dropdown → pop}/types.js +0 -0
- /package/{select-option → select-button}/types.js +0 -0
- /package/{tag-close → select-menu}/types.js +0 -0
- /package/{select → select-menu-option}/types.js +0 -0
package/time-picker/index.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$pickerHours, _$pickerMinutes, _$pickerTouch, _$needleHour, _$needleMinute, _$headerHours, _$headerHoursText, _$headerMinutes, _$headerMinutesText, _$ampm, _$submitButton, _hour, _minute, _getClickDegree, _onPickerClick, _render, _selectHour, _selectMinute, _onAmPmChange, _onSubmitButtonClick, _onHoursKeydown, _onMinutesKeydown, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
-
|
|
8
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
-
|
|
10
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
-
|
|
12
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
-
|
|
14
1
|
import '../icon-button';
|
|
15
2
|
import '../icons/done';
|
|
16
3
|
import '../icons/arrow-drop-up';
|
|
@@ -18,7 +5,7 @@ import '../icons/arrow-drop-down';
|
|
|
18
5
|
import '../segmented-control';
|
|
19
6
|
import '../segmented-control-option';
|
|
20
7
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
21
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-font-title-xl);line-height:48px}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-500)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;font:var(--sinch-font-text-s);line-height:28px;text-align:center;color:var(--sinch-color-text-default);top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-24{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-minute{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-hour-12:hover,.digit-hour-24:hover,.digit-minute:hover{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected,.digit-hour-24.selected,.digit-minute.selected{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected{font-size:16px}.digit-hour-24.selected{font-size:16px}.digit-minute.selected{font-size:16px}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-color-stormy-500)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-color-tropical-500)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0;--sinch-icon
|
|
8
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-font-title-xl);line-height:48px}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-500)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;font:var(--sinch-font-text-s);line-height:28px;text-align:center;color:var(--sinch-color-text-default);top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-24{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-minute{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-hour-12:hover,.digit-hour-24:hover,.digit-minute:hover{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected,.digit-hour-24.selected,.digit-minute.selected{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected{font-size:16px}.digit-hour-24.selected{font-size:16px}.digit-minute.selected{font-size:16px}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-color-stormy-500)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-color-tropical-500)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0;--sinch-size-icon:24px}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-hours::before,#header-minutes::before{content:"";display:none;position:absolute;border-radius:12px;left:50%;top:50%;width:100%;height:100%;transform:translate(-50%,-50%);padding:1px;border:1px solid var(--sinch-color-border-focus)}#header-hours-down,#header-hours-up,#header-minutes-down,#header-minutes-up{display:none;position:absolute;left:50%;transform:translateX(-50%)}#header-hours-up,#header-minutes-up{top:-18px}#header-hours-down,#header-minutes-down{bottom:-18px}#header-hours:focus #header-hours-down,#header-hours:focus #header-hours-up,#header-hours:focus::before{display:block}#header-minutes:focus #header-minutes-down,#header-minutes:focus #header-minutes-up,#header-minutes:focus::before{display:block}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-hours-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-hours-down"></sinch-icon-arrow-drop-down></div><div id="header-colon">:</div><div id="header-minutes" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-minutes-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-minutes-down"></sinch-icon-arrow-drop-down></div><sinch-icon-button id="submit" small aria-label="Submit"><sinch-icon-done slot="icon"></sinch-icon-done></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour"></div><div id="needle-minute"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
|
|
22
9
|
import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
|
|
23
10
|
const template = document.createElement('template');
|
|
24
11
|
template.innerHTML = templateHTML;
|
|
@@ -32,254 +19,38 @@ const HOUR_24_RADIUS = HOUR_12_RADIUS - HOUR_24_DIGIT_SIZE;
|
|
|
32
19
|
const NEEDLE_HOUR_12_LENGTH = HOUR_12_RADIUS;
|
|
33
20
|
const NEEDLE_HOUR_24_LENGTH = HOUR_24_RADIUS;
|
|
34
21
|
const NEEDLE_MINUTE_LENGTH = MINUTE_RADIUS;
|
|
35
|
-
defineCustomElement('sinch-time-picker',
|
|
22
|
+
defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
23
|
+
#$pickerHours;
|
|
24
|
+
#$pickerMinutes;
|
|
25
|
+
#$pickerTouch;
|
|
26
|
+
#$needleHour;
|
|
27
|
+
#$needleMinute;
|
|
28
|
+
#$headerHours;
|
|
29
|
+
#$headerHoursText;
|
|
30
|
+
#$headerMinutes;
|
|
31
|
+
#$headerMinutesText;
|
|
32
|
+
#$ampm;
|
|
33
|
+
#$submitButton;
|
|
34
|
+
#hour = 0;
|
|
35
|
+
#minute = 0;
|
|
36
|
+
|
|
36
37
|
constructor() {
|
|
37
38
|
super();
|
|
38
|
-
|
|
39
|
-
_classPrivateMethodInitSpec(this, _selectMinute);
|
|
40
|
-
|
|
41
|
-
_classPrivateMethodInitSpec(this, _selectHour);
|
|
42
|
-
|
|
43
|
-
_classPrivateMethodInitSpec(this, _render);
|
|
44
|
-
|
|
45
|
-
_classPrivateMethodInitSpec(this, _getClickDegree);
|
|
46
|
-
|
|
47
|
-
_classPrivateFieldInitSpec(this, _$pickerHours, {
|
|
48
|
-
writable: true,
|
|
49
|
-
value: void 0
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
_classPrivateFieldInitSpec(this, _$pickerMinutes, {
|
|
53
|
-
writable: true,
|
|
54
|
-
value: void 0
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
_classPrivateFieldInitSpec(this, _$pickerTouch, {
|
|
58
|
-
writable: true,
|
|
59
|
-
value: void 0
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
_classPrivateFieldInitSpec(this, _$needleHour, {
|
|
63
|
-
writable: true,
|
|
64
|
-
value: void 0
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
_classPrivateFieldInitSpec(this, _$needleMinute, {
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
_classPrivateFieldInitSpec(this, _$headerHours, {
|
|
73
|
-
writable: true,
|
|
74
|
-
value: void 0
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
_classPrivateFieldInitSpec(this, _$headerHoursText, {
|
|
78
|
-
writable: true,
|
|
79
|
-
value: void 0
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
_classPrivateFieldInitSpec(this, _$headerMinutes, {
|
|
83
|
-
writable: true,
|
|
84
|
-
value: void 0
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
_classPrivateFieldInitSpec(this, _$headerMinutesText, {
|
|
88
|
-
writable: true,
|
|
89
|
-
value: void 0
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
_classPrivateFieldInitSpec(this, _$ampm, {
|
|
93
|
-
writable: true,
|
|
94
|
-
value: void 0
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
_classPrivateFieldInitSpec(this, _$submitButton, {
|
|
98
|
-
writable: true,
|
|
99
|
-
value: void 0
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
_classPrivateFieldInitSpec(this, _hour, {
|
|
103
|
-
writable: true,
|
|
104
|
-
value: 0
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
_classPrivateFieldInitSpec(this, _minute, {
|
|
108
|
-
writable: true,
|
|
109
|
-
value: 0
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
_classPrivateFieldInitSpec(this, _onPickerClick, {
|
|
113
|
-
writable: true,
|
|
114
|
-
value: e => {
|
|
115
|
-
const [cssDeg, rowIndex] = _classPrivateMethodGet(this, _getClickDegree, _getClickDegree2).call(this, e.x, e.y);
|
|
116
|
-
|
|
117
|
-
const isHourRowClick = rowIndex > 0;
|
|
118
|
-
const isHour24RowClick = rowIndex > 1;
|
|
119
|
-
|
|
120
|
-
if (isHourRowClick) {
|
|
121
|
-
const digitIndex = Math.round(cssDeg / 30) % 12;
|
|
122
|
-
const is24 = getBooleanAttribute(this, 'ampm') === false;
|
|
123
|
-
|
|
124
|
-
if (is24) {
|
|
125
|
-
if (isHour24RowClick) {
|
|
126
|
-
_classPrivateFieldSet(this, _hour, digitIndex === 0 ? 0 : digitIndex + 12);
|
|
127
|
-
} else {
|
|
128
|
-
_classPrivateFieldSet(this, _hour, digitIndex === 0 ? 12 : digitIndex);
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
_classPrivateFieldSet(this, _hour, digitIndex + (_classPrivateFieldGet(this, _$ampm).value === 'pm' ? 12 : 0));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
_classPrivateFieldGet(this, _$headerHours).focus();
|
|
135
|
-
} else {
|
|
136
|
-
_classPrivateFieldSet(this, _minute, Math.round(cssDeg / 6) % 60);
|
|
137
|
-
|
|
138
|
-
_classPrivateFieldGet(this, _$headerMinutes).focus();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
_classPrivateFieldInitSpec(this, _onAmPmChange, {
|
|
146
|
-
writable: true,
|
|
147
|
-
value: e => {
|
|
148
|
-
e.stopPropagation();
|
|
149
|
-
const value = e.detail;
|
|
150
|
-
|
|
151
|
-
switch (value) {
|
|
152
|
-
case 'am':
|
|
153
|
-
{
|
|
154
|
-
if (_classPrivateFieldGet(this, _hour) >= 12) {
|
|
155
|
-
_classPrivateFieldSet(this, _hour, _classPrivateFieldGet(this, _hour) - 12);
|
|
156
|
-
|
|
157
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
case 'pm':
|
|
164
|
-
{
|
|
165
|
-
if (_classPrivateFieldGet(this, _hour) < 12) {
|
|
166
|
-
_classPrivateFieldSet(this, _hour, _classPrivateFieldGet(this, _hour) + 12);
|
|
167
|
-
|
|
168
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
_classPrivateFieldInitSpec(this, _onSubmitButtonClick, {
|
|
178
|
-
writable: true,
|
|
179
|
-
value: () => {
|
|
180
|
-
const value = stringifyTime(_classPrivateFieldGet(this, _hour), _classPrivateFieldGet(this, _minute));
|
|
181
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
182
|
-
bubbles: true,
|
|
183
|
-
detail: value
|
|
184
|
-
}));
|
|
185
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
186
|
-
detail: value
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
_classPrivateFieldInitSpec(this, _onHoursKeydown, {
|
|
192
|
-
writable: true,
|
|
193
|
-
value: e => {
|
|
194
|
-
switch (e.key) {
|
|
195
|
-
case 'ArrowUp':
|
|
196
|
-
{
|
|
197
|
-
e.preventDefault();
|
|
198
|
-
|
|
199
|
-
_classPrivateFieldSet(this, _hour, (_classPrivateFieldGet(this, _hour) + 1) % 24);
|
|
200
|
-
|
|
201
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
202
|
-
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
case 'ArrowDown':
|
|
207
|
-
{
|
|
208
|
-
e.preventDefault();
|
|
209
|
-
|
|
210
|
-
_classPrivateFieldSet(this, _hour, (_classPrivateFieldGet(this, _hour) + 23) % 24);
|
|
211
|
-
|
|
212
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
213
|
-
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
_classPrivateFieldInitSpec(this, _onMinutesKeydown, {
|
|
221
|
-
writable: true,
|
|
222
|
-
value: e => {
|
|
223
|
-
switch (e.key) {
|
|
224
|
-
case 'ArrowUp':
|
|
225
|
-
{
|
|
226
|
-
e.preventDefault();
|
|
227
|
-
|
|
228
|
-
_classPrivateFieldSet(this, _minute, (_classPrivateFieldGet(this, _minute) + 1) % 60);
|
|
229
|
-
|
|
230
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
231
|
-
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
case 'ArrowDown':
|
|
236
|
-
{
|
|
237
|
-
e.preventDefault();
|
|
238
|
-
|
|
239
|
-
_classPrivateFieldSet(this, _minute, (_classPrivateFieldGet(this, _minute) + 59) % 60);
|
|
240
|
-
|
|
241
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
242
|
-
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
250
|
-
writable: true,
|
|
251
|
-
value: e => {
|
|
252
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
39
|
const shadowRoot = this.attachShadow();
|
|
257
40
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
_classPrivateFieldSet(this, _$headerMinutes, shadowRoot.querySelector('#header-minutes'));
|
|
272
|
-
|
|
273
|
-
_classPrivateFieldSet(this, _$headerHoursText, shadowRoot.querySelector('#header-hours > span'));
|
|
274
|
-
|
|
275
|
-
_classPrivateFieldSet(this, _$headerMinutesText, shadowRoot.querySelector('#header-minutes > span'));
|
|
276
|
-
|
|
277
|
-
_classPrivateFieldSet(this, _$ampm, shadowRoot.querySelector('#ampm'));
|
|
278
|
-
|
|
279
|
-
_classPrivateFieldSet(this, _$submitButton, shadowRoot.querySelector('#submit'));
|
|
280
|
-
|
|
281
|
-
_classPrivateFieldGet(this, _$needleMinute).style.height = `${NEEDLE_MINUTE_LENGTH}px`;
|
|
282
|
-
_classPrivateFieldGet(this, _$needleHour).style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
41
|
+
this.#$pickerHours = shadowRoot.querySelector('#picker-hours');
|
|
42
|
+
this.#$pickerMinutes = shadowRoot.querySelector('#picker-minutes');
|
|
43
|
+
this.#$pickerTouch = shadowRoot.querySelector('#picker');
|
|
44
|
+
this.#$needleHour = shadowRoot.querySelector('#needle-hour');
|
|
45
|
+
this.#$needleMinute = shadowRoot.querySelector('#needle-minute');
|
|
46
|
+
this.#$headerHours = shadowRoot.querySelector('#header-hours');
|
|
47
|
+
this.#$headerMinutes = shadowRoot.querySelector('#header-minutes');
|
|
48
|
+
this.#$headerHoursText = shadowRoot.querySelector('#header-hours > span');
|
|
49
|
+
this.#$headerMinutesText = shadowRoot.querySelector('#header-minutes > span');
|
|
50
|
+
this.#$ampm = shadowRoot.querySelector('#ampm');
|
|
51
|
+
this.#$submitButton = shadowRoot.querySelector('#submit');
|
|
52
|
+
this.#$needleMinute.style.height = `${NEEDLE_MINUTE_LENGTH}px`;
|
|
53
|
+
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
283
54
|
const MINUTE_DIGIT_RADIUS = MINUTE_RADIUS + MINUTE_DIGIT_SIZE / 2;
|
|
284
55
|
const HOUR_12_DIGIT_RADIUS = HOUR_12_RADIUS + HOUR_12_DIGIT_SIZE / 2;
|
|
285
56
|
const HOUR_24_DIGIT_RADIUS = HOUR_24_RADIUS + HOUR_24_DIGIT_SIZE / 2;
|
|
@@ -297,8 +68,7 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
297
68
|
hours12Frag.appendChild(el);
|
|
298
69
|
}
|
|
299
70
|
|
|
300
|
-
|
|
301
|
-
|
|
71
|
+
this.#$pickerHours.appendChild(hours12Frag);
|
|
302
72
|
const hours24Frag = document.createDocumentFragment();
|
|
303
73
|
|
|
304
74
|
for (let i = 12; i < 24; i++) {
|
|
@@ -313,8 +83,7 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
313
83
|
hours24Frag.appendChild(el);
|
|
314
84
|
}
|
|
315
85
|
|
|
316
|
-
|
|
317
|
-
|
|
86
|
+
this.#$pickerHours.appendChild(hours24Frag);
|
|
318
87
|
const minutesFrag = document.createDocumentFragment();
|
|
319
88
|
|
|
320
89
|
for (let i = 0; i < 60; i += 5) {
|
|
@@ -328,35 +97,25 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
328
97
|
minutesFrag.appendChild(el);
|
|
329
98
|
}
|
|
330
99
|
|
|
331
|
-
|
|
100
|
+
this.#$pickerMinutes.appendChild(minutesFrag);
|
|
332
101
|
}
|
|
333
102
|
|
|
334
103
|
connectedCallback() {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
_classPrivateFieldGet(this, _$headerHours).addEventListener('keydown', _classPrivateFieldGet(this, _onHoursKeydown));
|
|
342
|
-
|
|
343
|
-
_classPrivateFieldGet(this, _$headerMinutes).addEventListener('keydown', _classPrivateFieldGet(this, _onMinutesKeydown));
|
|
344
|
-
|
|
345
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
104
|
+
this.#$pickerTouch.addEventListener('click', this.#onPickerClick);
|
|
105
|
+
this.#$ampm.addEventListener('change', this.#onAmPmChange);
|
|
106
|
+
this.#$submitButton.addEventListener('click', this.#onSubmitButtonClick);
|
|
107
|
+
this.#$headerHours.addEventListener('keydown', this.#onHoursKeydown);
|
|
108
|
+
this.#$headerMinutes.addEventListener('keydown', this.#onMinutesKeydown);
|
|
109
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
346
110
|
}
|
|
347
111
|
|
|
348
112
|
disconnectedCallback() {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
_classPrivateFieldGet(this, _$headerHours).removeEventListener('keydown', _classPrivateFieldGet(this, _onHoursKeydown));
|
|
356
|
-
|
|
357
|
-
_classPrivateFieldGet(this, _$headerMinutes).removeEventListener('keydown', _classPrivateFieldGet(this, _onMinutesKeydown));
|
|
358
|
-
|
|
359
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
113
|
+
this.#$pickerTouch.removeEventListener('click', this.#onPickerClick);
|
|
114
|
+
this.#$ampm.removeEventListener('change', this.#onAmPmChange);
|
|
115
|
+
this.#$submitButton.removeEventListener('click', this.#onSubmitButtonClick);
|
|
116
|
+
this.#$headerHours.removeEventListener('keydown', this.#onHoursKeydown);
|
|
117
|
+
this.#$headerMinutes.removeEventListener('keydown', this.#onMinutesKeydown);
|
|
118
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
360
119
|
}
|
|
361
120
|
|
|
362
121
|
static get observedAttributes() {
|
|
@@ -379,13 +138,9 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
379
138
|
hours,
|
|
380
139
|
minutes
|
|
381
140
|
} = parseTime(newVal);
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
_classPrivateFieldSet(this, _minute, minutes);
|
|
386
|
-
|
|
387
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
388
|
-
|
|
141
|
+
this.#hour = hours;
|
|
142
|
+
this.#minute = minutes;
|
|
143
|
+
this.#render();
|
|
389
144
|
break;
|
|
390
145
|
}
|
|
391
146
|
|
|
@@ -393,15 +148,13 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
393
148
|
{
|
|
394
149
|
const isAmpm = isAttrTrue(newVal);
|
|
395
150
|
updateBooleanAttribute(this, 'ampm', isAmpm);
|
|
396
|
-
|
|
397
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
398
|
-
|
|
151
|
+
this.#render();
|
|
399
152
|
break;
|
|
400
153
|
}
|
|
401
154
|
|
|
402
155
|
case 'submit-aria-label':
|
|
403
156
|
{
|
|
404
|
-
updateAttribute(
|
|
157
|
+
updateAttribute(this.#$submitButton, 'aria-label', newVal);
|
|
405
158
|
break;
|
|
406
159
|
}
|
|
407
160
|
}
|
|
@@ -436,7 +189,7 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
436
189
|
}
|
|
437
190
|
|
|
438
191
|
get submitButtonRect() {
|
|
439
|
-
return getRect(
|
|
192
|
+
return getRect(this.#$submitButton);
|
|
440
193
|
}
|
|
441
194
|
|
|
442
195
|
get amButtonRect() {
|
|
@@ -444,8 +197,7 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
444
197
|
return null;
|
|
445
198
|
}
|
|
446
199
|
|
|
447
|
-
const $am =
|
|
448
|
-
|
|
200
|
+
const $am = this.#$ampm.querySelector('[value="am"]');
|
|
449
201
|
return $am != null ? getRect($am) : null;
|
|
450
202
|
}
|
|
451
203
|
|
|
@@ -454,102 +206,198 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
454
206
|
return null;
|
|
455
207
|
}
|
|
456
208
|
|
|
457
|
-
const $pm =
|
|
458
|
-
|
|
209
|
+
const $pm = this.#$ampm.querySelector('[value="pm"]');
|
|
459
210
|
return $pm != null ? getRect($pm) : null;
|
|
460
211
|
}
|
|
461
212
|
|
|
462
213
|
hourDigitRect(hour) {
|
|
463
|
-
const $digit =
|
|
464
|
-
|
|
214
|
+
const $digit = this.#$pickerHours.children[hourToIndex(hour, !this.ampm)];
|
|
465
215
|
return $digit != null ? getRect($digit) : null;
|
|
466
216
|
}
|
|
467
217
|
|
|
468
218
|
minuteDigitRect(minute) {
|
|
469
|
-
const $digit =
|
|
470
|
-
|
|
219
|
+
const $digit = this.#$pickerMinutes.children[Math.round(minute / 5)];
|
|
471
220
|
return $digit != null ? getRect($digit) : null;
|
|
472
221
|
}
|
|
473
222
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
223
|
+
#getClickDegree(x, y) {
|
|
224
|
+
const touchRect = this.#$pickerTouch.getBoundingClientRect();
|
|
225
|
+
const cx = touchRect.width / 2;
|
|
226
|
+
const cy = touchRect.height / 2;
|
|
227
|
+
const px = x - touchRect.x;
|
|
228
|
+
const py = touchRect.height - y + touchRect.y;
|
|
229
|
+
const dx = px - cx;
|
|
230
|
+
const dy = py - cy;
|
|
231
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
232
|
+
const cosRad = dx / len;
|
|
233
|
+
const rad = Math.acos(cosRad * (dy < 0 ? -1 : 1));
|
|
234
|
+
const deg = rad * (180 / Math.PI);
|
|
235
|
+
let cssDeg = (deg - 90 - 360) % 360 * -1;
|
|
236
|
+
|
|
237
|
+
if (dy < 0) {
|
|
238
|
+
cssDeg += 180;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const rowIndex = len > MINUTE_RADIUS ? 0 : len > HOUR_12_RADIUS ? 1 : 2;
|
|
242
|
+
return [cssDeg, rowIndex];
|
|
493
243
|
}
|
|
494
244
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
245
|
+
#onPickerClick = e => {
|
|
246
|
+
const [cssDeg, rowIndex] = this.#getClickDegree(e.x, e.y);
|
|
247
|
+
const isHourRowClick = rowIndex > 0;
|
|
248
|
+
const isHour24RowClick = rowIndex > 1;
|
|
498
249
|
|
|
499
|
-
|
|
500
|
-
|
|
250
|
+
if (isHourRowClick) {
|
|
251
|
+
const digitIndex = Math.round(cssDeg / 30) % 12;
|
|
252
|
+
const is24 = getBooleanAttribute(this, 'ampm') === false;
|
|
501
253
|
|
|
502
|
-
|
|
254
|
+
if (is24) {
|
|
255
|
+
if (isHour24RowClick) {
|
|
256
|
+
this.#hour = digitIndex === 0 ? 0 : digitIndex + 12;
|
|
257
|
+
} else {
|
|
258
|
+
this.#hour = digitIndex === 0 ? 12 : digitIndex;
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
this.#hour = digitIndex + (this.#$ampm.value === 'pm' ? 12 : 0);
|
|
262
|
+
}
|
|
503
263
|
|
|
504
|
-
|
|
264
|
+
this.#$headerHours.focus();
|
|
265
|
+
} else {
|
|
266
|
+
this.#minute = Math.round(cssDeg / 6) % 60;
|
|
267
|
+
this.#$headerMinutes.focus();
|
|
268
|
+
}
|
|
505
269
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
270
|
+
this.#render();
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
#render() {
|
|
274
|
+
const is24 = getBooleanAttribute(this, 'ampm') === false;
|
|
275
|
+
this.#selectHour(is24);
|
|
276
|
+
this.#selectMinute();
|
|
277
|
+
this.#$headerHoursText.textContent = stringifyHour(this.#hour, is24);
|
|
278
|
+
this.#$headerMinutesText.textContent = stringifyMinute(this.#minute);
|
|
279
|
+
updateAttribute(this.#$headerHours, 'aria-valuenow', this.#hour);
|
|
280
|
+
updateAttribute(this.#$headerHours, 'aria-valuetext', this.#hour);
|
|
281
|
+
updateAttribute(this.#$headerMinutes, 'aria-valuenow', this.#minute);
|
|
282
|
+
updateAttribute(this.#$headerMinutes, 'aria-valuetext', this.#minute);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
#selectHour(is24) {
|
|
286
|
+
const $hours = this.#$pickerHours.children;
|
|
287
|
+
const hourDigitIndex = this.#hour % 12;
|
|
288
|
+
const selectedIndex = hourToIndex(this.#hour, is24);
|
|
289
|
+
const currentCssDeg = getNeedleRotationDeg(this.#$needleHour);
|
|
290
|
+
const hourCssDeg = getShortestCssDeg(currentCssDeg, hourDigitIndex * 30);
|
|
291
|
+
|
|
292
|
+
for (let i = 0; i < $hours.length; i++) {
|
|
293
|
+
setClass($hours[i], 'selected', i === selectedIndex);
|
|
294
|
+
}
|
|
513
295
|
|
|
514
|
-
|
|
515
|
-
const $hours = _classPrivateFieldGet(this, _$pickerHours).children;
|
|
296
|
+
this.#$needleHour.style.transform = `rotate(${hourCssDeg}deg)`;
|
|
516
297
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
298
|
+
if (is24) {
|
|
299
|
+
if (this.#hour > 0 && this.#hour <= 12) {
|
|
300
|
+
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
301
|
+
} else {
|
|
302
|
+
this.#$needleHour.style.height = `${NEEDLE_HOUR_24_LENGTH}px`;
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
306
|
+
}
|
|
521
307
|
|
|
522
|
-
|
|
523
|
-
setClass($hours[i], 'selected', i === selectedIndex);
|
|
308
|
+
this.#$ampm.setAttribute('value', this.#hour >= 0 && this.#hour < 12 ? 'am' : 'pm');
|
|
524
309
|
}
|
|
525
310
|
|
|
526
|
-
|
|
311
|
+
#selectMinute() {
|
|
312
|
+
const $minutes = this.#$pickerMinutes.children;
|
|
313
|
+
const isNeedleSelected = this.#minute % 5 === 0;
|
|
314
|
+
const selectedIndex = this.#minute / 5;
|
|
315
|
+
const currentCssDeg = getNeedleRotationDeg(this.#$needleMinute);
|
|
316
|
+
const minuteCssDeg = getShortestCssDeg(currentCssDeg, this.#minute * 6);
|
|
527
317
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
_classPrivateFieldGet(this, _$needleHour).style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
531
|
-
} else {
|
|
532
|
-
_classPrivateFieldGet(this, _$needleHour).style.height = `${NEEDLE_HOUR_24_LENGTH}px`;
|
|
318
|
+
for (let i = 0; i < $minutes.length; i++) {
|
|
319
|
+
setClass($minutes[i], 'selected', selectedIndex === i);
|
|
533
320
|
}
|
|
534
|
-
|
|
535
|
-
|
|
321
|
+
|
|
322
|
+
setClass(this.#$needleMinute, 'selected', isNeedleSelected);
|
|
323
|
+
this.#$needleMinute.style.transform = `rotate(${minuteCssDeg}deg)`;
|
|
536
324
|
}
|
|
537
325
|
|
|
538
|
-
|
|
539
|
-
|
|
326
|
+
#onAmPmChange = e => {
|
|
327
|
+
e.stopPropagation();
|
|
328
|
+
const value = e.detail;
|
|
540
329
|
|
|
541
|
-
|
|
542
|
-
|
|
330
|
+
switch (value) {
|
|
331
|
+
case 'am':
|
|
332
|
+
{
|
|
333
|
+
if (this.#hour >= 12) {
|
|
334
|
+
this.#hour -= 12;
|
|
335
|
+
this.#render();
|
|
336
|
+
}
|
|
543
337
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const currentCssDeg = getNeedleRotationDeg(_classPrivateFieldGet(this, _$needleMinute));
|
|
547
|
-
const minuteCssDeg = getShortestCssDeg(currentCssDeg, _classPrivateFieldGet(this, _minute) * 6);
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
548
340
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
341
|
+
case 'pm':
|
|
342
|
+
{
|
|
343
|
+
if (this.#hour < 12) {
|
|
344
|
+
this.#hour += 12;
|
|
345
|
+
this.#render();
|
|
346
|
+
}
|
|
552
347
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
#onSubmitButtonClick = () => {
|
|
353
|
+
const value = stringifyTime(this.#hour, this.#minute);
|
|
354
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
355
|
+
bubbles: true,
|
|
356
|
+
detail: value
|
|
357
|
+
}));
|
|
358
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
359
|
+
detail: value
|
|
360
|
+
}));
|
|
361
|
+
};
|
|
362
|
+
#onHoursKeydown = e => {
|
|
363
|
+
switch (e.key) {
|
|
364
|
+
case 'ArrowUp':
|
|
365
|
+
{
|
|
366
|
+
e.preventDefault();
|
|
367
|
+
this.#hour = (this.#hour + 1) % 24;
|
|
368
|
+
this.#render();
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
case 'ArrowDown':
|
|
373
|
+
{
|
|
374
|
+
e.preventDefault();
|
|
375
|
+
this.#hour = (this.#hour + 23) % 24;
|
|
376
|
+
this.#render();
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
#onMinutesKeydown = e => {
|
|
382
|
+
switch (e.key) {
|
|
383
|
+
case 'ArrowUp':
|
|
384
|
+
{
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
this.#minute = (this.#minute + 1) % 60;
|
|
387
|
+
this.#render();
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
case 'ArrowDown':
|
|
392
|
+
{
|
|
393
|
+
e.preventDefault();
|
|
394
|
+
this.#minute = (this.#minute + 59) % 60;
|
|
395
|
+
this.#render();
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
#onChangeReactHandler = e => {
|
|
401
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
402
|
+
};
|
|
403
|
+
});
|