amotify 0.0.64 → 0.0.66
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/amotify.js +3 -2
- package/dist/amotify.min.css +2 -2
- package/dist/coreVender.js +14 -2
- package/package.json +10 -10
- package/tsconfig.json +13 -5
- package/@types/_.tsx +0 -7
- package/@types/amot.tsx +0 -357
- package/@types/fn.tsx +0 -1280
- package/@types/jsminAmotifyExtension.tsx +0 -137
- package/@types/module.tsx +0 -1
- package/@types/state.tsx +0 -231
- package/src/@atoms.tsx +0 -34
- package/src/@functions.tsx +0 -29
- package/src/@global.tsx +0 -149
- package/src/@jsminAmotifyExtension/_.tsx +0 -4
- package/src/@jsminAmotifyExtension/fetch.tsx +0 -110
- package/src/@jsminAmotifyExtension/formCollect.tsx +0 -94
- package/src/@jsminAmotifyExtension/spreadSheet.tsx +0 -165
- package/src/@jsminAmotifyExtension/variables.tsx +0 -137
- package/src/@molecules.tsx +0 -96
- package/src/@organisms.tsx +0 -1
- package/src/@reactPacks/reactProduction@18.2.0.js +0 -79
- package/src/@reactPacks/reactRouterDomProduction@18.2.0.js +0 -31
- package/src/@styles/@app.scss +0 -4
- package/src/@styles/UniStyling.scss +0 -1028
- package/src/@styles/init.scss +0 -94
- package/src/@styles/props.scss +0 -109
- package/src/@styles/styleSet.scss +0 -38
- package/src/@styles/themeColor.scss +0 -71
- package/src/@styles/var.scss +0 -182
- package/src/@templates.tsx +0 -7
- package/src/@variables.tsx +0 -74
- package/src/atoms/FAI/parts.tsx +0 -139
- package/src/atoms/Logo/parts.tsx +0 -335
- package/src/atoms/Logo/style.module.scss +0 -96
- package/src/atoms/Various/parts.tsx +0 -159
- package/src/atoms/Various/style.module.scss +0 -46
- package/src/config.tsx +0 -191
- package/src/functions/Button/_.tsx +0 -331
- package/src/functions/Button/style.module.scss +0 -157
- package/src/functions/Cropper/parts.tsx +0 -1084
- package/src/functions/Cropper/style.module.scss +0 -64
- package/src/functions/Effects/Fade.tsx +0 -76
- package/src/functions/Effects/Ripple.tsx +0 -141
- package/src/functions/Effects/_.tsx +0 -33
- package/src/functions/Effects/style.module.scss +0 -91
- package/src/functions/Input/Chips/Selector.tsx +0 -445
- package/src/functions/Input/Chips/_.tsx +0 -289
- package/src/functions/Input/Chips/style.module.scss +0 -6
- package/src/functions/Input/Contenteditable.tsx +0 -114
- package/src/functions/Input/DigitCharacters.tsx +0 -235
- package/src/functions/Input/File/_.tsx +0 -553
- package/src/functions/Input/File/style.module.scss +0 -34
- package/src/functions/Input/Hidden.tsx +0 -21
- package/src/functions/Input/List/_.tsx +0 -383
- package/src/functions/Input/List/style.module.scss +0 -84
- package/src/functions/Input/RichSelect/_.tsx +0 -230
- package/src/functions/Input/RichSelect/style.module.scss +0 -11
- package/src/functions/Input/Segmented/_.tsx +0 -246
- package/src/functions/Input/Segmented/style.module.scss +0 -81
- package/src/functions/Input/Select/_.tsx +0 -218
- package/src/functions/Input/Select/style.module.scss +0 -11
- package/src/functions/Input/Slider/_.tsx +0 -524
- package/src/functions/Input/Slider/style.module.scss +0 -67
- package/src/functions/Input/Switch/_.tsx +0 -176
- package/src/functions/Input/Switch/style.module.scss +0 -18
- package/src/functions/Input/Text.tsx +0 -487
- package/src/functions/Input/TextArea.tsx +0 -109
- package/src/functions/Input/Time/Picker.tsx +0 -1361
- package/src/functions/Input/Time/_.tsx +0 -749
- package/src/functions/Input/Time/style.module.scss +0 -79
- package/src/functions/Input/_.tsx +0 -881
- package/src/functions/Input/core.tsx +0 -473
- package/src/functions/Input/style.module.scss +0 -102
- package/src/functions/Inputs/_.tsx +0 -5
- package/src/functions/Inputs/style.module.scss +0 -15
- package/src/functions/Inputs/text.tsx +0 -53
- package/src/functions/Inputs/types.d.ts +0 -13
- package/src/functions/Layout/PageNotFound.tsx +0 -78
- package/src/functions/Layout/PageRouter.tsx +0 -89
- package/src/functions/Layout/PageViewController/parts.tsx +0 -27
- package/src/functions/Layout/Plate.tsx +0 -30
- package/src/functions/Layout/RootViewController/parts.tsx +0 -300
- package/src/functions/Layout/RootViewController/style.module.scss +0 -23
- package/src/functions/Layout/SwipeView/parts.tsx +0 -375
- package/src/functions/Layout/SwipeView/style.module.scss +0 -20
- package/src/functions/Layout/TabBar.tsx +0 -60
- package/src/functions/Layout/_.tsx +0 -20
- package/src/functions/Loader/corner.tsx +0 -74
- package/src/functions/Loader/mini.tsx +0 -114
- package/src/functions/Loader/parts.tsx +0 -103
- package/src/functions/Loader/style.module.scss +0 -223
- package/src/functions/Loader/top.tsx +0 -84
- package/src/functions/Sheet/parts.tsx +0 -994
- package/src/functions/Sheet/style.module.scss +0 -208
- package/src/functions/SnackBar/parts.tsx +0 -215
- package/src/functions/SnackBar/style.module.scss +0 -25
- package/src/functions/Table/Data/parts.tsx +0 -965
- package/src/functions/Table/Drag/parts.tsx +0 -442
- package/src/functions/Table/Normal/parts.tsx +0 -124
- package/src/functions/Table/_.tsx +0 -177
- package/src/functions/Table/style.module.scss +0 -93
- package/src/functions/Tooltips/parts.tsx +0 -53
- package/src/global/LaunchReactApplication.tsx +0 -74
- package/src/global/styleConverter.tsx +0 -465
- package/src/launch.tsx +0 -119
- package/src/molecules/Accordion/parts.tsx +0 -146
- package/src/molecules/Accordion/style.module.scss +0 -13
- package/src/molecules/LinkifyText/parts.tsx +0 -52
- package/src/molecules/List.tsx +0 -31
- package/src/preload.tsx +0 -31
- package/src/templates/PlayGround/parts.tsx +0 -96
- package/src/templates/PlayGround/style.module.scss +0 -38
- package/webpack.config.js +0 -146
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
React
|
|
3
|
-
} from '@global'
|
|
4
|
-
import {
|
|
5
|
-
FAI
|
|
6
|
-
} from '@atoms'
|
|
7
|
-
import {
|
|
8
|
-
Column,
|
|
9
|
-
Row,
|
|
10
|
-
Text
|
|
11
|
-
} from '@mols'
|
|
12
|
-
import {
|
|
13
|
-
Input,
|
|
14
|
-
Buttons,
|
|
15
|
-
Loader,
|
|
16
|
-
Sheet
|
|
17
|
-
} from '@fn'
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
BoxWrapper,
|
|
21
|
-
SubmitForm,
|
|
22
|
-
ValidationCheck,
|
|
23
|
-
CommonEffects
|
|
24
|
-
} from '../core'
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
ChipsInputFNs
|
|
28
|
-
} from './Selector'
|
|
29
|
-
|
|
30
|
-
import coreStyle from '../style.module.scss'
|
|
31
|
-
|
|
32
|
-
function DefaultValidation( props: {
|
|
33
|
-
value: any
|
|
34
|
-
params: any
|
|
35
|
-
} ): amotify.fn.Input.Validation.Result {
|
|
36
|
-
let {
|
|
37
|
-
value,
|
|
38
|
-
params
|
|
39
|
-
} = props
|
|
40
|
-
let {
|
|
41
|
-
required
|
|
42
|
-
} = params as amotify.fn.Input.Chips.PlainParams
|
|
43
|
-
let notice: amotify.fn.Input.Validation.NoticeTypes[] = []
|
|
44
|
-
|
|
45
|
-
if ( required && !value.length ) {
|
|
46
|
-
notice.push( { type: 'invalid',label: '一つ以上選択してください' } )
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
ok: !notice.filter( ( { type } ) => type == 'invalid' ).length,
|
|
51
|
-
notice: notice
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const DataWrapping: React.FC<amotify.fn.Input.Chips.PlainParams> = ( params ) => {
|
|
56
|
-
let DefaultValues = [ ...( params.value || [] ) ]
|
|
57
|
-
let Values = DefaultValues.splice( 0,params.limit || 65535 )
|
|
58
|
-
|
|
59
|
-
return <Core
|
|
60
|
-
SelectedCellComponent={ ( params ) => {
|
|
61
|
-
let {
|
|
62
|
-
value,
|
|
63
|
-
label,
|
|
64
|
-
removeCallback
|
|
65
|
-
} = params
|
|
66
|
-
|
|
67
|
-
return <Row.Left
|
|
68
|
-
ssCardBox
|
|
69
|
-
padding={ '1/2' }
|
|
70
|
-
gap={ '1/2' }
|
|
71
|
-
isRounded
|
|
72
|
-
textAlign='left'
|
|
73
|
-
>
|
|
74
|
-
{ label }
|
|
75
|
-
{ params.defaultRemoveButton }
|
|
76
|
-
</Row.Left>
|
|
77
|
-
} }
|
|
78
|
-
AddButtonComponent={ ( props ) => {
|
|
79
|
-
if ( params.limit && params.limit <= props.selected.length ) return null
|
|
80
|
-
|
|
81
|
-
return <Buttons.Button.Sub.R
|
|
82
|
-
color='cloud'
|
|
83
|
-
padding={ '1/2' }
|
|
84
|
-
onClick={ () => {
|
|
85
|
-
props.openCallback()
|
|
86
|
-
} }
|
|
87
|
-
>
|
|
88
|
-
<FAI.Plus />
|
|
89
|
-
追加する
|
|
90
|
-
</Buttons.Button.Sub.R>
|
|
91
|
-
} }
|
|
92
|
-
{ ...params }
|
|
93
|
-
value={ Values }
|
|
94
|
-
/>
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const Core: React.FC<amotify.fn.Input.Chips.PlainParams> = ( params ) => {
|
|
98
|
-
let {
|
|
99
|
-
required,
|
|
100
|
-
form,
|
|
101
|
-
name,
|
|
102
|
-
|
|
103
|
-
checkValidationAtFirst,
|
|
104
|
-
onValidate,
|
|
105
|
-
onUpdateValue,onUpdateValidValue,
|
|
106
|
-
value = [],
|
|
107
|
-
limit,
|
|
108
|
-
|
|
109
|
-
leftIndicator,rightIndicator,leftIcon,rightIcon,
|
|
110
|
-
|
|
111
|
-
SelectedCellComponent,
|
|
112
|
-
AddButtonComponent,
|
|
113
|
-
|
|
114
|
-
componentID,
|
|
115
|
-
defaultOptions,
|
|
116
|
-
enableFormSubmit,
|
|
117
|
-
|
|
118
|
-
...others
|
|
119
|
-
} = params
|
|
120
|
-
AddButtonComponent = AddButtonComponent!
|
|
121
|
-
|
|
122
|
-
let [ val_selectorID ] = React.useState( $.uuidGen() )
|
|
123
|
-
let [ val_status,set_status ] = React.useState( {
|
|
124
|
-
componentID: params.componentID || '',
|
|
125
|
-
dataValue: value.map( ( val: any ) => val ),
|
|
126
|
-
eventID: $.uuidGen(),
|
|
127
|
-
eventType: 'init'
|
|
128
|
-
} as amotify.fn.Input.Status.Plain )
|
|
129
|
-
let [ val_validate,set_validate ] = React.useState( {
|
|
130
|
-
ok: false,
|
|
131
|
-
notice: []
|
|
132
|
-
} as amotify.fn.Input.Validation.Result )
|
|
133
|
-
|
|
134
|
-
let [ val_selected,set_selected ] = React.useState( [ ...value ] )
|
|
135
|
-
|
|
136
|
-
CommonEffects( {
|
|
137
|
-
params,
|
|
138
|
-
val_status,set_status,
|
|
139
|
-
val_validate,set_validate,
|
|
140
|
-
DefaultValidation,
|
|
141
|
-
onUpdateValue,onUpdateValidValue,
|
|
142
|
-
ExtraOverrideParams: {
|
|
143
|
-
formatValue: val_selected,
|
|
144
|
-
dataValue: val_selected.map( ( val: any ) => val )
|
|
145
|
-
},
|
|
146
|
-
ExtraStoreParams: {
|
|
147
|
-
searchTimer: null
|
|
148
|
-
}
|
|
149
|
-
} )
|
|
150
|
-
|
|
151
|
-
const UpdateValue = ( values: amotify.fn.Input.Chips.OptionParams[] ) => {
|
|
152
|
-
set_selected( values )
|
|
153
|
-
set_status( {
|
|
154
|
-
...val_status,
|
|
155
|
-
dataValue: values.map( ( val: any ) => val ),
|
|
156
|
-
eventID: $.uuidGen(),
|
|
157
|
-
eventType: 'update'
|
|
158
|
-
} as amotify.fn.Input.Status.Plain )
|
|
159
|
-
}
|
|
160
|
-
const OpenSelector = () => {
|
|
161
|
-
ChipsInputFNs.openSelector( {
|
|
162
|
-
parent: DefaultParentQuerySelector,
|
|
163
|
-
gravityPoint: params.selectorGravityPoint,
|
|
164
|
-
SelectorCellComponent: params.SelectorCellComponent,
|
|
165
|
-
selectorID: val_selectorID,
|
|
166
|
-
options: params.defaultOptions || [],
|
|
167
|
-
selected: val_selected,
|
|
168
|
-
limit: params.limit,
|
|
169
|
-
onDynamicSearch: params.onDynamicSearch,
|
|
170
|
-
onUpdated: ( args ) => {
|
|
171
|
-
UpdateValue( args.values )
|
|
172
|
-
},
|
|
173
|
-
onClosed: () => {
|
|
174
|
-
$( DefaultParentQuerySelector ).focus()
|
|
175
|
-
}
|
|
176
|
-
} )
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
let DefaultParentQuerySelector = `[data-chips-input-wrapper="${ val_selectorID }"]`
|
|
180
|
-
let isFully = limit && limit <= val_selected.length
|
|
181
|
-
|
|
182
|
-
const mounted = React.useRef( false )
|
|
183
|
-
React.useEffect( () => {
|
|
184
|
-
if ( mounted.current ) {
|
|
185
|
-
if ( isFully ) {
|
|
186
|
-
Sheet.close( val_selectorID )
|
|
187
|
-
$( DefaultParentQuerySelector ).focus()
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
mounted.current = true
|
|
191
|
-
}
|
|
192
|
-
},[ val_selected ] )
|
|
193
|
-
|
|
194
|
-
let Selected = val_selected.map( ( s ) => {
|
|
195
|
-
let { value,label } = s
|
|
196
|
-
SelectedCellComponent = SelectedCellComponent!
|
|
197
|
-
|
|
198
|
-
const removeCallback = () => {
|
|
199
|
-
let findIndex = val_selected.findIndex( ( v ) => v.value == value )
|
|
200
|
-
if ( findIndex == -1 ) return
|
|
201
|
-
let newSelected = [ ...val_selected ]
|
|
202
|
-
newSelected.splice( findIndex,1 )
|
|
203
|
-
UpdateValue( newSelected )
|
|
204
|
-
if ( !newSelected.length ) {
|
|
205
|
-
setTimeout( () => {
|
|
206
|
-
$( DefaultParentQuerySelector ).focus()
|
|
207
|
-
},200 )
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return <SelectedCellComponent
|
|
211
|
-
key={ JSON.stringify( value ) }
|
|
212
|
-
value={ value }
|
|
213
|
-
label={ label }
|
|
214
|
-
removeCallback={ removeCallback }
|
|
215
|
-
defaultRemoveButton={ <Buttons.Button.Sub.S
|
|
216
|
-
padding={ '2/3' }
|
|
217
|
-
flexSizing={ 'none' }
|
|
218
|
-
color='cloud'
|
|
219
|
-
backgroundColor='cloud'
|
|
220
|
-
isRounded
|
|
221
|
-
onClick={ () => {
|
|
222
|
-
removeCallback()
|
|
223
|
-
} }
|
|
224
|
-
>
|
|
225
|
-
<FAI.Times />
|
|
226
|
-
</Buttons.Button.Sub.S> }
|
|
227
|
-
openCallback={ () => {
|
|
228
|
-
OpenSelector()
|
|
229
|
-
} }
|
|
230
|
-
/>
|
|
231
|
-
} )
|
|
232
|
-
|
|
233
|
-
return <BoxWrapper
|
|
234
|
-
val_status={ val_status }
|
|
235
|
-
set_status={ set_status }
|
|
236
|
-
val_validate={ val_validate }
|
|
237
|
-
params={ params }
|
|
238
|
-
>
|
|
239
|
-
<Input.Hidden
|
|
240
|
-
data-value={ JSON.stringify( val_status.dataValue.map( ( v: any ) => v.value ) ) }
|
|
241
|
-
name={ name }
|
|
242
|
-
form={ form }
|
|
243
|
-
data-input-type={ 'chips-' + [ 'single','multi' ][ Number( params.limit != 1 ) ] }
|
|
244
|
-
data-validation={ val_validate.ok }
|
|
245
|
-
componentID={ val_status.componentID }
|
|
246
|
-
data-focusor={ val_selectorID }
|
|
247
|
-
/>
|
|
248
|
-
<button
|
|
249
|
-
data-chips-input-wrapper={ val_selectorID }
|
|
250
|
-
onKeyDown={ ( e ) => {
|
|
251
|
-
let { key,ctrlKey,metaKey,keyCode } = e
|
|
252
|
-
let auxKey = ctrlKey || metaKey
|
|
253
|
-
let isString = ( keyCode >= 48 && keyCode <= 57 ) || ( keyCode >= 65 && keyCode <= 90 ) || ( keyCode >= 96 && keyCode <= 105 )
|
|
254
|
-
|
|
255
|
-
if ( isString ) {
|
|
256
|
-
if ( isFully ) return
|
|
257
|
-
OpenSelector()
|
|
258
|
-
} else if ( key == 'Tab' ) {
|
|
259
|
-
|
|
260
|
-
} else if ( key == 'Backspace' ) {
|
|
261
|
-
if ( !val_selected.length ) return
|
|
262
|
-
if ( auxKey ) {
|
|
263
|
-
UpdateValue( [] )
|
|
264
|
-
} else {
|
|
265
|
-
let newSelected = [ ...val_selected ]
|
|
266
|
-
newSelected.pop()
|
|
267
|
-
UpdateValue( newSelected )
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
} }
|
|
271
|
-
onClick={ () => {
|
|
272
|
-
if ( isFully ) return
|
|
273
|
-
// if ( val_selected.length ) return
|
|
274
|
-
OpenSelector()
|
|
275
|
-
} }
|
|
276
|
-
{ ...others }
|
|
277
|
-
>
|
|
278
|
-
{ !isFully ? <AddButtonComponent
|
|
279
|
-
selected={ val_selected }
|
|
280
|
-
openCallback={ OpenSelector }
|
|
281
|
-
/> : null }
|
|
282
|
-
{ Selected }
|
|
283
|
-
</button>
|
|
284
|
-
</BoxWrapper>
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const ChipsInput: amotify.fn.Input.Chips.Methods = DataWrapping as any
|
|
288
|
-
ChipsInput.fn = ChipsInputFNs
|
|
289
|
-
export { ChipsInput }
|
|
@@ -1,114 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
React
|
|
3
|
-
} from '@global'
|
|
4
|
-
import {
|
|
5
|
-
Flex
|
|
6
|
-
} from '@atoms'
|
|
7
|
-
import {
|
|
8
|
-
Input
|
|
9
|
-
} from '@fn'
|
|
10
|
-
import {
|
|
11
|
-
BoxWrapper,
|
|
12
|
-
SubmitForm,
|
|
13
|
-
CommonEffects
|
|
14
|
-
} from './core'
|
|
15
|
-
|
|
16
|
-
import style from './style.module.scss'
|
|
17
|
-
|
|
18
|
-
function DefaultValidation( props: {
|
|
19
|
-
value: any
|
|
20
|
-
params: any
|
|
21
|
-
} ): amotify.fn.Input.Validation.Result {
|
|
22
|
-
let { value,params } = props
|
|
23
|
-
let {
|
|
24
|
-
required,
|
|
25
|
-
numericOnly = false,
|
|
26
|
-
digits
|
|
27
|
-
} = params as amotify.fn.Input.DigitCharacters.PlainParams
|
|
28
|
-
let notice: amotify.fn.Input.Validation.NoticeTypes[] = []
|
|
29
|
-
|
|
30
|
-
if ( required && !value ) {
|
|
31
|
-
notice.push( { type: 'invalid',label: '必須項目です' } )
|
|
32
|
-
}
|
|
33
|
-
if ( value ) {
|
|
34
|
-
if ( numericOnly && value.match( /\D/ ) ) {
|
|
35
|
-
notice.push( { type: 'invalid',label: '数字のみで入力してください' } )
|
|
36
|
-
}
|
|
37
|
-
if ( value.length != digits ) {
|
|
38
|
-
notice.push( { type: 'warn',label: '最後まで入力してください' } )
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
ok: !notice.filter( ( { type } ) => type == 'invalid' || type == 'warn' ).length,
|
|
44
|
-
notice: notice
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const dataToFormat = ( digits: number,value: any = '' ) => {
|
|
50
|
-
let dataValue = String( value )
|
|
51
|
-
let formatValue: any = []
|
|
52
|
-
for ( let index = 0; index < digits; index++ ) {
|
|
53
|
-
formatValue[ index ] = dataValue[ index ] || ''
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
formatValue,
|
|
57
|
-
dataValue
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const formatToData = ( value: any = '' ) => {
|
|
61
|
-
let formatValue = value
|
|
62
|
-
let dataValue = formatValue.join( '' )
|
|
63
|
-
return {
|
|
64
|
-
formatValue,
|
|
65
|
-
dataValue
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export const DigitCharactersInput: React.FC<amotify.fn.Input.DigitCharacters.PlainParams> = ( params ) => {
|
|
71
|
-
let {
|
|
72
|
-
tone,
|
|
73
|
-
required,
|
|
74
|
-
form,
|
|
75
|
-
name,
|
|
76
|
-
|
|
77
|
-
className = '',
|
|
78
|
-
digits,
|
|
79
|
-
numericOnly = false,
|
|
80
|
-
enableFormSubmit,
|
|
81
|
-
|
|
82
|
-
checkValidationAtFirst,
|
|
83
|
-
onChange,onKeyDown,
|
|
84
|
-
onValidate,
|
|
85
|
-
onUpdateValue,
|
|
86
|
-
onUpdateValidValue,
|
|
87
|
-
value = '',
|
|
88
|
-
|
|
89
|
-
override,
|
|
90
|
-
|
|
91
|
-
componentID,
|
|
92
|
-
listStyles,
|
|
93
|
-
...others
|
|
94
|
-
} = params
|
|
95
|
-
|
|
96
|
-
if ( numericOnly ) {
|
|
97
|
-
params.inputMode = params.inputMode || 'numeric'
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let Default_Status: amotify.fn.Input.Status.DigitCharacters = {
|
|
101
|
-
componentID: params.componentID || '',
|
|
102
|
-
...dataToFormat( digits,value ),
|
|
103
|
-
eventType: 'init',
|
|
104
|
-
eventID: $.uuidGen()
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let [ val_status,set_status ] = React.useState( Default_Status )
|
|
108
|
-
let [ val_validate,set_validate ] = React.useState( {
|
|
109
|
-
ok: false,
|
|
110
|
-
notice: []
|
|
111
|
-
} as amotify.fn.Input.Validation.Result )
|
|
112
|
-
|
|
113
|
-
CommonEffects( {
|
|
114
|
-
params,
|
|
115
|
-
val_status,
|
|
116
|
-
set_status,
|
|
117
|
-
val_validate,
|
|
118
|
-
set_validate,
|
|
119
|
-
onUpdateValue,
|
|
120
|
-
onUpdateValidValue,
|
|
121
|
-
DefaultValidation
|
|
122
|
-
} )
|
|
123
|
-
|
|
124
|
-
let Digits = []
|
|
125
|
-
for ( let index = 0; index < digits; index++ ) {
|
|
126
|
-
let Character = val_status.formatValue[ index ]
|
|
127
|
-
|
|
128
|
-
let Styles: React.CSSProperties = {}
|
|
129
|
-
|
|
130
|
-
let ClassName = className
|
|
131
|
-
|
|
132
|
-
if ( params.combineInput ) {
|
|
133
|
-
ClassName = [
|
|
134
|
-
className,
|
|
135
|
-
style.DigitCharacterCell,
|
|
136
|
-
style.Combined
|
|
137
|
-
].join( ' ' )
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
Digits.push( <input
|
|
141
|
-
key={ index }
|
|
142
|
-
type={ 'text' }
|
|
143
|
-
inputMode={ params.inputMode || 'text' }
|
|
144
|
-
value={ Character }
|
|
145
|
-
data-form-name={ form }
|
|
146
|
-
id={ 'Digit-' + index + '-' + val_status.componentID }
|
|
147
|
-
className={ ClassName }
|
|
148
|
-
style={ {
|
|
149
|
-
...params.style,
|
|
150
|
-
...Styles
|
|
151
|
-
} }
|
|
152
|
-
onKeyDown={ ( event ) => {
|
|
153
|
-
let {
|
|
154
|
-
key,
|
|
155
|
-
code
|
|
156
|
-
} = event
|
|
157
|
-
|
|
158
|
-
if ( key == 'Tab' ) return
|
|
159
|
-
event.preventDefault()
|
|
160
|
-
let nextFocusIndex = null
|
|
161
|
-
|
|
162
|
-
if ( key == 'Backspace' ) {
|
|
163
|
-
let newFormatValue = val_status.formatValue
|
|
164
|
-
newFormatValue[ index ] = ''
|
|
165
|
-
|
|
166
|
-
set_status( {
|
|
167
|
-
...val_status,
|
|
168
|
-
...formatToData( newFormatValue ),
|
|
169
|
-
eventType: 'update',
|
|
170
|
-
eventID: $.uuidGen()
|
|
171
|
-
} )
|
|
172
|
-
nextFocusIndex = index - 1
|
|
173
|
-
} else if ( [ 'ArrowLeft','ArrowRight' ].includes( key ) ) {
|
|
174
|
-
let dir = Number( key == 'ArrowRight' ) * 2 - 1
|
|
175
|
-
nextFocusIndex = index + dir
|
|
176
|
-
} else {
|
|
177
|
-
if ( enableFormSubmit ) SubmitForm( event );
|
|
178
|
-
|
|
179
|
-
( () => {
|
|
180
|
-
let regExp = code.match( /^(Key(.)|Digit(\d)|Numpad(\d))/ )
|
|
181
|
-
if ( !regExp ) return
|
|
182
|
-
|
|
183
|
-
let newCharacter: string = regExp[ 2 ] || regExp[ 3 ] || regExp[ 4 ]
|
|
184
|
-
if ( numericOnly ) {
|
|
185
|
-
if ( !newCharacter.match( /\d/ ) ) return
|
|
186
|
-
}
|
|
187
|
-
if ( !newCharacter ) return
|
|
188
|
-
|
|
189
|
-
let newFormatValue = val_status.formatValue
|
|
190
|
-
newFormatValue[ index ] = newCharacter
|
|
191
|
-
|
|
192
|
-
set_status( {
|
|
193
|
-
...val_status,
|
|
194
|
-
...formatToData( newFormatValue ),
|
|
195
|
-
eventType: 'update',
|
|
196
|
-
eventID: $.uuidGen()
|
|
197
|
-
} )
|
|
198
|
-
nextFocusIndex = index + 1
|
|
199
|
-
} )()
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if ( $.is.exist( nextFocusIndex ) ) {
|
|
203
|
-
$( '#Digit-' + nextFocusIndex + '-' + val_status.componentID ).focus()
|
|
204
|
-
}
|
|
205
|
-
} }
|
|
206
|
-
onChange={ () => { } }
|
|
207
|
-
/> )
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return <BoxWrapper
|
|
211
|
-
val_status={ val_status }
|
|
212
|
-
set_status={ set_status }
|
|
213
|
-
val_validate={ val_validate }
|
|
214
|
-
params={ params }
|
|
215
|
-
>
|
|
216
|
-
<Input.Hidden
|
|
217
|
-
name={ name }
|
|
218
|
-
data-input-type={ 'digitCharacters' }
|
|
219
|
-
data-form={ form }
|
|
220
|
-
data-validation={ val_validate.ok }
|
|
221
|
-
componentID={ val_status.componentID }
|
|
222
|
-
data-value={ val_status.dataValue }
|
|
223
|
-
{ ...others }
|
|
224
|
-
/>
|
|
225
|
-
<Flex
|
|
226
|
-
gap={ '1/2' }
|
|
227
|
-
flexChilds='even'
|
|
228
|
-
flexWrap={ false }
|
|
229
|
-
flexSizing='auto'
|
|
230
|
-
{ ...listStyles }
|
|
231
|
-
>
|
|
232
|
-
{ Digits }
|
|
233
|
-
</Flex>
|
|
234
|
-
</BoxWrapper>
|
|
235
|
-
}
|