@controleonline/ui-default 1.0.270 → 1.0.273
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/.github/workflows/integration-source-gate.yml +68 -0
- package/.github/workflows/manager-worker.yml +19 -0
- package/.github/workflows/publish-npm.yml +91 -0
- package/AGENTS.md +46 -50
- package/docs/technical/Contrato-de-colunas.md +67 -0
- package/docs/technical/Default-Components.md +76 -0
- package/docs/technical/DefaultForm.md +80 -0
- package/docs/technical/DefaultInput-e-DefaultSelect.md +73 -0
- package/docs/technical/DefaultTable.md +272 -0
- package/docs/wiki.md +1 -0
- package/package.json +4 -3
- package/scripts/validate-wiki-pointer.cjs +13 -0
- package/src/react/components/address/DefaultAddress.js +446 -0
- package/src/react/components/address/DefaultAddress.styles.js +133 -0
- package/src/react/components/address/DefaultAddressCoordFields.js +59 -0
- package/src/react/components/address/DefaultAddressMapPane.js +55 -0
- package/src/react/components/address/LatLonReadonlyFields.js +51 -0
- package/src/react/components/address/defaultAddressHelpers.js +163 -0
- package/src/react/components/address/defaultAddressStyles.js +148 -0
- package/src/react/components/address/defaultAddressUtils.js +129 -0
- package/src/react/components/extra-data/DefaultExtraData.js +152 -0
- package/src/react/components/extra-data/DefaultExtraData.styles.js +61 -0
- package/src/react/components/files/DefaultFile.js +231 -46
- package/src/react/components/files/DefaultFileColumn.js +123 -0
- package/src/react/components/files/DefaultFileColumn.styles.js +52 -0
- package/src/react/components/files/DefaultFileColumn.utils.js +104 -0
- package/src/react/components/filters/CompactFilterSelector.js +51 -35
- package/src/react/components/filters/DefaultColumnFilter.js +60 -48
- package/src/react/components/filters/DefaultExternalFilters.js +324 -265
- package/src/react/components/filters/filterValue.js +65 -0
- package/src/react/components/form/DefaultForm.js +99 -79
- package/src/react/components/help/DefaultTooltip.js +48 -12
- package/src/react/components/help/DefaultTooltip.styles.js +20 -0
- package/src/react/components/inputs/DefaultColorInput.js +153 -0
- package/src/react/components/inputs/DefaultFeatherIconPicker.js +146 -0
- package/src/react/components/inputs/DefaultFeatherIconPicker.styles.js +113 -0
- package/src/react/components/inputs/DefaultInput.js +296 -141
- package/src/react/components/inputs/DefaultInput.styles.js +26 -0
- package/src/react/components/inputs/DefaultSelect.js +134 -123
- package/src/react/components/inputs/defaultInputUtils.js +262 -213
- package/src/react/components/map/DefaultMap.native.js +73 -73
- package/src/react/components/map/DefaultMap.shared.js +911 -762
- package/src/react/components/map/DefaultMap.web.js +124 -68
- package/src/react/components/table/DefaultColumnMenu.js +22 -3
- package/src/react/components/table/DefaultDebug.js +44 -37
- package/src/react/components/table/DefaultSearchModal.js +9 -1
- package/src/react/components/table/DefaultTable.grouping.js +98 -0
- package/src/react/components/table/DefaultTable.js +217 -111
- package/src/react/components/table/DefaultTable.styles.js +369 -310
- package/src/react/components/table/DefaultTable.utils.js +38 -4
- package/src/react/components/table/DefaultTableBody.js +13 -8
- package/src/react/components/table/DefaultTableCards.js +20 -1
- package/src/react/components/table/DefaultTableControls.js +180 -205
- package/src/react/components/table/DefaultTableImportModal.js +108 -0
- package/src/react/components/table/DefaultTableInput.js +1 -0
- package/src/react/components/table/DefaultTableRowActions.js +1 -1
- package/src/react/components/table/DefaultTableRows.js +357 -325
- package/src/react/components/table/DefaultTableSearch.js +28 -5
- package/src/react/components/table/DefaultTableToolbar.js +92 -3
- package/src/react/components/table/useDefaultTablePagination.js +56 -7
- package/src/react/components/table/useDefaultTableStoreSync.js +164 -0
- package/src/react/components/upload/DefaultUpload.js +406 -0
- package/src/react/components/upload/DefaultUpload.styles.js +153 -0
- package/src/react/components/upload/DefaultUploadAttachmentsList.js +146 -0
- package/src/react/components/upload/DefaultUploadManagerModal.js +247 -0
- package/src/react/components/upload/defaultUploadHelpers.js +108 -0
- package/src/react/components/upload/defaultUploadLibrary.js +248 -0
- package/src/react/components/upload/fileUpload.js +93 -0
- package/src/react/hooks/usePostalCodeLookup.js +159 -0
- package/src/react/index.js +6 -0
- package/src/react/services/addressFormUtils.js +262 -0
- package/src/react/services/addressGeo.js +230 -0
- package/src/react/utils/tableVisibleColumnsPreferences.js +113 -15
- package/src/tests/react/components/address/defaultAddressHelpers.test.js +104 -0
- package/src/tests/react/components/files/DefaultFile.test.js +22 -6
- package/src/tests/react/components/files/DefaultFileColumn.company.test.js +24 -0
- package/src/tests/react/components/form/DefaultForm.test.js +123 -0
- package/src/tests/react/components/help/DefaultTooltip.test.js +93 -0
- package/src/tests/react/components/inputs/DefaultSelect.test.js +108 -79
- package/src/tests/react/components/table/DefaultTable.grouping.test.js +49 -0
- package/src/tests/react/components/table/DefaultTable.test.js +53 -2
- package/src/tests/react/components/table/DefaultTable.utils.test.js +10 -0
- package/src/tests/react/components/table/DefaultTableControls.filters.test.mjs +21 -0
- package/src/tests/react/components/table/DefaultTableRowActions.test.js +23 -0
- package/src/tests/react/components/table/DefaultTableRows.rowActions.test.js +152 -0
- package/src/tests/react/components/table/resolveRowBackgroundColor.test.mjs +45 -0
- package/src/tests/react/components/table/useDefaultTableStoreSync.test.js +161 -0
- package/src/tests/react/components/upload/DefaultUpload.test.js +353 -0
- package/src/tests/react/components/upload/defaultUploadLibrary.test.js +104 -0
- package/src/tests/react/components/upload/peopleMediaLibraryPreview.test.mjs +57 -0
- package/src/tests/react/filters/filterValue.test.js +46 -0
- package/src/tests/react/hooks/usePostalCodeLookup.test.js +107 -0
- package/src/tests/react/inputs/defaultInputUtils.test.js +9 -1
- package/src/tests/react/services/SMOKE-637-cep-hydrate.md +45 -0
- package/src/tests/react/services/addressFormUtils.test.js +179 -0
- package/src/tests/react/services/addressGeoLookup.async.test.js +104 -0
- package/src/tests/react/services/addressGeoLookup.test.js +105 -0
- package/src/tests/react/services/smoke-637/form-cep-12941040.png +0 -0
- package/src/tests/react/services/smoke-637/index.html +132 -0
- package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +96 -49
|
@@ -2,31 +2,31 @@ import { getAllStores } from '@store';
|
|
|
2
2
|
import Formatter from '@controleonline/ui-common/src/utils/formatter.js';
|
|
3
3
|
import { formatStoreColumnValue } from '@controleonline/ui-common/src/react/utils/storeColumns';
|
|
4
4
|
import FeatherGlyphMap from 'react-native-vector-icons/glyphmaps/Feather.json';
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
export const normalizeText = value => String(value ?? '').trim();
|
|
7
7
|
export const isValidFeatherIcon = icon => Boolean(FeatherGlyphMap[normalizeText(icon)]);
|
|
8
8
|
const formatHumanLabel = value =>
|
|
9
|
-
normalizeText(value)
|
|
10
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
11
|
-
.replace(/[_-]+/g, ' ')
|
|
12
|
-
.replace(/^\w/, letter => letter.toUpperCase());
|
|
13
|
-
const DEFAULT_TRANSLATABLE_FIELDS = new Set([
|
|
14
|
-
'active',
|
|
15
|
-
'app',
|
|
16
|
-
'channel',
|
|
17
|
-
'displaytype',
|
|
18
|
-
'featured',
|
|
19
|
-
'frequency',
|
|
20
|
-
'invoicetype',
|
|
21
|
-
'installments',
|
|
22
|
-
'ordertype',
|
|
23
|
-
'peopletype',
|
|
24
|
-
'pricecalculation',
|
|
25
|
-
'productcondition',
|
|
26
|
-
'realstatus',
|
|
27
|
-
'status',
|
|
28
|
-
]);
|
|
29
|
-
|
|
9
|
+
normalizeText(value)
|
|
10
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
11
|
+
.replace(/[_-]+/g, ' ')
|
|
12
|
+
.replace(/^\w/, letter => letter.toUpperCase());
|
|
13
|
+
const DEFAULT_TRANSLATABLE_FIELDS = new Set([
|
|
14
|
+
'active',
|
|
15
|
+
'app',
|
|
16
|
+
'channel',
|
|
17
|
+
'displaytype',
|
|
18
|
+
'featured',
|
|
19
|
+
'frequency',
|
|
20
|
+
'invoicetype',
|
|
21
|
+
'installments',
|
|
22
|
+
'ordertype',
|
|
23
|
+
'peopletype',
|
|
24
|
+
'pricecalculation',
|
|
25
|
+
'productcondition',
|
|
26
|
+
'realstatus',
|
|
27
|
+
'status',
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
30
|
export const getColumnKey = column => column?.key || column?.name || '';
|
|
31
31
|
|
|
32
32
|
export const isDateColumn = column =>
|
|
@@ -39,120 +39,197 @@ export const isDateRangeColumn = column =>
|
|
|
39
39
|
|
|
40
40
|
export const isDateLikeColumn = column =>
|
|
41
41
|
isDateColumn(column) || isDateRangeColumn(column);
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
option.
|
|
124
|
-
option
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
|
|
42
|
+
|
|
43
|
+
export const isColorColumn = column => {
|
|
44
|
+
const fieldName = normalizeColumnKey(getColumnKey(column));
|
|
45
|
+
const inputType = normalizeColumnKey(column?.inputType || column?.type);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
inputType === 'color' ||
|
|
49
|
+
inputType === 'hexcolor' ||
|
|
50
|
+
fieldName === 'color' ||
|
|
51
|
+
fieldName === 'bgcolor' ||
|
|
52
|
+
fieldName === 'backgroundcolor' ||
|
|
53
|
+
fieldName === 'bordercolor'
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const isIconColumn = column => {
|
|
58
|
+
const fieldName = normalizeColumnKey(getColumnKey(column));
|
|
59
|
+
const inputType = normalizeColumnKey(column?.inputType || column?.type);
|
|
60
|
+
|
|
61
|
+
return inputType === 'icon' || fieldName === 'icon';
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const isFileColumn = column => {
|
|
65
|
+
const inputType = normalizeColumnKey(column?.inputType || column?.type);
|
|
66
|
+
|
|
67
|
+
return [
|
|
68
|
+
'document',
|
|
69
|
+
'documents',
|
|
70
|
+
'file',
|
|
71
|
+
'files',
|
|
72
|
+
'image',
|
|
73
|
+
'images',
|
|
74
|
+
'pdf',
|
|
75
|
+
].includes(inputType);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const isExtraDataColumn = column =>
|
|
79
|
+
normalizeColumnKey(column?.inputType || column?.type) === 'extradata';
|
|
80
|
+
|
|
81
|
+
const normalizeColumnKey = value =>
|
|
82
|
+
normalizeText(value)
|
|
83
|
+
.replace(/[^a-zA-Z0-9]/g, '')
|
|
84
|
+
.toLowerCase();
|
|
85
|
+
|
|
86
|
+
const shouldTranslateOptionLabel = (column, storeName, rawLabel) => {
|
|
87
|
+
if (column?.translate === false || !normalizeText(rawLabel) || !normalizeText(storeName)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (column?.translate === true || Array.isArray(column?.list)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return [column?.key, column?.name, column?.label]
|
|
96
|
+
.map(normalizeColumnKey)
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.some(candidate => DEFAULT_TRANSLATABLE_FIELDS.has(candidate));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const normalizeId = value => {
|
|
102
|
+
if (!value) return '';
|
|
103
|
+
if (typeof value === 'number') return String(value);
|
|
104
|
+
if (typeof value === 'string') {
|
|
105
|
+
const match = value.match(/\d+/g);
|
|
106
|
+
return match ? match[match.length - 1] : value;
|
|
107
|
+
}
|
|
108
|
+
return normalizeId(value?.id || value?.['@id'] || '');
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const isEditableColumn = column =>
|
|
112
|
+
column?.editable !== false &&
|
|
113
|
+
!column?.isIdentity &&
|
|
114
|
+
column?.inputType !== 'increase' &&
|
|
115
|
+
!isFileColumn(column) &&
|
|
116
|
+
!String(getColumnKey(column)).includes('.');
|
|
117
|
+
|
|
118
|
+
export const normalizeOptionKey = option => {
|
|
119
|
+
if (!option) return '';
|
|
120
|
+
if (typeof option !== 'object') return normalizeId(option) || normalizeText(option);
|
|
121
|
+
return normalizeText(
|
|
122
|
+
option.value ??
|
|
123
|
+
option.id ??
|
|
124
|
+
normalizeId(option['@id']) ??
|
|
125
|
+
option.key ??
|
|
126
|
+
'',
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const resolveOptionLabel = (column, option, storeName = '') => {
|
|
131
|
+
if (!option) return '';
|
|
132
|
+
|
|
133
|
+
const STATUS_DISPLAY_PT = {
|
|
134
|
+
paid: 'Pago',
|
|
135
|
+
'waiting payment': 'Aguardando pagamento',
|
|
136
|
+
waiting_payment: 'Aguardando pagamento',
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const translateOptionLabel = rawLabel => {
|
|
140
|
+
const normalizedLabel = normalizeText(rawLabel);
|
|
141
|
+
const statusFallback = STATUS_DISPLAY_PT[normalizedLabel.toLowerCase()] || '';
|
|
142
|
+
if (!shouldTranslateOptionLabel(column, storeName, normalizedLabel)) {
|
|
143
|
+
return statusFallback || normalizedLabel;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const translated = global.t?.t(storeName, 'label', normalizedLabel) || normalizedLabel;
|
|
147
|
+
const translatedText = normalizeText(translated);
|
|
148
|
+
if (
|
|
149
|
+
statusFallback &&
|
|
150
|
+
(!translatedText ||
|
|
151
|
+
translatedText.toLowerCase() === normalizedLabel.toLowerCase() ||
|
|
152
|
+
translatedText === formatHumanLabel(normalizedLabel))
|
|
153
|
+
) {
|
|
154
|
+
return statusFallback;
|
|
155
|
+
}
|
|
156
|
+
return translatedText === formatHumanLabel(normalizedLabel)
|
|
157
|
+
? normalizedLabel
|
|
158
|
+
: translated;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (typeof column?.formatList === 'function') {
|
|
162
|
+
const formatted = column.formatList(option, null, column);
|
|
163
|
+
if (formatted && typeof formatted === 'object') {
|
|
164
|
+
return translateOptionLabel(formatted.label ?? formatted.value);
|
|
165
|
+
}
|
|
166
|
+
if (formatted) return translateOptionLabel(formatted);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const rawLabel = normalizeText(
|
|
170
|
+
option.label ??
|
|
171
|
+
option[column?.searchParam] ??
|
|
172
|
+
option[column?.name] ??
|
|
173
|
+
option.name ??
|
|
174
|
+
option.status ??
|
|
175
|
+
option.wallet ??
|
|
176
|
+
option.paymentType ??
|
|
177
|
+
option.alias ??
|
|
178
|
+
option.id,
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
return translateOptionLabel(rawLabel);
|
|
182
|
+
};
|
|
183
|
+
|
|
130
184
|
export const resolveStoreNameFromList = list =>
|
|
131
185
|
typeof list === 'string' ? normalizeText(list).split('/')[0] || '' : '';
|
|
132
|
-
|
|
186
|
+
|
|
133
187
|
const filterItemsByListRequestParams = (items = [], column = null) => {
|
|
134
|
-
const requestParams =
|
|
135
|
-
column?.listRequestParams &&
|
|
136
|
-
typeof column.listRequestParams === 'object' &&
|
|
137
|
-
!Array.isArray(column.listRequestParams)
|
|
138
|
-
? column.listRequestParams
|
|
139
|
-
: null;
|
|
140
|
-
|
|
141
|
-
if (!requestParams || Object.keys(requestParams).length === 0) {
|
|
142
|
-
return Array.isArray(items) ? items : [];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return (Array.isArray(items) ? items : []).filter(item =>
|
|
146
|
-
Object.entries(requestParams).every(([key, expectedValue]) => {
|
|
147
|
-
if (expectedValue === undefined || expectedValue === null || expectedValue === '') {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return normalizeText(item?.[key]) === normalizeText(expectedValue);
|
|
152
|
-
}),
|
|
188
|
+
const requestParams =
|
|
189
|
+
column?.listRequestParams &&
|
|
190
|
+
typeof column.listRequestParams === 'object' &&
|
|
191
|
+
!Array.isArray(column.listRequestParams)
|
|
192
|
+
? column.listRequestParams
|
|
193
|
+
: null;
|
|
194
|
+
|
|
195
|
+
if (!requestParams || Object.keys(requestParams).length === 0) {
|
|
196
|
+
return Array.isArray(items) ? items : [];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (Array.isArray(items) ? items : []).filter(item =>
|
|
200
|
+
Object.entries(requestParams).every(([key, expectedValue]) => {
|
|
201
|
+
if (expectedValue === undefined || expectedValue === null || expectedValue === '') {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return normalizeText(item?.[key]) === normalizeText(expectedValue);
|
|
206
|
+
}),
|
|
153
207
|
);
|
|
154
208
|
};
|
|
155
209
|
|
|
210
|
+
export const resolveColorToken = (value, themeColors = {}) => {
|
|
211
|
+
const normalized = normalizeText(value);
|
|
212
|
+
if (!normalized) return '';
|
|
213
|
+
|
|
214
|
+
if (normalized.startsWith('$')) {
|
|
215
|
+
return normalizeText(themeColors?.[normalized.slice(1)]);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const cssVarMatch = normalized.match(/^var\([^,]+,\s*(#[0-9a-fA-F]{3,8})\s*\)$/);
|
|
219
|
+
if (cssVarMatch?.[1]) return cssVarMatch[1];
|
|
220
|
+
|
|
221
|
+
return normalized;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export const resolveDefaultColorValue = (column, themeColors = {}, fallbackColor = '') =>
|
|
225
|
+
resolveColorToken(
|
|
226
|
+
column?.defaultColor ??
|
|
227
|
+
column?.defaultColour ??
|
|
228
|
+
column?.defaultValue ??
|
|
229
|
+
fallbackColor,
|
|
230
|
+
themeColors,
|
|
231
|
+
);
|
|
232
|
+
|
|
156
233
|
const normalizeObject = value =>
|
|
157
234
|
value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
158
235
|
|
|
@@ -161,31 +238,21 @@ export const mapOptions = (column, items = [], storeName = '') => {
|
|
|
161
238
|
const options = [];
|
|
162
239
|
|
|
163
240
|
(Array.isArray(items) ? items : []).forEach(item => {
|
|
164
|
-
const formatted =
|
|
165
|
-
typeof column?.formatList === 'function'
|
|
166
|
-
? column.formatList(item, null, column)
|
|
167
|
-
: item;
|
|
168
|
-
const key = normalizeOptionKey(formatted) || normalizeOptionKey(item);
|
|
169
|
-
const dedupeKey = key || normalizeText(resolveOptionLabel(column, item, storeName)).toLowerCase();
|
|
170
|
-
|
|
171
|
-
if (dedupeKey && seenKeys.has(dedupeKey)) return;
|
|
172
|
-
if (dedupeKey) seenKeys.add(dedupeKey);
|
|
173
|
-
|
|
241
|
+
const formatted =
|
|
242
|
+
typeof column?.formatList === 'function'
|
|
243
|
+
? column.formatList(item, null, column)
|
|
244
|
+
: item;
|
|
245
|
+
const key = normalizeOptionKey(formatted) || normalizeOptionKey(item);
|
|
246
|
+
const dedupeKey = key || normalizeText(resolveOptionLabel(column, item, storeName)).toLowerCase();
|
|
247
|
+
|
|
248
|
+
if (dedupeKey && seenKeys.has(dedupeKey)) return;
|
|
249
|
+
if (dedupeKey) seenKeys.add(dedupeKey);
|
|
250
|
+
|
|
174
251
|
const formattedMeta = normalizeObject(formatted);
|
|
175
252
|
const itemMeta = normalizeObject(item);
|
|
176
253
|
const color = formattedMeta.color ?? itemMeta.color;
|
|
177
|
-
const icon =
|
|
178
|
-
|
|
179
|
-
formattedMeta.iconName ??
|
|
180
|
-
itemMeta.icon ??
|
|
181
|
-
itemMeta.iconName;
|
|
182
|
-
const image =
|
|
183
|
-
formattedMeta.image ??
|
|
184
|
-
formattedMeta.logo ??
|
|
185
|
-
formattedMeta.source ??
|
|
186
|
-
itemMeta.image ??
|
|
187
|
-
itemMeta.logo ??
|
|
188
|
-
itemMeta.source;
|
|
254
|
+
const icon = formattedMeta.icon ?? itemMeta.icon;
|
|
255
|
+
const image = formattedMeta.image ?? itemMeta.image;
|
|
189
256
|
|
|
190
257
|
options.push({
|
|
191
258
|
...(color ? { color } : {}),
|
|
@@ -196,10 +263,10 @@ export const mapOptions = (column, items = [], storeName = '') => {
|
|
|
196
263
|
raw: item,
|
|
197
264
|
});
|
|
198
265
|
});
|
|
199
|
-
|
|
200
|
-
return options;
|
|
201
|
-
};
|
|
202
|
-
|
|
266
|
+
|
|
267
|
+
return options;
|
|
268
|
+
};
|
|
269
|
+
|
|
203
270
|
export const buildOptionsFromColumn = (column, getOptionsForColumn = null, storeName = '') => {
|
|
204
271
|
const explicitOptions = getOptionsForColumn?.(column);
|
|
205
272
|
if (Array.isArray(explicitOptions) && explicitOptions.length > 0) {
|
|
@@ -211,26 +278,26 @@ export const buildOptionsFromColumn = (column, getOptionsForColumn = null, store
|
|
|
211
278
|
}
|
|
212
279
|
|
|
213
280
|
const listStoreName = resolveStoreNameFromList(column?.list);
|
|
214
|
-
if (!listStoreName) return [];
|
|
215
|
-
|
|
216
|
-
const listStore = getAllStores()?.[listStoreName];
|
|
217
|
-
return mapOptions(
|
|
218
|
-
column,
|
|
219
|
-
filterItemsByListRequestParams(listStore?.getters?.items || [], column),
|
|
220
|
-
storeName,
|
|
221
|
-
);
|
|
222
|
-
};
|
|
223
|
-
|
|
281
|
+
if (!listStoreName) return [];
|
|
282
|
+
|
|
283
|
+
const listStore = getAllStores()?.[listStoreName];
|
|
284
|
+
return mapOptions(
|
|
285
|
+
column,
|
|
286
|
+
filterItemsByListRequestParams(listStore?.getters?.items || [], column),
|
|
287
|
+
storeName,
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
|
|
224
291
|
export const resolveCellText = ({ column, columns = [], row, storeName, value }) => {
|
|
225
292
|
const fieldName = getColumnKey(column);
|
|
226
293
|
const rawValue = value ?? row?.[fieldName];
|
|
227
294
|
const formattedValue = formatStoreColumnValue({
|
|
228
|
-
columns: columns.length ? columns : [column],
|
|
229
|
-
fieldName,
|
|
230
|
-
row,
|
|
231
|
-
storeName,
|
|
232
|
-
value: rawValue,
|
|
233
|
-
});
|
|
295
|
+
columns: columns.length ? columns : [column],
|
|
296
|
+
fieldName,
|
|
297
|
+
row,
|
|
298
|
+
storeName,
|
|
299
|
+
value: rawValue,
|
|
300
|
+
});
|
|
234
301
|
|
|
235
302
|
return normalizeText(formattedValue) || '-';
|
|
236
303
|
};
|
|
@@ -286,12 +353,8 @@ export const resolveCellPresentation = ({
|
|
|
286
353
|
backgroundColor:
|
|
287
354
|
formattedValueMeta.backgroundColor ??
|
|
288
355
|
formattedMeta.backgroundColor ??
|
|
289
|
-
formattedValueMeta.bgColor ??
|
|
290
|
-
formattedMeta.bgColor ??
|
|
291
356
|
rawMeta.backgroundColor ??
|
|
292
|
-
|
|
293
|
-
styleMeta.backgroundColor ??
|
|
294
|
-
styleMeta.bgColor,
|
|
357
|
+
styleMeta.backgroundColor,
|
|
295
358
|
borderColor:
|
|
296
359
|
formattedValueMeta.borderColor ??
|
|
297
360
|
formattedMeta.borderColor ??
|
|
@@ -301,31 +364,17 @@ export const resolveCellPresentation = ({
|
|
|
301
364
|
formattedValueMeta.color ??
|
|
302
365
|
formattedMeta.color ??
|
|
303
366
|
rawMeta.color ??
|
|
304
|
-
rawMeta.statusColor ??
|
|
305
|
-
rawMeta.categoryColor ??
|
|
306
367
|
styleMeta.color,
|
|
307
368
|
icon:
|
|
308
369
|
formattedValueMeta.icon ??
|
|
309
|
-
formattedValueMeta.iconName ??
|
|
310
370
|
formattedMeta.icon ??
|
|
311
|
-
formattedMeta.iconName ??
|
|
312
371
|
rawMeta.icon ??
|
|
313
|
-
|
|
314
|
-
styleMeta.icon ??
|
|
315
|
-
styleMeta.iconName,
|
|
372
|
+
styleMeta.icon,
|
|
316
373
|
image:
|
|
317
374
|
formattedValueMeta.image ??
|
|
318
|
-
formattedValueMeta.logo ??
|
|
319
|
-
formattedValueMeta.source ??
|
|
320
375
|
formattedMeta.image ??
|
|
321
|
-
formattedMeta.logo ??
|
|
322
|
-
formattedMeta.source ??
|
|
323
376
|
rawMeta.image ??
|
|
324
|
-
|
|
325
|
-
rawMeta.source ??
|
|
326
|
-
styleMeta.image ??
|
|
327
|
-
styleMeta.logo ??
|
|
328
|
-
styleMeta.source,
|
|
377
|
+
styleMeta.image,
|
|
329
378
|
label,
|
|
330
379
|
};
|
|
331
380
|
};
|
|
@@ -382,29 +431,29 @@ export const buildReadPresentationStyles = presentation => {
|
|
|
382
431
|
export const resolveEditValue = (column, row, value) => {
|
|
383
432
|
const rawValue = value ?? row?.[getColumnKey(column)];
|
|
384
433
|
if (column?.list) {
|
|
385
|
-
return normalizeOptionKey(
|
|
386
|
-
typeof column?.formatList === 'function'
|
|
387
|
-
? column.formatList(rawValue, row, column)
|
|
388
|
-
: rawValue,
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (typeof column?.editFormat === 'function') {
|
|
393
|
-
return normalizeText(column.editFormat(rawValue, column, row, true));
|
|
394
|
-
}
|
|
395
|
-
|
|
434
|
+
return normalizeOptionKey(
|
|
435
|
+
typeof column?.formatList === 'function'
|
|
436
|
+
? column.formatList(rawValue, row, column)
|
|
437
|
+
: rawValue,
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (typeof column?.editFormat === 'function') {
|
|
442
|
+
return normalizeText(column.editFormat(rawValue, column, row, true));
|
|
443
|
+
}
|
|
444
|
+
|
|
396
445
|
if (isDateLikeColumn(column) && rawValue) {
|
|
397
446
|
return normalizeText(Formatter.formatDateYmdTodmY(rawValue));
|
|
398
447
|
}
|
|
399
|
-
|
|
400
|
-
return normalizeText(rawValue);
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
export const formatSaveValue = (column, value, row) => {
|
|
404
|
-
if (typeof column?.saveFormat === 'function') {
|
|
405
|
-
return column.saveFormat(value, column, row);
|
|
406
|
-
}
|
|
407
|
-
|
|
448
|
+
|
|
449
|
+
return normalizeText(rawValue);
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
export const formatSaveValue = (column, value, row) => {
|
|
453
|
+
if (typeof column?.saveFormat === 'function') {
|
|
454
|
+
return column.saveFormat(value, column, row);
|
|
455
|
+
}
|
|
456
|
+
|
|
408
457
|
if (value && typeof value === 'object') {
|
|
409
458
|
if (value.value) return Number.isNaN(Number(value.value)) ? value.value : Number(value.value);
|
|
410
459
|
if (value['@id']) return value['@id'];
|