@semcore/input-number 16.0.1 → 16.0.2-prerelease.3

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.
@@ -2,36 +2,40 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _isNativeReflectConstruct from "@babel/runtime/helpers/esm/isNativeReflectConstruct";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
8
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
8
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
10
  import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
10
- import React from "react";
11
+ import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
12
+ import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
13
+ import { forkRef } from "@semcore/core/lib/utils/ref";
11
14
  import Input from "@semcore/input";
15
+ import React from "react";
12
16
  import { IncrementIcon, DecrementIcon } from "./buttons.mjs";
13
17
  import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
14
- import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
15
- import { forkRef } from "@semcore/core/lib/utils/ref";
16
- import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
18
+ function _callSuper(t, o, e) {
19
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
20
+ }
17
21
  /*!__reshadow-styles__:"./style/input-number.shadow.css"*/
18
22
  var style = (
19
23
  /*__reshadow_css_start__*/
20
24
  (sstyled.insert(
21
25
  /*__inner_css_start__*/
22
- ".___SValue_og6bd_gg_:focus~.___SControls_og6bd_gg_{display:flex}.___SControls_og6bd_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_og6bd_gg_.__showControls_og6bd_gg_{display:flex}.___SDown_og6bd_gg_,.___SUp_og6bd_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_og6bd_gg_:focus,.___SUp_og6bd_gg_:focus{outline:0}@media (hover:hover){.___SDown_og6bd_gg_:hover,.___SUp_og6bd_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_og6bd_gg_{padding-bottom:1px}.___SDown_og6bd_gg_{padding-top:1px}.___SValue_og6bd_gg_::-webkit-inner-spin-button,.___SValue_og6bd_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_og6bd_gg_._type_number_og6bd_gg_{-moz-appearance:textfield}.___SValue_og6bd_gg_.__disabled_og6bd_gg_~.___SControls_og6bd_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_og6bd_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}",
26
+ ".___SValue_tmq0p_gg_:focus~.___SControls_tmq0p_gg_{display:flex}.___SControls_tmq0p_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_tmq0p_gg_.__showControls_tmq0p_gg_{display:flex}.___SDown_tmq0p_gg_,.___SUp_tmq0p_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_tmq0p_gg_:focus,.___SUp_tmq0p_gg_:focus{outline:0}@media (hover:hover){.___SDown_tmq0p_gg_:hover,.___SUp_tmq0p_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_tmq0p_gg_{padding-bottom:1px}.___SDown_tmq0p_gg_{padding-top:1px}.___SValue_tmq0p_gg_::-webkit-inner-spin-button,.___SValue_tmq0p_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_tmq0p_gg_._type_number_tmq0p_gg_{-moz-appearance:textfield}.___SValue_tmq0p_gg_.__disabled_tmq0p_gg_~.___SControls_tmq0p_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_tmq0p_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}",
23
27
  /*__inner_css_end__*/
24
- "og6bd_gg_"
28
+ "tmq0p_gg_"
25
29
  ), /*__reshadow_css_end__*/
26
30
  {
27
- "__SValue": "___SValue_og6bd_gg_",
28
- "__SControls": "___SControls_og6bd_gg_",
29
- "_showControls": "__showControls_og6bd_gg_",
30
- "__SUp": "___SUp_og6bd_gg_",
31
- "__SDown": "___SDown_og6bd_gg_",
32
- "_disabled": "__disabled_og6bd_gg_",
33
- "__SValueHidden": "___SValueHidden_og6bd_gg_",
34
- "_type_number": "_type_number_og6bd_gg_"
31
+ "__SValue": "___SValue_tmq0p_gg_",
32
+ "__SControls": "___SControls_tmq0p_gg_",
33
+ "_showControls": "__showControls_tmq0p_gg_",
34
+ "__SUp": "___SUp_tmq0p_gg_",
35
+ "__SDown": "___SDown_tmq0p_gg_",
36
+ "_disabled": "__disabled_tmq0p_gg_",
37
+ "__SValueHidden": "___SValueHidden_tmq0p_gg_",
38
+ "_type_number": "_type_number_tmq0p_gg_"
35
39
  })
36
40
  );
37
41
  function parseValueWithMinMax(value) {
@@ -40,27 +44,26 @@ function parseValueWithMinMax(value) {
40
44
  return Math.max(min, Math.min(max, value));
41
45
  }
42
46
  var InputNumber = /* @__PURE__ */ function(_Component) {
43
- _inherits(InputNumber2, _Component);
44
- var _super = _createSuper(InputNumber2);
45
47
  function InputNumber2() {
46
48
  var _this;
47
49
  _classCallCheck(this, InputNumber2);
48
50
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
49
51
  args[_key] = arguments[_key];
50
52
  }
51
- _this = _super.call.apply(_super, [this].concat(args));
52
- _defineProperty(_assertThisInitialized(_this), "inputRef", /* @__PURE__ */ React.createRef());
53
- _defineProperty(_assertThisInitialized(_this), "increment", function(event) {
53
+ _this = _callSuper(this, InputNumber2, [].concat(args));
54
+ _defineProperty(_this, "inputRef", /* @__PURE__ */ React.createRef());
55
+ _defineProperty(_this, "increment", function(event) {
54
56
  var _this$inputRef$curren, _this$inputRef$curren2;
55
- (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : (_this$inputRef$curren2 = _this$inputRef$curren.stepUp) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.call(_this$inputRef$curren, event);
57
+ (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 || (_this$inputRef$curren2 = _this$inputRef$curren.stepUp) === null || _this$inputRef$curren2 === void 0 || _this$inputRef$curren2.call(_this$inputRef$curren, event);
56
58
  });
57
- _defineProperty(_assertThisInitialized(_this), "decrement", function(event) {
59
+ _defineProperty(_this, "decrement", function(event) {
58
60
  var _this$inputRef$curren3, _this$inputRef$curren4;
59
- (_this$inputRef$curren3 = _this.inputRef.current) === null || _this$inputRef$curren3 === void 0 ? void 0 : (_this$inputRef$curren4 = _this$inputRef$curren3.stepDown) === null || _this$inputRef$curren4 === void 0 ? void 0 : _this$inputRef$curren4.call(_this$inputRef$curren3, event);
61
+ (_this$inputRef$curren3 = _this.inputRef.current) === null || _this$inputRef$curren3 === void 0 || (_this$inputRef$curren4 = _this$inputRef$curren3.stepDown) === null || _this$inputRef$curren4 === void 0 || _this$inputRef$curren4.call(_this$inputRef$curren3, event);
60
62
  });
61
63
  return _this;
62
64
  }
63
- _createClass(InputNumber2, [{
65
+ _inherits(InputNumber2, _Component);
66
+ return _createClass(InputNumber2, [{
64
67
  key: "getValueProps",
65
68
  value: function getValueProps() {
66
69
  var numberFormatter = new Intl.NumberFormat(this.asProps.locale, {
@@ -92,7 +95,6 @@ var InputNumber = /* @__PURE__ */ function(_Component) {
92
95
  return _ref4 = sstyled(this.asProps.style), /* @__PURE__ */ React.createElement(SInputNumber, _ref4.cn("SInputNumber", _objectSpread({}, assignProps({}, _ref))));
93
96
  }
94
97
  }]);
95
- return InputNumber2;
96
98
  }(Component);
97
99
  _defineProperty(InputNumber, "displayName", "InputNumber");
98
100
  _defineProperty(InputNumber, "style", style);
@@ -103,21 +105,19 @@ _defineProperty(InputNumber, "defaultProps", {
103
105
  locale: "en"
104
106
  });
105
107
  var Value = /* @__PURE__ */ function(_Component2) {
106
- _inherits(Value2, _Component2);
107
- var _super2 = _createSuper(Value2);
108
108
  function Value2() {
109
109
  var _this2;
110
110
  _classCallCheck(this, Value2);
111
111
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
112
112
  args[_key2] = arguments[_key2];
113
113
  }
114
- _this2 = _super2.call.apply(_super2, [this].concat(args));
115
- _defineProperty(_assertThisInitialized(_this2), "valueInputRef", /* @__PURE__ */ React.createRef());
116
- _defineProperty(_assertThisInitialized(_this2), "cursorPosition", -1);
117
- _defineProperty(_assertThisInitialized(_this2), "getFormattedValue", function(value) {
114
+ _this2 = _callSuper(this, Value2, [].concat(args));
115
+ _defineProperty(_this2, "valueInputRef", /* @__PURE__ */ React.createRef());
116
+ _defineProperty(_this2, "cursorPosition", -1);
117
+ _defineProperty(_this2, "getFormattedValue", function(value) {
118
118
  return value.replace(new RegExp("[".concat(_this2.separatorThousands, "]"), "g"), "").replace(_this2.separatorDecimal, ".");
119
119
  });
120
- _defineProperty(_assertThisInitialized(_this2), "valueParser", function(value, prevValue, prevDisplayValue) {
120
+ _defineProperty(_this2, "valueParser", function(value, prevValue, prevDisplayValue) {
121
121
  var numberFormatter = _this2.props.numberFormatter;
122
122
  var stringNumber = _this2.getFormattedValue(String(value));
123
123
  if (Number.isNaN(Number(stringNumber))) {
@@ -138,7 +138,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
138
138
  displayValue
139
139
  };
140
140
  });
141
- _defineProperty(_assertThisInitialized(_this2), "handleValidation", function(event) {
141
+ _defineProperty(_this2, "handleValidation", function(event) {
142
142
  var _this2$asProps = _this2.asProps, value = _this2$asProps.value, displayValue = _this2$asProps.displayValue, min = _this2$asProps.min, max = _this2$asProps.max, step = _this2$asProps.step;
143
143
  var _this2$valueParser = _this2.valueParser(event.currentTarget.value, value, displayValue), parsedValue = _this2$valueParser.parsedValue;
144
144
  var roundCoefficient = step < 1 ? step.toString().split(".")[1].length : 1;
@@ -159,10 +159,10 @@ var Value = /* @__PURE__ */ function(_Component2) {
159
159
  _this2.handlers.value(String(numberValueRounded), event);
160
160
  }
161
161
  });
162
- _defineProperty(_assertThisInitialized(_this2), "onWheel", function(event) {
162
+ _defineProperty(_this2, "onWheel", function(event) {
163
163
  callAllEventHandlers(_this2.asProps.onWheel, _this2.handleWheel)(event);
164
164
  });
165
- _defineProperty(_assertThisInitialized(_this2), "handleWheel", function(event) {
165
+ _defineProperty(_this2, "handleWheel", function(event) {
166
166
  if (event.target !== _this2.valueInputRef.current) return;
167
167
  if (document.activeElement !== _this2.valueInputRef.current) return;
168
168
  event.preventDefault();
@@ -172,7 +172,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
172
172
  _this2.stepDown(event);
173
173
  }
174
174
  });
175
- _defineProperty(_assertThisInitialized(_this2), "handleChange", function(event) {
175
+ _defineProperty(_this2, "handleChange", function(event) {
176
176
  var value = _this2.getFormattedValue(event.currentTarget.value);
177
177
  var _this2$asProps2 = _this2.asProps, numberFormatter = _this2$asProps2.numberFormatter, prevValue = _this2$asProps2.value;
178
178
  if (value === "." || value === "-") {
@@ -196,12 +196,12 @@ var Value = /* @__PURE__ */ function(_Component2) {
196
196
  _this2.handlers.value(value, event);
197
197
  }
198
198
  });
199
- _defineProperty(_assertThisInitialized(_this2), "handleKeyUp", function(event) {
199
+ _defineProperty(_this2, "handleKeyUp", function(event) {
200
200
  if (event.key === "Shift") {
201
201
  _this2.cursorPosition = -1;
202
202
  }
203
203
  });
204
- _defineProperty(_assertThisInitialized(_this2), "handleKeyDown", function(event) {
204
+ _defineProperty(_this2, "handleKeyDown", function(event) {
205
205
  var element = event.currentTarget;
206
206
  var value = element.value;
207
207
  var length = value.length;
@@ -258,7 +258,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
258
258
  }
259
259
  }
260
260
  });
261
- _defineProperty(_assertThisInitialized(_this2), "moveSelectionLeft", function(element, cursorIndex) {
261
+ _defineProperty(_this2, "moveSelectionLeft", function(element, cursorIndex) {
262
262
  var value = element.value;
263
263
  var nextPosition = element.selectionStart - 1 >= 0 ? element.selectionStart - 1 : 0;
264
264
  var cursorPosition = value[element.selectionStart - cursorIndex] === _this2.separatorThousands ? element.selectionStart - cursorIndex : nextPosition;
@@ -272,7 +272,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
272
272
  }
273
273
  }
274
274
  });
275
- _defineProperty(_assertThisInitialized(_this2), "moveSelectionRight", function(element, cursorIndex) {
275
+ _defineProperty(_this2, "moveSelectionRight", function(element, cursorIndex) {
276
276
  var value = element.value;
277
277
  var nextPosition = element.selectionEnd + 1;
278
278
  var cursorPosition = value[element.selectionEnd] === _this2.separatorThousands ? element.selectionEnd + cursorIndex : nextPosition;
@@ -286,18 +286,18 @@ var Value = /* @__PURE__ */ function(_Component2) {
286
286
  }
287
287
  }
288
288
  });
289
- _defineProperty(_assertThisInitialized(_this2), "handleClick", function(event) {
289
+ _defineProperty(_this2, "handleClick", function(event) {
290
290
  var element = event.target;
291
291
  var value = element.value;
292
292
  if (value[element.selectionStart - 1] === _this2.separatorThousands) {
293
293
  element.setSelectionRange(element.selectionStart - 1, element.selectionEnd - 1);
294
294
  }
295
295
  });
296
- _defineProperty(_assertThisInitialized(_this2), "handleBlur", function(event) {
296
+ _defineProperty(_this2, "handleBlur", function(event) {
297
297
  _this2.cursorPosition = -1;
298
298
  _this2.handleValidation(event);
299
299
  });
300
- _defineProperty(_assertThisInitialized(_this2), "stepUp", function(event) {
300
+ _defineProperty(_this2, "stepUp", function(event) {
301
301
  var _this2$asProps3 = _this2.asProps, _this2$asProps3$max = _this2$asProps3.max, max = _this2$asProps3$max === void 0 ? Number.MAX_SAFE_INTEGER : _this2$asProps3$max, min = _this2$asProps3.min, step = _this2$asProps3.step, value = _this2$asProps3.value;
302
302
  var numberValue;
303
303
  if (value === "") {
@@ -310,7 +310,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
310
310
  _this2.handlers.value(newValue.toString(), event);
311
311
  }
312
312
  });
313
- _defineProperty(_assertThisInitialized(_this2), "stepDown", function(event) {
313
+ _defineProperty(_this2, "stepDown", function(event) {
314
314
  var _this2$asProps4 = _this2.asProps, max = _this2$asProps4.max, _this2$asProps4$min = _this2$asProps4.min, min = _this2$asProps4$min === void 0 ? Number.MIN_SAFE_INTEGER : _this2$asProps4$min, step = _this2$asProps4.step, value = _this2$asProps4.value;
315
315
  var numberValue;
316
316
  if (value === "") {
@@ -325,7 +325,8 @@ var Value = /* @__PURE__ */ function(_Component2) {
325
325
  });
326
326
  return _this2;
327
327
  }
328
- _createClass(Value2, [{
328
+ _inherits(Value2, _Component2);
329
+ return _createClass(Value2, [{
329
330
  key: "uncontrolledProps",
330
331
  value: function uncontrolledProps() {
331
332
  var _this3 = this;
@@ -363,7 +364,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
363
364
  // https://stackoverflow.com/questions/57358640/cancel-wheel-event-with-e-preventdefault-in-react-event-bubbling
364
365
  function componentDidMount() {
365
366
  var _this$valueInputRef$c;
366
- (_this$valueInputRef$c = this.valueInputRef.current) === null || _this$valueInputRef$c === void 0 ? void 0 : _this$valueInputRef$c.addEventListener("wheel", this.onWheel);
367
+ (_this$valueInputRef$c = this.valueInputRef.current) === null || _this$valueInputRef$c === void 0 || _this$valueInputRef$c.addEventListener("wheel", this.onWheel);
367
368
  var _this$asProps2 = this.asProps, inputRef = _this$asProps2.inputRef, value = _this$asProps2.value;
368
369
  if (inputRef.current) {
369
370
  inputRef.current.stepUp = this.stepUp;
@@ -387,7 +388,7 @@ var Value = /* @__PURE__ */ function(_Component2) {
387
388
  key: "componentWillUnmount",
388
389
  value: function componentWillUnmount() {
389
390
  var _this$valueInputRef$c2;
390
- (_this$valueInputRef$c2 = this.valueInputRef.current) === null || _this$valueInputRef$c2 === void 0 ? void 0 : _this$valueInputRef$c2.removeEventListener("wheel", this.onWheel);
391
+ (_this$valueInputRef$c2 = this.valueInputRef.current) === null || _this$valueInputRef$c2 === void 0 || _this$valueInputRef$c2.removeEventListener("wheel", this.onWheel);
391
392
  }
392
393
  }, {
393
394
  key: "render",
@@ -411,7 +412,6 @@ var Value = /* @__PURE__ */ function(_Component2) {
411
412
  }, _ref2)))));
412
413
  }
413
414
  }]);
414
- return Value2;
415
415
  }(Component);
416
416
  _defineProperty(Value, "style", style);
417
417
  _defineProperty(Value, "defaultProps", {
@@ -6,12 +6,12 @@ import it from "./it.json.mjs";
6
6
  import ja from "./ja.json.mjs";
7
7
  import ko from "./ko.json.mjs";
8
8
  import nl from "./nl.json.mjs";
9
+ import pl from "./pl.json.mjs";
9
10
  import pt from "./pt.json.mjs";
11
+ import sv from "./sv.json.mjs";
10
12
  import tr from "./tr.json.mjs";
11
13
  import vi from "./vi.json.mjs";
12
14
  import zh from "./zh.json.mjs";
13
- import pl from "./pl.json.mjs";
14
- import sv from "./sv.json.mjs";
15
15
  var localizedMessages = {
16
16
  de,
17
17
  en,
@@ -1,6 +1,6 @@
1
- import React from 'react';
2
- import { Intergalactic, PropGetterFn, UnknownProperties } from '@semcore/core';
3
- import { InputAddonProps, InputProps, InputValueProps } from '@semcore/input';
1
+ import type { Intergalactic, PropGetterFn, UnknownProperties } from '@semcore/core';
2
+ import type { InputAddonProps, InputProps, InputValueProps } from '@semcore/input';
3
+ import type React from 'react';
4
4
 
5
5
  export type InputNumberValue = string;
6
6
  export type InputNumberSize = 'm' | 'l';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/input-number",
3
3
  "description": "Semrush InputNumber Component",
4
- "version": "16.0.1",
4
+ "version": "16.0.2-prerelease.3",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,11 +14,11 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/input": "16.0.1",
18
- "@semcore/flex-box": "16.0.1"
17
+ "@semcore/input": "16.0.2-prerelease.3",
18
+ "@semcore/flex-box": "16.0.2-prerelease.3"
19
19
  },
20
20
  "peerDependencies": {
21
- "@semcore/base-components": "^16.0.0"
21
+ "@semcore/base-components": "^16.0.2-prerelease.3"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "directory": "semcore/input-number"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/react": "18.0.21",
29
+ "@semcore/core": "16.0.0",
30
30
  "@semcore/testing-utils": "1.0.0"
31
31
  },
32
32
  "scripts": {