numora-react 1.0.5 → 1.0.7
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/dist/handlers.d.ts +25 -0
- package/dist/index.cjs +171 -0
- package/dist/index.cjs.js +158 -511
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.esm.js +152 -512
- package/dist/index.esm.js.map +1 -1
- package/package.json +20 -12
- package/rollup.config.mjs +0 -10
- package/src/handlers.ts +107 -0
- package/src/index.tsx +164 -101
package/dist/index.cjs.js
CHANGED
|
@@ -1,524 +1,171 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
4
5
|
var numora = require('numora');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
var hasRequiredReactJsxRuntime_production;
|
|
21
|
-
|
|
22
|
-
function requireReactJsxRuntime_production () {
|
|
23
|
-
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
24
|
-
hasRequiredReactJsxRuntime_production = 1;
|
|
25
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
26
|
-
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
27
|
-
function jsxProd(type, config, maybeKey) {
|
|
28
|
-
var key = null;
|
|
29
|
-
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
30
|
-
void 0 !== config.key && (key = "" + config.key);
|
|
31
|
-
if ("key" in config) {
|
|
32
|
-
maybeKey = {};
|
|
33
|
-
for (var propName in config)
|
|
34
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
35
|
-
} else maybeKey = config;
|
|
36
|
-
config = maybeKey.ref;
|
|
37
|
-
return {
|
|
38
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
39
|
-
type: type,
|
|
40
|
-
key: key,
|
|
41
|
-
ref: void 0 !== config ? config : null,
|
|
42
|
-
props: maybeKey
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
46
|
-
reactJsxRuntime_production.jsx = jsxProd;
|
|
47
|
-
reactJsxRuntime_production.jsxs = jsxProd;
|
|
48
|
-
return reactJsxRuntime_production;
|
|
7
|
+
function handleNumoraOnChange(e, options) {
|
|
8
|
+
numora.handleOnChangeNumoraInput(e.nativeEvent, options.decimalMaxLength, options.caretPositionBeforeChange, options.formattingOptions);
|
|
9
|
+
const target = e.target;
|
|
10
|
+
const rawValue = target.getAttribute('data-raw-value') ?? undefined;
|
|
11
|
+
if (rawValue) {
|
|
12
|
+
target.removeAttribute('data-raw-value');
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
value: target.value,
|
|
16
|
+
rawValue,
|
|
17
|
+
};
|
|
49
18
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
var hasRequiredReactJsxRuntime_development;
|
|
64
|
-
|
|
65
|
-
function requireReactJsxRuntime_development () {
|
|
66
|
-
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
67
|
-
hasRequiredReactJsxRuntime_development = 1;
|
|
68
|
-
"production" !== process.env.NODE_ENV &&
|
|
69
|
-
(function () {
|
|
70
|
-
function getComponentNameFromType(type) {
|
|
71
|
-
if (null == type) return null;
|
|
72
|
-
if ("function" === typeof type)
|
|
73
|
-
return type.$$typeof === REACT_CLIENT_REFERENCE
|
|
74
|
-
? null
|
|
75
|
-
: type.displayName || type.name || null;
|
|
76
|
-
if ("string" === typeof type) return type;
|
|
77
|
-
switch (type) {
|
|
78
|
-
case REACT_FRAGMENT_TYPE:
|
|
79
|
-
return "Fragment";
|
|
80
|
-
case REACT_PROFILER_TYPE:
|
|
81
|
-
return "Profiler";
|
|
82
|
-
case REACT_STRICT_MODE_TYPE:
|
|
83
|
-
return "StrictMode";
|
|
84
|
-
case REACT_SUSPENSE_TYPE:
|
|
85
|
-
return "Suspense";
|
|
86
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
87
|
-
return "SuspenseList";
|
|
88
|
-
case REACT_ACTIVITY_TYPE:
|
|
89
|
-
return "Activity";
|
|
90
|
-
}
|
|
91
|
-
if ("object" === typeof type)
|
|
92
|
-
switch (
|
|
93
|
-
("number" === typeof type.tag &&
|
|
94
|
-
console.error(
|
|
95
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
96
|
-
),
|
|
97
|
-
type.$$typeof)
|
|
98
|
-
) {
|
|
99
|
-
case REACT_PORTAL_TYPE:
|
|
100
|
-
return "Portal";
|
|
101
|
-
case REACT_CONTEXT_TYPE:
|
|
102
|
-
return (type.displayName || "Context") + ".Provider";
|
|
103
|
-
case REACT_CONSUMER_TYPE:
|
|
104
|
-
return (type._context.displayName || "Context") + ".Consumer";
|
|
105
|
-
case REACT_FORWARD_REF_TYPE:
|
|
106
|
-
var innerType = type.render;
|
|
107
|
-
type = type.displayName;
|
|
108
|
-
type ||
|
|
109
|
-
((type = innerType.displayName || innerType.name || ""),
|
|
110
|
-
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
|
|
111
|
-
return type;
|
|
112
|
-
case REACT_MEMO_TYPE:
|
|
113
|
-
return (
|
|
114
|
-
(innerType = type.displayName || null),
|
|
115
|
-
null !== innerType
|
|
116
|
-
? innerType
|
|
117
|
-
: getComponentNameFromType(type.type) || "Memo"
|
|
118
|
-
);
|
|
119
|
-
case REACT_LAZY_TYPE:
|
|
120
|
-
innerType = type._payload;
|
|
121
|
-
type = type._init;
|
|
122
|
-
try {
|
|
123
|
-
return getComponentNameFromType(type(innerType));
|
|
124
|
-
} catch (x) {}
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
function testStringCoercion(value) {
|
|
129
|
-
return "" + value;
|
|
130
|
-
}
|
|
131
|
-
function checkKeyStringCoercion(value) {
|
|
132
|
-
try {
|
|
133
|
-
testStringCoercion(value);
|
|
134
|
-
var JSCompiler_inline_result = !1;
|
|
135
|
-
} catch (e) {
|
|
136
|
-
JSCompiler_inline_result = true;
|
|
137
|
-
}
|
|
138
|
-
if (JSCompiler_inline_result) {
|
|
139
|
-
JSCompiler_inline_result = console;
|
|
140
|
-
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
141
|
-
var JSCompiler_inline_result$jscomp$0 =
|
|
142
|
-
("function" === typeof Symbol &&
|
|
143
|
-
Symbol.toStringTag &&
|
|
144
|
-
value[Symbol.toStringTag]) ||
|
|
145
|
-
value.constructor.name ||
|
|
146
|
-
"Object";
|
|
147
|
-
JSCompiler_temp_const.call(
|
|
148
|
-
JSCompiler_inline_result,
|
|
149
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
150
|
-
JSCompiler_inline_result$jscomp$0
|
|
151
|
-
);
|
|
152
|
-
return testStringCoercion(value);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function getTaskName(type) {
|
|
156
|
-
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
157
|
-
if (
|
|
158
|
-
"object" === typeof type &&
|
|
159
|
-
null !== type &&
|
|
160
|
-
type.$$typeof === REACT_LAZY_TYPE
|
|
161
|
-
)
|
|
162
|
-
return "<...>";
|
|
163
|
-
try {
|
|
164
|
-
var name = getComponentNameFromType(type);
|
|
165
|
-
return name ? "<" + name + ">" : "<...>";
|
|
166
|
-
} catch (x) {
|
|
167
|
-
return "<...>";
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function getOwner() {
|
|
171
|
-
var dispatcher = ReactSharedInternals.A;
|
|
172
|
-
return null === dispatcher ? null : dispatcher.getOwner();
|
|
173
|
-
}
|
|
174
|
-
function UnknownOwner() {
|
|
175
|
-
return Error("react-stack-top-frame");
|
|
176
|
-
}
|
|
177
|
-
function hasValidKey(config) {
|
|
178
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
179
|
-
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
180
|
-
if (getter && getter.isReactWarning) return false;
|
|
181
|
-
}
|
|
182
|
-
return void 0 !== config.key;
|
|
183
|
-
}
|
|
184
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
185
|
-
function warnAboutAccessingKey() {
|
|
186
|
-
specialPropKeyWarningShown ||
|
|
187
|
-
((specialPropKeyWarningShown = true),
|
|
188
|
-
console.error(
|
|
189
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
190
|
-
displayName
|
|
191
|
-
));
|
|
192
|
-
}
|
|
193
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
194
|
-
Object.defineProperty(props, "key", {
|
|
195
|
-
get: warnAboutAccessingKey,
|
|
196
|
-
configurable: true
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
function elementRefGetterWithDeprecationWarning() {
|
|
200
|
-
var componentName = getComponentNameFromType(this.type);
|
|
201
|
-
didWarnAboutElementRef[componentName] ||
|
|
202
|
-
((didWarnAboutElementRef[componentName] = true),
|
|
203
|
-
console.error(
|
|
204
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
205
|
-
));
|
|
206
|
-
componentName = this.props.ref;
|
|
207
|
-
return void 0 !== componentName ? componentName : null;
|
|
208
|
-
}
|
|
209
|
-
function ReactElement(
|
|
210
|
-
type,
|
|
211
|
-
key,
|
|
212
|
-
self,
|
|
213
|
-
source,
|
|
214
|
-
owner,
|
|
215
|
-
props,
|
|
216
|
-
debugStack,
|
|
217
|
-
debugTask
|
|
218
|
-
) {
|
|
219
|
-
self = props.ref;
|
|
220
|
-
type = {
|
|
221
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
222
|
-
type: type,
|
|
223
|
-
key: key,
|
|
224
|
-
props: props,
|
|
225
|
-
_owner: owner
|
|
226
|
-
};
|
|
227
|
-
null !== (void 0 !== self ? self : null)
|
|
228
|
-
? Object.defineProperty(type, "ref", {
|
|
229
|
-
enumerable: false,
|
|
230
|
-
get: elementRefGetterWithDeprecationWarning
|
|
231
|
-
})
|
|
232
|
-
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
233
|
-
type._store = {};
|
|
234
|
-
Object.defineProperty(type._store, "validated", {
|
|
235
|
-
configurable: false,
|
|
236
|
-
enumerable: false,
|
|
237
|
-
writable: true,
|
|
238
|
-
value: 0
|
|
239
|
-
});
|
|
240
|
-
Object.defineProperty(type, "_debugInfo", {
|
|
241
|
-
configurable: false,
|
|
242
|
-
enumerable: false,
|
|
243
|
-
writable: true,
|
|
244
|
-
value: null
|
|
245
|
-
});
|
|
246
|
-
Object.defineProperty(type, "_debugStack", {
|
|
247
|
-
configurable: false,
|
|
248
|
-
enumerable: false,
|
|
249
|
-
writable: true,
|
|
250
|
-
value: debugStack
|
|
251
|
-
});
|
|
252
|
-
Object.defineProperty(type, "_debugTask", {
|
|
253
|
-
configurable: false,
|
|
254
|
-
enumerable: false,
|
|
255
|
-
writable: true,
|
|
256
|
-
value: debugTask
|
|
257
|
-
});
|
|
258
|
-
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
259
|
-
return type;
|
|
260
|
-
}
|
|
261
|
-
function jsxDEVImpl(
|
|
262
|
-
type,
|
|
263
|
-
config,
|
|
264
|
-
maybeKey,
|
|
265
|
-
isStaticChildren,
|
|
266
|
-
source,
|
|
267
|
-
self,
|
|
268
|
-
debugStack,
|
|
269
|
-
debugTask
|
|
270
|
-
) {
|
|
271
|
-
var children = config.children;
|
|
272
|
-
if (void 0 !== children)
|
|
273
|
-
if (isStaticChildren)
|
|
274
|
-
if (isArrayImpl(children)) {
|
|
275
|
-
for (
|
|
276
|
-
isStaticChildren = 0;
|
|
277
|
-
isStaticChildren < children.length;
|
|
278
|
-
isStaticChildren++
|
|
279
|
-
)
|
|
280
|
-
validateChildKeys(children[isStaticChildren]);
|
|
281
|
-
Object.freeze && Object.freeze(children);
|
|
282
|
-
} else
|
|
283
|
-
console.error(
|
|
284
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
285
|
-
);
|
|
286
|
-
else validateChildKeys(children);
|
|
287
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
288
|
-
children = getComponentNameFromType(type);
|
|
289
|
-
var keys = Object.keys(config).filter(function (k) {
|
|
290
|
-
return "key" !== k;
|
|
291
|
-
});
|
|
292
|
-
isStaticChildren =
|
|
293
|
-
0 < keys.length
|
|
294
|
-
? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
|
|
295
|
-
: "{key: someKey}";
|
|
296
|
-
didWarnAboutKeySpread[children + isStaticChildren] ||
|
|
297
|
-
((keys =
|
|
298
|
-
0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
|
|
299
|
-
console.error(
|
|
300
|
-
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
301
|
-
isStaticChildren,
|
|
302
|
-
children,
|
|
303
|
-
keys,
|
|
304
|
-
children
|
|
305
|
-
),
|
|
306
|
-
(didWarnAboutKeySpread[children + isStaticChildren] = true));
|
|
307
|
-
}
|
|
308
|
-
children = null;
|
|
309
|
-
void 0 !== maybeKey &&
|
|
310
|
-
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
|
|
311
|
-
hasValidKey(config) &&
|
|
312
|
-
(checkKeyStringCoercion(config.key), (children = "" + config.key));
|
|
313
|
-
if ("key" in config) {
|
|
314
|
-
maybeKey = {};
|
|
315
|
-
for (var propName in config)
|
|
316
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
317
|
-
} else maybeKey = config;
|
|
318
|
-
children &&
|
|
319
|
-
defineKeyPropWarningGetter(
|
|
320
|
-
maybeKey,
|
|
321
|
-
"function" === typeof type
|
|
322
|
-
? type.displayName || type.name || "Unknown"
|
|
323
|
-
: type
|
|
324
|
-
);
|
|
325
|
-
return ReactElement(
|
|
326
|
-
type,
|
|
327
|
-
children,
|
|
328
|
-
self,
|
|
329
|
-
source,
|
|
330
|
-
getOwner(),
|
|
331
|
-
maybeKey,
|
|
332
|
-
debugStack,
|
|
333
|
-
debugTask
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
function validateChildKeys(node) {
|
|
337
|
-
"object" === typeof node &&
|
|
338
|
-
null !== node &&
|
|
339
|
-
node.$$typeof === REACT_ELEMENT_TYPE &&
|
|
340
|
-
node._store &&
|
|
341
|
-
(node._store.validated = 1);
|
|
342
|
-
}
|
|
343
|
-
var React = require$$0,
|
|
344
|
-
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
345
|
-
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
346
|
-
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
347
|
-
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
348
|
-
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
349
|
-
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
350
|
-
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
351
|
-
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
352
|
-
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
353
|
-
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
354
|
-
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
355
|
-
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
356
|
-
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
357
|
-
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
358
|
-
ReactSharedInternals =
|
|
359
|
-
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
360
|
-
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
361
|
-
isArrayImpl = Array.isArray,
|
|
362
|
-
createTask = console.createTask
|
|
363
|
-
? console.createTask
|
|
364
|
-
: function () {
|
|
365
|
-
return null;
|
|
366
|
-
};
|
|
367
|
-
React = {
|
|
368
|
-
"react-stack-bottom-frame": function (callStackForError) {
|
|
369
|
-
return callStackForError();
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
var specialPropKeyWarningShown;
|
|
373
|
-
var didWarnAboutElementRef = {};
|
|
374
|
-
var unknownOwnerDebugStack = React["react-stack-bottom-frame"].bind(
|
|
375
|
-
React,
|
|
376
|
-
UnknownOwner
|
|
377
|
-
)();
|
|
378
|
-
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
379
|
-
var didWarnAboutKeySpread = {};
|
|
380
|
-
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
381
|
-
reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
|
|
382
|
-
var trackActualOwner =
|
|
383
|
-
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
384
|
-
return jsxDEVImpl(
|
|
385
|
-
type,
|
|
386
|
-
config,
|
|
387
|
-
maybeKey,
|
|
388
|
-
false,
|
|
389
|
-
source,
|
|
390
|
-
self,
|
|
391
|
-
trackActualOwner
|
|
392
|
-
? Error("react-stack-top-frame")
|
|
393
|
-
: unknownOwnerDebugStack,
|
|
394
|
-
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
395
|
-
);
|
|
396
|
-
};
|
|
397
|
-
reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
|
|
398
|
-
var trackActualOwner =
|
|
399
|
-
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
400
|
-
return jsxDEVImpl(
|
|
401
|
-
type,
|
|
402
|
-
config,
|
|
403
|
-
maybeKey,
|
|
404
|
-
true,
|
|
405
|
-
source,
|
|
406
|
-
self,
|
|
407
|
-
trackActualOwner
|
|
408
|
-
? Error("react-stack-top-frame")
|
|
409
|
-
: unknownOwnerDebugStack,
|
|
410
|
-
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
411
|
-
);
|
|
412
|
-
};
|
|
413
|
-
})();
|
|
414
|
-
return reactJsxRuntime_development;
|
|
19
|
+
function handleNumoraOnPaste(e, options) {
|
|
20
|
+
const value = numora.handleOnPasteNumoraInput(e.nativeEvent, options.decimalMaxLength, options.formattingOptions);
|
|
21
|
+
const target = e.target;
|
|
22
|
+
const rawValue = target.getAttribute('data-raw-value') ?? undefined;
|
|
23
|
+
if (rawValue) {
|
|
24
|
+
target.removeAttribute('data-raw-value');
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
value,
|
|
28
|
+
rawValue,
|
|
29
|
+
};
|
|
415
30
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
function requireJsxRuntime () {
|
|
420
|
-
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
421
|
-
hasRequiredJsxRuntime = 1;
|
|
422
|
-
|
|
423
|
-
if (process.env.NODE_ENV === 'production') {
|
|
424
|
-
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
425
|
-
} else {
|
|
426
|
-
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
427
|
-
}
|
|
428
|
-
return jsxRuntime.exports;
|
|
31
|
+
function handleNumoraOnKeyDown(e, formattingOptions) {
|
|
32
|
+
return numora.handleOnKeyDownNumoraInput(e.nativeEvent, formattingOptions);
|
|
429
33
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
autoComplete: 'off',
|
|
435
|
-
autoCorrect: 'off',
|
|
436
|
-
autoCapitalize: 'none',
|
|
437
|
-
minLength: 1,
|
|
438
|
-
placeholder: '0.0',
|
|
439
|
-
pattern: '^[0-9]*[.,]?[0-9]*$',
|
|
440
|
-
spellCheck: false,
|
|
441
|
-
step: 'any'
|
|
442
|
-
};
|
|
443
|
-
const NumoraInput = /*#__PURE__*/require$$0.forwardRef((_ref, ref) => {
|
|
444
|
-
let {
|
|
445
|
-
maxDecimals = 2,
|
|
446
|
-
onChange,
|
|
447
|
-
formatOn = numora.FormatOn.Blur,
|
|
448
|
-
thousandSeparator = ',',
|
|
449
|
-
thousandStyle = numora.ThousandStyle.Thousand,
|
|
450
|
-
decimalSeparator = '.',
|
|
451
|
-
decimalMinLength,
|
|
452
|
-
enableCompactNotation = false,
|
|
453
|
-
enableNegative = false,
|
|
454
|
-
enableLeadingZeros = false,
|
|
455
|
-
rawValueMode = false,
|
|
456
|
-
...props
|
|
457
|
-
} = _ref;
|
|
458
|
-
const [caretPositionBeforeChange, setCaretPositionBeforeChange] = require$$0.useState();
|
|
459
|
-
const formattingOptions = {
|
|
460
|
-
formatOn,
|
|
461
|
-
thousandSeparator,
|
|
462
|
-
ThousandStyle: thousandStyle,
|
|
463
|
-
decimalSeparator,
|
|
464
|
-
decimalMinLength,
|
|
465
|
-
enableCompactNotation,
|
|
466
|
-
enableNegative,
|
|
467
|
-
enableLeadingZeros,
|
|
468
|
-
rawValueMode
|
|
469
|
-
};
|
|
470
|
-
function handleOnKeyDown(e) {
|
|
471
|
-
const caretInfo = numora.handleOnKeyDownNumoraInput(e.nativeEvent, formattingOptions);
|
|
472
|
-
if (caretInfo) {
|
|
473
|
-
setCaretPositionBeforeChange(caretInfo);
|
|
474
|
-
} else {
|
|
475
|
-
const input = e.currentTarget;
|
|
476
|
-
setCaretPositionBeforeChange({
|
|
477
|
-
selectionStart: input.selectionStart ?? 0,
|
|
478
|
-
selectionEnd: input.selectionEnd ?? 0
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
if (props.onKeyDown) {
|
|
482
|
-
props.onKeyDown(e);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
function handleOnChange(e) {
|
|
486
|
-
numora.handleOnChangeNumoraInput(e.nativeEvent, maxDecimals, caretPositionBeforeChange, formattingOptions);
|
|
487
|
-
setCaretPositionBeforeChange(undefined);
|
|
488
|
-
if (onChange) onChange(e);
|
|
489
|
-
}
|
|
490
|
-
function handleOnPaste(e) {
|
|
491
|
-
numora.handleOnPasteNumoraInput(e.nativeEvent, maxDecimals, formattingOptions);
|
|
492
|
-
if (onChange) onChange(e);
|
|
493
|
-
}
|
|
494
|
-
function handleOnFocus(e) {
|
|
495
|
-
if (formatOn === numora.FormatOn.Blur && thousandSeparator) {
|
|
496
|
-
const target = e.currentTarget;
|
|
497
|
-
target.value = target.value.replace(new RegExp(thousandSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), '');
|
|
34
|
+
function handleNumoraOnBlur(e, options) {
|
|
35
|
+
// If formatOn is blur, force formatting on blur by invoking change handler logic
|
|
36
|
+
if (options.formattingOptions.formatOn === numora.FormatOn.Blur) {
|
|
37
|
+
numora.handleOnChangeNumoraInput(e.nativeEvent, options.decimalMaxLength, undefined, { ...options.formattingOptions, formatOn: numora.FormatOn.Change });
|
|
498
38
|
}
|
|
499
|
-
|
|
500
|
-
|
|
39
|
+
const target = e.target;
|
|
40
|
+
const rawValue = target.getAttribute('data-raw-value') ?? undefined;
|
|
41
|
+
if (rawValue) {
|
|
42
|
+
target.removeAttribute('data-raw-value');
|
|
501
43
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
...
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
44
|
+
return {
|
|
45
|
+
value: target.value,
|
|
46
|
+
rawValue,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const NumoraInput = react.forwardRef((props, ref) => {
|
|
51
|
+
const { maxDecimals = 2, onChange, onPaste, onBlur, onKeyDown, formatOn = numora.FormatOn.Blur, thousandSeparator = ',', thousandStyle = numora.ThousandStyle.Thousand, decimalSeparator = '.', decimalMinLength, enableCompactNotation = false, enableNegative = false, enableLeadingZeros = false, rawValueMode = false, value: controlledValue, defaultValue, ...rest } = props;
|
|
52
|
+
const inputRef = react.useRef(null);
|
|
53
|
+
const caretInfoRef = react.useRef(undefined);
|
|
54
|
+
const [internalValue, setInternalValue] = react.useState(controlledValue !== undefined
|
|
55
|
+
? String(controlledValue)
|
|
56
|
+
: defaultValue !== undefined
|
|
57
|
+
? String(defaultValue)
|
|
58
|
+
: '');
|
|
59
|
+
// Keep internal state in sync when controlled
|
|
60
|
+
react.useEffect(() => {
|
|
61
|
+
if (controlledValue !== undefined) {
|
|
62
|
+
setInternalValue(String(controlledValue));
|
|
63
|
+
}
|
|
64
|
+
}, [controlledValue]);
|
|
65
|
+
react.useImperativeHandle(ref, () => inputRef.current, []);
|
|
66
|
+
const formattingOptions = {
|
|
67
|
+
formatOn,
|
|
68
|
+
thousandSeparator,
|
|
69
|
+
ThousandStyle: thousandStyle,
|
|
70
|
+
decimalSeparator,
|
|
71
|
+
decimalMinLength,
|
|
72
|
+
enableCompactNotation,
|
|
73
|
+
enableNegative,
|
|
74
|
+
enableLeadingZeros,
|
|
75
|
+
rawValueMode,
|
|
76
|
+
};
|
|
77
|
+
const formatValueWithCore = (value) => {
|
|
78
|
+
const el = inputRef.current ?? document.createElement('input');
|
|
79
|
+
el.value = value;
|
|
80
|
+
const fakeEvent = { target: el };
|
|
81
|
+
numora.handleOnChangeNumoraInput(fakeEvent, maxDecimals, undefined, formattingOptions);
|
|
82
|
+
return el.value;
|
|
83
|
+
};
|
|
84
|
+
// When controlled value changes, normalize/format it for display
|
|
85
|
+
react.useEffect(() => {
|
|
86
|
+
if (controlledValue !== undefined) {
|
|
87
|
+
const formatted = formatValueWithCore(String(controlledValue));
|
|
88
|
+
setInternalValue(formatted);
|
|
89
|
+
}
|
|
90
|
+
}, [controlledValue, formatOn, thousandSeparator, thousandStyle, decimalSeparator, decimalMinLength, enableCompactNotation, enableNegative, enableLeadingZeros, rawValueMode, maxDecimals]);
|
|
91
|
+
const handleChange = (e) => {
|
|
92
|
+
const { value, rawValue } = handleNumoraOnChange(e, {
|
|
93
|
+
decimalMaxLength: maxDecimals,
|
|
94
|
+
caretPositionBeforeChange: caretInfoRef.current,
|
|
95
|
+
formattingOptions,
|
|
96
|
+
});
|
|
97
|
+
caretInfoRef.current = undefined;
|
|
98
|
+
if (controlledValue === undefined) {
|
|
99
|
+
setInternalValue(value);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
setInternalValue(value);
|
|
103
|
+
}
|
|
104
|
+
if (onChange) {
|
|
105
|
+
onChange(e);
|
|
106
|
+
}
|
|
107
|
+
// Optionally expose rawValue via a custom event attribute if needed later
|
|
108
|
+
if (rawValue && e.target && rawValueMode) {
|
|
109
|
+
// Keep the raw value on the input for consumers that read it directly
|
|
110
|
+
e.target.setAttribute('data-raw-value', rawValue);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const handlePaste = (e) => {
|
|
114
|
+
const { value, rawValue } = handleNumoraOnPaste(e, {
|
|
115
|
+
decimalMaxLength: maxDecimals,
|
|
116
|
+
formattingOptions,
|
|
117
|
+
});
|
|
118
|
+
if (controlledValue === undefined) {
|
|
119
|
+
setInternalValue(value);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
setInternalValue(value);
|
|
123
|
+
}
|
|
124
|
+
if (onPaste) {
|
|
125
|
+
onPaste(e);
|
|
126
|
+
}
|
|
127
|
+
if (onChange) {
|
|
128
|
+
onChange(e);
|
|
129
|
+
}
|
|
130
|
+
if (rawValue && e.target && rawValueMode) {
|
|
131
|
+
e.target.setAttribute('data-raw-value', rawValue);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const handleKeyDown = (e) => {
|
|
135
|
+
caretInfoRef.current = handleNumoraOnKeyDown(e, formattingOptions);
|
|
136
|
+
if (onKeyDown) {
|
|
137
|
+
onKeyDown(e);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const handleBlur = (e) => {
|
|
141
|
+
const { value, rawValue } = handleNumoraOnBlur(e, {
|
|
142
|
+
decimalMaxLength: maxDecimals,
|
|
143
|
+
formattingOptions,
|
|
144
|
+
});
|
|
145
|
+
if (controlledValue === undefined) {
|
|
146
|
+
setInternalValue(value);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
setInternalValue(value);
|
|
150
|
+
}
|
|
151
|
+
if (onBlur) {
|
|
152
|
+
onBlur(e);
|
|
153
|
+
}
|
|
154
|
+
if (rawValue && e.target && rawValueMode) {
|
|
155
|
+
e.target.setAttribute('data-raw-value', rawValue);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return (jsxRuntime.jsx("input", { ...rest, ref: inputRef, value: internalValue, onChange: handleChange, onPaste: handlePaste, onKeyDown: handleKeyDown, onBlur: handleBlur, type: "text", inputMode: "decimal" }));
|
|
520
159
|
});
|
|
521
160
|
NumoraInput.displayName = 'NumoraInput';
|
|
522
161
|
|
|
523
|
-
|
|
162
|
+
Object.defineProperty(exports, "FormatOn", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () { return numora.FormatOn; }
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "ThousandStyle", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function () { return numora.ThousandStyle; }
|
|
169
|
+
});
|
|
170
|
+
exports.NumoraInput = NumoraInput;
|
|
524
171
|
//# sourceMappingURL=index.cjs.js.map
|