tycho-components 0.46.1 → 0.46.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.
- package/dist/common/AppCard/AppCard.d.ts +2 -1
- package/dist/common/AppCard/AppCard.js +2 -2
- package/dist/features/AccessControl/AccessUsers/AccessUsers.d.ts +3 -3
- package/dist/features/AccessControl/AccessUsers/AccessUsers.js +31 -31
- package/dist/features/PageRender/PageRenderView.d.ts +3 -1
- package/dist/features/PageRender/PageRenderView.js +25 -3
- package/package.json +3 -3
|
@@ -8,6 +8,7 @@ type Props = {
|
|
|
8
8
|
options?: DropdownMenuItem[];
|
|
9
9
|
className?: string;
|
|
10
10
|
onClick?: () => void;
|
|
11
|
+
dataTour?: string;
|
|
11
12
|
};
|
|
12
|
-
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, }: Props): import("react").JSX.Element;
|
|
13
|
+
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, dataTour, }: Props): import("react").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { DropdownMenu } from 'tycho-storybook';
|
|
4
4
|
import './style.scss';
|
|
5
|
-
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, }) {
|
|
6
|
-
return (_jsxs("div", { className: cx('ds-app-card', className), onClick: onClick, children: [title && (_jsxs("div", { className: "header", children: [_jsx("div", { className: "title", children: title }), extraHeaderActions && (_jsx("div", { className: "extra-header-actions", children: extraHeaderActions })), options && _jsx(DropdownMenu, { list: options })] })), _jsx("div", { className: "body", children: children }), footer && _jsx("div", { className: "footer", children: footer })] }));
|
|
5
|
+
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, dataTour, }) {
|
|
6
|
+
return (_jsxs("div", { className: cx('ds-app-card', className), onClick: onClick, "data-tour": dataTour, children: [title && (_jsxs("div", { className: "header", children: [_jsx("div", { className: "title", children: title }), extraHeaderActions && (_jsx("div", { className: "extra-header-actions", children: extraHeaderActions })), options && _jsx(DropdownMenu, { list: options })] })), _jsx("div", { className: "body", children: children }), footer && _jsx("div", { className: "footer", children: footer })] }));
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { AccessMode } from
|
|
3
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AccessMode } from "../../../configs/types/Access";
|
|
3
|
+
import "./styles.scss";
|
|
4
4
|
export type AccessUsersProps = {
|
|
5
5
|
mode: AccessMode;
|
|
6
6
|
resourceUid: string;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useEffect, useState } from
|
|
3
|
-
import { useTranslation } from
|
|
4
|
-
import { Tag } from
|
|
5
|
-
import { AppCard, AppLoading, AppPicture, AppPlaceholder, AppTable, EMPTY_PAGE, } from
|
|
6
|
-
import DateUtils from
|
|
7
|
-
import AccessControlService from
|
|
8
|
-
import AccessGrant from
|
|
9
|
-
import AccessUser from
|
|
10
|
-
import { EMPTY_ACCESS_SEARCH_FILTER, } from
|
|
11
|
-
import
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { Tag } from "tycho-storybook";
|
|
5
|
+
import { AppCard, AppLoading, AppPicture, AppPlaceholder, AppTable, EMPTY_PAGE, } from "../../../common";
|
|
6
|
+
import DateUtils from "../../../functions/DateUtils";
|
|
7
|
+
import AccessControlService from "../AccessControlService";
|
|
8
|
+
import AccessGrant from "../AccessGrant";
|
|
9
|
+
import AccessUser from "../AccessUser";
|
|
10
|
+
import { EMPTY_ACCESS_SEARCH_FILTER, } from "./AccessUsersFilter";
|
|
11
|
+
import "./styles.scss";
|
|
12
12
|
const STATUS_TAG_COLOR = {
|
|
13
|
-
ACTIVE:
|
|
14
|
-
INACTIVE:
|
|
13
|
+
ACTIVE: "green",
|
|
14
|
+
INACTIVE: "gray",
|
|
15
15
|
};
|
|
16
16
|
const ROLE_TAG_COLOR = {
|
|
17
|
-
ADMIN:
|
|
18
|
-
EDITOR:
|
|
19
|
-
READER:
|
|
17
|
+
ADMIN: "violet",
|
|
18
|
+
EDITOR: "blue",
|
|
19
|
+
READER: "yellow",
|
|
20
20
|
};
|
|
21
21
|
export default function AccessUsers({ mode, resourceUid }) {
|
|
22
|
-
const { t } = useTranslation(
|
|
22
|
+
const { t } = useTranslation("access");
|
|
23
23
|
const [filter, setFilter] = useState(EMPTY_ACCESS_SEARCH_FILTER);
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
const [loading, setLoading] = useState(true);
|
|
@@ -47,8 +47,8 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
47
47
|
});
|
|
48
48
|
const menuOptions = [
|
|
49
49
|
{
|
|
50
|
-
icon:
|
|
51
|
-
label: t(
|
|
50
|
+
icon: "add",
|
|
51
|
+
label: t("common:button.add"),
|
|
52
52
|
onClick: handleCreate,
|
|
53
53
|
},
|
|
54
54
|
];
|
|
@@ -57,7 +57,7 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
57
57
|
};
|
|
58
58
|
const addStatusToCell = (props) => {
|
|
59
59
|
const status = props.row.original.status;
|
|
60
|
-
return (_jsx(Tag, { text: t(`status.label.${status?.toLowerCase() ??
|
|
60
|
+
return (_jsx(Tag, { text: t(`status.label.${status?.toLowerCase() ?? ""}`), color: status ? STATUS_TAG_COLOR[status] : "gray", size: "small" }));
|
|
61
61
|
};
|
|
62
62
|
const addRoleToCell = (props) => {
|
|
63
63
|
const role = props.row.original.role;
|
|
@@ -69,29 +69,29 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
69
69
|
};
|
|
70
70
|
const columns = React.useMemo(() => [
|
|
71
71
|
{
|
|
72
|
-
id:
|
|
73
|
-
header:
|
|
72
|
+
id: "original",
|
|
73
|
+
header: "",
|
|
74
74
|
cell: addImageToCell,
|
|
75
75
|
size: 10,
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
|
-
id:
|
|
79
|
-
header: t(
|
|
78
|
+
id: "name",
|
|
79
|
+
header: t("table.label.name"),
|
|
80
80
|
accessorFn: (row) => row.name || row.email,
|
|
81
81
|
cell: addNameToCell,
|
|
82
82
|
size: 35,
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
id:
|
|
86
|
-
header: t(
|
|
87
|
-
accessorKey:
|
|
85
|
+
id: "status",
|
|
86
|
+
header: t("table.label.status"),
|
|
87
|
+
accessorKey: "status",
|
|
88
88
|
cell: addStatusToCell,
|
|
89
89
|
size: 15,
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
|
-
id:
|
|
93
|
-
header: t(
|
|
94
|
-
accessorKey:
|
|
92
|
+
id: "role",
|
|
93
|
+
header: t("table.label.role"),
|
|
94
|
+
accessorKey: "role",
|
|
95
95
|
cell: addRoleToCell,
|
|
96
96
|
size: 35,
|
|
97
97
|
},
|
|
@@ -99,11 +99,11 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
99
99
|
useEffect(() => {
|
|
100
100
|
paginate();
|
|
101
101
|
}, [filter, resourceUid, mode]);
|
|
102
|
-
return (_jsxs(AppCard, { title: t(
|
|
102
|
+
return (_jsxs(AppCard, { title: t("title.users"), options: menuOptions, className: "access-users-container", "data-tour": "admin-access-users-panel", children: [loading && _jsx(AppLoading, { pageLoading: true }), !loading && data.totalElements > 0 && (_jsx(AppTable, { columns: columns, data: data, className: "users-table", onClickRow: onClickRow, pagination: { pageIndex: filter.page, pageSize: filter.size }, setPagination: (p) => {
|
|
103
103
|
setFilter({ ...filter, page: p.pageIndex, size: p.pageSize });
|
|
104
104
|
}, sorting: filter.sort || [], setSorting: (s) => {
|
|
105
105
|
setFilter({ ...filter, sort: s });
|
|
106
|
-
} })), !loading && data.totalElements === 0 && (_jsx(AppPlaceholder, { text: t(
|
|
106
|
+
} })), !loading && data.totalElements === 0 && (_jsx(AppPlaceholder, { text: t("access.placeholder"), useMarginTop: true })), selected && (_jsx(AccessUser, { mode: mode, resourceUid: resourceUid, user: selected, setItems: setData, onClose: () => {
|
|
107
107
|
setSelected(undefined);
|
|
108
108
|
}, onReload: () => {
|
|
109
109
|
setSelected(undefined);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './style.scss';
|
|
2
|
-
import { CollapsedPageRenderElement, PageRenderViewProps } from './types';
|
|
2
|
+
import { CollapsedPageRenderElement, PageRenderElement, PageRenderViewProps } from './types';
|
|
3
|
+
/** Ensure PARTICIPANT elements carry a sentence uid (API or next-token look-ahead). */
|
|
4
|
+
export declare function withParticipantSentenceUids(elements: PageRenderElement[]): PageRenderElement[];
|
|
3
5
|
export default function PageRenderView({ elements, selectedTier, corpus, displayTags, showLineNumbers, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }: PageRenderViewProps): import("react").JSX.Element;
|
|
4
6
|
export declare function findPunctuationAfterCollapsedJunction(items: CollapsedPageRenderElement[], junctionIndex: number): number | undefined;
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from 'react';
|
|
2
|
+
import { Fragment, useMemo } from 'react';
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import './style.scss';
|
|
5
5
|
import collapseElementsForTier from './collapseElementsForTier';
|
|
6
6
|
import isTokenRefVisible, { tokenRefToToken } from './tokenUtils';
|
|
7
7
|
import { PageRenderElementType, } from './types';
|
|
8
|
+
/** Ensure PARTICIPANT elements carry a sentence uid (API or next-token look-ahead). */
|
|
9
|
+
export function withParticipantSentenceUids(elements) {
|
|
10
|
+
return elements.map((element, index) => {
|
|
11
|
+
if (element.type !== PageRenderElementType.PARTICIPANT ||
|
|
12
|
+
!element.participant ||
|
|
13
|
+
element.uid) {
|
|
14
|
+
return element;
|
|
15
|
+
}
|
|
16
|
+
for (let i = index + 1; i < elements.length; i++) {
|
|
17
|
+
const next = elements[i];
|
|
18
|
+
if (next.type === PageRenderElementType.PARTICIPANT)
|
|
19
|
+
break;
|
|
20
|
+
if (next.token?.uid) {
|
|
21
|
+
return { ...element, uid: next.token.uid };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return element;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
8
27
|
export default function PageRenderView({ elements, selectedTier, corpus, displayTags = false, showLineNumbers = true, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }) {
|
|
9
|
-
const
|
|
28
|
+
const elementsWithUids = useMemo(() => withParticipantSentenceUids(elements), [elements]);
|
|
29
|
+
const collapsed = collapseElementsForTier(elementsWithUids, selectedTier, corpus);
|
|
10
30
|
const punctuationBeforeBreak = new Map();
|
|
11
31
|
const punctuationIndexes = new Set();
|
|
12
32
|
collapsed.forEach((item, index) => {
|
|
@@ -74,9 +94,11 @@ function PageRenderElementItem({ item, highlight, showLineNumbers, displayTags,
|
|
|
74
94
|
return (_jsx("span", { className: "participant", style: getParticipantColor
|
|
75
95
|
? { backgroundColor: getParticipantColor(element.participant) }
|
|
76
96
|
: undefined, onMouseEnter: () => onParticipantHover?.(element.participant), onMouseLeave: () => onParticipantHover?.(undefined), onClick: (event) => {
|
|
77
|
-
if (!onParticipantClick
|
|
97
|
+
if (!onParticipantClick)
|
|
78
98
|
return;
|
|
79
99
|
event.stopPropagation();
|
|
100
|
+
if (!element.uid)
|
|
101
|
+
return;
|
|
80
102
|
onParticipantClick(element.participant, element.uid);
|
|
81
103
|
}, children: getParticipantName
|
|
82
104
|
? getParticipantName(element.participant)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.46.
|
|
4
|
+
"version": "0.46.3",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"react-i18next": "^13.0.2",
|
|
91
91
|
"react-router-dom": "^6.14.2",
|
|
92
92
|
"react-toastify": "^9.1.3",
|
|
93
|
-
"tycho-storybook": "0.12.
|
|
93
|
+
"tycho-storybook": "0.12.8",
|
|
94
94
|
"wavesurfer-react": "^2.2.2",
|
|
95
95
|
"wavesurfer.js": "^6.6.3"
|
|
96
96
|
},
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"react-toastify": "^9.1.3",
|
|
121
121
|
"sass-embedded": "^1.97.2",
|
|
122
122
|
"storybook": "^10.1.11",
|
|
123
|
-
"tycho-storybook": "^0.12.
|
|
123
|
+
"tycho-storybook": "^0.12.8",
|
|
124
124
|
"typescript": "^5.7.3",
|
|
125
125
|
"vite": "^7.0.0",
|
|
126
126
|
"vitest": "^3.2.6",
|