@indigina/ui-kit 1.1.670 → 1.1.671

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.
@@ -10829,6 +10829,7 @@ const kitTranslateFilterTitle = (translateService, title, useTranslation, transl
10829
10829
  };
10830
10830
 
10831
10831
  const nonIndexableCharacters = /[^A-Za-z0-9\-.:_,\\/]+/;
10832
+ const nonPhraseCharacters = /[^\p{L}\p{N}\-.:_,\\/]+/u;
10832
10833
  const kitFormatStringForSearch = (inputString, addWildcard = true) => {
10833
10834
  return inputString
10834
10835
  .split(nonIndexableCharacters)
@@ -10836,6 +10837,16 @@ const kitFormatStringForSearch = (inputString, addWildcard = true) => {
10836
10837
  .map(text => addWildcard ? text + '*' : text)
10837
10838
  .join(' ');
10838
10839
  };
10840
+ const kitFormatStringForPhraseSearch = (inputString) => {
10841
+ const words = inputString
10842
+ .split(nonPhraseCharacters)
10843
+ .filter(text => !!text);
10844
+ if (!words.length) {
10845
+ return '';
10846
+ }
10847
+ const wildcardClause = words.map(text => `${text}*`).join(' ');
10848
+ return `"${words.join(' ')}" | (${wildcardClause})`;
10849
+ };
10839
10850
 
10840
10851
  const kitBuildGridColumn = (field, title, type, sortable = true, hidden = false, width, filterType, excelFormat, apiField, hiddenInGrid, customFieldHandler, customRangeHandler, dateFilterConstraint) => ({
10841
10852
  field,
@@ -10868,7 +10879,8 @@ const kitBuildSortString = (sort, columns) => {
10868
10879
  }).join(', ');
10869
10880
  return sortString !== '' && sortString || undefined;
10870
10881
  };
10871
- const kitFetchGridData = ({ store, destroyRef, isLoading, fetchAction, fetchFromIndexAction, hasArchiveToggle, addSearchWildcard = true, error, }) => {
10882
+ const buildSearchTerm = (search, addSearchWildcard, phraseSearch) => phraseSearch ? kitFormatStringForPhraseSearch(search) : kitFormatStringForSearch(search, addSearchWildcard);
10883
+ const kitFetchGridData = ({ store, destroyRef, isLoading, fetchAction, fetchFromIndexAction, hasArchiveToggle, addSearchWildcard = true, phraseSearch = false, error, }) => {
10872
10884
  isLoading.set(true);
10873
10885
  const { skip, take, sort, filter, search, archive, columns } = store.selectSnapshot(KIT_GRID_STATE_TOKEN);
10874
10886
  const gridState = {
@@ -10880,17 +10892,17 @@ const kitFetchGridData = ({ store, destroyRef, isLoading, fetchAction, fetchFrom
10880
10892
  };
10881
10893
  const isArchive = hasArchiveToggle && archive || false;
10882
10894
  const isSearchMode = hasArchiveToggle && !isArchive || !!search;
10883
- const searchTerm = search && kitFormatStringForSearch(search, addSearchWildcard) || undefined;
10895
+ const searchTerm = search && buildSearchTerm(search, addSearchWildcard, phraseSearch) || undefined;
10884
10896
  const action = (isSearchMode && fetchFromIndexAction) ? fetchFromIndexAction({ ...gridState, searchTerm }) : fetchAction(gridState);
10885
10897
  store.dispatch(action).pipe(takeUntilDestroyed(destroyRef), finalize(() => isLoading.set(false))).subscribe({ error });
10886
10898
  };
10887
- const kitFetchExportGridData = ({ fetchAction, fetchIndexAction, sort, filter, search, columns, total, hasArchiveToggle = false, archiveModeEnabled = false, addSearchWildcard = true, }) => {
10899
+ const kitFetchExportGridData = ({ fetchAction, fetchIndexAction, sort, filter, search, columns, total, hasArchiveToggle = false, archiveModeEnabled = false, addSearchWildcard = true, phraseSearch = false, }) => {
10888
10900
  const isArchive = hasArchiveToggle && archiveModeEnabled || false;
10889
10901
  const isSearchMode = hasArchiveToggle && !isArchive || !!search;
10890
10902
  const sortString = kitBuildSortString(sort, columns);
10891
10903
  const filterString = kitBuildOdataFilter(kitBuildFilters(filter));
10892
10904
  if (isSearchMode) {
10893
- const searchTerm = search && kitFormatStringForSearch(search, addSearchWildcard) || undefined;
10905
+ const searchTerm = search && buildSearchTerm(search, addSearchWildcard, phraseSearch) || undefined;
10894
10906
  return fetchIndexAction(0, total, sortString, filterString, searchTerm);
10895
10907
  }
10896
10908
  return fetchAction(0, total, sortString, filterString);