@headless-adminapp/fluent 1.4.17 → 1.4.19
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/App/AppHeaderContianer.js +2 -3
- package/App/Navigation/NavCategoryItemComponent.js +1 -2
- package/App/Navigation/NavItemComponent.js +1 -2
- package/App/Navigation/NavSubItemComponent.js +1 -2
- package/App/Navigation/NavigationContainer.js +4 -5
- package/DataGrid/GridPaginationContainer.js +58 -5
- package/DataGrid/GridTableContainer.js +4 -1
- package/DataGrid/TableCell/TableCellChoice.d.ts +7 -0
- package/DataGrid/TableCell/TableCellChoice.js +6 -1
- package/DataGrid/TableCell/TableCellLink.d.ts +8 -1
- package/DataGrid/TableCell/TableCellLink.js +27 -23
- package/DataGrid/TableCell/TableCellText.d.ts +2 -1
- package/DataGrid/TableCell/TableCellText.js +10 -13
- package/DataGrid/TableCell/TableCellWrapper.d.ts +9 -0
- package/DataGrid/TableCell/TableCellWrapper.js +90 -0
- package/DataGrid/TableCell/utils.d.ts +9 -0
- package/DataGrid/TableCell/utils.js +29 -0
- package/DataGrid/useDataGridKeyboardEvent.d.ts +2 -0
- package/DataGrid/useDataGridKeyboardEvent.js +95 -0
- package/DataGrid/useTableColumns.d.ts +1 -8
- package/DataGrid/useTableColumns.js +60 -52
- package/Insights/WidgetTableContainer.js +8 -14
- package/package.json +2 -3
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppHeaderContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
7
6
|
const app_1 = require("@headless-adminapp/app/app");
|
|
8
7
|
const hooks_1 = require("@headless-adminapp/app/auth/hooks");
|
|
9
8
|
const useIsSkipAuthCheck_1 = require("@headless-adminapp/app/auth/hooks/useIsSkipAuthCheck");
|
|
@@ -28,7 +27,7 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
28
27
|
exports.AppHeaderContainer = AppHeaderContainer;
|
|
29
28
|
const NavHamburger = ({ onNavToggle }) => {
|
|
30
29
|
const isMobile = (0, hooks_2.useIsMobile)();
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Hamburger, { style: {
|
|
32
31
|
color: 'inherit',
|
|
33
32
|
width: !isMobile ? 44 : undefined,
|
|
34
33
|
maxWidth: !isMobile ? 44 : undefined,
|
|
@@ -37,7 +36,7 @@ const NavHamburger = ({ onNavToggle }) => {
|
|
|
37
36
|
const NavBackButton = () => {
|
|
38
37
|
const isMobile = (0, hooks_2.useIsMobile)();
|
|
39
38
|
const router = (0, route_1.useRouter)();
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Hamburger, { style: {
|
|
41
40
|
color: 'inherit',
|
|
42
41
|
width: !isMobile ? 44 : undefined,
|
|
43
42
|
maxWidth: !isMobile ? 44 : undefined,
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NavCategoryItemComponent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
7
6
|
const icons_1 = require("@headless-adminapp/icons");
|
|
8
7
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
9
8
|
activeNavCategoryItem: {
|
|
@@ -15,6 +14,6 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
15
14
|
const NavCategoryItemComponent = ({ item, isActive, }) => {
|
|
16
15
|
const styles = useStyles();
|
|
17
16
|
const Icon = item.Icon ?? icons_1.IconPlaceholder;
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.NavCategoryItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { filled: isActive, color: isActive ? 'var(--colorNeutralForeground2BrandSelected)' : undefined }), className: isActive ? styles.activeNavCategoryItem : undefined, children: item.label }));
|
|
19
18
|
};
|
|
20
19
|
exports.NavCategoryItemComponent = NavCategoryItemComponent;
|
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NavItemComponent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
7
6
|
const usePrefetch_1 = require("./usePrefetch");
|
|
8
7
|
const NavItemComponent = ({ item, onClick, isMini, }) => {
|
|
9
8
|
(0, usePrefetch_1.usePrefetch)(item);
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.NavItem, { href: item.link, onClick: (event) => {
|
|
11
10
|
event.preventDefault();
|
|
12
11
|
onClick(item);
|
|
13
12
|
}, style: {
|
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NavSubItemComponent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
7
6
|
const usePrefetch_1 = require("./usePrefetch");
|
|
8
7
|
const NavSubItemComponent = ({ item, onClick, }) => {
|
|
9
8
|
(0, usePrefetch_1.usePrefetch)(item);
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.NavSubItem, { href: item.link, onClick: (event) => {
|
|
11
10
|
event.preventDefault();
|
|
12
11
|
onClick(item);
|
|
13
12
|
}, style: {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NavigationContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
7
6
|
const app_1 = require("@headless-adminapp/app/app");
|
|
8
7
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
9
8
|
const hooks_1 = require("@headless-adminapp/app/route/hooks");
|
|
@@ -58,17 +57,17 @@ const NavigationContainer = ({ open, type, onOpenChange, isMini, }) => {
|
|
|
58
57
|
router.push(item.link);
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: styles.root, children: (0, jsx_runtime_1.jsx)(
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: styles.root, children: (0, jsx_runtime_1.jsx)(react_components_1.NavDrawer, { selectedValue: "active", selectedCategoryValue: "active", defaultOpenCategories: ['active'], open: open || isMini, type: type, onOpenChange: (_value, data) => onOpenChange(data.open), onNavItemSelect: () => {
|
|
62
61
|
// do nothing
|
|
63
|
-
}, style: { width: isMini ? 60 : undefined }, children: (0, jsx_runtime_1.jsx)(
|
|
62
|
+
}, style: { width: isMini ? 60 : undefined }, children: (0, jsx_runtime_1.jsx)(react_components_1.NavDrawerBody, { style: {
|
|
64
63
|
paddingTop: 8,
|
|
65
|
-
}, children: sections.map((section, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!section.hideLabel && !isMini && ((0, jsx_runtime_1.jsx)(
|
|
64
|
+
}, children: sections.map((section, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!section.hideLabel && !isMini && ((0, jsx_runtime_1.jsx)(react_components_1.NavSectionHeader, { children: section.label })), isMini && index > 0 && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.5 } }) })), section.items.map((item) => {
|
|
66
65
|
if (item.type === app_2.PageType.Category) {
|
|
67
66
|
const isActive = item.items.some((subItem) => subItem.active);
|
|
68
67
|
if (isMini) {
|
|
69
68
|
return ((0, jsx_runtime_1.jsx)(NavMiniCategoryMenu_1.NavMiniCategoryMenu, { isActive: isActive, item: item, onSelect: handleNavigation }, item.key));
|
|
70
69
|
}
|
|
71
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.NavCategory, { value: isActive ? 'active' : '', children: [(0, jsx_runtime_1.jsx)(NavCategoryItemComponent_1.NavCategoryItemComponent, { item: item, isActive: isActive }), (0, jsx_runtime_1.jsx)(react_components_1.NavSubItemGroup, { children: item.items.map((subItem) => ((0, jsx_runtime_1.jsx)(NavSubItemComponent_1.NavSubItemComponent, { item: subItem, onClick: handleNavigation }, subItem.key))) })] }, item.key));
|
|
72
71
|
}
|
|
73
72
|
return ((0, jsx_runtime_1.jsx)(NavItemComponent_1.NavItemComponent, { item: item, onClick: handleNavigation, isMini: isMini }, item.key));
|
|
74
73
|
})] }, section.label))) }) }) }));
|
|
@@ -3,17 +3,70 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GridPaginationContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
6
7
|
const hooks_1 = require("@headless-adminapp/app/datagrid/hooks");
|
|
8
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
9
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
10
|
const react_1 = require("react");
|
|
11
|
+
const formatters_1 = require("../Insights/charts/formatters");
|
|
8
12
|
const PageEntityViewStringContext_1 = require("../PageEntityView/PageEntityViewStringContext");
|
|
9
13
|
const GridPaginationContainer = () => {
|
|
10
14
|
const data = (0, hooks_1.useGridData)();
|
|
11
15
|
const [selectedIds] = (0, hooks_1.useGridSelection)();
|
|
12
16
|
const strings = (0, PageEntityViewStringContext_1.usePageEntityViewStrings)();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const locale = (0, locale_1.useLocale)();
|
|
18
|
+
const leftSideItems = [];
|
|
19
|
+
const rightSideItems = [];
|
|
20
|
+
leftSideItems.push({
|
|
21
|
+
label: strings.records,
|
|
22
|
+
value: data?.count ?? '-',
|
|
23
|
+
});
|
|
24
|
+
leftSideItems.push({
|
|
25
|
+
label: strings.loaded,
|
|
26
|
+
value: data?.records.length ?? '-',
|
|
27
|
+
});
|
|
28
|
+
if (data?.count && selectedIds.length) {
|
|
29
|
+
leftSideItems.push({
|
|
30
|
+
label: strings.selected,
|
|
31
|
+
value: selectedIds.length,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const range = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.cellSelectionRange);
|
|
35
|
+
const gridColumns = (0, hooks_1.useGridColumns)();
|
|
36
|
+
const schema = (0, hooks_1.useDataGridSchema)();
|
|
37
|
+
if (range &&
|
|
38
|
+
range.start.column === range.end.column &&
|
|
39
|
+
range.start.row !== range.end.row) {
|
|
40
|
+
const startRowIndex = Math.min(range.start.row, range.end.row);
|
|
41
|
+
const endRowIndex = Math.max(range.start.row, range.end.row);
|
|
42
|
+
const columnIndex = range.start.column;
|
|
43
|
+
const column = gridColumns[columnIndex];
|
|
44
|
+
const attribute = schema.attributes[column.name];
|
|
45
|
+
rightSideItems.push({
|
|
46
|
+
label: 'Count',
|
|
47
|
+
value: endRowIndex - startRowIndex + 1,
|
|
48
|
+
});
|
|
49
|
+
if (attribute.type === 'money') {
|
|
50
|
+
const total = data?.records
|
|
51
|
+
.slice(startRowIndex, endRowIndex + 1)
|
|
52
|
+
.reduce((sum, record) => {
|
|
53
|
+
return sum + (record[column.name] ?? 0);
|
|
54
|
+
}, 0);
|
|
55
|
+
rightSideItems.push({
|
|
56
|
+
label: 'Sum',
|
|
57
|
+
value: (0, formatters_1.formatCurrency)(locale, total),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: {
|
|
62
|
+
color: react_components_1.tokens.colorNeutralForeground3,
|
|
63
|
+
display: 'flex',
|
|
64
|
+
gap: 8,
|
|
65
|
+
}, children: leftSideItems.map((item, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index > 0 && (0, jsx_runtime_1.jsx)("span", { children: "|" }), (0, jsx_runtime_1.jsxs)("span", { children: [item.label, ": ", item.value] })] }, index))) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: {
|
|
66
|
+
color: react_components_1.tokens.colorNeutralForeground3,
|
|
67
|
+
display: 'flex',
|
|
68
|
+
justifyContent: 'flex-end',
|
|
69
|
+
gap: 8,
|
|
70
|
+
}, children: rightSideItems.map((item, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index > 0 && (0, jsx_runtime_1.jsx)("span", { children: "|" }), (0, jsx_runtime_1.jsxs)("span", { children: [item.label, ": ", item.value] })] }, index))) })] }));
|
|
18
71
|
};
|
|
19
72
|
exports.GridPaginationContainer = GridPaginationContainer;
|
|
@@ -16,6 +16,7 @@ const react_1 = require("react");
|
|
|
16
16
|
const uuid_1 = require("uuid");
|
|
17
17
|
const PageEntityViewStringContext_1 = require("../PageEntityView/PageEntityViewStringContext");
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
|
+
const useDataGridKeyboardEvent_1 = require("./useDataGridKeyboardEvent");
|
|
19
20
|
const useTableColumns_1 = require("./useTableColumns");
|
|
20
21
|
const utils_1 = require("./utils");
|
|
21
22
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
@@ -199,6 +200,7 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
199
200
|
if (isScrollNearBottom)
|
|
200
201
|
handlePseudoResize();
|
|
201
202
|
}, [isScrollNearBottom, virtualItems.length, handlePseudoResize]);
|
|
203
|
+
(0, useDataGridKeyboardEvent_1.useDataGridKeyboardEvent)(tableElementRef);
|
|
202
204
|
const isScrolledToRight = tableWrapperRef.current?.parentElement?.parentElement?.scrollLeft ===
|
|
203
205
|
(tableWrapperRef.current?.parentElement?.parentElement?.scrollWidth ?? 0) -
|
|
204
206
|
(tableWrapperRef.current?.parentElement?.parentElement?.clientWidth ?? 0);
|
|
@@ -217,7 +219,8 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
217
219
|
['--action-shadow']: !isScrolledToRight
|
|
218
220
|
? '-2px 0px 6px rgba(0, 0, 0, 0.12)'
|
|
219
221
|
: 'none',
|
|
220
|
-
|
|
222
|
+
userSelect: 'none',
|
|
223
|
+
}, ref: tableElementRef, tabIndex: 0, className: "table-pseduo", children: [(0, jsx_runtime_1.jsx)(react_components_1.TableHeader, { style: {
|
|
221
224
|
display: 'flex',
|
|
222
225
|
position: 'sticky',
|
|
223
226
|
top: 0,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChoiceAttribute } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { FC } from 'react';
|
|
2
3
|
import { CellDisplayType } from './TableCellBase';
|
|
3
4
|
interface TableCellChoiceProps {
|
|
4
5
|
value: unknown;
|
|
@@ -8,4 +9,10 @@ interface TableCellChoiceProps {
|
|
|
8
9
|
display?: CellDisplayType;
|
|
9
10
|
}
|
|
10
11
|
export declare function TableCellChoice(props: Readonly<TableCellChoiceProps>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
interface TableCellChoiceContentProps {
|
|
13
|
+
attribute: ChoiceAttribute<string | number>;
|
|
14
|
+
formattedValue: string;
|
|
15
|
+
value: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare const TableCellChoiceContent: FC<TableCellChoiceContentProps>;
|
|
11
18
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableCellChoiceContent = void 0;
|
|
3
4
|
exports.TableCellChoice = TableCellChoice;
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const ChoiceBadge_1 = require("../../components/ChoiceBadge");
|
|
@@ -12,5 +13,9 @@ function TableCellChoice(props) {
|
|
|
12
13
|
width: props.width,
|
|
13
14
|
minWidth: props.width,
|
|
14
15
|
maxWidth: props.width,
|
|
15
|
-
}, display: props.display, children: (0, jsx_runtime_1.jsx)(
|
|
16
|
+
}, display: props.display, children: (0, jsx_runtime_1.jsx)(exports.TableCellChoiceContent, { attribute: props.attribute, formattedValue: props.formattedValue, value: props.value }) }));
|
|
16
17
|
}
|
|
18
|
+
const TableCellChoiceContent = (props) => {
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(ChoiceBadge_1.ChoiceBadge, { attribute: props.attribute, formattedValue: props.formattedValue, value: props.value }));
|
|
20
|
+
};
|
|
21
|
+
exports.TableCellChoiceContent = TableCellChoiceContent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { CellDisplayType } from './TableCellBase';
|
|
3
3
|
export interface TableCellLinkProps {
|
|
4
4
|
value: React.ReactNode | undefined | null;
|
|
@@ -9,3 +9,10 @@ export interface TableCellLinkProps {
|
|
|
9
9
|
display?: CellDisplayType;
|
|
10
10
|
}
|
|
11
11
|
export declare const TableCellLink: FC<TableCellLinkProps>;
|
|
12
|
+
interface TableCellLinkContentProps {
|
|
13
|
+
target?: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
onClick?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const TableCellLinkContent: FC<PropsWithChildren<TableCellLinkContentProps>>;
|
|
18
|
+
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TableCellLink = void 0;
|
|
3
|
+
exports.TableCellLinkContent = exports.TableCellLink = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const hooks_1 = require("@headless-adminapp/app/route/hooks");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target, display = 'flex' }) => {
|
|
9
|
-
const router = (0, hooks_1.useRouter)();
|
|
10
9
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
11
10
|
textOverflow: 'ellipsis',
|
|
12
11
|
overflow: 'hidden',
|
|
@@ -17,26 +16,31 @@ exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target
|
|
|
17
16
|
display,
|
|
18
17
|
alignItems: 'center',
|
|
19
18
|
height: '100%',
|
|
20
|
-
}, children: (0, jsx_runtime_1.jsx)(
|
|
21
|
-
if (target === '_blank') {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (event.metaKey || event.ctrlKey) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (onClick) {
|
|
28
|
-
event.preventDefault();
|
|
29
|
-
onClick();
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (href?.startsWith('/')) {
|
|
33
|
-
router.push(href);
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
}
|
|
36
|
-
}, style: {
|
|
37
|
-
display: 'flex',
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
40
|
-
}, children: value }) }));
|
|
19
|
+
}, children: (0, jsx_runtime_1.jsx)(exports.TableCellLinkContent, { target: target, href: href, onClick: onClick, children: value }) }));
|
|
41
20
|
});
|
|
42
21
|
exports.TableCellLink.displayName = 'TableCellLink';
|
|
22
|
+
const TableCellLinkContent = ({ children, target, href, onClick }) => {
|
|
23
|
+
const router = (0, hooks_1.useRouter)();
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, target: target, onClick: (event) => {
|
|
25
|
+
if (target === '_blank') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (event.metaKey || event.ctrlKey) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (onClick) {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
onClick();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (href?.startsWith('/')) {
|
|
37
|
+
router.push(href);
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
}, style: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
44
|
+
}, children: children }));
|
|
45
|
+
};
|
|
46
|
+
exports.TableCellLinkContent = TableCellLinkContent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { CellDisplayType } from './TableCellBase';
|
|
3
3
|
export interface TableCellTextProps {
|
|
4
4
|
value: string;
|
|
@@ -7,3 +7,4 @@ export interface TableCellTextProps {
|
|
|
7
7
|
display?: CellDisplayType;
|
|
8
8
|
}
|
|
9
9
|
export declare const TableCellText: FC<TableCellTextProps>;
|
|
10
|
+
export declare const TableCellTextContent: FC<PropsWithChildren>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TableCellText = void 0;
|
|
3
|
+
exports.TableCellTextContent = exports.TableCellText = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const TableCellBase_1 = require("./TableCellBase");
|
|
@@ -10,20 +10,17 @@ exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment, displa
|
|
|
10
10
|
textOverflow: 'ellipsis',
|
|
11
11
|
overflow: 'hidden',
|
|
12
12
|
whiteSpace: 'nowrap',
|
|
13
|
-
// maxWidth: 50,
|
|
14
|
-
// width: 50,
|
|
15
|
-
// width: '100%',
|
|
16
13
|
width,
|
|
17
14
|
minWidth: width,
|
|
18
15
|
maxWidth: width,
|
|
19
|
-
|
|
20
|
-
// display: 'flex',
|
|
21
|
-
// alignItems: 'center',
|
|
22
|
-
// borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke3}`,
|
|
23
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
24
|
-
overflow: 'hidden',
|
|
25
|
-
textOverflow: 'ellipsis',
|
|
26
|
-
width: '100%',
|
|
27
|
-
}, children: value }) }));
|
|
16
|
+
}, children: (0, jsx_runtime_1.jsx)(exports.TableCellTextContent, { children: value }) }));
|
|
28
17
|
});
|
|
29
18
|
exports.TableCellText.displayName = 'TableCellText';
|
|
19
|
+
const TableCellTextContent = ({ children }) => {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
textOverflow: 'ellipsis',
|
|
23
|
+
width: '100%',
|
|
24
|
+
}, children: children }));
|
|
25
|
+
};
|
|
26
|
+
exports.TableCellTextContent = TableCellTextContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
interface TableCellWrapperProps {
|
|
3
|
+
rowIndex: number;
|
|
4
|
+
columnIndex: number;
|
|
5
|
+
textAlignment?: 'left' | 'center' | 'right';
|
|
6
|
+
width?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const TableCellWrapper: FC<PropsWithChildren<TableCellWrapperProps>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableCellWrapper = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
7
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
function isCellSelected(rowIndex, columnIndex, range) {
|
|
11
|
+
if (rowIndex < 0 || columnIndex < 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const rowStart = Math.min(range.start.row, range.end.row);
|
|
15
|
+
const rowEnd = Math.max(range.start.row, range.end.row);
|
|
16
|
+
const columnStart = Math.min(range.start.column, range.end.column);
|
|
17
|
+
const columnEnd = Math.max(range.start.column, range.end.column);
|
|
18
|
+
return (rowStart <= rowIndex &&
|
|
19
|
+
rowEnd >= rowIndex &&
|
|
20
|
+
columnStart <= columnIndex &&
|
|
21
|
+
columnEnd >= columnIndex);
|
|
22
|
+
}
|
|
23
|
+
const TableCellWrapper = ({ children, rowIndex, columnIndex, textAlignment, width, }) => {
|
|
24
|
+
const range = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.cellSelectionRange);
|
|
25
|
+
const setValue = (0, mutable_1.useContextSetValue)(datagrid_1.GridContext);
|
|
26
|
+
const selectionInfo = (0, react_1.useMemo)(() => {
|
|
27
|
+
if (!range)
|
|
28
|
+
return;
|
|
29
|
+
const isSelectedCell = isCellSelected(rowIndex, columnIndex, range);
|
|
30
|
+
if (!isSelectedCell)
|
|
31
|
+
return;
|
|
32
|
+
const isLeftCellSelected = isCellSelected(rowIndex, columnIndex - 1, range);
|
|
33
|
+
const isRightCellSelected = isCellSelected(rowIndex, columnIndex + 1, range);
|
|
34
|
+
const isAboveCellSelected = isCellSelected(rowIndex - 1, columnIndex, range);
|
|
35
|
+
const isBelowCellSelected = isCellSelected(rowIndex + 1, columnIndex, range);
|
|
36
|
+
return {
|
|
37
|
+
selected: isSelectedCell,
|
|
38
|
+
left: !isLeftCellSelected,
|
|
39
|
+
right: !isRightCellSelected,
|
|
40
|
+
top: !isAboveCellSelected,
|
|
41
|
+
bottom: !isBelowCellSelected,
|
|
42
|
+
};
|
|
43
|
+
}, [range, rowIndex, columnIndex]);
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
45
|
+
display: 'flex',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
height: '100%',
|
|
48
|
+
textAlign: textAlignment ?? 'left',
|
|
49
|
+
textOverflow: 'ellipsis',
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
whiteSpace: 'nowrap',
|
|
52
|
+
width,
|
|
53
|
+
minWidth: width,
|
|
54
|
+
maxWidth: width,
|
|
55
|
+
...(0, utils_1.getSelectedCellStyle)(selectionInfo),
|
|
56
|
+
}, onMouseDown: (e) => {
|
|
57
|
+
if (e.button !== 0)
|
|
58
|
+
return; // Only handle left mouse button
|
|
59
|
+
if (e.shiftKey && range) {
|
|
60
|
+
// change end
|
|
61
|
+
setValue({
|
|
62
|
+
cellSelectionRange: {
|
|
63
|
+
start: range.start,
|
|
64
|
+
end: { row: rowIndex, column: columnIndex },
|
|
65
|
+
active: true,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
setValue({
|
|
71
|
+
cellSelectionRange: {
|
|
72
|
+
start: { row: rowIndex, column: columnIndex },
|
|
73
|
+
end: { row: rowIndex, column: columnIndex },
|
|
74
|
+
active: true,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, onMouseEnter: (e) => {
|
|
79
|
+
if (range?.active) {
|
|
80
|
+
setValue({
|
|
81
|
+
cellSelectionRange: {
|
|
82
|
+
start: range.start,
|
|
83
|
+
end: { row: rowIndex, column: columnIndex },
|
|
84
|
+
active: true,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, children: children }));
|
|
89
|
+
};
|
|
90
|
+
exports.TableCellWrapper = TableCellWrapper;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface SelectionInfo {
|
|
3
|
+
selected?: boolean;
|
|
4
|
+
left?: boolean;
|
|
5
|
+
right?: boolean;
|
|
6
|
+
top?: boolean;
|
|
7
|
+
bottom?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function getSelectedCellStyle(info: SelectionInfo | undefined): Pick<CSSProperties, "backgroundColor" | "boxShadow"> | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSelectedCellStyle = getSelectedCellStyle;
|
|
4
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
5
|
+
function getSelectedCellStyle(info) {
|
|
6
|
+
if (!info)
|
|
7
|
+
return;
|
|
8
|
+
const styles = {};
|
|
9
|
+
if (info.selected) {
|
|
10
|
+
styles.backgroundColor = `color-mix(in srgb, ${react_components_1.tokens.colorBrandBackground2} 60%, transparent)`;
|
|
11
|
+
}
|
|
12
|
+
const shadows = [];
|
|
13
|
+
if (info.left) {
|
|
14
|
+
shadows.push(`inset 1px 0 0 ${react_components_1.tokens.colorBrandStroke1}`);
|
|
15
|
+
}
|
|
16
|
+
if (info.right) {
|
|
17
|
+
shadows.push(`inset -1px 0 0 ${react_components_1.tokens.colorBrandStroke1}`);
|
|
18
|
+
}
|
|
19
|
+
if (info.top) {
|
|
20
|
+
shadows.push(`inset 0 1px 0 ${react_components_1.tokens.colorBrandStroke1}`);
|
|
21
|
+
}
|
|
22
|
+
if (info.bottom) {
|
|
23
|
+
shadows.push(`inset 0 -1px 0 ${react_components_1.tokens.colorBrandStroke1}`);
|
|
24
|
+
}
|
|
25
|
+
if (shadows.length > 0) {
|
|
26
|
+
styles.boxShadow = shadows.join(', ');
|
|
27
|
+
}
|
|
28
|
+
return styles;
|
|
29
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDataGridKeyboardEvent = useDataGridKeyboardEvent;
|
|
4
|
+
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
5
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
6
|
+
const metadata_1 = require("@headless-adminapp/app/metadata");
|
|
7
|
+
const utils_1 = require("@headless-adminapp/app/utils");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
function useDataGridKeyboardEvent(tableElementRef) {
|
|
10
|
+
const context = (0, react_1.useContext)(datagrid_1.GridContext);
|
|
11
|
+
const locale = (0, locale_1.useLocale)();
|
|
12
|
+
const { schemaStore } = (0, metadata_1.useMetadata)();
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
const contextValue = context.value;
|
|
15
|
+
const isTableActive = function () {
|
|
16
|
+
if (!tableElementRef.current)
|
|
17
|
+
return;
|
|
18
|
+
let activeElement = document.activeElement;
|
|
19
|
+
while (activeElement && activeElement !== tableElementRef.current) {
|
|
20
|
+
activeElement = activeElement?.parentElement;
|
|
21
|
+
}
|
|
22
|
+
return activeElement === tableElementRef.current;
|
|
23
|
+
};
|
|
24
|
+
const handleCopy = async (e) => {
|
|
25
|
+
const range = contextValue.current.cellSelectionRange;
|
|
26
|
+
const data = contextValue.current.data;
|
|
27
|
+
const gridColumns = contextValue.current.columns;
|
|
28
|
+
const schema = contextValue.current.schema;
|
|
29
|
+
if (!range) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!isTableActive()) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
const startRowIndex = Math.min(range.start.row, range.end.row);
|
|
37
|
+
const endRowIndex = Math.max(range.start.row, range.end.row);
|
|
38
|
+
const startColumnIndex = Math.min(range.start.column, range.end.column);
|
|
39
|
+
const endColumnIndex = Math.max(range.start.column, range.end.column);
|
|
40
|
+
const lineItems = [];
|
|
41
|
+
for (let rowIndex = startRowIndex; rowIndex <= endRowIndex; rowIndex++) {
|
|
42
|
+
const rowItems = [];
|
|
43
|
+
for (let colIndex = startColumnIndex; colIndex <= endColumnIndex; colIndex++) {
|
|
44
|
+
const column = gridColumns[colIndex];
|
|
45
|
+
let attribute = schema.attributes[column.name];
|
|
46
|
+
let value = data?.records[rowIndex]?.[column.name];
|
|
47
|
+
if (column.expandedKey) {
|
|
48
|
+
const lookup = column.name;
|
|
49
|
+
const field = column.expandedKey;
|
|
50
|
+
const entity = schema.attributes[lookup]
|
|
51
|
+
.entity;
|
|
52
|
+
const lookupSchema = schemaStore.getSchema(entity);
|
|
53
|
+
attribute = lookupSchema.attributes[field];
|
|
54
|
+
value = data?.records[rowIndex]?.$expand?.[lookup]?.[field];
|
|
55
|
+
}
|
|
56
|
+
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value, locale);
|
|
57
|
+
rowItems.push(formattedValue ?? '');
|
|
58
|
+
}
|
|
59
|
+
lineItems.push(rowItems.join('\t'));
|
|
60
|
+
}
|
|
61
|
+
await navigator.clipboard.writeText(lineItems.join('\n'));
|
|
62
|
+
};
|
|
63
|
+
const handleSelectAll = (e) => {
|
|
64
|
+
if (!contextValue.current.data?.records.length) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!isTableActive()) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
context.setValue({
|
|
72
|
+
cellSelectionRange: {
|
|
73
|
+
start: { row: 0, column: 0 },
|
|
74
|
+
end: {
|
|
75
|
+
row: contextValue.current.data.records.length - 1,
|
|
76
|
+
column: contextValue.current.columns.length - 1,
|
|
77
|
+
},
|
|
78
|
+
active: false,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const handleKeyDown = async (e) => {
|
|
83
|
+
if ((e.ctrlKey || e.metaKey) && e.key === 'c') {
|
|
84
|
+
await handleCopy(e);
|
|
85
|
+
}
|
|
86
|
+
else if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
|
|
87
|
+
handleSelectAll(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
91
|
+
return () => {
|
|
92
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
93
|
+
};
|
|
94
|
+
}, [tableElementRef, context, locale, schemaStore]);
|
|
95
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { TransformedViewColumn } from '@headless-adminapp/app/datagrid';
|
|
2
1
|
import { InternalRouteResolver, RouterInstance } from '@headless-adminapp/app/route/context';
|
|
3
2
|
import { LookupAttribute } from '@headless-adminapp/core/attributes';
|
|
4
|
-
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
5
3
|
import { ISchemaStore } from '@headless-adminapp/core/store';
|
|
6
|
-
import { CellContext } from '@tanstack/react-table';
|
|
7
|
-
import { CellDisplayType } from './TableCell';
|
|
8
4
|
import { UniqueRecord } from './types';
|
|
9
5
|
export declare function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }: {
|
|
10
6
|
disableSelection?: boolean;
|
|
@@ -14,14 +10,11 @@ export declare function useTableColumns({ disableSelection, disableContextMenu,
|
|
|
14
10
|
disableColumnSort?: boolean;
|
|
15
11
|
tableWrapperRef: React.RefObject<HTMLDivElement>;
|
|
16
12
|
}): import("@tanstack/react-table").AccessorFnColumnDef<UniqueRecord, unknown>[];
|
|
17
|
-
export declare function renderLookupAttribute({ value,
|
|
13
|
+
export declare function renderLookupAttribute({ value, schemaStore, routeResolver, router, attribute, formattedValue, }: {
|
|
18
14
|
value: unknown;
|
|
19
|
-
info?: CellContext<UniqueRecord, unknown>;
|
|
20
|
-
column?: TransformedViewColumn<SchemaAttributes>;
|
|
21
15
|
schemaStore: ISchemaStore;
|
|
22
16
|
routeResolver: InternalRouteResolver;
|
|
23
17
|
router: RouterInstance;
|
|
24
18
|
attribute: LookupAttribute;
|
|
25
19
|
formattedValue: string;
|
|
26
|
-
display?: CellDisplayType;
|
|
27
20
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,6 +24,7 @@ const GridColumnHeader_1 = require("./GridColumnHeader");
|
|
|
24
24
|
const TableCell_1 = require("./TableCell");
|
|
25
25
|
const TableCellChoice_1 = require("./TableCell/TableCellChoice");
|
|
26
26
|
const TableCellLink_1 = require("./TableCell/TableCellLink");
|
|
27
|
+
const TableCellWrapper_1 = require("./TableCell/TableCellWrapper");
|
|
27
28
|
const columnHelper = (0, react_table_1.createColumnHelper)();
|
|
28
29
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
29
30
|
selectionCell: {
|
|
@@ -88,6 +89,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
88
89
|
const router = (0, hooks_4.useRouter)();
|
|
89
90
|
const openRecord = (0, useOpenRecord_1.useOpenRecord)();
|
|
90
91
|
const locale = (0, locale_1.useLocale)();
|
|
92
|
+
const setValue = (0, mutable_1.useContextSetValue)(datagrid_1.GridContext);
|
|
91
93
|
const dataRef = (0, react_1.useRef)(data);
|
|
92
94
|
dataRef.current = data;
|
|
93
95
|
const headingSelectionState = (0, react_1.useMemo)(() => {
|
|
@@ -124,6 +126,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
124
126
|
cell: (info) => ((0, jsx_runtime_1.jsx)(ActionCell_1.ActionCell, { onOpen: () => {
|
|
125
127
|
const id = info.row.original[schema.idAttribute];
|
|
126
128
|
setSelectedIdsRef.current([id]);
|
|
129
|
+
setValue({ cellSelectionRange: null });
|
|
127
130
|
}, mutableState: mutableContextCommandState })),
|
|
128
131
|
enableResizing: false,
|
|
129
132
|
size: 32,
|
|
@@ -145,6 +148,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
145
148
|
}
|
|
146
149
|
return getAllIds();
|
|
147
150
|
});
|
|
151
|
+
setValue({ cellSelectionRange: null });
|
|
148
152
|
}
|
|
149
153
|
function excludeId(ids, id) {
|
|
150
154
|
return ids.filter((i) => i !== id);
|
|
@@ -157,6 +161,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
157
161
|
}
|
|
158
162
|
return [...ids, id];
|
|
159
163
|
});
|
|
164
|
+
setValue({ cellSelectionRange: null });
|
|
160
165
|
}
|
|
161
166
|
return [
|
|
162
167
|
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
@@ -193,6 +198,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
193
198
|
headingSelectionState,
|
|
194
199
|
schema.idAttribute,
|
|
195
200
|
styles.selectionCell,
|
|
201
|
+
setValue,
|
|
196
202
|
]);
|
|
197
203
|
const restColumns = (0, react_1.useMemo)(() => {
|
|
198
204
|
return gridColumns.map((column, index) => {
|
|
@@ -228,6 +234,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
228
234
|
primaryAttributeName: schema.primaryAttribute,
|
|
229
235
|
idAttributeName: schema.idAttribute,
|
|
230
236
|
avatarAttributeName: schema.avatarAttribute,
|
|
237
|
+
disableSelection,
|
|
231
238
|
}),
|
|
232
239
|
enableResizing: true,
|
|
233
240
|
size: columnWidths[index],
|
|
@@ -248,6 +255,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
248
255
|
routeResolver,
|
|
249
256
|
openRecord,
|
|
250
257
|
router,
|
|
258
|
+
disableSelection,
|
|
251
259
|
]);
|
|
252
260
|
return (0, react_1.useMemo)(() => {
|
|
253
261
|
return [...selectionColumns, ...restColumns, ...actionColumns];
|
|
@@ -256,7 +264,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
256
264
|
function renderCellHeaderContent({ column, props, disableColumnResize, disableColumnFilter, disableColumnSort, onChangeSortDirection, }) {
|
|
257
265
|
return ((0, jsx_runtime_1.jsx)(GridColumnHeader_1.TableHeaderFilterCell, { sortDirection: props.column.getIsSorted(), minWidth: props.header.getSize(), column: column, resizable: !disableColumnResize, disableFilter: disableColumnFilter, disableSort: disableColumnSort, onChangeSortDirection: onChangeSortDirection, onResetSize: props.column.resetSize, resizeHandler: props.header.getResizeHandler(), children: column.label }, column.id));
|
|
258
266
|
}
|
|
259
|
-
function renderCellContent({ info, column, attributes, schemaStore, locale, routeResolver, openRecord, router, primaryAttributeName, idAttributeName, avatarAttributeName, }) {
|
|
267
|
+
function renderCellContent({ info, column, attributes, schemaStore, locale, routeResolver, openRecord, router, primaryAttributeName, idAttributeName, avatarAttributeName, disableSelection, }) {
|
|
260
268
|
let attribute;
|
|
261
269
|
let value;
|
|
262
270
|
if (column.expandedKey) {
|
|
@@ -272,8 +280,10 @@ function renderCellContent({ info, column, attributes, schemaStore, locale, rout
|
|
|
272
280
|
value = info.getValue();
|
|
273
281
|
}
|
|
274
282
|
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value, locale) ?? '';
|
|
283
|
+
const rowIndex = info.row.index;
|
|
284
|
+
const columnIndex = info.column.getIndex() + (disableSelection ? 0 : -1);
|
|
275
285
|
if (column.plainText) {
|
|
276
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
286
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, { children: formattedValue }) }, column.id));
|
|
277
287
|
}
|
|
278
288
|
if (column.component) {
|
|
279
289
|
let Component;
|
|
@@ -303,77 +313,75 @@ function renderCellContent({ info, column, attributes, schemaStore, locale, rout
|
|
|
303
313
|
idAttributeName,
|
|
304
314
|
avatarAttributeName,
|
|
305
315
|
value: value,
|
|
316
|
+
rowIndex,
|
|
317
|
+
columnIndex,
|
|
306
318
|
});
|
|
307
319
|
}
|
|
308
320
|
switch (attribute?.type) {
|
|
309
321
|
case 'money':
|
|
310
322
|
case 'number':
|
|
311
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
323
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, textAlignment: attribute.type === 'number' &&
|
|
312
324
|
['duration', 'time'].includes(attribute.format)
|
|
313
325
|
? 'left'
|
|
314
|
-
: 'right' }, column.id));
|
|
326
|
+
: 'right', children: (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, { children: formattedValue }) }, column.id));
|
|
315
327
|
case 'lookup': {
|
|
316
|
-
return renderLookupAttribute({
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
formattedValue,
|
|
325
|
-
});
|
|
328
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info?.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: renderLookupAttribute({
|
|
329
|
+
schemaStore,
|
|
330
|
+
routeResolver,
|
|
331
|
+
router,
|
|
332
|
+
value,
|
|
333
|
+
attribute,
|
|
334
|
+
formattedValue,
|
|
335
|
+
}) }, column?.id));
|
|
326
336
|
}
|
|
327
337
|
case 'regarding': {
|
|
328
|
-
return renderRegardingAttribute({
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
formattedValue,
|
|
337
|
-
});
|
|
338
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info?.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: renderRegardingAttribute({
|
|
339
|
+
schemaStore,
|
|
340
|
+
routeResolver,
|
|
341
|
+
router,
|
|
342
|
+
value,
|
|
343
|
+
attribute,
|
|
344
|
+
formattedValue,
|
|
345
|
+
}) }, column?.id));
|
|
338
346
|
}
|
|
339
347
|
case 'attachment': {
|
|
340
348
|
const url = value?.url;
|
|
341
349
|
if (!url) {
|
|
342
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
350
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, {}) }, column.id));
|
|
343
351
|
}
|
|
344
|
-
return ((0, jsx_runtime_1.
|
|
352
|
+
return ((0, jsx_runtime_1.jsxs)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: [(0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLinkContent, { href: url, target: "_blank" }), formattedValue] }, column.id));
|
|
345
353
|
}
|
|
346
354
|
case 'choice':
|
|
347
|
-
return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.
|
|
355
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoiceContent, { value: value, attribute: attribute, formattedValue: formattedValue }) }, column.id));
|
|
348
356
|
}
|
|
349
357
|
if (attribute.type === 'string' && attribute.format === 'phone') {
|
|
350
358
|
const parsedNumber = (0, phone_1.parsePhoneNumber)(value, locale.region);
|
|
351
359
|
if (parsedNumber.isValid && parsedNumber.uri) {
|
|
352
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
360
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLinkContent, { href: parsedNumber.uri, children: formattedValue }) }, column.id));
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
if (attribute.type === 'string' &&
|
|
356
364
|
attribute.format === 'email' &&
|
|
357
365
|
value &&
|
|
358
366
|
typeof value === 'string') {
|
|
359
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
367
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLinkContent, { href: `mailto:${value}`, children: formattedValue }) }, column.id));
|
|
360
368
|
}
|
|
361
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
369
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, { children: formattedValue }) }, column.id));
|
|
362
370
|
}
|
|
363
|
-
function renderPrimaryAttribute({ info, column, attributes, routeResolver, openRecord, value, idAttributeName, avatarAttributeName, }) {
|
|
371
|
+
function renderPrimaryAttribute({ info, column, attributes, routeResolver, openRecord, value, idAttributeName, avatarAttributeName, rowIndex, columnIndex, }) {
|
|
364
372
|
const path = routeResolver({
|
|
365
373
|
logicalName: info.row.original.$entity,
|
|
366
374
|
type: app_1.PageType.EntityForm,
|
|
367
375
|
id: info.row.original[idAttributeName],
|
|
368
376
|
});
|
|
369
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
+
return ((0, jsx_runtime_1.jsx)(TableCellWrapper_1.TableCellWrapper, { width: info.column.getSize(), rowIndex: rowIndex, columnIndex: columnIndex, children: (0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLinkContent, { href: path, onClick: () => {
|
|
378
|
+
openRecord?.(info.row.original[idAttributeName], info.row.original.$entity);
|
|
379
|
+
}, children: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [renderPrimaryAttributeAvatar({
|
|
380
|
+
info,
|
|
381
|
+
value,
|
|
382
|
+
avatarAttributeName,
|
|
383
|
+
attributes,
|
|
384
|
+
}), value] }) }) }, column.id));
|
|
377
385
|
}
|
|
378
386
|
function renderPrimaryAttributeAvatar({ info, value, avatarAttributeName, attributes, }) {
|
|
379
387
|
if (!avatarAttributeName) {
|
|
@@ -392,9 +400,9 @@ function renderPrimaryAttributeAvatar({ info, value, avatarAttributeName, attrib
|
|
|
392
400
|
src: avatarValue?.url,
|
|
393
401
|
} }));
|
|
394
402
|
}
|
|
395
|
-
function renderLookupAttribute({ value,
|
|
403
|
+
function renderLookupAttribute({ value, schemaStore, routeResolver, router, attribute, formattedValue, }) {
|
|
396
404
|
if (!value) {
|
|
397
|
-
return (
|
|
405
|
+
return (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, {});
|
|
398
406
|
}
|
|
399
407
|
const lookupSchema = schemaStore.getSchema(attribute.entity);
|
|
400
408
|
const path = routeResolver({
|
|
@@ -402,23 +410,23 @@ function renderLookupAttribute({ value, info, column, schemaStore, routeResolver
|
|
|
402
410
|
type: app_1.PageType.EntityForm,
|
|
403
411
|
id: value.id,
|
|
404
412
|
});
|
|
405
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.
|
|
413
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLinkContent, { href: path, onClick: () => {
|
|
414
|
+
router.push(path);
|
|
415
|
+
}, children: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!!lookupSchema.avatarAttribute && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
406
416
|
width: 24,
|
|
407
417
|
height: 24,
|
|
408
418
|
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
409
419
|
}, name: formattedValue, color: (0, avatar_1.getAvatarColor)(formattedValue), image: {
|
|
410
420
|
src: value.avatar,
|
|
411
|
-
} })), formattedValue] })
|
|
412
|
-
router.push(path);
|
|
413
|
-
} }, column?.id));
|
|
421
|
+
} })), formattedValue] }) }));
|
|
414
422
|
}
|
|
415
|
-
function renderRegardingAttribute({ value,
|
|
423
|
+
function renderRegardingAttribute({ value, schemaStore, routeResolver, router, formattedValue, }) {
|
|
416
424
|
if (!value) {
|
|
417
|
-
return (
|
|
425
|
+
return (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, {});
|
|
418
426
|
}
|
|
419
427
|
const hasSchema = schemaStore.hasSchema(value.logicalName);
|
|
420
428
|
if (!hasSchema) {
|
|
421
|
-
return (
|
|
429
|
+
return (0, jsx_runtime_1.jsx)(TableCell_1.TableCellTextContent, {});
|
|
422
430
|
}
|
|
423
431
|
const logicalName = value.logicalName;
|
|
424
432
|
const lookupSchema = schemaStore.getSchema(logicalName);
|
|
@@ -427,13 +435,13 @@ function renderRegardingAttribute({ value, info, column, schemaStore, routeResol
|
|
|
427
435
|
type: app_1.PageType.EntityForm,
|
|
428
436
|
id: value.id,
|
|
429
437
|
});
|
|
430
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.
|
|
438
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLinkContent, { href: path, onClick: () => {
|
|
439
|
+
router.push(path);
|
|
440
|
+
}, children: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!!lookupSchema.avatarAttribute && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
431
441
|
width: 24,
|
|
432
442
|
height: 24,
|
|
433
443
|
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
434
444
|
}, name: formattedValue, color: (0, avatar_1.getAvatarColor)(formattedValue), image: {
|
|
435
445
|
src: value.avatar,
|
|
436
|
-
} })), formattedValue] })
|
|
437
|
-
router.push(path);
|
|
438
|
-
} }, column.id));
|
|
446
|
+
} })), formattedValue] }) }));
|
|
439
447
|
}
|
|
@@ -71,20 +71,14 @@ const WidgetTable = ({ columns, attributes, data, }) => {
|
|
|
71
71
|
case 'money':
|
|
72
72
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: { textAlign: 'right' }, children: formattedValue }, column));
|
|
73
73
|
case 'lookup':
|
|
74
|
-
return (0, useTableColumns_1.renderLookupAttribute)({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
router,
|
|
83
|
-
routeResolver,
|
|
84
|
-
schemaStore,
|
|
85
|
-
formattedValue,
|
|
86
|
-
display: 'table-cell',
|
|
87
|
-
});
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { children: (0, useTableColumns_1.renderLookupAttribute)({
|
|
75
|
+
value,
|
|
76
|
+
attribute,
|
|
77
|
+
router,
|
|
78
|
+
routeResolver,
|
|
79
|
+
schemaStore,
|
|
80
|
+
formattedValue,
|
|
81
|
+
}) }, column));
|
|
88
82
|
case 'choice':
|
|
89
83
|
return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoice, { value: value, attribute: attribute, formattedValue: formattedValue, display: "table-cell" }, column));
|
|
90
84
|
case 'attachment': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@fluentui/react-calendar-compat": "^0.3.7",
|
|
25
25
|
"@fluentui/react-components": "^9.68.3",
|
|
26
26
|
"@fluentui/react-datepicker-compat": "^0.6.12",
|
|
27
|
-
"@fluentui/react-nav-preview": "^0.13.9",
|
|
28
27
|
"@fluentui/react-timepicker-compat": "^0.4.13",
|
|
29
28
|
"@tanstack/react-query": "^5.84.2"
|
|
30
29
|
},
|
|
@@ -52,5 +51,5 @@
|
|
|
52
51
|
"uuid": "11.0.3",
|
|
53
52
|
"yup": "^1.4.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "65c5192a870badd4de4c135261d5aeafae063756"
|
|
56
55
|
}
|