@aquera/ngx-smart-table 0.0.17-patch-0.5 → 0.0.17-patch-0.6

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.
@@ -4843,6 +4843,305 @@ class NileDatePickerEditor {
4843
4843
  }
4844
4844
  }
4845
4845
 
4846
+ /**
4847
+ * Custom editor using NileChip from @aquera/nile-elements
4848
+ * Renders the chip input in a floating popover below the cell to avoid row height mismatch.
4849
+ *
4850
+ * @see https://nile.aqueralabs.com/1.6.3/chip?theme=enterprise
4851
+ */
4852
+ let chipStylesInjected = false;
4853
+ function injectChipStyles() {
4854
+ if (chipStylesInjected)
4855
+ return;
4856
+ chipStylesInjected = true;
4857
+ const styleId = 'nile-chip-editor-styles';
4858
+ if (document.getElementById(styleId))
4859
+ return;
4860
+ const style = document.createElement('style');
4861
+ style.id = styleId;
4862
+ style.textContent = `
4863
+ .st-chip-popover {
4864
+ position: fixed;
4865
+ z-index: 10000;
4866
+ background: var(--nile-colors-white-base, #fff);
4867
+ border: 1px solid var(--nile-colors-neutral-200, #e2e8f0);
4868
+ border-radius: 6px;
4869
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
4870
+ padding: 8px;
4871
+ box-sizing: border-box;
4872
+ max-height: 200px;
4873
+ overflow-y: auto;
4874
+ }
4875
+ .st-chip-popover nile-chip {
4876
+ width: 100%;
4877
+ }
4878
+ .st-chip-popover nile-chip::part(base) {
4879
+ border: none !important;
4880
+ box-shadow: none !important;
4881
+ min-height: 32px;
4882
+ }
4883
+ .st-chip-popover nile-chip::part(input) {
4884
+ font-size: var(--nile-font-size-small, 13px);
4885
+ }
4886
+ `;
4887
+ document.head.appendChild(style);
4888
+ }
4889
+ /**
4890
+ * Custom editor that uses NileChip (tag input) component.
4891
+ * Renders in a floating popover below the cell to avoid expanding row height.
4892
+ *
4893
+ * Cell value is expected to be `string[]` (array of tag strings).
4894
+ */
4895
+ class NileChipEditor {
4896
+ constructor(options) {
4897
+ this.options = options;
4898
+ this.acceptsInitialKeypress = false;
4899
+ this.eventListeners = [];
4900
+ this.trackedValues = [];
4901
+ }
4902
+ edit(context) {
4903
+ var _a, _b;
4904
+ if (!context.container) {
4905
+ console.warn('NileChipEditor requires a container element');
4906
+ return;
4907
+ }
4908
+ injectChipStyles();
4909
+ this.cellContainer = context.container;
4910
+ // Create the floating popover
4911
+ this.popover = document.createElement('div');
4912
+ this.popover.className = 'st-chip-popover';
4913
+ // Create nile-chip inside the popover
4914
+ this.chip = document.createElement('nile-chip');
4915
+ this.chip.className = 'st-cell-editor st-nile-chip-editor';
4916
+ this.setInitialValue(context.value);
4917
+ this.applyOptions();
4918
+ this.popover.appendChild(this.chip);
4919
+ // Apply custom max-height if provided
4920
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.popoverMaxHeight) {
4921
+ this.popover.style.maxHeight = `${this.options.popoverMaxHeight}px`;
4922
+ }
4923
+ // Append popover to body and position it
4924
+ document.body.appendChild(this.popover);
4925
+ this.positionPopover();
4926
+ this.setupEventListeners(context);
4927
+ if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.autoFocus) !== false) {
4928
+ setTimeout(() => {
4929
+ var _a;
4930
+ try {
4931
+ (_a = this.chip) === null || _a === void 0 ? void 0 : _a.focus();
4932
+ }
4933
+ catch ( /* ignore */_b) { /* ignore */ }
4934
+ }, 0);
4935
+ }
4936
+ }
4937
+ positionPopover() {
4938
+ var _a, _b;
4939
+ if (!this.popover || !this.cellContainer)
4940
+ return;
4941
+ const rect = this.cellContainer.getBoundingClientRect();
4942
+ const minWidth = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.popoverMinWidth) !== null && _b !== void 0 ? _b : rect.width;
4943
+ const popoverWidth = Math.max(minWidth, rect.width);
4944
+ this.popover.style.top = `${rect.bottom + 2}px`;
4945
+ this.popover.style.left = `${rect.left}px`;
4946
+ this.popover.style.width = `${popoverWidth}px`;
4947
+ // After rendering, check if it goes off-screen bottom and flip above if needed
4948
+ requestAnimationFrame(() => {
4949
+ if (!this.popover)
4950
+ return;
4951
+ const popRect = this.popover.getBoundingClientRect();
4952
+ if (popRect.bottom > window.innerHeight) {
4953
+ this.popover.style.top = `${rect.top - popRect.height - 2}px`;
4954
+ }
4955
+ });
4956
+ }
4957
+ setInitialValue(value) {
4958
+ if (!this.chip)
4959
+ return;
4960
+ if (Array.isArray(value)) {
4961
+ this.trackedValues = [...value];
4962
+ this.chip.value = this.trackedValues;
4963
+ }
4964
+ else if (typeof value === 'string' && value) {
4965
+ this.trackedValues = [value];
4966
+ this.chip.value = this.trackedValues;
4967
+ }
4968
+ else {
4969
+ this.trackedValues = [];
4970
+ this.chip.value = [];
4971
+ }
4972
+ }
4973
+ applyOptions() {
4974
+ if (!this.chip || !this.options)
4975
+ return;
4976
+ if (this.options.placeholder) {
4977
+ this.chip.placeholder = this.options.placeholder;
4978
+ }
4979
+ if (this.options.label) {
4980
+ this.chip.label = this.options.label;
4981
+ }
4982
+ if (this.options.helpText) {
4983
+ this.chip.helpText = this.options.helpText;
4984
+ }
4985
+ if (this.options.disabled !== undefined) {
4986
+ this.chip.disabled = this.options.disabled;
4987
+ }
4988
+ if (this.options.readonly !== undefined) {
4989
+ this.chip.readonly = this.options.readonly;
4990
+ }
4991
+ if (this.options.acceptUserInput !== undefined) {
4992
+ this.chip.acceptUserInput = this.options.acceptUserInput;
4993
+ }
4994
+ if (this.options.noDuplicates !== undefined) {
4995
+ this.chip.noDuplicates = this.options.noDuplicates;
4996
+ }
4997
+ if (this.options.clearable !== undefined) {
4998
+ this.chip.clearable = this.options.clearable;
4999
+ }
5000
+ if (this.options.noWrap !== undefined) {
5001
+ this.chip.noWrap = this.options.noWrap;
5002
+ }
5003
+ if (this.options.noAutoComplete !== undefined) {
5004
+ this.chip.noAutoComplete = this.options.noAutoComplete;
5005
+ }
5006
+ if (this.options.enableVirtualScroll !== undefined) {
5007
+ this.chip.enableVirtualScroll = this.options.enableVirtualScroll;
5008
+ }
5009
+ if (this.options.openDropdownOnFocus !== undefined) {
5010
+ this.chip.openDropdownOnFocus = this.options.openDropdownOnFocus;
5011
+ }
5012
+ if (this.options.loading !== undefined) {
5013
+ this.chip.loading = this.options.loading;
5014
+ }
5015
+ // Visual states
5016
+ if (this.options.warning !== undefined) {
5017
+ this.chip.warning = this.options.warning;
5018
+ }
5019
+ if (this.options.error !== undefined) {
5020
+ this.chip.error = this.options.error;
5021
+ }
5022
+ if (this.options.success !== undefined) {
5023
+ this.chip.success = this.options.success;
5024
+ }
5025
+ if (this.options.errorMessage) {
5026
+ this.chip.errorMessage = this.options.errorMessage;
5027
+ }
5028
+ if (this.options.errorIndexes) {
5029
+ this.chip.errorIndexes = this.options.errorIndexes;
5030
+ }
5031
+ // Autocomplete options
5032
+ if (this.options.autoCompleteOptions) {
5033
+ const opts = this.options.autoCompleteOptions;
5034
+ const stringOpts = opts.map(o => { var _a; return typeof o === 'string' ? o : ((_a = o.label) !== null && _a !== void 0 ? _a : o.value); });
5035
+ this.chip.autoCompleteOptions = stringOpts;
5036
+ }
5037
+ if (this.options.filterFunction) {
5038
+ this.chip.filterFunction = this.options.filterFunction;
5039
+ }
5040
+ if (this.options.renderItemFunction) {
5041
+ this.chip.renderItemFunction = this.options.renderItemFunction;
5042
+ }
5043
+ }
5044
+ addListener(element, event, handler, capture) {
5045
+ element.addEventListener(event, handler, capture);
5046
+ this.eventListeners.push({ element, event, handler, capture });
5047
+ }
5048
+ setupEventListeners(context) {
5049
+ if (!this.chip)
5050
+ return;
5051
+ // Track chip changes
5052
+ this.addListener(this.chip, 'nile-chip-change', (e) => {
5053
+ var _a;
5054
+ const detail = e.detail;
5055
+ const newValue = Array.isArray(detail === null || detail === void 0 ? void 0 : detail.value) ? [...detail.value] : (((_a = this.chip) === null || _a === void 0 ? void 0 : _a.value) ? [...this.chip.value] : []);
5056
+ this.trackedValues = newValue;
5057
+ context.onChange(newValue);
5058
+ });
5059
+ // Keyboard handling on the chip element
5060
+ this.addListener(this.chip, 'keydown', (e) => {
5061
+ const keyEvent = e;
5062
+ if (keyEvent.key === 'Enter') {
5063
+ keyEvent.stopPropagation();
5064
+ }
5065
+ else if (keyEvent.key === 'Escape') {
5066
+ keyEvent.preventDefault();
5067
+ keyEvent.stopPropagation();
5068
+ context.onCancel();
5069
+ }
5070
+ else if (keyEvent.key === 'Tab') {
5071
+ keyEvent.preventDefault();
5072
+ keyEvent.stopPropagation();
5073
+ context.onSave(this.getCurrentValue());
5074
+ }
5075
+ });
5076
+ // Click-outside: save when clicking anywhere outside the popover
5077
+ let saveTriggered = false;
5078
+ const mousedownHandler = (e) => {
5079
+ var _a;
5080
+ if (saveTriggered)
5081
+ return;
5082
+ if (!this.popover)
5083
+ return;
5084
+ const path = e.composedPath();
5085
+ for (const el of path) {
5086
+ if (el === this.popover)
5087
+ return;
5088
+ if (el === this.chip)
5089
+ return;
5090
+ if (el instanceof HTMLElement) {
5091
+ if (((_a = el.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'nile-chip')
5092
+ return;
5093
+ if (el.className && typeof el.className === 'string' && el.className.includes('nile-chip'))
5094
+ return;
5095
+ }
5096
+ }
5097
+ saveTriggered = true;
5098
+ context.onSave(this.getCurrentValue());
5099
+ };
5100
+ document.addEventListener('mousedown', mousedownHandler, true);
5101
+ this._documentMousedownHandler = mousedownHandler;
5102
+ // Reposition on scroll/resize so popover stays aligned with the cell
5103
+ const reposition = () => this.positionPopover();
5104
+ this.addListener(window, 'resize', reposition);
5105
+ this.addListener(window, 'scroll', reposition, true);
5106
+ }
5107
+ destroy() {
5108
+ // Remove document mousedown handler
5109
+ if (this._documentMousedownHandler) {
5110
+ document.removeEventListener('mousedown', this._documentMousedownHandler, true);
5111
+ delete this._documentMousedownHandler;
5112
+ }
5113
+ // Remove all tracked listeners
5114
+ for (const { element, event, handler, capture } of this.eventListeners) {
5115
+ element.removeEventListener(event, handler, capture);
5116
+ }
5117
+ this.eventListeners = [];
5118
+ // Remove the popover from the DOM
5119
+ if (this.popover) {
5120
+ this.popover.remove();
5121
+ this.popover = undefined;
5122
+ }
5123
+ this.chip = undefined;
5124
+ this.cellContainer = undefined;
5125
+ this.trackedValues = [];
5126
+ }
5127
+ focus() {
5128
+ var _a;
5129
+ try {
5130
+ (_a = this.chip) === null || _a === void 0 ? void 0 : _a.focus();
5131
+ }
5132
+ catch ( /* ignore */_b) { /* ignore */ }
5133
+ }
5134
+ getCurrentValue() {
5135
+ if (this.trackedValues.length > 0) {
5136
+ return [...this.trackedValues];
5137
+ }
5138
+ if (!this.chip)
5139
+ return [];
5140
+ const val = this.chip.value;
5141
+ return Array.isArray(val) ? [...val] : [];
5142
+ }
5143
+ }
5144
+
4846
5145
  /**
4847
5146
  * Custom editor using NileCodeEditor from @aquera/nile-elements
4848
5147
  * This provides code editing capabilities with syntax highlighting for table cells
@@ -4984,7 +5283,7 @@ class NileCodeEditor {
4984
5283
  this.syncingFromDialog = false; // Flag to prevent inline editor from overwriting multiline content
4985
5284
  this.userEditedInline = false; // Flag to track if user has typed in inline editor
4986
5285
  this.dialogOriginalValue = ''; // Store original value when dialog opens
4987
- this.dialogCurrentValue = ''; // Track current value in dialog
5286
+ this.dialogCurrentValue = null; // Track current value in dialog
4988
5287
  }
4989
5288
  edit(context) {
4990
5289
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -5266,7 +5565,7 @@ class NileCodeEditor {
5266
5565
  getDialogEditorValue() {
5267
5566
  var _a;
5268
5567
  // Use tracked value from change events (most reliable)
5269
- if (this.dialogCurrentValue) {
5568
+ if (this.dialogCurrentValue !== null && this.dialogCurrentValue !== undefined) {
5270
5569
  return this.dialogCurrentValue.replace(/\n+$/, '');
5271
5570
  }
5272
5571
  if (!this.dialogEditor)
@@ -5296,10 +5595,9 @@ class NileCodeEditor {
5296
5595
  var _a, _b;
5297
5596
  if (!this.dialogOpen)
5298
5597
  return;
5299
- // Get the value from dialog editor - try multiple sources
5598
+ // Always read live dialog editor state to avoid stale tracked values from debounced updates
5300
5599
  let dialogValue = this.dialogCurrentValue;
5301
- // If no tracked value, try reading directly from dialog editor
5302
- if (!dialogValue && this.dialogEditor) {
5600
+ if (this.dialogEditor) {
5303
5601
  try {
5304
5602
  const shadowRoot = this.dialogEditor.shadowRoot;
5305
5603
  if (shadowRoot) {
@@ -5313,12 +5611,12 @@ class NileCodeEditor {
5313
5611
  // Fall through
5314
5612
  }
5315
5613
  // Fallback to value property
5316
- if (!dialogValue) {
5614
+ if (dialogValue === null || dialogValue === undefined) {
5317
5615
  dialogValue = (_b = this.dialogEditor.value) !== null && _b !== void 0 ? _b : '';
5318
5616
  }
5319
5617
  }
5320
5618
  // Strip trailing newlines
5321
- dialogValue = (dialogValue || '').replace(/\n+$/, '');
5619
+ dialogValue = (dialogValue !== null && dialogValue !== void 0 ? dialogValue : '').replace(/\n+$/, '');
5322
5620
  // Update tracked value and inline editor
5323
5621
  this.trackedValue = dialogValue;
5324
5622
  this.userEditedInline = false;
@@ -5360,7 +5658,7 @@ class NileCodeEditor {
5360
5658
  */
5361
5659
  closeDialogUI() {
5362
5660
  this.dialogOpen = false;
5363
- this.dialogCurrentValue = '';
5661
+ this.dialogCurrentValue = null;
5364
5662
  if (this.dialog) {
5365
5663
  this.dialog.open = false;
5366
5664
  const dialogRef = this.dialog;
@@ -5612,7 +5910,7 @@ class NileCodeEditor {
5612
5910
  this.trackedValue = null;
5613
5911
  this.userEditedInline = false;
5614
5912
  this.dialogOriginalValue = '';
5615
- this.dialogCurrentValue = '';
5913
+ this.dialogCurrentValue = null;
5616
5914
  }
5617
5915
  focus() {
5618
5916
  var _a;
@@ -13340,5 +13638,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
13340
13638
  * Generated bundle index. Do not edit.
13341
13639
  */
13342
13640
 
13343
- export { ArrayFormatter, AutosaveService, BaseColumnConfig, BooleanEditor, BooleanFormatter, BuilderPreviewComponent, BuilderToolbarComponent, Cell, CellAlignment, CellDataType, CellLifecycleState, CellVerticalAlignment, ChainValidator, ClickOutsideDirective, ColumnConfigFactory, ColumnEditorComponent, ColumnListComponent, Columns, CurrencyFormatter, DEFAULT_AUTOSAVE_CONFIG, DEFAULT_COLUMN_CONFIG, DEFAULT_TABLE_CONFIG, DateEditor, DateFormatter, DateRangeValidator, DefaultFormatter, DefinitionBuilderComponent, DefinitionBuilderModule, DefinitionBuilderService, DefinitionExportService, DefinitionImportService, EditMode, EmailValidator, FilterOperator, FunctionFormatter, FunctionValidator, JsonSchemaValidatorService, LengthValidator, NavigationDirection, NavigationKey, NileAutoCompleteEditor, NileCalendarEditor, NileCodeEditor, NileDatePickerEditor, NileInputEditor, NileSelectEditor, NumberEditor, NumberFormatter, OUFormatter, PatternValidators, PercentageFormatter, RangeValidator, RegexValidator, RequiredValidator, RowValidationService, SampleDataGeneratorService, SelectEditor, SharedTableComponentsModule, SheetState, SimpleColumnConfig, SmartTableModule, SortDirection, StAddColumnButtonComponent, StCellComponent, StColumnEditorModalComponent, StColumnFilterComponent, StColumnMenuDropdownComponent, StColumnResizeDirective, StColumnVisibilityComponent, StHeaderComponent, StKeyboardNavigationDirective, StPaginationComponent, StRowActionsDropdownComponent, StSheetActionsComponent, StSheetComponent, StTableActionsComponent, StTableComponent, StWorkbookComponent, StringFormatter, TableConfigEditorComponent, TableState, TableZIndex, TemplateFormatter, TextAreaEditor, TextEditor, UrlValidator, ValidationLoggerService, VirtualScrollService, WorkbookState, canEdit, createCellState, createMemento, dnToHumanReadable, isCellValid, isDisplayMode, isNullOrUndefined, isValidDate, isValidationSuccess, mergeTableConfig, registerFormatter, resolveFormatter, restoreFromMemento };
13641
+ export { ArrayFormatter, AutosaveService, BaseColumnConfig, BooleanEditor, BooleanFormatter, BuilderPreviewComponent, BuilderToolbarComponent, Cell, CellAlignment, CellDataType, CellLifecycleState, CellVerticalAlignment, ChainValidator, ClickOutsideDirective, ColumnConfigFactory, ColumnEditorComponent, ColumnListComponent, Columns, CurrencyFormatter, DEFAULT_AUTOSAVE_CONFIG, DEFAULT_COLUMN_CONFIG, DEFAULT_TABLE_CONFIG, DateEditor, DateFormatter, DateRangeValidator, DefaultFormatter, DefinitionBuilderComponent, DefinitionBuilderModule, DefinitionBuilderService, DefinitionExportService, DefinitionImportService, EditMode, EmailValidator, FilterOperator, FunctionFormatter, FunctionValidator, JsonSchemaValidatorService, LengthValidator, NavigationDirection, NavigationKey, NileAutoCompleteEditor, NileCalendarEditor, NileChipEditor, NileCodeEditor, NileDatePickerEditor, NileInputEditor, NileSelectEditor, NumberEditor, NumberFormatter, OUFormatter, PatternValidators, PercentageFormatter, RangeValidator, RegexValidator, RequiredValidator, RowValidationService, SampleDataGeneratorService, SelectEditor, SharedTableComponentsModule, SheetState, SimpleColumnConfig, SmartTableModule, SortDirection, StAddColumnButtonComponent, StCellComponent, StColumnEditorModalComponent, StColumnFilterComponent, StColumnMenuDropdownComponent, StColumnResizeDirective, StColumnVisibilityComponent, StHeaderComponent, StKeyboardNavigationDirective, StPaginationComponent, StRowActionsDropdownComponent, StSheetActionsComponent, StSheetComponent, StTableActionsComponent, StTableComponent, StWorkbookComponent, StringFormatter, TableConfigEditorComponent, TableState, TableZIndex, TemplateFormatter, TextAreaEditor, TextEditor, UrlValidator, ValidationLoggerService, VirtualScrollService, WorkbookState, canEdit, createCellState, createMemento, dnToHumanReadable, isCellValid, isDisplayMode, isNullOrUndefined, isValidDate, isValidationSuccess, mergeTableConfig, registerFormatter, resolveFormatter, restoreFromMemento };
13344
13642
  //# sourceMappingURL=aquera-ngx-smart-table.mjs.map