@moving-walls/design-system 1.0.18 → 1.0.19

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/dist/index.esm.js CHANGED
@@ -49253,6 +49253,169 @@ function getRowSelectionOption(rowSelection, serverSidePagination) {
49253
49253
  }
49254
49254
  return rowSelection;
49255
49255
  }
49256
+ /* ------------------------------------------------------------------ */
49257
+ /* Server-side pagination bar – replaces AG Grid's built-in panel */
49258
+ /* when serverSidePagination=true to avoid page-reset feedback loops */
49259
+ /* ------------------------------------------------------------------ */
49260
+ var paginationBtnStyle = function paginationBtnStyle(disabled) {
49261
+ return {
49262
+ display: 'inline-flex',
49263
+ alignItems: 'center',
49264
+ justifyContent: 'center',
49265
+ width: 32,
49266
+ height: 32,
49267
+ border: '1px solid #e2e8f0',
49268
+ borderRadius: 6,
49269
+ background: disabled ? 'transparent' : '#fff',
49270
+ color: disabled ? '#cbd5e1' : '#475569',
49271
+ cursor: disabled ? 'default' : 'pointer',
49272
+ fontSize: 16,
49273
+ lineHeight: 1,
49274
+ transition: 'background 0.15s, border-color 0.15s'
49275
+ };
49276
+ };
49277
+ var ServerSidePaginationBar = /*#__PURE__*/React__default.memo(function ServerSidePaginationBar(_ref) {
49278
+ var totalCount = _ref.totalCount,
49279
+ currentPage = _ref.currentPage,
49280
+ pageSize = _ref.pageSize,
49281
+ onPageChange = _ref.onPageChange,
49282
+ onPageSizeChange = _ref.onPageSizeChange,
49283
+ _ref$pageSizeSelector = _ref.pageSizeSelector,
49284
+ pageSizeSelector = _ref$pageSizeSelector === void 0 ? DEFAULT_PAGE_SIZE_SELECTOR : _ref$pageSizeSelector;
49285
+ var totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
49286
+ var start = totalCount === 0 ? 0 : (currentPage - 1) * pageSize + 1;
49287
+ var end = Math.min(currentPage * pageSize, totalCount);
49288
+ var atFirst = currentPage <= 1;
49289
+ var atLast = currentPage >= totalPages;
49290
+ return jsxs("div", {
49291
+ style: {
49292
+ display: 'flex',
49293
+ alignItems: 'center',
49294
+ justifyContent: 'flex-end',
49295
+ gap: 16,
49296
+ padding: '10px 16px',
49297
+ borderTop: '1px solid #e2e8f0',
49298
+ fontSize: 13,
49299
+ color: '#64748b',
49300
+ background: '#fff',
49301
+ flexShrink: 0,
49302
+ minHeight: 48
49303
+ },
49304
+ role: "navigation",
49305
+ "aria-label": "Pagination",
49306
+ children: [jsxs("span", {
49307
+ style: {
49308
+ display: 'flex',
49309
+ alignItems: 'center',
49310
+ gap: 6
49311
+ },
49312
+ children: [jsx("span", {
49313
+ children: "Page Size:"
49314
+ }), jsx("select", {
49315
+ value: pageSize,
49316
+ onChange: function onChange(e) {
49317
+ return onPageSizeChange(Number(e.target.value));
49318
+ },
49319
+ style: {
49320
+ border: '1px solid #e2e8f0',
49321
+ borderRadius: 6,
49322
+ padding: '4px 8px',
49323
+ fontSize: 13,
49324
+ background: '#fff',
49325
+ color: '#334155',
49326
+ cursor: 'pointer',
49327
+ outline: 'none'
49328
+ },
49329
+ children: pageSizeSelector.map(function (size) {
49330
+ return jsx("option", {
49331
+ value: size,
49332
+ children: size
49333
+ }, size);
49334
+ })
49335
+ })]
49336
+ }), jsxs("span", {
49337
+ style: {
49338
+ display: 'flex',
49339
+ gap: 4
49340
+ },
49341
+ children: [jsx("strong", {
49342
+ style: {
49343
+ color: '#334155'
49344
+ },
49345
+ children: start
49346
+ }), ' to ', jsx("strong", {
49347
+ style: {
49348
+ color: '#334155'
49349
+ },
49350
+ children: end
49351
+ }), ' of ', jsx("strong", {
49352
+ style: {
49353
+ color: '#334155'
49354
+ },
49355
+ children: totalCount
49356
+ })]
49357
+ }), jsxs("span", {
49358
+ style: {
49359
+ display: 'flex',
49360
+ alignItems: 'center',
49361
+ gap: 4
49362
+ },
49363
+ children: [jsx("button", {
49364
+ type: "button",
49365
+ disabled: atFirst,
49366
+ onClick: function onClick() {
49367
+ return onPageChange(1);
49368
+ },
49369
+ style: paginationBtnStyle(atFirst),
49370
+ "aria-label": "First Page",
49371
+ children: "\u226A"
49372
+ }), jsx("button", {
49373
+ type: "button",
49374
+ disabled: atFirst,
49375
+ onClick: function onClick() {
49376
+ return onPageChange(currentPage - 1);
49377
+ },
49378
+ style: paginationBtnStyle(atFirst),
49379
+ "aria-label": "Previous Page",
49380
+ children: "\u2039"
49381
+ }), jsxs("span", {
49382
+ style: {
49383
+ margin: '0 8px',
49384
+ fontSize: 13
49385
+ },
49386
+ children: ["Page ", jsx("strong", {
49387
+ style: {
49388
+ color: '#334155'
49389
+ },
49390
+ children: currentPage
49391
+ }), " of ", jsx("strong", {
49392
+ style: {
49393
+ color: '#334155'
49394
+ },
49395
+ children: totalPages
49396
+ })]
49397
+ }), jsx("button", {
49398
+ type: "button",
49399
+ disabled: atLast,
49400
+ onClick: function onClick() {
49401
+ return onPageChange(currentPage + 1);
49402
+ },
49403
+ style: paginationBtnStyle(atLast),
49404
+ "aria-label": "Next Page",
49405
+ children: "\u203A"
49406
+ }), jsx("button", {
49407
+ type: "button",
49408
+ disabled: atLast,
49409
+ onClick: function onClick() {
49410
+ return onPageChange(totalPages);
49411
+ },
49412
+ style: paginationBtnStyle(atLast),
49413
+ "aria-label": "Last Page",
49414
+ children: "\u226B"
49415
+ })]
49416
+ })]
49417
+ });
49418
+ });
49256
49419
  function AgGridTableInner(props) {
49257
49420
  var _a, _b;
49258
49421
  var rowData = props.rowData,
@@ -49297,7 +49460,8 @@ function AgGridTableInner(props) {
49297
49460
  state: sortStateToColumnState(sortState)
49298
49461
  });
49299
49462
  }
49300
- if (serverSidePagination && serverSideConfig) {
49463
+ // For non-server-side pagination, sync AG Grid's internal page
49464
+ if (!serverSidePagination && serverSideConfig) {
49301
49465
  isPaginationFromExternalRef.current = true;
49302
49466
  event.api.paginationGoToPage(serverSideConfig.currentPage - 1);
49303
49467
  event.api.setGridOption("paginationPageSize", serverSideConfig.pageSize);
@@ -49310,8 +49474,9 @@ function AgGridTableInner(props) {
49310
49474
  state: sortStateToColumnState(sortState)
49311
49475
  });
49312
49476
  }, [sortState]);
49477
+ // Sync AG Grid internal page — only for NON-server-side pagination
49313
49478
  useEffect(function () {
49314
- if (!serverSidePagination || !serverSideConfig || !apiRef.current) return;
49479
+ if (serverSidePagination || !serverSideConfig || !apiRef.current) return;
49315
49480
  var api = apiRef.current;
49316
49481
  var currentGridPage = api.paginationGetCurrentPage();
49317
49482
  var currentGridSize = api.paginationGetPageSize();
@@ -49324,8 +49489,12 @@ function AgGridTableInner(props) {
49324
49489
  },
49325
49490
  // eslint-disable-next-line react-hooks/exhaustive-deps
49326
49491
  [serverSidePagination, serverSideConfig === null || serverSideConfig === void 0 ? void 0 : serverSideConfig.currentPage, serverSideConfig === null || serverSideConfig === void 0 ? void 0 : serverSideConfig.pageSize]);
49492
+ // onPaginationChanged — only relevant for NON-server-side mode
49327
49493
  var onPaginationChanged = useCallback(function (event) {
49328
- if (!serverSidePagination || !serverSideConfig || !event.api) return;
49494
+ // When serverSidePagination is true, AG Grid's pagination is disabled;
49495
+ // our custom bar handles page changes directly. Ignore all grid events.
49496
+ if (serverSidePagination) return;
49497
+ if (!serverSideConfig || !event.api) return;
49329
49498
  if (event.newData) return;
49330
49499
  if (isPaginationFromExternalRef.current) {
49331
49500
  isPaginationFromExternalRef.current = false;
@@ -49396,45 +49565,57 @@ function AgGridTableInner(props) {
49396
49565
  width: "100%"
49397
49566
  };
49398
49567
  }, [height]);
49399
- return jsx("div", {
49400
- className: "".concat(AG_GRID_THEME_CLASS, " ag-grid-table-wrapper ").concat(className),
49401
- style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : {
49402
- height: "100%",
49403
- width: "100%"
49404
- },
49405
- children: jsx(AgGridReact, {
49406
- ref: gridRef,
49407
- rowData: rowData,
49408
- columnDefs: columnDefsWithVisibility,
49409
- getRowId: function getRowId(params) {
49410
- return _getRowId(params.data);
49568
+ // When serverSidePagination is true, disable AG Grid's built-in pagination.
49569
+ // We render our own bar below with proper React click handlers.
49570
+ var useGridPagination = !serverSidePagination && pagination;
49571
+ return jsxs(Fragment, {
49572
+ children: [jsx("div", {
49573
+ className: "".concat(AG_GRID_THEME_CLASS, " ag-grid-table-wrapper ").concat(className),
49574
+ style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : {
49575
+ height: "100%",
49576
+ width: "100%"
49411
49577
  },
49412
- loading: loading,
49413
- overlayNoRowsTemplate: "<span class=\"ag-overlay-no-rows-center\">".concat(escapeOverlayText(emptyMessage), "</span>"),
49414
- rowSelection: getRowSelectionOption(rowSelection, serverSidePagination),
49415
- popupParent: typeof document !== "undefined" ? document.body : null,
49416
- onGridReady: onGridReady,
49417
- onSortChanged: onSortChanged,
49418
- onPaginationChanged: onPaginationChanged,
49419
- onSelectionChanged: rowSelection !== false ? onSelectionChanged : undefined,
49420
- defaultColDef: Object.assign({
49421
- sortable: false,
49422
- resizable: true
49423
- }, defaultColDef),
49424
- domLayout: domLayout,
49425
- rowHeight: 60,
49426
- suppressRowTransform: true,
49427
- headerHeight: 44,
49428
- pagination: pagination,
49429
- paginationPageSize: (_a = serverSideConfig === null || serverSideConfig === void 0 ? void 0 : serverSideConfig.pageSize) !== null && _a !== void 0 ? _a : 10,
49430
- paginationPageSizeSelector: (_b = serverSideConfig === null || serverSideConfig === void 0 ? void 0 : serverSideConfig.pageSizeSelector) !== null && _b !== void 0 ? _b : DEFAULT_PAGE_SIZE_SELECTOR,
49431
- cacheBlockSize: cacheBlockSize,
49432
- pinnedBottomRowData: footerData === null || footerData === void 0 ? void 0 : footerData.map(function (row, i) {
49433
- return _typeof(row) === "object" && row !== null && !("id" in row) ? Object.assign(Object.assign({}, row), {
49434
- id: "pinned-bottom-".concat(i)
49435
- }) : row;
49578
+ children: jsx(AgGridReact, {
49579
+ ref: gridRef,
49580
+ rowData: rowData,
49581
+ columnDefs: columnDefsWithVisibility,
49582
+ getRowId: function getRowId(params) {
49583
+ return _getRowId(params.data);
49584
+ },
49585
+ loading: loading,
49586
+ overlayNoRowsTemplate: "<span class=\"ag-overlay-no-rows-center\">".concat(escapeOverlayText(emptyMessage), "</span>"),
49587
+ rowSelection: getRowSelectionOption(rowSelection, serverSidePagination),
49588
+ popupParent: typeof document !== "undefined" ? document.body : null,
49589
+ onGridReady: onGridReady,
49590
+ onSortChanged: onSortChanged,
49591
+ onPaginationChanged: useGridPagination ? onPaginationChanged : undefined,
49592
+ onSelectionChanged: rowSelection !== false ? onSelectionChanged : undefined,
49593
+ defaultColDef: Object.assign({
49594
+ sortable: false,
49595
+ resizable: true
49596
+ }, defaultColDef),
49597
+ domLayout: domLayout,
49598
+ rowHeight: 60,
49599
+ suppressRowTransform: true,
49600
+ headerHeight: 44,
49601
+ pagination: useGridPagination,
49602
+ paginationPageSize: useGridPagination ? (_a = serverSideConfig === null || serverSideConfig === void 0 ? void 0 : serverSideConfig.pageSize) !== null && _a !== void 0 ? _a : 10 : undefined,
49603
+ paginationPageSizeSelector: useGridPagination ? (_b = serverSideConfig === null || serverSideConfig === void 0 ? void 0 : serverSideConfig.pageSizeSelector) !== null && _b !== void 0 ? _b : DEFAULT_PAGE_SIZE_SELECTOR : undefined,
49604
+ cacheBlockSize: cacheBlockSize,
49605
+ pinnedBottomRowData: footerData === null || footerData === void 0 ? void 0 : footerData.map(function (row, i) {
49606
+ return _typeof(row) === "object" && row !== null && !("id" in row) ? Object.assign(Object.assign({}, row), {
49607
+ id: "pinned-bottom-".concat(i)
49608
+ }) : row;
49609
+ })
49436
49610
  })
49437
- })
49611
+ }), serverSidePagination && serverSideConfig && jsx(ServerSidePaginationBar, {
49612
+ totalCount: serverSideConfig.totalCount,
49613
+ currentPage: serverSideConfig.currentPage,
49614
+ pageSize: serverSideConfig.pageSize,
49615
+ onPageChange: serverSideConfig.onPageChange,
49616
+ onPageSizeChange: serverSideConfig.onPageSizeChange,
49617
+ pageSizeSelector: serverSideConfig.pageSizeSelector
49618
+ })]
49438
49619
  });
49439
49620
  }
49440
49621
  var AgGridTable = AgGridTableInner;