yummy-guide-generic-administrate 0.8.14 → 0.8.16

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: 31c95c124f946da973981b50eaf0247b854e0eca67d35a1fa2d120c58567d366
4
- data.tar.gz: 4a27c58133a3ec86c2fd483cfd80cef1c45a6655d91316b790dfe0732c0a1d29
3
+ metadata.gz: bea5c7cfc5273ba6a7f6cf59dacded8b77c7ce8c728859b689ddd8e504b6e4fc
4
+ data.tar.gz: e39d3ae5f41ca38513f96e5160ca2ac8949dac0faebee99cebb63e6e8645b66d
5
5
  SHA512:
6
- metadata.gz: b0a893584bf5d7b1db8baee814bb2802ec78e1ce2c61701e411b4166b235d8ab9fba5d5fe4304d837a73fd9ea0d03a787e02912d27d6ead5325d238bc0b3b21e
7
- data.tar.gz: 854c72827dafd518d89c481a7d54da30245fb360e8a717e80b58bb18ac4e82b17e7527bababf8f9bd867b9077ca6d9134de899838de20db5ba6f9e7517a281ad
6
+ metadata.gz: 07caa0d706ce90f07bfed3d380c1e3ab7a8b527e2285bb856b66e19c6a4a5334ff700c38df3a9e22d45cdaaf78edb2acf3cbaf271c8097d223e1f822c1d1cca9
7
+ data.tar.gz: bdbebfc1293d49c7bbd12d495d478edb3295e3b2a8a4b193594d1883a63c57c0fbb5f611d569d9ac9c5740e814245c30252af2c8e1ee51a83b61243091d4339e
@@ -1,5 +1,6 @@
1
1
  (function() {
2
2
  var TABLE_SELECTOR = 'table[data-fixed-columns-count]';
3
+ var TANSTACK_TABLE_ATTRIBUTE = 'data-yummy-guide-administrate-tanstack-table';
3
4
  var CSS_STICKY_TABLE_SELECTOR = '[data-css-sticky-table]';
4
5
  var MAIN_CONTENT_SELECTOR = '.main-content';
5
6
  var STICKY_PAGE_HEADER_SELECTOR = '.main-content__header--sticky-table-layout, [data-reservations-sticky-header], .main-content__header';
@@ -544,12 +545,15 @@
544
545
 
545
546
  function refreshCssStickyLeftColumns(table) {
546
547
  if (!table || table.getAttribute('aria-hidden') === 'true') return;
548
+ if (table.hasAttribute(TANSTACK_TABLE_ATTRIBUTE)) return;
547
549
 
548
550
  refreshCssStickyLeftColumnSet(table, 'sticky-left', '--sticky-left', '--sticky-width');
549
551
  refreshCssStickyLeftColumnSet(table, 'sticky-left-mobile', '--sticky-mobile-left', '--sticky-mobile-width');
550
552
  }
551
553
 
552
554
  function refreshExternalStickyLeftColumns(table, options) {
555
+ if (table && table.hasAttribute(TANSTACK_TABLE_ATTRIBUTE)) return false;
556
+
553
557
  var api = window.YummyGuideAdministrateStickyLeftColumns;
554
558
  var settings = options || {};
555
559
 
@@ -571,6 +575,16 @@
571
575
  }
572
576
 
573
577
  function refreshTableWidthLayout(table, options) {
578
+ if (table && table.hasAttribute(TANSTACK_TABLE_ATTRIBUTE)) {
579
+ table.dispatchEvent(new CustomEvent('yummy-guide-administrate:column-width-change', {
580
+ bubbles: true,
581
+ detail: {
582
+ columnId: options && options.columnId,
583
+ width: options && options.width
584
+ }
585
+ }));
586
+ }
587
+
574
588
  refreshCssStickyLeftColumns(table);
575
589
  refreshExternalStickyLeftColumns(table, options);
576
590
  refreshStickyHeaderLayoutForTable(table);
@@ -1,5 +1,5 @@
1
1
  (function() {
2
- var TABLE_SELECTOR = "table[data-fixed-columns-count]";
2
+ var TABLE_SELECTOR = "table[data-fixed-columns-count]:not([data-yummy-guide-administrate-tanstack-table])";
3
3
  var MOBILE_MEDIA_QUERY = "(max-width: 767px)";
4
4
  var resizeObservers = new WeakMap();
5
5
  var suppressedResizeTables = new WeakMap();
@@ -140,6 +140,11 @@
140
140
  box-shadow: 0 calc(0px - var(--admin-sticky-page-header-top, 0px)) 0 var(--admin-sticky-page-header-top, 0px) var(--admin-page-background, #f6f7f7);
141
141
  }
142
142
 
143
+ .app-container > .main-content:has(> .main-content__header > .main-content__header-pagination),
144
+ body.admin-body > main.main-content:has(> .main-content__header > .main-content__header-pagination) {
145
+ --admin-sticky-page-header-height: 8rem;
146
+ }
147
+
143
148
  .main-content__header--sticky-table-layout + .main-content__body,
144
149
  [data-reservations-sticky-header] + .main-content__body,
145
150
  .app-container > .main-content:has(> .main-content__body--flush [data-css-sticky-table]) > .main-content__body--flush,
@@ -188,6 +193,57 @@
188
193
  --admin-sticky-page-header-height: 6.75rem;
189
194
  --admin-sticky-page-header-z-index: 10;
190
195
  }
196
+
197
+ .app-container > .main-content:has(> .main-content__header > .main-content__header-pagination),
198
+ body.admin-body > main.main-content:has(> .main-content__header > .main-content__header-pagination) {
199
+ --admin-sticky-page-header-height: 9rem;
200
+ }
201
+ }
202
+
203
+ .main-content__header:has(> .main-content__header-pagination) {
204
+ padding-bottom: calc(var(--admin-sticky-page-header-pagination-height, 2.5rem) + 0.75rem);
205
+ }
206
+
207
+ .main-content__header-pagination {
208
+ align-items: center;
209
+ box-sizing: border-box;
210
+ display: flex;
211
+ inset-block-end: 0.5rem;
212
+ inset-inline-start: 50%;
213
+ justify-content: center;
214
+ max-inline-size: calc(100% - 2rem);
215
+ pointer-events: none;
216
+ position: absolute;
217
+ transform: translateX(-50%);
218
+ width: max-content;
219
+ z-index: 1;
220
+ }
221
+
222
+ .main-content__header-pagination .pagination {
223
+ align-items: center;
224
+ display: flex;
225
+ flex-wrap: wrap;
226
+ gap: 0.25rem 0.5rem;
227
+ justify-content: center;
228
+ margin: 0;
229
+ max-inline-size: 100%;
230
+ padding-left: 0;
231
+ padding-right: 0;
232
+ pointer-events: auto;
233
+ text-align: center;
234
+ }
235
+
236
+ .main-content__header-pagination .pagination .first,
237
+ .main-content__header-pagination .pagination .prev,
238
+ .main-content__header-pagination .pagination .page,
239
+ .main-content__header-pagination .pagination .next,
240
+ .main-content__header-pagination .pagination .last {
241
+ flex: 0 0 auto;
242
+ inline-size: auto;
243
+ margin: 0;
244
+ max-inline-size: none;
245
+ white-space: nowrap;
246
+ width: auto;
191
247
  }
192
248
 
193
249
  .scroll-table {
@@ -589,7 +645,23 @@ td.cell-data:hover .admin-copy-cell__button:not([disabled]),
589
645
  left: calc(var(--admin-sticky-table-left-offset, 0px) + var(--sticky-left, 0px));
590
646
  }
591
647
 
648
+ // TanStackを利用するテーブルでは、製品側のReact entrypointがテーブル要素に
649
+ // 設定したCSS変数を使う。仮想行の生成ごとにセルへleftを直接書き込まない。
650
+ @for $index from 1 through 6 {
651
+ table[data-yummy-guide-administrate-tanstack-table] > :is(thead, tbody, tfoot) > tr:not(.js-virtualized-table-spacer) > :nth-child(#{$index}).sticky-left {
652
+ --sticky-left: var(--yummy-guide-administrate-tanstack-column-#{$index}-left) !important;
653
+ --sticky-width: var(--yummy-guide-administrate-tanstack-column-#{$index}-width) !important;
654
+ }
655
+ }
656
+
592
657
  @media (max-width: 767px) {
658
+ @for $index from 1 through 6 {
659
+ table[data-yummy-guide-administrate-tanstack-table] > :is(thead, tbody, tfoot) > tr:not(.js-virtualized-table-spacer) > :nth-child(#{$index}).sticky-left-mobile {
660
+ --sticky-mobile-left: var(--yummy-guide-administrate-tanstack-column-#{$index}-left) !important;
661
+ --sticky-mobile-width: var(--yummy-guide-administrate-tanstack-column-#{$index}-width) !important;
662
+ }
663
+ }
664
+
593
665
  @for $count from 1 through 6 {
594
666
  @for $index from 1 through $count {
595
667
  .scroll-table table[data-fixed-columns-count="#{$count}"] tr > :nth-child(#{$index}):not(.sticky-left),
@@ -98,6 +98,14 @@ module YummyGuide
98
98
  )
99
99
  end
100
100
 
101
+ # TanStack Table を利用する製品側テーブルが、従来の固定列JSではなく
102
+ # CSS変数経由で固定位置を受け取るためのopt-in属性を返す。
103
+ def yummy_guide_administrate_tanstack_table_attributes
104
+ {
105
+ "data-yummy-guide-administrate-tanstack-table" => "true"
106
+ }
107
+ end
108
+
101
109
  def yummy_guide_administrate_collection_table_fixed_columns_count(page:, collection_presenter:)
102
110
  yummy_guide_administrate_collection_fixed_columns_count_for(
103
111
  page: page,
@@ -0,0 +1,7 @@
1
+ <% pagination = local_assigns[:pagination] %>
2
+
3
+ <% if pagination.present? %>
4
+ <div class="main-content__header-pagination">
5
+ <%= pagination %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,30 @@
1
+ <% content_for(:title) do %>
2
+ <%= display_resource_name(page.resource_name) %>
3
+ <% end %>
4
+
5
+ <header class="main-content__header main-content__header--sticky-table-layout">
6
+ <h1 class="main-content__page-title" id="page-title">
7
+ <%= content_for(:title) %>
8
+ </h1>
9
+
10
+ <% if show_search_bar %>
11
+ <%= render(
12
+ "search",
13
+ search_term: search_term,
14
+ resource_name: display_resource_name(page.resource_name)
15
+ ) %>
16
+ <% end %>
17
+
18
+ <div>
19
+ <%= link_to(
20
+ t(
21
+ "administrate.actions.new_resource",
22
+ name: display_resource_name(page.resource_name, singular: true).downcase
23
+ ),
24
+ [:new, namespace, page.resource_path.to_sym],
25
+ class: "button",
26
+ ) if accessible_action?(new_resource, :new) %>
27
+ </div>
28
+
29
+ <%= render("administrate/application/header_pagination", pagination: local_assigns[:pagination]) %>
30
+ </header>
@@ -0,0 +1,22 @@
1
+ <% pagination = render("pagination", resources: resources) %>
2
+
3
+ <%=
4
+ render("index_header",
5
+ resources: resources,
6
+ search_term: search_term,
7
+ page: page,
8
+ show_search_bar: show_search_bar,
9
+ pagination: pagination,
10
+ )
11
+ %>
12
+
13
+ <section class="main-content__body main-content__body--flush">
14
+ <%= render(
15
+ "collection",
16
+ collection_presenter: page,
17
+ collection_field_name: resource_name,
18
+ page: page,
19
+ resources: resources,
20
+ table_title: "page-title"
21
+ ) %>
22
+ </section>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YummyGuide
4
4
  module Administrate
5
- VERSION = "0.8.14"
5
+ VERSION = "0.8.16"
6
6
  end
7
7
  end
@@ -26,6 +26,15 @@ RSpec.describe YummyGuide::Administrate::CollectionHelper do
26
26
  end.new
27
27
  end
28
28
 
29
+ describe "#yummy_guide_administrate_tanstack_table_attributes" do
30
+ # TanStack管理のテーブルだけが従来の固定列JSを回避できる属性を返すことを確認する
31
+ it "returns the TanStack opt-in data attribute" do
32
+ expect(helper_host.yummy_guide_administrate_tanstack_table_attributes).to eq(
33
+ "data-yummy-guide-administrate-tanstack-table" => "true"
34
+ )
35
+ end
36
+ end
37
+
29
38
  describe "#yummy_guide_administrate_collection_table_fixed_columns_count" do
30
39
  # dashboard の固定列数が表示列数を超えていても、実際の列数で打ち止めになることを確認する
31
40
  it "caps the fixed column count by the number of visible attributes" do
@@ -57,6 +57,18 @@ RSpec.describe "column resizer assets" do
57
57
  expect(javascript_source).not_to include("refreshStickyLeftColumnsForWidth")
58
58
  end
59
59
 
60
+ # TanStack管理テーブルは仮想行ごとの固定セル再計算を避け、幅変更イベントだけを通知することを確認する
61
+ it "delegates TanStack table pinning updates to the product entrypoint" do
62
+ sticky_left_columns_source = File.read(File.expand_path("../../../app/assets/javascripts/yummy_guide_administrate/sticky_left_columns.js", __dir__))
63
+ stylesheet_source = File.read(File.expand_path("../../../app/assets/stylesheets/yummy_guide_administrate/components.scss", __dir__))
64
+
65
+ expect(sticky_left_columns_source).to include('table[data-fixed-columns-count]:not([data-yummy-guide-administrate-tanstack-table])')
66
+ expect(javascript_source).to include("TANSTACK_TABLE_ATTRIBUTE = 'data-yummy-guide-administrate-tanstack-table'")
67
+ expect(javascript_source).to include("yummy-guide-administrate:column-width-change")
68
+ expect(javascript_source).to include("if (table.hasAttribute(TANSTACK_TABLE_ATTRIBUTE)) return;")
69
+ expect(stylesheet_source).to include('--yummy-guide-administrate-tanstack-column-#{$index}-left')
70
+ end
71
+
60
72
  # ドラッグ中は実テーブルを再レイアウトせず、プレビューだけを更新することを静的に確認する
61
73
  it "updates only the lightweight preview while dragging" do
62
74
  expect(javascript_source).to include("createDragPreview(sourceTable, previewHeader, startWidth, previewHeaderRect)")
@@ -358,6 +370,22 @@ RSpec.describe "column resizer assets" do
358
370
  expect(resizable_navigation_source).to include("z-index: var(--admin-navigation-z-index, 40)")
359
371
  end
360
372
 
373
+ # ページネーションを固定ページヘッダー下部中央に配置するCSSがあることを静的に確認する
374
+ it "places pagination at the bottom center of the sticky page header" do
375
+ expect(components_source).to include(".main-content__header-pagination")
376
+ expect(components_source).to include("inset-block-end: 0.5rem")
377
+ expect(components_source).to include("inset-inline-start: 50%")
378
+ expect(components_source).to include("transform: translateX(-50%)")
379
+ expect(components_source).to include("justify-content: center")
380
+ expect(components_source).to include("pointer-events: none")
381
+ expect(components_source).to include("pointer-events: auto")
382
+ expect(components_source).to include("--admin-sticky-page-header-height: 8rem")
383
+ expect(components_source).to include("--admin-sticky-page-header-height: 9rem")
384
+ expect(components_source).to include(".main-content__header:has(> .main-content__header-pagination)")
385
+ expect(components_source).to include("white-space: nowrap")
386
+ expect(components_source).to include("inline-size: auto")
387
+ end
388
+
361
389
  # 固定列リサイズ後にCSS変数のleftと幅を再計算する処理があることを静的に確認する
362
390
  it "recalculates CSS sticky-left offsets after applying column widths" do
363
391
  expect(javascript_source).to include("function refreshCssStickyLeftColumns(table)")
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yummy-guide-generic-administrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.14
4
+ version: 0.8.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - akatsuki-kk
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-06-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: administrate
@@ -121,6 +120,9 @@ files:
121
120
  - app/helpers/yummy_guide/administrate/filter_form_helper.rb
122
121
  - app/helpers/yummy_guide/administrate/number_input_helper.rb
123
122
  - app/helpers/yummy_guide/administrate/tooltip_helper.rb
123
+ - app/views/administrate/application/_header_pagination.html.erb
124
+ - app/views/administrate/application/_index_header.html.erb
125
+ - app/views/administrate/application/index.html.erb
124
126
  - app/views/fields/number/_form.html.erb
125
127
  - app/views/fields/yummy_guide_administrate/area/picture/_form.html.erb
126
128
  - app/views/fields/yummy_guide_administrate/area/picture/_index.html.erb
@@ -169,7 +171,6 @@ metadata:
169
171
  homepage_uri: https://github.com/yummy-guide/generic-administrate
170
172
  source_code_uri: https://github.com/yummy-guide/generic-administrate
171
173
  changelog_uri: https://github.com/yummy-guide/generic-administrate
172
- post_install_message:
173
174
  rdoc_options: []
174
175
  require_paths:
175
176
  - lib
@@ -184,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
185
  - !ruby/object:Gem::Version
185
186
  version: '0'
186
187
  requirements: []
187
- rubygems_version: 3.4.10
188
- signing_key:
188
+ rubygems_version: 4.0.21
189
189
  specification_version: 4
190
190
  summary: Shared Administrate extensions for Yummy Guide Rails apps
191
191
  test_files: []