@headless-adminapp/fluent 1.4.11 → 1.4.13
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 +105 -49
- package/App/QuickActionItem.d.ts +1 -0
- package/App/QuickActionItem.js +7 -3
- package/DataGrid/MobileHeaderRightContainer.d.ts +2 -0
- package/DataGrid/MobileHeaderRightContainer.js +11 -0
- package/DataGrid/TableCell/TableCellBase.d.ts +2 -0
- package/DataGrid/TableCell/TableCellBase.js +2 -2
- package/DataGrid/TableCell/TableCellChoice.d.ts +3 -1
- package/DataGrid/TableCell/TableCellChoice.js +1 -1
- package/DataGrid/TableCell/TableCellLink.d.ts +3 -1
- package/DataGrid/TableCell/TableCellLink.js +2 -2
- package/DataGrid/TableCell/TableCellText.d.ts +3 -1
- package/DataGrid/TableCell/TableCellText.js +2 -2
- package/DataGrid/useTableColumns.d.ts +18 -0
- package/DataGrid/useTableColumns.js +27 -20
- package/Header/MobileHeaderCommandContainer.d.ts +7 -0
- package/Header/MobileHeaderCommandContainer.js +167 -0
- package/Header/MobileHeaderQuickActionButton.d.ts +10 -0
- package/Header/MobileHeaderQuickActionButton.js +36 -0
- package/Insights/Header.js +1 -1
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +62 -30
- package/Insights/WidgetTitleBar.d.ts +2 -1
- package/Insights/WidgetTitleBar.js +3 -3
- package/PageEntityForm/CommandContainer.js +3 -3
- package/PageEntityForm/MobileHeaderRightContainer.d.ts +2 -0
- package/PageEntityForm/MobileHeaderRightContainer.js +11 -0
- package/PageEntityForm/MobileHeaderTitleContainer.d.ts +2 -0
- package/PageEntityForm/MobileHeaderTitleContainer.js +38 -0
- package/PageEntityForm/PageEntityForm.js +2 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.js +89 -74
- package/PageEntityForm/TabContainer.d.ts +2 -0
- package/PageEntityForm/TabContainer.js +35 -0
- package/PageEntityView/PageEntityView.js +4 -1
- package/PageEntityView/PageEntityViewMobileContainer.js +1 -2
- package/PageEntityView/PageEntityViewMobileFrame.d.ts +0 -1
- package/PageEntityView/PageEntityViewMobileFrame.js +25 -23
- package/ToastNotificationContainer/index.js +7 -5
- package/components/ChoiceBadge.js +4 -1
- package/components/DialogLogin.js +1 -1
- package/components/PageLogin.js +22 -2
- package/form/layout/FormBody/FormBody.js +16 -1
- package/package.json +2 -2
|
@@ -7,8 +7,10 @@ const react_nav_preview_1 = require("@fluentui/react-nav-preview");
|
|
|
7
7
|
const app_1 = require("@headless-adminapp/app/app");
|
|
8
8
|
const hooks_1 = require("@headless-adminapp/app/auth/hooks");
|
|
9
9
|
const useIsSkipAuthCheck_1 = require("@headless-adminapp/app/auth/hooks/useIsSkipAuthCheck");
|
|
10
|
+
const header_1 = require("@headless-adminapp/app/header");
|
|
10
11
|
const hooks_2 = require("@headless-adminapp/app/hooks");
|
|
11
12
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
13
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
12
14
|
const route_1 = require("@headless-adminapp/app/route");
|
|
13
15
|
const icons_1 = require("@headless-adminapp/icons");
|
|
14
16
|
const react_1 = require("react");
|
|
@@ -16,14 +18,48 @@ const AppLogo_1 = require("./AppLogo");
|
|
|
16
18
|
const AppStringContext_1 = require("./AppStringContext");
|
|
17
19
|
const QuickActionItem_1 = require("./QuickActionItem");
|
|
18
20
|
const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
21
|
+
const isMobile = (0, hooks_2.useIsMobile)();
|
|
22
|
+
if (isMobile) {
|
|
23
|
+
return (0, jsx_runtime_1.jsx)(AppMobileHeader, { onNavToggle: onNavToggle });
|
|
24
|
+
}
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(AppDesktopHeader, { onNavToggle: onNavToggle });
|
|
26
|
+
};
|
|
27
|
+
exports.AppHeaderContainer = AppHeaderContainer;
|
|
28
|
+
const NavHamburger = ({ onNavToggle }) => {
|
|
29
|
+
const isMobile = (0, hooks_2.useIsMobile)();
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.Hamburger, { style: {
|
|
31
|
+
color: 'inherit',
|
|
32
|
+
width: !isMobile ? 44 : undefined,
|
|
33
|
+
maxWidth: !isMobile ? 44 : undefined,
|
|
34
|
+
}, onClick: onNavToggle }));
|
|
35
|
+
};
|
|
36
|
+
const NavBackButton = () => {
|
|
37
|
+
const isMobile = (0, hooks_2.useIsMobile)();
|
|
38
|
+
const router = (0, route_1.useRouter)();
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.Hamburger, { style: {
|
|
40
|
+
color: 'inherit',
|
|
41
|
+
width: !isMobile ? 44 : undefined,
|
|
42
|
+
maxWidth: !isMobile ? 44 : undefined,
|
|
43
|
+
}, icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.ArrowLeft, {}), onClick: () => {
|
|
44
|
+
router.back();
|
|
45
|
+
} }));
|
|
46
|
+
};
|
|
47
|
+
const NavTitle = () => {
|
|
48
|
+
const { appExperience: app } = (0, app_1.useAppContext)();
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
cursor: 'pointer',
|
|
53
|
+
color: 'white',
|
|
54
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', paddingLeft: 4, paddingRight: 6 }, children: (0, jsx_runtime_1.jsx)(AppLogo_1.AppLogo, { logo: app.logo, title: app.title }) }), (0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { paddingLeft: 4 }, children: app.title })] }));
|
|
55
|
+
};
|
|
56
|
+
const NavActions = () => {
|
|
19
57
|
const { appExperience: app } = (0, app_1.useAppContext)();
|
|
20
58
|
const authSession = (0, hooks_1.useAuthSession)();
|
|
21
59
|
const isSkipAuthCheck = (0, useIsSkipAuthCheck_1.useIsSkipAuthCheck)();
|
|
22
60
|
const logout = (0, hooks_1.useLogout)();
|
|
23
61
|
const strings = (0, AppStringContext_1.useAppStrings)();
|
|
24
62
|
const { language } = (0, locale_1.useLocale)();
|
|
25
|
-
const isMobile = (0, hooks_2.useIsMobile)();
|
|
26
|
-
const isTablet = (0, hooks_2.useIsTablet)();
|
|
27
63
|
const initials = (0, react_1.useMemo)(() => {
|
|
28
64
|
return authSession?.fullName
|
|
29
65
|
.split(' ')
|
|
@@ -35,6 +71,60 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
35
71
|
const accountMenuItems = (0, hooks_2.useItemsWithKey)(app.accountMenuItems);
|
|
36
72
|
const router = (0, route_1.useRouter)();
|
|
37
73
|
const basePath = (0, route_1.useBasePath)();
|
|
74
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
75
|
+
paddingLeft: 8,
|
|
76
|
+
display: 'flex',
|
|
77
|
+
gap: 16,
|
|
78
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', gap: 8 }, children: quickActionItems?.map((item) => {
|
|
79
|
+
if (item.type === 'custom') {
|
|
80
|
+
return (0, jsx_runtime_1.jsx)(item.Component, {}, item.__key);
|
|
81
|
+
}
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(QuickActionItem_1.QuickActionItem, { Icon: item.icon, label: item.localizedLabel?.[language] ?? item.label, onClick: () => item.onClick?.(), link: item.link }, item.__key));
|
|
83
|
+
}) }), (!isSkipAuthCheck || !!accountMenuItems?.length) && ((0, jsx_runtime_1.jsxs)(react_components_1.Popover, { children: [(0, jsx_runtime_1.jsx)(react_components_1.PopoverTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", style: { cursor: 'pointer' }, image: {
|
|
84
|
+
src: authSession?.profilePicture,
|
|
85
|
+
} }) }), (0, jsx_runtime_1.jsxs)(react_components_1.PopoverSurface, { tabIndex: -1, style: { padding: 0 }, children: [!isSkipAuthCheck && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
gap: 8,
|
|
88
|
+
padding: 8,
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
width: 200,
|
|
91
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", image: {
|
|
92
|
+
src: authSession?.profilePicture,
|
|
93
|
+
} }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
94
|
+
display: 'flex',
|
|
95
|
+
flexDirection: 'column',
|
|
96
|
+
overflow: 'hidden',
|
|
97
|
+
flex: 1,
|
|
98
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1Strong, { children: authSession?.fullName }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { textOverflow: 'ellipsis', overflow: 'hidden' }, children: authSession?.email })] })] })), !isSkipAuthCheck && (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, { style: { marginInline: 0 } }), (0, jsx_runtime_1.jsxs)(react_components_1.MenuList, { style: { width: 200, marginBottom: 4 }, children: [accountMenuItems?.map((item) => {
|
|
99
|
+
const Icon = item.icon;
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), onClick: () => {
|
|
101
|
+
if (item.onClick) {
|
|
102
|
+
item.onClick();
|
|
103
|
+
}
|
|
104
|
+
else if (item.link) {
|
|
105
|
+
router.push(basePath + item.link);
|
|
106
|
+
}
|
|
107
|
+
}, children: item.localizedLabel?.[language] ?? item.label }, item.__key));
|
|
108
|
+
}), !isSkipAuthCheck && ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.SignOut, {}), onClick: () => logout(), children: strings.logout }))] })] })] }))] }));
|
|
109
|
+
};
|
|
110
|
+
const AppDesktopHeader = ({ onNavToggle }) => {
|
|
111
|
+
const isTablet = (0, hooks_2.useIsTablet)();
|
|
112
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
113
|
+
display: 'flex',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
height: 50,
|
|
116
|
+
minHeight: 50,
|
|
117
|
+
background: react_components_1.tokens.colorBrandBackground,
|
|
118
|
+
paddingInline: 8,
|
|
119
|
+
gap: 8,
|
|
120
|
+
color: 'white',
|
|
121
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, alignItems: 'center', gap: 8 }, children: [isTablet && (0, jsx_runtime_1.jsx)(NavHamburger, { onNavToggle: onNavToggle }), (0, jsx_runtime_1.jsx)(NavTitle, {})] }), (0, jsx_runtime_1.jsx)(NavActions, {})] }));
|
|
122
|
+
};
|
|
123
|
+
const AppMobileHeader = ({ onNavToggle }) => {
|
|
124
|
+
const showCustomHeader = (0, mutable_1.useContextSelector)(header_1.HeaderContext, (state) => state.showBackButton.length > 0);
|
|
125
|
+
const headerTitle = (0, header_1.useHeaderValue)('title');
|
|
126
|
+
const rightComponent = (0, header_1.useHeaderValue)('rightComponent');
|
|
127
|
+
const showBackButton = (0, header_1.useHeaderValue)('showBackButton');
|
|
38
128
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
39
129
|
display: 'flex',
|
|
40
130
|
alignItems: 'center',
|
|
@@ -43,52 +133,18 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
43
133
|
background: react_components_1.tokens.colorBrandBackground,
|
|
44
134
|
paddingInline: 8,
|
|
45
135
|
gap: 8,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
display: 'flex',
|
|
50
|
-
flexDirection: 'row',
|
|
51
|
-
justifyContent: 'center',
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
}, onClick: onNavToggle, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.Hamburger, { style: { color: 'white' } }) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
54
|
-
display: 'flex',
|
|
55
|
-
alignItems: 'center',
|
|
56
|
-
cursor: 'pointer',
|
|
57
|
-
color: 'white',
|
|
58
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', paddingLeft: 4, paddingRight: 6 }, children: (0, jsx_runtime_1.jsx)(AppLogo_1.AppLogo, { logo: app.logo, title: app.title }) }), (0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { paddingLeft: 4 }, children: app.title })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
59
|
-
paddingLeft: 8,
|
|
136
|
+
color: 'white',
|
|
137
|
+
zIndex: 10,
|
|
138
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
60
139
|
display: 'flex',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
gap: 8,
|
|
72
|
-
padding: 8,
|
|
73
|
-
overflow: 'hidden',
|
|
74
|
-
width: 200,
|
|
75
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", image: {
|
|
76
|
-
src: authSession?.profilePicture,
|
|
77
|
-
} }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
78
|
-
display: 'flex',
|
|
79
|
-
flexDirection: 'column',
|
|
80
|
-
overflow: 'hidden',
|
|
81
|
-
flex: 1,
|
|
82
|
-
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1Strong, { children: authSession?.fullName }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { textOverflow: 'ellipsis', overflow: 'hidden' }, children: authSession?.email })] })] })), !isSkipAuthCheck && (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, { style: { marginInline: 0 } }), (0, jsx_runtime_1.jsxs)(react_components_1.MenuList, { style: { width: 200, marginBottom: 4 }, children: [accountMenuItems?.map((item) => {
|
|
83
|
-
const Icon = item.icon;
|
|
84
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), onClick: () => {
|
|
85
|
-
if (item.onClick) {
|
|
86
|
-
item.onClick();
|
|
87
|
-
}
|
|
88
|
-
else if (item.link) {
|
|
89
|
-
router.push(basePath + item.link);
|
|
90
|
-
}
|
|
91
|
-
}, children: item.localizedLabel?.[language] ?? item.label }, item.__key));
|
|
92
|
-
}), !isSkipAuthCheck && ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.SignOut, {}), onClick: () => logout(), children: strings.logout }))] })] })] }))] })] }));
|
|
140
|
+
flex: 1,
|
|
141
|
+
alignItems: 'center',
|
|
142
|
+
gap: 8,
|
|
143
|
+
overflow: 'hidden',
|
|
144
|
+
}, children: [showBackButton ? ((0, jsx_runtime_1.jsx)(NavBackButton, {})) : ((0, jsx_runtime_1.jsx)(NavHamburger, { onNavToggle: onNavToggle })), showCustomHeader ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: typeof headerTitle === 'string' ? ((0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: {
|
|
145
|
+
textOverflow: 'ellipsis',
|
|
146
|
+
whiteSpace: 'nowrap',
|
|
147
|
+
overflow: 'hidden',
|
|
148
|
+
flex: 1,
|
|
149
|
+
}, children: headerTitle })) : (headerTitle) })) : ((0, jsx_runtime_1.jsx)(NavTitle, {}))] }), showCustomHeader ? rightComponent : (0, jsx_runtime_1.jsx)(NavActions, {})] }));
|
|
93
150
|
};
|
|
94
|
-
exports.AppHeaderContainer = AppHeaderContainer;
|
package/App/QuickActionItem.d.ts
CHANGED
package/App/QuickActionItem.js
CHANGED
|
@@ -23,12 +23,16 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
|
-
const QuickActionItem = ({ label, Icon, onClick, link, badgeCount, badgeColor = 'informative', }) => {
|
|
26
|
+
const QuickActionItem = ({ label, Icon, onClick, link, badgeCount, badgeColor = 'informative', type = 'icon', }) => {
|
|
27
27
|
const styles = useStyles();
|
|
28
28
|
const router = (0, route_1.useRouter)();
|
|
29
29
|
const basePath = (0, route_1.useBasePath)();
|
|
30
30
|
const fullLink = link ? `${basePath}${link}` : undefined;
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.Button, { icon: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), !!badgeCount && ((0, jsx_runtime_1.jsx)(react_components_1.Badge, { style: { position: 'absolute', top: 0, right: 0 }, color: badgeColor, size: "small", children: badgeCount }))] }), appearance: "transparent", style: {
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Button, { icon: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), !!badgeCount && ((0, jsx_runtime_1.jsx)(react_components_1.Badge, { style: { position: 'absolute', top: 0, right: 0 }, color: badgeColor, size: "small", children: badgeCount }))] }), appearance: "transparent", style: {
|
|
32
|
+
position: 'relative',
|
|
33
|
+
fontWeight: react_components_1.tokens.fontWeightRegular,
|
|
34
|
+
minWidth: 'unset',
|
|
35
|
+
}, as: "a", href: fullLink, title: label, className: styles.root, onClick: (event) => {
|
|
32
36
|
event.preventDefault();
|
|
33
37
|
if (fullLink) {
|
|
34
38
|
router.push(fullLink);
|
|
@@ -36,6 +40,6 @@ const QuickActionItem = ({ label, Icon, onClick, link, badgeCount, badgeColor =
|
|
|
36
40
|
else if (onClick) {
|
|
37
41
|
onClick();
|
|
38
42
|
}
|
|
39
|
-
} }));
|
|
43
|
+
}, children: type === 'button' ? label : '' }));
|
|
40
44
|
};
|
|
41
45
|
exports.QuickActionItem = QuickActionItem;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MobileHeaderRightContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
6
|
+
const MobileHeaderCommandContainer_1 = require("../Header/MobileHeaderCommandContainer");
|
|
7
|
+
const MobileHeaderRightContainer = () => {
|
|
8
|
+
const commands = (0, datagrid_1.useMainGridCommands)();
|
|
9
|
+
return (0, jsx_runtime_1.jsx)(MobileHeaderCommandContainer_1.MobileHeaderCommandContainer, { commands: commands });
|
|
10
|
+
};
|
|
11
|
+
exports.MobileHeaderRightContainer = MobileHeaderRightContainer;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CSSProperties, FC, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export type CellDisplayType = 'flex' | 'table-cell';
|
|
2
3
|
export interface TableCellBaseProps {
|
|
3
4
|
children?: ReactNode;
|
|
4
5
|
onClick?: MouseEventHandler;
|
|
5
6
|
style?: CSSProperties;
|
|
7
|
+
display?: CellDisplayType;
|
|
6
8
|
}
|
|
7
9
|
export declare const TableCellBase: FC<TableCellBaseProps>;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TableCellBase = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const TableCellBase = ({ children, onClick, style, }) => {
|
|
6
|
+
const TableCellBase = ({ children, onClick, style, display = 'flex', }) => {
|
|
7
7
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { onClick: onClick, style: {
|
|
8
|
-
display
|
|
8
|
+
display,
|
|
9
9
|
alignItems: 'center',
|
|
10
10
|
height: '100%',
|
|
11
11
|
// borderBottom: `var(--strokeWidthThin) solid var(--colorNeutralStroke2)`,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ChoiceAttribute } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { CellDisplayType } from './TableCellBase';
|
|
2
3
|
interface TableCellChoiceProps {
|
|
3
4
|
value: unknown;
|
|
4
5
|
attribute: ChoiceAttribute<string | number>;
|
|
5
6
|
formattedValue: string;
|
|
6
|
-
width
|
|
7
|
+
width?: number;
|
|
8
|
+
display?: CellDisplayType;
|
|
7
9
|
}
|
|
8
10
|
export declare function TableCellChoice(props: Readonly<TableCellChoiceProps>): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -12,5 +12,5 @@ function TableCellChoice(props) {
|
|
|
12
12
|
width: props.width,
|
|
13
13
|
minWidth: props.width,
|
|
14
14
|
maxWidth: props.width,
|
|
15
|
-
}, children: (0, jsx_runtime_1.jsx)(ChoiceBadge_1.ChoiceBadge, { attribute: props.attribute, formattedValue: props.formattedValue, value: props.value }) }));
|
|
15
|
+
}, display: props.display, children: (0, jsx_runtime_1.jsx)(ChoiceBadge_1.ChoiceBadge, { attribute: props.attribute, formattedValue: props.formattedValue, value: props.value }) }));
|
|
16
16
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { CellDisplayType } from './TableCellBase';
|
|
2
3
|
export interface TableCellLinkProps {
|
|
3
4
|
value: React.ReactNode | undefined | null;
|
|
4
5
|
href?: string;
|
|
5
6
|
onClick?: () => void;
|
|
6
|
-
width
|
|
7
|
+
width?: number;
|
|
7
8
|
target?: string;
|
|
9
|
+
display?: CellDisplayType;
|
|
8
10
|
}
|
|
9
11
|
export declare const TableCellLink: FC<TableCellLinkProps>;
|
|
@@ -5,7 +5,7 @@ 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
|
-
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target }) => {
|
|
8
|
+
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target, display = 'flex' }) => {
|
|
9
9
|
const router = (0, hooks_1.useRouter)();
|
|
10
10
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
11
11
|
textOverflow: 'ellipsis',
|
|
@@ -14,7 +14,7 @@ exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width, target
|
|
|
14
14
|
width,
|
|
15
15
|
minWidth: width,
|
|
16
16
|
maxWidth: width,
|
|
17
|
-
display
|
|
17
|
+
display,
|
|
18
18
|
alignItems: 'center',
|
|
19
19
|
height: '100%',
|
|
20
20
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { as: "a", href: href, target: target, onClick: (event) => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { CellDisplayType } from './TableCellBase';
|
|
2
3
|
export interface TableCellTextProps {
|
|
3
4
|
value: string;
|
|
4
|
-
width
|
|
5
|
+
width?: number;
|
|
5
6
|
textAlignment?: 'left' | 'center' | 'right';
|
|
7
|
+
display?: CellDisplayType;
|
|
6
8
|
}
|
|
7
9
|
export declare const TableCellText: FC<TableCellTextProps>;
|
|
@@ -4,8 +4,8 @@ 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");
|
|
7
|
-
exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment }) => {
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { style: {
|
|
7
|
+
exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment, display }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { display: display, style: {
|
|
9
9
|
textAlign: textAlignment ?? 'left',
|
|
10
10
|
textOverflow: 'ellipsis',
|
|
11
11
|
overflow: 'hidden',
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { TransformedViewColumn } from '@headless-adminapp/app/datagrid';
|
|
2
|
+
import { InternalRouteResolver, RouterInstance } from '@headless-adminapp/app/route/context';
|
|
3
|
+
import { LookupAttribute } from '@headless-adminapp/core/attributes';
|
|
4
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
5
|
+
import { ISchemaStore } from '@headless-adminapp/core/store';
|
|
6
|
+
import { CellContext } from '@tanstack/react-table';
|
|
7
|
+
import { CellDisplayType } from './TableCell';
|
|
1
8
|
import { UniqueRecord } from './types';
|
|
2
9
|
export declare function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }: {
|
|
3
10
|
disableSelection?: boolean;
|
|
@@ -7,3 +14,14 @@ export declare function useTableColumns({ disableSelection, disableContextMenu,
|
|
|
7
14
|
disableColumnSort?: boolean;
|
|
8
15
|
tableWrapperRef: React.RefObject<HTMLDivElement>;
|
|
9
16
|
}): import("@tanstack/react-table").AccessorFnColumnDef<UniqueRecord, unknown>[];
|
|
17
|
+
export declare function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, router, attribute, formattedValue, display, }: {
|
|
18
|
+
value: unknown;
|
|
19
|
+
info?: CellContext<UniqueRecord, unknown>;
|
|
20
|
+
column?: TransformedViewColumn<SchemaAttributes>;
|
|
21
|
+
schemaStore: ISchemaStore;
|
|
22
|
+
routeResolver: InternalRouteResolver;
|
|
23
|
+
router: RouterInstance;
|
|
24
|
+
attribute: LookupAttribute;
|
|
25
|
+
formattedValue: string;
|
|
26
|
+
display?: CellDisplayType;
|
|
27
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTableColumns = useTableColumns;
|
|
4
|
+
exports.renderLookupAttribute = renderLookupAttribute;
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
7
|
const datagrid_1 = require("@headless-adminapp/app/datagrid");
|
|
@@ -218,12 +219,15 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
218
219
|
cell: (info) => renderCellContent({
|
|
219
220
|
info,
|
|
220
221
|
column,
|
|
221
|
-
schema,
|
|
222
|
+
attributes: schema.attributes,
|
|
222
223
|
locale,
|
|
223
224
|
schemaStore,
|
|
224
225
|
routeResolver,
|
|
225
226
|
openRecord,
|
|
226
227
|
router,
|
|
228
|
+
primaryAttributeName: schema.primaryAttribute,
|
|
229
|
+
idAttributeName: schema.idAttribute,
|
|
230
|
+
avatarAttributeName: schema.avatarAttribute,
|
|
227
231
|
}),
|
|
228
232
|
enableResizing: true,
|
|
229
233
|
size: columnWidths[index],
|
|
@@ -252,19 +256,19 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
252
256
|
function renderCellHeaderContent({ column, props, disableColumnResize, disableColumnFilter, disableColumnSort, onChangeSortDirection, }) {
|
|
253
257
|
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));
|
|
254
258
|
}
|
|
255
|
-
function renderCellContent({ info, column,
|
|
259
|
+
function renderCellContent({ info, column, attributes, schemaStore, locale, routeResolver, openRecord, router, primaryAttributeName, idAttributeName, avatarAttributeName, }) {
|
|
256
260
|
let attribute;
|
|
257
261
|
let value;
|
|
258
262
|
if (column.expandedKey) {
|
|
259
263
|
const lookup = column.name;
|
|
260
264
|
const field = column.expandedKey;
|
|
261
|
-
const entity =
|
|
265
|
+
const entity = attributes[lookup].entity;
|
|
262
266
|
const lookupSchema = schemaStore.getSchema(entity);
|
|
263
267
|
attribute = lookupSchema.attributes[field];
|
|
264
268
|
value = info.row.original.$expand?.[lookup]?.[field];
|
|
265
269
|
}
|
|
266
270
|
else {
|
|
267
|
-
attribute =
|
|
271
|
+
attribute = attributes[column.name];
|
|
268
272
|
value = info.getValue();
|
|
269
273
|
}
|
|
270
274
|
const formattedValue = (0, utils_1.getAttributeFormattedValue)(attribute, value, locale) ?? '';
|
|
@@ -287,15 +291,17 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
287
291
|
if (!Component) {
|
|
288
292
|
throw new Error(`Component with name ${column.component} not found`);
|
|
289
293
|
}
|
|
290
|
-
return ((0, jsx_runtime_1.jsx)(Component, { column: column,
|
|
294
|
+
return ((0, jsx_runtime_1.jsx)(Component, { column: column, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
291
295
|
}
|
|
292
|
-
if (
|
|
296
|
+
if (idAttributeName && primaryAttributeName === column.name) {
|
|
293
297
|
return renderPrimaryAttribute({
|
|
294
298
|
info,
|
|
295
299
|
column,
|
|
296
300
|
routeResolver,
|
|
297
301
|
openRecord,
|
|
298
|
-
|
|
302
|
+
attributes,
|
|
303
|
+
idAttributeName,
|
|
304
|
+
avatarAttributeName,
|
|
299
305
|
value: value,
|
|
300
306
|
});
|
|
301
307
|
}
|
|
@@ -354,29 +360,30 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
354
360
|
}
|
|
355
361
|
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
356
362
|
}
|
|
357
|
-
function renderPrimaryAttribute({ info, column,
|
|
363
|
+
function renderPrimaryAttribute({ info, column, attributes, routeResolver, openRecord, value, idAttributeName, avatarAttributeName, }) {
|
|
358
364
|
const path = routeResolver({
|
|
359
365
|
logicalName: info.row.original.$entity,
|
|
360
366
|
type: app_1.PageType.EntityForm,
|
|
361
|
-
id: info.row.original[
|
|
367
|
+
id: info.row.original[idAttributeName],
|
|
362
368
|
});
|
|
363
369
|
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [renderPrimaryAttributeAvatar({
|
|
364
370
|
info,
|
|
365
|
-
schema,
|
|
366
371
|
value,
|
|
372
|
+
avatarAttributeName,
|
|
373
|
+
attributes,
|
|
367
374
|
}), value] }), width: info.column.getSize(), href: path, onClick: () => {
|
|
368
|
-
openRecord(info.row.original[
|
|
375
|
+
openRecord?.(info.row.original[idAttributeName], info.row.original.$entity);
|
|
369
376
|
} }, column.id));
|
|
370
377
|
}
|
|
371
|
-
function renderPrimaryAttributeAvatar({ info,
|
|
372
|
-
if (!
|
|
378
|
+
function renderPrimaryAttributeAvatar({ info, value, avatarAttributeName, attributes, }) {
|
|
379
|
+
if (!avatarAttributeName) {
|
|
373
380
|
return null;
|
|
374
381
|
}
|
|
375
|
-
const avatarAttribute =
|
|
382
|
+
const avatarAttribute = attributes[avatarAttributeName];
|
|
376
383
|
if (avatarAttribute.type !== 'attachment') {
|
|
377
384
|
return null;
|
|
378
385
|
}
|
|
379
|
-
const avatarValue = info.row.original[
|
|
386
|
+
const avatarValue = info.row.original[avatarAttributeName];
|
|
380
387
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
381
388
|
width: 24,
|
|
382
389
|
height: 24,
|
|
@@ -385,9 +392,9 @@ function renderPrimaryAttributeAvatar({ info, schema, value, }) {
|
|
|
385
392
|
src: avatarValue?.url,
|
|
386
393
|
} }));
|
|
387
394
|
}
|
|
388
|
-
function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, router, attribute, formattedValue, }) {
|
|
395
|
+
function renderLookupAttribute({ value, info, column, schemaStore, routeResolver, router, attribute, formattedValue, display, }) {
|
|
389
396
|
if (!value) {
|
|
390
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info
|
|
397
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info?.column.getSize(), display: display }, column?.id));
|
|
391
398
|
}
|
|
392
399
|
const lookupSchema = schemaStore.getSchema(attribute.entity);
|
|
393
400
|
const path = routeResolver({
|
|
@@ -395,15 +402,15 @@ function renderLookupAttribute({ value, info, column, schemaStore, routeResolver
|
|
|
395
402
|
type: app_1.PageType.EntityForm,
|
|
396
403
|
id: value.id,
|
|
397
404
|
});
|
|
398
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!!lookupSchema.avatarAttribute && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
405
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { display: display, value: (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!!lookupSchema.avatarAttribute && ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { style: {
|
|
399
406
|
width: 24,
|
|
400
407
|
height: 24,
|
|
401
408
|
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
402
409
|
}, name: formattedValue, color: (0, avatar_1.getAvatarColor)(formattedValue), image: {
|
|
403
410
|
src: value.avatar,
|
|
404
|
-
} })), formattedValue] }), width: info
|
|
411
|
+
} })), formattedValue] }), width: info?.column.getSize(), href: path, onClick: () => {
|
|
405
412
|
router.push(path);
|
|
406
|
-
} }, column
|
|
413
|
+
} }, column?.id));
|
|
407
414
|
}
|
|
408
415
|
function renderRegardingAttribute({ value, info, column, schemaStore, routeResolver, router, formattedValue, }) {
|
|
409
416
|
if (!value) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommandItemState } from '@headless-adminapp/app/command';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface MobileHeaderCommandContainerProps {
|
|
4
|
+
commands: CommandItemState[][];
|
|
5
|
+
}
|
|
6
|
+
export declare const MobileHeaderCommandContainer: FC<MobileHeaderCommandContainerProps>;
|
|
7
|
+
export {};
|