<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Catalog\Block\Adminhtml\Category\AssignProducts $block */

/** @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product $blockGrid */
$blockGrid = $block->getBlockGrid();
$gridJsObjectName = $blockGrid->getJsObjectName();
?>
<?= $block->getGridHtml() ?>
<input type="hidden" name="category_products" id="in_category_products" data-form-part="category_form" value="" />
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Catalog/catalog/category/assign-products": {
                "selectedProducts": <?= /* @escapeNotVerified */ $block->getProductsJson() ?>,
                "gridJsObjectName": <?= /* @escapeNotVerified */ '"' . $gridJsObjectName . '"' ?: '{}' ?>
            }
        }
    }
</script>
<!-- @todo remove when "UI components" will support such initialization -->
<script>
    require('mage/apply/main').apply();
</script>
