From a6dac878b10f8d9ef49385f41350a516b14c05dd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 20:47:49 +0000 Subject: [PATCH] Changes before error encountered Agent-Logs-Url: https://github.com/behowell/fluentui/sessions/5f08b0db-2d83-4a84-aa1a-037df26ec2d6 --- .github/CODEOWNERS | 2 + .../library/.babelrc.json | 4 ++ .../react-file-upload-preview/library/.swcrc | 30 +++++++++ .../react-file-upload-preview/library/LICENSE | 15 +++++ .../library/README.md | 5 ++ .../library/config/api-extractor.json | 5 ++ .../library/config/tests.js | 1 + .../library/docs/Spec.md | 63 +++++++++++++++++++ .../library/eslint.config.js | 5 ++ .../etc/react-file-upload-preview.api.md | 0 .../library/jest.config.js | 34 ++++++++++ .../library/package.json | 50 +++++++++++++++ .../library/project.json | 8 +++ .../library/src/FileUpload.ts | 8 +++ .../components/FileUpload/FileUpload.test.tsx | 18 ++++++ .../src/components/FileUpload/FileUpload.tsx | 29 +++++++++ .../components/FileUpload/FileUpload.types.ts | 17 +++++ .../src/components/FileUpload/index.ts | 5 ++ .../FileUpload/renderFileUpload.tsx | 16 +++++ .../components/FileUpload/useFileUpload.ts | 31 +++++++++ .../FileUpload/useFileUploadStyles.styles.ts | 36 +++++++++++ .../library/src/index.ts | 8 +++ .../library/src/testing/isConformant.ts | 15 +++++ .../library/tsconfig.json | 22 +++++++ .../library/tsconfig.lib.json | 22 +++++++ .../library/tsconfig.spec.json | 17 +++++ .../stories/.storybook/main.js | 14 +++++ .../stories/.storybook/preview.js | 9 +++ .../stories/.storybook/tsconfig.json | 10 +++ .../stories/README.md | 17 +++++ .../stories/eslint.config.js | 10 +++ .../stories/package.json | 6 ++ .../stories/project.json | 8 +++ .../stories/src/.gitkeep | 0 .../src/FileUpload/FileUploadBestPractices.md | 5 ++ .../FileUpload/FileUploadDefault.stories.tsx | 4 ++ .../src/FileUpload/FileUploadDescription.md | 0 .../stories/src/FileUpload/index.stories.tsx | 18 ++++++ .../stories/src/index.ts | 1 + .../stories/tsconfig.json | 22 +++++++ .../stories/tsconfig.lib.json | 10 +++ tsconfig.base.all.json | 14 +++-- tsconfig.base.json | 6 ++ 43 files changed, 616 insertions(+), 4 deletions(-) create mode 100644 packages/react-components/react-file-upload-preview/library/.babelrc.json create mode 100644 packages/react-components/react-file-upload-preview/library/.swcrc create mode 100644 packages/react-components/react-file-upload-preview/library/LICENSE create mode 100644 packages/react-components/react-file-upload-preview/library/README.md create mode 100644 packages/react-components/react-file-upload-preview/library/config/api-extractor.json create mode 100644 packages/react-components/react-file-upload-preview/library/config/tests.js create mode 100644 packages/react-components/react-file-upload-preview/library/docs/Spec.md create mode 100644 packages/react-components/react-file-upload-preview/library/eslint.config.js create mode 100644 packages/react-components/react-file-upload-preview/library/etc/react-file-upload-preview.api.md create mode 100644 packages/react-components/react-file-upload-preview/library/jest.config.js create mode 100644 packages/react-components/react-file-upload-preview/library/package.json create mode 100644 packages/react-components/react-file-upload-preview/library/project.json create mode 100644 packages/react-components/react-file-upload-preview/library/src/FileUpload.ts create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.test.tsx create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.tsx create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.types.ts create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/index.ts create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/renderFileUpload.tsx create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUpload.ts create mode 100644 packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUploadStyles.styles.ts create mode 100644 packages/react-components/react-file-upload-preview/library/src/index.ts create mode 100644 packages/react-components/react-file-upload-preview/library/src/testing/isConformant.ts create mode 100644 packages/react-components/react-file-upload-preview/library/tsconfig.json create mode 100644 packages/react-components/react-file-upload-preview/library/tsconfig.lib.json create mode 100644 packages/react-components/react-file-upload-preview/library/tsconfig.spec.json create mode 100644 packages/react-components/react-file-upload-preview/stories/.storybook/main.js create mode 100644 packages/react-components/react-file-upload-preview/stories/.storybook/preview.js create mode 100644 packages/react-components/react-file-upload-preview/stories/.storybook/tsconfig.json create mode 100644 packages/react-components/react-file-upload-preview/stories/README.md create mode 100644 packages/react-components/react-file-upload-preview/stories/eslint.config.js create mode 100644 packages/react-components/react-file-upload-preview/stories/package.json create mode 100644 packages/react-components/react-file-upload-preview/stories/project.json create mode 100644 packages/react-components/react-file-upload-preview/stories/src/.gitkeep create mode 100644 packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadBestPractices.md create mode 100644 packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDefault.stories.tsx create mode 100644 packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDescription.md create mode 100644 packages/react-components/react-file-upload-preview/stories/src/FileUpload/index.stories.tsx create mode 100644 packages/react-components/react-file-upload-preview/stories/src/index.ts create mode 100644 packages/react-components/react-file-upload-preview/stories/tsconfig.json create mode 100644 packages/react-components/react-file-upload-preview/stories/tsconfig.lib.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4036f2094b3c55..54650fc8c3397e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -334,6 +334,8 @@ packages/react-components/react-menu-grid-preview/library @microsoft/teams-prg packages/react-components/react-menu-grid-preview/stories @microsoft/teams-prg packages/react-components/react-headless-components-preview/library @microsoft/cxe-prg packages/react-components/react-headless-components-preview/stories @microsoft/cxe-prg +packages/react-components/react-file-upload-preview/library @microsoft/cxe-prg +packages/react-components/react-file-upload-preview/stories @microsoft/cxe-prg # <%= NX-CODEOWNER-PLACEHOLDER %> # Deprecated v9 packages - exposed as part of `/unstable` api diff --git a/packages/react-components/react-file-upload-preview/library/.babelrc.json b/packages/react-components/react-file-upload-preview/library/.babelrc.json new file mode 100644 index 00000000000000..630deaf765c49f --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/.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-file-upload-preview/library/.swcrc b/packages/react-components/react-file-upload-preview/library/.swcrc new file mode 100644 index 00000000000000..b4ffa86dee3067 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/.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-file-upload-preview/library/LICENSE b/packages/react-components/react-file-upload-preview/library/LICENSE new file mode 100644 index 00000000000000..f149fb4d54431b --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/LICENSE @@ -0,0 +1,15 @@ +@fluentui/react-file-upload-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-file-upload-preview/library/README.md b/packages/react-components/react-file-upload-preview/library/README.md new file mode 100644 index 00000000000000..89cd0bfcb215f2 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/README.md @@ -0,0 +1,5 @@ +# @fluentui/react-file-upload-preview + +**React File Upload 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-file-upload-preview/library/config/api-extractor.json b/packages/react-components/react-file-upload-preview/library/config/api-extractor.json new file mode 100644 index 00000000000000..8d482156d10d53 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/config/api-extractor.json @@ -0,0 +1,5 @@ +{ + "$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", + "mainEntryPointFilePath": "/../../../../../../dist/out-tsc/types/packages/react-components//library/src/index.d.ts" +} diff --git a/packages/react-components/react-file-upload-preview/library/config/tests.js b/packages/react-components/react-file-upload-preview/library/config/tests.js new file mode 100644 index 00000000000000..2e211ae9e21420 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/config/tests.js @@ -0,0 +1 @@ +/** Jest test setup file. */ diff --git a/packages/react-components/react-file-upload-preview/library/docs/Spec.md b/packages/react-components/react-file-upload-preview/library/docs/Spec.md new file mode 100644 index 00000000000000..cdff698df18246 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/docs/Spec.md @@ -0,0 +1,63 @@ +# @fluentui/react-file-upload-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-file-upload-preview/library/eslint.config.js b/packages/react-components/react-file-upload-preview/library/eslint.config.js new file mode 100644 index 00000000000000..ec2e7cb1fc479f --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/eslint.config.js @@ -0,0 +1,5 @@ +// @ts-check + +const fluentPlugin = require('@fluentui/eslint-plugin'); + +module.exports = [...fluentPlugin.configs['flat/react']]; diff --git a/packages/react-components/react-file-upload-preview/library/etc/react-file-upload-preview.api.md b/packages/react-components/react-file-upload-preview/library/etc/react-file-upload-preview.api.md new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/packages/react-components/react-file-upload-preview/library/jest.config.js b/packages/react-components/react-file-upload-preview/library/jest.config.js new file mode 100644 index 00000000000000..113891f7f2dcf9 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/jest.config.js @@ -0,0 +1,34 @@ +// @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; + +/** + * @type {import('@jest/types').Config.InitialOptions} + */ +module.exports = { + displayName: 'react-file-upload-preview', + preset: '../../../../jest.preset.js', + transform: { + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], + }, + coverageDirectory: './coverage', + setupFilesAfterEnv: ['./config/tests.js'], + snapshotSerializers: ['@griffel/jest-serializer'], +}; diff --git a/packages/react-components/react-file-upload-preview/library/package.json b/packages/react-components/react-file-upload-preview/library/package.json new file mode 100644 index 00000000000000..2ef912213c0890 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/package.json @@ -0,0 +1,50 @@ +{ + "name": "@fluentui/react-file-upload-preview", + "version": "0.0.0", + "private": true, + "description": "New fluentui react package", + "main": "lib-commonjs/index.js", + "module": "lib/index.js", + "typings": "./dist/index.d.ts", + "sideEffects": false, + "files": [ + "*.md", + "dist/*.d.ts", + "lib", + "lib-commonjs" + ], + "repository": { + "type": "git", + "url": "https://github.com/microsoft/fluentui" + }, + "license": "MIT", + "dependencies": { + "@fluentui/react-jsx-runtime": "^9.4.3", + "@fluentui/react-shared-contexts": "^9.26.2", + "@fluentui/react-theme": "^9.2.1", + "@fluentui/react-utilities": "^9.26.4", + "@griffel/react": "^1.5.32", + "@swc/helpers": "^0.5.1" + }, + "peerDependencies": { + "@types/react": ">=16.14.0 <19.0.0", + "@types/react-dom": ">=16.9.0 <19.0.0", + "react": ">=16.14.0 <19.0.0", + "react-dom": ">=16.14.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-file-upload-preview/library/project.json b/packages/react-components/react-file-upload-preview/library/project.json new file mode 100644 index 00000000000000..c9c702bd468dd4 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/project.json @@ -0,0 +1,8 @@ +{ + "name": "react-file-upload-preview", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "packages/react-components/react-file-upload-preview/library/src", + "tags": ["platform:web", "vNext"], + "implicitDependencies": [] +} diff --git a/packages/react-components/react-file-upload-preview/library/src/FileUpload.ts b/packages/react-components/react-file-upload-preview/library/src/FileUpload.ts new file mode 100644 index 00000000000000..a6b4d7dedb39ac --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/FileUpload.ts @@ -0,0 +1,8 @@ +export { + fileUploadClassNames, + FileUpload, + renderFileUpload_unstable, + useFileUpload_unstable, + useFileUploadStyles_unstable, +} from './components/FileUpload/index'; +export type { FileUploadProps, FileUploadState } from './components/FileUpload/index'; diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.test.tsx b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.test.tsx new file mode 100644 index 00000000000000..806feae19117f9 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.test.tsx @@ -0,0 +1,18 @@ +import * as React from 'react'; +import { render } from '@testing-library/react'; +import { isConformant } from '../../testing/isConformant'; +import { FileUpload } from './FileUpload'; + +describe('FileUpload', () => { + isConformant({ + Component: FileUpload, + displayName: 'FileUpload', + }); + + // TODO add more tests here, and create visual regression tests in /apps/vr-tests + + it('renders a default state', () => { + const result = render(Default FileUpload); + expect(result.container).toMatchSnapshot(); + }); +}); diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.tsx b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.tsx new file mode 100644 index 00000000000000..3f101e84a132b0 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.tsx @@ -0,0 +1,29 @@ +import * as React from 'react'; +import type { ForwardRefComponent } from '@fluentui/react-utilities'; +import { useFileUpload_unstable } from './useFileUpload'; +import { renderFileUpload_unstable } from './renderFileUpload'; +import { useFileUploadStyles_unstable } from './useFileUploadStyles.styles'; +import type { FileUploadProps } from './FileUpload.types'; + +/** + * FileUpload component - TODO: add more docs + */ +export const FileUpload: ForwardRefComponent = React.forwardRef((props, ref) => { + const state = useFileUpload_unstable(props, ref); + + useFileUploadStyles_unstable(state); + + /** + * @see https://github.com/microsoft/fluentui/blob/master/docs/react-v9/contributing/rfcs/react-components/convergence/custom-styling.md + * + * TODO: 💡 once package will become stable (PR which will be part of promoting PREVIEW package to STABLE), + * - uncomment this line + * - update types {@link file://./../../../../../../../packages/react-components/react-shared-contexts/library/src/CustomStyleHooksContext/CustomStyleHooksContext.ts#CustomStyleHooksContextValue} + * - verify that custom global style override works for your component + */ + // useCustomStyleHook_unstable('useFileUploadStyles_unstable')(state); + + return renderFileUpload_unstable(state); +}); + +FileUpload.displayName = 'FileUpload'; diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.types.ts b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.types.ts new file mode 100644 index 00000000000000..a062230e8b2e91 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/FileUpload.types.ts @@ -0,0 +1,17 @@ +import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities'; + +export type FileUploadSlots = { + root: Slot<'div'>; +}; + +/** + * FileUpload Props + */ +export type FileUploadProps = ComponentProps & {}; + +/** + * State used in rendering FileUpload + */ +export type FileUploadState = ComponentState; +// TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from FileUploadProps. +// & Required> diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/index.ts b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/index.ts new file mode 100644 index 00000000000000..ae0f5f9fef5311 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/index.ts @@ -0,0 +1,5 @@ +export { FileUpload } from './FileUpload'; +export type { FileUploadProps, FileUploadState } from './FileUpload.types'; +export { renderFileUpload_unstable } from './renderFileUpload'; +export { useFileUpload_unstable } from './useFileUpload'; +export { fileUploadClassNames, useFileUploadStyles_unstable } from './useFileUploadStyles.styles'; diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/renderFileUpload.tsx b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/renderFileUpload.tsx new file mode 100644 index 00000000000000..9b56f682a19cc5 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/renderFileUpload.tsx @@ -0,0 +1,16 @@ +/** @jsxRuntime automatic */ +/** @jsxImportSource @fluentui/react-jsx-runtime */ + +import { assertSlots } from '@fluentui/react-utilities'; +import type { JSXElement } from '@fluentui/react-utilities'; +import type { FileUploadState, FileUploadSlots } from './FileUpload.types'; + +/** + * Render the final JSX of FileUpload + */ +export const renderFileUpload_unstable = (state: FileUploadState): JSXElement => { + assertSlots(state); + + // TODO Add additional slots in the appropriate place + return ; +}; diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUpload.ts b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUpload.ts new file mode 100644 index 00000000000000..4122f4fda9e8bf --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUpload.ts @@ -0,0 +1,31 @@ +import * as React from 'react'; +import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities'; +import type { FileUploadProps, FileUploadState } from './FileUpload.types'; + +/** + * Create the state required to render FileUpload. + * + * The returned state can be modified with hooks such as useFileUploadStyles_unstable, + * before being passed to renderFileUpload_unstable. + * + * @param props - props from this instance of FileUpload + * @param ref - reference to root HTMLDivElement of FileUpload + */ +export const useFileUpload_unstable = (props: FileUploadProps, ref: React.Ref): FileUploadState => { + 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( + getIntrinsicElementProps('div', { + ref, + ...props, + }), + { elementType: 'div' }, + ), + }; +}; diff --git a/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUploadStyles.styles.ts b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUploadStyles.styles.ts new file mode 100644 index 00000000000000..8e828f308f4cfd --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/components/FileUpload/useFileUploadStyles.styles.ts @@ -0,0 +1,36 @@ +import { makeStyles, mergeClasses } from '@griffel/react'; +import type { SlotClassNames } from '@fluentui/react-utilities'; +import type { FileUploadSlots, FileUploadState } from './FileUpload.types'; + +export const fileUploadClassNames: SlotClassNames = { + root: 'fui-FileUpload', + // TODO: add class names for all slots on FileUploadSlots. + // Should be of the form `: 'fui-FileUpload__` +}; + +/** + * 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 FileUpload slots based on the state + */ +export const useFileUploadStyles_unstable = (state: FileUploadState): FileUploadState => { + 'use no memo'; + + const styles = useStyles(); + // eslint-disable-next-line react-hooks/immutability + state.root.className = mergeClasses(fileUploadClassNames.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-file-upload-preview/library/src/index.ts b/packages/react-components/react-file-upload-preview/library/src/index.ts new file mode 100644 index 00000000000000..f4554319a02893 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/src/index.ts @@ -0,0 +1,8 @@ +export { + fileUploadClassNames, + FileUpload, + renderFileUpload_unstable, + useFileUpload_unstable, + useFileUploadStyles_unstable, +} from './FileUpload'; +export type { FileUploadProps, FileUploadState } from './FileUpload'; diff --git a/packages/react-components/react-file-upload-preview/library/src/testing/isConformant.ts b/packages/react-components/react-file-upload-preview/library/src/testing/isConformant.ts new file mode 100644 index 00000000000000..8ed2da0f925135 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/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 }, +): void { + 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-file-upload-preview/library/tsconfig.json b/packages/react-components/react-file-upload-preview/library/tsconfig.json new file mode 100644 index 00000000000000..32bdbdf1ac26f0 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/tsconfig.json @@ -0,0 +1,22 @@ +{ + "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" + } + ] +} diff --git a/packages/react-components/react-file-upload-preview/library/tsconfig.lib.json b/packages/react-components/react-file-upload-preview/library/tsconfig.lib.json new file mode 100644 index 00000000000000..53066fdd11fff0 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/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-file-upload-preview/library/tsconfig.spec.json b/packages/react-components/react-file-upload-preview/library/tsconfig.spec.json new file mode 100644 index 00000000000000..911456fe4b4d91 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/library/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/packages/react-components/react-file-upload-preview/stories/.storybook/main.js b/packages/react-components/react-file-upload-preview/stories/.storybook/main.js new file mode 100644 index 00000000000000..67905c6bfe15f2 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/.storybook/main.js @@ -0,0 +1,14 @@ +const rootMain = require('../../../../../.storybook/main'); + +module.exports = /** @type {Omit} */ ({ + ...rootMain, + stories: [...rootMain.stories, '../src/**/*.mdx', '../src/**/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-file-upload-preview/stories/.storybook/preview.js b/packages/react-components/react-file-upload-preview/stories/.storybook/preview.js new file mode 100644 index 00000000000000..98274ed0b8095f --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/.storybook/preview.js @@ -0,0 +1,9 @@ +import * as rootPreview from '../../../../../.storybook/preview'; + +/** @type {typeof rootPreview.decorators} */ +export const decorators = [...rootPreview.decorators]; + +/** @type {typeof rootPreview.parameters} */ +export const parameters = { ...rootPreview.parameters }; + +export const tags = ['autodocs']; diff --git a/packages/react-components/react-file-upload-preview/stories/.storybook/tsconfig.json b/packages/react-components/react-file-upload-preview/stories/.storybook/tsconfig.json new file mode 100644 index 00000000000000..4cdd1ce9d006f1 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/.storybook/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "", + "allowJs": true, + "checkJs": true, + "types": ["static-assets", "environment"] + }, + "include": ["*.js"] +} diff --git a/packages/react-components/react-file-upload-preview/stories/README.md b/packages/react-components/react-file-upload-preview/stories/README.md new file mode 100644 index 00000000000000..ad6c3d77d59ed1 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/README.md @@ -0,0 +1,17 @@ +# @fluentui/react-file-upload-preview-stories + +Storybook stories for packages/react-components/react-file-upload-preview + +## Usage + +To include within storybook specify stories globs: + +\`\`\`js +module.exports = { +stories: ['../packages/react-components/react-file-upload-preview/stories/src/**/*.mdx', '../packages/react-components/react-file-upload-preview/stories/src/**/index.stories.@(ts|tsx)'], +} +\`\`\` + +## API + +no public API available diff --git a/packages/react-components/react-file-upload-preview/stories/eslint.config.js b/packages/react-components/react-file-upload-preview/stories/eslint.config.js new file mode 100644 index 00000000000000..f8362c3e413031 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/eslint.config.js @@ -0,0 +1,10 @@ +// @ts-check + +const fluentPlugin = require('@fluentui/eslint-plugin'); + +module.exports = [ + ...fluentPlugin.configs['flat/react'], + { + rules: {}, + }, +]; diff --git a/packages/react-components/react-file-upload-preview/stories/package.json b/packages/react-components/react-file-upload-preview/stories/package.json new file mode 100644 index 00000000000000..4b9bf4f44e6b54 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/package.json @@ -0,0 +1,6 @@ +{ + "name": "@fluentui/react-file-upload-preview-stories", + "version": "0.0.0", + "private": true, + "devDependencies": {} +} diff --git a/packages/react-components/react-file-upload-preview/stories/project.json b/packages/react-components/react-file-upload-preview/stories/project.json new file mode 100644 index 00000000000000..ffd64b49c12795 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/project.json @@ -0,0 +1,8 @@ +{ + "name": "react-file-upload-preview-stories", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "packages/react-components/react-file-upload-preview/stories/src", + "tags": ["vNext", "platform:web", "type:stories"], + "implicitDependencies": [] +} diff --git a/packages/react-components/react-file-upload-preview/stories/src/.gitkeep b/packages/react-components/react-file-upload-preview/stories/src/.gitkeep new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadBestPractices.md b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadBestPractices.md new file mode 100644 index 00000000000000..08ff8ddeeb5f86 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadBestPractices.md @@ -0,0 +1,5 @@ +## Best practices + +### Do + +### Don't diff --git a/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDefault.stories.tsx b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDefault.stories.tsx new file mode 100644 index 00000000000000..e75cd2ad5201a2 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDefault.stories.tsx @@ -0,0 +1,4 @@ +import * as React from 'react'; +import { FileUpload, FileUploadProps } from '@fluentui/react-file-upload-preview'; + +export const Default = (props: Partial) => ; diff --git a/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDescription.md b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/FileUploadDescription.md new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/packages/react-components/react-file-upload-preview/stories/src/FileUpload/index.stories.tsx b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/index.stories.tsx new file mode 100644 index 00000000000000..93cd0493f5853c --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/src/FileUpload/index.stories.tsx @@ -0,0 +1,18 @@ +import { FileUpload } from '@fluentui/react-file-upload-preview'; + +import descriptionMd from './FileUploadDescription.md'; +import bestPracticesMd from './FileUploadBestPractices.md'; + +export { Default } from './FileUploadDefault.stories'; + +export default { + title: 'Preview Components/FileUpload', + component: FileUpload, + parameters: { + docs: { + description: { + component: [descriptionMd, bestPracticesMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-components/react-file-upload-preview/stories/src/index.ts b/packages/react-components/react-file-upload-preview/stories/src/index.ts new file mode 100644 index 00000000000000..cb0ff5c3b541f6 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/src/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/react-components/react-file-upload-preview/stories/tsconfig.json b/packages/react-components/react-file-upload-preview/stories/tsconfig.json new file mode 100644 index 00000000000000..efc50169d1df18 --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/tsconfig.json @@ -0,0 +1,22 @@ +{ + "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": "./.storybook/tsconfig.json" + } + ] +} diff --git a/packages/react-components/react-file-upload-preview/stories/tsconfig.lib.json b/packages/react-components/react-file-upload-preview/stories/tsconfig.lib.json new file mode 100644 index 00000000000000..9486b224643d9f --- /dev/null +++ b/packages/react-components/react-file-upload-preview/stories/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "lib": ["ES2019", "dom"], + "outDir": "../../../../dist/out-tsc", + "inlineSources": true, + "types": ["static-assets", "environment"] + }, + "include": ["./src/**/*.ts", "./src/**/*.tsx"] +} diff --git a/tsconfig.base.all.json b/tsconfig.base.all.json index 8d5d5cf60d08e6..3d94c973a1439e 100644 --- a/tsconfig.base.all.json +++ b/tsconfig.base.all.json @@ -121,13 +121,16 @@ "@fluentui/react-drawer-stories": ["packages/react-components/react-drawer/stories/src/index.ts"], "@fluentui/react-field": ["packages/react-components/react-field/library/src/index.ts"], "@fluentui/react-field-stories": ["packages/react-components/react-field/stories/src/index.ts"], - "@fluentui/react-focus-management": ["packages/react-focus-management/src/index.ts"], - "@fluentui/react-headless-components-preview/*": [ - "packages/react-components/react-headless-components-preview/library/src/*.ts" + "@fluentui/react-file-upload-preview": [ + "packages/react-components/react-file-upload-preview/library/src/index.ts" ], + "@fluentui/react-focus-management": ["packages/react-focus-management/src/index.ts"], "@fluentui/react-headless-components-preview-stories": [ "packages/react-components/react-headless-components-preview/stories/src/index.ts" ], + "@fluentui/react-headless-components-preview/*": [ + "packages/react-components/react-headless-components-preview/library/src/*.ts" + ], "@fluentui/react-icons-compat": ["packages/react-components/react-icons-compat/library/src/index.ts"], "@fluentui/react-icons-compat-stories": ["packages/react-components/react-icons-compat/stories/src/index.ts"], "@fluentui/react-image": ["packages/react-components/react-image/library/src/index.ts"], @@ -260,7 +263,10 @@ "@fluentui/tokens": ["packages/tokens/src/index.ts"], "@fluentui/visual-regression-assert": ["tools/visual-regression-assert/src/index.ts"], "@fluentui/visual-regression-utilities": ["tools/visual-regression-utilities/src/index.ts"], - "@fluentui/workspace-plugin": ["tools/workspace-plugin/src/index.ts"] + "@fluentui/workspace-plugin": ["tools/workspace-plugin/src/index.ts"], + "@fluentui/react-file-upload-preview-stories": [ + "packages/react-components/react-file-upload-preview/stories/src/index.ts" + ] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index 58d5e4845e447d..22240936cd0cdc 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -76,6 +76,12 @@ "@fluentui/react-drawer-stories": ["packages/react-components/react-drawer/stories/src/index.ts"], "@fluentui/react-field": ["packages/react-components/react-field/library/src/index.ts"], "@fluentui/react-field-stories": ["packages/react-components/react-field/stories/src/index.ts"], + "@fluentui/react-file-upload-preview": [ + "packages/react-components/react-file-upload-preview/library/src/index.ts" + ], + "@fluentui/react-file-upload-preview-stories": [ + "packages/react-components/react-file-upload-preview/stories/src/index.ts" + ], "@fluentui/react-focus-management": ["packages/react-focus-management/src/index.ts"], "@fluentui/react-headless-components-preview-stories": [ "packages/react-components/react-headless-components-preview/stories/src/index.ts"