@svelte-lean/table 0.2.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @svelte-lean/table
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `pageSizeSelect="custom"` draws the page-size control with the Select primitive of `@svelte-lean/primitives`: a trigger button and a listbox popup drawn from the design tokens in every engine, around the same native `<select>`, which keeps the value and works without scripts. The application imports `@svelte-lean/primitives/select/register` and `@svelte-lean/styles/select.css`. `native` (a plain `<select>`) stays the default.
8
+
9
+ The ids that tie the control's label, trigger and listbox come from `$props.id()`, so the peer dependency is now `svelte ^5.20.0`.
10
+
3
11
  ## 0.2.0
4
12
 
5
13
  ### Minor Changes
package/dist/style.css CHANGED
@@ -700,6 +700,13 @@
700
700
  gap: 0.5rem;
701
701
  white-space: nowrap;
702
702
  }
703
+ /* The Select primitive as the page-size control (`pageSizeSelect="custom"`): as tall as the
704
+ pager's buttons, as wide as its longest option. */
705
+ :where(.slean-table-page-select) {
706
+ --slean-control-height-sm: var(--slean-table-control-height);
707
+ min-inline-size: 4.75rem;
708
+ font-size: inherit;
709
+ }
703
710
  :where(.slean-table-pager, .slean-table-pages) {
704
711
  display: flex;
705
712
  align-items: center;
@@ -119,6 +119,7 @@
119
119
  progressive = false,
120
120
  pagination = true,
121
121
  pageSizeOptions = [10, 20, 50, 100],
122
+ pageSizeSelect = 'native',
122
123
  placeholder = '',
123
124
  rowHoverable = true,
124
125
  dir,
@@ -136,6 +137,15 @@
136
137
  onCellRangeChange,
137
138
  class: className = ''
138
139
  }: TableProps<T> = $props();
140
+ /** Ids of this instance's own relationships (the page-size label and listbox); SSR-stable. */
141
+ const uid = $props.id();
142
+ /**
143
+ * The Select primitive's root marker, spread rather than written: @svelte-lean/vite registers
144
+ * the behavior of every marker it reads in markup, and a marker here would put the select
145
+ * behavior in every application that renders a table. The application that sets
146
+ * `pageSizeSelect="custom"` imports `@svelte-lean/primitives/select/register` itself.
147
+ */
148
+ const SELECT_ROOT = { 'data-slean': 'select' } as const;
139
149
  /**
140
150
  * One engine. Props are handed over as getters so the engine follows every prop change.
141
151
  * `getSubRows` and `searchText` must stay `undefined` when absent (grouping rejects tree input;
@@ -1717,16 +1727,42 @@
1717
1727
  {#if pagination}<div class="slean-table-pagination">
1718
1728
  <span class="slean-table-page-status" aria-live="polite"
1719
1729
  >{m.page(model.pageIndex + 1, model.pageCount, rowsKnown ? model.total : undefined)}</span
1720
- ><label class="slean-table-page-size"
1721
- >{m.pageSize}<select
1722
- class="slean-table-input"
1723
- value={s.pageSize}
1724
- onchange={(e) => table.setPageSize(Number(e.currentTarget.value))}
1725
- >{#each pageSizes as size (size)}<option value={size}
1726
- >{size === 0 ? m.allRows : size}</option
1727
- >{/each}</select
1728
- ></label
1729
- ><span class="slean-table-pager"
1730
+ >{#if pageSizeSelect === 'custom'}<span class="slean-table-page-size"
1731
+ ><span id="{uid}-page-size">{m.pageSize}</span>
1732
+ <div class="slean-table-page-select" {...SELECT_ROOT} data-size="sm">
1733
+ <select
1734
+ data-slean-part="native"
1735
+ aria-labelledby="{uid}-page-size"
1736
+ value={s.pageSize}
1737
+ onchange={(e) => table.setPageSize(Number(e.currentTarget.value))}
1738
+ >{#each pageSizes as size (size)}<option value={size}
1739
+ >{size === 0 ? m.allRows : size}</option
1740
+ >{/each}</select
1741
+ ><button
1742
+ type="button"
1743
+ role="combobox"
1744
+ aria-haspopup="listbox"
1745
+ aria-expanded="false"
1746
+ aria-controls="{uid}-page-sizes"
1747
+ aria-labelledby="{uid}-page-size"
1748
+ data-slean-part="trigger"
1749
+ ><span data-slean-part="value">{s.pageSize === 0 ? m.allRows : s.pageSize}</span
1750
+ ></button
1751
+ ><span data-slean-part="toggle" aria-hidden="true"></span>
1752
+ <div popover="manual" data-slean-part="popup">
1753
+ <ul id="{uid}-page-sizes" role="listbox" aria-labelledby="{uid}-page-size"></ul>
1754
+ </div>
1755
+ </div></span
1756
+ >{:else}<label class="slean-table-page-size"
1757
+ >{m.pageSize}<select
1758
+ class="slean-table-input"
1759
+ value={s.pageSize}
1760
+ onchange={(e) => table.setPageSize(Number(e.currentTarget.value))}
1761
+ >{#each pageSizes as size (size)}<option value={size}
1762
+ >{size === 0 ? m.allRows : size}</option
1763
+ >{/each}</select
1764
+ ></label
1765
+ >{/if}<span class="slean-table-pager"
1730
1766
  ><button
1731
1767
  type="button"
1732
1768
  class="slean-table-button"
package/dist/types.d.ts CHANGED
@@ -299,6 +299,14 @@ export interface TableProps<T> {
299
299
  pagination?: boolean;
300
300
  /** Page sizes offered by the pager; the current size is always included. */
301
301
  pageSizeOptions?: number[];
302
+ /**
303
+ * The page-size control. `native` (default): a native `<select>`. `custom`: the Select primitive
304
+ * of `@svelte-lean/primitives` (a trigger button and a listbox popup drawn the same in every
305
+ * engine), around the same native `<select>`, which keeps the value and works without scripts.
306
+ * `custom` needs the select behavior (`import '@svelte-lean/primitives/select/register'`) and
307
+ * its styles (`@svelte-lean/styles/select.css`) in the application.
308
+ */
309
+ pageSizeSelect?: 'native' | 'custom';
302
310
  /** Text of an empty value (`null`, `undefined`, `''`, or `format` returning `null`/`''`). */
303
311
  placeholder?: string;
304
312
  rowHoverable?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svelte-lean/table",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A Svelte-native table and data-grid engine that ships only the features you use.",
5
5
  "license": "MIT",
6
6
  "author": "Ömer Say",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "peerDependencies": {
61
- "svelte": "^5.0.0"
61
+ "svelte": "^5.20.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "yarn run -T svelte-kit sync && yarn run -T svelte-package && node scripts/types.mjs && yarn run -T publint && yarn run -T attw --pack . --profile esm-only --exclude-entrypoints ./style.css --format table-flipped --no-emoji",