@itrocks/list 0.27.0 → 0.27.1

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/cjs/list.html CHANGED
@@ -28,7 +28,7 @@
28
28
  <div class="list-filter">
29
29
  <!--filterBar-->{{template}}<!--end-->
30
30
  </div>
31
- <span class="summary">{count} elements</span>
31
+ <div class="summary">{count} elements</div>
32
32
  <button class="add-column" hidden type="button" aria-label="Add column">+</button>
33
33
  </div>
34
34
  </header>
package/list.css CHANGED
@@ -288,10 +288,11 @@ article[data-action=list] > form > .search-menu > button:focus-visible, article[
288
288
  }
289
289
 
290
290
  main > article[data-action=list] > header > .list-toolbar {
291
+ --list-toolbar-gap: 5px;
291
292
  align-items: center;
292
293
  border-bottom: 1px solid #ccc;
293
294
  display: grid;
294
- gap: 5px;
295
+ gap: var(--list-toolbar-gap);
295
296
  grid-template-areas: "actions filter count add";
296
297
  grid-template-columns: auto minmax(0, 1fr) auto max-content;
297
298
  }
@@ -300,6 +301,7 @@ main > article[data-action=list] > header > .list-toolbar:has(> .add-column[hidd
300
301
  grid-template-columns: auto minmax(0, 1fr) auto;
301
302
  }
302
303
  main > article[data-action=list] > header > .list-toolbar[data-filter-row] {
304
+ gap: 0;
303
305
  grid-template-areas: "actions count count" "filter filter add";
304
306
  grid-template-columns: minmax(0, 1fr) auto max-content;
305
307
  }
@@ -307,10 +309,22 @@ main > article[data-action=list] > header > .list-toolbar[data-filter-row]:has(>
307
309
  grid-template-areas: "actions count" "filter filter";
308
310
  grid-template-columns: minmax(0, 1fr) auto;
309
311
  }
312
+ main > article[data-action=list] > header > .list-toolbar[data-filter-row] > :is(.general.actions, .summary) {
313
+ align-self: stretch;
314
+ border-bottom: 1px solid #ccc;
315
+ }
310
316
  main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .general.actions {
311
317
  flex-wrap: wrap;
312
318
  overflow-x: auto;
313
319
  }
320
+ main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .list-filter {
321
+ align-self: stretch;
322
+ }
323
+ main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .summary {
324
+ align-content: center;
325
+ justify-self: stretch;
326
+ text-align: end;
327
+ }
314
328
  main > article[data-action=list] > header > .list-toolbar > .add-column {
315
329
  align-self: stretch;
316
330
  background: white;
@@ -342,6 +356,7 @@ main > article[data-action=list] > header > .list-toolbar > .general.actions > l
342
356
  white-space: nowrap;
343
357
  }
344
358
  main > article[data-action=list] > header > .list-toolbar > .summary {
359
+ display: inline-block;
345
360
  grid-area: count;
346
361
  justify-self: end;
347
362
  padding: 5px 10px;
package/package.json CHANGED
@@ -102,5 +102,5 @@
102
102
  "build:front": "tsc -p src/front/tsconfig.json",
103
103
  "test": "npm run build:cjs && node --test \"test/**/*.test.mjs\""
104
104
  },
105
- "version": "0.27.0"
105
+ "version": "0.27.1"
106
106
  }
package/toolbar.js CHANGED
@@ -7,6 +7,11 @@ function actionsWidth(actions) {
7
7
  + gapWidth(style, items.length)
8
8
  + items.reduce((width, item) => width + item.getBoundingClientRect().width, 0);
9
9
  }
10
+ function contentWidth(element, style) {
11
+ const range = document.createRange();
12
+ range.selectNodeContents(element);
13
+ return range.getBoundingClientRect().width + inlineEdges(style);
14
+ }
10
15
  function filterWidth(filter) {
11
16
  const icon = filter.querySelector('.list-filter-icon');
12
17
  let width = inlineEdges(getComputedStyle(filter));
@@ -20,11 +25,8 @@ function filterWidth(filter) {
20
25
  width += inlineEdges(rowStyle);
21
26
  }
22
27
  if (text) {
23
- const range = document.createRange();
24
- range.selectNodeContents(text);
25
28
  const textStyle = getComputedStyle(text);
26
- const contentWidth = range.getBoundingClientRect().width + inlineEdges(textStyle);
27
- width += gapWidth(rowStyle, 2) + Math.max(contentWidth, pixels(textStyle.minWidth));
29
+ width += gapWidth(rowStyle, 2) + Math.max(contentWidth(text, textStyle), pixels(textStyle.minWidth));
28
30
  }
29
31
  return width;
30
32
  }
@@ -51,8 +53,9 @@ function watchToolbar(toolbar) {
51
53
  frame = undefined;
52
54
  const style = getComputedStyle(toolbar);
53
55
  const available = toolbar.getBoundingClientRect().width - inlineEdges(style);
54
- const required = actionsWidth(actions) + filterWidth(filter) + count.getBoundingClientRect().width
55
- + add.getBoundingClientRect().width + gapWidth(style, add.hidden ? 3 : 4);
56
+ const gaps = (add.hidden ? 2 : 3) * pixels(style.getPropertyValue('--list-toolbar-gap'));
57
+ const required = actionsWidth(actions) + filterWidth(filter) + contentWidth(count, getComputedStyle(count))
58
+ + add.getBoundingClientRect().width + gaps;
56
59
  toolbar.toggleAttribute('data-filter-row', required > available);
57
60
  }
58
61
  function schedule() {