tycho-components 0.14.19 → 0.14.21
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.
|
@@ -2,7 +2,18 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { formatSwitchFieldValue } from './AppFormField';
|
|
4
4
|
import './style.scss';
|
|
5
|
+
import { Icon } from 'tycho-storybook';
|
|
6
|
+
import { UsabilityUtils } from '..';
|
|
7
|
+
function truncateValue(value, truncate) {
|
|
8
|
+
if (value.length <= truncate) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
return `${value.slice(0, truncate)}…`;
|
|
12
|
+
}
|
|
5
13
|
function getFieldDisplayContent(field, raw, t) {
|
|
14
|
+
if (field.truncate) {
|
|
15
|
+
return truncateValue(raw, field.truncate);
|
|
16
|
+
}
|
|
6
17
|
if (field.display) {
|
|
7
18
|
return field.display(raw);
|
|
8
19
|
}
|
|
@@ -24,6 +35,8 @@ function getFieldDisplayContent(field, raw, t) {
|
|
|
24
35
|
export default function AppFormInfo({ fields, data }) {
|
|
25
36
|
const { t } = useTranslation('common');
|
|
26
37
|
return (_jsx("div", { className: "app-form-info-container", children: fields.map((field, idx) => {
|
|
27
|
-
return (_jsxs("div", { className: "item", children: [_jsxs("span", { className: "label", children: [field.name, ":"] }), _jsx("span", { className: "value", children: getFieldDisplayContent(field, data[field.attr], t) })
|
|
38
|
+
return (_jsxs("div", { className: "item", ...(field.title && { title: field.title }), children: [_jsxs("span", { className: "label", children: [field.name, ":"] }), _jsx("span", { className: "value", children: getFieldDisplayContent(field, data[field.attr], t) }), field.copyToClipboard && (_jsx(Icon, { name: "content_copy", size: "small", className: "ds-copy-icon", filled: true, onClick: () => {
|
|
39
|
+
UsabilityUtils.copy(data[field.attr]);
|
|
40
|
+
} }))] }, idx));
|
|
28
41
|
}) }));
|
|
29
42
|
}
|
package/dist/AppForm/style.scss
CHANGED
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
@include body-medium-1;
|
|
22
22
|
color: var(--text-secondary);
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
> .ds-copy-icon {
|
|
26
|
+
color: var(--icon-primary);
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -34,4 +39,4 @@
|
|
|
34
39
|
grid-template-columns: repeat(2, 1fr);
|
|
35
40
|
gap: 16px;
|
|
36
41
|
}
|
|
37
|
-
}
|
|
42
|
+
}
|