// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Disableable } from '../../../Behaviors/Disableable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { TextElement } from '../../Primitives/Text/TextElement';
import { ItemsElement } from '../Abstracts/Items/ItemsElement';
import { ListElement } from '../List/ListElement';
import { dataListElementTemplate } from './DataListElementTemplate';
import { dataListElementJoyStyle } from './Themes/DataListElement.Joy';
import { dataListElementMemphisStyle } from './Themes/DataListElement.Memphis';
import { dataListElementCosmopolitanStyle } from './Themes/DataListElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * Data List - A structured list component for displaying tabular data with configurable columns.
 *
 * @description
 * The Data List component provides a flexible way to display tabular data in a list format.
 * It supports dynamic item definitions with configurable columns, alternating row styles, and
 * data binding from various sources. Each row is rendered as a list item with cells corresponding
 * to the defined item definitions. The component is ideal for displaying structured data sets
 * where each record has multiple fields that need to be presented in a consistent format.
 *
 * @name Data List
 * @element mosaik-data-list
 * @category Selectors
 *
 * @csspart list - The inner list container element
 *
 * @dependency {ListElement} - The underlying list component for rendering rows
 * @dependency {TextElement} - Text rendering component for cell content
 *
 * @fires connected {ConnectedEvent} - Fired when the data list is connected to the DOM
 * @fires changed {PropertyChangedEvent} - Fired when data list properties change
 *
 * @example
 * Basic data list with item definitions:
 * ```html
 * <mosaik-data-list id="userList"></mosaik-data-list>
 * <script>
 *   const list = document.getElementById('userList');
 *   list.itemDefinitions = [
 *     { key: 'name', path: 'name' },
 *     { key: 'email', path: 'email' },
 *     { key: 'role', path: 'role' }
 *   ];
 *   list.source = [
 *     { name: 'John Doe', email: 'john@example.com', role: 'Admin' },
 *     { name: 'Jane Smith', email: 'jane@example.com', role: 'User' }
 *   ];
 * </script>
 * ```
 *
 * @example
 * Data list with alternating rows:
 * ```html
 * <mosaik-data-list alternating id="products"></mosaik-data-list>
 * <script>
 *   const list = document.getElementById('products');
 *   list.itemDefinitions = [
 *     { key: 'sku', path: 'sku' },
 *     { key: 'product', path: 'name' },
 *     { key: 'price', path: 'price' }
 *   ];
 *   list.source = productData;
 * </script>
 * ```
 *
 * @public
 */
let DataListElement = class DataListElement extends Themeable(Disableable(ItemsElement)) {
    // #region Fields
    _alternating;
    _itemDefinitions;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._alternating = false;
        this._itemDefinitions = new Array();
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-data-list';
    }
    /**
     * Gets or sets the `alternating` property.
     *
     * @public
     * @attr
     */
    get alternating() {
        return this._alternating;
    }
    set alternating(value) {
        if (this._alternating !== value) {
            this._alternating = value;
            this.requestUpdate('alternating');
        }
    }
    /**
     * Gets or sets the `itemDefinitions` property.
     *
     * @public
     */
    get itemDefinitions() {
        return this._itemDefinitions;
    }
    set itemDefinitions(value) {
        if (this._itemDefinitions !== value) {
            this._itemDefinitions = value;
            this.requestUpdate('itemDefinitions');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @template
     * @private
     */
    getItemDefinitions() {
        // let definitions;
        // if (this._autoGenerateColumns) {
        //     // TODO: find a way to get all object keys of array.
        //     // const first = this.source[0];
        //     // const firstKeys = Object.keys(first);
        //     // return firstKeys;
        //     const row = this.source[0];
        //     columns = Object.getOwnPropertyNames(row).map(x => ({
        //         key: x,
        //         path: x
        //     }));
        //     return;
        // }
        const definitions = this._itemDefinitions.map((x) => ({
            ...x,
            ...{ path: x.path ?? x.key }
        }));
        return definitions;
    }
};
__decorate([
    Attribute({ type: Boolean,
        useDefault: true }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], DataListElement.prototype, "alternating", null);
__decorate([
    Property({ type: Array }),
    __metadata("design:type", Array),
    __metadata("design:paramtypes", [Array])
], DataListElement.prototype, "itemDefinitions", null);
DataListElement = __decorate([
    Component({
        selector: 'mosaik-data-list',
        template: dataListElementTemplate,
        themes: {
            joy: dataListElementJoyStyle,
            memphis: dataListElementMemphisStyle,
            cosmopolitan: dataListElementCosmopolitanStyle
        },
        imports: [
            ListElement,
            TextElement
        ]
    }),
    __metadata("design:paramtypes", [])
], DataListElement);
export { DataListElement };
//# sourceMappingURL=DataListElement.js.map