@visns-studio/visns-components 5.10.7 → 5.10.9
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 +4 -4
- package/src/components/crm/Form.jsx +24 -2
- package/src/components/crm/generic/GenericReport.jsx +4689 -5622
- package/src/components/crm/generic/styles/GenericReport.module.scss +2191 -1568
- package/src/examples/TableWidthConfigExample.jsx +171 -0
- package/src/index.js +0 -2
- package/src/components/crm/generic/GenericReportImproved.jsx +0 -5280
- package/src/components/crm/generic/styles/GenericReportImproved.module.scss +0 -2631
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Form from '../components/crm/Form';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Example demonstrating table width configuration in Form component
|
|
6
|
+
*
|
|
7
|
+
* This example shows how to use the "width" property in the JSON config
|
|
8
|
+
* to control the table container width when displaying return data.
|
|
9
|
+
*/
|
|
10
|
+
const TableWidthConfigExample = () => {
|
|
11
|
+
const [selectedWidth, setSelectedWidth] = useState('1500');
|
|
12
|
+
|
|
13
|
+
// Base form settings that can be modified
|
|
14
|
+
const getFormSettings = (width) => ({
|
|
15
|
+
primaryKey: 'id',
|
|
16
|
+
url: '/api/example',
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
id: 'name',
|
|
20
|
+
label: 'Name',
|
|
21
|
+
type: 'text',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'email',
|
|
26
|
+
label: 'Email',
|
|
27
|
+
type: 'email',
|
|
28
|
+
required: true
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
save: {
|
|
32
|
+
return: {
|
|
33
|
+
type: 'table',
|
|
34
|
+
width: width, // This controls the table container width
|
|
35
|
+
param: 'data',
|
|
36
|
+
props: {
|
|
37
|
+
// Optional table props like grouping
|
|
38
|
+
// groupBy: ['status']
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const widthOptions = [
|
|
45
|
+
{ value: '', label: 'Default (100%)', description: 'Uses full available width' },
|
|
46
|
+
{ value: '800', label: '800px', description: 'Compact table for smaller datasets' },
|
|
47
|
+
{ value: '1200', label: '1200px', description: 'Standard wide table' },
|
|
48
|
+
{ value: '1500', label: '1500px', description: 'Extra wide table for many columns' },
|
|
49
|
+
{ value: '2000', label: '2000px', description: 'Very wide table for detailed data' }
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div style={{ padding: '20px' }}>
|
|
54
|
+
<h2>Table Width Configuration Example</h2>
|
|
55
|
+
|
|
56
|
+
<div style={{
|
|
57
|
+
marginBottom: '30px',
|
|
58
|
+
padding: '20px',
|
|
59
|
+
backgroundColor: '#f8fafc',
|
|
60
|
+
borderRadius: '8px',
|
|
61
|
+
border: '1px solid #e2e8f0'
|
|
62
|
+
}}>
|
|
63
|
+
<h3>Configuration:</h3>
|
|
64
|
+
<div style={{ marginBottom: '15px' }}>
|
|
65
|
+
<label style={{ fontWeight: 'bold', marginRight: '10px' }}>
|
|
66
|
+
Table Width:
|
|
67
|
+
</label>
|
|
68
|
+
<select
|
|
69
|
+
value={selectedWidth}
|
|
70
|
+
onChange={(e) => setSelectedWidth(e.target.value)}
|
|
71
|
+
style={{
|
|
72
|
+
padding: '8px 12px',
|
|
73
|
+
borderRadius: '4px',
|
|
74
|
+
border: '1px solid #d1d5db',
|
|
75
|
+
marginRight: '15px'
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{widthOptions.map(option => (
|
|
79
|
+
<option key={option.value} value={option.value}>
|
|
80
|
+
{option.label}
|
|
81
|
+
</option>
|
|
82
|
+
))}
|
|
83
|
+
</select>
|
|
84
|
+
<span style={{ color: '#6b7280', fontSize: '14px' }}>
|
|
85
|
+
{widthOptions.find(opt => opt.value === selectedWidth)?.description}
|
|
86
|
+
</span>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div style={{
|
|
90
|
+
backgroundColor: '#1f2937',
|
|
91
|
+
color: '#f9fafb',
|
|
92
|
+
padding: '15px',
|
|
93
|
+
borderRadius: '6px',
|
|
94
|
+
fontFamily: 'monospace',
|
|
95
|
+
fontSize: '14px',
|
|
96
|
+
overflow: 'auto'
|
|
97
|
+
}}>
|
|
98
|
+
<pre>{JSON.stringify({
|
|
99
|
+
save: {
|
|
100
|
+
return: {
|
|
101
|
+
type: 'table',
|
|
102
|
+
width: selectedWidth || undefined,
|
|
103
|
+
param: 'data'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, null, 2)}</pre>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div style={{
|
|
111
|
+
border: '1px solid #d1d5db',
|
|
112
|
+
borderRadius: '8px',
|
|
113
|
+
overflow: 'hidden',
|
|
114
|
+
backgroundColor: 'white'
|
|
115
|
+
}}>
|
|
116
|
+
<div style={{
|
|
117
|
+
padding: '15px',
|
|
118
|
+
backgroundColor: '#f8fafc',
|
|
119
|
+
borderBottom: '1px solid #e2e8f0',
|
|
120
|
+
fontWeight: 'bold'
|
|
121
|
+
}}>
|
|
122
|
+
Form with Table Width: {selectedWidth ? `${selectedWidth}px` : 'Default'}
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<div style={{ padding: '20px' }}>
|
|
126
|
+
<Form
|
|
127
|
+
formSettings={getFormSettings(selectedWidth)}
|
|
128
|
+
formType="create"
|
|
129
|
+
// Mock other required props
|
|
130
|
+
style={{}}
|
|
131
|
+
// The Form component will use the width configuration when displaying return data
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<div style={{
|
|
137
|
+
marginTop: '30px',
|
|
138
|
+
padding: '20px',
|
|
139
|
+
backgroundColor: '#fef3c7',
|
|
140
|
+
borderRadius: '8px',
|
|
141
|
+
border: '1px solid #f59e0b'
|
|
142
|
+
}}>
|
|
143
|
+
<h3>How It Works:</h3>
|
|
144
|
+
<ul style={{ marginTop: '10px', lineHeight: '1.6' }}>
|
|
145
|
+
<li><strong>JSON Configuration:</strong> Set the <code>width</code> property in <code>save.return</code></li>
|
|
146
|
+
<li><strong>Container Width:</strong> The table container will be set to the specified width in pixels</li>
|
|
147
|
+
<li><strong>Responsive:</strong> Uses <code>min(width, 100vw - 40px)</code> to prevent overflow on small screens</li>
|
|
148
|
+
<li><strong>Centering:</strong> Tables with custom width are automatically centered</li>
|
|
149
|
+
<li><strong>Scrolling:</strong> Horizontal scrolling is enabled when content exceeds container width</li>
|
|
150
|
+
</ul>
|
|
151
|
+
|
|
152
|
+
<h4 style={{ marginTop: '20px' }}>Supported Formats:</h4>
|
|
153
|
+
<ul style={{ marginTop: '5px' }}>
|
|
154
|
+
<li><code>"width": "1500"</code> - String format (pixels)</li>
|
|
155
|
+
<li><code>"width": 1500</code> - Number format (pixels)</li>
|
|
156
|
+
<li><code>width</code> property omitted - Uses default 100% width</li>
|
|
157
|
+
</ul>
|
|
158
|
+
|
|
159
|
+
<h4 style={{ marginTop: '20px' }}>Example Scenarios:</h4>
|
|
160
|
+
<ul style={{ marginTop: '5px' }}>
|
|
161
|
+
<li><strong>800px:</strong> Perfect for 4-6 columns with moderate content</li>
|
|
162
|
+
<li><strong>1200px:</strong> Good for 6-8 columns or tables with longer text content</li>
|
|
163
|
+
<li><strong>1500px:</strong> Ideal for 8-12 columns or detailed reporting tables</li>
|
|
164
|
+
<li><strong>2000px:</strong> Best for very wide tables with many columns or complex data</li>
|
|
165
|
+
</ul>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default TableWidthConfigExample;
|
package/src/index.js
CHANGED
|
@@ -57,7 +57,6 @@ import GenericIndex from './components/crm/generic/GenericIndex';
|
|
|
57
57
|
import GenericMain from './components/crm/generic/GenericMain';
|
|
58
58
|
import GenericQuote from './components/crm/generic/GenericQuote';
|
|
59
59
|
import GenericReport from './components/crm/generic/GenericReport';
|
|
60
|
-
import GenericReportImproved from './components/crm/generic/GenericReportImproved';
|
|
61
60
|
import GenericSort from './components/crm/generic/GenericSort';
|
|
62
61
|
import NotificationList from './components/crm/generic/NotificationList';
|
|
63
62
|
|
|
@@ -98,7 +97,6 @@ export {
|
|
|
98
97
|
GenericMain,
|
|
99
98
|
GenericQuote,
|
|
100
99
|
GenericReport,
|
|
101
|
-
GenericReportImproved,
|
|
102
100
|
GenericSort,
|
|
103
101
|
Loader,
|
|
104
102
|
Login,
|