@basictech/react 0.12.0-beta.2 → 0.12.0-beta.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement, RefObject, ButtonHTMLAttributes, HTMLAttributes } from 'react';
3
- import { BasicSchema, BasicConfig, BasicClient, BasicAccount, BasicProfile, ReadOnlyReason, AuthStatus as AuthStatus$1, BasicError, AuthUser, BasicSyncStatus, BasicRejection, BasicConflict, SourceRef, SchemaStatus, BasicDb, Repo, FileRecord, MountFileInfo, StorageInfo, FileListQuery, MountInfo, MountHandle, OutgoingShareInfo, CreateOutgoingShareInput, MountsQuery, JsonObject, BasicRecord, Query, ProjectProfile, ProjectProfilePatch, MountViewerFiles, OwnerFiles, TableNames, Collection, InferValue, KeyValueStorage, TokenStore, AuthChannelContext, AuthMessageChannel, ReplicaStoreFactory, StoragePartition, ReplicaStore, UploadTransportAdapter } from '@basictech/core';
3
+ import { BasicSchema, BasicConfig, BasicClient, BasicAccount, BasicProfile, ReadOnlyReason, AuthStatus as AuthStatus$1, BasicError, AuthUser, BasicSyncStatus, BasicRejection, BasicConflict, SourceRef, SchemaStatus, BasicDb, Repo, FileRecord, MountFileInfo, StorageInfo, FileListQuery, MountInfo, MountHandle, OutgoingShareInfo, CreateOutgoingShareInput, MountsQuery, JsonObject, BasicRecord, Query, ProjectProfile, ProjectProfilePatch, ShareInviteInfo, MountViewerFiles, OwnerFiles, TableNames, Collection, InferValue, KeyValueStorage, TokenStore, AuthChannelContext, AuthMessageChannel, ReplicaStoreFactory, StoragePartition, ReplicaStore, UploadTransportAdapter } from '@basictech/core';
4
4
 
5
5
  type BrowserBasicConfig<S extends BasicSchema = BasicSchema> = BasicConfig<S>;
6
6
  /** Create a core client with the complete browser adapter set installed. */
@@ -133,6 +133,29 @@ interface UseProjectProfileResult extends AsyncResult<ProjectProfile | null> {
133
133
  }
134
134
  declare function useProjectProfile(enabled?: boolean): UseProjectProfileResult;
135
135
 
136
+ interface UseShareInvitesResult {
137
+ data: ShareInviteInfo[];
138
+ isLoading: boolean;
139
+ error: BasicError | null;
140
+ refresh(): void;
141
+ get(id: string): Promise<ShareInviteInfo>;
142
+ accept(id: string): Promise<MountInfo>;
143
+ decline(id: string): Promise<ShareInviteInfo>;
144
+ delete(id: string): Promise<ShareInviteInfo>;
145
+ resolveContactHandle(did: string): Promise<string | null>;
146
+ }
147
+ declare function useShareInvites(enabled?: boolean): UseShareInvitesResult;
148
+
149
+ /** Names/photos are optional app-supplied data, never inferred from a share title. */
150
+ interface ShareRecipient {
151
+ did: string;
152
+ name?: string | null;
153
+ handle?: string | null;
154
+ picture?: string | null;
155
+ }
156
+ type UseShareRecipientsResult = AsyncResult<ShareRecipient[]>;
157
+ declare function useShareRecipients(dids: readonly string[]): UseShareRecipientsResult;
158
+
136
159
  type CreateBasicConfig<S extends BasicSchema> = BrowserBasicConfig<S> & {
137
160
  schema: S;
138
161
  };
@@ -169,6 +192,8 @@ interface CreatedBasic<S extends BasicSchema> {
169
192
  useStorageInfo(): UseStorageInfoResult;
170
193
  useMounts(query?: MountsQuery): UseMountsResult<S>;
171
194
  useOutgoingShares(): UseOutgoingSharesResult;
195
+ useShareInvites(enabled?: boolean): UseShareInvitesResult;
196
+ useShareRecipients(dids: readonly string[]): UseShareRecipientsResult;
172
197
  }
173
198
  /** Create one browser client and a complete hook surface bound to its schema. */
174
199
  declare function createBasic<const S extends BasicSchema>(config: CreateBasicConfig<S>): CreatedBasic<S>;
@@ -198,6 +223,9 @@ declare function useCollection<V extends JsonObject = JsonObject>(name: string,
198
223
 
199
224
  interface BasicAppearance {
200
225
  theme?: 'light' | 'dark';
226
+ /** Background color. Choose a light or dark base to match the theme. */
227
+ base?: string;
228
+ /** Hex colors get automatic black/white foreground contrast. */
201
229
  accent?: string;
202
230
  radius?: string;
203
231
  density?: 'compact' | 'comfortable';
@@ -218,16 +246,34 @@ interface AuthButtonProps extends BasicButtonProps {
218
246
  declare function SignInButton(props: AuthButtonProps): react.JSX.Element;
219
247
  declare function SignOutButton(props: AuthButtonProps): react.JSX.Element;
220
248
  interface UserAvatarProps extends HTMLAttributes<HTMLSpanElement> {
221
- profile?: (Pick<BasicProfile, 'name' | 'handle' | 'email' | 'picture'> & Partial<Pick<BasicProfile, 'kind'>>) | null;
249
+ profile?: (Pick<BasicProfile, 'name' | 'handle' | 'email' | 'picture'> & Partial<Pick<BasicProfile, 'id' | 'did' | 'kind'>>) | null;
222
250
  size?: number;
223
251
  showSyncBadge?: boolean;
224
252
  sync?: UseSyncStatusResult;
225
253
  accounts?: UseAccountsResult;
226
254
  auth?: UseAuthResult;
227
255
  projectProfile?: UseProjectProfileResult;
256
+ invites?: UseShareInvitesResult;
257
+ showInvites?: boolean;
228
258
  allowAddAccount?: boolean;
259
+ menuItems?: UserMenuItem[];
260
+ }
261
+ declare function UserAvatar({ accounts, auth, projectProfile, invites, showInvites, allowAddAccount, menuItems, ...avatarProps }: UserAvatarProps): react.JSX.Element;
262
+ interface ShareRecipientAvatarProps extends HTMLAttributes<HTMLSpanElement> {
263
+ recipient: ShareRecipient;
264
+ size?: number;
229
265
  }
230
- declare function UserAvatar({ accounts, auth, projectProfile, allowAddAccount, ...avatarProps }: UserAvatarProps): react.JSX.Element;
266
+ /** Display-only identity: no account menu, sync badge, provider, or profile lookup. */
267
+ declare function ShareRecipientAvatar({ recipient, ...props }: ShareRecipientAvatarProps): react.JSX.Element;
268
+ type ShareRecipientLabelProps = ShareRecipientAvatarProps;
269
+ /** Avatar and visible handle; accepts the same data as the avatar-only components. */
270
+ declare function ShareRecipientLabel({ recipient, size, className, ...props }: ShareRecipientLabelProps): react.JSX.Element;
271
+ interface ShareRecipientAvatarsProps extends HTMLAttributes<HTMLSpanElement> {
272
+ recipients: readonly ShareRecipient[];
273
+ size?: number;
274
+ max?: number;
275
+ }
276
+ declare function ShareRecipientAvatars({ recipients, size, max, className, ...props }: ShareRecipientAvatarsProps): react.JSX.Element;
231
277
  declare function AuthStatus({ auth: supplied, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
232
278
  auth?: UseAuthResult;
233
279
  }): react.JSX.Element;
@@ -235,6 +281,19 @@ declare function SyncStatus({ sync: supplied, source, className, ...props }: HTM
235
281
  sync?: UseSyncStatusResult;
236
282
  source?: SourceRef;
237
283
  }): react.JSX.Element | null;
284
+ /** App-owned items appear after Manage account and before Sign out. */
285
+ type UserMenuItem = {
286
+ id: string;
287
+ label: string;
288
+ icon?: ReactNode;
289
+ disabled?: boolean;
290
+ } & ({
291
+ href: string;
292
+ onClick?: never;
293
+ } | {
294
+ onClick: () => void | Promise<void>;
295
+ href?: never;
296
+ });
238
297
  interface UserButtonProps {
239
298
  accounts?: UseAccountsResult;
240
299
  auth?: UseAuthResult;
@@ -245,17 +304,20 @@ interface UserButtonProps {
245
304
  showSyncBadge?: boolean;
246
305
  shape?: 'rounded' | 'square';
247
306
  projectProfile?: UseProjectProfileResult;
307
+ invites?: UseShareInvitesResult;
308
+ showInvites?: boolean;
248
309
  /** Show the action to sign in to another account. Defaults to true. */
249
310
  allowAddAccount?: boolean;
250
311
  className?: string;
251
312
  accountSettingsUrl?: string;
313
+ menuItems?: UserMenuItem[];
252
314
  }
253
315
  declare function UserButton(props: UserButtonProps): react.JSX.Element;
254
316
  interface UserMenuProps extends UserButtonProps {
255
317
  trigger?: 'avatar' | 'button';
256
318
  avatarProps?: UserAvatarProps;
257
319
  }
258
- declare function UserMenu({ accounts: supplied, auth: suppliedAuth, sync, showSyncStatus, showSyncBadge, shape, trigger, avatarProps, projectProfile, allowAddAccount, className, accountSettingsUrl, }: UserMenuProps): react.JSX.Element;
320
+ declare function UserMenu({ accounts: supplied, auth: suppliedAuth, sync, showSyncStatus, showSyncBadge, shape, trigger, avatarProps, projectProfile, invites, showInvites, allowAddAccount, className, accountSettingsUrl, menuItems, }: UserMenuProps): react.JSX.Element;
259
321
  interface BasicModalProps {
260
322
  open?: boolean;
261
323
  onOpenChange?: (open: boolean) => void;
@@ -267,21 +329,39 @@ interface AccountSettingsModalProps extends BasicModalProps {
267
329
  auth?: UseAuthResult;
268
330
  accounts?: UseAccountsResult;
269
331
  projectProfile?: UseProjectProfileResult;
332
+ invites?: UseShareInvitesResult;
333
+ /** Show the in-app invitation inbox. Defaults to true; loads only when selected. */
334
+ showInvites?: boolean;
270
335
  sync?: UseSyncStatusResult;
271
336
  accountSettingsUrl?: string;
272
337
  children?: ReactNode;
273
338
  }
274
- declare function AccountSettingsModal({ auth: suppliedAuth, accounts: suppliedAccounts, accountSettingsUrl, projectProfile, sync, children, ...props }: AccountSettingsModalProps): react.JSX.Element;
339
+ declare function AccountSettingsModal({ auth: suppliedAuth, accounts: suppliedAccounts, accountSettingsUrl, projectProfile, invites, showInvites, sync, children, ...props }: AccountSettingsModalProps): react.JSX.Element;
340
+ interface ShareInvitesProps extends HTMLAttributes<HTMLElement> {
341
+ auth?: UseAuthResult;
342
+ accounts?: UseAccountsResult;
343
+ /** Optional complete hook result, useful for previews or app-owned state. */
344
+ invites?: UseShareInvitesResult;
345
+ }
346
+ /** Inline invitation inbox, shared by standalone and account-settings dialogs. */
347
+ declare function ShareInvites({ auth: suppliedAuth, accounts: suppliedAccounts, invites, className, ...props }: ShareInvitesProps): react.JSX.Element;
348
+ interface ShareInvitesModalProps extends BasicModalProps {
349
+ auth?: UseAuthResult;
350
+ accounts?: UseAccountsResult;
351
+ invites?: UseShareInvitesResult;
352
+ }
353
+ declare function ShareInvitesModal({ auth, accounts, invites, ...props }: ShareInvitesModalProps): react.JSX.Element;
275
354
  interface SharesModalProps extends BasicModalProps {
276
355
  auth?: UseAuthResult;
277
356
  accounts?: UseAccountsResult;
278
357
  sync?: UseSyncStatusResult;
279
358
  shares?: UseOutgoingSharesResult;
359
+ invites?: UseShareInvitesResult;
280
360
  /** Explicit least-privilege scope; the component never infers all tables. */
281
361
  scope: CreateOutgoingShareInput['scope'];
282
362
  repo?: CreateOutgoingShareInput['repo'];
283
363
  }
284
- declare function SharesModal({ auth: supplied, accounts: suppliedAccounts, sync, shares, scope, repo, ...props }: SharesModalProps): react.JSX.Element;
364
+ declare function SharesModal({ auth: supplied, accounts: suppliedAccounts, sync, shares, invites, scope, repo, ...props }: SharesModalProps): react.JSX.Element;
285
365
 
286
366
  /** Synchronous browser Storage adapted to core's key-value contract. */
287
367
  declare class BrowserKeyValueStorage implements KeyValueStorage {
@@ -378,4 +458,4 @@ declare class PersistenceStore implements ReplicaStoreFactory {
378
458
  /** Browser multipart transport with upload progress, adapted from the Drive UI. */
379
459
  declare const browserUploadTransport: UploadTransportAdapter;
380
460
 
381
- export { type AccessTokenAdopter, AccountSettingsModal, type AccountSettingsModalProps, type AuthButtonProps, AuthStatus, type BasicAppearance, BasicButton, type BasicButtonProps, type BasicModalProps, BasicProvider, type BasicProviderProps, BasicUIProvider, type BoundBasicProviderProps, type BrowserBasicConfig, BrowserKeyValueStorage, type BrowserLockManager, type BrowserMessageChannel, BrowserTokenStore, type CreateBasicConfig, type CreatedBasic, PersistenceStore, type PersistenceStoreOptions, SharesModal, type SharesModalProps, SignInButton, SignOutButton, SyncStatus, type UseAccountsResult, type UseAuthResult, type UseBasicResult, type UseFilesResult, type UseMountsResult, type UseOutgoingSharesResult, type UseProjectProfileResult, type UseQueryResult, type UseReposResult, type UseStorageInfoResult, type UseSyncStatusResult, UserAvatar, type UserAvatarProps, UserButton, type UserButtonProps, UserMenu, type UserMenuProps, browserCurrentUrl, browserNavigate, browserReplaceUrl, browserStorage, browserUploadTransport, createBasic, createBasicClient, createBrowserAuthChannelFactory, createBrowserMessageChannel, useAccounts, useAuth, useBasic, useCollection, useDb, useFiles, useMounts, useOutgoingShares, useProjectProfile, useQuery, useRepos, useSchemaStatus, useStorageInfo, useSyncStatus };
461
+ export { type AccessTokenAdopter, AccountSettingsModal, type AccountSettingsModalProps, type AuthButtonProps, AuthStatus, type BasicAppearance, BasicButton, type BasicButtonProps, type BasicModalProps, BasicProvider, type BasicProviderProps, BasicUIProvider, type BoundBasicProviderProps, type BrowserBasicConfig, BrowserKeyValueStorage, type BrowserLockManager, type BrowserMessageChannel, BrowserTokenStore, type CreateBasicConfig, type CreatedBasic, PersistenceStore, type PersistenceStoreOptions, ShareInvites, ShareInvitesModal, type ShareInvitesModalProps, type ShareInvitesProps, type ShareRecipient, ShareRecipientAvatar, type ShareRecipientAvatarProps, ShareRecipientAvatars, type ShareRecipientAvatarsProps, ShareRecipientLabel, type ShareRecipientLabelProps, SharesModal, type SharesModalProps, SignInButton, SignOutButton, SyncStatus, type UseAccountsResult, type UseAuthResult, type UseBasicResult, type UseFilesResult, type UseMountsResult, type UseOutgoingSharesResult, type UseProjectProfileResult, type UseQueryResult, type UseReposResult, type UseShareInvitesResult, type UseShareRecipientsResult, type UseStorageInfoResult, type UseSyncStatusResult, UserAvatar, type UserAvatarProps, UserButton, type UserButtonProps, UserMenu, type UserMenuItem, type UserMenuProps, browserCurrentUrl, browserNavigate, browserReplaceUrl, browserStorage, browserUploadTransport, createBasic, createBasicClient, createBrowserAuthChannelFactory, createBrowserMessageChannel, useAccounts, useAuth, useBasic, useCollection, useDb, useFiles, useMounts, useOutgoingShares, useProjectProfile, useQuery, useRepos, useSchemaStatus, useShareInvites, useShareRecipients, useStorageInfo, useSyncStatus };