From c1016ff1ce3f2fee0cfa05a9f8c5bc9066758042 Mon Sep 17 00:00:00 2001 From: Tomi Olubeko <66456876+tomi-msft@users.noreply.github.com> Date: Sun, 24 Sep 2023 20:23:20 -0700 Subject: [PATCH 1/2] Scaffold Rating component (#29188) * Scaffold Rating component * Update .github/CODEOWNERS Co-authored-by: Makoto Morimoto * Update package description * Update dependency * Update renderRating file --------- Co-authored-by: Makoto Morimoto --- .github/CODEOWNERS | 1 + .../react-rating-preview/.babelrc.json | 4 ++ .../react-rating-preview/.eslintrc.json | 4 ++ .../react-rating-preview/.npmignore | 38 +++++++++++ .../react-rating-preview/.storybook/main.js | 14 +++++ .../.storybook/preview.js | 7 +++ .../.storybook/tsconfig.json | 10 +++ .../react-rating-preview/.swcrc | 30 +++++++++ .../react-rating-preview/LICENSE | 15 +++++ .../react-rating-preview/README.md | 5 ++ .../config/api-extractor.json | 4 ++ .../react-rating-preview/config/tests.js | 1 + .../react-rating-preview/docs/Spec.md | 63 +++++++++++++++++++ .../etc/react-rating-preview.api.md | 42 +++++++++++++ .../react-rating-preview/jest.config.js | 21 +++++++ .../react-rating-preview/just.config.ts | 5 ++ .../react-rating-preview/package.json | 61 ++++++++++++++++++ .../react-rating-preview/project.json | 8 +++ .../react-rating-preview/src/Rating.ts | 1 + .../src/components/Rating/Rating.test.tsx | 18 ++++++ .../src/components/Rating/Rating.tsx | 18 ++++++ .../src/components/Rating/Rating.types.ts | 17 +++++ .../Rating/__snapshots__/Rating.test.tsx.snap | 11 ++++ .../src/components/Rating/index.ts | 5 ++ .../src/components/Rating/renderRating.tsx | 15 +++++ .../src/components/Rating/useRating.ts | 31 +++++++++ .../Rating/useRatingStyles.styles.ts | 33 ++++++++++ .../react-rating-preview/src/index.ts | 8 +++ .../src/testing/isConformant.ts | 15 +++++ .../react-rating-preview/stories/.gitkeep | 0 .../stories/Rating/RatingBestPractices.md | 5 ++ .../stories/Rating/RatingDefault.stories.tsx | 4 ++ .../stories/Rating/RatingDescription.md | 0 .../stories/Rating/index.stories.tsx | 18 ++++++ .../react-rating-preview/tsconfig.json | 25 ++++++++ .../react-rating-preview/tsconfig.lib.json | 22 +++++++ .../react-rating-preview/tsconfig.spec.json | 17 +++++ tsconfig.base.all.json | 3 +- tsconfig.base.json | 1 + 39 files changed, 599 insertions(+), 1 deletion(-) create mode 100644 packages/react-components/react-rating-preview/.babelrc.json create mode 100644 packages/react-components/react-rating-preview/.eslintrc.json create mode 100644 packages/react-components/react-rating-preview/.npmignore create mode 100644 packages/react-components/react-rating-preview/.storybook/main.js create mode 100644 packages/react-components/react-rating-preview/.storybook/preview.js create mode 100644 packages/react-components/react-rating-preview/.storybook/tsconfig.json create mode 100644 packages/react-components/react-rating-preview/.swcrc create mode 100644 packages/react-components/react-rating-preview/LICENSE create mode 100644 packages/react-components/react-rating-preview/README.md create mode 100644 packages/react-components/react-rating-preview/config/api-extractor.json create mode 100644 packages/react-components/react-rating-preview/config/tests.js create mode 100644 packages/react-components/react-rating-preview/docs/Spec.md create mode 100644 packages/react-components/react-rating-preview/etc/react-rating-preview.api.md create mode 100644 packages/react-components/react-rating-preview/jest.config.js create mode 100644 packages/react-components/react-rating-preview/just.config.ts create mode 100644 packages/react-components/react-rating-preview/package.json create mode 100644 packages/react-components/react-rating-preview/project.json create mode 100644 packages/react-components/react-rating-preview/src/Rating.ts create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/Rating.test.tsx create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/Rating.tsx create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/Rating.types.ts create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/__snapshots__/Rating.test.tsx.snap create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/index.ts create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/renderRating.tsx create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/useRating.ts create mode 100644 packages/react-components/react-rating-preview/src/components/Rating/useRatingStyles.styles.ts create mode 100644 packages/react-components/react-rating-preview/src/index.ts create mode 100644 packages/react-components/react-rating-preview/src/testing/isConformant.ts create mode 100644 packages/react-components/react-rating-preview/stories/.gitkeep create mode 100644 packages/react-components/react-rating-preview/stories/Rating/RatingBestPractices.md create mode 100644 packages/react-components/react-rating-preview/stories/Rating/RatingDefault.stories.tsx create mode 100644 packages/react-components/react-rating-preview/stories/Rating/RatingDescription.md create mode 100644 packages/react-components/react-rating-preview/stories/Rating/index.stories.tsx create mode 100644 packages/react-components/react-rating-preview/tsconfig.json create mode 100644 packages/react-components/react-rating-preview/tsconfig.lib.json create mode 100644 packages/react-components/react-rating-preview/tsconfig.spec.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a19fce6584213..201ae7ad8f5c1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -244,6 +244,7 @@ packages/react-components/react-nav-preview @microsoft/cxe-red @mltejera packages/react-components/react-motion-preview @microsoft/cxe-prg @marcosmoura packages/react-components/react-message-bar-preview @microsoft/teams-prg packages/react-components/react-timepicker-compat-preview @microsoft/teams-prg +packages/react-components/react-rating-preview @microsoft/cxe-red @tomi-msft # <%= NX-CODEOWNER-PLACEHOLDER %> ## Components diff --git a/packages/react-components/react-rating-preview/.babelrc.json b/packages/react-components/react-rating-preview/.babelrc.json new file mode 100644 index 0000000000000..45fb71ca16d2c --- /dev/null +++ b/packages/react-components/react-rating-preview/.babelrc.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../.babelrc-v9.json", + "plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"] +} diff --git a/packages/react-components/react-rating-preview/.eslintrc.json b/packages/react-components/react-rating-preview/.eslintrc.json new file mode 100644 index 0000000000000..ceea884c70dcc --- /dev/null +++ b/packages/react-components/react-rating-preview/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": ["plugin:@fluentui/eslint-plugin/react"], + "root": true +} diff --git a/packages/react-components/react-rating-preview/.npmignore b/packages/react-components/react-rating-preview/.npmignore new file mode 100644 index 0000000000000..a5817be2414de --- /dev/null +++ b/packages/react-components/react-rating-preview/.npmignore @@ -0,0 +1,38 @@ +.storybook/ +.vscode/ +bundle-size/ +config/ +coverage/ +docs/ +etc/ +node_modules/ +src/ +stories/ +dist/types/ +temp/ +__fixtures__ +__mocks__ +__tests__ + +*.api.json +*.log +*.spec.* +*.cy.* +*.test.* +*.yml + +# config files +*config.* +*rc.* +.editorconfig +.eslint* +.git* +.prettierignore +.swcrc +project.json + +# exclude gitignore patterns explicitly +!lib +!lib-commonjs +!lib-amd +!dist/*.d.ts diff --git a/packages/react-components/react-rating-preview/.storybook/main.js b/packages/react-components/react-rating-preview/.storybook/main.js new file mode 100644 index 0000000000000..26536b61b387f --- /dev/null +++ b/packages/react-components/react-rating-preview/.storybook/main.js @@ -0,0 +1,14 @@ +const rootMain = require('../../../../.storybook/main'); + +module.exports = /** @type {Omit} */ ({ + ...rootMain, + stories: [...rootMain.stories, '../stories/**/*.stories.mdx', '../stories/**/index.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-components/react-rating-preview/.storybook/preview.js b/packages/react-components/react-rating-preview/.storybook/preview.js new file mode 100644 index 0000000000000..1939500a3d18c --- /dev/null +++ b/packages/react-components/react-rating-preview/.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-components/react-rating-preview/.storybook/tsconfig.json b/packages/react-components/react-rating-preview/.storybook/tsconfig.json new file mode 100644 index 0000000000000..ea89218a3d916 --- /dev/null +++ b/packages/react-components/react-rating-preview/.storybook/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "", + "allowJs": true, + "checkJs": true, + "types": ["static-assets", "environment", "storybook__addons"] + }, + "include": ["../stories/**/*.stories.ts", "../stories/**/*.stories.tsx", "*.js"] +} diff --git a/packages/react-components/react-rating-preview/.swcrc b/packages/react-components/react-rating-preview/.swcrc new file mode 100644 index 0000000000000..b4ffa86dee306 --- /dev/null +++ b/packages/react-components/react-rating-preview/.swcrc @@ -0,0 +1,30 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "exclude": [ + "/testing", + "/**/*.cy.ts", + "/**/*.cy.tsx", + "/**/*.spec.ts", + "/**/*.spec.tsx", + "/**/*.test.ts", + "/**/*.test.tsx" + ], + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true, + "decorators": false, + "dynamicImport": false + }, + "externalHelpers": true, + "transform": { + "react": { + "runtime": "classic", + "useSpread": true + } + }, + "target": "es2019" + }, + "minify": false, + "sourceMaps": true +} diff --git a/packages/react-components/react-rating-preview/LICENSE b/packages/react-components/react-rating-preview/LICENSE new file mode 100644 index 0000000000000..574972057c12c --- /dev/null +++ b/packages/react-components/react-rating-preview/LICENSE @@ -0,0 +1,15 @@ +@fluentui/react-rating-preview + +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-components/react-rating-preview/README.md b/packages/react-components/react-rating-preview/README.md new file mode 100644 index 0000000000000..636e2fef4374a --- /dev/null +++ b/packages/react-components/react-rating-preview/README.md @@ -0,0 +1,5 @@ +# @fluentui/react-rating-preview + +**React Rating components for [Fluent UI React](https://react.fluentui.dev/)** + +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-components/react-rating-preview/config/api-extractor.json b/packages/react-components/react-rating-preview/config/api-extractor.json new file mode 100644 index 0000000000000..e533bf30b48a2 --- /dev/null +++ b/packages/react-components/react-rating-preview/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.v-next.json" +} diff --git a/packages/react-components/react-rating-preview/config/tests.js b/packages/react-components/react-rating-preview/config/tests.js new file mode 100644 index 0000000000000..2e211ae9e2142 --- /dev/null +++ b/packages/react-components/react-rating-preview/config/tests.js @@ -0,0 +1 @@ +/** Jest test setup file. */ diff --git a/packages/react-components/react-rating-preview/docs/Spec.md b/packages/react-components/react-rating-preview/docs/Spec.md new file mode 100644 index 0000000000000..89a7ab9c60165 --- /dev/null +++ b/packages/react-components/react-rating-preview/docs/Spec.md @@ -0,0 +1,63 @@ +# @fluentui/react-rating-preview 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-components/react-rating-preview/etc/react-rating-preview.api.md b/packages/react-components/react-rating-preview/etc/react-rating-preview.api.md new file mode 100644 index 0000000000000..d33c654ded784 --- /dev/null +++ b/packages/react-components/react-rating-preview/etc/react-rating-preview.api.md @@ -0,0 +1,42 @@ +## API Report File for "@fluentui/react-rating-preview" + +> 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 * as React_2 from 'react'; +import type { Slot } from '@fluentui/react-utilities'; +import type { SlotClassNames } from '@fluentui/react-utilities'; + +// @public +export const Rating: ForwardRefComponent; + +// @public (undocumented) +export const ratingClassNames: SlotClassNames; + +// @public +export type RatingProps = ComponentProps & {}; + +// @public (undocumented) +export type RatingSlots = { + root: Slot<'div'>; +}; + +// @public +export type RatingState = ComponentState; + +// @public +export const renderRating_unstable: (state: RatingState) => JSX.Element; + +// @public +export const useRating_unstable: (props: RatingProps, ref: React_2.Ref) => RatingState; + +// @public +export const useRatingStyles_unstable: (state: RatingState) => RatingState; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/react-components/react-rating-preview/jest.config.js b/packages/react-components/react-rating-preview/jest.config.js new file mode 100644 index 0000000000000..2e803f870822d --- /dev/null +++ b/packages/react-components/react-rating-preview/jest.config.js @@ -0,0 +1,21 @@ +// @ts-check + +/** + * @type {import('@jest/types').Config.InitialOptions} + */ +module.exports = { + displayName: 'react-rating-preview', + preset: '../../../jest.preset.js', + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + tsconfig: '/tsconfig.spec.json', + isolatedModules: true, + }, + ], + }, + coverageDirectory: './coverage', + setupFilesAfterEnv: ['./config/tests.js'], + snapshotSerializers: ['@griffel/jest-serializer'], +}; diff --git a/packages/react-components/react-rating-preview/just.config.ts b/packages/react-components/react-rating-preview/just.config.ts new file mode 100644 index 0000000000000..b7b2c9a33bf43 --- /dev/null +++ b/packages/react-components/react-rating-preview/just.config.ts @@ -0,0 +1,5 @@ +import { preset, task } from '@fluentui/scripts-tasks'; + +preset(); + +task('build', 'build:react-components').cached?.(); diff --git a/packages/react-components/react-rating-preview/package.json b/packages/react-components/react-rating-preview/package.json new file mode 100644 index 0000000000000..1f13b19ed104c --- /dev/null +++ b/packages/react-components/react-rating-preview/package.json @@ -0,0 +1,61 @@ +{ + "name": "@fluentui/react-rating-preview", + "version": "0.0.0", + "private": true, + "description": "Rating component for building web experiences", + "main": "lib-commonjs/index.js", + "module": "lib/index.js", + "typings": "./dist/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", + "generate-api": "just-scripts generate-api", + "lint": "just-scripts lint", + "start": "yarn storybook", + "storybook": "start-storybook", + "test": "jest --passWithNoTests", + "test-ssr": "test-ssr \"./stories/**/*.stories.tsx\"", + "type-check": "tsc -b tsconfig.json" + }, + "devDependencies": { + "@fluentui/eslint-plugin": "*", + "@fluentui/react-conformance": "*", + "@fluentui/react-conformance-griffel": "*", + "@fluentui/scripts-api-extractor": "*", + "@fluentui/scripts-tasks": "*" + }, + "dependencies": { + "@fluentui/react-jsx-runtime": "^9.0.10", + "@fluentui/react-theme": "^9.1.12", + "@fluentui/react-utilities": "^9.13.3", + "@griffel/react": "^1.5.14", + "@swc/helpers": "^0.5.1" + }, + "peerDependencies": { + "@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" + }, + "exports": { + ".": { + "types": "./dist/index.d.ts", + "node": "./lib-commonjs/index.js", + "import": "./lib/index.js", + "require": "./lib-commonjs/index.js" + }, + "./package.json": "./package.json" + }, + "beachball": { + "disallowedChangeTypes": [ + "major", + "prerelease" + ] + } +} diff --git a/packages/react-components/react-rating-preview/project.json b/packages/react-components/react-rating-preview/project.json new file mode 100644 index 0000000000000..7a43ef0bb2d73 --- /dev/null +++ b/packages/react-components/react-rating-preview/project.json @@ -0,0 +1,8 @@ +{ + "name": "@fluentui/react-rating-preview", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "packages/react-components/react-rating-preview/src", + "tags": ["platform:web", "vNext"], + "implicitDependencies": [] +} diff --git a/packages/react-components/react-rating-preview/src/Rating.ts b/packages/react-components/react-rating-preview/src/Rating.ts new file mode 100644 index 0000000000000..8547775f01880 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/Rating.ts @@ -0,0 +1 @@ +export * from './components/Rating/index'; diff --git a/packages/react-components/react-rating-preview/src/components/Rating/Rating.test.tsx b/packages/react-components/react-rating-preview/src/components/Rating/Rating.test.tsx new file mode 100644 index 0000000000000..0096085671380 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/Rating.test.tsx @@ -0,0 +1,18 @@ +import * as React from 'react'; +import { render } from '@testing-library/react'; +import { isConformant } from '../../testing/isConformant'; +import { Rating } from './Rating'; + +describe('Rating', () => { + isConformant({ + Component: Rating, + displayName: 'Rating', + }); + + // TODO add more tests here, and create visual regression tests in /apps/vr-tests + + it('renders a default state', () => { + const result = render(Default Rating); + expect(result.container).toMatchSnapshot(); + }); +}); diff --git a/packages/react-components/react-rating-preview/src/components/Rating/Rating.tsx b/packages/react-components/react-rating-preview/src/components/Rating/Rating.tsx new file mode 100644 index 0000000000000..24b49d4e77483 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/Rating.tsx @@ -0,0 +1,18 @@ +import * as React from 'react'; +import type { ForwardRefComponent } from '@fluentui/react-utilities'; +import { useRating_unstable } from './useRating'; +import { renderRating_unstable } from './renderRating'; +import { useRatingStyles_unstable } from './useRatingStyles.styles'; +import type { RatingProps } from './Rating.types'; + +/** + * Rating component - TODO: add more docs + */ +export const Rating: ForwardRefComponent = React.forwardRef((props, ref) => { + const state = useRating_unstable(props, ref); + + useRatingStyles_unstable(state); + return renderRating_unstable(state); +}); + +Rating.displayName = 'Rating'; diff --git a/packages/react-components/react-rating-preview/src/components/Rating/Rating.types.ts b/packages/react-components/react-rating-preview/src/components/Rating/Rating.types.ts new file mode 100644 index 0000000000000..78707aae6302d --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/Rating.types.ts @@ -0,0 +1,17 @@ +import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities'; + +export type RatingSlots = { + root: Slot<'div'>; +}; + +/** + * Rating Props + */ +export type RatingProps = ComponentProps & {}; + +/** + * State used in rendering Rating + */ +export type RatingState = ComponentState; +// TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from RatingProps. +// & Required> diff --git a/packages/react-components/react-rating-preview/src/components/Rating/__snapshots__/Rating.test.tsx.snap b/packages/react-components/react-rating-preview/src/components/Rating/__snapshots__/Rating.test.tsx.snap new file mode 100644 index 0000000000000..3463751c07b51 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/__snapshots__/Rating.test.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Rating renders a default state 1`] = ` +
+
+ Default Rating +
+
+`; diff --git a/packages/react-components/react-rating-preview/src/components/Rating/index.ts b/packages/react-components/react-rating-preview/src/components/Rating/index.ts new file mode 100644 index 0000000000000..4da4d2ba5b4ed --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/index.ts @@ -0,0 +1,5 @@ +export * from './Rating'; +export * from './Rating.types'; +export * from './renderRating'; +export * from './useRating'; +export * from './useRatingStyles.styles'; diff --git a/packages/react-components/react-rating-preview/src/components/Rating/renderRating.tsx b/packages/react-components/react-rating-preview/src/components/Rating/renderRating.tsx new file mode 100644 index 0000000000000..c54470cc134d6 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/renderRating.tsx @@ -0,0 +1,15 @@ +/** @jsxRuntime automatic */ +/** @jsxImportSource @fluentui/react-jsx-runtime */ + +import { assertSlots } from '@fluentui/react-utilities'; +import type { RatingState, RatingSlots } from './Rating.types'; + +/** + * Render the final JSX of Rating + */ +export const renderRating_unstable = (state: RatingState) => { + assertSlots(state); + + // TODO Add additional slots in the appropriate place + return ; +}; diff --git a/packages/react-components/react-rating-preview/src/components/Rating/useRating.ts b/packages/react-components/react-rating-preview/src/components/Rating/useRating.ts new file mode 100644 index 0000000000000..01a62a85e2ad0 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/useRating.ts @@ -0,0 +1,31 @@ +import * as React from 'react'; +import { getNativeElementProps, slot } from '@fluentui/react-utilities'; +import type { RatingProps, RatingState } from './Rating.types'; + +/** + * Create the state required to render Rating. + * + * The returned state can be modified with hooks such as useRatingStyles_unstable, + * before being passed to renderRating_unstable. + * + * @param props - props from this instance of Rating + * @param ref - reference to root HTMLElement of Rating + */ +export const useRating_unstable = (props: RatingProps, ref: React.Ref): RatingState => { + return { + // TODO add appropriate props/defaults + components: { + // TODO add each slot's element type or component + root: 'div', + }, + // TODO add appropriate slots, for example: + // mySlot: resolveShorthand(props.mySlot), + root: slot.always( + getNativeElementProps('div', { + ref, + ...props, + }), + { elementType: 'div' }, + ), + }; +}; diff --git a/packages/react-components/react-rating-preview/src/components/Rating/useRatingStyles.styles.ts b/packages/react-components/react-rating-preview/src/components/Rating/useRatingStyles.styles.ts new file mode 100644 index 0000000000000..7ce9e2cac85d6 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/components/Rating/useRatingStyles.styles.ts @@ -0,0 +1,33 @@ +import { makeStyles, mergeClasses } from '@griffel/react'; +import type { SlotClassNames } from '@fluentui/react-utilities'; +import type { RatingSlots, RatingState } from './Rating.types'; + +export const ratingClassNames: SlotClassNames = { + root: 'fui-Rating', + // TODO: add class names for all slots on RatingSlots. + // Should be of the form `: 'fui-Rating__` +}; + +/** + * Styles for the root slot + */ +const useStyles = makeStyles({ + root: { + // TODO Add default styles for the root element + }, + + // TODO add additional classes for different states and/or slots +}); + +/** + * Apply styling to the Rating slots based on the state + */ +export const useRatingStyles_unstable = (state: RatingState): RatingState => { + const styles = useStyles(); + state.root.className = mergeClasses(ratingClassNames.root, 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-components/react-rating-preview/src/index.ts b/packages/react-components/react-rating-preview/src/index.ts new file mode 100644 index 0000000000000..cca3731f19b5b --- /dev/null +++ b/packages/react-components/react-rating-preview/src/index.ts @@ -0,0 +1,8 @@ +export { + Rating, + ratingClassNames, + renderRating_unstable, + useRatingStyles_unstable, + useRating_unstable, +} from './Rating'; +export type { RatingProps, RatingSlots, RatingState } from './Rating'; diff --git a/packages/react-components/react-rating-preview/src/testing/isConformant.ts b/packages/react-components/react-rating-preview/src/testing/isConformant.ts new file mode 100644 index 0000000000000..a3d988f29a172 --- /dev/null +++ b/packages/react-components/react-rating-preview/src/testing/isConformant.ts @@ -0,0 +1,15 @@ +import { isConformant as baseIsConformant } from '@fluentui/react-conformance'; +import type { IsConformantOptions, TestObject } from '@fluentui/react-conformance'; +import griffelTests from '@fluentui/react-conformance-griffel'; + +export function isConformant( + testInfo: Omit, 'componentPath'> & { componentPath?: string }, +) { + const defaultOptions: Partial> = { + tsConfig: { configName: 'tsconfig.spec.json' }, + componentPath: require.main?.filename.replace('.test', ''), + extraTests: griffelTests as TestObject, + }; + + baseIsConformant(defaultOptions, testInfo); +} diff --git a/packages/react-components/react-rating-preview/stories/.gitkeep b/packages/react-components/react-rating-preview/stories/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/react-components/react-rating-preview/stories/Rating/RatingBestPractices.md b/packages/react-components/react-rating-preview/stories/Rating/RatingBestPractices.md new file mode 100644 index 0000000000000..08ff8ddeeb5f8 --- /dev/null +++ b/packages/react-components/react-rating-preview/stories/Rating/RatingBestPractices.md @@ -0,0 +1,5 @@ +## Best practices + +### Do + +### Don't diff --git a/packages/react-components/react-rating-preview/stories/Rating/RatingDefault.stories.tsx b/packages/react-components/react-rating-preview/stories/Rating/RatingDefault.stories.tsx new file mode 100644 index 0000000000000..f04985cf99ff6 --- /dev/null +++ b/packages/react-components/react-rating-preview/stories/Rating/RatingDefault.stories.tsx @@ -0,0 +1,4 @@ +import * as React from 'react'; +import { Rating, RatingProps } from '@fluentui/react-rating-preview'; + +export const Default = (props: Partial) => ; diff --git a/packages/react-components/react-rating-preview/stories/Rating/RatingDescription.md b/packages/react-components/react-rating-preview/stories/Rating/RatingDescription.md new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/react-components/react-rating-preview/stories/Rating/index.stories.tsx b/packages/react-components/react-rating-preview/stories/Rating/index.stories.tsx new file mode 100644 index 0000000000000..25c16b389f459 --- /dev/null +++ b/packages/react-components/react-rating-preview/stories/Rating/index.stories.tsx @@ -0,0 +1,18 @@ +import { Rating } from '@fluentui/react-rating-preview'; + +import descriptionMd from './RatingDescription.md'; +import bestPracticesMd from './RatingBestPractices.md'; + +export { Default } from './RatingDefault.stories'; + +export default { + title: 'Preview Components/Rating', + component: Rating, + parameters: { + docs: { + description: { + component: [descriptionMd, bestPracticesMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-components/react-rating-preview/tsconfig.json b/packages/react-components/react-rating-preview/tsconfig.json new file mode 100644 index 0000000000000..1941a041d46c1 --- /dev/null +++ b/packages/react-components/react-rating-preview/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-components/react-rating-preview/tsconfig.lib.json b/packages/react-components/react-rating-preview/tsconfig.lib.json new file mode 100644 index 0000000000000..6f90cf95c005b --- /dev/null +++ b/packages/react-components/react-rating-preview/tsconfig.lib.json @@ -0,0 +1,22 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "lib": ["ES2019", "dom"], + "declaration": true, + "declarationDir": "../../../dist/out-tsc/types", + "outDir": "../../../dist/out-tsc", + "inlineSources": true, + "types": ["static-assets", "environment"] + }, + "exclude": [ + "./src/testing/**", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.stories.ts", + "**/*.stories.tsx" + ], + "include": ["./src/**/*.ts", "./src/**/*.tsx"] +} diff --git a/packages/react-components/react-rating-preview/tsconfig.spec.json b/packages/react-components/react-rating-preview/tsconfig.spec.json new file mode 100644 index 0000000000000..911456fe4b4d9 --- /dev/null +++ b/packages/react-components/react-rating-preview/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist", + "types": ["jest", "node"] + }, + "include": [ + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.d.ts", + "./src/testing/**/*.ts", + "./src/testing/**/*.tsx" + ] +} diff --git a/tsconfig.base.all.json b/tsconfig.base.all.json index 3a32d18aab0ad..3e9d93be25d96 100644 --- a/tsconfig.base.all.json +++ b/tsconfig.base.all.json @@ -165,7 +165,8 @@ "@fluentui/workspace-plugin": ["tools/workspace-plugin/src/index.ts"], "@fluentui/react-timepicker-compat-preview": [ "packages/react-components/react-timepicker-compat-preview/src/index.ts" - ] + ], + "@fluentui/react-rating-preview": ["packages/react-components/react-rating-preview/src/index.ts"] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index 7ab4096d7c085..e92421861d019 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -69,6 +69,7 @@ "@fluentui/react-progress": ["packages/react-components/react-progress/src/index.ts"], "@fluentui/react-provider": ["packages/react-components/react-provider/src/index.ts"], "@fluentui/react-radio": ["packages/react-components/react-radio/src/index.ts"], + "@fluentui/react-rating-preview": ["packages/react-components/react-rating-preview/src/index.ts"], "@fluentui/react-search-preview": ["packages/react-components/react-search-preview/src/index.ts"], "@fluentui/react-select": ["packages/react-components/react-select/src/index.ts"], "@fluentui/react-shared-contexts": ["packages/react-components/react-shared-contexts/src/index.ts"], From 4942c5f07e08f1061cc8a6b753cd668b05482151 Mon Sep 17 00:00:00 2001 From: Fluent UI Build Date: Mon, 25 Sep 2023 07:36:48 +0000 Subject: [PATCH 2/2] applying package updates --- ...ting-18c6ed5b-114e-4e6f-982f-2a59fa333f96.json | 7 ------- packages/react-charting/CHANGELOG.json | 15 +++++++++++++++ packages/react-charting/CHANGELOG.md | 11 ++++++++++- packages/react-charting/package.json | 2 +- packages/react-docsite-components/CHANGELOG.json | 15 +++++++++++++++ packages/react-docsite-components/CHANGELOG.md | 11 ++++++++++- packages/react-docsite-components/package.json | 4 ++-- packages/react-examples/package.json | 4 ++-- packages/react-monaco-editor/CHANGELOG.json | 15 +++++++++++++++ packages/react-monaco-editor/CHANGELOG.md | 11 ++++++++++- packages/react-monaco-editor/package.json | 4 ++-- 11 files changed, 82 insertions(+), 17 deletions(-) delete mode 100644 change/@fluentui-react-charting-18c6ed5b-114e-4e6f-982f-2a59fa333f96.json diff --git a/change/@fluentui-react-charting-18c6ed5b-114e-4e6f-982f-2a59fa333f96.json b/change/@fluentui-react-charting-18c6ed5b-114e-4e6f-982f-2a59fa333f96.json deleted file mode 100644 index f433e9c63f85a..0000000000000 --- a/change/@fluentui-react-charting-18c6ed5b-114e-4e6f-982f-2a59fa333f96.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "patch", - "comment": "Enable reflow for all cartesian chart examples", - "packageName": "@fluentui/react-charting", - "email": "kumarkshitij@microsoft.com", - "dependentChangeType": "patch" -} diff --git a/packages/react-charting/CHANGELOG.json b/packages/react-charting/CHANGELOG.json index dcdb835efb240..a97ce26f61cb6 100644 --- a/packages/react-charting/CHANGELOG.json +++ b/packages/react-charting/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@fluentui/react-charting", "entries": [ + { + "date": "Mon, 25 Sep 2023 07:36:44 GMT", + "tag": "@fluentui/react-charting_v5.17.8", + "version": "5.17.8", + "comments": { + "patch": [ + { + "author": "kumarkshitij@microsoft.com", + "package": "@fluentui/react-charting", + "commit": "0327a2d37ae2b10127ee8133355d993fade18648", + "comment": "Enable reflow for all cartesian chart examples" + } + ] + } + }, { "date": "Mon, 11 Sep 2023 07:35:28 GMT", "tag": "@fluentui/react-charting_v5.17.7", diff --git a/packages/react-charting/CHANGELOG.md b/packages/react-charting/CHANGELOG.md index bf38aa68e3b6e..ba67b4875c696 100644 --- a/packages/react-charting/CHANGELOG.md +++ b/packages/react-charting/CHANGELOG.md @@ -1,9 +1,18 @@ # Change Log - @fluentui/react-charting -This log was last generated on Mon, 11 Sep 2023 07:35:28 GMT and should not be manually modified. +This log was last generated on Mon, 25 Sep 2023 07:36:44 GMT and should not be manually modified. +## [5.17.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-charting_v5.17.8) + +Mon, 25 Sep 2023 07:36:44 GMT +[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-charting_v5.17.7..@fluentui/react-charting_v5.17.8) + +### Patches + +- Enable reflow for all cartesian chart examples ([PR #29229](https://github.com/microsoft/fluentui/pull/29229) by kumarkshitij@microsoft.com) + ## [5.17.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-charting_v5.17.7) Mon, 11 Sep 2023 07:35:28 GMT diff --git a/packages/react-charting/package.json b/packages/react-charting/package.json index ecaaec1c0beed..d93700d586718 100644 --- a/packages/react-charting/package.json +++ b/packages/react-charting/package.json @@ -1,6 +1,6 @@ { "name": "@fluentui/react-charting", - "version": "5.17.7", + "version": "5.17.8", "description": "Experimental React charting components for building experiences for Microsoft 365.", "main": "lib-commonjs/index.js", "module": "lib/index.js", diff --git a/packages/react-docsite-components/CHANGELOG.json b/packages/react-docsite-components/CHANGELOG.json index c9343c60a4d86..4db03570b7f64 100644 --- a/packages/react-docsite-components/CHANGELOG.json +++ b/packages/react-docsite-components/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@fluentui/react-docsite-components", "entries": [ + { + "date": "Mon, 25 Sep 2023 07:36:44 GMT", + "tag": "@fluentui/react-docsite-components_v8.13.8", + "version": "8.13.8", + "comments": { + "patch": [ + { + "author": "beachball", + "package": "@fluentui/react-docsite-components", + "comment": "Bump @fluentui/react-monaco-editor to v1.7.126", + "commit": "c1016ff1ce3f2fee0cfa05a9f8c5bc9066758042" + } + ] + } + }, { "date": "Mon, 11 Sep 2023 07:35:28 GMT", "tag": "@fluentui/react-docsite-components_v8.13.7", diff --git a/packages/react-docsite-components/CHANGELOG.md b/packages/react-docsite-components/CHANGELOG.md index 18a3dc33aea68..3c913d45520e3 100644 --- a/packages/react-docsite-components/CHANGELOG.md +++ b/packages/react-docsite-components/CHANGELOG.md @@ -1,9 +1,18 @@ # Change Log - @fluentui/react-docsite-components -This log was last generated on Mon, 11 Sep 2023 07:35:28 GMT and should not be manually modified. +This log was last generated on Mon, 25 Sep 2023 07:36:44 GMT and should not be manually modified. +## [8.13.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-docsite-components_v8.13.8) + +Mon, 25 Sep 2023 07:36:44 GMT +[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-docsite-components_v8.13.7..@fluentui/react-docsite-components_v8.13.8) + +### Patches + +- Bump @fluentui/react-monaco-editor to v1.7.126 ([PR #29188](https://github.com/microsoft/fluentui/pull/29188) by beachball) + ## [8.13.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-docsite-components_v8.13.7) Mon, 11 Sep 2023 07:35:28 GMT diff --git a/packages/react-docsite-components/package.json b/packages/react-docsite-components/package.json index c4404243e827c..2489f84c6f7ed 100644 --- a/packages/react-docsite-components/package.json +++ b/packages/react-docsite-components/package.json @@ -1,6 +1,6 @@ { "name": "@fluentui/react-docsite-components", - "version": "8.13.7", + "version": "8.13.8", "description": "Fluent UI React components for building documentation sites.", "main": "lib-commonjs/index.js", "module": "lib/index.js", @@ -42,7 +42,7 @@ "@fluentui/public-docsite-setup": "^0.3.22", "@fluentui/react-hooks": "^8.6.29", "@fluentui/set-version": "^8.2.11", - "@fluentui/react-monaco-editor": "^1.7.125", + "@fluentui/react-monaco-editor": "^1.7.126", "color-check": "0.0.2", "markdown-to-jsx": "^7.0.0", "office-ui-fabric-core": "^11.0.0", diff --git a/packages/react-examples/package.json b/packages/react-examples/package.json index 4d2c84e0f4963..8fd99809d5054 100644 --- a/packages/react-examples/package.json +++ b/packages/react-examples/package.json @@ -36,8 +36,8 @@ "@fluentui/merge-styles": "^8.5.12", "@fluentui/react": "^8.111.2", "@fluentui/react-cards": "^0.205.111", - "@fluentui/react-charting": "^5.17.7", - "@fluentui/react-docsite-components": "^8.13.7", + "@fluentui/react-charting": "^5.17.8", + "@fluentui/react-docsite-components": "^8.13.8", "@fluentui/react-experiments": "^8.14.106", "@fluentui/react-file-type-icons": "^8.10.1", "@fluentui/react-focus": "^8.8.31", diff --git a/packages/react-monaco-editor/CHANGELOG.json b/packages/react-monaco-editor/CHANGELOG.json index e479a9d986bd1..04ac75130f050 100644 --- a/packages/react-monaco-editor/CHANGELOG.json +++ b/packages/react-monaco-editor/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@fluentui/react-monaco-editor", "entries": [ + { + "date": "Mon, 25 Sep 2023 07:36:44 GMT", + "tag": "@fluentui/react-monaco-editor_v1.7.126", + "version": "1.7.126", + "comments": { + "patch": [ + { + "author": "beachball", + "package": "@fluentui/react-monaco-editor", + "comment": "Bump @fluentui/react-charting to v5.17.8", + "commit": "c1016ff1ce3f2fee0cfa05a9f8c5bc9066758042" + } + ] + } + }, { "date": "Mon, 11 Sep 2023 07:35:28 GMT", "tag": "@fluentui/react-monaco-editor_v1.7.125", diff --git a/packages/react-monaco-editor/CHANGELOG.md b/packages/react-monaco-editor/CHANGELOG.md index 67e63d4ed58db..505aa485fcdd1 100644 --- a/packages/react-monaco-editor/CHANGELOG.md +++ b/packages/react-monaco-editor/CHANGELOG.md @@ -1,9 +1,18 @@ # Change Log - @fluentui/react-monaco-editor -This log was last generated on Mon, 11 Sep 2023 07:35:28 GMT and should not be manually modified. +This log was last generated on Mon, 25 Sep 2023 07:36:44 GMT and should not be manually modified. +## [1.7.126](https://github.com/microsoft/fluentui/tree/@fluentui/react-monaco-editor_v1.7.126) + +Mon, 25 Sep 2023 07:36:44 GMT +[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-monaco-editor_v1.7.125..@fluentui/react-monaco-editor_v1.7.126) + +### Patches + +- Bump @fluentui/react-charting to v5.17.8 ([PR #29188](https://github.com/microsoft/fluentui/pull/29188) by beachball) + ## [1.7.125](https://github.com/microsoft/fluentui/tree/@fluentui/react-monaco-editor_v1.7.125) Mon, 11 Sep 2023 07:35:28 GMT diff --git a/packages/react-monaco-editor/package.json b/packages/react-monaco-editor/package.json index f454360200259..be087c5218532 100644 --- a/packages/react-monaco-editor/package.json +++ b/packages/react-monaco-editor/package.json @@ -1,6 +1,6 @@ { "name": "@fluentui/react-monaco-editor", - "version": "1.7.125", + "version": "1.7.126", "description": "Live React example editing using monaco", "main": "lib-commonjs/index.js", "module": "lib/index.js", @@ -35,7 +35,7 @@ "@fluentui/example-data": "^8.4.12", "@fluentui/monaco-editor": "^1.3.11", "@fluentui/react-hooks": "^8.6.29", - "@fluentui/react-charting": "^5.17.7", + "@fluentui/react-charting": "^5.17.8", "raw-loader": "4.0.2", "react-syntax-highlighter": "^10.1.3", "tslib": "^2.1.0"