@omniumretail/component-library 1.2.52 → 1.2.54

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.
@@ -23,4 +23,5 @@ export interface HeaderProps {
23
23
  onNotificationClick?: (id: string, url: string) => void;
24
24
  handleMarkAllAsRead?: () => void;
25
25
  notifications?: BellNotification[];
26
+ shouldConfirmNavigation?: boolean;
26
27
  }
@@ -3,5 +3,5 @@ import { HeaderProps } from './Header.types';
3
3
  * Header component to display navigation bar with dropdown menus and action button.
4
4
  * @param {HeaderProps} props - Properties passed to the component.
5
5
  */
6
- export declare const Header: ({ menuList, actionButton, logout, homeUrl, profileUrl, onLeavingPage, userName, pageTitle, onFilterChange, notifications, onNotificationClick, handleMarkAllAsRead }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const Header: ({ menuList, actionButton, logout, homeUrl, profileUrl, onLeavingPage, userName, pageTitle, onFilterChange, notifications, onNotificationClick, handleMarkAllAsRead, shouldConfirmNavigation }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Header;
@@ -48,5 +48,6 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
48
48
  cleanRowSelection?: boolean;
49
49
  getRowActions?: (record: any) => any;
50
50
  customSelectAllButton?: string;
51
+ buttonActionIcon?: any;
51
52
  }
52
53
  export declare const ResponsiveTable: (props: ResponsiveTableCustomProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.2.52",
3
+ "version": "1.2.54",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -26,4 +26,5 @@ export interface HeaderProps {
26
26
  onNotificationClick?: (id: string, url: string) => void;
27
27
  handleMarkAllAsRead?: () => void;
28
28
  notifications?: BellNotification[];
29
+ shouldConfirmNavigation?: boolean;
29
30
  }
@@ -24,7 +24,8 @@ export const Header = ({
24
24
  onFilterChange,
25
25
  notifications,
26
26
  onNotificationClick,
27
- handleMarkAllAsRead
27
+ handleMarkAllAsRead,
28
+ shouldConfirmNavigation
28
29
  }: HeaderProps) => {
29
30
 
30
31
  const [isMenuOpen, setIsMenuOpen] = useState(false);
@@ -36,7 +37,9 @@ export const Header = ({
36
37
  * Handle the logout action. If no logout function is provided, redirect to home as discussed in a meet
37
38
  */
38
39
  const onLogout = () => {
39
- if (logout) {
40
+ if (shouldConfirmNavigation) {
41
+ onLeavingPage!('/logout');
42
+ } else if (logout) {
40
43
  logout();
41
44
  } else {
42
45
  onHome();
@@ -47,14 +50,22 @@ export const Header = ({
47
50
  * Navigate to the profile URL.
48
51
  */
49
52
  const onProfile = () => {
50
- window.location.href = profileUrl;
53
+ if (shouldConfirmNavigation) {
54
+ onLeavingPage!('/profile');
55
+ } else {
56
+ window.location.href = profileUrl;
57
+ }
51
58
  };
52
59
 
53
60
  /**
54
61
  * Navigate to the home URL.
55
62
  */
56
63
  const onHome = () => {
57
- window.location.href = homeUrl;
64
+ if (shouldConfirmNavigation) {
65
+ onLeavingPage!('/home');
66
+ } else {
67
+ window.location.href = homeUrl;
68
+ }
58
69
  };
59
70
 
60
71
  const menuTopList = getMenuTopList(
@@ -54,6 +54,7 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
54
54
  cleanRowSelection?: boolean;
55
55
  getRowActions?: (record: any) => any;
56
56
  customSelectAllButton?: string;
57
+ buttonActionIcon?: any;
57
58
  }
58
59
 
59
60
  export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
@@ -85,7 +86,8 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
85
86
  buttonActionLabel,
86
87
  cleanRowSelection,
87
88
  getRowActions,
88
- customSelectAllButton
89
+ customSelectAllButton,
90
+ buttonActionIcon
89
91
  } = props;
90
92
 
91
93
  const [customFilters, setCustomFilters] = useState<any>([]);
@@ -217,21 +219,46 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
217
219
  render: (_: any, record: any) => {
218
220
  const rowActions = getRowActions ? getRowActions(record) : null;
219
221
 
220
- if ((!items?.[0] && !rowActions)) return null;
222
+ if ((!items?.[0] && !rowActions)) return null;
221
223
 
222
224
  const actions = rowActions ? rowActions : items;
223
225
 
224
226
  const buttonLabel = buttonActionLabel ? buttonActionLabel(record) : null;
225
-
226
- const buttonClass = typeof buttonActionStyle === 'function'
227
- ? buttonActionStyle(record) // Se for uma função, chama com o `record`
228
- : buttonActionStyle || ''; // Se for string, usa diretamente
227
+
228
+ const buttonClass = typeof buttonActionStyle === 'function'
229
+ ? buttonActionStyle(record) // Se for uma função, chama com o `record`
230
+ : buttonActionStyle || ''; // Se for string, usa diretamente
231
+
232
+ const renderActionElement = () => {
233
+ if (buttonActionIcon) {
234
+ return (
235
+ <span
236
+ className={buttonClass}
237
+ onClick={() => buttonActionMethod?.()}
238
+ >
239
+ {buttonActionIcon}
240
+ </span>
241
+ );
242
+ }
243
+
244
+ // Senão, renderiza botão como antes
245
+ if (buttonActionName || buttonLabel) {
246
+ return (
247
+ <Button
248
+ customClass={buttonClass}
249
+ onClick={() => buttonActionMethod?.()}
250
+ >
251
+ {buttonActionName || buttonLabel}
252
+ </Button>
253
+ );
254
+ }
255
+
256
+ return null;
257
+ };
229
258
 
230
259
  return (
231
260
  <Space size="middle">
232
- {(buttonActionName || buttonLabel) &&
233
- <Button customClass={buttonClass} onClick={() => buttonActionMethod?.()}>{buttonActionName || buttonLabel}</Button>
234
- }
261
+ {renderActionElement()}
235
262
 
236
263
  <Dropdown menu={{ items: actions }}>
237
264
  <a>