@apotech-os/ui-sdk 0.8.0 → 0.10.0

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,8 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  import * as React from 'react';
3
- import { AppErrorCode } from '@apotech-os/app-kit';
3
+ import { ReactNode } from 'react';
4
+ import { AppErrorCode, AppRunRecord, AppRunStatus } from '@apotech-os/app-kit';
5
+ export { AppRunRecord, AppRunStatus } from '@apotech-os/app-kit';
4
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
5
7
  import { VariantProps } from 'class-variance-authority';
6
8
 
@@ -100,6 +102,46 @@ declare function useAppSettings<T = Record<string, unknown>>(): {
100
102
  isSaving: boolean;
101
103
  saveError: unknown;
102
104
  };
105
+ /**
106
+ * Follows a single run until it reaches a terminal status.
107
+ *
108
+ * Polling uses a recursive `setTimeout` (never `setInterval`, which piles up
109
+ * requests when the API slows down), starting at `intervalMs` (default 1 s)
110
+ * and multiplying by 1.5 each tick up to `maxIntervalMs` (default 5 s). The
111
+ * backoff resets to `intervalMs` whenever `progress` or `message` changes —
112
+ * an actively-progressing run is polled fast, a stalled one is polled slowly.
113
+ *
114
+ * `runId === null` puts the hook to sleep: no request is ever sent. This lets
115
+ * a page call the hook unconditionally with a run id that may not exist yet
116
+ * (e.g. before the triggering `uiInvoke` has returned).
117
+ */
118
+ declare function useAppRun(runId: string | null, opts?: {
119
+ intervalMs?: number;
120
+ maxIntervalMs?: number;
121
+ }): {
122
+ run: AppRunRecord | undefined;
123
+ isPolling: boolean;
124
+ error: unknown;
125
+ refresh: () => Promise<void>;
126
+ };
127
+ /**
128
+ * Lists the latest runs of a `kind` — used to re-attach the UI after a page
129
+ * reload, where the runId returned by `invoke()` is lost, and to follow a run
130
+ * by its business `key` rather than by its id.
131
+ */
132
+ declare function useAppRuns(opts: {
133
+ kind?: string;
134
+ key?: string;
135
+ status?: AppRunStatus[];
136
+ limit?: number;
137
+ /** Keeps refreshing while a non-terminal run is present. Default: true. */
138
+ follow?: boolean;
139
+ }): {
140
+ runs: AppRunRecord[];
141
+ isLoading: boolean;
142
+ error: unknown;
143
+ refresh: () => Promise<void>;
144
+ };
103
145
 
104
146
  declare const buttonVariants: (props?: ({
105
147
  variant?: "default" | "secondary" | "outline" | "ghost" | "destructive" | null | undefined;
@@ -109,7 +151,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, Var
109
151
  }
110
152
  declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
111
153
  declare const badgeVariants: (props?: ({
112
- variant?: "outline" | "neutral" | "brand" | "success" | "warning" | "danger" | "info" | null | undefined;
154
+ variant?: "success" | "outline" | "neutral" | "brand" | "warning" | "danger" | "info" | null | undefined;
113
155
  } & class_variance_authority_types.ClassProp) | undefined) => string;
114
156
  interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {
115
157
  dot?: boolean;
@@ -118,7 +160,9 @@ declare function Badge({ className, variant, dot, children, ...props }: BadgePro
118
160
  declare function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
119
161
  declare function CardHeader({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
120
162
  declare function CardTitle({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>): React.JSX.Element;
163
+ declare function CardDescription({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>): React.JSX.Element;
121
164
  declare function CardContent({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
165
+ declare function CardFooter({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
122
166
  declare const Input: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
123
167
  declare function Table({ className, ...props }: React.HTMLAttributes<HTMLTableElement>): React.JSX.Element;
124
168
  declare function TableHeader({ className, ...props }: React.HTMLAttributes<HTMLTableSectionElement>): React.JSX.Element;
@@ -150,7 +194,7 @@ declare function TabsContent({ value, className, children, }: {
150
194
  value: string;
151
195
  className?: string;
152
196
  children: React.ReactNode;
153
- }): React.JSX.Element | null;
197
+ }): React.JSX.Element;
154
198
  interface ModalProps {
155
199
  open: boolean;
156
200
  onClose: () => void;
@@ -158,7 +202,8 @@ interface ModalProps {
158
202
  children: React.ReactNode;
159
203
  className?: string;
160
204
  }
161
- declare function Modal({ open, onClose, title, children, className }: ModalProps): React.JSX.Element | null;
205
+ /** Centred blocking dialog. Base UI owns the focus trap, focus restore and Escape. */
206
+ declare function Modal({ open, onClose, title, children, className }: ModalProps): React.JSX.Element;
162
207
  interface SpinnerProps {
163
208
  className?: string;
164
209
  size?: 'sm' | 'md' | 'lg';
@@ -168,6 +213,10 @@ interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
168
213
  variant?: 'default' | 'muted';
169
214
  }
170
215
  declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
216
+ /**
217
+ * Do not pass `aria-label` when the switch sits inside a `<label>`: the label
218
+ * already names it, and the two naming sources cancel out into no name at all.
219
+ */
171
220
  interface SwitchProps {
172
221
  checked?: boolean;
173
222
  onCheckedChange?: (checked: boolean) => void;
@@ -213,9 +262,10 @@ interface SidePanelProps {
213
262
  * Children are laid out in a flex column filling the panel: put the scrollable
214
263
  * region in a `min-h-0 flex-1 overflow-y-auto` child and the footer after it.
215
264
  *
216
- * NOTE: no focus management. Autofocus the primary action yourself.
265
+ * Focus is trapped inside while open and restored to the opener on close — Base
266
+ * UI's dialog does both, which is what the hand-rolled version never did.
217
267
  */
218
- declare function SidePanel({ open, onClose, title, description, children, className, }: SidePanelProps): React.JSX.Element | null;
268
+ declare function SidePanel({ open, onClose, title, description, children, className, }: SidePanelProps): React.JSX.Element;
219
269
  interface CopyButtonProps {
220
270
  value: string;
221
271
  label?: string;
@@ -253,9 +303,45 @@ interface DropdownMenuProps {
253
303
  align?: 'start' | 'end';
254
304
  className?: string;
255
305
  }
256
- /** Uncontrolled menu built on Popover. Selecting an item closes it. */
306
+ /** Uncontrolled menu. Selecting an item closes it; arrow keys move between them. */
257
307
  declare function DropdownMenu({ trigger, items, align, className }: DropdownMenuProps): React.JSX.Element;
258
308
 
309
+ interface ToastInput {
310
+ title: string;
311
+ description?: string;
312
+ /** `info` exists because Pilotage's own stack had it — a neutral outcome is not a success. */
313
+ variant?: 'success' | 'error' | 'info';
314
+ }
315
+ /** Returns a `toast({ title, description?, variant? })` function. */
316
+ declare function useToast(): (toast: ToastInput) => void;
317
+ /** Fixed bottom-right stack, auto-dismissing. */
318
+ declare function ToastProvider({ children }: {
319
+ children: ReactNode;
320
+ }): React.JSX.Element;
321
+
322
+ /**
323
+ * Hover tooltip, lifted from the shell.
324
+ *
325
+ * Deliberately CSS-only (`group-hover`) rather than another Base UI surface: it
326
+ * carries no focus, no dismissal and no state, so a portal and a positioner would
327
+ * be weight for nothing. If a tooltip ever needs to be keyboard-reachable or to
328
+ * survive a scroll container, that is the moment to move it onto Base UI's.
329
+ */
330
+
331
+ declare const SIDES: {
332
+ readonly top: "bottom-full left-1/2 -translate-x-1/2 mb-1.5";
333
+ readonly right: "left-full top-1/2 -translate-y-1/2 ml-1.5";
334
+ readonly bottom: "top-full left-1/2 -translate-x-1/2 mt-1.5";
335
+ readonly left: "right-full top-1/2 -translate-y-1/2 mr-1.5";
336
+ };
337
+ interface TooltipProps {
338
+ label: React.ReactNode;
339
+ children: React.ReactNode;
340
+ side?: keyof typeof SIDES;
341
+ className?: string;
342
+ }
343
+ declare function Tooltip({ label, children, side, className }: TooltipProps): React.JSX.Element;
344
+
259
345
  /**
260
346
  * Browser helpers for app pages.
261
347
  *
@@ -285,4 +371,4 @@ declare function toCsv(rows: string[][]): string;
285
371
  */
286
372
  declare function downloadCsv(rows: string[][], filename: string): void;
287
373
 
288
- export { type AppApiClient, AppApiProvider, AppContextProvider, type AppContextValue, AppInvokeError, Badge, type BadgeProps, Button, type ButtonProps, Card, CardContent, CardHeader, CardTitle, Checkbox, type CheckboxProps, CopyButton, type CopyButtonProps, type DateRange, DateRangePicker, type DateRangePickerProps, DropdownMenu, type DropdownMenuItem, type DropdownMenuProps, Input, Link, type LinkProps, Modal, type ModalProps, Popover, type PopoverProps, Select, type SelectProps, SidePanel, type SidePanelProps, Spinner, type SpinnerProps, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, type TextareaProps, cn, copyToClipboard, downloadBlob, downloadCsv, toCsv, useAppApi, useAppContext, useAppSettings };
374
+ export { type AppApiClient, AppApiProvider, AppContextProvider, type AppContextValue, AppInvokeError, Badge, type BadgeProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, type CheckboxProps, CopyButton, type CopyButtonProps, type DateRange, DateRangePicker, type DateRangePickerProps, DropdownMenu, type DropdownMenuItem, type DropdownMenuProps, Input, Link, type LinkProps, Modal, type ModalProps, Popover, type PopoverProps, Select, type SelectProps, SidePanel, type SidePanelProps, Spinner, type SpinnerProps, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, type TextareaProps, type ToastInput, ToastProvider, Tooltip, type TooltipProps, badgeVariants, buttonVariants, cn, copyToClipboard, downloadBlob, downloadCsv, toCsv, useAppApi, useAppContext, useAppRun, useAppRuns, useAppSettings, useToast };