react-input-material 0.0.354 → 0.0.358
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/components/Dummy.d.ts +9 -5
- package/components/Dummy.tsx +9 -4
- package/components/FileInput.d.ts +3 -2
- package/components/FileInput.js +1 -1
- package/components/FileInput.module.css +1 -1
- package/components/FileInput.styles.css +4 -4
- package/components/FileInput.tsx +228 -190
- package/components/GenericAnimate.d.ts +3 -0
- package/components/GenericAnimate.module.css +3 -3
- package/components/GenericAnimate.styles.css +1 -1
- package/components/GenericAnimate.tsx +17 -10
- package/components/GenericInput.d.ts +26 -2
- package/components/GenericInput.js +1 -1
- package/components/GenericInput.styles.css +2 -2
- package/components/GenericInput.tsx +470 -347
- package/components/Inputs.d.ts +3 -3
- package/components/Inputs.js +1 -1
- package/components/Inputs.module.css +2 -2
- package/components/Inputs.styles.css +3 -3
- package/components/Inputs.tsx +20 -21
- package/components/Interval.d.ts +4 -6
- package/components/Interval.js +1 -1
- package/components/Interval.module.css +1 -1
- package/components/Interval.styles.css +3 -3
- package/components/Interval.tsx +7 -13
- package/components/RequireableCheckbox.d.ts +10 -3
- package/components/RequireableCheckbox.js +1 -1
- package/components/RequireableCheckbox.styles.css +1 -1
- package/components/RequireableCheckbox.tsx +66 -51
- package/components/WrapConfigurations.d.ts +13 -0
- package/components/WrapConfigurations.tsx +17 -5
- package/components/WrapStrict.d.ts +6 -0
- package/components/WrapStrict.tsx +7 -0
- package/components/WrapThemeProvider.d.ts +7 -5
- package/components/WrapThemeProvider.tsx +8 -5
- package/components/WrapTooltip.d.ts +4 -2
- package/components/WrapTooltip.tsx +14 -6
- package/helper.d.ts +39 -9
- package/helper.js +1 -1
- package/index.js +1 -1
- package/index.styles.css +11 -11
- package/package.json +9 -17
- package/type.d.ts +42 -42
package/components/FileInput.tsx
CHANGED
|
@@ -89,13 +89,17 @@ import {
|
|
|
89
89
|
} from '../type'
|
|
90
90
|
// endregion
|
|
91
91
|
// region constants
|
|
92
|
+
/*
|
|
93
|
+
NOTE: Caused by a bug transpiling regular expression which ignores needed
|
|
94
|
+
escape sequences for "/" when using the nativ regular expression type.
|
|
95
|
+
*/
|
|
92
96
|
const imageContentTypeRegularExpression = new RegExp(
|
|
93
|
-
'^image
|
|
94
|
-
'|vnd\\.wap\\.wbmp|x-(?:icon|jng|ms-bmp))$',
|
|
97
|
+
'^image\\/(?:p?jpe?g|png|svg(?:\\+xml)?|vnd\\.microsoft\\.icon|gif|tiff|' +
|
|
98
|
+
'webp|vnd\\.wap\\.wbmp|x-(?:icon|jng|ms-bmp))$',
|
|
95
99
|
'i'
|
|
96
100
|
)
|
|
97
101
|
const textContentTypeRegularExpression = new RegExp(
|
|
98
|
-
'^(?:application
|
|
102
|
+
'^(?:application\\/xml)|(?:text\\/(?:plain|x-ndpb[wy]html|(?:x-)?csv' +
|
|
99
103
|
'|x?html?|xml))$',
|
|
100
104
|
'i'
|
|
101
105
|
)
|
|
@@ -105,14 +109,16 @@ const representableTextContentTypeRegularExpression =
|
|
|
105
109
|
// Rendered version:
|
|
106
110
|
// /^(application\/xml)|(text\/(plain|x?html?|xml))$/i
|
|
107
111
|
const videoContentTypeRegularExpression = new RegExp(
|
|
108
|
-
'^video
|
|
112
|
+
'^video\\/(?:(?:x-)?(?:x-)?webm|3gpp|mp2t|mp4|mpeg|quicktime|(?:x-)?flv' +
|
|
109
113
|
'|(?:x-)?m4v|(?:x-)mng|x-ms-as|x-ms-wmv|x-msvideo)' +
|
|
110
|
-
'|(?:application
|
|
114
|
+
'|(?:application\\/(?:x-)?shockwave-flash)$',
|
|
111
115
|
'i'
|
|
112
116
|
)
|
|
113
117
|
// endregion
|
|
114
118
|
// region helper
|
|
115
|
-
export const preserveStaticFileBaseNameInputGenerator:Properties[
|
|
119
|
+
export const preserveStaticFileBaseNameInputGenerator:Properties[
|
|
120
|
+
'generateFileNameInputProperties'
|
|
121
|
+
] = (
|
|
116
122
|
prototype:InputProps<string>, {name, value: {name: fileName}}
|
|
117
123
|
):InputProps<string> => ({
|
|
118
124
|
...prototype,
|
|
@@ -198,9 +204,11 @@ export const determineValidationState = <P extends DefaultProperties>(
|
|
|
198
204
|
}
|
|
199
205
|
)
|
|
200
206
|
export const readBinaryDataIntoText = (
|
|
201
|
-
blob:Blob, encoding
|
|
207
|
+
blob:Blob, encoding = 'utf-8'
|
|
202
208
|
):Promise<string> =>
|
|
203
|
-
new Promise<string>((
|
|
209
|
+
new Promise<string>((
|
|
210
|
+
resolve:(_value:string) => void, reject:(_reason:Error) => void
|
|
211
|
+
):void => {
|
|
204
212
|
const fileReader:FileReader = new FileReader()
|
|
205
213
|
|
|
206
214
|
fileReader.onload = (event:Event):void => {
|
|
@@ -218,8 +226,8 @@ export const readBinaryDataIntoText = (
|
|
|
218
226
|
resolve(content)
|
|
219
227
|
}
|
|
220
228
|
|
|
221
|
-
fileReader.onabort = ():void => reject('abort')
|
|
222
|
-
fileReader.onerror = ():void => reject(
|
|
229
|
+
fileReader.onabort = ():void => reject(new Error('abort'))
|
|
230
|
+
fileReader.onerror = ():void => reject(new Error())
|
|
223
231
|
|
|
224
232
|
fileReader.readAsText(
|
|
225
233
|
blob,
|
|
@@ -231,7 +239,6 @@ export const readBinaryDataIntoText = (
|
|
|
231
239
|
// endregion
|
|
232
240
|
/**
|
|
233
241
|
* Validateable checkbox wrapper component.
|
|
234
|
-
*
|
|
235
242
|
* @property static:displayName - Descriptive name for component to show in web
|
|
236
243
|
* developer tools.
|
|
237
244
|
*
|
|
@@ -253,6 +260,7 @@ export const readBinaryDataIntoText = (
|
|
|
253
260
|
*
|
|
254
261
|
* @param props - Given components properties.
|
|
255
262
|
* @param reference - Reference object to forward internal state.
|
|
263
|
+
*
|
|
256
264
|
* @returns React elements.
|
|
257
265
|
*/
|
|
258
266
|
export const FileInputInner = function(
|
|
@@ -262,10 +270,11 @@ export const FileInputInner = function(
|
|
|
262
270
|
/**
|
|
263
271
|
* Calculate external properties (a set of all configurable properties).
|
|
264
272
|
* @param properties - Properties to merge.
|
|
273
|
+
*
|
|
265
274
|
* @returns External properties object.
|
|
266
275
|
*/
|
|
267
276
|
const getConsolidatedProperties = (properties:Props):Properties => {
|
|
268
|
-
|
|
277
|
+
const result:DefaultProperties =
|
|
269
278
|
mapPropertiesIntoModel<Props, DefaultProperties>(
|
|
270
279
|
properties, FileInput.defaultProperties.model
|
|
271
280
|
)
|
|
@@ -274,11 +283,13 @@ export const FileInputInner = function(
|
|
|
274
283
|
result,
|
|
275
284
|
// TODO not available
|
|
276
285
|
false
|
|
277
|
-
/*
|
|
286
|
+
/*
|
|
287
|
+
nameInputReference.current?.properties.invalid ??
|
|
278
288
|
result.fileNameInputProperties.invalid ??
|
|
279
289
|
result.model.fileName.invalid ??
|
|
280
|
-
result.model!.state.invalidName
|
|
281
|
-
|
|
290
|
+
result.model!.state.invalidName
|
|
291
|
+
*/,
|
|
292
|
+
result.model.state
|
|
282
293
|
)
|
|
283
294
|
|
|
284
295
|
return getBaseConsolidatedProperties<Props, Properties>(result)
|
|
@@ -288,12 +299,13 @@ export const FileInputInner = function(
|
|
|
288
299
|
/**
|
|
289
300
|
* Triggered on blur events.
|
|
290
301
|
* @param event - Event object.
|
|
302
|
+
*
|
|
291
303
|
* @returns Nothing.
|
|
292
304
|
*/
|
|
293
305
|
const onBlur = (event:SyntheticEvent):void => setValueState((
|
|
294
306
|
oldValueState:ValueState
|
|
295
307
|
):ValueState => {
|
|
296
|
-
let changed
|
|
308
|
+
let changed = false
|
|
297
309
|
|
|
298
310
|
if (oldValueState.modelState.focused) {
|
|
299
311
|
properties.focused = false
|
|
@@ -330,6 +342,7 @@ export const FileInputInner = function(
|
|
|
330
342
|
* Triggered on any change events. Consolidates properties object and
|
|
331
343
|
* triggers given on change callbacks.
|
|
332
344
|
* @param event - Potential event object.
|
|
345
|
+
*
|
|
333
346
|
* @returns Nothing.
|
|
334
347
|
*/
|
|
335
348
|
const onChange = (event?:SyntheticEvent):void => {
|
|
@@ -364,13 +377,14 @@ export const FileInputInner = function(
|
|
|
364
377
|
* @param inputProperties - Current properties state.
|
|
365
378
|
* @param attachBlobProperty - Indicates whether additional data is added
|
|
366
379
|
* through post processed data properties.
|
|
380
|
+
*
|
|
367
381
|
* @returns Nothing.
|
|
368
382
|
*/
|
|
369
383
|
const onChangeValue = (
|
|
370
384
|
eventSourceOrName:FileValue|null|string|SyntheticEvent,
|
|
371
385
|
event?:SyntheticEvent|undefined,
|
|
372
386
|
inputProperties?:InputProperties<string>|undefined,
|
|
373
|
-
attachBlobProperty
|
|
387
|
+
attachBlobProperty = false
|
|
374
388
|
):void => {
|
|
375
389
|
if (!(properties.model.mutable && properties.model.writable))
|
|
376
390
|
return
|
|
@@ -416,7 +430,7 @@ export const FileInputInner = function(
|
|
|
416
430
|
if (Tools.equals(oldValueState.value, properties.value))
|
|
417
431
|
return oldValueState
|
|
418
432
|
|
|
419
|
-
let stateChanged
|
|
433
|
+
let stateChanged = false
|
|
420
434
|
|
|
421
435
|
const result:ValueState = {
|
|
422
436
|
...oldValueState, value: properties.value as FileValue|null
|
|
@@ -469,6 +483,7 @@ export const FileInputInner = function(
|
|
|
469
483
|
/**
|
|
470
484
|
* Triggered on click events.
|
|
471
485
|
* @param event - Mouse event object.
|
|
486
|
+
*
|
|
472
487
|
* @returns Nothing.
|
|
473
488
|
*/
|
|
474
489
|
const onClick = (event:ReactMouseEvent):void => {
|
|
@@ -481,6 +496,7 @@ export const FileInputInner = function(
|
|
|
481
496
|
/**
|
|
482
497
|
* Triggered on focus events.
|
|
483
498
|
* @param event - Focus event object.
|
|
499
|
+
*
|
|
484
500
|
* @returns Nothing.
|
|
485
501
|
*/
|
|
486
502
|
const onFocus = (event:ReactFocusEvent):void => {
|
|
@@ -493,11 +509,12 @@ export const FileInputInner = function(
|
|
|
493
509
|
/**
|
|
494
510
|
* Triggers on start interacting with the input.
|
|
495
511
|
* @param event - Event object which triggered interaction.
|
|
512
|
+
*
|
|
496
513
|
* @returns Nothing.
|
|
497
514
|
*/
|
|
498
515
|
const onTouch = (event:ReactFocusEvent|ReactMouseEvent):void =>
|
|
499
516
|
setValueState((oldValueState:ValueState):ValueState => {
|
|
500
|
-
let changedState
|
|
517
|
+
let changedState = false
|
|
501
518
|
|
|
502
519
|
if (!oldValueState.modelState.focused) {
|
|
503
520
|
properties.focused = true
|
|
@@ -550,7 +567,7 @@ export const FileInputInner = function(
|
|
|
550
567
|
const givenProps:Props = translateKnownSymbols(props)
|
|
551
568
|
|
|
552
569
|
const initialValue:FileValue|null = determineInitialValue<FileValue>(
|
|
553
|
-
givenProps, FileInput.defaultProperties.model
|
|
570
|
+
givenProps, FileInput.defaultProperties.model.default
|
|
554
571
|
)
|
|
555
572
|
/*
|
|
556
573
|
NOTE: Extend default properties with given properties while letting
|
|
@@ -591,7 +608,7 @@ export const FileInputInner = function(
|
|
|
591
608
|
properties.value =
|
|
592
609
|
Tools.extend<FileValue>(true, valueState.value, properties.value!)
|
|
593
610
|
|
|
594
|
-
// / region synchronize properties into state
|
|
611
|
+
// / region synchronize uncontrolled properties into state
|
|
595
612
|
const currentValueState:ValueState = {
|
|
596
613
|
attachBlobProperty: false,
|
|
597
614
|
modelState: properties.model.state,
|
|
@@ -655,7 +672,7 @@ export const FileInputInner = function(
|
|
|
655
672
|
typeof Blob === 'undefined' ?
|
|
656
673
|
(properties.value.toString as
|
|
657
674
|
unknown as
|
|
658
|
-
(
|
|
675
|
+
(_encoding:string) => string
|
|
659
676
|
)('base64') :
|
|
660
677
|
await blobToBase64String(properties.value.blob)
|
|
661
678
|
}
|
|
@@ -692,6 +709,7 @@ export const FileInputInner = function(
|
|
|
692
709
|
if (valueChanged)
|
|
693
710
|
onChangeValue(valueChanged, undefined, undefined, true)
|
|
694
711
|
})()
|
|
712
|
+
.catch(console.error)
|
|
695
713
|
})
|
|
696
714
|
// region render
|
|
697
715
|
const representationType:RepresentationType =
|
|
@@ -714,186 +732,205 @@ export const FileInputInner = function(
|
|
|
714
732
|
strict={FileInput.strict}
|
|
715
733
|
themeConfiguration={properties.themeConfiguration}
|
|
716
734
|
tooltip={properties.tooltip}
|
|
717
|
-
><Card
|
|
718
|
-
className={
|
|
719
|
-
[styles['file-input']].concat(properties.className ?? []).join(' ')
|
|
720
|
-
}
|
|
721
|
-
onBlur={onBlur}
|
|
722
|
-
onClick={onClick}
|
|
723
|
-
onFocus={onFocus}
|
|
724
|
-
style={properties.styles}
|
|
725
735
|
>
|
|
726
|
-
<
|
|
727
|
-
{
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
{...properties.media}
|
|
731
|
-
style={{backgroundImage: `url(${properties.value.url})`}}
|
|
732
|
-
/> :
|
|
733
|
-
representationType === 'video' ?
|
|
734
|
-
<video autoPlay loop muted>
|
|
735
|
-
<source
|
|
736
|
-
src={properties.value.url}
|
|
737
|
-
type={properties.value.blob!.type}
|
|
738
|
-
/>
|
|
739
|
-
</video> :
|
|
740
|
-
representationType === 'renderableText' ?
|
|
741
|
-
<div className={
|
|
742
|
-
[styles['file-input__iframe-wrapper']].concat(
|
|
743
|
-
['text/html', 'text/plain'].includes(
|
|
744
|
-
properties.value.blob!.type!
|
|
745
|
-
) ?
|
|
746
|
-
styles['file-input__iframe-wrapper--padding'] :
|
|
747
|
-
[]
|
|
748
|
-
)
|
|
749
|
-
.join(' ')
|
|
750
|
-
}>
|
|
751
|
-
<iframe
|
|
752
|
-
frameBorder="no"
|
|
753
|
-
scrolling="no"
|
|
754
|
-
src={properties.value.url}
|
|
755
|
-
/>
|
|
756
|
-
</div> :
|
|
757
|
-
properties.value?.source && representationType === 'text' ?
|
|
758
|
-
<pre className={styles['file-input__text-representation']}>
|
|
759
|
-
{properties.value.source}
|
|
760
|
-
</pre> :
|
|
761
|
-
'' :
|
|
762
|
-
properties.value?.blob && properties.value.blob instanceof Blob ?
|
|
763
|
-
// NOTE: Only blobs have to red asynchronously.
|
|
764
|
-
<CircularProgress size="large" /> :
|
|
765
|
-
''
|
|
736
|
+
<Card
|
|
737
|
+
className={
|
|
738
|
+
[styles['file-input']].concat(properties.className ?? [])
|
|
739
|
+
.join(' ')
|
|
766
740
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
741
|
+
onBlur={onBlur}
|
|
742
|
+
onClick={onClick}
|
|
743
|
+
onFocus={onFocus}
|
|
744
|
+
style={properties.styles}
|
|
745
|
+
>
|
|
746
|
+
<CardPrimaryAction>
|
|
747
|
+
{properties.value?.url ?
|
|
748
|
+
representationType === 'image' ?
|
|
749
|
+
<CardMedia
|
|
750
|
+
{...properties.media}
|
|
751
|
+
style={{
|
|
752
|
+
backgroundImage: `url(${properties.value.url})`
|
|
753
|
+
}}
|
|
754
|
+
/> :
|
|
755
|
+
representationType === 'video' ?
|
|
756
|
+
<video autoPlay loop muted>
|
|
757
|
+
<source
|
|
758
|
+
src={properties.value.url}
|
|
759
|
+
type={properties.value.blob!.type}
|
|
760
|
+
/>
|
|
761
|
+
</video> :
|
|
762
|
+
representationType === 'renderableText' ?
|
|
763
|
+
<div className={
|
|
764
|
+
[styles['file-input__iframe-wrapper']]
|
|
765
|
+
.concat(
|
|
766
|
+
['text/html', 'text/plain']
|
|
767
|
+
.includes(
|
|
768
|
+
properties.value.blob!.type!
|
|
769
|
+
) ?
|
|
770
|
+
styles[
|
|
771
|
+
'file-input__iframe-' +
|
|
772
|
+
'wrapper--padding'
|
|
773
|
+
] :
|
|
774
|
+
[]
|
|
775
|
+
)
|
|
776
|
+
.join(' ')
|
|
777
|
+
}>
|
|
778
|
+
<iframe
|
|
779
|
+
frameBorder="no"
|
|
780
|
+
scrolling="no"
|
|
781
|
+
src={properties.value.url}
|
|
782
|
+
/>
|
|
783
|
+
</div> :
|
|
784
|
+
properties.value?.source &&
|
|
785
|
+
representationType === 'text' ?
|
|
786
|
+
<pre
|
|
787
|
+
className={styles[
|
|
788
|
+
'file-input__text-representation'
|
|
789
|
+
]}
|
|
790
|
+
>
|
|
791
|
+
{properties.value.source}
|
|
792
|
+
</pre> :
|
|
793
|
+
'' :
|
|
794
|
+
properties.value?.blob &&
|
|
795
|
+
properties.value.blob instanceof Blob ?
|
|
796
|
+
// NOTE: Only blobs have to red asynchronously.
|
|
797
|
+
<CircularProgress size="large" /> :
|
|
798
|
+
''
|
|
799
|
+
}
|
|
800
|
+
<div>
|
|
801
|
+
<Typography tag="h2" use="headline6">
|
|
802
|
+
{invalid ?
|
|
803
|
+
<Theme use="error">{
|
|
804
|
+
properties.description ?
|
|
805
|
+
properties.description :
|
|
806
|
+
properties.name
|
|
807
|
+
}</Theme> :
|
|
771
808
|
properties.description ?
|
|
772
809
|
properties.description :
|
|
773
810
|
properties.name
|
|
774
|
-
}</Theme> :
|
|
775
|
-
properties.description ?
|
|
776
|
-
properties.description :
|
|
777
|
-
properties.name
|
|
778
|
-
}
|
|
779
|
-
</Typography>
|
|
780
|
-
{properties.declaration ?
|
|
781
|
-
<Typography
|
|
782
|
-
style={{marginTop: '-1rem'}}
|
|
783
|
-
tag="h3"
|
|
784
|
-
theme="textSecondaryOnBackground"
|
|
785
|
-
use="subtitle2"
|
|
786
|
-
>
|
|
787
|
-
{invalid ?
|
|
788
|
-
<Theme use="error">
|
|
789
|
-
{properties.declaration}
|
|
790
|
-
</Theme> :
|
|
791
|
-
properties.declaration
|
|
792
811
|
}
|
|
793
|
-
</Typography>
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
{
|
|
801
|
-
disabled: properties.disabled,
|
|
802
|
-
value: properties.value?.name,
|
|
803
|
-
...defaultFileNameInputProperties,
|
|
804
|
-
model: properties.model.fileName,
|
|
805
|
-
onChangeValue: onChangeValue,
|
|
806
|
-
default: properties.value.name
|
|
807
|
-
},
|
|
808
|
-
properties as
|
|
809
|
-
Omit<Properties, 'value'> &
|
|
810
|
-
{value:FileValue & {name:string}}
|
|
811
|
-
)}
|
|
812
|
-
/> :
|
|
813
|
-
''
|
|
814
|
-
}
|
|
815
|
-
{properties.children ?
|
|
816
|
-
properties.children({
|
|
817
|
-
declaration: properties.declaration,
|
|
818
|
-
invalid,
|
|
819
|
-
properties,
|
|
820
|
-
value: properties.value
|
|
821
|
-
}) :
|
|
822
|
-
''
|
|
823
|
-
}
|
|
824
|
-
</div>
|
|
825
|
-
{/*TODO use "accept" attribute*/}
|
|
826
|
-
<input
|
|
827
|
-
disabled={properties.disabled}
|
|
828
|
-
className={styles['file-input__native']}
|
|
829
|
-
id={properties.id || properties.name}
|
|
830
|
-
name={properties.name}
|
|
831
|
-
onChange={onChangeValue}
|
|
832
|
-
ref={fileInputReference}
|
|
833
|
-
type="file"
|
|
834
|
-
/>
|
|
835
|
-
</CardPrimaryAction>
|
|
836
|
-
{!properties.disabled || properties.value ?
|
|
837
|
-
<CardActions>
|
|
838
|
-
<CardActionButtons>
|
|
839
|
-
{!properties.disabled ?
|
|
840
|
-
<CardActionButton
|
|
841
|
-
onClick={():void =>
|
|
842
|
-
fileInputReference.current?.click()
|
|
843
|
-
}
|
|
844
|
-
ref={uploadButtonReference}
|
|
845
|
-
ripple={properties.ripple}
|
|
812
|
+
</Typography>
|
|
813
|
+
{properties.declaration ?
|
|
814
|
+
<Typography
|
|
815
|
+
style={{marginTop: '-1rem'}}
|
|
816
|
+
tag="h3"
|
|
817
|
+
theme="textSecondaryOnBackground"
|
|
818
|
+
use="subtitle2"
|
|
846
819
|
>
|
|
847
|
-
{
|
|
848
|
-
|
|
849
|
-
|
|
820
|
+
{invalid ?
|
|
821
|
+
<Theme use="error">
|
|
822
|
+
{properties.declaration}
|
|
823
|
+
</Theme> :
|
|
824
|
+
properties.declaration
|
|
850
825
|
}
|
|
851
|
-
</
|
|
826
|
+
</Typography> :
|
|
852
827
|
''
|
|
853
828
|
}
|
|
854
829
|
{properties.value ?
|
|
855
|
-
|
|
856
|
-
{
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
<a
|
|
872
|
-
className={
|
|
873
|
-
styles['file-input__download']
|
|
874
|
-
}
|
|
875
|
-
download={properties.value.name}
|
|
876
|
-
href={properties.value.url}
|
|
877
|
-
ref={downloadLinkReference}
|
|
878
|
-
target="_blank"
|
|
879
|
-
{...(properties.value.blob?.type ?
|
|
880
|
-
{type:
|
|
881
|
-
properties.value.blob.type
|
|
882
|
-
} :
|
|
883
|
-
{}
|
|
884
|
-
)}
|
|
885
|
-
>{properties.downloadButton}</a>
|
|
886
|
-
</CardActionButton> :
|
|
887
|
-
''
|
|
888
|
-
}
|
|
889
|
-
</> :
|
|
830
|
+
<GenericInput
|
|
831
|
+
ref={nameInputReference}
|
|
832
|
+
{...properties.generateFileNameInputProperties(
|
|
833
|
+
{
|
|
834
|
+
disabled: properties.disabled,
|
|
835
|
+
value: properties.value?.name,
|
|
836
|
+
...defaultFileNameInputProperties,
|
|
837
|
+
model: properties.model.fileName,
|
|
838
|
+
onChangeValue: onChangeValue,
|
|
839
|
+
default: properties.value.name
|
|
840
|
+
},
|
|
841
|
+
properties as
|
|
842
|
+
Omit<Properties, 'value'> &
|
|
843
|
+
{value:FileValue & {name:string}}
|
|
844
|
+
)}
|
|
845
|
+
/> :
|
|
890
846
|
''
|
|
891
847
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
848
|
+
{properties.children ?
|
|
849
|
+
properties.children({
|
|
850
|
+
declaration: properties.declaration,
|
|
851
|
+
invalid,
|
|
852
|
+
properties,
|
|
853
|
+
value: properties.value
|
|
854
|
+
}) :
|
|
855
|
+
''
|
|
856
|
+
}
|
|
857
|
+
</div>
|
|
858
|
+
{/* TODO use "accept" attribute for better validation. */}
|
|
859
|
+
<input
|
|
860
|
+
disabled={properties.disabled}
|
|
861
|
+
className={styles['file-input__native']}
|
|
862
|
+
id={properties.id || properties.name}
|
|
863
|
+
name={properties.name}
|
|
864
|
+
onChange={onChangeValue}
|
|
865
|
+
ref={fileInputReference}
|
|
866
|
+
type="file"
|
|
867
|
+
/>
|
|
868
|
+
</CardPrimaryAction>
|
|
869
|
+
{!properties.disabled || properties.value ?
|
|
870
|
+
<CardActions>
|
|
871
|
+
<CardActionButtons>
|
|
872
|
+
{!properties.disabled ?
|
|
873
|
+
<CardActionButton
|
|
874
|
+
onClick={():void =>
|
|
875
|
+
fileInputReference.current?.click()
|
|
876
|
+
}
|
|
877
|
+
ref={uploadButtonReference}
|
|
878
|
+
ripple={properties.ripple}
|
|
879
|
+
>
|
|
880
|
+
{properties.value ?
|
|
881
|
+
properties.editButton :
|
|
882
|
+
properties.newButton
|
|
883
|
+
}
|
|
884
|
+
</CardActionButton> :
|
|
885
|
+
''
|
|
886
|
+
}
|
|
887
|
+
{properties.value ?
|
|
888
|
+
<>
|
|
889
|
+
{!properties.disabled ?
|
|
890
|
+
<CardActionButton
|
|
891
|
+
onClick={():void => onChangeValue(null)}
|
|
892
|
+
ref={deleteButtonReference}
|
|
893
|
+
ripple={properties.ripple}
|
|
894
|
+
>
|
|
895
|
+
{properties.deleteButton}
|
|
896
|
+
</CardActionButton> :
|
|
897
|
+
''
|
|
898
|
+
}
|
|
899
|
+
{properties.value.url ?
|
|
900
|
+
<CardActionButton
|
|
901
|
+
onClick={():void =>
|
|
902
|
+
downloadLinkReference
|
|
903
|
+
.current?.click()
|
|
904
|
+
}
|
|
905
|
+
ripple={properties.ripple}
|
|
906
|
+
>
|
|
907
|
+
<a
|
|
908
|
+
className={
|
|
909
|
+
styles['file-input__download']
|
|
910
|
+
}
|
|
911
|
+
download={properties.value.name}
|
|
912
|
+
href={properties.value.url}
|
|
913
|
+
ref={downloadLinkReference}
|
|
914
|
+
target="_blank"
|
|
915
|
+
{...(properties.value.blob?.type ?
|
|
916
|
+
{type:
|
|
917
|
+
properties.value.blob.type
|
|
918
|
+
} :
|
|
919
|
+
{}
|
|
920
|
+
)}
|
|
921
|
+
>{properties.downloadButton}</a>
|
|
922
|
+
</CardActionButton> :
|
|
923
|
+
''
|
|
924
|
+
}
|
|
925
|
+
</> :
|
|
926
|
+
''
|
|
927
|
+
}
|
|
928
|
+
</CardActionButtons>
|
|
929
|
+
</CardActions> :
|
|
930
|
+
''
|
|
931
|
+
}
|
|
932
|
+
</Card>
|
|
933
|
+
</WrapConfigurations>
|
|
897
934
|
// endregion
|
|
898
935
|
}
|
|
899
936
|
// NOTE: This is useful in react dev tools.
|
|
@@ -902,13 +939,14 @@ FileInputInner.displayName = 'FileInput'
|
|
|
902
939
|
* Wrapping web component compatible react component.
|
|
903
940
|
* @property static:defaultModelState - Initial model state.
|
|
904
941
|
* @property static:defaultProperties - Initial property configuration.
|
|
905
|
-
* @property static:propTypes - Triggers reacts runtime property value checks
|
|
942
|
+
* @property static:propTypes - Triggers reacts runtime property value checks.
|
|
906
943
|
* @property static:strict - Indicates whether we should wrap render output in
|
|
907
944
|
* reacts strict component.
|
|
908
945
|
* @property static:wrapped - Wrapped component.
|
|
909
946
|
*
|
|
910
947
|
* @param props - Given components properties.
|
|
911
948
|
* @param reference - Reference object to forward internal state.
|
|
949
|
+
*
|
|
912
950
|
* @returns React elements.
|
|
913
951
|
*/
|
|
914
952
|
export const FileInput:FileInputComponent =
|
|
@@ -2,6 +2,9 @@ import { FunctionComponent } from 'react';
|
|
|
2
2
|
import { TransitionProps } from 'react-transition-group/Transition';
|
|
3
3
|
/**
|
|
4
4
|
* Generic animation wrapper component.
|
|
5
|
+
* @param properties - Component given properties object.
|
|
6
|
+
*
|
|
7
|
+
* @returns React elements.
|
|
5
8
|
*/
|
|
6
9
|
export declare const GenericAnimate: FunctionComponent<Partial<TransitionProps<HTMLElement | undefined>>>;
|
|
7
10
|
export default GenericAnimate;
|
|
@@ -22,13 +22,13 @@ endregion */
|
|
|
22
22
|
.generic-animate-appear,
|
|
23
23
|
.generic-animate-enter,
|
|
24
24
|
.generic-animate-exit-active {
|
|
25
|
-
opacity: 0
|
|
25
|
+
opacity: 0;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.generic-animate-appear-active,
|
|
29
29
|
.generic-animate-enter-active,
|
|
30
30
|
.generic-animate-exit {
|
|
31
|
-
opacity:
|
|
31
|
+
opacity: 1;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.generic-animate-appear-active,
|
|
@@ -41,7 +41,7 @@ endregion */
|
|
|
41
41
|
animations gets broken.
|
|
42
42
|
*/
|
|
43
43
|
.generic-animate-exit-active {
|
|
44
|
-
opacity: 0
|
|
44
|
+
opacity: 0;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
.generic-animate-exit-done {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* !/usr/bin/env css
|
|
2
|
-
-*- coding: utf-8 -*- */.generic-animate,.generic-animate__list-wrapper,.generic-animate__wrapper{visibility:visible}.generic-animate-appear,.generic-animate-enter,.generic-animate-exit-active{opacity:0}.generic-animate-appear-active,.generic-animate-enter-active,.generic-animate-exit{opacity:1
|
|
2
|
+
-*- coding: utf-8 -*- */.generic-animate,.generic-animate__list-wrapper,.generic-animate__wrapper{visibility:visible}.generic-animate-appear,.generic-animate-enter,.generic-animate-exit-active{opacity:0}.generic-animate-appear-active,.generic-animate-enter-active,.generic-animate-exit{opacity:1}.generic-animate-appear-active,.generic-animate-enter-active,.generic-animate-exit-active{-webkit-transition:opacity .2s ease-in;transition:opacity .2s ease-in}.generic-animate-exit-active{opacity:0}.generic-animate-exit-done{display:none}
|