react-input-material 0.0.433 → 0.0.435
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/FileInput.js +1 -1
- package/components/FileInput.styles.css +3 -3
- package/components/GenericAnimate.d.ts +5 -3
- package/components/GenericAnimate.js +1 -1
- package/components/GenericInput.js +1 -1
- package/components/GenericInput.styles.css +1 -1
- package/components/Inputs.js +1 -1
- package/components/Inputs.styles.css +2 -2
- package/components/Interval.js +1 -1
- package/components/Interval.styles.css +2 -2
- package/components/RequireableCheckbox.styles.css +1 -1
- package/index.js +1 -1
- package/index.styles.css +6 -6
- package/package.json +4 -2
- package/type.d.ts +5 -0
- package/components/Dummy.tsx +0 -58
- package/components/FileInput.tsx +0 -1010
- package/components/GenericAnimate.tsx +0 -88
- package/components/GenericInput.tsx +0 -2875
- package/components/Inputs.tsx +0 -585
- package/components/Interval.tsx +0 -436
- package/components/RequireableCheckbox.tsx +0 -520
- package/components/WrapConfigurations.tsx +0 -127
- package/components/WrapStrict.tsx +0 -43
- package/components/WrapThemeProvider.tsx +0 -48
- package/components/WrapTooltip.tsx +0 -67
package/components/Interval.tsx
DELETED
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
// #!/usr/bin/env babel-node
|
|
2
|
-
// -*- coding: utf-8 -*-
|
|
3
|
-
/** @module Interval */
|
|
4
|
-
'use strict'
|
|
5
|
-
/* !
|
|
6
|
-
region header
|
|
7
|
-
[Project page](https://torben.website/react-material-input)
|
|
8
|
-
|
|
9
|
-
Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
|
|
10
|
-
|
|
11
|
-
License
|
|
12
|
-
-------
|
|
13
|
-
|
|
14
|
-
This library written by Torben Sickert stand under a creative commons
|
|
15
|
-
naming 3.0 unported license.
|
|
16
|
-
See https://creativecommons.org/licenses/by/3.0/deed.de
|
|
17
|
-
endregion
|
|
18
|
-
*/
|
|
19
|
-
// region imports
|
|
20
|
-
import Tools from 'clientnode'
|
|
21
|
-
import {Mapping} from 'clientnode/type'
|
|
22
|
-
import {Icon} from '@rmwc/icon'
|
|
23
|
-
import {IconOptions} from '@rmwc/types'
|
|
24
|
-
import {
|
|
25
|
-
ForwardedRef,
|
|
26
|
-
forwardRef,
|
|
27
|
-
memo as memorize,
|
|
28
|
-
MutableRefObject,
|
|
29
|
-
ReactElement,
|
|
30
|
-
useImperativeHandle,
|
|
31
|
-
useRef,
|
|
32
|
-
useState
|
|
33
|
-
} from 'react'
|
|
34
|
-
|
|
35
|
-
import GenericInput from './GenericInput'
|
|
36
|
-
/*
|
|
37
|
-
"namedExport" version of css-loader:
|
|
38
|
-
|
|
39
|
-
import {intervalClassName, intervalDisabledClassName} from './Interval.module'
|
|
40
|
-
*/
|
|
41
|
-
import cssClassNames from './Interval.module'
|
|
42
|
-
import WrapConfigurations from './WrapConfigurations'
|
|
43
|
-
import {
|
|
44
|
-
createDummyStateSetter, translateKnownSymbols, triggerCallbackIfExists
|
|
45
|
-
} from '../helper'
|
|
46
|
-
import {
|
|
47
|
-
defaultIntervalProperties as defaultProperties,
|
|
48
|
-
GenericEvent,
|
|
49
|
-
InputProps,
|
|
50
|
-
InputProperties,
|
|
51
|
-
InputAdapterWithReferences,
|
|
52
|
-
IntervalAdapter as Adapter,
|
|
53
|
-
IntervalAdapterWithReferences as AdapterWithReferences,
|
|
54
|
-
IntervalComponent,
|
|
55
|
-
IntervalModelState as ModelState,
|
|
56
|
-
IntervalProperties as Properties,
|
|
57
|
-
intervalPropertyTypes as propertyTypes,
|
|
58
|
-
IntervalProps as Props,
|
|
59
|
-
IntervalValue as Value
|
|
60
|
-
} from '../type'
|
|
61
|
-
// endregion
|
|
62
|
-
const CSS_CLASS_NAMES:Mapping = cssClassNames as Mapping
|
|
63
|
-
// region helper
|
|
64
|
-
const getModelState = (
|
|
65
|
-
startProperties:InputProperties<number>,
|
|
66
|
-
endProperties:InputProperties<number>
|
|
67
|
-
):ModelState => ({
|
|
68
|
-
dirty: startProperties.dirty || endProperties.dirty,
|
|
69
|
-
focused: startProperties.focused || endProperties.focused,
|
|
70
|
-
invalid: startProperties.invalid || endProperties.invalid,
|
|
71
|
-
invalidRequired:
|
|
72
|
-
startProperties.invalidRequired ||
|
|
73
|
-
endProperties.invalidRequired,
|
|
74
|
-
pristine: startProperties.pristine && endProperties.pristine,
|
|
75
|
-
touched: startProperties.touched || endProperties.touched,
|
|
76
|
-
untouched: startProperties.untouched && endProperties.untouched,
|
|
77
|
-
valid: startProperties.valid && endProperties.valid,
|
|
78
|
-
visited: startProperties.visited || endProperties.visited
|
|
79
|
-
})
|
|
80
|
-
const getExternalProperties = (
|
|
81
|
-
properties:Properties,
|
|
82
|
-
iconProperties:IconOptions,
|
|
83
|
-
startProperties:InputProperties<number>,
|
|
84
|
-
endProperties:InputProperties<number>
|
|
85
|
-
):Properties => {
|
|
86
|
-
const modelState:ModelState =
|
|
87
|
-
getModelState(startProperties, endProperties)
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
...properties,
|
|
91
|
-
...modelState,
|
|
92
|
-
icon: iconProperties,
|
|
93
|
-
model: {
|
|
94
|
-
name: properties.name,
|
|
95
|
-
state: modelState,
|
|
96
|
-
value: {
|
|
97
|
-
end: endProperties.model,
|
|
98
|
-
start: startProperties.model
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
value: {
|
|
102
|
-
end: endProperties,
|
|
103
|
-
start: startProperties
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// endregion
|
|
108
|
-
/**
|
|
109
|
-
* Generic interval start, end input wrapper component.
|
|
110
|
-
* @param props - Component properties.
|
|
111
|
-
* @param reference - Mutable reference bound to created component instance.
|
|
112
|
-
*
|
|
113
|
-
* @returns React elements.
|
|
114
|
-
*/
|
|
115
|
-
export const IntervalInner = function(
|
|
116
|
-
props:Props, reference?:ForwardedRef<Adapter>
|
|
117
|
-
):ReactElement {
|
|
118
|
-
// region consolidate properties
|
|
119
|
-
const givenProps:Props = translateKnownSymbols(props) as Props
|
|
120
|
-
/*
|
|
121
|
-
Normalize value property (providing only value instead of props is
|
|
122
|
-
allowed also).
|
|
123
|
-
*/
|
|
124
|
-
if (!givenProps.value)
|
|
125
|
-
givenProps.value = {
|
|
126
|
-
end: {value: givenProps.value}, start: {value: givenProps.value}
|
|
127
|
-
}
|
|
128
|
-
if (typeof givenProps.value.end === 'number')
|
|
129
|
-
givenProps.value.end = {value: givenProps.value.end}
|
|
130
|
-
if (typeof givenProps.value.start === 'number')
|
|
131
|
-
givenProps.value.start = {value: givenProps.value.start}
|
|
132
|
-
/*
|
|
133
|
-
NOTE: Extend default properties with given properties while letting
|
|
134
|
-
default property object untouched for unchanged usage in other
|
|
135
|
-
instances.
|
|
136
|
-
*/
|
|
137
|
-
const properties:Omit<Props, 'value'> & {value:Properties['value']} =
|
|
138
|
-
Tools.extend(
|
|
139
|
-
true, Tools.copy(Interval.defaultProperties), givenProps
|
|
140
|
-
) as Properties
|
|
141
|
-
|
|
142
|
-
let endProperties:InputProps<number> = properties.value?.end || {}
|
|
143
|
-
const iconProperties:IconOptions = typeof properties.icon === 'string' ?
|
|
144
|
-
{icon: properties.icon} :
|
|
145
|
-
properties.icon!
|
|
146
|
-
let startProperties:InputProps<number> = properties.value?.start || {}
|
|
147
|
-
|
|
148
|
-
/*
|
|
149
|
-
NOTE: Sometimes we need real given properties or derived (default
|
|
150
|
-
extended) "given" properties.
|
|
151
|
-
*/
|
|
152
|
-
const controlled:boolean =
|
|
153
|
-
!properties.enforceUncontrolled &&
|
|
154
|
-
(
|
|
155
|
-
givenProps.model?.value?.end?.value !== undefined ||
|
|
156
|
-
givenProps.model?.value?.start?.value !== undefined ||
|
|
157
|
-
givenProps.value !== undefined
|
|
158
|
-
) &&
|
|
159
|
-
Boolean(properties.onChange || properties.onChangeValue)
|
|
160
|
-
|
|
161
|
-
let [value, setValue] = useState<Value>({
|
|
162
|
-
end:
|
|
163
|
-
endProperties.value ??
|
|
164
|
-
properties.model?.value?.end?.value ??
|
|
165
|
-
endProperties.default ??
|
|
166
|
-
properties.model?.value?.end?.default ??
|
|
167
|
-
null,
|
|
168
|
-
start:
|
|
169
|
-
startProperties.value ??
|
|
170
|
-
properties.model?.value?.end?.value ??
|
|
171
|
-
startProperties.default ??
|
|
172
|
-
properties.model?.value?.start?.default ??
|
|
173
|
-
null
|
|
174
|
-
})
|
|
175
|
-
if (!properties.value)
|
|
176
|
-
properties.value =
|
|
177
|
-
{end: {value: value.end}, start: {value: value.start}}
|
|
178
|
-
const propertiesToForward:InputProps<number> =
|
|
179
|
-
Tools.mask<InputProps<number>>(
|
|
180
|
-
properties as unknown as InputProps<number>,
|
|
181
|
-
{exclude: {
|
|
182
|
-
className: true,
|
|
183
|
-
enforceUncontrolled: true,
|
|
184
|
-
end: true,
|
|
185
|
-
icon: true,
|
|
186
|
-
start: true,
|
|
187
|
-
model: true,
|
|
188
|
-
name: true,
|
|
189
|
-
onChange: true,
|
|
190
|
-
onChangeValue: true,
|
|
191
|
-
style: true,
|
|
192
|
-
value: true
|
|
193
|
-
}}
|
|
194
|
-
) as InputProps<number>
|
|
195
|
-
|
|
196
|
-
endProperties = Tools.extend(
|
|
197
|
-
true,
|
|
198
|
-
Tools.copy(propertiesToForward),
|
|
199
|
-
properties.model?.value?.end ?
|
|
200
|
-
{model: properties.model.value.end} :
|
|
201
|
-
{},
|
|
202
|
-
endProperties
|
|
203
|
-
)
|
|
204
|
-
startProperties = Tools.extend(
|
|
205
|
-
true,
|
|
206
|
-
Tools.copy(propertiesToForward),
|
|
207
|
-
properties.model?.value?.start ?
|
|
208
|
-
{model: properties.model.value.start} :
|
|
209
|
-
{},
|
|
210
|
-
startProperties
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
if (!endProperties.className)
|
|
214
|
-
endProperties.className = `${CSS_CLASS_NAMES.interval}__end`
|
|
215
|
-
if (!iconProperties.className)
|
|
216
|
-
iconProperties.className = `${CSS_CLASS_NAMES.interval}__icon`
|
|
217
|
-
if (!startProperties.className)
|
|
218
|
-
startProperties.className = `${CSS_CLASS_NAMES.interval}__start`
|
|
219
|
-
|
|
220
|
-
const endConfiguration = {...endProperties.model, ...endProperties}
|
|
221
|
-
const startConfiguration = {...startProperties.model, ...startProperties}
|
|
222
|
-
|
|
223
|
-
startProperties.maximum = Math.min(
|
|
224
|
-
typeof startConfiguration.maximum === 'number' ?
|
|
225
|
-
startConfiguration.maximum :
|
|
226
|
-
Infinity,
|
|
227
|
-
properties.value.end.value || Infinity,
|
|
228
|
-
typeof endConfiguration.maximum === 'number' ?
|
|
229
|
-
endConfiguration.maximum :
|
|
230
|
-
Infinity
|
|
231
|
-
)
|
|
232
|
-
startProperties.minimum = startConfiguration.minimum || -Infinity
|
|
233
|
-
startProperties.value = properties.value.start.value
|
|
234
|
-
|
|
235
|
-
endProperties.maximum = typeof endConfiguration.maximum === 'number' ?
|
|
236
|
-
endConfiguration.maximum :
|
|
237
|
-
Infinity
|
|
238
|
-
endProperties.minimum = Math.max(
|
|
239
|
-
typeof endConfiguration.minimum === 'number' ?
|
|
240
|
-
endConfiguration.minimum :
|
|
241
|
-
-Infinity,
|
|
242
|
-
properties.value.start.value || -Infinity,
|
|
243
|
-
typeof startConfiguration.minimum === 'number' ?
|
|
244
|
-
startConfiguration.minimum :
|
|
245
|
-
-Infinity
|
|
246
|
-
)
|
|
247
|
-
endProperties.value = properties.value.end.value
|
|
248
|
-
|
|
249
|
-
const endInputReference:MutableRefObject<
|
|
250
|
-
InputAdapterWithReferences<number>|null
|
|
251
|
-
> = useRef<InputAdapterWithReferences<number>>(null)
|
|
252
|
-
const startInputReference:MutableRefObject<
|
|
253
|
-
InputAdapterWithReferences<number>|null
|
|
254
|
-
> = useRef<InputAdapterWithReferences<number>>(null)
|
|
255
|
-
|
|
256
|
-
const valueState:Value = {
|
|
257
|
-
end: properties.value.end.value,
|
|
258
|
-
start: properties.value.start.value
|
|
259
|
-
}
|
|
260
|
-
if (controlled)
|
|
261
|
-
/*
|
|
262
|
-
NOTE: We act as a controlled component by overwriting internal
|
|
263
|
-
state setter.
|
|
264
|
-
*/
|
|
265
|
-
setValue = createDummyStateSetter<Value>(valueState)
|
|
266
|
-
// endregion
|
|
267
|
-
useImperativeHandle(
|
|
268
|
-
reference,
|
|
269
|
-
():AdapterWithReferences => ({
|
|
270
|
-
properties: getExternalProperties(
|
|
271
|
-
properties as Properties,
|
|
272
|
-
iconProperties,
|
|
273
|
-
startInputReference.current?.properties ||
|
|
274
|
-
properties.value.start as InputProperties<number>,
|
|
275
|
-
endInputReference.current?.properties ||
|
|
276
|
-
properties.value.end as InputProperties<number>
|
|
277
|
-
),
|
|
278
|
-
references: {end: endInputReference, start: startInputReference},
|
|
279
|
-
state: controlled ? {} : {value: valueState}
|
|
280
|
-
})
|
|
281
|
-
)
|
|
282
|
-
// region attach event handler
|
|
283
|
-
if (properties.onChange) {
|
|
284
|
-
endProperties.onChange = (
|
|
285
|
-
inputProperties:InputProperties<number>, event?:GenericEvent
|
|
286
|
-
):void => {
|
|
287
|
-
const start:InputProperties<number> =
|
|
288
|
-
startInputReference.current?.properties ||
|
|
289
|
-
startProperties as unknown as InputProperties<number>
|
|
290
|
-
start.value = Math.min(
|
|
291
|
-
startInputReference.current?.properties?.value ?? Infinity,
|
|
292
|
-
inputProperties.value ?? Infinity
|
|
293
|
-
)
|
|
294
|
-
|
|
295
|
-
triggerCallbackIfExists<Properties>(
|
|
296
|
-
properties as Properties,
|
|
297
|
-
'change',
|
|
298
|
-
controlled,
|
|
299
|
-
getExternalProperties(
|
|
300
|
-
properties as Properties,
|
|
301
|
-
iconProperties,
|
|
302
|
-
start,
|
|
303
|
-
inputProperties
|
|
304
|
-
),
|
|
305
|
-
event,
|
|
306
|
-
properties
|
|
307
|
-
)
|
|
308
|
-
}
|
|
309
|
-
startProperties.onChange = (
|
|
310
|
-
inputProperties:InputProperties<number>, event?:GenericEvent
|
|
311
|
-
):void => {
|
|
312
|
-
const end:InputProperties<number> =
|
|
313
|
-
endInputReference.current?.properties ||
|
|
314
|
-
endProperties as unknown as InputProperties<number>
|
|
315
|
-
end.value = Math.max(
|
|
316
|
-
endInputReference.current?.properties?.value ?? -Infinity,
|
|
317
|
-
inputProperties.value ?? -Infinity
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
triggerCallbackIfExists<Properties>(
|
|
321
|
-
properties as Properties,
|
|
322
|
-
'change',
|
|
323
|
-
controlled,
|
|
324
|
-
getExternalProperties(
|
|
325
|
-
properties as Properties,
|
|
326
|
-
iconProperties,
|
|
327
|
-
inputProperties,
|
|
328
|
-
end
|
|
329
|
-
),
|
|
330
|
-
event,
|
|
331
|
-
properties
|
|
332
|
-
)
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
endProperties.onChangeValue = (
|
|
337
|
-
value:null|number, event?:GenericEvent
|
|
338
|
-
):void => {
|
|
339
|
-
const startValue:number = Math.min(
|
|
340
|
-
startInputReference.current?.properties?.value ?? Infinity,
|
|
341
|
-
value ?? Infinity
|
|
342
|
-
)
|
|
343
|
-
const newValue:Value = {
|
|
344
|
-
end: value, start: isFinite(startValue) ? startValue : value
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
triggerCallbackIfExists<Properties>(
|
|
348
|
-
properties as Properties,
|
|
349
|
-
'changeValue',
|
|
350
|
-
controlled,
|
|
351
|
-
newValue,
|
|
352
|
-
event,
|
|
353
|
-
properties
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
setValue(newValue)
|
|
357
|
-
}
|
|
358
|
-
startProperties.onChangeValue = (
|
|
359
|
-
value:null|number, event?:GenericEvent
|
|
360
|
-
):void => {
|
|
361
|
-
const endValue:number = Math.max(
|
|
362
|
-
endInputReference.current?.properties?.value ?? -Infinity,
|
|
363
|
-
value ?? -Infinity
|
|
364
|
-
)
|
|
365
|
-
const newValue:Value = {
|
|
366
|
-
end: isFinite(endValue) ? endValue : value, start: value
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
triggerCallbackIfExists<Properties>(
|
|
370
|
-
properties as Properties,
|
|
371
|
-
'changeValue',
|
|
372
|
-
controlled,
|
|
373
|
-
newValue,
|
|
374
|
-
event,
|
|
375
|
-
properties
|
|
376
|
-
)
|
|
377
|
-
|
|
378
|
-
setValue(newValue)
|
|
379
|
-
}
|
|
380
|
-
// endregion
|
|
381
|
-
return <WrapConfigurations
|
|
382
|
-
strict={Interval.strict}
|
|
383
|
-
themeConfiguration={properties.themeConfiguration}
|
|
384
|
-
>
|
|
385
|
-
<div
|
|
386
|
-
className={[CSS_CLASS_NAMES.interval]
|
|
387
|
-
.concat(
|
|
388
|
-
properties.className ?? [],
|
|
389
|
-
properties.disabled ?
|
|
390
|
-
CSS_CLASS_NAMES['interval--disabled'] :
|
|
391
|
-
[]
|
|
392
|
-
)
|
|
393
|
-
.join(' ')
|
|
394
|
-
}
|
|
395
|
-
data-name={properties.name}
|
|
396
|
-
style={properties.styles}
|
|
397
|
-
>
|
|
398
|
-
<GenericInput
|
|
399
|
-
{...startProperties} ref={startInputReference}
|
|
400
|
-
/>
|
|
401
|
-
<Icon icon={iconProperties} />
|
|
402
|
-
<GenericInput {...endProperties} ref={endInputReference} />
|
|
403
|
-
</div>
|
|
404
|
-
</WrapConfigurations>
|
|
405
|
-
}
|
|
406
|
-
// NOTE: This is useful in react dev tools.
|
|
407
|
-
IntervalInner.displayName = 'Interval'
|
|
408
|
-
/**
|
|
409
|
-
* Wrapping web component compatible react component.
|
|
410
|
-
* @property static:defaultProperties - Initial property configuration.
|
|
411
|
-
* @property static:propTypes - Triggers reacts runtime property value checks.
|
|
412
|
-
* @property static:strict - Indicates whether we should wrap render output in
|
|
413
|
-
* reacts strict component.
|
|
414
|
-
* @property static:wrapped - Wrapped component.
|
|
415
|
-
*
|
|
416
|
-
* @param props - Given components properties.
|
|
417
|
-
* @param reference - Reference object to forward internal state.
|
|
418
|
-
*
|
|
419
|
-
* @returns React elements.
|
|
420
|
-
*/
|
|
421
|
-
export const Interval:IntervalComponent =
|
|
422
|
-
memorize(forwardRef(IntervalInner)) as unknown as IntervalComponent
|
|
423
|
-
// region static properties
|
|
424
|
-
/// region web-component hints
|
|
425
|
-
Interval.wrapped = IntervalInner
|
|
426
|
-
Interval.webComponentAdapterWrapped = 'react'
|
|
427
|
-
/// endregion
|
|
428
|
-
Interval.defaultProperties = defaultProperties
|
|
429
|
-
Interval.propTypes = propertyTypes
|
|
430
|
-
Interval.strict = false
|
|
431
|
-
// endregion
|
|
432
|
-
export default Interval
|
|
433
|
-
// region vim modline
|
|
434
|
-
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
435
|
-
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
436
|
-
// endregion
|