@digitaldefiance/express-suite-react-components 4.19.20 → 4.19.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/express-suite-react-components",
3
- "version": "4.19.20",
3
+ "version": "4.19.22",
4
4
  "homepage": "https://github.com/Digital-Defiance/react-components",
5
5
  "description": "React MUI components for Digital Defiance Express Suite",
6
6
  "repository": {
@@ -44,7 +44,7 @@ const TopMenu = ({ Logo, additionalMenus, constants, showTitle }) => {
44
44
  marginRight: 2,
45
45
  display: 'flex',
46
46
  alignItems: 'center',
47
- }, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: (showTitle !== false) ? siteTitle : ' ' }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: [isAuthenticated ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/dashboard", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard) }), allMenus.map((menu, index) => menu.isUserMenu ? ((0, jsx_runtime_1.jsx)(UserMenu_1.UserMenu, {}, `user-menu`)) : ((0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: menu.menuType, menuIcon: menu.menuIcon }, `menu-${index}`)))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/login", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_LoginButton) }), (0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/register", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RegisterButton) })] })), (0, jsx_runtime_1.jsx)(UserLanguageSelector_1.UserLanguageSelector, {})] })] }), (0, jsx_runtime_1.jsx)(SideMenu_1.SideMenu, { isOpen: isSideMenuOpen, onClose: handleCloseSideMenu })] }));
47
+ }, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: (showTitle !== false) ? siteTitle : '\u00A0' }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: [isAuthenticated ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/dashboard", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard) }), allMenus.map((menu, index) => menu.isUserMenu ? ((0, jsx_runtime_1.jsx)(UserMenu_1.UserMenu, {}, `user-menu`)) : ((0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: menu.menuType, menuIcon: menu.menuIcon }, `menu-${index}`)))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/login", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_LoginButton) }), (0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/register", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RegisterButton) })] })), (0, jsx_runtime_1.jsx)(UserLanguageSelector_1.UserLanguageSelector, {})] })] }), (0, jsx_runtime_1.jsx)(SideMenu_1.SideMenu, { isOpen: isSideMenuOpen, onClose: handleCloseSideMenu })] }));
48
48
  };
49
49
  exports.TopMenu = TopMenu;
50
50
  exports.default = exports.TopMenu;
@@ -3,4 +3,5 @@ export * from './useLocalStorage';
3
3
  export * from './useBackupCodes';
4
4
  export * from './useUserSettings';
5
5
  export * from './useEmailVerification';
6
+ export * from './useAuthenticatedApi';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
@@ -6,3 +6,4 @@ tslib_1.__exportStar(require("./useLocalStorage"), exports);
6
6
  tslib_1.__exportStar(require("./useBackupCodes"), exports);
7
7
  tslib_1.__exportStar(require("./useUserSettings"), exports);
8
8
  tslib_1.__exportStar(require("./useEmailVerification"), exports);
9
+ tslib_1.__exportStar(require("./useAuthenticatedApi"), exports);
@@ -0,0 +1,34 @@
1
+ /**
2
+ * useAuthenticatedApi — React hook + provider for a shared authenticated
3
+ * Axios instance.
4
+ *
5
+ * The provider creates a single AxiosInstance via createAuthenticatedApiClient
6
+ * using the baseUrl from SuiteConfigProvider. All component libraries consume
7
+ * the same instance through the useAuthenticatedApi() hook, eliminating
8
+ * duplicate axios instances and circular dependency issues.
9
+ *
10
+ * Usage:
11
+ * // In the app root (wrap inside SuiteConfigProvider):
12
+ * <AuthenticatedApiProvider>
13
+ * <App />
14
+ * </AuthenticatedApiProvider>
15
+ *
16
+ * // In any component library:
17
+ * const api = useAuthenticatedApi();
18
+ * const res = await api.get('/some-endpoint');
19
+ */
20
+ import { ReactNode } from 'react';
21
+ import type { AxiosInstance } from 'axios';
22
+ export interface AuthenticatedApiProviderProps {
23
+ children: ReactNode;
24
+ /** Optional token key in localStorage. Defaults to 'authToken'. */
25
+ tokenKey?: string;
26
+ }
27
+ export declare const AuthenticatedApiProvider: ({ children, tokenKey, }: AuthenticatedApiProviderProps) => import("react/jsx-runtime").JSX.Element;
28
+ /**
29
+ * Returns the shared authenticated Axios instance.
30
+ * Must be used within an AuthenticatedApiProvider (which itself must be
31
+ * inside a SuiteConfigProvider).
32
+ */
33
+ export declare const useAuthenticatedApi: () => AxiosInstance;
34
+ //# sourceMappingURL=useAuthenticatedApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthenticatedApi.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/hooks/useAuthenticatedApi.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAiB,SAAS,EAAuB,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQ3C,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,wBAAwB,GAAI,yBAGtC,6BAA6B,4CAa/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAO,aAQtC,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAuthenticatedApi = exports.AuthenticatedApiProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /**
6
+ * useAuthenticatedApi — React hook + provider for a shared authenticated
7
+ * Axios instance.
8
+ *
9
+ * The provider creates a single AxiosInstance via createAuthenticatedApiClient
10
+ * using the baseUrl from SuiteConfigProvider. All component libraries consume
11
+ * the same instance through the useAuthenticatedApi() hook, eliminating
12
+ * duplicate axios instances and circular dependency issues.
13
+ *
14
+ * Usage:
15
+ * // In the app root (wrap inside SuiteConfigProvider):
16
+ * <AuthenticatedApiProvider>
17
+ * <App />
18
+ * </AuthenticatedApiProvider>
19
+ *
20
+ * // In any component library:
21
+ * const api = useAuthenticatedApi();
22
+ * const res = await api.get('/some-endpoint');
23
+ */
24
+ const react_1 = require("react");
25
+ const authenticatedApi_1 = require("../services/authenticatedApi");
26
+ const SuiteConfigProvider_1 = require("../contexts/SuiteConfigProvider");
27
+ const AuthenticatedApiContext = (0, react_1.createContext)(undefined);
28
+ const AuthenticatedApiProvider = ({ children, tokenKey, }) => {
29
+ const { baseUrl } = (0, SuiteConfigProvider_1.useSuiteConfig)();
30
+ const api = (0, react_1.useMemo)(() => (0, authenticatedApi_1.createAuthenticatedApiClient)(baseUrl, tokenKey), [baseUrl, tokenKey]);
31
+ return ((0, jsx_runtime_1.jsx)(AuthenticatedApiContext.Provider, { value: api, children: children }));
32
+ };
33
+ exports.AuthenticatedApiProvider = AuthenticatedApiProvider;
34
+ /**
35
+ * Returns the shared authenticated Axios instance.
36
+ * Must be used within an AuthenticatedApiProvider (which itself must be
37
+ * inside a SuiteConfigProvider).
38
+ */
39
+ const useAuthenticatedApi = () => {
40
+ const context = (0, react_1.useContext)(AuthenticatedApiContext);
41
+ if (!context) {
42
+ throw new Error('useAuthenticatedApi must be used within an AuthenticatedApiProvider');
43
+ }
44
+ return context;
45
+ };
46
+ exports.useAuthenticatedApi = useAuthenticatedApi;