@orsetra/shared-ui 1.0.19 → 1.0.20

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.
@@ -13,7 +13,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
13
13
  }
14
14
 
15
15
  const base =
16
- 'inline-flex items-center justify-center font-semibold rounded-md transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ibm-blue-60 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none select-none'
16
+ 'inline-flex items-center justify-center font-semibold rounded-none transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ibm-blue-60 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none select-none'
17
17
 
18
18
  export const variants: Record<ButtonVariant, string> = {
19
19
  primary:
@@ -1,14 +1,13 @@
1
- import HttpClient from './http-client';
1
+ import HttpClient, { type AuthHeadersProvider } from './http-client';
2
2
 
3
3
  /**
4
4
  * Classe de base pour tous les services qui utilisent HttpClient
5
- * L'organization ID est automatiquement ajouté aux headers via les custom attributes AWS Amplify
6
5
  */
7
6
  export abstract class BaseService {
8
7
  protected httpClient: HttpClient;
9
8
 
10
- constructor(baseUrl: string) {
11
- this.httpClient = HttpClient.getInstance(baseUrl);
9
+ constructor(baseUrl: string, authHeadersProvider?: AuthHeadersProvider) {
10
+ this.httpClient = HttpClient.getInstance(baseUrl, authHeadersProvider);
12
11
  }
13
12
 
14
13
  protected handleServiceError(error: any): Error {
@@ -16,3 +15,5 @@ export abstract class BaseService {
16
15
  return error
17
16
  }
18
17
  }
18
+
19
+ export type { AuthHeadersProvider };
@@ -1,14 +1,18 @@
1
1
  // Simplified HTTP client without AWS Amplify dependencies
2
2
 
3
+ export type AuthHeadersProvider = () => Promise<Record<string, string>> | Record<string, string>;
4
+
3
5
  class HttpClient {
4
6
  private baseUrl: string;
7
+ private authHeadersProvider?: AuthHeadersProvider;
5
8
 
6
- private constructor(baseUrl: string) {
7
- this.baseUrl = baseUrl || '';
9
+ private constructor(baseUrl: string, authHeadersProvider?: AuthHeadersProvider) {
10
+ this.baseUrl = baseUrl || '';
11
+ this.authHeadersProvider = authHeadersProvider;
8
12
  }
9
13
 
10
- public static getInstance(baseUrl: string): HttpClient {
11
- return new HttpClient(baseUrl);
14
+ public static getInstance(baseUrl: string, authHeadersProvider?: AuthHeadersProvider): HttpClient {
15
+ return new HttpClient(baseUrl, authHeadersProvider);
12
16
  }
13
17
 
14
18
  private getFullUrl(path: string): string {
@@ -20,15 +24,15 @@ class HttpClient {
20
24
  const headers = new Headers();
21
25
  headers.set('Content-Type', 'application/json');
22
26
 
23
- try {
24
- // TODO: Add authentication token and account context if needed
25
- // For now, just return basic headers
26
- } catch (error) {
27
- console.warn('Failed to get auth headers:', error);
28
- }
29
-
30
- if (!headers.has('Content-Type')) {
31
- headers.set('Content-Type', 'application/json');
27
+ if (this.authHeadersProvider) {
28
+ try {
29
+ const authHeaders = await this.authHeadersProvider();
30
+ Object.entries(authHeaders).forEach(([key, value]) => {
31
+ headers.set(key, value);
32
+ });
33
+ } catch (error) {
34
+ console.warn('Failed to get auth headers:', error);
35
+ }
32
36
  }
33
37
 
34
38
  return headers;
@@ -138,8 +142,8 @@ class HttpClient {
138
142
  }
139
143
  }
140
144
 
141
- export function useHttpClient(baseUrl: string) {
142
- return HttpClient.getInstance(baseUrl);
145
+ export function useHttpClient(baseUrl: string, authHeadersProvider?: AuthHeadersProvider) {
146
+ return HttpClient.getInstance(baseUrl, authHeadersProvider);
143
147
  }
144
148
 
145
149
  export default HttpClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",