@bgarizao/admin-library 0.1.0 → 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.
Files changed (41) hide show
  1. package/dist/dts/components/AdminLayout/index.d.ts +22 -0
  2. package/dist/dts/components/AdminLogin/index.d.ts +20 -0
  3. package/dist/dts/components/AdminRoute/index.d.ts +14 -0
  4. package/dist/dts/components/Button/Button.d.ts +2 -0
  5. package/dist/dts/components/Button/Button.types.d.ts +6 -0
  6. package/dist/dts/components/Button/index.d.ts +2 -0
  7. package/dist/dts/components/Dropdown/Dropdown.d.ts +9 -0
  8. package/dist/dts/components/Dropdown/DropdownItem.d.ts +12 -0
  9. package/dist/dts/components/Dropdown/index.d.ts +2 -0
  10. package/dist/dts/components/IconSelect/index.d.ts +10 -0
  11. package/dist/dts/components/Icons/Icon.d.ts +6 -0
  12. package/dist/dts/components/Icons/index.d.ts +1 -0
  13. package/dist/dts/components/Inputs/Input.d.ts +8 -0
  14. package/dist/dts/components/Inputs/Select.d.ts +6 -0
  15. package/dist/dts/components/Inputs/TextArea.d.ts +2 -0
  16. package/dist/dts/components/Inputs/index.d.ts +3 -0
  17. package/dist/dts/components/MediaPreview/index.d.ts +28 -0
  18. package/dist/dts/components/Text/Text.d.ts +12 -0
  19. package/dist/dts/components/Text/index.d.ts +1 -0
  20. package/dist/dts/components/UrlField/index.d.ts +17 -0
  21. package/dist/dts/components/index.d.ts +12 -0
  22. package/dist/dts/hooks/index.d.ts +2 -0
  23. package/dist/dts/hooks/useAuth.d.ts +22 -0
  24. package/dist/dts/hooks/useDarkMode.d.ts +1 -0
  25. package/dist/dts/index.d.ts +9 -0
  26. package/dist/dts/libs/authUtils.d.ts +18 -0
  27. package/dist/dts/libs/icosLibs.d.ts +12 -0
  28. package/dist/dts/libs/index.d.ts +4 -0
  29. package/dist/dts/libs/sanityClient/index.d.ts +15 -0
  30. package/dist/dts/libs/sanityImage.d.ts +11 -0
  31. package/dist/dts/modals/IconModal.d.ts +9 -0
  32. package/dist/dts/modals/PreviewImage.d.ts +5 -0
  33. package/dist/dts/modals/index.d.ts +2 -0
  34. package/dist/dts/pages/SubscriptionPage/index.d.ts +14 -0
  35. package/dist/dts/pages/SubscriptionPage/useSubscription.d.ts +26 -0
  36. package/dist/dts/pages/index.d.ts +1 -0
  37. package/dist/index.esm.js +109 -29
  38. package/dist/index.esm.js.map +1 -1
  39. package/dist/index.js +108 -27
  40. package/dist/index.js.map +1 -1
  41. package/package.json +3 -19
@@ -0,0 +1,22 @@
1
+ import React, { ReactNode } from 'react';
2
+ export interface MenuItem {
3
+ key: string;
4
+ label: string;
5
+ icon?: ReactNode;
6
+ path?: string;
7
+ children?: MenuItem[];
8
+ }
9
+ interface AdminLayoutProps {
10
+ menu: MenuItem[];
11
+ onLogout: () => void;
12
+ children: ReactNode;
13
+ onMenuClick?: (key: string, path?: string) => void;
14
+ }
15
+ interface AdminLayoutContextType {
16
+ collapsed: boolean;
17
+ setCollapsed: (collapsed: boolean) => void;
18
+ }
19
+ export declare const AdminLayoutContext: React.Context<AdminLayoutContextType>;
20
+ export declare const useAdminLayout: () => AdminLayoutContextType;
21
+ declare const AdminLayout: React.FC<AdminLayoutProps>;
22
+ export default AdminLayout;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ interface LoginCredentials {
3
+ email: string;
4
+ password: string;
5
+ }
6
+ interface User {
7
+ _id: string;
8
+ name: string;
9
+ email: string;
10
+ role: 'superadmin' | 'admin' | 'editor';
11
+ }
12
+ interface AdminLoginProps {
13
+ title?: string;
14
+ logo?: string;
15
+ onLogin: (credentials: LoginCredentials) => Promise<User>;
16
+ onSuccess?: () => void;
17
+ loggedInUser?: User | null;
18
+ }
19
+ declare const AdminLogin: React.FC<AdminLoginProps>;
20
+ export default AdminLogin;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ interface User {
3
+ _id: string;
4
+ name: string;
5
+ email: string;
6
+ role: 'superadmin' | 'admin' | 'editor';
7
+ }
8
+ interface AdminRouteProps {
9
+ children: React.ReactNode;
10
+ user: User | null;
11
+ redirectTo?: string;
12
+ }
13
+ declare const AdminRoute: React.FC<AdminRouteProps>;
14
+ export default AdminRoute;
@@ -0,0 +1,2 @@
1
+ import type { ButtonProps } from "./Button.types";
2
+ export declare const Button: ({ className, children, variant, startIcon, endIcon, size, ...rest }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { ButtonProps as ButtonPropsAntd } from "antd";
2
+ import { ReactNode } from "react";
3
+ export interface ButtonProps extends ButtonPropsAntd {
4
+ startIcon?: ReactNode;
5
+ endIcon?: ReactNode;
6
+ }
@@ -0,0 +1,2 @@
1
+ export { Button } from "./Button";
2
+ export type { ButtonProps } from "./Button.types";
@@ -0,0 +1,9 @@
1
+ import type React from "react";
2
+ interface DropdownProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ children: React.ReactNode;
6
+ className?: string;
7
+ }
8
+ export declare const Dropdown: ({ isOpen, onClose, children, className, }: DropdownProps) => import("react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ import type React from "react";
2
+ interface DropdownItemProps {
3
+ tag?: "a" | "button";
4
+ to?: string;
5
+ onClick?: () => void;
6
+ onItemClick?: () => void;
7
+ baseClassName?: string;
8
+ className?: string;
9
+ children: React.ReactNode;
10
+ }
11
+ export declare const DropdownItem: ({ tag, to, onClick, onItemClick, baseClassName, className, children, }: DropdownItemProps) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ export { Dropdown } from "./Dropdown";
2
+ export { DropdownItem } from "./DropdownItem";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { IconData } from "@lineiconshq/free-icons";
3
+ type IconSelectValue = string | IconData | undefined;
4
+ interface IconSelectProps {
5
+ value?: IconSelectValue;
6
+ onChange?: (value: string) => void;
7
+ placeholder?: string;
8
+ }
9
+ export declare const IconSelect: React.FC<IconSelectProps>;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ interface IconProps {
2
+ name: string;
3
+ className?: string;
4
+ }
5
+ export declare const Icon: ({ name, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1 @@
1
+ export { Icon } from "./Icon";
@@ -0,0 +1,8 @@
1
+ import { InputProps } from "antd";
2
+ export declare const Input: {
3
+ ({ children, ...rest }: InputProps): import("react/jsx-runtime").JSX.Element;
4
+ Password: import("react").ForwardRefExoticComponent<import("antd/es/input").PasswordProps & import("react").RefAttributes<import("rc-input").InputRef>>;
5
+ Search: import("react").ForwardRefExoticComponent<import("antd/es/input").SearchProps & import("react").RefAttributes<import("rc-input").InputRef>>;
6
+ TextArea: import("react").ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & import("react").RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
7
+ OTP: import("react").ForwardRefExoticComponent<import("antd/es/input/OTP").OTPProps & import("react").RefAttributes<import("antd/es/input/OTP").OTPRef>>;
8
+ };
@@ -0,0 +1,6 @@
1
+ import { SelectProps } from "antd";
2
+ export declare const Select: {
3
+ ({ className, ...rest }: SelectProps): import("react/jsx-runtime").JSX.Element;
4
+ Option: import("rc-select/lib/Option").OptionFC;
5
+ OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
6
+ };
@@ -0,0 +1,2 @@
1
+ import { TextAreaProps } from "antd/es/input";
2
+ export declare const TextArea: ({ ...rest }: TextAreaProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export { Input } from "./Input";
2
+ export { Select } from "./Select";
3
+ export { TextArea } from "./TextArea";
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ interface MediaPreviewProps {
3
+ /** URL of the image or video to display */
4
+ src: string | null | undefined;
5
+ /** Alt text for images (optional) */
6
+ alt?: string;
7
+ /** Maximum width in pixels (default: 200) */
8
+ maxWidth?: number | string;
9
+ /** Maximum height in pixels (default: 120) */
10
+ maxHeight?: number | string;
11
+ /** Border radius in pixels (default: 4) */
12
+ borderRadius?: number;
13
+ /** Show video controls (default: true) */
14
+ showControls?: boolean;
15
+ /** Optional className for additional styling */
16
+ className?: string;
17
+ /** Optional inline styles */
18
+ style?: React.CSSProperties;
19
+ }
20
+ /**
21
+ * MediaPreview component
22
+ *
23
+ * Renders an image or video preview based on the file type.
24
+ * Automatically detects video files by extension (.mp4, .webm, .ogg)
25
+ * and renders a video player. For images, renders a standard img tag.
26
+ */
27
+ declare const MediaPreview: React.FC<MediaPreviewProps>;
28
+ export default MediaPreview;
@@ -0,0 +1,12 @@
1
+ interface Props {
2
+ children: React.ReactNode;
3
+ className?: string;
4
+ as?: React.ElementType;
5
+ }
6
+ export declare const Text: (({ as: Tag, className, children }: Props) => import("react/jsx-runtime").JSX.Element) & {
7
+ Title: ({ as: Tag, className, children }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ Subtitle: ({ as: Tag, className, children }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ Caption: ({ as: Tag, className, children }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ Label: ({ as: Tag, className, children }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ };
12
+ export {};
@@ -0,0 +1 @@
1
+ export { Text } from "./Text";
@@ -0,0 +1,17 @@
1
+ interface UrlFieldProps {
2
+ routes: {
3
+ label: string;
4
+ value: string;
5
+ }[];
6
+ isExternal: boolean;
7
+ value?: string;
8
+ onChange?: (v: string) => void;
9
+ placeholder?: string;
10
+ }
11
+ /**
12
+ * Smart URL input:
13
+ * - When isExternal=true → free-text input for any URL
14
+ * - When isExternal=false → select from known internal pages
15
+ */
16
+ export declare const UrlField: ({ routes, isExternal, value, onChange, placeholder, }: UrlFieldProps) => import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,12 @@
1
+ export * from "./Button";
2
+ export * from "./Icons";
3
+ export * from "./Dropdown";
4
+ export * from "./Text";
5
+ export * from "./Inputs";
6
+ export * from "./UrlField";
7
+ export * from "./IconSelect";
8
+ export { default as AdminLayout } from "./AdminLayout";
9
+ export * from "./AdminLogin";
10
+ export { default as AdminLogin } from "./AdminLogin";
11
+ export { default as AdminRoute } from "./AdminRoute";
12
+ export { default as MediaPreview } from "./MediaPreview";
@@ -0,0 +1,2 @@
1
+ export * from "./useDarkMode";
2
+ export * from "./useAuth";
@@ -0,0 +1,22 @@
1
+ export interface AdminUser {
2
+ _id: string;
3
+ name: string;
4
+ email: string;
5
+ role: 'superadmin' | 'admin' | 'editor';
6
+ }
7
+ interface LoginCredentials {
8
+ email: string;
9
+ password: string;
10
+ }
11
+ interface UseAuthOptions {
12
+ storageKey?: string;
13
+ }
14
+ interface UseAuthReturn {
15
+ user: AdminUser | null;
16
+ loading: boolean;
17
+ login: (credentials: LoginCredentials) => Promise<AdminUser>;
18
+ logout: () => void;
19
+ isAuthenticated: boolean;
20
+ }
21
+ export declare const createUseAuth: (loginFn: (credentials: LoginCredentials) => Promise<AdminUser>, options?: UseAuthOptions) => (() => UseAuthReturn);
22
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useDarkMode: () => boolean;
@@ -0,0 +1,9 @@
1
+ import "./styles/globals.css";
2
+ export * from "./components";
3
+ export * from "./libs";
4
+ export * from "./modals";
5
+ export * from "./hooks";
6
+ export * from "./pages";
7
+ import { default as SubscriptionPageExport } from "./pages/SubscriptionPage/index.tsx";
8
+ export { SubscriptionPageExport as SubscriptionPage };
9
+ export { useSubscription, adminClient, STRIPE_PAYMENT_LINK, STRIPE_PRODUCT_ID, getSubscriptionPageUrl, type SubscriptionData, type UseSubscriptionReturn, type SubscriptionConfig, createAdminClient } from "./pages/SubscriptionPage/useSubscription.ts";
@@ -0,0 +1,18 @@
1
+ import type { SanityClient } from "@sanity/client";
2
+ export interface User {
3
+ _id: string;
4
+ name: string;
5
+ email: string;
6
+ role: 'superadmin' | 'admin' | 'editor';
7
+ }
8
+ export interface LoginCredentials {
9
+ email: string;
10
+ password: string;
11
+ }
12
+ export interface CreateLoginFnOptions {
13
+ sanityClient: SanityClient;
14
+ comparePasswordFn?: (password: string, hashed: string) => Promise<boolean>;
15
+ }
16
+ export declare const createSanityLoginFn: (options: CreateLoginFnOptions) => (credentials: LoginCredentials) => Promise<User>;
17
+ export declare const hashPassword: (_password: string) => Promise<string>;
18
+ export declare const comparePassword: (password: string, hashed: string) => Promise<boolean>;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ /** Tipo de componente de icono compatible con className (para el front). */
3
+ export type IconComponentType = React.ComponentType<{
4
+ className?: string;
5
+ }>;
6
+ export declare function getIcon(name: string | undefined): IconComponentType;
7
+ /**
8
+ * Recorre recursivamente un objeto y reemplaza cualquier campo cuyo nombre esté
9
+ * en ICON_NAME_KEYS y cuyo valor sea un string (nombre Lineicons) por getIcon().
10
+ * No toca strings que parecen URLs (p. ej. icon que era imagen y ya es URL).
11
+ */
12
+ export declare function getIconsMap<T>(data: T): T;
@@ -0,0 +1,4 @@
1
+ export * from "./icosLibs";
2
+ export * from "./sanityImage";
3
+ export * from "./authUtils";
4
+ export * from "./sanityClient";
@@ -0,0 +1,15 @@
1
+ import { type SanityClient } from '@sanity/client';
2
+ export interface SanityClientOptions {
3
+ projectId: string;
4
+ dataset?: string;
5
+ apiVersion?: string;
6
+ useCdn?: boolean;
7
+ token?: string;
8
+ }
9
+ export declare const initSanityClient: (options: SanityClientOptions) => SanityClient;
10
+ export declare const getSanityClient: () => SanityClient;
11
+ export declare const sanityClient: {
12
+ init: (options: SanityClientOptions) => SanityClient;
13
+ get: () => SanityClient;
14
+ };
15
+ export default sanityClient;
@@ -0,0 +1,11 @@
1
+ export declare function sanityImageUrl(builder: any, source: {
2
+ asset?: {
3
+ _ref?: string;
4
+ };
5
+ } | undefined): string;
6
+ interface envProp {
7
+ proj: any;
8
+ ds: any;
9
+ }
10
+ export declare function processImages<T>(builder: any, env: envProp, data: T): T;
11
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { IconData } from "@lineiconshq/free-icons";
2
+ interface IconModalProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ onSelect: (iconName: string) => void;
6
+ selectedValue?: string | IconData;
7
+ }
8
+ export declare const IconModal: ({ open, onClose, onSelect, selectedValue, }: IconModalProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,5 @@
1
+ import { GetProp, UploadProps } from "antd";
2
+ type FileType = Parameters<GetProp<UploadProps, "beforeUpload">>[0];
3
+ export declare const getBase64: (file: FileType) => Promise<string>;
4
+ export declare const PreviewImage: ({ file, open, onClose }: any) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./PreviewImage";
2
+ export * from "./IconModal";
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ interface SubscriptionPageProps {
3
+ subscriptionStatus?: 'active' | 'inactive' | 'past_due' | 'canceled' | 'trialing' | 'none';
4
+ currentPeriodEnd?: string;
5
+ cancelAtPeriodEnd?: boolean;
6
+ onSubscribe?: () => void;
7
+ onManageBilling?: () => void;
8
+ loading?: boolean;
9
+ stripePaymentLink?: string;
10
+ stripeCustomerId?: string;
11
+ createBillingSession?: () => Promise<string>;
12
+ }
13
+ declare const SubscriptionPage: React.FC<SubscriptionPageProps>;
14
+ export default SubscriptionPage;
@@ -0,0 +1,26 @@
1
+ export interface SubscriptionConfig {
2
+ adminProjectId?: string;
3
+ subscriptionProductId?: string;
4
+ stripePaymentLink?: string;
5
+ }
6
+ export declare const createAdminClient: (config: SubscriptionConfig) => import("@sanity/client").SanityClient;
7
+ export declare const adminClient: import("@sanity/client").SanityClient;
8
+ export interface SubscriptionData {
9
+ subscriptionStatus: "active" | "inactive" | "past_due" | "canceled" | "trialing" | "none";
10
+ currentPeriodEnd?: string;
11
+ cancelAtPeriodEnd?: boolean;
12
+ customerEmail?: string;
13
+ subscriptionId?: string;
14
+ stripeCustomerId?: string;
15
+ stripePaymentLink?: string;
16
+ }
17
+ export interface UseSubscriptionReturn {
18
+ subscription: SubscriptionData | null;
19
+ loading: boolean;
20
+ error: string | null;
21
+ refetch: () => Promise<void>;
22
+ }
23
+ export declare const useSubscription: (email: string, config?: SubscriptionConfig) => UseSubscriptionReturn;
24
+ export declare const STRIPE_PAYMENT_LINK: string;
25
+ export declare const STRIPE_PRODUCT_ID: string;
26
+ export declare const getSubscriptionPageUrl: (config?: SubscriptionConfig) => string;
@@ -0,0 +1 @@
1
+ export * from "./SubscriptionPage";