@semcore/input-number 5.41.0-prerelease.9 → 5.41.1-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -2
- package/lib/cjs/InputNumber.js +9 -9
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/es6/InputNumber.js +9 -9
- package/lib/es6/index.d.js.map +1 -1
- package/lib/esm/InputNumber.mjs +322 -0
- package/lib/esm/buttons.mjs +24 -0
- package/lib/esm/index.mjs +8 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +33 -0
- package/lib/esm/translations/de.json.mjs +9 -0
- package/lib/esm/translations/en.json.mjs +9 -0
- package/lib/esm/translations/es.json.mjs +9 -0
- package/lib/esm/translations/fr.json.mjs +9 -0
- package/lib/esm/translations/it.json.mjs +9 -0
- package/lib/esm/translations/ja.json.mjs +9 -0
- package/lib/esm/translations/ko.json.mjs +9 -0
- package/lib/esm/translations/nl.json.mjs +9 -0
- package/lib/esm/translations/pl.json.mjs +9 -0
- package/lib/esm/translations/pt.json.mjs +9 -0
- package/lib/esm/translations/sv.json.mjs +9 -0
- package/lib/esm/translations/tr.json.mjs +9 -0
- package/lib/esm/translations/vi.json.mjs +9 -0
- package/lib/esm/translations/zh.json.mjs +9 -0
- package/lib/types/index.d.ts +4 -1
- package/package.json +11 -6
- package/vite.config.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
-
## [5.41.
|
|
5
|
+
## [5.41.1] - 2025-03-17
|
|
6
6
|
|
|
7
7
|
### Changed
|
|
8
8
|
|
|
9
|
-
- Version
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/input` [4.42.0 ~> 4.42.1], `@semcore/utils` [4.48.0 ~> 4.48.1], `@semcore/flex-box` [5.41.0 ~> 5.41.1], `@semcore/core` [2.39.0 ~> 2.39.1]).
|
|
10
|
+
|
|
11
|
+
## [5.41.0] - 2025-03-14
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Build for ESM.
|
|
16
|
+
|
|
17
|
+
## [5.40.5] - 2025-03-03
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- `locale` property type. Moved from `InputNumber.Value` to `InputNumber`.
|
|
10
22
|
|
|
11
23
|
## [5.40.4] - 2025-02-05
|
|
12
24
|
|
package/lib/cjs/InputNumber.js
CHANGED
|
@@ -25,15 +25,15 @@ var _i18nEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/i
|
|
|
25
25
|
var _ref7 = require("@semcore/utils/lib/ref");
|
|
26
26
|
var _assignProps4 = require("@semcore/utils/lib/assignProps");
|
|
27
27
|
/*__reshadow-styles__:"./style/input-number.shadow.css"*/
|
|
28
|
-
var style = ( /*__reshadow_css_start__*/_index.sstyled.insert( /*__inner_css_start__*/".
|
|
29
|
-
"__SValue": "
|
|
30
|
-
"__SControls": "
|
|
31
|
-
"_showControls": "
|
|
32
|
-
"__SUp": "
|
|
33
|
-
"__SDown": "
|
|
34
|
-
"_disabled": "
|
|
35
|
-
"__SValueHidden": "
|
|
36
|
-
"_type_number": "
|
|
28
|
+
var style = ( /*__reshadow_css_start__*/_index.sstyled.insert( /*__inner_css_start__*/".___SValue_otw7a_gg_:focus~.___SControls_otw7a_gg_{display:flex}.___SControls_otw7a_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_otw7a_gg_.__showControls_otw7a_gg_{display:flex}.___SDown_otw7a_gg_,.___SUp_otw7a_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_otw7a_gg_:focus,.___SUp_otw7a_gg_:focus{outline:0}@media (hover:hover){.___SDown_otw7a_gg_:hover,.___SUp_otw7a_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_otw7a_gg_{padding-bottom:1px}.___SDown_otw7a_gg_{padding-top:1px}.___SValue_otw7a_gg_::-webkit-inner-spin-button,.___SValue_otw7a_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_otw7a_gg_._type_number_otw7a_gg_{-moz-appearance:textfield}.___SValue_otw7a_gg_.__disabled_otw7a_gg_~.___SControls_otw7a_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_otw7a_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}" /*__inner_css_end__*/, "otw7a_gg_") /*__reshadow_css_end__*/, {
|
|
29
|
+
"__SValue": "___SValue_otw7a_gg_",
|
|
30
|
+
"__SControls": "___SControls_otw7a_gg_",
|
|
31
|
+
"_showControls": "__showControls_otw7a_gg_",
|
|
32
|
+
"__SUp": "___SUp_otw7a_gg_",
|
|
33
|
+
"__SDown": "___SDown_otw7a_gg_",
|
|
34
|
+
"_disabled": "__disabled_otw7a_gg_",
|
|
35
|
+
"__SValueHidden": "___SValueHidden_otw7a_gg_",
|
|
36
|
+
"_type_number": "_type_number_otw7a_gg_"
|
|
37
37
|
});
|
|
38
38
|
function parseValueWithMinMax(value) {
|
|
39
39
|
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MIN_SAFE_INTEGER;
|
package/lib/cjs/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, PropGetterFn, UnknownProperties } from '@semcore/core';\nimport { InputAddonProps, InputProps, InputValueProps } from '@semcore/input';\n\nexport type InputNumberValue = string;\nexport type InputNumberSize = 'm' | 'l';\n\n/** @deprecated */\nexport interface IInputNumberProps extends InputNumberProps, UnknownProperties {}\nexport type InputNumberProps = InputProps & {\n /** Input size\n * @default m\n * */\n size?: InputNumberSize;\n};\n\n/** @deprecated */\nexport interface IInputNumberValueProps extends InputNumberValueProps, UnknownProperties {}\nexport type InputNumberValueProps = InputValueProps & {\n /** Minimum value\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /** Maximum value\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** Value change step\n * @default 1\n */\n step?: number;\n /** Numeric value */\n value?: InputNumberValue;\n /** Called when the input value changes, it returns its current value in numeric format */\n onChange?: (value: InputNumberValue, event?: React.SyntheticEvent<HTMLInputElement>) => void;\n
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, PropGetterFn, UnknownProperties } from '@semcore/core';\nimport { InputAddonProps, InputProps, InputValueProps } from '@semcore/input';\n\nexport type InputNumberValue = string;\nexport type InputNumberSize = 'm' | 'l';\n\n/** @deprecated */\nexport interface IInputNumberProps extends InputNumberProps, UnknownProperties {}\nexport type InputNumberProps = InputProps & {\n /** Input size\n * @default m\n * */\n size?: InputNumberSize;\n /**\n * Locale value\n */\n locale?: string;\n};\n\n/** @deprecated */\nexport interface IInputNumberValueProps extends InputNumberValueProps, UnknownProperties {}\nexport type InputNumberValueProps = InputValueProps & {\n /** Minimum value\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /** Maximum value\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** Value change step\n * @default 1\n */\n step?: number;\n /** Numeric value */\n value?: InputNumberValue;\n /** Called when the input value changes, it returns its current value in numeric format */\n onChange?: (value: InputNumberValue, event?: React.SyntheticEvent<HTMLInputElement>) => void;\n};\n\n/** @deprecated */\nexport interface IInputNumberControlsProps extends InputNumberControlsProps, UnknownProperties {}\nexport type InputNumberControlsProps = InputAddonProps & {\n /** Always displays controls (steppers)\n * @default false\n */\n showControls?: boolean;\n};\n\n/** @deprecated */\nexport interface IInputNumberCtx extends InputNumberCtx, UnknownProperties {}\nexport type InputNumberCtx = {\n getValueProps: PropGetterFn;\n getControlsProps: PropGetterFn;\n getAddonProps: PropGetterFn;\n};\n\ndeclare const InputNumber: Intergalactic.Component<'div', InputNumberProps, InputNumberCtx> & {\n Value: Intergalactic.Component<'input', InputNumberValueProps>;\n Controls: Intergalactic.Component<'div', InputNumberControlsProps>;\n Addon: Intergalactic.Component<'div', InputAddonProps>;\n};\n\nexport default InputNumber;\n\ndeclare const IncrementIcon: React.FC;\ndeclare const DecrementIcon: React.FC;\ndeclare const parseValueWithMinMax: (value: number, min?: number, max?: number) => number;\n\nexport { IncrementIcon, DecrementIcon, parseValueWithMinMax };\n"],"mappings":""}
|
package/lib/es6/InputNumber.js
CHANGED
|
@@ -17,15 +17,15 @@ import { IncrementIcon, DecrementIcon } from './buttons';
|
|
|
17
17
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
18
18
|
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
19
19
|
/*__reshadow-styles__:"./style/input-number.shadow.css"*/
|
|
20
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
21
|
-
"__SValue": "
|
|
22
|
-
"__SControls": "
|
|
23
|
-
"_showControls": "
|
|
24
|
-
"__SUp": "
|
|
25
|
-
"__SDown": "
|
|
26
|
-
"_disabled": "
|
|
27
|
-
"__SValueHidden": "
|
|
28
|
-
"_type_number": "
|
|
20
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SValue_otw7a_gg_:focus~.___SControls_otw7a_gg_{display:flex}.___SControls_otw7a_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_otw7a_gg_.__showControls_otw7a_gg_{display:flex}.___SDown_otw7a_gg_,.___SUp_otw7a_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_otw7a_gg_:focus,.___SUp_otw7a_gg_:focus{outline:0}@media (hover:hover){.___SDown_otw7a_gg_:hover,.___SUp_otw7a_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_otw7a_gg_{padding-bottom:1px}.___SDown_otw7a_gg_{padding-top:1px}.___SValue_otw7a_gg_::-webkit-inner-spin-button,.___SValue_otw7a_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_otw7a_gg_._type_number_otw7a_gg_{-moz-appearance:textfield}.___SValue_otw7a_gg_.__disabled_otw7a_gg_~.___SControls_otw7a_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_otw7a_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}" /*__inner_css_end__*/, "otw7a_gg_") /*__reshadow_css_end__*/, {
|
|
21
|
+
"__SValue": "___SValue_otw7a_gg_",
|
|
22
|
+
"__SControls": "___SControls_otw7a_gg_",
|
|
23
|
+
"_showControls": "__showControls_otw7a_gg_",
|
|
24
|
+
"__SUp": "___SUp_otw7a_gg_",
|
|
25
|
+
"__SDown": "___SDown_otw7a_gg_",
|
|
26
|
+
"_disabled": "__disabled_otw7a_gg_",
|
|
27
|
+
"__SValueHidden": "___SValueHidden_otw7a_gg_",
|
|
28
|
+
"_type_number": "_type_number_otw7a_gg_"
|
|
29
29
|
});
|
|
30
30
|
import { forkRef } from '@semcore/utils/lib/ref';
|
|
31
31
|
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
package/lib/es6/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, PropGetterFn, UnknownProperties } from '@semcore/core';\nimport { InputAddonProps, InputProps, InputValueProps } from '@semcore/input';\n\nexport type InputNumberValue = string;\nexport type InputNumberSize = 'm' | 'l';\n\n/** @deprecated */\nexport interface IInputNumberProps extends InputNumberProps, UnknownProperties {}\nexport type InputNumberProps = InputProps & {\n /** Input size\n * @default m\n * */\n size?: InputNumberSize;\n};\n\n/** @deprecated */\nexport interface IInputNumberValueProps extends InputNumberValueProps, UnknownProperties {}\nexport type InputNumberValueProps = InputValueProps & {\n /** Minimum value\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /** Maximum value\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** Value change step\n * @default 1\n */\n step?: number;\n /** Numeric value */\n value?: InputNumberValue;\n /** Called when the input value changes, it returns its current value in numeric format */\n onChange?: (value: InputNumberValue, event?: React.SyntheticEvent<HTMLInputElement>) => void;\n
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, PropGetterFn, UnknownProperties } from '@semcore/core';\nimport { InputAddonProps, InputProps, InputValueProps } from '@semcore/input';\n\nexport type InputNumberValue = string;\nexport type InputNumberSize = 'm' | 'l';\n\n/** @deprecated */\nexport interface IInputNumberProps extends InputNumberProps, UnknownProperties {}\nexport type InputNumberProps = InputProps & {\n /** Input size\n * @default m\n * */\n size?: InputNumberSize;\n /**\n * Locale value\n */\n locale?: string;\n};\n\n/** @deprecated */\nexport interface IInputNumberValueProps extends InputNumberValueProps, UnknownProperties {}\nexport type InputNumberValueProps = InputValueProps & {\n /** Minimum value\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /** Maximum value\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** Value change step\n * @default 1\n */\n step?: number;\n /** Numeric value */\n value?: InputNumberValue;\n /** Called when the input value changes, it returns its current value in numeric format */\n onChange?: (value: InputNumberValue, event?: React.SyntheticEvent<HTMLInputElement>) => void;\n};\n\n/** @deprecated */\nexport interface IInputNumberControlsProps extends InputNumberControlsProps, UnknownProperties {}\nexport type InputNumberControlsProps = InputAddonProps & {\n /** Always displays controls (steppers)\n * @default false\n */\n showControls?: boolean;\n};\n\n/** @deprecated */\nexport interface IInputNumberCtx extends InputNumberCtx, UnknownProperties {}\nexport type InputNumberCtx = {\n getValueProps: PropGetterFn;\n getControlsProps: PropGetterFn;\n getAddonProps: PropGetterFn;\n};\n\ndeclare const InputNumber: Intergalactic.Component<'div', InputNumberProps, InputNumberCtx> & {\n Value: Intergalactic.Component<'input', InputNumberValueProps>;\n Controls: Intergalactic.Component<'div', InputNumberControlsProps>;\n Addon: Intergalactic.Component<'div', InputAddonProps>;\n};\n\nexport default InputNumber;\n\ndeclare const IncrementIcon: React.FC;\ndeclare const DecrementIcon: React.FC;\ndeclare const parseValueWithMinMax: (value: number, min?: number, max?: number) => number;\n\nexport { IncrementIcon, DecrementIcon, parseValueWithMinMax };\n"],"mappings":""}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import A from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import V from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import x from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import I from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import d from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import C from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import k from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import l from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { sstyled as M } from "@semcore/utils/lib/core/index";
|
|
10
|
+
import z, { sstyled as D, assignProps as R, Component as $ } from "@semcore/core";
|
|
11
|
+
import h from "react";
|
|
12
|
+
import P from "@semcore/input";
|
|
13
|
+
import { IncrementIcon as W, DecrementIcon as K } from "./buttons.mjs";
|
|
14
|
+
import { localizedMessages as F } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
15
|
+
import L from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
16
|
+
import { forkRef as B } from "@semcore/utils/lib/ref";
|
|
17
|
+
import { callAllEventHandlers as G } from "@semcore/utils/lib/assignProps";
|
|
18
|
+
var N = (
|
|
19
|
+
/*__reshadow_css_start__*/
|
|
20
|
+
(M.insert(
|
|
21
|
+
/*__inner_css_start__*/
|
|
22
|
+
".___SValue_otw7a_gg_:focus~.___SControls_otw7a_gg_{display:flex}.___SControls_otw7a_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_otw7a_gg_.__showControls_otw7a_gg_{display:flex}.___SDown_otw7a_gg_,.___SUp_otw7a_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_otw7a_gg_:focus,.___SUp_otw7a_gg_:focus{outline:0}@media (hover:hover){.___SDown_otw7a_gg_:hover,.___SUp_otw7a_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_otw7a_gg_{padding-bottom:1px}.___SDown_otw7a_gg_{padding-top:1px}.___SValue_otw7a_gg_::-webkit-inner-spin-button,.___SValue_otw7a_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_otw7a_gg_._type_number_otw7a_gg_{-moz-appearance:textfield}.___SValue_otw7a_gg_.__disabled_otw7a_gg_~.___SControls_otw7a_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_otw7a_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}",
|
|
23
|
+
"otw7a_gg_"
|
|
24
|
+
), {
|
|
25
|
+
__SValue: "___SValue_otw7a_gg_",
|
|
26
|
+
__SControls: "___SControls_otw7a_gg_",
|
|
27
|
+
_showControls: "__showControls_otw7a_gg_",
|
|
28
|
+
__SUp: "___SUp_otw7a_gg_",
|
|
29
|
+
__SDown: "___SDown_otw7a_gg_",
|
|
30
|
+
_disabled: "__disabled_otw7a_gg_",
|
|
31
|
+
__SValueHidden: "___SValueHidden_otw7a_gg_",
|
|
32
|
+
_type_number: "_type_number_otw7a_gg_"
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
function H(m) {
|
|
36
|
+
var g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Number.MIN_SAFE_INTEGER, c = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Number.MAX_SAFE_INTEGER;
|
|
37
|
+
return Math.max(g, Math.min(c, m));
|
|
38
|
+
}
|
|
39
|
+
var b = /* @__PURE__ */ function(m) {
|
|
40
|
+
C(c, m);
|
|
41
|
+
var g = k(c);
|
|
42
|
+
function c() {
|
|
43
|
+
var t;
|
|
44
|
+
x(this, c);
|
|
45
|
+
for (var n = arguments.length, s = new Array(n), i = 0; i < n; i++)
|
|
46
|
+
s[i] = arguments[i];
|
|
47
|
+
return t = g.call.apply(g, [this].concat(s)), l(d(t), "inputRef", /* @__PURE__ */ h.createRef()), l(d(t), "increment", function(e) {
|
|
48
|
+
var a, r;
|
|
49
|
+
(a = t.inputRef.current) === null || a === void 0 || (r = a.stepUp) === null || r === void 0 || r.call(a, e);
|
|
50
|
+
}), l(d(t), "decrement", function(e) {
|
|
51
|
+
var a, r;
|
|
52
|
+
(a = t.inputRef.current) === null || a === void 0 || (r = a.stepDown) === null || r === void 0 || r.call(a, e);
|
|
53
|
+
}), t;
|
|
54
|
+
}
|
|
55
|
+
return I(c, [{
|
|
56
|
+
key: "getValueProps",
|
|
57
|
+
value: function() {
|
|
58
|
+
var n = new Intl.NumberFormat(this.asProps.locale, {
|
|
59
|
+
style: "decimal"
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
inputRef: this.inputRef,
|
|
63
|
+
increment: this.increment,
|
|
64
|
+
decrement: this.decrement,
|
|
65
|
+
numberFormatter: n
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "getControlsProps",
|
|
70
|
+
value: function() {
|
|
71
|
+
var n = this.asProps, s = n.size, i = n.getI18nText;
|
|
72
|
+
return {
|
|
73
|
+
size: s,
|
|
74
|
+
increment: this.increment,
|
|
75
|
+
decrement: this.decrement,
|
|
76
|
+
getI18nText: i
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "render",
|
|
81
|
+
value: function() {
|
|
82
|
+
var n = this.asProps, s, i = P;
|
|
83
|
+
return s = D(this.asProps.style), /* @__PURE__ */ h.createElement(i, s.cn("SInputNumber", V({}, R({}, n))));
|
|
84
|
+
}
|
|
85
|
+
}]), c;
|
|
86
|
+
}($);
|
|
87
|
+
l(b, "displayName", "InputNumber");
|
|
88
|
+
l(b, "style", N);
|
|
89
|
+
l(b, "enhance", [L(F)]);
|
|
90
|
+
l(b, "defaultProps", {
|
|
91
|
+
size: "m",
|
|
92
|
+
i18n: F,
|
|
93
|
+
locale: "en"
|
|
94
|
+
});
|
|
95
|
+
var E = /* @__PURE__ */ function(m) {
|
|
96
|
+
C(c, m);
|
|
97
|
+
var g = k(c);
|
|
98
|
+
function c() {
|
|
99
|
+
var t;
|
|
100
|
+
x(this, c);
|
|
101
|
+
for (var n = arguments.length, s = new Array(n), i = 0; i < n; i++)
|
|
102
|
+
s[i] = arguments[i];
|
|
103
|
+
return t = g.call.apply(g, [this].concat(s)), l(d(t), "valueInputRef", /* @__PURE__ */ h.createRef()), l(d(t), "cursorPosition", -1), l(d(t), "getFormattedValue", function(e) {
|
|
104
|
+
return e.replace(new RegExp("[".concat(t.separatorThousands, "]"), "g"), "").replace(t.separatorDecimal, ".");
|
|
105
|
+
}), l(d(t), "valueParser", function(e, a, r) {
|
|
106
|
+
var u = t.props.numberFormatter, o = t.getFormattedValue(String(e));
|
|
107
|
+
if (Number.isNaN(Number(o)))
|
|
108
|
+
return {
|
|
109
|
+
parsedValue: a,
|
|
110
|
+
displayValue: r
|
|
111
|
+
};
|
|
112
|
+
var f = "";
|
|
113
|
+
if (/\.[0-9]*0$/.test(o)) {
|
|
114
|
+
var p = o.split(t.separatorDecimal), _ = A(p, 2), v = _[0], S = _[1];
|
|
115
|
+
f = u.format(v) + t.separatorDecimal + S;
|
|
116
|
+
} else o !== "" && (f = u.format(o));
|
|
117
|
+
return {
|
|
118
|
+
parsedValue: o,
|
|
119
|
+
displayValue: f
|
|
120
|
+
};
|
|
121
|
+
}), l(d(t), "handleValidation", function(e) {
|
|
122
|
+
var a = t.asProps, r = a.value, u = a.displayValue, o = a.min, f = a.max, p = a.step, _ = t.valueParser(e.currentTarget.value, r, u), v = _.parsedValue, S = p < 1 ? p.toString().split(".")[1].length : 1;
|
|
123
|
+
if (Number.isNaN(r) || Number.isNaN(Number.parseFloat(v)))
|
|
124
|
+
e.currentTarget.value = "", t.handlers.value("", e);
|
|
125
|
+
else {
|
|
126
|
+
var y = H(Number.parseFloat(v), o, f), w = t.round(y % p, p);
|
|
127
|
+
w !== 0 && (w >= p / 2 ? y += p - w : Math.abs(w) < p && (y -= w));
|
|
128
|
+
var U = Number(y.toFixed(S));
|
|
129
|
+
t.handlers.value(String(U), e);
|
|
130
|
+
}
|
|
131
|
+
}), l(d(t), "onWheel", function(e) {
|
|
132
|
+
G(t.asProps.onWheel, t.handleWheel)(e);
|
|
133
|
+
}), l(d(t), "handleWheel", function(e) {
|
|
134
|
+
e.target === t.valueInputRef.current && document.activeElement === t.valueInputRef.current && (e.preventDefault(), e.wheelDelta > 0 ? t.stepUp(e) : e.wheelDelta < 0 && t.stepDown(e));
|
|
135
|
+
}), l(d(t), "handleChange", function(e) {
|
|
136
|
+
var a = t.getFormattedValue(e.currentTarget.value), r = t.asProps, u = r.numberFormatter, o = r.value;
|
|
137
|
+
if (a === "." || a === "-")
|
|
138
|
+
return t.handlers.displayValue(a), !1;
|
|
139
|
+
if (a.endsWith("-"))
|
|
140
|
+
return !1;
|
|
141
|
+
if (a.endsWith("."))
|
|
142
|
+
return a.length > o.length ? (t.handlers.displayValue(u.format(a) + t.separatorDecimal), !1) : (t.handlers.value(a.slice(0, -1), e), !1);
|
|
143
|
+
var f = /[0-9.-]+/.test(a);
|
|
144
|
+
(f || a === "") && t.handlers.value(a, e);
|
|
145
|
+
}), l(d(t), "handleKeyUp", function(e) {
|
|
146
|
+
e.key === "Shift" && (t.cursorPosition = -1);
|
|
147
|
+
}), l(d(t), "handleKeyDown", function(e) {
|
|
148
|
+
var a = e.currentTarget, r = a.value, u = r.length, o = t.asProps.displayValue;
|
|
149
|
+
if (e.key === "." || e.key === ",") {
|
|
150
|
+
if (r.indexOf(t.separatorDecimal) === -1 && e.key === ",")
|
|
151
|
+
e.currentTarget.value = r + ".";
|
|
152
|
+
else if (r.indexOf(t.separatorDecimal) !== -1) {
|
|
153
|
+
e.preventDefault(), e.stopPropagation();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (e.key === "Backspace" && r.endsWith(t.separatorDecimal))
|
|
158
|
+
return e.preventDefault(), e.stopPropagation(), t.handlers.displayValue(o.slice(0, -1)), !1;
|
|
159
|
+
if (a.selectionStart !== u && (e.key === "Backspace" || e.key === t.separatorDecimal || ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(e.key))) {
|
|
160
|
+
var f = r.slice(a.selectionEnd);
|
|
161
|
+
requestAnimationFrame(function() {
|
|
162
|
+
var _ = t.state.displayValue, v = _.lastIndexOf(f), S = v, y = v;
|
|
163
|
+
a.setSelectionRange(S, y);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
var p = 2;
|
|
167
|
+
switch (e.shiftKey && t.cursorPosition === -1 && (t.cursorPosition = a.selectionStart), e.key) {
|
|
168
|
+
case "ArrowLeft": {
|
|
169
|
+
e.preventDefault(), t.moveSelectionLeft(a, p);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case "ArrowRight": {
|
|
173
|
+
e.preventDefault(), t.moveSelectionRight(a, p);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "ArrowDown": {
|
|
177
|
+
e.preventDefault(), t.stepDown(e);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "ArrowUp": {
|
|
181
|
+
e.preventDefault(), t.stepUp(e);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}), l(d(t), "moveSelectionLeft", function(e, a) {
|
|
186
|
+
var r = e.value, u = e.selectionStart - 1 >= 0 ? e.selectionStart - 1 : 0, o = r[e.selectionStart - a] === t.separatorThousands ? e.selectionStart - a : u;
|
|
187
|
+
t.cursorPosition === -1 ? e.setSelectionRange(o, o) : e.selectionStart <= t.cursorPosition && e.selectionEnd === t.cursorPosition ? e.setSelectionRange(o, e.selectionEnd) : e.setSelectionRange(e.selectionStart, r[e.selectionEnd - a] === t.separatorThousands ? e.selectionEnd - a : e.selectionEnd - 1);
|
|
188
|
+
}), l(d(t), "moveSelectionRight", function(e, a) {
|
|
189
|
+
var r = e.value, u = e.selectionEnd + 1, o = r[e.selectionEnd] === t.separatorThousands ? e.selectionEnd + a : u;
|
|
190
|
+
t.cursorPosition === -1 ? e.setSelectionRange(o, o) : e.selectionEnd >= t.cursorPosition && e.selectionStart === t.cursorPosition ? e.setSelectionRange(e.selectionStart, o) : e.setSelectionRange(r[e.selectionStart] === t.separatorThousands ? e.selectionStart + a : e.selectionStart + 1, e.selectionEnd);
|
|
191
|
+
}), l(d(t), "handleClick", function(e) {
|
|
192
|
+
var a = e.target, r = a.value;
|
|
193
|
+
r[a.selectionStart - 1] === t.separatorThousands && a.setSelectionRange(a.selectionStart - 1, a.selectionEnd - 1);
|
|
194
|
+
}), l(d(t), "handleBlur", function(e) {
|
|
195
|
+
t.cursorPosition = -1, t.handleValidation(e);
|
|
196
|
+
}), l(d(t), "stepUp", function(e) {
|
|
197
|
+
var a = t.asProps, r = a.max, u = r === void 0 ? Number.MAX_SAFE_INTEGER : r, o = a.min, f = a.step, p = a.value, _;
|
|
198
|
+
if (p === "" ? _ = o ?? 0 : _ = Number.parseFloat(p), !Number.isNaN(_)) {
|
|
199
|
+
var v = _ + f <= u ? _ + f : u;
|
|
200
|
+
t.handlers.value(v.toString(), e);
|
|
201
|
+
}
|
|
202
|
+
}), l(d(t), "stepDown", function(e) {
|
|
203
|
+
var a = t.asProps, r = a.max, u = a.min, o = u === void 0 ? Number.MIN_SAFE_INTEGER : u, f = a.step, p = a.value, _;
|
|
204
|
+
if (p === "" ? _ = r ?? 0 : _ = Number.parseFloat(p), !Number.isNaN(_)) {
|
|
205
|
+
var v = _ - f >= o ? _ - f : o;
|
|
206
|
+
t.handlers.value(v.toString(), e);
|
|
207
|
+
}
|
|
208
|
+
}), t;
|
|
209
|
+
}
|
|
210
|
+
return I(c, [{
|
|
211
|
+
key: "uncontrolledProps",
|
|
212
|
+
value: function() {
|
|
213
|
+
var n = this;
|
|
214
|
+
return {
|
|
215
|
+
displayValue: null,
|
|
216
|
+
value: [null, function(s) {
|
|
217
|
+
var i = n.asProps, e = i.value, a = i.displayValue, r = n.valueParser(s, e, a), u = r.parsedValue, o = r.displayValue;
|
|
218
|
+
return n.handlers.displayValue(o), u;
|
|
219
|
+
}]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}, {
|
|
223
|
+
key: "separatorDecimal",
|
|
224
|
+
get: function() {
|
|
225
|
+
var n = this.props.numberFormatter;
|
|
226
|
+
return n.format(11.11).replace(/\d/g, "");
|
|
227
|
+
}
|
|
228
|
+
}, {
|
|
229
|
+
key: "separatorThousands",
|
|
230
|
+
get: function() {
|
|
231
|
+
var n = this.props.numberFormatter;
|
|
232
|
+
return n.format(1111).replace(/\d/g, "");
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "round",
|
|
236
|
+
value: function(n, s) {
|
|
237
|
+
var i = Math.floor(s) === s ? 0 : s.toString().split(".")[1].length || 0;
|
|
238
|
+
return i === 0 ? Number.parseFloat(n) : Number.parseFloat(n).toPrecision(i);
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
key: "componentDidMount",
|
|
242
|
+
value: (
|
|
243
|
+
// https://stackoverflow.com/questions/57358640/cancel-wheel-event-with-e-preventdefault-in-react-event-bubbling
|
|
244
|
+
function() {
|
|
245
|
+
var n;
|
|
246
|
+
(n = this.valueInputRef.current) === null || n === void 0 || n.addEventListener("wheel", this.onWheel);
|
|
247
|
+
var s = this.asProps, i = s.inputRef, e = s.value;
|
|
248
|
+
if (i.current && (i.current.stepUp = this.stepUp, i.current.stepDown = this.stepDown), e !== "") {
|
|
249
|
+
var a = this.valueParser(e, "", ""), r = a.displayValue;
|
|
250
|
+
this.handlers.displayValue(r);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
}, {
|
|
255
|
+
key: "componentDidUpdate",
|
|
256
|
+
value: function(n) {
|
|
257
|
+
if (n.value !== this.props.value) {
|
|
258
|
+
var s = this.valueParser(this.props.value, n.value, n.displayValue), i = s.displayValue;
|
|
259
|
+
this.handlers.displayValue(i);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "componentWillUnmount",
|
|
264
|
+
value: function() {
|
|
265
|
+
var n;
|
|
266
|
+
(n = this.valueInputRef.current) === null || n === void 0 || n.removeEventListener("wheel", this.onWheel);
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "render",
|
|
270
|
+
value: function() {
|
|
271
|
+
var n = this.asProps, s, i = P.Value, e = this.asProps, a = e.styles, r = e.min, u = e.max, o = e.step, f = e.forwardRef, p = e.inputRef, _ = e.displayValue;
|
|
272
|
+
return s = D(a), /* @__PURE__ */ h.createElement(h.Fragment, null, /* @__PURE__ */ h.createElement(i, s.cn("SValue", V({}, R({
|
|
273
|
+
autoComplete: "off",
|
|
274
|
+
onBlur: this.handleValidation,
|
|
275
|
+
"use:onChange": this.handleChange,
|
|
276
|
+
onKeyDown: this.handleKeyDown,
|
|
277
|
+
onKeyUp: this.handleKeyUp,
|
|
278
|
+
onClick: this.handleClick,
|
|
279
|
+
"use:ref": B(this.valueInputRef, p, f),
|
|
280
|
+
"use:value": _,
|
|
281
|
+
inputMode: Number.isInteger(o) ? "numeric" : "decimal",
|
|
282
|
+
min: r,
|
|
283
|
+
max: u,
|
|
284
|
+
step: o
|
|
285
|
+
}, n)))));
|
|
286
|
+
}
|
|
287
|
+
}]), c;
|
|
288
|
+
}($);
|
|
289
|
+
l(E, "style", N);
|
|
290
|
+
l(E, "defaultProps", {
|
|
291
|
+
defaultValue: "",
|
|
292
|
+
defaultDisplayValue: "",
|
|
293
|
+
step: 1
|
|
294
|
+
});
|
|
295
|
+
function T(m) {
|
|
296
|
+
var g = arguments[0], c, t = m.Children, n = m.increment, s = m.decrement, i = m.size, e = m.styles, a = m.getI18nText, r = P.Addon, u = "button", o = "button";
|
|
297
|
+
return c = D(e), /* @__PURE__ */ h.createElement(r, c.cn("SControls", V({}, R({
|
|
298
|
+
"aria-hidden": "true"
|
|
299
|
+
}, g))), /* @__PURE__ */ h.createElement(u, c.cn("SUp", {
|
|
300
|
+
onClick: n,
|
|
301
|
+
tabIndex: -1,
|
|
302
|
+
type: "button",
|
|
303
|
+
size: i,
|
|
304
|
+
"aria-label": a("increment")
|
|
305
|
+
}), /* @__PURE__ */ h.createElement(W, c.cn("IncrementIcon", {}))), /* @__PURE__ */ h.createElement(o, c.cn("SDown", {
|
|
306
|
+
onClick: s,
|
|
307
|
+
tabIndex: -1,
|
|
308
|
+
type: "button",
|
|
309
|
+
size: i,
|
|
310
|
+
"aria-label": a("decrement")
|
|
311
|
+
}), /* @__PURE__ */ h.createElement(K, c.cn("DecrementIcon", {}))), /* @__PURE__ */ h.createElement(t, c.cn("Children", {})));
|
|
312
|
+
}
|
|
313
|
+
T.style = N;
|
|
314
|
+
const ue = z(b, {
|
|
315
|
+
Value: E,
|
|
316
|
+
Controls: T,
|
|
317
|
+
Addon: P.Addon
|
|
318
|
+
});
|
|
319
|
+
export {
|
|
320
|
+
ue as default,
|
|
321
|
+
H as parseValueWithMinMax
|
|
322
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
var n = function() {
|
|
3
|
+
return /* @__PURE__ */ e.createElement("svg", {
|
|
4
|
+
fill: "currentColor",
|
|
5
|
+
width: "10",
|
|
6
|
+
height: "5",
|
|
7
|
+
viewBox: "0 0 10 5"
|
|
8
|
+
}, /* @__PURE__ */ e.createElement("path", {
|
|
9
|
+
d: "M0,5l5,-5l5,5Z"
|
|
10
|
+
}));
|
|
11
|
+
}, c = function() {
|
|
12
|
+
return /* @__PURE__ */ e.createElement("svg", {
|
|
13
|
+
fill: "currentColor",
|
|
14
|
+
width: "10",
|
|
15
|
+
height: "5",
|
|
16
|
+
viewBox: "0 0 10 5"
|
|
17
|
+
}, /* @__PURE__ */ e.createElement("path", {
|
|
18
|
+
d: "M0,0l10,0l-5,5Z"
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
c as DecrementIcon,
|
|
23
|
+
n as IncrementIcon
|
|
24
|
+
};
|
|
@@ -0,0 +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
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
B as localizedMessages
|
|
33
|
+
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type InputNumberProps = InputProps & {
|
|
|
12
12
|
* @default m
|
|
13
13
|
* */
|
|
14
14
|
size?: InputNumberSize;
|
|
15
|
+
/**
|
|
16
|
+
* Locale value
|
|
17
|
+
*/
|
|
18
|
+
locale?: string;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
/** @deprecated */
|
|
@@ -33,7 +37,6 @@ export type InputNumberValueProps = InputValueProps & {
|
|
|
33
37
|
value?: InputNumberValue;
|
|
34
38
|
/** Called when the input value changes, it returns its current value in numeric format */
|
|
35
39
|
onChange?: (value: InputNumberValue, event?: React.SyntheticEvent<HTMLInputElement>) => void;
|
|
36
|
-
locale?: string;
|
|
37
40
|
};
|
|
38
41
|
|
|
39
42
|
/** @deprecated */
|
package/package.json
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/input-number",
|
|
3
3
|
"description": "Semrush InputNumber Component",
|
|
4
|
-
"version": "5.41.
|
|
4
|
+
"version": "5.41.1-prerelease.0",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"author": "UI-kit team <ui-kit-team@semrush.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"exports": {
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"import": "./lib/esm/index.mjs",
|
|
14
|
+
"types": "./lib/types/index.d.ts"
|
|
15
|
+
},
|
|
11
16
|
"dependencies": {
|
|
12
|
-
"@semcore/input": "4.42.
|
|
13
|
-
"@semcore/utils": "4.
|
|
14
|
-
"@semcore/flex-box": "5.41.
|
|
17
|
+
"@semcore/input": "4.42.1-prerelease.0",
|
|
18
|
+
"@semcore/utils": "4.48.1-prerelease.0",
|
|
19
|
+
"@semcore/flex-box": "5.41.1-prerelease.0"
|
|
15
20
|
},
|
|
16
21
|
"peerDependencies": {
|
|
17
|
-
"@semcore/core": "^2.39.
|
|
22
|
+
"@semcore/core": "^2.39.1-prerelease.0",
|
|
18
23
|
"react": "16.8 - 18",
|
|
19
24
|
"react-dom": "16.8 - 18"
|
|
20
25
|
},
|
|
@@ -28,6 +33,6 @@
|
|
|
28
33
|
"@semcore/testing-utils": "1.0.0"
|
|
29
34
|
},
|
|
30
35
|
"scripts": {
|
|
31
|
-
"build": "pnpm semcore-builder --source=js"
|
|
36
|
+
"build": "pnpm semcore-builder --source=js && pnpm vite build"
|
|
32
37
|
}
|
|
33
38
|
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig, mergeConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
import viteConfig from '../../commonVite.config';
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(
|
|
6
|
+
viteConfig,
|
|
7
|
+
defineConfig({
|
|
8
|
+
build: {
|
|
9
|
+
lib: {
|
|
10
|
+
entry: './src/index.js',
|
|
11
|
+
},
|
|
12
|
+
rollupOptions: {
|
|
13
|
+
external: ['react', 'react-dom', 'react/jsx-runtime', /@babel\/runtime\/*/, /@semcore\/*/],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
);
|