UNPKG

@blocklet/ui-react

Version:

Some useful front-end web components that can be used in Blocklets.

205 lines (204 loc) 4.81 kB
import { Axios } from 'axios'; import { UserPublicInfo } from '@blocklet/js-sdk'; import { OAUTH_PROVIDER } from '@arcblock/ux/lib/Util/constant'; import { CloseConnect, OpenConnect } from '@arcblock/did-connect/lib/types'; export type SessionContext = { session: Session; api: Axios; connectApi: { open: OpenConnect; close: CloseConnect; }; }; export type OAuthAccount = { provider: keyof typeof OAUTH_PROVIDER; id: string; did: string; pk: string; lastLoginAt: string; firstLoginAt: string; order?: number; userInfo?: { email: string; emailVerified: boolean; name: string; picture: string; sub: string; extraData: Object; }; }; export type WalletAccount = { provider: 'wallet'; did: string; pk: string; lastLoginAt: string; firstLoginAt: string; }; export type NFTAccount = { provider: 'nft'; did: string; pk: string; owner: string; lastLoginAt: string; firstLoginAt: string; }; export type ConnectedAccount = OAuthAccount | WalletAccount | NFTAccount; export type UserMetadataLink = { url: string; favicon?: string; }; export declare enum DurationEnum { NoClear = "no_clear", ThirtyMinutes = "30_minutes", OneHour = "1_hour", FourHours = "4_hours", Today = "today", ThisWeek = "this_week", Custom = "custom" } export declare enum StatusEnum { Meeting = "meeting", Community = "community", Holiday = "holiday", OffSick = "off_sick", WorkingRemotely = "working_remotely" } export type UserPhoneProps = { country: string; phoneNumber?: string; }; export type UserMetadata = { bio?: string; location?: string; timezone?: string; joinedAt?: string; status?: { value: string; duration?: DurationEnum; dateRange?: Date[]; }; links?: UserMetadataLink[]; cover?: string; email?: string; phone?: UserPhoneProps; }; export type UserAddress = { country?: string; province?: string; city?: string; line1?: string; line2?: string; postalCode?: string; }; export type User = UserPublicInfo & { role: string; email?: string; phone?: string; sourceProvider?: string; sourceAppPid?: string; lastLoginAt?: string; lastLoginIp?: string; createdAt?: string; passports?: any[]; didSpace?: Record<string, any>; connectedAccounts?: any[]; locale?: string; url: string; inviter?: string; emailVerified?: boolean; phoneVerified?: boolean; metadata?: UserMetadata; address?: UserAddress; }; export type UserCenterTab = { value: string; label: string; url: string; protected: boolean; icon?: string; isPrivate?: boolean; }; export type Session = { loading: boolean; initialized: boolean; user?: User; login: any; logout: any; switch: any; switchDid: any; refreshProfile: () => Promise<void>; switchProfile: any; switchPassport: any; refresh: Function; useOAuth: Function; usePasskey: Function; }; export type WebhookType = 'slack' | 'api'; export type WebhookItemData = { type: WebhookType; url: string; }; export type WebhookItemProps = { onTest: (params: WebhookItemData) => void; onSave: (params: WebhookItemData) => void; onDelete?: (params: WebhookItemData) => void; onCancel?: () => void; edit: boolean; type?: WebhookType; url?: string; }; export type CreatePassportProps = { issuer: string; title: string; issuerDid: string; issuerAvatarUrl: string; ownerDid: string; ownerName?: string; ownerAvatarUrl: string; preferredColor?: string; revoked?: boolean; isDataUrl?: boolean; width?: string; height?: string; scope?: string; role?: string; display?: { type: string; content: string; }; }; export type BlockletMetaProps = { appLogo?: React.ReactNode; appName?: string; theme?: { background?: string; }; enableConnect?: boolean; enableLocale?: boolean; navigation?: Array<{ title?: string | object; link?: string | object; icon?: string; items?: Array<{ title?: string | object; link?: string | object; }>; }>; }; export type SessionManagerProps = { showText?: boolean; showRole?: boolean; switchDid?: boolean; switchProfile?: boolean; switchPassport?: boolean; disableLogout?: boolean; onLogin?: () => void; onLogout?: () => void; onSwitchDid?: () => void; onSwitchProfile?: () => void; onSwitchPassport?: () => void; menu?: any[]; menuRender?: () => void; dark?: boolean; size?: number; };