react-input-material 0.0.405 → 0.0.408
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 +2 -2
- package/components/GenericInput.js +1 -1
- package/components/GenericInput.module.css +1 -0
- package/components/GenericInput.styles.css +1 -1
- package/components/GenericInput.tsx +62 -41
- package/components/Inputs.js +1 -1
- package/components/Inputs.styles.css +1 -1
- package/components/Interval.js +1 -1
- package/components/Interval.styles.css +1 -1
- package/helper.d.ts +13 -27
- package/helper.js +1 -1
- package/index.js +1 -1
- package/index.styles.css +2 -2
- package/package.json +1 -1
- package/type.d.ts +11 -11
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
MouseEvent as ReactMouseEvent,
|
|
33
33
|
MutableRefObject,
|
|
34
34
|
ReactElement,
|
|
35
|
+
ReactNode,
|
|
35
36
|
Suspense,
|
|
36
37
|
useEffect,
|
|
37
38
|
useImperativeHandle,
|
|
@@ -123,6 +124,7 @@ import {
|
|
|
123
124
|
InputState as State,
|
|
124
125
|
InputModel as Model,
|
|
125
126
|
NativeInputType,
|
|
127
|
+
NormalizedSelection,
|
|
126
128
|
Renderable,
|
|
127
129
|
GenericInputComponent,
|
|
128
130
|
InputTablePosition as TablePosition,
|
|
@@ -782,7 +784,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
782
784
|
const keysSorted:Array<keyof typeof indicator> =
|
|
783
785
|
['start', 'end']
|
|
784
786
|
|
|
785
|
-
let value:string = properties.representation
|
|
787
|
+
let value:string = properties.representation as string
|
|
786
788
|
for (const type of keysSorted)
|
|
787
789
|
value = (
|
|
788
790
|
value.substring(0, cursor[type]) +
|
|
@@ -887,9 +889,13 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
887
889
|
(event as unknown as KeyboardEvent)?.key?.length === 1 ?
|
|
888
890
|
1 :
|
|
889
891
|
(event as unknown as KeyboardEvent)?.key === 'Backspace' &&
|
|
890
|
-
|
|
892
|
+
(
|
|
893
|
+
(properties.representation as string).length >
|
|
894
|
+
selectionStart
|
|
895
|
+
) ?
|
|
891
896
|
-1 :
|
|
892
897
|
0
|
|
898
|
+
|
|
893
899
|
setCursor({end: selectionEnd + add, start: selectionStart + add})
|
|
894
900
|
}
|
|
895
901
|
}
|
|
@@ -1102,7 +1108,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1102
1108
|
|
|
1103
1109
|
if (!useSuggestions || properties.suggestSelection) {
|
|
1104
1110
|
const candidate:null|Type = getValueFromSelection<Type>(
|
|
1105
|
-
properties.representation, normalizedSelection
|
|
1111
|
+
properties.representation, normalizedSelection!
|
|
1106
1112
|
)
|
|
1107
1113
|
if (candidate === null) {
|
|
1108
1114
|
properties.value = parseValue<Type>(
|
|
@@ -1422,7 +1428,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1422
1428
|
|
|
1423
1429
|
if (selectedIndex === -1) {
|
|
1424
1430
|
const result:null|Type = getValueFromSelection<Type>(
|
|
1425
|
-
properties.representation, normalizeSelection(results)
|
|
1431
|
+
properties.representation, normalizeSelection(results)!
|
|
1426
1432
|
)
|
|
1427
1433
|
|
|
1428
1434
|
if (result !== null || properties.searchSelection)
|
|
@@ -1447,7 +1453,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1447
1453
|
) = properties.suggestionCreator({
|
|
1448
1454
|
abortController,
|
|
1449
1455
|
properties,
|
|
1450
|
-
query: properties.representation
|
|
1456
|
+
query: properties.representation as string
|
|
1451
1457
|
})
|
|
1452
1458
|
|
|
1453
1459
|
if ((result as Promise<Properties['selection']>)?.then) {
|
|
@@ -1489,7 +1495,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1489
1495
|
consolidation.
|
|
1490
1496
|
*/
|
|
1491
1497
|
const result:null|Type = getValueFromSelection<Type>(
|
|
1492
|
-
properties.representation, normalizedSelection
|
|
1498
|
+
properties.representation, normalizedSelection!
|
|
1493
1499
|
)
|
|
1494
1500
|
|
|
1495
1501
|
if (result !== null || properties.searchSelection)
|
|
@@ -1721,11 +1727,10 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1721
1727
|
selection =
|
|
1722
1728
|
givenProperties.selection || givenProperties.model?.selection
|
|
1723
1729
|
|
|
1724
|
-
const normalizedSelection:
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
normalizeSelection(selection, givenProperties.labels)
|
|
1730
|
+
const normalizedSelection:NormalizedSelection|undefined =
|
|
1731
|
+
selection instanceof AbortController ?
|
|
1732
|
+
[] :
|
|
1733
|
+
normalizeSelection(selection, givenProperties.labels)
|
|
1729
1734
|
const [suggestionLabels, suggestionValues] =
|
|
1730
1735
|
selection instanceof AbortController ?
|
|
1731
1736
|
[[], []] :
|
|
@@ -1924,7 +1929,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1924
1929
|
)
|
|
1925
1930
|
|
|
1926
1931
|
const currentRenderableSuggestions:Array<ReactElement> = []
|
|
1927
|
-
const currentSuggestionLabels:Array<string> = []
|
|
1932
|
+
const currentSuggestionLabels:Array<ReactNode|string> = []
|
|
1928
1933
|
const currentSuggestionValues:Array<unknown> = []
|
|
1929
1934
|
const useSuggestions = Boolean(
|
|
1930
1935
|
properties.suggestionCreator ||
|
|
@@ -1940,9 +1945,9 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1940
1945
|
if (Tools.isFunction(properties.children)) {
|
|
1941
1946
|
const result:null|ReactElement = properties.children({
|
|
1942
1947
|
index,
|
|
1943
|
-
normalizedSelection
|
|
1948
|
+
normalizedSelection: normalizedSelection!,
|
|
1944
1949
|
properties,
|
|
1945
|
-
query: properties.representation,
|
|
1950
|
+
query: properties.representation as string,
|
|
1946
1951
|
suggestion,
|
|
1947
1952
|
value: suggestionValues[index] as Type
|
|
1948
1953
|
})
|
|
@@ -1964,7 +1969,9 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1964
1969
|
} else if (
|
|
1965
1970
|
!properties.representation ||
|
|
1966
1971
|
properties.suggestionCreator ||
|
|
1967
|
-
suggestionMatches(
|
|
1972
|
+
suggestionMatches(
|
|
1973
|
+
suggestion as string, properties.representation as string
|
|
1974
|
+
)
|
|
1968
1975
|
) {
|
|
1969
1976
|
currentRenderableSuggestions.push(
|
|
1970
1977
|
<MenuItem
|
|
@@ -1975,7 +1982,9 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
1975
1982
|
>
|
|
1976
1983
|
{(Tools.stringMark(
|
|
1977
1984
|
suggestion,
|
|
1978
|
-
|
|
1985
|
+
(
|
|
1986
|
+
properties.representation as string
|
|
1987
|
+
)?.split(' ') || '',
|
|
1979
1988
|
(value:unknown):string =>
|
|
1980
1989
|
`${value as string}`.toLowerCase(),
|
|
1981
1990
|
(foundWord:string):ReactElement =>
|
|
@@ -2172,7 +2181,10 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
2172
2181
|
useWorker: false
|
|
2173
2182
|
}}
|
|
2174
2183
|
theme="github"
|
|
2175
|
-
value={
|
|
2184
|
+
value={
|
|
2185
|
+
properties.representation as
|
|
2186
|
+
string
|
|
2187
|
+
}
|
|
2176
2188
|
{...properties.inputProperties as
|
|
2177
2189
|
CodeEditorProps
|
|
2178
2190
|
}
|
|
@@ -2201,12 +2213,16 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
2201
2213
|
ref={setRichTextEditorReference}
|
|
2202
2214
|
textareaName={properties.name}
|
|
2203
2215
|
tinymceScriptSrc={
|
|
2204
|
-
(
|
|
2205
|
-
|
|
2216
|
+
(
|
|
2217
|
+
TINYMCE_DEFAULT_OPTIONS
|
|
2218
|
+
.base_url as
|
|
2219
|
+
string
|
|
2206
2220
|
) +
|
|
2207
2221
|
'tinymce.min.js'
|
|
2208
2222
|
}
|
|
2209
|
-
value={
|
|
2223
|
+
value={
|
|
2224
|
+
properties.representation as string
|
|
2225
|
+
}
|
|
2210
2226
|
{...properties.inputProperties as
|
|
2211
2227
|
RichTextEditorProps
|
|
2212
2228
|
}
|
|
@@ -2339,7 +2355,7 @@ export const GenericInputInner = function<Type = unknown>(
|
|
|
2339
2355
|
properties.trailingIcon
|
|
2340
2356
|
))}
|
|
2341
2357
|
type={determineNativeType(properties)}
|
|
2342
|
-
value={properties.representation}
|
|
2358
|
+
value={properties.representation as string}
|
|
2343
2359
|
{...properties.inputProperties as TextFieldProps}
|
|
2344
2360
|
/>
|
|
2345
2361
|
</div>,
|
|
@@ -2454,6 +2470,7 @@ GenericInput.transformer = {
|
|
|
2454
2470
|
NaN,
|
|
2455
2471
|
type: 'text'
|
|
2456
2472
|
},
|
|
2473
|
+
|
|
2457
2474
|
date: {
|
|
2458
2475
|
format: {final: {transform: (value:number):string => {
|
|
2459
2476
|
value = typeof value === 'number' ? value : parseFloat(value)
|
|
@@ -2475,7 +2492,7 @@ GenericInput.transformer = {
|
|
|
2475
2492
|
value :
|
|
2476
2493
|
value instanceof Date ?
|
|
2477
2494
|
value.getTime() / 1000 :
|
|
2478
|
-
|
|
2495
|
+
isNaN(Date.parse(value)) ?
|
|
2479
2496
|
parseFloat(value) :
|
|
2480
2497
|
Date.parse(value) / 1000
|
|
2481
2498
|
},
|
|
@@ -2503,7 +2520,9 @@ GenericInput.transformer = {
|
|
|
2503
2520
|
):number =>
|
|
2504
2521
|
transformer.date.parse ?
|
|
2505
2522
|
transformer.date.parse(value, configuration, transformer) :
|
|
2506
|
-
Date.parse(value as string)
|
|
2523
|
+
isNaN(Date.parse(value as string)) ?
|
|
2524
|
+
0 :
|
|
2525
|
+
Date.parse(value as string) / 1000
|
|
2507
2526
|
},
|
|
2508
2527
|
time: {
|
|
2509
2528
|
format: {final: {transform: (
|
|
@@ -2541,24 +2560,26 @@ GenericInput.transformer = {
|
|
|
2541
2560
|
value :
|
|
2542
2561
|
value instanceof Date ?
|
|
2543
2562
|
value.getTime() / 1000 :
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2563
|
+
isNaN(Date.parse(value)) ?
|
|
2564
|
+
parseFloat(value.replace(
|
|
2565
|
+
/^([0-9]{2}):([0-9]{2})(:([0-9]{2}(\.[0-9]+)?))?$/,
|
|
2566
|
+
(
|
|
2567
|
+
_match:string,
|
|
2568
|
+
hour:string,
|
|
2569
|
+
minute:string,
|
|
2570
|
+
secondsSuffix?:string,
|
|
2571
|
+
seconds?:string,
|
|
2572
|
+
_millisecondsSuffix?:string
|
|
2573
|
+
):string =>
|
|
2574
|
+
String(
|
|
2575
|
+
parseInt(hour) *
|
|
2576
|
+
60 ** 2 +
|
|
2577
|
+
parseInt(minute) *
|
|
2578
|
+
60 +
|
|
2579
|
+
(secondsSuffix ? parseFloat(seconds!) : 0)
|
|
2580
|
+
)
|
|
2581
|
+
)) :
|
|
2582
|
+
Date.parse(value) / 1000
|
|
2562
2583
|
},
|
|
2563
2584
|
|
|
2564
2585
|
float: {
|