@fctc/widget-logic 2.7.1 → 2.7.3

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/widget.mjs CHANGED
@@ -59,7 +59,7 @@ var require_moment = __commonJS({
59
59
  function hasOwnProp(a, b) {
60
60
  return Object.prototype.hasOwnProperty.call(a, b);
61
61
  }
62
- function isObjectEmpty4(obj) {
62
+ function isObjectEmpty5(obj) {
63
63
  if (Object.getOwnPropertyNames) {
64
64
  return Object.getOwnPropertyNames(obj).length === 0;
65
65
  } else {
@@ -2198,7 +2198,7 @@ var require_moment = __commonJS({
2198
2198
  strict = locale2;
2199
2199
  locale2 = void 0;
2200
2200
  }
2201
- if (isObject(input) && isObjectEmpty4(input) || isArray(input) && input.length === 0) {
2201
+ if (isObject(input) && isObjectEmpty5(input) || isArray(input) && input.length === 0) {
2202
2202
  input = void 0;
2203
2203
  }
2204
2204
  c._isAMomentObject = true;
@@ -2617,7 +2617,7 @@ var require_moment = __commonJS({
2617
2617
  return isMoment(input) || isDate(input) || isString(input) || isNumber(input) || isNumberOrStringArray(input) || isMomentInputObject(input) || input === null || input === void 0;
2618
2618
  }
2619
2619
  function isMomentInputObject(input) {
2620
- var objectTest = isObject(input) && !isObjectEmpty4(input), propertyTest = false, properties = [
2620
+ var objectTest = isObject(input) && !isObjectEmpty5(input), propertyTest = false, properties = [
2621
2621
  "years",
2622
2622
  "year",
2623
2623
  "y",
@@ -2659,7 +2659,7 @@ var require_moment = __commonJS({
2659
2659
  return arrayTest && dataTypeTest;
2660
2660
  }
2661
2661
  function isCalendarSpec(input) {
2662
- var objectTest = isObject(input) && !isObjectEmpty4(input), propertyTest = false, properties = [
2662
+ var objectTest = isObject(input) && !isObjectEmpty5(input), propertyTest = false, properties = [
2663
2663
  "sameDay",
2664
2664
  "nextDay",
2665
2665
  "lastDay",
@@ -4180,15 +4180,6 @@ var provider_exports = {};
4180
4180
  __reExport(provider_exports, provider_star);
4181
4181
  import * as provider_star from "@fctc/interface-logic/provider";
4182
4182
 
4183
- // src/hooks/core/use-detail.ts
4184
- import { useQuery } from "@tanstack/react-query";
4185
- import { useEffect as useEffect2 } from "react";
4186
-
4187
- // src/hooks/core/use-profile.ts
4188
- import { useQuery as useQuery2 } from "@tanstack/react-query";
4189
- import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
4190
- import { useTranslation } from "react-i18next";
4191
-
4192
4183
  // src/utils.ts
4193
4184
  var utils_exports = {};
4194
4185
  __export(utils_exports, {
@@ -4210,7 +4201,7 @@ var languages = [
4210
4201
  ];
4211
4202
 
4212
4203
  // src/utils/function.ts
4213
- import { useCallback as useCallback2, useEffect as useEffect3, useReducer } from "react";
4204
+ import { useCallback as useCallback2, useEffect as useEffect2, useReducer } from "react";
4214
4205
  var countSum = (data, field) => {
4215
4206
  if (!data || !field) return 0;
4216
4207
  return data.reduce(
@@ -4349,7 +4340,7 @@ async function setStorageItemAsync(key, value) {
4349
4340
  }
4350
4341
  function useStorageState(key) {
4351
4342
  const [state, setState] = useAsyncState();
4352
- useEffect3(() => {
4343
+ useEffect2(() => {
4353
4344
  try {
4354
4345
  const storedValue = localStorage.getItem(key);
4355
4346
  setState(storedValue);
@@ -4371,6 +4362,15 @@ function useStorageState(key) {
4371
4362
  __reExport(utils_exports, utils_star);
4372
4363
  import * as utils_star from "@fctc/interface-logic/utils";
4373
4364
 
4365
+ // src/hooks/core/use-detail.ts
4366
+ import { useQuery } from "@tanstack/react-query";
4367
+ import { useEffect as useEffect3 } from "react";
4368
+
4369
+ // src/hooks/core/use-profile.ts
4370
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
4371
+ import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
4372
+ import { useTranslation } from "react-i18next";
4373
+
4374
4374
  // src/hooks/core/use-view-v2.ts
4375
4375
  import { useMemo as useMemo3 } from "react";
4376
4376
 
@@ -4394,13 +4394,41 @@ import { useEffect as useEffect6 } from "react";
4394
4394
 
4395
4395
  // src/hooks/core/use-get-specification.ts
4396
4396
  import { useMemo as useMemo6 } from "react";
4397
+ var useGetSpecification = ({
4398
+ model,
4399
+ viewData,
4400
+ fields
4401
+ }) => {
4402
+ const baseModel = useMemo6(
4403
+ () => ({
4404
+ name: String(model),
4405
+ view: viewData || {},
4406
+ fields
4407
+ }),
4408
+ [model, viewData]
4409
+ );
4410
+ const initModel = useModel();
4411
+ const modelInstance = useMemo6(() => {
4412
+ if (viewData) {
4413
+ return initModel.initModel(baseModel);
4414
+ }
4415
+ return null;
4416
+ }, [baseModel, viewData]);
4417
+ const specification = useMemo6(() => {
4418
+ if (modelInstance) {
4419
+ return modelInstance.getSpecification();
4420
+ }
4421
+ return null;
4422
+ }, [modelInstance]);
4423
+ return { specification };
4424
+ };
4397
4425
 
4398
4426
  // src/hooks/core/use-list-data.ts
4399
4427
  import { useMemo as useMemo7, useState as useState6 } from "react";
4400
4428
  import {
4401
4429
  evalJSONDomain,
4402
4430
  formatSortingString,
4403
- isObjectEmpty as isObjectEmpty3
4431
+ isObjectEmpty as isObjectEmpty4
4404
4432
  } from "@fctc/interface-logic/utils";
4405
4433
 
4406
4434
  // src/hooks/utils/use-click-outside.ts
@@ -4700,7 +4728,7 @@ var many2oneButtonController = (props) => {
4700
4728
  };
4701
4729
 
4702
4730
  // src/widget/basic/many2many-field/controller.ts
4703
- import { useEffect as useEffect11, useMemo as useMemo9, useState as useState8 } from "react";
4731
+ import { useEffect as useEffect11, useState as useState8 } from "react";
4704
4732
  import {
4705
4733
  evalJSONContext as evalJSONContext4,
4706
4734
  evalJSONDomain as evalJSONDomain4,
@@ -4715,8 +4743,7 @@ var many2manyFieldController = (props) => {
4715
4743
  tab,
4716
4744
  setSelectedRowKeys: setSelectedRowKeys2,
4717
4745
  groupByDomain,
4718
- enabled: enabledCallAPI,
4719
- actionData
4746
+ enabled: enabledCallAPI
4720
4747
  } = props;
4721
4748
  const { env } = (0, provider_exports.useEnv)();
4722
4749
  const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
@@ -4740,31 +4767,14 @@ var many2manyFieldController = (props) => {
4740
4767
  viewParams,
4741
4768
  enabled: enabledCallAPI
4742
4769
  });
4743
- const baseModel = useMemo9(
4744
- () => ({
4745
- name: String(relation),
4746
- view: viewResponse || {},
4747
- actContext: contextObject,
4748
- fields: [
4749
- ...Object.values(viewResponse?.views?.list?.fields ?? {}),
4750
- ...tab?.fields ? tab.fields : []
4751
- ]
4752
- }),
4753
- [relation, viewResponse]
4754
- );
4755
- const initModel = useModel();
4756
- const modelInstance = useMemo9(() => {
4757
- if (viewResponse) {
4758
- return initModel.initModel(baseModel);
4759
- }
4760
- return null;
4761
- }, [baseModel, viewResponse]);
4762
- const specification = useMemo9(() => {
4763
- if (modelInstance) {
4764
- return modelInstance.getSpecification();
4765
- }
4766
- return null;
4767
- }, [modelInstance]);
4770
+ const { specification } = useGetSpecification({
4771
+ model: String(relation),
4772
+ viewData: viewResponse || {},
4773
+ fields: [
4774
+ ...Object.values(viewResponse?.views?.list?.fields ?? {}),
4775
+ ...tab?.fields ? tab.fields : []
4776
+ ]
4777
+ });
4768
4778
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
4769
4779
  const optionsObject = tab?.options ? evalJSONContext4(tab?.options) : (options ? evalJSONContext4(options) : {}) || {};
4770
4780
  const fetchData = async () => {
@@ -4855,7 +4865,7 @@ var many2manyFieldController = (props) => {
4855
4865
  };
4856
4866
 
4857
4867
  // src/widget/basic/many2many-tags-field/controller.ts
4858
- import { useMemo as useMemo10 } from "react";
4868
+ import { useMemo as useMemo9 } from "react";
4859
4869
  import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
4860
4870
  import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
4861
4871
  var many2manyTagsController = (props) => {
@@ -4873,7 +4883,7 @@ var many2manyTagsController = (props) => {
4873
4883
  const { env } = (0, provider_exports.useEnv)();
4874
4884
  const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
4875
4885
  const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
4876
- const domainObject = useMemo10(
4886
+ const domainObject = useMemo9(
4877
4887
  () => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
4878
4888
  [domain, formValues]
4879
4889
  );
@@ -6105,7 +6115,7 @@ var binaryFieldController = (props) => {
6105
6115
  };
6106
6116
 
6107
6117
  // src/widget/advance/table/table-head/controller.ts
6108
- import { useMemo as useMemo11, useRef as useRef5 } from "react";
6118
+ import { useMemo as useMemo10, useRef as useRef5 } from "react";
6109
6119
  var tableHeadController = (props) => {
6110
6120
  const {
6111
6121
  typeTable,
@@ -6118,19 +6128,19 @@ var tableHeadController = (props) => {
6118
6128
  const { rowIds: recordIds } = useGetRowIds(tableRef);
6119
6129
  const selectedRowKeysRef = useRef5(recordIds);
6120
6130
  const isGroupTable = typeTable === "group";
6121
- const recordsCheckedGroup = useMemo11(() => {
6131
+ const recordsCheckedGroup = useMemo10(() => {
6122
6132
  if (!rows || !groupByList) return 0;
6123
6133
  const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
6124
6134
  return countSum(rows, groupBy);
6125
6135
  }, [rows, groupByList]);
6126
- const isAllGroupChecked = useMemo11(() => {
6136
+ const isAllGroupChecked = useMemo10(() => {
6127
6137
  if (!isGroupTable || !selectedRowKeys?.length) return false;
6128
6138
  const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
6129
6139
  const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
6130
6140
  const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
6131
6141
  return allGroupsSelected || allRecordsSelected;
6132
6142
  }, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
6133
- const isAllNormalChecked = useMemo11(() => {
6143
+ const isAllNormalChecked = useMemo10(() => {
6134
6144
  if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
6135
6145
  return selectedRowKeys.length === rows.length && selectedRowKeys.every(
6136
6146
  (id) => rows.some((record) => record.id === id)
@@ -6260,7 +6270,7 @@ var tableController = ({ data }) => {
6260
6270
  };
6261
6271
 
6262
6272
  // src/widget/advance/table/table-group/controller.ts
6263
- import { useEffect as useEffect14, useMemo as useMemo12, useState as useState14 } from "react";
6273
+ import { useEffect as useEffect14, useMemo as useMemo11, useState as useState14 } from "react";
6264
6274
  import {
6265
6275
  useAppSelector as useAppSelector2,
6266
6276
  selectList
@@ -6288,7 +6298,7 @@ var tableGroupController = (props) => {
6288
6298
  fromEnd: 1
6289
6299
  });
6290
6300
  const domain = row?.__domain;
6291
- const processedData = useMemo12(() => {
6301
+ const processedData = useMemo11(() => {
6292
6302
  const calculateColSpanEmpty = () => {
6293
6303
  const startIndex = columns.findIndex(
6294
6304
  (col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
@@ -6303,7 +6313,7 @@ var tableGroupController = (props) => {
6303
6313
  };
6304
6314
  return calculateColSpanEmpty();
6305
6315
  }, [columns, row]);
6306
- const shouldFetchData = useMemo12(() => {
6316
+ const shouldFetchData = useMemo11(() => {
6307
6317
  return !!isShowGroup;
6308
6318
  }, [isShowGroup]);
6309
6319
  const enabled = shouldFetchData && !!processedData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/widget-logic",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",