185 lines
5.6 KiB
React
185 lines
5.6 KiB
React
// Metro module 321 (f322).
|
|
import _classCallCheck from "./_classCallCheck";
|
|
import _createClass from "./_createClass";
|
|
import _possibleConstructorReturn from "./_possibleConstructorReturn";
|
|
import _getPrototypeOf from "./_getPrototypeOf";
|
|
import _inherits from "./_inherits";
|
|
import { PureComponent, isValidElement } from "react";
|
|
import { StyleSheet, View } from "react-native";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import Module38 from "./Module38";
|
|
import { VirtualizedListCellContextProvider } from "./Module322";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
let styles;
|
|
let CellRenderer;
|
|
let env334 = {};
|
|
env334[10] = function _isNativeReflectConstruct() {
|
|
let c12240_0;
|
|
try {
|
|
c12240_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
} catch ($e) {}
|
|
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
|
|
return !!c12240_0;
|
|
};
|
|
env334[10] = _isNativeReflectConstruct2;
|
|
return _isNativeReflectConstruct2();
|
|
};
|
|
CellRenderer = function CellRenderer(...args) {
|
|
_classCallCheck(this, CellRenderer);
|
|
const r10 = [...args];
|
|
const r9 = _getPrototypeOf(CellRenderer);
|
|
const r27 = _possibleConstructorReturn(this, (0, env334[10])() ? Reflect.construct(r9, r10, _getPrototypeOf(this).constructor) : r9.apply(this, r10));
|
|
r27.state = {
|
|
separatorProps: {
|
|
highlighted: false,
|
|
leadingItem: r27.props.item
|
|
}
|
|
};
|
|
r27._separators = {
|
|
highlight: () => {
|
|
const props = this.props;
|
|
this.props.onUpdateSeparators([props.cellKey, props.prevCellKey], {
|
|
highlighted: true
|
|
});
|
|
},
|
|
unhighlight: () => {
|
|
const props = this.props;
|
|
this.props.onUpdateSeparators([props.cellKey, props.prevCellKey], {
|
|
highlighted: false
|
|
});
|
|
},
|
|
updateProps: (a0, a1) => {
|
|
const props2 = this.props;
|
|
let cellKey = props2.cellKey;
|
|
const prevCellKey = props2.prevCellKey;
|
|
const props = this.props;
|
|
if (a0 === "leading") {
|
|
cellKey = prevCellKey;
|
|
}
|
|
props.onUpdateSeparators([cellKey], a1);
|
|
}
|
|
};
|
|
r27._onLayout = (a0) => {
|
|
const props = this.props;
|
|
const onCellLayout = props.onCellLayout;
|
|
if (onCellLayout != null) {
|
|
onCellLayout.call(props, a0, this.props.cellKey, this.props.index);
|
|
}
|
|
};
|
|
r27._onCellFocusCapture = (a0) => {
|
|
const props = this.props;
|
|
const onCellFocusCapture = props.onCellFocusCapture;
|
|
if (onCellFocusCapture != null) {
|
|
onCellFocusCapture.call(props, this.props.cellKey);
|
|
}
|
|
};
|
|
return r27;
|
|
};
|
|
_inherits(CellRenderer, PureComponent);
|
|
const r53 = _createClass(CellRenderer, [{
|
|
key: "updateSeparatorProps",
|
|
value: function updateSeparatorProps(c23655_0) {
|
|
this.setState((state) => ({
|
|
separatorProps: {
|
|
...state.separatorProps,
|
|
...c23655_0
|
|
}
|
|
}));
|
|
}
|
|
}, {
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
this.props.onUnmount(this.props.cellKey);
|
|
}
|
|
}, {
|
|
key: "_renderElement",
|
|
value: function _renderElement(a0, a1, a2, a3) {
|
|
let r21;
|
|
if (a0 ? a1 : a0) {
|
|
console.warn("VirtualizedList: Both ListItemComponent and renderItem props are present. ListItemComponent will take precedence over renderItem.");
|
|
}
|
|
if (a1) {
|
|
r21 = (0, jsx)(a1, {
|
|
item: a2,
|
|
index: a3,
|
|
separators: this._separators
|
|
});
|
|
} else if (a0) {
|
|
r21 = a0({
|
|
item: a2,
|
|
index: a3,
|
|
separators: this._separators
|
|
});
|
|
} else {
|
|
Module38(false, "VirtualizedList: Either ListItemComponent or renderItem props are required but none were found.");
|
|
r21 = void 0;
|
|
}
|
|
return r21;
|
|
}
|
|
}, {
|
|
key: "render",
|
|
value: function render() {
|
|
let children, style;
|
|
const props = this.props;
|
|
const { CellRendererComponent, ItemSeparatorComponent, ListItemComponent, cellKey, horizontal, item, index, inversionStyle } = props;
|
|
let onCellLayout = props.onCellLayout;
|
|
const r9 = this._renderElement(props.renderItem, ListItemComponent, item, index);
|
|
const r8 = (0, isValidElement)(ItemSeparatorComponent) ? ItemSeparatorComponent : ItemSeparatorComponent ? <ItemSeparatorComponent {...this.state.separatorProps} /> : ItemSeparatorComponent;
|
|
if (inversionStyle) {
|
|
style = horizontal ? [styles.rowReverse, inversionStyle] : [styles.columnReverse, inversionStyle];
|
|
} else {
|
|
style = horizontal ? [styles.row, inversionStyle] : inversionStyle;
|
|
}
|
|
if (CellRendererComponent) {
|
|
const r50 = {
|
|
cellKey,
|
|
index,
|
|
item,
|
|
style,
|
|
onFocusCapture: this._onCellFocusCapture
|
|
};
|
|
if (onCellLayout) {
|
|
onCellLayout = {
|
|
onLayout: this._onLayout
|
|
};
|
|
}
|
|
HermesBuiltin.copyDataProperties(r50, onCellLayout);
|
|
r50.children = [r9, r8];
|
|
children = <CellRendererComponent {...r50} />;
|
|
} else {
|
|
children = <View style={style} onFocusCapture={this._onCellFocusCapture} {...onCellLayout ? {
|
|
onLayout: this._onLayout
|
|
} : onCellLayout}>
|
|
{r9}
|
|
{r8}
|
|
</View>;
|
|
}
|
|
return (0, jsx)(VirtualizedListCellContextProvider, {
|
|
cellKey: this.props.cellKey,
|
|
children
|
|
});
|
|
}
|
|
}], [{
|
|
key: "getDerivedStateFromProps",
|
|
value: function getDerivedStateFromProps(a0, a1) {
|
|
return a0.item !== a1.separatorProps.leadingItem ? {
|
|
separatorProps: {
|
|
...a1.separatorProps,
|
|
leadingItem: a0.item
|
|
}
|
|
} : null;
|
|
}
|
|
}]);
|
|
styles = StyleSheet.create({
|
|
row: {
|
|
flexDirection: "row"
|
|
},
|
|
rowReverse: {
|
|
flexDirection: "row-reverse"
|
|
},
|
|
columnReverse: {
|
|
flexDirection: "column-reverse"
|
|
}
|
|
});
|
|
export default r53;
|