@alaarab/ogrid-angular-material 2.0.15 → 2.0.16

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.
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Component, ChangeDetectionStrategy, ViewChild, computed, Input } from '@angular/core';
8
8
  import { MatMenuModule, MatMenuTrigger } from '@angular/material/menu';
9
9
  import { MatDividerModule } from '@angular/material/divider';
10
- import { getColumnHeaderMenuItems } from '@alaarab/ogrid-core';
10
+ import { getColumnHeaderMenuItems } from '@alaarab/ogrid-angular';
11
11
  /**
12
12
  * Column header dropdown menu for pin/unpin, sort, and autosize actions.
13
13
  * Uses Angular Material MatMenu.
@@ -138,7 +138,7 @@ DataGridTableComponent = __decorate([
138
138
  [attr.rowSpan]="headerRows().length > 1 ? headerRows().length - rowIdx : null"
139
139
  [attr.data-column-id]="col.columnId"
140
140
  [attr.aria-sort]="ariaSort"
141
- [style.minWidth.px]="col.minWidth ?? 80"
141
+ [style.minWidth.px]="getEffectiveMinWidth(col)"
142
142
  [style.width.px]="colW"
143
143
  [style.maxWidth.px]="colW"
144
144
  [style.cursor]="columnReorderService.isDragging() ? 'grabbing' : 'grab'"
@@ -239,6 +239,7 @@ DataGridTableComponent = __decorate([
239
239
  >
240
240
  @let descriptor = getCellDescriptor(item, colLayout.col, rowIndex, colIdx);
241
241
  @if (descriptor.mode === 'editing-inline') {
242
+ <div class="ogrid-editing-cell">
242
243
  <ogrid-mat-inline-cell-editor
243
244
  [value]="descriptor.value"
244
245
  [item]="item"
@@ -248,6 +249,7 @@ DataGridTableComponent = __decorate([
248
249
  (commit)="commitEdit(item, colLayout.col.columnId, descriptor.value, $event, rowIndex, descriptor.globalColIndex)"
249
250
  (cancel)="cancelEdit()"
250
251
  ></ogrid-mat-inline-cell-editor>
252
+ </div>
251
253
  } @else if (descriptor.mode === 'editing-popover') {
252
254
  @let editorProps = buildPopoverEditorProps(item, colLayout.col, descriptor);
253
255
  <ogrid-mat-popover-cell-editor
@@ -518,6 +520,11 @@ DataGridTableComponent = __decorate([
518
520
  .ogrid-datagrid-cell--in-range { background: var(--ogrid-range-bg, rgba(33, 115, 70, 0.12)); }
519
521
  .ogrid-datagrid-cell--in-cut-range { background: var(--ogrid-hover-bg, rgba(0, 0, 0, 0.04)); opacity: 0.7; }
520
522
  .ogrid-datagrid-cell--editing { padding: 0; }
523
+ .ogrid-editing-cell {
524
+ width: 100%; height: 100%; display: flex; align-items: center; box-sizing: border-box;
525
+ outline: 2px solid var(--ogrid-selection-color, #217346); outline-offset: -1px;
526
+ z-index: 2; position: relative; background: var(--ogrid-bg, #fff); overflow: visible; padding: 0;
527
+ }
521
528
  .ogrid-datagrid-editor-input {
522
529
  width: 100%; height: 100%; padding: 6px 10px; border: 2px solid var(--ogrid-selection-color, #217346);
523
530
  box-sizing: border-box; font-size: 14px; outline: none; font-family: inherit; line-height: inherit;
@@ -4,109 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Component, Input, Output, EventEmitter, signal, ViewChild } from '@angular/core';
7
+ import { Component } from '@angular/core';
8
8
  import { CommonModule } from '@angular/common';
9
- let InlineCellEditorComponent = class InlineCellEditorComponent {
10
- constructor() {
11
- this.commit = new EventEmitter();
12
- this.cancel = new EventEmitter();
13
- this.localValue = signal('');
14
- this.selectOptions = signal([]);
15
- this._initialized = false;
16
- }
17
- ngOnInit() {
18
- this._initialized = true;
19
- this.syncFromInputs();
20
- }
21
- ngOnChanges() {
22
- if (this._initialized) {
23
- this.syncFromInputs();
24
- }
25
- }
26
- syncFromInputs() {
27
- const v = this.value;
28
- this.localValue.set(v != null ? String(v) : '');
29
- const col = this.column;
30
- if (col?.cellEditorParams?.values) {
31
- this.selectOptions.set(col.cellEditorParams.values);
32
- }
33
- }
34
- ngAfterViewInit() {
35
- setTimeout(() => {
36
- const el = this.inputEl?.nativeElement;
37
- if (el) {
38
- el.focus();
39
- if (el instanceof HTMLInputElement && el.type === 'text') {
40
- el.select();
41
- }
42
- }
43
- });
44
- }
45
- commitValue(value) {
46
- this.commit.emit(value);
47
- }
48
- onTextKeyDown(e) {
49
- if (e.key === 'Enter') {
50
- e.preventDefault();
51
- this.commitValue(this.localValue());
52
- }
53
- else if (e.key === 'Escape') {
54
- e.preventDefault();
55
- this.cancel.emit();
56
- }
57
- else if (e.key === 'Tab') {
58
- e.preventDefault();
59
- this.commitValue(this.localValue());
60
- }
61
- }
62
- onSelectKeyDown(e) {
63
- if (e.key === 'Escape') {
64
- e.preventDefault();
65
- this.cancel.emit();
66
- }
67
- }
68
- onCheckboxKeyDown(e) {
69
- if (e.key === 'Escape') {
70
- e.preventDefault();
71
- this.cancel.emit();
72
- }
73
- }
74
- onTextBlur() {
75
- this.commitValue(this.localValue());
76
- }
77
- getInputStyle() {
78
- const baseStyle = 'width:100%;box-sizing:border-box;padding:6px 10px;border:2px solid var(--ogrid-selection, #217346);border-radius:2px;outline:none;font:inherit;background:var(--ogrid-bg, #fff);color:var(--ogrid-fg, #242424);';
79
- const col = this.column;
80
- if (col.type === 'numeric') {
81
- return baseStyle + 'text-align:right;';
82
- }
83
- return baseStyle;
84
- }
9
+ import { BaseInlineCellEditorComponent } from '@alaarab/ogrid-angular';
10
+ let InlineCellEditorComponent = class InlineCellEditorComponent extends BaseInlineCellEditorComponent {
85
11
  };
86
- __decorate([
87
- Input({ required: true })
88
- ], InlineCellEditorComponent.prototype, "value", void 0);
89
- __decorate([
90
- Input({ required: true })
91
- ], InlineCellEditorComponent.prototype, "item", void 0);
92
- __decorate([
93
- Input({ required: true })
94
- ], InlineCellEditorComponent.prototype, "column", void 0);
95
- __decorate([
96
- Input({ required: true })
97
- ], InlineCellEditorComponent.prototype, "rowIndex", void 0);
98
- __decorate([
99
- Input({ required: true })
100
- ], InlineCellEditorComponent.prototype, "editorType", void 0);
101
- __decorate([
102
- Output()
103
- ], InlineCellEditorComponent.prototype, "commit", void 0);
104
- __decorate([
105
- Output()
106
- ], InlineCellEditorComponent.prototype, "cancel", void 0);
107
- __decorate([
108
- ViewChild('inputEl')
109
- ], InlineCellEditorComponent.prototype, "inputEl", void 0);
110
12
  InlineCellEditorComponent = __decorate([
111
13
  Component({
112
14
  selector: 'ogrid-mat-inline-cell-editor',
@@ -125,19 +27,53 @@ InlineCellEditorComponent = __decorate([
125
27
  [style]="getInputStyle()"
126
28
  />
127
29
  }
30
+ @case ('richSelect') {
31
+ <div #richSelectWrapper
32
+ style="width:100%;height:100%;display:flex;align-items:center;padding:6px 10px;box-sizing:border-box;min-width:0;position:relative">
33
+ <input
34
+ #richSelectInput
35
+ type="text"
36
+ [value]="searchText()"
37
+ (input)="onRichSelectSearch($any($event.target).value)"
38
+ (keydown)="onRichSelectKeyDown($event)"
39
+ placeholder="Search..."
40
+ style="width:100%;padding:0;border:none;background:transparent;color:inherit;font:inherit;font-size:13px;outline:none;min-width:0"
41
+ />
42
+ <div #richSelectDropdown role="listbox"
43
+ style="position:absolute;top:100%;left:0;right:0;max-height:200px;overflow-y:auto;background:var(--ogrid-bg, #fff);border:1px solid var(--ogrid-border, rgba(0,0,0,0.12));z-index:10;box-shadow:0 4px 16px rgba(0,0,0,0.2)">
44
+ @for (opt of filteredOptions(); track opt; let i = $index) {
45
+ <div role="option"
46
+ [attr.aria-selected]="i === highlightedIndex()"
47
+ (click)="commitValue(opt)"
48
+ [style]="i === highlightedIndex() ? 'padding:6px 8px;cursor:pointer;color:var(--ogrid-fg, #242424);background:var(--ogrid-bg-hover, #e8f0fe)' : 'padding:6px 8px;cursor:pointer;color:var(--ogrid-fg, #242424)'">
49
+ {{ getDisplayText(opt) }}
50
+ </div>
51
+ }
52
+ @if (filteredOptions().length === 0) {
53
+ <div style="padding:6px 8px;color:var(--ogrid-muted, #999)">No matches</div>
54
+ }
55
+ </div>
56
+ </div>
57
+ }
128
58
  @case ('select') {
129
- <div style="width:100%;height:100%;display:flex;align-items:center;padding:6px 10px;box-sizing:border-box;overflow:hidden;min-width:0">
130
- <select
131
- #inputEl
132
- [value]="localValue()"
133
- (change)="commitValue($any($event.target).value)"
134
- (keydown)="onSelectKeyDown($event)"
135
- style="width:100%;border:none;outline:none;background:transparent;font:inherit;cursor:pointer;color:var(--ogrid-fg, #242424)"
136
- >
137
- @for (opt of selectOptions(); track opt) {
138
- <option [value]="opt">{{ opt }}</option>
59
+ <div #selectWrapper tabindex="0"
60
+ style="width:100%;height:100%;display:flex;align-items:center;padding:6px 10px;box-sizing:border-box;min-width:0;position:relative"
61
+ (keydown)="onCustomSelectKeyDown($event)">
62
+ <div style="display:flex;align-items:center;justify-content:space-between;width:100%;cursor:pointer;font-size:13px;color:inherit">
63
+ <span>{{ getDisplayText(value) }}</span>
64
+ <span style="margin-left:4px;font-size:10px;opacity:0.5">&#9662;</span>
65
+ </div>
66
+ <div #selectDropdown role="listbox"
67
+ style="position:absolute;top:100%;left:0;right:0;max-height:200px;overflow-y:auto;background:var(--ogrid-bg, #fff);border:1px solid var(--ogrid-border, rgba(0,0,0,0.12));z-index:10;box-shadow:0 4px 16px rgba(0,0,0,0.2)">
68
+ @for (opt of selectOptions(); track opt; let i = $index) {
69
+ <div role="option"
70
+ [attr.aria-selected]="i === highlightedIndex()"
71
+ (click)="commitValue(opt)"
72
+ [style]="i === highlightedIndex() ? 'padding:6px 8px;cursor:pointer;color:var(--ogrid-fg, #242424);background:var(--ogrid-bg-hover, #e8f0fe)' : 'padding:6px 8px;cursor:pointer;color:var(--ogrid-fg, #242424)'">
73
+ {{ getDisplayText(opt) }}
74
+ </div>
139
75
  }
140
- </select>
76
+ </div>
141
77
  </div>
142
78
  }
143
79
  @case ('checkbox') {
@@ -1,5 +1,5 @@
1
1
  import { MatMenuTrigger } from '@angular/material/menu';
2
- import { type IColumnHeaderMenuItem, type ColumnHeaderMenuHandlers } from '@alaarab/ogrid-core';
2
+ import { type IColumnHeaderMenuItem, type ColumnHeaderMenuHandlers } from '@alaarab/ogrid-angular';
3
3
  /**
4
4
  * Column header dropdown menu for pin/unpin, sort, and autosize actions.
5
5
  * Uses Angular Material MatMenu.
@@ -1,25 +1,3 @@
1
- import { EventEmitter, ElementRef, AfterViewInit } from '@angular/core';
2
- import type { IColumnDef } from '@alaarab/ogrid-angular';
3
- export declare class InlineCellEditorComponent<T = unknown> implements AfterViewInit {
4
- value: unknown;
5
- item: T;
6
- column: IColumnDef<T>;
7
- rowIndex: number;
8
- editorType: 'text' | 'select' | 'checkbox' | 'date' | 'richSelect';
9
- commit: EventEmitter<unknown>;
10
- cancel: EventEmitter<void>;
11
- inputEl?: ElementRef<HTMLInputElement | HTMLSelectElement>;
12
- readonly localValue: import("@angular/core").WritableSignal<unknown>;
13
- readonly selectOptions: import("@angular/core").WritableSignal<unknown[]>;
14
- private _initialized;
15
- ngOnInit(): void;
16
- ngOnChanges(): void;
17
- private syncFromInputs;
18
- ngAfterViewInit(): void;
19
- commitValue(value: unknown): void;
20
- onTextKeyDown(e: KeyboardEvent): void;
21
- onSelectKeyDown(e: KeyboardEvent): void;
22
- onCheckboxKeyDown(e: KeyboardEvent): void;
23
- onTextBlur(): void;
24
- getInputStyle(): string;
1
+ import { BaseInlineCellEditorComponent } from '@alaarab/ogrid-angular';
2
+ export declare class InlineCellEditorComponent<T = unknown> extends BaseInlineCellEditorComponent<T> {
25
3
  }
@@ -1,4 +1,4 @@
1
- import type { IColumnDef, ICellEditorProps } from '@alaarab/ogrid-core';
1
+ import type { IColumnDef, ICellEditorProps } from '@alaarab/ogrid-angular';
2
2
  /**
3
3
  * PopoverCellEditor component for Angular Material.
4
4
  * Renders custom popover editor when anchor element is set.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-angular-material",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "OGrid Angular Material – MatTable-based data grid with sorting, filtering, pagination, column chooser, and CSV export.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",