amotify 0.0.2 → 0.0.4

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 (185) hide show
  1. package/dist/src/@jsminAmotifyExtension/_.d.ts +4 -0
  2. package/dist/src/@jsminAmotifyExtension/fetch.d.ts +9 -0
  3. package/dist/src/@jsminAmotifyExtension/formCollect.d.ts +1 -0
  4. package/dist/src/@jsminAmotifyExtension/spreadSheet.d.ts +4 -0
  5. package/dist/src/@jsminAmotifyExtension/variables.d.ts +0 -0
  6. package/dist/src/@types/_.d.ts +6 -0
  7. package/dist/src/@types/amot.d.ts +260 -0
  8. package/dist/src/@types/fn.d.ts +1040 -0
  9. package/dist/src/@types/index.d.ts +62 -0
  10. package/dist/src/@types/jsminAmotifyExtension.d.ts +134 -0
  11. package/dist/src/@types/module.d.ts +2 -0
  12. package/dist/src/@types/state.d.ts +145 -0
  13. package/dist/src/Atoms/@export.d.ts +4 -0
  14. package/dist/src/Atoms/FAIcon/parts.d.ts +2 -0
  15. package/dist/src/Atoms/Logo/parts.d.ts +1 -0
  16. package/dist/src/Atoms/Various/parts.d.ts +9 -0
  17. package/dist/src/Functions/@export.d.ts +12 -0
  18. package/dist/src/Functions/Button/_.d.ts +1 -0
  19. package/dist/src/Functions/Cropper/parts.d.ts +1 -0
  20. package/dist/src/Functions/Effects/Fade.d.ts +1 -0
  21. package/dist/src/Functions/Effects/Ripple.d.ts +1 -0
  22. package/dist/src/Functions/Effects/_.d.ts +3 -0
  23. package/dist/src/Functions/Input/Chips/Selector.d.ts +1 -0
  24. package/dist/src/Functions/Input/Chips/_.d.ts +2 -0
  25. package/dist/src/Functions/Input/DigitCharacters.d.ts +1 -0
  26. package/dist/src/Functions/Input/File/_.d.ts +2 -0
  27. package/dist/src/Functions/Input/Hidden.d.ts +1 -0
  28. package/dist/src/Functions/Input/List/_.d.ts +1 -0
  29. package/dist/src/Functions/Input/Segmented/_.d.ts +1 -0
  30. package/dist/src/Functions/Input/Select/_.d.ts +1 -0
  31. package/dist/src/Functions/Input/Slider/_.d.ts +1 -0
  32. package/dist/src/Functions/Input/Switch/_.d.ts +1 -0
  33. package/dist/src/Functions/Input/Text.d.ts +5 -0
  34. package/dist/src/Functions/Input/TextArea.d.ts +1 -0
  35. package/dist/src/Functions/Input/Time/Picker.d.ts +1 -0
  36. package/dist/src/Functions/Input/Time/_.d.ts +2 -0
  37. package/dist/src/Functions/Input/_.d.ts +5 -0
  38. package/dist/src/Functions/Input/core.d.ts +34 -0
  39. package/dist/src/Functions/Inputs/_.d.ts +3 -0
  40. package/dist/src/Functions/Inputs/text.d.ts +12 -0
  41. package/dist/src/Functions/Layout/PageNotFound.d.ts +1 -0
  42. package/dist/src/Functions/Layout/PageRouter.d.ts +2 -0
  43. package/dist/src/Functions/Layout/PageViewController/parts.d.ts +1 -0
  44. package/dist/src/Functions/Layout/Plate.d.ts +1 -0
  45. package/dist/src/Functions/Layout/RootViewController/parts.d.ts +1 -0
  46. package/dist/src/Functions/Layout/SwipeView/parts.d.ts +2 -0
  47. package/dist/src/Functions/Layout/TabBar.d.ts +1 -0
  48. package/dist/src/Functions/Layout/_.d.ts +2 -0
  49. package/dist/src/Functions/Loader/corner.d.ts +1 -0
  50. package/dist/src/Functions/Loader/mini.d.ts +33 -0
  51. package/dist/src/Functions/Loader/parts.d.ts +3 -0
  52. package/dist/src/Functions/Loader/top.d.ts +1 -0
  53. package/dist/src/Functions/Sheet/parts.d.ts +2 -0
  54. package/dist/src/Functions/SnackBar/parts.d.ts +2 -0
  55. package/dist/src/Functions/Table/Data/parts.d.ts +3 -0
  56. package/dist/src/Functions/Table/Drag/parts.d.ts +1 -0
  57. package/dist/src/Functions/Table/Normal/parts.d.ts +1 -0
  58. package/dist/src/Functions/Table/_.d.ts +9 -0
  59. package/dist/src/Functions/Tooltips/parts.d.ts +2 -0
  60. package/dist/src/Global/@export.d.ts +12 -0
  61. package/dist/src/Global/LaunchReactApplication.d.ts +1 -0
  62. package/dist/src/Global/styleConverter.d.ts +2 -0
  63. package/dist/src/Molecules/@export.d.ts +21 -0
  64. package/dist/src/Molecules/Accordion/parts.d.ts +2 -0
  65. package/dist/src/Molecules/LinkifyText/parts.d.ts +1 -0
  66. package/dist/src/Molecules/List.d.ts +1 -0
  67. package/dist/src/Organisms/@export.d.ts +2 -0
  68. package/dist/src/Organisms/DisplayStyleInput/_.d.ts +1 -0
  69. package/dist/src/Organisms/DisplayStyleInput/darkmode.d.ts +1 -0
  70. package/dist/src/Organisms/DisplayStyleInput/themeColor.d.ts +27 -0
  71. package/dist/src/Templates/@export.d.ts +2 -0
  72. package/dist/src/Templates/PlayGround/parts.d.ts +1 -0
  73. package/dist/src/config.d.ts +16 -0
  74. package/dist/src/launch.d.ts +9 -0
  75. package/dist/src/preload.d.ts +1 -0
  76. package/package.json +2 -2
  77. package/src/@jsminAmotifyExtension/_.tsx +4 -0
  78. package/src/@jsminAmotifyExtension/fetch.tsx +107 -0
  79. package/src/@jsminAmotifyExtension/formCollect.tsx +89 -0
  80. package/src/@jsminAmotifyExtension/spreadSheet.tsx +159 -0
  81. package/src/@jsminAmotifyExtension/variables.tsx +130 -0
  82. package/src/@styles/@app.scss +4 -0
  83. package/src/@styles/@variables/customProps.scss +109 -0
  84. package/src/@styles/@variables/styleSet.scss +38 -0
  85. package/src/@styles/@variables/themeColor.scss +71 -0
  86. package/src/@styles/@variables/var.scss +171 -0
  87. package/src/@styles/UniStyling.scss +996 -0
  88. package/src/@styles/init.scss +154 -0
  89. package/src/@types/_.tsx +6 -0
  90. package/src/@types/amot.tsx +323 -0
  91. package/src/@types/fn.tsx +1210 -0
  92. package/src/@types/index.tsx +74 -0
  93. package/src/@types/jsminAmotifyExtension.tsx +143 -0
  94. package/src/@types/module.tsx +2 -0
  95. package/src/@types/state.tsx +199 -0
  96. package/src/Atoms/@export.tsx +32 -0
  97. package/src/Atoms/FAIcon/parts.tsx +117 -0
  98. package/src/Atoms/FAIcon/style.module.scss +9 -0
  99. package/src/Atoms/Logo/parts.tsx +335 -0
  100. package/src/Atoms/Logo/style.module.scss +96 -0
  101. package/src/Atoms/Various/parts.tsx +157 -0
  102. package/src/Atoms/Various/style.module.scss +40 -0
  103. package/src/Functions/@export.tsx +29 -0
  104. package/src/Functions/Button/_.tsx +305 -0
  105. package/src/Functions/Button/style.module.scss +183 -0
  106. package/src/Functions/Cropper/parts.tsx +1061 -0
  107. package/src/Functions/Cropper/style.module.scss +62 -0
  108. package/src/Functions/Effects/Fade.tsx +81 -0
  109. package/src/Functions/Effects/Ripple.tsx +141 -0
  110. package/src/Functions/Effects/_.tsx +33 -0
  111. package/src/Functions/Effects/style.module.scss +83 -0
  112. package/src/Functions/Input/Chips/Selector.tsx +451 -0
  113. package/src/Functions/Input/Chips/_.tsx +286 -0
  114. package/src/Functions/Input/Chips/style.module.scss +6 -0
  115. package/src/Functions/Input/DigitCharacters.tsx +241 -0
  116. package/src/Functions/Input/File/_.tsx +596 -0
  117. package/src/Functions/Input/File/style.module.scss +34 -0
  118. package/src/Functions/Input/Hidden.tsx +18 -0
  119. package/src/Functions/Input/List/_.tsx +383 -0
  120. package/src/Functions/Input/List/style.module.scss +84 -0
  121. package/src/Functions/Input/Segmented/_.tsx +238 -0
  122. package/src/Functions/Input/Segmented/style.module.scss +81 -0
  123. package/src/Functions/Input/Select/_.tsx +225 -0
  124. package/src/Functions/Input/Select/style.module.scss +10 -0
  125. package/src/Functions/Input/Slider/_.tsx +519 -0
  126. package/src/Functions/Input/Slider/style.module.scss +67 -0
  127. package/src/Functions/Input/Switch/_.tsx +177 -0
  128. package/src/Functions/Input/Switch/style.module.scss +18 -0
  129. package/src/Functions/Input/Text.tsx +437 -0
  130. package/src/Functions/Input/TextArea.tsx +115 -0
  131. package/src/Functions/Input/Time/Picker.tsx +950 -0
  132. package/src/Functions/Input/Time/_.tsx +736 -0
  133. package/src/Functions/Input/Time/style.module.scss +72 -0
  134. package/src/Functions/Input/_.tsx +793 -0
  135. package/src/Functions/Input/core.tsx +461 -0
  136. package/src/Functions/Input/style.module.scss +43 -0
  137. package/src/Functions/Inputs/_.tsx +5 -0
  138. package/src/Functions/Inputs/style.module.scss +15 -0
  139. package/src/Functions/Inputs/text.tsx +67 -0
  140. package/src/Functions/Inputs/types.d.ts +1 -0
  141. package/src/Functions/Layout/PageNotFound.tsx +81 -0
  142. package/src/Functions/Layout/PageRouter.tsx +107 -0
  143. package/src/Functions/Layout/PageViewController/parts.tsx +32 -0
  144. package/src/Functions/Layout/Plate.tsx +30 -0
  145. package/src/Functions/Layout/RootViewController/parts.tsx +290 -0
  146. package/src/Functions/Layout/RootViewController/style.module.scss +24 -0
  147. package/src/Functions/Layout/SwipeView/parts.tsx +380 -0
  148. package/src/Functions/Layout/SwipeView/style.module.scss +19 -0
  149. package/src/Functions/Layout/TabBar.tsx +64 -0
  150. package/src/Functions/Layout/_.tsx +20 -0
  151. package/src/Functions/Loader/corner.tsx +78 -0
  152. package/src/Functions/Loader/mini.tsx +117 -0
  153. package/src/Functions/Loader/parts.tsx +105 -0
  154. package/src/Functions/Loader/style.module.scss +222 -0
  155. package/src/Functions/Loader/top.tsx +90 -0
  156. package/src/Functions/Sheet/parts.tsx +972 -0
  157. package/src/Functions/Sheet/style.module.scss +235 -0
  158. package/src/Functions/SnackBar/parts.tsx +215 -0
  159. package/src/Functions/SnackBar/style.module.scss +25 -0
  160. package/src/Functions/Table/Data/parts.tsx +955 -0
  161. package/src/Functions/Table/Drag/parts.tsx +448 -0
  162. package/src/Functions/Table/Normal/parts.tsx +123 -0
  163. package/src/Functions/Table/_.tsx +170 -0
  164. package/src/Functions/Table/style.module.scss +92 -0
  165. package/src/Functions/Tooltips/parts.tsx +52 -0
  166. package/src/Global/@export.tsx +138 -0
  167. package/src/Global/LaunchReactApplication.tsx +30 -0
  168. package/src/Global/exe.tsx +0 -0
  169. package/src/Global/styleConverter.tsx +435 -0
  170. package/src/Molecules/@export.tsx +95 -0
  171. package/src/Molecules/Accordion/parts.tsx +146 -0
  172. package/src/Molecules/Accordion/style.module.scss +13 -0
  173. package/src/Molecules/LinkifyText/parts.tsx +54 -0
  174. package/src/Molecules/List.tsx +30 -0
  175. package/src/Organisms/@export.tsx +5 -0
  176. package/src/Organisms/DisplayStyleInput/_.tsx +18 -0
  177. package/src/Organisms/DisplayStyleInput/darkmode.tsx +112 -0
  178. package/src/Organisms/DisplayStyleInput/themeColor.tsx +210 -0
  179. package/src/Templates/@export.tsx +7 -0
  180. package/src/Templates/PlayGround/parts.tsx +115 -0
  181. package/src/Templates/PlayGround/style.module.scss +38 -0
  182. package/src/config.tsx +132 -0
  183. package/src/launch.tsx +100 -0
  184. package/src/preload.tsx +49 -0
  185. package/tsconfig.json +27 -14
@@ -0,0 +1,448 @@
1
+ import {
2
+ useStore
3
+ } from '@global';
4
+ import {
5
+ FAIcon
6
+ } from '@atoms';
7
+ import {
8
+ Buttons,
9
+ Tooltips,
10
+ } from '@functions';
11
+ const {
12
+ useState,
13
+ useEffect,
14
+ } = React;
15
+
16
+ import {
17
+ Comps,
18
+ DefaultCellSystemStyles
19
+ } from '../_';
20
+
21
+ import style from '../style.module.scss';
22
+
23
+ const HeadRow: FNC<amotify.fn.Tables.Drag.Params> = ( props ) => {
24
+ let {
25
+ cellStyles = {},
26
+ cellClassName = '',
27
+ cellStylesCallback,
28
+ colLength,
29
+ head,
30
+ rows
31
+ } = props;
32
+
33
+ if ( !head ) return null;
34
+
35
+ let Cols = [];
36
+
37
+ for ( let colIndex = 0; colIndex < colLength; colIndex++ ) {
38
+ let col = head[ colIndex ];
39
+
40
+ let Cell = Comps[ col.type == 'th' ? 'TH' : 'TD' ];
41
+ Cols.push( <Cell
42
+ { ...cellStyles }
43
+ { ...DefaultCellSystemStyles( {
44
+ top: true,
45
+ bottom: !rows.length,
46
+ left: colIndex == 0,
47
+ right: colIndex == colLength - 1
48
+ } ) }
49
+ { ...cellStylesCallback ? cellStylesCallback( {
50
+ top: true,
51
+ bottom: !rows.length,
52
+ left: colIndex == 0,
53
+ right: colIndex == colLength - 1,
54
+ rowIndex: 0,
55
+ colIndex,
56
+ isBody: false,
57
+ isHeader: true,
58
+ } ) : {} }
59
+ className={ [
60
+ style.Cell,
61
+ cellClassName,
62
+ col.className,
63
+ ].join( ' ' ) }
64
+ { ...col }
65
+ /> );
66
+ }
67
+
68
+ return ( <Comps.Row
69
+ className={ [ style.Row,style.HeadRow ].join( ' ' ) }
70
+ children={ Cols }
71
+ /> );
72
+ }
73
+ const BodyRows: FNC<amotify.fn.Tables.Drag.Params> = ( props ) => {
74
+ let {
75
+ cellStyles = {},
76
+ cellClassName = '',
77
+ cellStylesCallback,
78
+ head,
79
+ rows,
80
+ colLength,
81
+ onOrderChanged
82
+ } = props;
83
+
84
+ let [ val_componentID ] = useState( $.uuidGen() );
85
+ let [ val_info,set_info ] = useState( {
86
+ rows: rows,
87
+ origin: 0,
88
+ to: NaN
89
+ } );
90
+
91
+ let BodyRows: ReactElement[] = [];
92
+
93
+ val_info.rows.forEach( ( cols,rowIndex ) => {
94
+ let Cols: ReactElement[] = [];
95
+ {
96
+ Cols.push( <Comps.TH
97
+ key={ 'DragOrigin' }
98
+ { ...cellStyles }
99
+ { ...DefaultCellSystemStyles( {
100
+ top: rowIndex == 0 && !head,
101
+ bottom: rowIndex == rows.length - 1,
102
+ left: true,
103
+ right: false
104
+ } ) }
105
+ { ...cellStylesCallback ? cellStylesCallback( {
106
+ top: rowIndex == 0 && !head,
107
+ bottom: rowIndex == rows.length - 1,
108
+ left: true,
109
+ right: false,
110
+ rowIndex,
111
+ colIndex: 0,
112
+ isBody: true,
113
+ isHeader: false,
114
+ } ) : {} }
115
+ padding={ 0 }
116
+ borderRight
117
+ className={ [
118
+ style.Cell,
119
+ style.Draggable,
120
+ cellClassName
121
+ ].join( ' ' ) }
122
+ >
123
+ <Buttons.Button.Clear.R
124
+ className={ style.DragableButton }
125
+ fontColor={ '5.translucent' }
126
+ fontSize={ '3.paragraph' }
127
+ margin={ 'auto' }
128
+ tabIndex={ -1 }
129
+ ssSphere={ 3 }
130
+ onMouseDown={ ( event ) => {
131
+ EffectStart( event,{
132
+ id: val_componentID,
133
+ index: rowIndex,
134
+ rows: val_info.rows,
135
+ maxLength: rows.length
136
+ } );
137
+ } }
138
+ onTouchStart={ ( event ) => {
139
+ EffectStart( event,{
140
+ id: val_componentID,
141
+ index: rowIndex,
142
+ rows: val_info.rows,
143
+ maxLength: rows.length
144
+ } );
145
+ } }
146
+ >
147
+ <FAIcon
148
+ d='grip-dots-vertical'
149
+ />
150
+ </Buttons.Button.Clear.R>
151
+ </Comps.TH> );
152
+ }
153
+
154
+ cols.forEach( ( col,colIndex ) => {
155
+ col = { ...col as any }
156
+
157
+ let Cell = Comps[ col.type == 'th' ? 'TH' : 'TD' ];
158
+ Cols.push( <Cell
159
+ { ...cellStyles }
160
+ { ...DefaultCellSystemStyles( {
161
+ top: !!head && !head.length,
162
+ bottom: rowIndex == rows.length - 1,
163
+ left: false,
164
+ right: colIndex == colLength - 2
165
+ } ) }
166
+ { ...cellStylesCallback ? cellStylesCallback( {
167
+ top: !!head && !head.length,
168
+ bottom: rowIndex == rows.length - 1,
169
+ left: false,
170
+ right: colIndex == colLength - 2,
171
+ rowIndex,
172
+ colIndex,
173
+ isBody: true,
174
+ isHeader: false,
175
+ } ) : {} }
176
+ className={ [
177
+ style.Cell,
178
+ cellClassName,
179
+ col.className,
180
+ ].join( ' ' ) }
181
+ { ...col }
182
+ /> );
183
+ } );
184
+
185
+ BodyRows.push( <Comps.Row
186
+ key={ rowIndex }
187
+ id={ 'TableRow-' + val_componentID + '-' + rowIndex }
188
+ data-rowId={ rowIndex }
189
+ className={ [ style.Row,style.BodyRow ].join( ' ' ) }
190
+ children={ Cols }
191
+ /> );
192
+ } );
193
+
194
+ if ( !isNaN( val_info.to ) ) {
195
+ let {
196
+ origin,
197
+ to
198
+ } = val_info;
199
+ let Cols = [];
200
+ Cols.push( <Comps.TH
201
+ key={ 'dragButton' }
202
+ backgroundColor='tcOpLow'
203
+ padding={ 0 }
204
+ borderRight={ '2.normal' }
205
+ className={ [
206
+ style.Cell,
207
+ style.Draggable,
208
+ cellClassName
209
+ ].join( ' ' ) }
210
+ >
211
+ <FAIcon.ArrowRight
212
+ fontColor='theme'
213
+ />
214
+ </Comps.TH> );
215
+
216
+ let cols = val_info.rows[ origin ];
217
+ cols.forEach( ( col,colIndex ) => {
218
+ col = { ...col as any }
219
+
220
+ let Cell = Comps[ col.type == 'th' ? 'TH' : 'TD' ];
221
+ Cols.push( <Cell
222
+ { ...cellStyles }
223
+ { ...DefaultCellSystemStyles( {
224
+ top: false,
225
+ bottom: false,
226
+ left: false,
227
+ right: false
228
+ } ) }
229
+ { ...cellStylesCallback ? cellStylesCallback( {
230
+ top: false,
231
+ bottom: false,
232
+ left: false,
233
+ right: false,
234
+ rowIndex: -1,
235
+ colIndex: -1,
236
+ isBody: true,
237
+ isHeader: false,
238
+ } ) : {} }
239
+ className={ [
240
+ style.Cell,
241
+ cellClassName,
242
+ col.className,
243
+ ].join( ' ' ) }
244
+ backgroundColor='tcOpLow'
245
+ { ...col }
246
+ /> );
247
+ } );
248
+
249
+ BodyRows.splice( to,0,<Comps.Row
250
+ key={ 'preSet' }
251
+ className={ [ style.Row,style.Pre ].join( ' ' ) }
252
+ children={ Cols }
253
+ /> )
254
+ }
255
+
256
+ useEffect( () => {
257
+ useStore.set( {
258
+ key: val_componentID,
259
+ value: {
260
+ swap: ( rowIndex: number,insertIndex: number ) => {
261
+ if ( insertIndex || insertIndex == 0 ) {
262
+ let targetRow = val_info.rows[ rowIndex ];
263
+
264
+ let newRows = [ ...val_info.rows ];
265
+ newRows.splice( rowIndex,1 );
266
+ newRows.splice( insertIndex - ( rowIndex < insertIndex ? 1 : 0 ),0,targetRow );
267
+
268
+ set_info( {
269
+ rows: newRows,
270
+ origin: 0,
271
+ to: NaN
272
+ } );
273
+
274
+ onOrderChanged( newRows.map( ( row ) => JSON.parse( row.rowID ) ) );
275
+ }
276
+ },
277
+ preSet: ( props: {
278
+ origin: number,
279
+ index: number
280
+ } ) => {
281
+ let {
282
+ origin,index
283
+ } = props;
284
+
285
+ set_info( {
286
+ rows: val_info.rows,
287
+ origin: origin,
288
+ to: index
289
+ } );
290
+ }
291
+ }
292
+ } )
293
+ } );
294
+ useEffect( () => {
295
+ return () => {
296
+ useStore.delete( val_componentID );
297
+ }
298
+ },[] );
299
+
300
+ return ( <>
301
+ { BodyRows }
302
+ </> );
303
+ }
304
+
305
+
306
+ export const DragTable: FNC<amotify.fn.Tables.Drag.Params> = ( params ) => {
307
+ params.colLength = params.colLength + 1;
308
+
309
+ if ( params.head ) {
310
+ params.head = [
311
+ {
312
+ children: <Buttons.Button.Plain
313
+ ssSphere={ 3 }
314
+ fontSize={ '3.paragraph' }
315
+ fontColor={ 'theme' }
316
+ onMouseOver={ ( event ) => {
317
+ Tooltips.open( {
318
+ parent: event.currentTarget,
319
+ padding: [ 0,1 ],
320
+ content: <Tooltips.Comps.Body>
321
+ <FAIcon
322
+ d='grip-dots-vertical'
323
+ />
324
+ ボタンをドラッグして順序を変更
325
+ </Tooltips.Comps.Body>
326
+ } );
327
+ } }
328
+ >
329
+ <FAIcon.QuestionCircle />
330
+ </Buttons.Button.Plain>,
331
+ padding: [ 0,1 ],
332
+ unitWidth: 4
333
+ },
334
+ ...params.head
335
+ ];
336
+ }
337
+ params.rows = params.rows.map( ( row,rowIndex ) => {
338
+ row.rowID = JSON.stringify( row.rowID || rowIndex );
339
+ return row;
340
+ } );
341
+
342
+ return ( <Comps.Table className={ style.Table }>
343
+ <HeadRow { ...params } />
344
+ <BodyRows { ...params } />
345
+ </Comps.Table> );
346
+ }
347
+
348
+ type InfoParams = {
349
+ id: string
350
+ index: number
351
+ maxLength: number
352
+ rows: amotify.fn.Tables.Drag.BodyRowParams[]
353
+ insertIndex?: number
354
+ }
355
+
356
+ const EffectStart = async function ( event: any,info: InfoParams ) {
357
+ event.stopPropagation();
358
+ event.preventDefault();
359
+
360
+ let {
361
+ id,
362
+ index,
363
+ rows,
364
+ maxLength
365
+ } = info;
366
+
367
+ $( '#TableRow-' + id + '-' + index ).addClass( style.DraggerOrigin );
368
+
369
+ $( document )
370
+ .addEvent( {
371
+ eventID: 'DragMouseMove',
372
+ eventType: 'mousemove',
373
+ callback: ( event ) => { EffectMove( event,info ) },
374
+ option: { passive: false }
375
+ } )
376
+ .addEvent( {
377
+ eventID: 'DragTouchMove',
378
+ eventType: 'touchmove',
379
+ callback: ( event ) => { EffectMove( event,info ) },
380
+ option: { passive: false }
381
+ } )
382
+ .addEvent( {
383
+ eventID: 'DragMouseUp',
384
+ eventType: 'mouseup',
385
+ callback: ( event ) => { EffectEnd( event,info ) }
386
+ } )
387
+ .addEvent( {
388
+ eventID: 'DragTouchEnd',
389
+ eventType: 'touchend',
390
+ callback: ( event ) => { EffectEnd( event,info ) }
391
+ } );
392
+ }
393
+ const EffectMove = function ( event: any,info: InfoParams ) {
394
+ let {
395
+ id,
396
+ maxLength
397
+ } = info;
398
+
399
+ let Y = $.getCursor( event ).y - $.getScreenSize().scrollY;
400
+
401
+ for ( let rowIndex = 0; rowIndex < maxLength; rowIndex++ ) {
402
+ let Row = $( '#TableRow-' + id + '-' + rowIndex );
403
+ let {
404
+ top: rT,
405
+ bottom: rB,
406
+ height: rH
407
+ } = Row.position();
408
+
409
+ if ( rowIndex == 0 && Y < rT ) {
410
+ info.insertIndex = 0;
411
+ } else if ( rowIndex === maxLength - 1 && rB <= Y ) {
412
+ info.insertIndex = maxLength;
413
+ } else if ( Y >= rT && Y < rB ) {
414
+ info.insertIndex = rowIndex + 1;
415
+ }
416
+ }
417
+
418
+ {
419
+ let {
420
+ index,
421
+ insertIndex
422
+ } = info;
423
+
424
+ let component = useStore.get( id );
425
+ if ( component && component.preSet ) component.preSet( {
426
+ origin: index,
427
+ index: insertIndex
428
+ } );
429
+ }
430
+
431
+ event.stopPropagation();
432
+ event.preventDefault();
433
+ return false;
434
+ }
435
+ const EffectEnd = function ( event: any,info: InfoParams ) {
436
+ let {
437
+ id,
438
+ index,
439
+ insertIndex
440
+ } = info;
441
+
442
+ let component = useStore.get( id );
443
+ if ( component && component.swap ) component.swap( index,insertIndex );
444
+
445
+ $( '#TableRow-' + id + '-' + index ).removeClass( style.DraggerOrigin );
446
+
447
+ $( document ).removeEvent( [ 'DragMouseMove','DragTouchMove','DragMouseUp','DragTouchEnd' ] );
448
+ }
@@ -0,0 +1,123 @@
1
+ import style from '../style.module.scss';
2
+
3
+ import {
4
+ Comps,
5
+ DefaultCellSystemStyles
6
+ } from '../_';
7
+
8
+ const HeadRow: FNC<amotify.fn.Tables.Normal.Params> = ( params ) => {
9
+ let {
10
+ cellStyles = {},
11
+ cellClassName = '',
12
+ cellStylesCallback,
13
+ colLength,
14
+ head,
15
+ rows
16
+ } = params;
17
+
18
+ if ( !head ) return null;
19
+
20
+ let Cols: ReactElement[] = [];
21
+ head.forEach( ( col,colIndex ) => {
22
+ let Cell = Comps[ col.type == 'th' ? 'TH' : 'TD' ];
23
+ Cols.push( <Cell
24
+ { ...cellStyles }
25
+ { ...DefaultCellSystemStyles( {
26
+ top: true,
27
+ bottom: !rows.length,
28
+ left: colIndex == 0,
29
+ right: colIndex == colLength - 1
30
+ } ) }
31
+ { ...cellStylesCallback ? cellStylesCallback( {
32
+ top: true,
33
+ bottom: !rows.length,
34
+ left: colIndex == 0,
35
+ right: colIndex == colLength - 1,
36
+ rowIndex: 0,
37
+ colIndex,
38
+ isBody: false,
39
+ isHeader: true,
40
+ } ) : {} }
41
+ className={ [
42
+ style.Cell,
43
+ cellClassName,
44
+ col.className,
45
+ ].join( ' ' ) }
46
+ { ...col }
47
+ /> );
48
+ } )
49
+
50
+ return ( <Comps.Row
51
+ className={ [ style.Row,style.HeadRow ].join( ' ' ) }
52
+ children={ Cols }
53
+ /> );
54
+ }
55
+ const BodyRows: FNC<amotify.fn.Tables.Normal.Params> = ( params ) => {
56
+ let {
57
+ cellStyles = {},
58
+ cellClassName = '',
59
+ cellStylesCallback,
60
+ head,
61
+ rows,
62
+ colLength,
63
+ onRowClick,
64
+ } = params;
65
+
66
+ let BodyRows: ReactElement[] = [];
67
+ rows.forEach( ( cols,rowIndex ) => {
68
+ let Cols: ReactElement[] = [];
69
+ cols.forEach( ( col,colIndex ) => {
70
+ let Cell = Comps[ col.type == 'th' ? 'TH' : 'TD' ];
71
+ Cols.push( <Cell
72
+ { ...cellStyles }
73
+ { ...DefaultCellSystemStyles( {
74
+ top: rowIndex == 0 && !head,
75
+ bottom: rowIndex == rows.length - 1,
76
+ left: colIndex == 0,
77
+ right: colIndex == colLength - 1
78
+ } ) }
79
+ { ...cellStylesCallback ? cellStylesCallback( {
80
+ top: rowIndex == 0 && !head,
81
+ bottom: rowIndex == rows.length - 1,
82
+ left: colIndex == 0,
83
+ right: colIndex == colLength - 1,
84
+ rowIndex,
85
+ colIndex,
86
+ isBody: true,
87
+ isHeader: false,
88
+ } ) : {} }
89
+ className={ [
90
+ style.Cell,
91
+ cellClassName,
92
+ col.className,
93
+ ].join( ' ' ) }
94
+ { ...col }
95
+ /> );
96
+ } );
97
+
98
+ BodyRows.push( <Comps.Row
99
+ key={ rowIndex }
100
+ className={ [ style.Row,style.BodyRow ].join( ' ' ) }
101
+ children={ Cols }
102
+ onClick={ ( event ) => {
103
+ if ( onRowClick ) onRowClick( cols.rowID as any,event );
104
+ } }
105
+ /> );
106
+ } );
107
+
108
+ return ( <>
109
+ { BodyRows }
110
+ </> );
111
+ }
112
+
113
+ export const NormalTable: FNC<amotify.fn.Tables.Normal.Params> = ( params ) => {
114
+ params.rows = params.rows.map( ( row,rowIndex ) => {
115
+ row.rowID = row.rowID || rowIndex;
116
+ return row;
117
+ } );
118
+
119
+ return ( <Comps.Table className={ style.Table }>
120
+ <HeadRow { ...params } />
121
+ <BodyRows { ...params } />
122
+ </Comps.Table> );
123
+ }