@bbl-digital/snorre 3.0.11 → 3.0.15
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +21 -16
- package/esm/core/Autocomplete/hooks/useAutocomplete.js +19 -16
- package/esm/core/Timepicker/index.js +2 -0
- package/lib/core/Autocomplete/hooks/useAutocomplete.d.ts.map +1 -1
- package/lib/core/Autocomplete/hooks/useAutocomplete.js +19 -16
- package/lib/core/Timepicker/index.d.ts +2 -0
- package/lib/core/Timepicker/index.d.ts.map +1 -1
- package/lib/core/Timepicker/index.js +2 -0
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
@@ -30324,6 +30324,7 @@
|
|
30324
30324
|
css,
|
30325
30325
|
validation,
|
30326
30326
|
invalidMessage,
|
30327
|
+
autoFocus,
|
30327
30328
|
onChange,
|
30328
30329
|
onBlur
|
30329
30330
|
}) => {
|
@@ -30421,6 +30422,7 @@
|
|
30421
30422
|
type: "text",
|
30422
30423
|
value: inputStateValue,
|
30423
30424
|
disabled: disabled,
|
30425
|
+
autoFocus: autoFocus,
|
30424
30426
|
css: theme => [disabled && styles$7.disabled(theme), css && css],
|
30425
30427
|
onChange: event => onInputChange(event, v => onChange && onChange(v)),
|
30426
30428
|
onBlur: onBlur,
|
@@ -31850,41 +31852,45 @@
|
|
31850
31852
|
const [inputDirty, setInputDirty] = React.useState(false);
|
31851
31853
|
const debouncedValue = useDebounce(value, props.debounceDelay ?? 0);
|
31852
31854
|
const [inputValues, setInputValues] = React.useState(props.values);
|
31855
|
+
const labelKey = props.labelFromValues ?? 'label';
|
31853
31856
|
|
31854
31857
|
const handleValueClick = value => {
|
31855
31858
|
props.onSelectItem?.(value);
|
31859
|
+
if (props.fuzzy) setValueChanged(value[labelKey]);
|
31856
31860
|
setShowValues(false);
|
31857
31861
|
};
|
31858
31862
|
|
31859
31863
|
const clearSelectedItem = () => handleValueClick({
|
31860
|
-
[
|
31864
|
+
[labelKey]: '',
|
31861
31865
|
[props.keyFromValues ?? 'key']: ''
|
31862
31866
|
});
|
31863
31867
|
|
31864
31868
|
const onInputChange = e => {
|
31865
31869
|
setInputDirty(true);
|
31866
|
-
if (
|
31870
|
+
if (renderedValues) setHighlightedIndex(0);
|
31867
31871
|
setValueChanged(e.target.value); // Should not use onChange whenever we have fuzzy search on
|
31868
31872
|
|
31869
|
-
if (props.fuzzy)
|
31873
|
+
if (props.fuzzy) {
|
31874
|
+
setShowValues(Boolean(value));
|
31875
|
+
return;
|
31876
|
+
}
|
31877
|
+
|
31870
31878
|
if (props.onChange) props.onChange(e);
|
31871
31879
|
};
|
31872
31880
|
|
31873
31881
|
const handleOnInputClick = () => {
|
31874
|
-
if (
|
31882
|
+
if (renderedValues?.length) setHighlightedIndex(0);
|
31875
31883
|
setShowValues(true);
|
31876
31884
|
};
|
31877
31885
|
|
31878
31886
|
const onFuzzyBlur = e => {
|
31879
|
-
// If the value of the input is changed, and does not match the value of the values array,
|
31880
|
-
// we should revert back the input value to the original value
|
31881
31887
|
if (e.target.value === props.value) return; // If target value is the same as a value from the values array, we should set the value for the user
|
31882
31888
|
|
31883
31889
|
if (inputValues?.length) {
|
31884
|
-
const valueInInputValues = inputValues.find(item => item[
|
31890
|
+
const valueInInputValues = inputValues.find(item => item[labelKey].length && item[labelKey].toLowerCase() === e.target.value.toLowerCase());
|
31885
31891
|
|
31886
31892
|
if (valueInInputValues) {
|
31887
|
-
const val = valueInInputValues[
|
31893
|
+
const val = valueInInputValues[labelKey];
|
31888
31894
|
setValueChanged(val);
|
31889
31895
|
handleValueClick(valueInInputValues);
|
31890
31896
|
return;
|
@@ -31902,9 +31908,8 @@
|
|
31902
31908
|
|
31903
31909
|
if (props.fuzzy) {
|
31904
31910
|
const fuzzyOptions = {
|
31905
|
-
keys: [
|
31911
|
+
keys: [labelKey]
|
31906
31912
|
};
|
31907
|
-
setShowValues(Boolean(value));
|
31908
31913
|
return matchSorter.matchSorter(props.values, value ?? '', fuzzyOptions);
|
31909
31914
|
}
|
31910
31915
|
|
@@ -31933,11 +31938,11 @@
|
|
31933
31938
|
});
|
31934
31939
|
}
|
31935
31940
|
|
31936
|
-
if (highlightedIndex === null || !
|
31941
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
31937
31942
|
return;
|
31938
31943
|
}
|
31939
31944
|
|
31940
|
-
const item =
|
31945
|
+
const item = renderedValues[highlightedIndex];
|
31941
31946
|
handleValueClick(item);
|
31942
31947
|
setShowValues(false);
|
31943
31948
|
};
|
@@ -31947,7 +31952,7 @@
|
|
31947
31952
|
e.stopPropagation();
|
31948
31953
|
if (!showValues) return;
|
31949
31954
|
|
31950
|
-
if (highlightedIndex === null || !
|
31955
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
31951
31956
|
return;
|
31952
31957
|
}
|
31953
31958
|
|
@@ -31967,13 +31972,13 @@
|
|
31967
31972
|
e.preventDefault();
|
31968
31973
|
e.stopPropagation();
|
31969
31974
|
|
31970
|
-
if (highlightedIndex === null || !
|
31975
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
31971
31976
|
return;
|
31972
31977
|
}
|
31973
31978
|
|
31974
31979
|
const newHighlightIndex = highlightedIndex + 1;
|
31975
31980
|
|
31976
|
-
if (newHighlightIndex ===
|
31981
|
+
if (newHighlightIndex === renderedValues.length) {
|
31977
31982
|
setHighlightedIndex(null);
|
31978
31983
|
setShowValues(false);
|
31979
31984
|
return;
|
@@ -32001,7 +32006,7 @@
|
|
32001
32006
|
key
|
32002
32007
|
} = e;
|
32003
32008
|
|
32004
|
-
if (showValues &&
|
32009
|
+
if (showValues && renderedValues?.length) {
|
32005
32010
|
setHighlightedIndex(0);
|
32006
32011
|
} else {
|
32007
32012
|
setHighlightedIndex(null);
|
@@ -10,41 +10,45 @@ const useAutocomplete = props => {
|
|
10
10
|
const [inputDirty, setInputDirty] = useState(false);
|
11
11
|
const debouncedValue = useDebounce(value, props.debounceDelay ?? 0);
|
12
12
|
const [inputValues, setInputValues] = useState(props.values);
|
13
|
+
const labelKey = props.labelFromValues ?? 'label';
|
13
14
|
|
14
15
|
const handleValueClick = value => {
|
15
16
|
props.onSelectItem?.(value);
|
17
|
+
if (props.fuzzy) setValueChanged(value[labelKey]);
|
16
18
|
setShowValues(false);
|
17
19
|
};
|
18
20
|
|
19
21
|
const clearSelectedItem = () => handleValueClick({
|
20
|
-
[
|
22
|
+
[labelKey]: '',
|
21
23
|
[props.keyFromValues ?? 'key']: ''
|
22
24
|
});
|
23
25
|
|
24
26
|
const onInputChange = e => {
|
25
27
|
setInputDirty(true);
|
26
|
-
if (
|
28
|
+
if (renderedValues) setHighlightedIndex(0);
|
27
29
|
setValueChanged(e.target.value); // Should not use onChange whenever we have fuzzy search on
|
28
30
|
|
29
|
-
if (props.fuzzy)
|
31
|
+
if (props.fuzzy) {
|
32
|
+
setShowValues(Boolean(value));
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
|
30
36
|
if (props.onChange) props.onChange(e);
|
31
37
|
};
|
32
38
|
|
33
39
|
const handleOnInputClick = () => {
|
34
|
-
if (
|
40
|
+
if (renderedValues?.length) setHighlightedIndex(0);
|
35
41
|
setShowValues(true);
|
36
42
|
};
|
37
43
|
|
38
44
|
const onFuzzyBlur = e => {
|
39
|
-
// If the value of the input is changed, and does not match the value of the values array,
|
40
|
-
// we should revert back the input value to the original value
|
41
45
|
if (e.target.value === props.value) return; // If target value is the same as a value from the values array, we should set the value for the user
|
42
46
|
|
43
47
|
if (inputValues?.length) {
|
44
|
-
const valueInInputValues = inputValues.find(item => item[
|
48
|
+
const valueInInputValues = inputValues.find(item => item[labelKey].length && item[labelKey].toLowerCase() === e.target.value.toLowerCase());
|
45
49
|
|
46
50
|
if (valueInInputValues) {
|
47
|
-
const val = valueInInputValues[
|
51
|
+
const val = valueInInputValues[labelKey];
|
48
52
|
setValueChanged(val);
|
49
53
|
handleValueClick(valueInInputValues);
|
50
54
|
return;
|
@@ -62,9 +66,8 @@ const useAutocomplete = props => {
|
|
62
66
|
|
63
67
|
if (props.fuzzy) {
|
64
68
|
const fuzzyOptions = {
|
65
|
-
keys: [
|
69
|
+
keys: [labelKey]
|
66
70
|
};
|
67
|
-
setShowValues(Boolean(value));
|
68
71
|
return matchSorter(props.values, value ?? '', fuzzyOptions);
|
69
72
|
}
|
70
73
|
|
@@ -93,11 +96,11 @@ const useAutocomplete = props => {
|
|
93
96
|
});
|
94
97
|
}
|
95
98
|
|
96
|
-
if (highlightedIndex === null || !
|
99
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
97
100
|
return;
|
98
101
|
}
|
99
102
|
|
100
|
-
const item =
|
103
|
+
const item = renderedValues[highlightedIndex];
|
101
104
|
handleValueClick(item);
|
102
105
|
setShowValues(false);
|
103
106
|
};
|
@@ -107,7 +110,7 @@ const useAutocomplete = props => {
|
|
107
110
|
e.stopPropagation();
|
108
111
|
if (!showValues) return;
|
109
112
|
|
110
|
-
if (highlightedIndex === null || !
|
113
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
111
114
|
return;
|
112
115
|
}
|
113
116
|
|
@@ -127,13 +130,13 @@ const useAutocomplete = props => {
|
|
127
130
|
e.preventDefault();
|
128
131
|
e.stopPropagation();
|
129
132
|
|
130
|
-
if (highlightedIndex === null || !
|
133
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
131
134
|
return;
|
132
135
|
}
|
133
136
|
|
134
137
|
const newHighlightIndex = highlightedIndex + 1;
|
135
138
|
|
136
|
-
if (newHighlightIndex ===
|
139
|
+
if (newHighlightIndex === renderedValues.length) {
|
137
140
|
setHighlightedIndex(null);
|
138
141
|
setShowValues(false);
|
139
142
|
return;
|
@@ -161,7 +164,7 @@ const useAutocomplete = props => {
|
|
161
164
|
key
|
162
165
|
} = e;
|
163
166
|
|
164
|
-
if (showValues &&
|
167
|
+
if (showValues && renderedValues?.length) {
|
165
168
|
setHighlightedIndex(0);
|
166
169
|
} else {
|
167
170
|
setHighlightedIndex(null);
|
@@ -18,6 +18,7 @@ const TimePicker = ({
|
|
18
18
|
css,
|
19
19
|
validation,
|
20
20
|
invalidMessage,
|
21
|
+
autoFocus,
|
21
22
|
onChange,
|
22
23
|
onBlur
|
23
24
|
}) => {
|
@@ -115,6 +116,7 @@ const TimePicker = ({
|
|
115
116
|
type: "text",
|
116
117
|
value: inputStateValue,
|
117
118
|
disabled: disabled,
|
119
|
+
autoFocus: autoFocus,
|
118
120
|
css: theme => [disabled && styles.disabled(theme), css && css],
|
119
121
|
onChange: event => onInputChange(event, v => onChange && onChange(v)),
|
120
122
|
onBlur: onBlur,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAutocomplete.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/Autocomplete/hooks/useAutocomplete.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE1D,QAAA,MAAM,eAAe,UAAW,MAAM;;;;;;
|
1
|
+
{"version":3,"file":"useAutocomplete.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/Autocomplete/hooks/useAutocomplete.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE1D,QAAA,MAAM,eAAe,UAAW,MAAM;;;;;;uBA2BV,MAAM,WAAW,CAAC,gBAAgB,CAAC;yBA6IjC,mBAAmB,CAAC,gBAAgB,CAAC;+BAZ/B,mBAAmB,CAAC,gBAAgB,CAAC;;qBA7G/C,gBAAgB,CAAC,gBAAgB,EAAE,OAAO,CAAC;;;;;;CAuMpE,CAAA;AAED,eAAe,eAAe,CAAA"}
|
@@ -10,41 +10,45 @@ const useAutocomplete = props => {
|
|
10
10
|
const [inputDirty, setInputDirty] = useState(false);
|
11
11
|
const debouncedValue = useDebounce(value, props.debounceDelay ?? 0);
|
12
12
|
const [inputValues, setInputValues] = useState(props.values);
|
13
|
+
const labelKey = props.labelFromValues ?? 'label';
|
13
14
|
|
14
15
|
const handleValueClick = value => {
|
15
16
|
props.onSelectItem?.(value);
|
17
|
+
if (props.fuzzy) setValueChanged(value[labelKey]);
|
16
18
|
setShowValues(false);
|
17
19
|
};
|
18
20
|
|
19
21
|
const clearSelectedItem = () => handleValueClick({
|
20
|
-
[
|
22
|
+
[labelKey]: '',
|
21
23
|
[props.keyFromValues ?? 'key']: ''
|
22
24
|
});
|
23
25
|
|
24
26
|
const onInputChange = e => {
|
25
27
|
setInputDirty(true);
|
26
|
-
if (
|
28
|
+
if (renderedValues) setHighlightedIndex(0);
|
27
29
|
setValueChanged(e.target.value); // Should not use onChange whenever we have fuzzy search on
|
28
30
|
|
29
|
-
if (props.fuzzy)
|
31
|
+
if (props.fuzzy) {
|
32
|
+
setShowValues(Boolean(value));
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
|
30
36
|
if (props.onChange) props.onChange(e);
|
31
37
|
};
|
32
38
|
|
33
39
|
const handleOnInputClick = () => {
|
34
|
-
if (
|
40
|
+
if (renderedValues?.length) setHighlightedIndex(0);
|
35
41
|
setShowValues(true);
|
36
42
|
};
|
37
43
|
|
38
44
|
const onFuzzyBlur = e => {
|
39
|
-
// If the value of the input is changed, and does not match the value of the values array,
|
40
|
-
// we should revert back the input value to the original value
|
41
45
|
if (e.target.value === props.value) return; // If target value is the same as a value from the values array, we should set the value for the user
|
42
46
|
|
43
47
|
if (inputValues?.length) {
|
44
|
-
const valueInInputValues = inputValues.find(item => item[
|
48
|
+
const valueInInputValues = inputValues.find(item => item[labelKey].length && item[labelKey].toLowerCase() === e.target.value.toLowerCase());
|
45
49
|
|
46
50
|
if (valueInInputValues) {
|
47
|
-
const val = valueInInputValues[
|
51
|
+
const val = valueInInputValues[labelKey];
|
48
52
|
setValueChanged(val);
|
49
53
|
handleValueClick(valueInInputValues);
|
50
54
|
return;
|
@@ -62,9 +66,8 @@ const useAutocomplete = props => {
|
|
62
66
|
|
63
67
|
if (props.fuzzy) {
|
64
68
|
const fuzzyOptions = {
|
65
|
-
keys: [
|
69
|
+
keys: [labelKey]
|
66
70
|
};
|
67
|
-
setShowValues(Boolean(value));
|
68
71
|
return matchSorter(props.values, value ?? '', fuzzyOptions);
|
69
72
|
}
|
70
73
|
|
@@ -93,11 +96,11 @@ const useAutocomplete = props => {
|
|
93
96
|
});
|
94
97
|
}
|
95
98
|
|
96
|
-
if (highlightedIndex === null || !
|
99
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
97
100
|
return;
|
98
101
|
}
|
99
102
|
|
100
|
-
const item =
|
103
|
+
const item = renderedValues[highlightedIndex];
|
101
104
|
handleValueClick(item);
|
102
105
|
setShowValues(false);
|
103
106
|
};
|
@@ -107,7 +110,7 @@ const useAutocomplete = props => {
|
|
107
110
|
e.stopPropagation();
|
108
111
|
if (!showValues) return;
|
109
112
|
|
110
|
-
if (highlightedIndex === null || !
|
113
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
111
114
|
return;
|
112
115
|
}
|
113
116
|
|
@@ -127,13 +130,13 @@ const useAutocomplete = props => {
|
|
127
130
|
e.preventDefault();
|
128
131
|
e.stopPropagation();
|
129
132
|
|
130
|
-
if (highlightedIndex === null || !
|
133
|
+
if (highlightedIndex === null || !renderedValues?.length) {
|
131
134
|
return;
|
132
135
|
}
|
133
136
|
|
134
137
|
const newHighlightIndex = highlightedIndex + 1;
|
135
138
|
|
136
|
-
if (newHighlightIndex ===
|
139
|
+
if (newHighlightIndex === renderedValues.length) {
|
137
140
|
setHighlightedIndex(null);
|
138
141
|
setShowValues(false);
|
139
142
|
return;
|
@@ -161,7 +164,7 @@ const useAutocomplete = props => {
|
|
161
164
|
key
|
162
165
|
} = e;
|
163
166
|
|
164
|
-
if (showValues &&
|
167
|
+
if (showValues && renderedValues?.length) {
|
165
168
|
setHighlightedIndex(0);
|
166
169
|
} else {
|
167
170
|
setHighlightedIndex(null);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Timepicker/index.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,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CAA6C;IAC7C,QAAQ,EAAE,YAAY,CAAA;IACtB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IACxB,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+BAA+B;IAC/B,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CA0LhC,CAAA;AAED,eAAe,UAAU,CAAA"}
|
@@ -18,6 +18,7 @@ const TimePicker = ({
|
|
18
18
|
css,
|
19
19
|
validation,
|
20
20
|
invalidMessage,
|
21
|
+
autoFocus,
|
21
22
|
onChange,
|
22
23
|
onBlur
|
23
24
|
}) => {
|
@@ -115,6 +116,7 @@ const TimePicker = ({
|
|
115
116
|
type: "text",
|
116
117
|
value: inputStateValue,
|
117
118
|
disabled: disabled,
|
119
|
+
autoFocus: autoFocus,
|
118
120
|
css: theme => [disabled && styles.disabled(theme), css && css],
|
119
121
|
onChange: event => onInputChange(event, v => onChange && onChange(v)),
|
120
122
|
onBlur: onBlur,
|