@fctc/widget-logic 4.6.6 → 4.6.8
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/hooks.js +1 -5
- package/dist/hooks.mjs +19 -23
- package/dist/index.js +95 -36
- package/dist/index.mjs +131 -77
- package/dist/widget.d.mts +8 -0
- package/dist/widget.d.ts +8 -0
- package/dist/widget.js +94 -25
- package/dist/widget.mjs +123 -58
- package/package.json +2 -2
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
|
|
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,
|
|
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) => !
|
|
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 !
|
|
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) => !
|
|
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(
|
|
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(
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
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 ===
|
|
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
|
|
6067
|
-
if (type ===
|
|
6068
|
-
addSearchItems(`${
|
|
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 ===
|
|
6073
|
-
addSearchItems(`${
|
|
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 ===
|
|
6081
|
-
addSearchItems(`${
|
|
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
|
@@ -4091,7 +4091,7 @@ var statusDropdownController = (props) => {
|
|
|
4091
4091
|
};
|
|
4092
4092
|
|
|
4093
4093
|
// src/widget/basic/many2one-field/controller.ts
|
|
4094
|
-
import { useCallback as useCallback4, useEffect as useEffect10, useMemo as
|
|
4094
|
+
import { useCallback as useCallback4, useEffect as useEffect10, useMemo as useMemo8, useState as useState7 } from "react";
|
|
4095
4095
|
|
|
4096
4096
|
// src/hooks.ts
|
|
4097
4097
|
import {
|
|
@@ -4182,13 +4182,13 @@ import {
|
|
|
4182
4182
|
} from "@fctc/interface-logic/hooks";
|
|
4183
4183
|
|
|
4184
4184
|
// src/hooks/core/use-app-provider.tsx
|
|
4185
|
-
import { createContext, useContext, useMemo as
|
|
4185
|
+
import { createContext, useContext, useMemo as useMemo5 } from "react";
|
|
4186
4186
|
|
|
4187
4187
|
// src/hooks/core/use-menu.ts
|
|
4188
|
-
import { useMemo
|
|
4188
|
+
import { useMemo, useState as useState3 } from "react";
|
|
4189
4189
|
|
|
4190
4190
|
// src/hooks/core/use-call-action.ts
|
|
4191
|
-
import { useCallback,
|
|
4191
|
+
import { useCallback, useState as useState2 } from "react";
|
|
4192
4192
|
|
|
4193
4193
|
// src/provider.ts
|
|
4194
4194
|
var provider_exports = {};
|
|
@@ -4383,15 +4383,15 @@ import { useEffect as useEffect3 } from "react";
|
|
|
4383
4383
|
|
|
4384
4384
|
// src/hooks/core/use-profile.ts
|
|
4385
4385
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
4386
|
-
import { useEffect as useEffect4, useMemo as
|
|
4386
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
4387
4387
|
import { useTranslation } from "react-i18next";
|
|
4388
4388
|
|
|
4389
4389
|
// src/hooks/core/use-view-v2.ts
|
|
4390
|
-
import { useMemo as
|
|
4390
|
+
import { useMemo as useMemo3 } from "react";
|
|
4391
4391
|
|
|
4392
4392
|
// src/hooks/core/use-company.ts
|
|
4393
4393
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
4394
|
-
import { useEffect as useEffect5, useMemo as
|
|
4394
|
+
import { useEffect as useEffect5, useMemo as useMemo4 } from "react";
|
|
4395
4395
|
|
|
4396
4396
|
// src/hooks/core/use-app-provider.tsx
|
|
4397
4397
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -4415,7 +4415,7 @@ var useAppProvider = () => {
|
|
|
4415
4415
|
import { useEffect as useEffect6 } from "react";
|
|
4416
4416
|
|
|
4417
4417
|
// src/hooks/core/use-get-specification.ts
|
|
4418
|
-
import { useMemo as
|
|
4418
|
+
import { useMemo as useMemo6 } from "react";
|
|
4419
4419
|
var useGetSpecification = ({
|
|
4420
4420
|
model,
|
|
4421
4421
|
viewData,
|
|
@@ -4427,13 +4427,13 @@ var useGetSpecification = ({
|
|
|
4427
4427
|
fields
|
|
4428
4428
|
};
|
|
4429
4429
|
const initModel = useModel();
|
|
4430
|
-
const modelInstance =
|
|
4430
|
+
const modelInstance = useMemo6(() => {
|
|
4431
4431
|
if (viewData) {
|
|
4432
4432
|
return initModel.initModel(baseModel);
|
|
4433
4433
|
}
|
|
4434
4434
|
return null;
|
|
4435
4435
|
}, [baseModel, viewData, model]);
|
|
4436
|
-
const specification =
|
|
4436
|
+
const specification = useMemo6(() => {
|
|
4437
4437
|
if (modelInstance) {
|
|
4438
4438
|
return modelInstance.getSpecification();
|
|
4439
4439
|
}
|
|
@@ -4443,7 +4443,7 @@ var useGetSpecification = ({
|
|
|
4443
4443
|
};
|
|
4444
4444
|
|
|
4445
4445
|
// src/hooks/core/use-list-data.ts
|
|
4446
|
-
import { useMemo as
|
|
4446
|
+
import { useMemo as useMemo7, useState as useState6 } from "react";
|
|
4447
4447
|
import {
|
|
4448
4448
|
evalJSONDomain,
|
|
4449
4449
|
formatSortingString,
|
|
@@ -4559,7 +4559,7 @@ var useListData = ({
|
|
|
4559
4559
|
viewData,
|
|
4560
4560
|
fields: mode === "kanban" ? viewData?.views?.kanban?.fields : viewData?.views?.list?.fields
|
|
4561
4561
|
});
|
|
4562
|
-
const listDataProps =
|
|
4562
|
+
const listDataProps = useMemo7(() => {
|
|
4563
4563
|
if (!viewData || !action || !context) {
|
|
4564
4564
|
return null;
|
|
4565
4565
|
}
|
|
@@ -4696,7 +4696,7 @@ var many2oneFieldController = (props) => {
|
|
|
4696
4696
|
service: widget === MANY2ONE_EXTERNAL ? optionsObject?.service : service,
|
|
4697
4697
|
xNode
|
|
4698
4698
|
});
|
|
4699
|
-
const selectOptions =
|
|
4699
|
+
const selectOptions = useMemo8(() => {
|
|
4700
4700
|
return dataOfSelection?.records?.map((val) => ({
|
|
4701
4701
|
value: val?.id,
|
|
4702
4702
|
label: val?.display_name || val?.name,
|
|
@@ -4707,7 +4707,7 @@ var many2oneFieldController = (props) => {
|
|
|
4707
4707
|
setListOptions(selectOptions);
|
|
4708
4708
|
setDomainModal(domainObject);
|
|
4709
4709
|
}, [selectOptions]);
|
|
4710
|
-
const parsedFormValues =
|
|
4710
|
+
const parsedFormValues = useMemo8(
|
|
4711
4711
|
() => JSON.parse(
|
|
4712
4712
|
JSON.stringify({
|
|
4713
4713
|
...formValues,
|
|
@@ -5064,7 +5064,7 @@ var many2manyFieldController = (props) => {
|
|
|
5064
5064
|
};
|
|
5065
5065
|
|
|
5066
5066
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5067
|
-
import { useCallback as useCallback5, useEffect as useEffect12, useMemo as
|
|
5067
|
+
import { useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo9, useState as useState8 } from "react";
|
|
5068
5068
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
5069
5069
|
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain4 } from "@fctc/interface-logic/utils";
|
|
5070
5070
|
var many2manyTagsController = (props) => {
|
|
@@ -5096,7 +5096,7 @@ var many2manyTagsController = (props) => {
|
|
|
5096
5096
|
...fieldContext ?? {},
|
|
5097
5097
|
...env?.context
|
|
5098
5098
|
};
|
|
5099
|
-
const parsedFormValues =
|
|
5099
|
+
const parsedFormValues = useMemo9(
|
|
5100
5100
|
() => JSON.parse(
|
|
5101
5101
|
JSON.stringify({
|
|
5102
5102
|
...formValues,
|
|
@@ -5137,7 +5137,7 @@ var many2manyTagsController = (props) => {
|
|
|
5137
5137
|
xNode,
|
|
5138
5138
|
enabled: false
|
|
5139
5139
|
});
|
|
5140
|
-
const selectOptions =
|
|
5140
|
+
const selectOptions = useMemo9(() => {
|
|
5141
5141
|
return dataOfSelection?.records?.map((val) => ({
|
|
5142
5142
|
value: val.id,
|
|
5143
5143
|
label: val.name ?? val.display_name,
|
|
@@ -5644,7 +5644,7 @@ var binaryFieldController = (props) => {
|
|
|
5644
5644
|
};
|
|
5645
5645
|
|
|
5646
5646
|
// src/widget/advance/table/table-head/controller.ts
|
|
5647
|
-
import { useMemo as
|
|
5647
|
+
import { useMemo as useMemo10, useRef as useRef5 } from "react";
|
|
5648
5648
|
var tableHeadController = (props) => {
|
|
5649
5649
|
const {
|
|
5650
5650
|
typeTable,
|
|
@@ -5657,19 +5657,19 @@ var tableHeadController = (props) => {
|
|
|
5657
5657
|
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
5658
5658
|
const selectedRowKeysRef = useRef5(recordIds);
|
|
5659
5659
|
const isGroupTable = typeTable === "group";
|
|
5660
|
-
const recordsCheckedGroup =
|
|
5660
|
+
const recordsCheckedGroup = useMemo10(() => {
|
|
5661
5661
|
if (!rows || !groupByList) return 0;
|
|
5662
5662
|
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
5663
5663
|
return countSum(rows, groupBy);
|
|
5664
5664
|
}, [rows, groupByList]);
|
|
5665
|
-
const isAllGroupChecked =
|
|
5665
|
+
const isAllGroupChecked = useMemo10(() => {
|
|
5666
5666
|
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
5667
5667
|
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
5668
5668
|
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
5669
5669
|
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
5670
5670
|
return allGroupsSelected || allRecordsSelected;
|
|
5671
5671
|
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
5672
|
-
const isAllNormalChecked =
|
|
5672
|
+
const isAllNormalChecked = useMemo10(() => {
|
|
5673
5673
|
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
5674
5674
|
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
5675
5675
|
(id) => rows.some((record) => record.id === id)
|
|
@@ -5710,19 +5710,19 @@ var tableHeadController = (props) => {
|
|
|
5710
5710
|
};
|
|
5711
5711
|
|
|
5712
5712
|
// src/widget/advance/table/table-view/controller.ts
|
|
5713
|
-
import { useCallback as useCallback6, useEffect as useEffect14, useMemo as
|
|
5713
|
+
import { useCallback as useCallback6, useEffect as useEffect14, useMemo as useMemo11, useState as useState13 } from "react";
|
|
5714
5714
|
import { domainHelper } from "@fctc/interface-logic/utils";
|
|
5715
5715
|
var tableController = ({ data }) => {
|
|
5716
5716
|
const [rows, setRows] = useState13([]);
|
|
5717
5717
|
const [columnVisibility, setColumnVisibility] = useState13({});
|
|
5718
|
-
const dataModelFields =
|
|
5718
|
+
const dataModelFields = useMemo11(() => {
|
|
5719
5719
|
return data?.fields?.map((field) => ({
|
|
5720
5720
|
...data.dataModel?.[field?.name],
|
|
5721
5721
|
...field,
|
|
5722
5722
|
string: field?.string || data.dataModel?.[field?.name]?.string
|
|
5723
5723
|
})) ?? [];
|
|
5724
5724
|
}, [data?.fields, data?.dataModel]);
|
|
5725
|
-
const mergeFields =
|
|
5725
|
+
const mergeFields = useMemo11(
|
|
5726
5726
|
() => mergeButtons(dataModelFields),
|
|
5727
5727
|
[dataModelFields]
|
|
5728
5728
|
);
|
|
@@ -5751,7 +5751,7 @@ var tableController = ({ data }) => {
|
|
|
5751
5751
|
useEffect14(() => {
|
|
5752
5752
|
setRows(transformData(data?.records));
|
|
5753
5753
|
}, [data?.records, transformData]);
|
|
5754
|
-
const columns =
|
|
5754
|
+
const columns = useMemo11(() => {
|
|
5755
5755
|
try {
|
|
5756
5756
|
return mergeFields?.filter((item) => {
|
|
5757
5757
|
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? domainHelper.matchDomains(
|
|
@@ -5787,7 +5787,7 @@ var tableController = ({ data }) => {
|
|
|
5787
5787
|
};
|
|
5788
5788
|
|
|
5789
5789
|
// src/widget/advance/table/table-group/controller.ts
|
|
5790
|
-
import { useEffect as useEffect15, useMemo as
|
|
5790
|
+
import { useEffect as useEffect15, useMemo as useMemo12, useState as useState14 } from "react";
|
|
5791
5791
|
import { useAppSelector, selectList } from "@fctc/interface-logic/store";
|
|
5792
5792
|
var tableGroupController = (props) => {
|
|
5793
5793
|
const { env } = (0, provider_exports.useEnv)();
|
|
@@ -5812,7 +5812,7 @@ var tableGroupController = (props) => {
|
|
|
5812
5812
|
fromEnd: 1
|
|
5813
5813
|
});
|
|
5814
5814
|
const domain = row?.__domain;
|
|
5815
|
-
const processedData =
|
|
5815
|
+
const processedData = useMemo12(() => {
|
|
5816
5816
|
const calculateColSpanEmpty = () => {
|
|
5817
5817
|
const startIndex = columns.findIndex(
|
|
5818
5818
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -5827,7 +5827,7 @@ var tableGroupController = (props) => {
|
|
|
5827
5827
|
};
|
|
5828
5828
|
return calculateColSpanEmpty();
|
|
5829
5829
|
}, [columns, row]);
|
|
5830
|
-
const shouldFetchData =
|
|
5830
|
+
const shouldFetchData = useMemo12(() => {
|
|
5831
5831
|
return !!isShowGroup;
|
|
5832
5832
|
}, [isShowGroup]);
|
|
5833
5833
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -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
|
|
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] :
|
|
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) => !
|
|
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 !
|
|
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) => !
|
|
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
|
|
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.
|
|
3
|
+
"version": "4.6.8",
|
|
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.
|
|
77
|
+
"@fctc/interface-logic": "^4.0.4",
|
|
78
78
|
"@headlessui/react": "^2.2.6",
|
|
79
79
|
"@tanstack/react-query": "^5.84.0",
|
|
80
80
|
"i18next": "^25.3.2",
|