Skip to content

Commit

Permalink
chore(react-tree-grid): scaffold package (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsunderhus authored Jan 16, 2024
1 parent 02945ea commit 52d7ca4
Show file tree
Hide file tree
Showing 26 changed files with 1,128 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/react-tree-grid/.eslintrc.json
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"
}
}
]
}
30 changes: 30 additions & 0 deletions packages/react-tree-grid/.storybook/main.ts
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
17 changes: 17 additions & 0 deletions packages/react-tree-grid/.storybook/preview.tsx
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;
28 changes: 28 additions & 0 deletions packages/react-tree-grid/.storybook/tsconfig.json
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"
]
}
31 changes: 31 additions & 0 deletions packages/react-tree-grid/.swcrc
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"
}
11 changes: 11 additions & 0 deletions packages/react-tree-grid/README.md
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).
29 changes: 29 additions & 0 deletions packages/react-tree-grid/jest.config.ts
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',
};
16 changes: 16 additions & 0 deletions packages/react-tree-grid/package.json
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"
}
}
68 changes: 68 additions & 0 deletions packages/react-tree-grid/project.json
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 packages/react-tree-grid/src/components/TreeGrid/TreeGrid.tsx
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)}
/>
);
}
);
1 change: 1 addition & 0 deletions packages/react-tree-grid/src/components/TreeGrid/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TreeGrid';
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)}
/>
);
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TreeGridCell';
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)}
/>
);
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TreeGridRow';
3 changes: 3 additions & 0 deletions packages/react-tree-grid/src/index.ts
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';
Loading

0 comments on commit 52d7ca4

Please sign in to comment.