@scattered-light/loomiere-base-ui 0.18.0 → 0.19.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/README.md +9 -1
- package/dist/custom/collection/index.d.ts +19 -1
- package/dist/custom/collection/index.js +20 -1
- package/dist/custom/collection/index.js.map +1 -1
- package/dist/design-system/components/CollectionCards/README.md +26 -0
- package/dist/design-system/components/CollectionCards/preview.html +19 -0
- package/dist/design-system/components/bundle.js +6 -6
- package/dist/design-system/components/styles.css +87 -62
- package/dist/styles/components/Accordion.css +1 -1
- package/dist/styles/components/AlertDialog.css +1 -1
- package/dist/styles/components/Autocomplete.css +1 -1
- package/dist/styles/components/Avatar.css +1 -1
- package/dist/styles/components/Button.css +1 -1
- package/dist/styles/components/Checkbox.css +1 -1
- package/dist/styles/components/CheckboxGroup.css +1 -1
- package/dist/styles/components/Collapsible.css +1 -1
- package/dist/styles/components/Combobox.css +1 -1
- package/dist/styles/components/ContextMenu.css +1 -1
- package/dist/styles/components/Dialog.css +1 -1
- package/dist/styles/components/Drawer.css +1 -1
- package/dist/styles/components/Field.css +1 -1
- package/dist/styles/components/Fieldset.css +1 -1
- package/dist/styles/components/Form.css +1 -1
- package/dist/styles/components/Input.css +1 -1
- package/dist/styles/components/Menu.css +1 -1
- package/dist/styles/components/Menubar.css +1 -1
- package/dist/styles/components/Meter.css +1 -1
- package/dist/styles/components/NavigationMenu.css +1 -1
- package/dist/styles/components/NumberField.css +1 -1
- package/dist/styles/components/OTPField.css +1 -1
- package/dist/styles/components/Popover.css +1 -1
- package/dist/styles/components/PreviewCard.css +1 -1
- package/dist/styles/components/Progress.css +1 -1
- package/dist/styles/components/Radio.css +1 -1
- package/dist/styles/components/ScrollArea.css +1 -1
- package/dist/styles/components/Select.css +1 -1
- package/dist/styles/components/Separator.css +1 -1
- package/dist/styles/components/Slider.css +1 -1
- package/dist/styles/components/Switch.css +1 -1
- package/dist/styles/components/Tabs.css +1 -1
- package/dist/styles/components/Toast.css +1 -1
- package/dist/styles/components/Toggle.css +1 -1
- package/dist/styles/components/ToggleGroup.css +1 -1
- package/dist/styles/components/Toolbar.css +1 -1
- package/dist/styles/components/Tooltip.css +1 -1
- package/dist/styles/custom/AppBar.css +1 -1
- package/dist/styles/custom/Badge.css +1 -1
- package/dist/styles/custom/Collection.css +2 -1
- package/dist/styles/custom/CollectionCards.css +24 -0
- package/dist/styles/custom/CollectionPagination.css +1 -1
- package/dist/styles/custom/CollectionToolbar.css +1 -1
- package/dist/styles/custom/DataList.css +1 -1
- package/dist/styles/custom/DataTable.css +1 -1
- package/dist/styles/custom/DatePicker.css +1 -1
- package/dist/styles/custom/DescriptionList.css +1 -1
- package/dist/styles/custom/EditableList.css +1 -1
- package/dist/styles/custom/EmptyState.css +1 -1
- package/dist/styles/custom/ListDetail.css +1 -1
- package/dist/styles/custom/MoneyField.css +1 -1
- package/dist/styles/custom/PickerButton.css +1 -1
- package/dist/styles/custom/PickerSplit.css +1 -1
- package/dist/styles/custom/Sheet.css +1 -1
- package/dist/styles/custom/SideNav.css +1 -1
- package/dist/styles/custom/Splitter.css +1 -1
- package/dist/styles/custom/StatCard.css +1 -1
- package/dist/styles/custom/StatFigure.css +1 -1
- package/dist/styles/custom/Table.css +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/reset/accessibility.css +1 -1
- package/dist/styles/reset/reset-accessibility.css +1 -1
- package/dist/styles/reset/reset-tailwind.css +1 -1
- package/dist/styles/reset/reset.css +1 -1
- package/dist/styles/tailwind.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -254,10 +254,18 @@ npm install @tanstack/react-table
|
|
|
254
254
|
```
|
|
255
255
|
|
|
256
256
|
```tsx
|
|
257
|
-
import { DataList, DataTable, CollectionToolbar, CollectionPagination, defineColumns, useCollection } from '@scattered-light/loomiere-base-ui/custom/collection';
|
|
257
|
+
import { DataList, DataTable, CollectionToolbar, CollectionPagination, CollectionCards, defineColumns, useCollection } from '@scattered-light/loomiere-base-ui/custom/collection';
|
|
258
258
|
import { EditableList } from '@scattered-light/loomiere-base-ui/custom';
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
+
`CollectionCards` shows the current page as a grid of cards, for a page that lists things such as Entities or accounts. Give it `renderCard` (a `StatCard` works well); `CollectionToolbar` and `CollectionPagination` work with it as they do with the table.
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
<CollectionToolbar collection={collection} searchLabel="Find an Entity" showSort />
|
|
265
|
+
<CollectionCards collection={collection} label="Entities" renderCard={(e) => <StatCard title={e.name} onOpen={() => open(e.id)} />} />
|
|
266
|
+
<CollectionPagination page={collection.page} pageCount={collection.pageCount} total={collection.pageTotal} onPageChange={collection.setPage} label="Entities" />
|
|
267
|
+
```
|
|
268
|
+
|
|
261
269
|
`useCollection` holds search, sort, filters, selection, grouping, paging, and column order and visibility. DataTable and DataList render that same state. Switch views by changing the component. The plain `<table class="Table">` is unchanged, for static tables and reports.
|
|
262
270
|
|
|
263
271
|
Columns decide how a value sorts, searches, filters and totals. `rowHeader` names the row. One column may use a tabs filter. Money totals add in minor units. Search is deferred, not debounced.
|
|
@@ -477,6 +477,24 @@ interface DataTableTotalRow<T = unknown> {
|
|
|
477
477
|
*/
|
|
478
478
|
declare function DataTable<T>({ collection, label, caption, onRowActivate, getRowHref, activeRowId, rowActions, empty, loading, stickyHeader, stickyRowHeader, narrow, size, totalStyle, totalRows, treeLines, headerStyle, figures, disclosure, getRowKind, rowNavigation, className, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
479
479
|
|
|
480
|
+
interface CollectionCardsProps<T> {
|
|
481
|
+
collection: CollectionApi<T>;
|
|
482
|
+
/** Names the list for screen readers: "Entities". */
|
|
483
|
+
label: string;
|
|
484
|
+
/** One card for a row, such as a StatCard. */
|
|
485
|
+
renderCard: (row: T) => React.ReactNode;
|
|
486
|
+
/** Shown when the data itself is empty. A search with no matches uses the built-in no-results state. */
|
|
487
|
+
empty?: React.ReactNode;
|
|
488
|
+
loading?: boolean;
|
|
489
|
+
className?: string;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* The rows of a collection as a grid of cards, for a page that lists things such as Entities or
|
|
493
|
+
* accounts. Search, filter, sort and paging come from the same collection the table and list use,
|
|
494
|
+
* so CollectionToolbar and CollectionPagination work with it unchanged. It shows the current page.
|
|
495
|
+
*/
|
|
496
|
+
declare function CollectionCards<T>({ collection, label, renderCard, empty, loading, className }: CollectionCardsProps<T>): react_jsx_runtime.JSX.Element;
|
|
497
|
+
|
|
480
498
|
interface CollectionPaginationProps {
|
|
481
499
|
/** 1-based. */
|
|
482
500
|
page: number;
|
|
@@ -586,4 +604,4 @@ declare const CollectionToolbar: typeof CollectionToolbarImpl & {
|
|
|
586
604
|
*/
|
|
587
605
|
declare function totalText<T>(column: CollectionColumn<T>, rows: readonly T[], locale: string): string;
|
|
588
606
|
|
|
589
|
-
export { type CellContext, type CollectionAlign, type CollectionApi, type CollectionColumn, type CollectionFilter, type CollectionKind, CollectionPagination, type CollectionPaginationProps, type CollectionSort, CollectionToolbar, type CollectionToolbarProps, DataList, type DataListProps, DataTable, type DataTableProps, type DataTableTotalRow, type FilterKind, type FilterOption, type ListSlot, type UseCollectionOptions, balanceOf, collectionTableOptions, compareDecimal, countFacets, defineColumns, formatDate, formatMoney, headerLabel, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, selectableIds, sortRows, sumMoney, toMinor, totalText, treeVisibleIds, useCollection };
|
|
607
|
+
export { type CellContext, type CollectionAlign, type CollectionApi, CollectionCards, type CollectionCardsProps, type CollectionColumn, type CollectionFilter, type CollectionKind, CollectionPagination, type CollectionPaginationProps, type CollectionSort, CollectionToolbar, type CollectionToolbarProps, DataList, type DataListProps, DataTable, type DataTableProps, type DataTableTotalRow, type FilterKind, type FilterOption, type ListSlot, type UseCollectionOptions, balanceOf, collectionTableOptions, compareDecimal, countFacets, defineColumns, formatDate, formatMoney, headerLabel, hiddenSelectedCount, nextSort, pageBounds, pageFlat, searchMatches, selectableIds, sortRows, sumMoney, toMinor, totalText, treeVisibleIds, useCollection };
|
|
@@ -771,6 +771,25 @@ function widthStyle(width) {
|
|
|
771
771
|
if (!width || width === "auto" || width === "min") return void 0;
|
|
772
772
|
return { width: `var(--sl-${width.replace(/\./g, "-")})` };
|
|
773
773
|
}
|
|
774
|
+
function CollectionCards({ collection, label, renderCard, empty, loading, className }) {
|
|
775
|
+
const rows = collection.pageRows;
|
|
776
|
+
if (loading && collection.totalCount === 0) {
|
|
777
|
+
return /* @__PURE__ */ jsx(LoadingNote, { text: collection.messages.loading });
|
|
778
|
+
}
|
|
779
|
+
if (!rows.length) {
|
|
780
|
+
return collection.totalCount > 0 || collection.isFiltered ? /* @__PURE__ */ jsx(
|
|
781
|
+
EmptyState,
|
|
782
|
+
{
|
|
783
|
+
size: "compact",
|
|
784
|
+
kind: "no-results",
|
|
785
|
+
title: collection.messages.noResults,
|
|
786
|
+
description: collection.messages.noResultsDescription,
|
|
787
|
+
actions: /* @__PURE__ */ jsx(Button, { emphasis: "standard", onClick: collection.clearFilters, children: collection.messages.clearFilters })
|
|
788
|
+
}
|
|
789
|
+
) : /* @__PURE__ */ jsx(Fragment, { children: empty ?? /* @__PURE__ */ jsx(EmptyState, { size: "compact", kind: "start", title: collection.messages.nothingHere }) });
|
|
790
|
+
}
|
|
791
|
+
return /* @__PURE__ */ jsx("ul", { className: cn("CollectionCards", className), "aria-label": label, children: rows.map((row) => /* @__PURE__ */ jsx("li", { children: renderCard(row) }, collection.getRowId(row))) });
|
|
792
|
+
}
|
|
774
793
|
function CollectionPagination({
|
|
775
794
|
page,
|
|
776
795
|
pageCount,
|
|
@@ -1543,6 +1562,6 @@ function leafRows(row) {
|
|
|
1543
1562
|
return children.flatMap(leafRows);
|
|
1544
1563
|
}
|
|
1545
1564
|
|
|
1546
|
-
export { CollectionPagination, CollectionToolbar, DataList, DataTable, collectionTableOptions, defineColumns, headerLabel, totalText, useCollection };
|
|
1565
|
+
export { CollectionCards, CollectionPagination, CollectionToolbar, DataList, DataTable, collectionTableOptions, defineColumns, headerLabel, totalText, useCollection };
|
|
1547
1566
|
//# sourceMappingURL=index.js.map
|
|
1548
1567
|
//# sourceMappingURL=index.js.map
|