@office-iss/react-native-win32 0.72.0-preview.4 → 0.72.0-preview.6
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.
- package/CHANGELOG.json +49 -1
- package/CHANGELOG.md +23 -4
- package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
- package/Libraries/Components/Text/TextWin32.Props.d.ts +1 -1
- package/Libraries/Components/Text/TextWin32.Props.js.map +1 -1
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +0 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +121 -86
- package/Libraries/Components/TextInput/TextInput.flow.js +121 -135
- package/Libraries/Components/TextInput/TextInput.js +126 -155
- package/Libraries/Components/TextInput/TextInput.win32.js +121 -135
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.d.ts +5 -0
- package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/View/ViewAccessibility.d.ts +158 -4
- package/Libraries/Components/View/ViewPropTypes.d.ts +146 -6
- package/Libraries/Components/View/ViewWin32.d.ts +1 -1
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +0 -2
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -13
- package/Libraries/Text/TextNativeComponent.win32.js +31 -5
- package/Libraries/platform-types.d.ts +5 -5
- package/overrides.json +5 -13
- package/package.json +16 -16
- package/src/Libraries/Components/Button/ButtonWin32.tsx +1 -1
- package/src/Libraries/Components/Text/TextWin32.Props.ts +1 -1
- package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +1 -1
- package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +1 -1
- package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
- package/{Libraries/Components/View/ViewPropTypes.win32.d.ts → src/Libraries/Components/View/ViewPropTypes.d.ts} +14 -1
- package/src/Libraries/Components/View/ViewWin32.d.ts +1 -1
- package/src/Libraries/platform-types.d.ts +5 -5
- package/types/experimental.d.ts +101 -0
- package/Libraries/Components/Text/Tests/TextWin32Test.d.ts +0 -8
- package/Libraries/Components/Text/Tests/TextWin32Test.js +0 -120
- package/Libraries/Components/Text/Tests/TextWin32Test.js.map +0 -1
- package/Libraries/Components/View/Tests/ViewWin32Test.d.ts +0 -8
- package/Libraries/Components/View/Tests/ViewWin32Test.js +0 -233
- package/Libraries/Components/View/Tests/ViewWin32Test.js.map +0 -1
- package/src/Libraries/Components/Text/Tests/TextWin32Test.tsx +0 -164
- package/src/Libraries/Components/Touchable/TouchableNativeFeedback.win32.d.ts +0 -119
- package/src/Libraries/Components/View/Tests/ViewWin32Test.tsx +0 -333
- package/src/Libraries/Components/View/ViewAccessibility.win32.d.ts +0 -527
- package/src/Libraries/Components/View/ViewPropTypes.win32.d.ts +0 -372
- /package/{Libraries/Components/Touchable/TouchableNativeFeedback.win32.d.ts → src/Libraries/Components/Touchable/TouchableNativeFeedback.d.ts} +0 -0
- /package/{Libraries/Components/View/ViewAccessibility.win32.d.ts → src/Libraries/Components/View/ViewAccessibility.d.ts} +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { Button, View } from 'react-native';
|
|
4
|
-
import { TextWin32 } from '../../Text/TextWin32';
|
|
5
|
-
import { ViewWin32 } from '../../View/ViewWin32';
|
|
6
|
-
|
|
7
|
-
// Disabling no-jsx-lambda so functional components are more convenient to use
|
|
8
|
-
|
|
9
|
-
const TextRunsTest: React.FC<{}> = () => {
|
|
10
|
-
return (
|
|
11
|
-
<View focusable>
|
|
12
|
-
<TextWin32>
|
|
13
|
-
<TextWin32>Text With </TextWin32>
|
|
14
|
-
<TextWin32>Multiple Text </TextWin32>
|
|
15
|
-
<TextWin32>Children [Runs]</TextWin32>
|
|
16
|
-
</TextWin32>
|
|
17
|
-
</View>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const FocusableTextTest: React.FC<{}> = () => {
|
|
22
|
-
return (
|
|
23
|
-
<ViewWin32>
|
|
24
|
-
<TextWin32 focusable>This TextWin32 demonstrates focusable</TextWin32>
|
|
25
|
-
</ViewWin32>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const SelectableTextTest: React.FC<{}> = () => {
|
|
30
|
-
return (
|
|
31
|
-
<ViewWin32>
|
|
32
|
-
<TextWin32 selectable>This TextWin32 demonstrates selectable</TextWin32>
|
|
33
|
-
</ViewWin32>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const TextStyleTest: React.FC<{}> = () => {
|
|
38
|
-
return (
|
|
39
|
-
<ViewWin32>
|
|
40
|
-
<TextWin32 textStyle={'MediumBold'}>Normal Text Display</TextWin32>
|
|
41
|
-
</ViewWin32>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const TooltipTextTest: React.FC<{}> = () => {
|
|
46
|
-
return (
|
|
47
|
-
<ViewWin32>
|
|
48
|
-
<TextWin32 tooltip="Example Tooltip">This TextWin32 demonstrates a tooltip</TextWin32>
|
|
49
|
-
</ViewWin32>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const TextPromotionTest: React.FC<{}> = () => {
|
|
54
|
-
enum FocusabilityState {
|
|
55
|
-
NoFocus,
|
|
56
|
-
Focusable,
|
|
57
|
-
Selectable,
|
|
58
|
-
}
|
|
59
|
-
const [focusabilityState, setFocusabilityState] = React.useState(FocusabilityState.NoFocus);
|
|
60
|
-
return (
|
|
61
|
-
<ViewWin32>
|
|
62
|
-
<Button
|
|
63
|
-
title="Click to Promote Focusability"
|
|
64
|
-
onPress={() =>
|
|
65
|
-
{
|
|
66
|
-
if (focusabilityState === FocusabilityState.NoFocus)
|
|
67
|
-
{
|
|
68
|
-
setFocusabilityState(FocusabilityState.Focusable);
|
|
69
|
-
}
|
|
70
|
-
else if (focusabilityState === FocusabilityState.Focusable)
|
|
71
|
-
{
|
|
72
|
-
setFocusabilityState(FocusabilityState.Selectable);
|
|
73
|
-
}
|
|
74
|
-
}} />
|
|
75
|
-
<TextWin32
|
|
76
|
-
focusable={focusabilityState === FocusabilityState.Focusable}
|
|
77
|
-
selectable={focusabilityState === FocusabilityState.Selectable}
|
|
78
|
-
>
|
|
79
|
-
This text is currently...
|
|
80
|
-
</TextWin32>
|
|
81
|
-
<TextWin32>
|
|
82
|
-
{(focusabilityState === FocusabilityState.NoFocus) ? 'No Focusability' :
|
|
83
|
-
(focusabilityState === FocusabilityState.Focusable) ? 'Focusable' :
|
|
84
|
-
'Selectable'}
|
|
85
|
-
</TextWin32>
|
|
86
|
-
</ViewWin32>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const BlurringAndFocusingTextTest: React.FC<{}> = () => {
|
|
91
|
-
const [isFocusableFocused, setIsFocusableFocused] = React.useState(false);
|
|
92
|
-
const [isSelectableFocused, setIsSelectableFocused] = React.useState(false);
|
|
93
|
-
return (
|
|
94
|
-
<View>
|
|
95
|
-
<TextWin32
|
|
96
|
-
focusable
|
|
97
|
-
onBlur={() => setIsFocusableFocused(false)}
|
|
98
|
-
onFocus={() => setIsFocusableFocused(true)}>Focusable text is focused:</TextWin32>
|
|
99
|
-
<TextWin32
|
|
100
|
-
textStyle={isFocusableFocused ? 'MediumBold' : 'MediumStandard'}>{isFocusableFocused ? 'true' : 'false'}</TextWin32>
|
|
101
|
-
<TextWin32
|
|
102
|
-
selectable
|
|
103
|
-
onBlur={() => setIsSelectableFocused(false)}
|
|
104
|
-
onFocus={() => setIsSelectableFocused(true)}>Selectable text is focused:</TextWin32>
|
|
105
|
-
<TextWin32
|
|
106
|
-
textStyle={isSelectableFocused ? 'MediumBold' : 'MediumStandard'}>{isSelectableFocused ? 'true' : 'false'}</TextWin32>
|
|
107
|
-
</View>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const title = 'TextWin32';
|
|
112
|
-
export const displayName = 'TextWin32';
|
|
113
|
-
export const description = 'TextWin32 Examples and Tests';
|
|
114
|
-
export const examples = [
|
|
115
|
-
{
|
|
116
|
-
title: 'Text Runs Example',
|
|
117
|
-
description: 'text runs in action',
|
|
118
|
-
render(): JSX.Element {
|
|
119
|
-
return (<TextRunsTest />);
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
title: 'Focusable Example',
|
|
124
|
-
description: 'focusable in action',
|
|
125
|
-
render(): JSX.Element {
|
|
126
|
-
return (<FocusableTextTest />);
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
title: 'Selectable Example',
|
|
131
|
-
description: 'selectable in action',
|
|
132
|
-
render(): JSX.Element {
|
|
133
|
-
return (<SelectableTextTest />);
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
title: 'TextStyle Example',
|
|
138
|
-
description: 'TextStyles in action',
|
|
139
|
-
render(): JSX.Element {
|
|
140
|
-
return (<TextStyleTest />);
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
title: 'Tooltip Example',
|
|
145
|
-
description: 'tooltips in action',
|
|
146
|
-
render(): JSX.Element {
|
|
147
|
-
return (<TooltipTextTest />);
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
title: 'TextPromotion Example',
|
|
152
|
-
description: 'dynamic increases in focusability in action',
|
|
153
|
-
render(): JSX.Element {
|
|
154
|
-
return (<TextPromotionTest />);
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
title: 'Focus and Blur Example',
|
|
159
|
-
description: 'onFocus/onBlur in action',
|
|
160
|
-
render(): JSX.Element {
|
|
161
|
-
return (<BlurringAndFocusingTextTest />);
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
];
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and 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
|
-
* @format
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type * as React from 'react';
|
|
11
|
-
import {Constructor} from '../../../types/private/Utilities';
|
|
12
|
-
import {ColorValue} from '../../StyleSheet/StyleSheet';
|
|
13
|
-
import {TouchableMixin} from './Touchable';
|
|
14
|
-
|
|
15
|
-
import type {TVProps} from './TouchableOpacity';
|
|
16
|
-
import {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';
|
|
17
|
-
|
|
18
|
-
interface BaseBackgroundPropType {
|
|
19
|
-
type: string;
|
|
20
|
-
rippleRadius?: number | null | undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface RippleBackgroundPropType extends BaseBackgroundPropType {
|
|
24
|
-
type: 'RippleAndroid';
|
|
25
|
-
borderless: boolean;
|
|
26
|
-
color?: number | null | undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface ThemeAttributeBackgroundPropType extends BaseBackgroundPropType {
|
|
30
|
-
type: 'ThemeAttrAndroid';
|
|
31
|
-
attribute: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type BackgroundPropType =
|
|
35
|
-
| RippleBackgroundPropType
|
|
36
|
-
| ThemeAttributeBackgroundPropType;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @see https://reactnative.dev/docs/touchablenativefeedback#props
|
|
40
|
-
*/
|
|
41
|
-
export interface TouchableNativeFeedbackProps
|
|
42
|
-
extends TouchableWithoutFeedbackProps,
|
|
43
|
-
TVProps {
|
|
44
|
-
/**
|
|
45
|
-
* Determines the type of background drawable that's going to be used to display feedback.
|
|
46
|
-
* It takes an object with type property and extra data depending on the type.
|
|
47
|
-
* It's recommended to use one of the following static methods to generate that dictionary:
|
|
48
|
-
* 1) TouchableNativeFeedback.SelectableBackground() - will create object that represents android theme's
|
|
49
|
-
* default background for selectable elements (?android:attr/selectableItemBackground)
|
|
50
|
-
* 2) TouchableNativeFeedback.SelectableBackgroundBorderless() - will create object that represent android
|
|
51
|
-
* theme's default background for borderless selectable elements
|
|
52
|
-
* (?android:attr/selectableItemBackgroundBorderless). Available on android API level 21+
|
|
53
|
-
* 3) TouchableNativeFeedback.Ripple(color, borderless) - will create object that represents ripple drawable
|
|
54
|
-
* with specified color (as a string). If property borderless evaluates to true the ripple will render
|
|
55
|
-
* outside of the view bounds (see native actionbar buttons as an example of that behavior). This background
|
|
56
|
-
* type is available on Android API level 21+
|
|
57
|
-
*/
|
|
58
|
-
background?: BackgroundPropType | undefined;
|
|
59
|
-
useForeground?: boolean | undefined;
|
|
60
|
-
|
|
61
|
-
tooltip?: string; // Win32
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* A wrapper for making views respond properly to touches (Android only).
|
|
66
|
-
* On Android this component uses native state drawable to display touch feedback.
|
|
67
|
-
* At the moment it only supports having a single View instance as a child node,
|
|
68
|
-
* as it's implemented by replacing that View with another instance of RCTView node with some additional properties set.
|
|
69
|
-
*
|
|
70
|
-
* Background drawable of native feedback touchable can be customized with background property.
|
|
71
|
-
*
|
|
72
|
-
* @see https://reactnative.dev/docs/touchablenativefeedback#content
|
|
73
|
-
*/
|
|
74
|
-
declare class TouchableNativeFeedbackComponent extends React.Component<TouchableNativeFeedbackProps> {}
|
|
75
|
-
declare const TouchableNativeFeedbackBase: Constructor<TouchableMixin> &
|
|
76
|
-
typeof TouchableNativeFeedbackComponent;
|
|
77
|
-
export class TouchableNativeFeedback extends TouchableNativeFeedbackBase {
|
|
78
|
-
/**
|
|
79
|
-
* Creates an object that represents android theme's default background for
|
|
80
|
-
* selectable elements (?android:attr/selectableItemBackground).
|
|
81
|
-
*
|
|
82
|
-
* @param rippleRadius The radius of ripple effect
|
|
83
|
-
*/
|
|
84
|
-
static SelectableBackground(
|
|
85
|
-
rippleRadius?: number | null,
|
|
86
|
-
): ThemeAttributeBackgroundPropType;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Creates an object that represent android theme's default background for borderless
|
|
90
|
-
* selectable elements (?android:attr/selectableItemBackgroundBorderless).
|
|
91
|
-
* Available on android API level 21+.
|
|
92
|
-
*
|
|
93
|
-
* @param rippleRadius The radius of ripple effect
|
|
94
|
-
*/
|
|
95
|
-
static SelectableBackgroundBorderless(
|
|
96
|
-
rippleRadius?: number | null,
|
|
97
|
-
): ThemeAttributeBackgroundPropType;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Creates an object that represents ripple drawable with specified color (as a
|
|
101
|
-
* string). If property `borderless` evaluates to true the ripple will
|
|
102
|
-
* render outside of the view bounds (see native actionbar buttons as an
|
|
103
|
-
* example of that behavior). This background type is available on Android
|
|
104
|
-
* API level 21+.
|
|
105
|
-
*
|
|
106
|
-
* @param color The ripple color
|
|
107
|
-
* @param borderless If the ripple can render outside it's bounds
|
|
108
|
-
* @param rippleRadius The radius of ripple effect
|
|
109
|
-
*/
|
|
110
|
-
static Ripple(
|
|
111
|
-
color: ColorValue,
|
|
112
|
-
borderless: boolean,
|
|
113
|
-
rippleRadius?: number | null,
|
|
114
|
-
): RippleBackgroundPropType;
|
|
115
|
-
static canUseNativeForeground(): boolean;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// For backcompat
|
|
119
|
-
export type ITouchableNativeFeedbackProps = TouchableNativeFeedbackProps;
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { StyleSheet, Text, TouchableHighlight } from 'react-native';
|
|
4
|
-
import { Cursor, IKeyboardEvent, IHandledKeyboardEvent, ViewWin32 } from '@office-iss/react-native-win32';
|
|
5
|
-
|
|
6
|
-
const styles = StyleSheet.create({
|
|
7
|
-
border: {
|
|
8
|
-
borderStyle: 'dotted',
|
|
9
|
-
borderColor: 'black',
|
|
10
|
-
},
|
|
11
|
-
keyComponentRoot: {
|
|
12
|
-
borderWidth: 2,
|
|
13
|
-
flexDirection: 'row',
|
|
14
|
-
marginVertical: 5,
|
|
15
|
-
backgroundColor: 'whitesmoke',
|
|
16
|
-
justifyContent: 'space-around',
|
|
17
|
-
},
|
|
18
|
-
keyEnterVisualizer: {
|
|
19
|
-
margin: 5,
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
minWidth: 100,
|
|
22
|
-
minHeight: 30,
|
|
23
|
-
},
|
|
24
|
-
blackbox: { height: 30, width: 30, borderColor: 'black', borderWidth: 3 },
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
interface IFocusableComponentState {
|
|
28
|
-
hasFocus: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function FocusMoverTestComponent() {
|
|
32
|
-
const [hasFocus, setHasFocus] = React.useState<boolean>(false);
|
|
33
|
-
|
|
34
|
-
const labelId = React.useId();
|
|
35
|
-
|
|
36
|
-
const ref = React.useRef<ViewWin32>(null);
|
|
37
|
-
const onBtnPress = () => {
|
|
38
|
-
if (ref.current) {
|
|
39
|
-
ref.current.focus();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<ViewWin32>
|
|
45
|
-
<ViewWin32 nativeID={labelId} accessibilityLabel="separate label for test" accessibilityItemType="Comment" />
|
|
46
|
-
<ViewWin32 style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around', marginVertical: 5 }}>
|
|
47
|
-
<TouchableHighlight onPress={onBtnPress}>
|
|
48
|
-
<ViewWin32 accessibilityLabelledBy={labelId} style={styles.blackbox} />
|
|
49
|
-
</TouchableHighlight>
|
|
50
|
-
<ViewWin32
|
|
51
|
-
ref={ref}
|
|
52
|
-
focusable
|
|
53
|
-
style={hasFocus ? { backgroundColor: '#aee8fcff' } : { backgroundColor: '#00000000' }}
|
|
54
|
-
onFocus={() => setHasFocus(true)}
|
|
55
|
-
onBlur={() => setHasFocus(false)}
|
|
56
|
-
enableFocusRing={false}
|
|
57
|
-
>
|
|
58
|
-
<Text>{hasFocus ? 'Focus: Yes' : 'Focus: No'}</Text>
|
|
59
|
-
</ViewWin32>
|
|
60
|
-
</ViewWin32>
|
|
61
|
-
</ViewWin32>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface IKeyboardableComponentState {
|
|
66
|
-
lastKeyDown: string;
|
|
67
|
-
lastKeyUp: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const handledNativeKeyboardEvents: IHandledKeyboardEvent[] = [
|
|
71
|
-
{ key: 'ArrowDown' },
|
|
72
|
-
{ key: 'ArrowUp' },
|
|
73
|
-
{ key: 'ArrowLeft' },
|
|
74
|
-
{ key: 'ArrowRight' },
|
|
75
|
-
{ key: 'Tab' },
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
class KeyboardTestComponent extends React.Component<{}, IFocusableComponentState & IKeyboardableComponentState> {
|
|
79
|
-
public constructor(props) {
|
|
80
|
-
super(props);
|
|
81
|
-
this.state = {
|
|
82
|
-
hasFocus: false,
|
|
83
|
-
lastKeyDown: null,
|
|
84
|
-
lastKeyUp: null,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public render() {
|
|
89
|
-
return (
|
|
90
|
-
<ViewWin32 keyDownEvents={handledNativeKeyboardEvents} keyUpEvents={handledNativeKeyboardEvents}>
|
|
91
|
-
<ViewWin32
|
|
92
|
-
style={this.state.hasFocus ? [styles.keyComponentRoot, styles.border] : styles.keyComponentRoot}
|
|
93
|
-
focusable
|
|
94
|
-
onKeyUp={this._onKeyUp}
|
|
95
|
-
onKeyDown={this._onKeyDown}
|
|
96
|
-
onFocus={this._onFocus}
|
|
97
|
-
onBlur={this._onBlur}
|
|
98
|
-
enableFocusRing={false}
|
|
99
|
-
>
|
|
100
|
-
<ViewWin32 style={styles.keyEnterVisualizer}>
|
|
101
|
-
<Text>OnKeyDown</Text>
|
|
102
|
-
<Text>----</Text>
|
|
103
|
-
<Text>{this.state.lastKeyDown !== null ? this.state.lastKeyDown : ' '}</Text>
|
|
104
|
-
</ViewWin32>
|
|
105
|
-
<ViewWin32 style={styles.keyEnterVisualizer}>
|
|
106
|
-
<Text>OnKeyUp</Text>
|
|
107
|
-
<Text>----</Text>
|
|
108
|
-
<Text>{this.state.lastKeyUp !== null ? this.state.lastKeyUp : ' '}</Text>
|
|
109
|
-
</ViewWin32>
|
|
110
|
-
</ViewWin32>
|
|
111
|
-
</ViewWin32>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private readonly _onFocus = () => {
|
|
116
|
-
this.setState({
|
|
117
|
-
hasFocus: true,
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
private readonly _onBlur = () => {
|
|
122
|
-
this.setState({
|
|
123
|
-
hasFocus: false,
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
private readonly _onKeyUp = (ev: IKeyboardEvent) => {
|
|
128
|
-
this.setState({ lastKeyUp: ev.nativeEvent.key, lastKeyDown: null });
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
private readonly _onKeyDown = (ev: IKeyboardEvent) => {
|
|
132
|
-
this.setState({ lastKeyDown: ev.nativeEvent.key, lastKeyUp: null });
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface IHoverComponentProps {
|
|
137
|
-
color: string;
|
|
138
|
-
}
|
|
139
|
-
class HoverTestComponent extends React.Component<IHoverComponentProps, IFocusableComponentState> {
|
|
140
|
-
public constructor(props) {
|
|
141
|
-
super(props);
|
|
142
|
-
this.state = {
|
|
143
|
-
hasFocus: false,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
public render() {
|
|
148
|
-
return (
|
|
149
|
-
<ViewWin32
|
|
150
|
-
onMouseEnter={this._onMouseEnter}
|
|
151
|
-
onMouseLeave={this._onMouseLeave}
|
|
152
|
-
style={this.state.hasFocus ? [styles.blackbox, { backgroundColor: this.props.color }] : styles.blackbox}
|
|
153
|
-
/>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
private readonly _onMouseLeave = () => {
|
|
157
|
-
this.setState({ hasFocus: false });
|
|
158
|
-
};
|
|
159
|
-
private readonly _onMouseEnter = () => {
|
|
160
|
-
this.setState({ hasFocus: true });
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
class HoverExample extends React.Component {
|
|
165
|
-
public render() {
|
|
166
|
-
return (
|
|
167
|
-
<ViewWin32 style={{ flexDirection: 'row', marginHorizontal: 75, justifyContent: 'space-around' }}>
|
|
168
|
-
<HoverTestComponent color="red" />
|
|
169
|
-
<HoverTestComponent color="orange" />
|
|
170
|
-
<HoverTestComponent color="yellow" />
|
|
171
|
-
<HoverTestComponent color="green" />
|
|
172
|
-
<HoverTestComponent color="blue" />
|
|
173
|
-
<HoverTestComponent color="indigo" />
|
|
174
|
-
<HoverTestComponent color="violet" />
|
|
175
|
-
</ViewWin32>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const ToolTipExample: React.FunctionComponent<{}> = () => {
|
|
181
|
-
return (
|
|
182
|
-
<ViewWin32
|
|
183
|
-
style={{
|
|
184
|
-
backgroundColor: 'red',
|
|
185
|
-
height: 100,
|
|
186
|
-
width: 100,
|
|
187
|
-
}}
|
|
188
|
-
tooltip="Example tooltip"
|
|
189
|
-
cursor="pointer"
|
|
190
|
-
/>
|
|
191
|
-
);
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
interface ICursorTestComponentProps {
|
|
195
|
-
cursor: Cursor
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const CursorTestComponent: React.FunctionComponent<ICursorTestComponentProps> = (props) => {
|
|
199
|
-
return (
|
|
200
|
-
<ViewWin32 style={{flexDirection: 'column'}}>
|
|
201
|
-
<Text>{props.cursor}</Text>
|
|
202
|
-
<ViewWin32 cursor={props.cursor} style={styles.blackbox} />
|
|
203
|
-
</ViewWin32>
|
|
204
|
-
)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const CursorExample: React.FunctionComponent = () => {
|
|
208
|
-
return (
|
|
209
|
-
<ViewWin32 style={{ flexDirection: 'row', justifyContent: 'space-around' }}>
|
|
210
|
-
<CursorTestComponent cursor='auto' />
|
|
211
|
-
<CursorTestComponent cursor='default' />
|
|
212
|
-
<CursorTestComponent cursor='help' />
|
|
213
|
-
<CursorTestComponent cursor='nesw-resize' />
|
|
214
|
-
<CursorTestComponent cursor='not-allowed' />
|
|
215
|
-
<CursorTestComponent cursor='ns-resize' />
|
|
216
|
-
<CursorTestComponent cursor='nwse-resize' />
|
|
217
|
-
<CursorTestComponent cursor='pointer' />
|
|
218
|
-
<CursorTestComponent cursor='wait' />
|
|
219
|
-
<CursorTestComponent cursor='move' />
|
|
220
|
-
<CursorTestComponent cursor='text' />
|
|
221
|
-
<CursorTestComponent cursor='we-resize' />
|
|
222
|
-
</ViewWin32>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
class EnableFocusRingExample extends React.Component<{}, IFocusableComponentState> {
|
|
226
|
-
public constructor(props) {
|
|
227
|
-
super(props);
|
|
228
|
-
this.state = {
|
|
229
|
-
hasFocus: false,
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
public render() {
|
|
234
|
-
return (
|
|
235
|
-
<ViewWin32 style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around', marginVertical: 5 }}>
|
|
236
|
-
<ViewWin32
|
|
237
|
-
style={{
|
|
238
|
-
backgroundColor: 'pink',
|
|
239
|
-
height: 100,
|
|
240
|
-
width: 100,
|
|
241
|
-
}}
|
|
242
|
-
enableFocusRing={true}
|
|
243
|
-
focusable
|
|
244
|
-
>
|
|
245
|
-
<Text>enableFocusRing set to true</Text>
|
|
246
|
-
</ViewWin32>
|
|
247
|
-
<ViewWin32
|
|
248
|
-
style={{
|
|
249
|
-
backgroundColor: 'pink',
|
|
250
|
-
height: 100,
|
|
251
|
-
width: 100,
|
|
252
|
-
}}
|
|
253
|
-
enableFocusRing={false}
|
|
254
|
-
focusable
|
|
255
|
-
onFocus={this._onFocus}
|
|
256
|
-
onBlur={this._onBlur}
|
|
257
|
-
>
|
|
258
|
-
<>
|
|
259
|
-
<Text>enableFocusRing set to false</Text>
|
|
260
|
-
<Text>{this.state.hasFocus ? 'Focus: Yes' : 'Focus: No'}</Text>
|
|
261
|
-
</>
|
|
262
|
-
</ViewWin32>
|
|
263
|
-
</ViewWin32>
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private readonly _onFocus = () => {
|
|
268
|
-
this.setState({
|
|
269
|
-
hasFocus: true,
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
private readonly _onBlur = () => {
|
|
274
|
-
this.setState({
|
|
275
|
-
hasFocus: false,
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
export const title = 'ViewWin32';
|
|
282
|
-
export const displayName = 'ViewWin32 Example';
|
|
283
|
-
export const description = 'All the stock View props plus Win32 specific ones';
|
|
284
|
-
export const examples = [
|
|
285
|
-
{
|
|
286
|
-
title: 'focus() method example',
|
|
287
|
-
description: 'Each of these black boxes moves focus to the ViewWin32 on the right',
|
|
288
|
-
render(): JSX.Element {
|
|
289
|
-
return (
|
|
290
|
-
<ViewWin32>
|
|
291
|
-
<FocusMoverTestComponent />
|
|
292
|
-
<FocusMoverTestComponent />
|
|
293
|
-
<FocusMoverTestComponent />
|
|
294
|
-
</ViewWin32>
|
|
295
|
-
);
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
title: 'KeyboardEvents example',
|
|
300
|
-
description: 'Native keyboarding has been prevented',
|
|
301
|
-
render(): JSX.Element {
|
|
302
|
-
return <KeyboardTestComponent />;
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
title: 'Hover example',
|
|
307
|
-
description: 'Hover a rainbow',
|
|
308
|
-
render(): JSX.Element {
|
|
309
|
-
return <HoverExample />;
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
title: 'Tooltip example',
|
|
314
|
-
description: 'Displays a tooltip on hover',
|
|
315
|
-
render(): JSX.Element {
|
|
316
|
-
return <ToolTipExample />;
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
title: 'Cursor example',
|
|
321
|
-
description: 'Each of these boxes should display a different cursor',
|
|
322
|
-
render(): JSX.Element {
|
|
323
|
-
return <CursorExample />;
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
title: 'EnableFocusRing example',
|
|
328
|
-
description: 'Displays focus visuals that are driven by native',
|
|
329
|
-
render(): JSX.Element {
|
|
330
|
-
return <EnableFocusRingExample />;
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
];
|