@nukleus-sports/ui-web 0.1.1 → 0.2.0

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