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.
Files changed (114) hide show
  1. package/dist/amotify.js +3 -2
  2. package/dist/amotify.min.css +2 -2
  3. package/dist/coreVender.js +14 -2
  4. package/package.json +10 -10
  5. package/tsconfig.json +13 -5
  6. package/@types/_.tsx +0 -7
  7. package/@types/amot.tsx +0 -357
  8. package/@types/fn.tsx +0 -1280
  9. package/@types/jsminAmotifyExtension.tsx +0 -137
  10. package/@types/module.tsx +0 -1
  11. package/@types/state.tsx +0 -231
  12. package/src/@atoms.tsx +0 -34
  13. package/src/@functions.tsx +0 -29
  14. package/src/@global.tsx +0 -149
  15. package/src/@jsminAmotifyExtension/_.tsx +0 -4
  16. package/src/@jsminAmotifyExtension/fetch.tsx +0 -110
  17. package/src/@jsminAmotifyExtension/formCollect.tsx +0 -94
  18. package/src/@jsminAmotifyExtension/spreadSheet.tsx +0 -165
  19. package/src/@jsminAmotifyExtension/variables.tsx +0 -137
  20. package/src/@molecules.tsx +0 -96
  21. package/src/@organisms.tsx +0 -1
  22. package/src/@reactPacks/reactProduction@18.2.0.js +0 -79
  23. package/src/@reactPacks/reactRouterDomProduction@18.2.0.js +0 -31
  24. package/src/@styles/@app.scss +0 -4
  25. package/src/@styles/UniStyling.scss +0 -1028
  26. package/src/@styles/init.scss +0 -94
  27. package/src/@styles/props.scss +0 -109
  28. package/src/@styles/styleSet.scss +0 -38
  29. package/src/@styles/themeColor.scss +0 -71
  30. package/src/@styles/var.scss +0 -182
  31. package/src/@templates.tsx +0 -7
  32. package/src/@variables.tsx +0 -74
  33. package/src/atoms/FAI/parts.tsx +0 -139
  34. package/src/atoms/Logo/parts.tsx +0 -335
  35. package/src/atoms/Logo/style.module.scss +0 -96
  36. package/src/atoms/Various/parts.tsx +0 -159
  37. package/src/atoms/Various/style.module.scss +0 -46
  38. package/src/config.tsx +0 -191
  39. package/src/functions/Button/_.tsx +0 -331
  40. package/src/functions/Button/style.module.scss +0 -157
  41. package/src/functions/Cropper/parts.tsx +0 -1084
  42. package/src/functions/Cropper/style.module.scss +0 -64
  43. package/src/functions/Effects/Fade.tsx +0 -76
  44. package/src/functions/Effects/Ripple.tsx +0 -141
  45. package/src/functions/Effects/_.tsx +0 -33
  46. package/src/functions/Effects/style.module.scss +0 -91
  47. package/src/functions/Input/Chips/Selector.tsx +0 -445
  48. package/src/functions/Input/Chips/_.tsx +0 -289
  49. package/src/functions/Input/Chips/style.module.scss +0 -6
  50. package/src/functions/Input/Contenteditable.tsx +0 -114
  51. package/src/functions/Input/DigitCharacters.tsx +0 -235
  52. package/src/functions/Input/File/_.tsx +0 -553
  53. package/src/functions/Input/File/style.module.scss +0 -34
  54. package/src/functions/Input/Hidden.tsx +0 -21
  55. package/src/functions/Input/List/_.tsx +0 -383
  56. package/src/functions/Input/List/style.module.scss +0 -84
  57. package/src/functions/Input/RichSelect/_.tsx +0 -230
  58. package/src/functions/Input/RichSelect/style.module.scss +0 -11
  59. package/src/functions/Input/Segmented/_.tsx +0 -246
  60. package/src/functions/Input/Segmented/style.module.scss +0 -81
  61. package/src/functions/Input/Select/_.tsx +0 -218
  62. package/src/functions/Input/Select/style.module.scss +0 -11
  63. package/src/functions/Input/Slider/_.tsx +0 -524
  64. package/src/functions/Input/Slider/style.module.scss +0 -67
  65. package/src/functions/Input/Switch/_.tsx +0 -176
  66. package/src/functions/Input/Switch/style.module.scss +0 -18
  67. package/src/functions/Input/Text.tsx +0 -487
  68. package/src/functions/Input/TextArea.tsx +0 -109
  69. package/src/functions/Input/Time/Picker.tsx +0 -1361
  70. package/src/functions/Input/Time/_.tsx +0 -749
  71. package/src/functions/Input/Time/style.module.scss +0 -79
  72. package/src/functions/Input/_.tsx +0 -881
  73. package/src/functions/Input/core.tsx +0 -473
  74. package/src/functions/Input/style.module.scss +0 -102
  75. package/src/functions/Inputs/_.tsx +0 -5
  76. package/src/functions/Inputs/style.module.scss +0 -15
  77. package/src/functions/Inputs/text.tsx +0 -53
  78. package/src/functions/Inputs/types.d.ts +0 -13
  79. package/src/functions/Layout/PageNotFound.tsx +0 -78
  80. package/src/functions/Layout/PageRouter.tsx +0 -89
  81. package/src/functions/Layout/PageViewController/parts.tsx +0 -27
  82. package/src/functions/Layout/Plate.tsx +0 -30
  83. package/src/functions/Layout/RootViewController/parts.tsx +0 -300
  84. package/src/functions/Layout/RootViewController/style.module.scss +0 -23
  85. package/src/functions/Layout/SwipeView/parts.tsx +0 -375
  86. package/src/functions/Layout/SwipeView/style.module.scss +0 -20
  87. package/src/functions/Layout/TabBar.tsx +0 -60
  88. package/src/functions/Layout/_.tsx +0 -20
  89. package/src/functions/Loader/corner.tsx +0 -74
  90. package/src/functions/Loader/mini.tsx +0 -114
  91. package/src/functions/Loader/parts.tsx +0 -103
  92. package/src/functions/Loader/style.module.scss +0 -223
  93. package/src/functions/Loader/top.tsx +0 -84
  94. package/src/functions/Sheet/parts.tsx +0 -994
  95. package/src/functions/Sheet/style.module.scss +0 -208
  96. package/src/functions/SnackBar/parts.tsx +0 -215
  97. package/src/functions/SnackBar/style.module.scss +0 -25
  98. package/src/functions/Table/Data/parts.tsx +0 -965
  99. package/src/functions/Table/Drag/parts.tsx +0 -442
  100. package/src/functions/Table/Normal/parts.tsx +0 -124
  101. package/src/functions/Table/_.tsx +0 -177
  102. package/src/functions/Table/style.module.scss +0 -93
  103. package/src/functions/Tooltips/parts.tsx +0 -53
  104. package/src/global/LaunchReactApplication.tsx +0 -74
  105. package/src/global/styleConverter.tsx +0 -465
  106. package/src/launch.tsx +0 -119
  107. package/src/molecules/Accordion/parts.tsx +0 -146
  108. package/src/molecules/Accordion/style.module.scss +0 -13
  109. package/src/molecules/LinkifyText/parts.tsx +0 -52
  110. package/src/molecules/List.tsx +0 -31
  111. package/src/preload.tsx +0 -31
  112. package/src/templates/PlayGround/parts.tsx +0 -96
  113. package/src/templates/PlayGround/style.module.scss +0 -38
  114. package/webpack.config.js +0 -146
@@ -1,749 +0,0 @@
1
- import {
2
- useStore,
3
- React
4
- } from '@global'
5
- import {
6
- Box
7
- } from '@atoms'
8
- import {
9
- Input,
10
- Buttons,
11
- Tooltips
12
- } from '@fn'
13
-
14
- import {
15
- BoxWrapper,
16
- SubmitForm,
17
- ValidationCheck,
18
- CommonEffects
19
- } from '../core'
20
- import { Picker } from './Picker'
21
-
22
- const PeriodMargin = ' ~ '
23
-
24
- const TimeFormatDatas: {
25
- [ key: string ]: {
26
- defaultValue: string
27
- format: RegExp
28
- ranges: amotify.fn.Input.Time.RangeProps[]
29
- sets: number
30
- }
31
- } = {
32
- clock: {
33
- defaultValue: '--:--',format: /^\d{2}\D\d{2}$/,ranges: [
34
- { type: 'hour',from: 0,length: 2 },
35
- { type: 'minute',from: 3,length: 2 }
36
- ],sets: 1
37
- },
38
- date: {
39
- defaultValue: '----/--/--',format: /^\d{4}\D\d{2}\D\d{2}$/,ranges: [
40
- { type: 'year',from: 0,length: 4 },
41
- { type: 'month',from: 5,length: 2 },
42
- { type: 'date',from: 8,length: 2 }
43
- ],sets: 1
44
- },
45
- week: {
46
- defaultValue: '----年第--週',format: /^\d{4}\D\d{2}$/,ranges: [
47
- { type: 'year',from: 0,length: 4,region: 6 },
48
- { type: 'week',from: 6,length: 2,region: 3 }
49
- ],sets: 1
50
- },
51
- month: {
52
- defaultValue: '----年--月',format: /^\d{4}\D\d{2}$/,ranges: [
53
- { type: 'year',from: 0,length: 4 },
54
- { type: 'month',from: 5,length: 2,region: 3 }
55
- ],sets: 1
56
- },
57
- year: {
58
- defaultValue: '----年',format: /^\d{4}$/,ranges: [
59
- { type: 'year',from: 0,length: 4,region: 5 }
60
- ],sets: 1
61
- },
62
- dates: {
63
- defaultValue: '----/--/--',format: /^\d{4}\D\d{2}\D\d{2}$/,ranges: [
64
- { type: 'year',from: 0,length: 4 },
65
- { type: 'month',from: 5,length: 2 },
66
- { type: 'date',from: 8,length: 2,region: 5 },
67
- { type: 'year',from: 10 + PeriodMargin.length,length: 4 },
68
- { type: 'month',from: 15 + PeriodMargin.length,length: 2 },
69
- { type: 'date',from: 18 + PeriodMargin.length,length: 2 }
70
- ],sets: 2
71
- },
72
- months: {
73
- defaultValue: '----年--月',format: /^\d{4}\D\d{2}$/,ranges: [
74
- { type: 'year',from: 0,length: 4 },
75
- { type: 'month',from: 5,length: 2,region: 6 },
76
- { type: 'year',from: 8 + PeriodMargin.length,length: 4 },
77
- { type: 'month',from: 13 + PeriodMargin.length,length: 2,region: 3 }
78
- ],sets: 2
79
- },
80
- dateWareki: {
81
- defaultValue: '----年--月--日',format: /^\d{4}\D\d{2}\D\d{2}$/,ranges: [
82
- { type: 'dateWareki',from: 0,length: 4,region: 5 },
83
- { type: 'month',from: 5,length: 2,region: 3 },
84
- { type: 'date',from: 8,length: 2,region: 3 }
85
- ],sets: 1
86
- }
87
- }
88
-
89
- const DataLeveling = ( params: {
90
- restrict: amotify.fn.Input.Time.RestrictTypes
91
- value: any
92
- era: amotify.fn.Input.Time.EraTypes
93
- } ) => {
94
- let {
95
- restrict,
96
- value,
97
- era
98
- } = params
99
-
100
- let dataValue = $.flatArray( value || '' )
101
-
102
- let {
103
- defaultValue,
104
- format,
105
- ranges,
106
- sets
107
- } = TimeFormatDatas[ restrict ]
108
- let formatValues: string[] = []
109
-
110
- let separateStr = restrict == 'clock' ? ':' : '/'
111
- for ( let index = 0; index < dataValue.length; index++ ) {
112
- dataValue[ index ] = String( dataValue[ index ] ).replace( /\D/ig,separateStr )
113
- }
114
- for ( let index = 0; index < sets; index++ ) {
115
- let val = dataValue[ index ] || ''
116
- if ( !val.match( format ) ) {
117
- dataValue[ index ] = ''
118
- formatValues.push( defaultValue )
119
- } else {
120
- let _value = defaultValue
121
- val.split( /\D/ ).forEach( ( v: string,i: number ) => {
122
- if ( i == 0 && restrict == 'dateWareki' ) {
123
- let Year = Number( v )
124
- if ( era != 'year' ) {
125
- if ( Year >= 2019 ) {
126
- if ( era == 'reiwa' ) Year -= ( 2019 - 1 )
127
- else if ( era == 'heisei' ) Year = 31
128
- } else if ( Year >= 1989 ) {
129
- if ( era == 'heisei' ) Year -= ( 1989 - 1 )
130
- else if ( era == 'shouwa' ) Year = 64
131
- } else if ( Year >= 1926 ) {
132
- if ( era == 'shouwa' ) Year -= ( 1926 - 1 )
133
- else if ( era == 'taisho' ) Year = 15
134
- } else if ( Year >= 1912 ) {
135
- if ( era == 'taisho' ) Year -= ( 1912 - 1 )
136
- else if ( era == 'meiji' ) Year = 45
137
- } else if ( Year >= 1868 ) Year -= ( 1868 - 1 )
138
- }
139
- v = Year.zeroEmbed( 4 )
140
- }
141
- _value = _value.replace( new RegExp( '------------------'.slice( 0,v.length ) ),v )
142
- } )
143
- formatValues.push( _value )
144
- }
145
- }
146
-
147
- return {
148
- formatValue: formatValues.join( PeriodMargin ),
149
- dataValue: [ 'dates','months' ].includes( restrict ) ? dataValue : dataValue[ 0 ],
150
- ranges
151
- }
152
- }
153
-
154
- function DefaultValidation( props: {
155
- value: any
156
- params: any
157
- } ): amotify.fn.Input.Validation.Result {
158
- let {
159
- params
160
- } = props
161
- let {
162
- restrict,
163
- min,max,
164
- required
165
- } = params as amotify.fn.Input.Time.OriginParams
166
- let notice: amotify.fn.Input.Validation.NoticeTypes[] = []
167
- let values: string[] = $.flatArray( props.value )
168
-
169
- let validate = {
170
- empty: false,
171
- escalated: 1,
172
- filled: true,
173
- correct: true,
174
- prohibited: false
175
- };
176
-
177
- ( () => {
178
- let separateStr = restrict == 'clock' ? ':' : '/'
179
- for ( let index = 0; index < values.length; index++ ) {
180
- values[ index ] = String( values[ index ] ).replace( /\D/ig,separateStr )
181
- }
182
- for ( let index = 0; index < values.length; index++ ) {
183
- let value = values[ index ]
184
- let prevValue = values[ index - 1 ]
185
- if ( !value.removeLetters() ) validate.empty = true
186
- if ( index > 0 ) validate.escalated &= Number( value >= prevValue )
187
- }
188
- if ( !validate.escalated ) return
189
- if ( validate.empty ) return
190
-
191
- if ( restrict.match( /clock/ ) ) {
192
- values.forEach( value => {
193
- let [ hour,minute ] = value.split( /\D+/ )
194
-
195
- if ( !hour || !minute ) {
196
- validate.filled = false
197
- } else if ( Number( hour ) > 23 || Number( minute ) > 59 ) {
198
- validate.correct = false
199
- }
200
- } )
201
- } else if ( restrict.match( /date/ ) ) {
202
- values.forEach( value => {
203
- let [ year,month,day ] = value.split( /\D+/ )
204
- if ( !year || !month || !day ) {
205
- validate.filled = false
206
- } else {
207
- let Time = $.Time( value )
208
- if ( !Time.validate || value != Time.toFormatYMD() ) {
209
- validate.correct = false
210
- }
211
- }
212
- } )
213
- } else if ( restrict.match( /week/ ) ) {
214
- values.forEach( value => {
215
- let [ year,week ] = value.split( /\D+/ )
216
- if ( !year || !week ) {
217
- validate.filled = false
218
- } else {
219
- let yearFirstDay = $.Time( year + '/01/01' ).weekday
220
- let yearFirstWeek0Day = $.Time( year + '/01/0' + ( 7 - yearFirstDay + 1 ) )
221
- let yearValueWeek0Day = yearFirstWeek0Day.addWeek( Number( week ) - 1 )
222
- if ( year != String( yearValueWeek0Day.year ) ) {
223
- validate.correct = false
224
- }
225
- }
226
- } )
227
- } else if ( restrict.match( /month/ ) ) {
228
- values.forEach( value => {
229
- let [ year,month ] = value.split( /\D+/ )
230
- if ( !year || !month ) {
231
- validate.filled = false
232
- } else {
233
- let date = $.Time( [ year,month,'01' ].join( '/' ) )
234
- if ( !date.validate ) validate.correct = false
235
- }
236
- } )
237
- } else if ( restrict.match( /year/ ) ) {
238
-
239
- }
240
-
241
- if ( validate.filled && validate.correct ) {
242
- values.forEach( value => {
243
- {
244
- let VAL = Number( String( value ).replace( /\D/ig,'' ) )
245
- if ( min ) {
246
- let MIN = Number( String( min ).replace( /\D/ig,'' ) )
247
- if ( MIN > VAL ) validate.prohibited = true
248
- }
249
- if ( max ) {
250
- let MAX = Number( String( max ).replace( /\D/ig,'' ) )
251
- if ( VAL > MAX ) validate.prohibited = true
252
- }
253
- }
254
- } )
255
- }
256
- } )()
257
-
258
- {
259
- let {
260
- empty,
261
- escalated,
262
- filled,
263
- correct,
264
- prohibited
265
- } = validate
266
- if ( empty && required ) {
267
- notice = [
268
- { type: 'invalid',label: '必須項目です' }
269
- ]
270
- }
271
- if ( !escalated ) {
272
- notice.push( { type: 'invalid',label: '時系列を正しく入力してください' } )
273
- }
274
- if ( !correct ) {
275
- notice.push( { type: 'invalid',label: '無効な値が入力されています' } )
276
- }
277
- if ( !filled ) {
278
- notice.push( { type: 'invalid',label: '最後まで値を埋めてください' } )
279
- }
280
- if ( prohibited ) {
281
- notice.push( {
282
- type: 'invalid',label: <>
283
- <Box>
284
- 入力範囲が制限されています
285
- </Box>
286
- [{ min || '下限無し' }] ~ [{ max || '上限無し' }]
287
- </>
288
- } )
289
- }
290
- }
291
-
292
- return {
293
- ok: !notice.filter( ( { type } ) => type == 'invalid' ).length,
294
- notice: notice
295
- }
296
- }
297
-
298
- type FocusProps = {
299
- active: boolean
300
- index: number
301
- prevIndex: number
302
- }
303
-
304
- export const TimeInput: React.FC<amotify.fn.Input.Time.OriginParams> = ( params ) => {
305
- let {
306
- tone,
307
- required,
308
- restrict = 'clock',
309
- componentID,
310
- era,
311
- form,
312
- name,
313
- min,max,
314
- className,
315
-
316
- enableFormSubmit,
317
-
318
- checkValidationAtFirst,
319
- onKeyDown,
320
- onValidate,
321
- onUpdateValue,
322
- onUpdateValidValue,
323
- value = '',
324
- leftIndicator,rightIndicator,
325
-
326
- ...others
327
- } = params
328
-
329
- let [ val_era,set_era ] = React.useState( era! )
330
-
331
- let [ val_status,set_status ] = React.useState( {
332
- componentID: params.componentID || '',
333
- ...DataLeveling( {
334
- restrict,
335
- value,
336
- era: val_era
337
- } ),
338
- eventType: 'init',
339
- eventID: $.uuidGen(),
340
- } as amotify.fn.Input.Status.Time )
341
-
342
- let [ val_validate,set_validate ] = React.useState( {
343
- ok: false,
344
- notice: []
345
- } as amotify.fn.Input.Validation.Result )
346
- let [ val_focus,set_focus ] = React.useState( {
347
- active: false,
348
- index: 0,
349
- prevIndex: -1
350
- } as FocusProps )
351
-
352
- CommonEffects( {
353
- type: 'time',
354
- params,
355
- val_status,
356
- set_status,
357
- val_validate,
358
- set_validate,
359
- DefaultValidation,
360
- onUpdateValue,
361
- onUpdateValidValue,
362
- ExtraOverrideParams: {
363
- ...DataLeveling( {
364
- restrict,
365
- value,
366
- era: val_era!
367
- } )
368
- }
369
- } )
370
-
371
- const mounted = React.useRef( false )
372
- React.useEffect( () => {
373
- if ( mounted.current ) {
374
- set_status( {
375
- ...val_status,
376
- ...DataLeveling( {
377
- restrict,
378
- value: val_status.dataValue,
379
- era: val_era
380
- } )
381
- } )
382
-
383
- let ParentComponent = useStore.get( 'refreshEra_' + val_status.componentID )
384
- ParentComponent && ParentComponent.refreshEra( val_era )
385
- } else {
386
- mounted.current = true
387
- }
388
- },[ val_era ] )
389
-
390
- useStore.update( {
391
- key: val_status.componentID,
392
- value: {
393
- openPicker: () => {
394
- if ( params.disabled ) return
395
-
396
- TimeFNs.picker.launch( {
397
- parent: '#Picker-' + val_status.componentID,
398
- tipsID: 'PickerTips-' + val_status.componentID,
399
- restrict,
400
- min,max,
401
- defaultValue: val_status.dataValue,
402
- era: val_era,
403
- onValueUpdate: ( value,era ) => {
404
- set_status( {
405
- ...val_status,
406
- ...DataLeveling( {
407
- restrict,
408
- value,
409
- era
410
- } ),
411
- eventType: 'update',
412
- eventID: $.uuidGen()
413
- } )
414
- set_era( era )
415
- }
416
- } )
417
- },
418
- resetEra: ( era: amotify.fn.Input.Time.EraTypes ) => {
419
- set_era( era )
420
- set_status( {
421
- ...val_status,
422
- ...DataLeveling( {
423
- restrict,
424
- value: '',
425
- era: val_era!
426
- } ),
427
- eventType: 'update',
428
- eventID: $.uuidGen()
429
- } )
430
- }
431
- }
432
- } )
433
-
434
- React.useEffect( () => {
435
- let { index,active } = val_focus
436
- if ( active ) {
437
- index = Math.max( index,0 )
438
- index = Math.min( index,val_status.ranges.length - 1 )
439
-
440
- let { from,length } = val_status.ranges[ index ]
441
- let input = $( '#' + params.id )[ 0 ] as HTMLInputElement
442
- if ( input ) input.setSelectionRange( from,( from + length ) )
443
- }
444
- },[ val_focus ] )
445
-
446
- return <BoxWrapper
447
- val_status={ val_status }
448
- set_status={ set_status }
449
- val_validate={ val_validate }
450
- params={ params }
451
- >
452
- <Input.Hidden
453
- name={ name }
454
- data-input-type={ 'time' }
455
- data-form={ form }
456
- data-validation={ val_validate.ok }
457
- componentID={ val_status.componentID }
458
- data-value={ JSON.stringify(
459
- [ 'dates','months' ].includes( restrict ) ?
460
- !val_status.dataValue[ 0 ] || !val_status.dataValue[ 1 ] ? null
461
- : val_status.dataValue
462
- : ( val_status.dataValue || null )
463
- ) }
464
- />
465
- { amotify.config.device.isTouchDevice ?
466
- <Buttons.Button.Plain
467
- className={ className }
468
- freeCSS={ {
469
- textAlign: 'left'
470
- } }
471
- children={ val_status.formatValue }
472
- onClick={ ( event ) => {
473
- let component = useStore.get( val_status.componentID )
474
- if ( component ) component.openPicker()
475
- event.stopPropagation()
476
- } }
477
- /> : <input
478
- type={ 'text' }
479
- inputMode={ 'numeric' }
480
- data-input-type={ 'time' }
481
- data-form-name={ form }
482
- value={ val_status.formatValue }
483
- className={ className }
484
- tabIndex={ amotify.config.device.isTouchDevice ? -1 : 0 }
485
- onKeyDown={ ( event ) => {
486
- KeyDownEvent( {
487
- restrict,
488
- event,
489
- val_era,
490
- val_status,set_status,
491
- val_focus,set_focus
492
- } )
493
-
494
- if ( onKeyDown ) onKeyDown( event )
495
- if ( enableFormSubmit ) SubmitForm( event )
496
- } }
497
- onKeyUp={ ( event ) => {
498
- if ( event.key == 'Tab' ) set_focus( {
499
- ...val_focus,
500
- active: true
501
- } )
502
- } }
503
- onClick={ ( event ) => {
504
- let caretTo = ( event.target as HTMLInputElement ).selectionEnd as number
505
- let Index = 0
506
-
507
- val_status.ranges.forEach( ( range,index ) => {
508
- let { from,length,region } = range
509
- if ( from <= caretTo && caretTo <= ( from + ( region || length ) ) ) {
510
- Index = index
511
- }
512
- } )
513
- set_focus( {
514
- ...val_focus,
515
- active: true,
516
- index: Index
517
- } )
518
- event.preventDefault()
519
- } }
520
- onChange={ () => { } }
521
- { ...others }
522
- /> }
523
- </BoxWrapper>
524
- }
525
-
526
- const KeyDownEvent = ( props: {
527
- restrict: amotify.fn.Input.Time.RestrictTypes
528
- event: React.KeyboardEvent<HTMLInputElement>
529
- val_era: amotify.fn.Input.Time.EraTypes
530
- val_status: amotify.fn.Input.Status.Time
531
- set_status: React.Dispatch<React.SetStateAction<amotify.fn.Input.Status.Time>>
532
- val_focus: FocusProps
533
- set_focus: React.Dispatch<React.SetStateAction<FocusProps>>
534
- } ) => {
535
- let {
536
- val_era,
537
- restrict,
538
- event,
539
- val_status,set_status,
540
- val_focus,set_focus
541
- } = props
542
-
543
- let { key,shiftKey,ctrlKey,metaKey } = event
544
- let auxKey = ctrlKey || metaKey
545
- let {
546
- selectionStart: caretFrom,
547
- selectionEnd: caretTo
548
- } = event.target as HTMLInputElement
549
-
550
- let {
551
- index: currentFocusIndex,
552
- prevIndex: prevFocusIndex
553
- } = val_focus
554
- let {
555
- ranges,
556
- formatValue
557
- } = val_status
558
- let maxFocusIndex = ranges.length - 1
559
-
560
- if ( [ 'Tab','ArrowLeft','ArrowRight' ].includes( key ) ) {
561
- let nextFocusIndex = 0
562
- if ( key == 'Tab' ) {
563
- let direction = Number( !shiftKey ) * 2 - 1
564
- nextFocusIndex = val_focus.index + direction
565
- if ( nextFocusIndex < 0 || nextFocusIndex > maxFocusIndex ) return
566
- } else {
567
- let direction = key == 'ArrowLeft' ? -1 : key == 'ArrowRight' ? 1 : 0
568
-
569
- if ( auxKey ) {
570
- nextFocusIndex = direction == 1 ? maxFocusIndex : 0
571
- } else {
572
- if ( caretFrom == 0 && caretTo == String( val_status.formatValue ).length ) {
573
- nextFocusIndex = direction == 1 ? maxFocusIndex : 0
574
- } else {
575
- nextFocusIndex = Math.max( 0,Math.min( currentFocusIndex + direction,maxFocusIndex ) )
576
- }
577
- }
578
- }
579
- set_focus( {
580
- ...val_focus,
581
- index: nextFocusIndex,
582
- prevIndex: currentFocusIndex
583
- } )
584
- event.preventDefault()
585
- }
586
-
587
- if ( [ 'Backspace','ArrowUp','ArrowDown','0','1','2','3','4','5','6','7','8','9' ].includes( key ) ) {
588
- event.preventDefault()
589
-
590
- let nextFocusIndex = currentFocusIndex
591
- nextFocusIndex = Math.max( nextFocusIndex,0 )
592
- nextFocusIndex = Math.min( nextFocusIndex,maxFocusIndex )
593
- let {
594
- type,
595
- from,
596
- length
597
- } = ranges[ nextFocusIndex ]
598
-
599
- let prevValue: any = formatValue.slice( from,( from + length ) )
600
- let partsValue: any
601
-
602
- if ( key == 'Backspace' ) {
603
- partsValue = '------'.slice( 0,length )
604
- } else if ( [ 'ArrowUp','ArrowDown' ].includes( key ) ) {
605
- let direction = key == 'ArrowUp' ? 1 : -1
606
-
607
- prevValue = prevValue | 0
608
- partsValue = prevValue + direction
609
-
610
- let [ min,max,range ] =
611
- type == 'dateWareki' ?
612
- val_era == 'year' ? [ 0,2999,4 ]
613
- : val_era == 'reiwa' ? [ 1,2999,4 ]
614
- : val_era == 'heisei' ? [ 1,31,4 ]
615
- : val_era == 'shouwa' ? [ 1,64,4 ]
616
- : val_era == 'taisho' ? [ 1,15,4 ]
617
- : val_era == 'meiji' ? [ 1,45,4 ] : [ 0,0,0 ]
618
- : type == 'minute' ? [ 0,59,2 ]
619
- : type == 'hour' ? [ 0,23,2 ]
620
- : type == 'date' ? [ 1,31,2 ]
621
- : type == 'week' ? [ 1,53,2 ]
622
- : type == 'month' ? [ 1,12,2 ]
623
- : type == 'year' ? [ 0,2999,4 ] : [ 0,0,0 ]
624
-
625
- if ( partsValue > max ) partsValue = min
626
- else if ( partsValue < min ) partsValue = max
627
- partsValue = ( Number( partsValue ) ).zeroEmbed( range )
628
- } else if ( [ '0','1','2','3','4','5','6','7','8','9' ].includes( key ) ) {
629
- let prev = prevValue | 0
630
- let add = key
631
- let compound: any = `${ prev }${ add }`
632
-
633
- if ( prevFocusIndex != currentFocusIndex && prevFocusIndex >= 0 ) {
634
- prev = 0,compound = '0' + add
635
- }
636
-
637
- if ( type == 'year' || ( type == 'dateWareki' && val_era == 'year' ) ) {
638
- if ( Number( compound ) > 10000 ) partsValue = add
639
- else partsValue = compound
640
-
641
- if ( ( partsValue | 0 ) > 1000 ) nextFocusIndex++
642
- } else if (
643
- [ 'hour','minute','date','week','month' ].includes( type ) ||
644
- ( type == 'dateWareki' && val_era != 'year' )
645
- ) {
646
- let base =
647
- type == 'dateWareki' ?
648
- val_era == 'reiwa' ? 100
649
- : val_era == 'heisei' ? 31
650
- : val_era == 'shouwa' ? 64
651
- : val_era == 'taisho' ? 15
652
- : val_era == 'meiji' ? 45 : 0
653
- : type == 'minute' ? 59
654
- : type == 'hour' ? 23
655
- : type == 'date' ? 31
656
- : type == 'week' ? 53
657
- : type == 'month' ? 12 : 0
658
-
659
- partsValue = ( compound | 0 ) > base ? add : compound
660
-
661
- if ( Number( add ) > Number( String( base )[ 0 ] ) ||
662
- (
663
- prevValue == '0000'.slice( 0,String( base ).length ) && (
664
- compound != '0000'.slice( 0,String( base ).length ) ||
665
- ( [ 'minute','hour' ].includes( type ) && prevFocusIndex == currentFocusIndex )
666
- )
667
- ) || ( compound | 0 ) >= ( 10 ** ( String( base ).length - 1 ) )
668
- ) nextFocusIndex++
669
- }
670
-
671
- if ( type == 'year' || type == 'dateWareki' ) partsValue = ( partsValue | 0 ).zeroEmbed( 4 )
672
- else partsValue = ( partsValue | 0 ).zeroEmbed( 2 )
673
- }
674
-
675
- {
676
- let nextFormatValue = String( formatValue ).partReplace( from,String( partsValue ) )
677
- let nextDataValue = nextFormatValue.split( PeriodMargin ).map( ( value ) => {
678
- return value
679
- .replace( /(^\D|\D$)/,'' )
680
- .split( /\D+/ )
681
- .join( restrict == 'clock' ? ':' : '/' )
682
- .replace( /(^\D|\D$)/,'' )
683
- } )
684
- if ( restrict == 'dateWareki' ) {
685
- let v = nextDataValue[ 0 ].split( /\D/ )
686
- let [ year,month,day ] = v
687
- if ( v.length == 3 && year ) {
688
- let yearYear: any = Number( year ) - 1 + Number(
689
- {
690
- year: 1,reiwa: 2019,heisei: 1989,shouwa: 1926,taisho: 1912,meiji: 1868
691
- }[ val_era as string ]
692
- )
693
- nextDataValue = [ [ yearYear,month,day ].join( '/' ) ]
694
- }
695
- }
696
-
697
- nextFocusIndex = Math.max( nextFocusIndex,0 )
698
- nextFocusIndex = Math.min( nextFocusIndex,maxFocusIndex )
699
-
700
- set_status( {
701
- ...val_status,
702
- dataValue: [ 'dates','months' ].includes( restrict ) ? nextDataValue : nextDataValue[ 0 ],
703
- formatValue: nextFormatValue,
704
- eventType: 'update',
705
- eventID: $.uuidGen(),
706
- } )
707
- set_focus( {
708
- ...val_focus,
709
- index: nextFocusIndex,
710
- prevIndex: val_focus.index
711
- } )
712
- }
713
- }
714
- }
715
-
716
-
717
- export const TimeFNs: amotify.fn.Input.Time.FNTypes = {
718
- picker: {
719
- launch: ( params ) => {
720
- let tipsID = params.tipsID || $.uuidGen()
721
-
722
- Tooltips.open( {
723
- gravityPoint: params.gravityPoint || 24,
724
- padding: '1/2',
725
- tipsID,
726
- ...params,
727
- close_option: {
728
- aroundClick: true,
729
- elementBlur: false,
730
- ...params.close_option
731
- },
732
- content: <Picker
733
- restrict={ params.restrict }
734
- min={ params.min }
735
- max={ params.max }
736
- era={ params.era }
737
- defaultValue={ params.defaultValue }
738
- tipsID={ tipsID }
739
- onValueUpdate={ ( value,era ) => {
740
- params.onValueUpdate( value,era )
741
- } }
742
- />
743
- } )
744
- },
745
- remove: ( tipsID ) => {
746
- Tooltips.close( tipsID )
747
- }
748
- }
749
- }