@semcore/time-picker 4.51.0 → 16.0.0-prerelease.10

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