Skip to content

Commit

Permalink
[react-interactions] Make FocusList bundle (#16876)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Sep 24, 2019
1 parent 68a87ee commit 793f176
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 17 deletions.
12 changes: 12 additions & 0 deletions packages/react-interactions/accessibility/focus-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

'use strict';

module.exports = require('./src/FocusList');
8 changes: 3 additions & 5 deletions packages/react-interactions/accessibility/src/FocusList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

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

import React from 'react';
Expand Down Expand Up @@ -59,10 +59,8 @@ function getNextListItem(
return null;
}

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

function List({children, portrait}): FocusListProps {
return (
Expand Down
8 changes: 3 additions & 5 deletions packages/react-interactions/accessibility/src/FocusTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

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

import React from 'react';
Expand Down Expand Up @@ -127,10 +127,8 @@ function triggerNavigateOut(
}
}

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

function Table({children, onKeyboardOut, id}): FocusTableProps {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import React from 'react';

export const tabFocusableImpl = (type: string, props: Object): boolean => {
const tabFocusableImpl = (type: string, props: Object): boolean => {
if (props.tabIndex === -1 || props.disabled) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {createEventTarget} from 'react-interactions/events/src/dom/testing-libra
let React;
let ReactFeatureFlags;
let createFocusList;
let tabFocusableImpl;
let TabbableScope;

describe('FocusList', () => {
beforeEach(() => {
Expand All @@ -21,7 +21,7 @@ describe('FocusList', () => {
ReactFeatureFlags.enableScopeAPI = true;
ReactFeatureFlags.enableFlareAPI = true;
createFocusList = require('../FocusList').createFocusList;
tabFocusableImpl = require('../TabbableScope').tabFocusableImpl;
TabbableScope = require('../TabbableScope').default;
React = require('react');
});

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

function createFocusListComponent() {
const [FocusList, FocusItem] = createFocusList(tabFocusableImpl);
const [FocusList, FocusItem] = createFocusList(TabbableScope);

return ({portrait}) => (
<FocusList portrait={portrait}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {createEventTarget} from 'react-interactions/events/src/dom/testing-libra
let React;
let ReactFeatureFlags;
let createFocusTable;
let tabFocusableImpl;
let TabbableScope;

describe('FocusTable', () => {
beforeEach(() => {
Expand All @@ -21,7 +21,7 @@ describe('FocusTable', () => {
ReactFeatureFlags.enableScopeAPI = true;
ReactFeatureFlags.enableFlareAPI = true;
createFocusTable = require('../FocusTable').createFocusTable;
tabFocusableImpl = require('../TabbableScope').tabFocusableImpl;
TabbableScope = require('../TabbableScope').default;
React = require('react');
});

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

function createFocusTableComponent() {
const [FocusTable, FocusTableRow, FocusTableCell] = createFocusTable(
tabFocusableImpl,
TabbableScope,
);

return ({onKeyboardOut, id}) => (
Expand Down
12 changes: 12 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,18 @@ const bundles = [
global: 'ReactTabbableScope',
externals: ['react'],
},

{
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
moduleType: NON_FIBER_RENDERER,
entry: 'react-interactions/accessibility/focus-list',
global: 'ReactFocusList',
externals: [
'react',
'react-interactions/events/keyboard',
'react-interactions/accessibility/tabbable-scope',
],
},
];

const fbBundleExternalsMap = {
Expand Down

0 comments on commit 793f176

Please sign in to comment.