{"version":3,"file":"odx-angular-cdk-expandable.mjs","sources":["../../../../libs/angular/cdk/expandable/src/lib/expandable.tokens.ts","../../../../libs/angular/cdk/expandable/src/lib/directives/expandable-container.directive.ts","../../../../libs/angular/cdk/expandable/src/lib/directives/expandable-item.directive.ts","../../../../libs/angular/cdk/expandable/src/lib/expandable.module.ts","../../../../libs/angular/cdk/expandable/src/odx-angular-cdk-expandable.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { ExpandableContainer, ExpandableItem } from './facade';\n\nexport const ODX_EXPANDABLE_CONTAINER = new InjectionToken<ExpandableContainer>('@odx/angular/cdk/expandable::ExpandableContainer');\nexport const ODX_EXPANDABLE_ITEM = new InjectionToken<ExpandableItem>('@odx/angular/cdk/expandable::ExpandableItem');\n","import { booleanAttribute, Directive, inject, Input, OnDestroy, OnInit } from '@angular/core';\nimport { ODX_EXPANDABLE_CONTAINER, ODX_EXPANDABLE_ITEM } from '../expandable.tokens';\nimport type { ExpandableContainer, ExpandableItem } from '../facade';\n\n/**\n * `ExpandableContainerDirective` provides a container for managing a group of expandable items,\n * allowing them to expand or collapse. It supports the functionality to either allow multiple\n * items to be expanded simultaneously or restrict to a single item at a time.\n *\n * This directive uses Angular's dependency injection to optionally inject a parent `ExpandableItem` or `ExpandableContainer`,\n * enabling nested expandable structures. The `multiple` property can be set to dictate the expand/collapse behavior.\n */\n@Directive({\n  standalone: true,\n  selector: '[odxExpandableContainer]',\n  exportAs: 'odxExpandableContainer',\n  providers: [{ provide: ODX_EXPANDABLE_CONTAINER, useExisting: ExpandableContainerDirective }],\n})\nexport class ExpandableContainerDirective implements ExpandableContainer, OnInit, OnDestroy {\n  private readonly expandedItems = new Set<ExpandableItem>();\n  private readonly parentItem = inject(ODX_EXPANDABLE_ITEM, { optional: true, skipSelf: true });\n  private readonly parentContainer = inject(ODX_EXPANDABLE_CONTAINER, { optional: true, skipSelf: true });\n\n  /**\n   * Determines whether multiple items can be expanded within the container.\n   *\n   * @type {boolean}\n   * @default false\n   */\n  @Input({ transform: booleanAttribute })\n  public multiple = this.parentContainer?.multiple ?? false;\n\n  public ngOnInit(): void {\n    this.parentItem?.addChild(this);\n  }\n\n  public ngOnDestroy(): void {\n    this.parentItem?.removeChild(this);\n  }\n\n  /**\n   * Collapses all the expanded items within the expandable container.\n   */\n  public collapseAll(): void {\n    this.expandedItems.forEach((item) => item.collapse());\n  }\n\n  /**\n   * Collapses the specified item.\n   *\n   * @param {ExpandableItem} item - The item to collapse.\n   */\n  public collapse(item: ExpandableItem): void {\n    this.expandedItems.delete(item);\n  }\n\n  /**\n   * Expands the specified item.\n   * If `multiple` is set to `false`, it collapses all other items before expanding the specified item.\n   * @param {ExpandableItem} item - The item to expand.\n   */\n  public expand(item: ExpandableItem): void {\n    if (!this.multiple) {\n      this.collapseAll();\n    }\n    this.expandedItems.add(item);\n  }\n\n  /**\n   * Toggles the expansion state of the specified item.\n   * If `forceState` is provided, it will set the expansion state to the specified value.\n   * If `forceState` is not provided, it will toggle the expansion state of the item.\n   *\n   * @param {ExpandableItem} item - The item to toggle the expansion state for.\n   * @param {boolean} forceState - Optional. The desired expansion state to set for the item.\n   */\n  public toggle(item: ExpandableItem, forceState?: boolean): void {\n    const shouldExpand = forceState ?? !this.isExpanded(item);\n    if (shouldExpand) {\n      this.expand(item);\n    } else {\n      this.collapse(item);\n    }\n  }\n\n  /**\n   * Checks if the specified item is expanded.\n   * @param {ExpandableItem} item - The item to check.\n   * @returns `true` if the item is expanded, `false` otherwise.\n   */\n  public isExpanded(item: ExpandableItem): boolean {\n    return this.expandedItems.has(item);\n  }\n\n  /**\n   * Checks if there is any expanded item.\n   *\n   * @returns {boolean} True if there is at least one expanded item, false otherwise.\n   */\n  public hasExpandedItem(): boolean {\n    return this.expandedItems.size > 0;\n  }\n}\n","import { booleanAttribute, ChangeDetectorRef, Directive, inject, Input } from '@angular/core';\nimport { getUniqueId } from '@odx/angular/utils';\nimport { ODX_EXPANDABLE_CONTAINER, ODX_EXPANDABLE_ITEM } from '../expandable.tokens';\nimport type { ExpandableContainer, ExpandableItem } from '../facade';\n\n/**\n * `ExpandableItemDirective` allows you to manage the expansion state of an item within an expandable container, such as an accordion or a nested list. It provides methods to expand, collapse, and toggle the item, and automatically registers itself with a parent expandable container if one is available.\n *\n * You can control the expanded state programmatically by binding to the `expanded` property.\n */\n@Directive({\n  standalone: true,\n  selector: '[odxExpandableItem]',\n  exportAs: 'odxExpandableItem',\n  providers: [{ provide: ODX_EXPANDABLE_ITEM, useExisting: ExpandableItemDirective }],\n})\nexport class ExpandableItemDirective implements ExpandableItem {\n  private readonly changeDetectorRef = inject(ChangeDetectorRef);\n  private readonly childContainers = new Set<ExpandableContainer>();\n  private _expanded = false;\n\n  /**\n   * Container which can be set manually.\n   */\n  @Input()\n  public container: ExpandableContainer | null = inject(ODX_EXPANDABLE_CONTAINER, { optional: true, skipSelf: true });\n\n  /** Unique identifier for the expandable item.\n   *\n   * @type {string}\n   */\n  @Input()\n  public id = getUniqueId('odx-expandable-item');\n\n  /**\n   * Controls the expanded state of the item.\n   *\n   * @param {boolean} value - When `true`, expands the item; when `false`, collapses the item.\n   *\n   * @example\n   * Bind to the expanded state:\n   * ```html\n   * <div odxExpandableItem [expanded]=\"isItemExpanded\"></div>\n   * ```\n   */\n  @Input({ transform: booleanAttribute })\n  public set expanded(value: boolean) {\n    if (this._expanded === value) return;\n    this._expanded = value;\n    if (this._expanded) {\n      this.container?.expand(this);\n    } else {\n      this.closeAllChildren();\n      this.container?.collapse(this);\n    }\n    this.changeDetectorRef.markForCheck();\n  }\n\n  /**\n   * Gets a value indicating whether the item is expanded.\n   * If the item is contained within a container, it checks the container's `isExpanded` method.\n   * Otherwise, it returns the value of the `_expanded` property.\n   *\n   * @type {boolean} `true` if the item is expanded; otherwise, `false`.\n   */\n  public get expanded(): boolean {\n    return this.container?.isExpanded(this) ?? this._expanded;\n  }\n\n  /**\n   * Toggles the expansion state of the item, optionally forcing a specific state.\n   *\n   * @param {boolean} forceState - When provided, forces the expansion state to the specified value.\n   */\n  public toggle(forceState?: boolean): void {\n    this.expanded = forceState ?? !this.expanded;\n  }\n\n  /** Expands the item.\n   *\n   * @returns {void}\n   */\n  public expand(): void {\n    this.toggle(true);\n  }\n\n  /** Collapses the item.\n   *\n   * @returns {void}\n   */\n  public collapse(): void {\n    this.toggle(false);\n  }\n\n  /** Adds a child container to the item.\n   *\n   * @param {ExpandableContainer} container - The child container to add.\n   * @returns {void}\n   */\n  public addChild(container: ExpandableContainer): void {\n    this.childContainers.add(container);\n  }\n\n  /** Removes a child container from the item.\n   *\n   * @param {ExpandableContainer} container - The child container to remove.\n   * @returns {void}\n   */\n  public removeChild(container: ExpandableContainer): void {\n    this.childContainers.delete(container);\n  }\n\n  private closeAllChildren(): void {\n    this.childContainers.forEach((container) => container.collapseAll());\n  }\n}\n","import { NgModule } from '@angular/core';\nimport { ExpandableContainerDirective, ExpandableItemDirective } from './directives';\n\nconst modules = [ExpandableContainerDirective, ExpandableItemDirective];\n\n@NgModule({\n  imports: modules,\n  exports: modules,\n})\nexport class ExpandableModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAGa,wBAAwB,GAAG,IAAI,cAAc,CAAsB,kDAAkD;MACrH,mBAAmB,GAAG,IAAI,cAAc,CAAiB,6CAA6C;;ACAnH;;;;;;;AAOG;MAOU,4BAA4B,CAAA;AANzC,IAAA,WAAA,GAAA;AAOmB,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,GAAG,EAAkB;AACzC,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5E,QAAA,IAAA,CAAA,eAAe,GAAG,MAAM,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEvG;;;;;AAKG;QAEI,IAAA,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