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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.production.js","../../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.development.js","../../../node_modules/.pnpm/react@19.2.0/node_modules/react/jsx-runtime.js","../src/index.tsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\");\nfunction jsxProd(type, config, maybeKey) {\n var key = null;\n void 0 !== maybeKey && (key = \"\" + maybeKey);\n void 0 !== config.key && (key = \"\" + config.key);\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n config = maybeKey.ref;\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n ref: void 0 !== config ? config : null,\n props: maybeKey\n };\n}\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsxProd;\nexports.jsxs = jsxProd;\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\n\"production\" !== process.env.NODE_ENV &&\n (function () {\n function getComponentNameFromType(type) {\n if (null == type) return null;\n if (\"function\" === typeof type)\n return type.$$typeof === REACT_CLIENT_REFERENCE\n ? null\n : type.displayName || type.name || null;\n if (\"string\" === typeof type) return type;\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return \"Fragment\";\n case REACT_PROFILER_TYPE:\n return \"Profiler\";\n case REACT_STRICT_MODE_TYPE:\n return \"StrictMode\";\n case REACT_SUSPENSE_TYPE:\n return \"Suspense\";\n case REACT_SUSPENSE_LIST_TYPE:\n return \"SuspenseList\";\n case REACT_ACTIVITY_TYPE:\n return \"Activity\";\n }\n if (\"object\" === typeof type)\n switch (\n (\"number\" === typeof type.tag &&\n console.error(\n \"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.\"\n ),\n type.$$typeof)\n ) {\n case REACT_PORTAL_TYPE:\n return \"Portal\";\n case REACT_CONTEXT_TYPE:\n return type.displayName || \"Context\";\n case REACT_CONSUMER_TYPE:\n return (type._context.displayName || \"Context\") + \".Consumer\";\n case REACT_FORWARD_REF_TYPE:\n var innerType = type.render;\n type = type.displayName;\n type ||\n ((type = innerType.displayName || innerType.name || \"\"),\n (type = \"\" !== type ? \"ForwardRef(\" + type + \")\" : \"ForwardRef\"));\n return type;\n case REACT_MEMO_TYPE:\n return (\n (innerType = type.displayName || null),\n null !== innerType\n ? innerType\n : getComponentNameFromType(type.type) || \"Memo\"\n );\n case REACT_LAZY_TYPE:\n innerType = type._payload;\n type = type._init;\n try {\n return getComponentNameFromType(type(innerType));\n } catch (x) {}\n }\n return null;\n }\n function testStringCoercion(value) {\n return \"\" + value;\n }\n function checkKeyStringCoercion(value) {\n try {\n testStringCoercion(value);\n var JSCompiler_inline_result = !1;\n } catch (e) {\n JSCompiler_inline_result = !0;\n }\n if (JSCompiler_inline_result) {\n JSCompiler_inline_result = console;\n var JSCompiler_temp_const = JSCompiler_inline_result.error;\n var JSCompiler_inline_result$jscomp$0 =\n (\"function\" === typeof Symbol &&\n Symbol.toStringTag &&\n value[Symbol.toStringTag]) ||\n value.constructor.name ||\n \"Object\";\n JSCompiler_temp_const.call(\n JSCompiler_inline_result,\n \"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.\",\n JSCompiler_inline_result$jscomp$0\n );\n return testStringCoercion(value);\n }\n }\n function getTaskName(type) {\n if (type === REACT_FRAGMENT_TYPE) return \"<>\";\n if (\n \"object\" === typeof type &&\n null !== type &&\n type.$$typeof === REACT_LAZY_TYPE\n )\n return \"<...>\";\n try {\n var name = getComponentNameFromType(type);\n return name ? \"<\" + name + \">\" : \"<...>\";\n } catch (x) {\n return \"<...>\";\n }\n }\n function getOwner() {\n var dispatcher = ReactSharedInternals.A;\n return null === dispatcher ? null : dispatcher.getOwner();\n }\n function UnknownOwner() {\n return Error(\"react-stack-top-frame\");\n }\n function hasValidKey(config) {\n if (hasOwnProperty.call(config, \"key\")) {\n var getter = Object.getOwnPropertyDescriptor(config, \"key\").get;\n if (getter && getter.isReactWarning) return !1;\n }\n return void 0 !== config.key;\n }\n function defineKeyPropWarningGetter(props, displayName) {\n function warnAboutAccessingKey() {\n specialPropKeyWarningShown ||\n ((specialPropKeyWarningShown = !0),\n console.error(\n \"%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)\",\n displayName\n ));\n }\n warnAboutAccessingKey.isReactWarning = !0;\n Object.defineProperty(props, \"key\", {\n get: warnAboutAccessingKey,\n configurable: !0\n });\n }\n function elementRefGetterWithDeprecationWarning() {\n var componentName = getComponentNameFromType(this.type);\n didWarnAboutElementRef[componentName] ||\n ((didWarnAboutElementRef[componentName] = !0),\n console.error(\n \"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.\"\n ));\n componentName = this.props.ref;\n return void 0 !== componentName ? componentName : null;\n }\n function ReactElement(type, key, props, owner, debugStack, debugTask) {\n var refProp = props.ref;\n type = {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n props: props,\n _owner: owner\n };\n null !== (void 0 !== refProp ? refProp : null)\n ? Object.defineProperty(type, \"ref\", {\n enumerable: !1,\n get: elementRefGetterWithDeprecationWarning\n })\n : Object.defineProperty(type, \"ref\", { enumerable: !1, value: null });\n type._store = {};\n Object.defineProperty(type._store, \"validated\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: 0\n });\n Object.defineProperty(type, \"_debugInfo\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: null\n });\n Object.defineProperty(type, \"_debugStack\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: debugStack\n });\n Object.defineProperty(type, \"_debugTask\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: debugTask\n });\n Object.freeze && (Object.freeze(type.props), Object.freeze(type));\n return type;\n }\n function jsxDEVImpl(\n type,\n config,\n maybeKey,\n isStaticChildren,\n debugStack,\n debugTask\n ) {\n var children = config.children;\n if (void 0 !== children)\n if (isStaticChildren)\n if (isArrayImpl(children)) {\n for (\n isStaticChildren = 0;\n isStaticChildren < children.length;\n isStaticChildren++\n )\n validateChildKeys(children[isStaticChildren]);\n Object.freeze && Object.freeze(children);\n } else\n console.error(\n \"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.\"\n );\n else validateChildKeys(children);\n if (hasOwnProperty.call(config, \"key\")) {\n children = getComponentNameFromType(type);\n var keys = Object.keys(config).filter(function (k) {\n return \"key\" !== k;\n });\n isStaticChildren =\n 0 < keys.length\n ? \"{key: someKey, \" + keys.join(\": ..., \") + \": ...}\"\n : \"{key: someKey}\";\n didWarnAboutKeySpread[children + isStaticChildren] ||\n ((keys =\n 0 < keys.length ? \"{\" + keys.join(\": ..., \") + \": ...}\" : \"{}\"),\n console.error(\n '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} />',\n isStaticChildren,\n children,\n keys,\n children\n ),\n (didWarnAboutKeySpread[children + isStaticChildren] = !0));\n }\n children = null;\n void 0 !== maybeKey &&\n (checkKeyStringCoercion(maybeKey), (children = \"\" + maybeKey));\n hasValidKey(config) &&\n (checkKeyStringCoercion(config.key), (children = \"\" + config.key));\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n children &&\n defineKeyPropWarningGetter(\n maybeKey,\n \"function\" === typeof type\n ? type.displayName || type.name || \"Unknown\"\n : type\n );\n return ReactElement(\n type,\n children,\n maybeKey,\n getOwner(),\n debugStack,\n debugTask\n );\n }\n function validateChildKeys(node) {\n isValidElement(node)\n ? node._store && (node._store.validated = 1)\n : \"object\" === typeof node &&\n null !== node &&\n node.$$typeof === REACT_LAZY_TYPE &&\n (\"fulfilled\" === node._payload.status\n ? isValidElement(node._payload.value) &&\n node._payload.value._store &&\n (node._payload.value._store.validated = 1)\n : node._store && (node._store.validated = 1));\n }\n function isValidElement(object) {\n return (\n \"object\" === typeof object &&\n null !== object &&\n object.$$typeof === REACT_ELEMENT_TYPE\n );\n }\n var React = require(\"react\"),\n REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_PORTAL_TYPE = Symbol.for(\"react.portal\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\"),\n REACT_STRICT_MODE_TYPE = Symbol.for(\"react.strict_mode\"),\n REACT_PROFILER_TYPE = Symbol.for(\"react.profiler\"),\n REACT_CONSUMER_TYPE = Symbol.for(\"react.consumer\"),\n REACT_CONTEXT_TYPE = Symbol.for(\"react.context\"),\n REACT_FORWARD_REF_TYPE = Symbol.for(\"react.forward_ref\"),\n REACT_SUSPENSE_TYPE = Symbol.for(\"react.suspense\"),\n REACT_SUSPENSE_LIST_TYPE = Symbol.for(\"react.suspense_list\"),\n REACT_MEMO_TYPE = Symbol.for(\"react.memo\"),\n REACT_LAZY_TYPE = Symbol.for(\"react.lazy\"),\n REACT_ACTIVITY_TYPE = Symbol.for(\"react.activity\"),\n REACT_CLIENT_REFERENCE = Symbol.for(\"react.client.reference\"),\n ReactSharedInternals =\n React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n isArrayImpl = Array.isArray,\n createTask = console.createTask\n ? console.createTask\n : function () {\n return null;\n };\n React = {\n react_stack_bottom_frame: function (callStackForError) {\n return callStackForError();\n }\n };\n var specialPropKeyWarningShown;\n var didWarnAboutElementRef = {};\n var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(\n React,\n UnknownOwner\n )();\n var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));\n var didWarnAboutKeySpread = {};\n exports.Fragment = REACT_FRAGMENT_TYPE;\n exports.jsx = function (type, config, maybeKey) {\n var trackActualOwner =\n 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;\n return jsxDEVImpl(\n type,\n config,\n maybeKey,\n !1,\n trackActualOwner\n ? Error(\"react-stack-top-frame\")\n : unknownOwnerDebugStack,\n trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask\n );\n };\n exports.jsxs = function (type, config, maybeKey) {\n var trackActualOwner =\n 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;\n return jsxDEVImpl(\n type,\n config,\n maybeKey,\n !0,\n trackActualOwner\n ? Error(\"react-stack-top-frame\")\n : unknownOwnerDebugStack,\n trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask\n );\n };\n })();\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","import React, { ChangeEvent, ClipboardEvent, forwardRef } from 'react';\nimport {\n handleOnChangeNumoraInput,\n handleOnPasteNumoraInput,\n handleOnKeyDownNumoraInput,\n FormatOn,\n ThousandStyle,\n type FormattingOptions,\n type CaretPositionInfo,\n} from 'numora';\n\ninterface NumericInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'type' | 'inputMode'> {\n maxDecimals?: number;\n onChange?: (e: ChangeEvent<HTMLInputElement> | ClipboardEvent<HTMLInputElement>) => void;\n\n // Formatting options\n formatOn?: FormatOn;\n thousandSeparator?: string;\n thousandStyle?: ThousandStyle;\n decimalSeparator?: string;\n decimalMinLength?: number;\n\n // Feature flags\n enableCompactNotation?: boolean;\n enableNegative?: boolean;\n enableLeadingZeros?: boolean;\n rawValueMode?: boolean;\n}\n\nconst DEFAULT_PROPS = {\n autoComplete: 'off',\n autoCorrect: 'off',\n autoCapitalize: 'none',\n minLength: 1,\n placeholder: '0.0',\n pattern: '^[0-9]*[.,]?[0-9]*$',\n spellCheck: false,\n step: 'any',\n};\n\nconst NumoraInput = forwardRef<HTMLInputElement, NumericInputProps>(\n ({\n maxDecimals = 2,\n onChange,\n formatOn = FormatOn.Blur,\n thousandSeparator = ',',\n thousandStyle = ThousandStyle.Thousand,\n decimalSeparator = '.',\n decimalMinLength,\n enableCompactNotation = false,\n enableNegative = false,\n enableLeadingZeros = false,\n rawValueMode = false,\n ...props\n }: NumericInputProps, ref) => {\n const [caretPositionBeforeChange, setCaretPositionBeforeChange] =\n React.useState<CaretPositionInfo>();\n\n const formattingOptions: FormattingOptions = {\n formatOn,\n thousandSeparator,\n ThousandStyle: thousandStyle as any,\n decimalSeparator,\n decimalMinLength,\n enableCompactNotation,\n enableNegative,\n enableLeadingZeros,\n rawValueMode,\n };\n\n function handleOnKeyDown(e: React.KeyboardEvent<HTMLInputElement>): void {\n const caretInfo = handleOnKeyDownNumoraInput(e.nativeEvent, formattingOptions);\n\n if (caretInfo) {\n setCaretPositionBeforeChange(caretInfo);\n } else {\n const input = e.currentTarget;\n setCaretPositionBeforeChange({\n selectionStart: input.selectionStart ?? 0,\n selectionEnd: input.selectionEnd ?? 0,\n });\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n }\n\n function handleOnChange(e: ChangeEvent<HTMLInputElement>): void {\n handleOnChangeNumoraInput(\n e.nativeEvent,\n maxDecimals,\n caretPositionBeforeChange,\n formattingOptions\n );\n setCaretPositionBeforeChange(undefined);\n if (onChange) onChange(e);\n }\n\n function handleOnPaste(e: ClipboardEvent<HTMLInputElement>): void {\n handleOnPasteNumoraInput(e.nativeEvent, maxDecimals, formattingOptions);\n if (onChange) onChange(e);\n }\n\n function handleOnFocus(e: React.FocusEvent<HTMLInputElement>): void {\n if (formatOn === FormatOn.Blur && thousandSeparator) {\n const target = e.currentTarget;\n target.value = target.value.replace(\n new RegExp(thousandSeparator.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n ''\n );\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n }\n\n function handleOnBlur(e: React.FocusEvent<HTMLInputElement>): void {\n if (props.onBlur) {\n props.onBlur(e);\n }\n }\n\n return (\n <input\n {...DEFAULT_PROPS}\n {...props}\n ref={ref}\n onChange={handleOnChange}\n onKeyDown={handleOnKeyDown}\n onPaste={handleOnPaste}\n onFocus={handleOnFocus}\n onBlur={handleOnBlur}\n type=\"text\"\n inputMode=\"decimal\"\n />\n );\n }\n);\n\nNumoraInput.displayName = 'NumoraInput';\n\nexport { NumoraInput };\n"],"names":["REACT_ELEMENT_TYPE","Symbol","for","REACT_FRAGMENT_TYPE","jsxProd","type","config","maybeKey","key","propName","ref","$$typeof","props","reactJsxRuntime_production","Fragment","jsx","jsxs","process","env","NODE_ENV","getComponentNameFromType","REACT_CLIENT_REFERENCE","displayName","name","REACT_PROFILER_TYPE","REACT_STRICT_MODE_TYPE","REACT_SUSPENSE_TYPE","REACT_SUSPENSE_LIST_TYPE","REACT_ACTIVITY_TYPE","tag","console","error","REACT_PORTAL_TYPE","REACT_CONTEXT_TYPE","REACT_CONSUMER_TYPE","_context","REACT_FORWARD_REF_TYPE","innerType","render","REACT_MEMO_TYPE","REACT_LAZY_TYPE","_payload","_init","x","testStringCoercion","value","checkKeyStringCoercion","JSCompiler_inline_result","e","JSCompiler_temp_const","JSCompiler_inline_result$jscomp$0","toStringTag","constructor","call","getTaskName","getOwner","dispatcher","ReactSharedInternals","A","UnknownOwner","Error","hasValidKey","hasOwnProperty","getter","Object","getOwnPropertyDescriptor","get","isReactWarning","defineKeyPropWarningGetter","warnAboutAccessingKey","specialPropKeyWarningShown","defineProperty","configurable","elementRefGetterWithDeprecationWarning","componentName","didWarnAboutElementRef","ReactElement","owner","debugStack","debugTask","refProp","_owner","enumerable","_store","writable","freeze","jsxDEVImpl","isStaticChildren","children","isArrayImpl","length","validateChildKeys","keys","filter","k","join","didWarnAboutKeySpread","node","isValidElement","validated","status","object","React","require$$0","__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE","prototype","Array","isArray","createTask","react_stack_bottom_frame","callStackForError","unknownOwnerDebugStack","bind","unknownOwnerDebugTask","reactJsxRuntime_development","trackActualOwner","recentlyCreatedOwnerStacks","jsxRuntimeModule","exports","require$$1","DEFAULT_PROPS","autoComplete","autoCorrect","autoCapitalize","minLength","placeholder","pattern","spellCheck","step","NumoraInput","forwardRef","maxDecimals","onChange","formatOn","FormatOn","Blur","thousandSeparator","thousandStyle","ThousandStyle","Thousand","decimalSeparator","decimalMinLength","enableCompactNotation","enableNegative","enableLeadingZeros","rawValueMode","caretPositionBeforeChange","setCaretPositionBeforeChange","useState","formattingOptions","handleOnKeyDown","caretInfo","handleOnKeyDownNumoraInput","nativeEvent","input","currentTarget","selectionStart","selectionEnd","onKeyDown","handleOnChange","handleOnChangeNumoraInput","undefined","handleOnPaste","handleOnPasteNumoraInput","handleOnFocus","target","replace","RegExp","onFocus","handleOnBlur","onBlur","_jsx","onPaste","inputMode"],"mappings":";;;;;;;;;;;;;;;;;;;;AAWA,EAAA,IAAIA,kBAAkB,GAAGC,MAAM,CAACC,GAAG,CAAC,4BAA4B,CAAC;AAC/DC,IAAAA,mBAAmB,GAAGF,MAAM,CAACC,GAAG,CAAC,gBAAgB,CAAC;AACpD,EAAA,SAASE,OAAOA,CAACC,IAAI,EAAEC,MAAM,EAAEC,QAAQ,EAAE;I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Content":["import type React from 'react';\nimport {\n handleOnChangeNumoraInput,\n handleOnKeyDownNumoraInput,\n handleOnPasteNumoraInput,\n type CaretPositionInfo,\n type FormattingOptions,\n FormatOn,\n} from 'numora';\n\ntype ChangeResult = {\n value: string;\n rawValue?: string;\n};\n\ntype PasteResult = ChangeResult;\ntype BlurResult = ChangeResult;\n\ntype BaseOptions = {\n decimalMaxLength: number;\n caretPositionBeforeChange?: CaretPositionInfo;\n formattingOptions: FormattingOptions & { rawValueMode?: boolean };\n};\n\nexport function handleNumoraOnChange(\n e: React.ChangeEvent<HTMLInputElement>,\n options: BaseOptions\n): ChangeResult {\n handleOnChangeNumoraInput(\n e.nativeEvent as unknown as Event,\n options.decimalMaxLength,\n options.caretPositionBeforeChange,\n options.formattingOptions\n );\n\n const target = e.target;\n const rawValue = target.getAttribute('data-raw-value') ?? undefined;\n if (rawValue) {\n target.removeAttribute('data-raw-value');\n }\n\n return {\n value: target.value,\n rawValue,\n };\n}\n\nexport function handleNumoraOnPaste(\n e: React.ClipboardEvent<HTMLInputElement>,\n options: Omit<BaseOptions, 'caretPositionBeforeChange'>\n): PasteResult {\n const value = handleOnPasteNumoraInput(\n e.nativeEvent as ClipboardEvent,\n options.decimalMaxLength,\n options.formattingOptions\n );\n\n const target = e.target as HTMLInputElement;\n const rawValue = target.getAttribute('data-raw-value') ?? undefined;\n if (rawValue) {\n target.removeAttribute('data-raw-value');\n }\n\n return {\n value,\n rawValue,\n };\n}\n\nexport function handleNumoraOnKeyDown(\n e: React.KeyboardEvent<HTMLInputElement>,\n formattingOptions: FormattingOptions\n): CaretPositionInfo | undefined {\n return handleOnKeyDownNumoraInput(\n e.nativeEvent as unknown as KeyboardEvent,\n formattingOptions\n );\n}\n\nexport function handleNumoraOnBlur(\n e: React.FocusEvent<HTMLInputElement>,\n options: {\n decimalMaxLength: number;\n formattingOptions: FormattingOptions & { rawValueMode?: boolean };\n }\n): BlurResult {\n // If formatOn is blur, force formatting on blur by invoking change handler logic\n if (options.formattingOptions.formatOn === FormatOn.Blur) {\n handleOnChangeNumoraInput(\n e.nativeEvent as unknown as Event,\n options.decimalMaxLength,\n undefined,\n { ...options.formattingOptions, formatOn: FormatOn.Change }\n );\n }\n\n const target = e.target;\n const rawValue = target.getAttribute('data-raw-value') ?? undefined;\n if (rawValue) {\n target.removeAttribute('data-raw-value');\n }\n\n return {\n value: target.value,\n rawValue,\n };\n}\n","import React, {\n useRef,\n useState,\n useEffect,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport {\n FormatOn,\n ThousandStyle,\n type CaretPositionInfo,\n type FormattingOptions,\n handleOnChangeNumoraInput,\n} from 'numora';\nimport {\n handleNumoraOnBlur,\n handleNumoraOnChange,\n handleNumoraOnKeyDown,\n handleNumoraOnPaste,\n} from './handlers';\n\ninterface NumoraInputProps\n extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'onChange' | 'type' | 'inputMode'\n > {\n maxDecimals?: number;\n onChange?: (e: React.ChangeEvent<HTMLInputElement> | React.ClipboardEvent<HTMLInputElement>) => void;\n\n formatOn?: FormatOn;\n thousandSeparator?: string;\n thousandStyle?: ThousandStyle;\n decimalSeparator?: string;\n decimalMinLength?: number;\n\n enableCompactNotation?: boolean;\n enableNegative?: boolean;\n enableLeadingZeros?: boolean;\n rawValueMode?: boolean;\n}\n\nconst NumoraInput = forwardRef<HTMLInputElement, NumoraInputProps>((props, ref) => {\n const {\n maxDecimals = 2,\n onChange,\n onPaste,\n onBlur,\n onKeyDown,\n formatOn = FormatOn.Blur,\n thousandSeparator = ',',\n thousandStyle = ThousandStyle.Thousand,\n decimalSeparator = '.',\n decimalMinLength,\n enableCompactNotation = false,\n enableNegative = false,\n enableLeadingZeros = false,\n rawValueMode = false,\n value: controlledValue,\n defaultValue,\n ...rest\n } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const caretInfoRef = useRef<CaretPositionInfo | undefined>(undefined);\n\n const [internalValue, setInternalValue] = useState<string>(\n controlledValue !== undefined\n ? String(controlledValue)\n : defaultValue !== undefined\n ? String(defaultValue)\n : ''\n );\n\n // Keep internal state in sync when controlled\n useEffect(() => {\n if (controlledValue !== undefined) {\n setInternalValue(String(controlledValue));\n }\n }, [controlledValue]);\n\n useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);\n\n const formattingOptions: FormattingOptions & { rawValueMode?: boolean } = {\n formatOn,\n thousandSeparator,\n ThousandStyle: thousandStyle,\n decimalSeparator,\n decimalMinLength,\n enableCompactNotation,\n enableNegative,\n enableLeadingZeros,\n rawValueMode,\n };\n\n const formatValueWithCore = (value: string): string => {\n const el = inputRef.current ?? document.createElement('input');\n el.value = value;\n const fakeEvent = { target: el } as unknown as Event;\n handleOnChangeNumoraInput(fakeEvent, maxDecimals, undefined, formattingOptions);\n return el.value;\n };\n\n // When controlled value changes, normalize/format it for display\n useEffect(() => {\n if (controlledValue !== undefined) {\n const formatted = formatValueWithCore(String(controlledValue));\n setInternalValue(formatted);\n }\n }, [controlledValue, formatOn, thousandSeparator, thousandStyle, decimalSeparator, decimalMinLength, enableCompactNotation, enableNegative, enableLeadingZeros, rawValueMode, maxDecimals]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const { value, rawValue } = handleNumoraOnChange(e, {\n decimalMaxLength: maxDecimals,\n caretPositionBeforeChange: caretInfoRef.current,\n formattingOptions,\n });\n caretInfoRef.current = undefined;\n\n if (controlledValue === undefined) {\n setInternalValue(value);\n } else {\n setInternalValue(value);\n }\n\n if (onChange) {\n onChange(e);\n }\n\n // Optionally expose rawValue via a custom event attribute if needed later\n if (rawValue && e.target && rawValueMode) {\n // Keep the raw value on the input for consumers that read it directly\n e.target.setAttribute('data-raw-value', rawValue);\n }\n };\n\n const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const { value, rawValue } = handleNumoraOnPaste(e, {\n decimalMaxLength: maxDecimals,\n formattingOptions,\n });\n\n if (controlledValue === undefined) {\n setInternalValue(value);\n } else {\n setInternalValue(value);\n }\n\n if (onPaste) {\n onPaste(e);\n }\n if (onChange) {\n onChange(e);\n }\n\n if (rawValue && e.target && rawValueMode) {\n (e.target as HTMLInputElement).setAttribute('data-raw-value', rawValue);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n caretInfoRef.current = handleNumoraOnKeyDown(e, formattingOptions);\n if (onKeyDown) {\n onKeyDown(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n const { value, rawValue } = handleNumoraOnBlur(e, {\n decimalMaxLength: maxDecimals,\n formattingOptions,\n });\n\n if (controlledValue === undefined) {\n setInternalValue(value);\n } else {\n setInternalValue(value);\n }\n\n if (onBlur) {\n onBlur(e);\n }\n\n if (rawValue && e.target && rawValueMode) {\n (e.target as HTMLInputElement).setAttribute('data-raw-value', rawValue);\n }\n };\n\n return (\n <input\n {...rest}\n ref={inputRef}\n value={internalValue}\n onChange={handleChange}\n onPaste={handlePaste}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n type=\"text\"\n inputMode=\"decimal\"\n />\n );\n});\n\nNumoraInput.displayName = 'NumoraInput';\n\nexport { NumoraInput };\nexport { FormatOn, ThousandStyle } from 'numora';\nexport type { FormattingOptions, CaretPositionInfo } from 'numora';\n"],"names":["handleNumoraOnChange","e","options","handleOnChangeNumoraInput","nativeEvent","decimalMaxLength","caretPositionBeforeChange","formattingOptions","target","rawValue","getAttribute","undefined","removeAttribute","value","handleNumoraOnPaste","handleOnPasteNumoraInput","handleNumoraOnKeyDown","handleOnKeyDownNumoraInput","handleNumoraOnBlur","formatOn","FormatOn","Blur","Change","NumoraInput","forwardRef","props","ref","maxDecimals","onChange","onPaste","onBlur","onKeyDown","thousandSeparator","thousandStyle","ThousandStyle","Thousand","decimalSeparator","decimalMinLength","enableCompactNotation","enableNegative","enableLeadingZeros","rawValueMode","controlledValue","defaultValue","rest","inputRef","useRef","caretInfoRef","internalValue","setInternalValue","useState","String","useEffect","useImperativeHandle","current","formatValueWithCore","el","document","createElement","fakeEvent","formatted","handleChange","setAttribute","handlePaste","handleKeyDown","handleBlur","_jsx","type","inputMode","displayName"],"mappings":";;;;;AAwBM,SAAUA,oBAAoBA,CAClCC,CAAsC,EACtCC,OAAoB,EAAA;AAEpBC,EAAAA,yBAAyB,CACvBF,CAAC,CAACG,WAA+B,EACjCF,OAAO,CAACG,gBAAgB,EACxBH,OAAO,CAACI,yBAAyB,EACjCJ,OAAO,CAACK,iBAAiB,CAC1B;AAED,EAAA,MAAMC,MAAM,GAAGP,CAAC,CAACO,MAAM;EACvB,MAAMC,QAAQ,GAAGD,MAAM,CAACE,YAAY,CAAC,gBAAgB,CAAC,IAAIC,SAAS;AACnE,EAAA,IAAIF,QAAQ,EAAE;AACZD,IAAAA,MAAM,CAACI,eAAe,CAAC,gBAAgB,CAAC;AAC1C,EAAA;EAEA,OAAO;IACLC,KAAK,EAAEL,MAAM,CAACK,KAAK;AACnBJ,IAAAA;GACD;AACH;AAEM,SAAUK,mBAAmBA,CACjCb,CAAyC,EACzCC,OAAuD,EAAA;AAEvD,EAAA,MAAMW,KAAK,GAAGE,wBAAwB,CACpCd,CAAC,CAACG,WAA6B,EAC/BF,OAAO,CAACG,gBAAgB,EACxBH,OAAO,CAACK,iBAAiB,CAC1B;AAED,EAAA,MAAMC,MAAM,GAAGP,CAAC,CAACO,MAA0B;EAC3C,MAAMC,QAAQ,GAAGD,MAAM,CAACE,YAAY,CAAC,gBAAgB,CAAC,IAAIC,SAAS;AACnE,EAAA,IAAIF,QAAQ,EAAE;AACZD,IAAAA,MAAM,CAACI,eAAe,CAAC,gBAAgB,CAAC;AAC1C,EAAA;EAEA,OAAO;IACLC,KAAK;AACLJ,IAAAA;GACD;AACH;AAEM,SAAUO,qBAAqBA,CACnCf,CAAwC,EACxCM,iBAAoC,EAAA;AAEpC,EAAA,OAAOU,0BAA0B,CAC/BhB,CAAC,CAACG,WAAuC,EACzCG,iBAAiB,CAClB;AACH;AAEM,SAAUW,kBA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;AACRlB,IAAAA,GAAG,EAAEmB,QAAQ;AACbhC,IAAAA,KAAK,EAAEmC,aAAa;AACpBpB,IAAAA,QAAQ,EAAEiC,YAAY;AACtBhC,IAAAA,OAAO,EAAEkC,WAAW;AACpBhC,IAAAA,SAAS,EAAEiC,aAAa;AACxBlC,IAAAA,MAAM,EAAEmC,UAAU;AAClBE,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,SAAS,EAAC;AAAS,GAAA,CACnB;AAEN,CAAC;AAED7C,WAAW,CAAC8C,WAAW,GAAG,aAAa;;;;"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "numora-react",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Numora for React - Headless finance input library",
5
- "homepage": "https://numora.netlify.app/",
5
+ "homepage": "https://numora.xyz/",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs.js",
8
8
  "module": "dist/index.esm.js",
9
- "types": "dist/types/index.d.ts",
9
+ "types": "dist/index.d.ts",
10
10
  "sideEffects": false,
11
11
  "repository": {
12
12
  "type": "git",
@@ -43,6 +43,10 @@
43
43
  }
44
44
  ],
45
45
  "license": "MIT",
46
+ "peerDependencies": {
47
+ "react": "^18.0.0 || ^19.0.0",
48
+ "react-dom": "^18.0.0 || ^19.0.0"
49
+ },
46
50
  "devDependencies": {
47
51
  "@babel/core": "^7.26.10",
48
52
  "@babel/preset-env": "^7.26.9",
@@ -56,12 +60,13 @@
56
60
  "rollup": "^4.38.0",
57
61
  "rollup-plugin-peer-deps-external": "^2.2.4",
58
62
  "tslib": "^2.8.1",
59
- "typescript": "^5.8.2"
60
- },
61
- "dependencies": {
62
- "numora": "^1.0.4",
63
+ "typescript": "^5.8.2",
63
64
  "react": "^19.1.0",
64
- "react-dom": "^19.1.0"
65
+ "react-dom": "^19.1.0",
66
+ "numora": "^2.0.2"
67
+ },
68
+ "publishConfig": {
69
+ "access": "public"
65
70
  },
66
71
  "scripts": {
67
72
  "build": "rollup -c",
@@ -0,0 +1,107 @@
1
+ import type React from 'react';
2
+ import {
3
+ handleOnChangeNumoraInput,
4
+ handleOnKeyDownNumoraInput,
5
+ handleOnPasteNumoraInput,
6
+ type CaretPositionInfo,
7
+ type FormattingOptions,
8
+ FormatOn,
9
+ } from 'numora';
10
+
11
+ type ChangeResult = {
12
+ value: string;
13
+ rawValue?: string;
14
+ };
15
+
16
+ type PasteResult = ChangeResult;
17
+ type BlurResult = ChangeResult;
18
+
19
+ type BaseOptions = {
20
+ decimalMaxLength: number;
21
+ caretPositionBeforeChange?: CaretPositionInfo;
22
+ formattingOptions: FormattingOptions & { rawValueMode?: boolean };
23
+ };
24
+
25
+ export function handleNumoraOnChange(
26
+ e: React.ChangeEvent<HTMLInputElement>,
27
+ options: BaseOptions
28
+ ): ChangeResult {
29
+ handleOnChangeNumoraInput(
30
+ e.nativeEvent as unknown as Event,
31
+ options.decimalMaxLength,
32
+ options.caretPositionBeforeChange,
33
+ options.formattingOptions
34
+ );
35
+
36
+ const target = e.target;
37
+ const rawValue = target.getAttribute('data-raw-value') ?? undefined;
38
+ if (rawValue) {
39
+ target.removeAttribute('data-raw-value');
40
+ }
41
+
42
+ return {
43
+ value: target.value,
44
+ rawValue,
45
+ };
46
+ }
47
+
48
+ export function handleNumoraOnPaste(
49
+ e: React.ClipboardEvent<HTMLInputElement>,
50
+ options: Omit<BaseOptions, 'caretPositionBeforeChange'>
51
+ ): PasteResult {
52
+ const value = handleOnPasteNumoraInput(
53
+ e.nativeEvent as ClipboardEvent,
54
+ options.decimalMaxLength,
55
+ options.formattingOptions
56
+ );
57
+
58
+ const target = e.target as HTMLInputElement;
59
+ const rawValue = target.getAttribute('data-raw-value') ?? undefined;
60
+ if (rawValue) {
61
+ target.removeAttribute('data-raw-value');
62
+ }
63
+
64
+ return {
65
+ value,
66
+ rawValue,
67
+ };
68
+ }
69
+
70
+ export function handleNumoraOnKeyDown(
71
+ e: React.KeyboardEvent<HTMLInputElement>,
72
+ formattingOptions: FormattingOptions
73
+ ): CaretPositionInfo | undefined {
74
+ return handleOnKeyDownNumoraInput(
75
+ e.nativeEvent as unknown as KeyboardEvent,
76
+ formattingOptions
77
+ );
78
+ }
79
+
80
+ export function handleNumoraOnBlur(
81
+ e: React.FocusEvent<HTMLInputElement>,
82
+ options: {
83
+ decimalMaxLength: number;
84
+ formattingOptions: FormattingOptions & { rawValueMode?: boolean };
85
+ }
86
+ ): BlurResult {
87
+ // If formatOn is blur, force formatting on blur by invoking change handler logic
88
+ if (options.formattingOptions.formatOn === FormatOn.Blur) {
89
+ handleOnChangeNumoraInput(
90
+ e.nativeEvent as unknown as Event,
91
+ options.decimalMaxLength,
92
+ undefined,
93
+ { ...options.formattingOptions, formatOn: FormatOn.Change }
94
+ );
95
+ }
96
+
97
+ const target = e.target;
98
+ const rawValue = target.getAttribute('data-raw-value') ?? undefined;
99
+ if (rawValue) {
100
+ target.removeAttribute('data-raw-value');
101
+ }
102
+
103
+ return {
104
+ value: target.value,
105
+ rawValue,
106
+ };
107
+ }
package/src/index.tsx CHANGED
@@ -1,47 +1,51 @@
1
- import React, { ChangeEvent, ClipboardEvent, forwardRef } from 'react';
1
+ import React, {
2
+ useRef,
3
+ useState,
4
+ useEffect,
5
+ forwardRef,
6
+ useImperativeHandle,
7
+ } from 'react';
2
8
  import {
3
- handleOnChangeNumoraInput,
4
- handleOnPasteNumoraInput,
5
- handleOnKeyDownNumoraInput,
6
9
  FormatOn,
7
10
  ThousandStyle,
8
- type FormattingOptions,
9
11
  type CaretPositionInfo,
12
+ type FormattingOptions,
13
+ handleOnChangeNumoraInput,
10
14
  } from 'numora';
11
-
12
- interface NumericInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'type' | 'inputMode'> {
15
+ import {
16
+ handleNumoraOnBlur,
17
+ handleNumoraOnChange,
18
+ handleNumoraOnKeyDown,
19
+ handleNumoraOnPaste,
20
+ } from './handlers';
21
+
22
+ interface NumoraInputProps
23
+ extends Omit<
24
+ React.InputHTMLAttributes<HTMLInputElement>,
25
+ 'onChange' | 'type' | 'inputMode'
26
+ > {
13
27
  maxDecimals?: number;
14
- onChange?: (e: ChangeEvent<HTMLInputElement> | ClipboardEvent<HTMLInputElement>) => void;
28
+ onChange?: (e: React.ChangeEvent<HTMLInputElement> | React.ClipboardEvent<HTMLInputElement>) => void;
15
29
 
16
- // Formatting options
17
30
  formatOn?: FormatOn;
18
31
  thousandSeparator?: string;
19
32
  thousandStyle?: ThousandStyle;
20
33
  decimalSeparator?: string;
21
34
  decimalMinLength?: number;
22
35
 
23
- // Feature flags
24
36
  enableCompactNotation?: boolean;
25
37
  enableNegative?: boolean;
26
38
  enableLeadingZeros?: boolean;
27
39
  rawValueMode?: boolean;
28
40
  }
29
41
 
30
- const DEFAULT_PROPS = {
31
- autoComplete: 'off',
32
- autoCorrect: 'off',
33
- autoCapitalize: 'none',
34
- minLength: 1,
35
- placeholder: '0.0',
36
- pattern: '^[0-9]*[.,]?[0-9]*$',
37
- spellCheck: false,
38
- step: 'any',
39
- };
40
-
41
- const NumoraInput = forwardRef<HTMLInputElement, NumericInputProps>(
42
- ({
42
+ const NumoraInput = forwardRef<HTMLInputElement, NumoraInputProps>((props, ref) => {
43
+ const {
43
44
  maxDecimals = 2,
44
45
  onChange,
46
+ onPaste,
47
+ onBlur,
48
+ onKeyDown,
45
49
  formatOn = FormatOn.Blur,
46
50
  thousandSeparator = ',',
47
51
  thousandStyle = ThousandStyle.Thousand,
@@ -51,94 +55,153 @@ const NumoraInput = forwardRef<HTMLInputElement, NumericInputProps>(
51
55
  enableNegative = false,
52
56
  enableLeadingZeros = false,
53
57
  rawValueMode = false,
54
- ...props
55
- }: NumericInputProps, ref) => {
56
- const [caretPositionBeforeChange, setCaretPositionBeforeChange] =
57
- React.useState<CaretPositionInfo>();
58
-
59
- const formattingOptions: FormattingOptions = {
60
- formatOn,
61
- thousandSeparator,
62
- ThousandStyle: thousandStyle as any,
63
- decimalSeparator,
64
- decimalMinLength,
65
- enableCompactNotation,
66
- enableNegative,
67
- enableLeadingZeros,
68
- rawValueMode,
69
- };
70
-
71
- function handleOnKeyDown(e: React.KeyboardEvent<HTMLInputElement>): void {
72
- const caretInfo = handleOnKeyDownNumoraInput(e.nativeEvent, formattingOptions);
73
-
74
- if (caretInfo) {
75
- setCaretPositionBeforeChange(caretInfo);
76
- } else {
77
- const input = e.currentTarget;
78
- setCaretPositionBeforeChange({
79
- selectionStart: input.selectionStart ?? 0,
80
- selectionEnd: input.selectionEnd ?? 0,
81
- });
82
- }
83
-
84
- if (props.onKeyDown) {
85
- props.onKeyDown(e);
86
- }
58
+ value: controlledValue,
59
+ defaultValue,
60
+ ...rest
61
+ } = props;
62
+
63
+ const inputRef = useRef<HTMLInputElement>(null);
64
+ const caretInfoRef = useRef<CaretPositionInfo | undefined>(undefined);
65
+
66
+ const [internalValue, setInternalValue] = useState<string>(
67
+ controlledValue !== undefined
68
+ ? String(controlledValue)
69
+ : defaultValue !== undefined
70
+ ? String(defaultValue)
71
+ : ''
72
+ );
73
+
74
+ // Keep internal state in sync when controlled
75
+ useEffect(() => {
76
+ if (controlledValue !== undefined) {
77
+ setInternalValue(String(controlledValue));
87
78
  }
79
+ }, [controlledValue]);
80
+
81
+ useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);
88
82
 
89
- function handleOnChange(e: ChangeEvent<HTMLInputElement>): void {
90
- handleOnChangeNumoraInput(
91
- e.nativeEvent,
92
- maxDecimals,
93
- caretPositionBeforeChange,
94
- formattingOptions
95
- );
96
- setCaretPositionBeforeChange(undefined);
97
- if (onChange) onChange(e);
83
+ const formattingOptions: FormattingOptions & { rawValueMode?: boolean } = {
84
+ formatOn,
85
+ thousandSeparator,
86
+ ThousandStyle: thousandStyle,
87
+ decimalSeparator,
88
+ decimalMinLength,
89
+ enableCompactNotation,
90
+ enableNegative,
91
+ enableLeadingZeros,
92
+ rawValueMode,
93
+ };
94
+
95
+ const formatValueWithCore = (value: string): string => {
96
+ const el = inputRef.current ?? document.createElement('input');
97
+ el.value = value;
98
+ const fakeEvent = { target: el } as unknown as Event;
99
+ handleOnChangeNumoraInput(fakeEvent, maxDecimals, undefined, formattingOptions);
100
+ return el.value;
101
+ };
102
+
103
+ // When controlled value changes, normalize/format it for display
104
+ 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
+
111
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
112
+ const { value, rawValue } = handleNumoraOnChange(e, {
113
+ decimalMaxLength: maxDecimals,
114
+ caretPositionBeforeChange: caretInfoRef.current,
115
+ formattingOptions,
116
+ });
117
+ caretInfoRef.current = undefined;
118
+
119
+ if (controlledValue === undefined) {
120
+ setInternalValue(value);
121
+ } else {
122
+ setInternalValue(value);
98
123
  }
99
124
 
100
- function handleOnPaste(e: ClipboardEvent<HTMLInputElement>): void {
101
- handleOnPasteNumoraInput(e.nativeEvent, maxDecimals, formattingOptions);
102
- if (onChange) onChange(e);
125
+ if (onChange) {
126
+ onChange(e);
103
127
  }
104
128
 
105
- function handleOnFocus(e: React.FocusEvent<HTMLInputElement>): void {
106
- if (formatOn === FormatOn.Blur && thousandSeparator) {
107
- const target = e.currentTarget;
108
- target.value = target.value.replace(
109
- new RegExp(thousandSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'),
110
- ''
111
- );
112
- }
113
-
114
- if (props.onFocus) {
115
- props.onFocus(e);
116
- }
129
+ // Optionally expose rawValue via a custom event attribute if needed later
130
+ if (rawValue && e.target && rawValueMode) {
131
+ // Keep the raw value on the input for consumers that read it directly
132
+ e.target.setAttribute('data-raw-value', rawValue);
133
+ }
134
+ };
135
+
136
+ const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
137
+ const { value, rawValue } = handleNumoraOnPaste(e, {
138
+ decimalMaxLength: maxDecimals,
139
+ formattingOptions,
140
+ });
141
+
142
+ if (controlledValue === undefined) {
143
+ setInternalValue(value);
144
+ } else {
145
+ setInternalValue(value);
117
146
  }
118
147
 
119
- function handleOnBlur(e: React.FocusEvent<HTMLInputElement>): void {
120
- if (props.onBlur) {
121
- props.onBlur(e);
122
- }
148
+ if (onPaste) {
149
+ onPaste(e);
123
150
  }
151
+ if (onChange) {
152
+ onChange(e);
153
+ }
154
+
155
+ if (rawValue && e.target && rawValueMode) {
156
+ (e.target as HTMLInputElement).setAttribute('data-raw-value', rawValue);
157
+ }
158
+ };
124
159
 
125
- return (
126
- <input
127
- {...DEFAULT_PROPS}
128
- {...props}
129
- ref={ref}
130
- onChange={handleOnChange}
131
- onKeyDown={handleOnKeyDown}
132
- onPaste={handleOnPaste}
133
- onFocus={handleOnFocus}
134
- onBlur={handleOnBlur}
135
- type="text"
136
- inputMode="decimal"
137
- />
138
- );
139
- }
140
- );
160
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
161
+ caretInfoRef.current = handleNumoraOnKeyDown(e, formattingOptions);
162
+ if (onKeyDown) {
163
+ onKeyDown(e);
164
+ }
165
+ };
166
+
167
+ const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
168
+ const { value, rawValue } = handleNumoraOnBlur(e, {
169
+ decimalMaxLength: maxDecimals,
170
+ formattingOptions,
171
+ });
172
+
173
+ if (controlledValue === undefined) {
174
+ setInternalValue(value);
175
+ } else {
176
+ setInternalValue(value);
177
+ }
178
+
179
+ if (onBlur) {
180
+ onBlur(e);
181
+ }
182
+
183
+ if (rawValue && e.target && rawValueMode) {
184
+ (e.target as HTMLInputElement).setAttribute('data-raw-value', rawValue);
185
+ }
186
+ };
187
+
188
+ return (
189
+ <input
190
+ {...rest}
191
+ ref={inputRef}
192
+ value={internalValue}
193
+ onChange={handleChange}
194
+ onPaste={handlePaste}
195
+ onKeyDown={handleKeyDown}
196
+ onBlur={handleBlur}
197
+ type="text"
198
+ inputMode="decimal"
199
+ />
200
+ );
201
+ });
141
202
 
142
203
  NumoraInput.displayName = 'NumoraInput';
143
204
 
144
205
  export { NumoraInput };
206
+ export { FormatOn, ThousandStyle } from 'numora';
207
+ export type { FormattingOptions, CaretPositionInfo } from 'numora';