najm-kit 2.2.4 → 2.2.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +40 -8
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -12127,7 +12127,24 @@ var computeFlags = (state) => {
12127
12127
  const hasControls = Boolean(state.showColumnVisibility || state.showAddButton || state.showViewToggle);
12128
12128
  const isRefreshing = Boolean(state.isLoading) && hasData;
12129
12129
  const showContent = !state.error && !hasNoData && !isFilteredEmpty && (!state.isLoading || hasData);
12130
- return { hasData, hasNoData, isTableView, isCardView, isJsonView, isFilesView, isCustomMode, hasActions, hasControls, isRefreshing, showContent, showPagination: state.showPagination && showContent };
12130
+ return {
12131
+ hasData,
12132
+ hasNoData,
12133
+ isTableView,
12134
+ isCardView,
12135
+ isJsonView,
12136
+ isFilesView,
12137
+ isCustomMode,
12138
+ hasActions,
12139
+ hasControls,
12140
+ isRefreshing,
12141
+ showContent,
12142
+ // Rendered during a first load too, so the bar occupies its height while
12143
+ // the skeleton is up. Without it the body is one bar taller than it will be
12144
+ // once rows arrive, the measured page size is one row too many, and that
12145
+ // row is visibly removed the moment the table loads.
12146
+ showPagination: state.showPagination && (showContent || Boolean(state.isLoading))
12147
+ };
12131
12148
  };
12132
12149
  var createSelectors = (_store) => {
12133
12150
  const store = _store;
@@ -12721,7 +12738,7 @@ function useTable(effectiveViewModeOverride) {
12721
12738
  const dynamicPageSizeTarget = renderedMode === "cards" ? calculatedCardPageSize : calculatedPageSize;
12722
12739
  const geometryKey = `${Math.round(measuredBodyWidth / GEOMETRY_BUCKET_PX)}x${Math.round(measuredBodyHeight / GEOMETRY_BUCKET_PX)}`;
12723
12740
  const reportedGeometryRef = useRef(null);
12724
- useEffect(() => {
12741
+ useLayoutEffect(() => {
12725
12742
  if (!manualPagination || !dynamicHeight) return;
12726
12743
  if (cardPagination.mode !== "paged") return;
12727
12744
  if (!hasMeasuredLayout || measuredBodyHeight <= 0) return;
@@ -12729,12 +12746,16 @@ function useTable(effectiveViewModeOverride) {
12729
12746
  if (dynamicPageSizeTarget === storePagination.pageSize) return;
12730
12747
  const reported = reportedGeometryRef.current;
12731
12748
  if (reported?.key === geometryKey && reported.count >= MAX_PAGE_SIZE_REPORTS_PER_GEOMETRY) return;
12732
- const delay = reported ? DYNAMIC_PAGE_SIZE_DEBOUNCE_MS : 0;
12733
- const timer = setTimeout(() => {
12749
+ const commit = () => {
12734
12750
  const current = reportedGeometryRef.current;
12735
12751
  reportedGeometryRef.current = current?.key === geometryKey ? { key: geometryKey, count: current.count + 1 } : { key: geometryKey, count: 1 };
12736
12752
  setPagination({ pageIndex: storePagination.pageIndex, pageSize: dynamicPageSizeTarget });
12737
- }, delay);
12753
+ };
12754
+ if (!reported) {
12755
+ commit();
12756
+ return;
12757
+ }
12758
+ const timer = setTimeout(commit, DYNAMIC_PAGE_SIZE_DEBOUNCE_MS);
12738
12759
  return () => clearTimeout(timer);
12739
12760
  }, [
12740
12761
  manualPagination,
@@ -13842,7 +13863,7 @@ function CardLoadMorePagination({
13842
13863
  function NTablePagination() {
13843
13864
  const table = useTableStore.use.table();
13844
13865
  const showPagination = useTableStore.use.showPagination();
13845
- const showContent = useTableStore.use.showContent();
13866
+ useTableStore.use.showContent();
13846
13867
  const pageSizeOptions = useTableStore.use.pageSizeOptions();
13847
13868
  const classNames = useTableStore.use.classNames();
13848
13869
  const effectiveViewMode = useTableStore.use.effectiveViewMode();
@@ -13855,7 +13876,7 @@ function NTablePagination() {
13855
13876
  const setPagination = useTableStore.use.setPagination();
13856
13877
  const isPaginationControlled = useTableStore.use.isPaginationControlled();
13857
13878
  const bordered = useTableStore.use.bordered();
13858
- if (!table || !showContent || !showPagination || effectiveViewMode === "json" || effectiveViewMode === "files") return null;
13879
+ if (!table || !showPagination || effectiveViewMode === "json" || effectiveViewMode === "files") return null;
13859
13880
  if (cardPagination.mode === "all") return null;
13860
13881
  if (effectiveViewMode === "cards" && cardPagination.mode === "infinite") return null;
13861
13882
  if (effectiveViewMode === "cards" && cardPagination.mode === "load-more") {
@@ -14336,7 +14357,18 @@ function TableLayout(props) {
14336
14357
  ] })
14337
14358
  }
14338
14359
  ),
14339
- /* @__PURE__ */ jsx("div", { "data-ntable-pagination": true, className: "min-w-0 shrink-0 bg-background text-foreground", children: /* @__PURE__ */ jsx(NTablePagination, {}) })
14360
+ /* @__PURE__ */ jsx(
14361
+ "div",
14362
+ {
14363
+ "data-ntable-pagination": true,
14364
+ "aria-hidden": isLoading && !isRefreshing ? "true" : void 0,
14365
+ className: cn(
14366
+ "min-w-0 shrink-0 bg-background text-foreground",
14367
+ isLoading && !isRefreshing && "invisible"
14368
+ ),
14369
+ children: /* @__PURE__ */ jsx(NTablePagination, {})
14370
+ }
14371
+ )
14340
14372
  ] });
14341
14373
  }
14342
14374
  function NTable(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Reusable React UI component package for Najm framework",