@semcore/time-picker 4.51.0 → 16.0.0-prerelease.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/lib/cjs/PickerFormat.js +3 -3
- package/lib/cjs/PickerFormat.js.map +1 -1
- package/lib/cjs/PickerInput.js +1 -1
- package/lib/cjs/PickerInput.js.map +1 -1
- package/lib/cjs/TimePicker.js +15 -19
- package/lib/cjs/TimePicker.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/time-picker.shadow.css +6 -12
- package/lib/es6/PickerFormat.js +3 -3
- package/lib/es6/PickerFormat.js.map +1 -1
- package/lib/es6/PickerInput.js +1 -1
- package/lib/es6/PickerInput.js.map +1 -1
- package/lib/es6/TimePicker.js +15 -17
- package/lib/es6/TimePicker.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/time-picker.shadow.css +6 -12
- package/lib/esm/PickerFormat.mjs +56 -46
- package/lib/esm/PickerInput.mjs +220 -146
- package/lib/esm/TimePicker.mjs +222 -157
- package/lib/esm/index.mjs +7 -7
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
- package/lib/esm/translations/de.json.mjs +20 -14
- package/lib/esm/translations/en.json.mjs +20 -14
- package/lib/esm/translations/es.json.mjs +20 -14
- package/lib/esm/translations/fr.json.mjs +20 -14
- package/lib/esm/translations/it.json.mjs +20 -14
- package/lib/esm/translations/ja.json.mjs +20 -14
- package/lib/esm/translations/ko.json.mjs +20 -14
- package/lib/esm/translations/nl.json.mjs +20 -14
- package/lib/esm/translations/pl.json.mjs +20 -14
- package/lib/esm/translations/pt.json.mjs +20 -14
- package/lib/esm/translations/sv.json.mjs +20 -14
- package/lib/esm/translations/tr.json.mjs +20 -14
- package/lib/esm/translations/vi.json.mjs +20 -14
- package/lib/esm/translations/zh.json.mjs +20 -14
- package/lib/types/index.d.ts +1 -1
- package/package.json +6 -9
package/lib/esm/TimePicker.mjs
CHANGED
|
@@ -1,108 +1,144 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { sstyled
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
import J from "@semcore/utils/lib/enhances/keyboardFocusEnhance";
|
|
19
|
-
var K = (
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { sstyled, createComponent, assignProps, Component } from "@semcore/core";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import Input from "@semcore/input";
|
|
12
|
+
import { Box } from "@semcore/flex-box";
|
|
13
|
+
import { Hours, Minutes } from "./PickerInput.mjs";
|
|
14
|
+
import TimePickerFormat from "./PickerFormat.mjs";
|
|
15
|
+
import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
16
|
+
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
17
|
+
var style = (
|
|
20
18
|
/*__reshadow_css_start__*/
|
|
21
|
-
(
|
|
19
|
+
(sstyled.insert(
|
|
22
20
|
/*__inner_css_start__*/
|
|
23
|
-
".
|
|
24
|
-
"
|
|
21
|
+
".___STimePicker_xkf0v_gg_{position:relative;width:auto;outline:0}.___STimePicker_xkf0v_gg_.__disabled_xkf0v_gg_{color:var(--intergalactic-text-secondary, #6c6e79);cursor:default}.___SPickerInput_xkf0v_gg_{box-sizing:content-box;text-align:center;z-index:1;height:1.5em}.___SPickerInput_xkf0v_gg_.__placeholder_xkf0v_gg_{text-overflow:initial}.___SPickerInput_xkf0v_gg_:focus{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SPickerInput_xkf0v_gg_._size_l_xkf0v_gg_,.___SPickerInput_xkf0v_gg_._size_m_xkf0v_gg_{width:19px;margin:0 var(--intergalactic-spacing-2x, 8px);padding:0}.___SPickerInput_xkf0v_gg_._size_l_xkf0v_gg_{width:21px}.___SPickerFormat_xkf0v_gg_{flex-shrink:0;position:relative;display:inline-flex;padding:0;white-space:nowrap;font-family:inherit;font-weight:var(--intergalactic-medium, 500);line-height:normal;-webkit-text-decoration:none;text-decoration:none;align-items:center;border:1px solid var(--intergalactic-border-primary, #c4c7cf);border-radius:0 var(--intergalactic-control-rounded, 6px) var(--intergalactic-control-rounded, 6px)0;box-shadow:none;cursor:pointer;box-sizing:border-box;overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;color:var(--intergalactic-text-secondary, #6c6e79);background-color:var(--intergalactic-bg-secondary-neutral, #f4f5f9)}@media (hover:hover){.___SPickerFormat_xkf0v_gg_:hover{color:var(--intergalactic-text-secondary, #6c6e79);background-color:var(--intergalactic-bg-secondary-neutral-hover, #e0e1e9)}}.___SPickerFormat_xkf0v_gg_.__active_xkf0v_gg_,.___SPickerFormat_xkf0v_gg_:active{color:var(--intergalactic-text-secondary, #6c6e79);background-color:var(--intergalactic-bg-secondary-neutral-active, #c4c7cf)}.___SPickerFormat_xkf0v_gg_._size_m_xkf0v_gg_{height:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px);margin:0-1px 0 0}.___SPickerFormat_xkf0v_gg_._size_m_xkf0v_gg_ .___SPickerFormatText_xkf0v_gg_{margin:0 var(--intergalactic-spacing-2x, 8px)}.___SPickerFormat_xkf0v_gg_._size_l_xkf0v_gg_{height:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px);margin:0 calc(-1*var(--intergalactic-spacing-1x, 4px))0 0}.___SPickerFormat_xkf0v_gg_._size_l_xkf0v_gg_ .___SPickerFormatText_xkf0v_gg_{margin:0 var(--intergalactic-spacing-3x, 12px)}.___SPickerFormat_xkf0v_gg_.__disabled_xkf0v_gg_{cursor:default;border-color:transparent transparent transparent var(--intergalactic-border-primary, #c4c7cf)}.___STimePickerSeparator_xkf0v_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SPickerFormat_xkf0v_gg_.__disabled_xkf0v_gg_,.___STimePickerSeparator_xkf0v_gg_.__disabled_xkf0v_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);pointer-events:none}",
|
|
22
|
+
"xkf0v_gg_"
|
|
25
23
|
), {
|
|
26
|
-
__STimePicker: "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
__SPickerFormatText: "___SPickerFormatText_us7vk_gg_"
|
|
24
|
+
"__STimePicker": "___STimePicker_xkf0v_gg_",
|
|
25
|
+
"_disabled": "__disabled_xkf0v_gg_",
|
|
26
|
+
"__SPickerInput": "___SPickerInput_xkf0v_gg_",
|
|
27
|
+
"_size_m": "_size_m_xkf0v_gg_",
|
|
28
|
+
"_size_l": "_size_l_xkf0v_gg_",
|
|
29
|
+
"__SPickerFormat": "___SPickerFormat_xkf0v_gg_",
|
|
30
|
+
"__STimePickerSeparator": "___STimePickerSeparator_xkf0v_gg_",
|
|
31
|
+
"_placeholder": "__placeholder_xkf0v_gg_",
|
|
32
|
+
"_active": "__active_xkf0v_gg_",
|
|
33
|
+
"__SPickerFormatText": "___SPickerFormatText_xkf0v_gg_"
|
|
37
34
|
})
|
|
38
|
-
)
|
|
35
|
+
);
|
|
36
|
+
var MAP_MERIDIEM = {
|
|
39
37
|
AM: "PM",
|
|
40
38
|
PM: "AM"
|
|
41
|
-
}
|
|
39
|
+
};
|
|
40
|
+
var MAP_FIELD_TO_TIME = {
|
|
42
41
|
hours: 0,
|
|
43
42
|
minutes: 1
|
|
44
43
|
};
|
|
45
|
-
function
|
|
46
|
-
var
|
|
47
|
-
|
|
44
|
+
function intOrDefault(value) {
|
|
45
|
+
var def = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
46
|
+
var number = Number.parseInt(value);
|
|
47
|
+
return Number.isNaN(number) ? def : number;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
49
|
+
function withLeadingZero(value) {
|
|
50
|
+
value = String(value);
|
|
51
|
+
if (value.length === 1) return "0".concat(value);
|
|
52
|
+
return String(value);
|
|
51
53
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
54
|
+
function meridiemByHours(hours) {
|
|
55
|
+
return hours >= 12 ? "PM" : "AM";
|
|
54
56
|
}
|
|
55
|
-
function
|
|
56
|
-
var
|
|
57
|
-
|
|
57
|
+
function formatHoursTo12(hours) {
|
|
58
|
+
var nHours = intOrDefault(hours, NaN);
|
|
59
|
+
if (Number.isNaN(nHours)) return hours;
|
|
60
|
+
if (nHours === 0) return 12;
|
|
61
|
+
if (nHours > 12) return nHours - 12;
|
|
62
|
+
return hours;
|
|
58
63
|
}
|
|
59
|
-
function
|
|
60
|
-
var
|
|
61
|
-
|
|
64
|
+
function formatHoursTo24(hours, meridiem) {
|
|
65
|
+
var nHours = intOrDefault(hours, NaN);
|
|
66
|
+
if (Number.isNaN(nHours)) return hours;
|
|
67
|
+
if (meridiem === "AM") {
|
|
68
|
+
if (nHours === 12) return 0;
|
|
69
|
+
}
|
|
70
|
+
if (meridiem === "PM") {
|
|
71
|
+
if (nHours < 12) return nHours + 12;
|
|
72
|
+
}
|
|
73
|
+
return hours;
|
|
62
74
|
}
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
function
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
for (var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
var TimePickerRoot = /* @__PURE__ */ function(_Component) {
|
|
76
|
+
_inherits(TimePickerRoot2, _Component);
|
|
77
|
+
var _super = _createSuper(TimePickerRoot2);
|
|
78
|
+
function TimePickerRoot2() {
|
|
79
|
+
var _this;
|
|
80
|
+
_classCallCheck(this, TimePickerRoot2);
|
|
81
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
82
|
+
args[_key] = arguments[_key];
|
|
83
|
+
}
|
|
84
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
85
|
+
_defineProperty(_assertThisInitialized(_this), "hoursInputRef", /* @__PURE__ */ React.createRef());
|
|
86
|
+
_defineProperty(_assertThisInitialized(_this), "minutesInputRef", /* @__PURE__ */ React.createRef());
|
|
87
|
+
_defineProperty(_assertThisInitialized(_this), "_lastMeridiem", "AM");
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "handleValueChange", function(value, field, event) {
|
|
89
|
+
var is12Hour = _this.asProps.is12Hour;
|
|
90
|
+
var _assertThisInitialize = _assertThisInitialized(_this), meridiem = _assertThisInitialize.meridiem;
|
|
91
|
+
var time;
|
|
92
|
+
if (field) {
|
|
93
|
+
time = _this.value.split(":");
|
|
94
|
+
time[MAP_FIELD_TO_TIME[field]] = value;
|
|
95
|
+
} else {
|
|
96
|
+
time = value.split(":");
|
|
97
|
+
}
|
|
98
|
+
var _time = time, _time2 = _slicedToArray(_time, 2), _time2$ = _time2[0], hours = _time2$ === void 0 ? "" : _time2$, _time2$2 = _time2[1], minutes = _time2$2 === void 0 ? "" : _time2$2;
|
|
99
|
+
if (is12Hour) hours = String(formatHoursTo12(hours));
|
|
100
|
+
value = _this.timeToValue([hours, minutes], meridiem);
|
|
101
|
+
_this.handlers.value(value, event);
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleMeridiemClick", function(event) {
|
|
104
|
+
var is12Hour = _this.asProps.is12Hour;
|
|
105
|
+
var _assertThisInitialize2 = _assertThisInitialized(_this), value = _assertThisInitialize2.value, meridiem = _assertThisInitialize2.meridiem;
|
|
106
|
+
var _value$split = value.split(":"), _value$split2 = _slicedToArray(_value$split, 2), _value$split2$ = _value$split2[0], hours = _value$split2$ === void 0 ? "" : _value$split2$, _value$split2$2 = _value$split2[1], minutes = _value$split2$2 === void 0 ? "" : _value$split2$2;
|
|
107
|
+
if (is12Hour) hours = String(formatHoursTo12(hours));
|
|
108
|
+
value = _this.timeToValue([hours, minutes], MAP_MERIDIEM[meridiem]);
|
|
109
|
+
_this.handlers.value(value, event);
|
|
110
|
+
});
|
|
111
|
+
_defineProperty(_assertThisInitialized(_this), "_getHoursAndMinutesProps", function() {
|
|
112
|
+
var _this$asProps = _this.asProps, is12Hour = _this$asProps.is12Hour, size = _this$asProps.size, disabled = _this$asProps.disabled, getI18nText = _this$asProps.getI18nText;
|
|
113
|
+
var time = _this.valueToTime(_this.value);
|
|
81
114
|
return {
|
|
82
|
-
time
|
|
83
|
-
size
|
|
84
|
-
is12Hour
|
|
85
|
-
disabled
|
|
86
|
-
$onValueChange:
|
|
87
|
-
minutesInputRef:
|
|
88
|
-
hoursInputRef:
|
|
89
|
-
_getI18nText:
|
|
115
|
+
time,
|
|
116
|
+
size,
|
|
117
|
+
is12Hour,
|
|
118
|
+
disabled,
|
|
119
|
+
$onValueChange: _this.handleValueChange,
|
|
120
|
+
minutesInputRef: _this.minutesInputRef,
|
|
121
|
+
hoursInputRef: _this.hoursInputRef,
|
|
122
|
+
_getI18nText: getI18nText
|
|
90
123
|
};
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
|
|
124
|
+
});
|
|
125
|
+
_defineProperty(_assertThisInitialized(_this), "getHoursProps", function() {
|
|
126
|
+
return _objectSpread(_objectSpread({}, _this._getHoursAndMinutesProps()), {}, {
|
|
127
|
+
ref: _this.hoursInputRef
|
|
94
128
|
});
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
});
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "getMinutesProps", function() {
|
|
131
|
+
return _objectSpread(_objectSpread({}, _this._getHoursAndMinutesProps()), {}, {
|
|
132
|
+
ref: _this.minutesInputRef
|
|
98
133
|
});
|
|
99
|
-
})
|
|
134
|
+
});
|
|
135
|
+
return _this;
|
|
100
136
|
}
|
|
101
|
-
|
|
137
|
+
_createClass(TimePickerRoot2, [{
|
|
102
138
|
key: "uncontrolledProps",
|
|
103
139
|
value: (
|
|
104
140
|
// default AM
|
|
105
|
-
function() {
|
|
141
|
+
function uncontrolledProps() {
|
|
106
142
|
return {
|
|
107
143
|
value: null,
|
|
108
144
|
title: null
|
|
@@ -111,37 +147,55 @@ var T = /* @__PURE__ */ function(a) {
|
|
|
111
147
|
)
|
|
112
148
|
}, {
|
|
113
149
|
key: "componentDidMount",
|
|
114
|
-
value: function() {
|
|
115
|
-
var
|
|
116
|
-
|
|
150
|
+
value: function componentDidMount() {
|
|
151
|
+
var _document$querySelect;
|
|
152
|
+
var _this$asProps2 = this.asProps, id = _this$asProps2.id, ariaDescribedBy = _this$asProps2["aria-describedby"];
|
|
153
|
+
var selector = "[for=".concat(id, "]");
|
|
154
|
+
var titleElement = (_document$querySelect = document.querySelector(selector)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("#".concat(ariaDescribedBy));
|
|
155
|
+
if (titleElement) {
|
|
156
|
+
this.handlers.title(titleElement.textContent);
|
|
157
|
+
}
|
|
117
158
|
}
|
|
118
159
|
}, {
|
|
119
160
|
key: "value",
|
|
120
|
-
get: function() {
|
|
121
|
-
var
|
|
122
|
-
return
|
|
161
|
+
get: function get() {
|
|
162
|
+
var value = this.asProps.value;
|
|
163
|
+
return value === null || value === void 0 ? ":" : value;
|
|
123
164
|
}
|
|
124
165
|
}, {
|
|
125
166
|
key: "meridiem",
|
|
126
|
-
get: function() {
|
|
127
|
-
var
|
|
128
|
-
|
|
167
|
+
get: function get() {
|
|
168
|
+
var value = this.asProps.value;
|
|
169
|
+
var _value$split3 = value.split(":"), _value$split4 = _slicedToArray(_value$split3, 1), _value$split4$ = _value$split4[0], hours = _value$split4$ === void 0 ? "" : _value$split4$;
|
|
170
|
+
var nHours = intOrDefault(hours, NaN);
|
|
171
|
+
if (!Number.isNaN(nHours)) {
|
|
172
|
+
this._lastMeridiem = meridiemByHours(nHours);
|
|
173
|
+
}
|
|
174
|
+
return this._lastMeridiem;
|
|
129
175
|
}
|
|
130
176
|
}, {
|
|
131
177
|
key: "valueToTime",
|
|
132
|
-
value: function(
|
|
133
|
-
var
|
|
134
|
-
|
|
178
|
+
value: function valueToTime(value) {
|
|
179
|
+
var is12Hour = this.asProps.is12Hour;
|
|
180
|
+
var _value$split5 = value.split(":"), _value$split6 = _slicedToArray(_value$split5, 2), _value$split6$ = _value$split6[0], hours = _value$split6$ === void 0 ? "" : _value$split6$, _value$split6$2 = _value$split6[1], minutes = _value$split6$2 === void 0 ? "" : _value$split6$2;
|
|
181
|
+
if (is12Hour) hours = formatHoursTo12(hours);
|
|
182
|
+
hours = withLeadingZero(hours);
|
|
183
|
+
minutes = withLeadingZero(minutes);
|
|
184
|
+
return [hours, minutes];
|
|
135
185
|
}
|
|
136
186
|
}, {
|
|
137
187
|
key: "timeToValue",
|
|
138
|
-
value: function(
|
|
139
|
-
var
|
|
140
|
-
|
|
188
|
+
value: function timeToValue(time, meridiem) {
|
|
189
|
+
var is12Hour = this.asProps.is12Hour;
|
|
190
|
+
var _time3 = _slicedToArray(time, 2), _time3$ = _time3[0], hours = _time3$ === void 0 ? "" : _time3$, _time3$2 = _time3[1], minutes = _time3$2 === void 0 ? "" : _time3$2;
|
|
191
|
+
hours = intOrDefault(hours, hours);
|
|
192
|
+
minutes = intOrDefault(minutes, minutes);
|
|
193
|
+
if (is12Hour) hours = formatHoursTo24(hours, meridiem);
|
|
194
|
+
return "".concat(hours, ":").concat(minutes);
|
|
141
195
|
}
|
|
142
196
|
}, {
|
|
143
197
|
key: "getSeparatorProps",
|
|
144
|
-
value: function() {
|
|
198
|
+
value: function getSeparatorProps() {
|
|
145
199
|
return {
|
|
146
200
|
disabled: this.asProps.disabled,
|
|
147
201
|
hoursInputRef: this.hoursInputRef
|
|
@@ -149,86 +203,97 @@ var T = /* @__PURE__ */ function(a) {
|
|
|
149
203
|
}
|
|
150
204
|
}, {
|
|
151
205
|
key: "getFormatProps",
|
|
152
|
-
value: function() {
|
|
153
|
-
var
|
|
206
|
+
value: function getFormatProps() {
|
|
207
|
+
var _this$asProps3 = this.asProps, size = _this$asProps3.size, disabled = _this$asProps3.disabled, disablePortal = _this$asProps3.disablePortal, getI18nText = _this$asProps3.getI18nText;
|
|
154
208
|
return {
|
|
155
|
-
size
|
|
156
|
-
disabled
|
|
157
|
-
disablePortal
|
|
209
|
+
size,
|
|
210
|
+
disabled,
|
|
211
|
+
disablePortal,
|
|
158
212
|
meridiem: this.meridiem,
|
|
159
213
|
onClick: this.handleMeridiemClick,
|
|
160
|
-
getI18nText
|
|
214
|
+
getI18nText
|
|
161
215
|
};
|
|
162
216
|
}
|
|
163
217
|
}, {
|
|
164
218
|
key: "render",
|
|
165
|
-
value: function() {
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
219
|
+
value: function render() {
|
|
220
|
+
var _ref = this.asProps, _ref3;
|
|
221
|
+
var STimePicker = Input;
|
|
222
|
+
var _this$asProps4 = this.asProps, styles = _this$asProps4.styles, Children = _this$asProps4.Children, value = _this$asProps4.value, is12Hour = _this$asProps4.is12Hour, getI18nText = _this$asProps4.getI18nText, title = _this$asProps4.title;
|
|
223
|
+
var _this$valueToTime = this.valueToTime(this.value), _this$valueToTime2 = _slicedToArray(_this$valueToTime, 2), hours = _this$valueToTime2[0], minutes = _this$valueToTime2[1];
|
|
224
|
+
var label = value ? "".concat(title, " ").concat(getI18nText("title", {
|
|
225
|
+
time: "".concat(hours, ":").concat(withLeadingZero(minutes)),
|
|
226
|
+
meridiem: is12Hour ? this.meridiem : ""
|
|
227
|
+
})) : "".concat(title, " ").concat(getI18nText("titleEmpty"));
|
|
228
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(STimePicker, _ref3.cn("STimePicker", _objectSpread({}, assignProps({
|
|
229
|
+
"role": "group",
|
|
230
|
+
"aria-label": label,
|
|
231
|
+
"__excludeProps": ["value", "title"]
|
|
232
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {}))));
|
|
175
233
|
}
|
|
176
|
-
}])
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
234
|
+
}]);
|
|
235
|
+
return TimePickerRoot2;
|
|
236
|
+
}(Component);
|
|
237
|
+
_defineProperty(TimePickerRoot, "displayName", "TimePicker");
|
|
238
|
+
_defineProperty(TimePickerRoot, "style", style);
|
|
239
|
+
_defineProperty(TimePickerRoot, "enhance", [i18nEnhance(localizedMessages)]);
|
|
240
|
+
_defineProperty(TimePickerRoot, "defaultProps", function(_ref5) {
|
|
241
|
+
var is12Hour = _ref5.is12Hour;
|
|
183
242
|
return {
|
|
184
243
|
defaultValue: "",
|
|
185
244
|
size: "m",
|
|
186
|
-
children: /* @__PURE__ */
|
|
187
|
-
i18n:
|
|
245
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TimePicker.Hours, null), /* @__PURE__ */ React.createElement(TimePicker.Separator, null), /* @__PURE__ */ React.createElement(TimePicker.Minutes, null), is12Hour && /* @__PURE__ */ React.createElement(TimePicker.Format, null)),
|
|
246
|
+
i18n: localizedMessages,
|
|
188
247
|
locale: "en",
|
|
189
248
|
defaultTitle: ""
|
|
190
249
|
};
|
|
191
250
|
});
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
var
|
|
195
|
-
function
|
|
196
|
-
var
|
|
197
|
-
|
|
198
|
-
for (var
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
251
|
+
var Separator = /* @__PURE__ */ function(_Component2) {
|
|
252
|
+
_inherits(Separator2, _Component2);
|
|
253
|
+
var _super2 = _createSuper(Separator2);
|
|
254
|
+
function Separator2() {
|
|
255
|
+
var _this2;
|
|
256
|
+
_classCallCheck(this, Separator2);
|
|
257
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
258
|
+
args[_key2] = arguments[_key2];
|
|
259
|
+
}
|
|
260
|
+
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
261
|
+
_defineProperty(_assertThisInitialized(_this2), "handlerClick", function() {
|
|
262
|
+
if (_this2.asProps.hoursInputRef.current) {
|
|
263
|
+
var _this2$asProps$hoursI;
|
|
264
|
+
(_this2$asProps$hoursI = _this2.asProps.hoursInputRef.current) === null || _this2$asProps$hoursI === void 0 ? void 0 : _this2$asProps$hoursI.focus();
|
|
204
265
|
}
|
|
205
|
-
})
|
|
266
|
+
});
|
|
267
|
+
return _this2;
|
|
206
268
|
}
|
|
207
|
-
|
|
269
|
+
_createClass(Separator2, [{
|
|
208
270
|
key: "render",
|
|
209
|
-
value: function() {
|
|
210
|
-
var
|
|
211
|
-
|
|
212
|
-
|
|
271
|
+
value: function render() {
|
|
272
|
+
var _ref2 = this.asProps, _ref4;
|
|
273
|
+
var STimePickerSeparator = Box;
|
|
274
|
+
var styles = this.asProps.styles;
|
|
275
|
+
return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(STimePickerSeparator, _ref4.cn("STimePickerSeparator", _objectSpread({}, assignProps({
|
|
276
|
+
"onClick": this.handlerClick,
|
|
213
277
|
"aria-hidden": "true"
|
|
214
|
-
},
|
|
278
|
+
}, _ref2))));
|
|
215
279
|
}
|
|
216
|
-
}])
|
|
217
|
-
|
|
218
|
-
|
|
280
|
+
}]);
|
|
281
|
+
return Separator2;
|
|
282
|
+
}(Component);
|
|
283
|
+
_defineProperty(Separator, "defaultProps", {
|
|
219
284
|
children: ":"
|
|
220
285
|
});
|
|
221
|
-
var
|
|
222
|
-
Hours
|
|
223
|
-
Minutes
|
|
224
|
-
Separator
|
|
225
|
-
Format:
|
|
286
|
+
var TimePicker = createComponent(TimePickerRoot, {
|
|
287
|
+
Hours,
|
|
288
|
+
Minutes,
|
|
289
|
+
Separator,
|
|
290
|
+
Format: TimePickerFormat
|
|
226
291
|
});
|
|
227
292
|
export {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
293
|
+
TimePicker as default,
|
|
294
|
+
formatHoursTo12,
|
|
295
|
+
formatHoursTo24,
|
|
296
|
+
intOrDefault,
|
|
297
|
+
meridiemByHours,
|
|
298
|
+
withLeadingZero
|
|
234
299
|
};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as default2, formatHoursTo12, formatHoursTo24, intOrDefault, meridiemByHours, withLeadingZero } from "./TimePicker.mjs";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
default2 as default,
|
|
4
|
+
formatHoursTo12,
|
|
5
|
+
formatHoursTo24,
|
|
6
|
+
intOrDefault,
|
|
7
|
+
meridiemByHours,
|
|
8
|
+
withLeadingZero
|
|
9
9
|
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
var
|
|
16
|
-
de
|
|
17
|
-
en
|
|
18
|
-
es
|
|
19
|
-
fr
|
|
20
|
-
it
|
|
21
|
-
ja
|
|
22
|
-
ko
|
|
23
|
-
nl
|
|
24
|
-
pt
|
|
25
|
-
tr
|
|
26
|
-
vi
|
|
27
|
-
zh
|
|
28
|
-
pl
|
|
29
|
-
sv
|
|
1
|
+
import de from "./de.json.mjs";
|
|
2
|
+
import en from "./en.json.mjs";
|
|
3
|
+
import es from "./es.json.mjs";
|
|
4
|
+
import fr from "./fr.json.mjs";
|
|
5
|
+
import it from "./it.json.mjs";
|
|
6
|
+
import ja from "./ja.json.mjs";
|
|
7
|
+
import ko from "./ko.json.mjs";
|
|
8
|
+
import nl from "./nl.json.mjs";
|
|
9
|
+
import pt from "./pt.json.mjs";
|
|
10
|
+
import tr from "./tr.json.mjs";
|
|
11
|
+
import vi from "./vi.json.mjs";
|
|
12
|
+
import zh from "./zh.json.mjs";
|
|
13
|
+
import pl from "./pl.json.mjs";
|
|
14
|
+
import sv from "./sv.json.mjs";
|
|
15
|
+
var localizedMessages = {
|
|
16
|
+
de,
|
|
17
|
+
en,
|
|
18
|
+
es,
|
|
19
|
+
fr,
|
|
20
|
+
it,
|
|
21
|
+
ja,
|
|
22
|
+
ko,
|
|
23
|
+
nl,
|
|
24
|
+
pt,
|
|
25
|
+
tr,
|
|
26
|
+
vi,
|
|
27
|
+
zh,
|
|
28
|
+
pl,
|
|
29
|
+
sv
|
|
30
30
|
};
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
localizedMessages
|
|
33
33
|
};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const title = "{time} {meridiem}";
|
|
2
|
+
const titleEmpty = "Auswählen";
|
|
3
|
+
const hours = "Stunden";
|
|
4
|
+
const minutes = "Minuten";
|
|
5
|
+
const formatToggler = "Zeitraum";
|
|
6
|
+
const changedFormatNotice = "Zeitraum geändert auf {meridiem}";
|
|
7
|
+
const de = {
|
|
8
|
+
title,
|
|
9
|
+
titleEmpty,
|
|
10
|
+
hours,
|
|
11
|
+
minutes,
|
|
12
|
+
formatToggler,
|
|
13
|
+
changedFormatNotice
|
|
8
14
|
};
|
|
9
15
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
changedFormatNotice,
|
|
17
|
+
de as default,
|
|
18
|
+
formatToggler,
|
|
19
|
+
hours,
|
|
20
|
+
minutes,
|
|
21
|
+
title,
|
|
22
|
+
titleEmpty
|
|
17
23
|
};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const title = "{time} {meridiem}";
|
|
2
|
+
const titleEmpty = "Select";
|
|
3
|
+
const hours = "Hours";
|
|
4
|
+
const minutes = "Minutes";
|
|
5
|
+
const formatToggler = "Time period";
|
|
6
|
+
const changedFormatNotice = "Time period changed to {meridiem}";
|
|
7
|
+
const en = {
|
|
8
|
+
title,
|
|
9
|
+
titleEmpty,
|
|
10
|
+
hours,
|
|
11
|
+
minutes,
|
|
12
|
+
formatToggler,
|
|
13
|
+
changedFormatNotice
|
|
8
14
|
};
|
|
9
15
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
changedFormatNotice,
|
|
17
|
+
en as default,
|
|
18
|
+
formatToggler,
|
|
19
|
+
hours,
|
|
20
|
+
minutes,
|
|
21
|
+
title,
|
|
22
|
+
titleEmpty
|
|
17
23
|
};
|