import { Component, Input } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ProductVariantListQueryDocument, TypedBaseListComponent, } from '@vendure/admin-ui/core';
import * as i0 from "@angular/core";
import * as i1 from "@clr/angular";
import * as i2 from "@angular/common";
import * as i3 from "@angular/router";
import * as i4 from "@vendure/admin-ui/core";
import * as i5 from "@ngx-translate/core";
export class ProductVariantListComponent extends TypedBaseListComponent {
    constructor() {
        super();
        this.hideLanguageSelect = false;
        this.customFields = this.getCustomFieldConfig('ProductVariant');
        this.filters = this.createFilterCollection()
            .addIdFilter()
            .addDateFilters()
            .addFilters([
            {
                name: 'name',
                type: { kind: 'text' },
                label: _('common.name'),
                filterField: 'name',
            },
            {
                name: 'enabled',
                type: { kind: 'boolean' },
                label: _('common.enabled'),
                filterField: 'enabled',
            },
            {
                name: 'sku',
                type: { kind: 'text' },
                label: _('catalog.sku'),
                filterField: 'sku',
            },
            {
                name: 'price',
                type: { kind: 'number', inputType: 'currency' },
                label: _('common.price'),
                filterField: 'price',
            },
            {
                name: 'priceWithTax',
                type: { kind: 'number', inputType: 'currency' },
                label: _('common.price-with-tax'),
                filterField: 'priceWithTax',
            },
        ])
            .addCustomFieldFilters(this.customFields)
            .connectToRoute(this.route);
        this.sorts = this.createSortCollection()
            .addSorts([
            { name: 'id' },
            { name: 'createdAt' },
            { name: 'updatedAt' },
            { name: 'name' },
            { name: 'sku' },
            { name: 'price' },
            { name: 'priceWithTax' },
        ])
            .addCustomFieldSorts(this.customFields)
            .connectToRoute(this.route);
        this.configure({
            document: ProductVariantListQueryDocument,
            getItems: data => data.productVariants,
            setVariables: (skip, take) => ({
                options: {
                    skip,
                    take,
                    filter: {
                        sku: {
                            contains: this.searchTermControl.value,
                        },
                        ...this.filters.createFilterInput(),
                        ...(this.productId ? { productId: { eq: this.productId } } : {}),
                    },
                    sort: this.sorts.createSortInput(),
                },
            }),
            refreshListOnChanges: [this.sorts.valueChanges, this.filters.valueChanges],
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: ProductVariantListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: ProductVariantListComponent, selector: "vdr-product-variant-list", inputs: { productId: "productId", hideLanguageSelect: "hideLanguageSelect", dataTableId: "dataTableId" }, usesInheritance: true, ngImport: i0, template: "<vdr-page-block *ngIf=\"!hideLanguageSelect\">\n    <vdr-language-selector\n        [availableLanguageCodes]=\"availableLanguages$ | async\"\n        [currentLanguageCode]=\"contentLanguage$ | async\"\n        (languageCodeChange)=\"setLanguage($event)\"\n    ></vdr-language-selector>\n</vdr-page-block>\n<vdr-data-table-2\n    class=\"mt-2\"\n    [id]=\"dataTableId || 'product-variant-list'\"\n    [items]=\"items$ | async\"\n    [itemsPerPage]=\"itemsPerPage$ | async\"\n    [totalItems]=\"totalItems$ | async\"\n    [currentPage]=\"currentPage$ | async\"\n    [filters]=\"filters\"\n    (pageChange)=\"setPageNumber($event)\"\n    (itemsPerPageChange)=\"setItemsPerPage($event)\"\n>\n    <vdr-bulk-action-menu\n        locationId=\"product-variant-list\"\n        [hostComponent]=\"this\"\n        [selectionManager]=\"selectionManager\"\n    />\n    <vdr-dt2-search\n        [searchTermControl]=\"searchTermControl\"\n        [searchTermPlaceholder]=\"'catalog.filter-by-sku' | translate\"\n    />\n    <vdr-dt2-column [heading]=\"'common.id' | translate\" id=\"id\" [hiddenByDefault]=\"true\" [sort]=\"sorts.get('id')\">\n        <ng-template let-variant=\"item\">\n            {{ variant.id }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column\n        [heading]=\"'common.created-at' | translate\" id=\"created-at\"\n        [hiddenByDefault]=\"true\"\n        [sort]=\"sorts.get('createdAt')\"\n    >\n        <ng-template let-variant=\"item\">\n            {{ variant.createdAt | localeDate : 'short' }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column\n        [heading]=\"'common.updated-at' | translate\" id=\"updated-at\"\n        [hiddenByDefault]=\"true\"\n        [sort]=\"sorts.get('updatedAt')\"\n    >\n        <ng-template let-variant=\"item\">\n            {{ variant.updatedAt | localeDate : 'short' }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'common.image' | translate\" id=\"image\">\n        <ng-template let-variant=\"item\">\n            <div class=\"image-placeholder\">\n                <img\n                    *ngIf=\"variant.featuredAsset as asset; else imagePlaceholder\"\n                    [src]=\"asset | assetPreview : 'tiny'\"\n                />\n                <ng-template #imagePlaceholder>\n                    <div class=\"placeholder\">\n                        <clr-icon shape=\"image\" size=\"48\"></clr-icon>\n                    </div>\n                </ng-template>\n            </div>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'catalog.name' | translate\" id=\"name\" [optional]=\"false\" [sort]=\"sorts.get('name')\">\n        <ng-template let-variant=\"item\">\n            <a\n                class=\"button-ghost\"\n                [routerLink]=\"['/catalog/products', variant.productId, 'variants', variant.id]\"\n                ><span>{{ variant.name }}</span\n                ><clr-icon shape=\"arrow right\"\n            /></a>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'catalog.sku' | translate\" id=\"sku\" [sort]=\"sorts.get('sku')\">\n        <ng-template let-variant=\"item\">\n            {{ variant.sku }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'common.enabled' | translate\" id=\"enabled\">\n        <ng-template let-variant=\"item\">\n            <vdr-chip *ngIf=\"variant.enabled\" colorType=\"success\">{{\n                'common.enabled' | translate\n            }}</vdr-chip>\n            <vdr-chip *ngIf=\"!variant.enabled\" colorType=\"warning\">{{\n                'common.disabled' | translate\n            }}</vdr-chip>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column\n        [heading]=\"'common.price' | translate\" id=\"price\"\n        [hiddenByDefault]=\"true\"\n        [sort]=\"sorts.get('price')\"\n    >\n        <ng-template let-variant=\"item\">\n            {{ variant.price | localeCurrency : variant.currencyCode }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'common.price-with-tax' | translate\" id=\"price-with-tax\" [sort]=\"sorts.get('priceWithTax')\">\n        <ng-template let-variant=\"item\">\n            {{ variant.priceWithTax | localeCurrency : variant.currencyCode }}\n        </ng-template>\n    </vdr-dt2-column>\n\n    <vdr-dt2-column [heading]=\"'catalog.stock-on-hand' | translate\" id=\"stock-on-hand\" [hiddenByDefault]=\"false\">\n        <ng-template let-variant=\"item\">\n            <vdr-chip *ngFor=\"let stockLevel of variant.stockLevels\" [title]=\"stockLevel.stockLocation?.name\">\n                <div class=\"flex center\">\n                    <div>\n                        {{ stockLevel.stockOnHand\n                        }}<span class=\"ml-1\" *ngIf=\"stockLevel.stockAllocated\"\n                            >({{ stockLevel.stockAllocated }} allocated)</span\n                        >\n                    </div>\n                </div>\n            </vdr-chip>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-custom-field-column *ngFor=\"let field of customFields\" [customField]=\"field\" [sorts]=\"sorts\" />\n</vdr-data-table-2>\n", styles: [".image-col{width:70px}.image-placeholder{width:50px;height:50px;margin-top:calc(var(--space-unit) * -1);margin-bottom:calc(var(--space-unit) * -1);background-color:var(--color-component-bg-200)}.image-placeholder img{border-radius:var(--border-radius-img)}.image-placeholder .placeholder{text-align:center;color:var(--color-grey-300)}.search-form{display:flex;align-items:center;width:100%}vdr-product-search-input{min-width:300px}@media screen and (max-width: 768px){vdr-product-search-input{min-width:100px}}.search-settings-menu{margin:0 12px}td.disabled{background-color:var(--color-component-bg-200)}.search-index-button{position:relative}.search-index-button vdr-status-badge{right:0;top:0}.run-updates-button{position:relative}.run-updates-button vdr-status-badge{left:10px;top:10px}.edit-button{margin-inline-end:24px}.sku{color:var(--color-text-300)}\n"], dependencies: [{ kind: "directive", type: i1.ClrIconCustomTag, selector: "clr-icon" }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i4.ChipComponent, selector: "vdr-chip", inputs: ["icon", "invert", "colorFrom", "colorType"], outputs: ["iconClick"] }, { kind: "component", type: i4.LanguageSelectorComponent, selector: "vdr-language-selector", inputs: ["currentLanguageCode", "availableLanguageCodes", "disabled"], outputs: ["languageCodeChange"] }, { kind: "component", type: i4.BulkActionMenuComponent, selector: "vdr-bulk-action-menu", inputs: ["locationId", "selectionManager", "hostComponent"] }, { kind: "component", type: i4.DataTable2Component, selector: "vdr-data-table-2", inputs: ["id", "items", "itemsPerPage", "currentPage", "totalItems", "emptyStateLabel", "filters", "activeIndex"], outputs: ["pageChange", "itemsPerPageChange"] }, { kind: "component", type: i4.DataTable2ColumnComponent, selector: "vdr-dt2-column", inputs: ["id", "expand", "heading", "align", "sort", "optional", "hiddenByDefault", "orderable"], exportAs: ["row"] }, { kind: "component", type: i4.DataTable2SearchComponent, selector: "vdr-dt2-search", inputs: ["searchTermControl", "searchTermPlaceholder"] }, { kind: "component", type: i4.DataTableCustomFieldColumnComponent, selector: "vdr-dt2-custom-field-column", inputs: ["customField", "sorts"], exportAs: ["row"] }, { kind: "component", type: i4.PageBlockComponent, selector: "vdr-page-block" }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }, { kind: "pipe", type: i4.AssetPreviewPipe, name: "assetPreview" }, { kind: "pipe", type: i4.LocaleDatePipe, name: "localeDate" }, { kind: "pipe", type: i4.LocaleCurrencyPipe, name: "localeCurrency" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: ProductVariantListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-product-variant-list', template: "<vdr-page-block *ngIf=\"!hideLanguageSelect\">\n    <vdr-language-selector\n        [availableLanguageCodes]=\"availableLanguages$ | async\"\n        [currentLanguageCode]=\"contentLanguage$ | async\"\n        (languageCodeChange)=\"setLanguage($event)\"\n    ></vdr-language-selector>\n</vdr-page-block>\n<vdr-data-table-2\n    class=\"mt-2\"\n    [id]=\"dataTableId || 'product-variant-list'\"\n    [items]=\"items$ | async\"\n    [itemsPerPage]=\"itemsPerPage$ | async\"\n    [totalItems]=\"totalItems$ | async\"\n    [currentPage]=\"currentPage$ | async\"\n    [filters]=\"filters\"\n    (pageChange)=\"setPageNumber($event)\"\n    (itemsPerPageChange)=\"setItemsPerPage($event)\"\n>\n    <vdr-bulk-action-menu\n        locationId=\"product-variant-list\"\n        [hostComponent]=\"this\"\n        [selectionManager]=\"selectionManager\"\n    />\n    <vdr-dt2-search\n        [searchTermControl]=\"searchTermControl\"\n        [searchTermPlaceholder]=\"'catalog.filter-by-sku' | translate\"\n    />\n    <vdr-dt2-column [heading]=\"'common.id' | translate\" id=\"id\" [hiddenByDefault]=\"true\" [sort]=\"sorts.get('id')\">\n        <ng-template let-variant=\"item\">\n            {{ variant.id }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column\n        [heading]=\"'common.created-at' | translate\" id=\"created-at\"\n        [hiddenByDefault]=\"true\"\n        [sort]=\"sorts.get('createdAt')\"\n    >\n        <ng-template let-variant=\"item\">\n            {{ variant.createdAt | localeDate : 'short' }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column\n        [heading]=\"'common.updated-at' | translate\" id=\"updated-at\"\n        [hiddenByDefault]=\"true\"\n        [sort]=\"sorts.get('updatedAt')\"\n    >\n        <ng-template let-variant=\"item\">\n            {{ variant.updatedAt | localeDate : 'short' }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'common.image' | translate\" id=\"image\">\n        <ng-template let-variant=\"item\">\n            <div class=\"image-placeholder\">\n                <img\n                    *ngIf=\"variant.featuredAsset as asset; else imagePlaceholder\"\n                    [src]=\"asset | assetPreview : 'tiny'\"\n                />\n                <ng-template #imagePlaceholder>\n                    <div class=\"placeholder\">\n                        <clr-icon shape=\"image\" size=\"48\"></clr-icon>\n                    </div>\n                </ng-template>\n            </div>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'catalog.name' | translate\" id=\"name\" [optional]=\"false\" [sort]=\"sorts.get('name')\">\n        <ng-template let-variant=\"item\">\n            <a\n                class=\"button-ghost\"\n                [routerLink]=\"['/catalog/products', variant.productId, 'variants', variant.id]\"\n                ><span>{{ variant.name }}</span\n                ><clr-icon shape=\"arrow right\"\n            /></a>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'catalog.sku' | translate\" id=\"sku\" [sort]=\"sorts.get('sku')\">\n        <ng-template let-variant=\"item\">\n            {{ variant.sku }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'common.enabled' | translate\" id=\"enabled\">\n        <ng-template let-variant=\"item\">\n            <vdr-chip *ngIf=\"variant.enabled\" colorType=\"success\">{{\n                'common.enabled' | translate\n            }}</vdr-chip>\n            <vdr-chip *ngIf=\"!variant.enabled\" colorType=\"warning\">{{\n                'common.disabled' | translate\n            }}</vdr-chip>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column\n        [heading]=\"'common.price' | translate\" id=\"price\"\n        [hiddenByDefault]=\"true\"\n        [sort]=\"sorts.get('price')\"\n    >\n        <ng-template let-variant=\"item\">\n            {{ variant.price | localeCurrency : variant.currencyCode }}\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-column [heading]=\"'common.price-with-tax' | translate\" id=\"price-with-tax\" [sort]=\"sorts.get('priceWithTax')\">\n        <ng-template let-variant=\"item\">\n            {{ variant.priceWithTax | localeCurrency : variant.currencyCode }}\n        </ng-template>\n    </vdr-dt2-column>\n\n    <vdr-dt2-column [heading]=\"'catalog.stock-on-hand' | translate\" id=\"stock-on-hand\" [hiddenByDefault]=\"false\">\n        <ng-template let-variant=\"item\">\n            <vdr-chip *ngFor=\"let stockLevel of variant.stockLevels\" [title]=\"stockLevel.stockLocation?.name\">\n                <div class=\"flex center\">\n                    <div>\n                        {{ stockLevel.stockOnHand\n                        }}<span class=\"ml-1\" *ngIf=\"stockLevel.stockAllocated\"\n                            >({{ stockLevel.stockAllocated }} allocated)</span\n                        >\n                    </div>\n                </div>\n            </vdr-chip>\n        </ng-template>\n    </vdr-dt2-column>\n    <vdr-dt2-custom-field-column *ngFor=\"let field of customFields\" [customField]=\"field\" [sorts]=\"sorts\" />\n</vdr-data-table-2>\n", styles: [".image-col{width:70px}.image-placeholder{width:50px;height:50px;margin-top:calc(var(--space-unit) * -1);margin-bottom:calc(var(--space-unit) * -1);background-color:var(--color-component-bg-200)}.image-placeholder img{border-radius:var(--border-radius-img)}.image-placeholder .placeholder{text-align:center;color:var(--color-grey-300)}.search-form{display:flex;align-items:center;width:100%}vdr-product-search-input{min-width:300px}@media screen and (max-width: 768px){vdr-product-search-input{min-width:100px}}.search-settings-menu{margin:0 12px}td.disabled{background-color:var(--color-component-bg-200)}.search-index-button{position:relative}.search-index-button vdr-status-badge{right:0;top:0}.run-updates-button{position:relative}.run-updates-button vdr-status-badge{left:10px;top:10px}.edit-button{margin-inline-end:24px}.sku{color:var(--color-text-300)}\n"] }]
        }], ctorParameters: function () { return []; }, propDecorators: { productId: [{
                type: Input
            }], hideLanguageSelect: [{
                type: Input
            }], dataTableId: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 