@grasp-labs/ds-microfrontends-integration 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -18,8 +18,8 @@ Components for managing secrets with JSON Schema-based forms.
18
18
 
19
19
  ```tsx
20
20
  import {
21
- VaultProvider,
22
21
  VaultInput,
22
+ VaultProvider,
23
23
  VaultSecretDialog,
24
24
  } from "@grasp-labs/ds-microfrontends-integration";
25
25
  import "@grasp-labs/ds-microfrontends-integration/styles.css";
@@ -2,4 +2,5 @@ export * from './groups';
2
2
  export * from './language';
3
3
  export * from './schemaFields';
4
4
  export * from './toast';
5
+ export * from './user';
5
6
  export * from './vault';
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from 'react';
2
+ import { User } from '../../types';
3
+ export type UserContextValue = {
4
+ user: User | null;
5
+ isAuthenticated: boolean;
6
+ };
7
+ export type UserProviderProps = {
8
+ children: ReactNode;
9
+ user: User | null;
10
+ };
11
+ /**
12
+ * Provides user context to child components.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <UserProvider user={user}>
17
+ * <App />
18
+ * </UserProvider>
19
+ * ```
20
+ */
21
+ export declare const UserProvider: ({ children, user }: UserProviderProps) => import("react/jsx-runtime").JSX.Element;
22
+ /**
23
+ * Hook to access user context.
24
+ *
25
+ * @returns The user context with user data and authentication status.
26
+ * @throws Error if used outside of UserProvider.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const { user, isAuthenticated } = useUser();
31
+ *
32
+ * if (isAuthenticated) {
33
+ * console.log(user.name);
34
+ * }
35
+ * ```
36
+ */
37
+ export declare const useUser: () => UserContextValue;
@@ -0,0 +1,16 @@
1
+ import { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: ({ children, user }: import('./UserProvider').UserProviderProps) => import("react/jsx-runtime").JSX.Element;
5
+ parameters: {
6
+ layout: string;
7
+ };
8
+ tags: string[];
9
+ };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Authenticated: Story;
13
+ export declare const Unauthenticated: Story;
14
+ export declare const PartialUserData: Story;
15
+ export declare const WithCustomFields: Story;
16
+ export declare const LogoutTriggersEffect: StoryObj;
@@ -0,0 +1 @@
1
+ export * from './UserProvider';