From 23e92b091a68e30f4e476b435f786aae3e5f3ee1 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Wed, 29 Oct 2025 17:28:33 +0100 Subject: [PATCH] chore(v0): cleanup Refs --- .../ComponentControls/ComponentControls.tsx | 215 +++++++----------- .../Portal/Types/PortalExample.shorthand.tsx | 62 ----- .../PortalExampleFocusTrapped.shorthand.tsx | 75 ------ .../fluentui/react-component-ref/src/Ref.tsx | 2 +- .../react-component-ref/test/Ref-test.tsx | 14 +- .../react-component-ref/test/fixtures.tsx | 6 +- .../src/components/Portal/Portal.tsx | 22 +- .../src/components/Portal/PortalInner.tsx | 11 +- .../src/utils/positioner/Popper.tsx | 9 +- 9 files changed, 125 insertions(+), 291 deletions(-) delete mode 100644 packages/fluentui/docs/src/examples/components/Portal/Types/PortalExample.shorthand.tsx delete mode 100644 packages/fluentui/docs/src/examples/components/Portal/Types/PortalExampleFocusTrapped.shorthand.tsx diff --git a/packages/fluentui/docs/src/components/ComponentDoc/ComponentControls/ComponentControls.tsx b/packages/fluentui/docs/src/components/ComponentDoc/ComponentControls/ComponentControls.tsx index 28bcc697c2a798..fff46455c9d4ac 100644 --- a/packages/fluentui/docs/src/components/ComponentDoc/ComponentControls/ComponentControls.tsx +++ b/packages/fluentui/docs/src/components/ComponentDoc/ComponentControls/ComponentControls.tsx @@ -2,19 +2,10 @@ import * as _ from 'lodash'; import * as React from 'react'; import { NavLink } from 'react-router-dom'; -import { CodeSandboxExporter, CodeSandboxState, CopyToClipboard } from '@fluentui/docs-components'; -import { - AcceptIcon, - CircleIcon, - EditIcon, - IndentIcon, - LinkIcon, - OpenOutsideIcon, -} from '@fluentui/react-icons-northstar'; -import { Loader, Menu, menuAsToolbarBehavior, MenuItem, MenuProps, Tooltip } from '@fluentui/react-northstar'; +import { CopyToClipboard } from '@fluentui/docs-components'; +import { CircleIcon, EditIcon, IndentIcon, LinkIcon, OpenOutsideIcon } from '@fluentui/react-icons-northstar'; +import { Menu, menuAsToolbarBehavior, MenuItem, MenuProps, Tooltip } from '@fluentui/react-northstar'; -import { CodeSandboxIcon } from '../../Icons/CodeSandboxIcon'; -import { imports } from '../../Playground/renderConfig'; import { ComponentSourceManagerLanguage } from '../ComponentSourceManager'; import CodeSnippetIcon from './CodeSnippetIcon'; @@ -54,126 +45,92 @@ const ComponentControls: React.FC = props => { ...rest } = props; - return ( - - {(state, onCodeSandboxClick) => { - const codeSandboxTooltip = - state === CodeSandboxState.Default - ? 'CodeSandbox' - : state === CodeSandboxState.Loading - ? 'Exporting...' - : 'Click to open'; - - const codeSandboxIcon = - state === CodeSandboxState.Default ? ( - - ) : state === CodeSandboxState.Loading ? ( - - ) : ( - - ); + const items: MenuProps['items'] = [ + { + icon: , + onClick: onShowCode, + active: showCode, + children: (Component: typeof MenuItem, props) => ( + } /> + ), + }, - const items: MenuProps['items'] = [ - { - icon: , - onClick: onShowCode, - active: showCode, - children: (Component: typeof MenuItem, props) => ( - } /> - ), - }, + { + icon: , + onClick: onShowVariables, + active: showVariables, + children: (Component: typeof MenuItem, props) => ( + } /> + ), + }, + { + key: 'divider-1', + style: { margin: '0 5px' }, + kind: 'divider', + }, + { + icon: , + onClick: onShowTransparent, + active: showTransparent, + children: (Component: typeof MenuItem, props) => ( + } /> + ), + }, + { + icon: , + onClick: onShowRtl, + active: showRtl, + children: (Component: typeof MenuItem, props) => ( + } /> + ), + }, - { - icon: , - onClick: onShowVariables, - active: showVariables, - children: (Component: typeof MenuItem, props) => ( - } /> - ), - }, - { - key: 'divider-1', - style: { margin: '0 5px' }, - kind: 'divider', - }, - { - icon: , - onClick: onShowTransparent, - active: showTransparent, - children: (Component: typeof MenuItem, props) => ( - } /> - ), - }, - { - icon: , - onClick: onShowRtl, - active: showRtl, - children: (Component: typeof MenuItem, props) => ( - } /> - ), - }, + { + icon: , + children: (Component: typeof MenuItem, props) => ( + } /> + ), + as: NavLink, + to: `/maximize/${_.kebabCase(examplePath.split('/').slice(-1).pop())}/${showRtl}`, + target: '_blank', + rel: 'noopener noreferrer', + }, + { + key: 'divider-2', + style: { margin: '0 5px' }, + kind: 'divider', + }, + { + icon: , + children: (Component: typeof MenuItem, props) => ( + + {(active, onClick) => ( + { + onClick(); + onCopyLink(e); + }} + /> + } + /> + )} + + ), + }, + ]; - { - icon: , - children: (Component: typeof MenuItem, props) => ( - } /> - ), - as: NavLink, - to: `/maximize/${_.kebabCase(examplePath.split('/').slice(-1).pop())}/${showRtl}`, - target: '_blank', - rel: 'noopener noreferrer', - }, - { - key: 'divider-2', - style: { margin: '0 5px' }, - kind: 'divider', - }, - { - onClick: onCodeSandboxClick, - icon: codeSandboxIcon, - children: (Component: typeof MenuItem, props) => ( - } /> - ), - }, - { - icon: , - children: (Component: typeof MenuItem, props) => ( - - {(active, onClick) => ( - { - onClick(); - onCopyLink(e); - }} - /> - } - /> - )} - - ), - }, - ]; - - return ( - - ); - }} - + return ( + ); }; diff --git a/packages/fluentui/docs/src/examples/components/Portal/Types/PortalExample.shorthand.tsx b/packages/fluentui/docs/src/examples/components/Portal/Types/PortalExample.shorthand.tsx deleted file mode 100644 index 45f2bc4a987cc9..00000000000000 --- a/packages/fluentui/docs/src/examples/components/Portal/Types/PortalExample.shorthand.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import * as React from 'react'; -import { Button, Divider, Flex, Header, Label, Portal } from '@fluentui/react-northstar'; - -class PortalExamplePortal extends React.Component { - state = { log: [], logCount: 0 }; - - handleClick = () => - this.setState({ - log: [`${new Date().toLocaleTimeString()}: handleClick`, ...this.state.log].slice(0, 20), - logCount: this.state.logCount + 1, - }); - - clearLog = () => this.setState({ log: [], logCount: 0 }); - - render() { - const { log, logCount } = this.state; - - return ( -
- -
This is a basic portal
-

Portals have tons of great callback functions to hook into.

-

To close, simply click the close button or click away

-
- } - trigger={