@fctc/widget-logic 4.6.7 → 4.6.9

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/dist/index.js CHANGED
@@ -6623,10 +6623,14 @@ var tableGroupController = (props) => {
6623
6623
  };
6624
6624
 
6625
6625
  // src/widget/advance/search/controller.ts
6626
- var import_constants3 = require("@fctc/interface-logic/constants");
6627
- var import_utils20 = require("@fctc/interface-logic/utils");
6628
6626
  var import_moment2 = __toESM(require_moment());
6629
6627
  var import_react26 = require("react");
6628
+
6629
+ // src/constants.ts
6630
+ var constants_exports = {};
6631
+ __reExport(constants_exports, require("@fctc/interface-logic/constants"));
6632
+
6633
+ // src/widget/advance/search/controller.ts
6630
6634
  var searchController = ({
6631
6635
  viewData,
6632
6636
  model,
@@ -6641,9 +6645,11 @@ var searchController = ({
6641
6645
  const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
6642
6646
  const [searchString, setSearchString] = (0, import_react26.useState)("");
6643
6647
  const [searchMap, setSearchMap] = (0, import_react26.useState)({});
6644
- const actionContext = typeof context === "string" ? (0, import_utils20.evalJSONContext)(context) : context;
6648
+ const [hoveredIndex, setHoveredIndex] = (0, import_react26.useState)(0);
6649
+ const [hoveredIndexSearchList, setHoveredIndexSearchList] = (0, import_react26.useState)(0);
6650
+ const actionContext = typeof context === "string" ? (0, utils_exports.evalJSONContext)(context) : context;
6645
6651
  const contextSearch = { ...env.context, ...actionContext };
6646
- const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils20.evalJSONDomain)(domain, contextSearch) : [];
6652
+ const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, utils_exports.evalJSONDomain)(domain, contextSearch) : [];
6647
6653
  const clearSearch = () => {
6648
6654
  setFilterBy([]);
6649
6655
  setGroupBy([]);
@@ -6658,23 +6664,23 @@ var searchController = ({
6658
6664
  const dataModel = viewData?.models?.[model];
6659
6665
  const searchViews = viewData?.views?.search;
6660
6666
  const searchByItems = searchViews?.search_by?.filter(
6661
- (item) => !import_utils20.domainHelper.matchDomains(contextSearch, item.invisible)
6667
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item.invisible)
6662
6668
  )?.map(
6663
6669
  ({ string, name, filter_domain, operator, widget }, index) => ({
6664
6670
  dataIndex: index,
6665
- title: string ?? dataModel[name]?.string,
6666
- name: name ?? dataModel[name]?.name,
6671
+ title: string ?? dataModel?.[name]?.string,
6672
+ name: name ?? dataModel?.[name]?.name,
6667
6673
  filter_domain,
6668
6674
  operator,
6669
6675
  widget,
6670
- type: dataModel[name]?.type
6676
+ type: dataModel?.[name]?.type
6671
6677
  })
6672
6678
  );
6673
6679
  const filterByItems = searchViews?.filter_by.filter((item) => {
6674
- return !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible);
6680
+ return !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible);
6675
6681
  })?.map((item) => ({ ...item, active: false }));
6676
6682
  const groupByItems = searchViews?.group_by.filter(
6677
- (item) => !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible)
6683
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible)
6678
6684
  ).map((item) => ({
6679
6685
  ...item,
6680
6686
  string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
@@ -6728,7 +6734,7 @@ var searchController = ({
6728
6734
  if (domainAction) {
6729
6735
  const domain2 = [];
6730
6736
  if (Array.isArray(domainAction) && domainAction.length > 0) {
6731
- if (Object.keys(searchMap).some((key) => !key.includes(import_constants3.SearchType.GROUP))) {
6737
+ if (Object.keys(searchMap).some((key) => !key.includes(constants_exports.SearchType.GROUP))) {
6732
6738
  domain2.push("&");
6733
6739
  }
6734
6740
  domainAction.forEach((domainItem) => {
@@ -6736,7 +6742,7 @@ var searchController = ({
6736
6742
  });
6737
6743
  }
6738
6744
  Object.keys(searchMap).forEach((key, keyIndex, keys) => {
6739
- if (!key?.includes(import_constants3.SearchType.GROUP)) {
6745
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6740
6746
  if (keys.length > 1 && keyIndex < keys.length - 1) {
6741
6747
  domain2.push("&");
6742
6748
  }
@@ -6751,14 +6757,14 @@ var searchController = ({
6751
6757
  }
6752
6758
  let valueDomainItem = value?.value;
6753
6759
  if (value?.modelType === "date") {
6754
- valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value);
6760
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value);
6755
6761
  } else if (value?.modelType === "datetime") {
6756
6762
  if (value?.operator === "<=" || value?.operator === "<") {
6757
- const parsedDate = (0, import_utils20.validateAndParseDate)(value?.value, true);
6763
+ const parsedDate = (0, utils_exports.validateAndParseDate)(value?.value, true);
6758
6764
  const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
6759
6765
  valueDomainItem = hasTime ? (0, import_moment2.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment2.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
6760
6766
  } else {
6761
- valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value, true);
6767
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value, true);
6762
6768
  }
6763
6769
  }
6764
6770
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
@@ -6783,11 +6789,11 @@ var searchController = ({
6783
6789
  modelType,
6784
6790
  dataIndex
6785
6791
  } = objValues[0];
6786
- if (!key?.includes(import_constants3.SearchType.GROUP)) {
6792
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6787
6793
  const values = objValues?.map((objValue) => objValue.value);
6788
6794
  return {
6789
6795
  title,
6790
- name: type === import_constants3.SearchType.SEARCH ? `${import_constants3.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6796
+ name: type === constants_exports.SearchType.SEARCH ? `${constants_exports.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6791
6797
  values,
6792
6798
  type,
6793
6799
  widget,
@@ -6837,22 +6843,22 @@ var searchController = ({
6837
6843
  }, [searchMap]);
6838
6844
  const handleAddTagSearch = (tag) => {
6839
6845
  const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
6840
- const domainFormat = new import_utils20.domainHelper.Domain(domain2);
6841
- if (type === import_constants3.SearchType.FILTER) {
6842
- addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
6846
+ const domainFormat = new utils_exports.domainHelper.Domain(domain2);
6847
+ if (type === constants_exports.SearchType.FILTER) {
6848
+ addSearchItems(`${constants_exports.SearchType.FILTER}_${groupIndex}`, {
6843
6849
  ...tag,
6844
6850
  domain: domain2 ? domainFormat.toList(context2) : null
6845
6851
  });
6846
- } else if (type === import_constants3.SearchType.SEARCH) {
6847
- addSearchItems(`${import_constants3.SearchType.SEARCH}_${String(dataIndex)}`, {
6852
+ } else if (type === constants_exports.SearchType.SEARCH) {
6853
+ addSearchItems(`${constants_exports.SearchType.SEARCH}_${String(dataIndex)}`, {
6848
6854
  ...tag,
6849
6855
  domain: domain2 ? domainFormat.toList({
6850
6856
  ...context2,
6851
6857
  self: value
6852
6858
  }) : null
6853
6859
  });
6854
- } else if (type === import_constants3.SearchType.GROUP) {
6855
- addSearchItems(`${import_constants3.SearchType.GROUP}`, {
6860
+ } else if (type === constants_exports.SearchType.GROUP) {
6861
+ addSearchItems(`${constants_exports.SearchType.GROUP}`, {
6856
6862
  ...tag,
6857
6863
  domain: domain2 ? domainFormat.toList({
6858
6864
  context: context2,
@@ -6861,6 +6867,65 @@ var searchController = ({
6861
6867
  });
6862
6868
  }
6863
6869
  };
6870
+ const onKeyDown = (e) => {
6871
+ if (!searchBy || searchBy.length === 0) return;
6872
+ switch (e.key) {
6873
+ case "Backspace": {
6874
+ if (!searchString && selectedTags && selectedTags.length > 0) {
6875
+ const lastTag = selectedTags[selectedTags.length - 1];
6876
+ if (!lastTag) return;
6877
+ const key = lastTag.type === constants_exports.SearchType.GROUP ? constants_exports.SearchType.GROUP : lastTag.name;
6878
+ removeKeyFromSearchMap({ key: String(key) });
6879
+ }
6880
+ break;
6881
+ }
6882
+ case "ArrowDown": {
6883
+ e.preventDefault();
6884
+ setHoveredIndex((prev) => {
6885
+ const maxIndex = searchBy.length - 1;
6886
+ const next = prev < maxIndex ? prev + 1 : prev;
6887
+ setHoveredIndexSearchList(next);
6888
+ return next;
6889
+ });
6890
+ break;
6891
+ }
6892
+ case "ArrowUp": {
6893
+ e.preventDefault();
6894
+ setHoveredIndex((prev) => {
6895
+ const next = prev > 0 ? prev - 1 : prev;
6896
+ setHoveredIndexSearchList(next);
6897
+ return next;
6898
+ });
6899
+ break;
6900
+ }
6901
+ case "Enter": {
6902
+ e.preventDefault();
6903
+ if (!searchString.trim()) return;
6904
+ const head = searchBy[hoveredIndex];
6905
+ if (!head) return;
6906
+ handleAddTagSearch({
6907
+ title: head.title,
6908
+ name: head.name,
6909
+ value: searchString,
6910
+ type: constants_exports.SearchType.SEARCH,
6911
+ domain: head.filter_domain,
6912
+ operator: head.operator,
6913
+ dataIndex: head.dataIndex,
6914
+ widget: head.widget,
6915
+ modelType: head.type
6916
+ });
6917
+ break;
6918
+ }
6919
+ default:
6920
+ break;
6921
+ }
6922
+ };
6923
+ const handleMouseEnter = (index) => {
6924
+ setHoveredIndexSearchList(index);
6925
+ };
6926
+ const handleMouseLeave = () => {
6927
+ setHoveredIndexSearchList(null);
6928
+ };
6864
6929
  return {
6865
6930
  groupBy,
6866
6931
  searchBy,
@@ -6876,7 +6941,11 @@ var searchController = ({
6876
6941
  onSearchString: onChangeSearchInput,
6877
6942
  handleAddTagSearch,
6878
6943
  domain: formatDomain(),
6879
- context: contextSearch
6944
+ context: contextSearch,
6945
+ onKeyDown,
6946
+ handleMouseEnter,
6947
+ handleMouseLeave,
6948
+ hoveredIndexSearchList
6880
6949
  };
6881
6950
  };
6882
6951
 
@@ -6889,12 +6958,6 @@ __reExport(store_exports, require("@fctc/interface-logic/store"));
6889
6958
 
6890
6959
  // src/index.ts
6891
6960
  __reExport(index_exports, store_exports, module.exports);
6892
-
6893
- // src/constants.ts
6894
- var constants_exports = {};
6895
- __reExport(constants_exports, require("@fctc/interface-logic/constants"));
6896
-
6897
- // src/index.ts
6898
6961
  __reExport(index_exports, constants_exports, module.exports);
6899
6962
 
6900
6963
  // src/environment.ts
package/dist/index.mjs CHANGED
@@ -6719,14 +6719,14 @@ var tableGroupController = (props) => {
6719
6719
 
6720
6720
  // src/widget/advance/search/controller.ts
6721
6721
  var import_moment2 = __toESM(require_moment());
6722
- import { SearchType } from "@fctc/interface-logic/constants";
6723
- import {
6724
- domainHelper as domainHelper2,
6725
- evalJSONContext as evalJSONContext8,
6726
- evalJSONDomain as evalJSONDomain6,
6727
- validateAndParseDate
6728
- } from "@fctc/interface-logic/utils";
6729
6722
  import { useCallback as useCallback7, useEffect as useEffect16, useState as useState15 } from "react";
6723
+
6724
+ // src/constants.ts
6725
+ var constants_exports = {};
6726
+ __reExport(constants_exports, constants_star);
6727
+ import * as constants_star from "@fctc/interface-logic/constants";
6728
+
6729
+ // src/widget/advance/search/controller.ts
6730
6730
  var searchController = ({
6731
6731
  viewData,
6732
6732
  model,
@@ -6741,9 +6741,11 @@ var searchController = ({
6741
6741
  const [selectedTags, setSelectedTags] = useState15(null);
6742
6742
  const [searchString, setSearchString] = useState15("");
6743
6743
  const [searchMap, setSearchMap] = useState15({});
6744
- const actionContext = typeof context === "string" ? evalJSONContext8(context) : context;
6744
+ const [hoveredIndex, setHoveredIndex] = useState15(0);
6745
+ const [hoveredIndexSearchList, setHoveredIndexSearchList] = useState15(0);
6746
+ const actionContext = typeof context === "string" ? (0, utils_exports.evalJSONContext)(context) : context;
6745
6747
  const contextSearch = { ...env.context, ...actionContext };
6746
- const domainAction = domain ? Array.isArray(domain) ? [...domain] : evalJSONDomain6(domain, contextSearch) : [];
6748
+ const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, utils_exports.evalJSONDomain)(domain, contextSearch) : [];
6747
6749
  const clearSearch = () => {
6748
6750
  setFilterBy([]);
6749
6751
  setGroupBy([]);
@@ -6758,23 +6760,23 @@ var searchController = ({
6758
6760
  const dataModel = viewData?.models?.[model];
6759
6761
  const searchViews = viewData?.views?.search;
6760
6762
  const searchByItems = searchViews?.search_by?.filter(
6761
- (item) => !domainHelper2.matchDomains(contextSearch, item.invisible)
6763
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item.invisible)
6762
6764
  )?.map(
6763
6765
  ({ string, name, filter_domain, operator, widget }, index) => ({
6764
6766
  dataIndex: index,
6765
- title: string ?? dataModel[name]?.string,
6766
- name: name ?? dataModel[name]?.name,
6767
+ title: string ?? dataModel?.[name]?.string,
6768
+ name: name ?? dataModel?.[name]?.name,
6767
6769
  filter_domain,
6768
6770
  operator,
6769
6771
  widget,
6770
- type: dataModel[name]?.type
6772
+ type: dataModel?.[name]?.type
6771
6773
  })
6772
6774
  );
6773
6775
  const filterByItems = searchViews?.filter_by.filter((item) => {
6774
- return !domainHelper2.matchDomains(contextSearch, item?.invisible);
6776
+ return !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible);
6775
6777
  })?.map((item) => ({ ...item, active: false }));
6776
6778
  const groupByItems = searchViews?.group_by.filter(
6777
- (item) => !domainHelper2.matchDomains(contextSearch, item?.invisible)
6779
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible)
6778
6780
  ).map((item) => ({
6779
6781
  ...item,
6780
6782
  string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
@@ -6828,7 +6830,7 @@ var searchController = ({
6828
6830
  if (domainAction) {
6829
6831
  const domain2 = [];
6830
6832
  if (Array.isArray(domainAction) && domainAction.length > 0) {
6831
- if (Object.keys(searchMap).some((key) => !key.includes(SearchType.GROUP))) {
6833
+ if (Object.keys(searchMap).some((key) => !key.includes(constants_exports.SearchType.GROUP))) {
6832
6834
  domain2.push("&");
6833
6835
  }
6834
6836
  domainAction.forEach((domainItem) => {
@@ -6836,7 +6838,7 @@ var searchController = ({
6836
6838
  });
6837
6839
  }
6838
6840
  Object.keys(searchMap).forEach((key, keyIndex, keys) => {
6839
- if (!key?.includes(SearchType.GROUP)) {
6841
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6840
6842
  if (keys.length > 1 && keyIndex < keys.length - 1) {
6841
6843
  domain2.push("&");
6842
6844
  }
@@ -6851,14 +6853,14 @@ var searchController = ({
6851
6853
  }
6852
6854
  let valueDomainItem = value?.value;
6853
6855
  if (value?.modelType === "date") {
6854
- valueDomainItem = validateAndParseDate(value?.value);
6856
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value);
6855
6857
  } else if (value?.modelType === "datetime") {
6856
6858
  if (value?.operator === "<=" || value?.operator === "<") {
6857
- const parsedDate = validateAndParseDate(value?.value, true);
6859
+ const parsedDate = (0, utils_exports.validateAndParseDate)(value?.value, true);
6858
6860
  const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
6859
6861
  valueDomainItem = hasTime ? (0, import_moment2.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment2.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
6860
6862
  } else {
6861
- valueDomainItem = validateAndParseDate(value?.value, true);
6863
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value, true);
6862
6864
  }
6863
6865
  }
6864
6866
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
@@ -6883,11 +6885,11 @@ var searchController = ({
6883
6885
  modelType,
6884
6886
  dataIndex
6885
6887
  } = objValues[0];
6886
- if (!key?.includes(SearchType.GROUP)) {
6888
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6887
6889
  const values = objValues?.map((objValue) => objValue.value);
6888
6890
  return {
6889
6891
  title,
6890
- name: type === SearchType.SEARCH ? `${SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6892
+ name: type === constants_exports.SearchType.SEARCH ? `${constants_exports.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6891
6893
  values,
6892
6894
  type,
6893
6895
  widget,
@@ -6937,22 +6939,22 @@ var searchController = ({
6937
6939
  }, [searchMap]);
6938
6940
  const handleAddTagSearch = (tag) => {
6939
6941
  const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
6940
- const domainFormat = new domainHelper2.Domain(domain2);
6941
- if (type === SearchType.FILTER) {
6942
- addSearchItems(`${SearchType.FILTER}_${groupIndex}`, {
6942
+ const domainFormat = new utils_exports.domainHelper.Domain(domain2);
6943
+ if (type === constants_exports.SearchType.FILTER) {
6944
+ addSearchItems(`${constants_exports.SearchType.FILTER}_${groupIndex}`, {
6943
6945
  ...tag,
6944
6946
  domain: domain2 ? domainFormat.toList(context2) : null
6945
6947
  });
6946
- } else if (type === SearchType.SEARCH) {
6947
- addSearchItems(`${SearchType.SEARCH}_${String(dataIndex)}`, {
6948
+ } else if (type === constants_exports.SearchType.SEARCH) {
6949
+ addSearchItems(`${constants_exports.SearchType.SEARCH}_${String(dataIndex)}`, {
6948
6950
  ...tag,
6949
6951
  domain: domain2 ? domainFormat.toList({
6950
6952
  ...context2,
6951
6953
  self: value
6952
6954
  }) : null
6953
6955
  });
6954
- } else if (type === SearchType.GROUP) {
6955
- addSearchItems(`${SearchType.GROUP}`, {
6956
+ } else if (type === constants_exports.SearchType.GROUP) {
6957
+ addSearchItems(`${constants_exports.SearchType.GROUP}`, {
6956
6958
  ...tag,
6957
6959
  domain: domain2 ? domainFormat.toList({
6958
6960
  context: context2,
@@ -6961,6 +6963,65 @@ var searchController = ({
6961
6963
  });
6962
6964
  }
6963
6965
  };
6966
+ const onKeyDown = (e) => {
6967
+ if (!searchBy || searchBy.length === 0) return;
6968
+ switch (e.key) {
6969
+ case "Backspace": {
6970
+ if (!searchString && selectedTags && selectedTags.length > 0) {
6971
+ const lastTag = selectedTags[selectedTags.length - 1];
6972
+ if (!lastTag) return;
6973
+ const key = lastTag.type === constants_exports.SearchType.GROUP ? constants_exports.SearchType.GROUP : lastTag.name;
6974
+ removeKeyFromSearchMap({ key: String(key) });
6975
+ }
6976
+ break;
6977
+ }
6978
+ case "ArrowDown": {
6979
+ e.preventDefault();
6980
+ setHoveredIndex((prev) => {
6981
+ const maxIndex = searchBy.length - 1;
6982
+ const next = prev < maxIndex ? prev + 1 : prev;
6983
+ setHoveredIndexSearchList(next);
6984
+ return next;
6985
+ });
6986
+ break;
6987
+ }
6988
+ case "ArrowUp": {
6989
+ e.preventDefault();
6990
+ setHoveredIndex((prev) => {
6991
+ const next = prev > 0 ? prev - 1 : prev;
6992
+ setHoveredIndexSearchList(next);
6993
+ return next;
6994
+ });
6995
+ break;
6996
+ }
6997
+ case "Enter": {
6998
+ e.preventDefault();
6999
+ if (!searchString.trim()) return;
7000
+ const head = searchBy[hoveredIndex];
7001
+ if (!head) return;
7002
+ handleAddTagSearch({
7003
+ title: head.title,
7004
+ name: head.name,
7005
+ value: searchString,
7006
+ type: constants_exports.SearchType.SEARCH,
7007
+ domain: head.filter_domain,
7008
+ operator: head.operator,
7009
+ dataIndex: head.dataIndex,
7010
+ widget: head.widget,
7011
+ modelType: head.type
7012
+ });
7013
+ break;
7014
+ }
7015
+ default:
7016
+ break;
7017
+ }
7018
+ };
7019
+ const handleMouseEnter = (index) => {
7020
+ setHoveredIndexSearchList(index);
7021
+ };
7022
+ const handleMouseLeave = () => {
7023
+ setHoveredIndexSearchList(null);
7024
+ };
6964
7025
  return {
6965
7026
  groupBy,
6966
7027
  searchBy,
@@ -6976,7 +7037,11 @@ var searchController = ({
6976
7037
  onSearchString: onChangeSearchInput,
6977
7038
  handleAddTagSearch,
6978
7039
  domain: formatDomain(),
6979
- context: contextSearch
7040
+ context: contextSearch,
7041
+ onKeyDown,
7042
+ handleMouseEnter,
7043
+ handleMouseLeave,
7044
+ hoveredIndexSearchList
6980
7045
  };
6981
7046
  };
6982
7047
 
@@ -6990,13 +7055,6 @@ import * as store_star from "@fctc/interface-logic/store";
6990
7055
 
6991
7056
  // src/index.ts
6992
7057
  __reExport(index_exports, store_exports);
6993
-
6994
- // src/constants.ts
6995
- var constants_exports = {};
6996
- __reExport(constants_exports, constants_star);
6997
- import * as constants_star from "@fctc/interface-logic/constants";
6998
-
6999
- // src/index.ts
7000
7058
  __reExport(index_exports, constants_exports);
7001
7059
 
7002
7060
  // src/environment.ts
package/dist/widget.d.mts CHANGED
@@ -109,6 +109,10 @@ declare const many2manyFieldController: (props: IMany2ManyControllerProps) => {
109
109
  handleAddTagSearch: (tag: any) => void;
110
110
  domain: any[] | undefined;
111
111
  context: any;
112
+ onKeyDown: (e: any) => void;
113
+ handleMouseEnter: (index: number) => void;
114
+ handleMouseLeave: () => void;
115
+ hoveredIndexSearchList: number | null;
112
116
  };
113
117
  handleCreateNewOnPage: () => Promise<void>;
114
118
  specification: Record<string, any> | null;
@@ -306,6 +310,10 @@ declare const searchController: ({ viewData, model, domain, context, fieldsList,
306
310
  handleAddTagSearch: (tag: any) => void;
307
311
  domain: any[] | undefined;
308
312
  context: any;
313
+ onKeyDown: (e: any) => void;
314
+ handleMouseEnter: (index: number) => void;
315
+ handleMouseLeave: () => void;
316
+ hoveredIndexSearchList: number | null;
309
317
  };
310
318
 
311
319
  export { type ISelctionStateProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController };
package/dist/widget.d.ts CHANGED
@@ -109,6 +109,10 @@ declare const many2manyFieldController: (props: IMany2ManyControllerProps) => {
109
109
  handleAddTagSearch: (tag: any) => void;
110
110
  domain: any[] | undefined;
111
111
  context: any;
112
+ onKeyDown: (e: any) => void;
113
+ handleMouseEnter: (index: number) => void;
114
+ handleMouseLeave: () => void;
115
+ hoveredIndexSearchList: number | null;
112
116
  };
113
117
  handleCreateNewOnPage: () => Promise<void>;
114
118
  specification: Record<string, any> | null;
@@ -306,6 +310,10 @@ declare const searchController: ({ viewData, model, domain, context, fieldsList,
306
310
  handleAddTagSearch: (tag: any) => void;
307
311
  domain: any[] | undefined;
308
312
  context: any;
313
+ onKeyDown: (e: any) => void;
314
+ handleMouseEnter: (index: number) => void;
315
+ handleMouseLeave: () => void;
316
+ hoveredIndexSearchList: number | null;
309
317
  };
310
318
 
311
319
  export { type ISelctionStateProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableController, tableGroupController, tableHeadController };
package/dist/widget.js CHANGED
@@ -5849,10 +5849,14 @@ var tableGroupController = (props) => {
5849
5849
  };
5850
5850
 
5851
5851
  // src/widget/advance/search/controller.ts
5852
- var import_constants3 = require("@fctc/interface-logic/constants");
5853
- var import_utils20 = require("@fctc/interface-logic/utils");
5854
5852
  var import_moment2 = __toESM(require_moment());
5855
5853
  var import_react26 = require("react");
5854
+
5855
+ // src/constants.ts
5856
+ var constants_exports = {};
5857
+ __reExport(constants_exports, require("@fctc/interface-logic/constants"));
5858
+
5859
+ // src/widget/advance/search/controller.ts
5856
5860
  var searchController = ({
5857
5861
  viewData,
5858
5862
  model,
@@ -5867,9 +5871,11 @@ var searchController = ({
5867
5871
  const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
5868
5872
  const [searchString, setSearchString] = (0, import_react26.useState)("");
5869
5873
  const [searchMap, setSearchMap] = (0, import_react26.useState)({});
5870
- const actionContext = typeof context === "string" ? (0, import_utils20.evalJSONContext)(context) : context;
5874
+ const [hoveredIndex, setHoveredIndex] = (0, import_react26.useState)(0);
5875
+ const [hoveredIndexSearchList, setHoveredIndexSearchList] = (0, import_react26.useState)(0);
5876
+ const actionContext = typeof context === "string" ? (0, utils_exports.evalJSONContext)(context) : context;
5871
5877
  const contextSearch = { ...env.context, ...actionContext };
5872
- const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils20.evalJSONDomain)(domain, contextSearch) : [];
5878
+ const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, utils_exports.evalJSONDomain)(domain, contextSearch) : [];
5873
5879
  const clearSearch = () => {
5874
5880
  setFilterBy([]);
5875
5881
  setGroupBy([]);
@@ -5884,23 +5890,23 @@ var searchController = ({
5884
5890
  const dataModel = viewData?.models?.[model];
5885
5891
  const searchViews = viewData?.views?.search;
5886
5892
  const searchByItems = searchViews?.search_by?.filter(
5887
- (item) => !import_utils20.domainHelper.matchDomains(contextSearch, item.invisible)
5893
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item.invisible)
5888
5894
  )?.map(
5889
5895
  ({ string, name, filter_domain, operator, widget }, index) => ({
5890
5896
  dataIndex: index,
5891
- title: string ?? dataModel[name]?.string,
5892
- name: name ?? dataModel[name]?.name,
5897
+ title: string ?? dataModel?.[name]?.string,
5898
+ name: name ?? dataModel?.[name]?.name,
5893
5899
  filter_domain,
5894
5900
  operator,
5895
5901
  widget,
5896
- type: dataModel[name]?.type
5902
+ type: dataModel?.[name]?.type
5897
5903
  })
5898
5904
  );
5899
5905
  const filterByItems = searchViews?.filter_by.filter((item) => {
5900
- return !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible);
5906
+ return !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible);
5901
5907
  })?.map((item) => ({ ...item, active: false }));
5902
5908
  const groupByItems = searchViews?.group_by.filter(
5903
- (item) => !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible)
5909
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible)
5904
5910
  ).map((item) => ({
5905
5911
  ...item,
5906
5912
  string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
@@ -5954,7 +5960,7 @@ var searchController = ({
5954
5960
  if (domainAction) {
5955
5961
  const domain2 = [];
5956
5962
  if (Array.isArray(domainAction) && domainAction.length > 0) {
5957
- if (Object.keys(searchMap).some((key) => !key.includes(import_constants3.SearchType.GROUP))) {
5963
+ if (Object.keys(searchMap).some((key) => !key.includes(constants_exports.SearchType.GROUP))) {
5958
5964
  domain2.push("&");
5959
5965
  }
5960
5966
  domainAction.forEach((domainItem) => {
@@ -5962,7 +5968,7 @@ var searchController = ({
5962
5968
  });
5963
5969
  }
5964
5970
  Object.keys(searchMap).forEach((key, keyIndex, keys) => {
5965
- if (!key?.includes(import_constants3.SearchType.GROUP)) {
5971
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
5966
5972
  if (keys.length > 1 && keyIndex < keys.length - 1) {
5967
5973
  domain2.push("&");
5968
5974
  }
@@ -5977,14 +5983,14 @@ var searchController = ({
5977
5983
  }
5978
5984
  let valueDomainItem = value?.value;
5979
5985
  if (value?.modelType === "date") {
5980
- valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value);
5986
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value);
5981
5987
  } else if (value?.modelType === "datetime") {
5982
5988
  if (value?.operator === "<=" || value?.operator === "<") {
5983
- const parsedDate = (0, import_utils20.validateAndParseDate)(value?.value, true);
5989
+ const parsedDate = (0, utils_exports.validateAndParseDate)(value?.value, true);
5984
5990
  const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
5985
5991
  valueDomainItem = hasTime ? (0, import_moment2.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment2.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
5986
5992
  } else {
5987
- valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value, true);
5993
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value, true);
5988
5994
  }
5989
5995
  }
5990
5996
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
@@ -6009,11 +6015,11 @@ var searchController = ({
6009
6015
  modelType,
6010
6016
  dataIndex
6011
6017
  } = objValues[0];
6012
- if (!key?.includes(import_constants3.SearchType.GROUP)) {
6018
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6013
6019
  const values = objValues?.map((objValue) => objValue.value);
6014
6020
  return {
6015
6021
  title,
6016
- name: type === import_constants3.SearchType.SEARCH ? `${import_constants3.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6022
+ name: type === constants_exports.SearchType.SEARCH ? `${constants_exports.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6017
6023
  values,
6018
6024
  type,
6019
6025
  widget,
@@ -6063,22 +6069,22 @@ var searchController = ({
6063
6069
  }, [searchMap]);
6064
6070
  const handleAddTagSearch = (tag) => {
6065
6071
  const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
6066
- const domainFormat = new import_utils20.domainHelper.Domain(domain2);
6067
- if (type === import_constants3.SearchType.FILTER) {
6068
- addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
6072
+ const domainFormat = new utils_exports.domainHelper.Domain(domain2);
6073
+ if (type === constants_exports.SearchType.FILTER) {
6074
+ addSearchItems(`${constants_exports.SearchType.FILTER}_${groupIndex}`, {
6069
6075
  ...tag,
6070
6076
  domain: domain2 ? domainFormat.toList(context2) : null
6071
6077
  });
6072
- } else if (type === import_constants3.SearchType.SEARCH) {
6073
- addSearchItems(`${import_constants3.SearchType.SEARCH}_${String(dataIndex)}`, {
6078
+ } else if (type === constants_exports.SearchType.SEARCH) {
6079
+ addSearchItems(`${constants_exports.SearchType.SEARCH}_${String(dataIndex)}`, {
6074
6080
  ...tag,
6075
6081
  domain: domain2 ? domainFormat.toList({
6076
6082
  ...context2,
6077
6083
  self: value
6078
6084
  }) : null
6079
6085
  });
6080
- } else if (type === import_constants3.SearchType.GROUP) {
6081
- addSearchItems(`${import_constants3.SearchType.GROUP}`, {
6086
+ } else if (type === constants_exports.SearchType.GROUP) {
6087
+ addSearchItems(`${constants_exports.SearchType.GROUP}`, {
6082
6088
  ...tag,
6083
6089
  domain: domain2 ? domainFormat.toList({
6084
6090
  context: context2,
@@ -6087,6 +6093,65 @@ var searchController = ({
6087
6093
  });
6088
6094
  }
6089
6095
  };
6096
+ const onKeyDown = (e) => {
6097
+ if (!searchBy || searchBy.length === 0) return;
6098
+ switch (e.key) {
6099
+ case "Backspace": {
6100
+ if (!searchString && selectedTags && selectedTags.length > 0) {
6101
+ const lastTag = selectedTags[selectedTags.length - 1];
6102
+ if (!lastTag) return;
6103
+ const key = lastTag.type === constants_exports.SearchType.GROUP ? constants_exports.SearchType.GROUP : lastTag.name;
6104
+ removeKeyFromSearchMap({ key: String(key) });
6105
+ }
6106
+ break;
6107
+ }
6108
+ case "ArrowDown": {
6109
+ e.preventDefault();
6110
+ setHoveredIndex((prev) => {
6111
+ const maxIndex = searchBy.length - 1;
6112
+ const next = prev < maxIndex ? prev + 1 : prev;
6113
+ setHoveredIndexSearchList(next);
6114
+ return next;
6115
+ });
6116
+ break;
6117
+ }
6118
+ case "ArrowUp": {
6119
+ e.preventDefault();
6120
+ setHoveredIndex((prev) => {
6121
+ const next = prev > 0 ? prev - 1 : prev;
6122
+ setHoveredIndexSearchList(next);
6123
+ return next;
6124
+ });
6125
+ break;
6126
+ }
6127
+ case "Enter": {
6128
+ e.preventDefault();
6129
+ if (!searchString.trim()) return;
6130
+ const head = searchBy[hoveredIndex];
6131
+ if (!head) return;
6132
+ handleAddTagSearch({
6133
+ title: head.title,
6134
+ name: head.name,
6135
+ value: searchString,
6136
+ type: constants_exports.SearchType.SEARCH,
6137
+ domain: head.filter_domain,
6138
+ operator: head.operator,
6139
+ dataIndex: head.dataIndex,
6140
+ widget: head.widget,
6141
+ modelType: head.type
6142
+ });
6143
+ break;
6144
+ }
6145
+ default:
6146
+ break;
6147
+ }
6148
+ };
6149
+ const handleMouseEnter = (index) => {
6150
+ setHoveredIndexSearchList(index);
6151
+ };
6152
+ const handleMouseLeave = () => {
6153
+ setHoveredIndexSearchList(null);
6154
+ };
6090
6155
  return {
6091
6156
  groupBy,
6092
6157
  searchBy,
@@ -6102,7 +6167,11 @@ var searchController = ({
6102
6167
  onSearchString: onChangeSearchInput,
6103
6168
  handleAddTagSearch,
6104
6169
  domain: formatDomain(),
6105
- context: contextSearch
6170
+ context: contextSearch,
6171
+ onKeyDown,
6172
+ handleMouseEnter,
6173
+ handleMouseLeave,
6174
+ hoveredIndexSearchList
6106
6175
  };
6107
6176
  };
6108
6177
  // Annotate the CommonJS export names for ESM import in node:
package/dist/widget.mjs CHANGED
@@ -5922,14 +5922,14 @@ var tableGroupController = (props) => {
5922
5922
 
5923
5923
  // src/widget/advance/search/controller.ts
5924
5924
  var import_moment2 = __toESM(require_moment());
5925
- import { SearchType } from "@fctc/interface-logic/constants";
5926
- import {
5927
- domainHelper as domainHelper2,
5928
- evalJSONContext as evalJSONContext8,
5929
- evalJSONDomain as evalJSONDomain6,
5930
- validateAndParseDate
5931
- } from "@fctc/interface-logic/utils";
5932
5925
  import { useCallback as useCallback7, useEffect as useEffect16, useState as useState15 } from "react";
5926
+
5927
+ // src/constants.ts
5928
+ var constants_exports = {};
5929
+ __reExport(constants_exports, constants_star);
5930
+ import * as constants_star from "@fctc/interface-logic/constants";
5931
+
5932
+ // src/widget/advance/search/controller.ts
5933
5933
  var searchController = ({
5934
5934
  viewData,
5935
5935
  model,
@@ -5944,9 +5944,11 @@ var searchController = ({
5944
5944
  const [selectedTags, setSelectedTags] = useState15(null);
5945
5945
  const [searchString, setSearchString] = useState15("");
5946
5946
  const [searchMap, setSearchMap] = useState15({});
5947
- const actionContext = typeof context === "string" ? evalJSONContext8(context) : context;
5947
+ const [hoveredIndex, setHoveredIndex] = useState15(0);
5948
+ const [hoveredIndexSearchList, setHoveredIndexSearchList] = useState15(0);
5949
+ const actionContext = typeof context === "string" ? (0, utils_exports.evalJSONContext)(context) : context;
5948
5950
  const contextSearch = { ...env.context, ...actionContext };
5949
- const domainAction = domain ? Array.isArray(domain) ? [...domain] : evalJSONDomain6(domain, contextSearch) : [];
5951
+ const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, utils_exports.evalJSONDomain)(domain, contextSearch) : [];
5950
5952
  const clearSearch = () => {
5951
5953
  setFilterBy([]);
5952
5954
  setGroupBy([]);
@@ -5961,23 +5963,23 @@ var searchController = ({
5961
5963
  const dataModel = viewData?.models?.[model];
5962
5964
  const searchViews = viewData?.views?.search;
5963
5965
  const searchByItems = searchViews?.search_by?.filter(
5964
- (item) => !domainHelper2.matchDomains(contextSearch, item.invisible)
5966
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item.invisible)
5965
5967
  )?.map(
5966
5968
  ({ string, name, filter_domain, operator, widget }, index) => ({
5967
5969
  dataIndex: index,
5968
- title: string ?? dataModel[name]?.string,
5969
- name: name ?? dataModel[name]?.name,
5970
+ title: string ?? dataModel?.[name]?.string,
5971
+ name: name ?? dataModel?.[name]?.name,
5970
5972
  filter_domain,
5971
5973
  operator,
5972
5974
  widget,
5973
- type: dataModel[name]?.type
5975
+ type: dataModel?.[name]?.type
5974
5976
  })
5975
5977
  );
5976
5978
  const filterByItems = searchViews?.filter_by.filter((item) => {
5977
- return !domainHelper2.matchDomains(contextSearch, item?.invisible);
5979
+ return !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible);
5978
5980
  })?.map((item) => ({ ...item, active: false }));
5979
5981
  const groupByItems = searchViews?.group_by.filter(
5980
- (item) => !domainHelper2.matchDomains(contextSearch, item?.invisible)
5982
+ (item) => !utils_exports.domainHelper.matchDomains(contextSearch, item?.invisible)
5981
5983
  ).map((item) => ({
5982
5984
  ...item,
5983
5985
  string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
@@ -6031,7 +6033,7 @@ var searchController = ({
6031
6033
  if (domainAction) {
6032
6034
  const domain2 = [];
6033
6035
  if (Array.isArray(domainAction) && domainAction.length > 0) {
6034
- if (Object.keys(searchMap).some((key) => !key.includes(SearchType.GROUP))) {
6036
+ if (Object.keys(searchMap).some((key) => !key.includes(constants_exports.SearchType.GROUP))) {
6035
6037
  domain2.push("&");
6036
6038
  }
6037
6039
  domainAction.forEach((domainItem) => {
@@ -6039,7 +6041,7 @@ var searchController = ({
6039
6041
  });
6040
6042
  }
6041
6043
  Object.keys(searchMap).forEach((key, keyIndex, keys) => {
6042
- if (!key?.includes(SearchType.GROUP)) {
6044
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6043
6045
  if (keys.length > 1 && keyIndex < keys.length - 1) {
6044
6046
  domain2.push("&");
6045
6047
  }
@@ -6054,14 +6056,14 @@ var searchController = ({
6054
6056
  }
6055
6057
  let valueDomainItem = value?.value;
6056
6058
  if (value?.modelType === "date") {
6057
- valueDomainItem = validateAndParseDate(value?.value);
6059
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value);
6058
6060
  } else if (value?.modelType === "datetime") {
6059
6061
  if (value?.operator === "<=" || value?.operator === "<") {
6060
- const parsedDate = validateAndParseDate(value?.value, true);
6062
+ const parsedDate = (0, utils_exports.validateAndParseDate)(value?.value, true);
6061
6063
  const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
6062
6064
  valueDomainItem = hasTime ? (0, import_moment2.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment2.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
6063
6065
  } else {
6064
- valueDomainItem = validateAndParseDate(value?.value, true);
6066
+ valueDomainItem = (0, utils_exports.validateAndParseDate)(value?.value, true);
6065
6067
  }
6066
6068
  }
6067
6069
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
@@ -6086,11 +6088,11 @@ var searchController = ({
6086
6088
  modelType,
6087
6089
  dataIndex
6088
6090
  } = objValues[0];
6089
- if (!key?.includes(SearchType.GROUP)) {
6091
+ if (!key?.includes(constants_exports.SearchType.GROUP)) {
6090
6092
  const values = objValues?.map((objValue) => objValue.value);
6091
6093
  return {
6092
6094
  title,
6093
- name: type === SearchType.SEARCH ? `${SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6095
+ name: type === constants_exports.SearchType.SEARCH ? `${constants_exports.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6094
6096
  values,
6095
6097
  type,
6096
6098
  widget,
@@ -6140,22 +6142,22 @@ var searchController = ({
6140
6142
  }, [searchMap]);
6141
6143
  const handleAddTagSearch = (tag) => {
6142
6144
  const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
6143
- const domainFormat = new domainHelper2.Domain(domain2);
6144
- if (type === SearchType.FILTER) {
6145
- addSearchItems(`${SearchType.FILTER}_${groupIndex}`, {
6145
+ const domainFormat = new utils_exports.domainHelper.Domain(domain2);
6146
+ if (type === constants_exports.SearchType.FILTER) {
6147
+ addSearchItems(`${constants_exports.SearchType.FILTER}_${groupIndex}`, {
6146
6148
  ...tag,
6147
6149
  domain: domain2 ? domainFormat.toList(context2) : null
6148
6150
  });
6149
- } else if (type === SearchType.SEARCH) {
6150
- addSearchItems(`${SearchType.SEARCH}_${String(dataIndex)}`, {
6151
+ } else if (type === constants_exports.SearchType.SEARCH) {
6152
+ addSearchItems(`${constants_exports.SearchType.SEARCH}_${String(dataIndex)}`, {
6151
6153
  ...tag,
6152
6154
  domain: domain2 ? domainFormat.toList({
6153
6155
  ...context2,
6154
6156
  self: value
6155
6157
  }) : null
6156
6158
  });
6157
- } else if (type === SearchType.GROUP) {
6158
- addSearchItems(`${SearchType.GROUP}`, {
6159
+ } else if (type === constants_exports.SearchType.GROUP) {
6160
+ addSearchItems(`${constants_exports.SearchType.GROUP}`, {
6159
6161
  ...tag,
6160
6162
  domain: domain2 ? domainFormat.toList({
6161
6163
  context: context2,
@@ -6164,6 +6166,65 @@ var searchController = ({
6164
6166
  });
6165
6167
  }
6166
6168
  };
6169
+ const onKeyDown = (e) => {
6170
+ if (!searchBy || searchBy.length === 0) return;
6171
+ switch (e.key) {
6172
+ case "Backspace": {
6173
+ if (!searchString && selectedTags && selectedTags.length > 0) {
6174
+ const lastTag = selectedTags[selectedTags.length - 1];
6175
+ if (!lastTag) return;
6176
+ const key = lastTag.type === constants_exports.SearchType.GROUP ? constants_exports.SearchType.GROUP : lastTag.name;
6177
+ removeKeyFromSearchMap({ key: String(key) });
6178
+ }
6179
+ break;
6180
+ }
6181
+ case "ArrowDown": {
6182
+ e.preventDefault();
6183
+ setHoveredIndex((prev) => {
6184
+ const maxIndex = searchBy.length - 1;
6185
+ const next = prev < maxIndex ? prev + 1 : prev;
6186
+ setHoveredIndexSearchList(next);
6187
+ return next;
6188
+ });
6189
+ break;
6190
+ }
6191
+ case "ArrowUp": {
6192
+ e.preventDefault();
6193
+ setHoveredIndex((prev) => {
6194
+ const next = prev > 0 ? prev - 1 : prev;
6195
+ setHoveredIndexSearchList(next);
6196
+ return next;
6197
+ });
6198
+ break;
6199
+ }
6200
+ case "Enter": {
6201
+ e.preventDefault();
6202
+ if (!searchString.trim()) return;
6203
+ const head = searchBy[hoveredIndex];
6204
+ if (!head) return;
6205
+ handleAddTagSearch({
6206
+ title: head.title,
6207
+ name: head.name,
6208
+ value: searchString,
6209
+ type: constants_exports.SearchType.SEARCH,
6210
+ domain: head.filter_domain,
6211
+ operator: head.operator,
6212
+ dataIndex: head.dataIndex,
6213
+ widget: head.widget,
6214
+ modelType: head.type
6215
+ });
6216
+ break;
6217
+ }
6218
+ default:
6219
+ break;
6220
+ }
6221
+ };
6222
+ const handleMouseEnter = (index) => {
6223
+ setHoveredIndexSearchList(index);
6224
+ };
6225
+ const handleMouseLeave = () => {
6226
+ setHoveredIndexSearchList(null);
6227
+ };
6167
6228
  return {
6168
6229
  groupBy,
6169
6230
  searchBy,
@@ -6179,7 +6240,11 @@ var searchController = ({
6179
6240
  onSearchString: onChangeSearchInput,
6180
6241
  handleAddTagSearch,
6181
6242
  domain: formatDomain(),
6182
- context: contextSearch
6243
+ context: contextSearch,
6244
+ onKeyDown,
6245
+ handleMouseEnter,
6246
+ handleMouseLeave,
6247
+ hoveredIndexSearchList
6183
6248
  };
6184
6249
  };
6185
6250
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/widget-logic",
3
- "version": "4.6.7",
3
+ "version": "4.6.9",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -74,7 +74,7 @@
74
74
  "test": "jest"
75
75
  },
76
76
  "dependencies": {
77
- "@fctc/interface-logic": "^4.0.3",
77
+ "@fctc/interface-logic": "^4.0.5",
78
78
  "@headlessui/react": "^2.2.6",
79
79
  "@tanstack/react-query": "^5.84.0",
80
80
  "i18next": "^25.3.2",