@design.estate/dees-catalog 3.99.0 → 3.99.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.
@@ -116,6 +116,15 @@ export class DeesTable<T> extends DeesElement {
116
116
  type: Array,
117
117
  })
118
118
  accessor dataActions: ITableAction<T>[] = [];
119
+ private readonly __searchAction: ITableAction<T> = {
120
+ name: 'Search',
121
+ iconName: 'lucide:Search',
122
+ type: ['header'],
123
+ actionFunc: async () => {
124
+ const searchGrid = this.shadowRoot!.querySelector('.searchGrid');
125
+ searchGrid!.classList.toggle('hidden');
126
+ },
127
+ };
119
128
 
120
129
  // schema-first columns API
121
130
  @property({ attribute: false })
@@ -854,7 +863,7 @@ export class DeesTable<T> extends DeesElement {
854
863
  ${this.renderSortIndicator(col)}
855
864
  </th>`;
856
865
  })}
857
- ${this.dataActions && this.dataActions.length > 0
866
+ ${this.__getEffectiveDataActions().length > 0
858
867
  ? html`<th class="actionsCol">Actions</th>`
859
868
  : html``}
860
869
  </tr>
@@ -873,7 +882,7 @@ export class DeesTable<T> extends DeesElement {
873
882
  @input=${(e: Event) => this.setColumnFilter(key, (e.target as HTMLInputElement).value)} />
874
883
  </th>`;
875
884
  })}
876
- ${this.dataActions && this.dataActions.length > 0
885
+ ${this.__getEffectiveDataActions().length > 0
877
886
  ? html`<th></th>`
878
887
  : html``}
879
888
  </tr>`
@@ -1512,21 +1521,6 @@ export class DeesTable<T> extends DeesElement {
1512
1521
  this.__syncFloatingHeader();
1513
1522
  }
1514
1523
  if (this.searchable) {
1515
- const existing = this.dataActions.find((actionArg) => actionArg.type?.includes('header') && actionArg.name === 'Search');
1516
- if (!existing) {
1517
- this.dataActions.unshift({
1518
- name: 'Search',
1519
- iconName: 'lucide:Search',
1520
- type: ['header'],
1521
- actionFunc: async () => {
1522
- console.log('open search');
1523
- const searchGrid = this.shadowRoot!.querySelector('.searchGrid');
1524
- searchGrid!.classList.toggle('hidden');
1525
- }
1526
- });
1527
- console.log(this.dataActions);
1528
- this.requestUpdate();
1529
- };
1530
1524
  // wire search inputs
1531
1525
  this.wireSearchInputs();
1532
1526
  }
@@ -1595,7 +1589,9 @@ export class DeesTable<T> extends DeesElement {
1595
1589
  const width = window.getComputedStyle(cell).width;
1596
1590
  if (cell.textContent.includes('Actions')) {
1597
1591
  const neededWidth =
1598
- this.dataActions.filter((actionArg) => actionArg.type?.includes('inRow')).length * 36;
1592
+ this.__getEffectiveDataActions().filter((actionArg) =>
1593
+ actionArg.type?.includes('inRow')
1594
+ ).length * 36;
1599
1595
  cell.style.width = `${Math.max(neededWidth, 68)}px`;
1600
1596
  } else {
1601
1597
  cell.style.width = width;
@@ -2121,7 +2117,7 @@ export class DeesTable<T> extends DeesElement {
2121
2117
  this.startEditing(cell.item, cell.col);
2122
2118
  return;
2123
2119
  }
2124
- const dblAction = this.dataActions.find(
2120
+ const dblAction = this.__getEffectiveDataActions().find(
2125
2121
  (action) =>
2126
2122
  action.type?.includes('doubleClick')
2127
2123
  && this.isActionRelevant(action, cell.item)
@@ -2349,9 +2345,21 @@ export class DeesTable<T> extends DeesElement {
2349
2345
  );
2350
2346
  }
2351
2347
 
2348
+ private __getEffectiveDataActions(): ITableAction<T>[] {
2349
+ if (
2350
+ !this.searchable
2351
+ || this.dataActions.some((actionArg) =>
2352
+ actionArg.type?.includes('header') && actionArg.name === 'Search'
2353
+ )
2354
+ ) {
2355
+ return this.dataActions;
2356
+ }
2357
+ return [this.__searchAction, ...this.dataActions];
2358
+ }
2359
+
2352
2360
  getActionsForType(typeArg: ITableAction['type'][0]) {
2353
2361
  const actions: ITableAction[] = [];
2354
- for (const action of this.dataActions) {
2362
+ for (const action of this.__getEffectiveDataActions()) {
2355
2363
  if (!action.type?.includes(typeArg)) continue;
2356
2364
  actions.push(action);
2357
2365
  }