@semcore/time-picker 16.0.0-prerelease.2 → 16.0.0-prerelease.21

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