Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Virtualizer #25451

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ packages/react-components/react-avatar-context @microsoft/teams-prg
packages/react-components/react-infobutton @microsoft/cxe-red @sopranopillow
packages/react-migration-v8-v9 @microsoft/cxe-coastal @geoffcoxmsft
packages/react-components/react-tree @microsoft/teams-prg
packages/react-components/react-virtualizer @microsoft/xc-uxe @Mitch-At-Work
packages/react-components/react-skeleton @microsoft/cxe-red
packages/tokens @microsoft/teams-prg
packages/react-components/react-tags @microsoft/cxe-coastal @TristanWatanabe
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "feat: Export 'Virtualizer' as unstable",
"packageName": "@fluentui/react-components",
"email": "mifraser@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "feat: Initial unstable release of the Virtualizer",
"packageName": "@fluentui/react-virtualizer",
"email": "mifraser@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ import { renderTableHeader_unstable } from '@fluentui/react-table';
import { renderTableHeaderCell_unstable } from '@fluentui/react-table';
import { renderTableRow_unstable } from '@fluentui/react-table';
import { renderTableSelectionCell_unstable } from '@fluentui/react-table';
import { renderVirtualizer_unstable } from '@fluentui/react-virtualizer';
import { Select } from '@fluentui/react-select';
import { selectClassNames } from '@fluentui/react-select';
import { SelectField_unstable as SelectField } from '@fluentui/react-select';
Expand Down Expand Up @@ -283,6 +284,7 @@ import { useField_unstable } from '@fluentui/react-field';
import { useFieldStyles_unstable } from '@fluentui/react-field';
import { useInfoButton_unstable } from '@fluentui/react-infobutton';
import { useInfoButtonStyles_unstable } from '@fluentui/react-infobutton';
import { useIntersectionObserver } from '@fluentui/react-virtualizer';
import { useListbox_unstable } from '@fluentui/react-combobox';
import { useListboxContextValues } from '@fluentui/react-combobox';
import { useListboxStyles_unstable } from '@fluentui/react-combobox';
Expand Down Expand Up @@ -318,6 +320,14 @@ import { useTableSelectionCell_unstable } from '@fluentui/react-table';
import { useTableSelectionCellStyles_unstable } from '@fluentui/react-table';
import { useTableSort } from '@fluentui/react-table';
import { useTableStyles_unstable } from '@fluentui/react-table';
import { useVirtualizer_unstable } from '@fluentui/react-virtualizer';
import { useVirtualizerStyles_unstable } from '@fluentui/react-virtualizer';
import { Virtualizer } from '@fluentui/react-virtualizer';
import { VirtualizerChildRenderFunction } from '@fluentui/react-virtualizer';
import { virtualizerClassNames } from '@fluentui/react-virtualizer';
import { VirtualizerProps } from '@fluentui/react-virtualizer';
import { VirtualizerSlots } from '@fluentui/react-virtualizer';
import { VirtualizerState } from '@fluentui/react-virtualizer';

export { Alert }

Expand Down Expand Up @@ -643,6 +653,8 @@ export { renderTableRow_unstable }

export { renderTableSelectionCell_unstable }

export { renderVirtualizer_unstable }

export { Select }

export { selectClassNames }
Expand Down Expand Up @@ -877,6 +889,8 @@ export { useInfoButton_unstable }

export { useInfoButtonStyles_unstable }

export { useIntersectionObserver }

export { useListbox_unstable }

export { useListboxContextValues }
Expand Down Expand Up @@ -947,6 +961,22 @@ export { useTableSort }

export { useTableStyles_unstable }

export { useVirtualizer_unstable }

export { useVirtualizerStyles_unstable }

export { Virtualizer }

export { VirtualizerChildRenderFunction }

export { virtualizerClassNames }

export { VirtualizerProps }

export { VirtualizerSlots }

export { VirtualizerState }

// (No @packageDocumentation comment for this package)

```
1 change: 1 addition & 0 deletions packages/react-components/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@fluentui/react-tooltip": "^9.1.9",
"@fluentui/react-utilities": "^9.4.0",
"@fluentui/react-text": "^9.1.13",
"@fluentui/react-virtualizer": "9.0.0-alpha.0",
"@griffel/react": "^1.5.2",
"tslib": "^2.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,18 @@ export {
useProgressBar_unstable,
} from '@fluentui/react-progress';
export type { ProgressBarProps, ProgressBarState, ProgressBarSlots } from '@fluentui/react-progress';

export {
Virtualizer,
virtualizerClassNames,
useVirtualizer_unstable,
renderVirtualizer_unstable,
useVirtualizerStyles_unstable,
useIntersectionObserver,
} from '@fluentui/react-virtualizer';
export type {
VirtualizerProps,
VirtualizerState,
VirtualizerSlots,
VirtualizerChildRenderFunction,
} from '@fluentui/react-virtualizer';
4 changes: 4 additions & 0 deletions packages/react-components/react-virtualizer/.babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@griffel"],
"plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"]
}
4 changes: 4 additions & 0 deletions packages/react-components/react-virtualizer/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["plugin:@fluentui/eslint-plugin/react"],
"root": true
}
30 changes: 30 additions & 0 deletions packages/react-components/react-virtualizer/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.storybook/
.vscode/
bundle-size/
config/
coverage/
docs/
etc/
node_modules/
src/
stories/
dist/types/
temp/
__fixtures__
__mocks__
__tests__

*.api.json
*.log
*.spec.*
*.cy.*
*.test.*
*.yml

# config files
*config.*
*rc.*
.editorconfig
.eslint*
.git*
.prettierignore
14 changes: 14 additions & 0 deletions packages/react-components/react-virtualizer/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const rootMain = require('../../../../.storybook/main');

module.exports = /** @type {Omit<import('../../../../.storybook/main'), 'typescript'|'babel'>} */ ({
...rootMain,
stories: [...rootMain.stories, '../stories/**/*.stories.mdx', '../stories/**/index.stories.@(ts|tsx)'],
addons: [...rootMain.addons],
webpackFinal: (config, options) => {
const localConfig = { ...rootMain.webpackFinal(config, options) };

// add your own webpack tweaks if needed

return localConfig;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as rootPreview from '../../../../.storybook/preview';

/** @type {typeof rootPreview.decorators} */
export const decorators = [...rootPreview.decorators];

/** @type {typeof rootPreview.parameters} */
export const parameters = { ...rootPreview.parameters };
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "",
"allowJs": true,
"checkJs": true,
"types": ["static-assets", "environment", "storybook__addons"]
},
"include": ["../stories/**/*.stories.ts", "../stories/**/*.stories.tsx", "*.js"]
}
15 changes: 15 additions & 0 deletions packages/react-components/react-virtualizer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@fluentui/react-virtualizer

Copyright (c) Microsoft Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
5 changes: 5 additions & 0 deletions packages/react-components/react-virtualizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @fluentui/react-virtualizer

**Virtualizer components for [Fluent UI React](https://react.fluentui.dev/)**

These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@fluentui/scripts-api-extractor/api-extractor.common.v-next.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Jest test setup file. */
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
## API Report File for "@fluentui/react-virtualizer"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { Dispatch } from 'react';
import type { FC } from 'react';
import type { MutableRefObject } from 'react';
import * as React_2 from 'react';
import type { SetStateAction } from 'react';
import type { Slot } from '@fluentui/react-utilities';
import type { SlotClassNames } from '@fluentui/react-utilities';

// @public (undocumented)
export const renderVirtualizer_unstable: (state: VirtualizerState) => JSX.Element;

// @public
export const useIntersectionObserver: (callback: IntersectionObserverCallback, options?: IntersectionObserverInit | undefined) => {
setObserverList: Dispatch<SetStateAction<Element[] | undefined>>;
setObserverInit: Dispatch<SetStateAction<IntersectionObserverInit | undefined>>;
observer: MutableRefObject<IntersectionObserver | undefined>;
};

// @public (undocumented)
export function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState;

// @public
export const useVirtualizerStyles_unstable: (state: VirtualizerState) => VirtualizerState;

// @public
export const Virtualizer: FC<VirtualizerProps>;

// @public (undocumented)
export type VirtualizerChildRenderFunction = (index: number) => React_2.ReactNode;

// @public (undocumented)
export const virtualizerClassNames: SlotClassNames<VirtualizerSlots>;

// @public (undocumented)
export type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & {
children: VirtualizerChildRenderFunction;
itemSize: number;
numItems: number;
virtualizerLength: number;
bufferItems?: number;
bufferSize?: number;
intersectionObserverRoot?: React_2.MutableRefObject<HTMLElement | null>;
axis?: 'vertical' | 'horizontal';
reversed?: boolean;
getItemSize?: (index: number) => number;
onUpdateIndex?: (index: number, prevIndex: number) => void;
onCalculateIndex?: (newIndex: number) => number;
};

// @public (undocumented)
export type VirtualizerSlots = {
before: NonNullable<Slot<'div', 'td'>>;
beforeContainer: NonNullable<Slot<'div', 'tr'>>;
after: NonNullable<Slot<'div', 'td'>>;
afterContainer: NonNullable<Slot<'div', 'tr'>>;
};

// @public (undocumented)
export type VirtualizerState = ComponentState<VirtualizerSlots> & {
virtualizedChildren: React_2.ReactNode[];
virtualizerStartIndex: number;
afterBufferHeight: number;
beforeBufferHeight: number;
totalVirtualizerHeight: number;
axis?: 'vertical' | 'horizontal';
reversed?: boolean;
bufferSize: number;
};

// (No @packageDocumentation comment for this package)

```
21 changes: 21 additions & 0 deletions packages/react-components/react-virtualizer/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check

/**
* @type {import('@jest/types').Config.InitialOptions}
*/
module.exports = {
displayName: 'virtualizer',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
snapshotSerializers: ['@griffel/jest-serializer'],
};
3 changes: 3 additions & 0 deletions packages/react-components/react-virtualizer/just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { preset } from '@fluentui/scripts-tasks';

preset();
59 changes: 59 additions & 0 deletions packages/react-components/react-virtualizer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@fluentui/react-virtualizer",
"version": "9.0.0-alpha.0",
"description": "Generic and composable virtualizer framework built on browser intersection observer",
"main": "lib-commonjs/index.js",
"module": "lib/index.js",
"typings": "./dist/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui"
},
"license": "MIT",
"scripts": {
"build": "just-scripts build",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"just": "just-scripts",
"lint": "just-scripts lint",
"test": "jest --passWithNoTests",
"storybook": "start-storybook",
"start": "yarn storybook",
"generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor",
"type-check": "tsc -b tsconfig.json"
},
"devDependencies": {
"@fluentui/eslint-plugin": "*",
"@fluentui/react-conformance": "*",
"@fluentui/react-conformance-griffel": "9.0.0-beta.19",
"@fluentui/scripts-api-extractor": "*",
"@fluentui/scripts-tasks": "*"
},
"dependencies": {
"@fluentui/react-utilities": "^9.4.0",
"@griffel/react": "^1.5.2",
"tslib": "^2.1.0"
},
"peerDependencies": {
"@types/react": ">=16.8.0 <18.0.0",
"@types/react-dom": ">=16.8.0 <18.0.0",
"react": ">=16.8.0 <18.0.0",
"react-dom": ">=16.8.0 <18.0.0"
Comment on lines +39 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be up to 19.0.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Causing this bug #26859

},
"beachball": {
"disallowedChangeTypes": [
"major",
"minor",
"patch"
]
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./lib/index.js",
"require": "./lib-commonjs/index.js"
},
"./package.json": "./package.json"
}
}
1 change: 1 addition & 0 deletions packages/react-components/react-virtualizer/src/Hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './hooks/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Virtualizer/index';
Loading