Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,24 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Virtualizer", {
enumerable: true,
get: function() {
return Virtualizer;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _useVirtualizerStylesstyles = require("./useVirtualizerStyles.styles");
const _useVirtualizer = require("./useVirtualizer");
const _renderVirtualizer = require("./renderVirtualizer");
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
const Virtualizer = (props)=>{
const state = (0, _useVirtualizer.useVirtualizer_unstable)(props);
(0, _useVirtualizerStylesstyles.useVirtualizerStyles_unstable)(state);
(0, _reactsharedcontexts.useCustomStyleHook_unstable)('useVirtualizerStyles_unstable')(state);
return (0, _renderVirtualizer.renderVirtualizer_unstable)(state);
};
Virtualizer.displayName = 'Virtualizer';

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Virtualizer/Virtualizer.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { VirtualizerProps } from './Virtualizer.types';\nimport { useVirtualizerStyles_unstable } from './useVirtualizerStyles.styles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Virtualizer pseudo-component, this functional wrapper\n * provides a simple interface for reducing the total number\n * of elements rendered at one time in large lists.\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const Virtualizer: React.FC<VirtualizerProps> = (props: VirtualizerProps) => {\n const state = useVirtualizer_unstable(props);\n useVirtualizerStyles_unstable(state);\n useCustomStyleHook_unstable('useVirtualizerStyles_unstable')(state);\n\n return renderVirtualizer_unstable(state);\n};\n\nVirtualizer.displayName = 'Virtualizer';\n"],"names":["React","useVirtualizerStyles_unstable","useVirtualizer_unstable","renderVirtualizer_unstable","useCustomStyleHook_unstable","Virtualizer","props","state","displayName"],"mappings":"AAAA;;;;;;;;;;;;iEAEuB,QAAQ;4CAEe,gCAAgC;gCACtC,mBAAmB;mCAChB,sBAAsB;qCACrB,kCAAkC;AAQvE,MAAMK,cAA0C,CAACC;IACtD,MAAMC,YAAQL,uCAAAA,EAAwBI;QACtCL,yDAAAA,EAA8BM;QAC9BH,gDAAAA,EAA4B,iCAAiCG;IAE7D,WAAOJ,6CAAAA,EAA2BI;AACpC,EAAE;AAEFF,YAAYG,WAAW,GAAG"}

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
Virtualizer: function() {
return _Virtualizer.Virtualizer;
},
renderVirtualizerChildPlaceholder: function() {
return _renderVirtualizer.renderVirtualizerChildPlaceholder;
},
renderVirtualizer_unstable: function() {
return _renderVirtualizer.renderVirtualizer_unstable;
},
useVirtualizerStyles_unstable: function() {
return _useVirtualizerStylesstyles.useVirtualizerStyles_unstable;
},
useVirtualizer_unstable: function() {
return _useVirtualizer.useVirtualizer_unstable;
},
virtualizerClassNames: function() {
return _useVirtualizerStylesstyles.virtualizerClassNames;
}
});
const _Virtualizer = require("./Virtualizer");
const _useVirtualizer = require("./useVirtualizer");
const _renderVirtualizer = require("./renderVirtualizer");
const _useVirtualizerStylesstyles = require("./useVirtualizerStyles.styles");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Virtualizer/index.ts"],"sourcesContent":["export { Virtualizer } from './Virtualizer';\nexport type {\n VirtualizerChildRenderFunction,\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerDataRef,\n VirtualizerProps,\n VirtualizerSlots,\n VirtualizerState,\n} from './Virtualizer.types';\nexport { useVirtualizer_unstable } from './useVirtualizer';\nexport { renderVirtualizerChildPlaceholder, renderVirtualizer_unstable } from './renderVirtualizer';\nexport { useVirtualizerStyles_unstable, virtualizerClassNames } from './useVirtualizerStyles.styles';\n"],"names":["Virtualizer","useVirtualizer_unstable","renderVirtualizerChildPlaceholder","renderVirtualizer_unstable","useVirtualizerStyles_unstable","virtualizerClassNames"],"mappings":";;;;;;;;;;;;eAASA,wBAAW;;;eAWXE,oDAAiC;;;eAAEC,6CAA0B;;;eAC7DC,yDAA6B;;;eAF7BH,uCAAuB;;;eAEQI,iDAAqB;;;6BAZjC,gBAAgB;gCAUJ,mBAAmB;mCACmB,sBAAsB;4CAC/B,gCAAgC"}

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
renderVirtualizerChildPlaceholder: function() {
return renderVirtualizerChildPlaceholder;
},
renderVirtualizer_unstable: function() {
return renderVirtualizer_unstable;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _reactutilities = require("@fluentui/react-utilities");
const renderVirtualizer_unstable = (state)=>{
(0, _reactutilities.assertSlots)(state);
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.beforeContainer, {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.before, {})
}),
state.virtualizedChildren,
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.afterContainer, {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.after, {})
})
]
});
};
const renderVirtualizerChildPlaceholder = (child, index)=>{
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Suspense, {
fallback: null,
children: child
}, `fui-virtualizer-placeholder-${index}`);
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Virtualizer/renderVirtualizer.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport type { VirtualizerSlots, VirtualizerState } from './Virtualizer.types';\n\nimport { assertSlots } from '@fluentui/react-utilities';\n\n/**\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const renderVirtualizer_unstable = (state: VirtualizerState): React.ReactElement => {\n assertSlots<VirtualizerSlots>(state);\n return (\n <React.Fragment>\n {/* The 'before' bookend to hold items in place and detect scroll previous */}\n <state.beforeContainer>\n <state.before />\n </state.beforeContainer>\n {/* The reduced list of non-virtualized children to be rendered */}\n {state.virtualizedChildren}\n {/* The 'after' bookend to hold items in place and detect scroll next */}\n <state.afterContainer>\n <state.after />\n </state.afterContainer>\n </React.Fragment>\n );\n};\n/**\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const renderVirtualizerChildPlaceholder = (child: React.ReactNode, index: number): React.ReactElement => {\n return (\n <React.Suspense key={`fui-virtualizer-placeholder-${index}`} fallback={null}>\n {child}\n </React.Suspense>\n );\n};\n"],"names":["React","assertSlots","renderVirtualizer_unstable","state","Fragment","beforeContainer","before","virtualizedChildren","afterContainer","after","renderVirtualizerChildPlaceholder","child","index","Suspense","fallback"],"mappings":";;;;;;;;;;;qCA+BaU;;;IApBAR,0BAAAA;;;;;4BAVb,iCAAiD;iEAE1B,QAAQ;gCAGH,4BAA4B;AAKjD,mCAAmC,CAACC;QACzCF,2BAAAA,EAA8BE;IAC9B,OAAA,WAAA,OACE,gBAAA,EAACH,OAAMI,QAAQ,EAAA;;8BAEb,eAAA,EAACD,MAAME,eAAe,EAAA;0BACpB,WAAA,OAAA,eAAA,EAACF,MAAMG,MAAM,EAAA,CAAA;;YAGdH,MAAMI,mBAAmB;8BAE1B,eAAA,EAACJ,MAAMK,cAAc,EAAA;0BACnB,WAAA,OAAA,eAAA,EAACL,MAAMM,KAAK,EAAA,CAAA;;;;AAIpB,EAAE;AAIK,MAAMC,oCAAoC,CAACC,OAAwBC;IACxE,OAAA,WAAA,OACE,eAAA,EAACZ,OAAMa,QAAQ,EAAA;QAA8CC,UAAU;kBACpEH;OADkB,CAAC,4BAA4B,EAAEC,OAAO;AAI/D,EAAE"}

View File

@@ -0,0 +1,543 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useVirtualizer_unstable", {
enumerable: true,
get: function() {
return useVirtualizer_unstable;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _useIntersectionObserver = require("../../hooks/useIntersectionObserver");
const _Utilities = require("../../Utilities");
const _reactutilities = require("@fluentui/react-utilities");
const _reactdom = require("react-dom");
function useVirtualizer_unstable(props) {
'use no memo';
const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef, containerSizeRef, scrollViewRef, enableScrollLoad, updateScrollPosition, gap = 0 } = props;
/* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = (0, _Utilities.useVirtualizerContextState_unstable)(virtualizerContext);
// We use this ref as a constant source to access the virtualizer's state imperatively
const actualIndexRef = _react.useRef(_virtualizerContext.contextIndex);
const flaggedIndex = _react.useRef(null);
const actualIndex = _virtualizerContext.contextIndex;
// Just in case our ref gets out of date vs the context during a re-render
if (_virtualizerContext.contextIndex !== actualIndexRef.current) {
actualIndexRef.current = _virtualizerContext.contextIndex;
}
const setActualIndex = _react.useCallback((index)=>{
actualIndexRef.current = index;
_virtualizerContext.setContextIndex(index);
}, [
_virtualizerContext
]);
// Store ref to before padding element
const beforeElementRef = _react.useRef(null);
// Store ref to before padding element
const afterElementRef = _react.useRef(null);
// We need to store an array to track dynamic sizes, we can use this to incrementally update changes
const childSizes = _react.useRef(new Array(getItemSize ? numItems : 0));
/* We keep track of the progressive sizing/placement down the list,
this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = _react.useRef(new Array(getItemSize ? numItems : 0));
if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
}
// The internal tracking REF for child array (updates often).
const childArray = _react.useRef(new Array(virtualizerLength));
const populateSizeArrays = ()=>{
if (!getItemSize) {
// Static sizes, never mind!
return;
}
if (numItems !== childSizes.current.length) {
childSizes.current = new Array(numItems);
}
if (numItems !== childProgressiveSizes.current.length) {
childProgressiveSizes.current = new Array(numItems);
if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
}
}
for(let index = 0; index < numItems; index++){
const _gap = index < numItems - 1 ? gap : 0;
childSizes.current[index] = getItemSize(index) + _gap;
if (index === 0) {
childProgressiveSizes.current[index] = childSizes.current[index];
} else {
childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];
}
}
};
const [isScrolling, setIsScrolling] = _react.useState(false);
const [setScrollTimer, clearScrollTimer] = (0, _reactutilities.useTimeout)();
const scrollCounter = _react.useRef(0);
const initializeScrollingTimer = _react.useCallback(()=>{
if (!enableScrollLoad) {
// Disabled by default for reduction of render callbacks
setIsScrolling(false);
clearScrollTimer();
return;
}
/*
* This can be considered the 'velocity' required to start 'isScrolling'
* INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling
* INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset
* - Maybe we should let users customize these in the future.
*/ const INIT_SCROLL_FLAG_REQ = 10;
const INIT_SCROLL_FLAG_DELAY = 100;
scrollCounter.current++;
if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {
setIsScrolling(true);
}
clearScrollTimer();
setScrollTimer(()=>{
setIsScrolling(false);
scrollCounter.current = 0;
}, INIT_SCROLL_FLAG_DELAY);
}, [
clearScrollTimer,
setScrollTimer,
enableScrollLoad
]);
_react.useEffect(()=>{
initializeScrollingTimer();
}, [
actualIndex,
initializeScrollingTimer
]);
const updateChildRows = _react.useCallback((newIndex)=>{
if (numItems === 0) {
/* Nothing to virtualize */ return;
}
/*
We reset the array every time to ensure children are re-rendered
This function should only be called when update is nessecary
*/ childArray.current = new Array(virtualizerLength);
const _actualIndex = Math.max(newIndex, 0);
const end = Math.min(_actualIndex + virtualizerLength, numItems);
for(let i = _actualIndex; i < end; i++){
childArray.current[i - _actualIndex] = renderChild(i, isScrolling);
}
}, [
isScrolling,
numItems,
renderChild,
virtualizerLength
]);
const updateCurrentItemSizes = _react.useCallback((newIndex)=>{
if (!getItemSize) {
// Static sizes, not required.
return;
}
// We should always call our size function on index change (only for the items that will be rendered)
// This ensures we request the latest data for incoming items in case sizing has changed.
const endIndex = Math.min(newIndex + virtualizerLength, numItems);
const startIndex = Math.max(newIndex, 0);
let didUpdate = false;
for(let i = startIndex; i < endIndex; i++){
const _gap = i < numItems - 1 ? gap : 0;
const newSize = getItemSize(i) + _gap;
if (newSize !== childSizes.current[i]) {
childSizes.current[i] = newSize;
didUpdate = true;
}
}
if (didUpdate) {
// Update our progressive size array
for(let i = startIndex; i < numItems; i++){
const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;
childProgressiveSizes.current[i] = prevSize + childSizes.current[i];
}
}
}, [
getItemSize,
numItems,
virtualizerLength,
gap
]);
const batchUpdateNewIndex = _react.useCallback((index)=>{
// Local updates
updateChildRows(index);
updateCurrentItemSizes(index);
// State setters
setActualIndex(index);
}, [
setActualIndex,
updateChildRows,
updateCurrentItemSizes
]);
const findIndexRecursive = _react.useCallback((scrollPos, lowIndex, highIndex)=>{
if (lowIndex > highIndex) {
// We shouldn't get here - but no-op the index if we do.
return actualIndex;
}
const midpoint = Math.floor((lowIndex + highIndex) / 2);
const iBefore = Math.max(midpoint - 1, 0);
const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);
const indexValue = childProgressiveSizes.current[midpoint];
const afterIndexValue = childProgressiveSizes.current[iAfter];
const beforeIndexValue = childProgressiveSizes.current[iBefore];
if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {
/* We've found our index - if we are exactly matching before/after index that's ok,
better to reduce checks if it's right on the boundary. */ return midpoint;
}
if (indexValue > scrollPos) {
return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);
} else {
return findIndexRecursive(scrollPos, midpoint + 1, highIndex);
}
}, [
actualIndex
]);
const getIndexFromSizeArray = _react.useCallback((scrollPos)=>{
/* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {
// Check start
return 0;
}
if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {
// Check end
return childProgressiveSizes.current.length - 1;
}
return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);
}, [
findIndexRecursive
]);
const getIndexFromScrollPosition = _react.useCallback((scrollPos)=>{
if (!getItemSize) {
return Math.round(scrollPos / (itemSize + gap));
}
return getIndexFromSizeArray(scrollPos);
}, [
getIndexFromSizeArray,
getItemSize,
itemSize,
gap
]);
const calculateTotalSize = _react.useCallback(()=>{
if (!getItemSize) {
return (itemSize + gap) * numItems;
}
// Time for custom size calcs
return childProgressiveSizes.current[numItems - 1];
}, [
getItemSize,
itemSize,
numItems,
gap
]);
const calculateBefore = _react.useCallback(()=>{
const currentIndex = Math.min(actualIndex, numItems - 1);
if (!getItemSize) {
// The missing items from before virtualization starts height
return currentIndex * (itemSize + gap);
}
if (currentIndex <= 0) {
return 0;
}
// Time for custom size calcs
return childProgressiveSizes.current[currentIndex - 1];
}, [
actualIndex,
getItemSize,
itemSize,
numItems,
gap
]);
const calculateAfter = _react.useCallback(()=>{
if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {
return 0;
}
const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);
if (!getItemSize) {
// The missing items from after virtualization ends height
const remainingItems = numItems - lastItemIndex;
return remainingItems * (itemSize + gap) - gap;
}
// Time for custom size calcs
return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];
}, [
actualIndex,
getItemSize,
itemSize,
numItems,
virtualizerLength,
gap
]);
// We store the number of items since last render, we will allow an update if the number of items changes
const previousNumItems = _react.useRef(numItems);
// Observe intersections of virtualized components
const { setObserverList } = (0, _useIntersectionObserver.useIntersectionObserver)(_react.useCallback((entries, observer)=>{
/* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
if (actualIndex !== 0) {
batchUpdateNewIndex(0);
}
// No-op
return;
}
if (entries.length === 0) {
// No entries found, return.
return;
}
// Find the latest entry that is intersecting
const sortedEntries = entries.sort((entry1, entry2)=>entry2.time - entry1.time);
const latestEntry = sortedEntries.find((entry)=>{
return entry.isIntersecting;
});
if (!latestEntry) {
return;
}
// We have to be sure our item sizes are up to date with current indexed ref before calculation
// Check if we still need
updateCurrentItemSizes(actualIndexRef.current);
const calculateOverBuffer = ()=>{
/**
* We avoid using the scroll ref scrollTop, it may be incorrect
* as virtualization may exist within a scroll view with other elements
* The benefit of using IO is that we can detect relative scrolls,
* so any items can be placed around the virtualizer in the scroll view
*/ let measurementPos = 0;
if (latestEntry.target === afterElementRef.current) {
// Get after buffers position
measurementPos = calculateTotalSize() - calculateAfter();
// Get exact intersection position based on overflow size (how far into IO did we scroll?)
const overflowAmount = axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;
// Add to original after position
measurementPos += overflowAmount;
// Ignore buffer size (IO offset)
measurementPos -= bufferSize;
var _containerSizeRef_current;
// we hit the after buffer and detected the end of view, we need to find the start index.
measurementPos -= (_containerSizeRef_current = containerSizeRef.current) !== null && _containerSizeRef_current !== void 0 ? _containerSizeRef_current : 0;
// Calculate how far past the window bounds we are (this will be zero if IO is within window)
const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
const hOverflowReversed = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;
const wOverflow = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;
const wOverflowReversed = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;
const widthOverflow = reversed ? wOverflowReversed : wOverflow;
const heightOverflow = reversed ? hOverflowReversed : hOverflow;
const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;
if (reversed) {
measurementPos += additionalOverflow;
} else {
measurementPos -= additionalOverflow;
}
} else if (latestEntry.target === beforeElementRef.current) {
// Get before buffers position
measurementPos = calculateBefore();
// Get exact intersection position based on overflow size (how far into window did we scroll IO?)
const overflowAmount = axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;
// Minus from original before position
measurementPos -= overflowAmount;
// Ignore buffer size (IO offset)
measurementPos += bufferSize;
// Calculate how far past the window bounds we are (this will be zero if IO is within window)
const hOverflow = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;
const hOverflowReversed = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
const wOverflow = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;
const wOverflowReversed = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;
const widthOverflow = reversed ? wOverflowReversed : wOverflow;
const heightOverflow = reversed ? hOverflowReversed : hOverflow;
const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;
if (reversed) {
measurementPos += additionalOverflow;
} else {
measurementPos -= additionalOverflow;
}
}
return measurementPos;
};
// Get exact relative 'scrollTop' via IO values
const measurementPos = calculateOverBuffer();
const maxIndex = Math.max(numItems - virtualizerLength, 0);
const startIndex = getIndexFromScrollPosition(measurementPos) - bufferItems;
// Safety limits
const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);
(0, _reactdom.flushSync)(()=>{
// Callback to allow measure functions to check virtualizer length
if (previousNumItems.current === numItems && newStartIndex + virtualizerLength >= numItems && actualIndex + virtualizerLength >= numItems) {
// We've already hit the end, no need to update state.
return;
}
// We should ensure we update virtualizer calculations if the length changes
previousNumItems.current = virtualizerLength;
updateScrollPosition === null || updateScrollPosition === void 0 ? void 0 : updateScrollPosition(measurementPos);
if (actualIndex !== newStartIndex) {
batchUpdateNewIndex(newStartIndex);
}
});
}, [
actualIndex,
virtualizerLength,
axis,
reversed,
numItems,
bufferSize,
bufferItems,
containerSizeRef,
updateScrollPosition,
batchUpdateNewIndex,
calculateAfter,
calculateBefore,
calculateTotalSize,
getIndexFromScrollPosition,
updateCurrentItemSizes
]), {
root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
rootMargin: '0px',
threshold: 0
});
const setBeforeRef = _react.useCallback((element)=>{
if (!element || beforeElementRef.current === element) {
return;
}
beforeElementRef.current = element;
const newList = [];
newList.push(beforeElementRef.current);
if (afterElementRef.current) {
newList.push(afterElementRef.current);
}
// Ensure we update array if before element changed
setObserverList(newList);
}, [
setObserverList
]);
const setAfterRef = _react.useCallback((element)=>{
if (!element || afterElementRef.current === element) {
return;
}
afterElementRef.current = element;
const newList = [];
if (beforeElementRef.current) {
newList.push(beforeElementRef.current);
}
newList.push(afterElementRef.current);
// Ensure we update array if after element changed
setObserverList(newList);
}, [
setObserverList
]);
// Initialize the size array before first render.
const hasInitialized = _react.useRef(false);
const initializeSizeArray = ()=>{
if (hasInitialized.current === false) {
hasInitialized.current = true;
populateSizeArrays();
}
};
_react.useImperativeHandle(imperativeVirtualizerRef, ()=>{
return {
progressiveSizes: childProgressiveSizes,
nodeSizes: childSizes,
setFlaggedIndex: (index)=>flaggedIndex.current = index,
currentIndex: actualIndexRef
};
}, [
childProgressiveSizes,
childSizes
]);
// Initialization on mount - update array index to 0 (ready state).
// Only fire on mount (no deps).
_react.useEffect(()=>{
if (actualIndex < 0) {
batchUpdateNewIndex(0);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
/*
* forceUpdate:
* We only want to trigger this when child render or scroll loading changes,
* it will force re-render all children elements
*/ const forceUpdate = _react.useReducer(()=>({}), {})[1];
// If the user passes in an updated renderChild function - update current children
_react.useEffect(()=>{
if (actualIndex >= 0) {
updateChildRows(actualIndex);
forceUpdate();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
renderChild,
isScrolling
]);
_react.useEffect(()=>{
// Ensure we repopulate if getItemSize callback changes
populateSizeArrays();
// We only run this effect on getItemSize change (recalc dynamic sizes)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
getItemSize,
gap
]);
// Effect to check flag index on updates
_react.useEffect(()=>{
if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {
return;
}
if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {
onRenderedFlaggedIndex(flaggedIndex.current);
flaggedIndex.current = null;
}
}, [
actualIndex,
onRenderedFlaggedIndex,
virtualizerLength
]);
// Ensure we have run through and updated the whole size list array at least once.
initializeSizeArray();
if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {
// Child length mismatch, repopulate size arrays.
populateSizeArrays();
}
// Ensure we recalc if virtualizer length changes
const maxCompare = Math.min(virtualizerLength, numItems);
if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {
updateChildRows(actualIndex);
}
const isFullyInitialized = hasInitialized.current && actualIndex >= 0;
return {
components: {
before: 'div',
after: 'div',
beforeContainer: 'div',
afterContainer: 'div'
},
virtualizedChildren: childArray.current,
before: _reactutilities.slot.always(props.before, {
defaultProps: {
ref: setBeforeRef,
role: 'none'
},
elementType: 'div'
}),
after: _reactutilities.slot.always(props.after, {
defaultProps: {
ref: setAfterRef,
role: 'none'
},
elementType: 'div'
}),
beforeContainer: _reactutilities.slot.always(props.beforeContainer, {
defaultProps: {
role: 'none'
},
elementType: 'div'
}),
afterContainer: _reactutilities.slot.always(props.afterContainer, {
defaultProps: {
role: 'none'
},
elementType: 'div'
}),
beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,
afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,
totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,
virtualizerStartIndex: actualIndex,
axis,
bufferSize,
reversed,
childSizes,
childProgressiveSizes
};
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,124 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
useVirtualizerStyles_unstable: function() {
return useVirtualizerStyles_unstable;
},
virtualizerClassNames: function() {
return virtualizerClassNames;
}
});
const _react = require("@griffel/react");
const virtualizerClassName = 'fui-Virtualizer';
const virtualizerClassNames = {
before: `${virtualizerClassName}__before`,
beforeContainer: `${virtualizerClassName}__beforeContainer`,
after: `${virtualizerClassName}__after`,
afterContainer: `${virtualizerClassName}__afterContainer`
};
const useStyles = /*#__PURE__*/ (0, _react.__styles)({
base: {
mc9l5x: "ftgm304",
Bkecrkj: "f1aehjj5"
},
relative: {
qhf8xq: "f10pi13n"
},
horizontal: {
sshi5w: "fan4evk"
},
vertical: {
Bf4jedk: "f11qra4b"
}
}, {
d: [
".ftgm304{display:block;}",
".f1aehjj5{pointer-events:none;}",
".f10pi13n{position:relative;}",
".fan4evk{min-height:100%;}",
".f11qra4b{min-width:100%;}"
]
});
const useVirtualizerStyles_unstable = (state)=>{
'use no memo';
const styles = useStyles();
const { reversed, axis, beforeBufferHeight, afterBufferHeight, bufferSize } = state;
const horizontal = axis === 'horizontal';
state.before.className = (0, _react.mergeClasses)(virtualizerClassNames.before, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.before.className);
state.after.className = (0, _react.mergeClasses)(virtualizerClassNames.after, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.after.className);
state.beforeContainer.className = (0, _react.mergeClasses)(virtualizerClassNames.beforeContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.beforeContainer.className);
state.afterContainer.className = (0, _react.mergeClasses)(virtualizerClassNames.afterContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.afterContainer.className);
const beforeHeightPx = beforeBufferHeight + 'px';
const afterHeightPx = afterBufferHeight + 'px';
const beforeBufferHeightPx = beforeBufferHeight + bufferSize + 'px';
const afterBufferHeightPx = afterBufferHeight + bufferSize + 'px';
const bufferPx = bufferSize + 'px';
const beforeBuffer = {
// Column
...!reversed && !horizontal && {
marginBottom: `-${bufferPx}`
},
// Column-Reverse
...reversed && !horizontal && {
marginTop: `-${bufferPx}`
},
// Row
...!reversed && horizontal && {
marginRight: `-${bufferPx}`
},
// Row-Reverse
...reversed && horizontal && {
marginLeft: `-${bufferPx}`
}
};
const afterBuffer = {
// Column
...!reversed && !horizontal && {
marginTop: `-${bufferPx}`
},
// Column-Reverse
...reversed && !horizontal && {
marginBottom: `-${bufferPx}`
},
// Row
...!reversed && horizontal && {
marginLeft: `-${bufferPx}`
},
// Row-Reverse
...reversed && horizontal && {
marginRight: `-${bufferPx}`
}
};
state.before.style = {
height: horizontal ? '100%' : beforeBufferHeightPx,
width: horizontal ? beforeBufferHeightPx : '100%',
...beforeBuffer,
...state.before.style
};
state.beforeContainer.style = {
height: horizontal ? 'auto' : beforeHeightPx,
width: horizontal ? beforeHeightPx : 'auto',
...state.beforeContainer.style
};
state.after.style = {
height: horizontal ? '100%' : afterBufferHeightPx,
width: horizontal ? afterBufferHeightPx : '100%',
...afterBuffer,
...state.after.style
};
state.afterContainer.style = {
height: horizontal ? 'auto' : afterHeightPx,
width: horizontal ? afterHeightPx : 'auto',
...state.afterContainer.style
};
return state;
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,116 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
useVirtualizerStyles_unstable: function() {
return useVirtualizerStyles_unstable;
},
virtualizerClassNames: function() {
return virtualizerClassNames;
}
});
const _react = require("@griffel/react");
const virtualizerClassName = 'fui-Virtualizer';
const virtualizerClassNames = {
before: `${virtualizerClassName}__before`,
beforeContainer: `${virtualizerClassName}__beforeContainer`,
after: `${virtualizerClassName}__after`,
afterContainer: `${virtualizerClassName}__afterContainer`
};
const useStyles = (0, _react.makeStyles)({
base: {
display: 'block',
pointerEvents: 'none'
},
relative: {
position: 'relative'
},
horizontal: {
minHeight: '100%'
},
vertical: {
minWidth: '100%'
}
});
const useVirtualizerStyles_unstable = (state)=>{
'use no memo';
const styles = useStyles();
const { reversed, axis, beforeBufferHeight, afterBufferHeight, bufferSize } = state;
const horizontal = axis === 'horizontal';
state.before.className = (0, _react.mergeClasses)(virtualizerClassNames.before, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.before.className);
state.after.className = (0, _react.mergeClasses)(virtualizerClassNames.after, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.after.className);
state.beforeContainer.className = (0, _react.mergeClasses)(virtualizerClassNames.beforeContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.beforeContainer.className);
state.afterContainer.className = (0, _react.mergeClasses)(virtualizerClassNames.afterContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.afterContainer.className);
const beforeHeightPx = beforeBufferHeight + 'px';
const afterHeightPx = afterBufferHeight + 'px';
const beforeBufferHeightPx = beforeBufferHeight + bufferSize + 'px';
const afterBufferHeightPx = afterBufferHeight + bufferSize + 'px';
const bufferPx = bufferSize + 'px';
const beforeBuffer = {
// Column
...!reversed && !horizontal && {
marginBottom: `-${bufferPx}`
},
// Column-Reverse
...reversed && !horizontal && {
marginTop: `-${bufferPx}`
},
// Row
...!reversed && horizontal && {
marginRight: `-${bufferPx}`
},
// Row-Reverse
...reversed && horizontal && {
marginLeft: `-${bufferPx}`
}
};
const afterBuffer = {
// Column
...!reversed && !horizontal && {
marginTop: `-${bufferPx}`
},
// Column-Reverse
...reversed && !horizontal && {
marginBottom: `-${bufferPx}`
},
// Row
...!reversed && horizontal && {
marginLeft: `-${bufferPx}`
},
// Row-Reverse
...reversed && horizontal && {
marginRight: `-${bufferPx}`
}
};
state.before.style = {
height: horizontal ? '100%' : beforeBufferHeightPx,
width: horizontal ? beforeBufferHeightPx : '100%',
...beforeBuffer,
...state.before.style
};
state.beforeContainer.style = {
height: horizontal ? 'auto' : beforeHeightPx,
width: horizontal ? beforeHeightPx : 'auto',
...state.beforeContainer.style
};
state.after.style = {
height: horizontal ? '100%' : afterBufferHeightPx,
width: horizontal ? afterBufferHeightPx : '100%',
...afterBuffer,
...state.after.style
};
state.afterContainer.style = {
height: horizontal ? 'auto' : afterHeightPx,
width: horizontal ? afterHeightPx : 'auto',
...state.afterContainer.style
};
return state;
};

File diff suppressed because one or more lines are too long