@zeedhi/common 1.89.0 → 1.90.0

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.
@@ -5723,41 +5723,13 @@ FormatterParserProvider.registerFormatter('column_ZdSelect', ({ column, value, r
5723
5723
  if (!Object.keys(currentRow).length)
5724
5724
  return typeof value === 'object' ? '' : value;
5725
5725
  const textColumn = formatterDataText || dataText;
5726
- if (textColumn) {
5727
- if (typeof textColumn === 'string') {
5728
- return currentRow[textColumn] || value;
5729
- }
5730
- const dataTextNames = [];
5731
- const masks = [];
5732
- textColumn.forEach((text) => {
5733
- if (typeof text === 'string') {
5734
- dataTextNames.push(text);
5735
- masks.push('');
5736
- }
5737
- else {
5738
- dataTextNames.push(text.name);
5739
- if (Accessor.isAccessorDefinition(text.mask)) {
5740
- const [controller, accessor] = Accessor.getAccessor(text.mask);
5741
- masks.push(Loader.getInstance(controller)[accessor]);
5742
- }
5743
- else {
5744
- masks.push(text.mask);
5745
- }
5746
- }
5747
- });
5748
- return dataTextNames.reduce((result, columnName, index) => {
5749
- const rowCell = currentRow[columnName];
5750
- if (rowCell !== undefined && rowCell !== null) {
5751
- const separator = index > 0 ? (dataTextSeparator || ' | ') : '';
5752
- const mask = masks[index];
5753
- const maskValue = typeof mask === 'function' ? mask(rowCell) : mask;
5754
- const masked = masks[index] ? Mask.getValueWithMask(rowCell, maskValue) : rowCell;
5755
- return result + separator + masked;
5756
- }
5757
- return result;
5758
- }, '');
5726
+ if (!textColumn)
5727
+ return value;
5728
+ if (typeof textColumn === 'string') {
5729
+ return currentRow[textColumn] || value;
5759
5730
  }
5760
- return value;
5731
+ const formatterFn = FormatterParserProvider.getFormatter('ZdSelect');
5732
+ return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
5761
5733
  });
5762
5734
  FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', ({ column, value, row, componentProps, }) => {
5763
5735
  if (!value || !Array.isArray(value) || value.length === 0)
@@ -9959,29 +9931,11 @@ class SelectMultiple extends Select {
9959
9931
  if (!value || value.length === 0) {
9960
9932
  return [];
9961
9933
  }
9962
- const dataTextNames = [];
9963
- const masks = [];
9964
- this.dataText.forEach((text) => {
9965
- if (typeof text === 'string') {
9966
- dataTextNames.push(text);
9967
- masks.push('');
9968
- }
9969
- else {
9970
- dataTextNames.push(text.name);
9971
- masks.push(text.mask);
9972
- }
9973
- });
9934
+ const selectFormatter = FormatterParserProvider.getFormatter('ZdSelect');
9974
9935
  const formattedValue = value.map((row) => {
9975
9936
  const isDisabled = this.dataDisabled && row[this.dataDisabled];
9976
9937
  const formattedRow = { value: row[this.dataValue], disabled: isDisabled, originalRow: row };
9977
- formattedRow.text = dataTextNames.reduce((result, columnName, index) => {
9978
- if (row[columnName]) {
9979
- const separator = index > 0 ? this.dataTextSeparator : '';
9980
- const masked = masks[index] ? Mask.getValueWithMask(row[columnName], masks[index]) : row[columnName];
9981
- return result + separator + masked;
9982
- }
9983
- return result;
9984
- }, '');
9938
+ formattedRow.text = selectFormatter(row, this);
9985
9939
  return formattedRow;
9986
9940
  });
9987
9941
  return formattedValue;
@@ -5730,41 +5730,13 @@
5730
5730
  if (!Object.keys(currentRow).length)
5731
5731
  return typeof value === 'object' ? '' : value;
5732
5732
  const textColumn = formatterDataText || dataText;
5733
- if (textColumn) {
5734
- if (typeof textColumn === 'string') {
5735
- return currentRow[textColumn] || value;
5736
- }
5737
- const dataTextNames = [];
5738
- const masks = [];
5739
- textColumn.forEach((text) => {
5740
- if (typeof text === 'string') {
5741
- dataTextNames.push(text);
5742
- masks.push('');
5743
- }
5744
- else {
5745
- dataTextNames.push(text.name);
5746
- if (core.Accessor.isAccessorDefinition(text.mask)) {
5747
- const [controller, accessor] = core.Accessor.getAccessor(text.mask);
5748
- masks.push(core.Loader.getInstance(controller)[accessor]);
5749
- }
5750
- else {
5751
- masks.push(text.mask);
5752
- }
5753
- }
5754
- });
5755
- return dataTextNames.reduce((result, columnName, index) => {
5756
- const rowCell = currentRow[columnName];
5757
- if (rowCell !== undefined && rowCell !== null) {
5758
- const separator = index > 0 ? (dataTextSeparator || ' | ') : '';
5759
- const mask = masks[index];
5760
- const maskValue = typeof mask === 'function' ? mask(rowCell) : mask;
5761
- const masked = masks[index] ? core.Mask.getValueWithMask(rowCell, maskValue) : rowCell;
5762
- return result + separator + masked;
5763
- }
5764
- return result;
5765
- }, '');
5733
+ if (!textColumn)
5734
+ return value;
5735
+ if (typeof textColumn === 'string') {
5736
+ return currentRow[textColumn] || value;
5766
5737
  }
5767
- return value;
5738
+ const formatterFn = core.FormatterParserProvider.getFormatter('ZdSelect');
5739
+ return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
5768
5740
  });
5769
5741
  core.FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', ({ column, value, row, componentProps, }) => {
5770
5742
  if (!value || !Array.isArray(value) || value.length === 0)
@@ -9966,29 +9938,11 @@
9966
9938
  if (!value || value.length === 0) {
9967
9939
  return [];
9968
9940
  }
9969
- const dataTextNames = [];
9970
- const masks = [];
9971
- this.dataText.forEach((text) => {
9972
- if (typeof text === 'string') {
9973
- dataTextNames.push(text);
9974
- masks.push('');
9975
- }
9976
- else {
9977
- dataTextNames.push(text.name);
9978
- masks.push(text.mask);
9979
- }
9980
- });
9941
+ const selectFormatter = core.FormatterParserProvider.getFormatter('ZdSelect');
9981
9942
  const formattedValue = value.map((row) => {
9982
9943
  const isDisabled = this.dataDisabled && row[this.dataDisabled];
9983
9944
  const formattedRow = { value: row[this.dataValue], disabled: isDisabled, originalRow: row };
9984
- formattedRow.text = dataTextNames.reduce((result, columnName, index) => {
9985
- if (row[columnName]) {
9986
- const separator = index > 0 ? this.dataTextSeparator : '';
9987
- const masked = masks[index] ? core.Mask.getValueWithMask(row[columnName], masks[index]) : row[columnName];
9988
- return result + separator + masked;
9989
- }
9990
- return result;
9991
- }, '');
9945
+ formattedRow.text = selectFormatter(row, this);
9992
9946
  return formattedRow;
9993
9947
  });
9994
9948
  return formattedValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.89.0",
3
+ "version": "1.90.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "338bd948c7d990ff8ca1c26470b5da2220f10730"
46
+ "gitHead": "87d5d71b724457ce1332c43f6b0809d02d27d1b0"
47
47
  }
@@ -26,10 +26,6 @@ export declare class GridColumn extends Column implements IGridColumn {
26
26
  events?: import("..").IComponentEvents<import("@zeedhi/core").IEventParam<any>> | undefined;
27
27
  directives?: import("..").IComponentDirectives | undefined;
28
28
  isVisible?: string | boolean | undefined;
29
- /**
30
- * Creates a new Grid Column.
31
- * @param props Grid column properties
32
- */
33
29
  dark?: boolean | undefined;
34
30
  light?: boolean | undefined;
35
31
  keyMap?: import("@zeedhi/core").IKeyMap<import("@zeedhi/core").IEventParam<any>> | undefined;