@semcore/inline-input 4.17.0 → 4.17.2-prerelease.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,19 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [4.17.0-prerelease.1] - 2023-11-13
5
+ ## [4.17.2-prerelease.1] - 2023-11-24
6
+
7
+ ### Changed
8
+
9
+ - Version prepatch update due to children dependencies update (`@semcore/flex-box` [5.10.2 ~> 5.11.0], `@semcore/icon` [4.16.1 ~> 4.17.0], `@semcore/tooltip` [6.10.3 ~> 6.10.4], `@semcore/utils` [4.10.3 ~> 4.13.0], `@semcore/input-number` [5.12.2 ~> 5.13.0], `@semcore/core` [2.9.2 ~> 2.10.0]).
10
+
11
+ ## [4.17.1] - 2023-11-21
12
+
13
+ ### Changed
14
+
15
+ - Version prepatch update due to children dependencies update (`@semcore/flex-box` [5.10.1 ~> 5.10.2], `@semcore/icon` [4.16.0 ~> 4.16.1], `@semcore/utils` [4.10.2 ~> 4.10.3], `@semcore/core` [2.9.1 ~> 2.9.2]).
16
+
17
+ ## [4.17.0] - 2023-11-13
6
18
 
7
19
  ### Changed
8
20
 
@@ -23,23 +23,31 @@ var _m2 = _interopRequireDefault(require("@semcore/icon/Close/m"));
23
23
  var _spin = _interopRequireDefault(require("@semcore/spin"));
24
24
  var _intergalacticDynamicLocales = require("./translations/__intergalactic-dynamic-locales");
25
25
  var _i18nEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/i18nEnhance"));
26
+ var _input = _interopRequireDefault(require("@semcore/input"));
27
+ var _inputNumber = require("@semcore/input-number");
26
28
  /*__reshadow-styles__:"./style/inline-input.shadow.css"*/
27
- var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SInlineInput_81jea_gg_{display:inline-flex;width:100%;height:100%;align-items:center;position:relative;z-index:0;vertical-align:middle;padding:1px;box-sizing:border-box;background-color:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SInlineInput_81jea_gg_.__disabled_81jea_gg_{cursor:default;pointer-events:none;opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SValue_81jea_gg_{min-width:0;width:100%;height:100%;padding:0 var(--intergalactic-spacing-1x, 4px);border:0;box-sizing:border-box;color:var(--intergalactic-text-primary, #191b23);font-size:inherit;line-height:1.2;text-overflow:ellipsis;font-family:inherit;background:0 0;min-height:1em}.___SValue_81jea_gg_:focus{outline:0}.___SValue_81jea_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SValue_81jea_gg_::placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SValue_81jea_gg_.__disabled_81jea_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SUnderline_81jea_gg_{display:flex;flex-direction:row;align-items:center;flex-grow:1;width:100%;height:100%;min-height:1em;border:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SAddon_81jea_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:var(--intergalactic-icon-secondary-neutral, #a9abb6);padding:0 var(--intergalactic-spacing-1x, 4px)}.___SAddon_81jea_gg_.__disabled_81jea_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SConfirmIcon_81jea_gg_{color:var(--intergalactic-icon-secondary-success, #00c192);cursor:pointer}@media (hover:hover){.___SConfirmIcon_81jea_gg_:hover{color:var(--intergalactic-icon-secondary-success-hover-active, #049B75)}}.___SCancelIcon_81jea_gg_{color:var(--intergalactic-icon-secondary-neutral, #a9abb6);cursor:pointer}@media (hover:hover){.___SCancelIcon_81jea_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SInlineInput_81jea_gg_.__focused_81jea_gg_{z-index:1}.___SInlineInput_81jea_gg_.__focused_81jea_gg_ .___SUnderline_81jea_gg_{border-bottom-color:var(--intergalactic-border-info-active, #006dca);box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SInlineInput_81jea_gg_._state_valid_81jea_gg_ .___SUnderline_81jea_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65)}.___SInlineInput_81jea_gg_._state_valid_81jea_gg_.__focused_81jea_gg_ .___SUnderline_81jea_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65);box-shadow:var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px rgba(0, 159, 129, 0.5))}.___SInlineInput_81jea_gg_._state_invalid_81jea_gg_ .___SUnderline_81jea_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f)}.___SInlineInput_81jea_gg_._state_invalid_81jea_gg_.__focused_81jea_gg_ .___SUnderline_81jea_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f);box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.5))}" /*__inner_css_end__*/, "81jea_gg_") /*__reshadow_css_end__*/, {
28
- "__SInlineInput": "___SInlineInput_81jea_gg_",
29
- "_disabled": "__disabled_81jea_gg_",
30
- "__SUnderline": "___SUnderline_81jea_gg_",
31
- "__SAddon": "___SAddon_81jea_gg_",
32
- "__SConfirmIcon": "___SConfirmIcon_81jea_gg_",
33
- "__SCancelIcon": "___SCancelIcon_81jea_gg_",
34
- "_focused": "__focused_81jea_gg_",
35
- "_state_valid": "_state_valid_81jea_gg_",
36
- "_state_invalid": "_state_invalid_81jea_gg_",
37
- "__SValue": "___SValue_81jea_gg_"
29
+ var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SInlineInput_wt2a7_gg_{display:inline-flex;width:100%;height:100%;align-items:center;position:relative;z-index:0;vertical-align:middle;padding:1px;box-sizing:border-box;background-color:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SInlineInput_wt2a7_gg_.__disabled_wt2a7_gg_{cursor:default;pointer-events:none;opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SValue_wt2a7_gg_{min-width:0;width:100%;height:100%;padding:0 var(--intergalactic-spacing-1x, 4px);border:0;box-sizing:border-box;color:var(--intergalactic-text-primary, #191b23);font-size:inherit;line-height:1.2;text-overflow:ellipsis;font-family:inherit;background:0 0;min-height:1em}.___SValue_wt2a7_gg_:focus{outline:0}.___SValue_wt2a7_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SValue_wt2a7_gg_::placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SValue_wt2a7_gg_.__disabled_wt2a7_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SValue_wt2a7_gg_::-webkit-inner-spin-button,.___SValue_wt2a7_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_wt2a7_gg_._type_number_wt2a7_gg_{-moz-appearance:textfield}.___SUnderline_wt2a7_gg_{display:flex;flex-direction:row;align-items:center;flex-grow:1;width:100%;height:100%;min-height:1em;border:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SAddon_wt2a7_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:var(--intergalactic-icon-secondary-neutral, #a9abb6);padding:0 var(--intergalactic-spacing-1x, 4px)}.___SAddon_wt2a7_gg_.__disabled_wt2a7_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SConfirmIcon_wt2a7_gg_{color:var(--intergalactic-icon-secondary-success, #00c192);cursor:pointer}@media (hover:hover){.___SConfirmIcon_wt2a7_gg_:hover{color:var(--intergalactic-icon-secondary-success-hover-active, #049B75)}}.___SCancelIcon_wt2a7_gg_{color:var(--intergalactic-icon-secondary-neutral, #a9abb6);cursor:pointer}@media (hover:hover){.___SCancelIcon_wt2a7_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SInlineInput_wt2a7_gg_.__focused_wt2a7_gg_{z-index:1}.___SInlineInput_wt2a7_gg_.__focused_wt2a7_gg_ .___SUnderline_wt2a7_gg_{border-bottom-color:var(--intergalactic-border-info-active, #006dca);box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SInlineInput_wt2a7_gg_._state_valid_wt2a7_gg_ .___SUnderline_wt2a7_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65)}.___SInlineInput_wt2a7_gg_._state_valid_wt2a7_gg_.__focused_wt2a7_gg_ .___SUnderline_wt2a7_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65);box-shadow:var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px rgba(0, 159, 129, 0.5))}.___SInlineInput_wt2a7_gg_._state_invalid_wt2a7_gg_ .___SUnderline_wt2a7_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f)}.___SInlineInput_wt2a7_gg_._state_invalid_wt2a7_gg_.__focused_wt2a7_gg_ .___SUnderline_wt2a7_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f);box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.5))}.___SValue_wt2a7_gg_:focus~.___SControls_wt2a7_gg_{display:flex}.___SControls_wt2a7_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_wt2a7_gg_.__showControls_wt2a7_gg_{display:flex}.___SDown_wt2a7_gg_,.___SUp_wt2a7_gg_{padding:0;width:16px;color:var(--intergalactic-icon-secondary-neutral, #a9abb6);box-sizing:border-box;display:inline-flex;justify-content:center;border:0;background:0 0;cursor:pointer}.___SDown_wt2a7_gg_:focus,.___SUp_wt2a7_gg_:focus{outline:0}@media (hover:hover){.___SDown_wt2a7_gg_:hover,.___SUp_wt2a7_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_wt2a7_gg_{padding-bottom:1px}.___SDown_wt2a7_gg_{padding-top:1px}.___SValue_wt2a7_gg_.__disabled_wt2a7_gg_~.___SControls_wt2a7_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_wt2a7_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}" /*__inner_css_end__*/, "wt2a7_gg_") /*__reshadow_css_end__*/, {
30
+ "__SInlineInput": "___SInlineInput_wt2a7_gg_",
31
+ "_disabled": "__disabled_wt2a7_gg_",
32
+ "__SUnderline": "___SUnderline_wt2a7_gg_",
33
+ "__SAddon": "___SAddon_wt2a7_gg_",
34
+ "__SConfirmIcon": "___SConfirmIcon_wt2a7_gg_",
35
+ "__SCancelIcon": "___SCancelIcon_wt2a7_gg_",
36
+ "_focused": "__focused_wt2a7_gg_",
37
+ "_state_valid": "_state_valid_wt2a7_gg_",
38
+ "_state_invalid": "_state_invalid_wt2a7_gg_",
39
+ "__SValue": "___SValue_wt2a7_gg_",
40
+ "__SControls": "___SControls_wt2a7_gg_",
41
+ "_showControls": "__showControls_wt2a7_gg_",
42
+ "__SUp": "___SUp_wt2a7_gg_",
43
+ "__SDown": "___SDown_wt2a7_gg_",
44
+ "__SValueHidden": "___SValueHidden_wt2a7_gg_",
45
+ "_type_number": "_type_number_wt2a7_gg_"
38
46
  });
39
- var pointInsideOfRect = function pointInsideOfRect(_ref13) {
40
- var x = _ref13.x,
41
- y = _ref13.y,
42
- rect = _ref13.rect;
47
+ var pointInsideOfRect = function pointInsideOfRect(_ref17) {
48
+ var x = _ref17.x,
49
+ y = _ref17.y,
50
+ rect = _ref17.rect;
43
51
  return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
44
52
  };
45
53
  var InlineInputBase = /*#__PURE__*/function (_Component) {
@@ -57,6 +65,7 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
57
65
  });
58
66
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rootRef", /*#__PURE__*/_react["default"].createRef());
59
67
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef", /*#__PURE__*/_react["default"].createRef());
68
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputHandlersRef", /*#__PURE__*/_react["default"].createRef());
60
69
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "initValue", '');
61
70
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "lastMouseDownPosition", null);
62
71
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "lastHandledKeyboardEvent", -1);
@@ -70,6 +79,19 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
70
79
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDocumentKeyDown", function () {
71
80
  _this.lastMouseDownPosition = null;
72
81
  });
82
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "increment", function (event) {
83
+ var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3, _this$inputHandlersRe, _this$inputRef$curren4;
84
+ // https://stackoverflow.com/questions/68010124/safari-number-input-stepup-stepdown-not-functioning-with-empty-value
85
+ if (((_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.value) === '') _this.inputRef.current.value = _this.inputRef.current.min || '0';
86
+ (_this$inputRef$curren2 = _this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : (_this$inputRef$curren3 = _this$inputRef$curren2.stepUp) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.call(_this$inputRef$curren2);
87
+ (_this$inputHandlersRe = _this.inputHandlersRef.current) === null || _this$inputHandlersRe === void 0 ? void 0 : _this$inputHandlersRe.value((_this$inputRef$curren4 = _this.inputRef.current) === null || _this$inputRef$curren4 === void 0 ? void 0 : _this$inputRef$curren4.value, event);
88
+ });
89
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "decrement", function (event) {
90
+ var _this$inputRef$curren5, _this$inputRef$curren6, _this$inputRef$curren7, _this$inputHandlersRe2, _this$inputRef$curren8;
91
+ if (((_this$inputRef$curren5 = _this.inputRef.current) === null || _this$inputRef$curren5 === void 0 ? void 0 : _this$inputRef$curren5.value) === '') _this.inputRef.current.value = _this.inputRef.current.max || '0';
92
+ (_this$inputRef$curren6 = _this.inputRef.current) === null || _this$inputRef$curren6 === void 0 ? void 0 : (_this$inputRef$curren7 = _this$inputRef$curren6.stepDown) === null || _this$inputRef$curren7 === void 0 ? void 0 : _this$inputRef$curren7.call(_this$inputRef$curren6);
93
+ (_this$inputHandlersRe2 = _this.inputHandlersRef.current) === null || _this$inputHandlersRe2 === void 0 ? void 0 : _this$inputHandlersRe2.value((_this$inputRef$curren8 = _this.inputRef.current) === null || _this$inputRef$curren8 === void 0 ? void 0 : _this$inputRef$curren8.value, event);
94
+ });
73
95
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bindHandlerValueFocused", function (focused) {
74
96
  return function () {
75
97
  _this.setState({
@@ -78,9 +100,9 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
78
100
  };
79
101
  });
80
102
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseDownAddon", function (event) {
81
- var _this$inputRef$curren;
103
+ var _this$inputRef$curren9;
82
104
  event.preventDefault();
83
- (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
105
+ (_this$inputRef$curren9 = _this.inputRef.current) === null || _this$inputRef$curren9 === void 0 ? void 0 : _this$inputRef$curren9.focus();
84
106
  });
85
107
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleConfirm", function (text, event) {
86
108
  var _this$asProps$onConfi, _this$asProps;
@@ -91,7 +113,7 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
91
113
  (_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 ? void 0 : _this$asProps$onCance.call(_this$asProps2, prevText, event);
92
114
  });
93
115
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (event) {
94
- var _this$inputRef$curren2, _this$inputRef$curren3;
116
+ var _this$inputRef$curren10, _this$inputRef$curren11;
95
117
  var _this$asProps3 = _this.asProps,
96
118
  onConfirm = _this$asProps3.onConfirm,
97
119
  onCancel = _this$asProps3.onCancel,
@@ -111,7 +133,7 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
111
133
  return;
112
134
  }
113
135
  }
114
- if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren2 = (_this$inputRef$curren3 = _this.inputRef.current) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.value) !== null && _this$inputRef$curren2 !== void 0 ? _this$inputRef$curren2 : '', event);
136
+ if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren10 = (_this$inputRef$curren11 = _this.inputRef.current) === null || _this$inputRef$curren11 === void 0 ? void 0 : _this$inputRef$curren11.value) !== null && _this$inputRef$curren10 !== void 0 ? _this$inputRef$curren10 : '', event);
115
137
  if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
116
138
  });
117
139
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (event) {
@@ -119,8 +141,8 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
119
141
  onConfirm = _this$asProps4.onConfirm,
120
142
  onCancel = _this$asProps4.onCancel;
121
143
  if (event.key === 'Enter') {
122
- var _this$inputRef$curren4, _this$inputRef$curren5;
123
- onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren4 = (_this$inputRef$curren5 = _this.inputRef.current) === null || _this$inputRef$curren5 === void 0 ? void 0 : _this$inputRef$curren5.value) !== null && _this$inputRef$curren4 !== void 0 ? _this$inputRef$curren4 : '', event);
144
+ var _this$inputRef$curren12, _this$inputRef$curren13;
145
+ onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren12 = (_this$inputRef$curren13 = _this.inputRef.current) === null || _this$inputRef$curren13 === void 0 ? void 0 : _this$inputRef$curren13.value) !== null && _this$inputRef$curren12 !== void 0 ? _this$inputRef$curren12 : '', event);
124
146
  _this.lastHandledKeyboardEvent = Date.now();
125
147
  }
126
148
  if (event.key === 'Escape') {
@@ -154,12 +176,12 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
154
176
  }, {
155
177
  key: "getConfirmControlProps",
156
178
  value: function getConfirmControlProps() {
157
- var _this$inputRef$curren6;
179
+ var _this$inputRef$curren14;
158
180
  var _this$asProps5 = this.asProps,
159
181
  loading = _this$asProps5.loading,
160
182
  getI18nText = _this$asProps5.getI18nText;
161
183
  return {
162
- value: (_this$inputRef$curren6 = this.inputRef.current) === null || _this$inputRef$curren6 === void 0 ? void 0 : _this$inputRef$curren6.value,
184
+ value: (_this$inputRef$curren14 = this.inputRef.current) === null || _this$inputRef$curren14 === void 0 ? void 0 : _this$inputRef$curren14.value,
163
185
  loading: loading,
164
186
  onConfirm: this.handleConfirm,
165
187
  getI18nText: getI18nText
@@ -192,11 +214,31 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
192
214
  onBlur: this.bindHandlerValueFocused(false)
193
215
  };
194
216
  }
217
+ }, {
218
+ key: "getNumberValueProps",
219
+ value: function getNumberValueProps() {
220
+ return {
221
+ ref: this.inputRef,
222
+ inputHandlerRefs: this.inputHandlersRef,
223
+ increment: this.increment,
224
+ decrement: this.decrement
225
+ };
226
+ }
227
+ }, {
228
+ key: "getNumberControlsProps",
229
+ value: function getNumberControlsProps() {
230
+ var getI18nText = this.asProps.getI18nText;
231
+ return {
232
+ increment: this.increment,
233
+ decrement: this.decrement,
234
+ getI18nText: getI18nText
235
+ };
236
+ }
195
237
  }, {
196
238
  key: "render",
197
239
  value: function render() {
198
240
  var _ref = this.asProps,
199
- _ref6;
241
+ _ref8;
200
242
  var SInlineInput = _flexBox.Box;
201
243
  var SUnderline = 'div';
202
244
  var _this$asProps7 = this.asProps,
@@ -204,12 +246,12 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
204
246
  styles = _this$asProps7.styles,
205
247
  getI18nText = _this$asProps7.getI18nText;
206
248
  var focused = this.state.focused;
207
- return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInlineInput, _ref6.cn("SInlineInput", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
249
+ return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInlineInput, _ref8.cn("SInlineInput", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
208
250
  "ref": this.rootRef,
209
251
  "focused": focused,
210
252
  "onBlur": this.handleBlur,
211
253
  "aria-label": getI18nText('keyboardHint')
212
- }, _ref))), /*#__PURE__*/_react["default"].createElement(SUnderline, _ref6.cn("SUnderline", {}), /*#__PURE__*/_react["default"].createElement(Children, _ref6.cn("Children", {}))));
254
+ }, _ref))), /*#__PURE__*/_react["default"].createElement(SUnderline, _ref8.cn("SUnderline", {}), /*#__PURE__*/_react["default"].createElement(Children, _ref8.cn("Children", {}))));
213
255
  }
214
256
  }]);
215
257
  return InlineInputBase;
@@ -243,9 +285,9 @@ var Value = /*#__PURE__*/function (_Component2) {
243
285
  key: "render",
244
286
  value: function render() {
245
287
  var _ref2 = this.asProps,
246
- _ref7;
288
+ _ref9;
247
289
  var SValue = _flexBox.Box;
248
- return _ref7 = (0, _core.sstyled)(this.asProps.styles), /*#__PURE__*/_react["default"].createElement(SValue, _ref7.cn("SValue", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
290
+ return _ref9 = (0, _core.sstyled)(this.asProps.styles), /*#__PURE__*/_react["default"].createElement(SValue, _ref9.cn("SValue", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
249
291
  "tag": 'input',
250
292
  "type": 'text'
251
293
  }, _ref2))));
@@ -260,15 +302,15 @@ var Value = /*#__PURE__*/function (_Component2) {
260
302
  (0, _defineProperty2["default"])(Value, "hoistProps", ['disabled']);
261
303
  var Addon = function Addon(props) {
262
304
  var _ref3 = arguments[0],
263
- _ref8;
305
+ _ref10;
264
306
  var SAddon = _flexBox.Box;
265
- return _ref8 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref3))));
307
+ return _ref10 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref10.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref3))));
266
308
  };
267
309
  var ConfirmControl = function ConfirmControl(props) {
268
310
  var _ref4 = arguments[0],
269
- _ref10,
311
+ _ref12,
270
312
  _props$title,
271
- _ref14;
313
+ _ref18;
272
314
  var SAddon = _flexBox.Box;
273
315
  var Children = props.Children,
274
316
  hasChildren = props.children;
@@ -285,17 +327,17 @@ var ConfirmControl = function ConfirmControl(props) {
285
327
  }
286
328
  }, [handleConfirm]);
287
329
  if (props.loading) {
288
- var _ref9;
289
- return _ref9 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref9.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref9.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_spin["default"], _ref9.cn("Spin", {
330
+ var _ref11;
331
+ return _ref11 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref11.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_spin["default"], _ref11.cn("Spin", {
290
332
  "size": 'xs'
291
333
  })));
292
334
  }
293
335
  var sstyles = (0, _core.sstyled)(props.styles);
294
336
  var sConfirmIconStyles = sstyles.cn('SConfirmIcon', {});
295
- return _ref10 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref10.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
337
+ return _ref12 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref12.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
296
338
  "onKeyDown": handleKeydown
297
- }, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_tooltip["default"], _ref10.cn("Tooltip", (0, _objectSpread2["default"])({}, props.$tooltipsProps)), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Trigger, {
298
- tag: (_ref14 = props.icon) !== null && _ref14 !== void 0 ? _ref14 : _m["default"],
339
+ }, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_tooltip["default"], _ref12.cn("Tooltip", (0, _objectSpread2["default"])({}, props.$tooltipsProps)), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Trigger, {
340
+ tag: (_ref18 = props.icon) !== null && _ref18 !== void 0 ? _ref18 : _m["default"],
299
341
  "aria-hidden": "true",
300
342
  role: "button",
301
343
  onClick: handleConfirm,
@@ -307,9 +349,9 @@ var ConfirmControl = function ConfirmControl(props) {
307
349
  };
308
350
  var CancelControl = function CancelControl(props) {
309
351
  var _ref5 = arguments[0],
310
- _ref12,
352
+ _ref14,
311
353
  _props$title2,
312
- _ref15;
354
+ _ref19;
313
355
  var SAddon = _flexBox.Box;
314
356
  var Children = props.Children,
315
357
  hasChildren = props.children;
@@ -326,17 +368,17 @@ var CancelControl = function CancelControl(props) {
326
368
  }
327
369
  }, [handleCancel]);
328
370
  if (props.disabled) {
329
- var _ref11;
330
- return _ref11 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref11.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_m2["default"], _ref11.cn("CloseM", {
371
+ var _ref13;
372
+ return _ref13 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref13.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref13.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_m2["default"], _ref13.cn("CloseM", {
331
373
  "disabled": true
332
374
  })));
333
375
  }
334
376
  var sstyles = (0, _core.sstyled)(props.styles);
335
377
  var sCancelIconStyles = sstyles.cn('SCancelIcon', {});
336
- return _ref12 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref12.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
378
+ return _ref14 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref14.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
337
379
  "onKeyDown": handleKeydown
338
- }, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_tooltip["default"], _ref12.cn("Tooltip", (0, _objectSpread2["default"])({}, props.$tooltipsProps)), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Trigger, {
339
- tag: (_ref15 = props.icon) !== null && _ref15 !== void 0 ? _ref15 : _m2["default"],
380
+ }, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref14.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_tooltip["default"], _ref14.cn("Tooltip", (0, _objectSpread2["default"])({}, props.$tooltipsProps)), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Trigger, {
381
+ tag: (_ref19 = props.icon) !== null && _ref19 !== void 0 ? _ref19 : _m2["default"],
340
382
  "aria-hidden": "true",
341
383
  role: "button",
342
384
  onClick: handleCancel,
@@ -346,13 +388,153 @@ var CancelControl = function CancelControl(props) {
346
388
  p: 3
347
389
  }, title)));
348
390
  };
391
+ var NumberValue = /*#__PURE__*/function (_Component3) {
392
+ (0, _inherits2["default"])(NumberValue, _Component3);
393
+ var _super3 = (0, _createSuper2["default"])(NumberValue);
394
+ function NumberValue() {
395
+ var _this2;
396
+ (0, _classCallCheck2["default"])(this, NumberValue);
397
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
398
+ args[_key2] = arguments[_key2];
399
+ }
400
+ _this2 = _super3.call.apply(_super3, [this].concat(args));
401
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "inputRef", /*#__PURE__*/_react["default"].createRef());
402
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "handleValidation", function (event) {
403
+ var _this2$asProps = _this2.asProps,
404
+ value = _this2$asProps.value,
405
+ min = _this2$asProps.min,
406
+ max = _this2$asProps.max,
407
+ _this2$asProps$step = _this2$asProps.step,
408
+ step = _this2$asProps$step === void 0 ? 1 : _this2$asProps$step;
409
+ var roundCoefficient = step < 1 ? step.toString().split('.')[1].length : 1;
410
+ if (Number.isNaN(event.currentTarget.valueAsNumber)) {
411
+ event.currentTarget.value = '';
412
+ _this2.handlers.value('', event);
413
+ } else if (value !== undefined) {
414
+ var numberValue = (0, _inputNumber.parseValueWithMinMax)(Number.parseFloat(value), min, max);
415
+ var rounded = _this2.round(numberValue % step, step);
416
+ if (rounded !== 0) {
417
+ if (rounded >= step / 2) {
418
+ numberValue += step - rounded;
419
+ } else if (Math.abs(rounded) < step) {
420
+ numberValue -= rounded;
421
+ }
422
+ }
423
+ var numberValueRounded = Number(numberValue.toFixed(roundCoefficient));
424
+ _this2.handlers.value(String(numberValueRounded), event);
425
+ }
426
+ });
427
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "handleWheel", function (event) {
428
+ if (event.target !== _this2.inputRef.current) return;
429
+ if (document.activeElement !== _this2.inputRef.current) return;
430
+ event.preventDefault();
431
+ if (event.deltaY < 0 && _this2.asProps.increment) {
432
+ _this2.asProps.increment(event);
433
+ } else if (event.deltaY > 0 && _this2.asProps.decrement) {
434
+ _this2.asProps.decrement(event);
435
+ }
436
+ });
437
+ return _this2;
438
+ }
439
+ (0, _createClass2["default"])(NumberValue, [{
440
+ key: "uncontrolledProps",
441
+ value: function uncontrolledProps() {
442
+ return {
443
+ value: null
444
+ };
445
+ }
446
+ }, {
447
+ key: "round",
448
+ value: function round(value, step) {
449
+ var countDecimals = Math.floor(step) === step ? 0 : step.toString().split('.')[1].length || 0;
450
+ return countDecimals === 0 ? value : Number.parseFloat(value.toPrecision(countDecimals));
451
+ }
452
+ }, {
453
+ key: "componentDidMount",
454
+ value:
455
+ // https://stackoverflow.com/questions/57358640/cancel-wheel-event-with-e-preventdefault-in-react-event-bubbling
456
+ function componentDidMount() {
457
+ var _this$inputRef$curren15;
458
+ (_this$inputRef$curren15 = this.inputRef.current) === null || _this$inputRef$curren15 === void 0 ? void 0 : _this$inputRef$curren15.addEventListener('wheel', this.handleWheel);
459
+ }
460
+ }, {
461
+ key: "componentWillUnmount",
462
+ value: function componentWillUnmount() {
463
+ var _this$inputRef$curren16;
464
+ (_this$inputRef$curren16 = this.inputRef.current) === null || _this$inputRef$curren16 === void 0 ? void 0 : _this$inputRef$curren16.removeEventListener('wheel', this.handleWheel);
465
+ }
466
+ }, {
467
+ key: "render",
468
+ value: function render() {
469
+ var _ref6 = this.asProps,
470
+ _ref15;
471
+ var SValue = _input["default"].Value;
472
+ var SValueHidden = 'div';
473
+ var _this$asProps8 = this.asProps,
474
+ styles = _this$asProps8.styles,
475
+ inputHandlerRefs = _this$asProps8.inputHandlerRefs,
476
+ value = _this$asProps8.value,
477
+ min = _this$asProps8.min,
478
+ max = _this$asProps8.max;
479
+ if (inputHandlerRefs) {
480
+ // @ts-ignore
481
+ inputHandlerRefs.current = this.handlers;
482
+ }
483
+ return _ref15 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(SValue, _ref15.cn("SValue", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
484
+ "type": 'number',
485
+ "autoComplete": 'off',
486
+ "onBlur": this.handleValidation,
487
+ "onInvalid": this.handleValidation,
488
+ "ref": this.inputRef,
489
+ "aria-valuenow": value,
490
+ "aria-valuemin": min,
491
+ "aria-valuemax": max
492
+ }, _ref6)))), /*#__PURE__*/_react["default"].createElement(SValueHidden, _ref15.cn("SValueHidden", {
493
+ "aria-live": 'polite',
494
+ "aria-atomic": true
495
+ }), value));
496
+ }
497
+ }]);
498
+ return NumberValue;
499
+ }(_core.Component);
500
+ (0, _defineProperty2["default"])(NumberValue, "defaultProps", {
501
+ defaultValue: '',
502
+ step: 1
503
+ });
504
+ function NumberControls(props) {
505
+ var _ref7 = arguments[0],
506
+ _ref16;
507
+ var Children = props.Children,
508
+ increment = props.increment,
509
+ decrement = props.decrement,
510
+ styles = props.styles,
511
+ getI18nText = props.getI18nText;
512
+ var SControls = InlineInput.Addon;
513
+ var SUp = 'button';
514
+ var SDown = 'button';
515
+ return _ref16 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SControls, _ref16.cn("SControls", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
516
+ "aria-hidden": 'true'
517
+ }, _ref7))), /*#__PURE__*/_react["default"].createElement(SUp, _ref16.cn("SUp", {
518
+ "onClick": increment,
519
+ "tabIndex": -1,
520
+ "type": 'button',
521
+ "aria-label": getI18nText('increment')
522
+ }), /*#__PURE__*/_react["default"].createElement(_inputNumber.IncrementIcon, _ref16.cn("IncrementIcon", {}))), /*#__PURE__*/_react["default"].createElement(SDown, _ref16.cn("SDown", {
523
+ "onClick": decrement,
524
+ "tabIndex": -1,
525
+ "type": 'button',
526
+ "aria-label": getI18nText('decrement')
527
+ }), /*#__PURE__*/_react["default"].createElement(_inputNumber.DecrementIcon, _ref16.cn("DecrementIcon", {}))), /*#__PURE__*/_react["default"].createElement(Children, _ref16.cn("Children", {})));
528
+ }
349
529
 
350
530
  /** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
351
531
  var InlineInput = (0, _core["default"])(InlineInputBase, {
352
532
  Addon: Addon,
353
533
  Value: Value,
354
534
  ConfirmControl: ConfirmControl,
355
- CancelControl: CancelControl
535
+ CancelControl: CancelControl,
536
+ NumberValue: NumberValue,
537
+ NumberControls: NumberControls
356
538
  });
357
539
  var _default = InlineInput;
358
540
  exports["default"] = _default;