@storybook/addon-ondevice-controls 10.0.1 → 10.0.2-alpha.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/dist/components/ModalPortal.d.ts +4 -0
- package/dist/components/ModalPortal.js +16 -0
- package/dist/components/SelectModal.js +2 -3
- package/dist/components/Slider.d.ts +12 -0
- package/dist/components/Slider.js +207 -0
- package/dist/components/SliderWrapper.d.ts +13 -0
- package/dist/components/SliderWrapper.js +23 -0
- package/dist/components/color-picker/HoloColorPicker.js +2 -2
- package/dist/types/Color.js +2 -1
- package/dist/types/Number.js +2 -2
- package/package.json +5 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModalPortal = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const portal_1 = require("@gorhom/portal");
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
const modalSupported = react_native_1.Platform.OS !== 'macos';
|
|
8
|
+
const ModalPortal = ({ children, visible, usePortal, ...props }) => {
|
|
9
|
+
if (modalSupported && !usePortal) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Modal, { visible: visible, ...props, children: children }));
|
|
11
|
+
}
|
|
12
|
+
if (!visible)
|
|
13
|
+
return null;
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(portal_1.Portal, { hostName: "storybook-lite-ui-root", children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1, position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }, children: children }) }));
|
|
15
|
+
};
|
|
16
|
+
exports.ModalPortal = ModalPortal;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SelectModal = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
// NOTE This is adapted from react-native-modal-selector https://github.com/peacechen/react-native-modal-selector/blob/master/index.js
|
|
6
5
|
const react_1 = require("react");
|
|
7
6
|
const react_native_1 = require("react-native");
|
|
7
|
+
const ModalPortal_1 = require("./ModalPortal");
|
|
8
8
|
const PADDING = 8;
|
|
9
9
|
const BORDER_RADIUS = 5;
|
|
10
10
|
const FONT_SIZE = 16;
|
|
@@ -120,7 +120,6 @@ const SelectModal = ({ data = [], onChange, onModalOpen, onModalClose, keyExtrac
|
|
|
120
120
|
const initialItem = data.find((item) => String(keyExtractor(item)) === String(initValue));
|
|
121
121
|
return initialItem ? [initialItem] : [];
|
|
122
122
|
});
|
|
123
|
-
const modalRef = (0, react_1.useRef)(null);
|
|
124
123
|
const selectedItemsMap = (0, react_1.useMemo)(() => {
|
|
125
124
|
if (multiselect) {
|
|
126
125
|
return (selectedItems || []).reduce((acc, item) => {
|
|
@@ -290,7 +289,7 @@ const SelectModal = ({ data = [], onChange, onModalOpen, onModalClose, keyExtrac
|
|
|
290
289
|
selectStyleProp,
|
|
291
290
|
selectTextPassThruProps,
|
|
292
291
|
]);
|
|
293
|
-
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: style, ...passThruProps, children: [(0, jsx_runtime_1.jsx)(
|
|
292
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: style, ...passThruProps, children: [(0, jsx_runtime_1.jsx)(ModalPortal_1.ModalPortal, { transparent: true, supportedOrientations: supportedOrientations, visible: modalVisible, onRequestClose: close, animationType: animationType, onDismiss: () => selectedItems.length > 0 && onChange?.(selectedItems), children: renderOptionList() }), customSelector || ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { hitSlop: modalOpenerHitSlop, activeOpacity: touchableActiveOpacity, style: touchableStyle, onPress: open, onLongPress: handleLongPress, disabled: disabled, accessible: openButtonContainerAccessible, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: childrenContainerStyle, pointerEvents: "none", children: renderChildren() }) }))] }));
|
|
294
293
|
};
|
|
295
294
|
exports.SelectModal = SelectModal;
|
|
296
295
|
exports.default = exports.SelectModal;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface SliderProps {
|
|
2
|
+
minimumValue?: number;
|
|
3
|
+
maximumValue?: number;
|
|
4
|
+
step?: number;
|
|
5
|
+
value?: number;
|
|
6
|
+
onValueChange?: (value: number) => void;
|
|
7
|
+
onSlidingComplete?: (value: number) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
style?: any;
|
|
10
|
+
}
|
|
11
|
+
declare const Slider: ({ minimumValue, maximumValue, step, value, onValueChange, onSlidingComplete, disabled, style, }: SliderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default Slider;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const react_native_theming_1 = require("@storybook/react-native-theming");
|
|
7
|
+
const THUMB_SIZE = 32;
|
|
8
|
+
const THUMB_RADIUS = THUMB_SIZE / 2;
|
|
9
|
+
const THUMB_HIT_SLOP = THUMB_SIZE;
|
|
10
|
+
const SliderContainer = react_native_theming_1.styled.View({
|
|
11
|
+
height: 48,
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
paddingHorizontal: 10,
|
|
14
|
+
});
|
|
15
|
+
const Track = react_native_theming_1.styled.View(({ theme }) => ({
|
|
16
|
+
height: 4,
|
|
17
|
+
borderRadius: 2,
|
|
18
|
+
backgroundColor: theme.appBorderColor,
|
|
19
|
+
position: 'relative',
|
|
20
|
+
width: '100%',
|
|
21
|
+
}));
|
|
22
|
+
const Fill = react_native_theming_1.styled.View(({ theme }) => ({
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: 0,
|
|
25
|
+
height: 4,
|
|
26
|
+
borderRadius: 2,
|
|
27
|
+
backgroundColor: theme.color.positive,
|
|
28
|
+
}));
|
|
29
|
+
const Thumb = react_native_theming_1.styled.View(({ theme }) => ({
|
|
30
|
+
width: THUMB_SIZE,
|
|
31
|
+
height: THUMB_SIZE,
|
|
32
|
+
borderRadius: THUMB_RADIUS,
|
|
33
|
+
backgroundColor: theme.color.positive,
|
|
34
|
+
borderWidth: 2,
|
|
35
|
+
borderColor: theme.background.content,
|
|
36
|
+
shadowColor: '#000',
|
|
37
|
+
shadowOffset: { width: 0, height: 2 },
|
|
38
|
+
shadowOpacity: 0.25,
|
|
39
|
+
shadowRadius: 3.84,
|
|
40
|
+
elevation: 5,
|
|
41
|
+
}));
|
|
42
|
+
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
43
|
+
const Slider = ({ minimumValue = 0, maximumValue = 1, step, value = minimumValue, onValueChange, onSlidingComplete, disabled = false, style, }) => {
|
|
44
|
+
const isRTL = react_native_1.I18nManager.isRTL;
|
|
45
|
+
const initialValueRef = (0, react_1.useRef)(value ?? minimumValue);
|
|
46
|
+
const [trackWidth, setTrackWidth] = (0, react_1.useState)(0);
|
|
47
|
+
const [displayValue, setDisplayValue] = (0, react_1.useState)(initialValueRef.current);
|
|
48
|
+
const translateX = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
49
|
+
const currentTranslateRef = (0, react_1.useRef)(0);
|
|
50
|
+
const startTranslateRef = (0, react_1.useRef)(0);
|
|
51
|
+
const isDraggingRef = (0, react_1.useRef)(false);
|
|
52
|
+
const range = maximumValue - minimumValue || 1;
|
|
53
|
+
const clampValue = (0, react_1.useCallback)((raw) => {
|
|
54
|
+
let clampedValue = clamp(raw, minimumValue, maximumValue);
|
|
55
|
+
if (step && step > 0) {
|
|
56
|
+
const steps = Math.round((clampedValue - minimumValue) / step);
|
|
57
|
+
clampedValue = minimumValue + steps * step;
|
|
58
|
+
clampedValue = clamp(clampedValue, minimumValue, maximumValue);
|
|
59
|
+
}
|
|
60
|
+
return clampedValue;
|
|
61
|
+
}, [minimumValue, maximumValue, step]);
|
|
62
|
+
const valueToTranslate = (0, react_1.useCallback)((val, width) => {
|
|
63
|
+
if (width <= 0)
|
|
64
|
+
return 0;
|
|
65
|
+
const clampedValue = clampValue(val);
|
|
66
|
+
const ratio = (clampedValue - minimumValue) / range;
|
|
67
|
+
const normalized = isRTL ? 1 - ratio : ratio;
|
|
68
|
+
return normalized * width;
|
|
69
|
+
}, [clampValue, minimumValue, range, isRTL]);
|
|
70
|
+
const translateToValue = (0, react_1.useCallback)((translate, width) => {
|
|
71
|
+
if (width <= 0)
|
|
72
|
+
return clampValue(minimumValue);
|
|
73
|
+
const ratio = clamp(translate / width, 0, 1);
|
|
74
|
+
const normalized = isRTL ? 1 - ratio : ratio;
|
|
75
|
+
const raw = minimumValue + normalized * range;
|
|
76
|
+
return clampValue(raw);
|
|
77
|
+
}, [clampValue, minimumValue, range, isRTL]);
|
|
78
|
+
const clampTranslate = (0, react_1.useCallback)((translate, width) => clamp(translate, 0, width), []);
|
|
79
|
+
const updateFromTranslate = (0, react_1.useCallback)((nextTranslate, width, notify) => {
|
|
80
|
+
const clampedTranslate = clampTranslate(nextTranslate, width);
|
|
81
|
+
const snappedValue = translateToValue(clampedTranslate, width);
|
|
82
|
+
const snappedTranslate = valueToTranslate(snappedValue, width);
|
|
83
|
+
translateX.setValue(snappedTranslate);
|
|
84
|
+
currentTranslateRef.current = snappedTranslate;
|
|
85
|
+
setDisplayValue(snappedValue);
|
|
86
|
+
if (notify) {
|
|
87
|
+
onValueChange?.(snappedValue);
|
|
88
|
+
}
|
|
89
|
+
}, [clampTranslate, translateToValue, valueToTranslate, translateX, onValueChange]);
|
|
90
|
+
// Sync with external value when not dragging
|
|
91
|
+
(0, react_1.useEffect)(() => {
|
|
92
|
+
if (isDraggingRef.current)
|
|
93
|
+
return;
|
|
94
|
+
const clamped = clampValue(value ?? minimumValue);
|
|
95
|
+
setDisplayValue(clamped);
|
|
96
|
+
if (trackWidth > 0) {
|
|
97
|
+
const translate = valueToTranslate(clamped, trackWidth);
|
|
98
|
+
translateX.setValue(translate);
|
|
99
|
+
currentTranslateRef.current = translate;
|
|
100
|
+
}
|
|
101
|
+
}, [value, trackWidth, clampValue, valueToTranslate, translateX, minimumValue]);
|
|
102
|
+
const handlePanMove = (0, react_1.useCallback)((gestureState, width) => {
|
|
103
|
+
const delta = isRTL ? -gestureState.dx : gestureState.dx;
|
|
104
|
+
const nextTranslate = startTranslateRef.current + delta;
|
|
105
|
+
updateFromTranslate(nextTranslate, width, true);
|
|
106
|
+
}, [updateFromTranslate, isRTL]);
|
|
107
|
+
const handlePanEnd = (0, react_1.useCallback)((width, shouldNotifyComplete) => {
|
|
108
|
+
isDraggingRef.current = false;
|
|
109
|
+
const snappedValue = translateToValue(currentTranslateRef.current, width);
|
|
110
|
+
const snappedTranslate = valueToTranslate(snappedValue, width);
|
|
111
|
+
translateX.setValue(snappedTranslate);
|
|
112
|
+
currentTranslateRef.current = snappedTranslate;
|
|
113
|
+
setDisplayValue(snappedValue);
|
|
114
|
+
if (shouldNotifyComplete) {
|
|
115
|
+
onValueChange?.(snappedValue);
|
|
116
|
+
onSlidingComplete?.(snappedValue);
|
|
117
|
+
}
|
|
118
|
+
}, [translateToValue, valueToTranslate, translateX, onValueChange, onSlidingComplete]);
|
|
119
|
+
const panResponder = (0, react_1.useMemo)(() => react_native_1.PanResponder.create({
|
|
120
|
+
onStartShouldSetPanResponder: () => !disabled,
|
|
121
|
+
onMoveShouldSetPanResponder: () => !disabled,
|
|
122
|
+
onStartShouldSetPanResponderCapture: () => !disabled,
|
|
123
|
+
onMoveShouldSetPanResponderCapture: () => !disabled,
|
|
124
|
+
onPanResponderGrant: (evt) => {
|
|
125
|
+
if (disabled || trackWidth <= 0)
|
|
126
|
+
return;
|
|
127
|
+
isDraggingRef.current = true;
|
|
128
|
+
const rawTouchX = evt.nativeEvent.locationX - THUMB_RADIUS;
|
|
129
|
+
const clampedTouch = clamp(rawTouchX, 0, trackWidth);
|
|
130
|
+
const proposedTranslate = isRTL ? trackWidth - clampedTouch : clampedTouch;
|
|
131
|
+
const currentTranslate = currentTranslateRef.current;
|
|
132
|
+
const distanceFromThumb = Math.abs(proposedTranslate - currentTranslate);
|
|
133
|
+
if (distanceFromThumb <= THUMB_HIT_SLOP) {
|
|
134
|
+
// Treat as grabbing the existing thumb position — don't jump.
|
|
135
|
+
startTranslateRef.current = currentTranslate;
|
|
136
|
+
const currentValue = translateToValue(currentTranslate, trackWidth);
|
|
137
|
+
setDisplayValue(currentValue);
|
|
138
|
+
onValueChange?.(currentValue);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Treat as tap on track: jump to that location before dragging.
|
|
142
|
+
updateFromTranslate(proposedTranslate, trackWidth, true);
|
|
143
|
+
startTranslateRef.current = currentTranslateRef.current;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
onPanResponderMove: (_evt, gestureState) => {
|
|
147
|
+
if (disabled || trackWidth <= 0)
|
|
148
|
+
return;
|
|
149
|
+
handlePanMove(gestureState, trackWidth);
|
|
150
|
+
},
|
|
151
|
+
onPanResponderRelease: () => {
|
|
152
|
+
if (trackWidth <= 0)
|
|
153
|
+
return;
|
|
154
|
+
handlePanEnd(trackWidth, true);
|
|
155
|
+
},
|
|
156
|
+
onPanResponderTerminationRequest: () => false,
|
|
157
|
+
onPanResponderTerminate: () => {
|
|
158
|
+
if (trackWidth <= 0)
|
|
159
|
+
return;
|
|
160
|
+
handlePanEnd(trackWidth, true);
|
|
161
|
+
},
|
|
162
|
+
}), [
|
|
163
|
+
disabled,
|
|
164
|
+
trackWidth,
|
|
165
|
+
handlePanMove,
|
|
166
|
+
handlePanEnd,
|
|
167
|
+
updateFromTranslate,
|
|
168
|
+
translateToValue,
|
|
169
|
+
onValueChange,
|
|
170
|
+
isRTL,
|
|
171
|
+
]);
|
|
172
|
+
const handleTrackLayout = (event) => {
|
|
173
|
+
const { width } = event.nativeEvent.layout;
|
|
174
|
+
const usableWidth = Math.max(width - THUMB_RADIUS * 2, 0);
|
|
175
|
+
setTrackWidth(usableWidth);
|
|
176
|
+
if (usableWidth > 0) {
|
|
177
|
+
const translate = valueToTranslate(displayValue, usableWidth);
|
|
178
|
+
translateX.setValue(translate);
|
|
179
|
+
currentTranslateRef.current = translate;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const fillWidth = trackWidth > 0 ? ((displayValue - minimumValue) / range) * trackWidth : 0;
|
|
183
|
+
const fillStyle = isRTL
|
|
184
|
+
? [styles.fillBase, { right: 0, width: fillWidth }]
|
|
185
|
+
: [styles.fillBase, { left: 0, width: fillWidth }];
|
|
186
|
+
return ((0, jsx_runtime_1.jsx)(SliderContainer, { style: style, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.touchArea, onLayout: handleTrackLayout, ...panResponder.panHandlers, collapsable: false, children: (0, jsx_runtime_1.jsxs)(Track, { children: [(0, jsx_runtime_1.jsx)(Fill, { style: fillStyle }), (0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { style: [styles.thumbWrapper, { transform: [{ translateX }] }], pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(Thumb, {}) })] }) }) }));
|
|
187
|
+
};
|
|
188
|
+
const styles = react_native_1.StyleSheet.create({
|
|
189
|
+
touchArea: {
|
|
190
|
+
height: 48,
|
|
191
|
+
justifyContent: 'center',
|
|
192
|
+
width: '100%',
|
|
193
|
+
paddingHorizontal: THUMB_RADIUS,
|
|
194
|
+
},
|
|
195
|
+
thumbWrapper: {
|
|
196
|
+
position: 'absolute',
|
|
197
|
+
top: -THUMB_RADIUS,
|
|
198
|
+
left: -THUMB_RADIUS,
|
|
199
|
+
},
|
|
200
|
+
fillBase: {
|
|
201
|
+
position: 'absolute',
|
|
202
|
+
top: 0,
|
|
203
|
+
height: 4,
|
|
204
|
+
borderRadius: 2,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
exports.default = Slider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface SliderWrapperProps {
|
|
2
|
+
minimumValue?: number;
|
|
3
|
+
maximumValue?: number;
|
|
4
|
+
step?: number;
|
|
5
|
+
value?: number;
|
|
6
|
+
onValueChange?: (value: number) => void;
|
|
7
|
+
onSlidingComplete?: (value: number) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
style?: any;
|
|
10
|
+
useBuiltInSlider?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const SliderWrapper: ({ useBuiltInSlider, ...props }: SliderWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default SliderWrapper;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const Slider_1 = __importDefault(require("./Slider"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
let Slider = null;
|
|
10
|
+
try {
|
|
11
|
+
Slider = require('@react-native-community/slider').default;
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
}
|
|
14
|
+
catch (error) { }
|
|
15
|
+
const supportedPlatforms = ['android', 'ios', 'windows', 'web'];
|
|
16
|
+
const nativeSliderSupported = supportedPlatforms.includes(react_native_1.Platform.OS);
|
|
17
|
+
const SliderWrapper = ({ useBuiltInSlider = false, ...props }) => {
|
|
18
|
+
if (!nativeSliderSupported || useBuiltInSlider || Slider === null) {
|
|
19
|
+
return (0, jsx_runtime_1.jsx)(Slider_1.default, { ...props });
|
|
20
|
+
}
|
|
21
|
+
return (0, jsx_runtime_1.jsx)(Slider, { ...props });
|
|
22
|
+
};
|
|
23
|
+
exports.default = SliderWrapper;
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.HoloColorPicker = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const slider_1 = __importDefault(require("@react-native-community/slider"));
|
|
9
8
|
const react_1 = require("react");
|
|
10
9
|
const react_native_1 = require("react-native");
|
|
11
10
|
const tinycolor2_1 = __importDefault(require("tinycolor2"));
|
|
12
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const SliderWrapper_1 = __importDefault(require("../SliderWrapper"));
|
|
13
13
|
class HoloColorPicker extends react_1.PureComponent {
|
|
14
14
|
_layout;
|
|
15
15
|
_pageX;
|
|
@@ -128,7 +128,7 @@ class HoloColorPicker extends react_1.PureComponent {
|
|
|
128
128
|
angle,
|
|
129
129
|
isRTL: this._isRTL,
|
|
130
130
|
});
|
|
131
|
-
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: style, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { onLayout: this._onLayout, ref: this.pickerContainer, style: styles.pickerContainer, children: !pickerSize ? null : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { ...this._pickerResponder.panHandlers, style: [computed.picker], collapsable: false, children: [(0, jsx_runtime_1.jsx)(react_native_1.Image, { source: require('./resources/color-circle.png'), resizeMode: "contain", style: [styles.pickerImage] }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.pickerIndicator, computed.pickerIndicator] })] }), oldColor && ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.selectedPreview, computed.selectedPreview], onPress: this._onColorSelected, activeOpacity: 0.7 })), oldColor && ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.originalPreview, computed.originalPreview], onPress: this._onOldColorSelected, activeOpacity: 0.7 })), !oldColor && ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.selectedFullPreview, computed.selectedFullPreview], onPress: this._onColorSelected, activeOpacity: 0.7 }))] })) }), this.props.hideSliders ? null : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: { paddingStart: 4, color: '#859499', fontSize: 12 }, children: "Saturation" }), (0, jsx_runtime_1.jsx)(
|
|
131
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: style, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { onLayout: this._onLayout, ref: this.pickerContainer, style: styles.pickerContainer, children: !pickerSize ? null : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { ...this._pickerResponder.panHandlers, style: [computed.picker], collapsable: false, children: [(0, jsx_runtime_1.jsx)(react_native_1.Image, { source: require('./resources/color-circle.png'), resizeMode: "contain", style: [styles.pickerImage] }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.pickerIndicator, computed.pickerIndicator] })] }), oldColor && ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.selectedPreview, computed.selectedPreview], onPress: this._onColorSelected, activeOpacity: 0.7 })), oldColor && ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.originalPreview, computed.originalPreview], onPress: this._onOldColorSelected, activeOpacity: 0.7 })), !oldColor && ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.selectedFullPreview, computed.selectedFullPreview], onPress: this._onColorSelected, activeOpacity: 0.7 }))] })) }), this.props.hideSliders ? null : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: { paddingStart: 4, color: '#859499', fontSize: 12 }, children: "Saturation" }), (0, jsx_runtime_1.jsx)(SliderWrapper_1.default, { value: s, onValueChange: this._onSValueChange }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: { paddingStart: 4, color: '#859499', fontSize: 12 }, children: "Lightness" }), (0, jsx_runtime_1.jsx)(SliderWrapper_1.default, { value: v, onValueChange: this._onVValueChange })] }))] }));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
exports.HoloColorPicker = HoloColorPicker;
|
package/dist/types/Color.js
CHANGED
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
6
|
const react_native_theming_1 = require("@storybook/react-native-theming");
|
|
7
7
|
const color_picker_1 = require("../components/color-picker");
|
|
8
|
+
const ModalPortal_1 = require("../components/ModalPortal");
|
|
8
9
|
const TouchableContainer = react_native_theming_1.styled.View(({ theme }) => ({
|
|
9
10
|
width: 40,
|
|
10
11
|
height: 40,
|
|
@@ -63,7 +64,7 @@ const ColorType = ({ arg, onChange = (value) => value }) => {
|
|
|
63
64
|
backgroundColor: theme.background.content,
|
|
64
65
|
} }));
|
|
65
66
|
}
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(TouchableContainer, { children: (0, jsx_runtime_1.jsx)(Touchable, { color: arg.value, onPress: openColorPicker }) }), (0, jsx_runtime_1.jsxs)(
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(TouchableContainer, { children: (0, jsx_runtime_1.jsx)(Touchable, { color: arg.value, onPress: openColorPicker }) }), (0, jsx_runtime_1.jsxs)(ModalPortal_1.ModalPortal, { supportedOrientations: ['portrait', 'landscape'], transparent: true, visible: displayColorPicker, onRequestClose: closeColorPicker, children: [(0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { onPress: closeColorPicker, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.modalOverlay }) }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.centerContainer, children: (0, jsx_runtime_1.jsxs)(InnerContainer, { pointerEvents: "box-none", children: [(0, jsx_runtime_1.jsx)(color_picker_1.ColorPicker, { onColorSelected: onChangeColor, onColorChange: (color) => setCurrentColor(color), defaultColor: arg.value, oldColor: arg.value, style: styles.picker }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.actionContainer, children: [(0, jsx_runtime_1.jsx)(ButtonTouchable, { onPress: closeColorPicker, children: (0, jsx_runtime_1.jsx)(ButtonText, { children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: { width: 12 } }), (0, jsx_runtime_1.jsx)(ButtonTouchable, { primary: true, onPress: () => {
|
|
67
68
|
onChangeColor(currentColor);
|
|
68
69
|
closeColorPicker();
|
|
69
70
|
}, children: (0, jsx_runtime_1.jsx)(ButtonText, { primary: true, children: "Select" }) })] })] }) })] })] }));
|
package/dist/types/Number.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const slider_1 = __importDefault(require("@react-native-community/slider"));
|
|
8
7
|
const react_native_theming_1 = require("@storybook/react-native-theming");
|
|
9
8
|
const react_1 = require("react");
|
|
10
9
|
const react_native_1 = require("react-native");
|
|
11
10
|
const useResyncValue_1 = require("./useResyncValue");
|
|
12
11
|
const common_1 = require("./common");
|
|
12
|
+
const SliderWrapper_1 = __importDefault(require("../components/SliderWrapper"));
|
|
13
13
|
const ValueContainer = react_native_theming_1.styled.View({ flexDirection: 'row' });
|
|
14
14
|
const LabelText = react_native_theming_1.styled.Text(({ theme }) => ({
|
|
15
15
|
color: theme.color.mediumdark,
|
|
@@ -60,7 +60,7 @@ const NumberType = ({ arg, isPristine, onChange = (value) => value }) => {
|
|
|
60
60
|
};
|
|
61
61
|
if (arg.range || arg.type === 'range') {
|
|
62
62
|
const { min, max, step } = getRangeOptions(arg);
|
|
63
|
-
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsxs)(ValueContainer, { children: [(0, jsx_runtime_1.jsx)(LabelText, { children: "Value: " }), (0, jsx_runtime_1.jsx)(ValueText, { children: arg.value })] }), (0, jsx_runtime_1.jsx)(
|
|
63
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsxs)(ValueContainer, { children: [(0, jsx_runtime_1.jsx)(LabelText, { children: "Value: " }), (0, jsx_runtime_1.jsx)(ValueText, { children: arg.value })] }), (0, jsx_runtime_1.jsx)(SliderWrapper_1.default, { minimumValue: min, maximumValue: max, step: step, value: arg.value, onSlidingComplete: (val) => {
|
|
64
64
|
onChange(val);
|
|
65
65
|
setCurrentValue(val);
|
|
66
66
|
} })] }, key));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-ondevice-controls",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.2-alpha.0",
|
|
4
4
|
"description": "Display storybook controls on your device.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"copyimages": "cross-env-shell cp -r src/components/color-picker/resources dist/components/color-picker/resources"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@storybook/react-native-
|
|
33
|
+
"@gorhom/portal": "^1.0.14",
|
|
34
|
+
"@storybook/react-native-theming": "^10.0.2-alpha.0",
|
|
35
|
+
"@storybook/react-native-ui-common": "^10.0.2-alpha.0",
|
|
35
36
|
"polished": "^4.3.1",
|
|
36
37
|
"react-native-modal-datetime-picker": "^18.0.0",
|
|
37
38
|
"tinycolor2": "^1.6.0"
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "f88cc47d0ddc9958f4a8b029f8366de9184bfc8e"
|
|
60
61
|
}
|