@semcore/input-number 5.41.0-prerelease.4 → 5.41.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 +9 -3
- package/lib/cjs/index.d.js.map +1 -1
- 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,17 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
-
## [5.41.0] - 2025-
|
|
5
|
+
## [5.41.0] - 2025-03-14
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Build for ESM.
|
|
10
|
+
|
|
11
|
+
## [5.40.5] - 2025-03-03
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
8
14
|
|
|
9
|
-
-
|
|
15
|
+
- `locale` property type. Moved from `InputNumber.Value` to `InputNumber`.
|
|
10
16
|
|
|
11
17
|
## [5.40.4] - 2025-02-05
|
|
12
18
|
|
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/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 D 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 u from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { sstyled as M } from "@semcore/utils/lib/core/index";
|
|
10
|
+
import z, { sstyled as w, assignProps as R, Component as $ } from "@semcore/core";
|
|
11
|
+
import h from "react";
|
|
12
|
+
import V 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_1uuai_gg_:focus~.___SControls_1uuai_gg_{display:flex}.___SControls_1uuai_gg_{display:none;flex-flow:column;justify-content:center;height:100%;box-sizing:border-box}.___SControls_1uuai_gg_.__showControls_1uuai_gg_{display:flex}.___SDown_1uuai_gg_,.___SUp_1uuai_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_1uuai_gg_:focus,.___SUp_1uuai_gg_:focus{outline:0}@media (hover:hover){.___SDown_1uuai_gg_:hover,.___SUp_1uuai_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SUp_1uuai_gg_{padding-bottom:1px}.___SDown_1uuai_gg_{padding-top:1px}.___SValue_1uuai_gg_::-webkit-inner-spin-button,.___SValue_1uuai_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_1uuai_gg_._type_number_1uuai_gg_{-moz-appearance:textfield}.___SValue_1uuai_gg_.__disabled_1uuai_gg_~.___SControls_1uuai_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SValueHidden_1uuai_gg_{position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden}",
|
|
23
|
+
"1uuai_gg_"
|
|
24
|
+
), {
|
|
25
|
+
__SValue: "___SValue_1uuai_gg_",
|
|
26
|
+
__SControls: "___SControls_1uuai_gg_",
|
|
27
|
+
_showControls: "__showControls_1uuai_gg_",
|
|
28
|
+
__SUp: "___SUp_1uuai_gg_",
|
|
29
|
+
__SDown: "___SDown_1uuai_gg_",
|
|
30
|
+
_disabled: "__disabled_1uuai_gg_",
|
|
31
|
+
__SValueHidden: "___SValueHidden_1uuai_gg_",
|
|
32
|
+
_type_number: "_type_number_1uuai_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 P = /* @__PURE__ */ function(m) {
|
|
40
|
+
C(c, m);
|
|
41
|
+
var g = k(c);
|
|
42
|
+
function c() {
|
|
43
|
+
var a;
|
|
44
|
+
x(this, c);
|
|
45
|
+
for (var n = arguments.length, s = new Array(n), o = 0; o < n; o++)
|
|
46
|
+
s[o] = arguments[o];
|
|
47
|
+
return a = g.call.apply(g, [this].concat(s)), u(d(a), "inputRef", /* @__PURE__ */ h.createRef()), u(d(a), "increment", function(e) {
|
|
48
|
+
var r, t;
|
|
49
|
+
(r = a.inputRef.current) === null || r === void 0 || (t = r.stepUp) === null || t === void 0 || t.call(r, e);
|
|
50
|
+
}), u(d(a), "decrement", function(e) {
|
|
51
|
+
var r, t;
|
|
52
|
+
(r = a.inputRef.current) === null || r === void 0 || (t = r.stepDown) === null || t === void 0 || t.call(r, e);
|
|
53
|
+
}), a;
|
|
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, o = n.getI18nText;
|
|
72
|
+
return {
|
|
73
|
+
size: s,
|
|
74
|
+
increment: this.increment,
|
|
75
|
+
decrement: this.decrement,
|
|
76
|
+
getI18nText: o
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "render",
|
|
81
|
+
value: function() {
|
|
82
|
+
var n = this.asProps, s, o = V;
|
|
83
|
+
return s = w(this.asProps.style), /* @__PURE__ */ h.createElement(o, s.cn("SInputNumber", D({}, R({}, n))));
|
|
84
|
+
}
|
|
85
|
+
}]), c;
|
|
86
|
+
}($);
|
|
87
|
+
u(P, "displayName", "InputNumber");
|
|
88
|
+
u(P, "style", N);
|
|
89
|
+
u(P, "enhance", [L(F)]);
|
|
90
|
+
u(P, "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 a;
|
|
100
|
+
x(this, c);
|
|
101
|
+
for (var n = arguments.length, s = new Array(n), o = 0; o < n; o++)
|
|
102
|
+
s[o] = arguments[o];
|
|
103
|
+
return a = g.call.apply(g, [this].concat(s)), u(d(a), "valueInputRef", /* @__PURE__ */ h.createRef()), u(d(a), "cursorPosition", -1), u(d(a), "getFormattedValue", function(e) {
|
|
104
|
+
return e.replace(new RegExp("[".concat(a.separatorThousands, "]"), "g"), "").replace(a.separatorDecimal, ".");
|
|
105
|
+
}), u(d(a), "valueParser", function(e, r, t) {
|
|
106
|
+
var l = a.props.numberFormatter, i = a.getFormattedValue(String(e));
|
|
107
|
+
if (Number.isNaN(Number(i)))
|
|
108
|
+
return {
|
|
109
|
+
parsedValue: r,
|
|
110
|
+
displayValue: t
|
|
111
|
+
};
|
|
112
|
+
var f = "";
|
|
113
|
+
if (/\.[0-9]*0$/.test(i)) {
|
|
114
|
+
var p = i.split(a.separatorDecimal), _ = A(p, 2), v = _[0], S = _[1];
|
|
115
|
+
f = l.format(v) + a.separatorDecimal + S;
|
|
116
|
+
} else i !== "" && (f = l.format(i));
|
|
117
|
+
return {
|
|
118
|
+
parsedValue: i,
|
|
119
|
+
displayValue: f
|
|
120
|
+
};
|
|
121
|
+
}), u(d(a), "handleValidation", function(e) {
|
|
122
|
+
var r = a.asProps, t = r.value, l = r.displayValue, i = r.min, f = r.max, p = r.step, _ = a.valueParser(e.currentTarget.value, t, l), v = _.parsedValue, S = p < 1 ? p.toString().split(".")[1].length : 1;
|
|
123
|
+
if (Number.isNaN(t) || Number.isNaN(Number.parseFloat(v)))
|
|
124
|
+
e.currentTarget.value = "", a.handlers.value("", e);
|
|
125
|
+
else {
|
|
126
|
+
var y = H(Number.parseFloat(v), i, f), b = a.round(y % p, p);
|
|
127
|
+
b !== 0 && (b >= p / 2 ? y += p - b : Math.abs(b) < p && (y -= b));
|
|
128
|
+
var U = Number(y.toFixed(S));
|
|
129
|
+
a.handlers.value(String(U), e);
|
|
130
|
+
}
|
|
131
|
+
}), u(d(a), "onWheel", function(e) {
|
|
132
|
+
G(a.asProps.onWheel, a.handleWheel)(e);
|
|
133
|
+
}), u(d(a), "handleWheel", function(e) {
|
|
134
|
+
e.target === a.valueInputRef.current && document.activeElement === a.valueInputRef.current && (e.preventDefault(), e.wheelDelta > 0 ? a.stepUp(e) : e.wheelDelta < 0 && a.stepDown(e));
|
|
135
|
+
}), u(d(a), "handleChange", function(e) {
|
|
136
|
+
var r = a.getFormattedValue(e.currentTarget.value), t = a.asProps, l = t.numberFormatter, i = t.value;
|
|
137
|
+
if (r === "." || r === "-")
|
|
138
|
+
return a.handlers.displayValue(r), !1;
|
|
139
|
+
if (r.endsWith("-"))
|
|
140
|
+
return !1;
|
|
141
|
+
if (r.endsWith("."))
|
|
142
|
+
return r.length > i.length ? (a.handlers.displayValue(l.format(r) + a.separatorDecimal), !1) : (a.handlers.value(r.slice(0, -1), e), !1);
|
|
143
|
+
var f = /[0-9.-]+/.test(r);
|
|
144
|
+
(f || r === "") && a.handlers.value(r, e);
|
|
145
|
+
}), u(d(a), "handleKeyUp", function(e) {
|
|
146
|
+
e.key === "Shift" && (a.cursorPosition = -1);
|
|
147
|
+
}), u(d(a), "handleKeyDown", function(e) {
|
|
148
|
+
var r = e.currentTarget, t = r.value, l = t.length, i = a.asProps.displayValue;
|
|
149
|
+
if (e.key === "." || e.key === ",") {
|
|
150
|
+
if (t.indexOf(a.separatorDecimal) === -1 && e.key === ",")
|
|
151
|
+
e.currentTarget.value = t + ".";
|
|
152
|
+
else if (t.indexOf(a.separatorDecimal) !== -1) {
|
|
153
|
+
e.preventDefault(), e.stopPropagation();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (e.key === "Backspace" && t.endsWith(a.separatorDecimal))
|
|
158
|
+
return e.preventDefault(), e.stopPropagation(), a.handlers.displayValue(i.slice(0, -1)), !1;
|
|
159
|
+
if (r.selectionStart !== l && (e.key === "Backspace" || e.key === a.separatorDecimal || ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(e.key))) {
|
|
160
|
+
var f = t.slice(r.selectionEnd);
|
|
161
|
+
requestAnimationFrame(function() {
|
|
162
|
+
var _ = a.state.displayValue, v = _.lastIndexOf(f), S = v, y = v;
|
|
163
|
+
r.setSelectionRange(S, y);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
var p = 2;
|
|
167
|
+
switch (e.shiftKey && a.cursorPosition === -1 && (a.cursorPosition = r.selectionStart), e.key) {
|
|
168
|
+
case "ArrowLeft": {
|
|
169
|
+
e.preventDefault(), a.moveSelectionLeft(r, p);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case "ArrowRight": {
|
|
173
|
+
e.preventDefault(), a.moveSelectionRight(r, p);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "ArrowDown": {
|
|
177
|
+
e.preventDefault(), a.stepDown(e);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "ArrowUp": {
|
|
181
|
+
e.preventDefault(), a.stepUp(e);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}), u(d(a), "moveSelectionLeft", function(e, r) {
|
|
186
|
+
var t = e.value, l = e.selectionStart - 1 >= 0 ? e.selectionStart - 1 : 0, i = t[e.selectionStart - r] === a.separatorThousands ? e.selectionStart - r : l;
|
|
187
|
+
a.cursorPosition === -1 ? e.setSelectionRange(i, i) : e.selectionStart <= a.cursorPosition && e.selectionEnd === a.cursorPosition ? e.setSelectionRange(i, e.selectionEnd) : e.setSelectionRange(e.selectionStart, t[e.selectionEnd - r] === a.separatorThousands ? e.selectionEnd - r : e.selectionEnd - 1);
|
|
188
|
+
}), u(d(a), "moveSelectionRight", function(e, r) {
|
|
189
|
+
var t = e.value, l = e.selectionEnd + 1, i = t[e.selectionEnd] === a.separatorThousands ? e.selectionEnd + r : l;
|
|
190
|
+
a.cursorPosition === -1 ? e.setSelectionRange(i, i) : e.selectionEnd >= a.cursorPosition && e.selectionStart === a.cursorPosition ? e.setSelectionRange(e.selectionStart, i) : e.setSelectionRange(t[e.selectionStart] === a.separatorThousands ? e.selectionStart + r : e.selectionStart + 1, e.selectionEnd);
|
|
191
|
+
}), u(d(a), "handleClick", function(e) {
|
|
192
|
+
var r = e.target, t = r.value;
|
|
193
|
+
t[r.selectionStart - 1] === a.separatorThousands && r.setSelectionRange(r.selectionStart - 1, r.selectionEnd - 1);
|
|
194
|
+
}), u(d(a), "handleBlur", function(e) {
|
|
195
|
+
a.cursorPosition = -1, a.handleValidation(e);
|
|
196
|
+
}), u(d(a), "stepUp", function(e) {
|
|
197
|
+
var r = a.asProps, t = r.max, l = t === void 0 ? Number.MAX_SAFE_INTEGER : t, i = r.min, f = r.step, p = r.value, _;
|
|
198
|
+
if (p === "" ? _ = i ?? 0 : _ = Number.parseFloat(p), !Number.isNaN(_)) {
|
|
199
|
+
var v = _ + f <= l ? _ + f : l;
|
|
200
|
+
a.handlers.value(v.toString(), e);
|
|
201
|
+
}
|
|
202
|
+
}), u(d(a), "stepDown", function(e) {
|
|
203
|
+
var r = a.asProps, t = r.max, l = r.min, i = l === void 0 ? Number.MIN_SAFE_INTEGER : l, f = r.step, p = r.value, _;
|
|
204
|
+
if (p === "" ? _ = t ?? 0 : _ = Number.parseFloat(p), !Number.isNaN(_)) {
|
|
205
|
+
var v = _ - f >= i ? _ - f : i;
|
|
206
|
+
a.handlers.value(v.toString(), e);
|
|
207
|
+
}
|
|
208
|
+
}), a;
|
|
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 o = n.asProps, e = o.value, r = o.displayValue, t = n.valueParser(s, e, r), l = t.parsedValue, i = t.displayValue;
|
|
218
|
+
return n.handlers.displayValue(i), l;
|
|
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 o = Math.floor(s) === s ? 0 : s.toString().split(".")[1].length || 0;
|
|
238
|
+
return o === 0 ? Number.parseFloat(n) : Number.parseFloat(n).toPrecision(o);
|
|
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, o = s.inputRef, e = s.value;
|
|
248
|
+
if (o.current && (o.current.stepUp = this.stepUp, o.current.stepDown = this.stepDown), e !== "") {
|
|
249
|
+
var r = this.valueParser(e, "", ""), t = r.displayValue;
|
|
250
|
+
this.handlers.displayValue(t);
|
|
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), o = s.displayValue;
|
|
259
|
+
this.handlers.displayValue(o);
|
|
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, o = V.Value, e = this.asProps, r = e.styles, t = e.min, l = e.max, i = e.step, f = e.forwardRef, p = e.inputRef, _ = e.displayValue;
|
|
272
|
+
return s = w(r), /* @__PURE__ */ h.createElement(h.Fragment, null, /* @__PURE__ */ h.createElement(o, s.cn("SValue", D({}, 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(i) ? "numeric" : "decimal",
|
|
282
|
+
min: t,
|
|
283
|
+
max: l,
|
|
284
|
+
step: i
|
|
285
|
+
}, n)))));
|
|
286
|
+
}
|
|
287
|
+
}]), c;
|
|
288
|
+
}($);
|
|
289
|
+
u(E, "style", N);
|
|
290
|
+
u(E, "defaultProps", {
|
|
291
|
+
defaultValue: "",
|
|
292
|
+
defaultDisplayValue: "",
|
|
293
|
+
step: 1
|
|
294
|
+
});
|
|
295
|
+
function T(m) {
|
|
296
|
+
var g = arguments[0], c, a = m.Children, n = m.increment, s = m.decrement, o = m.size, e = m.styles, r = m.getI18nText, t = V.Addon, l = "button", i = "button";
|
|
297
|
+
return c = w(e), /* @__PURE__ */ h.createElement(t, c.cn("SControls", D({}, R({
|
|
298
|
+
"aria-hidden": "true"
|
|
299
|
+
}, g))), /* @__PURE__ */ h.createElement(l, c.cn("SUp", {
|
|
300
|
+
onClick: n,
|
|
301
|
+
tabIndex: -1,
|
|
302
|
+
type: "button",
|
|
303
|
+
size: o,
|
|
304
|
+
"aria-label": r("increment")
|
|
305
|
+
}), /* @__PURE__ */ h.createElement(W, c.cn("IncrementIcon", {}))), /* @__PURE__ */ h.createElement(i, c.cn("SDown", {
|
|
306
|
+
onClick: s,
|
|
307
|
+
tabIndex: -1,
|
|
308
|
+
type: "button",
|
|
309
|
+
size: o,
|
|
310
|
+
"aria-label": r("decrement")
|
|
311
|
+
}), /* @__PURE__ */ h.createElement(K, c.cn("DecrementIcon", {}))), /* @__PURE__ */ h.createElement(a, c.cn("Children", {})));
|
|
312
|
+
}
|
|
313
|
+
T.style = N;
|
|
314
|
+
const le = z(P, {
|
|
315
|
+
Value: E,
|
|
316
|
+
Controls: T,
|
|
317
|
+
Addon: V.Addon
|
|
318
|
+
});
|
|
319
|
+
export {
|
|
320
|
+
le 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.0
|
|
4
|
+
"version": "5.41.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.0
|
|
13
|
-
"@semcore/utils": "4.
|
|
14
|
-
"@semcore/flex-box": "5.41.0
|
|
17
|
+
"@semcore/input": "4.42.0",
|
|
18
|
+
"@semcore/utils": "4.48.0",
|
|
19
|
+
"@semcore/flex-box": "5.41.0"
|
|
15
20
|
},
|
|
16
21
|
"peerDependencies": {
|
|
17
|
-
"@semcore/core": "^2.
|
|
22
|
+
"@semcore/core": "^2.17.5",
|
|
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
|
+
);
|