Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] chore(xplat): Hook up Dropdown to cross-platform-adapter #30981

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/xplat-v9/StrictDomDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

import { Label } from '@fluentui/react-label';
import { Dropdown, Option } from '@fluentui/react-combobox';
import { mergeClasses, makeStyles, shorthands } from '@fluentui/react-platform-adapter-preview';
import { FluentProvider } from '@fluentui/react-provider';
import { tokens, webLightTheme } from '@fluentui/react-theme';
Expand All @@ -24,6 +25,12 @@ export const StrictDomDemo = () => {
return (
<FluentProvider theme={webLightTheme} className={mergeClasses(classNames.root)}>
<Label required>Label</Label>
<h1>Dropdown</h1>
<Dropdown inlinePopup>
<Option>Option 1</Option>
<Option>Option 2</Option>
<Option>Option 3</Option>
</Dropdown>
<ButtonStories />
</FluentProvider>
);
Expand Down
1 change: 1 addition & 0 deletions apps/xplat-v9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@fluentui/react-button": "*",
"@fluentui/react-combobox": "*",
"@fluentui/react-jsx-runtime": "*",
"@fluentui/react-label": "*",
"@fluentui/react-platform-adapter-preview": "*",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
"@types/jest-axe/axe-core": "4.7.2",
"eslint": "7.25.0",
"@mdx-js/loader/loader-utils": "~2.0.4",
"scheduler": "^0.20.2",
"swc-loader": "^0.2.3",
"prettier": "2.8.8",
"puppeteer": "19.6.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/react-components/react-aria/etc/react-aria.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

/// <reference types="react" />

import type { AnnounceContextValue } from '@fluentui/react-shared-contexts';
import type { ExtractSlotProps } from '@fluentui/react-utilities';
import * as React_2 from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export function useActiveDescendant<TActiveParentElement extends HTMLElement, TL
const attributeVisibilityRef = React.useRef(true);

const removeAttribute = React.useCallback(() => {
activeParentRef.current?.removeAttribute('aria-activedescendant');
activeParentRef.current?.removeAttribute?.('aria-activedescendant');
}, []);
const setAttribute = React.useCallback((id?: string) => {
if (id) {
activeIdRef.current = id;
}
if (attributeVisibilityRef.current && activeIdRef.current) {
activeParentRef.current?.setAttribute('aria-activedescendant', activeIdRef.current);
activeParentRef.current?.setAttribute?.('aria-activedescendant', activeIdRef.current);
}
}, []);

Expand All @@ -35,9 +35,9 @@ export function useActiveDescendant<TActiveParentElement extends HTMLElement, TL
}

if (isNavigatingWithKeyboard) {
active.setAttribute(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE, '');
active.setAttribute?.(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE, '');
} else {
active.removeAttribute(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE);
active.removeAttribute?.(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE);
}
});

Expand All @@ -51,8 +51,8 @@ export function useActiveDescendant<TActiveParentElement extends HTMLElement, TL
const blurActiveDescendant = React.useCallback(() => {
const active = getActiveDescendant();
if (active) {
active.removeAttribute(ACTIVEDESCENDANT_ATTRIBUTE);
active.removeAttribute(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE);
active.removeAttribute?.(ACTIVEDESCENDANT_ATTRIBUTE);
active.removeAttribute?.(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE);
}

removeAttribute();
Expand All @@ -69,10 +69,10 @@ export function useActiveDescendant<TActiveParentElement extends HTMLElement, TL

scrollIntoView(nextActive, listboxRef.current);
setAttribute(nextActive.id);
nextActive.setAttribute(ACTIVEDESCENDANT_ATTRIBUTE, '');
nextActive.setAttribute?.(ACTIVEDESCENDANT_ATTRIBUTE, '');

if (focusVisibleRef.current) {
nextActive.setAttribute(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE, '');
nextActive.setAttribute?.(ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE, '');
}
},
[listboxRef, blurActiveDescendant, setAttribute],
Expand Down
2 changes: 2 additions & 0 deletions packages/react-components/react-card/etc/react-card.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

/// <reference types="react" />

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
Expand Down
1 change: 1 addition & 0 deletions packages/react-components/react-combobox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@fluentui/react-field": "^9.1.58",
"@fluentui/react-icons": "^2.0.224",
"@fluentui/react-jsx-runtime": "^9.0.34",
"@fluentui/react-platform-adapter-preview": "^0.0.0",
"@fluentui/react-portal": "^9.4.18",
"@fluentui/react-positioning": "^9.14.2",
"@fluentui/react-shared-contexts": "^9.15.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import { useActiveDescendant } from '@fluentui/react-aria';
import { useFieldControlProps_unstable } from '@fluentui/react-field';
import { ChevronDownRegular as ChevronDownIcon, DismissRegular as DismissIcon } from '@fluentui/react-icons';
import {
ChevronDownRegular as ChevronDownIcon,
DismissRegular as DismissIcon,
} from '@fluentui/react-platform-adapter-preview';
import {
getPartitionedNativeProps,
mergeCallbacks,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tokens, typographyStyles } from '@fluentui/react-theme';
import { SlotClassNames } from '@fluentui/react-utilities';
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
import { makeStyles, mergeClasses, shorthands } from '@fluentui/react-platform-adapter-preview';
import { iconSizes } from '../../utils/internalTokens';
import type { ComboboxSlots, ComboboxState } from './Combobox.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import { useFieldControlProps_unstable } from '@fluentui/react-field';
import { useActiveDescendant } from '@fluentui/react-aria';
import { ChevronDownRegular as ChevronDownIcon, DismissRegular as DismissIcon } from '@fluentui/react-icons';
import {
ChevronDownRegular as ChevronDownIcon,
DismissRegular as DismissIcon,
} from '@fluentui/react-platform-adapter-preview';
import {
getPartitionedNativeProps,
mergeCallbacks,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createFocusOutlineStyle } from '@fluentui/react-tabster';
import { tokens, typographyStyles } from '@fluentui/react-theme';
import { SlotClassNames } from '@fluentui/react-utilities';
import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';
import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@fluentui/react-platform-adapter-preview';
import { iconSizes } from '../../utils/internalTokens';
import type { DropdownSlots, DropdownState } from './Dropdown.types';

Expand Down Expand Up @@ -239,12 +239,12 @@ const useIconStyles = makeStyles({
const useBaseClearButtonStyle = makeResetStyles({
alignSelf: 'center',
backgroundColor: tokens.colorTransparentBackground,
border: 'none',
...shorthands.borderStyle('none'),
cursor: 'pointer',
height: 'fit-content',
margin: 0,
...shorthands.margin(0),
marginRight: tokens.spacingHorizontalMNudge,
padding: 0,
...shorthands.padding(0),
position: 'relative',

...createFocusOutlineStyle(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { getIntrinsicElementProps, useId, useMergedRefs, slot } from '@fluentui/react-utilities';
import { useActiveDescendantContext } from '@fluentui/react-aria';
import { CheckmarkFilled, Checkmark12Filled } from '@fluentui/react-icons';
import { CheckmarkFilled, Checkmark12Filled } from '@fluentui/react-platform-adapter-preview';
import { useListboxContext_unstable } from '../../contexts/ListboxContext';
import type { OptionValue } from '../../utils/OptionCollection.types';
import type { OptionProps, OptionState } from './Option.types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { tokens } from '@fluentui/react-theme';
import { SlotClassNames } from '@fluentui/react-utilities';
import { ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from '@fluentui/react-aria';
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
import { makeStyles, mergeClasses, shorthands } from '@fluentui/react-platform-adapter-preview';
import type { OptionSlots, OptionState } from './Option.types';

export const optionClassNames: SlotClassNames<OptionSlots> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tokens } from '@fluentui/react-theme';
import { SlotClassNames } from '@fluentui/react-utilities';
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
import { makeStyles, mergeClasses, shorthands } from '@fluentui/react-platform-adapter-preview';
import type { OptionGroupSlots, OptionGroupState } from './OptionGroup.types';

export const optionGroupClassNames: SlotClassNames<OptionGroupSlots> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

/// <reference types="react" />

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

/// <reference types="react" />

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

/// <reference types="react" />

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-components/react-link/etc/react-link.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

/// <reference types="react" />

import { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';
import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

```ts

/// <reference types="react" />

import { Checkmark12Filled } from '@fluentui/react-icons';
import { CheckmarkFilled } from '@fluentui/react-icons';
import { ChevronDownRegular } from '@fluentui/react-icons';
import { DismissRegular } from '@fluentui/react-icons';
import type { GriffelStyle } from '@griffel/react';
import { makeStyles } from '@griffel/react';
import { makeStyles as makeStylesCore } from '@griffel/core';
Expand All @@ -15,6 +21,14 @@ import { TextDirectionProvider } from '@griffel/react';
import type { Theme } from '@fluentui/react-theme';
import { useRenderer_unstable } from '@griffel/react';

export { Checkmark12Filled }

export { CheckmarkFilled }

export { ChevronDownRegular }

export { DismissRegular }

// @public (undocumented)
export const getStylesFromClassName: (className: string) => {
[key: string]: unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@stylexjs/stylex": "^0.5.1"
},
"dependencies": {
"@fluentui/react-icons": "^2.0.224",
"@fluentui/react-shared-contexts": "^9.15.2",
"@fluentui/react-theme": "^9.1.19",
"@griffel/core": "^1.14.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { html } from 'react-strict-dom';

// TODO create real wrappers for svg icons
export const Checkmark12Filled = html.span;
export const CheckmarkFilled = html.span;
export const ChevronDownRegular = html.span;
export const DismissRegular = html.span;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Checkmark12Filled, CheckmarkFilled, ChevronDownRegular, DismissRegular } from '@fluentui/react-icons';
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { XPlatProvider, suppressCssVariableInsertion } from './XPlatProvider/XPlatProvider';
export type { XPlatProviderProps } from './XPlatProvider/XPlatProvider.types';
export { Checkmark12Filled, CheckmarkFilled, ChevronDownRegular, DismissRegular } from './icons/icons';
export { jsxPlatformAdapter } from './jsx/jsxPlatformAdapter';
export { getStylesFromClassName } from './styling/classNameMap';
export { makeResetStyles } from './styling/makeResetStyles';
Expand Down
Loading
Loading