@nukleus-sports/ui-web 0.1.1 → 0.2.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/dist/index.cjs CHANGED
@@ -241,6 +241,7 @@ __export(src_exports, {
241
241
  toast: () => import_sonner2.toast,
242
242
  toggleVariants: () => toggleVariants,
243
243
  useFormField: () => useFormField,
244
+ useInfiniteList: () => useInfiniteList,
244
245
  useSidebar: () => useSidebar
245
246
  });
246
247
  module.exports = __toCommonJS(src_exports);
@@ -1355,6 +1356,7 @@ function BaseTable({
1355
1356
  ]
1356
1357
  }
1357
1358
  ),
1359
+ bottomContent,
1358
1360
  !loading && !table.getRowModel().rows?.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1359
1361
  TableEmpty,
1360
1362
  {
@@ -4260,7 +4262,7 @@ var MobileModalLayout = ({
4260
4262
  !showBackButton && isDialog ? "px-9" : "px-2"
4261
4263
  ),
4262
4264
  children: [
4263
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4265
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react_dialog.DialogTitle, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4264
4266
  "div",
4265
4267
  {
4266
4268
  className: cn(
@@ -4270,7 +4272,7 @@ var MobileModalLayout = ({
4270
4272
  ),
4271
4273
  children: title
4272
4274
  }
4273
- ),
4275
+ ) }),
4274
4276
  actionContext && actionContext,
4275
4277
  cancelButtonName && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4276
4278
  Button,
@@ -6471,6 +6473,40 @@ function showUndoToast(options) {
6471
6473
  { duration }
6472
6474
  );
6473
6475
  }
6476
+
6477
+ // src/hooks/use-infinite-list.ts
6478
+ var import_react5 = require("react");
6479
+ function useInfiniteList(items, options = {}) {
6480
+ const { batchSize = 100, prefetchPx = 300, resetKey, scrollRootRef } = options;
6481
+ const [displayCount, setDisplayCount] = (0, import_react5.useState)(batchSize);
6482
+ const [sentinelNode, setSentinelNode] = (0, import_react5.useState)(null);
6483
+ const sentinelRef = (0, import_react5.useCallback)((node) => setSentinelNode(node), []);
6484
+ (0, import_react5.useEffect)(() => {
6485
+ setDisplayCount(batchSize);
6486
+ }, [resetKey, batchSize]);
6487
+ const effectiveCount = Math.min(
6488
+ Math.max(displayCount, batchSize),
6489
+ Math.max(items.length, batchSize)
6490
+ );
6491
+ const hasMore = effectiveCount < items.length;
6492
+ (0, import_react5.useEffect)(() => {
6493
+ if (!hasMore || !sentinelNode) return;
6494
+ const observer = new IntersectionObserver(
6495
+ (entries) => {
6496
+ if (entries[0].isIntersecting) setDisplayCount((prev) => prev + batchSize);
6497
+ },
6498
+ {
6499
+ threshold: 0,
6500
+ root: scrollRootRef?.current ?? null,
6501
+ rootMargin: `${prefetchPx}px 0px ${prefetchPx}px 0px`
6502
+ }
6503
+ );
6504
+ observer.observe(sentinelNode);
6505
+ return () => observer.disconnect();
6506
+ }, [hasMore, batchSize, prefetchPx, scrollRootRef, displayCount, sentinelNode]);
6507
+ const visibleItems = (0, import_react5.useMemo)(() => items.slice(0, effectiveCount), [items, effectiveCount]);
6508
+ return { visibleItems, sentinelRef, hasMore, displayCount: effectiveCount };
6509
+ }
6474
6510
  // Annotate the CommonJS export names for ESM import in node:
6475
6511
  0 && (module.exports = {
6476
6512
  Accordion,
@@ -6684,6 +6720,7 @@ function showUndoToast(options) {
6684
6720
  toast,
6685
6721
  toggleVariants,
6686
6722
  useFormField,
6723
+ useInfiniteList,
6687
6724
  useSidebar
6688
6725
  });
6689
6726
  //# sourceMappingURL=index.cjs.map