@alaarab/ogrid-angular-radix 2.0.4 → 2.0.5

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/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-angular-radix",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "OGrid Angular Radix – Lightweight data grid with sorting, filtering, pagination, column chooser, and CSV export. Built with Angular CDK.",
5
5
  "main": "dist/esm/index.js",
6
+ "module": "dist/esm/index.js",
6
7
  "types": "dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/index.d.ts",
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/esm/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md", "LICENSE"],
16
+ "sideEffects": false,
7
17
  "keywords": ["ogrid", "datagrid", "angular", "angular-cdk", "data-table", "spreadsheet", "grid"],
8
18
  "author": "Ala Arab",
9
19
  "license": "MIT",
@@ -17,7 +27,7 @@
17
27
  "test": "jest"
18
28
  },
19
29
  "dependencies": {
20
- "@alaarab/ogrid-angular": "2.0.4",
30
+ "@alaarab/ogrid-angular": "2.0.5",
21
31
  "@angular/cdk": "^21.0.0"
22
32
  },
23
33
  "peerDependencies": {
@@ -1,38 +0,0 @@
1
- // Mock for @angular/cdk/overlay in tests
2
- class MockOverlay {
3
- position() {
4
- return {
5
- flexibleConnectedTo() {
6
- return {
7
- withPositions() {
8
- return this;
9
- }
10
- };
11
- }
12
- };
13
- }
14
-
15
- create(config) {
16
- return {
17
- attach: jest.fn(),
18
- detach: jest.fn(),
19
- dispose: jest.fn(),
20
- backdropClick: () => ({
21
- subscribe: jest.fn()
22
- })
23
- };
24
- }
25
- }
26
-
27
- class MockComponentPortal {
28
- constructor(component) {
29
- this.component = component;
30
- }
31
- }
32
-
33
- module.exports = {
34
- Overlay: MockOverlay,
35
- OverlayModule: class MockOverlayModule {},
36
- ComponentPortal: MockComponentPortal,
37
- CdkOverlayOrigin: class MockCdkOverlayOrigin {},
38
- };
@@ -1 +0,0 @@
1
- module.exports = {};
package/jest.config.js DELETED
@@ -1,43 +0,0 @@
1
- /** @type {import('jest').Config} */
2
- module.exports = {
3
- testEnvironment: 'jsdom',
4
- roots: ['<rootDir>/src'],
5
- testMatch: [
6
- '**/__tests__/**/*.test.ts',
7
- '**/__tests__/**/*.test.tsx',
8
- '**/__tests__/**/*.spec.ts',
9
- ],
10
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
11
- transform: {
12
- '^.+\\.tsx?$': [
13
- 'ts-jest',
14
- {
15
- useESM: false,
16
- tsconfig: {
17
- esModuleInterop: true,
18
- allowSyntheticDefaultImports: true,
19
- module: 'commonjs',
20
- target: 'es2019',
21
- types: ['jest', 'node'],
22
- experimentalDecorators: true,
23
- useDefineForClassFields: false,
24
- },
25
- },
26
- ],
27
- },
28
- moduleNameMapper: {
29
- '^@alaarab/ogrid-core$': '<rootDir>/../core/src/index.ts',
30
- '^@alaarab/ogrid-core/testing$': '<rootDir>/../core/src/testing/index.ts',
31
- '^@alaarab/ogrid-angular$': '<rootDir>/../angular/src/index.ts',
32
- '^@angular/core/testing$': '<rootDir>/../angular/jest-mocks/angular-core-testing.cjs.js',
33
- '^@angular/core$': '<rootDir>/../angular/jest-mocks/angular-core.cjs.js',
34
- '^@angular/common$': '<rootDir>/../angular/jest-mocks/angular-common.cjs.js',
35
- '^@angular/platform-browser$': '<rootDir>/../angular/jest-mocks/angular-platform-browser.cjs.js',
36
- '^@angular/cdk/overlay$': '<rootDir>/jest-mocks/angular-cdk-overlay.cjs.js',
37
- '\\.scss$': '<rootDir>/jest-mocks/style-mock.js',
38
- },
39
- transformIgnorePatterns: [
40
- 'node_modules/(?!(@angular|primeng)/)',
41
- ],
42
- testTimeout: 10000,
43
- };
@@ -1,53 +0,0 @@
1
- /**
2
- * Compiles all .module.scss files to .module.css and rewrites dist JS imports.
3
- */
4
- const fs = require('fs');
5
- const path = require('path');
6
- const sass = require('sass');
7
-
8
- const SRC_DIR = path.join(__dirname, '..', 'src');
9
- const DIST_ESM = path.join(__dirname, '..', 'dist', 'esm');
10
-
11
- function* walkDir(dir, base = dir) {
12
- const entries = fs.readdirSync(dir, { withFileTypes: true });
13
- for (const e of entries) {
14
- const full = path.join(dir, e.name);
15
- const rel = path.relative(base, full);
16
- if (e.isDirectory()) {
17
- yield* walkDir(full, base);
18
- } else if (e.isFile() && e.name.endsWith('.module.scss')) {
19
- yield { full, rel };
20
- }
21
- }
22
- }
23
-
24
- for (const { full, rel } of walkDir(SRC_DIR)) {
25
- const outRel = rel.replace(/\.scss$/, '.css');
26
- const outPath = path.join(DIST_ESM, outRel);
27
- const outDir = path.dirname(outPath);
28
- if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
29
- const result = sass.compile(full);
30
- fs.writeFileSync(outPath, result.css, 'utf8');
31
- console.log('Compiled:', rel, '→', outRel);
32
- }
33
-
34
- function* walkJs(dir) {
35
- if (!fs.existsSync(dir)) return;
36
- const entries = fs.readdirSync(dir, { withFileTypes: true });
37
- for (const e of entries) {
38
- const full = path.join(dir, e.name);
39
- if (e.isDirectory()) yield* walkJs(full);
40
- else if (e.isFile() && e.name.endsWith('.js')) yield full;
41
- }
42
- }
43
-
44
- for (const jsPath of walkJs(DIST_ESM)) {
45
- let content = fs.readFileSync(jsPath, 'utf8');
46
- if (content.includes('.module.scss')) {
47
- content = content.replace(/\.module\.scss/g, '.module.css');
48
- fs.writeFileSync(jsPath, content, 'utf8');
49
- console.log('Rewrote imports:', path.relative(DIST_ESM, jsPath));
50
- }
51
- }
52
-
53
- console.log('Styles compiled and dist JS imports updated.');
@@ -1,195 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DebugElement } from '@angular/core';
3
- import { By } from '@angular/platform-browser';
4
- import { ColumnChooserComponent } from '../column-chooser/column-chooser.component';
5
- import type { IColumnDefinition } from '@alaarab/ogrid-angular';
6
-
7
- describe('ColumnChooserComponent', () => {
8
- let component: ColumnChooserComponent;
9
- let fixture: ComponentFixture<ColumnChooserComponent>;
10
-
11
- const mockColumns: IColumnDefinition[] = [
12
- { columnId: 'name', name: 'Name' },
13
- { columnId: 'status', name: 'Status' },
14
- { columnId: 'priority', name: 'Priority' },
15
- ];
16
-
17
- beforeEach(async () => {
18
- await TestBed.configureTestingModule({
19
- imports: [ColumnChooserComponent],
20
- }).compileComponents();
21
-
22
- fixture = TestBed.createComponent(ColumnChooserComponent);
23
- component = fixture.componentInstance;
24
- });
25
-
26
- it('should create', () => {
27
- expect(component).toBeTruthy();
28
- });
29
-
30
- it('should display column count in trigger button', () => {
31
- fixture.componentRef.setInput('columns', mockColumns);
32
- fixture.componentRef.setInput('visibleColumns', new Set(['name', 'status']));
33
- fixture.detectChanges();
34
-
35
- const trigger = fixture.debugElement.query(By.css('.ogrid-column-chooser__trigger'));
36
- expect(trigger.nativeElement.textContent).toContain('Columns (2/3)');
37
- });
38
-
39
- it('should toggle dropdown when trigger clicked', () => {
40
- fixture.componentRef.setInput('columns', mockColumns);
41
- fixture.componentRef.setInput('visibleColumns', new Set(['name']));
42
- fixture.detectChanges();
43
-
44
- const trigger = fixture.debugElement.query(By.css('.ogrid-column-chooser__trigger'));
45
-
46
- // Initially closed
47
- expect(component.isOpen()).toBe(false);
48
- let dropdown = fixture.debugElement.query(By.css('.ogrid-column-chooser__dropdown'));
49
- expect(dropdown).toBeNull();
50
-
51
- // Click to open
52
- trigger.nativeElement.click();
53
- fixture.detectChanges();
54
- expect(component.isOpen()).toBe(true);
55
- dropdown = fixture.debugElement.query(By.css('.ogrid-column-chooser__dropdown'));
56
- expect(dropdown).toBeTruthy();
57
-
58
- // Click to close
59
- trigger.nativeElement.click();
60
- fixture.detectChanges();
61
- expect(component.isOpen()).toBe(false);
62
- });
63
-
64
- it('should show aria-expanded attribute', () => {
65
- fixture.componentRef.setInput('columns', mockColumns);
66
- fixture.componentRef.setInput('visibleColumns', new Set(['name']));
67
- fixture.detectChanges();
68
-
69
- const trigger = fixture.debugElement.query(By.css('.ogrid-column-chooser__trigger'));
70
-
71
- expect(trigger.nativeElement.getAttribute('aria-expanded')).toBe('false');
72
-
73
- component.toggle();
74
- fixture.detectChanges();
75
-
76
- expect(trigger.nativeElement.getAttribute('aria-expanded')).toBe('true');
77
- });
78
-
79
- it('should render all columns as checkboxes', () => {
80
- fixture.componentRef.setInput('columns', mockColumns);
81
- fixture.componentRef.setInput('visibleColumns', new Set(['name', 'status']));
82
- component.isOpen.set(true);
83
- fixture.detectChanges();
84
-
85
- const items = fixture.debugElement.queryAll(By.css('.ogrid-column-chooser__item'));
86
- expect(items.length).toBe(3);
87
-
88
- const checkboxes = fixture.debugElement.queryAll(By.css('input[type="checkbox"]'));
89
- expect(checkboxes.length).toBe(3);
90
- });
91
-
92
- it('should check visible columns', () => {
93
- fixture.componentRef.setInput('columns', mockColumns);
94
- fixture.componentRef.setInput('visibleColumns', new Set(['name', 'priority']));
95
- component.isOpen.set(true);
96
- fixture.detectChanges();
97
-
98
- const checkboxes = fixture.debugElement.queryAll(By.css('input[type="checkbox"]'));
99
- expect(checkboxes[0].nativeElement.checked).toBe(true); // name
100
- expect(checkboxes[1].nativeElement.checked).toBe(false); // status
101
- expect(checkboxes[2].nativeElement.checked).toBe(true); // priority
102
- });
103
-
104
- it('should emit visibilityChange when checkbox toggled', () => {
105
- fixture.componentRef.setInput('columns', mockColumns);
106
- fixture.componentRef.setInput('visibleColumns', new Set(['name']));
107
- component.isOpen.set(true);
108
- fixture.detectChanges();
109
-
110
- const visibilityChangeSpy = jest.fn();
111
- component.visibilityChange.subscribe(visibilityChangeSpy);
112
-
113
- const checkboxes = fixture.debugElement.queryAll(By.css('input[type="checkbox"]'));
114
-
115
- // Toggle status checkbox (currently unchecked)
116
- checkboxes[1].nativeElement.checked = true;
117
- checkboxes[1].nativeElement.dispatchEvent(new Event('change'));
118
- fixture.detectChanges();
119
-
120
- expect(visibilityChangeSpy).toHaveBeenCalledWith({
121
- columnKey: 'status',
122
- visible: true,
123
- });
124
- });
125
-
126
- it('should emit visibilityChange for all columns when selectAll clicked', () => {
127
- fixture.componentRef.setInput('columns', mockColumns);
128
- fixture.componentRef.setInput('visibleColumns', new Set(['name']));
129
- component.isOpen.set(true);
130
- fixture.detectChanges();
131
-
132
- const visibilityChangeSpy = jest.fn();
133
- component.visibilityChange.subscribe(visibilityChangeSpy);
134
-
135
- const selectAllBtn = fixture.debugElement.queryAll(By.css('.ogrid-column-chooser__btn'))[1];
136
- selectAllBtn.nativeElement.click();
137
- fixture.detectChanges();
138
-
139
- // Should emit for status and priority (not already visible)
140
- expect(visibilityChangeSpy).toHaveBeenCalledTimes(2);
141
- expect(visibilityChangeSpy).toHaveBeenCalledWith({ columnKey: 'status', visible: true });
142
- expect(visibilityChangeSpy).toHaveBeenCalledWith({ columnKey: 'priority', visible: true });
143
- });
144
-
145
- it('should emit visibilityChange for all columns when clearAll clicked', () => {
146
- fixture.componentRef.setInput('columns', mockColumns);
147
- fixture.componentRef.setInput('visibleColumns', new Set(['name', 'status', 'priority']));
148
- component.isOpen.set(true);
149
- fixture.detectChanges();
150
-
151
- const visibilityChangeSpy = jest.fn();
152
- component.visibilityChange.subscribe(visibilityChangeSpy);
153
-
154
- const clearAllBtn = fixture.debugElement.queryAll(By.css('.ogrid-column-chooser__btn'))[0];
155
- clearAllBtn.nativeElement.click();
156
- fixture.detectChanges();
157
-
158
- // Should emit for all 3 columns
159
- expect(visibilityChangeSpy).toHaveBeenCalledTimes(3);
160
- expect(visibilityChangeSpy).toHaveBeenCalledWith({ columnKey: 'name', visible: false });
161
- expect(visibilityChangeSpy).toHaveBeenCalledWith({ columnKey: 'status', visible: false });
162
- expect(visibilityChangeSpy).toHaveBeenCalledWith({ columnKey: 'priority', visible: false });
163
- });
164
-
165
- it('should close dropdown when clicking outside', () => {
166
- fixture.componentRef.setInput('columns', mockColumns);
167
- fixture.componentRef.setInput('visibleColumns', new Set(['name']));
168
- component.isOpen.set(true);
169
- fixture.detectChanges();
170
-
171
- // Simulate click outside
172
- const outsideElement = document.createElement('div');
173
- document.body.appendChild(outsideElement);
174
-
175
- const event = new MouseEvent('click', { bubbles: true });
176
- Object.defineProperty(event, 'target', { value: outsideElement, enumerable: true });
177
-
178
- component.onDocumentClick(event);
179
- fixture.detectChanges();
180
-
181
- expect(component.isOpen()).toBe(false);
182
-
183
- document.body.removeChild(outsideElement);
184
- });
185
-
186
- it('should display correct header text', () => {
187
- fixture.componentRef.setInput('columns', mockColumns);
188
- fixture.componentRef.setInput('visibleColumns', new Set(['name', 'status']));
189
- component.isOpen.set(true);
190
- fixture.detectChanges();
191
-
192
- const header = fixture.debugElement.query(By.css('.ogrid-column-chooser__header'));
193
- expect(header.nativeElement.textContent).toContain('Select Columns (2 of 3)');
194
- });
195
- });