tycho-components 0.14.16 → 0.14.18

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,4 +1,11 @@
1
1
  import { SelectItem } from 'tycho-storybook';
2
+ export type SwitchFieldLabels = {
3
+ trueLabel: string;
4
+ falseLabel: string;
5
+ notAvailable: string;
6
+ };
7
+ /** Renders switch (boolean) values for read-only display — no ternary chains. */
8
+ export declare function formatSwitchFieldValue(value: unknown, labels: SwitchFieldLabels): string;
2
9
  export type DisplayFunction = (value: any) => string;
3
10
  export type MaskFunction = (value: string, isBlur?: boolean) => string;
4
11
  export type AppFormField = {
@@ -1 +1,10 @@
1
- export {};
1
+ /** Renders switch (boolean) values for read-only display — no ternary chains. */
2
+ export function formatSwitchFieldValue(value, labels) {
3
+ if (value === true) {
4
+ return labels.trueLabel;
5
+ }
6
+ if (value === false) {
7
+ return labels.falseLabel;
8
+ }
9
+ return labels.notAvailable;
10
+ }
@@ -1,13 +1,29 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useTranslation } from 'react-i18next';
3
+ import { formatSwitchFieldValue } from './AppFormField';
3
4
  import './style.scss';
5
+ function getFieldDisplayContent(field, raw, t) {
6
+ if (field.display) {
7
+ return field.display(raw);
8
+ }
9
+ if (field.fn) {
10
+ return field.fn(raw);
11
+ }
12
+ if (field.type === 'switch') {
13
+ return formatSwitchFieldValue(raw, {
14
+ trueLabel: t('generic.boolean.true'),
15
+ falseLabel: t('generic.boolean.false'),
16
+ notAvailable: t('label.notavailable'),
17
+ });
18
+ }
19
+ if (raw) {
20
+ return raw;
21
+ }
22
+ return t('label.notavailable');
23
+ }
4
24
  export default function AppFormInfo({ fields, data }) {
5
25
  const { t } = useTranslation('common');
6
26
  return (_jsx("div", { className: "app-form-info-container", children: fields.map((field, idx) => {
7
- return (_jsxs("div", { className: "item", children: [_jsxs("span", { className: "label", children: [field.name, ":"] }), _jsx("span", { className: "value", children: field.display
8
- ? field.display(data[field.attr])
9
- : field.fn
10
- ? field.fn(data[field.attr])
11
- : data[field.attr] || t('label.notavailable') })] }, 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) })] }, idx));
12
28
  }) }));
13
29
  }
@@ -65,6 +65,8 @@ export declare const commonResources: {
65
65
  'label.public': string;
66
66
  'label.private': string;
67
67
  'label.notavailable': string;
68
+ 'generic.boolean.true': string;
69
+ 'generic.boolean.false': string;
68
70
  'select.empty': string;
69
71
  'pagination.label.showing': string;
70
72
  'pagination.label.results': string;
@@ -334,6 +336,8 @@ export declare const commonResources: {
334
336
  'label.public': string;
335
337
  'label.private': string;
336
338
  'label.notavailable': string;
339
+ 'generic.boolean.true': string;
340
+ 'generic.boolean.false': string;
337
341
  'select.empty': string;
338
342
  'pagination.label.showing': string;
339
343
  'pagination.label.results': string;
@@ -600,6 +604,8 @@ export declare const commonResources: {
600
604
  'label.public': string;
601
605
  'label.private': string;
602
606
  'label.notavailable': string;
607
+ 'generic.boolean.true': string;
608
+ 'generic.boolean.false': string;
603
609
  'select.empty': string;
604
610
  'pagination.label.showing': string;
605
611
  'pagination.label.results': string;
@@ -19,6 +19,8 @@ export declare const CommonTexts: {
19
19
  'label.public': string;
20
20
  'label.private': string;
21
21
  'label.notavailable': string;
22
+ 'generic.boolean.true': string;
23
+ 'generic.boolean.false': string;
22
24
  'select.empty': string;
23
25
  'pagination.label.showing': string;
24
26
  'pagination.label.results': string;
@@ -77,6 +79,8 @@ export declare const CommonTexts: {
77
79
  'label.public': string;
78
80
  'label.private': string;
79
81
  'label.notavailable': string;
82
+ 'generic.boolean.true': string;
83
+ 'generic.boolean.false': string;
80
84
  'select.empty': string;
81
85
  'pagination.label.showing': string;
82
86
  'pagination.label.results': string;
@@ -135,6 +139,8 @@ export declare const CommonTexts: {
135
139
  'label.public': string;
136
140
  'label.private': string;
137
141
  'label.notavailable': string;
142
+ 'generic.boolean.true': string;
143
+ 'generic.boolean.false': string;
138
144
  'select.empty': string;
139
145
  'pagination.label.showing': string;
140
146
  'pagination.label.results': string;
@@ -19,6 +19,8 @@ export const CommonTexts = {
19
19
  'label.public': 'Public',
20
20
  'label.private': 'Private',
21
21
  'label.notavailable': 'N/A',
22
+ 'generic.boolean.true': 'Yes',
23
+ 'generic.boolean.false': 'No',
22
24
  'select.empty': 'Select',
23
25
  'pagination.label.showing': '',
24
26
  'pagination.label.results': 'results per page',
@@ -77,6 +79,8 @@ export const CommonTexts = {
77
79
  'label.public': 'Público',
78
80
  'label.private': 'Privado',
79
81
  'label.notavailable': 'N/A',
82
+ 'generic.boolean.true': 'Sim',
83
+ 'generic.boolean.false': 'Não',
80
84
  'select.empty': 'Selecionar',
81
85
  'pagination.label.showing': 'Exibindo',
82
86
  'pagination.label.results': 'resultados por página',
@@ -135,6 +139,8 @@ export const CommonTexts = {
135
139
  'label.public': 'Pubblico',
136
140
  'label.private': 'Privato',
137
141
  'label.notavailable': 'N/A',
142
+ 'generic.boolean.true': 'Sì',
143
+ 'generic.boolean.false': 'No',
138
144
  'select.empty': 'Seleziona',
139
145
  'pagination.label.showing': 'Mostrando',
140
146
  'pagination.label.results': 'risultati per pagina',
package/dist/index.d.ts CHANGED
@@ -76,6 +76,8 @@ export { default as LanguageSelector } from './LanguageSelector';
76
76
  export { AvailableLanguages } from './LanguageSelector';
77
77
  export type { AvailableLanguage } from './LanguageSelector';
78
78
  export { default as Participants } from './Participants';
79
+ export type { default as Participant, ParticipantCreateRequest } from './Participants/types/Participant';
80
+ export { EMPTY_PARTICIPANT, PARTICIPANT_FIELDS, CHAT_FIELDS, } from './Participants/types/Participant';
79
81
  export { default as SentenceView } from './SentenceView';
80
82
  export { default as TreeView } from './TreeView';
81
83
  export { default as CytoscapeTreeConverter } from './TreeView/cytoscape/CytoscapeTreeConverter';
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ export { default as HelpButton } from './Header/HelpButton';
57
57
  export { default as LanguageSelector } from './LanguageSelector';
58
58
  export { AvailableLanguages } from './LanguageSelector';
59
59
  export { default as Participants } from './Participants';
60
+ export { EMPTY_PARTICIPANT, PARTICIPANT_FIELDS, CHAT_FIELDS, } from './Participants/types/Participant';
60
61
  export { default as SentenceView } from './SentenceView';
61
62
  export { default as TreeView } from './TreeView';
62
63
  export { default as CytoscapeTreeConverter } from './TreeView/cytoscape/CytoscapeTreeConverter';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.14.16",
4
+ "version": "0.14.18",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {