@inf-monkeys-tech/monkeys-design 1.0.53 → 1.0.54

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.mjs CHANGED
@@ -17828,7 +17828,7 @@ var InputGroupInput = React4.forwardRef(({ className, ...props }, ref) => /* @__
17828
17828
  ref,
17829
17829
  "data-slot": "input-group-control",
17830
17830
  className: cn(
17831
- "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
17831
+ "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent",
17832
17832
  className
17833
17833
  ),
17834
17834
  ...props
@@ -17841,7 +17841,7 @@ var InputGroupTextarea = React4.forwardRef(({ className, ...props }, ref) => /*
17841
17841
  ref,
17842
17842
  "data-slot": "input-group-control",
17843
17843
  className: cn(
17844
- "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
17844
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent",
17845
17845
  className
17846
17846
  ),
17847
17847
  ...props
@@ -23253,7 +23253,11 @@ function WorkbenchCollection({
23253
23253
  const itemsRef = useRef(null);
23254
23254
  const loadMoreRef = useRef(null);
23255
23255
  const lastSelectedIndexRef = useRef(null);
23256
- const loadMoreLockedRef = useRef(false);
23256
+ const loadMoreRequestPendingRef = useRef(false);
23257
+ const loadMoreIntersectionActiveRef = useRef(false);
23258
+ const loadMoreIntersectionConsumedRef = useRef(false);
23259
+ const loadMoreScrollValidationPendingRef = useRef(false);
23260
+ const observedLoadMoreTargetRef = useRef(null);
23257
23261
  const layoutReadyRef = useRef(false);
23258
23262
  const [containerWidth, setContainerWidth] = useState(0);
23259
23263
  const [itemsNode, setItemsNode] = useState(null);
@@ -23411,38 +23415,91 @@ function WorkbenchCollection({
23411
23415
  const canLoadMore = typeof callbacks?.onLoadMore === "function";
23412
23416
  const effectiveError = state?.error ?? virtualizationError;
23413
23417
  useEffect(() => {
23414
- if (!loadingMore || !hasMore) loadMoreLockedRef.current = false;
23415
- }, [hasMore, loadingMore, normalizedItems.length, keysSignature]);
23418
+ if (!canLoadMore || !hasMore) {
23419
+ loadMoreIntersectionActiveRef.current = false;
23420
+ loadMoreIntersectionConsumedRef.current = false;
23421
+ loadMoreScrollValidationPendingRef.current = false;
23422
+ }
23423
+ }, [canLoadMore, hasMore]);
23416
23424
  const requestLoadMore = useCallback(() => {
23417
- if (!canLoadMore || !hasMore || loadingMore || loadMoreLockedRef.current) return;
23418
- loadMoreLockedRef.current = true;
23425
+ if (!canLoadMore || !hasMore || loadingMore || loadMoreRequestPendingRef.current) return;
23426
+ loadMoreRequestPendingRef.current = true;
23427
+ const releaseRequest = () => {
23428
+ loadMoreRequestPendingRef.current = false;
23429
+ };
23419
23430
  try {
23420
23431
  const result = callbacksRef.current?.onLoadMore?.();
23421
23432
  if (result && typeof result.then === "function") {
23422
- void result.catch(() => {
23423
- loadMoreLockedRef.current = false;
23424
- });
23433
+ void result.then(releaseRequest, releaseRequest);
23434
+ } else {
23435
+ releaseRequest();
23425
23436
  }
23426
23437
  } catch (error) {
23427
- loadMoreLockedRef.current = false;
23438
+ releaseRequest();
23428
23439
  throw error;
23429
23440
  }
23430
23441
  }, [canLoadMore, hasMore, loadingMore]);
23431
23442
  useEffect(() => {
23432
23443
  const sentinel = loadMoreRef.current;
23433
- if (!sentinel || !canLoadMore || !hasMore || loadingMore) return void 0;
23444
+ if (observedLoadMoreTargetRef.current !== sentinel) {
23445
+ observedLoadMoreTargetRef.current = sentinel;
23446
+ loadMoreIntersectionActiveRef.current = false;
23447
+ loadMoreIntersectionConsumedRef.current = false;
23448
+ loadMoreScrollValidationPendingRef.current = false;
23449
+ }
23450
+ if (!sentinel || !canLoadMore || !hasMore) return void 0;
23434
23451
  if (typeof IntersectionObserver !== "function") return void 0;
23435
23452
  const owner = resolveScrollOwner();
23453
+ let observerHasDelivered = false;
23436
23454
  const observer = new IntersectionObserver((entries) => {
23437
- if (!entries.some((entry) => entry.isIntersecting)) return;
23455
+ const isIntersecting = entries.some((entry) => entry.isIntersecting);
23456
+ if (loadMoreScrollValidationPendingRef.current) {
23457
+ observerHasDelivered = true;
23458
+ loadMoreScrollValidationPendingRef.current = false;
23459
+ loadMoreIntersectionActiveRef.current = isIntersecting;
23460
+ if (!isIntersecting) {
23461
+ loadMoreIntersectionConsumedRef.current = false;
23462
+ return;
23463
+ }
23464
+ if (loadMoreIntersectionConsumedRef.current) return;
23465
+ loadMoreIntersectionConsumedRef.current = true;
23466
+ requestLoadMore();
23467
+ return;
23468
+ }
23469
+ if (!observerHasDelivered) {
23470
+ observerHasDelivered = true;
23471
+ loadMoreIntersectionActiveRef.current = isIntersecting;
23472
+ if (!isIntersecting) loadMoreIntersectionConsumedRef.current = false;
23473
+ return;
23474
+ }
23475
+ if (!isIntersecting) {
23476
+ loadMoreIntersectionActiveRef.current = false;
23477
+ loadMoreIntersectionConsumedRef.current = false;
23478
+ return;
23479
+ }
23480
+ if (loadMoreIntersectionActiveRef.current) return;
23481
+ loadMoreIntersectionActiveRef.current = true;
23482
+ loadMoreIntersectionConsumedRef.current = true;
23438
23483
  requestLoadMore();
23439
23484
  }, {
23440
23485
  root: owner === rootRef.current ? owner : owner || null,
23441
23486
  rootMargin: config.loading?.rootMargin ?? "240px",
23442
23487
  threshold: normalizeThreshold(config.loading?.threshold)
23443
23488
  });
23489
+ const scrollTarget = owner ?? (typeof window === "undefined" ? null : window);
23490
+ const validateActiveIntersection = () => {
23491
+ if (!loadMoreIntersectionActiveRef.current || loadMoreIntersectionConsumedRef.current || loadMoreScrollValidationPendingRef.current) return;
23492
+ loadMoreScrollValidationPendingRef.current = true;
23493
+ observer.unobserve(sentinel);
23494
+ observer.takeRecords();
23495
+ observer.observe(sentinel);
23496
+ };
23444
23497
  observer.observe(sentinel);
23445
- return () => observer.disconnect();
23498
+ scrollTarget?.addEventListener("scroll", validateActiveIntersection, { passive: true });
23499
+ return () => {
23500
+ observer.disconnect();
23501
+ scrollTarget?.removeEventListener("scroll", validateActiveIntersection);
23502
+ };
23446
23503
  }, [canLoadMore, config.loading?.rootMargin, config.loading?.threshold, hasMore, keysSignature, loadingMore, normalizedItems.length, requestLoadMore, resolveScrollOwner]);
23447
23504
  useEffect(() => {
23448
23505
  if (!config.loading?.autoFill || !canLoadMore || !hasMore || loadingMore) return;
@@ -23450,7 +23507,10 @@ function WorkbenchCollection({
23450
23507
  if (!sentinel) return;
23451
23508
  const owner = resolveScrollOwner() ?? (config.layout.scrollOwner === "parent" ? rootRef.current?.parentElement ?? null : null) ?? rootRef.current;
23452
23509
  if (!owner || owner.clientHeight <= 0) return;
23453
- if (owner.scrollHeight <= owner.clientHeight + 1) requestLoadMore();
23510
+ if (owner.scrollHeight <= owner.clientHeight + 1) {
23511
+ loadMoreIntersectionConsumedRef.current = true;
23512
+ requestLoadMore();
23513
+ }
23454
23514
  }, [
23455
23515
  canLoadMore,
23456
23516
  config.layout.scrollOwner,