diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5fc466336d99f..9fa08ac0024f7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -131,6 +131,7 @@ packages/react-button/ @microsoft/cxe-red @dzearing @khmakoto packages/react-card/ @microsoft/cxe-prg packages/react-checkbox/ @microsoft/cxe-red @khmakoto packages/react-components/ @microsoft/teams-prg @microsoft/cxe-prg @microsoft/cxe-red +packages/react-dialog/ @microsoft/cxe-prg packages/react-divider/ @microsoft/cxe-red @geoffcoxmsft packages/react-focus/ @microsoft/cxe-red @khmakoto packages/react-image/ @microsoft/cxe-prg diff --git a/jest.config.js b/jest.config.js index efbee7e59b5db..2fb099f51e626 100644 --- a/jest.config.js +++ b/jest.config.js @@ -41,5 +41,6 @@ module.exports = { '/packages/react-radio', '/packages/react-spinbutton', '/packages/react-tabs', + '/packages/react-dialog', ], }; diff --git a/nx.json b/nx.json index bc227018eab70..9c025553d286a 100644 --- a/nx.json +++ b/nx.json @@ -215,6 +215,10 @@ "@fluentui/react-date-time": { "implicitDependencies": [] }, + "@fluentui/react-dialog": { + "tags": ["vNext", "platform:web"], + "implicitDependencies": [] + }, "@fluentui/react-divider": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] diff --git a/packages/react-dialog/.babelrc.json b/packages/react-dialog/.babelrc.json new file mode 100644 index 0000000000000..b51a5457ced10 --- /dev/null +++ b/packages/react-dialog/.babelrc.json @@ -0,0 +1,3 @@ +{ + "plugins": ["module:@fluentui/babel-make-styles", "annotate-pure-calls", "@babel/transform-react-pure-annotations"] +} diff --git a/packages/react-dialog/.eslintrc.json b/packages/react-dialog/.eslintrc.json new file mode 100644 index 0000000000000..ceea884c70dcc --- /dev/null +++ b/packages/react-dialog/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": ["plugin:@fluentui/eslint-plugin/react"], + "root": true +} diff --git a/packages/react-dialog/.npmignore b/packages/react-dialog/.npmignore new file mode 100644 index 0000000000000..e719afb921bc9 --- /dev/null +++ b/packages/react-dialog/.npmignore @@ -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 diff --git a/packages/react-dialog/.storybook/main.js b/packages/react-dialog/.storybook/main.js new file mode 100644 index 0000000000000..18a60b265c2cf --- /dev/null +++ b/packages/react-dialog/.storybook/main.js @@ -0,0 +1,14 @@ +const rootMain = require('../../../.storybook/main'); + +module.exports = /** @type {Omit} */ ({ + ...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; + }, +}); diff --git a/packages/react-dialog/.storybook/preview.js b/packages/react-dialog/.storybook/preview.js new file mode 100644 index 0000000000000..10fd98d02c945 --- /dev/null +++ b/packages/react-dialog/.storybook/preview.js @@ -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 }; diff --git a/packages/react-dialog/.storybook/tsconfig.json b/packages/react-dialog/.storybook/tsconfig.json new file mode 100644 index 0000000000000..29aa16f2f178f --- /dev/null +++ b/packages/react-dialog/.storybook/tsconfig.json @@ -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"] +} diff --git a/packages/react-dialog/LICENSE b/packages/react-dialog/LICENSE new file mode 100644 index 0000000000000..6234d13ff805c --- /dev/null +++ b/packages/react-dialog/LICENSE @@ -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 diff --git a/packages/react-dialog/README.md b/packages/react-dialog/README.md new file mode 100644 index 0000000000000..5e8c4846fb1b1 --- /dev/null +++ b/packages/react-dialog/README.md @@ -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. diff --git a/packages/react-dialog/Spec.md b/packages/react-dialog/Spec.md new file mode 100644 index 0000000000000..4f87703faa967 --- /dev/null +++ b/packages/react-dialog/Spec.md @@ -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) diff --git a/packages/react-dialog/config/api-extractor.json b/packages/react-dialog/config/api-extractor.json new file mode 100644 index 0000000000000..f890ae360b7f7 --- /dev/null +++ b/packages/react-dialog/config/api-extractor.json @@ -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" +} diff --git a/packages/react-dialog/config/api-extractor.local.json b/packages/react-dialog/config/api-extractor.local.json new file mode 100644 index 0000000000000..7974a129e8a33 --- /dev/null +++ b/packages/react-dialog/config/api-extractor.local.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "extends": "./api-extractor.json", + "mainEntryPointFilePath": "/dist/packages//src/index.d.ts" +} diff --git a/packages/react-dialog/config/tests.js b/packages/react-dialog/config/tests.js new file mode 100644 index 0000000000000..3882d3702ddc9 --- /dev/null +++ b/packages/react-dialog/config/tests.js @@ -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() }); diff --git a/packages/react-dialog/etc/react-dialog.api.md b/packages/react-dialog/etc/react-dialog.api.md new file mode 100644 index 0000000000000..815c1b176c621 --- /dev/null +++ b/packages/react-dialog/etc/react-dialog.api.md @@ -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; + +// @public (undocumented) +export const dialogClassName = "fui-Dialog"; + +// @public (undocumented) +export type DialogCommons = {}; + +// @public +export type DialogProps = ComponentProps & DialogCommons; + +// @public +export const dialogShorthandProps: (keyof DialogSlots)[]; + +// @public (undocumented) +export type DialogSlots = { + root: IntrinsicShorthandProps<'div'>; +}; + +// @public +export type DialogState = ComponentState & DialogCommons; + +// @public +export const renderDialog: (state: DialogState) => JSX.Element; + +// @public +export const useDialog: (props: DialogProps, ref: React_2.Ref) => DialogState; + +// @public +export const useDialogStyles: (state: DialogState) => DialogState; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/react-dialog/jest.config.js b/packages/react-dialog/jest.config.js new file mode 100644 index 0000000000000..d25098a468985 --- /dev/null +++ b/packages/react-dialog/jest.config.js @@ -0,0 +1,21 @@ +// @ts-check + +/** + * @type {jest.InitialOptions} + */ +module.exports = { + displayName: 'react-dialog', + preset: '../../jest.preset.js', + globals: { + 'ts-jest': { + tsConfig: '/tsconfig.spec.json', + diagnostics: false, + }, + }, + transform: { + '^.+\\.tsx?$': 'ts-jest', + }, + coverageDirectory: './coverage', + setupFilesAfterEnv: ['./config/tests.js'], + snapshotSerializers: ['@fluentui/jest-serializer-make-styles'], +}; diff --git a/packages/react-dialog/just.config.ts b/packages/react-dialog/just.config.ts new file mode 100644 index 0000000000000..bcc7d9d264037 --- /dev/null +++ b/packages/react-dialog/just.config.ts @@ -0,0 +1,3 @@ +import { preset } from '@fluentui/scripts'; + +preset(); diff --git a/packages/react-dialog/package.json b/packages/react-dialog/package.json new file mode 100644 index 0000000000000..e52a8a72247a6 --- /dev/null +++ b/packages/react-dialog/package.json @@ -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" + ] + } +} diff --git a/packages/react-dialog/src/Dialog.ts b/packages/react-dialog/src/Dialog.ts new file mode 100644 index 0000000000000..7bf75f7fd91ba --- /dev/null +++ b/packages/react-dialog/src/Dialog.ts @@ -0,0 +1 @@ +export * from './components/Dialog/index'; diff --git a/packages/react-dialog/src/common/isConformant.ts b/packages/react-dialog/src/common/isConformant.ts new file mode 100644 index 0000000000000..a6b1f0890db02 --- /dev/null +++ b/packages/react-dialog/src/common/isConformant.ts @@ -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( + testInfo: Omit, 'componentPath'> & { componentPath?: string }, +) { + const defaultOptions: Partial> = { + asPropHandlesRef: true, + componentPath: module!.parent!.filename.replace('.test', ''), + extraTests: makeStylesTests as TestObject, + }; + + baseIsConformant(defaultOptions, testInfo); +} diff --git a/packages/react-dialog/src/components/Dialog/Dialog.test.tsx b/packages/react-dialog/src/components/Dialog/Dialog.test.tsx new file mode 100644 index 0000000000000..596c471f7f769 --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/Dialog.test.tsx @@ -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(Default Dialog); + expect(result.container).toMatchSnapshot(); + }); +}); diff --git a/packages/react-dialog/src/components/Dialog/Dialog.tsx b/packages/react-dialog/src/components/Dialog/Dialog.tsx new file mode 100644 index 0000000000000..ccf1ac32d3a2d --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/Dialog.tsx @@ -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 = React.forwardRef((props, ref) => { + const state = useDialog(props, ref); + + useDialogStyles(state); + return renderDialog(state); +}); + +Dialog.displayName = 'Dialog'; diff --git a/packages/react-dialog/src/components/Dialog/Dialog.types.ts b/packages/react-dialog/src/components/Dialog/Dialog.types.ts new file mode 100644 index 0000000000000..3550698472b01 --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/Dialog.types.ts @@ -0,0 +1,20 @@ +import type { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities'; + +export type DialogSlots = { + // TODO Add slots here and to dialogShorthandProps in useDialog.ts + root: IntrinsicShorthandProps<'div'>; +}; + +export type DialogCommons = { + // TODO Add things shared between props and state here +}; + +/** + * Dialog Props + */ +export type DialogProps = ComponentProps & DialogCommons; + +/** + * State used in rendering Dialog + */ +export type DialogState = ComponentState & DialogCommons; diff --git a/packages/react-dialog/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap b/packages/react-dialog/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap new file mode 100644 index 0000000000000..5483ee1e275b8 --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Dialog renders a default state 1`] = ` +
+
+ Default Dialog +
+
+`; diff --git a/packages/react-dialog/src/components/Dialog/index.ts b/packages/react-dialog/src/components/Dialog/index.ts new file mode 100644 index 0000000000000..315888ea4e499 --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/index.ts @@ -0,0 +1,5 @@ +export * from './Dialog'; +export * from './Dialog.types'; +export * from './renderDialog'; +export * from './useDialog'; +export * from './useDialogStyles'; diff --git a/packages/react-dialog/src/components/Dialog/renderDialog.tsx b/packages/react-dialog/src/components/Dialog/renderDialog.tsx new file mode 100644 index 0000000000000..524dd29519e9b --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/renderDialog.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import { getSlots } from '@fluentui/react-utilities'; +import { dialogShorthandProps } from './useDialog'; +import type { DialogState, DialogSlots } from './Dialog.types'; + +/** + * Render the final JSX of Dialog + */ +export const renderDialog = (state: DialogState) => { + const { slots, slotProps } = getSlots(state, dialogShorthandProps); + + // TODO Add additional slots in the appropriate place + return ; +}; diff --git a/packages/react-dialog/src/components/Dialog/useDialog.ts b/packages/react-dialog/src/components/Dialog/useDialog.ts new file mode 100644 index 0000000000000..32e2475b6d1b3 --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/useDialog.ts @@ -0,0 +1,36 @@ +import * as React from 'react'; +import { getNativeElementProps } from '@fluentui/react-utilities'; +import type { DialogProps, DialogSlots, DialogState } from './Dialog.types'; + +/** + * Array of all shorthand properties listed in DialogSlots + */ +export const dialogShorthandProps: (keyof DialogSlots)[] = [ + 'root', + // TODO add shorthand property names +]; + +/** + * Create the state required to render Dialog. + * + * The returned state can be modified with hooks such as useDialogStyles, + * before being passed to renderDialog. + * + * @param props - props from this instance of Dialog + * @param ref - reference to root HTMLElement of Dialog + */ +export const useDialog = (props: DialogProps, ref: React.Ref): DialogState => { + return { + // TODO add appropriate props/defaults + components: { + // TODO add slot types here if needed (div is the default) + root: 'div', + }, + // TODO add appropriate slots, for example: + // mySlot: resolveShorthand(props.mySlot), + root: getNativeElementProps('div', { + ref, + ...props, + }), + }; +}; diff --git a/packages/react-dialog/src/components/Dialog/useDialogStyles.ts b/packages/react-dialog/src/components/Dialog/useDialogStyles.ts new file mode 100644 index 0000000000000..94f58ae3539f9 --- /dev/null +++ b/packages/react-dialog/src/components/Dialog/useDialogStyles.ts @@ -0,0 +1,28 @@ +import { makeStyles, mergeClasses } from '@fluentui/react-make-styles'; +import type { DialogState } from './Dialog.types'; + +export const dialogClassName = 'fui-Dialog'; + +/** + * Styles for the root slot + */ +const useStyles = makeStyles({ + root: theme => ({ + // TODO Add default styles for the root element + }), + + // TODO add additional classes for different states and/or slots +}); + +/** + * Apply styling to the Dialog slots based on the state + */ +export const useDialogStyles = (state: DialogState): DialogState => { + const styles = useStyles(); + state.root.className = mergeClasses(dialogClassName, styles.root, state.root.className); + + // TODO Add class names to slots, for example: + // state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className); + + return state; +}; diff --git a/packages/react-dialog/src/index.ts b/packages/react-dialog/src/index.ts new file mode 100644 index 0000000000000..435ae7de95b0a --- /dev/null +++ b/packages/react-dialog/src/index.ts @@ -0,0 +1,3 @@ +// TODO: replace with real exports +export {}; +export * from './Dialog'; diff --git a/packages/react-dialog/src/stories/Dialog.stories.tsx b/packages/react-dialog/src/stories/Dialog.stories.tsx new file mode 100644 index 0000000000000..b3419dd986573 --- /dev/null +++ b/packages/react-dialog/src/stories/Dialog.stories.tsx @@ -0,0 +1,18 @@ +import { Dialog } from '../index'; + +import descriptionMd from './DialogDescription.md'; +import bestPracticesMd from './DialogBestPractices.md'; + +export { Default } from './DialogDefault.stories'; + +export default { + title: 'Components/Dialog', + component: Dialog, + parameters: { + docs: { + description: { + component: [descriptionMd, bestPracticesMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-dialog/src/stories/DialogBestPractices.md b/packages/react-dialog/src/stories/DialogBestPractices.md new file mode 100644 index 0000000000000..08ff8ddeeb5f8 --- /dev/null +++ b/packages/react-dialog/src/stories/DialogBestPractices.md @@ -0,0 +1,5 @@ +## Best practices + +### Do + +### Don't diff --git a/packages/react-dialog/src/stories/DialogDefault.stories.tsx b/packages/react-dialog/src/stories/DialogDefault.stories.tsx new file mode 100644 index 0000000000000..d6039f20da964 --- /dev/null +++ b/packages/react-dialog/src/stories/DialogDefault.stories.tsx @@ -0,0 +1,4 @@ +import * as React from 'react'; +import { Dialog, DialogProps } from '../index'; + +export const Default = (props: Partial) => ; diff --git a/packages/react-dialog/src/stories/DialogDescription.md b/packages/react-dialog/src/stories/DialogDescription.md new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/react-dialog/tsconfig.json b/packages/react-dialog/tsconfig.json new file mode 100644 index 0000000000000..affceae1828ae --- /dev/null +++ b/packages/react-dialog/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "target": "ES2019", + "noEmit": true, + "isolatedModules": true, + "importHelpers": true, + "jsx": "react", + "noUnusedLocals": true, + "preserveConstEnums": true + }, + "include": [], + "files": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + }, + { + "path": "./.storybook/tsconfig.json" + } + ] +} diff --git a/packages/react-dialog/tsconfig.lib.json b/packages/react-dialog/tsconfig.lib.json new file mode 100644 index 0000000000000..b83999c31f8a3 --- /dev/null +++ b/packages/react-dialog/tsconfig.lib.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "lib": ["ES2019", "dom"], + "outDir": "dist", + "declaration": true, + "types": ["static-assets", "environment", "inline-style-expand-shorthand"] + }, + "exclude": [ + "./src/common/**", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.stories.ts", + "**/*.stories.tsx" + ], + "include": ["./src/**/*.ts", "./src/**/*.tsx"] +} diff --git a/packages/react-dialog/tsconfig.spec.json b/packages/react-dialog/tsconfig.spec.json new file mode 100644 index 0000000000000..28fa5226de420 --- /dev/null +++ b/packages/react-dialog/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist", + "types": ["jest", "node", "inline-style-expand-shorthand"] + }, + "include": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 0bd059cda9040..94e93191af3bf 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -29,6 +29,7 @@ "@fluentui/react-conformance": ["packages/react-conformance/src/index.ts"], "@fluentui/react-conformance-make-styles": ["packages/react-conformance-make-styles/src/index.ts"], "@fluentui/react-context-selector": ["packages/react-context-selector/src/index.ts"], + "@fluentui/react-dialog": ["packages/react-dialog/src/index.ts"], "@fluentui/react-divider": ["packages/react-divider/src/index.ts"], "@fluentui/react-focus-management": ["packages/react-focus-management/src/index.ts"], "@fluentui/react-image": ["packages/react-image/src/index.ts"], diff --git a/workspace.json b/workspace.json index 498533b285c42..6b845348448ea 100644 --- a/workspace.json +++ b/workspace.json @@ -253,6 +253,11 @@ "root": "packages/react-date-time", "projectType": "library" }, + "@fluentui/react-dialog": { + "root": "packages/react-dialog", + "projectType": "library", + "sourceRoot": "packages/react-dialog/src" + }, "@fluentui/react-divider": { "root": "packages/react-divider", "projectType": "library",