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.
@@ -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,2 @@
1
+ export { Button } from './Button';
2
+ export type { ButtonProps } from './Button';
@@ -0,0 +1,7 @@
1
+ type ProtectedAppProps = {
2
+ children: React.ReactElement;
3
+ requiredClientRoles?: string[];
4
+ unauthorizedMessage?: string;
5
+ };
6
+ export declare const ProtectedApp: React.FC<ProtectedAppProps>;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ type ProtectedRouterProps = {
2
+ children: React.ReactElement;
3
+ requiredClientRoles: string[];
4
+ };
5
+ export declare const ProtectedComponent: React.FC<ProtectedRouterProps>;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ type ProtectedRouterProps = {
2
+ children: React.ReactElement;
3
+ requiredClientRoles?: string[];
4
+ unauthorizedMessage?: string;
5
+ };
6
+ export declare const ProtectedRouter: React.FC<ProtectedRouterProps>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ declare function Spinner({ className, ...props }: React.ComponentProps<"svg">): import("react/jsx-runtime").JSX.Element;
2
+ export { Spinner };
@@ -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';
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "academe-kit",
3
- "version": "0.1.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
  },