Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
7c0eb3290f | |||
62403625ba | |||
9a34b03540 | |||
8bb63df7e3 | |||
65cd73845a | |||
8534bc254b | |||
2a2fd324a0 | |||
58e3de2559 | |||
c30736870d | |||
cfd48de885 | |||
462df2b648 | |||
f64da93cf9 | |||
a55db621ef | |||
c033bdfc3b | |||
2610e56ec1 | |||
08aa9e3fe4 | |||
411ae7ee07 | |||
41700c1eb1 | |||
8d7bac9793 | |||
0229eefa4d | |||
61f646743a | |||
e3babde7e8 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@design.estate/dees-catalog",
|
||||
"version": "1.0.196",
|
||||
"version": "1.0.207",
|
||||
"private": false,
|
||||
"description": "website for lossless.com",
|
||||
"main": "dist_ts_web/index.js",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-catalog',
|
||||
version: '1.0.196',
|
||||
version: '1.0.207',
|
||||
description: 'website for lossless.com'
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ export class DeesContextmenu extends DeesElement {
|
||||
color: ${cssManager.bdTheme('#222', '#ccc')};
|
||||
font-size: 14px;
|
||||
width: 200px;
|
||||
border: 1px solid #444;
|
||||
border: 1px solid ${cssManager.bdTheme('#fff', '#444')};
|
||||
min-height: 34px;
|
||||
border-radius: 3px;
|
||||
background: #222;
|
||||
box-shadow: 0px 1px 4px #000;
|
||||
background: ${cssManager.bdTheme('#fff', '#222')};
|
||||
box-shadow: 0px 1px 4px ${cssManager.bdTheme('#00000020', '#000000')};
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ export class DeesContextmenu extends DeesElement {
|
||||
|
||||
.mainbox .menuitem:hover {
|
||||
cursor: pointer;
|
||||
background: #ffffff10;
|
||||
background: ${cssManager.bdTheme('#00000010', '#ffffff10')};
|
||||
}
|
||||
|
||||
.mainbox .menuitem:active {
|
||||
|
@ -42,6 +42,7 @@ import {
|
||||
faCircleInfo as faCircleInfoSolid,
|
||||
faCircleCheck as faCircleCheckSolid,
|
||||
faCircleXmark as faCircleXmarkSolid,
|
||||
faClockRotateLeft as faClockRotateLeftSolid,
|
||||
faCopy as faCopySolid,
|
||||
faDesktop as faDesktopSolid,
|
||||
faEye as faEyeSolid,
|
||||
@ -82,6 +83,8 @@ export const faIcons = {
|
||||
circleCheckSolid: faCircleCheckSolid,
|
||||
circleXmark: faCircleXmarkRegular,
|
||||
circleXmarkSolid: faCircleXmarkSolid,
|
||||
clockRotateLeft: faClockRotateLeftSolid,
|
||||
clockRotateLeftSolid: faClockRotateLeftSolid,
|
||||
copy: faCopyRegular,
|
||||
copySolid: faCopySolid,
|
||||
desktop: faDesktopSolid,
|
||||
@ -95,7 +98,7 @@ export const faIcons = {
|
||||
message: faMessageRegular,
|
||||
messageSolid: faMessageSolid,
|
||||
mugHot: faMugHotSolid,
|
||||
faMugHotSolid: faMugHotSolid,
|
||||
mugHotSolid: faMugHotSolid,
|
||||
minus: faMinusSolid,
|
||||
minusSolid: faMinusSolid,
|
||||
paste: faPasteRegular,
|
||||
|
@ -124,7 +124,7 @@ export class DeesInputText extends DeesElement {
|
||||
|
||||
.showPassword:hover {
|
||||
cursor: pointer;
|
||||
background: #333;
|
||||
background: ${cssManager.bdTheme('#00000010', '#ffffff10')};
|
||||
}
|
||||
</style>
|
||||
<div class="maincontainer">
|
||||
|
@ -86,7 +86,7 @@ export class DeesModal extends DeesElement {
|
||||
}
|
||||
.modal {
|
||||
will-change: transform;
|
||||
transform: translateY(10px);
|
||||
transform: translateY(0px) scale(0.95);
|
||||
opacity: 0;
|
||||
width: 480px;
|
||||
min-height: 120px;
|
||||
@ -100,7 +100,12 @@ export class DeesModal extends DeesElement {
|
||||
|
||||
.modal.show {
|
||||
opacity: 1;
|
||||
transform: translateY(0px);
|
||||
transform: translateY(0px) scale(1);
|
||||
}
|
||||
|
||||
.modal.show.predestroy {
|
||||
opacity: 0;
|
||||
transform: translateY(10px) scale(1);
|
||||
}
|
||||
|
||||
.modal .heading {
|
||||
@ -183,7 +188,7 @@ export class DeesModal extends DeesElement {
|
||||
public async destroy() {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
const modal = this.shadowRoot.querySelector('.modal');
|
||||
modal.classList.remove('show');
|
||||
modal.classList.add('predestroy');
|
||||
await domtools.convenience.smartdelay.delayFor(200);
|
||||
document.body.removeChild(this);
|
||||
await this.windowLayer.destroy();
|
||||
|
@ -2,6 +2,12 @@ import { type ITableAction } from './dees-table.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
interface ITableDemoData {
|
||||
date: string;
|
||||
amount: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.demoWrapper {
|
||||
@ -17,6 +23,7 @@ export const demoFunc = () => html`
|
||||
<dees-table
|
||||
heading1="Current Account Statement"
|
||||
heading2="Bunq - Payment Account 2 - April 2021"
|
||||
.editableFields="${['description']}"
|
||||
.data=${[
|
||||
{
|
||||
date: '2021-04-01',
|
||||
@ -51,7 +58,7 @@ export const demoFunc = () => html`
|
||||
iconName: 'bell',
|
||||
useTableBehaviour: 'upload',
|
||||
type: ['inRow'],
|
||||
actionFunc: async (itemArg: any) => {
|
||||
actionFunc: async (itemArg) => {
|
||||
alert(itemArg.amount);
|
||||
},
|
||||
},
|
||||
@ -100,7 +107,16 @@ export const demoFunc = () => html`
|
||||
return null;
|
||||
},
|
||||
},
|
||||
] as ITableAction[]}"
|
||||
{
|
||||
name: 'preview',
|
||||
type: ['doubleClick', 'contextmenu'],
|
||||
iconName: 'eye',
|
||||
actionFunc: async (itemArg) => {
|
||||
alert(itemArg.amount);
|
||||
return null;
|
||||
},
|
||||
}
|
||||
] as (ITableAction<ITableDemoData>)[] as any}"
|
||||
.displayFunction=${(itemArg) => {
|
||||
return {
|
||||
...itemArg,
|
||||
|
@ -37,7 +37,15 @@ export interface ITableAction<T = any> {
|
||||
/**
|
||||
* the type of the action
|
||||
*/
|
||||
type: ('inRow' | 'contextmenu' | 'footer' | 'header' | 'preview' | 'keyCombination')[];
|
||||
type: (
|
||||
| 'inRow'
|
||||
| 'contextmenu'
|
||||
| 'doubleClick'
|
||||
| 'footer'
|
||||
| 'header'
|
||||
| 'preview'
|
||||
| 'keyCombination'
|
||||
)[];
|
||||
/**
|
||||
* allows to check if the action is relevant for the given item
|
||||
* @param itemArg
|
||||
@ -84,7 +92,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
@property({
|
||||
type: Array,
|
||||
})
|
||||
public dataActions: ITableAction[] = [];
|
||||
public dataActions: ITableAction<T>[] = [];
|
||||
|
||||
@property({
|
||||
attribute: false,
|
||||
@ -96,6 +104,11 @@ export class DeesTable<T> extends DeesElement {
|
||||
})
|
||||
public selectedDataRow: T;
|
||||
|
||||
@property({
|
||||
type: Array,
|
||||
})
|
||||
public editableFields: string[] = [];
|
||||
|
||||
public files: File[] = [];
|
||||
public fileWeakMap = new WeakMap();
|
||||
|
||||
@ -185,8 +198,8 @@ export class DeesTable<T> extends DeesElement {
|
||||
tr:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
tr:hover .innerCellContainer {
|
||||
background: ${cssManager.bdTheme('#22222210', '#ffffff20')};
|
||||
tr:hover td {
|
||||
background: ${cssManager.bdTheme('#22222210', '#ffffff10')};
|
||||
}
|
||||
tr:first-child:hover {
|
||||
cursor: auto;
|
||||
@ -194,19 +207,30 @@ export class DeesTable<T> extends DeesElement {
|
||||
tr:first-child:hover .innerCellContainer {
|
||||
background: none;
|
||||
}
|
||||
tr.selected .innerCellContainer {
|
||||
background: ${cssManager.bdTheme('#22222220', '#ffffff40')};
|
||||
tr.selected td {
|
||||
background: ${cssManager.bdTheme('#22222220', '#ffffff20')};
|
||||
}
|
||||
|
||||
tr.hasAttachment td {
|
||||
background: ${cssManager.bdTheme('#0098847c', '#0098847c')};
|
||||
}
|
||||
|
||||
th {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 3px 0px;
|
||||
position: relative;
|
||||
padding: 0px;
|
||||
border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
|
||||
}
|
||||
.innerCellContainer {
|
||||
min-height: 36px;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
line-height: 24px;
|
||||
}
|
||||
th:first-child .innerCellContainer,
|
||||
td:first-child .innerCellContainer {
|
||||
@ -220,11 +244,29 @@ export class DeesTable<T> extends DeesElement {
|
||||
td:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
td input {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
outline: none;
|
||||
border: 2px solid #fa6101;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
background: #fa610140;
|
||||
color: inherit;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
font-weight: inherit;
|
||||
padding: 0px 6px
|
||||
}
|
||||
|
||||
.action {
|
||||
margin: -8px 0px;
|
||||
padding: 8px;
|
||||
line-height: 16px;
|
||||
margin: -6px 0px;
|
||||
padding: 10px;
|
||||
line-height: 36px;
|
||||
height: 36px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@ -234,7 +276,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
}
|
||||
|
||||
.action:hover {
|
||||
background: ${cssManager.bdTheme('#CCC', '#111')};
|
||||
background: ${cssManager.bdTheme('#CCC', '#00000030')};
|
||||
}
|
||||
|
||||
.footer {
|
||||
@ -355,14 +397,14 @@ export class DeesTable<T> extends DeesElement {
|
||||
console.log('dragenter');
|
||||
console.log(realTarget);
|
||||
setTimeout(() => {
|
||||
realTarget.style.background = 'green';
|
||||
realTarget.classList.add('hasAttachment');
|
||||
}, 0);
|
||||
}}
|
||||
@dragleave=${async (eventArg: DragEvent) => {
|
||||
eventArg.preventDefault();
|
||||
eventArg.stopPropagation();
|
||||
const realTarget = getTr(eventArg.target as HTMLElement);
|
||||
realTarget.style.background = 'none';
|
||||
realTarget.classList.remove('hasAttachment');
|
||||
}}
|
||||
@dragover=${async (eventArg: DragEvent) => {
|
||||
eventArg.preventDefault();
|
||||
@ -383,23 +425,39 @@ export class DeesTable<T> extends DeesElement {
|
||||
}
|
||||
}}
|
||||
@contextmenu=${async (eventArg: MouseEvent) => {
|
||||
DeesContextmenu.openContextMenuWithOptions(eventArg, this.getActionsForType('contextmenu').map(action => {
|
||||
const menuItem: plugins.tsclass.website.IMenuItem = {
|
||||
name: action.name,
|
||||
iconName: action.iconName as any,
|
||||
action: async () => {
|
||||
await action.actionFunc(itemArg);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return menuItem;
|
||||
}));
|
||||
DeesContextmenu.openContextMenuWithOptions(
|
||||
eventArg,
|
||||
this.getActionsForType('contextmenu').map((action) => {
|
||||
const menuItem: plugins.tsclass.website.IMenuItem = {
|
||||
name: action.name,
|
||||
iconName: action.iconName as any,
|
||||
action: async () => {
|
||||
await action.actionFunc(itemArg);
|
||||
return null;
|
||||
},
|
||||
};
|
||||
return menuItem;
|
||||
})
|
||||
);
|
||||
}}
|
||||
class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
|
||||
>
|
||||
${headings.map(
|
||||
(headingArg) => html`
|
||||
<td>
|
||||
<td
|
||||
@dblclick=${(e: Event) => {
|
||||
if (this.editableFields.includes(headingArg)) {
|
||||
this.handleCellEditing(e, itemArg, headingArg);
|
||||
} else {
|
||||
const wantedAction = this.dataActions.find((actionArg) =>
|
||||
actionArg.type.includes('doubleClick')
|
||||
);
|
||||
if (wantedAction) {
|
||||
wantedAction.actionFunc(itemArg);
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="innerCellContainer">${transformedItem[headingArg]}</div>
|
||||
</td>
|
||||
`
|
||||
@ -468,6 +526,45 @@ export class DeesTable<T> extends DeesElement {
|
||||
|
||||
public async firstUpdated() {}
|
||||
|
||||
public async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
|
||||
super.updated(changedProperties);
|
||||
this.freezeColumnWidths();
|
||||
}
|
||||
|
||||
freezeColumnWidths() {
|
||||
// Get the table element
|
||||
const table = this.shadowRoot.querySelector('table');
|
||||
if (!table) return;
|
||||
|
||||
// Create a colgroup if it doesn't exist
|
||||
let colgroup = table.querySelector('colgroup');
|
||||
if (!colgroup) {
|
||||
colgroup = document.createElement('colgroup');
|
||||
table.insertBefore(colgroup, table.firstChild);
|
||||
}
|
||||
|
||||
// Get the first row's cells to measure the widths
|
||||
const cells = table.rows[0].cells;
|
||||
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
const cell = cells[i];
|
||||
|
||||
// Get computed width
|
||||
const width = window.getComputedStyle(cell).width;
|
||||
|
||||
// Check if there's already a <col> for this cell
|
||||
let col = colgroup.children[i] as HTMLElement;
|
||||
if (!col) {
|
||||
col = document.createElement('col');
|
||||
colgroup.appendChild(col);
|
||||
}
|
||||
|
||||
// Set the width
|
||||
col.style.width = width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getActionsForType(typeArg: ITableAction['type'][0]) {
|
||||
const actions: ITableAction[] = [];
|
||||
for (const action of this.dataActions) {
|
||||
@ -476,4 +573,29 @@ export class DeesTable<T> extends DeesElement {
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
handleCellEditing(event: Event, item: T, key: string) {
|
||||
const target = event.target as HTMLElement;
|
||||
|
||||
// Create an input element
|
||||
const input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.value = (item[key] as unknown as string) || '';
|
||||
|
||||
// When the input loses focus or the Enter key is pressed, update the data
|
||||
input.addEventListener('blur', () => {
|
||||
item[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
|
||||
target.innerHTML = input.value; // Update the cell's display
|
||||
});
|
||||
input.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
input.blur(); // This will trigger the blur event handler above
|
||||
}
|
||||
});
|
||||
|
||||
// Replace the cell's content with the input
|
||||
target.innerHTML = '';
|
||||
target.appendChild(input);
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user