@maskito/kit
Advanced tools
Comparing version 0.16.0 to 1.0.0
@@ -288,2 +288,6 @@ import { MASKITO_DEFAULT_OPTIONS, maskitoTransform } from '@maskito/core'; | ||
function identity(x) { | ||
return x; | ||
} | ||
function isEmpty(entity) { | ||
@@ -368,3 +372,3 @@ return !entity || typeof entity === 'object' && Object.keys(entity).length === 0; | ||
}; | ||
} : MASKITO_DEFAULT_OPTIONS.postprocessor; | ||
} : identity; | ||
} | ||
@@ -395,3 +399,3 @@ | ||
}; | ||
} : MASKITO_DEFAULT_OPTIONS.postprocessor; | ||
} : identity; | ||
} | ||
@@ -554,37 +558,31 @@ | ||
const preprocessor = ({ | ||
elementState, | ||
data | ||
}) => { | ||
const { | ||
value, | ||
selection | ||
} = elementState; | ||
return { | ||
elementState: { | ||
selection, | ||
value: removePlaceholder(value) | ||
}, | ||
data | ||
}; | ||
}; | ||
const postprocessor = ({ | ||
value, | ||
selection | ||
}, initialElementState) => initialElementState.value && (focused || !focusedOnly) ? { | ||
value: value + placeholder.slice(value.length), | ||
selection | ||
} : { | ||
value, | ||
selection | ||
}; | ||
return { | ||
plugins, | ||
removePlaceholder, | ||
preprocessor, | ||
postprocessor, | ||
preprocessors: [preprocessor], | ||
postprocessors: [postprocessor] | ||
preprocessors: [({ | ||
elementState, | ||
data | ||
}) => { | ||
const { | ||
value, | ||
selection | ||
} = elementState; | ||
return { | ||
elementState: { | ||
selection, | ||
value: removePlaceholder(value) | ||
}, | ||
data | ||
}; | ||
}], | ||
postprocessors: [({ | ||
value, | ||
selection | ||
}, initialElementState) => initialElementState.value && (focused || !focusedOnly) ? { | ||
value: value + placeholder.slice(value.length), | ||
selection | ||
} : { | ||
value, | ||
selection | ||
}] | ||
}; | ||
@@ -665,3 +663,3 @@ } | ||
if (isEmpty(minLength) && isEmpty(maxLength)) { | ||
return elementState => elementState; | ||
return identity; | ||
} | ||
@@ -1105,2 +1103,3 @@ | ||
*/ | ||
function createDecimalZeroPaddingPostprocessor({ | ||
@@ -1112,3 +1111,3 @@ decimalSeparator, | ||
if (precision <= 0 || !decimalZeroPadding) { | ||
return elementState => elementState; | ||
return identity; | ||
} | ||
@@ -1340,3 +1339,3 @@ | ||
if (!thousandSeparator) { | ||
return elementState => elementState; | ||
return identity; | ||
} | ||
@@ -1404,3 +1403,3 @@ | ||
if (precision > 0) { | ||
return elementState => elementState; | ||
return identity; | ||
} | ||
@@ -1432,3 +1431,2 @@ | ||
min = Number.MIN_SAFE_INTEGER, | ||
isNegativeAllowed = min < 0, | ||
precision = 0, | ||
@@ -1448,5 +1446,5 @@ thousandSeparator = CHAR_NO_BREAK_SPACE, | ||
thousandSeparator, | ||
isNegativeAllowed, | ||
prefix, | ||
postfix | ||
postfix, | ||
isNegativeAllowed: min < 0 | ||
}), | ||
@@ -1453,0 +1451,0 @@ preprocessors: [createPseudoCharactersPreprocessor(CHAR_MINUS, pseudoMinuses), createPseudoCharactersPreprocessor(decimalSeparator, decimalPseudoSeparators), createNotEmptyIntegerPartPreprocessor({ |
import { MaskitoOptions } from '@maskito/core'; | ||
export declare function maskitoNumberOptionsGenerator({ max, min, isNegativeAllowed, precision, thousandSeparator, decimalSeparator, decimalPseudoSeparators, decimalZeroPadding, prefix, postfix, }?: { | ||
export declare function maskitoNumberOptionsGenerator({ max, min, precision, thousandSeparator, decimalSeparator, decimalPseudoSeparators, decimalZeroPadding, prefix, postfix, }?: { | ||
min?: number; | ||
max?: number; | ||
/** | ||
* @deprecated use `min > 0` instead of `isNegativeAllowed: false` | ||
* TODO: delete in 1.x.x | ||
*/ | ||
isNegativeAllowed?: boolean; | ||
precision?: number; | ||
@@ -11,0 +6,0 @@ decimalSeparator?: string; |
import { MaskitoOptions } from '@maskito/core'; | ||
export declare function maskitoWithPlaceholder(placeholder: string, focusedOnly?: boolean): Pick<Required<MaskitoOptions>, 'plugins' | 'postprocessor' | 'postprocessors' | 'preprocessor' | 'preprocessors'> & { | ||
export declare function maskitoWithPlaceholder(placeholder: string, focusedOnly?: boolean): Pick<Required<MaskitoOptions>, 'plugins' | 'postprocessors' | 'preprocessors'> & { | ||
removePlaceholder: (value: string) => string; | ||
}; | ||
//# sourceMappingURL=with-placeholder.d.ts.map |
@@ -14,4 +14,5 @@ export * from './clamp'; | ||
export * from './get-object-from-entries'; | ||
export * from './identity'; | ||
export * from './is-empty'; | ||
export * from './pad-with-zeroes-until-valid'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@maskito/kit", | ||
"version": "0.16.0", | ||
"version": "1.0.0", | ||
"description": "The optional framework-agnostic Maskito's package with ready-to-use masks", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@maskito/core": "^0.16.0" | ||
"@maskito/core": "^1.0.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "main": "./index.umd.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
178
1
169516
3314