ng-zorro-antd-progress.mjs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. import * as i0 from '@angular/core';
  2. import { numberAttribute, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
  3. import { __esDecorate, __runInitializers } from 'tslib';
  4. import { NgTemplateOutlet } from '@angular/common';
  5. import { Subject } from 'rxjs';
  6. import { takeUntil } from 'rxjs/operators';
  7. import * as i1 from 'ng-zorro-antd/core/config';
  8. import { WithConfig } from 'ng-zorro-antd/core/config';
  9. import * as i4 from 'ng-zorro-antd/core/outlet';
  10. import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
  11. import { isNotNil, numberAttributeWithZeroFallback } from 'ng-zorro-antd/core/util';
  12. import * as i3 from 'ng-zorro-antd/icon';
  13. import { NzIconModule } from 'ng-zorro-antd/icon';
  14. import * as i2 from '@angular/cdk/bidi';
  15. /**
  16. * Use of this source code is governed by an MIT-style license that can be
  17. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  18. */
  19. function stripPercentToNumber(percent) {
  20. return +percent.replace('%', '');
  21. }
  22. const sortGradient = (gradients) => {
  23. let tempArr = [];
  24. Object.keys(gradients).forEach(key => {
  25. const value = gradients[key];
  26. const formatKey = stripPercentToNumber(key);
  27. if (!isNaN(formatKey)) {
  28. tempArr.push({
  29. key: formatKey,
  30. value
  31. });
  32. }
  33. });
  34. tempArr = tempArr.sort((a, b) => a.key - b.key);
  35. return tempArr;
  36. };
  37. const handleCircleGradient = (strokeColor) => sortGradient(strokeColor).map(({ key, value }) => ({ offset: `${key}%`, color: value }));
  38. const handleLinearGradient = (strokeColor) => {
  39. const { from = '#1890ff', to = '#1890ff', direction = 'to right', ...rest } = strokeColor;
  40. if (Object.keys(rest).length !== 0) {
  41. const sortedGradients = sortGradient(rest)
  42. .map(({ key, value }) => `${value} ${key}%`)
  43. .join(', ');
  44. return `linear-gradient(${direction}, ${sortedGradients})`;
  45. }
  46. return `linear-gradient(${direction}, ${from}, ${to})`;
  47. };
  48. let gradientIdSeed = 0;
  49. const NZ_CONFIG_MODULE_NAME = 'progress';
  50. const statusIconNameMap = new Map([
  51. ['success', 'check'],
  52. ['exception', 'close']
  53. ]);
  54. const statusColorMap = new Map([
  55. ['normal', '#108ee9'],
  56. ['exception', '#ff5500'],
  57. ['success', '#87d068']
  58. ]);
  59. const defaultFormatter = (p) => `${p}%`;
  60. let NzProgressComponent = (() => {
  61. let _nzShowInfo_decorators;
  62. let _nzShowInfo_initializers = [];
  63. let _nzShowInfo_extraInitializers = [];
  64. let _nzStrokeColor_decorators;
  65. let _nzStrokeColor_initializers = [];
  66. let _nzStrokeColor_extraInitializers = [];
  67. let _nzSize_decorators;
  68. let _nzSize_initializers = [];
  69. let _nzSize_extraInitializers = [];
  70. let _nzStrokeWidth_decorators;
  71. let _nzStrokeWidth_initializers = [];
  72. let _nzStrokeWidth_extraInitializers = [];
  73. let _nzGapDegree_decorators;
  74. let _nzGapDegree_initializers = [];
  75. let _nzGapDegree_extraInitializers = [];
  76. let _nzGapPosition_decorators;
  77. let _nzGapPosition_initializers = [];
  78. let _nzGapPosition_extraInitializers = [];
  79. let _nzStrokeLinecap_decorators;
  80. let _nzStrokeLinecap_initializers = [];
  81. let _nzStrokeLinecap_extraInitializers = [];
  82. return class NzProgressComponent {
  83. static {
  84. const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
  85. _nzShowInfo_decorators = [WithConfig()];
  86. _nzStrokeColor_decorators = [WithConfig()];
  87. _nzSize_decorators = [WithConfig()];
  88. _nzStrokeWidth_decorators = [WithConfig()];
  89. _nzGapDegree_decorators = [WithConfig()];
  90. _nzGapPosition_decorators = [WithConfig()];
  91. _nzStrokeLinecap_decorators = [WithConfig()];
  92. __esDecorate(null, null, _nzShowInfo_decorators, { kind: "field", name: "nzShowInfo", static: false, private: false, access: { has: obj => "nzShowInfo" in obj, get: obj => obj.nzShowInfo, set: (obj, value) => { obj.nzShowInfo = value; } }, metadata: _metadata }, _nzShowInfo_initializers, _nzShowInfo_extraInitializers);
  93. __esDecorate(null, null, _nzStrokeColor_decorators, { kind: "field", name: "nzStrokeColor", static: false, private: false, access: { has: obj => "nzStrokeColor" in obj, get: obj => obj.nzStrokeColor, set: (obj, value) => { obj.nzStrokeColor = value; } }, metadata: _metadata }, _nzStrokeColor_initializers, _nzStrokeColor_extraInitializers);
  94. __esDecorate(null, null, _nzSize_decorators, { kind: "field", name: "nzSize", static: false, private: false, access: { has: obj => "nzSize" in obj, get: obj => obj.nzSize, set: (obj, value) => { obj.nzSize = value; } }, metadata: _metadata }, _nzSize_initializers, _nzSize_extraInitializers);
  95. __esDecorate(null, null, _nzStrokeWidth_decorators, { kind: "field", name: "nzStrokeWidth", static: false, private: false, access: { has: obj => "nzStrokeWidth" in obj, get: obj => obj.nzStrokeWidth, set: (obj, value) => { obj.nzStrokeWidth = value; } }, metadata: _metadata }, _nzStrokeWidth_initializers, _nzStrokeWidth_extraInitializers);
  96. __esDecorate(null, null, _nzGapDegree_decorators, { kind: "field", name: "nzGapDegree", static: false, private: false, access: { has: obj => "nzGapDegree" in obj, get: obj => obj.nzGapDegree, set: (obj, value) => { obj.nzGapDegree = value; } }, metadata: _metadata }, _nzGapDegree_initializers, _nzGapDegree_extraInitializers);
  97. __esDecorate(null, null, _nzGapPosition_decorators, { kind: "field", name: "nzGapPosition", static: false, private: false, access: { has: obj => "nzGapPosition" in obj, get: obj => obj.nzGapPosition, set: (obj, value) => { obj.nzGapPosition = value; } }, metadata: _metadata }, _nzGapPosition_initializers, _nzGapPosition_extraInitializers);
  98. __esDecorate(null, null, _nzStrokeLinecap_decorators, { kind: "field", name: "nzStrokeLinecap", static: false, private: false, access: { has: obj => "nzStrokeLinecap" in obj, get: obj => obj.nzStrokeLinecap, set: (obj, value) => { obj.nzStrokeLinecap = value; } }, metadata: _metadata }, _nzStrokeLinecap_initializers, _nzStrokeLinecap_extraInitializers);
  99. if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
  100. }
  101. cdr;
  102. nzConfigService;
  103. directionality;
  104. _nzModuleName = NZ_CONFIG_MODULE_NAME;
  105. nzShowInfo = __runInitializers(this, _nzShowInfo_initializers, true);
  106. nzWidth = (__runInitializers(this, _nzShowInfo_extraInitializers), 132);
  107. nzStrokeColor = __runInitializers(this, _nzStrokeColor_initializers, undefined);
  108. nzSize = (__runInitializers(this, _nzStrokeColor_extraInitializers), __runInitializers(this, _nzSize_initializers, 'default'));
  109. nzFormat = __runInitializers(this, _nzSize_extraInitializers);
  110. nzSuccessPercent;
  111. nzPercent = 0;
  112. nzStrokeWidth = __runInitializers(this, _nzStrokeWidth_initializers, void 0);
  113. nzGapDegree = (__runInitializers(this, _nzStrokeWidth_extraInitializers), __runInitializers(this, _nzGapDegree_initializers, void 0));
  114. nzStatus = __runInitializers(this, _nzGapDegree_extraInitializers);
  115. nzType = 'line';
  116. nzGapPosition = __runInitializers(this, _nzGapPosition_initializers, 'top');
  117. nzStrokeLinecap = (__runInitializers(this, _nzGapPosition_extraInitializers), __runInitializers(this, _nzStrokeLinecap_initializers, 'round'));
  118. nzSteps = (__runInitializers(this, _nzStrokeLinecap_extraInitializers), 0);
  119. steps = [];
  120. /** Gradient style when `nzType` is `line`. */
  121. lineGradient = null;
  122. /** If user uses gradient color. */
  123. isGradient = false;
  124. /** If the linear progress is a step progress. */
  125. isSteps = false;
  126. /**
  127. * Each progress whose `nzType` is circle or dashboard should have unique id to
  128. * define `<linearGradient>`.
  129. */
  130. gradientId = gradientIdSeed++;
  131. /** Paths to rendered in the template. */
  132. progressCirclePath = [];
  133. circleGradient;
  134. trailPathStyle = null;
  135. pathString;
  136. icon;
  137. dir = 'ltr';
  138. get formatter() {
  139. return this.nzFormat || defaultFormatter;
  140. }
  141. get status() {
  142. return this.nzStatus || this.inferredStatus;
  143. }
  144. get strokeWidth() {
  145. return this.nzStrokeWidth || (this.nzType === 'line' && this.nzSize !== 'small' ? 8 : 6);
  146. }
  147. get isCircleStyle() {
  148. return this.nzType === 'circle' || this.nzType === 'dashboard';
  149. }
  150. cachedStatus = 'normal';
  151. inferredStatus = 'normal';
  152. destroy$ = new Subject();
  153. constructor(cdr, nzConfigService, directionality) {
  154. this.cdr = cdr;
  155. this.nzConfigService = nzConfigService;
  156. this.directionality = directionality;
  157. }
  158. ngOnChanges(changes) {
  159. const { nzSteps, nzGapPosition, nzStrokeLinecap, nzStrokeColor, nzGapDegree, nzType, nzStatus, nzPercent, nzSuccessPercent, nzStrokeWidth } = changes;
  160. if (nzStatus) {
  161. this.cachedStatus = this.nzStatus || this.cachedStatus;
  162. }
  163. if (nzPercent || nzSuccessPercent) {
  164. const fillAll = parseInt(this.nzPercent.toString(), 10) >= 100;
  165. if (fillAll) {
  166. if ((isNotNil(this.nzSuccessPercent) && this.nzSuccessPercent >= 100) || this.nzSuccessPercent === undefined) {
  167. this.inferredStatus = 'success';
  168. }
  169. }
  170. else {
  171. this.inferredStatus = this.cachedStatus;
  172. }
  173. }
  174. if (nzStatus || nzPercent || nzSuccessPercent || nzStrokeColor) {
  175. this.updateIcon();
  176. }
  177. if (nzStrokeColor) {
  178. this.setStrokeColor();
  179. }
  180. if (nzGapPosition || nzStrokeLinecap || nzGapDegree || nzType || nzPercent || nzStrokeColor || nzStrokeColor) {
  181. this.getCirclePaths();
  182. }
  183. if (nzPercent || nzSteps || nzStrokeWidth) {
  184. this.isSteps = this.nzSteps > 0;
  185. if (this.isSteps) {
  186. this.getSteps();
  187. }
  188. }
  189. }
  190. ngOnInit() {
  191. this.nzConfigService
  192. .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)
  193. .pipe(takeUntil(this.destroy$))
  194. .subscribe(() => {
  195. this.updateIcon();
  196. this.setStrokeColor();
  197. this.getCirclePaths();
  198. });
  199. this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
  200. this.dir = direction;
  201. this.cdr.detectChanges();
  202. });
  203. this.dir = this.directionality.value;
  204. }
  205. ngOnDestroy() {
  206. this.destroy$.next();
  207. this.destroy$.complete();
  208. }
  209. updateIcon() {
  210. const ret = statusIconNameMap.get(this.status);
  211. this.icon = ret ? ret + (this.isCircleStyle ? '-o' : '-circle-fill') : '';
  212. }
  213. /**
  214. * Calculate step render configs.
  215. */
  216. getSteps() {
  217. const current = Math.floor(this.nzSteps * (this.nzPercent / 100));
  218. const stepWidth = this.nzSize === 'small' ? 2 : 14;
  219. const steps = [];
  220. for (let i = 0; i < this.nzSteps; i++) {
  221. let color;
  222. if (i <= current - 1) {
  223. color = this.nzStrokeColor;
  224. }
  225. const stepStyle = {
  226. backgroundColor: `${color}`,
  227. width: `${stepWidth}px`,
  228. height: `${this.strokeWidth}px`
  229. };
  230. steps.push(stepStyle);
  231. }
  232. this.steps = steps;
  233. }
  234. /**
  235. * Calculate paths when the type is circle or dashboard.
  236. */
  237. getCirclePaths() {
  238. if (!this.isCircleStyle) {
  239. return;
  240. }
  241. const values = isNotNil(this.nzSuccessPercent) ? [this.nzSuccessPercent, this.nzPercent] : [this.nzPercent];
  242. // Calculate shared styles.
  243. const radius = 50 - this.strokeWidth / 2;
  244. const gapPosition = this.nzGapPosition || (this.nzType === 'circle' ? 'top' : 'bottom');
  245. const len = Math.PI * 2 * radius;
  246. const gapDegree = this.nzGapDegree || (this.nzType === 'circle' ? 0 : 75);
  247. let beginPositionX = 0;
  248. let beginPositionY = -radius;
  249. let endPositionX = 0;
  250. let endPositionY = radius * -2;
  251. switch (gapPosition) {
  252. case 'left':
  253. beginPositionX = -radius;
  254. beginPositionY = 0;
  255. endPositionX = radius * 2;
  256. endPositionY = 0;
  257. break;
  258. case 'right':
  259. beginPositionX = radius;
  260. beginPositionY = 0;
  261. endPositionX = radius * -2;
  262. endPositionY = 0;
  263. break;
  264. case 'bottom':
  265. beginPositionY = radius;
  266. endPositionY = radius * 2;
  267. break;
  268. default:
  269. }
  270. this.pathString = `M 50,50 m ${beginPositionX},${beginPositionY}
  271. a ${radius},${radius} 0 1 1 ${endPositionX},${-endPositionY}
  272. a ${radius},${radius} 0 1 1 ${-endPositionX},${endPositionY}`;
  273. this.trailPathStyle = {
  274. strokeDasharray: `${len - gapDegree}px ${len}px`,
  275. strokeDashoffset: `-${gapDegree / 2}px`,
  276. transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s'
  277. };
  278. // Calculate styles for each path.
  279. this.progressCirclePath = values
  280. .map((value, index) => {
  281. const isSuccessPercent = values.length === 2 && index === 0;
  282. return {
  283. stroke: this.isGradient && !isSuccessPercent ? `url(#gradient-${this.gradientId})` : null,
  284. strokePathStyle: {
  285. stroke: !this.isGradient
  286. ? isSuccessPercent
  287. ? statusColorMap.get('success')
  288. : this.nzStrokeColor
  289. : null,
  290. transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s',
  291. strokeDasharray: `${((value || 0) / 100) * (len - gapDegree)}px ${len}px`,
  292. strokeDashoffset: `-${gapDegree / 2}px`
  293. }
  294. };
  295. })
  296. .reverse();
  297. }
  298. setStrokeColor() {
  299. const color = this.nzStrokeColor;
  300. const isGradient = (this.isGradient = !!color && typeof color !== 'string');
  301. if (isGradient && !this.isCircleStyle) {
  302. this.lineGradient = handleLinearGradient(color);
  303. }
  304. else if (isGradient && this.isCircleStyle) {
  305. this.circleGradient = handleCircleGradient(this.nzStrokeColor);
  306. }
  307. else {
  308. this.lineGradient = null;
  309. this.circleGradient = [];
  310. }
  311. }
  312. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzProgressComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.NzConfigService }, { token: i2.Directionality }], target: i0.ɵɵFactoryTarget.Component });
  313. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzProgressComponent, isStandalone: true, selector: "nz-progress", inputs: { nzShowInfo: "nzShowInfo", nzWidth: "nzWidth", nzStrokeColor: "nzStrokeColor", nzSize: "nzSize", nzFormat: "nzFormat", nzSuccessPercent: ["nzSuccessPercent", "nzSuccessPercent", numberAttributeWithZeroFallback], nzPercent: ["nzPercent", "nzPercent", numberAttribute], nzStrokeWidth: ["nzStrokeWidth", "nzStrokeWidth", numberAttributeWithZeroFallback], nzGapDegree: ["nzGapDegree", "nzGapDegree", numberAttributeWithZeroFallback], nzStatus: "nzStatus", nzType: "nzType", nzGapPosition: "nzGapPosition", nzStrokeLinecap: "nzStrokeLinecap", nzSteps: ["nzSteps", "nzSteps", numberAttribute] }, exportAs: ["nzProgress"], usesOnChanges: true, ngImport: i0, template: `
  314. <ng-template #progressInfoTemplate>
  315. @if (nzShowInfo) {
  316. <span class="ant-progress-text">
  317. @if ((status === 'exception' || status === 'success') && !nzFormat) {
  318. <nz-icon [nzType]="icon" />
  319. } @else {
  320. <ng-container *nzStringTemplateOutlet="formatter; context: { $implicit: nzPercent }; let formatter">
  321. {{ formatter(nzPercent) }}
  322. </ng-container>
  323. }
  324. </span>
  325. }
  326. </ng-template>
  327. <div
  328. [class]="'ant-progress ant-progress-status-' + status"
  329. [class.ant-progress-line]="nzType === 'line'"
  330. [class.ant-progress-small]="nzSize === 'small'"
  331. [class.ant-progress-default]="nzSize === 'default'"
  332. [class.ant-progress-show-info]="nzShowInfo"
  333. [class.ant-progress-circle]="isCircleStyle"
  334. [class.ant-progress-steps]="isSteps"
  335. [class.ant-progress-rtl]="dir === 'rtl'"
  336. >
  337. @if (nzType === 'line') {
  338. <div>
  339. <!-- normal line style -->
  340. @if (isSteps) {
  341. <div class="ant-progress-steps-outer">
  342. @for (step of steps; track $index) {
  343. <div class="ant-progress-steps-item" [style]="step"></div>
  344. }
  345. <ng-template [ngTemplateOutlet]="progressInfoTemplate" />
  346. </div>
  347. } @else {
  348. <div class="ant-progress-outer">
  349. <div class="ant-progress-inner">
  350. <div
  351. class="ant-progress-bg"
  352. [style.width.%]="nzPercent"
  353. [style.border-radius]="nzStrokeLinecap === 'round' ? '100px' : '0'"
  354. [style.background]="!isGradient ? nzStrokeColor : null"
  355. [style.background-image]="isGradient ? lineGradient : null"
  356. [style.height.px]="strokeWidth"
  357. ></div>
  358. @if (nzSuccessPercent || nzSuccessPercent === 0) {
  359. <div
  360. class="ant-progress-success-bg"
  361. [style.width.%]="nzSuccessPercent"
  362. [style.border-radius]="nzStrokeLinecap === 'round' ? '100px' : '0'"
  363. [style.height.px]="strokeWidth"
  364. ></div>
  365. }
  366. </div>
  367. </div>
  368. <ng-template [ngTemplateOutlet]="progressInfoTemplate" />
  369. }
  370. </div>
  371. }
  372. <!-- line progress -->
  373. <!-- circle / dashboard progress -->
  374. @if (isCircleStyle) {
  375. <div
  376. [style.width.px]="this.nzWidth"
  377. [style.height.px]="this.nzWidth"
  378. [style.fontSize.px]="this.nzWidth * 0.15 + 6"
  379. class="ant-progress-inner"
  380. [class.ant-progress-circle-gradient]="isGradient"
  381. >
  382. <svg class="ant-progress-circle " viewBox="0 0 100 100">
  383. @if (isGradient) {
  384. <defs>
  385. <linearGradient [id]="'gradient-' + gradientId" x1="100%" y1="0%" x2="0%" y2="0%">
  386. @for (i of circleGradient; track $index) {
  387. <stop [attr.offset]="i.offset" [attr.stop-color]="i.color"></stop>
  388. }
  389. </linearGradient>
  390. </defs>
  391. }
  392. <path
  393. class="ant-progress-circle-trail"
  394. stroke="#f3f3f3"
  395. fill-opacity="0"
  396. [attr.stroke-width]="strokeWidth"
  397. [attr.d]="pathString"
  398. [style]="trailPathStyle"
  399. ></path>
  400. @for (p of progressCirclePath; track $index) {
  401. <path
  402. class="ant-progress-circle-path"
  403. fill-opacity="0"
  404. [attr.d]="pathString"
  405. [attr.stroke-linecap]="nzStrokeLinecap"
  406. [attr.stroke]="p.stroke"
  407. [attr.stroke-width]="nzPercent ? strokeWidth : 0"
  408. [style]="p.strokePathStyle"
  409. ></path>
  410. }
  411. </svg>
  412. <ng-template [ngTemplateOutlet]="progressInfoTemplate" />
  413. </div>
  414. }
  415. </div>
  416. `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i3.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i4.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
  417. };
  418. })();
  419. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzProgressComponent, decorators: [{
  420. type: Component,
  421. args: [{
  422. changeDetection: ChangeDetectionStrategy.OnPush,
  423. encapsulation: ViewEncapsulation.None,
  424. selector: 'nz-progress',
  425. exportAs: 'nzProgress',
  426. preserveWhitespaces: false,
  427. imports: [NzIconModule, NzOutletModule, NgTemplateOutlet],
  428. template: `
  429. <ng-template #progressInfoTemplate>
  430. @if (nzShowInfo) {
  431. <span class="ant-progress-text">
  432. @if ((status === 'exception' || status === 'success') && !nzFormat) {
  433. <nz-icon [nzType]="icon" />
  434. } @else {
  435. <ng-container *nzStringTemplateOutlet="formatter; context: { $implicit: nzPercent }; let formatter">
  436. {{ formatter(nzPercent) }}
  437. </ng-container>
  438. }
  439. </span>
  440. }
  441. </ng-template>
  442. <div
  443. [class]="'ant-progress ant-progress-status-' + status"
  444. [class.ant-progress-line]="nzType === 'line'"
  445. [class.ant-progress-small]="nzSize === 'small'"
  446. [class.ant-progress-default]="nzSize === 'default'"
  447. [class.ant-progress-show-info]="nzShowInfo"
  448. [class.ant-progress-circle]="isCircleStyle"
  449. [class.ant-progress-steps]="isSteps"
  450. [class.ant-progress-rtl]="dir === 'rtl'"
  451. >
  452. @if (nzType === 'line') {
  453. <div>
  454. <!-- normal line style -->
  455. @if (isSteps) {
  456. <div class="ant-progress-steps-outer">
  457. @for (step of steps; track $index) {
  458. <div class="ant-progress-steps-item" [style]="step"></div>
  459. }
  460. <ng-template [ngTemplateOutlet]="progressInfoTemplate" />
  461. </div>
  462. } @else {
  463. <div class="ant-progress-outer">
  464. <div class="ant-progress-inner">
  465. <div
  466. class="ant-progress-bg"
  467. [style.width.%]="nzPercent"
  468. [style.border-radius]="nzStrokeLinecap === 'round' ? '100px' : '0'"
  469. [style.background]="!isGradient ? nzStrokeColor : null"
  470. [style.background-image]="isGradient ? lineGradient : null"
  471. [style.height.px]="strokeWidth"
  472. ></div>
  473. @if (nzSuccessPercent || nzSuccessPercent === 0) {
  474. <div
  475. class="ant-progress-success-bg"
  476. [style.width.%]="nzSuccessPercent"
  477. [style.border-radius]="nzStrokeLinecap === 'round' ? '100px' : '0'"
  478. [style.height.px]="strokeWidth"
  479. ></div>
  480. }
  481. </div>
  482. </div>
  483. <ng-template [ngTemplateOutlet]="progressInfoTemplate" />
  484. }
  485. </div>
  486. }
  487. <!-- line progress -->
  488. <!-- circle / dashboard progress -->
  489. @if (isCircleStyle) {
  490. <div
  491. [style.width.px]="this.nzWidth"
  492. [style.height.px]="this.nzWidth"
  493. [style.fontSize.px]="this.nzWidth * 0.15 + 6"
  494. class="ant-progress-inner"
  495. [class.ant-progress-circle-gradient]="isGradient"
  496. >
  497. <svg class="ant-progress-circle " viewBox="0 0 100 100">
  498. @if (isGradient) {
  499. <defs>
  500. <linearGradient [id]="'gradient-' + gradientId" x1="100%" y1="0%" x2="0%" y2="0%">
  501. @for (i of circleGradient; track $index) {
  502. <stop [attr.offset]="i.offset" [attr.stop-color]="i.color"></stop>
  503. }
  504. </linearGradient>
  505. </defs>
  506. }
  507. <path
  508. class="ant-progress-circle-trail"
  509. stroke="#f3f3f3"
  510. fill-opacity="0"
  511. [attr.stroke-width]="strokeWidth"
  512. [attr.d]="pathString"
  513. [style]="trailPathStyle"
  514. ></path>
  515. @for (p of progressCirclePath; track $index) {
  516. <path
  517. class="ant-progress-circle-path"
  518. fill-opacity="0"
  519. [attr.d]="pathString"
  520. [attr.stroke-linecap]="nzStrokeLinecap"
  521. [attr.stroke]="p.stroke"
  522. [attr.stroke-width]="nzPercent ? strokeWidth : 0"
  523. [style]="p.strokePathStyle"
  524. ></path>
  525. }
  526. </svg>
  527. <ng-template [ngTemplateOutlet]="progressInfoTemplate" />
  528. </div>
  529. }
  530. </div>
  531. `
  532. }]
  533. }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.NzConfigService }, { type: i2.Directionality }], propDecorators: { nzShowInfo: [{
  534. type: Input
  535. }], nzWidth: [{
  536. type: Input
  537. }], nzStrokeColor: [{
  538. type: Input
  539. }], nzSize: [{
  540. type: Input
  541. }], nzFormat: [{
  542. type: Input
  543. }], nzSuccessPercent: [{
  544. type: Input,
  545. args: [{ transform: numberAttributeWithZeroFallback }]
  546. }], nzPercent: [{
  547. type: Input,
  548. args: [{ transform: numberAttribute }]
  549. }], nzStrokeWidth: [{
  550. type: Input,
  551. args: [{ transform: numberAttributeWithZeroFallback }]
  552. }], nzGapDegree: [{
  553. type: Input,
  554. args: [{ transform: numberAttributeWithZeroFallback }]
  555. }], nzStatus: [{
  556. type: Input
  557. }], nzType: [{
  558. type: Input
  559. }], nzGapPosition: [{
  560. type: Input
  561. }], nzStrokeLinecap: [{
  562. type: Input
  563. }], nzSteps: [{
  564. type: Input,
  565. args: [{ transform: numberAttribute }]
  566. }] } });
  567. /**
  568. * Use of this source code is governed by an MIT-style license that can be
  569. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  570. */
  571. class NzProgressModule {
  572. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzProgressModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  573. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzProgressModule, imports: [NzProgressComponent], exports: [NzProgressComponent] });
  574. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzProgressModule, imports: [NzProgressComponent] });
  575. }
  576. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzProgressModule, decorators: [{
  577. type: NgModule,
  578. args: [{
  579. imports: [NzProgressComponent],
  580. exports: [NzProgressComponent]
  581. }]
  582. }] });
  583. /**
  584. * Use of this source code is governed by an MIT-style license that can be
  585. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  586. */
  587. /**
  588. * Use of this source code is governed by an MIT-style license that can be
  589. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  590. */
  591. /**
  592. * Generated bundle index. Do not edit.
  593. */
  594. export { NzProgressComponent, NzProgressModule };
  595. //# sourceMappingURL=ng-zorro-antd-progress.mjs.map