{"version":3,"file":"ng-nest-ui-timeline.mjs","sources":["../../../../lib/ng-nest/ui/timeline/timeline.property.ts","../../../../lib/ng-nest/ui/timeline/timeline.component.ts","../../../../lib/ng-nest/ui/timeline/timeline.component.html","../../../../lib/ng-nest/ui/timeline/timeline.module.ts","../../../../lib/ng-nest/ui/timeline/ng-nest-ui-timeline.ts"],"sourcesContent":["import { XPropertyFunction, XToBoolean, XToDataArray } from '@ng-nest/ui/core';\r\nimport { Component, input } from '@angular/core';\r\nimport type { XType, XSize, XTemplate, XIdentityProperty, XDate, XDataArray, XBoolean } from '@ng-nest/ui/core';\r\nimport type { XLoadingType } from '@ng-nest/ui/loading';\r\n\r\n/**\r\n * Timeline\r\n * @selector x-timeline\r\n * @decorator component\r\n */\r\nexport const XTimelinePrefix = 'x-timeline';\r\nconst X_TIMELINE_CONFIG_NAME = 'timeline';\r\n\r\n/**\r\n * Timeline Property\r\n */\r\n@Component({ selector: `${XTimelinePrefix}-property`, template: '' })\r\nexport class XTimelineProperty extends XPropertyFunction(X_TIMELINE_CONFIG_NAME) {\r\n  /**\r\n   * @zh_CN 数据\r\n   * @en_US Date\r\n   */\r\n  readonly data = input<XTimelineNode[], XDataArray<XTimelineNode>>([], { transform: XToDataArray });\r\n  /**\r\n   * @zh_CN 内容模板\r\n   * @en_US Content template\r\n   */\r\n  readonly wrapper = input<XTemplate>();\r\n  /**\r\n   * @zh_CN 图标模板\r\n   * @en_US Icon template\r\n   */\r\n  readonly icon = input<XTemplate>();\r\n  /**\r\n   * @zh_CN 显示序号\r\n   * @en_US Show number\r\n   */\r\n  readonly showNumber = input<boolean, XBoolean>(this.config?.showNumber ?? false, { transform: XToBoolean });\r\n  /**\r\n   * @zh_CN 时间轴的相对位置\r\n   * @en_US Content and timeline relative position\r\n   */\r\n  readonly mode = input<XTimelineMode>(this.config?.mode ?? 'left');\r\n  /**\r\n   * @zh_CN loading 的类型样式\r\n   * @en_US Loading type style\r\n   */\r\n  readonly loadingType = input<XLoadingType>(this.config?.loadingType ?? 'circular');\r\n  /**\r\n   * @zh_CN 尺寸\r\n   * @en_US Size\r\n   */\r\n  readonly size = input<XSize>(this.config?.size ?? 'medium');\r\n}\r\n\r\n/**\r\n * @zh_CN Timeline 数据对象\r\n * @en_US Timeline node data\r\n */\r\nexport interface XTimelineNode extends XIdentityProperty {\r\n  /**\r\n   * @zh_CN 时间\r\n   * @en_US Time\r\n   */\r\n  time?: XDate;\r\n  /**\r\n   * @zh_CN 内容\r\n   * @en_US Content\r\n   */\r\n  content?: string;\r\n  /**\r\n   * @zh_CN 类型\r\n   * @en_US Type\r\n   */\r\n  type?: XType;\r\n  /**\r\n   * @zh_CN 图标\r\n   * @en_US Icon\r\n   */\r\n  icon?: string;\r\n  /**\r\n   * @zh_CN 颜色\r\n   * @en_US Color\r\n   */\r\n  color?: string;\r\n  /**\r\n   * @zh_CN 加载中\r\n   * @en_US Loading\r\n   */\r\n  loading?: boolean;\r\n  /**\r\n   * @zh_CN 连接线显示虚线，针对下一个节点，下一个节点为 loading 状态也会显示虚线\r\n   * @en_US The connecting line displays a dotted line. For the next node, the dotted line will also be displayed when the next node is in loading status\r\n   */\r\n  dashed?: boolean;\r\n  /**\r\n   * @zh_CN 其它自定义属性\r\n   * @en_US Other property\r\n   */\r\n  [property: string]: any;\r\n}\r\n\r\n/**\r\n * @zh_CN 时间轴的相对位置\r\n * @en_US Content and timeline relative position\r\n */\r\nexport type XTimelineMode = 'left' | 'right' | 'alternate';\r\n","import { Component, ViewEncapsulation, ChangeDetectionStrategy, computed } from '@angular/core';\r\nimport { XTimelinePrefix, XTimelineNode, XTimelineProperty } from './timeline.property';\r\nimport { XIsEmpty } from '@ng-nest/ui/core';\r\nimport { DatePipe, NgClass } from '@angular/common';\r\nimport { XIconComponent } from '@ng-nest/ui/icon';\r\nimport { XTimeAgoPipe } from '@ng-nest/ui/time-ago';\r\nimport { XLinkComponent } from '@ng-nest/ui/link';\r\nimport { XOutletDirective } from '@ng-nest/ui/outlet';\r\nimport { XLoadingComponent } from '@ng-nest/ui/loading';\r\n\r\n@Component({\r\n  selector: `${XTimelinePrefix}`,\r\n  imports: [NgClass, DatePipe, XIconComponent, XTimeAgoPipe, XLinkComponent, XLoadingComponent, XOutletDirective],\r\n  templateUrl: './timeline.component.html',\r\n  styleUrls: ['./timeline.component.scss'],\r\n  encapsulation: ViewEncapsulation.None,\r\n  changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class XTimelineComponent extends XTimelineProperty {\r\n  classMap = computed(() => ({\r\n    [`${XTimelinePrefix}-${this.mode()}`]: !XIsEmpty(this.mode()),\r\n    [`${XTimelinePrefix}-${this.size()}`]: !XIsEmpty(this.size())\r\n  }));\r\n\r\n  nodes = computed(() => {\r\n    const data = this.data();\r\n    this.setDashed(data);\r\n    return data;\r\n  });\r\n\r\n  private setDashed(nodes: XTimelineNode[]) {\r\n    const len = nodes.length;\r\n    if (len <= 1) return;\r\n    for (let i = 0; i < nodes.length; i++) {\r\n      let node = nodes[i];\r\n      if (!node.loading) continue;\r\n      if (i === 0) {\r\n        node.dashed = true;\r\n      } else if (i > 0) {\r\n        nodes[i - 1].dashed = true;\r\n      }\r\n    }\r\n  }\r\n}\r\n","<div #timeline class=\"x-timeline\" [class.x-timeline-number]=\"showNumber()\" [ngClass]=\"classMap()\">\r\n  <ul>\r\n    @for (node of nodes(); track node.id) {\r\n      <li [class.x-timeline-loading]=\"node.loading\">\r\n        <div class=\"x-timeline-tail\" [class.x-timeline-tail-dashed]=\"node.dashed\"></div>\r\n        @if (icon()) {\r\n          <div class=\"x-timeline-icon\">\r\n            <ng-container *xOutlet=\"icon(); context: { $node: node, $index }\"></ng-container>\r\n          </div>\r\n        } @else {\r\n          <div\r\n            class=\"x-timeline-icon {{ node.type ? 'x-timeline-' + node.type : '' }}\"\r\n            [style.background-color]=\"node.color\"\r\n          >\r\n            @if (showNumber() && !node.icon && !node.loading) {\r\n              {{ $index + 1 }}\r\n            }\r\n            @if (node.icon && !node.loading) {\r\n              <x-icon [type]=\"node.icon\"></x-icon>\r\n            }\r\n            @if (node.loading) {\r\n              <x-loading inline [x-loading]=\"true\" [type]=\"loadingType()\"></x-loading>\r\n            }\r\n          </div>\r\n        }\r\n        <div class=\"x-timeline-wrapper\">\r\n          <ng-container *xOutlet=\"wrapper(); context: { $node: node, $index }\">\r\n            <div class=\"x-timeline-label\">\r\n              @if (node.label) {\r\n                <x-link>{{ node.label }}</x-link>\r\n              }\r\n              <span class=\"x-timeline-time\" [title]=\"node.time | date: 'yyyy-MM-dd HH:mm:ss'\">{{\r\n                node.time | xTimeAgo\r\n              }}</span>\r\n            </div>\r\n            <div class=\"x-timeline-content\">{{ node.content }}</div>\r\n          </ng-container>\r\n        </div>\r\n      </li>\r\n    }\r\n  </ul>\r\n</div>\r\n","import { NgModule } from '@angular/core';\r\nimport { XTimelineComponent } from './timeline.component';\r\n\r\n@NgModule({\r\n  exports: [XTimelineComponent],\r\n  imports: [XTimelineComponent]\r\n})\r\nexport class XTimelineModule {}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAKA;;;;AAIG;AACI,MAAM,eAAe,GAAG;AAC/B,MAAM,sBAAsB,GAAG,UAAU;AAEzC;;AAEG;MAEU,iBAAkB,SAAQ,iBAAiB,CAAC,sBAAsB,CAAC,CAAA;AADhF,IAAA,WAAA,GAAA;;AAEE;;;AAGG;QACM,IAAA,CAAA,IAAI,GAAG,KAAK,CAA6C,EAAE,iDAAI,SAAS,EAAE,YAAY,EAAA,CAAG;AAClG;;;AAGG;QACM,IAAA,CAAA,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAa;AACrC;;;AAGG;QACM,IAAA,CAAA,IAAI,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,MAAA,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