chore: add mobile app

This commit is contained in:
2026-02-07 22:33:02 +01:00
parent db34640acc
commit e89384ad4e
29327 changed files with 3886944 additions and 12 deletions
@@ -0,0 +1,99 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
function isScreenReaderEnabled() {
return new Promise((resolve, reject) => {
resolve(true);
});
}
var prefersReducedMotionMedia = _canUseDom.default && typeof window.matchMedia === 'function' ? window.matchMedia('(prefers-reduced-motion: reduce)') : null;
function isReduceMotionEnabled() {
return new Promise((resolve, reject) => {
resolve(prefersReducedMotionMedia ? prefersReducedMotionMedia.matches : true);
});
}
function addChangeListener(fn) {
if (prefersReducedMotionMedia != null) {
prefersReducedMotionMedia.addEventListener != null ? prefersReducedMotionMedia.addEventListener('change', fn) : prefersReducedMotionMedia.addListener(fn);
}
}
function removeChangeListener(fn) {
if (prefersReducedMotionMedia != null) {
prefersReducedMotionMedia.removeEventListener != null ? prefersReducedMotionMedia.removeEventListener('change', fn) : prefersReducedMotionMedia.removeListener(fn);
}
}
var handlers = {};
var AccessibilityInfo = {
/**
* Query whether a screen reader is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when a screen reader is enabled and `false` otherwise.
*/
isScreenReaderEnabled,
/**
* Query whether the user prefers reduced motion.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when a screen reader is enabled and `false` otherwise.
*/
isReduceMotionEnabled,
/**
* Deprecated
*/
fetch: isScreenReaderEnabled,
/**
* Add an event handler. Supported events: reduceMotionChanged
*/
addEventListener: function addEventListener(eventName, handler) {
if (eventName === 'reduceMotionChanged') {
if (!prefersReducedMotionMedia) {
return;
}
var listener = event => {
handler(event.matches);
};
addChangeListener(listener);
handlers[handler] = listener;
}
return {
remove: () => AccessibilityInfo.removeEventListener(eventName, handler)
};
},
/**
* Set accessibility focus to a react component.
*/
setAccessibilityFocus: function setAccessibilityFocus(reactTag) {},
/**
* Post a string to be announced by the screen reader.
*/
announceForAccessibility: function announceForAccessibility(announcement) {},
/**
* Remove an event handler.
*/
removeEventListener: function removeEventListener(eventName, handler) {
if (eventName === 'reduceMotionChanged') {
var listener = handlers[handler];
if (!listener || !prefersReducedMotionMedia) {
return;
}
removeChangeListener(listener);
}
return;
}
};
var _default = exports.default = AccessibilityInfo;
module.exports = exports.default;
@@ -0,0 +1,106 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["animating", "color", "hidesWhenStopped", "size", "style"];
var createSvgCircle = style => /*#__PURE__*/React.createElement("circle", {
cx: "16",
cy: "16",
fill: "none",
r: "14",
strokeWidth: "4",
style: style
});
var ActivityIndicator = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var _props$animating = props.animating,
animating = _props$animating === void 0 ? true : _props$animating,
_props$color = props.color,
color = _props$color === void 0 ? '#1976D2' : _props$color,
_props$hidesWhenStopp = props.hidesWhenStopped,
hidesWhenStopped = _props$hidesWhenStopp === void 0 ? true : _props$hidesWhenStopp,
_props$size = props.size,
size = _props$size === void 0 ? 'small' : _props$size,
style = props.style,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var svg = /*#__PURE__*/React.createElement("svg", {
height: "100%",
viewBox: "0 0 32 32",
width: "100%"
}, createSvgCircle({
stroke: color,
opacity: 0.2
}), createSvgCircle({
stroke: color,
strokeDasharray: 80,
strokeDashoffset: 60
}));
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, other, {
"aria-valuemax": 1,
"aria-valuemin": 0,
ref: forwardedRef,
role: "progressbar",
style: [styles.container, style]
}), /*#__PURE__*/React.createElement(_View.default, {
children: svg,
style: [typeof size === 'number' ? {
height: size,
width: size
} : indicatorSizes[size], styles.animation, !animating && styles.animationPause, !animating && hidesWhenStopped && styles.hidesWhenStopped]
}));
});
ActivityIndicator.displayName = 'ActivityIndicator';
var styles = _StyleSheet.default.create({
container: {
alignItems: 'center',
justifyContent: 'center'
},
hidesWhenStopped: {
visibility: 'hidden'
},
animation: {
animationDuration: '0.75s',
animationKeyframes: [{
'0%': {
transform: 'rotate(0deg)'
},
'100%': {
transform: 'rotate(360deg)'
}
}],
animationTimingFunction: 'linear',
animationIterationCount: 'infinite'
},
animationPause: {
animationPlayState: 'paused'
}
});
var indicatorSizes = _StyleSheet.default.create({
small: {
width: 20,
height: 20
},
large: {
width: 36,
height: 36
}
});
var _default = exports.default = ActivityIndicator;
module.exports = exports.default;
@@ -0,0 +1,18 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
class Alert {
static alert() {}
}
var _default = exports.default = Alert;
module.exports = exports.default;
@@ -0,0 +1,18 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _Animated = _interopRequireDefault(require("../../vendor/react-native/Animated/Animated"));
var _default = exports.default = _Animated.default;
module.exports = exports.default;
@@ -0,0 +1,47 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var RootTagContext = /*#__PURE__*/React.createContext(null);
var AppContainer = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var children = props.children,
WrapperComponent = props.WrapperComponent;
var innerView = /*#__PURE__*/React.createElement(_View.default, {
children: children,
key: 1,
style: styles.appContainer
});
if (WrapperComponent) {
innerView = /*#__PURE__*/React.createElement(WrapperComponent, null, innerView);
}
return /*#__PURE__*/React.createElement(RootTagContext.Provider, {
value: props.rootTag
}, /*#__PURE__*/React.createElement(_View.default, {
ref: forwardedRef,
style: styles.appContainer
}, innerView));
});
AppContainer.displayName = 'AppContainer';
var _default = exports.default = AppContainer;
var styles = _StyleSheet.default.create({
appContainer: {
flex: 1,
pointerEvents: 'box-none'
}
});
module.exports = exports.default;
@@ -0,0 +1,92 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _unmountComponentAtNode = _interopRequireDefault(require("../unmountComponentAtNode"));
var _renderApplication = _interopRequireWildcard(require("./renderApplication"));
var emptyObject = {};
var runnables = {};
var componentProviderInstrumentationHook = component => component();
var wrapperComponentProvider;
/**
* `AppRegistry` is the JS entry point to running all React Native apps.
*/
class AppRegistry {
static getAppKeys() {
return Object.keys(runnables);
}
static getApplication(appKey, appParameters) {
(0, _invariant.default)(runnables[appKey] && runnables[appKey].getApplication, "Application " + appKey + " has not been registered. " + 'This is either due to an import error during initialization or failure to call AppRegistry.registerComponent.');
return runnables[appKey].getApplication(appParameters);
}
static registerComponent(appKey, componentProvider) {
runnables[appKey] = {
getApplication: appParameters => (0, _renderApplication.getApplication)(componentProviderInstrumentationHook(componentProvider), appParameters ? appParameters.initialProps : emptyObject, wrapperComponentProvider && wrapperComponentProvider(appParameters)),
run: appParameters => (0, _renderApplication.default)(componentProviderInstrumentationHook(componentProvider), wrapperComponentProvider && wrapperComponentProvider(appParameters), appParameters.callback, {
hydrate: appParameters.hydrate || false,
initialProps: appParameters.initialProps || emptyObject,
mode: appParameters.mode || 'concurrent',
rootTag: appParameters.rootTag
})
};
return appKey;
}
static registerConfig(config) {
config.forEach(_ref => {
var appKey = _ref.appKey,
component = _ref.component,
run = _ref.run;
if (run) {
AppRegistry.registerRunnable(appKey, run);
} else {
(0, _invariant.default)(component, 'No component provider passed in');
AppRegistry.registerComponent(appKey, component);
}
});
}
// TODO: fix style sheet creation when using this method
static registerRunnable(appKey, run) {
runnables[appKey] = {
run
};
return appKey;
}
static runApplication(appKey, appParameters) {
var isDevelopment = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test';
if (isDevelopment) {
var params = (0, _objectSpread2.default)({}, appParameters);
params.rootTag = "#" + params.rootTag.id;
console.log("Running application \"" + appKey + "\" with appParams:\n", params, "\nDevelopment-level warnings: " + (isDevelopment ? 'ON' : 'OFF') + "." + ("\nPerformance optimizations: " + (isDevelopment ? 'OFF' : 'ON') + "."));
}
(0, _invariant.default)(runnables[appKey] && runnables[appKey].run, "Application \"" + appKey + "\" has not been registered. " + 'This is either due to an import error during initialization or failure to call AppRegistry.registerComponent.');
return runnables[appKey].run(appParameters);
}
static setComponentProviderInstrumentationHook(hook) {
componentProviderInstrumentationHook = hook;
}
static setWrapperComponentProvider(provider) {
wrapperComponentProvider = provider;
}
static unmountApplicationComponentAtRootTag(rootTag) {
(0, _unmountComponentAtNode.default)(rootTag);
}
}
exports.default = AppRegistry;
module.exports = exports.default;
@@ -0,0 +1,55 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = renderApplication;
exports.getApplication = getApplication;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _AppContainer = _interopRequireDefault(require("./AppContainer"));
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _render = _interopRequireWildcard(require("../render"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _react = _interopRequireDefault(require("react"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function renderApplication(RootComponent, WrapperComponent, callback, options) {
var shouldHydrate = options.hydrate,
initialProps = options.initialProps,
rootTag = options.rootTag;
var renderFn = shouldHydrate ? _render.hydrate : _render.default;
(0, _invariant.default)(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
return renderFn(/*#__PURE__*/_react.default.createElement(_AppContainer.default, {
WrapperComponent: WrapperComponent,
ref: callback,
rootTag: rootTag
}, /*#__PURE__*/_react.default.createElement(RootComponent, initialProps)), rootTag);
}
function getApplication(RootComponent, initialProps, WrapperComponent) {
var element = /*#__PURE__*/_react.default.createElement(_AppContainer.default, {
WrapperComponent: WrapperComponent,
rootTag: {}
}, /*#__PURE__*/_react.default.createElement(RootComponent, initialProps));
// Don't escape CSS text
var getStyleElement = props => {
var sheet = _StyleSheet.default.getSheet();
return /*#__PURE__*/_react.default.createElement("style", (0, _extends2.default)({}, props, {
dangerouslySetInnerHTML: {
__html: sheet.textContent
},
id: sheet.id
}));
};
return {
element,
getStyleElement
};
}
@@ -0,0 +1,63 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _EventEmitter = _interopRequireDefault(require("../../vendor/react-native/vendor/emitter/EventEmitter"));
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
// Android 4.4 browser
var isPrefixed = _canUseDom.default && !document.hasOwnProperty('hidden') && document.hasOwnProperty('webkitHidden');
var EVENT_TYPES = ['change', 'memoryWarning'];
var VISIBILITY_CHANGE_EVENT = isPrefixed ? 'webkitvisibilitychange' : 'visibilitychange';
var VISIBILITY_STATE_PROPERTY = isPrefixed ? 'webkitVisibilityState' : 'visibilityState';
var AppStates = {
BACKGROUND: 'background',
ACTIVE: 'active'
};
var changeEmitter = null;
class AppState {
static get currentState() {
if (!AppState.isAvailable) {
return AppStates.ACTIVE;
}
switch (document[VISIBILITY_STATE_PROPERTY]) {
case 'hidden':
case 'prerender':
case 'unloaded':
return AppStates.BACKGROUND;
default:
return AppStates.ACTIVE;
}
}
static addEventListener(type, handler) {
if (AppState.isAvailable) {
(0, _invariant.default)(EVENT_TYPES.indexOf(type) !== -1, 'Trying to subscribe to unknown event: "%s"', type);
if (type === 'change') {
if (!changeEmitter) {
changeEmitter = new _EventEmitter.default();
document.addEventListener(VISIBILITY_CHANGE_EVENT, () => {
if (changeEmitter) {
changeEmitter.emit('change', AppState.currentState);
}
}, false);
}
return changeEmitter.addListener(type, handler);
}
}
}
}
exports.default = AppState;
AppState.isAvailable = _canUseDom.default && !!document[VISIBILITY_STATE_PROPERTY];
module.exports = exports.default;
@@ -0,0 +1,54 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
function getQuery() {
return _canUseDom.default && window.matchMedia != null ? window.matchMedia('(prefers-color-scheme: dark)') : null;
}
var query = getQuery();
var listenerMapping = new WeakMap();
var Appearance = {
getColorScheme() {
return query && query.matches ? 'dark' : 'light';
},
addChangeListener(listener) {
var mappedListener = listenerMapping.get(listener);
if (!mappedListener) {
mappedListener = _ref => {
var matches = _ref.matches;
listener({
colorScheme: matches ? 'dark' : 'light'
});
};
listenerMapping.set(listener, mappedListener);
}
if (query) {
query.addListener(mappedListener);
}
function remove() {
var mappedListener = listenerMapping.get(listener);
if (query && mappedListener) {
query.removeListener(mappedListener);
}
listenerMapping.delete(listener);
}
return {
remove
};
}
};
var _default = exports.default = Appearance;
module.exports = exports.default;
@@ -0,0 +1,27 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function emptyFunction() {}
var BackHandler = {
exitApp: emptyFunction,
addEventListener() {
console.error('BackHandler is not supported on web and should not be used.');
return {
remove: emptyFunction
};
},
removeEventListener: emptyFunction
};
var _default = exports.default = BackHandler;
module.exports = exports.default;
@@ -0,0 +1,68 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _TouchableOpacity = _interopRequireDefault(require("../TouchableOpacity"));
var _Text = _interopRequireDefault(require("../Text"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
//import { warnOnce } from '../../modules/warnOnce';
var Button = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
// warnOnce('Button', 'Button is deprecated. Please use Pressable.');
var accessibilityLabel = props.accessibilityLabel,
color = props.color,
disabled = props.disabled,
onPress = props.onPress,
testID = props.testID,
title = props.title;
return /*#__PURE__*/React.createElement(_TouchableOpacity.default, {
accessibilityLabel: accessibilityLabel,
accessibilityRole: "button",
disabled: disabled,
focusable: !disabled,
onPress: onPress,
ref: forwardedRef,
style: [styles.button, color && {
backgroundColor: color
}, disabled && styles.buttonDisabled],
testID: testID
}, /*#__PURE__*/React.createElement(_Text.default, {
style: [styles.text, disabled && styles.textDisabled]
}, title));
});
Button.displayName = 'Button';
var styles = _StyleSheet.default.create({
button: {
backgroundColor: '#2196F3',
borderRadius: 2
},
text: {
color: '#fff',
fontWeight: '500',
padding: 8,
textAlign: 'center',
textTransform: 'uppercase'
},
buttonDisabled: {
backgroundColor: '#dfdfdf'
},
textDisabled: {
color: '#a1a1a1'
}
});
var _default = exports.default = Button;
module.exports = exports.default;
@@ -0,0 +1,112 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["aria-readonly", "color", "disabled", "onChange", "onValueChange", "readOnly", "style", "value"];
var CheckBox = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var ariaReadOnly = props['aria-readonly'],
color = props.color,
disabled = props.disabled,
onChange = props.onChange,
onValueChange = props.onValueChange,
readOnly = props.readOnly,
style = props.style,
value = props.value,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
function handleChange(event) {
var value = event.nativeEvent.target.checked;
event.nativeEvent.value = value;
onChange && onChange(event);
onValueChange && onValueChange(value);
}
var fakeControl = /*#__PURE__*/React.createElement(_View.default, {
style: [styles.fakeControl, value && styles.fakeControlChecked,
// custom color
value && color && {
backgroundColor: color,
borderColor: color
}, disabled && styles.fakeControlDisabled, value && disabled && styles.fakeControlCheckedAndDisabled]
});
var nativeControl = (0, _createElement.default)('input', {
checked: value,
disabled: disabled,
onChange: handleChange,
readOnly: readOnly === true || ariaReadOnly === true || other.accessibilityReadOnly === true,
ref: forwardedRef,
style: [styles.nativeControl, styles.cursorInherit],
type: 'checkbox'
});
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, other, {
"aria-disabled": disabled,
"aria-readonly": ariaReadOnly,
style: [styles.root, style, disabled && styles.cursorDefault]
}), fakeControl, nativeControl);
});
CheckBox.displayName = 'CheckBox';
var styles = _StyleSheet.default.create({
root: {
cursor: 'pointer',
height: 16,
userSelect: 'none',
width: 16
},
cursorDefault: {
cursor: 'default'
},
cursorInherit: {
cursor: 'inherit'
},
fakeControl: {
alignItems: 'center',
backgroundColor: '#fff',
borderColor: '#657786',
borderRadius: 2,
borderStyle: 'solid',
borderWidth: 2,
height: '100%',
justifyContent: 'center',
width: '100%'
},
fakeControlChecked: {
backgroundColor: '#009688',
backgroundImage: 'url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgdmVyc2lvbj0iMS4xIgogICB2aWV3Qm94PSIwIDAgMSAxIgogICBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWluWU1pbiBtZWV0Ij4KICA8cGF0aAogICAgIGQ9Ik0gMC4wNDAzODA1OSwwLjYyNjc3NjcgMC4xNDY0NDY2MSwwLjUyMDcxMDY4IDAuNDI5Mjg5MzIsMC44MDM1NTMzOSAwLjMyMzIyMzMsMC45MDk2MTk0MSB6IE0gMC4yMTcxNTcyOSwwLjgwMzU1MzM5IDAuODUzNTUzMzksMC4xNjcxNTcyOSAwLjk1OTYxOTQxLDAuMjczMjIzMyAwLjMyMzIyMzMsMC45MDk2MTk0MSB6IgogICAgIGlkPSJyZWN0Mzc4MCIKICAgICBzdHlsZT0iZmlsbDojZmZmZmZmO2ZpbGwtb3BhY2l0eToxO3N0cm9rZTpub25lIiAvPgo8L3N2Zz4K")',
backgroundRepeat: 'no-repeat',
borderColor: '#009688'
},
fakeControlDisabled: {
borderColor: '#CCD6DD'
},
fakeControlCheckedAndDisabled: {
backgroundColor: '#AAB8C2',
borderColor: '#AAB8C2'
},
nativeControl: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _StyleSheet.default.absoluteFillObject), {}, {
height: '100%',
margin: 0,
appearance: 'none',
padding: 0,
width: '100%'
})
});
var _default = exports.default = CheckBox;
module.exports = exports.default;
@@ -0,0 +1,61 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
exports.__esModule = true;
exports.default = void 0;
var clipboardAvailable;
class Clipboard {
static isAvailable() {
if (clipboardAvailable === undefined) {
clipboardAvailable = typeof document.queryCommandSupported === 'function' && document.queryCommandSupported('copy');
}
return clipboardAvailable;
}
static getString() {
return Promise.resolve('');
}
static setString(text) {
var success = false;
var body = document.body;
if (body) {
// add the text to a hidden node
var node = document.createElement('span');
node.textContent = text;
node.style.opacity = '0';
node.style.position = 'absolute';
node.style.whiteSpace = 'pre-wrap';
node.style.userSelect = 'auto';
body.appendChild(node);
// select the text
var selection = window.getSelection();
selection.removeAllRanges();
var range = document.createRange();
range.selectNodeContents(node);
selection.addRange(range);
// attempt to copy
try {
document.execCommand('copy');
success = true;
} catch (e) {}
// remove selection and node
selection.removeAllRanges();
body.removeChild(node);
}
return success;
}
}
exports.default = Clipboard;
module.exports = exports.default;
@@ -0,0 +1,8 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _RCTDeviceEventEmitter = _interopRequireDefault(require("../../vendor/react-native/EventEmitter/RCTDeviceEventEmitter"));
var _default = exports.default = _RCTDeviceEventEmitter.default;
module.exports = exports.default;
@@ -0,0 +1,128 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
var dimensions = {
window: {
fontScale: 1,
height: 0,
scale: 1,
width: 0
},
screen: {
fontScale: 1,
height: 0,
scale: 1,
width: 0
}
};
var listeners = {};
var shouldInit = _canUseDom.default;
function update() {
if (!_canUseDom.default) {
return;
}
var win = window;
var height;
var width;
/**
* iOS does not update viewport dimensions on keyboard open/close.
* window.visualViewport(https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport)
* is used instead of document.documentElement.clientHeight (which remains as a fallback)
*/
if (win.visualViewport) {
var visualViewport = win.visualViewport;
/**
* We are multiplying by scale because height and width from visual viewport
* also react to pinch zoom, and become smaller when zoomed. But it is not desired
* behaviour, since originally documentElement client height and width were used,
* and they do not react to pinch zoom.
*/
height = Math.round(visualViewport.height * visualViewport.scale);
width = Math.round(visualViewport.width * visualViewport.scale);
} else {
var docEl = win.document.documentElement;
height = docEl.clientHeight;
width = docEl.clientWidth;
}
dimensions.window = {
fontScale: 1,
height,
scale: win.devicePixelRatio || 1,
width
};
dimensions.screen = {
fontScale: 1,
height: win.screen.height,
scale: win.devicePixelRatio || 1,
width: win.screen.width
};
}
function handleResize() {
update();
if (Array.isArray(listeners['change'])) {
listeners['change'].forEach(handler => handler(dimensions));
}
}
class Dimensions {
static get(dimension) {
if (shouldInit) {
shouldInit = false;
update();
}
(0, _invariant.default)(dimensions[dimension], "No dimension set for key " + dimension);
return dimensions[dimension];
}
static set(initialDimensions) {
if (initialDimensions) {
if (_canUseDom.default) {
(0, _invariant.default)(false, 'Dimensions cannot be set in the browser');
} else {
if (initialDimensions.screen != null) {
dimensions.screen = initialDimensions.screen;
}
if (initialDimensions.window != null) {
dimensions.window = initialDimensions.window;
}
}
}
}
static addEventListener(type, handler) {
listeners[type] = listeners[type] || [];
listeners[type].push(handler);
return {
remove: () => {
this.removeEventListener(type, handler);
}
};
}
static removeEventListener(type, handler) {
if (Array.isArray(listeners[type])) {
listeners[type] = listeners[type].filter(_handler => _handler !== handler);
}
}
}
exports.default = Dimensions;
if (_canUseDom.default) {
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', handleResize, false);
} else {
window.addEventListener('resize', handleResize, false);
}
}
module.exports = exports.default;
@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _Easing = _interopRequireDefault(require("../../vendor/react-native/Animated/Easing"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _default = exports.default = _Easing.default;
module.exports = exports.default;
@@ -0,0 +1,19 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _FlatList = _interopRequireDefault(require("../../vendor/react-native/FlatList"));
var _default = exports.default = _FlatList.default;
module.exports = exports.default;
@@ -0,0 +1,29 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var I18nManager = {
allowRTL() {
return;
},
forceRTL() {
return;
},
getConstants() {
return {
isRTL: false
};
}
};
var _default = exports.default = I18nManager;
module.exports = exports.default;
@@ -0,0 +1,364 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var _AssetRegistry = require("../../modules/AssetRegistry");
var _preprocess = require("../StyleSheet/preprocess");
var _ImageLoader = _interopRequireDefault(require("../../modules/ImageLoader"));
var _PixelRatio = _interopRequireDefault(require("../PixelRatio"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _TextAncestorContext = _interopRequireDefault(require("../Text/TextAncestorContext"));
var _View = _interopRequireDefault(require("../View"));
var _warnOnce = require("../../modules/warnOnce");
var _excluded = ["aria-label", "accessibilityLabel", "blurRadius", "defaultSource", "draggable", "onError", "onLayout", "onLoad", "onLoadEnd", "onLoadStart", "pointerEvents", "source", "style"];
var ERRORED = 'ERRORED';
var LOADED = 'LOADED';
var LOADING = 'LOADING';
var IDLE = 'IDLE';
var _filterId = 0;
var svgDataUriPattern = /^(data:image\/svg\+xml;utf8,)(.*)/;
function createTintColorSVG(tintColor, id) {
return tintColor && id != null ? /*#__PURE__*/React.createElement("svg", {
style: {
position: 'absolute',
height: 0,
visibility: 'hidden',
width: 0
}
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("filter", {
id: "tint-" + id,
suppressHydrationWarning: true
}, /*#__PURE__*/React.createElement("feFlood", {
floodColor: "" + tintColor,
key: tintColor
}), /*#__PURE__*/React.createElement("feComposite", {
in2: "SourceAlpha",
operator: "in"
})))) : null;
}
function extractNonStandardStyleProps(style, blurRadius, filterId, tintColorProp) {
var flatStyle = _StyleSheet.default.flatten(style);
var filter = flatStyle.filter,
resizeMode = flatStyle.resizeMode,
shadowOffset = flatStyle.shadowOffset,
tintColor = flatStyle.tintColor;
if (flatStyle.resizeMode) {
(0, _warnOnce.warnOnce)('Image.style.resizeMode', 'Image: style.resizeMode is deprecated. Please use props.resizeMode.');
}
if (flatStyle.tintColor) {
(0, _warnOnce.warnOnce)('Image.style.tintColor', 'Image: style.tintColor is deprecated. Please use props.tintColor.');
}
// Add CSS filters
// React Native exposes these features as props and proprietary styles
var filters = [];
var _filter = null;
if (filter) {
filters.push(filter);
}
if (blurRadius) {
filters.push("blur(" + blurRadius + "px)");
}
if (shadowOffset) {
var shadowString = (0, _preprocess.createBoxShadowValue)(flatStyle);
if (shadowString) {
filters.push("drop-shadow(" + shadowString + ")");
}
}
if ((tintColorProp || tintColor) && filterId != null) {
filters.push("url(#tint-" + filterId + ")");
}
if (filters.length > 0) {
_filter = filters.join(' ');
}
return [resizeMode, _filter, tintColor];
}
function resolveAssetDimensions(source) {
if (typeof source === 'number') {
var _getAssetByID = (0, _AssetRegistry.getAssetByID)(source),
_height = _getAssetByID.height,
_width = _getAssetByID.width;
return {
height: _height,
width: _width
};
} else if (source != null && !Array.isArray(source) && typeof source === 'object') {
var _height2 = source.height,
_width2 = source.width;
return {
height: _height2,
width: _width2
};
}
}
function resolveAssetUri(source) {
var uri = null;
if (typeof source === 'number') {
// get the URI from the packager
var asset = (0, _AssetRegistry.getAssetByID)(source);
if (asset == null) {
throw new Error("Image: asset with ID \"" + source + "\" could not be found. Please check the image source or packager.");
}
var scale = asset.scales[0];
if (asset.scales.length > 1) {
var preferredScale = _PixelRatio.default.get();
// Get the scale which is closest to the preferred scale
scale = asset.scales.reduce((prev, curr) => Math.abs(curr - preferredScale) < Math.abs(prev - preferredScale) ? curr : prev);
}
var scaleSuffix = scale !== 1 ? "@" + scale + "x" : '';
uri = asset ? asset.httpServerLocation + "/" + asset.name + scaleSuffix + "." + asset.type : '';
} else if (typeof source === 'string') {
uri = source;
} else if (source && typeof source.uri === 'string') {
uri = source.uri;
}
if (uri) {
var match = uri.match(svgDataUriPattern);
// inline SVG markup may contain characters (e.g., #, ") that need to be escaped
if (match) {
var prefix = match[1],
svg = match[2];
var encodedSvg = encodeURIComponent(svg);
return "" + prefix + encodedSvg;
}
}
return uri;
}
var Image = /*#__PURE__*/React.forwardRef((props, ref) => {
var _ariaLabel = props['aria-label'],
accessibilityLabel = props.accessibilityLabel,
blurRadius = props.blurRadius,
defaultSource = props.defaultSource,
draggable = props.draggable,
onError = props.onError,
onLayout = props.onLayout,
onLoad = props.onLoad,
onLoadEnd = props.onLoadEnd,
onLoadStart = props.onLoadStart,
pointerEvents = props.pointerEvents,
source = props.source,
style = props.style,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var ariaLabel = _ariaLabel || accessibilityLabel;
if (process.env.NODE_ENV !== 'production') {
if (props.children) {
throw new Error('The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.');
}
}
var _React$useState = React.useState(() => {
var uri = resolveAssetUri(source);
if (uri != null) {
var isLoaded = _ImageLoader.default.has(uri);
if (isLoaded) {
return LOADED;
}
}
return IDLE;
}),
state = _React$useState[0],
updateState = _React$useState[1];
var _React$useState2 = React.useState({}),
layout = _React$useState2[0],
updateLayout = _React$useState2[1];
var hasTextAncestor = React.useContext(_TextAncestorContext.default);
var hiddenImageRef = React.useRef(null);
var filterRef = React.useRef(_filterId++);
var requestRef = React.useRef(null);
var shouldDisplaySource = state === LOADED || state === LOADING && defaultSource == null;
var _extractNonStandardSt = extractNonStandardStyleProps(style, blurRadius, filterRef.current, props.tintColor),
_resizeMode = _extractNonStandardSt[0],
filter = _extractNonStandardSt[1],
_tintColor = _extractNonStandardSt[2];
var resizeMode = props.resizeMode || _resizeMode || 'cover';
var tintColor = props.tintColor || _tintColor;
var selectedSource = shouldDisplaySource ? source : defaultSource;
var displayImageUri = resolveAssetUri(selectedSource);
var imageSizeStyle = resolveAssetDimensions(selectedSource);
var backgroundImage = displayImageUri ? "url(\"" + displayImageUri + "\")" : null;
var backgroundSize = getBackgroundSize();
// Accessibility image allows users to trigger the browser's image context menu
var hiddenImage = displayImageUri ? (0, _createElement.default)('img', {
alt: ariaLabel || '',
style: styles.accessibilityImage$raw,
draggable: draggable || false,
ref: hiddenImageRef,
src: displayImageUri
}) : null;
function getBackgroundSize() {
if (hiddenImageRef.current != null && (resizeMode === 'center' || resizeMode === 'repeat')) {
var _hiddenImageRef$curre = hiddenImageRef.current,
naturalHeight = _hiddenImageRef$curre.naturalHeight,
naturalWidth = _hiddenImageRef$curre.naturalWidth;
var _height3 = layout.height,
_width3 = layout.width;
if (naturalHeight && naturalWidth && _height3 && _width3) {
var scaleFactor = Math.min(1, _width3 / naturalWidth, _height3 / naturalHeight);
var x = Math.ceil(scaleFactor * naturalWidth);
var y = Math.ceil(scaleFactor * naturalHeight);
return x + "px " + y + "px";
}
}
}
function handleLayout(e) {
if (resizeMode === 'center' || resizeMode === 'repeat' || onLayout) {
var _layout = e.nativeEvent.layout;
onLayout && onLayout(e);
updateLayout(_layout);
}
}
// Image loading
var uri = resolveAssetUri(source);
React.useEffect(() => {
abortPendingRequest();
if (uri != null) {
updateState(LOADING);
if (onLoadStart) {
onLoadStart();
}
requestRef.current = _ImageLoader.default.load(uri, function load(e) {
updateState(LOADED);
if (onLoad) {
onLoad(e);
}
if (onLoadEnd) {
onLoadEnd();
}
}, function error() {
updateState(ERRORED);
if (onError) {
onError({
nativeEvent: {
error: "Failed to load resource " + uri
}
});
}
if (onLoadEnd) {
onLoadEnd();
}
});
}
function abortPendingRequest() {
if (requestRef.current != null) {
_ImageLoader.default.abort(requestRef.current);
requestRef.current = null;
}
}
return abortPendingRequest;
}, [uri, requestRef, updateState, onError, onLoad, onLoadEnd, onLoadStart]);
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, {
"aria-label": ariaLabel,
onLayout: handleLayout,
pointerEvents: pointerEvents,
ref: ref,
style: [styles.root, hasTextAncestor && styles.inline, imageSizeStyle, style, styles.undo,
// TEMP: avoid deprecated shadow props regression
// until Image refactored to use createElement.
{
boxShadow: null
}]
}), /*#__PURE__*/React.createElement(_View.default, {
style: [styles.image, resizeModeStyles[resizeMode], {
backgroundImage,
filter
}, backgroundSize != null && {
backgroundSize
}],
suppressHydrationWarning: true
}), hiddenImage, createTintColorSVG(tintColor, filterRef.current));
});
Image.displayName = 'Image';
// $FlowIgnore: This is the correct type, but casting makes it unhappy since the variables aren't defined yet
var ImageWithStatics = Image;
ImageWithStatics.getSize = function (uri, success, failure) {
_ImageLoader.default.getSize(uri, success, failure);
};
ImageWithStatics.prefetch = function (uri) {
return _ImageLoader.default.prefetch(uri);
};
ImageWithStatics.queryCache = function (uris) {
return _ImageLoader.default.queryCache(uris);
};
var styles = _StyleSheet.default.create({
root: {
flexBasis: 'auto',
overflow: 'hidden',
zIndex: 0
},
inline: {
display: 'inline-flex'
},
undo: {
// These styles are converted to CSS filters applied to the
// element displaying the background image.
blurRadius: null,
shadowColor: null,
shadowOpacity: null,
shadowOffset: null,
shadowRadius: null,
tintColor: null,
// These styles are not supported
overlayColor: null,
resizeMode: null
},
image: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _StyleSheet.default.absoluteFillObject), {}, {
backgroundColor: 'transparent',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
height: '100%',
width: '100%',
zIndex: -1
}),
accessibilityImage$raw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _StyleSheet.default.absoluteFillObject), {}, {
height: '100%',
opacity: 0,
width: '100%',
zIndex: -1
})
});
var resizeModeStyles = _StyleSheet.default.create({
center: {
backgroundSize: 'auto'
},
contain: {
backgroundSize: 'contain'
},
cover: {
backgroundSize: 'cover'
},
none: {
backgroundPosition: '0',
backgroundSize: 'auto'
},
repeat: {
backgroundPosition: '0',
backgroundRepeat: 'repeat',
backgroundSize: 'auto'
},
stretch: {
backgroundSize: '100% 100%'
}
});
var _default = exports.default = ImageWithStatics;
module.exports = exports.default;
@@ -0,0 +1 @@
"use strict";
@@ -0,0 +1,59 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _Image = _interopRequireDefault(require("../Image"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["children", "style", "imageStyle", "imageRef"];
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var emptyObject = {};
/**
* Very simple drop-in replacement for <Image> which supports nesting views.
*/
var ImageBackground = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
var children = props.children,
_props$style = props.style,
style = _props$style === void 0 ? emptyObject : _props$style,
imageStyle = props.imageStyle,
imageRef = props.imageRef,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var _StyleSheet$flatten = _StyleSheet.default.flatten(style),
height = _StyleSheet$flatten.height,
width = _StyleSheet$flatten.width;
return /*#__PURE__*/React.createElement(_View.default, {
ref: forwardedRef,
style: style
}, /*#__PURE__*/React.createElement(_Image.default, (0, _extends2.default)({}, rest, {
ref: imageRef,
style: [{
// Temporary Workaround:
// Current (imperfect yet) implementation of <Image> overwrites width and height styles
// (which is not quite correct), and these styles conflict with explicitly set styles
// of <ImageBackground> and with our internal layout model here.
// So, we have to proxy/reapply these styles explicitly for actual <Image> component.
// This workaround should be removed after implementing proper support of
// intrinsic content size of the <Image>.
width,
height,
zIndex: -1
}, _StyleSheet.default.absoluteFill, imageStyle]
})), children);
});
ImageBackground.displayName = 'ImageBackground';
var _default = exports.default = ImageBackground;
module.exports = exports.default;
@@ -0,0 +1,8 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _UnimplementedView = _interopRequireDefault(require("../../modules/UnimplementedView"));
var _default = exports.default = _UnimplementedView.default;
module.exports = exports.default;
@@ -0,0 +1,93 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
class TaskQueue {
constructor(_ref) {
var onMoreTasks = _ref.onMoreTasks;
this._onMoreTasks = onMoreTasks;
this._queueStack = [{
tasks: [],
popable: true
}];
}
enqueue(task) {
this._getCurrentQueue().push(task);
}
enqueueTasks(tasks) {
tasks.forEach(task => this.enqueue(task));
}
cancelTasks(tasksToCancel) {
this._queueStack = this._queueStack.map(queue => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, queue), {}, {
tasks: queue.tasks.filter(task => tasksToCancel.indexOf(task) === -1)
})).filter((queue, idx) => queue.tasks.length > 0 || idx === 0);
}
hasTasksToProcess() {
return this._getCurrentQueue().length > 0;
}
/**
* Executes the next task in the queue.
*/
processNext() {
var queue = this._getCurrentQueue();
if (queue.length) {
var task = queue.shift();
try {
if (typeof task === 'object' && task.gen) {
this._genPromise(task);
} else if (typeof task === 'object' && task.run) {
task.run();
} else {
(0, _invariant.default)(typeof task === 'function', 'Expected Function, SimpleTask, or PromiseTask, but got:\n' + JSON.stringify(task, null, 2));
task();
}
} catch (e) {
e.message = 'TaskQueue: Error with task ' + (task.name || '') + ': ' + e.message;
throw e;
}
}
}
_getCurrentQueue() {
var stackIdx = this._queueStack.length - 1;
var queue = this._queueStack[stackIdx];
if (queue.popable && queue.tasks.length === 0 && stackIdx > 0) {
this._queueStack.pop();
return this._getCurrentQueue();
} else {
return queue.tasks;
}
}
_genPromise(task) {
var length = this._queueStack.push({
tasks: [],
popable: false
});
var stackIdx = length - 1;
var stackItem = this._queueStack[stackIdx];
task.gen().then(() => {
stackItem.popable = true;
this.hasTasksToProcess() && this._onMoreTasks();
}).catch(ex => {
setTimeout(() => {
ex.message = "TaskQueue: Error resolving Promise in task " + task.name + ": " + ex.message;
throw ex;
}, 0);
});
}
}
var _default = exports.default = TaskQueue;
module.exports = exports.default;
@@ -0,0 +1,130 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
var _EventEmitter = _interopRequireDefault(require("../../vendor/react-native/vendor/emitter/EventEmitter"));
var _requestIdleCallback = _interopRequireDefault(require("../../modules/requestIdleCallback"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _emitter = new _EventEmitter.default();
var InteractionManager = {
Events: {
interactionStart: 'interactionStart',
interactionComplete: 'interactionComplete'
},
/**
* Schedule a function to run after all interactions have completed.
*/
runAfterInteractions(task) {
var tasks = [];
var promise = new Promise(resolve => {
_scheduleUpdate();
if (task) {
tasks.push(task);
}
tasks.push({
run: resolve,
name: 'resolve ' + (task && task.name || '?')
});
_taskQueue.enqueueTasks(tasks);
});
return {
then: promise.then.bind(promise),
done: promise.then.bind(promise),
cancel: () => {
_taskQueue.cancelTasks(tasks);
}
};
},
/**
* Notify manager that an interaction has started.
*/
createInteractionHandle() {
_scheduleUpdate();
var handle = ++_inc;
_addInteractionSet.add(handle);
return handle;
},
/**
* Notify manager that an interaction has completed.
*/
clearInteractionHandle(handle) {
(0, _invariant.default)(!!handle, 'Must provide a handle to clear.');
_scheduleUpdate();
_addInteractionSet.delete(handle);
_deleteInteractionSet.add(handle);
},
addListener: _emitter.addListener.bind(_emitter),
/**
*
* @param deadline
*/
setDeadline(deadline) {
_deadline = deadline;
}
};
var _interactionSet = new Set();
var _addInteractionSet = new Set();
var _deleteInteractionSet = new Set();
var _taskQueue = new _TaskQueue.default({
onMoreTasks: _scheduleUpdate
});
var _nextUpdateHandle = 0;
var _inc = 0;
var _deadline = -1;
/**
* Schedule an asynchronous update to the interaction state.
*/
function _scheduleUpdate() {
if (!_nextUpdateHandle) {
if (_deadline > 0) {
_nextUpdateHandle = setTimeout(_processUpdate);
} else {
_nextUpdateHandle = (0, _requestIdleCallback.default)(_processUpdate);
}
}
}
/**
* Notify listeners, process queue, etc
*/
function _processUpdate() {
_nextUpdateHandle = 0;
var interactionCount = _interactionSet.size;
_addInteractionSet.forEach(handle => _interactionSet.add(handle));
_deleteInteractionSet.forEach(handle => _interactionSet.delete(handle));
var nextInteractionCount = _interactionSet.size;
if (interactionCount !== 0 && nextInteractionCount === 0) {
_emitter.emit(InteractionManager.Events.interactionComplete);
} else if (interactionCount === 0 && nextInteractionCount !== 0) {
_emitter.emit(InteractionManager.Events.interactionStart);
}
if (nextInteractionCount === 0) {
// It seems that we can't know the running time of the current event loop,
// we can only calculate the running time of the current task queue.
var begin = Date.now();
while (_taskQueue.hasTasksToProcess()) {
_taskQueue.processNext();
if (_deadline > 0 && Date.now() - begin >= _deadline) {
_scheduleUpdate();
break;
}
}
}
_addInteractionSet.clear();
_deleteInteractionSet.clear();
}
var _default = exports.default = InteractionManager;
module.exports = exports.default;
@@ -0,0 +1,34 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _dismissKeyboard = _interopRequireDefault(require("../../modules/dismissKeyboard"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
// in the future we can use https://github.com/w3c/virtual-keyboard
var Keyboard = {
isVisible() {
return false;
},
addListener() {
return {
remove: () => {}
};
},
dismiss() {
(0, _dismissKeyboard.default)();
},
removeAllListeners() {},
removeListener() {}
};
var _default = exports.default = Keyboard;
module.exports = exports.default;
@@ -0,0 +1,52 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["behavior", "contentContainerStyle", "keyboardVerticalOffset"];
class KeyboardAvoidingView extends React.Component {
constructor() {
super(...arguments);
this.frame = null;
this.onLayout = event => {
this.frame = event.nativeEvent.layout;
};
}
relativeKeyboardHeight(keyboardFrame) {
var frame = this.frame;
if (!frame || !keyboardFrame) {
return 0;
}
var keyboardY = keyboardFrame.screenY - (this.props.keyboardVerticalOffset || 0);
return Math.max(frame.y + frame.height - keyboardY, 0);
}
onKeyboardChange(event) {}
render() {
var _this$props = this.props,
behavior = _this$props.behavior,
contentContainerStyle = _this$props.contentContainerStyle,
keyboardVerticalOffset = _this$props.keyboardVerticalOffset,
rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props, _excluded);
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({
onLayout: this.onLayout
}, rest));
}
}
var _default = exports.default = KeyboardAvoidingView;
module.exports = exports.default;
@@ -0,0 +1,17 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _LayoutAnimation = _interopRequireDefault(require("../../vendor/react-native/LayoutAnimation"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _default = exports.default = _LayoutAnimation.default;
module.exports = exports.default;
@@ -0,0 +1,109 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var initialURL = _canUseDom.default ? window.location.href : '';
class Linking {
constructor() {
this._eventCallbacks = {};
}
/**
* An object mapping of event name
* and all the callbacks subscribing to it
*/
_dispatchEvent(event) {
for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
data[_key - 1] = arguments[_key];
}
var listeners = this._eventCallbacks[event];
if (listeners != null && Array.isArray(listeners)) {
listeners.map(listener => {
listener(...data);
});
}
}
/**
* Adds a event listener for the specified event. The callback will be called when the
* said event is dispatched.
*/
addEventListener(eventType, callback) {
var _this = this;
if (!_this._eventCallbacks[eventType]) {
_this._eventCallbacks[eventType] = [callback];
}
_this._eventCallbacks[eventType].push(callback);
return {
remove() {
var callbacks = _this._eventCallbacks[eventType];
var filteredCallbacks = callbacks.filter(c => c.toString() !== callback.toString());
_this._eventCallbacks[eventType] = filteredCallbacks;
}
};
}
/**
* Removes a previously added event listener for the specified event. The callback must
* be the same object as the one passed to `addEventListener`.
*/
removeEventListener(eventType, callback) {
console.error("Linking.removeEventListener('" + eventType + "', ...): Method has been " + 'deprecated. Please instead use `remove()` on the subscription ' + 'returned by `Linking.addEventListener`.');
var callbacks = this._eventCallbacks[eventType];
var filteredCallbacks = callbacks.filter(c => c.toString() !== callback.toString());
this._eventCallbacks[eventType] = filteredCallbacks;
}
canOpenURL() {
return Promise.resolve(true);
}
getInitialURL() {
return Promise.resolve(initialURL);
}
/**
* Try to open the given url in a secure fashion. The method returns a Promise object.
* If a target is passed (including undefined) that target will be used, otherwise '_blank'.
* If the url opens, the promise is resolved. If not, the promise is rejected.
* Dispatches the `onOpen` event if `url` is opened successfully.
*/
openURL(url, target) {
if (arguments.length === 1) {
target = '_blank';
}
try {
open(url, target);
this._dispatchEvent('onOpen', url);
return Promise.resolve();
} catch (e) {
return Promise.reject(e);
}
}
_validateURL(url) {
(0, _invariant.default)(typeof url === 'string', 'Invalid URL: should be a string. Was: ' + url);
(0, _invariant.default)(url, 'Invalid URL: cannot be empty');
}
}
var open = (url, target) => {
if (_canUseDom.default) {
var urlToOpen = new URL(url, window.location).toString();
if (urlToOpen.indexOf('tel:') === 0) {
window.location = urlToOpen;
} else {
window.open(urlToOpen, target, 'noopener');
}
}
};
var _default = exports.default = new Linking();
module.exports = exports.default;
@@ -0,0 +1,21 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) 2016-present, Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var LogBox = {
ignoreLogs() {},
ignoreAllLogs() {},
uninstall() {},
install() {}
};
var _default = exports.default = LogBox;
module.exports = exports.default;
@@ -0,0 +1,149 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _createElement = _interopRequireDefault(require("../createElement"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var ANIMATION_DURATION = 250;
function getAnimationStyle(animationType, visible) {
if (animationType === 'slide') {
return visible ? animatedSlideInStyles : animatedSlideOutStyles;
}
if (animationType === 'fade') {
return visible ? animatedFadeInStyles : animatedFadeOutStyles;
}
return visible ? styles.container : styles.hidden;
}
function ModalAnimation(props) {
var animationType = props.animationType,
children = props.children,
onDismiss = props.onDismiss,
onShow = props.onShow,
visible = props.visible;
var _React$useState = React.useState(false),
isRendering = _React$useState[0],
setIsRendering = _React$useState[1];
var wasVisible = React.useRef(false);
var wasRendering = React.useRef(false);
var isAnimated = animationType && animationType !== 'none';
var animationEndCallback = React.useCallback(e => {
if (e && e.currentTarget !== e.target) {
// If the event was generated for something NOT this element we
// should ignore it as it's not relevant to us
return;
}
if (visible) {
if (onShow) {
onShow();
}
} else {
setIsRendering(false);
}
}, [onShow, visible]);
React.useEffect(() => {
if (wasRendering.current && !isRendering && onDismiss) {
onDismiss();
}
wasRendering.current = isRendering;
}, [isRendering, onDismiss]);
React.useEffect(() => {
if (visible) {
setIsRendering(true);
}
if (visible !== wasVisible.current && !isAnimated) {
// Manually call `animationEndCallback` if no animation is used
animationEndCallback();
}
wasVisible.current = visible;
}, [isAnimated, visible, animationEndCallback]);
return isRendering || visible ? (0, _createElement.default)('div', {
style: isRendering ? getAnimationStyle(animationType, visible) : styles.hidden,
onAnimationEnd: animationEndCallback,
children
}) : null;
}
var styles = _StyleSheet.default.create({
container: {
position: 'fixed',
top: 0,
right: 0,
bottom: 0,
left: 0,
zIndex: 9999
},
animatedIn: {
animationDuration: ANIMATION_DURATION + "ms",
animationTimingFunction: 'cubic-bezier(0.215, 0.61, 0.355, 1)'
},
animatedOut: {
pointerEvents: 'none',
animationDuration: ANIMATION_DURATION + "ms",
animationTimingFunction: 'cubic-bezier(0.47, 0, 0.745, 0.715)'
},
fadeIn: {
opacity: 1,
animationKeyframes: {
'0%': {
opacity: 0
},
'100%': {
opacity: 1
}
}
},
fadeOut: {
opacity: 0,
animationKeyframes: {
'0%': {
opacity: 1
},
'100%': {
opacity: 0
}
}
},
slideIn: {
transform: 'translateY(0%)',
animationKeyframes: {
'0%': {
transform: 'translateY(100%)'
},
'100%': {
transform: 'translateY(0%)'
}
}
},
slideOut: {
transform: 'translateY(100%)',
animationKeyframes: {
'0%': {
transform: 'translateY(0%)'
},
'100%': {
transform: 'translateY(100%)'
}
}
},
hidden: {
opacity: 0
}
});
var animatedSlideInStyles = [styles.container, styles.animatedIn, styles.slideIn];
var animatedSlideOutStyles = [styles.container, styles.animatedOut, styles.slideOut];
var animatedFadeInStyles = [styles.container, styles.animatedIn, styles.fadeIn];
var animatedFadeOutStyles = [styles.container, styles.animatedOut, styles.fadeOut];
var _default = exports.default = ModalAnimation;
module.exports = exports.default;
@@ -0,0 +1,75 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _View = _interopRequireDefault(require("../View"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
var _excluded = ["active", "children", "onRequestClose", "transparent"];
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var ModalContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var active = props.active,
children = props.children,
onRequestClose = props.onRequestClose,
transparent = props.transparent,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
React.useEffect(() => {
if (_canUseDom.default) {
var closeOnEscape = e => {
if (active && e.key === 'Escape') {
e.stopPropagation();
if (onRequestClose) {
onRequestClose();
}
}
};
document.addEventListener('keyup', closeOnEscape, false);
return () => document.removeEventListener('keyup', closeOnEscape, false);
}
}, [active, onRequestClose]);
var style = React.useMemo(() => {
return [styles.modal, transparent ? styles.modalTransparent : styles.modalOpaque];
}, [transparent]);
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, {
"aria-modal": true,
ref: forwardedRef,
role: active ? 'dialog' : null,
style: style
}), /*#__PURE__*/React.createElement(_View.default, {
style: styles.container
}, children));
});
var styles = _StyleSheet.default.create({
modal: {
position: 'fixed',
top: 0,
right: 0,
bottom: 0,
left: 0
},
modalTransparent: {
backgroundColor: 'transparent'
},
modalOpaque: {
backgroundColor: 'white'
},
container: {
top: 0,
flex: 1
}
});
var _default = exports.default = ModalContent;
module.exports = exports.default;
@@ -0,0 +1,138 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _View = _interopRequireDefault(require("../View"));
var _createElement = _interopRequireDefault(require("../createElement"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _UIManager = _interopRequireDefault(require("../UIManager"));
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
/**
* This Component is used to "wrap" the modal we're opening
* so that changing focus via tab will never leave the document.
*
* This allows us to properly trap the focus within a modal
* even if the modal is at the start or end of a document.
*/
var FocusBracket = () => {
return (0, _createElement.default)('div', {
role: 'none',
tabIndex: 0,
style: styles.focusBracket
});
};
function attemptFocus(element) {
if (!_canUseDom.default) {
return false;
}
try {
element.focus();
} catch (e) {
// Do nothing
}
return document.activeElement === element;
}
function focusFirstDescendant(element) {
for (var i = 0; i < element.childNodes.length; i++) {
var child = element.childNodes[i];
if (attemptFocus(child) || focusFirstDescendant(child)) {
return true;
}
}
return false;
}
function focusLastDescendant(element) {
for (var i = element.childNodes.length - 1; i >= 0; i--) {
var child = element.childNodes[i];
if (attemptFocus(child) || focusLastDescendant(child)) {
return true;
}
}
return false;
}
var ModalFocusTrap = _ref => {
var active = _ref.active,
children = _ref.children;
var trapElementRef = React.useRef();
var focusRef = React.useRef({
trapFocusInProgress: false,
lastFocusedElement: null
});
React.useEffect(() => {
if (_canUseDom.default) {
var trapFocus = () => {
// We should not trap focus if:
// - The modal hasn't fully initialized with an HTMLElement ref
// - Focus is already in the process of being trapped (e.g., we're refocusing)
// - isTrapActive prop being falsey tells us to do nothing
if (trapElementRef.current == null || focusRef.current.trapFocusInProgress || !active) {
return;
}
try {
focusRef.current.trapFocusInProgress = true;
if (document.activeElement instanceof Node && !trapElementRef.current.contains(document.activeElement)) {
// To handle keyboard focusing we can make an assumption here.
// If you're tabbing through the focusable elements, the previously
// active element will either be the first or the last.
// If the previously selected element is the "first" descendant
// and we're leaving it - this means that we should be looping
// around to the other side of the modal.
var hasFocused = focusFirstDescendant(trapElementRef.current);
if (focusRef.current.lastFocusedElement === document.activeElement) {
hasFocused = focusLastDescendant(trapElementRef.current);
}
// If we couldn't focus a new element then we need to focus onto the trap target
if (!hasFocused && trapElementRef.current != null && document.activeElement) {
_UIManager.default.focus(trapElementRef.current);
}
}
} finally {
focusRef.current.trapFocusInProgress = false;
}
focusRef.current.lastFocusedElement = document.activeElement;
};
// Call the trapFocus callback at least once when this modal has been activated.
trapFocus();
document.addEventListener('focus', trapFocus, true);
return () => document.removeEventListener('focus', trapFocus, true);
}
}, [active]);
// To be fully compliant with WCAG we need to refocus element that triggered opening modal
// after closing it
React.useEffect(function () {
if (_canUseDom.default) {
var lastFocusedElementOutsideTrap = document.activeElement;
return function () {
if (lastFocusedElementOutsideTrap && document.contains(lastFocusedElementOutsideTrap)) {
_UIManager.default.focus(lastFocusedElementOutsideTrap);
}
};
}
}, []);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FocusBracket, null), /*#__PURE__*/React.createElement(_View.default, {
ref: trapElementRef
}, children), /*#__PURE__*/React.createElement(FocusBracket, null));
};
var _default = exports.default = ModalFocusTrap;
var styles = _StyleSheet.default.create({
focusBracket: {
outlineStyle: 'none'
}
});
module.exports = exports.default;
@@ -0,0 +1,43 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactDom = require("react-dom");
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function ModalPortal(props) {
var children = props.children;
var elementRef = React.useRef(null);
if (_canUseDom.default && !elementRef.current) {
var element = document.createElement('div');
if (element && document.body) {
document.body.appendChild(element);
elementRef.current = element;
}
}
React.useEffect(() => {
if (_canUseDom.default) {
return () => {
if (document.body && elementRef.current) {
document.body.removeChild(elementRef.current);
elementRef.current = null;
}
};
}
}, []);
return elementRef.current && _canUseDom.default ? /*#__PURE__*/(0, _reactDom.createPortal)(children, elementRef.current) : null;
}
var _default = exports.default = ModalPortal;
module.exports = exports.default;
@@ -0,0 +1,106 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _ModalPortal = _interopRequireDefault(require("./ModalPortal"));
var _ModalAnimation = _interopRequireDefault(require("./ModalAnimation"));
var _ModalContent = _interopRequireDefault(require("./ModalContent"));
var _ModalFocusTrap = _interopRequireDefault(require("./ModalFocusTrap"));
var _excluded = ["animationType", "children", "onDismiss", "onRequestClose", "onShow", "transparent", "visible"];
var uniqueModalIdentifier = 0;
var activeModalStack = [];
var activeModalListeners = {};
function notifyActiveModalListeners() {
if (activeModalStack.length === 0) {
return;
}
var activeModalId = activeModalStack[activeModalStack.length - 1];
activeModalStack.forEach(modalId => {
if (modalId in activeModalListeners) {
activeModalListeners[modalId](modalId === activeModalId);
}
});
}
function removeActiveModal(modalId) {
if (modalId in activeModalListeners) {
// Before removing this listener we should probably tell it
// that it's no longer the active modal for sure.
activeModalListeners[modalId](false);
delete activeModalListeners[modalId];
}
var index = activeModalStack.indexOf(modalId);
if (index !== -1) {
activeModalStack.splice(index, 1);
notifyActiveModalListeners();
}
}
function addActiveModal(modalId, listener) {
removeActiveModal(modalId);
activeModalStack.push(modalId);
activeModalListeners[modalId] = listener;
notifyActiveModalListeners();
}
var Modal = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var animationType = props.animationType,
children = props.children,
onDismiss = props.onDismiss,
onRequestClose = props.onRequestClose,
onShow = props.onShow,
transparent = props.transparent,
_props$visible = props.visible,
visible = _props$visible === void 0 ? true : _props$visible,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
// Set a unique model identifier so we can correctly route
// dismissals and check the layering of modals.
var modalId = React.useMemo(() => uniqueModalIdentifier++, []);
var _React$useState = React.useState(false),
isActive = _React$useState[0],
setIsActive = _React$useState[1];
var onDismissCallback = React.useCallback(() => {
removeActiveModal(modalId);
if (onDismiss) {
onDismiss();
}
}, [modalId, onDismiss]);
var onShowCallback = React.useCallback(() => {
addActiveModal(modalId, setIsActive);
if (onShow) {
onShow();
}
}, [modalId, onShow]);
React.useEffect(() => {
return () => removeActiveModal(modalId);
}, [modalId]);
return /*#__PURE__*/React.createElement(_ModalPortal.default, null, /*#__PURE__*/React.createElement(_ModalAnimation.default, {
animationType: animationType,
onDismiss: onDismissCallback,
onShow: onShowCallback,
visible: visible
}, /*#__PURE__*/React.createElement(_ModalFocusTrap.default, {
active: isActive
}, /*#__PURE__*/React.createElement(_ModalContent.default, (0, _extends2.default)({}, rest, {
active: isActive,
onRequestClose: onRequestClose,
ref: forwardedRef,
transparent: transparent
}), children))));
});
var _default = exports.default = Modal;
module.exports = exports.default;
@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _NativeEventEmitter = _interopRequireDefault(require("../../vendor/react-native/EventEmitter/NativeEventEmitter"));
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _default = exports.default = _NativeEventEmitter.default;
module.exports = exports.default;
@@ -0,0 +1,21 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _UIManager = _interopRequireDefault(require("../UIManager"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
// NativeModules shim
var NativeModules = {
UIManager: _UIManager.default
};
var _default = exports.default = NativeModules;
module.exports = exports.default;
@@ -0,0 +1,273 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
/**
* PAN RESPONDER
*
* `PanResponder` uses the Responder System to reconcile several touches into
* a single gesture. It makes single-touch gestures resilient to extra touches,
* and can be used to recognize simple multi-touch gestures. For each handler,
* it provides a `gestureState` object alongside the ResponderEvent object.
*
* By default, `PanResponder` holds an `InteractionManager` handle to block
* long-running JS events from interrupting active gestures.
*
* A graphical explanation of the touch data flow:
*
* +----------------------------+ +--------------------------------+
* | ResponderTouchHistoryStore | |TouchHistoryMath |
* +----------------------------+ +----------+---------------------+
* |Global store of touchHistory| |Allocation-less math util |
* |including activeness, start | |on touch history (centroids |
* |position, prev/cur position.| |and multitouch movement etc) |
* | | | |
* +----^-----------------------+ +----^---------------------------+
* | |
* | (records relevant history |
* | of touches relevant for |
* | implementing higher level |
* | gestures) |
* | |
* +----+-----------------------+ +----|---------------------------+
* | ResponderEventPlugin | | | Your App/Component |
* +----------------------------+ +----|---------------------------+
* |Negotiates which view gets | Low level | | High level |
* |onResponderMove events. | events w/ | +-+-------+ events w/ |
* |Also records history into | touchHistory| | Pan | multitouch + |
* |ResponderTouchHistoryStore. +---------------->Responder+-----> accumulative|
* +----------------------------+ attached to | | | distance and |
* each event | +---------+ velocity. |
* | |
* | |
* +--------------------------------+
*/
'use strict';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _InteractionManager = _interopRequireDefault(require("../InteractionManager"));
var _TouchHistoryMath = _interopRequireDefault(require("../../vendor/react-native/TouchHistoryMath"));
var currentCentroidX = _TouchHistoryMath.default.currentCentroidX,
currentCentroidY = _TouchHistoryMath.default.currentCentroidY,
currentCentroidXOfTouchesChangedAfter = _TouchHistoryMath.default.currentCentroidXOfTouchesChangedAfter,
currentCentroidYOfTouchesChangedAfter = _TouchHistoryMath.default.currentCentroidYOfTouchesChangedAfter,
previousCentroidXOfTouchesChangedAfter = _TouchHistoryMath.default.previousCentroidXOfTouchesChangedAfter,
previousCentroidYOfTouchesChangedAfter = _TouchHistoryMath.default.previousCentroidYOfTouchesChangedAfter;
var PanResponder = {
_initializeGestureState(gestureState) {
gestureState.x = 0;
gestureState.y = 0;
gestureState.initialX = 0;
gestureState.initialY = 0;
gestureState.deltaX = 0;
gestureState.deltaY = 0;
gestureState.velocityX = 0;
gestureState.velocityY = 0;
gestureState.numberActiveTouches = 0;
// All `gestureState` accounts for timeStamps up until:
gestureState._accountsForMovesUpTo = 0;
},
/**
* Take all recently moved touches, calculate how the centroid has changed just for those
* recently moved touches, and append that change to an accumulator. This is
* to (at least) handle the case where the user is moving three fingers, and
* then one of the fingers stops but the other two continue.
*
* This is very different than taking all of the recently moved touches and
* storing their centroid as `dx/dy`. For correctness, we must *accumulate
* changes* in the centroid of recently moved touches.
*
* There is also some nuance with how we handle multiple moved touches in a
* single event. Multiple touches generate two 'move' events, each of
* them triggering `onResponderMove`. But with the way `PanResponder` works,
* all of the gesture inference is performed on the first dispatch, since it
* looks at all of the touches. Therefore, `PanResponder` does not call
* `onResponderMove` passed the first dispatch. This diverges from the
* typical responder callback pattern (without using `PanResponder`), but
* avoids more dispatches than necessary.
*
* When moving two touches in opposite directions, the cumulative
* distance is zero in each dimension. When two touches move in parallel five
* pixels in the same direction, the cumulative distance is five, not ten. If
* two touches start, one moves five in a direction, then stops and the other
* touch moves fives in the same direction, the cumulative distance is ten.
*
* This logic requires a kind of processing of time "clusters" of touch events
* so that two touch moves that essentially occur in parallel but move every
* other frame respectively, are considered part of the same movement.
*
* x/y: If a move event has been observed, `(x, y)` is the centroid of the most
* recently moved "cluster" of active touches.
* deltaX/deltaY: Cumulative touch distance. Accounts for touch moves that are
* clustered together in time, moving the same direction. Only valid when
* currently responder (otherwise, it only represents the drag distance below
* the threshold).
*/
_updateGestureStateOnMove(gestureState, touchHistory) {
var movedAfter = gestureState._accountsForMovesUpTo;
var prevX = previousCentroidXOfTouchesChangedAfter(touchHistory, movedAfter);
var prevY = previousCentroidYOfTouchesChangedAfter(touchHistory, movedAfter);
var prevDeltaX = gestureState.deltaX;
var prevDeltaY = gestureState.deltaY;
var x = currentCentroidXOfTouchesChangedAfter(touchHistory, movedAfter);
var y = currentCentroidYOfTouchesChangedAfter(touchHistory, movedAfter);
var deltaX = prevDeltaX + (x - prevX);
var deltaY = prevDeltaY + (y - prevY);
// TODO: This must be filtered intelligently.
var dt = touchHistory.mostRecentTimeStamp - gestureState._accountsForMovesUpTo;
gestureState.deltaX = deltaX;
gestureState.deltaY = deltaY;
gestureState.numberActiveTouches = touchHistory.numberActiveTouches;
gestureState.velocityX = (deltaX - prevDeltaX) / dt;
gestureState.velocityY = (deltaY - prevDeltaY) / dt;
gestureState.x = x;
gestureState.y = y;
gestureState._accountsForMovesUpTo = touchHistory.mostRecentTimeStamp;
},
/**
* Enhanced versions of all of the responder callbacks that provide not only
* the `ResponderEvent`, but also the `PanResponder` gesture state.
*
* In general, for events that have capture equivalents, we update the
* gestureState once in the capture phase and can use it in the bubble phase
* as well.
*/
create(config) {
var interactionState = {
handle: null
};
var gestureState = {
// Useful for debugging
stateID: Math.random(),
x: 0,
y: 0,
initialX: 0,
initialY: 0,
deltaX: 0,
deltaY: 0,
velocityX: 0,
velocityY: 0,
numberActiveTouches: 0,
_accountsForMovesUpTo: 0
};
var onStartShouldSetResponder = config.onStartShouldSetResponder,
onStartShouldSetResponderCapture = config.onStartShouldSetResponderCapture,
onMoveShouldSetResponder = config.onMoveShouldSetResponder,
onMoveShouldSetResponderCapture = config.onMoveShouldSetResponderCapture,
onPanGrant = config.onPanGrant,
onPanStart = config.onPanStart,
onPanMove = config.onPanMove,
onPanEnd = config.onPanEnd,
onPanRelease = config.onPanRelease,
onPanReject = config.onPanReject,
onPanTerminate = config.onPanTerminate,
onPanTerminationRequest = config.onPanTerminationRequest;
var panHandlers = {
onStartShouldSetResponder(event) {
return onStartShouldSetResponder != null ? onStartShouldSetResponder(event, gestureState) : false;
},
onMoveShouldSetResponder(event) {
return onMoveShouldSetResponder != null ? onMoveShouldSetResponder(event, gestureState) : false;
},
onStartShouldSetResponderCapture(event) {
// TODO: Actually, we should reinitialize the state any time
// touches.length increases from 0 active to > 0 active.
if (event.nativeEvent.touches.length === 1) {
PanResponder._initializeGestureState(gestureState);
}
gestureState.numberActiveTouches = event.touchHistory.numberActiveTouches;
return onStartShouldSetResponderCapture != null ? onStartShouldSetResponderCapture(event, gestureState) : false;
},
onMoveShouldSetResponderCapture(event) {
var touchHistory = event.touchHistory;
// Responder system incorrectly dispatches should* to current responder
// Filter out any touch moves past the first one - we would have
// already processed multi-touch geometry during the first event.
// NOTE: commented out because new responder system should get it right.
//if (gestureState._accountsForMovesUpTo === touchHistory.mostRecentTimeStamp) {
// return false;
//}
PanResponder._updateGestureStateOnMove(gestureState, touchHistory);
return onMoveShouldSetResponderCapture != null ? onMoveShouldSetResponderCapture(event, gestureState) : false;
},
onResponderGrant(event) {
if (!interactionState.handle) {
interactionState.handle = _InteractionManager.default.createInteractionHandle();
}
gestureState.initialX = currentCentroidX(event.touchHistory);
gestureState.initialY = currentCentroidY(event.touchHistory);
gestureState.deltaX = 0;
gestureState.deltaY = 0;
if (onPanGrant != null) {
onPanGrant(event, gestureState);
}
},
onResponderReject(event) {
clearInteractionHandle(interactionState, onPanReject, event, gestureState);
},
onResponderStart(event) {
var numberActiveTouches = event.touchHistory.numberActiveTouches;
gestureState.numberActiveTouches = numberActiveTouches;
if (onPanStart != null) {
onPanStart(event, gestureState);
}
},
onResponderMove(event) {
var touchHistory = event.touchHistory;
// Guard against the dispatch of two touch moves when there are two
// simultaneously changed touches.
if (gestureState._accountsForMovesUpTo === touchHistory.mostRecentTimeStamp) {
return;
}
// Filter out any touch moves past the first one - we would have
// already processed multi-touch geometry during the first event.
PanResponder._updateGestureStateOnMove(gestureState, touchHistory);
if (onPanMove != null) {
onPanMove(event, gestureState);
}
},
onResponderEnd(event) {
var numberActiveTouches = event.touchHistory.numberActiveTouches;
gestureState.numberActiveTouches = numberActiveTouches;
clearInteractionHandle(interactionState, onPanEnd, event, gestureState);
},
onResponderRelease(event) {
clearInteractionHandle(interactionState, onPanRelease, event, gestureState);
PanResponder._initializeGestureState(gestureState);
},
onResponderTerminate(event) {
clearInteractionHandle(interactionState, onPanTerminate, event, gestureState);
PanResponder._initializeGestureState(gestureState);
},
onResponderTerminationRequest(event) {
return onPanTerminationRequest != null ? onPanTerminationRequest(event, gestureState) : true;
}
};
return {
panHandlers,
getInteractionHandle() {
return interactionState.handle;
}
};
}
};
function clearInteractionHandle(interactionState, callback, event, gestureState) {
if (interactionState.handle) {
_InteractionManager.default.clearInteractionHandle(interactionState.handle);
interactionState.handle = null;
}
if (callback) {
callback(event, gestureState);
}
}
var _default = exports.default = PanResponder;
module.exports = exports.default;
@@ -0,0 +1,8 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _PanResponder = _interopRequireDefault(require("../../vendor/react-native/PanResponder"));
var _default = exports.default = _PanResponder.default;
module.exports = exports.default;
@@ -0,0 +1,32 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = PickerItem;
var _createElement = _interopRequireDefault(require("../createElement"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function PickerItem(props) {
var color = props.color,
label = props.label,
testID = props.testID,
value = props.value;
var style = {
color
};
return (0, _createElement.default)('option', {
children: label,
style,
testID,
value
});
}
module.exports = exports.default;
@@ -0,0 +1,73 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePlatformMethods = _interopRequireDefault(require("../../modules/usePlatformMethods"));
var _PickerItem = _interopRequireDefault(require("./PickerItem"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _excluded = ["children", "enabled", "onValueChange", "selectedValue", "style", "testID", "itemStyle", "mode", "prompt"];
var Picker = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var children = props.children,
enabled = props.enabled,
onValueChange = props.onValueChange,
selectedValue = props.selectedValue,
style = props.style,
testID = props.testID,
itemStyle = props.itemStyle,
mode = props.mode,
prompt = props.prompt,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var hostRef = React.useRef(null);
function handleChange(e) {
var _e$target = e.target,
selectedIndex = _e$target.selectedIndex,
value = _e$target.value;
if (onValueChange) {
onValueChange(value, selectedIndex);
}
}
// $FlowFixMe
var supportedProps = (0, _objectSpread2.default)({
children,
disabled: enabled === false ? true : undefined,
onChange: handleChange,
style: [styles.initial, style],
testID,
value: selectedValue
}, other);
var platformMethodsRef = (0, _usePlatformMethods.default)(supportedProps);
var setRef = (0, _useMergeRefs.default)(hostRef, platformMethodsRef, forwardedRef);
supportedProps.ref = setRef;
return (0, _createElement.default)('select', supportedProps);
});
// $FlowFixMe
Picker.Item = _PickerItem.default;
var styles = _StyleSheet.default.create({
initial: {
fontFamily: 'System',
fontSize: 'inherit',
margin: 0
}
});
var _default = exports.default = Picker;
module.exports = exports.default;
@@ -0,0 +1,55 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _Dimensions = _interopRequireDefault(require("../Dimensions"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
/**
* PixelRatio gives access to the device pixel density.
*/
class PixelRatio {
/**
* Returns the device pixel density.
*/
static get() {
return _Dimensions.default.get('window').scale;
}
/**
* No equivalent for Web
*/
static getFontScale() {
return _Dimensions.default.get('window').fontScale || PixelRatio.get();
}
/**
* Converts a layout size (dp) to pixel size (px).
* Guaranteed to return an integer number.
*/
static getPixelSizeForLayoutSize(layoutSize) {
return Math.round(layoutSize * PixelRatio.get());
}
/**
* Rounds a layout size (dp) to the nearest layout size that corresponds to
* an integer number of pixels. For example, on a device with a PixelRatio
* of 3, `PixelRatio.roundToNearestPixel(8.4) = 8.33`, which corresponds to
* exactly (8.33 * 3) = 25 pixels.
*/
static roundToNearestPixel(layoutSize) {
var ratio = PixelRatio.get();
return Math.round(layoutSize * ratio) / ratio;
}
}
exports.default = PixelRatio;
module.exports = exports.default;
@@ -0,0 +1,29 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var Platform = {
OS: 'web',
select: obj => 'web' in obj ? obj.web : obj.default,
get isTesting() {
if (process.env.NODE_ENV === 'test') {
return true;
}
return false;
},
get Version() {
return '0.0.0';
}
};
var _default = exports.default = Platform;
module.exports = exports.default;
@@ -0,0 +1,158 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _useHover = _interopRequireDefault(require("../../modules/useHover"));
var _usePressEvents = _interopRequireDefault(require("../../modules/usePressEvents"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["children", "delayLongPress", "delayPressIn", "delayPressOut", "disabled", "onBlur", "onContextMenu", "onFocus", "onHoverIn", "onHoverOut", "onKeyDown", "onLongPress", "onPress", "onPressMove", "onPressIn", "onPressOut", "style", "tabIndex", "testOnly_hovered", "testOnly_pressed"];
/**
* Component used to build display components that should respond to whether the
* component is currently pressed or not.
*/
function Pressable(props, forwardedRef) {
var children = props.children,
delayLongPress = props.delayLongPress,
delayPressIn = props.delayPressIn,
delayPressOut = props.delayPressOut,
disabled = props.disabled,
onBlur = props.onBlur,
onContextMenu = props.onContextMenu,
onFocus = props.onFocus,
onHoverIn = props.onHoverIn,
onHoverOut = props.onHoverOut,
onKeyDown = props.onKeyDown,
onLongPress = props.onLongPress,
onPress = props.onPress,
onPressMove = props.onPressMove,
onPressIn = props.onPressIn,
onPressOut = props.onPressOut,
style = props.style,
tabIndex = props.tabIndex,
testOnly_hovered = props.testOnly_hovered,
testOnly_pressed = props.testOnly_pressed,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var _useForceableState = useForceableState(testOnly_hovered === true),
hovered = _useForceableState[0],
setHovered = _useForceableState[1];
var _useForceableState2 = useForceableState(false),
focused = _useForceableState2[0],
setFocused = _useForceableState2[1];
var _useForceableState3 = useForceableState(testOnly_pressed === true),
pressed = _useForceableState3[0],
setPressed = _useForceableState3[1];
var hostRef = (0, _react.useRef)(null);
var setRef = (0, _useMergeRefs.default)(forwardedRef, hostRef);
var pressConfig = (0, _react.useMemo)(() => ({
delayLongPress,
delayPressStart: delayPressIn,
delayPressEnd: delayPressOut,
disabled,
onLongPress,
onPress,
onPressChange: setPressed,
onPressStart: onPressIn,
onPressMove,
onPressEnd: onPressOut
}), [delayLongPress, delayPressIn, delayPressOut, disabled, onLongPress, onPress, onPressIn, onPressMove, onPressOut, setPressed]);
var pressEventHandlers = (0, _usePressEvents.default)(hostRef, pressConfig);
var onContextMenuPress = pressEventHandlers.onContextMenu,
onKeyDownPress = pressEventHandlers.onKeyDown;
(0, _useHover.default)(hostRef, {
contain: true,
disabled,
onHoverChange: setHovered,
onHoverStart: onHoverIn,
onHoverEnd: onHoverOut
});
var interactionState = {
hovered,
focused,
pressed
};
var blurHandler = React.useCallback(e => {
if (e.nativeEvent.target === hostRef.current) {
setFocused(false);
if (onBlur != null) {
onBlur(e);
}
}
}, [hostRef, setFocused, onBlur]);
var focusHandler = React.useCallback(e => {
if (e.nativeEvent.target === hostRef.current) {
setFocused(true);
if (onFocus != null) {
onFocus(e);
}
}
}, [hostRef, setFocused, onFocus]);
var contextMenuHandler = React.useCallback(e => {
if (onContextMenuPress != null) {
onContextMenuPress(e);
}
if (onContextMenu != null) {
onContextMenu(e);
}
}, [onContextMenu, onContextMenuPress]);
var keyDownHandler = React.useCallback(e => {
if (onKeyDownPress != null) {
onKeyDownPress(e);
}
if (onKeyDown != null) {
onKeyDown(e);
}
}, [onKeyDown, onKeyDownPress]);
var _tabIndex;
if (tabIndex !== undefined) {
_tabIndex = tabIndex;
} else {
_tabIndex = disabled ? -1 : 0;
}
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, pressEventHandlers, {
"aria-disabled": disabled,
onBlur: blurHandler,
onContextMenu: contextMenuHandler,
onFocus: focusHandler,
onKeyDown: keyDownHandler,
ref: setRef,
style: [disabled ? styles.disabled : styles.active, typeof style === 'function' ? style(interactionState) : style],
tabIndex: _tabIndex
}), typeof children === 'function' ? children(interactionState) : children);
}
function useForceableState(forced) {
var _useState = (0, _react.useState)(false),
bool = _useState[0],
setBool = _useState[1];
return [bool || forced, setBool];
}
var styles = _StyleSheet.default.create({
active: {
cursor: 'pointer',
touchAction: 'manipulation'
},
disabled: {
pointerEvents: 'box-none'
}
});
var MemoedPressable = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(Pressable));
MemoedPressable.displayName = 'Pressable';
var _default = exports.default = MemoedPressable;
module.exports = exports.default;
@@ -0,0 +1,81 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["color", "indeterminate", "progress", "trackColor", "style"];
var ProgressBar = /*#__PURE__*/React.forwardRef((props, ref) => {
var _props$color = props.color,
color = _props$color === void 0 ? '#1976D2' : _props$color,
_props$indeterminate = props.indeterminate,
indeterminate = _props$indeterminate === void 0 ? false : _props$indeterminate,
_props$progress = props.progress,
progress = _props$progress === void 0 ? 0 : _props$progress,
_props$trackColor = props.trackColor,
trackColor = _props$trackColor === void 0 ? 'transparent' : _props$trackColor,
style = props.style,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var percentageProgress = progress * 100;
var width = indeterminate ? '25%' : percentageProgress + "%";
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, other, {
"aria-valuemax": 100,
"aria-valuemin": 0,
"aria-valuenow": indeterminate ? null : percentageProgress,
ref: ref,
role: "progressbar",
style: [styles.track, style, {
backgroundColor: trackColor
}]
}), /*#__PURE__*/React.createElement(_View.default, {
style: [{
backgroundColor: color,
width
}, styles.progress, indeterminate && styles.animation]
}));
});
ProgressBar.displayName = 'ProgressBar';
var styles = _StyleSheet.default.create({
track: {
forcedColorAdjust: 'none',
height: 5,
overflow: 'hidden',
userSelect: 'none',
zIndex: 0
},
progress: {
forcedColorAdjust: 'none',
height: '100%',
zIndex: -1
},
animation: {
animationDuration: '1s',
animationKeyframes: [{
'0%': {
transform: 'translateX(-100%)'
},
'100%': {
transform: 'translateX(400%)'
}
}],
animationTimingFunction: 'linear',
animationIterationCount: 'infinite'
}
});
var _default = exports.default = ProgressBar;
module.exports = exports.default;
@@ -0,0 +1,34 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _View = _interopRequireDefault(require("../View"));
var _react = _interopRequireDefault(require("react"));
var _excluded = ["colors", "enabled", "onRefresh", "progressBackgroundColor", "progressViewOffset", "refreshing", "size", "tintColor", "title", "titleColor"];
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function RefreshControl(props) {
var colors = props.colors,
enabled = props.enabled,
onRefresh = props.onRefresh,
progressBackgroundColor = props.progressBackgroundColor,
progressViewOffset = props.progressViewOffset,
refreshing = props.refreshing,
size = props.size,
tintColor = props.tintColor,
title = props.title,
titleColor = props.titleColor,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
return /*#__PURE__*/_react.default.createElement(_View.default, rest);
}
var _default = exports.default = RefreshControl;
module.exports = exports.default;
@@ -0,0 +1,47 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
var _excluded = ["style"];
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var cssFunction = function () {
if (_canUseDom.default && window.CSS && window.CSS.supports && window.CSS.supports('top: constant(safe-area-inset-top)')) {
return 'constant';
}
return 'env';
}();
var SafeAreaView = /*#__PURE__*/React.forwardRef((props, ref) => {
var style = props.style,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, {
ref: ref,
style: [styles.root, style]
}));
});
SafeAreaView.displayName = 'SafeAreaView';
var styles = _StyleSheet.default.create({
root: {
paddingTop: cssFunction + "(safe-area-inset-top)",
paddingRight: cssFunction + "(safe-area-inset-right)",
paddingBottom: cssFunction + "(safe-area-inset-bottom)",
paddingLeft: cssFunction + "(safe-area-inset-left)"
}
});
var _default = exports.default = SafeAreaView;
module.exports = exports.default;
@@ -0,0 +1,150 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _excluded = ["onScroll", "onTouchMove", "onWheel", "scrollEnabled", "scrollEventThrottle", "showsHorizontalScrollIndicator", "showsVerticalScrollIndicator", "style"];
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function normalizeScrollEvent(e) {
return {
nativeEvent: {
contentOffset: {
get x() {
return e.target.scrollLeft;
},
get y() {
return e.target.scrollTop;
}
},
contentSize: {
get height() {
return e.target.scrollHeight;
},
get width() {
return e.target.scrollWidth;
}
},
layoutMeasurement: {
get height() {
return e.target.offsetHeight;
},
get width() {
return e.target.offsetWidth;
}
}
},
timeStamp: Date.now()
};
}
function shouldEmitScrollEvent(lastTick, eventThrottle) {
var timeSinceLastTick = Date.now() - lastTick;
return eventThrottle > 0 && timeSinceLastTick >= eventThrottle;
}
/**
* Encapsulates the Web-specific scroll throttling and disabling logic
*/
var ScrollViewBase = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var onScroll = props.onScroll,
onTouchMove = props.onTouchMove,
onWheel = props.onWheel,
_props$scrollEnabled = props.scrollEnabled,
scrollEnabled = _props$scrollEnabled === void 0 ? true : _props$scrollEnabled,
_props$scrollEventThr = props.scrollEventThrottle,
scrollEventThrottle = _props$scrollEventThr === void 0 ? 0 : _props$scrollEventThr,
showsHorizontalScrollIndicator = props.showsHorizontalScrollIndicator,
showsVerticalScrollIndicator = props.showsVerticalScrollIndicator,
style = props.style,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var scrollState = React.useRef({
isScrolling: false,
scrollLastTick: 0
});
var scrollTimeout = React.useRef(null);
var scrollRef = React.useRef(null);
function createPreventableScrollHandler(handler) {
return e => {
if (scrollEnabled) {
if (handler) {
handler(e);
}
}
};
}
function handleScroll(e) {
e.stopPropagation();
if (e.target === scrollRef.current) {
e.persist();
// A scroll happened, so the scroll resets the scrollend timeout.
if (scrollTimeout.current != null) {
clearTimeout(scrollTimeout.current);
}
scrollTimeout.current = setTimeout(() => {
handleScrollEnd(e);
}, 100);
if (scrollState.current.isScrolling) {
// Scroll last tick may have changed, check if we need to notify
if (shouldEmitScrollEvent(scrollState.current.scrollLastTick, scrollEventThrottle)) {
handleScrollTick(e);
}
} else {
// Weren't scrolling, so we must have just started
handleScrollStart(e);
}
}
}
function handleScrollStart(e) {
scrollState.current.isScrolling = true;
handleScrollTick(e);
}
function handleScrollTick(e) {
scrollState.current.scrollLastTick = Date.now();
if (onScroll) {
onScroll(normalizeScrollEvent(e));
}
}
function handleScrollEnd(e) {
scrollState.current.isScrolling = false;
if (onScroll) {
onScroll(normalizeScrollEvent(e));
}
}
var hideScrollbar = showsHorizontalScrollIndicator === false || showsVerticalScrollIndicator === false;
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, {
onScroll: handleScroll,
onTouchMove: createPreventableScrollHandler(onTouchMove),
onWheel: createPreventableScrollHandler(onWheel),
ref: (0, _useMergeRefs.default)(scrollRef, forwardedRef),
style: [style, !scrollEnabled && styles.scrollDisabled, hideScrollbar && styles.hideScrollbar]
}));
});
// Chrome doesn't support e.preventDefault in this case; touch-action must be
// used to disable scrolling.
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
var styles = _StyleSheet.default.create({
scrollDisabled: {
overflowX: 'hidden',
overflowY: 'hidden',
touchAction: 'none'
},
hideScrollbar: {
scrollbarWidth: 'none'
}
});
var _default = exports.default = ScrollViewBase;
module.exports = exports.default;
@@ -0,0 +1,662 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _Dimensions = _interopRequireDefault(require("../Dimensions"));
var _dismissKeyboard = _interopRequireDefault(require("../../modules/dismissKeyboard"));
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
var _mergeRefs = _interopRequireDefault(require("../../modules/mergeRefs"));
var _Platform = _interopRequireDefault(require("../Platform"));
var _ScrollViewBase = _interopRequireDefault(require("./ScrollViewBase"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _TextInputState = _interopRequireDefault(require("../../modules/TextInputState"));
var _UIManager = _interopRequireDefault(require("../UIManager"));
var _View = _interopRequireDefault(require("../View"));
var _react = _interopRequireDefault(require("react"));
var _warning = _interopRequireDefault(require("fbjs/lib/warning"));
var _excluded = ["contentContainerStyle", "horizontal", "onContentSizeChange", "refreshControl", "stickyHeaderIndices", "pagingEnabled", "forwardedRef", "keyboardDismissMode", "onScroll", "centerContent"];
var emptyObject = {};
var IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16;
class ScrollView extends _react.default.Component {
constructor() {
super(...arguments);
this._scrollNodeRef = null;
this._innerViewRef = null;
this.isTouching = false;
this.lastMomentumScrollBeginTime = 0;
this.lastMomentumScrollEndTime = 0;
this.observedScrollSinceBecomingResponder = false;
this.becameResponderWhileAnimating = false;
this.scrollResponderHandleScrollShouldSetResponder = () => {
return this.isTouching;
};
this.scrollResponderHandleStartShouldSetResponderCapture = e => {
// First see if we want to eat taps while the keyboard is up
// var currentlyFocusedTextInput = TextInputState.currentlyFocusedField();
// if (!this.props.keyboardShouldPersistTaps &&
// currentlyFocusedTextInput != null &&
// e.target !== currentlyFocusedTextInput) {
// return true;
// }
return this.scrollResponderIsAnimating();
};
this.scrollResponderHandleTerminationRequest = () => {
return !this.observedScrollSinceBecomingResponder;
};
this.scrollResponderHandleTouchEnd = e => {
var nativeEvent = e.nativeEvent;
this.isTouching = nativeEvent.touches.length !== 0;
this.props.onTouchEnd && this.props.onTouchEnd(e);
};
this.scrollResponderHandleResponderRelease = e => {
this.props.onResponderRelease && this.props.onResponderRelease(e);
// By default scroll views will unfocus a textField
// if another touch occurs outside of it
var currentlyFocusedTextInput = _TextInputState.default.currentlyFocusedField();
if (!this.props.keyboardShouldPersistTaps && currentlyFocusedTextInput != null && e.target !== currentlyFocusedTextInput && !this.observedScrollSinceBecomingResponder && !this.becameResponderWhileAnimating) {
this.props.onScrollResponderKeyboardDismissed && this.props.onScrollResponderKeyboardDismissed(e);
_TextInputState.default.blurTextInput(currentlyFocusedTextInput);
}
};
this.scrollResponderHandleScroll = e => {
this.observedScrollSinceBecomingResponder = true;
this.props.onScroll && this.props.onScroll(e);
};
this.scrollResponderHandleResponderGrant = e => {
this.observedScrollSinceBecomingResponder = false;
this.props.onResponderGrant && this.props.onResponderGrant(e);
this.becameResponderWhileAnimating = this.scrollResponderIsAnimating();
};
this.scrollResponderHandleScrollBeginDrag = e => {
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
};
this.scrollResponderHandleScrollEndDrag = e => {
this.props.onScrollEndDrag && this.props.onScrollEndDrag(e);
};
this.scrollResponderHandleMomentumScrollBegin = e => {
this.lastMomentumScrollBeginTime = Date.now();
this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
};
this.scrollResponderHandleMomentumScrollEnd = e => {
this.lastMomentumScrollEndTime = Date.now();
this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e);
};
this.scrollResponderHandleTouchStart = e => {
this.isTouching = true;
this.props.onTouchStart && this.props.onTouchStart(e);
};
this.scrollResponderHandleTouchMove = e => {
this.props.onTouchMove && this.props.onTouchMove(e);
};
this.scrollResponderIsAnimating = () => {
var now = Date.now();
var timeSinceLastMomentumScrollEnd = now - this.lastMomentumScrollEndTime;
var isAnimating = timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS || this.lastMomentumScrollEndTime < this.lastMomentumScrollBeginTime;
return isAnimating;
};
this.scrollResponderScrollTo = (x, y, animated) => {
if (typeof x === 'number') {
console.warn('`scrollResponderScrollTo(x, y, animated)` is deprecated. Use `scrollResponderScrollTo({x: 5, y: 5, animated: true})` instead.');
} else {
var _ref = x || emptyObject;
x = _ref.x;
y = _ref.y;
animated = _ref.animated;
}
var node = this.getScrollableNode();
var left = x || 0;
var top = y || 0;
if (node != null) {
if (typeof node.scroll === 'function') {
node.scroll({
top,
left,
behavior: !animated ? 'auto' : 'smooth'
});
} else {
node.scrollLeft = left;
node.scrollTop = top;
}
}
};
this.scrollResponderZoomTo = (rect, animated) => {
if (_Platform.default.OS !== 'ios') {
(0, _invariant.default)('zoomToRect is not implemented');
}
};
this.scrollResponderScrollNativeHandleToKeyboard = (nodeHandle, additionalOffset, preventNegativeScrollOffset) => {
this.additionalScrollOffset = additionalOffset || 0;
this.preventNegativeScrollOffset = !!preventNegativeScrollOffset;
_UIManager.default.measureLayout(nodeHandle, this.getInnerViewNode(), this.scrollResponderTextInputFocusError, this.scrollResponderInputMeasureAndScrollToKeyboard);
};
this.scrollResponderInputMeasureAndScrollToKeyboard = (left, top, width, height) => {
var keyboardScreenY = _Dimensions.default.get('window').height;
if (this.keyboardWillOpenTo) {
keyboardScreenY = this.keyboardWillOpenTo.endCoordinates.screenY;
}
var scrollOffsetY = top - keyboardScreenY + height + this.additionalScrollOffset;
// By default, this can scroll with negative offset, pulling the content
// down so that the target component's bottom meets the keyboard's top.
// If requested otherwise, cap the offset at 0 minimum to avoid content
// shifting down.
if (this.preventNegativeScrollOffset) {
scrollOffsetY = Math.max(0, scrollOffsetY);
}
this.scrollResponderScrollTo({
x: 0,
y: scrollOffsetY,
animated: true
});
this.additionalOffset = 0;
this.preventNegativeScrollOffset = false;
};
this.scrollResponderKeyboardWillShow = e => {
this.keyboardWillOpenTo = e;
this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e);
};
this.scrollResponderKeyboardWillHide = e => {
this.keyboardWillOpenTo = null;
this.props.onKeyboardWillHide && this.props.onKeyboardWillHide(e);
};
this.scrollResponderKeyboardDidShow = e => {
// TODO(7693961): The event for DidShow is not available on iOS yet.
// Use the one from WillShow and do not assign.
if (e) {
this.keyboardWillOpenTo = e;
}
this.props.onKeyboardDidShow && this.props.onKeyboardDidShow(e);
};
this.scrollResponderKeyboardDidHide = e => {
this.keyboardWillOpenTo = null;
this.props.onKeyboardDidHide && this.props.onKeyboardDidHide(e);
};
this.flashScrollIndicators = () => {
this.scrollResponderFlashScrollIndicators();
};
this.getScrollResponder = () => {
return this;
};
this.getScrollableNode = () => {
return this._scrollNodeRef;
};
this.getInnerViewRef = () => {
return this._innerViewRef;
};
this.getInnerViewNode = () => {
return this._innerViewRef;
};
this.getNativeScrollRef = () => {
return this._scrollNodeRef;
};
this.scrollTo = (y, x, animated) => {
if (typeof y === 'number') {
console.warn('`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.');
} else {
var _ref2 = y || emptyObject;
x = _ref2.x;
y = _ref2.y;
animated = _ref2.animated;
}
this.scrollResponderScrollTo({
x: x || 0,
y: y || 0,
animated: animated !== false
});
};
this.scrollToEnd = options => {
// Default to true
var animated = (options && options.animated) !== false;
var horizontal = this.props.horizontal;
var scrollResponderNode = this.getScrollableNode();
var x = horizontal ? scrollResponderNode.scrollWidth : 0;
var y = horizontal ? 0 : scrollResponderNode.scrollHeight;
this.scrollResponderScrollTo({
x,
y,
animated
});
};
this._handleContentOnLayout = e => {
var _e$nativeEvent$layout = e.nativeEvent.layout,
width = _e$nativeEvent$layout.width,
height = _e$nativeEvent$layout.height;
this.props.onContentSizeChange(width, height);
};
this._handleScroll = e => {
if (process.env.NODE_ENV !== 'production') {
if (this.props.onScroll && this.props.scrollEventThrottle == null) {
console.log('You specified `onScroll` on a <ScrollView> but not ' + '`scrollEventThrottle`. You will only receive one event. ' + 'Using `16` you get all the events but be aware that it may ' + "cause frame drops, use a bigger number if you don't need as " + 'much precision.');
}
}
if (this.props.keyboardDismissMode === 'on-drag') {
(0, _dismissKeyboard.default)();
}
this.scrollResponderHandleScroll(e);
};
this._setInnerViewRef = node => {
this._innerViewRef = node;
};
this._setScrollNodeRef = node => {
this._scrollNodeRef = node;
// ScrollView needs to add more methods to the hostNode in addition to those
// added by `usePlatformMethods`. This is temporarily until an API like
// `ScrollView.scrollTo(hostNode, { x, y })` is added to React Native.
if (node != null) {
node.getScrollResponder = this.getScrollResponder;
node.getInnerViewNode = this.getInnerViewNode;
node.getInnerViewRef = this.getInnerViewRef;
node.getNativeScrollRef = this.getNativeScrollRef;
node.getScrollableNode = this.getScrollableNode;
node.scrollTo = this.scrollTo;
node.scrollToEnd = this.scrollToEnd;
node.flashScrollIndicators = this.flashScrollIndicators;
node.scrollResponderZoomTo = this.scrollResponderZoomTo;
node.scrollResponderScrollNativeHandleToKeyboard = this.scrollResponderScrollNativeHandleToKeyboard;
}
var ref = (0, _mergeRefs.default)(this.props.forwardedRef);
ref(node);
};
}
/**
* ------------------------------------------------------
* START SCROLLRESPONDER
* ------------------------------------------------------
*/
// Reset to false every time becomes responder. This is used to:
// - Determine if the scroll view has been scrolled and therefore should
// refuse to give up its responder lock.
// - Determine if releasing should dismiss the keyboard when we are in
// tap-to-dismiss mode (!this.props.keyboardShouldPersistTaps).
/**
* Invoke this from an `onScroll` event.
*/
/**
* Merely touch starting is not sufficient for a scroll view to become the
* responder. Being the "responder" means that the very next touch move/end
* event will result in an action/movement.
*
* Invoke this from an `onStartShouldSetResponder` event.
*
* `onStartShouldSetResponder` is used when the next move/end will trigger
* some UI movement/action, but when you want to yield priority to views
* nested inside of the view.
*
* There may be some cases where scroll views actually should return `true`
* from `onStartShouldSetResponder`: Any time we are detecting a standard tap
* that gives priority to nested views.
*
* - If a single tap on the scroll view triggers an action such as
* recentering a map style view yet wants to give priority to interaction
* views inside (such as dropped pins or labels), then we would return true
* from this method when there is a single touch.
*
* - Similar to the previous case, if a two finger "tap" should trigger a
* zoom, we would check the `touches` count, and if `>= 2`, we would return
* true.
*
*/
scrollResponderHandleStartShouldSetResponder() {
return false;
}
/**
* There are times when the scroll view wants to become the responder
* (meaning respond to the next immediate `touchStart/touchEnd`), in a way
* that *doesn't* give priority to nested views (hence the capture phase):
*
* - Currently animating.
* - Tapping anywhere that is not the focused input, while the keyboard is
* up (which should dismiss the keyboard).
*
* Invoke this from an `onStartShouldSetResponderCapture` event.
*/
/**
* Invoke this from an `onResponderReject` event.
*
* Some other element is not yielding its role as responder. Normally, we'd
* just disable the `UIScrollView`, but a touch has already began on it, the
* `UIScrollView` will not accept being disabled after that. The easiest
* solution for now is to accept the limitation of disallowing this
* altogether. To improve this, find a way to disable the `UIScrollView` after
* a touch has already started.
*/
scrollResponderHandleResponderReject() {
(0, _warning.default)(false, "ScrollView doesn't take rejection well - scrolls anyway");
}
/**
* We will allow the scroll view to give up its lock iff it acquired the lock
* during an animation. This is a very useful default that happens to satisfy
* many common user experiences.
*
* - Stop a scroll on the left edge, then turn that into an outer view's
* backswipe.
* - Stop a scroll mid-bounce at the top, continue pulling to have the outer
* view dismiss.
* - However, without catching the scroll view mid-bounce (while it is
* motionless), if you drag far enough for the scroll view to become
* responder (and therefore drag the scroll view a bit), any backswipe
* navigation of a swipe gesture higher in the view hierarchy, should be
* rejected.
*/
/**
* Invoke this from an `onTouchEnd` event.
*
* @param {SyntheticEvent} e Event.
*/
/**
* Invoke this from an `onResponderRelease` event.
*/
/**
* Invoke this from an `onResponderGrant` event.
*/
/**
* Unfortunately, `onScrollBeginDrag` also fires when *stopping* the scroll
* animation, and there's not an easy way to distinguish a drag vs. stopping
* momentum.
*
* Invoke this from an `onScrollBeginDrag` event.
*/
/**
* Invoke this from an `onScrollEndDrag` event.
*/
/**
* Invoke this from an `onMomentumScrollBegin` event.
*/
/**
* Invoke this from an `onMomentumScrollEnd` event.
*/
/**
* Invoke this from an `onTouchStart` event.
*
* Since we know that the `SimpleEventPlugin` occurs later in the plugin
* order, after `ResponderEventPlugin`, we can detect that we were *not*
* permitted to be the responder (presumably because a contained view became
* responder). The `onResponderReject` won't fire in that case - it only
* fires when a *current* responder rejects our request.
*
* @param {SyntheticEvent} e Touch Start event.
*/
/**
* Invoke this from an `onTouchMove` event.
*
* Since we know that the `SimpleEventPlugin` occurs later in the plugin
* order, after `ResponderEventPlugin`, we can detect that we were *not*
* permitted to be the responder (presumably because a contained view became
* responder). The `onResponderReject` won't fire in that case - it only
* fires when a *current* responder rejects our request.
*
* @param {SyntheticEvent} e Touch Start event.
*/
/**
* A helper function for this class that lets us quickly determine if the
* view is currently animating. This is particularly useful to know when
* a touch has just started or ended.
*/
/**
* A helper function to scroll to a specific point in the scrollview.
* This is currently used to help focus on child textviews, but can also
* be used to quickly scroll to any element we want to focus. Syntax:
*
* scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
*
* Note: The weird argument signature is due to the fact that, for historical reasons,
* the function also accepts separate arguments as as alternative to the options object.
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
*/
/**
* A helper function to zoom to a specific rect in the scrollview. The argument has the shape
* {x: number; y: number; width: number; height: number; animated: boolean = true}
*
* @platform ios
*/
/**
* Displays the scroll indicators momentarily.
*/
scrollResponderFlashScrollIndicators() {}
/**
* This method should be used as the callback to onFocus in a TextInputs'
* parent view. Note that any module using this mixin needs to return
* the parent view's ref in getScrollViewRef() in order to use this method.
* @param {any} nodeHandle The TextInput node handle
* @param {number} additionalOffset The scroll view's top "contentInset".
* Default is 0.
* @param {bool} preventNegativeScrolling Whether to allow pulling the content
* down to make it meet the keyboard's top. Default is false.
*/
/**
* The calculations performed here assume the scroll view takes up the entire
* screen - even if has some content inset. We then measure the offsets of the
* keyboard, and compensate both for the scroll view's "contentInset".
*
* @param {number} left Position of input w.r.t. table view.
* @param {number} top Position of input w.r.t. table view.
* @param {number} width Width of the text input.
* @param {number} height Height of the text input.
*/
scrollResponderTextInputFocusError(e) {
console.error('Error measuring text field: ', e);
}
/**
* Warning, this may be called several times for a single keyboard opening.
* It's best to store the information in this method and then take any action
* at a later point (either in `keyboardDidShow` or other).
*
* Here's the order that events occur in:
* - focus
* - willShow {startCoordinates, endCoordinates} several times
* - didShow several times
* - blur
* - willHide {startCoordinates, endCoordinates} several times
* - didHide several times
*
* The `ScrollResponder` providesModule callbacks for each of these events.
* Even though any user could have easily listened to keyboard events
* themselves, using these `props` callbacks ensures that ordering of events
* is consistent - and not dependent on the order that the keyboard events are
* subscribed to. This matters when telling the scroll view to scroll to where
* the keyboard is headed - the scroll responder better have been notified of
* the keyboard destination before being instructed to scroll to where the
* keyboard will be. Stick to the `ScrollResponder` callbacks, and everything
* will work.
*
* WARNING: These callbacks will fire even if a keyboard is displayed in a
* different navigation pane. Filter out the events to determine if they are
* relevant to you. (For example, only if you receive these callbacks after
* you had explicitly focused a node etc).
*/
/**
* ------------------------------------------------------
* END SCROLLRESPONDER
* ------------------------------------------------------
*/
/**
* Returns a reference to the underlying scroll responder, which supports
* operations like `scrollTo`. All ScrollView-like components should
* implement this method so that they can be composed while providing access
* to the underlying scroll responder's methods.
*/
/**
* Scrolls to a given x, y offset, either immediately or with a smooth animation.
* Syntax:
*
* scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
*
* Note: The weird argument signature is due to the fact that, for historical reasons,
* the function also accepts separate arguments as as alternative to the options object.
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
*/
/**
* If this is a vertical ScrollView scrolls to the bottom.
* If this is a horizontal ScrollView scrolls to the right.
*
* Use `scrollToEnd({ animated: true })` for smooth animated scrolling,
* `scrollToEnd({ animated: false })` for immediate scrolling.
* If no options are passed, `animated` defaults to true.
*/
render() {
var _this$props = this.props,
contentContainerStyle = _this$props.contentContainerStyle,
horizontal = _this$props.horizontal,
onContentSizeChange = _this$props.onContentSizeChange,
refreshControl = _this$props.refreshControl,
stickyHeaderIndices = _this$props.stickyHeaderIndices,
pagingEnabled = _this$props.pagingEnabled,
forwardedRef = _this$props.forwardedRef,
keyboardDismissMode = _this$props.keyboardDismissMode,
onScroll = _this$props.onScroll,
centerContent = _this$props.centerContent,
other = (0, _objectWithoutPropertiesLoose2.default)(_this$props, _excluded);
if (process.env.NODE_ENV !== 'production' && this.props.style) {
var style = _StyleSheet.default.flatten(this.props.style);
var childLayoutProps = ['alignItems', 'justifyContent'].filter(prop => style && style[prop] !== undefined);
(0, _invariant.default)(childLayoutProps.length === 0, "ScrollView child layout (" + JSON.stringify(childLayoutProps) + ") " + 'must be applied through the contentContainerStyle prop.');
}
var contentSizeChangeProps = {};
if (onContentSizeChange) {
contentSizeChangeProps = {
onLayout: this._handleContentOnLayout
};
}
var hasStickyHeaderIndices = !horizontal && Array.isArray(stickyHeaderIndices);
var children = hasStickyHeaderIndices || pagingEnabled ? _react.default.Children.map(this.props.children, (child, i) => {
var isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1;
if (child != null && (isSticky || pagingEnabled)) {
return /*#__PURE__*/_react.default.createElement(_View.default, {
style: [isSticky && styles.stickyHeader, pagingEnabled && styles.pagingEnabledChild]
}, child);
} else {
return child;
}
}) : this.props.children;
var contentContainer = /*#__PURE__*/_react.default.createElement(_View.default, (0, _extends2.default)({}, contentSizeChangeProps, {
children: children,
collapsable: false,
ref: this._setInnerViewRef,
style: [horizontal && styles.contentContainerHorizontal, centerContent && styles.contentContainerCenterContent, contentContainerStyle]
}));
var baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;
var pagingEnabledStyle = horizontal ? styles.pagingEnabledHorizontal : styles.pagingEnabledVertical;
var props = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, other), {}, {
style: [baseStyle, pagingEnabled && pagingEnabledStyle, this.props.style],
onTouchStart: this.scrollResponderHandleTouchStart,
onTouchMove: this.scrollResponderHandleTouchMove,
onTouchEnd: this.scrollResponderHandleTouchEnd,
onScrollBeginDrag: this.scrollResponderHandleScrollBeginDrag,
onScrollEndDrag: this.scrollResponderHandleScrollEndDrag,
onMomentumScrollBegin: this.scrollResponderHandleMomentumScrollBegin,
onMomentumScrollEnd: this.scrollResponderHandleMomentumScrollEnd,
onStartShouldSetResponder: this.scrollResponderHandleStartShouldSetResponder,
onStartShouldSetResponderCapture: this.scrollResponderHandleStartShouldSetResponderCapture,
onScrollShouldSetResponder: this.scrollResponderHandleScrollShouldSetResponder,
onScroll: this._handleScroll,
onResponderGrant: this.scrollResponderHandleResponderGrant,
onResponderTerminationRequest: this.scrollResponderHandleTerminationRequest,
onResponderTerminate: this.scrollResponderHandleTerminate,
onResponderRelease: this.scrollResponderHandleResponderRelease,
onResponderReject: this.scrollResponderHandleResponderReject
});
var ScrollViewClass = _ScrollViewBase.default;
(0, _invariant.default)(ScrollViewClass !== undefined, 'ScrollViewClass must not be undefined');
var scrollView = /*#__PURE__*/_react.default.createElement(ScrollViewClass, (0, _extends2.default)({}, props, {
ref: this._setScrollNodeRef
}), contentContainer);
if (refreshControl) {
return /*#__PURE__*/_react.default.cloneElement(refreshControl, {
style: props.style
}, scrollView);
}
return scrollView;
}
}
var commonStyle = {
flexGrow: 1,
flexShrink: 1,
// Enable hardware compositing in modern browsers.
// Creates a new layer with its own backing surface that can significantly
// improve scroll performance.
transform: 'translateZ(0)',
// iOS native scrolling
WebkitOverflowScrolling: 'touch'
};
var styles = _StyleSheet.default.create({
baseVertical: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commonStyle), {}, {
flexDirection: 'column',
overflowX: 'hidden',
overflowY: 'auto'
}),
baseHorizontal: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commonStyle), {}, {
flexDirection: 'row',
overflowX: 'auto',
overflowY: 'hidden'
}),
contentContainerHorizontal: {
flexDirection: 'row'
},
contentContainerCenterContent: {
justifyContent: 'center',
flexGrow: 1
},
stickyHeader: {
position: 'sticky',
top: 0,
zIndex: 10
},
pagingEnabledHorizontal: {
scrollSnapType: 'x mandatory'
},
pagingEnabledVertical: {
scrollSnapType: 'y mandatory'
},
pagingEnabledChild: {
scrollSnapAlign: 'start'
}
});
var ForwardedScrollView = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) => {
return /*#__PURE__*/_react.default.createElement(ScrollView, (0, _extends2.default)({}, props, {
forwardedRef: forwardedRef
}));
});
ForwardedScrollView.displayName = 'ScrollView';
var _default = exports.default = ForwardedScrollView;
module.exports = exports.default;
@@ -0,0 +1,18 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _SectionList = _interopRequireDefault(require("../../vendor/react-native/SectionList"));
var _default = exports.default = _SectionList.default;
module.exports = exports.default;
@@ -0,0 +1,53 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
class Share {
static share(content, options) {
if (options === void 0) {
options = {};
}
(0, _invariant.default)(typeof content === 'object' && content !== null, 'Content to share must be a valid object');
(0, _invariant.default)(typeof content.url === 'string' || typeof content.message === 'string', 'At least one of URL and message is required');
(0, _invariant.default)(typeof options === 'object' && options !== null, 'Options must be a valid object');
(0, _invariant.default)(!content.title || typeof content.title === 'string', 'Invalid title: title should be a string.');
if (window.navigator.share !== undefined) {
return window.navigator.share({
title: content.title,
text: content.message,
url: content.url
});
} else {
return Promise.reject(new Error('Share is not supported in this browser'));
}
}
/**
* The content was successfully shared.
*/
static get sharedAction() {
return 'sharedAction';
}
/**
* The dialog has been dismissed.
* @platform ios
*/
static get dismissedAction() {
return 'dismissedAction';
}
}
var _default = exports.default = Share;
module.exports = exports.default;
@@ -0,0 +1,24 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var emptyFunction = () => {};
function StatusBar() {
return null;
}
StatusBar.setBackgroundColor = emptyFunction;
StatusBar.setBarStyle = emptyFunction;
StatusBar.setHidden = emptyFunction;
StatusBar.setNetworkActivityIndicatorVisible = emptyFunction;
StatusBar.setTranslucent = emptyFunction;
var _default = exports.default = StatusBar;
module.exports = exports.default;
@@ -0,0 +1,184 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _normalizeValueWithProperty = _interopRequireDefault(require("./normalizeValueWithProperty"));
var _canUseDom = _interopRequireDefault(require("../../../modules/canUseDom"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
/**
* The browser implements the CSS cascade, where the order of properties is a
* factor in determining which styles to paint. React Native is different. It
* gives giving precedence to the more specific style property. For example,
* the value of `paddingTop` takes precedence over that of `padding`.
*
* This module creates mutally exclusive style declarations by expanding all of
* React Native's supported shortform properties (e.g. `padding`) to their
* longfrom equivalents.
*/
var emptyObject = {};
var supportsCSS3TextDecoration = !_canUseDom.default || window.CSS != null && window.CSS.supports != null && (window.CSS.supports('text-decoration-line', 'none') || window.CSS.supports('-webkit-text-decoration-line', 'none'));
var MONOSPACE_FONT_STACK = 'monospace,monospace';
var SYSTEM_FONT_STACK = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif';
var STYLE_SHORT_FORM_EXPANSIONS = {
borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],
borderBlockColor: ['borderTopColor', 'borderBottomColor'],
borderInlineColor: ['borderRightColor', 'borderLeftColor'],
borderRadius: ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius'],
borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],
borderBlockStyle: ['borderTopStyle', 'borderBottomStyle'],
borderInlineStyle: ['borderRightStyle', 'borderLeftStyle'],
borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],
borderBlockWidth: ['borderTopWidth', 'borderBottomWidth'],
borderInlineWidth: ['borderRightWidth', 'borderLeftWidth'],
insetBlock: ['top', 'bottom'],
insetInline: ['left', 'right'],
marginBlock: ['marginTop', 'marginBottom'],
marginInline: ['marginRight', 'marginLeft'],
paddingBlock: ['paddingTop', 'paddingBottom'],
paddingInline: ['paddingRight', 'paddingLeft'],
overflow: ['overflowX', 'overflowY'],
overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],
borderBlockStartColor: ['borderTopColor'],
borderBlockStartStyle: ['borderTopStyle'],
borderBlockStartWidth: ['borderTopWidth'],
borderBlockEndColor: ['borderBottomColor'],
borderBlockEndStyle: ['borderBottomStyle'],
borderBlockEndWidth: ['borderBottomWidth'],
//borderInlineStartColor: ['borderLeftColor'],
//borderInlineStartStyle: ['borderLeftStyle'],
//borderInlineStartWidth: ['borderLeftWidth'],
//borderInlineEndColor: ['borderRightColor'],
//borderInlineEndStyle: ['borderRightStyle'],
//borderInlineEndWidth: ['borderRightWidth'],
borderEndStartRadius: ['borderBottomLeftRadius'],
borderEndEndRadius: ['borderBottomRightRadius'],
borderStartStartRadius: ['borderTopLeftRadius'],
borderStartEndRadius: ['borderTopRightRadius'],
insetBlockEnd: ['bottom'],
insetBlockStart: ['top'],
//insetInlineEnd: ['right'],
//insetInlineStart: ['left'],
marginBlockStart: ['marginTop'],
marginBlockEnd: ['marginBottom'],
//marginInlineStart: ['marginLeft'],
//marginInlineEnd: ['marginRight'],
paddingBlockStart: ['paddingTop'],
paddingBlockEnd: ['paddingBottom']
//paddingInlineStart: ['marginLeft'],
//paddingInlineEnd: ['marginRight'],
};
/**
* Reducer
*/
var createReactDOMStyle = (style, isInline) => {
if (!style) {
return emptyObject;
}
var resolvedStyle = {};
var _loop = function _loop() {
var value = style[prop];
if (
// Ignore everything with a null value
value == null) {
return "continue";
}
if (prop === 'backgroundClip') {
// TODO: remove once this issue is fixed
// https://github.com/rofrischmann/inline-style-prefixer/issues/159
if (value === 'text') {
resolvedStyle.backgroundClip = value;
resolvedStyle.WebkitBackgroundClip = value;
}
} else if (prop === 'flex') {
if (value === -1) {
resolvedStyle.flexGrow = 0;
resolvedStyle.flexShrink = 1;
resolvedStyle.flexBasis = 'auto';
} else {
resolvedStyle.flex = value;
}
} else if (prop === 'font') {
resolvedStyle[prop] = value.replace('System', SYSTEM_FONT_STACK);
} else if (prop === 'fontFamily') {
if (value.indexOf('System') > -1) {
var stack = value.split(/,\s*/);
stack[stack.indexOf('System')] = SYSTEM_FONT_STACK;
resolvedStyle[prop] = stack.join(',');
} else if (value === 'monospace') {
resolvedStyle[prop] = MONOSPACE_FONT_STACK;
} else {
resolvedStyle[prop] = value;
}
} else if (prop === 'textDecorationLine') {
// use 'text-decoration' for browsers that only support CSS2
// text-decoration (e.g., IE, Edge)
if (!supportsCSS3TextDecoration) {
resolvedStyle.textDecoration = value;
} else {
resolvedStyle.textDecorationLine = value;
}
} else if (prop === 'writingDirection') {
resolvedStyle.direction = value;
} else {
var _value = (0, _normalizeValueWithProperty.default)(style[prop], prop);
var longFormProperties = STYLE_SHORT_FORM_EXPANSIONS[prop];
if (isInline && prop === 'inset') {
if (style.insetInline == null) {
resolvedStyle.left = _value;
resolvedStyle.right = _value;
}
if (style.insetBlock == null) {
resolvedStyle.top = _value;
resolvedStyle.bottom = _value;
}
} else if (isInline && prop === 'margin') {
if (style.marginInline == null) {
resolvedStyle.marginLeft = _value;
resolvedStyle.marginRight = _value;
}
if (style.marginBlock == null) {
resolvedStyle.marginTop = _value;
resolvedStyle.marginBottom = _value;
}
} else if (isInline && prop === 'padding') {
if (style.paddingInline == null) {
resolvedStyle.paddingLeft = _value;
resolvedStyle.paddingRight = _value;
}
if (style.paddingBlock == null) {
resolvedStyle.paddingTop = _value;
resolvedStyle.paddingBottom = _value;
}
} else if (longFormProperties) {
longFormProperties.forEach((longForm, i) => {
// The value of any longform property in the original styles takes
// precedence over the shortform's value.
if (style[longForm] == null) {
resolvedStyle[longForm] = _value;
}
});
} else {
resolvedStyle[prop] = _value;
}
}
};
for (var prop in style) {
var _ret = _loop();
if (_ret === "continue") continue;
}
return resolvedStyle;
};
var _default = exports.default = createReactDOMStyle;
module.exports = exports.default;
@@ -0,0 +1,52 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/* eslint-disable */
/**
* JS Implementation of MurmurHash2
*
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
* @see http://github.com/garycourt/murmurhash-js
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
* @see http://sites.google.com/site/murmurhash/
*
* @param {string} str ASCII only
* @param {number} seed Positive integer only
* @return {number} 32-bit positive integer hash
*
*
*/
function murmurhash2_32_gc(str, seed) {
var l = str.length,
h = seed ^ l,
i = 0,
k;
while (l >= 4) {
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
k ^= k >>> 24;
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k;
l -= 4;
++i;
}
switch (l) {
case 3:
h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
case 2:
h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
case 1:
h ^= str.charCodeAt(i) & 0xff;
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
}
h ^= h >>> 13;
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
h ^= h >>> 15;
return h >>> 0;
}
var hash = str => murmurhash2_32_gc(str, 1).toString(36);
var _default = exports.default = hash;
module.exports = exports.default;
@@ -0,0 +1,28 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var uppercasePattern = /[A-Z]/g;
var msPattern = /^ms-/;
var cache = {};
function toHyphenLower(match) {
return '-' + match.toLowerCase();
}
function hyphenateStyleName(name) {
if (name in cache) {
return cache[name];
}
var hName = name.replace(uppercasePattern, toHyphenLower);
return cache[name] = msPattern.test(hName) ? '-' + hName : hName;
}
var _default = exports.default = hyphenateStyleName;
module.exports = exports.default;
@@ -0,0 +1,484 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.atomic = atomic;
exports.classic = classic;
exports.inline = inline;
exports.stringifyValueWithProperty = stringifyValueWithProperty;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _createReactDOMStyle = _interopRequireDefault(require("./createReactDOMStyle"));
var _hash = _interopRequireDefault(require("./hash"));
var _hyphenateStyleName = _interopRequireDefault(require("./hyphenateStyleName"));
var _normalizeValueWithProperty = _interopRequireDefault(require("./normalizeValueWithProperty"));
var _prefixStyles = _interopRequireDefault(require("../../../modules/prefixStyles"));
var _excluded = ["animationKeyframes"];
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var cache = new Map();
var emptyObject = {};
var classicGroup = 1;
var atomicGroup = 3;
var customGroup = {
borderColor: 2,
borderRadius: 2,
borderStyle: 2,
borderWidth: 2,
display: 2,
flex: 2,
inset: 2,
margin: 2,
overflow: 2,
overscrollBehavior: 2,
padding: 2,
insetBlock: 2.1,
insetInline: 2.1,
marginInline: 2.1,
marginBlock: 2.1,
paddingInline: 2.1,
paddingBlock: 2.1,
borderBlockStartColor: 2.2,
borderBlockStartStyle: 2.2,
borderBlockStartWidth: 2.2,
borderBlockEndColor: 2.2,
borderBlockEndStyle: 2.2,
borderBlockEndWidth: 2.2,
borderInlineStartColor: 2.2,
borderInlineStartStyle: 2.2,
borderInlineStartWidth: 2.2,
borderInlineEndColor: 2.2,
borderInlineEndStyle: 2.2,
borderInlineEndWidth: 2.2,
borderEndStartRadius: 2.2,
borderEndEndRadius: 2.2,
borderStartStartRadius: 2.2,
borderStartEndRadius: 2.2,
insetBlockEnd: 2.2,
insetBlockStart: 2.2,
insetInlineEnd: 2.2,
insetInlineStart: 2.2,
marginBlockStart: 2.2,
marginBlockEnd: 2.2,
marginInlineStart: 2.2,
marginInlineEnd: 2.2,
paddingBlockStart: 2.2,
paddingBlockEnd: 2.2,
paddingInlineStart: 2.2,
paddingInlineEnd: 2.2
};
var borderTopLeftRadius = 'borderTopLeftRadius';
var borderTopRightRadius = 'borderTopRightRadius';
var borderBottomLeftRadius = 'borderBottomLeftRadius';
var borderBottomRightRadius = 'borderBottomRightRadius';
var borderLeftColor = 'borderLeftColor';
var borderLeftStyle = 'borderLeftStyle';
var borderLeftWidth = 'borderLeftWidth';
var borderRightColor = 'borderRightColor';
var borderRightStyle = 'borderRightStyle';
var borderRightWidth = 'borderRightWidth';
var right = 'right';
var marginLeft = 'marginLeft';
var marginRight = 'marginRight';
var paddingLeft = 'paddingLeft';
var paddingRight = 'paddingRight';
var left = 'left';
// Map of LTR property names to their BiDi equivalent.
var PROPERTIES_FLIP = {
[borderTopLeftRadius]: borderTopRightRadius,
[borderTopRightRadius]: borderTopLeftRadius,
[borderBottomLeftRadius]: borderBottomRightRadius,
[borderBottomRightRadius]: borderBottomLeftRadius,
[borderLeftColor]: borderRightColor,
[borderLeftStyle]: borderRightStyle,
[borderLeftWidth]: borderRightWidth,
[borderRightColor]: borderLeftColor,
[borderRightStyle]: borderLeftStyle,
[borderRightWidth]: borderLeftWidth,
[left]: right,
[marginLeft]: marginRight,
[marginRight]: marginLeft,
[paddingLeft]: paddingRight,
[paddingRight]: paddingLeft,
[right]: left
};
// Map of I18N property names to their LTR equivalent.
var PROPERTIES_I18N = {
borderStartStartRadius: borderTopLeftRadius,
borderStartEndRadius: borderTopRightRadius,
borderEndStartRadius: borderBottomLeftRadius,
borderEndEndRadius: borderBottomRightRadius,
borderInlineStartColor: borderLeftColor,
borderInlineStartStyle: borderLeftStyle,
borderInlineStartWidth: borderLeftWidth,
borderInlineEndColor: borderRightColor,
borderInlineEndStyle: borderRightStyle,
borderInlineEndWidth: borderRightWidth,
insetInlineEnd: right,
insetInlineStart: left,
marginInlineStart: marginLeft,
marginInlineEnd: marginRight,
paddingInlineStart: paddingLeft,
paddingInlineEnd: paddingRight
};
var PROPERTIES_VALUE = ['clear', 'float', 'textAlign'];
function atomic(style) {
var compiledStyle = {
$$css: true
};
var compiledRules = [];
function atomicCompile(srcProp, prop, value) {
var valueString = stringifyValueWithProperty(value, prop);
var cacheKey = prop + valueString;
var cachedResult = cache.get(cacheKey);
var identifier;
if (cachedResult != null) {
identifier = cachedResult[0];
compiledRules.push(cachedResult[1]);
} else {
var v = srcProp !== prop ? cacheKey : valueString;
identifier = createIdentifier('r', srcProp, v);
var order = customGroup[srcProp] || atomicGroup;
var rules = createAtomicRules(identifier, prop, value);
var orderedRules = [rules, order];
compiledRules.push(orderedRules);
cache.set(cacheKey, [identifier, orderedRules]);
}
return identifier;
}
Object.keys(style).sort().forEach(srcProp => {
var value = style[srcProp];
if (value != null) {
var localizeableValue;
// BiDi flip values
if (PROPERTIES_VALUE.indexOf(srcProp) > -1) {
var _left = atomicCompile(srcProp, srcProp, 'left');
var _right = atomicCompile(srcProp, srcProp, 'right');
if (value === 'start') {
localizeableValue = [_left, _right];
} else if (value === 'end') {
localizeableValue = [_right, _left];
}
}
// BiDi flip properties
var propPolyfill = PROPERTIES_I18N[srcProp];
if (propPolyfill != null) {
var ltr = atomicCompile(srcProp, propPolyfill, value);
var rtl = atomicCompile(srcProp, PROPERTIES_FLIP[propPolyfill], value);
localizeableValue = [ltr, rtl];
}
// BiDi flip transitionProperty value
if (srcProp === 'transitionProperty') {
var values = Array.isArray(value) ? value : [value];
var polyfillIndices = [];
for (var i = 0; i < values.length; i++) {
var val = values[i];
if (typeof val === 'string' && PROPERTIES_I18N[val] != null) {
polyfillIndices.push(i);
}
}
if (polyfillIndices.length > 0) {
var ltrPolyfillValues = [...values];
var rtlPolyfillValues = [...values];
polyfillIndices.forEach(i => {
var ltrVal = ltrPolyfillValues[i];
if (typeof ltrVal === 'string') {
var ltrPolyfill = PROPERTIES_I18N[ltrVal];
var rtlPolyfill = PROPERTIES_FLIP[ltrPolyfill];
ltrPolyfillValues[i] = ltrPolyfill;
rtlPolyfillValues[i] = rtlPolyfill;
var _ltr = atomicCompile(srcProp, srcProp, ltrPolyfillValues);
var _rtl = atomicCompile(srcProp, srcProp, rtlPolyfillValues);
localizeableValue = [_ltr, _rtl];
}
});
}
}
if (localizeableValue == null) {
localizeableValue = atomicCompile(srcProp, srcProp, value);
} else {
compiledStyle['$$css$localize'] = true;
}
compiledStyle[srcProp] = localizeableValue;
}
});
return [compiledStyle, compiledRules];
}
/**
* Compile simple style object to classic CSS rules.
* No support for 'placeholderTextColor', 'scrollbarWidth', or 'pointerEvents'.
*/
function classic(style, name) {
var compiledStyle = {
$$css: true
};
var compiledRules = [];
var animationKeyframes = style.animationKeyframes,
rest = (0, _objectWithoutPropertiesLoose2.default)(style, _excluded);
var identifier = createIdentifier('css', name, JSON.stringify(style));
var selector = "." + identifier;
var animationName;
if (animationKeyframes != null) {
var _processKeyframesValu = processKeyframesValue(animationKeyframes),
animationNames = _processKeyframesValu[0],
keyframesRules = _processKeyframesValu[1];
animationName = animationNames.join(',');
compiledRules.push(...keyframesRules);
}
var block = createDeclarationBlock((0, _objectSpread2.default)((0, _objectSpread2.default)({}, rest), {}, {
animationName
}));
compiledRules.push("" + selector + block);
compiledStyle[identifier] = identifier;
return [compiledStyle, [[compiledRules, classicGroup]]];
}
/**
* Compile simple style object to inline DOM styles.
* No support for 'animationKeyframes', 'placeholderTextColor', 'scrollbarWidth', or 'pointerEvents'.
*/
function inline(originalStyle, isRTL) {
var style = originalStyle || emptyObject;
var frozenProps = {};
var nextStyle = {};
var _loop = function _loop() {
var originalValue = style[originalProp];
var prop = originalProp;
var value = originalValue;
if (!Object.prototype.hasOwnProperty.call(style, originalProp) || originalValue == null) {
return "continue";
}
// BiDi flip values
if (PROPERTIES_VALUE.indexOf(originalProp) > -1) {
if (originalValue === 'start') {
value = isRTL ? 'right' : 'left';
} else if (originalValue === 'end') {
value = isRTL ? 'left' : 'right';
}
}
// BiDi flip properties
var propPolyfill = PROPERTIES_I18N[originalProp];
if (propPolyfill != null) {
prop = isRTL ? PROPERTIES_FLIP[propPolyfill] : propPolyfill;
}
// BiDi flip transitionProperty value
if (originalProp === 'transitionProperty') {
// $FlowFixMe
var originalValues = Array.isArray(originalValue) ? originalValue : [originalValue];
originalValues.forEach((val, i) => {
if (typeof val === 'string') {
var valuePolyfill = PROPERTIES_I18N[val];
if (valuePolyfill != null) {
originalValues[i] = isRTL ? PROPERTIES_FLIP[valuePolyfill] : valuePolyfill;
value = originalValues.join(' ');
}
}
});
}
// Create finalized style
if (!frozenProps[prop]) {
nextStyle[prop] = value;
}
if (prop === originalProp) {
frozenProps[prop] = true;
}
// if (PROPERTIES_I18N.hasOwnProperty(originalProp)) {
// frozenProps[prop] = true;
//}
};
for (var originalProp in style) {
var _ret = _loop();
if (_ret === "continue") continue;
}
return (0, _createReactDOMStyle.default)(nextStyle, true);
}
/**
* Create a value string that normalizes different input values with a common
* output.
*/
function stringifyValueWithProperty(value, property) {
// e.g., 0 => '0px', 'black' => 'rgba(0,0,0,1)'
var normalizedValue = (0, _normalizeValueWithProperty.default)(value, property);
return typeof normalizedValue !== 'string' ? JSON.stringify(normalizedValue || '') : normalizedValue;
}
/**
* Create the Atomic CSS rules needed for a given StyleSheet rule.
* Translates StyleSheet declarations to CSS.
*/
function createAtomicRules(identifier, property, value) {
var rules = [];
var selector = "." + identifier;
// Handle non-standard properties and object values that require multiple
// CSS rules to be created.
switch (property) {
case 'animationKeyframes':
{
var _processKeyframesValu2 = processKeyframesValue(value),
animationNames = _processKeyframesValu2[0],
keyframesRules = _processKeyframesValu2[1];
var block = createDeclarationBlock({
animationName: animationNames.join(',')
});
rules.push("" + selector + block, ...keyframesRules);
break;
}
// Equivalent to using '::placeholder'
case 'placeholderTextColor':
{
var _block = createDeclarationBlock({
color: value,
opacity: 1
});
rules.push(selector + "::-webkit-input-placeholder" + _block, selector + "::-moz-placeholder" + _block, selector + ":-ms-input-placeholder" + _block, selector + "::placeholder" + _block);
break;
}
// Polyfill for additional 'pointer-events' values
// See d13f78622b233a0afc0c7a200c0a0792c8ca9e58
// See https://reactnative.dev/docs/view#pointerevents
case 'pointerEvents':
{
var finalValue = value;
if (value === 'auto') {
finalValue = 'auto!important';
} else if (value === 'none') {
finalValue = 'none!important';
var _block2 = createDeclarationBlock({
pointerEvents: 'none'
});
rules.push(selector + ">* " + _block2);
} else if (value === 'box-none') {
finalValue = 'none!important';
var _block3 = createDeclarationBlock({
pointerEvents: 'auto'
});
rules.push(selector + ">* " + _block3);
} else if (value === 'box-only') {
finalValue = 'auto!important';
var _block4 = createDeclarationBlock({
pointerEvents: 'none'
});
rules.push(selector + ">* " + _block4);
}
var _block5 = createDeclarationBlock({
pointerEvents: finalValue
});
rules.push("" + selector + _block5);
break;
}
// Polyfill for draft spec
// https://drafts.csswg.org/css-scrollbars-1/
case 'scrollbarWidth':
{
if (value === 'none') {
rules.push(selector + "::-webkit-scrollbar{display:none}");
}
var _block6 = createDeclarationBlock({
scrollbarWidth: value
});
rules.push("" + selector + _block6);
break;
}
default:
{
var _block7 = createDeclarationBlock({
[property]: value
});
rules.push("" + selector + _block7);
break;
}
}
return rules;
}
/**
* Creates a CSS declaration block from a StyleSheet object.
*/
function createDeclarationBlock(style) {
var domStyle = (0, _prefixStyles.default)((0, _createReactDOMStyle.default)(style));
var declarationsString = Object.keys(domStyle).map(property => {
var value = domStyle[property];
var prop = (0, _hyphenateStyleName.default)(property);
// The prefixer may return an array of values:
// { display: [ '-webkit-flex', 'flex' ] }
// to represent "fallback" declarations
// { display: -webkit-flex; display: flex; }
if (Array.isArray(value)) {
return value.map(v => prop + ":" + v).join(';');
} else {
return prop + ":" + value;
}
})
// Once properties are hyphenated, this will put the vendor
// prefixed and short-form properties first in the list.
.sort().join(';');
return "{" + declarationsString + ";}";
}
/**
* An identifier is associated with a unique set of styles.
*/
function createIdentifier(prefix, name, key) {
var hashedString = (0, _hash.default)(name + key);
return process.env.NODE_ENV !== 'production' ? prefix + "-" + name + "-" + hashedString : prefix + "-" + hashedString;
}
/**
* Create individual CSS keyframes rules.
*/
function createKeyframes(keyframes) {
var prefixes = ['-webkit-', ''];
var identifier = createIdentifier('r', 'animation', JSON.stringify(keyframes));
var steps = '{' + Object.keys(keyframes).map(stepName => {
var rule = keyframes[stepName];
var block = createDeclarationBlock(rule);
return "" + stepName + block;
}).join('') + '}';
var rules = prefixes.map(prefix => {
return "@" + prefix + "keyframes " + identifier + steps;
});
return [identifier, rules];
}
/**
* Create CSS keyframes rules and names from a StyleSheet keyframes object.
*/
function processKeyframesValue(keyframesValue) {
if (typeof keyframesValue === 'number') {
throw new Error("Invalid CSS keyframes type: " + typeof keyframesValue);
}
var animationNames = [];
var rules = [];
var value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue];
value.forEach(keyframes => {
if (typeof keyframes === 'string') {
// Support external animation libraries (identifiers only)
animationNames.push(keyframes);
} else {
// Create rules for each of the keyframes
var _createKeyframes = createKeyframes(keyframes),
identifier = _createKeyframes[0],
keyframesRules = _createKeyframes[1];
animationNames.push(identifier);
rules.push(...keyframesRules);
}
});
return [animationNames, rules];
}
@@ -0,0 +1,36 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _isWebColor = _interopRequireDefault(require("../../../modules/isWebColor"));
var _processColor = _interopRequireDefault(require("../../../exports/processColor"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var normalizeColor = function normalizeColor(color, opacity) {
if (opacity === void 0) {
opacity = 1;
}
if (color == null) return;
if (typeof color === 'string' && (0, _isWebColor.default)(color)) {
return color;
}
var colorInt = (0, _processColor.default)(color);
if (colorInt != null) {
var r = colorInt >> 16 & 255;
var g = colorInt >> 8 & 255;
var b = colorInt & 255;
var a = (colorInt >> 24 & 255) / 255;
var alpha = (a * opacity).toFixed(2);
return "rgba(" + r + "," + g + "," + b + "," + alpha + ")";
}
};
var _default = exports.default = normalizeColor;
module.exports = exports.default;
@@ -0,0 +1,38 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = normalizeValueWithProperty;
var _unitlessNumbers = _interopRequireDefault(require("./unitlessNumbers"));
var _normalizeColor = _interopRequireDefault(require("./normalizeColor"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var colorProps = {
backgroundColor: true,
borderColor: true,
borderTopColor: true,
borderRightColor: true,
borderBottomColor: true,
borderLeftColor: true,
color: true,
shadowColor: true,
textDecorationColor: true,
textShadowColor: true
};
function normalizeValueWithProperty(value, property) {
var returnValue = value;
if ((property == null || !_unitlessNumbers.default[property]) && typeof value === 'number') {
returnValue = value + "px";
} else if (property != null && colorProps[property]) {
returnValue = (0, _normalizeColor.default)(value);
}
return returnValue;
}
module.exports = exports.default;
@@ -0,0 +1,38 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _normalizeColor = _interopRequireDefault(require("./normalizeColor"));
var _normalizeValueWithProperty = _interopRequireDefault(require("./normalizeValueWithProperty"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var defaultOffset = {
height: 0,
width: 0
};
var resolveShadowValue = style => {
var shadowColor = style.shadowColor,
shadowOffset = style.shadowOffset,
shadowOpacity = style.shadowOpacity,
shadowRadius = style.shadowRadius;
var _ref = shadowOffset || defaultOffset,
height = _ref.height,
width = _ref.width;
var offsetX = (0, _normalizeValueWithProperty.default)(width);
var offsetY = (0, _normalizeValueWithProperty.default)(height);
var blurRadius = (0, _normalizeValueWithProperty.default)(shadowRadius || 0);
var color = (0, _normalizeColor.default)(shadowColor || 'black', shadowOpacity);
if (color != null && offsetX != null && offsetY != null && blurRadius != null) {
return offsetX + " " + offsetY + " " + blurRadius + " " + color;
}
};
var _default = exports.default = resolveShadowValue;
module.exports = exports.default;
@@ -0,0 +1,80 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var unitlessNumbers = {
animationIterationCount: true,
aspectRatio: true,
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
flex: true,
flexGrow: true,
flexOrder: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
fontWeight: true,
gridRow: true,
gridRowEnd: true,
gridRowGap: true,
gridRowStart: true,
gridColumn: true,
gridColumnEnd: true,
gridColumnGap: true,
gridColumnStart: true,
lineClamp: true,
opacity: true,
order: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
// SVG-related
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true,
// transform types
scale: true,
scaleX: true,
scaleY: true,
scaleZ: true,
// RN properties
shadowOpacity: true
};
/**
* Support style names that may come passed in prefixed by adding permutations
* of vendor prefixes.
*/
var prefixes = ['ms', 'Moz', 'O', 'Webkit'];
var prefixKey = (prefix, key) => {
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
};
Object.keys(unitlessNumbers).forEach(prop => {
prefixes.forEach(prefix => {
unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop];
});
});
var _default = exports.default = unitlessNumbers;
module.exports = exports.default;
@@ -0,0 +1,42 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = createCSSStyleSheet;
var _canUseDom = _interopRequireDefault(require("../../../modules/canUseDom"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
// $FlowFixMe: HTMLStyleElement is incorrectly typed - https://github.com/facebook/flow/issues/2696
function createCSSStyleSheet(id, rootNode, textContent) {
if (_canUseDom.default) {
var root = rootNode != null ? rootNode : document;
var element = root.getElementById(id);
if (element == null) {
element = document.createElement('style');
element.setAttribute('id', id);
if (typeof textContent === 'string') {
element.appendChild(document.createTextNode(textContent));
}
if (root instanceof ShadowRoot) {
root.insertBefore(element, root.firstChild);
} else {
var head = root.head;
if (head) {
head.insertBefore(element, head.firstChild);
}
}
}
// $FlowFixMe: HTMLElement is incorrectly typed
return element.sheet;
} else {
return null;
}
}
module.exports = exports.default;
@@ -0,0 +1,168 @@
"use strict";
exports.__esModule = true;
exports.default = createOrderedCSSStyleSheet;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var slice = Array.prototype.slice;
/**
* Order-based insertion of CSS.
*
* Each rule is associated with a numerically defined group.
* Groups are ordered within the style sheet according to their number, with the
* lowest first.
*
* Groups are implemented using marker rules. The selector of the first rule of
* each group is used only to encode the group number for hydration. An
* alternative implementation could rely on CSSMediaRule, allowing groups to be
* treated as a sub-sheet, but the Edge implementation of CSSMediaRule is
* broken.
* https://developer.mozilla.org/en-US/docs/Web/API/CSSMediaRule
* https://gist.github.com/necolas/aa0c37846ad6bd3b05b727b959e82674
*/
function createOrderedCSSStyleSheet(sheet) {
var groups = {};
var selectors = {};
/**
* Hydrate approximate record from any existing rules in the sheet.
*/
if (sheet != null) {
var group;
slice.call(sheet.cssRules).forEach((cssRule, i) => {
var cssText = cssRule.cssText;
// Create record of existing selectors and rules
if (cssText.indexOf('stylesheet-group') > -1) {
group = decodeGroupRule(cssRule);
groups[group] = {
start: i,
rules: [cssText]
};
} else {
var selectorText = getSelectorText(cssText);
if (selectorText != null) {
selectors[selectorText] = true;
groups[group].rules.push(cssText);
}
}
});
}
function sheetInsert(sheet, group, text) {
var orderedGroups = getOrderedGroups(groups);
var groupIndex = orderedGroups.indexOf(group);
var nextGroupIndex = groupIndex + 1;
var nextGroup = orderedGroups[nextGroupIndex];
// Insert rule before the next group, or at the end of the stylesheet
var position = nextGroup != null && groups[nextGroup].start != null ? groups[nextGroup].start : sheet.cssRules.length;
var isInserted = insertRuleAt(sheet, text, position);
if (isInserted) {
// Set the starting index of the new group
if (groups[group].start == null) {
groups[group].start = position;
}
// Increment the starting index of all subsequent groups
for (var i = nextGroupIndex; i < orderedGroups.length; i += 1) {
var groupNumber = orderedGroups[i];
var previousStart = groups[groupNumber].start || 0;
groups[groupNumber].start = previousStart + 1;
}
}
return isInserted;
}
var OrderedCSSStyleSheet = {
/**
* The textContent of the style sheet.
*/
getTextContent() {
return getOrderedGroups(groups).map(group => {
var rules = groups[group].rules;
// Sorting provides deterministic order of styles in group for
// build-time extraction of the style sheet.
var marker = rules.shift();
rules.sort();
rules.unshift(marker);
return rules.join('\n');
}).join('\n');
},
/**
* Insert a rule into the style sheet
*/
insert(cssText, groupValue) {
var group = Number(groupValue);
// Create a new group.
if (groups[group] == null) {
var markerRule = encodeGroupRule(group);
// Create the internal record.
groups[group] = {
start: null,
rules: [markerRule]
};
// Update CSSOM.
if (sheet != null) {
sheetInsert(sheet, group, markerRule);
}
}
// selectorText is more reliable than cssText for insertion checks. The
// browser excludes vendor-prefixed properties and rewrites certain values
// making cssText more likely to be different from what was inserted.
var selectorText = getSelectorText(cssText);
if (selectorText != null && selectors[selectorText] == null) {
// Update the internal records.
selectors[selectorText] = true;
groups[group].rules.push(cssText);
// Update CSSOM.
if (sheet != null) {
var isInserted = sheetInsert(sheet, group, cssText);
if (!isInserted) {
// Revert internal record change if a rule was rejected (e.g.,
// unrecognized pseudo-selector)
groups[group].rules.pop();
}
}
}
}
};
return OrderedCSSStyleSheet;
}
/**
* Helper functions
*/
function encodeGroupRule(group) {
return "[stylesheet-group=\"" + group + "\"]{}";
}
var groupPattern = /["']/g;
function decodeGroupRule(cssRule) {
return Number(cssRule.selectorText.split(groupPattern)[1]);
}
function getOrderedGroups(obj) {
return Object.keys(obj).map(Number).sort((a, b) => a > b ? 1 : -1);
}
var selectorPattern = /\s*([,])\s*/g;
function getSelectorText(cssText) {
var selector = cssText.split('{')[0].trim();
return selector !== '' ? selector.replace(selectorPattern, '$1') : null;
}
function insertRuleAt(root, cssText, position) {
try {
// $FlowFixMe: Flow is missing CSSOM types needed to type 'root'.
root.insertRule(cssText, position);
return true;
} catch (e) {
// JSDOM doesn't support `CSSSMediaRule#insertRule`.
// Also ignore errors that occur from attempting to insert vendor-prefixed selectors.
return false;
}
}
module.exports = exports.default;
@@ -0,0 +1,78 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.createSheet = createSheet;
var _canUseDom = _interopRequireDefault(require("../../../modules/canUseDom"));
var _createCSSStyleSheet = _interopRequireDefault(require("./createCSSStyleSheet"));
var _createOrderedCSSStyleSheet = _interopRequireDefault(require("./createOrderedCSSStyleSheet"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var defaultId = 'react-native-stylesheet';
var roots = new WeakMap();
var sheets = [];
var initialRules = [
// minimal top-level reset
'html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);}', 'body{margin:0;}',
// minimal form pseudo-element reset
'button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}', 'input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-webkit-search-results-button,input::-webkit-search-results-decoration{display:none;}'];
function createSheet(root, id) {
if (id === void 0) {
id = defaultId;
}
var sheet;
if (_canUseDom.default) {
var rootNode = root != null ? root.getRootNode() : document;
// Create the initial style sheet
if (sheets.length === 0) {
sheet = (0, _createOrderedCSSStyleSheet.default)((0, _createCSSStyleSheet.default)(id));
initialRules.forEach(rule => {
sheet.insert(rule, 0);
});
roots.set(rootNode, sheets.length);
sheets.push(sheet);
} else {
var index = roots.get(rootNode);
if (index == null) {
var initialSheet = sheets[0];
// If we're creating a new sheet, populate it with existing styles
var textContent = initialSheet != null ? initialSheet.getTextContent() : '';
// Cast rootNode to 'any' because Flow types for getRootNode are wrong
sheet = (0, _createOrderedCSSStyleSheet.default)((0, _createCSSStyleSheet.default)(id, rootNode, textContent));
roots.set(rootNode, sheets.length);
sheets.push(sheet);
} else {
sheet = sheets[index];
}
}
} else {
// Create the initial style sheet
if (sheets.length === 0) {
sheet = (0, _createOrderedCSSStyleSheet.default)((0, _createCSSStyleSheet.default)(id));
initialRules.forEach(rule => {
sheet.insert(rule, 0);
});
sheets.push(sheet);
} else {
sheet = sheets[0];
}
}
return {
getTextContent() {
return sheet.getTextContent();
},
id,
insert(cssText, groupValue) {
sheets.forEach(s => {
s.insert(cssText, groupValue);
});
}
};
}
@@ -0,0 +1,190 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _compiler = require("./compiler");
var _dom = require("./dom");
var _transformLocalizeStyle = require("styleq/transform-localize-style");
var _preprocess = require("./preprocess");
var _styleq = require("styleq");
var _validate = require("./validate");
var _canUseDom = _interopRequireDefault(require("../../modules/canUseDom"));
var _excluded = ["writingDirection"];
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var staticStyleMap = new WeakMap();
var sheet = (0, _dom.createSheet)();
var defaultPreprocessOptions = {
shadow: true,
textShadow: true
};
function customStyleq(styles, options) {
if (options === void 0) {
options = {};
}
var _options = options,
writingDirection = _options.writingDirection,
preprocessOptions = (0, _objectWithoutPropertiesLoose2.default)(_options, _excluded);
var isRTL = writingDirection === 'rtl';
return _styleq.styleq.factory({
transform(style) {
var compiledStyle = staticStyleMap.get(style);
if (compiledStyle != null) {
return (0, _transformLocalizeStyle.localizeStyle)(compiledStyle, isRTL);
}
return (0, _preprocess.preprocess)(style, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultPreprocessOptions), preprocessOptions));
}
})(styles);
}
function insertRules(compiledOrderedRules) {
compiledOrderedRules.forEach(_ref => {
var rules = _ref[0],
order = _ref[1];
if (sheet != null) {
rules.forEach(rule => {
sheet.insert(rule, order);
});
}
});
}
function compileAndInsertAtomic(style) {
var _atomic = (0, _compiler.atomic)((0, _preprocess.preprocess)(style, defaultPreprocessOptions)),
compiledStyle = _atomic[0],
compiledOrderedRules = _atomic[1];
insertRules(compiledOrderedRules);
return compiledStyle;
}
function compileAndInsertReset(style, key) {
var _classic = (0, _compiler.classic)(style, key),
compiledStyle = _classic[0],
compiledOrderedRules = _classic[1];
insertRules(compiledOrderedRules);
return compiledStyle;
}
/* ----- API ----- */
var absoluteFillObject = {
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0
};
var absoluteFill = create({
x: (0, _objectSpread2.default)({}, absoluteFillObject)
}).x;
/**
* create
*/
function create(styles) {
Object.keys(styles).forEach(key => {
var styleObj = styles[key];
// Only compile at runtime if the style is not already compiled
if (styleObj != null && styleObj.$$css !== true) {
var compiledStyles;
if (key.indexOf('$raw') > -1) {
compiledStyles = compileAndInsertReset(styleObj, key.split('$raw')[0]);
} else {
if (process.env.NODE_ENV !== 'production') {
(0, _validate.validate)(styleObj);
styles[key] = Object.freeze(styleObj);
}
compiledStyles = compileAndInsertAtomic(styleObj);
}
staticStyleMap.set(styleObj, compiledStyles);
}
});
return styles;
}
/**
* compose
*/
function compose(style1, style2) {
if (process.env.NODE_ENV !== 'production') {
/* eslint-disable prefer-rest-params */
var len = arguments.length;
if (len > 2) {
var readableStyles = [...arguments].map(a => flatten(a));
throw new Error("StyleSheet.compose() only accepts 2 arguments, received " + len + ": " + JSON.stringify(readableStyles));
}
/* eslint-enable prefer-rest-params */
/*
console.warn(
'StyleSheet.compose(a, b) is deprecated; use array syntax, i.e., [a,b].'
);
*/
}
return [style1, style2];
}
/**
* flatten
*/
function flatten() {
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
styles[_key] = arguments[_key];
}
var flatArray = styles.flat(Infinity);
var result = {};
for (var i = 0; i < flatArray.length; i++) {
var style = flatArray[i];
if (style != null && typeof style === 'object') {
// $FlowFixMe
Object.assign(result, style);
}
}
return result;
}
/**
* getSheet
*/
function getSheet() {
return {
id: sheet.id,
textContent: sheet.getTextContent()
};
}
/**
* resolve
*/
function StyleSheet(styles, options) {
if (options === void 0) {
options = {};
}
var isRTL = options.writingDirection === 'rtl';
var styleProps = customStyleq(styles, options);
if (Array.isArray(styleProps) && styleProps[1] != null) {
styleProps[1] = (0, _compiler.inline)(styleProps[1], isRTL);
}
return styleProps;
}
StyleSheet.absoluteFill = absoluteFill;
StyleSheet.absoluteFillObject = absoluteFillObject;
StyleSheet.create = create;
StyleSheet.compose = compose;
StyleSheet.flatten = flatten;
StyleSheet.getSheet = getSheet;
// `hairlineWidth` is not implemented using screen density as browsers may
// round sub-pixel values down to `0`, causing the line not to be rendered.
StyleSheet.hairlineWidth = 1;
if (_canUseDom.default && window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.resolveRNStyle = StyleSheet.flatten;
}
var stylesheet = StyleSheet;
var _default = exports.default = stylesheet;
module.exports = exports.default;
@@ -0,0 +1,222 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.preprocess = exports.default = exports.createTransformValue = exports.createTransformOriginValue = exports.createTextShadowValue = exports.createBoxShadowValue = exports.createBoxShadowArrayValue = void 0;
var _normalizeColor = _interopRequireDefault(require("./compiler/normalizeColor"));
var _normalizeValueWithProperty = _interopRequireDefault(require("./compiler/normalizeValueWithProperty"));
var _warnOnce = require("../../modules/warnOnce");
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var emptyObject = {};
/**
* Shadows
*/
var defaultOffset = {
height: 0,
width: 0
};
var createBoxShadowValue = style => {
var shadowColor = style.shadowColor,
shadowOffset = style.shadowOffset,
shadowOpacity = style.shadowOpacity,
shadowRadius = style.shadowRadius;
var _ref = shadowOffset || defaultOffset,
height = _ref.height,
width = _ref.width;
var offsetX = (0, _normalizeValueWithProperty.default)(width);
var offsetY = (0, _normalizeValueWithProperty.default)(height);
var blurRadius = (0, _normalizeValueWithProperty.default)(shadowRadius || 0);
var color = (0, _normalizeColor.default)(shadowColor || 'black', shadowOpacity);
if (color != null && offsetX != null && offsetY != null && blurRadius != null) {
return offsetX + " " + offsetY + " " + blurRadius + " " + color;
}
};
exports.createBoxShadowValue = createBoxShadowValue;
var createTextShadowValue = style => {
var textShadowColor = style.textShadowColor,
textShadowOffset = style.textShadowOffset,
textShadowRadius = style.textShadowRadius;
var _ref2 = textShadowOffset || defaultOffset,
height = _ref2.height,
width = _ref2.width;
var radius = textShadowRadius || 0;
var offsetX = (0, _normalizeValueWithProperty.default)(width);
var offsetY = (0, _normalizeValueWithProperty.default)(height);
var blurRadius = (0, _normalizeValueWithProperty.default)(radius);
var color = (0, _normalizeValueWithProperty.default)(textShadowColor, 'textShadowColor');
if (color && (height !== 0 || width !== 0 || radius !== 0) && offsetX != null && offsetY != null && blurRadius != null) {
return offsetX + " " + offsetY + " " + blurRadius + " " + color;
}
};
// { offsetX: 1, offsetY: 2, blurRadius: 3, spreadDistance: 4, color: 'rgba(255, 0, 0)', inset: true }
// => 'rgba(255, 0, 0) 1px 2px 3px 4px inset'
exports.createTextShadowValue = createTextShadowValue;
var mapBoxShadow = boxShadow => {
if (typeof boxShadow === 'string') {
return boxShadow;
}
var offsetX = (0, _normalizeValueWithProperty.default)(boxShadow.offsetX) || 0;
var offsetY = (0, _normalizeValueWithProperty.default)(boxShadow.offsetY) || 0;
var blurRadius = (0, _normalizeValueWithProperty.default)(boxShadow.blurRadius) || 0;
var spreadDistance = (0, _normalizeValueWithProperty.default)(boxShadow.spreadDistance) || 0;
var color = (0, _normalizeColor.default)(boxShadow.color) || 'black';
var position = boxShadow.inset ? 'inset ' : '';
return "" + position + offsetX + " " + offsetY + " " + blurRadius + " " + spreadDistance + " " + color;
};
var createBoxShadowArrayValue = value => {
return value.map(mapBoxShadow).join(', ');
};
// { scale: 2 } => 'scale(2)'
// { translateX: 20 } => 'translateX(20px)'
// { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
exports.createBoxShadowArrayValue = createBoxShadowArrayValue;
var mapTransform = transform => {
var type = Object.keys(transform)[0];
var value = transform[type];
if (type === 'matrix' || type === 'matrix3d') {
return type + "(" + value.join(',') + ")";
} else {
var normalizedValue = (0, _normalizeValueWithProperty.default)(value, type);
return type + "(" + normalizedValue + ")";
}
};
var createTransformValue = value => {
return value.map(mapTransform).join(' ');
};
// [2, '30%', 10] => '2px 30% 10px'
exports.createTransformValue = createTransformValue;
var createTransformOriginValue = value => {
return value.map(v => (0, _normalizeValueWithProperty.default)(v)).join(' ');
};
exports.createTransformOriginValue = createTransformOriginValue;
var PROPERTIES_STANDARD = {
borderBottomEndRadius: 'borderEndEndRadius',
borderBottomStartRadius: 'borderEndStartRadius',
borderTopEndRadius: 'borderStartEndRadius',
borderTopStartRadius: 'borderStartStartRadius',
borderEndColor: 'borderInlineEndColor',
borderEndStyle: 'borderInlineEndStyle',
borderEndWidth: 'borderInlineEndWidth',
borderStartColor: 'borderInlineStartColor',
borderStartStyle: 'borderInlineStartStyle',
borderStartWidth: 'borderInlineStartWidth',
end: 'insetInlineEnd',
marginEnd: 'marginInlineEnd',
marginHorizontal: 'marginInline',
marginStart: 'marginInlineStart',
marginVertical: 'marginBlock',
paddingEnd: 'paddingInlineEnd',
paddingHorizontal: 'paddingInline',
paddingStart: 'paddingInlineStart',
paddingVertical: 'paddingBlock',
start: 'insetInlineStart'
};
var ignoredProps = {
elevation: true,
overlayColor: true,
resizeMode: true,
tintColor: true
};
/**
* Preprocess styles
*/
var preprocess = exports.preprocess = function preprocess(originalStyle, options) {
if (options === void 0) {
options = {};
}
var style = originalStyle || emptyObject;
var nextStyle = {};
// Convert shadow styles
if (options.shadow === true, style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
(0, _warnOnce.warnOnce)('shadowStyles', "\"shadow*\" style props are deprecated. Use \"boxShadow\".");
var boxShadowValue = createBoxShadowValue(style);
if (boxShadowValue != null) {
nextStyle.boxShadow = boxShadowValue;
}
}
// Convert text shadow styles
if (options.textShadow === true, style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
(0, _warnOnce.warnOnce)('textShadowStyles', "\"textShadow*\" style props are deprecated. Use \"textShadow\".");
var textShadowValue = createTextShadowValue(style);
if (textShadowValue != null && nextStyle.textShadow == null) {
var textShadow = style.textShadow;
var value = textShadow ? textShadow + ", " + textShadowValue : textShadowValue;
nextStyle.textShadow = value;
}
}
for (var originalProp in style) {
if (
// Ignore some React Native styles
ignoredProps[originalProp] != null || originalProp === 'shadowColor' || originalProp === 'shadowOffset' || originalProp === 'shadowOpacity' || originalProp === 'shadowRadius' || originalProp === 'textShadowColor' || originalProp === 'textShadowOffset' || originalProp === 'textShadowRadius') {
continue;
}
var originalValue = style[originalProp];
var prop = PROPERTIES_STANDARD[originalProp] || originalProp;
var _value = originalValue;
if (!Object.prototype.hasOwnProperty.call(style, originalProp) || prop !== originalProp && style[prop] != null) {
continue;
}
if (prop === 'aspectRatio' && typeof _value === 'number') {
nextStyle[prop] = _value.toString();
} else if (prop === 'boxShadow') {
if (Array.isArray(_value)) {
_value = createBoxShadowArrayValue(_value);
}
var boxShadow = nextStyle.boxShadow;
nextStyle.boxShadow = boxShadow ? _value + ", " + boxShadow : _value;
} else if (prop === 'fontVariant') {
if (Array.isArray(_value) && _value.length > 0) {
/*
warnOnce(
'fontVariant',
'"fontVariant" style array value is deprecated. Use space-separated values.'
);
*/
_value = _value.join(' ');
}
nextStyle[prop] = _value;
} else if (prop === 'textAlignVertical') {
/*
warnOnce(
'textAlignVertical',
'"textAlignVertical" style is deprecated. Use "verticalAlign".'
);
*/
if (style.verticalAlign == null) {
nextStyle.verticalAlign = _value === 'center' ? 'middle' : _value;
}
} else if (prop === 'transform') {
if (Array.isArray(_value)) {
_value = createTransformValue(_value);
}
nextStyle.transform = _value;
} else if (prop === 'transformOrigin') {
if (Array.isArray(_value)) {
_value = createTransformOriginValue(_value);
}
nextStyle.transformOrigin = _value;
} else {
nextStyle[prop] = _value;
}
}
// $FlowIgnore
return nextStyle;
};
var _default = exports.default = preprocess;
@@ -0,0 +1,89 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.validate = validate;
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var invalidShortforms = {
background: true,
borderBottom: true,
borderLeft: true,
borderRight: true,
borderTop: true,
font: true,
grid: true,
outline: true,
textDecoration: true
};
var invalidMultiValueShortforms = {
flex: true,
margin: true,
padding: true,
borderColor: true,
borderRadius: true,
borderStyle: true,
borderWidth: true,
inset: true,
insetBlock: true,
insetInline: true,
marginBlock: true,
marginInline: true,
marginHorizontal: true,
marginVertical: true,
paddingBlock: true,
paddingInline: true,
paddingHorizontal: true,
paddingVertical: true,
overflow: true,
overscrollBehavior: true,
backgroundPosition: true
};
function error(message) {
console.error(message);
}
function validate(obj) {
for (var k in obj) {
var prop = k.trim();
var value = obj[prop];
var isInvalid = false;
if (value === null) {
continue;
}
if (typeof value === 'string' && value.indexOf('!important') > -1) {
error("Invalid style declaration \"" + prop + ":" + value + "\". Values cannot include \"!important\"");
isInvalid = true;
} else {
var suggestion = '';
if (prop === 'animation' || prop === 'animationName') {
suggestion = 'Did you mean "animationKeyframes"?';
isInvalid = true;
} else if (prop === 'direction') {
suggestion = 'Did you mean "writingDirection"?';
isInvalid = true;
} else if (invalidShortforms[prop]) {
suggestion = 'Please use long-form properties.';
isInvalid = true;
} else if (invalidMultiValueShortforms[prop]) {
if (typeof value === 'string' && (0, _postcssValueParser.default)(value).nodes.length > 1) {
suggestion = "Value is \"" + value + "\" but only single values are supported.";
isInvalid = true;
}
}
if (suggestion !== '') {
error("Invalid style property of \"" + prop + "\". " + suggestion);
}
}
if (isInvalid) {
delete obj[k];
}
}
}
@@ -0,0 +1,194 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var _multiplyStyleLengthValue = _interopRequireDefault(require("../../modules/multiplyStyleLengthValue"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["aria-label", "accessibilityLabel", "activeThumbColor", "activeTrackColor", "disabled", "onValueChange", "style", "thumbColor", "trackColor", "value"];
var emptyObject = {};
var thumbDefaultBoxShadow = '0px 1px 3px rgba(0,0,0,0.5)';
var thumbFocusedBoxShadow = thumbDefaultBoxShadow + ", 0 0 0 10px rgba(0,0,0,0.1)";
var defaultActiveTrackColor = '#A3D3CF';
var defaultTrackColor = '#939393';
var defaultDisabledTrackColor = '#D5D5D5';
var defaultActiveThumbColor = '#009688';
var defaultThumbColor = '#FAFAFA';
var defaultDisabledThumbColor = '#BDBDBD';
var Switch = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var ariaLabel = props['aria-label'],
accessibilityLabel = props.accessibilityLabel,
activeThumbColor = props.activeThumbColor,
activeTrackColor = props.activeTrackColor,
_props$disabled = props.disabled,
disabled = _props$disabled === void 0 ? false : _props$disabled,
onValueChange = props.onValueChange,
_props$style = props.style,
style = _props$style === void 0 ? emptyObject : _props$style,
thumbColor = props.thumbColor,
trackColor = props.trackColor,
_props$value = props.value,
value = _props$value === void 0 ? false : _props$value,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var thumbRef = React.useRef(null);
function handleChange(event) {
if (onValueChange != null) {
onValueChange(event.nativeEvent.target.checked);
}
}
function handleFocusState(event) {
var isFocused = event.nativeEvent.type === 'focus';
var boxShadow = isFocused ? thumbFocusedBoxShadow : thumbDefaultBoxShadow;
if (thumbRef.current != null) {
thumbRef.current.style.boxShadow = boxShadow;
}
}
var _StyleSheet$flatten = _StyleSheet.default.flatten(style),
styleHeight = _StyleSheet$flatten.height,
styleWidth = _StyleSheet$flatten.width;
var height = styleHeight || '20px';
var minWidth = (0, _multiplyStyleLengthValue.default)(height, 2);
var width = styleWidth > minWidth ? styleWidth : minWidth;
var trackBorderRadius = (0, _multiplyStyleLengthValue.default)(height, 0.5);
var trackCurrentColor = function () {
if (value === true) {
if (trackColor != null && typeof trackColor === 'object') {
return trackColor.true;
} else {
return activeTrackColor !== null && activeTrackColor !== void 0 ? activeTrackColor : defaultActiveTrackColor;
}
} else {
if (trackColor != null && typeof trackColor === 'object') {
return trackColor.false;
} else {
return trackColor !== null && trackColor !== void 0 ? trackColor : defaultTrackColor;
}
}
}();
var thumbCurrentColor = value ? activeThumbColor !== null && activeThumbColor !== void 0 ? activeThumbColor : defaultActiveThumbColor : thumbColor !== null && thumbColor !== void 0 ? thumbColor : defaultThumbColor;
var thumbHeight = height;
var thumbWidth = thumbHeight;
var rootStyle = [styles.root, style, disabled && styles.cursorDefault, {
height,
width
}];
var disabledTrackColor = function () {
if (value === true) {
if (typeof activeTrackColor === 'string' && activeTrackColor != null || typeof trackColor === 'object' && trackColor != null && trackColor.true) {
return trackCurrentColor;
} else {
return defaultDisabledTrackColor;
}
} else {
if (typeof trackColor === 'string' && trackColor != null || typeof trackColor === 'object' && trackColor != null && trackColor.false) {
return trackCurrentColor;
} else {
return defaultDisabledTrackColor;
}
}
}();
var disabledThumbColor = function () {
if (value === true) {
if (activeThumbColor == null) {
return defaultDisabledThumbColor;
} else {
return thumbCurrentColor;
}
} else {
if (thumbColor == null) {
return defaultDisabledThumbColor;
} else {
return thumbCurrentColor;
}
}
}();
var trackStyle = [styles.track, {
backgroundColor: disabled ? disabledTrackColor : trackCurrentColor,
borderRadius: trackBorderRadius
}];
var thumbStyle = [styles.thumb, value && styles.thumbActive, {
backgroundColor: disabled ? disabledThumbColor : thumbCurrentColor,
height: thumbHeight,
marginStart: value ? (0, _multiplyStyleLengthValue.default)(thumbWidth, -1) : 0,
width: thumbWidth
}];
var nativeControl = (0, _createElement.default)('input', {
'aria-label': ariaLabel || accessibilityLabel,
checked: value,
disabled: disabled,
onBlur: handleFocusState,
onChange: handleChange,
onFocus: handleFocusState,
ref: forwardedRef,
style: [styles.nativeControl, styles.cursorInherit],
type: 'checkbox',
role: 'switch'
});
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, other, {
style: rootStyle
}), /*#__PURE__*/React.createElement(_View.default, {
style: trackStyle
}), /*#__PURE__*/React.createElement(_View.default, {
ref: thumbRef,
style: thumbStyle
}), nativeControl);
});
Switch.displayName = 'Switch';
var styles = _StyleSheet.default.create({
root: {
cursor: 'pointer',
userSelect: 'none'
},
cursorDefault: {
cursor: 'default'
},
cursorInherit: {
cursor: 'inherit'
},
track: (0, _objectSpread2.default)((0, _objectSpread2.default)({
forcedColorAdjust: 'none'
}, _StyleSheet.default.absoluteFillObject), {}, {
height: '70%',
margin: 'auto',
transitionDuration: '0.1s',
width: '100%'
}),
thumb: {
forcedColorAdjust: 'none',
alignSelf: 'flex-start',
borderRadius: '100%',
boxShadow: thumbDefaultBoxShadow,
start: '0%',
transform: 'translateZ(0)',
transitionDuration: '0.1s'
},
thumbActive: {
insetInlineStart: '100%'
},
nativeControl: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _StyleSheet.default.absoluteFillObject), {}, {
height: '100%',
margin: 0,
appearance: 'none',
padding: 0,
width: '100%'
})
});
var _default = exports.default = Switch;
module.exports = exports.default;
@@ -0,0 +1,18 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
exports.__esModule = true;
exports.default = void 0;
var _react = require("react");
var TextAncestorContext = /*#__PURE__*/(0, _react.createContext)(false);
var _default = exports.default = TextAncestorContext;
module.exports = exports.default;
@@ -0,0 +1,199 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var forwardedProps = _interopRequireWildcard(require("../../modules/forwardedProps"));
var _pick = _interopRequireDefault(require("../../modules/pick"));
var _useElementLayout = _interopRequireDefault(require("../../modules/useElementLayout"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePlatformMethods = _interopRequireDefault(require("../../modules/usePlatformMethods"));
var _useResponderEvents = _interopRequireDefault(require("../../modules/useResponderEvents"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _TextAncestorContext = _interopRequireDefault(require("./TextAncestorContext"));
var _useLocale = require("../../modules/useLocale");
var _excluded = ["hrefAttrs", "numberOfLines", "onClick", "onLayout", "onPress", "onMoveShouldSetResponder", "onMoveShouldSetResponderCapture", "onResponderEnd", "onResponderGrant", "onResponderMove", "onResponderReject", "onResponderRelease", "onResponderStart", "onResponderTerminate", "onResponderTerminationRequest", "onScrollShouldSetResponder", "onScrollShouldSetResponderCapture", "onSelectionChangeShouldSetResponder", "onSelectionChangeShouldSetResponderCapture", "onStartShouldSetResponder", "onStartShouldSetResponderCapture", "selectable"];
//import { warnOnce } from '../../modules/warnOnce';
var forwardPropsList = Object.assign({}, forwardedProps.defaultProps, forwardedProps.accessibilityProps, forwardedProps.clickProps, forwardedProps.focusProps, forwardedProps.keyboardProps, forwardedProps.mouseProps, forwardedProps.touchProps, forwardedProps.styleProps, {
href: true,
lang: true,
pointerEvents: true
});
var pickProps = props => (0, _pick.default)(props, forwardPropsList);
var Text = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var hrefAttrs = props.hrefAttrs,
numberOfLines = props.numberOfLines,
onClick = props.onClick,
onLayout = props.onLayout,
onPress = props.onPress,
onMoveShouldSetResponder = props.onMoveShouldSetResponder,
onMoveShouldSetResponderCapture = props.onMoveShouldSetResponderCapture,
onResponderEnd = props.onResponderEnd,
onResponderGrant = props.onResponderGrant,
onResponderMove = props.onResponderMove,
onResponderReject = props.onResponderReject,
onResponderRelease = props.onResponderRelease,
onResponderStart = props.onResponderStart,
onResponderTerminate = props.onResponderTerminate,
onResponderTerminationRequest = props.onResponderTerminationRequest,
onScrollShouldSetResponder = props.onScrollShouldSetResponder,
onScrollShouldSetResponderCapture = props.onScrollShouldSetResponderCapture,
onSelectionChangeShouldSetResponder = props.onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture = props.onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder = props.onStartShouldSetResponder,
onStartShouldSetResponderCapture = props.onStartShouldSetResponderCapture,
selectable = props.selectable,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
/*
if (selectable != null) {
warnOnce(
'selectable',
'selectable prop is deprecated. Use styles.userSelect.'
);
}
*/
var hasTextAncestor = React.useContext(_TextAncestorContext.default);
var hostRef = React.useRef(null);
var _useLocaleContext = (0, _useLocale.useLocaleContext)(),
contextDirection = _useLocaleContext.direction;
(0, _useElementLayout.default)(hostRef, onLayout);
(0, _useResponderEvents.default)(hostRef, {
onMoveShouldSetResponder,
onMoveShouldSetResponderCapture,
onResponderEnd,
onResponderGrant,
onResponderMove,
onResponderReject,
onResponderRelease,
onResponderStart,
onResponderTerminate,
onResponderTerminationRequest,
onScrollShouldSetResponder,
onScrollShouldSetResponderCapture,
onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder,
onStartShouldSetResponderCapture
});
var handleClick = React.useCallback(e => {
if (onClick != null) {
onClick(e);
} else if (onPress != null) {
e.stopPropagation();
onPress(e);
}
}, [onClick, onPress]);
var component = hasTextAncestor ? 'span' : 'div';
var langDirection = props.lang != null ? (0, _useLocale.getLocaleDirection)(props.lang) : null;
var componentDirection = props.dir || langDirection;
var writingDirection = componentDirection || contextDirection;
var supportedProps = pickProps(rest);
supportedProps.dir = componentDirection;
// 'auto' by default allows browsers to infer writing direction (root elements only)
if (!hasTextAncestor) {
supportedProps.dir = componentDirection != null ? componentDirection : 'auto';
}
if (onClick || onPress) {
supportedProps.onClick = handleClick;
}
supportedProps.style = [numberOfLines != null && numberOfLines > 1 && {
WebkitLineClamp: numberOfLines
}, hasTextAncestor === true ? styles.textHasAncestor$raw : styles.text$raw, numberOfLines === 1 && styles.textOneLine, numberOfLines != null && numberOfLines > 1 && styles.textMultiLine, props.style, selectable === true && styles.selectable, selectable === false && styles.notSelectable, onPress && styles.pressable];
if (props.href != null) {
component = 'a';
if (hrefAttrs != null) {
var download = hrefAttrs.download,
rel = hrefAttrs.rel,
target = hrefAttrs.target;
if (download != null) {
supportedProps.download = download;
}
if (rel != null) {
supportedProps.rel = rel;
}
if (typeof target === 'string') {
supportedProps.target = target.charAt(0) !== '_' ? '_' + target : target;
}
}
}
var platformMethodsRef = (0, _usePlatformMethods.default)(supportedProps);
var setRef = (0, _useMergeRefs.default)(hostRef, platformMethodsRef, forwardedRef);
supportedProps.ref = setRef;
var element = (0, _createElement.default)(component, supportedProps, {
writingDirection
});
return hasTextAncestor ? element : /*#__PURE__*/React.createElement(_TextAncestorContext.default.Provider, {
value: true
}, element);
});
Text.displayName = 'Text';
var textStyle = {
backgroundColor: 'transparent',
border: '0 solid black',
boxSizing: 'border-box',
color: 'black',
display: 'inline',
font: '14px System',
listStyle: 'none',
margin: 0,
padding: 0,
position: 'relative',
textAlign: 'start',
textDecoration: 'none',
whiteSpace: 'pre-wrap',
wordWrap: 'break-word'
};
var styles = _StyleSheet.default.create({
text$raw: textStyle,
textHasAncestor$raw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, textStyle), {}, {
color: 'inherit',
font: 'inherit',
textAlign: 'inherit',
whiteSpace: 'inherit'
}),
textOneLine: {
maxWidth: '100%',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
wordWrap: 'normal'
},
// See #13
textMultiLine: {
display: '-webkit-box',
maxWidth: '100%',
overflow: 'clip',
textOverflow: 'ellipsis',
WebkitBoxOrient: 'vertical'
},
notSelectable: {
userSelect: 'none'
},
selectable: {
userSelect: 'text'
},
pressable: {
cursor: 'pointer'
}
});
var _default = exports.default = Text;
module.exports = exports.default;
@@ -0,0 +1 @@
"use strict";
@@ -0,0 +1,424 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var forwardedProps = _interopRequireWildcard(require("../../modules/forwardedProps"));
var _pick = _interopRequireDefault(require("../../modules/pick"));
var _useElementLayout = _interopRequireDefault(require("../../modules/useElementLayout"));
var _useLayoutEffect = _interopRequireDefault(require("../../modules/useLayoutEffect"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePlatformMethods = _interopRequireDefault(require("../../modules/usePlatformMethods"));
var _useResponderEvents = _interopRequireDefault(require("../../modules/useResponderEvents"));
var _useLocale = require("../../modules/useLocale");
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _TextInputState = _interopRequireDefault(require("../../modules/TextInputState"));
//import { warnOnce } from '../../modules/warnOnce';
/**
* Determines whether a 'selection' prop differs from a node's existing
* selection state.
*/
var isSelectionStale = (node, selection) => {
var selectionEnd = node.selectionEnd,
selectionStart = node.selectionStart;
var start = selection.start,
end = selection.end;
return start !== selectionStart || end !== selectionEnd;
};
/**
* Certain input types do no support 'selectSelectionRange' and will throw an
* error.
*/
var setSelection = (node, selection) => {
if (isSelectionStale(node, selection)) {
var start = selection.start,
end = selection.end;
try {
node.setSelectionRange(start, end || start);
} catch (e) {}
}
};
var forwardPropsList = Object.assign({}, forwardedProps.defaultProps, forwardedProps.accessibilityProps, forwardedProps.clickProps, forwardedProps.focusProps, forwardedProps.keyboardProps, forwardedProps.mouseProps, forwardedProps.touchProps, forwardedProps.styleProps, {
autoCapitalize: true,
autoComplete: true,
autoCorrect: true,
autoFocus: true,
defaultValue: true,
disabled: true,
lang: true,
maxLength: true,
onChange: true,
onScroll: true,
placeholder: true,
pointerEvents: true,
readOnly: true,
rows: true,
spellCheck: true,
value: true,
type: true
});
var pickProps = props => (0, _pick.default)(props, forwardPropsList);
// If an Input Method Editor is processing key input, the 'keyCode' is 229.
// https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode
function isEventComposing(nativeEvent) {
return nativeEvent.isComposing || nativeEvent.keyCode === 229;
}
var focusTimeout = null;
var TextInput = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var _props$autoCapitalize = props.autoCapitalize,
autoCapitalize = _props$autoCapitalize === void 0 ? 'sentences' : _props$autoCapitalize,
autoComplete = props.autoComplete,
autoCompleteType = props.autoCompleteType,
_props$autoCorrect = props.autoCorrect,
autoCorrect = _props$autoCorrect === void 0 ? true : _props$autoCorrect,
blurOnSubmit = props.blurOnSubmit,
caretHidden = props.caretHidden,
clearTextOnFocus = props.clearTextOnFocus,
dir = props.dir,
editable = props.editable,
enterKeyHint = props.enterKeyHint,
inputMode = props.inputMode,
keyboardType = props.keyboardType,
_props$multiline = props.multiline,
multiline = _props$multiline === void 0 ? false : _props$multiline,
numberOfLines = props.numberOfLines,
onBlur = props.onBlur,
onChange = props.onChange,
onChangeText = props.onChangeText,
onContentSizeChange = props.onContentSizeChange,
onFocus = props.onFocus,
onKeyPress = props.onKeyPress,
onLayout = props.onLayout,
onMoveShouldSetResponder = props.onMoveShouldSetResponder,
onMoveShouldSetResponderCapture = props.onMoveShouldSetResponderCapture,
onResponderEnd = props.onResponderEnd,
onResponderGrant = props.onResponderGrant,
onResponderMove = props.onResponderMove,
onResponderReject = props.onResponderReject,
onResponderRelease = props.onResponderRelease,
onResponderStart = props.onResponderStart,
onResponderTerminate = props.onResponderTerminate,
onResponderTerminationRequest = props.onResponderTerminationRequest,
onScrollShouldSetResponder = props.onScrollShouldSetResponder,
onScrollShouldSetResponderCapture = props.onScrollShouldSetResponderCapture,
onSelectionChange = props.onSelectionChange,
onSelectionChangeShouldSetResponder = props.onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture = props.onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder = props.onStartShouldSetResponder,
onStartShouldSetResponderCapture = props.onStartShouldSetResponderCapture,
onSubmitEditing = props.onSubmitEditing,
placeholderTextColor = props.placeholderTextColor,
_props$readOnly = props.readOnly,
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
returnKeyType = props.returnKeyType,
rows = props.rows,
_props$secureTextEntr = props.secureTextEntry,
secureTextEntry = _props$secureTextEntr === void 0 ? false : _props$secureTextEntr,
selection = props.selection,
selectTextOnFocus = props.selectTextOnFocus,
showSoftInputOnFocus = props.showSoftInputOnFocus,
spellCheck = props.spellCheck;
var type;
var _inputMode;
if (inputMode != null) {
_inputMode = inputMode;
if (inputMode === 'email') {
type = 'email';
} else if (inputMode === 'tel') {
type = 'tel';
} else if (inputMode === 'search') {
type = 'search';
} else if (inputMode === 'url') {
type = 'url';
} else {
type = 'text';
}
} else if (keyboardType != null) {
// warnOnce('keyboardType', 'keyboardType is deprecated. Use inputMode.');
switch (keyboardType) {
case 'email-address':
type = 'email';
break;
case 'number-pad':
case 'numeric':
_inputMode = 'numeric';
break;
case 'decimal-pad':
_inputMode = 'decimal';
break;
case 'phone-pad':
type = 'tel';
break;
case 'search':
case 'web-search':
type = 'search';
break;
case 'url':
type = 'url';
break;
default:
type = 'text';
}
}
if (secureTextEntry) {
type = 'password';
}
var dimensions = React.useRef({
height: null,
width: null
});
var hostRef = React.useRef(null);
var prevSelection = React.useRef(null);
var prevSecureTextEntry = React.useRef(false);
React.useEffect(() => {
if (hostRef.current && prevSelection.current) {
setSelection(hostRef.current, prevSelection.current);
}
prevSecureTextEntry.current = secureTextEntry;
}, [secureTextEntry]);
var handleContentSizeChange = React.useCallback(hostNode => {
if (multiline && onContentSizeChange && hostNode != null) {
var newHeight = hostNode.scrollHeight;
var newWidth = hostNode.scrollWidth;
if (newHeight !== dimensions.current.height || newWidth !== dimensions.current.width) {
dimensions.current.height = newHeight;
dimensions.current.width = newWidth;
onContentSizeChange({
nativeEvent: {
contentSize: {
height: dimensions.current.height,
width: dimensions.current.width
}
}
});
}
}
}, [multiline, onContentSizeChange]);
var imperativeRef = React.useMemo(() => hostNode => {
// TextInput needs to add more methods to the hostNode in addition to those
// added by `usePlatformMethods`. This is temporarily until an API like
// `TextInput.clear(hostRef)` is added to React Native.
if (hostNode != null) {
hostNode.clear = function () {
if (hostNode != null) {
hostNode.value = '';
}
};
hostNode.isFocused = function () {
return hostNode != null && _TextInputState.default.currentlyFocusedField() === hostNode;
};
handleContentSizeChange(hostNode);
}
}, [handleContentSizeChange]);
function handleBlur(e) {
_TextInputState.default._currentlyFocusedNode = null;
if (onBlur) {
e.nativeEvent.text = e.target.value;
onBlur(e);
}
}
function handleChange(e) {
var hostNode = e.target;
var text = hostNode.value;
e.nativeEvent.text = text;
handleContentSizeChange(hostNode);
if (onChange) {
onChange(e);
}
if (onChangeText) {
onChangeText(text);
}
}
function handleFocus(e) {
var hostNode = e.target;
if (onFocus) {
e.nativeEvent.text = hostNode.value;
onFocus(e);
}
if (hostNode != null) {
_TextInputState.default._currentlyFocusedNode = hostNode;
if (clearTextOnFocus) {
hostNode.value = '';
}
if (selectTextOnFocus) {
// Safari requires selection to occur in a setTimeout
if (focusTimeout != null) {
clearTimeout(focusTimeout);
}
focusTimeout = setTimeout(() => {
// Check if the input is still focused after the timeout
// (see #2704)
if (hostNode != null && document.activeElement === hostNode) {
hostNode.select();
}
}, 0);
}
}
}
function handleKeyDown(e) {
var hostNode = e.target;
// Prevent key events bubbling (see #612)
e.stopPropagation();
var blurOnSubmitDefault = !multiline;
var shouldBlurOnSubmit = blurOnSubmit == null ? blurOnSubmitDefault : blurOnSubmit;
var nativeEvent = e.nativeEvent;
var isComposing = isEventComposing(nativeEvent);
if (onKeyPress) {
onKeyPress(e);
}
if (e.key === 'Enter' && !e.shiftKey &&
// Do not call submit if composition is occuring.
!isComposing && !e.isDefaultPrevented()) {
if ((blurOnSubmit || !multiline) && onSubmitEditing) {
// prevent "Enter" from inserting a newline or submitting a form
e.preventDefault();
nativeEvent.text = e.target.value;
onSubmitEditing(e);
}
if (shouldBlurOnSubmit && hostNode != null) {
setTimeout(() => hostNode.blur(), 0);
}
}
}
function handleSelectionChange(e) {
try {
var _e$target = e.target,
selectionStart = _e$target.selectionStart,
selectionEnd = _e$target.selectionEnd;
var _selection = {
start: selectionStart,
end: selectionEnd
};
if (onSelectionChange) {
e.nativeEvent.selection = _selection;
e.nativeEvent.text = e.target.value;
onSelectionChange(e);
}
if (prevSecureTextEntry.current === secureTextEntry) {
prevSelection.current = _selection;
}
} catch (e) {}
}
(0, _useLayoutEffect.default)(() => {
var node = hostRef.current;
if (node != null && selection != null) {
setSelection(node, selection);
}
if (document.activeElement === node) {
_TextInputState.default._currentlyFocusedNode = node;
}
}, [hostRef, selection]);
var component = multiline ? 'textarea' : 'input';
(0, _useElementLayout.default)(hostRef, onLayout);
(0, _useResponderEvents.default)(hostRef, {
onMoveShouldSetResponder,
onMoveShouldSetResponderCapture,
onResponderEnd,
onResponderGrant,
onResponderMove,
onResponderReject,
onResponderRelease,
onResponderStart,
onResponderTerminate,
onResponderTerminationRequest,
onScrollShouldSetResponder,
onScrollShouldSetResponderCapture,
onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder,
onStartShouldSetResponderCapture
});
var _useLocaleContext = (0, _useLocale.useLocaleContext)(),
contextDirection = _useLocaleContext.direction;
var supportedProps = pickProps(props);
supportedProps.autoCapitalize = autoCapitalize;
supportedProps.autoComplete = autoComplete || autoCompleteType || 'on';
supportedProps.autoCorrect = autoCorrect ? 'on' : 'off';
// 'auto' by default allows browsers to infer writing direction
supportedProps.dir = dir !== undefined ? dir : 'auto';
/*
if (returnKeyType != null) {
warnOnce('returnKeyType', 'returnKeyType is deprecated. Use enterKeyHint.');
}
*/
supportedProps.enterKeyHint = enterKeyHint || returnKeyType;
supportedProps.inputMode = _inputMode;
supportedProps.onBlur = handleBlur;
supportedProps.onChange = handleChange;
supportedProps.onFocus = handleFocus;
supportedProps.onKeyDown = handleKeyDown;
supportedProps.onSelect = handleSelectionChange;
/*
if (editable != null) {
warnOnce('editable', 'editable is deprecated. Use readOnly.');
}
*/
supportedProps.readOnly = readOnly === true || editable === false;
/*
if (numberOfLines != null) {
warnOnce(
'numberOfLines',
'TextInput numberOfLines is deprecated. Use rows.'
);
}
*/
supportedProps.rows = multiline ? rows != null ? rows : numberOfLines : 1;
supportedProps.spellCheck = spellCheck != null ? spellCheck : autoCorrect;
supportedProps.style = [{
'--placeholderTextColor': placeholderTextColor
}, styles.textinput$raw, styles.placeholder, props.style, caretHidden && styles.caretHidden];
supportedProps.type = multiline ? undefined : type;
supportedProps.virtualkeyboardpolicy = showSoftInputOnFocus === false ? 'manual' : 'auto';
var platformMethodsRef = (0, _usePlatformMethods.default)(supportedProps);
var setRef = (0, _useMergeRefs.default)(hostRef, platformMethodsRef, imperativeRef, forwardedRef);
supportedProps.ref = setRef;
var langDirection = props.lang != null ? (0, _useLocale.getLocaleDirection)(props.lang) : null;
var componentDirection = props.dir || langDirection;
var writingDirection = componentDirection || contextDirection;
var element = (0, _createElement.default)(component, supportedProps, {
writingDirection
});
return element;
});
TextInput.displayName = 'TextInput';
// $FlowFixMe
TextInput.State = _TextInputState.default;
var styles = _StyleSheet.default.create({
textinput$raw: {
MozAppearance: 'textfield',
WebkitAppearance: 'none',
backgroundColor: 'transparent',
border: '0 solid black',
borderRadius: 0,
boxSizing: 'border-box',
font: '14px System',
margin: 0,
padding: 0,
resize: 'none'
},
placeholder: {
placeholderTextColor: 'var(--placeholderTextColor)'
},
caretHidden: {
caretColor: 'transparent'
}
});
var _default = exports.default = TextInput;
module.exports = exports.default;
@@ -0,0 +1 @@
"use strict";
@@ -0,0 +1,35 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _PooledClass = _interopRequireDefault(require("../../vendor/react-native/PooledClass"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var twoArgumentPooler = _PooledClass.default.twoArgumentPooler;
/**
* PooledClass representing the bounding rectangle of a region.
*/
function BoundingDimensions(width, height) {
this.width = width;
this.height = height;
}
BoundingDimensions.prototype.destructor = function () {
this.width = null;
this.height = null;
};
BoundingDimensions.getPooledFromElement = function (element) {
return BoundingDimensions.getPooled(element.offsetWidth, element.offsetHeight);
};
_PooledClass.default.addPoolingTo(BoundingDimensions, twoArgumentPooler);
var _default = exports.default = BoundingDimensions;
module.exports = exports.default;
@@ -0,0 +1,27 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _PooledClass = _interopRequireDefault(require("../../vendor/react-native/PooledClass"));
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var twoArgumentPooler = _PooledClass.default.twoArgumentPooler;
function Position(left, top) {
this.left = left;
this.top = top;
}
Position.prototype.destructor = function () {
this.left = null;
this.top = null;
};
_PooledClass.default.addPoolingTo(Position, twoArgumentPooler);
var _default = exports.default = Position;
module.exports = exports.default;
@@ -0,0 +1,20 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _invariant = _interopRequireDefault(require("fbjs/lib/invariant"));
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var ensurePositiveDelayProps = props => {
(0, _invariant.default)(!(props.delayPressIn < 0 || props.delayPressOut < 0 || props.delayLongPress < 0), 'Touchable components cannot have negative delay properties');
};
var _default = exports.default = ensurePositiveDelayProps;
module.exports = exports.default;
@@ -0,0 +1,839 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _AccessibilityUtil = _interopRequireDefault(require("../../modules/AccessibilityUtil"));
var _BoundingDimensions = _interopRequireDefault(require("./BoundingDimensions"));
var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
var _Position = _interopRequireDefault(require("./Position"));
var _react = _interopRequireDefault(require("react"));
var _UIManager = _interopRequireDefault(require("../UIManager"));
var _View = _interopRequireDefault(require("../View"));
var _warnOnce = require("../../modules/warnOnce");
var extractSingleTouch = nativeEvent => {
var touches = nativeEvent.touches;
var changedTouches = nativeEvent.changedTouches;
var hasTouches = touches && touches.length > 0;
var hasChangedTouches = changedTouches && changedTouches.length > 0;
return !hasTouches && hasChangedTouches ? changedTouches[0] : hasTouches ? touches[0] : nativeEvent;
};
/**
* `Touchable`: Taps done right.
*
* You hook your `ResponderEventPlugin` events into `Touchable`. `Touchable`
* will measure time/geometry and tells you when to give feedback to the user.
*
* ====================== Touchable Tutorial ===============================
* The `Touchable` mixin helps you handle the "press" interaction. It analyzes
* the geometry of elements, and observes when another responder (scroll view
* etc) has stolen the touch lock. It notifies your component when it should
* give feedback to the user. (bouncing/highlighting/unhighlighting).
*
* - When a touch was activated (typically you highlight)
* - When a touch was deactivated (typically you unhighlight)
* - When a touch was "pressed" - a touch ended while still within the geometry
* of the element, and no other element (like scroller) has "stolen" touch
* lock ("responder") (Typically you bounce the element).
*
* A good tap interaction isn't as simple as you might think. There should be a
* slight delay before showing a highlight when starting a touch. If a
* subsequent touch move exceeds the boundary of the element, it should
* unhighlight, but if that same touch is brought back within the boundary, it
* should rehighlight again. A touch can move in and out of that boundary
* several times, each time toggling highlighting, but a "press" is only
* triggered if that touch ends while within the element's boundary and no
* scroller (or anything else) has stolen the lock on touches.
*
* To create a new type of component that handles interaction using the
* `Touchable` mixin, do the following:
*
* - Initialize the `Touchable` state.
*
* getInitialState: function() {
* return merge(this.touchableGetInitialState(), yourComponentState);
* }
*
* - Add a method to get your touchable component's node.
* getTouchableNode: function() {
* return this.touchableRef.current
* }
*
* - Choose the rendered component who's touches should start the interactive
* sequence. On that rendered node, forward all `Touchable` responder
* handlers. You can choose any rendered node you like. Choose a node whose
* hit target you'd like to instigate the interaction sequence:
*
* // In render function:
* return (
* <View
* ref={this.touchableRef}
* onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
* onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}
* onResponderGrant={this.touchableHandleResponderGrant}
* onResponderMove={this.touchableHandleResponderMove}
* onResponderRelease={this.touchableHandleResponderRelease}
* onResponderTerminate={this.touchableHandleResponderTerminate}>
* <View>
* Even though the hit detection/interactions are triggered by the
* wrapping (typically larger) node, we usually end up implementing
* custom logic that highlights this inner one.
* </View>
* </View>
* );
*
* - You may set up your own handlers for each of these events, so long as you
* also invoke the `touchable*` handlers inside of your custom handler.
*
* - Implement the handlers on your component class in order to provide
* feedback to the user. See documentation for each of these class methods
* that you should implement.
*
* touchableHandlePress: function() {
* this.performBounceAnimation(); // or whatever you want to do.
* },
* touchableHandleActivePressIn: function() {
* this.beginHighlighting(...); // Whatever you like to convey activation
* },
* touchableHandleActivePressOut: function() {
* this.endHighlighting(...); // Whatever you like to convey deactivation
* },
*
* - There are more advanced methods you can implement (see documentation below):
* touchableGetHighlightDelayMS: function() {
* return 20;
* }
* // In practice, *always* use a predeclared constant (conserve memory).
* touchableGetPressRectOffset: function() {
* return {top: 20, left: 20, right: 20, bottom: 100};
* }
*/
/**
* Touchable states.
*/
var States = {
NOT_RESPONDER: 'NOT_RESPONDER',
// Not the responder
RESPONDER_INACTIVE_PRESS_IN: 'RESPONDER_INACTIVE_PRESS_IN',
// Responder, inactive, in the `PressRect`
RESPONDER_INACTIVE_PRESS_OUT: 'RESPONDER_INACTIVE_PRESS_OUT',
// Responder, inactive, out of `PressRect`
RESPONDER_ACTIVE_PRESS_IN: 'RESPONDER_ACTIVE_PRESS_IN',
// Responder, active, in the `PressRect`
RESPONDER_ACTIVE_PRESS_OUT: 'RESPONDER_ACTIVE_PRESS_OUT',
// Responder, active, out of `PressRect`
RESPONDER_ACTIVE_LONG_PRESS_IN: 'RESPONDER_ACTIVE_LONG_PRESS_IN',
// Responder, active, in the `PressRect`, after long press threshold
RESPONDER_ACTIVE_LONG_PRESS_OUT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT',
// Responder, active, out of `PressRect`, after long press threshold
ERROR: 'ERROR'
};
/*
* Quick lookup map for states that are considered to be "active"
*/
var baseStatesConditions = {
NOT_RESPONDER: false,
RESPONDER_INACTIVE_PRESS_IN: false,
RESPONDER_INACTIVE_PRESS_OUT: false,
RESPONDER_ACTIVE_PRESS_IN: false,
RESPONDER_ACTIVE_PRESS_OUT: false,
RESPONDER_ACTIVE_LONG_PRESS_IN: false,
RESPONDER_ACTIVE_LONG_PRESS_OUT: false,
ERROR: false
};
var IsActive = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, baseStatesConditions), {}, {
RESPONDER_ACTIVE_PRESS_OUT: true,
RESPONDER_ACTIVE_PRESS_IN: true
});
/**
* Quick lookup for states that are considered to be "pressing" and are
* therefore eligible to result in a "selection" if the press stops.
*/
var IsPressingIn = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, baseStatesConditions), {}, {
RESPONDER_INACTIVE_PRESS_IN: true,
RESPONDER_ACTIVE_PRESS_IN: true,
RESPONDER_ACTIVE_LONG_PRESS_IN: true
});
var IsLongPressingIn = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, baseStatesConditions), {}, {
RESPONDER_ACTIVE_LONG_PRESS_IN: true
});
/**
* Inputs to the state machine.
*/
var Signals = {
DELAY: 'DELAY',
RESPONDER_GRANT: 'RESPONDER_GRANT',
RESPONDER_RELEASE: 'RESPONDER_RELEASE',
RESPONDER_TERMINATED: 'RESPONDER_TERMINATED',
ENTER_PRESS_RECT: 'ENTER_PRESS_RECT',
LEAVE_PRESS_RECT: 'LEAVE_PRESS_RECT',
LONG_PRESS_DETECTED: 'LONG_PRESS_DETECTED'
};
/**
* Mapping from States x Signals => States
*/
var Transitions = {
NOT_RESPONDER: {
DELAY: States.ERROR,
RESPONDER_GRANT: States.RESPONDER_INACTIVE_PRESS_IN,
RESPONDER_RELEASE: States.ERROR,
RESPONDER_TERMINATED: States.ERROR,
ENTER_PRESS_RECT: States.ERROR,
LEAVE_PRESS_RECT: States.ERROR,
LONG_PRESS_DETECTED: States.ERROR
},
RESPONDER_INACTIVE_PRESS_IN: {
DELAY: States.RESPONDER_ACTIVE_PRESS_IN,
RESPONDER_GRANT: States.ERROR,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_IN,
LEAVE_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_OUT,
LONG_PRESS_DETECTED: States.ERROR
},
RESPONDER_INACTIVE_PRESS_OUT: {
DELAY: States.RESPONDER_ACTIVE_PRESS_OUT,
RESPONDER_GRANT: States.ERROR,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_IN,
LEAVE_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_OUT,
LONG_PRESS_DETECTED: States.ERROR
},
RESPONDER_ACTIVE_PRESS_IN: {
DELAY: States.ERROR,
RESPONDER_GRANT: States.ERROR,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.RESPONDER_ACTIVE_PRESS_IN,
LEAVE_PRESS_RECT: States.RESPONDER_ACTIVE_PRESS_OUT,
LONG_PRESS_DETECTED: States.RESPONDER_ACTIVE_LONG_PRESS_IN
},
RESPONDER_ACTIVE_PRESS_OUT: {
DELAY: States.ERROR,
RESPONDER_GRANT: States.ERROR,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.RESPONDER_ACTIVE_PRESS_IN,
LEAVE_PRESS_RECT: States.RESPONDER_ACTIVE_PRESS_OUT,
LONG_PRESS_DETECTED: States.ERROR
},
RESPONDER_ACTIVE_LONG_PRESS_IN: {
DELAY: States.ERROR,
RESPONDER_GRANT: States.ERROR,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.RESPONDER_ACTIVE_LONG_PRESS_IN,
LEAVE_PRESS_RECT: States.RESPONDER_ACTIVE_LONG_PRESS_OUT,
LONG_PRESS_DETECTED: States.RESPONDER_ACTIVE_LONG_PRESS_IN
},
RESPONDER_ACTIVE_LONG_PRESS_OUT: {
DELAY: States.ERROR,
RESPONDER_GRANT: States.ERROR,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.RESPONDER_ACTIVE_LONG_PRESS_IN,
LEAVE_PRESS_RECT: States.RESPONDER_ACTIVE_LONG_PRESS_OUT,
LONG_PRESS_DETECTED: States.ERROR
},
error: {
DELAY: States.NOT_RESPONDER,
RESPONDER_GRANT: States.RESPONDER_INACTIVE_PRESS_IN,
RESPONDER_RELEASE: States.NOT_RESPONDER,
RESPONDER_TERMINATED: States.NOT_RESPONDER,
ENTER_PRESS_RECT: States.NOT_RESPONDER,
LEAVE_PRESS_RECT: States.NOT_RESPONDER,
LONG_PRESS_DETECTED: States.NOT_RESPONDER
}
};
// ==== Typical Constants for integrating into UI components ====
// var HIT_EXPAND_PX = 20;
// var HIT_VERT_OFFSET_PX = 10;
var HIGHLIGHT_DELAY_MS = 130;
var PRESS_EXPAND_PX = 20;
var LONG_PRESS_THRESHOLD = 500;
var LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS;
var LONG_PRESS_ALLOWED_MOVEMENT = 10;
// Default amount "active" region protrudes beyond box
/**
* By convention, methods prefixed with underscores are meant to be @private,
* and not @protected. Mixers shouldn't access them - not even to provide them
* as callback handlers.
*
*
* ========== Geometry =========
* `Touchable` only assumes that there exists a `HitRect` node. The `PressRect`
* is an abstract box that is extended beyond the `HitRect`.
*
* +--------------------------+
* | | - "Start" events in `HitRect` cause `HitRect`
* | +--------------------+ | to become the responder.
* | | +--------------+ | | - `HitRect` is typically expanded around
* | | | | | | the `VisualRect`, but shifted downward.
* | | | VisualRect | | | - After pressing down, after some delay,
* | | | | | | and before letting up, the Visual React
* | | +--------------+ | | will become "active". This makes it eligible
* | | HitRect | | for being highlighted (so long as the
* | +--------------------+ | press remains in the `PressRect`).
* | PressRect o |
* +----------------------|---+
* Out Region |
* +-----+ This gap between the `HitRect` and
* `PressRect` allows a touch to move far away
* from the original hit rect, and remain
* highlighted, and eligible for a "Press".
* Customize this via
* `touchableGetPressRectOffset()`.
*
*
*
* ======= State Machine =======
*
* +-------------+ <---+ RESPONDER_RELEASE
* |NOT_RESPONDER|
* +-------------+ <---+ RESPONDER_TERMINATED
* +
* | RESPONDER_GRANT (HitRect)
* v
* +---------------------------+ DELAY +-------------------------+ T + DELAY +------------------------------+
* |RESPONDER_INACTIVE_PRESS_IN|+-------->|RESPONDER_ACTIVE_PRESS_IN| +------------> |RESPONDER_ACTIVE_LONG_PRESS_IN|
* +---------------------------+ +-------------------------+ +------------------------------+
* + ^ + ^ + ^
* |LEAVE_ |ENTER_ |LEAVE_ |ENTER_ |LEAVE_ |ENTER_
* |PRESS_RECT |PRESS_RECT |PRESS_RECT |PRESS_RECT |PRESS_RECT |PRESS_RECT
* | | | | | |
* v + v + v +
* +----------------------------+ DELAY +--------------------------+ +-------------------------------+
* |RESPONDER_INACTIVE_PRESS_OUT|+------->|RESPONDER_ACTIVE_PRESS_OUT| |RESPONDER_ACTIVE_LONG_PRESS_OUT|
* +----------------------------+ +--------------------------+ +-------------------------------+
*
* T + DELAY => LONG_PRESS_DELAY_MS + DELAY
*
* Not drawn are the side effects of each transition. The most important side
* effect is the `touchableHandlePress` abstract method invocation that occurs
* when a responder is released while in either of the "Press" states.
*
* The other important side effects are the highlight abstract method
* invocations (internal callbacks) to be implemented by the mixer.
*
*
* @lends Touchable.prototype
*/
var TouchableMixin = {
// HACK (part 1): basic support for touchable interactions using a keyboard
componentDidMount: function componentDidMount() {
(0, _warnOnce.warnOnce)('TouchableMixin', 'TouchableMixin is deprecated. Please use Pressable.');
var touchableNode = this.getTouchableNode && this.getTouchableNode();
if (touchableNode && touchableNode.addEventListener) {
this._touchableBlurListener = e => {
if (this._isTouchableKeyboardActive) {
if (this.state.touchable.touchState && this.state.touchable.touchState !== States.NOT_RESPONDER) {
this.touchableHandleResponderTerminate({
nativeEvent: e
});
}
this._isTouchableKeyboardActive = false;
}
};
touchableNode.addEventListener('blur', this._touchableBlurListener);
}
},
/**
* Clear all timeouts on unmount
*/
componentWillUnmount: function componentWillUnmount() {
var touchableNode = this.getTouchableNode && this.getTouchableNode();
if (touchableNode && touchableNode.addEventListener) {
touchableNode.removeEventListener('blur', this._touchableBlurListener);
}
this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout);
this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout);
this.pressOutDelayTimeout && clearTimeout(this.pressOutDelayTimeout);
// Clear DOM nodes
this.pressInLocation = null;
this.state.touchable.responderID = null;
},
/**
* It's prefer that mixins determine state in this way, having the class
* explicitly mix the state in the one and only `getInitialState` method.
*
* @return {object} State object to be placed inside of
* `this.state.touchable`.
*/
touchableGetInitialState: function touchableGetInitialState() {
return {
touchable: {
touchState: undefined,
responderID: null
}
};
},
// ==== Hooks to Gesture Responder system ====
/**
* Must return true if embedded in a native platform scroll view.
*/
touchableHandleResponderTerminationRequest: function touchableHandleResponderTerminationRequest() {
return !this.props.rejectResponderTermination;
},
/**
* Must return true to start the process of `Touchable`.
*/
touchableHandleStartShouldSetResponder: function touchableHandleStartShouldSetResponder() {
return !this.props.disabled;
},
/**
* Return true to cancel press on long press.
*/
touchableLongPressCancelsPress: function touchableLongPressCancelsPress() {
return true;
},
/**
* Place as callback for a DOM element's `onResponderGrant` event.
* @param {SyntheticEvent} e Synthetic event from event system.
*
*/
touchableHandleResponderGrant: function touchableHandleResponderGrant(e) {
var dispatchID = e.currentTarget;
// Since e is used in a callback invoked on another event loop
// (as in setTimeout etc), we need to call e.persist() on the
// event to make sure it doesn't get reused in the event object pool.
e.persist();
this.pressOutDelayTimeout && clearTimeout(this.pressOutDelayTimeout);
this.pressOutDelayTimeout = null;
this.state.touchable.touchState = States.NOT_RESPONDER;
this.state.touchable.responderID = dispatchID;
this._receiveSignal(Signals.RESPONDER_GRANT, e);
var delayMS = this.touchableGetHighlightDelayMS !== undefined ? Math.max(this.touchableGetHighlightDelayMS(), 0) : HIGHLIGHT_DELAY_MS;
delayMS = isNaN(delayMS) ? HIGHLIGHT_DELAY_MS : delayMS;
if (delayMS !== 0) {
this.touchableDelayTimeout = setTimeout(this._handleDelay.bind(this, e), delayMS);
} else {
this._handleDelay(e);
}
var longDelayMS = this.touchableGetLongPressDelayMS !== undefined ? Math.max(this.touchableGetLongPressDelayMS(), 10) : LONG_PRESS_DELAY_MS;
longDelayMS = isNaN(longDelayMS) ? LONG_PRESS_DELAY_MS : longDelayMS;
this.longPressDelayTimeout = setTimeout(this._handleLongDelay.bind(this, e), longDelayMS + delayMS);
},
/**
* Place as callback for a DOM element's `onResponderRelease` event.
*/
touchableHandleResponderRelease: function touchableHandleResponderRelease(e) {
this.pressInLocation = null;
this._receiveSignal(Signals.RESPONDER_RELEASE, e);
},
/**
* Place as callback for a DOM element's `onResponderTerminate` event.
*/
touchableHandleResponderTerminate: function touchableHandleResponderTerminate(e) {
this.pressInLocation = null;
this._receiveSignal(Signals.RESPONDER_TERMINATED, e);
},
/**
* Place as callback for a DOM element's `onResponderMove` event.
*/
touchableHandleResponderMove: function touchableHandleResponderMove(e) {
// Measurement may not have returned yet.
if (!this.state.touchable.positionOnActivate) {
return;
}
var positionOnActivate = this.state.touchable.positionOnActivate;
var dimensionsOnActivate = this.state.touchable.dimensionsOnActivate;
var pressRectOffset = this.touchableGetPressRectOffset ? this.touchableGetPressRectOffset() : {
left: PRESS_EXPAND_PX,
right: PRESS_EXPAND_PX,
top: PRESS_EXPAND_PX,
bottom: PRESS_EXPAND_PX
};
var pressExpandLeft = pressRectOffset.left;
var pressExpandTop = pressRectOffset.top;
var pressExpandRight = pressRectOffset.right;
var pressExpandBottom = pressRectOffset.bottom;
var hitSlop = this.touchableGetHitSlop ? this.touchableGetHitSlop() : null;
if (hitSlop) {
pressExpandLeft += hitSlop.left || 0;
pressExpandTop += hitSlop.top || 0;
pressExpandRight += hitSlop.right || 0;
pressExpandBottom += hitSlop.bottom || 0;
}
var touch = extractSingleTouch(e.nativeEvent);
var pageX = touch && touch.pageX;
var pageY = touch && touch.pageY;
if (this.pressInLocation) {
var movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this.pressInLocation.pageX, this.pressInLocation.pageY);
if (movedDistance > LONG_PRESS_ALLOWED_MOVEMENT) {
this._cancelLongPressDelayTimeout();
}
}
var isTouchWithinActive = pageX > positionOnActivate.left - pressExpandLeft && pageY > positionOnActivate.top - pressExpandTop && pageX < positionOnActivate.left + dimensionsOnActivate.width + pressExpandRight && pageY < positionOnActivate.top + dimensionsOnActivate.height + pressExpandBottom;
if (isTouchWithinActive) {
var prevState = this.state.touchable.touchState;
this._receiveSignal(Signals.ENTER_PRESS_RECT, e);
var curState = this.state.touchable.touchState;
if (curState === States.RESPONDER_INACTIVE_PRESS_IN && prevState !== States.RESPONDER_INACTIVE_PRESS_IN) {
// fix for t7967420
this._cancelLongPressDelayTimeout();
}
} else {
this._cancelLongPressDelayTimeout();
this._receiveSignal(Signals.LEAVE_PRESS_RECT, e);
}
},
/**
* Invoked when the item receives focus. Mixers might override this to
* visually distinguish the `VisualRect` so that the user knows that it
* currently has the focus. Most platforms only support a single element being
* focused at a time, in which case there may have been a previously focused
* element that was blurred just prior to this. This can be overridden when
* using `Touchable.Mixin.withoutDefaultFocusAndBlur`.
*/
touchableHandleFocus: function touchableHandleFocus(e) {
this.props.onFocus && this.props.onFocus(e);
},
/**
* Invoked when the item loses focus. Mixers might override this to
* visually distinguish the `VisualRect` so that the user knows that it
* no longer has focus. Most platforms only support a single element being
* focused at a time, in which case the focus may have moved to another.
* This can be overridden when using
* `Touchable.Mixin.withoutDefaultFocusAndBlur`.
*/
touchableHandleBlur: function touchableHandleBlur(e) {
this.props.onBlur && this.props.onBlur(e);
},
// ==== Abstract Application Callbacks ====
/**
* Invoked when the item should be highlighted. Mixers should implement this
* to visually distinguish the `VisualRect` so that the user knows that
* releasing a touch will result in a "selection" (analog to click).
*
* @abstract
* touchableHandleActivePressIn: function,
*/
/**
* Invoked when the item is "active" (in that it is still eligible to become
* a "select") but the touch has left the `PressRect`. Usually the mixer will
* want to unhighlight the `VisualRect`. If the user (while pressing) moves
* back into the `PressRect` `touchableHandleActivePressIn` will be invoked
* again and the mixer should probably highlight the `VisualRect` again. This
* event will not fire on an `touchEnd/mouseUp` event, only move events while
* the user is depressing the mouse/touch.
*
* @abstract
* touchableHandleActivePressOut: function
*/
/**
* Invoked when the item is "selected" - meaning the interaction ended by
* letting up while the item was either in the state
* `RESPONDER_ACTIVE_PRESS_IN` or `RESPONDER_INACTIVE_PRESS_IN`.
*
* @abstract
* touchableHandlePress: function
*/
/**
* Invoked when the item is long pressed - meaning the interaction ended by
* letting up while the item was in `RESPONDER_ACTIVE_LONG_PRESS_IN`. If
* `touchableHandleLongPress` is *not* provided, `touchableHandlePress` will
* be called as it normally is. If `touchableHandleLongPress` is provided, by
* default any `touchableHandlePress` callback will not be invoked. To
* override this default behavior, override `touchableLongPressCancelsPress`
* to return false. As a result, `touchableHandlePress` will be called when
* lifting up, even if `touchableHandleLongPress` has also been called.
*
* @abstract
* touchableHandleLongPress: function
*/
/**
* Returns the number of millis to wait before triggering a highlight.
*
* @abstract
* touchableGetHighlightDelayMS: function
*/
/**
* Returns the amount to extend the `HitRect` into the `PressRect`. Positive
* numbers mean the size expands outwards.
*
* @abstract
* touchableGetPressRectOffset: function
*/
// ==== Internal Logic ====
/**
* Measures the `HitRect` node on activation. The Bounding rectangle is with
* respect to viewport - not page, so adding the `pageXOffset/pageYOffset`
* should result in points that are in the same coordinate system as an
* event's `globalX/globalY` data values.
*
* - Consider caching this for the lifetime of the component, or possibly
* being able to share this cache between any `ScrollMap` view.
*
* @sideeffects
* @private
*/
_remeasureMetricsOnActivation: function _remeasureMetricsOnActivation() {
var tag = this.state.touchable.responderID;
if (tag == null) {
return;
}
_UIManager.default.measure(tag, this._handleQueryLayout);
},
_handleQueryLayout: function _handleQueryLayout(l, t, w, h, globalX, globalY) {
//don't do anything UIManager failed to measure node
if (!l && !t && !w && !h && !globalX && !globalY) {
return;
}
this.state.touchable.positionOnActivate && _Position.default.release(this.state.touchable.positionOnActivate);
this.state.touchable.dimensionsOnActivate &&
// $FlowFixMe
_BoundingDimensions.default.release(this.state.touchable.dimensionsOnActivate);
this.state.touchable.positionOnActivate = _Position.default.getPooled(globalX, globalY);
// $FlowFixMe
this.state.touchable.dimensionsOnActivate = _BoundingDimensions.default.getPooled(w, h);
},
_handleDelay: function _handleDelay(e) {
this.touchableDelayTimeout = null;
this._receiveSignal(Signals.DELAY, e);
},
_handleLongDelay: function _handleLongDelay(e) {
this.longPressDelayTimeout = null;
var curState = this.state.touchable.touchState;
if (curState !== States.RESPONDER_ACTIVE_PRESS_IN && curState !== States.RESPONDER_ACTIVE_LONG_PRESS_IN) {
console.error('Attempted to transition from state `' + curState + '` to `' + States.RESPONDER_ACTIVE_LONG_PRESS_IN + '`, which is not supported. This is ' + 'most likely due to `Touchable.longPressDelayTimeout` not being cancelled.');
} else {
this._receiveSignal(Signals.LONG_PRESS_DETECTED, e);
}
},
/**
* Receives a state machine signal, performs side effects of the transition
* and stores the new state. Validates the transition as well.
*
* @param {Signals} signal State machine signal.
* @throws Error if invalid state transition or unrecognized signal.
* @sideeffects
*/
_receiveSignal: function _receiveSignal(signal, e) {
var responderID = this.state.touchable.responderID;
var curState = this.state.touchable.touchState;
var nextState = Transitions[curState] && Transitions[curState][signal];
if (!responderID && signal === Signals.RESPONDER_RELEASE) {
return;
}
if (!nextState) {
throw new Error('Unrecognized signal `' + signal + '` or state `' + curState + '` for Touchable responder `' + responderID + '`');
}
if (nextState === States.ERROR) {
throw new Error('Touchable cannot transition from `' + curState + '` to `' + signal + '` for responder `' + responderID + '`');
}
if (curState !== nextState) {
this._performSideEffectsForTransition(curState, nextState, signal, e);
this.state.touchable.touchState = nextState;
}
},
_cancelLongPressDelayTimeout: function _cancelLongPressDelayTimeout() {
this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout);
this.longPressDelayTimeout = null;
},
_isHighlight: function _isHighlight(state) {
return state === States.RESPONDER_ACTIVE_PRESS_IN || state === States.RESPONDER_ACTIVE_LONG_PRESS_IN;
},
_savePressInLocation: function _savePressInLocation(e) {
var touch = extractSingleTouch(e.nativeEvent);
var pageX = touch && touch.pageX;
var pageY = touch && touch.pageY;
var locationX = touch && touch.locationX;
var locationY = touch && touch.locationY;
this.pressInLocation = {
pageX,
pageY,
locationX,
locationY
};
},
_getDistanceBetweenPoints: function _getDistanceBetweenPoints(aX, aY, bX, bY) {
var deltaX = aX - bX;
var deltaY = aY - bY;
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
},
/**
* Will perform a transition between touchable states, and identify any
* highlighting or unhighlighting that must be performed for this particular
* transition.
*
* @param {States} curState Current Touchable state.
* @param {States} nextState Next Touchable state.
* @param {Signal} signal Signal that triggered the transition.
* @param {Event} e Native event.
* @sideeffects
*/
_performSideEffectsForTransition: function _performSideEffectsForTransition(curState, nextState, signal, e) {
var curIsHighlight = this._isHighlight(curState);
var newIsHighlight = this._isHighlight(nextState);
var isFinalSignal = signal === Signals.RESPONDER_TERMINATED || signal === Signals.RESPONDER_RELEASE;
if (isFinalSignal) {
this._cancelLongPressDelayTimeout();
}
var isInitialTransition = curState === States.NOT_RESPONDER && nextState === States.RESPONDER_INACTIVE_PRESS_IN;
var isActiveTransition = !IsActive[curState] && IsActive[nextState];
if (isInitialTransition || isActiveTransition) {
this._remeasureMetricsOnActivation();
}
if (IsPressingIn[curState] && signal === Signals.LONG_PRESS_DETECTED) {
this.touchableHandleLongPress && this.touchableHandleLongPress(e);
}
if (newIsHighlight && !curIsHighlight) {
this._startHighlight(e);
} else if (!newIsHighlight && curIsHighlight) {
this._endHighlight(e);
}
if (IsPressingIn[curState] && signal === Signals.RESPONDER_RELEASE) {
var hasLongPressHandler = !!this.props.onLongPress;
var pressIsLongButStillCallOnPress = IsLongPressingIn[curState] && (
// We *are* long pressing.. // But either has no long handler
!hasLongPressHandler || !this.touchableLongPressCancelsPress()); // or we're told to ignore it.
var shouldInvokePress = !IsLongPressingIn[curState] || pressIsLongButStillCallOnPress;
if (shouldInvokePress && this.touchableHandlePress) {
if (!newIsHighlight && !curIsHighlight) {
// we never highlighted because of delay, but we should highlight now
this._startHighlight(e);
this._endHighlight(e);
}
this.touchableHandlePress(e);
}
}
this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout);
this.touchableDelayTimeout = null;
},
_playTouchSound: function _playTouchSound() {
_UIManager.default.playTouchSound();
},
_startHighlight: function _startHighlight(e) {
this._savePressInLocation(e);
this.touchableHandleActivePressIn && this.touchableHandleActivePressIn(e);
},
_endHighlight: function _endHighlight(e) {
if (this.touchableHandleActivePressOut) {
if (this.touchableGetPressOutDelayMS && this.touchableGetPressOutDelayMS()) {
this.pressOutDelayTimeout = setTimeout(() => {
this.touchableHandleActivePressOut(e);
}, this.touchableGetPressOutDelayMS());
} else {
this.touchableHandleActivePressOut(e);
}
}
},
// HACK (part 2): basic support for touchable interactions using a keyboard (including
// delays and longPress)
touchableHandleKeyEvent: function touchableHandleKeyEvent(e) {
var type = e.type,
key = e.key;
if (key === 'Enter' || key === ' ') {
if (type === 'keydown') {
if (!this._isTouchableKeyboardActive) {
if (!this.state.touchable.touchState || this.state.touchable.touchState === States.NOT_RESPONDER) {
this.touchableHandleResponderGrant(e);
this._isTouchableKeyboardActive = true;
}
}
} else if (type === 'keyup') {
if (this._isTouchableKeyboardActive) {
if (this.state.touchable.touchState && this.state.touchable.touchState !== States.NOT_RESPONDER) {
this.touchableHandleResponderRelease(e);
this._isTouchableKeyboardActive = false;
}
}
}
e.stopPropagation();
// prevent the default behaviour unless the Touchable functions as a link
// and Enter is pressed
if (!(key === 'Enter' && _AccessibilityUtil.default.propsToAriaRole(this.props) === 'link')) {
e.preventDefault();
}
}
},
withoutDefaultFocusAndBlur: {}
};
/**
* Provide an optional version of the mixin where `touchableHandleFocus` and
* `touchableHandleBlur` can be overridden. This allows appropriate defaults to
* be set on TV platforms, without breaking existing implementations of
* `Touchable`.
*/
var touchableHandleFocus = TouchableMixin.touchableHandleFocus,
touchableHandleBlur = TouchableMixin.touchableHandleBlur,
TouchableMixinWithoutDefaultFocusAndBlur = (0, _objectWithoutPropertiesLoose2.default)(TouchableMixin, ["touchableHandleFocus", "touchableHandleBlur"]);
TouchableMixin.withoutDefaultFocusAndBlur = TouchableMixinWithoutDefaultFocusAndBlur;
var Touchable = {
Mixin: TouchableMixin,
TOUCH_TARGET_DEBUG: false,
// Highlights all touchable targets. Toggle with Inspector.
/**
* Renders a debugging overlay to visualize touch target with hitSlop (might not work on Android).
*/
renderDebugView: _ref => {
var color = _ref.color,
hitSlop = _ref.hitSlop;
if (!Touchable.TOUCH_TARGET_DEBUG) {
return null;
}
if (process.env.NODE_ENV !== 'production') {
throw Error('Touchable.TOUCH_TARGET_DEBUG should not be enabled in prod!');
}
var debugHitSlopStyle = {};
hitSlop = hitSlop || {
top: 0,
bottom: 0,
left: 0,
right: 0
};
for (var key in hitSlop) {
debugHitSlopStyle[key] = -hitSlop[key];
}
var normalizedColor = (0, _normalizeColors.default)(color);
if (typeof normalizedColor !== 'number') {
return null;
}
var hexColor = '#' + ('00000000' + normalizedColor.toString(16)).substr(-8);
return /*#__PURE__*/_react.default.createElement(_View.default, {
pointerEvents: "none",
style: (0, _objectSpread2.default)({
position: 'absolute',
borderColor: hexColor.slice(0, -2) + '55',
// More opaque
borderWidth: 1,
borderStyle: 'dashed',
backgroundColor: hexColor.slice(0, -2) + '0F'
}, debugHitSlopStyle)
});
}
};
var _default = exports.default = Touchable;
module.exports = exports.default;
@@ -0,0 +1,152 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePressEvents = _interopRequireDefault(require("../../modules/usePressEvents"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["activeOpacity", "children", "delayPressIn", "delayPressOut", "delayLongPress", "disabled", "focusable", "onHideUnderlay", "onLongPress", "onPress", "onPressIn", "onPressOut", "onShowUnderlay", "rejectResponderTermination", "style", "testOnly_pressed", "underlayColor"];
//import { warnOnce } from '../../modules/warnOnce';
function createExtraStyles(activeOpacity, underlayColor) {
return {
child: {
opacity: activeOpacity !== null && activeOpacity !== void 0 ? activeOpacity : 0.85
},
underlay: {
backgroundColor: underlayColor === undefined ? 'black' : underlayColor
}
};
}
function hasPressHandler(props) {
return props.onPress != null || props.onPressIn != null || props.onPressOut != null || props.onLongPress != null;
}
/**
* A wrapper for making views respond properly to touches.
* On press down, the opacity of the wrapped view is decreased, which allows
* the underlay color to show through, darkening or tinting the view.
*
* The underlay comes from wrapping the child in a new View, which can affect
* layout, and sometimes cause unwanted visual artifacts if not used correctly,
* for example if the backgroundColor of the wrapped view isn't explicitly set
* to an opaque color.
*
* TouchableHighlight must have one child (not zero or more than one).
* If you wish to have several child components, wrap them in a View.
*/
function TouchableHighlight(props, forwardedRef) {
/*
warnOnce(
'TouchableHighlight',
'TouchableHighlight is deprecated. Please use Pressable.'
);
*/
var activeOpacity = props.activeOpacity,
children = props.children,
delayPressIn = props.delayPressIn,
delayPressOut = props.delayPressOut,
delayLongPress = props.delayLongPress,
disabled = props.disabled,
focusable = props.focusable,
onHideUnderlay = props.onHideUnderlay,
onLongPress = props.onLongPress,
onPress = props.onPress,
onPressIn = props.onPressIn,
onPressOut = props.onPressOut,
onShowUnderlay = props.onShowUnderlay,
rejectResponderTermination = props.rejectResponderTermination,
style = props.style,
testOnly_pressed = props.testOnly_pressed,
underlayColor = props.underlayColor,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var hostRef = (0, _react.useRef)(null);
var setRef = (0, _useMergeRefs.default)(forwardedRef, hostRef);
var _useState = (0, _react.useState)(testOnly_pressed === true ? createExtraStyles(activeOpacity, underlayColor) : null),
extraStyles = _useState[0],
setExtraStyles = _useState[1];
var showUnderlay = (0, _react.useCallback)(() => {
if (!hasPressHandler(props)) {
return;
}
setExtraStyles(createExtraStyles(activeOpacity, underlayColor));
if (onShowUnderlay != null) {
onShowUnderlay();
}
}, [activeOpacity, onShowUnderlay, props, underlayColor]);
var hideUnderlay = (0, _react.useCallback)(() => {
if (testOnly_pressed === true) {
return;
}
if (hasPressHandler(props)) {
setExtraStyles(null);
if (onHideUnderlay != null) {
onHideUnderlay();
}
}
}, [onHideUnderlay, props, testOnly_pressed]);
var pressConfig = (0, _react.useMemo)(() => ({
cancelable: !rejectResponderTermination,
disabled,
delayLongPress,
delayPressStart: delayPressIn,
delayPressEnd: delayPressOut,
onLongPress,
onPress,
onPressStart(event) {
showUnderlay();
if (onPressIn != null) {
onPressIn(event);
}
},
onPressEnd(event) {
hideUnderlay();
if (onPressOut != null) {
onPressOut(event);
}
}
}), [delayLongPress, delayPressIn, delayPressOut, disabled, onLongPress, onPress, onPressIn, onPressOut, rejectResponderTermination, showUnderlay, hideUnderlay]);
var pressEventHandlers = (0, _usePressEvents.default)(hostRef, pressConfig);
var child = React.Children.only(children);
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, pressEventHandlers, {
accessibilityDisabled: disabled,
focusable: !disabled && focusable !== false,
pointerEvents: disabled ? 'box-none' : undefined,
ref: setRef,
style: [styles.root, style, !disabled && styles.actionable, extraStyles && extraStyles.underlay]
}), /*#__PURE__*/React.cloneElement(child, {
style: [child.props.style, extraStyles && extraStyles.child]
}));
}
var styles = _StyleSheet.default.create({
root: {
userSelect: 'none'
},
actionable: {
cursor: 'pointer',
touchAction: 'manipulation'
}
});
var MemoedTouchableHighlight = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(TouchableHighlight));
MemoedTouchableHighlight.displayName = 'TouchableHighlight';
var _default = exports.default = MemoedTouchableHighlight;
module.exports = exports.default;
@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _UnimplementedView = _interopRequireDefault(require("../../modules/UnimplementedView"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _default = exports.default = _UnimplementedView.default;
module.exports = exports.default;
@@ -0,0 +1,121 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePressEvents = _interopRequireDefault(require("../../modules/usePressEvents"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _View = _interopRequireDefault(require("../View"));
var _excluded = ["activeOpacity", "delayPressIn", "delayPressOut", "delayLongPress", "disabled", "focusable", "onLongPress", "onPress", "onPressIn", "onPressOut", "rejectResponderTermination", "style"];
//import { warnOnce } from '../../modules/warnOnce';
/**
* A wrapper for making views respond properly to touches.
* On press down, the opacity of the wrapped view is decreased, dimming it.
*/
function TouchableOpacity(props, forwardedRef) {
/*
warnOnce(
'TouchableOpacity',
'TouchableOpacity is deprecated. Please use Pressable.'
);
*/
var activeOpacity = props.activeOpacity,
delayPressIn = props.delayPressIn,
delayPressOut = props.delayPressOut,
delayLongPress = props.delayLongPress,
disabled = props.disabled,
focusable = props.focusable,
onLongPress = props.onLongPress,
onPress = props.onPress,
onPressIn = props.onPressIn,
onPressOut = props.onPressOut,
rejectResponderTermination = props.rejectResponderTermination,
style = props.style,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
var hostRef = (0, _react.useRef)(null);
var setRef = (0, _useMergeRefs.default)(forwardedRef, hostRef);
var _useState = (0, _react.useState)('0s'),
duration = _useState[0],
setDuration = _useState[1];
var _useState2 = (0, _react.useState)(null),
opacityOverride = _useState2[0],
setOpacityOverride = _useState2[1];
var setOpacityTo = (0, _react.useCallback)((value, duration) => {
setOpacityOverride(value);
setDuration(duration ? duration / 1000 + "s" : '0s');
}, [setOpacityOverride, setDuration]);
var setOpacityActive = (0, _react.useCallback)(duration => {
setOpacityTo(activeOpacity !== null && activeOpacity !== void 0 ? activeOpacity : 0.2, duration);
}, [activeOpacity, setOpacityTo]);
var setOpacityInactive = (0, _react.useCallback)(duration => {
setOpacityTo(null, duration);
}, [setOpacityTo]);
var pressConfig = (0, _react.useMemo)(() => ({
cancelable: !rejectResponderTermination,
disabled,
delayLongPress,
delayPressStart: delayPressIn,
delayPressEnd: delayPressOut,
onLongPress,
onPress,
onPressStart(event) {
var isGrant = event.dispatchConfig != null ? event.dispatchConfig.registrationName === 'onResponderGrant' : event.type === 'keydown';
setOpacityActive(isGrant ? 0 : 150);
if (onPressIn != null) {
onPressIn(event);
}
},
onPressEnd(event) {
setOpacityInactive(250);
if (onPressOut != null) {
onPressOut(event);
}
}
}), [delayLongPress, delayPressIn, delayPressOut, disabled, onLongPress, onPress, onPressIn, onPressOut, rejectResponderTermination, setOpacityActive, setOpacityInactive]);
var pressEventHandlers = (0, _usePressEvents.default)(hostRef, pressConfig);
return /*#__PURE__*/React.createElement(_View.default, (0, _extends2.default)({}, rest, pressEventHandlers, {
accessibilityDisabled: disabled,
focusable: !disabled && focusable !== false,
pointerEvents: disabled ? 'box-none' : undefined,
ref: setRef,
style: [styles.root, !disabled && styles.actionable, style, opacityOverride != null && {
opacity: opacityOverride
}, {
transitionDuration: duration
}]
}));
}
var styles = _StyleSheet.default.create({
root: {
transitionProperty: 'opacity',
transitionDuration: '0.15s',
userSelect: 'none'
},
actionable: {
cursor: 'pointer',
touchAction: 'manipulation'
}
});
var MemoedTouchableOpacity = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(TouchableOpacity));
MemoedTouchableOpacity.displayName = 'TouchableOpacity';
var _default = exports.default = MemoedTouchableOpacity;
module.exports = exports.default;
@@ -0,0 +1,78 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _pick = _interopRequireDefault(require("../../modules/pick"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePressEvents = _interopRequireDefault(require("../../modules/usePressEvents"));
var _warnOnce = require("../../modules/warnOnce");
var forwardPropsList = {
accessibilityDisabled: true,
accessibilityLabel: true,
accessibilityLiveRegion: true,
accessibilityRole: true,
accessibilityState: true,
accessibilityValue: true,
children: true,
disabled: true,
focusable: true,
nativeID: true,
onBlur: true,
onFocus: true,
onLayout: true,
testID: true
};
var pickProps = props => (0, _pick.default)(props, forwardPropsList);
function TouchableWithoutFeedback(props, forwardedRef) {
(0, _warnOnce.warnOnce)('TouchableWithoutFeedback', 'TouchableWithoutFeedback is deprecated. Please use Pressable.');
var delayPressIn = props.delayPressIn,
delayPressOut = props.delayPressOut,
delayLongPress = props.delayLongPress,
disabled = props.disabled,
focusable = props.focusable,
onLongPress = props.onLongPress,
onPress = props.onPress,
onPressIn = props.onPressIn,
onPressOut = props.onPressOut,
rejectResponderTermination = props.rejectResponderTermination;
var hostRef = (0, _react.useRef)(null);
var pressConfig = (0, _react.useMemo)(() => ({
cancelable: !rejectResponderTermination,
disabled,
delayLongPress,
delayPressStart: delayPressIn,
delayPressEnd: delayPressOut,
onLongPress,
onPress,
onPressStart: onPressIn,
onPressEnd: onPressOut
}), [disabled, delayPressIn, delayPressOut, delayLongPress, onLongPress, onPress, onPressIn, onPressOut, rejectResponderTermination]);
var pressEventHandlers = (0, _usePressEvents.default)(hostRef, pressConfig);
var element = React.Children.only(props.children);
var children = [element.props.children];
var supportedProps = pickProps(props);
supportedProps.accessibilityDisabled = disabled;
supportedProps.focusable = !disabled && focusable !== false;
supportedProps.ref = (0, _useMergeRefs.default)(forwardedRef, hostRef, element.ref);
var elementProps = Object.assign(supportedProps, pressEventHandlers);
return /*#__PURE__*/React.cloneElement(element, elementProps, ...children);
}
var MemoedTouchableWithoutFeedback = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(TouchableWithoutFeedback));
MemoedTouchableWithoutFeedback.displayName = 'TouchableWithoutFeedback';
var _default = exports.default = MemoedTouchableWithoutFeedback;
module.exports = exports.default;
@@ -0,0 +1,133 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _getBoundingClientRect = _interopRequireDefault(require("../../modules/getBoundingClientRect"));
var _setValueForStyles = _interopRequireDefault(require("../../modules/setValueForStyles"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var getRect = node => {
var height = node.offsetHeight;
var width = node.offsetWidth;
var left = node.offsetLeft;
var top = node.offsetTop;
node = node.offsetParent;
while (node && node.nodeType === 1 /* Node.ELEMENT_NODE */) {
left += node.offsetLeft + node.clientLeft - node.scrollLeft;
top += node.offsetTop + node.clientTop - node.scrollTop;
node = node.offsetParent;
}
top -= window.scrollY;
left -= window.scrollX;
return {
width,
height,
top,
left
};
};
var measureLayout = (node, relativeToNativeNode, callback) => {
var relativeNode = relativeToNativeNode || node && node.parentNode;
if (node && relativeNode) {
setTimeout(() => {
if (node.isConnected && relativeNode.isConnected) {
var relativeRect = getRect(relativeNode);
var _getRect = getRect(node),
height = _getRect.height,
left = _getRect.left,
top = _getRect.top,
width = _getRect.width;
var x = left - relativeRect.left;
var y = top - relativeRect.top;
callback(x, y, width, height, left, top);
}
}, 0);
}
};
var elementsToIgnore = {
A: true,
BODY: true,
INPUT: true,
SELECT: true,
TEXTAREA: true
};
var UIManager = {
blur(node) {
try {
node.blur();
} catch (err) {}
},
focus(node) {
try {
var name = node.nodeName;
// A tabIndex of -1 allows element to be programmatically focused but
// prevents keyboard focus. We don't want to set the tabindex value on
// elements that should not prevent keyboard focus.
if (node.getAttribute('tabIndex') == null && node.isContentEditable !== true && elementsToIgnore[name] == null) {
node.setAttribute('tabIndex', '-1');
}
node.focus();
} catch (err) {}
},
measure(node, callback) {
measureLayout(node, null, callback);
},
measureInWindow(node, callback) {
if (node) {
setTimeout(() => {
var _getBoundingClientRec = (0, _getBoundingClientRect.default)(node),
height = _getBoundingClientRec.height,
left = _getBoundingClientRec.left,
top = _getBoundingClientRec.top,
width = _getBoundingClientRec.width;
callback(left, top, width, height);
}, 0);
}
},
measureLayout(node, relativeToNativeNode, onFail, onSuccess) {
measureLayout(node, relativeToNativeNode, onSuccess);
},
updateView(node, props) {
for (var prop in props) {
if (!Object.prototype.hasOwnProperty.call(props, prop)) {
continue;
}
var value = props[prop];
switch (prop) {
case 'style':
{
(0, _setValueForStyles.default)(node, value);
break;
}
case 'class':
case 'className':
{
node.setAttribute('class', value);
break;
}
case 'text':
case 'value':
// native platforms use `text` prop to replace text input value
node.value = value;
break;
default:
node.setAttribute(prop, value);
}
}
},
configureNextLayoutAnimation(config, onAnimationDidEnd) {
onAnimationDidEnd();
},
// mocks
setLayoutAnimationEnabledExperimental() {}
};
var _default = exports.default = UIManager;
module.exports = exports.default;
@@ -0,0 +1,32 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var vibrate = pattern => {
if ('vibrate' in window.navigator) {
window.navigator.vibrate(pattern);
}
};
var Vibration = {
cancel() {
vibrate(0);
},
vibrate(pattern) {
if (pattern === void 0) {
pattern = 400;
}
vibrate(pattern);
}
};
var _default = exports.default = Vibration;
module.exports = exports.default;
@@ -0,0 +1,146 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = void 0;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var forwardedProps = _interopRequireWildcard(require("../../modules/forwardedProps"));
var _pick = _interopRequireDefault(require("../../modules/pick"));
var _useElementLayout = _interopRequireDefault(require("../../modules/useElementLayout"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePlatformMethods = _interopRequireDefault(require("../../modules/usePlatformMethods"));
var _useResponderEvents = _interopRequireDefault(require("../../modules/useResponderEvents"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
var _TextAncestorContext = _interopRequireDefault(require("../Text/TextAncestorContext"));
var _useLocale = require("../../modules/useLocale");
var _excluded = ["hrefAttrs", "onLayout", "onMoveShouldSetResponder", "onMoveShouldSetResponderCapture", "onResponderEnd", "onResponderGrant", "onResponderMove", "onResponderReject", "onResponderRelease", "onResponderStart", "onResponderTerminate", "onResponderTerminationRequest", "onScrollShouldSetResponder", "onScrollShouldSetResponderCapture", "onSelectionChangeShouldSetResponder", "onSelectionChangeShouldSetResponderCapture", "onStartShouldSetResponder", "onStartShouldSetResponderCapture"];
var forwardPropsList = Object.assign({}, forwardedProps.defaultProps, forwardedProps.accessibilityProps, forwardedProps.clickProps, forwardedProps.focusProps, forwardedProps.keyboardProps, forwardedProps.mouseProps, forwardedProps.touchProps, forwardedProps.styleProps, {
href: true,
lang: true,
onScroll: true,
onWheel: true,
pointerEvents: true
});
var pickProps = props => (0, _pick.default)(props, forwardPropsList);
var View = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
var hrefAttrs = props.hrefAttrs,
onLayout = props.onLayout,
onMoveShouldSetResponder = props.onMoveShouldSetResponder,
onMoveShouldSetResponderCapture = props.onMoveShouldSetResponderCapture,
onResponderEnd = props.onResponderEnd,
onResponderGrant = props.onResponderGrant,
onResponderMove = props.onResponderMove,
onResponderReject = props.onResponderReject,
onResponderRelease = props.onResponderRelease,
onResponderStart = props.onResponderStart,
onResponderTerminate = props.onResponderTerminate,
onResponderTerminationRequest = props.onResponderTerminationRequest,
onScrollShouldSetResponder = props.onScrollShouldSetResponder,
onScrollShouldSetResponderCapture = props.onScrollShouldSetResponderCapture,
onSelectionChangeShouldSetResponder = props.onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture = props.onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder = props.onStartShouldSetResponder,
onStartShouldSetResponderCapture = props.onStartShouldSetResponderCapture,
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
if (process.env.NODE_ENV !== 'production') {
React.Children.toArray(props.children).forEach(item => {
if (typeof item === 'string') {
console.error("Unexpected text node: " + item + ". A text node cannot be a child of a <View>.");
}
});
}
var hasTextAncestor = React.useContext(_TextAncestorContext.default);
var hostRef = React.useRef(null);
var _useLocaleContext = (0, _useLocale.useLocaleContext)(),
contextDirection = _useLocaleContext.direction;
(0, _useElementLayout.default)(hostRef, onLayout);
(0, _useResponderEvents.default)(hostRef, {
onMoveShouldSetResponder,
onMoveShouldSetResponderCapture,
onResponderEnd,
onResponderGrant,
onResponderMove,
onResponderReject,
onResponderRelease,
onResponderStart,
onResponderTerminate,
onResponderTerminationRequest,
onScrollShouldSetResponder,
onScrollShouldSetResponderCapture,
onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder,
onStartShouldSetResponderCapture
});
var component = 'div';
var langDirection = props.lang != null ? (0, _useLocale.getLocaleDirection)(props.lang) : null;
var componentDirection = props.dir || langDirection;
var writingDirection = componentDirection || contextDirection;
var supportedProps = pickProps(rest);
supportedProps.dir = componentDirection;
supportedProps.style = [styles.view$raw, hasTextAncestor && styles.inline, props.style];
if (props.href != null) {
component = 'a';
if (hrefAttrs != null) {
var download = hrefAttrs.download,
rel = hrefAttrs.rel,
target = hrefAttrs.target;
if (download != null) {
supportedProps.download = download;
}
if (rel != null) {
supportedProps.rel = rel;
}
if (typeof target === 'string') {
supportedProps.target = target.charAt(0) !== '_' ? '_' + target : target;
}
}
}
var platformMethodsRef = (0, _usePlatformMethods.default)(supportedProps);
var setRef = (0, _useMergeRefs.default)(hostRef, platformMethodsRef, forwardedRef);
supportedProps.ref = setRef;
return (0, _createElement.default)(component, supportedProps, {
writingDirection
});
});
View.displayName = 'View';
var styles = _StyleSheet.default.create({
view$raw: {
alignContent: 'flex-start',
alignItems: 'stretch',
backgroundColor: 'transparent',
border: '0 solid black',
boxSizing: 'border-box',
display: 'flex',
flexBasis: 'auto',
flexDirection: 'column',
flexShrink: 0,
listStyle: 'none',
margin: 0,
minHeight: 0,
minWidth: 0,
padding: 0,
position: 'relative',
textDecoration: 'none',
zIndex: 0
},
inline: {
display: 'inline-flex'
}
});
var _default = exports.default = View;
module.exports = exports.default;
@@ -0,0 +1 @@
"use strict";
@@ -0,0 +1,18 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _VirtualizedList = _interopRequireDefault(require("../../vendor/react-native/VirtualizedList"));
var _default = exports.default = _VirtualizedList.default;
module.exports = exports.default;
@@ -0,0 +1,23 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _UnimplementedView = _interopRequireDefault(require("../../modules/UnimplementedView"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function YellowBox(props) {
return /*#__PURE__*/_react.default.createElement(_UnimplementedView.default, props);
}
YellowBox.ignoreWarnings = () => {};
var _default = exports.default = YellowBox;
module.exports = exports.default;
@@ -0,0 +1,39 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _AccessibilityUtil = _interopRequireDefault(require("../../modules/AccessibilityUtil"));
var _createDOMProps = _interopRequireDefault(require("../../modules/createDOMProps"));
var _react = _interopRequireDefault(require("react"));
var _useLocale = require("../../modules/useLocale");
var createElement = (component, props, options) => {
// Use equivalent platform elements where possible.
var accessibilityComponent;
if (component && component.constructor === String) {
accessibilityComponent = _AccessibilityUtil.default.propsToAccessibilityComponent(props);
}
var Component = accessibilityComponent || component;
var domProps = (0, _createDOMProps.default)(Component, props, options);
var element = /*#__PURE__*/_react.default.createElement(Component, domProps);
// Update locale context if element's writing direction prop changes
var elementWithLocaleProvider = domProps.dir ? /*#__PURE__*/_react.default.createElement(_useLocale.LocaleProvider, {
children: element,
direction: domProps.dir,
locale: domProps.lang
}) : element;
return elementWithLocaleProvider;
};
var _default = exports.default = createElement;
module.exports = exports.default;
@@ -0,0 +1,19 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var findNodeHandle = component => {
throw new Error('findNodeHandle is not supported on web. ' + 'Use the ref property on the component instead.');
};
var _default = exports.default = findNodeHandle;
module.exports = exports.default;
@@ -0,0 +1,31 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var processColor = color => {
if (color === undefined || color === null) {
return color;
}
// convert number and hex
var int32Color = (0, _normalizeColors.default)(color);
if (int32Color === undefined || int32Color === null) {
return undefined;
}
int32Color = (int32Color << 24 | int32Color >>> 8) >>> 0;
return int32Color;
};
var _default = exports.default = processColor;
module.exports = exports.default;
@@ -0,0 +1,27 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
exports.__esModule = true;
exports.default = render;
exports.hydrate = hydrate;
var _client = require("react-dom/client");
var _dom = require("../StyleSheet/dom");
function hydrate(element, root) {
(0, _dom.createSheet)(root);
return (0, _client.hydrateRoot)(root, element);
}
function render(element, root) {
(0, _dom.createSheet)(root);
var reactRoot = (0, _client.createRoot)(root);
reactRoot.render(element);
return reactRoot;
}
@@ -0,0 +1,18 @@
"use strict";
exports.__esModule = true;
exports.default = unmountComponentAtNode;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function unmountComponentAtNode(rootTag) {
rootTag.unmount();
return true;
}
module.exports = exports.default;
@@ -0,0 +1,34 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
exports.__esModule = true;
exports.default = useColorScheme;
var React = _interopRequireWildcard(require("react"));
var _Appearance = _interopRequireDefault(require("../Appearance"));
function useColorScheme() {
var _React$useState = React.useState(_Appearance.default.getColorScheme()),
colorScheme = _React$useState[0],
setColorScheme = _React$useState[1];
React.useEffect(() => {
function listener(appearance) {
setColorScheme(appearance.colorScheme);
}
var _Appearance$addChange = _Appearance.default.addChangeListener(listener),
remove = _Appearance$addChange.remove;
return remove;
});
return colorScheme;
}
module.exports = exports.default;
@@ -0,0 +1,17 @@
"use strict";
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
'use client';
exports.__esModule = true;
exports.default = void 0;
var _useLocale = require("../../modules/useLocale");
var _default = exports.default = _useLocale.useLocaleContext;
module.exports = exports.default;
@@ -0,0 +1,41 @@
"use strict";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = useWindowDimensions;
var _Dimensions = _interopRequireDefault(require("../Dimensions"));
var _react = require("react");
function useWindowDimensions() {
var _useState = (0, _react.useState)(() => _Dimensions.default.get('window')),
dims = _useState[0],
setDims = _useState[1];
(0, _react.useEffect)(() => {
function handleChange(_ref) {
var window = _ref.window;
if (window != null) {
setDims(window);
}
}
_Dimensions.default.addEventListener('change', handleChange);
// We might have missed an update between calling `get` in render and
// `addEventListener` in this handler, so we set it here. If there was
// no change, React will filter out this update as a no-op.
setDims(_Dimensions.default.get('window'));
return () => {
_Dimensions.default.removeEventListener('change', handleChange);
};
}, []);
return dims;
}
module.exports = exports.default;
+127
View File
@@ -0,0 +1,127 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.useWindowDimensions = exports.useLocaleContext = exports.useColorScheme = exports.unstable_createElement = exports.unmountComponentAtNode = exports.render = exports.processColor = exports.findNodeHandle = exports.YellowBox = exports.VirtualizedList = exports.View = exports.Vibration = exports.UIManager = exports.TouchableWithoutFeedback = exports.TouchableOpacity = exports.TouchableNativeFeedback = exports.TouchableHighlight = exports.Touchable = exports.TextInput = exports.Text = exports.Switch = exports.StyleSheet = exports.StatusBar = exports.Share = exports.SectionList = exports.ScrollView = exports.SafeAreaView = exports.RefreshControl = exports.ProgressBar = exports.Pressable = exports.Platform = exports.PixelRatio = exports.Picker = exports.PanResponder = exports.NativeModules = exports.NativeEventEmitter = exports.Modal = exports.LogBox = exports.Linking = exports.LayoutAnimation = exports.KeyboardAvoidingView = exports.Keyboard = exports.InteractionManager = exports.ImageBackground = exports.Image = exports.I18nManager = exports.FlatList = exports.Easing = exports.Dimensions = exports.DeviceEventEmitter = exports.Clipboard = exports.CheckBox = exports.Button = exports.BackHandler = exports.Appearance = exports.AppState = exports.AppRegistry = exports.Animated = exports.Alert = exports.ActivityIndicator = exports.AccessibilityInfo = void 0;
var _createElement = _interopRequireDefault(require("./exports/createElement"));
exports.unstable_createElement = _createElement.default;
var _findNodeHandle = _interopRequireDefault(require("./exports/findNodeHandle"));
exports.findNodeHandle = _findNodeHandle.default;
var _processColor = _interopRequireDefault(require("./exports/processColor"));
exports.processColor = _processColor.default;
var _render = _interopRequireDefault(require("./exports/render"));
exports.render = _render.default;
var _unmountComponentAtNode = _interopRequireDefault(require("./exports/unmountComponentAtNode"));
exports.unmountComponentAtNode = _unmountComponentAtNode.default;
var _NativeModules = _interopRequireDefault(require("./exports/NativeModules"));
exports.NativeModules = _NativeModules.default;
var _AccessibilityInfo = _interopRequireDefault(require("./exports/AccessibilityInfo"));
exports.AccessibilityInfo = _AccessibilityInfo.default;
var _Alert = _interopRequireDefault(require("./exports/Alert"));
exports.Alert = _Alert.default;
var _Animated = _interopRequireDefault(require("./exports/Animated"));
exports.Animated = _Animated.default;
var _Appearance = _interopRequireDefault(require("./exports/Appearance"));
exports.Appearance = _Appearance.default;
var _AppRegistry = _interopRequireDefault(require("./exports/AppRegistry"));
exports.AppRegistry = _AppRegistry.default;
var _AppState = _interopRequireDefault(require("./exports/AppState"));
exports.AppState = _AppState.default;
var _BackHandler = _interopRequireDefault(require("./exports/BackHandler"));
exports.BackHandler = _BackHandler.default;
var _Clipboard = _interopRequireDefault(require("./exports/Clipboard"));
exports.Clipboard = _Clipboard.default;
var _Dimensions = _interopRequireDefault(require("./exports/Dimensions"));
exports.Dimensions = _Dimensions.default;
var _Easing = _interopRequireDefault(require("./exports/Easing"));
exports.Easing = _Easing.default;
var _I18nManager = _interopRequireDefault(require("./exports/I18nManager"));
exports.I18nManager = _I18nManager.default;
var _Keyboard = _interopRequireDefault(require("./exports/Keyboard"));
exports.Keyboard = _Keyboard.default;
var _InteractionManager = _interopRequireDefault(require("./exports/InteractionManager"));
exports.InteractionManager = _InteractionManager.default;
var _LayoutAnimation = _interopRequireDefault(require("./exports/LayoutAnimation"));
exports.LayoutAnimation = _LayoutAnimation.default;
var _Linking = _interopRequireDefault(require("./exports/Linking"));
exports.Linking = _Linking.default;
var _NativeEventEmitter = _interopRequireDefault(require("./exports/NativeEventEmitter"));
exports.NativeEventEmitter = _NativeEventEmitter.default;
var _PanResponder = _interopRequireDefault(require("./exports/PanResponder"));
exports.PanResponder = _PanResponder.default;
var _PixelRatio = _interopRequireDefault(require("./exports/PixelRatio"));
exports.PixelRatio = _PixelRatio.default;
var _Platform = _interopRequireDefault(require("./exports/Platform"));
exports.Platform = _Platform.default;
var _Share = _interopRequireDefault(require("./exports/Share"));
exports.Share = _Share.default;
var _StyleSheet = _interopRequireDefault(require("./exports/StyleSheet"));
exports.StyleSheet = _StyleSheet.default;
var _UIManager = _interopRequireDefault(require("./exports/UIManager"));
exports.UIManager = _UIManager.default;
var _Vibration = _interopRequireDefault(require("./exports/Vibration"));
exports.Vibration = _Vibration.default;
var _ActivityIndicator = _interopRequireDefault(require("./exports/ActivityIndicator"));
exports.ActivityIndicator = _ActivityIndicator.default;
var _Button = _interopRequireDefault(require("./exports/Button"));
exports.Button = _Button.default;
var _CheckBox = _interopRequireDefault(require("./exports/CheckBox"));
exports.CheckBox = _CheckBox.default;
var _FlatList = _interopRequireDefault(require("./exports/FlatList"));
exports.FlatList = _FlatList.default;
var _Image = _interopRequireDefault(require("./exports/Image"));
exports.Image = _Image.default;
var _ImageBackground = _interopRequireDefault(require("./exports/ImageBackground"));
exports.ImageBackground = _ImageBackground.default;
var _KeyboardAvoidingView = _interopRequireDefault(require("./exports/KeyboardAvoidingView"));
exports.KeyboardAvoidingView = _KeyboardAvoidingView.default;
var _Modal = _interopRequireDefault(require("./exports/Modal"));
exports.Modal = _Modal.default;
var _Picker = _interopRequireDefault(require("./exports/Picker"));
exports.Picker = _Picker.default;
var _Pressable = _interopRequireDefault(require("./exports/Pressable"));
exports.Pressable = _Pressable.default;
var _ProgressBar = _interopRequireDefault(require("./exports/ProgressBar"));
exports.ProgressBar = _ProgressBar.default;
var _RefreshControl = _interopRequireDefault(require("./exports/RefreshControl"));
exports.RefreshControl = _RefreshControl.default;
var _SafeAreaView = _interopRequireDefault(require("./exports/SafeAreaView"));
exports.SafeAreaView = _SafeAreaView.default;
var _ScrollView = _interopRequireDefault(require("./exports/ScrollView"));
exports.ScrollView = _ScrollView.default;
var _SectionList = _interopRequireDefault(require("./exports/SectionList"));
exports.SectionList = _SectionList.default;
var _StatusBar = _interopRequireDefault(require("./exports/StatusBar"));
exports.StatusBar = _StatusBar.default;
var _Switch = _interopRequireDefault(require("./exports/Switch"));
exports.Switch = _Switch.default;
var _Text = _interopRequireDefault(require("./exports/Text"));
exports.Text = _Text.default;
var _TextInput = _interopRequireDefault(require("./exports/TextInput"));
exports.TextInput = _TextInput.default;
var _Touchable = _interopRequireDefault(require("./exports/Touchable"));
exports.Touchable = _Touchable.default;
var _TouchableHighlight = _interopRequireDefault(require("./exports/TouchableHighlight"));
exports.TouchableHighlight = _TouchableHighlight.default;
var _TouchableNativeFeedback = _interopRequireDefault(require("./exports/TouchableNativeFeedback"));
exports.TouchableNativeFeedback = _TouchableNativeFeedback.default;
var _TouchableOpacity = _interopRequireDefault(require("./exports/TouchableOpacity"));
exports.TouchableOpacity = _TouchableOpacity.default;
var _TouchableWithoutFeedback = _interopRequireDefault(require("./exports/TouchableWithoutFeedback"));
exports.TouchableWithoutFeedback = _TouchableWithoutFeedback.default;
var _View = _interopRequireDefault(require("./exports/View"));
exports.View = _View.default;
var _VirtualizedList = _interopRequireDefault(require("./exports/VirtualizedList"));
exports.VirtualizedList = _VirtualizedList.default;
var _YellowBox = _interopRequireDefault(require("./exports/YellowBox"));
exports.YellowBox = _YellowBox.default;
var _LogBox = _interopRequireDefault(require("./exports/LogBox"));
exports.LogBox = _LogBox.default;
var _DeviceEventEmitter = _interopRequireDefault(require("./exports/DeviceEventEmitter"));
exports.DeviceEventEmitter = _DeviceEventEmitter.default;
var _useColorScheme = _interopRequireDefault(require("./exports/useColorScheme"));
exports.useColorScheme = _useColorScheme.default;
var _useLocaleContext = _interopRequireDefault(require("./exports/useLocaleContext"));
exports.useLocaleContext = _useLocaleContext.default;
var _useWindowDimensions = _interopRequireDefault(require("./exports/useWindowDimensions"));
exports.useWindowDimensions = _useWindowDimensions.default;
@@ -0,0 +1,24 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _isDisabled = _interopRequireDefault(require("./isDisabled"));
var _propsToAccessibilityComponent = _interopRequireDefault(require("./propsToAccessibilityComponent"));
var _propsToAriaRole = _interopRequireDefault(require("./propsToAriaRole"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var AccessibilityUtil = {
isDisabled: _isDisabled.default,
propsToAccessibilityComponent: _propsToAccessibilityComponent.default,
propsToAriaRole: _propsToAriaRole.default
};
var _default = exports.default = AccessibilityUtil;
module.exports = exports.default;
@@ -0,0 +1,16 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var isDisabled = props => props.disabled || Array.isArray(props.accessibilityStates) && props.accessibilityStates.indexOf('disabled') > -1;
var _default = exports.default = isDisabled;
module.exports = exports.default;
@@ -0,0 +1,60 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
exports.__esModule = true;
exports.default = void 0;
var _propsToAriaRole = _interopRequireDefault(require("./propsToAriaRole"));
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var roleComponents = {
article: 'article',
banner: 'header',
blockquote: 'blockquote',
button: 'button',
code: 'code',
complementary: 'aside',
contentinfo: 'footer',
deletion: 'del',
emphasis: 'em',
figure: 'figure',
insertion: 'ins',
form: 'form',
list: 'ul',
listitem: 'li',
main: 'main',
navigation: 'nav',
paragraph: 'p',
region: 'section',
strong: 'strong'
};
var emptyObject = {};
var propsToAccessibilityComponent = function propsToAccessibilityComponent(props) {
if (props === void 0) {
props = emptyObject;
}
var roleProp = props.role || props.accessibilityRole;
// special-case for "label" role which doesn't map to an ARIA role
if (roleProp === 'label') {
return 'label';
}
var role = (0, _propsToAriaRole.default)(props);
if (role) {
if (role === 'heading') {
var level = props.accessibilityLevel || props['aria-level'];
if (level != null) {
return "h" + level;
}
return 'h1';
}
return roleComponents[role];
}
};
var _default = exports.default = propsToAccessibilityComponent;
module.exports = exports.default;
@@ -0,0 +1,41 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var accessibilityRoleToWebRole = {
adjustable: 'slider',
button: 'button',
header: 'heading',
image: 'img',
imagebutton: null,
keyboardkey: null,
label: null,
link: 'link',
none: 'presentation',
search: 'search',
summary: 'region',
text: null
};
var propsToAriaRole = _ref => {
var accessibilityRole = _ref.accessibilityRole,
role = _ref.role;
var _role = role || accessibilityRole;
if (_role) {
var inferredRole = accessibilityRoleToWebRole[_role];
if (inferredRole !== null) {
// ignore roles that don't map to web
return inferredRole || _role;
}
}
};
var _default = exports.default = propsToAriaRole;
module.exports = exports.default;
@@ -0,0 +1,23 @@
"use strict";
exports.__esModule = true;
exports.getAssetByID = getAssetByID;
exports.registerAsset = registerAsset;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var assets = [];
function registerAsset(asset) {
// `push` returns new array length, so the first asset will
// get id 1 (not 0) to make the value truthy
return assets.push(asset);
}
function getAssetByID(assetId) {
return assets[assetId - 1];
}
@@ -0,0 +1,149 @@
"use strict";
exports.__esModule = true;
exports.default = exports.ImageUriCache = void 0;
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var dataUriPattern = /^data:/;
class ImageUriCache {
static has(uri) {
var entries = ImageUriCache._entries;
var isDataUri = dataUriPattern.test(uri);
return isDataUri || Boolean(entries[uri]);
}
static add(uri) {
var entries = ImageUriCache._entries;
var lastUsedTimestamp = Date.now();
if (entries[uri]) {
entries[uri].lastUsedTimestamp = lastUsedTimestamp;
entries[uri].refCount += 1;
} else {
entries[uri] = {
lastUsedTimestamp,
refCount: 1
};
}
}
static remove(uri) {
var entries = ImageUriCache._entries;
if (entries[uri]) {
entries[uri].refCount -= 1;
}
// Free up entries when the cache is "full"
ImageUriCache._cleanUpIfNeeded();
}
static _cleanUpIfNeeded() {
var entries = ImageUriCache._entries;
var imageUris = Object.keys(entries);
if (imageUris.length + 1 > ImageUriCache._maximumEntries) {
var leastRecentlyUsedKey;
var leastRecentlyUsedEntry;
imageUris.forEach(uri => {
var entry = entries[uri];
if ((!leastRecentlyUsedEntry || entry.lastUsedTimestamp < leastRecentlyUsedEntry.lastUsedTimestamp) && entry.refCount === 0) {
leastRecentlyUsedKey = uri;
leastRecentlyUsedEntry = entry;
}
});
if (leastRecentlyUsedKey) {
delete entries[leastRecentlyUsedKey];
}
}
}
}
exports.ImageUriCache = ImageUriCache;
ImageUriCache._maximumEntries = 256;
ImageUriCache._entries = {};
var id = 0;
var requests = {};
var ImageLoader = {
abort(requestId) {
var image = requests["" + requestId];
if (image) {
image.onerror = null;
image.onload = null;
image = null;
delete requests["" + requestId];
}
},
getSize(uri, success, failure) {
var complete = false;
var interval = setInterval(callback, 16);
var requestId = ImageLoader.load(uri, callback, errorCallback);
function callback() {
var image = requests["" + requestId];
if (image) {
var naturalHeight = image.naturalHeight,
naturalWidth = image.naturalWidth;
if (naturalHeight && naturalWidth) {
success(naturalWidth, naturalHeight);
complete = true;
}
}
if (complete) {
ImageLoader.abort(requestId);
clearInterval(interval);
}
}
function errorCallback() {
if (typeof failure === 'function') {
failure();
}
ImageLoader.abort(requestId);
clearInterval(interval);
}
},
has(uri) {
return ImageUriCache.has(uri);
},
load(uri, onLoad, onError) {
id += 1;
var image = new window.Image();
image.onerror = onError;
image.onload = e => {
// avoid blocking the main thread
var onDecode = () => onLoad({
nativeEvent: e
});
if (typeof image.decode === 'function') {
// Safari currently throws exceptions when decoding svgs.
// We want to catch that error and allow the load handler
// to be forwarded to the onLoad handler in this case
image.decode().then(onDecode, onDecode);
} else {
setTimeout(onDecode, 0);
}
};
image.src = uri;
requests["" + id] = image;
return id;
},
prefetch(uri) {
return new Promise((resolve, reject) => {
ImageLoader.load(uri, () => {
// Add the uri to the cache so it can be immediately displayed when used
// but also immediately remove it to correctly reflect that it has no active references
ImageUriCache.add(uri);
ImageUriCache.remove(uri);
resolve();
}, reject);
});
},
queryCache(uris) {
var result = {};
uris.forEach(u => {
if (ImageUriCache.has(u)) {
result[u] = 'disk/memory';
}
});
return Promise.resolve(result);
}
};
var _default = exports.default = ImageLoader;

Some files were not shown because too many files have changed in this diff Show More