367 lines
13 KiB
React
367 lines
13 KiB
React
// Metro module 326 (f327).
|
|
import _objectWithoutProperties from "./_objectWithoutProperties";
|
|
import _classCallCheck from "./_classCallCheck";
|
|
import _createClass from "./_createClass";
|
|
import _possibleConstructorReturn from "./_possibleConstructorReturn";
|
|
import _getPrototypeOf from "./_getPrototypeOf";
|
|
import _inherits from "./_inherits";
|
|
import { PureComponent, useState, useEffect, isValidElement } from "react";
|
|
import Module38 from "./Module38";
|
|
import * as _elementsThatOverlapOffsets from "./elementsThatOverlapOffsets";
|
|
import VirtualizedList from "./VirtualizedList";
|
|
let ItemWithSeparator, _excluded;
|
|
let VirtualizedSectionList;
|
|
let env341 = {};
|
|
env341[15] = function _isNativeReflectConstruct() {
|
|
let c12244_0;
|
|
try {
|
|
c12244_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
} catch ($e) {}
|
|
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
|
|
return !!c12244_0;
|
|
};
|
|
env341[15] = _isNativeReflectConstruct2;
|
|
return _isNativeReflectConstruct2();
|
|
};
|
|
ItemWithSeparator = function ItemWithSeparator(props) {
|
|
const { LeadingSeparatorComponent, SeparatorComponent, cellKey, prevCellKey, setSelfHighlightCallback, updateHighlightFor, setSelfUpdatePropsCallback, updatePropsFor, item, index, section, inverted } = props;
|
|
let [highlighted2, c12245_8] = useState(false);
|
|
let [highlighted, c12245_9] = useState(false);
|
|
let [props2, c12245_11] = useState({
|
|
leadingItem: props.leadingItem,
|
|
leadingSection: props.leadingSection,
|
|
section: props.section,
|
|
trailingItem: props.item,
|
|
trailingSection: props.trailingSection
|
|
});
|
|
let c12245_10 = props2;
|
|
const [props3, setState] = useState({
|
|
leadingItem: props.item,
|
|
leadingSection: props.leadingSection,
|
|
section: props.section,
|
|
trailingItem: props.trailingItem,
|
|
trailingSection: props.trailingSection
|
|
});
|
|
let c12245_12 = props3;
|
|
let c12245_13 = setState;
|
|
(0, useEffect)(() => {
|
|
setSelfHighlightCallback(cellKey, c12245_9);
|
|
setSelfUpdatePropsCallback(cellKey, c12245_13);
|
|
return () => {
|
|
setSelfUpdatePropsCallback(cellKey, null);
|
|
setSelfHighlightCallback(cellKey, null);
|
|
};
|
|
}, [cellKey, setSelfHighlightCallback, setState, setSelfUpdatePropsCallback]);
|
|
const r60 = props.renderItem({
|
|
item,
|
|
index,
|
|
section,
|
|
separators: {
|
|
highlight: () => {
|
|
c12245_8(true);
|
|
c12245_9(true);
|
|
if (prevCellKey != null) {
|
|
updateHighlightFor(prevCellKey, true);
|
|
}
|
|
},
|
|
unhighlight: () => {
|
|
c12245_8(false);
|
|
c12245_9(false);
|
|
if (prevCellKey != null) {
|
|
updateHighlightFor(prevCellKey, false);
|
|
}
|
|
},
|
|
updateProps: (a0, a1) => {
|
|
if (a0 === "leading") {
|
|
if (LeadingSeparatorComponent != null) {
|
|
c12245_11({
|
|
...c12245_10,
|
|
...a1
|
|
});
|
|
} else if (prevCellKey != null) {
|
|
updatePropsFor(prevCellKey, {
|
|
...c12245_10,
|
|
...a1
|
|
});
|
|
}
|
|
} else if (a0 === "trailing" && SeparatorComponent != null) {
|
|
c12245_13({
|
|
...c12245_12,
|
|
...a1
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
let r62 = LeadingSeparatorComponent != null && (isValidElement(LeadingSeparatorComponent) ? LeadingSeparatorComponent : <LeadingSeparatorComponent highlighted={highlighted2} {...props2} />);
|
|
const r70 = SeparatorComponent != null && (isValidElement(SeparatorComponent) ? SeparatorComponent : <SeparatorComponent highlighted={highlighted} {...props3} />);
|
|
const r80 = r62 ? r62 : r70;
|
|
const r85 = [r80 ? inverted === false ? r62 : r70 : null, r60, ,];
|
|
let r86 = null;
|
|
if (r80) {
|
|
if (inverted === false) {
|
|
r62 = r70;
|
|
}
|
|
r86 = r62;
|
|
}
|
|
r85[2] = r86;
|
|
return <>{r85}</>;
|
|
};
|
|
_excluded = ["ItemSeparatorComponent", "SectionSeparatorComponent", "renderItem", "renderSectionFooter", "renderSectionHeader", "sections", "stickySectionHeadersEnabled"];
|
|
VirtualizedSectionList = function VirtualizedSectionList(...args) {
|
|
_classCallCheck(this, VirtualizedSectionList);
|
|
const r10 = [...args];
|
|
const r9 = _getPrototypeOf(VirtualizedSectionList);
|
|
const r27 = _possibleConstructorReturn(this, (0, env341[15])() ? Reflect.construct(r9, r10, _getPrototypeOf(this).constructor) : r9.apply(this, r10));
|
|
r27._keyExtractor = (a0, a1) => {
|
|
const r5 = this._subExtractor(a1);
|
|
return r5 && r5.key || String(a1);
|
|
};
|
|
r27._convertViewable = (a0) => {
|
|
let key;
|
|
Module38(a0.index != null, "Received a broken ViewToken");
|
|
const r19 = this._subExtractor(a0.index);
|
|
if (r19) {
|
|
const keyExtractor = r19.section.keyExtractor;
|
|
const r23 = this.props.keyExtractor || _elementsThatOverlapOffsets.keyExtractor;
|
|
if (keyExtractor != null) {
|
|
key = keyExtractor(a0.item, r19.index);
|
|
} else {
|
|
const item = a0.item;
|
|
let index = r19.index;
|
|
if (index == null) {
|
|
index = 0;
|
|
}
|
|
key = r23(item, index);
|
|
}
|
|
return {
|
|
...a0,
|
|
index: r19.index,
|
|
key,
|
|
section: r19.section
|
|
};
|
|
}
|
|
return null;
|
|
};
|
|
r27._onViewableItemsChanged = ({ viewableItems, changed }) => {
|
|
const onViewableItemsChanged = this.props.onViewableItemsChanged;
|
|
if (onViewableItemsChanged != null) {
|
|
onViewableItemsChanged({
|
|
viewableItems: viewableItems.map(this._convertViewable, this).filter(Boolean),
|
|
changed: changed.map(this._convertViewable, this).filter(Boolean)
|
|
});
|
|
}
|
|
};
|
|
r27._renderItem = (c28641_0) => ({ item, index }) => {
|
|
const r5 = this._subExtractor(index);
|
|
if (r5) {
|
|
const index2 = r5.index;
|
|
if (index2 == null) {
|
|
const section = r5.section;
|
|
if (r5.header === true) {
|
|
const renderSectionHeader = this.props.renderSectionHeader;
|
|
return renderSectionHeader ? renderSectionHeader({
|
|
section
|
|
}) : null;
|
|
}
|
|
const renderSectionFooter = this.props.renderSectionFooter;
|
|
return renderSectionFooter ? renderSectionFooter({
|
|
section
|
|
}) : null;
|
|
}
|
|
const renderItem = r5.section.renderItem || this.props.renderItem;
|
|
const SeparatorComponent2 = this._getSeparatorComponent(index, r5, c28641_0);
|
|
Module38(renderItem, "no renderItem!");
|
|
return <ItemWithSeparator SeparatorComponent={SeparatorComponent2} LeadingSeparatorComponent={index2 === 0 ? this.props.SectionSeparatorComponent : void 0} cellKey={r5.key} index={index2} item={item} leadingItem={r5.leadingItem} leadingSection={r5.leadingSection} prevCellKey={(this._subExtractor(index - 1) || {}).key} setSelfHighlightCallback={this._setUpdateHighlightFor} setSelfUpdatePropsCallback={this._setUpdatePropsFor} updateHighlightFor={this._updateHighlightFor} updatePropsFor={this._updatePropsFor} renderItem={renderItem} section={r5.section} trailingItem={r5.trailingItem} trailingSection={r5.trailingSection} inverted={!!this.props.inverted} />;
|
|
}
|
|
return null;
|
|
};
|
|
r27._updatePropsFor = (a0, a1) => {
|
|
const r5 = this._updatePropsMap[a0];
|
|
if (r5 != null) {
|
|
r5(a1);
|
|
}
|
|
};
|
|
r27._updateHighlightFor = (a0, a1) => {
|
|
const r5 = this._updateHighlightMap[a0];
|
|
if (r5 != null) {
|
|
r5(a1);
|
|
}
|
|
};
|
|
r27._setUpdateHighlightFor = (a0, a1) => {
|
|
if (a1 != null) {
|
|
this._updateHighlightMap[a0] = a1;
|
|
} else {
|
|
delete this._updateHighlightFor[a0];
|
|
}
|
|
};
|
|
r27._setUpdatePropsFor = (a0, a1) => {
|
|
if (a1 != null) {
|
|
this._updatePropsMap[a0] = a1;
|
|
} else {
|
|
delete this._updatePropsMap[a0];
|
|
}
|
|
};
|
|
r27._updateHighlightMap = {};
|
|
r27._updatePropsMap = {};
|
|
r27._captureRef = (a0) => {
|
|
this._listRef = a0;
|
|
};
|
|
return r27;
|
|
};
|
|
_inherits(VirtualizedSectionList, PureComponent);
|
|
export default _createClass(VirtualizedSectionList, [{
|
|
key: "scrollToLocation",
|
|
value: function scrollToLocation(a0) {
|
|
let sectionIndex;
|
|
let itemIndex = a0.itemIndex;
|
|
const r5 = 0 < a0.sectionIndex;
|
|
let r0 = 0;
|
|
let index = itemIndex;
|
|
if (r5) {
|
|
do {
|
|
itemIndex = itemIndex + (this.props.getItemCount(this.props.sections[r0].data) + 2);
|
|
r0 = r0 + 1;
|
|
sectionIndex = a0.sectionIndex;
|
|
index = itemIndex;
|
|
} while (r0 < sectionIndex);
|
|
}
|
|
const r24 = a0.viewOffset || 0;
|
|
if (this._listRef != null) {
|
|
const _listRef = this._listRef;
|
|
this._listRef.scrollToIndex({
|
|
...a0,
|
|
viewOffset: a0.itemIndex > 0 ? this.props.stickySectionHeadersEnabled ? r24 + _listRef.__getListMetrics().getCellMetricsApprox(index - a0.itemIndex, _listRef.props).length : r24 : r24,
|
|
index
|
|
});
|
|
}
|
|
}
|
|
}, {
|
|
key: "getListRef",
|
|
value: function getListRef() {
|
|
return this._listRef;
|
|
}
|
|
}, {
|
|
key: "render",
|
|
value: function render() {
|
|
const props = this.props;
|
|
props.ItemSeparatorComponent;
|
|
props.SectionSeparatorComponent;
|
|
props.renderItem;
|
|
props.renderSectionFooter;
|
|
props.renderSectionHeader;
|
|
props.sections;
|
|
props.stickySectionHeadersEnabled;
|
|
const rest = _objectWithoutProperties(props, _excluded);
|
|
const r11 = this.props.ListHeaderComponent ? 1 : 0;
|
|
const stickyHeaderIndices = this.props.stickySectionHeadersEnabled ? [] : void 0;
|
|
let r42 = 0;
|
|
let c23662_0 = 0;
|
|
for (const section of this.props.sections) {
|
|
if (stickyHeaderIndices != null) {
|
|
stickyHeaderIndices.push(r42 + r11);
|
|
}
|
|
const r55 = r42 + 2;
|
|
c23662_0 = r55;
|
|
const r60 = r55 + this.props.getItemCount(section.data);
|
|
r42 = r60;
|
|
c23662_0 = r60;
|
|
}
|
|
return <VirtualizedList {...rest} keyExtractor={this._keyExtractor} stickyHeaderIndices={stickyHeaderIndices} renderItem={this._renderItem(r42)} data={this.props.sections} getItem={(a0, a1) => this._getItem(this.props, a0, a1)} getItemCount={() => c23662_0} onViewableItemsChanged={this.props.onViewableItemsChanged ? this._onViewableItemsChanged : void 0} ref={this._captureRef} />;
|
|
}
|
|
}, {
|
|
key: "_getItem",
|
|
value: function _getItem(a0, a1, a2) {
|
|
if (a1) {
|
|
let r1 = a2 - 1;
|
|
const length = a1.length;
|
|
let r0 = 0;
|
|
if (0 < length) {
|
|
while (true) {
|
|
const r16 = a1[r0];
|
|
const data = r16.data;
|
|
const itemCount = a0.getItemCount(data);
|
|
const r3 = r0;
|
|
const r2 = r1;
|
|
if (r2 !== -1 && r2 !== itemCount) {
|
|
if (r2 < itemCount) {
|
|
return a0.getItem(data, r2);
|
|
}
|
|
r1 = r2 - (itemCount + 2);
|
|
r0 = r3 + 1;
|
|
if (r0 < a1.length) {
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
return r16;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
}, {
|
|
key: "_subExtractor",
|
|
value: function _subExtractor(r13) {
|
|
const props = this.props;
|
|
const { getItem: getItem2, getItemCount: getItemCount2, keyExtractor, sections } = props;
|
|
const length = sections.length;
|
|
let r0 = 0;
|
|
if (0 < length) {
|
|
do {
|
|
const section = sections[r0];
|
|
const data = section.data;
|
|
let key = section.key;
|
|
const r2 = r0;
|
|
const r14 = r13;
|
|
if (!key) {
|
|
key = String(r2);
|
|
}
|
|
const index = r14 - 1;
|
|
if (!(index >= getItemCount2(data) + 1)) {
|
|
return index === -1 ? {
|
|
section,
|
|
key: key + ":header",
|
|
index: null,
|
|
header: true,
|
|
trailingSection: sections[r2 + 1]
|
|
} : index === getItemCount2(data) ? {
|
|
section,
|
|
key: key + ":footer",
|
|
index: null,
|
|
header: false,
|
|
trailingSection: sections[r2 + 1]
|
|
} : {
|
|
section,
|
|
key: key + ":" + (section.keyExtractor || keyExtractor || _elementsThatOverlapOffsets.keyExtractor)(getItem2(data, index), index),
|
|
index,
|
|
leadingItem: getItem2(data, index - 1),
|
|
leadingSection: sections[r2 - 1],
|
|
trailingItem: getItem2(data, index + 1),
|
|
trailingSection: sections[r2 + 1]
|
|
};
|
|
}
|
|
r13 = index - (getItemCount2(data) + 1);
|
|
r0 = r2 + 1;
|
|
} while (r0 < sections.length);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_getSeparatorComponent",
|
|
value: function _getSeparatorComponent(a0, a1, a2) {
|
|
const r8 = a1 ? a1 : this._subExtractor(a0);
|
|
if (r8) {
|
|
const r6 = r8.section.ItemSeparatorComponent || this.props.ItemSeparatorComponent;
|
|
let SectionSeparatorComponent = this.props.SectionSeparatorComponent;
|
|
const r1 = a2 - 1;
|
|
const r3 = r8.index === this.props.getItemCount(r8.section.data) - 1;
|
|
if (!(SectionSeparatorComponent && r3)) {
|
|
SectionSeparatorComponent = r6 ? r3 ? null : a0 !== r1 ? r6 : null : null;
|
|
}
|
|
return SectionSeparatorComponent;
|
|
}
|
|
return null;
|
|
}
|
|
}]);
|