@fluentui-react-native/tester 0.93.0 → 0.93.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.json +70 -1
  2. package/CHANGELOG.md +30 -2
  3. package/lib/TestComponents/Common/MenuPicker.d.ts +3 -3
  4. package/lib/TestComponents/Common/MenuPicker.d.ts.map +1 -1
  5. package/lib/TestComponents/Common/styles.d.ts +1 -1
  6. package/lib/TestComponents/Common/styles.js +1 -1
  7. package/lib/TestComponents/Common/styles.js.map +1 -1
  8. package/lib/TestComponents/FocusZone/FocusZoneTest.d.ts.map +1 -1
  9. package/lib/TestComponents/FocusZone/FocusZoneTest.js +79 -108
  10. package/lib/TestComponents/FocusZone/FocusZoneTest.js.map +1 -1
  11. package/lib/TestComponents/FocusZone/styles.d.ts +19 -6
  12. package/lib/TestComponents/FocusZone/styles.d.ts.map +1 -1
  13. package/lib/TestComponents/FocusZone/styles.js +22 -11
  14. package/lib/TestComponents/FocusZone/styles.js.map +1 -1
  15. package/lib-commonjs/TestComponents/Common/MenuPicker.d.ts +3 -3
  16. package/lib-commonjs/TestComponents/Common/MenuPicker.d.ts.map +1 -1
  17. package/lib-commonjs/TestComponents/Common/styles.d.ts +1 -1
  18. package/lib-commonjs/TestComponents/Common/styles.js +1 -1
  19. package/lib-commonjs/TestComponents/Common/styles.js.map +1 -1
  20. package/lib-commonjs/TestComponents/FocusZone/FocusZoneTest.d.ts.map +1 -1
  21. package/lib-commonjs/TestComponents/FocusZone/FocusZoneTest.js +76 -105
  22. package/lib-commonjs/TestComponents/FocusZone/FocusZoneTest.js.map +1 -1
  23. package/lib-commonjs/TestComponents/FocusZone/styles.d.ts +19 -6
  24. package/lib-commonjs/TestComponents/FocusZone/styles.d.ts.map +1 -1
  25. package/lib-commonjs/TestComponents/FocusZone/styles.js +23 -12
  26. package/lib-commonjs/TestComponents/FocusZone/styles.js.map +1 -1
  27. package/macos/Podfile.lock +223 -223
  28. package/package.json +7 -7
  29. package/src/TestComponents/Common/MenuPicker.desktop.tsx +2 -2
  30. package/src/TestComponents/Common/MenuPicker.tsx +3 -3
  31. package/src/TestComponents/Common/MenuPicker.windows.tsx +2 -2
  32. package/src/TestComponents/Common/styles.ts +1 -1
  33. package/src/TestComponents/FocusZone/FocusZoneTest.tsx +113 -168
  34. package/src/TestComponents/FocusZone/styles.ts +22 -13
@@ -1,14 +1,14 @@
1
1
  export * from './MenuPicker.desktop';
2
2
  import * as React from 'react';
3
3
  import { Button, Text, View, StyleSheet } from 'react-native';
4
- import { MenuPickerProps, collectionItem } from './MenuPicker';
4
+ import { MenuPickerProps, CollectionItem } from './MenuPicker';
5
5
 
6
6
  export const MenuPicker: React.FunctionComponent<MenuPickerProps> = (props: MenuPickerProps) => {
7
7
  const { prompt, onChange, collection } = props;
8
8
  return (
9
9
  <View style={menuPickerStyles.container}>
10
10
  <Text style={menuPickerStyles.prompt}>{prompt}</Text>
11
- {collection.map((item: collectionItem, index: number) => (
11
+ {collection.map((item: CollectionItem, index: number) => (
12
12
  <Button onPress={() => onChange(item.value, index)} key={index} title={item.label} />
13
13
  ))}
14
14
  </View>
@@ -5,7 +5,7 @@ export const commonTestStyles = StyleSheet.create({
5
5
  root: {
6
6
  marginTop: 16,
7
7
  marginRight: 32,
8
- flexDirection: 'row',
8
+ flexDirection: 'column',
9
9
  alignItems: 'flex-start',
10
10
  },
11
11
  flex: { flex: 1 },
@@ -1,116 +1,118 @@
1
1
  import * as React from 'react';
2
- import { View, Switch } from 'react-native';
3
- import { FocusZone, Text, FocusZoneDirection, Checkbox } from '@fluentui/react-native';
2
+ import { View, Switch, ScrollView } from 'react-native';
3
+ import { FocusZone, Text, FocusZoneDirection } from '@fluentui/react-native';
4
4
  import { ButtonV1 as Button, ButtonProps } from '@fluentui-react-native/button';
5
+ import { Checkbox, CheckboxProps } from '@fluentui-react-native/experimental-checkbox';
5
6
  import { Test, TestSection, PlatformStatus } from '../Test';
6
7
  import { FOCUSZONE_TESTPAGE } from './consts';
7
- import { focusZoneTestStyles, GridButton, stackStyleFocusZone, SubheaderText } from './styles';
8
+ import { focusZoneTestStyles, GridButton, SubheaderText } from './styles';
8
9
  import { commonTestStyles } from '../Common/styles';
9
- import { Stack } from '@fluentui-react-native/stack';
10
- import { MenuButton, MenuButtonItemProps } from '@fluentui-react-native/experimental-menu-button';
10
+ import { CollectionItem, MenuPicker } from '../Common/MenuPicker';
11
11
 
12
- const ListOfCheckboxes: React.FunctionComponent = () => {
12
+ const FocusZoneDirections: FocusZoneDirection[] = ['bidirectional', 'horizontal', 'vertical', 'none'];
13
+ const directionCollection: CollectionItem<FocusZoneDirection>[] = FocusZoneDirections.map((x) => ({
14
+ label: x,
15
+ value: x,
16
+ }));
17
+
18
+ const Checkboxes = (props: CheckboxProps) => {
19
+ return (
20
+ <View style={focusZoneTestStyles.dashedBorder}>
21
+ <Checkbox label="Option A" {...props} />
22
+ <Checkbox label="Option B" {...props} />
23
+ <Checkbox label="Option C" {...props} />
24
+ </View>
25
+ );
26
+ };
27
+
28
+ const FocusZoneInsideScrollView: React.FunctionComponent = () => {
13
29
  return (
14
- <React.Fragment>
15
- <Checkbox label="Option A" />
16
- <Checkbox label="Option B" />
17
- <Checkbox label="Option C" />
18
- </React.Fragment>
30
+ <FocusZoneListWrapper>
31
+ <FocusZone focusZoneDirection="bidirectional">
32
+ <View style={focusZoneTestStyles.dashedBorder}>
33
+ <Button style={focusZoneTestStyles.listWrapperButton}>Inside Focus Zone</Button>
34
+ <ScrollView
35
+ focusable={false}
36
+ style={focusZoneTestStyles.scrollViewStyle}
37
+ contentContainerStyle={focusZoneTestStyles.scrollViewContentStyle}
38
+ showsVerticalScrollIndicator={true}
39
+ >
40
+ <Button style={focusZoneTestStyles.scrollViewButton}>1</Button>
41
+ <Button style={focusZoneTestStyles.scrollViewButton}>2</Button>
42
+ <Button style={focusZoneTestStyles.scrollViewButton}>3</Button>
43
+ </ScrollView>
44
+ </View>
45
+ </FocusZone>
46
+ </FocusZoneListWrapper>
19
47
  );
20
48
  };
21
49
 
22
- const ListOfDisabledCheckboxes: React.FunctionComponent = () => {
50
+ const FocusZoneNoFocusableElements: React.FunctionComponent = () => {
23
51
  return (
24
- <React.Fragment>
25
- <Checkbox label="Option A" disabled={true} />
26
- <Checkbox label="Option B" disabled={true} />
27
- <Checkbox label="Option C" disabled={true} />
28
- </React.Fragment>
52
+ <FocusZone>
53
+ <Checkboxes disabled />
54
+ </FocusZone>
29
55
  );
30
56
  };
31
57
 
32
- const EdgeCasesFocusZone: React.FunctionComponent = () => {
58
+ const FocusZoneNoProps: React.FunctionComponent = () => {
33
59
  return (
34
- <Stack style={stackStyleFocusZone}>
35
- <FocusZone>
36
- <SubheaderText>FocusZone with no focusable elements</SubheaderText>
37
- <ListOfDisabledCheckboxes />
38
- </FocusZone>
39
- <FocusZone>
40
- <SubheaderText>FocusZone with no props set</SubheaderText>
41
- <ListOfCheckboxes />
42
- </FocusZone>
43
- <FocusZone>
44
- <SubheaderText>FocusZone with no elements</SubheaderText>
45
- </FocusZone>
46
- <SubheaderText>Nested FocusZones</SubheaderText>
47
- <Button>Outside Focus Zone</Button>
48
- <Text>Parent FocusZone, vertical</Text>
49
- <View style={focusZoneTestStyles.nestedFocusZoneStyle}>
50
- <FocusZone focusZoneDirection="vertical">
51
- <Text>Inner FocusZone 1, horizontal</Text>
52
- <View style={focusZoneTestStyles.nestedFocusZoneStyle}>
60
+ <FocusZone>
61
+ <Checkboxes />
62
+ </FocusZone>
63
+ );
64
+ };
65
+
66
+ const NestedFocusZone: React.FunctionComponent = () => {
67
+ return (
68
+ <FocusZoneListWrapper>
69
+ <>
70
+ <Text>Parent FocusZone, vertical</Text>
71
+ <View style={focusZoneTestStyles.nestedFocusZoneStyle}>
72
+ <FocusZone focusZoneDirection="vertical">
73
+ <Text>Inner FocusZone 1, horizontal</Text>
53
74
  <FocusZone focusZoneDirection="horizontal">
54
- <View style={focusZoneTestStyles.focusZoneContainer}>
55
- {GridOfButtons({
56
- gridWidth: 3,
57
- gridHeight: 1,
58
- })}
59
- </View>
75
+ <GridOfButtons gridWidth={3} gridHeight={1} />
60
76
  </FocusZone>
61
- </View>
62
- <Text>Inner FocusZone 2, horizontal</Text>
63
- <View style={focusZoneTestStyles.nestedFocusZoneStyle}>
77
+ <Text>Inner FocusZone 2, horizontal</Text>
64
78
  <FocusZone focusZoneDirection="horizontal">
65
- <View style={focusZoneTestStyles.focusZoneContainer}>
66
- {GridOfButtons({
67
- gridWidth: 3,
68
- gridHeight: 1,
69
- })}
70
- </View>
79
+ <GridOfButtons gridWidth={3} gridHeight={1} />
71
80
  </FocusZone>
72
- </View>
73
- <Button>Inside Focus Zone</Button>
74
- </FocusZone>
75
- </View>
76
- <Button>Outside Focus Zone</Button>
77
- </Stack>
81
+ <Button>Inside Focus Zone</Button>
82
+ </FocusZone>
83
+ </View>
84
+ </>
85
+ </FocusZoneListWrapper>
78
86
  );
79
87
  };
80
88
 
81
- const FocusZoneListWrapper: React.FunctionComponent = (props) => {
82
- const buttonProps: ButtonProps = { children: 'Click to Focus', style: { marginVertical: 10 } };
89
+ const FocusZoneListWrapper = (props) => {
90
+ const buttonProps: ButtonProps = { children: 'Click to Focus', style: focusZoneTestStyles.listWrapperButton };
83
91
  return (
84
- <React.Fragment>
92
+ <>
85
93
  <Button {...buttonProps} />
86
94
  {React.Children.map(props.children, (child) => {
87
95
  return (
88
- <React.Fragment>
96
+ <>
89
97
  {child}
90
98
  <Button {...buttonProps} />
91
- </React.Fragment>
99
+ </>
92
100
  );
93
101
  })}
94
- </React.Fragment>
102
+ </>
95
103
  );
96
104
  };
97
105
 
98
- const FocusZoneDirections: FocusZoneDirection[] = ['bidirectional', 'horizontal', 'vertical', 'none'];
99
-
100
106
  const DirectionalFocusZone: React.FunctionComponent = () => {
107
+ const [direction, setDirection] = React.useState<FocusZoneDirection>('none');
108
+
101
109
  return (
102
- <FocusZoneListWrapper>
103
- <FocusZone>
104
- <SubheaderText>FocusZone with no props set</SubheaderText>
105
- <ListOfCheckboxes />
110
+ <>
111
+ <MenuPicker prompt="Direction" selected={direction} onChange={setDirection} collection={directionCollection} />
112
+ <FocusZone focusZoneDirection={direction}>
113
+ <Checkboxes />
106
114
  </FocusZone>
107
- {FocusZoneDirections.map((direction, index) => (
108
- <FocusZone key={index} focusZoneDirection={direction}>
109
- <SubheaderText>FocusZone with arrow key navigation: {direction}</SubheaderText>
110
- <ListOfCheckboxes />
111
- </FocusZone>
112
- ))}
113
- </FocusZoneListWrapper>
115
+ </>
114
116
  );
115
117
  };
116
118
 
@@ -119,11 +121,11 @@ const CommonUsageFocusZone: React.FunctionComponent = () => {
119
121
  <FocusZoneListWrapper>
120
122
  <FocusZone isCircularNavigation={true}>
121
123
  <SubheaderText>FocusZone with Circular Navigation</SubheaderText>
122
- <ListOfCheckboxes />
124
+ <Checkboxes />
123
125
  </FocusZone>
124
126
  <FocusZone disabled={true}>
125
127
  <SubheaderText>Disabled FocusZone</SubheaderText>
126
- <ListOfCheckboxes />
128
+ <Checkboxes />
127
129
  </FocusZone>
128
130
  </FocusZoneListWrapper>
129
131
  );
@@ -132,27 +134,18 @@ const CommonUsageFocusZone: React.FunctionComponent = () => {
132
134
  type GridOfButtonsProps = {
133
135
  gridWidth: number;
134
136
  gridHeight: number;
135
- buttonRefs?: React.RefObject<View>[];
136
- onClick?: (index: number) => void;
137
137
  };
138
138
 
139
139
  const GridOfButtons: React.FunctionComponent<GridOfButtonsProps> = (props: GridOfButtonsProps) => {
140
140
  return (
141
- <React.Fragment>
141
+ <View style={focusZoneTestStyles.dashedBorder}>
142
142
  {[...Array(props.gridHeight)].map((_value, heightIndex: number) => {
143
143
  return (
144
144
  <View key={heightIndex} style={focusZoneTestStyles.focusZoneViewStyle}>
145
145
  {[...Array(props.gridWidth)].map((_value, widthIndex: number) => {
146
146
  const gridIndex = heightIndex * props.gridWidth + widthIndex + 1;
147
147
  return (
148
- <GridButton
149
- key={widthIndex}
150
- style={focusZoneTestStyles.focusZoneButton}
151
- componentRef={props?.buttonRefs?.[gridIndex]}
152
- onClick={() => {
153
- props?.onClick?.(gridIndex);
154
- }}
155
- >
148
+ <GridButton key={widthIndex} style={focusZoneTestStyles.focusZoneButton}>
156
149
  <Text>{gridIndex}</Text>
157
150
  </GridButton>
158
151
  );
@@ -160,47 +153,7 @@ const GridOfButtons: React.FunctionComponent<GridOfButtonsProps> = (props: GridO
160
153
  </View>
161
154
  );
162
155
  })}
163
- </React.Fragment>
164
- );
165
- };
166
-
167
- const Navigation2DFocusZone: React.FunctionComponent = () => {
168
- const [defaultTabbableElementIndex, setDefaultTabbableElementIndex] = React.useState<number | null>(5);
169
- const gridWidth = 3,
170
- gridHeight = 4;
171
-
172
- const refMemo = React.useMemo(
173
- () =>
174
- Array(gridWidth * gridHeight)
175
- .fill(null)
176
- .map(() => React.createRef<View>()),
177
- [gridWidth, gridHeight],
178
- );
179
- const buttonRefs = React.useRef(refMemo);
180
- const defaultTextNote = 'The defaultTabbableElement is ' + defaultTabbableElementIndex;
181
- return (
182
- <React.Fragment>
183
- <Text>{defaultTextNote}</Text>
184
- <Button onClick={() => setDefaultTabbableElementIndex(null)} style={{ marginTop: 10 }}>
185
- Clear defaultTabbableElement
186
- </Button>
187
- <FocusZoneListWrapper>
188
- <FocusZone
189
- use2DNavigation={true}
190
- defaultTabbableElement={defaultTabbableElementIndex ? buttonRefs.current[defaultTabbableElementIndex] : undefined}
191
- isCircularNavigation={true}
192
- >
193
- <View style={focusZoneTestStyles.focusZoneContainer}>
194
- {GridOfButtons({
195
- gridWidth: 3,
196
- gridHeight: 4,
197
- buttonRefs: buttonRefs.current,
198
- onClick: (index: number) => setDefaultTabbableElementIndex(index),
199
- })}
200
- </View>
201
- </FocusZone>
202
- </FocusZoneListWrapper>
203
- </React.Fragment>
156
+ </View>
204
157
  );
205
158
  };
206
159
 
@@ -220,67 +173,59 @@ function SwitchWithLabel(props: ISwitchWithLabelProps): React.ReactElement {
220
173
  );
221
174
  }
222
175
 
223
- const CustomizableFocusZone: React.FunctionComponent = () => {
176
+ const FocusZone2D: React.FunctionComponent = () => {
224
177
  const [is2DNav, set2dNav] = React.useState(false);
225
178
  const [isDisabled, setDisabled] = React.useState(false);
226
179
  const [isCircularNav, setIsCircularNav] = React.useState(false);
227
- const [focusZoneDirection, setFocusZoneDirection] = React.useState<FocusZoneDirection>('bidirectional');
228
- const menuItems: MenuButtonItemProps[] = FocusZoneDirections.map((direction) => ({ itemKey: direction, text: direction }));
180
+ const [direction, setDirection] = React.useState<FocusZoneDirection>('bidirectional');
229
181
 
230
182
  return (
231
183
  <View style={commonTestStyles.root}>
232
- <Stack style={stackStyleFocusZone}>
233
- <View style={commonTestStyles.settings}>
234
- <SwitchWithLabel label="2D Navigation" value={is2DNav} onValueChange={set2dNav} />
235
- <SwitchWithLabel label="Disabled" value={isDisabled} onValueChange={setDisabled} />
236
- <SwitchWithLabel label="Circular Navigation" value={isCircularNav} onValueChange={setIsCircularNav} />
237
- <MenuButton
238
- content={focusZoneDirection}
239
- menuItems={menuItems}
240
- onItemClick={(direction) => setFocusZoneDirection(direction as FocusZoneDirection)}
241
- contextualMenu={{
242
- shouldFocusOnMount: true,
243
- shouldFocusOnContainer: true,
244
- }}
245
- />
246
- </View>
184
+ <View style={commonTestStyles.settings}>
185
+ <SwitchWithLabel label="2D Navigation" value={is2DNav} onValueChange={set2dNav} />
186
+ <SwitchWithLabel label="Disabled" value={isDisabled} onValueChange={setDisabled} />
187
+ <SwitchWithLabel label="Circular Navigation" value={isCircularNav} onValueChange={setIsCircularNav} />
188
+ <MenuPicker prompt="Direction" selected={direction} onChange={setDirection} collection={directionCollection} />
189
+ </View>
247
190
 
248
- <FocusZoneListWrapper>
249
- <FocusZone
250
- disabled={isDisabled}
251
- use2DNavigation={is2DNav}
252
- focusZoneDirection={focusZoneDirection}
253
- isCircularNavigation={isCircularNav}
254
- >
255
- <View style={focusZoneTestStyles.focusZoneContainer}>{GridOfButtons({ gridWidth: 3, gridHeight: 3 })}</View>
256
- </FocusZone>
257
- </FocusZoneListWrapper>
258
- </Stack>
191
+ <FocusZoneListWrapper>
192
+ <FocusZone disabled={isDisabled} use2DNavigation={is2DNav} focusZoneDirection={direction} isCircularNavigation={isCircularNav}>
193
+ <GridOfButtons gridWidth={3} gridHeight={3} />
194
+ </FocusZone>
195
+ </FocusZoneListWrapper>
259
196
  </View>
260
197
  );
261
198
  };
262
199
 
263
200
  const focusZoneSections: TestSection[] = [
201
+ {
202
+ name: 'Common FocusZone Usage',
203
+ component: CommonUsageFocusZone,
204
+ },
264
205
  {
265
206
  name: 'Directional FocusZone Usage',
266
207
  testID: FOCUSZONE_TESTPAGE,
267
208
  component: DirectionalFocusZone,
268
209
  },
269
210
  {
270
- name: 'Common FocusZone Usage',
271
- component: CommonUsageFocusZone,
211
+ name: '2D Navigation',
212
+ component: FocusZone2D,
272
213
  },
273
214
  {
274
- name: '2D Navigation',
275
- component: Navigation2DFocusZone,
215
+ name: 'ScrollView inside FocusZone',
216
+ component: FocusZoneInsideScrollView,
217
+ },
218
+ {
219
+ name: 'FocusZone with no focusable components',
220
+ component: FocusZoneNoFocusableElements,
276
221
  },
277
222
  {
278
- name: 'Customizable FocusZone',
279
- component: CustomizableFocusZone,
223
+ name: 'FocusZone with no props',
224
+ component: FocusZoneNoProps,
280
225
  },
281
226
  {
282
- name: 'FocusZone Edge Cases',
283
- component: EdgeCasesFocusZone,
227
+ name: 'Nested FocusZone',
228
+ component: NestedFocusZone,
284
229
  },
285
230
  ];
286
231
 
@@ -1,5 +1,4 @@
1
1
  import { StyleSheet, View } from 'react-native';
2
- import { IStackProps } from '@fluentui-react-native/stack';
3
2
  import { Text } from '@fluentui/react-native';
4
3
  import { ButtonV1 as Button } from '@fluentui-react-native/button';
5
4
  import { Icon } from '@fluentui-react-native/icon';
@@ -9,11 +8,7 @@ export const focusZoneTestStyles = StyleSheet.create({
9
8
  flexDirection: 'row',
10
9
  alignContent: 'flex-start',
11
10
  alignItems: 'flex-start',
12
- },
13
- focusZoneContainer: {
14
- flexDirection: 'column',
15
- justifyContent: 'space-evenly',
16
- padding: 4,
11
+ padding: 10,
17
12
  },
18
13
  nestedFocusZoneStyle: {
19
14
  borderWidth: 1,
@@ -21,8 +16,27 @@ export const focusZoneTestStyles = StyleSheet.create({
21
16
  margin: 8,
22
17
  },
23
18
  focusZoneButton: {
24
- height: 50,
25
- width: 50,
19
+ height: 30,
20
+ width: 100,
21
+ margin: 10,
22
+ },
23
+ listWrapperButton: {
24
+ marginVertical: 10,
25
+ },
26
+ dashedBorder: {
27
+ borderWidth: 1,
28
+ borderStyle: 'dashed',
29
+ },
30
+ scrollViewStyle: {
31
+ height: 100,
32
+ width: 300,
33
+ },
34
+ scrollViewContentStyle: {
35
+ backgroundColor: 'grey',
36
+ },
37
+ scrollViewButton: {
38
+ marginHorizontal: 20,
39
+ marginBottom: 100,
26
40
  },
27
41
  });
28
42
 
@@ -43,8 +57,3 @@ export const SubheaderText = Text.customize({
43
57
  tokens: { variant: 'subheaderSemibold' },
44
58
  root: { style: { textDecorationLine: 'underline' } },
45
59
  });
46
-
47
- export const stackStyleFocusZone: IStackProps['style'] = {
48
- flexDirection: 'column',
49
- marginBottom: 40,
50
- };