@topconsultnpm/sdkui-react-beta 6.15.24 → 6.15.25
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import { SDK_Globals } from "@topconsultnpm/sdk-ts-beta";
|
|
4
|
-
import { formatBytes, getFileIcon, IconAttachment, IconCADossier, IconMenuCAWorkingGroups, SDKUI_Localizator } from "../../helper";
|
|
4
|
+
import { formatBytes, getAvatarColor, getFileIcon, IconAttachment, IconCADossier, IconMenuCAWorkingGroups, SDKUI_Localizator } from "../../helper";
|
|
5
5
|
import TMTooltip from "../base/TMTooltip";
|
|
6
6
|
import { DownloadTypes } from '../../ts';
|
|
7
7
|
import { TMColors } from '../../utils/theme';
|
|
@@ -178,40 +178,6 @@ export const AttachmentElement = (attachment, treeFs, draftLatestInfoMap, archiv
|
|
|
178
178
|
}, children: _jsxs("div", { style: { alignItems: 'center', display: 'flex' }, children: [fileExt ? _jsx("span", { style: { marginRight: "10px" }, children: getFileIcon(fileExt, undefined, tooltipContent) }) : _jsx(IconAttachment, { style: { marginRight: "5px" } }), _jsx("span", { children: nameElement })] }) }, attachment.did);
|
|
179
179
|
};
|
|
180
180
|
export const OwnerInitialsBadge = (blogPost) => {
|
|
181
|
-
const generateDarkColorFromName = (str) => {
|
|
182
|
-
// Create a hash of the string
|
|
183
|
-
let hash = 0;
|
|
184
|
-
for (let i = 0; i < str.length; i++) {
|
|
185
|
-
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
186
|
-
}
|
|
187
|
-
// Convert the hash to a color (ensure it's within RGB range)
|
|
188
|
-
const hue = Math.floor((hash & 0x00FFFFFF) / 0x10000);
|
|
189
|
-
// Define color ranges for dark red, green, yellow, and others
|
|
190
|
-
let colorRange;
|
|
191
|
-
if (hue >= 0 && hue < 30) { // Dark red
|
|
192
|
-
colorRange = 0; // Red hue
|
|
193
|
-
}
|
|
194
|
-
else if (hue >= 30 && hue < 90) { // Dark orange to yellow
|
|
195
|
-
colorRange = 60; // Yellow hue
|
|
196
|
-
}
|
|
197
|
-
else if (hue >= 90 && hue < 150) { // Dark green
|
|
198
|
-
colorRange = 120; // Green hue
|
|
199
|
-
}
|
|
200
|
-
else if (hue >= 150 && hue < 210) { // Dark cyan
|
|
201
|
-
colorRange = 180; // Cyan hue
|
|
202
|
-
}
|
|
203
|
-
else if (hue >= 210 && hue < 270) { // Dark blue
|
|
204
|
-
colorRange = 240; // Blue hue
|
|
205
|
-
}
|
|
206
|
-
else if (hue >= 270 && hue < 330) { // Dark purple
|
|
207
|
-
colorRange = 300; // Purple hue
|
|
208
|
-
}
|
|
209
|
-
else { // Dark magenta
|
|
210
|
-
colorRange = 360; // Magenta hue
|
|
211
|
-
}
|
|
212
|
-
// Use a low lightness value to keep the color dark
|
|
213
|
-
return `hsl(${colorRange}, 70%, 30%)`; // Low lightness for dark colors
|
|
214
|
-
};
|
|
215
181
|
const extractInitialsFromName = (name) => {
|
|
216
182
|
if (!name)
|
|
217
183
|
return '';
|
|
@@ -228,7 +194,7 @@ export const OwnerInitialsBadge = (blogPost) => {
|
|
|
228
194
|
width: "40px",
|
|
229
195
|
height: "40px",
|
|
230
196
|
borderRadius: "50%",
|
|
231
|
-
backgroundColor:
|
|
197
|
+
backgroundColor: getAvatarColor(blogPost.ownerName ?? '-'),
|
|
232
198
|
display: "flex",
|
|
233
199
|
alignItems: "center",
|
|
234
200
|
justifyContent: "center",
|
|
@@ -27,7 +27,6 @@ interface ITMHeader {
|
|
|
27
27
|
onSettingsClick?: () => void;
|
|
28
28
|
}
|
|
29
29
|
export declare const getInitials: (name: string) => string;
|
|
30
|
-
export declare const getAvatarColor: (name: string) => string;
|
|
31
30
|
export declare const getCultureFlag: (cultureId: CultureIDs) => string;
|
|
32
31
|
export declare const getCultureDisplayName: (cultureId: CultureIDs) => string;
|
|
33
32
|
export declare const copyUserInfoToClipboard: (userName: string, cultureId: string, archiveId: string, archiveDesc: string, endpoint: string, domain?: string) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
3
3
|
import six from '../../assets/six.png';
|
|
4
|
-
import { IconCloseOutline, IconCopy, IconSearch, openApps, SDKUI_Localizator } from '../../helper';
|
|
4
|
+
import { getAvatarColor, IconCloseOutline, IconCopy, IconSearch, openApps, SDKUI_Localizator } from '../../helper';
|
|
5
5
|
import styled, { keyframes } from 'styled-components';
|
|
6
6
|
import { SDK_Globals, AuthenticationModes, AppModules, UserLevels, CultureIDs } from '@topconsultnpm/sdk-ts-beta';
|
|
7
7
|
import { TMColors } from '../../utils/theme';
|
|
@@ -36,15 +36,6 @@ export const getInitials = (name) => {
|
|
|
36
36
|
}
|
|
37
37
|
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
38
38
|
};
|
|
39
|
-
export const getAvatarColor = (name) => {
|
|
40
|
-
const colors = [
|
|
41
|
-
'#6264A7', '#8C6BAD', '#C239B3', '#E33B9A', '#F2707C',
|
|
42
|
-
'#FF8C00', '#CA5010', '#8E562E', '#498205', '#107C10',
|
|
43
|
-
'#0078D4', '#038387', '#8764B8', '#881798', '#C50E20'
|
|
44
|
-
];
|
|
45
|
-
const hash = name.split('').reduce((acc, char) => char.charCodeAt(0) + acc, 0);
|
|
46
|
-
return colors[hash % colors.length];
|
|
47
|
-
};
|
|
48
39
|
export const getCultureFlag = (cultureId) => {
|
|
49
40
|
switch (cultureId) {
|
|
50
41
|
case 'it_IT': return it;
|
package/lib/helper/TMUtils.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export interface RowData {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const associateColumnsToRows: (columns: Array<DataColumnDescriptor> | undefined, rows: Array<Array<string>> | undefined) => Array<RowData>;
|
|
8
8
|
export declare const buildValueToLabelMapFromDataColumns: (columns: Array<DataColumnDescriptor>) => Promise<Map<string, string>>;
|
|
9
|
+
export declare const getAvatarColor: (name: string) => string;
|
package/lib/helper/TMUtils.js
CHANGED
|
@@ -133,3 +133,12 @@ export const buildValueToLabelMapFromDataColumns = async (columns) => {
|
|
|
133
133
|
}
|
|
134
134
|
return valueToNameMap;
|
|
135
135
|
};
|
|
136
|
+
export const getAvatarColor = (name) => {
|
|
137
|
+
const colors = [
|
|
138
|
+
'#6264A7', '#8C6BAD', '#C239B3', '#E33B9A', '#F2707C',
|
|
139
|
+
'#FF8C00', '#CA5010', '#8E562E', '#498205', '#107C10',
|
|
140
|
+
'#0078D4', '#038387', '#8764B8', '#881798', '#C50E20'
|
|
141
|
+
];
|
|
142
|
+
const hash = name.split('').reduce((acc, char) => char.charCodeAt(0) + acc, 0);
|
|
143
|
+
return colors[hash % colors.length];
|
|
144
|
+
};
|