Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 3cea7da

Browse files
committed
wip
1 parent 45b27de commit 3cea7da

38 files changed

+639
-918
lines changed

docs/src/examples/components/List/Content/ListExampleContent.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ import { List } from '@fluentui/react'
33

44
const ListExample = () => (
55
<List>
6-
<List.Item header="Program the sensor to the SAS alarm through the haptic SQL card!" />
7-
<List.Item header="Use the online FTP application to input the multi-byte application!" />
8-
<List.Item header="The GB pixel is down, navigate the virtual interface!" />
6+
<List.Item
7+
header="Program the sensor to the SAS alarm through the haptic SQL card!"
8+
index={0}
9+
/>
10+
<List.Item
11+
header="Use the online FTP application to input the multi-byte application!"
12+
index={1}
13+
/>
14+
<List.Item header="The GB pixel is down, navigate the virtual interface!" index={2} />
915
</List>
1016
)
1117

docs/src/examples/components/List/Content/ListExampleContentMedia.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ const ListExample = () => (
66
<List.Item
77
content="Program the sensor to the SAS alarm through the haptic SQL card!"
88
contentMedia="7:26:56 AM"
9+
index={0}
910
/>
1011
<List.Item
1112
content="Use the online FTP application to input the multi-byte application!"
1213
contentMedia="11:30:17 PM"
14+
index={1}
1315
/>
1416
<List.Item
1517
content="The GB pixel is down, navigate the virtual interface!"
1618
contentMedia="5:22:40 PM"
19+
index={2}
1720
/>
1821
</List>
1922
)

docs/src/examples/components/List/Content/ListExampleEndMedia.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ const ListExample = () => (
99
content="Program the sensor to the SAS alarm through the haptic SQL card!"
1010
endMedia={ellipsis}
1111
selectable
12+
index={0}
1213
/>
1314
<List.Item
1415
content="Use the online FTP application to input the multi-byte application!"
1516
endMedia={ellipsis}
1617
selectable
18+
index={1}
1719
/>
1820
<List.Item
1921
content="The GB pixel is down, navigate the virtual interface!"
2022
endMedia={ellipsis}
2123
selectable
24+
index={2}
2225
/>
2326
</List>
2427
)

docs/src/examples/components/List/Content/ListExampleHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { List } from '@fluentui/react'
33

44
const ListExample = () => (
55
<List>
6-
<List.Item header="Irving Kuhic" />
7-
<List.Item header="Skyler Parks" />
8-
<List.Item header="Dante Schneider" />
6+
<List.Item header="Irving Kuhic" index={0} />
7+
<List.Item header="Skyler Parks" index={1} />
8+
<List.Item header="Dante Schneider" index={2} />
99
</List>
1010
)
1111

docs/src/examples/components/List/Content/ListExampleHeaderContent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ const ListExample = () => (
66
<List.Item
77
header="Irving Kuhic"
88
content="Program the sensor to the SAS alarm through the haptic SQL card!"
9+
index={0}
910
/>
1011
<List.Item
1112
header="Skyler Parks"
1213
content="Use the online FTP application to input the multi-byte application!"
14+
index={1}
1315
/>
1416
<List.Item
1517
header="Dante Schneider"
1618
content="The GB pixel is down, navigate the virtual interface!"
19+
index={2}
1720
/>
1821
</List>
1922
)

docs/src/examples/components/List/Content/ListExampleHeaderMedia.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { List } from '@fluentui/react'
33

44
const ListExample = () => (
55
<List>
6-
<List.Item header="Irving Kuhic" headerMedia="7:26:56 AM" />
7-
<List.Item header="Skyler Parks" headerMedia="11:30:17 PM" />
8-
<List.Item header="Dante Schneider" headerMedia="5:22:40 PM" />
6+
<List.Item header="Irving Kuhic" headerMedia="7:26:56 AM" index={0} />
7+
<List.Item header="Skyler Parks" headerMedia="11:30:17 PM" index={1} />
8+
<List.Item header="Dante Schneider" headerMedia="5:22:40 PM" index={2} />
99
</List>
1010
)
1111

docs/src/examples/components/List/Content/ListExampleMedia.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ const ListExampleMedia = () => (
88
header="Irving Kuhic"
99
headerMedia="7:26:56 AM"
1010
content="Program the sensor to the SAS alarm through the haptic SQL card!"
11+
index={0}
1112
/>
1213
<List.Item
1314
media={<Image src="public/images/avatar/small/steve.jpg" avatar />}
1415
header="Skyler Parks"
1516
headerMedia="11:30:17 PM"
1617
content="Use the online FTP application to input the multi-byte application!"
18+
index={1}
1719
/>
1820
<List.Item
1921
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
2022
header="Dante Schneider"
2123
headerMedia="5:22:40 PM"
2224
content="The GB pixel is down, navigate the virtual interface!"
25+
index={2}
2326
/>
2427
</List>
2528
)

docs/src/examples/components/List/Performance/ListCommon.perf.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContextList as List, Image } from '@fluentui/react'
1+
import { List, Image } from '@fluentui/react'
22
import * as React from 'react'
33

44
const avatars = {

docs/src/examples/components/List/Types/ListExample.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ const ListExampleSelectable = () => {
1212
header="Irving Kuhic"
1313
headerMedia="7:26:56 AM"
1414
content="Program the sensor to the SAS alarm through the haptic SQL card!"
15+
index={0}
1516
/>
1617
<List.Item
1718
media={<Image src="public/images/avatar/small/steve.jpg" avatar />}
1819
header="Skyler Parks"
1920
headerMedia="11:30:17 PM"
2021
content="Use the online FTP application to input the multi-byte application!"
22+
index={1}
2123
/>
2224
<List.Item
2325
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
2426
header="Dante Schneider"
2527
headerMedia="5:22:40 PM"
2628
content="The GB pixel is down, navigate the virtual interface!"
29+
index={2}
2730
/>
2831
</List>
2932
)

docs/src/examples/components/List/Types/ListExampleNavigable.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ const ListExampleNavigable = () => (
99
headerMedia="7:26:56 AM"
1010
content="Program the sensor to the SAS alarm through the haptic SQL card!"
1111
navigable
12+
index={0}
1213
/>
1314
<List.Item
1415
media={<Image src="public/images/avatar/small/steve.jpg" avatar />}
1516
header="Skyler Parks"
1617
headerMedia="11:30:17 PM"
1718
content="Use the online FTP application to input the multi-byte application!"
1819
navigable
20+
index={1}
1921
/>
2022
<List.Item
2123
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
2224
header="Dante Schneider"
2325
headerMedia="5:22:40 PM"
2426
content="The GB pixel is down, navigate the virtual interface!"
2527
navigable
28+
index={2}
2629
/>
2730
</List>
2831
)

docs/src/examples/components/List/Types/ListExampleSelectable.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ const ListExampleSelectable = () => (
77
media={<Image src="public/images/avatar/small/matt.jpg" avatar />}
88
header="Irving Kuhic"
99
headerMedia="7:26:56 AM"
10+
index={0}
1011
content="Program the sensor to the SAS alarm through the haptic SQL card!"
1112
/>
1213
<List.Item
1314
media={<Image src="public/images/avatar/small/steve.jpg" avatar />}
1415
header="Skyler Parks"
1516
headerMedia="11:30:17 PM"
17+
index={1}
1618
content="Use the online FTP application to input the multi-byte application!"
1719
/>
1820
<List.Item
1921
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
2022
header="Dante Schneider"
2123
headerMedia="5:22:40 PM"
24+
index={2}
2225
content="The GB pixel is down, navigate the virtual interface!"
2326
/>
2427
</List>

docs/src/examples/components/List/Variations/ListExampleTruncate.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,23 @@ const ListExample = () => {
1717
headerMedia="7:26:56 AM"
1818
content="Program the sensor to the SAS alarm through the haptic SQL card!"
1919
contentMedia="!!"
20+
index={0}
2021
/>
2122
<List.Item
2223
media={<Image src="public/images/avatar/small/steve.jpg" avatar />}
2324
header="Skyler Parks - Super long title here"
2425
headerMedia="11:30:17 PM"
2526
content="Use the online FTP application to input the multi-byte application!"
2627
contentMedia="!!"
28+
index={1}
2729
/>
2830
<List.Item
2931
media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
3032
header="Dante Schneider - Super long title here"
3133
headerMedia="5:22:40 PM"
3234
content="The GB pixel is down, navigate the virtual interface!"
3335
contentMedia="!!"
36+
index={2}
3437
/>
3538
</List>
3639
</div>

packages/accessibility/src/behaviors/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@ export { default as menuBehavior } from './Menu/menuBehavior'
88
export { default as menuItemBehavior } from './Menu/menuItemBehavior'
99
export { default as menuDividerBehavior } from './Menu/menuDividerBehavior'
1010
export { default as submenuBehavior } from './Menu/submenuBehavior'
11+
12+
// List
13+
1114
export { default as basicListBehavior } from './List/listBehavior'
1215
export { default as basicListItemBehavior } from './List/basicListItemBehavior'
16+
1317
export { default as listBehavior } from './List/listBehavior'
18+
export * from './List/listBehavior'
1419
export { default as listItemBehavior } from './List/listItemBehavior'
20+
export * from './List/listItemBehavior'
21+
1522
export { default as navigableListBehavior } from './List/navigableListBehavior'
1623
export { default as navigableListItemBehavior } from './List/navigableListItemBehavior'
24+
1725
export { default as selectableListBehavior } from './List/selectableListBehavior'
1826
export { default as selectableListItemBehavior } from './List/selectableListItemBehavior'
27+
1928
export { default as loaderBehavior } from './Loader/loaderBehavior'
2029
export { default as inputBehavior } from './Input/inputBehavior'
2130
export { default as iconBehavior } from './Icon/iconBehavior'

packages/react-bindings/src/hooks/useStateManager.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ const useStateManager = <
3939
const latestManager = React.useRef<Manager<State, Actions> | null>(null)
4040

4141
// Heads up! forceUpdate() is used only for triggering rerenders stateManager is SSOT()
42-
const [, forceUpdate] = React.useState()
43-
const syncState = React.useCallback(
44-
(_prevState: State, nextState: State) => forceUpdate(nextState),
45-
[],
46-
)
42+
const [, forceUpdate] = React.useReducer((c: number) => c + 1, 0) as [never, () => void]
43+
const syncState = React.useCallback(() => forceUpdate(), [])
4744

4845
// If manager exists, the current state will be used
4946
const initialState = latestManager.current
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../.gulp')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`@fluentui/react-context-selector`
2+
===
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = api => require('@fluentui/internal-tooling/babel')(api)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '../../gulpfile'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@fluentui/react-context-selector",
3+
"description": "TODO",
4+
"version": "0.43.0",
5+
"author": "Oleksandr Fediashov <a@fedyashov.com>",
6+
"bugs": "https://github.com/microsoft/fluent-ui-react/issues",
7+
"dependencies": {
8+
"@babel/runtime": "^7.1.2"
9+
},
10+
"devDependencies": {
11+
"@fluentui/internal-tooling": "^0.43.0",
12+
"lerna-alias": "^3.0.3-0"
13+
},
14+
"files": [
15+
"dist"
16+
],
17+
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/react-context-selector",
18+
"jsnext:main": "dist/es/index.js",
19+
"license": "MIT",
20+
"main": "dist/commonjs/index.js",
21+
"module": "dist/es/index.js",
22+
"publishConfig": {
23+
"access": "public"
24+
},
25+
"repository": "microsoft/fluent-ui-react.git",
26+
"scripts": {
27+
"build": "gulp bundle:package:no-umd",
28+
"clean": "gulp bundle:package:clean"
29+
},
30+
"sideEffects": false,
31+
"types": "dist/es/index.d.ts"
32+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as React from 'react'
2+
import { ContextListener, ContextValue, Context } from './types'
3+
4+
export const SUBSCRIBE_CONTEXT_PROPERTY = 's'
5+
export const VALUE_CONTEXT_PROPERTY = 'v'
6+
7+
const calculateChangedBits = () => 0
8+
9+
const createProvider = <Value>(
10+
Original: React.Provider<ContextValue<Value>>,
11+
): React.FC<React.ProviderProps<Value>> => props => {
12+
const listeners = React.useRef<ContextListener<Value>[]>([])
13+
14+
// We call listeners in render intentionally. Listeners are not technically pure, but
15+
// otherwise we can't get benefits from concurrent mode.
16+
//
17+
// We make sure to work with double or more invocation of listeners.
18+
listeners.current.forEach(listener => listener(props.value))
19+
20+
const subscribe = React.useCallback((listener: ContextListener<Value>) => {
21+
listeners.current.push(listener)
22+
23+
const unsubscribe = () => {
24+
const index = listeners.current.indexOf(listener)
25+
listeners.current.splice(index, 1)
26+
}
27+
28+
return unsubscribe
29+
}, [])
30+
31+
const value: ContextValue<Value> = {
32+
[SUBSCRIBE_CONTEXT_PROPERTY]: subscribe,
33+
[VALUE_CONTEXT_PROPERTY]: props.value,
34+
}
35+
36+
return React.createElement(Original, { value }, props.children)
37+
}
38+
39+
export const createContext = <Value>(defaultValue: Value): Context<Value> => {
40+
const context = React.createContext<ContextValue<Value>>(
41+
{
42+
get [SUBSCRIBE_CONTEXT_PROPERTY](): any {
43+
throw new Error(
44+
process.env.NODE_ENV === 'production'
45+
? ''
46+
: `Please use <Provider> from "@fluentui/react-bindings"`,
47+
)
48+
},
49+
[VALUE_CONTEXT_PROPERTY]: defaultValue,
50+
},
51+
calculateChangedBits,
52+
)
53+
context.Provider = createProvider<Value>(context.Provider) as any
54+
55+
// We don't support Consumer API
56+
delete context.Consumer
57+
58+
return context as any
59+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { createContext } from './createContext'
2+
export { useContextSelector } from './useContextSelector'
3+
export * from './types'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as React from 'react'
2+
3+
export type Context<Value> = React.Context<Value> & {
4+
Provider: React.FC<React.ProviderProps<Value>>
5+
Consumer: never
6+
}
7+
8+
export type ContextListener<Value> = (value: Value) => void
9+
10+
export type ContextSelector<Value, SelectedValue> = (value: Value) => SelectedValue
11+
12+
export type ContextValue<Value> = {
13+
s: (listener: ContextListener<Value>) => any
14+
v: Value
15+
}

0 commit comments

Comments
 (0)