react-input-material 0.0.354 → 0.0.355
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 +2 -2
- package/components/FileInput.tsx +221 -187
- 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 +1 -1
- 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 +2 -2
- 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 +2 -2
- package/components/Interval.tsx +7 -13
- package/components/RequireableCheckbox.d.ts +10 -3
- package/components/RequireableCheckbox.js +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 +6 -6
- package/package.json +1 -1
- package/type.d.ts +42 -42
package/components/FileInput.tsx
CHANGED
|
@@ -90,8 +90,8 @@ import {
|
|
|
90
90
|
// endregion
|
|
91
91
|
// region constants
|
|
92
92
|
const imageContentTypeRegularExpression = new RegExp(
|
|
93
|
-
'^image/(?:p?jpe?g|png|svg(?:\\+xml)?|vnd\\.microsoft\\.icon|gif|tiff|
|
|
94
|
-
'|vnd\\.wap\\.wbmp|x-(?:icon|jng|ms-bmp))$',
|
|
93
|
+
'^image/(?:p?jpe?g|png|svg(?:\\+xml)?|vnd\\.microsoft\\.icon|gif|tiff|' +
|
|
94
|
+
'webp|vnd\\.wap\\.wbmp|x-(?:icon|jng|ms-bmp))$',
|
|
95
95
|
'i'
|
|
96
96
|
)
|
|
97
97
|
const textContentTypeRegularExpression = new RegExp(
|
|
@@ -112,7 +112,9 @@ const videoContentTypeRegularExpression = new RegExp(
|
|
|
112
112
|
)
|
|
113
113
|
// endregion
|
|
114
114
|
// region helper
|
|
115
|
-
export const preserveStaticFileBaseNameInputGenerator:Properties[
|
|
115
|
+
export const preserveStaticFileBaseNameInputGenerator:Properties[
|
|
116
|
+
'generateFileNameInputProperties'
|
|
117
|
+
] = (
|
|
116
118
|
prototype:InputProps<string>, {name, value: {name: fileName}}
|
|
117
119
|
):InputProps<string> => ({
|
|
118
120
|
...prototype,
|
|
@@ -198,9 +200,11 @@ export const determineValidationState = <P extends DefaultProperties>(
|
|
|
198
200
|
}
|
|
199
201
|
)
|
|
200
202
|
export const readBinaryDataIntoText = (
|
|
201
|
-
blob:Blob, encoding
|
|
203
|
+
blob:Blob, encoding = 'utf-8'
|
|
202
204
|
):Promise<string> =>
|
|
203
|
-
new Promise<string>((
|
|
205
|
+
new Promise<string>((
|
|
206
|
+
resolve:(_value:string) => void, reject:(_reason:Error) => void
|
|
207
|
+
):void => {
|
|
204
208
|
const fileReader:FileReader = new FileReader()
|
|
205
209
|
|
|
206
210
|
fileReader.onload = (event:Event):void => {
|
|
@@ -218,8 +222,8 @@ export const readBinaryDataIntoText = (
|
|
|
218
222
|
resolve(content)
|
|
219
223
|
}
|
|
220
224
|
|
|
221
|
-
fileReader.onabort = ():void => reject('abort')
|
|
222
|
-
fileReader.onerror = ():void => reject(
|
|
225
|
+
fileReader.onabort = ():void => reject(new Error('abort'))
|
|
226
|
+
fileReader.onerror = ():void => reject(new Error())
|
|
223
227
|
|
|
224
228
|
fileReader.readAsText(
|
|
225
229
|
blob,
|
|
@@ -231,7 +235,6 @@ export const readBinaryDataIntoText = (
|
|
|
231
235
|
// endregion
|
|
232
236
|
/**
|
|
233
237
|
* Validateable checkbox wrapper component.
|
|
234
|
-
*
|
|
235
238
|
* @property static:displayName - Descriptive name for component to show in web
|
|
236
239
|
* developer tools.
|
|
237
240
|
*
|
|
@@ -253,6 +256,7 @@ export const readBinaryDataIntoText = (
|
|
|
253
256
|
*
|
|
254
257
|
* @param props - Given components properties.
|
|
255
258
|
* @param reference - Reference object to forward internal state.
|
|
259
|
+
*
|
|
256
260
|
* @returns React elements.
|
|
257
261
|
*/
|
|
258
262
|
export const FileInputInner = function(
|
|
@@ -262,10 +266,11 @@ export const FileInputInner = function(
|
|
|
262
266
|
/**
|
|
263
267
|
* Calculate external properties (a set of all configurable properties).
|
|
264
268
|
* @param properties - Properties to merge.
|
|
269
|
+
*
|
|
265
270
|
* @returns External properties object.
|
|
266
271
|
*/
|
|
267
272
|
const getConsolidatedProperties = (properties:Props):Properties => {
|
|
268
|
-
|
|
273
|
+
const result:DefaultProperties =
|
|
269
274
|
mapPropertiesIntoModel<Props, DefaultProperties>(
|
|
270
275
|
properties, FileInput.defaultProperties.model
|
|
271
276
|
)
|
|
@@ -274,11 +279,13 @@ export const FileInputInner = function(
|
|
|
274
279
|
result,
|
|
275
280
|
// TODO not available
|
|
276
281
|
false
|
|
277
|
-
/*
|
|
282
|
+
/*
|
|
283
|
+
nameInputReference.current?.properties.invalid ??
|
|
278
284
|
result.fileNameInputProperties.invalid ??
|
|
279
285
|
result.model.fileName.invalid ??
|
|
280
|
-
result.model!.state.invalidName
|
|
281
|
-
|
|
286
|
+
result.model!.state.invalidName
|
|
287
|
+
*/,
|
|
288
|
+
result.model.state
|
|
282
289
|
)
|
|
283
290
|
|
|
284
291
|
return getBaseConsolidatedProperties<Props, Properties>(result)
|
|
@@ -288,12 +295,13 @@ export const FileInputInner = function(
|
|
|
288
295
|
/**
|
|
289
296
|
* Triggered on blur events.
|
|
290
297
|
* @param event - Event object.
|
|
298
|
+
*
|
|
291
299
|
* @returns Nothing.
|
|
292
300
|
*/
|
|
293
301
|
const onBlur = (event:SyntheticEvent):void => setValueState((
|
|
294
302
|
oldValueState:ValueState
|
|
295
303
|
):ValueState => {
|
|
296
|
-
let changed
|
|
304
|
+
let changed = false
|
|
297
305
|
|
|
298
306
|
if (oldValueState.modelState.focused) {
|
|
299
307
|
properties.focused = false
|
|
@@ -330,6 +338,7 @@ export const FileInputInner = function(
|
|
|
330
338
|
* Triggered on any change events. Consolidates properties object and
|
|
331
339
|
* triggers given on change callbacks.
|
|
332
340
|
* @param event - Potential event object.
|
|
341
|
+
*
|
|
333
342
|
* @returns Nothing.
|
|
334
343
|
*/
|
|
335
344
|
const onChange = (event?:SyntheticEvent):void => {
|
|
@@ -364,13 +373,14 @@ export const FileInputInner = function(
|
|
|
364
373
|
* @param inputProperties - Current properties state.
|
|
365
374
|
* @param attachBlobProperty - Indicates whether additional data is added
|
|
366
375
|
* through post processed data properties.
|
|
376
|
+
*
|
|
367
377
|
* @returns Nothing.
|
|
368
378
|
*/
|
|
369
379
|
const onChangeValue = (
|
|
370
380
|
eventSourceOrName:FileValue|null|string|SyntheticEvent,
|
|
371
381
|
event?:SyntheticEvent|undefined,
|
|
372
382
|
inputProperties?:InputProperties<string>|undefined,
|
|
373
|
-
attachBlobProperty
|
|
383
|
+
attachBlobProperty = false
|
|
374
384
|
):void => {
|
|
375
385
|
if (!(properties.model.mutable && properties.model.writable))
|
|
376
386
|
return
|
|
@@ -416,7 +426,7 @@ export const FileInputInner = function(
|
|
|
416
426
|
if (Tools.equals(oldValueState.value, properties.value))
|
|
417
427
|
return oldValueState
|
|
418
428
|
|
|
419
|
-
let stateChanged
|
|
429
|
+
let stateChanged = false
|
|
420
430
|
|
|
421
431
|
const result:ValueState = {
|
|
422
432
|
...oldValueState, value: properties.value as FileValue|null
|
|
@@ -469,6 +479,7 @@ export const FileInputInner = function(
|
|
|
469
479
|
/**
|
|
470
480
|
* Triggered on click events.
|
|
471
481
|
* @param event - Mouse event object.
|
|
482
|
+
*
|
|
472
483
|
* @returns Nothing.
|
|
473
484
|
*/
|
|
474
485
|
const onClick = (event:ReactMouseEvent):void => {
|
|
@@ -481,6 +492,7 @@ export const FileInputInner = function(
|
|
|
481
492
|
/**
|
|
482
493
|
* Triggered on focus events.
|
|
483
494
|
* @param event - Focus event object.
|
|
495
|
+
*
|
|
484
496
|
* @returns Nothing.
|
|
485
497
|
*/
|
|
486
498
|
const onFocus = (event:ReactFocusEvent):void => {
|
|
@@ -493,11 +505,12 @@ export const FileInputInner = function(
|
|
|
493
505
|
/**
|
|
494
506
|
* Triggers on start interacting with the input.
|
|
495
507
|
* @param event - Event object which triggered interaction.
|
|
508
|
+
*
|
|
496
509
|
* @returns Nothing.
|
|
497
510
|
*/
|
|
498
511
|
const onTouch = (event:ReactFocusEvent|ReactMouseEvent):void =>
|
|
499
512
|
setValueState((oldValueState:ValueState):ValueState => {
|
|
500
|
-
let changedState
|
|
513
|
+
let changedState = false
|
|
501
514
|
|
|
502
515
|
if (!oldValueState.modelState.focused) {
|
|
503
516
|
properties.focused = true
|
|
@@ -550,7 +563,7 @@ export const FileInputInner = function(
|
|
|
550
563
|
const givenProps:Props = translateKnownSymbols(props)
|
|
551
564
|
|
|
552
565
|
const initialValue:FileValue|null = determineInitialValue<FileValue>(
|
|
553
|
-
givenProps, FileInput.defaultProperties.model
|
|
566
|
+
givenProps, FileInput.defaultProperties.model.default
|
|
554
567
|
)
|
|
555
568
|
/*
|
|
556
569
|
NOTE: Extend default properties with given properties while letting
|
|
@@ -591,7 +604,7 @@ export const FileInputInner = function(
|
|
|
591
604
|
properties.value =
|
|
592
605
|
Tools.extend<FileValue>(true, valueState.value, properties.value!)
|
|
593
606
|
|
|
594
|
-
// / region synchronize properties into state
|
|
607
|
+
// / region synchronize uncontrolled properties into state
|
|
595
608
|
const currentValueState:ValueState = {
|
|
596
609
|
attachBlobProperty: false,
|
|
597
610
|
modelState: properties.model.state,
|
|
@@ -655,7 +668,7 @@ export const FileInputInner = function(
|
|
|
655
668
|
typeof Blob === 'undefined' ?
|
|
656
669
|
(properties.value.toString as
|
|
657
670
|
unknown as
|
|
658
|
-
(
|
|
671
|
+
(_encoding:string) => string
|
|
659
672
|
)('base64') :
|
|
660
673
|
await blobToBase64String(properties.value.blob)
|
|
661
674
|
}
|
|
@@ -692,6 +705,7 @@ export const FileInputInner = function(
|
|
|
692
705
|
if (valueChanged)
|
|
693
706
|
onChangeValue(valueChanged, undefined, undefined, true)
|
|
694
707
|
})()
|
|
708
|
+
.catch(console.error)
|
|
695
709
|
})
|
|
696
710
|
// region render
|
|
697
711
|
const representationType:RepresentationType =
|
|
@@ -714,186 +728,205 @@ export const FileInputInner = function(
|
|
|
714
728
|
strict={FileInput.strict}
|
|
715
729
|
themeConfiguration={properties.themeConfiguration}
|
|
716
730
|
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
731
|
>
|
|
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
|
-
''
|
|
732
|
+
<Card
|
|
733
|
+
className={
|
|
734
|
+
[styles['file-input']].concat(properties.className ?? [])
|
|
735
|
+
.join(' ')
|
|
766
736
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
737
|
+
onBlur={onBlur}
|
|
738
|
+
onClick={onClick}
|
|
739
|
+
onFocus={onFocus}
|
|
740
|
+
style={properties.styles}
|
|
741
|
+
>
|
|
742
|
+
<CardPrimaryAction>
|
|
743
|
+
{properties.value?.url ?
|
|
744
|
+
representationType === 'image' ?
|
|
745
|
+
<CardMedia
|
|
746
|
+
{...properties.media}
|
|
747
|
+
style={{
|
|
748
|
+
backgroundImage: `url(${properties.value.url})`
|
|
749
|
+
}}
|
|
750
|
+
/> :
|
|
751
|
+
representationType === 'video' ?
|
|
752
|
+
<video autoPlay loop muted>
|
|
753
|
+
<source
|
|
754
|
+
src={properties.value.url}
|
|
755
|
+
type={properties.value.blob!.type}
|
|
756
|
+
/>
|
|
757
|
+
</video> :
|
|
758
|
+
representationType === 'renderableText' ?
|
|
759
|
+
<div className={
|
|
760
|
+
[styles['file-input__iframe-wrapper']]
|
|
761
|
+
.concat(
|
|
762
|
+
['text/html', 'text/plain']
|
|
763
|
+
.includes(
|
|
764
|
+
properties.value.blob!.type!
|
|
765
|
+
) ?
|
|
766
|
+
styles[
|
|
767
|
+
'file-input__iframe-' +
|
|
768
|
+
'wrapper--padding'
|
|
769
|
+
] :
|
|
770
|
+
[]
|
|
771
|
+
)
|
|
772
|
+
.join(' ')
|
|
773
|
+
}>
|
|
774
|
+
<iframe
|
|
775
|
+
frameBorder="no"
|
|
776
|
+
scrolling="no"
|
|
777
|
+
src={properties.value.url}
|
|
778
|
+
/>
|
|
779
|
+
</div> :
|
|
780
|
+
properties.value?.source &&
|
|
781
|
+
representationType === 'text' ?
|
|
782
|
+
<pre
|
|
783
|
+
className={styles[
|
|
784
|
+
'file-input__text-representation'
|
|
785
|
+
]}
|
|
786
|
+
>
|
|
787
|
+
{properties.value.source}
|
|
788
|
+
</pre> :
|
|
789
|
+
'' :
|
|
790
|
+
properties.value?.blob &&
|
|
791
|
+
properties.value.blob instanceof Blob ?
|
|
792
|
+
// NOTE: Only blobs have to red asynchronously.
|
|
793
|
+
<CircularProgress size="large" /> :
|
|
794
|
+
''
|
|
795
|
+
}
|
|
796
|
+
<div>
|
|
797
|
+
<Typography tag="h2" use="headline6">
|
|
798
|
+
{invalid ?
|
|
799
|
+
<Theme use="error">{
|
|
800
|
+
properties.description ?
|
|
801
|
+
properties.description :
|
|
802
|
+
properties.name
|
|
803
|
+
}</Theme> :
|
|
771
804
|
properties.description ?
|
|
772
805
|
properties.description :
|
|
773
806
|
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
807
|
}
|
|
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}
|
|
808
|
+
</Typography>
|
|
809
|
+
{properties.declaration ?
|
|
810
|
+
<Typography
|
|
811
|
+
style={{marginTop: '-1rem'}}
|
|
812
|
+
tag="h3"
|
|
813
|
+
theme="textSecondaryOnBackground"
|
|
814
|
+
use="subtitle2"
|
|
846
815
|
>
|
|
847
|
-
{
|
|
848
|
-
|
|
849
|
-
|
|
816
|
+
{invalid ?
|
|
817
|
+
<Theme use="error">
|
|
818
|
+
{properties.declaration}
|
|
819
|
+
</Theme> :
|
|
820
|
+
properties.declaration
|
|
850
821
|
}
|
|
851
|
-
</
|
|
822
|
+
</Typography> :
|
|
852
823
|
''
|
|
853
824
|
}
|
|
854
825
|
{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
|
-
</> :
|
|
826
|
+
<GenericInput
|
|
827
|
+
ref={nameInputReference}
|
|
828
|
+
{...properties.generateFileNameInputProperties(
|
|
829
|
+
{
|
|
830
|
+
disabled: properties.disabled,
|
|
831
|
+
value: properties.value?.name,
|
|
832
|
+
...defaultFileNameInputProperties,
|
|
833
|
+
model: properties.model.fileName,
|
|
834
|
+
onChangeValue: onChangeValue,
|
|
835
|
+
default: properties.value.name
|
|
836
|
+
},
|
|
837
|
+
properties as
|
|
838
|
+
Omit<Properties, 'value'> &
|
|
839
|
+
{value:FileValue & {name:string}}
|
|
840
|
+
)}
|
|
841
|
+
/> :
|
|
890
842
|
''
|
|
891
843
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
844
|
+
{properties.children ?
|
|
845
|
+
properties.children({
|
|
846
|
+
declaration: properties.declaration,
|
|
847
|
+
invalid,
|
|
848
|
+
properties,
|
|
849
|
+
value: properties.value
|
|
850
|
+
}) :
|
|
851
|
+
''
|
|
852
|
+
}
|
|
853
|
+
</div>
|
|
854
|
+
{/* TODO use "accept" attribute for better validation. */}
|
|
855
|
+
<input
|
|
856
|
+
disabled={properties.disabled}
|
|
857
|
+
className={styles['file-input__native']}
|
|
858
|
+
id={properties.id || properties.name}
|
|
859
|
+
name={properties.name}
|
|
860
|
+
onChange={onChangeValue}
|
|
861
|
+
ref={fileInputReference}
|
|
862
|
+
type="file"
|
|
863
|
+
/>
|
|
864
|
+
</CardPrimaryAction>
|
|
865
|
+
{!properties.disabled || properties.value ?
|
|
866
|
+
<CardActions>
|
|
867
|
+
<CardActionButtons>
|
|
868
|
+
{!properties.disabled ?
|
|
869
|
+
<CardActionButton
|
|
870
|
+
onClick={():void =>
|
|
871
|
+
fileInputReference.current?.click()
|
|
872
|
+
}
|
|
873
|
+
ref={uploadButtonReference}
|
|
874
|
+
ripple={properties.ripple}
|
|
875
|
+
>
|
|
876
|
+
{properties.value ?
|
|
877
|
+
properties.editButton :
|
|
878
|
+
properties.newButton
|
|
879
|
+
}
|
|
880
|
+
</CardActionButton> :
|
|
881
|
+
''
|
|
882
|
+
}
|
|
883
|
+
{properties.value ?
|
|
884
|
+
<>
|
|
885
|
+
{!properties.disabled ?
|
|
886
|
+
<CardActionButton
|
|
887
|
+
onClick={():void => onChangeValue(null)}
|
|
888
|
+
ref={deleteButtonReference}
|
|
889
|
+
ripple={properties.ripple}
|
|
890
|
+
>
|
|
891
|
+
{properties.deleteButton}
|
|
892
|
+
</CardActionButton> :
|
|
893
|
+
''
|
|
894
|
+
}
|
|
895
|
+
{properties.value.url ?
|
|
896
|
+
<CardActionButton
|
|
897
|
+
onClick={():void =>
|
|
898
|
+
downloadLinkReference
|
|
899
|
+
.current?.click()
|
|
900
|
+
}
|
|
901
|
+
ripple={properties.ripple}
|
|
902
|
+
>
|
|
903
|
+
<a
|
|
904
|
+
className={
|
|
905
|
+
styles['file-input__download']
|
|
906
|
+
}
|
|
907
|
+
download={properties.value.name}
|
|
908
|
+
href={properties.value.url}
|
|
909
|
+
ref={downloadLinkReference}
|
|
910
|
+
target="_blank"
|
|
911
|
+
{...(properties.value.blob?.type ?
|
|
912
|
+
{type:
|
|
913
|
+
properties.value.blob.type
|
|
914
|
+
} :
|
|
915
|
+
{}
|
|
916
|
+
)}
|
|
917
|
+
>{properties.downloadButton}</a>
|
|
918
|
+
</CardActionButton> :
|
|
919
|
+
''
|
|
920
|
+
}
|
|
921
|
+
</> :
|
|
922
|
+
''
|
|
923
|
+
}
|
|
924
|
+
</CardActionButtons>
|
|
925
|
+
</CardActions> :
|
|
926
|
+
''
|
|
927
|
+
}
|
|
928
|
+
</Card>
|
|
929
|
+
</WrapConfigurations>
|
|
897
930
|
// endregion
|
|
898
931
|
}
|
|
899
932
|
// NOTE: This is useful in react dev tools.
|
|
@@ -902,13 +935,14 @@ FileInputInner.displayName = 'FileInput'
|
|
|
902
935
|
* Wrapping web component compatible react component.
|
|
903
936
|
* @property static:defaultModelState - Initial model state.
|
|
904
937
|
* @property static:defaultProperties - Initial property configuration.
|
|
905
|
-
* @property static:propTypes - Triggers reacts runtime property value checks
|
|
938
|
+
* @property static:propTypes - Triggers reacts runtime property value checks.
|
|
906
939
|
* @property static:strict - Indicates whether we should wrap render output in
|
|
907
940
|
* reacts strict component.
|
|
908
941
|
* @property static:wrapped - Wrapped component.
|
|
909
942
|
*
|
|
910
943
|
* @param props - Given components properties.
|
|
911
944
|
* @param reference - Reference object to forward internal state.
|
|
945
|
+
*
|
|
912
946
|
* @returns React elements.
|
|
913
947
|
*/
|
|
914
948
|
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}
|
|
@@ -35,6 +35,9 @@ import styles from './GenericAnimate.module'
|
|
|
35
35
|
// endregion
|
|
36
36
|
/**
|
|
37
37
|
* Generic animation wrapper component.
|
|
38
|
+
* @param properties - Component given properties object.
|
|
39
|
+
*
|
|
40
|
+
* @returns React elements.
|
|
38
41
|
*/
|
|
39
42
|
export const GenericAnimate:FunctionComponent<Partial<TransitionProps<
|
|
40
43
|
HTMLElement|undefined
|
|
@@ -49,17 +52,21 @@ export const GenericAnimate:FunctionComponent<Partial<TransitionProps<
|
|
|
49
52
|
timeout={200}
|
|
50
53
|
unmountOnExit
|
|
51
54
|
{...properties}
|
|
52
|
-
>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
</span> :
|
|
57
|
-
Array.isArray(properties.children) ?
|
|
58
|
-
<div className={styles['generic-animate__list-wrapper']}>
|
|
55
|
+
>
|
|
56
|
+
{
|
|
57
|
+
typeof properties.children === 'string' ?
|
|
58
|
+
<span className={styles['generic-animate__wrapper']}>
|
|
59
59
|
{properties.children}
|
|
60
|
-
</
|
|
61
|
-
properties.children
|
|
62
|
-
|
|
60
|
+
</span> :
|
|
61
|
+
Array.isArray(properties.children) ?
|
|
62
|
+
<div
|
|
63
|
+
className={styles['generic-animate__list-wrapper']}
|
|
64
|
+
>
|
|
65
|
+
{properties.children}
|
|
66
|
+
</div> :
|
|
67
|
+
properties.children
|
|
68
|
+
}
|
|
69
|
+
</CSSTransition>
|
|
63
70
|
// region static properties
|
|
64
71
|
GenericAnimate.propTypes = {
|
|
65
72
|
appear: boolean,
|