@design.estate/dees-catalog 1.0.183 → 1.0.187

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.
Files changed (36) hide show
  1. package/dist_bundle/bundle.js +392 -253
  2. package/dist_bundle/bundle.js.map +4 -4
  3. package/dist_ts_web/00_commitinfo_data.js +1 -1
  4. package/dist_ts_web/elements/dees-contextmenu.d.ts +2 -0
  5. package/dist_ts_web/elements/dees-contextmenu.js +9 -1
  6. package/dist_ts_web/elements/dees-dataview-codebox.demo.d.ts +1 -0
  7. package/dist_ts_web/elements/dees-dataview-codebox.demo.js +18 -0
  8. package/dist_ts_web/elements/dees-dataview-codebox.js +54 -19
  9. package/dist_ts_web/elements/dees-dataview-statusobject.demo.d.ts +1 -0
  10. package/dist_ts_web/elements/dees-dataview-statusobject.demo.js +38 -0
  11. package/dist_ts_web/elements/dees-dataview-statusobject.js +8 -39
  12. package/dist_ts_web/elements/dees-icon.d.ts +1 -0
  13. package/dist_ts_web/elements/dees-icon.js +1 -1
  14. package/dist_ts_web/elements/dees-mobilenavigation.js +11 -17
  15. package/dist_ts_web/elements/dees-pdf.d.ts +1 -2
  16. package/dist_ts_web/elements/dees-simple-appdash.d.ts +1 -0
  17. package/dist_ts_web/elements/dees-simple-appdash.js +2 -0
  18. package/dist_ts_web/elements/dees-table.d.ts +24 -3
  19. package/dist_ts_web/elements/dees-table.js +271 -84
  20. package/dist_ts_web/elements/dees-windowlayer.d.ts +2 -0
  21. package/dist_ts_web/elements/dees-windowlayer.js +19 -3
  22. package/dist_watch/bundle.js +3442 -1724
  23. package/dist_watch/bundle.js.map +4 -4
  24. package/package.json +6 -6
  25. package/ts_web/00_commitinfo_data.ts +1 -1
  26. package/ts_web/elements/dees-contextmenu.ts +9 -0
  27. package/ts_web/elements/dees-dataview-codebox.demo.ts +18 -0
  28. package/ts_web/elements/dees-dataview-codebox.ts +57 -22
  29. package/ts_web/elements/dees-dataview-statusobject.demo.ts +39 -0
  30. package/ts_web/elements/dees-dataview-statusobject.ts +7 -38
  31. package/ts_web/elements/dees-icon.ts +2 -0
  32. package/ts_web/elements/dees-mobilenavigation.ts +8 -14
  33. package/ts_web/elements/dees-pdf.ts +2 -2
  34. package/ts_web/elements/dees-simple-appdash.ts +0 -0
  35. package/ts_web/elements/dees-table.ts +263 -53
  36. package/ts_web/elements/dees-windowlayer.ts +17 -1
@@ -9,9 +9,13 @@ import {
9
9
  unsafeCSS,
10
10
  type CSSResult,
11
11
  state,
12
+ resolveExec,
12
13
  } from '@design.estate/dees-element';
13
14
 
15
+ import { DeesContextmenu } from './dees-contextmenu.js'
16
+
14
17
  import * as domtools from '@design.estate/dees-domtools';
18
+ import { type TIconKey } from './dees-icon.js';
15
19
 
16
20
  declare global {
17
21
  interface HTMLElementTagNameMap {
@@ -19,13 +23,36 @@ declare global {
19
23
  }
20
24
  }
21
25
 
26
+ // interfaces
22
27
  export interface IDataAction<T = any> {
23
28
  name: string;
24
- iconName: string;
29
+ iconName: TIconKey;
30
+ /**
31
+ * the table behaviour to use for this action
32
+ * e.g. upload: allows to upload files to the table
33
+ */
25
34
  useTableBehaviour?: 'upload' | 'cancelUpload' | 'none';
35
+ /**
36
+ * the type of the action
37
+ */
38
+ type: 'inRow' | 'rightClick' | 'footer' | 'header' | 'preview' | 'keyCombination';
39
+ /**
40
+ * allows to check if the action is relevant for the given item
41
+ * @param itemArg
42
+ * @returns
43
+ */
44
+ actionRelevancyCheckFunc?: (itemArg: T) => boolean;
45
+ /**
46
+ * the actual action function implementation
47
+ * @param itemArg
48
+ * @returns
49
+ */
26
50
  actionFunc: (itemArg: T) => Promise<any>;
27
51
  }
28
52
 
53
+ export type TDisplayFunction<T = any> = (itemArg: T) => object;
54
+
55
+ // the table implementation
29
56
  @customElement('dees-table')
30
57
  export class DeesTable<T> extends DeesElement {
31
58
  public static demo = () => html`
@@ -35,7 +62,7 @@ export class DeesTable<T> extends DeesElement {
35
62
  position: absolute;
36
63
  width: 100%;
37
64
  height: 100%;
38
- padding: 60px;
65
+ padding: 20px;
39
66
  background: #000000;
40
67
  }
41
68
  </style>
@@ -70,22 +97,47 @@ export class DeesTable<T> extends DeesElement {
70
97
  description: 'Office-Supplies - STAPLES BREMEN',
71
98
  },
72
99
  ]}
73
- .dataActions="${[{
74
- name: 'upload',
75
- iconName: 'upload',
76
- useTableBehaviour: 'upload',
77
- actionFunc: async (itemArg: any) => {
78
-
100
+ dataName="transactions"
101
+ .dataActions="${[
102
+ {
103
+ name: 'upload',
104
+ iconName: 'bell',
105
+ useTableBehaviour: 'upload',
106
+ type: 'inRow',
107
+ actionFunc: async (itemArg: any) => {
108
+ alert(itemArg.amount);
109
+ },
79
110
  },
80
- },{
81
- name: 'visibility',
82
- iconName: 'visibility',
83
- useTableBehaviour: 'preview',
84
- actionFunc: async (itemArg: any) => {
85
-
111
+ {
112
+ name: 'visibility',
113
+ iconName: 'copy',
114
+ type: 'inRow',
115
+ useTableBehaviour: 'preview',
116
+ actionFunc: async (itemArg: any) => {},
117
+ },
118
+ {
119
+ name: 'create new',
120
+ iconName: 'instagram',
121
+ type: 'header',
122
+ useTableBehaviour: 'preview',
123
+ actionFunc: async (itemArg: any) => {},
86
124
  },
87
- }] as IDataAction[]}"
88
- >This is a slotted Text</dees-table>
125
+ {
126
+ name: 'to gallery',
127
+ iconName: 'message',
128
+ type: 'footer',
129
+ useTableBehaviour: 'preview',
130
+ actionFunc: async (itemArg: any) => {},
131
+ },
132
+ ] as IDataAction[]}"
133
+ .displayFunction=${(itemArg) => {
134
+ return {
135
+ ...itemArg,
136
+ onlyDisplayProp: 'onlyDisplay',
137
+ };
138
+ }}
139
+ >This is a slotted Text</dees-table
140
+ >
89
141
  </div>
90
142
  `;
91
143
 
@@ -106,24 +158,25 @@ export class DeesTable<T> extends DeesElement {
106
158
  public data: T[] = [];
107
159
 
108
160
  @property({
109
- type: Array,
161
+ type: String,
162
+ reflect: true,
110
163
  })
111
- public dataActions: IDataAction[] = [];
164
+ public dataName: string;
112
165
 
113
166
  @property({
114
- type: Object,
167
+ type: Array,
115
168
  })
116
- public selectedDataRow: T;
169
+ public dataActions: IDataAction[] = [];
117
170
 
118
171
  @property({
119
- type: String,
172
+ attribute: false,
120
173
  })
121
- public type: 'normal' | 'highlighted' | 'discreet' | 'big' = 'normal';
174
+ public displayFunction: TDisplayFunction = (itemArg: T) => itemArg as any;
122
175
 
123
176
  @property({
124
- type: String,
177
+ type: Object,
125
178
  })
126
- public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
179
+ public selectedDataRow: T;
127
180
 
128
181
  public files: File[] = [];
129
182
  public fileWeakMap = new WeakMap();
@@ -139,7 +192,7 @@ export class DeesTable<T> extends DeesElement {
139
192
  color: ${cssManager.bdTheme('#333', '#fff')};
140
193
  font-family: 'Mona Sans', 'Inter', sans-serif;
141
194
  font-weight: 400;
142
- font-size: 16px;
195
+ font-size: 14px;
143
196
  padding: 16px;
144
197
  display: block;
145
198
  width: 100%;
@@ -150,11 +203,49 @@ export class DeesTable<T> extends DeesElement {
150
203
  box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3);
151
204
  overflow-x: auto;
152
205
  }
206
+
207
+ .header {
208
+ display: flex;
209
+ justify-content: flex-end;
210
+ align-items: center;
211
+ }
212
+
213
+ .headingContainer {
214
+ }
215
+
216
+ .heading {
217
+ font-family: 'Hubot Sans', 'Inter', sans-serif;
218
+ }
219
+
220
+ .heading1 {
221
+ font-weight: 600;
222
+ }
223
+ .heading2 {
224
+ opacity: 0.6;
225
+ }
226
+
153
227
  .headingSeparation {
154
228
  margin-top: 7px;
155
229
  border-bottom: 1px solid ${cssManager.bdTheme('#bcbcbc', '#bcbcbc')};
156
230
  }
157
231
 
232
+ .headerActions {
233
+ margin-left: auto;
234
+ cursor: pointer;
235
+ }
236
+ .headerAction {
237
+ display: flex;
238
+ color: ${cssManager.bdTheme('#333', '#ccc')};
239
+ }
240
+
241
+ .headerAction:hover {
242
+ color: ${cssManager.bdTheme('#555', '#fff')};
243
+ }
244
+
245
+ .headerAction dees-icon {
246
+ margin-right: 8px;
247
+ }
248
+
158
249
  table,
159
250
  .noDataSet {
160
251
  margin-top: 16px;
@@ -186,7 +277,7 @@ export class DeesTable<T> extends DeesElement {
186
277
  background: none;
187
278
  }
188
279
  tr.selected .innerCellContainer {
189
- background: ${cssManager.bdTheme('#22222220', '#ffffff20')};
280
+ background: ${cssManager.bdTheme('#22222220', '#ffffff40')};
190
281
  }
191
282
  th {
192
283
  text-transform: uppercase;
@@ -228,14 +319,37 @@ export class DeesTable<T> extends DeesElement {
228
319
  background: ${cssManager.bdTheme('#CCC', '#111')};
229
320
  }
230
321
 
231
- .tableStatistics {
232
- padding: 4px 16px;
233
- font-size: 12px;
322
+ .footer {
323
+ font-size: 14px;
234
324
  color: ${cssManager.bdTheme('#111', '#ffffff90')};
235
325
  background: ${cssManager.bdTheme('#eeeeeb', '#00000050')};
236
326
  margin: 16px -16px -16px -16px;
237
327
  border-bottom-left-radius: 3px;
238
328
  border-bottom-right-radius: 3px;
329
+ display: flex;
330
+ }
331
+
332
+ .tableStatistics {
333
+ padding: 8px 16px;
334
+ }
335
+
336
+ .footerActions {
337
+ margin-left: auto;
338
+ }
339
+
340
+ .footerActions .footerAction {
341
+ cursor: pointer;
342
+ padding: 8px 16px;
343
+ display: flex;
344
+ }
345
+
346
+ .footerActions .footerAction:hover {
347
+ background: ${cssManager.bdTheme('#CCC', '#111')};
348
+ }
349
+
350
+ .footerActions dees-icon {
351
+ display: flex;
352
+ margin-right: 8px;
239
353
  }
240
354
  `,
241
355
  ];
@@ -244,15 +358,44 @@ export class DeesTable<T> extends DeesElement {
244
358
  return html`
245
359
  <div class="mainbox">
246
360
  <!-- the heading part -->
247
- <div>${this.heading1}</div>
248
- <div>${this.heading2}</div>
361
+ <div class="header">
362
+ <div class="headingContainer">
363
+ <div class="heading heading1">${this.heading1}</div>
364
+ <div class="heading heading2">${this.heading2}</div>
365
+ </div>
366
+ <div class="headerActions">
367
+ ${resolveExec(async () => {
368
+ const resultArray: TemplateResult[] = [];
369
+ for (const action of this.dataActions) {
370
+ if (action.type !== 'header') continue;
371
+ resultArray.push(
372
+ html`<div
373
+ class="headerAction"
374
+ @click=${() => {
375
+ action.actionFunc(this.selectedDataRow);
376
+ }}
377
+ >
378
+ ${action.iconName
379
+ ? html`<dees-icon .iconSize=${14} .iconFA=${action.iconName}></dees-icon>
380
+ ${action.name}`
381
+ : action.name}
382
+ </div>`
383
+ );
384
+ }
385
+ return resultArray;
386
+ })}
387
+ </div>
388
+ </div>
249
389
  <div class="headingSeparation"></div>
250
390
 
251
391
  <!-- the actual table -->
252
392
  <style></style>
253
393
  ${this.data.length > 0
254
394
  ? (() => {
255
- const headings: string[] = Object.keys(this.data[0]);
395
+ // Only pick up the keys from the first transformed data object
396
+ // as all data objects are assumed to have the same structure
397
+ const firstTransformedItem = this.displayFunction(this.data[0]);
398
+ const headings: string[] = Object.keys(firstTransformedItem);
256
399
  return html`
257
400
  <table>
258
401
  <tr>
@@ -273,32 +416,42 @@ export class DeesTable<T> extends DeesElement {
273
416
  }
274
417
  })()}
275
418
  </tr>
276
- ${this.data.map(
277
- (itemArg) => html`
419
+ ${this.data.map((itemArg) => {
420
+ const transformedItem = this.displayFunction(itemArg);
421
+ const getTr = (elementArg: HTMLElement): HTMLElement => {
422
+ if (elementArg.tagName === 'TR') {
423
+ return elementArg;
424
+ } else {
425
+ return getTr(elementArg.parentElement);
426
+ }
427
+ };
428
+ return html`
278
429
  <tr
279
430
  @click=${() => {
280
431
  this.selectedDataRow = itemArg;
281
432
  }}
282
433
  @dragenter=${async (eventArg: DragEvent) => {
283
- console.log((eventArg.target as HTMLElement).tagName)
284
- console.log('dragenter');
285
434
  eventArg.preventDefault();
286
435
  eventArg.stopPropagation();
287
- (eventArg.target as HTMLElement).parentElement.style.background = '#800000';
436
+ const realTarget = getTr(eventArg.target as HTMLElement);
437
+ console.log('dragenter');
438
+ console.log(realTarget);
439
+ setTimeout(() => {
440
+ realTarget.style.background = 'green';
441
+ }, 0);
288
442
  }}
289
443
  @dragleave=${async (eventArg: DragEvent) => {
290
- console.log((eventArg.target as HTMLElement).tagName)
291
- console.log('dragleave');
292
444
  eventArg.preventDefault();
293
445
  eventArg.stopPropagation();
294
- (eventArg.target as HTMLElement).parentElement.style.background = 'none';
446
+ const realTarget = getTr(eventArg.target as HTMLElement);
447
+ realTarget.style.background = 'none';
295
448
  }}
296
449
  @dragover=${async (eventArg: DragEvent) => {
297
450
  eventArg.preventDefault();
298
451
  }}
299
452
  @drop=${async (eventArg: DragEvent) => {
300
453
  eventArg.preventDefault();
301
- const newFiles = []
454
+ const newFiles = [];
302
455
  for (const file of Array.from(eventArg.dataTransfer.files)) {
303
456
  this.files.push(file);
304
457
  newFiles.push(file);
@@ -306,17 +459,41 @@ export class DeesTable<T> extends DeesElement {
306
459
  }
307
460
  const result: File[] = this.fileWeakMap.get(itemArg as object);
308
461
  if (!result) {
309
- this.fileWeakMap.set(itemArg as object, newFiles)
462
+ this.fileWeakMap.set(itemArg as object, newFiles);
310
463
  } else {
311
464
  result.push(...newFiles);
312
465
  }
313
466
  }}
467
+ @contextmenu=${async (eventArg: MouseEvent) => {
468
+ DeesContextmenu.openContextMenuWithOptions(eventArg, [
469
+ {
470
+ name: 'copy',
471
+ iconName: 'copySolid',
472
+ action: async () => {
473
+ return null;
474
+ },
475
+ },
476
+ {
477
+ name: 'edit',
478
+ iconName: 'penToSquare',
479
+ action: async () => {
480
+ return null;
481
+ },
482
+ },{
483
+ name: 'paste',
484
+ iconName: 'pasteSolid',
485
+ action: async () => {
486
+ return null;
487
+ },
488
+ },
489
+ ])
490
+ }}
314
491
  class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
315
492
  >
316
493
  ${headings.map(
317
494
  (headingArg) => html`
318
495
  <td>
319
- <div class="innerCellContainer">${itemArg[headingArg]}</div>
496
+ <div class="innerCellContainer">${transformedItem[headingArg]}</div>
320
497
  </td>
321
498
  `
322
499
  )}
@@ -328,9 +505,19 @@ export class DeesTable<T> extends DeesElement {
328
505
  ${(() => {
329
506
  const actions: TemplateResult[] = [];
330
507
  for (const action of this.dataActions) {
331
- actions.push(html`<div class="action">${action.iconName ? html`
332
- <dees-icon .iconName=${'upload_file'}></dees-icon>
333
- ` : action.name}</div>`)
508
+ if (action.type !== 'inRow') continue;
509
+ actions.push(
510
+ html`<div
511
+ class="action"
512
+ @click=${() => action.actionFunc(itemArg)}
513
+ >
514
+ ${action.iconName
515
+ ? html`
516
+ <dees-icon .iconFA=${action.iconName}></dees-icon>
517
+ `
518
+ : action.name}
519
+ </div>`
520
+ );
334
521
  }
335
522
  return actions;
336
523
  })()}
@@ -340,17 +527,40 @@ export class DeesTable<T> extends DeesElement {
340
527
  }
341
528
  })()}
342
529
  </tr>
343
- `
344
- )}
530
+ `;
531
+ })}
345
532
  </table>
346
533
  `;
347
534
  })()
348
535
  : html` <div class="noDataSet">No data set!</div> `}
349
- <div class="tableStatistics">
350
- ${this.data.length} data rows (total) |
351
- ${this.selectedDataRow
352
- ? html`Row ${this.data.indexOf(this.selectedDataRow) + 1} selected`
353
- : html`No row selected`}
536
+ <div class="footer">
537
+ <div class="tableStatistics">
538
+ ${this.data.length} ${this.dataName || 'data rows'} (total) |
539
+ ${this.selectedDataRow ? '# ' + `${this.data.indexOf(this.selectedDataRow) + 1}` : `No`}
540
+ selected
541
+ </div>
542
+ <div class="footerActions">
543
+ ${resolveExec(async () => {
544
+ const resultArray: TemplateResult[] = [];
545
+ for (const action of this.dataActions) {
546
+ if (action.type !== 'footer') continue;
547
+ resultArray.push(
548
+ html`<div
549
+ class="footerAction"
550
+ @click=${() => {
551
+ action.actionFunc(this.selectedDataRow);
552
+ }}
553
+ >
554
+ ${action.iconName
555
+ ? html`<dees-icon .iconSize=${14} .iconFA=${action.iconName}></dees-icon>
556
+ ${action.name}`
557
+ : action.name}
558
+ </div>`
559
+ );
560
+ }
561
+ return resultArray;
562
+ })}
563
+ </div>
354
564
  </div>
355
565
  </div>
356
566
  `;
@@ -13,6 +13,15 @@ export class DeesWindowLayer extends DeesElement {
13
13
  // STATIC
14
14
  public static demo = () => html`<dees-windowlayer></dees-windowlayer>`;
15
15
 
16
+ public static async createAndShow() {
17
+ const domtoolsInstance = domtools.DomTools.getGlobalDomToolsSync();
18
+ const windowLayer = new DeesWindowLayer();
19
+ document.body.append(windowLayer);
20
+ await domtoolsInstance.convenience.smartdelay.delayFor(0);
21
+ windowLayer.show();
22
+ return windowLayer;
23
+ }
24
+
16
25
  // INSTANCE
17
26
  @property({
18
27
  type: Boolean
@@ -29,7 +38,7 @@ export class DeesWindowLayer extends DeesElement {
29
38
  ${domtools.elementBasic.styles}
30
39
  <style>
31
40
  .windowOverlay {
32
- transition: all 0.3s;
41
+ transition: all 0.2s;
33
42
  will-change: transform;
34
43
  position: fixed;
35
44
  top: 0px;
@@ -82,4 +91,11 @@ export class DeesWindowLayer extends DeesElement {
82
91
  await domtools.convenience.smartdelay.delayFor(0);
83
92
  this.visible = false;
84
93
  }
94
+
95
+ public async destroy() {
96
+ const domtools = await this.domtoolsPromise;
97
+ await this.hide();
98
+ await domtools.convenience.smartdelay.delayFor(300);
99
+ this.remove();
100
+ }
85
101
  }