@visns-studio/visns-components 5.15.15 → 5.15.17

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/README.md CHANGED
@@ -13,6 +13,7 @@ VISNS Components is a React-based UI component library that provides a set of re
13
13
 
14
14
  ### Latest Enhancements
15
15
 
16
+ - **Phone and ABN Formatting**: Added specialized formatting for Australian phone numbers and ABNs across DataGrid, GenericDetail, and JSON fields with format support
16
17
  - **CameraPlacement Legacy Import**: Added comprehensive legacy JSON file import functionality with support for multiple data formats, automatic image loading, and seamless database integration
17
18
  - **CameraPlacement Module**: Enhanced interactive camera placement tool with improved UI consistency, better icon visibility, drag-and-drop image upload, professional export capabilities, and complete Verkada database integration
18
19
  - **Complete StandardModal Migration**: All components now use StandardModal instead of reactjs-popup for consistent modal behavior across the entire library
@@ -586,6 +587,8 @@ The DataGrid component utilizes a modular column renderer system with 28 special
586
587
  - `json` - JSON data extraction and display
587
588
  - `number` - Numeric values
588
589
  - `option` - Option mapping with placeholders
590
+ - `phone` - Phone number formatting for Australian numbers
591
+ - `abn` - Australian Business Number formatting
589
592
  - `placeholder` - Static placeholder text
590
593
  - `age` - Age calculation from dates
591
594
  - `coding` - Custom coding logic
@@ -677,6 +680,72 @@ The `html5_date` column type provides native HTML5 date picker functionality in
677
680
  }
678
681
  ```
679
682
 
683
+ #### Phone and ABN Formatting
684
+
685
+ The DataGrid and GenericDetail components include specialized formatting for Australian phone numbers and ABNs (Australian Business Numbers).
686
+
687
+ ##### Phone Number Formatting
688
+
689
+ The `phone` column type automatically formats phone numbers according to Australian standards:
690
+
691
+ **Supported Formats:**
692
+ - **Mobile Numbers**: `0400 000 000` (04XX XXX XXX)
693
+ - **1300/1800 Numbers**: `1300 000 000` (1300 XXX XXX)
694
+ - **Landline Numbers**: `(02) 0000 0000` ((0X) XXXX XXXX)
695
+ - **Generic Formatting**: Applied to other number patterns
696
+ - **Fallback**: Returns original value if no pattern matches
697
+
698
+ **Configuration Examples:**
699
+
700
+ DataGrid:
701
+ ```jsx
702
+ {
703
+ id: 'phone',
704
+ label: 'Phone Number',
705
+ type: 'phone',
706
+ width: '15%'
707
+ }
708
+ ```
709
+
710
+ GenericDetail:
711
+ ```jsx
712
+ {
713
+ id: 'phone',
714
+ label: 'Phone Number',
715
+ type: 'phone',
716
+ relation: ['company'] // Also works with relationship fields
717
+ }
718
+ ```
719
+
720
+ JSON Fields with Format:
721
+ ```jsx
722
+ {
723
+ id: 'contact_data',
724
+ label: 'Contact',
725
+ type: 'json',
726
+ jsonData: 'phone',
727
+ format: 'phone' // Applies phone formatting to JSON field values
728
+ }
729
+ ```
730
+
731
+ ##### ABN Formatting
732
+
733
+ The `abn` column type formats Australian Business Numbers:
734
+
735
+ **Format**: `00 000 000 000` (XX XXX XXX XXX)
736
+ - Validates 11-digit ABNs
737
+ - Returns original value if not valid format
738
+
739
+ **Configuration Example:**
740
+ ```jsx
741
+ {
742
+ id: 'abn',
743
+ label: 'ABN',
744
+ type: 'abn',
745
+ width: '15%'
746
+ }
747
+ ```
748
+
680
749
  #### Intelligent Relationship Sorting
681
750
 
682
751
  The DataGrid component includes intelligent sorting capabilities that automatically detect and enable sorting for relationship and JSON fields. This feature works seamlessly with the backend `HasRelationshipSorting` trait.
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "@fontsource/barlow": "^5.2.6",
8
8
  "@inovua/reactdatagrid-community": "^5.10.2",
9
9
  "@inovua/reactdatagrid-enterprise": "^5.10.2",
10
- "@mapbox/mapbox-gl-geocoder": "^5.1.0",
10
+ "@mapbox/mapbox-gl-geocoder": "^5.1.1",
11
11
  "@nivo/bar": "^0.99.0",
12
12
  "@nivo/core": "^0.99.0",
13
13
  "@nivo/line": "^0.99.0",
@@ -24,7 +24,7 @@
24
24
  "array-move": "^4.0.0",
25
25
  "awesome-debounce-promise": "^2.1.0",
26
26
  "browser-image-compression": "^2.0.2",
27
- "dayjs": "^1.11.13",
27
+ "dayjs": "^1.11.14",
28
28
  "fabric": "^6.7.1",
29
29
  "file-saver": "^2.0.5",
30
30
  "framer-motion": "^12.23.12",
@@ -32,7 +32,7 @@
32
32
  "html2canvas": "^1.4.1",
33
33
  "lodash": "^4.17.21",
34
34
  "lodash.debounce": "^4.0.8",
35
- "lucide-react": "^0.541.0",
35
+ "lucide-react": "^0.542.0",
36
36
  "mapbox-gl": "^3.14.0",
37
37
  "moment": "^2.30.1",
38
38
  "motion": "^12.23.12",
@@ -64,7 +64,7 @@
64
64
  "reactjs-popup": "^2.0.6",
65
65
  "style-loader": "^4.0.0",
66
66
  "swapy": "^1.0.5",
67
- "sweetalert2": "^11.22.4",
67
+ "sweetalert2": "^11.22.5",
68
68
  "tesseract.js": "^6.0.1",
69
69
  "truncate": "^3.0.0",
70
70
  "uuid": "^11.1.0",
@@ -86,7 +86,7 @@
86
86
  "mini-css-extract-plugin": "^2.9.4",
87
87
  "react": "^18.3.1",
88
88
  "react-dom": "^18.3.1",
89
- "sass": "^1.90.0",
89
+ "sass": "^1.91.0",
90
90
  "sass-loader": "^16.0.5"
91
91
  },
92
92
  "peerDependencies": {
@@ -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.15",
97
+ "version": "5.15.17",
98
98
  "description": "Various packages to assist in the development of our Custom Applications.",
99
99
  "main": "src/index.js",
100
100
  "files": [
@@ -2412,6 +2412,22 @@ const DataGrid = forwardRef(
2412
2412
  }
2413
2413
  }
2414
2414
 
2415
+ // Check function-based condition if it exists
2416
+ if (allow && s.condition && typeof s.condition === 'function') {
2417
+ try {
2418
+ console.log('🔍 DataGrid: Evaluating condition for setting:', s.id, 'with data:', d);
2419
+ const conditionResult = s.condition(d);
2420
+ console.log('🔍 DataGrid: Condition result:', conditionResult, 'for setting:', s.id);
2421
+ if (!conditionResult) {
2422
+ allow = false;
2423
+ console.log('🔍 DataGrid: Setting blocked by condition:', s.id);
2424
+ }
2425
+ } catch (error) {
2426
+ console.warn('🔍 DataGrid: Condition function error for setting:', s.id, error);
2427
+ allow = false;
2428
+ }
2429
+ }
2430
+
2415
2431
  if (allow) {
2416
2432
  switch (s.id) {
2417
2433
  case 'activate':
@@ -2456,6 +2472,8 @@ const DataGrid = forwardRef(
2456
2472
  return getIconComponent(RotateCcw);
2457
2473
  case 'update':
2458
2474
  return getIconComponent(Edit);
2475
+ case 'romComplete':
2476
+ return getIconComponent(CheckCircle);
2459
2477
  default:
2460
2478
  return null;
2461
2479
  }
@@ -1513,10 +1513,49 @@ const GenericReportImproved = ({
1513
1513
 
1514
1514
  // Start again function to reset wizard to home
1515
1515
  const startAgain = () => {
1516
- // Reset all state
1516
+ console.log('🔄 [DEBUG] StartAgain called - BEFORE reset:', {
1517
+ selectedTemplate: selectedTemplate?.id,
1518
+ customUrls: customUrls,
1519
+ groupingConfig: groupingConfig,
1520
+ });
1521
+
1522
+ // Reset wizard state
1523
+ setCurrentWizardStep(0);
1524
+ setShowTemplates(true);
1525
+ setShowBusinessTemplates(false);
1526
+
1527
+ // CRITICAL FIX: Reset template selection
1528
+ setSelectedTemplate(null);
1529
+
1530
+ // Reset database schema state
1517
1531
  setSelectedTable(null);
1532
+ setTableColumns([]);
1533
+ setAvailableTables([]);
1534
+ setDetectedJoins({});
1535
+ setIsLoadingDetectedJoins({});
1536
+
1537
+ // Reset report configuration
1518
1538
  setSelectedColumns([]);
1519
1539
  setJoins([]);
1540
+ setReportName('');
1541
+ setIsPublic(false);
1542
+ setLoadedReportId(null);
1543
+
1544
+ // Reset manual relationship state
1545
+ setShowManualJoinForm(false);
1546
+ setManualJoin({
1547
+ sourceTable: '',
1548
+ targetTable: '',
1549
+ sourceColumn: '',
1550
+ targetColumn: '',
1551
+ joinType: 'INNER JOIN',
1552
+ });
1553
+ setManualJoinColumns({
1554
+ source: [],
1555
+ target: [],
1556
+ });
1557
+
1558
+ // Reset sorting and filtering
1520
1559
  setFilterCriteria({
1521
1560
  operator: 'AND',
1522
1561
  groups: [
@@ -1529,16 +1568,68 @@ const GenericReportImproved = ({
1529
1568
  setSortCriteria([]);
1530
1569
  setShowSortingSection(false);
1531
1570
  setShowFilteringSection(false);
1571
+ setShowSelectedFields(false);
1572
+
1573
+ // CRITICAL FIX: Reset grouping configuration
1574
+ setGroupingConfig({
1575
+ enabled: false,
1576
+ groupByField: '',
1577
+ groupDisplayName: '',
1578
+ sortBy: '',
1579
+ sortDirection: 'asc',
1580
+ rowsPerGroup: 10,
1581
+ showEmptyRows: false,
1582
+ showGroupTotals: false,
1583
+ expandable: true,
1584
+ groupHeaderStyle: 'primary',
1585
+ emptyRowStyle: 'light',
1586
+ });
1587
+
1588
+ // CRITICAL FIX: Reset custom URLs
1589
+ setCustomUrls({
1590
+ executeUrl: '',
1591
+ exportUrl: '',
1592
+ });
1593
+
1594
+ // Reset report execution and preview
1532
1595
  setPreviewData([]);
1596
+ setGroupedData(null);
1533
1597
  setGridColumns([]);
1534
- setReportName('');
1535
- setIsPublic(false);
1536
- setLoadedReportId(null); // Reset loaded report ID
1537
- setCurrentWizardStep(0);
1538
- setShowTemplates(true);
1539
- setTableColumns([]);
1540
- setAvailableTables([]);
1541
- setHasAutoExecuted(false); // Reset auto-execute flag
1598
+ setTotalResults(0);
1599
+ setHasAutoExecuted(false);
1600
+
1601
+ // Reset pagination
1602
+ setCurrentPage(1);
1603
+ setPageSize(10);
1604
+ setTotalPages(0);
1605
+ setTotalCount(0);
1606
+
1607
+ // Reset calculated fields
1608
+ setCustomCalculatedFields([]);
1609
+ setCalculatedFieldForm({
1610
+ displayName: '',
1611
+ formula: '',
1612
+ type: 'decimal',
1613
+ });
1614
+ setShowCalculatedFieldModal(false);
1615
+
1616
+ // Reset unique fields and exclusions
1617
+ setUniqueFieldConfig({
1618
+ enabled: false,
1619
+ selectedField: '',
1620
+ });
1621
+ setExcludedRows(new Set());
1622
+ setShowRowExclusionModal(false);
1623
+ setExportType('regular');
1624
+
1625
+ // Reset UI state
1626
+ setShowHiddenFields(false);
1627
+
1628
+ console.log('✅ [DEBUG] StartAgain completed - AFTER reset:', {
1629
+ selectedTemplate: null,
1630
+ customUrls: { executeUrl: '', exportUrl: '' },
1631
+ groupingConfig: { enabled: false },
1632
+ });
1542
1633
 
1543
1634
  toast.info(
1544
1635
  'Report builder reset. You can start creating a new report.'
@@ -2336,6 +2427,13 @@ const GenericReportImproved = ({
2336
2427
  }
2337
2428
  } else {
2338
2429
  // For predefined templates, use the existing approach
2430
+ console.log('🚨 [DEBUG] Using predefined template approach:', {
2431
+ selectedTemplate: selectedTemplate,
2432
+ selectedTemplateId: selectedTemplate?.id,
2433
+ fallbackId: 'utilization_planning',
2434
+ finalTemplateId: selectedTemplate?.id || 'utilization_planning',
2435
+ });
2436
+
2339
2437
  payload = {
2340
2438
  template_id:
2341
2439
  selectedTemplate?.id || 'utilization_planning',
@@ -2756,7 +2854,7 @@ const GenericReportImproved = ({
2756
2854
  lowerKey.includes('disabled')
2757
2855
  ) {
2758
2856
  // Check if values look like boolean/status values
2759
- const sampleValues = firstPageResult.data
2857
+ const sampleValues = dataToProcess
2760
2858
  .slice(0, 5)
2761
2859
  .map((row) => row[key]);
2762
2860
  const hasStatusValues = sampleValues.some(
@@ -2814,7 +2912,15 @@ const GenericReportImproved = ({
2814
2912
  setGridColumns(dynamicColumns);
2815
2913
  } else {
2816
2914
  // Fallback to selected columns if no data
2817
- const columns = selectedColumns.map((col) => {
2915
+ console.log('🔧 [DEBUG] Creating fallback columns from selectedColumns:', selectedColumns);
2916
+ if (!Array.isArray(selectedColumns) || selectedColumns.length === 0) {
2917
+ console.warn('⚠️ selectedColumns is not a valid array:', selectedColumns);
2918
+ setGridColumns([]);
2919
+ return;
2920
+ }
2921
+
2922
+ const columns = selectedColumns.map((col, index) => {
2923
+ try {
2818
2924
  // Find column type from table columns with enhanced detection
2819
2925
  let columnType = 'varchar';
2820
2926
  const tableColumn = tableColumns.find(
@@ -2852,37 +2958,52 @@ const GenericReportImproved = ({
2852
2958
 
2853
2959
  return {
2854
2960
  name:
2855
- col.displayName || `${col.table}.${col.column}`,
2856
- header: col.displayName || formatName(col.column),
2961
+ col.displayName || `${col.table || 'unknown'}.${col.column}`,
2962
+ header: col.displayName || formatName(col.column || 'Unknown Column'),
2857
2963
  defaultFlex: 1,
2858
2964
  minWidth: 100,
2859
2965
  render: ({ value }) => {
2860
- const formattedValue = formatSmartValue(
2861
- value,
2862
- col.column,
2863
- columnType
2864
- );
2865
-
2866
- // For JSON content, wrap in a container that allows full height expansion
2867
- if (isJsonValue(value)) {
2868
- return (
2869
- <div
2870
- style={{
2871
- whiteSpace: 'normal',
2872
- wordWrap: 'break-word',
2873
- lineHeight: '1.4',
2874
- padding: '4px 0',
2875
- width: '100%',
2876
- }}
2877
- >
2878
- {formattedValue}
2879
- </div>
2966
+ try {
2967
+ const formattedValue = formatSmartValue(
2968
+ value,
2969
+ col.column,
2970
+ columnType
2880
2971
  );
2881
- }
2882
2972
 
2883
- return formattedValue;
2973
+ // For JSON content, wrap in a container that allows full height expansion
2974
+ if (isJsonValue(value)) {
2975
+ return (
2976
+ <div
2977
+ style={{
2978
+ whiteSpace: 'normal',
2979
+ wordWrap: 'break-word',
2980
+ lineHeight: '1.4',
2981
+ padding: '4px 0',
2982
+ width: '100%',
2983
+ }}
2984
+ >
2985
+ {formattedValue}
2986
+ </div>
2987
+ );
2988
+ }
2989
+
2990
+ return formattedValue;
2991
+ } catch (renderError) {
2992
+ console.warn('🚨 Cell render error:', renderError, 'for value:', value);
2993
+ return String(value || '');
2994
+ }
2884
2995
  },
2885
2996
  };
2997
+ } catch (colError) {
2998
+ console.warn('🚨 Column mapping error:', colError, 'for column:', col);
2999
+ return {
3000
+ name: `error_col_${index}`,
3001
+ header: 'Error Column',
3002
+ defaultFlex: 1,
3003
+ minWidth: 100,
3004
+ render: () => 'Error',
3005
+ };
3006
+ }
2886
3007
  });
2887
3008
  setGridColumns(columns);
2888
3009
  }
@@ -2899,8 +3020,24 @@ const GenericReportImproved = ({
2899
3020
  typeof fetchedDataCount
2900
3021
  );
2901
3022
  } catch (error) {
2902
- toast.error('Failed to execute report');
3023
+ console.group('🚨 [ERROR] executeReport failed');
2903
3024
  console.error('Error executing report:', error);
3025
+ console.log('Error name:', error.name);
3026
+ console.log('Error message:', error.message);
3027
+ console.log('Error stack:', error.stack);
3028
+ console.log('Current state at error:', {
3029
+ selectedTable,
3030
+ selectedColumns: selectedColumns.length,
3031
+ hasGrouping: selectedTemplate?.grouping?.enabled || groupingConfig.enabled,
3032
+ currentPage,
3033
+ pageSize,
3034
+ });
3035
+ console.groupEnd();
3036
+
3037
+ // Only show toast error for actual failures, not for successful pagination
3038
+ if (!error.message?.includes('successful')) {
3039
+ toast.error(`Failed to execute report: ${error.message || 'Unknown error'}`);
3040
+ }
2904
3041
  } finally {
2905
3042
  setIsLoading(false);
2906
3043
  }
@@ -15,6 +15,11 @@ const interpretBooleanValue = (value, column) => {
15
15
 
16
16
  if (!isTrue && !isFalse) return value; // Return original if not clearly boolean
17
17
 
18
+ // Check for custom boolean labels first
19
+ if (column.booleanLabels && typeof column.booleanLabels === 'object') {
20
+ return isTrue ? column.booleanLabels.true : column.booleanLabels.false;
21
+ }
22
+
18
23
  // Contextual interpretations based on column name patterns
19
24
  const interpretations = {
20
25
  // Status/State patterns