react-input-material 0.0.351 → 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 +11 -6
- package/components/FileInput.d.ts +3 -2
- package/components/FileInput.js +1 -1
- package/components/FileInput.module.css +12 -24
- package/components/FileInput.styles.css +3 -3
- package/components/FileInput.tsx +235 -203
- package/components/GenericAnimate.d.ts +3 -0
- package/components/GenericAnimate.module.css +0 -1
- package/components/GenericAnimate.tsx +17 -10
- package/components/GenericInput.d.ts +26 -2
- package/components/GenericInput.js +1 -1
- package/components/GenericInput.module.css +32 -45
- package/components/GenericInput.styles.css +1 -1
- package/components/GenericInput.tsx +471 -348
- package/components/Inputs.d.ts +3 -3
- package/components/Inputs.js +1 -1
- package/components/Inputs.module.css +10 -9
- 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 +16 -15
- 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.module.css +4 -4
- 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 +10 -10
- package/package.json +32 -16
- package/readme.md +38 -2
- package/type.d.ts +42 -42
package/components/FileInput.tsx
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
// region imports
|
|
20
20
|
import {blobToBase64String, dataURLToBlob} from 'blob-util'
|
|
21
21
|
import Tools from 'clientnode'
|
|
22
|
-
import {FirstParameter} from 'clientnode/type'
|
|
23
22
|
import {
|
|
24
23
|
FocusEvent as ReactFocusEvent,
|
|
25
24
|
ForwardedRef,
|
|
@@ -28,7 +27,6 @@ import {
|
|
|
28
27
|
MouseEvent as ReactMouseEvent,
|
|
29
28
|
MutableRefObject,
|
|
30
29
|
ReactElement,
|
|
31
|
-
RefCallback,
|
|
32
30
|
SyntheticEvent,
|
|
33
31
|
useEffect,
|
|
34
32
|
useImperativeHandle,
|
|
@@ -46,7 +44,6 @@ import {
|
|
|
46
44
|
import {CircularProgress} from '@rmwc/circular-progress'
|
|
47
45
|
import {Theme} from '@rmwc/theme'
|
|
48
46
|
import {Typography} from '@rmwc/typography'
|
|
49
|
-
import {ComponentAdapter} from 'web-component-wrapper/type'
|
|
50
47
|
|
|
51
48
|
/*
|
|
52
49
|
"namedExport" version of css-loader:
|
|
@@ -78,11 +75,9 @@ import {
|
|
|
78
75
|
defaultFileInputProperties as defaultProperties,
|
|
79
76
|
defaultFileNameInputProperties,
|
|
80
77
|
FileInputAdapter as Adapter,
|
|
81
|
-
FileInputModel as Model,
|
|
82
78
|
FileInputModelState as ModelState,
|
|
83
79
|
FileInputProperties as Properties,
|
|
84
80
|
FileInputProps as Props,
|
|
85
|
-
FileInputState as State,
|
|
86
81
|
FileValue,
|
|
87
82
|
FileInputValueState as ValueState,
|
|
88
83
|
fileInputPropertyTypes as propertyTypes,
|
|
@@ -94,27 +89,32 @@ import {
|
|
|
94
89
|
} from '../type'
|
|
95
90
|
// endregion
|
|
96
91
|
// region constants
|
|
97
|
-
const imageContentTypeRegularExpression
|
|
98
|
-
'^image/(?:p?jpe?g|png|svg(?:\\+xml)?|vnd\\.microsoft\\.icon|gif|' +
|
|
99
|
-
'
|
|
92
|
+
const imageContentTypeRegularExpression = new RegExp(
|
|
93
|
+
'^image/(?:p?jpe?g|png|svg(?:\\+xml)?|vnd\\.microsoft\\.icon|gif|tiff|' +
|
|
94
|
+
'webp|vnd\\.wap\\.wbmp|x-(?:icon|jng|ms-bmp))$',
|
|
95
|
+
'i'
|
|
100
96
|
)
|
|
101
|
-
const textContentTypeRegularExpression
|
|
102
|
-
'^(?:application/xml)|' +
|
|
103
|
-
'
|
|
97
|
+
const textContentTypeRegularExpression = new RegExp(
|
|
98
|
+
'^(?:application/xml)|(?:text/(?:plain|x-ndpb[wy]html|(?:x-)?csv' +
|
|
99
|
+
'|x?html?|xml))$',
|
|
100
|
+
'i'
|
|
104
101
|
)
|
|
105
|
-
const representableTextContentTypeRegularExpression
|
|
102
|
+
const representableTextContentTypeRegularExpression =
|
|
106
103
|
// Plain version:
|
|
107
|
-
/^text\/plain$/
|
|
104
|
+
/^text\/plain$/i
|
|
108
105
|
// Rendered version:
|
|
109
|
-
//
|
|
110
|
-
const videoContentTypeRegularExpression
|
|
111
|
-
'^video/(?:(?:x-)?(?:x-)?webm|3gpp|mp2t|mp4|mpeg|quicktime|' +
|
|
112
|
-
'
|
|
113
|
-
'(?:application/(?:x-)?shockwave-flash)$'
|
|
106
|
+
// /^(application\/xml)|(text\/(plain|x?html?|xml))$/i
|
|
107
|
+
const videoContentTypeRegularExpression = new RegExp(
|
|
108
|
+
'^video/(?:(?:x-)?(?:x-)?webm|3gpp|mp2t|mp4|mpeg|quicktime|(?:x-)?flv' +
|
|
109
|
+
'|(?:x-)?m4v|(?:x-)mng|x-ms-as|x-ms-wmv|x-msvideo)' +
|
|
110
|
+
'|(?:application/(?:x-)?shockwave-flash)$',
|
|
111
|
+
'i'
|
|
114
112
|
)
|
|
115
113
|
// endregion
|
|
116
114
|
// region helper
|
|
117
|
-
export const preserveStaticFileBaseNameInputGenerator:Properties[
|
|
115
|
+
export const preserveStaticFileBaseNameInputGenerator:Properties[
|
|
116
|
+
'generateFileNameInputProperties'
|
|
117
|
+
] = (
|
|
118
118
|
prototype:InputProps<string>, {name, value: {name: fileName}}
|
|
119
119
|
):InputProps<string> => ({
|
|
120
120
|
...prototype,
|
|
@@ -200,9 +200,11 @@ export const determineValidationState = <P extends DefaultProperties>(
|
|
|
200
200
|
}
|
|
201
201
|
)
|
|
202
202
|
export const readBinaryDataIntoText = (
|
|
203
|
-
blob:Blob, encoding
|
|
203
|
+
blob:Blob, encoding = 'utf-8'
|
|
204
204
|
):Promise<string> =>
|
|
205
|
-
new Promise<string>((
|
|
205
|
+
new Promise<string>((
|
|
206
|
+
resolve:(_value:string) => void, reject:(_reason:Error) => void
|
|
207
|
+
):void => {
|
|
206
208
|
const fileReader:FileReader = new FileReader()
|
|
207
209
|
|
|
208
210
|
fileReader.onload = (event:Event):void => {
|
|
@@ -220,8 +222,8 @@ export const readBinaryDataIntoText = (
|
|
|
220
222
|
resolve(content)
|
|
221
223
|
}
|
|
222
224
|
|
|
223
|
-
fileReader.onabort = ():void => reject('abort')
|
|
224
|
-
fileReader.onerror = ():void => reject(
|
|
225
|
+
fileReader.onabort = ():void => reject(new Error('abort'))
|
|
226
|
+
fileReader.onerror = ():void => reject(new Error())
|
|
225
227
|
|
|
226
228
|
fileReader.readAsText(
|
|
227
229
|
blob,
|
|
@@ -233,7 +235,6 @@ export const readBinaryDataIntoText = (
|
|
|
233
235
|
// endregion
|
|
234
236
|
/**
|
|
235
237
|
* Validateable checkbox wrapper component.
|
|
236
|
-
*
|
|
237
238
|
* @property static:displayName - Descriptive name for component to show in web
|
|
238
239
|
* developer tools.
|
|
239
240
|
*
|
|
@@ -255,6 +256,7 @@ export const readBinaryDataIntoText = (
|
|
|
255
256
|
*
|
|
256
257
|
* @param props - Given components properties.
|
|
257
258
|
* @param reference - Reference object to forward internal state.
|
|
259
|
+
*
|
|
258
260
|
* @returns React elements.
|
|
259
261
|
*/
|
|
260
262
|
export const FileInputInner = function(
|
|
@@ -264,10 +266,11 @@ export const FileInputInner = function(
|
|
|
264
266
|
/**
|
|
265
267
|
* Calculate external properties (a set of all configurable properties).
|
|
266
268
|
* @param properties - Properties to merge.
|
|
269
|
+
*
|
|
267
270
|
* @returns External properties object.
|
|
268
271
|
*/
|
|
269
272
|
const getConsolidatedProperties = (properties:Props):Properties => {
|
|
270
|
-
|
|
273
|
+
const result:DefaultProperties =
|
|
271
274
|
mapPropertiesIntoModel<Props, DefaultProperties>(
|
|
272
275
|
properties, FileInput.defaultProperties.model
|
|
273
276
|
)
|
|
@@ -276,11 +279,13 @@ export const FileInputInner = function(
|
|
|
276
279
|
result,
|
|
277
280
|
// TODO not available
|
|
278
281
|
false
|
|
279
|
-
/*
|
|
282
|
+
/*
|
|
283
|
+
nameInputReference.current?.properties.invalid ??
|
|
280
284
|
result.fileNameInputProperties.invalid ??
|
|
281
285
|
result.model.fileName.invalid ??
|
|
282
|
-
result.model!.state.invalidName
|
|
283
|
-
|
|
286
|
+
result.model!.state.invalidName
|
|
287
|
+
*/,
|
|
288
|
+
result.model.state
|
|
284
289
|
)
|
|
285
290
|
|
|
286
291
|
return getBaseConsolidatedProperties<Props, Properties>(result)
|
|
@@ -290,12 +295,13 @@ export const FileInputInner = function(
|
|
|
290
295
|
/**
|
|
291
296
|
* Triggered on blur events.
|
|
292
297
|
* @param event - Event object.
|
|
298
|
+
*
|
|
293
299
|
* @returns Nothing.
|
|
294
300
|
*/
|
|
295
301
|
const onBlur = (event:SyntheticEvent):void => setValueState((
|
|
296
302
|
oldValueState:ValueState
|
|
297
303
|
):ValueState => {
|
|
298
|
-
let changed
|
|
304
|
+
let changed = false
|
|
299
305
|
|
|
300
306
|
if (oldValueState.modelState.focused) {
|
|
301
307
|
properties.focused = false
|
|
@@ -332,6 +338,7 @@ export const FileInputInner = function(
|
|
|
332
338
|
* Triggered on any change events. Consolidates properties object and
|
|
333
339
|
* triggers given on change callbacks.
|
|
334
340
|
* @param event - Potential event object.
|
|
341
|
+
*
|
|
335
342
|
* @returns Nothing.
|
|
336
343
|
*/
|
|
337
344
|
const onChange = (event?:SyntheticEvent):void => {
|
|
@@ -366,13 +373,14 @@ export const FileInputInner = function(
|
|
|
366
373
|
* @param inputProperties - Current properties state.
|
|
367
374
|
* @param attachBlobProperty - Indicates whether additional data is added
|
|
368
375
|
* through post processed data properties.
|
|
376
|
+
*
|
|
369
377
|
* @returns Nothing.
|
|
370
378
|
*/
|
|
371
379
|
const onChangeValue = (
|
|
372
380
|
eventSourceOrName:FileValue|null|string|SyntheticEvent,
|
|
373
381
|
event?:SyntheticEvent|undefined,
|
|
374
382
|
inputProperties?:InputProperties<string>|undefined,
|
|
375
|
-
attachBlobProperty
|
|
383
|
+
attachBlobProperty = false
|
|
376
384
|
):void => {
|
|
377
385
|
if (!(properties.model.mutable && properties.model.writable))
|
|
378
386
|
return
|
|
@@ -418,7 +426,7 @@ export const FileInputInner = function(
|
|
|
418
426
|
if (Tools.equals(oldValueState.value, properties.value))
|
|
419
427
|
return oldValueState
|
|
420
428
|
|
|
421
|
-
let stateChanged
|
|
429
|
+
let stateChanged = false
|
|
422
430
|
|
|
423
431
|
const result:ValueState = {
|
|
424
432
|
...oldValueState, value: properties.value as FileValue|null
|
|
@@ -471,6 +479,7 @@ export const FileInputInner = function(
|
|
|
471
479
|
/**
|
|
472
480
|
* Triggered on click events.
|
|
473
481
|
* @param event - Mouse event object.
|
|
482
|
+
*
|
|
474
483
|
* @returns Nothing.
|
|
475
484
|
*/
|
|
476
485
|
const onClick = (event:ReactMouseEvent):void => {
|
|
@@ -483,6 +492,7 @@ export const FileInputInner = function(
|
|
|
483
492
|
/**
|
|
484
493
|
* Triggered on focus events.
|
|
485
494
|
* @param event - Focus event object.
|
|
495
|
+
*
|
|
486
496
|
* @returns Nothing.
|
|
487
497
|
*/
|
|
488
498
|
const onFocus = (event:ReactFocusEvent):void => {
|
|
@@ -495,11 +505,12 @@ export const FileInputInner = function(
|
|
|
495
505
|
/**
|
|
496
506
|
* Triggers on start interacting with the input.
|
|
497
507
|
* @param event - Event object which triggered interaction.
|
|
508
|
+
*
|
|
498
509
|
* @returns Nothing.
|
|
499
510
|
*/
|
|
500
511
|
const onTouch = (event:ReactFocusEvent|ReactMouseEvent):void =>
|
|
501
512
|
setValueState((oldValueState:ValueState):ValueState => {
|
|
502
|
-
let changedState
|
|
513
|
+
let changedState = false
|
|
503
514
|
|
|
504
515
|
if (!oldValueState.modelState.focused) {
|
|
505
516
|
properties.focused = true
|
|
@@ -552,7 +563,7 @@ export const FileInputInner = function(
|
|
|
552
563
|
const givenProps:Props = translateKnownSymbols(props)
|
|
553
564
|
|
|
554
565
|
const initialValue:FileValue|null = determineInitialValue<FileValue>(
|
|
555
|
-
givenProps, FileInput.defaultProperties.model
|
|
566
|
+
givenProps, FileInput.defaultProperties.model.default
|
|
556
567
|
)
|
|
557
568
|
/*
|
|
558
569
|
NOTE: Extend default properties with given properties while letting
|
|
@@ -593,7 +604,7 @@ export const FileInputInner = function(
|
|
|
593
604
|
properties.value =
|
|
594
605
|
Tools.extend<FileValue>(true, valueState.value, properties.value!)
|
|
595
606
|
|
|
596
|
-
// / region synchronize properties into state
|
|
607
|
+
// / region synchronize uncontrolled properties into state
|
|
597
608
|
const currentValueState:ValueState = {
|
|
598
609
|
attachBlobProperty: false,
|
|
599
610
|
modelState: properties.model.state,
|
|
@@ -657,7 +668,7 @@ export const FileInputInner = function(
|
|
|
657
668
|
typeof Blob === 'undefined' ?
|
|
658
669
|
(properties.value.toString as
|
|
659
670
|
unknown as
|
|
660
|
-
(
|
|
671
|
+
(_encoding:string) => string
|
|
661
672
|
)('base64') :
|
|
662
673
|
await blobToBase64String(properties.value.blob)
|
|
663
674
|
}
|
|
@@ -694,6 +705,7 @@ export const FileInputInner = function(
|
|
|
694
705
|
if (valueChanged)
|
|
695
706
|
onChangeValue(valueChanged, undefined, undefined, true)
|
|
696
707
|
})()
|
|
708
|
+
.catch(console.error)
|
|
697
709
|
})
|
|
698
710
|
// region render
|
|
699
711
|
const representationType:RepresentationType =
|
|
@@ -716,186 +728,205 @@ export const FileInputInner = function(
|
|
|
716
728
|
strict={FileInput.strict}
|
|
717
729
|
themeConfiguration={properties.themeConfiguration}
|
|
718
730
|
tooltip={properties.tooltip}
|
|
719
|
-
><Card
|
|
720
|
-
className={
|
|
721
|
-
[styles['file-input']].concat(properties.className ?? []).join(' ')
|
|
722
|
-
}
|
|
723
|
-
onBlur={onBlur}
|
|
724
|
-
onClick={onClick}
|
|
725
|
-
onFocus={onFocus}
|
|
726
|
-
style={properties.styles}
|
|
727
731
|
>
|
|
728
|
-
<
|
|
729
|
-
{
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
{...properties.media}
|
|
733
|
-
style={{backgroundImage: `url(${properties.value.url})`}}
|
|
734
|
-
/> :
|
|
735
|
-
representationType === 'video' ?
|
|
736
|
-
<video autoPlay loop muted>
|
|
737
|
-
<source
|
|
738
|
-
src={properties.value.url}
|
|
739
|
-
type={properties.value.blob!.type}
|
|
740
|
-
/>
|
|
741
|
-
</video> :
|
|
742
|
-
representationType === 'renderableText' ?
|
|
743
|
-
<div className={
|
|
744
|
-
[styles['file-input__iframe-wrapper']].concat(
|
|
745
|
-
['text/html', 'text/plain'].includes(
|
|
746
|
-
properties.value.blob!.type!
|
|
747
|
-
) ?
|
|
748
|
-
styles['file-input__iframe-wrapper--padding'] :
|
|
749
|
-
[]
|
|
750
|
-
)
|
|
751
|
-
.join(' ')
|
|
752
|
-
}>
|
|
753
|
-
<iframe
|
|
754
|
-
frameBorder="no"
|
|
755
|
-
scrolling="no"
|
|
756
|
-
src={properties.value.url}
|
|
757
|
-
/>
|
|
758
|
-
</div> :
|
|
759
|
-
properties.value?.source && representationType === 'text' ?
|
|
760
|
-
<pre className={styles['file-input__text-representation']}>
|
|
761
|
-
{properties.value.source}
|
|
762
|
-
</pre> :
|
|
763
|
-
'' :
|
|
764
|
-
properties.value?.blob && properties.value.blob instanceof Blob ?
|
|
765
|
-
// NOTE: Only blobs have to red asynchronously.
|
|
766
|
-
<CircularProgress size="large" /> :
|
|
767
|
-
''
|
|
732
|
+
<Card
|
|
733
|
+
className={
|
|
734
|
+
[styles['file-input']].concat(properties.className ?? [])
|
|
735
|
+
.join(' ')
|
|
768
736
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
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> :
|
|
773
804
|
properties.description ?
|
|
774
805
|
properties.description :
|
|
775
806
|
properties.name
|
|
776
|
-
}</Theme> :
|
|
777
|
-
properties.description ?
|
|
778
|
-
properties.description :
|
|
779
|
-
properties.name
|
|
780
|
-
}
|
|
781
|
-
</Typography>
|
|
782
|
-
{properties.declaration ?
|
|
783
|
-
<Typography
|
|
784
|
-
style={{marginTop: '-1rem'}}
|
|
785
|
-
tag="h3"
|
|
786
|
-
theme="textSecondaryOnBackground"
|
|
787
|
-
use="subtitle2"
|
|
788
|
-
>
|
|
789
|
-
{invalid ?
|
|
790
|
-
<Theme use="error">
|
|
791
|
-
{properties.declaration}
|
|
792
|
-
</Theme> :
|
|
793
|
-
properties.declaration
|
|
794
807
|
}
|
|
795
|
-
</Typography>
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
{
|
|
803
|
-
disabled: properties.disabled,
|
|
804
|
-
value: properties.value?.name,
|
|
805
|
-
...defaultFileNameInputProperties,
|
|
806
|
-
model: properties.model.fileName,
|
|
807
|
-
onChangeValue: onChangeValue,
|
|
808
|
-
default: properties.value.name
|
|
809
|
-
},
|
|
810
|
-
properties as
|
|
811
|
-
Omit<Properties, 'value'> &
|
|
812
|
-
{value:FileValue & {name:string}}
|
|
813
|
-
)}
|
|
814
|
-
/> :
|
|
815
|
-
''
|
|
816
|
-
}
|
|
817
|
-
{properties.children ?
|
|
818
|
-
properties.children({
|
|
819
|
-
declaration: properties.declaration,
|
|
820
|
-
invalid,
|
|
821
|
-
properties,
|
|
822
|
-
value: properties.value
|
|
823
|
-
}) :
|
|
824
|
-
''
|
|
825
|
-
}
|
|
826
|
-
</div>
|
|
827
|
-
{/*TODO use "accept" attribute*/}
|
|
828
|
-
<input
|
|
829
|
-
disabled={properties.disabled}
|
|
830
|
-
className={styles['file-input__native']}
|
|
831
|
-
id={properties.id || properties.name}
|
|
832
|
-
name={properties.name}
|
|
833
|
-
onChange={onChangeValue}
|
|
834
|
-
ref={fileInputReference}
|
|
835
|
-
type="file"
|
|
836
|
-
/>
|
|
837
|
-
</CardPrimaryAction>
|
|
838
|
-
{!properties.disabled || properties.value ?
|
|
839
|
-
<CardActions>
|
|
840
|
-
<CardActionButtons>
|
|
841
|
-
{!properties.disabled ?
|
|
842
|
-
<CardActionButton
|
|
843
|
-
onClick={():void =>
|
|
844
|
-
fileInputReference.current?.click()
|
|
845
|
-
}
|
|
846
|
-
ref={uploadButtonReference}
|
|
847
|
-
ripple={properties.ripple}
|
|
808
|
+
</Typography>
|
|
809
|
+
{properties.declaration ?
|
|
810
|
+
<Typography
|
|
811
|
+
style={{marginTop: '-1rem'}}
|
|
812
|
+
tag="h3"
|
|
813
|
+
theme="textSecondaryOnBackground"
|
|
814
|
+
use="subtitle2"
|
|
848
815
|
>
|
|
849
|
-
{
|
|
850
|
-
|
|
851
|
-
|
|
816
|
+
{invalid ?
|
|
817
|
+
<Theme use="error">
|
|
818
|
+
{properties.declaration}
|
|
819
|
+
</Theme> :
|
|
820
|
+
properties.declaration
|
|
852
821
|
}
|
|
853
|
-
</
|
|
822
|
+
</Typography> :
|
|
854
823
|
''
|
|
855
824
|
}
|
|
856
825
|
{properties.value ?
|
|
857
|
-
|
|
858
|
-
{
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
<a
|
|
874
|
-
className={
|
|
875
|
-
styles['file-input__download']
|
|
876
|
-
}
|
|
877
|
-
download={properties.value.name}
|
|
878
|
-
href={properties.value.url}
|
|
879
|
-
ref={downloadLinkReference}
|
|
880
|
-
target="_blank"
|
|
881
|
-
{...(properties.value.blob?.type ?
|
|
882
|
-
{type:
|
|
883
|
-
properties.value.blob.type
|
|
884
|
-
} :
|
|
885
|
-
{}
|
|
886
|
-
)}
|
|
887
|
-
>{properties.downloadButton}</a>
|
|
888
|
-
</CardActionButton> :
|
|
889
|
-
''
|
|
890
|
-
}
|
|
891
|
-
</> :
|
|
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
|
+
/> :
|
|
892
842
|
''
|
|
893
843
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
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>
|
|
899
930
|
// endregion
|
|
900
931
|
}
|
|
901
932
|
// NOTE: This is useful in react dev tools.
|
|
@@ -904,13 +935,14 @@ FileInputInner.displayName = 'FileInput'
|
|
|
904
935
|
* Wrapping web component compatible react component.
|
|
905
936
|
* @property static:defaultModelState - Initial model state.
|
|
906
937
|
* @property static:defaultProperties - Initial property configuration.
|
|
907
|
-
* @property static:propTypes - Triggers reacts runtime property value checks
|
|
938
|
+
* @property static:propTypes - Triggers reacts runtime property value checks.
|
|
908
939
|
* @property static:strict - Indicates whether we should wrap render output in
|
|
909
940
|
* reacts strict component.
|
|
910
941
|
* @property static:wrapped - Wrapped component.
|
|
911
942
|
*
|
|
912
943
|
* @param props - Given components properties.
|
|
913
944
|
* @param reference - Reference object to forward internal state.
|
|
945
|
+
*
|
|
914
946
|
* @returns React elements.
|
|
915
947
|
*/
|
|
916
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;
|