numora 2.0.3 → 2.0.4
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.js +1 -1
- package/dist/index.mjs +455 -465
- package/package.json +1 -1
- package/dist/NumoraInput.d.ts +0 -72
- package/dist/config.d.ts +0 -11
- package/dist/features/compact-notation.d.ts +0 -17
- package/dist/features/decimals.d.ts +0 -52
- package/dist/features/formatting/caret-position-utils.d.ts +0 -54
- package/dist/features/formatting/change-detection.d.ts +0 -40
- package/dist/features/formatting/character-equivalence.d.ts +0 -9
- package/dist/features/formatting/constants.d.ts +0 -29
- package/dist/features/formatting/cursor-boundary.d.ts +0 -39
- package/dist/features/formatting/cursor-position.d.ts +0 -50
- package/dist/features/formatting/digit-counting.d.ts +0 -61
- package/dist/features/formatting/index.d.ts +0 -19
- package/dist/features/formatting/large-number.d.ts +0 -39
- package/dist/features/formatting/percent.d.ts +0 -45
- package/dist/features/formatting/subscript-notation.d.ts +0 -20
- package/dist/features/formatting/thousand-grouping.d.ts +0 -34
- package/dist/features/leading-zeros.d.ts +0 -18
- package/dist/features/mobile-keyboard-filtering.d.ts +0 -18
- package/dist/features/non-numeric-characters.d.ts +0 -9
- package/dist/features/sanitization.d.ts +0 -41
- package/dist/features/scientific-notation.d.ts +0 -9
- package/dist/index.d.ts +0 -4
- package/dist/types.d.ts +0 -34
- package/dist/utils/escape-reg-exp.d.ts +0 -16
- package/dist/utils/event-handlers.d.ts +0 -24
- package/dist/utils/input-pattern.d.ts +0 -5
- package/dist/validation.d.ts +0 -20
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes non-numeric characters from a string, preserving the decimal separator.
|
|
3
|
-
*
|
|
4
|
-
* @param value - The string to sanitize
|
|
5
|
-
* @param enableNegative - Whether to allow negative sign
|
|
6
|
-
* @param decimalSeparator - The decimal separator character (default: '.')
|
|
7
|
-
* @returns The sanitized string with only numbers and the decimal separator
|
|
8
|
-
*/
|
|
9
|
-
export declare const removeNonNumericCharacters: (value: string, enableNegative?: boolean, decimalSeparator?: string) => string;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { FormattingOptions, Separators } from '@/types';
|
|
2
|
-
/**
|
|
3
|
-
* Removes all occurrences of thousand separator from a string.
|
|
4
|
-
* Escapes special regex characters in the separator to ensure safe pattern matching.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The string to remove separators from
|
|
7
|
-
* @param thousandSeparator - The thousand separator character to remove
|
|
8
|
-
* @returns The string with all thousand separators removed
|
|
9
|
-
*/
|
|
10
|
-
export declare function removeThousandSeparators(value: string, thousandSeparator: string): string;
|
|
11
|
-
export interface SanitizationOptions {
|
|
12
|
-
enableCompactNotation?: boolean;
|
|
13
|
-
enableNegative?: boolean;
|
|
14
|
-
enableLeadingZeros?: boolean;
|
|
15
|
-
decimalSeparator?: string;
|
|
16
|
-
thousandSeparator?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Sanitizes numeric input by:
|
|
20
|
-
* 0. Filter mobile keyboard artifacts (non-breaking spaces, Unicode whitespace)
|
|
21
|
-
* 1. Remove thousand separators (formatting, not data)
|
|
22
|
-
* 2. (Optional) Expanding compact notation (e.g., 1k → 1000)
|
|
23
|
-
* 3. Expanding scientific notation (e.g., 1.5e-5 → 0.000015)
|
|
24
|
-
* 4. Removing non-numeric characters
|
|
25
|
-
* 5. Removing extra decimal points
|
|
26
|
-
* 6. (Optional) Removing leading zeros
|
|
27
|
-
*
|
|
28
|
-
* @param value - The string value to sanitize
|
|
29
|
-
* @param options - Optional sanitization configuration
|
|
30
|
-
* @returns The sanitized numeric string
|
|
31
|
-
*/
|
|
32
|
-
export declare const sanitizeNumoraInput: (value: string, options?: SanitizationOptions) => string;
|
|
33
|
-
/**
|
|
34
|
-
* Builds sanitization options from formatting options and separators.
|
|
35
|
-
*
|
|
36
|
-
* @param formattingOptions - Optional formatting options
|
|
37
|
-
* @param separators - Separator configuration
|
|
38
|
-
* @param shouldRemoveThousandSeparators - Whether to remove thousand separators
|
|
39
|
-
* @returns Sanitization options
|
|
40
|
-
*/
|
|
41
|
-
export declare function buildSanitizationOptions(formattingOptions: FormattingOptions | undefined, separators: Separators, shouldRemoveThousandSeparators: boolean): SanitizationOptions;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expands scientific notation to decimal notation using string manipulation only.
|
|
3
|
-
* Handles formats like: 1.5e-7, 2e+5, 1.23e-4, etc.
|
|
4
|
-
* Finds and expands scientific notation anywhere in the string.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The string value that may contain scientific notation
|
|
7
|
-
* @returns The expanded decimal string, or original value if not scientific notation
|
|
8
|
-
*/
|
|
9
|
-
export declare function expandScientificNotation(value: string): string;
|
package/dist/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export * from './NumoraInput';
|
|
2
|
-
export { ThousandStyle, FormatOn } from './types';
|
|
3
|
-
export { handleOnChangeNumoraInput, handleOnPasteNumoraInput, handleOnKeyDownNumoraInput, } from './utils/event-handlers';
|
|
4
|
-
export type { FormattingOptions, CaretPositionInfo } from './types';
|
package/dist/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export declare enum FormatOn {
|
|
2
|
-
Blur = "blur",
|
|
3
|
-
Change = "change"
|
|
4
|
-
}
|
|
5
|
-
export declare enum ThousandStyle {
|
|
6
|
-
None = "none",
|
|
7
|
-
Thousand = "thousand",
|
|
8
|
-
Lakh = "lakh",
|
|
9
|
-
Wan = "wan"
|
|
10
|
-
}
|
|
11
|
-
export interface FormattingOptions {
|
|
12
|
-
formatOn?: FormatOn;
|
|
13
|
-
thousandSeparator?: string;
|
|
14
|
-
ThousandStyle?: ThousandStyle;
|
|
15
|
-
enableCompactNotation?: boolean;
|
|
16
|
-
enableNegative?: boolean;
|
|
17
|
-
enableLeadingZeros?: boolean;
|
|
18
|
-
decimalSeparator?: string;
|
|
19
|
-
decimalMinLength?: number;
|
|
20
|
-
rawValueMode?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface CaretPositionInfo {
|
|
23
|
-
selectionStart?: number;
|
|
24
|
-
selectionEnd?: number;
|
|
25
|
-
endOffset?: number;
|
|
26
|
-
}
|
|
27
|
-
export interface SeparatorOptions {
|
|
28
|
-
decimalSeparator?: string;
|
|
29
|
-
thousandSeparator?: string;
|
|
30
|
-
}
|
|
31
|
-
export interface Separators {
|
|
32
|
-
decimalSeparator: string;
|
|
33
|
-
thousandSeparator?: string;
|
|
34
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utility functions used across multiple features.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Escapes special regex characters in a string.
|
|
6
|
-
* This is used when building regex patterns from user-provided separator characters.
|
|
7
|
-
*
|
|
8
|
-
* @param str - The string to escape
|
|
9
|
-
* @returns The escaped string safe for use in regex patterns
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* escapeRegExp(".") // Returns: "\\."
|
|
13
|
-
* escapeRegExp("$") // Returns: "\\$"
|
|
14
|
-
* escapeRegExp("1,234") // Returns: "1\\,234"
|
|
15
|
-
*/
|
|
16
|
-
export declare function escapeRegExp(str: string): string;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type FormattingOptions, type CaretPositionInfo } from '@/types';
|
|
2
|
-
/**
|
|
3
|
-
* Handles the keydown event to prevent the user from entering a second decimal point.
|
|
4
|
-
* Also tracks selection info for Delete/Backspace keys to enable proper cursor positioning.
|
|
5
|
-
* In 'change' mode with formatting, skips cursor over thousand separators on delete/backspace.
|
|
6
|
-
*
|
|
7
|
-
* @param e - The keyboard event triggered by the input.
|
|
8
|
-
* @param formattingOptions - Optional formatting options for separator skipping
|
|
9
|
-
* @returns Caret position info if Delete/Backspace was pressed, undefined otherwise
|
|
10
|
-
*/
|
|
11
|
-
export declare function handleOnKeyDownNumoraInput(e: KeyboardEvent, formattingOptions?: FormattingOptions): CaretPositionInfo | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Handles the input change event to ensure the value does not exceed the maximum number of decimal places,
|
|
14
|
-
* replaces commas with dots, and removes invalid non-numeric characters.
|
|
15
|
-
* Also handles cursor positioning for Delete/Backspace keys.
|
|
16
|
-
* Optionally formats with thousand separators in real-time if formatOn is 'change'.
|
|
17
|
-
*
|
|
18
|
-
* @param e - The event triggered by the input.
|
|
19
|
-
* @param decimalMaxLength - The maximum number of decimal places allowed.
|
|
20
|
-
* @param caretPositionBeforeChange - Optional caret position info from keydown handler
|
|
21
|
-
* @param formattingOptions - Optional formatting options for real-time formatting
|
|
22
|
-
*/
|
|
23
|
-
export declare function handleOnChangeNumoraInput(e: Event, decimalMaxLength: number, caretPositionBeforeChange?: CaretPositionInfo, formattingOptions?: FormattingOptions): void;
|
|
24
|
-
export declare function handleOnPasteNumoraInput(e: ClipboardEvent, decimalMaxLength: number, formattingOptions?: FormattingOptions): string;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds an input pattern that allows optional negative sign and a single custom decimal separator.
|
|
3
|
-
* The separator is escaped so any character can be safely used.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getNumoraPattern(decimalSeparator: string, enableNegative: boolean): string;
|
package/dist/validation.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FormatOn } from './types';
|
|
2
|
-
import { ThousandStyle } from './types';
|
|
3
|
-
export interface NumoraInputValidationOptions {
|
|
4
|
-
decimalMaxLength?: number;
|
|
5
|
-
decimalMinLength?: number;
|
|
6
|
-
formatOn?: FormatOn;
|
|
7
|
-
thousandSeparator?: string;
|
|
8
|
-
thousandStyle?: ThousandStyle;
|
|
9
|
-
decimalSeparator?: string;
|
|
10
|
-
enableCompactNotation?: boolean;
|
|
11
|
-
enableNegative?: boolean;
|
|
12
|
-
enableLeadingZeros?: boolean;
|
|
13
|
-
rawValueMode?: boolean;
|
|
14
|
-
onChange?: (value: string) => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Validates all NumoraInput constructor parameters.
|
|
18
|
-
* Throws descriptive errors for invalid values.
|
|
19
|
-
*/
|
|
20
|
-
export declare function validateNumoraInputOptions(options: NumoraInputValidationOptions): void;
|