Skip to content

Commit 793f176

Browse files
authored
[react-interactions] Make FocusList bundle (#16876)
1 parent 68a87ee commit 793f176

File tree

7 files changed

+37
-17
lines changed

7 files changed

+37
-17
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
'use strict';
11+
12+
module.exports = require('./src/FocusList');

packages/react-interactions/accessibility/src/FocusList.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {ReactScopeMethods} from 'shared/ReactTypes';
10+
import type {ReactScope, ReactScopeMethods} from 'shared/ReactTypes';
1111
import type {KeyboardEvent} from 'react-interactions/events/keyboard';
1212

1313
import React from 'react';
@@ -59,10 +59,8 @@ function getNextListItem(
5959
return null;
6060
}
6161

62-
export function createFocusList(
63-
scopeImpl: (type: string, props: Object) => boolean,
64-
): Array<React.Component> {
65-
const TableScope = React.unstable_createScope(scopeImpl);
62+
export function createFocusList(scope: ReactScope): Array<React.Component> {
63+
const TableScope = React.unstable_createScope(scope.fn);
6664

6765
function List({children, portrait}): FocusListProps {
6866
return (

packages/react-interactions/accessibility/src/FocusTable.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {ReactScopeMethods} from 'shared/ReactTypes';
10+
import type {ReactScope, ReactScopeMethods} from 'shared/ReactTypes';
1111
import type {KeyboardEvent} from 'react-interactions/events/keyboard';
1212

1313
import React from 'react';
@@ -127,10 +127,8 @@ function triggerNavigateOut(
127127
}
128128
}
129129

130-
export function createFocusTable(
131-
scopeImpl: (type: string, props: Object) => boolean,
132-
): Array<React.Component> {
133-
const TableScope = React.unstable_createScope(scopeImpl);
130+
export function createFocusTable(scope: ReactScope): Array<React.Component> {
131+
const TableScope = React.unstable_createScope(scope.fn);
134132

135133
function Table({children, onKeyboardOut, id}): FocusTableProps {
136134
return (

packages/react-interactions/accessibility/src/TabbableScope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import React from 'react';
1111

12-
export const tabFocusableImpl = (type: string, props: Object): boolean => {
12+
const tabFocusableImpl = (type: string, props: Object): boolean => {
1313
if (props.tabIndex === -1 || props.disabled) {
1414
return false;
1515
}

packages/react-interactions/accessibility/src/__tests__/FocusList-test.internal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {createEventTarget} from 'react-interactions/events/src/dom/testing-libra
1212
let React;
1313
let ReactFeatureFlags;
1414
let createFocusList;
15-
let tabFocusableImpl;
15+
let TabbableScope;
1616

1717
describe('FocusList', () => {
1818
beforeEach(() => {
@@ -21,7 +21,7 @@ describe('FocusList', () => {
2121
ReactFeatureFlags.enableScopeAPI = true;
2222
ReactFeatureFlags.enableFlareAPI = true;
2323
createFocusList = require('../FocusList').createFocusList;
24-
tabFocusableImpl = require('../TabbableScope').tabFocusableImpl;
24+
TabbableScope = require('../TabbableScope').default;
2525
React = require('react');
2626
});
2727

@@ -41,7 +41,7 @@ describe('FocusList', () => {
4141
});
4242

4343
function createFocusListComponent() {
44-
const [FocusList, FocusItem] = createFocusList(tabFocusableImpl);
44+
const [FocusList, FocusItem] = createFocusList(TabbableScope);
4545

4646
return ({portrait}) => (
4747
<FocusList portrait={portrait}>

packages/react-interactions/accessibility/src/__tests__/FocusTable-test.internal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {createEventTarget} from 'react-interactions/events/src/dom/testing-libra
1212
let React;
1313
let ReactFeatureFlags;
1414
let createFocusTable;
15-
let tabFocusableImpl;
15+
let TabbableScope;
1616

1717
describe('FocusTable', () => {
1818
beforeEach(() => {
@@ -21,7 +21,7 @@ describe('FocusTable', () => {
2121
ReactFeatureFlags.enableScopeAPI = true;
2222
ReactFeatureFlags.enableFlareAPI = true;
2323
createFocusTable = require('../FocusTable').createFocusTable;
24-
tabFocusableImpl = require('../TabbableScope').tabFocusableImpl;
24+
TabbableScope = require('../TabbableScope').default;
2525
React = require('react');
2626
});
2727

@@ -42,7 +42,7 @@ describe('FocusTable', () => {
4242

4343
function createFocusTableComponent() {
4444
const [FocusTable, FocusTableRow, FocusTableCell] = createFocusTable(
45-
tabFocusableImpl,
45+
TabbableScope,
4646
);
4747

4848
return ({onKeyboardOut, id}) => (

scripts/rollup/bundles.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,18 @@ const bundles = [
706706
global: 'ReactTabbableScope',
707707
externals: ['react'],
708708
},
709+
710+
{
711+
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
712+
moduleType: NON_FIBER_RENDERER,
713+
entry: 'react-interactions/accessibility/focus-list',
714+
global: 'ReactFocusList',
715+
externals: [
716+
'react',
717+
'react-interactions/events/keyboard',
718+
'react-interactions/accessibility/tabbable-scope',
719+
],
720+
},
709721
];
710722

711723
const fbBundleExternalsMap = {

0 commit comments

Comments
 (0)