@enact/ui 4.6.1 → 4.7.0
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/AnnounceDecorator/Announce.js +27 -15
- package/AnnounceDecorator/AnnounceDecorator.d.ts +64 -0
- package/AnnounceDecorator/AnnounceDecorator.js +15 -6
- package/AnnounceDecorator/useAnnounce.js +1 -2
- package/BodyText/BodyText.d.ts +66 -0
- package/BodyText/BodyText.js +14 -6
- package/Button/Button.d.ts +125 -0
- package/Button/Button.js +18 -10
- package/CHANGELOG.md +14 -0
- package/Cancelable/Cancelable.d.ts +64 -0
- package/Cancelable/Cancelable.js +17 -9
- package/Cancelable/tests/Cancelable-specs.js +3 -1
- package/Changeable/Changeable.d.ts +54 -0
- package/Changeable/Changeable.js +15 -9
- package/ComponentOverride/ComponentOverride.d.ts +52 -0
- package/ComponentOverride/ComponentOverride.js +18 -5
- package/FloatingLayer/FloatingLayer.js +14 -13
- package/FloatingLayer/FloatingLayerContainer.js +3 -1
- package/FloatingLayer/FloatingLayerDecorator.js +11 -6
- package/FloatingLayer/Scrim.js +4 -2
- package/FloatingLayer/index.d.ts +100 -0
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +3 -1
- package/FloatingLayer/useFloatingLayer.js +2 -2
- package/ForwardRef/ForwardRef.d.ts +22 -0
- package/ForwardRef/ForwardRef.js +13 -7
- package/GridListImageItem/GridListImageItem.d.ts +85 -0
- package/GridListImageItem/GridListImageItem.js +16 -7
- package/Group/Group.d.ts +107 -0
- package/Group/Group.js +17 -6
- package/Group/GroupItem.js +16 -10
- package/Heading/Heading.d.ts +89 -0
- package/Heading/Heading.js +22 -9
- package/Icon/Icon.d.ts +88 -0
- package/Icon/Icon.js +15 -6
- package/IconButton/IconButton.d.ts +115 -0
- package/IconButton/IconButton.js +26 -11
- package/Image/Image.d.ts +113 -0
- package/Image/Image.js +16 -6
- package/ImageItem/ImageItem.d.ts +83 -0
- package/ImageItem/ImageItem.js +12 -2
- package/ImageItem/tests/ImageItem-specs.js +3 -1
- package/Item/Item.d.ts +64 -0
- package/Item/Item.js +17 -7
- package/LabeledIcon/LabeledIcon.d.ts +130 -0
- package/LabeledIcon/LabeledIcon.js +16 -6
- package/Layout/Cell.js +30 -5
- package/Layout/Layout.d.ts +284 -0
- package/Layout/Layout.js +181 -36
- package/Layout/Layout.module.css +8 -0
- package/Layout/tests/Layout-specs.js +44 -3
- package/Marquee/MarqueeBase.js +3 -1
- package/Marquee/MarqueeController.js +54 -2
- package/Marquee/MarqueeDecorator.js +44 -4
- package/Marquee/index.d.ts +258 -0
- package/Marquee/tests/Marquee-specs.js +3 -1
- package/Measurable/Measurable.d.ts +26 -0
- package/Measurable/Measurable.js +16 -10
- package/Measurable/tests/Measurable-specs.js +8 -6
- package/Media/Media.d.ts +99 -0
- package/Media/Media.js +36 -27
- package/Placeholder/PlaceholderControllerDecorator.js +13 -10
- package/Placeholder/PlaceholderDecorator.js +11 -10
- package/Placeholder/index.d.ts +53 -0
- package/ProgressBar/ProgressBar.d.ts +92 -0
- package/ProgressBar/ProgressBar.js +14 -1
- package/README.md +1 -1
- package/RadioDecorator/RadioControllerDecorator.js +4 -2
- package/RadioDecorator/RadioDecorator.d.ts +35 -0
- package/RadioDecorator/RadioDecorator.js +17 -9
- package/Repeater/Repeater.d.ts +82 -0
- package/Repeater/Repeater.js +16 -10
- package/Repeater/tests/Repeater-specs.js +3 -1
- package/Resizable/Resizable.d.ts +31 -0
- package/Resizable/Resizable.js +16 -10
- package/Routable/Link.js +12 -10
- package/Routable/Routable.d.ts +148 -0
- package/Routable/Routable.js +17 -8
- package/Routable/Router.js +14 -12
- package/Routable/tests/Routable-specs.js +5 -3
- package/Scrollable/ScrollAnimator.js +3 -1
- package/Scrollable/ScrollThumb.js +10 -9
- package/Scrollable/Scrollable.d.ts +0 -0
- package/Scrollable/Scrollable.js +27 -3
- package/Scrollable/ScrollableNative.js +16 -2
- package/Scrollable/Scrollbar.js +4 -2
- package/Scroller/Scroller.d.ts +276 -0
- package/Scroller/Scroller.js +10 -1
- package/Scroller/ScrollerBasic.js +12 -11
- package/Scroller/UiScrollerBase.js +15 -14
- package/Skinnable/Skinnable.d.ts +94 -0
- package/Skinnable/Skinnable.js +20 -6
- package/Skinnable/tests/Skinnable-specs.js +3 -1
- package/Skinnable/tests/useSkins-specs.js +3 -1
- package/Skinnable/useSkins.js +1 -2
- package/Slider/Knob.js +8 -6
- package/Slider/PositionDecorator.js +4 -2
- package/Slider/Slider.d.ts +202 -0
- package/Slider/Slider.js +18 -9
- package/SlotItem/SlotItem.d.ts +118 -0
- package/SlotItem/SlotItem.js +20 -6
- package/Slottable/Slottable.d.ts +22 -0
- package/Slottable/Slottable.js +16 -8
- package/Slottable/useSlots.js +3 -1
- package/Spinner/Spinner.d.ts +95 -0
- package/Spinner/Spinner.js +24 -7
- package/ToggleIcon/ToggleIcon.d.ts +90 -0
- package/ToggleIcon/ToggleIcon.js +21 -7
- package/ToggleItem/ToggleItem.d.ts +132 -0
- package/ToggleItem/ToggleItem.js +17 -2
- package/ToggleItem/tests/ToggleItem-specs.js +3 -1
- package/Toggleable/Toggle.js +4 -2
- package/Toggleable/Toggleable.d.ts +103 -0
- package/Toggleable/Toggleable.js +13 -7
- package/Toggleable/useToggle.js +1 -2
- package/Touchable/ClickAllow.js +3 -1
- package/Touchable/Drag.js +6 -3
- package/Touchable/Flick.js +6 -2
- package/Touchable/Hold.js +6 -2
- package/Touchable/Pinch.js +6 -3
- package/Touchable/Touch.js +6 -4
- package/Touchable/Touchable.d.ts +217 -0
- package/Touchable/Touchable.js +10 -1
- package/Touchable/config.js +3 -1
- package/Touchable/tests/useTouch-specs.js +3 -1
- package/Touchable/useTouch.js +5 -4
- package/Transition/Transition.d.ts +194 -0
- package/Transition/Transition.js +22 -4
- package/Transition/tests/Transition-specs.js +5 -3
- package/ViewManager/Arranger.js +6 -1
- package/ViewManager/TransitionGroup.js +8 -5
- package/ViewManager/View.js +7 -4
- package/ViewManager/ViewManager.d.ts +191 -0
- package/ViewManager/ViewManager.js +29 -11
- package/ViewManager/tests/ViewManager-specs.js +47 -1
- package/VirtualList/UiVirtualListBase.js +9 -3
- package/VirtualList/VirtualList.d.ts +528 -0
- package/VirtualList/VirtualList.js +13 -1
- package/VirtualList/VirtualListBasic.js +9 -3
- package/VirtualList/tests/VirtualGridList-native-specs.js +3 -1
- package/VirtualList/tests/VirtualGridList-specs.js +3 -1
- package/VirtualList/tests/VirtualList-native-specs.js +3 -1
- package/VirtualList/tests/VirtualList-specs.js +3 -1
- package/index.d.ts +0 -0
- package/internal/IdProvider/IdProvider.d.ts +0 -0
- package/internal/IdProvider/IdProvider.js +8 -7
- package/internal/IdProvider/Provider.js +3 -1
- package/internal/IdProvider/tests/IdProvider-specs.js +3 -1
- package/internal/IdProvider/tests/useId-specs.js +4 -3
- package/internal/IdProvider/useId.js +0 -1
- package/internal/Pure/Pure.d.ts +0 -0
- package/internal/Pure/Pure.js +15 -9
- package/internal/Pure/tests/Pure-specs.js +4 -2
- package/internal/localized-fonts/localized-fonts.d.ts +53 -0
- package/internal/localized-fonts/localized-fonts.js +2 -2
- package/internal/selection/selection.d.ts +0 -0
- package/internal/validators/validators.d.ts +0 -0
- package/package.json +2 -2
- package/resolution/ResolutionDecorator.js +40 -9
- package/resolution/index.d.ts +187 -0
- package/resolution/resolution.js +23 -7
- package/useControlledState/tests/useControlledState-specs.js +2 -2
- package/useControlledState/useControlledState.d.ts +0 -0
- package/useControlledState/useControlledState.js +2 -2
- package/useScroll/ScrollAnimator.js +3 -1
- package/useScroll/Scrollbar.js +6 -4
- package/useScroll/ScrollbarTrack.js +8 -6
- package/useScroll/useScroll.d.ts +0 -0
- package/useScroll/useScroll.js +80 -52
package/Touchable/Touch.js
CHANGED
|
@@ -17,8 +17,10 @@ var _Hold = require("./Hold");
|
|
|
17
17
|
var _Pinch = require("./Pinch");
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
20
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
21
21
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
24
|
var getEventCoordinates = function getEventCoordinates(ev) {
|
|
23
25
|
var x = ev.clientX,
|
|
24
26
|
y = ev.clientY,
|
|
@@ -69,8 +71,8 @@ var makeTouchableEvent = function makeTouchableEvent(type) {
|
|
|
69
71
|
};
|
|
70
72
|
};
|
|
71
73
|
var isEnabled = (0, _handle.forProp)('disabled', false);
|
|
72
|
-
var handleDown = (0, _handle.handle)(isEnabled, (0, _handle.
|
|
73
|
-
var handleUp = (0, _handle.handle)(isEnabled, (0, _handle.call)('endGesture'), (0, _handle.call)('isTracking'), (0, _handle.
|
|
74
|
+
var handleDown = (0, _handle.handle)(isEnabled, (0, _handle.forwardCustomWithPrevent)('onDown', makeTouchableEvent('onDown')), (0, _handle.call)('activate'), (0, _handle.call)('startGesture')).named('handleDown');
|
|
75
|
+
var handleUp = (0, _handle.handle)(isEnabled, (0, _handle.call)('endGesture'), (0, _handle.call)('isTracking'), (0, _handle.forwardCustomWithPrevent)('onUp', makeTouchableEvent('onUp')), (0, _handle.forwardCustom)('onTap', makeTouchableEvent('onTap')))["finally"]((0, _handle.call)('deactivate')).named('handleUp');
|
|
74
76
|
var handleEnter = (0, _handle.handle)(isEnabled, (0, _handle.forProp)('noResume', false), (0, _handle.call)('enterGesture'), (0, _handle.call)('isPaused'), (0, _handle.call)('activate')).named('handleEnter');
|
|
75
77
|
var handleLeave = (0, _handle.handle)(isEnabled, (0, _handle.call)('leaveGesture'), (0, _handle.oneOf)([(0, _handle.forProp)('noResume', false), (0, _handle.call)('pause')], [_handle.returnsTrue, (0, _handle.call)('deactivate')])).named('handleLeave');
|
|
76
78
|
|
|
@@ -94,7 +96,7 @@ var handleTouchMove = (0, _handle.handle)((0, _handle.forward)('onTouchMove'), (
|
|
|
94
96
|
// detecting when the touch leaves the boundary. oneOf returns the value of whichever
|
|
95
97
|
// branch it follows so we append moveHold to either to handle moves that aren't
|
|
96
98
|
// entering or leaving
|
|
97
|
-
(0, _handle.
|
|
99
|
+
(0, _handle.forwardCustom)('onMove', makeTouchableEvent('onMove')), (0, _handle.oneOf)([(0, _handle.call)('hasTouchLeftTarget'), handleLeave], [_handle.returnsTrue, handleEnter])["finally"]((0, _handle.call)('moveGesture')));
|
|
98
100
|
var handleTouchEnd = (0, _handle.handle)((0, _handle.forward)('onTouchEnd'),
|
|
99
101
|
// block the next mousedown to prevent duplicate touchable events
|
|
100
102
|
(0, _handle.returnsTrue)((0, _handle.call)('setLastTouchEnd')), (0, _handle.call)('isTracking'), (0, _complement["default"])((0, _handle.call)('hasTouchLeftTarget')), (0, _handle.returnsTrue)((0, _handle.call)('endTouch')), handleUp);
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Type definitions for ui/Touchable
|
|
2
|
+
|
|
3
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
4
|
+
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
5
|
+
|
|
6
|
+
export interface TouchableConfig extends Object {
|
|
7
|
+
/**
|
|
8
|
+
* Configures the prop name to pass the active state to the wrapped component
|
|
9
|
+
*/
|
|
10
|
+
activeProp?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TouchableProps {
|
|
13
|
+
/**
|
|
14
|
+
* Disables the component.
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Instance-specific overrides of the drag configuration.
|
|
19
|
+
*/
|
|
20
|
+
dragConfig?: object;
|
|
21
|
+
/**
|
|
22
|
+
* Instance-specific overrides of the flick configuration.
|
|
23
|
+
*/
|
|
24
|
+
flickConfig?: object;
|
|
25
|
+
/**
|
|
26
|
+
* Instance-specific overrides of the hold configuration.
|
|
27
|
+
*/
|
|
28
|
+
holdConfig?: object;
|
|
29
|
+
/**
|
|
30
|
+
* Prevents resuming the touch events and gestures when re-entering the component.
|
|
31
|
+
*/
|
|
32
|
+
noResume?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Event handler for 'down' pointer events.
|
|
35
|
+
*/
|
|
36
|
+
onDown?: Function;
|
|
37
|
+
/**
|
|
38
|
+
* Event handler for a drag gesture.
|
|
39
|
+
*
|
|
40
|
+
* Event payload includes:
|
|
41
|
+
* * `type` - Type of event, `'onDrag'`
|
|
42
|
+
* * `x` - Horizontal position of the drag, relative to the viewport
|
|
43
|
+
* * `y` - Vertical position of the drag, relative to the viewport
|
|
44
|
+
*/
|
|
45
|
+
onDrag?: Function;
|
|
46
|
+
/**
|
|
47
|
+
* Event handler for the end of a drag gesture.
|
|
48
|
+
*
|
|
49
|
+
* Event payload includes:
|
|
50
|
+
* * `type` - Type of event, `'onDragEnd'`
|
|
51
|
+
*/
|
|
52
|
+
onDragEnd?: Function;
|
|
53
|
+
/**
|
|
54
|
+
* Event handler for the start of a drag gesture.
|
|
55
|
+
*
|
|
56
|
+
* Event payload includes:
|
|
57
|
+
* * `type` - Type of event, `'onDragStart'`
|
|
58
|
+
* * `x` - Horizontal position of the drag, relative to the viewport
|
|
59
|
+
* * `y` - Vertical position of the drag, relative to the viewport
|
|
60
|
+
*/
|
|
61
|
+
onDragStart?: Function;
|
|
62
|
+
/**
|
|
63
|
+
* Event handler for a flick gesture.
|
|
64
|
+
*
|
|
65
|
+
* Event payload includes:
|
|
66
|
+
* * `type` - Type of event, `'onFlick'`
|
|
67
|
+
* * `direction` - Primary direction of the flick, either `'horizontal'` or `'vertical'`
|
|
68
|
+
* * `velocity` - Velocity of flick
|
|
69
|
+
* * `velocityX` - Velocity of flick along te horizontal axis
|
|
70
|
+
* * `velocityY` - Velocity of flick along te vertical axis
|
|
71
|
+
*/
|
|
72
|
+
onFlick?: Function;
|
|
73
|
+
/**
|
|
74
|
+
* Event handler for hold pulse events.
|
|
75
|
+
*
|
|
76
|
+
* Event payload includes:
|
|
77
|
+
* * `type` - Type of event, `'onHold'`
|
|
78
|
+
* * `time` - Time, in milliseconds, since the hold began
|
|
79
|
+
*/
|
|
80
|
+
onHold?: Function;
|
|
81
|
+
/**
|
|
82
|
+
* Event handler for the end of hold events.
|
|
83
|
+
*
|
|
84
|
+
* Event payload includes:
|
|
85
|
+
* * `type` - Type of event, `'onHoldEnd'`
|
|
86
|
+
* * `time` - Time, in milliseconds, since the hold began
|
|
87
|
+
*/
|
|
88
|
+
onHoldEnd?: Function;
|
|
89
|
+
/**
|
|
90
|
+
* Event handler for hold events.
|
|
91
|
+
*
|
|
92
|
+
* Event payload includes:
|
|
93
|
+
* * `type` - Type of event, `'onHoldStart'`
|
|
94
|
+
* * `name` - The name of the hold as configured in the events list
|
|
95
|
+
* * `time` - Time, in milliseconds, configured for this hold which may vary slightly
|
|
96
|
+
from time since the hold began
|
|
97
|
+
*/
|
|
98
|
+
onHoldStart?: Function;
|
|
99
|
+
/**
|
|
100
|
+
* Event handler for 'move' pointer events.
|
|
101
|
+
*/
|
|
102
|
+
onMove?: Function;
|
|
103
|
+
/**
|
|
104
|
+
* Event handler for a pinch gesture.
|
|
105
|
+
*
|
|
106
|
+
* Event payload includes:
|
|
107
|
+
* * `type` - Type of event, `'onPinch'`
|
|
108
|
+
* * `scale` - The scale factor, calculated from the distance while pinching.
|
|
109
|
+
The default value is 1.0. The value would be a number between
|
|
110
|
+
pinchConfig.minScale and pinchConfig.maxScale.
|
|
111
|
+
* * `coords` - The coordinates array of the touch point, relative to the viewport
|
|
112
|
+
*/
|
|
113
|
+
onPinch?: Function;
|
|
114
|
+
/**
|
|
115
|
+
* Event handler for the end of a pinch gesture.
|
|
116
|
+
*
|
|
117
|
+
* Event payload includes:
|
|
118
|
+
* * `type` - Type of event, `'onPinchEnd'`
|
|
119
|
+
*/
|
|
120
|
+
onPinchEnd?: Function;
|
|
121
|
+
/**
|
|
122
|
+
* Event handler for the start of a pinch gesture.
|
|
123
|
+
*
|
|
124
|
+
* Event payload includes:
|
|
125
|
+
* * `type` - Type of event, `'onPinchStart'`
|
|
126
|
+
* * `coords` - The coordinates array of the touch point, relative to the viewport
|
|
127
|
+
*/
|
|
128
|
+
onPinchStart?: Function;
|
|
129
|
+
/**
|
|
130
|
+
* Event handler for 'tap' pointer events.
|
|
131
|
+
*/
|
|
132
|
+
onTap?: Function;
|
|
133
|
+
/**
|
|
134
|
+
* Event handler for 'up' pointer events.
|
|
135
|
+
*/
|
|
136
|
+
onUp?: Function;
|
|
137
|
+
/**
|
|
138
|
+
* Instance-specific overrides of the pinch configuration.
|
|
139
|
+
*/
|
|
140
|
+
pinchConfig?: object;
|
|
141
|
+
}
|
|
142
|
+
export function Touchable<P>(
|
|
143
|
+
config: TouchableConfig,
|
|
144
|
+
Component: React.ComponentType<P> | string
|
|
145
|
+
): React.ComponentType<P & TouchableProps>;
|
|
146
|
+
|
|
147
|
+
export function Touchable<P>(
|
|
148
|
+
Component: React.ComponentType<P> | string
|
|
149
|
+
): React.ComponentType<P & TouchableProps>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Configures the global gesture configuration for the application.
|
|
153
|
+
*
|
|
154
|
+
* Example:
|
|
155
|
+
* ```
|
|
156
|
+
// Updates the `maxMoves`, `moveTolerance`, and `frequency` configurations while retaining the
|
|
157
|
+
// current value of all other configurations
|
|
158
|
+
configure({
|
|
159
|
+
flick: {
|
|
160
|
+
maxMoves: 10
|
|
161
|
+
},
|
|
162
|
+
hold: {
|
|
163
|
+
moveTolerance: 32,
|
|
164
|
+
frequency: 400
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
* Each type of gesture has its own set of configuration properties grouped within a separate object
|
|
170
|
+
keyed by the name of the gesture. Partial configurations may be passed and will be merged with
|
|
171
|
+
the current configuration.
|
|
172
|
+
*
|
|
173
|
+
* `drag`
|
|
174
|
+
* * `boxSizing` - The part of the component's box model is used as the bounds of the constraint.
|
|
175
|
+
Only applies when `global` is `false` .
|
|
176
|
+
* * `'border-box'` - the default, includes the padding and border but excludes the margin.
|
|
177
|
+
* * `'content-box'` - excludes the padding, border, and margin.
|
|
178
|
+
* * `global` - When `true` , drag gestures will continue when leaving the bounds of the component
|
|
179
|
+
or blurring the component.
|
|
180
|
+
* * `moveTolerance` - The number of pixels from the start position of the drag that the pointer
|
|
181
|
+
may move before cancelling the drag. Defaults to `16` .
|
|
182
|
+
*
|
|
183
|
+
* `flick`
|
|
184
|
+
* * `maxDuration` - The amount of time, in milliseconds, to complete a flick gesture before it
|
|
185
|
+
is cancelled. Defaults to 250.
|
|
186
|
+
* * `maxMoves` - The number of moves tracked to determine if a flick occurred. Defaults to `5` .
|
|
187
|
+
* * `minVelocity` - The minimum threshold, measured as the change in pixels over the change in
|
|
188
|
+
time per move, that must be exceeded to generate a `onFlick` event.
|
|
189
|
+
*
|
|
190
|
+
* `hold`
|
|
191
|
+
* * `cancelOnMove` - When `true` , the hold is cancelled when moving beyond the `moveTolerance` .
|
|
192
|
+
Defaults to `false`
|
|
193
|
+
* * `global` - When `true` , hold gestures will continue when leaving the bounds of the component
|
|
194
|
+
or blurring the component.
|
|
195
|
+
* * `moveTolerance` - The number of pixels from the start position of the hold that the pointer
|
|
196
|
+
may move before cancelling the hold. Ignored when `cancelOnMove` is `false` . Defaults to
|
|
197
|
+
`16` .
|
|
198
|
+
* * `frequency` - The time, in milliseconds, to poll for hold events. Defaults to `200` .
|
|
199
|
+
* * `events` - An array of `onHoldStart` events which each contain a `name` and `time` . The `time`
|
|
200
|
+
controls the amount of time that must pass before this `onHoldStart` event is fired and should
|
|
201
|
+
be a multiple of `frequency` .
|
|
202
|
+
*
|
|
203
|
+
* `pinch`
|
|
204
|
+
* * `boxSizing` - The part of the component's box model is used as the bounds of the constraint.
|
|
205
|
+
Only applies when `global` is `false` .
|
|
206
|
+
* * `'border-box'` - the default, includes the padding and border but excludes the margin.
|
|
207
|
+
* * `'content-box'` - excludes the padding, border, and margin.
|
|
208
|
+
* * `global` - When `true` , pinch gestures will continue when leaving the bounds of the component
|
|
209
|
+
or blurring the component.
|
|
210
|
+
* * `maxScale` - The maximum scale value. Defaults to `4` .
|
|
211
|
+
* * `minScale` - The minimum scale value. Defaults to `0.5` .
|
|
212
|
+
* * `moveTolerance` - The distance difference from the previous distance that the pointer may move
|
|
213
|
+
before cancelling the scaling. Defaults to `16` .
|
|
214
|
+
*/
|
|
215
|
+
export function configure(cfg: object): void;
|
|
216
|
+
|
|
217
|
+
export default Touchable;
|
package/Touchable/Touchable.js
CHANGED
|
@@ -28,10 +28,19 @@ var _Pinch = require("./Pinch");
|
|
|
28
28
|
var _useTouch = _interopRequireDefault(require("./useTouch"));
|
|
29
29
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
30
|
var _excluded = ["dragConfig", "flickConfig", "holdConfig", "pinchConfig", "disabled", "noResume", "onBlur", "onClick", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseMove", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "onDown", "onDrag", "onDragEnd", "onDragStart", "onFlick", "onHold", "onHoldEnd", "onHoldStart", "onMove", "onPinch", "onPinchEnd", "onPinchStart", "onTap", "onUp"];
|
|
31
|
+
/**
|
|
32
|
+
* Application support for gestures.
|
|
33
|
+
*
|
|
34
|
+
* @module ui/Touchable
|
|
35
|
+
* @exports Touchable
|
|
36
|
+
* @exports configure
|
|
37
|
+
*/
|
|
31
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
32
39
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
40
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
41
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
42
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
43
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
35
44
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
36
45
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
37
46
|
var selectProps = function selectProps(props) {
|
package/Touchable/config.js
CHANGED
|
@@ -10,7 +10,9 @@ var _Hold = require("./Hold.js");
|
|
|
10
10
|
var _Pinch = require("./Pinch");
|
|
11
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
16
|
var allowedDragKeys = Object.keys(_Drag.defaultDragConfig);
|
|
15
17
|
var allowedFlickKeys = Object.keys(_Flick.defaultFlickConfig);
|
|
16
18
|
var allowedHoldKeys = Object.keys(_Hold.defaultHoldConfig);
|
|
@@ -8,7 +8,9 @@ var _excluded = ["activeProp", "id"];
|
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
13
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
14
16
|
describe('useTouch', function () {
|
package/Touchable/useTouch.js
CHANGED
|
@@ -12,12 +12,14 @@ var _Touch = _interopRequireDefault(require("./Touch"));
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
18
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
19
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
20
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
20
|
-
function _iterableToArrayLimit(arr, i) { var _i =
|
|
21
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
22
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
21
23
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
24
|
/**
|
|
23
25
|
* Configuration for `useTouch`
|
|
@@ -68,7 +70,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
68
70
|
* @property {Object} handlers Event handlers that need to be passed to DOM node
|
|
69
71
|
* @private
|
|
70
72
|
*/
|
|
71
|
-
|
|
72
73
|
/**
|
|
73
74
|
* Provides a consistent set of pointer events -- `onDown`, `onUp`, and `onTap` --
|
|
74
75
|
* across mouse and touch interfaces along with support for common gestures including
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Type definitions for ui/Transition
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
6
|
+
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
7
|
+
|
|
8
|
+
export interface TransitionBaseProps {
|
|
9
|
+
/**
|
|
10
|
+
* Provide a function to get the reference to the child node (the one with the content) at
|
|
11
|
+
render time.
|
|
12
|
+
*
|
|
13
|
+
* Useful if you need to measure or interact with the node directly.
|
|
14
|
+
*/
|
|
15
|
+
childRef?: object | Function;
|
|
16
|
+
/**
|
|
17
|
+
* The node to be transitioned.
|
|
18
|
+
*/
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* The height of the transition when `type` is set to `'clip'` , used when direction is
|
|
22
|
+
'left' or 'right'.
|
|
23
|
+
*/
|
|
24
|
+
clipHeight?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The width of the transition when `type` is set to `'clip'` , used when direction is 'left'
|
|
27
|
+
or 'right'.
|
|
28
|
+
*/
|
|
29
|
+
clipWidth?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Customizes the component by mapping the supplied collection of CSS class names to the
|
|
32
|
+
corresponding internal elements and states of this component.
|
|
33
|
+
*
|
|
34
|
+
* The following classes are supported:
|
|
35
|
+
* * `transition` - The root component class
|
|
36
|
+
* * `inner` - The element inside the transition. This is the container for the transitioning content.
|
|
37
|
+
* * `shown` - Applied when content is present (visible), related to the `visible` prop/state
|
|
38
|
+
* * `hidden` - Applied when content is not present (hiding), related to the `visible` prop/state
|
|
39
|
+
* * `slide` - Applied when the `slide` `type` is set
|
|
40
|
+
* * `fade` - Applied when the `fade` `type` is set
|
|
41
|
+
* * `clip` - Applied when the `clip` `type` is set
|
|
42
|
+
* * `up` - Applied when the `direction` `up` is set
|
|
43
|
+
* * `right` - Applied when the `direction` `right` is set
|
|
44
|
+
* * `down` - Applied when the `direction` `down` is set
|
|
45
|
+
* * `left` - Applied when the `direction` `left` is set
|
|
46
|
+
* * `short` - Applied when the `duration` `short` is set
|
|
47
|
+
* * `medium` - Applied when the `duration` `medium` is set
|
|
48
|
+
* * `long` - Applied when the `duration` `long` is set
|
|
49
|
+
* * `ease` - Applied when the `timingFunction` `ease` is set
|
|
50
|
+
* * `ease-in` - Applied when the `timingFunction` `ease-in` is set
|
|
51
|
+
* * `ease-out` - Applied when the `timingFunction` `ease-out` is set
|
|
52
|
+
* * `ease-in-out` - Applied when the `timingFunction` `ease-in-out` is set
|
|
53
|
+
* * `ease-in-quart` - Applied when the `timingFunction` `ease-in-quart` is set
|
|
54
|
+
* * `ease-out-quart` - Applied when the `timingFunction` `ease-out-quart` is set
|
|
55
|
+
* * `linear` - Applied when the `timingFunction` `linear` is set
|
|
56
|
+
*/
|
|
57
|
+
css?: object;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the direction of transition. Where the component will move _to_ ; the destination.
|
|
60
|
+
Supported directions are: `'up'` , `'right'` , `'down'` , `'left'` .
|
|
61
|
+
*/
|
|
62
|
+
direction?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Controls how long the transition should take.
|
|
65
|
+
Supported preset durations are: `'short'` (250ms), `'medium'` (500ms), and `'long'` (1s).
|
|
66
|
+
`'medium'` (500ms) is default when no others are specified.
|
|
67
|
+
Any valid CSS duration value is also accepted, e.g. "200ms" or "3s". Pure numeric values
|
|
68
|
+
are also supported and treated as milliseconds.
|
|
69
|
+
*/
|
|
70
|
+
duration?: string | number;
|
|
71
|
+
/**
|
|
72
|
+
* Disables transition animation.
|
|
73
|
+
*
|
|
74
|
+
* When `false` , visibility changes animate.
|
|
75
|
+
*/
|
|
76
|
+
noAnimation?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* The transition timing function.
|
|
79
|
+
* * Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out` , `ease-in-quart` ,
|
|
80
|
+
`ease-out-quart` , and `linear` .
|
|
81
|
+
*/
|
|
82
|
+
timingFunction?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The type of transition to affect the content.
|
|
85
|
+
* * Supported types are: `'slide'` , `'clip'` , and `'fade'` .
|
|
86
|
+
*
|
|
87
|
+
* Details on types:
|
|
88
|
+
* * `'slide'` - Typically used for bringing something which is off the edge of the screen,
|
|
89
|
+
and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
|
|
90
|
+
an overlaying menu. This requires no re-rendering or repainting of the screen during
|
|
91
|
+
the transition, making it very performant. However, this does not affect layout at
|
|
92
|
+
all, which makes it less useful for transitioning from a place already on the
|
|
93
|
+
screen.
|
|
94
|
+
* * `'clip'` - This is useful for showing a component that transitions-in from a location
|
|
95
|
+
that is already on the screen. Examples would be an expanding header or an
|
|
96
|
+
accordion. This type does affects layout, its current size will push other sibling
|
|
97
|
+
elements to make room for itself. Because of this, repainting the layout does happen
|
|
98
|
+
during transition.
|
|
99
|
+
* * `'fade'` - Fade the components onto the screen, from 0 opacity (completely invisible)
|
|
100
|
+
to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
|
|
101
|
+
menu, a panel, or even view contents. This does not affect layout at all.
|
|
102
|
+
*/
|
|
103
|
+
type?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Sets the visibility of the component, which determines whether it's on screen or off.
|
|
106
|
+
*/
|
|
107
|
+
visible?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The stateless structure of the component.
|
|
111
|
+
*
|
|
112
|
+
* In case you want to provide all of the state yourself.
|
|
113
|
+
In general, you'll probably want to use the `Transition` instead of `TransitionBase` .
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
export class TransitionBase extends React.Component<
|
|
117
|
+
Merge<React.HTMLProps<HTMLElement>, TransitionBaseProps>
|
|
118
|
+
> {}
|
|
119
|
+
|
|
120
|
+
export interface TransitionProps {
|
|
121
|
+
/**
|
|
122
|
+
* The node to be transitioned.
|
|
123
|
+
*/
|
|
124
|
+
children?: React.ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* The direction of transition (i.e. where the component will move _to_ ; the destination).
|
|
127
|
+
* * Supported directions are: `'up'` , `'right'` , `'down'` , `'left'` .
|
|
128
|
+
*/
|
|
129
|
+
direction?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Controls how long the transition should take.
|
|
132
|
+
* * Supported preset durations are: `'short'` (250ms), `'medium'` (500ms), and `'long'` (1s).
|
|
133
|
+
`'medium'` (500ms) is default when no others are specified.
|
|
134
|
+
*
|
|
135
|
+
* Any valid CSS duration value is also accepted, e.g. "200ms" or "3s". Pure numeric values
|
|
136
|
+
are also supported and treated as miliseconds.
|
|
137
|
+
*/
|
|
138
|
+
duration?: string | number;
|
|
139
|
+
/**
|
|
140
|
+
* Disables transition animation.
|
|
141
|
+
*
|
|
142
|
+
* When `false` , visibility changes animate.
|
|
143
|
+
*/
|
|
144
|
+
noAnimation?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Called after transition for hiding is finished.
|
|
147
|
+
*/
|
|
148
|
+
onHide?: Function;
|
|
149
|
+
/**
|
|
150
|
+
* Called after transition for showing is finished.
|
|
151
|
+
*/
|
|
152
|
+
onShow?: Function;
|
|
153
|
+
/**
|
|
154
|
+
* The transition timing function.
|
|
155
|
+
Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out` , `ease-in-quart` ,
|
|
156
|
+
`ease-out-quart` , and `linear` .
|
|
157
|
+
*/
|
|
158
|
+
timingFunction?: string;
|
|
159
|
+
/**
|
|
160
|
+
* The type of transition to affect the content.
|
|
161
|
+
* * Supported types are: `'slide'` , `'clip'` , and `'fade'` .
|
|
162
|
+
*
|
|
163
|
+
* Details on types:
|
|
164
|
+
* * `'slide'` - Typically used for bringing something which is off the edge of the screen,
|
|
165
|
+
and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
|
|
166
|
+
an overlaying menu. This requires no re-rendering or repainting of the screen during
|
|
167
|
+
the transition, making it very performant. However, this does not affect layout at
|
|
168
|
+
all, which makes it less useful for transitioning from a place already on the
|
|
169
|
+
screen.
|
|
170
|
+
* * `'clip'` - This is useful for showing a component that transitions-in from a location
|
|
171
|
+
that is already on the screen. Examples would be an expanding header or an
|
|
172
|
+
accordion. This type does affects layout, its current size will push other sibling
|
|
173
|
+
elements to make room for itself. Because of this, repainting the layout does happen
|
|
174
|
+
during transition.
|
|
175
|
+
* * `'fade'` - Fade the components onto the screen, from 0 opacity (completely invisible)
|
|
176
|
+
to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
|
|
177
|
+
menu, a panel, or even view contents. This does not affect layout at all.
|
|
178
|
+
*/
|
|
179
|
+
type?: string;
|
|
180
|
+
/**
|
|
181
|
+
* The visibility of the component, which determines whether it's on the screen or off.
|
|
182
|
+
*/
|
|
183
|
+
visible?: boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A stateful component that allows for applying transitions to its child items via configurable
|
|
187
|
+
properties and events.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
export class Transition extends React.Component<
|
|
191
|
+
Merge<React.HTMLProps<HTMLElement>, TransitionProps>
|
|
192
|
+
> {}
|
|
193
|
+
|
|
194
|
+
export default Transition;
|
package/Transition/Transition.js
CHANGED
|
@@ -17,7 +17,7 @@ var _excluded = ["css", "childRef", "children", "innerStyle"],
|
|
|
17
17
|
_excluded2 = ["visible"];
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
20
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
21
21
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
22
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
23
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -30,7 +30,25 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
30
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
31
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
32
32
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
34
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
35
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
36
|
+
* A component that can transition its children components onto the screen.
|
|
37
|
+
*
|
|
38
|
+
* Transitions whether that's from off the edge of the screen or hidden inside or behind an
|
|
39
|
+
* already-on-screen component. You can switch types of transitions using the `type` property,
|
|
40
|
+
* change the direction they come in from using the `direction` property, or even adjust the
|
|
41
|
+
* transition timing function using `timingFunction`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <Transition visible={true} type="slide">
|
|
45
|
+
* <div>Set `visible` above to `false` to hide this element.</div>
|
|
46
|
+
* </Transition>
|
|
47
|
+
*
|
|
48
|
+
* @module ui/Transition
|
|
49
|
+
* @exports Transition
|
|
50
|
+
* @exports TransitionBase
|
|
51
|
+
*/
|
|
34
52
|
var formatter = function formatter(duration) {
|
|
35
53
|
return typeof duration === 'number' ? duration + 'ms' : duration;
|
|
36
54
|
};
|
|
@@ -397,9 +415,9 @@ var Transition = /*#__PURE__*/function (_Component) {
|
|
|
397
415
|
}
|
|
398
416
|
if (noAnimation) {
|
|
399
417
|
if (!prevProps.visible && visible) {
|
|
400
|
-
(0, _handle.forwardCustom)('onShow')(
|
|
418
|
+
(0, _handle.forwardCustom)('onShow')(null, this.props);
|
|
401
419
|
} else if (prevProps.visible && !visible) {
|
|
402
|
-
(0, _handle.forwardCustom)('onHide')(
|
|
420
|
+
(0, _handle.forwardCustom)('onHide')(null, this.props);
|
|
403
421
|
}
|
|
404
422
|
}
|
|
405
423
|
}
|
|
@@ -9,12 +9,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
9
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
13
|
-
function _iterableToArrayLimit(arr, i) { var _i =
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
20
|
describe('Transition Specs', function () {
|
|
19
21
|
// NOTE: Feature not yet implemented
|
|
20
22
|
test.skip('should apply author classes', function () {
|
package/ViewManager/Arranger.js
CHANGED
|
@@ -8,7 +8,12 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
14
|
+
* Exports a number of pre-defined arrangers for use with {@link ui/ViewManager}.
|
|
15
|
+
* note: not jsdoc on purpose
|
|
16
|
+
*/
|
|
12
17
|
var slideInOut = function slideInOut(direction, total, orientation) {
|
|
13
18
|
var p = direction === 'out' ? total : -total;
|
|
14
19
|
return orientation === 'top' && 'translateY(' + -p + '%)' || orientation === 'bottom' && 'translateY(' + p + '%)' || orientation === 'left' && 'translateX(' + -p + '%)' || orientation === 'right' && 'translateX(' + p + '%)';
|