amotify 0.0.4 → 0.0.5

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.
Files changed (186) hide show
  1. package/package.json +1 -1
  2. package/public/amotify.js +1 -0
  3. package/public/amotify.min.css +24 -0
  4. package/dist/src/@jsminAmotifyExtension/_.d.ts +0 -4
  5. package/dist/src/@jsminAmotifyExtension/fetch.d.ts +0 -9
  6. package/dist/src/@jsminAmotifyExtension/formCollect.d.ts +0 -1
  7. package/dist/src/@jsminAmotifyExtension/spreadSheet.d.ts +0 -4
  8. package/dist/src/@jsminAmotifyExtension/variables.d.ts +0 -0
  9. package/dist/src/@types/_.d.ts +0 -6
  10. package/dist/src/@types/amot.d.ts +0 -260
  11. package/dist/src/@types/fn.d.ts +0 -1040
  12. package/dist/src/@types/index.d.ts +0 -62
  13. package/dist/src/@types/jsminAmotifyExtension.d.ts +0 -134
  14. package/dist/src/@types/module.d.ts +0 -2
  15. package/dist/src/@types/state.d.ts +0 -145
  16. package/dist/src/Atoms/@export.d.ts +0 -4
  17. package/dist/src/Atoms/FAIcon/parts.d.ts +0 -2
  18. package/dist/src/Atoms/Logo/parts.d.ts +0 -1
  19. package/dist/src/Atoms/Various/parts.d.ts +0 -9
  20. package/dist/src/Functions/@export.d.ts +0 -12
  21. package/dist/src/Functions/Button/_.d.ts +0 -1
  22. package/dist/src/Functions/Cropper/parts.d.ts +0 -1
  23. package/dist/src/Functions/Effects/Fade.d.ts +0 -1
  24. package/dist/src/Functions/Effects/Ripple.d.ts +0 -1
  25. package/dist/src/Functions/Effects/_.d.ts +0 -3
  26. package/dist/src/Functions/Input/Chips/Selector.d.ts +0 -1
  27. package/dist/src/Functions/Input/Chips/_.d.ts +0 -2
  28. package/dist/src/Functions/Input/DigitCharacters.d.ts +0 -1
  29. package/dist/src/Functions/Input/File/_.d.ts +0 -2
  30. package/dist/src/Functions/Input/Hidden.d.ts +0 -1
  31. package/dist/src/Functions/Input/List/_.d.ts +0 -1
  32. package/dist/src/Functions/Input/Segmented/_.d.ts +0 -1
  33. package/dist/src/Functions/Input/Select/_.d.ts +0 -1
  34. package/dist/src/Functions/Input/Slider/_.d.ts +0 -1
  35. package/dist/src/Functions/Input/Switch/_.d.ts +0 -1
  36. package/dist/src/Functions/Input/Text.d.ts +0 -5
  37. package/dist/src/Functions/Input/TextArea.d.ts +0 -1
  38. package/dist/src/Functions/Input/Time/Picker.d.ts +0 -1
  39. package/dist/src/Functions/Input/Time/_.d.ts +0 -2
  40. package/dist/src/Functions/Input/_.d.ts +0 -5
  41. package/dist/src/Functions/Input/core.d.ts +0 -34
  42. package/dist/src/Functions/Inputs/_.d.ts +0 -3
  43. package/dist/src/Functions/Inputs/text.d.ts +0 -12
  44. package/dist/src/Functions/Layout/PageNotFound.d.ts +0 -1
  45. package/dist/src/Functions/Layout/PageRouter.d.ts +0 -2
  46. package/dist/src/Functions/Layout/PageViewController/parts.d.ts +0 -1
  47. package/dist/src/Functions/Layout/Plate.d.ts +0 -1
  48. package/dist/src/Functions/Layout/RootViewController/parts.d.ts +0 -1
  49. package/dist/src/Functions/Layout/SwipeView/parts.d.ts +0 -2
  50. package/dist/src/Functions/Layout/TabBar.d.ts +0 -1
  51. package/dist/src/Functions/Layout/_.d.ts +0 -2
  52. package/dist/src/Functions/Loader/corner.d.ts +0 -1
  53. package/dist/src/Functions/Loader/mini.d.ts +0 -33
  54. package/dist/src/Functions/Loader/parts.d.ts +0 -3
  55. package/dist/src/Functions/Loader/top.d.ts +0 -1
  56. package/dist/src/Functions/Sheet/parts.d.ts +0 -2
  57. package/dist/src/Functions/SnackBar/parts.d.ts +0 -2
  58. package/dist/src/Functions/Table/Data/parts.d.ts +0 -3
  59. package/dist/src/Functions/Table/Drag/parts.d.ts +0 -1
  60. package/dist/src/Functions/Table/Normal/parts.d.ts +0 -1
  61. package/dist/src/Functions/Table/_.d.ts +0 -9
  62. package/dist/src/Functions/Tooltips/parts.d.ts +0 -2
  63. package/dist/src/Global/@export.d.ts +0 -12
  64. package/dist/src/Global/LaunchReactApplication.d.ts +0 -1
  65. package/dist/src/Global/styleConverter.d.ts +0 -2
  66. package/dist/src/Molecules/@export.d.ts +0 -21
  67. package/dist/src/Molecules/Accordion/parts.d.ts +0 -2
  68. package/dist/src/Molecules/LinkifyText/parts.d.ts +0 -1
  69. package/dist/src/Molecules/List.d.ts +0 -1
  70. package/dist/src/Organisms/@export.d.ts +0 -2
  71. package/dist/src/Organisms/DisplayStyleInput/_.d.ts +0 -1
  72. package/dist/src/Organisms/DisplayStyleInput/darkmode.d.ts +0 -1
  73. package/dist/src/Organisms/DisplayStyleInput/themeColor.d.ts +0 -27
  74. package/dist/src/Templates/@export.d.ts +0 -2
  75. package/dist/src/Templates/PlayGround/parts.d.ts +0 -1
  76. package/dist/src/config.d.ts +0 -16
  77. package/dist/src/launch.d.ts +0 -9
  78. package/dist/src/preload.d.ts +0 -1
  79. package/src/@jsminAmotifyExtension/_.tsx +0 -4
  80. package/src/@jsminAmotifyExtension/fetch.tsx +0 -107
  81. package/src/@jsminAmotifyExtension/formCollect.tsx +0 -89
  82. package/src/@jsminAmotifyExtension/spreadSheet.tsx +0 -159
  83. package/src/@jsminAmotifyExtension/variables.tsx +0 -130
  84. package/src/@styles/@app.scss +0 -4
  85. package/src/@styles/@variables/customProps.scss +0 -109
  86. package/src/@styles/@variables/styleSet.scss +0 -38
  87. package/src/@styles/@variables/themeColor.scss +0 -71
  88. package/src/@styles/@variables/var.scss +0 -171
  89. package/src/@styles/UniStyling.scss +0 -996
  90. package/src/@styles/init.scss +0 -154
  91. package/src/@types/_.tsx +0 -6
  92. package/src/@types/amot.tsx +0 -323
  93. package/src/@types/fn.tsx +0 -1210
  94. package/src/@types/index.tsx +0 -74
  95. package/src/@types/jsminAmotifyExtension.tsx +0 -143
  96. package/src/@types/module.tsx +0 -2
  97. package/src/@types/state.tsx +0 -199
  98. package/src/Atoms/@export.tsx +0 -32
  99. package/src/Atoms/FAIcon/parts.tsx +0 -117
  100. package/src/Atoms/FAIcon/style.module.scss +0 -9
  101. package/src/Atoms/Logo/parts.tsx +0 -335
  102. package/src/Atoms/Logo/style.module.scss +0 -96
  103. package/src/Atoms/Various/parts.tsx +0 -157
  104. package/src/Atoms/Various/style.module.scss +0 -40
  105. package/src/Functions/@export.tsx +0 -29
  106. package/src/Functions/Button/_.tsx +0 -305
  107. package/src/Functions/Button/style.module.scss +0 -183
  108. package/src/Functions/Cropper/parts.tsx +0 -1061
  109. package/src/Functions/Cropper/style.module.scss +0 -62
  110. package/src/Functions/Effects/Fade.tsx +0 -81
  111. package/src/Functions/Effects/Ripple.tsx +0 -141
  112. package/src/Functions/Effects/_.tsx +0 -33
  113. package/src/Functions/Effects/style.module.scss +0 -83
  114. package/src/Functions/Input/Chips/Selector.tsx +0 -451
  115. package/src/Functions/Input/Chips/_.tsx +0 -286
  116. package/src/Functions/Input/Chips/style.module.scss +0 -6
  117. package/src/Functions/Input/DigitCharacters.tsx +0 -241
  118. package/src/Functions/Input/File/_.tsx +0 -596
  119. package/src/Functions/Input/File/style.module.scss +0 -34
  120. package/src/Functions/Input/Hidden.tsx +0 -18
  121. package/src/Functions/Input/List/_.tsx +0 -383
  122. package/src/Functions/Input/List/style.module.scss +0 -84
  123. package/src/Functions/Input/Segmented/_.tsx +0 -238
  124. package/src/Functions/Input/Segmented/style.module.scss +0 -81
  125. package/src/Functions/Input/Select/_.tsx +0 -225
  126. package/src/Functions/Input/Select/style.module.scss +0 -10
  127. package/src/Functions/Input/Slider/_.tsx +0 -519
  128. package/src/Functions/Input/Slider/style.module.scss +0 -67
  129. package/src/Functions/Input/Switch/_.tsx +0 -177
  130. package/src/Functions/Input/Switch/style.module.scss +0 -18
  131. package/src/Functions/Input/Text.tsx +0 -437
  132. package/src/Functions/Input/TextArea.tsx +0 -115
  133. package/src/Functions/Input/Time/Picker.tsx +0 -950
  134. package/src/Functions/Input/Time/_.tsx +0 -736
  135. package/src/Functions/Input/Time/style.module.scss +0 -72
  136. package/src/Functions/Input/_.tsx +0 -793
  137. package/src/Functions/Input/core.tsx +0 -461
  138. package/src/Functions/Input/style.module.scss +0 -43
  139. package/src/Functions/Inputs/_.tsx +0 -5
  140. package/src/Functions/Inputs/style.module.scss +0 -15
  141. package/src/Functions/Inputs/text.tsx +0 -67
  142. package/src/Functions/Inputs/types.d.ts +0 -1
  143. package/src/Functions/Layout/PageNotFound.tsx +0 -81
  144. package/src/Functions/Layout/PageRouter.tsx +0 -107
  145. package/src/Functions/Layout/PageViewController/parts.tsx +0 -32
  146. package/src/Functions/Layout/Plate.tsx +0 -30
  147. package/src/Functions/Layout/RootViewController/parts.tsx +0 -290
  148. package/src/Functions/Layout/RootViewController/style.module.scss +0 -24
  149. package/src/Functions/Layout/SwipeView/parts.tsx +0 -380
  150. package/src/Functions/Layout/SwipeView/style.module.scss +0 -19
  151. package/src/Functions/Layout/TabBar.tsx +0 -64
  152. package/src/Functions/Layout/_.tsx +0 -20
  153. package/src/Functions/Loader/corner.tsx +0 -78
  154. package/src/Functions/Loader/mini.tsx +0 -117
  155. package/src/Functions/Loader/parts.tsx +0 -105
  156. package/src/Functions/Loader/style.module.scss +0 -222
  157. package/src/Functions/Loader/top.tsx +0 -90
  158. package/src/Functions/Sheet/parts.tsx +0 -972
  159. package/src/Functions/Sheet/style.module.scss +0 -235
  160. package/src/Functions/SnackBar/parts.tsx +0 -215
  161. package/src/Functions/SnackBar/style.module.scss +0 -25
  162. package/src/Functions/Table/Data/parts.tsx +0 -955
  163. package/src/Functions/Table/Drag/parts.tsx +0 -448
  164. package/src/Functions/Table/Normal/parts.tsx +0 -123
  165. package/src/Functions/Table/_.tsx +0 -170
  166. package/src/Functions/Table/style.module.scss +0 -92
  167. package/src/Functions/Tooltips/parts.tsx +0 -52
  168. package/src/Global/@export.tsx +0 -138
  169. package/src/Global/LaunchReactApplication.tsx +0 -30
  170. package/src/Global/exe.tsx +0 -0
  171. package/src/Global/styleConverter.tsx +0 -435
  172. package/src/Molecules/@export.tsx +0 -95
  173. package/src/Molecules/Accordion/parts.tsx +0 -146
  174. package/src/Molecules/Accordion/style.module.scss +0 -13
  175. package/src/Molecules/LinkifyText/parts.tsx +0 -54
  176. package/src/Molecules/List.tsx +0 -30
  177. package/src/Organisms/@export.tsx +0 -5
  178. package/src/Organisms/DisplayStyleInput/_.tsx +0 -18
  179. package/src/Organisms/DisplayStyleInput/darkmode.tsx +0 -112
  180. package/src/Organisms/DisplayStyleInput/themeColor.tsx +0 -210
  181. package/src/Templates/@export.tsx +0 -7
  182. package/src/Templates/PlayGround/parts.tsx +0 -115
  183. package/src/Templates/PlayGround/style.module.scss +0 -38
  184. package/src/config.tsx +0 -132
  185. package/src/launch.tsx +0 -100
  186. package/src/preload.tsx +0 -49
@@ -1,177 +0,0 @@
1
- import {
2
- React
3
- } from '@global';
4
- import {
5
- Box,
6
- FAIcon
7
- } from '@atoms';
8
- import {
9
- Row
10
- } from '@mols';
11
- import {
12
- Buttons
13
- } from '@functions';
14
- import {
15
- BoxWrapper,
16
- SubmitForm,
17
- ValidationCheck,
18
- CommonEffects
19
- } from '../core';
20
- import style from './style.module.scss';
21
-
22
- const {
23
- useState
24
- } = React;
25
-
26
- function DefaultValidation( props: {
27
- value: any
28
- params: any
29
- } ): amotify.fn.Input.Validation.Result {
30
- let { value,params } = props;
31
- let { required } = params as amotify.fn.Input.TextArea.PlainParams;
32
- let notice: amotify.fn.Input.Validation.NoticeTypes[] = [];
33
-
34
- if ( required && !value ) {
35
- notice.push( { type: 'invalid',label: 'ONになっていません' } );
36
- }
37
-
38
- return {
39
- ok: !notice.filter( ( { type } ) => type == 'invalid' ).length,
40
- notice: notice
41
- }
42
- }
43
-
44
- export const SwitchInput: FNC<amotify.fn.Input.Switch.PlainParams> = ( params ) => {
45
- let {
46
- componentID,
47
- color = 'posi',
48
- required,
49
- form,
50
- id,
51
-
52
- enableFormSubmit,
53
-
54
- checkValidationAtFirst,
55
- onChange,onKeyDown,
56
- onValidate,
57
- onUpdateValue,onUpdateValidValue,
58
- value = '',
59
- icon = '',
60
- appearance = 'material',
61
-
62
- ...others
63
- } = params;
64
-
65
- let Default_Status: amotify.fn.Input.Status.Plain = {
66
- componentID: params.componentID || '',
67
- dataValue: value,
68
- eventType: 'init',
69
- eventID: $.uuidGen()
70
- }
71
- let [ val_status,set_status ] = useState( Default_Status );
72
- let [ val_validate,set_validate ] = useState( {
73
- ok: false,
74
- notice: []
75
- } as amotify.fn.Input.Validation.Result );
76
- let isChecked = !!val_status.dataValue;
77
-
78
- CommonEffects( {
79
- params,
80
- val_status,
81
- set_status,
82
- val_validate,
83
- set_validate,
84
- DefaultValidation,
85
- onUpdateValue,onUpdateValidValue,
86
- ExtraOverrideParams: {
87
- dataValue: value,
88
- formatValue: value
89
- },
90
- } );
91
-
92
- return ( <BoxWrapper
93
- val_status={ val_status }
94
- set_status={ set_status }
95
- val_validate={ val_validate }
96
- params={ params }
97
- >
98
- <input
99
- type='checkbox'
100
- data-form={ form }
101
- data-input-type={ 'switch' }
102
- data-validation={ val_validate.ok }
103
- data-component-id={ val_status.componentID }
104
- data-value={ val_status.dataValue }
105
- checked={ val_status.dataValue }
106
- className={ style.Input }
107
- id={ id }
108
- onKeyDown={ ( event ) => {
109
- if ( onKeyDown ) onKeyDown( event );
110
- if ( enableFormSubmit ) SubmitForm( event );
111
- } }
112
- onChange={ ( event ) => {
113
- if ( val_validate.ok ) set_validate( { ok: false,notice: [] } );
114
- set_status( {
115
- ...val_status,
116
- dataValue: event.target.checked,
117
- eventType: 'update',
118
- eventID: $.uuidGen(),
119
- } );
120
-
121
- if ( onChange ) onChange( event );
122
- } }
123
- { ...others }
124
- />
125
- <Buttons.Label.Plain
126
- tabIndex={ -1 }
127
- htmlFor={ id }
128
- padding={ '1/3' }
129
- transition='middle'
130
- borderRadius={ '1.tone.primary' }
131
- className={ style.Label }
132
- >
133
- <Box
134
- { ...appearance == 'applely' ? {
135
- padding: '1/4',
136
- isRounded: true,
137
- backgroundColor: isChecked ? color : '5.layer.darker'
138
- } : {} }
139
- >
140
- <Row.Center
141
- unitHeight={ 2.5 }
142
- position='relative'
143
- freeCSS={ {
144
- width: 12 * 4.5
145
- } }
146
- >
147
- { appearance == 'material' ? <Box
148
- position='absolute'
149
- backgroundColor={ isChecked ? color : '5.layer.darker' }
150
- borderRadius={ 'sphere' }
151
- unitHeight={ 1 }
152
- transition='middle'
153
- width={ 1 }
154
- className={ style.Bar }
155
- opacity='middle'
156
- /> : null }
157
- <Box
158
- position='absolute'
159
- top={ 0 }
160
- left={ 0 }
161
- backgroundColor={ appearance == 'material' && isChecked ? color : 'white' }
162
- transition='middle'
163
- ssSphere={ 2.5 }
164
- boxShadow={ 2 }
165
- className={ style.Dot }
166
- >
167
- { icon ? <FAIcon
168
- transition='middle'
169
- fontColor={ appearance == 'applely' && isChecked ? color : 'white' }
170
- d={ icon }
171
- /> : null }
172
- </Box>
173
- </Row.Center>
174
- </Box>
175
- </Buttons.Label.Plain>
176
- </BoxWrapper> );
177
- }
@@ -1,18 +0,0 @@
1
- @use '@uniVar' as *;
2
- .Input {
3
- position: absolute;
4
- height: 0;
5
- width: 0;
6
- overflow: hidden;
7
- &:checked + .Label {
8
- .Dot {
9
- left: calc(100% - $unit2-5 ) !important;
10
- }
11
- }
12
- &:focus + .Label {
13
- box-shadow: 0 0 0 $unit1_3 $color-layer3;
14
- }
15
- &[disabled] + .Label {
16
- opacity: .4;
17
- }
18
- }
@@ -1,437 +0,0 @@
1
- import {
2
- React,
3
- } from '@global';
4
- const {
5
- useEffect,
6
- useState,
7
- } = React;
8
-
9
- import {
10
- Box,
11
- } from '@atoms';
12
-
13
- import {
14
- BoxWrapper,
15
- SubmitForm,
16
- CommonEffects
17
- } from './core';
18
-
19
- import style from './style.module.scss';
20
-
21
- const ValidateTypes: {
22
- [ key: string ]: {
23
- reg: RegExp
24
- exist: boolean
25
- reason: ReactElement
26
- }
27
- } = {
28
- number: {
29
- reg: /^-?[0-9\.]+$/g,exist: true,
30
- reason: '半角数字で入力してください'
31
- },
32
- digitNumber: {
33
- reg: /^-?[0-9\.]+$/g,exist: true,
34
- reason: '半角数字で入力してください'
35
- },
36
- fileName: {
37
- reg: /[¥\/;:*\?\"\'\|\.\s\n\r\<\>]/g,exist: false,
38
- reason: '空白または一部の特殊文字は使用できません'
39
- },
40
- creditCard: {
41
- reg: /^\d{16}$/g,exist: true,
42
- reason: '16桁の数字で入力してください'
43
- },
44
- email: {
45
- reg: /^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]+\.[A-Za-z0-9]+$/,exist: true,
46
- reason: <>
47
- <Box>○○○○@○○○○.○○○の形式で入力してください</Box>
48
- <Box>最後の文字に.(ドット)を入れることはできません</Box>
49
- </>,
50
- },
51
- password: {
52
- reg: /^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=[^0-9]*[0-9]).{8,}$/,exist: true,
53
- reason: '8文字以上、半角英数大小文字で入力してください'
54
- },
55
- tel: {
56
- reg: /^(0|\(?\+\d{1,3}\)?\s)[-0-9]{9,12}$/g,exist: true,
57
- reason: <>
58
- <Box>0から始まる番号のみ入力可能です</Box>
59
- <Box>9~12桁の数字で入力してください</Box>
60
- <Box>数字のみ入力可能です</Box>
61
- </>
62
- },
63
- url: {
64
- reg: /^https?:\/\/[^\n\s]+(\.|\:)[^\n\s\.\:]+$/,exist: true,
65
- reason: 'URL形式 : http(s)://◯◯◯◯'
66
- },
67
- postal: {
68
- reg: /^\d{7}$/g,exist: true,
69
- reason: '7桁の数字で入力してください'
70
- }
71
- }
72
-
73
- const DataLeveling = ( params: {
74
- min?: number | null
75
- max?: number | null
76
- restrict: amotify.fn.Input.Text.RestrictTypes,
77
- value: any
78
- } ) => {
79
- let {
80
- restrict,
81
- value = ''
82
- } = params;
83
-
84
- let dataValue = String( value );
85
- let minus = false;
86
- if ( [ 'tel','number','digitNumber','test','postal','creditCard' ].includes( restrict ) ) {
87
- dataValue = dataValue.zen2hanNumber();
88
- }
89
- if ( [ 'postal','creditCard' ].includes( restrict ) ) {
90
- dataValue = dataValue.removeLetters();
91
- }
92
- if ( [ 'number','digitNumber' ].includes( restrict ) ) {
93
- if ( dataValue ) {
94
- if ( dataValue == '-' ) {
95
-
96
- } else if ( dataValue == '0-' ) {
97
- dataValue = '-';
98
- } else {
99
- if ( dataValue[ 0 ] == '-' ) minus = true;
100
- dataValue = dataValue.replace( /[^0-9\.]/ig,'' );
101
-
102
- let Amount = Number( dataValue );
103
- if ( Amount === 0 ) minus = false;
104
- if ( minus ) Amount = -1 * Amount;
105
-
106
- if ( $.is.exist( params.min ) ) {
107
- Amount = Math.max( Amount,Number( params.min ) );
108
- }
109
- if ( $.is.exist( params.max ) ) {
110
- Amount = Math.min( Amount,Number( params.max ) );
111
- }
112
- dataValue = String( Math.abs( Amount ) );
113
- }
114
- }
115
- }
116
-
117
- let formatValue = dataValue;
118
- if ( restrict == 'digitNumber' ) {
119
- if ( dataValue && dataValue != '-' ) {
120
- let arrary = [];
121
- for ( let index = dataValue.length - 1; index >= 0; index-- ) {
122
- arrary.unshift( dataValue[ index ] );
123
- let Index = ( dataValue.length - 1 ) - index + 1;
124
- if (
125
- index != 0 && Index % 3 == 0 ) {
126
- arrary.unshift( ',' );
127
- }
128
- }
129
- formatValue = arrary.join( '' );
130
- }
131
- } else if ( restrict == 'postal' ) {
132
- if ( dataValue.length >= 4 ) {
133
- formatValue = dataValue.clip( 0,3 ) + '-' + dataValue.clip( 3 );
134
- }
135
- } else if ( restrict == 'creditCard' ) {
136
- formatValue = dataValue.replace( /.{4}(?=.)/g,"$& " );
137
- }
138
-
139
- if ( [ 'number','digitNumber' ].includes( restrict ) ) {
140
- if ( minus ) {
141
- dataValue = '-' + dataValue;
142
- formatValue = '-' + formatValue;
143
- }
144
- }
145
-
146
- return {
147
- formatValue,
148
- dataValue
149
- };
150
- }
151
-
152
- const setSelection: {
153
- ( props: {
154
- id?: string,
155
- restrict: amotify.fn.Input.Text.RestrictTypes
156
- val_status: any
157
- } ): void
158
- } = ( props ) => {
159
- let {
160
- id,
161
- restrict,
162
- val_status
163
- } = props;
164
-
165
- let input = $( '#' + id )[ 0 ] as HTMLInputElement;
166
- if ( input ) {
167
- if ( val_status.prevValue && val_status.formatValue ) {
168
- let {
169
- formatValue: currentValue,
170
- prevValue,
171
- caretFrom,caretTo
172
- } = val_status;
173
-
174
- if ( restrict == 'creditCard' ) {
175
- if ( currentValue.length >= prevValue.length ) {
176
- if ( caretFrom % 5 == 0 ) {
177
- caretFrom++; caretTo++;
178
- }
179
- }
180
- input.setSelectionRange( caretFrom,caretTo );
181
- } else if ( restrict == 'postal' ) {
182
- if ( currentValue.length == 5 && prevValue.length == 3 ) {
183
- caretFrom++; caretTo++;
184
- }
185
- input.setSelectionRange( caretFrom,caretTo );
186
- } else if ( restrict == 'digitNumber' ) {
187
- let margin = currentValue.length - prevValue.length;
188
-
189
- if ( margin == 2 ) {
190
- caretFrom++; caretTo++;
191
- }
192
- if ( margin == -2 ) {
193
- caretFrom--; caretTo--;
194
- }
195
- input.setSelectionRange( caretFrom,caretTo );
196
- }
197
- }
198
- }
199
- }
200
- export const TextValidate = ( value: any,restrict: amotify.fn.Input.Text.RestrictTypes ) => {
201
- let response = {
202
- ok: true,
203
- body: '' as any
204
- };
205
- ( () => {
206
- let kit = ValidateTypes[ restrict ];
207
- if ( !kit ) return;
208
-
209
- let reason = kit.reason;
210
- if ( kit ) {
211
- let valid = Boolean( Number( !!value.match( kit.reg ) ) ^ Number( !kit.exist ) );
212
- response = {
213
- ok: valid,
214
- body: valid ? '' : reason
215
- }
216
- }
217
- } )();
218
- return response;
219
- }
220
-
221
- function DefaultValidation( props: {
222
- value: any
223
- params: any
224
- } ): amotify.fn.Input.Validation.Result {
225
- let {
226
- value,
227
- params
228
- } = props;
229
- let {
230
- restrict = 'text',
231
- maxLength = 255,
232
- required
233
- } = params as amotify.fn.Input.Text.OriginParams
234
- let notice: amotify.fn.Input.Validation.NoticeTypes[] = [];
235
-
236
- if ( $.is.exist( maxLength ) ) {
237
- if ( value.length >= Number( maxLength ) ) {
238
- notice.push( { type: 'invalid',label: maxLength + '字以内で入力してください' } );
239
- }
240
- }
241
- if ( value ) {
242
- let Valid = TextValidate( value,restrict );
243
- if ( !Valid.ok ) notice.push( { type: 'invalid',label: Valid.body } );
244
- } else if ( required ) {
245
- notice.push( { type: 'invalid',label: '必須項目です' } );
246
- }
247
-
248
- return {
249
- ok: !notice.filter( ( { type } ) => type == 'invalid' ).length,
250
- notice: notice
251
- }
252
- }
253
-
254
- export const TextInput: FNC<amotify.fn.Input.Text.OriginParams> = ( params ) => {
255
- let {
256
- componentID,
257
- tone,
258
- required,
259
- restrict = 'text',
260
- form,
261
- autoComplete = 'off',
262
- autoCapitalize = 'off',
263
-
264
- enableFormSubmit,
265
- clearButton = false,
266
-
267
- checkValidationAtFirst,
268
- onChange,onKeyDown,
269
- onValidate,
270
- onUpdateValue,
271
- onUpdateValidValue,
272
- value = '',
273
- leftIndicator,rightIndicator,rightIcon,
274
- maxLength,
275
- min,
276
- max,
277
-
278
- ...others
279
- } = params;
280
-
281
- let inputType = restrict == 'password' ? 'password' : 'text';
282
- let inputMode: 'numeric' | 'text' | 'email' = [ 'number','digitNumber','tel','creditCard' ].includes( restrict ) ? 'numeric' : restrict == 'email' ? 'email' : 'text';
283
-
284
- let Default_Status: amotify.fn.Input.Status.Text = {
285
- componentID: componentID!,
286
- ...DataLeveling( {
287
- min,max,
288
- restrict,
289
- value
290
- } ),
291
- prevValue: '',
292
- eventType: 'init',
293
- eventID: $.uuidGen(),
294
- caretFrom: null as any,
295
- caretTo: null as any
296
- }
297
- let [ val_status,set_status ] = useState( Default_Status );
298
- let [ val_validate,set_validate ] = useState( {
299
- ok: false,
300
- notice: []
301
- } as amotify.fn.Input.Validation.Result );
302
-
303
- CommonEffects( {
304
- params,
305
- val_status,
306
- set_status,
307
- val_validate,
308
- set_validate,
309
- DefaultValidation,
310
- onUpdateValue,
311
- onUpdateValidValue,
312
- ExtraOverrideParams: {
313
- ...DataLeveling( {
314
- min,max,
315
- restrict,
316
- value
317
- } )
318
- }
319
- } );
320
-
321
- useEffect( () => {
322
- setSelection( { id: params.id,restrict,val_status } );
323
- },[ val_status ] );
324
-
325
- return (
326
- <BoxWrapper
327
- val_status={ val_status }
328
- set_status={ set_status }
329
- val_validate={ val_validate }
330
- params={ params }
331
- >
332
- <input
333
- type={ inputType }
334
- inputMode={ inputMode }
335
- data-form={ form }
336
- data-input-type={ 'text' }
337
- data-validation={ val_validate.ok }
338
- data-value={ val_status.dataValue }
339
- data-component-id={ val_status.componentID }
340
- value={ val_status.formatValue }
341
- autoComplete={ autoComplete }
342
- autoCapitalize={ autoCapitalize }
343
- onKeyDown={ ( event ) => {
344
- let { key,target } = event;
345
- {
346
- let input = target as HTMLInputElement;
347
- let { selectionStart,selectionEnd } = input;
348
- let caretFrom = Number( selectionStart );
349
- let caretTo = Number( selectionEnd )
350
-
351
- let _v = val_status.formatValue[ Number( caretFrom ) ];
352
- let v_ = val_status.formatValue[ Number( caretFrom ) - 1 ];
353
- if ( key == 'Delete' && (
354
- ( restrict == 'creditCard' && _v == ' ' ) ||
355
- ( restrict == 'postal' && _v == '-' ) ||
356
- ( restrict == 'digitNumber' && _v == ',' )
357
- ) ) {
358
- input.setSelectionRange( caretFrom + 1,caretTo + 1 );
359
- event.preventDefault();
360
- }
361
- if ( key == 'Backspace' && (
362
- ( restrict == 'creditCard' && v_ == ' ' ) ||
363
- ( restrict == 'postal' && v_ == '-' ) ||
364
- ( restrict == 'digitNumber' && v_ == ',' )
365
- ) ) {
366
- input.setSelectionRange( caretFrom - 1,caretTo - 1 );
367
- event.preventDefault();
368
- }
369
- }
370
-
371
- if ( [ 'number','digitNumber','creditCard' ].includes( restrict ) ) {
372
- if ( key == 'Clear' ) {
373
- set_status( {
374
- ...val_status,
375
- dataValue: '',
376
- formatValue: '',
377
- eventType: 'update',
378
- eventID: $.uuidGen(),
379
- } )
380
- }
381
- }
382
- if ( [ 'number','digitNumber' ].includes( restrict ) ) {
383
- if ( [ 'ArrowUp','ArrowDown' ].includes( key ) ) {
384
- let direction = Number( key == 'ArrowUp' ) * 2 - 1;
385
- let Value = String( Number( val_status.dataValue ) + direction );
386
- if ( val_validate.ok ) {
387
- set_validate( { ok: false,notice: [] } );
388
- }
389
- set_status( {
390
- ...val_status,
391
- ...DataLeveling( {
392
- min,max,
393
- restrict,
394
- value: Value
395
- } ),
396
- eventType: 'update',
397
- eventID: $.uuidGen(),
398
- } );
399
- event.preventDefault();
400
- }
401
- }
402
-
403
- if ( onKeyDown ) onKeyDown( event );
404
- if ( enableFormSubmit ) SubmitForm( event );
405
- } }
406
- onChange={ ( event ) => {
407
- let {
408
- value: rawValue,
409
- selectionStart,
410
- selectionEnd
411
- } = event.target;
412
-
413
- let value = DataLeveling( {
414
- min,max,
415
- restrict,
416
- value: rawValue
417
- } );
418
- if ( value.formatValue == val_status.formatValue ) return;
419
-
420
- if ( val_validate.ok ) set_validate( { ok: false,notice: [] } );
421
- set_status( {
422
- ...val_status,
423
- ...value,
424
- prevValue: val_status.formatValue,
425
- eventType: 'update',
426
- eventID: $.uuidGen(),
427
- caretFrom: Number( selectionStart ),
428
- caretTo: Number( selectionEnd )
429
- } );
430
-
431
- if ( onChange ) onChange( event );
432
- } }
433
- { ...others }
434
- />
435
- </BoxWrapper>
436
- );
437
- }