@scattered-light/loomiere-base-ui 0.12.0 → 0.14.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.
Files changed (72) hide show
  1. package/README.md +3 -0
  2. package/dist/custom/collection/index.d.ts +18 -3
  3. package/dist/custom/collection/index.js +15 -4
  4. package/dist/custom/collection/index.js.map +1 -1
  5. package/dist/design-system/components/CollectionToolbar/README.md +3 -1
  6. package/dist/design-system/components/DataTable/preview.html +129 -129
  7. package/dist/design-system/components/Table/README.md +1 -1
  8. package/dist/design-system/components/bundle.js +6 -6
  9. package/dist/design-system/components/styles.css +141 -62
  10. package/dist/styles/components/Accordion.css +1 -1
  11. package/dist/styles/components/AlertDialog.css +1 -1
  12. package/dist/styles/components/Autocomplete.css +1 -1
  13. package/dist/styles/components/Avatar.css +1 -1
  14. package/dist/styles/components/Button.css +1 -1
  15. package/dist/styles/components/Checkbox.css +1 -1
  16. package/dist/styles/components/CheckboxGroup.css +1 -1
  17. package/dist/styles/components/Collapsible.css +1 -1
  18. package/dist/styles/components/Combobox.css +1 -1
  19. package/dist/styles/components/ContextMenu.css +1 -1
  20. package/dist/styles/components/Dialog.css +1 -1
  21. package/dist/styles/components/Drawer.css +1 -1
  22. package/dist/styles/components/Field.css +1 -1
  23. package/dist/styles/components/Fieldset.css +1 -1
  24. package/dist/styles/components/Form.css +1 -1
  25. package/dist/styles/components/Input.css +1 -1
  26. package/dist/styles/components/Menu.css +1 -1
  27. package/dist/styles/components/Menubar.css +1 -1
  28. package/dist/styles/components/Meter.css +1 -1
  29. package/dist/styles/components/NavigationMenu.css +1 -1
  30. package/dist/styles/components/NumberField.css +1 -1
  31. package/dist/styles/components/OTPField.css +1 -1
  32. package/dist/styles/components/Popover.css +1 -1
  33. package/dist/styles/components/PreviewCard.css +1 -1
  34. package/dist/styles/components/Progress.css +1 -1
  35. package/dist/styles/components/Radio.css +1 -1
  36. package/dist/styles/components/ScrollArea.css +1 -1
  37. package/dist/styles/components/Select.css +1 -1
  38. package/dist/styles/components/Separator.css +1 -1
  39. package/dist/styles/components/Slider.css +1 -1
  40. package/dist/styles/components/Switch.css +1 -1
  41. package/dist/styles/components/Tabs.css +1 -1
  42. package/dist/styles/components/Toast.css +1 -1
  43. package/dist/styles/components/Toggle.css +1 -1
  44. package/dist/styles/components/ToggleGroup.css +1 -1
  45. package/dist/styles/components/Toolbar.css +1 -1
  46. package/dist/styles/components/Tooltip.css +1 -1
  47. package/dist/styles/custom/AppBar.css +1 -1
  48. package/dist/styles/custom/Badge.css +1 -1
  49. package/dist/styles/custom/Collection.css +1 -1
  50. package/dist/styles/custom/CollectionPagination.css +1 -1
  51. package/dist/styles/custom/CollectionToolbar.css +26 -1
  52. package/dist/styles/custom/DataList.css +1 -1
  53. package/dist/styles/custom/DataTable.css +37 -2
  54. package/dist/styles/custom/DatePicker.css +1 -1
  55. package/dist/styles/custom/DescriptionList.css +1 -1
  56. package/dist/styles/custom/EditableList.css +1 -1
  57. package/dist/styles/custom/EmptyState.css +1 -1
  58. package/dist/styles/custom/ListDetail.css +1 -1
  59. package/dist/styles/custom/MoneyField.css +1 -1
  60. package/dist/styles/custom/PickerButton.css +1 -1
  61. package/dist/styles/custom/Sheet.css +3 -1
  62. package/dist/styles/custom/SideNav.css +1 -1
  63. package/dist/styles/custom/Splitter.css +1 -1
  64. package/dist/styles/custom/StatFigure.css +1 -1
  65. package/dist/styles/custom/Table.css +19 -2
  66. package/dist/styles/index.css +1 -1
  67. package/dist/styles/reset/accessibility.css +1 -1
  68. package/dist/styles/reset/reset-accessibility.css +1 -1
  69. package/dist/styles/reset/reset-tailwind.css +1 -1
  70. package/dist/styles/reset/reset.css +1 -1
  71. package/dist/styles/tailwind.css +1 -1
  72. package/package.json +2 -2
package/README.md CHANGED
@@ -171,7 +171,10 @@ A tree in a DataTable (`getSubRows`) has options for a register of parents and c
171
171
  - `useCollection({ pageBy: 'top-level', pageSize: 5 })` pages by parents, so a page holds whole parents with their children. The pager counts parents: pass `collection.pageTotal` as `total`. `collection.pageRows` is the leaf rows of the page, children of collapsed parents included.
172
172
  - `totalRows={[{ scope: 'page', label }, { scope: 'all', label }]}` writes several footer rows. A `page` row totals the current page and is ruled as a subtotal; an `all` row totals every filtered row and is ruled as the grand total. `label` is text or a function of the collection, such as `(c) => \`Page ${c.page} of ${c.pageCount} subtotal\``.
173
173
  - A `rowHeader` column's `cell` now draws the row's name: put a second line or a count beside it. The row's link or button keeps the plain name as its accessible name.
174
+ - `treeLines` also gives parent, child and total rows their own heights, from `collection.tree-row-height-parent`, `tree-row-height-child`, `total-row-height-subtotal` and `total-row-height-grand` (all the dense row until a brand sets them), and starts the elbow `collection.tree-line-offset` in. With `disclosure="small"` the chevron takes `collection.disclosure-color`. A row with `onRowActivate` or `getRowHref` shows a pointer. `table.row-hover-color` is the text color on the hovered row.
175
+ - `CollectionToolbar` takes `searchWidth="fixed"` (the search keeps `collection.search-fixed-width`), `meta` and `metaEnd` (quiet text beside the search and at the far end of the row) and `framed` (padding and a rule under it, inside a Sheet).
174
176
  - `treeLines` draws an elbow from each child's name back up to its parent. `disclosure="small"` shrinks the expand button so a parent is as tall as its children. `getRowKind={(row) => 'link'}` marks a row (`data-kind="link"`) whose name reads as a link, for a row such as "3 more Entities".
177
+ - `CollectionToolbar` takes `searchPlaceholder`. `DataTable` takes `headerStyle="caps"` (column names and total-row labels in caps-condense) and `figures` (end-aligned cells in the figures family). With `treeLines`, parent rows take `collection.tree-parent-row-background` and `collection.tree-parent-row-hover`.
175
178
 
176
179
 
177
180
  ### App bar: AppBar, PickerButton and a segmented ToggleGroup
@@ -455,6 +455,10 @@ interface DataTableProps<T> extends CollectionViewProps<T> {
455
455
  * total, so totalStyle is ignored. The label defaults to the messages for page subtotal and total.
456
456
  */
457
457
  totalRows?: DataTableTotalRow<T>[];
458
+ /** 'caps' sets the column names, and the labels in total rows, in caps-condense, as on a working paper. */
459
+ headerStyle?: 'default' | 'caps';
460
+ /** Sets right-aligned cells (numbers) in the figures text family: mono, tabular. Total rows included. */
461
+ figures?: boolean;
458
462
  /** Draws an elbow connector from each child row's name back up to its parent. Use it with getSubRows. */
459
463
  treeLines?: boolean;
460
464
  /** 'small' shrinks the expand/collapse button so a parent row stays the height of its siblings. */
@@ -471,7 +475,7 @@ interface DataTableTotalRow<T = unknown> {
471
475
  * A data table, the APG pattern: one tab stop for the rows, headers announce sort, and it is
472
476
  * not a grid. A grid would say this is a spreadsheet, and it is not. AG Grid is that tool.
473
477
  */
474
- declare function DataTable<T>({ collection, label, caption, onRowActivate, getRowHref, activeRowId, rowActions, empty, loading, stickyHeader, stickyRowHeader, narrow, size, totalStyle, totalRows, treeLines, disclosure, getRowKind, rowNavigation, className, }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
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;
475
479
 
476
480
  interface CollectionPaginationProps {
477
481
  /** 1-based. */
@@ -510,13 +514,23 @@ interface CollectionToolbarProps<T> {
510
514
  }>;
511
515
  actions?: React.ReactNode;
512
516
  bulkActions?: React.ReactNode;
517
+ /** Placeholder text in the search box, such as "Find a client". The label still names it for screen readers. */
518
+ searchPlaceholder?: string;
519
+ /** 'fill' (the default) lets the search grow. 'fixed' gives it collection.search-fixed-width, so the meta beside it has room. */
520
+ searchWidth?: 'fill' | 'fixed';
521
+ /** Quiet text beside the search, such as "12 clients". */
522
+ meta?: React.ReactNode;
523
+ /** Quiet text at the far end of the row, such as "Sorted by most open". */
524
+ metaEnd?: React.ReactNode;
525
+ /** Pads the toolbar and rules it from the table below, for a toolbar inside a Sheet above an edge-to-edge table. */
526
+ framed?: boolean;
513
527
  className?: string;
514
528
  }
515
529
  /**
516
530
  * Tabs and search stay put while rows are selected. The trailing controls swap for the
517
531
  * selection bar, so the bar takes their place and the row does not grow.
518
532
  */
519
- declare function CollectionToolbarImpl<T>({ collection, searchLabel, searchLabelVisible, showSort, groupOptions, actions, bulkActions, className }: CollectionToolbarProps<T>): react_jsx_runtime.JSX.Element;
533
+ declare function CollectionToolbarImpl<T>({ collection, searchLabel, searchLabelVisible, searchPlaceholder, showSort, groupOptions, actions, bulkActions, searchWidth, meta, metaEnd, framed, className }: CollectionToolbarProps<T>): react_jsx_runtime.JSX.Element;
520
534
  declare function ToolbarTabs<T>({ collection, column }: {
521
535
  collection: CollectionApi<T>;
522
536
  column: CollectionColumn<T>;
@@ -525,8 +539,9 @@ declare function ToolbarTabs<T>({ collection, column }: {
525
539
  * The icon and the clear button sit inside the field. The clear button is the only clear
526
540
  * control and shows only when there is text. Escape clears too.
527
541
  */
528
- declare function SearchField({ label, visible, value, onChange, clearLabel }: {
542
+ declare function SearchField({ label, visible, placeholder, value, onChange, clearLabel }: {
529
543
  label: string;
544
+ placeholder?: string;
530
545
  visible?: boolean;
531
546
  value: string;
532
547
  onChange: (value: string) => void;
@@ -446,6 +446,8 @@ function DataTable({
446
446
  totalStyle = "band",
447
447
  totalRows,
448
448
  treeLines,
449
+ headerStyle = "default",
450
+ figures,
449
451
  disclosure = "default",
450
452
  getRowKind,
451
453
  rowNavigation,
@@ -495,6 +497,8 @@ function DataTable({
495
497
  totalStyle,
496
498
  totalRows,
497
499
  treeLines,
500
+ headerStyle,
501
+ figures,
498
502
  disclosure,
499
503
  getRowKind,
500
504
  className,
@@ -506,7 +510,7 @@ function DataTable({
506
510
  );
507
511
  return /* @__PURE__ */ jsx("div", { ref: narrowWidth.ref, className: cn("CollectionView", asList ? className : void 0), "data-narrow": narrowWidth.under ? "" : void 0, children: view });
508
512
  }
509
- function TableView({ collection, columns, label, caption, colSpan, leaves, navigate, allSelected, someSelected, loading, empty, stickyHeader, stickyRowHeader, size, totalStyle, totalRows, treeLines, disclosure, getRowKind, className, onRowActivate, getRowHref, activeRowId, rowActions }) {
513
+ function TableView({ collection, columns, label, caption, colSpan, leaves, navigate, allSelected, someSelected, loading, empty, stickyHeader, stickyRowHeader, size, totalStyle, totalRows, treeLines, headerStyle, figures, disclosure, getRowKind, className, onRowActivate, getRowHref, activeRowId, rowActions }) {
510
514
  const roving = useRovingRows(leaves.length, navigate);
511
515
  const scrollerRef = React4.useRef(null);
512
516
  const [overflows, setOverflows] = React4.useState(false);
@@ -560,6 +564,8 @@ function TableView({ collection, columns, label, caption, colSpan, leaves, navig
560
564
  "data-sticky-header": stickyHeader ? "" : void 0,
561
565
  "data-sticky-row-header": stickyRowHeader ? "" : void 0,
562
566
  "data-tree-lines": treeLines ? "" : void 0,
567
+ "data-header-style": headerStyle === "caps" ? "caps" : void 0,
568
+ "data-figures": figures ? "" : void 0,
563
569
  "data-disclosure": disclosure === "small" ? "small" : void 0,
564
570
  children: [
565
571
  caption ? /* @__PURE__ */ jsx("caption", { children: caption }) : null,
@@ -729,6 +735,7 @@ function DataRow({ entry, index, collection, columns, roving, navigate, onRowAct
729
735
  "aria-current": active ? "true" : void 0,
730
736
  "data-depth": entry.row.depth || void 0,
731
737
  "data-kind": rowKind,
738
+ "data-activates": href || onRowActivate ? "" : void 0,
732
739
  onClick: (event) => {
733
740
  const target = event.target;
734
741
  if (interactiveTarget(target) || selectingText()) return;
@@ -815,7 +822,7 @@ function CollectionPagination({
815
822
  ] });
816
823
  }
817
824
  var COMBOBOX_AT = 12;
818
- function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, showSort, groupOptions, actions, bulkActions, className }) {
825
+ function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, searchPlaceholder, showSort, groupOptions, actions, bulkActions, searchWidth = "fill", meta, metaEnd, framed, className }) {
819
826
  const tabs = collection.columns.find((column) => column.filter?.kind === "tabs");
820
827
  const selects = collection.columns.filter((column) => column.filter && column.filter.kind !== "tabs");
821
828
  const searchable = collection.columns.some((column) => column.searchable);
@@ -841,7 +848,7 @@ function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, sh
841
848
  }, [collection.selection, collection.hiddenSelectedCount, collection.messages]);
842
849
  const selecting = collection.selection.length > 0;
843
850
  const narrow = useUnderWidth("--sl-collection-narrow-width");
844
- return /* @__PURE__ */ jsxs("div", { ref: narrow.ref, className: cn("CollectionToolbar", className), "data-selecting": selecting ? "" : void 0, "data-narrow": narrow.under ? "" : void 0, children: [
851
+ return /* @__PURE__ */ jsxs("div", { ref: narrow.ref, className: cn("CollectionToolbar", className), "data-selecting": selecting ? "" : void 0, "data-narrow": narrow.under ? "" : void 0, "data-search": searchWidth === "fixed" ? "fixed" : void 0, "data-framed": framed ? "" : void 0, children: [
845
852
  tabs ? /* @__PURE__ */ jsx(ToolbarTabs, { collection, column: tabs }) : null,
846
853
  /* @__PURE__ */ jsxs("div", { className: "CollectionToolbarMain", children: [
847
854
  searchable ? /* @__PURE__ */ jsx(
@@ -849,11 +856,14 @@ function CollectionToolbarImpl({ collection, searchLabel, searchLabelVisible, sh
849
856
  {
850
857
  label: searchLabel ?? "Search",
851
858
  visible: searchLabelVisible,
859
+ placeholder: searchPlaceholder,
852
860
  value: collection.search,
853
861
  onChange: collection.setSearch,
854
862
  clearLabel: collection.messages.clearSearch
855
863
  }
856
864
  ) : null,
865
+ meta ? /* @__PURE__ */ jsx("p", { className: "CollectionToolbarMeta", "aria-live": "polite", children: meta }) : null,
866
+ metaEnd ? /* @__PURE__ */ jsx("p", { className: "CollectionToolbarMeta CollectionToolbarMetaEnd", children: metaEnd }) : null,
857
867
  selecting ? /* @__PURE__ */ jsxs("div", { className: "CollectionSelectionBar", role: "region", "aria-label": "Selection", children: [
858
868
  /* @__PURE__ */ jsxs("p", { className: "CollectionCount", children: [
859
869
  collection.messages.selected(collection.selection.length),
@@ -898,7 +908,7 @@ function ToolbarTabs({ collection, column }) {
898
908
  ] }, tabValue || "all");
899
909
  }) }) });
900
910
  }
901
- function SearchField({ label, visible, value, onChange, clearLabel = "Clear search" }) {
911
+ function SearchField({ label, visible, placeholder, value, onChange, clearLabel = "Clear search" }) {
902
912
  const id = React4.useId();
903
913
  const input = React4.useRef(null);
904
914
  return /* @__PURE__ */ jsxs("div", { className: "CollectionSearch", children: [
@@ -911,6 +921,7 @@ function SearchField({ label, visible, value, onChange, clearLabel = "Clear sear
911
921
  ref: input,
912
922
  id,
913
923
  type: "search",
924
+ placeholder,
914
925
  value,
915
926
  onChange: (event) => onChange(event.target.value),
916
927
  onKeyDown: (event) => {