amotify 0.0.54 → 0.0.55
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/@types/fn.tsx +3 -1
- package/dist/amotify.js +2 -2
- package/dist/amotify.min.css +1 -1
- package/dist/coreVender.js +1 -1
- package/package.json +1 -1
- package/src/functions/Input/Text.tsx +60 -4
- package/src/functions/Input/_.tsx +8 -0
package/package.json
CHANGED
|
@@ -24,6 +24,14 @@ const ValidateTypes: {
|
|
|
24
24
|
reg: /^-?[0-9\.]+$/g,exist: true,
|
|
25
25
|
reason: '半角数字で入力してください'
|
|
26
26
|
},
|
|
27
|
+
katakana: {
|
|
28
|
+
reg: /^[ァ-ヶー ヲ-゚ ]*$/g,exist: true,
|
|
29
|
+
reason: 'カタカナで入力してください'
|
|
30
|
+
},
|
|
31
|
+
[ 'hankaku.katakana' ]: {
|
|
32
|
+
reg: /^[ヲ-゚ ]*$/g,exist: true,
|
|
33
|
+
reason: '半角カタカナで入力してください'
|
|
34
|
+
},
|
|
27
35
|
digitNumber: {
|
|
28
36
|
reg: /^-?[0-9\.]+$/g,exist: true,
|
|
29
37
|
reason: '半角数字で入力してください'
|
|
@@ -33,8 +41,8 @@ const ValidateTypes: {
|
|
|
33
41
|
reason: '空白または一部の特殊文字は使用できません'
|
|
34
42
|
},
|
|
35
43
|
creditCard: {
|
|
36
|
-
reg: /^\d{16}$/g,exist: true,
|
|
37
|
-
reason: '16桁の数字で入力してください'
|
|
44
|
+
reg: /^\d{14,16}$/g,exist: true,
|
|
45
|
+
reason: '14~16桁の数字で入力してください'
|
|
38
46
|
},
|
|
39
47
|
email: {
|
|
40
48
|
reg: /^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist: true,
|
|
@@ -48,12 +56,18 @@ const ValidateTypes: {
|
|
|
48
56
|
reason: '8文字以上、半角英数大小文字で入力してください'
|
|
49
57
|
},
|
|
50
58
|
tel: {
|
|
51
|
-
reg:
|
|
59
|
+
reg: /.*$/g,exist: true,
|
|
52
60
|
reason: <>
|
|
53
61
|
<Box>0から始まる番号のみ入力可能です</Box>
|
|
54
62
|
<Box>9~12桁の数字で入力してください</Box>
|
|
55
63
|
<Box>数字のみ入力可能です</Box>
|
|
56
64
|
</>
|
|
65
|
+
// reg: /^(0|\(?\+\d{1,3}\)?\s)[-0-9]{9,12}$/g,exist: true,
|
|
66
|
+
// reason: <>
|
|
67
|
+
// <Box>0から始まる番号のみ入力可能です</Box>
|
|
68
|
+
// <Box>9~12桁の数字で入力してください</Box>
|
|
69
|
+
// <Box>数字のみ入力可能です</Box>
|
|
70
|
+
// </>
|
|
57
71
|
},
|
|
58
72
|
url: {
|
|
59
73
|
reg: /^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist: true,
|
|
@@ -81,6 +95,12 @@ const DataLeveling = ( params: {
|
|
|
81
95
|
if ( [ 'tel','number','digitNumber','test','postal','creditCard' ].includes( restrict ) ) {
|
|
82
96
|
dataValue = dataValue.zen2hanNumber();
|
|
83
97
|
}
|
|
98
|
+
if ( restrict == 'katakana' ) {
|
|
99
|
+
dataValue = dataValue.replace( /[^ァ-ヶー ヲ-゚ ]/ig,'' );
|
|
100
|
+
}
|
|
101
|
+
if ( restrict == 'hankaku.katakana' ) {
|
|
102
|
+
dataValue = dataValue.replace( /[^ヲ-゚ ]/ig,'' );
|
|
103
|
+
}
|
|
84
104
|
if ( [ 'postal','creditCard' ].includes( restrict ) ) {
|
|
85
105
|
dataValue = dataValue.removeLetters();
|
|
86
106
|
}
|
|
@@ -273,7 +293,7 @@ export const TextInput: React.FC<amotify.fn.Input.Text.OriginParams> = ( params
|
|
|
273
293
|
} = params;
|
|
274
294
|
|
|
275
295
|
let inputType = restrict == 'password' ? 'password' : 'text';
|
|
276
|
-
let inputMode: 'numeric' | 'text' | 'email' = [ 'number','digitNumber','
|
|
296
|
+
let inputMode: 'numeric' | 'text' | 'email' = [ 'number','digitNumber','creditCard' ].includes( restrict ) ? 'numeric' : restrict == 'email' ? 'email' : 'text';
|
|
277
297
|
|
|
278
298
|
let Default_Status: amotify.fn.Input.Status.Text = {
|
|
279
299
|
componentID: componentID!,
|
|
@@ -288,6 +308,7 @@ export const TextInput: React.FC<amotify.fn.Input.Text.OriginParams> = ( params
|
|
|
288
308
|
caretFrom: null as any,
|
|
289
309
|
caretTo: null as any
|
|
290
310
|
}
|
|
311
|
+
let [ val_isComposing,set_isComposing ] = React.useState( false );
|
|
291
312
|
let [ val_status,set_status ] = React.useState( Default_Status );
|
|
292
313
|
let [ val_validate,set_validate ] = React.useState( {
|
|
293
314
|
ok: false,
|
|
@@ -335,6 +356,7 @@ export const TextInput: React.FC<amotify.fn.Input.Text.OriginParams> = ( params
|
|
|
335
356
|
autoCapitalize={ autoCapitalize }
|
|
336
357
|
onKeyDown={ ( event ) => {
|
|
337
358
|
let { key,target } = event;
|
|
359
|
+
|
|
338
360
|
{
|
|
339
361
|
let input = target as HTMLInputElement;
|
|
340
362
|
let { selectionStart,selectionEnd } = input;
|
|
@@ -359,6 +381,9 @@ export const TextInput: React.FC<amotify.fn.Input.Text.OriginParams> = ( params
|
|
|
359
381
|
input.setSelectionRange( caretFrom - 1,caretTo - 1 );
|
|
360
382
|
event.preventDefault();
|
|
361
383
|
}
|
|
384
|
+
if ( key == 'Enter' || key == 'Tab' ) {
|
|
385
|
+
|
|
386
|
+
}
|
|
362
387
|
}
|
|
363
388
|
|
|
364
389
|
if ( [ 'number','digitNumber','creditCard' ].includes( restrict ) ) {
|
|
@@ -408,9 +433,13 @@ export const TextInput: React.FC<amotify.fn.Input.Text.OriginParams> = ( params
|
|
|
408
433
|
restrict,
|
|
409
434
|
value: rawValue
|
|
410
435
|
} );
|
|
436
|
+
|
|
437
|
+
if ( val_isComposing ) value.formatValue = rawValue;
|
|
438
|
+
|
|
411
439
|
if ( value.formatValue == val_status.formatValue ) return;
|
|
412
440
|
|
|
413
441
|
if ( val_validate.ok ) set_validate( { ok: false,notice: [] } );
|
|
442
|
+
|
|
414
443
|
set_status( {
|
|
415
444
|
...val_status,
|
|
416
445
|
...value,
|
|
@@ -424,6 +453,33 @@ export const TextInput: React.FC<amotify.fn.Input.Text.OriginParams> = ( params
|
|
|
424
453
|
if ( onChange ) onChange( event );
|
|
425
454
|
} }
|
|
426
455
|
{ ...others }
|
|
456
|
+
onCompositionStart={ ( event ) => {
|
|
457
|
+
others?.onCompositionStart && others?.onCompositionStart( event );
|
|
458
|
+
set_isComposing( true );
|
|
459
|
+
} }
|
|
460
|
+
onCompositionEnd={ ( event ) => {
|
|
461
|
+
others?.onCompositionEnd && others?.onCompositionEnd( event );
|
|
462
|
+
|
|
463
|
+
if ( restrict == 'text' ) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
let value = DataLeveling( {
|
|
468
|
+
min,max,
|
|
469
|
+
restrict,
|
|
470
|
+
value: val_status.formatValue
|
|
471
|
+
} );
|
|
472
|
+
set_status( {
|
|
473
|
+
...val_status,
|
|
474
|
+
...value,
|
|
475
|
+
prevValue: val_status.formatValue,
|
|
476
|
+
eventType: 'update',
|
|
477
|
+
eventID: $.uuidGen(),
|
|
478
|
+
caretFrom: Number( val_status.formatValue.length + 1 ),
|
|
479
|
+
caretTo: Number( val_status.formatValue.length + 1 )
|
|
480
|
+
} );
|
|
481
|
+
set_isComposing( false );
|
|
482
|
+
} }
|
|
427
483
|
/>
|
|
428
484
|
</BoxWrapper>;
|
|
429
485
|
}
|
|
@@ -88,6 +88,14 @@ const TextInputs: amotify.fn.Input.Text.Methods = {
|
|
|
88
88
|
params={ DefaultStyles.Boxish( rawParams ) }
|
|
89
89
|
/>;
|
|
90
90
|
},
|
|
91
|
+
Katakana: ( props ) => ( <TextInputs.Normal
|
|
92
|
+
restrict='katakana'
|
|
93
|
+
{ ...props }
|
|
94
|
+
/> ),
|
|
95
|
+
HankakuKatakana: ( props ) => ( <TextInputs.Normal
|
|
96
|
+
restrict='hankaku.katakana'
|
|
97
|
+
{ ...props }
|
|
98
|
+
/> ),
|
|
91
99
|
CreditCard: ( props ) => ( <TextInputs.Normal
|
|
92
100
|
restrict='creditCard'
|
|
93
101
|
{ ...props }
|