amotify 0.0.56 → 0.0.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "description": "UI Component for React",
5
5
  "main": "dist/launch.js",
6
6
  "types": "dist/@types.d.ts",
@@ -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,19 @@ 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
+
417
+ let params = DefaultStyles.Boxish( rawParams );
418
+ params.rows = params.rows || 5;
419
+ return <UniComponent
420
+ componentID={ rawParams.componentID }
421
+ children={ ContenteditableInput }
422
+ params={ params }
423
+ />;
424
+ },
411
425
  DigitCharacters: ( rawParams ) => {
412
426
  rawParams = { ...rawParams }
413
427
  rawParams = {
@@ -51,6 +51,7 @@
51
51
  }
52
52
  }
53
53
  .Input {
54
+ outline: none !important;
54
55
  &:focus, &:active {
55
56
  z-index: 1;
56
57
  background-color: $color-layer1;