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