numora-react 1.0.8 → 3.0.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/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { FormatOn, ThousandStyle } from 'numora';
3
- interface NumoraInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'type' | 'inputMode'> {
3
+ export interface NumoraInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'type' | 'inputMode'> {
4
4
  maxDecimals?: number;
5
- onChange?: (e: React.ChangeEvent<HTMLInputElement> | React.ClipboardEvent<HTMLInputElement>) => void;
5
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
6
6
  formatOn?: FormatOn;
7
7
  thousandSeparator?: string;
8
8
  thousandStyle?: ThousandStyle;
package/dist/index.js ADDED
@@ -0,0 +1,604 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('react');
4
+ var numora = require('numora');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
9
+
10
+ var jsxRuntime = {exports: {}};
11
+
12
+ var reactJsxRuntime_production = {};
13
+
14
+ /**
15
+ * @license React
16
+ * react-jsx-runtime.production.js
17
+ *
18
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ */
23
+
24
+ var hasRequiredReactJsxRuntime_production;
25
+
26
+ function requireReactJsxRuntime_production () {
27
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
28
+ hasRequiredReactJsxRuntime_production = 1;
29
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
30
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
31
+ function jsxProd(type, config, maybeKey) {
32
+ var key = null;
33
+ void 0 !== maybeKey && (key = "" + maybeKey);
34
+ void 0 !== config.key && (key = "" + config.key);
35
+ if ("key" in config) {
36
+ maybeKey = {};
37
+ for (var propName in config)
38
+ "key" !== propName && (maybeKey[propName] = config[propName]);
39
+ } else maybeKey = config;
40
+ config = maybeKey.ref;
41
+ return {
42
+ $$typeof: REACT_ELEMENT_TYPE,
43
+ type: type,
44
+ key: key,
45
+ ref: void 0 !== config ? config : null,
46
+ props: maybeKey
47
+ };
48
+ }
49
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
50
+ reactJsxRuntime_production.jsx = jsxProd;
51
+ reactJsxRuntime_production.jsxs = jsxProd;
52
+ return reactJsxRuntime_production;
53
+ }
54
+
55
+ var reactJsxRuntime_development = {};
56
+
57
+ /**
58
+ * @license React
59
+ * react-jsx-runtime.development.js
60
+ *
61
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
62
+ *
63
+ * This source code is licensed under the MIT license found in the
64
+ * LICENSE file in the root directory of this source tree.
65
+ */
66
+
67
+ var hasRequiredReactJsxRuntime_development;
68
+
69
+ function requireReactJsxRuntime_development () {
70
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
71
+ hasRequiredReactJsxRuntime_development = 1;
72
+ "production" !== process.env.NODE_ENV &&
73
+ (function () {
74
+ function getComponentNameFromType(type) {
75
+ if (null == type) return null;
76
+ if ("function" === typeof type)
77
+ return type.$$typeof === REACT_CLIENT_REFERENCE
78
+ ? null
79
+ : type.displayName || type.name || null;
80
+ if ("string" === typeof type) return type;
81
+ switch (type) {
82
+ case REACT_FRAGMENT_TYPE:
83
+ return "Fragment";
84
+ case REACT_PROFILER_TYPE:
85
+ return "Profiler";
86
+ case REACT_STRICT_MODE_TYPE:
87
+ return "StrictMode";
88
+ case REACT_SUSPENSE_TYPE:
89
+ return "Suspense";
90
+ case REACT_SUSPENSE_LIST_TYPE:
91
+ return "SuspenseList";
92
+ case REACT_ACTIVITY_TYPE:
93
+ return "Activity";
94
+ }
95
+ if ("object" === typeof type)
96
+ switch (
97
+ ("number" === typeof type.tag &&
98
+ console.error(
99
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
100
+ ),
101
+ type.$$typeof)
102
+ ) {
103
+ case REACT_PORTAL_TYPE:
104
+ return "Portal";
105
+ case REACT_CONTEXT_TYPE:
106
+ return type.displayName || "Context";
107
+ case REACT_CONSUMER_TYPE:
108
+ return (type._context.displayName || "Context") + ".Consumer";
109
+ case REACT_FORWARD_REF_TYPE:
110
+ var innerType = type.render;
111
+ type = type.displayName;
112
+ type ||
113
+ ((type = innerType.displayName || innerType.name || ""),
114
+ (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
115
+ return type;
116
+ case REACT_MEMO_TYPE:
117
+ return (
118
+ (innerType = type.displayName || null),
119
+ null !== innerType
120
+ ? innerType
121
+ : getComponentNameFromType(type.type) || "Memo"
122
+ );
123
+ case REACT_LAZY_TYPE:
124
+ innerType = type._payload;
125
+ type = type._init;
126
+ try {
127
+ return getComponentNameFromType(type(innerType));
128
+ } catch (x) {}
129
+ }
130
+ return null;
131
+ }
132
+ function testStringCoercion(value) {
133
+ return "" + value;
134
+ }
135
+ function checkKeyStringCoercion(value) {
136
+ try {
137
+ testStringCoercion(value);
138
+ var JSCompiler_inline_result = !1;
139
+ } catch (e) {
140
+ JSCompiler_inline_result = true;
141
+ }
142
+ if (JSCompiler_inline_result) {
143
+ JSCompiler_inline_result = console;
144
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
145
+ var JSCompiler_inline_result$jscomp$0 =
146
+ ("function" === typeof Symbol &&
147
+ Symbol.toStringTag &&
148
+ value[Symbol.toStringTag]) ||
149
+ value.constructor.name ||
150
+ "Object";
151
+ JSCompiler_temp_const.call(
152
+ JSCompiler_inline_result,
153
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
154
+ JSCompiler_inline_result$jscomp$0
155
+ );
156
+ return testStringCoercion(value);
157
+ }
158
+ }
159
+ function getTaskName(type) {
160
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
161
+ if (
162
+ "object" === typeof type &&
163
+ null !== type &&
164
+ type.$$typeof === REACT_LAZY_TYPE
165
+ )
166
+ return "<...>";
167
+ try {
168
+ var name = getComponentNameFromType(type);
169
+ return name ? "<" + name + ">" : "<...>";
170
+ } catch (x) {
171
+ return "<...>";
172
+ }
173
+ }
174
+ function getOwner() {
175
+ var dispatcher = ReactSharedInternals.A;
176
+ return null === dispatcher ? null : dispatcher.getOwner();
177
+ }
178
+ function UnknownOwner() {
179
+ return Error("react-stack-top-frame");
180
+ }
181
+ function hasValidKey(config) {
182
+ if (hasOwnProperty.call(config, "key")) {
183
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
184
+ if (getter && getter.isReactWarning) return false;
185
+ }
186
+ return void 0 !== config.key;
187
+ }
188
+ function defineKeyPropWarningGetter(props, displayName) {
189
+ function warnAboutAccessingKey() {
190
+ specialPropKeyWarningShown ||
191
+ ((specialPropKeyWarningShown = true),
192
+ console.error(
193
+ "%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)",
194
+ displayName
195
+ ));
196
+ }
197
+ warnAboutAccessingKey.isReactWarning = true;
198
+ Object.defineProperty(props, "key", {
199
+ get: warnAboutAccessingKey,
200
+ configurable: true
201
+ });
202
+ }
203
+ function elementRefGetterWithDeprecationWarning() {
204
+ var componentName = getComponentNameFromType(this.type);
205
+ didWarnAboutElementRef[componentName] ||
206
+ ((didWarnAboutElementRef[componentName] = true),
207
+ console.error(
208
+ "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."
209
+ ));
210
+ componentName = this.props.ref;
211
+ return void 0 !== componentName ? componentName : null;
212
+ }
213
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
214
+ var refProp = props.ref;
215
+ type = {
216
+ $$typeof: REACT_ELEMENT_TYPE,
217
+ type: type,
218
+ key: key,
219
+ props: props,
220
+ _owner: owner
221
+ };
222
+ null !== (void 0 !== refProp ? refProp : null)
223
+ ? Object.defineProperty(type, "ref", {
224
+ enumerable: false,
225
+ get: elementRefGetterWithDeprecationWarning
226
+ })
227
+ : Object.defineProperty(type, "ref", { enumerable: false, value: null });
228
+ type._store = {};
229
+ Object.defineProperty(type._store, "validated", {
230
+ configurable: false,
231
+ enumerable: false,
232
+ writable: true,
233
+ value: 0
234
+ });
235
+ Object.defineProperty(type, "_debugInfo", {
236
+ configurable: false,
237
+ enumerable: false,
238
+ writable: true,
239
+ value: null
240
+ });
241
+ Object.defineProperty(type, "_debugStack", {
242
+ configurable: false,
243
+ enumerable: false,
244
+ writable: true,
245
+ value: debugStack
246
+ });
247
+ Object.defineProperty(type, "_debugTask", {
248
+ configurable: false,
249
+ enumerable: false,
250
+ writable: true,
251
+ value: debugTask
252
+ });
253
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
254
+ return type;
255
+ }
256
+ function jsxDEVImpl(
257
+ type,
258
+ config,
259
+ maybeKey,
260
+ isStaticChildren,
261
+ debugStack,
262
+ debugTask
263
+ ) {
264
+ var children = config.children;
265
+ if (void 0 !== children)
266
+ if (isStaticChildren)
267
+ if (isArrayImpl(children)) {
268
+ for (
269
+ isStaticChildren = 0;
270
+ isStaticChildren < children.length;
271
+ isStaticChildren++
272
+ )
273
+ validateChildKeys(children[isStaticChildren]);
274
+ Object.freeze && Object.freeze(children);
275
+ } else
276
+ console.error(
277
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
278
+ );
279
+ else validateChildKeys(children);
280
+ if (hasOwnProperty.call(config, "key")) {
281
+ children = getComponentNameFromType(type);
282
+ var keys = Object.keys(config).filter(function (k) {
283
+ return "key" !== k;
284
+ });
285
+ isStaticChildren =
286
+ 0 < keys.length
287
+ ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
288
+ : "{key: someKey}";
289
+ didWarnAboutKeySpread[children + isStaticChildren] ||
290
+ ((keys =
291
+ 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
292
+ console.error(
293
+ '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} />',
294
+ isStaticChildren,
295
+ children,
296
+ keys,
297
+ children
298
+ ),
299
+ (didWarnAboutKeySpread[children + isStaticChildren] = true));
300
+ }
301
+ children = null;
302
+ void 0 !== maybeKey &&
303
+ (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
304
+ hasValidKey(config) &&
305
+ (checkKeyStringCoercion(config.key), (children = "" + config.key));
306
+ if ("key" in config) {
307
+ maybeKey = {};
308
+ for (var propName in config)
309
+ "key" !== propName && (maybeKey[propName] = config[propName]);
310
+ } else maybeKey = config;
311
+ children &&
312
+ defineKeyPropWarningGetter(
313
+ maybeKey,
314
+ "function" === typeof type
315
+ ? type.displayName || type.name || "Unknown"
316
+ : type
317
+ );
318
+ return ReactElement(
319
+ type,
320
+ children,
321
+ maybeKey,
322
+ getOwner(),
323
+ debugStack,
324
+ debugTask
325
+ );
326
+ }
327
+ function validateChildKeys(node) {
328
+ isValidElement(node)
329
+ ? node._store && (node._store.validated = 1)
330
+ : "object" === typeof node &&
331
+ null !== node &&
332
+ node.$$typeof === REACT_LAZY_TYPE &&
333
+ ("fulfilled" === node._payload.status
334
+ ? isValidElement(node._payload.value) &&
335
+ node._payload.value._store &&
336
+ (node._payload.value._store.validated = 1)
337
+ : node._store && (node._store.validated = 1));
338
+ }
339
+ function isValidElement(object) {
340
+ return (
341
+ "object" === typeof object &&
342
+ null !== object &&
343
+ object.$$typeof === REACT_ELEMENT_TYPE
344
+ );
345
+ }
346
+ var React = require$$0__default.default,
347
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
348
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
349
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
350
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
351
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
352
+ REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
353
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
354
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
355
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
356
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
357
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
358
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
359
+ REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
360
+ REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
361
+ ReactSharedInternals =
362
+ React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
363
+ hasOwnProperty = Object.prototype.hasOwnProperty,
364
+ isArrayImpl = Array.isArray,
365
+ createTask = console.createTask
366
+ ? console.createTask
367
+ : function () {
368
+ return null;
369
+ };
370
+ React = {
371
+ react_stack_bottom_frame: function (callStackForError) {
372
+ return callStackForError();
373
+ }
374
+ };
375
+ var specialPropKeyWarningShown;
376
+ var didWarnAboutElementRef = {};
377
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
378
+ React,
379
+ UnknownOwner
380
+ )();
381
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
382
+ var didWarnAboutKeySpread = {};
383
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
384
+ reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
385
+ var trackActualOwner =
386
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
387
+ return jsxDEVImpl(
388
+ type,
389
+ config,
390
+ maybeKey,
391
+ false,
392
+ trackActualOwner
393
+ ? Error("react-stack-top-frame")
394
+ : unknownOwnerDebugStack,
395
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
396
+ );
397
+ };
398
+ reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
399
+ var trackActualOwner =
400
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
401
+ return jsxDEVImpl(
402
+ type,
403
+ config,
404
+ maybeKey,
405
+ true,
406
+ trackActualOwner
407
+ ? Error("react-stack-top-frame")
408
+ : unknownOwnerDebugStack,
409
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
410
+ );
411
+ };
412
+ })();
413
+ return reactJsxRuntime_development;
414
+ }
415
+
416
+ var hasRequiredJsxRuntime;
417
+
418
+ function requireJsxRuntime () {
419
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
420
+ hasRequiredJsxRuntime = 1;
421
+
422
+ if (process.env.NODE_ENV === 'production') {
423
+ jsxRuntime.exports = requireReactJsxRuntime_production();
424
+ } else {
425
+ jsxRuntime.exports = requireReactJsxRuntime_development();
426
+ }
427
+ return jsxRuntime.exports;
428
+ }
429
+
430
+ var jsxRuntimeExports = requireJsxRuntime();
431
+
432
+ function handleNumoraOnChange(e, options) {
433
+ const { formatted, raw } = numora.handleOnChangeNumoraInput(e.nativeEvent, options.decimalMaxLength, options.caretPositionBeforeChange, options.formattingOptions);
434
+ return {
435
+ value: formatted,
436
+ rawValue: raw,
437
+ };
438
+ }
439
+ function handleNumoraOnPaste(e, options) {
440
+ const { formatted, raw } = numora.handleOnPasteNumoraInput(e.nativeEvent, options.decimalMaxLength, options.formattingOptions);
441
+ return {
442
+ value: formatted,
443
+ rawValue: raw,
444
+ };
445
+ }
446
+ function handleNumoraOnKeyDown(e, formattingOptions) {
447
+ return numora.handleOnKeyDownNumoraInput(e.nativeEvent, formattingOptions);
448
+ }
449
+ function handleNumoraOnBlur(e, options) {
450
+ if (options.formattingOptions.formatOn === numora.FormatOn.Blur) {
451
+ const { formatted, raw } = numora.formatValueForDisplay(e.target.value, options.decimalMaxLength, { ...options.formattingOptions, formatOn: numora.FormatOn.Change });
452
+ return {
453
+ value: formatted,
454
+ rawValue: raw,
455
+ };
456
+ }
457
+ return {
458
+ value: e.target.value,
459
+ rawValue: undefined,
460
+ };
461
+ }
462
+
463
+ const NumoraInput = require$$0.forwardRef((props, ref) => {
464
+ 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;
465
+ const internalInputRef = require$$0.useRef(null);
466
+ const caretInfoRef = require$$0.useRef(undefined);
467
+ const lastCaretPosRef = require$$0.useRef(null);
468
+ const formattingOptions = {
469
+ formatOn,
470
+ thousandSeparator,
471
+ ThousandStyle: thousandStyle,
472
+ decimalSeparator,
473
+ decimalMinLength,
474
+ enableCompactNotation,
475
+ enableNegative,
476
+ enableLeadingZeros,
477
+ rawValueMode,
478
+ };
479
+ const getInitialValue = () => {
480
+ const valueToFormat = controlledValue !== undefined ? controlledValue : defaultValue;
481
+ if (valueToFormat !== undefined) {
482
+ const { formatted } = numora.formatValueForDisplay(String(valueToFormat), maxDecimals, formattingOptions);
483
+ return formatted;
484
+ }
485
+ return '';
486
+ };
487
+ const [displayValue, setDisplayValue] = require$$0.useState(getInitialValue);
488
+ // Sync external ref with internal ref
489
+ require$$0.useLayoutEffect(() => {
490
+ if (!ref)
491
+ return;
492
+ if (typeof ref === 'function') {
493
+ ref(internalInputRef.current);
494
+ }
495
+ else {
496
+ ref.current = internalInputRef.current;
497
+ }
498
+ }, [ref]);
499
+ // When controlled value changes from outside, update display value
500
+ require$$0.useEffect(() => {
501
+ if (controlledValue !== undefined) {
502
+ const { formatted } = numora.formatValueForDisplay(String(controlledValue), maxDecimals, formattingOptions);
503
+ if (formatted !== displayValue) {
504
+ setDisplayValue(formatted);
505
+ }
506
+ }
507
+ }, [controlledValue, maxDecimals, formattingOptions]);
508
+ // Restore cursor position after render
509
+ require$$0.useLayoutEffect(() => {
510
+ if (internalInputRef.current && lastCaretPosRef.current !== null) {
511
+ const input = internalInputRef.current;
512
+ const pos = lastCaretPosRef.current;
513
+ input.setSelectionRange(pos, pos);
514
+ lastCaretPosRef.current = null;
515
+ }
516
+ });
517
+ const handleChange = require$$0.useCallback((e) => {
518
+ const { value, rawValue } = handleNumoraOnChange(e, {
519
+ decimalMaxLength: maxDecimals,
520
+ caretPositionBeforeChange: caretInfoRef.current,
521
+ formattingOptions,
522
+ });
523
+ // Store cursor position AFTER core library has calculated and set it
524
+ // The core library modifies the DOM element directly during handleNumoraOnChange
525
+ // Read from the input ref (which is the same element) to get the position set by the core library
526
+ if (internalInputRef.current) {
527
+ const cursorPos = internalInputRef.current.selectionStart;
528
+ if (cursorPos !== null && cursorPos !== undefined) {
529
+ lastCaretPosRef.current = cursorPos;
530
+ }
531
+ }
532
+ caretInfoRef.current = undefined;
533
+ // Add rawValue to the event object without overriding 'value' property
534
+ e.target.rawValue = rawValue;
535
+ setDisplayValue(value);
536
+ if (onChange) {
537
+ onChange(e);
538
+ }
539
+ }, [maxDecimals, formattingOptions, onChange]);
540
+ const handleKeyDown = require$$0.useCallback((e) => {
541
+ const coreCaretInfo = handleNumoraOnKeyDown(e, formattingOptions);
542
+ // Always capture cursor position info, even if core library doesn't return it
543
+ // This is needed for cursor position calculation during normal typing (not just Delete/Backspace)
544
+ if (!coreCaretInfo && internalInputRef.current) {
545
+ const selectionStart = internalInputRef.current.selectionStart ?? 0;
546
+ const selectionEnd = internalInputRef.current.selectionEnd ?? 0;
547
+ caretInfoRef.current = {
548
+ selectionStart,
549
+ selectionEnd,
550
+ };
551
+ }
552
+ else {
553
+ caretInfoRef.current = coreCaretInfo;
554
+ }
555
+ if (onKeyDown) {
556
+ onKeyDown(e);
557
+ }
558
+ }, [formattingOptions, onKeyDown]);
559
+ const handlePaste = require$$0.useCallback((e) => {
560
+ const { value, rawValue } = handleNumoraOnPaste(e, {
561
+ decimalMaxLength: maxDecimals,
562
+ formattingOptions,
563
+ });
564
+ // For paste, we often want to move cursor to the end of pasted content
565
+ // handleNumoraOnPaste already handles DOM value and cursor, but React will overwrite it.
566
+ // So we capture where the core logic set the cursor.
567
+ lastCaretPosRef.current = e.target.selectionStart;
568
+ e.target.rawValue = rawValue;
569
+ setDisplayValue(value);
570
+ if (onPaste) {
571
+ onPaste(e);
572
+ }
573
+ // Trigger onChange manually because paste event doesn't always trigger a ChangeEvent in all React versions
574
+ // when we preventDefault.
575
+ if (onChange) {
576
+ const changeEvent = e;
577
+ onChange(changeEvent);
578
+ }
579
+ }, [maxDecimals, formattingOptions, onPaste, onChange]);
580
+ const handleBlur = require$$0.useCallback((e) => {
581
+ const { value, rawValue } = handleNumoraOnBlur(e, {
582
+ decimalMaxLength: maxDecimals,
583
+ formattingOptions,
584
+ });
585
+ e.target.rawValue = rawValue;
586
+ setDisplayValue(value);
587
+ if (onBlur) {
588
+ onBlur(e);
589
+ }
590
+ }, [maxDecimals, formattingOptions, onBlur]);
591
+ return (jsxRuntimeExports.jsx("input", { ...rest, ref: internalInputRef, value: displayValue, onChange: handleChange, onKeyDown: handleKeyDown, onPaste: handlePaste, onBlur: handleBlur, type: "text", inputMode: "decimal", spellCheck: false, autoComplete: "off" }));
592
+ });
593
+ NumoraInput.displayName = 'NumoraInput';
594
+
595
+ Object.defineProperty(exports, "FormatOn", {
596
+ enumerable: true,
597
+ get: function () { return numora.FormatOn; }
598
+ });
599
+ Object.defineProperty(exports, "ThousandStyle", {
600
+ enumerable: true,
601
+ get: function () { return numora.ThousandStyle; }
602
+ });
603
+ exports.NumoraInput = NumoraInput;
604
+ //# sourceMappingURL=index.js.map