gridsmith-ui 0.11.0 → 0.13.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,20 @@ 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). A list that
868
+ * grows (load more, loading on scroll) reads "Showing 40 of 120 members" until every row is shown (round 22).
869
+ */
870
+ pagination?: {
871
+ page: number;
872
+ pageSize: number;
873
+ totalItems?: number;
874
+ style?: "pagination" | "load-more" | "infinite-scroll";
875
+ shown?: number;
876
+ };
853
877
  /** Utility actions on the right — an overflow DropdownMenu, an export button. Primary actions belong in the PageHeader. */
854
878
  actions?: ReactNode;
855
879
  size?: "sm" | "md";
@@ -865,12 +889,13 @@ interface TableToolbarProps {
865
889
  * component, so a page never hand-rolls the row. Primary actions belong in
866
890
  * the PageHeader, not here.
867
891
  */
868
- declare function TableToolbar({ search, primaryFilter, filters, filtersOpen, onFiltersOpenChange, activeFilterCount, activeFilters, onClearAll, resultCount, resultNoun, actions, size, compactBreakpoint, className, }: TableToolbarProps): react_jsx_runtime.JSX.Element;
892
+ 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
893
 
870
894
  interface TimelineItem {
871
895
  title: string;
872
896
  description?: string;
873
897
  timestamp?: string;
898
+ /** Takes the dot's place — the actor's Avatar (size="sm") on an activity feed, or an Icon. `variant` colours the dot only. */
874
899
  icon?: ReactNode;
875
900
  variant?: "default" | "success" | "warning" | "error";
876
901
  }
@@ -1457,9 +1482,21 @@ interface PaginationProps {
1457
1482
  pageSize?: number;
1458
1483
  pageSizeOptions?: number[];
1459
1484
  onPageSizeChange?: (size: number) => void;
1485
+ /**
1486
+ * How the list shows more (round 22): page numbers, a Load more button, or loading as the user scrolls (with the
1487
+ * button kept for keyboard users). `usePagination` passes the project's dataDisplay.paginationStyle here in
1488
+ * `pager.props`, so `<Pagination {...pager.props} />` follows the project's style with nothing written on the page.
1489
+ */
1490
+ mode?: "pagination" | "load-more" | "infinite-scroll";
1491
+ /** Rows left to load (load-more and infinite-scroll). */
1492
+ hasMore?: boolean;
1493
+ /** Load the next rows (load-more and infinite-scroll). */
1494
+ onLoadMore?: () => void;
1495
+ /** The Load more button's label (default "Load more"). */
1496
+ loadMoreLabel?: string;
1460
1497
  className?: string;
1461
1498
  }
1462
- declare function Pagination({ currentPage, totalPages, onPageChange, pageSize: pageSizeProp, pageSizeOptions, onPageSizeChange, className }: PaginationProps): react_jsx_runtime.JSX.Element;
1499
+ declare function Pagination(props: PaginationProps): react_jsx_runtime.JSX.Element;
1463
1500
 
1464
1501
  interface Step {
1465
1502
  label: string;
@@ -2144,6 +2181,8 @@ type PreferenceBreakpoint = "sm" | "md" | "lg";
2144
2181
  type PreferenceEmptyStyle = "illustration-cta" | "text-cta" | "redirect";
2145
2182
  type PreferenceLoadingStyle = "skeleton" | "spinner" | "progress-bar";
2146
2183
  type PreferenceDestructiveMode = "dialog" | "undo";
2184
+ /** dataDisplay.paginationStyle — how a long list shows more: page numbers, a Load more button, or loading as the user scrolls. */
2185
+ type PreferencePaginationStyle = "pagination" | "load-more" | "infinite-scroll";
2147
2186
  interface AppShellPreferences {
2148
2187
  /** forms.validationTiming — when a field first shows its error. */
2149
2188
  validationTiming?: PreferenceValidationTiming;
@@ -2154,6 +2193,8 @@ interface AppShellPreferences {
2154
2193
  };
2155
2194
  /** dataDisplay.itemsPerPage — the page size of a paged or load-more list. */
2156
2195
  itemsPerPage?: number;
2196
+ /** dataDisplay.paginationStyle — page numbers, a Load more button, or loading on scroll; usePagination and Pagination follow it (round 22). */
2197
+ paginationStyle?: PreferencePaginationStyle;
2157
2198
  /** responsive.tableToCardsBreakpoint — below this width a Table becomes stacked cards. */
2158
2199
  tableToCardsBreakpoint?: PreferenceBreakpoint;
2159
2200
  /** emptyStates.emptyStyle — illustration with an action, text with an action, or redirect to creation. */
@@ -2170,8 +2211,30 @@ interface AppShellPreferences {
2170
2211
  undoWindowSeconds?: number;
2171
2212
  }
2172
2213
  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;
2214
+ /** Every preference in force, the shell's value or the house default — what app code reads. */
2215
+ interface ResolvedPreferences {
2216
+ validationTiming: PreferenceValidationTiming;
2217
+ formActions: {
2218
+ align: "start" | "end";
2219
+ placement: "auto" | "inline";
2220
+ };
2221
+ itemsPerPage: number;
2222
+ paginationStyle: PreferencePaginationStyle;
2223
+ tableToCardsBreakpoint: PreferenceBreakpoint;
2224
+ emptyStyle: PreferenceEmptyStyle;
2225
+ loadingStyle: PreferenceLoadingStyle;
2226
+ destructiveMode: PreferenceDestructiveMode;
2227
+ highSeverityActions: string[];
2228
+ typeToConfirmActions: string[];
2229
+ undoWindowSeconds: number;
2230
+ }
2231
+ /**
2232
+ * For app code: every preference in force — the shell's value, else the house default — so a page never writes a
2233
+ * fallback of its own. Round 21 (run 58): with every field optional, TypeScript made the builder write
2234
+ * `const { itemsPerPage = 20 } = usePreferences()`, a second copy of the preference it then edited by hand when the
2235
+ * rule changed. Paged lists use `usePagination`, which reads the page size itself.
2236
+ */
2237
+ declare function usePreferences(): ResolvedPreferences;
2175
2238
  /**
2176
2239
  * "Remove range" → "remove_range": the key the high-severity and type-to-confirm lists use. The engine's `actionKey`
2177
2240
  * (platform/src/lib/destructive-mode.ts) is the same rule for compliance; a platform test keeps the two identical.
@@ -2277,6 +2340,68 @@ interface AppShellProps {
2277
2340
  }
2278
2341
  declare const AppShell: react.ForwardRefExoticComponent<AppShellProps & react.RefAttributes<HTMLDivElement>>;
2279
2342
 
2343
+ /**
2344
+ * A long list in one hook (round 21; all three list styles since round 22). The page size and the list style are the
2345
+ * project's `dataDisplay.itemsPerPage` and `dataDisplay.paginationStyle`, read from the shell, so a mid-build
2346
+ * `update_rule` on either reaches every list with no page edited. The page gets what to show, the props for
2347
+ * `<Pagination>` — page numbers, a Load more button or loading on scroll, whichever the project's style is — and the
2348
+ * numbers the count line needs ("Showing 51–100 of 200 events", or "Showing 40 of 120 members" while a list grows).
2349
+ *
2350
+ * Run 58 hand-wrote the paging; runs 59 and 60 hand-wrote load-more and scroll loading — an IntersectionObserver, a
2351
+ * visible count and a page size copied in as a constant, twice in one app — because the library had no way to.
2352
+ *
2353
+ * const pager = usePagination(sortedEvents, { resetOn: [sortKey, sortDir] })
2354
+ * <TableToolbar resultCount={sortedEvents.length} resultNoun={["event", "events"]} pagination={pager} />
2355
+ * <Table columns={columns} data={pager.items.map(toRow)} />
2356
+ * <Pagination {...pager.props} />
2357
+ */
2358
+ interface Pager<T> {
2359
+ /** The list style this list follows: the project's, unless `style` was passed. */
2360
+ style: PreferencePaginationStyle;
2361
+ /** What to show: the current page's rows, or every row loaded so far on a list that grows. */
2362
+ items: T[];
2363
+ /** The current page, from 1; on a growing list, how many pages are loaded. */
2364
+ page: number;
2365
+ pageSize: number;
2366
+ totalItems: number;
2367
+ totalPages: number;
2368
+ /** The first and last row numbers on screen, from 1 ("Showing 51–100"); [0, 0] for an empty list. */
2369
+ range: [number, number];
2370
+ /** How many rows are on screen. */
2371
+ shown: number;
2372
+ /** Rows left to show: a next page, or more to load. */
2373
+ hasMore: boolean;
2374
+ /** The next page, or the next `pageSize` rows on a growing list. */
2375
+ loadMore: () => void;
2376
+ setPage: (page: number) => void;
2377
+ /** A page-size selector's choice; it wins over the project's page size and starts again at page 1. */
2378
+ setPageSize: (size: number) => void;
2379
+ /** Spread onto <Pagination>: it renders page numbers, a Load more button or the scroll trigger, as `style` says. */
2380
+ props: {
2381
+ currentPage: number;
2382
+ totalPages: number;
2383
+ onPageChange: (page: number) => void;
2384
+ pageSize: number;
2385
+ onPageSizeChange: (size: number) => void;
2386
+ mode: PreferencePaginationStyle;
2387
+ hasMore: boolean;
2388
+ onLoadMore: () => void;
2389
+ };
2390
+ }
2391
+ interface PaginationOptions {
2392
+ /** A fixed page size for this list, over the project's. Leave it out: the project's page size is the rule. */
2393
+ pageSize?: number;
2394
+ /** Values that start the list again at page 1 when they change — the sort column and direction, a search query. */
2395
+ resetOn?: unknown;
2396
+ /**
2397
+ * A list style for this list only, over the project's. Leave it out: the project's style is the rule. Passing one that
2398
+ * differs is overriding a rule in force — ask the user first, and put `// @gridsmith-override
2399
+ * dataDisplay.paginationStyle: <their reason>` above the call.
2400
+ */
2401
+ style?: PreferencePaginationStyle;
2402
+ }
2403
+ declare function usePagination<T>(list: readonly T[], options?: PaginationOptions): Pager<T>;
2404
+
2280
2405
  interface DestructiveActionOptions {
2281
2406
  /** The action's key as the preference lists name it ("remove_range"); derived from `title` when omitted. */
2282
2407
  action?: string;
@@ -2452,4 +2577,4 @@ interface UseTextOverflowResult {
2452
2577
  */
2453
2578
  declare function useTextOverflow(options?: UseTextOverflowOptions): UseTextOverflowResult;
2454
2579
 
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 };
2580
+ 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 };