text-input-guard 1.0.2 → 1.2.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 +308 -68
- package/dist/cjs/text-input-guard.min.cjs +1 -1
- package/dist/esm/text-input-guard.js +308 -69
- package/dist/esm/text-input-guard.min.js +1 -1
- package/dist/types/text-input-guard.d.ts +65 -28
- package/dist/umd/text-input-guard.js +308 -68
- package/dist/umd/text-input-guard.min.js +1 -1
- package/package.json +1 -1
|
@@ -283,10 +283,22 @@ type AttachOptions = {
|
|
|
283
283
|
* - 表示値と内部値の分離設定
|
|
284
284
|
*/
|
|
285
285
|
separateValue?: SeparateValueOptions;
|
|
286
|
+
/**
|
|
287
|
+
* - 記録する履歴の最大件数
|
|
288
|
+
*/
|
|
289
|
+
historySize?: number;
|
|
286
290
|
/**
|
|
287
291
|
* - 評価完了時の通知(input/commitごと)
|
|
288
292
|
*/
|
|
289
293
|
onValidate?: (result: ValidateResult) => void;
|
|
294
|
+
/**
|
|
295
|
+
* - 入力時に値が変更されていた場合の通知
|
|
296
|
+
*/
|
|
297
|
+
onInput?: (result: Guard) => void;
|
|
298
|
+
/**
|
|
299
|
+
* - フォーカスが外れた値が変更されていた場合の通知
|
|
300
|
+
*/
|
|
301
|
+
onChange?: (result: Guard) => void;
|
|
290
302
|
};
|
|
291
303
|
/**
|
|
292
304
|
* revert要求(入力を巻き戻す指示)
|
|
@@ -317,7 +329,7 @@ type RevertRequest = {
|
|
|
317
329
|
* - fix: 確定時(blur)に「-」「.」「-.」や末尾の「.」を空/削除にする
|
|
318
330
|
*
|
|
319
331
|
* @param {NumericRuleOptions} [options]
|
|
320
|
-
* @returns {
|
|
332
|
+
* @returns {Rule}
|
|
321
333
|
*/
|
|
322
334
|
declare function numeric(options?: NumericRuleOptions): Rule;
|
|
323
335
|
declare namespace numeric {
|
|
@@ -335,7 +347,7 @@ declare namespace numeric {
|
|
|
335
347
|
*
|
|
336
348
|
* @param {DOMStringMap} dataset
|
|
337
349
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
338
|
-
* @returns {
|
|
350
|
+
* @returns {Rule|null}
|
|
339
351
|
*/
|
|
340
352
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
341
353
|
}
|
|
@@ -364,7 +376,7 @@ type NumericRuleOptions = {
|
|
|
364
376
|
/**
|
|
365
377
|
* digits ルールを生成する
|
|
366
378
|
* @param {DigitsRuleOptions} [options]
|
|
367
|
-
* @returns {
|
|
379
|
+
* @returns {Rule}
|
|
368
380
|
*/
|
|
369
381
|
declare function digits(options?: DigitsRuleOptions): Rule;
|
|
370
382
|
declare namespace digits {
|
|
@@ -386,7 +398,7 @@ declare namespace digits {
|
|
|
386
398
|
*
|
|
387
399
|
* @param {DOMStringMap} dataset
|
|
388
400
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
389
|
-
* @returns {
|
|
401
|
+
* @returns {Rule|null}
|
|
390
402
|
*/
|
|
391
403
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
392
404
|
}
|
|
@@ -440,7 +452,7 @@ type DigitsRuleOptions = {
|
|
|
440
452
|
/**
|
|
441
453
|
* カンマ付与ルール
|
|
442
454
|
* - blur時のみ整数部に3桁区切りカンマを付与する
|
|
443
|
-
* @returns {
|
|
455
|
+
* @returns {Rule}
|
|
444
456
|
*/
|
|
445
457
|
declare function comma(): Rule;
|
|
446
458
|
declare namespace comma {
|
|
@@ -453,7 +465,7 @@ declare namespace comma {
|
|
|
453
465
|
*
|
|
454
466
|
* @param {DOMStringMap} dataset
|
|
455
467
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
456
|
-
* @returns {
|
|
468
|
+
* @returns {Rule|null}
|
|
457
469
|
*/
|
|
458
470
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
459
471
|
}
|
|
@@ -465,7 +477,7 @@ declare namespace comma {
|
|
|
465
477
|
* - これは「半角化」ではなく「IMEオフ入力相当への寄せ」
|
|
466
478
|
* - ascii() とは責務が異なる
|
|
467
479
|
*
|
|
468
|
-
* @returns {
|
|
480
|
+
* @returns {Rule}
|
|
469
481
|
*/
|
|
470
482
|
declare function imeOff(): Rule;
|
|
471
483
|
declare namespace imeOff {
|
|
@@ -477,7 +489,7 @@ declare namespace imeOff {
|
|
|
477
489
|
*
|
|
478
490
|
* @param {DOMStringMap} dataset
|
|
479
491
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
480
|
-
* @returns {
|
|
492
|
+
* @returns {Rule|null}
|
|
481
493
|
*/
|
|
482
494
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
483
495
|
}
|
|
@@ -491,7 +503,7 @@ declare namespace imeOff {
|
|
|
491
503
|
/**
|
|
492
504
|
* kana ルールを生成する
|
|
493
505
|
* @param {KanaRuleOptions} [options]
|
|
494
|
-
* @returns {
|
|
506
|
+
* @returns {Rule}
|
|
495
507
|
*/
|
|
496
508
|
declare function kana(options?: KanaRuleOptions): Rule;
|
|
497
509
|
declare namespace kana {
|
|
@@ -507,7 +519,7 @@ declare namespace kana {
|
|
|
507
519
|
*
|
|
508
520
|
* @param {DOMStringMap} dataset
|
|
509
521
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
510
|
-
* @returns {
|
|
522
|
+
* @returns {Rule|null}
|
|
511
523
|
*/
|
|
512
524
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
513
525
|
}
|
|
@@ -536,7 +548,7 @@ type KanaRuleOptions = {
|
|
|
536
548
|
* - 必要に応じて英字を大文字/小文字へ統一
|
|
537
549
|
*
|
|
538
550
|
* @param {AsciiRuleOptions} [options]
|
|
539
|
-
* @returns {
|
|
551
|
+
* @returns {Rule}
|
|
540
552
|
*/
|
|
541
553
|
declare function ascii(options?: AsciiRuleOptions): Rule;
|
|
542
554
|
declare namespace ascii {
|
|
@@ -549,7 +561,7 @@ declare namespace ascii {
|
|
|
549
561
|
*
|
|
550
562
|
* @param {DOMStringMap} dataset
|
|
551
563
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
552
|
-
* @returns {
|
|
564
|
+
* @returns {Rule|null}
|
|
553
565
|
*/
|
|
554
566
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
555
567
|
}
|
|
@@ -566,7 +578,7 @@ type AsciiRuleOptions = {
|
|
|
566
578
|
/**
|
|
567
579
|
* filter ルールを生成する
|
|
568
580
|
* @param {FilterRuleOptions} [options]
|
|
569
|
-
* @returns {
|
|
581
|
+
* @returns {Rule}
|
|
570
582
|
*/
|
|
571
583
|
declare function filter(options?: FilterRuleOptions): Rule;
|
|
572
584
|
declare namespace filter {
|
|
@@ -585,7 +597,7 @@ declare namespace filter {
|
|
|
585
597
|
*
|
|
586
598
|
* @param {DOMStringMap} dataset
|
|
587
599
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
588
|
-
* @returns {
|
|
600
|
+
* @returns {Rule|null}
|
|
589
601
|
*/
|
|
590
602
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
591
603
|
}
|
|
@@ -643,7 +655,7 @@ type FilterCategory = "digits" | "alpha-upper" | "alpha-lower" | "ascii" | "hira
|
|
|
643
655
|
/**
|
|
644
656
|
* length ルールを生成する
|
|
645
657
|
* @param {LengthRuleOptions} [options]
|
|
646
|
-
* @returns {
|
|
658
|
+
* @returns {Rule}
|
|
647
659
|
*/
|
|
648
660
|
declare function length(options?: LengthRuleOptions): Rule;
|
|
649
661
|
declare namespace length {
|
|
@@ -660,7 +672,7 @@ declare namespace length {
|
|
|
660
672
|
*
|
|
661
673
|
* @param {DOMStringMap} dataset
|
|
662
674
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
663
|
-
* @returns {
|
|
675
|
+
* @returns {Rule|null}
|
|
664
676
|
*/
|
|
665
677
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
666
678
|
}
|
|
@@ -691,7 +703,7 @@ type LengthRuleOptions = {
|
|
|
691
703
|
/**
|
|
692
704
|
* width ルールを生成する
|
|
693
705
|
* @param {WidthRuleOptions} [options]
|
|
694
|
-
* @returns {
|
|
706
|
+
* @returns {Rule}
|
|
695
707
|
*/
|
|
696
708
|
declare function width(options?: WidthRuleOptions): Rule;
|
|
697
709
|
declare namespace width {
|
|
@@ -707,7 +719,7 @@ declare namespace width {
|
|
|
707
719
|
*
|
|
708
720
|
* @param {DOMStringMap} dataset
|
|
709
721
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
710
|
-
* @returns {
|
|
722
|
+
* @returns {Rule|null}
|
|
711
723
|
*/
|
|
712
724
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
713
725
|
}
|
|
@@ -728,7 +740,7 @@ type WidthRuleOptions = {
|
|
|
728
740
|
/**
|
|
729
741
|
* bytes ルールを生成する
|
|
730
742
|
* @param {BytesRuleOptions} [options]
|
|
731
|
-
* @returns {
|
|
743
|
+
* @returns {Rule}
|
|
732
744
|
*/
|
|
733
745
|
declare function bytes(options?: BytesRuleOptions): Rule;
|
|
734
746
|
declare namespace bytes {
|
|
@@ -742,10 +754,11 @@ declare namespace bytes {
|
|
|
742
754
|
* - data-tig-rules-bytes-max -> dataset.tigRulesBytesMax
|
|
743
755
|
* - data-tig-rules-bytes-mode -> dataset.tigRulesBytesMode
|
|
744
756
|
* - data-tig-rules-bytes-unit -> dataset.tigRulesBytesUnit
|
|
757
|
+
* - data-tig-rules-bytes-newline -> dataset.tigRulesBytesNewline
|
|
745
758
|
*
|
|
746
759
|
* @param {DOMStringMap} dataset
|
|
747
760
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
748
|
-
* @returns {
|
|
761
|
+
* @returns {Rule|null}
|
|
749
762
|
*/
|
|
750
763
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
751
764
|
}
|
|
@@ -754,7 +767,7 @@ declare namespace bytes {
|
|
|
754
767
|
*/
|
|
755
768
|
type BytesRuleOptions = {
|
|
756
769
|
/**
|
|
757
|
-
* -
|
|
770
|
+
* - バイト数。未指定なら制限なし
|
|
758
771
|
*/
|
|
759
772
|
max?: number;
|
|
760
773
|
/**
|
|
@@ -765,6 +778,10 @@ type BytesRuleOptions = {
|
|
|
765
778
|
* - サイズの単位(sjis系を使用する場合はfilterも必須)
|
|
766
779
|
*/
|
|
767
780
|
unit?: "utf-8" | "utf-16" | "utf-32" | "sjis" | "cp932";
|
|
781
|
+
/**
|
|
782
|
+
* - 改行の扱い(バイト数計算に影響あり)
|
|
783
|
+
*/
|
|
784
|
+
newline?: "\n" | "\r" | "\r\n";
|
|
768
785
|
};
|
|
769
786
|
|
|
770
787
|
/**
|
|
@@ -788,7 +805,7 @@ type BytesRuleOptions = {
|
|
|
788
805
|
* - 手動入力された同文字列は normalizeStructure で除去する
|
|
789
806
|
*
|
|
790
807
|
* @param {PrefixRuleOptions} options
|
|
791
|
-
* @returns {
|
|
808
|
+
* @returns {Rule}
|
|
792
809
|
*/
|
|
793
810
|
declare function prefix(options: PrefixRuleOptions): Rule;
|
|
794
811
|
declare namespace prefix {
|
|
@@ -803,7 +820,7 @@ declare namespace prefix {
|
|
|
803
820
|
*
|
|
804
821
|
* @param {DOMStringMap} dataset
|
|
805
822
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
806
|
-
* @returns {
|
|
823
|
+
* @returns {Rule|null}
|
|
807
824
|
*/
|
|
808
825
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
809
826
|
}
|
|
@@ -842,7 +859,7 @@ type PrefixRuleOptions = {
|
|
|
842
859
|
* - 手動入力された同文字列は normalizeStructure で除去する
|
|
843
860
|
*
|
|
844
861
|
* @param {SuffixRuleOptions} options
|
|
845
|
-
* @returns {
|
|
862
|
+
* @returns {Rule}
|
|
846
863
|
*/
|
|
847
864
|
declare function suffix(options: SuffixRuleOptions): Rule;
|
|
848
865
|
declare namespace suffix {
|
|
@@ -857,7 +874,7 @@ declare namespace suffix {
|
|
|
857
874
|
*
|
|
858
875
|
* @param {DOMStringMap} dataset
|
|
859
876
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
860
|
-
* @returns {
|
|
877
|
+
* @returns {Rule|null}
|
|
861
878
|
*/
|
|
862
879
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
863
880
|
}
|
|
@@ -886,7 +903,7 @@ type SuffixRuleOptions = {
|
|
|
886
903
|
*/
|
|
887
904
|
/**
|
|
888
905
|
* トリムするルール
|
|
889
|
-
* @returns {
|
|
906
|
+
* @returns {Rule}
|
|
890
907
|
*/
|
|
891
908
|
declare function trim(): Rule;
|
|
892
909
|
declare namespace trim {
|
|
@@ -899,7 +916,7 @@ declare namespace trim {
|
|
|
899
916
|
*
|
|
900
917
|
* @param {DOMStringMap} dataset
|
|
901
918
|
* @param {HTMLInputElement|HTMLTextAreaElement} _el
|
|
902
|
-
* @returns {
|
|
919
|
+
* @returns {Rule|null}
|
|
903
920
|
*/
|
|
904
921
|
function fromDataset(dataset: DOMStringMap, _el: HTMLInputElement | HTMLTextAreaElement): Rule | null;
|
|
905
922
|
}
|
|
@@ -925,5 +942,25 @@ declare namespace rules {
|
|
|
925
942
|
* 例: rollup replace で "__VERSION__" を package.json の version に置換
|
|
926
943
|
*/
|
|
927
944
|
declare const version: any;
|
|
945
|
+
declare namespace TextInputGuard {
|
|
946
|
+
export { attach };
|
|
947
|
+
export { attachAll };
|
|
948
|
+
export { autoAttach };
|
|
949
|
+
export { rules };
|
|
950
|
+
export { numeric };
|
|
951
|
+
export { digits };
|
|
952
|
+
export { comma };
|
|
953
|
+
export { imeOff };
|
|
954
|
+
export { kana };
|
|
955
|
+
export { ascii };
|
|
956
|
+
export { filter };
|
|
957
|
+
export { length };
|
|
958
|
+
export { width };
|
|
959
|
+
export { bytes };
|
|
960
|
+
export { prefix };
|
|
961
|
+
export { suffix };
|
|
962
|
+
export { trim };
|
|
963
|
+
export { version };
|
|
964
|
+
}
|
|
928
965
|
|
|
929
|
-
export { ascii, attach, attachAll, autoAttach, bytes, comma, digits, filter, imeOff, kana, length, numeric, prefix, rules, suffix, trim, version, width };
|
|
966
|
+
export { TextInputGuard, ascii, attach, attachAll, autoAttach, bytes, comma, digits, filter, imeOff, kana, length, numeric, prefix, rules, suffix, trim, version, width };
|