gridsmith-ui 0.10.0 → 0.12.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
@@ -433,6 +433,15 @@ interface FormWrapperProps {
433
433
  */
434
434
  actions?: ReactNode;
435
435
  actionsAlign?: "start" | "end";
436
+ /**
437
+ * Renders a secondary Cancel before the actions. Inside a Drawer, Sheet or Dialog it closes the overlay through its
438
+ * unsaved-changes check — the question Escape and the close control ask while the form is dirty — and the overlay's
439
+ * onClose runs; anywhere else this function runs. Never hand-wire a Cancel to the overlay's close: it skips the
440
+ * question (round 21, run 58).
441
+ */
442
+ onCancel?: () => void;
443
+ /** The Cancel button's label (default "Cancel"). */
444
+ cancelLabel?: string;
436
445
  /** After a failed submit, scroll to and focus the first invalid field (default on). */
437
446
  focusFirstError?: boolean;
438
447
  /**
@@ -443,7 +452,7 @@ interface FormWrapperProps {
443
452
  className?: string;
444
453
  ref?: React.Ref<HTMLFormElement>;
445
454
  }
446
- declare function FormWrapper({ onSubmit, validationMode: validationModeProp, children, actions, actionsAlign: actionsAlignProp, focusFirstError, errorSummary, className, ref }: FormWrapperProps): react_jsx_runtime.JSX.Element;
455
+ declare function FormWrapper({ onSubmit, validationMode: validationModeProp, children, actions: actionsProp, actionsAlign: actionsAlignProp, onCancel, cancelLabel, focusFirstError, errorSummary, className, ref }: FormWrapperProps): react_jsx_runtime.JSX.Element;
447
456
 
448
457
  interface TransferItem {
449
458
  id: string;
@@ -716,6 +725,7 @@ declare const Tag: react.ForwardRefExoticComponent<TagProps & react.RefAttribute
716
725
  type AvatarStatus = "online" | "away" | "busy" | "offline";
717
726
  type AvatarColor = "auto" | "accent" | "neutral" | 1 | 2 | 3 | 4 | 5;
718
727
  interface AvatarProps {
728
+ /** One to three letters ("JB"). A name passed here shows its initials ("Amara Haddad" → "AH"), never the whole name. */
719
729
  initials?: string;
720
730
  src?: string;
721
731
  alt?: string;
@@ -791,7 +801,7 @@ interface EntityCellProps {
791
801
  avatar?: ReactNode;
792
802
  /** An image URL for the avatar. */
793
803
  src?: string;
794
- /** Initials for the avatar. Absent, and with no src or element, they are derived from `primary` ("Sarah Chen" → "SC"). */
804
+ /** Leave it out: with no src or element the initials come from `primary` ("Sarah Chen" → "SC"). A name passed here shows its initials too (round 21). */
795
805
  initials?: string;
796
806
  primary: string;
797
807
  secondary?: string;
@@ -850,6 +860,17 @@ interface TableToolbarProps {
850
860
  /** How many rows match; shown with `resultNoun`. */
851
861
  resultCount?: number;
852
862
  resultNoun?: [singular: string, plural: string];
863
+ /**
864
+ * The list is paged: pass the `usePagination` result and the count says which rows are showing — "Showing 51–100 of
865
+ * 200 events" — instead of a bare total the table does not show (round 21, the owner's call); one page reads
866
+ * "12 events". Under tabs that carry the counts, pass the pager alone (no resultCount): the line then shows only the
867
+ * range, and only while the list spans pages — the tabs already say how many (gs:count-duplicated-by-tabs).
868
+ */
869
+ pagination?: {
870
+ page: number;
871
+ pageSize: number;
872
+ totalItems?: number;
873
+ };
853
874
  /** Utility actions on the right — an overflow DropdownMenu, an export button. Primary actions belong in the PageHeader. */
854
875
  actions?: ReactNode;
855
876
  size?: "sm" | "md";
@@ -865,7 +886,7 @@ interface TableToolbarProps {
865
886
  * component, so a page never hand-rolls the row. Primary actions belong in
866
887
  * the PageHeader, not here.
867
888
  */
868
- declare function TableToolbar({ search, primaryFilter, filters, filtersOpen, onFiltersOpenChange, activeFilterCount, activeFilters, onClearAll, resultCount, resultNoun, actions, size, compactBreakpoint, className, }: TableToolbarProps): react_jsx_runtime.JSX.Element;
889
+ declare function TableToolbar({ search, primaryFilter, filters, filtersOpen, onFiltersOpenChange, activeFilterCount, activeFilters, onClearAll, resultCount, resultNoun, pagination, actions, size, compactBreakpoint, className, }: TableToolbarProps): react_jsx_runtime.JSX.Element | null;
869
890
 
870
891
  interface TimelineItem {
871
892
  title: string;
@@ -2170,8 +2191,29 @@ interface AppShellPreferences {
2170
2191
  undoWindowSeconds?: number;
2171
2192
  }
2172
2193
  declare const PreferencesContext: react.Context<AppShellPreferences | null>;
2173
- /** The shell's preferences, or an empty object outside any shell — so `usePreferences().itemsPerPage ?? 25` reads naturally. */
2174
- declare function usePreferences(): AppShellPreferences;
2194
+ /** Every preference in force, the shell's value or the house default — what app code reads. */
2195
+ interface ResolvedPreferences {
2196
+ validationTiming: PreferenceValidationTiming;
2197
+ formActions: {
2198
+ align: "start" | "end";
2199
+ placement: "auto" | "inline";
2200
+ };
2201
+ itemsPerPage: number;
2202
+ tableToCardsBreakpoint: PreferenceBreakpoint;
2203
+ emptyStyle: PreferenceEmptyStyle;
2204
+ loadingStyle: PreferenceLoadingStyle;
2205
+ destructiveMode: PreferenceDestructiveMode;
2206
+ highSeverityActions: string[];
2207
+ typeToConfirmActions: string[];
2208
+ undoWindowSeconds: number;
2209
+ }
2210
+ /**
2211
+ * For app code: every preference in force — the shell's value, else the house default — so a page never writes a
2212
+ * fallback of its own. Round 21 (run 58): with every field optional, TypeScript made the builder write
2213
+ * `const { itemsPerPage = 20 } = usePreferences()`, a second copy of the preference it then edited by hand when the
2214
+ * rule changed. Paged lists use `usePagination`, which reads the page size itself.
2215
+ */
2216
+ declare function usePreferences(): ResolvedPreferences;
2175
2217
  /**
2176
2218
  * "Remove range" → "remove_range": the key the high-severity and type-to-confirm lists use. The engine's `actionKey`
2177
2219
  * (platform/src/lib/destructive-mode.ts) is the same rule for compliance; a platform test keeps the two identical.
@@ -2277,6 +2319,49 @@ interface AppShellProps {
2277
2319
  }
2278
2320
  declare const AppShell: react.ForwardRefExoticComponent<AppShellProps & react.RefAttributes<HTMLDivElement>>;
2279
2321
 
2322
+ /**
2323
+ * A paged list in one hook (round 21). The page size is the project's `dataDisplay.itemsPerPage`, read from the
2324
+ * shell, so a mid-build `update_rule` reaches every paged list with no page edited; the page gets its slice, the
2325
+ * props for `<Pagination>` and the numbers the count line needs ("Showing 51–100 of 200 events").
2326
+ *
2327
+ * Run 58 showed why: both pages hand-wrote the same slicing, a `totalPages` sum and a fallback page size of their
2328
+ * own, and the count line above the table said "200 events" while the table showed fifty.
2329
+ *
2330
+ * const pager = usePagination(sortedEvents, { resetOn: [sortKey, sortDir] })
2331
+ * <TableToolbar resultCount={sortedEvents.length} resultNoun={["event", "events"]} pagination={pager} />
2332
+ * <Table columns={columns} data={pager.items.map(toRow)} />
2333
+ * <Pagination {...pager.props} />
2334
+ */
2335
+ interface Pager<T> {
2336
+ /** This page's slice of the list. */
2337
+ items: T[];
2338
+ /** The current page, from 1. */
2339
+ page: number;
2340
+ pageSize: number;
2341
+ totalItems: number;
2342
+ totalPages: number;
2343
+ /** The first and last item numbers on this page, from 1 ("Showing 51–100"); [0, 0] for an empty list. */
2344
+ range: [number, number];
2345
+ setPage: (page: number) => void;
2346
+ /** A page-size selector's choice; it wins over the project's page size and starts again at page 1. */
2347
+ setPageSize: (size: number) => void;
2348
+ /** Spread onto <Pagination>. */
2349
+ props: {
2350
+ currentPage: number;
2351
+ totalPages: number;
2352
+ onPageChange: (page: number) => void;
2353
+ pageSize: number;
2354
+ onPageSizeChange: (size: number) => void;
2355
+ };
2356
+ }
2357
+ interface PaginationOptions {
2358
+ /** A fixed page size for this list, over the project's. Leave it out: the project's page size is the rule. */
2359
+ pageSize?: number;
2360
+ /** Values that start the list again at page 1 when they change — the sort column and direction, a search query. */
2361
+ resetOn?: unknown;
2362
+ }
2363
+ declare function usePagination<T>(list: readonly T[], options?: PaginationOptions): Pager<T>;
2364
+
2280
2365
  interface DestructiveActionOptions {
2281
2366
  /** The action's key as the preference lists name it ("remove_range"); derived from `title` when omitted. */
2282
2367
  action?: string;
@@ -2452,4 +2537,4 @@ interface UseTextOverflowResult {
2452
2537
  */
2453
2538
  declare function useTextOverflow(options?: UseTextOverflowOptions): UseTextOverflowResult;
2454
2539
 
2455
- export { Accordion, ActionPanel, ActionPanelGroup, Alert, type AlertPlacement, AppShell, type AppShellContextValue, type AppShellPreferences, type AppShellTheme, AsidePanel, type AsidePanelProps, type AsidePanelSide, Avatar, AvatarGroup, type AvatarGroupItem, type AvatarGroupProps, type AvatarStatus, Badge, type BadgePaletteColor, type BadgeSeverity, type BadgeSize, type BadgeVariant, BottomNav, type BottomNavItem, type BreadcrumbItem$1 as BreadcrumbItem, Breadcrumbs, type BreadcrumbsSeparator, type BreadcrumbsSize, type BreadcrumbsVariant, BreakpointKey, BulkActionBar, Button, ButtonSizeContext, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, type CardSelectType, CardTitle, type CardVariant, Carousel, type ChatMessage, type ChatMessageAction, type ChatMessageLayout, ChatMessageList, type ChatMessageSender, type ChatMessageSource, type ChatMessageStatus, ChatPanel, type ChatPanelProps, type ChatPanelStatusTone, Checkbox, CheckboxGroup, CheckboxGroupItem, CodeBlock, Collapsible, ColorPicker, type Column, Combobox, CommandPalette, ContextMenu, type ControlSize, ControlSizeContext, CornerPanel, type CornerPanelEdge, type CornerPanelProps, DEFAULT_DATE_RANGE_PRESETS, DataList, DatePicker, type DateRange, DateRangePicker, type DateRangePickerProps, type DateRangePreset, type DescriptionItem, DescriptionList, type DescriptionListOrientation, type DescriptionListSize, type DestructiveActionHandle, type DestructiveActionOptions, Dialog, Divider, Dock, Drawer, Dropdown, DropdownMenu, type DropdownMenuDivider, type DropdownMenuEntry, type DropdownMenuItem, EmptyState, EntityCell, Field, type FieldControlProps, type FieldProps, FileUpload, FormWrapper, HoverCard, InlineFieldError, Input, Kbd, Label, Launcher, type LauncherEdge, type LauncherProps, type LauncherVariant, type LauncherWhenOpen, Link, type LinkProps, MentionInput, MobileHeaderMenu, type MobileHeaderMenuItemData, type MobileHeaderMenuType, NavItem, type NavItemProps, type NavItemType, NavMenu, type NavMenuItem, Navbar, type NavbarSize, type NavbarType, type NavbarVariant, NotificationCenter, NumberInput, PageContainer, type PageContainerWidth, PageHeader, type PageHeaderBehavior, type PageHeaderIntensity, type PageHeaderProps, type PageHeaderVariant, Pagination, PinInput, Popover, PreferencesContext, Progress, type PromiseToastMessages, RadioGroup, Rating, ScrollArea, SectionHeading, type SectionHeadingProps, SegmentedControl, SettingsLayout, type SettingsLayoutProps, type SettingsSection, Sheet, Sidebar, type SidebarContextValue, type SidebarItem, SidebarNav, type SidebarNavSize, type SidebarPosition, type SidebarSection, type SidebarType, Skeleton, SkipLink, SliderRange, Spinner, StackedList, type StackedListVariant, StatsCard, StatusDot, type StatusDotVariant, Stepper, type Tab, Table, type TableDensity, type TableProps, TableToolbar, type TableToolbarActiveFilter, type TableToolbarFilterOption, Tabs, Tag, TagInput, type TagPaletteColor, type TagVariant, TextOverflow, type TextOverflowProps, Textarea, TimePicker, Timeline, Toast, type ToastAction, type ToastApi, type ToastOptions, type ToastPosition, ToastProvider, type ToastVariant, Toggle, Tooltip, Tour, TransferList, TreeView, type Trend, type UseTextOverflowOptions, type UseTextOverflowResult, preferenceActionKey, useAppShell, useContentWidth, useDestructiveAction, useFormContext, usePreferences, useSidebar, useTextOverflow, useToast, useToastOptional };
2540
+ export { Accordion, ActionPanel, ActionPanelGroup, Alert, type AlertPlacement, AppShell, type AppShellContextValue, type AppShellPreferences, type AppShellTheme, AsidePanel, type AsidePanelProps, type AsidePanelSide, Avatar, AvatarGroup, type AvatarGroupItem, type AvatarGroupProps, type AvatarStatus, Badge, type BadgePaletteColor, type BadgeSeverity, type BadgeSize, type BadgeVariant, BottomNav, type BottomNavItem, type BreadcrumbItem$1 as BreadcrumbItem, Breadcrumbs, type BreadcrumbsSeparator, type BreadcrumbsSize, type BreadcrumbsVariant, BreakpointKey, BulkActionBar, Button, ButtonSizeContext, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, type CardSelectType, CardTitle, type CardVariant, Carousel, type ChatMessage, type ChatMessageAction, type ChatMessageLayout, ChatMessageList, type ChatMessageSender, type ChatMessageSource, type ChatMessageStatus, ChatPanel, type ChatPanelProps, type ChatPanelStatusTone, Checkbox, CheckboxGroup, CheckboxGroupItem, CodeBlock, Collapsible, ColorPicker, type Column, Combobox, CommandPalette, ContextMenu, type ControlSize, ControlSizeContext, CornerPanel, type CornerPanelEdge, type CornerPanelProps, DEFAULT_DATE_RANGE_PRESETS, DataList, DatePicker, type DateRange, DateRangePicker, type DateRangePickerProps, type DateRangePreset, type DescriptionItem, DescriptionList, type DescriptionListOrientation, type DescriptionListSize, type DestructiveActionHandle, type DestructiveActionOptions, Dialog, Divider, Dock, Drawer, Dropdown, DropdownMenu, type DropdownMenuDivider, type DropdownMenuEntry, type DropdownMenuItem, EmptyState, EntityCell, Field, type FieldControlProps, type FieldProps, FileUpload, FormWrapper, HoverCard, InlineFieldError, Input, Kbd, Label, Launcher, type LauncherEdge, type LauncherProps, type LauncherVariant, type LauncherWhenOpen, Link, type LinkProps, MentionInput, MobileHeaderMenu, type MobileHeaderMenuItemData, type MobileHeaderMenuType, NavItem, type NavItemProps, type NavItemType, NavMenu, type NavMenuItem, Navbar, type NavbarSize, type NavbarType, type NavbarVariant, NotificationCenter, NumberInput, PageContainer, type PageContainerWidth, PageHeader, type PageHeaderBehavior, type PageHeaderIntensity, type PageHeaderProps, type PageHeaderVariant, type Pager, Pagination, type PaginationOptions, PinInput, Popover, PreferencesContext, Progress, type PromiseToastMessages, RadioGroup, Rating, type ResolvedPreferences, ScrollArea, SectionHeading, type SectionHeadingProps, SegmentedControl, SettingsLayout, type SettingsLayoutProps, type SettingsSection, Sheet, Sidebar, type SidebarContextValue, type SidebarItem, SidebarNav, type SidebarNavSize, type SidebarPosition, type SidebarSection, type SidebarType, Skeleton, SkipLink, SliderRange, Spinner, StackedList, type StackedListVariant, StatsCard, StatusDot, type StatusDotVariant, Stepper, type Tab, Table, type TableDensity, type TableProps, TableToolbar, type TableToolbarActiveFilter, type TableToolbarFilterOption, Tabs, Tag, TagInput, type TagPaletteColor, type TagVariant, TextOverflow, type TextOverflowProps, Textarea, TimePicker, Timeline, Toast, type ToastAction, type ToastApi, type ToastOptions, type ToastPosition, ToastProvider, type ToastVariant, Toggle, Tooltip, Tour, TransferList, TreeView, type Trend, type UseTextOverflowOptions, type UseTextOverflowResult, preferenceActionKey, useAppShell, useContentWidth, useDestructiveAction, useFormContext, usePagination, usePreferences, useSidebar, useTextOverflow, useToast, useToastOptional };