@fctc/widget-logic 2.7.2 → 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/index.js CHANGED
@@ -5497,8 +5497,7 @@ var many2manyFieldController = (props) => {
5497
5497
  tab,
5498
5498
  setSelectedRowKeys: setSelectedRowKeys2,
5499
5499
  groupByDomain,
5500
- enabled: enabledCallAPI,
5501
- actionData
5500
+ enabled: enabledCallAPI
5502
5501
  } = props;
5503
5502
  const { env } = (0, provider_exports.useEnv)();
5504
5503
  const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
@@ -5522,31 +5521,14 @@ var many2manyFieldController = (props) => {
5522
5521
  viewParams,
5523
5522
  enabled: enabledCallAPI
5524
5523
  });
5525
- const baseModel = (0, import_react17.useMemo)(
5526
- () => ({
5527
- name: String(relation),
5528
- view: viewResponse || {},
5529
- actContext: contextObject,
5530
- fields: [
5531
- ...Object.values(viewResponse?.views?.list?.fields ?? {}),
5532
- ...tab?.fields ? tab.fields : []
5533
- ]
5534
- }),
5535
- [relation, viewResponse]
5536
- );
5537
- const initModel = (0, import_hooks2.useModel)();
5538
- const modelInstance = (0, import_react17.useMemo)(() => {
5539
- if (viewResponse) {
5540
- return initModel.initModel(baseModel);
5541
- }
5542
- return null;
5543
- }, [baseModel, viewResponse]);
5544
- const specification = (0, import_react17.useMemo)(() => {
5545
- if (modelInstance) {
5546
- return modelInstance.getSpecification();
5547
- }
5548
- return null;
5549
- }, [modelInstance]);
5524
+ const { specification } = useGetSpecification({
5525
+ model: String(relation),
5526
+ viewData: viewResponse || {},
5527
+ fields: [
5528
+ ...Object.values(viewResponse?.views?.list?.fields ?? {}),
5529
+ ...tab?.fields ? tab.fields : []
5530
+ ]
5531
+ });
5550
5532
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
5551
5533
  const optionsObject = tab?.options ? (0, import_utils9.evalJSONContext)(tab?.options) : (options ? (0, import_utils9.evalJSONContext)(options) : {}) || {};
5552
5534
  const fetchData = async () => {
package/dist/index.mjs CHANGED
@@ -5567,7 +5567,7 @@ var many2oneButtonController = (props) => {
5567
5567
  };
5568
5568
 
5569
5569
  // src/widget/basic/many2many-field/controller.ts
5570
- import { useEffect as useEffect11, useMemo as useMemo9, useState as useState8 } from "react";
5570
+ import { useEffect as useEffect11, useState as useState8 } from "react";
5571
5571
  import {
5572
5572
  evalJSONContext as evalJSONContext4,
5573
5573
  evalJSONDomain as evalJSONDomain4,
@@ -5582,8 +5582,7 @@ var many2manyFieldController = (props) => {
5582
5582
  tab,
5583
5583
  setSelectedRowKeys: setSelectedRowKeys2,
5584
5584
  groupByDomain,
5585
- enabled: enabledCallAPI,
5586
- actionData
5585
+ enabled: enabledCallAPI
5587
5586
  } = props;
5588
5587
  const { env } = (0, provider_exports.useEnv)();
5589
5588
  const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
@@ -5607,31 +5606,14 @@ var many2manyFieldController = (props) => {
5607
5606
  viewParams,
5608
5607
  enabled: enabledCallAPI
5609
5608
  });
5610
- const baseModel = useMemo9(
5611
- () => ({
5612
- name: String(relation),
5613
- view: viewResponse || {},
5614
- actContext: contextObject,
5615
- fields: [
5616
- ...Object.values(viewResponse?.views?.list?.fields ?? {}),
5617
- ...tab?.fields ? tab.fields : []
5618
- ]
5619
- }),
5620
- [relation, viewResponse]
5621
- );
5622
- const initModel = useModel();
5623
- const modelInstance = useMemo9(() => {
5624
- if (viewResponse) {
5625
- return initModel.initModel(baseModel);
5626
- }
5627
- return null;
5628
- }, [baseModel, viewResponse]);
5629
- const specification = useMemo9(() => {
5630
- if (modelInstance) {
5631
- return modelInstance.getSpecification();
5632
- }
5633
- return null;
5634
- }, [modelInstance]);
5609
+ const { specification } = useGetSpecification({
5610
+ model: String(relation),
5611
+ viewData: viewResponse || {},
5612
+ fields: [
5613
+ ...Object.values(viewResponse?.views?.list?.fields ?? {}),
5614
+ ...tab?.fields ? tab.fields : []
5615
+ ]
5616
+ });
5635
5617
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
5636
5618
  const optionsObject = tab?.options ? evalJSONContext4(tab?.options) : (options ? evalJSONContext4(options) : {}) || {};
5637
5619
  const fetchData = async () => {
@@ -5722,7 +5704,7 @@ var many2manyFieldController = (props) => {
5722
5704
  };
5723
5705
 
5724
5706
  // src/widget/basic/many2many-tags-field/controller.ts
5725
- import { useMemo as useMemo10 } from "react";
5707
+ import { useMemo as useMemo9 } from "react";
5726
5708
  import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
5727
5709
  import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
5728
5710
  var many2manyTagsController = (props) => {
@@ -5740,7 +5722,7 @@ var many2manyTagsController = (props) => {
5740
5722
  const { env } = (0, provider_exports.useEnv)();
5741
5723
  const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
5742
5724
  const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
5743
- const domainObject = useMemo10(
5725
+ const domainObject = useMemo9(
5744
5726
  () => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
5745
5727
  [domain, formValues]
5746
5728
  );
@@ -6972,7 +6954,7 @@ var binaryFieldController = (props) => {
6972
6954
  };
6973
6955
 
6974
6956
  // src/widget/advance/table/table-head/controller.ts
6975
- import { useMemo as useMemo11, useRef as useRef5 } from "react";
6957
+ import { useMemo as useMemo10, useRef as useRef5 } from "react";
6976
6958
  var tableHeadController = (props) => {
6977
6959
  const {
6978
6960
  typeTable,
@@ -6985,19 +6967,19 @@ var tableHeadController = (props) => {
6985
6967
  const { rowIds: recordIds } = useGetRowIds(tableRef);
6986
6968
  const selectedRowKeysRef = useRef5(recordIds);
6987
6969
  const isGroupTable = typeTable === "group";
6988
- const recordsCheckedGroup = useMemo11(() => {
6970
+ const recordsCheckedGroup = useMemo10(() => {
6989
6971
  if (!rows || !groupByList) return 0;
6990
6972
  const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
6991
6973
  return countSum(rows, groupBy);
6992
6974
  }, [rows, groupByList]);
6993
- const isAllGroupChecked = useMemo11(() => {
6975
+ const isAllGroupChecked = useMemo10(() => {
6994
6976
  if (!isGroupTable || !selectedRowKeys?.length) return false;
6995
6977
  const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
6996
6978
  const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
6997
6979
  const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
6998
6980
  return allGroupsSelected || allRecordsSelected;
6999
6981
  }, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
7000
- const isAllNormalChecked = useMemo11(() => {
6982
+ const isAllNormalChecked = useMemo10(() => {
7001
6983
  if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
7002
6984
  return selectedRowKeys.length === rows.length && selectedRowKeys.every(
7003
6985
  (id) => rows.some((record) => record.id === id)
@@ -7127,7 +7109,7 @@ var tableController = ({ data }) => {
7127
7109
  };
7128
7110
 
7129
7111
  // src/widget/advance/table/table-group/controller.ts
7130
- import { useEffect as useEffect14, useMemo as useMemo12, useState as useState14 } from "react";
7112
+ import { useEffect as useEffect14, useMemo as useMemo11, useState as useState14 } from "react";
7131
7113
  import {
7132
7114
  useAppSelector as useAppSelector2,
7133
7115
  selectList
@@ -7155,7 +7137,7 @@ var tableGroupController = (props) => {
7155
7137
  fromEnd: 1
7156
7138
  });
7157
7139
  const domain = row?.__domain;
7158
- const processedData = useMemo12(() => {
7140
+ const processedData = useMemo11(() => {
7159
7141
  const calculateColSpanEmpty = () => {
7160
7142
  const startIndex = columns.findIndex(
7161
7143
  (col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
@@ -7170,7 +7152,7 @@ var tableGroupController = (props) => {
7170
7152
  };
7171
7153
  return calculateColSpanEmpty();
7172
7154
  }, [columns, row]);
7173
- const shouldFetchData = useMemo12(() => {
7155
+ const shouldFetchData = useMemo11(() => {
7174
7156
  return !!isShowGroup;
7175
7157
  }, [isShowGroup]);
7176
7158
  const enabled = shouldFetchData && !!processedData;
package/dist/widget.d.mts CHANGED
@@ -66,7 +66,6 @@ interface IMany2ManyControllerProps extends IInputFieldProps {
66
66
  groupByDomain: any;
67
67
  options: any;
68
68
  enabled: boolean;
69
- actionData: any;
70
69
  viewData: any;
71
70
  }
72
71
 
package/dist/widget.d.ts CHANGED
@@ -66,7 +66,6 @@ interface IMany2ManyControllerProps extends IInputFieldProps {
66
66
  groupByDomain: any;
67
67
  options: any;
68
68
  enabled: boolean;
69
- actionData: any;
70
69
  viewData: any;
71
70
  }
72
71
 
package/dist/widget.js CHANGED
@@ -4341,6 +4341,34 @@ var import_react10 = require("react");
4341
4341
 
4342
4342
  // src/hooks/core/use-get-specification.ts
4343
4343
  var import_react11 = require("react");
4344
+ var useGetSpecification = ({
4345
+ model,
4346
+ viewData,
4347
+ fields
4348
+ }) => {
4349
+ const baseModel = (0, import_react11.useMemo)(
4350
+ () => ({
4351
+ name: String(model),
4352
+ view: viewData || {},
4353
+ fields
4354
+ }),
4355
+ [model, viewData]
4356
+ );
4357
+ const initModel = (0, import_hooks3.useModel)();
4358
+ const modelInstance = (0, import_react11.useMemo)(() => {
4359
+ if (viewData) {
4360
+ return initModel.initModel(baseModel);
4361
+ }
4362
+ return null;
4363
+ }, [baseModel, viewData]);
4364
+ const specification = (0, import_react11.useMemo)(() => {
4365
+ if (modelInstance) {
4366
+ return modelInstance.getSpecification();
4367
+ }
4368
+ return null;
4369
+ }, [modelInstance]);
4370
+ return { specification };
4371
+ };
4344
4372
 
4345
4373
  // src/hooks/core/use-list-data.ts
4346
4374
  var import_react15 = require("react");
@@ -4653,8 +4681,7 @@ var many2manyFieldController = (props) => {
4653
4681
  tab,
4654
4682
  setSelectedRowKeys: setSelectedRowKeys2,
4655
4683
  groupByDomain,
4656
- enabled: enabledCallAPI,
4657
- actionData
4684
+ enabled: enabledCallAPI
4658
4685
  } = props;
4659
4686
  const { env } = (0, provider_exports.useEnv)();
4660
4687
  const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
@@ -4678,31 +4705,14 @@ var many2manyFieldController = (props) => {
4678
4705
  viewParams,
4679
4706
  enabled: enabledCallAPI
4680
4707
  });
4681
- const baseModel = (0, import_react17.useMemo)(
4682
- () => ({
4683
- name: String(relation),
4684
- view: viewResponse || {},
4685
- actContext: contextObject,
4686
- fields: [
4687
- ...Object.values(viewResponse?.views?.list?.fields ?? {}),
4688
- ...tab?.fields ? tab.fields : []
4689
- ]
4690
- }),
4691
- [relation, viewResponse]
4692
- );
4693
- const initModel = (0, import_hooks3.useModel)();
4694
- const modelInstance = (0, import_react17.useMemo)(() => {
4695
- if (viewResponse) {
4696
- return initModel.initModel(baseModel);
4697
- }
4698
- return null;
4699
- }, [baseModel, viewResponse]);
4700
- const specification = (0, import_react17.useMemo)(() => {
4701
- if (modelInstance) {
4702
- return modelInstance.getSpecification();
4703
- }
4704
- return null;
4705
- }, [modelInstance]);
4708
+ const { specification } = useGetSpecification({
4709
+ model: String(relation),
4710
+ viewData: viewResponse || {},
4711
+ fields: [
4712
+ ...Object.values(viewResponse?.views?.list?.fields ?? {}),
4713
+ ...tab?.fields ? tab.fields : []
4714
+ ]
4715
+ });
4706
4716
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
4707
4717
  const optionsObject = tab?.options ? (0, import_utils9.evalJSONContext)(tab?.options) : (options ? (0, import_utils9.evalJSONContext)(options) : {}) || {};
4708
4718
  const fetchData = async () => {
package/dist/widget.mjs CHANGED
@@ -4394,6 +4394,34 @@ 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";
@@ -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.2",
3
+ "version": "2.7.3",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",