@semcore/time-picker 16.2.0-prerelease.3 → 16.2.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.
Files changed (73) hide show
  1. package/lib/cjs/component/PickerFormat/PickerFormat.js +93 -0
  2. package/lib/cjs/component/PickerFormat/PickerFormat.js.map +1 -0
  3. package/lib/cjs/component/PickerFormat/PickerFormat.type.js +2 -0
  4. package/lib/cjs/component/PickerFormat/PickerFormat.type.js.map +1 -0
  5. package/lib/cjs/{style/time-picker.shadow.css → component/PickerFormat/picker-format.shadow.css} +1 -56
  6. package/lib/cjs/{PickerInput.js → component/PickerInput/PickerInput.js} +72 -82
  7. package/lib/cjs/component/PickerInput/PickerInput.js.map +1 -0
  8. package/lib/cjs/component/PickerInput/PickerInput.type.js +2 -0
  9. package/lib/cjs/component/PickerInput/PickerInput.type.js.map +1 -0
  10. package/lib/cjs/component/PickerInput/picker-input.shadow.css +11 -0
  11. package/lib/cjs/component/TimePicker/TimePicker.js +254 -0
  12. package/lib/cjs/component/TimePicker/TimePicker.js.map +1 -0
  13. package/lib/cjs/component/TimePicker/TimePicker.type.js +2 -0
  14. package/lib/cjs/component/TimePicker/TimePicker.type.js.map +1 -0
  15. package/lib/cjs/component/TimePicker/time-picker.shadow.css +34 -0
  16. package/lib/cjs/entity/TimePickerEntity.js +101 -0
  17. package/lib/cjs/entity/TimePickerEntity.js.map +1 -0
  18. package/lib/cjs/index.js +6 -5
  19. package/lib/cjs/index.js.map +1 -1
  20. package/lib/es6/component/PickerFormat/PickerFormat.js +88 -0
  21. package/lib/es6/component/PickerFormat/PickerFormat.js.map +1 -0
  22. package/lib/es6/component/PickerFormat/PickerFormat.type.js +2 -0
  23. package/lib/es6/component/PickerFormat/PickerFormat.type.js.map +1 -0
  24. package/lib/{esm/style/time-picker.shadow.css → es6/component/PickerFormat/picker-format.shadow.css} +1 -56
  25. package/lib/es6/{PickerInput.js → component/PickerInput/PickerInput.js} +73 -82
  26. package/lib/es6/component/PickerInput/PickerInput.js.map +1 -0
  27. package/lib/es6/component/PickerInput/PickerInput.type.js +2 -0
  28. package/lib/es6/component/PickerInput/PickerInput.type.js.map +1 -0
  29. package/lib/es6/component/PickerInput/picker-input.shadow.css +11 -0
  30. package/lib/es6/component/TimePicker/TimePicker.js +250 -0
  31. package/lib/es6/component/TimePicker/TimePicker.js.map +1 -0
  32. package/lib/es6/component/TimePicker/TimePicker.type.js +2 -0
  33. package/lib/es6/component/TimePicker/TimePicker.type.js.map +1 -0
  34. package/lib/es6/component/TimePicker/time-picker.shadow.css +34 -0
  35. package/lib/es6/entity/TimePickerEntity.js +94 -0
  36. package/lib/es6/entity/TimePickerEntity.js.map +1 -0
  37. package/lib/es6/index.js +2 -2
  38. package/lib/es6/index.js.map +1 -1
  39. package/lib/esm/component/PickerFormat/PickerFormat.mjs +86 -0
  40. package/lib/{es6/style/time-picker.shadow.css → esm/component/PickerFormat/picker-format.shadow.css} +1 -56
  41. package/lib/esm/{PickerInput.mjs → component/PickerInput/PickerInput.mjs} +75 -76
  42. package/lib/esm/component/PickerInput/picker-input.shadow.css +11 -0
  43. package/lib/esm/component/TimePicker/TimePicker.mjs +233 -0
  44. package/lib/esm/component/TimePicker/TimePicker.type.mjs +1 -0
  45. package/lib/esm/component/TimePicker/time-picker.shadow.css +34 -0
  46. package/lib/esm/entity/TimePickerEntity.mjs +90 -0
  47. package/lib/esm/index.mjs +3 -7
  48. package/lib/types/component/PickerFormat/PickerFormat.d.ts +17 -0
  49. package/lib/types/component/PickerFormat/PickerFormat.type.d.ts +16 -0
  50. package/lib/types/component/PickerInput/PickerInput.d.ts +54 -0
  51. package/lib/types/component/PickerInput/PickerInput.type.d.ts +13 -0
  52. package/lib/types/component/TimePicker/TimePicker.d.ts +3 -0
  53. package/lib/types/component/TimePicker/TimePicker.type.d.ts +50 -0
  54. package/lib/types/entity/TimePickerEntity.d.ts +22 -0
  55. package/lib/types/index.d.ts +2 -63
  56. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +114 -0
  57. package/package.json +7 -7
  58. package/lib/cjs/PickerFormat.js +0 -81
  59. package/lib/cjs/PickerFormat.js.map +0 -1
  60. package/lib/cjs/PickerInput.js.map +0 -1
  61. package/lib/cjs/TimePicker.js +0 -348
  62. package/lib/cjs/TimePicker.js.map +0 -1
  63. package/lib/cjs/index.d.js +0 -2
  64. package/lib/cjs/index.d.js.map +0 -1
  65. package/lib/es6/PickerFormat.js +0 -75
  66. package/lib/es6/PickerFormat.js.map +0 -1
  67. package/lib/es6/PickerInput.js.map +0 -1
  68. package/lib/es6/TimePicker.js +0 -339
  69. package/lib/es6/TimePicker.js.map +0 -1
  70. package/lib/es6/index.d.js +0 -2
  71. package/lib/es6/index.d.js.map +0 -1
  72. package/lib/esm/PickerFormat.mjs +0 -67
  73. package/lib/esm/TimePicker.mjs +0 -297
@@ -1,72 +1,78 @@
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
5
  import _callSuper from "@babel/runtime/helpers/esm/callSuper";
7
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
8
7
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
9
  import { sstyled, assignProps, Component } from "@semcore/core";
10
10
  import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
11
11
  import Input from "@semcore/input";
12
12
  import Select from "@semcore/select";
13
13
  import React from "react";
14
- import { intOrDefault, withLeadingZero } from "./TimePicker.mjs";
15
- var _excluded = ["styles", "step", "onSelect", "time", "size", "disabled", "onVisibleChange"];
16
- var MAP_FIELD_TO_TIME = {
17
- hours: 0,
18
- minutes: 1
19
- };
20
- var MAP_SIZE_SELECT = {
21
- m: "m",
22
- l: "l"
23
- };
24
- function getOptions(min, max) {
25
- var step = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
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];
26
33
  var length = Number(((max + 1 - min) / step).toFixed(0));
27
34
  var options = Array(length).fill("");
28
35
  var numValue = min;
29
36
  return options.map(function(_i, index) {
30
37
  numValue = index === 0 ? numValue : numValue + step;
31
- var value = withLeadingZero(String(numValue));
38
+ var value = String(numValue).padStart(2, "0");
32
39
  return /* @__PURE__ */ React.createElement(Select.Option, {
33
40
  value,
34
41
  key: value
35
42
  }, value);
36
43
  });
37
44
  }
38
- var defaultPopperOffset = [-8, 4];
39
- var ItemPicker = /* @__PURE__ */ (function(_Component) {
40
- function ItemPicker2() {
45
+ var AbstractPickerInput = /* @__PURE__ */ (function(_Component) {
46
+ function AbstractPickerInput2() {
41
47
  var _this;
42
- _classCallCheck(this, ItemPicker2);
48
+ _classCallCheck(this, AbstractPickerInput2);
43
49
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
50
  args[_key] = arguments[_key];
45
51
  }
46
- _this = _callSuper(this, ItemPicker2, [].concat(args));
47
- _defineProperty(_this, "inputRef", /* @__PURE__ */ React.createRef());
52
+ _this = _callSuper(this, AbstractPickerInput2, [].concat(args));
48
53
  _defineProperty(_this, "state", {
49
54
  dirtyValue: void 0,
50
55
  visible: false
51
56
  });
57
+ _defineProperty(_this, "inputRef", /* @__PURE__ */ React.createRef());
52
58
  _defineProperty(_this, "parseValueWithMinMax", function(value) {
53
- var _this$minMax = _this.minMax(), _this$minMax2 = _slicedToArray(_this$minMax, 2), min = _this$minMax2[0], max = _this$minMax2[1];
54
- return String(Math.max(min, Math.min(max, 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)));
55
62
  });
56
63
  _defineProperty(_this, "handleChange", function(value, event) {
57
64
  event.stopPropagation();
58
- var numberValue = intOrDefault(Number(value), Number.NaN);
65
+ var inputValue = value.replace(/[^0-9]/g, "");
66
+ var numberValue = Number(inputValue);
59
67
  if (!Number.isNaN(numberValue)) {
60
68
  _this.setState({
61
- dirtyValue: value.slice(-2)
69
+ dirtyValue: inputValue.slice(-2)
62
70
  });
63
71
  }
64
72
  });
65
73
  _defineProperty(_this, "handleBlur", function(event) {
66
74
  return _this.submitChanges(event);
67
75
  });
68
- _defineProperty(_this, "handleKeyDown", function() {
69
- });
70
76
  _defineProperty(_this, "handleSelect", function(value, event) {
71
77
  _this.dispatchOnChange(value, event);
72
78
  });
@@ -75,21 +81,10 @@ var ItemPicker = /* @__PURE__ */ (function(_Component) {
75
81
  visible
76
82
  });
77
83
  });
78
- _defineProperty(_this, "getAriaLabel", function() {
79
- var getI18nText = _this.asProps._getI18nText;
80
- if (_this.field === "hours") return getI18nText("hours");
81
- if (_this.field === "minutes") return getI18nText("minutes");
82
- return void 0;
83
- });
84
84
  return _this;
85
85
  }
86
- _inherits(ItemPicker2, _Component);
87
- return _createClass(ItemPicker2, [{
88
- key: "minMax",
89
- value: function minMax() {
90
- return [];
91
- }
92
- }, {
86
+ _inherits(AbstractPickerInput2, _Component);
87
+ return _createClass(AbstractPickerInput2, [{
93
88
  key: "dispatchOnChange",
94
89
  value: function dispatchOnChange(value, event) {
95
90
  this.setState({
@@ -111,18 +106,17 @@ var ItemPicker = /* @__PURE__ */ (function(_Component) {
111
106
  value: function render() {
112
107
  var _ref = this.asProps, _ref2;
113
108
  var SPickerInput = Select.Trigger;
114
- 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);
115
110
  var _this$state = this.state, dirtyValue = _this$state.dirtyValue, visible = _this$state.visible;
116
- var timeValue = time[MAP_FIELD_TO_TIME[this.field]];
117
- var value = dirtyValue === void 0 ? timeValue : dirtyValue;
118
- 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;
119
112
  return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(Select, _ref2.cn("Select", _objectSpread(_objectSpread({}, other), {}, {
120
113
  "interaction": "focus",
121
- "size": size ? MAP_SIZE_SELECT[size] : false,
114
+ "size": size,
122
115
  "onChange": callAllEventHandlers(onSelect, this.handleSelect),
123
116
  "onVisibleChange": callAllEventHandlers(onVisibleChange, this.handleVisibleChange),
124
117
  "visible": visible,
125
- "value": timeValue
118
+ "value": time,
119
+ "defaultHighlightedIndex": time ? null : 0
126
120
  })), /* @__PURE__ */ React.createElement(SPickerInput, _ref2.cn("SPickerInput", _objectSpread({}, assignProps({
127
121
  "tag": Input.Value,
128
122
  "ref": this.inputRef,
@@ -131,21 +125,24 @@ var ItemPicker = /* @__PURE__ */ (function(_Component) {
131
125
  "disabled": disabled,
132
126
  "neighborLocation": false,
133
127
  "value": value,
134
- "aria-label": this.getAriaLabel(),
128
+ "aria-label": ariaLabel,
135
129
  "onChange": this.handleChange,
136
130
  "onBlur": this.handleBlur,
137
131
  "onKeyDown": this.handleKeyDown
138
132
  }, _ref)))), /* @__PURE__ */ React.createElement(Select.Menu, {
139
133
  hMax: 180
140
- }, getOptions(min, max, step)));
134
+ }, getOptions(this.minMax, step)));
141
135
  }
142
136
  }]);
143
137
  })(Component);
144
- _defineProperty(ItemPicker, "defaultProps", {
145
- placeholder: "00",
146
- offset: defaultPopperOffset
138
+ _defineProperty(AbstractPickerInput, "style", style);
139
+ _defineProperty(AbstractPickerInput, "defaultProps", function(_) {
140
+ return {
141
+ placeholder: "00",
142
+ offset: [-8, 4]
143
+ };
147
144
  });
148
- var Hours = /* @__PURE__ */ (function(_ItemPicker2) {
145
+ var Hours = /* @__PURE__ */ (function(_AbstractPickerInput2) {
149
146
  function Hours2() {
150
147
  var _this2;
151
148
  _classCallCheck(this, Hours2);
@@ -153,14 +150,13 @@ var Hours = /* @__PURE__ */ (function(_ItemPicker2) {
153
150
  args[_key2] = arguments[_key2];
154
151
  }
155
152
  _this2 = _callSuper(this, Hours2, [].concat(args));
156
- _defineProperty(_this2, "field", "hours");
157
153
  _defineProperty(_this2, "handleKeyDown", function(event) {
158
154
  var currentTarget = event.currentTarget;
159
155
  if (event.key === "Enter") {
160
156
  _this2.submitChanges(event);
161
157
  }
162
158
  if (event.key === "ArrowRight") {
163
- if (currentTarget.selectionStart >= currentTarget.value.length && currentTarget.selectionStart === currentTarget.selectionEnd) {
159
+ if (currentTarget.selectionStart && currentTarget.selectionStart >= currentTarget.value.length && currentTarget.selectionStart === currentTarget.selectionEnd) {
164
160
  event.preventDefault();
165
161
  _this2.focusNext();
166
162
  }
@@ -168,16 +164,17 @@ var Hours = /* @__PURE__ */ (function(_ItemPicker2) {
168
164
  });
169
165
  return _this2;
170
166
  }
171
- _inherits(Hours2, _ItemPicker2);
167
+ _inherits(Hours2, _AbstractPickerInput2);
172
168
  return _createClass(Hours2, [{
169
+ key: "field",
170
+ get: function get() {
171
+ return "hours";
172
+ }
173
+ }, {
173
174
  key: "minMax",
174
- value: function minMax() {
175
+ get: function get() {
175
176
  var is12Hour = this.asProps.is12Hour;
176
- if (is12Hour) {
177
- return [1, 12];
178
- } else {
179
- return [0, 23];
180
- }
177
+ return is12Hour ? [1, 12] : [0, 23];
181
178
  }
182
179
  }, {
183
180
  key: "focusNext",
@@ -191,7 +188,7 @@ var Hours = /* @__PURE__ */ (function(_ItemPicker2) {
191
188
  }
192
189
  }, {
193
190
  key: "componentDidUpdate",
194
- value: function componentDidUpdate(_prevProps, prevState) {
191
+ value: function componentDidUpdate(_, prevState) {
195
192
  var dirtyValue = this.state.dirtyValue;
196
193
  if (prevState.dirtyValue === void 0 || dirtyValue === void 0) return;
197
194
  if (prevState.dirtyValue.length === 1 && dirtyValue.length === 2) {
@@ -199,14 +196,13 @@ var Hours = /* @__PURE__ */ (function(_ItemPicker2) {
199
196
  }
200
197
  }
201
198
  }]);
202
- })(ItemPicker);
203
- _defineProperty(Hours, "defaultProps", function(_ref3) {
204
- var size = _ref3.size;
205
- return _objectSpread(_objectSpread({}, ItemPicker.defaultProps), {}, {
206
- 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
207
203
  });
208
204
  });
209
- var Minutes = /* @__PURE__ */ (function(_ItemPicker3) {
205
+ var Minutes = /* @__PURE__ */ (function(_AbstractPickerInput3) {
210
206
  function Minutes2() {
211
207
  var _this3;
212
208
  _classCallCheck(this, Minutes2);
@@ -214,11 +210,10 @@ var Minutes = /* @__PURE__ */ (function(_ItemPicker3) {
214
210
  args[_key3] = arguments[_key3];
215
211
  }
216
212
  _this3 = _callSuper(this, Minutes2, [].concat(args));
217
- _defineProperty(_this3, "field", "minutes");
218
213
  _defineProperty(_this3, "handleKeyDown", function(event) {
219
214
  var currentTarget = event.currentTarget;
220
215
  if (event.key === "ArrowLeft") {
221
- if (currentTarget.selectionStart <= 0 && currentTarget.selectionStart === currentTarget.selectionEnd) {
216
+ if (currentTarget.selectionStart && currentTarget.selectionStart <= 0 && currentTarget.selectionStart === currentTarget.selectionEnd) {
222
217
  event.preventDefault();
223
218
  _this3.focusPrev();
224
219
  }
@@ -233,10 +228,15 @@ var Minutes = /* @__PURE__ */ (function(_ItemPicker3) {
233
228
  });
234
229
  return _this3;
235
230
  }
236
- _inherits(Minutes2, _ItemPicker3);
231
+ _inherits(Minutes2, _AbstractPickerInput3);
237
232
  return _createClass(Minutes2, [{
233
+ key: "field",
234
+ get: function get() {
235
+ return "minutes";
236
+ }
237
+ }, {
238
238
  key: "minMax",
239
- value: function minMax() {
239
+ get: function get() {
240
240
  return [0, 59];
241
241
  }
242
242
  }, {
@@ -250,11 +250,10 @@ var Minutes = /* @__PURE__ */ (function(_ItemPicker3) {
250
250
  }
251
251
  }
252
252
  }]);
253
- })(ItemPicker);
254
- _defineProperty(Minutes, "defaultProps", function(_ref4) {
255
- var size = _ref4.size;
256
- return _objectSpread(_objectSpread({}, ItemPicker.defaultProps), {}, {
257
- 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
258
257
  });
259
258
  });
260
259
  export {
@@ -0,0 +1,11 @@
1
+ SPickerInput[size='m'] {
2
+ width: 19px;
3
+ margin: 0 var(--intergalactic-spacing-2x, 8px);
4
+ padding: 0;
5
+ }
6
+
7
+ SPickerInput[size='l'] {
8
+ width: 21px;
9
+ margin: 0 var(--intergalactic-spacing-2x, 8px);
10
+ padding: 0;
11
+ }
@@ -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_1p1i0_gg_{position:relative;width:auto;outline:0}.___STimePicker_1p1i0_gg_ .___SPickerInput_1p1i0_gg_{box-sizing:content-box;text-align:center;z-index:1;height:1.5em}.___STimePicker_1p1i0_gg_ .___SPickerInput_1p1i0_gg_.__placeholder_1p1i0_gg_{text-overflow:initial}.___STimePicker_1p1i0_gg_ .___SPickerInput_1p1i0_gg_:focus{outline:0;background-color:var(--intergalactic-bg-highlight-focus, rgba(1, 79, 255, 0.116))}@supports (color:color(display-p3 0 0 0%)){.___STimePicker_1p1i0_gg_ .___SPickerInput_1p1i0_gg_:focus{background-color:var(--intergalactic-bg-highlight-focus, rgba(1, 79, 255, 0.116))}@media (color-gamut:p3){.___STimePicker_1p1i0_gg_ .___SPickerInput_1p1i0_gg_:focus{background-color:var(--intergalactic-bg-highlight-focus, color(display-p3 0.12361 0.30547 0.96332 / 0.116))}}}.___STimePicker_1p1i0_gg_.__disabled_1p1i0_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));cursor:default}@supports (color:color(display-p3 0 0 0%)){.___STimePicker_1p1i0_gg_.__disabled_1p1i0_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STimePicker_1p1i0_gg_.__disabled_1p1i0_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STimePickerSeparator_1p1i0_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}.___STimePickerSeparator_1p1i0_gg_.__disabled_1p1i0_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4);pointer-events:none}",
30
+ /*__inner_css_end__*/
31
+ "1p1i0_gg_"
32
+ ), /*__reshadow_css_end__*/
33
+ {
34
+ "__STimePicker": "___STimePicker_1p1i0_gg_",
35
+ "_disabled": "__disabled_1p1i0_gg_",
36
+ "__STimePickerSeparator": "___STimePickerSeparator_1p1i0_gg_",
37
+ "__SPickerInput": "___SPickerInput_1p1i0_gg_",
38
+ "_placeholder": "__placeholder_1p1i0_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,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.524 0.266 263.1 / 0.116));
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
+ }