text-input-guard 1.0.1 → 1.1.0
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/cjs/text-input-guard.cjs +187 -94
- package/dist/cjs/text-input-guard.min.cjs +1 -1
- package/dist/esm/text-input-guard.js +187 -95
- package/dist/esm/text-input-guard.min.js +1 -1
- package/dist/types/text-input-guard.d.ts +57 -28
- package/dist/umd/text-input-guard.js +187 -94
- package/dist/umd/text-input-guard.min.js +1 -1
- package/package.json +1 -1
|
@@ -287,6 +287,10 @@ type AttachOptions = {
|
|
|
287
287
|
* - 評価完了時の通知(input/commitごと)
|
|
288
288
|
*/
|
|
289
289
|
onValidate?: (result: ValidateResult) => void;
|
|
290
|
+
/**
|
|
291
|
+
* - フォーカスが外れた値が変更されていた場合の通知
|
|
292
|
+
*/
|
|
293
|
+
onChange?: (result: Guard) => void;
|
|
290
294
|
};
|
|
291
295
|
/**
|
|
292
296
|
* revert要求(入力を巻き戻す指示)
|
|
@@ -317,7 +321,7 @@ type RevertRequest = {
|
|
|
317
321
|
* - fix: 確定時(blur)に「-」「.」「-.」や末尾の「.」を空/削除にする
|
|
318
322
|
*
|
|
319
323
|
* @param {NumericRuleOptions} [options]
|
|
320
|
-
* @returns {
|
|
324
|
+
* @returns {Rule}
|
|
321
325
|
*/
|
|
322
326
|
declare function numeric(options?: NumericRuleOptions): Rule;
|
|
323
327
|
declare namespace numeric {
|
|
@@ -335,7 +339,7 @@ declare namespace numeric {
|
|
|
335
339
|
*
|
|
336
340
|
* @param {DOMStringMap} dataset
|
|
337
341
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
338
|
-
* @returns {
|
|
342
|
+
* @returns {Rule|null}
|
|
339
343
|
*/
|
|
340
344
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
341
345
|
}
|
|
@@ -364,7 +368,7 @@ type NumericRuleOptions = {
|
|
|
364
368
|
/**
|
|
365
369
|
* digits ルールを生成する
|
|
366
370
|
* @param {DigitsRuleOptions} [options]
|
|
367
|
-
* @returns {
|
|
371
|
+
* @returns {Rule}
|
|
368
372
|
*/
|
|
369
373
|
declare function digits(options?: DigitsRuleOptions): Rule;
|
|
370
374
|
declare namespace digits {
|
|
@@ -386,7 +390,7 @@ declare namespace digits {
|
|
|
386
390
|
*
|
|
387
391
|
* @param {DOMStringMap} dataset
|
|
388
392
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
389
|
-
* @returns {
|
|
393
|
+
* @returns {Rule|null}
|
|
390
394
|
*/
|
|
391
395
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
392
396
|
}
|
|
@@ -440,7 +444,7 @@ type DigitsRuleOptions = {
|
|
|
440
444
|
/**
|
|
441
445
|
* カンマ付与ルール
|
|
442
446
|
* - blur時のみ整数部に3桁区切りカンマを付与する
|
|
443
|
-
* @returns {
|
|
447
|
+
* @returns {Rule}
|
|
444
448
|
*/
|
|
445
449
|
declare function comma(): Rule;
|
|
446
450
|
declare namespace comma {
|
|
@@ -453,7 +457,7 @@ declare namespace comma {
|
|
|
453
457
|
*
|
|
454
458
|
* @param {DOMStringMap} dataset
|
|
455
459
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
456
|
-
* @returns {
|
|
460
|
+
* @returns {Rule|null}
|
|
457
461
|
*/
|
|
458
462
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
459
463
|
}
|
|
@@ -465,7 +469,7 @@ declare namespace comma {
|
|
|
465
469
|
* - これは「半角化」ではなく「IMEオフ入力相当への寄せ」
|
|
466
470
|
* - ascii() とは責務が異なる
|
|
467
471
|
*
|
|
468
|
-
* @returns {
|
|
472
|
+
* @returns {Rule}
|
|
469
473
|
*/
|
|
470
474
|
declare function imeOff(): Rule;
|
|
471
475
|
declare namespace imeOff {
|
|
@@ -477,7 +481,7 @@ declare namespace imeOff {
|
|
|
477
481
|
*
|
|
478
482
|
* @param {DOMStringMap} dataset
|
|
479
483
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
480
|
-
* @returns {
|
|
484
|
+
* @returns {Rule|null}
|
|
481
485
|
*/
|
|
482
486
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
483
487
|
}
|
|
@@ -491,7 +495,7 @@ declare namespace imeOff {
|
|
|
491
495
|
/**
|
|
492
496
|
* kana ルールを生成する
|
|
493
497
|
* @param {KanaRuleOptions} [options]
|
|
494
|
-
* @returns {
|
|
498
|
+
* @returns {Rule}
|
|
495
499
|
*/
|
|
496
500
|
declare function kana(options?: KanaRuleOptions): Rule;
|
|
497
501
|
declare namespace kana {
|
|
@@ -507,7 +511,7 @@ declare namespace kana {
|
|
|
507
511
|
*
|
|
508
512
|
* @param {DOMStringMap} dataset
|
|
509
513
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
510
|
-
* @returns {
|
|
514
|
+
* @returns {Rule|null}
|
|
511
515
|
*/
|
|
512
516
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
513
517
|
}
|
|
@@ -536,7 +540,7 @@ type KanaRuleOptions = {
|
|
|
536
540
|
* - 必要に応じて英字を大文字/小文字へ統一
|
|
537
541
|
*
|
|
538
542
|
* @param {AsciiRuleOptions} [options]
|
|
539
|
-
* @returns {
|
|
543
|
+
* @returns {Rule}
|
|
540
544
|
*/
|
|
541
545
|
declare function ascii(options?: AsciiRuleOptions): Rule;
|
|
542
546
|
declare namespace ascii {
|
|
@@ -549,7 +553,7 @@ declare namespace ascii {
|
|
|
549
553
|
*
|
|
550
554
|
* @param {DOMStringMap} dataset
|
|
551
555
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
552
|
-
* @returns {
|
|
556
|
+
* @returns {Rule|null}
|
|
553
557
|
*/
|
|
554
558
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
555
559
|
}
|
|
@@ -566,7 +570,7 @@ type AsciiRuleOptions = {
|
|
|
566
570
|
/**
|
|
567
571
|
* filter ルールを生成する
|
|
568
572
|
* @param {FilterRuleOptions} [options]
|
|
569
|
-
* @returns {
|
|
573
|
+
* @returns {Rule}
|
|
570
574
|
*/
|
|
571
575
|
declare function filter(options?: FilterRuleOptions): Rule;
|
|
572
576
|
declare namespace filter {
|
|
@@ -585,7 +589,7 @@ declare namespace filter {
|
|
|
585
589
|
*
|
|
586
590
|
* @param {DOMStringMap} dataset
|
|
587
591
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
588
|
-
* @returns {
|
|
592
|
+
* @returns {Rule|null}
|
|
589
593
|
*/
|
|
590
594
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
591
595
|
}
|
|
@@ -643,7 +647,7 @@ type FilterCategory = "digits" | "alpha-upper" | "alpha-lower" | "ascii" | "hira
|
|
|
643
647
|
/**
|
|
644
648
|
* length ルールを生成する
|
|
645
649
|
* @param {LengthRuleOptions} [options]
|
|
646
|
-
* @returns {
|
|
650
|
+
* @returns {Rule}
|
|
647
651
|
*/
|
|
648
652
|
declare function length(options?: LengthRuleOptions): Rule;
|
|
649
653
|
declare namespace length {
|
|
@@ -660,7 +664,7 @@ declare namespace length {
|
|
|
660
664
|
*
|
|
661
665
|
* @param {DOMStringMap} dataset
|
|
662
666
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
663
|
-
* @returns {
|
|
667
|
+
* @returns {Rule|null}
|
|
664
668
|
*/
|
|
665
669
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
666
670
|
}
|
|
@@ -691,7 +695,7 @@ type LengthRuleOptions = {
|
|
|
691
695
|
/**
|
|
692
696
|
* width ルールを生成する
|
|
693
697
|
* @param {WidthRuleOptions} [options]
|
|
694
|
-
* @returns {
|
|
698
|
+
* @returns {Rule}
|
|
695
699
|
*/
|
|
696
700
|
declare function width(options?: WidthRuleOptions): Rule;
|
|
697
701
|
declare namespace width {
|
|
@@ -707,7 +711,7 @@ declare namespace width {
|
|
|
707
711
|
*
|
|
708
712
|
* @param {DOMStringMap} dataset
|
|
709
713
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
710
|
-
* @returns {
|
|
714
|
+
* @returns {Rule|null}
|
|
711
715
|
*/
|
|
712
716
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
713
717
|
}
|
|
@@ -728,7 +732,7 @@ type WidthRuleOptions = {
|
|
|
728
732
|
/**
|
|
729
733
|
* bytes ルールを生成する
|
|
730
734
|
* @param {BytesRuleOptions} [options]
|
|
731
|
-
* @returns {
|
|
735
|
+
* @returns {Rule}
|
|
732
736
|
*/
|
|
733
737
|
declare function bytes(options?: BytesRuleOptions): Rule;
|
|
734
738
|
declare namespace bytes {
|
|
@@ -742,10 +746,11 @@ declare namespace bytes {
|
|
|
742
746
|
* - data-tig-rules-bytes-max -> dataset.tigRulesBytesMax
|
|
743
747
|
* - data-tig-rules-bytes-mode -> dataset.tigRulesBytesMode
|
|
744
748
|
* - data-tig-rules-bytes-unit -> dataset.tigRulesBytesUnit
|
|
749
|
+
* - data-tig-rules-bytes-newline -> dataset.tigRulesBytesNewline
|
|
745
750
|
*
|
|
746
751
|
* @param {DOMStringMap} dataset
|
|
747
752
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
748
|
-
* @returns {
|
|
753
|
+
* @returns {Rule|null}
|
|
749
754
|
*/
|
|
750
755
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
751
756
|
}
|
|
@@ -754,7 +759,7 @@ declare namespace bytes {
|
|
|
754
759
|
*/
|
|
755
760
|
type BytesRuleOptions = {
|
|
756
761
|
/**
|
|
757
|
-
* -
|
|
762
|
+
* - バイト数。未指定なら制限なし
|
|
758
763
|
*/
|
|
759
764
|
max?: number;
|
|
760
765
|
/**
|
|
@@ -765,6 +770,10 @@ type BytesRuleOptions = {
|
|
|
765
770
|
* - サイズの単位(sjis系を使用する場合はfilterも必須)
|
|
766
771
|
*/
|
|
767
772
|
unit?: "utf-8" | "utf-16" | "utf-32" | "sjis" | "cp932";
|
|
773
|
+
/**
|
|
774
|
+
* - 改行の扱い(バイト数計算に影響あり)
|
|
775
|
+
*/
|
|
776
|
+
newline?: "\n" | "\r" | "\r\n";
|
|
768
777
|
};
|
|
769
778
|
|
|
770
779
|
/**
|
|
@@ -788,7 +797,7 @@ type BytesRuleOptions = {
|
|
|
788
797
|
* - 手動入力された同文字列は normalizeStructure で除去する
|
|
789
798
|
*
|
|
790
799
|
* @param {PrefixRuleOptions} options
|
|
791
|
-
* @returns {
|
|
800
|
+
* @returns {Rule}
|
|
792
801
|
*/
|
|
793
802
|
declare function prefix(options: PrefixRuleOptions): Rule;
|
|
794
803
|
declare namespace prefix {
|
|
@@ -803,7 +812,7 @@ declare namespace prefix {
|
|
|
803
812
|
*
|
|
804
813
|
* @param {DOMStringMap} dataset
|
|
805
814
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
806
|
-
* @returns {
|
|
815
|
+
* @returns {Rule|null}
|
|
807
816
|
*/
|
|
808
817
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
809
818
|
}
|
|
@@ -842,7 +851,7 @@ type PrefixRuleOptions = {
|
|
|
842
851
|
* - 手動入力された同文字列は normalizeStructure で除去する
|
|
843
852
|
*
|
|
844
853
|
* @param {SuffixRuleOptions} options
|
|
845
|
-
* @returns {
|
|
854
|
+
* @returns {Rule}
|
|
846
855
|
*/
|
|
847
856
|
declare function suffix(options: SuffixRuleOptions): Rule;
|
|
848
857
|
declare namespace suffix {
|
|
@@ -857,7 +866,7 @@ declare namespace suffix {
|
|
|
857
866
|
*
|
|
858
867
|
* @param {DOMStringMap} dataset
|
|
859
868
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
860
|
-
* @returns {
|
|
869
|
+
* @returns {Rule|null}
|
|
861
870
|
*/
|
|
862
871
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
863
872
|
}
|
|
@@ -886,7 +895,7 @@ type SuffixRuleOptions = {
|
|
|
886
895
|
*/
|
|
887
896
|
/**
|
|
888
897
|
* トリムするルール
|
|
889
|
-
* @returns {
|
|
898
|
+
* @returns {Rule}
|
|
890
899
|
*/
|
|
891
900
|
declare function trim(): Rule;
|
|
892
901
|
declare namespace trim {
|
|
@@ -899,7 +908,7 @@ declare namespace trim {
|
|
|
899
908
|
*
|
|
900
909
|
* @param {DOMStringMap} dataset
|
|
901
910
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
902
|
-
* @returns {
|
|
911
|
+
* @returns {Rule|null}
|
|
903
912
|
*/
|
|
904
913
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
905
914
|
}
|
|
@@ -925,5 +934,25 @@ declare namespace rules {
|
|
|
925
934
|
* 例: rollup replace で "__VERSION__" を package.json の version に置換
|
|
926
935
|
*/
|
|
927
936
|
declare const version: any;
|
|
937
|
+
declare namespace TextInputGuard {
|
|
938
|
+
export { attach };
|
|
939
|
+
export { attachAll };
|
|
940
|
+
export { autoAttach };
|
|
941
|
+
export { rules };
|
|
942
|
+
export { numeric };
|
|
943
|
+
export { digits };
|
|
944
|
+
export { comma };
|
|
945
|
+
export { imeOff };
|
|
946
|
+
export { kana };
|
|
947
|
+
export { ascii };
|
|
948
|
+
export { filter };
|
|
949
|
+
export { length };
|
|
950
|
+
export { width };
|
|
951
|
+
export { bytes };
|
|
952
|
+
export { prefix };
|
|
953
|
+
export { suffix };
|
|
954
|
+
export { trim };
|
|
955
|
+
export { version };
|
|
956
|
+
}
|
|
928
957
|
|
|
929
|
-
export { ascii, attach, attachAll, autoAttach, bytes, comma, digits, filter, imeOff, kana, length, numeric, prefix, rules, suffix, trim, version, width };
|
|
958
|
+
export { TextInputGuard, ascii, attach, attachAll, autoAttach, bytes, comma, digits, filter, imeOff, kana, length, numeric, prefix, rules, suffix, trim, version, width };
|