@design.estate/dees-catalog 1.0.201 → 1.0.203

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-catalog",
3
- "version": "1.0.201",
3
+ "version": "1.0.203",
4
4
  "private": false,
5
5
  "description": "website for lossless.com",
6
6
  "main": "dist_ts_web/index.js",
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-catalog',
6
- version: '1.0.201',
6
+ version: '1.0.203',
7
7
  description: 'website for lossless.com'
8
8
  }
@@ -23,6 +23,7 @@ export const demoFunc = () => html`
23
23
  <dees-table
24
24
  heading1="Current Account Statement"
25
25
  heading2="Bunq - Payment Account 2 - April 2021"
26
+ .editableFields="${['description']}"
26
27
  .data=${[
27
28
  {
28
29
  date: '2021-04-01',
@@ -106,6 +107,15 @@ export const demoFunc = () => html`
106
107
  return null;
107
108
  },
108
109
  },
110
+ {
111
+ name: 'preview',
112
+ type: ['doubleClick', 'contextmenu'],
113
+ iconName: 'eye',
114
+ actionFunc: async (itemArg) => {
115
+ alert(itemArg.amount);
116
+ return null;
117
+ },
118
+ }
109
119
  ] as (ITableAction<ITableDemoData>)[] as any}"
110
120
  .displayFunction=${(itemArg) => {
111
121
  return {
@@ -37,7 +37,15 @@ export interface ITableAction<T = any> {
37
37
  /**
38
38
  * the type of the action
39
39
  */
40
- type: ('inRow' | 'contextmenu' | 'footer' | 'header' | 'preview' | 'keyCombination')[];
40
+ type: (
41
+ | 'inRow'
42
+ | 'contextmenu'
43
+ | 'doubleClick'
44
+ | 'footer'
45
+ | 'header'
46
+ | 'preview'
47
+ | 'keyCombination'
48
+ )[];
41
49
  /**
42
50
  * allows to check if the action is relevant for the given item
43
51
  * @param itemArg
@@ -96,6 +104,11 @@ export class DeesTable<T> extends DeesElement {
96
104
  })
97
105
  public selectedDataRow: T;
98
106
 
107
+ @property({
108
+ type: Array,
109
+ })
110
+ public editableFields: string[] = [];
111
+
99
112
  public files: File[] = [];
100
113
  public fileWeakMap = new WeakMap();
101
114
 
@@ -185,7 +198,7 @@ export class DeesTable<T> extends DeesElement {
185
198
  tr:hover {
186
199
  cursor: pointer;
187
200
  }
188
- tr:hover .innerCellContainer {
201
+ tr:hover td {
189
202
  background: ${cssManager.bdTheme('#22222210', '#ffffff20')};
190
203
  }
191
204
  tr:first-child:hover {
@@ -194,7 +207,7 @@ export class DeesTable<T> extends DeesElement {
194
207
  tr:first-child:hover .innerCellContainer {
195
208
  background: none;
196
209
  }
197
- tr.selected .innerCellContainer {
210
+ tr.selected td {
198
211
  background: ${cssManager.bdTheme('#22222220', '#ffffff40')};
199
212
  }
200
213
  th {
@@ -202,11 +215,17 @@ export class DeesTable<T> extends DeesElement {
202
215
  }
203
216
  th,
204
217
  td {
205
- padding: 3px 0px;
218
+ position: relative;
219
+ padding: 0px;
206
220
  border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
207
221
  }
208
222
  .innerCellContainer {
223
+ min-height: 36px;
224
+ position: relative;
225
+ height: 100%;
226
+ width: 100%;
209
227
  padding: 6px 8px;
228
+ line-height: 24px;
210
229
  }
211
230
  th:first-child .innerCellContainer,
212
231
  td:first-child .innerCellContainer {
@@ -220,6 +239,23 @@ export class DeesTable<T> extends DeesElement {
220
239
  td:last-child {
221
240
  border-right: none;
222
241
  }
242
+ td input {
243
+ width: 100%;
244
+ height: 100%;
245
+ outline: none;
246
+ border: 2px solid #fa6101;
247
+ top: 0px;
248
+ bottom: 0px;
249
+ right: 0px;
250
+ left: 0px;
251
+ position: absolute;
252
+ background: #00000060;
253
+ color: inherit;
254
+ font-family: inherit;
255
+ font-size: inherit;
256
+ font-weight: inherit;
257
+ padding: 0px 6px
258
+ }
223
259
 
224
260
  .action {
225
261
  margin: -8px 0px;
@@ -383,23 +419,39 @@ export class DeesTable<T> extends DeesElement {
383
419
  }
384
420
  }}
385
421
  @contextmenu=${async (eventArg: MouseEvent) => {
386
- DeesContextmenu.openContextMenuWithOptions(eventArg, this.getActionsForType('contextmenu').map(action => {
387
- const menuItem: plugins.tsclass.website.IMenuItem = {
388
- name: action.name,
389
- iconName: action.iconName as any,
390
- action: async () => {
391
- await action.actionFunc(itemArg);
392
- return null;
393
- }
394
- }
395
- return menuItem;
396
- }));
422
+ DeesContextmenu.openContextMenuWithOptions(
423
+ eventArg,
424
+ this.getActionsForType('contextmenu').map((action) => {
425
+ const menuItem: plugins.tsclass.website.IMenuItem = {
426
+ name: action.name,
427
+ iconName: action.iconName as any,
428
+ action: async () => {
429
+ await action.actionFunc(itemArg);
430
+ return null;
431
+ },
432
+ };
433
+ return menuItem;
434
+ })
435
+ );
397
436
  }}
398
437
  class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
399
438
  >
400
439
  ${headings.map(
401
440
  (headingArg) => html`
402
- <td>
441
+ <td
442
+ @dblclick=${(e: Event) => {
443
+ if (this.editableFields.includes(headingArg)) {
444
+ this.handleCellEditing(e, itemArg, headingArg);
445
+ } else {
446
+ const wantedAction = this.dataActions.find((actionArg) =>
447
+ actionArg.type.includes('doubleClick')
448
+ );
449
+ if (wantedAction) {
450
+ wantedAction.actionFunc(itemArg);
451
+ }
452
+ }
453
+ }}
454
+ >
403
455
  <div class="innerCellContainer">${transformedItem[headingArg]}</div>
404
456
  </td>
405
457
  `
@@ -476,4 +528,29 @@ export class DeesTable<T> extends DeesElement {
476
528
  }
477
529
  return actions;
478
530
  }
531
+
532
+ handleCellEditing(event: Event, item: T, key: string) {
533
+ const target = event.target as HTMLElement;
534
+
535
+ // Create an input element
536
+ const input = document.createElement('input');
537
+ input.type = 'text';
538
+ input.value = (item[key] as unknown as string) || '';
539
+
540
+ // When the input loses focus or the Enter key is pressed, update the data
541
+ input.addEventListener('blur', () => {
542
+ item[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
543
+ target.innerHTML = input.value; // Update the cell's display
544
+ });
545
+ input.addEventListener('keydown', (e: KeyboardEvent) => {
546
+ if (e.key === 'Enter') {
547
+ input.blur(); // This will trigger the blur event handler above
548
+ }
549
+ });
550
+
551
+ // Replace the cell's content with the input
552
+ target.innerHTML = '';
553
+ target.appendChild(input);
554
+ input.focus();
555
+ }
479
556
  }