ngx-repeat 2.2.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -85,7 +85,8 @@ import { NgxRepeatDirective } from 'ngx-repeat';
85
85
 
86
86
  | Angular | ngx-repeat | Install |
87
87
  | --------- | ---------- | ----------------------- |
88
- | >= 14 | 2.x | `yarn add ngx-repeat ` |
88
+ | >= 19 | 3.x | `yarn add ngx-repeat` |
89
+ | >= 14 | 2.x | `yarn add ngx-repeat@2` |
89
90
  | >= 12 | 1.x | `yarn add ngx-repeat@1` |
90
91
  | >= 5 < 13 | 0.x | `yarn add ngx-repeat@0` |
91
92
 
@@ -95,7 +96,7 @@ _None_
95
96
 
96
97
  ## 🪪 License
97
98
 
98
- Copyright &copy; 2021 - 2024 [Dominik Hladik](https://github.com/Celtian)
99
+ Copyright &copy; 2021 - 2025 [Dominik Hladik](https://github.com/Celtian)
99
100
 
100
101
  All contents are licensed under the [MIT license].
101
102
 
@@ -1,10 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, Input } from '@angular/core';
2
+ import { inject, TemplateRef, ViewContainerRef, input, effect, Directive } from '@angular/core';
3
3
 
4
4
  /**
5
5
  * @publicApi
6
6
  */
7
7
  class RepeatDirectiveContext {
8
+ $implicit;
9
+ count;
8
10
  constructor($implicit, count) {
9
11
  this.$implicit = $implicit;
10
12
  this.count = count;
@@ -26,32 +28,29 @@ class RepeatDirectiveContext {
26
28
  }
27
29
  }
28
30
  class NgxRepeatDirective {
29
- set ngxRepeat(count) {
30
- for (let i = this.viewContainer.length; i > count; i--)
31
- this.viewContainer.remove(i - 1);
32
- for (let i = this.viewContainer.length; i < count; i++)
33
- this.viewContainer.createEmbeddedView(this.templateRef, new RepeatDirectiveContext(i, count));
34
- for (let i = 0; i < this.viewContainer.length; i++) {
35
- const viewRef = this.viewContainer.get(i);
36
- viewRef.context.count = count;
37
- }
31
+ templateRef = inject(TemplateRef);
32
+ viewContainer = inject(ViewContainerRef);
33
+ count = input.required({ alias: 'ngxRepeat' });
34
+ constructor() {
35
+ effect(() => {
36
+ const count = this.count();
37
+ for (let i = this.viewContainer.length; i > count; i--)
38
+ this.viewContainer.remove(i - 1);
39
+ for (let i = this.viewContainer.length; i < count; i++)
40
+ this.viewContainer.createEmbeddedView(this.templateRef, new RepeatDirectiveContext(i, count));
41
+ for (let i = 0; i < this.viewContainer.length; i++) {
42
+ const viewRef = this.viewContainer.get(i);
43
+ viewRef.context.count = count;
44
+ }
45
+ });
38
46
  }
39
- constructor(templateRef, viewContainer) {
40
- this.templateRef = templateRef;
41
- this.viewContainer = viewContainer;
42
- }
43
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NgxRepeatDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
44
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.1", type: NgxRepeatDirective, isStandalone: true, selector: "[ngxRepeat]", inputs: { ngxRepeat: "ngxRepeat" }, ngImport: i0 }); }
47
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgxRepeatDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
48
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.6", type: NgxRepeatDirective, isStandalone: true, selector: "[ngxRepeat]", inputs: { count: { classPropertyName: "count", publicName: "ngxRepeat", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
45
49
  }
46
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NgxRepeatDirective, decorators: [{
50
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgxRepeatDirective, decorators: [{
47
51
  type: Directive,
48
- args: [{
49
- selector: '[ngxRepeat]',
50
- standalone: true
51
- }]
52
- }], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }], propDecorators: { ngxRepeat: [{
53
- type: Input
54
- }] } });
52
+ args: [{ selector: '[ngxRepeat]' }]
53
+ }], ctorParameters: () => [] });
55
54
 
56
55
  /*
57
56
  * Public API Surface of ngx-repeat
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-repeat.mjs","sources":["../../../projects/ngx-repeat/src/lib/ngx-repeat.directive.ts","../../../projects/ngx-repeat/src/public-api.ts","../../../projects/ngx-repeat/src/ngx-repeat.ts"],"sourcesContent":["import { Directive, EmbeddedViewRef, Input, TemplateRef, ViewContainerRef } from '@angular/core';\n\n/**\n * @publicApi\n */\nexport class RepeatDirectiveContext {\n constructor(\n public $implicit: number,\n public count: number\n ) {}\n\n public get index(): number {\n return this.$implicit;\n }\n\n public get first(): boolean {\n return this.$implicit === 0;\n }\n\n public get last(): boolean {\n return this.index === this.count - 1;\n }\n\n public get even(): boolean {\n return this.$implicit % 2 === 0;\n }\n\n public get odd(): boolean {\n return this.$implicit % 2 === 1;\n }\n}\n\n@Directive({\n selector: '[ngxRepeat]',\n standalone: true\n})\nexport class NgxRepeatDirective {\n @Input() public set ngxRepeat(count: number) {\n for (let i = this.viewContainer.length; i > count; i--) this.viewContainer.remove(i - 1);\n\n for (let i = this.viewContainer.length; i < count; i++)\n this.viewContainer.createEmbeddedView(this.templateRef, new RepeatDirectiveContext(i, count));\n\n for (let i = 0; i < this.viewContainer.length; i++) {\n const viewRef = this.viewContainer.get(i) as EmbeddedViewRef<RepeatDirectiveContext>;\n viewRef.context.count = count;\n }\n }\n\n constructor(\n private templateRef: TemplateRef<RepeatDirectiveContext>,\n private viewContainer: ViewContainerRef\n ) {}\n}\n","/*\n * Public API Surface of ngx-repeat\n */\n\nexport * from './lib/ngx-repeat.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"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AC,CAA4C;AACpF,YAAA,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK;;;IAIjC,WACU,CAAA,WAAgD,EAChD,aAA+B,EAAA;QAD/B,IAAW,CAAA,WAAA,GAAX,WAAW;QACX,IAAa,CAAA,aAAA,GAAb,aAAa;;8GAfZ,kBAAkB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,WAAA,EAAA,EAAA,EAAA,KAAA,EAAA,EAAA,CAAA,gBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAAlB,kBAAkB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,aAAA,EAAA,MAAA,EAAA,EAAA,SAAA,EAAA,WAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAJ9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,UAAU,EAAE;AACb,iBAAA;+GAEqB,SAAS,EAAA,CAAA;sBAA5B;;;ACrCH;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngx-repeat.mjs","sources":["../../../projects/ngx-repeat/src/lib/ngx-repeat.directive.ts","../../../projects/ngx-repeat/src/public-api.ts","../../../projects/ngx-repeat/src/ngx-repeat.ts"],"sourcesContent":["import { Directive, EmbeddedViewRef, TemplateRef, ViewContainerRef, effect, inject, input } from '@angular/core';\n\n/**\n * @publicApi\n */\nexport class RepeatDirectiveContext {\n constructor(\n public $implicit: number,\n public count: number\n ) {}\n\n public get index(): number {\n return this.$implicit;\n }\n\n public get first(): boolean {\n return this.$implicit === 0;\n }\n\n public get last(): boolean {\n return this.index === this.count - 1;\n }\n\n public get even(): boolean {\n return this.$implicit % 2 === 0;\n }\n\n public get odd(): boolean {\n return this.$implicit % 2 === 1;\n }\n}\n\n@Directive({ selector: '[ngxRepeat]' })\nexport class NgxRepeatDirective {\n private readonly templateRef = inject<TemplateRef<RepeatDirectiveContext>>(TemplateRef);\n private readonly viewContainer = inject(ViewContainerRef);\n public readonly count = input.required<number>({ alias: 'ngxRepeat' });\n\n constructor() {\n effect(() => {\n const count = this.count();\n for (let i = this.viewContainer.length; i > count; i--) this.viewContainer.remove(i - 1);\n\n for (let i = this.viewContainer.length; i < count; i++)\n this.viewContainer.createEmbeddedView(this.templateRef, new RepeatDirectiveContext(i, count));\n\n for (let i = 0; i < this.viewContainer.length; i++) {\n const viewRef = this.viewContainer.get(i) as EmbeddedViewRef<RepeatDirectiveContext>;\n viewRef.context.count = count;\n }\n });\n }\n}\n","/*\n * Public API Surface of ngx-repeat\n */\n\nexport * from './lib/ngx-repeat.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEA;;AAEG;MACU,sBAAsB,CAAA;AAExB,IAAA,SAAA;AACA,IAAA,KAAA;IAFT,WACS,CAAA,SAAiB,EACjB,KAAa,EAAA;QADb,IAAS,CAAA,SAAA,GAAT,SAAS;QACT,IAAK,CAAA,KAAA,GAAL,KAAK;;AAGd,IAAA,IAAW,KAAK,GAAA;QACd,OAAO,IAAI,CAAC,SAAS;;AAGvB,IAAA,IAAW,KAAK,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,SAAS,KAAK,CAAC;;AAG7B,IAAA,IAAW,IAAI,GAAA;QACb,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC;;AAGtC,IAAA,IAAW,IAAI,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC;;AAGjC,IAAA,IAAW,GAAG,GAAA;AACZ,QAAA,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC;;AAElC;MAGY,kBAAkB,CAAA;AACZ,IAAA,WAAW,GAAG,MA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EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAD9B,SAAS;mBAAC,EAAE,QAAQ,EAAE,aAAa,EAAE;;;AChCtC;;AAEG;;ACFH;;AAEG;;;;"}
@@ -1,4 +1,3 @@
1
- import { TemplateRef, ViewContainerRef } from '@angular/core';
2
1
  import * as i0 from "@angular/core";
3
2
  /**
4
3
  * @publicApi
@@ -14,10 +13,10 @@ export declare class RepeatDirectiveContext {
14
13
  get odd(): boolean;
15
14
  }
16
15
  export declare class NgxRepeatDirective {
17
- private templateRef;
18
- private viewContainer;
19
- set ngxRepeat(count: number);
20
- constructor(templateRef: TemplateRef<RepeatDirectiveContext>, viewContainer: ViewContainerRef);
16
+ private readonly templateRef;
17
+ private readonly viewContainer;
18
+ readonly count: import("@angular/core").InputSignal<number>;
19
+ constructor();
21
20
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxRepeatDirective, never>;
22
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgxRepeatDirective, "[ngxRepeat]", never, { "ngxRepeat": { "alias": "ngxRepeat"; "required": false; }; }, {}, never, never, true, never>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxRepeatDirective, "[ngxRepeat]", never, { "count": { "alias": "ngxRepeat"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
23
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-repeat",
3
- "version": "2.2.0",
3
+ "version": "3.0.1",
4
4
  "author": {
5
5
  "name": "Dominik Hladík",
6
6
  "email": "dominik.hladik@seznam.cz",
@@ -10,8 +10,8 @@
10
10
  "license": "MIT",
11
11
  "description": "Angular directive for repeating HTML element by count",
12
12
  "peerDependencies": {
13
- "@angular/common": ">=12",
14
- "@angular/core": ">=12"
13
+ "@angular/common": ">=19",
14
+ "@angular/core": ">=19"
15
15
  },
16
16
  "publishConfig": {
17
17
  "registry": "https://registry.npmjs.org"
@@ -31,7 +31,7 @@
31
31
  "repeat"
32
32
  ],
33
33
  "engines": {
34
- "node": ">=12"
34
+ "node": ">=18"
35
35
  },
36
36
  "module": "fesm2022/ngx-repeat.mjs",
37
37
  "typings": "index.d.ts",