@headless-adminapp/fluent 1.4.47 → 1.4.49

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.
@@ -3,4 +3,5 @@ interface AppHeaderContainerProps {
3
3
  onNavToggle?: () => void;
4
4
  }
5
5
  export declare const AppHeaderContainer: FC<AppHeaderContainerProps>;
6
+ export declare const AccountAvatar: FC;
6
7
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppHeaderContainer = void 0;
3
+ exports.AccountAvatar = 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
6
  const app_1 = require("@headless-adminapp/app/app");
@@ -65,13 +65,13 @@ const NavTitle = () => {
65
65
  color: 'inherit',
66
66
  }, 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 })] }));
67
67
  };
68
- const NavActions = () => {
68
+ const AccountAvatar = () => {
69
69
  const { appExperience: app } = (0, app_1.useAppContext)();
70
+ const { language } = (0, locale_1.useLocale)();
70
71
  const authSession = (0, hooks_1.useAuthSession)();
71
72
  const isSkipAuthCheck = (0, useIsSkipAuthCheck_1.useIsSkipAuthCheck)();
72
73
  const logout = (0, hooks_1.useLogout)();
73
74
  const strings = (0, AppStringContext_1.useAppStrings)();
74
- const { language } = (0, locale_1.useLocale)();
75
75
  const [accountMenuOpen, setAccountMenuOpen] = (0, react_1.useState)(false);
76
76
  const initials = (0, react_1.useMemo)(() => {
77
77
  return authSession?.fullName
@@ -81,10 +81,50 @@ const NavActions = () => {
81
81
  .slice(0, 2)
82
82
  .join('');
83
83
  }, [authSession?.fullName]);
84
- const quickActionItems = (0, hooks_2.useItemsWithKey)(app.quickActionItems);
85
84
  const accountMenuItems = (0, hooks_2.useItemsWithKey)(app.accountMenuItems);
86
85
  const router = (0, route_1.useRouter)();
87
86
  const basePath = (0, route_1.useBasePath)();
87
+ if (isSkipAuthCheck && !accountMenuItems?.length) {
88
+ // if auth check is skipped and there is no account menu item, we don't show the avatar and menu
89
+ return null;
90
+ }
91
+ const content = ((0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", style: { cursor: 'pointer' }, image: {
92
+ src: authSession?.profilePicture,
93
+ } }));
94
+ if (!accountMenuItems?.length) {
95
+ return content;
96
+ }
97
+ return ((0, jsx_runtime_1.jsxs)(react_components_1.Popover, { open: accountMenuOpen, onOpenChange: (e, data) => setAccountMenuOpen(data.open), children: [(0, jsx_runtime_1.jsx)(react_components_1.PopoverTrigger, { disableButtonEnhancement: true, children: content }), (0, jsx_runtime_1.jsxs)(fluent_1.PopoverSurface, { tabIndex: -1, style: { padding: 0 }, children: [!isSkipAuthCheck && ((0, jsx_runtime_1.jsxs)("div", { style: {
98
+ display: 'flex',
99
+ gap: 8,
100
+ padding: 8,
101
+ overflow: 'hidden',
102
+ width: 200,
103
+ }, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", image: {
104
+ src: authSession?.profilePicture,
105
+ } }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
106
+ display: 'flex',
107
+ flexDirection: 'column',
108
+ overflow: 'hidden',
109
+ flex: 1,
110
+ }, 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) => {
111
+ const Icon = item.icon;
112
+ return ((0, jsx_runtime_1.jsx)(fluent_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), onClick: async () => {
113
+ setAccountMenuOpen(false);
114
+ if (item.onClick) {
115
+ item.onClick();
116
+ }
117
+ else if (item.link) {
118
+ await router.push(basePath + item.link);
119
+ }
120
+ }, children: item.localizedLabel?.[language] ?? item.label }, item.__key));
121
+ }), !isSkipAuthCheck && ((0, jsx_runtime_1.jsx)(fluent_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.SignOut, {}), onClick: () => logout(), children: strings.logout }))] })] })] }));
122
+ };
123
+ exports.AccountAvatar = AccountAvatar;
124
+ const NavActions = () => {
125
+ const { appExperience: app } = (0, app_1.useAppContext)();
126
+ const { language } = (0, locale_1.useLocale)();
127
+ const quickActionItems = (0, hooks_2.useItemsWithKey)(app.quickActionItems);
88
128
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
89
129
  paddingLeft: 8,
90
130
  display: 'flex',
@@ -94,33 +134,7 @@ const NavActions = () => {
94
134
  return (0, jsx_runtime_1.jsx)(item.Component, {}, item.__key);
95
135
  }
96
136
  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));
97
- }) }), (!isSkipAuthCheck || !!accountMenuItems?.length) && ((0, jsx_runtime_1.jsxs)(react_components_1.Popover, { open: accountMenuOpen, onOpenChange: (e, data) => setAccountMenuOpen(data.open), 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: {
98
- src: authSession?.profilePicture,
99
- } }) }), (0, jsx_runtime_1.jsxs)(fluent_1.PopoverSurface, { tabIndex: -1, style: { padding: 0 }, children: [!isSkipAuthCheck && ((0, jsx_runtime_1.jsxs)("div", { style: {
100
- display: 'flex',
101
- gap: 8,
102
- padding: 8,
103
- overflow: 'hidden',
104
- width: 200,
105
- }, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Avatar, { initials: initials, color: "neutral", image: {
106
- src: authSession?.profilePicture,
107
- } }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
108
- display: 'flex',
109
- flexDirection: 'column',
110
- overflow: 'hidden',
111
- flex: 1,
112
- }, 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) => {
113
- const Icon = item.icon;
114
- return ((0, jsx_runtime_1.jsx)(fluent_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: "inherit" }), onClick: async () => {
115
- setAccountMenuOpen(false);
116
- if (item.onClick) {
117
- item.onClick();
118
- }
119
- else if (item.link) {
120
- await router.push(basePath + item.link);
121
- }
122
- }, children: item.localizedLabel?.[language] ?? item.label }, item.__key));
123
- }), !isSkipAuthCheck && ((0, jsx_runtime_1.jsx)(fluent_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.SignOut, {}), onClick: () => logout(), children: strings.logout }))] })] })] }))] }));
137
+ }) }), (0, jsx_runtime_1.jsx)(exports.AccountAvatar, {})] }));
124
138
  };
125
139
  const AppDesktopHeader = ({ onNavToggle }) => {
126
140
  const isTablet = (0, hooks_2.useIsTablet)();
@@ -14,6 +14,7 @@ const NavItemComponent_1 = require("./NavItemComponent");
14
14
  const NavMiniCategoryMenu_1 = require("./NavMiniCategoryMenu");
15
15
  const NavSubItemComponent_1 = require("./NavSubItemComponent");
16
16
  const utils_1 = require("./utils");
17
+ const AppHeaderContianer_1 = require("../AppHeaderContianer");
17
18
  const useStyles = (0, react_components_1.makeStyles)({
18
19
  root: {
19
20
  overflow: 'hidden',
@@ -61,14 +62,15 @@ const NavigationContainer = ({ open, type, onOpenChange, isMini, }) => {
61
62
  };
62
63
  return ((0, jsx_runtime_1.jsx)("div", { className: styles.root, children: (0, jsx_runtime_1.jsxs)(react_components_1.NavDrawer, { selectedValue: "active", selectedCategoryValue: "active", defaultOpenCategories: ['active'], open: open || isMini, type: type, onOpenChange: (_value, data) => onOpenChange(data.open), onNavItemSelect: () => {
63
64
  // do nothing
64
- }, style: { width: isMini ? 60 : undefined }, children: [isMobile && ((0, jsx_runtime_1.jsx)(react_components_1.NavDrawerHeader, { style: { padding: 0 }, children: (0, jsx_runtime_1.jsx)("div", { style: {
65
+ }, style: { width: isMini ? 60 : undefined }, children: [isMobile && ((0, jsx_runtime_1.jsx)(react_components_1.NavDrawerHeader, { style: { padding: 0 }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
65
66
  display: 'flex',
66
67
  alignItems: 'center',
68
+ justifyContent: 'space-between',
67
69
  height: 50,
68
70
  minHeight: 50,
69
71
  paddingInline: 12,
70
72
  gap: 8,
71
- }, children: (0, jsx_runtime_1.jsx)(react_components_1.Hamburger, { onClick: () => onOpenChange(false) }) }) })), (0, jsx_runtime_1.jsx)(react_components_1.NavDrawerBody, { style: {
73
+ }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Hamburger, { onClick: () => onOpenChange(false) }), (0, jsx_runtime_1.jsx)(AppHeaderContianer_1.AccountAvatar, {})] }) })), (0, jsx_runtime_1.jsx)(react_components_1.NavDrawerBody, { style: {
72
74
  paddingTop: 8,
73
75
  paddingBottom: 8,
74
76
  }, 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) => {
@@ -2,6 +2,7 @@ import { PropsWithChildren } from 'react';
2
2
  interface SectionControlWrapperProps {
3
3
  label: string;
4
4
  labelPosition?: 'top' | 'left';
5
+ description?: string;
5
6
  labelHidden?: boolean;
6
7
  required?: boolean;
7
8
  isError?: boolean;
@@ -9,7 +9,12 @@ function SectionControlWrapper(props) {
9
9
  : props.labelPosition === 'top' && !props.labelHidden
10
10
  ? 'auto 1fr auto auto'
11
11
  : '1fr auto auto auto';
12
- return ((0, jsx_runtime_1.jsx)(react_components_1.Field, { label: props.labelHidden ? undefined : props.label, orientation: props.labelPosition === 'top' ? 'vertical' : 'horizontal', required: props.labelHidden ? undefined : props.required, validationState: props.isError ? 'error' : undefined, validationMessage: props.errorMessage, validationMessageIcon: null, style: {
12
+ return ((0, jsx_runtime_1.jsx)(react_components_1.Field, { label: props.labelHidden
13
+ ? undefined
14
+ : {
15
+ children: props.label,
16
+ title: props.description,
17
+ }, orientation: props.labelPosition === 'top' ? 'vertical' : 'horizontal', required: props.labelHidden ? undefined : props.required, validationState: props.isError ? 'error' : undefined, validationMessage: props.errorMessage, validationMessageIcon: null, style: {
13
18
  paddingLeft: props.labelHidden ? 0 : undefined,
14
19
  gridTemplateRows,
15
20
  flexGrow: props.grow ? 1 : undefined,
@@ -130,7 +130,7 @@ const Wrapper = ({ children, formHeaderDivRef, }) => {
130
130
  const tabContainerHeight = 36;
131
131
  const visible = !!rect && rect.bottom < headerHeight + tabContainerHeight;
132
132
  if (isMobile) {
133
- return ((0, jsx_runtime_1.jsxs)(ScrollView_1.ScrollView, { children: [(0, jsx_runtime_1.jsx)("div", { style: {
133
+ return ((0, jsx_runtime_1.jsxs)(ScrollView_1.ScrollView, { flexColumn: true, children: [(0, jsx_runtime_1.jsx)("div", { style: {
134
134
  background: react_components_1.tokens.colorNeutralBackgroundAlpha2,
135
135
  backdropFilter: 'blur(20px)',
136
136
  position: 'fixed',
@@ -93,7 +93,7 @@ function SectionContainer({ section, skeleton, }) {
93
93
  control.label ??
94
94
  attribute.label;
95
95
  const labelHidden = control.labelHidden;
96
- return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelHidden: labelHidden, labelPosition: isMobile ? 'top' : section.labelPosition, required: required, isError: isError, errorMessage: errorMessage, grow: control.fullHeight, children: (0, jsx_runtime_1.jsx)(Control, { attribute: attribute, name: control.attributeName, value: field.value, onChange: (value) => {
96
+ return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: label, labelHidden: labelHidden, labelPosition: isMobile ? 'top' : section.labelPosition, description: attribute.description, required: required, isError: isError, errorMessage: errorMessage, grow: control.fullHeight, children: (0, jsx_runtime_1.jsx)(Control, { attribute: attribute, name: control.attributeName, value: field.value, onChange: (value) => {
97
97
  const previousValue = field.value;
98
98
  field.onChange(value);
99
99
  eventManager.emit(constants_1.EVENT_KEY_ON_FIELD_CHANGE, control.attributeName, value, previousValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/fluent",
3
- "version": "1.4.47",
3
+ "version": "1.4.49",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -54,5 +54,5 @@
54
54
  "devDependencies": {
55
55
  "@types/lodash": "4.17.20"
56
56
  },
57
- "gitHead": "bf25872bd5633ce7bc68f6aedb5356b4890b6bde"
57
+ "gitHead": "bb4bc9454aebb0910a9e74be20c4342bb9b06afc"
58
58
  }