numora-react 1.0.4 → 1.0.6

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