amotify 0.0.56 → 0.0.58
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 +16 -0
- package/dist/amotify.js +2 -2
- package/dist/amotify.min.css +2 -2
- package/dist/coreVender.js +1 -1
- package/package.json +1 -1
- package/src/@jsminAmotifyExtension/formCollect.tsx +3 -0
- package/src/functions/Button/_.tsx +1 -1
- package/src/functions/Input/Contenteditable.tsx +114 -0
- package/src/functions/Input/_.tsx +21 -0
- package/src/functions/Input/style.module.scss +1 -0
package/package.json
CHANGED
|
@@ -31,12 +31,15 @@ $.formCollect = async ( form ) => {
|
|
|
31
31
|
checked,
|
|
32
32
|
dataset: {
|
|
33
33
|
value,
|
|
34
|
+
name: dataName = '',
|
|
34
35
|
inputType = '',
|
|
35
36
|
validation
|
|
36
37
|
}
|
|
37
38
|
} = Inputs[ index ] as any;
|
|
38
39
|
let Value: any = value;
|
|
39
40
|
|
|
41
|
+
name = name || dataName;
|
|
42
|
+
|
|
40
43
|
validation = Number( ( validation ?? 'true' ) == 'true' );
|
|
41
44
|
|
|
42
45
|
if ( inputType == 'hidden' ) {
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
React,
|
|
3
|
+
} from '@global';
|
|
4
|
+
import {
|
|
5
|
+
BoxWrapper,
|
|
6
|
+
SubmitForm,
|
|
7
|
+
ValidationCheck,
|
|
8
|
+
CommonEffects
|
|
9
|
+
} from './core'
|
|
10
|
+
|
|
11
|
+
import style from './style.module.scss';
|
|
12
|
+
|
|
13
|
+
function DefaultValidation( props: {
|
|
14
|
+
value: any
|
|
15
|
+
params: any
|
|
16
|
+
} ): amotify.fn.Input.Validation.Result {
|
|
17
|
+
let { value,params } = props;
|
|
18
|
+
let { required } = params as amotify.fn.Input.Contenteditable.PlainParams;
|
|
19
|
+
let notice: amotify.fn.Input.Validation.NoticeTypes[] = [];
|
|
20
|
+
|
|
21
|
+
if ( required && !value ) {
|
|
22
|
+
notice.push( { type: 'invalid',label: '必須項目です' } );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
ok: !notice.filter( ( { type } ) => type == 'invalid' ).length,
|
|
27
|
+
notice: notice
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const ContenteditableInput: React.FC<amotify.fn.Input.Contenteditable.PlainParams> = ( params ) => {
|
|
32
|
+
let {
|
|
33
|
+
componentID,
|
|
34
|
+
tone,
|
|
35
|
+
required,
|
|
36
|
+
form,
|
|
37
|
+
|
|
38
|
+
enableFormSubmit,
|
|
39
|
+
|
|
40
|
+
checkValidationAtFirst,
|
|
41
|
+
onInput,onKeyDown,
|
|
42
|
+
onValidate,
|
|
43
|
+
onUpdateValue,
|
|
44
|
+
onUpdateValidValue,
|
|
45
|
+
children = '',
|
|
46
|
+
leftIndicator,rightIndicator,leftIcon,rightIcon,
|
|
47
|
+
|
|
48
|
+
...others
|
|
49
|
+
} = params;
|
|
50
|
+
|
|
51
|
+
let Default_Status: amotify.fn.Input.Status.Plain = {
|
|
52
|
+
componentID: componentID!,
|
|
53
|
+
dataValue: children,
|
|
54
|
+
eventType: 'init',
|
|
55
|
+
eventID: $.uuidGen()
|
|
56
|
+
}
|
|
57
|
+
let [ val_status,set_status ] = React.useState( Default_Status );
|
|
58
|
+
let [ val_validate,set_validate ] = React.useState( {
|
|
59
|
+
ok: false,
|
|
60
|
+
notice: []
|
|
61
|
+
} as amotify.fn.Input.Validation.Result );
|
|
62
|
+
|
|
63
|
+
CommonEffects( {
|
|
64
|
+
params,
|
|
65
|
+
val_status,
|
|
66
|
+
set_status,
|
|
67
|
+
val_validate,
|
|
68
|
+
set_validate,
|
|
69
|
+
onUpdateValue,
|
|
70
|
+
onUpdateValidValue,
|
|
71
|
+
DefaultValidation
|
|
72
|
+
} );
|
|
73
|
+
|
|
74
|
+
return <BoxWrapper
|
|
75
|
+
val_status={ val_status }
|
|
76
|
+
set_status={ set_status }
|
|
77
|
+
val_validate={ val_validate }
|
|
78
|
+
params={ params }
|
|
79
|
+
>
|
|
80
|
+
<div
|
|
81
|
+
contentEditable
|
|
82
|
+
data-form={ form }
|
|
83
|
+
data-name={ params.name }
|
|
84
|
+
data-input-type={ 'contenteditable' }
|
|
85
|
+
data-validation={ val_validate.ok }
|
|
86
|
+
data-value={ val_status.dataValue }
|
|
87
|
+
data-component-id={ val_status.componentID }
|
|
88
|
+
onKeyDown={ ( event ) => {
|
|
89
|
+
!!onKeyDown && onKeyDown( event );
|
|
90
|
+
!!enableFormSubmit && SubmitForm( event );
|
|
91
|
+
} }
|
|
92
|
+
onInput={ ( event ) => {
|
|
93
|
+
let contentEditor = event.currentTarget as HTMLDivElement;
|
|
94
|
+
let {
|
|
95
|
+
innerHTML,
|
|
96
|
+
innerText
|
|
97
|
+
} = contentEditor;
|
|
98
|
+
|
|
99
|
+
if ( val_validate.ok ) set_validate( { ok: false,notice: [] } );
|
|
100
|
+
set_status( {
|
|
101
|
+
...val_status,
|
|
102
|
+
dataValue: innerText,
|
|
103
|
+
eventType: 'update',
|
|
104
|
+
eventID: $.uuidGen(),
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
onInput && onInput( event );
|
|
108
|
+
} }
|
|
109
|
+
{ ...others }
|
|
110
|
+
>
|
|
111
|
+
{ children }
|
|
112
|
+
</div>
|
|
113
|
+
</BoxWrapper>;
|
|
114
|
+
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
TextValidate
|
|
35
35
|
} from './Text';
|
|
36
36
|
import { TextAreaInput } from './TextArea';
|
|
37
|
+
import { ContenteditableInput } from './Contenteditable';
|
|
37
38
|
import { DigitCharactersInput } from './DigitCharacters';
|
|
38
39
|
import {
|
|
39
40
|
TimeInput,
|
|
@@ -408,6 +409,26 @@ export const Input: amotify.fn.Input.Methods = {
|
|
|
408
409
|
params={ params }
|
|
409
410
|
/>;
|
|
410
411
|
},
|
|
412
|
+
Contenteditable: ( rawParams ) => {
|
|
413
|
+
rawParams = { ...rawParams }
|
|
414
|
+
if ( rawParams.rightIcon ) rawParams.paddingRight = rawParams.paddingRight ?? 3;
|
|
415
|
+
if ( rawParams.leftIcon ) rawParams.paddingLeft = rawParams.paddingLeft ?? 3;
|
|
416
|
+
rawParams = {
|
|
417
|
+
...rawParams,
|
|
418
|
+
freeCSS: {
|
|
419
|
+
whiteSpace: 'pre-wrap',
|
|
420
|
+
...rawParams.freeCSS
|
|
421
|
+
},
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
let params = DefaultStyles.Boxish( rawParams );
|
|
425
|
+
params.rows = params.rows || 5;
|
|
426
|
+
return <UniComponent
|
|
427
|
+
componentID={ rawParams.componentID }
|
|
428
|
+
children={ ContenteditableInput }
|
|
429
|
+
params={ params }
|
|
430
|
+
/>;
|
|
431
|
+
},
|
|
411
432
|
DigitCharacters: ( rawParams ) => {
|
|
412
433
|
rawParams = { ...rawParams }
|
|
413
434
|
rawParams = {
|