use-mask-input 3.7.2 → 3.7.3
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/CHANGELOG.md +6 -0
- package/README.md +4 -1
- package/dist/antd.cjs +13 -23
- package/dist/antd.cjs.map +1 -1
- package/dist/antd.d.cts +2 -3
- package/dist/antd.d.ts +2 -3
- package/dist/antd.js +7 -17
- package/dist/antd.js.map +1 -1
- package/dist/{chunk-FDD3PKBM.js → chunk-QCWLMMDI.js} +50 -47
- package/dist/chunk-QCWLMMDI.js.map +1 -0
- package/dist/{chunk-NIHSNNRR.cjs → chunk-VK6LQ75W.cjs} +50 -53
- package/dist/chunk-VK6LQ75W.cjs.map +1 -0
- package/dist/index.cjs +22 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/antd/useMaskInputAntd.ts +13 -34
- package/src/api/useMaskInput.ts +9 -27
- package/dist/chunk-FDD3PKBM.js.map +0 -1
- package/dist/chunk-NIHSNNRR.cjs.map +0 -1
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
23
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
24
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
|
|
25
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
|
|
@@ -3677,47 +3677,8 @@ var require_inputmask = __commonJS({
|
|
|
3677
3677
|
}
|
|
3678
3678
|
});
|
|
3679
3679
|
|
|
3680
|
-
// src/
|
|
3681
|
-
|
|
3682
|
-
return element !== null && typeof element === "object" && "nodeType" in element && "querySelector" in element && typeof element.querySelector === "function";
|
|
3683
|
-
}
|
|
3684
|
-
function findInputElement(element) {
|
|
3685
|
-
if (!element) return null;
|
|
3686
|
-
if (!isHTMLElement(element)) {
|
|
3687
|
-
return null;
|
|
3688
|
-
}
|
|
3689
|
-
if (element.nodeName === "INPUT" || element.nodeName === "TEXTAREA") {
|
|
3690
|
-
return element;
|
|
3691
|
-
}
|
|
3692
|
-
if (!("querySelector" in element) || typeof element.querySelector !== "function") {
|
|
3693
|
-
return null;
|
|
3694
|
-
}
|
|
3695
|
-
try {
|
|
3696
|
-
const inputElement = element.querySelector("input, textarea");
|
|
3697
|
-
if (inputElement && isHTMLElement(inputElement)) {
|
|
3698
|
-
return inputElement;
|
|
3699
|
-
}
|
|
3700
|
-
} catch {
|
|
3701
|
-
return null;
|
|
3702
|
-
}
|
|
3703
|
-
return null;
|
|
3704
|
-
}
|
|
3705
|
-
function resolveInputRef(input) {
|
|
3706
|
-
if (!input) {
|
|
3707
|
-
return null;
|
|
3708
|
-
}
|
|
3709
|
-
if (typeof input === "object" && "current" in input) {
|
|
3710
|
-
const refValue = input.current;
|
|
3711
|
-
if (isHTMLElement(refValue)) {
|
|
3712
|
-
return refValue;
|
|
3713
|
-
}
|
|
3714
|
-
return null;
|
|
3715
|
-
}
|
|
3716
|
-
if (isHTMLElement(input)) {
|
|
3717
|
-
return input;
|
|
3718
|
-
}
|
|
3719
|
-
return null;
|
|
3720
|
-
}
|
|
3680
|
+
// src/api/withMask.ts
|
|
3681
|
+
var import_inputmask = __toESM(require_inputmask());
|
|
3721
3682
|
|
|
3722
3683
|
// src/core/maskConfig.ts
|
|
3723
3684
|
var ALIAS_MASKS = {
|
|
@@ -3811,10 +3772,52 @@ function setPrevRef(result, ref) {
|
|
|
3811
3772
|
});
|
|
3812
3773
|
}
|
|
3813
3774
|
|
|
3775
|
+
// src/api/withMask.ts
|
|
3776
|
+
var callbackCache = /* @__PURE__ */ new Map();
|
|
3777
|
+
function withMask(mask, options) {
|
|
3778
|
+
if (!options) {
|
|
3779
|
+
const cacheKey = makeMaskCacheKey("", mask);
|
|
3780
|
+
if (callbackCache.has(cacheKey)) {
|
|
3781
|
+
return callbackCache.get(cacheKey);
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
const callback = (input) => {
|
|
3785
|
+
if (isServer_default || mask === null || !input) return;
|
|
3786
|
+
const maskInput = interopDefaultSync(import_inputmask.default)(getMaskOptions(mask, options));
|
|
3787
|
+
maskInput.mask(input);
|
|
3788
|
+
};
|
|
3789
|
+
if (!options) {
|
|
3790
|
+
const cacheKey = makeMaskCacheKey("", mask);
|
|
3791
|
+
callbackCache.set(cacheKey, callback);
|
|
3792
|
+
}
|
|
3793
|
+
return callback;
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
// src/core/elementResolver.ts
|
|
3797
|
+
function isHTMLElement(element) {
|
|
3798
|
+
return element !== null && typeof element === "object" && "nodeType" in element && "querySelector" in element && typeof element.querySelector === "function";
|
|
3799
|
+
}
|
|
3800
|
+
function resolveInputRef(input) {
|
|
3801
|
+
if (!input) {
|
|
3802
|
+
return null;
|
|
3803
|
+
}
|
|
3804
|
+
if (typeof input === "object" && "current" in input) {
|
|
3805
|
+
const refValue = input.current;
|
|
3806
|
+
if (isHTMLElement(refValue)) {
|
|
3807
|
+
return refValue;
|
|
3808
|
+
}
|
|
3809
|
+
return null;
|
|
3810
|
+
}
|
|
3811
|
+
if (isHTMLElement(input)) {
|
|
3812
|
+
return input;
|
|
3813
|
+
}
|
|
3814
|
+
return null;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3814
3817
|
// src/core/maskEngine.ts
|
|
3815
|
-
var
|
|
3818
|
+
var import_inputmask2 = __toESM(require_inputmask());
|
|
3816
3819
|
function createMaskInstance(mask, options) {
|
|
3817
|
-
const inputmaskInstance = interopDefaultSync(
|
|
3820
|
+
const inputmaskInstance = interopDefaultSync(import_inputmask2.default);
|
|
3818
3821
|
return inputmaskInstance(getMaskOptions(mask, options));
|
|
3819
3822
|
}
|
|
3820
3823
|
function applyMaskToElement(element, mask, options) {
|
|
@@ -3840,18 +3843,12 @@ inputmask/dist/inputmask.js:
|
|
|
3840
3843
|
(*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE *)
|
|
3841
3844
|
*/
|
|
3842
3845
|
|
|
3843
|
-
exports.__toESM = __toESM;
|
|
3844
3846
|
exports.applyMaskToElement = applyMaskToElement;
|
|
3845
|
-
exports.createMaskInstance = createMaskInstance;
|
|
3846
|
-
exports.findInputElement = findInputElement;
|
|
3847
3847
|
exports.flow = flow;
|
|
3848
|
-
exports.getMaskOptions = getMaskOptions;
|
|
3849
|
-
exports.interopDefaultSync = interopDefaultSync;
|
|
3850
|
-
exports.isHTMLElement = isHTMLElement;
|
|
3851
3848
|
exports.isServer_default = isServer_default;
|
|
3852
3849
|
exports.makeMaskCacheKey = makeMaskCacheKey;
|
|
3853
|
-
exports.require_inputmask = require_inputmask;
|
|
3854
3850
|
exports.resolveInputRef = resolveInputRef;
|
|
3855
3851
|
exports.setPrevRef = setPrevRef;
|
|
3856
|
-
|
|
3857
|
-
//# sourceMappingURL=chunk-
|
|
3852
|
+
exports.withMask = withMask;
|
|
3853
|
+
//# sourceMappingURL=chunk-VK6LQ75W.cjs.map
|
|
3854
|
+
//# sourceMappingURL=chunk-VK6LQ75W.cjs.map
|