@semcore/time-picker 4.52.2 → 4.53.0-prerelease.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/CHANGELOG.md +6 -0
- package/lib/cjs/component/PickerFormat/PickerFormat.js +93 -0
- package/lib/cjs/component/PickerFormat/PickerFormat.js.map +1 -0
- package/lib/cjs/component/PickerFormat/PickerFormat.type.js +2 -0
- package/lib/cjs/component/PickerFormat/PickerFormat.type.js.map +1 -0
- package/lib/cjs/component/PickerFormat/picker-format.shadow.css +61 -0
- package/lib/cjs/{PickerInput.js → component/PickerInput/PickerInput.js} +89 -108
- package/lib/cjs/component/PickerInput/PickerInput.js.map +1 -0
- package/lib/cjs/component/PickerInput/PickerInput.type.js +2 -0
- package/lib/cjs/component/PickerInput/PickerInput.type.js.map +1 -0
- package/lib/cjs/component/PickerInput/picker-input.shadow.css +11 -0
- package/lib/cjs/component/TimePicker/TimePicker.js +254 -0
- package/lib/cjs/component/TimePicker/TimePicker.js.map +1 -0
- package/lib/cjs/component/TimePicker/TimePicker.type.js +2 -0
- package/lib/cjs/component/TimePicker/TimePicker.type.js.map +1 -0
- package/lib/cjs/component/TimePicker/time-picker.shadow.css +34 -0
- package/lib/cjs/entity/TimePickerEntity.js +101 -0
- package/lib/cjs/entity/TimePickerEntity.js.map +1 -0
- package/lib/cjs/index.js +6 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +4 -5
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/component/PickerFormat/PickerFormat.js +88 -0
- package/lib/es6/component/PickerFormat/PickerFormat.js.map +1 -0
- package/lib/es6/component/PickerFormat/PickerFormat.type.js +2 -0
- package/lib/es6/component/PickerFormat/PickerFormat.type.js.map +1 -0
- package/lib/es6/component/PickerFormat/picker-format.shadow.css +61 -0
- package/lib/es6/{PickerInput.js → component/PickerInput/PickerInput.js} +90 -106
- package/lib/es6/component/PickerInput/PickerInput.js.map +1 -0
- package/lib/es6/component/PickerInput/PickerInput.type.js +2 -0
- package/lib/es6/component/PickerInput/PickerInput.type.js.map +1 -0
- package/lib/es6/component/PickerInput/picker-input.shadow.css +11 -0
- package/lib/es6/component/TimePicker/TimePicker.js +250 -0
- package/lib/es6/component/TimePicker/TimePicker.js.map +1 -0
- package/lib/es6/component/TimePicker/TimePicker.type.js +2 -0
- package/lib/es6/component/TimePicker/TimePicker.type.js.map +1 -0
- package/lib/es6/component/TimePicker/time-picker.shadow.css +34 -0
- package/lib/es6/entity/TimePickerEntity.js +94 -0
- package/lib/es6/entity/TimePickerEntity.js.map +1 -0
- package/lib/es6/index.js +2 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/component/PickerFormat/PickerFormat.mjs +86 -0
- package/lib/esm/component/PickerFormat/picker-format.shadow.css +61 -0
- package/lib/esm/{PickerInput.mjs → component/PickerInput/PickerInput.mjs} +92 -100
- package/lib/esm/component/PickerInput/picker-input.shadow.css +11 -0
- package/lib/esm/component/TimePicker/TimePicker.mjs +233 -0
- package/lib/esm/component/TimePicker/TimePicker.type.mjs +1 -0
- package/lib/esm/component/TimePicker/time-picker.shadow.css +34 -0
- package/lib/esm/entity/TimePickerEntity.mjs +90 -0
- package/lib/esm/index.mjs +3 -7
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/types/component/PickerFormat/PickerFormat.d.ts +17 -0
- package/lib/types/component/PickerFormat/PickerFormat.type.d.ts +16 -0
- package/lib/types/component/PickerInput/PickerInput.d.ts +54 -0
- package/lib/types/component/PickerInput/PickerInput.type.d.ts +13 -0
- package/lib/types/component/TimePicker/TimePicker.d.ts +3 -0
- package/lib/types/component/TimePicker/TimePicker.type.d.ts +50 -0
- package/lib/types/entity/TimePickerEntity.d.ts +22 -0
- package/lib/types/index.d.ts +2 -63
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +114 -0
- package/package.json +7 -7
- package/lib/cjs/PickerFormat.js +0 -85
- package/lib/cjs/PickerFormat.js.map +0 -1
- package/lib/cjs/PickerInput.js.map +0 -1
- package/lib/cjs/TimePicker.js +0 -360
- package/lib/cjs/TimePicker.js.map +0 -1
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/cjs/style/time-picker.shadow.css +0 -121
- package/lib/es6/PickerFormat.js +0 -79
- package/lib/es6/PickerFormat.js.map +0 -1
- package/lib/es6/PickerInput.js.map +0 -1
- package/lib/es6/TimePicker.js +0 -348
- package/lib/es6/TimePicker.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
- package/lib/es6/style/time-picker.shadow.css +0 -121
- package/lib/esm/PickerFormat.mjs +0 -70
- package/lib/esm/TimePicker.mjs +0 -305
- package/lib/esm/style/time-picker.shadow.css +0 -121
|
@@ -1,97 +1,90 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
-
import
|
|
5
|
+
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
7
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
10
9
|
import { sstyled, assignProps, Component } from "@semcore/core";
|
|
11
|
-
import
|
|
10
|
+
import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
12
11
|
import Input from "@semcore/input";
|
|
13
12
|
import Select from "@semcore/select";
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
import React from "react";
|
|
14
|
+
var _excluded = ["styles", "step", "onSelect", "time", "size", "disabled", "onVisibleChange", "ariaLabel"];
|
|
15
|
+
/*!__reshadow-styles__:"./picker-input.shadow.css"*/
|
|
16
|
+
var style = (
|
|
17
|
+
/*__reshadow_css_start__*/
|
|
18
|
+
(sstyled.insert(
|
|
19
|
+
/*__inner_css_start__*/
|
|
20
|
+
".___SPickerInput_p1g8c_gg_._size_l_p1g8c_gg_,.___SPickerInput_p1g8c_gg_._size_m_p1g8c_gg_{width:19px;margin:0 var(--intergalactic-spacing-2x, 8px);padding:0}.___SPickerInput_p1g8c_gg_._size_l_p1g8c_gg_{width:21px}",
|
|
21
|
+
/*__inner_css_end__*/
|
|
22
|
+
"p1g8c_gg_"
|
|
23
|
+
), /*__reshadow_css_end__*/
|
|
24
|
+
{
|
|
25
|
+
"__SPickerInput": "___SPickerInput_p1g8c_gg_",
|
|
26
|
+
"_size_m": "_size_m_p1g8c_gg_",
|
|
27
|
+
"_size_l": "_size_l_p1g8c_gg_"
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
function getOptions(minMax) {
|
|
31
|
+
var step = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
32
|
+
var _minMax = _slicedToArray(minMax, 2), min = _minMax[0], max = _minMax[1];
|
|
27
33
|
var length = Number(((max + 1 - min) / step).toFixed(0));
|
|
28
34
|
var options = Array(length).fill("");
|
|
29
35
|
var numValue = min;
|
|
30
|
-
return options.map(function(
|
|
36
|
+
return options.map(function(_i, index) {
|
|
31
37
|
numValue = index === 0 ? numValue : numValue + step;
|
|
32
|
-
var value =
|
|
38
|
+
var value = String(numValue).padStart(2, "0");
|
|
33
39
|
return /* @__PURE__ */ React.createElement(Select.Option, {
|
|
34
40
|
value,
|
|
35
41
|
key: value
|
|
36
42
|
}, value);
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
_inherits(ItemPicker2, _Component);
|
|
42
|
-
var _super = _createSuper(ItemPicker2);
|
|
43
|
-
function ItemPicker2() {
|
|
45
|
+
var AbstractPickerInput = /* @__PURE__ */ (function(_Component) {
|
|
46
|
+
function AbstractPickerInput2() {
|
|
44
47
|
var _this;
|
|
45
|
-
_classCallCheck(this,
|
|
48
|
+
_classCallCheck(this, AbstractPickerInput2);
|
|
46
49
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
50
|
args[_key] = arguments[_key];
|
|
48
51
|
}
|
|
49
|
-
_this =
|
|
50
|
-
_defineProperty(
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
52
|
+
_this = _callSuper(this, AbstractPickerInput2, [].concat(args));
|
|
53
|
+
_defineProperty(_this, "state", {
|
|
52
54
|
dirtyValue: void 0,
|
|
53
55
|
visible: false
|
|
54
56
|
});
|
|
55
|
-
_defineProperty(
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
_defineProperty(_this, "inputRef", /* @__PURE__ */ React.createRef());
|
|
58
|
+
_defineProperty(_this, "parseValueWithMinMax", function(value) {
|
|
59
|
+
var _this$minMax = _slicedToArray(_this.minMax, 2), min = _this$minMax[0], max = _this$minMax[1];
|
|
60
|
+
var numberValue = isNaN(Number(value)) ? min : Number(value);
|
|
61
|
+
return String(Math.max(min, Math.min(max, numberValue)));
|
|
58
62
|
});
|
|
59
|
-
_defineProperty(
|
|
63
|
+
_defineProperty(_this, "handleChange", function(value, event) {
|
|
60
64
|
event.stopPropagation();
|
|
61
|
-
var
|
|
65
|
+
var inputValue = value.replace(/[^0-9]/g, "");
|
|
66
|
+
var numberValue = Number(inputValue);
|
|
62
67
|
if (!Number.isNaN(numberValue)) {
|
|
63
68
|
_this.setState({
|
|
64
|
-
dirtyValue:
|
|
69
|
+
dirtyValue: inputValue.slice(-2)
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
72
|
});
|
|
68
|
-
_defineProperty(
|
|
73
|
+
_defineProperty(_this, "handleBlur", function(event) {
|
|
69
74
|
return _this.submitChanges(event);
|
|
70
75
|
});
|
|
71
|
-
_defineProperty(
|
|
72
|
-
});
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "handleSelect", function(value, event) {
|
|
76
|
+
_defineProperty(_this, "handleSelect", function(value, event) {
|
|
74
77
|
_this.dispatchOnChange(value, event);
|
|
75
78
|
});
|
|
76
|
-
_defineProperty(
|
|
79
|
+
_defineProperty(_this, "handleVisibleChange", function(visible) {
|
|
77
80
|
return _this.setState({
|
|
78
81
|
visible
|
|
79
82
|
});
|
|
80
83
|
});
|
|
81
|
-
_defineProperty(_assertThisInitialized(_this), "getAriaLabel", function() {
|
|
82
|
-
var getI18nText = _this.asProps._getI18nText;
|
|
83
|
-
if (_this.field === "hours") return getI18nText("hours");
|
|
84
|
-
if (_this.field === "minutes") return getI18nText("minutes");
|
|
85
|
-
return void 0;
|
|
86
|
-
});
|
|
87
84
|
return _this;
|
|
88
85
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
value: function minMax() {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
86
|
+
_inherits(AbstractPickerInput2, _Component);
|
|
87
|
+
return _createClass(AbstractPickerInput2, [{
|
|
95
88
|
key: "dispatchOnChange",
|
|
96
89
|
value: function dispatchOnChange(value, event) {
|
|
97
90
|
this.setState({
|
|
@@ -113,18 +106,17 @@ var ItemPicker = /* @__PURE__ */ function(_Component) {
|
|
|
113
106
|
value: function render() {
|
|
114
107
|
var _ref = this.asProps, _ref2;
|
|
115
108
|
var SPickerInput = Select.Trigger;
|
|
116
|
-
var _this$asProps = this.asProps, styles = _this$asProps.styles, step = _this$asProps.step, onSelect = _this$asProps.onSelect, time = _this$asProps.time, size = _this$asProps.size, disabled = _this$asProps.disabled, onVisibleChange = _this$asProps.onVisibleChange, other = _objectWithoutProperties(_this$asProps, _excluded);
|
|
109
|
+
var _this$asProps = this.asProps, styles = _this$asProps.styles, step = _this$asProps.step, onSelect = _this$asProps.onSelect, time = _this$asProps.time, size = _this$asProps.size, disabled = _this$asProps.disabled, onVisibleChange = _this$asProps.onVisibleChange, ariaLabel = _this$asProps.ariaLabel, other = _objectWithoutProperties(_this$asProps, _excluded);
|
|
117
110
|
var _this$state = this.state, dirtyValue = _this$state.dirtyValue, visible = _this$state.visible;
|
|
118
|
-
var
|
|
119
|
-
var value = dirtyValue === void 0 ? timeValue : dirtyValue;
|
|
120
|
-
var _this$minMax3 = this.minMax(), _this$minMax4 = _slicedToArray(_this$minMax3, 2), min = _this$minMax4[0], max = _this$minMax4[1];
|
|
111
|
+
var value = dirtyValue === void 0 ? time : dirtyValue;
|
|
121
112
|
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(Select, _ref2.cn("Select", _objectSpread(_objectSpread({}, other), {}, {
|
|
122
113
|
"interaction": "focus",
|
|
123
|
-
"size": size
|
|
114
|
+
"size": size,
|
|
124
115
|
"onChange": callAllEventHandlers(onSelect, this.handleSelect),
|
|
125
116
|
"onVisibleChange": callAllEventHandlers(onVisibleChange, this.handleVisibleChange),
|
|
126
117
|
"visible": visible,
|
|
127
|
-
"value":
|
|
118
|
+
"value": time,
|
|
119
|
+
"defaultHighlightedIndex": time ? null : 0
|
|
128
120
|
})), /* @__PURE__ */ React.createElement(SPickerInput, _ref2.cn("SPickerInput", _objectSpread({}, assignProps({
|
|
129
121
|
"tag": Input.Value,
|
|
130
122
|
"ref": this.inputRef,
|
|
@@ -133,39 +125,38 @@ var ItemPicker = /* @__PURE__ */ function(_Component) {
|
|
|
133
125
|
"disabled": disabled,
|
|
134
126
|
"neighborLocation": false,
|
|
135
127
|
"value": value,
|
|
136
|
-
"aria-label":
|
|
128
|
+
"aria-label": ariaLabel,
|
|
137
129
|
"onChange": this.handleChange,
|
|
138
130
|
"onBlur": this.handleBlur,
|
|
139
131
|
"onKeyDown": this.handleKeyDown
|
|
140
132
|
}, _ref)))), /* @__PURE__ */ React.createElement(Select.Menu, {
|
|
141
133
|
hMax: 180
|
|
142
|
-
}, getOptions(
|
|
134
|
+
}, getOptions(this.minMax, step)));
|
|
143
135
|
}
|
|
144
136
|
}]);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
_defineProperty(
|
|
148
|
-
|
|
149
|
-
|
|
137
|
+
})(Component);
|
|
138
|
+
_defineProperty(AbstractPickerInput, "style", style);
|
|
139
|
+
_defineProperty(AbstractPickerInput, "defaultProps", function(_) {
|
|
140
|
+
return {
|
|
141
|
+
placeholder: "00",
|
|
142
|
+
offset: [-8, 4]
|
|
143
|
+
};
|
|
150
144
|
});
|
|
151
|
-
var Hours = /* @__PURE__ */ function(
|
|
152
|
-
_inherits(Hours2, _ItemPicker);
|
|
153
|
-
var _super2 = _createSuper(Hours2);
|
|
145
|
+
var Hours = /* @__PURE__ */ (function(_AbstractPickerInput2) {
|
|
154
146
|
function Hours2() {
|
|
155
147
|
var _this2;
|
|
156
148
|
_classCallCheck(this, Hours2);
|
|
157
149
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
158
150
|
args[_key2] = arguments[_key2];
|
|
159
151
|
}
|
|
160
|
-
_this2 =
|
|
161
|
-
_defineProperty(
|
|
162
|
-
_defineProperty(_assertThisInitialized(_this2), "handleKeyDown", function(event) {
|
|
152
|
+
_this2 = _callSuper(this, Hours2, [].concat(args));
|
|
153
|
+
_defineProperty(_this2, "handleKeyDown", function(event) {
|
|
163
154
|
var currentTarget = event.currentTarget;
|
|
164
155
|
if (event.key === "Enter") {
|
|
165
156
|
_this2.submitChanges(event);
|
|
166
157
|
}
|
|
167
158
|
if (event.key === "ArrowRight") {
|
|
168
|
-
if (currentTarget.selectionStart >= currentTarget.value.length && currentTarget.selectionStart === currentTarget.selectionEnd) {
|
|
159
|
+
if (currentTarget.selectionStart && currentTarget.selectionStart >= currentTarget.value.length && currentTarget.selectionStart === currentTarget.selectionEnd) {
|
|
169
160
|
event.preventDefault();
|
|
170
161
|
_this2.focusNext();
|
|
171
162
|
}
|
|
@@ -173,15 +164,17 @@ var Hours = /* @__PURE__ */ function(_ItemPicker) {
|
|
|
173
164
|
});
|
|
174
165
|
return _this2;
|
|
175
166
|
}
|
|
176
|
-
|
|
167
|
+
_inherits(Hours2, _AbstractPickerInput2);
|
|
168
|
+
return _createClass(Hours2, [{
|
|
169
|
+
key: "field",
|
|
170
|
+
get: function get() {
|
|
171
|
+
return "hours";
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
177
174
|
key: "minMax",
|
|
178
|
-
|
|
175
|
+
get: function get() {
|
|
179
176
|
var is12Hour = this.asProps.is12Hour;
|
|
180
|
-
|
|
181
|
-
return [1, 12];
|
|
182
|
-
} else {
|
|
183
|
-
return [0, 23];
|
|
184
|
-
}
|
|
177
|
+
return is12Hour ? [1, 12] : [0, 23];
|
|
185
178
|
}
|
|
186
179
|
}, {
|
|
187
180
|
key: "focusNext",
|
|
@@ -195,7 +188,7 @@ var Hours = /* @__PURE__ */ function(_ItemPicker) {
|
|
|
195
188
|
}
|
|
196
189
|
}, {
|
|
197
190
|
key: "componentDidUpdate",
|
|
198
|
-
value: function componentDidUpdate(
|
|
191
|
+
value: function componentDidUpdate(_, prevState) {
|
|
199
192
|
var dirtyValue = this.state.dirtyValue;
|
|
200
193
|
if (prevState.dirtyValue === void 0 || dirtyValue === void 0) return;
|
|
201
194
|
if (prevState.dirtyValue.length === 1 && dirtyValue.length === 2) {
|
|
@@ -203,29 +196,24 @@ var Hours = /* @__PURE__ */ function(_ItemPicker) {
|
|
|
203
196
|
}
|
|
204
197
|
}
|
|
205
198
|
}]);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return _objectSpread(_objectSpread({}, ItemPicker.defaultProps), {}, {
|
|
211
|
-
ml: size === "l" ? 3 : void 0
|
|
199
|
+
})(AbstractPickerInput);
|
|
200
|
+
_defineProperty(Hours, "defaultProps", function(props) {
|
|
201
|
+
return _objectSpread(_objectSpread({}, AbstractPickerInput.defaultProps(props)), {}, {
|
|
202
|
+
ml: props.size === "l" ? 3 : void 0
|
|
212
203
|
});
|
|
213
204
|
});
|
|
214
|
-
var Minutes = /* @__PURE__ */ function(
|
|
215
|
-
_inherits(Minutes2, _ItemPicker2);
|
|
216
|
-
var _super3 = _createSuper(Minutes2);
|
|
205
|
+
var Minutes = /* @__PURE__ */ (function(_AbstractPickerInput3) {
|
|
217
206
|
function Minutes2() {
|
|
218
207
|
var _this3;
|
|
219
208
|
_classCallCheck(this, Minutes2);
|
|
220
209
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
221
210
|
args[_key3] = arguments[_key3];
|
|
222
211
|
}
|
|
223
|
-
_this3 =
|
|
224
|
-
_defineProperty(
|
|
225
|
-
_defineProperty(_assertThisInitialized(_this3), "handleKeyDown", function(event) {
|
|
212
|
+
_this3 = _callSuper(this, Minutes2, [].concat(args));
|
|
213
|
+
_defineProperty(_this3, "handleKeyDown", function(event) {
|
|
226
214
|
var currentTarget = event.currentTarget;
|
|
227
215
|
if (event.key === "ArrowLeft") {
|
|
228
|
-
if (currentTarget.selectionStart <= 0 && currentTarget.selectionStart === currentTarget.selectionEnd) {
|
|
216
|
+
if (currentTarget.selectionStart && currentTarget.selectionStart <= 0 && currentTarget.selectionStart === currentTarget.selectionEnd) {
|
|
229
217
|
event.preventDefault();
|
|
230
218
|
_this3.focusPrev();
|
|
231
219
|
}
|
|
@@ -240,9 +228,15 @@ var Minutes = /* @__PURE__ */ function(_ItemPicker2) {
|
|
|
240
228
|
});
|
|
241
229
|
return _this3;
|
|
242
230
|
}
|
|
243
|
-
|
|
231
|
+
_inherits(Minutes2, _AbstractPickerInput3);
|
|
232
|
+
return _createClass(Minutes2, [{
|
|
233
|
+
key: "field",
|
|
234
|
+
get: function get() {
|
|
235
|
+
return "minutes";
|
|
236
|
+
}
|
|
237
|
+
}, {
|
|
244
238
|
key: "minMax",
|
|
245
|
-
|
|
239
|
+
get: function get() {
|
|
246
240
|
return [0, 59];
|
|
247
241
|
}
|
|
248
242
|
}, {
|
|
@@ -256,12 +250,10 @@ var Minutes = /* @__PURE__ */ function(_ItemPicker2) {
|
|
|
256
250
|
}
|
|
257
251
|
}
|
|
258
252
|
}]);
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return _objectSpread(_objectSpread({}, ItemPicker.defaultProps), {}, {
|
|
264
|
-
mr: size === "l" ? 3 : void 0
|
|
253
|
+
})(AbstractPickerInput);
|
|
254
|
+
_defineProperty(Minutes, "defaultProps", function(props) {
|
|
255
|
+
return _objectSpread(_objectSpread({}, AbstractPickerInput.defaultProps(props)), {}, {
|
|
256
|
+
mr: props.size === "l" ? 3 : void 0
|
|
265
257
|
});
|
|
266
258
|
});
|
|
267
259
|
export {
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import _applyDecs from "@babel/runtime/helpers/esm/applyDecs2311";
|
|
10
|
+
import _identity from "@babel/runtime/helpers/esm/identity";
|
|
11
|
+
import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
|
|
12
|
+
import { ScreenReaderOnly, Box } from "@semcore/base-components";
|
|
13
|
+
import propsObserver from "@semcore/core/lib/decorators/propsObserver";
|
|
14
|
+
import reactive from "@semcore/core/lib/decorators/reactive";
|
|
15
|
+
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
16
|
+
import Input from "@semcore/input";
|
|
17
|
+
import React from "react";
|
|
18
|
+
import TimePickerEntity from "../../entity/TimePickerEntity.mjs";
|
|
19
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
20
|
+
import TimePickerFormat from "../PickerFormat/PickerFormat.mjs";
|
|
21
|
+
import { Minutes, Hours } from "../PickerInput/PickerInput.mjs";
|
|
22
|
+
var _Class, _TimePickerRoot3, _applyDecs2, _applyDecs2$e, _applyDecs2$c;
|
|
23
|
+
var _initClass, _classDecs, _entityDecs, _init_entity, _init_extra_entity, _TimePickerRoot2, _ref5;
|
|
24
|
+
/*!__reshadow-styles__:"./time-picker.shadow.css"*/
|
|
25
|
+
var style = (
|
|
26
|
+
/*__reshadow_css_start__*/
|
|
27
|
+
(sstyled.insert(
|
|
28
|
+
/*__inner_css_start__*/
|
|
29
|
+
".___STimePicker_1p8j0_gg_{position:relative;width:auto;outline:0}.___STimePicker_1p8j0_gg_ .___SPickerInput_1p8j0_gg_{box-sizing:content-box;text-align:center;z-index:1;height:1.5em}.___STimePicker_1p8j0_gg_ .___SPickerInput_1p8j0_gg_.__placeholder_1p8j0_gg_{text-overflow:initial}.___STimePicker_1p8j0_gg_ .___SPickerInput_1p8j0_gg_:focus{outline:0;background-color:var(--intergalactic-bg-highlight-focus, rgb(231, 234, 251))}.___STimePicker_1p8j0_gg_.__disabled_1p8j0_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));cursor:default}@supports (color:color(display-p3 0 0 0%)){.___STimePicker_1p8j0_gg_.__disabled_1p8j0_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STimePicker_1p8j0_gg_.__disabled_1p8j0_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STimePickerSeparator_1p8j0_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}.___STimePickerSeparator_1p8j0_gg_.__disabled_1p8j0_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4);pointer-events:none}",
|
|
30
|
+
/*__inner_css_end__*/
|
|
31
|
+
"1p8j0_gg_"
|
|
32
|
+
), /*__reshadow_css_end__*/
|
|
33
|
+
{
|
|
34
|
+
"__STimePicker": "___STimePicker_1p8j0_gg_",
|
|
35
|
+
"_disabled": "__disabled_1p8j0_gg_",
|
|
36
|
+
"__STimePickerSeparator": "___STimePickerSeparator_1p8j0_gg_",
|
|
37
|
+
"__SPickerInput": "___SPickerInput_1p8j0_gg_",
|
|
38
|
+
"_placeholder": "__placeholder_1p8j0_gg_"
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
_classDecs = [propsObserver(["value", "is12Hour"])];
|
|
42
|
+
var _TimePickerRoot;
|
|
43
|
+
new (_TimePickerRoot2 = (_ref5 = (_entityDecs = reactive(["meridiem"], function() {
|
|
44
|
+
this.forceUpdate();
|
|
45
|
+
}), "hoursInputRef"), _TimePickerRoot3 = /* @__PURE__ */ (function(_Component) {
|
|
46
|
+
function TimePickerRoot() {
|
|
47
|
+
var _this$props$value;
|
|
48
|
+
var _this;
|
|
49
|
+
_classCallCheck(this, TimePickerRoot);
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
_this = _callSuper(this, TimePickerRoot, [].concat(args));
|
|
54
|
+
_defineProperty(_this, _ref5, /* @__PURE__ */ React.createRef());
|
|
55
|
+
_defineProperty(_this, "minutesInputRef", /* @__PURE__ */ React.createRef());
|
|
56
|
+
_defineProperty(_this, "state", {
|
|
57
|
+
ariaLabel: ""
|
|
58
|
+
});
|
|
59
|
+
_defineProperty(_this, "entity", _init_entity(_this, new TimePickerEntity((_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.props.defaultValue, _this.props.is12Hour)));
|
|
60
|
+
_defineProperty(_this, "handleValueChange", (_init_extra_entity(_this), function(value, field, event) {
|
|
61
|
+
_this.entity[field] = value;
|
|
62
|
+
_this.handlers.value(_this.entity.toString(), event);
|
|
63
|
+
}));
|
|
64
|
+
_defineProperty(_this, "handleMeridiemClick", function(event) {
|
|
65
|
+
_this.entity.toggleMeridiem();
|
|
66
|
+
_this.handlers.value(_this.entity.toString(), event);
|
|
67
|
+
});
|
|
68
|
+
_defineProperty(_this, "getCommonPickerInputProps", function() {
|
|
69
|
+
var _this$asProps = _this.asProps, is12Hour = _this$asProps.is12Hour, size = _this$asProps.size, disabled = _this$asProps.disabled;
|
|
70
|
+
return {
|
|
71
|
+
size,
|
|
72
|
+
is12Hour,
|
|
73
|
+
disabled,
|
|
74
|
+
$onValueChange: _this.handleValueChange,
|
|
75
|
+
minutesInputRef: _this.minutesInputRef,
|
|
76
|
+
hoursInputRef: _this.hoursInputRef
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
_defineProperty(_this, "getHoursProps", function() {
|
|
80
|
+
return _objectSpread(_objectSpread({}, _this.getCommonPickerInputProps()), {}, {
|
|
81
|
+
time: _this.entity.hours,
|
|
82
|
+
ariaLabel: _this.asProps.getI18nText("hours"),
|
|
83
|
+
ref: _this.hoursInputRef
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
_defineProperty(_this, "getMinutesProps", function() {
|
|
87
|
+
return _objectSpread(_objectSpread({}, _this.getCommonPickerInputProps()), {}, {
|
|
88
|
+
time: _this.entity.minutes,
|
|
89
|
+
ariaLabel: _this.asProps.getI18nText("minutes"),
|
|
90
|
+
ref: _this.minutesInputRef
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
_inherits(TimePickerRoot, _Component);
|
|
96
|
+
return _createClass(TimePickerRoot, [{
|
|
97
|
+
key: "componentDidMount",
|
|
98
|
+
value: function componentDidMount() {
|
|
99
|
+
var _document$querySelect;
|
|
100
|
+
var _this$asProps2 = this.asProps, id = _this$asProps2.id, ariaDescribedBy = _this$asProps2["aria-describedby"];
|
|
101
|
+
var selector = "[for=".concat(id, "]");
|
|
102
|
+
var element = (_document$querySelect = document.querySelector(selector)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("#".concat(ariaDescribedBy));
|
|
103
|
+
if (element) {
|
|
104
|
+
this.setState({
|
|
105
|
+
ariaLabel: element.textContent
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "onPropsChange",
|
|
111
|
+
value: function onPropsChange(changedProps) {
|
|
112
|
+
var value = changedProps.value, is12Hour = changedProps.is12Hour;
|
|
113
|
+
if (value !== void 0) {
|
|
114
|
+
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;
|
|
115
|
+
this.entity.hours = hours;
|
|
116
|
+
this.entity.minutes = minutes;
|
|
117
|
+
}
|
|
118
|
+
if (is12Hour !== void 0) {
|
|
119
|
+
this.entity.is12Hour = is12Hour;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "uncontrolledProps",
|
|
124
|
+
value: function uncontrolledProps() {
|
|
125
|
+
return {
|
|
126
|
+
value: null
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "getSeparatorProps",
|
|
131
|
+
value: function getSeparatorProps() {
|
|
132
|
+
return {
|
|
133
|
+
disabled: this.asProps.disabled,
|
|
134
|
+
hoursInputRef: this.hoursInputRef
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "getFormatProps",
|
|
139
|
+
value: function getFormatProps() {
|
|
140
|
+
var _this$asProps3 = this.asProps, size = _this$asProps3.size, disabled = _this$asProps3.disabled, getI18nText = _this$asProps3.getI18nText;
|
|
141
|
+
return {
|
|
142
|
+
size,
|
|
143
|
+
disabled,
|
|
144
|
+
meridiem: this.entity.meridiem,
|
|
145
|
+
onClick: this.handleMeridiemClick,
|
|
146
|
+
getI18nText
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
150
|
+
key: "render",
|
|
151
|
+
value: function render() {
|
|
152
|
+
var _ref = this.asProps, _ref3;
|
|
153
|
+
var STimePicker = Input;
|
|
154
|
+
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, id = _this$asProps4.id;
|
|
155
|
+
var time = "".concat(this.entity.hours, ":").concat(this.entity.minutes);
|
|
156
|
+
var meridiem = is12Hour ? this.entity.meridiem : "";
|
|
157
|
+
var label = value ? "".concat(this.state.ariaLabel, " ").concat(getI18nText("title", {
|
|
158
|
+
time,
|
|
159
|
+
meridiem
|
|
160
|
+
})) : "".concat(this.state.ariaLabel, " ").concat(getI18nText("titleEmpty"));
|
|
161
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(STimePicker, _ref3.cn("STimePicker", _objectSpread({}, assignProps({
|
|
162
|
+
"role": "group",
|
|
163
|
+
"aria-label": label,
|
|
164
|
+
"__excludeProps": ["value", "id"]
|
|
165
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {}))), /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref3.cn("ScreenReaderOnly", {
|
|
166
|
+
"tag": "input",
|
|
167
|
+
"tabIndex": -1,
|
|
168
|
+
"id": id,
|
|
169
|
+
"aria-hidden": true,
|
|
170
|
+
"value": "".concat(time, " ").concat(meridiem)
|
|
171
|
+
})));
|
|
172
|
+
}
|
|
173
|
+
}]);
|
|
174
|
+
})(Component), _applyDecs2 = _applyDecs(_TimePickerRoot3, _classDecs, [[_entityDecs, 0, "entity"]], 0, void 0, Component), _applyDecs2$e = _slicedToArray(_applyDecs2.e, 2), _init_entity = _applyDecs2$e[0], _init_extra_entity = _applyDecs2$e[1], _applyDecs2$c = _slicedToArray(_applyDecs2.c, 2), _TimePickerRoot = _applyDecs2$c[0], _initClass = _applyDecs2$c[1], _TimePickerRoot3), _Class = /* @__PURE__ */ (function(_identity2) {
|
|
175
|
+
function _Class2() {
|
|
176
|
+
var _this2;
|
|
177
|
+
_classCallCheck(this, _Class2);
|
|
178
|
+
_this2 = _callSuper(this, _Class2, [_TimePickerRoot]), _defineProperty(_assertThisInitialized(_this2), "displayName", "TimePicker"), _defineProperty(_assertThisInitialized(_this2), "style", style), _defineProperty(_assertThisInitialized(_this2), "enhance", [i18nEnhance(localizedMessages)]), _defineProperty(_assertThisInitialized(_this2), "defaultProps", function(_ref6) {
|
|
179
|
+
var is12Hour = _ref6.is12Hour;
|
|
180
|
+
return {
|
|
181
|
+
defaultValue: "",
|
|
182
|
+
size: "m",
|
|
183
|
+
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)),
|
|
184
|
+
locale: "en"
|
|
185
|
+
};
|
|
186
|
+
}), _initClass();
|
|
187
|
+
return _this2;
|
|
188
|
+
}
|
|
189
|
+
_inherits(_Class2, _identity2);
|
|
190
|
+
return _createClass(_Class2);
|
|
191
|
+
})(_identity), _defineProperty(_Class, _TimePickerRoot2, void 0), _Class)();
|
|
192
|
+
var Separator = /* @__PURE__ */ (function(_Component2) {
|
|
193
|
+
function Separator2() {
|
|
194
|
+
var _this3;
|
|
195
|
+
_classCallCheck(this, Separator2);
|
|
196
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
197
|
+
args[_key2] = arguments[_key2];
|
|
198
|
+
}
|
|
199
|
+
_this3 = _callSuper(this, Separator2, [].concat(args));
|
|
200
|
+
_defineProperty(_this3, "handlerClick", function() {
|
|
201
|
+
if (_this3.asProps.hoursInputRef.current) {
|
|
202
|
+
var _this3$asProps$hoursI;
|
|
203
|
+
(_this3$asProps$hoursI = _this3.asProps.hoursInputRef.current) === null || _this3$asProps$hoursI === void 0 || _this3$asProps$hoursI.focus();
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return _this3;
|
|
207
|
+
}
|
|
208
|
+
_inherits(Separator2, _Component2);
|
|
209
|
+
return _createClass(Separator2, [{
|
|
210
|
+
key: "render",
|
|
211
|
+
value: function render() {
|
|
212
|
+
var _ref2 = this.asProps, _ref4;
|
|
213
|
+
var STimePickerSeparator = Box;
|
|
214
|
+
var styles = this.asProps.styles;
|
|
215
|
+
return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(STimePickerSeparator, _ref4.cn("STimePickerSeparator", _objectSpread({}, assignProps({
|
|
216
|
+
"onClick": this.handlerClick,
|
|
217
|
+
"aria-hidden": "true"
|
|
218
|
+
}, _ref2))));
|
|
219
|
+
}
|
|
220
|
+
}]);
|
|
221
|
+
})(Component);
|
|
222
|
+
_defineProperty(Separator, "defaultProps", {
|
|
223
|
+
children: ":"
|
|
224
|
+
});
|
|
225
|
+
var TimePicker = createComponent(_TimePickerRoot, {
|
|
226
|
+
Hours,
|
|
227
|
+
Minutes,
|
|
228
|
+
Separator,
|
|
229
|
+
Format: TimePickerFormat
|
|
230
|
+
});
|
|
231
|
+
export {
|
|
232
|
+
TimePicker as default
|
|
233
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
STimePicker {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: auto;
|
|
4
|
+
outline: none;
|
|
5
|
+
|
|
6
|
+
SPickerInput {
|
|
7
|
+
box-sizing: content-box;
|
|
8
|
+
text-align: center;
|
|
9
|
+
z-index: 1;
|
|
10
|
+
height: 1.5em;
|
|
11
|
+
|
|
12
|
+
&[placeholder] {
|
|
13
|
+
text-overflow: initial;
|
|
14
|
+
}
|
|
15
|
+
&:focus {
|
|
16
|
+
outline: none;
|
|
17
|
+
background-color: var(--intergalactic-bg-highlight-focus, oklch(0.94 0.023 278.4));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
STimePicker[disabled] {
|
|
23
|
+
color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
STimePickerSeparator {
|
|
28
|
+
color: var(--intergalactic-text-primary, oklch(0.1 0.03 137 / 0.899));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
STimePickerSeparator[disabled] {
|
|
32
|
+
opacity: var(--intergalactic-disabled-opacity, 0.4);
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|