academe-kit 0.1.1 → 0.1.2
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/dist/index.d.ts +3 -0
- package/dist/index.esm.js +7 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/types/components/Button/Button.d.ts +7 -0
- package/dist/types/components/Button/index.d.ts +2 -0
- package/dist/types/components/ProtectedApp/index.d.ts +7 -0
- package/dist/types/components/ProtectedComponent/index.d.ts +6 -0
- package/dist/types/components/ProtectedRouter/index.d.ts +7 -0
- package/dist/types/components/ui/spinner.d.ts +2 -0
- package/dist/types/context/SecurityProvider/index.d.ts +8 -0
- package/dist/types/context/SecurityProvider/types.d.ts +30 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/package.json +3 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
variant?: 'primary' | 'secondary' | 'outline';
|
|
4
|
+
size?: 'sm' | 'md' | 'lg';
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SecurityContextType, AcademeKeycloakContextProps } from "./types";
|
|
2
|
+
export declare const AcademeAuthProvider: React.FC<AcademeKeycloakContextProps>;
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare const useAcademeAuth: () => SecurityContextType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { KeycloakLoginOptions, KeycloakPromise } from 'keycloak-js';
|
|
2
|
+
export type AcademeKeycloakContextProps = {
|
|
3
|
+
realm: string;
|
|
4
|
+
hubUrl: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
keycloakUrl: string;
|
|
7
|
+
children: React.ReactElement;
|
|
8
|
+
};
|
|
9
|
+
export type SecurityProviderProps = {
|
|
10
|
+
hubUrl: string;
|
|
11
|
+
children: React.ReactElement;
|
|
12
|
+
};
|
|
13
|
+
export type KeycloakUser = {
|
|
14
|
+
name: string;
|
|
15
|
+
lastName: string;
|
|
16
|
+
email: string;
|
|
17
|
+
attributes: {
|
|
18
|
+
school_ids: Array<string>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type SecurityContextType = {
|
|
22
|
+
isInitialized: boolean;
|
|
23
|
+
isAuthenticated: () => boolean;
|
|
24
|
+
signOut: () => void | null;
|
|
25
|
+
redirectToHub: (errorMessage: string) => void | null;
|
|
26
|
+
goToLogin: (options?: KeycloakLoginOptions | undefined) => KeycloakPromise<void, void> | null;
|
|
27
|
+
getUser: () => KeycloakUser;
|
|
28
|
+
hasRealmRole: (role: string) => boolean;
|
|
29
|
+
hasClientRole: (role: string, resource?: string) => boolean;
|
|
30
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Button } from './components/Button';
|
|
2
|
+
export type { ButtonProps } from './components/Button';
|
|
3
|
+
export { ProtectedApp } from './components/ProtectedApp';
|
|
4
|
+
export { ProtectedComponent } from './components/ProtectedComponent';
|
|
5
|
+
export { ProtectedRouter } from './components/ProtectedRouter';
|
|
6
|
+
export { Spinner } from './components/ui/spinner';
|
|
7
|
+
export { AcademeAuthProvider, useAcademeAuth } from './context/SecurityProvider';
|
|
8
|
+
export type { AcademeKeycloakContextProps, SecurityProviderProps, KeycloakUser, SecurityContextType, } from './context/SecurityProvider/types';
|
|
9
|
+
export { cn } from './lib/utils';
|
|
10
|
+
import './styles/globals.css';
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "academe-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A React component library with Tailwind CSS and Storybook",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"module": "dist/index.esm.js",
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
"scripts": {
|
|
12
13
|
"dev": "storybook dev -p 6006",
|
|
13
14
|
"build": "rollup -c",
|
|
15
|
+
"build:watch": "rollup -c --watch",
|
|
14
16
|
"build-storybook": "storybook build",
|
|
15
17
|
"storybook": "storybook dev -p 6006"
|
|
16
18
|
},
|