-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generated react-dialog package (#20954)
* feat: generated react-dialog package * chore: run package migration * fix: radio-dialog conformance * docs: update react-dialog api docs
- Loading branch information
1 parent
4035bf3
commit 25864f8
Showing
39 changed files
with
562 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
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
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
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 @@ | ||
{ | ||
"plugins": ["module:@fluentui/babel-make-styles", "annotate-pure-calls", "@babel/transform-react-pure-annotations"] | ||
} |
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,4 @@ | ||
{ | ||
"extends": ["plugin:@fluentui/eslint-plugin/react"], | ||
"root": true | ||
} |
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 @@ | ||
.storybook/ | ||
.vscode/ | ||
bundle-size/ | ||
config/ | ||
coverage/ | ||
e2e/ | ||
etc/ | ||
node_modules/ | ||
src/ | ||
temp/ | ||
__fixtures__ | ||
__mocks__ | ||
__tests__ | ||
|
||
*.api.json | ||
*.log | ||
*.spec.* | ||
*.stories.* | ||
*.test.* | ||
*.yml | ||
|
||
# config files | ||
*config.* | ||
*rc.* | ||
.editorconfig | ||
.eslint* | ||
.git* | ||
.prettierignore |
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,14 @@ | ||
const rootMain = require('../../../.storybook/main'); | ||
|
||
module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript'|'babel'>} */ ({ | ||
...rootMain, | ||
stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'], | ||
addons: [...rootMain.addons], | ||
webpackFinal: (config, options) => { | ||
const localConfig = { ...rootMain.webpackFinal(config, options) }; | ||
|
||
// add your own webpack tweaks if needed | ||
|
||
return localConfig; | ||
}, | ||
}); |
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,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 }; |
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,10 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"types": ["static-assets", "environment", "inline-style-expand-shorthand", "storybook__addons"] | ||
}, | ||
"include": ["../src/**/*.stories.ts", "../src/**/*.stories.tsx", "*.js"] | ||
} |
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,15 @@ | ||
@fluentui/react-dialog | ||
|
||
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 |
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,5 @@ | ||
# @fluentui/react-dialog | ||
|
||
**React Dialog components for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)** | ||
|
||
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. |
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,63 @@ | ||
# @fluentui/react-dialog Spec | ||
|
||
## Background | ||
|
||
_Description and use cases of this component_ | ||
|
||
## Prior Art | ||
|
||
_Include background research done for this component_ | ||
|
||
- _Link to Open UI research_ | ||
- _Link to comparison of v7 and v0_ | ||
- _Link to GitHub epic issue for the converged component_ | ||
|
||
## Sample Code | ||
|
||
_Provide some representative example code that uses the proposed API for the component_ | ||
|
||
## Variants | ||
|
||
_Describe visual or functional variants of this control, if applicable. For example, a slider could have a 2D variant._ | ||
|
||
## API | ||
|
||
_List the **Props** and **Slots** proposed for the component. Ideally this would just be a link to the component's `.types.ts` file_ | ||
|
||
## Structure | ||
|
||
- _**Public**_ | ||
- _**Internal**_ | ||
- _**DOM** - how the component will be rendered as HTML elements_ | ||
|
||
## Migration | ||
|
||
_Describe what will need to be done to upgrade from the existing implementations:_ | ||
|
||
- _Migration from v8_ | ||
- _Migration from v0_ | ||
|
||
## Behaviors | ||
|
||
_Explain how the component will behave in use, including:_ | ||
|
||
- _Component States_ | ||
- _Interaction_ | ||
- _Keyboard_ | ||
- _Cursor_ | ||
- _Touch_ | ||
- _Screen readers_ | ||
|
||
## Accessibility | ||
|
||
Base accessibility information is included in the design document. After the spec is filled and review, outcomes from it need to be communicated to design and incorporated in the design document. | ||
|
||
- Decide whether to use **native element** or folow **ARIA** and provide reasons | ||
- Identify the **[ARIA](https://www.w3.org/TR/wai-aria-practices-1.2/) pattern** and, if the component is listed there, follow its specification as possible. | ||
- Identify accessibility **variants**, the `role` ([ARIA roles](https://www.w3.org/TR/wai-aria-1.1/#role_definitions)) of the component, its `slots` and `aria-*` props. | ||
- Describe the **keyboard navigation**: Tab Oder and Arrow Key Navigation. Describe any other keyboard **shortcuts** used | ||
- Specify texts for **state change announcements** - [ARIA live regions | ||
](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) (number of available items in dropdown, error messages, confirmations, ...) | ||
- Identify UI parts that appear on **hover or focus** and specify keyboard and screen reader interaction with them | ||
- List cases when **focus** needs to be **trapped** in sections of the UI (for dialogs and popups or for hierarchical navigation) | ||
- List cases when **focus** needs to be **moved programatically** (if parts of the UI are appearing/disappearing or other cases) |
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,4 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "@fluentui/scripts/api-extractor/api-extractor.common.json" | ||
} |
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,5 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "./api-extractor.json", | ||
"mainEntryPointFilePath": "<projectFolder>/dist/packages/<unscopedPackageName>/src/index.d.ts" | ||
} |
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,7 @@ | ||
/** Jest test setup file. */ | ||
|
||
const { configure } = require('enzyme'); | ||
const Adapter = require('enzyme-adapter-react-16'); | ||
|
||
// Configure enzyme. | ||
configure({ adapter: new Adapter() }); |
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,47 @@ | ||
## API Report File for "@fluentui/react-dialog" | ||
|
||
> 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 { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities'; | ||
import * as React_2 from 'react'; | ||
|
||
// @public | ||
export const Dialog: ForwardRefComponent<DialogProps>; | ||
|
||
// @public (undocumented) | ||
export const dialogClassName = "fui-Dialog"; | ||
|
||
// @public (undocumented) | ||
export type DialogCommons = {}; | ||
|
||
// @public | ||
export type DialogProps = ComponentProps<DialogSlots> & DialogCommons; | ||
|
||
// @public | ||
export const dialogShorthandProps: (keyof DialogSlots)[]; | ||
|
||
// @public (undocumented) | ||
export type DialogSlots = { | ||
root: IntrinsicShorthandProps<'div'>; | ||
}; | ||
|
||
// @public | ||
export type DialogState = ComponentState<DialogSlots> & DialogCommons; | ||
|
||
// @public | ||
export const renderDialog: (state: DialogState) => JSX.Element; | ||
|
||
// @public | ||
export const useDialog: (props: DialogProps, ref: React_2.Ref<HTMLElement>) => DialogState; | ||
|
||
// @public | ||
export const useDialogStyles: (state: DialogState) => DialogState; | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
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 @@ | ||
// @ts-check | ||
|
||
/** | ||
* @type {jest.InitialOptions} | ||
*/ | ||
module.exports = { | ||
displayName: 'react-dialog', | ||
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: ['@fluentui/jest-serializer-make-styles'], | ||
}; |
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 @@ | ||
import { preset } from '@fluentui/scripts'; | ||
|
||
preset(); |
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,64 @@ | ||
{ | ||
"name": "@fluentui/react-dialog", | ||
"version": "9.0.0-beta.5", | ||
"private": true, | ||
"description": "Dialog component for Fluent UI React", | ||
"main": "lib-commonjs/index.js", | ||
"module": "lib/index.js", | ||
"typings": "lib/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", | ||
"start": "yarn storybook", | ||
"test": "jest --passWithNoTests", | ||
"docs": "api-extractor run --config=config/api-extractor.local.json --local", | ||
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-dialog/src && yarn docs", | ||
"storybook": "start-storybook", | ||
"type-check": "tsc -b tsconfig.json" | ||
}, | ||
"devDependencies": { | ||
"@fluentui/babel-make-styles": "9.0.0-beta.4", | ||
"@fluentui/eslint-plugin": "*", | ||
"@fluentui/jest-serializer-make-styles": "9.0.0-beta.4", | ||
"@fluentui/react-conformance": "*", | ||
"@fluentui/react-conformance-make-styles": "9.0.0-beta.4", | ||
"@fluentui/scripts": "^1.0.0", | ||
"@types/enzyme": "3.10.3", | ||
"@types/enzyme-adapter-react-16": "1.0.3", | ||
"@types/react": "16.9.42", | ||
"@types/react-dom": "16.9.10", | ||
"@types/react-test-renderer": "^16.0.0", | ||
"enzyme": "~3.10.0", | ||
"enzyme-adapter-react-16": "^1.15.0", | ||
"react": "16.8.6", | ||
"react-dom": "16.8.6", | ||
"react-test-renderer": "^16.3.0" | ||
}, | ||
"dependencies": { | ||
"@fluentui/react-make-styles": "9.0.0-beta.4", | ||
"@fluentui/react-utilities": "9.0.0-beta.4", | ||
"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" | ||
}, | ||
"beachball": { | ||
"disallowedChangeTypes": [ | ||
"major", | ||
"minor", | ||
"patch" | ||
] | ||
} | ||
} |
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 './components/Dialog/index'; |
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,15 @@ | ||
import { isConformant as baseIsConformant } from '@fluentui/react-conformance'; | ||
import type { IsConformantOptions, TestObject } from '@fluentui/react-conformance'; | ||
import makeStylesTests from '@fluentui/react-conformance-make-styles'; | ||
|
||
export function isConformant<TProps = {}>( | ||
testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & { componentPath?: string }, | ||
) { | ||
const defaultOptions: Partial<IsConformantOptions<TProps>> = { | ||
asPropHandlesRef: true, | ||
componentPath: module!.parent!.filename.replace('.test', ''), | ||
extraTests: makeStylesTests as TestObject<TProps>, | ||
}; | ||
|
||
baseIsConformant(defaultOptions, testInfo); | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/react-dialog/src/components/Dialog/Dialog.test.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,18 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Dialog } from './Dialog'; | ||
import { isConformant } from '../../common/isConformant'; | ||
|
||
describe('Dialog', () => { | ||
isConformant({ | ||
Component: Dialog, | ||
displayName: 'Dialog', | ||
}); | ||
|
||
// TODO add more tests here, and create visual regression tests in /apps/vr-tests | ||
|
||
it('renders a default state', () => { | ||
const result = render(<Dialog>Default Dialog</Dialog>); | ||
expect(result.container).toMatchSnapshot(); | ||
}); | ||
}); |
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,18 @@ | ||
import * as React from 'react'; | ||
import { useDialog } from './useDialog'; | ||
import { renderDialog } from './renderDialog'; | ||
import { useDialogStyles } from './useDialogStyles'; | ||
import type { DialogProps } from './Dialog.types'; | ||
import type { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
|
||
/** | ||
* A Dialog is an elevated Card triggered by a user’s action. | ||
*/ | ||
export const Dialog: ForwardRefComponent<DialogProps> = React.forwardRef((props, ref) => { | ||
const state = useDialog(props, ref); | ||
|
||
useDialogStyles(state); | ||
return renderDialog(state); | ||
}); | ||
|
||
Dialog.displayName = 'Dialog'; |
Oops, something went wrong.