tycho-components 0.48.1 → 0.48.3

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.
@@ -4,6 +4,12 @@ import { formatSwitchFieldValue } from './AppFormField';
4
4
  import './style.scss';
5
5
  import { Icon } from 'tycho-storybook';
6
6
  import UsabilityUtils from '../../functions/UsabilityUtils';
7
+ /** Resolve dotted paths (e.g. `progress.pages`, `file.path`) against nested objects. */
8
+ const getNestedValue = (obj, path) => path
9
+ .split('.')
10
+ .reduce((current, key) => current != null && typeof current === 'object' && key in current
11
+ ? current[key]
12
+ : undefined, obj);
7
13
  function truncateValue(value, truncate, t) {
8
14
  if (!value) {
9
15
  return t('label.notavailable');
@@ -30,6 +36,11 @@ function getFieldDisplayContent(field, raw, t) {
30
36
  notAvailable: t('label.notavailable'),
31
37
  });
32
38
  }
39
+ if (field.options?.length && raw != null && raw !== '') {
40
+ const option = field.options.find((op) => op.value === raw);
41
+ if (option)
42
+ return option.label;
43
+ }
33
44
  if (raw != null && raw !== '') {
34
45
  return raw;
35
46
  }
@@ -38,8 +49,9 @@ function getFieldDisplayContent(field, raw, t) {
38
49
  export default function AppFormInfo({ fields, data }) {
39
50
  const { t } = useTranslation('common');
40
51
  return (_jsx("div", { className: "app-form-info-container", children: fields.map((field, idx) => {
41
- 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: () => {
42
- UsabilityUtils.copy(data[field.attr]);
52
+ const value = getNestedValue(data, field.attr);
53
+ 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, value, t) }), field.copyToClipboard && (_jsx(Icon, { name: "content_copy", size: "small", className: "ds-copy-icon", filled: true, onClick: () => {
54
+ UsabilityUtils.copy(String(value ?? ''));
43
55
  } }))] }, idx));
44
56
  }) }));
45
57
  }
@@ -9,7 +9,7 @@ import "./style.scss";
9
9
  export default function AccessUser({ mode, resourceUid, user, onClose, onReload, setItems, }) {
10
10
  const { t } = useTranslation("access");
11
11
  const { getCorpus, hasCorpus } = useCorpusUtils();
12
- const showPortal = mode !== "corpus" || (hasCorpus() && getCorpus().opened);
12
+ const showPortal = mode === "corpus" && hasCorpus() && getCorpus().opened;
13
13
  const handleChangeAccess = (r) => {
14
14
  setItems((prevState) => {
15
15
  if (!prevState)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.48.1",
4
+ "version": "0.48.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {