@visns-studio/visns-components 5.15.14 → 5.15.15

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/package.json CHANGED
@@ -94,7 +94,7 @@
94
94
  "react-dom": "^17.0.0 || ^18.0.0"
95
95
  },
96
96
  "name": "@visns-studio/visns-components",
97
- "version": "5.15.14",
97
+ "version": "5.15.15",
98
98
  "description": "Various packages to assist in the development of our Custom Applications.",
99
99
  "main": "src/index.js",
100
100
  "files": [
@@ -1047,10 +1047,14 @@ export const renderJsonColumn = ({ column, commonProps }) => {
1047
1047
  ? val
1048
1048
  ? 'Yes'
1049
1049
  : 'No'
1050
- : String(val).substring(
1051
- 0,
1052
- 15
1053
- )
1050
+ : (() => {
1051
+ // Check if column has format = 'phone' and apply phone formatting
1052
+ if (column.format === 'phone') {
1053
+ return formatPhoneNumber(String(val));
1054
+ }
1055
+ // Default string handling
1056
+ return String(val).substring(0, 15);
1057
+ })()
1054
1058
  : 'N/A'}
1055
1059
  </span>
1056
1060
  </div>
@@ -1008,6 +1008,62 @@ function GenericDetail({
1008
1008
 
1009
1009
  const renderDateTime = () => formatDateTimeValue(value);
1010
1010
 
1011
+ const renderPhone = () => {
1012
+ if (!value) return '';
1013
+
1014
+ // Remove all non-digit characters
1015
+ const cleanNumber = value.replace(/\D/g, '');
1016
+
1017
+ // Check if it's an Australian mobile number (starts with 04 and has 10 digits)
1018
+ if (cleanNumber.match(/^04\d{8}$/)) {
1019
+ // Mobile format: 0400 000 000
1020
+ return cleanNumber.replace(/(\d{4})(\d{3})(\d{3})/, '$1 $2 $3');
1021
+ }
1022
+
1023
+ // Check if it's a 1300/1800 number (10 digits starting with 1300 or 1800)
1024
+ if (cleanNumber.match(/^1[38]00\d{6}$/)) {
1025
+ // 1300/1800 format: 1300 000 000
1026
+ return cleanNumber.replace(/(\d{4})(\d{3})(\d{3})/, '$1 $2 $3');
1027
+ }
1028
+
1029
+ // Check if it's an Australian landline number (8 digits with area code, or 10 digits total)
1030
+ if (cleanNumber.match(/^0[2-9]\d{8}$/)) {
1031
+ // Landline format: (02) 0000 0000
1032
+ return cleanNumber.replace(/(\d{2})(\d{4})(\d{4})/, '($1) $2 $3');
1033
+ }
1034
+
1035
+ // If it doesn't match standard Australian patterns, return as is with some basic formatting
1036
+ if (cleanNumber.length >= 8) {
1037
+ // Generic formatting for longer numbers
1038
+ if (cleanNumber.length === 8) {
1039
+ return cleanNumber.replace(/(\d{4})(\d{4})/, '$1 $2');
1040
+ } else if (cleanNumber.length === 9) {
1041
+ return cleanNumber.replace(/(\d{1})(\d{4})(\d{4})/, '$1 $2 $3');
1042
+ } else if (cleanNumber.length === 10) {
1043
+ return cleanNumber.replace(/(\d{2})(\d{4})(\d{4})/, '($1) $2 $3');
1044
+ }
1045
+ }
1046
+
1047
+ // Return original if no formatting pattern matches
1048
+ return value;
1049
+ };
1050
+
1051
+ const renderABN = () => {
1052
+ if (!value) return '';
1053
+
1054
+ // Remove all non-digit characters
1055
+ const cleanABN = value.replace(/\D/g, '');
1056
+
1057
+ // Check if it's a valid 11-digit ABN
1058
+ if (cleanABN.length === 11) {
1059
+ // Format as: 00 000 000 000
1060
+ return cleanABN.replace(/(\d{2})(\d{3})(\d{3})(\d{3})/, '$1 $2 $3 $4');
1061
+ }
1062
+
1063
+ // Return original if not 11 digits
1064
+ return value;
1065
+ };
1066
+
1011
1067
  const renderFile = () => {
1012
1068
  if (value) {
1013
1069
  return (
@@ -1222,9 +1278,15 @@ function GenericDetail({
1222
1278
  return options[0];
1223
1279
  }
1224
1280
  } else {
1225
- return size === 'full' && truncatedValue
1226
- ? parse(`<br /><p>${truncatedValue}</p>`)
1227
- : truncatedValue;
1281
+ // Check if this is a phone type and apply phone formatting
1282
+ let displayValue = truncatedValue;
1283
+ if (type === 'phone' && displayValue) {
1284
+ displayValue = renderPhone();
1285
+ }
1286
+
1287
+ return size === 'full' && displayValue
1288
+ ? parse(`<br /><p>${displayValue}</p>`)
1289
+ : displayValue;
1228
1290
  }
1229
1291
  };
1230
1292
 
@@ -1476,6 +1538,10 @@ function GenericDetail({
1476
1538
  return renderOptions();
1477
1539
  case 'password':
1478
1540
  return renderPassword();
1541
+ case 'phone':
1542
+ return renderPhone();
1543
+ case 'abn':
1544
+ return renderABN();
1479
1545
  case 'relation':
1480
1546
  return renderRelation();
1481
1547
  case 'richtext':