-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(react-tree-grid): scaffold package (#63)
- Loading branch information
1 parent
02945ea
commit 52d7ca4
Showing
26 changed files
with
1,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["stories/**/*.tsx", "stories/**/*.ts"], | ||
"rules": { | ||
"@nx/enforce-module-boundaries": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains 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 @@ | ||
import type { StorybookConfig } from '@storybook/react-webpack5'; | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../stories/**/index.stories.@(js|jsx|ts|tsx|mdx)'], | ||
addons: [ | ||
'@nx/react/plugins/storybook', | ||
{ | ||
name: '@storybook/addon-storysource', | ||
options: { | ||
loaderOptions: { | ||
injectStoryParameters: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {}, | ||
}, | ||
core: { | ||
builder: '@storybook/builder-webpack5', | ||
disableTelemetry: true, | ||
}, | ||
}; | ||
|
||
export default config; | ||
|
||
// To customize your webpack configuration you can use the webpackFinal field. | ||
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config | ||
// and https://nx.dev/packages/storybook/documents/custom-builder-configs |
This file contains 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 @@ | ||
import * as React from 'react'; | ||
|
||
import { Preview } from '@storybook/react'; | ||
|
||
import { FluentProvider, webLightTheme } from '@fluentui/react-components'; | ||
|
||
const preview: Preview = { | ||
decorators: [ | ||
(Story) => ( | ||
<FluentProvider theme={webLightTheme}> | ||
<Story /> | ||
</FluentProvider> | ||
), | ||
], | ||
}; | ||
|
||
export default preview; |
This file contains 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,28 @@ | ||
{ | ||
"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", | ||
"../stories/VariantB.stories.tsx" | ||
] | ||
} |
This file contains 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,31 @@ | ||
{ | ||
"jsc": { | ||
"target": "es2019", | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true, | ||
"decorators": false, | ||
"dynamicImport": false | ||
}, | ||
"transform": { | ||
"react": { | ||
"runtime": "automatic", | ||
"importSource": "@fluentui/react-jsx-runtime", | ||
"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 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 @@ | ||
# react-tree-grid | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build react-tree-grid` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test react-tree-grid` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains 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,29 @@ | ||
/* 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/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries | ||
// jest needs EsModule Interop to find the default exported setup/teardown functions | ||
// swcJestConfig.module.noInterop = false; | ||
|
||
export default { | ||
displayName: 'button', | ||
preset: '../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]sx?$': ['@swc/jest', swcJestConfig], | ||
}, | ||
moduleFileExtensions: ['js', 'ts', 'tsx', 'html'], | ||
coverageDirectory: '../../coverage/packages/button', | ||
}; |
This file contains 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,16 @@ | ||
{ | ||
"name": "@fluentui-contrib/react-tree-grid", | ||
"version": "0.0.1", | ||
"private": true, | ||
"peerDependencies": { | ||
"@fluentui/react-components": ">=9.35.1 < 10.0.0", | ||
"@fluentui/react-shared-contexts": ">=9.7.2 <10.0.0", | ||
"@fluentui/keyboard-keys": ">=9.0.6 < 10.0.0", | ||
"@fluentui/react-tabster": ">=9.14.0 < 10.0.0", | ||
"@fluentui/react-utilities": ">=9.15.1 < 10.0.0", | ||
"@types/react": ">=16.8.0 <19.0.0", | ||
"@types/react-dom": ">=16.8.0 <19.0.0", | ||
"react": ">=16.8.0 <19.0.0", | ||
"react-dom": ">=16.8.0 <19.0.0" | ||
} | ||
} |
This file contains 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,68 @@ | ||
{ | ||
"name": "react-tree-grid", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/react-tree-grid/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@fluentui-contrib/nx-plugin:build" | ||
}, | ||
"publish": { | ||
"command": "node tools/scripts/publish.mjs react-tree-grid {args.ver} {args.tag}", | ||
"dependsOn": ["build"] | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"packages/react-tree-grid/**/*.ts", | ||
"packages/react-tree-grid/**/*.tsx" | ||
] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "packages/react-tree-grid/jest.config.ts", | ||
"passWithNoTests": true | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"ci": true, | ||
"codeCoverage": true | ||
} | ||
} | ||
}, | ||
"type-check": { | ||
"executor": "@fluentui-contrib/nx-plugin:type-check" | ||
}, | ||
"storybook": { | ||
"executor": "@nx/storybook:storybook", | ||
"options": { | ||
"port": 4400, | ||
"configDir": "packages/react-tree-grid/.storybook" | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"quiet": true | ||
} | ||
} | ||
}, | ||
"build-storybook": { | ||
"executor": "@nx/storybook:build", | ||
"outputs": ["{options.outputDir}"], | ||
"options": { | ||
"outputDir": "dist/storybook/react-tree-grid", | ||
"configDir": "packages/react-tree-grid/.storybook" | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"quiet": true | ||
} | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/react-tree-grid/src/components/TreeGrid/TreeGrid.tsx
This file contains 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,21 @@ | ||
import * as React from 'react'; | ||
import { makeResetStyles, mergeClasses } from '@fluentui/react-components'; | ||
|
||
export type TreeGridProps = JSX.IntrinsicElements['div']; | ||
|
||
const useStyles = makeResetStyles({ | ||
display: 'block', | ||
}); | ||
|
||
export const TreeGrid = React.forwardRef( | ||
(props: TreeGridProps, ref: React.ForwardedRef<HTMLDivElement>) => { | ||
const styles = useStyles(); | ||
return ( | ||
<div | ||
ref={ref} | ||
{...props} | ||
className={mergeClasses(styles, props.className)} | ||
/> | ||
); | ||
} | ||
); |
This file contains 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 @@ | ||
export * from './TreeGrid'; |
26 changes: 26 additions & 0 deletions
26
packages/react-tree-grid/src/components/TreeGridCell/TreeGridCell.tsx
This file contains 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,26 @@ | ||
import * as React from 'react'; | ||
import { | ||
mergeClasses, | ||
useTableCell_unstable, | ||
TableCellState, | ||
useTableCellStyles_unstable, | ||
} from '@fluentui/react-components'; | ||
|
||
export type TreeGridCellProps = JSX.IntrinsicElements['div']; | ||
|
||
export const TreeGridCell = React.forwardRef( | ||
(props: TreeGridCellProps, ref: React.ForwardedRef<HTMLDivElement>) => { | ||
const tableCellState: TableCellState = { | ||
...useTableCell_unstable({ as: 'div' }, ref), | ||
noNativeElements: true, | ||
}; | ||
useTableCellStyles_unstable(tableCellState); | ||
return ( | ||
<div | ||
ref={ref} | ||
{...props} | ||
className={mergeClasses(tableCellState.root.className, props.className)} | ||
/> | ||
); | ||
} | ||
); |
This file contains 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 @@ | ||
export * from './TreeGridCell'; |
26 changes: 26 additions & 0 deletions
26
packages/react-tree-grid/src/components/TreeGridRow/TreeGridRow.tsx
This file contains 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,26 @@ | ||
import * as React from 'react'; | ||
import { | ||
mergeClasses, | ||
useTableRowStyles_unstable, | ||
useTableRow_unstable, | ||
TableRowState, | ||
} from '@fluentui/react-components'; | ||
|
||
export type TreeGridRowProps = JSX.IntrinsicElements['div']; | ||
|
||
export const TreeGridRow = React.forwardRef( | ||
(props: TreeGridRowProps, ref: React.ForwardedRef<HTMLDivElement>) => { | ||
const tableRowState: TableRowState = { | ||
...useTableRow_unstable({ as: 'div' }, ref), | ||
noNativeElements: true, | ||
}; | ||
useTableRowStyles_unstable(tableRowState); | ||
return ( | ||
<div | ||
ref={ref} | ||
{...props} | ||
className={mergeClasses(tableRowState.root.className, props.className)} | ||
/> | ||
); | ||
} | ||
); |
This file contains 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 @@ | ||
export * from './TreeGridRow'; |
This file contains 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 @@ | ||
export * from './components/TreeGridCell'; | ||
export * from './components/TreeGridRow'; | ||
export * from './components/TreeGrid'; |
Oops, something went wrong.