amotify 0.0.6 → 0.0.8
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/@jsminAmotifyExtension/formCollect.js +2 -2
- package/dist/Atoms/Logo/parts.js +11 -11
- package/dist/Atoms/Various/parts.js +5 -5
- package/dist/Functions/Button/_.js +5 -5
- package/dist/Functions/Cropper/parts.js +47 -47
- package/dist/Functions/Effects/Fade.js +5 -5
- package/dist/Functions/Input/Chips/Selector.js +32 -32
- package/dist/Functions/Input/Chips/_.js +10 -10
- package/dist/Functions/Input/DigitCharacters.js +8 -8
- package/dist/Functions/Input/File/_.js +33 -33
- package/dist/Functions/Input/List/_.js +17 -17
- package/dist/Functions/Input/Segmented/_.js +13 -13
- package/dist/Functions/Input/Select/_.js +12 -12
- package/dist/Functions/Input/Slider/_.js +16 -16
- package/dist/Functions/Input/Switch/_.js +12 -12
- package/dist/Functions/Input/Text.js +12 -12
- package/dist/Functions/Input/TextArea.js +4 -4
- package/dist/Functions/Input/Time/Picker.js +65 -65
- package/dist/Functions/Input/Time/_.js +10 -10
- package/dist/Functions/Input/_.js +31 -31
- package/dist/Functions/Input/core.js +27 -27
- package/dist/Functions/Inputs/text.js +2 -2
- package/dist/Functions/Layout/PageNotFound.js +15 -15
- package/dist/Functions/Layout/PageRouter.js +5 -5
- package/dist/Functions/Layout/PageViewController/parts.js +5 -5
- package/dist/Functions/Layout/Plate.js +2 -2
- package/dist/Functions/Layout/RootViewController/parts.js +22 -22
- package/dist/Functions/Layout/SwipeView/parts.js +6 -6
- package/dist/Functions/Layout/TabBar.js +7 -7
- package/dist/Functions/Loader/corner.js +13 -13
- package/dist/Functions/Loader/mini.js +4 -4
- package/dist/Functions/Loader/parts.js +9 -9
- package/dist/Functions/Loader/top.js +22 -22
- package/dist/Functions/Sheet/parts.js +46 -46
- package/dist/Functions/SnackBar/parts.js +16 -16
- package/dist/Functions/Table/Data/parts.js +72 -72
- package/dist/Functions/Table/Drag/parts.js +15 -15
- package/dist/Functions/Table/_.js +11 -11
- package/dist/Functions/Tooltips/parts.js +6 -6
- package/dist/Molecules/@export.js +14 -14
- package/dist/Molecules/Accordion/parts.js +10 -10
- package/dist/Molecules/LinkifyText/parts.js +4 -4
- package/dist/Molecules/List.js +3 -3
- package/dist/Organisms/DisplayStyleInput/darkmode.js +17 -17
- package/dist/Organisms/DisplayStyleInput/themeColor.js +25 -25
- package/dist/Templates/PlayGround/parts.js +22 -22
- package/dist/launch.js +12 -12
- package/package.json +1 -1
- package/public/amotify.js +47 -47
- package/src/@jsminAmotifyExtension/_.tsx +4 -0
- package/src/@jsminAmotifyExtension/fetch.tsx +107 -0
- package/src/@jsminAmotifyExtension/formCollect.tsx +89 -0
- package/src/@jsminAmotifyExtension/spreadSheet.tsx +159 -0
- package/src/@jsminAmotifyExtension/variables.tsx +130 -0
- package/src/@styles/@app.scss +4 -0
- package/src/@styles/UniStyling.scss +996 -0
- package/src/@styles/init.scss +154 -0
- package/src/@styles/props.scss +109 -0
- package/src/@styles/styleSet.scss +38 -0
- package/src/@styles/themeColor.scss +71 -0
- package/src/@styles/var.scss +171 -0
- package/src/@types/_.tsx +6 -0
- package/src/@types/amot.tsx +323 -0
- package/src/@types/fn.tsx +1210 -0
- package/src/@types/index.tsx +74 -0
- package/src/@types/jsminAmotifyExtension.tsx +143 -0
- package/src/@types/module.tsx +2 -0
- package/src/@types/state.tsx +199 -0
- package/src/Atoms/@export.tsx +32 -0
- package/src/Atoms/FAIcon/parts.tsx +117 -0
- package/src/Atoms/FAIcon/style.module.scss +9 -0
- package/src/Atoms/Logo/parts.tsx +335 -0
- package/src/Atoms/Logo/style.module.scss +96 -0
- package/src/Atoms/Various/parts.tsx +157 -0
- package/src/Atoms/Various/style.module.scss +40 -0
- package/src/Functions/@export.tsx +29 -0
- package/src/Functions/Button/_.tsx +305 -0
- package/src/Functions/Button/style.module.scss +183 -0
- package/src/Functions/Cropper/parts.tsx +1061 -0
- package/src/Functions/Cropper/style.module.scss +62 -0
- package/src/Functions/Effects/Fade.tsx +81 -0
- package/src/Functions/Effects/Ripple.tsx +141 -0
- package/src/Functions/Effects/_.tsx +33 -0
- package/src/Functions/Effects/style.module.scss +83 -0
- package/src/Functions/Input/Chips/Selector.tsx +451 -0
- package/src/Functions/Input/Chips/_.tsx +286 -0
- package/src/Functions/Input/Chips/style.module.scss +6 -0
- package/src/Functions/Input/DigitCharacters.tsx +241 -0
- package/src/Functions/Input/File/_.tsx +596 -0
- package/src/Functions/Input/File/style.module.scss +34 -0
- package/src/Functions/Input/Hidden.tsx +18 -0
- package/src/Functions/Input/List/_.tsx +383 -0
- package/src/Functions/Input/List/style.module.scss +84 -0
- package/src/Functions/Input/Segmented/_.tsx +238 -0
- package/src/Functions/Input/Segmented/style.module.scss +81 -0
- package/src/Functions/Input/Select/_.tsx +225 -0
- package/src/Functions/Input/Select/style.module.scss +10 -0
- package/src/Functions/Input/Slider/_.tsx +519 -0
- package/src/Functions/Input/Slider/style.module.scss +67 -0
- package/src/Functions/Input/Switch/_.tsx +177 -0
- package/src/Functions/Input/Switch/style.module.scss +18 -0
- package/src/Functions/Input/Text.tsx +437 -0
- package/src/Functions/Input/TextArea.tsx +115 -0
- package/src/Functions/Input/Time/Picker.tsx +950 -0
- package/src/Functions/Input/Time/_.tsx +736 -0
- package/src/Functions/Input/Time/style.module.scss +72 -0
- package/src/Functions/Input/_.tsx +793 -0
- package/src/Functions/Input/core.tsx +461 -0
- package/src/Functions/Input/style.module.scss +43 -0
- package/src/Functions/Inputs/_.tsx +5 -0
- package/src/Functions/Inputs/style.module.scss +15 -0
- package/src/Functions/Inputs/text.tsx +67 -0
- package/src/Functions/Inputs/types.d.ts +1 -0
- package/src/Functions/Layout/PageNotFound.tsx +81 -0
- package/src/Functions/Layout/PageRouter.tsx +107 -0
- package/src/Functions/Layout/PageViewController/parts.tsx +32 -0
- package/src/Functions/Layout/Plate.tsx +30 -0
- package/src/Functions/Layout/RootViewController/parts.tsx +290 -0
- package/src/Functions/Layout/RootViewController/style.module.scss +24 -0
- package/src/Functions/Layout/SwipeView/parts.tsx +380 -0
- package/src/Functions/Layout/SwipeView/style.module.scss +19 -0
- package/src/Functions/Layout/TabBar.tsx +64 -0
- package/src/Functions/Layout/_.tsx +20 -0
- package/src/Functions/Loader/corner.tsx +78 -0
- package/src/Functions/Loader/mini.tsx +117 -0
- package/src/Functions/Loader/parts.tsx +105 -0
- package/src/Functions/Loader/style.module.scss +222 -0
- package/src/Functions/Loader/top.tsx +90 -0
- package/src/Functions/Sheet/parts.tsx +972 -0
- package/src/Functions/Sheet/style.module.scss +235 -0
- package/src/Functions/SnackBar/parts.tsx +215 -0
- package/src/Functions/SnackBar/style.module.scss +25 -0
- package/src/Functions/Table/Data/parts.tsx +955 -0
- package/src/Functions/Table/Drag/parts.tsx +448 -0
- package/src/Functions/Table/Normal/parts.tsx +123 -0
- package/src/Functions/Table/_.tsx +170 -0
- package/src/Functions/Table/style.module.scss +92 -0
- package/src/Functions/Tooltips/parts.tsx +52 -0
- package/src/Global/@export.tsx +138 -0
- package/src/Global/LaunchReactApplication.tsx +30 -0
- package/src/Global/exe.tsx +0 -0
- package/src/Global/styleConverter.tsx +435 -0
- package/src/Molecules/@export.tsx +95 -0
- package/src/Molecules/Accordion/parts.tsx +146 -0
- package/src/Molecules/Accordion/style.module.scss +13 -0
- package/src/Molecules/LinkifyText/parts.tsx +54 -0
- package/src/Molecules/List.tsx +30 -0
- package/src/Organisms/@export.tsx +5 -0
- package/src/Organisms/DisplayStyleInput/_.tsx +18 -0
- package/src/Organisms/DisplayStyleInput/darkmode.tsx +112 -0
- package/src/Organisms/DisplayStyleInput/themeColor.tsx +210 -0
- package/src/Templates/@export.tsx +7 -0
- package/src/Templates/PlayGround/parts.tsx +116 -0
- package/src/Templates/PlayGround/style.module.scss +38 -0
- package/src/config.tsx +132 -0
- package/src/index.js +0 -0
- package/src/launch.tsx +100 -0
- package/src/preload.tsx +49 -0
- package/tsconfig.json +4 -22
- package/webpack.config.js +105 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useStore
|
|
3
|
+
} from '~/Global/@export';
|
|
4
|
+
const {
|
|
5
|
+
useEffect,
|
|
6
|
+
useState
|
|
7
|
+
} = React;
|
|
8
|
+
import {
|
|
9
|
+
Box,
|
|
10
|
+
Flex,
|
|
11
|
+
FAIcon
|
|
12
|
+
} from '~/Atoms/@export';
|
|
13
|
+
import {
|
|
14
|
+
Column,
|
|
15
|
+
Row,
|
|
16
|
+
Text
|
|
17
|
+
} from '~/Molecules/@export';
|
|
18
|
+
import {
|
|
19
|
+
Input,
|
|
20
|
+
Buttons,
|
|
21
|
+
SnackBar
|
|
22
|
+
} from '~/Functions/@export';
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
BoxWrapper,
|
|
26
|
+
SubmitForm,
|
|
27
|
+
ValidationCheck,
|
|
28
|
+
CommonEffects
|
|
29
|
+
} from '../core';
|
|
30
|
+
import style from './style.module.scss';
|
|
31
|
+
|
|
32
|
+
function DefaultValidation( props: {
|
|
33
|
+
value: any
|
|
34
|
+
params: any
|
|
35
|
+
} ): amotify.fn.Input.Validation.Result {
|
|
36
|
+
let { value,params } = props;
|
|
37
|
+
let { required } = params as amotify.fn.Input.Filer.PlainParams;
|
|
38
|
+
let notice: amotify.fn.Input.Validation.NoticeTypes[] = [];
|
|
39
|
+
|
|
40
|
+
if ( required && !value.length ) {
|
|
41
|
+
notice.push( { type: 'invalid',label: '必須項目です' } );
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
ok: !notice.filter( ( { type } ) => type == 'invalid' ).length,
|
|
46
|
+
notice: notice
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const FileComponent: FNC<amotify.fn.Input.Filer.PlainParams> = ( params ) => {
|
|
51
|
+
let {
|
|
52
|
+
tone,
|
|
53
|
+
required,
|
|
54
|
+
form,
|
|
55
|
+
|
|
56
|
+
fileNameEdit = true,
|
|
57
|
+
systemOnly = false,
|
|
58
|
+
accept = '*',
|
|
59
|
+
limit = 1,
|
|
60
|
+
|
|
61
|
+
checkValidationAtFirst,
|
|
62
|
+
onChange,
|
|
63
|
+
onValidate,
|
|
64
|
+
onUpdateValue,onUpdateValidValue,
|
|
65
|
+
value = [],
|
|
66
|
+
className,
|
|
67
|
+
|
|
68
|
+
cellStyles,cellClassName,
|
|
69
|
+
|
|
70
|
+
...others
|
|
71
|
+
} = params;
|
|
72
|
+
|
|
73
|
+
let Default_Status: amotify.fn.Input.Status.Plain = {
|
|
74
|
+
componentID: params.componentID || '',
|
|
75
|
+
dataValue: value,
|
|
76
|
+
eventType: 'init',
|
|
77
|
+
eventID: $.uuidGen()
|
|
78
|
+
}
|
|
79
|
+
let [ val_status,set_status ] = useState( Default_Status );
|
|
80
|
+
let [ val_validate,set_validate ] = useState( {
|
|
81
|
+
ok: false,
|
|
82
|
+
notice: []
|
|
83
|
+
} as amotify.fn.Input.Validation.Result );
|
|
84
|
+
|
|
85
|
+
CommonEffects( {
|
|
86
|
+
type: 'file',
|
|
87
|
+
params,
|
|
88
|
+
val_status,
|
|
89
|
+
set_status,
|
|
90
|
+
val_validate,
|
|
91
|
+
set_validate,
|
|
92
|
+
DefaultValidation,
|
|
93
|
+
onUpdateValue,onUpdateValidValue,
|
|
94
|
+
ExtraOverrideParams: {
|
|
95
|
+
dataValue: value,
|
|
96
|
+
formatValue: value,
|
|
97
|
+
},
|
|
98
|
+
ExtraStoreParams: {
|
|
99
|
+
AddFiles: async ( files: any[] ) => {
|
|
100
|
+
let currentFiles = useStore.get( val_status.componentID ).Files;
|
|
101
|
+
let newFiles = [];
|
|
102
|
+
for ( var i = 0; i < files?.length; i++ ) {
|
|
103
|
+
let file = files[ i ];
|
|
104
|
+
let { type,name } = file;
|
|
105
|
+
|
|
106
|
+
if ( i + 1 + currentFiles.length > limit ) {
|
|
107
|
+
SnackBar.add( {
|
|
108
|
+
componentID: name,
|
|
109
|
+
secondsToClose: 12000,
|
|
110
|
+
children: `ファイル選択上限を超えたため、${ name }}は追加できません。`,
|
|
111
|
+
backgroundColor: 'nega'
|
|
112
|
+
} );
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if ( accept ) {
|
|
117
|
+
if ( accept == 'image' ) {
|
|
118
|
+
if ( !type.match( /image/ ) ) {
|
|
119
|
+
SnackBar.add( {
|
|
120
|
+
componentID: name,
|
|
121
|
+
secondsToClose: 12000,
|
|
122
|
+
children: `ファイル形式が異なるため、${ name } は追加できません。`,
|
|
123
|
+
backgroundColor: 'nega'
|
|
124
|
+
} );
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
newFiles.push( file );
|
|
130
|
+
}
|
|
131
|
+
set_status( {
|
|
132
|
+
...val_status,
|
|
133
|
+
dataValue: [ ...currentFiles,...newFiles ],
|
|
134
|
+
eventType: 'update',
|
|
135
|
+
eventID: $.uuidGen(),
|
|
136
|
+
} );
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} );
|
|
140
|
+
|
|
141
|
+
let Accept = '';
|
|
142
|
+
if ( accept ) {
|
|
143
|
+
if ( accept == 'image' ) Accept = 'image/png,image/jpeg';
|
|
144
|
+
else Accept = accept;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<BoxWrapper
|
|
149
|
+
val_status={ val_status }
|
|
150
|
+
set_status={ set_status }
|
|
151
|
+
val_validate={ val_validate }
|
|
152
|
+
params={ params }
|
|
153
|
+
>
|
|
154
|
+
<input
|
|
155
|
+
type='file'
|
|
156
|
+
className={ style.Input }
|
|
157
|
+
data-form={ form }
|
|
158
|
+
data-input-type={ 'file' }
|
|
159
|
+
data-component-id={ val_status.componentID }
|
|
160
|
+
data-validation={ val_validate.ok }
|
|
161
|
+
accept={ Accept }
|
|
162
|
+
multiple={ limit == 1 ? false : true }
|
|
163
|
+
onChange={ async ( event ) => {
|
|
164
|
+
let Input = event.target;
|
|
165
|
+
let files = Input.files as any;
|
|
166
|
+
let newFiles = [];
|
|
167
|
+
for ( var i = 0; i < files?.length; i++ ) {
|
|
168
|
+
let file = files[ i ];
|
|
169
|
+
let fileName = file.name;
|
|
170
|
+
file.id = $.uuidGen();
|
|
171
|
+
|
|
172
|
+
if ( i + 1 + val_status.dataValue.length > limit ) {
|
|
173
|
+
SnackBar.add( {
|
|
174
|
+
componentID: fileName,
|
|
175
|
+
secondsToClose: 12000,
|
|
176
|
+
children: `ファイル登録数を超えたため、${ fileName }}は追加できませんでした。`,
|
|
177
|
+
backgroundColor: 'nega'
|
|
178
|
+
} );
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
newFiles.push( file );
|
|
182
|
+
}
|
|
183
|
+
set_status( {
|
|
184
|
+
...val_status,
|
|
185
|
+
dataValue: [ ...val_status.dataValue,...newFiles ],
|
|
186
|
+
eventType: 'update',
|
|
187
|
+
eventID: $.uuidGen(),
|
|
188
|
+
} );
|
|
189
|
+
Input.value = '';
|
|
190
|
+
} }
|
|
191
|
+
{ ...others }
|
|
192
|
+
tabIndex={ -1 }
|
|
193
|
+
value={ '' }
|
|
194
|
+
/>
|
|
195
|
+
{ !systemOnly ? <FileList
|
|
196
|
+
files={ val_status.dataValue }
|
|
197
|
+
params={ params }
|
|
198
|
+
val_status={ val_status }
|
|
199
|
+
set_status={ set_status }
|
|
200
|
+
/> : null }
|
|
201
|
+
</BoxWrapper>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const FileList: FNC<{
|
|
206
|
+
files: File[]
|
|
207
|
+
params: amotify.fn.Input.Filer.PlainParams
|
|
208
|
+
val_status: amotify.fn.Input.Status.Plain
|
|
209
|
+
set_status: React.Dispatch<React.SetStateAction<amotify.fn.Input.Status.Plain>>
|
|
210
|
+
}> = ( props ) => {
|
|
211
|
+
let {
|
|
212
|
+
files,
|
|
213
|
+
params,
|
|
214
|
+
val_status,
|
|
215
|
+
set_status
|
|
216
|
+
} = props;
|
|
217
|
+
let Left = ( params.limit || 1 ) - val_status.dataValue.length;
|
|
218
|
+
|
|
219
|
+
let Files = files.map( ( file,index ) => {
|
|
220
|
+
return (
|
|
221
|
+
<FileCell
|
|
222
|
+
key={ file.name }
|
|
223
|
+
index={ index }
|
|
224
|
+
file={ file }
|
|
225
|
+
className={ params.cellClassName }
|
|
226
|
+
val_status={ val_status }
|
|
227
|
+
set_status={ set_status }
|
|
228
|
+
fileNameEdit={ params.fileNameEdit }
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
231
|
+
} );
|
|
232
|
+
|
|
233
|
+
if ( Left > 0 ) {
|
|
234
|
+
Files.push(
|
|
235
|
+
<Buttons.Label.Plain
|
|
236
|
+
key={ 'AddButton' }
|
|
237
|
+
className={ [ params.cellClassName,style.AddButton ].join( ' ' ) }
|
|
238
|
+
htmlFor={ params.id }
|
|
239
|
+
tabIndex={ params.tabIndex }
|
|
240
|
+
onKeyDown={ ( event ) => {
|
|
241
|
+
let { key } = event;
|
|
242
|
+
if ( params.tabIndex != -1 ) {
|
|
243
|
+
if ( [ ' ','Enter' ].includes( key ) ) {
|
|
244
|
+
$( '#' + params.id ).click();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} }
|
|
248
|
+
>
|
|
249
|
+
<Row.Center
|
|
250
|
+
padding={ [ '1/3',0 ] }
|
|
251
|
+
>
|
|
252
|
+
<Box
|
|
253
|
+
isRounded
|
|
254
|
+
className={ style.AddIcon }
|
|
255
|
+
>
|
|
256
|
+
<FAIcon
|
|
257
|
+
d={ 'cloud-arrow-up' }
|
|
258
|
+
className={ style.Icon }
|
|
259
|
+
fontColor={ 'theme' }
|
|
260
|
+
backgroundColor={ 'tcOpLow' }
|
|
261
|
+
padding={ 0 }
|
|
262
|
+
unitWidth={ 4 }
|
|
263
|
+
unitHeight={ 4 }
|
|
264
|
+
isRounded
|
|
265
|
+
/>
|
|
266
|
+
</Box>
|
|
267
|
+
<Box>
|
|
268
|
+
<Box
|
|
269
|
+
children={ 'ファイルを選択' + `(${ Left })` }
|
|
270
|
+
fontColor={ 'theme' }
|
|
271
|
+
fontSize={ '2.normal' }
|
|
272
|
+
isBoldFont
|
|
273
|
+
/>
|
|
274
|
+
<Box
|
|
275
|
+
children={ 'または、ファイルをドロップ' }
|
|
276
|
+
fontColor={ '4.thin' }
|
|
277
|
+
fontSize={ '0.xs' }
|
|
278
|
+
/>
|
|
279
|
+
</Box>
|
|
280
|
+
</Row.Center>
|
|
281
|
+
</Buttons.Label.Plain>
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return ( <Column
|
|
286
|
+
flexSizing={ 'auto' }
|
|
287
|
+
className={ params.className }
|
|
288
|
+
children={ Files }
|
|
289
|
+
/>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const FileCell: FNC<{
|
|
294
|
+
index: number
|
|
295
|
+
file: File
|
|
296
|
+
className?: string
|
|
297
|
+
val_status: amotify.fn.Input.Status.Plain
|
|
298
|
+
set_status: React.Dispatch<React.SetStateAction<amotify.fn.Input.Status.Plain>>
|
|
299
|
+
fileNameEdit?: boolean
|
|
300
|
+
}> = ( props ) => {
|
|
301
|
+
let {
|
|
302
|
+
index,
|
|
303
|
+
file,
|
|
304
|
+
className,
|
|
305
|
+
val_status,
|
|
306
|
+
set_status,
|
|
307
|
+
fileNameEdit = true
|
|
308
|
+
} = props;
|
|
309
|
+
let {
|
|
310
|
+
name: fileName,
|
|
311
|
+
size,
|
|
312
|
+
type,
|
|
313
|
+
} = file;
|
|
314
|
+
|
|
315
|
+
let [ val_edit,set_edit ] = useState( false );
|
|
316
|
+
let FileID = $.uuidGen();
|
|
317
|
+
let Size = size.rank();
|
|
318
|
+
let [ name,extension ] = fileName
|
|
319
|
+
.replace( /\s/,'' )
|
|
320
|
+
.replace( /(.*)\.(.*)$/,'$1 $2' ).split( ' ' );
|
|
321
|
+
|
|
322
|
+
let FileType = {
|
|
323
|
+
name: '不明',
|
|
324
|
+
icon: 'fal file'
|
|
325
|
+
}
|
|
326
|
+
if ( type.match( /image/ ) ) {
|
|
327
|
+
FileType = {
|
|
328
|
+
name: type.replace( /image\//,'' ),
|
|
329
|
+
icon: 'image'
|
|
330
|
+
}
|
|
331
|
+
} else if ( type.match( /pdf/ ) ) {
|
|
332
|
+
FileType = {
|
|
333
|
+
name: 'PDF',
|
|
334
|
+
icon: 'file-pdf'
|
|
335
|
+
}
|
|
336
|
+
} else if ( type.match( /csv/ ) ) {
|
|
337
|
+
FileType = {
|
|
338
|
+
name: 'CSV',
|
|
339
|
+
icon: 'file-csv'
|
|
340
|
+
}
|
|
341
|
+
} else if ( type.match( /spreadsheet/ ) ) {
|
|
342
|
+
FileType = {
|
|
343
|
+
name: 'SpreadSheet',
|
|
344
|
+
icon: 'file-excel'
|
|
345
|
+
}
|
|
346
|
+
} else if ( type.match( /presentation/ ) ) {
|
|
347
|
+
FileType = {
|
|
348
|
+
name: 'PowerPoint',
|
|
349
|
+
icon: 'file-powerpoint'
|
|
350
|
+
}
|
|
351
|
+
} else if ( type.match( /word/ ) ) {
|
|
352
|
+
FileType = {
|
|
353
|
+
name: 'Word',
|
|
354
|
+
icon: 'file-word'
|
|
355
|
+
}
|
|
356
|
+
} else if ( type.match( /zip/ ) ) {
|
|
357
|
+
FileType = {
|
|
358
|
+
name: 'Zip',
|
|
359
|
+
icon: 'file-zipper'
|
|
360
|
+
}
|
|
361
|
+
} else if ( type.match( /powerpoint/ ) ) {
|
|
362
|
+
FileType = {
|
|
363
|
+
name: 'PowerPoint',
|
|
364
|
+
icon: 'file-powerpoint'
|
|
365
|
+
}
|
|
366
|
+
} else if ( type.match( /html/ ) ) {
|
|
367
|
+
FileType = {
|
|
368
|
+
name: 'HTML',
|
|
369
|
+
icon: 'fab html5'
|
|
370
|
+
}
|
|
371
|
+
} else if ( type.match( /js/ ) ) {
|
|
372
|
+
FileType = {
|
|
373
|
+
name: 'JS',
|
|
374
|
+
icon: 'fab js-square'
|
|
375
|
+
}
|
|
376
|
+
} else if ( type.match( /css/ ) ) {
|
|
377
|
+
FileType = {
|
|
378
|
+
name: 'CSS',
|
|
379
|
+
icon: 'fab css3-alt'
|
|
380
|
+
}
|
|
381
|
+
} else if ( type.match( /text\/plain/ ) ) {
|
|
382
|
+
FileType = {
|
|
383
|
+
name: 'テキスト',
|
|
384
|
+
icon: 'file-lines'
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
useEffect( () => {
|
|
389
|
+
if ( val_edit ) {
|
|
390
|
+
setTimeout( () => {
|
|
391
|
+
$( '#' + FileID )[ 0 ].focus();
|
|
392
|
+
},100 );
|
|
393
|
+
}
|
|
394
|
+
},[ val_edit ] );
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<Flex
|
|
398
|
+
verticalAlign='center'
|
|
399
|
+
flexWrap={ false }
|
|
400
|
+
gap={ 1 }
|
|
401
|
+
className={ className }
|
|
402
|
+
>
|
|
403
|
+
<FAIcon
|
|
404
|
+
fontSize={ '4.thirdTitle' }
|
|
405
|
+
fontColor={ 'theme' }
|
|
406
|
+
d={ FileType.icon }
|
|
407
|
+
/>
|
|
408
|
+
<Box flexSizing={ 0 }>
|
|
409
|
+
<Box>
|
|
410
|
+
<Flex
|
|
411
|
+
verticalAlign='center'
|
|
412
|
+
gap={ '2/3' }
|
|
413
|
+
flexWrap={ false }
|
|
414
|
+
className={ style.FileName }
|
|
415
|
+
children={ !val_edit ? <>
|
|
416
|
+
{ fileName }
|
|
417
|
+
{ fileNameEdit ?
|
|
418
|
+
<Buttons.Button.Clear.R
|
|
419
|
+
padding={ '1/3' }
|
|
420
|
+
ssEffectsOnActive={ 'expand' }
|
|
421
|
+
children={ <FAIcon d='pen' /> }
|
|
422
|
+
onClick={ () => {
|
|
423
|
+
set_edit( true );
|
|
424
|
+
} }
|
|
425
|
+
/> : null
|
|
426
|
+
}
|
|
427
|
+
</> : <>
|
|
428
|
+
<Column
|
|
429
|
+
gap={ '1/2' }
|
|
430
|
+
flexSizing={ 0 }
|
|
431
|
+
>
|
|
432
|
+
<Flex
|
|
433
|
+
gap={ '2/3' }
|
|
434
|
+
verticalAlign='center'
|
|
435
|
+
>
|
|
436
|
+
<Input.Text.Normal
|
|
437
|
+
tone='border'
|
|
438
|
+
wrapStyles={ {
|
|
439
|
+
flexSizing: 'auto'
|
|
440
|
+
} }
|
|
441
|
+
restrict='fileName'
|
|
442
|
+
name='name'
|
|
443
|
+
required
|
|
444
|
+
id={ FileID }
|
|
445
|
+
form={ 'form-' + FileID }
|
|
446
|
+
enableFormSubmit
|
|
447
|
+
value={ name }
|
|
448
|
+
onKeyDown={ ( event ) => {
|
|
449
|
+
let { key } = event;
|
|
450
|
+
if ( key == 'Escape' ) set_edit( false );
|
|
451
|
+
} }
|
|
452
|
+
/>
|
|
453
|
+
<Box>
|
|
454
|
+
. { extension }
|
|
455
|
+
</Box>
|
|
456
|
+
</Flex>
|
|
457
|
+
<Flex
|
|
458
|
+
gap={ '2/3' }
|
|
459
|
+
horizontalAlign='right'
|
|
460
|
+
flexWrap={ false }
|
|
461
|
+
>
|
|
462
|
+
<Buttons.Button.Sub.R
|
|
463
|
+
padding={ [ '2/3',1 ] }
|
|
464
|
+
children={ '閉じる' }
|
|
465
|
+
onClick={ () => {
|
|
466
|
+
set_edit( false );
|
|
467
|
+
} }
|
|
468
|
+
/>
|
|
469
|
+
<Buttons.Button.Prime.R
|
|
470
|
+
padding={ [ '2/3',1 ] }
|
|
471
|
+
submitOption={ {
|
|
472
|
+
formName: 'form-' + FileID,
|
|
473
|
+
submitDelegationKey: 'auxEnter',
|
|
474
|
+
callback: async ( form ) => {
|
|
475
|
+
let { name } = form;
|
|
476
|
+
let nextFiles = [ ...val_status.dataValue ];
|
|
477
|
+
let prevFile = nextFiles[ index ];
|
|
478
|
+
let id = prevFile.id;
|
|
479
|
+
if ( !prevFile ) return;
|
|
480
|
+
|
|
481
|
+
let { target } = await prevFile.read();
|
|
482
|
+
if ( !target ) return;
|
|
483
|
+
let dataUrl = String( target.result );
|
|
484
|
+
|
|
485
|
+
let newBlob = await dataUrl.toBlob( file.type )
|
|
486
|
+
if ( !newBlob ) return;
|
|
487
|
+
let newFile: any = new File( [ newBlob ],name + '.' + extension,{ type: prevFile.type } );
|
|
488
|
+
newFile.id = id;
|
|
489
|
+
|
|
490
|
+
nextFiles[ index ] = newFile;
|
|
491
|
+
|
|
492
|
+
set_status( {
|
|
493
|
+
...val_status,
|
|
494
|
+
dataValue: nextFiles,
|
|
495
|
+
eventType: 'update',
|
|
496
|
+
eventID: $.uuidGen(),
|
|
497
|
+
} );
|
|
498
|
+
set_edit( false );
|
|
499
|
+
}
|
|
500
|
+
} }
|
|
501
|
+
>
|
|
502
|
+
決定
|
|
503
|
+
</Buttons.Button.Prime.R>
|
|
504
|
+
</Flex>
|
|
505
|
+
</Column>
|
|
506
|
+
</>
|
|
507
|
+
}
|
|
508
|
+
/>
|
|
509
|
+
</Box>
|
|
510
|
+
{ !val_edit ? <>
|
|
511
|
+
<Box
|
|
512
|
+
fontSize={ '1.mini' }
|
|
513
|
+
fontColor={ '4.thin' }
|
|
514
|
+
flexSizing={ 0 }
|
|
515
|
+
children={ FileType.name + 'ファイル / ' + Size + 'B' }
|
|
516
|
+
/>
|
|
517
|
+
</> : null }
|
|
518
|
+
</Box>
|
|
519
|
+
<Buttons.Button.Sub.R
|
|
520
|
+
ssSphere={ 3 }
|
|
521
|
+
onClick={ () => {
|
|
522
|
+
let nextFiles = [ ...val_status.dataValue ];
|
|
523
|
+
let prevFile = nextFiles[ index ];
|
|
524
|
+
if ( !prevFile ) return;
|
|
525
|
+
|
|
526
|
+
nextFiles.splice( index,1 );
|
|
527
|
+
set_status( {
|
|
528
|
+
...val_status,
|
|
529
|
+
dataValue: nextFiles,
|
|
530
|
+
eventType: 'update',
|
|
531
|
+
eventID: $.uuidGen(),
|
|
532
|
+
} )
|
|
533
|
+
} }
|
|
534
|
+
>
|
|
535
|
+
<FAIcon.Times />
|
|
536
|
+
</Buttons.Button.Sub.R>
|
|
537
|
+
</Flex>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
( async () => {
|
|
543
|
+
$( document ).addEvent( {
|
|
544
|
+
eventType: 'dragover',
|
|
545
|
+
callback: ( event ) => {
|
|
546
|
+
event.preventDefault();
|
|
547
|
+
$( '.' + style.AddButton ).addClass( style.Draggable );
|
|
548
|
+
},
|
|
549
|
+
option: {
|
|
550
|
+
passive: false
|
|
551
|
+
}
|
|
552
|
+
} ).addEvent( {
|
|
553
|
+
eventType: 'drop',
|
|
554
|
+
callback: ( event: any ) => {
|
|
555
|
+
event.preventDefault();
|
|
556
|
+
$( '.' + style.AddButton ).removeClass( style.Draggable );
|
|
557
|
+
let Files = event.dataTransfer.files;
|
|
558
|
+
if ( Files.length ) {
|
|
559
|
+
let Target = event.target as HTMLElement;
|
|
560
|
+
if ( $( Target ).hasClass( style.AddButton ) ) {
|
|
561
|
+
let { inputComponentId } = Target.dataset;
|
|
562
|
+
let component = useStore.get( inputComponentId! );
|
|
563
|
+
if ( component && component.AddFiles ) component.AddFiles( Files );
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
option: {
|
|
568
|
+
passive: false
|
|
569
|
+
}
|
|
570
|
+
} );
|
|
571
|
+
} )();
|
|
572
|
+
|
|
573
|
+
const FileInput: amotify.fn.Input.Filer.Methods = FileComponent as any
|
|
574
|
+
FileInput.fn = {
|
|
575
|
+
openDialog: ( params ) => {
|
|
576
|
+
let {
|
|
577
|
+
multiple,
|
|
578
|
+
accept
|
|
579
|
+
} = params;
|
|
580
|
+
|
|
581
|
+
return new Promise( resolve => {
|
|
582
|
+
const input = document.createElement( 'input' );
|
|
583
|
+
input.type = 'file';
|
|
584
|
+
input.multiple = multiple ?? true;
|
|
585
|
+
if ( accept ) {
|
|
586
|
+
if ( accept == 'image' ) input.accept = 'image/png,image/jpeg';
|
|
587
|
+
else input.accept = accept;
|
|
588
|
+
}
|
|
589
|
+
input.onchange = ( event: any ) => {
|
|
590
|
+
resolve( event.target.files );
|
|
591
|
+
};
|
|
592
|
+
input.click();
|
|
593
|
+
} );
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
export { FileInput }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@use 'src/@styles/props' as *;
|
|
2
|
+
|
|
3
|
+
.Input:focus {
|
|
4
|
+
+ .List .AddButton {
|
|
5
|
+
background-color: $color-layer3;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
.FileName {
|
|
9
|
+
word-break: break-all;
|
|
10
|
+
}
|
|
11
|
+
.AddButton {
|
|
12
|
+
transition: $animation-time-middle;
|
|
13
|
+
> * {
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
&:hover {
|
|
17
|
+
background-color: $color-layer3;
|
|
18
|
+
}
|
|
19
|
+
&.Draggable {
|
|
20
|
+
background-color: $color-layer3;
|
|
21
|
+
.AddIcon {
|
|
22
|
+
animation: 1s infinite IconAnimation;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@keyframes IconAnimation {
|
|
28
|
+
0% {
|
|
29
|
+
box-shadow: 0 0 0 0 $color-theme;
|
|
30
|
+
}
|
|
31
|
+
100% {
|
|
32
|
+
box-shadow: 0 0 0 1rem cAlfa( 0 );
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const HiddenInput: FNC<amotify.fn.Input.Hidden.PlainParams> = ( params ) => {
|
|
2
|
+
let {
|
|
3
|
+
componentID = '',
|
|
4
|
+
form,
|
|
5
|
+
value = '',
|
|
6
|
+
...others
|
|
7
|
+
} = params;
|
|
8
|
+
|
|
9
|
+
return ( <input
|
|
10
|
+
value={ JSON.stringify( value ) }
|
|
11
|
+
data-input-type={ 'hidden' }
|
|
12
|
+
data-form={ form }
|
|
13
|
+
data-component-id={ componentID }
|
|
14
|
+
data-value={ JSON.stringify( value ) }
|
|
15
|
+
{ ...others }
|
|
16
|
+
type='hidden'
|
|
17
|
+
/> );
|
|
18
|
+
}
|