@streamscloud/kit 0.49.0 → 0.50.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.
@@ -3,7 +3,7 @@ import { EmptyState } from '../empty-state';
3
3
  import { Icon } from '../icon';
4
4
  import { TableCell, TableHideableCell } from './table-cells';
5
5
  import { TableLocalization } from './table-localization';
6
- import { createTableView, cssWidth } from './table-view.svelte';
6
+ import { columnWidthStyle, createTableView } from './table-view.svelte';
7
7
  import IconReorderDotsHorizontal from '@fluentui/svg-icons/icons/re_order_dots_horizontal_20_regular.svg?raw';
8
8
  import { flip } from 'svelte/animate';
9
9
  import { dndzone } from 'svelte-dnd-action';
@@ -73,7 +73,7 @@ const transformDraggedElement = (draggedRow) => {
73
73
  <th class="table__th table__drag-handle">&nbsp;</th>
74
74
  {#each model.columns as column (column)}
75
75
  <TableHideableCell column={column}>
76
- <th class="table__th" class:table__th--centered={column.centered} style={cssWidth(column)} title={column.title}>
76
+ <th class="table__th" class:table__th--centered={column.centered} style={columnWidthStyle(column)} title={column.title}>
77
77
  <DynamicComponent model={column.headerView} />
78
78
  </th>
79
79
  </TableHideableCell>
@@ -132,7 +132,7 @@ const transformDraggedElement = (draggedRow) => {
132
132
  class:table__td--centered={column.centered}
133
133
  class:table__td--clickable={!!column.onClick}
134
134
  class:table__td--flush={flushBottom}
135
- style={cssWidth(column)}
135
+ style={columnWidthStyle(column)}
136
136
  onclick={() => column.onClick && column.onClick(item)}>
137
137
  <TableCell model={model} item={item} column={column} itemIndex={itemIndex} on={{ itemsReordered: on?.itemsReordered }} />
138
138
  </td>
@@ -2,7 +2,7 @@
2
2
  import { EmptyState } from '../empty-state';
3
3
  import { TableCell, TableHideableCell } from './table-cells';
4
4
  import { TableLocalization } from './table-localization';
5
- import { createTableView, cssWidth } from './table-view.svelte';
5
+ import { columnWidthStyle, createTableView } from './table-view.svelte';
6
6
  let { model, showPlaceholder = false, showAlternativeView = false, grouping, on, alternativeView, placeholderRow, customNoItemsPlaceholder } = $props();
7
7
  const localization = new TableLocalization();
8
8
  const view = createTableView(() => model, () => on);
@@ -58,7 +58,7 @@ const visibleColspan = $derived(model.columns.filter((column) => !column.hidden)
58
58
  <tr>
59
59
  {#each model.columns as column (column)}
60
60
  <TableHideableCell column={column}>
61
- <th class="table__th" class:table__th--centered={column.centered} style={cssWidth(column)} title={column.title}>
61
+ <th class="table__th" class:table__th--centered={column.centered} style={columnWidthStyle(column)} title={column.title}>
62
62
  <DynamicComponent model={column.headerView} />
63
63
  </th>
64
64
  </TableHideableCell>
@@ -112,7 +112,7 @@ const visibleColspan = $derived(model.columns.filter((column) => !column.hidden)
112
112
  class:table__td--centered={column.centered}
113
113
  class:table__td--clickable={!!column.onClick}
114
114
  class:table__td--flush={flushBottom}
115
- style={cssWidth(column)}
115
+ style={columnWidthStyle(column)}
116
116
  onclick={() => column.onClick && column.onClick(item)}>
117
117
  <TableCell model={model} item={item} column={column} itemIndex={itemIndex} on={{ itemsReordered: on?.itemsReordered }} />
118
118
  </td>
@@ -24,7 +24,8 @@ export declare class ResolvedColumn<T extends WithId> {
24
24
  get id(): keyof T;
25
25
  get title(): string;
26
26
  get centered(): boolean;
27
- get fixedCssWidth(): string;
27
+ get cssWidth(): string;
28
+ get minCssWidth(): string;
28
29
  get hideable(): boolean;
29
30
  get sortLabelsOverride(): {
30
31
  asc: string;
@@ -31,8 +31,11 @@ export class ResolvedColumn {
31
31
  get centered() {
32
32
  return this.def.centered ?? false;
33
33
  }
34
- get fixedCssWidth() {
35
- return this.def.fixedCssWidth ?? '';
34
+ get cssWidth() {
35
+ return this.def.cssWidth ?? '';
36
+ }
37
+ get minCssWidth() {
38
+ return this.def.minCssWidth ?? '';
36
39
  }
37
40
  get hideable() {
38
41
  if ('hideable' in this.def) {
@@ -113,7 +113,7 @@ export class TableModel {
113
113
  }
114
114
  // Append actions column if needed
115
115
  if (this._itemActions.length) {
116
- const actionsColumn = new ResolvedColumn({ type: 'actions', centered: true, fixedCssWidth: Css.em(75) });
116
+ const actionsColumn = new ResolvedColumn({ type: 'actions', centered: true, cssWidth: Css.em(75) });
117
117
  actionsColumn.headerView = new DynamicComponentModel({
118
118
  component: TableHeader,
119
119
  props: { column: { title: 'Actions' } }
@@ -151,7 +151,7 @@ export class TableModel {
151
151
  const resolved = new ResolvedColumn({
152
152
  ...column,
153
153
  centered: true,
154
- fixedCssWidth: column.fixedCssWidth || Css.em(50)
154
+ cssWidth: column.cssWidth || Css.em(50)
155
155
  });
156
156
  resolved.headerView = new DynamicComponentModel({
157
157
  component: TableCheckboxHeader,
@@ -163,7 +163,7 @@ export class TableModel {
163
163
  const resolved = new ResolvedColumn({
164
164
  ...column,
165
165
  centered: true,
166
- fixedCssWidth: column.fixedCssWidth || Css.em(75)
166
+ cssWidth: column.cssWidth || Css.em(75)
167
167
  });
168
168
  resolved.headerView = resolveSortableHeader(resolved);
169
169
  return resolved;
@@ -6,7 +6,8 @@ type SelectionCallbacks<T> = {
6
6
  itemsSelected?: (e: T[]) => void;
7
7
  itemsDeselected?: (e: T[]) => void;
8
8
  };
9
- export declare const cssWidth: <T extends WithId>(column: ResolvedColumn<T>) => string;
9
+ /** Inline width declarations for a column's `th` / `td`: the preferred width plus, when set, the floor the browser must honour. */
10
+ export declare const columnWidthStyle: <T extends WithId>(column: ResolvedColumn<T>) => string;
10
11
  /** Shared presentation wiring for the table views: selection-event subscriptions + the debounced no-items placeholder. */
11
12
  export declare const createTableView: <T extends WithId>(model: () => TableModel<T>, on: () => SelectionCallbacks<T> | undefined) => {
12
13
  readonly showNoItemsPlaceholder: boolean;
@@ -1,5 +1,9 @@
1
1
  import { untrack } from 'svelte';
2
- export const cssWidth = (column) => (column.fixedCssWidth ? `width: ${column.fixedCssWidth};` : 'width: auto;');
2
+ /** Inline width declarations for a column's `th` / `td`: the preferred width plus, when set, the floor the browser must honour. */
3
+ export const columnWidthStyle = (column) => {
4
+ const width = column.cssWidth ? `width: ${column.cssWidth};` : 'width: auto;';
5
+ return column.minCssWidth ? `${width} min-width: ${column.minCssWidth};` : width;
6
+ };
3
7
  /** Shared presentation wiring for the table views: selection-event subscriptions + the debounced no-items placeholder. */
4
8
  export const createTableView = (model, on) => {
5
9
  let showNoItemsPlaceholder = $state(false);
@@ -11,7 +11,13 @@ export type IOneOfTableColumn<T> = ITableBadgeColumn<T> | ITableButtonColumn<T>
11
11
  export type TableColumnType = 'actions' | 'badge' | 'button' | 'by' | 'checkbox' | 'icon' | 'image' | 'move-row' | 'snippet' | 'text';
12
12
  interface ITableColumnBase {
13
13
  type: TableColumnType;
14
- fixedCssWidth?: string;
14
+ /**
15
+ * Preferred column width. Under the table's `table-layout: auto` this is a suggestion: content can push a column wider, and a column with no width of its
16
+ * own is left with whatever the others do not claim. Use `minCssWidth` for a width the browser must honour.
17
+ */
18
+ cssWidth?: string;
19
+ /** Floor the column will not shrink below, taken out of columns whose `cssWidth` is merely a suggestion. Use it on the column that must keep space. */
20
+ minCssWidth?: string;
15
21
  centered?: boolean;
16
22
  }
17
23
  export interface ITableColumn<T> extends ITableColumnBase {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",