-
Notifications
You must be signed in to change notification settings - Fork 50
feat(react-virtualizer): migrate package from fluentui core repo #441
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66e2dfb
Migrate react-virtualizer into contrib repo
Mitch-At-Work 5f90459
Fix test
Mitch-At-Work 4547042
Fix dep conflicts
Mitch-At-Work e415a2d
Update yarn lock
Mitch-At-Work 0a775f0
Update readme
Mitch-At-Work c87ecd6
Fix if statement
Mitch-At-Work 5da1460
Format react-virtualizer to match contrib lint settings
Mitch-At-Work e854508
Fix up linter after formatting
Mitch-At-Work File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": "../../babel.config.json" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import type { StorybookConfig } from '@storybook/react-webpack5'; | ||
|
|
||
| // eslint-disable-next-line @nx/enforce-module-boundaries | ||
| import rootConfig from '../../../.storybook/main'; | ||
|
|
||
| const config: StorybookConfig = { | ||
| ...rootConfig, | ||
| stories: ['../stories/**/index.stories.@(js|jsx|ts|tsx|mdx)'], | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { Preview } from '@storybook/react'; | ||
|
|
||
| // eslint-disable-next-line @nx/enforce-module-boundaries | ||
| import rootPreview from '../../../.storybook/preview'; | ||
|
|
||
| const preview: Preview = { | ||
| ...rootPreview, | ||
| }; | ||
|
|
||
| export default preview; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "extends": "../tsconfig.json", | ||
| "compilerOptions": { | ||
| "emitDecoratorMetadata": true, | ||
| "outDir": "" | ||
| }, | ||
| "files": [ | ||
| "../../../node_modules/@nx/react/typings/styled-jsx.d.ts", | ||
| "../../../node_modules/@nx/react/typings/cssmodule.d.ts", | ||
| "../../../node_modules/@nx/react/typings/image.d.ts" | ||
| ], | ||
| "exclude": [ | ||
| "../**/*.spec.ts", | ||
| "../**/*.spec.js", | ||
| "../**/*.spec.tsx", | ||
| "../**/*.spec.jsx" | ||
| ], | ||
| "include": [ | ||
| "../stories/**/*.stories.ts", | ||
| "../stories/**/*.stories.js", | ||
| "../stories/**/*.stories.jsx", | ||
| "../stories/**/*.stories.tsx", | ||
| "../stories/**/*.stories.mdx", | ||
| "*.ts", | ||
| "*.js" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "jsc": { | ||
| "target": "es2019", | ||
| "parser": { | ||
| "syntax": "typescript", | ||
| "tsx": true, | ||
| "decorators": false, | ||
| "dynamicImport": false | ||
| }, | ||
| "transform": { | ||
| "react": { | ||
| "runtime": "classic", | ||
| "useSpread": true | ||
| } | ||
| }, | ||
| "keepClassNames": true, | ||
| "externalHelpers": true, | ||
| "loose": true | ||
| }, | ||
| "sourceMaps": true, | ||
| "exclude": [ | ||
| "jest.config.ts", | ||
| ".*\\.spec.tsx?$", | ||
| ".*\\.test.tsx?$", | ||
| "./src/jest-setup.ts$", | ||
| "./**/jest-setup.ts$", | ||
| ".*.js$" | ||
| ], | ||
| "$schema": "https://json.schemastore.org/swcrc" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # react-virtualizer | ||
|
|
||
| This library was generated with [Nx](https://nx.dev). | ||
|
|
||
| ## Building | ||
|
|
||
| Run `nx build react-virtualizer` to build the library. | ||
|
|
||
| ## Running unit tests | ||
|
|
||
| Run `nx test react-virtualizer` to execute the unit tests via [Jest](https://jestjs.io). | ||
|
|
||
| ## Dependency | ||
|
|
||
| When taking @fluentui/react-contributor as a dependency, we recommend using the latest patch version i.e. "@fluentui-contrib/react-virtualizer": "~0.0.1". | ||
| This is due to major version bumps being reserved for future stable releases or major API changes, while minor versioning may contain smaller API modifications. | ||
|
|
||
| ## Description | ||
|
|
||
| React-virtualizer is a new approach to virtualization that uses IntersectionObserver to enable scroll detection. | ||
|
|
||
| The core benefit of this method, is that the virtualization itself is disconnected from both a scroll container, and any JS loop detection, to increase flexibility and react performance. | ||
|
|
||
| This enables virtualization in the top level HTML page body, as well as multiple virtualized lists in a single scroll view. | ||
|
|
||
| ## Usage | ||
|
|
||
| It is recommended to use the ScrollView versions of this virtualizer for simple virtualization scenarios, as it simplifies the encapsulation of virtualizer hooks and provides access to internal variables via context. | ||
|
|
||
| If more complex virtualization is needed, a variety of static/dynamic hooks has been provided to configure virtualizer variants, be sure to take a look at the base virtualizer stories to see core implementation, or implement the hooks similar to the internal usage of VirtualizerScrollView/VirtualizerScrollViewDynamic. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| const baseConfig = require('../../eslint.config.js'); | ||
|
|
||
| module.exports = [ | ||
| ...baseConfig, | ||
| { | ||
| files: ['**/*.json'], | ||
| rules: { | ||
| '@nx/dependency-checks': [ | ||
| 'error', | ||
| { | ||
| ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'], | ||
| }, | ||
| ], | ||
| }, | ||
| languageOptions: { | ||
| parser: require('jsonc-eslint-parser'), | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const baseConfig = require('../../eslint.config.js'); | ||
|
|
||
| module.exports = [ | ||
| ...baseConfig, | ||
| { | ||
| files: ['**/*.ts', '**/*.tsx'], | ||
| // Override or add rules here | ||
| rules: {}, | ||
| }, | ||
| { | ||
| files: ['**/*.js', '**/*.jsx'], | ||
| // Override or add rules here | ||
| rules: {}, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* eslint-disable */ | ||
| import { readFileSync } from 'fs'; | ||
|
|
||
| // Reading the SWC compilation config and remove the "exclude" | ||
| // for the test files to be compiled by SWC | ||
| const { exclude: _, ...swcJestConfig } = JSON.parse( | ||
| readFileSync(`${__dirname}/.swcrc`, 'utf-8') | ||
| ); | ||
|
|
||
| // disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. | ||
| // If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" | ||
| if (swcJestConfig.swcrc === undefined) { | ||
| swcJestConfig.swcrc = false; | ||
| } | ||
|
|
||
| // Uncomment if using global setup/teardown files being transformed via swc | ||
| // https://nx.dev/nx-api/jest/documents/overview#global-setupteardown-with-nx-libraries | ||
| // jest needs EsModule Interop to find the default exported setup/teardown functions | ||
| // swcJestConfig.module.noInterop = false; | ||
|
|
||
| export default { | ||
| displayName: 'react-virtualizer', | ||
| preset: '../../jest.preset.js', | ||
| transform: { | ||
| '^.+\\.[tj]s$': ['@swc/jest', swcJestConfig], | ||
| }, | ||
| moduleFileExtensions: ['ts', 'js', 'html'], | ||
| testEnvironment: 'jsdom', | ||
| coverageDirectory: '../../coverage/packages/react-virtualizer', | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "@fluentui-contrib/react-virtualizer", | ||
| "version": "0.0.1", | ||
| "private": true, | ||
| "main": "./src/index.js", | ||
| "types": "./src/index.d.ts", | ||
| "devDependencies": { | ||
| "jsonc-eslint-parser": "2.4.0", | ||
| "@testing-library/react": "16.3.0" | ||
| }, | ||
| "dependencies": { | ||
| "@fluentui/react-utilities": "^9.16.0", | ||
| "@griffel/react": "^1.5.14", | ||
| "@swc/helpers": "~0.5.11", | ||
| "jsonc-eslint-parser": "2.4.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "@fluentui/react-shared-contexts": ">=9.7.2 <10.0.0", | ||
| "@types/react": ">=16.8.0 <19.0.0", | ||
| "@types/react-dom": ">=16.9.0 <19.0.0", | ||
| "react": ">=16.8.0 <19.0.0", | ||
| "react-dom": ">=16.8.0 <19.0.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { defineConfig, devices } from '@playwright/experimental-ct-react'; | ||
|
|
||
| /** | ||
| * Read environment variables from file. | ||
| * https://github.com/motdotla/dotenv | ||
| */ | ||
| // require('dotenv').config(); | ||
|
|
||
| /** | ||
| * See https://playwright.dev/docs/test-configuration. | ||
| */ | ||
| export default defineConfig({ | ||
| testDir: './src', | ||
| /* Glob patterns or regular expressions that match test files. */ | ||
| testMatch: '**/*.component-browser-@(spec|test).tsx', | ||
| /* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */ | ||
| snapshotDir: './__snapshots__', | ||
| /* Maximum time one test can run for. */ | ||
| timeout: 10 * 1000, | ||
| /* Run tests in files in parallel */ | ||
| fullyParallel: true, | ||
| /* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
| forbidOnly: !!process.env.CI, | ||
| /* Retry on CI only */ | ||
| retries: process.env.CI ? 2 : 0, | ||
| /* Opt out of parallel tests on CI. */ | ||
| workers: process.env.CI ? 1 : undefined, | ||
| /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
| reporter: 'list', | ||
| /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
| use: { | ||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry', | ||
|
|
||
| /* Port to use for Playwright component endpoint. */ | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| ctPort: 3100 + Number(require('./package.json').name.length), | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| { | ||
| name: 'firefox', | ||
| use: { ...devices['Desktop Firefox'] }, | ||
| }, | ||
| { | ||
| name: 'webkit', | ||
| use: { ...devices['Desktop Safari'] }, | ||
| }, | ||
| ], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Testing Page</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="./index.tsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // Import styles, initialize component theme here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| "name": "react-virtualizer", | ||
| "$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
| "sourceRoot": "packages/react-virtualizer/src", | ||
| "projectType": "library", | ||
| "tags": [], | ||
| "targets": { | ||
| "build": { | ||
| "executor": "@fluentui-contrib/nx-plugin:build" | ||
| }, | ||
| "lint": { | ||
| "executor": "@nx/eslint:lint", | ||
| "options": { | ||
| "lintFilePatterns": [ | ||
| "packages/react-virtualizer/**/*.ts", | ||
| "packages/react-virtualizer/**/*.tsx" | ||
| ] | ||
| } | ||
| }, | ||
| "test": { | ||
| "executor": "@nx/jest:jest", | ||
| "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
| "options": { | ||
| "jestConfig": "packages/react-virtualizer/jest.config.ts", | ||
| "passWithNoTests": true | ||
| } | ||
| }, | ||
| "type-check": { | ||
| "executor": "@fluentui-contrib/nx-plugin:type-check" | ||
| }, | ||
| "storybook": { | ||
| "executor": "@nx/storybook:storybook", | ||
| "options": { | ||
| "port": 4400, | ||
| "configDir": "packages/react-virtualizer/.storybook" | ||
| }, | ||
| "configurations": { | ||
| "ci": { | ||
| "quiet": true | ||
| } | ||
| } | ||
| }, | ||
| "build-storybook": { | ||
| "executor": "@nx/storybook:build", | ||
| "outputs": ["{options.outputDir}"], | ||
| "options": { | ||
| "outputDir": "dist/storybook/react-virtualizer", | ||
| "configDir": "packages/react-virtualizer/.storybook" | ||
| }, | ||
| "configurations": { | ||
| "ci": { | ||
| "quiet": true | ||
| } | ||
| } | ||
| }, | ||
| "component-test": { | ||
| "executor": "@fluentui-contrib/nx-plugin:playwright", | ||
| "options": { | ||
| "testingType": "component", | ||
| "output": "{workspaceRoot}/dist/.playwright/packages/react-virtualizer", | ||
| "config": "packages/react-virtualizer/playwright.config.ts" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export type { | ||
| IndexedResizeCallbackElement, | ||
| ResizeCallbackWithRef, | ||
| VirtualizerDynamicPaginationProps, | ||
| VirtualizerMeasureDynamicProps, | ||
| VirtualizerMeasureProps, | ||
| VirtualizerStaticPaginationProps, | ||
| } from './hooks/index'; | ||
| export { | ||
| createResizeObserverFromDocument, | ||
| getRTLRootMargin, | ||
| useDynamicVirtualizerMeasure, | ||
| useIntersectionObserver, | ||
| useMeasureList, | ||
| useResizeObserverRef_unstable, | ||
| useStaticVirtualizerMeasure, | ||
| } from './hooks/index'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export type { | ||
| DynamicVirtualizerContextProps, | ||
| ScrollToInterface, | ||
| ScrollToItemDynamicParams, | ||
| ScrollToItemStaticParams, | ||
| VirtualizerContextProps, | ||
| } from './utilities/index'; | ||
| export { | ||
| VirtualizerContextProvider, | ||
| scrollToItemDynamic, | ||
| scrollToItemStatic, | ||
| useVirtualizerContextState_unstable, | ||
| useVirtualizerContext_unstable, | ||
| } from './utilities/index'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets start with
"private": trueand make public once ready for release