ng-zorro-antd-skeleton.mjs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import * as i0 from '@angular/core';
  2. import { booleanAttribute, Input, Directive, ChangeDetectionStrategy, Component, ViewEncapsulation, NgModule } from '@angular/core';
  3. import { toCssPixel } from 'ng-zorro-antd/core/util';
  4. /**
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  7. */
  8. class NzSkeletonElementDirective {
  9. nzActive = false;
  10. nzType;
  11. nzBlock = false;
  12. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  13. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.2", type: NzSkeletonElementDirective, isStandalone: true, selector: "nz-skeleton-element", inputs: { nzActive: ["nzActive", "nzActive", booleanAttribute], nzType: "nzType", nzBlock: ["nzBlock", "nzBlock", booleanAttribute] }, host: { properties: { "class.ant-skeleton-active": "nzActive", "class.ant-skeleton-block": "nzBlock" }, classAttribute: "ant-skeleton ant-skeleton-element" }, ngImport: i0 });
  14. }
  15. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementDirective, decorators: [{
  16. type: Directive,
  17. args: [{
  18. selector: 'nz-skeleton-element',
  19. host: {
  20. class: 'ant-skeleton ant-skeleton-element',
  21. '[class.ant-skeleton-active]': 'nzActive',
  22. '[class.ant-skeleton-block]': 'nzBlock'
  23. }
  24. }]
  25. }], propDecorators: { nzActive: [{
  26. type: Input,
  27. args: [{ transform: booleanAttribute }]
  28. }], nzType: [{
  29. type: Input
  30. }], nzBlock: [{
  31. type: Input,
  32. args: [{ transform: booleanAttribute }]
  33. }] } });
  34. class NzSkeletonElementButtonComponent {
  35. nzShape = 'default';
  36. nzSize = 'default';
  37. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
  38. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzSkeletonElementButtonComponent, isStandalone: true, selector: "nz-skeleton-element[nzType=\"button\"]", inputs: { nzShape: "nzShape", nzSize: "nzSize" }, ngImport: i0, template: `
  39. <span
  40. class="ant-skeleton-button"
  41. [class.ant-skeleton-button-square]="nzShape === 'square'"
  42. [class.ant-skeleton-button-round]="nzShape === 'round'"
  43. [class.ant-skeleton-button-circle]="nzShape === 'circle'"
  44. [class.ant-skeleton-button-lg]="nzSize === 'large'"
  45. [class.ant-skeleton-button-sm]="nzSize === 'small'"
  46. ></span>
  47. `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
  48. }
  49. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementButtonComponent, decorators: [{
  50. type: Component,
  51. args: [{
  52. changeDetection: ChangeDetectionStrategy.OnPush,
  53. selector: 'nz-skeleton-element[nzType="button"]',
  54. template: `
  55. <span
  56. class="ant-skeleton-button"
  57. [class.ant-skeleton-button-square]="nzShape === 'square'"
  58. [class.ant-skeleton-button-round]="nzShape === 'round'"
  59. [class.ant-skeleton-button-circle]="nzShape === 'circle'"
  60. [class.ant-skeleton-button-lg]="nzSize === 'large'"
  61. [class.ant-skeleton-button-sm]="nzSize === 'small'"
  62. ></span>
  63. `
  64. }]
  65. }], propDecorators: { nzShape: [{
  66. type: Input
  67. }], nzSize: [{
  68. type: Input
  69. }] } });
  70. class NzSkeletonElementAvatarComponent {
  71. nzShape = 'circle';
  72. nzSize = 'default';
  73. styleMap = {};
  74. ngOnChanges(changes) {
  75. if (changes.nzSize && typeof this.nzSize === 'number') {
  76. const sideLength = `${this.nzSize}px`;
  77. this.styleMap = { width: sideLength, height: sideLength, 'line-height': sideLength };
  78. }
  79. else {
  80. this.styleMap = {};
  81. }
  82. }
  83. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementAvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
  84. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzSkeletonElementAvatarComponent, isStandalone: true, selector: "nz-skeleton-element[nzType=\"avatar\"]", inputs: { nzShape: "nzShape", nzSize: "nzSize" }, usesOnChanges: true, ngImport: i0, template: `
  85. <span
  86. class="ant-skeleton-avatar"
  87. [class.ant-skeleton-avatar-square]="nzShape === 'square'"
  88. [class.ant-skeleton-avatar-circle]="nzShape === 'circle'"
  89. [class.ant-skeleton-avatar-lg]="nzSize === 'large'"
  90. [class.ant-skeleton-avatar-sm]="nzSize === 'small'"
  91. [style]="styleMap"
  92. ></span>
  93. `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
  94. }
  95. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementAvatarComponent, decorators: [{
  96. type: Component,
  97. args: [{
  98. changeDetection: ChangeDetectionStrategy.OnPush,
  99. selector: 'nz-skeleton-element[nzType="avatar"]',
  100. template: `
  101. <span
  102. class="ant-skeleton-avatar"
  103. [class.ant-skeleton-avatar-square]="nzShape === 'square'"
  104. [class.ant-skeleton-avatar-circle]="nzShape === 'circle'"
  105. [class.ant-skeleton-avatar-lg]="nzSize === 'large'"
  106. [class.ant-skeleton-avatar-sm]="nzSize === 'small'"
  107. [style]="styleMap"
  108. ></span>
  109. `
  110. }]
  111. }], propDecorators: { nzShape: [{
  112. type: Input
  113. }], nzSize: [{
  114. type: Input
  115. }] } });
  116. class NzSkeletonElementInputComponent {
  117. nzSize = 'default';
  118. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
  119. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzSkeletonElementInputComponent, isStandalone: true, selector: "nz-skeleton-element[nzType=\"input\"]", inputs: { nzSize: "nzSize" }, ngImport: i0, template: `
  120. <span
  121. class="ant-skeleton-input"
  122. [class.ant-skeleton-input-lg]="nzSize === 'large'"
  123. [class.ant-skeleton-input-sm]="nzSize === 'small'"
  124. ></span>
  125. `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
  126. }
  127. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementInputComponent, decorators: [{
  128. type: Component,
  129. args: [{
  130. changeDetection: ChangeDetectionStrategy.OnPush,
  131. selector: 'nz-skeleton-element[nzType="input"]',
  132. template: `
  133. <span
  134. class="ant-skeleton-input"
  135. [class.ant-skeleton-input-lg]="nzSize === 'large'"
  136. [class.ant-skeleton-input-sm]="nzSize === 'small'"
  137. ></span>
  138. `
  139. }]
  140. }], propDecorators: { nzSize: [{
  141. type: Input
  142. }] } });
  143. class NzSkeletonElementImageComponent {
  144. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
  145. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzSkeletonElementImageComponent, isStandalone: true, selector: "nz-skeleton-element[nzType=\"image\"]", ngImport: i0, template: `
  146. <span class="ant-skeleton-image">
  147. <svg class="ant-skeleton-image-svg" viewBox="0 0 1098 1024" xmlns="http://www.w3.org/2000/svg">
  148. <path
  149. d="M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z"
  150. class="ant-skeleton-image-path"
  151. />
  152. </svg>
  153. </span>
  154. `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
  155. }
  156. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonElementImageComponent, decorators: [{
  157. type: Component,
  158. args: [{
  159. changeDetection: ChangeDetectionStrategy.OnPush,
  160. selector: 'nz-skeleton-element[nzType="image"]',
  161. template: `
  162. <span class="ant-skeleton-image">
  163. <svg class="ant-skeleton-image-svg" viewBox="0 0 1098 1024" xmlns="http://www.w3.org/2000/svg">
  164. <path
  165. d="M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z"
  166. class="ant-skeleton-image-path"
  167. />
  168. </svg>
  169. </span>
  170. `
  171. }]
  172. }] });
  173. /**
  174. * Use of this source code is governed by an MIT-style license that can be
  175. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  176. */
  177. class NzSkeletonComponent {
  178. cdr;
  179. nzActive = false;
  180. nzLoading = true;
  181. nzRound = false;
  182. nzTitle = true;
  183. nzAvatar = false;
  184. nzParagraph = true;
  185. title;
  186. avatar;
  187. paragraph;
  188. rowsList = [];
  189. widthList = [];
  190. constructor(cdr) {
  191. this.cdr = cdr;
  192. }
  193. toCSSUnit(value = '') {
  194. return toCssPixel(value);
  195. }
  196. getTitleProps() {
  197. const hasAvatar = !!this.nzAvatar;
  198. const hasParagraph = !!this.nzParagraph;
  199. let width = '';
  200. if (!hasAvatar && hasParagraph) {
  201. width = '38%';
  202. }
  203. else if (hasAvatar && hasParagraph) {
  204. width = '50%';
  205. }
  206. return { width, ...this.getProps(this.nzTitle) };
  207. }
  208. getAvatarProps() {
  209. const shape = !!this.nzTitle && !this.nzParagraph ? 'square' : 'circle';
  210. const size = 'large';
  211. return { shape, size, ...this.getProps(this.nzAvatar) };
  212. }
  213. getParagraphProps() {
  214. const hasAvatar = !!this.nzAvatar;
  215. const hasTitle = !!this.nzTitle;
  216. const basicProps = {};
  217. // Width
  218. if (!hasAvatar || !hasTitle) {
  219. basicProps.width = '61%';
  220. }
  221. // Rows
  222. if (!hasAvatar && hasTitle) {
  223. basicProps.rows = 3;
  224. }
  225. else {
  226. basicProps.rows = 2;
  227. }
  228. return { ...basicProps, ...this.getProps(this.nzParagraph) };
  229. }
  230. getProps(prop) {
  231. return prop && typeof prop === 'object' ? prop : {};
  232. }
  233. getWidthList() {
  234. const { width, rows } = this.paragraph;
  235. let widthList = [];
  236. if (width && Array.isArray(width)) {
  237. widthList = width;
  238. }
  239. else if (width && !Array.isArray(width)) {
  240. widthList = [];
  241. widthList[rows - 1] = width;
  242. }
  243. return widthList;
  244. }
  245. updateProps() {
  246. this.title = this.getTitleProps();
  247. this.avatar = this.getAvatarProps();
  248. this.paragraph = this.getParagraphProps();
  249. this.rowsList = [...Array(this.paragraph.rows)];
  250. this.widthList = this.getWidthList();
  251. this.cdr.markForCheck();
  252. }
  253. ngOnInit() {
  254. this.updateProps();
  255. }
  256. ngOnChanges(changes) {
  257. if (changes.nzTitle || changes.nzAvatar || changes.nzParagraph) {
  258. this.updateProps();
  259. }
  260. }
  261. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
  262. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzSkeletonComponent, isStandalone: true, selector: "nz-skeleton", inputs: { nzActive: "nzActive", nzLoading: "nzLoading", nzRound: "nzRound", nzTitle: "nzTitle", nzAvatar: "nzAvatar", nzParagraph: "nzParagraph" }, host: { properties: { "class.ant-skeleton-with-avatar": "!!nzAvatar", "class.ant-skeleton-active": "nzActive", "class.ant-skeleton-round": "!!nzRound" }, classAttribute: "ant-skeleton" }, exportAs: ["nzSkeleton"], usesOnChanges: true, ngImport: i0, template: `
  263. @if (nzLoading) {
  264. @if (!!nzAvatar) {
  265. <div class="ant-skeleton-header">
  266. <nz-skeleton-element
  267. nzType="avatar"
  268. [nzSize]="avatar.size || 'default'"
  269. [nzShape]="avatar.shape || 'circle'"
  270. ></nz-skeleton-element>
  271. </div>
  272. }
  273. <div class="ant-skeleton-content">
  274. @if (!!nzTitle) {
  275. <h3 class="ant-skeleton-title" [style.width]="toCSSUnit(title.width)"></h3>
  276. }
  277. @if (!!nzParagraph) {
  278. <ul class="ant-skeleton-paragraph">
  279. @for (row of rowsList; track row; let i = $index) {
  280. <li [style.width]="toCSSUnit(widthList[i])"></li>
  281. }
  282. </ul>
  283. }
  284. </div>
  285. } @else {
  286. <ng-content></ng-content>
  287. }
  288. `, isInline: true, dependencies: [{ kind: "directive", type: NzSkeletonElementDirective, selector: "nz-skeleton-element", inputs: ["nzActive", "nzType", "nzBlock"] }, { kind: "component", type: NzSkeletonElementAvatarComponent, selector: "nz-skeleton-element[nzType=\"avatar\"]", inputs: ["nzShape", "nzSize"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
  289. }
  290. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonComponent, decorators: [{
  291. type: Component,
  292. args: [{
  293. changeDetection: ChangeDetectionStrategy.OnPush,
  294. encapsulation: ViewEncapsulation.None,
  295. selector: 'nz-skeleton',
  296. exportAs: 'nzSkeleton',
  297. host: {
  298. class: 'ant-skeleton',
  299. '[class.ant-skeleton-with-avatar]': '!!nzAvatar',
  300. '[class.ant-skeleton-active]': 'nzActive',
  301. '[class.ant-skeleton-round]': '!!nzRound'
  302. },
  303. template: `
  304. @if (nzLoading) {
  305. @if (!!nzAvatar) {
  306. <div class="ant-skeleton-header">
  307. <nz-skeleton-element
  308. nzType="avatar"
  309. [nzSize]="avatar.size || 'default'"
  310. [nzShape]="avatar.shape || 'circle'"
  311. ></nz-skeleton-element>
  312. </div>
  313. }
  314. <div class="ant-skeleton-content">
  315. @if (!!nzTitle) {
  316. <h3 class="ant-skeleton-title" [style.width]="toCSSUnit(title.width)"></h3>
  317. }
  318. @if (!!nzParagraph) {
  319. <ul class="ant-skeleton-paragraph">
  320. @for (row of rowsList; track row; let i = $index) {
  321. <li [style.width]="toCSSUnit(widthList[i])"></li>
  322. }
  323. </ul>
  324. }
  325. </div>
  326. } @else {
  327. <ng-content></ng-content>
  328. }
  329. `,
  330. imports: [NzSkeletonElementDirective, NzSkeletonElementAvatarComponent]
  331. }]
  332. }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { nzActive: [{
  333. type: Input
  334. }], nzLoading: [{
  335. type: Input
  336. }], nzRound: [{
  337. type: Input
  338. }], nzTitle: [{
  339. type: Input
  340. }], nzAvatar: [{
  341. type: Input
  342. }], nzParagraph: [{
  343. type: Input
  344. }] } });
  345. /**
  346. * Use of this source code is governed by an MIT-style license that can be
  347. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  348. */
  349. class NzSkeletonModule {
  350. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  351. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonModule, imports: [NzSkeletonElementDirective,
  352. NzSkeletonComponent,
  353. NzSkeletonElementButtonComponent,
  354. NzSkeletonElementAvatarComponent,
  355. NzSkeletonElementImageComponent,
  356. NzSkeletonElementInputComponent], exports: [NzSkeletonElementDirective,
  357. NzSkeletonComponent,
  358. NzSkeletonElementButtonComponent,
  359. NzSkeletonElementAvatarComponent,
  360. NzSkeletonElementImageComponent,
  361. NzSkeletonElementInputComponent] });
  362. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonModule });
  363. }
  364. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSkeletonModule, decorators: [{
  365. type: NgModule,
  366. args: [{
  367. imports: [
  368. NzSkeletonElementDirective,
  369. NzSkeletonComponent,
  370. NzSkeletonElementButtonComponent,
  371. NzSkeletonElementAvatarComponent,
  372. NzSkeletonElementImageComponent,
  373. NzSkeletonElementInputComponent
  374. ],
  375. exports: [
  376. NzSkeletonElementDirective,
  377. NzSkeletonComponent,
  378. NzSkeletonElementButtonComponent,
  379. NzSkeletonElementAvatarComponent,
  380. NzSkeletonElementImageComponent,
  381. NzSkeletonElementInputComponent
  382. ]
  383. }]
  384. }] });
  385. /**
  386. * Use of this source code is governed by an MIT-style license that can be
  387. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  388. */
  389. /**
  390. * Use of this source code is governed by an MIT-style license that can be
  391. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  392. */
  393. /**
  394. * Generated bundle index. Do not edit.
  395. */
  396. export { NzSkeletonComponent, NzSkeletonElementAvatarComponent, NzSkeletonElementButtonComponent, NzSkeletonElementDirective, NzSkeletonElementImageComponent, NzSkeletonElementInputComponent, NzSkeletonModule };
  397. //# sourceMappingURL=ng-zorro-antd-skeleton.mjs.map