@zohodesk/components 1.4.9 → 1.4.10

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/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+ # 1.4.10
6
+
7
+ - **Select, MultiSelect**
8
+ - Searching with leading spaces is not reflected the results correctly. Issue Fixed.
9
+
10
+ - **Select**
11
+ - Fixed performance issue in options formatting caused by unnecessary rendering triggers
12
+
5
13
  # 1.4.9
6
14
 
7
15
  - **MultiSelect , MultiSelectWithAvatar, AdvancedMultiSelect, AdvancedGroupMultiSelect**
@@ -18,7 +18,7 @@ import { ResponsiveReceiver } from "../Responsive/CustomResponsive";
18
18
  import Loader from '@zohodesk/svg/lib/Loader/Loader';
19
19
  /**** Methods ****/
20
20
 
21
- import { makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetSelectedValueText as makeGetSelectedValue } from "../utils/dropDownUtils";
21
+ import { dummyObj, makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetSelectedValueText as makeGetSelectedValue } from "../utils/dropDownUtils";
22
22
  import { debounce, scrollTo, getIsEmptyValue, getSearchString, findScrollEnd, getKeyValue } from "../utils/Common.js";
23
23
  /**** CSS ****/
24
24
 
@@ -251,10 +251,10 @@ export class SelectComponent extends Component {
251
251
  valueField,
252
252
  textField,
253
253
  allowValueFallback,
254
- customProps = {}
254
+ customProps = dummyObj
255
255
  } = props;
256
256
  let {
257
- listItemProps = {}
257
+ listItemProps = dummyObj
258
258
  } = customProps;
259
259
  return this.formatOptions({
260
260
  options,
@@ -193,7 +193,7 @@ class SelectWithIcon extends Component {
193
193
  } = this.props;
194
194
 
195
195
  if (options.length) {
196
- datas = options.filter(obj => obj[valueKey].toLowerCase().includes(searchValue.toLowerCase()));
196
+ datas = options.filter(obj => obj[valueKey].toLowerCase().includes(searchValue.toLowerCase().trim()));
197
197
  }
198
198
 
199
199
  return datas;
@@ -246,14 +246,22 @@ describe('Select -', () => {
246
246
  userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
247
247
  expect(getAllByRole(listItemRole)).toHaveLength(1);
248
248
  expect(asFragment()).toMatchSnapshot();
249
- }); // test('Should render the only options matching search value even with additional spaces before and after', () => {
250
- // const { getByRole, getAllByRole, asFragment, getByTestId } = render(<Select needSearch options={options} />);
251
- // userEvent.click(getByRole(selectInputRole));
252
- // userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), ' 2 ');
253
- // expect(getAllByRole(listItemRole)).toHaveLength(1);
254
- // expect(asFragment()).toMatchSnapshot();
255
- // });
256
-
249
+ });
250
+ test('Should render the only options matching search value even with additional spaces before and after', () => {
251
+ const {
252
+ getByRole,
253
+ getAllByRole,
254
+ asFragment,
255
+ getByTestId
256
+ } = render( /*#__PURE__*/React.createElement(Select, {
257
+ needSearch: true,
258
+ options: options
259
+ }));
260
+ userEvent.click(getByRole(selectInputRole));
261
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), ' 2 ');
262
+ expect(getAllByRole(listItemRole)).toHaveLength(1);
263
+ expect(asFragment()).toMatchSnapshot();
264
+ });
257
265
  test('Should trigger given onSearch, when type on the search input', async () => {
258
266
  const mockOnSearch = jest.fn();
259
267
  const {
@@ -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
@@ -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 {
@@ -43,8 +43,10 @@ const getDisabledOptions = props => props.disabledOptions || dummyArray;
43
43
 
44
44
  const getListItemProps = props => props.listItemProps || '';
45
45
 
46
+ const defaultSearchFields = ['value'];
47
+
46
48
  const getSearchFields = props => {
47
- return props.searchFields || ['value'];
49
+ return props.searchFields || defaultSearchFields;
48
50
  }; // const isObjectContainsSearchString = (searchFields = [], searchStr = '', obj) => {
49
51
  // const matchedFields = searchFields.filter(element => {
50
52
  // return getSearchString(obj[element]).indexOf(searchStr) !== -1
@@ -309,9 +309,9 @@ var SelectComponent = /*#__PURE__*/function (_Component) {
309
309
  textField = props.textField,
310
310
  allowValueFallback = props.allowValueFallback,
311
311
  _props$customProps = props.customProps,
312
- customProps = _props$customProps === void 0 ? {} : _props$customProps;
312
+ customProps = _props$customProps === void 0 ? _dropDownUtils.dummyObj : _props$customProps;
313
313
  var _customProps$listItem = customProps.listItemProps,
314
- listItemProps = _customProps$listItem === void 0 ? {} : _customProps$listItem;
314
+ listItemProps = _customProps$listItem === void 0 ? _dropDownUtils.dummyObj : _customProps$listItem;
315
315
  return this.formatOptions({
316
316
  options: options,
317
317
  valueField: valueField,
@@ -261,7 +261,7 @@ var SelectWithIcon = /*#__PURE__*/function (_Component) {
261
261
 
262
262
  if (options.length) {
263
263
  datas = options.filter(function (obj) {
264
- return obj[valueKey].toLowerCase().includes(searchValue.toLowerCase());
264
+ return obj[valueKey].toLowerCase().includes(searchValue.toLowerCase().trim());
265
265
  });
266
266
  }
267
267