yummy-guide-generic-administrate 0.5.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82f8a49b6cf64da8e522b0290770f402b7f387ba989d5e38ff0d17232b8a7ff2
4
- data.tar.gz: '0648859c41c97f9bf5d6a5bef998fca7e8685a2a5b5d617bfbd1830d75d08fa9'
3
+ metadata.gz: d74616803937316aa5cb1017b29b59dd95d9853caf6b3f3dae65500265d18312
4
+ data.tar.gz: ff39212a171b9238896ccb7c8b5e6d4980ca655cfb110dde961434cbf558175c
5
5
  SHA512:
6
- metadata.gz: 8e7752a04124f92bd2abdbb7d6f5e16284c593ff33166cd9429a202146ea0de5ca35e812c80bf69bb96eb1b1179daec5584ba66fa0c55fd9bc8921c78a072aef
7
- data.tar.gz: 6d109d78f58cc76f4d125a6027aa28f4d048c0c3233b97b0b5c244edab96757f5c20c078461ca5975b6cf3cc3af5a32030bdd87563de9d38aa11167d31d57060
6
+ metadata.gz: 92b1684a3992f57bd1fe73ba84bc6f162761c9264843ff31cb769d9c4d87f6f5254493e20d0ea4a223efb1779f8207b1d34649606880525c00a48f530b7ec9ca
7
+ data.tar.gz: 1e3bbbc9b83448f8f33616b756262f91e48f59e179ba85f13c8d638bc8f032853fcd070c08194eb11e179bf2de72b1c8d05ee2ae0b43a7321bf3489958886c34
@@ -345,13 +345,14 @@
345
345
  });
346
346
  }
347
347
 
348
+ function mergeMeasuredCellWidths(widths, cells) {
349
+ cells.forEach(function(cell, index) {
350
+ widths[index] = Math.max(widths[index] || 0, measuredWidth(cell));
351
+ });
352
+ }
353
+
348
354
  function widthCandidateRows(sourceTable, headerCellCount) {
349
355
  var candidates = [];
350
- var headerRow = sourceTable.querySelector('thead tr');
351
-
352
- if (headerRow) {
353
- candidates.push(headerRow);
354
- }
355
356
 
356
357
  Array.from(sourceTable.querySelectorAll('tbody tr, tfoot tr')).forEach(function(row) {
357
358
  var cells = directCells(row);
@@ -363,13 +364,6 @@
363
364
  return candidates;
364
365
  }
365
366
 
366
- function hasMeasurableDataRow(sourceTable, headerCellCount) {
367
- return Array.from(sourceTable.querySelectorAll('tbody tr, tfoot tr')).some(function(row) {
368
- var cells = directCells(row);
369
- return cells.length === headerCellCount && !cells.some(function(cell) { return cell.colSpan > 1; });
370
- });
371
- }
372
-
373
367
  function removeGeneratedColGroup(table) {
374
368
  if (!table) return;
375
369
 
@@ -379,20 +373,87 @@
379
373
  }
380
374
  }
381
375
 
382
- function generatedColGroupWidths(table, expectedCount) {
383
- if (!table) return [];
384
-
385
- var colgroup = table.querySelector('colgroup[data-fixed-header-colgroup]');
386
- if (!colgroup) return [];
376
+ function clearSourceColumnMinWidths(sourceTable) {
377
+ if (!sourceTable) return;
387
378
 
388
- var widths = Array.from(colgroup.children).map(function(col) {
389
- var inlineWidth = parseFloat(col.style.width || '0');
390
- return Number.isNaN(inlineWidth) ? 0 : preciseNumber(inlineWidth);
379
+ Array.from(sourceTable.querySelectorAll('[data-fixed-header-column-min-width]')).forEach(function(cell) {
380
+ restoreManagedCellWidth(cell, 'width');
381
+ restoreManagedCellWidth(cell, 'min-width');
382
+ cell.style.removeProperty('--fixed-header-column-min-width');
383
+ cell.removeAttribute('data-fixed-header-column-min-width');
391
384
  });
385
+ }
386
+
387
+ function managedWidthAttributeName(kind, propertyName) {
388
+ return 'data-fixed-header-' + kind + '-' + propertyName;
389
+ }
392
390
 
393
- if (expectedCount && widths.length !== expectedCount) return [];
391
+ function storeOriginalCellWidth(cell, propertyName) {
392
+ var originalAttribute = managedWidthAttributeName('original', propertyName);
393
+ var originalPriorityAttribute = managedWidthAttributeName('original-priority', propertyName);
394
394
 
395
- return widths;
395
+ if (cell.hasAttribute(originalAttribute)) return;
396
+
397
+ cell.setAttribute(originalAttribute, cell.style.getPropertyValue(propertyName));
398
+ cell.setAttribute(originalPriorityAttribute, cell.style.getPropertyPriority(propertyName));
399
+ }
400
+
401
+ function applyManagedCellWidth(cell, propertyName, value) {
402
+ storeOriginalCellWidth(cell, propertyName);
403
+ cell.style.setProperty(propertyName, value, 'important');
404
+ cell.setAttribute(managedWidthAttributeName('applied', propertyName), value);
405
+ cell.setAttribute(managedWidthAttributeName('applied-priority', propertyName), 'important');
406
+ }
407
+
408
+ function restoreManagedCellWidth(cell, propertyName) {
409
+ var originalAttribute = managedWidthAttributeName('original', propertyName);
410
+ var originalPriorityAttribute = managedWidthAttributeName('original-priority', propertyName);
411
+ var appliedAttribute = managedWidthAttributeName('applied', propertyName);
412
+ var appliedPriorityAttribute = managedWidthAttributeName('applied-priority', propertyName);
413
+ var appliedValue = cell.getAttribute(appliedAttribute);
414
+ var appliedPriority = cell.getAttribute(appliedPriorityAttribute);
415
+
416
+ if (
417
+ appliedValue === null ||
418
+ (
419
+ cell.style.getPropertyValue(propertyName) === appliedValue &&
420
+ cell.style.getPropertyPriority(propertyName) === (appliedPriority || '')
421
+ )
422
+ ) {
423
+ var originalValue = cell.getAttribute(originalAttribute);
424
+ var originalPriority = cell.getAttribute(originalPriorityAttribute) || '';
425
+
426
+ if (originalValue) {
427
+ cell.style.setProperty(propertyName, originalValue, originalPriority);
428
+ } else {
429
+ cell.style.removeProperty(propertyName);
430
+ }
431
+ }
432
+
433
+ cell.removeAttribute(originalAttribute);
434
+ cell.removeAttribute(originalPriorityAttribute);
435
+ cell.removeAttribute(appliedAttribute);
436
+ cell.removeAttribute(appliedPriorityAttribute);
437
+ }
438
+
439
+ function applySourceColumnMinWidths(sourceTable, widths) {
440
+ if (!sourceTable || !widths.length) return;
441
+
442
+ Array.from(sourceTable.querySelectorAll('thead tr, tbody tr, tfoot tr')).forEach(function(row) {
443
+ var cells = directCells(row);
444
+ if (cells.length !== widths.length || cells.some(function(cell) { return cell.colSpan > 1; })) return;
445
+
446
+ cells.forEach(function(cell, index) {
447
+ var width = widths[index];
448
+ if (!width) return;
449
+
450
+ var widthValue = cssPixelValue(width);
451
+ cell.style.setProperty('--fixed-header-column-min-width', widthValue);
452
+ applyManagedCellWidth(cell, 'width', widthValue);
453
+ applyManagedCellWidth(cell, 'min-width', widthValue);
454
+ cell.setAttribute('data-fixed-header-column-min-width', 'true');
455
+ });
456
+ });
396
457
  }
397
458
 
398
459
  function clearFixedHeaderState(slot, scroll, sourceTable) {
@@ -403,6 +464,7 @@
403
464
  if (!sourceTable) return;
404
465
 
405
466
  removeGeneratedColGroup(sourceTable);
467
+ clearSourceColumnMinWidths(sourceTable);
406
468
  sourceTable.classList.remove('table-with-fixed-header');
407
469
 
408
470
  if (sourceTable.classList.contains('home-table')) {
@@ -425,25 +487,14 @@
425
487
  var widths = headerCells.map(function() { return 0; });
426
488
 
427
489
  widthCandidateRows(sourceTable, headerCells.length).forEach(function(row) {
428
- directCells(row).forEach(function(cell, index) {
429
- widths[index] = Math.max(widths[index], measuredWidth(cell));
430
- });
490
+ mergeMeasuredCellWidths(widths, directCells(row));
431
491
  });
432
492
 
433
- if (!widths.some(Boolean)) {
434
- var generatedWidths = generatedColGroupWidths(sourceTable, headerCells.length);
435
- if (generatedWidths.length) {
436
- widths = generatedWidths.slice();
437
- }
438
- }
439
-
440
- if (!widths.some(Boolean) && fixedTable && settings.allowFixedTableFallback !== false) {
493
+ if (fixedTable && settings.allowFixedTableFallback !== false) {
441
494
  var fixedRow = fixedTable.querySelector('thead tr');
442
495
  var fixedCells = fixedRow ? directCells(fixedRow) : [];
443
496
 
444
- fixedCells.forEach(function(cell, index) {
445
- widths[index] = Math.max(widths[index] || 0, measuredWidth(cell));
446
- });
497
+ mergeMeasuredCellWidths(widths, fixedCells);
447
498
  }
448
499
 
449
500
  return widths;
@@ -483,13 +534,16 @@
483
534
 
484
535
  var sourceRow = sourceHead.querySelector('tr');
485
536
  var headerCells = sourceRow ? directCells(sourceRow) : [];
486
- var hasDataRow = hasMeasurableDataRow(sourceTable, headerCells.length);
487
537
 
488
538
  if (!headerCells.length) {
489
539
  clearFixedHeaderState(slot, scroll, sourceTable);
490
540
  return;
491
541
  }
492
542
 
543
+ slot.hidden = false;
544
+ removeGeneratedColGroup(sourceTable);
545
+ clearSourceColumnMinWidths(sourceTable);
546
+
493
547
  var fixedScroll = ensureFixedHeaderScrollViewport(slot);
494
548
  var fixedTable = fixedScroll.querySelector('.table-fixed-header__table');
495
549
  var fixedSpacer = ensureFixedHeaderSpacer(fixedScroll);
@@ -501,6 +555,7 @@
501
555
 
502
556
  fixedTable.className = fixedHeaderTableClassName(sourceTable);
503
557
  fixedTable.dataset.fixedColumnsCount = sourceTable.dataset.fixedColumnsCount || '0';
558
+ fixedTable.style.width = '';
504
559
  fixedTable.innerHTML = sourceHead.outerHTML;
505
560
 
506
561
  if (fixedTable.parentNode !== fixedScroll) {
@@ -509,15 +564,13 @@
509
564
  fixedScroll.appendChild(fixedSpacer);
510
565
  }
511
566
 
512
- var widths = measuredColumnWidths(sourceTable, fixedTable, {
513
- allowFixedTableFallback: hasDataRow
514
- });
567
+ var widths = measuredColumnWidths(sourceTable, fixedTable);
515
568
  if (!widths.some(Boolean)) {
516
569
  clearFixedHeaderState(slot, scroll, sourceTable);
517
570
  return;
518
571
  }
519
572
 
520
- applyColGroup(sourceTable, widths);
573
+ applySourceColumnMinWidths(sourceTable, widths);
521
574
  applyColGroup(fixedTable, widths);
522
575
  applyFixedHeaderCellWidths(fixedTable, widths);
523
576
  applyFixedHeaderStickyColumns(sourceTable, fixedTable, widths);
@@ -402,6 +402,12 @@ td.actions-column .sticky__item,
402
402
  display: none;
403
403
  }
404
404
 
405
+ table[data-fixed-columns-count] [data-fixed-header-column-min-width] {
406
+ box-sizing: border-box;
407
+ width: var(--fixed-header-column-min-width);
408
+ min-width: var(--fixed-header-column-min-width);
409
+ }
410
+
405
411
  [data-fixed-table-header] .table-fixed-header__table {
406
412
  width: max-content;
407
413
  min-width: 100%;
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YummyGuide
4
4
  module Administrate
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yummy-guide-generic-administrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - akatsuki-kk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-12 00:00:00.000000000 Z
11
+ date: 2026-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate