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