@zohodesk/components 1.4.8 → 1.4.10-exp-0
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/.cli/propValidation_report.html +1 -1
- package/README.md +22 -0
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +16 -8
- package/es/MultiSelect/AdvancedMultiSelect.js +13 -6
- package/es/MultiSelect/EmptyState.js +2 -1
- package/es/MultiSelect/MultiSelect.js +36 -15
- package/es/MultiSelect/MultiSelectWithAvatar.js +9 -2
- package/es/MultiSelect/SelectedOptions.js +4 -2
- package/es/MultiSelect/Suggestions.js +174 -97
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
- package/es/MultiSelect/__tests__/Suggestions.spec.js +58 -0
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
- package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
- package/es/MultiSelect/constants.js +6 -0
- package/es/MultiSelect/props/defaultProps.js +2 -0
- package/es/MultiSelect/props/propTypes.js +18 -55
- package/es/Select/Select.js +13 -3
- package/es/Select/SelectWithIcon.js +1 -1
- package/es/Select/__tests__/Select.spec.js +16 -8
- package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
- package/es/Select/props/defaultProps.js +1 -0
- package/es/Select/props/propTypes.js +1 -0
- package/es/utils/Common.js +3 -2
- package/es/utils/dropDownUtils.js +28 -7
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +94 -83
- package/lib/MultiSelect/AdvancedMultiSelect.js +16 -7
- package/lib/MultiSelect/EmptyState.js +3 -1
- package/lib/MultiSelect/MultiSelect.js +39 -15
- package/lib/MultiSelect/MultiSelectWithAvatar.js +11 -3
- package/lib/MultiSelect/SelectedOptions.js +4 -2
- package/lib/MultiSelect/Suggestions.js +176 -100
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
- package/lib/MultiSelect/__tests__/Suggestions.spec.js +58 -0
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
- package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
- package/lib/MultiSelect/constants.js +13 -0
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +17 -55
- package/lib/Select/Select.js +13 -2
- package/lib/Select/SelectWithIcon.js +1 -1
- package/lib/Select/__tests__/Select.spec.js +165 -155
- package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
- package/lib/Select/props/defaultProps.js +1 -0
- package/lib/Select/props/propTypes.js +1 -0
- package/lib/utils/Common.js +5 -3
- package/lib/utils/dropDownUtils.js +27 -4
- package/package.json +9 -8
|
@@ -1926,6 +1926,287 @@ exports[`Select - Should render the only options matching search value 1`] = `
|
|
|
1926
1926
|
</DocumentFragment>
|
|
1927
1927
|
`;
|
|
1928
1928
|
|
|
1929
|
+
exports[`Select - Should render the only options matching search value even with additional spaces before and after 1`] = `
|
|
1930
|
+
<DocumentFragment>
|
|
1931
|
+
<div
|
|
1932
|
+
class="container box_medium "
|
|
1933
|
+
data-selector-id="select"
|
|
1934
|
+
>
|
|
1935
|
+
<div
|
|
1936
|
+
class=""
|
|
1937
|
+
data-id="selectComponent"
|
|
1938
|
+
data-test-id="selectComponent"
|
|
1939
|
+
>
|
|
1940
|
+
<div
|
|
1941
|
+
class="container effect effectFocused input flex rowdir"
|
|
1942
|
+
data-id="containerComponent"
|
|
1943
|
+
data-selector-id="textBoxIcon"
|
|
1944
|
+
data-test-id="containerComponent"
|
|
1945
|
+
>
|
|
1946
|
+
<div
|
|
1947
|
+
class="grow basis shrinkOff"
|
|
1948
|
+
data-id="boxComponent"
|
|
1949
|
+
data-selector-id="box"
|
|
1950
|
+
data-test-id="boxComponent"
|
|
1951
|
+
>
|
|
1952
|
+
<input
|
|
1953
|
+
aria-activedescendant="1"
|
|
1954
|
+
aria-controls="1"
|
|
1955
|
+
aria-expanded="true"
|
|
1956
|
+
aria-haspopup="true"
|
|
1957
|
+
aria-label="click to select options"
|
|
1958
|
+
aria-owns="1"
|
|
1959
|
+
aria-readonly="true"
|
|
1960
|
+
autocomplete="off"
|
|
1961
|
+
class=" pointer container medium default effect focus borderColor_default inputDotted "
|
|
1962
|
+
data-id="selectComponent_textBox"
|
|
1963
|
+
data-selector-id="textBoxIcon"
|
|
1964
|
+
data-test-id="selectComponent_textBox"
|
|
1965
|
+
data-title="Option 1"
|
|
1966
|
+
maxlength="250"
|
|
1967
|
+
placeholder=""
|
|
1968
|
+
readonly=""
|
|
1969
|
+
role="Menuitem"
|
|
1970
|
+
type="text"
|
|
1971
|
+
value="Option 1"
|
|
1972
|
+
/>
|
|
1973
|
+
</div>
|
|
1974
|
+
<div
|
|
1975
|
+
class="iconContainer shrinkOff"
|
|
1976
|
+
data-id="boxComponent"
|
|
1977
|
+
data-selector-id="box"
|
|
1978
|
+
data-test-id="boxComponent"
|
|
1979
|
+
>
|
|
1980
|
+
<div
|
|
1981
|
+
class="flex cover rowdir"
|
|
1982
|
+
data-id="containerComponent"
|
|
1983
|
+
data-selector-id="container"
|
|
1984
|
+
data-test-id="containerComponent"
|
|
1985
|
+
>
|
|
1986
|
+
<div
|
|
1987
|
+
class="icon rotated shrinkOff"
|
|
1988
|
+
data-id="boxComponent"
|
|
1989
|
+
data-selector-id="box"
|
|
1990
|
+
data-test-id="boxComponent"
|
|
1991
|
+
>
|
|
1992
|
+
<div
|
|
1993
|
+
class="rightPlaceholder inflex rowdir both"
|
|
1994
|
+
data-id="containerComponent"
|
|
1995
|
+
data-selector-id="container"
|
|
1996
|
+
data-test-id="containerComponent"
|
|
1997
|
+
>
|
|
1998
|
+
<div
|
|
1999
|
+
aria-hidden="true"
|
|
2000
|
+
class="arrowIcon flex cover coldir both"
|
|
2001
|
+
data-id="selectComponent_downIcon"
|
|
2002
|
+
data-selector-id="container"
|
|
2003
|
+
data-test-id="selectComponent_downIcon"
|
|
2004
|
+
>
|
|
2005
|
+
<i
|
|
2006
|
+
aria-hidden="true"
|
|
2007
|
+
class="zd_font_icons basic icon-down "
|
|
2008
|
+
data-id="fontIcon"
|
|
2009
|
+
data-selector-id="fontIcon"
|
|
2010
|
+
data-test-id="fontIcon"
|
|
2011
|
+
style="--zd-iconfont-size: var(--zd_font_size7);"
|
|
2012
|
+
/>
|
|
2013
|
+
</div>
|
|
2014
|
+
</div>
|
|
2015
|
+
</div>
|
|
2016
|
+
</div>
|
|
2017
|
+
</div>
|
|
2018
|
+
<div
|
|
2019
|
+
class="line borderColor_default "
|
|
2020
|
+
/>
|
|
2021
|
+
</div>
|
|
2022
|
+
</div>
|
|
2023
|
+
<div
|
|
2024
|
+
class="main container bottomMid default"
|
|
2025
|
+
data-a11y-focus-main-area="true"
|
|
2026
|
+
data-arrow-position="mid"
|
|
2027
|
+
data-box-direction="bottom"
|
|
2028
|
+
data-id="selectComponent_suggestions"
|
|
2029
|
+
data-position="bottomMid"
|
|
2030
|
+
data-selector-id="dropBox"
|
|
2031
|
+
data-test-id="selectComponent_suggestions"
|
|
2032
|
+
dot-ui-element="dropbox"
|
|
2033
|
+
style="z-index: 4;"
|
|
2034
|
+
>
|
|
2035
|
+
<div
|
|
2036
|
+
class="subContainer shadow radius bounce defaultPalette"
|
|
2037
|
+
data-id="selectComponent_suggestions_subcontainer"
|
|
2038
|
+
data-selector-id="dropBox_subcontainer"
|
|
2039
|
+
data-test-id="selectComponent_suggestions_subcontainer"
|
|
2040
|
+
tabindex="-1"
|
|
2041
|
+
>
|
|
2042
|
+
<div
|
|
2043
|
+
class="flex rowdir"
|
|
2044
|
+
data-id="containerComponent"
|
|
2045
|
+
data-selector-id="container"
|
|
2046
|
+
data-test-id="containerComponent"
|
|
2047
|
+
>
|
|
2048
|
+
<div
|
|
2049
|
+
class="grow basis shrinkOff"
|
|
2050
|
+
data-id="boxComponent"
|
|
2051
|
+
data-selector-id="box"
|
|
2052
|
+
data-test-id="boxComponent"
|
|
2053
|
+
>
|
|
2054
|
+
<div
|
|
2055
|
+
class="flex cover coldir"
|
|
2056
|
+
data-id="containerComponent"
|
|
2057
|
+
data-selector-id="container"
|
|
2058
|
+
data-test-id="containerComponent"
|
|
2059
|
+
>
|
|
2060
|
+
<div
|
|
2061
|
+
class="notScroll shrinkOff"
|
|
2062
|
+
data-id="CardHeader"
|
|
2063
|
+
data-selector-id="cardHeader"
|
|
2064
|
+
data-test-id="CardHeader"
|
|
2065
|
+
>
|
|
2066
|
+
<div
|
|
2067
|
+
class="search medium"
|
|
2068
|
+
>
|
|
2069
|
+
<div
|
|
2070
|
+
class="container effect effectFocused flex rowdir"
|
|
2071
|
+
data-id="containerComponent"
|
|
2072
|
+
data-selector-id="textBoxIcon"
|
|
2073
|
+
data-test-id="containerComponent"
|
|
2074
|
+
>
|
|
2075
|
+
<div
|
|
2076
|
+
class="grow basis shrinkOff"
|
|
2077
|
+
data-id="boxComponent"
|
|
2078
|
+
data-selector-id="box"
|
|
2079
|
+
data-test-id="boxComponent"
|
|
2080
|
+
>
|
|
2081
|
+
<input
|
|
2082
|
+
aria-autocomplete="list"
|
|
2083
|
+
aria-controls="1"
|
|
2084
|
+
aria-describedby="2"
|
|
2085
|
+
autocomplete="off"
|
|
2086
|
+
class=" container small default effect borderColor_default "
|
|
2087
|
+
data-id="selectComponent_search"
|
|
2088
|
+
data-selector-id="textBoxIcon"
|
|
2089
|
+
data-test-id="selectComponent_search"
|
|
2090
|
+
maxlength="250"
|
|
2091
|
+
placeholder="Search"
|
|
2092
|
+
type="text"
|
|
2093
|
+
value=" 2 "
|
|
2094
|
+
/>
|
|
2095
|
+
</div>
|
|
2096
|
+
<div
|
|
2097
|
+
class="iconContainer shrinkOff"
|
|
2098
|
+
data-id="boxComponent"
|
|
2099
|
+
data-selector-id="box"
|
|
2100
|
+
data-test-id="boxComponent"
|
|
2101
|
+
>
|
|
2102
|
+
<div
|
|
2103
|
+
class="flex cover rowdir"
|
|
2104
|
+
data-id="containerComponent"
|
|
2105
|
+
data-selector-id="container"
|
|
2106
|
+
data-test-id="containerComponent"
|
|
2107
|
+
>
|
|
2108
|
+
<button
|
|
2109
|
+
class="buttonReset icon shrinkOff"
|
|
2110
|
+
data-id="selectComponent_search_ClearIcon"
|
|
2111
|
+
data-selector-id="box"
|
|
2112
|
+
data-test-id="selectComponent_search_ClearIcon"
|
|
2113
|
+
data-title="Clear"
|
|
2114
|
+
>
|
|
2115
|
+
<div
|
|
2116
|
+
aria-hidden="true"
|
|
2117
|
+
class="flex cover coldir both"
|
|
2118
|
+
data-id="containerComponent"
|
|
2119
|
+
data-selector-id="container"
|
|
2120
|
+
data-test-id="containerComponent"
|
|
2121
|
+
>
|
|
2122
|
+
<i
|
|
2123
|
+
aria-hidden="true"
|
|
2124
|
+
class="zd_font_icons basic icon-delete rtl "
|
|
2125
|
+
data-id="fontIcon"
|
|
2126
|
+
data-selector-id="fontIcon"
|
|
2127
|
+
data-test-id="fontIcon"
|
|
2128
|
+
style="--zd-iconfont-size: var(--zd_font_size14);"
|
|
2129
|
+
/>
|
|
2130
|
+
</div>
|
|
2131
|
+
</button>
|
|
2132
|
+
</div>
|
|
2133
|
+
</div>
|
|
2134
|
+
<div
|
|
2135
|
+
class="line borderColor_default "
|
|
2136
|
+
/>
|
|
2137
|
+
</div>
|
|
2138
|
+
</div>
|
|
2139
|
+
</div>
|
|
2140
|
+
<div
|
|
2141
|
+
class="small grow basis shrinkOn scrolly"
|
|
2142
|
+
data-id="CardContent"
|
|
2143
|
+
data-selector-id="cardContent"
|
|
2144
|
+
data-test-id="CardContent"
|
|
2145
|
+
>
|
|
2146
|
+
<div
|
|
2147
|
+
class="flex coldir"
|
|
2148
|
+
data-id="containerComponent"
|
|
2149
|
+
data-selector-id="container"
|
|
2150
|
+
data-test-id="containerComponent"
|
|
2151
|
+
id="1"
|
|
2152
|
+
role="listbox"
|
|
2153
|
+
tabindex="0"
|
|
2154
|
+
>
|
|
2155
|
+
<div
|
|
2156
|
+
class="listItemContainer shrinkOff"
|
|
2157
|
+
data-id="selectComponent_Options"
|
|
2158
|
+
data-selector-id="box"
|
|
2159
|
+
data-test-id="selectComponent_Options"
|
|
2160
|
+
>
|
|
2161
|
+
<li
|
|
2162
|
+
aria-label="Option 2"
|
|
2163
|
+
aria-selected="false"
|
|
2164
|
+
ariaparentrole="listbox"
|
|
2165
|
+
class="list medium default defaultHover mediumwithTick flex rowdir vCenter"
|
|
2166
|
+
data-a11y-inset-focus="true"
|
|
2167
|
+
data-a11y-list-active="true"
|
|
2168
|
+
data-id="Option 2"
|
|
2169
|
+
data-selector-id="listItem"
|
|
2170
|
+
data-test-id="Option 2"
|
|
2171
|
+
data-title="Option 2"
|
|
2172
|
+
role="option"
|
|
2173
|
+
tabindex="0"
|
|
2174
|
+
>
|
|
2175
|
+
<div
|
|
2176
|
+
class="leftBox grow basis shrinkOff"
|
|
2177
|
+
data-id="boxComponent"
|
|
2178
|
+
data-selector-id="box"
|
|
2179
|
+
data-test-id="boxComponent"
|
|
2180
|
+
>
|
|
2181
|
+
<div
|
|
2182
|
+
class="titleBox shrinkOff"
|
|
2183
|
+
data-id="boxComponent"
|
|
2184
|
+
data-selector-id="box"
|
|
2185
|
+
data-test-id="boxComponent"
|
|
2186
|
+
>
|
|
2187
|
+
<div
|
|
2188
|
+
class="value basisAuto shrinkOn"
|
|
2189
|
+
data-id="boxComponent"
|
|
2190
|
+
data-selector-id="box"
|
|
2191
|
+
data-test-id="boxComponent"
|
|
2192
|
+
>
|
|
2193
|
+
Option 2
|
|
2194
|
+
</div>
|
|
2195
|
+
</div>
|
|
2196
|
+
</div>
|
|
2197
|
+
</li>
|
|
2198
|
+
</div>
|
|
2199
|
+
</div>
|
|
2200
|
+
</div>
|
|
2201
|
+
</div>
|
|
2202
|
+
</div>
|
|
2203
|
+
</div>
|
|
2204
|
+
</div>
|
|
2205
|
+
</div>
|
|
2206
|
+
</div>
|
|
2207
|
+
</DocumentFragment>
|
|
2208
|
+
`;
|
|
2209
|
+
|
|
1929
2210
|
exports[`Select - Should render the placeholder when there is no default value 1`] = `
|
|
1930
2211
|
<DocumentFragment>
|
|
1931
2212
|
<div
|
|
@@ -12,6 +12,7 @@ export const Select_propTypes = {
|
|
|
12
12
|
defaultDropBoxPosition: PropTypes.string,
|
|
13
13
|
dropBoxSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
14
14
|
emptyMessage: PropTypes.string,
|
|
15
|
+
isVirtualizerEnabled: PropTypes.bool,
|
|
15
16
|
excludeOptions: PropTypes.array,
|
|
16
17
|
getChildren: PropTypes.func,
|
|
17
18
|
getContainerRef: PropTypes.func,
|
package/es/utils/Common.js
CHANGED
|
@@ -376,7 +376,7 @@ export function getElementSpace(elementRef) {
|
|
|
376
376
|
}
|
|
377
377
|
export function getSearchString() {
|
|
378
378
|
let charachers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
379
|
-
return (charachers || '').toString().toLowerCase(); //.replace(/\s+/g, '');
|
|
379
|
+
return (charachers || '').toString().toLowerCase().trim(); //.replace(/\s+/g, '');
|
|
380
380
|
}
|
|
381
381
|
export function findScrollEnd(element) {
|
|
382
382
|
let {
|
|
@@ -413,4 +413,5 @@ export function isTextSelected() {
|
|
|
413
413
|
|
|
414
414
|
return false;
|
|
415
415
|
}
|
|
416
|
-
export const DUMMY_OBJECT = {};
|
|
416
|
+
export const DUMMY_OBJECT = {};
|
|
417
|
+
export const DUMMY_ARRAY = [];
|
|
@@ -7,6 +7,8 @@ export const getOptions = props => props.options || dummyArray;
|
|
|
7
7
|
|
|
8
8
|
const getOptionsOrder = props => props.optionsOrder || dummyArray;
|
|
9
9
|
|
|
10
|
+
const getLimit = props => props.limit || 0;
|
|
11
|
+
|
|
10
12
|
const getSelectedOptionsSel = props => props.selectedOptions || dummyArray;
|
|
11
13
|
|
|
12
14
|
const getSearchStr = props => props.searchStr || '';
|
|
@@ -41,8 +43,10 @@ const getDisabledOptions = props => props.disabledOptions || dummyArray;
|
|
|
41
43
|
|
|
42
44
|
const getListItemProps = props => props.listItemProps || '';
|
|
43
45
|
|
|
46
|
+
const defaultSearchFields = ['value'];
|
|
47
|
+
|
|
44
48
|
const getSearchFields = props => {
|
|
45
|
-
return props.searchFields ||
|
|
49
|
+
return props.searchFields || defaultSearchFields;
|
|
46
50
|
}; // const isObjectContainsSearchString = (searchFields = [], searchStr = '', obj) => {
|
|
47
51
|
// const matchedFields = searchFields.filter(element => {
|
|
48
52
|
// return getSearchString(obj[element]).indexOf(searchStr) !== -1
|
|
@@ -206,10 +210,10 @@ export const makeFormatOptions = () => createSelector([getOptions, getValueField
|
|
|
206
210
|
optionsOrder: remvampOptionIds
|
|
207
211
|
};
|
|
208
212
|
});
|
|
209
|
-
export const makeGetMultiSelectSelectedOptions = () => createSelector([getSelectedOptionsSel, getNormalizedFormatOptions, getSelectedOptionsLength, getAllowValueFallback], (selectedOptions, normalizedFormatOptions, selectedOptionsLength, allowValueFallback) => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
export const makeGetMultiSelectSelectedOptions = () => createSelector([getSelectedOptionsSel, getNormalizedFormatOptions, getSelectedOptionsLength, getAllowValueFallback, getLimit], (selectedOptions, normalizedFormatOptions, selectedOptionsLength, allowValueFallback, limit) => {
|
|
214
|
+
let output = [];
|
|
215
|
+
let revampSelectedOptions = [];
|
|
216
|
+
let normalizedSelectedOptions = {};
|
|
213
217
|
selectedOptionsLength = !getIsEmptyValue(selectedOptionsLength) ? selectedOptionsLength : selectedOptions.length;
|
|
214
218
|
|
|
215
219
|
for (let i = 0; i < selectedOptionsLength; i++) {
|
|
@@ -234,6 +238,12 @@ export const makeGetMultiSelectSelectedOptions = () => createSelector([getSelect
|
|
|
234
238
|
}
|
|
235
239
|
}
|
|
236
240
|
|
|
241
|
+
if (limit && limit > 0) {
|
|
242
|
+
output = output.slice(0, limit);
|
|
243
|
+
revampSelectedOptions = revampSelectedOptions.slice(0, limit);
|
|
244
|
+
normalizedSelectedOptions = Object.fromEntries(Object.entries(normalizedSelectedOptions).slice(0, limit));
|
|
245
|
+
}
|
|
246
|
+
|
|
237
247
|
return {
|
|
238
248
|
formatSelectedOptions: output,
|
|
239
249
|
normalizedSelectedOptions,
|
|
@@ -423,7 +433,8 @@ export const filterSelectedOptions = function () {
|
|
|
423
433
|
let {
|
|
424
434
|
selectedOptions = dummyArray,
|
|
425
435
|
propSelectedOptions = dummyArray,
|
|
426
|
-
disabledOptions = dummyArray
|
|
436
|
+
disabledOptions = dummyArray,
|
|
437
|
+
limit
|
|
427
438
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
428
439
|
// eslint-disable-next-line no-param-reassign
|
|
429
440
|
selectedOptions = selectedOptions || dummyArray; // eslint-disable-next-line no-param-reassign
|
|
@@ -445,8 +456,18 @@ export const filterSelectedOptions = function () {
|
|
|
445
456
|
|
|
446
457
|
return true;
|
|
447
458
|
});
|
|
459
|
+
const totalSelectedOptions = [...oldValidSelectedOptions, ...newlyAddedOptions];
|
|
460
|
+
|
|
461
|
+
if (limit && limit > 0) {
|
|
462
|
+
if (totalSelectedOptions.length > limit) {
|
|
463
|
+
return {
|
|
464
|
+
newSelectedOptions: totalSelectedOptions.slice(0, limit)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
448
469
|
return {
|
|
449
|
-
newSelectedOptions:
|
|
470
|
+
newSelectedOptions: totalSelectedOptions
|
|
450
471
|
};
|
|
451
472
|
};
|
|
452
473
|
export const makeGetIsShowClearIcon = () => createSelector([getSelectedOptionsSel, getDisabledOptions], (selectedOptions, disabledOptions) => {
|