@wordpress/block-editor
Version:
74 lines (70 loc) • 1.66 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _element = require("@wordpress/element");
var _data = require("@wordpress/data");
var _blockListContext = require("./block-list-context");
var _store = require("../../store");
var _jsxRuntime = require("react/jsx-runtime");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockListItemCell({
children,
item: clientId,
onLayout
}) {
const {
blocksLayouts,
updateBlocksLayouts
} = (0, _blockListContext.useBlockListContext)();
const {
rootClientId
} = (0, _data.useSelect)(select => {
const {
getBlockRootClientId
} = select(_store.store);
return {
rootClientId: getBlockRootClientId(clientId)
};
}, [clientId]);
(0, _element.useEffect)(() => {
return () => {
updateBlocksLayouts(blocksLayouts, {
clientId,
shouldRemove: true
});
};
}, []);
const onCellLayout = (0, _element.useCallback)(event => {
const {
nativeEvent: {
layout
}
} = event;
updateBlocksLayouts(blocksLayouts, {
clientId,
rootClientId,
...layout
});
if (onLayout) {
onLayout(event);
}
}, [clientId, rootClientId, updateBlocksLayouts, onLayout]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
testID: "block-list-item-cell",
onLayout: onCellLayout,
children: children
});
}
var _default = exports.default = BlockListItemCell;
//# sourceMappingURL=block-list-item-cell.native.js.map
;